TextField -> StandardInput + fixes in it

This commit is contained in:
InsanusMokrassar 2022-01-26 00:51:26 +06:00
parent 17badd4724
commit 4a7101697a
2 changed files with 25 additions and 2 deletions

View File

@ -2,6 +2,9 @@
## 0.0.27 ## 0.0.27
* `TextField` has been renamed to `StandardInput`
* `StandardInput` now will look for changes in state
## 0.0.26 ## 0.0.26
* Add UIKitColumn * Add UIKitColumn

View File

@ -9,7 +9,7 @@ import org.jetbrains.compose.web.dom.Input
import org.w3c.dom.HTMLInputElement import org.w3c.dom.HTMLInputElement
@Composable @Composable
fun <T> TextField( fun <T> StandardInput(
type: InputType<T>, type: InputType<T>,
state: MutableState<T>, state: MutableState<T>,
disabledState: State<Boolean>? = null, disabledState: State<Boolean>? = null,
@ -23,7 +23,16 @@ fun <T> TextField(
placeholder ?.let(::placeholder) placeholder ?.let(::placeholder)
onChange { state.value = it.value } state.value.let {
when (it) {
is String -> value(it)
is Number -> value(it)
else -> {}
}
}
onInput { state.value = it.value }
disabledState ?.let { disabledState ?.let {
if (it.value) { if (it.value) {
disabled() disabled()
@ -32,3 +41,14 @@ fun <T> TextField(
attributesCustomizer() attributesCustomizer()
} }
} }
@Composable
@Deprecated("Renamed", ReplaceWith("StandardInput", "dev.inmo.jsuikit.elements.StandardInput"))
fun <T> TextField(
type: InputType<T>,
state: MutableState<T>,
disabledState: State<Boolean>? = null,
placeholder: String? = null,
vararg modifiers: UIKitModifier,
attributesCustomizer: AttrBuilderContext<HTMLInputElement> = {},
) = StandardInput(type, state, disabledState, placeholder, modifiers = modifiers, attributesCustomizer)