package dev.inmo.jsuikit.elements import androidx.compose.runtime.* import dev.inmo.jsuikit.modifiers.UIKitModifier import dev.inmo.jsuikit.modifiers.include import org.jetbrains.compose.web.attributes.* import org.jetbrains.compose.web.dom.AttrBuilderContext import org.jetbrains.compose.web.dom.Input import org.w3c.dom.HTMLInputElement @Composable fun StandardInput( type: InputType, state: MutableState, disabledState: State? = null, placeholder: String? = null, vararg modifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, ) { Input(type) { classes("uk-input") include(*modifiers) placeholder ?.let(::placeholder) state.value.let { when (it) { is String -> value(it) is Number -> value(it) else -> {} } } onInput { state.value = it.value } disabledState ?.let { if (it.value) { disabled() } } attributesCustomizer() } } @Composable @Deprecated("Renamed", ReplaceWith("StandardInput", "dev.inmo.jsuikit.elements.StandardInput")) fun TextField( type: InputType, state: MutableState, disabledState: State? = null, placeholder: String? = null, vararg modifiers: UIKitModifier, attributesCustomizer: AttrBuilderContext = {}, ) = StandardInput(type, state, disabledState, placeholder, modifiers = modifiers, attributesCustomizer)