@ultraviolet/form 4.0.0-beta.6 → 4.0.0-beta.7
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/DateField/index.cjs +7 -17
- package/dist/components/DateField/index.d.ts +3 -13
- package/dist/components/DateField/index.js +7 -17
- package/dist/components/NumberInputFieldV2/index.cjs +5 -18
- package/dist/components/NumberInputFieldV2/index.d.ts +2 -4
- package/dist/components/NumberInputFieldV2/index.js +5 -18
- package/dist/components/SelectableCardField/index.cjs +5 -11
- package/dist/components/SelectableCardField/index.d.ts +3 -11
- package/dist/components/SelectableCardField/index.js +5 -11
- package/dist/components/SelectableCardGroupField/index.cjs +4 -8
- package/dist/components/SelectableCardGroupField/index.d.ts +2 -2
- package/dist/components/SelectableCardGroupField/index.js +4 -8
- package/dist/components/TagInputField/index.cjs +5 -16
- package/dist/components/TagInputField/index.d.ts +2 -2
- package/dist/components/TagInputField/index.js +5 -16
- package/dist/components/TextAreaField/index.cjs +5 -19
- package/dist/components/TextAreaField/index.d.ts +1 -1
- package/dist/components/TextAreaField/index.js +5 -19
- package/dist/components/TextInputFieldV2/index.cjs +4 -32
- package/dist/components/TextInputFieldV2/index.d.ts +1 -1
- package/dist/components/TextInputFieldV2/index.js +4 -32
- package/dist/components/TimeInputFieldV2/index.cjs +4 -18
- package/dist/components/TimeInputFieldV2/index.d.ts +1 -1
- package/dist/components/TimeInputFieldV2/index.js +4 -18
- package/dist/components/ToggleField/index.cjs +4 -9
- package/dist/components/ToggleField/index.d.ts +5 -5
- package/dist/components/ToggleField/index.js +4 -9
- package/dist/components/ToggleGroupField/index.d.ts +2 -2
- package/dist/components/UnitInputField/index.cjs +5 -15
- package/dist/components/UnitInputField/index.d.ts +2 -4
- package/dist/components/UnitInputField/index.js +5 -15
- package/dist/components/VerificationCodeField/index.cjs +5 -14
- package/dist/components/VerificationCodeField/index.d.ts +2 -7
- package/dist/components/VerificationCodeField/index.js +5 -14
- package/package.json +5 -5
|
@@ -15,25 +15,15 @@ const DateField = ({
|
|
|
15
15
|
control,
|
|
16
16
|
label = "",
|
|
17
17
|
format,
|
|
18
|
-
locale,
|
|
19
|
-
maxDate: maxDate$1,
|
|
20
18
|
minDate: minDate$1,
|
|
21
|
-
|
|
19
|
+
maxDate: maxDate$1,
|
|
22
20
|
onChange,
|
|
23
21
|
onBlur,
|
|
24
|
-
onFocus,
|
|
25
22
|
validate,
|
|
26
|
-
autoFocus = false,
|
|
27
|
-
excludeDates,
|
|
28
23
|
selectsRange,
|
|
29
|
-
size,
|
|
30
|
-
placeholder,
|
|
31
|
-
tooltip,
|
|
32
|
-
clearable,
|
|
33
|
-
"data-testid": dataTestId,
|
|
34
|
-
shouldUnregister = false,
|
|
35
24
|
showMonthYearPicker,
|
|
36
|
-
|
|
25
|
+
shouldUnregister = false,
|
|
26
|
+
...props
|
|
37
27
|
}) => {
|
|
38
28
|
const {
|
|
39
29
|
getError
|
|
@@ -56,14 +46,14 @@ const DateField = ({
|
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
48
|
});
|
|
59
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { name: field.name, label,
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { ...props, name: field.name, label, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
|
|
60
50
|
if (!value) return "";
|
|
61
51
|
const date = parseDate(value);
|
|
62
52
|
return showMonthYearPicker ? date.toLocaleDateString(void 0, {
|
|
63
53
|
year: "numeric",
|
|
64
54
|
month: "numeric"
|
|
65
55
|
}) : date.toLocaleDateString();
|
|
66
|
-
}),
|
|
56
|
+
}), required, onChange: (val) => {
|
|
67
57
|
if (val && val instanceof Date) {
|
|
68
58
|
onChange?.(val);
|
|
69
59
|
const newDate = parseDate(val);
|
|
@@ -84,10 +74,10 @@ const DateField = ({
|
|
|
84
74
|
}, onBlur: (e) => {
|
|
85
75
|
field.onBlur();
|
|
86
76
|
onBlur?.(e);
|
|
87
|
-
},
|
|
77
|
+
}, maxDate: maxDate$1, minDate: minDate$1, error: getError({
|
|
88
78
|
minDate: minDate$1,
|
|
89
79
|
maxDate: maxDate$1,
|
|
90
80
|
label
|
|
91
|
-
}, error),
|
|
81
|
+
}, error), selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0 });
|
|
92
82
|
};
|
|
93
83
|
exports.DateField = DateField;
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { DateInput } from '@ultraviolet/ui';
|
|
2
|
-
import type { ComponentProps
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
4
|
import type { BaseFieldProps } from '../../types';
|
|
5
|
-
type DateFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof DateInput>, '
|
|
6
|
-
|
|
7
|
-
minDate?: Date;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
required?: boolean;
|
|
10
|
-
locale?: string;
|
|
11
|
-
onBlur?: (event: FocusEvent<HTMLElement>) => void;
|
|
12
|
-
onFocus?: (value: FocusEvent<HTMLElement>) => void;
|
|
13
|
-
autoFocus?: boolean;
|
|
14
|
-
placeholder?: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const DateField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, label, format, locale, maxDate, minDate, disabled, onChange, onBlur, onFocus, validate, autoFocus, excludeDates, selectsRange, size, placeholder, tooltip, clearable, "data-testid": dataTestId, shouldUnregister, showMonthYearPicker, input, }: DateFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
5
|
+
type DateFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof DateInput>, 'required' | 'name' | 'onChange'>;
|
|
6
|
+
export declare const DateField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, label, format, minDate, maxDate, onChange, onBlur, validate, selectsRange, showMonthYearPicker, shouldUnregister, ...props }: DateFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
7
|
export {};
|
|
@@ -13,25 +13,15 @@ const DateField = ({
|
|
|
13
13
|
control,
|
|
14
14
|
label = "",
|
|
15
15
|
format,
|
|
16
|
-
locale,
|
|
17
|
-
maxDate,
|
|
18
16
|
minDate,
|
|
19
|
-
|
|
17
|
+
maxDate,
|
|
20
18
|
onChange,
|
|
21
19
|
onBlur,
|
|
22
|
-
onFocus,
|
|
23
20
|
validate,
|
|
24
|
-
autoFocus = false,
|
|
25
|
-
excludeDates,
|
|
26
21
|
selectsRange,
|
|
27
|
-
size,
|
|
28
|
-
placeholder,
|
|
29
|
-
tooltip,
|
|
30
|
-
clearable,
|
|
31
|
-
"data-testid": dataTestId,
|
|
32
|
-
shouldUnregister = false,
|
|
33
22
|
showMonthYearPicker,
|
|
34
|
-
|
|
23
|
+
shouldUnregister = false,
|
|
24
|
+
...props
|
|
35
25
|
}) => {
|
|
36
26
|
const {
|
|
37
27
|
getError
|
|
@@ -54,14 +44,14 @@ const DateField = ({
|
|
|
54
44
|
}
|
|
55
45
|
}
|
|
56
46
|
});
|
|
57
|
-
return /* @__PURE__ */ jsx(DateInput, { name: field.name, label,
|
|
47
|
+
return /* @__PURE__ */ jsx(DateInput, { ...props, name: field.name, label, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
|
|
58
48
|
if (!value) return "";
|
|
59
49
|
const date = parseDate(value);
|
|
60
50
|
return showMonthYearPicker ? date.toLocaleDateString(void 0, {
|
|
61
51
|
year: "numeric",
|
|
62
52
|
month: "numeric"
|
|
63
53
|
}) : date.toLocaleDateString();
|
|
64
|
-
}),
|
|
54
|
+
}), required, onChange: (val) => {
|
|
65
55
|
if (val && val instanceof Date) {
|
|
66
56
|
onChange?.(val);
|
|
67
57
|
const newDate = parseDate(val);
|
|
@@ -82,11 +72,11 @@ const DateField = ({
|
|
|
82
72
|
}, onBlur: (e) => {
|
|
83
73
|
field.onBlur();
|
|
84
74
|
onBlur?.(e);
|
|
85
|
-
},
|
|
75
|
+
}, maxDate, minDate, error: getError({
|
|
86
76
|
minDate,
|
|
87
77
|
maxDate,
|
|
88
78
|
label
|
|
89
|
-
}, error),
|
|
79
|
+
}, error), selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0 });
|
|
90
80
|
};
|
|
91
81
|
export {
|
|
92
82
|
DateField
|
|
@@ -7,32 +7,19 @@ const reactHookForm = require("react-hook-form");
|
|
|
7
7
|
const isInteger = require("../../validators/isInteger.cjs");
|
|
8
8
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
9
|
const NumberInputFieldV2 = ({
|
|
10
|
-
disabled,
|
|
11
10
|
control,
|
|
12
11
|
max = Number.MAX_SAFE_INTEGER,
|
|
13
12
|
min = 0,
|
|
14
13
|
name,
|
|
15
14
|
onChange,
|
|
16
15
|
onBlur,
|
|
17
|
-
size,
|
|
18
16
|
step,
|
|
19
|
-
unit,
|
|
20
|
-
tooltip,
|
|
21
|
-
className,
|
|
22
17
|
label,
|
|
23
|
-
labelDescription,
|
|
24
|
-
id,
|
|
25
|
-
placeholder,
|
|
26
|
-
success,
|
|
27
|
-
helper,
|
|
28
|
-
controls = true,
|
|
29
18
|
"aria-label": ariaLabel,
|
|
30
|
-
"data-testid": dataTestId,
|
|
31
19
|
required,
|
|
32
|
-
autoFocus,
|
|
33
|
-
readOnly,
|
|
34
20
|
shouldUnregister = false,
|
|
35
|
-
validate
|
|
21
|
+
validate,
|
|
22
|
+
...props
|
|
36
23
|
}) => {
|
|
37
24
|
const {
|
|
38
25
|
getError
|
|
@@ -56,17 +43,17 @@ const NumberInputFieldV2 = ({
|
|
|
56
43
|
}
|
|
57
44
|
}
|
|
58
45
|
});
|
|
59
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInputV2, { name: field.name, value: field.value,
|
|
46
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInputV2, { ...props, name: field.name, value: field.value, onBlur: (event) => {
|
|
60
47
|
field.onBlur();
|
|
61
48
|
onBlur?.(event);
|
|
62
49
|
}, onChange: (newValue) => {
|
|
63
50
|
field.onChange(newValue);
|
|
64
51
|
onChange?.(newValue);
|
|
65
|
-
}, max, min,
|
|
52
|
+
}, max, min, step, label, error: getError({
|
|
66
53
|
label: label ?? ariaLabel ?? name,
|
|
67
54
|
max,
|
|
68
55
|
min,
|
|
69
56
|
isInteger: step
|
|
70
|
-
}, error),
|
|
57
|
+
}, error), "aria-label": ariaLabel, required });
|
|
71
58
|
};
|
|
72
59
|
exports.NumberInputFieldV2 = NumberInputFieldV2;
|
|
@@ -2,8 +2,6 @@ import { NumberInputV2 } from '@ultraviolet/ui';
|
|
|
2
2
|
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
4
|
import type { BaseFieldProps } from '../../types';
|
|
5
|
-
type NumberInputV2Props<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> &
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export declare const NumberInputFieldV2: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ disabled, control, max, min, name, onChange, onBlur, size, step, unit, tooltip, className, label, labelDescription, id, placeholder, success, helper, controls, "aria-label": ariaLabel, "data-testid": dataTestId, required, autoFocus, readOnly, shouldUnregister, validate, }: NumberInputV2Props<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
5
|
+
type NumberInputV2Props<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof NumberInputV2>, 'onChange'>;
|
|
6
|
+
export declare const NumberInputFieldV2: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, max, min, name, onChange, onBlur, step, label, "aria-label": ariaLabel, required, shouldUnregister, validate, ...props }: NumberInputV2Props<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
7
|
export {};
|
|
@@ -5,32 +5,19 @@ import { useController } from "react-hook-form";
|
|
|
5
5
|
import { isInteger } from "../../validators/isInteger.js";
|
|
6
6
|
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
7
7
|
const NumberInputFieldV2 = ({
|
|
8
|
-
disabled,
|
|
9
8
|
control,
|
|
10
9
|
max = Number.MAX_SAFE_INTEGER,
|
|
11
10
|
min = 0,
|
|
12
11
|
name,
|
|
13
12
|
onChange,
|
|
14
13
|
onBlur,
|
|
15
|
-
size,
|
|
16
14
|
step,
|
|
17
|
-
unit,
|
|
18
|
-
tooltip,
|
|
19
|
-
className,
|
|
20
15
|
label,
|
|
21
|
-
labelDescription,
|
|
22
|
-
id,
|
|
23
|
-
placeholder,
|
|
24
|
-
success,
|
|
25
|
-
helper,
|
|
26
|
-
controls = true,
|
|
27
16
|
"aria-label": ariaLabel,
|
|
28
|
-
"data-testid": dataTestId,
|
|
29
17
|
required,
|
|
30
|
-
autoFocus,
|
|
31
|
-
readOnly,
|
|
32
18
|
shouldUnregister = false,
|
|
33
|
-
validate
|
|
19
|
+
validate,
|
|
20
|
+
...props
|
|
34
21
|
}) => {
|
|
35
22
|
const {
|
|
36
23
|
getError
|
|
@@ -54,18 +41,18 @@ const NumberInputFieldV2 = ({
|
|
|
54
41
|
}
|
|
55
42
|
}
|
|
56
43
|
});
|
|
57
|
-
return /* @__PURE__ */ jsx(NumberInputV2, { name: field.name, value: field.value,
|
|
44
|
+
return /* @__PURE__ */ jsx(NumberInputV2, { ...props, name: field.name, value: field.value, onBlur: (event) => {
|
|
58
45
|
field.onBlur();
|
|
59
46
|
onBlur?.(event);
|
|
60
47
|
}, onChange: (newValue) => {
|
|
61
48
|
field.onChange(newValue);
|
|
62
49
|
onChange?.(newValue);
|
|
63
|
-
}, max, min,
|
|
50
|
+
}, max, min, step, label, error: getError({
|
|
64
51
|
label: label ?? ariaLabel ?? name,
|
|
65
52
|
max,
|
|
66
53
|
min,
|
|
67
54
|
isInteger: step
|
|
68
|
-
}, error),
|
|
55
|
+
}, error), "aria-label": ariaLabel, required });
|
|
69
56
|
};
|
|
70
57
|
export {
|
|
71
58
|
NumberInputFieldV2
|
|
@@ -9,23 +9,17 @@ const SelectableCardField = ({
|
|
|
9
9
|
control,
|
|
10
10
|
value,
|
|
11
11
|
onChange,
|
|
12
|
-
showTick,
|
|
13
12
|
type,
|
|
14
|
-
disabled,
|
|
15
|
-
children,
|
|
16
|
-
className,
|
|
17
13
|
onFocus,
|
|
18
14
|
onBlur,
|
|
19
15
|
required,
|
|
20
|
-
tooltip,
|
|
21
|
-
id,
|
|
22
16
|
label,
|
|
23
17
|
shouldUnregister = false,
|
|
24
18
|
validate,
|
|
25
19
|
productIcon,
|
|
26
20
|
illustration,
|
|
27
|
-
"
|
|
28
|
-
|
|
21
|
+
"aria-label": ariaLabel,
|
|
22
|
+
...props
|
|
29
23
|
}) => {
|
|
30
24
|
const {
|
|
31
25
|
field,
|
|
@@ -42,7 +36,7 @@ const SelectableCardField = ({
|
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
38
|
const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
|
|
45
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCard, { ...productIcon ? {
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCard, { ...props, ...productIcon ? {
|
|
46
40
|
productIcon
|
|
47
41
|
} : {
|
|
48
42
|
illustration
|
|
@@ -50,7 +44,7 @@ const SelectableCardField = ({
|
|
|
50
44
|
label
|
|
51
45
|
} : {
|
|
52
46
|
"aria-label": ariaLabel
|
|
53
|
-
}, isError: !!error,
|
|
47
|
+
}, isError: !!error, checked: isChecked, onChange: (event) => {
|
|
54
48
|
if (type === "checkbox") {
|
|
55
49
|
const fieldValue = field.value ?? [];
|
|
56
50
|
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
@@ -67,6 +61,6 @@ const SelectableCardField = ({
|
|
|
67
61
|
onBlur?.(event);
|
|
68
62
|
}, onFocus: (event) => {
|
|
69
63
|
onFocus?.(event);
|
|
70
|
-
}, type,
|
|
64
|
+
}, type, value: value ?? "", name: field.name });
|
|
71
65
|
};
|
|
72
66
|
exports.SelectableCardField = SelectableCardField;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { SelectableCard } from '@ultraviolet/ui';
|
|
2
2
|
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
-
import type { BaseFieldProps
|
|
5
|
-
type SelectableCardFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> =
|
|
6
|
-
|
|
7
|
-
} & ({
|
|
8
|
-
illustration?: ComponentProps<typeof SelectableCard>['illustration'];
|
|
9
|
-
productIcon?: never;
|
|
10
|
-
} | {
|
|
11
|
-
productIcon?: ComponentProps<typeof SelectableCard>['productIcon'];
|
|
12
|
-
illustration?: never;
|
|
13
|
-
}) & LabelProp;
|
|
14
|
-
export declare const SelectableCardField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, control, value, onChange, showTick, type, disabled, children, className, onFocus, onBlur, required, tooltip, id, label, shouldUnregister, validate, productIcon, illustration, "data-testid": dataTestId, "aria-label": ariaLabel, }: SelectableCardFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
type SelectableCardFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof SelectableCard>, 'name' | 'onChange'>;
|
|
6
|
+
export declare const SelectableCardField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, control, value, onChange, type, onFocus, onBlur, required, label, shouldUnregister, validate, productIcon, illustration, "aria-label": ariaLabel, ...props }: SelectableCardFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
7
|
export {};
|
|
@@ -7,23 +7,17 @@ const SelectableCardField = ({
|
|
|
7
7
|
control,
|
|
8
8
|
value,
|
|
9
9
|
onChange,
|
|
10
|
-
showTick,
|
|
11
10
|
type,
|
|
12
|
-
disabled,
|
|
13
|
-
children,
|
|
14
|
-
className,
|
|
15
11
|
onFocus,
|
|
16
12
|
onBlur,
|
|
17
13
|
required,
|
|
18
|
-
tooltip,
|
|
19
|
-
id,
|
|
20
14
|
label,
|
|
21
15
|
shouldUnregister = false,
|
|
22
16
|
validate,
|
|
23
17
|
productIcon,
|
|
24
18
|
illustration,
|
|
25
|
-
"
|
|
26
|
-
|
|
19
|
+
"aria-label": ariaLabel,
|
|
20
|
+
...props
|
|
27
21
|
}) => {
|
|
28
22
|
const {
|
|
29
23
|
field,
|
|
@@ -40,7 +34,7 @@ const SelectableCardField = ({
|
|
|
40
34
|
}
|
|
41
35
|
});
|
|
42
36
|
const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
|
|
43
|
-
return /* @__PURE__ */ jsx(SelectableCard, { ...productIcon ? {
|
|
37
|
+
return /* @__PURE__ */ jsx(SelectableCard, { ...props, ...productIcon ? {
|
|
44
38
|
productIcon
|
|
45
39
|
} : {
|
|
46
40
|
illustration
|
|
@@ -48,7 +42,7 @@ const SelectableCardField = ({
|
|
|
48
42
|
label
|
|
49
43
|
} : {
|
|
50
44
|
"aria-label": ariaLabel
|
|
51
|
-
}, isError: !!error,
|
|
45
|
+
}, isError: !!error, checked: isChecked, onChange: (event) => {
|
|
52
46
|
if (type === "checkbox") {
|
|
53
47
|
const fieldValue = field.value ?? [];
|
|
54
48
|
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
@@ -65,7 +59,7 @@ const SelectableCardField = ({
|
|
|
65
59
|
onBlur?.(event);
|
|
66
60
|
}, onFocus: (event) => {
|
|
67
61
|
onFocus?.(event);
|
|
68
|
-
}, type,
|
|
62
|
+
}, type, value: value ?? "", name: field.name });
|
|
69
63
|
};
|
|
70
64
|
export {
|
|
71
65
|
SelectableCardField
|
|
@@ -6,21 +6,17 @@ const ui = require("@ultraviolet/ui");
|
|
|
6
6
|
const reactHookForm = require("react-hook-form");
|
|
7
7
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
8
|
const SelectableCardGroupField = ({
|
|
9
|
-
className,
|
|
10
9
|
legend = "",
|
|
11
|
-
legendDescription,
|
|
12
10
|
control,
|
|
13
11
|
name,
|
|
14
12
|
onChange,
|
|
15
13
|
required = false,
|
|
16
|
-
children,
|
|
17
14
|
error: customError,
|
|
18
|
-
helper,
|
|
19
15
|
columns = 1,
|
|
20
|
-
showTick,
|
|
21
16
|
type = "radio",
|
|
22
17
|
shouldUnregister = false,
|
|
23
|
-
validate
|
|
18
|
+
validate,
|
|
19
|
+
...props
|
|
24
20
|
}) => {
|
|
25
21
|
const {
|
|
26
22
|
getError
|
|
@@ -39,7 +35,7 @@ const SelectableCardGroupField = ({
|
|
|
39
35
|
validate
|
|
40
36
|
}
|
|
41
37
|
});
|
|
42
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardGroup, {
|
|
38
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardGroup, { ...props, legend, name, type, value: field.value, onChange: (event) => {
|
|
43
39
|
if (type === "checkbox") {
|
|
44
40
|
const fieldValue = field.value ?? [];
|
|
45
41
|
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
@@ -53,7 +49,7 @@ const SelectableCardGroupField = ({
|
|
|
53
49
|
onChange?.(event.currentTarget.value);
|
|
54
50
|
}, error: getError({
|
|
55
51
|
label: legend
|
|
56
|
-
}, error) ?? customError,
|
|
52
|
+
}, error) ?? customError, columns, required });
|
|
57
53
|
};
|
|
58
54
|
SelectableCardGroupField.Card = ui.SelectableCardGroup.Card;
|
|
59
55
|
exports.SelectableCardGroupField = SelectableCardGroupField;
|
|
@@ -2,9 +2,9 @@ import { SelectableCardGroup } from '@ultraviolet/ui';
|
|
|
2
2
|
import type { ComponentProps, JSX } from 'react';
|
|
3
3
|
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
4
|
import type { BaseFieldProps } from '../../types';
|
|
5
|
-
type SelectableCardGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> =
|
|
5
|
+
type SelectableCardGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof SelectableCardGroup>, 'name' | 'onChange'>;
|
|
6
6
|
export declare const SelectableCardGroupField: {
|
|
7
|
-
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({
|
|
7
|
+
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ legend, control, name, onChange, required, error: customError, columns, type, shouldUnregister, validate, ...props }: SelectableCardGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
|
|
8
8
|
Card: ({ value, disabled, children, className, isError, onFocus, onBlur, tooltip, id, label, "data-testid": dataTestId, }: import("node_modules/@ultraviolet/ui/dist/components/SelectableCardGroup").CardSelectableCardProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
9
|
};
|
|
10
10
|
export {};
|
|
@@ -4,21 +4,17 @@ import { SelectableCardGroup } from "@ultraviolet/ui";
|
|
|
4
4
|
import { useController } from "react-hook-form";
|
|
5
5
|
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
6
6
|
const SelectableCardGroupField = ({
|
|
7
|
-
className,
|
|
8
7
|
legend = "",
|
|
9
|
-
legendDescription,
|
|
10
8
|
control,
|
|
11
9
|
name,
|
|
12
10
|
onChange,
|
|
13
11
|
required = false,
|
|
14
|
-
children,
|
|
15
12
|
error: customError,
|
|
16
|
-
helper,
|
|
17
13
|
columns = 1,
|
|
18
|
-
showTick,
|
|
19
14
|
type = "radio",
|
|
20
15
|
shouldUnregister = false,
|
|
21
|
-
validate
|
|
16
|
+
validate,
|
|
17
|
+
...props
|
|
22
18
|
}) => {
|
|
23
19
|
const {
|
|
24
20
|
getError
|
|
@@ -37,7 +33,7 @@ const SelectableCardGroupField = ({
|
|
|
37
33
|
validate
|
|
38
34
|
}
|
|
39
35
|
});
|
|
40
|
-
return /* @__PURE__ */ jsx(SelectableCardGroup, {
|
|
36
|
+
return /* @__PURE__ */ jsx(SelectableCardGroup, { ...props, legend, name, type, value: field.value, onChange: (event) => {
|
|
41
37
|
if (type === "checkbox") {
|
|
42
38
|
const fieldValue = field.value ?? [];
|
|
43
39
|
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
@@ -51,7 +47,7 @@ const SelectableCardGroupField = ({
|
|
|
51
47
|
onChange?.(event.currentTarget.value);
|
|
52
48
|
}, error: getError({
|
|
53
49
|
label: legend
|
|
54
|
-
}, error) ?? customError,
|
|
50
|
+
}, error) ?? customError, columns, required });
|
|
55
51
|
};
|
|
56
52
|
SelectableCardGroupField.Card = SelectableCardGroup.Card;
|
|
57
53
|
export {
|
|
@@ -8,26 +8,15 @@ const validateRegex = require("../../utils/validateRegex.cjs");
|
|
|
8
8
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
9
|
const TagInputField = ({
|
|
10
10
|
regex: regexes,
|
|
11
|
-
className,
|
|
12
|
-
disabled,
|
|
13
|
-
id,
|
|
14
11
|
control,
|
|
15
12
|
name,
|
|
16
13
|
onChange,
|
|
17
|
-
placeholder,
|
|
18
14
|
required,
|
|
19
|
-
variant,
|
|
20
15
|
shouldUnregister = false,
|
|
21
|
-
"data-testid": dataTestId,
|
|
22
|
-
clearable,
|
|
23
16
|
label,
|
|
24
|
-
labelDescription,
|
|
25
|
-
size,
|
|
26
|
-
success,
|
|
27
|
-
readOnly,
|
|
28
|
-
tooltip,
|
|
29
17
|
validate,
|
|
30
|
-
"aria-label": ariaLabel
|
|
18
|
+
"aria-label": ariaLabel,
|
|
19
|
+
...props
|
|
31
20
|
}) => {
|
|
32
21
|
const {
|
|
33
22
|
getError
|
|
@@ -51,12 +40,12 @@ const TagInputField = ({
|
|
|
51
40
|
}
|
|
52
41
|
}
|
|
53
42
|
});
|
|
54
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.TagInput, { name: field.name,
|
|
43
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.TagInput, { ...props, name: field.name, onChange: (newTags) => {
|
|
55
44
|
field.onChange(newTags);
|
|
56
45
|
onChange?.(newTags);
|
|
57
|
-
},
|
|
46
|
+
}, value: field.value, label, "aria-label": ariaLabel, error: getError({
|
|
58
47
|
regex: regexes,
|
|
59
48
|
label: label ?? ariaLabel ?? name
|
|
60
|
-
}, error)
|
|
49
|
+
}, error) });
|
|
61
50
|
};
|
|
62
51
|
exports.TagInputField = TagInputField;
|
|
@@ -2,7 +2,7 @@ import { TagInput } from '@ultraviolet/ui';
|
|
|
2
2
|
import type { ComponentProps } from 'react';
|
|
3
3
|
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
4
|
import type { BaseFieldProps } from '../../types';
|
|
5
|
-
export type TagInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> &
|
|
5
|
+
export type TagInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof TagInput>, 'name' | 'onChange'> & {
|
|
6
6
|
regex?: (RegExp | RegExp[])[];
|
|
7
7
|
};
|
|
8
|
-
export declare const TagInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ regex: regexes,
|
|
8
|
+
export declare const TagInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ regex: regexes, control, name, onChange, required, shouldUnregister, label, validate, "aria-label": ariaLabel, ...props }: TagInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -6,26 +6,15 @@ import { validateRegex } from "../../utils/validateRegex.js";
|
|
|
6
6
|
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
7
7
|
const TagInputField = ({
|
|
8
8
|
regex: regexes,
|
|
9
|
-
className,
|
|
10
|
-
disabled,
|
|
11
|
-
id,
|
|
12
9
|
control,
|
|
13
10
|
name,
|
|
14
11
|
onChange,
|
|
15
|
-
placeholder,
|
|
16
12
|
required,
|
|
17
|
-
variant,
|
|
18
13
|
shouldUnregister = false,
|
|
19
|
-
"data-testid": dataTestId,
|
|
20
|
-
clearable,
|
|
21
14
|
label,
|
|
22
|
-
labelDescription,
|
|
23
|
-
size,
|
|
24
|
-
success,
|
|
25
|
-
readOnly,
|
|
26
|
-
tooltip,
|
|
27
15
|
validate,
|
|
28
|
-
"aria-label": ariaLabel
|
|
16
|
+
"aria-label": ariaLabel,
|
|
17
|
+
...props
|
|
29
18
|
}) => {
|
|
30
19
|
const {
|
|
31
20
|
getError
|
|
@@ -49,13 +38,13 @@ const TagInputField = ({
|
|
|
49
38
|
}
|
|
50
39
|
}
|
|
51
40
|
});
|
|
52
|
-
return /* @__PURE__ */ jsx(TagInput, { name: field.name,
|
|
41
|
+
return /* @__PURE__ */ jsx(TagInput, { ...props, name: field.name, onChange: (newTags) => {
|
|
53
42
|
field.onChange(newTags);
|
|
54
43
|
onChange?.(newTags);
|
|
55
|
-
},
|
|
44
|
+
}, value: field.value, label, "aria-label": ariaLabel, error: getError({
|
|
56
45
|
regex: regexes,
|
|
57
46
|
label: label ?? ariaLabel ?? name
|
|
58
|
-
}, error)
|
|
47
|
+
}, error) });
|
|
59
48
|
};
|
|
60
49
|
export {
|
|
61
50
|
TagInputField
|
|
@@ -7,34 +7,20 @@ const reactHookForm = require("react-hook-form");
|
|
|
7
7
|
const validateRegex = require("../../utils/validateRegex.cjs");
|
|
8
8
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
9
9
|
const TextAreaField = ({
|
|
10
|
-
autoFocus,
|
|
11
|
-
clearable,
|
|
12
|
-
className,
|
|
13
|
-
tabIndex,
|
|
14
10
|
control,
|
|
15
|
-
"data-testid": dataTestId,
|
|
16
|
-
disabled,
|
|
17
|
-
helper,
|
|
18
11
|
label,
|
|
19
|
-
labelDescription,
|
|
20
12
|
onChange,
|
|
21
13
|
minLength,
|
|
22
14
|
maxLength,
|
|
23
15
|
name,
|
|
24
|
-
onFocus,
|
|
25
16
|
onBlur,
|
|
26
17
|
onKeyDown,
|
|
27
|
-
maxRows,
|
|
28
|
-
placeholder,
|
|
29
|
-
readOnly,
|
|
30
18
|
required,
|
|
31
|
-
rows,
|
|
32
|
-
success,
|
|
33
|
-
tooltip,
|
|
34
19
|
regex: regexes,
|
|
35
20
|
submitOnEnter,
|
|
36
21
|
validate,
|
|
37
|
-
"aria-label": ariaLabel
|
|
22
|
+
"aria-label": ariaLabel,
|
|
23
|
+
...props
|
|
38
24
|
}) => {
|
|
39
25
|
const {
|
|
40
26
|
getError
|
|
@@ -77,19 +63,19 @@ const TextAreaField = ({
|
|
|
77
63
|
onKeyDown?.(event);
|
|
78
64
|
}
|
|
79
65
|
};
|
|
80
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.TextArea, {
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.TextArea, { ...props, error: getError({
|
|
81
67
|
regex: regexes,
|
|
82
68
|
minLength,
|
|
83
69
|
maxLength,
|
|
84
70
|
label: label ?? ariaLabel ?? name,
|
|
85
71
|
value: field.value
|
|
86
|
-
}, error),
|
|
72
|
+
}, error), minLength, maxLength, name, onBlur: (event) => {
|
|
87
73
|
onBlur?.(event);
|
|
88
74
|
field.onBlur();
|
|
89
75
|
}, onChange: (event) => {
|
|
90
76
|
field.onChange(event);
|
|
91
77
|
onChange?.(event);
|
|
92
|
-
},
|
|
78
|
+
}, onKeyDown: onKeyDownHandler, required, value: field.value, ...label ? {
|
|
93
79
|
label
|
|
94
80
|
} : {
|
|
95
81
|
"aria-label": ariaLabel
|