@ultraviolet/form 2.13.2 → 2.13.3
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.d.ts +10 -0
- package/dist/components/CheckboxField/index.js +40 -41
- package/dist/components/CheckboxGroupField/index.d.ts +32 -0
- package/dist/components/CheckboxGroupField/index.js +59 -53
- package/dist/components/DateField/index.d.ts +16 -0
- package/dist/components/DateField/index.js +53 -58
- package/dist/components/Form/defaultErrors.d.ts +2 -0
- package/dist/components/Form/defaultErrors.js +20 -19
- package/dist/components/Form/index.d.ts +69 -0
- package/dist/components/Form/index.js +52 -57
- package/dist/components/KeyValueField/index.d.ts +33 -0
- package/dist/components/KeyValueField/index.js +61 -60
- package/dist/components/NumberInputField/index.d.ts +13 -0
- package/dist/components/NumberInputField/index.js +39 -45
- package/dist/components/NumberInputFieldV2/index.d.ts +11 -0
- package/dist/components/NumberInputFieldV2/index.js +45 -51
- package/dist/components/RadioField/index.d.ts +12 -0
- package/dist/components/RadioField/index.js +36 -42
- package/dist/components/RadioGroupField/index.d.ts +28 -0
- package/dist/components/RadioGroupField/index.js +31 -32
- package/dist/components/SelectInputField/index.d.ts +82 -0
- package/dist/components/SelectInputField/index.js +90 -83
- package/dist/components/SelectInputFieldV2/index.d.ts +7 -0
- package/dist/components/SelectInputFieldV2/index.js +60 -60
- package/dist/components/SelectableCardField/index.d.ts +9 -0
- package/dist/components/SelectableCardField/index.js +49 -44
- package/dist/components/SelectableCardGroupField/index.d.ts +42 -0
- package/dist/components/SelectableCardGroupField/index.js +42 -41
- package/dist/components/Submit/index.d.ts +17 -0
- package/dist/components/Submit/index.js +27 -27
- package/dist/components/SubmitErrorAlert/index.d.ts +3 -0
- package/dist/components/SubmitErrorAlert/index.js +9 -17
- package/dist/components/TagInputField/index.d.ts +6 -0
- package/dist/components/TagInputField/index.js +35 -38
- package/dist/components/TextAreaField/index.d.ts +11 -0
- package/dist/components/TextAreaField/index.js +57 -56
- package/dist/components/TextInputField/index.d.ts +18 -0
- package/dist/components/TextInputField/index.js +82 -81
- package/dist/components/TextInputFieldV2/index.d.ts +12 -0
- package/dist/components/TextInputFieldV2/index.js +73 -72
- package/dist/components/TimeField/index.d.ts +9 -0
- package/dist/components/TimeField/index.js +51 -49
- package/dist/components/ToggleField/index.d.ts +10 -0
- package/dist/components/ToggleField/index.js +32 -31
- package/dist/components/ToggleGroupField/index.d.ts +26 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +4 -3
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useField.d.ts +34 -0
- package/dist/hooks/useField.js +7 -30
- package/dist/hooks/useFieldArray.d.ts +21 -0
- package/dist/hooks/useFieldArray.js +9 -22
- package/dist/hooks/useForm.d.ts +23 -0
- package/dist/hooks/useForm.js +8 -25
- package/dist/hooks/useFormState.d.ts +39 -0
- package/dist/hooks/useFormState.js +6 -23
- package/dist/hooks/useOnFieldChange.d.ts +3 -0
- package/dist/hooks/useOnFieldChange.js +10 -11
- package/dist/index.d.ts +7 -555
- package/dist/index.js +66 -29
- package/dist/mocks/index.d.ts +1 -0
- package/dist/mocks/mockErrors.d.ts +3 -0
- package/dist/providers/ErrorContext/index.d.ts +14 -0
- package/dist/providers/ErrorContext/index.js +30 -29
- package/dist/providers/index.d.ts +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/validators/index.d.ts +5 -0
- package/dist/validators/maxDate.d.ts +1 -0
- package/dist/validators/maxDate.js +4 -3
- package/dist/validators/minDate.d.ts +1 -0
- package/dist/validators/minDate.js +4 -3
- package/package.json +11 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SelectableCard } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
type SelectableCardFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TName>, 'label' | 'onChange'> & Partial<Pick<ComponentProps<typeof SelectableCard>, 'disabled' | 'onBlur' | 'onChange' | 'onFocus' | 'showTick' | 'type' | 'id' | 'children' | 'tooltip' | 'label' | 'data-testid'>> & {
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const SelectableCardField: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, value, onChange, showTick, type, disabled, children, className, onFocus, onBlur, required, tooltip, id, label, rules, shouldUnregister, "data-testid": dataTestId, }: SelectableCardFieldProps<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { SelectableCard } from "@ultraviolet/ui";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
5
4
|
const SelectableCardField = ({
|
|
6
5
|
name,
|
|
7
6
|
value,
|
|
@@ -19,13 +18,11 @@ const SelectableCardField = ({
|
|
|
19
18
|
label,
|
|
20
19
|
rules,
|
|
21
20
|
shouldUnregister = false,
|
|
22
|
-
|
|
21
|
+
"data-testid": dataTestId
|
|
23
22
|
}) => {
|
|
24
23
|
const {
|
|
25
24
|
field,
|
|
26
|
-
fieldState: {
|
|
27
|
-
error
|
|
28
|
-
}
|
|
25
|
+
fieldState: { error }
|
|
29
26
|
} = useController({
|
|
30
27
|
name,
|
|
31
28
|
shouldUnregister,
|
|
@@ -34,42 +31,50 @@ const SelectableCardField = ({
|
|
|
34
31
|
...rules
|
|
35
32
|
}
|
|
36
33
|
});
|
|
37
|
-
const isChecked = type ===
|
|
38
|
-
return jsx(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
34
|
+
const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
SelectableCard,
|
|
37
|
+
{
|
|
38
|
+
isError: !!error,
|
|
39
|
+
showTick,
|
|
40
|
+
checked: isChecked,
|
|
41
|
+
className,
|
|
42
|
+
disabled,
|
|
43
|
+
onChange: (event) => {
|
|
44
|
+
if (type === "checkbox") {
|
|
45
|
+
const fieldValue = field.value ?? [];
|
|
46
|
+
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
47
|
+
field.onChange(
|
|
48
|
+
fieldValue?.filter(
|
|
49
|
+
(currentValue) => currentValue !== event.currentTarget.value
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
} else {
|
|
53
|
+
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
54
|
+
}
|
|
49
55
|
} else {
|
|
50
|
-
field.onChange(
|
|
56
|
+
field.onChange(event);
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
58
|
+
onChange?.(event);
|
|
59
|
+
},
|
|
60
|
+
onBlur: (event) => {
|
|
61
|
+
field.onBlur();
|
|
62
|
+
onBlur?.(event);
|
|
63
|
+
},
|
|
64
|
+
onFocus: (event) => {
|
|
65
|
+
onFocus?.(event);
|
|
66
|
+
},
|
|
67
|
+
type,
|
|
68
|
+
id,
|
|
69
|
+
tooltip,
|
|
70
|
+
label,
|
|
71
|
+
value: value ?? "",
|
|
72
|
+
name: field.name,
|
|
73
|
+
"data-testid": dataTestId,
|
|
74
|
+
children
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
SelectableCardField
|
|
73
80
|
};
|
|
74
|
-
|
|
75
|
-
export { SelectableCardField };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SelectableCardGroup } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps, JSX } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
type SelectableCardGroupFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Omit<BaseFieldProps<TFieldValues, TName>, 'label' | 'onChange'> & Partial<Pick<ComponentProps<typeof SelectableCardGroup>, 'helper' | 'error' | 'columns' | 'children' | 'showTick' | 'type' | 'className' | 'onChange'>> & Pick<ComponentProps<typeof SelectableCardGroup>, 'legend'>;
|
|
6
|
+
export declare const SelectableCardGroupField: {
|
|
7
|
+
<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, legend, name, onChange, required, rules, children, label, error: customError, helper, columns, showTick, type, shouldUnregister, }: SelectableCardGroupFieldProps<TFieldValues, TName>): JSX.Element;
|
|
8
|
+
Card: ({ value, disabled, children, className, isError, onFocus, onBlur, tooltip, id, label, "data-testid": dataTestId, }: {
|
|
9
|
+
value: string | number;
|
|
10
|
+
onBlur?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
|
|
11
|
+
disabled?: boolean | undefined;
|
|
12
|
+
children?: import("react").ReactNode | (({ disabled, checked, }: Pick<{
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
children?: import("react").ReactNode | any;
|
|
15
|
+
value: string | number;
|
|
16
|
+
onChange: import("react").ChangeEventHandler<HTMLInputElement>;
|
|
17
|
+
showTick?: boolean | undefined;
|
|
18
|
+
type?: "checkbox" | "radio" | undefined;
|
|
19
|
+
disabled?: boolean | undefined;
|
|
20
|
+
checked?: boolean | undefined;
|
|
21
|
+
className?: string | undefined;
|
|
22
|
+
isError?: boolean | undefined;
|
|
23
|
+
onFocus?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
|
|
24
|
+
onBlur?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
|
|
25
|
+
id?: string | undefined;
|
|
26
|
+
tooltip?: string | undefined;
|
|
27
|
+
label?: import("react").ReactNode;
|
|
28
|
+
'data-testid'?: string | undefined;
|
|
29
|
+
}, "disabled" | "checked">) => import("react").ReactNode);
|
|
30
|
+
className?: string | undefined;
|
|
31
|
+
ref?: import("react").LegacyRef<HTMLDivElement> | undefined;
|
|
32
|
+
name?: string | undefined;
|
|
33
|
+
label?: import("react").ReactNode;
|
|
34
|
+
onFocus?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
|
|
35
|
+
id?: string | undefined;
|
|
36
|
+
'data-testid'?: string | undefined;
|
|
37
|
+
tooltip?: string | undefined;
|
|
38
|
+
key?: import("react").Key | null | undefined;
|
|
39
|
+
isError?: boolean | undefined;
|
|
40
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useErrors } from
|
|
5
|
-
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { SelectableCardGroup } from "@ultraviolet/ui";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
4
|
+
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
6
5
|
const SelectableCardGroupField = ({
|
|
7
6
|
className,
|
|
8
7
|
legend,
|
|
@@ -11,22 +10,18 @@ const SelectableCardGroupField = ({
|
|
|
11
10
|
required = false,
|
|
12
11
|
rules,
|
|
13
12
|
children,
|
|
14
|
-
label =
|
|
13
|
+
label = "",
|
|
15
14
|
error: customError,
|
|
16
15
|
helper,
|
|
17
16
|
columns = 1,
|
|
18
17
|
showTick,
|
|
19
|
-
type =
|
|
18
|
+
type = "radio",
|
|
20
19
|
shouldUnregister = false
|
|
21
20
|
}) => {
|
|
22
|
-
const {
|
|
23
|
-
getError
|
|
24
|
-
} = useErrors();
|
|
21
|
+
const { getError } = useErrors();
|
|
25
22
|
const {
|
|
26
23
|
field,
|
|
27
|
-
fieldState: {
|
|
28
|
-
error
|
|
29
|
-
}
|
|
24
|
+
fieldState: { error }
|
|
30
25
|
} = useController({
|
|
31
26
|
name,
|
|
32
27
|
shouldUnregister,
|
|
@@ -35,35 +30,41 @@ const SelectableCardGroupField = ({
|
|
|
35
30
|
...rules
|
|
36
31
|
}
|
|
37
32
|
});
|
|
38
|
-
return jsx(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
33
|
+
return /* @__PURE__ */ jsx(
|
|
34
|
+
SelectableCardGroup,
|
|
35
|
+
{
|
|
36
|
+
legend,
|
|
37
|
+
name,
|
|
38
|
+
type,
|
|
39
|
+
showTick,
|
|
40
|
+
value: field.value,
|
|
41
|
+
onChange: (event) => {
|
|
42
|
+
if (type === "checkbox") {
|
|
43
|
+
const fieldValue = field.value ?? [];
|
|
44
|
+
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
45
|
+
field.onChange(
|
|
46
|
+
fieldValue?.filter(
|
|
47
|
+
(currentValue) => currentValue !== event.currentTarget.value
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
52
|
+
}
|
|
49
53
|
} else {
|
|
50
|
-
field.onChange(
|
|
54
|
+
field.onChange(event);
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
helper: helper,
|
|
63
|
-
required: required,
|
|
64
|
-
children: children
|
|
65
|
-
});
|
|
56
|
+
onChange?.(event);
|
|
57
|
+
},
|
|
58
|
+
error: getError({ label }, error) ?? customError,
|
|
59
|
+
className,
|
|
60
|
+
columns,
|
|
61
|
+
helper,
|
|
62
|
+
required,
|
|
63
|
+
children
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
66
|
};
|
|
67
67
|
SelectableCardGroupField.Card = SelectableCardGroup.Card;
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
export {
|
|
69
|
+
SelectableCardGroupField
|
|
70
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Button } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
3
|
+
type SubmitProps = {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
icon?: ComponentProps<typeof Button>['icon'];
|
|
8
|
+
iconPosition?: ComponentProps<typeof Button>['iconPosition'];
|
|
9
|
+
size?: ComponentProps<typeof Button>['size'];
|
|
10
|
+
variant?: ComponentProps<typeof Button>['variant'];
|
|
11
|
+
sentiment?: ComponentProps<typeof Button>['sentiment'];
|
|
12
|
+
tooltip?: ComponentProps<typeof Button>['tooltip'];
|
|
13
|
+
fullWidth?: ComponentProps<typeof Button>['fullWidth'];
|
|
14
|
+
onClick?: ComponentProps<typeof Button>['onClick'];
|
|
15
|
+
};
|
|
16
|
+
export declare const Submit: ({ children, className, disabled, icon, iconPosition, size, variant, sentiment, tooltip, fullWidth, onClick, }: SubmitProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Button } from "@ultraviolet/ui";
|
|
3
|
+
import { useFormState } from "react-hook-form";
|
|
5
4
|
const Submit = ({
|
|
6
5
|
children,
|
|
7
6
|
className,
|
|
@@ -9,32 +8,33 @@ const Submit = ({
|
|
|
9
8
|
icon,
|
|
10
9
|
iconPosition,
|
|
11
10
|
size,
|
|
12
|
-
variant =
|
|
13
|
-
sentiment =
|
|
11
|
+
variant = "filled",
|
|
12
|
+
sentiment = "primary",
|
|
14
13
|
tooltip,
|
|
15
14
|
fullWidth,
|
|
16
15
|
onClick
|
|
17
16
|
}) => {
|
|
18
|
-
const {
|
|
19
|
-
isSubmitting,
|
|
20
|
-
isValid
|
|
21
|
-
} = useFormState();
|
|
17
|
+
const { isSubmitting, isValid } = useFormState();
|
|
22
18
|
const isDisabled = disabled || isSubmitting || !isValid;
|
|
23
|
-
return jsx(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
Button,
|
|
21
|
+
{
|
|
22
|
+
className,
|
|
23
|
+
disabled: isDisabled,
|
|
24
|
+
icon,
|
|
25
|
+
iconPosition,
|
|
26
|
+
isLoading: isSubmitting,
|
|
27
|
+
size,
|
|
28
|
+
type: "submit",
|
|
29
|
+
variant,
|
|
30
|
+
sentiment,
|
|
31
|
+
tooltip,
|
|
32
|
+
fullWidth,
|
|
33
|
+
onClick,
|
|
34
|
+
children
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
Submit
|
|
38
40
|
};
|
|
39
|
-
|
|
40
|
-
export { Submit };
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
className
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = useFormState();
|
|
11
|
-
return errors?.root?.['submit']?.message ? jsx(Alert, {
|
|
12
|
-
className: className,
|
|
13
|
-
sentiment: "danger",
|
|
14
|
-
children: errors.root['submit'].message
|
|
15
|
-
}) : null;
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Alert } from "@ultraviolet/ui";
|
|
3
|
+
import { useFormState } from "react-hook-form";
|
|
4
|
+
const SubmitErrorAlert = ({ className }) => {
|
|
5
|
+
const { errors } = useFormState();
|
|
6
|
+
return errors?.root?.["submit"]?.message ? /* @__PURE__ */ jsx(Alert, { className, sentiment: "danger", children: errors.root["submit"].message }) : null;
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
SubmitErrorAlert
|
|
16
10
|
};
|
|
17
|
-
|
|
18
|
-
export { SubmitErrorAlert };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TagInput } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
export type TagInputFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & 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, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, disabled, id, name, onChange, placeholder, required, rules, variant, shouldUnregister, "data-testid": dataTestId, clearable, label, labelDescription, size, success, readOnly, tooltip, }: TagInputFieldProps<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useErrors } from
|
|
5
|
-
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { TagInput } from "@ultraviolet/ui";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
4
|
+
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
6
5
|
const TagInputField = ({
|
|
7
6
|
className,
|
|
8
7
|
disabled,
|
|
@@ -14,7 +13,7 @@ const TagInputField = ({
|
|
|
14
13
|
rules,
|
|
15
14
|
variant,
|
|
16
15
|
shouldUnregister = false,
|
|
17
|
-
|
|
16
|
+
"data-testid": dataTestId,
|
|
18
17
|
clearable,
|
|
19
18
|
label,
|
|
20
19
|
labelDescription,
|
|
@@ -23,14 +22,10 @@ const TagInputField = ({
|
|
|
23
22
|
readOnly,
|
|
24
23
|
tooltip
|
|
25
24
|
}) => {
|
|
26
|
-
const {
|
|
27
|
-
getError
|
|
28
|
-
} = useErrors();
|
|
25
|
+
const { getError } = useErrors();
|
|
29
26
|
const {
|
|
30
27
|
field,
|
|
31
|
-
fieldState: {
|
|
32
|
-
error
|
|
33
|
-
}
|
|
28
|
+
fieldState: { error }
|
|
34
29
|
} = useController({
|
|
35
30
|
name,
|
|
36
31
|
rules: {
|
|
@@ -39,30 +34,32 @@ const TagInputField = ({
|
|
|
39
34
|
...rules
|
|
40
35
|
}
|
|
41
36
|
});
|
|
42
|
-
return jsx(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onChange
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
TagInput,
|
|
39
|
+
{
|
|
40
|
+
name: field.name,
|
|
41
|
+
className,
|
|
42
|
+
disabled,
|
|
43
|
+
id,
|
|
44
|
+
onChange: (newTags) => {
|
|
45
|
+
field.onChange(newTags);
|
|
46
|
+
onChange?.(newTags);
|
|
47
|
+
},
|
|
48
|
+
placeholder,
|
|
49
|
+
variant,
|
|
50
|
+
value: field.value,
|
|
51
|
+
"data-testid": dataTestId,
|
|
52
|
+
clearable,
|
|
53
|
+
label,
|
|
54
|
+
labelDescription,
|
|
55
|
+
size,
|
|
56
|
+
success,
|
|
57
|
+
error: getError({ label: label ?? "" }, error),
|
|
58
|
+
readOnly,
|
|
59
|
+
tooltip
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
TagInputField
|
|
66
65
|
};
|
|
67
|
-
|
|
68
|
-
export { TagInputField };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TextArea } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
export type TextAreaFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Omit<ComponentProps<typeof TextArea>, 'value' | 'error' | 'name' | 'onChange'> & {
|
|
6
|
+
regex?: (RegExp | RegExp[])[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* This component offers a form field based on Ultraviolet UI TextArea component
|
|
10
|
+
*/
|
|
11
|
+
export declare const TextAreaField: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ autoFocus, clearable, className, tabIndex, "data-testid": dataTestId, disabled, helper, label, labelDescription, onChange, minLength, maxLength, name, onFocus, onBlur, placeholder, readOnly, required, rows, success, tooltip, validate, regex: regexes, }: TextAreaFieldProps<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useErrors } from
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This component offers a form field based on Ultraviolet UI TextArea component
|
|
8
|
-
*/
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { TextArea } from "@ultraviolet/ui";
|
|
3
|
+
import { useController } from "react-hook-form";
|
|
4
|
+
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
9
5
|
const TextAreaField = ({
|
|
10
6
|
autoFocus,
|
|
11
7
|
clearable,
|
|
12
8
|
className,
|
|
13
9
|
tabIndex,
|
|
14
|
-
|
|
10
|
+
"data-testid": dataTestId,
|
|
15
11
|
disabled,
|
|
16
12
|
helper,
|
|
17
13
|
label,
|
|
@@ -31,67 +27,72 @@ const TextAreaField = ({
|
|
|
31
27
|
validate,
|
|
32
28
|
regex: regexes
|
|
33
29
|
}) => {
|
|
34
|
-
const {
|
|
35
|
-
getError
|
|
36
|
-
} = useErrors();
|
|
30
|
+
const { getError } = useErrors();
|
|
37
31
|
const {
|
|
38
32
|
field,
|
|
39
|
-
fieldState: {
|
|
40
|
-
error
|
|
41
|
-
}
|
|
33
|
+
fieldState: { error }
|
|
42
34
|
} = useController({
|
|
43
35
|
name,
|
|
44
36
|
rules: {
|
|
45
37
|
required,
|
|
46
38
|
validate: {
|
|
47
|
-
...
|
|
48
|
-
pattern: value => regexes.every(
|
|
49
|
-
|
|
39
|
+
...regexes ? {
|
|
40
|
+
pattern: (value) => regexes.every(
|
|
41
|
+
(regex) => value === void 0 || value === "" || (Array.isArray(regex) ? regex.some((regexOr) => regexOr.test(value)) : regex.test(value))
|
|
42
|
+
)
|
|
43
|
+
} : {},
|
|
50
44
|
...validate
|
|
51
45
|
},
|
|
52
46
|
minLength,
|
|
53
47
|
maxLength
|
|
54
48
|
}
|
|
55
49
|
});
|
|
56
|
-
return jsx(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
TextArea,
|
|
52
|
+
{
|
|
53
|
+
autoFocus,
|
|
54
|
+
className,
|
|
55
|
+
clearable,
|
|
56
|
+
"data-testid": dataTestId,
|
|
57
|
+
disabled,
|
|
58
|
+
error: getError(
|
|
59
|
+
{
|
|
60
|
+
regex: regexes,
|
|
61
|
+
minLength,
|
|
62
|
+
maxLength,
|
|
63
|
+
label,
|
|
64
|
+
value: field.value
|
|
65
|
+
},
|
|
66
|
+
error
|
|
67
|
+
),
|
|
68
|
+
helper,
|
|
69
|
+
label,
|
|
70
|
+
labelDescription,
|
|
64
71
|
minLength,
|
|
65
72
|
maxLength,
|
|
66
|
-
|
|
73
|
+
name,
|
|
74
|
+
onBlur: (event) => {
|
|
75
|
+
onBlur?.(event);
|
|
76
|
+
field.onBlur();
|
|
77
|
+
},
|
|
78
|
+
onChange: (event) => {
|
|
79
|
+
field.onChange(event);
|
|
80
|
+
onChange?.(event);
|
|
81
|
+
},
|
|
82
|
+
onFocus: (event) => {
|
|
83
|
+
onFocus?.(event);
|
|
84
|
+
},
|
|
85
|
+
placeholder,
|
|
86
|
+
readOnly,
|
|
87
|
+
required,
|
|
88
|
+
rows,
|
|
89
|
+
success,
|
|
90
|
+
tabIndex,
|
|
91
|
+
tooltip,
|
|
67
92
|
value: field.value
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
maxLength: maxLength,
|
|
74
|
-
name: name,
|
|
75
|
-
onBlur: event => {
|
|
76
|
-
onBlur?.(event);
|
|
77
|
-
field.onBlur();
|
|
78
|
-
},
|
|
79
|
-
onChange: event => {
|
|
80
|
-
field.onChange(event);
|
|
81
|
-
onChange?.(event);
|
|
82
|
-
},
|
|
83
|
-
onFocus: event => {
|
|
84
|
-
onFocus?.(event);
|
|
85
|
-
},
|
|
86
|
-
placeholder: placeholder,
|
|
87
|
-
readOnly: readOnly,
|
|
88
|
-
required: required,
|
|
89
|
-
rows: rows,
|
|
90
|
-
success: success,
|
|
91
|
-
tabIndex: tabIndex,
|
|
92
|
-
tooltip: tooltip,
|
|
93
|
-
value: field.value
|
|
94
|
-
});
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
TextAreaField
|
|
95
98
|
};
|
|
96
|
-
|
|
97
|
-
export { TextAreaField };
|