1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| import { TextControl, TextareaControl } from '@wordpress/components';
|
| const TYPE_MAP = { text: 'text', email: 'email', tel: 'tel', url: 'url', number: 'number' };
|
| const TextField = ({ field, value, onChange }) => {
| if (field.type === 'textarea') {
| return (
| <TextareaControl
| label={field.label}
| help={field.description}
| value={value ?? ''}
| onChange={onChange}
| id={field.name}
| />
| );
| }
|
| return (
| <TextControl
| label={field.label}
| help={field.description}
| type={TYPE_MAP[field.type] || 'text'}
| value={value ?? ''}
| onChange={onChange}
| required={field.required}
| id={field.name}
| />
| );
| };
|
| export default TextField;
|
|