Compare commits

..

98 Commits

Author SHA1 Message Date
44c35c6778 support of UIKitForm 2022-02-17 19:31:31 +06:00
7b06e0ecb1 add UIKitCustom 2022-02-17 17:46:15 +06:00
366971bcf5 add afterHeaderBuilder and beforeFooterBuilder in Dialog 2022-02-17 17:28:42 +06:00
d4d0adf020 vertical and horizontal in margins 2022-02-17 15:16:30 +06:00
fc2fb24fce reorder comment arguments 2022-02-17 14:57:09 +06:00
687c3ab065 start 0.0.36 2022-02-17 14:56:47 +06:00
70f1abd527 Merge pull request #36 from InsanusMokrassar/0.0.35
0.0.35
2022-02-17 14:09:11 +06:00
1785e2158e improve work with modal dialogs 2022-02-16 19:54:07 +06:00
23ec737a05 start 0.0.35 2022-02-16 19:53:28 +06:00
f7eecc01e3 Merge pull request #35 from InsanusMokrassar/0.0.34
0.0.34
2022-02-09 16:10:11 +06:00
e4c2622115 fix of class in Alert 2022-02-09 15:47:02 +06:00
1a655810bd fixes in AlertCloseButton 2022-02-09 15:28:47 +06:00
dcc8646f18 add AlertCloseButton 2022-02-09 13:53:56 +06:00
53c728d7bc make Alert#attrs to be optional 2022-02-09 13:48:06 +06:00
01349d2fac add Alert and several things in animation 2022-02-09 13:43:56 +06:00
5ac4242b68 start 0.0.34 2022-02-09 13:43:11 +06:00
c1c1f847a9 Merge pull request #34 from InsanusMokrassar/0.0.33
attribute builder now may skip nullable values
2022-02-09 01:27:47 +06:00
1f8298f626 attribute builder now may skip nullable values 2022-02-09 01:26:33 +06:00
94698a0468 Merge pull request #33 from InsanusMokrassar/0.0.33
0.0.33
2022-02-09 01:19:14 +06:00
ca8f927304 updates and attributes buildings and fixes 2022-02-09 01:18:51 +06:00
a856545471 start 0.0.33 2022-02-09 01:18:34 +06:00
41b8063c72 Merge pull request #32 from InsanusMokrassar/0.0.32
0.0.32
2022-02-08 22:09:00 +06:00
6f4f1776c4 fix in UIKitWidth#Fixed 2022-02-08 19:12:24 +06:00
e10bbdeaa0 support of UIKitHeight, AttributesBuilder and Percents/Pixels abstractions 2022-02-08 18:48:49 +06:00
9dd486090a start 0.0.32 2022-02-08 18:48:20 +06:00
4479d9b0f9 Merge pull request #31 from InsanusMokrassar/0.0.31
0.0.31
2022-01-28 14:14:42 +06:00
cef131b1d0 UIKitVisibility 2022-01-28 14:14:27 +06:00
15340eadb1 start 0.0.31 2022-01-28 14:14:14 +06:00
36ab3fe52e Merge pull request #30 from InsanusMokrassar/0.0.30
0.0.30
2022-01-28 14:01:31 +06:00
029a7804ad add UIKitComment, Comment element, upfill UIKitSubNav 2022-01-28 14:01:06 +06:00
7edea7bf74 start 0.0.30 2022-01-28 14:00:34 +06:00
b1ea6d3a61 Merge pull request #29 from InsanusMokrassar/0.0.29
0.0.29
2022-01-26 13:38:46 +06:00
a304dcf5df fixes for build 2022-01-26 13:37:59 +06:00
a88562d3c4 upfill UIKitText 2022-01-26 13:37:03 +06:00
d9a01a8ab8 start 0.0.29 2022-01-26 13:36:49 +06:00
56b1268172 Merge pull request #28 from InsanusMokrassar/0.0.28
0.0.28
2022-01-26 13:20:44 +06:00
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
6b60d22e1e upfill UIKitWidth 2022-01-25 13:15:37 +06:00
4e0cc3621c start 0.0.21 2022-01-25 13:15:04 +06:00
4943490910 Merge pull request #20 from InsanusMokrassar/0.0.20
0.0.20
2022-01-25 12:54:38 +06:00
b60a3bc279 fixes in buttons 2022-01-25 12:54:19 +06:00
228138757d start 0.0.20 2022-01-25 12:53:47 +06:00
f1dedf1e09 Merge pull request #19 from InsanusMokrassar/0.0.19
0.0.19
2022-01-25 12:39:35 +06:00
936bb2d6fd create cards implementation and upgrade labels 2022-01-25 12:39:09 +06:00
0da87743e8 start 0.0.19 2022-01-25 12:38:37 +06:00
36eeb012c6 Merge pull request #18 from InsanusMokrassar/0.0.18
0.0.18
2022-01-25 11:25:47 +06:00
58f8f99e10 add uk-flex to UIKitFlex base class 2022-01-25 11:24:58 +06:00
d1c03e5c48 start 0.0.18 2022-01-25 11:22:36 +06:00
bd19572d78 Merge pull request #17 from InsanusMokrassar/0.0.17
0.0.17
2022-01-25 00:02:49 +06:00
9449eccec1 headingCustomizer -> headerCellCustomizer + add index and title parameters for it 2022-01-25 00:02:29 +06:00
f518933195 start 0.0.17 2022-01-25 00:00:42 +06:00
23f3ecb0d4 Merge pull request #16 from InsanusMokrassar/0.0.16
0.0.16
2022-01-24 21:46:41 +06:00
c6023d3075 add opportunity to customize NavDivider 2022-01-24 21:39:47 +06:00
7b72f99f66 start 0.0.16 2022-01-24 21:39:40 +06:00
66c3f97f65 Merge pull request #15 from InsanusMokrassar/0.0.15
0.0.15
2022-01-21 22:41:49 +06:00
40c3c0f437 add support of link icons type 2022-01-21 22:41:26 +06:00
e46b2e0ddd start 0.0.15 2022-01-21 22:41:18 +06:00
2db4e48571 Merge pull request #14 from InsanusMokrassar/0.0.14
0.0.14
2022-01-21 22:20:16 +06:00
e13a2fd241 add DefaultTable parameter cellAttributes 2022-01-21 22:20:02 +06:00
b3b19ed2b7 start 0.0.14 2022-01-21 22:16:03 +06:00
d590762d28 Merge pull request #13 from InsanusMokrassar/0.0.13
0.0.13
2022-01-21 21:37:39 +06:00
65703d1c22 add Icon#Custom 2022-01-21 21:37:16 +06:00
814045a43f start 0.0.13 2022-01-21 21:37:07 +06:00
1f36657857 Merge pull request #12 from InsanusMokrassar/0.0.12
0.0.12
2022-01-21 20:29:00 +06:00
a2830e5e85 add rowAttributes customizer for tables 2022-01-21 20:28:19 +06:00
484564e323 start 0.0.12 2022-01-21 20:27:31 +06:00
b5e93bc829 Merge pull request #11 from InsanusMokrassar/0.0.11
0.0.11
2022-01-21 11:32:00 +06:00
4282165d79 upfill navs 2022-01-21 11:31:00 +06:00
1e452c78d1 start 0.0.11 2022-01-21 11:30:47 +06:00
5fa388c169 Merge pull request #10 from InsanusMokrassar/0.0.10
0.0.10
2022-01-21 10:57:06 +06:00
763e1fa5ac upfill utilities 2022-01-21 10:55:14 +06:00
150efa1719 start 0.0.10 2022-01-21 10:55:01 +06:00
20bf43b8a1 Merge pull request #9 from InsanusMokrassar/0.0.9
0.0.9
2022-01-20 20:06:36 +06:00
93dd63c6b1 nav support improving 2022-01-20 19:56:46 +06:00
eb06ff80a1 start 0.0.9 2022-01-20 19:46:30 +06:00
25ba9188e3 Update README.md 2022-01-14 23:32:06 +06:00
19ca960b35 Update README.md 2022-01-14 00:45:09 +06:00
ef3b711e2b Merge pull request #8 from InsanusMokrassar/0.0.8
0.0.8
2022-01-13 21:38:04 +06:00
49 changed files with 1566 additions and 150 deletions

1
.gitignore vendored
View File

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

View File

@@ -1,5 +1,132 @@
# Changelog
## 0.0.36
* Reorder arguments in `DefaultComment` fun
* Add `Vertical` and `Horizontal` members in margins
* Add `afterHeaderBuilder` and `beforeFooterBuilder` properties in `Dialog` fun
* Add `UIKitCustom` to be able for simple creating of custom modifiers
* Add support of `UIKitForm`
## 0.0.35
* Add `UIKitModal`
* Improve work with dialogs
## 0.0.34
* Add `Alert`
* Add `Animation#KenBurns`
## 0.0.33
* Fixes in attributes building and related things
## 0.0.32
* Support of `UIKitHeight`
* New builder `AttributesBuilder`
* New `Percents`/`Pixels` abstractions
* Fixes in `UIKitWidth#Fixed` classnames
## 0.0.31
* Support of `UIKitVisibility`
## 0.0.30
* Add `UIKitComment`
* Including of `Comment` element
* Upfill `UIKitSubNav`
## 0.0.29
* Unfilling of `UIKitText`
## 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`
* New extension `UIKitModifier#applyWhenScreenSizeIs`
## 0.0.20
* Remove type of button from `DefaultButton` and add companion to `UIKitButton` to be able to use `uk-button` class
## 0.0.19
* Create `Card`s implementation
* Upgrade `Label` composable draw and create `UIKitLabel` modifiers
## 0.0.18
* Add base companion for `UIKitFlex` with result class `uk-flex`
## 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
## 0.0.8
Removing of redundant non standard things

View File

@@ -1,8 +1,5 @@
# JSUIKit Kotlin
**IMPORTANT NOTICE**: ___Currently it is possible that you will have issues with `vararg` arguments passing to the functions.
Use `arrayOf(...)` instead___
Hello :) This library is a wrapper for JavaScript/CSS [UIKit](https://getuikit.com) framework. It uses the same
structure as in [UIKit Docs](https://getuikit.com/docs/introduction) and in most cases you may use it.
@@ -11,10 +8,10 @@ for you in case you are using it too.
## How to include
Last version: [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/jsuikitkotlin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/jsuikitkotlin)
Last version: [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/kjsuikit/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/kjsuikit)
```groovy
implementation "dev.inmo:jsuikitkotlin:$jsuikitkotlin_version"
implementation "dev.inmo:kjsuikit:$kjsuikit_version"
```
**THIS LIBRARY DO NOT ADD ANY JS OR CSS**. So, you must download and include UIKit js/css by yourself. See

View File

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

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,8 +1,11 @@
package dev.inmo.jsuikit
import dev.inmo.jsuikit.modifiers.AttributeValue
import dev.inmo.jsuikit.utils.AttributeBuilder
import dev.inmo.jsuikit.utils.buildAttribute
import org.jetbrains.compose.web.attributes.AttrsBuilder
@Deprecated("Will be removed soon")
class UIKitAttributeValueBuilder {
private val attrs = mutableListOf<Pair<String, String>>()
@@ -21,7 +24,10 @@ class UIKitAttributeValueBuilder {
fun AttrsBuilder<*>.buildAndAddAttribute(
attributeName: String,
block: UIKitAttributeValueBuilder.() -> Unit
skipNullValues: Boolean = true,
block: AttributeBuilder.() -> Unit
) {
attr(attributeName, UIKitAttributeValueBuilder().apply(block).build())
buildAttribute(attributeName, skipNullValues, block).let {
attr(it.first, it.second)
}
}

View File

@@ -0,0 +1,49 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.buildAndAddAttribute
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Attrs
import dev.inmo.jsuikit.utils.Milliseconds
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLAnchorElement
import org.w3c.dom.HTMLDivElement
@Composable
fun Alert(
attrs: Attrs<HTMLDivElement> = Attrs.empty(),
animation: UIKitAnimation? = UIKitAnimation.Fade,
duration: Milliseconds? = null,
selClose: String? = null,
content: ContentBuilder<HTMLDivElement>
) = Div(
{
attrs.builder(this)
include(UIKitAlert)
buildAndAddAttribute("uk-alert") {
"animation" to animation ?.classes ?.firstOrNull()
"duration" to duration
"sel-close" to selClose
}
},
content
)
@Composable
fun AlertCloseButton(
attrs: Attrs<HTMLAnchorElement> = Attrs.empty(),
content: ContentBuilder<HTMLAnchorElement> = @Composable {}
) {
A(
null,
{
include(UIKitAlert.Close, UIKitIcon)
attr("uk-close", "")
classes("uk-close")
attrs.builder(this)
},
content
)
}

View File

@@ -14,7 +14,6 @@ import org.w3c.dom.events.Event
fun DefaultButton(
vararg modifiers: UIKitModifier,
disabled: Boolean = false,
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
contentAllocator: ContentBuilder<HTMLButtonElement>
@@ -22,8 +21,7 @@ fun DefaultButton(
Button(
{
onClick ?.let { onClick(it) }
classes("uk-button")
include(*modifiers, buttonType)
include(UIKitButton, *modifiers)
if (disabled) {
disabled()
}
@@ -39,12 +37,11 @@ fun DefaultButton(
text: String,
vararg modifiers: UIKitModifier,
disabled: Boolean = false,
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
preTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
afterTextContentAllocator: ContentBuilder<HTMLButtonElement>? = null,
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
onClick: ((SyntheticMouseEvent) -> Unit)? = null
) = DefaultButton(*modifiers, disabled = disabled, buttonType = buttonType, onClick = onClick, attributesCustomizer = attributesCustomizer) {
) = DefaultButton(*modifiers, disabled = disabled, onClick = onClick, attributesCustomizer = attributesCustomizer) {
preTextContentAllocator ?.apply { preTextContentAllocator() }
Text(text)
afterTextContentAllocator ?.apply { afterTextContentAllocator() }

View File

@@ -0,0 +1,79 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Attrs
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.*
@Composable
fun Card(
cardAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
headerAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
header: ContentBuilder<HTMLDivElement>? = null,
footerAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
footer: ContentBuilder<HTMLDivElement>? = null,
bodyAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
body: ContentBuilder<HTMLDivElement>
) {
Div(
{
include(UIKitCard)
cardAttrs.builder(this)
}
) {
header ?.let {
Div(
{
include(UIKitCard.Parts.Header)
headerAttrs.builder(this)
},
header
)
}
Div(
{
include(UIKitCard.Parts.Body)
bodyAttrs.builder(this)
},
body
)
footer ?.let {
Div(
{
include(UIKitCard.Parts.Footer)
footerAttrs.builder(this)
},
footer
)
}
}
}
@Composable
fun CardTitle(
titleAttrs: Attrs<HTMLHeadingElement> = Attrs.empty(),
title: ContentBuilder<HTMLHeadingElement>
) {
H3(
{
include(UIKitCard.Title)
titleAttrs.builder(this)
},
title
)
}
@Composable
fun CardBadge(
badgeAttrs: Attrs<HTMLDivElement> = Attrs.empty(),
badge: ContentBuilder<HTMLDivElement>
) {
Div(
{
include(UIKitCard.Badge, UIKitLabel)
badgeAttrs.builder(this)
},
badge
)
}

View File

@@ -0,0 +1,106 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.*
@Composable
fun Comment(
rootAttrs: Attrs<HTMLElement> = Attrs.empty(),
headerAttrs: Attrs<HTMLElement>? = null,
headerContent: ContentBuilder<HTMLElement>? = null,
bodyAttrs: Attrs<HTMLDivElement>? = null,
bodyContent: ContentBuilder<HTMLDivElement>? = null,
) {
Article(
{
include(UIKitComment)
rootAttrs.builder(this)
}
) {
if (headerAttrs != null || headerContent != null) {
Header (
{
include(UIKitComment.Header)
headerAttrs ?.builder ?.invoke(this)
}
) {
headerContent ?.let { it(this) }
}
}
if (bodyAttrs != null || bodyContent != null) {
Div(
{
include(UIKitComment.Body)
bodyAttrs ?.builder ?.invoke(this)
}
) {
bodyContent ?.let { it(this) }
}
}
}
}
@Composable
fun DefaultComment(
rootAttrs: Attrs<HTMLElement> = Attrs.empty(),
headerGridAttrs: Attrs<HTMLDivElement>? = null,
headerAttrs: Attrs<HTMLElement>? = null,
additionalHeaderContent: ContentBuilder<HTMLElement>? = null,
avatarUrl: String? = null,
avatarAttrs: Attrs<HTMLImageElement>? = null,
titleAttrs: Attrs<HTMLHeadingElement>? = null,
titleContent: ContentBuilder<HTMLHeadingElement>? = null,
metaAttrs: Attrs<HTMLUListElement>? = null,
metaContent: ContentBuilder<HTMLUListElement>? = null,
bodyAttrs: Attrs<HTMLDivElement>? = null,
bodyContent: ContentBuilder<HTMLDivElement>? = null,
) {
Comment(
rootAttrs = rootAttrs,
headerAttrs = headerAttrs,
headerContent = {
if (arrayOf(headerGridAttrs, avatarUrl, avatarAttrs, titleAttrs, titleContent, metaAttrs, metaContent).anyNotNull()) {
Grid(
UIKitGrid.Gap.Medium, UIKitFlex.Alignment.Vertical.Middle,
attributesCustomizer = headerGridAttrs ?.builder ?: {}
) {
if (avatarUrl != null) {
Div({ include(UIKitWidth.Auto) }) {
Img(avatarUrl, attrs = avatarAttrs ?.builder)
}
}
if (arrayOf(titleAttrs, titleContent, metaAttrs, metaContent).anyNotNull()) {
Div({ include(UIKitWidth.Expand) }) {
optionallyDraw(titleAttrs, titleContent) {
H4(
{
include(UIKitComment.Title, UIKitMargin.Remove)
titleAttrs ?.builder ?.invoke(this)
}
) {
titleContent ?.invoke(this)
}
}
optionallyDraw(metaAttrs, metaContent) {
Ul (
{
include(UIKitComment.Meta, UIKitSubNav, UIKitSubNav.Divider, UIKitMargin.Remove.Top)
metaAttrs ?.builder ?.invoke(this)
}
) {
metaContent ?.invoke(this)
}
}
}
}
}
}
additionalHeaderContent ?.let { it(this) }
},
bodyAttrs = bodyAttrs,
bodyContent = bodyContent
)
}

View File

@@ -2,8 +2,7 @@ package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffectResult
import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.modifiers.*
import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.dom.Text
import org.w3c.dom.*
@@ -25,59 +24,70 @@ private class DialogDisposableEffectResult(
@Composable
fun Dialog(
title: String? = null,
vararg modifiers: UIKitModifier,
hide: (() -> Unit)? = null,
hidden: (() -> Unit)? = null,
footerBuilder: (@Composable () -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
bodyBuilder: @Composable () -> Unit
onHide: (() -> Unit)? = null,
onHidden: (() -> Unit)? = null,
dialogAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
headerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
headerBuilder: ContentBuilder<HTMLDivElement>? = null,
afterHeaderBuilder: ContentBuilder<HTMLDivElement>? = null,
beforeFooterBuilder: ContentBuilder<HTMLDivElement>? = null,
footerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
footerBuilder: ContentBuilder<HTMLDivElement>? = null,
bodyAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
bodyBuilder: ContentBuilder<HTMLDivElement>
) {
Div(
{
attr("uk-modal", "")
classes("uk-flex-top", "uk-modal")
if (modifiers.none { it is UIKitModal.WithCustomAttributes }) {
include(UIKitModal)
}
id("dialog${Random.nextUInt()}")
include(*modifiers)
include(*modifiers, UIKitFlex.Alignment.Vertical.Top)
attributesCustomizer()
}
) {
Div(
{
classes("uk-modal-dialog", "uk-margin-auto-vertical")
include(UIKitModal.Dialog)
dialogAttrsBuilder ?.let { it() } ?: include(UIKitMargin.Auto.Vertical)
}
) {
title ?.let {
headerBuilder ?.let {
Div(
{
classes("uk-modal-header")
include(UIKitModal.Header)
headerAttrsBuilder ?.let { it() }
}
) {
H2({ classes("uk-modal-title") }) {
Text(title)
}
it()
}
}
afterHeaderBuilder ?.let { it() }
Div(
{
classes("uk-modal-body")
include(UIKitModal.Body)
bodyAttrsBuilder ?.let { it() }
}
) {
bodyBuilder()
}
beforeFooterBuilder ?.let { it() }
footerBuilder ?.let {
Div(
{
classes("uk-modal-footer", "uk-text-right")
include(UIKitModal.Footer)
footerAttrsBuilder ?.let { it() } ?: include(UIKitText.Alignment.Horizontal.Right)
}
) {
footerBuilder()
it()
}
}
}
DisposableRefEffect {
DialogDisposableEffectResult(it, hide, hidden)
DialogDisposableEffectResult(it, onHide, onHidden)
}
DomSideEffect { htmlElement ->
@@ -85,13 +95,44 @@ fun Dialog(
wrapper = { it: Event ->
htmlElement.removeEventListener("hidden", wrapper)
htmlElement.remove()
hidden ?.invoke()
onHidden ?.invoke()
}
htmlElement.addEventListener("hidden", wrapper)
val dialog = js("UIkit").modal("#${htmlElement.id}")
val dialog = UIKit.modal("#${htmlElement.id}")
dialog.show()
Unit
}
}
}
@Composable
fun Dialog(
title: String,
vararg modifiers: UIKitModifier,
hide: (() -> Unit)? = null,
hidden: (() -> Unit)? = null,
footerBuilder: (@Composable () -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
bodyBuilder: @Composable () -> Unit
) = Dialog(
modifiers = modifiers,
headerBuilder = {
H2({ include(UIKitModal.Title) }) {
Text(title)
}
},
onHide = hide,
onHidden = hidden,
footerBuilder = footerBuilder ?.let { _ ->
{
footerBuilder()
}
},
attributesCustomizer = {
attributesCustomizer()
},
bodyBuilder = {
bodyBuilder()
}
)

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

@@ -4,6 +4,7 @@ import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.buildAndAddAttribute
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Milliseconds
import dev.inmo.jsuikit.utils.buildAttribute
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLDivElement

View File

@@ -211,21 +211,22 @@ sealed class Icon(val name: String) {
onClick: ((Event) -> Unit)? = null
) {
val configurer: AttrBuilderContext<out HTMLElement> = {
classes("uk-icon")
include(*modifiers, type)
include(*modifiers, type, UIKitIcon)
attr("uk-icon", "icon: $name${if (ratio != null) { "; ratio: $ratio" } else ""}")
onClick ?.let { _ ->
onClick { onClick(it.nativeEvent) }
}
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 +242,20 @@ 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)
@Composable
fun drawAsFormInputPart(
vararg modifiers: UIKitModifier,
ratio: Float? = null,
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) = invoke(*modifiers, UIKitForm.Icon, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
}

View File

@@ -1,41 +1,20 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Attrs
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLSpanElement
sealed interface Label {
val suffix: String
@Composable
fun draw(
text: String,
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLSpanElement> = {},
) = Span(
{
classes("uk-label", "uk-label-$suffix")
include(*modifiers)
attributesCustomizer()
}
) {
Text(text)
}
object Success : Label {
override val suffix: String
get() = "success"
}
object Warning : Label {
override val suffix: String
get() = "warning"
}
object Error : Label {
override val suffix: String
get() = "danger"
@Composable
fun Label(
text: String,
attrs: Attrs<HTMLSpanElement>
) = Span(
{
include(UIKitLabel)
attrs.builder(this)
}
) {
Text(text)
}

View File

@@ -1,12 +1,13 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import androidx.compose.runtime.snapshots.SnapshotStateList
import dev.inmo.jsuikit.buildAndAddAttribute
import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.Milliseconds
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLLIElement
import org.w3c.dom.HTMLUListElement
import org.jetbrains.compose.web.dom.Text
import org.w3c.dom.*
@Composable
fun Nav(
@@ -26,8 +27,7 @@ fun Nav(
"animation" to animation
"duration" to duration ?.toString()
}
classes("uk-nav")
include(*modifiers)
include(*modifiers, UIKitNav)
attributesCustomizer()
}
) {
@@ -35,6 +35,223 @@ 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,
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
) {
Ul(
{
buildAndAddAttribute("uk-nav") {
"multiple" to multiple ?.toString()
"collapsible" to collapsible ?.toString()
"animation" to animation
"duration" to duration ?.toString()
}
include(*ulModifiers, UIKitNav)
ulCustomizer()
}
) {
NavHeader(
title,
*titleModifiers,
attributesCustomizer = titleCustomizer
)
besidesTitleAndList ?.let { it() }
data.forEach {
elementAllocator(it)
}
}
}
@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,
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
) {
Li(
{
include(*modifiers, UIKitNav.Header)
attributesCustomizer()
}
) {
Text(text)
}
}
@Composable
fun NavItemElement(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
contentAllocator: ContentBuilder<HTMLAnchorElement>
) {
Li(
{
include(*modifiers)
attributesCustomizer()
}
) {
A("#") {
contentAllocator()
}
}
}
@Composable
fun NavElement(
vararg modifiers: UIKitModifier,
@@ -44,9 +261,17 @@ fun NavElement(
Li(
{
include(*modifiers)
attributesCustomizer
attributesCustomizer()
}
) {
contentAllocator()
}
}
@Composable
fun NavDivider(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
) {
Li({ include(UIKitNav.Divider, *modifiers);attributesCustomizer() })
}

View File

@@ -23,4 +23,4 @@ fun Spinner(
}
@Composable
fun DefaultSpinner() = Spinner(UIKitAlign.Center, UIKitMargin.Small, UIKitText.Alignment.Center)
fun DefaultSpinner() = Spinner(UIKitAlign.Center, UIKitMargin.Small, UIKitText.Alignment.Horizontal.Center, UIKitText.Alignment.Vertical.Middle)

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

@@ -3,20 +3,25 @@ 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.*
@Composable
fun <T> DefaultTable(
heading: List<String>,
headerBuilders: List<ContentBuilder<HTMLTableCellElement>>,
dataList: SnapshotStateList<T>,
vararg tableModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
headingCustomizer: AttrBuilderContext<HTMLTableCellElement> = {},
cellFiller: @Composable (i: Int, t: T) -> 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")
@@ -24,24 +29,33 @@ fun <T> DefaultTable(
attributesCustomizer()
}
) {
Thead {
Thead(headerCustomizer) {
Tr {
heading.forEach {
headerBuilders.forEachIndexed { i, t ->
Th(
{
headingCustomizer()
headerCellCustomizer(i)
}
) {
Text(it)
t()
}
}
}
}
betweenHeaderAndBodyFiller()
Tbody {
dataList.forEach {
Tr {
Tr(
{
rowAttributes(it)
}
) {
headingIndexes.forEach { i ->
Td {
Td(
{
cellCustomizer(i, it)
}
) {
cellFiller(i, it)
}
}
@@ -50,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,18 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitAlert(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
sealed class Style(classname: String) : UIKitAlert(classname) {
object Primary : Style("uk-alert-primary")
object Success : Style("uk-alert-success")
object Warning : Style("uk-alert-warning")
object Danger : Style("uk-alert-danger")
}
object Close : UIKitAlert("uk-alert-close")
companion object : UIKitAlert("uk-alert")
}

View File

@@ -60,4 +60,6 @@ sealed class UIKitAnimation (name: String) : UIKitModifier, AttributeValue(name)
object Fast : UIKitAnimation("fast")
object KenBurns : UIKitAnimation("kenburns")
}

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

@@ -1,7 +1,7 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitButton(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-button-$suffix")
sealed class UIKitButton(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-button${suffix?.let { "-$it" } ?: ""}")
sealed class Type(suffix: String) : UIKitButton(suffix) {
object Default : Type("default")
@@ -11,4 +11,6 @@ sealed class UIKitButton(suffix: String) : UIKitModifier {
object Text : Type("text")
object Link : Type("link")
}
companion object : UIKitButton(null)
}

View File

@@ -0,0 +1,35 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitCard(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-card${suffix ?.let { "-$it" } ?: ""}")
object Title : UIKitCard("title")
object Hover : UIKitCard("hover")
object Badge : Parts("badge")
sealed class Parts(suffix: String) : UIKitCard(suffix) {
object Header : Parts("header")
object Body : Parts("body")
object Footer : Parts("footer")
}
sealed class Style(suffix: String) : UIKitCard(suffix) {
object Default : Style("default")
object Primary : Style("primary")
object Secondary : Style("secondary")
}
sealed class Size(suffix: String) : UIKitCard(suffix) {
object Small : Size("small")
object Large : Size("large")
}
sealed class Media(suffix: String) : UIKitCard("media-$suffix") {
object Top : Media("top")
object Right : Media("right")
object Bottom : Media("bottom")
object Left : Media("left")
}
companion object : UIKitCard(null)
}

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,17 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitComment(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-comment${suffix ?.let { "-$it" } ?: ""}")
object Body : UIKitComment("body")
object Header : UIKitComment("header")
object Title : UIKitComment("title")
object Meta : UIKitComment("meta")
object Avatar : UIKitComment("avatar")
object Primary : UIKitComment("primary")
object List : UIKitComment("list")
companion object : UIKitComment(null)
}

View File

@@ -0,0 +1,6 @@
package dev.inmo.jsuikit.modifiers
class UIKitCustom(
override val classes: Array<String> = emptyArray(),
override val otherAttrs: Map<String, String> = emptyMap()
) : UIKitModifier

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,7 +1,7 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitFlex(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-flex-$suffix")
sealed class UIKitFlex(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-flex${suffix ?.let { "-$it" } ?: ""}")
object Inline : UIKitFlex("inline")
@@ -76,4 +76,6 @@ sealed class UIKitFlex(suffix: String) : UIKitModifier {
object NoWrap : UIKitFlex("nowrap")
companion object : UIKitFlex(null)
}

View File

@@ -0,0 +1,58 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.buildAttribute
sealed class UIKitForm(
vararg classnames: String,
override val otherAttrs: Map<String, String> = emptyMap()
) : UIKitModifier {
@Suppress("UNCHECKED_CAST")
override val classes: Array<String> = classnames as Array<String>
object Fieldset : UIKitForm("uk-fieldset")
object Legend : UIKitForm("uk-legend")
object Input : UIKitForm("uk-input")
object Select : UIKitForm("uk-select")
object TextArea : UIKitForm("uk-textarea")
object Radio : UIKitForm("uk-radio", otherAttrs = mapOf("type" to "radio"))
object Checkbox : UIKitForm("uk-checkbox", otherAttrs = mapOf("type" to "checkbox"))
object Range : UIKitForm("uk-range", otherAttrs = mapOf("type" to "range"))
sealed class State(vararg classnames: String) : UIKitForm(*classnames) {
object Danger : State("uk-form-danger")
object Success : State("uk-form-success")
}
sealed class Size(vararg classnames: String) : UIKitForm(*classnames) {
object Large : Size("uk-form-large")
object Default : Size() // :)
object Small : Size("uk-form-small")
}
sealed class Width(vararg classnames: String) : UIKitForm(*classnames) {
object Large : Width("uk-form-width-large")
object Medium : Width("uk-form-width-medium")
object Small : Width("uk-form-width-small")
object XSmall : Width("uk-form-width-xsmall")
}
object Blank : UIKitForm("uk-form-blank")
sealed class Layout(vararg classnames: String) : UIKitForm(*classnames) {
object Stacked : Layout("uk-form-stacked")
object Horizontal : Layout("uk-form-horizontal")
object Label : Layout("uk-form-label")
object Controls : Layout("uk-form-controls")
}
object Icon : UIKitForm("uk-form-icon")
class Custom(
target: String = "true"
) : UIKitForm(
otherAttrs = mapOf(
buildAttribute("uk-form-custom") {
"target" to target
}
)
)
}

View File

@@ -0,0 +1,80 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.css.CSSKeyframe
sealed class UIKitHeight(
classname: String?,
override val otherAttrs: Map<String, String> = emptyMap()
) : UIKitModifier {
override val classes: Array<String> = classname ?.let { arrayOf(it) } ?: emptyArray()
object Full : UIKitHeight("uk-height-1-1")
sealed class Size(classname: String) : UIKitHeight(classname) {
sealed class Small(classname: String = "uk-height-small") : Size(classname) {
object Max : Small("uk-height-max-small")
companion object : Small()
}
sealed class Medium(classname: String = "uk-height-medium") : Size(classname) {
object Max : Medium("uk-height-max-medium")
companion object : Medium()
}
sealed class Large(classname: String = "uk-height-large") : Size(classname) {
object Max : Large("uk-height-max-large")
companion object : Large()
}
}
class Viewport(offsetTop: Boolean? = null, offsetBottom: String? = null, expand: Boolean? = null, minHeight: Int? = null) : UIKitHeight(
null,
mapOf(
buildAttribute("uk-height-viewport") {
offsetTop ?.let { "offset-top" to it.toString() }
offsetBottom ?.let { "offset-bottom" to it }
expand ?.let { "expand" to it.toString() }
minHeight ?.let { "min-height" to it.toString() }
}
)
)
fun Viewport(
offsetTop: Boolean? = null,
offsetBottom: Boolean,
expand: Boolean? = null,
minHeight: Int? = null
) = Viewport(offsetTop, offsetBottom.toString(), expand, minHeight)
fun Viewport(
offsetTop: Boolean? = null,
offsetBottom: Pixels,
expand: Boolean? = null,
minHeight: Int? = null
) = Viewport(offsetTop, offsetBottom.toString(), expand, minHeight)
fun Viewport(
offsetTop: Boolean? = null,
offsetBottom: Percents,
expand: Boolean? = null,
minHeight: Int? = null
) = Viewport(offsetTop, offsetBottom.toString(), expand, minHeight)
class Match(target: String? = null, row: Boolean? = null) : UIKitHeight(
null,
mapOf(
buildAttribute("uk-height-match") {
target ?.let { "target" to it }
row ?.let { "row" to it.toString() }
}
)
)
}

View File

@@ -0,0 +1,7 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitIcon(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
companion object : UIKitIcon("uk-icon")
}

View File

@@ -0,0 +1,11 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitLabel(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-label${suffix?.let { "-$it" } ?: ""}")
object Success : UIKitLabel("success")
object Warning : UIKitLabel("warning")
object Error : UIKitLabel("danger")
companion object : UIKitLabel(null)
}

View File

@@ -1,68 +1,87 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitMargin(val classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
sealed class UIKitMargin(vararg classnames: String) : UIKitModifier {
@Suppress("UNCHECKED_CAST")
override val classes: Array<String> = classnames as Array<String>
object Top : Small("uk-margin-top")
object Bottom : Small("uk-margin-bottom")
object Left : Small("uk-margin-left")
object Right : Small("uk-margin-right")
object Top : UIKitMargin("uk-margin-top")
object Bottom : UIKitMargin("uk-margin-bottom")
object Left : UIKitMargin("uk-margin-left")
object Right : UIKitMargin("uk-margin-right")
object Vertical : UIKitMargin() { override val classes: Array<String> = Top.classes + Bottom.classes }
object Horizontal : UIKitMargin() { override val classes: Array<String> = Left.classes + Right.classes }
companion object : Small("uk-margin")
sealed class Small(classname: String) : UIKitMargin(classname) {
sealed class Small(vararg classnames: String) : UIKitMargin(*classnames) {
object Top : Small("uk-margin-small-top")
object Bottom : Small("uk-margin-small-bottom")
object Left : Small("uk-margin-small-left")
object Right : Small("uk-margin-small-right")
object Vertical : Small() {
override val classes: Array<String> = Top.classes + Bottom.classes
}
object Horizontal : Small() {
override val classes: Array<String> = Left.classes + Right.classes
}
companion object : Small("uk-margin-small")
}
sealed class Medium(classname: String) : UIKitMargin(classname) {
sealed class Medium(vararg classnames: String) : UIKitMargin(*classnames) {
object Top : Medium("uk-margin-medium-top")
object Bottom : Medium("uk-margin-medium-bottom")
object Left : Medium("uk-margin-medium-left")
object Right : Medium("uk-margin-medium-right")
object Vertical : Medium() { override val classes: Array<String> = Top.classes + Bottom.classes }
object Horizontal : Medium() { override val classes: Array<String> = Left.classes + Right.classes }
companion object : Medium("uk-margin-medium")
}
sealed class Large(classname: String) : UIKitMargin(classname) {
sealed class Large(vararg classnames: String) : UIKitMargin(*classnames) {
object Top : Large("uk-margin-large-top")
object Bottom : Large("uk-margin-large-bottom")
object Left : Large("uk-margin-large-left")
object Right : Large("uk-margin-large-right")
object Vertical : Large() { override val classes: Array<String> = Top.classes + Bottom.classes }
object Horizontal : Large() { override val classes: Array<String> = Left.classes + Right.classes }
companion object : Large("uk-margin-large")
}
sealed class XLarge(classname: String) : UIKitMargin(classname) {
sealed class XLarge(vararg classnames: String) : UIKitMargin(*classnames) {
object Top : XLarge("uk-margin-xlarge-top")
object Bottom : XLarge("uk-margin-xlarge-bottom")
object Left : XLarge("uk-margin-xlarge-left")
object Right : XLarge("uk-margin-xlarge-right")
object Vertical : XLarge() { override val classes: Array<String> = Top.classes + Bottom.classes }
object Horizontal : XLarge() { override val classes: Array<String> = Left.classes + Right.classes }
companion object : XLarge("uk-margin-xlarge")
}
sealed class Auto(classname: String) : UIKitMargin(classname) {
sealed class Auto(vararg classnames: String) : UIKitMargin(*classnames) {
object Top : Auto("uk-margin-auto-top")
object Bottom : Auto("uk-margin-auto-bottom")
object Left : Auto("uk-margin-auto-left")
object Right : Auto("uk-margin-auto-right")
object Vertical : Auto("uk-margin-auto-vertical")
object Horizontal : Auto() { override val classes: Array<String> = Left.classes + Right.classes }
companion object : Auto("uk-margin-auto")
}
sealed class Remove(classname: String) : UIKitMargin(classname) {
sealed class Remove(vararg classnames: String) : UIKitMargin(*classnames) {
object Top : Remove("uk-margin-remove-top")
object Bottom : Remove("uk-margin-remove-bottom")
object Left : Remove("uk-margin-remove-left")
object Right : Remove("uk-margin-remove-right")
object Vertical : Remove("uk-margin-remove-vertical")
object Horizontal : Remove() { override val classes: Array<String> = Left.classes + Right.classes }
object Adjacent : Remove("uk-margin-remove-adjacent")
object FirstChild : Remove("uk-margin-remove-first-child")
object LastChild : Remove("uk-margin-remove-last-child")

View File

@@ -0,0 +1,58 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.buildAttribute
sealed class UIKitModal(
classname: String,
override val otherAttrs: Map<String, String> = emptyMap()
) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
object Dialog : UIKitModal("uk-modal-dialog")
object Title : UIKitModal("uk-modal-title")
object Header : UIKitModal("uk-modal-header")
object Body : UIKitModal("uk-modal-body")
object Footer : UIKitModal("uk-modal-footer")
object Container : UIKitModal("uk-modal-container")
object Full : UIKitModal("uk-modal-full")
object Page : UIKitModal("uk-modal-page")
sealed class Close(classname: String) : UIKitModal(classname) {
object Default : Close("uk-modal-close-default")
object Outside : Close("uk-modal-close-outside")
object Full : Close("uk-modal-close-full")
companion object : Close("uk-modal-close")
}
internal class WithCustomAttributes(
otherAttrs: Map<String, String> = emptyMap()
) : UIKitModal("uk-modal", otherAttrs)
companion object : UIKitModal("uk-modal", mapOf("uk-modal" to "")) {
operator fun invoke(
escClose: Boolean? = null,
backgroundClose: Boolean? = null,
stack: Boolean? = null,
container: Boolean? = null,
classPage: String? = null,
classPanel: String? = null,
closingSelection: String? = null,
): UIKitModal = WithCustomAttributes(
mapOf(
buildAttribute("uk-modal") {
"esc-close" to escClose
"bg-close" to backgroundClose
"stack" to stack
"container" to container
"cls-page" to classPage
"cls-panel" to classPanel
"sel-close" to closingSelection
}
)
)
}
}

View File

@@ -3,8 +3,7 @@ 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 Header : UIKitNav("uk-nav-header")
object Divider : UIKitNav("uk-nav-divider")
@@ -14,4 +13,8 @@ sealed class UIKitNav(classname: String) : UIKitModifier {
object Primary : UIKitNav("uk-nav-primary")
object Center : UIKitNav("uk-nav-center")
companion object : UIKitNav("uk-nav") {
val SubNav = UIKitSubNav
}
}

View File

@@ -18,3 +18,5 @@ sealed class UIKitScreenSizeModifier(val name: String) {
modifier
)
}
fun UIKitModifier.applyWhenScreenSizeIs(size: UIKitScreenSizeModifier) = size.modify(this)

View File

@@ -0,0 +1,10 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitSubNav(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
object Divider : UIKitSubNav("uk-subnav-divider")
object Pill : UIKitSubNav("uk-subnav-pill")
companion object : UIKitSubNav("uk-subnav")
}

View File

@@ -3,16 +3,34 @@ package dev.inmo.jsuikit.modifiers
sealed class UIKitText(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-text-$suffix")
object Lead : UIKitText("lead")
object Meta : UIKitText("meta")
sealed class Alignment(suffix: String) : UIKitText(suffix) {
object Left : Alignment("left")
object Right : Alignment("right")
object Center : Alignment("center")
object Justify : Alignment("justify")
sealed class Style(suffix: String) : UIKitText(suffix) {
object Lead : Style("lead")
object Meta : Style("meta")
object Italic : Style("italic")
}
sealed class Size(suffix: String) : UIKitText(suffix) {
object Small : Size("small")
object Default : Size("default")
object Large : Size("large")
}
sealed class Weight(suffix: String) : UIKitText(suffix) {
object Light : Weight("light")
object Normal : Weight("normal")
object Bold : Weight("bold")
object Lighter : Weight("lighter")
object Bolder : Weight("bolder")
}
sealed class Transform(suffix: String) : UIKitText(suffix) {
object Capitalize : Transform("capitalize")
object Uppercase : Transform("uppercase")
object Lowercase : Transform("lowercase")
}
object DecorationNone : UIKitText("decoration-none")
sealed class Color(suffix: String) : UIKitText(suffix) {
object Muted : Color("muted")
object Emphasis : Color("emphasis")
@@ -22,4 +40,32 @@ sealed class UIKitText(suffix: String) : UIKitModifier {
object Warning : Color("warning")
object Danger : Color("danger")
}
object Background : UIKitText("background")
sealed class Alignment(suffix: String) : UIKitText(suffix) {
sealed class Horizontal(suffix: String) : Alignment(suffix) {
object Left : Horizontal("left")
object Right : Horizontal("right")
object Center : Horizontal("center")
object Justify : Horizontal("justify")
}
sealed class Vertical(suffix: String) : Alignment(suffix) {
object Top : Vertical("top")
object Middle : Vertical("middle")
object Bottom : Vertical("bottom")
object Baseline : Vertical("baseline")
}
}
sealed class Wrapping(suffix: String) : UIKitText(suffix) {
object Truncate : Wrapping("truncate")
object Break : Wrapping("break")
object NoWrap : Wrapping("nowrap")
}
}

View File

@@ -1,5 +1,7 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.buildAttribute
class UIKitTooltipModifier(
text: String,
align: Align? = null,
@@ -8,16 +10,15 @@ class UIKitTooltipModifier(
duration: Int? = null,
animation: UIKitAnimation? = null
) : UIKitModifier {
private val parametersMap = listOfNotNull(
"title" to text,
align ?.let { it.k to it.v },
delay ?.let { "delay" to it.toString() },
offset ?.let { "offset" to it.toString() },
duration ?.let { "duration" to it.toString() },
animation ?.let { "animation" to it.name },
)
override val otherAttrs: Map<String, String> = mapOf(
"uk-tooltip" to parametersMap.joinToString(";") { (k, v) -> "$k: $v" }
buildAttribute("uk-tooltip") {
"title" to text
align ?.let { it.k to it.v }
delay ?.let { "delay" to it.toString() }
offset ?.let { "offset" to it.toString() }
duration ?.let { "duration" to it.toString() }
animation ?.let { "animation" to it.name }
}
)
sealed class Align(name: String) {

View File

@@ -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")
}

View File

@@ -0,0 +1,30 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitVisibility(classname: String) : UIKitModifier {
override val classes: Array<String> = arrayOf(classname)
sealed class Hidden(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-hidden${suffix ?.let { "-$it" } ?: ""}")
object Hover : Hidden("hover")
sealed class Touch(suffix: String?) : Hidden(suffix) {
override val classes: Array<String> = arrayOf("${suffix ?: ""}touch")
object No : Touch("no")
companion object : Touch(null)
}
companion object : Hidden(null) {
val NoTouch = Touch.No
}
}
sealed class Invisible(suffix: String?) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-invisible${suffix ?.let { "-$it" } ?: ""}")
object Hover : Invisible("hover")
companion object : Invisible(null)
}
}

View File

@@ -1,33 +1,82 @@
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 Full : UIKitWidth("1-1")
object Expand : UIKitWidth("expand")
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")
val TwoFourth get() = Half
object ThreeFourth : UIKitWidth("3-4")
val FourFourth get() = Full
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")
val FiveFifth get() = Full
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")
val TwoSixth get() = OneThird
val ThreeSixth get() = Half
val FourSixth get() = TwoThird
object FiveSixth : UIKitWidth("5-6")
val SixSixth get() = Full
object OneSixth : UIKitWidth("uk-width-1-6")
object FiveSixth : UIKitWidth("uk-width-5-6")
sealed class Child(suffix: String) : UIKitWidth("uk-child-width-$suffix") {
object Full : Child("1-1")
object Half : Child("1-2")
object OneThird : Child("1-3")
object TwoThird : Child("2-3")
object OneFourth : Child("1-4")
object ThreeFourth : Child("3-4")
object OneFifth : Child("1-5")
object TwoFifth : Child("2-5")
object ThreeFifth : Child("3-5")
object FourFifth : Child("4-5")
object OneSixth : Child("1-6")
object FiveSixth : Child("5-6")
object Auto : Child("auto")
object Expand : Child("expand")
companion object {
val TwoFourth get() = Half
val TwoSixth get() = OneThird
val ThreeSixth get() = Half
val FourSixth get() = TwoThird
val FourFourth get() = Full
val FiveFifth get() = Full
val SixSixth get() = Full
}
}
sealed class Fixed(suffix: String) : UIKitWidth("uk-width-$suffix") {
object Small : Fixed("small")
object Medium : Fixed("medium")
object Large : Fixed("large")
object XLarge : Fixed("xlarge")
object XXLarge : Fixed("2xlarge")
}
override fun toString() = classes.first()
companion object {
val TwoFourth get() = Half
val TwoSixth get() = OneThird
val ThreeSixth get() = Half
val FourSixth get() = TwoThird
val FourFourth get() = Full
val FiveFifth get() = Full
val SixSixth get() = Full
}
}

View File

@@ -0,0 +1,11 @@
package dev.inmo.jsuikit.utils
fun <T> Array<T>.anyNotNull(): Boolean {
for (item in this) {
if (item != null) {
return true
}
}
return false
}

View File

@@ -0,0 +1,27 @@
package dev.inmo.jsuikit.utils
class AttributeBuilder (
val attributeName: String,
val skipNullValues: Boolean = true,
private val parametersPreset: MutableMap<String, String?> = mutableMapOf()
) {
fun add(k: String, v: Any? = null) {
if (v != null || !skipNullValues) {
parametersPreset[k] = v ?.toString()
}
}
infix fun String.to(value: Any?) = add(this, value)
operator fun String.unaryPlus() = add(this, null)
fun build(): Pair<String, String> = Pair(
attributeName, parametersPreset.toList().joinToString(";") {
"${it.first}${it.second ?.let { ": $it" } ?: ""}"
}
)
}
inline fun buildAttribute(attributeName: String, skipNullValues: Boolean = true, block: AttributeBuilder.() -> Unit) = AttributeBuilder(
attributeName,
skipNullValues
).apply(block).build()

View File

@@ -0,0 +1,26 @@
package dev.inmo.jsuikit.utils
import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include
import org.jetbrains.compose.web.attributes.AttrsBuilder
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.w3c.dom.Element
class AttributesCollection<T : Element> (
private vararg val modifiers: UIKitModifier,
private val attrs: AttrBuilderContext<T> = {}
) {
val builder: AttrBuilderContext<T> = {
include(*modifiers)
attrs()
}
companion object {
val Empty = Attrs<Element>()
@Suppress("UNCHECKED_CAST")
fun <T : Element> empty() = Empty as Attrs<T>
}
}
typealias Attrs<T> = AttributesCollection<T>

View File

@@ -0,0 +1,16 @@
package dev.inmo.jsuikit.utils
import androidx.compose.runtime.Composable
import org.jetbrains.compose.web.dom.ContentBuilder
import org.w3c.dom.Element
@Composable
inline fun <T : Element> optionallyDraw (
attrs: Attrs<T>? = null,
noinline contentBuilder: ContentBuilder<T>? = null,
whatToDraw: @Composable () -> Unit
) {
if (attrs != null || contentBuilder != null) {
whatToDraw()
}
}

View File

@@ -0,0 +1,5 @@
package dev.inmo.jsuikit.utils
value class Percents(val int: Int) {
override fun toString(): String = "${int}%"
}

View File

@@ -0,0 +1,5 @@
package dev.inmo.jsuikit.utils
value class Pixels(val int: Int) {
override fun toString(): String = "${int}px"
}