@ultraviolet/form 4.0.0-beta.1 → 4.0.0-beta.11

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 (71) hide show
  1. package/dist/components/CheckboxGroupField/index.cjs +3 -3
  2. package/dist/components/CheckboxGroupField/index.d.ts +2 -2
  3. package/dist/components/CheckboxGroupField/index.js +3 -3
  4. package/dist/components/DateField/index.cjs +7 -17
  5. package/dist/components/DateField/index.d.ts +3 -13
  6. package/dist/components/DateField/index.js +7 -17
  7. package/dist/components/Form/index.cjs +20 -1
  8. package/dist/components/Form/index.js +18 -1
  9. package/dist/components/KeyValueField/index.cjs +1 -1
  10. package/dist/components/KeyValueField/index.d.ts +6 -6
  11. package/dist/components/KeyValueField/index.js +1 -1
  12. package/dist/components/NumberInputField/index.cjs +24 -24
  13. package/dist/components/NumberInputField/index.d.ts +3 -9
  14. package/dist/components/NumberInputField/index.js +24 -24
  15. package/dist/components/RadioGroupField/index.cjs +3 -4
  16. package/dist/components/RadioGroupField/index.d.ts +2 -2
  17. package/dist/components/RadioGroupField/index.js +3 -4
  18. package/dist/components/SelectInputField/index.cjs +19 -71
  19. package/dist/components/SelectInputField/index.d.ts +3 -81
  20. package/dist/components/SelectInputField/index.js +20 -72
  21. package/dist/components/SelectableCardField/index.cjs +5 -11
  22. package/dist/components/SelectableCardField/index.d.ts +3 -11
  23. package/dist/components/SelectableCardField/index.js +5 -11
  24. package/dist/components/SelectableCardGroupField/index.cjs +6 -10
  25. package/dist/components/SelectableCardGroupField/index.d.ts +2 -2
  26. package/dist/components/SelectableCardGroupField/index.js +6 -10
  27. package/dist/components/SelectableCardOptionGroupField/index.cjs +2 -3
  28. package/dist/components/SelectableCardOptionGroupField/index.d.ts +5 -5
  29. package/dist/components/SelectableCardOptionGroupField/index.js +2 -3
  30. package/dist/components/SwitchButtonField/index.cjs +2 -3
  31. package/dist/components/SwitchButtonField/index.d.ts +9 -2
  32. package/dist/components/SwitchButtonField/index.js +2 -3
  33. package/dist/components/TagInputField/index.cjs +5 -16
  34. package/dist/components/TagInputField/index.d.ts +2 -2
  35. package/dist/components/TagInputField/index.js +5 -16
  36. package/dist/components/TextAreaField/index.cjs +5 -19
  37. package/dist/components/TextAreaField/index.d.ts +1 -1
  38. package/dist/components/TextAreaField/index.js +5 -19
  39. package/dist/components/TextInputField/index.cjs +19 -73
  40. package/dist/components/TextInputField/index.d.ts +5 -11
  41. package/dist/components/TextInputField/index.js +19 -73
  42. package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.cjs +6 -20
  43. package/dist/components/TimeInputField/index.d.ts +11 -0
  44. package/dist/components/{TimeInputFieldV2 → TimeInputField}/index.js +7 -21
  45. package/dist/components/ToggleField/index.cjs +4 -9
  46. package/dist/components/ToggleField/index.d.ts +5 -5
  47. package/dist/components/ToggleField/index.js +4 -9
  48. package/dist/components/ToggleGroupField/index.d.ts +2 -2
  49. package/dist/components/UnitInputField/index.cjs +5 -15
  50. package/dist/components/UnitInputField/index.d.ts +2 -4
  51. package/dist/components/UnitInputField/index.js +5 -15
  52. package/dist/components/VerificationCodeField/index.cjs +5 -14
  53. package/dist/components/VerificationCodeField/index.d.ts +2 -7
  54. package/dist/components/VerificationCodeField/index.js +5 -14
  55. package/dist/components/index.d.ts +2 -6
  56. package/dist/index.cjs +36 -44
  57. package/dist/index.js +3 -11
  58. package/package.json +11 -11
  59. package/dist/components/NumberInputFieldV2/index.cjs +0 -72
  60. package/dist/components/NumberInputFieldV2/index.d.ts +0 -9
  61. package/dist/components/NumberInputFieldV2/index.js +0 -72
  62. package/dist/components/SelectInputFieldV2/index.cjs +0 -50
  63. package/dist/components/SelectInputFieldV2/index.d.ts +0 -7
  64. package/dist/components/SelectInputFieldV2/index.js +0 -50
  65. package/dist/components/TextInputFieldV2/index.cjs +0 -90
  66. package/dist/components/TextInputFieldV2/index.d.ts +0 -12
  67. package/dist/components/TextInputFieldV2/index.js +0 -90
  68. package/dist/components/TimeField/index.cjs +0 -68
  69. package/dist/components/TimeField/index.d.ts +0 -7
  70. package/dist/components/TimeField/index.js +0 -68
  71. package/dist/components/TimeInputFieldV2/index.d.ts +0 -11
@@ -6,71 +6,19 @@ const ui = require("@ultraviolet/ui");
6
6
  const react = require("react");
7
7
  const reactHookForm = require("react-hook-form");
8
8
  const index = require("../../providers/ErrorContext/index.cjs");
9
- const identity = (x) => x;
10
9
  const SelectInputField = ({
11
- animation,
12
- animationDuration,
13
- animationOnChange,
14
- children,
15
- className,
16
- disabled,
17
- // error: errorProp,
18
- format: formatProp = identity,
19
- // formatOnBlur,
20
- id,
21
- inputId,
22
- isClearable,
23
- isLoading,
24
- isSearchable,
25
10
  label = "",
26
- maxLength,
27
- menuPortalTarget,
28
- minLength,
29
- multiple,
30
- name,
31
11
  onBlur,
32
- onChange,
33
- onFocus,
34
- options: optionsProp,
35
- parse: parseProp = identity,
36
- placeholder,
37
- readOnly,
38
12
  required,
39
- noTopLabel,
40
- emptyState,
41
- customStyle,
13
+ name,
14
+ "aria-label": ariaLabel,
42
15
  shouldUnregister = false,
43
- "data-testid": dataTestId,
44
- validate
16
+ control,
17
+ validate,
18
+ onChange,
19
+ multiselect,
20
+ ...props
45
21
  }) => {
46
- const options = react.useMemo(() => optionsProp || react.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 = react.useMemo(() => multiple ? parseProp : (option) => parseProp(option?.value ?? null, name), [multiple, parseProp, name]);
56
- const format = react.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
- selected = find(options, val);
62
- if (!selected) {
63
- selected = options.map((curr) => find(curr.options, val)).filter(identity);
64
- if (Array.isArray(selected) && selected.length === 0) {
65
- selected = "";
66
- }
67
- }
68
- }
69
- return formatProp(selected, name);
70
- }, [formatProp, multiple, name, options]);
71
- const {
72
- getError
73
- } = index.useErrors();
74
22
  const {
75
23
  field,
76
24
  fieldState: {
@@ -78,25 +26,25 @@ const SelectInputField = ({
78
26
  }
79
27
  } = reactHookForm.useController({
80
28
  name,
29
+ control,
81
30
  shouldUnregister,
82
31
  rules: {
83
32
  required,
84
- minLength: minLength || required ? 1 : void 0,
85
- maxLength,
86
33
  validate
87
34
  }
88
35
  });
89
- return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInput, { name: field.name, animation, animationDuration, animationOnChange, className, disabled, error: getError({
90
- label,
91
- minLength,
92
- maxLength
93
- }, error), id, inputId, isClearable, isLoading, isMulti: multiple, customStyle, isSearchable, menuPortalTarget, onBlur: (event) => {
36
+ const {
37
+ getError
38
+ } = index.useErrors();
39
+ const handleChange = react.useCallback((value) => {
40
+ onChange?.(value);
41
+ field.onChange(value);
42
+ }, [onChange, field]);
43
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectInput, { name: field.name, multiselect, required, onBlur: (event) => {
94
44
  field.onBlur();
95
45
  onBlur?.(event);
96
- }, onChange: (event, action) => {
97
- field.onChange(parse(event));
98
- onChange?.(event, action);
99
- }, onFocus, options, placeholder, readOnly, noTopLabel, required, value: format(field.value), emptyState, "data-testid": dataTestId, children });
46
+ }, value: field.value, error: getError({
47
+ label: label ?? ariaLabel ?? name
48
+ }, error), label, "aria-label": ariaLabel, onChange: handleChange, ...props });
100
49
  };
101
- SelectInputField.Option = ui.SelectInput.Option;
102
50
  exports.SelectInputField = SelectInputField;
@@ -1,85 +1,7 @@
1
- import type { CSSObject, Theme, css } from '@emotion/react';
2
1
  import { SelectInput } from '@ultraviolet/ui';
3
- import type { ComponentProps, ForwardedRef, ReactNode } from 'react';
2
+ import { type ComponentProps } from 'react';
4
3
  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
4
  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, 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
- multiple?: boolean;
73
- parse?: (value: unknown, name?: string) => unknown;
74
- format?: (value: unknown, name: string) => unknown;
75
- maxLength?: number;
76
- minLength?: number;
77
- };
78
- /**
79
- * @deprecated use SelectInputFieldV2 component instead
80
- */
81
- export declare const SelectInputField: {
82
- <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;
83
- Option: (props: Partial<OptionProps<import("@ultraviolet/ui").SelectOption> & import("@ultraviolet/ui").SelectOption>) => import("react").JSX.Element;
84
- };
5
+ type SelectInputFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof SelectInput>, 'value' | 'onChange'>;
6
+ export declare const SelectInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ label, onBlur, required, name, "aria-label": ariaLabel, shouldUnregister, control, validate, onChange, multiselect, ...props }: SelectInputFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
85
7
  export {};
@@ -1,74 +1,22 @@
1
1
  "use client";
2
2
  import { jsx } from "@emotion/react/jsx-runtime";
3
3
  import { SelectInput } from "@ultraviolet/ui";
4
- import { useMemo, Children, useCallback } from "react";
4
+ import { useCallback } from "react";
5
5
  import { useController } from "react-hook-form";
6
6
  import { useErrors } from "../../providers/ErrorContext/index.js";
7
- const identity = (x) => x;
8
7
  const SelectInputField = ({
9
- animation,
10
- animationDuration,
11
- animationOnChange,
12
- children,
13
- className,
14
- disabled,
15
- // error: errorProp,
16
- format: formatProp = identity,
17
- // formatOnBlur,
18
- id,
19
- inputId,
20
- isClearable,
21
- isLoading,
22
- isSearchable,
23
8
  label = "",
24
- maxLength,
25
- menuPortalTarget,
26
- minLength,
27
- multiple,
28
- name,
29
9
  onBlur,
30
- onChange,
31
- onFocus,
32
- options: optionsProp,
33
- parse: parseProp = identity,
34
- placeholder,
35
- readOnly,
36
10
  required,
37
- noTopLabel,
38
- emptyState,
39
- customStyle,
11
+ name,
12
+ "aria-label": ariaLabel,
40
13
  shouldUnregister = false,
41
- "data-testid": dataTestId,
42
- validate
14
+ control,
15
+ validate,
16
+ onChange,
17
+ multiselect,
18
+ ...props
43
19
  }) => {
44
- const options = useMemo(() => optionsProp || Children.toArray(children).flat().filter(Boolean).map(({
45
- props: {
46
- children: labelChild,
47
- ...option
48
- }
49
- }) => ({
50
- ...option,
51
- label: labelChild
52
- })), [optionsProp, children]);
53
- const parse = useMemo(() => multiple ? parseProp : (option) => parseProp(option?.value ?? null, name), [multiple, parseProp, name]);
54
- const format = useCallback((val) => {
55
- if (multiple) return formatProp(val, name);
56
- const find = (opts, valueToFind) => opts?.find((option) => option.value === valueToFind);
57
- let selected = "";
58
- if (val && options) {
59
- selected = find(options, val);
60
- if (!selected) {
61
- selected = options.map((curr) => find(curr.options, val)).filter(identity);
62
- if (Array.isArray(selected) && selected.length === 0) {
63
- selected = "";
64
- }
65
- }
66
- }
67
- return formatProp(selected, name);
68
- }, [formatProp, multiple, name, options]);
69
- const {
70
- getError
71
- } = useErrors();
72
20
  const {
73
21
  field,
74
22
  fieldState: {
@@ -76,27 +24,27 @@ const SelectInputField = ({
76
24
  }
77
25
  } = useController({
78
26
  name,
27
+ control,
79
28
  shouldUnregister,
80
29
  rules: {
81
30
  required,
82
- minLength: minLength || required ? 1 : void 0,
83
- maxLength,
84
31
  validate
85
32
  }
86
33
  });
87
- return /* @__PURE__ */ jsx(SelectInput, { name: field.name, animation, animationDuration, animationOnChange, className, disabled, error: getError({
88
- label,
89
- minLength,
90
- maxLength
91
- }, error), id, inputId, isClearable, isLoading, isMulti: multiple, customStyle, isSearchable, menuPortalTarget, onBlur: (event) => {
34
+ const {
35
+ getError
36
+ } = useErrors();
37
+ const handleChange = useCallback((value) => {
38
+ onChange?.(value);
39
+ field.onChange(value);
40
+ }, [onChange, field]);
41
+ return /* @__PURE__ */ jsx(SelectInput, { name: field.name, multiselect, required, onBlur: (event) => {
92
42
  field.onBlur();
93
43
  onBlur?.(event);
94
- }, onChange: (event, action) => {
95
- field.onChange(parse(event));
96
- onChange?.(event, action);
97
- }, onFocus, options, placeholder, readOnly, noTopLabel, required, value: format(field.value), emptyState, "data-testid": dataTestId, children });
44
+ }, value: field.value, error: getError({
45
+ label: label ?? ariaLabel ?? name
46
+ }, error), label, "aria-label": ariaLabel, onChange: handleChange, ...props });
98
47
  };
99
- SelectInputField.Option = SelectInput.Option;
100
48
  export {
101
49
  SelectInputField
102
50
  };
@@ -9,23 +9,17 @@ const SelectableCardField = ({
9
9
  control,
10
10
  value,
11
11
  onChange,
12
- showTick,
13
12
  type,
14
- disabled,
15
- children,
16
- className,
17
13
  onFocus,
18
14
  onBlur,
19
15
  required,
20
- tooltip,
21
- id,
22
16
  label,
23
17
  shouldUnregister = false,
24
18
  validate,
25
19
  productIcon,
26
20
  illustration,
27
- "data-testid": dataTestId,
28
- "aria-label": ariaLabel
21
+ "aria-label": ariaLabel,
22
+ ...props
29
23
  }) => {
30
24
  const {
31
25
  field,
@@ -42,7 +36,7 @@ const SelectableCardField = ({
42
36
  }
43
37
  });
44
38
  const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
45
- return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCard, { ...productIcon ? {
39
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCard, { ...props, ...productIcon ? {
46
40
  productIcon
47
41
  } : {
48
42
  illustration
@@ -50,7 +44,7 @@ const SelectableCardField = ({
50
44
  label
51
45
  } : {
52
46
  "aria-label": ariaLabel
53
- }, isError: !!error, showTick, checked: isChecked, className, disabled, onChange: (event) => {
47
+ }, isError: !!error, checked: isChecked, onChange: (event) => {
54
48
  if (type === "checkbox") {
55
49
  const fieldValue = field.value ?? [];
56
50
  if (fieldValue?.includes(event.currentTarget.value)) {
@@ -67,6 +61,6 @@ const SelectableCardField = ({
67
61
  onBlur?.(event);
68
62
  }, onFocus: (event) => {
69
63
  onFocus?.(event);
70
- }, type, id, tooltip, value: value ?? "", name: field.name, "data-testid": dataTestId, children });
64
+ }, type, value: value ?? "", name: field.name });
71
65
  };
72
66
  exports.SelectableCardField = SelectableCardField;
@@ -1,15 +1,7 @@
1
1
  import { SelectableCard } from '@ultraviolet/ui';
2
2
  import type { ComponentProps } from 'react';
3
3
  import type { FieldPath, FieldValues } from 'react-hook-form';
4
- import type { BaseFieldProps, LabelProp } from '../../types';
5
- type SelectableCardFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & Partial<Pick<ComponentProps<typeof SelectableCard>, 'disabled' | 'onBlur' | 'onFocus' | 'showTick' | 'type' | 'id' | 'children' | 'tooltip' | 'data-testid'>> & {
6
- className?: string;
7
- } & ({
8
- illustration?: ComponentProps<typeof SelectableCard>['illustration'];
9
- productIcon?: never;
10
- } | {
11
- productIcon?: ComponentProps<typeof SelectableCard>['productIcon'];
12
- illustration?: never;
13
- }) & LabelProp;
14
- export declare const SelectableCardField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, control, value, onChange, showTick, type, disabled, children, className, onFocus, onBlur, required, tooltip, id, label, shouldUnregister, validate, productIcon, illustration, "data-testid": dataTestId, "aria-label": ariaLabel, }: SelectableCardFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
4
+ import type { BaseFieldProps } from '../../types';
5
+ type SelectableCardFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & Omit<ComponentProps<typeof SelectableCard>, 'name' | 'onChange' | 'value'>;
6
+ export declare const SelectableCardField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, control, value, onChange, type, onFocus, onBlur, required, label, shouldUnregister, validate, productIcon, illustration, "aria-label": ariaLabel, ...props }: SelectableCardFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
15
7
  export {};
@@ -7,23 +7,17 @@ const SelectableCardField = ({
7
7
  control,
8
8
  value,
9
9
  onChange,
10
- showTick,
11
10
  type,
12
- disabled,
13
- children,
14
- className,
15
11
  onFocus,
16
12
  onBlur,
17
13
  required,
18
- tooltip,
19
- id,
20
14
  label,
21
15
  shouldUnregister = false,
22
16
  validate,
23
17
  productIcon,
24
18
  illustration,
25
- "data-testid": dataTestId,
26
- "aria-label": ariaLabel
19
+ "aria-label": ariaLabel,
20
+ ...props
27
21
  }) => {
28
22
  const {
29
23
  field,
@@ -40,7 +34,7 @@ const SelectableCardField = ({
40
34
  }
41
35
  });
42
36
  const isChecked = type === "checkbox" && Array.isArray(field.value) && value ? (field.value ?? []).includes(value) : field.value === value;
43
- return /* @__PURE__ */ jsx(SelectableCard, { ...productIcon ? {
37
+ return /* @__PURE__ */ jsx(SelectableCard, { ...props, ...productIcon ? {
44
38
  productIcon
45
39
  } : {
46
40
  illustration
@@ -48,7 +42,7 @@ const SelectableCardField = ({
48
42
  label
49
43
  } : {
50
44
  "aria-label": ariaLabel
51
- }, isError: !!error, showTick, checked: isChecked, className, disabled, onChange: (event) => {
45
+ }, isError: !!error, checked: isChecked, onChange: (event) => {
52
46
  if (type === "checkbox") {
53
47
  const fieldValue = field.value ?? [];
54
48
  if (fieldValue?.includes(event.currentTarget.value)) {
@@ -65,7 +59,7 @@ const SelectableCardField = ({
65
59
  onBlur?.(event);
66
60
  }, onFocus: (event) => {
67
61
  onFocus?.(event);
68
- }, type, id, tooltip, value: value ?? "", name: field.name, "data-testid": dataTestId, children });
62
+ }, type, value: value ?? "", name: field.name });
69
63
  };
70
64
  export {
71
65
  SelectableCardField
@@ -6,21 +6,17 @@ const ui = require("@ultraviolet/ui");
6
6
  const reactHookForm = require("react-hook-form");
7
7
  const index = require("../../providers/ErrorContext/index.cjs");
8
8
  const SelectableCardGroupField = ({
9
- className,
10
- legend,
9
+ legend = "",
11
10
  control,
12
11
  name,
13
12
  onChange,
14
13
  required = false,
15
- children,
16
- label = "",
17
14
  error: customError,
18
- helper,
19
15
  columns = 1,
20
- showTick,
21
16
  type = "radio",
22
17
  shouldUnregister = false,
23
- validate
18
+ validate,
19
+ ...props
24
20
  }) => {
25
21
  const {
26
22
  getError
@@ -39,7 +35,7 @@ const SelectableCardGroupField = ({
39
35
  validate
40
36
  }
41
37
  });
42
- return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardGroup, { legend, name, type, showTick, value: field.value, onChange: (event) => {
38
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.SelectableCardGroup, { ...props, legend, name, type, value: field.value, onChange: (event) => {
43
39
  if (type === "checkbox") {
44
40
  const fieldValue = field.value ?? [];
45
41
  if (fieldValue?.includes(event.currentTarget.value)) {
@@ -52,8 +48,8 @@ const SelectableCardGroupField = ({
52
48
  }
53
49
  onChange?.(event.currentTarget.value);
54
50
  }, error: getError({
55
- label
56
- }, error) ?? customError, className, columns, helper, required, children });
51
+ label: legend
52
+ }, error) ?? customError, columns, required });
57
53
  };
58
54
  SelectableCardGroupField.Card = ui.SelectableCardGroup.Card;
59
55
  exports.SelectableCardGroupField = SelectableCardGroupField;
@@ -2,9 +2,9 @@ import { SelectableCardGroup } from '@ultraviolet/ui';
2
2
  import type { ComponentProps, JSX } from 'react';
3
3
  import type { FieldPath, FieldValues } from 'react-hook-form';
4
4
  import type { BaseFieldProps } from '../../types';
5
- type SelectableCardGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & Partial<Pick<ComponentProps<typeof SelectableCardGroup>, 'helper' | 'error' | 'columns' | 'children' | 'showTick' | 'type' | 'className'>> & Pick<ComponentProps<typeof SelectableCardGroup>, 'legend'>;
5
+ type SelectableCardGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof SelectableCardGroup>, 'name' | 'onChange' | 'value'>;
6
6
  export declare const SelectableCardGroupField: {
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;
7
+ <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ legend, control, name, onChange, required, error: customError, columns, type, shouldUnregister, validate, ...props }: SelectableCardGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
8
8
  Card: ({ value, disabled, children, className, isError, onFocus, onBlur, tooltip, id, label, "data-testid": dataTestId, }: import("node_modules/@ultraviolet/ui/dist/components/SelectableCardGroup").CardSelectableCardProps) => import("@emotion/react/jsx-runtime").JSX.Element;
9
9
  };
10
10
  export {};
@@ -4,21 +4,17 @@ import { SelectableCardGroup } from "@ultraviolet/ui";
4
4
  import { useController } from "react-hook-form";
5
5
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
6
  const SelectableCardGroupField = ({
7
- className,
8
- legend,
7
+ legend = "",
9
8
  control,
10
9
  name,
11
10
  onChange,
12
11
  required = false,
13
- children,
14
- label = "",
15
12
  error: customError,
16
- helper,
17
13
  columns = 1,
18
- showTick,
19
14
  type = "radio",
20
15
  shouldUnregister = false,
21
- validate
16
+ validate,
17
+ ...props
22
18
  }) => {
23
19
  const {
24
20
  getError
@@ -37,7 +33,7 @@ const SelectableCardGroupField = ({
37
33
  validate
38
34
  }
39
35
  });
40
- return /* @__PURE__ */ jsx(SelectableCardGroup, { legend, name, type, showTick, value: field.value, onChange: (event) => {
36
+ return /* @__PURE__ */ jsx(SelectableCardGroup, { ...props, legend, name, type, value: field.value, onChange: (event) => {
41
37
  if (type === "checkbox") {
42
38
  const fieldValue = field.value ?? [];
43
39
  if (fieldValue?.includes(event.currentTarget.value)) {
@@ -50,8 +46,8 @@ const SelectableCardGroupField = ({
50
46
  }
51
47
  onChange?.(event.currentTarget.value);
52
48
  }, error: getError({
53
- label
54
- }, error) ?? customError, className, columns, helper, required, children });
49
+ label: legend
50
+ }, error) ?? customError, columns, required });
55
51
  };
56
52
  SelectableCardGroupField.Card = SelectableCardGroup.Card;
57
53
  export {
@@ -6,7 +6,7 @@ const ui = require("@ultraviolet/ui");
6
6
  const reactHookForm = require("react-hook-form");
7
7
  const index = require("../../providers/ErrorContext/index.cjs");
8
8
  const SelectableCardOptionGroupField = ({
9
- legend,
9
+ legend = "",
10
10
  control,
11
11
  name,
12
12
  optionName,
@@ -14,7 +14,6 @@ const SelectableCardOptionGroupField = ({
14
14
  onChangeOption,
15
15
  required = false,
16
16
  children,
17
- label = "",
18
17
  error: customError,
19
18
  shouldUnregister = false,
20
19
  validate,
@@ -53,7 +52,7 @@ const SelectableCardOptionGroupField = ({
53
52
  optionField.onChange(value);
54
53
  onChangeOption?.(value);
55
54
  }, error: getError({
56
- label
55
+ label: legend
57
56
  }, error) ?? customError, required, ...props, children });
58
57
  };
59
58
  SelectableCardOptionGroupField.Option = ui.SelectableCardOptionGroup.Option;
@@ -2,18 +2,18 @@ import { SelectableCardOptionGroup } 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 SelectableCardOptionGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<ComponentProps<typeof SelectableCardOptionGroup>, 'onChange' | 'onChangeOption'> & Partial<Pick<ComponentProps<typeof SelectableCardOptionGroup>, 'onChangeOption' | 'onChange'>> & BaseFieldProps<TFieldValues, TFieldName> & Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & {
5
+ type SelectableCardOptionGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<ComponentProps<typeof SelectableCardOptionGroup>, 'onChange' | 'onChangeOption'> & Partial<Pick<ComponentProps<typeof SelectableCardOptionGroup>, 'onChangeOption' | 'onChange'>> & Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & {
6
6
  optionName?: string;
7
7
  };
8
8
  export declare const SelectableCardOptionGroupField: {
9
- <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ legend, control, name, optionName, onChange, onChangeOption, required, children, label, error: customError, shouldUnregister, validate, ...props }: SelectableCardOptionGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
9
+ <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ legend, control, name, optionName, onChange, onChangeOption, required, children, error: customError, shouldUnregister, validate, ...props }: SelectableCardOptionGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
10
10
  Option: ({ value, label, labelDescription, "aria-label": ariaLabel, children, className, options, optionPlaceholder, image, disabled, id, "data-testid": dataTestId, tooltip, }: Omit<import("node_modules/@ultraviolet/ui/dist/components/SelectableCard").SelectableCardProps & import("react").RefAttributes<HTMLDivElement>, "onChange"> & {
11
11
  value: string;
12
12
  className?: string;
13
13
  children?: import("react").ReactNode;
14
- options: ComponentProps<typeof import("@ultraviolet/ui").SelectInputV2>["options"];
15
- optionValue?: ComponentProps<typeof import("@ultraviolet/ui").SelectInputV2>["value"];
16
- optionPlaceholder?: ComponentProps<typeof import("@ultraviolet/ui").SelectInputV2>["placeholder"];
14
+ options: ComponentProps<typeof import("@ultraviolet/ui").SelectInput>["options"];
15
+ optionValue?: ComponentProps<typeof import("@ultraviolet/ui").SelectInput>["value"];
16
+ optionPlaceholder?: ComponentProps<typeof import("@ultraviolet/ui").SelectInput>["placeholder"];
17
17
  image?: import("react").ReactNode;
18
18
  labelDescription?: ComponentProps<typeof import("@ultraviolet/ui").Label>["labelDescription"];
19
19
  id?: string;
@@ -4,7 +4,7 @@ import { SelectableCardOptionGroup } from "@ultraviolet/ui";
4
4
  import { useController } from "react-hook-form";
5
5
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
6
  const SelectableCardOptionGroupField = ({
7
- legend,
7
+ legend = "",
8
8
  control,
9
9
  name,
10
10
  optionName,
@@ -12,7 +12,6 @@ const SelectableCardOptionGroupField = ({
12
12
  onChangeOption,
13
13
  required = false,
14
14
  children,
15
- label = "",
16
15
  error: customError,
17
16
  shouldUnregister = false,
18
17
  validate,
@@ -51,7 +50,7 @@ const SelectableCardOptionGroupField = ({
51
50
  optionField.onChange(value);
52
51
  onChangeOption?.(value);
53
52
  }, error: getError({
54
- label
53
+ label: legend
55
54
  }, error) ?? customError, required, ...props, children });
56
55
  };
57
56
  SelectableCardOptionGroupField.Option = SelectableCardOptionGroup.Option;
@@ -6,8 +6,6 @@ const ui = require("@ultraviolet/ui");
6
6
  const reactHookForm = require("react-hook-form");
7
7
  const SwitchButtonField = ({
8
8
  name,
9
- leftButton,
10
- rightButton,
11
9
  size,
12
10
  control,
13
11
  shouldUnregister,
@@ -25,7 +23,7 @@ const SwitchButtonField = ({
25
23
  shouldUnregister,
26
24
  control
27
25
  });
28
- return /* @__PURE__ */ jsxRuntime.jsx(ui.SwitchButton, { ...props, name, leftButton, rightButton, onChange: (event) => {
26
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.SwitchButton, { ...props, name, onChange: (event) => {
29
27
  field.onChange(event);
30
28
  onChange?.(event.target);
31
29
  }, value: field.value, tooltip, size, className, onFocus, onBlur: (event) => {
@@ -33,4 +31,5 @@ const SwitchButtonField = ({
33
31
  onBlur?.(event);
34
32
  } });
35
33
  };
34
+ SwitchButtonField.Option = ui.SwitchButton.Option;
36
35
  exports.SwitchButtonField = SwitchButtonField;