@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.
Files changed (73) hide show
  1. package/dist/components/CheckboxField/index.d.ts +10 -0
  2. package/dist/components/CheckboxField/index.js +40 -41
  3. package/dist/components/CheckboxGroupField/index.d.ts +32 -0
  4. package/dist/components/CheckboxGroupField/index.js +59 -53
  5. package/dist/components/DateField/index.d.ts +16 -0
  6. package/dist/components/DateField/index.js +53 -58
  7. package/dist/components/Form/defaultErrors.d.ts +2 -0
  8. package/dist/components/Form/defaultErrors.js +20 -19
  9. package/dist/components/Form/index.d.ts +69 -0
  10. package/dist/components/Form/index.js +52 -57
  11. package/dist/components/KeyValueField/index.d.ts +33 -0
  12. package/dist/components/KeyValueField/index.js +61 -60
  13. package/dist/components/NumberInputField/index.d.ts +13 -0
  14. package/dist/components/NumberInputField/index.js +39 -45
  15. package/dist/components/NumberInputFieldV2/index.d.ts +11 -0
  16. package/dist/components/NumberInputFieldV2/index.js +45 -51
  17. package/dist/components/RadioField/index.d.ts +12 -0
  18. package/dist/components/RadioField/index.js +36 -42
  19. package/dist/components/RadioGroupField/index.d.ts +28 -0
  20. package/dist/components/RadioGroupField/index.js +31 -32
  21. package/dist/components/SelectInputField/index.d.ts +82 -0
  22. package/dist/components/SelectInputField/index.js +90 -83
  23. package/dist/components/SelectInputFieldV2/index.d.ts +7 -0
  24. package/dist/components/SelectInputFieldV2/index.js +60 -60
  25. package/dist/components/SelectableCardField/index.d.ts +9 -0
  26. package/dist/components/SelectableCardField/index.js +49 -44
  27. package/dist/components/SelectableCardGroupField/index.d.ts +42 -0
  28. package/dist/components/SelectableCardGroupField/index.js +42 -41
  29. package/dist/components/Submit/index.d.ts +17 -0
  30. package/dist/components/Submit/index.js +27 -27
  31. package/dist/components/SubmitErrorAlert/index.d.ts +3 -0
  32. package/dist/components/SubmitErrorAlert/index.js +9 -17
  33. package/dist/components/TagInputField/index.d.ts +6 -0
  34. package/dist/components/TagInputField/index.js +35 -38
  35. package/dist/components/TextAreaField/index.d.ts +11 -0
  36. package/dist/components/TextAreaField/index.js +57 -56
  37. package/dist/components/TextInputField/index.d.ts +18 -0
  38. package/dist/components/TextInputField/index.js +82 -81
  39. package/dist/components/TextInputFieldV2/index.d.ts +12 -0
  40. package/dist/components/TextInputFieldV2/index.js +73 -72
  41. package/dist/components/TimeField/index.d.ts +9 -0
  42. package/dist/components/TimeField/index.js +51 -49
  43. package/dist/components/ToggleField/index.d.ts +10 -0
  44. package/dist/components/ToggleField/index.js +32 -31
  45. package/dist/components/ToggleGroupField/index.d.ts +26 -0
  46. package/dist/components/index.d.ts +22 -0
  47. package/dist/constants.d.ts +1 -0
  48. package/dist/constants.js +4 -3
  49. package/dist/hooks/index.d.ts +5 -0
  50. package/dist/hooks/useField.d.ts +34 -0
  51. package/dist/hooks/useField.js +7 -30
  52. package/dist/hooks/useFieldArray.d.ts +21 -0
  53. package/dist/hooks/useFieldArray.js +9 -22
  54. package/dist/hooks/useForm.d.ts +23 -0
  55. package/dist/hooks/useForm.js +8 -25
  56. package/dist/hooks/useFormState.d.ts +39 -0
  57. package/dist/hooks/useFormState.js +6 -23
  58. package/dist/hooks/useOnFieldChange.d.ts +3 -0
  59. package/dist/hooks/useOnFieldChange.js +10 -11
  60. package/dist/index.d.ts +7 -555
  61. package/dist/index.js +66 -29
  62. package/dist/mocks/index.d.ts +1 -0
  63. package/dist/mocks/mockErrors.d.ts +3 -0
  64. package/dist/providers/ErrorContext/index.d.ts +14 -0
  65. package/dist/providers/ErrorContext/index.js +30 -29
  66. package/dist/providers/index.d.ts +1 -0
  67. package/dist/types.d.ts +32 -0
  68. package/dist/validators/index.d.ts +5 -0
  69. package/dist/validators/maxDate.d.ts +1 -0
  70. package/dist/validators/maxDate.js +4 -3
  71. package/dist/validators/minDate.d.ts +1 -0
  72. package/dist/validators/minDate.js +4 -3
  73. package/package.json +11 -5
@@ -1,19 +1,15 @@
1
- import { Radio } from '@ultraviolet/ui';
2
- import { useController } from 'react-hook-form';
3
- import { jsx } from '@emotion/react/jsx-runtime';
4
- import { useErrors } from '../../providers/ErrorContext/index.js';
5
-
6
- /**
7
- * @deprecated This component is deprecated, use `RadioGroupField` instead.
8
- */
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { Radio } from "@ultraviolet/ui";
3
+ import { useController } from "react-hook-form";
4
+ import { useErrors } from "../../providers/ErrorContext/index.js";
9
5
  const RadioField = ({
10
6
  className,
11
- 'data-testid': dataTestId,
7
+ "data-testid": dataTestId,
12
8
  disabled,
13
9
  id,
14
10
  name,
15
11
  onBlur,
16
- label = '',
12
+ label = "",
17
13
  onChange,
18
14
  onFocus,
19
15
  required,
@@ -22,14 +18,10 @@ const RadioField = ({
22
18
  tooltip,
23
19
  shouldUnregister = false
24
20
  }) => {
25
- const {
26
- getError
27
- } = useErrors();
21
+ const { getError } = useErrors();
28
22
  const {
29
23
  field,
30
- fieldState: {
31
- error
32
- }
24
+ fieldState: { error }
33
25
  } = useController({
34
26
  name,
35
27
  shouldUnregister,
@@ -38,30 +30,32 @@ const RadioField = ({
38
30
  ...rules
39
31
  }
40
32
  });
41
- return jsx(Radio, {
42
- name: field.name,
43
- checked: field.value === value,
44
- className: className,
45
- "data-testid": dataTestId,
46
- disabled: disabled,
47
- error: getError({
48
- label: typeof label === 'string' ? label : ''
49
- }, error),
50
- id: id,
51
- onChange: () => {
52
- field.onChange(value);
53
- onChange?.(value);
54
- },
55
- onBlur: event => {
56
- field.onBlur();
57
- onBlur?.(event);
58
- },
59
- onFocus: onFocus,
60
- required: required,
61
- value: value ?? '',
62
- label: label,
63
- tooltip: tooltip
64
- });
33
+ return /* @__PURE__ */ jsx(
34
+ Radio,
35
+ {
36
+ name: field.name,
37
+ checked: field.value === value,
38
+ className,
39
+ "data-testid": dataTestId,
40
+ disabled,
41
+ error: getError({ label: typeof label === "string" ? label : "" }, error),
42
+ id,
43
+ onChange: () => {
44
+ field.onChange(value);
45
+ onChange?.(value);
46
+ },
47
+ onBlur: (event) => {
48
+ field.onBlur();
49
+ onBlur?.(event);
50
+ },
51
+ onFocus,
52
+ required,
53
+ value: value ?? "",
54
+ label,
55
+ tooltip
56
+ }
57
+ );
58
+ };
59
+ export {
60
+ RadioField
65
61
  };
66
-
67
- export { RadioField };
@@ -0,0 +1,28 @@
1
+ import { RadioGroup } 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 RadioGroupFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Partial<Pick<ComponentProps<typeof RadioGroup>, 'legend' | 'children' | 'error' | 'helper' | 'direction'>> & {
6
+ className?: string;
7
+ };
8
+ export declare const RadioGroupField: {
9
+ <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, legend, name, onChange, required, rules, children, label, error: customError, helper, direction, shouldUnregister, }: RadioGroupFieldProps<TFieldValues, TName>): JSX.Element;
10
+ Radio: ({ onFocus, onBlur, disabled, error, name, value, label, helper, className, autoFocus, onKeyDown, "data-testid": dataTestId, }: Omit<({
11
+ error?: import("react").ReactNode;
12
+ checked?: boolean | undefined;
13
+ value: string | number;
14
+ helper?: import("react").ReactNode;
15
+ className?: string | undefined;
16
+ 'data-testid'?: string | undefined;
17
+ tooltip?: string | undefined;
18
+ } & Required<Pick<import("react").InputHTMLAttributes<HTMLInputElement>, "onChange">> & (Pick<import("react").InputHTMLAttributes<HTMLInputElement>, "required" | "onBlur" | "disabled" | "name" | "onFocus" | "autoFocus" | "id" | "onKeyDown"> & ({
19
+ 'aria-label': string;
20
+ label?: undefined;
21
+ } | {
22
+ 'aria-label'?: undefined;
23
+ label: import("react").ReactNode;
24
+ }))) & import("react").RefAttributes<HTMLInputElement>, "required" | "onChange" | "checked"> & {
25
+ name?: string | undefined;
26
+ }) => import("@emotion/react/jsx-runtime").JSX.Element;
27
+ };
28
+ export {};
@@ -1,30 +1,25 @@
1
- import { RadioGroup } from '@ultraviolet/ui';
2
- import { useController } from 'react-hook-form';
3
- import { jsx } from '@emotion/react/jsx-runtime';
4
- import { useErrors } from '../../providers/ErrorContext/index.js';
5
-
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { RadioGroup } from "@ultraviolet/ui";
3
+ import { useController } from "react-hook-form";
4
+ import { useErrors } from "../../providers/ErrorContext/index.js";
6
5
  const RadioGroupField = ({
7
6
  className,
8
- legend = '',
7
+ legend = "",
9
8
  name,
10
9
  onChange,
11
10
  required,
12
11
  rules,
13
12
  children,
14
- label = '',
13
+ label = "",
15
14
  error: customError,
16
15
  helper,
17
16
  direction,
18
17
  shouldUnregister = false
19
18
  }) => {
20
- const {
21
- getError
22
- } = useErrors();
19
+ const { getError } = useErrors();
23
20
  const {
24
21
  field,
25
- fieldState: {
26
- error
27
- }
22
+ fieldState: { error }
28
23
  } = useController({
29
24
  name,
30
25
  shouldUnregister,
@@ -33,24 +28,28 @@ const RadioGroupField = ({
33
28
  ...rules
34
29
  }
35
30
  });
36
- return jsx(RadioGroup, {
37
- className: className,
38
- name: field.name,
39
- onChange: event => {
40
- field.onChange(event);
41
- onChange?.(event.target.value);
42
- },
43
- required: required,
44
- value: field.value,
45
- legend: legend,
46
- error: getError({
47
- label
48
- }, error) ?? customError,
49
- helper: helper,
50
- direction: direction,
51
- children: children
52
- });
31
+ return /* @__PURE__ */ jsx(
32
+ RadioGroup,
33
+ {
34
+ className,
35
+ name: field.name,
36
+ onChange: (event) => {
37
+ field.onChange(event);
38
+ onChange?.(
39
+ event.target.value
40
+ );
41
+ },
42
+ required,
43
+ value: field.value,
44
+ legend,
45
+ error: getError({ label }, error) ?? customError,
46
+ helper,
47
+ direction,
48
+ children
49
+ }
50
+ );
53
51
  };
54
52
  RadioGroupField.Radio = RadioGroup.Radio;
55
-
56
- export { RadioGroupField };
53
+ export {
54
+ RadioGroupField
55
+ };
@@ -0,0 +1,82 @@
1
+ import type { CSSObject, Theme, css } from '@emotion/react';
2
+ import { SelectInput } from '@ultraviolet/ui';
3
+ import type { ComponentProps, ForwardedRef, ReactNode } from 'react';
4
+ import type { FieldPath, FieldValues } from 'react-hook-form';
5
+ import type { CommonProps, GroupBase, OptionProps, Props } from 'react-select';
6
+ import type Select from 'react-select';
7
+ import type { BaseFieldProps } from '../../types';
8
+ export type SelectInputType = typeof SelectInput;
9
+ type SelectOption = {
10
+ value: string;
11
+ label: ReactNode;
12
+ disabled?: boolean;
13
+ description?: string;
14
+ inlineDescription?: string;
15
+ };
16
+ type WithSelectProps = {
17
+ selectProps: SelectProps;
18
+ };
19
+ type SelectStyleProps = {
20
+ error?: string;
21
+ /**
22
+ * Custom styles of the SelectInput. See [React select documentation](https://react-select.com/styles)
23
+ */
24
+ customStyle: (state: SelectProps & WithSelectProps) => Record<string, CSSObject>;
25
+ animation?: string;
26
+ /**
27
+ * Time of the animation
28
+ */
29
+ animationDuration?: number;
30
+ /**
31
+ * Show/hide the label inside the component
32
+ */
33
+ noTopLabel?: boolean;
34
+ theme: Theme;
35
+ };
36
+ type StyledContainerProps = {
37
+ isDisabled?: boolean;
38
+ additionalStyles?: Parameters<typeof css>[0];
39
+ };
40
+ type SelectProps = StyledContainerProps & Omit<Props<SelectOption>, 'value'> & CommonProps<SelectOption, boolean, GroupBase<SelectOption>> & {
41
+ value?: string | SelectOption;
42
+ checked?: boolean;
43
+ error?: string;
44
+ labelId?: string;
45
+ required?: boolean;
46
+ time?: boolean;
47
+ };
48
+ type StateManagedSelect = typeof Select;
49
+ type SelectInputProps = Partial<SelectProps & SelectStyleProps & Pick<ComponentProps<typeof SelectInput>, 'data-testid'> & {
50
+ /**
51
+ * Name of the animation
52
+ */
53
+ animation?: string;
54
+ /**
55
+ * Play the animation when the value change
56
+ */
57
+ animationOnChange?: boolean;
58
+ disabled?: boolean;
59
+ readOnly?: boolean;
60
+ innerRef?: ForwardedRef<StateManagedSelect>;
61
+ /**
62
+ * Custom components of the SelectInput. See [React select documentation](https://react-select.com/components)
63
+ */
64
+ customComponents?: SelectProps['components'];
65
+ children: ReactNode;
66
+ emptyState?: ComponentProps<Select>['noOptionsMessage'];
67
+ }>;
68
+ /**
69
+ * @deprecated This component is deprecated, please use `SelectInputFieldV2` instead
70
+ */
71
+ export type SelectInputFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TName>, '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
+ multiple?: boolean;
73
+ parse?: (value: unknown, name?: string) => unknown;
74
+ format?: (value: unknown, name: string) => unknown;
75
+ maxLength?: number;
76
+ minLength?: number;
77
+ };
78
+ export declare const SelectInputField: {
79
+ <TFieldValues extends FieldValues, TName 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, rules, noTopLabel, emptyState, customStyle, shouldUnregister, "data-testid": dataTestId, }: SelectInputFieldProps<TFieldValues, TName>): import("@emotion/react/jsx-runtime").JSX.Element;
80
+ Option: (props: Partial<OptionProps<import("@ultraviolet/ui").SelectOption, boolean, GroupBase<import("@ultraviolet/ui").SelectOption>> & import("@ultraviolet/ui").SelectOption>) => import("react").JSX.Element;
81
+ };
82
+ export {};
@@ -1,12 +1,9 @@
1
- import { SelectInput } from '@ultraviolet/ui';
2
- import { useMemo, Children, useCallback } from 'react';
3
- import { useController } from 'react-hook-form';
4
- import { jsx } from '@emotion/react/jsx-runtime';
5
- import { useErrors } from '../../providers/ErrorContext/index.js';
6
-
7
- const identity = x => x;
8
- // const identity = <T,>(x: T) => x
9
-
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { SelectInput } from "@ultraviolet/ui";
3
+ import { useMemo, Children, useCallback } from "react";
4
+ import { useController } from "react-hook-form";
5
+ import { useErrors } from "../../providers/ErrorContext/index.js";
6
+ const identity = (x) => x;
10
7
  const SelectInputField = ({
11
8
  animation,
12
9
  animationDuration,
@@ -22,7 +19,7 @@ const SelectInputField = ({
22
19
  isClearable,
23
20
  isLoading,
24
21
  isSearchable,
25
- label = '',
22
+ label = "",
26
23
  maxLength,
27
24
  menuPortalTarget,
28
25
  minLength,
@@ -41,92 +38,102 @@ const SelectInputField = ({
41
38
  emptyState,
42
39
  customStyle,
43
40
  shouldUnregister = false,
44
- 'data-testid': dataTestId
41
+ "data-testid": dataTestId
45
42
  }) => {
46
- const options = useMemo(() => optionsProp || Children.toArray(children).flat().filter(Boolean).map(({
47
- props: {
48
- children: labelChild,
49
- ...option
50
- }
51
- }) => ({
52
- ...option,
53
- label: labelChild
54
- })), [optionsProp, children]);
55
- const parse = useMemo(() => multiple ? parseProp : option => parseProp(option?.value ?? null, name), [multiple, parseProp, name]);
56
- const format = useCallback(val => {
57
- if (multiple) return formatProp(val, name);
58
- const find = (opts, valueToFind) => opts?.find(option => option.value === valueToFind);
59
- let selected = '';
60
- if (val && options) {
61
- // TODO: find a proper way to simplify format with recursive options
62
- selected = find(options, val);
63
- if (!selected) {
64
- selected = options.map(curr => find(curr.options, val)).filter(identity);
65
- if (Array.isArray(selected) && selected.length === 0) {
66
- selected = '';
43
+ const options = useMemo(
44
+ () => optionsProp || Children.toArray(children).flat().filter(Boolean).map(({ props: { children: labelChild, ...option } }) => ({
45
+ ...option,
46
+ label: labelChild
47
+ })),
48
+ [optionsProp, children]
49
+ );
50
+ const parse = useMemo(
51
+ () => multiple ? parseProp : (option) => parseProp(option?.value ?? null, name),
52
+ [multiple, parseProp, name]
53
+ );
54
+ const format = useCallback(
55
+ (val) => {
56
+ if (multiple)
57
+ return formatProp(val, name);
58
+ const find = (opts, valueToFind) => opts?.find(
59
+ (option) => option.value === valueToFind
60
+ );
61
+ let selected = "";
62
+ if (val && options) {
63
+ selected = find(
64
+ options,
65
+ val
66
+ );
67
+ if (!selected) {
68
+ selected = options.map(
69
+ (curr) => find(
70
+ curr.options,
71
+ val
72
+ )
73
+ ).filter(identity);
74
+ if (Array.isArray(selected) && selected.length === 0) {
75
+ selected = "";
76
+ }
67
77
  }
68
78
  }
69
- }
70
- return formatProp(selected, name);
71
- }, [formatProp, multiple, name, options]);
72
- const {
73
- getError
74
- } = useErrors();
79
+ return formatProp(selected, name);
80
+ },
81
+ [formatProp, multiple, name, options]
82
+ );
83
+ const { getError } = useErrors();
75
84
  const {
76
85
  field,
77
- fieldState: {
78
- error
79
- }
86
+ fieldState: { error }
80
87
  } = useController({
81
88
  name,
82
89
  shouldUnregister,
83
90
  rules: {
84
91
  required,
85
- minLength: minLength || required ? 1 : undefined,
92
+ minLength: minLength || required ? 1 : void 0,
86
93
  maxLength,
87
94
  ...rules
88
95
  }
89
96
  });
90
- return jsx(SelectInput, {
91
- name: field.name,
92
- animation: animation,
93
- animationDuration: animationDuration,
94
- animationOnChange: animationOnChange,
95
- className: className,
96
- disabled: disabled,
97
- error: getError({
98
- label,
99
- minLength,
100
- maxLength
101
- }, error),
102
- id: id,
103
- inputId: inputId,
104
- isClearable: isClearable,
105
- isLoading: isLoading,
106
- isMulti: multiple,
107
- customStyle: customStyle,
108
- isSearchable: isSearchable,
109
- menuPortalTarget: menuPortalTarget,
110
- onBlur: event => {
111
- field.onBlur();
112
- onBlur?.(event);
113
- },
114
- onChange: (event, action) => {
115
- field.onChange(parse(event));
116
- onChange?.(event, action);
117
- },
118
- onFocus: onFocus,
119
- options: options,
120
- placeholder: placeholder,
121
- readOnly: readOnly,
122
- noTopLabel: noTopLabel,
123
- required: required,
124
- value: format(field.value),
125
- emptyState: emptyState,
126
- "data-testid": dataTestId,
127
- children: children
128
- });
97
+ return /* @__PURE__ */ jsx(
98
+ SelectInput,
99
+ {
100
+ name: field.name,
101
+ animation,
102
+ animationDuration,
103
+ animationOnChange,
104
+ className,
105
+ disabled,
106
+ error: getError({ label, minLength, maxLength }, error),
107
+ id,
108
+ inputId,
109
+ isClearable,
110
+ isLoading,
111
+ isMulti: multiple,
112
+ customStyle,
113
+ isSearchable,
114
+ menuPortalTarget,
115
+ onBlur: (event) => {
116
+ field.onBlur();
117
+ onBlur?.(event);
118
+ },
119
+ onChange: (event, action) => {
120
+ field.onChange(parse(event));
121
+ onChange?.(event, action);
122
+ },
123
+ onFocus,
124
+ options,
125
+ placeholder,
126
+ readOnly,
127
+ noTopLabel,
128
+ required,
129
+ value: format(field.value),
130
+ emptyState,
131
+ "data-testid": dataTestId,
132
+ children
133
+ }
134
+ );
129
135
  };
130
136
  SelectInputField.Option = SelectInput.Option;
131
-
132
- export { SelectInputField };
137
+ export {
138
+ SelectInputField
139
+ };
@@ -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 { SelectInputV2 } from '@ultraviolet/ui';
2
- import { useCallback } from 'react';
3
- import { useController } from 'react-hook-form';
4
- import { jsx } from '@emotion/react/jsx-runtime';
5
- import { useErrors } from '../../providers/ErrorContext/index.js';
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
- 'data-testid': dataTestId,
17
+ "data-testid": dataTestId,
19
18
  disabled,
20
19
  placeholderSearch,
21
20
  helper,
@@ -34,16 +33,14 @@ const SelectInputFieldV2 = ({
34
33
  selectAll,
35
34
  selectAllGroup,
36
35
  name,
37
- 'aria-label': ariaLabel,
36
+ "aria-label": ariaLabel,
38
37
  optionalInfoPlacement,
39
38
  rules,
40
39
  shouldUnregister = false
41
40
  }) => {
42
41
  const {
43
42
  field,
44
- fieldState: {
45
- error
46
- }
43
+ fieldState: { error }
47
44
  } = useController({
48
45
  name,
49
46
  shouldUnregister,
@@ -52,53 +49,56 @@ const SelectInputFieldV2 = ({
52
49
  ...rules
53
50
  }
54
51
  });
55
- const {
56
- getError
57
- } = useErrors();
58
- const handleChange = useCallback(value => {
59
- onChange?.(value);
60
- field.onChange(value);
61
- }, [onChange, field]);
62
- return jsx(SelectInputV2, {
63
- name: field.name,
64
- options: options,
65
- required: required,
66
- size: size,
67
- "data-testid": dataTestId,
68
- className: className,
69
- disabled: disabled,
70
- id: id,
71
- label: label,
72
- onFocus: onFocus,
73
- onBlur: event => {
74
- field.onBlur();
75
- onBlur?.(event);
52
+ const { getError } = useErrors();
53
+ const handleChange = useCallback(
54
+ (value) => {
55
+ onChange?.(value);
56
+ field.onChange(value);
76
57
  },
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
- });
58
+ [onChange, field]
59
+ );
60
+ return /* @__PURE__ */ jsx(
61
+ SelectInputV2,
62
+ {
63
+ name: field.name,
64
+ options,
65
+ required,
66
+ size,
67
+ "data-testid": dataTestId,
68
+ className,
69
+ disabled,
70
+ id,
71
+ label,
72
+ onFocus,
73
+ onBlur: (event) => {
74
+ field.onBlur();
75
+ onBlur?.(event);
76
+ },
77
+ placeholder,
78
+ readOnly,
79
+ multiselect,
80
+ value: field.value,
81
+ placeholderSearch,
82
+ helper,
83
+ emptyState,
84
+ searchable,
85
+ clearable,
86
+ descriptionDirection,
87
+ footer,
88
+ labelDescription,
89
+ error: getError({ label }, error),
90
+ success,
91
+ loadMore,
92
+ isLoading,
93
+ selectAll,
94
+ selectAllGroup,
95
+ autofocus,
96
+ optionalInfoPlacement,
97
+ "aria-label": ariaLabel,
98
+ onChange: handleChange
99
+ }
100
+ );
101
+ };
102
+ export {
103
+ SelectInputFieldV2
102
104
  };
103
-
104
- export { SelectInputFieldV2 };