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 org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.Text import org.w3c.dom.* @Composable fun DefaultTable( heading: List, dataList: SnapshotStateList, vararg tableModifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, headingCustomizer: AttrBuilderContext = {}, rowAttributes: AttrsBuilder.(t: T) -> Unit = {}, cellCustomizer: AttrsBuilder.(i: Int, t: T) -> Unit = { _, _ -> }, cellFiller: @Composable ElementScope.(i: Int, t: T) -> Unit ) { val headingIndexes = heading.indices Table( { classes("uk-table") include(*tableModifiers) attributesCustomizer() } ) { Thead { Tr { heading.forEach { Th( { headingCustomizer() } ) { Text(it) } } } } Tbody { dataList.forEach { Tr( { rowAttributes(it) } ) { headingIndexes.forEach { i -> Td( { cellCustomizer(i, it) } ) { cellFiller(i, it) } } } } } } }