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.*
|
2021-12-22 08:38:12 +00:00
|
|
|
import org.jetbrains.compose.web.dom.*
|
2022-01-13 05:55:08 +00:00
|
|
|
import org.w3c.dom.HTMLProgressElement
|
|
|
|
import org.w3c.dom.HTMLTableElement
|
2021-12-22 08:38:12 +00:00
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun <T> DefaultTable(
|
|
|
|
heading: List<String>,
|
|
|
|
dataList: SnapshotStateList<T>,
|
2022-01-13 13:56:39 +00:00
|
|
|
vararg tableModifiers: UIKitModifier,
|
2022-01-13 05:55:08 +00:00
|
|
|
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
2021-12-22 08:38:12 +00:00
|
|
|
cellFiller: @Composable (i: Int, t: T) -> Unit
|
|
|
|
) {
|
|
|
|
val headingIndexes = heading.indices
|
|
|
|
Table(
|
|
|
|
{
|
|
|
|
classes("uk-table")
|
|
|
|
include(*tableModifiers)
|
2022-01-13 05:55:08 +00:00
|
|
|
attributesCustomizer()
|
2021-12-22 08:38:12 +00:00
|
|
|
}
|
|
|
|
) {
|
|
|
|
Thead {
|
|
|
|
Tr {
|
|
|
|
heading.forEach {
|
|
|
|
Th(
|
|
|
|
{
|
|
|
|
include(UIKitExtension.TextTransformUnset)
|
|
|
|
}
|
|
|
|
) {
|
|
|
|
Text(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Tbody {
|
|
|
|
dataList.forEach {
|
|
|
|
Tr {
|
|
|
|
headingIndexes.forEach { i ->
|
|
|
|
Td {
|
|
|
|
cellFiller(i, it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|