(props: TextInputProps)
| 29 | * |
| 30 | */ |
| 31 | export const TextInput = (props: TextInputProps) => { |
| 32 | const { |
| 33 | className, |
| 34 | defaultValue, |
| 35 | label, |
| 36 | format, |
| 37 | helperText, |
| 38 | onBlur, |
| 39 | onChange, |
| 40 | parse, |
| 41 | resource, |
| 42 | source, |
| 43 | validate, |
| 44 | ...rest |
| 45 | } = useThemeProps({ |
| 46 | props: props, |
| 47 | name: PREFIX, |
| 48 | }); |
| 49 | |
| 50 | const { |
| 51 | field, |
| 52 | fieldState: { error, invalid }, |
| 53 | id, |
| 54 | isRequired, |
| 55 | } = useInput({ |
| 56 | defaultValue, |
| 57 | format, |
| 58 | parse, |
| 59 | resource, |
| 60 | source, |
| 61 | type: 'text', |
| 62 | validate, |
| 63 | onBlur, |
| 64 | onChange, |
| 65 | ...rest, |
| 66 | }); |
| 67 | |
| 68 | const renderHelperText = helperText !== false || invalid; |
| 69 | |
| 70 | return ( |
| 71 | <StyledResettableTextField |
| 72 | id={id} |
| 73 | {...field} |
| 74 | className={clsx('ra-input', `ra-input-${source}`, className)} |
| 75 | label={ |
| 76 | label !== '' && label !== false ? ( |
| 77 | <FieldTitle |
| 78 | label={label} |
| 79 | source={source} |
| 80 | resource={resource} |
| 81 | isRequired={isRequired} |
| 82 | /> |
| 83 | ) : null |
| 84 | } |
| 85 | error={invalid} |
| 86 | helperText={ |
| 87 | renderHelperText ? ( |
| 88 | <InputHelperText |
nothing calls this directly
no test coverage detected