Compare commits

...

95 Commits

Author SHA1 Message Date
a48de4e095 Merge pull request #87 from InsanusMokrassar/0.7.6
0.7.6
2024-03-17 14:18:28 +06:00
1582b7a93b update dependencies 2024-03-17 14:17:19 +06:00
687e9941d9 start 0.7.6 2024-03-17 14:16:26 +06:00
4d92b9630c improve of publishing scripts 2024-03-13 11:55:13 +06:00
212acfd68d Merge pull request #86 from InsanusMokrassar/0.7.5
0.7.5
2024-03-13 11:49:27 +06:00
d437730be6 update dependencies 2024-03-13 11:48:35 +06:00
57d81a2856 start 0.7.5 2024-03-13 11:46:07 +06:00
2e665a8411 Merge pull request #85 from InsanusMokrassar/0.7.4
0.7.4
2023-11-26 21:17:56 +06:00
96d5936e83 update dependencies 2023-11-26 21:14:31 +06:00
de6253c50e start 0.7.4 2023-11-26 21:14:08 +06:00
1f66ca8346 Merge pull request #84 from InsanusMokrassar/0.7.3
0.7.3
2023-11-02 22:29:42 +06:00
7dc0e08a78 fix in publishing script 2023-11-02 22:29:21 +06:00
0eb80f141a update gradle wrapper 2023-11-02 22:27:15 +06:00
120df9d84e start 0.7.3 and update dependencies 2023-11-02 22:24:34 +06:00
6783bd6666 Merge pull request #83 from InsanusMokrassar/0.7.2
0.7.2
2023-09-07 01:16:01 +06:00
9c4bc444dd update dependencies 2023-09-07 01:12:39 +06:00
0635b4a233 start 0.7.2 2023-09-07 01:09:03 +06:00
29fe133777 Merge pull request #82 from InsanusMokrassar/0.7.1
0.7.1
2023-06-19 16:47:32 +06:00
d2ba2fe96a improvements 2023-06-19 16:42:41 +06:00
c0ce6f5b71 start 0.7.1 2023-06-19 16:38:49 +06:00
665432cdce Merge pull request #81 from InsanusMokrassar/0.7.0
0.7.0
2023-04-13 12:10:00 +06:00
5e379ee3e2 update dependencies 2023-04-13 12:09:01 +06:00
5a86d6705b start 0.7.0 2023-04-13 12:08:43 +06:00
25134879c1 Merge pull request #80 from InsanusMokrassar/0.6.2
0.6.2
2023-03-10 22:31:03 +06:00
30a85795dd start 0.6.2 && update compose 2023-03-10 15:07:19 +06:00
730da9f759 Merge pull request #79 from InsanusMokrassar/0.6.1
0.6.1
2023-03-05 21:36:49 +06:00
8178fa9d39 value in StandardInput is nullable 2023-03-05 18:50:59 +06:00
1eb14becde now StandardInput uses callback with input receiver 2023-03-05 18:15:12 +06:00
6502e0923e DefaultInput -> StandardInput 2023-03-05 14:41:30 +06:00
443043cff5 update dependencies 2023-03-05 14:37:57 +06:00
1765214c97 remove redundant settings fromm gradle.properties 2023-03-05 14:36:16 +06:00
dcc6495030 start 0.6.1 2023-03-05 14:35:56 +06:00
1c16fb4ed7 Merge pull request #78 from InsanusMokrassar/0.6.0
0.6.0
2023-02-28 12:42:40 +06:00
a60fb67ad3 update compose 2023-02-28 12:35:34 +06:00
f8402b24d1 update dependencies 2023-02-28 12:21:43 +06:00
f70f4674ed start 0.6.0 2023-02-28 12:20:49 +06:00
7c81cea8af Merge pull request #77 from InsanusMokrassar/0.5.2
0.5.2
2023-01-26 22:44:37 +06:00
2aca51d742 Update CHANGELOG.md 2023-01-26 22:44:07 +06:00
d8be33d4f6 add inline support 2023-01-24 18:06:16 +06:00
1d6c0db692 add badge support 2023-01-24 13:44:01 +06:00
264bcae65e fixes in dialogs 2023-01-23 12:50:50 +06:00
ce5281c52d start 0.5.2 2023-01-23 12:50:03 +06:00
1349d253d7 Merge pull request #76 from InsanusMokrassar/0.5.1
0.5.1
2023-01-13 13:36:26 +06:00
dbf9efa8f5 fill changelog 2023-01-13 13:25:14 +06:00
c483bb67d8 potential fix of modals composition cancelling 2023-01-13 13:21:45 +06:00
7c5a9ecc3d start 0.5.1 2023-01-13 12:49:25 +06:00
05816f9a57 Merge pull request #75 from InsanusMokrassar/0.5.0
0.5.0
2023-01-12 14:51:06 +06:00
402af2445f temporarily remove UIKitConstants 2023-01-12 14:50:23 +06:00
71ccc74c94 fixes 2023-01-12 14:31:38 +06:00
0b8017a164 small improvement in dialogs 2023-01-11 21:57:43 +06:00
46a897e629 total rework of dialogs 2023-01-11 21:55:47 +06:00
0e1be72219 start 0.5.0 2023-01-11 21:35:30 +06:00
0feafdae4b Merge pull request #74 from InsanusMokrassar/0.4.3
0.4.3
2023-01-04 20:25:13 +06:00
fad48715b4 add gitea to the target repositories 2023-01-03 18:40:53 +06:00
f6bfef4b89 update github workflows 2023-01-03 18:38:33 +06:00
432a5744b3 add opportunity to now show dialog automatically 2023-01-03 18:37:01 +06:00
5dff8d69f2 start 0.4.3 2023-01-03 18:33:50 +06:00
e6ebc70578 Merge pull request #73 from InsanusMokrassar/0.4.2
0.4.2
2022-12-18 10:10:57 +06:00
0eba5d10f7 Update CHANGELOG.md 2022-12-18 10:07:51 +06:00
ffb7f41328 Update libs.versions.toml 2022-12-18 10:07:07 +06:00
77dabb5553 0.4.2 2022-12-18 10:06:45 +06:00
8c086eb3eb Merge pull request #71 from InsanusMokrassar/0.4.1
0.4.1
2022-11-16 00:57:42 +06:00
0d55505e09 fill changelog 2022-11-16 00:57:11 +06:00
eefdb5fda1 list may accept any iterable 2022-11-16 00:45:10 +06:00
0c281aa653 fixes for build 2022-11-16 00:17:03 +06:00
17ae0b119b StandardInput improvements 2022-11-15 21:50:15 +06:00
36214aeba5 start 0.4.1 2022-11-15 21:46:29 +06:00
19f3a59a79 Merge pull request #70 from InsanusMokrassar/0.4.0
0.4.0
2022-11-08 07:56:31 +06:00
5cfee9c4cc Update CHANGELOG.md 2022-11-08 07:54:53 +06:00
c9a17fa92a Update gradle-wrapper.properties 2022-11-08 07:53:42 +06:00
c36e8c58f4 Update libs.versions.toml 2022-11-08 07:52:33 +06:00
67f083610a start 0.4.0 2022-11-08 07:51:48 +06:00
636280a982 Merge pull request #69 from InsanusMokrassar/0.3.0
0.3.0
2022-09-19 20:54:03 +06:00
415549b251 Update libs.versions.toml 2022-09-17 00:55:20 +06:00
0d2672b679 start 0.3.0 2022-09-17 00:53:59 +06:00
a511def014 Merge pull request #68 from InsanusMokrassar/0.2.2
0.2.2
2022-09-14 14:07:24 +06:00
d783834aa4 Drop component and Navbar improvements 2022-09-14 13:54:48 +06:00
cf2b823765 start 0.2.2 2022-09-14 13:01:31 +06:00
0f6e2c9805 Merge pull request #67 from InsanusMokrassar/0.2.1
0.2.1
2022-08-20 18:24:02 +06:00
7b2810b206 add Tab support 2022-08-20 17:43:44 +06:00
0dff161ce6 start 0.2.1 2022-08-20 16:54:54 +06:00
0648ceed18 Merge pull request #66 from InsanusMokrassar/0.2.0
0.2.0
2022-08-04 17:33:45 +06:00
190b3ac53e remove deprecations 2022-08-04 17:31:07 +06:00
aa5015d079 update workflows 2022-08-04 17:22:33 +06:00
752bf5bfcd Update CHANGELOG.md 2022-08-04 16:53:10 +06:00
8d05f7e020 Update gradle.properties 2022-08-04 16:52:32 +06:00
5589d42f6d Update libs.versions.toml 2022-08-04 16:52:12 +06:00
32d26a8e56 Merge pull request #65 from InsanusMokrassar/0.1.10
0.1.10
2022-08-02 18:41:55 +06:00
2f521a4584 improve grid attributes 2022-08-02 18:40:17 +06:00
c47a140719 start 0.1.10 2022-08-02 18:32:53 +06:00
fbb4fb16d7 Merge pull request #64 from InsanusMokrassar/0.1.9
0.1.9
2022-07-31 15:08:35 +06:00
8c5dca73fa Grid support improvement; Article, Iconnav and Leader support 2022-07-31 15:04:27 +06:00
429d3d4e77 start 0.1.9 2022-07-31 14:57:40 +06:00
fed53cd8cd Update github_release.gradle 2022-07-24 12:09:59 +06:00
b72937e907 Merge pull request #63 from InsanusMokrassar/0.1.8
0.1.8
2022-07-24 12:07:34 +06:00
39 changed files with 915 additions and 340 deletions

View File

@@ -1,19 +0,0 @@
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Fix android 31.0.0 dx
continue-on-error: true
run: cd /usr/local/lib/android/sdk/build-tools/31.0.0/ && mv d8 dx && cd lib && mv d8.jar dx.jar
- name: Build with Gradle
run: ./gradlew build

26
.github/workflows/build_and_publish.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Rewrite version
run: |
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
cat gradle.properties | sed -e "s/^version=\([0-9\.]*\)/version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
rm gradle.properties
mv gradle.properties.tmp gradle.properties
- name: Build with Gradle
run: ./gradlew build
- name: Publish
continue-on-error: true
run: ./gradlew publishAllPublicationsToGiteaRepository
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}

View File

@@ -1,5 +1,113 @@
# Changelog
## 0.7.6
* `Kotlin`: `1.9.23`
* `Compose`: `1.6.1`
## 0.7.5
* `Kotlin`: `1.9.22`
* `Compose`: `1.6.0`
## 0.7.4
* `Kotlin`: `1.9.21`
* `Compose`: `1.5.11`
## 0.7.3
* `Kotlin`: `1.9.20`
* `Compose`: `1.5.10`
## 0.7.2
* `Kotlin`: `1.9.10`
* `Compose`: `1.5.1`
## 0.7.1
* Type of `animation` parameter in `Alert` has been changed according to docs: now it is `Boolean`
* Add tooltip `JS` part support
## 0.7.0
* `Kotlin`: `1.8.20`
* `Compose`: `1.4.0`
## 0.6.2
* `Compose`: `1.3.1`
## 0.6.1
* `DefaultInput` has been renamed to `StandardInput`
* `Compose`: `1.3.1-rc02`
## 0.6.0
* `Kotlin`: `1.8.10`
* `Compose`: `1.3.1-rc01`
## 0.5.2
* More fixes in Dialogs
* Badge supported
* Inline creation support
## 0.5.1
* Fixes in new `Dialog`s
## 0.5.0
* Fully rework `Dialog` elements
## 0.4.3
* Add opportunity to now show dialog automatically
## 0.4.2
* `Compose`: `1.2.2`
## 0.4.1
* Now it is possible to use `StandardInput` with simple `T` types instead of states
* `List` may accept any `Iterable`
## 0.4.0
* `Kotlin`: `1.7.20`
* `Compose`: `1.2.1`
## 0.2.2
* Add support of `Drop` component
* Improve support of `Navbar`s
## 0.2.1
* `Tab` elements become supported
## 0.2.0
**ALL DEPRECATIONS HAVE BEEN REMOVED**
* `Kotlin`: `1.7.0`
* `Compose`: `1.2.0-alpha01-dev753`
## 0.1.10
* `Grid` support improvements
## 0.1.9
* `Artile` elements become supported
* `Iconnav` elements become supported
* `Leader` elements become supported
* `Grid` support improvements
## 0.1.8
* `Compose`: `1.2.0-alpha01-dev731`

View File

@@ -18,14 +18,14 @@ if (new File(projectDir, "secret.gradle").exists()) {
githubRelease {
token "${project.property('GITHUB_RELEASE_TOKEN')}"
owner "InsanusMokrassar"
repo "JSUIKitKBindings"
owner = "InsanusMokrassar"
repo = "JSUIKitKBindings"
tagName "${project.version}"
releaseName "${project.version}"
targetCommitish "${project.version}"
tagName = "v${project.version}"
releaseName = "${project.version}"
targetCommitish = "${project.version}"
body getCurrentVersionChangelog()
body = getCurrentVersionChangelog()
}
}

View File

@@ -3,10 +3,8 @@ org.gradle.parallel=true
kotlin.js.generate.externals=true
kotlin.incremental=true
kotlin.incremental.js=true
android.useAndroidX=true
android.enableJetifier=true
# Project data
group=dev.inmo
version=0.1.8
version=0.7.6

View File

@@ -1,9 +1,9 @@
[versions]
kt = "1.6.21"
jb-compose = "1.2.0-alpha01-dev731"
jb-dokka = "1.6.21"
gh-release = "2.4.1"
kt = "1.9.23"
jb-compose = "1.6.1"
jb-dokka = "1.9.20"
gh-release = "2.5.1"
[libraries]

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,7 +1,7 @@
apply plugin: 'maven-publish'
task javadocsJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
}
publishing {
@@ -38,14 +38,28 @@ publishing {
}
}
repositories {
if ((project.hasProperty('INMONEXUS_USER') || System.getenv('INMONEXUS_USER') != null) && (project.hasProperty('INMONEXUS_PASSWORD') || System.getenv('INMONEXUS_PASSWORD') != null)) {
maven {
name = "InmoNexus"
url = uri("https://nexus.inmo.dev/repository/maven-releases/")
credentials {
username = project.hasProperty('INMONEXUS_USER') ? project.property('INMONEXUS_USER') : System.getenv('INMONEXUS_USER')
password = project.hasProperty('INMONEXUS_PASSWORD') ? project.property('INMONEXUS_PASSWORD') : System.getenv('INMONEXUS_PASSWORD')
}
}
}
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')
}
}
}
}
@@ -66,4 +80,10 @@ if (project.hasProperty("signing.gnupg.keyName")) {
dependsOn(it)
}
}
// Workaround to make android sign operations depend on signing tasks
project.getTasks().withType(AbstractPublishToMaven.class).configureEach {
def signingTasks = project.getTasks().withType(Sign.class)
mustRunAfter(signingTasks)
}
}

View File

@@ -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"}}}
{"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":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}

View File

@@ -1,3 +1 @@
rootProject.name = 'kjsuikit'
enableFeaturePreview("VERSION_CATALOGS")

View File

@@ -1,26 +1,8 @@
package dev.inmo.jsuikit
import dev.inmo.jsuikit.modifiers.AttributeValue
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.attributes.AttrsScope
@Deprecated("Will be removed soon")
class UIKitAttributeValueBuilder {
private val attrs = mutableListOf<Pair<String, String>>()
infix fun String.to(other: String?) {
other ?.let {
attrs.add(Pair(this, other))
}
}
infix fun String.to(other: AttributeValue?) {
this to other ?.name
}
fun build(): String = attrs.joinToString(";") { (k, v) -> "$k: $v" }
}
fun AttrsScope<*>.buildAndAddAttribute(
attributeName: String,
skipNullValues: Boolean = true,

View File

@@ -12,7 +12,7 @@ import org.w3c.dom.HTMLDivElement
@Composable
fun Alert(
attrs: Attrs<HTMLDivElement> = Attrs.empty(),
animation: UIKitAnimation? = UIKitAnimation.Fade,
animation: Boolean = true,
duration: Milliseconds? = null,
selClose: String? = null,
content: ContentBuilder<HTMLDivElement>
@@ -22,7 +22,7 @@ fun Alert(
include(UIKitAlert)
buildAndAddAttribute("uk-alert") {
"animation" to animation ?.classes ?.firstOrNull()
"animation" to animation
"duration" to duration
"sel-close" to selClose
}

View File

@@ -0,0 +1,57 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitArticle
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.Attrs
import dev.inmo.jsuikit.utils.optionallyDraw
import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.dom.Text
import org.w3c.dom.*
@Composable
fun UIKitArticleElement (
headerBuilder: ContentBuilder<HTMLHeadingElement>,
headerAttrs: Attrs<HTMLHeadingElement> = Attrs.empty(),
metaBuilder: ContentBuilder<HTMLParagraphElement>? = null,
metaAttrs: Attrs<HTMLParagraphElement>? = null,
otherContentBuilder: ContentBuilder<HTMLElement>
) = Article(
{
include(UIKitArticle)
}
) {
H1(
{
include(UIKitArticle.Title)
headerAttrs.builder(this)
},
headerBuilder
)
optionallyDraw(metaAttrs, metaBuilder) {
P(
{
include(UIKitArticle.Meta)
metaAttrs ?.builder ?.invoke(this)
},
metaBuilder ?: {}
)
}
otherContentBuilder()
}
@Composable
fun UIKitArticleElement (
header: String,
meta: String? = null,
otherContentBuilder: ContentBuilder<HTMLElement>
) = UIKitArticleElement(
{ Text(header) },
metaBuilder = meta ?.let {
{
Text(meta)
}
},
otherContentBuilder = otherContentBuilder
)

View File

@@ -0,0 +1,25 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitBadge
import dev.inmo.jsuikit.modifiers.include
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.jetbrains.compose.web.dom.ContentBuilder
import org.jetbrains.compose.web.dom.Span
import org.jetbrains.compose.web.dom.Text
import org.w3c.dom.HTMLSpanElement
@Composable
fun Badge(
text: String,
onAfterText: ContentBuilder<HTMLSpanElement>? = null,
onBeforeText: ContentBuilder<HTMLSpanElement>? = null,
attrs: AttrBuilderContext<HTMLSpanElement>? = null
) = Span({
include(UIKitBadge)
attrs ?.invoke(this)
}) {
onAfterText ?.invoke(this)
Text(text)
onBeforeText ?.invoke(this)
}

View File

@@ -1,33 +1,22 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffectResult
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import dev.inmo.jsuikit.modifiers.*
import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.renderComposableInBody
import org.w3c.dom.HTMLDivElement
import org.w3c.dom.HTMLElement
import org.w3c.dom.events.Event
import kotlin.random.Random
import kotlin.random.nextUInt
private class DialogDisposableEffectResult(
private val element: HTMLElement,
private val onDispose: (() -> Unit)?,
private val onDisposed: (() -> Unit)?
) : DisposableEffectResult {
override fun dispose() {
onDispose?.invoke()
UIKit.modal("#${element.id}") ?.hide()
onDisposed?.invoke()
}
}
@Composable
fun Dialog(
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
onHide: (() -> Unit)? = null,
onHidden: (() -> Unit)? = null,
onHidden: ((HTMLDivElement) -> Unit)? = null,
onShown: ((HTMLDivElement) -> Unit)? = null,
dialogAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
headerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
headerBuilder: ContentBuilder<HTMLDivElement>? = null,
@@ -36,101 +25,148 @@ fun Dialog(
footerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
footerBuilder: ContentBuilder<HTMLDivElement>? = null,
bodyAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
bodyBuilder: ContentBuilder<HTMLDivElement>
autoShow: Boolean = true,
removeOnHide: Boolean = true,
bodyBuilder: ContentBuilder<HTMLDivElement> = {}
) {
Div(
{
if (modifiers.none { it is UIKitModal.WithCustomAttributes }) {
include(UIKitModal)
}
id("dialog${Random.nextUInt()}")
include(*modifiers)
attributesCustomizer()
}
) {
Div(
{
include(UIKitModal.Dialog)
dialogAttrsBuilder ?.let { it() } ?: include(UIKitMargin.Auto.Vertical)
}
) {
headerBuilder ?.let {
val draw = remember { mutableStateOf(true) }
remember {
renderComposableInBody {
if (draw.value) {
Div(
{
include(UIKitModal.Header)
headerAttrsBuilder ?.let { it() }
if (modifiers.none { it is UIKitModal.WithCustomAttributes }) {
include(UIKitModal)
}
id("dialog${Random.nextUInt()}")
include(*modifiers)
attributesCustomizer()
}
) {
it()
}
}
afterHeaderBuilder ?.let { it() }
Div(
{
include(UIKitModal.Body)
bodyAttrsBuilder ?.let { it() }
}
) {
bodyBuilder()
}
beforeFooterBuilder ?.let { it() }
footerBuilder ?.let {
Div(
{
include(UIKitModal.Footer)
footerAttrsBuilder ?.let { it() } ?: include(UIKitText.Alignment.Horizontal.Right)
DisposableEffect(true) {
val htmlElement = scopeElement
if (autoShow) {
UIKit.modal(htmlElement).show()
}
if (onHidden != null || removeOnHide) {
htmlElement.addEventListener("hidden", {
if (it.target != htmlElement) return@addEventListener
onHidden ?.invoke(htmlElement)
if (removeOnHide) {
htmlElement.remove()
}
})
}
onShown ?.let {
htmlElement.addEventListener("shown", {
if (it.target != htmlElement) return@addEventListener
onShown(htmlElement)
})
}
onDispose {
draw.value = false
}
}
Div(
{
include(UIKitModal.Dialog)
dialogAttrsBuilder ?.let { it() } ?: include(UIKitMargin.Auto.Vertical)
}
) {
headerBuilder ?.let {
Div(
{
include(UIKitModal.Header)
headerAttrsBuilder ?.let { it() }
}
) {
it()
}
}
afterHeaderBuilder ?.let { it() }
Div(
{
include(UIKitModal.Body)
bodyAttrsBuilder ?.let { it() }
}
) {
bodyBuilder()
}
beforeFooterBuilder ?.let { it() }
footerBuilder ?.let {
Div(
{
include(UIKitModal.Footer)
footerAttrsBuilder ?.let { it() } ?: include(UIKitText.Alignment.Horizontal.Right)
}
) {
it()
}
}
}
) {
it()
}
}
}
DisposableRefEffect {
DialogDisposableEffectResult(it, onHide, onHidden)
}
DomSideEffect { htmlElement ->
var wrapper: (Event) -> Unit = {}
wrapper = { it: Event ->
htmlElement.removeEventListener("hidden", wrapper)
htmlElement.remove()
onHidden ?.invoke()
}
htmlElement.addEventListener("hidden", wrapper)
UIKit.modal("#${htmlElement.id}") ?.show()
}
}
Div({
hidden()
ref {
onDispose {
draw.value = false
}
}
})
}
@Composable
fun Dialog(
title: String,
vararg modifiers: UIKitModifier,
hide: (() -> Unit)? = null,
hidden: (() -> Unit)? = null,
footerBuilder: (@Composable () -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
bodyBuilder: @Composable () -> Unit
onHidden: ((HTMLDivElement) -> Unit)? = null,
onShown: ((HTMLDivElement) -> 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,
autoShow: Boolean = true,
removeOnHide: Boolean = true,
bodyBuilder: ContentBuilder<HTMLDivElement> = {}
) = Dialog(
modifiers = modifiers,
attributesCustomizer = attributesCustomizer,
onHidden = onHidden,
onShown = onShown,
dialogAttrsBuilder = dialogAttrsBuilder,
headerAttrsBuilder = headerAttrsBuilder,
headerBuilder = {
H2({ include(UIKitModal.Title) }) {
Text(title)
}
headerBuilder ?.invoke(this)
},
onHide = hide,
onHidden = hidden,
footerBuilder = footerBuilder ?.let { _ ->
{
footerBuilder()
}
},
attributesCustomizer = {
attributesCustomizer()
},
bodyBuilder = {
bodyBuilder()
}
afterHeaderBuilder = afterHeaderBuilder,
beforeFooterBuilder = beforeFooterBuilder,
footerAttrsBuilder = footerAttrsBuilder,
footerBuilder = footerBuilder,
bodyAttrsBuilder = bodyAttrsBuilder,
autoShow = autoShow,
removeOnHide = removeOnHide,
bodyBuilder = bodyBuilder
)

View File

@@ -0,0 +1,24 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitDrop
import dev.inmo.jsuikit.modifiers.attrsBuilder
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.dom.Div
import org.w3c.dom.HTMLButtonElement
import org.w3c.dom.HTMLDivElement
@Composable
fun Drop(
buttonBuilder: AttrsWithContentBuilder<HTMLButtonElement>,
dropBuilder: AttrsWithContentBuilder<HTMLDivElement>
) {
DefaultButton(
attributesCustomizer = buttonBuilder.attributesBuilderContext,
contentAllocator = buttonBuilder.builder
)
Div(
(Attrs<HTMLDivElement>(UIKitDrop.Custom()) + dropBuilder.attrs).builder,
dropBuilder.builder
)
}

View File

@@ -1,8 +1,8 @@
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.buildAttribute
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLDivElement
@@ -26,23 +26,18 @@ fun GridColumn(
fun Grid(
vararg modifiers: UIKitModifier,
masonry: Boolean = false,
parallax: Int? = null,
marginClass: String? = null,
parallax: UInt? = null,
marginClass: UIKitMargin? = null,
firstColumnClass: String? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
builder: @Composable ElementScope<HTMLDivElement>.() -> Unit = {}
builder: ContentBuilder<HTMLDivElement> = {}
) {
val attrs = listOfNotNull(
if (masonry) "masonry" to "true" else null,
parallax ?.let { "parallax" to it.toString() },
marginClass ?.let { "margin" to it },
firstColumnClass ?.let { "first-column" to it },
)
Div(
{
attr("uk-grid", attrs.joinToString(";") { (k, v) -> "$k: $v" })
classes("uk-grid")
include(*modifiers)
include(
UIKitGrid.invoke(marginClass, firstColumnClass, masonry, parallax),
*modifiers
)
attributesCustomizer()
}
) {

View File

@@ -202,60 +202,62 @@ sealed class Icon(val name: String) {
object Youtube : Brands("youtube")
}
@Composable
operator fun invoke(
vararg modifiers: UIKitModifier,
type: UIKitIconType = UIKitIconType.Default,
ratio: Float? = null,
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) {
val configurer: AttrBuilderContext<out HTMLElement> = {
include(*modifiers, type, UIKitIcon)
attr("uk-icon", "icon: $name${if (ratio != null) { "; ratio: $ratio" } else ""}")
onClick ?.let { _ ->
onClick { onClick(it.nativeEvent) }
}
attributesCustomizer()
}
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,
ratio: Float? = null,
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) = invoke(*modifiers, type = UIKitIconType.Button, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
@Composable
fun drawAsIcon(
vararg modifiers: UIKitModifier,
ratio: Float? = null,
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)
companion object {
}
}
@Composable
operator fun Icon.invoke(
vararg modifiers: UIKitModifier,
type: UIKitIconType = UIKitIconType.Default,
ratio: Float? = null,
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) {
val configurer: AttrBuilderContext<out HTMLElement> = {
include(*modifiers, type, UIKitIcon)
attr("uk-icon", "icon: $name${if (ratio != null) { "; ratio: $ratio" } else ""}")
onClick ?.let { _ ->
onClick { onClick(it.nativeEvent) }
}
attributesCustomizer()
}
when (type) {
UIKitIconType.Default -> Span(configurer)
UIKitIconType.Link -> A(href = "#", configurer)
UIKitIconType.Button -> Button(configurer)
}
}
@Composable
fun Icon.drawAsButton(
vararg modifiers: UIKitModifier,
ratio: Float? = null,
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) = invoke(*modifiers, type = UIKitIconType.Button, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
@Composable
fun Icon.drawAsIcon(
vararg modifiers: UIKitModifier,
ratio: Float? = null,
attributesCustomizer: AttrBuilderContext<out HTMLElement> = {},
onClick: ((Event) -> Unit)? = null
) = invoke(*modifiers, type = UIKitIconType.Default, ratio = ratio, onClick = onClick, attributesCustomizer = attributesCustomizer)
@Composable
fun Icon.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 Icon.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

@@ -0,0 +1,41 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitIconnav
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.Attrs
import org.jetbrains.compose.web.attributes.AttrsScope
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLLIElement
import org.w3c.dom.HTMLUListElement
@Composable
fun <T> IconNav(
data: Iterable<T>,
listAttrs: Attrs<HTMLUListElement> = Attrs.empty(),
elementAttrsBuilder: AttrsScope<HTMLLIElement>.(T) -> Unit = {},
elementBuilder: @Composable ElementScope<HTMLLIElement>.(T) -> Unit
) {
Ul(
{
include(UIKitIconnav)
listAttrs.builder(this)
}
) {
data.forEach {
Li(
{
elementAttrsBuilder.invoke(this, it)
}
) { elementBuilder(this, it) }
}
}
}
@Composable
fun <T> Iconnav(
data: Iterable<T>,
listAttrs: Attrs<HTMLUListElement> = Attrs.empty(),
elementAttrsBuilder: AttrsScope<HTMLLIElement>.(T) -> Unit = {},
elementBuilder: @Composable ElementScope<HTMLLIElement>.(T) -> Unit
) = IconNav(data, listAttrs, elementAttrsBuilder, elementBuilder)

View File

@@ -0,0 +1,18 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitUtility
import dev.inmo.jsuikit.modifiers.include
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.jetbrains.compose.web.dom.ContentBuilder
import org.jetbrains.compose.web.dom.Div
import org.w3c.dom.HTMLDivElement
@Composable
fun Inline(
attrBuilderContext: AttrBuilderContext<HTMLDivElement>? = null,
contentBuilder: ContentBuilder<HTMLDivElement>
) = Div({
include(UIKitUtility.Inline)
attrBuilderContext ?.invoke(this)
}, contentBuilder)

View File

@@ -10,7 +10,7 @@ import org.w3c.dom.HTMLUListElement
@Composable
fun <T> List(
data: SnapshotStateList<T>,
data: Iterable<T>,
ukAttrs: Attrs<HTMLUListElement> = Attrs.empty(),
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
) {
@@ -29,7 +29,7 @@ fun <T> List(
@Composable
fun <T> ListWithTitle(
title: String,
data: SnapshotStateList<T>,
data: Iterable<T>,
vararg titleModifiers: UIKitModifier,
ulModifiers: Array<UIKitModifier> = emptyArray(),
besidesTitleAndList: (@Composable () -> Unit)? = null,
@@ -43,25 +43,3 @@ fun <T> ListWithTitle(
besidesTitleAndList ?.invoke()
List(data, Attrs(*ulModifiers) { ulCustomizer(this) }, elementAllocator)
}
@Deprecated("Renamed", ReplaceWith("ListWithTitle", "dev.inmo.jsuikit.elements.ListWithTitle"))
@Composable
fun <T> List(
title: String,
data: SnapshotStateList<T>,
vararg titleModifiers: UIKitModifier,
ulModifiers: Array<UIKitModifier> = emptyArray(),
besidesTitleAndList: (@Composable () -> Unit)? = null,
titleCustomizer: AttrBuilderContext<HTMLHeadingElement> = {},
ulCustomizer: AttrBuilderContext<HTMLUListElement> = {},
elementAllocator: @Composable ElementScope<HTMLUListElement>.(T) -> Unit
) = ListWithTitle(
title,
data,
*titleModifiers,
ulModifiers = ulModifiers,
besidesTitleAndList = besidesTitleAndList,
titleCustomizer = titleCustomizer,
ulCustomizer = ulCustomizer,
elementAllocator = elementAllocator
)

View File

@@ -22,33 +22,6 @@ fun Navbar(
}
}
@Deprecated("Will be removed soon. Use the variant with AttrsWithContentBuilders")
@Composable
fun Navbar(
leftBuilder: NavbarNavBuilder?,
centerBuilder: NavbarNavBuilder? = null,
rightBuilder: NavbarNavBuilder? = null,
vararg navModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLElement> = {},
) {
Navbar(
{
include(*navModifiers)
attributesCustomizer()
}
) {
leftBuilder ?.let {
Div({ include(UIKitNavbar.Alignment.Left) }) { it.draw() }
}
centerBuilder ?.let {
Div({ include(UIKitNavbar.Alignment.Center) }) { it.draw() }
}
rightBuilder ?.let {
Div({ include(UIKitNavbar.Alignment.Right) }) { it.draw() }
}
}
}
@Composable
fun Navbar(
leftBuilder: AttrsWithContentBuilder<HTMLDivElement>? = null,

View File

@@ -5,8 +5,7 @@ import dev.inmo.jsuikit.modifiers.*
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.attributes.AttrsScope
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLLIElement
import org.w3c.dom.HTMLUListElement
import org.w3c.dom.*
@Composable
fun NavbarNav(
@@ -31,57 +30,16 @@ fun NavbarNav(
attrs: Attrs<HTMLUListElement> = Attrs.empty()
) = NavbarNav(elements.toList(), attrs)
@Deprecated("Will be removed soon. Use NavbarNavPart with AttrsWithContentBuilder instead")
interface NavbarNavElement {
fun AttrsScope<HTMLLIElement>.setup() {}
@Composable
fun ElementScope<HTMLLIElement>.fill()
class Default(
private val setupCallback: AttrsScope<HTMLLIElement>.() -> Unit,
private val fillCallback: @Composable ElementScope<HTMLLIElement>.() -> Unit
) : NavbarNavElement {
override fun AttrsScope<HTMLLIElement>.setup() {
setupCallback()
}
@Composable
override fun ElementScope<HTMLLIElement>.fill() {
fillCallback()
}
}
fun NavbarNavBuilder(
elements: List<AttrsWithContentBuilder<HTMLLIElement>>,
attrs: Attrs<HTMLUListElement> = Attrs.empty(),
containerAttrs: Attrs<HTMLDivElement> = Attrs.empty()
) = AttrsWithContentBuilder<HTMLDivElement>(containerAttrs) {
NavbarNav(elements, attrs)
}
@Deprecated("Will be removed soon. Use NavbarNavPart with AttrsWithContentBuilder instead")
class NavbarNavBuilder(
private val modifiers: Array<UIKitModifier>,
private val elements: List<NavbarNavElement>,
private val attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {}
) {
constructor(
modifiers: Array<UIKitModifier>,
vararg elements: NavbarNavElement,
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {}
) : this(modifiers, elements.toList(), attributesCustomizer)
constructor(
vararg elements: NavbarNavElement,
attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {}
) : this(emptyArray(), elements.toList(), attributesCustomizer)
@Composable
fun draw() {
Ul(
{
include(UIKitNavbar.Nav, *modifiers)
attributesCustomizer()
}
) {
elements.forEach { element ->
Li(
{ element.apply { setup() } }
) {
element.apply { fill() }
}
}
}
}
}
fun NavbarNavBuilder(
vararg elements: AttrsWithContentBuilder<HTMLLIElement>,
attrs: Attrs<HTMLUListElement> = Attrs.empty(),
containerAttrs: Attrs<HTMLDivElement> = Attrs.empty()
) = NavbarNavBuilder(elements.toList(), attrs, containerAttrs)

View File

@@ -11,11 +11,12 @@ import org.w3c.dom.HTMLInputElement
@Composable
fun <T> StandardInput(
type: InputType<T>,
state: MutableState<T>,
disabledState: State<Boolean>? = null,
placeholder: String? = null,
value: T? = null,
vararg modifiers: UIKitModifier,
disabled: Boolean = false,
placeholder: String? = null,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
onChange: HTMLInputElement.(T) -> Unit
) {
Input(type) {
classes("uk-input")
@@ -23,7 +24,7 @@ fun <T> StandardInput(
placeholder ?.let(::placeholder)
state.value.let {
value ?.let {
when (it) {
is String -> value(it)
is Number -> value(it)
@@ -31,24 +32,44 @@ fun <T> StandardInput(
}
}
onInput { state.value = it.value }
onInput { event -> event.target.onChange(event.value) }
disabledState ?.let {
if (it.value) {
disabled()
}
if (disabled) {
disabled()
}
attributesCustomizer()
}
}
@Deprecated("Renamed", ReplaceWith("StandardInput(type, value, *modifiers, disabled, placeholder, attributesCustomizer, onChange)"))
@Composable
@Deprecated("Renamed", ReplaceWith("StandardInput", "dev.inmo.jsuikit.elements.StandardInput"))
fun <T> TextField(
fun <T> DefaultInput(
type: InputType<T>,
value: T,
disabled: Boolean = false,
placeholder: String? = null,
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
onChange: (T) -> Unit
) = StandardInput(type, value, modifiers = modifiers, disabled, placeholder, attributesCustomizer) {
onChange(it)
}
@Composable
fun <T> StandardInput(
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)
) = StandardInput(
type,
state.value,
modifiers = modifiers,
disabledState ?.value == true,
placeholder,
attributesCustomizer = attributesCustomizer
) {
state.value = it
}

View File

@@ -0,0 +1,46 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitTab
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.optionallyDraw
import org.jetbrains.compose.web.attributes.AttrsScope
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLLIElement
import org.w3c.dom.HTMLUListElement
@Composable
fun <T> Tabs(
data: Iterable<T>,
tabsItemBuilder: @Composable ElementScope<HTMLLIElement>.(i: Int, data: T) -> Unit,
tabsItemAttrs: AttrsScope<HTMLLIElement>.(i: Int, data: T) -> Unit = { _, _ -> },
tabsContainerAttrs: AttrsScope<HTMLUListElement>.() -> Unit = {},
contentContainerAttrs: (AttrsScope<HTMLUListElement>.() -> Unit)? = null,
contentItemAttrs: (AttrsScope<HTMLLIElement>.(i: Int, data: T) -> Unit)? = null,
contentItemBuilder: (@Composable ElementScope<HTMLLIElement>.(i: Int, data: T) -> Unit)? = null
) {
Ul({
include(UIKitTab);
tabsContainerAttrs()
}) {
data.forEachIndexed { i, data ->
Li({ tabsItemAttrs(i, data) }) {
tabsItemBuilder(i, data)
}
}
}
optionallyDraw(contentItemAttrs != null, contentItemBuilder != null, contentContainerAttrs != null) {
Ul({
contentContainerAttrs ?.invoke(this)
}) {
optionallyDraw(contentItemAttrs != null, contentItemBuilder != null) {
data.forEachIndexed { i, data ->
Li({ contentItemAttrs ?.invoke(this, i, data) }) {
contentItemBuilder ?.invoke(this, i, data)
}
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitArticle(
override val classes: Array<String>
) : UIKitModifier {
object Title : UIKitArticle(arrayOf("uk-article-title"))
object Meta : UIKitArticle(arrayOf("uk-article-meta"))
companion object : UIKitArticle(arrayOf("uk-article"))
}

View File

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

View File

@@ -0,0 +1,122 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.css.selectors.CSSSelector
sealed class UIKitDrop(
override val classes: Array<String> = emptyArray(),
override val otherAttrs: Map<String, String> = emptyMap()
) : UIKitModifier {
sealed class Position(name: String) : AttributeValue(name) {
sealed class Bottom(name: String) : Position("bottom-$name") {
object Left : Bottom("left")
object Center : Bottom("center")
object Right : Bottom("right")
object Justify : Bottom("justify")
}
sealed class Top(name: String) : Position("top-$name") {
object Left : Top("left")
object Center : Top("center")
object Right : Top("right")
object Justify : Top("justify")
}
sealed class Left(name: String) : Position("left-$name") {
object Top : Left("top")
object Center : Left("center")
object Bottom : Left("bottom")
}
sealed class Right(name: String) : Position("right-$name") {
object Top : Right("top")
object Center : Right("center")
object Bottom : Right("bottom")
}
}
sealed class Stretch(name: String) : AttributeValue(name) {
object True : Stretch("true")
object X : Stretch("x")
object Y : Stretch("y")
}
sealed class Mode(name: String) : AttributeValue(name) {
object Click : Mode("click")
object Hover : Mode("hover")
object None : Mode("")
object HoverAndClick : Mode("$Hover, $Click")
}
class Custom internal constructor(
classes: Array<String> = emptyArray(),
otherAttrs: Map<String, String> = emptyMap()
) : UIKitDrop(classes, otherAttrs)
companion object {
operator fun invoke(
toggle: CSSSelector? = null,
position: Position? = null,
stretch: Stretch? = null,
mode: Mode? = null,
delayShow: Milliseconds? = null,
delayHide: Milliseconds? = null,
autoUpdate: Boolean? = null,
boundary: CSSSelector? = null,
boundaryX: CSSSelector? = null,
boundaryY: CSSSelector? = null,
target: CSSSelector? = null,
targetX: CSSSelector? = null,
targetY: CSSSelector? = null,
inset: Boolean? = null,
flip: Boolean? = null,
shift: Boolean? = null,
offset: Pixels? = null,
animation: UIKitAnimation? = null,
animationOut: Boolean? = null,
bgScroll: Boolean? = null,
duration: Milliseconds? = null,
container: Boolean? = null
) = Custom(
arrayOf("uk-drop"),
mapOf(
buildAttribute("uk-drop") {
"toggle" to toggle
"position" to position
"stretch" to stretch
"mode" to mode
"delay-show" to delayShow
"delay-hide" to delayHide
"auto-update" to autoUpdate
"boundary" to boundary
"boundary-x" to boundaryX
"boundary-y" to boundaryY
"target" to target
"target-x" to targetX
"target-y" to targetY
"inset" to inset
"flip" to flip
"shift" to shift
"offset" to offset
"animation" to animation
"animation-out" to animationOut
"bg-scroll" to bgScroll
"duration" to duration
"container" to container
}
)
)
}
}

View File

@@ -14,12 +14,30 @@ sealed class UIKitGrid(vararg classnames: String) : UIKitModifier {
}
sealed class Column(classname: String) : UIKitGrid(classname) {
object Small : Column("uk-grid-column-small")
object Medium : Column("uk-grid-column-medium")
object Large : Column("uk-grid-column-large")
object Collapse : Column("uk-grid-column-collapse")
}
sealed class Row(classname: String) : UIKitGrid(classname) {
object Small : Row("uk-grid-row-small")
object Medium : Row("uk-grid-row-medium")
object Large : Row("uk-grid-row-large")
object Collapse : Row("uk-grid-row-collapse")
}
object Divider : UIKitGrid("uk-grid-divider")
object MatchHeight : UIKitGrid("uk-grid-match")
object ItemMatchHeight : UIKitGrid("uk-grid-item-match")
class Custom internal constructor(override val otherAttrs: Map<String, String>) : UIKitGrid()
class Custom internal constructor(override val otherAttrs: Map<String, String>) : UIKitGrid("uk-grid")
companion object : UIKitGrid("uk-grid") {
operator fun invoke(

View File

@@ -0,0 +1,11 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitIconnav(
override val classes: Array<String>
) : UIKitModifier {
object Vertical : UIKitIconnav(arrayOf("uk-iconnav-vertical"))
companion object : UIKitIconnav(arrayOf("uk-iconnav"))
}

View File

@@ -0,0 +1,28 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.buildAttribute
sealed class UIKitLeader(
override val classes: Array<String>,
override val otherAttrs: Map<String, String>
) : UIKitModifier {
class Custom(
otherAttrs: Map<String, String>
) : UIKitLeader(arrayOf("uk-leader"), otherAttrs)
companion object : UIKitLeader(arrayOf("uk-leader"), emptyMap()) {
operator fun invoke(
media: String? = null,
fill: String? = null
) = Custom(
mapOf(
buildAttribute("uk-leader") {
"fill" to fill
"media" to media
}
)
)
}
}

View File

@@ -0,0 +1,51 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.buildAttribute
import org.jetbrains.compose.web.css.selectors.CSSSelector
import kotlin.time.Duration
sealed class UIKitTab(
override val classes: Array<String> = emptyArray(),
override val otherAttrs: Map<String, String> = emptyMap()
) : UIKitModifier {
sealed class Position(
classes: Array<String> = emptyArray(),
otherAttrs: Map<String, String> = emptyMap()
) : UIKitTab(classes, otherAttrs) {
object Bottom : Position(arrayOf("uk-tab-bottom"))
object Left : Position(arrayOf("uk-tab-left"))
object Right : Position(arrayOf("uk-tab-right"))
}
class Custom(
connect: CSSSelector? = null,
toggle: CSSSelector? = null,
active: Int? = null,
animationsIn: Array<UIKitAnimation>? = null,
animationsOut: Array<UIKitAnimation>? = null,
animationDuration: Duration? = null,
swiping: Boolean? = null,
media: String? = null
) : UIKitTab(
arrayOf("uk-tab"),
mapOf(
buildAttribute("uk-tab") {
"connect" to connect
"toggle" to toggle
"active" to active
"animation" to (
(animationsIn ?.let {
it.joinToString(" ") { it.name }
} ?: "") + (animationsOut ?.let {
it.joinToString(" ", ",") { it.name }
} ?: "")
).takeIf { it.isNotBlank() }
"duration" to animationDuration
"swiping" to swiping
"media" to media
}
)
)
companion object : UIKitTab(arrayOf("uk-tab"), mapOf("uk-tab" to ""))
}

View File

@@ -6,6 +6,7 @@ import kotlin.js.Json
external interface UIKit {
val notification: UIKitNotifications
val modal: UIKitDialogs
val util: UIKitUtil
fun notification(message: String, parameters: Json)
@@ -16,4 +17,7 @@ external interface UIKit {
fun dropdown(element: Element, options: DropdownOptions = definedExternally): Dropdown
fun dropdown(selector: String, options: DropdownOptions = definedExternally): Dropdown?
fun tooltip(element: Element): UIKitTooltip
fun tooltip(selector: String): UIKitTooltip?
}

View File

@@ -0,0 +1,6 @@
package dev.inmo.jsuikit.types
external interface UIKitTooltip {
fun show()
fun hide()
}

View File

@@ -0,0 +1,8 @@
package dev.inmo.jsuikit.types
import org.w3c.dom.HTMLElement
external interface UIKitUtil {
fun on(selector: String, event: String, callback: () -> Unit)
fun on(element: HTMLElement, event: String, callback: () -> Unit)
}

View File

@@ -0,0 +1,9 @@
package dev.inmo.jsuikit.utils
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.w3c.dom.Element
operator fun <T : Element> AttrBuilderContext<T>.plus(other: AttrBuilderContext<T>): AttrBuilderContext<T> = {
this@plus()
other()
}

View File

@@ -3,7 +3,9 @@ package dev.inmo.jsuikit.utils
import dev.inmo.jsuikit.modifiers.UIKitModifier
import dev.inmo.jsuikit.modifiers.include
import org.jetbrains.compose.web.attributes.AttrsScope
import org.jetbrains.compose.web.attributes.HtmlAttrMarker
import org.jetbrains.compose.web.attributes.builders.InputAttrsScope
import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.w3c.dom.Element
import org.w3c.dom.HTMLInputElement

View File

@@ -4,13 +4,19 @@ import androidx.compose.runtime.Composable
import org.jetbrains.compose.web.dom.ContentBuilder
import org.w3c.dom.Element
@Composable
inline fun optionallyDraw (
vararg bools: Boolean,
whatToDraw: @Composable () -> Unit
) {
if (bools.any { it }) {
whatToDraw()
}
}
@Composable
inline fun <T : Element> optionallyDraw (
attrs: Attrs<T>? = null,
noinline contentBuilder: ContentBuilder<T>? = null,
whatToDraw: @Composable () -> Unit
) {
if (attrs != null || contentBuilder != null) {
whatToDraw()
}
}
) = optionallyDraw(attrs != null || contentBuilder != null, whatToDraw = whatToDraw)

View File

@@ -1,13 +1,17 @@
package dev.inmo.jsuikit.utils
import dev.inmo.jsuikit.modifiers.AttributeValue
class ParametersBuilder(
val skipNullValues: Boolean = true,
private val parameters: MutableMap<String, String?> = mutableMapOf()
) {
fun add(k: String, v: Any? = null) {
if (v != null || !skipNullValues) {
parameters[k] = v ?.toString()
when {
v is AttributeValue -> parameters[k] = v.name
v == null && skipNullValues -> return
else -> parameters[k] = v ?.toString()
}
}
infix fun String.to(value: Any?) = add(this, value)