mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-11-26 03:58:46 +00:00
improve support of List
This commit is contained in:
parent
8adbe8a1ca
commit
6daa57fe8f
@ -2,12 +2,30 @@ package dev.inmo.jsuikit.elements
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||
import dev.inmo.jsuikit.modifiers.include
|
||||
import dev.inmo.jsuikit.modifiers.*
|
||||
import dev.inmo.jsuikit.utils.Attrs
|
||||
import org.jetbrains.compose.web.dom.*
|
||||
import org.w3c.dom.HTMLHeadingElement
|
||||
import org.w3c.dom.HTMLUListElement
|
||||
|
||||
@Composable
|
||||
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> List(
|
||||
title: String,
|
||||
@ -23,15 +41,5 @@ fun <T> List(
|
||||
Text(title)
|
||||
}
|
||||
besidesTitleAndList ?.invoke()
|
||||
Ul(
|
||||
{
|
||||
classes("uk-list")
|
||||
include(*ulModifiers)
|
||||
ulCustomizer()
|
||||
}
|
||||
) {
|
||||
data.forEach {
|
||||
elementAllocator(it)
|
||||
}
|
||||
}
|
||||
List(data, Attrs(*ulModifiers) { ulCustomizer(this) }, elementAllocator)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user