({
className,
style,
value = "",
disabled = false,
onChange,
}: InputTextProps)
| 29 | } |
| 30 | |
| 31 | function InputText({ |
| 32 | className, |
| 33 | style, |
| 34 | value = "", |
| 35 | disabled = false, |
| 36 | onChange, |
| 37 | }: InputTextProps) { |
| 38 | const [stateValue, setStateValue] = useState(value); |
| 39 | |
| 40 | useEffect(() => { |
| 41 | setStateValue(value); |
| 42 | }, [value]); |
| 43 | |
| 44 | function update(pValue: string) { |
| 45 | setStateValue(pValue); |
| 46 | if (onChange) { |
| 47 | onChange(pValue); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | function handleChange(event: React.ChangeEvent<HTMLInputElement>) { |
| 52 | update(event.target.value); |
| 53 | } |
| 54 | |
| 55 | const inputWidth = 100; |
| 56 | |
| 57 | const _style: React.CSSProperties = { |
| 58 | display: "flex", |
| 59 | justifyContent: "center", |
| 60 | alignItems: "center", |
| 61 | width: "100%", |
| 62 | ...style, |
| 63 | }; |
| 64 | |
| 65 | if (disabled) { |
| 66 | _style.cursor = "not-allowed"; |
| 67 | } |
| 68 | |
| 69 | return ( |
| 70 | <div |
| 71 | className={classNames("solid-elem", "solid-input-text", className)} |
| 72 | style={_style} |
| 73 | > |
| 74 | <input |
| 75 | type="text" |
| 76 | inputMode="text" |
| 77 | value={stateValue} |
| 78 | style={{ width: `${inputWidth}%` }} |
| 79 | onChange={handleChange} |
| 80 | disabled={disabled} |
| 81 | /> |
| 82 | </div> |
| 83 | ); |
| 84 | } |
| 85 | |
| 86 | export default InputText; |
nothing calls this directly
no outgoing calls
no test coverage detected