Compare commits

..

137 Commits

Author SHA1 Message Date
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
c88138a8ed update compose version 2022-07-24 12:05:31 +06:00
214fb07362 start 0.1.8 2022-07-24 12:04:22 +06:00
589fc62364 Merge pull request #62 from InsanusMokrassar/0.1.7
0.1.7
2022-05-29 10:45:29 +06:00
767f5291a8 add Toggle builder 2022-05-29 09:43:23 +06:00
38819eba21 start 0.1.7 2022-05-29 09:43:14 +06:00
e5223f8408 Merge pull request #61 from InsanusMokrassar/0.1.6
0.1.6
2022-05-23 16:52:35 +06:00
854bc9f8ca Add support of size and group in UIKitButton 2022-05-23 16:51:09 +06:00
36f5d5661b start 0.1.6 2022-05-23 16:50:50 +06:00
2af001a4f1 Merge pull request #60 from InsanusMokrassar/0.1.5
0.1.5
2022-05-23 13:09:15 +06:00
68f1879114 Update CHANGELOG.md 2022-05-23 13:08:35 +06:00
f16c93cf0d Update gradle.properties 2022-05-23 13:04:55 +06:00
63dd8f1bf6 Update UIKitSticky.kt 2022-05-23 13:03:29 +06:00
fafb7e7e04 Merge pull request #59 from InsanusMokrassar/0.1.4
0.1.4
2022-05-22 23:46:13 +06:00
5afa92ef37 UIKitSticky 2022-05-22 23:45:21 +06:00
4377ec3969 improvements 2022-05-22 23:21:25 +06:00
674fbbd4d5 start 0.1.4 2022-05-22 23:21:10 +06:00
efd9cb80e1 Merge pull request #58 from InsanusMokrassar/0.1.3
0.1.3
2022-05-19 10:38:33 -04:00
53b020ab8d improve AttrsWithContentBuilder functions 2022-05-19 18:56:52 +06:00
67a6998f02 add new variant of NavbarNav 2022-05-19 18:50:43 +06:00
abe44fe1c6 fixes in signature of NavbarNav fun 2022-05-19 18:50:06 +06:00
b028b12103 small fixes in UIKitNav 2022-05-19 18:47:03 +06:00
816f341729 fixes in UIKitNavbar invoke 2022-05-19 18:44:19 +06:00
6a652249c0 improvements and fixes in Navbar and NavbarNav parts 2022-05-19 18:43:41 +06:00
ec584798ad Update Navbar.kt 2022-05-19 15:23:04 +06:00
faf238cf07 fix in navbar 2022-05-19 14:38:35 +06:00
d78acce3c5 add several builders for AttrsWithContentBuilder 2022-05-19 14:16:30 +06:00
3afe6c2815 add support of sections 2022-05-19 13:42:21 +06:00
29efe4b5cd Improve support of navbars 2022-05-19 13:21:39 +06:00
990bd6385f start 0.1.3 2022-05-19 13:21:29 +06:00
deb30957ac Merge pull request #57 from InsanusMokrassar/0.1.2
0.1.2
2022-05-19 02:13:29 -04:00
276eaddcac Remove redundant DList and other + add AttrsWithContentBuilder 2022-05-19 12:13:13 +06:00
9b992cbda0 start 0.1.2 2022-05-19 12:10:49 +06:00
e227d3c88e Merge pull request #56 from InsanusMokrassar/0.1.1
0.1.1
2022-05-17 02:33:50 -04:00
fc4f937cc1 Update CHANGELOG.md 2022-05-17 12:30:38 +06:00
1ee9b8c4de Update libs.versions.toml 2022-05-17 12:29:51 +06:00
90e27d0cab start 0.1.1 2022-05-17 12:29:18 +06:00
400724c918 Merge pull request #55 from InsanusMokrassar/0.1.0
0.1.0
2022-05-16 00:00:24 +06:00
ea59ba1446 Update CHANGELOG.md 2022-05-15 23:58:58 +06:00
a97898fe69 Update libs.versions.toml 2022-05-15 23:58:00 +06:00
21d2ccf208 Update CHANGELOG.md 2022-05-10 15:05:06 +06:00
fd6a122b40 Update libs.versions.toml 2022-05-10 15:04:54 +06:00
6b4e141cd2 update release version 2022-05-07 01:46:31 +06:00
fb5e0ade11 update compose dependency 2022-05-07 01:43:57 +06:00
353314dd26 add dev compose maven 2022-04-29 17:34:10 +06:00
57ffe32b9f Update of dependencies 2022-04-29 17:29:37 +06:00
c6bacffdb3 start 0.1.0 2022-04-29 17:28:52 +06:00
3e2aa22076 Merge pull request #54 from InsanusMokrassar/0.0.53
0.0.53
2022-04-27 16:29:24 +06:00
52 changed files with 1256 additions and 398 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,148 @@
# Changelog
## 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`
## 0.1.7
Add Toggle builder
## 0.1.6
* Add support of UIKitButton size and group
## 0.1.5
* Fix access to `UIKitSticky`
## 0.1.4
* Improvements in `UIKitGrid`
* Add support of `UIKitSticky`
## 0.1.3
* Add support of sections
* Improve support of navbars
## 0.1.2
* New typealias `AttrsWithContentBuilder`
* Old `DList` and related composable functions removed (they are built-in in compose)
## 0.1.1
* `Compose`: `1.2.0-alpha01-dev686`
## 0.1.0
* `Kotlin` = `1.6.21`
* `Compose`: `1.2.0-alpha01-dev683`
## 0.0.53
* Improvements in `UIKitPadding`

View File

@@ -26,6 +26,7 @@ repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://maven.pkg.jetbrains.space/public/p/compose/dev" }
}
kotlin {

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.0.53
version=0.7.5

View File

@@ -1,9 +1,9 @@
[versions]
kt = "1.6.10"
jb-compose = "1.1.1"
jb-dokka = "1.6.10"
gh-release = "2.2.12"
kt = "1.9.22"
jb-compose = "1.6.0"
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.4.1-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,32 @@ publishing {
}
}
repositories {
if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) {
maven {
name = "GITEA"
url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven")
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN')
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
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 +84,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":"GITEA","url":"https://git.inmo.dev/api/packages/InsanusMokrassar/maven","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.HttpHeaderCredentials","headerName":"Authorization","headerValueProperty":"GITEA_TOKEN"}},{"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

@@ -4,8 +4,7 @@ import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitDescriptionList
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.*
import org.jetbrains.compose.web.dom.ContentBuilder
import org.jetbrains.compose.web.dom.ElementScope
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLDListElement
import org.w3c.dom.HTMLElement

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

@@ -10,7 +10,7 @@ import org.w3c.dom.HTMLDivElement
@Composable
fun DropArea(
attrs: Attrs<HTMLDivElement> = Attrs.empty(),
inputAttrs: InputAttrs<String> = Attrs.empty(),
inputAttrs: InputAttrs<String> = InputAttrs.empty(),
contentBuilder: ContentBuilder<HTMLDivElement> = {}
) = Div(
{

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

@@ -1,35 +1,49 @@
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.*
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLDivElement
import org.w3c.dom.HTMLElement
@Composable
fun Navbar(
leftBuilder: NavbarNavBuilder? = null,
centerBuilder: NavbarNavBuilder? = null,
rightBuilder: NavbarNavBuilder? = null,
vararg navModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLElement> = {},
contentBuilder: ContentBuilder<HTMLElement>
) {
Nav(
{
attr("uk-navbar", "")
classes("uk-navbar-container", "uk-navbar")
include(UIKitNavbar, UIKitNavbar(), UIKitNavbar.Container)
attributesCustomizer()
}
) {
contentBuilder()
}
}
@Composable
fun Navbar(
leftBuilder: AttrsWithContentBuilder<HTMLDivElement>? = null,
centerBuilder: AttrsWithContentBuilder<HTMLDivElement>? = null,
rightBuilder: AttrsWithContentBuilder<HTMLDivElement>? = null,
vararg navModifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLElement> = {},
) {
Navbar(
attributesCustomizer = {
include(*navModifiers)
attributesCustomizer()
}
) {
leftBuilder ?.let {
Div({ classes("uk-navbar-left") }) { it.draw() }
Div({ include(UIKitNavbar.Alignment.Left);leftBuilder.attributesBuilderContext(this) }, leftBuilder.builder)
}
centerBuilder ?.let {
Div({ classes("uk-navbar-center") }) { it.draw() }
Div({ include(UIKitNavbar.Alignment.Center);centerBuilder.attributesBuilderContext(this) }, centerBuilder.builder)
}
rightBuilder ?.let {
Div({ classes("uk-navbar-right") }) { it.draw() }
Div({ include(UIKitNavbar.Alignment.Right);rightBuilder.attributesBuilderContext(this) }, rightBuilder.builder)
}
}
}

View File

@@ -1,63 +1,45 @@
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.*
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.*
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()
}
}
}
class NavbarNavBuilder(
private val modifiers: Array<UIKitModifier>,
private val elements: List<NavbarNavElement>,
private val attributesCustomizer: AttrBuilderContext<HTMLUListElement> = {}
@Composable
fun NavbarNav(
elements: List<AttrsWithContentBuilder<HTMLLIElement>>,
attrs: Attrs<HTMLUListElement> = Attrs.empty()
) {
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(
{
classes("uk-navbar-nav")
include(*modifiers)
attributesCustomizer()
}
) {
elements.forEach { element ->
Li(
{ element.apply { setup() } }
) {
element.apply { fill() }
}
}
Ul(
{
include(UIKitNavbar.Nav)
attrs.builder(this)
}
) {
elements.forEach { element ->
Li(element.attributesBuilderContext, element.builder)
}
}
}
@Composable
fun NavbarNav(
vararg elements: AttrsWithContentBuilder<HTMLLIElement>,
attrs: Attrs<HTMLUListElement> = Attrs.empty()
) = NavbarNav(elements.toList(), attrs)
fun NavbarNavBuilder(
elements: List<AttrsWithContentBuilder<HTMLLIElement>>,
attrs: Attrs<HTMLUListElement> = Attrs.empty(),
containerAttrs: Attrs<HTMLDivElement> = Attrs.empty()
) = AttrsWithContentBuilder<HTMLDivElement>(containerAttrs) {
NavbarNav(elements, attrs)
}
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,26 @@
package dev.inmo.jsuikit.elements
import androidx.compose.runtime.Composable
import dev.inmo.jsuikit.modifiers.UIKitToggle
import dev.inmo.jsuikit.modifiers.include
import dev.inmo.jsuikit.utils.Attrs
import org.jetbrains.compose.web.attributes.ButtonType
import org.jetbrains.compose.web.attributes.type
import org.jetbrains.compose.web.dom.Button
import org.jetbrains.compose.web.dom.ContentBuilder
import org.w3c.dom.HTMLButtonElement
@Composable
fun Toggle(
attrs: Attrs<HTMLButtonElement>,
contentBuilder: ContentBuilder<HTMLButtonElement>
) {
Button(
{
include(UIKitToggle)
type(ButtonType.Button)
attrs.builder(this)
},
contentBuilder
)
}

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

@@ -12,5 +12,12 @@ sealed class UIKitButton(suffix: String?) : UIKitModifier {
object Link : Type("link")
}
sealed class Size(suffix: String) : UIKitButton(suffix) {
object Small : Size("small")
object Large : Size("large")
}
object Group : UIKitButton("group")
companion object : UIKitButton(null)
}

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

@@ -1,20 +1,59 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitGrid(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-grid-$suffix")
import dev.inmo.jsuikit.utils.buildAttribute
sealed class Gap(suffix: String) : UIKitGrid(suffix) {
sealed class UIKitGrid(vararg classnames: String) : UIKitModifier {
override val classes: Array<String> = classnames as Array<String>
object Small : Gap("small")
object Medium : Gap("medium")
object Large : Gap("large")
object Collapse : Gap("collapse")
sealed class Gap(classname: String) : UIKitGrid(classname) {
object Small : Gap("uk-grid-small")
object Medium : Gap("uk-grid-medium")
object Large : Gap("uk-grid-large")
object Collapse : Gap("uk-grid-collapse")
}
object Divider : UIKitGrid("divider")
sealed class Column(classname: String) : UIKitGrid(classname) {
object MatchHeight : UIKitGrid("match")
object ItemMatchHeight : UIKitGrid("item-match")
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("uk-grid")
companion object : UIKitGrid("uk-grid") {
operator fun invoke(
margin: UIKitMargin? = null,
firstColumnClass: String? = null,
masonry: Boolean? = null,
parallax: UInt? = null
) = Custom(
mapOf(
buildAttribute("uk-grid") {
margin to margin ?.classes ?.joinToString(" ")
"first-column" to firstColumnClass
"masonry" to masonry
"parallax" to parallax
}
)
)
}
}

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

@@ -14,6 +14,8 @@ sealed class UIKitNav(classname: String) : UIKitModifier {
object Center : UIKitNav("uk-nav-center")
object Sub : UIKitNav("uk-nav-sub")
companion object : UIKitNav("uk-nav") {
val SubNav = UIKitSubNav
}

View File

@@ -1,17 +1,86 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitNavbar(suffix: String) : UIKitModifier {
override val classes: Array<String> = arrayOf("uk-navbar-$suffix")
import dev.inmo.jsuikit.types.Dropdown
import dev.inmo.jsuikit.utils.*
object Transparent : UIKitNavbar("transparent")
sealed class Dropdown(suffix: String?) : UIKitNavbar("dropdown${suffix ?.let { "-$it" } ?: ""}") {
sealed class UIKitNavbar(vararg classes: String) : UIKitModifier {
override val classes: Array<String> = classes as Array<String>
object Transparent : UIKitNavbar("uk-navbar-transparent")
object Container : UIKitNavbar("uk-navbar-container")
sealed class Dropdown(suffix: String?) : UIKitNavbar("uk-navbar-dropdown${suffix ?.let { "-$it" } ?: ""}") {
object Nav : Dropdown("nav")
sealed class Width(suffix: String) : Dropdown(suffix) {
object Two : Width("width-2")
object Three : Width("width-3")
object Four : Width("width-4")
object Five : Width("width-5")
}
companion object : Dropdown(null)
}
object Item : UIKitNavbar("item")
sealed class Alignment(val suffix: String) : UIKitNavbar("uk-navbar-$suffix") {
object Left : Alignment("left")
sealed class Center(suffix: String) : Alignment(suffix) {
object Left : Center("center-left")
object Right : Center("center-right")
companion object {
companion object : Center("center")
}
object Right : Alignment("right")
}
object Item : UIKitNavbar("uk-navbar-item")
object Nav : UIKitNavbar("uk-navbar-nav")
object Subtitle : UIKitNavbar("uk-navbar-subtitle")
object Toggle : UIKitNavbar("uk-navbar-toggle")
object Sticky : UIKitNavbar("uk-navbar-sticky")
class Component internal constructor(
override val otherAttrs: Map<String, String>
) : UIKitNavbar(*UIKitNavbar.classes)
companion object : UIKitNavbar("uk-navbar") {
val Logo = UIKitUtility.Logo
operator fun invoke(
align: String?,
mode: String? = null,
delayShow: Milliseconds? = null,
delayHide: Milliseconds? = null,
boundary: String? = null,
boundaryAlign: Boolean? = null,
offset: Pixels? = null,
dropbar: Boolean? = null,
duration: Milliseconds? = null
): Component {
return Component(
mapOf(
buildAttribute(UIKitNavbar.classes.first()) {
"align" to align
"mode" to mode
"delay-show" to delayShow
"delay-hide" to delayHide
"boundary" to boundary
"boundary-align" to boundaryAlign
"offset" to offset
"dropbar" to dropbar
"duration" to duration
}
)
)
}
operator fun invoke(
align: Alignment? = null,
mode: UIKitDropdown.Mode? = null,
delayShow: Milliseconds? = null,
delayHide: Milliseconds? = null,
boundary: String? = null,
boundaryAlign: Boolean? = null,
offset: Pixels? = null,
dropbar: Boolean? = null,
duration: Milliseconds? = null
): Component = invoke(align ?.suffix, mode ?.name, delayShow, delayHide, boundary, boundaryAlign, offset, dropbar, duration)
}
}

View File

@@ -0,0 +1,23 @@
package dev.inmo.jsuikit.modifiers
sealed class UIKitSection(vararg classes: String) : UIKitModifier {
override val classes: Array<String> = classes as Array<String>
sealed class Style(suffix: String) : UIKitSection("uk-section-$suffix") {
object Default : Style("default")
object Muted : Style("muted")
object Primary : Style("primary")
object Secondary : Style("secondary")
}
sealed class Size(suffix: String) : UIKitSection("uk-section-$suffix") {
object XSmall : Size("xsmall")
object Small : Size("small")
object Large : Size("large")
object XLarge : Size("xlarge")
}
object Overlap : UIKitSection("uk-section-overlap")
companion object : UIKitSection("uk-section")
}

View File

@@ -0,0 +1,47 @@
package dev.inmo.jsuikit.modifiers
import dev.inmo.jsuikit.utils.buildAttribute
import org.jetbrains.compose.web.css.CSSUnitLengthOrPercentage
import org.jetbrains.compose.web.css.CSSUnitValueTyped
class UIKitSticky(
position: Position? = null,
start: String? = null,
end: String? = null,
offset: CSSUnitValueTyped<CSSUnitLengthOrPercentage>? = null,
overflowFlip: Boolean? = null,
animation: UIKitAnimation? = null,
classForActiveItems: String? = null,
classForInactiveItems: String? = null,
showOnUp: Boolean? = null,
media: String? = null,
targetOffset: CSSUnitValueTyped<CSSUnitLengthOrPercentage>? = null
) : UIKitModifier {
override val otherAttrs: Map<String, String> = mapOf(
buildAttribute("uk-sticky") {
"position" to position ?.name
"start" to start
"end" to end
"offset" to offset ?.toString()
"overflow-flip" to overflowFlip
"animation" to animation
"cls-active" to classForActiveItems
"cls-inactive" to classForInactiveItems
"show-on-up" to showOnUp
"media" to media
"target-offset" to targetOffset ?.toString()
}
)
sealed interface Position {
val name: String
object Top : Position {
override val name: String
get() = "top"
}
object Bottom : Position {
override val name: String
get() = "bottom"
}
}
}

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

@@ -38,7 +38,7 @@ sealed class UIKitToggle(
class Custom internal constructor(otherAttrs: Map<String, String>) : UIKitToggle(otherAttrs = otherAttrs)
companion object {
companion object : UIKitToggle(otherAttrs = mapOf("uk-toggle" to "")) {
operator fun invoke(
target: String? = null,
mode: Mode? = null,

View File

@@ -38,7 +38,10 @@ sealed class UIKitUtility(classname: String) : UIKitModifier {
object Width : Responsive("width")
object Height : Responsive("height")
}
object PreserveWidth : UIKitUtility("uk-preserve-width")
sealed class Preserve(suffix: String) : UIKitUtility("uk-preserve-$suffix") {
object Width : Preserve("width")
object Color : Preserve("color")
}
sealed class Border(suffix: String) : UIKitUtility("uk-border-$suffix") {
object Rounded : Border("rounded")
@@ -112,4 +115,8 @@ sealed class UIKitUtility(classname: String) : UIKitModifier {
object Open : UIKitUtility("uk-open")
object Link : UIKitUtility("uk-link")
companion object {
val PreserveWidth = Preserve.Width
}
}

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

@@ -0,0 +1,32 @@
package dev.inmo.jsuikit.utils
import dev.inmo.jsuikit.modifiers.UIKitModifier
import org.jetbrains.compose.web.attributes.AttrsScope
import org.jetbrains.compose.web.dom.ContentBuilder
import org.w3c.dom.Element
typealias AttrsWithContentBuilder<T> = Pair<Attrs<T>, ContentBuilder<T>>
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Element> AttrsWithContentBuilder(
vararg modifiers: UIKitModifier?,
noinline attrs: AttrsScope<T>.() -> Unit = {},
noinline builder: ContentBuilder<T>
) = AttrsWithContentBuilder(
Attrs(*modifiers, attrs = attrs),
builder
)
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Element> AttrsWithContentBuilder(attrs: Attrs<T>) = AttrsWithContentBuilder(
attrs
) {}
inline val <T : Element> AttrsWithContentBuilder<T>.attrs
get() = first
inline val <T : Element> AttrsWithContentBuilder<T>.attributesBuilderContext
get() = attrs.builder
inline val <T : Element> AttrsWithContentBuilder<T>.builder
get() = second

View File

@@ -1,55 +0,0 @@
package dev.inmo.jsuikit.utils
import androidx.compose.runtime.Composable
import kotlinx.browser.document
import org.jetbrains.compose.web.dom.*
import org.w3c.dom.*
private object DListElementBuilder : ElementBuilder<HTMLDListElement> {
private val el: Element by lazy { document.createElement("dl") }
override fun create(): HTMLDListElement = el.cloneNode() as HTMLDListElement
}
private object DTermElementBuilder : ElementBuilder<HTMLElement> {
private val el: Element by lazy { document.createElement("dt") }
override fun create(): HTMLElement = el.cloneNode() as HTMLElement
}
private object DDescriptionElementBuilder : ElementBuilder<HTMLElement> {
private val el: Element by lazy { document.createElement("dd") }
override fun create(): HTMLElement = el.cloneNode() as HTMLElement
}
@Composable
fun DList(
attrs: AttrBuilderContext<HTMLDListElement>? = null,
content: ContentBuilder<HTMLDListElement>? = null
) {
TagElement(
DListElementBuilder,
attrs,
content
)
}
@Composable
fun DTerm(
attrs: AttrBuilderContext<HTMLElement>? = null,
content: ContentBuilder<HTMLElement>? = null
) {
TagElement(
DTermElementBuilder,
attrs,
content
)
}
@Composable
fun DDescription(
attrs: AttrBuilderContext<HTMLElement>? = null,
content: ContentBuilder<HTMLElement>? = null
) {
TagElement(
DDescriptionElementBuilder,
attrs,
content
)
}

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)