From 598e481f75f0b4fa88843d4de1075d6ca2a3d8cd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 25 Jan 2022 20:13:03 +0600 Subject: [PATCH] add headerCustomizer to table --- .gitignore | 1 + CHANGELOG.md | 2 ++ src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 032b956..790348e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ out/ secret.gradle local.properties +local.* kotlin-js-store/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 68795f9..e7f03dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.0.23 +* New parameter of tables `headerCustomizer` + ## 0.0.22 * Add opportunity to customize table header cells diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt index 911eae9..f58c05f 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt @@ -14,7 +14,8 @@ fun DefaultTable( dataList: SnapshotStateList, vararg tableModifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, - headerCellCustomizer: AttrsBuilder.(i: Int) -> Unit = { }, + headerCustomizer: AttrBuilderContext = {}, + headerCellCustomizer: AttrsBuilder.(i: Int) -> Unit = {}, rowAttributes: AttrsBuilder.(t: T) -> Unit = {}, cellCustomizer: AttrsBuilder.(i: Int, t: T) -> Unit = { _, _ -> }, cellFiller: @Composable ElementScope.(i: Int, t: T) -> Unit @@ -27,7 +28,7 @@ fun DefaultTable( attributesCustomizer() } ) { - Thead { + Thead(headerCustomizer) { Tr { headerBuilders.forEachIndexed { i, t -> Th( @@ -40,6 +41,7 @@ fun DefaultTable( } } } + Tbody { dataList.forEach { Tr( @@ -68,6 +70,7 @@ fun DefaultTable( dataList: SnapshotStateList, vararg tableModifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, + headerCustomizer: AttrBuilderContext = {}, headerCellCustomizer: AttrsBuilder.(i: Int, title: String) -> Unit = { _, _ -> }, rowAttributes: AttrsBuilder.(t: T) -> Unit = {}, cellCustomizer: AttrsBuilder.(i: Int, t: T) -> Unit = { _, _ -> }, @@ -89,6 +92,7 @@ fun DefaultTable( dataList, tableModifiers = tableModifiers, attributesCustomizer, + headerCustomizer, headerCellCustomizer, rowAttributes, cellCustomizer,