(props: InputProps)
| 11 | } |
| 12 | |
| 13 | export function Input(props: InputProps) { |
| 14 | const styles = createStyles() |
| 15 | const [val, setVal] = createSignal(props.value || '') |
| 16 | |
| 17 | const handleChange = (e: Event) => { |
| 18 | const value = (e.target as HTMLInputElement).value |
| 19 | setVal((prev) => (prev !== value ? value : prev)) |
| 20 | props.onChange?.(value) |
| 21 | } |
| 22 | |
| 23 | return ( |
| 24 | <div class={styles().inputContainer}> |
| 25 | <div class={styles().inputWrapper}> |
| 26 | {props.label && ( |
| 27 | <label class={styles().inputLabel}>{props.label}</label> |
| 28 | )} |
| 29 | {props.description && ( |
| 30 | <p class={styles().inputDescription}>{props.description}</p> |
| 31 | )} |
| 32 | <input |
| 33 | type={props.type || 'text'} |
| 34 | class={styles().input} |
| 35 | value={val()} |
| 36 | placeholder={props.placeholder} |
| 37 | onInput={handleChange} |
| 38 | /> |
| 39 | </div> |
| 40 | </div> |
| 41 | ) |
| 42 | } |
nothing calls this directly
no test coverage detected