@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.
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/asyncToGenerator.js +5 -3
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/defineProperty.js +19 -0
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/objectSpread2.js +8 -4
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutProperties.js +22 -0
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/objectWithoutPropertiesLoose.js +17 -0
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/toPrimitive.js +8 -4
- package/dist/_virtual/_@oxc-project_runtime@0.115.0/helpers/toPropertyKey.js +17 -0
- package/dist/_virtual/{_@oxc-project_runtime@0.114.0 → _@oxc-project_runtime@0.115.0}/helpers/typeof.js +5 -3
- package/dist/_virtual/_rolldown/runtime.js +2 -1
- package/dist/components/CheckboxField/index.js +59 -51
- package/dist/components/CheckboxGroupField/index.js +67 -59
- package/dist/components/DateInputField/index.js +94 -84
- package/dist/components/FileInputField/index.js +64 -60
- package/dist/components/Form/defaultErrors.js +25 -21
- package/dist/components/Form/index.d.ts +2 -1
- package/dist/components/Form/index.d.ts.map +1 -1
- package/dist/components/Form/index.js +41 -31
- package/dist/components/KeyValueField/index.js +88 -86
- package/dist/components/NumberInputField/index.js +66 -57
- package/dist/components/RadioField/index.js +65 -57
- package/dist/components/RadioGroupField/index.js +50 -42
- package/dist/components/SelectInputField/index.js +56 -48
- package/dist/components/SelectableCardField/index.js +64 -58
- package/dist/components/SelectableCardGroupField/SelectableCardGroupField.js +56 -48
- package/dist/components/SelectableCardGroupField/index.js +9 -0
- package/dist/components/SelectableCardOptionGroupField/index.js +61 -53
- package/dist/components/SliderField/index.js +83 -75
- package/dist/components/Submit/index.js +22 -18
- package/dist/components/SubmitErrorAlert/index.js +15 -11
- package/dist/components/SwitchButtonField/index.js +47 -41
- package/dist/components/TagInputField/index.js +54 -45
- package/dist/components/TextAreaField/index.js +78 -72
- package/dist/components/TextInputField/index.js +67 -61
- package/dist/components/TimeInputField/index.js +50 -46
- package/dist/components/ToggleField/index.js +63 -55
- package/dist/components/ToggleGroupField/index.js +53 -45
- package/dist/components/UnitInputField/index.js +61 -53
- package/dist/components/VerificationCodeField/index.js +47 -39
- package/dist/components/compositions/CodeEditorField/index.js +48 -42
- package/dist/components/compositions/CustomerSatisfactionField/index.js +17 -13
- package/dist/components/compositions/OfferListField/index.js +54 -48
- package/dist/components/compositions/OptionSelectorField/index.js +53 -45
- package/dist/components/compositions/PlansField/index.js +25 -21
- package/dist/components/compositions/index.js +17 -5
- package/dist/components/index.js +59 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/useOnFieldChange.js +25 -24
- package/dist/index.js +14 -1
- package/dist/providers/ErrorContext/index.js +28 -24
- package/dist/providers/index.js +11 -0
- package/dist/utils/validateRegex.js +7 -3
- package/dist/validators/isInteger.js +11 -7
- package/dist/validators/maxDate.js +7 -3
- package/dist/validators/minDate.js +7 -3
- package/package.json +6 -6
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/defineProperty.js +0 -15
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutProperties.js +0 -18
- package/dist/_virtual/_@oxc-project_runtime@0.114.0/helpers/objectWithoutPropertiesLoose.js +0 -15
- 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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
15
|
+
init_typeof();
|
|
16
|
+
export { _typeof, init_typeof };
|
|
@@ -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.
|
|
4
|
-
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
disabled,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
field.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
-
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
name,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
-
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.
|
|
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 {
|
|
7
|
-
import {
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
106
|
+
init_DateInputField();
|
|
107
|
+
export { DateInputField, init_DateInputField };
|