Merge pull request #57 from InsanusMokrassar/0.1.2

0.1.2
This commit is contained in:
InsanusMokrassar 2022-05-19 02:13:29 -04:00 committed by GitHub
commit deb30957ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 58 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
## 0.1.2
* New typealias `AttrsWithContentBuilder`
* Old `DList` and related composable functions removed (they are built-in in compose)
## 0.1.1 ## 0.1.1
* `Compose`: `1.2.0-alpha01-dev686` * `Compose`: `1.2.0-alpha01-dev686`

View File

@ -9,4 +9,4 @@ android.enableJetifier=true
# Project data # Project data
group=dev.inmo group=dev.inmo
version=0.1.1 version=0.1.2

View File

@ -4,8 +4,7 @@ import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitDescriptionList import dev.inmo.jsuikit.modifiers.UIKitDescriptionList
import dev.inmo.jsuikit.modifiers.include import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.* import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.dom.ContentBuilder import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.dom.ElementScope
import org.w3c.dom.HTMLDListElement import org.w3c.dom.HTMLDListElement
import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLElement

View File

@ -0,0 +1,15 @@
package dev.inmo.jsuikit.utils
import org.jetbrains.compose.web.dom.ContentBuilder
import org.w3c.dom.Element
typealias AttrsWithContentBuilder<T> = Pair<Attrs<T>, ContentBuilder<T>>
inline val <T : Element> AttrsWithContentBuilder<T>.attrs
get() = first
inline val <T : Element> AttrsWithContentBuilder<T>.attributesBuilderContext
get() = attrs.builder
inline val <T : Element> AttrsWithContentBuilder<T>.builder
get() = second

View File

@ -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<HTMLDListElement> {
private val el: Element by lazy { document.createElement("dl") }
override fun create(): HTMLDListElement = el.cloneNode() as HTMLDListElement
}
private object DTermElementBuilder : ElementBuilder<HTMLElement> {
private val el: Element by lazy { document.createElement("dt") }
override fun create(): HTMLElement = el.cloneNode() as HTMLElement
}
private object DDescriptionElementBuilder : ElementBuilder<HTMLElement> {
private val el: Element by lazy { document.createElement("dd") }
override fun create(): HTMLElement = el.cloneNode() as HTMLElement
}
@Composable
fun DList(
attrs: AttrBuilderContext<HTMLDListElement>? = null,
content: ContentBuilder<HTMLDListElement>? = null
) {
TagElement(
DListElementBuilder,
attrs,
content
)
}
@Composable
fun DTerm(
attrs: AttrBuilderContext<HTMLElement>? = null,
content: ContentBuilder<HTMLElement>? = null
) {
TagElement(
DTermElementBuilder,
attrs,
content
)
}
@Composable
fun DDescription(
attrs: AttrBuilderContext<HTMLElement>? = null,
content: ContentBuilder<HTMLElement>? = null
) {
TagElement(
DDescriptionElementBuilder,
attrs,
content
)
}