@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,11 +1,12 @@
1
- import React, { useMemo } from 'react';
2
- import { useForm, FormProvider } from 'react-hook-form';
3
- import { FORM_ERROR } from '../../constants.js';
4
- import { defaultErrors } from './defaultErrors.js';
5
- import { jsx } from '@emotion/react/jsx-runtime';
6
- import { ErrorProvider } from '../../providers/ErrorContext/index.js';
7
-
8
- const FormSubmitContext = /*#__PURE__*/React.createContext({});
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import React, { useMemo } from "react";
3
+ import { useForm, FormProvider } from "react-hook-form";
4
+ import { FORM_ERROR } from "../../constants.js";
5
+ import { defaultErrors } from "./defaultErrors.js";
6
+ import { ErrorProvider } from "../../providers/ErrorContext/index.js";
7
+ const FormSubmitContext = React.createContext(
8
+ {}
9
+ );
9
10
  const Form = ({
10
11
  children,
11
12
  methods: methodsProp,
@@ -16,10 +17,10 @@ const Form = ({
16
17
  }) => {
17
18
  const methodsHook = useForm({
18
19
  defaultValues: initialValues,
19
- mode: 'onChange'
20
+ mode: "onChange"
20
21
  });
21
22
  const methods = !methodsProp ? methodsHook : methodsProp;
22
- const handleSubmit = methods.handleSubmit(async values => {
23
+ const handleSubmit = methods.handleSubmit(async (values) => {
23
24
  const result = await onRawSubmit(values, {
24
25
  reset: methods.reset,
25
26
  resetFieldState: methods.resetField,
@@ -27,57 +28,51 @@ const Form = ({
27
28
  change: methods.setValue
28
29
  });
29
30
  if (result === null) {
30
- methods.setError('root.submit', {
31
- type: 'custom'
31
+ methods.setError("root.submit", {
32
+ type: "custom"
32
33
  });
33
34
  return;
34
35
  }
35
- if (result && typeof result !== 'boolean' && typeof result !== 'number') {
36
- methods.setError('root.submit', {
37
- type: 'custom',
38
- message: typeof result === 'object' ? result[FORM_ERROR] : result
36
+ if (result && typeof result !== "boolean" && typeof result !== "number") {
37
+ methods.setError("root.submit", {
38
+ type: "custom",
39
+ message: typeof result === "object" ? result[FORM_ERROR] : result
39
40
  });
40
41
  }
41
42
  });
42
- const formSubmitContextValue = useMemo(() => ({
43
- handleSubmit
44
- }), [handleSubmit]);
45
- return jsx(FormProvider, {
46
- ...methods,
47
- children: jsx(FormSubmitContext.Provider, {
48
- value: formSubmitContextValue,
49
- children: jsx(ErrorProvider, {
50
- errors: {
51
- ...defaultErrors,
52
- ...errors
53
- },
54
- children: jsx("form", {
55
- onSubmit: async e => {
56
- e.preventDefault();
57
- e.stopPropagation();
58
- await handleSubmit(e);
59
- },
60
- name: name,
61
- noValidate: true,
62
- children: typeof children === 'function' ? children({
63
- values: methods.watch(),
64
- hasValidationErrors: !methods.formState.isValid,
65
- errors: methods.formState.errors,
66
- submitting: methods.formState.isSubmitting,
67
- pristine: !methods.formState.isDirty,
68
- handleSubmit,
69
- submitError: !!methods.formState.errors?.root?.['submit'],
70
- valid: methods.formState.isValid,
71
- form: {
72
- change: methods.setValue,
73
- reset: methods.reset,
74
- submit: handleSubmit
75
- }
76
- }) : children
77
- })
78
- })
79
- })
80
- });
43
+ const formSubmitContextValue = useMemo(
44
+ () => ({ handleSubmit }),
45
+ [handleSubmit]
46
+ );
47
+ return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(FormSubmitContext.Provider, { value: formSubmitContextValue, children: /* @__PURE__ */ jsx(ErrorProvider, { errors: { ...defaultErrors, ...errors }, children: /* @__PURE__ */ jsx(
48
+ "form",
49
+ {
50
+ onSubmit: async (e) => {
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ await handleSubmit(e);
54
+ },
55
+ name,
56
+ noValidate: true,
57
+ children: typeof children === "function" ? children({
58
+ values: methods.watch(),
59
+ hasValidationErrors: !methods.formState.isValid,
60
+ errors: methods.formState.errors,
61
+ submitting: methods.formState.isSubmitting,
62
+ pristine: !methods.formState.isDirty,
63
+ handleSubmit,
64
+ submitError: !!methods.formState.errors?.root?.["submit"],
65
+ valid: methods.formState.isValid,
66
+ form: {
67
+ change: methods.setValue,
68
+ reset: methods.reset,
69
+ submit: handleSubmit
70
+ }
71
+ }) : children
72
+ }
73
+ ) }) }) });
74
+ };
75
+ export {
76
+ Form,
77
+ FormSubmitContext
81
78
  };
82
-
83
- export { Form, FormSubmitContext };
@@ -0,0 +1,33 @@
1
+ import { Button } from '@ultraviolet/ui';
2
+ import type { ComponentProps } from 'react';
3
+ import type { Control, FieldArrayPath, FieldValues } from 'react-hook-form';
4
+ import { TextInputField as TextInputFieldV2 } from '../TextInputFieldV2';
5
+ type InputKeyProps = {
6
+ label: ComponentProps<typeof TextInputFieldV2>['label'];
7
+ required?: ComponentProps<typeof TextInputFieldV2>['required'];
8
+ regex?: ComponentProps<typeof TextInputFieldV2>['regex'];
9
+ };
10
+ type InputValueProps = {
11
+ type?: ComponentProps<typeof TextInputFieldV2>['type'];
12
+ placeholder?: ComponentProps<typeof TextInputFieldV2>['placeholder'];
13
+ } & InputKeyProps;
14
+ type AddButtonProps = {
15
+ name: ComponentProps<typeof Button>['children'];
16
+ fullWidth?: ComponentProps<typeof Button>['fullWidth'];
17
+ tooltip?: string;
18
+ maxSizeReachedTooltip?: string;
19
+ };
20
+ type KeyValueFieldProps<TFieldValues extends FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues>> = {
21
+ name: TFieldArrayName;
22
+ inputKey: InputKeyProps;
23
+ inputValue: InputValueProps;
24
+ addButton: AddButtonProps;
25
+ maxSize?: number;
26
+ readonly?: boolean;
27
+ control?: Control<TFieldValues>;
28
+ };
29
+ /**
30
+ * A React component that allows users to manage key-value pairs
31
+ */
32
+ export declare const KeyValueField: <TFieldValues extends FieldValues = FieldValues, TFieldArrayName extends FieldArrayPath<TFieldValues> = FieldArrayPath<TFieldValues>>({ name, inputKey, inputValue, addButton, maxSize, readonly, control, }: KeyValueFieldProps<TFieldValues, TFieldArrayName>) => import("@emotion/react/jsx-runtime").JSX.Element;
33
+ export {};
@@ -1,11 +1,7 @@
1
- import { Stack, Row, Button } from '@ultraviolet/ui';
2
- import { useFieldArray } from 'react-hook-form';
3
- import { TextInputField } from '../TextInputFieldV2/index.js';
4
- import { jsxs, jsx } from '@emotion/react/jsx-runtime';
5
-
6
- /**
7
- * A React component that allows users to manage key-value pairs
8
- */
1
+ import { jsxs, jsx } from "@emotion/react/jsx-runtime";
2
+ import { Stack, Row, Button } from "@ultraviolet/ui";
3
+ import { useFieldArray } from "react-hook-form";
4
+ import { TextInputField } from "../TextInputFieldV2/index.js";
9
5
  const KeyValueField = ({
10
6
  name,
11
7
  inputKey,
@@ -15,70 +11,75 @@ const KeyValueField = ({
15
11
  readonly = false,
16
12
  control
17
13
  }) => {
18
- const {
19
- fields,
20
- append,
21
- remove
22
- } = useFieldArray({
14
+ const { fields, append, remove } = useFieldArray({
23
15
  name,
24
16
  control
25
17
  });
26
- const canAdd = fields.length !== undefined && fields.length < maxSize;
18
+ const canAdd = fields.length !== void 0 && fields.length < maxSize;
27
19
  const maxSizeReachedTooltip = addButton.maxSizeReachedTooltip ?? `Cannot add more than ${maxSize} elements`;
28
- return jsxs(Stack, {
29
- gap: 3,
30
- children: [fields.length ? jsx(Stack, {
31
- gap: 3,
32
- children: fields.map((field, index) => jsxs(Row, {
20
+ return /* @__PURE__ */ jsxs(Stack, { gap: 3, children: [
21
+ fields.length ? /* @__PURE__ */ jsx(Stack, { gap: 3, children: fields.map((field, index) => /* @__PURE__ */ jsxs(
22
+ Row,
23
+ {
33
24
  templateColumns: "1fr 1fr auto",
34
25
  gap: 2,
35
26
  alignItems: "end",
36
- children: [jsx(TextInputField, {
37
- readOnly: readonly,
38
- required: inputKey.required,
39
- name: `${name}.${index}.key`,
40
- label: inputKey.label,
41
- regex: inputKey.regex
42
- }), jsx(TextInputField, {
43
- readOnly: readonly,
44
- required: inputValue.required,
45
- name: `${name}.${index}.value`,
46
- label: inputValue.label,
47
- placeholder: inputValue.placeholder,
48
- type: inputValue.type,
49
- autoComplete: "off",
50
- regex: inputValue.regex
51
- }), jsx(Button, {
52
- disabled: readonly,
53
- "data-testid": `remove-button-${index}`,
54
- icon: "delete",
55
- variant: "outlined",
56
- sentiment: "danger",
57
- size: "large",
58
- onClick: () => remove(index)
59
- })]
60
- }, field.id))
61
- }) : null, jsx(Stack, {
62
- direction: "row",
63
- justifyContent: "flex-start",
64
- children: jsx(Button, {
27
+ children: [
28
+ /* @__PURE__ */ jsx(
29
+ TextInputField,
30
+ {
31
+ readOnly: readonly,
32
+ required: inputKey.required,
33
+ name: `${name}.${index}.key`,
34
+ label: inputKey.label,
35
+ regex: inputKey.regex
36
+ }
37
+ ),
38
+ /* @__PURE__ */ jsx(
39
+ TextInputField,
40
+ {
41
+ readOnly: readonly,
42
+ required: inputValue.required,
43
+ name: `${name}.${index}.value`,
44
+ label: inputValue.label,
45
+ placeholder: inputValue.placeholder,
46
+ type: inputValue.type,
47
+ autoComplete: "off",
48
+ regex: inputValue.regex
49
+ }
50
+ ),
51
+ /* @__PURE__ */ jsx(
52
+ Button,
53
+ {
54
+ disabled: readonly,
55
+ "data-testid": `remove-button-${index}`,
56
+ icon: "delete",
57
+ variant: "outlined",
58
+ sentiment: "danger",
59
+ size: "large",
60
+ onClick: () => remove(index)
61
+ }
62
+ )
63
+ ]
64
+ },
65
+ field.id
66
+ )) }) : null,
67
+ /* @__PURE__ */ jsx(Stack, { direction: "row", justifyContent: "flex-start", children: /* @__PURE__ */ jsx(
68
+ Button,
69
+ {
65
70
  "data-testid": "add-button",
66
71
  icon: "plus",
67
72
  variant: "filled",
68
73
  sentiment: "neutral",
69
74
  fullWidth: addButton.fullWidth,
70
75
  disabled: !canAdd || readonly,
71
- tooltip: !canAdd ? maxSizeReachedTooltip : addButton.tooltip
72
- // @ts-expect-error can't infer properly
73
- ,
74
- onClick: () => append({
75
- key: '',
76
- value: ''
77
- }),
76
+ tooltip: !canAdd ? maxSizeReachedTooltip : addButton.tooltip,
77
+ onClick: () => append({ key: "", value: "" }),
78
78
  children: addButton.name
79
- })
80
- })]
81
- });
79
+ }
80
+ ) })
81
+ ] });
82
+ };
83
+ export {
84
+ KeyValueField
82
85
  };
83
-
84
- export { KeyValueField };
@@ -0,0 +1,13 @@
1
+ import { NumberInput } from '@ultraviolet/ui';
2
+ import type { ComponentProps, FocusEventHandler } from 'react';
3
+ import type { FieldPath, FieldValues } from 'react-hook-form';
4
+ import type { BaseFieldProps } from '../../types';
5
+ type NumberInputValueFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Partial<Pick<ComponentProps<typeof NumberInput>, 'disabled' | 'maxValue' | 'minValue' | 'onMaxCrossed' | 'onMinCrossed' | 'size' | 'step' | 'text' | 'className'>> & {
6
+ onBlur?: FocusEventHandler<HTMLInputElement>;
7
+ onFocus?: FocusEventHandler<HTMLInputElement>;
8
+ };
9
+ /**
10
+ * @deprecated This component is deprecated, use `NumberInputFieldV2` instead.
11
+ */
12
+ export declare const NumberInputField: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ disabled, maxValue, minValue, name, onChange, onBlur, onFocus, onMaxCrossed, onMinCrossed, required, size, step, text, rules, className, label, shouldUnregister, }: NumberInputValueFieldProps<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -1,11 +1,7 @@
1
- import { NumberInput } 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 `NumberInputFieldV2` instead.
8
- */
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { NumberInput } from "@ultraviolet/ui";
3
+ import { useController } from "react-hook-form";
4
+ import { useErrors } from "../../providers/ErrorContext/index.js";
9
5
  const NumberInputField = ({
10
6
  disabled,
11
7
  maxValue,
@@ -25,14 +21,10 @@ const NumberInputField = ({
25
21
  label,
26
22
  shouldUnregister = false
27
23
  }) => {
28
- const {
29
- getError
30
- } = useErrors();
24
+ const { getError } = useErrors();
31
25
  const {
32
26
  field,
33
- fieldState: {
34
- error
35
- }
27
+ fieldState: { error }
36
28
  } = useController({
37
29
  name,
38
30
  shouldUnregister,
@@ -43,35 +35,37 @@ const NumberInputField = ({
43
35
  ...rules
44
36
  }
45
37
  });
46
- return jsx(NumberInput, {
47
- name: field.name,
48
- value: field.value,
49
- disabled: disabled,
50
- onBlur: event => {
51
- field.onBlur();
52
- onBlur?.(event);
53
- },
54
- onChange: event => {
55
- // React hook form doesnt allow undefined values after definition https://react-hook-form.com/docs/usecontroller/controller (that make sense)
56
- field.onChange(event ?? null);
57
- onChange?.(event);
58
- },
59
- onFocus: onFocus,
60
- maxValue: maxValue,
61
- minValue: minValue,
62
- onMinCrossed: onMinCrossed,
63
- onMaxCrossed: onMaxCrossed,
64
- size: size,
65
- step: step,
66
- text: text,
67
- className: className,
68
- label: label,
69
- error: getError({
70
- label: label ?? '',
71
- max: maxValue,
72
- min: minValue
73
- }, error)
74
- });
38
+ return /* @__PURE__ */ jsx(
39
+ NumberInput,
40
+ {
41
+ name: field.name,
42
+ value: field.value,
43
+ disabled,
44
+ onBlur: (event) => {
45
+ field.onBlur();
46
+ onBlur?.(event);
47
+ },
48
+ onChange: (event) => {
49
+ field.onChange(event ?? null);
50
+ onChange?.(event);
51
+ },
52
+ onFocus,
53
+ maxValue,
54
+ minValue,
55
+ onMinCrossed,
56
+ onMaxCrossed,
57
+ size,
58
+ step,
59
+ text,
60
+ className,
61
+ label,
62
+ error: getError(
63
+ { label: label ?? "", max: maxValue, min: minValue },
64
+ error
65
+ )
66
+ }
67
+ );
68
+ };
69
+ export {
70
+ NumberInputField
75
71
  };
76
-
77
- export { NumberInputField };
@@ -0,0 +1,11 @@
1
+ import { NumberInputV2 } 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 NumberInputV2Props<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TName> & Partial<Pick<ComponentProps<typeof NumberInputV2>, 'disabled' | 'id' | 'onBlur' | 'onChange' | 'onFocus' | 'value' | 'data-testid' | 'label' | 'tooltip' | 'unit' | 'size' | 'step' | 'className' | 'placeholder' | 'error' | 'success' | 'helper' | 'labelDescription' | 'aria-label' | 'autoFocus' | 'readOnly' | 'min' | 'max'>> & {
6
+ className?: string;
7
+ name: string;
8
+ required?: boolean;
9
+ };
10
+ export declare const NumberInputFieldV2: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ disabled, max, min, name, onChange, onBlur, size, step, unit, tooltip, className, label, labelDescription, id, placeholder, success, helper, rules, "aria-label": ariaLabel, "data-testid": dataTestId, required, autoFocus, readOnly, shouldUnregister, }: NumberInputV2Props<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -1,8 +1,7 @@
1
- import { NumberInputV2 } 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 { NumberInputV2 } from "@ultraviolet/ui";
3
+ import { useController } from "react-hook-form";
4
+ import { useErrors } from "../../providers/ErrorContext/index.js";
6
5
  const NumberInputFieldV2 = ({
7
6
  disabled,
8
7
  max = Number.MAX_SAFE_INTEGER,
@@ -22,21 +21,17 @@ const NumberInputFieldV2 = ({
22
21
  success,
23
22
  helper,
24
23
  rules,
25
- 'aria-label': ariaLabel,
26
- 'data-testid': dataTestId,
24
+ "aria-label": ariaLabel,
25
+ "data-testid": dataTestId,
27
26
  required,
28
27
  autoFocus,
29
28
  readOnly,
30
29
  shouldUnregister = false
31
30
  }) => {
32
- const {
33
- getError
34
- } = useErrors();
31
+ const { getError } = useErrors();
35
32
  const {
36
33
  field,
37
- fieldState: {
38
- error
39
- }
34
+ fieldState: { error }
40
35
  } = useController({
41
36
  name,
42
37
  shouldUnregister,
@@ -47,43 +42,42 @@ const NumberInputFieldV2 = ({
47
42
  ...rules
48
43
  }
49
44
  });
50
- return jsx(NumberInputV2, {
51
- name: field.name,
52
- value: field.value,
53
- disabled: disabled,
54
- onBlur: event => {
55
- field.onBlur();
56
- onBlur?.(event);
57
- },
58
- onChange: newValue => {
59
- // React hook form doesnt allow undefined values after definition https://react-hook-form.com/docs/usecontroller/controller (that make sense)
60
- field.onChange(newValue);
61
- onChange?.(newValue);
62
- },
63
- max: max,
64
- min: min,
65
- size: size,
66
- step: step,
67
- className: className,
68
- "data-testid": dataTestId,
69
- id: id,
70
- label: label,
71
- labelDescription: labelDescription,
72
- placeholder: placeholder,
73
- error: getError({
74
- label: label ?? '',
45
+ return /* @__PURE__ */ jsx(
46
+ NumberInputV2,
47
+ {
48
+ name: field.name,
49
+ value: field.value,
50
+ disabled,
51
+ onBlur: (event) => {
52
+ field.onBlur();
53
+ onBlur?.(event);
54
+ },
55
+ onChange: (newValue) => {
56
+ field.onChange(newValue);
57
+ onChange?.(newValue);
58
+ },
75
59
  max,
76
- min
77
- }, error),
78
- success: success,
79
- helper: helper,
80
- tooltip: tooltip,
81
- unit: unit,
82
- "aria-label": ariaLabel,
83
- autoFocus: autoFocus,
84
- readOnly: readOnly,
85
- required: required
86
- });
60
+ min,
61
+ size,
62
+ step,
63
+ className,
64
+ "data-testid": dataTestId,
65
+ id,
66
+ label,
67
+ labelDescription,
68
+ placeholder,
69
+ error: getError({ label: label ?? "", max, min }, error),
70
+ success,
71
+ helper,
72
+ tooltip,
73
+ unit,
74
+ "aria-label": ariaLabel,
75
+ autoFocus,
76
+ readOnly,
77
+ required
78
+ }
79
+ );
80
+ };
81
+ export {
82
+ NumberInputFieldV2
87
83
  };
88
-
89
- export { NumberInputFieldV2 };
@@ -0,0 +1,12 @@
1
+ import { Radio } 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 RadioFieldProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TName>, 'label'> & Partial<Pick<ComponentProps<typeof Radio>, 'disabled' | 'id' | 'onBlur' | 'onFocus' | 'data-testid' | 'tooltip' | 'label'>> & {
6
+ className?: string;
7
+ };
8
+ /**
9
+ * @deprecated This component is deprecated, use `RadioGroupField` instead.
10
+ */
11
+ export declare const RadioField: <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ className, "data-testid": dataTestId, disabled, id, name, onBlur, label, onChange, onFocus, required, value, rules, tooltip, shouldUnregister, }: RadioFieldProps<TFieldValues, TName>) => import("@emotion/react/jsx-runtime").JSX.Element;
12
+ export {};