@ultraviolet/form 6.2.1 → 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,68 +1,76 @@
|
|
|
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 { Radio } from "@ultraviolet/ui";
|
|
7
8
|
import { useController } from "react-hook-form";
|
|
8
9
|
import { jsx } from "react/jsx-runtime";
|
|
9
10
|
import { useMemo } from "react";
|
|
10
11
|
|
|
11
12
|
//#region src/components/RadioField/index.tsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
name,
|
|
33
|
-
|
|
13
|
+
var _excluded, RadioField;
|
|
14
|
+
var init_RadioField = __esmMin(() => {
|
|
15
|
+
init_providers();
|
|
16
|
+
init_objectWithoutProperties();
|
|
17
|
+
init_objectSpread2();
|
|
18
|
+
_excluded = [
|
|
19
|
+
"control",
|
|
20
|
+
"disabled",
|
|
21
|
+
"name",
|
|
22
|
+
"onBlur",
|
|
23
|
+
"label",
|
|
24
|
+
"onChange",
|
|
25
|
+
"onFocus",
|
|
26
|
+
"required",
|
|
27
|
+
"value",
|
|
28
|
+
"shouldUnregister",
|
|
29
|
+
"validate",
|
|
30
|
+
"aria-label"
|
|
31
|
+
];
|
|
32
|
+
RadioField = (_ref) => {
|
|
33
|
+
let { control, disabled, name, onBlur, label = "", onChange, onFocus, required, value, shouldUnregister = false, validate, "aria-label": ariaLabel } = _ref;
|
|
34
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
+
const { getError } = useErrors();
|
|
36
|
+
const { field, fieldState: { error } } = useController({
|
|
37
|
+
control,
|
|
38
|
+
name,
|
|
39
|
+
rules: {
|
|
40
|
+
required,
|
|
41
|
+
validate
|
|
42
|
+
},
|
|
43
|
+
shouldUnregister
|
|
44
|
+
});
|
|
45
|
+
const errorLabel = useMemo(() => {
|
|
46
|
+
if (label && typeof label === "string") return label;
|
|
47
|
+
if (ariaLabel) return ariaLabel;
|
|
48
|
+
return name;
|
|
49
|
+
}, [
|
|
50
|
+
label,
|
|
51
|
+
name,
|
|
52
|
+
ariaLabel
|
|
53
|
+
]);
|
|
54
|
+
return /* @__PURE__ */ jsx(Radio, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
55
|
+
checked: field.value === value,
|
|
56
|
+
disabled,
|
|
57
|
+
error: getError({ label: errorLabel }, error),
|
|
58
|
+
name: field.name,
|
|
59
|
+
onBlur: (event) => {
|
|
60
|
+
field.onBlur();
|
|
61
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
62
|
+
},
|
|
63
|
+
onChange: () => {
|
|
64
|
+
field.onChange(value);
|
|
65
|
+
onChange === null || onChange === void 0 || onChange(value);
|
|
66
|
+
},
|
|
67
|
+
onFocus,
|
|
34
68
|
required,
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const errorLabel = useMemo(() => {
|
|
40
|
-
if (label && typeof label === "string") return label;
|
|
41
|
-
if (ariaLabel) return ariaLabel;
|
|
42
|
-
return name;
|
|
43
|
-
}, [
|
|
44
|
-
label,
|
|
45
|
-
name,
|
|
46
|
-
ariaLabel
|
|
47
|
-
]);
|
|
48
|
-
return /* @__PURE__ */ jsx(Radio, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
49
|
-
checked: field.value === value,
|
|
50
|
-
disabled,
|
|
51
|
-
error: getError({ label: errorLabel }, error),
|
|
52
|
-
name: field.name,
|
|
53
|
-
onBlur: (event) => {
|
|
54
|
-
field.onBlur();
|
|
55
|
-
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
56
|
-
},
|
|
57
|
-
onChange: () => {
|
|
58
|
-
field.onChange(value);
|
|
59
|
-
onChange === null || onChange === void 0 || onChange(value);
|
|
60
|
-
},
|
|
61
|
-
onFocus,
|
|
62
|
-
required,
|
|
63
|
-
value: value !== null && value !== void 0 ? value : ""
|
|
64
|
-
}, label ? { label } : { "aria-label": ariaLabel }));
|
|
65
|
-
};
|
|
69
|
+
value: value !== null && value !== void 0 ? value : ""
|
|
70
|
+
}, label ? { label } : { "aria-label": ariaLabel }));
|
|
71
|
+
};
|
|
72
|
+
});
|
|
66
73
|
|
|
67
74
|
//#endregion
|
|
68
|
-
|
|
75
|
+
init_RadioField();
|
|
76
|
+
export { RadioField, init_RadioField };
|
|
@@ -1,52 +1,60 @@
|
|
|
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 { RadioGroup } 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/RadioGroupField/index.tsx
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
name,
|
|
30
|
-
|
|
12
|
+
var _excluded, RadioGroupFieldComponent, RadioGroupField;
|
|
13
|
+
var init_RadioGroupField = __esmMin(() => {
|
|
14
|
+
init_providers();
|
|
15
|
+
init_objectWithoutProperties();
|
|
16
|
+
init_objectSpread2();
|
|
17
|
+
_excluded = [
|
|
18
|
+
"control",
|
|
19
|
+
"name",
|
|
20
|
+
"onChange",
|
|
21
|
+
"required",
|
|
22
|
+
"children",
|
|
23
|
+
"error",
|
|
24
|
+
"shouldUnregister",
|
|
25
|
+
"validate",
|
|
26
|
+
"legend"
|
|
27
|
+
];
|
|
28
|
+
RadioGroupFieldComponent = (_ref) => {
|
|
29
|
+
var _getError;
|
|
30
|
+
let { control, name, onChange, required, children, error: customError, shouldUnregister = false, validate, legend = "" } = _ref;
|
|
31
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
const { getError } = useErrors();
|
|
33
|
+
const { field, fieldState: { error } } = useController({
|
|
34
|
+
control,
|
|
35
|
+
name,
|
|
36
|
+
rules: {
|
|
37
|
+
required,
|
|
38
|
+
validate
|
|
39
|
+
},
|
|
40
|
+
shouldUnregister
|
|
41
|
+
});
|
|
42
|
+
return /* @__PURE__ */ jsx(RadioGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
43
|
+
error: (_getError = getError({ label: legend }, error)) !== null && _getError !== void 0 ? _getError : customError,
|
|
44
|
+
legend,
|
|
45
|
+
name: field.name,
|
|
46
|
+
onChange: (event) => {
|
|
47
|
+
field.onChange(event);
|
|
48
|
+
onChange === null || onChange === void 0 || onChange(event.target.value);
|
|
49
|
+
},
|
|
31
50
|
required,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
legend,
|
|
39
|
-
name: field.name,
|
|
40
|
-
onChange: (event) => {
|
|
41
|
-
field.onChange(event);
|
|
42
|
-
onChange === null || onChange === void 0 || onChange(event.target.value);
|
|
43
|
-
},
|
|
44
|
-
required,
|
|
45
|
-
value: field.value,
|
|
46
|
-
children
|
|
47
|
-
}));
|
|
48
|
-
};
|
|
49
|
-
const RadioGroupField = Object.assign(RadioGroupFieldComponent, { Radio: RadioGroup.Radio });
|
|
51
|
+
value: field.value,
|
|
52
|
+
children
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
RadioGroupField = Object.assign(RadioGroupFieldComponent, { Radio: RadioGroup.Radio });
|
|
56
|
+
});
|
|
50
57
|
|
|
51
58
|
//#endregion
|
|
52
|
-
|
|
59
|
+
init_RadioGroupField();
|
|
60
|
+
export { RadioGroupField, init_RadioGroupField };
|
|
@@ -1,59 +1,67 @@
|
|
|
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 { SelectInput } from "@ultraviolet/ui";
|
|
7
8
|
import { useController } from "react-hook-form";
|
|
8
9
|
import { jsx } from "react/jsx-runtime";
|
|
9
10
|
import { useCallback } from "react";
|
|
10
11
|
|
|
11
12
|
//#region src/components/SelectInputField/index.tsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
var _excluded, SelectInputField;
|
|
14
|
+
var init_SelectInputField = __esmMin(() => {
|
|
15
|
+
init_providers();
|
|
16
|
+
init_objectWithoutProperties();
|
|
17
|
+
init_objectSpread2();
|
|
18
|
+
_excluded = [
|
|
19
|
+
"label",
|
|
20
|
+
"onBlur",
|
|
21
|
+
"required",
|
|
22
|
+
"name",
|
|
23
|
+
"aria-label",
|
|
24
|
+
"shouldUnregister",
|
|
25
|
+
"control",
|
|
26
|
+
"validate",
|
|
27
|
+
"onChange",
|
|
28
|
+
"multiselect"
|
|
29
|
+
];
|
|
30
|
+
SelectInputField = (_ref) => {
|
|
31
|
+
var _ref2;
|
|
32
|
+
let { label = "", onBlur, required, name, "aria-label": ariaLabel, shouldUnregister = false, control, validate, onChange, multiselect } = _ref;
|
|
33
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
const { field, fieldState: { error } } = useController({
|
|
35
|
+
control,
|
|
36
|
+
name,
|
|
37
|
+
rules: {
|
|
38
|
+
required,
|
|
39
|
+
validate
|
|
40
|
+
},
|
|
41
|
+
shouldUnregister
|
|
42
|
+
});
|
|
43
|
+
const { getError } = useErrors();
|
|
44
|
+
const handleChange = useCallback((value) => {
|
|
45
|
+
onChange === null || onChange === void 0 || onChange(value);
|
|
46
|
+
field.onChange(value);
|
|
47
|
+
}, [onChange, field]);
|
|
48
|
+
return /* @__PURE__ */ jsx(SelectInput, _objectSpread2({
|
|
49
|
+
"aria-label": ariaLabel,
|
|
50
|
+
error: getError({ label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name }, error),
|
|
51
|
+
label,
|
|
52
|
+
multiselect,
|
|
53
|
+
name: field.name,
|
|
54
|
+
onBlur: (event) => {
|
|
55
|
+
field.onBlur();
|
|
56
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
57
|
+
},
|
|
58
|
+
onChange: handleChange,
|
|
32
59
|
required,
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const { getError } = useErrors();
|
|
38
|
-
const handleChange = useCallback((value) => {
|
|
39
|
-
onChange === null || onChange === void 0 || onChange(value);
|
|
40
|
-
field.onChange(value);
|
|
41
|
-
}, [onChange, field]);
|
|
42
|
-
return /* @__PURE__ */ jsx(SelectInput, _objectSpread2({
|
|
43
|
-
"aria-label": ariaLabel,
|
|
44
|
-
error: getError({ label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name }, error),
|
|
45
|
-
label,
|
|
46
|
-
multiselect,
|
|
47
|
-
name: field.name,
|
|
48
|
-
onBlur: (event) => {
|
|
49
|
-
field.onBlur();
|
|
50
|
-
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
51
|
-
},
|
|
52
|
-
onChange: handleChange,
|
|
53
|
-
required,
|
|
54
|
-
value: field.value
|
|
55
|
-
}, props));
|
|
56
|
-
};
|
|
60
|
+
value: field.value
|
|
61
|
+
}, props));
|
|
62
|
+
};
|
|
63
|
+
});
|
|
57
64
|
|
|
58
65
|
//#endregion
|
|
59
|
-
|
|
66
|
+
init_SelectInputField();
|
|
67
|
+
export { SelectInputField, init_SelectInputField };
|
|
@@ -1,66 +1,72 @@
|
|
|
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 { SelectableCard } from "@ultraviolet/ui";
|
|
6
6
|
import { useController } from "react-hook-form";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/components/SelectableCardField/index.tsx
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
name,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
10
|
+
var _excluded, SelectableCardField;
|
|
11
|
+
var init_SelectableCardField = __esmMin(() => {
|
|
12
|
+
init_objectWithoutProperties();
|
|
13
|
+
init_objectSpread2();
|
|
14
|
+
_excluded = [
|
|
15
|
+
"name",
|
|
16
|
+
"control",
|
|
17
|
+
"value",
|
|
18
|
+
"onChange",
|
|
19
|
+
"type",
|
|
20
|
+
"onFocus",
|
|
21
|
+
"onBlur",
|
|
22
|
+
"required",
|
|
23
|
+
"label",
|
|
24
|
+
"shouldUnregister",
|
|
25
|
+
"validate",
|
|
26
|
+
"productIcon",
|
|
27
|
+
"illustration",
|
|
28
|
+
"aria-label"
|
|
29
|
+
];
|
|
30
|
+
SelectableCardField = (_ref) => {
|
|
31
|
+
var _field$value;
|
|
32
|
+
let { name, control, value, onChange, type, onFocus, onBlur, required, label, shouldUnregister = false, validate, productIcon, illustration, "aria-label": ariaLabel } = _ref;
|
|
33
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
const { field, fieldState: { error } } = useController({
|
|
35
|
+
control,
|
|
36
|
+
name,
|
|
37
|
+
rules: {
|
|
38
|
+
required,
|
|
39
|
+
validate
|
|
40
|
+
},
|
|
41
|
+
shouldUnregister
|
|
42
|
+
});
|
|
43
|
+
const isChecked = (type === "checkbox" || type === "toggle") && Array.isArray(field.value) && value ? ((_field$value = field.value) !== null && _field$value !== void 0 ? _field$value : []).includes(value) : field.value === value;
|
|
44
|
+
return /* @__PURE__ */ jsx(SelectableCard, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, props), productIcon ? { productIcon } : { illustration }), label ? { label } : { "aria-label": ariaLabel }), {}, {
|
|
45
|
+
checked: isChecked,
|
|
46
|
+
isError: !!error,
|
|
47
|
+
name: field.name,
|
|
48
|
+
onBlur: (event) => {
|
|
49
|
+
field.onBlur();
|
|
50
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
51
|
+
},
|
|
52
|
+
onChange: (event) => {
|
|
53
|
+
if (type === "checkbox" || type === "toggle") {
|
|
54
|
+
var _field$value2;
|
|
55
|
+
const fieldValue = (_field$value2 = field.value) !== null && _field$value2 !== void 0 ? _field$value2 : [];
|
|
56
|
+
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));
|
|
57
|
+
else field.onChange([...fieldValue, event.currentTarget.value]);
|
|
58
|
+
} else field.onChange(event);
|
|
59
|
+
onChange === null || onChange === void 0 || onChange(event.currentTarget.value);
|
|
60
|
+
},
|
|
61
|
+
onFocus: (event) => {
|
|
62
|
+
onFocus === null || onFocus === void 0 || onFocus(event);
|
|
63
|
+
},
|
|
64
|
+
type,
|
|
65
|
+
value: value !== null && value !== void 0 ? value : ""
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
68
|
+
});
|
|
64
69
|
|
|
65
70
|
//#endregion
|
|
66
|
-
|
|
71
|
+
init_SelectableCardField();
|
|
72
|
+
export { SelectableCardField, init_SelectableCardField };
|
|
@@ -1,59 +1,67 @@
|
|
|
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 { SelectableCardGroup } 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/SelectableCardGroupField/SelectableCardGroupField.tsx
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
name,
|
|
31
|
-
|
|
12
|
+
var _excluded, SelectableCardGroupFieldComponent, SelectableCardGroupField;
|
|
13
|
+
var init_SelectableCardGroupField = __esmMin(() => {
|
|
14
|
+
init_providers();
|
|
15
|
+
init_objectWithoutProperties();
|
|
16
|
+
init_objectSpread2();
|
|
17
|
+
_excluded = [
|
|
18
|
+
"legend",
|
|
19
|
+
"control",
|
|
20
|
+
"name",
|
|
21
|
+
"onChange",
|
|
22
|
+
"required",
|
|
23
|
+
"error",
|
|
24
|
+
"columns",
|
|
25
|
+
"type",
|
|
26
|
+
"shouldUnregister",
|
|
27
|
+
"validate"
|
|
28
|
+
];
|
|
29
|
+
SelectableCardGroupFieldComponent = (_ref) => {
|
|
30
|
+
var _getError;
|
|
31
|
+
let { legend = "", control, name, onChange, required = false, error: customError, columns = 1, type = "radio", shouldUnregister = false, validate } = _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
|
|
40
|
+
},
|
|
41
|
+
shouldUnregister
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ jsx(SelectableCardGroup, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
44
|
+
columns,
|
|
45
|
+
error: (_getError = getError({ label: legend }, error)) !== null && _getError !== void 0 ? _getError : customError,
|
|
46
|
+
legend,
|
|
47
|
+
name,
|
|
48
|
+
onChange: (event) => {
|
|
49
|
+
if (type === "checkbox") {
|
|
50
|
+
var _field$value;
|
|
51
|
+
const fieldValue = (_field$value = field.value) !== null && _field$value !== void 0 ? _field$value : [];
|
|
52
|
+
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));
|
|
53
|
+
else field.onChange([...fieldValue, event.currentTarget.value]);
|
|
54
|
+
} else field.onChange(event);
|
|
55
|
+
onChange === null || onChange === void 0 || onChange(event.currentTarget.value);
|
|
56
|
+
},
|
|
32
57
|
required,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
error: (_getError = getError({ label: legend }, error)) !== null && _getError !== void 0 ? _getError : customError,
|
|
40
|
-
legend,
|
|
41
|
-
name,
|
|
42
|
-
onChange: (event) => {
|
|
43
|
-
if (type === "checkbox") {
|
|
44
|
-
var _field$value;
|
|
45
|
-
const fieldValue = (_field$value = field.value) !== null && _field$value !== void 0 ? _field$value : [];
|
|
46
|
-
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));
|
|
47
|
-
else field.onChange([...fieldValue, event.currentTarget.value]);
|
|
48
|
-
} else field.onChange(event);
|
|
49
|
-
onChange === null || onChange === void 0 || onChange(event.currentTarget.value);
|
|
50
|
-
},
|
|
51
|
-
required,
|
|
52
|
-
type,
|
|
53
|
-
value: field.value
|
|
54
|
-
}));
|
|
55
|
-
};
|
|
56
|
-
const SelectableCardGroupField = Object.assign(SelectableCardGroupFieldComponent, { Card: SelectableCardGroup.Card });
|
|
58
|
+
type,
|
|
59
|
+
value: field.value
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
SelectableCardGroupField = Object.assign(SelectableCardGroupFieldComponent, { Card: SelectableCardGroup.Card });
|
|
63
|
+
});
|
|
57
64
|
|
|
58
65
|
//#endregion
|
|
66
|
+
init_SelectableCardGroupField();
|
|
59
67
|
export { SelectableCardGroupField };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { SelectableCardGroupField } from "./SelectableCardGroupField.js";
|
|
3
|
+
|
|
4
|
+
//#region src/components/SelectableCardGroupField/index.ts
|
|
5
|
+
var init_SelectableCardGroupField = __esmMin(() => {});
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
init_SelectableCardGroupField();
|
|
9
|
+
export { init_SelectableCardGroupField };
|