diff --git a/CHANGELOG.md b/CHANGELOG.md index feee5bf..34ad16d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.0.42 + +* Migration to compose 1.1.0 +* Replaces according to it + ## 0.0.41 * Add `DropArea` diff --git a/gradle.properties b/gradle.properties index 9c57a62..cbd324d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ android.enableJetifier=true # Project data group=dev.inmo -version=0.0.41 +version=0.0.42 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 16e01c2..c9e6fc3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] kt = "1.6.10" -jb-compose = "1.0.1" +jb-compose = "1.1.0" jb-dokka = "1.6.10" gh-release = "2.2.12" diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/UIKitAttributeValueBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/UIKitAttributeValueBuilder.kt index e454721..cbfee2c 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/UIKitAttributeValueBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/UIKitAttributeValueBuilder.kt @@ -3,7 +3,7 @@ package dev.inmo.jsuikit import dev.inmo.jsuikit.modifiers.AttributeValue import dev.inmo.jsuikit.utils.AttributeBuilder import dev.inmo.jsuikit.utils.buildAttribute -import org.jetbrains.compose.web.attributes.AttrsBuilder +import org.jetbrains.compose.web.attributes.AttrsScope @Deprecated("Will be removed soon") class UIKitAttributeValueBuilder { @@ -22,7 +22,7 @@ class UIKitAttributeValueBuilder { fun build(): String = attrs.joinToString(";") { (k, v) -> "$k: $v" } } -fun AttrsBuilder<*>.buildAndAddAttribute( +fun AttrsScope<*>.buildAndAddAttribute( attributeName: String, skipNullValues: Boolean = true, block: AttributeBuilder.() -> Unit diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Accordion.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Accordion.kt index 9d91b34..f3f074b 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Accordion.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Accordion.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.UIKitAccordion import dev.inmo.jsuikit.modifiers.include import dev.inmo.jsuikit.utils.Attrs -import org.jetbrains.compose.web.attributes.AttrsBuilder +import org.jetbrains.compose.web.attributes.AttrsScope import org.jetbrains.compose.web.dom.* import org.w3c.dom.* @@ -12,7 +12,7 @@ import org.w3c.dom.* fun Accordion( data: Iterable, attrs: Attrs = Attrs.empty(), - itemAttrsBuilder: AttrsBuilder.(Int, T) -> Unit = { _, _ -> }, + itemAttrsBuilder: AttrsScope.(Int, T) -> Unit = { _, _ -> }, itemContentBuilder: @Composable ElementScope.(Int, T) -> Unit ) { Ul( @@ -33,13 +33,13 @@ fun Accordion( fun DefaultAccordion( data: Iterable, attrs: Attrs = Attrs.empty(), - itemAttrsBuilder: AttrsBuilder.(Int, T) -> Unit = { _, _ -> }, - titleAttrsBuilder: AttrsBuilder.(Int, T) -> Unit = { _, _ -> }, + itemAttrsBuilder: AttrsScope.(Int, T) -> Unit = { _, _ -> }, + titleAttrsBuilder: AttrsScope.(Int, T) -> Unit = { _, _ -> }, titleContentBuilder: @Composable ElementScope.(Int, T) -> Unit = { _, _ -> }, beforeTitleContentBuilder: @Composable ElementScope.(Int, T) -> Unit = { _, _ -> }, afterTitleContentBuilder: @Composable ElementScope.(Int, T) -> Unit = { _, _ -> }, afterContentContentBuilder: @Composable ElementScope.(Int, T) -> Unit = { _, _ -> }, - contentAttrsBuilder: AttrsBuilder.(Int, T) -> Unit = { _, _ -> }, + contentAttrsBuilder: AttrsScope.(Int, T) -> Unit = { _, _ -> }, contentContentBuilder: @Composable ElementScope.(Int, T) -> Unit ) = Accordion( data, @@ -72,9 +72,9 @@ fun DefaultAccordion( data: Iterable, titleResolver: (Int, T) -> String, attrs: Attrs = Attrs.empty(), - itemAttrsBuilder: AttrsBuilder.(Int, T) -> Unit = { _, _ -> }, - titleAttrsBuilder: AttrsBuilder.(Int, T) -> Unit = { _, _ -> }, - contentAttrsBuilder: AttrsBuilder.(Int, T) -> Unit = { _, _ -> }, + itemAttrsBuilder: AttrsScope.(Int, T) -> Unit = { _, _ -> }, + titleAttrsBuilder: AttrsScope.(Int, T) -> Unit = { _, _ -> }, + contentAttrsBuilder: AttrsScope.(Int, T) -> Unit = { _, _ -> }, contentContentBuilder: @Composable ElementScope.(Int, T) -> Unit ) = DefaultAccordion( data, diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt index b431672..679cd97 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt @@ -4,7 +4,8 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.utils.Attrs import org.jetbrains.compose.web.dom.* -import org.w3c.dom.* +import org.w3c.dom.HTMLDivElement +import org.w3c.dom.HTMLHeadingElement @Composable fun Card( diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt index 0fa23ac..60fe10e 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt @@ -4,8 +4,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffectResult import dev.inmo.jsuikit.modifiers.* import org.jetbrains.compose.web.dom.* -import org.jetbrains.compose.web.dom.Text -import org.w3c.dom.* +import org.w3c.dom.HTMLDivElement +import org.w3c.dom.HTMLElement import org.w3c.dom.events.Event import kotlin.random.Random import kotlin.random.nextUInt diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt index ec24ed4..1a18195 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt @@ -4,10 +4,8 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.utils.Attrs import dev.inmo.jsuikit.utils.InputAttrs -import org.jetbrains.compose.web.attributes.InputType import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLDivElement -import org.w3c.dom.HTMLInputElement @Composable fun DropArea( diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dropdown.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dropdown.kt index 7d40b0f..43b1751 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dropdown.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dropdown.kt @@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.buildAndAddAttribute import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.utils.Milliseconds -import dev.inmo.jsuikit.utils.buildAttribute import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLDivElement diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Labels.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Labels.kt index 4db71ca..d063ff8 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Labels.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Labels.kt @@ -1,9 +1,11 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable -import dev.inmo.jsuikit.modifiers.* +import dev.inmo.jsuikit.modifiers.UIKitLabel +import dev.inmo.jsuikit.modifiers.include import dev.inmo.jsuikit.utils.Attrs -import org.jetbrains.compose.web.dom.* +import org.jetbrains.compose.web.dom.Span +import org.jetbrains.compose.web.dom.Text import org.w3c.dom.HTMLSpanElement @Composable diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt index 3cd40f2..184293a 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/NavbarNavBuilder.kt @@ -3,21 +3,21 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.UIKitModifier import dev.inmo.jsuikit.modifiers.include -import org.jetbrains.compose.web.attributes.AttrsBuilder +import org.jetbrains.compose.web.attributes.AttrsScope import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLLIElement import org.w3c.dom.HTMLUListElement interface NavbarNavElement { - fun AttrsBuilder.setup() {} + fun AttrsScope.setup() {} @Composable fun ElementScope.fill() class Default( - private val setupCallback: AttrsBuilder.() -> Unit, + private val setupCallback: AttrsScope.() -> Unit, private val fillCallback: @Composable ElementScope.() -> Unit ) : NavbarNavElement { - override fun AttrsBuilder.setup() { + override fun AttrsScope.setup() { setupCallback() } diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Notification.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Notification.kt index 6e95fcf..cbb7d8d 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Notification.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Notification.kt @@ -1,9 +1,7 @@ package dev.inmo.jsuikit.elements import dev.inmo.jsuikit.modifiers.UIKit -import dev.inmo.jsuikit.types.UIKitNotificationParameter -import dev.inmo.jsuikit.types.NotificationsGroup -import dev.inmo.jsuikit.types.invoke +import dev.inmo.jsuikit.types.* import dev.inmo.jsuikit.utils.Milliseconds fun Notification( diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt index 28e7857..c85d81f 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt @@ -1,9 +1,9 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable -import androidx.compose.runtime.snapshots.SnapshotStateList -import dev.inmo.jsuikit.modifiers.* -import org.jetbrains.compose.web.attributes.AttrsBuilder +import dev.inmo.jsuikit.modifiers.UIKitModifier +import dev.inmo.jsuikit.modifiers.include +import org.jetbrains.compose.web.attributes.AttrsScope import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.Text import org.w3c.dom.* @@ -15,9 +15,9 @@ fun DefaultTable( vararg tableModifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, headerCustomizer: AttrBuilderContext = {}, - headerCellCustomizer: AttrsBuilder.(i: Int) -> Unit = {}, - rowAttributes: AttrsBuilder.(t: T) -> Unit = {}, - cellCustomizer: AttrsBuilder.(i: Int, t: T) -> Unit = { _, _ -> }, + headerCellCustomizer: AttrsScope.(i: Int) -> Unit = {}, + rowAttributes: AttrsScope.(t: T) -> Unit = {}, + cellCustomizer: AttrsScope.(i: Int, t: T) -> Unit = { _, _ -> }, betweenHeaderAndBodyFiller: ContentBuilder = {}, cellFiller: @Composable ElementScope.(i: Int, t: T) -> Unit ) { @@ -72,14 +72,14 @@ fun DefaultTable( vararg tableModifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, headerCustomizer: AttrBuilderContext = {}, - headerCellCustomizer: AttrsBuilder.(i: Int, title: String) -> Unit = { _, _ -> }, - rowAttributes: AttrsBuilder.(t: T) -> Unit = {}, - cellCustomizer: AttrsBuilder.(i: Int, t: T) -> Unit = { _, _ -> }, + headerCellCustomizer: AttrsScope.(i: Int, title: String) -> Unit = { _, _ -> }, + rowAttributes: AttrsScope.(t: T) -> Unit = {}, + cellCustomizer: AttrsScope.(i: Int, t: T) -> Unit = { _, _ -> }, betweenHeaderAndBodyFiller: ContentBuilder = {}, cellFiller: @Composable ElementScope.(i: Int, t: T) -> Unit ) { val headersByIndex = heading.mapIndexed { index, s -> index to s }.toMap() - val headerCellCustomizer: AttrsBuilder.(i: Int) -> Unit = { i -> + val headerCellCustomizer: AttrsScope.(i: Int) -> Unit = { i -> val header = headersByIndex[i] if (header != null) { headerCellCustomizer(i, header) diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAccordion.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAccordion.kt index abecd54..42d2f42 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAccordion.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitAccordion.kt @@ -1,6 +1,7 @@ package dev.inmo.jsuikit.modifiers -import dev.inmo.jsuikit.utils.* +import dev.inmo.jsuikit.utils.Milliseconds +import dev.inmo.jsuikit.utils.buildAttribute import org.w3c.dom.PageTransitionEvent sealed class UIKitAccordion( diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitHeight.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitHeight.kt index 8fe6513..900f30c 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitHeight.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitHeight.kt @@ -1,7 +1,6 @@ package dev.inmo.jsuikit.modifiers import dev.inmo.jsuikit.utils.* -import org.jetbrains.compose.web.css.CSSKeyframe sealed class UIKitHeight( classname: String?, diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt index 983a553..0e826e0 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitModifier.kt @@ -1,6 +1,6 @@ package dev.inmo.jsuikit.modifiers -import org.jetbrains.compose.web.attributes.AttrsBuilder +import org.jetbrains.compose.web.attributes.AttrsScope interface UIKitModifier { val classes: Array @@ -9,7 +9,7 @@ interface UIKitModifier { get() = emptyMap() } -fun AttrsBuilder<*>.include(vararg container: UIKitModifier?) { +fun AttrsScope<*>.include(vararg container: UIKitModifier?) { container.forEach { it ?.classes ?.let { newClasses -> classes(*newClasses) } it ?.otherAttrs ?.let { attrs -> attrs.forEach { (k, v) -> attr(k, v) } } diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/types/UIKitNotifications.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/types/UIKitNotifications.kt index adff565..a5343da 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/types/UIKitNotifications.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/types/UIKitNotifications.kt @@ -2,8 +2,6 @@ package dev.inmo.jsuikit.types import dev.inmo.jsuikit.modifiers.UIKit import dev.inmo.jsuikit.utils.Milliseconds -import org.w3c.dom.Element -import kotlin.js.Json import kotlin.js.json typealias NotificationsGroup = String diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt index 38c7f6b..13d3ca8 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt @@ -2,14 +2,12 @@ package dev.inmo.jsuikit.utils import dev.inmo.jsuikit.modifiers.UIKitModifier import dev.inmo.jsuikit.modifiers.include -import org.jetbrains.compose.web.attributes.AttrsBuilder -import org.jetbrains.compose.web.attributes.InputType -import org.jetbrains.compose.web.attributes.builders.InputAttrsBuilder -import org.jetbrains.compose.web.dom.AttrBuilderContext +import org.jetbrains.compose.web.attributes.AttrsScope +import org.jetbrains.compose.web.attributes.builders.InputAttrsScope import org.w3c.dom.Element import org.w3c.dom.HTMLInputElement -class AttributesCollection> ( +class AttributesCollection> ( private vararg val modifiers: UIKitModifier?, private val attrs: Builder.() -> Unit = {} ) { @@ -29,9 +27,9 @@ class AttributesCollection> ( val Empty = Attrs() @Suppress("UNCHECKED_CAST") - fun > empty() = Empty as AttributesCollection + fun > empty() = Empty as AttributesCollection } } -typealias Attrs = AttributesCollection> -typealias InputAttrs = AttributesCollection> +typealias Attrs = AttributesCollection> +typealias InputAttrs = AttributesCollection>