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