@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
@@ -16,12 +16,12 @@ const CheckboxGroupField = ({
16
16
  control,
17
17
  children,
18
18
  onChange,
19
- label = "",
20
19
  error: customError,
21
20
  name,
22
21
  required = false,
23
22
  shouldUnregister = false,
24
23
  validate,
24
+ legend = "",
25
25
  ...props
26
26
  }) => {
27
27
  const {
@@ -73,8 +73,8 @@ const CheckboxGroupField = ({
73
73
  }
74
74
  onChange?.(event.currentTarget.value);
75
75
  }, error: getError({
76
- label
77
- }, error) ?? customError, name, required, children });
76
+ label: legend
77
+ }, error) ?? customError, name, required, legend, children });
78
78
  };
79
79
  CheckboxGroupField.Checkbox = ui.CheckboxGroup.Checkbox;
80
80
  exports.CheckboxGroupField = CheckboxGroupField;
@@ -2,9 +2,9 @@ import { CheckboxGroup } from '@ultraviolet/ui';
2
2
  import type { ComponentProps } from 'react';
3
3
  import type { FieldPath, FieldValues } from 'react-hook-form';
4
4
  import type { BaseFieldProps } from '../../types';
5
- type CheckboxGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof CheckboxGroup>, 'value' | 'onChange'>;
5
+ type CheckboxGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & Omit<ComponentProps<typeof CheckboxGroup>, 'value' | 'onChange'>;
6
6
  export declare const CheckboxGroupField: {
7
- <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, children, onChange, label, error: customError, name, required, shouldUnregister, validate, ...props }: CheckboxGroupFieldProps<TFieldValues, TFieldName>): import("@emotion/react/jsx-runtime").JSX.Element;
7
+ <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, children, onChange, error: customError, name, required, shouldUnregister, validate, legend, ...props }: CheckboxGroupFieldProps<TFieldValues, TFieldName>): import("@emotion/react/jsx-runtime").JSX.Element;
8
8
  Checkbox: ({ onFocus, onBlur, disabled, error, name, value, children, helper, className, autoFocus, "data-testid": dataTestId, required, }: Omit<({
9
9
  error?: string | import("react").ReactNode;
10
10
  size?: number;
@@ -14,12 +14,12 @@ const CheckboxGroupField = ({
14
14
  control,
15
15
  children,
16
16
  onChange,
17
- label = "",
18
17
  error: customError,
19
18
  name,
20
19
  required = false,
21
20
  shouldUnregister = false,
22
21
  validate,
22
+ legend = "",
23
23
  ...props
24
24
  }) => {
25
25
  const {
@@ -71,8 +71,8 @@ const CheckboxGroupField = ({
71
71
  }
72
72
  onChange?.(event.currentTarget.value);
73
73
  }, error: getError({
74
- label
75
- }, error) ?? customError, name, required, children });
74
+ label: legend
75
+ }, error) ?? customError, name, required, legend, children });
76
76
  };
77
77
  CheckboxGroupField.Checkbox = CheckboxGroup.Checkbox;
78
78
  export {
@@ -15,25 +15,15 @@ const DateField = ({
15
15
  control,
16
16
  label = "",
17
17
  format,
18
- locale,
19
- maxDate: maxDate$1,
20
18
  minDate: minDate$1,
21
- disabled,
19
+ maxDate: maxDate$1,
22
20
  onChange,
23
21
  onBlur,
24
- onFocus,
25
22
  validate,
26
- autoFocus = false,
27
- excludeDates,
28
23
  selectsRange,
29
- size,
30
- placeholder,
31
- tooltip,
32
- clearable,
33
- "data-testid": dataTestId,
34
- shouldUnregister = false,
35
24
  showMonthYearPicker,
36
- input = "text"
25
+ shouldUnregister = false,
26
+ ...props
37
27
  }) => {
38
28
  const {
39
29
  getError
@@ -56,14 +46,14 @@ const DateField = ({
56
46
  }
57
47
  }
58
48
  });
59
- return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { name: field.name, label, placeholder, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
49
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.DateInput, { ...props, name: field.name, label, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
60
50
  if (!value) return "";
61
51
  const date = parseDate(value);
62
52
  return showMonthYearPicker ? date.toLocaleDateString(void 0, {
63
53
  year: "numeric",
64
54
  month: "numeric"
65
55
  }) : date.toLocaleDateString();
66
- }), locale, required, onChange: (val) => {
56
+ }), required, onChange: (val) => {
67
57
  if (val && val instanceof Date) {
68
58
  onChange?.(val);
69
59
  const newDate = parseDate(val);
@@ -84,10 +74,10 @@ const DateField = ({
84
74
  }, onBlur: (e) => {
85
75
  field.onBlur();
86
76
  onBlur?.(e);
87
- }, onFocus, maxDate: maxDate$1, size, minDate: minDate$1, error: getError({
77
+ }, maxDate: maxDate$1, minDate: minDate$1, error: getError({
88
78
  minDate: minDate$1,
89
79
  maxDate: maxDate$1,
90
80
  label
91
- }, error), disabled, autoFocus, excludeDates, selectsRange, showMonthYearPicker, "data-testid": dataTestId, clearable, tooltip, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, input });
81
+ }, error), selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0 });
92
82
  };
93
83
  exports.DateField = DateField;
@@ -1,17 +1,7 @@
1
1
  import { DateInput } from '@ultraviolet/ui';
2
- import type { ComponentProps, FocusEvent } from 'react';
2
+ import type { ComponentProps } from 'react';
3
3
  import type { FieldPath, FieldValues } from 'react-hook-form';
4
4
  import type { BaseFieldProps } from '../../types';
5
- type DateFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof DateInput>, 'maxDate' | 'minDate' | 'disabled' | 'required' | 'locale' | 'name' | 'onChange' | 'onFocus' | 'onBlur' | 'autoFocus' | 'stardDate' | 'endDate'> & {
6
- maxDate?: Date;
7
- minDate?: Date;
8
- disabled?: boolean;
9
- required?: boolean;
10
- locale?: string;
11
- onBlur?: (event: FocusEvent<HTMLElement>) => void;
12
- onFocus?: (value: FocusEvent<HTMLElement>) => void;
13
- autoFocus?: boolean;
14
- placeholder?: string;
15
- };
16
- export declare const DateField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, label, format, locale, maxDate, minDate, disabled, onChange, onBlur, onFocus, validate, autoFocus, excludeDates, selectsRange, size, placeholder, tooltip, clearable, "data-testid": dataTestId, shouldUnregister, showMonthYearPicker, input, }: DateFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ type DateFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof DateInput>, 'required' | 'name' | 'onChange' | 'value'>;
6
+ export declare const DateField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ required, name, control, label, format, minDate, maxDate, onChange, onBlur, validate, selectsRange, showMonthYearPicker, shouldUnregister, ...props }: DateFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
17
7
  export {};
@@ -13,25 +13,15 @@ const DateField = ({
13
13
  control,
14
14
  label = "",
15
15
  format,
16
- locale,
17
- maxDate,
18
16
  minDate,
19
- disabled,
17
+ maxDate,
20
18
  onChange,
21
19
  onBlur,
22
- onFocus,
23
20
  validate,
24
- autoFocus = false,
25
- excludeDates,
26
21
  selectsRange,
27
- size,
28
- placeholder,
29
- tooltip,
30
- clearable,
31
- "data-testid": dataTestId,
32
- shouldUnregister = false,
33
22
  showMonthYearPicker,
34
- input = "text"
23
+ shouldUnregister = false,
24
+ ...props
35
25
  }) => {
36
26
  const {
37
27
  getError
@@ -54,14 +44,14 @@ const DateField = ({
54
44
  }
55
45
  }
56
46
  });
57
- return /* @__PURE__ */ jsx(DateInput, { name: field.name, label, placeholder, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
47
+ return /* @__PURE__ */ jsx(DateInput, { ...props, name: field.name, label, value: Array.isArray(field.value) ? void 0 : field.value, format: format || ((value) => {
58
48
  if (!value) return "";
59
49
  const date = parseDate(value);
60
50
  return showMonthYearPicker ? date.toLocaleDateString(void 0, {
61
51
  year: "numeric",
62
52
  month: "numeric"
63
53
  }) : date.toLocaleDateString();
64
- }), locale, required, onChange: (val) => {
54
+ }), required, onChange: (val) => {
65
55
  if (val && val instanceof Date) {
66
56
  onChange?.(val);
67
57
  const newDate = parseDate(val);
@@ -82,11 +72,11 @@ const DateField = ({
82
72
  }, onBlur: (e) => {
83
73
  field.onBlur();
84
74
  onBlur?.(e);
85
- }, onFocus, maxDate, size, minDate, error: getError({
75
+ }, maxDate, minDate, error: getError({
86
76
  minDate,
87
77
  maxDate,
88
78
  label
89
- }, error), disabled, autoFocus, excludeDates, selectsRange, showMonthYearPicker, "data-testid": dataTestId, clearable, tooltip, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0, input });
79
+ }, error), selectsRange, showMonthYearPicker, startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0, endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0 });
90
80
  };
91
81
  export {
92
82
  DateField
@@ -2,9 +2,28 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("@emotion/react/jsx-runtime");
5
+ const _styled = require("@emotion/styled/base");
5
6
  const reactHookForm = require("react-hook-form");
6
7
  const defaultErrors = require("./defaultErrors.cjs");
7
8
  const index = require("../../providers/ErrorContext/index.cjs");
9
+ const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
10
+ const _styled__default = /* @__PURE__ */ _interopDefaultCompat(_styled);
11
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() {
12
+ return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
13
+ }
14
+ const StyledForm = /* @__PURE__ */ _styled__default.default("form", process.env.NODE_ENV === "production" ? {
15
+ target: "ep3wzi00"
16
+ } : {
17
+ target: "ep3wzi00",
18
+ label: "StyledForm"
19
+ })(process.env.NODE_ENV === "production" ? {
20
+ name: "49aokf",
21
+ styles: "display:contents"
22
+ } : {
23
+ name: "49aokf",
24
+ styles: "display:contents/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL3VsdHJhdmlvbGV0L3VsdHJhdmlvbGV0L3BhY2thZ2VzL2Zvcm0vc3JjL2NvbXBvbmVudHMvRm9ybS9pbmRleC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBb0I4QiIsImZpbGUiOiIvaG9tZS9ydW5uZXIvd29yay91bHRyYXZpb2xldC91bHRyYXZpb2xldC9wYWNrYWdlcy9mb3JtL3NyYy9jb21wb25lbnRzL0Zvcm0vaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBjbGllbnQnXG5cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJ1xuaW1wb3J0IHR5cGUgeyBSZWFjdE5vZGUgfSBmcm9tICdyZWFjdCdcbmltcG9ydCB0eXBlIHsgRmllbGRWYWx1ZXMsIFVzZUZvcm1SZXR1cm4gfSBmcm9tICdyZWFjdC1ob29rLWZvcm0nXG5pbXBvcnQgeyBGb3JtUHJvdmlkZXIgfSBmcm9tICdyZWFjdC1ob29rLWZvcm0nXG5pbXBvcnQgeyBFcnJvclByb3ZpZGVyIH0gZnJvbSAnLi4vLi4vcHJvdmlkZXJzJ1xuaW1wb3J0IHR5cGUgeyBGb3JtRXJyb3JzIH0gZnJvbSAnLi4vLi4vdH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IH0pXG5cbiAgcmV0dXJuIChcbiAgICA8Rm9ybVByb3ZpZGVyIHsuLi5tZXRob2RzfT5cbiAgICAgIDxFcnJvclByb3ZpZGVyIGVycm9ycz17eyAuLi5kZWZhdWx0RXJyb3JzLCAuLi5lcnJvcnMgfX0+XG4gICAgICAgIDxTdHlsZWRGb3JtXG4gICAgICAgICAgb25TdWJtaXQ9e2FzeW5jIGUgPT4ge1xuICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpXG4gICAgICAgICAgICBhd2FpdCBoYW5kbGVTdWJtaXQoZSlcbiAgICAgICAgICB9fVxuICAgICAgICAgIG5hbWU9e25hbWV9XG4gICAgICAgICAgbm9WYWxpZGF0ZVxuICAgICAgICA+XG4gICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1N0eWxlZEZvcm0+XG4gICAgICA8L0Vycm9yUHJvdmlkZXI+XG4gICAgPC9Gb3JtUHJvdmlkZXI+XG4gIClcbn1cbiJdfQ== */",
25
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
26
+ });
8
27
  const Form = ({
9
28
  children,
10
29
  methods,
@@ -24,7 +43,7 @@ const Form = ({
24
43
  return /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...methods, children: /* @__PURE__ */ jsxRuntime.jsx(index.ErrorProvider, { errors: {
25
44
  ...defaultErrors.defaultErrors,
26
45
  ...errors
27
- }, children: /* @__PURE__ */ jsxRuntime.jsx("form", { onSubmit: async (e) => {
46
+ }, children: /* @__PURE__ */ jsxRuntime.jsx(StyledForm, { onSubmit: async (e) => {
28
47
  e.preventDefault();
29
48
  e.stopPropagation();
30
49
  await handleSubmit(e);
@@ -1,8 +1,25 @@
1
1
  "use client";
2
2
  import { jsx } from "@emotion/react/jsx-runtime";
3
+ import _styled from "@emotion/styled/base";
3
4
  import { FormProvider } from "react-hook-form";
4
5
  import { defaultErrors } from "./defaultErrors.js";
5
6
  import { ErrorProvider } from "../../providers/ErrorContext/index.js";
7
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() {
8
+ return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
9
+ }
10
+ const StyledForm = /* @__PURE__ */ _styled("form", process.env.NODE_ENV === "production" ? {
11
+ target: "ep3wzi00"
12
+ } : {
13
+ target: "ep3wzi00",
14
+ label: "StyledForm"
15
+ })(process.env.NODE_ENV === "production" ? {
16
+ name: "49aokf",
17
+ styles: "display:contents"
18
+ } : {
19
+ name: "49aokf",
20
+ styles: "display:contents/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL3VsdHJhdmlvbGV0L3VsdHJhdmlvbGV0L3BhY2thZ2VzL2Zvcm0vc3JjL2NvbXBvbmVudHMvRm9ybS9pbmRleC50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBb0I4QiIsImZpbGUiOiIvaG9tZS9ydW5uZXIvd29yay91bHRyYXZpb2xldC91bHRyYXZpb2xldC9wYWNrYWdlcy9mb3JtL3NyYy9jb21wb25lbnRzL0Zvcm0vaW5kZXgudHN4Iiwic291cmNlc0NvbnRlbnQiOlsiJ3VzZSBjbGllbnQnXG5cbmltcG9ydCBzdHlsZWQgZnJvbSAnQGVtb3Rpb24vc3R5bGVkJ1xuaW1wb3J0IHR5cGUgeyBSZWFjdE5vZGUgfSBmcm9tICdyZWFjdCdcbmltcG9ydCB0eXBlIHsgRmllbGRWYWx1ZXMsIFVzZUZvcm1SZXR1cm4gfSBmcm9tICdyZWFjdC1ob29rLWZvcm0nXG5pbXBvcnQgeyBGb3JtUHJvdmlkZXIgfSBmcm9tICdyZWFjdC1ob29rLWZvcm0nXG5pbXBvcnQgeyBFcnJvclByb3ZpZGVyIH0gZnJvbSAnLi4vLi4vcHJv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nY3VzdG9tJyxcbiAgICAgICAgbWVzc2FnZTogcmVzdWx0LFxuICAgICAgfSlcbiAgICB9XG4gIH0pXG5cbiAgcmV0dXJuIChcbiAgICA8Rm9ybVByb3ZpZGVyIHsuLi5tZXRob2RzfT5cbiAgICAgIDxFcnJvclByb3ZpZGVyIGVycm9ycz17eyAuLi5kZWZhdWx0RXJyb3JzLCAuLi5lcnJvcnMgfX0+XG4gICAgICAgIDxTdHlsZWRGb3JtXG4gICAgICAgICAgb25TdWJtaXQ9e2FzeW5jIGUgPT4ge1xuICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpXG4gICAgICAgICAgICBlLnN0b3BQcm9wYWdhdGlvbigpXG4gICAgICAgICAgICBhd2FpdCBoYW5kbGVTdWJtaXQoZSlcbiAgICAgICAgICB9fVxuICAgICAgICAgIG5hbWU9e25hbWV9XG4gICAgICAgICAgbm9WYWxpZGF0ZVxuICAgICAgICA+XG4gICAgICAgICAge2NoaWxkcmVufVxuICAgICAgICA8L1N0eWxlZEZvcm0+XG4gICAgICA8L0Vycm9yUHJvdmlkZXI+XG4gICAgPC9Gb3JtUHJvdmlkZXI+XG4gIClcbn1cbiJdfQ== */",
21
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
22
+ });
6
23
  const Form = ({
7
24
  children,
8
25
  methods,
@@ -22,7 +39,7 @@ const Form = ({
22
39
  return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(ErrorProvider, { errors: {
23
40
  ...defaultErrors,
24
41
  ...errors
25
- }, children: /* @__PURE__ */ jsx("form", { onSubmit: async (e) => {
42
+ }, children: /* @__PURE__ */ jsx(StyledForm, { onSubmit: async (e) => {
26
43
  e.preventDefault();
27
44
  e.stopPropagation();
28
45
  await handleSubmit(e);
@@ -5,7 +5,7 @@ const jsxRuntime = require("@emotion/react/jsx-runtime");
5
5
  const icons = require("@ultraviolet/icons");
6
6
  const ui = require("@ultraviolet/ui");
7
7
  const reactHookForm = require("react-hook-form");
8
- const index = require("../TextInputFieldV2/index.cjs");
8
+ const index = require("../TextInputField/index.cjs");
9
9
  const KeyValueField = ({
10
10
  name,
11
11
  inputKey,
@@ -1,15 +1,15 @@
1
1
  import { Button } from '@ultraviolet/ui';
2
2
  import type { ComponentProps } from 'react';
3
3
  import type { Control, FieldArrayPath, FieldValues } from 'react-hook-form';
4
- import { TextInputField as TextInputFieldV2 } from '../TextInputFieldV2';
4
+ import { TextInputField } from '../TextInputField';
5
5
  type InputKeyProps = {
6
- label: ComponentProps<typeof TextInputFieldV2>['label'];
7
- required?: ComponentProps<typeof TextInputFieldV2>['required'];
8
- regex?: ComponentProps<typeof TextInputFieldV2>['regex'];
6
+ label: ComponentProps<typeof TextInputField>['label'];
7
+ required?: ComponentProps<typeof TextInputField>['required'];
8
+ regex?: ComponentProps<typeof TextInputField>['regex'];
9
9
  };
10
10
  type InputValueProps = {
11
- type?: ComponentProps<typeof TextInputFieldV2>['type'];
12
- placeholder?: ComponentProps<typeof TextInputFieldV2>['placeholder'];
11
+ type?: ComponentProps<typeof TextInputField>['type'];
12
+ placeholder?: ComponentProps<typeof TextInputField>['placeholder'];
13
13
  } & InputKeyProps;
14
14
  type AddButtonProps = {
15
15
  name: ComponentProps<typeof Button>['children'];
@@ -3,7 +3,7 @@ import { jsxs, jsx } from "@emotion/react/jsx-runtime";
3
3
  import { DeleteIcon, PlusIcon } from "@ultraviolet/icons";
4
4
  import { Stack, Row, Button } from "@ultraviolet/ui";
5
5
  import { useFieldArray } from "react-hook-form";
6
- import { TextInputField } from "../TextInputFieldV2/index.js";
6
+ import { TextInputField } from "../TextInputField/index.js";
7
7
  const KeyValueField = ({
8
8
  name,
9
9
  inputKey,
@@ -4,26 +4,22 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const jsxRuntime = require("@emotion/react/jsx-runtime");
5
5
  const ui = require("@ultraviolet/ui");
6
6
  const reactHookForm = require("react-hook-form");
7
+ const isInteger = require("../../validators/isInteger.cjs");
7
8
  const index = require("../../providers/ErrorContext/index.cjs");
8
9
  const NumberInputField = ({
9
- disabled,
10
- maxValue,
11
- minValue,
10
+ control,
11
+ max = Number.MAX_SAFE_INTEGER,
12
+ min = 0,
12
13
  name,
13
14
  onChange,
14
15
  onBlur,
15
- onFocus,
16
- onMaxCrossed,
17
- onMinCrossed,
18
- required,
19
- size,
20
16
  step,
21
- text,
22
- className,
23
17
  label,
18
+ "aria-label": ariaLabel,
19
+ required,
24
20
  shouldUnregister = false,
25
21
  validate,
26
- control
22
+ ...props
27
23
  }) => {
28
24
  const {
29
25
  getError
@@ -35,25 +31,29 @@ const NumberInputField = ({
35
31
  }
36
32
  } = reactHookForm.useController({
37
33
  name,
38
- shouldUnregister,
39
34
  control,
35
+ shouldUnregister,
40
36
  rules: {
41
- max: maxValue,
42
- min: minValue,
37
+ max,
38
+ min,
43
39
  required,
44
- validate
40
+ validate: {
41
+ ...validate,
42
+ isInteger: isInteger.isInteger(step)
43
+ }
45
44
  }
46
45
  });
47
- return /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInput, { name: field.name, value: field.value, disabled, onBlur: (event) => {
46
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.NumberInput, { ...props, name: field.name, value: field.value, onBlur: (event) => {
48
47
  field.onBlur();
49
48
  onBlur?.(event);
50
- }, onChange: (event) => {
51
- field.onChange(event ?? null);
52
- onChange?.(event);
53
- }, onFocus, maxValue, minValue, onMinCrossed, onMaxCrossed, size, step, text, className, label, error: getError({
54
- label: label ?? "",
55
- max: maxValue,
56
- min: minValue
57
- }, error) });
49
+ }, onChange: (newValue) => {
50
+ field.onChange(newValue);
51
+ onChange?.(newValue);
52
+ }, max, min, step, label, error: getError({
53
+ label: label ?? ariaLabel ?? name,
54
+ max,
55
+ min,
56
+ isInteger: step
57
+ }, error), "aria-label": ariaLabel, required });
58
58
  };
59
59
  exports.NumberInputField = NumberInputField;
@@ -1,13 +1,7 @@
1
1
  import { NumberInput } from '@ultraviolet/ui';
2
- import type { ComponentProps, FocusEventHandler } from 'react';
2
+ import type { ComponentProps } from 'react';
3
3
  import type { FieldPath, FieldValues } from 'react-hook-form';
4
4
  import type { BaseFieldProps } from '../../types';
5
- type NumberInputValueFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & 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, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ disabled, maxValue, minValue, name, onChange, onBlur, onFocus, onMaxCrossed, onMinCrossed, required, size, step, text, className, label, shouldUnregister, validate, control, }: NumberInputValueFieldProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ type NumberInputProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof NumberInput>, 'onChange'>;
6
+ export declare const NumberInputField: <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, max, min, name, onChange, onBlur, step, label, "aria-label": ariaLabel, required, shouldUnregister, validate, ...props }: NumberInputProps<TFieldValues, TFieldName>) => import("@emotion/react/jsx-runtime").JSX.Element;
13
7
  export {};
@@ -2,26 +2,22 @@
2
2
  import { jsx } from "@emotion/react/jsx-runtime";
3
3
  import { NumberInput } from "@ultraviolet/ui";
4
4
  import { useController } from "react-hook-form";
5
+ import { isInteger } from "../../validators/isInteger.js";
5
6
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
7
  const NumberInputField = ({
7
- disabled,
8
- maxValue,
9
- minValue,
8
+ control,
9
+ max = Number.MAX_SAFE_INTEGER,
10
+ min = 0,
10
11
  name,
11
12
  onChange,
12
13
  onBlur,
13
- onFocus,
14
- onMaxCrossed,
15
- onMinCrossed,
16
- required,
17
- size,
18
14
  step,
19
- text,
20
- className,
21
15
  label,
16
+ "aria-label": ariaLabel,
17
+ required,
22
18
  shouldUnregister = false,
23
19
  validate,
24
- control
20
+ ...props
25
21
  }) => {
26
22
  const {
27
23
  getError
@@ -33,26 +29,30 @@ const NumberInputField = ({
33
29
  }
34
30
  } = useController({
35
31
  name,
36
- shouldUnregister,
37
32
  control,
33
+ shouldUnregister,
38
34
  rules: {
39
- max: maxValue,
40
- min: minValue,
35
+ max,
36
+ min,
41
37
  required,
42
- validate
38
+ validate: {
39
+ ...validate,
40
+ isInteger: isInteger(step)
41
+ }
43
42
  }
44
43
  });
45
- return /* @__PURE__ */ jsx(NumberInput, { name: field.name, value: field.value, disabled, onBlur: (event) => {
44
+ return /* @__PURE__ */ jsx(NumberInput, { ...props, name: field.name, value: field.value, onBlur: (event) => {
46
45
  field.onBlur();
47
46
  onBlur?.(event);
48
- }, onChange: (event) => {
49
- field.onChange(event ?? null);
50
- onChange?.(event);
51
- }, onFocus, maxValue, minValue, onMinCrossed, onMaxCrossed, size, step, text, className, label, error: getError({
52
- label: label ?? "",
53
- max: maxValue,
54
- min: minValue
55
- }, error) });
47
+ }, onChange: (newValue) => {
48
+ field.onChange(newValue);
49
+ onChange?.(newValue);
50
+ }, max, min, step, label, error: getError({
51
+ label: label ?? ariaLabel ?? name,
52
+ max,
53
+ min,
54
+ isInteger: step
55
+ }, error), "aria-label": ariaLabel, required });
56
56
  };
57
57
  export {
58
58
  NumberInputField
@@ -11,11 +11,10 @@ const RadioGroupField = ({
11
11
  onChange,
12
12
  required,
13
13
  children,
14
- label = "",
15
14
  error: customError,
16
15
  shouldUnregister = false,
17
16
  validate,
18
- legend,
17
+ legend = "",
19
18
  ...props
20
19
  }) => {
21
20
  const {
@@ -39,8 +38,8 @@ const RadioGroupField = ({
39
38
  field.onChange(event);
40
39
  onChange?.(event.target.value);
41
40
  }, required, value: field.value, error: getError({
42
- label
43
- }, error) ?? customError, legend: legend ?? "", children });
41
+ label: legend
42
+ }, error) ?? customError, legend, children });
44
43
  };
45
44
  RadioGroupField.Radio = ui.RadioGroup.Radio;
46
45
  exports.RadioGroupField = RadioGroupField;
@@ -2,9 +2,9 @@ import { RadioGroup } 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 RadioGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = BaseFieldProps<TFieldValues, TFieldName> & Omit<ComponentProps<typeof RadioGroup>, 'value' | 'onChange' | 'legend'> & Partial<Pick<ComponentProps<typeof RadioGroup>, 'legend'>>;
5
+ type RadioGroupFieldProps<TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues>> = Omit<BaseFieldProps<TFieldValues, TFieldName>, 'label'> & Omit<ComponentProps<typeof RadioGroup>, 'value' | 'onChange' | 'legend'> & Partial<Pick<ComponentProps<typeof RadioGroup>, 'legend'>>;
6
6
  export declare const RadioGroupField: {
7
- <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, name, onChange, required, children, label, error: customError, shouldUnregister, validate, legend, ...props }: RadioGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
7
+ <TFieldValues extends FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ control, name, onChange, required, children, error: customError, shouldUnregister, validate, legend, ...props }: RadioGroupFieldProps<TFieldValues, TFieldName>): JSX.Element;
8
8
  Radio: ({ onFocus, onBlur, disabled, error, name, value, label, helper, className, autoFocus, onKeyDown, tooltip, "data-testid": dataTestId, }: Omit<({
9
9
  error?: import("react").ReactNode;
10
10
  value: string | number;
@@ -9,11 +9,10 @@ const RadioGroupField = ({
9
9
  onChange,
10
10
  required,
11
11
  children,
12
- label = "",
13
12
  error: customError,
14
13
  shouldUnregister = false,
15
14
  validate,
16
- legend,
15
+ legend = "",
17
16
  ...props
18
17
  }) => {
19
18
  const {
@@ -37,8 +36,8 @@ const RadioGroupField = ({
37
36
  field.onChange(event);
38
37
  onChange?.(event.target.value);
39
38
  }, required, value: field.value, error: getError({
40
- label
41
- }, error) ?? customError, legend: legend ?? "", children });
39
+ label: legend
40
+ }, error) ?? customError, legend, children });
42
41
  };
43
42
  RadioGroupField.Radio = RadioGroup.Radio;
44
43
  export {