@ultraviolet/form 6.2.0 → 6.2.2

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 (59) hide show
  1. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/asyncToGenerator.js +5 -3
  2. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +19 -0
  3. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/objectSpread2.js +8 -4
  4. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +22 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +17 -0
  6. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/toPrimitive.js +8 -4
  7. package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +17 -0
  8. package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/typeof.js +5 -3
  9. package/dist/_virtual/_rolldown/runtime.js +2 -1
  10. package/dist/components/CheckboxField/index.js +59 -51
  11. package/dist/components/CheckboxGroupField/index.js +67 -59
  12. package/dist/components/DateInputField/index.js +94 -84
  13. package/dist/components/FileInputField/index.js +64 -60
  14. package/dist/components/Form/defaultErrors.js +25 -21
  15. package/dist/components/Form/index.d.ts +2 -1
  16. package/dist/components/Form/index.d.ts.map +1 -1
  17. package/dist/components/Form/index.js +41 -31
  18. package/dist/components/KeyValueField/index.js +88 -86
  19. package/dist/components/NumberInputField/index.js +66 -57
  20. package/dist/components/RadioField/index.js +65 -57
  21. package/dist/components/RadioGroupField/index.js +50 -42
  22. package/dist/components/SelectInputField/index.js +56 -48
  23. package/dist/components/SelectableCardField/index.js +64 -58
  24. package/dist/components/SelectableCardGroupField/SelectableCardGroupField.js +56 -48
  25. package/dist/components/SelectableCardGroupField/index.js +9 -0
  26. package/dist/components/SelectableCardOptionGroupField/index.js +61 -53
  27. package/dist/components/SliderField/index.js +83 -75
  28. package/dist/components/Submit/index.js +22 -18
  29. package/dist/components/SubmitErrorAlert/index.js +15 -11
  30. package/dist/components/SwitchButtonField/index.js +47 -41
  31. package/dist/components/TagInputField/index.js +54 -45
  32. package/dist/components/TextAreaField/index.js +78 -72
  33. package/dist/components/TextInputField/index.js +67 -61
  34. package/dist/components/TimeInputField/index.js +50 -46
  35. package/dist/components/ToggleField/index.js +63 -55
  36. package/dist/components/ToggleGroupField/index.js +53 -45
  37. package/dist/components/UnitInputField/index.js +61 -53
  38. package/dist/components/VerificationCodeField/index.js +47 -39
  39. package/dist/components/compositions/CodeEditorField/index.js +48 -42
  40. package/dist/components/compositions/CustomerSatisfactionField/index.js +17 -13
  41. package/dist/components/compositions/OfferListField/index.js +54 -48
  42. package/dist/components/compositions/OptionSelectorField/index.js +53 -45
  43. package/dist/components/compositions/PlansField/index.js +25 -21
  44. package/dist/components/compositions/index.js +17 -5
  45. package/dist/components/index.js +59 -0
  46. package/dist/hooks/index.js +9 -0
  47. package/dist/hooks/useOnFieldChange.js +25 -24
  48. package/dist/index.js +14 -1
  49. package/dist/providers/ErrorContext/index.js +28 -24
  50. package/dist/providers/index.js +11 -0
  51. package/dist/utils/validateRegex.js +7 -3
  52. package/dist/validators/isInteger.js +11 -7
  53. package/dist/validators/maxDate.js +7 -3
  54. package/dist/validators/minDate.js +7 -3
  55. package/package.json +6 -6
  56. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/defineProperty.js +0 -15
  57. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js +0 -18
  58. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutPropertiesLoose.js +0 -15
  59. package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/toPropertyKey.js +0 -12
@@ -1,6 +1,6 @@
1
- import { __name } from "../../_rolldown/runtime.js";
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
2
 
3
- //#region \0@oxc-project+runtime@0.114.0/helpers/asyncToGenerator.js
3
+ //#region \0@oxc-project+runtime@0.115.0/helpers/asyncToGenerator.js
4
4
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
5
5
  try {
6
6
  var i = n[a](c);
@@ -27,6 +27,8 @@ function _asyncToGenerator(n) {
27
27
  });
28
28
  };
29
29
  }
30
+ var init_asyncToGenerator = __esmMin(() => {});
30
31
 
31
32
  //#endregion
32
- export { _asyncToGenerator };
33
+ init_asyncToGenerator();
34
+ export { _asyncToGenerator, init_asyncToGenerator };
@@ -0,0 +1,19 @@
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
+ import { init_toPropertyKey, toPropertyKey } from "./toPropertyKey.js";
3
+
4
+ //#region \0@oxc-project+runtime@0.115.0/helpers/defineProperty.js
5
+ function _defineProperty(e, r, t) {
6
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
7
+ value: t,
8
+ enumerable: !0,
9
+ configurable: !0,
10
+ writable: !0
11
+ }) : e[r] = t, e;
12
+ }
13
+ var init_defineProperty = __esmMin(() => {
14
+ init_toPropertyKey();
15
+ });
16
+
17
+ //#endregion
18
+ init_defineProperty();
19
+ export { _defineProperty, init_defineProperty };
@@ -1,7 +1,7 @@
1
- import { __name } from "../../_rolldown/runtime.js";
2
- import { _defineProperty } from "./defineProperty.js";
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
+ import { _defineProperty, init_defineProperty } from "./defineProperty.js";
3
3
 
4
- //#region \0@oxc-project+runtime@0.114.0/helpers/objectSpread2.js
4
+ //#region \0@oxc-project+runtime@0.115.0/helpers/objectSpread2.js
5
5
  function ownKeys(e, r) {
6
6
  var t = Object.keys(e);
7
7
  if (Object.getOwnPropertySymbols) {
@@ -23,6 +23,10 @@ function _objectSpread2(e) {
23
23
  }
24
24
  return e;
25
25
  }
26
+ var init_objectSpread2 = __esmMin(() => {
27
+ init_defineProperty();
28
+ });
26
29
 
27
30
  //#endregion
28
- export { _objectSpread2 };
31
+ init_objectSpread2();
32
+ export { _objectSpread2, init_objectSpread2 };
@@ -0,0 +1,22 @@
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
+ import { _objectWithoutPropertiesLoose, init_objectWithoutPropertiesLoose } from "./objectWithoutPropertiesLoose.js";
3
+
4
+ //#region \0@oxc-project+runtime@0.115.0/helpers/objectWithoutProperties.js
5
+ function _objectWithoutProperties(e, t) {
6
+ if (null == e) return {};
7
+ var o;
8
+ var r;
9
+ var i = _objectWithoutPropertiesLoose(e, t);
10
+ if (Object.getOwnPropertySymbols) {
11
+ var s = Object.getOwnPropertySymbols(e);
12
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
13
+ }
14
+ return i;
15
+ }
16
+ var init_objectWithoutProperties = __esmMin(() => {
17
+ init_objectWithoutPropertiesLoose();
18
+ });
19
+
20
+ //#endregion
21
+ init_objectWithoutProperties();
22
+ export { _objectWithoutProperties, init_objectWithoutProperties };
@@ -0,0 +1,17 @@
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
+
3
+ //#region \0@oxc-project+runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js
4
+ function _objectWithoutPropertiesLoose(r, e) {
5
+ if (null == r) return {};
6
+ var t = {};
7
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
8
+ if (e.includes(n)) continue;
9
+ t[n] = r[n];
10
+ }
11
+ return t;
12
+ }
13
+ var init_objectWithoutPropertiesLoose = __esmMin(() => {});
14
+
15
+ //#endregion
16
+ init_objectWithoutPropertiesLoose();
17
+ export { _objectWithoutPropertiesLoose, init_objectWithoutPropertiesLoose };
@@ -1,7 +1,7 @@
1
- import { __name } from "../../_rolldown/runtime.js";
2
- import { _typeof } from "./typeof.js";
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
+ import { _typeof, init_typeof } from "./typeof.js";
3
3
 
4
- //#region \0@oxc-project+runtime@0.114.0/helpers/toPrimitive.js
4
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPrimitive.js
5
5
  function toPrimitive(t, r) {
6
6
  if ("object" != _typeof(t) || !t) return t;
7
7
  var e = t[Symbol.toPrimitive];
@@ -12,6 +12,10 @@ function toPrimitive(t, r) {
12
12
  }
13
13
  return ("string" === r ? String : Number)(t);
14
14
  }
15
+ var init_toPrimitive = __esmMin(() => {
16
+ init_typeof();
17
+ });
15
18
 
16
19
  //#endregion
17
- export { toPrimitive };
20
+ init_toPrimitive();
21
+ export { init_toPrimitive, toPrimitive };
@@ -0,0 +1,17 @@
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
+ import { _typeof, init_typeof } from "./typeof.js";
3
+ import { init_toPrimitive, toPrimitive } from "./toPrimitive.js";
4
+
5
+ //#region \0@oxc-project+runtime@0.115.0/helpers/toPropertyKey.js
6
+ function toPropertyKey(t) {
7
+ var i = toPrimitive(t, "string");
8
+ return "symbol" == _typeof(i) ? i : i + "";
9
+ }
10
+ var init_toPropertyKey = __esmMin(() => {
11
+ init_typeof();
12
+ init_toPrimitive();
13
+ });
14
+
15
+ //#endregion
16
+ init_toPropertyKey();
17
+ export { init_toPropertyKey, toPropertyKey };
@@ -1,6 +1,6 @@
1
- import { __name } from "../../_rolldown/runtime.js";
1
+ import { __esmMin, __name } from "../../_rolldown/runtime.js";
2
2
 
3
- //#region \0@oxc-project+runtime@0.114.0/helpers/typeof.js
3
+ //#region \0@oxc-project+runtime@0.115.0/helpers/typeof.js
4
4
  function _typeof(o) {
5
5
  "@babel/helpers - typeof";
6
6
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -9,6 +9,8 @@ function _typeof(o) {
9
9
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
10
10
  }, _typeof(o);
11
11
  }
12
+ var init_typeof = __esmMin(() => {});
12
13
 
13
14
  //#endregion
14
- export { _typeof };
15
+ init_typeof();
16
+ export { _typeof, init_typeof };
@@ -4,6 +4,7 @@ var __name = (target, value) => __defProp(target, "name", {
4
4
  value,
5
5
  configurable: true
6
6
  });
7
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
7
8
 
8
9
  //#endregion
9
- export { __name };
10
+ export { __esmMin, __name };
@@ -1,60 +1,68 @@
1
1
  'use client';
2
- import { __name } from "../../_virtual/_rolldown/runtime.js";
3
- import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js";
4
- import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectSpread2.js";
2
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { _objectWithoutProperties, init_objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js";
4
+ import { _objectSpread2, init_objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js";
5
5
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
+ import { init_providers } from "../../providers/index.js";
6
7
  import { Checkbox } from "@ultraviolet/ui";
7
8
  import { useController } from "react-hook-form";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
 
10
11
  //#region src/components/CheckboxField/index.tsx
11
- const _excluded = [
12
- "control",
13
- "name",
14
- "label",
15
- "disabled",
16
- "required",
17
- "children",
18
- "onChange",
19
- "onBlur",
20
- "shouldUnregister",
21
- "validate",
22
- "aria-label"
23
- ];
24
- const CheckboxField = (_ref) => {
25
- var _ref2;
26
- let { control, name, label, disabled, required, children, onChange, onBlur, shouldUnregister = false, validate, "aria-label": ariaLabel } = _ref;
27
- let props = _objectWithoutProperties(_ref, _excluded);
28
- const { getError } = useErrors();
29
- const { field, fieldState: { error } } = useController({
30
- control,
31
- disabled,
32
- name,
33
- rules: {
34
- required,
35
- validate
36
- },
37
- shouldUnregister
38
- });
39
- return /* @__PURE__ */ jsx(Checkbox, _objectSpread2(_objectSpread2({}, props), {}, {
40
- checked: !!field.value,
41
- disabled: field.disabled,
42
- error: getError({ label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name }, error),
43
- name: field.name,
44
- onBlur: (event) => {
45
- field.onBlur();
46
- onBlur === null || onBlur === void 0 || onBlur(event);
47
- },
48
- onChange: (event) => {
49
- field.onChange(event.target.checked);
50
- onChange === null || onChange === void 0 || onChange(event.target.checked);
51
- },
52
- ref: field.ref
53
- }, children ? {
54
- "aria-label": void 0,
55
- children
56
- } : { "aria-label": ariaLabel }));
57
- };
12
+ var _excluded, CheckboxField;
13
+ var init_CheckboxField = __esmMin(() => {
14
+ init_providers();
15
+ init_objectWithoutProperties();
16
+ init_objectSpread2();
17
+ _excluded = [
18
+ "control",
19
+ "name",
20
+ "label",
21
+ "disabled",
22
+ "required",
23
+ "children",
24
+ "onChange",
25
+ "onBlur",
26
+ "shouldUnregister",
27
+ "validate",
28
+ "aria-label"
29
+ ];
30
+ CheckboxField = (_ref) => {
31
+ var _ref2;
32
+ let { control, name, label, disabled, required, children, onChange, onBlur, shouldUnregister = false, validate, "aria-label": ariaLabel } = _ref;
33
+ let props = _objectWithoutProperties(_ref, _excluded);
34
+ const { getError } = useErrors();
35
+ const { field, fieldState: { error } } = useController({
36
+ control,
37
+ disabled,
38
+ name,
39
+ rules: {
40
+ required,
41
+ validate
42
+ },
43
+ shouldUnregister
44
+ });
45
+ return /* @__PURE__ */ jsx(Checkbox, _objectSpread2(_objectSpread2({}, props), {}, {
46
+ checked: !!field.value,
47
+ disabled: field.disabled,
48
+ error: getError({ label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name }, error),
49
+ name: field.name,
50
+ onBlur: (event) => {
51
+ field.onBlur();
52
+ onBlur === null || onBlur === void 0 || onBlur(event);
53
+ },
54
+ onChange: (event) => {
55
+ field.onChange(event.target.checked);
56
+ onChange === null || onChange === void 0 || onChange(event.target.checked);
57
+ },
58
+ ref: field.ref
59
+ }, children ? {
60
+ "aria-label": void 0,
61
+ children
62
+ } : { "aria-label": ariaLabel }));
63
+ };
64
+ });
58
65
 
59
66
  //#endregion
60
- export { CheckboxField };
67
+ init_CheckboxField();
68
+ export { CheckboxField, init_CheckboxField };
@@ -1,70 +1,78 @@
1
1
  'use client';
2
- import { __name } from "../../_virtual/_rolldown/runtime.js";
3
- import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js";
4
- import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectSpread2.js";
2
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { _objectWithoutProperties, init_objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js";
4
+ import { _objectSpread2, init_objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js";
5
5
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
+ import { init_providers } from "../../providers/index.js";
6
7
  import { CheckboxGroup } from "@ultraviolet/ui";
7
8
  import { useController } from "react-hook-form";
8
9
  import { jsx } from "react/jsx-runtime";
9
10
  import { Children, isValidElement, useCallback } from "react";
10
11
 
11
12
  //#region src/components/CheckboxGroupField/index.tsx
12
- const _excluded = [
13
- "control",
14
- "children",
15
- "onChange",
16
- "error",
17
- "name",
18
- "required",
19
- "shouldUnregister",
20
- "validate",
21
- "legend"
22
- ];
23
- const arraysContainSameValues = (array1, array2) => {
24
- if (array1.length === 0) return false;
25
- return array2.every((value) => array1.includes(value));
26
- };
27
- const CheckboxGroupFieldComponent = (_ref) => {
28
- var _getError;
29
- let { control, children, onChange, error: customError, name, required = false, shouldUnregister = false, validate, legend = "" } = _ref;
30
- let props = _objectWithoutProperties(_ref, _excluded);
31
- const { getError } = useErrors();
32
- const { field, fieldState: { error } } = useController({
33
- control,
34
- name,
35
- rules: { validate: _objectSpread2({ checkboxValid: useCallback((value) => {
36
- var _Children$map$filter;
37
- var _Children$map;
38
- const requiredChildren = (_Children$map$filter = (_Children$map = Children.map(children, (child) => {
39
- if (isValidElement(child)) {
40
- if (child.props.required) return child.props.name;
13
+ var _excluded, arraysContainSameValues, CheckboxGroupFieldComponent, CheckboxGroupField;
14
+ var init_CheckboxGroupField = __esmMin(() => {
15
+ init_providers();
16
+ init_objectWithoutProperties();
17
+ init_objectSpread2();
18
+ _excluded = [
19
+ "control",
20
+ "children",
21
+ "onChange",
22
+ "error",
23
+ "name",
24
+ "required",
25
+ "shouldUnregister",
26
+ "validate",
27
+ "legend"
28
+ ];
29
+ arraysContainSameValues = (array1, array2) => {
30
+ if (array1.length === 0) return false;
31
+ return array2.every((value) => array1.includes(value));
32
+ };
33
+ CheckboxGroupFieldComponent = (_ref) => {
34
+ var _getError;
35
+ let { control, children, onChange, error: customError, name, required = false, shouldUnregister = false, validate, legend = "" } = _ref;
36
+ let props = _objectWithoutProperties(_ref, _excluded);
37
+ const { getError } = useErrors();
38
+ const { field, fieldState: { error } } = useController({
39
+ control,
40
+ name,
41
+ rules: { validate: _objectSpread2({ checkboxValid: useCallback((value) => {
42
+ var _Children$map$filter;
43
+ var _Children$map;
44
+ const requiredChildren = (_Children$map$filter = (_Children$map = Children.map(children, (child) => {
45
+ if (isValidElement(child)) {
46
+ if (child.props.required) return child.props.name;
47
+ return null;
48
+ }
41
49
  return null;
42
- }
43
- return null;
44
- })) === null || _Children$map === void 0 ? void 0 : _Children$map.filter(Boolean)) !== null && _Children$map$filter !== void 0 ? _Children$map$filter : [];
45
- if (requiredChildren.length === 0 && !required) return true;
46
- if (!required && arraysContainSameValues(value, requiredChildren)) return true;
47
- if (value.length >= Children.count(children)) return true;
48
- return false;
49
- }, [children, required]) }, validate) },
50
- shouldUnregister
51
- });
52
- return /* @__PURE__ */ jsx(CheckboxGroup, _objectSpread2(_objectSpread2({}, props), {}, {
53
- error: (_getError = getError({ label: legend }, error)) !== null && _getError !== void 0 ? _getError : customError,
54
- legend,
55
- name,
56
- onChange: (event) => {
57
- const fieldValue = field.value;
58
- if (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.includes(event.currentTarget.value)) field.onChange(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.filter((currentValue) => currentValue !== event.currentTarget.value));
59
- else field.onChange([...field.value, event.currentTarget.value]);
60
- onChange === null || onChange === void 0 || onChange(event.currentTarget.value);
61
- },
62
- required,
63
- value: field.value,
64
- children
65
- }));
66
- };
67
- const CheckboxGroupField = Object.assign(CheckboxGroupFieldComponent, { Checkbox: CheckboxGroup.Checkbox });
50
+ })) === null || _Children$map === void 0 ? void 0 : _Children$map.filter(Boolean)) !== null && _Children$map$filter !== void 0 ? _Children$map$filter : [];
51
+ if (requiredChildren.length === 0 && !required) return true;
52
+ if (!required && arraysContainSameValues(value, requiredChildren)) return true;
53
+ if (value.length >= Children.count(children)) return true;
54
+ return false;
55
+ }, [children, required]) }, validate) },
56
+ shouldUnregister
57
+ });
58
+ return /* @__PURE__ */ jsx(CheckboxGroup, _objectSpread2(_objectSpread2({}, props), {}, {
59
+ error: (_getError = getError({ label: legend }, error)) !== null && _getError !== void 0 ? _getError : customError,
60
+ legend,
61
+ name,
62
+ onChange: (event) => {
63
+ const fieldValue = field.value;
64
+ if (fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.includes(event.currentTarget.value)) field.onChange(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.filter((currentValue) => currentValue !== event.currentTarget.value));
65
+ else field.onChange([...field.value, event.currentTarget.value]);
66
+ onChange === null || onChange === void 0 || onChange(event.currentTarget.value);
67
+ },
68
+ required,
69
+ value: field.value,
70
+ children
71
+ }));
72
+ };
73
+ CheckboxGroupField = Object.assign(CheckboxGroupFieldComponent, { Checkbox: CheckboxGroup.Checkbox });
74
+ });
68
75
 
69
76
  //#endregion
70
- export { CheckboxGroupField };
77
+ init_CheckboxGroupField();
78
+ export { CheckboxGroupField, init_CheckboxGroupField };
@@ -1,97 +1,107 @@
1
1
  'use client';
2
- import { __name } from "../../_virtual/_rolldown/runtime.js";
3
- import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js";
4
- import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.114.0/helpers/objectSpread2.js";
2
+ import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
3
+ import { _objectWithoutProperties, init_objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js";
4
+ import { _objectSpread2, init_objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.115.0/helpers/objectSpread2.js";
5
5
  import { useErrors } from "../../providers/ErrorContext/index.js";
6
- import { maxDateValidator } from "../../validators/maxDate.js";
7
- import { minDateValidator } from "../../validators/minDate.js";
6
+ import { init_providers } from "../../providers/index.js";
7
+ import { init_maxDate, maxDateValidator } from "../../validators/maxDate.js";
8
+ import { init_minDate, minDateValidator } from "../../validators/minDate.js";
8
9
  import { DateInput } from "@ultraviolet/ui";
9
10
  import { useController } from "react-hook-form";
10
11
  import { jsx } from "react/jsx-runtime";
11
12
 
12
13
  //#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
- ];
28
- const parseDate = (value) => typeof value === "string" ? new Date(value) : value;
29
- const isEmpty = (value) => !value;
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({
14
+ var _excluded, parseDate, isEmpty, DateInputField;
15
+ var init_DateInputField = __esmMin(() => {
16
+ init_providers();
17
+ init_maxDate();
18
+ init_minDate();
19
+ init_objectWithoutProperties();
20
+ init_objectSpread2();
21
+ _excluded = [
22
+ "required",
23
+ "name",
24
+ "control",
25
+ "label",
26
+ "format",
27
+ "minDate",
28
+ "maxDate",
29
+ "onChange",
30
+ "onBlur",
31
+ "validate",
32
+ "selectsRange",
33
+ "showMonthYearPicker",
34
+ "shouldUnregister"
35
+ ];
36
+ parseDate = (value) => typeof value === "string" ? new Date(value) : value;
37
+ isEmpty = (value) => !value;
38
+ DateInputField = (_ref) => {
39
+ let { required, name, control, label = "", format, minDate, maxDate, onChange, onBlur, validate, selectsRange, showMonthYearPicker, shouldUnregister = false } = _ref;
40
+ let props = _objectWithoutProperties(_ref, _excluded);
41
+ const { getError } = useErrors();
42
+ const { field, fieldState: { error } } = useController({
43
+ control,
44
+ name,
45
+ rules: {
46
+ required,
47
+ validate: _objectSpread2({
48
+ maxDate: maxDateValidator(maxDate),
49
+ minDate: minDateValidator(minDate)
50
+ }, validate)
51
+ },
52
+ shouldUnregister
53
+ });
54
+ return /* @__PURE__ */ jsx(DateInput, _objectSpread2(_objectSpread2({}, props), {}, {
55
+ endDate: selectsRange && Array.isArray(field.value) ? field.value[1] : void 0,
56
+ error: getError({
57
+ label,
58
+ maxDate,
59
+ minDate
60
+ }, error),
61
+ format: format !== null && format !== void 0 ? format : ((value) => {
62
+ if (!value) return "";
63
+ const date = parseDate(value);
64
+ return showMonthYearPicker ? date.toLocaleDateString(void 0, {
65
+ month: "numeric",
66
+ year: "numeric"
67
+ }) : date.toLocaleDateString();
68
+ }),
49
69
  label,
50
70
  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)) {
71
+ minDate,
72
+ name: field.name,
73
+ onBlur: (e) => {
74
+ field.onBlur();
75
+ onBlur === null || onBlur === void 0 || onBlur(e);
76
+ },
77
+ onChange: (val) => {
78
+ if (val && val instanceof Date) {
79
+ onChange === null || onChange === void 0 || onChange(val);
80
+ const newDate = parseDate(val);
81
+ if (isEmpty(field.value)) {
82
+ field.onChange(newDate);
83
+ return;
84
+ }
85
+ const currentDate = parseDate(field.value);
86
+ newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
74
87
  field.onChange(newDate);
75
- return;
88
+ } else if (Array.isArray(val)) {
89
+ onChange === null || onChange === void 0 || onChange(val);
90
+ field.onChange(val);
91
+ } else if (val === null) {
92
+ onChange === null || onChange === void 0 || onChange(val);
93
+ field.onChange(val);
76
94
  }
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
- }));
94
- };
95
+ },
96
+ required,
97
+ selectsRange,
98
+ showMonthYearPicker,
99
+ startDate: selectsRange && Array.isArray(field.value) ? field.value[0] : void 0,
100
+ value: Array.isArray(field.value) ? void 0 : field.value
101
+ }));
102
+ };
103
+ });
95
104
 
96
105
  //#endregion
97
- export { DateInputField };
106
+ init_DateInputField();
107
+ export { DateInputField, init_DateInputField };