From 9b992cbda07d49e27db149a4398c5ca0a8d8b2b2 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 12:10:49 +0600 Subject: [PATCH 1/2] start 0.1.2 --- CHANGELOG.md | 2 ++ gradle.properties | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce766bc..63c9038 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.1.2 + ## 0.1.1 * `Compose`: `1.2.0-alpha01-dev686` diff --git a/gradle.properties b/gradle.properties index ccd9957..5053701 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ android.enableJetifier=true # Project data group=dev.inmo -version=0.1.1 +version=0.1.2 From 276eaddcac25f14f498c2dd08e5cb2f8fb5e9244 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 19 May 2022 12:13:13 +0600 Subject: [PATCH 2/2] Remove redundant DList and other + add AttrsWithContentBuilder --- CHANGELOG.md | 3 + .../inmo/jsuikit/elements/DescriptionList.kt | 3 +- .../jsuikit/utils/AttrsWithContentBuilder.kt | 15 +++++ .../kotlin/dev/inmo/jsuikit/utils/Dlist.kt | 55 ------------------- 4 files changed, 19 insertions(+), 57 deletions(-) create mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt delete mode 100644 src/jsMain/kotlin/dev/inmo/jsuikit/utils/Dlist.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 63c9038..411493a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.1.2 +* New typealias `AttrsWithContentBuilder` +* Old `DList` and related composable functions removed (they are built-in in compose) + ## 0.1.1 * `Compose`: `1.2.0-alpha01-dev686` diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DescriptionList.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DescriptionList.kt index 7510e94..b7c3818 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DescriptionList.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DescriptionList.kt @@ -4,8 +4,7 @@ import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.UIKitDescriptionList import dev.inmo.jsuikit.modifiers.include import dev.inmo.jsuikit.utils.* -import org.jetbrains.compose.web.dom.ContentBuilder -import org.jetbrains.compose.web.dom.ElementScope +import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLDListElement import org.w3c.dom.HTMLElement diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt new file mode 100644 index 0000000..5bef24b --- /dev/null +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttrsWithContentBuilder.kt @@ -0,0 +1,15 @@ +package dev.inmo.jsuikit.utils + +import org.jetbrains.compose.web.dom.ContentBuilder +import org.w3c.dom.Element + +typealias AttrsWithContentBuilder = Pair, ContentBuilder> + +inline val AttrsWithContentBuilder.attrs + get() = first + +inline val AttrsWithContentBuilder.attributesBuilderContext + get() = attrs.builder + +inline val AttrsWithContentBuilder.builder + get() = second diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/Dlist.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/Dlist.kt deleted file mode 100644 index c886d2c..0000000 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/Dlist.kt +++ /dev/null @@ -1,55 +0,0 @@ -package dev.inmo.jsuikit.utils - -import androidx.compose.runtime.Composable -import kotlinx.browser.document -import org.jetbrains.compose.web.dom.* -import org.w3c.dom.* - -private object DListElementBuilder : ElementBuilder { - private val el: Element by lazy { document.createElement("dl") } - override fun create(): HTMLDListElement = el.cloneNode() as HTMLDListElement -} - -private object DTermElementBuilder : ElementBuilder { - private val el: Element by lazy { document.createElement("dt") } - override fun create(): HTMLElement = el.cloneNode() as HTMLElement -} - -private object DDescriptionElementBuilder : ElementBuilder { - private val el: Element by lazy { document.createElement("dd") } - override fun create(): HTMLElement = el.cloneNode() as HTMLElement -} - -@Composable -fun DList( - attrs: AttrBuilderContext? = null, - content: ContentBuilder? = null -) { - TagElement( - DListElementBuilder, - attrs, - content - ) -} -@Composable -fun DTerm( - attrs: AttrBuilderContext? = null, - content: ContentBuilder? = null -) { - TagElement( - DTermElementBuilder, - attrs, - content - ) -} -@Composable -fun DDescription( - attrs: AttrBuilderContext? = null, - content: ContentBuilder? = null -) { - TagElement( - DDescriptionElementBuilder, - attrs, - content - ) -}