Compare commits

..

21 Commits

Author SHA1 Message Date
a3c8cdcc96 Fixes in UIKitWidth 2022-01-26 13:20:14 +06:00
68d1ba6a37 start 0.0.28 2022-01-26 13:19:51 +06:00
1cf9655575 Merge pull request #27 from InsanusMokrassar/0.0.27
0.0.27
2022-01-26 00:51:54 +06:00
4a7101697a TextField -> StandardInput + fixes in it 2022-01-26 00:51:26 +06:00
17badd4724 start 0.0.27 2022-01-26 00:50:55 +06:00
39e54e8ca3 Merge pull request #26 from InsanusMokrassar/0.0.26
0.0.26
2022-01-25 23:44:43 +06:00
ed31eb01e5 add UIKitColumn 2022-01-25 23:44:22 +06:00
9d06725221 start 0.0.26 2022-01-25 23:44:15 +06:00
d8d4a7fcf1 Merge pull request #25 from InsanusMokrassar/0.0.25
0.0.25
2022-01-25 20:29:04 +06:00
252fe4a295 extend divider 2022-01-25 20:28:50 +06:00
6dbff07692 start 0.0.25 2022-01-25 20:28:34 +06:00
e94585fc7e Merge pull request #24 from InsanusMokrassar/0.0.24
0.0.24
2022-01-25 20:22:41 +06:00
b449caae13 add opportunity to fill space between header and body of table 2022-01-25 20:22:17 +06:00
95edaf1cfe start 0.0.24 2022-01-25 20:22:10 +06:00
cb2fbe9f42 Merge pull request #23 from InsanusMokrassar/0.0.23
0.0.23
2022-01-25 20:13:22 +06:00
598e481f75 add headerCustomizer to table 2022-01-25 20:13:03 +06:00
2a76519843 start 0.0.23 2022-01-25 20:12:48 +06:00
8e9ff07b71 Merge pull request #22 from InsanusMokrassar/0.0.22
0.0.22
2022-01-25 19:35:25 +06:00
13556a293c add opportunity to customize table header cells 2022-01-25 19:35:08 +06:00
a4d4ec3db8 start 0.0.22 2022-01-25 19:34:59 +06:00
6f095de81d Merge pull request #21 from InsanusMokrassar/0.0.21
0.0.21
2022-01-25 13:15:51 +06:00
11 changed files with 193 additions and 29 deletions

1
.gitignore vendored
View File

@@ -11,6 +11,7 @@ out/
secret.gradle
local.properties
local.*
kotlin-js-store/

View File

@@ -1,5 +1,34 @@
# Changelog
## 0.0.28
* Fixes in `UIKitWidth`
## 0.0.27
* `TextField` has been renamed to `StandardInput`
* `StandardInput` now will look for changes in state
## 0.0.26
* Add UIKitColumn
## 0.0.25
* Full including of divider
## 0.0.24
* Add opportunity to fill space between header and body of table
## 0.0.23
* New parameter of tables `headerCustomizer`
## 0.0.22
* Add opportunity to customize table header cells
## 0.0.21
* Upfill `UIKitWidth`

View File

@@ -9,4 +9,4 @@ android.enableJetifier=true
# Project data
group=dev.inmo
version=0.0.21
version=0.0.28

1
local.make_version.sh Executable file
View File

@@ -0,0 +1 @@
git add -A && git stash && git checkout master && git pull && git checkout -b "$1" && nano gradle.properties CHANGELOG.md && git add -A && git commit -m "start $1" && git stash pop && git add -A && nano CHANGELOG.md && git add -A && git commit -m "$2" && git push --set-upstream origin "$1" && ./gradlew clean && ./gradlew publishToMavenLocal

View File

@@ -1,7 +1,40 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.*
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.jetbrains.compose.web.dom.Hr
import org.w3c.dom.HTMLHRElement
object Divider {
@Composable
fun Common(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLHRElement> = {}
) = Hr {
include(*modifiers)
attributesCustomizer()
}
@Composable
fun Icon(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLHRElement> = {}
) = Common(
*(modifiers + UIKitDivider.Icon), attributesCustomizer = attributesCustomizer
)
@Composable
fun Small(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLHRElement> = {}
) = Common(
*(modifiers + UIKitDivider.Small), attributesCustomizer = attributesCustomizer
)
@Composable
fun Vertical(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLHRElement> = {}
) = Common(
*(modifiers + UIKitDivider.Vertical), attributesCustomizer = attributesCustomizer
)
}
@Composable
fun Divider() = Hr({ classes("uk-divider-icon") })

View File

@@ -9,7 +9,7 @@ import org.jetbrains.compose.web.dom.Input
import org.w3c.dom.HTMLInputElement
@Composable
fun <T> TextField(
fun <T> StandardInput(
type: InputType<T>,
state: MutableState<T>,
disabledState: State<Boolean>? = null,
@@ -23,7 +23,16 @@ fun <T> TextField(
placeholder ?.let(::placeholder)
onChange { state.value = it.value }
state.value.let {
when (it) {
is String -> value(it)
is Number -> value(it)
else -> {}
}
}
onInput { state.value = it.value }
disabledState ?.let {
if (it.value) {
disabled()
@@ -32,3 +41,14 @@ fun <T> TextField(
attributesCustomizer()
}
}
@Composable
@Deprecated("Renamed", ReplaceWith("StandardInput", "dev.inmo.jsuikit.elements.StandardInput"))
fun <T> TextField(
type: InputType<T>,
state: MutableState<T>,
disabledState: State<Boolean>? = null,
placeholder: String? = null,
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
) = StandardInput(type, state, disabledState, placeholder, modifiers = modifiers, attributesCustomizer)

View File

@@ -10,16 +10,18 @@ import org.w3c.dom.*
@Composable
fun <T> DefaultTable(
heading: List<String>,
headerBuilders: List<ContentBuilder<HTMLTableCellElement>>,
dataList: SnapshotStateList<T>,
vararg tableModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> },
headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {},
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> Unit = {},
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {},
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
) {
val headingIndexes = heading.indices
val headingIndexes = headerBuilders.indices
Table(
{
classes("uk-table")
@@ -27,19 +29,20 @@ fun <T> DefaultTable(
attributesCustomizer()
}
) {
Thead {
Thead(headerCustomizer) {
Tr {
heading.forEachIndexed { i, t ->
headerBuilders.forEachIndexed { i, t ->
Th(
{
headerCellCustomizer(i, t)
headerCellCustomizer(i)
}
) {
Text(t)
t()
}
}
}
}
betweenHeaderAndBodyFiller()
Tbody {
dataList.forEach {
Tr(
@@ -61,3 +64,41 @@ fun <T> DefaultTable(
}
}
}
@Composable
fun <T> DefaultTable(
heading: List<String>,
dataList: SnapshotStateList<T>,
vararg tableModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
headerCustomizer: AttrBuilderContext<HTMLTableSectionElement> = {},
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> },
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
betweenHeaderAndBodyFiller: ContentBuilder<HTMLTableElement> = {},
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
) {
val headersByIndex = heading.mapIndexed { index, s -> index to s }.toMap()
val headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int) -> Unit = { i ->
val header = headersByIndex[i]
if (header != null) {
headerCellCustomizer(i, header)
}
}
inline fun headerFactory(header: String): ContentBuilder<HTMLTableCellElement> = {
Text(header)
}
val headerBuilders = heading.map(::headerFactory)
return DefaultTable(
headerBuilders,
dataList,
tableModifiers = tableModifiers,
attributesCustomizer,
headerCustomizer,
headerCellCustomizer,
rowAttributes,
cellCustomizer,
betweenHeaderAndBodyFiller,
cellFiller
)
}

View File

@@ -0,0 +1,14 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitBase(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
sealed class Heading(suffix: String) : UIKitBase("uk-h$suffix") {
object H1 : Heading("1")
object H2 : Heading("2")
object H3 : Heading("3")
object H4 : Heading("4")
object H5 : Heading("5")
object H6 : Heading("6")
}
}

View File

@@ -0,0 +1,15 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitColumn(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
object Two : UIKitColumn("uk-column-1-2")
object Three : UIKitColumn("uk-column-1-3")
object Four : UIKitColumn("uk-column-1-4")
object Five : UIKitColumn("uk-column-1-5")
object Six : UIKitColumn("uk-column-1-6")
object Divider : UIKitColumn("uk-column-divider")
object Span : UIKitColumn("uk-column-span")
}

View File

@@ -0,0 +1,10 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitDivider(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
object Icon : UIKitDivider("uk-divider-icon")
object Small : UIKitDivider("uk-divider-small")
object Vertical : UIKitDivider("uk-divider-vertical")
}

View File

@@ -1,29 +1,29 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitWidth(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-width-$classname")
override val classes: Array<String> = arrayOf(classname)
object Auto : UIKitWidth("auto")
object Expand : UIKitWidth("expand")
object Full : UIKitWidth("1-1")
object Auto : UIKitWidth("uk-width-auto")
object Expand : UIKitWidth("uk-width-expand")
object Full : UIKitWidth("uk-width-1-1")
object Half : UIKitWidth("1-2")
object Half : UIKitWidth("uk-width-1-2")
object OneThird : UIKitWidth("1-3")
object TwoThird : UIKitWidth("2-3")
object OneThird : UIKitWidth("uk-width-1-3")
object TwoThird : UIKitWidth("uk-width-2-3")
object OneFourth : UIKitWidth("1-4")
object ThreeFourth : UIKitWidth("3-4")
object OneFourth : UIKitWidth("uk-width-1-4")
object ThreeFourth : UIKitWidth("uk-width-3-4")
object OneFifth : UIKitWidth("1-5")
object TwoFifth : UIKitWidth("2-5")
object ThreeFifth : UIKitWidth("3-5")
object FourFifth : UIKitWidth("4-5")
object OneFifth : UIKitWidth("uk-width-1-5")
object TwoFifth : UIKitWidth("uk-width-2-5")
object ThreeFifth : UIKitWidth("uk-width-3-5")
object FourFifth : UIKitWidth("uk-width-4-5")
object OneSixth : UIKitWidth("1-6")
object FiveSixth : UIKitWidth("5-6")
object OneSixth : UIKitWidth("uk-width-1-6")
object FiveSixth : UIKitWidth("uk-width-5-6")
sealed class Child(suffix: String) : UIKitWidth("child-$suffix") {
sealed class Child(suffix: String) : UIKitWidth("uk-child-width-$suffix") {
object Full : Child("1-1")
object Half : Child("1-2")
@@ -57,7 +57,7 @@ sealed class UIKitWidth(classname: String) : UIKitModifier {
}
}
sealed class Fixed(suffix: String) : UIKitWidth("fixed-$suffix") {
sealed class Fixed(suffix: String) : UIKitWidth("uk-width-fixed-$suffix") {
object Small : Fixed("small")
object Medium : Fixed("medium")