mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2025-12-04 21:35:40 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9449eccec1 | |||
| f518933195 | |||
| 23f3ecb0d4 | |||
| c6023d3075 | |||
| 7b72f99f66 | |||
| 66c3f97f65 | |||
| 40c3c0f437 | |||
| e46b2e0ddd | |||
| 2db4e48571 | |||
| e13a2fd241 | |||
| b3b19ed2b7 | |||
| d590762d28 | |||
| 65703d1c22 | |||
| 814045a43f | |||
| 1f36657857 | |||
| a2830e5e85 | |||
| 484564e323 | |||
| b5e93bc829 | |||
| 4282165d79 | |||
| 1e452c78d1 | |||
| 5fa388c169 | |||
| 763e1fa5ac | |||
| 150efa1719 | |||
| 20bf43b8a1 |
33
CHANGELOG.md
33
CHANGELOG.md
@@ -1,5 +1,38 @@
|
||||
# Changelog
|
||||
|
||||
## 0.0.17
|
||||
|
||||
* In `DefaultTable` `headingCustomizer` has been renamed to `headerCellCustomizer`
|
||||
* Add index and title parameters for `headerCellCustomizer` in `DefaultTable`
|
||||
|
||||
## 0.0.16
|
||||
|
||||
* Add opportunity to customize `NavDivider`
|
||||
|
||||
## 0.0.15
|
||||
|
||||
* Add support of link icons
|
||||
|
||||
## 0.0.14
|
||||
|
||||
* Add DefaultTable parameter cellCustomizer
|
||||
|
||||
## 0.0.13
|
||||
|
||||
* Add `Icon#Custom`
|
||||
|
||||
## 0.0.12
|
||||
|
||||
* Add `rowAttributes` to table fun
|
||||
|
||||
## 0.0.11
|
||||
|
||||
* Upfill `Nav` and `UIKitNav`
|
||||
|
||||
## 0.0.10
|
||||
|
||||
* Filling of `UIKitUtility`
|
||||
|
||||
## 0.0.9
|
||||
|
||||
* Improving of `Nav` support
|
||||
|
||||
@@ -9,4 +9,4 @@ android.enableJetifier=true
|
||||
# Project data
|
||||
|
||||
group=dev.inmo
|
||||
version=0.0.9
|
||||
version=0.0.17
|
||||
|
||||
@@ -219,13 +219,15 @@ sealed class Icon(val name: String) {
|
||||
}
|
||||
attributesCustomizer()
|
||||
}
|
||||
if (type == UIKitIconType.Button) {
|
||||
Button(configurer)
|
||||
} else {
|
||||
Span(configurer)
|
||||
when (type) {
|
||||
UIKitIconType.Default -> Span(configurer)
|
||||
UIKitIconType.Link -> A(href = "#", configurer)
|
||||
UIKitIconType.Button -> Button(configurer)
|
||||
}
|
||||
}
|
||||
|
||||
class Custom(name: String) : Icon(name)
|
||||
|
||||
@Composable
|
||||
fun drawAsButton(
|
||||
vararg modifiers: UIKitModifier,
|
||||
@@ -241,4 +243,12 @@ sealed class Icon(val name: String) {
|
||||
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||
onClick: ((Event) -> Unit)? = null
|
||||
) = invoke(*modifiers, type = UIKitIconType.Default, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
|
||||
|
||||
@Composable
|
||||
fun drawAsLink(
|
||||
vararg modifiers: UIKitModifier,
|
||||
ratio: Float? = null,
|
||||
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||
onClick: ((Event) -> Unit)? = null
|
||||
) = invoke(*modifiers, type = UIKitIconType.Link, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ fun Nav(
|
||||
"animation" to animation
|
||||
"duration" to duration ?.toString()
|
||||
}
|
||||
classes("uk-nav")
|
||||
include(*modifiers)
|
||||
include(*modifiers, UIKitNav)
|
||||
attributesCustomizer()
|
||||
}
|
||||
) {
|
||||
@@ -36,6 +35,63 @@ fun Nav(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DefaultNav(
|
||||
vararg modifiers: UIKitModifier,
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||
) = Nav(
|
||||
modifiers = modifiers + UIKitNav.Default,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
attributesCustomizer,
|
||||
dataAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun PrimaryNav(
|
||||
vararg modifiers: UIKitModifier,
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||
) = Nav(
|
||||
modifiers = modifiers + UIKitNav.Primary,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
attributesCustomizer,
|
||||
dataAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun SubNav(
|
||||
vararg modifiers: UIKitModifier,
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||
) = Nav(
|
||||
modifiers = modifiers + UIKitNav.SubNav,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
attributesCustomizer,
|
||||
dataAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun <T> Nav(
|
||||
title: String,
|
||||
@@ -59,8 +115,7 @@ fun <T> Nav(
|
||||
"animation" to animation
|
||||
"duration" to duration ?.toString()
|
||||
}
|
||||
classes("uk-nav")
|
||||
include(*ulModifiers)
|
||||
include(*ulModifiers, UIKitNav)
|
||||
ulCustomizer()
|
||||
}
|
||||
) {
|
||||
@@ -76,6 +131,93 @@ fun <T> Nav(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T> DefaultNav(
|
||||
title: String,
|
||||
data: SnapshotStateList<T>,
|
||||
vararg ulModifiers: UIKitModifier,
|
||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
|
||||
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||
) = Nav(
|
||||
title,
|
||||
data,
|
||||
ulModifiers = ulModifiers + UIKitNav.Default,
|
||||
titleModifiers,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
besidesTitleAndList,
|
||||
titleCustomizer,
|
||||
ulCustomizer,
|
||||
elementAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun <T> PrimaryNav(
|
||||
title: String,
|
||||
data: SnapshotStateList<T>,
|
||||
vararg ulModifiers: UIKitModifier,
|
||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
|
||||
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||
) = Nav(
|
||||
title,
|
||||
data,
|
||||
ulModifiers = ulModifiers + UIKitNav.Primary,
|
||||
titleModifiers,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
besidesTitleAndList,
|
||||
titleCustomizer,
|
||||
ulCustomizer,
|
||||
elementAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun <T> SubNav(
|
||||
title: String,
|
||||
data: SnapshotStateList<T>,
|
||||
vararg ulModifiers: UIKitModifier,
|
||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||
multiple: Boolean? = null,
|
||||
collapsible: Boolean? = null,
|
||||
animation: UIKitAnimation? = null,
|
||||
duration: Milliseconds? = null,
|
||||
besidesTitleAndList: ContentBuilder<HTMLUListElement>? = null,
|
||||
titleCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||
) = Nav(
|
||||
title,
|
||||
data,
|
||||
ulModifiers = ulModifiers + UIKitNav.SubNav,
|
||||
titleModifiers,
|
||||
multiple,
|
||||
collapsible,
|
||||
animation,
|
||||
duration,
|
||||
besidesTitleAndList,
|
||||
titleCustomizer,
|
||||
ulCustomizer,
|
||||
elementAllocator
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun NavHeader(
|
||||
text: String,
|
||||
@@ -92,6 +234,24 @@ fun NavHeader(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavItemElement(
|
||||
vararg modifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
contentAllocator: ContentBuilder<HTMLAnchorElement>
|
||||
) {
|
||||
Li(
|
||||
{
|
||||
include(*modifiers)
|
||||
attributesCustomizer()
|
||||
}
|
||||
) {
|
||||
A("#") {
|
||||
contentAllocator()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavElement(
|
||||
vararg modifiers: UIKitModifier,
|
||||
@@ -109,6 +269,9 @@ fun NavElement(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavDivider() {
|
||||
Li({ include(UIKitNav.Divider) })
|
||||
fun NavDivider(
|
||||
vararg modifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||
) {
|
||||
Li({ include(UIKitNav.Divider, *modifiers);attributesCustomizer() })
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.*
|
||||
@@ -13,8 +14,10 @@ fun <T> DefaultTable(
|
||||
dataList: SnapshotStateList<T>,
|
||||
vararg tableModifiers: UIKitModifier,
|
||||
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||
headingCustomizer: AttrBuilderContext<HTMLTableCellElement> = {},
|
||||
cellFiller: @Composable (i: Int, t: T) -> Unit
|
||||
headerCellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, title: String) -> Unit = { _, _ -> },
|
||||
rowAttributes: AttrsBuilder<HTMLTableRowElement>.(t: T) -> Unit = {},
|
||||
cellCustomizer: AttrsBuilder<HTMLTableCellElement>.(i: Int, t: T) -> Unit = { _, _ -> },
|
||||
cellFiller: @Composable ElementScope<HTMLTableCellElement>.(i: Int, t: T) -> Unit
|
||||
) {
|
||||
val headingIndexes = heading.indices
|
||||
Table(
|
||||
@@ -26,22 +29,30 @@ fun <T> DefaultTable(
|
||||
) {
|
||||
Thead {
|
||||
Tr {
|
||||
heading.forEach {
|
||||
heading.forEachIndexed { i, t ->
|
||||
Th(
|
||||
{
|
||||
headingCustomizer()
|
||||
headerCellCustomizer(i, t)
|
||||
}
|
||||
) {
|
||||
Text(it)
|
||||
Text(t)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Tbody {
|
||||
dataList.forEach {
|
||||
Tr {
|
||||
Tr(
|
||||
{
|
||||
rowAttributes(it)
|
||||
}
|
||||
) {
|
||||
headingIndexes.forEach { i ->
|
||||
Td {
|
||||
Td(
|
||||
{
|
||||
cellCustomizer(i, it)
|
||||
}
|
||||
) {
|
||||
cellFiller(i, it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package dev.inmo.jsuikit.modifiers
|
||||
sealed class UIKitNav(classname: String) : UIKitModifier {
|
||||
override val classes: Array<String> = arrayOf(classname)
|
||||
|
||||
object Accordion : UIKitNav("uk-nav-parent-icon")
|
||||
object Subnav : UIKitNav("uk-nav-sub")
|
||||
object ParentIcon : UIKitNav("uk-nav-parent-icon")
|
||||
object SubNav : UIKitNav("uk-nav-sub")
|
||||
|
||||
object Header : UIKitNav("uk-nav-header")
|
||||
object Divider : UIKitNav("uk-nav-divider")
|
||||
@@ -14,4 +14,6 @@ sealed class UIKitNav(classname: String) : UIKitModifier {
|
||||
object Primary : UIKitNav("uk-nav-primary")
|
||||
|
||||
object Center : UIKitNav("uk-nav-center")
|
||||
|
||||
companion object : UIKitNav("uk-nav")
|
||||
}
|
||||
|
||||
@@ -3,10 +3,110 @@ package dev.inmo.jsuikit.modifiers
|
||||
sealed class UIKitUtility(classname: String) : UIKitModifier {
|
||||
override val classes: Array<String> = arrayOf(classname)
|
||||
|
||||
object Panel : UIKitUtility("uk-panel")
|
||||
|
||||
sealed class Float(suffix: String) : UIKitUtility("uk-float-$suffix") {
|
||||
object Left : Float("left")
|
||||
object Right : Float("right")
|
||||
}
|
||||
object Clearfix : Float("clearfix")
|
||||
|
||||
sealed class Overflow(suffix: String) : UIKitUtility("uk-overflow-$suffix") {
|
||||
object Hidden : Overflow("hidden")
|
||||
object Auto : Overflow("auto")
|
||||
}
|
||||
|
||||
sealed class Resize(suffix: String?) : UIKitUtility("uk-resize${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Vertical : Resize("vertical")
|
||||
companion object : Resize(null)
|
||||
}
|
||||
|
||||
sealed class Display(suffix: String) : UIKitUtility("uk-display-$suffix") {
|
||||
object Block : Display("block")
|
||||
sealed class Inline(suffix: String?) : Display("inline${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Block : Inline("block")
|
||||
companion object : Inline(null)
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Inline(suffix: String?) : UIKitUtility("uk-inline${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Clip : Inline("clip")
|
||||
companion object : Inline(null)
|
||||
}
|
||||
|
||||
sealed class Responsive(suffix: String) : UIKitUtility("uk-responsive-$suffix") {
|
||||
object Width : Responsive("width")
|
||||
object Height : Responsive("height")
|
||||
}
|
||||
object PreserveWidth : UIKitUtility("uk-preserve-width")
|
||||
|
||||
sealed class Border(suffix: String) : UIKitUtility("uk-border-$suffix") {
|
||||
object Rounded : Border("rounded")
|
||||
object Circle : Border("circle")
|
||||
object Pill : Border("pill")
|
||||
}
|
||||
|
||||
sealed class BoxShadow(suffix: String) : UIKitUtility("uk-box-shadow-$suffix") {
|
||||
object Small : BoxShadow("small")
|
||||
object Medium : BoxShadow("medium")
|
||||
object Large : BoxShadow("large")
|
||||
object XLarge : BoxShadow("xlarge")
|
||||
|
||||
object Bottom : BoxShadow("bottom")
|
||||
|
||||
sealed class Hover(suffix: String) : BoxShadow("hover-$suffix") {
|
||||
object Small : Hover("small")
|
||||
object Medium : Hover("medium")
|
||||
object Large : Hover("large")
|
||||
object XLarge : Hover("xlarge")
|
||||
}
|
||||
}
|
||||
|
||||
object DropCap : UIKitUtility("uk-dropcap")
|
||||
|
||||
object Logo : UIKitUtility("uk-logo")
|
||||
|
||||
sealed class Blend(suffix: String) : UIKitUtility("uk-blend-$suffix") {
|
||||
object Multiply : Blend("multiply")
|
||||
object Screen : Blend("screen")
|
||||
object Overlay : Blend("overlay")
|
||||
object Darken : Blend("darken")
|
||||
object Lighten : Blend("lighten")
|
||||
sealed class Color(suffix: String?) : Blend("color${suffix ?.let { "-$it" } ?: ""}") {
|
||||
object Dodge : Color("dodge")
|
||||
object Burn : Color("burn")
|
||||
companion object : Color(null)
|
||||
}
|
||||
object HardLight : Blend("hard-light")
|
||||
object SoftLight : Blend("soft-light")
|
||||
object Difference : Blend("difference")
|
||||
object Exclusion : Blend("exclusion")
|
||||
object Hue : Blend("hue")
|
||||
object Saturation : Blend("saturation")
|
||||
object Luminosity : Blend("luminosity")
|
||||
}
|
||||
|
||||
sealed class Transform(suffix: String) : UIKitUtility("uk-transform-$suffix") {
|
||||
object Center : Transform("center")
|
||||
sealed class Origin(suffix: String) : Transform("origin-$suffix") {
|
||||
sealed class Top(suffix: String) : Origin("top-$suffix") {
|
||||
object Left : Top("left")
|
||||
object Center : Top("center")
|
||||
object Right : Top("right")
|
||||
}
|
||||
sealed class Center(suffix: String) : Origin("center-$suffix") {
|
||||
object Left : Center("left")
|
||||
object Right : Center("right")
|
||||
}
|
||||
sealed class Bottom(suffix: String) : Origin("bottom-$suffix") {
|
||||
object Left : Bottom("left")
|
||||
object Center : Bottom("center")
|
||||
object Right : Bottom("right")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Disabled : UIKitUtility("uk-disabled")
|
||||
object Drag : UIKitUtility("uk-drag")
|
||||
object Active : UIKitUtility("uk-active")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user