mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-11-23 02:28:47 +00:00
migration to compose 1.1.0 and replaces according to it
This commit is contained in:
parent
4e22cfce1a
commit
7bd5b26a1b
@ -2,6 +2,9 @@
|
||||
|
||||
## 0.0.42
|
||||
|
||||
* Migration to compose 1.1.0
|
||||
* Replaces according to it
|
||||
|
||||
## 0.0.41
|
||||
|
||||
* Add `DropArea`
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 <T> Accordion(
|
||||
data: Iterable<T>,
|
||||
attrs: Attrs<HTMLUListElement> = Attrs.empty(),
|
||||
itemAttrsBuilder: AttrsBuilder<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
itemAttrsBuilder: AttrsScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
itemContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit
|
||||
) {
|
||||
Ul(
|
||||
@ -33,13 +33,13 @@ fun <T> Accordion(
|
||||
fun <T> DefaultAccordion(
|
||||
data: Iterable<T>,
|
||||
attrs: Attrs<HTMLUListElement> = Attrs.empty(),
|
||||
itemAttrsBuilder: AttrsBuilder<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
titleAttrsBuilder: AttrsBuilder<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
itemAttrsBuilder: AttrsScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
titleAttrsBuilder: AttrsScope<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
titleContentBuilder: @Composable ElementScope<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
beforeTitleContentBuilder: @Composable ElementScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
afterTitleContentBuilder: @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
|
||||
) = Accordion(
|
||||
data,
|
||||
@ -72,9 +72,9 @@ fun <T> DefaultAccordion(
|
||||
data: Iterable<T>,
|
||||
titleResolver: (Int, T) -> String,
|
||||
attrs: Attrs<HTMLUListElement> = Attrs.empty(),
|
||||
itemAttrsBuilder: AttrsBuilder<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
titleAttrsBuilder: AttrsBuilder<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
contentAttrsBuilder: AttrsBuilder<HTMLDivElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
itemAttrsBuilder: AttrsScope<HTMLLIElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
titleAttrsBuilder: AttrsScope<HTMLAnchorElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
contentAttrsBuilder: AttrsScope<HTMLDivElement>.(Int, T) -> Unit = { _, _ -> },
|
||||
contentContentBuilder: @Composable ElementScope<HTMLDivElement>.(Int, T) -> Unit
|
||||
) = DefaultAccordion(
|
||||
data,
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<HTMLLIElement>.setup() {}
|
||||
fun AttrsScope<HTMLLIElement>.setup() {}
|
||||
@Composable
|
||||
fun ElementScope<HTMLLIElement>.fill()
|
||||
|
||||
class Default(
|
||||
private val setupCallback: AttrsBuilder<HTMLLIElement>.() -> Unit,
|
||||
private val setupCallback: AttrsScope<HTMLLIElement>.() -> Unit,
|
||||
private val fillCallback: @Composable ElementScope<HTMLLIElement>.() -> Unit
|
||||
) : NavbarNavElement {
|
||||
override fun AttrsBuilder<HTMLLIElement>.setup() {
|
||||
override fun AttrsScope<HTMLLIElement>.setup() {
|
||||
setupCallback()
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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 <T> DefaultTable(
|
||||
vararg tableModifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||
headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {},
|
||||
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> Unit = {},
|
||||
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
||||
headerCellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int) -> Unit = {},
|
||||
rowAttributes: AttrsScope<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||
cellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
||||
betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {},
|
||||
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
|
||||
) {
|
||||
@ -72,14 +72,14 @@ fun <T> DefaultTable(
|
||||
vararg tableModifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||
headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {},
|
||||
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> },
|
||||
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
||||
headerCellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> },
|
||||
rowAttributes: AttrsScope<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||
cellCustomizer: AttrsScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
||||
betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {},
|
||||
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
|
||||
) {
|
||||
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]
|
||||
if (header != null) {
|
||||
headerCellCustomizer(i, header)
|
||||
|
@ -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(
|
||||
|
@ -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?,
|
||||
|
@ -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<String>
|
||||
@ -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) } }
|
||||
|
@ -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
|
||||
|
@ -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<T : Element, Builder : AttrsBuilder<T>> (
|
||||
class AttributesCollection<T : Element, Builder : AttrsScope<T>> (
|
||||
private vararg val modifiers: UIKitModifier?,
|
||||
private val attrs: Builder.() -> Unit = {}
|
||||
) {
|
||||
@ -29,9 +27,9 @@ class AttributesCollection<T : Element, Builder : AttrsBuilder<T>> (
|
||||
val Empty = Attrs<Element>()
|
||||
|
||||
@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 InputAttrs<T> = AttributesCollection<HTMLInputElement, InputAttrsBuilder<T>>
|
||||
typealias Attrs<T> = AttributesCollection<T, AttrsScope<T>>
|
||||
typealias InputAttrs<T> = AttributesCollection<HTMLInputElement, InputAttrsScope<T>>
|
||||
|
Loading…
Reference in New Issue
Block a user