@ultraviolet/form 2.0.0-next.7 → 2.0.0-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckboxField/index.js +45 -49
- package/dist/components/CheckboxGroupField/index.js +31 -33
- package/dist/components/DateField/index.js +55 -58
- package/dist/components/Form/index.js +75 -36
- package/dist/components/NumberInputField/index.js +49 -40
- package/dist/components/RadioField/index.js +38 -42
- package/dist/components/RadioGroupField/index.js +32 -31
- package/dist/components/SelectInputField/index.js +74 -82
- package/dist/components/SelectableCardField/index.js +35 -43
- package/dist/components/Submit/index.js +19 -32
- package/dist/components/SubmitErrorAlert/index.js +12 -20
- package/dist/components/TagInputField/index.js +25 -26
- package/dist/components/TextInputField/index.js +104 -108
- package/dist/components/TimeField/index.js +44 -47
- package/dist/components/ToggleField/index.js +39 -52
- package/dist/helpers/pickValidators.js +1 -4
- package/dist/hooks/useField.js +2 -2
- package/dist/hooks/useFormField.js +26 -27
- package/dist/hooks/useFormState.js +1 -0
- package/dist/hooks/useOnFieldChange.js +14 -23
- package/dist/hooks/useValidation.js +14 -20
- package/dist/index.d.ts +256 -538
- package/dist/index.js +6 -5
- package/dist/providers/ErrorContext/index.js +12 -51
- package/dist/validators/maxDate.js +1 -4
- package/dist/validators/minDate.js +1 -4
- package/package.json +6 -6
|
@@ -1,65 +1,61 @@
|
|
|
1
1
|
import { Radio } from '@ultraviolet/ui';
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
2
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
4
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
4
|
-
import { useFormField } from '../../hooks/useFormField.js';
|
|
5
5
|
|
|
6
|
-
const RadioField =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const RadioField = ({
|
|
7
|
+
className,
|
|
8
|
+
'data-testid': dataTestId,
|
|
9
|
+
disabled,
|
|
10
|
+
id,
|
|
11
|
+
name,
|
|
12
|
+
onBlur,
|
|
13
|
+
label = '',
|
|
14
|
+
onChange,
|
|
15
|
+
onFocus,
|
|
16
|
+
required,
|
|
17
|
+
value,
|
|
18
|
+
rules,
|
|
19
|
+
tooltip,
|
|
20
|
+
shouldUnregister = false
|
|
21
|
+
}) => {
|
|
22
22
|
const {
|
|
23
23
|
getError
|
|
24
24
|
} = useErrors();
|
|
25
25
|
const {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
validate,
|
|
32
|
-
value
|
|
33
|
-
});
|
|
34
|
-
const error = getError({
|
|
35
|
-
disabled,
|
|
36
|
-
label: label,
|
|
37
|
-
meta: meta,
|
|
26
|
+
field,
|
|
27
|
+
fieldState: {
|
|
28
|
+
error
|
|
29
|
+
}
|
|
30
|
+
} = useController({
|
|
38
31
|
name,
|
|
39
|
-
|
|
32
|
+
shouldUnregister,
|
|
33
|
+
rules: {
|
|
34
|
+
required,
|
|
35
|
+
...rules
|
|
36
|
+
}
|
|
40
37
|
});
|
|
41
38
|
return jsx(Radio, {
|
|
42
|
-
|
|
39
|
+
name: field.name,
|
|
40
|
+
checked: field.value === value,
|
|
43
41
|
className: className,
|
|
44
42
|
"data-testid": dataTestId,
|
|
45
43
|
disabled: disabled,
|
|
46
|
-
error:
|
|
44
|
+
error: getError({
|
|
45
|
+
label: typeof label === 'string' ? label : ''
|
|
46
|
+
}, error),
|
|
47
47
|
id: id,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
onChange?.(event);
|
|
48
|
+
onChange: () => {
|
|
49
|
+
field.onChange(value);
|
|
50
|
+
onChange?.(value);
|
|
52
51
|
},
|
|
53
52
|
onBlur: event => {
|
|
54
|
-
|
|
53
|
+
field.onBlur();
|
|
55
54
|
onBlur?.(event);
|
|
56
55
|
},
|
|
57
|
-
onFocus:
|
|
58
|
-
input.onFocus(event);
|
|
59
|
-
onFocus?.(event);
|
|
60
|
-
},
|
|
56
|
+
onFocus: onFocus,
|
|
61
57
|
required: required,
|
|
62
|
-
value:
|
|
58
|
+
value: value ?? '',
|
|
63
59
|
label: label,
|
|
64
60
|
tooltip: tooltip
|
|
65
61
|
});
|
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
import { RadioGroup } from '@ultraviolet/ui';
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
2
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
4
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
4
|
-
import { useFormField } from '../../hooks/useFormField.js';
|
|
5
5
|
|
|
6
|
-
const RadioGroupField =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
const RadioGroupField = ({
|
|
7
|
+
className,
|
|
8
|
+
legend = '',
|
|
9
|
+
name,
|
|
10
|
+
onChange,
|
|
11
|
+
required,
|
|
12
|
+
rules,
|
|
13
|
+
children,
|
|
14
|
+
label = '',
|
|
15
|
+
error: customError,
|
|
16
|
+
helper,
|
|
17
|
+
direction,
|
|
18
|
+
shouldUnregister = false
|
|
19
|
+
}) => {
|
|
20
20
|
const {
|
|
21
21
|
getError
|
|
22
22
|
} = useErrors();
|
|
23
23
|
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
value
|
|
30
|
-
});
|
|
31
|
-
const error = getError({
|
|
32
|
-
label: legend,
|
|
33
|
-
meta: meta,
|
|
24
|
+
field,
|
|
25
|
+
fieldState: {
|
|
26
|
+
error
|
|
27
|
+
}
|
|
28
|
+
} = useController({
|
|
34
29
|
name,
|
|
35
|
-
|
|
30
|
+
shouldUnregister,
|
|
31
|
+
rules: {
|
|
32
|
+
required,
|
|
33
|
+
...rules
|
|
34
|
+
}
|
|
36
35
|
});
|
|
37
36
|
return jsx(RadioGroup, {
|
|
38
37
|
className: className,
|
|
39
|
-
name:
|
|
38
|
+
name: field.name,
|
|
40
39
|
onChange: event => {
|
|
41
|
-
|
|
42
|
-
onChange?.(event);
|
|
40
|
+
field.onChange(event);
|
|
41
|
+
onChange?.(event.target.value);
|
|
43
42
|
},
|
|
44
43
|
required: required,
|
|
45
|
-
value:
|
|
44
|
+
value: field.value,
|
|
46
45
|
legend: legend,
|
|
47
|
-
error:
|
|
46
|
+
error: getError({
|
|
47
|
+
label
|
|
48
|
+
}, error) ?? customError,
|
|
48
49
|
helper: helper,
|
|
49
50
|
direction: direction,
|
|
50
51
|
children: children
|
|
@@ -1,62 +1,57 @@
|
|
|
1
1
|
import { SelectInput } from '@ultraviolet/ui';
|
|
2
2
|
import { useMemo, Children, useCallback } from 'react';
|
|
3
|
+
import { useController } from 'react-hook-form';
|
|
3
4
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
5
|
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
5
|
-
import { useFormField } from '../../hooks/useFormField.js';
|
|
6
6
|
|
|
7
7
|
const identity = x => x;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
...option,
|
|
57
|
-
label: labelChild
|
|
58
|
-
};
|
|
59
|
-
}), [optionsProp, children]);
|
|
8
|
+
// const identity = <T,>(x: T) => x
|
|
9
|
+
|
|
10
|
+
const SelectInputField = ({
|
|
11
|
+
animation,
|
|
12
|
+
animationDuration,
|
|
13
|
+
animationOnChange,
|
|
14
|
+
children,
|
|
15
|
+
className,
|
|
16
|
+
disabled,
|
|
17
|
+
// error: errorProp,
|
|
18
|
+
format: formatProp = identity,
|
|
19
|
+
// formatOnBlur,
|
|
20
|
+
id,
|
|
21
|
+
inputId,
|
|
22
|
+
isClearable,
|
|
23
|
+
isLoading,
|
|
24
|
+
isSearchable,
|
|
25
|
+
label = '',
|
|
26
|
+
maxLength,
|
|
27
|
+
menuPortalTarget,
|
|
28
|
+
minLength,
|
|
29
|
+
multiple,
|
|
30
|
+
name,
|
|
31
|
+
onBlur,
|
|
32
|
+
onChange,
|
|
33
|
+
onFocus,
|
|
34
|
+
options: optionsProp,
|
|
35
|
+
parse: parseProp = identity,
|
|
36
|
+
placeholder,
|
|
37
|
+
readOnly,
|
|
38
|
+
required,
|
|
39
|
+
rules,
|
|
40
|
+
noTopLabel,
|
|
41
|
+
noOptionsMessage,
|
|
42
|
+
customStyle,
|
|
43
|
+
shouldUnregister = false,
|
|
44
|
+
'data-testid': dataTestId
|
|
45
|
+
}) => {
|
|
46
|
+
const options = useMemo(() => optionsProp || Children.toArray(children).flat().filter(Boolean).map(({
|
|
47
|
+
props: {
|
|
48
|
+
children: labelChild,
|
|
49
|
+
...option
|
|
50
|
+
}
|
|
51
|
+
}) => ({
|
|
52
|
+
...option,
|
|
53
|
+
label: labelChild
|
|
54
|
+
})), [optionsProp, children]);
|
|
60
55
|
const parse = useMemo(() => multiple ? parseProp : option => parseProp(option?.value ?? null, name), [multiple, parseProp, name]);
|
|
61
56
|
const format = useCallback(val => {
|
|
62
57
|
if (multiple) return formatProp(val, name);
|
|
@@ -75,61 +70,58 @@ const SelectInputField = _ref => {
|
|
|
75
70
|
return formatProp(selected, name);
|
|
76
71
|
}, [formatProp, multiple, name, options]);
|
|
77
72
|
const {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
multiple,
|
|
87
|
-
parse,
|
|
88
|
-
required,
|
|
89
|
-
value,
|
|
90
|
-
validate
|
|
91
|
-
});
|
|
92
|
-
const error = getError({
|
|
93
|
-
errorProp,
|
|
94
|
-
label,
|
|
95
|
-
meta: meta,
|
|
73
|
+
getError
|
|
74
|
+
} = useErrors();
|
|
75
|
+
const {
|
|
76
|
+
field,
|
|
77
|
+
fieldState: {
|
|
78
|
+
error
|
|
79
|
+
}
|
|
80
|
+
} = useController({
|
|
96
81
|
name,
|
|
97
|
-
|
|
82
|
+
shouldUnregister,
|
|
83
|
+
rules: {
|
|
84
|
+
required,
|
|
85
|
+
minLength: minLength || required ? 1 : undefined,
|
|
86
|
+
maxLength,
|
|
87
|
+
...rules
|
|
88
|
+
}
|
|
98
89
|
});
|
|
99
90
|
return jsx(SelectInput, {
|
|
91
|
+
name: field.name,
|
|
100
92
|
animation: animation,
|
|
101
93
|
animationDuration: animationDuration,
|
|
102
94
|
animationOnChange: animationOnChange,
|
|
103
95
|
className: className,
|
|
104
96
|
disabled: disabled,
|
|
105
|
-
error:
|
|
97
|
+
error: getError({
|
|
98
|
+
label,
|
|
99
|
+
minLength,
|
|
100
|
+
maxLength
|
|
101
|
+
}, error),
|
|
106
102
|
id: id,
|
|
107
103
|
inputId: inputId,
|
|
108
104
|
isClearable: isClearable,
|
|
109
105
|
isLoading: isLoading,
|
|
110
|
-
isMulti:
|
|
106
|
+
isMulti: multiple,
|
|
111
107
|
customStyle: customStyle,
|
|
112
108
|
isSearchable: isSearchable,
|
|
113
109
|
menuPortalTarget: menuPortalTarget,
|
|
114
|
-
name: name,
|
|
115
110
|
onBlur: event => {
|
|
116
|
-
|
|
111
|
+
field.onBlur();
|
|
117
112
|
onBlur?.(event);
|
|
118
113
|
},
|
|
119
114
|
onChange: (event, action) => {
|
|
120
|
-
|
|
115
|
+
field.onChange(parse(event));
|
|
121
116
|
onChange?.(event, action);
|
|
122
117
|
},
|
|
123
|
-
onFocus:
|
|
124
|
-
input.onFocus(event);
|
|
125
|
-
onFocus?.(event);
|
|
126
|
-
},
|
|
118
|
+
onFocus: onFocus,
|
|
127
119
|
options: options,
|
|
128
120
|
placeholder: placeholder,
|
|
129
121
|
readOnly: readOnly,
|
|
130
|
-
value: input.value,
|
|
131
122
|
noTopLabel: noTopLabel,
|
|
132
123
|
required: required,
|
|
124
|
+
value: format(field.value),
|
|
133
125
|
noOptionsMessage: noOptionsMessage,
|
|
134
126
|
"data-testid": dataTestId,
|
|
135
127
|
children: children
|
|
@@ -1,70 +1,62 @@
|
|
|
1
1
|
import { SelectableCard } from '@ultraviolet/ui';
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
2
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
|
-
import { useErrors } from '../../providers/ErrorContext/index.js';
|
|
4
|
-
import { useFormField } from '../../hooks/useFormField.js';
|
|
5
4
|
|
|
6
|
-
const SelectableCardField =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const {
|
|
26
|
-
getError
|
|
27
|
-
} = useErrors();
|
|
5
|
+
const SelectableCardField = ({
|
|
6
|
+
name,
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
showTick,
|
|
10
|
+
type,
|
|
11
|
+
disabled,
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
onFocus,
|
|
15
|
+
onBlur,
|
|
16
|
+
required,
|
|
17
|
+
tooltip,
|
|
18
|
+
id,
|
|
19
|
+
label,
|
|
20
|
+
rules,
|
|
21
|
+
shouldUnregister = false,
|
|
22
|
+
'data-testid': dataTestId
|
|
23
|
+
}) => {
|
|
28
24
|
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
type: type ?? 'radio',
|
|
35
|
-
validate,
|
|
36
|
-
value
|
|
37
|
-
});
|
|
38
|
-
const error = getError({
|
|
39
|
-
label: name,
|
|
40
|
-
meta: meta,
|
|
25
|
+
field,
|
|
26
|
+
fieldState: {
|
|
27
|
+
error
|
|
28
|
+
}
|
|
29
|
+
} = useController({
|
|
41
30
|
name,
|
|
42
|
-
|
|
31
|
+
shouldUnregister,
|
|
32
|
+
rules: {
|
|
33
|
+
required,
|
|
34
|
+
...rules
|
|
35
|
+
}
|
|
43
36
|
});
|
|
44
37
|
return jsx(SelectableCard, {
|
|
45
38
|
isError: !!error,
|
|
46
39
|
showTick: showTick,
|
|
47
|
-
checked:
|
|
40
|
+
checked: field.value === value,
|
|
48
41
|
className: className,
|
|
49
42
|
disabled: disabled,
|
|
50
|
-
name: input.name,
|
|
51
43
|
onChange: event => {
|
|
52
|
-
|
|
44
|
+
field.onChange(event);
|
|
53
45
|
onChange?.(event);
|
|
54
46
|
},
|
|
55
47
|
onBlur: event => {
|
|
56
|
-
|
|
48
|
+
field.onBlur();
|
|
57
49
|
onBlur?.(event);
|
|
58
50
|
},
|
|
59
51
|
onFocus: event => {
|
|
60
|
-
input.onFocus(event);
|
|
61
52
|
onFocus?.(event);
|
|
62
53
|
},
|
|
63
54
|
type: type,
|
|
64
|
-
value: input.value,
|
|
65
55
|
id: id,
|
|
66
56
|
tooltip: tooltip,
|
|
67
57
|
label: label,
|
|
58
|
+
value: value ?? '',
|
|
59
|
+
name: field.name,
|
|
68
60
|
"data-testid": dataTestId,
|
|
69
61
|
children: children
|
|
70
62
|
});
|
|
@@ -1,44 +1,31 @@
|
|
|
1
1
|
import { Button } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
3
|
-
import { useFormState } from 'react-final-form';
|
|
2
|
+
import { useFormState } from 'react-hook-form';
|
|
4
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
5
4
|
|
|
6
|
-
const Submit =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = _ref;
|
|
5
|
+
const Submit = ({
|
|
6
|
+
children,
|
|
7
|
+
className,
|
|
8
|
+
disabled = false,
|
|
9
|
+
icon,
|
|
10
|
+
iconPosition,
|
|
11
|
+
size,
|
|
12
|
+
variant = 'filled',
|
|
13
|
+
sentiment = 'primary',
|
|
14
|
+
tooltip,
|
|
15
|
+
fullWidth,
|
|
16
|
+
onClick
|
|
17
|
+
}) => {
|
|
20
18
|
const {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} = useFormState({
|
|
26
|
-
subscription: {
|
|
27
|
-
dirtySinceLastSubmit: true,
|
|
28
|
-
hasValidationErrors: true,
|
|
29
|
-
invalid: true,
|
|
30
|
-
submitting: true
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
34
|
-
const isDisabled = disabled || submitting || isLoading || invalid && hasValidationErrors && !dirtySinceLastSubmit;
|
|
35
|
-
useEffect(() => setIsLoading(false), []);
|
|
19
|
+
isSubmitting,
|
|
20
|
+
isValid
|
|
21
|
+
} = useFormState();
|
|
22
|
+
const isDisabled = disabled || isSubmitting || !isValid;
|
|
36
23
|
return jsx(Button, {
|
|
37
24
|
className: className,
|
|
38
25
|
disabled: isDisabled,
|
|
39
26
|
icon: icon,
|
|
40
27
|
iconPosition: iconPosition,
|
|
41
|
-
isLoading:
|
|
28
|
+
isLoading: isSubmitting,
|
|
42
29
|
size: size,
|
|
43
30
|
type: "submit",
|
|
44
31
|
variant: variant,
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { Alert } from '@ultraviolet/ui';
|
|
2
|
-
import {
|
|
2
|
+
import { useFormState } from 'react-hook-form';
|
|
3
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
4
4
|
|
|
5
|
-
const SubmitErrorAlert =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = _ref2;
|
|
17
|
-
return submitError ? jsx(Alert, {
|
|
18
|
-
className: className,
|
|
19
|
-
sentiment: "danger",
|
|
20
|
-
children: submitError
|
|
21
|
-
}) : null;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
5
|
+
const SubmitErrorAlert = ({
|
|
6
|
+
className
|
|
7
|
+
}) => {
|
|
8
|
+
const {
|
|
9
|
+
errors
|
|
10
|
+
} = useFormState();
|
|
11
|
+
return errors?.root?.['submit']?.message ? jsx(Alert, {
|
|
12
|
+
className: className,
|
|
13
|
+
sentiment: "danger",
|
|
14
|
+
children: errors.root['submit'].message
|
|
15
|
+
}) : null;
|
|
24
16
|
};
|
|
25
17
|
|
|
26
18
|
export { SubmitErrorAlert };
|
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
import { TagInput } from '@ultraviolet/ui';
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
2
3
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
3
|
-
import { useFormField } from '../../hooks/useFormField.js';
|
|
4
4
|
|
|
5
|
-
const TagInputField =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} = _ref;
|
|
5
|
+
const TagInputField = ({
|
|
6
|
+
className,
|
|
7
|
+
disabled,
|
|
8
|
+
id,
|
|
9
|
+
name,
|
|
10
|
+
onChange,
|
|
11
|
+
placeholder,
|
|
12
|
+
required,
|
|
13
|
+
rules,
|
|
14
|
+
variant,
|
|
15
|
+
shouldUnregister = false,
|
|
16
|
+
'data-testid': dataTestId
|
|
17
|
+
}) => {
|
|
19
18
|
const {
|
|
20
|
-
|
|
21
|
-
} =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
field
|
|
20
|
+
} = useController({
|
|
21
|
+
name,
|
|
22
|
+
rules: {
|
|
23
|
+
required,
|
|
24
|
+
shouldUnregister,
|
|
25
|
+
...rules
|
|
26
|
+
}
|
|
28
27
|
});
|
|
29
28
|
return jsx(TagInput, {
|
|
29
|
+
name: field.name,
|
|
30
30
|
className: className,
|
|
31
31
|
disabled: disabled,
|
|
32
32
|
id: id,
|
|
33
|
-
name: name,
|
|
34
33
|
onChange: event => {
|
|
34
|
+
field.onChange(event);
|
|
35
35
|
onChange?.(event);
|
|
36
|
-
input.onChange(event);
|
|
37
36
|
},
|
|
38
37
|
placeholder: placeholder,
|
|
39
38
|
variant: variant,
|
|
40
|
-
tags:
|
|
39
|
+
tags: field.value,
|
|
41
40
|
"data-testid": dataTestId
|
|
42
41
|
});
|
|
43
42
|
};
|