Browse Source

Merge branch 'master' into samples_against_master

samples_against_master
Shagen Ogandzhanian 3 years ago
parent
commit
81851831d0
  1. 25
      ci/docker/compose-web/Dockerfile-Basic
  2. 2
      components/build.gradle.kts
  3. 2
      components/gradle.properties
  4. 2
      compose/.run/build extended icons.run.xml
  5. 2
      compose/.run/build.run.xml
  6. 2
      compose/.run/publish (without Android Layout Inspector).run.xml
  7. 5
      compose/README.md
  8. 2
      compose/frameworks/support
  9. 2
      compose/golden
  10. 2
      compose/gradle/wrapper/gradle-wrapper.properties
  11. 2
      compose/prebuilts/androidx/internal
  12. 10
      compose/scripts/downloadAndroidSdk
  13. 2
      compose/scripts/prepare
  14. 2
      examples/web-landing/gradle/wrapper/gradle-wrapper.properties
  15. 178
      examples/web-landing/gradlew.bat
  16. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt
  17. 2
      gradle-plugins/gradle.properties
  18. 4
      templates/desktop-template/build.gradle.kts
  19. 6
      templates/multiplatform-template/build.gradle.kts
  20. 4
      templates/web-template/build.gradle.kts
  21. 15
      tutorials/Context_Menu/README.md
  22. 7
      tutorials/Mouse_Events/README.md
  23. 2
      web/buildSrc/build.gradle.kts
  24. 2
      web/compose-compiler-integration/main-template/build.gradle.kts
  25. 1
      web/core/build.gradle.kts
  26. 169
      web/core/src/jsTest/kotlin/StaticComposableTests.kt
  27. 84
      web/core/src/jsTest/kotlin/css/PositionTests.kt
  28. 4
      web/gradle.properties
  29. 2
      web/gradle/wrapper/gradle-wrapper.properties
  30. 178
      web/gradlew.bat
  31. 2
      web/settings.gradle.kts

25
ci/docker/compose-web/Dockerfile-Basic

@ -6,8 +6,6 @@ RUN echo "dash dash/sh boolean false" | debconf-set-selections
RUN dpkg-reconfigure -f noninteractive dash
RUN dpkg --add-architecture i386 && apt-get update -yqq && apt-get install -y \
firefox \
git \
gnupg2 \
openjdk-11-jdk \
python3 \
@ -15,6 +13,16 @@ RUN dpkg --add-architecture i386 && apt-get update -yqq && apt-get install -y \
unzip \
wget
ARG CHROME_VERSION="google-chrome-stable"
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A6DCF7707EBC211F \
&& echo "deb http://ppa.launchpad.net/ubuntu-mozilla-security/ppa/ubuntu focal main" >> /etc/apt/sources.list.d/mozilla.list \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -yqq \
&& apt-get install -y firefox ${CHROME_VERSION:-google-chrome-stable}
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.29.1/geckodriver-v0.29.1-linux64.tar.gz \
&& tar -xvzf geckodriver-v0.29.1-linux64.tar.gz && mkdir -p /root/.gradle/selenium/gecko &&mv geckodriver /root/.gradle/selenium/gecko
@ -22,18 +30,5 @@ RUN export CHROME_DRIVER_VERSION=$(wget -qO- https://chromedriver.storage.google
&& wget https://chromedriver.storage.googleapis.com/${CHROME_DRIVER_VERSION}/chromedriver_linux64.zip -P ~/tmp \
&& mkdir -p /root/.gradle/selenium/chrome && unzip -d /root/.gradle/selenium/chrome ~/tmp/chromedriver_linux64.zip && rm ~/tmp/chromedriver_linux64.zip
ARG GRADLE_VERSION=7.0.2
RUN wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -P /tmp
RUN unzip -d /opt/gradle /tmp/gradle-${GRADLE_VERSION}-bin.zip
ENV GRADLE_HOME=/opt/gradle/gradle-${GRADLE_VERSION}
ENV PATH=$GRADLE_HOME/bin:$PATH
ARG CHROME_VERSION="google-chrome-stable"
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -yqq && apt-get install -y \
${CHROME_VERSION:-google-chrome-stable}
COPY chrome-no-sandbox /usr/bin/chrome-no-sandbox
COPY gradle.properties /root/.gradle/gradle.properties
RUN chmod u+x /usr/bin/chrome-no-sandbox

2
components/build.gradle.kts

@ -10,7 +10,7 @@ buildscript {
dependencies {
classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion")
// __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.5.21"))
classpath(kotlin("gradle-plugin", version = "1.5.30"))
}
}

2
components/gradle.properties

@ -4,4 +4,4 @@ android.enableJetifier=true
kotlin.code.style=official
# __LATEST_COMPOSE_RELEASE_VERSION__
compose.version=1.0.0-alpha1
compose.version=1.0.0-alpha4-build328

2
compose/.run/build extended icons.run.xml

@ -4,7 +4,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--max-workers=1 -Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb" />
<option name="scriptParameters" value="--max-workers=1 -Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb -Pandroidx.validateProjectStructure=false" />
<option name="taskDescriptions">
<list />
</option>

2
compose/.run/build.run.xml

@ -4,7 +4,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb" />
<option name="scriptParameters" value="-Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb -Pandroidx.validateProjectStructure=false" />
<option name="taskDescriptions">
<list />
</option>

2
compose/.run/publish (without Android Layout Inspector).run.xml

@ -4,7 +4,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb -x :support:compose:ui:ui-inspection:assembleInspectorJarRelease -x :support:compose:ui:ui-inspection:dexInspectorRelease" />
<option name="scriptParameters" value="-Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb -Pandroidx.validateProjectStructure=false -x :support:compose:ui:ui-inspection:assembleInspectorJarRelease -x :support:compose:ui:ui-inspection:dexInspectorRelease" />
<option name="taskDescriptions">
<list />
</option>

5
compose/README.md

@ -15,13 +15,13 @@ git config --global submodule.recurse true
- Java 11 (should be specified in JAVA_HOME)
- [macOs/Linux] Android SDK downloaded via `./scripts/downloadAndroidSdk`
- [Windows] Android SDK downloaded from Android Studio and specified in ANDROID_SDK_ROOT. Required components:
- Android 11
- Android 12
- Build-Tools 30.0.3
- NDK 21.3.6528147 (in folder $androidSdk/ndk, not in $androidSdk/ndk/$version)
- CMake 3.10.2.4988404 (in folder $androidSdk/cmake, not in $androidSdk/cmake/$version)
## Requirements to develop in IDE
- Android Studio Arctic Fox
- Android Studio 2021.1.1 Canary 8 (https://developer.android.com/studio/archive)
- Custom Gradle 7.1 specified in `Settings -> Build, Execution, Deployment -> Build Tools -> Gradle` (because Android Studio will pick the wrong Gradle in the subproject instead of the Gradle in the root project)
- Specified Gradle JDK 11 in `... -> Build Tools -> Gradle`
- Environment variables:
@ -29,7 +29,6 @@ git config --global submodule.recurse true
export ALLOW_PUBLIC_REPOS=1
export JAVA_TOOLS_JAR=$PWD/external/tools.jar
export ANDROIDX_PROJECTS=COMPOSE
export COMPOSE_CUSTOM_GROUP=org.jetbrains.compose
```
- Gradle properties in ~/.gradle/gradle.properties:
```

2
compose/frameworks/support

@ -1 +1 @@
Subproject commit 30f010967cd12643134a80269c7eb2de65b2332b
Subproject commit f9fa0c45f480da2960e20a6007605d974b70cbcc

2
compose/golden

@ -1 +1 @@
Subproject commit 1b20aa551446123340cb42b4eb21d2f2797e608a
Subproject commit 2bc172b3d36904e78780624700c0d188acd83e1a

2
compose/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
compose/prebuilts/androidx/internal

@ -1 +1 @@
Subproject commit 818a882ba70e8603d6a22b17d421c9049926da4c
Subproject commit c93d857e3c972842489c8115fd6d3f2ff8e404e1

10
compose/scripts/downloadAndroidSdk

@ -12,9 +12,11 @@ clone() {
popd
}
# Commit hashes and sdk versions from default.xml (git clone --branch androidx-main https://android.googlesource.com/platform/manifest)
downloadLinuxSDK() {
clone ../prebuilts/fullsdk-linux/platforms/android-30 https://android.googlesource.com/platform/prebuilts/fullsdk/platforms/android-30 master
clone ../prebuilts/fullsdk-linux/sources/android-30 https://android.googlesource.com/platform/prebuilts/fullsdk/sources/android-30 master
clone ../prebuilts/fullsdk-linux/platforms/android-31 https://android.googlesource.com/platform/prebuilts/fullsdk/platforms/android-31 master
clone ../prebuilts/fullsdk-linux/sources/android-31 https://android.googlesource.com/platform/prebuilts/fullsdk/sources/android-31 master
clone ../prebuilts/fullsdk-linux/ndk https://android.googlesource.com/toolchain/prebuilts/ndk/r21 master
clone ../prebuilts/fullsdk-linux/build-tools/30.0.3 https://android.googlesource.com/platform/prebuilts/fullsdk-linux/build-tools/30.0.3 master
clone ../prebuilts/fullsdk-linux/platform-tools https://android.googlesource.com/platform/prebuilts/fullsdk-linux/platform-tools master
@ -23,8 +25,8 @@ downloadLinuxSDK() {
}
downloadMacOsSDK() {
clone ../prebuilts/fullsdk-darwin/platforms/android-30 https://android.googlesource.com/platform/prebuilts/fullsdk/platforms/android-30 master
clone ../prebuilts/fullsdk-darwin/sources/android-30 https://android.googlesource.com/platform/prebuilts/fullsdk/sources/android-30 master
clone ../prebuilts/fullsdk-darwin/platforms/android-31 https://android.googlesource.com/platform/prebuilts/fullsdk/platforms/android-31 master
clone ../prebuilts/fullsdk-darwin/sources/android-31 https://android.googlesource.com/platform/prebuilts/fullsdk/sources/android-31 master
clone ../prebuilts/fullsdk-darwin/ndk https://android.googlesource.com/toolchain/prebuilts/ndk-darwin/r21 master
clone ../prebuilts/fullsdk-darwin/build-tools/30.0.3 https://android.googlesource.com/platform/prebuilts/fullsdk-darwin/build-tools/30.0.3 master
clone ../prebuilts/fullsdk-darwin/platform-tools https://android.googlesource.com/platform/prebuilts/fullsdk-darwin/platform-tools master

2
compose/scripts/prepare

@ -6,4 +6,4 @@ export ALLOW_PUBLIC_REPOS=1
export JAVA_TOOLS_JAR=$SCRIPT_DIR/../external/tools.jar
export ANDROIDX_PROJECTS=COMPOSE
export COMPOSE_CUSTOM_GROUP=org.jetbrains.compose
export COMPOSE_DEFAULT_GRADLE_ARGS="-Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb -Pandroidx.compose.jsCompilerTestsEnabled=true"
export COMPOSE_DEFAULT_GRADLE_ARGS="-Pandroidx.compose.multiplatformEnabled=true -Pandroidx.versionExtraCheckEnabled=false -Pandroidx.alternativeProjectUrl=https://github.com/JetBrains/compose-jb -Pandroidx.compose.jsCompilerTestsEnabled=true -Pandroidx.validateProjectStructure=false"

2
examples/web-landing/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

178
examples/web-landing/gradlew.bat vendored

@ -1,89 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt

@ -8,6 +8,6 @@ package org.jetbrains.compose.test
@Suppress("EnumEntryName")
enum class TestKotlinVersion(val versionString: String) {
// __KOTLIN_COMPOSE_VERSION__
Default("1.5.21"),
Default("1.5.30"),
V1_5_20("1.5.20")
}

2
gradle-plugins/gradle.properties

@ -6,7 +6,7 @@ kotlin.code.style=official
# unless overridden by COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION env var.
#
# __LATEST_COMPOSE_RELEASE_VERSION__
compose.version=0.5.0-build262
compose.version=1.0.0-alpha4-build328
compose.with.web=false
# A version of Gradle plugin, that will be published,

4
templates/desktop-template/build.gradle.kts

@ -3,9 +3,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
// __KOTLIN_COMPOSE_VERSION__
kotlin("jvm") version "1.5.21"
kotlin("jvm") version "1.5.30"
// __LATEST_COMPOSE_RELEASE_VERSION__
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha1")
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha4-build328")
}
repositories {

6
templates/multiplatform-template/build.gradle.kts

@ -1,6 +1,6 @@
buildscript {
// __LATEST_COMPOSE_RELEASE_VERSION__
val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha1"
val composeVersion = System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha4-build328"
repositories {
mavenCentral()
@ -10,9 +10,9 @@ buildscript {
dependencies {
classpath("org.jetbrains.compose:compose-gradle-plugin:$composeVersion")
classpath("com.android.tools.build:gradle:4.0.1")
classpath("com.android.tools.build:gradle:4.1.3")
// __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.5.21"))
classpath(kotlin("gradle-plugin", version = "1.5.30"))
}
}

4
templates/web-template/build.gradle.kts

@ -3,9 +3,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
// __KOTLIN_COMPOSE_VERSION__
kotlin("multiplatform") version "1.5.21"
kotlin("multiplatform") version "1.5.30"
// __LATEST_COMPOSE_RELEASE_VERSION__
id("org.jetbrains.compose") version ("1.0.0-alpha1")
id("org.jetbrains.compose") version ("1.0.0-alpha4-build328")
}
repositories {

15
tutorials/Context_Menu/README.md

@ -60,6 +60,7 @@ To enable additional context menu items for TextField and Text components, Conte
```kotlin
import androidx.compose.desktop.DesktopMaterialTheme
import androidx.compose.foundation.ContextMenuDataProvider
import androidx.compose.foundation.ContextMenuItem
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
@ -70,14 +71,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ContextMenuItem
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.singleWindowApplication
@OptIn(ExperimentalComposeUiApi::class, androidx.compose.foundation.ExperimentalFoundationApi::class)
fun main() = singleWindowApplication(title = "Context menu") {
DesktopMaterialTheme { //it is mandatory for Context Menu
val text = remember {mutableStateOf("Hello!")}
DesktopMaterialTheme { //it is mandatory for Context Menu
val text = remember {mutableStateOf("Hello!")}
Column {
ContextMenuDataProvider(
items = {
@ -100,7 +100,7 @@ fun main() = singleWindowApplication(title = "Context menu") {
}
}
}
}
}
}
```
In this example Text/TextField context menus will be extended with two additional items.
@ -109,9 +109,9 @@ In this example Text/TextField context menus will be extended with two additiona
There is a possibility to create a context menu for an arbitrary application window area. This is implemented using ContextMenuArea API that is
similar to ContextMenuDataProvider.
```kotlin
import androidx.compose.desktop.DesktopMaterialTheme
import androidx.compose.foundation.ContextMenuArea
import androidx.compose.foundation.ContextMenuItem
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
@ -119,13 +119,12 @@ import androidx.compose.foundation.layout.width
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ContextMenuItem
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.singleWindowApplication
@OptIn(ExperimentalComposeUiApi::class, androidx.compose.foundation.ExperimentalFoundationApi::class)
fun main() = singleWindowApplication(title = "Context menu") {
DesktopMaterialTheme { //it is mandatory for Context Menu
DesktopMaterialTheme { //it is mandatory for Context Menu
ContextMenuArea(items = {
listOf(
ContextMenuItem("User-defined Action") {/*do something here*/},
@ -135,7 +134,7 @@ fun main() = singleWindowApplication(title = "Context menu") {
Box(modifier = Modifier.background(Color.Blue).height(100.dp).width(100.dp)) {
}
}
}
}
}
```
Right click on the Blue Square will show a context menu with two items

7
tutorials/Mouse_Events/README.md

@ -167,6 +167,13 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.isAltPressed
import androidx.compose.ui.input.pointer.isCtrlPressed
import androidx.compose.ui.input.pointer.isMetaPressed
import androidx.compose.ui.input.pointer.isPrimaryPressed
import androidx.compose.ui.input.pointer.isSecondaryPressed
import androidx.compose.ui.input.pointer.isShiftPressed
import androidx.compose.ui.input.pointer.isTertiaryPressed
import androidx.compose.ui.window.singleWindowApplication
@OptIn(ExperimentalDesktopApi::class)

2
web/buildSrc/build.gradle.kts

@ -10,5 +10,5 @@ repositories {
}
plugins {
id("org.jetbrains.kotlin.jvm") version "1.5.21"
id("org.jetbrains.kotlin.jvm") version "1.5.30"
}

2
web/compose-compiler-integration/main-template/build.gradle.kts

@ -1,5 +1,5 @@
plugins {
kotlin("multiplatform") version "1.5.21"
kotlin("multiplatform") version "1.5.30"
id("org.jetbrains.compose")
}

1
web/core/build.gradle.kts

@ -1,5 +1,4 @@
plugins {
//id("kotlin-multiplatform")
kotlin("multiplatform")
id("org.jetbrains.compose")
}

169
web/core/src/jsTest/kotlin/StaticComposableTests.kt

@ -2,43 +2,29 @@ package org.jetbrains.compose.web.core.tests
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.Div
import org.jetbrains.compose.web.dom.Span
import org.jetbrains.compose.web.dom.Text
import org.jetbrains.compose.web.renderComposable
import org.w3c.dom.HTMLElement
import org.w3c.dom.get
import org.jetbrains.compose.web.testutils.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import org.jetbrains.compose.web.testutils.*
class StaticComposableTests {
@Test
fun emptyComposable() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {}
fun emptyComposable() = runTest {
composition {}
assertEquals("<div></div>", root.outerHTML)
}
@Test
fun textChild() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
fun textChild() = runTest {
composition {
Text("inner text")
}
assertEquals("<div>inner text</div>", root.outerHTML)
}
@Test
fun attrs() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
fun attrs() = runTest {
composition {
Div(
attrs = {
classes("some", "simple", "classes")
@ -50,8 +36,7 @@ class StaticComposableTests {
)
}
val el = root.firstChild
assertTrue(el is HTMLElement, "element not found")
val el = nextChild()
assertEquals("verySpecial", el.getAttribute("id"))
assertEquals("some simple classes", el.getAttribute("class"))
@ -59,11 +44,8 @@ class StaticComposableTests {
}
@Test
fun styles() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
fun styles() = runTest {
composition {
Div(
{
style {
@ -76,135 +58,6 @@ class StaticComposableTests {
)
}
assertEquals("opacity: 0.2; color: green;", (root.children[0] as HTMLElement).style.cssText)
}
@Test
fun stylesTop() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
Div(
{
style {
top(100.px)
}
}
)
Div(
{
style {
top(100.percent)
}
}
)
}
assertEquals("top: 100px;", (root.children[0] as HTMLElement).style.cssText)
assertEquals("top: 100%;", (root.children[1] as HTMLElement).style.cssText)
}
@Test
fun stylesBottom() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
Div(
{
style {
bottom(100.px)
}
}
)
Div(
{
style {
bottom(100.percent)
}
}
)
}
assertEquals("bottom: 100px;", (root.children[0] as HTMLElement).style.cssText)
assertEquals("bottom: 100%;", (root.children[1] as HTMLElement).style.cssText)
}
@Test
fun stylesLeft() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
Div(
{
style {
left(100.px)
}
}
)
Div(
{
style {
left(100.percent)
}
}
)
}
assertEquals("left: 100px;", (root.children[0] as HTMLElement).style.cssText)
assertEquals("left: 100%;", (root.children[1] as HTMLElement).style.cssText)
}
@Test
fun stylesRight() {
val root = "div".asHtmlElement()
renderComposable(
root = root
) {
Div(
{
style {
right(100.px)
}
}
)
Div(
{
style {
right(100.percent)
}
}
)
}
assertEquals("right: 100px;", (root.children[0] as HTMLElement).style.cssText)
assertEquals("right: 100%;", (root.children[1] as HTMLElement).style.cssText)
}
@Test
fun stylesPosition() = runTest {
val enumValues = Position.values()
composition {
enumValues.forEach { position ->
Span(
{
style {
position(position)
}
}
)
}
}
enumValues.forEachIndexed { index, position ->
assertEquals(
"position: ${position.value};",
nextChild().style.cssText
)
}
assertEquals("opacity: 0.2; color: green;", nextChild().style.cssText)
}
}

84
web/core/src/jsTest/kotlin/css/PositionTests.kt

@ -0,0 +1,84 @@
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.web.core.tests.css
import org.jetbrains.compose.web.core.tests.values
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.Div
import org.jetbrains.compose.web.dom.Span
import org.jetbrains.compose.web.testutils.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
class PositionTests {
@Test
fun stylesTop() = runTest {
composition {
Div({ style { top(100.px) } })
Div({ style { top(100.percent) } })
}
assertEquals("100px", nextChild().style.top)
assertEquals("100%", nextChild().style.top)
}
@Test
fun stylesBottom() = runTest {
composition {
Div({ style { bottom(100.px) } })
Div({ style { bottom(100.percent) } })
}
assertEquals("100px", nextChild().style.bottom)
assertEquals("100%", nextChild().style.bottom)
}
@Test
fun stylesLeft() = runTest {
composition {
Div({ style { left(100.px) } })
Div({ style { left(100.percent) } })
}
assertEquals("100px", nextChild().style.left)
assertEquals("100%", nextChild().style.left)
}
@Test
fun stylesRight() = runTest {
composition {
Div({ style { right(100.px) } })
Div({ style { right(100.percent) } })
}
assertEquals("100px", nextChild().style.right)
assertEquals("100%", nextChild().style.right)
}
@Test
fun stylesPosition() = runTest {
val enumValues = Position.values()
composition {
enumValues.forEach { position ->
Span(
{
style {
position(position)
}
}
)
}
}
enumValues.forEachIndexed { index, position ->
assertEquals(
"position: ${position.value};",
nextChild().style.cssText
)
}
}
}

4
web/gradle.properties

@ -1,6 +1,6 @@
# __LATEST_COMPOSE_RELEASE_VERSION__
COMPOSE_CORE_VERSION=1.0.0-alpha4-build321
COMPOSE_WEB_VERSION=1.0.0-alpha4
COMPOSE_CORE_VERSION=1.0.0-alpha4-build328
COMPOSE_WEB_VERSION=1.0.0-alpha4-build328
compose.web.buildSamples=false
compose.web.tests.integration.withFirefox
compose.web.tests.skip.benchmarks=false

2
web/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

178
web/gradlew.bat vendored

@ -1,89 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

2
web/settings.gradle.kts

@ -18,7 +18,7 @@ pluginManagement {
println("[build] compose core version: ${extra["COMPOSE_CORE_VERSION"]}")
useModule("org.jetbrains.compose:org.jetbrains.compose.gradle.plugin:${extra["COMPOSE_CORE_VERSION"]}")
} else if (requested.id.id == "org.jetbrains.kotlin.multiplatform") {
useModule("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:1.5.21")
useModule("org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:1.5.30")
}
}
}

Loading…
Cancel
Save