mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2025-12-25 07:36:31 +00:00
Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4a7101697a | |||
| 17badd4724 | |||
| 39e54e8ca3 | |||
| ed31eb01e5 | |||
| 9d06725221 | |||
| d8d4a7fcf1 | |||
| 252fe4a295 | |||
| 6dbff07692 | |||
| e94585fc7e | |||
| b449caae13 | |||
| 95edaf1cfe | |||
| cb2fbe9f42 | |||
| 598e481f75 | |||
| 2a76519843 | |||
| 8e9ff07b71 | |||
| 13556a293c | |||
| a4d4ec3db8 | |||
| 6f095de81d | |||
| 6b60d22e1e | |||
| 4e0cc3621c | |||
| 4943490910 | |||
| b60a3bc279 | |||
| 228138757d | |||
| f1dedf1e09 | |||
| 936bb2d6fd | |||
| 0da87743e8 | |||
| 36eeb012c6 | |||
| 58f8f99e10 | |||
| d1c03e5c48 | |||
| bd19572d78 | |||
| 9449eccec1 | |||
| f518933195 | |||
| 23f3ecb0d4 | |||
| c6023d3075 | |||
| 7b72f99f66 | |||
| 66c3f97f65 | |||
| 40c3c0f437 | |||
| e46b2e0ddd | |||
| 2db4e48571 | |||
| e13a2fd241 | |||
| b3b19ed2b7 | |||
| d590762d28 | |||
| 65703d1c22 | |||
| 814045a43f | |||
| 1f36657857 | |||
| a2830e5e85 | |||
| 484564e323 | |||
| b5e93bc829 | |||
| 4282165d79 | |||
| 1e452c78d1 | |||
| 5fa388c169 | |||
| 763e1fa5ac | |||
| 150efa1719 | |||
| 20bf43b8a1 | |||
| 93dd63c6b1 | |||
| eb06ff80a1 | |||
| 25ba9188e3 | |||
| 19ca960b35 | |||
| ef3b711e2b | |||
| 6bebb8b8d4 | |||
| c013a978d4 | |||
| 9f342f428a | |||
| 0beb781e2c | |||
| 5880db3db1 | |||
| b7e08af54a |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ out/
|
|||||||
|
|
||||||
secret.gradle
|
secret.gradle
|
||||||
local.properties
|
local.properties
|
||||||
|
local.*
|
||||||
|
|
||||||
kotlin-js-store/
|
kotlin-js-store/
|
||||||
|
|
||||||
|
|||||||
90
CHANGELOG.md
90
CHANGELOG.md
@@ -1,3 +1,93 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
## 0.0.7
|
||||||
|
|
||||||
|
Rewrite project onto multiplatform paradigm and return back varargs instead of most `Array<UIKitModifier>`
|
||||||
|
|
||||||
## 0.0.6
|
## 0.0.6
|
||||||
|
|
||||||
Changes in signatures of text field and list
|
Changes in signatures of text field and list
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
# JSUIKit Kotlin
|
# 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
|
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.
|
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
|
## How to include
|
||||||
|
|
||||||
Last version: [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/jsuikitkotlin)
|
Last version: [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/kjsuikit)
|
||||||
|
|
||||||
```groovy
|
```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
|
**THIS LIBRARY DO NOT ADD ANY JS OR CSS**. So, you must download and include UIKit js/css by yourself. See
|
||||||
|
|||||||
39
build.gradle
39
build.gradle
@@ -15,35 +15,44 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.kt.js)
|
alias(libs.plugins.kt.multiplatform)
|
||||||
alias(libs.plugins.jb.compose)
|
alias(libs.plugins.jb.compose)
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "$version"
|
project.version = "$version"
|
||||||
project.group = "$group"
|
project.group = "$group"
|
||||||
|
|
||||||
allprojects {
|
repositories {
|
||||||
repositories {
|
mavenLocal()
|
||||||
mavenLocal()
|
mavenCentral()
|
||||||
mavenCentral()
|
google()
|
||||||
google()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
js(IR) {
|
js(IR) {
|
||||||
browser()
|
browser()
|
||||||
binaries.executable()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation libs.kt.stdlib
|
||||||
|
implementation compose.runtime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsMain {
|
||||||
|
dependencies {
|
||||||
|
implementation compose.web.core
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
jsTest {
|
||||||
implementation libs.kt.stdlib
|
dependencies {
|
||||||
implementation compose.web.core
|
implementation libs.kt.test.js
|
||||||
implementation compose.runtime
|
implementation libs.kt.test.junit
|
||||||
testImplementation libs.kt.test.js
|
}
|
||||||
testImplementation libs.kt.test.junit
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "./github_release.gradle"
|
apply from: "./github_release.gradle"
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ android.enableJetifier=true
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.0.6
|
version=0.0.27
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ buildscript-gh-release = { module = "com.github.breadmoirai:github-release", ver
|
|||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
|
|
||||||
kt-js = { id = "org.jetbrains.kotlin.js", version.ref = "kt" }
|
kt-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kt" }
|
||||||
jb-compose = { id = "org.jetbrains.compose", version.ref = "jb-compose" }
|
jb-compose = { id = "org.jetbrains.compose", version.ref = "jb-compose" }
|
||||||
|
|||||||
1
local.make_version.sh
Executable file
1
local.make_version.sh
Executable file
@@ -0,0 +1 @@
|
|||||||
|
git add -A && git stash && git checkout master && git pull && git checkout -b "$1" && nano gradle.properties CHANGELOG.md && git add -A && git commit -m "start $1" && git stash pop && git add -A && nano CHANGELOG.md && git add -A && git commit -m "$2" && git push --set-upstream origin "$1" && ./gradlew clean && ./gradlew publishToMavenLocal
|
||||||
@@ -1,65 +1,50 @@
|
|||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
task javadocJar(type: Jar) {
|
task javadocsJar(type: Jar) {
|
||||||
classifier = 'javadoc'
|
classifier = 'javadoc'
|
||||||
}
|
}
|
||||||
task sourcesJar(type: Jar) {
|
|
||||||
kotlin.sourceSets.all {
|
|
||||||
from(kotlin)
|
|
||||||
}
|
|
||||||
classifier = 'sources'
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications.all {
|
||||||
maven(MavenPublication) {
|
artifact javadocsJar
|
||||||
kotlin.js().components.forEach {
|
|
||||||
from(it)
|
pom {
|
||||||
|
description = "${project.name}"
|
||||||
|
name = "${project.name}"
|
||||||
|
url = "https://github.com/InsanusMokrassar/JSUIKitKBindings"
|
||||||
|
|
||||||
|
scm {
|
||||||
|
developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/JSUIKitKBindings.git[push=]https://github.com/InsanusMokrassar/JSUIKitKBindings.git"
|
||||||
|
url = "https://github.com/InsanusMokrassar/JSUIKitKBindings.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
artifact javadocJar
|
developers {
|
||||||
artifact sourcesJar
|
|
||||||
|
|
||||||
pom {
|
developer {
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
id = "InsanusMokrassar"
|
||||||
|
name = "Ovsiannikov Aleksei"
|
||||||
|
email = "ovsyannikov.alexey95@gmail.com"
|
||||||
|
}
|
||||||
|
|
||||||
description = "${project.name}"
|
|
||||||
name = "${project.name}"
|
|
||||||
url = "https://github.com/InsanusMokrassar/JSUIKitKBindings"
|
|
||||||
|
|
||||||
scm {
|
|
||||||
developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/JSUIKitKBindings.git[push=]https://github.com/InsanusMokrassar/JSUIKitKBindings.git"
|
|
||||||
url = "https://github.com/InsanusMokrassar/JSUIKitKBindings.git"
|
|
||||||
}
|
|
||||||
|
|
||||||
developers {
|
|
||||||
|
|
||||||
developer {
|
|
||||||
id = "InsanusMokrassar"
|
|
||||||
name = "Ovsiannikov Aleksei"
|
|
||||||
email = "ovsyannikov.alexey95@gmail.com"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
licenses {
|
|
||||||
|
|
||||||
license {
|
|
||||||
name = "Apache Software License 2.0"
|
|
||||||
url = "https://opensource.org/licenses/Apache-2.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
repositories {
|
|
||||||
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
licenses {
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
license {
|
||||||
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
name = "Apache Software License 2.0"
|
||||||
credentials {
|
url = "https://opensource.org/licenses/Apache-2.0"
|
||||||
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
}
|
||||||
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
if ((project.hasProperty('SONATYPE_USER') || System.getenv('SONATYPE_USER') != null) && (project.hasProperty('SONATYPE_PASSWORD') || System.getenv('SONATYPE_PASSWORD') != null)) {
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
|
credentials {
|
||||||
|
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
|
||||||
|
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://opensource.org/licenses/Apache-2.0"}],"mavenConfig":{"name":"${project.name}","description":"${project.name}","url":"https://github.com/InsanusMokrassar/JSUIKitKBindings","vcsUrl":"https://github.com/InsanusMokrassar/JSUIKitKBindings.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}},"type":"JS"}
|
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://opensource.org/licenses/Apache-2.0"}],"mavenConfig":{"name":"${project.name}","description":"${project.name}","url":"https://github.com/InsanusMokrassar/JSUIKitKBindings","vcsUrl":"https://github.com/InsanusMokrassar/JSUIKitKBindings.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}
|
||||||
@@ -12,9 +12,8 @@ import org.w3c.dom.events.Event
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DefaultButton(
|
fun DefaultButton(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
disabled: Boolean = false,
|
disabled: Boolean = false,
|
||||||
buttonType: UIKitButton.Type = UIKitButton.Type.Default,
|
|
||||||
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
|
onClick: ((SyntheticMouseEvent) -> Unit)? = null,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
||||||
contentAllocator: ContentBuilder<HTMLButtonElement>
|
contentAllocator: ContentBuilder<HTMLButtonElement>
|
||||||
@@ -22,8 +21,7 @@ fun DefaultButton(
|
|||||||
Button(
|
Button(
|
||||||
{
|
{
|
||||||
onClick ?.let { onClick(it) }
|
onClick ?.let { onClick(it) }
|
||||||
classes("uk-button")
|
include(UIKitButton, *modifiers)
|
||||||
include(*modifiers, buttonType)
|
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
disabled()
|
disabled()
|
||||||
}
|
}
|
||||||
@@ -37,14 +35,13 @@ fun DefaultButton(
|
|||||||
@Composable
|
@Composable
|
||||||
fun DefaultButton(
|
fun DefaultButton(
|
||||||
text: String,
|
text: String,
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
disabled: Boolean = false,
|
disabled: Boolean = false,
|
||||||
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> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLButtonElement> = {},
|
||||||
onClick: ((SyntheticMouseEvent) -> Unit)? = null
|
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() }
|
preTextContentAllocator ?.apply { preTextContentAllocator() }
|
||||||
Text(text)
|
Text(text)
|
||||||
afterTextContentAllocator ?.apply { afterTextContentAllocator() }
|
afterTextContentAllocator ?.apply { afterTextContentAllocator() }
|
||||||
@@ -53,7 +50,7 @@ fun DefaultButton(
|
|||||||
@Composable
|
@Composable
|
||||||
fun UploadButton(
|
fun UploadButton(
|
||||||
text: String,
|
text: String,
|
||||||
buttonModifiers: Array<UIKitModifier> = emptyArray(),
|
vararg buttonModifiers: UIKitModifier,
|
||||||
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,
|
||||||
79
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt
Normal file
79
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Card.kt
Normal 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
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ private class DialogDisposableEffectResult(
|
|||||||
@Composable
|
@Composable
|
||||||
fun Dialog(
|
fun Dialog(
|
||||||
title: String? = null,
|
title: String? = null,
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
hide: (() -> Unit)? = null,
|
hide: (() -> Unit)? = null,
|
||||||
hidden: (() -> Unit)? = null,
|
hidden: (() -> Unit)? = null,
|
||||||
footerBuilder: (@Composable () -> Unit)? = null,
|
footerBuilder: (@Composable () -> Unit)? = null,
|
||||||
40
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Divider.kt
Normal file
40
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Divider.kt
Normal file
@@ -0,0 +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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ import org.w3c.dom.HTMLDivElement
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Dropdown(
|
fun Dropdown(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
toggle: String? = null,
|
toggle: String? = null,
|
||||||
pos: UIKitDropdown.Position? = null,
|
pos: UIKitDropdown.Position? = null,
|
||||||
mode: UIKitDropdown.Mode? = null,
|
mode: UIKitDropdown.Mode? = null,
|
||||||
@@ -8,7 +8,7 @@ import org.w3c.dom.HTMLDivElement
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Flex(
|
fun Flex(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
filler: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
filler: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
||||||
) {
|
) {
|
||||||
@@ -8,7 +8,7 @@ import org.w3c.dom.HTMLDivElement
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun GridColumn(
|
fun GridColumn(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
|
||||||
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit
|
||||||
) {
|
) {
|
||||||
@@ -24,7 +24,7 @@ fun GridColumn(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Grid(
|
fun Grid(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
masonry: Boolean = false,
|
masonry: Boolean = false,
|
||||||
parallax: Int? = null,
|
parallax: Int? = null,
|
||||||
marginClass: String? = null,
|
marginClass: String? = null,
|
||||||
@@ -204,7 +204,7 @@ sealed class Icon(val name: String) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
operator fun invoke(
|
operator fun invoke(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
type: UIKitIconType = UIKitIconType.Default,
|
type: UIKitIconType = UIKitIconType.Default,
|
||||||
ratio: Float? = null,
|
ratio: Float? = null,
|
||||||
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||||
@@ -219,26 +219,36 @@ sealed class Icon(val name: String) {
|
|||||||
}
|
}
|
||||||
attributesCustomizer()
|
attributesCustomizer()
|
||||||
}
|
}
|
||||||
if (type == UIKitIconType.Button) {
|
when (type) {
|
||||||
Button(configurer)
|
UIKitIconType.Default -> Span(configurer)
|
||||||
} else {
|
UIKitIconType.Link -> A(href = "#", configurer)
|
||||||
Span(configurer)
|
UIKitIconType.Button -> Button(configurer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Custom(name: String) : Icon(name)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun drawAsButton(
|
fun drawAsButton(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
ratio: Float? = null,
|
ratio: Float? = null,
|
||||||
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||||
onClick: ((Event) -> Unit)? = null
|
onClick: ((Event) -> Unit)? = null
|
||||||
) = invoke(modifiers, type = UIKitIconType.Button, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
|
) = invoke(*modifiers, type = UIKitIconType.Button, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun drawAsIcon(
|
fun drawAsIcon(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
ratio: Float? = null,
|
ratio: Float? = null,
|
||||||
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
|
||||||
onClick: ((Event) -> Unit)? = null
|
onClick: ((Event) -> Unit)? = null
|
||||||
) = invoke(modifiers, type = UIKitIconType.Default, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
|
) = 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)
|
||||||
}
|
}
|
||||||
20
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Labels.kt
Normal file
20
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Labels.kt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
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.HTMLSpanElement
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Label(
|
||||||
|
text: String,
|
||||||
|
attrs: Attrs<HTMLSpanElement>
|
||||||
|
) = Span(
|
||||||
|
{
|
||||||
|
include(UIKitLabel)
|
||||||
|
attrs.builder(this)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Text(text)
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import org.w3c.dom.HTMLUListElement
|
|||||||
fun <T> List(
|
fun <T> List(
|
||||||
title: String,
|
title: String,
|
||||||
data: SnapshotStateList<T>,
|
data: SnapshotStateList<T>,
|
||||||
titleModifiers: Array<UIKitModifier> = emptyArray(),
|
vararg titleModifiers: UIKitModifier,
|
||||||
ulModifiers: Array<UIKitModifier> = emptyArray(),
|
ulModifiers: Array<UIKitModifier> = emptyArray(),
|
||||||
besidesTitleAndList: (@Composable () -> Unit)? = null,
|
besidesTitleAndList: (@Composable () -> Unit)? = null,
|
||||||
titleCustomizer: AttrBuilderContext<HTMLHeadingElement> = {},
|
titleCustomizer: AttrBuilderContext<HTMLHeadingElement> = {},
|
||||||
277
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Nav.kt
Normal file
277
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Nav.kt
Normal file
@@ -0,0 +1,277 @@
|
|||||||
|
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.jetbrains.compose.web.dom.Text
|
||||||
|
import org.w3c.dom.*
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Nav(
|
||||||
|
vararg modifiers: UIKitModifier,
|
||||||
|
multiple: Boolean? = null,
|
||||||
|
collapsible: Boolean? = null,
|
||||||
|
animation: UIKitAnimation? = null,
|
||||||
|
duration: Milliseconds? = null,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
||||||
|
dataAllocator: ContentBuilder<HTMLUListElement>
|
||||||
|
) {
|
||||||
|
Ul(
|
||||||
|
{
|
||||||
|
buildAndAddAttribute("uk-nav") {
|
||||||
|
"multiple" to multiple ?.toString()
|
||||||
|
"collapsible" to collapsible ?.toString()
|
||||||
|
"animation" to animation
|
||||||
|
"duration" to duration ?.toString()
|
||||||
|
}
|
||||||
|
include(*modifiers, UIKitNav)
|
||||||
|
attributesCustomizer()
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
dataAllocator()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||||
|
contentAllocator: ContentBuilder<HTMLLIElement>
|
||||||
|
) {
|
||||||
|
Li(
|
||||||
|
{
|
||||||
|
include(*modifiers)
|
||||||
|
attributesCustomizer()
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
contentAllocator()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun NavDivider(
|
||||||
|
vararg modifiers: UIKitModifier,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
||||||
|
) {
|
||||||
|
Li({ include(UIKitNav.Divider, *modifiers);attributesCustomizer() })
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ fun Navbar(
|
|||||||
leftBuilder: NavbarNavBuilder? = null,
|
leftBuilder: NavbarNavBuilder? = null,
|
||||||
centerBuilder: NavbarNavBuilder? = null,
|
centerBuilder: NavbarNavBuilder? = null,
|
||||||
rightBuilder: NavbarNavBuilder? = null,
|
rightBuilder: NavbarNavBuilder? = null,
|
||||||
navModifiers: Array<UIKitModifier> = emptyArray(),
|
vararg navModifiers: UIKitModifier,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLElement> = {},
|
||||||
) {
|
) {
|
||||||
Nav(
|
Nav(
|
||||||
@@ -10,7 +10,7 @@ import org.w3c.dom.HTMLProgressElement
|
|||||||
@Composable
|
@Composable
|
||||||
fun Progress(
|
fun Progress(
|
||||||
value: Int,
|
value: Int,
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
max: Int = 100,
|
max: Int = 100,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLProgressElement> = {}
|
attributesCustomizer: AttrBuilderContext<HTMLProgressElement> = {}
|
||||||
) {
|
) {
|
||||||
@@ -8,7 +8,7 @@ import org.w3c.dom.HTMLDivElement
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Spinner(
|
fun Spinner(
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
ratio: Float? = null,
|
ratio: Float? = null,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {}
|
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {}
|
||||||
) {
|
) {
|
||||||
@@ -23,6 +23,4 @@ fun Spinner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DefaultSpinner() = Spinner(
|
fun DefaultSpinner() = Spinner(UIKitAlign.Center, UIKitMargin.Small, UIKitText.Alignment.Center)
|
||||||
arrayOf(UIKitAlign.Center, UIKitMargin.Small, UIKitText.Alignment.Center)
|
|
||||||
)
|
|
||||||
@@ -9,12 +9,12 @@ import org.jetbrains.compose.web.dom.Input
|
|||||||
import org.w3c.dom.HTMLInputElement
|
import org.w3c.dom.HTMLInputElement
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> TextField(
|
fun <T> StandardInput(
|
||||||
type: InputType<T>,
|
type: InputType<T>,
|
||||||
state: MutableState<T>,
|
state: MutableState<T>,
|
||||||
disabledState: State<Boolean>? = null,
|
disabledState: State<Boolean>? = null,
|
||||||
placeholder: String? = null,
|
placeholder: String? = null,
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
vararg modifiers: UIKitModifier,
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
|
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
|
||||||
) {
|
) {
|
||||||
Input(type) {
|
Input(type) {
|
||||||
@@ -23,7 +23,16 @@ fun <T> TextField(
|
|||||||
|
|
||||||
placeholder ?.let(::placeholder)
|
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 {
|
disabledState ?.let {
|
||||||
if (it.value) {
|
if (it.value) {
|
||||||
disabled()
|
disabled()
|
||||||
@@ -32,3 +41,14 @@ fun <T> TextField(
|
|||||||
attributesCustomizer()
|
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)
|
||||||
104
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt
Normal file
104
src/jsMain/kotlin/dev/inmo/jsuikit/elements/Table.kt
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
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(
|
||||||
|
headerBuilders: List<ContentBuilder<HTMLTableCellElement>>,
|
||||||
|
dataList: SnapshotStateList<T>,
|
||||||
|
vararg tableModifiers: UIKitModifier,
|
||||||
|
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
||||||
|
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 = headerBuilders.indices
|
||||||
|
Table(
|
||||||
|
{
|
||||||
|
classes("uk-table")
|
||||||
|
include(*tableModifiers)
|
||||||
|
attributesCustomizer()
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
Thead(headerCustomizer) {
|
||||||
|
Tr {
|
||||||
|
headerBuilders.forEachIndexed { i, t ->
|
||||||
|
Th(
|
||||||
|
{
|
||||||
|
headerCellCustomizer(i)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
t()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
betweenHeaderAndBodyFiller()
|
||||||
|
Tbody {
|
||||||
|
dataList.forEach {
|
||||||
|
Tr(
|
||||||
|
{
|
||||||
|
rowAttributes(it)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
headingIndexes.forEach { i ->
|
||||||
|
Td(
|
||||||
|
{
|
||||||
|
cellCustomizer(i, it)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
cellFiller(i, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
sealed class UIKitButton(suffix: String) : UIKitModifier {
|
sealed class UIKitButton(suffix: String?) : UIKitModifier {
|
||||||
override val classes: Array<String> = arrayOf("uk-button-$suffix")
|
override val classes: Array<String> = arrayOf("uk-button${suffix?.let { "-$it" } ?: ""}")
|
||||||
|
|
||||||
sealed class Type(suffix: String) : UIKitButton(suffix) {
|
sealed class Type(suffix: String) : UIKitButton(suffix) {
|
||||||
object Default : Type("default")
|
object Default : Type("default")
|
||||||
@@ -11,4 +11,6 @@ sealed class UIKitButton(suffix: String) : UIKitModifier {
|
|||||||
object Text : Type("text")
|
object Text : Type("text")
|
||||||
object Link : Type("link")
|
object Link : Type("link")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object : UIKitButton(null)
|
||||||
}
|
}
|
||||||
35
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitCard.kt
Normal file
35
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitCard.kt
Normal 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)
|
||||||
|
}
|
||||||
15
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitColumn.kt
Normal file
15
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitColumn.kt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
|
sealed class UIKitColumn(classname: String) : UIKitModifier {
|
||||||
|
override val classes: Array<String> = arrayOf(classname)
|
||||||
|
|
||||||
|
object Two : UIKitColumn("uk-column-1-2")
|
||||||
|
object Three : UIKitColumn("uk-column-1-3")
|
||||||
|
object Four : UIKitColumn("uk-column-1-4")
|
||||||
|
object Five : UIKitColumn("uk-column-1-5")
|
||||||
|
object Six : UIKitColumn("uk-column-1-6")
|
||||||
|
|
||||||
|
object Divider : UIKitColumn("uk-column-divider")
|
||||||
|
|
||||||
|
object Span : UIKitColumn("uk-column-span")
|
||||||
|
}
|
||||||
10
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDivider.kt
Normal file
10
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitDivider.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
|
sealed class UIKitDivider(classname: String) : UIKitModifier {
|
||||||
|
override val classes: Array<String> = arrayOf(classname)
|
||||||
|
|
||||||
|
object Icon : UIKitDivider("uk-divider-icon")
|
||||||
|
object Small : UIKitDivider("uk-divider-small")
|
||||||
|
object Vertical : UIKitDivider("uk-divider-vertical")
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
sealed class UIKitFlex(suffix: String) : UIKitModifier {
|
sealed class UIKitFlex(suffix: String?) : UIKitModifier {
|
||||||
override val classes: Array<String> = arrayOf("uk-flex-$suffix")
|
override val classes: Array<String> = arrayOf("uk-flex${suffix ?.let { "-$it" } ?: ""}")
|
||||||
|
|
||||||
object Inline : UIKitFlex("inline")
|
object Inline : UIKitFlex("inline")
|
||||||
|
|
||||||
@@ -76,4 +76,6 @@ sealed class UIKitFlex(suffix: String) : UIKitModifier {
|
|||||||
|
|
||||||
object NoWrap : UIKitFlex("nowrap")
|
object NoWrap : UIKitFlex("nowrap")
|
||||||
|
|
||||||
|
companion object : UIKitFlex(null)
|
||||||
|
|
||||||
}
|
}
|
||||||
11
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitLabel.kt
Normal file
11
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitLabel.kt
Normal 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)
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@ package dev.inmo.jsuikit.modifiers
|
|||||||
sealed class UIKitNav(classname: String) : UIKitModifier {
|
sealed class UIKitNav(classname: String) : UIKitModifier {
|
||||||
override val classes: Array<String> = arrayOf(classname)
|
override val classes: Array<String> = arrayOf(classname)
|
||||||
|
|
||||||
object Accordion : UIKitNav("uk-nav-parent-icon")
|
object ParentIcon : UIKitNav("uk-nav-parent-icon")
|
||||||
object Subnav : UIKitNav("uk-nav-sub")
|
object SubNav : UIKitNav("uk-nav-sub")
|
||||||
|
|
||||||
object Header : UIKitNav("uk-nav-header")
|
object Header : UIKitNav("uk-nav-header")
|
||||||
object Divider : UIKitNav("uk-nav-divider")
|
object Divider : UIKitNav("uk-nav-divider")
|
||||||
@@ -14,4 +14,6 @@ sealed class UIKitNav(classname: String) : UIKitModifier {
|
|||||||
object Primary : UIKitNav("uk-nav-primary")
|
object Primary : UIKitNav("uk-nav-primary")
|
||||||
|
|
||||||
object Center : UIKitNav("uk-nav-center")
|
object Center : UIKitNav("uk-nav-center")
|
||||||
|
|
||||||
|
companion object : UIKitNav("uk-nav")
|
||||||
}
|
}
|
||||||
@@ -18,3 +18,5 @@ sealed class UIKitScreenSizeModifier(val name: String) {
|
|||||||
modifier
|
modifier
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun UIKitModifier.applyWhenScreenSizeIs(size: UIKitScreenSizeModifier) = size.modify(this)
|
||||||
112
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitUtility.kt
Normal file
112
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitUtility.kt
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
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")
|
||||||
|
}
|
||||||
82
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitWidth.kt
Normal file
82
src/jsMain/kotlin/dev/inmo/jsuikit/modifiers/UIKitWidth.kt
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package dev.inmo.jsuikit.modifiers
|
||||||
|
|
||||||
|
sealed class UIKitWidth(classname: String) : UIKitModifier {
|
||||||
|
override val classes: Array<String> = arrayOf("uk-width-$classname")
|
||||||
|
|
||||||
|
object Auto : UIKitWidth("auto")
|
||||||
|
object Expand : UIKitWidth("expand")
|
||||||
|
object Full : UIKitWidth("1-1")
|
||||||
|
|
||||||
|
object Half : UIKitWidth("1-2")
|
||||||
|
|
||||||
|
object OneThird : UIKitWidth("1-3")
|
||||||
|
object TwoThird : UIKitWidth("2-3")
|
||||||
|
|
||||||
|
object OneFourth : UIKitWidth("1-4")
|
||||||
|
object ThreeFourth : UIKitWidth("3-4")
|
||||||
|
|
||||||
|
object OneFifth : UIKitWidth("1-5")
|
||||||
|
object TwoFifth : UIKitWidth("2-5")
|
||||||
|
object ThreeFifth : UIKitWidth("3-5")
|
||||||
|
object FourFifth : UIKitWidth("4-5")
|
||||||
|
|
||||||
|
object OneSixth : UIKitWidth("1-6")
|
||||||
|
object FiveSixth : UIKitWidth("5-6")
|
||||||
|
|
||||||
|
sealed class Child(suffix: String) : UIKitWidth("child-$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("fixed-$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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package dev.inmo.jsuikit.elements
|
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import org.jetbrains.compose.web.dom.Hr
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun Divider() = Hr({ classes("uk-divider-icon") })
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package dev.inmo.jsuikit.elements
|
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
|
||||||
import dev.inmo.jsuikit.modifiers.include
|
|
||||||
import org.jetbrains.compose.web.dom.*
|
|
||||||
import org.w3c.dom.HTMLSpanElement
|
|
||||||
|
|
||||||
sealed interface Label {
|
|
||||||
val suffix: String
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
operator fun invoke(
|
|
||||||
text: String,
|
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
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.Milliseconds
|
|
||||||
import org.jetbrains.compose.web.dom.*
|
|
||||||
import org.w3c.dom.HTMLLIElement
|
|
||||||
import org.w3c.dom.HTMLUListElement
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun Nav(
|
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
|
||||||
multiple: Boolean? = null,
|
|
||||||
collapsible: Boolean? = null,
|
|
||||||
animation: UIKitAnimation? = null,
|
|
||||||
duration: Milliseconds? = null,
|
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {},
|
|
||||||
dataAllocator: ContentBuilder<HTMLUListElement>
|
|
||||||
) {
|
|
||||||
Ul(
|
|
||||||
{
|
|
||||||
buildAndAddAttribute("uk-nav") {
|
|
||||||
"multiple" to multiple ?.toString()
|
|
||||||
"collapsible" to collapsible ?.toString()
|
|
||||||
"animation" to animation
|
|
||||||
"duration" to duration ?.toString()
|
|
||||||
}
|
|
||||||
classes("uk-nav")
|
|
||||||
include(*modifiers)
|
|
||||||
attributesCustomizer()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
dataAllocator()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun NavElement(
|
|
||||||
modifiers: Array<UIKitModifier> = emptyArray(),
|
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLLIElement> = {},
|
|
||||||
contentAllocator: ContentBuilder<HTMLLIElement>
|
|
||||||
) {
|
|
||||||
Li(
|
|
||||||
{
|
|
||||||
include(*modifiers)
|
|
||||||
attributesCustomizer
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
contentAllocator()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
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.dom.*
|
|
||||||
import org.w3c.dom.HTMLProgressElement
|
|
||||||
import org.w3c.dom.HTMLTableElement
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun <T> DefaultTable(
|
|
||||||
heading: List<String>,
|
|
||||||
dataList: SnapshotStateList<T>,
|
|
||||||
tableModifiers: Array<UIKitModifier> = emptyArray(),
|
|
||||||
attributesCustomizer: AttrBuilderContext<HTMLTableElement> = {},
|
|
||||||
cellFiller: @Composable (i: Int, t: T) -> Unit
|
|
||||||
) {
|
|
||||||
val headingIndexes = heading.indices
|
|
||||||
Table(
|
|
||||||
{
|
|
||||||
classes("uk-table")
|
|
||||||
include(*tableModifiers)
|
|
||||||
attributesCustomizer()
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Thead {
|
|
||||||
Tr {
|
|
||||||
heading.forEach {
|
|
||||||
Th(
|
|
||||||
{
|
|
||||||
include(UIKitExtension.TextTransformUnset)
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Text(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Tbody {
|
|
||||||
dataList.forEach {
|
|
||||||
Tr {
|
|
||||||
headingIndexes.forEach { i ->
|
|
||||||
Td {
|
|
||||||
cellFiller(i, it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
|
||||||
|
|
||||||
sealed class UIKitExtension(classname: String) : UIKitModifier {
|
|
||||||
override val classes: Array<String> = arrayOf(classname)
|
|
||||||
object TextTransformUnset : UIKitExtension("text_transform_unset")
|
|
||||||
object CursorPointer : UIKitExtension("cursor_pointer")
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
|
||||||
|
|
||||||
sealed class UIKitUtility(classname: String) : UIKitModifier {
|
|
||||||
override val classes: Array<String> = arrayOf(classname)
|
|
||||||
|
|
||||||
sealed class Overflow(suffix: String) : UIKitUtility("uk-overflow-$suffix") {
|
|
||||||
object Hidden : Overflow("hidden")
|
|
||||||
object Auto : Overflow("auto")
|
|
||||||
}
|
|
||||||
|
|
||||||
object Logo : UIKitUtility("uk-logo")
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package dev.inmo.jsuikit.modifiers
|
|
||||||
|
|
||||||
sealed class UIKitWidth(classname: String) : UIKitModifier {
|
|
||||||
override val classes: Array<String> = arrayOf("uk-width-$classname")
|
|
||||||
|
|
||||||
object Full : UIKitWidth("1-1")
|
|
||||||
object Expand : UIKitWidth("expand")
|
|
||||||
|
|
||||||
object Half : UIKitWidth("1-2")
|
|
||||||
|
|
||||||
object OneThird : UIKitWidth("1-3")
|
|
||||||
object TwoThird : UIKitWidth("2-3")
|
|
||||||
|
|
||||||
object OneFourth : UIKitWidth("1-4")
|
|
||||||
val TwoFourth get() = Half
|
|
||||||
object ThreeFourth : UIKitWidth("3-4")
|
|
||||||
val FourFourth get() = Full
|
|
||||||
|
|
||||||
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 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
|
|
||||||
|
|
||||||
override fun toString() = classes.first()
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user