Open History to see the last commit
1import { FieldError } from './FieldError'
2import type { FieldWithValue } from '@tanstack/preact-form'
3β
4interface StringFieldProps {
5 field: FieldWithValue<string>
6 label: string
7}
8β
9export function StringField(props: StringFieldProps) {
10 const { field, label } = props
11β
12 return (
13 <label
14 className={field.meta.isValidating ? 'validating' : ''}
15 style={{
16 display: 'block',
17 }}
18 >
19 <span>{label}</span>
20β
21 <input
22 name={field.name}
23 value={field.value}
24 onBlur={field.handleBlur}
25 onInput={(e) => field.handleChange(e.currentTarget.value)}
26 aria-invalid={field.meta.isInvalid}
27 />
28 <br />
29 <FieldError field={field} />
30 </label>
31 )
32}