@ultraviolet/form 2.14.6 → 3.0.0
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.cjs +5 -3
- package/dist/components/CheckboxField/index.d.ts +2 -2
- package/dist/components/CheckboxField/index.js +5 -3
- package/dist/components/CheckboxGroupField/index.cjs +12 -8
- package/dist/components/CheckboxGroupField/index.d.ts +2 -2
- package/dist/components/CheckboxGroupField/index.js +8 -4
- package/dist/components/DateField/index.cjs +7 -6
- package/dist/components/DateField/index.d.ts +2 -2
- package/dist/components/DateField/index.js +7 -6
- package/dist/components/Form/index.cjs +7 -47
- package/dist/components/Form/index.d.ts +8 -64
- package/dist/components/Form/index.js +9 -47
- package/dist/components/NumberInputField/index.cjs +5 -3
- package/dist/components/NumberInputField/index.d.ts +2 -2
- package/dist/components/NumberInputField/index.js +5 -3
- package/dist/components/NumberInputFieldV2/index.cjs +5 -3
- package/dist/components/NumberInputFieldV2/index.d.ts +2 -4
- package/dist/components/NumberInputFieldV2/index.js +5 -3
- package/dist/components/RadioField/index.cjs +5 -3
- package/dist/components/RadioField/index.d.ts +2 -2
- package/dist/components/RadioField/index.js +5 -3
- package/dist/components/RadioGroupField/index.cjs +5 -3
- package/dist/components/RadioGroupField/index.d.ts +2 -2
- package/dist/components/RadioGroupField/index.js +5 -3
- package/dist/components/SelectInputField/index.cjs +7 -7
- package/dist/components/SelectInputField/index.d.ts +2 -2
- package/dist/components/SelectInputField/index.js +3 -3
- package/dist/components/SelectInputFieldV2/index.cjs +7 -5
- package/dist/components/SelectInputFieldV2/index.d.ts +2 -2
- package/dist/components/SelectInputFieldV2/index.js +5 -3
- package/dist/components/SelectableCardField/index.cjs +4 -2
- package/dist/components/SelectableCardField/index.d.ts +2 -2
- package/dist/components/SelectableCardField/index.js +4 -2
- package/dist/components/SelectableCardGroupField/index.cjs +5 -3
- package/dist/components/SelectableCardGroupField/index.d.ts +2 -2
- package/dist/components/SelectableCardGroupField/index.js +5 -3
- package/dist/components/TagInputField/index.cjs +5 -3
- package/dist/components/TagInputField/index.d.ts +2 -2
- package/dist/components/TagInputField/index.js +5 -3
- package/dist/components/TextAreaField/index.cjs +6 -3
- package/dist/components/TextAreaField/index.d.ts +2 -2
- package/dist/components/TextAreaField/index.js +6 -3
- package/dist/components/TextInputField/index.cjs +15 -14
- package/dist/components/TextInputField/index.d.ts +2 -2
- package/dist/components/TextInputField/index.js +15 -14
- package/dist/components/TextInputFieldV2/index.cjs +6 -3
- package/dist/components/TextInputFieldV2/index.d.ts +2 -2
- package/dist/components/TextInputFieldV2/index.js +6 -3
- package/dist/components/TimeField/index.cjs +5 -3
- package/dist/components/TimeField/index.d.ts +2 -4
- package/dist/components/TimeField/index.js +5 -3
- package/dist/components/ToggleField/index.cjs +5 -3
- package/dist/components/ToggleField/index.d.ts +2 -2
- package/dist/components/ToggleField/index.js +5 -3
- package/dist/components/ToggleGroupField/index.d.ts +2 -2
- package/dist/components/UnitInputField/index.cjs +4 -4
- package/dist/components/UnitInputField/index.d.ts +2 -2
- package/dist/components/UnitInputField/index.js +4 -4
- package/dist/components/index.d.ts +0 -1
- package/dist/hooks/index.d.ts +0 -4
- package/dist/hooks/useOnFieldChange.cjs +3 -3
- package/dist/hooks/useOnFieldChange.d.ts +3 -0
- package/dist/index.cjs +8 -18
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -11
- package/dist/providers/ErrorContext/index.cjs +5 -5
- package/dist/types.d.ts +7 -10
- package/dist/utils/validateRegex.cjs +4 -0
- package/dist/utils/validateRegex.d.ts +2 -0
- package/dist/utils/validateRegex.js +4 -0
- package/package.json +3 -3
- package/dist/constants.cjs +0 -4
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -4
- package/dist/hooks/useField.cjs +0 -30
- package/dist/hooks/useField.d.ts +0 -34
- package/dist/hooks/useField.js +0 -30
- package/dist/hooks/useFieldArray.cjs +0 -32
- package/dist/hooks/useFieldArray.d.ts +0 -21
- package/dist/hooks/useFieldArray.js +0 -32
- package/dist/hooks/useForm.cjs +0 -24
- package/dist/hooks/useForm.d.ts +0 -22
- package/dist/hooks/useForm.js +0 -24
- package/dist/hooks/useFormState.cjs +0 -22
- package/dist/hooks/useFormState.d.ts +0 -39
- package/dist/hooks/useFormState.js +0 -22
|
@@ -4,6 +4,7 @@ import { useController } from "react-hook-form";
|
|
|
4
4
|
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
5
5
|
const NumberInputFieldV2 = ({
|
|
6
6
|
disabled,
|
|
7
|
+
control,
|
|
7
8
|
max = Number.MAX_SAFE_INTEGER,
|
|
8
9
|
min = 0,
|
|
9
10
|
name,
|
|
@@ -20,14 +21,14 @@ const NumberInputFieldV2 = ({
|
|
|
20
21
|
placeholder,
|
|
21
22
|
success,
|
|
22
23
|
helper,
|
|
23
|
-
rules,
|
|
24
24
|
controls = true,
|
|
25
25
|
"aria-label": ariaLabel,
|
|
26
26
|
"data-testid": dataTestId,
|
|
27
27
|
required,
|
|
28
28
|
autoFocus,
|
|
29
29
|
readOnly,
|
|
30
|
-
shouldUnregister = false
|
|
30
|
+
shouldUnregister = false,
|
|
31
|
+
validate
|
|
31
32
|
}) => {
|
|
32
33
|
const {
|
|
33
34
|
getError
|
|
@@ -39,12 +40,13 @@ const NumberInputFieldV2 = ({
|
|
|
39
40
|
}
|
|
40
41
|
} = useController({
|
|
41
42
|
name,
|
|
43
|
+
control,
|
|
42
44
|
shouldUnregister,
|
|
43
45
|
rules: {
|
|
44
46
|
max,
|
|
45
47
|
min,
|
|
46
48
|
required,
|
|
47
|
-
|
|
49
|
+
validate
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
return /* @__PURE__ */ jsx(NumberInputV2, { name: field.name, value: field.value, disabled, onBlur: (event) => {
|
|
@@ -6,6 +6,7 @@ const reactHookForm = require("react-hook-form");
|
|
|
6
6
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
7
7
|
const RadioField = ({
|
|
8
8
|
className,
|
|
9
|
+
control,
|
|
9
10
|
"data-testid": dataTestId,
|
|
10
11
|
disabled,
|
|
11
12
|
id,
|
|
@@ -16,9 +17,9 @@ const RadioField = ({
|
|
|
16
17
|
onFocus,
|
|
17
18
|
required,
|
|
18
19
|
value,
|
|
19
|
-
rules,
|
|
20
20
|
tooltip,
|
|
21
|
-
shouldUnregister = false
|
|
21
|
+
shouldUnregister = false,
|
|
22
|
+
validate
|
|
22
23
|
}) => {
|
|
23
24
|
const {
|
|
24
25
|
getError
|
|
@@ -30,10 +31,11 @@ const RadioField = ({
|
|
|
30
31
|
}
|
|
31
32
|
} = reactHookForm.useController({
|
|
32
33
|
name,
|
|
34
|
+
control,
|
|
33
35
|
shouldUnregister,
|
|
34
36
|
rules: {
|
|
35
37
|
required,
|
|
36
|
-
|
|
38
|
+
validate
|
|
37
39
|
}
|
|
38
40
|
});
|
|
39
41
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Radio, { name: field.name, checked: field.value === value, className, "data-testid": dataTestId, disabled, error: getError({
|
|
@@ -2,11 +2,11 @@ import { Radio } 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 RadioFieldProps<TFieldValues extends FieldValues,
|
|
5
|
+
type RadioFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & Partial<Pick<ComponentProps<typeof Radio>, 'disabled' | 'id' | 'onBlur' | 'onFocus' | 'data-testid' | 'tooltip' | 'label'>> & {
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* @deprecated This component is deprecated, use `RadioGroupField` instead.
|
|
10
10
|
*/
|
|
11
|
-
export declare const RadioField: <TFieldValues extends FieldValues,
|
|
11
|
+
export declare const RadioField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, control, "data-testid": dataTestId, disabled, id, name, onBlur, label, onChange, onFocus, required, value, tooltip, shouldUnregister, validate, }: RadioFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -4,6 +4,7 @@ import { useController } from "react-hook-form";
|
|
|
4
4
|
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
5
5
|
const RadioField = ({
|
|
6
6
|
className,
|
|
7
|
+
control,
|
|
7
8
|
"data-testid": dataTestId,
|
|
8
9
|
disabled,
|
|
9
10
|
id,
|
|
@@ -14,9 +15,9 @@ const RadioField = ({
|
|
|
14
15
|
onFocus,
|
|
15
16
|
required,
|
|
16
17
|
value,
|
|
17
|
-
rules,
|
|
18
18
|
tooltip,
|
|
19
|
-
shouldUnregister = false
|
|
19
|
+
shouldUnregister = false,
|
|
20
|
+
validate
|
|
20
21
|
}) => {
|
|
21
22
|
const {
|
|
22
23
|
getError
|
|
@@ -28,10 +29,11 @@ const RadioField = ({
|
|
|
28
29
|
}
|
|
29
30
|
} = useController({
|
|
30
31
|
name,
|
|
32
|
+
control,
|
|
31
33
|
shouldUnregister,
|
|
32
34
|
rules: {
|
|
33
35
|
required,
|
|
34
|
-
|
|
36
|
+
validate
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
return /* @__PURE__ */ jsx(Radio, { name: field.name, checked: field.value === value, className, "data-testid": dataTestId, disabled, error: getError({
|
|
@@ -6,17 +6,18 @@ const reactHookForm = require("react-hook-form");
|
|
|
6
6
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
7
7
|
const RadioGroupField = ({
|
|
8
8
|
className,
|
|
9
|
+
control,
|
|
9
10
|
legend = "",
|
|
10
11
|
name,
|
|
11
12
|
onChange,
|
|
12
13
|
required,
|
|
13
|
-
rules,
|
|
14
14
|
children,
|
|
15
15
|
label = "",
|
|
16
16
|
error: customError,
|
|
17
17
|
helper,
|
|
18
18
|
direction,
|
|
19
|
-
shouldUnregister = false
|
|
19
|
+
shouldUnregister = false,
|
|
20
|
+
validate
|
|
20
21
|
}) => {
|
|
21
22
|
const {
|
|
22
23
|
getError
|
|
@@ -28,10 +29,11 @@ const RadioGroupField = ({
|
|
|
28
29
|
}
|
|
29
30
|
} = reactHookForm.useController({
|
|
30
31
|
name,
|
|
32
|
+
control,
|
|
31
33
|
shouldUnregister,
|
|
32
34
|
rules: {
|
|
33
35
|
required,
|
|
34
|
-
|
|
36
|
+
validate
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.RadioGroup, { className, name: field.name, onChange: (event) => {
|
|
@@ -2,11 +2,11 @@ import { RadioGroup } 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 RadioGroupFieldProps<TFieldValues extends FieldValues,
|
|
5
|
+
type RadioGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Partial<Pick<ComponentProps<typeof RadioGroup>, 'legend' | 'children' | 'error' | 'helper' | 'direction'>> & {
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const RadioGroupField: {
|
|
9
|
-
<TFieldValues extends FieldValues,
|
|
9
|
+
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, control, legend, name, onChange, required, children, label, error: customError, helper, direction, shouldUnregister, validate, }: RadioGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
|
|
10
10
|
Radio: ({ onFocus, onBlur, disabled, error, name, value, label, helper, className, autoFocus, onKeyDown, "data-testid": dataTestId, }: Omit<({
|
|
11
11
|
error?: import("react").ReactNode;
|
|
12
12
|
checked?: boolean;
|
|
@@ -4,17 +4,18 @@ import { useController } from "react-hook-form";
|
|
|
4
4
|
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
5
5
|
const RadioGroupField = ({
|
|
6
6
|
className,
|
|
7
|
+
control,
|
|
7
8
|
legend = "",
|
|
8
9
|
name,
|
|
9
10
|
onChange,
|
|
10
11
|
required,
|
|
11
|
-
rules,
|
|
12
12
|
children,
|
|
13
13
|
label = "",
|
|
14
14
|
error: customError,
|
|
15
15
|
helper,
|
|
16
16
|
direction,
|
|
17
|
-
shouldUnregister = false
|
|
17
|
+
shouldUnregister = false,
|
|
18
|
+
validate
|
|
18
19
|
}) => {
|
|
19
20
|
const {
|
|
20
21
|
getError
|
|
@@ -26,10 +27,11 @@ const RadioGroupField = ({
|
|
|
26
27
|
}
|
|
27
28
|
} = useController({
|
|
28
29
|
name,
|
|
30
|
+
control,
|
|
29
31
|
shouldUnregister,
|
|
30
32
|
rules: {
|
|
31
33
|
required,
|
|
32
|
-
|
|
34
|
+
validate
|
|
33
35
|
}
|
|
34
36
|
});
|
|
35
37
|
return /* @__PURE__ */ jsx(RadioGroup, { className, name: field.name, onChange: (event) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
4
|
const ui = require("@ultraviolet/ui");
|
|
5
|
-
const
|
|
5
|
+
const react = require("react");
|
|
6
6
|
const reactHookForm = require("react-hook-form");
|
|
7
7
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
8
|
const identity = (x) => x;
|
|
@@ -35,14 +35,14 @@ const SelectInputField = ({
|
|
|
35
35
|
placeholder,
|
|
36
36
|
readOnly,
|
|
37
37
|
required,
|
|
38
|
-
rules,
|
|
39
38
|
noTopLabel,
|
|
40
39
|
emptyState,
|
|
41
40
|
customStyle,
|
|
42
41
|
shouldUnregister = false,
|
|
43
|
-
"data-testid": dataTestId
|
|
42
|
+
"data-testid": dataTestId,
|
|
43
|
+
validate
|
|
44
44
|
}) => {
|
|
45
|
-
const options =
|
|
45
|
+
const options = react.useMemo(() => optionsProp || react.Children.toArray(children).flat().filter(Boolean).map(({
|
|
46
46
|
props: {
|
|
47
47
|
children: labelChild,
|
|
48
48
|
...option
|
|
@@ -51,8 +51,8 @@ const SelectInputField = ({
|
|
|
51
51
|
...option,
|
|
52
52
|
label: labelChild
|
|
53
53
|
})), [optionsProp, children]);
|
|
54
|
-
const parse =
|
|
55
|
-
const format =
|
|
54
|
+
const parse = react.useMemo(() => multiple ? parseProp : (option) => parseProp(option?.value ?? null, name), [multiple, parseProp, name]);
|
|
55
|
+
const format = react.useCallback((val) => {
|
|
56
56
|
if (multiple) return formatProp(val, name);
|
|
57
57
|
const find = (opts, valueToFind) => opts?.find((option) => option.value === valueToFind);
|
|
58
58
|
let selected = "";
|
|
@@ -82,7 +82,7 @@ const SelectInputField = ({
|
|
|
82
82
|
required,
|
|
83
83
|
minLength: minLength || required ? 1 : void 0,
|
|
84
84
|
maxLength,
|
|
85
|
-
|
|
85
|
+
validate
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInput, { name: field.name, animation, animationDuration, animationOnChange, className, disabled, error: getError({
|
|
@@ -68,7 +68,7 @@ type SelectInputProps = Partial<SelectProps & SelectStyleProps & Pick<ComponentP
|
|
|
68
68
|
/**
|
|
69
69
|
* @deprecated This component is deprecated, please use `SelectInputFieldV2` instead
|
|
70
70
|
*/
|
|
71
|
-
export type SelectInputFieldProps<TFieldValues extends FieldValues,
|
|
71
|
+
export type SelectInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'onChange'> & Partial<Pick<SelectInputProps, 'animation' | 'animationDuration' | 'animationOnChange' | 'children' | 'className' | 'disabled' | 'error' | 'id' | 'inputId' | 'isClearable' | 'isLoading' | 'isSearchable' | 'menuPortalTarget' | 'onBlur' | 'onChange' | 'onFocus' | 'options' | 'placeholder' | 'readOnly' | 'required' | 'value' | 'noTopLabel' | 'emptyState' | 'customStyle' | 'data-testid'>> & {
|
|
72
72
|
multiple?: boolean;
|
|
73
73
|
parse?: (value: unknown, name?: string) => unknown;
|
|
74
74
|
format?: (value: unknown, name: string) => unknown;
|
|
@@ -76,7 +76,7 @@ export type SelectInputFieldProps<TFieldValues extends FieldValues, TName extend
|
|
|
76
76
|
minLength?: number;
|
|
77
77
|
};
|
|
78
78
|
export declare const SelectInputField: {
|
|
79
|
-
<TFieldValues extends FieldValues,
|
|
79
|
+
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ animation, animationDuration, animationOnChange, children, className, disabled, format: formatProp, id, inputId, isClearable, isLoading, isSearchable, label, maxLength, menuPortalTarget, minLength, multiple, name, onBlur, onChange, onFocus, options: optionsProp, parse: parseProp, placeholder, readOnly, required, noTopLabel, emptyState, customStyle, shouldUnregister, "data-testid": dataTestId, validate, }: SelectInputFieldProps<TFieldValues, TFieldName>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
80
80
|
Option: (props: Partial<OptionProps<import("@ultraviolet/ui").SelectOption> & import("@ultraviolet/ui").SelectOption>) => import("react").JSX.Element;
|
|
81
81
|
};
|
|
82
82
|
export {};
|
|
@@ -33,12 +33,12 @@ const SelectInputField = ({
|
|
|
33
33
|
placeholder,
|
|
34
34
|
readOnly,
|
|
35
35
|
required,
|
|
36
|
-
rules,
|
|
37
36
|
noTopLabel,
|
|
38
37
|
emptyState,
|
|
39
38
|
customStyle,
|
|
40
39
|
shouldUnregister = false,
|
|
41
|
-
"data-testid": dataTestId
|
|
40
|
+
"data-testid": dataTestId,
|
|
41
|
+
validate
|
|
42
42
|
}) => {
|
|
43
43
|
const options = useMemo(() => optionsProp || Children.toArray(children).flat().filter(Boolean).map(({
|
|
44
44
|
props: {
|
|
@@ -80,7 +80,7 @@ const SelectInputField = ({
|
|
|
80
80
|
required,
|
|
81
81
|
minLength: minLength || required ? 1 : void 0,
|
|
82
82
|
maxLength,
|
|
83
|
-
|
|
83
|
+
validate
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
return /* @__PURE__ */ jsx(SelectInput, { name: field.name, animation, animationDuration, animationOnChange, className, disabled, error: getError({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
4
|
const ui = require("@ultraviolet/ui");
|
|
5
|
-
const
|
|
5
|
+
const react = require("react");
|
|
6
6
|
const reactHookForm = require("react-hook-form");
|
|
7
7
|
const index = require("../../providers/ErrorContext/index.cjs");
|
|
8
8
|
const SelectInputFieldV2 = ({
|
|
@@ -37,8 +37,9 @@ const SelectInputFieldV2 = ({
|
|
|
37
37
|
name,
|
|
38
38
|
"aria-label": ariaLabel,
|
|
39
39
|
optionalInfoPlacement,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
shouldUnregister = false,
|
|
41
|
+
control,
|
|
42
|
+
validate
|
|
42
43
|
}) => {
|
|
43
44
|
const {
|
|
44
45
|
field,
|
|
@@ -47,16 +48,17 @@ const SelectInputFieldV2 = ({
|
|
|
47
48
|
}
|
|
48
49
|
} = reactHookForm.useController({
|
|
49
50
|
name,
|
|
51
|
+
control,
|
|
50
52
|
shouldUnregister,
|
|
51
53
|
rules: {
|
|
52
54
|
required,
|
|
53
|
-
|
|
55
|
+
validate
|
|
54
56
|
}
|
|
55
57
|
});
|
|
56
58
|
const {
|
|
57
59
|
getError
|
|
58
60
|
} = index.useErrors();
|
|
59
|
-
const handleChange =
|
|
61
|
+
const handleChange = react.useCallback((value) => {
|
|
60
62
|
onChange?.(value);
|
|
61
63
|
field.onChange(value);
|
|
62
64
|
}, [onChange, field]);
|
|
@@ -2,6 +2,6 @@ import { SelectInputV2 } 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 SelectInputFieldV2Props<TFieldValues extends FieldValues,
|
|
6
|
-
export declare const SelectInputFieldV2: <TFieldValues extends FieldValues,
|
|
5
|
+
type SelectInputFieldV2Props<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Pick<ComponentProps<typeof SelectInputV2>, 'placeholder' | 'placeholderSearch' | 'label' | 'helper' | 'options' | 'emptyState' | 'searchable' | 'readOnly' | 'clearable' | 'size' | 'multiselect' | 'required' | 'descriptionDirection' | 'footer' | 'labelDescription' | 'success' | 'loadMore' | 'isLoading' | 'selectAll' | 'selectAllGroup' | 'autofocus' | 'data-testid' | 'onChange' | 'id' | 'onBlur' | 'aria-label' | 'className' | 'onFocus' | 'optionalInfoPlacement' | 'disabled'>;
|
|
6
|
+
export declare const SelectInputFieldV2: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ autofocus, className, id, label, onFocus, onBlur, placeholder, readOnly, required, size, "data-testid": dataTestId, disabled, placeholderSearch, helper, options, emptyState, onChange, searchable, clearable, multiselect, descriptionDirection, footer, labelDescription, success, loadMore, isLoading, selectAll, selectAllGroup, name, "aria-label": ariaLabel, optionalInfoPlacement, shouldUnregister, control, validate, }: SelectInputFieldV2Props<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -35,8 +35,9 @@ const SelectInputFieldV2 = ({
|
|
|
35
35
|
name,
|
|
36
36
|
"aria-label": ariaLabel,
|
|
37
37
|
optionalInfoPlacement,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
shouldUnregister = false,
|
|
39
|
+
control,
|
|
40
|
+
validate
|
|
40
41
|
}) => {
|
|
41
42
|
const {
|
|
42
43
|
field,
|
|
@@ -45,10 +46,11 @@ const SelectInputFieldV2 = ({
|
|
|
45
46
|
}
|
|
46
47
|
} = useController({
|
|
47
48
|
name,
|
|
49
|
+
control,
|
|
48
50
|
shouldUnregister,
|
|
49
51
|
rules: {
|
|
50
52
|
required,
|
|
51
|
-
|
|
53
|
+
validate
|
|
52
54
|
}
|
|
53
55
|
});
|
|
54
56
|
const {
|
|
@@ -5,6 +5,7 @@ const ui = require("@ultraviolet/ui");
|
|
|
5
5
|
const reactHookForm = require("react-hook-form");
|
|
6
6
|
const SelectableCardField = ({
|
|
7
7
|
name,
|
|
8
|
+
control,
|
|
8
9
|
value,
|
|
9
10
|
onChange,
|
|
10
11
|
showTick,
|
|
@@ -18,8 +19,8 @@ const SelectableCardField = ({
|
|
|
18
19
|
tooltip,
|
|
19
20
|
id,
|
|
20
21
|
label,
|
|
21
|
-
rules,
|
|
22
22
|
shouldUnregister = false,
|
|
23
|
+
validate,
|
|
23
24
|
"data-testid": dataTestId
|
|
24
25
|
}) => {
|
|
25
26
|
const {
|
|
@@ -29,10 +30,11 @@ const SelectableCardField = ({
|
|
|
29
30
|
}
|
|
30
31
|
} = reactHookForm.useController({
|
|
31
32
|
name,
|
|
33
|
+
control,
|
|
32
34
|
shouldUnregister,
|
|
33
35
|
rules: {
|
|
34
36
|
required,
|
|
35
|
-
|
|
37
|
+
validate
|
|
36
38
|
}
|
|
37
39
|
});
|
|
38
40
|
const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
|
|
@@ -2,8 +2,8 @@ import { SelectableCard } 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 SelectableCardFieldProps<TFieldValues extends FieldValues,
|
|
5
|
+
type SelectableCardFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label' | 'onChange'> & Partial<Pick<ComponentProps<typeof SelectableCard>, 'disabled' | 'onBlur' | 'onChange' | 'onFocus' | 'showTick' | 'type' | 'id' | 'children' | 'tooltip' | 'label' | 'data-testid'>> & {
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const SelectableCardField: <TFieldValues extends FieldValues,
|
|
8
|
+
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, "data-testid": dataTestId, }: SelectableCardFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -3,6 +3,7 @@ import { SelectableCard } from "@ultraviolet/ui";
|
|
|
3
3
|
import { useController } from "react-hook-form";
|
|
4
4
|
const SelectableCardField = ({
|
|
5
5
|
name,
|
|
6
|
+
control,
|
|
6
7
|
value,
|
|
7
8
|
onChange,
|
|
8
9
|
showTick,
|
|
@@ -16,8 +17,8 @@ const SelectableCardField = ({
|
|
|
16
17
|
tooltip,
|
|
17
18
|
id,
|
|
18
19
|
label,
|
|
19
|
-
rules,
|
|
20
20
|
shouldUnregister = false,
|
|
21
|
+
validate,
|
|
21
22
|
"data-testid": dataTestId
|
|
22
23
|
}) => {
|
|
23
24
|
const {
|
|
@@ -27,10 +28,11 @@ const SelectableCardField = ({
|
|
|
27
28
|
}
|
|
28
29
|
} = useController({
|
|
29
30
|
name,
|
|
31
|
+
control,
|
|
30
32
|
shouldUnregister,
|
|
31
33
|
rules: {
|
|
32
34
|
required,
|
|
33
|
-
|
|
35
|
+
validate
|
|
34
36
|
}
|
|
35
37
|
});
|
|
36
38
|
const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
|
|
@@ -7,10 +7,10 @@ const index = require("../../providers/ErrorContext/index.cjs");
|
|
|
7
7
|
const SelectableCardGroupField = ({
|
|
8
8
|
className,
|
|
9
9
|
legend,
|
|
10
|
+
control,
|
|
10
11
|
name,
|
|
11
12
|
onChange,
|
|
12
13
|
required = false,
|
|
13
|
-
rules,
|
|
14
14
|
children,
|
|
15
15
|
label = "",
|
|
16
16
|
error: customError,
|
|
@@ -18,7 +18,8 @@ const SelectableCardGroupField = ({
|
|
|
18
18
|
columns = 1,
|
|
19
19
|
showTick,
|
|
20
20
|
type = "radio",
|
|
21
|
-
shouldUnregister = false
|
|
21
|
+
shouldUnregister = false,
|
|
22
|
+
validate
|
|
22
23
|
}) => {
|
|
23
24
|
const {
|
|
24
25
|
getError
|
|
@@ -30,10 +31,11 @@ const SelectableCardGroupField = ({
|
|
|
30
31
|
}
|
|
31
32
|
} = reactHookForm.useController({
|
|
32
33
|
name,
|
|
34
|
+
control,
|
|
33
35
|
shouldUnregister,
|
|
34
36
|
rules: {
|
|
35
37
|
required,
|
|
36
|
-
|
|
38
|
+
validate
|
|
37
39
|
}
|
|
38
40
|
});
|
|
39
41
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardGroup, { legend, name, type, showTick, value: field.value, onChange: (event) => {
|
|
@@ -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,
|
|
5
|
+
type SelectableCardGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label' | 'onChange'> & Partial<Pick<ComponentProps<typeof SelectableCardGroup>, 'helper' | 'error' | 'columns' | 'children' | 'showTick' | 'type' | 'className' | 'onChange'>> & Pick<ComponentProps<typeof SelectableCardGroup>, 'legend'>;
|
|
6
6
|
export declare const SelectableCardGroupField: {
|
|
7
|
-
<TFieldValues extends FieldValues,
|
|
7
|
+
<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, legend, control, name, onChange, required, children, label, error: customError, helper, columns, showTick, type, shouldUnregister, validate, }: 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 {};
|
|
@@ -5,10 +5,10 @@ import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
|
5
5
|
const SelectableCardGroupField = ({
|
|
6
6
|
className,
|
|
7
7
|
legend,
|
|
8
|
+
control,
|
|
8
9
|
name,
|
|
9
10
|
onChange,
|
|
10
11
|
required = false,
|
|
11
|
-
rules,
|
|
12
12
|
children,
|
|
13
13
|
label = "",
|
|
14
14
|
error: customError,
|
|
@@ -16,7 +16,8 @@ const SelectableCardGroupField = ({
|
|
|
16
16
|
columns = 1,
|
|
17
17
|
showTick,
|
|
18
18
|
type = "radio",
|
|
19
|
-
shouldUnregister = false
|
|
19
|
+
shouldUnregister = false,
|
|
20
|
+
validate
|
|
20
21
|
}) => {
|
|
21
22
|
const {
|
|
22
23
|
getError
|
|
@@ -28,10 +29,11 @@ const SelectableCardGroupField = ({
|
|
|
28
29
|
}
|
|
29
30
|
} = useController({
|
|
30
31
|
name,
|
|
32
|
+
control,
|
|
31
33
|
shouldUnregister,
|
|
32
34
|
rules: {
|
|
33
35
|
required,
|
|
34
|
-
|
|
36
|
+
validate
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
return /* @__PURE__ */ jsx(SelectableCardGroup, { legend, name, type, showTick, value: field.value, onChange: (event) => {
|
|
@@ -8,11 +8,11 @@ const TagInputField = ({
|
|
|
8
8
|
className,
|
|
9
9
|
disabled,
|
|
10
10
|
id,
|
|
11
|
+
control,
|
|
11
12
|
name,
|
|
12
13
|
onChange,
|
|
13
14
|
placeholder,
|
|
14
15
|
required,
|
|
15
|
-
rules,
|
|
16
16
|
variant,
|
|
17
17
|
shouldUnregister = false,
|
|
18
18
|
"data-testid": dataTestId,
|
|
@@ -22,7 +22,8 @@ const TagInputField = ({
|
|
|
22
22
|
size,
|
|
23
23
|
success,
|
|
24
24
|
readOnly,
|
|
25
|
-
tooltip
|
|
25
|
+
tooltip,
|
|
26
|
+
validate
|
|
26
27
|
}) => {
|
|
27
28
|
const {
|
|
28
29
|
getError
|
|
@@ -34,10 +35,11 @@ const TagInputField = ({
|
|
|
34
35
|
}
|
|
35
36
|
} = reactHookForm.useController({
|
|
36
37
|
name,
|
|
38
|
+
control,
|
|
37
39
|
rules: {
|
|
38
40
|
required,
|
|
39
41
|
shouldUnregister,
|
|
40
|
-
|
|
42
|
+
validate
|
|
41
43
|
}
|
|
42
44
|
});
|
|
43
45
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.TagInput, { name: field.name, className, disabled, id, onChange: (newTags) => {
|
|
@@ -2,5 +2,5 @@ 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,
|
|
6
|
-
export declare const TagInputField: <TFieldValues extends FieldValues,
|
|
5
|
+
export type TagInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Partial<Pick<ComponentProps<typeof TagInput>, 'variant' | 'placeholder' | 'disabled' | 'className' | 'id' | 'data-testid' | 'clearable' | 'label' | 'labelDescription' | 'size' | 'success' | 'readOnly' | 'tooltip'>>;
|
|
6
|
+
export declare const TagInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, disabled, id, control, name, onChange, placeholder, required, variant, shouldUnregister, "data-testid": dataTestId, clearable, label, labelDescription, size, success, readOnly, tooltip, validate, }: TagInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -6,11 +6,11 @@ const TagInputField = ({
|
|
|
6
6
|
className,
|
|
7
7
|
disabled,
|
|
8
8
|
id,
|
|
9
|
+
control,
|
|
9
10
|
name,
|
|
10
11
|
onChange,
|
|
11
12
|
placeholder,
|
|
12
13
|
required,
|
|
13
|
-
rules,
|
|
14
14
|
variant,
|
|
15
15
|
shouldUnregister = false,
|
|
16
16
|
"data-testid": dataTestId,
|
|
@@ -20,7 +20,8 @@ const TagInputField = ({
|
|
|
20
20
|
size,
|
|
21
21
|
success,
|
|
22
22
|
readOnly,
|
|
23
|
-
tooltip
|
|
23
|
+
tooltip,
|
|
24
|
+
validate
|
|
24
25
|
}) => {
|
|
25
26
|
const {
|
|
26
27
|
getError
|
|
@@ -32,10 +33,11 @@ const TagInputField = ({
|
|
|
32
33
|
}
|
|
33
34
|
} = useController({
|
|
34
35
|
name,
|
|
36
|
+
control,
|
|
35
37
|
rules: {
|
|
36
38
|
required,
|
|
37
39
|
shouldUnregister,
|
|
38
|
-
|
|
40
|
+
validate
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
43
|
return /* @__PURE__ */ jsx(TagInput, { name: field.name, className, disabled, id, onChange: (newTags) => {
|