@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,63 +1,71 @@
|
|
|
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 { SelectableCardOptionGroup } 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/SelectableCardOptionGroupField/index.tsx
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
name,
|
|
32
|
-
|
|
12
|
+
var _excluded, SelectableCardOptionGroupFieldComponent, SelectableCardOptionGroupField;
|
|
13
|
+
var init_SelectableCardOptionGroupField = __esmMin(() => {
|
|
14
|
+
init_providers();
|
|
15
|
+
init_objectWithoutProperties();
|
|
16
|
+
init_objectSpread2();
|
|
17
|
+
_excluded = [
|
|
18
|
+
"legend",
|
|
19
|
+
"control",
|
|
20
|
+
"name",
|
|
21
|
+
"optionName",
|
|
22
|
+
"onChange",
|
|
23
|
+
"onChangeOption",
|
|
24
|
+
"required",
|
|
25
|
+
"children",
|
|
26
|
+
"error",
|
|
27
|
+
"shouldUnregister",
|
|
28
|
+
"validate"
|
|
29
|
+
];
|
|
30
|
+
SelectableCardOptionGroupFieldComponent = (_ref) => {
|
|
31
|
+
var _getError;
|
|
32
|
+
let { legend = "", control, name, optionName, onChange, onChangeOption, required = false, children, error: customError, shouldUnregister = false, validate } = _ref;
|
|
33
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
const { getError } = useErrors();
|
|
35
|
+
const { field, fieldState: { error } } = useController({
|
|
36
|
+
control,
|
|
37
|
+
name,
|
|
38
|
+
rules: {
|
|
39
|
+
required,
|
|
40
|
+
validate
|
|
41
|
+
},
|
|
42
|
+
shouldUnregister
|
|
43
|
+
});
|
|
44
|
+
const { field: optionField } = useController({
|
|
45
|
+
name: optionName !== null && optionName !== void 0 ? optionName : `${name}Option`,
|
|
46
|
+
rules: { required },
|
|
47
|
+
shouldUnregister
|
|
48
|
+
});
|
|
49
|
+
return /* @__PURE__ */ jsx(SelectableCardOptionGroup, _objectSpread2(_objectSpread2({
|
|
50
|
+
error: (_getError = getError({ label: legend }, error)) !== null && _getError !== void 0 ? _getError : customError,
|
|
51
|
+
legend,
|
|
52
|
+
name,
|
|
53
|
+
onChange: (event) => {
|
|
54
|
+
field.onChange(event);
|
|
55
|
+
onChange === null || onChange === void 0 || onChange(event);
|
|
56
|
+
},
|
|
57
|
+
onChangeOption: (value) => {
|
|
58
|
+
optionField.onChange(value);
|
|
59
|
+
onChangeOption === null || onChangeOption === void 0 || onChangeOption(value);
|
|
60
|
+
},
|
|
61
|
+
optionValue: String(optionField.value),
|
|
33
62
|
required,
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
name: optionName !== null && optionName !== void 0 ? optionName : `${name}Option`,
|
|
40
|
-
rules: { required },
|
|
41
|
-
shouldUnregister
|
|
42
|
-
});
|
|
43
|
-
return /* @__PURE__ */ jsx(SelectableCardOptionGroup, _objectSpread2(_objectSpread2({
|
|
44
|
-
error: (_getError = getError({ label: legend }, error)) !== null && _getError !== void 0 ? _getError : customError,
|
|
45
|
-
legend,
|
|
46
|
-
name,
|
|
47
|
-
onChange: (event) => {
|
|
48
|
-
field.onChange(event);
|
|
49
|
-
onChange === null || onChange === void 0 || onChange(event);
|
|
50
|
-
},
|
|
51
|
-
onChangeOption: (value) => {
|
|
52
|
-
optionField.onChange(value);
|
|
53
|
-
onChangeOption === null || onChangeOption === void 0 || onChangeOption(value);
|
|
54
|
-
},
|
|
55
|
-
optionValue: String(optionField.value),
|
|
56
|
-
required,
|
|
57
|
-
value: field.value
|
|
58
|
-
}, props), {}, { children }));
|
|
59
|
-
};
|
|
60
|
-
const SelectableCardOptionGroupField = Object.assign(SelectableCardOptionGroupFieldComponent, { Option: SelectableCardOptionGroup.Option });
|
|
63
|
+
value: field.value
|
|
64
|
+
}, props), {}, { children }));
|
|
65
|
+
};
|
|
66
|
+
SelectableCardOptionGroupField = Object.assign(SelectableCardOptionGroupFieldComponent, { Option: SelectableCardOptionGroup.Option });
|
|
67
|
+
});
|
|
61
68
|
|
|
62
69
|
//#endregion
|
|
63
|
-
|
|
70
|
+
init_SelectableCardOptionGroupField();
|
|
71
|
+
export { SelectableCardOptionGroupField, init_SelectableCardOptionGroupField };
|
|
@@ -1,88 +1,96 @@
|
|
|
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 { Slider } 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/SliderField/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
|
-
|
|
35
|
-
name,
|
|
36
|
-
|
|
13
|
+
var _excluded, SliderField;
|
|
14
|
+
var init_SliderField = __esmMin(() => {
|
|
15
|
+
init_providers();
|
|
16
|
+
init_objectWithoutProperties();
|
|
17
|
+
init_objectSpread2();
|
|
18
|
+
_excluded = [
|
|
19
|
+
"name",
|
|
20
|
+
"control",
|
|
21
|
+
"shouldUnregister",
|
|
22
|
+
"max",
|
|
23
|
+
"min",
|
|
24
|
+
"required",
|
|
25
|
+
"validate",
|
|
26
|
+
"onBlur",
|
|
27
|
+
"onChange",
|
|
28
|
+
"label",
|
|
29
|
+
"value",
|
|
30
|
+
"defaultValue",
|
|
31
|
+
"options",
|
|
32
|
+
"aria-label"
|
|
33
|
+
];
|
|
34
|
+
SliderField = (_ref) => {
|
|
35
|
+
var _ref2;
|
|
36
|
+
let { name, control, shouldUnregister, max, min, required, validate, onBlur, onChange, label, value, defaultValue, options, "aria-label": ariaLabel } = _ref;
|
|
37
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
+
const { getError } = useErrors();
|
|
39
|
+
const { field, fieldState: { error } } = useController({
|
|
40
|
+
control,
|
|
41
|
+
name,
|
|
42
|
+
rules: {
|
|
43
|
+
max,
|
|
44
|
+
min,
|
|
45
|
+
required,
|
|
46
|
+
validate
|
|
47
|
+
},
|
|
48
|
+
shouldUnregister
|
|
49
|
+
});
|
|
50
|
+
const finalValue = useMemo(() => {
|
|
51
|
+
if (options && field.value) {
|
|
52
|
+
if (!Array.isArray(field.value)) return options.map((option) => option.value).indexOf(field.value);
|
|
53
|
+
if (Array.isArray(field.value)) return field.value.map((val) => options.map((option) => option.value).indexOf(val));
|
|
54
|
+
}
|
|
55
|
+
return field.value;
|
|
56
|
+
}, [field.value, options]);
|
|
57
|
+
return /* @__PURE__ */ jsx(Slider, _objectSpread2({
|
|
58
|
+
"aria-label": ariaLabel,
|
|
59
|
+
error: getError({
|
|
60
|
+
label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name,
|
|
61
|
+
max,
|
|
62
|
+
min
|
|
63
|
+
}, error),
|
|
64
|
+
label,
|
|
37
65
|
max,
|
|
38
66
|
min,
|
|
67
|
+
name: field.name,
|
|
68
|
+
onBlur: (event) => {
|
|
69
|
+
field.onBlur();
|
|
70
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
71
|
+
},
|
|
72
|
+
onChange: (newValue) => {
|
|
73
|
+
if (options) {
|
|
74
|
+
var _options$newValue;
|
|
75
|
+
const processedValue = Array.isArray(newValue) ? newValue.map((val) => {
|
|
76
|
+
var _options$val;
|
|
77
|
+
var _options$;
|
|
78
|
+
return val ? (_options$val = options[val]) === null || _options$val === void 0 ? void 0 : _options$val.value : (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.value;
|
|
79
|
+
}) : (_options$newValue = options[newValue]) === null || _options$newValue === void 0 ? void 0 : _options$newValue.value;
|
|
80
|
+
field.onChange(processedValue);
|
|
81
|
+
onChange === null || onChange === void 0 || onChange(processedValue);
|
|
82
|
+
} else {
|
|
83
|
+
field.onChange(newValue);
|
|
84
|
+
onChange === null || onChange === void 0 || onChange(newValue);
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
options,
|
|
39
88
|
required,
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const finalValue = useMemo(() => {
|
|
45
|
-
if (options && field.value) {
|
|
46
|
-
if (!Array.isArray(field.value)) return options.map((option) => option.value).indexOf(field.value);
|
|
47
|
-
if (Array.isArray(field.value)) return field.value.map((val) => options.map((option) => option.value).indexOf(val));
|
|
48
|
-
}
|
|
49
|
-
return field.value;
|
|
50
|
-
}, [field.value, options]);
|
|
51
|
-
return /* @__PURE__ */ jsx(Slider, _objectSpread2({
|
|
52
|
-
"aria-label": ariaLabel,
|
|
53
|
-
error: getError({
|
|
54
|
-
label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name,
|
|
55
|
-
max,
|
|
56
|
-
min
|
|
57
|
-
}, error),
|
|
58
|
-
label,
|
|
59
|
-
max,
|
|
60
|
-
min,
|
|
61
|
-
name: field.name,
|
|
62
|
-
onBlur: (event) => {
|
|
63
|
-
field.onBlur();
|
|
64
|
-
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
65
|
-
},
|
|
66
|
-
onChange: (newValue) => {
|
|
67
|
-
if (options) {
|
|
68
|
-
var _options$newValue;
|
|
69
|
-
const processedValue = Array.isArray(newValue) ? newValue.map((val) => {
|
|
70
|
-
var _options$val;
|
|
71
|
-
var _options$;
|
|
72
|
-
return val ? (_options$val = options[val]) === null || _options$val === void 0 ? void 0 : _options$val.value : (_options$ = options[0]) === null || _options$ === void 0 ? void 0 : _options$.value;
|
|
73
|
-
}) : (_options$newValue = options[newValue]) === null || _options$newValue === void 0 ? void 0 : _options$newValue.value;
|
|
74
|
-
field.onChange(processedValue);
|
|
75
|
-
onChange === null || onChange === void 0 || onChange(processedValue);
|
|
76
|
-
} else {
|
|
77
|
-
field.onChange(newValue);
|
|
78
|
-
onChange === null || onChange === void 0 || onChange(newValue);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
options,
|
|
82
|
-
required,
|
|
83
|
-
value: finalValue
|
|
84
|
-
}, props));
|
|
85
|
-
};
|
|
89
|
+
value: finalValue
|
|
90
|
+
}, props));
|
|
91
|
+
};
|
|
92
|
+
});
|
|
86
93
|
|
|
87
94
|
//#endregion
|
|
88
|
-
|
|
95
|
+
init_SliderField();
|
|
96
|
+
export { SliderField, init_SliderField };
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { __name } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
|
|
3
3
|
import { Button } from "@ultraviolet/ui";
|
|
4
4
|
import { useFormState } from "react-hook-form";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Submit/index.tsx
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
var Submit;
|
|
9
|
+
var init_Submit = __esmMin(() => {
|
|
10
|
+
Submit = ({ children, className, disabled = false, size, variant = "filled", sentiment = "primary", tooltip, fullWidth, onClick }) => {
|
|
11
|
+
const { isSubmitting, isValid } = useFormState();
|
|
12
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
13
|
+
className,
|
|
14
|
+
disabled: disabled || isSubmitting || !isValid,
|
|
15
|
+
fullWidth,
|
|
16
|
+
isLoading: isSubmitting,
|
|
17
|
+
onClick,
|
|
18
|
+
sentiment,
|
|
19
|
+
size,
|
|
20
|
+
tooltip,
|
|
21
|
+
type: "submit",
|
|
22
|
+
variant,
|
|
23
|
+
children
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
});
|
|
24
27
|
|
|
25
28
|
//#endregion
|
|
26
|
-
|
|
29
|
+
init_Submit();
|
|
30
|
+
export { Submit, init_Submit };
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { __name } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { __esmMin, __name } from "../../_virtual/_rolldown/runtime.js";
|
|
3
3
|
import { Alert } from "@ultraviolet/ui";
|
|
4
4
|
import { useFormState } from "react-hook-form";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
|
|
7
7
|
//#region src/components/SubmitErrorAlert/index.tsx
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
var SubmitErrorAlert;
|
|
9
|
+
var init_SubmitErrorAlert = __esmMin(() => {
|
|
10
|
+
SubmitErrorAlert = ({ className }) => {
|
|
11
|
+
var _errors$root;
|
|
12
|
+
const { errors } = useFormState();
|
|
13
|
+
return (errors === null || errors === void 0 || (_errors$root = errors.root) === null || _errors$root === void 0 || (_errors$root = _errors$root["submit"]) === null || _errors$root === void 0 ? void 0 : _errors$root.message) ? /* @__PURE__ */ jsx(Alert, {
|
|
14
|
+
className,
|
|
15
|
+
sentiment: "danger",
|
|
16
|
+
children: errors.root["submit"].message
|
|
17
|
+
}) : null;
|
|
18
|
+
};
|
|
19
|
+
});
|
|
17
20
|
|
|
18
21
|
//#endregion
|
|
19
|
-
|
|
22
|
+
init_SubmitErrorAlert();
|
|
23
|
+
export { SubmitErrorAlert, init_SubmitErrorAlert };
|
|
@@ -1,49 +1,55 @@
|
|
|
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 { SwitchButton } 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/SwitchButtonField/index.tsx
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
name,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
10
|
+
var _excluded, SwitchButtonField;
|
|
11
|
+
var init_SwitchButtonField = __esmMin(() => {
|
|
12
|
+
init_objectWithoutProperties();
|
|
13
|
+
init_objectSpread2();
|
|
14
|
+
_excluded = [
|
|
15
|
+
"name",
|
|
16
|
+
"size",
|
|
17
|
+
"control",
|
|
18
|
+
"shouldUnregister",
|
|
19
|
+
"onBlur",
|
|
20
|
+
"onChange",
|
|
21
|
+
"onFocus",
|
|
22
|
+
"tooltip",
|
|
23
|
+
"className"
|
|
24
|
+
];
|
|
25
|
+
SwitchButtonField = (_ref) => {
|
|
26
|
+
let { name, size, control, shouldUnregister, onBlur, onChange, onFocus, tooltip, className } = _ref;
|
|
27
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
const { field } = useController({
|
|
29
|
+
control,
|
|
30
|
+
name,
|
|
31
|
+
shouldUnregister
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsx(SwitchButton, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
34
|
+
className,
|
|
35
|
+
name,
|
|
36
|
+
onBlur: (event) => {
|
|
37
|
+
field.onBlur();
|
|
38
|
+
onBlur === null || onBlur === void 0 || onBlur(event);
|
|
39
|
+
},
|
|
40
|
+
onChange: (event) => {
|
|
41
|
+
field.onChange(event);
|
|
42
|
+
onChange === null || onChange === void 0 || onChange(event.target);
|
|
43
|
+
},
|
|
44
|
+
onFocus,
|
|
45
|
+
size,
|
|
46
|
+
tooltip,
|
|
47
|
+
value: field.value
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
SwitchButtonField.Option = SwitchButton.Option;
|
|
51
|
+
});
|
|
47
52
|
|
|
48
53
|
//#endregion
|
|
49
|
-
|
|
54
|
+
init_SwitchButtonField();
|
|
55
|
+
export { SwitchButtonField, init_SwitchButtonField };
|
|
@@ -1,54 +1,63 @@
|
|
|
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 {
|
|
6
|
+
import { init_providers } from "../../providers/index.js";
|
|
7
|
+
import { init_validateRegex, validateRegex } from "../../utils/validateRegex.js";
|
|
7
8
|
import { TagInput } from "@ultraviolet/ui";
|
|
8
9
|
import { useController } from "react-hook-form";
|
|
9
10
|
import { jsx } from "react/jsx-runtime";
|
|
10
11
|
|
|
11
12
|
//#region src/components/TagInputField/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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
13
|
+
var _excluded, TagInputField;
|
|
14
|
+
var init_TagInputField = __esmMin(() => {
|
|
15
|
+
init_providers();
|
|
16
|
+
init_validateRegex();
|
|
17
|
+
init_objectWithoutProperties();
|
|
18
|
+
init_objectSpread2();
|
|
19
|
+
_excluded = [
|
|
20
|
+
"regex",
|
|
21
|
+
"control",
|
|
22
|
+
"name",
|
|
23
|
+
"onChange",
|
|
24
|
+
"required",
|
|
25
|
+
"shouldUnregister",
|
|
26
|
+
"label",
|
|
27
|
+
"validate",
|
|
28
|
+
"aria-label"
|
|
29
|
+
];
|
|
30
|
+
TagInputField = (_ref) => {
|
|
31
|
+
var _ref2;
|
|
32
|
+
let { regex: regexes, control, name, onChange, required, shouldUnregister = false, label, validate, "aria-label": ariaLabel } = _ref;
|
|
33
|
+
let props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
const { getError } = useErrors();
|
|
35
|
+
const { field, fieldState: { error } } = useController({
|
|
36
|
+
control,
|
|
37
|
+
name,
|
|
38
|
+
rules: {
|
|
39
|
+
required,
|
|
40
|
+
shouldUnregister,
|
|
41
|
+
validate: _objectSpread2(_objectSpread2({}, regexes ? { pattern: (value) => value.every((val) => validateRegex(val, regexes)) } : {}), validate)
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ jsx(TagInput, _objectSpread2(_objectSpread2({}, props), {}, {
|
|
45
|
+
"aria-label": ariaLabel,
|
|
46
|
+
error: getError({
|
|
47
|
+
label: (_ref2 = label !== null && label !== void 0 ? label : ariaLabel) !== null && _ref2 !== void 0 ? _ref2 : name,
|
|
48
|
+
regex: regexes
|
|
49
|
+
}, error),
|
|
50
|
+
label,
|
|
51
|
+
name: field.name,
|
|
52
|
+
onChange: (newTags) => {
|
|
53
|
+
field.onChange(newTags);
|
|
54
|
+
onChange === null || onChange === void 0 || onChange(newTags);
|
|
55
|
+
},
|
|
56
|
+
value: field.value
|
|
57
|
+
}));
|
|
58
|
+
};
|
|
59
|
+
});
|
|
52
60
|
|
|
53
61
|
//#endregion
|
|
54
|
-
|
|
62
|
+
init_TagInputField();
|
|
63
|
+
export { TagInputField, init_TagInputField };
|