JSUIKitKBindings/src/main/kotlin/dev/inmo/jsuikit/elements/TextField.kt
2022-01-12 16:30:45 +06:00

31 lines
724 B
Kotlin

package dev.inmo.jsuikit.elements
import androidx.compose.runtime.*
import dev.inmo.jsuikit.modifers.UIKitModifier
import dev.inmo.jsuikit.modifers.include
import org.jetbrains.compose.web.attributes.*
import org.jetbrains.compose.web.dom.Input
@Composable
fun <T> TextField(
type: InputType<T>,
state: MutableState<T>,
disabledState: State<Boolean>? = null,
placeholder: String? = null,
vararg modifiers: UIKitModifier
) {
Input(type) {
classes("uk-input")
include(*modifiers)
placeholder ?.let(::placeholder)
onChange { state.value = it.value }
disabledState ?.let {
if (it.value) {
disabled()
}
}
}
}