mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2025-12-04 05:15:56 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3c8cdcc96 | |||
| 68d1ba6a37 | |||
| 1cf9655575 | |||
| 4a7101697a | |||
| 17badd4724 | |||
| 39e54e8ca3 | |||
| ed31eb01e5 | |||
| 9d06725221 | |||
| d8d4a7fcf1 | |||
| 252fe4a295 | |||
| 6dbff07692 | |||
| e94585fc7e | |||
| b449caae13 | |||
| 95edaf1cfe | |||
| cb2fbe9f42 | |||
| 598e481f75 | |||
| 2a76519843 | |||
| 8e9ff07b71 | |||
| 13556a293c | |||
| a4d4ec3db8 | |||
| 6f095de81d |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ out/
|
||||
|
||||
secret.gradle
|
||||
local.properties
|
||||
local.*
|
||||
|
||||
kotlin-js-store/
|
||||
|
||||
|
||||
29
CHANGELOG.md
29
CHANGELOG.md
@@ -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`
|
||||
|
||||
@@ -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
1
local.make_version.sh
Executable 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
|
||||
@@ -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") })
|
||||
|
||||
@@ -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)
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
14
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitBase.kt
Normal file
14
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitBase.kt
Normal 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")
|
||||
}
|
||||
}
|
||||
15
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitColumn.kt
Normal file
15
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitColumn.kt
Normal 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")
|
||||
}
|
||||
10
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDivider.kt
Normal file
10
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDivider.kt
Normal 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")
|
||||
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user