@ultraviolet/form 6.0.16 → 6.1.0

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 (105) hide show
  1. package/dist/.vite/license.md +3 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/asyncToGenerator.js +32 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/defineProperty.js +15 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/objectSpread2.js +28 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/objectWithoutProperties.js +18 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/objectWithoutPropertiesLoose.js +15 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/toPrimitive.js +17 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/toPropertyKey.js +12 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.113.0/helpers/typeof.js +14 -0
  10. package/dist/_virtual/_rolldown/runtime.js +9 -0
  11. package/dist/components/CheckboxField/index.d.ts +1 -1
  12. package/dist/components/CheckboxField/index.d.ts.map +1 -1
  13. package/dist/components/CheckboxField/index.js +57 -56
  14. package/dist/components/CheckboxGroupField/index.d.ts.map +1 -1
  15. package/dist/components/CheckboxGroupField/index.js +65 -95
  16. package/dist/components/DateInputField/index.d.ts.map +1 -1
  17. package/dist/components/DateInputField/index.js +92 -91
  18. package/dist/components/FileInputField/index.js +68 -75
  19. package/dist/components/Form/defaultErrors.js +23 -20
  20. package/dist/components/Form/index.d.ts.map +1 -1
  21. package/dist/components/Form/index.js +39 -37
  22. package/dist/components/KeyValueField/index.d.ts.map +1 -1
  23. package/dist/components/KeyValueField/index.js +94 -106
  24. package/dist/components/NumberInputField/index.d.ts +1 -1
  25. package/dist/components/NumberInputField/index.d.ts.map +1 -1
  26. package/dist/components/NumberInputField/index.js +66 -66
  27. package/dist/components/RadioField/index.d.ts +1 -1
  28. package/dist/components/RadioField/index.d.ts.map +1 -1
  29. package/dist/components/RadioField/index.js +65 -66
  30. package/dist/components/RadioGroupField/index.d.ts.map +1 -1
  31. package/dist/components/RadioGroupField/index.js +49 -55
  32. package/dist/components/SelectInputField/index.d.ts +1 -1
  33. package/dist/components/SelectInputField/index.d.ts.map +1 -1
  34. package/dist/components/SelectInputField/index.js +56 -58
  35. package/dist/components/SelectableCardField/index.d.ts +1 -1
  36. package/dist/components/SelectableCardField/index.d.ts.map +1 -1
  37. package/dist/components/SelectableCardField/index.js +63 -74
  38. package/dist/components/SelectableCardGroupField/SelectableCardGroupField.d.ts.map +1 -1
  39. package/dist/components/SelectableCardGroupField/SelectableCardGroupField.js +56 -67
  40. package/dist/components/SelectableCardOptionGroupField/index.js +60 -62
  41. package/dist/components/SliderField/index.d.ts +1 -1
  42. package/dist/components/SliderField/index.d.ts.map +1 -1
  43. package/dist/components/SliderField/index.js +85 -87
  44. package/dist/components/Submit/index.d.ts.map +1 -1
  45. package/dist/components/Submit/index.js +23 -34
  46. package/dist/components/SubmitErrorAlert/index.d.ts +1 -1
  47. package/dist/components/SubmitErrorAlert/index.d.ts.map +1 -1
  48. package/dist/components/SubmitErrorAlert/index.js +15 -7
  49. package/dist/components/SwitchButtonField/index.d.ts +8 -8
  50. package/dist/components/SwitchButtonField/index.d.ts.map +1 -1
  51. package/dist/components/SwitchButtonField/index.js +45 -44
  52. package/dist/components/TagInputField/index.d.ts +1 -1
  53. package/dist/components/TagInputField/index.d.ts.map +1 -1
  54. package/dist/components/TagInputField/index.js +51 -55
  55. package/dist/components/TextAreaField/index.d.ts +1 -1
  56. package/dist/components/TextAreaField/index.d.ts.map +1 -1
  57. package/dist/components/TextAreaField/index.js +82 -89
  58. package/dist/components/TextInputField/index.d.ts +1 -1
  59. package/dist/components/TextInputField/index.d.ts.map +1 -1
  60. package/dist/components/TextInputField/index.js +70 -75
  61. package/dist/components/TimeInputField/index.d.ts +1 -1
  62. package/dist/components/TimeInputField/index.d.ts.map +1 -1
  63. package/dist/components/TimeInputField/index.js +53 -53
  64. package/dist/components/ToggleField/index.d.ts +1 -1
  65. package/dist/components/ToggleField/index.d.ts.map +1 -1
  66. package/dist/components/ToggleField/index.js +62 -72
  67. package/dist/components/ToggleGroupField/index.d.ts.map +1 -1
  68. package/dist/components/ToggleGroupField/index.js +51 -63
  69. package/dist/components/UnitInputField/index.d.ts.map +1 -1
  70. package/dist/components/UnitInputField/index.js +62 -59
  71. package/dist/components/VerificationCodeField/index.d.ts.map +1 -1
  72. package/dist/components/VerificationCodeField/index.js +45 -50
  73. package/dist/components/compositions/OfferListField/index.d.ts +54 -0
  74. package/dist/components/compositions/OfferListField/index.d.ts.map +1 -0
  75. package/dist/components/compositions/OfferListField/index.js +57 -0
  76. package/dist/components/compositions/OptionSelectorField/index.d.ts +1 -1
  77. package/dist/components/compositions/OptionSelectorField/index.d.ts.map +1 -1
  78. package/dist/components/compositions/OptionSelectorField/index.js +52 -53
  79. package/dist/components/compositions/PlansField/index.d.ts +8 -0
  80. package/dist/components/compositions/PlansField/index.d.ts.map +1 -0
  81. package/dist/components/compositions/PlansField/index.js +28 -0
  82. package/dist/components/compositions/index.d.ts +2 -0
  83. package/dist/components/compositions/index.d.ts.map +1 -1
  84. package/dist/components/compositions/index.js +4 -3
  85. package/dist/hooks/useOnFieldChange.d.ts.map +1 -1
  86. package/dist/hooks/useOnFieldChange.js +28 -17
  87. package/dist/index.js +6 -40
  88. package/dist/providers/ErrorContext/index.d.ts.map +1 -1
  89. package/dist/providers/ErrorContext/index.js +25 -31
  90. package/dist/utils/validateRegex.d.ts +1 -1
  91. package/dist/utils/validateRegex.d.ts.map +1 -1
  92. package/dist/utils/validateRegex.js +7 -6
  93. package/dist/validators/index.d.ts +2 -2
  94. package/dist/validators/index.d.ts.map +1 -1
  95. package/dist/validators/isInteger.d.ts +1 -1
  96. package/dist/validators/isInteger.d.ts.map +1 -1
  97. package/dist/validators/isInteger.js +9 -10
  98. package/dist/validators/maxDate.d.ts +1 -1
  99. package/dist/validators/maxDate.d.ts.map +1 -1
  100. package/dist/validators/maxDate.js +6 -3
  101. package/dist/validators/minDate.d.ts +1 -1
  102. package/dist/validators/minDate.d.ts.map +1 -1
  103. package/dist/validators/minDate.js +6 -3
  104. package/package.json +8 -8
  105. package/LICENSE +0 -189
@@ -1,96 +1,97 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { DateInput } from "@ultraviolet/ui";
4
- import { useController } from "react-hook-form";
1
+ 'use client';
2
+ import { __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { useErrors } from "../../providers/ErrorContext/index.js";
4
+ import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/objectWithoutProperties.js";
5
+ import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/objectSpread2.js";
5
6
  import { maxDateValidator } from "../../validators/maxDate.js";
6
7
  import { minDateValidator } from "../../validators/minDate.js";
7
- import { useErrors } from "../../providers/ErrorContext/index.js";
8
+ import { DateInput } from "@ultraviolet/ui";
9
+ import { useController } from "react-hook-form";
10
+ import { jsx } from "react/jsx-runtime";
11
+
12
+ //#region src/components/DateInputField/index.tsx
13
+ const _excluded = [
14
+ "required",
15
+ "name",
16
+ "control",
17
+ "label",
18
+ "format",
19
+ "minDate",
20
+ "maxDate",
21
+ "onChange",
22
+ "onBlur",
23
+ "validate",
24
+ "selectsRange",
25
+ "showMonthYearPicker",
26
+ "shouldUnregister"
27
+ ];
8
28
  const parseDate = (value) => typeof value === "string" ? new Date(value) : value;
9
29
  const isEmpty = (value) => !value;
10
- const DateInputField = ({
11
- required,
12
- name,
13
- control,
14
- label = "",
15
- format,
16
- minDate,
17
- maxDate,
18
- onChange,
19
- onBlur,
20
- validate,
21
- selectsRange,
22
- showMonthYearPicker,
23
- shouldUnregister = false,
24
- ...props
25
- }) => {
26
- const { getError } = useErrors();
27
- const {
28
- field,
29
- fieldState: { error }
30
- } = useController({
31
- control,
32
- name,
33
- rules: {
34
- required,
35
- validate: {
36
- maxDate: maxDateValidator(maxDate),
37
- minDate: minDateValidator(minDate),
38
- ...validate
39
- }
40
- },
41
- shouldUnregister
42
- });
43
- return /* @__PURE__ */ jsx(
44
- DateInput,
45
- {
46
- ...props,
47
- endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0,
48
- error: getError({ label, maxDate, minDate }, error),
49
- format: format ?? ((value) => {
50
- if (!value) {
51
- return "";
52
- }
53
- const date = parseDate(value);
54
- return showMonthYearPicker ? date.toLocaleDateString(void 0, {
55
- month: "numeric",
56
- year: "numeric"
57
- }) : date.toLocaleDateString();
58
- }),
59
- label,
60
- maxDate,
61
- minDate,
62
- name: field.name,
63
- onBlur: (e) => {
64
- field.onBlur();
65
- onBlur?.(e);
66
- },
67
- onChange: (val) => {
68
- if (val && val instanceof Date) {
69
- onChange?.(val);
70
- const newDate = parseDate(val);
71
- if (isEmpty(field.value)) {
72
- field.onChange(newDate);
73
- return;
74
- }
75
- const currentDate = parseDate(field.value);
76
- newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
77
- field.onChange(newDate);
78
- } else if (Array.isArray(val)) {
79
- onChange?.(val);
80
- field.onChange(val);
81
- } else if (val === null) {
82
- onChange?.(val);
83
- field.onChange(val);
84
- }
85
- },
86
- required,
87
- selectsRange,
88
- showMonthYearPicker,
89
- startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0,
90
- value: Array.isArray(field.value) ? void 0 : field.value
91
- }
92
- );
93
- };
94
- export {
95
- DateInputField
30
+ const DateInputField = (_ref) => {
31
+ let { required, name, control, label = "", format, minDate, maxDate, onChange, onBlur, validate, selectsRange, showMonthYearPicker, shouldUnregister = false } = _ref;
32
+ let props = _objectWithoutProperties(_ref, _excluded);
33
+ const { getError } = useErrors();
34
+ const { field, fieldState: { error } } = useController({
35
+ control,
36
+ name,
37
+ rules: {
38
+ required,
39
+ validate: _objectSpread2({
40
+ maxDate: maxDateValidator(maxDate),
41
+ minDate: minDateValidator(minDate)
42
+ }, validate)
43
+ },
44
+ shouldUnregister
45
+ });
46
+ return /* @__PURE__ */ jsx(DateInput, _objectSpread2(_objectSpread2({}, props), {}, {
47
+ endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0,
48
+ error: getError({
49
+ label,
50
+ maxDate,
51
+ minDate
52
+ }, error),
53
+ format: format !== null && format !== void 0 ? format : ((value) => {
54
+ if (!value) return "";
55
+ const date = parseDate(value);
56
+ return showMonthYearPicker ? date.toLocaleDateString(void 0, {
57
+ month: "numeric",
58
+ year: "numeric"
59
+ }) : date.toLocaleDateString();
60
+ }),
61
+ label,
62
+ maxDate,
63
+ minDate,
64
+ name: field.name,
65
+ onBlur: (e) => {
66
+ field.onBlur();
67
+ onBlur === null || onBlur === void 0 || onBlur(e);
68
+ },
69
+ onChange: (val) => {
70
+ if (val && val instanceof Date) {
71
+ onChange === null || onChange === void 0 || onChange(val);
72
+ const newDate = parseDate(val);
73
+ if (isEmpty(field.value)) {
74
+ field.onChange(newDate);
75
+ return;
76
+ }
77
+ const currentDate = parseDate(field.value);
78
+ newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
79
+ field.onChange(newDate);
80
+ } else if (Array.isArray(val)) {
81
+ onChange === null || onChange === void 0 || onChange(val);
82
+ field.onChange(val);
83
+ } else if (val === null) {
84
+ onChange === null || onChange === void 0 || onChange(val);
85
+ field.onChange(val);
86
+ }
87
+ },
88
+ required,
89
+ selectsRange,
90
+ showMonthYearPicker,
91
+ startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0,
92
+ value: Array.isArray(field.value) ? void 0 : field.value
93
+ }));
96
94
  };
95
+
96
+ //#endregion
97
+ export { DateInputField };
@@ -1,78 +1,71 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
1
+ 'use client';
2
+ import { __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { useErrors } from "../../providers/ErrorContext/index.js";
4
+ import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/objectWithoutProperties.js";
5
+ import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/objectSpread2.js";
3
6
  import { FileInput } from "@ultraviolet/ui";
4
7
  import { useController } from "react-hook-form";
5
- import { useErrors } from "../../providers/ErrorContext/index.js";
6
- const FileInputFieldBase = ({
7
- onChange,
8
- label,
9
- required = false,
10
- name,
11
- shouldUnregister,
12
- control,
13
- variant,
14
- size,
15
- title,
16
- bottom,
17
- children,
18
- ...props
19
- }) => {
20
- const { getError } = useErrors();
21
- const {
22
- field,
23
- fieldState: { error }
24
- } = useController({
25
- control,
26
- name,
27
- rules: {
28
- required
29
- },
30
- shouldUnregister
31
- });
32
- if (variant === "overlay" && children) {
33
- return /* @__PURE__ */ jsx(
34
- FileInput,
35
- {
36
- ...props,
37
- error: getError({ label }, error),
38
- label,
39
- onChangeFiles: (files) => {
40
- field.onChange(files);
41
- onChange?.(files);
42
- },
43
- required,
44
- title,
45
- variant: "overlay",
46
- children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
47
- }
48
- );
49
- }
50
- return /* @__PURE__ */ jsx(
51
- FileInput,
52
- {
53
- ...props,
54
- bottom,
55
- error: getError({ label }, error),
56
- label,
57
- onChangeFiles: (files) => {
58
- field.onChange(files);
59
- onChange?.(files);
60
- },
61
- required,
62
- size,
63
- title,
64
- variant: "dropzone",
65
- children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
66
- }
67
- );
68
- };
69
- const FileInputField = Object.assign(
70
- FileInputFieldBase,
71
- {
72
- Button: FileInput.Button,
73
- List: FileInput.List
74
- }
75
- );
76
- export {
77
- FileInputField
8
+ import { jsx } from "react/jsx-runtime";
9
+
10
+ //#region src/components/FileInputField/index.tsx
11
+ const _excluded = [
12
+ "onChange",
13
+ "label",
14
+ "required",
15
+ "name",
16
+ "shouldUnregister",
17
+ "control",
18
+ "variant",
19
+ "size",
20
+ "title",
21
+ "bottom",
22
+ "children"
23
+ ];
24
+ /**
25
+ * This component offers a form field based on Ultraviolet UI FileInput component
26
+ * @experimental This component is experimental and may be subject to breaking changes in the future.
27
+ */
28
+ const FileInputFieldBase = (_ref) => {
29
+ let { onChange, label, required = false, name, shouldUnregister, control, variant, size, title, bottom, children } = _ref;
30
+ let props = _objectWithoutProperties(_ref, _excluded);
31
+ const { getError } = useErrors();
32
+ const { field, fieldState: { error } } = useController({
33
+ control,
34
+ name,
35
+ rules: { required },
36
+ shouldUnregister
37
+ });
38
+ if (variant === "overlay" && children) return /* @__PURE__ */ jsx(FileInput, _objectSpread2(_objectSpread2({}, props), {}, {
39
+ error: getError({ label }, error),
40
+ label,
41
+ onChangeFiles: (files) => {
42
+ field.onChange(files);
43
+ onChange === null || onChange === void 0 || onChange(files);
44
+ },
45
+ required,
46
+ title,
47
+ variant: "overlay",
48
+ children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
49
+ }));
50
+ return /* @__PURE__ */ jsx(FileInput, _objectSpread2(_objectSpread2({}, props), {}, {
51
+ bottom,
52
+ error: getError({ label }, error),
53
+ label,
54
+ onChangeFiles: (files) => {
55
+ field.onChange(files);
56
+ onChange === null || onChange === void 0 || onChange(files);
57
+ },
58
+ required,
59
+ size,
60
+ title,
61
+ variant: "dropzone",
62
+ children: typeof children === "function" ? (inputId, inputRef) => children(inputId, inputRef) : children
63
+ }));
78
64
  };
65
+ const FileInputField = Object.assign(FileInputFieldBase, {
66
+ Button: FileInput.Button,
67
+ List: FileInput.List
68
+ });
69
+
70
+ //#endregion
71
+ export { FileInputField };
@@ -1,22 +1,25 @@
1
+ import { __name } from "../../_virtual/_rolldown/runtime.js";
2
+
3
+ //#region src/components/Form/defaultErrors.ts
1
4
  const defaultErrors = {
2
- deps: () => "",
3
- disabled: () => "",
4
- max: () => "",
5
- maxDate: () => "",
6
- maxLength: () => "",
7
- min: () => "",
8
- minLength: () => "",
9
- onBlur: () => "",
10
- onChange: () => "",
11
- pattern: () => "",
12
- required: () => "",
13
- setValueAs: () => "",
14
- shouldUnregister: () => "",
15
- validate: () => "",
16
- value: () => "",
17
- valueAsDate: () => "",
18
- valueAsNumber: () => ""
19
- };
20
- export {
21
- defaultErrors
5
+ deps: () => "",
6
+ disabled: () => "",
7
+ max: () => "",
8
+ maxDate: () => "",
9
+ maxLength: () => "",
10
+ min: () => "",
11
+ minLength: () => "",
12
+ onBlur: () => "",
13
+ onChange: () => "",
14
+ pattern: () => "",
15
+ required: () => "",
16
+ setValueAs: () => "",
17
+ shouldUnregister: () => "",
18
+ validate: () => "",
19
+ value: () => "",
20
+ valueAsDate: () => "",
21
+ valueAsNumber: () => ""
22
22
  };
23
+
24
+ //#endregion
25
+ export { defaultErrors };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,KAAK,cAAc,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAA;AAEtD,KAAK,SAAS,CAAC,YAAY,SAAS,WAAW,IAAI;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAA;IAC1E,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,YAAY,SAAS,WAAW,EAAE,gDAMpD,SAAS,CAAC,YAAY,CAAC,4CA+BzB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,KAAK,cAAc,GACf,MAAM,GACN,IAAI,GACJ,SAAS,GAET,IAAI,CAAA;AAER,KAAK,SAAS,CAAC,YAAY,SAAS,WAAW,IAAI;IACjD,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAA;IAC1E,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,YAAY,yIAqChC,CAAA"}
@@ -1,39 +1,41 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { FormProvider } from "react-hook-form";
4
- import { defaultErrors } from "./defaultErrors.js";
1
+ 'use client';
2
+ import { __name } from "../../_virtual/_rolldown/runtime.js";
5
3
  import { ErrorProvider } from "../../providers/ErrorContext/index.js";
6
- const Form = ({
7
- children,
8
- methods,
9
- errors,
10
- onSubmit,
11
- name
12
- }) => {
13
- const handleSubmit = methods.handleSubmit(async (values) => {
14
- const result = await onSubmit(values);
15
- if (result) {
16
- methods.setError("root.submit", {
17
- message: result,
18
- type: "custom"
19
- });
20
- }
21
- });
22
- return /* @__PURE__ */ jsx(FormProvider, { ...methods, children: /* @__PURE__ */ jsx(ErrorProvider, { errors: { ...defaultErrors, ...errors }, children: /* @__PURE__ */ jsx(
23
- "form",
24
- {
25
- name,
26
- noValidate: true,
27
- onSubmit: (e) => {
28
- e.preventDefault();
29
- e.stopPropagation();
30
- handleSubmit(e).catch(() => null);
31
- },
32
- style: { display: "contents" },
33
- children
34
- }
35
- ) }) });
36
- };
37
- export {
38
- Form
4
+ import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/objectSpread2.js";
5
+ import { defaultErrors } from "./defaultErrors.js";
6
+ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.113.0/helpers/asyncToGenerator.js";
7
+ import { FormProvider } from "react-hook-form";
8
+ import { jsx } from "react/jsx-runtime";
9
+
10
+ //#region src/components/Form/index.tsx
11
+ const Form = ({ children, methods, errors, onSubmit, name }) => {
12
+ const handleSubmit = methods.handleSubmit(function() {
13
+ var _ref = _asyncToGenerator(function* (values) {
14
+ const result = yield onSubmit(values);
15
+ if (result) methods.setError("root.submit", {
16
+ message: result,
17
+ type: "custom"
18
+ });
19
+ });
20
+ return function(_x) {
21
+ return _ref.apply(this, arguments);
22
+ };
23
+ }());
24
+ return /* @__PURE__ */ jsx(FormProvider, _objectSpread2(_objectSpread2({}, methods), {}, { children: /* @__PURE__ */ jsx(ErrorProvider, {
25
+ errors: _objectSpread2(_objectSpread2({}, defaultErrors), errors),
26
+ children: /* @__PURE__ */ jsx("form", {
27
+ name,
28
+ noValidate: true,
29
+ onSubmit: (e) => {
30
+ e.preventDefault();
31
+ e.stopPropagation();
32
+ handleSubmit(e).catch(() => null);
33
+ },
34
+ style: { display: "contents" },
35
+ children
36
+ })
37
+ }) }));
39
38
  };
39
+
40
+ //#endregion
41
+ export { Form };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/KeyValueField/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAc,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE3E,OAAO,EAAE,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