diff --git a/src/components/Input.tsx b/src/components/Input.tsx index fa673d9..7e5dbb8 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -11,6 +11,7 @@ interface InputProps { defaultValue?: string; placeholder?: string; disabled?: boolean; + readonly?: boolean; onInput?: (value: string | null) => void; wrapperClass?: JSX.HTMLAttributes['class']; inputClass?: JSX.HTMLAttributes['class']; @@ -21,6 +22,7 @@ const Input: Component = (props) => { { variant: 'normal', disabled: false, + readonly: false, placeholder: '', }, props, @@ -38,6 +40,9 @@ const Input: Component = (props) => { }); const handleInput: JSX.EventHandler = (evt) => { + if (mProps.readonly || mProps.disabled) { + return; + } const value = evt.currentTarget.value; setInternalValue(value); mProps.onInput?.(value); @@ -46,8 +51,9 @@ const Input: Component = (props) => { return (
= (props) => { type={mProps.type} placeholder={mProps.placeholder} disabled={mProps.disabled} + readonly={mProps.readonly} value={internalValue()} class={cx( 'min-h-[1em] grow focus:outline-none placeholder:italic disabled:text-neutral-disabled',