react-simple-formkit 1.3.4 → 1.3.6
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/README.md +2 -2
- package/dist/react-simple-formkit.js +4 -4
- package/dist/react-simple-formkit.mjs +230 -240
- package/dist/react-simple-formkit.umd.js +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,9 +193,9 @@ const handleSubmit = async (data) => {
|
|
|
193
193
|
setLoading(true);
|
|
194
194
|
await new Promise((res) => setTimeout(res, 1500));
|
|
195
195
|
setDefaultValues(data);
|
|
196
|
-
// After update default values,
|
|
196
|
+
// After update default values, reset the form to get new default values
|
|
197
197
|
// Because data updating is asynchronous. Catching it's change is ineffective.
|
|
198
|
-
actions.
|
|
198
|
+
actions.reset();
|
|
199
199
|
setLoading(false);
|
|
200
200
|
};
|
|
201
201
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react");var J={exports:{}},I={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Z;function
|
|
9
|
+
*/var Z;function se(){if(Z)return I;Z=1;var s=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(i,l,f){var R=null;if(f!==void 0&&(R=""+f),l.key!==void 0&&(R=""+l.key),"key"in l){f={};for(var b in l)b!=="key"&&(f[b]=l[b])}else f=l;return l=f.ref,{$$typeof:s,type:i,key:R,ref:l!==void 0?l:null,props:f}}return I.Fragment=t,I.jsx=o,I.jsxs=o,I}var $={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Q;function
|
|
17
|
+
*/var Q;function oe(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===O?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case C:return"Fragment";case h:return"Profiler";case _:return"StrictMode";case M:return"Suspense";case G:return"SuspenseList";case W:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case z:return"Portal";case V:return(e.displayName||"Context")+".Provider";case N:return(e._context.displayName||"Context")+".Consumer";case w:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case D:r=e._payload,e=e._init;try{return s(e(r))}catch{}}return null}function t(e){return""+e}function o(e){try{t(e);var r=!1}catch{r=!0}if(r){r=console;var c=r.error,u=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",u),t(e)}}function i(e){if(e===C)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===D)return"<...>";try{var r=s(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function l(){var e=A.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function R(e){if(y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function b(e,r){function c(){F||(F=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function E(){var e=s(this.type);return Y[e]||(Y[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function p(e,r,c,u,g,S,X,B){return c=S.ref,e={$$typeof:x,type:e,key:r,props:S,_owner:g},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:E}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function T(e,r,c,u,g,S,X,B){var k=r.children;if(k!==void 0)if(u)if(q(k)){for(u=0;u<k.length;u++)m(k[u]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(k);if(y.call(r,"key")){k=s(e);var P=Object.keys(r).filter(function(ae){return ae!=="key"});u=0<P.length?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}",d[k+u]||(P=0<P.length?"{"+P.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,k,
|
|
22
|
+
<%s key={someKey} {...props} />`,u,k,P,k),d[k+u]=!0)}if(k=null,c!==void 0&&(o(c),k=""+c),R(r)&&(o(r.key),k=""+r.key),"key"in r){c={};for(var H in r)H!=="key"&&(c[H]=r[H])}else c=r;return k&&b(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),p(e,k,S,g,l(),c,X,B)}function m(e){typeof e=="object"&&e!==null&&e.$$typeof===x&&e._store&&(e._store.validated=1)}var v=n,x=Symbol.for("react.transitional.element"),z=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),V=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),O=Symbol.for("react.client.reference"),A=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,y=Object.prototype.hasOwnProperty,q=Array.isArray,j=console.createTask?console.createTask:function(){return null};v={"react-stack-bottom-frame":function(e){return e()}};var F,Y={},U=v["react-stack-bottom-frame"].bind(v,f)(),a=j(i(f)),d={};$.Fragment=C,$.jsx=function(e,r,c,u,g){var S=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,c,!1,u,g,S?Error("react-stack-top-frame"):U,S?j(i(e)):a)},$.jsxs=function(e,r,c,u,g){var S=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,c,!0,u,g,S?Error("react-stack-top-frame"):U,S?j(i(e)):a)}}()),$}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?J.exports=se():J.exports=oe()),J.exports}var ee=ce();const te=n.createContext({}),ue=()=>n.useContext(te),le=({id:s,form:t,method:o,action:i,children:l,onSubmit:f=()=>{},onInput:R=()=>{},onChange:b=()=>{},numberFields:E=[],className:p,...T})=>(n.useEffect(()=>t.actions.registerOnchange(b),[b]),ee.jsx(te.Provider,{value:t,children:t.ready&&ee.jsx("form",{id:s,ref:t==null?void 0:t.ref,action:i,method:o,className:p,onSubmit:m=>{o||m.preventDefault();const v=t.actions.loadFormValues();f(v)},onInput:m=>{if(m.target.tagName==="FORM"){const v=t.actions.loadFormValues();t.actions.setFormState(v)}else R(m)},onChange:()=>{const m=t.actions.loadFormValues();t.actions.setFormState(m)},onReset:m=>{t&&(m.preventDefault(),t.actions.reset())},...T,children:l},t==null?void 0:t.lastReloadedAt)})),ie=({name:s,render:t=({ref:o,name:i,defaultValue:l,value:f,setValue:R})=>null})=>{const o=n.useRef(),i=ue(),l=i.actions.getDefaultValues()[s],[f,R]=n.useState(l),b=n.useCallback((E,{shouldDirty:p=!0}={})=>{i.actions.setFormState(T=>({...T,[s]:E}),{shouldDirty:p}),R(E)},[R,i.actions.setFormState]);return n.useEffect(()=>i.subscribe(s,(p,{shouldDirty:T=!0,shouldOnChange:m=!0}={})=>{R(p),i.actions.setFormState(v=>({...v,[s]:p}),{shouldDirty:T,shouldOnChange:m}),o.current&&typeof o.current.dispatchEvent=="function"&&m&&o.current.dispatchEvent(new Event("change"))}),[]),t({ref:o,name:s,defaultValue:l,value:f,setValue:b})},fe=(s,t)=>{let o=!1;return Object.keys(t).forEach(i=>{if(!(i in s)||o)return;const l=t[i],f=s[i];(typeof l=="object"||l!==f)&&(o=!0)}),o},re=s=>(typeof s.setCustomValidity=="function"&&s.setCustomValidity(""),!s||typeof s.checkValidity!="function"||s.checkValidity()?null:s.validationMessage),ne=()=>{const[s,t]=n.useState({}),o=n.useMemo(()=>Object.values(s).filter(Boolean).length>0,[s]),i=n.useCallback((b,E)=>{t(p=>p[b]===E?p:{...p,[b]:E})},[]),l=n.useCallback(b=>{t(E=>({...E,...b}))},[]),f=n.useCallback(b=>{t(E=>E[b]?{...E,[b]:""}:E)},[]),R=n.useCallback(()=>{t({})},[]);return{isError:o,errors:s,changeError:i,changeErrors:l,clearError:f,clearErrors:R}},de=()=>{const[s,t]=n.useState(),o=n.useCallback(()=>t(new Date().toString()),[]);return[s,o]},be=()=>{const[,s]=n.useState({});return n.useCallback(()=>s({}),[])},Ee=[],me=({numberFields:s=Ee,defaultValues:t={}}={})=>{const{changeError:o,errors:i,changeErrors:l,clearError:f,clearErrors:R,isError:b}=ne(),[E,p]=n.useState(!1),[T,m]=de(),[v,x]=n.useState(!1),z=be(),C=n.useRef(new Set),_=n.useRef(t),h=n.useRef(t),N=n.useRef({}),V=n.useRef(()=>{}),w=n.useRef(),M=n.useCallback((a,{shouldDirty:d=!0,shouldOnChange:e=!0}={})=>{let r=a;typeof a=="function"&&(r=a(_.current)),[...C.current].forEach(g=>{_.current[g]!==r[g]&&z()}),_.current=r;let u=E;d&&(console.log(u,_.current.password,h.current.password),u=fe(_.current,h.current),u!==E&&p(u)),e&&V.current(_.current)},[E]),G=n.useCallback((a,d)=>{const e=N.current;return e[a]=d,()=>{delete e[a],delete _.current[a],delete h.current[a]}},[]),L=n.useCallback(a=>(V.current=a,()=>V.current=()=>{})),D=n.useCallback(()=>x(!1),[]),W=n.useCallback(a=>re(a.target),[]),O=n.useCallback(a=>a?_.current[a]:_.current,[]),A=n.useCallback(()=>h.current,[]),y=n.useCallback(()=>{setTimeout(()=>w.current.dispatchEvent(new Event("input",{bubbles:!0})))},[]),q=n.useCallback(a=>{const d=re(a.target);d?o(a.target.name,d):o(a.target.name,null)},[o]),j=n.useCallback((a,d,{shouldDirty:e=!0,shouldOnChange:r=!0}={})=>{const c=N.current;switch(typeof a){case"string":{const u=c[a];if(!u)throw new Error(`${a} is uncontrolled, please use Controller for it!`);u(d,{shouldDirty:e,shouldOnChange:r}),r&&y()}break;case"object":Object.entries(a).forEach(([u,g])=>{const S=c[u];if(!S)throw new Error(`${u} is uncontrolled, please use Controller for it!`);S(g,{shouldDirty:e,shouldOnChange:r})}),r&&y();default:return}},[y]),F=n.useCallback(()=>{const a=Object.fromEntries(new FormData(w.current)),d=N.current;return Object.keys(d).map(e=>{a[e]=_.current[e]}),s.forEach(e=>a.hasOwnProperty(e)&&(a[e]=+a[e])),a},[]),Y=a=>(C.current.add(a),a==="data"?O():O()[a]),U=n.useMemo(()=>({setValue:j,instantChange:y,getDefaultValues:A,getFormState:O,setFormState:M,changeError:o,changeErrors:l,clearError:f,clearErrors:R,loadFormValues:F,checkValidity:q,getFieldValidity:W,registerOnchange:L,reload:m,reset:D,watch:Y}),[j,y,A,O,M,o,l,f,F,W,q,L,m,D,Y]);return n.useLayoutEffect(()=>{if(!v)h.current={...t},_.current={...t},p(!1),R(),x(!0);else if([...w.current.querySelectorAll("[name]")].forEach(d=>{!d.defaultValue&&t[d.name]&&(d.defaultValue=t[d.name])}),w.current){const d=F();h.current=d,_.current=d}},[v]),{ready:v,ref:w,isDirty:E,isError:b,errors:i,numberFields:s,subscribe:G,actions:U}};exports.Controller=ie;exports.Form=le;exports.useForm=me;exports.useValidateForm=ne;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
1
|
+
import ue, { createContext as le, useContext as ie, useEffect as oe, useRef as O, useState as N, useCallback as m, useMemo as ae, useLayoutEffect as fe } from "react";
|
|
2
|
+
var G = { exports: {} }, M = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -9,29 +9,29 @@ var X = { exports: {} }, $ = {};
|
|
|
9
9
|
* This source code is licensed under the MIT license found in the
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
|
-
var
|
|
12
|
+
var K;
|
|
13
13
|
function de() {
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
var o = Symbol.for("react.transitional.element"),
|
|
17
|
-
function a(
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
for (var
|
|
22
|
-
|
|
23
|
-
} else
|
|
24
|
-
return
|
|
14
|
+
if (K) return M;
|
|
15
|
+
K = 1;
|
|
16
|
+
var o = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
17
|
+
function a(l, u, i) {
|
|
18
|
+
var R = null;
|
|
19
|
+
if (i !== void 0 && (R = "" + i), u.key !== void 0 && (R = "" + u.key), "key" in u) {
|
|
20
|
+
i = {};
|
|
21
|
+
for (var d in u)
|
|
22
|
+
d !== "key" && (i[d] = u[d]);
|
|
23
|
+
} else i = u;
|
|
24
|
+
return u = i.ref, {
|
|
25
25
|
$$typeof: o,
|
|
26
|
-
type:
|
|
27
|
-
key:
|
|
28
|
-
ref:
|
|
29
|
-
props:
|
|
26
|
+
type: l,
|
|
27
|
+
key: R,
|
|
28
|
+
ref: u !== void 0 ? u : null,
|
|
29
|
+
props: i
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return M.Fragment = t, M.jsx = a, M.jsxs = a, M;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var L = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -41,44 +41,44 @@ var M = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
44
|
+
var ee;
|
|
45
45
|
function Ee() {
|
|
46
|
-
return
|
|
46
|
+
return ee || (ee = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
47
|
function o(e) {
|
|
48
48
|
if (e == null) return null;
|
|
49
49
|
if (typeof e == "function")
|
|
50
50
|
return e.$$typeof === j ? null : e.displayName || e.name || null;
|
|
51
51
|
if (typeof e == "string") return e;
|
|
52
52
|
switch (e) {
|
|
53
|
-
case
|
|
53
|
+
case A:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case k:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case g:
|
|
58
58
|
return "StrictMode";
|
|
59
|
-
case
|
|
59
|
+
case W:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case B:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case q:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof e == "object")
|
|
67
67
|
switch (typeof e.tag == "number" && console.error(
|
|
68
68
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
69
|
), e.$$typeof) {
|
|
70
|
-
case
|
|
70
|
+
case X:
|
|
71
71
|
return "Portal";
|
|
72
|
-
case
|
|
72
|
+
case Y:
|
|
73
73
|
return (e.displayName || "Context") + ".Provider";
|
|
74
|
-
case
|
|
74
|
+
case D:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
76
|
+
case y:
|
|
77
77
|
var r = e.render;
|
|
78
78
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
-
case
|
|
79
|
+
case U:
|
|
80
80
|
return r = e.displayName || null, r !== null ? r : o(e.type) || "Memo";
|
|
81
|
-
case
|
|
81
|
+
case I:
|
|
82
82
|
r = e._payload, e = e._init;
|
|
83
83
|
try {
|
|
84
84
|
return o(e(r));
|
|
@@ -87,29 +87,29 @@ function Ee() {
|
|
|
87
87
|
}
|
|
88
88
|
return null;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function t(e) {
|
|
91
91
|
return "" + e;
|
|
92
92
|
}
|
|
93
93
|
function a(e) {
|
|
94
94
|
try {
|
|
95
|
-
|
|
95
|
+
t(e);
|
|
96
96
|
var r = !1;
|
|
97
97
|
} catch {
|
|
98
98
|
r = !0;
|
|
99
99
|
}
|
|
100
100
|
if (r) {
|
|
101
101
|
r = console;
|
|
102
|
-
var s = r.error,
|
|
102
|
+
var s = r.error, c = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
103
|
return s.call(
|
|
104
104
|
r,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
|
|
107
|
-
),
|
|
106
|
+
c
|
|
107
|
+
), t(e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (e ===
|
|
112
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
110
|
+
function l(e) {
|
|
111
|
+
if (e === A) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === I)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
115
|
var r = o(e);
|
|
@@ -118,23 +118,23 @@ function Ee() {
|
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
function
|
|
122
|
-
var e =
|
|
121
|
+
function u() {
|
|
122
|
+
var e = x.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function i() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
if (
|
|
128
|
+
function R(e) {
|
|
129
|
+
if (w.call(e, "key")) {
|
|
130
130
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
131
|
if (r && r.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function d(e, r) {
|
|
136
136
|
function s() {
|
|
137
|
-
|
|
137
|
+
P || (P = !0, console.error(
|
|
138
138
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
139
|
r
|
|
140
140
|
));
|
|
@@ -144,22 +144,22 @@ function Ee() {
|
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function E() {
|
|
148
148
|
var e = o(this.type);
|
|
149
|
-
return
|
|
149
|
+
return $[e] || ($[e] = !0, console.error(
|
|
150
150
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
151
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
152
|
}
|
|
153
|
-
function _(e, r, s,
|
|
154
|
-
return s =
|
|
155
|
-
$$typeof:
|
|
153
|
+
function _(e, r, s, c, T, h, H, Z) {
|
|
154
|
+
return s = h.ref, e = {
|
|
155
|
+
$$typeof: V,
|
|
156
156
|
type: e,
|
|
157
157
|
key: r,
|
|
158
|
-
props:
|
|
159
|
-
_owner:
|
|
158
|
+
props: h,
|
|
159
|
+
_owner: T
|
|
160
160
|
}, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
161
|
enumerable: !1,
|
|
162
|
-
get:
|
|
162
|
+
get: E
|
|
163
163
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
164
164
|
configurable: !1,
|
|
165
165
|
enumerable: !1,
|
|
@@ -182,295 +182,285 @@ function Ee() {
|
|
|
182
182
|
value: Z
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
var
|
|
187
|
-
if (
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
for (
|
|
191
|
-
b(
|
|
192
|
-
Object.freeze && Object.freeze(
|
|
185
|
+
function S(e, r, s, c, T, h, H, Z) {
|
|
186
|
+
var p = r.children;
|
|
187
|
+
if (p !== void 0)
|
|
188
|
+
if (c)
|
|
189
|
+
if (J(p)) {
|
|
190
|
+
for (c = 0; c < p.length; c++)
|
|
191
|
+
b(p[c]);
|
|
192
|
+
Object.freeze && Object.freeze(p);
|
|
193
193
|
} else
|
|
194
194
|
console.error(
|
|
195
195
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
196
|
);
|
|
197
|
-
else b(
|
|
198
|
-
if (
|
|
199
|
-
|
|
200
|
-
var
|
|
201
|
-
return
|
|
197
|
+
else b(p);
|
|
198
|
+
if (w.call(r, "key")) {
|
|
199
|
+
p = o(e);
|
|
200
|
+
var C = Object.keys(r).filter(function(ce) {
|
|
201
|
+
return ce !== "key";
|
|
202
202
|
});
|
|
203
|
-
|
|
203
|
+
c = 0 < C.length ? "{key: someKey, " + C.join(": ..., ") + ": ...}" : "{key: someKey}", f[p + c] || (C = 0 < C.length ? "{" + C.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
204
|
`A props object containing a "key" prop is being spread into JSX:
|
|
205
205
|
let props = %s;
|
|
206
206
|
<%s {...props} />
|
|
207
207
|
React keys must be passed directly to JSX without using spread:
|
|
208
208
|
let props = %s;
|
|
209
209
|
<%s key={someKey} {...props} />`,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
),
|
|
210
|
+
c,
|
|
211
|
+
p,
|
|
212
|
+
C,
|
|
213
|
+
p
|
|
214
|
+
), f[p + c] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (
|
|
216
|
+
if (p = null, s !== void 0 && (a(s), p = "" + s), R(r) && (a(r.key), p = "" + r.key), "key" in r) {
|
|
217
217
|
s = {};
|
|
218
218
|
for (var Q in r)
|
|
219
219
|
Q !== "key" && (s[Q] = r[Q]);
|
|
220
220
|
} else s = r;
|
|
221
|
-
return
|
|
221
|
+
return p && d(
|
|
222
222
|
s,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
224
|
), _(
|
|
225
225
|
e,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
p,
|
|
227
|
+
h,
|
|
228
|
+
T,
|
|
229
|
+
u(),
|
|
230
230
|
s,
|
|
231
231
|
H,
|
|
232
232
|
Z
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
235
|
function b(e) {
|
|
236
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === V && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
238
|
+
var v = ue, V = Symbol.for("react.transitional.element"), X = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), Y = Symbol.for("react.context"), y = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), U = Symbol.for("react.memo"), I = Symbol.for("react.lazy"), q = Symbol.for("react.activity"), j = Symbol.for("react.client.reference"), x = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, w = Object.prototype.hasOwnProperty, J = Array.isArray, F = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
|
-
|
|
241
|
+
v = {
|
|
242
242
|
"react-stack-bottom-frame": function(e) {
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
)(),
|
|
250
|
-
|
|
251
|
-
var
|
|
252
|
-
return
|
|
246
|
+
var P, $ = {}, z = v["react-stack-bottom-frame"].bind(
|
|
247
|
+
v,
|
|
248
|
+
i
|
|
249
|
+
)(), n = F(l(i)), f = {};
|
|
250
|
+
L.Fragment = A, L.jsx = function(e, r, s, c, T) {
|
|
251
|
+
var h = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return S(
|
|
253
253
|
e,
|
|
254
254
|
r,
|
|
255
255
|
s,
|
|
256
256
|
!1,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
c,
|
|
258
|
+
T,
|
|
259
|
+
h ? Error("react-stack-top-frame") : z,
|
|
260
|
+
h ? F(l(e)) : n
|
|
261
261
|
);
|
|
262
|
-
},
|
|
263
|
-
var
|
|
264
|
-
return
|
|
262
|
+
}, L.jsxs = function(e, r, s, c, T) {
|
|
263
|
+
var h = 1e4 > x.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return S(
|
|
265
265
|
e,
|
|
266
266
|
r,
|
|
267
267
|
s,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
269
|
+
c,
|
|
270
|
+
T,
|
|
271
|
+
h ? Error("react-stack-top-frame") : z,
|
|
272
|
+
h ? F(l(e)) : n
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
|
-
}()),
|
|
275
|
+
}()), L;
|
|
276
276
|
}
|
|
277
|
-
var
|
|
277
|
+
var re;
|
|
278
278
|
function be() {
|
|
279
|
-
return
|
|
279
|
+
return re || (re = 1, process.env.NODE_ENV === "production" ? G.exports = de() : G.exports = Ee()), G.exports;
|
|
280
280
|
}
|
|
281
|
-
var
|
|
282
|
-
const
|
|
281
|
+
var te = be();
|
|
282
|
+
const se = le({}), me = () => ie(se), he = ({
|
|
283
283
|
id: o,
|
|
284
|
-
form:
|
|
284
|
+
form: t,
|
|
285
285
|
method: a,
|
|
286
|
-
action:
|
|
287
|
-
children:
|
|
288
|
-
onSubmit:
|
|
286
|
+
action: l,
|
|
287
|
+
children: u,
|
|
288
|
+
onSubmit: i = () => {
|
|
289
289
|
},
|
|
290
|
-
onInput:
|
|
290
|
+
onInput: R = () => {
|
|
291
291
|
},
|
|
292
|
-
onChange:
|
|
292
|
+
onChange: d = () => {
|
|
293
293
|
},
|
|
294
|
-
numberFields:
|
|
294
|
+
numberFields: E = [],
|
|
295
295
|
className: _,
|
|
296
|
-
...
|
|
297
|
-
}) => (
|
|
296
|
+
...S
|
|
297
|
+
}) => (oe(() => t.actions.registerOnchange(d), [d]), /* @__PURE__ */ te.jsx(se.Provider, { value: t, children: t.ready && /* @__PURE__ */ te.jsx(
|
|
298
298
|
"form",
|
|
299
299
|
{
|
|
300
300
|
id: o,
|
|
301
|
-
ref:
|
|
302
|
-
action:
|
|
301
|
+
ref: t == null ? void 0 : t.ref,
|
|
302
|
+
action: l,
|
|
303
303
|
method: a,
|
|
304
304
|
className: _,
|
|
305
305
|
onSubmit: (b) => {
|
|
306
306
|
a || b.preventDefault();
|
|
307
|
-
const
|
|
308
|
-
|
|
307
|
+
const v = t.actions.loadFormValues();
|
|
308
|
+
i(v);
|
|
309
309
|
},
|
|
310
310
|
onInput: (b) => {
|
|
311
311
|
if (b.target.tagName === "FORM") {
|
|
312
|
-
const
|
|
313
|
-
|
|
312
|
+
const v = t.actions.loadFormValues();
|
|
313
|
+
t.actions.setFormState(v);
|
|
314
314
|
} else
|
|
315
|
-
|
|
315
|
+
R(b);
|
|
316
316
|
},
|
|
317
317
|
onChange: () => {
|
|
318
|
-
const b =
|
|
319
|
-
|
|
318
|
+
const b = t.actions.loadFormValues();
|
|
319
|
+
t.actions.setFormState(b);
|
|
320
320
|
},
|
|
321
321
|
onReset: (b) => {
|
|
322
|
-
|
|
322
|
+
t && (b.preventDefault(), t.actions.reset());
|
|
323
323
|
},
|
|
324
|
-
...
|
|
325
|
-
children:
|
|
324
|
+
...S,
|
|
325
|
+
children: u
|
|
326
326
|
},
|
|
327
|
-
|
|
328
|
-
) })), Se = ({ name: o, render:
|
|
329
|
-
const a =
|
|
330
|
-
(
|
|
331
|
-
|
|
327
|
+
t == null ? void 0 : t.lastReloadedAt
|
|
328
|
+
) })), Se = ({ name: o, render: t = ({ ref: a, name: l, defaultValue: u, value: i, setValue: R }) => null }) => {
|
|
329
|
+
const a = O(), l = me(), u = l.actions.getDefaultValues()[o], [i, R] = N(u), d = m(
|
|
330
|
+
(E, { shouldDirty: _ = !0 } = {}) => {
|
|
331
|
+
l.actions.setFormState((S) => ({ ...S, [o]: E }), { shouldDirty: _ }), R(E);
|
|
332
332
|
},
|
|
333
|
-
[
|
|
333
|
+
[R, l.actions.setFormState]
|
|
334
334
|
);
|
|
335
|
-
return
|
|
336
|
-
|
|
337
|
-
}), []),
|
|
338
|
-
}, Re = (o,
|
|
335
|
+
return oe(() => l.subscribe(o, (_, { shouldDirty: S = !0, shouldOnChange: b = !0 } = {}) => {
|
|
336
|
+
R(_), l.actions.setFormState((v) => ({ ...v, [o]: _ }), { shouldDirty: S, shouldOnChange: b }), a.current && typeof a.current.dispatchEvent == "function" && b && a.current.dispatchEvent(new Event("change"));
|
|
337
|
+
}), []), t({ ref: a, name: o, defaultValue: u, value: i, setValue: d });
|
|
338
|
+
}, Re = (o, t) => {
|
|
339
339
|
let a = !1;
|
|
340
|
-
return Object.keys(
|
|
341
|
-
if (!(
|
|
342
|
-
const
|
|
343
|
-
(typeof
|
|
340
|
+
return Object.keys(t).forEach((l) => {
|
|
341
|
+
if (!(l in o) || a) return;
|
|
342
|
+
const u = t[l], i = o[l];
|
|
343
|
+
(typeof u == "object" || u !== i) && (a = !0);
|
|
344
344
|
}), a;
|
|
345
|
-
},
|
|
346
|
-
const [o,
|
|
347
|
-
|
|
348
|
-
}, []),
|
|
349
|
-
|
|
350
|
-
}, []),
|
|
351
|
-
|
|
352
|
-
}, []),
|
|
353
|
-
|
|
345
|
+
}, ne = (o) => (typeof o.setCustomValidity == "function" && o.setCustomValidity(""), !o || typeof o.checkValidity != "function" || o.checkValidity() ? null : o.validationMessage), pe = () => {
|
|
346
|
+
const [o, t] = N({}), a = ae(() => Object.values(o).filter(Boolean).length > 0, [o]), l = m((d, E) => {
|
|
347
|
+
t((_) => _[d] === E ? _ : { ..._, [d]: E });
|
|
348
|
+
}, []), u = m((d) => {
|
|
349
|
+
t((E) => ({ ...E, ...d }));
|
|
350
|
+
}, []), i = m((d) => {
|
|
351
|
+
t((E) => E[d] ? { ...E, [d]: "" } : E);
|
|
352
|
+
}, []), R = m(() => {
|
|
353
|
+
t({});
|
|
354
354
|
}, []);
|
|
355
|
-
return { isError: a, errors: o, changeError:
|
|
355
|
+
return { isError: a, errors: o, changeError: l, changeErrors: u, clearError: i, clearErrors: R };
|
|
356
356
|
}, _e = () => {
|
|
357
|
-
const [o,
|
|
357
|
+
const [o, t] = N(), a = m(() => t((/* @__PURE__ */ new Date()).toString()), []);
|
|
358
358
|
return [o, a];
|
|
359
359
|
}, ve = () => {
|
|
360
|
-
const [, o] =
|
|
361
|
-
return
|
|
362
|
-
}, ge = [], ke = ({ numberFields: o = ge, defaultValues:
|
|
363
|
-
const { changeError: a, errors:
|
|
364
|
-
}),
|
|
365
|
-
(
|
|
366
|
-
let
|
|
367
|
-
typeof
|
|
368
|
-
g.current[
|
|
369
|
-
}), g.current =
|
|
370
|
-
let
|
|
371
|
-
|
|
360
|
+
const [, o] = N({});
|
|
361
|
+
return m(() => o({}), []);
|
|
362
|
+
}, ge = [], ke = ({ numberFields: o = ge, defaultValues: t = {} } = {}) => {
|
|
363
|
+
const { changeError: a, errors: l, changeErrors: u, clearError: i, clearErrors: R, isError: d } = pe(), [E, _] = N(!1), [S, b] = _e(), [v, V] = N(!1), X = ve(), A = O(/* @__PURE__ */ new Set()), g = O(t), k = O(t), D = O({}), Y = O(() => {
|
|
364
|
+
}), y = O(), W = m(
|
|
365
|
+
(n, { shouldDirty: f = !0, shouldOnChange: e = !0 } = {}) => {
|
|
366
|
+
let r = n;
|
|
367
|
+
typeof n == "function" && (r = n(g.current)), [...A.current].forEach((T) => {
|
|
368
|
+
g.current[T] !== r[T] && X();
|
|
369
|
+
}), g.current = r;
|
|
370
|
+
let c = E;
|
|
371
|
+
f && (console.log(c, g.current.password, k.current.password), c = Re(g.current, k.current), c !== E && _(c)), e && Y.current(g.current);
|
|
372
372
|
},
|
|
373
|
-
[
|
|
374
|
-
),
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const m = t[i];
|
|
379
|
-
m(k.current[i], { shouldDirty: !1, shouldOnChange: !1 });
|
|
380
|
-
}), w.current && w.current.reset(), b();
|
|
381
|
-
}, [E]), B = p((t, i) => {
|
|
382
|
-
const m = F.current;
|
|
383
|
-
return m[t] = i, () => {
|
|
384
|
-
delete m[t], delete g.current[t], delete k.current[t];
|
|
373
|
+
[E]
|
|
374
|
+
), B = m((n, f) => {
|
|
375
|
+
const e = D.current;
|
|
376
|
+
return e[n] = f, () => {
|
|
377
|
+
delete e[n], delete g.current[n], delete k.current[n];
|
|
385
378
|
};
|
|
386
|
-
}, []),
|
|
387
|
-
})),
|
|
388
|
-
setTimeout(() =>
|
|
389
|
-
}, []),
|
|
390
|
-
(
|
|
391
|
-
const
|
|
392
|
-
|
|
379
|
+
}, []), U = m((n) => (Y.current = n, () => Y.current = () => {
|
|
380
|
+
})), I = m(() => V(!1), []), q = m((n) => ne(n.target), []), j = m((n) => n ? g.current[n] : g.current, []), x = m(() => k.current, []), w = m(() => {
|
|
381
|
+
setTimeout(() => y.current.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
382
|
+
}, []), J = m(
|
|
383
|
+
(n) => {
|
|
384
|
+
const f = ne(n.target);
|
|
385
|
+
f ? a(n.target.name, f) : a(n.target.name, null);
|
|
393
386
|
},
|
|
394
387
|
[a]
|
|
395
|
-
),
|
|
396
|
-
(
|
|
397
|
-
const
|
|
398
|
-
switch (typeof
|
|
388
|
+
), F = m(
|
|
389
|
+
(n, f, { shouldDirty: e = !0, shouldOnChange: r = !0 } = {}) => {
|
|
390
|
+
const s = D.current;
|
|
391
|
+
switch (typeof n) {
|
|
399
392
|
case "string":
|
|
400
393
|
{
|
|
401
|
-
const
|
|
402
|
-
if (!
|
|
403
|
-
throw new Error(`${
|
|
404
|
-
|
|
394
|
+
const c = s[n];
|
|
395
|
+
if (!c)
|
|
396
|
+
throw new Error(`${n} is uncontrolled, please use Controller for it!`);
|
|
397
|
+
c(f, { shouldDirty: e, shouldOnChange: r }), r && w();
|
|
405
398
|
}
|
|
406
399
|
break;
|
|
407
400
|
case "object":
|
|
408
|
-
Object.entries(
|
|
409
|
-
const
|
|
410
|
-
if (!
|
|
411
|
-
throw new Error(`${
|
|
412
|
-
|
|
413
|
-
}),
|
|
401
|
+
Object.entries(n).forEach(([c, T]) => {
|
|
402
|
+
const h = s[c];
|
|
403
|
+
if (!h)
|
|
404
|
+
throw new Error(`${c} is uncontrolled, please use Controller for it!`);
|
|
405
|
+
h(T, { shouldDirty: e, shouldOnChange: r });
|
|
406
|
+
}), r && w();
|
|
414
407
|
default:
|
|
415
408
|
return;
|
|
416
409
|
}
|
|
417
410
|
},
|
|
418
|
-
[
|
|
419
|
-
),
|
|
420
|
-
const
|
|
421
|
-
return Object.keys(
|
|
422
|
-
|
|
423
|
-
}), o.forEach((
|
|
424
|
-
}, []),
|
|
411
|
+
[w]
|
|
412
|
+
), P = m(() => {
|
|
413
|
+
const n = Object.fromEntries(new FormData(y.current)), f = D.current;
|
|
414
|
+
return Object.keys(f).map((e) => {
|
|
415
|
+
n[e] = g.current[e];
|
|
416
|
+
}), o.forEach((e) => n.hasOwnProperty(e) && (n[e] = +n[e])), n;
|
|
417
|
+
}, []), $ = (n) => (A.current.add(n), n === "data" ? j() : j()[n]), z = ae(
|
|
425
418
|
() => ({
|
|
426
|
-
setValue:
|
|
427
|
-
instantChange:
|
|
428
|
-
getDefaultValues:
|
|
429
|
-
getFormState:
|
|
419
|
+
setValue: F,
|
|
420
|
+
instantChange: w,
|
|
421
|
+
getDefaultValues: x,
|
|
422
|
+
getFormState: j,
|
|
430
423
|
setFormState: W,
|
|
431
424
|
changeError: a,
|
|
432
|
-
changeErrors:
|
|
433
|
-
clearError:
|
|
434
|
-
clearErrors:
|
|
435
|
-
loadFormValues:
|
|
436
|
-
checkValidity:
|
|
437
|
-
getFieldValidity:
|
|
438
|
-
registerOnchange:
|
|
425
|
+
changeErrors: u,
|
|
426
|
+
clearError: i,
|
|
427
|
+
clearErrors: R,
|
|
428
|
+
loadFormValues: P,
|
|
429
|
+
checkValidity: J,
|
|
430
|
+
getFieldValidity: q,
|
|
431
|
+
registerOnchange: U,
|
|
439
432
|
reload: b,
|
|
440
|
-
reset:
|
|
441
|
-
watch:
|
|
433
|
+
reset: I,
|
|
434
|
+
watch: $
|
|
442
435
|
}),
|
|
443
436
|
[
|
|
444
|
-
|
|
437
|
+
F,
|
|
438
|
+
w,
|
|
439
|
+
x,
|
|
445
440
|
j,
|
|
446
|
-
z,
|
|
447
|
-
A,
|
|
448
441
|
W,
|
|
449
442
|
a,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
I,
|
|
453
|
-
J,
|
|
443
|
+
u,
|
|
444
|
+
i,
|
|
454
445
|
P,
|
|
455
446
|
q,
|
|
456
|
-
|
|
447
|
+
J,
|
|
457
448
|
U,
|
|
458
|
-
|
|
449
|
+
b,
|
|
450
|
+
I,
|
|
451
|
+
$
|
|
459
452
|
]
|
|
460
453
|
);
|
|
461
|
-
return
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
|
|
454
|
+
return fe(() => {
|
|
455
|
+
if (!v)
|
|
456
|
+
k.current = { ...t }, g.current = { ...t }, _(!1), R(), V(!0);
|
|
457
|
+
else if ([...y.current.querySelectorAll("[name]")].forEach((f) => {
|
|
458
|
+
!f.defaultValue && t[f.name] && (f.defaultValue = t[f.name]);
|
|
459
|
+
}), y.current) {
|
|
460
|
+
const f = P();
|
|
461
|
+
k.current = f, g.current = f;
|
|
465
462
|
}
|
|
466
|
-
|
|
467
|
-
k.current = n, g.current = n, _(!1), E();
|
|
468
|
-
};
|
|
469
|
-
}, [T]), K(() => {
|
|
470
|
-
w.current && [...w.current.querySelectorAll("[name]")].forEach((i) => {
|
|
471
|
-
!i.defaultValue && n[i.name] && (i.defaultValue = n[i.name]);
|
|
472
|
-
});
|
|
473
|
-
}, [T]), { ref: w, lastReloadedAt: T, isDirty: d, isError: f, errors: u, numberFields: o, subscribe: B, actions: G };
|
|
463
|
+
}, [v]), { ready: v, ref: y, isDirty: E, isError: d, errors: l, numberFields: o, subscribe: B, actions: z };
|
|
474
464
|
};
|
|
475
465
|
export {
|
|
476
466
|
Se as Controller,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(S,
|
|
1
|
+
(function(S,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],r):(S=typeof globalThis<"u"?globalThis:S||self,r(S.Name={},S.React))})(this,function(S,r){"use strict";var W={exports:{}},N={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var q;function
|
|
9
|
+
*/var q;function se(){if(q)return N;q=1;var s=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(i,l,f){var R=null;if(f!==void 0&&(R=""+f),l.key!==void 0&&(R=""+l.key),"key"in l){f={};for(var b in l)b!=="key"&&(f[b]=l[b])}else f=l;return l=f.ref,{$$typeof:s,type:i,key:R,ref:l!==void 0?l:null,props:f}}return N.Fragment=n,N.jsx=o,N.jsxs=o,N}var V={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var $;function
|
|
17
|
+
*/var $;function oe(){return $||($=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case y:return"Profiler";case T:return"StrictMode";case U:return"Suspense";case H:return"SuspenseList";case z:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case B:return"Portal";case I:return(e.displayName||"Context")+".Provider";case Y:return(e._context.displayName||"Context")+".Consumer";case C:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J:return t=e.displayName||null,t!==null?t:s(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return s(e(t))}catch{}}return null}function n(e){return""+e}function o(e){try{n(e);var t=!1}catch{t=!0}if(t){t=console;var c=t.error,u=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",u),n(e)}}function i(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===M)return"<...>";try{var t=s(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function l(){var e=A.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function R(e){if(w.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function b(e,t){function c(){P||(P=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function E(){var e=s(this.type);return L[e]||(L[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function p(e,t,c,u,_,g,Z,Q){return c=g.ref,e={$$typeof:D,type:e,key:t,props:g,_owner:_},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:E}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function h(e,t,c,u,_,g,Z,Q){var k=t.children;if(k!==void 0)if(u)if(G(k)){for(u=0;u<k.length;u++)m(k[u]);Object.freeze&&Object.freeze(k)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(k);if(w.call(t,"key")){k=s(e);var x=Object.keys(t).filter(function(Re){return Re!=="key"});u=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",d[k+u]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,k,
|
|
22
|
+
<%s key={someKey} {...props} />`,u,k,x,k),d[k+u]=!0)}if(k=null,c!==void 0&&(o(c),k=""+c),R(t)&&(o(t.key),k=""+t.key),"key"in t){c={};for(var K in t)K!=="key"&&(c[K]=t[K])}else c=t;return k&&b(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),p(e,k,g,_,l(),c,Z,Q)}function m(e){typeof e=="object"&&e!==null&&e.$$typeof===D&&e._store&&(e._store.validated=1)}var v=r,D=Symbol.for("react.transitional.element"),B=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),I=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),z=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),A=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,w=Object.prototype.hasOwnProperty,G=Array.isArray,F=console.createTask?console.createTask:function(){return null};v={"react-stack-bottom-frame":function(e){return e()}};var P,L={},X=v["react-stack-bottom-frame"].bind(v,f)(),a=F(i(f)),d={};V.Fragment=O,V.jsx=function(e,t,c,u,_){var g=1e4>A.recentlyCreatedOwnerStacks++;return h(e,t,c,!1,u,_,g?Error("react-stack-top-frame"):X,g?F(i(e)):a)},V.jsxs=function(e,t,c,u,_){var g=1e4>A.recentlyCreatedOwnerStacks++;return h(e,t,c,!0,u,_,g?Error("react-stack-top-frame"):X,g?F(i(e)):a)}}()),V}var ee;function ce(){return ee||(ee=1,process.env.NODE_ENV==="production"?W.exports=se():W.exports=oe()),W.exports}var te=ce();const re=r.createContext({}),ue=()=>r.useContext(re),le=({id:s,form:n,method:o,action:i,children:l,onSubmit:f=()=>{},onInput:R=()=>{},onChange:b=()=>{},numberFields:E=[],className:p,...h})=>(r.useEffect(()=>n.actions.registerOnchange(b),[b]),te.jsx(re.Provider,{value:n,children:n.ready&&te.jsx("form",{id:s,ref:n==null?void 0:n.ref,action:i,method:o,className:p,onSubmit:m=>{o||m.preventDefault();const v=n.actions.loadFormValues();f(v)},onInput:m=>{if(m.target.tagName==="FORM"){const v=n.actions.loadFormValues();n.actions.setFormState(v)}else R(m)},onChange:()=>{const m=n.actions.loadFormValues();n.actions.setFormState(m)},onReset:m=>{n&&(m.preventDefault(),n.actions.reset())},...h,children:l},n==null?void 0:n.lastReloadedAt)})),ie=({name:s,render:n=({ref:o,name:i,defaultValue:l,value:f,setValue:R})=>null})=>{const o=r.useRef(),i=ue(),l=i.actions.getDefaultValues()[s],[f,R]=r.useState(l),b=r.useCallback((E,{shouldDirty:p=!0}={})=>{i.actions.setFormState(h=>({...h,[s]:E}),{shouldDirty:p}),R(E)},[R,i.actions.setFormState]);return r.useEffect(()=>i.subscribe(s,(p,{shouldDirty:h=!0,shouldOnChange:m=!0}={})=>{R(p),i.actions.setFormState(v=>({...v,[s]:p}),{shouldDirty:h,shouldOnChange:m}),o.current&&typeof o.current.dispatchEvent=="function"&&m&&o.current.dispatchEvent(new Event("change"))}),[]),n({ref:o,name:s,defaultValue:l,value:f,setValue:b})},fe=(s,n)=>{let o=!1;return Object.keys(n).forEach(i=>{if(!(i in s)||o)return;const l=n[i],f=s[i];(typeof l=="object"||l!==f)&&(o=!0)}),o},ne=s=>(typeof s.setCustomValidity=="function"&&s.setCustomValidity(""),!s||typeof s.checkValidity!="function"||s.checkValidity()?null:s.validationMessage),ae=()=>{const[s,n]=r.useState({}),o=r.useMemo(()=>Object.values(s).filter(Boolean).length>0,[s]),i=r.useCallback((b,E)=>{n(p=>p[b]===E?p:{...p,[b]:E})},[]),l=r.useCallback(b=>{n(E=>({...E,...b}))},[]),f=r.useCallback(b=>{n(E=>E[b]?{...E,[b]:""}:E)},[]),R=r.useCallback(()=>{n({})},[]);return{isError:o,errors:s,changeError:i,changeErrors:l,clearError:f,clearErrors:R}},de=()=>{const[s,n]=r.useState(),o=r.useCallback(()=>n(new Date().toString()),[]);return[s,o]},be=()=>{const[,s]=r.useState({});return r.useCallback(()=>s({}),[])},Ee=[],me=({numberFields:s=Ee,defaultValues:n={}}={})=>{const{changeError:o,errors:i,changeErrors:l,clearError:f,clearErrors:R,isError:b}=ae(),[E,p]=r.useState(!1),[h,m]=de(),[v,D]=r.useState(!1),B=be(),O=r.useRef(new Set),T=r.useRef(n),y=r.useRef(n),Y=r.useRef({}),I=r.useRef(()=>{}),C=r.useRef(),U=r.useCallback((a,{shouldDirty:d=!0,shouldOnChange:e=!0}={})=>{let t=a;typeof a=="function"&&(t=a(T.current)),[...O.current].forEach(_=>{T.current[_]!==t[_]&&B()}),T.current=t;let u=E;d&&(console.log(u,T.current.password,y.current.password),u=fe(T.current,y.current),u!==E&&p(u)),e&&I.current(T.current)},[E]),H=r.useCallback((a,d)=>{const e=Y.current;return e[a]=d,()=>{delete e[a],delete T.current[a],delete y.current[a]}},[]),J=r.useCallback(a=>(I.current=a,()=>I.current=()=>{})),M=r.useCallback(()=>D(!1),[]),z=r.useCallback(a=>ne(a.target),[]),j=r.useCallback(a=>a?T.current[a]:T.current,[]),A=r.useCallback(()=>y.current,[]),w=r.useCallback(()=>{setTimeout(()=>C.current.dispatchEvent(new Event("input",{bubbles:!0})))},[]),G=r.useCallback(a=>{const d=ne(a.target);d?o(a.target.name,d):o(a.target.name,null)},[o]),F=r.useCallback((a,d,{shouldDirty:e=!0,shouldOnChange:t=!0}={})=>{const c=Y.current;switch(typeof a){case"string":{const u=c[a];if(!u)throw new Error(`${a} is uncontrolled, please use Controller for it!`);u(d,{shouldDirty:e,shouldOnChange:t}),t&&w()}break;case"object":Object.entries(a).forEach(([u,_])=>{const g=c[u];if(!g)throw new Error(`${u} is uncontrolled, please use Controller for it!`);g(_,{shouldDirty:e,shouldOnChange:t})}),t&&w();default:return}},[w]),P=r.useCallback(()=>{const a=Object.fromEntries(new FormData(C.current)),d=Y.current;return Object.keys(d).map(e=>{a[e]=T.current[e]}),s.forEach(e=>a.hasOwnProperty(e)&&(a[e]=+a[e])),a},[]),L=a=>(O.current.add(a),a==="data"?j():j()[a]),X=r.useMemo(()=>({setValue:F,instantChange:w,getDefaultValues:A,getFormState:j,setFormState:U,changeError:o,changeErrors:l,clearError:f,clearErrors:R,loadFormValues:P,checkValidity:G,getFieldValidity:z,registerOnchange:J,reload:m,reset:M,watch:L}),[F,w,A,j,U,o,l,f,P,z,G,J,m,M,L]);return r.useLayoutEffect(()=>{if(!v)y.current={...n},T.current={...n},p(!1),R(),D(!0);else if([...C.current.querySelectorAll("[name]")].forEach(d=>{!d.defaultValue&&n[d.name]&&(d.defaultValue=n[d.name])}),C.current){const d=P();y.current=d,T.current=d}},[v]),{ready:v,ref:C,isDirty:E,isError:b,errors:i,numberFields:s,subscribe:H,actions:X}};S.Controller=ie,S.Form=le,S.useForm=me,S.useValidateForm=ae,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|