Merge pull request #43 from InsanusMokrassar/0.0.42

0.0.42
This commit is contained in:
InsanusMokrassar 2022-03-06 16:23:38 +06:00 committed by GitHub
commit af289b3194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 50 additions and 51 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
## 0.0.42
* Migration to compose 1.1.0
* Replaces according to it
## 0.0.41 ## 0.0.41
* Add `DropArea` * Add `DropArea`

View File

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

View File

@ -1,7 +1,7 @@
[versions] [versions]
kt = "1.6.10" kt = "1.6.10"
jb-compose = "1.0.1" jb-compose = "1.1.0"
jb-dokka = "1.6.10" jb-dokka = "1.6.10"
gh-release = "2.2.12" gh-release = "2.2.12"

View File

@ -3,7 +3,7 @@ package dev.inmo.jsuikit
import dev.inmo.jsuikit.modifiers.AttributeValue import dev.inmo.jsuikit.modifiers.AttributeValue
import dev.inmo.jsuikit.utils.AttributeBuilder import dev.inmo.jsuikit.utils.AttributeBuilder
import dev.inmo.jsuikit.utils.buildAttribute 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") @Deprecated("Will be removed soon")
class UIKitAttributeValueBuilder { class UIKitAttributeValueBuilder {
@ -22,7 +22,7 @@ class UIKitAttributeValueBuilder {
fun build(): String = attrs.joinToString(";") { (k, v) -> "$k: $v" } fun build(): String = attrs.joinToString(";") { (k, v) -> "$k: $v" }
} }
fun AttrsBuilder<*>.buildAndAddAttribute( fun AttrsScope<*>.buildAndAddAttribute(
attributeName: String, attributeName: String,
skipNullValues: Boolean = true, skipNullValues: Boolean = true,
block: AttributeBuilder.() -> Unit block: AttributeBuilder.() -> Unit

View File

@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitAccordion import dev.inmo.jsuikit.modifiers.UIKitAccordion
import dev.inmo.jsuikit.modifiers.include import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.Attrs 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.jetbrains.compose.web.dom.*
import org.w3c.dom.* import org.w3c.dom.*
@ -12,7 +12,7 @@ import org.w3c.dom.*
fun <T> Accordion( fun <T> Accordion(
data: Iterable<T>, data: Iterable<T>,
attrs: Attrs<HTMLUListElement> = Attrs.empty(), attrs: Attrs<HTMLUListElement> = Attrs.empty(),
itemAttrsBuilder: AttrsBuilder<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> }, itemAttrsBuilder: AttrsScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
itemContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit itemContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit
) { ) {
Ul( Ul(
@ -33,13 +33,13 @@ fun <T> Accordion(
fun <T> DefaultAccordion( fun <T> DefaultAccordion(
data: Iterable<T>, data: Iterable<T>,
attrs: Attrs<HTMLUListElement> = Attrs.empty(), attrs: Attrs<HTMLUListElement> = Attrs.empty(),
itemAttrsBuilder: AttrsBuilder<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> }, itemAttrsBuilder: AttrsScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
titleAttrsBuilder: AttrsBuilder<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> }, titleAttrsBuilder: AttrsScope<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
titleContentBuilder: @Composable ElementScope<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> }, titleContentBuilder: @Composable ElementScope<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
beforeTitleContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> }, beforeTitleContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
afterTitleContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> }, afterTitleContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
afterContentContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> }, afterContentContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
contentAttrsBuilder: AttrsBuilder<HTMLDivElement>.(Int, T) -> Unit = { _, _ -> }, contentAttrsBuilder: AttrsScope<HTMLDivElement>.(Int, T) -> Unit = { _, _ -> },
contentContentBuilder: @Composable ElementScope<HTMLDivElement>.(Int, T) -> Unit contentContentBuilder: @Composable ElementScope<HTMLDivElement>.(Int, T) -> Unit
) = Accordion( ) = Accordion(
data, data,
@ -72,9 +72,9 @@ fun <T> DefaultAccordion(
data: Iterable<T>, data: Iterable<T>,
titleResolver: (Int, T) -> String, titleResolver: (Int, T) -> String,
attrs: Attrs<HTMLUListElement> = Attrs.empty(), attrs: Attrs<HTMLUListElement> = Attrs.empty(),
itemAttrsBuilder: AttrsBuilder<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> }, itemAttrsBuilder: AttrsScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
titleAttrsBuilder: AttrsBuilder<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> }, titleAttrsBuilder: AttrsScope<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
contentAttrsBuilder: AttrsBuilder<HTMLDivElement>.(Int, T) -> Unit = { _, _ -> }, contentAttrsBuilder: AttrsScope<HTMLDivElement>.(Int, T) -> Unit = { _, _ -> },
contentContentBuilder: @Composable ElementScope<HTMLDivElement>.(Int, T) -> Unit contentContentBuilder: @Composable ElementScope<HTMLDivElement>.(Int, T) -> Unit
) = DefaultAccordion( ) = DefaultAccordion(
data, data,

View File

@ -4,7 +4,8 @@ import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Attrs import dev.inmo.jsuikit.utils.Attrs
import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.*
import org.w3c.dom.* import org.w3c.dom.HTMLDivElement
import org.w3c.dom.HTMLHeadingElement
@Composable @Composable
fun Card( fun Card(

View File

@ -4,8 +4,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffectResult import androidx.compose.runtime.DisposableEffectResult
import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.modifiers.*
import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.dom.Text import org.w3c.dom.HTMLDivElement
import org.w3c.dom.* import org.w3c.dom.HTMLElement
import org.w3c.dom.events.Event import org.w3c.dom.events.Event
import kotlin.random.Random import kotlin.random.Random
import kotlin.random.nextUInt import kotlin.random.nextUInt

View File

@ -4,10 +4,8 @@ import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Attrs import dev.inmo.jsuikit.utils.Attrs
import dev.inmo.jsuikit.utils.InputAttrs import dev.inmo.jsuikit.utils.InputAttrs
import org.jetbrains.compose.web.attributes.InputType
import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLDivElement import org.w3c.dom.HTMLDivElement
import org.w3c.dom.HTMLInputElement
@Composable @Composable
fun DropArea( fun DropArea(

View File

@ -4,7 +4,6 @@ import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.buildAndAddAttribute import dev.inmo.jsuikit.buildAndAddAttribute
import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Milliseconds import dev.inmo.jsuikit.utils.Milliseconds
import dev.inmo.jsuikit.utils.buildAttribute
import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLDivElement import org.w3c.dom.HTMLDivElement

View File

@ -1,9 +1,11 @@
package dev.inmo.jsuikit.elements package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable 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 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 import org.w3c.dom.HTMLSpanElement
@Composable @Composable

View File

@ -3,21 +3,21 @@ package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitModifier import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include 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.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLLIElement import org.w3c.dom.HTMLLIElement
import org.w3c.dom.HTMLUListElement import org.w3c.dom.HTMLUListElement
interface NavbarNavElement { interface NavbarNavElement {
fun AttrsBuilder<HTMLLIElement>.setup() {} fun AttrsScope<HTMLLIElement>.setup() {}
@Composable @Composable
fun ElementScope<HTMLLIElement>.fill() fun ElementScope<HTMLLIElement>.fill()
class Default( class Default(
private val setupCallback: AttrsBuilder<HTMLLIElement>.() -> Unit, private val setupCallback: AttrsScope<HTMLLIElement>.() -> Unit,
private val fillCallback: @Composable ElementScope<HTMLLIElement>.() -> Unit private val fillCallback: @Composable ElementScope<HTMLLIElement>.() -> Unit
) : NavbarNavElement { ) : NavbarNavElement {
override fun AttrsBuilder<HTMLLIElement>.setup() { override fun AttrsScope<HTMLLIElement>.setup() {
setupCallback() setupCallback()
} }

View File

@ -1,9 +1,7 @@
package dev.inmo.jsuikit.elements package dev.inmo.jsuikit.elements
import dev.inmo.jsuikit.modifiers.UIKit import dev.inmo.jsuikit.modifiers.UIKit
import dev.inmo.jsuikit.types.UIKitNotificationParameter import dev.inmo.jsuikit.types.*
import dev.inmo.jsuikit.types.NotificationsGroup
import dev.inmo.jsuikit.types.invoke
import dev.inmo.jsuikit.utils.Milliseconds import dev.inmo.jsuikit.utils.Milliseconds
fun Notification( fun Notification(

View File

@ -1,9 +1,9 @@
package dev.inmo.jsuikit.elements package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.snapshots.SnapshotStateList import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.* 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.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.dom.Text import org.jetbrains.compose.web.dom.Text
import org.w3c.dom.* import org.w3c.dom.*
@ -15,9 +15,9 @@ fun <T> DefaultTable(
vararg tableModifiers: UIKitModifier, vararg tableModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {}, attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {}, headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {},
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> Unit = {}, headerCellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int) -> Unit = {},
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {}, rowAttributes: AttrsScope<HTMLTableRowElement>.(t: T) -> Unit = {},
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> }, cellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {}, betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {},
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
) { ) {
@ -72,14 +72,14 @@ fun <T> DefaultTable(
vararg tableModifiers: UIKitModifier, vararg tableModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {}, attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {}, headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {},
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> }, headerCellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> },
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {}, rowAttributes: AttrsScope<HTMLTableRowElement>.(t: T) -> Unit = {},
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> }, cellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {}, betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {},
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
) { ) {
val headersByIndex = heading.mapIndexed { index, s -> index to s }.toMap() val headersByIndex = heading.mapIndexed { index, s -> index to s }.toMap()
val headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> Unit = { i -> val headerCellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int) -> Unit = { i ->
val header = headersByIndex[i] val header = headersByIndex[i]
if (header != null) { if (header != null) {
headerCellCustomizer(i, header) headerCellCustomizer(i, header)

View File

@ -1,6 +1,7 @@
package dev.inmo.jsuikit.modifiers 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 import org.w3c.dom.PageTransitionEvent
sealed class UIKitAccordion( sealed class UIKitAccordion(

View File

@ -1,7 +1,6 @@
package dev.inmo.jsuikit.modifiers package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.* import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.css.CSSKeyframe
sealed class UIKitHeight( sealed class UIKitHeight(
classname: String?, classname: String?,

View File

@ -1,6 +1,6 @@
package dev.inmo.jsuikit.modifiers package dev.inmo.jsuikit.modifiers
import org.jetbrains.compose.web.attributes.AttrsBuilder import org.jetbrains.compose.web.attributes.AttrsScope
interface UIKitModifier { interface UIKitModifier {
val classes: Array<String> val classes: Array<String>
@ -9,7 +9,7 @@ interface UIKitModifier {
get() = emptyMap() get() = emptyMap()
} }
fun AttrsBuilder<*>.include(vararg container: UIKitModifier?) { fun AttrsScope<*>.include(vararg container: UIKitModifier?) {
container.forEach { container.forEach {
it ?.classes ?.let { newClasses -> classes(*newClasses) } it ?.classes ?.let { newClasses -> classes(*newClasses) }
it ?.otherAttrs ?.let { attrs -> attrs.forEach { (k, v) -> attr(k, v) } } it ?.otherAttrs ?.let { attrs -> attrs.forEach { (k, v) -> attr(k, v) } }

View File

@ -2,8 +2,6 @@ package dev.inmo.jsuikit.types
import dev.inmo.jsuikit.modifiers.UIKit import dev.inmo.jsuikit.modifiers.UIKit
import dev.inmo.jsuikit.utils.Milliseconds import dev.inmo.jsuikit.utils.Milliseconds
import org.w3c.dom.Element
import kotlin.js.Json
import kotlin.js.json import kotlin.js.json
typealias NotificationsGroup = String typealias NotificationsGroup = String

View File

@ -2,14 +2,12 @@ package dev.inmo.jsuikit.utils
import dev.inmo.jsuikit.modifiers.UIKitModifier import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include 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.attributes.InputType import org.jetbrains.compose.web.attributes.builders.InputAttrsScope
import org.jetbrains.compose.web.attributes.builders.InputAttrsBuilder
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.w3c.dom.Element import org.w3c.dom.Element
import org.w3c.dom.HTMLInputElement import org.w3c.dom.HTMLInputElement
class AttributesCollection<T : Element, Builder : AttrsBuilder<T>> ( class AttributesCollection<T : Element, Builder : AttrsScope<T>> (
private vararg val modifiers: UIKitModifier?, private vararg val modifiers: UIKitModifier?,
private val attrs: Builder.() -> Unit = {} private val attrs: Builder.() -> Unit = {}
) { ) {
@ -29,9 +27,9 @@ class AttributesCollection<T : Element, Builder : AttrsBuilder<T>> (
val Empty = Attrs<Element>() val Empty = Attrs<Element>()
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
fun <T : Element, Builder : AttrsBuilder<T>> empty() = Empty as AttributesCollection<T, Builder> fun <T : Element, Builder : AttrsScope<T>> empty() = Empty as AttributesCollection<T, Builder>
} }
} }
typealias Attrs<T> = AttributesCollection<T, AttrsBuilder<T>> typealias Attrs<T> = AttributesCollection<T, AttrsScope<T>>
typealias InputAttrs<T> = AttributesCollection<HTMLInputElement, InputAttrsBuilder<T>> typealias InputAttrs<T> = AttributesCollection<HTMLInputElement, InputAttrsScope<T>>