2022-01-12 10:27:49 +00:00
|
|
|
package dev.inmo.jsuikit.elements
|
2021-12-22 08:38:12 +00:00
|
|
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.runtime.snapshots.SnapshotStateList
|
2022-01-12 13:58:52 +00:00
|
|
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
|
|
|
import dev.inmo.jsuikit.modifiers.include
|
2021-12-22 08:38:12 +00:00
|
|
|
import org.jetbrains.compose.web.dom.*
|
|
|
|
import org.w3c.dom.HTMLUListElement
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun <T> List(
|
|
|
|
title: String,
|
|
|
|
data: SnapshotStateList<T>,
|
|
|
|
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
|
|
|
ulModifiers: Array<UIKitModifier> = emptyArray(),
|
|
|
|
besidesTitleAndList: (@Composable () -> Unit)? = null,
|
|
|
|
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
|
|
|
) {
|
|
|
|
H4({ include(*titleModifiers) }) {
|
|
|
|
Text(title)
|
|
|
|
}
|
|
|
|
besidesTitleAndList ?.invoke()
|
|
|
|
Ul(
|
|
|
|
{
|
|
|
|
classes("uk-list")
|
|
|
|
include(*ulModifiers)
|
|
|
|
}
|
|
|
|
) {
|
|
|
|
data.forEach {
|
|
|
|
elementAllocator(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|