Merge pull request #79 from InsanusMokrassar/0.6.1

0.6.1
This commit is contained in:
InsanusMokrassar 2023-03-05 21:36:49 +06:00 committed by GitHub
commit 730da9f759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 30 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
## 0.6.1
* `DefaultInput` has been renamed to `StandardInput`
* `Compose`: `1.3.1-rc02`
## 0.6.0 ## 0.6.0
* `Kotlin`: `1.8.10` * `Kotlin`: `1.8.10`

View File

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

View File

@ -1,8 +1,8 @@
[versions] [versions]
kt = "1.8.10" kt = "1.8.10"
jb-compose = "1.3.1-rc01" jb-compose = "1.3.1-rc02"
jb-dokka = "1.7.20" jb-dokka = "1.8.10"
gh-release = "2.4.1" gh-release = "2.4.1"
[libraries] [libraries]

View File

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

View File

@ -8,6 +8,40 @@ import org.jetbrains.compose.web.dom.AttrBuilderContext
import org.jetbrains.compose.web.dom.Input import org.jetbrains.compose.web.dom.Input
import org.w3c.dom.HTMLInputElement import org.w3c.dom.HTMLInputElement
@Composable
fun <T> StandardInput(
type: InputType<T>,
value: T? = null,
vararg modifiers: UIKitModifier,
disabled: Boolean = false,
placeholder: String? = null,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
onChange: HTMLInputElement.(T) -> Unit
) {
Input(type) {
classes("uk-input")
include(*modifiers)
placeholder ?.let(::placeholder)
value ?.let {
when (it) {
is String -> value(it)
is Number -> value(it)
else -> {}
}
}
onInput { event -> event.target.onChange(event.value) }
if (disabled) {
disabled()
}
attributesCustomizer()
}
}
@Deprecated("Renamed", ReplaceWith("StandardInput(type, value, *modifiers, disabled, placeholder, attributesCustomizer, onChange)"))
@Composable @Composable
fun <T> DefaultInput( fun <T> DefaultInput(
type: InputType<T>, type: InputType<T>,
@ -17,28 +51,8 @@ fun <T> DefaultInput(
vararg modifiers: UIKitModifier, vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {}, attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
onChange: (T) -> Unit onChange: (T) -> Unit
) { ) = StandardInput(type, value, modifiers = modifiers, disabled, placeholder, attributesCustomizer) {
Input(type) { onChange(it)
classes("uk-input")
include(*modifiers)
placeholder ?.let(::placeholder)
value.let {
when (it) {
is String -> value(it)
is Number -> value(it)
else -> {}
}
}
onInput { onChange(it.value) }
if (disabled) {
disabled()
}
attributesCustomizer()
}
} }
@Composable @Composable
@ -49,12 +63,12 @@ fun <T> StandardInput(
placeholder: String? = null, placeholder: String? = null,
vararg modifiers: UIKitModifier, vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {}, attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
) = DefaultInput( ) = StandardInput(
type, type,
state.value, state.value,
modifiers = modifiers,
disabledState ?.value == true, disabledState ?.value == true,
placeholder, placeholder,
modifiers = modifiers,
attributesCustomizer = attributesCustomizer attributesCustomizer = attributesCustomizer
) { ) {
state.value = it state.value = it