import {iInputCompositionData} from "./input.utils"; import {createEffectiveHandler} from "../../utils/createEffectiveHandler"; import {createEffects} from "@peryl/utils/createEffects"; import {iKeyboardEvent} from "@peryl/react-compose"; import {FixInput} from "../../utils/FixInput"; export const useSingleInput = createEffectiveHandler(({ props, hooks, model, editComputed, styleComputed }: iInputCompositionData) => { const { effects } = createEffects(); const handler = { onRef: (input: any) => hooks.onRefInput.exec(input), onInput: (e: any) => { const val = e.target.value as string; if (!!props.maxLength && val.length > props.maxLength) { e.target.value = model.value; return; } model.value = val; hooks.onInput.exec(model.value); }, onKeydown: (e: iKeyboardEvent) => hooks.onInputKeydown.exec(e), }; effects.push(hooks.onRenderDefault.use((prev) => <> {prev} {!props.multiple && !props.textarea && ( styleComputed.value.inputMode === 'text' ? {model.value} : )} )); return effects.clear; });