(props: CellProps & VanillaRendererProps)
| 35 | import merge from 'lodash/merge'; |
| 36 | |
| 37 | export const TextCell = (props: CellProps & VanillaRendererProps) => { |
| 38 | const { |
| 39 | config, |
| 40 | data, |
| 41 | className, |
| 42 | id, |
| 43 | enabled, |
| 44 | uischema, |
| 45 | schema, |
| 46 | path, |
| 47 | handleChange, |
| 48 | } = props; |
| 49 | const maxLength = schema.maxLength; |
| 50 | const appliedUiSchemaOptions = merge({}, config, uischema.options); |
| 51 | return ( |
| 52 | <input |
| 53 | type={appliedUiSchemaOptions.format === 'password' ? 'password' : 'text'} |
| 54 | value={data || ''} |
| 55 | onChange={(ev) => |
| 56 | handleChange(path, ev.target.value === '' ? undefined : ev.target.value) |
| 57 | } |
| 58 | className={className} |
| 59 | id={id} |
| 60 | disabled={!enabled} |
| 61 | autoFocus={appliedUiSchemaOptions.focus} |
| 62 | placeholder={appliedUiSchemaOptions.placeholder} |
| 63 | maxLength={appliedUiSchemaOptions.restrict ? maxLength : undefined} |
| 64 | size={appliedUiSchemaOptions.trim ? maxLength : undefined} |
| 65 | /> |
| 66 | ); |
| 67 | }; |
| 68 | |
| 69 | /** |
| 70 | * Default tester for text-based/string controls. |
nothing calls this directly
no test coverage detected
searching dependent graphs…