@ultraviolet/form 2.13.3 → 2.13.4
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 +15 -32
- package/dist/components/CheckboxGroupField/index.js +31 -48
- package/dist/components/DateField/index.js +27 -42
- package/dist/components/Form/index.js +25 -33
- package/dist/components/KeyValueField/index.js +14 -48
- package/dist/components/NumberInputField/index.js +17 -32
- package/dist/components/NumberInputFieldV2/index.js +17 -37
- package/dist/components/RadioField/index.js +15 -27
- package/dist/components/RadioGroupField/index.js +12 -22
- package/dist/components/SelectInputField/index.js +41 -78
- package/dist/components/SelectInputFieldV2/index.js +16 -50
- package/dist/components/SelectableCardField/index.js +20 -42
- package/dist/components/SelectableCardGroupField/index.js +20 -34
- package/dist/components/Submit/index.js +5 -19
- package/dist/components/SubmitErrorAlert/index.js +6 -2
- package/dist/components/TagInputField/index.js +12 -27
- package/dist/components/TextAreaField/index.js +22 -50
- package/dist/components/TextInputField/index.js +31 -71
- package/dist/components/TextInputFieldV2/index.js +22 -59
- package/dist/components/TimeField/index.js +17 -42
- package/dist/components/ToggleField/index.js +10 -24
- package/dist/hooks/useField.js +10 -3
- package/dist/hooks/useFieldArray.js +13 -3
- package/dist/hooks/useForm.js +6 -1
- package/dist/hooks/useFormState.js +3 -1
- package/dist/hooks/useOnFieldChange.js +5 -4
- package/dist/providers/ErrorContext/index.js +17 -20
- package/package.json +3 -3
|
@@ -21,10 +21,14 @@ const CheckboxField = ({
|
|
|
21
21
|
"data-testid": dataTestId,
|
|
22
22
|
shouldUnregister = false
|
|
23
23
|
}) => {
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
getError
|
|
26
|
+
} = useErrors();
|
|
25
27
|
const {
|
|
26
28
|
field,
|
|
27
|
-
fieldState: {
|
|
29
|
+
fieldState: {
|
|
30
|
+
error
|
|
31
|
+
}
|
|
28
32
|
} = useController({
|
|
29
33
|
name,
|
|
30
34
|
disabled,
|
|
@@ -34,36 +38,15 @@ const CheckboxField = ({
|
|
|
34
38
|
...rules
|
|
35
39
|
}
|
|
36
40
|
});
|
|
37
|
-
return /* @__PURE__ */ jsx(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
);
|
|
47
|
-
},
|
|
48
|
-
onBlur: (event) => {
|
|
49
|
-
field.onBlur();
|
|
50
|
-
onBlur?.(event);
|
|
51
|
-
},
|
|
52
|
-
onFocus,
|
|
53
|
-
size,
|
|
54
|
-
progress,
|
|
55
|
-
disabled: field.disabled,
|
|
56
|
-
checked: !!field.value,
|
|
57
|
-
error: getError({ label: label ?? "" }, error),
|
|
58
|
-
ref: field.ref,
|
|
59
|
-
className,
|
|
60
|
-
required,
|
|
61
|
-
"data-testid": dataTestId,
|
|
62
|
-
helper,
|
|
63
|
-
tooltip,
|
|
64
|
-
children
|
|
65
|
-
}
|
|
66
|
-
);
|
|
41
|
+
return /* @__PURE__ */ jsx(Checkbox, { id, name: field.name, onChange: (event) => {
|
|
42
|
+
field.onChange(event.target.checked);
|
|
43
|
+
onChange?.(event.target.checked);
|
|
44
|
+
}, onBlur: (event) => {
|
|
45
|
+
field.onBlur();
|
|
46
|
+
onBlur?.(event);
|
|
47
|
+
}, onFocus, size, progress, disabled: field.disabled, checked: !!field.value, error: getError({
|
|
48
|
+
label: label ?? ""
|
|
49
|
+
}, error), ref: field.ref, className, required, "data-testid": dataTestId, helper, tooltip, children });
|
|
67
50
|
};
|
|
68
51
|
export {
|
|
69
52
|
CheckboxField
|
|
@@ -23,31 +23,32 @@ const CheckboxGroupField = ({
|
|
|
23
23
|
shouldUnregister = false,
|
|
24
24
|
rules
|
|
25
25
|
}) => {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return null;
|
|
26
|
+
const {
|
|
27
|
+
getError
|
|
28
|
+
} = useErrors();
|
|
29
|
+
const validate = useCallback((value) => {
|
|
30
|
+
const requiredChildren = Children.map(children, (child) => {
|
|
31
|
+
if (isValidElement(child)) {
|
|
32
|
+
if (child.props.required) {
|
|
33
|
+
return child.props.name;
|
|
35
34
|
}
|
|
36
35
|
return null;
|
|
37
|
-
})?.filter(Boolean) ?? [];
|
|
38
|
-
if (!required && arraysContainSameValues(value, requiredChildren)) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
if (value.length >= Children.count(children)) {
|
|
42
|
-
return true;
|
|
43
36
|
}
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
return null;
|
|
38
|
+
})?.filter(Boolean) ?? [];
|
|
39
|
+
if (!required && arraysContainSameValues(value, requiredChildren)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (value.length >= Children.count(children)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}, [children, required]);
|
|
48
47
|
const {
|
|
49
48
|
field,
|
|
50
|
-
fieldState: {
|
|
49
|
+
fieldState: {
|
|
50
|
+
error
|
|
51
|
+
}
|
|
51
52
|
} = useController({
|
|
52
53
|
name,
|
|
53
54
|
shouldUnregister,
|
|
@@ -56,35 +57,17 @@ const CheckboxGroupField = ({
|
|
|
56
57
|
...rules
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
|
-
return /* @__PURE__ */ jsx(
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
value
|
|
65
|
-
onChange: (event) => {
|
|
66
|
-
const fieldValue = field.value;
|
|
67
|
-
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
68
|
-
field.onChange(
|
|
69
|
-
fieldValue?.filter(
|
|
70
|
-
(currentValue) => currentValue !== event.currentTarget.value
|
|
71
|
-
)
|
|
72
|
-
);
|
|
73
|
-
} else {
|
|
74
|
-
field.onChange([...field.value, event.currentTarget.value]);
|
|
75
|
-
}
|
|
76
|
-
onChange?.(
|
|
77
|
-
event.currentTarget.value
|
|
78
|
-
);
|
|
79
|
-
},
|
|
80
|
-
error: getError({ label }, error) ?? customError,
|
|
81
|
-
className,
|
|
82
|
-
direction,
|
|
83
|
-
helper,
|
|
84
|
-
required,
|
|
85
|
-
children
|
|
60
|
+
return /* @__PURE__ */ jsx(CheckboxGroup, { legend, name, value: field.value, onChange: (event) => {
|
|
61
|
+
const fieldValue = field.value;
|
|
62
|
+
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
63
|
+
field.onChange(fieldValue?.filter((currentValue) => currentValue !== event.currentTarget.value));
|
|
64
|
+
} else {
|
|
65
|
+
field.onChange([...field.value, event.currentTarget.value]);
|
|
86
66
|
}
|
|
87
|
-
|
|
67
|
+
onChange?.(event.currentTarget.value);
|
|
68
|
+
}, error: getError({
|
|
69
|
+
label
|
|
70
|
+
}, error) ?? customError, className, direction, helper, required, children });
|
|
88
71
|
};
|
|
89
72
|
CheckboxGroupField.Checkbox = CheckboxGroup.Checkbox;
|
|
90
73
|
export {
|
|
@@ -25,10 +25,14 @@ const DateField = ({
|
|
|
25
25
|
"data-testid": dataTestId,
|
|
26
26
|
shouldUnregister = false
|
|
27
27
|
}) => {
|
|
28
|
-
const {
|
|
28
|
+
const {
|
|
29
|
+
getError
|
|
30
|
+
} = useErrors();
|
|
29
31
|
const {
|
|
30
32
|
field,
|
|
31
|
-
fieldState: {
|
|
33
|
+
fieldState: {
|
|
34
|
+
error
|
|
35
|
+
}
|
|
32
36
|
} = useController({
|
|
33
37
|
name,
|
|
34
38
|
shouldUnregister,
|
|
@@ -42,47 +46,28 @@ const DateField = ({
|
|
|
42
46
|
required
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
|
-
return /* @__PURE__ */ jsx(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (isEmpty(field.value)) {
|
|
59
|
-
field.onChange(newDate);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const currentDate = parseDate(field.value);
|
|
63
|
-
newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
|
|
64
|
-
field.onChange(newDate);
|
|
65
|
-
} else if (Array.isArray(val)) {
|
|
66
|
-
field.onChange(val);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
onBlur: (e) => {
|
|
70
|
-
field.onBlur();
|
|
71
|
-
onBlur?.(e);
|
|
72
|
-
},
|
|
73
|
-
onFocus,
|
|
74
|
-
maxDate,
|
|
75
|
-
minDate,
|
|
76
|
-
error: getError({ minDate, maxDate, label }, error),
|
|
77
|
-
disabled,
|
|
78
|
-
autoFocus,
|
|
79
|
-
excludeDates,
|
|
80
|
-
selectsRange,
|
|
81
|
-
"data-testid": dataTestId,
|
|
82
|
-
startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0,
|
|
83
|
-
endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0
|
|
49
|
+
return /* @__PURE__ */ jsx(DateInput, { name: field.name, label, value: field.value, format: format || ((value) => value ? parseDate(value).toLocaleDateString() : ""), locale, required, onChange: (val) => {
|
|
50
|
+
if (val && val instanceof Date) {
|
|
51
|
+
onChange?.(val);
|
|
52
|
+
const newDate = parseDate(val);
|
|
53
|
+
if (isEmpty(field.value)) {
|
|
54
|
+
field.onChange(newDate);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const currentDate = parseDate(field.value);
|
|
58
|
+
newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
|
|
59
|
+
field.onChange(newDate);
|
|
60
|
+
} else if (Array.isArray(val)) {
|
|
61
|
+
field.onChange(val);
|
|
84
62
|
}
|
|
85
|
-
)
|
|
63
|
+
}, onBlur: (e) => {
|
|
64
|
+
field.onBlur();
|
|
65
|
+
onBlur?.(e);
|
|
66
|
+
}, onFocus, maxDate, minDate, error: getError({
|
|
67
|
+
minDate,
|
|
68
|
+
maxDate,
|
|
69
|
+
label
|
|
70
|
+
}, error), disabled, autoFocus, excludeDates, selectsRange, "data-testid": dataTestId, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0 });
|
|
86
71
|
};
|
|
87
72
|
export {
|
|
88
73
|
DateField
|
|
@@ -4,9 +4,7 @@ import { useForm, FormProvider } from "react-hook-form";
|
|
|
4
4
|
import { FORM_ERROR } from "../../constants.js";
|
|
5
5
|
import { defaultErrors } from "./defaultErrors.js";
|
|
6
6
|
import { ErrorProvider } from "../../providers/ErrorContext/index.js";
|
|
7
|
-
const FormSubmitContext = React.createContext(
|
|
8
|
-
{}
|
|
9
|
-
);
|
|
7
|
+
const FormSubmitContext = React.createContext({});
|
|
10
8
|
const Form = ({
|
|
11
9
|
children,
|
|
12
10
|
methods: methodsProp,
|
|
@@ -40,37 +38,31 @@ const Form = ({
|
|
|
40
38
|
});
|
|
41
39
|
}
|
|
42
40
|
});
|
|
43
|
-
const formSubmitContextValue = useMemo(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
form: {
|
|
67
|
-
change: methods.setValue,
|
|
68
|
-
reset: methods.reset,
|
|
69
|
-
submit: handleSubmit
|
|
70
|
-
}
|
|
71
|
-
}) : children
|
|
41
|
+
const formSubmitContextValue = useMemo(() => ({
|
|
42
|
+
handleSubmit
|
|
43
|
+
}), [handleSubmit]);
|
|
44
|
+
return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(FormSubmitContext.Provider, { value: formSubmitContextValue, children: /* @__PURE__ */ jsx(ErrorProvider, { errors: {
|
|
45
|
+
...defaultErrors,
|
|
46
|
+
...errors
|
|
47
|
+
}, children: /* @__PURE__ */ jsx("form", { onSubmit: async (e) => {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
await handleSubmit(e);
|
|
51
|
+
}, name, noValidate: true, children: typeof children === "function" ? children({
|
|
52
|
+
values: methods.watch(),
|
|
53
|
+
hasValidationErrors: !methods.formState.isValid,
|
|
54
|
+
errors: methods.formState.errors,
|
|
55
|
+
submitting: methods.formState.isSubmitting,
|
|
56
|
+
pristine: !methods.formState.isDirty,
|
|
57
|
+
handleSubmit,
|
|
58
|
+
submitError: !!methods.formState.errors?.root?.["submit"],
|
|
59
|
+
valid: methods.formState.isValid,
|
|
60
|
+
form: {
|
|
61
|
+
change: methods.setValue,
|
|
62
|
+
reset: methods.reset,
|
|
63
|
+
submit: handleSubmit
|
|
72
64
|
}
|
|
73
|
-
) }) }) });
|
|
65
|
+
}) : children }) }) }) });
|
|
74
66
|
};
|
|
75
67
|
export {
|
|
76
68
|
Form,
|
|
@@ -11,59 +11,22 @@ const KeyValueField = ({
|
|
|
11
11
|
readonly = false,
|
|
12
12
|
control
|
|
13
13
|
}) => {
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
fields,
|
|
16
|
+
append,
|
|
17
|
+
remove
|
|
18
|
+
} = useFieldArray({
|
|
15
19
|
name,
|
|
16
20
|
control
|
|
17
21
|
});
|
|
18
22
|
const canAdd = fields.length !== void 0 && fields.length < maxSize;
|
|
19
23
|
const maxSizeReachedTooltip = addButton.maxSizeReachedTooltip ?? `Cannot add more than ${maxSize} elements`;
|
|
20
24
|
return /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
|
|
21
|
-
fields.length ? /* @__PURE__ */ jsx(Stack, { gap: 3, children: fields.map((field, index) => /* @__PURE__ */ jsxs(
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
alignItems: "end",
|
|
27
|
-
children: [
|
|
28
|
-
/* @__PURE__ */ jsx(
|
|
29
|
-
TextInputField,
|
|
30
|
-
{
|
|
31
|
-
readOnly: readonly,
|
|
32
|
-
required: inputKey.required,
|
|
33
|
-
name: `${name}.${index}.key`,
|
|
34
|
-
label: inputKey.label,
|
|
35
|
-
regex: inputKey.regex
|
|
36
|
-
}
|
|
37
|
-
),
|
|
38
|
-
/* @__PURE__ */ jsx(
|
|
39
|
-
TextInputField,
|
|
40
|
-
{
|
|
41
|
-
readOnly: readonly,
|
|
42
|
-
required: inputValue.required,
|
|
43
|
-
name: `${name}.${index}.value`,
|
|
44
|
-
label: inputValue.label,
|
|
45
|
-
placeholder: inputValue.placeholder,
|
|
46
|
-
type: inputValue.type,
|
|
47
|
-
autoComplete: "off",
|
|
48
|
-
regex: inputValue.regex
|
|
49
|
-
}
|
|
50
|
-
),
|
|
51
|
-
/* @__PURE__ */ jsx(
|
|
52
|
-
Button,
|
|
53
|
-
{
|
|
54
|
-
disabled: readonly,
|
|
55
|
-
"data-testid": `remove-button-${index}`,
|
|
56
|
-
icon: "delete",
|
|
57
|
-
variant: "outlined",
|
|
58
|
-
sentiment: "danger",
|
|
59
|
-
size: "large",
|
|
60
|
-
onClick: () => remove(index)
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
field.id
|
|
66
|
-
)) }) : null,
|
|
25
|
+
fields.length ? /* @__PURE__ */ jsx(Stack, { gap: 3, children: fields.map((field, index) => /* @__PURE__ */ jsxs(Row, { templateColumns: "1fr 1fr auto", gap: 2, alignItems: "end", children: [
|
|
26
|
+
/* @__PURE__ */ jsx(TextInputField, { readOnly: readonly, required: inputKey.required, name: `${name}.${index}.key`, label: inputKey.label, regex: inputKey.regex }),
|
|
27
|
+
/* @__PURE__ */ jsx(TextInputField, { readOnly: readonly, required: inputValue.required, name: `${name}.${index}.value`, label: inputValue.label, placeholder: inputValue.placeholder, type: inputValue.type, autoComplete: "off", regex: inputValue.regex }),
|
|
28
|
+
/* @__PURE__ */ jsx(Button, { disabled: readonly, "data-testid": `remove-button-${index}`, icon: "delete", variant: "outlined", sentiment: "danger", size: "large", onClick: () => remove(index) })
|
|
29
|
+
] }, field.id)) }) : null,
|
|
67
30
|
/* @__PURE__ */ jsx(Stack, { direction: "row", justifyContent: "flex-start", children: /* @__PURE__ */ jsx(
|
|
68
31
|
Button,
|
|
69
32
|
{
|
|
@@ -74,7 +37,10 @@ const KeyValueField = ({
|
|
|
74
37
|
fullWidth: addButton.fullWidth,
|
|
75
38
|
disabled: !canAdd || readonly,
|
|
76
39
|
tooltip: !canAdd ? maxSizeReachedTooltip : addButton.tooltip,
|
|
77
|
-
onClick: () => append({
|
|
40
|
+
onClick: () => append({
|
|
41
|
+
key: "",
|
|
42
|
+
value: ""
|
|
43
|
+
}),
|
|
78
44
|
children: addButton.name
|
|
79
45
|
}
|
|
80
46
|
) })
|
|
@@ -21,10 +21,14 @@ const NumberInputField = ({
|
|
|
21
21
|
label,
|
|
22
22
|
shouldUnregister = false
|
|
23
23
|
}) => {
|
|
24
|
-
const {
|
|
24
|
+
const {
|
|
25
|
+
getError
|
|
26
|
+
} = useErrors();
|
|
25
27
|
const {
|
|
26
28
|
field,
|
|
27
|
-
fieldState: {
|
|
29
|
+
fieldState: {
|
|
30
|
+
error
|
|
31
|
+
}
|
|
28
32
|
} = useController({
|
|
29
33
|
name,
|
|
30
34
|
shouldUnregister,
|
|
@@ -35,36 +39,17 @@ const NumberInputField = ({
|
|
|
35
39
|
...rules
|
|
36
40
|
}
|
|
37
41
|
});
|
|
38
|
-
return /* @__PURE__ */ jsx(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
field.onChange(event ?? null);
|
|
50
|
-
onChange?.(event);
|
|
51
|
-
},
|
|
52
|
-
onFocus,
|
|
53
|
-
maxValue,
|
|
54
|
-
minValue,
|
|
55
|
-
onMinCrossed,
|
|
56
|
-
onMaxCrossed,
|
|
57
|
-
size,
|
|
58
|
-
step,
|
|
59
|
-
text,
|
|
60
|
-
className,
|
|
61
|
-
label,
|
|
62
|
-
error: getError(
|
|
63
|
-
{ label: label ?? "", max: maxValue, min: minValue },
|
|
64
|
-
error
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
);
|
|
42
|
+
return /* @__PURE__ */ jsx(NumberInput, { name: field.name, value: field.value, disabled, onBlur: (event) => {
|
|
43
|
+
field.onBlur();
|
|
44
|
+
onBlur?.(event);
|
|
45
|
+
}, onChange: (event) => {
|
|
46
|
+
field.onChange(event ?? null);
|
|
47
|
+
onChange?.(event);
|
|
48
|
+
}, onFocus, maxValue, minValue, onMinCrossed, onMaxCrossed, size, step, text, className, label, error: getError({
|
|
49
|
+
label: label ?? "",
|
|
50
|
+
max: maxValue,
|
|
51
|
+
min: minValue
|
|
52
|
+
}, error) });
|
|
68
53
|
};
|
|
69
54
|
export {
|
|
70
55
|
NumberInputField
|
|
@@ -28,10 +28,14 @@ const NumberInputFieldV2 = ({
|
|
|
28
28
|
readOnly,
|
|
29
29
|
shouldUnregister = false
|
|
30
30
|
}) => {
|
|
31
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
getError
|
|
33
|
+
} = useErrors();
|
|
32
34
|
const {
|
|
33
35
|
field,
|
|
34
|
-
fieldState: {
|
|
36
|
+
fieldState: {
|
|
37
|
+
error
|
|
38
|
+
}
|
|
35
39
|
} = useController({
|
|
36
40
|
name,
|
|
37
41
|
shouldUnregister,
|
|
@@ -42,41 +46,17 @@ const NumberInputFieldV2 = ({
|
|
|
42
46
|
...rules
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
|
-
return /* @__PURE__ */ jsx(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
field.onChange(newValue);
|
|
57
|
-
onChange?.(newValue);
|
|
58
|
-
},
|
|
59
|
-
max,
|
|
60
|
-
min,
|
|
61
|
-
size,
|
|
62
|
-
step,
|
|
63
|
-
className,
|
|
64
|
-
"data-testid": dataTestId,
|
|
65
|
-
id,
|
|
66
|
-
label,
|
|
67
|
-
labelDescription,
|
|
68
|
-
placeholder,
|
|
69
|
-
error: getError({ label: label ?? "", max, min }, error),
|
|
70
|
-
success,
|
|
71
|
-
helper,
|
|
72
|
-
tooltip,
|
|
73
|
-
unit,
|
|
74
|
-
"aria-label": ariaLabel,
|
|
75
|
-
autoFocus,
|
|
76
|
-
readOnly,
|
|
77
|
-
required
|
|
78
|
-
}
|
|
79
|
-
);
|
|
49
|
+
return /* @__PURE__ */ jsx(NumberInputV2, { name: field.name, value: field.value, disabled, onBlur: (event) => {
|
|
50
|
+
field.onBlur();
|
|
51
|
+
onBlur?.(event);
|
|
52
|
+
}, onChange: (newValue) => {
|
|
53
|
+
field.onChange(newValue);
|
|
54
|
+
onChange?.(newValue);
|
|
55
|
+
}, max, min, size, step, className, "data-testid": dataTestId, id, label, labelDescription, placeholder, error: getError({
|
|
56
|
+
label: label ?? "",
|
|
57
|
+
max,
|
|
58
|
+
min
|
|
59
|
+
}, error), success, helper, tooltip, unit, "aria-label": ariaLabel, autoFocus, readOnly, required });
|
|
80
60
|
};
|
|
81
61
|
export {
|
|
82
62
|
NumberInputFieldV2
|
|
@@ -18,10 +18,14 @@ const RadioField = ({
|
|
|
18
18
|
tooltip,
|
|
19
19
|
shouldUnregister = false
|
|
20
20
|
}) => {
|
|
21
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
getError
|
|
23
|
+
} = useErrors();
|
|
22
24
|
const {
|
|
23
25
|
field,
|
|
24
|
-
fieldState: {
|
|
26
|
+
fieldState: {
|
|
27
|
+
error
|
|
28
|
+
}
|
|
25
29
|
} = useController({
|
|
26
30
|
name,
|
|
27
31
|
shouldUnregister,
|
|
@@ -30,31 +34,15 @@ const RadioField = ({
|
|
|
30
34
|
...rules
|
|
31
35
|
}
|
|
32
36
|
});
|
|
33
|
-
return /* @__PURE__ */ jsx(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
id,
|
|
43
|
-
onChange: () => {
|
|
44
|
-
field.onChange(value);
|
|
45
|
-
onChange?.(value);
|
|
46
|
-
},
|
|
47
|
-
onBlur: (event) => {
|
|
48
|
-
field.onBlur();
|
|
49
|
-
onBlur?.(event);
|
|
50
|
-
},
|
|
51
|
-
onFocus,
|
|
52
|
-
required,
|
|
53
|
-
value: value ?? "",
|
|
54
|
-
label,
|
|
55
|
-
tooltip
|
|
56
|
-
}
|
|
57
|
-
);
|
|
37
|
+
return /* @__PURE__ */ jsx(Radio, { name: field.name, checked: field.value === value, className, "data-testid": dataTestId, disabled, error: getError({
|
|
38
|
+
label: typeof label === "string" ? label : ""
|
|
39
|
+
}, error), id, onChange: () => {
|
|
40
|
+
field.onChange(value);
|
|
41
|
+
onChange?.(value);
|
|
42
|
+
}, onBlur: (event) => {
|
|
43
|
+
field.onBlur();
|
|
44
|
+
onBlur?.(event);
|
|
45
|
+
}, onFocus, required, value: value ?? "", label, tooltip });
|
|
58
46
|
};
|
|
59
47
|
export {
|
|
60
48
|
RadioField
|
|
@@ -16,10 +16,14 @@ const RadioGroupField = ({
|
|
|
16
16
|
direction,
|
|
17
17
|
shouldUnregister = false
|
|
18
18
|
}) => {
|
|
19
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
getError
|
|
21
|
+
} = useErrors();
|
|
20
22
|
const {
|
|
21
23
|
field,
|
|
22
|
-
fieldState: {
|
|
24
|
+
fieldState: {
|
|
25
|
+
error
|
|
26
|
+
}
|
|
23
27
|
} = useController({
|
|
24
28
|
name,
|
|
25
29
|
shouldUnregister,
|
|
@@ -28,26 +32,12 @@ const RadioGroupField = ({
|
|
|
28
32
|
...rules
|
|
29
33
|
}
|
|
30
34
|
});
|
|
31
|
-
return /* @__PURE__ */ jsx(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
field.onChange(event);
|
|
38
|
-
onChange?.(
|
|
39
|
-
event.target.value
|
|
40
|
-
);
|
|
41
|
-
},
|
|
42
|
-
required,
|
|
43
|
-
value: field.value,
|
|
44
|
-
legend,
|
|
45
|
-
error: getError({ label }, error) ?? customError,
|
|
46
|
-
helper,
|
|
47
|
-
direction,
|
|
48
|
-
children
|
|
49
|
-
}
|
|
50
|
-
);
|
|
35
|
+
return /* @__PURE__ */ jsx(RadioGroup, { className, name: field.name, onChange: (event) => {
|
|
36
|
+
field.onChange(event);
|
|
37
|
+
onChange?.(event.target.value);
|
|
38
|
+
}, required, value: field.value, legend, error: getError({
|
|
39
|
+
label
|
|
40
|
+
}, error) ?? customError, helper, direction, children });
|
|
51
41
|
};
|
|
52
42
|
RadioGroupField.Radio = RadioGroup.Radio;
|
|
53
43
|
export {
|