@gen-epix/ui-core-form 4.0.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/LICENSE +287 -0
- package/dist/@types/ui-form.d.ts +2 -0
- package/dist/@types/vite-env.d.ts +2 -0
- package/dist/@types/yup.d.ts +30 -0
- package/dist/_chunks/Autocomplete.js +229 -0
- package/dist/_chunks/Autocomplete.js.map +1 -0
- package/dist/_chunks/DatePicker.js +126 -0
- package/dist/_chunks/DatePicker.js.map +1 -0
- package/dist/_chunks/FormUtil.js +1350 -0
- package/dist/_chunks/FormUtil.js.map +1 -0
- package/dist/_chunks/RichTextEditor.js +22721 -0
- package/dist/_chunks/RichTextEditor.js.map +1 -0
- package/dist/_chunks/TransferList.js +453 -0
- package/dist/_chunks/TransferList.js.map +1 -0
- package/dist/_chunks/UploadButton.js +91 -0
- package/dist/_chunks/UploadButton.js.map +1 -0
- package/dist/_chunks/classnames.js +33 -0
- package/dist/_chunks/classnames.js.map +1 -0
- package/dist/_chunks/index.esm.js +348 -0
- package/dist/_chunks/index.esm.js.map +1 -0
- package/dist/_chunks/isEqual.js +348 -0
- package/dist/_chunks/isEqual.js.map +1 -0
- package/dist/_chunks/isObjectLike.js +304 -0
- package/dist/_chunks/isObjectLike.js.map +1 -0
- package/dist/_chunks/isValid.js +28 -0
- package/dist/_chunks/isValid.js.map +1 -0
- package/dist/_chunks/rolldown-runtime.js +13 -0
- package/dist/_chunks/sv.js +434 -0
- package/dist/_chunks/sv.js.map +1 -0
- package/dist/components/fields/Autocomplete/Autocomplete.d.ts +19 -0
- package/dist/components/fields/Autocomplete/AutocompleteSelectAllContext.d.ts +2 -0
- package/dist/components/fields/Autocomplete/AutocompleteSelectAllPaper.d.ts +2 -0
- package/dist/components/fields/Autocomplete/index.d.ts +1 -0
- package/dist/components/fields/Autocomplete/index.js +2 -0
- package/dist/components/fields/CheckboxGroup/CheckboxGroup.d.ts +18 -0
- package/dist/components/fields/CheckboxGroup/index.d.ts +1 -0
- package/dist/components/fields/CheckboxGroup/index.js +114 -0
- package/dist/components/fields/CheckboxGroup/index.js.map +1 -0
- package/dist/components/fields/DatePicker/DatePicker.d.ts +15 -0
- package/dist/components/fields/DatePicker/DatePickerInputAdornment.d.ts +8 -0
- package/dist/components/fields/DatePicker/index.d.ts +1 -0
- package/dist/components/fields/DatePicker/index.js +2 -0
- package/dist/components/fields/DateRangePicker/DateRangePicker.d.ts +17 -0
- package/dist/components/fields/DateRangePicker/index.d.ts +1 -0
- package/dist/components/fields/DateRangePicker/index.js +1648 -0
- package/dist/components/fields/DateRangePicker/index.js.map +1 -0
- package/dist/components/fields/NumberField/NumberField.d.ts +19 -0
- package/dist/components/fields/NumberField/index.d.ts +1 -0
- package/dist/components/fields/NumberField/index.js +180 -0
- package/dist/components/fields/NumberField/index.js.map +1 -0
- package/dist/components/fields/NumberRangeInput/NumberRangeInput.d.ts +15 -0
- package/dist/components/fields/NumberRangeInput/index.d.ts +1 -0
- package/dist/components/fields/NumberRangeInput/index.js +192 -0
- package/dist/components/fields/NumberRangeInput/index.js.map +1 -0
- package/dist/components/fields/RadioGroup/RadioGroup.d.ts +16 -0
- package/dist/components/fields/RadioGroup/index.d.ts +1 -0
- package/dist/components/fields/RadioGroup/index.js +72 -0
- package/dist/components/fields/RadioGroup/index.js.map +1 -0
- package/dist/components/fields/RichTextEditor/RichTextEditor.d.ts +13 -0
- package/dist/components/fields/RichTextEditor/RichTextEditorContent.d.ts +4 -0
- package/dist/components/fields/RichTextEditor/index.d.ts +2 -0
- package/dist/components/fields/RichTextEditor/index.js +2 -0
- package/dist/components/fields/RichTextEditor/useRichTextEditorExtensions.d.ts +10 -0
- package/dist/components/fields/Select/Select.d.ts +16 -0
- package/dist/components/fields/Select/index.d.ts +1 -0
- package/dist/components/fields/Select/index.js +129 -0
- package/dist/components/fields/Select/index.js.map +1 -0
- package/dist/components/fields/Switch/Switch.d.ts +13 -0
- package/dist/components/fields/Switch/index.d.ts +1 -0
- package/dist/components/fields/Switch/index.js +68 -0
- package/dist/components/fields/Switch/index.js.map +1 -0
- package/dist/components/fields/TextField/TextField.d.ts +18 -0
- package/dist/components/fields/TextField/index.d.ts +1 -0
- package/dist/components/fields/TextField/index.js +108 -0
- package/dist/components/fields/TextField/index.js.map +1 -0
- package/dist/components/fields/ToggleButtonGroup/ToggleButtonGroup.d.ts +14 -0
- package/dist/components/fields/ToggleButtonGroup/index.d.ts +1 -0
- package/dist/components/fields/ToggleButtonGroup/index.js +57 -0
- package/dist/components/fields/ToggleButtonGroup/index.js.map +1 -0
- package/dist/components/fields/TransferList/TransferList.d.ts +16 -0
- package/dist/components/fields/TransferList/index.d.ts +1 -0
- package/dist/components/fields/TransferList/index.js +2 -0
- package/dist/components/fields/UploadButton/UploadButton.d.ts +15 -0
- package/dist/components/fields/UploadButton/index.d.ts +1 -0
- package/dist/components/fields/UploadButton/index.js +2 -0
- package/dist/components/helpers/FormFieldHelperText/FormFieldHelperText.d.ts +8 -0
- package/dist/components/helpers/FormFieldHelperText/index.d.ts +1 -0
- package/dist/components/helpers/FormFieldHelperText/index.js +50 -0
- package/dist/components/helpers/FormFieldHelperText/index.js.map +1 -0
- package/dist/components/helpers/FormFieldLoadingIndicator/FormFieldLoadingIndicator.d.ts +4 -0
- package/dist/components/helpers/FormFieldLoadingIndicator/index.d.ts +1 -0
- package/dist/components/helpers/FormFieldLoadingIndicator/index.js +16 -0
- package/dist/components/helpers/FormFieldLoadingIndicator/index.js.map +1 -0
- package/dist/components/helpers/GenericForm/GenericForm.d.ts +18 -0
- package/dist/components/helpers/GenericForm/index.d.ts +1 -0
- package/dist/components/helpers/GenericForm/index.js +156 -0
- package/dist/components/helpers/GenericForm/index.js.map +1 -0
- package/dist/hooks/useIsFormFieldRequiredFromSchema/index.d.ts +1 -0
- package/dist/hooks/useIsFormFieldRequiredFromSchema/index.js +18 -0
- package/dist/hooks/useIsFormFieldRequiredFromSchema/index.js.map +1 -0
- package/dist/hooks/useIsFormFieldRequiredFromSchema/useIsFormFieldRequiredFromSchema.d.ts +4 -0
- package/dist/locale/en.json +97 -0
- package/dist/locale/nl.json +97 -0
- package/dist/models/form.d.ts +112 -0
- package/dist/models/form.js +8 -0
- package/dist/models/form.js.map +1 -0
- package/dist/setup/setup.d.ts +1 -0
- package/dist/setup/setup.js +166 -0
- package/dist/setup/setup.js.map +1 -0
- package/dist/utils/FormUtil/FormUtil.d.ts +19 -0
- package/dist/utils/FormUtil/index.d.ts +1 -0
- package/dist/utils/FormUtil/index.js +2 -0
- package/dist/utils/SchemaUtil/SchemaUtil.d.ts +9 -0
- package/dist/utils/SchemaUtil/index.d.ts +1 -0
- package/dist/utils/SchemaUtil/index.js +30 -0
- package/dist/utils/SchemaUtil/index.js.map +1 -0
- package/package.json +207 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
3
|
+
var t = /* @__PURE__ */ e(((e, t) => {
|
|
4
|
+
(function() {
|
|
5
|
+
var e = {}.hasOwnProperty;
|
|
6
|
+
function n() {
|
|
7
|
+
for (var e = "", t = 0; t < arguments.length; t++) {
|
|
8
|
+
var n = arguments[t];
|
|
9
|
+
n && (e = i(e, r(n)));
|
|
10
|
+
}
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
function r(t) {
|
|
14
|
+
if (typeof t == "string" || typeof t == "number") return t;
|
|
15
|
+
if (typeof t != "object") return "";
|
|
16
|
+
if (Array.isArray(t)) return n.apply(null, t);
|
|
17
|
+
if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]")) return t.toString();
|
|
18
|
+
var r = "";
|
|
19
|
+
for (var a in t) e.call(t, a) && t[a] && (r = i(r, a));
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
22
|
+
function i(e, t) {
|
|
23
|
+
return t ? e ? e + " " + t : e + t : e;
|
|
24
|
+
}
|
|
25
|
+
t !== void 0 && t.exports ? (n.default = n, t.exports = n) : typeof define == "function" && typeof define.amd == "object" && define.amd ? define("classnames", [], function() {
|
|
26
|
+
return n;
|
|
27
|
+
}) : window.classNames = n;
|
|
28
|
+
})();
|
|
29
|
+
}));
|
|
30
|
+
//#endregion
|
|
31
|
+
export { t };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=classnames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classnames.js","names":[],"sources":["../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"],"sourcesContent":["/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue(arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(null, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n"],"x_google_ignoreList":[0],"mappings":";;;CAOA,CAAC,WAAY;EAGZ,IAAI,IAAS,CAAC,EAAE;EAEhB,SAAS,IAAc;GAGtB,KAAK,IAFD,IAAU,IAEL,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;IAC1C,IAAI,IAAM,UAAU;IACpB,AAAI,MACH,IAAU,EAAY,GAAS,EAAW,CAAG,CAAC;GAEhD;GAEA,OAAO;EACR;EAEA,SAAS,EAAY,GAAK;GACzB,IAAI,OAAO,KAAQ,YAAY,OAAO,KAAQ,UAC7C,OAAO;GAGR,IAAI,OAAO,KAAQ,UAClB,OAAO;GAGR,IAAI,MAAM,QAAQ,CAAG,GACpB,OAAO,EAAW,MAAM,MAAM,CAAG;GAGlC,IAAI,EAAI,aAAa,OAAO,UAAU,YAAY,CAAC,EAAI,SAAS,SAAS,CAAC,CAAC,SAAS,eAAe,GAClG,OAAO,EAAI,SAAS;GAGrB,IAAI,IAAU;GAEd,KAAK,IAAI,KAAO,GACf,AAAI,EAAO,KAAK,GAAK,CAAG,KAAK,EAAI,OAChC,IAAU,EAAY,GAAS,CAAG;GAIpC,OAAO;EACR;EAEA,SAAS,EAAa,GAAO,GAAU;GAStC,OARK,IAID,IACI,IAAQ,MAAM,IAGf,IAAQ,IAPP;EAQT;EAEA,AAAW,MAAW,UAAe,EAAO,WAC3C,EAAW,UAAU,GACrB,EAAO,UAAU,KACP,OAAO,UAAW,cAAc,OAAO,OAAO,OAAQ,YAAY,OAAO,MAEnF,OAAO,cAAc,CAAC,GAAG,WAAY;GACpC,OAAO;EACR,CAAC,IAED,OAAO,aAAa;CAEtB,EAAA,CAAE"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
//#region ../../node_modules/.pnpm/react-hook-form@7.80.0_react@19.2.7/node_modules/react-hook-form/dist/index.esm.mjs
|
|
3
|
+
var t = (e) => e.type === "checkbox", n = (e) => e instanceof Date, r = (e) => e == null, i = (e) => typeof e == "object", a = (e) => !r(e) && !Array.isArray(e) && i(e) && !n(e), o = (e) => a(e) && e.target ? t(e.target) ? e.target.checked : e.target.value : e, s = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), c = (e) => {
|
|
4
|
+
let t = e.constructor && e.constructor.prototype;
|
|
5
|
+
return a(t) && t.hasOwnProperty("isPrototypeOf");
|
|
6
|
+
}, l = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
|
|
7
|
+
function u(e) {
|
|
8
|
+
if (e instanceof Date) return new Date(e);
|
|
9
|
+
let t = typeof FileList < "u" && e instanceof FileList;
|
|
10
|
+
if (l && (e instanceof Blob || t)) return e;
|
|
11
|
+
let n = Array.isArray(e);
|
|
12
|
+
if (!n && !(a(e) && c(e))) return e;
|
|
13
|
+
let r = n ? [] : Object.create(Object.getPrototypeOf(e));
|
|
14
|
+
for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = u(e[t]));
|
|
15
|
+
return r;
|
|
16
|
+
}
|
|
17
|
+
var d = {
|
|
18
|
+
BLUR: "blur",
|
|
19
|
+
FOCUS_OUT: "focusout",
|
|
20
|
+
CHANGE: "change",
|
|
21
|
+
SUBMIT: "submit",
|
|
22
|
+
TRIGGER: "trigger",
|
|
23
|
+
VALID: "valid"
|
|
24
|
+
}, f = {
|
|
25
|
+
onBlur: "onBlur",
|
|
26
|
+
onChange: "onChange",
|
|
27
|
+
onSubmit: "onSubmit",
|
|
28
|
+
onTouched: "onTouched",
|
|
29
|
+
all: "all"
|
|
30
|
+
}, p = [
|
|
31
|
+
"__proto__",
|
|
32
|
+
"constructor",
|
|
33
|
+
"prototype"
|
|
34
|
+
], m = /^\w*$/, h = (e) => m.test(e), g = (e) => e === void 0, _ = /[.[\]'"]/, v = (e) => e.split(_).filter(Boolean), y = (e, t, n) => {
|
|
35
|
+
if (!t || !a(e)) return n;
|
|
36
|
+
let i = h(t) ? [t] : v(t);
|
|
37
|
+
if (i.some((e) => p.includes(e))) return n;
|
|
38
|
+
let o = i.reduce((e, t) => r(e) ? void 0 : e[t], e);
|
|
39
|
+
return g(o) || o === e ? g(e[t]) ? n : e[t] : o;
|
|
40
|
+
}, b = (e) => typeof e == "boolean", x = (e) => typeof e == "function", S = (e, t, n) => {
|
|
41
|
+
let r = -1, i = h(t) ? [t] : v(t), o = i.length, s = o - 1;
|
|
42
|
+
for (; ++r < o;) {
|
|
43
|
+
let t = i[r], o = n;
|
|
44
|
+
if (r !== s) {
|
|
45
|
+
let n = e[t];
|
|
46
|
+
o = a(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
|
|
47
|
+
}
|
|
48
|
+
if (p.includes(t)) return;
|
|
49
|
+
e[t] = o, e = e[t];
|
|
50
|
+
}
|
|
51
|
+
}, C = e.createContext(null);
|
|
52
|
+
C.displayName = "HookFormControlContext";
|
|
53
|
+
var w = () => e.useContext(C), T = (e, t, n, r = !0) => {
|
|
54
|
+
let i = {};
|
|
55
|
+
for (let a in e) Object.defineProperty(i, a, { get: () => {
|
|
56
|
+
let i = a;
|
|
57
|
+
return t._proxyFormState[i] !== f.all && (t._proxyFormState[i] = !r || f.all), n && (n[i] = !0), e[i];
|
|
58
|
+
} });
|
|
59
|
+
return i;
|
|
60
|
+
}, E = l ? e.useLayoutEffect : e.useEffect;
|
|
61
|
+
function D(t) {
|
|
62
|
+
let n = w(), { control: r = n, disabled: i, name: a, exact: o } = t || {}, [s, c] = e.useState(() => ({
|
|
63
|
+
...r._formState,
|
|
64
|
+
defaultValues: r._defaultValues
|
|
65
|
+
})), l = e.useRef({
|
|
66
|
+
isDirty: !1,
|
|
67
|
+
isLoading: !1,
|
|
68
|
+
dirtyFields: !1,
|
|
69
|
+
touchedFields: !1,
|
|
70
|
+
validatingFields: !1,
|
|
71
|
+
isValidating: !1,
|
|
72
|
+
isValid: !1,
|
|
73
|
+
errors: !1
|
|
74
|
+
});
|
|
75
|
+
return E(() => r._subscribe({
|
|
76
|
+
name: a,
|
|
77
|
+
formState: l.current,
|
|
78
|
+
exact: o,
|
|
79
|
+
callback: (e) => {
|
|
80
|
+
!i && c({
|
|
81
|
+
...r._formState,
|
|
82
|
+
...e,
|
|
83
|
+
defaultValues: r._defaultValues
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}), [
|
|
87
|
+
a,
|
|
88
|
+
i,
|
|
89
|
+
o
|
|
90
|
+
]), e.useEffect(() => {
|
|
91
|
+
l.current.isValid && r._setValid(!0);
|
|
92
|
+
}, [r]), e.useMemo(() => T(s, r, l.current, !1), [s, r]);
|
|
93
|
+
}
|
|
94
|
+
var O = (e) => typeof e == "string", k = (e, t, n, r, i) => O(e) ? (r && t.watch.add(e), y(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), y(n, e))) : (r && (t.watchAll = !0), n), A = (e) => r(e) || !i(e), j = (e, t) => t.length === 0 && !Array.isArray(e) && !c(e);
|
|
95
|
+
function M(e, t, r = /* @__PURE__ */ new WeakMap()) {
|
|
96
|
+
if (e === t) return !0;
|
|
97
|
+
if (A(e) || A(t)) return Object.is(e, t);
|
|
98
|
+
if (n(e) && n(t)) return Object.is(e.getTime(), t.getTime());
|
|
99
|
+
let i = Object.keys(e), o = Object.keys(t);
|
|
100
|
+
if (i.length !== o.length) return !1;
|
|
101
|
+
if (j(e, i) || j(t, o)) return Object.is(e, t);
|
|
102
|
+
if (!i.length && Array.isArray(e) !== Array.isArray(t)) return !1;
|
|
103
|
+
let s = r.get(e);
|
|
104
|
+
if (s && s.has(t)) return !0;
|
|
105
|
+
if (s) s.add(t);
|
|
106
|
+
else {
|
|
107
|
+
let n = /* @__PURE__ */ new WeakSet();
|
|
108
|
+
n.add(t), r.set(e, n);
|
|
109
|
+
}
|
|
110
|
+
for (let o of i) {
|
|
111
|
+
let i = e[o];
|
|
112
|
+
if (!(o in t)) return !1;
|
|
113
|
+
if (o !== "ref") {
|
|
114
|
+
let e = t[o];
|
|
115
|
+
if (n(i) && n(e) || (a(i) || Array.isArray(i)) && (a(e) || Array.isArray(e)) ? !M(i, e, r) : !Object.is(i, e)) return !1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return !0;
|
|
119
|
+
}
|
|
120
|
+
function N(t) {
|
|
121
|
+
let n = w(), { control: r = n, name: i, defaultValue: a, disabled: o, exact: s, compute: c } = t || {}, l = e.useRef(a), u = e.useRef(c), d = e.useRef(void 0), f = e.useRef(r), p = e.useRef(i);
|
|
122
|
+
u.current = c;
|
|
123
|
+
let [m, h] = e.useState(() => {
|
|
124
|
+
let e = r._getWatch(i, l.current);
|
|
125
|
+
return u.current ? u.current(e) : e;
|
|
126
|
+
}), g = e.useCallback((e) => {
|
|
127
|
+
let t = k(i, r._names, e || r._formValues, !1, l.current);
|
|
128
|
+
return u.current ? u.current(t) : t;
|
|
129
|
+
}, [
|
|
130
|
+
r._formValues,
|
|
131
|
+
r._names,
|
|
132
|
+
i
|
|
133
|
+
]), _ = e.useCallback((e) => {
|
|
134
|
+
if (!o) {
|
|
135
|
+
let t = k(i, r._names, e || r._formValues, !1, l.current);
|
|
136
|
+
if (u.current) {
|
|
137
|
+
let e = u.current(t);
|
|
138
|
+
M(e, d.current) || (h(e), d.current = e);
|
|
139
|
+
} else h(t);
|
|
140
|
+
}
|
|
141
|
+
}, [
|
|
142
|
+
r._formValues,
|
|
143
|
+
r._names,
|
|
144
|
+
o,
|
|
145
|
+
i
|
|
146
|
+
]);
|
|
147
|
+
E(() => ((f.current !== r || !M(p.current, i)) && (f.current = r, p.current = i, _()), r._subscribe({
|
|
148
|
+
name: i,
|
|
149
|
+
formState: { values: !0 },
|
|
150
|
+
exact: s,
|
|
151
|
+
callback: (e) => {
|
|
152
|
+
_(e.values);
|
|
153
|
+
}
|
|
154
|
+
})), [
|
|
155
|
+
r,
|
|
156
|
+
s,
|
|
157
|
+
i,
|
|
158
|
+
_
|
|
159
|
+
]), e.useEffect(() => r._removeUnmounted());
|
|
160
|
+
let v = f.current !== r, y = p.current, b = e.useMemo(() => {
|
|
161
|
+
if (o) return null;
|
|
162
|
+
let e = !v && !M(y, i);
|
|
163
|
+
return v || e ? g() : null;
|
|
164
|
+
}, [
|
|
165
|
+
o,
|
|
166
|
+
v,
|
|
167
|
+
i,
|
|
168
|
+
y,
|
|
169
|
+
g
|
|
170
|
+
]);
|
|
171
|
+
return b === null ? m : b;
|
|
172
|
+
}
|
|
173
|
+
function P(t) {
|
|
174
|
+
let n = w(), { name: r, disabled: i, control: a = n, shouldUnregister: c, defaultValue: l, exact: f = !0 } = t, p = s(a._names.array, r), m = N({
|
|
175
|
+
control: a,
|
|
176
|
+
name: r,
|
|
177
|
+
defaultValue: e.useMemo(() => y(a._formValues, r, y(a._defaultValues, r, l)), [
|
|
178
|
+
a,
|
|
179
|
+
r,
|
|
180
|
+
l
|
|
181
|
+
]),
|
|
182
|
+
exact: f
|
|
183
|
+
}), h = D({
|
|
184
|
+
control: a,
|
|
185
|
+
name: r,
|
|
186
|
+
exact: f
|
|
187
|
+
}), _ = e.useRef(t), v = e.useRef(null), C = e.useRef(a.register(r, {
|
|
188
|
+
...t.rules,
|
|
189
|
+
value: m,
|
|
190
|
+
...b(t.disabled) ? { disabled: t.disabled } : {}
|
|
191
|
+
}));
|
|
192
|
+
_.current = t;
|
|
193
|
+
let T = e.useMemo(() => Object.defineProperties({}, {
|
|
194
|
+
invalid: {
|
|
195
|
+
enumerable: !0,
|
|
196
|
+
get: () => !!y(h.errors, r)
|
|
197
|
+
},
|
|
198
|
+
isDirty: {
|
|
199
|
+
enumerable: !0,
|
|
200
|
+
get: () => !!y(h.dirtyFields, r)
|
|
201
|
+
},
|
|
202
|
+
isTouched: {
|
|
203
|
+
enumerable: !0,
|
|
204
|
+
get: () => !!y(h.touchedFields, r)
|
|
205
|
+
},
|
|
206
|
+
isValidating: {
|
|
207
|
+
enumerable: !0,
|
|
208
|
+
get: () => !!y(h.validatingFields, r)
|
|
209
|
+
},
|
|
210
|
+
error: {
|
|
211
|
+
enumerable: !0,
|
|
212
|
+
get: () => y(h.errors, r)
|
|
213
|
+
}
|
|
214
|
+
}), [h, r]), E = e.useCallback((e) => {
|
|
215
|
+
let t = o(e);
|
|
216
|
+
return y(a._fields, r) || (C.current = a.register(r, {
|
|
217
|
+
..._.current.rules,
|
|
218
|
+
value: t
|
|
219
|
+
})), C.current.onChange({
|
|
220
|
+
target: {
|
|
221
|
+
value: o(e),
|
|
222
|
+
name: r
|
|
223
|
+
},
|
|
224
|
+
type: d.CHANGE
|
|
225
|
+
});
|
|
226
|
+
}, [r, a]), O = e.useCallback(() => C.current.onBlur({
|
|
227
|
+
target: {
|
|
228
|
+
value: y(a._formValues, r),
|
|
229
|
+
name: r
|
|
230
|
+
},
|
|
231
|
+
type: d.BLUR
|
|
232
|
+
}), [r, a._formValues]), k = e.useCallback((e) => {
|
|
233
|
+
e && (v.current = {
|
|
234
|
+
focus: () => x(e.focus) && e.focus(),
|
|
235
|
+
select: () => x(e.select) && e.select(),
|
|
236
|
+
setCustomValidity: (t) => x(e.setCustomValidity) && e.setCustomValidity(t),
|
|
237
|
+
reportValidity: () => x(e.reportValidity) && e.reportValidity()
|
|
238
|
+
});
|
|
239
|
+
let t = y(a._fields, r);
|
|
240
|
+
t && t._f && e && (t._f.ref = v.current);
|
|
241
|
+
}, [a._fields, r]), A = e.useMemo(() => ({
|
|
242
|
+
name: r,
|
|
243
|
+
value: m,
|
|
244
|
+
...b(i) || h.disabled ? { disabled: h.disabled || i } : {},
|
|
245
|
+
onChange: E,
|
|
246
|
+
onBlur: O,
|
|
247
|
+
ref: k
|
|
248
|
+
}), [
|
|
249
|
+
r,
|
|
250
|
+
i,
|
|
251
|
+
h.disabled,
|
|
252
|
+
E,
|
|
253
|
+
O,
|
|
254
|
+
k,
|
|
255
|
+
m
|
|
256
|
+
]);
|
|
257
|
+
return e.useEffect(() => {
|
|
258
|
+
let e = a._options.shouldUnregister || c;
|
|
259
|
+
a.register(r, {
|
|
260
|
+
..._.current.rules,
|
|
261
|
+
...b(_.current.disabled) ? { disabled: _.current.disabled } : {}
|
|
262
|
+
});
|
|
263
|
+
let t = (e, t) => {
|
|
264
|
+
let n = y(a._fields, e);
|
|
265
|
+
n && n._f && (n._f.mount = t);
|
|
266
|
+
};
|
|
267
|
+
if (t(r, !0), e) {
|
|
268
|
+
let e = u(y(c ? a._defaultValues : a._options.values || a._defaultValues, r, y(a._options.defaultValues, r, _.current.defaultValue)));
|
|
269
|
+
S(a._defaultValues, r, e), g(y(a._formValues, r)) && S(a._formValues, r, e);
|
|
270
|
+
}
|
|
271
|
+
if (!p && a.register(r), v.current) {
|
|
272
|
+
let e = y(a._fields, r);
|
|
273
|
+
e && e._f && (e._f.ref = v.current);
|
|
274
|
+
}
|
|
275
|
+
return () => {
|
|
276
|
+
(p ? e && !a._state.action : e) ? a.unregister(r) : t(r, !1);
|
|
277
|
+
};
|
|
278
|
+
}, [
|
|
279
|
+
r,
|
|
280
|
+
a,
|
|
281
|
+
p,
|
|
282
|
+
c
|
|
283
|
+
]), e.useEffect(() => {
|
|
284
|
+
a._setDisabledField({
|
|
285
|
+
disabled: i,
|
|
286
|
+
name: r
|
|
287
|
+
});
|
|
288
|
+
}, [
|
|
289
|
+
i,
|
|
290
|
+
r,
|
|
291
|
+
a
|
|
292
|
+
]), e.useMemo(() => ({
|
|
293
|
+
field: A,
|
|
294
|
+
formState: h,
|
|
295
|
+
fieldState: T
|
|
296
|
+
}), [
|
|
297
|
+
A,
|
|
298
|
+
h,
|
|
299
|
+
T
|
|
300
|
+
]);
|
|
301
|
+
}
|
|
302
|
+
var F = (e) => e.render(P(e)), I = e.createContext(null);
|
|
303
|
+
I.displayName = "HookFormContext";
|
|
304
|
+
var L = () => e.useContext(I), R = ({ children: t, watch: n, getValues: r, getFieldState: i, setError: a, clearErrors: o, setValue: s, setValues: c, trigger: l, formState: u, resetField: d, reset: f, handleSubmit: p, unregister: m, control: h, register: g, setFocus: _, subscribe: v }) => {
|
|
305
|
+
let y = e.useMemo(() => ({
|
|
306
|
+
watch: n,
|
|
307
|
+
getValues: r,
|
|
308
|
+
getFieldState: i,
|
|
309
|
+
setError: a,
|
|
310
|
+
clearErrors: o,
|
|
311
|
+
setValue: s,
|
|
312
|
+
setValues: c,
|
|
313
|
+
trigger: l,
|
|
314
|
+
formState: u,
|
|
315
|
+
resetField: d,
|
|
316
|
+
reset: f,
|
|
317
|
+
handleSubmit: p,
|
|
318
|
+
unregister: m,
|
|
319
|
+
control: h,
|
|
320
|
+
register: g,
|
|
321
|
+
setFocus: _,
|
|
322
|
+
subscribe: v
|
|
323
|
+
}), [
|
|
324
|
+
o,
|
|
325
|
+
h,
|
|
326
|
+
u,
|
|
327
|
+
i,
|
|
328
|
+
r,
|
|
329
|
+
p,
|
|
330
|
+
g,
|
|
331
|
+
f,
|
|
332
|
+
d,
|
|
333
|
+
a,
|
|
334
|
+
_,
|
|
335
|
+
s,
|
|
336
|
+
c,
|
|
337
|
+
v,
|
|
338
|
+
l,
|
|
339
|
+
m,
|
|
340
|
+
n
|
|
341
|
+
]);
|
|
342
|
+
return e.createElement(I.Provider, { value: y }, e.createElement(C.Provider, { value: y.control }, t));
|
|
343
|
+
};
|
|
344
|
+
f.onSubmit, f.onChange;
|
|
345
|
+
//#endregion
|
|
346
|
+
export { N as a, L as i, R as n, S as r, F as t };
|
|
347
|
+
|
|
348
|
+
//# sourceMappingURL=index.esm.js.map
|