mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-11-26 20:18:49 +00:00
Compare commits
No commits in common. "3e2aa2207635452fc6bfe3cf1a1c1a6e8cc41e8c" and "7cdd12e81e30e168f6128534d45027cbd8d17352" have entirely different histories.
3e2aa22076
...
7cdd12e81e
@ -1,10 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 0.0.53
|
|
||||||
|
|
||||||
* Improvements in `UIKitPadding`
|
|
||||||
* Add support of UIKit lists
|
|
||||||
|
|
||||||
## 0.0.52
|
## 0.0.52
|
||||||
|
|
||||||
* Improve work with UIKitModifiers
|
* Improve work with UIKitModifiers
|
||||||
|
@ -9,4 +9,4 @@ android.enableJetifier=true
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.0.53
|
version=0.0.52
|
||||||
|
@ -2,32 +2,14 @@ package dev.inmo.jsuikit.elements
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||||
import dev.inmo.jsuikit.modifiers.*
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.utils.Attrs
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.w3c.dom.HTMLHeadingElement
|
import org.w3c.dom.HTMLHeadingElement
|
||||||
import org.w3c.dom.HTMLUListElement
|
import org.w3c.dom.HTMLUListElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> List(
|
fun <T> List(
|
||||||
data: SnapshotStateList<T>,
|
|
||||||
ukAttrs: Attrs<HTMLUListElement> = Attrs.empty(),
|
|
||||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
|
||||||
) {
|
|
||||||
Ul(
|
|
||||||
{
|
|
||||||
include(UIKitList)
|
|
||||||
ukAttrs.builder(this)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
data.forEach {
|
|
||||||
elementAllocator(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun <T> ListWithTitle(
|
|
||||||
title: String,
|
title: String,
|
||||||
data: SnapshotStateList<T>,
|
data: SnapshotStateList<T>,
|
||||||
vararg titleModifiers: UIKitModifier,
|
vararg titleModifiers: UIKitModifier,
|
||||||
@ -41,27 +23,15 @@ fun <T> ListWithTitle(
|
|||||||
Text(title)
|
Text(title)
|
||||||
}
|
}
|
||||||
besidesTitleAndList ?.invoke()
|
besidesTitleAndList ?.invoke()
|
||||||
List(data, Attrs(*ulModifiers) { ulCustomizer(this) }, elementAllocator)
|
Ul(
|
||||||
|
{
|
||||||
|
classes("uk-list")
|
||||||
|
include(*ulModifiers)
|
||||||
|
ulCustomizer()
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
data.forEach {
|
||||||
|
elementAllocator(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("ListWithTitle", "dev.inmo.jsuikit.elements.ListWithTitle"))
|
|
||||||
@Composable
|
|
||||||
fun <T> List(
|
|
||||||
title: String,
|
|
||||||
data: SnapshotStateList<T>,
|
|
||||||
vararg titleModifiers: UIKitModifier,
|
|
||||||
ulModifiers: Array<UIKitModifier> = emptyArray(),
|
|
||||||
besidesTitleAndList: (@Composable () -> Unit)? = null,
|
|
||||||
titleCustomizer: AttrBuilderContext<HTMLHeadingElement> = {},
|
|
||||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
|
||||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
|
||||||
) = ListWithTitle(
|
|
||||||
title,
|
|
||||||
data,
|
|
||||||
*titleModifiers,
|
|
||||||
ulModifiers = ulModifiers,
|
|
||||||
besidesTitleAndList = besidesTitleAndList,
|
|
||||||
titleCustomizer = titleCustomizer,
|
|
||||||
ulCustomizer = ulCustomizer,
|
|
||||||
elementAllocator = elementAllocator
|
|
||||||
)
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
|
||||||
|
|
||||||
sealed class UIKitList(
|
|
||||||
vararg classes: String,
|
|
||||||
override val otherAttrs: Map<String, String> = emptyMap()
|
|
||||||
) : UIKitModifier {
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
override val classes: Array<String> = classes as Array<String>
|
|
||||||
|
|
||||||
sealed class Style(vararg classes: String) : UIKitList(*classes) {
|
|
||||||
|
|
||||||
object Disc : Style("uk-list-disc")
|
|
||||||
object Circle : Style("uk-list-circle")
|
|
||||||
object Square : Style("uk-list-square")
|
|
||||||
object Decimal : Style("uk-list-decimal")
|
|
||||||
object Hyphen : Style("uk-list-hyphen")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed class Size(vararg classes: String) : UIKitList(*classes) {
|
|
||||||
|
|
||||||
object Large : Size("uk-list-large")
|
|
||||||
object Collapse : Size("uk-list-collapse")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sealed class Color(vararg classes: String) : UIKitList(*classes) {
|
|
||||||
|
|
||||||
object Muted : Color("uk-list-muted")
|
|
||||||
object Emphasis : Color("uk-list-emphasis")
|
|
||||||
object Primary : Color("uk-list-primary")
|
|
||||||
object Secondary : Color("uk-list-secondary")
|
|
||||||
companion object {
|
|
||||||
val Bullet = UIKitList.Bullet
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
object Bullet: UIKitList("uk-list-bullet")
|
|
||||||
|
|
||||||
object Divider: UIKitList("uk-list-divider")
|
|
||||||
|
|
||||||
object Striped: UIKitList("uk-list-striped")
|
|
||||||
|
|
||||||
companion object : UIKitList("uk-list")
|
|
||||||
}
|
|
@ -8,10 +8,7 @@ sealed class UIKitPadding(suffix: String?) : UIKitModifier {
|
|||||||
object Small : Size("small")
|
object Small : Size("small")
|
||||||
object Large : Size("large")
|
object Large : Size("large")
|
||||||
|
|
||||||
companion object : Size(null) {
|
companion object : Size(null)
|
||||||
val Default
|
|
||||||
get() = this
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,6 +25,5 @@ sealed class UIKitPadding(suffix: String?) : UIKitModifier {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : Size(null)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user