Compare commits

...

42 Commits

Author SHA1 Message Date
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
30 changed files with 630 additions and 238 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,50 @@
# Changelog
## 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

@@ -21,7 +21,7 @@ if (new File(projectDir, "secret.gradle").exists()) {
owner "InsanusMokrassar"
repo "JSUIKitKBindings"
tagName "${project.version}"
tagName "v${project.version}"
releaseName "${project.version}"
targetCommitish "${project.version}"

View File

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

View File

@@ -1,8 +1,8 @@
[versions]
kt = "1.6.21"
jb-compose = "1.2.0-alpha01-dev731"
jb-dokka = "1.6.21"
kt = "1.7.20"
jb-compose = "1.2.2"
jb-dokka = "1.7.20"
gh-release = "2.4.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-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

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

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,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

@@ -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

@@ -36,6 +36,7 @@ fun Dialog(
footerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
footerBuilder: ContentBuilder<HTMLDivElement>? = null,
bodyAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
autoShow: Boolean = true,
bodyBuilder: ContentBuilder<HTMLDivElement>
) {
Div(
@@ -99,7 +100,9 @@ fun Dialog(
}
htmlElement.addEventListener("hidden", wrapper)
UIKit.modal("#${htmlElement.id}") ?.show()
if (autoShow) {
UIKit.modal("#${htmlElement.id}") ?.show()
}
}
}
}
@@ -112,6 +115,7 @@ fun Dialog(
hidden: (() -> Unit)? = null,
footerBuilder: (@Composable () -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
autoShow: Boolean = true,
bodyBuilder: @Composable () -> Unit
) = Dialog(
modifiers = modifiers,
@@ -130,6 +134,7 @@ fun Dialog(
attributesCustomizer = {
attributesCustomizer()
},
autoShow = autoShow,
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

@@ -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

@@ -9,13 +9,14 @@ import org.jetbrains.compose.web.dom.Input
import org.w3c.dom.HTMLInputElement
@Composable
fun <T> StandardInput(
fun <T> DefaultInput(
type: InputType<T>,
state: MutableState<T>,
disabledState: State<Boolean>? = null,
value: T,
disabled: Boolean = false,
placeholder: String? = null,
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
onChange: (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,30 @@ fun <T> StandardInput(
}
}
onInput { state.value = it.value }
onInput { onChange(it.value) }
disabledState ?.let {
if (it.value) {
disabled()
}
if (disabled) {
disabled()
}
attributesCustomizer()
}
}
@Composable
@Deprecated("Renamed", ReplaceWith("StandardInput", "dev.inmo.jsuikit.elements.StandardInput"))
fun <T> TextField(
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)
) = DefaultInput(
type,
state.value,
disabledState ?.value == true,
placeholder,
modifiers = modifiers,
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,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

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