@ultraviolet/form 2.13.2 → 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.d.ts +10 -0
- package/dist/components/CheckboxField/index.js +17 -35
- package/dist/components/CheckboxGroupField/index.d.ts +32 -0
- package/dist/components/CheckboxGroupField/index.js +24 -35
- package/dist/components/DateField/index.d.ts +16 -0
- package/dist/components/DateField/index.js +33 -53
- 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 +41 -54
- package/dist/components/KeyValueField/index.d.ts +33 -0
- package/dist/components/KeyValueField/index.js +23 -56
- package/dist/components/NumberInputField/index.d.ts +13 -0
- package/dist/components/NumberInputField/index.js +18 -39
- package/dist/components/NumberInputFieldV2/index.d.ts +11 -0
- package/dist/components/NumberInputFieldV2/index.js +20 -46
- package/dist/components/RadioField/index.d.ts +12 -0
- package/dist/components/RadioField/index.js +18 -36
- package/dist/components/RadioGroupField/index.d.ts +28 -0
- package/dist/components/RadioGroupField/index.js +15 -26
- package/dist/components/SelectInputField/index.d.ts +82 -0
- package/dist/components/SelectInputField/index.js +31 -61
- package/dist/components/SelectInputFieldV2/index.d.ts +7 -0
- package/dist/components/SelectInputFieldV2/index.js +18 -52
- package/dist/components/SelectableCardField/index.d.ts +9 -0
- package/dist/components/SelectableCardField/index.js +24 -41
- package/dist/components/SelectableCardGroupField/index.d.ts +42 -0
- package/dist/components/SelectableCardGroupField/index.js +22 -35
- package/dist/components/Submit/index.d.ts +17 -0
- package/dist/components/Submit/index.js +9 -23
- package/dist/components/SubmitErrorAlert/index.d.ts +3 -0
- package/dist/components/SubmitErrorAlert/index.js +7 -11
- package/dist/components/TagInputField/index.d.ts +6 -0
- package/dist/components/TagInputField/index.js +14 -32
- package/dist/components/TextAreaField/index.d.ts +11 -0
- package/dist/components/TextAreaField/index.js +25 -52
- package/dist/components/TextInputField/index.d.ts +18 -0
- package/dist/components/TextInputField/index.js +37 -76
- package/dist/components/TextInputFieldV2/index.d.ts +12 -0
- package/dist/components/TextInputFieldV2/index.js +30 -66
- package/dist/components/TimeField/index.d.ts +9 -0
- package/dist/components/TimeField/index.js +23 -46
- package/dist/components/ToggleField/index.d.ts +10 -0
- package/dist/components/ToggleField/index.js +15 -28
- 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 +4 -20
- package/dist/hooks/useFieldArray.d.ts +21 -0
- package/dist/hooks/useFieldArray.js +6 -9
- package/dist/hooks/useForm.d.ts +23 -0
- package/dist/hooks/useForm.js +7 -19
- package/dist/hooks/useFormState.d.ts +39 -0
- package/dist/hooks/useFormState.js +5 -20
- package/dist/hooks/useOnFieldChange.d.ts +3 -0
- package/dist/hooks/useOnFieldChange.js +6 -6
- 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 +11 -13
- 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 +12 -6
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SelectInputV2 } 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 SelectInputFieldV2Props<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & 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, TName 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, rules, shouldUnregister, }: SelectInputFieldV2Props<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useErrors } from
|
|
6
|
-
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { SelectInputV2 } from "@ultraviolet/ui";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { useController } from "react-hook-form";
|
|
5
|
+
import { useErrors } from "../../providers/ErrorContext/index.js";
|
|
7
6
|
const SelectInputFieldV2 = ({
|
|
8
7
|
autofocus,
|
|
9
8
|
className,
|
|
10
9
|
id,
|
|
11
|
-
label =
|
|
10
|
+
label = "",
|
|
12
11
|
onFocus,
|
|
13
12
|
onBlur,
|
|
14
13
|
placeholder,
|
|
15
14
|
readOnly,
|
|
16
15
|
required,
|
|
17
16
|
size,
|
|
18
|
-
|
|
17
|
+
"data-testid": dataTestId,
|
|
19
18
|
disabled,
|
|
20
19
|
placeholderSearch,
|
|
21
20
|
helper,
|
|
@@ -34,7 +33,7 @@ const SelectInputFieldV2 = ({
|
|
|
34
33
|
selectAll,
|
|
35
34
|
selectAllGroup,
|
|
36
35
|
name,
|
|
37
|
-
|
|
36
|
+
"aria-label": ariaLabel,
|
|
38
37
|
optionalInfoPlacement,
|
|
39
38
|
rules,
|
|
40
39
|
shouldUnregister = false
|
|
@@ -55,50 +54,17 @@ const SelectInputFieldV2 = ({
|
|
|
55
54
|
const {
|
|
56
55
|
getError
|
|
57
56
|
} = useErrors();
|
|
58
|
-
const handleChange = useCallback(value => {
|
|
57
|
+
const handleChange = useCallback((value) => {
|
|
59
58
|
onChange?.(value);
|
|
60
59
|
field.onChange(value);
|
|
61
60
|
}, [onChange, field]);
|
|
62
|
-
return jsx(SelectInputV2, {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
label: label,
|
|
72
|
-
onFocus: onFocus,
|
|
73
|
-
onBlur: event => {
|
|
74
|
-
field.onBlur();
|
|
75
|
-
onBlur?.(event);
|
|
76
|
-
},
|
|
77
|
-
placeholder: placeholder,
|
|
78
|
-
readOnly: readOnly,
|
|
79
|
-
multiselect: multiselect,
|
|
80
|
-
value: field.value,
|
|
81
|
-
placeholderSearch: placeholderSearch,
|
|
82
|
-
helper: helper,
|
|
83
|
-
emptyState: emptyState,
|
|
84
|
-
searchable: searchable,
|
|
85
|
-
clearable: clearable,
|
|
86
|
-
descriptionDirection: descriptionDirection,
|
|
87
|
-
footer: footer,
|
|
88
|
-
labelDescription: labelDescription,
|
|
89
|
-
error: getError({
|
|
90
|
-
label
|
|
91
|
-
}, error),
|
|
92
|
-
success: success,
|
|
93
|
-
loadMore: loadMore,
|
|
94
|
-
isLoading: isLoading,
|
|
95
|
-
selectAll: selectAll,
|
|
96
|
-
selectAllGroup: selectAllGroup,
|
|
97
|
-
autofocus: autofocus,
|
|
98
|
-
optionalInfoPlacement: optionalInfoPlacement,
|
|
99
|
-
"aria-label": ariaLabel,
|
|
100
|
-
onChange: handleChange
|
|
101
|
-
});
|
|
61
|
+
return /* @__PURE__ */ jsx(SelectInputV2, { name: field.name, options, required, size, "data-testid": dataTestId, className, disabled, id, label, onFocus, onBlur: (event) => {
|
|
62
|
+
field.onBlur();
|
|
63
|
+
onBlur?.(event);
|
|
64
|
+
}, placeholder, readOnly, multiselect, value: field.value, placeholderSearch, helper, emptyState, searchable, clearable, descriptionDirection, footer, labelDescription, error: getError({
|
|
65
|
+
label
|
|
66
|
+
}, error), success, loadMore, isLoading, selectAll, selectAllGroup, autofocus, optionalInfoPlacement, "aria-label": ariaLabel, onChange: handleChange });
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
SelectInputFieldV2
|
|
102
70
|
};
|
|
103
|
-
|
|
104
|
-
export { SelectInputFieldV2 };
|
|
@@ -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,7 +18,7 @@ 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,
|
|
@@ -34,42 +33,26 @@ const SelectableCardField = ({
|
|
|
34
33
|
...rules
|
|
35
34
|
}
|
|
36
35
|
});
|
|
37
|
-
const isChecked = type ===
|
|
38
|
-
return jsx(SelectableCard, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
disabled: disabled,
|
|
44
|
-
onChange: event => {
|
|
45
|
-
if (type === 'checkbox') {
|
|
46
|
-
const fieldValue = field.value ?? [];
|
|
47
|
-
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
48
|
-
field.onChange(fieldValue?.filter(currentValue => currentValue !== event.currentTarget.value));
|
|
49
|
-
} else {
|
|
50
|
-
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
51
|
-
}
|
|
36
|
+
const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
|
|
37
|
+
return /* @__PURE__ */ jsx(SelectableCard, { isError: !!error, showTick, checked: isChecked, className, disabled, onChange: (event) => {
|
|
38
|
+
if (type === "checkbox") {
|
|
39
|
+
const fieldValue = field.value ?? [];
|
|
40
|
+
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
41
|
+
field.onChange(fieldValue?.filter((currentValue) => currentValue !== event.currentTarget.value));
|
|
52
42
|
} else {
|
|
53
|
-
field.onChange(event);
|
|
43
|
+
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
54
44
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
value: value ?? '',
|
|
69
|
-
name: field.name,
|
|
70
|
-
"data-testid": dataTestId,
|
|
71
|
-
children: children
|
|
72
|
-
});
|
|
45
|
+
} else {
|
|
46
|
+
field.onChange(event);
|
|
47
|
+
}
|
|
48
|
+
onChange?.(event);
|
|
49
|
+
}, onBlur: (event) => {
|
|
50
|
+
field.onBlur();
|
|
51
|
+
onBlur?.(event);
|
|
52
|
+
}, onFocus: (event) => {
|
|
53
|
+
onFocus?.(event);
|
|
54
|
+
}, type, id, tooltip, label, value: value ?? "", name: field.name, "data-testid": dataTestId, children });
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
SelectableCardField
|
|
73
58
|
};
|
|
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,12 +10,12 @@ 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
21
|
const {
|
|
@@ -35,35 +34,23 @@ const SelectableCardGroupField = ({
|
|
|
35
34
|
...rules
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
|
-
return jsx(SelectableCardGroup, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
value: field.value,
|
|
44
|
-
onChange: event => {
|
|
45
|
-
if (type === 'checkbox') {
|
|
46
|
-
const fieldValue = field.value ?? [];
|
|
47
|
-
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
48
|
-
field.onChange(fieldValue?.filter(currentValue => currentValue !== event.currentTarget.value));
|
|
49
|
-
} else {
|
|
50
|
-
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
51
|
-
}
|
|
37
|
+
return /* @__PURE__ */ jsx(SelectableCardGroup, { legend, name, type, showTick, value: field.value, onChange: (event) => {
|
|
38
|
+
if (type === "checkbox") {
|
|
39
|
+
const fieldValue = field.value ?? [];
|
|
40
|
+
if (fieldValue?.includes(event.currentTarget.value)) {
|
|
41
|
+
field.onChange(fieldValue?.filter((currentValue) => currentValue !== event.currentTarget.value));
|
|
52
42
|
} else {
|
|
53
|
-
field.onChange(event);
|
|
43
|
+
field.onChange([...fieldValue, event.currentTarget.value]);
|
|
54
44
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
helper: helper,
|
|
63
|
-
required: required,
|
|
64
|
-
children: children
|
|
65
|
-
});
|
|
45
|
+
} else {
|
|
46
|
+
field.onChange(event);
|
|
47
|
+
}
|
|
48
|
+
onChange?.(event);
|
|
49
|
+
}, error: getError({
|
|
50
|
+
label
|
|
51
|
+
}, error) ?? customError, className, columns, helper, required, children });
|
|
66
52
|
};
|
|
67
53
|
SelectableCardGroupField.Card = SelectableCardGroup.Card;
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
export {
|
|
55
|
+
SelectableCardGroupField
|
|
56
|
+
};
|
|
@@ -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,8 +8,8 @@ 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
|
|
@@ -20,21 +19,8 @@ const Submit = ({
|
|
|
20
19
|
isValid
|
|
21
20
|
} = useFormState();
|
|
22
21
|
const isDisabled = disabled || isSubmitting || !isValid;
|
|
23
|
-
return jsx(Button, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
iconPosition: iconPosition,
|
|
28
|
-
isLoading: isSubmitting,
|
|
29
|
-
size: size,
|
|
30
|
-
type: "submit",
|
|
31
|
-
variant: variant,
|
|
32
|
-
sentiment: sentiment,
|
|
33
|
-
tooltip: tooltip,
|
|
34
|
-
fullWidth: fullWidth,
|
|
35
|
-
onClick: onClick,
|
|
36
|
-
children: children
|
|
37
|
-
});
|
|
22
|
+
return /* @__PURE__ */ jsx(Button, { className, disabled: isDisabled, icon, iconPosition, isLoading: isSubmitting, size, type: "submit", variant, sentiment, tooltip, fullWidth, onClick, children });
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
Submit
|
|
38
26
|
};
|
|
39
|
-
|
|
40
|
-
export { Submit };
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { Alert } from "@ultraviolet/ui";
|
|
3
|
+
import { useFormState } from "react-hook-form";
|
|
5
4
|
const SubmitErrorAlert = ({
|
|
6
5
|
className
|
|
7
6
|
}) => {
|
|
8
7
|
const {
|
|
9
8
|
errors
|
|
10
9
|
} = useFormState();
|
|
11
|
-
return errors?.root?.[
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}) : null;
|
|
10
|
+
return errors?.root?.["submit"]?.message ? /* @__PURE__ */ jsx(Alert, { className, sentiment: "danger", children: errors.root["submit"].message }) : null;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
SubmitErrorAlert
|
|
16
14
|
};
|
|
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,
|
|
@@ -39,30 +38,13 @@ const TagInputField = ({
|
|
|
39
38
|
...rules
|
|
40
39
|
}
|
|
41
40
|
});
|
|
42
|
-
return jsx(TagInput, {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
placeholder: placeholder,
|
|
52
|
-
variant: variant,
|
|
53
|
-
value: field.value,
|
|
54
|
-
"data-testid": dataTestId,
|
|
55
|
-
clearable: clearable,
|
|
56
|
-
label: label,
|
|
57
|
-
labelDescription: labelDescription,
|
|
58
|
-
size: size,
|
|
59
|
-
success: success,
|
|
60
|
-
error: getError({
|
|
61
|
-
label: label ?? ''
|
|
62
|
-
}, error),
|
|
63
|
-
readOnly: readOnly,
|
|
64
|
-
tooltip: tooltip
|
|
65
|
-
});
|
|
41
|
+
return /* @__PURE__ */ jsx(TagInput, { name: field.name, className, disabled, id, onChange: (newTags) => {
|
|
42
|
+
field.onChange(newTags);
|
|
43
|
+
onChange?.(newTags);
|
|
44
|
+
}, placeholder, variant, value: field.value, "data-testid": dataTestId, clearable, label, labelDescription, size, success, error: getError({
|
|
45
|
+
label: label ?? ""
|
|
46
|
+
}, error), readOnly, tooltip });
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
TagInputField
|
|
66
50
|
};
|
|
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,
|
|
@@ -44,54 +40,31 @@ const TextAreaField = ({
|
|
|
44
40
|
rules: {
|
|
45
41
|
required,
|
|
46
42
|
validate: {
|
|
47
|
-
...
|
|
48
|
-
pattern: value => regexes.every(regex => value ===
|
|
49
|
-
} : {}
|
|
43
|
+
...regexes ? {
|
|
44
|
+
pattern: (value) => regexes.every((regex) => value === void 0 || value === "" || (Array.isArray(regex) ? regex.some((regexOr) => regexOr.test(value)) : regex.test(value)))
|
|
45
|
+
} : {},
|
|
50
46
|
...validate
|
|
51
47
|
},
|
|
52
48
|
minLength,
|
|
53
49
|
maxLength
|
|
54
50
|
}
|
|
55
51
|
});
|
|
56
|
-
return jsx(TextArea, {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
disabled: disabled,
|
|
62
|
-
error: getError({
|
|
63
|
-
regex: regexes,
|
|
64
|
-
minLength,
|
|
65
|
-
maxLength,
|
|
66
|
-
label,
|
|
67
|
-
value: field.value
|
|
68
|
-
}, error),
|
|
69
|
-
helper: helper,
|
|
70
|
-
label: label,
|
|
71
|
-
labelDescription: labelDescription,
|
|
72
|
-
minLength: minLength,
|
|
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,
|
|
52
|
+
return /* @__PURE__ */ jsx(TextArea, { autoFocus, className, clearable, "data-testid": dataTestId, disabled, error: getError({
|
|
53
|
+
regex: regexes,
|
|
54
|
+
minLength,
|
|
55
|
+
maxLength,
|
|
56
|
+
label,
|
|
93
57
|
value: field.value
|
|
94
|
-
})
|
|
58
|
+
}, error), helper, label, labelDescription, minLength, maxLength, name, onBlur: (event) => {
|
|
59
|
+
onBlur?.(event);
|
|
60
|
+
field.onBlur();
|
|
61
|
+
}, onChange: (event) => {
|
|
62
|
+
field.onChange(event);
|
|
63
|
+
onChange?.(event);
|
|
64
|
+
}, onFocus: (event) => {
|
|
65
|
+
onFocus?.(event);
|
|
66
|
+
}, placeholder, readOnly, required, rows, success, tabIndex, tooltip, value: field.value });
|
|
67
|
+
};
|
|
68
|
+
export {
|
|
69
|
+
TextAreaField
|
|
95
70
|
};
|
|
96
|
-
|
|
97
|
-
export { TextAreaField };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TextInput } from '@ultraviolet/ui';
|
|
2
|
+
import type { ComponentProps, Ref } from 'react';
|
|
3
|
+
import type { FieldPath, FieldValues, Path, PathValue } from 'react-hook-form';
|
|
4
|
+
import type { BaseFieldProps } from '../../types';
|
|
5
|
+
type TextInputFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Partial<Pick<ComponentProps<typeof TextInput>, 'autoCapitalize' | 'autoComplete' | 'autoCorrect' | 'autoFocus' | 'autoSave' | 'cols' | 'disabled' | 'fillAvailable' | 'generated' | 'id' | 'multiline' | 'notice' | 'onBlur' | 'onFocus' | 'onKeyDown' | 'onKeyUp' | 'placeholder' | 'random' | 'readOnly' | 'resizable' | 'rows' | 'type' | 'noTopLabel' | 'unit' | 'valid' | 'size' | 'maxLength' | 'minLength' | 'min' | 'max' | 'data-testid'>> & {
|
|
6
|
+
className?: string;
|
|
7
|
+
regex?: (RegExp | RegExp[])[];
|
|
8
|
+
format?: (value: unknown) => PathValue<TFieldValues, Path<TFieldValues>>;
|
|
9
|
+
parse?: (value: string) => PathValue<TFieldValues, Path<TFieldValues>>;
|
|
10
|
+
customError?: string;
|
|
11
|
+
formatOnBlur?: boolean;
|
|
12
|
+
innerRef?: Ref<HTMLInputElement>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated This component is deprecated, please use `TextInputFieldV2` instead
|
|
16
|
+
*/
|
|
17
|
+
export declare const TextInputField: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ autoCapitalize, autoComplete, autoCorrect, autoFocus, autoSave, className, cols, disabled, fillAvailable, generated, id, label, multiline, name, noTopLabel, notice, onChange, onFocus, onKeyDown, onKeyUp, onBlur, placeholder, random, readOnly, required, resizable, rows, type, unit, size, rules, valid, parse, format, formatOnBlur, regex: regexes, min, max, minLength, maxLength, validate, defaultValue, customError, innerRef, shouldUnregister, "data-testid": dataTestId, }: TextInputFieldProps<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|