mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-12-22 16:47:24 +00:00
commit
6309656fac
@ -1,3 +1,7 @@
|
|||||||
|
## 0.0.5
|
||||||
|
|
||||||
|
All elements has changed their signatures: they all will accept an additional lambda for attributes configuration
|
||||||
|
|
||||||
## 0.0.4
|
## 0.0.4
|
||||||
|
|
||||||
__Migrate modifers to modifiers__
|
__Migrate modifers to modifiers__
|
||||||
|
@ -9,5 +9,5 @@ android.enableJetifier=true
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.0.4
|
version=0.0.5
|
||||||
|
|
||||||
|
@ -7,14 +7,16 @@ import org.jetbrains.compose.web.attributes.InputType
|
|||||||
import org.jetbrains.compose.web.attributes.disabled
|
import org.jetbrains.compose.web.attributes.disabled
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.w3c.dom.HTMLButtonElement
|
import org.w3c.dom.HTMLButtonElement
|
||||||
|
import org.w3c.dom.HTMLDivElement
|
||||||
import org.w3c.dom.events.Event
|
import org.w3c.dom.events.Event
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DefaultButton(
|
fun DefaultButton(
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
disabled: Boolean = false,
|
disabled: Boolean = false,
|
||||||
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
||||||
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
|
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
||||||
contentAllocator: ContentBuilder<HTMLButtonElement>
|
contentAllocator: ContentBuilder<HTMLButtonElement>
|
||||||
) {
|
) {
|
||||||
Button(
|
Button(
|
||||||
@ -25,6 +27,7 @@ fun DefaultButton(
|
|||||||
if (disabled) {
|
if (disabled) {
|
||||||
disabled()
|
disabled()
|
||||||
}
|
}
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
contentAllocator()
|
contentAllocator()
|
||||||
@ -34,13 +37,14 @@ fun DefaultButton(
|
|||||||
@Composable
|
@Composable
|
||||||
fun DefaultButton(
|
fun DefaultButton(
|
||||||
text: String,
|
text: String,
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
disabled: Boolean = false,
|
disabled: Boolean = false,
|
||||||
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
||||||
preTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
preTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
||||||
afterTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
afterTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
||||||
onClick: ((SyntheticMouseEvent) -> Unit)? = null
|
onClick: ((SyntheticMouseEvent) -> Unit)? = null
|
||||||
) = DefaultButton(*modifiers, disabled = disabled, buttonType = buttonType, onClick = onClick) {
|
) = DefaultButton(modifiers, disabled = disabled, buttonType = buttonType, onClick = onClick, attributesCustomizer = attributesCustomizer) {
|
||||||
preTextContentAllocator ?.apply { preTextContentAllocator() }
|
preTextContentAllocator ?.apply { preTextContentAllocator() }
|
||||||
Text(text)
|
Text(text)
|
||||||
afterTextContentAllocator ?.apply { afterTextContentAllocator() }
|
afterTextContentAllocator ?.apply { afterTextContentAllocator() }
|
||||||
@ -49,10 +53,11 @@ fun DefaultButton(
|
|||||||
@Composable
|
@Composable
|
||||||
fun UploadButton(
|
fun UploadButton(
|
||||||
text: String,
|
text: String,
|
||||||
vararg buttonModifiers: UIKitModifier,
|
buttonModifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
containerModifiers: Array<UIKitModifier> = emptyArray(),
|
containerModifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
disabled: Boolean = false,
|
disabled: Boolean = false,
|
||||||
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
onChange: (Event) -> Unit
|
onChange: (Event) -> Unit
|
||||||
) {
|
) {
|
||||||
Div(
|
Div(
|
||||||
@ -60,6 +65,7 @@ fun UploadButton(
|
|||||||
classes("js-upload", "uk-form-custom")
|
classes("js-upload", "uk-form-custom")
|
||||||
attr("uk-form-custom", "")
|
attr("uk-form-custom", "")
|
||||||
include(*containerModifiers)
|
include(*containerModifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Input(InputType.File) { onChange { onChange(it.nativeEvent) } }
|
Input(InputType.File) { onChange { onChange(it.nativeEvent) } }
|
||||||
|
@ -5,7 +5,8 @@ import androidx.compose.runtime.DisposableEffectResult
|
|||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.w3c.dom.HTMLElement
|
import org.jetbrains.compose.web.dom.Text
|
||||||
|
import org.w3c.dom.*
|
||||||
import org.w3c.dom.events.Event
|
import org.w3c.dom.events.Event
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import kotlin.random.nextUInt
|
import kotlin.random.nextUInt
|
||||||
@ -25,10 +26,11 @@ private class DialogDisposableEffectResult(
|
|||||||
@Composable
|
@Composable
|
||||||
fun Dialog(
|
fun Dialog(
|
||||||
title: String? = null,
|
title: String? = null,
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
hide: (() -> Unit)? = null,
|
hide: (() -> Unit)? = null,
|
||||||
hidden: (() -> Unit)? = null,
|
hidden: (() -> Unit)? = null,
|
||||||
footerBuilder: (@Composable () -> Unit)? = null,
|
footerBuilder: (@Composable () -> Unit)? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
bodyBuilder: @Composable () -> Unit
|
bodyBuilder: @Composable () -> Unit
|
||||||
) {
|
) {
|
||||||
Div(
|
Div(
|
||||||
@ -37,6 +39,7 @@ fun Dialog(
|
|||||||
classes("uk-flex-top", "uk-modal")
|
classes("uk-flex-top", "uk-modal")
|
||||||
id("dialog${Random.nextUInt()}")
|
id("dialog${Random.nextUInt()}")
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Div(
|
Div(
|
||||||
|
@ -4,13 +4,12 @@ import androidx.compose.runtime.Composable
|
|||||||
import dev.inmo.jsuikit.buildAndAddAttribute
|
import dev.inmo.jsuikit.buildAndAddAttribute
|
||||||
import dev.inmo.jsuikit.modifiers.*
|
import dev.inmo.jsuikit.modifiers.*
|
||||||
import dev.inmo.jsuikit.utils.Milliseconds
|
import dev.inmo.jsuikit.utils.Milliseconds
|
||||||
import org.jetbrains.compose.web.dom.ContentBuilder
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.jetbrains.compose.web.dom.Div
|
|
||||||
import org.w3c.dom.HTMLDivElement
|
import org.w3c.dom.HTMLDivElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Dropdown(
|
fun Dropdown(
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
toggle: String? = null,
|
toggle: String? = null,
|
||||||
pos: UIKitDropdown.Position? = null,
|
pos: UIKitDropdown.Position? = null,
|
||||||
mode: UIKitDropdown.Mode? = null,
|
mode: UIKitDropdown.Mode? = null,
|
||||||
@ -22,6 +21,7 @@ fun Dropdown(
|
|||||||
offset: Int? = null,
|
offset: Int? = null,
|
||||||
animation: UIKitAnimation? = null,
|
animation: UIKitAnimation? = null,
|
||||||
duration: Milliseconds? = null,
|
duration: Milliseconds? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
contentBuilder: ContentBuilder<HTMLDivElement>
|
contentBuilder: ContentBuilder<HTMLDivElement>
|
||||||
) {
|
) {
|
||||||
Div(
|
Div(
|
||||||
@ -41,6 +41,7 @@ fun Dropdown(
|
|||||||
}
|
}
|
||||||
classes("uk-dropdown")
|
classes("uk-dropdown")
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
},
|
},
|
||||||
contentBuilder
|
contentBuilder
|
||||||
)
|
)
|
||||||
|
@ -3,19 +3,20 @@ package dev.inmo.jsuikit.elements
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.dom.Div
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.jetbrains.compose.web.dom.ElementScope
|
|
||||||
import org.w3c.dom.HTMLDivElement
|
import org.w3c.dom.HTMLDivElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Flex(
|
fun Flex(
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
filler: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
filler: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
||||||
) {
|
) {
|
||||||
Div(
|
Div(
|
||||||
{
|
{
|
||||||
classes("uk-flex")
|
classes("uk-flex")
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
filler()
|
filler()
|
||||||
|
@ -3,18 +3,19 @@ package dev.inmo.jsuikit.elements
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.dom.Div
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.jetbrains.compose.web.dom.ElementScope
|
|
||||||
import org.w3c.dom.HTMLDivElement
|
import org.w3c.dom.HTMLDivElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun GridColumn(
|
fun GridColumn(
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
||||||
) {
|
) {
|
||||||
Div(
|
Div(
|
||||||
{
|
{
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
builder()
|
builder()
|
||||||
@ -23,11 +24,12 @@ fun GridColumn(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Grid(
|
fun Grid(
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
masonry: Boolean = false,
|
masonry: Boolean = false,
|
||||||
parallax: Int? = null,
|
parallax: Int? = null,
|
||||||
marginClass: String? = null,
|
marginClass: String? = null,
|
||||||
firstColumnClass: String? = null,
|
firstColumnClass: String? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
||||||
) {
|
) {
|
||||||
val attrs = listOfNotNull(
|
val attrs = listOfNotNull(
|
||||||
@ -41,6 +43,7 @@ fun Grid(
|
|||||||
attr("uk-grid", attrs.joinToString(";") { (k, v) -> "$k: $v" })
|
attr("uk-grid", attrs.joinToString(";") { (k, v) -> "$k: $v" })
|
||||||
classes("uk-grid")
|
classes("uk-grid")
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
builder()
|
builder()
|
||||||
|
@ -2,8 +2,8 @@ package dev.inmo.jsuikit.elements
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.*
|
import dev.inmo.jsuikit.modifiers.*
|
||||||
import org.jetbrains.compose.web.dom.Button
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.jetbrains.compose.web.dom.Span
|
import org.w3c.dom.*
|
||||||
import org.w3c.dom.events.Event
|
import org.w3c.dom.events.Event
|
||||||
|
|
||||||
sealed class Icon(val name: String) {
|
sealed class Icon(val name: String) {
|
||||||
@ -204,47 +204,41 @@ sealed class Icon(val name: String) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
operator fun invoke(
|
operator fun invoke(
|
||||||
vararg modifier: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
type: UIKitIconType = UIKitIconType.Default,
|
type: UIKitIconType = UIKitIconType.Default,
|
||||||
ratio: Float? = null,
|
ratio: Float? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||||
onClick: ((Event) -> Unit)? = null
|
onClick: ((Event) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
|
val configurer: AttrBuilderContext<out HTMLElement> = {
|
||||||
|
classes("uk-icon")
|
||||||
|
include(*modifiers, type)
|
||||||
|
attr("uk-icon", "icon: $name${if (ratio != null) { "; ratio: $ratio" } else ""}")
|
||||||
|
onClick ?.let { _ ->
|
||||||
|
onClick { onClick(it.nativeEvent) }
|
||||||
|
}
|
||||||
|
attributesCustomizer()
|
||||||
|
}
|
||||||
if (type == UIKitIconType.Button) {
|
if (type == UIKitIconType.Button) {
|
||||||
Button(
|
Button(configurer)
|
||||||
{
|
|
||||||
classes("uk-icon")
|
|
||||||
include(*modifier, type)
|
|
||||||
attr("uk-icon", "icon: $name${if (ratio != null) { "; ratio: $ratio" } else ""}")
|
|
||||||
onClick ?.let { _ ->
|
|
||||||
onClick { onClick(it.nativeEvent) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
Span(
|
Span(configurer)
|
||||||
{
|
|
||||||
classes("uk-icon")
|
|
||||||
include(*modifier, type)
|
|
||||||
attr("uk-icon", "icon: $name${if (ratio != null) { "; ratio: $ratio" } else ""}")
|
|
||||||
onClick ?.let { _ ->
|
|
||||||
onClick { onClick(it.nativeEvent) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun drawAsButton(
|
fun drawAsButton(
|
||||||
vararg modifier: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
ratio: Float? = null,
|
ratio: Float? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||||
onClick: ((Event) -> Unit)? = null
|
onClick: ((Event) -> Unit)? = null
|
||||||
) = invoke(*modifier, type = UIKitIconType.Button, ratio = ratio, onClick = onClick)
|
) = invoke(modifiers, type = UIKitIconType.Button, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun drawAsIcon(
|
fun drawAsIcon(
|
||||||
vararg modifier: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
ratio: Float? = null,
|
ratio: Float? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||||
onClick: ((Event) -> Unit)? = null
|
onClick: ((Event) -> Unit)? = null
|
||||||
) = invoke(*modifier, type = UIKitIconType.Default, ratio = ratio, onClick = onClick)
|
) = invoke(modifiers, type = UIKitIconType.Default, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package dev.inmo.jsuikit.elements
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.dom.Span
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.jetbrains.compose.web.dom.Text
|
import org.w3c.dom.HTMLSpanElement
|
||||||
|
|
||||||
sealed interface Label {
|
sealed interface Label {
|
||||||
val suffix: String
|
val suffix: String
|
||||||
@ -12,11 +12,13 @@ sealed interface Label {
|
|||||||
@Composable
|
@Composable
|
||||||
operator fun invoke(
|
operator fun invoke(
|
||||||
text: String,
|
text: String,
|
||||||
vararg modifiers: UIKitModifier
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLSpanElement> = {},
|
||||||
) = Span(
|
) = Span(
|
||||||
{
|
{
|
||||||
classes("uk-label", "uk-label-$suffix")
|
classes("uk-label", "uk-label-$suffix")
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Text(text)
|
Text(text)
|
||||||
|
@ -5,6 +5,7 @@ import androidx.compose.runtime.snapshots.SnapshotStateList
|
|||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
|
import org.w3c.dom.HTMLHeadingElement
|
||||||
import org.w3c.dom.HTMLUListElement
|
import org.w3c.dom.HTMLUListElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -12,11 +13,13 @@ fun <T> List(
|
|||||||
title: String,
|
title: String,
|
||||||
data: SnapshotStateList<T>,
|
data: SnapshotStateList<T>,
|
||||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
|
titleCustomizer: AttrBuilderContext<HTMLHeadingElement> = {},
|
||||||
ulModifiers: Array<UIKitModifier> = emptyArray(),
|
ulModifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
|
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||||
besidesTitleAndList: (@Composable () -> Unit)? = null,
|
besidesTitleAndList: (@Composable () -> Unit)? = null,
|
||||||
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
|
||||||
) {
|
) {
|
||||||
H4({ include(*titleModifiers) }) {
|
H4({ include(*titleModifiers); titleCustomizer() }) {
|
||||||
Text(title)
|
Text(title)
|
||||||
}
|
}
|
||||||
besidesTitleAndList ?.invoke()
|
besidesTitleAndList ?.invoke()
|
||||||
@ -24,6 +27,7 @@ fun <T> List(
|
|||||||
{
|
{
|
||||||
classes("uk-list")
|
classes("uk-list")
|
||||||
include(*ulModifiers)
|
include(*ulModifiers)
|
||||||
|
ulCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
data.forEach {
|
data.forEach {
|
||||||
|
@ -10,11 +10,12 @@ import org.w3c.dom.HTMLUListElement
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Nav(
|
fun Nav(
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
multiple: Boolean? = null,
|
multiple: Boolean? = null,
|
||||||
collapsible: Boolean? = null,
|
collapsible: Boolean? = null,
|
||||||
animation: UIKitAnimation? = null,
|
animation: UIKitAnimation? = null,
|
||||||
duration: Milliseconds? = null,
|
duration: Milliseconds? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||||
) {
|
) {
|
||||||
Ul(
|
Ul(
|
||||||
@ -27,6 +28,7 @@ fun Nav(
|
|||||||
}
|
}
|
||||||
classes("uk-nav")
|
classes("uk-nav")
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
dataAllocator()
|
dataAllocator()
|
||||||
@ -35,14 +37,14 @@ fun Nav(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NavElement(
|
fun NavElement(
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
attributesAllocator: (AttrBuilderContext<HTMLLIElement>)? = null,
|
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||||
contentAllocator: ContentBuilder<HTMLLIElement>
|
contentAllocator: ContentBuilder<HTMLLIElement>
|
||||||
) {
|
) {
|
||||||
Li(
|
Li(
|
||||||
{
|
{
|
||||||
attributesAllocator ?.apply { attributesAllocator() }
|
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
contentAllocator()
|
contentAllocator()
|
||||||
|
@ -3,21 +3,23 @@ package dev.inmo.jsuikit.elements
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.dom.Div
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.jetbrains.compose.web.dom.Nav
|
import org.w3c.dom.HTMLElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Navbar(
|
fun Navbar(
|
||||||
vararg navModifiers: UIKitModifier,
|
|
||||||
leftBuilder: NavbarNavBuilder? = null,
|
leftBuilder: NavbarNavBuilder? = null,
|
||||||
centerBuilder: NavbarNavBuilder? = null,
|
centerBuilder: NavbarNavBuilder? = null,
|
||||||
rightBuilder: NavbarNavBuilder? = null,
|
rightBuilder: NavbarNavBuilder? = null,
|
||||||
|
navModifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLElement> = {},
|
||||||
) {
|
) {
|
||||||
Nav(
|
Nav(
|
||||||
{
|
{
|
||||||
attr("uk-navbar", "")
|
attr("uk-navbar", "")
|
||||||
classes("uk-navbar-container", "uk-navbar")
|
classes("uk-navbar-container", "uk-navbar")
|
||||||
include(*navModifiers)
|
include(*navModifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
leftBuilder ?.let {
|
leftBuilder ?.let {
|
||||||
|
@ -6,6 +6,7 @@ import dev.inmo.jsuikit.modifiers.include
|
|||||||
import org.jetbrains.compose.web.attributes.AttrsBuilder
|
import org.jetbrains.compose.web.attributes.AttrsBuilder
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
import org.w3c.dom.HTMLLIElement
|
import org.w3c.dom.HTMLLIElement
|
||||||
|
import org.w3c.dom.HTMLUListElement
|
||||||
|
|
||||||
interface NavbarNavElement {
|
interface NavbarNavElement {
|
||||||
fun AttrsBuilder<HTMLLIElement>.setup() {}
|
fun AttrsBuilder<HTMLLIElement>.setup() {}
|
||||||
@ -29,21 +30,25 @@ interface NavbarNavElement {
|
|||||||
|
|
||||||
class NavbarNavBuilder(
|
class NavbarNavBuilder(
|
||||||
private val modifiers: Array<UIKitModifier>,
|
private val modifiers: Array<UIKitModifier>,
|
||||||
private val elements: List<NavbarNavElement>
|
private val elements: List<NavbarNavElement>,
|
||||||
|
private val attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {}
|
||||||
) {
|
) {
|
||||||
constructor(
|
constructor(
|
||||||
modifiers: Array<UIKitModifier>,
|
modifiers: Array<UIKitModifier>,
|
||||||
vararg elements: NavbarNavElement
|
vararg elements: NavbarNavElement,
|
||||||
) : this(modifiers, elements.toList())
|
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {}
|
||||||
|
) : this(modifiers, elements.toList(), attributesCustomizer)
|
||||||
constructor(
|
constructor(
|
||||||
vararg elements: NavbarNavElement
|
vararg elements: NavbarNavElement,
|
||||||
) : this(emptyArray(), elements.toList())
|
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {}
|
||||||
|
) : this(emptyArray(), elements.toList(), attributesCustomizer)
|
||||||
@Composable
|
@Composable
|
||||||
fun draw() {
|
fun draw() {
|
||||||
Ul(
|
Ul(
|
||||||
{
|
{
|
||||||
classes("uk-navbar-nav")
|
classes("uk-navbar-nav")
|
||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
elements.forEach { element ->
|
elements.forEach { element ->
|
||||||
|
@ -3,13 +3,16 @@ package dev.inmo.jsuikit.elements
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
|
import org.jetbrains.compose.web.dom.AttrBuilderContext
|
||||||
import org.jetbrains.compose.web.dom.Progress
|
import org.jetbrains.compose.web.dom.Progress
|
||||||
|
import org.w3c.dom.HTMLProgressElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Progress(
|
fun Progress(
|
||||||
value: Int,
|
value: Int,
|
||||||
vararg modifiers: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
max: Int = 100
|
max: Int = 100,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLProgressElement> = {}
|
||||||
) {
|
) {
|
||||||
Progress(
|
Progress(
|
||||||
{
|
{
|
||||||
@ -17,6 +20,7 @@ fun Progress(
|
|||||||
include(*modifiers)
|
include(*modifiers)
|
||||||
attr("max", max.toString())
|
attr("max", max.toString())
|
||||||
attr("value", value.toString())
|
attr("value", value.toString())
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,27 @@ package dev.inmo.jsuikit.elements
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import dev.inmo.jsuikit.modifiers.*
|
import dev.inmo.jsuikit.modifiers.*
|
||||||
|
import org.jetbrains.compose.web.dom.AttrBuilderContext
|
||||||
import org.jetbrains.compose.web.dom.Div
|
import org.jetbrains.compose.web.dom.Div
|
||||||
|
import org.w3c.dom.HTMLDivElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Spinner(
|
fun Spinner(
|
||||||
vararg modifier: UIKitModifier,
|
modifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
ratio: Float? = null
|
ratio: Float? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {}
|
||||||
) {
|
) {
|
||||||
Div(
|
Div(
|
||||||
{
|
{
|
||||||
attr("uk-spinner", ratio ?.let { "ratio: $it" } ?: "")
|
attr("uk-spinner", ratio ?.let { "ratio: $it" } ?: "")
|
||||||
classes("uk-icon", "uk-spinner")
|
classes("uk-icon", "uk-spinner")
|
||||||
include(*modifier)
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DefaultSpinner() = Spinner(UIKitAlign.Center, UIKitMargin.Small, UIKitText.Alignment.Center)
|
fun DefaultSpinner() = Spinner(
|
||||||
|
arrayOf(UIKitAlign.Center, UIKitMargin.Small, UIKitText.Alignment.Center)
|
||||||
|
)
|
||||||
|
@ -4,12 +4,15 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||||
import dev.inmo.jsuikit.modifiers.*
|
import dev.inmo.jsuikit.modifiers.*
|
||||||
import org.jetbrains.compose.web.dom.*
|
import org.jetbrains.compose.web.dom.*
|
||||||
|
import org.w3c.dom.HTMLProgressElement
|
||||||
|
import org.w3c.dom.HTMLTableElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> DefaultTable(
|
fun <T> DefaultTable(
|
||||||
heading: List<String>,
|
heading: List<String>,
|
||||||
dataList: SnapshotStateList<T>,
|
dataList: SnapshotStateList<T>,
|
||||||
vararg tableModifiers: UIKitModifier,
|
tableModifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||||
cellFiller: @Composable (i: Int, t: T) -> Unit
|
cellFiller: @Composable (i: Int, t: T) -> Unit
|
||||||
) {
|
) {
|
||||||
val headingIndexes = heading.indices
|
val headingIndexes = heading.indices
|
||||||
@ -17,6 +20,7 @@ fun <T> DefaultTable(
|
|||||||
{
|
{
|
||||||
classes("uk-table")
|
classes("uk-table")
|
||||||
include(*tableModifiers)
|
include(*tableModifiers)
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Thead {
|
Thead {
|
||||||
|
@ -4,7 +4,9 @@ import androidx.compose.runtime.*
|
|||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
import dev.inmo.jsuikit.modifiers.include
|
||||||
import org.jetbrains.compose.web.attributes.*
|
import org.jetbrains.compose.web.attributes.*
|
||||||
|
import org.jetbrains.compose.web.dom.AttrBuilderContext
|
||||||
import org.jetbrains.compose.web.dom.Input
|
import org.jetbrains.compose.web.dom.Input
|
||||||
|
import org.w3c.dom.HTMLInputElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> TextField(
|
fun <T> TextField(
|
||||||
@ -12,7 +14,8 @@ fun <T> TextField(
|
|||||||
state: MutableState<T>,
|
state: MutableState<T>,
|
||||||
disabledState: State<Boolean>? = null,
|
disabledState: State<Boolean>? = null,
|
||||||
placeholder: String? = null,
|
placeholder: String? = null,
|
||||||
vararg modifiers: UIKitModifier
|
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
|
||||||
|
modifiers: Array<UIKitModifier> = emptyArray()
|
||||||
) {
|
) {
|
||||||
Input(type) {
|
Input(type) {
|
||||||
classes("uk-input")
|
classes("uk-input")
|
||||||
@ -26,5 +29,6 @@ fun <T> TextField(
|
|||||||
disabled()
|
disabled()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user