react-simple-formkit 1.1.11 → 1.1.12
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react");var z={exports:{}},
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react");var z={exports:{}},D={};/**
|
|
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 oe(){if(Z)return
|
|
9
|
+
*/var Z;function oe(){if(Z)return D;Z=1;var o=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function f(b,u,s){var R=null;if(s!==void 0&&(R=""+s),u.key!==void 0&&(R=""+u.key),"key"in u){s={};for(var l in u)l!=="key"&&(s[l]=u[l])}else s=u;return u=s.ref,{$$typeof:o,type:b,key:R,ref:u!==void 0?u:null,props:s}}return D.Fragment=r,D.jsx=f,D.jsxs=f,D}var Y={};/**
|
|
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 se(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function o(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===
|
|
17
|
+
*/var Q;function se(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function o(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===F?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case g:return"Fragment";case $:return"Profiler";case I:return"StrictMode";case W:return"Suspense";case U:return"SuspenseList";case q: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 P:return"Portal";case M:return(e.displayName||"Context")+".Provider";case G:return(e._context.displayName||"Context")+".Consumer";case L:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case w:return n=e.displayName||null,n!==null?n:o(e.type)||"Memo";case x:n=e._payload,e=e._init;try{return o(e(n))}catch{}}return null}function r(e){return""+e}function f(e){try{r(e);var n=!1}catch{n=!0}if(n){n=console;var i=n.error,v=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",v),r(e)}}function b(e){if(e===g)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===x)return"<...>";try{var n=o(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function u(){var e=N.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function R(e){if(t.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function l(e,n){function i(){S||(S=!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)",n))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function E(){var e=o(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 k(e,n,i,v,j,h,X,B){return i=h.ref,e={$$typeof:C,type:e,key:n,props:h,_owner:j},(i!==void 0?i: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,n,i,v,j,h,X,B){var _=n.children;if(_!==void 0)if(v)if(p(_)){for(v=0;v<_.length;v++)c(_[v]);Object.freeze&&Object.freeze(_)}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 c(_);if(t.call(n,"key")){_=o(e);var A=Object.keys(n).filter(function(ae){return ae!=="key"});v=0<A.length?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}",V[_+v]||(A=0<A.length?"{"+A.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} />`,_,
|
|
22
|
+
<%s key={someKey} {...props} />`,v,_,A,_),V[_+v]=!0)}if(_=null,i!==void 0&&(f(i),_=""+i),R(n)&&(f(n.key),_=""+n.key),"key"in n){i={};for(var H in n)H!=="key"&&(i[H]=n[H])}else i=n;return _&&l(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),k(e,_,h,j,u(),i,X,B)}function c(e){typeof e=="object"&&e!==null&&e.$$typeof===C&&e._store&&(e._store.validated=1)}var m=a,C=Symbol.for("react.transitional.element"),P=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),M=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),N=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,t=Object.prototype.hasOwnProperty,p=Array.isArray,d=console.createTask?console.createTask:function(){return null};m={"react-stack-bottom-frame":function(e){return e()}};var S,y={},O=m["react-stack-bottom-frame"].bind(m,s)(),J=d(b(s)),V={};Y.Fragment=g,Y.jsx=function(e,n,i,v,j){var h=1e4>N.recentlyCreatedOwnerStacks++;return T(e,n,i,!1,v,j,h?Error("react-stack-top-frame"):O,h?d(b(e)):J)},Y.jsxs=function(e,n,i,v,j){var h=1e4>N.recentlyCreatedOwnerStacks++;return T(e,n,i,!0,v,j,h?Error("react-stack-top-frame"):O,h?d(b(e)):J)}}()),Y}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?z.exports=oe():z.exports=se()),z.exports}var ee=ce();const te=a.createContext({}),ue=()=>a.useContext(te),le=({id:o,form:r,method:f,action:b,children:u,onSubmit:s=()=>{},onInput:R=()=>{},onChange:l=()=>{},numberFields:E=[],className:k,...T})=>(a.useEffect(()=>r.actions.registerOnchange(l),[l]),ee.jsx(te.Provider,{value:r,children:ee.jsx("form",{ref:r==null?void 0:r.ref,action:b,className:k,onSubmit:c=>{f||c.preventDefault();const m=r.actions.loadFormValues();s(m)},onInput:c=>{if(c.target.tagName==="FORM"){const m=r.actions.loadFormValues();r.actions.setFormState(m)}else R(c)},onChange:()=>{const c=r.actions.loadFormValues();r.actions.setFormState(c)},onReset:c=>{r&&(c.preventDefault(),r.actions.reset())},...T,children:u},r==null?void 0:r.lastReloadedAt)})),ie=({name:o,defaultValue:r,render:f=({ref:b,name:u,defaultValue:s,value:R,setValue:l})=>null})=>{const[b,u]=a.useState(r),s=ue(),R=a.useRef(),l=a.useCallback((E,{shouldDirty:k=!1}={})=>{s.actions.setFormState(T=>({...T,[o]:E}),{shouldDirty:k}),u(E)},[u,s.actions.setFormState]);return a.useEffect(()=>(s.actions.setFormState(k=>({...k,[o]:r}),{shouldDirty:!1}),s.subscribe(o,(k,{shouldDirty:T=!0,shouldOnChange:c=!0}={})=>{u(k),s.actions.setFormState(m=>({...m,[o]:k}),{shouldDirty:T,shouldOnChange:c}),R.current&&typeof R.current.dispatchEvent=="function"&&c&&R.current.dispatchEvent(new Event("change"))})),[]),f({ref:R,name:o,defaultValue:r,value:b,setValue:l})},fe=(o,r)=>{let f=!1;return Object.keys(r).forEach(b=>{if(!(b in o)||f)return;const u=r[b],s=o[b];(typeof u=="object"||u!==s)&&(f=!0)}),f},re=o=>(typeof o.setCustomValidity=="function"&&o.setCustomValidity(""),!o||typeof o.checkValidity!="function"||o.checkValidity()?null:o.validationMessage),ne=()=>{const[o,r]=a.useState({}),f=a.useMemo(()=>Object.values(o).filter(Boolean).length>0,[o]),b=a.useCallback((l,E)=>{r(k=>k[l]===E?k:{...k,[l]:E})},[]),u=a.useCallback(l=>{r(E=>({...E,...l}))},[]),s=a.useCallback(l=>{r(E=>E[l]?{...E,[l]:""}:E)},[]),R=a.useCallback(()=>{r({})},[]);return{isError:f,errors:o,changeError:b,changeErrors:u,clearError:s,clearErrors:R}},de=()=>{const[o,r]=a.useState(),f=a.useCallback(()=>r(new Date().toString()),[]);return[o,f]},be=[],Ee=({numberFields:o=be}={})=>{const{changeError:r,errors:f,changeErrors:b,clearError:u,clearErrors:s,isError:R}=ne(),[l,E]=a.useState(!1),[k,T]=de(),c=a.useRef({}),m=a.useRef({}),C=a.useRef({}),P=a.useRef(()=>{}),g=a.useRef(),I=a.useCallback((t,{shouldDirty:p=!0,shouldOnChange:d=!0}={})=>{let S=t;typeof t=="function"&&(S=t(c.current)),c.current=S;let y=l;p&&(y=fe(c.current,m.current),y!==l&&E(y)),d&&P.current(c.current)},[l]),$=a.useCallback(()=>{E(!1),s();const t=C.current;Object.keys(t).forEach(p=>{const d=t[p];d(m.current[p],{shouldDirty:!1,shouldOnChange:!1})}),g.current&&g.current.reset(),T()},[s]),G=a.useCallback((t,p)=>{const d=C.current;return d[t]=p,()=>{delete d[t],delete c.current[t],delete m.current[t],console.log(C,c,m)}},[]),M=a.useCallback(t=>(P.current=t,()=>P.current=()=>{})),L=a.useCallback(t=>re(t.target),[]),W=a.useCallback(t=>t?c.current[t]:c.current,[]),U=a.useCallback(()=>m.current,[]),w=a.useCallback(()=>{setTimeout(()=>g.current.dispatchEvent(new Event("input",{bubbles:!0})))},[]),x=a.useCallback(t=>{const p=re(t.target);p?r(t.target.name,p):r(t.target.name,null)},[r]),q=a.useCallback((t,p,{shouldDirty:d=!0,shouldOnChange:S=!0}={})=>{const y=C.current;switch(typeof t){case"string":{const O=y[t];if(!O)throw new Error(`${t} is uncontrolled, please use Controller for it!`);O(p,{shouldDirty:d,shouldOnChange:S}),S&&w()}break;case"object":Object.entries(t).forEach(([O,J])=>{const V=y[O];if(!V)throw new Error(`${O} is uncontrolled, please use Controller for it!`);V(J,{shouldDirty:d,shouldOnChange:S})}),S&&w();default:return}},[w]),F=a.useCallback(()=>{const t=Object.fromEntries(new FormData(g.current)),p=C.current;return Object.keys(p).map(d=>{t[d]=c.current[d]}),o.forEach(d=>t.hasOwnProperty(d)&&(t[d]=+t[d])),t},[]),N=a.useMemo(()=>({setValue:q,instantChange:w,getDefaultValues:U,getFormState:W,setFormState:I,changeError:r,changeErrors:b,clearError:u,clearErrors:s,loadFormValues:F,checkValidity:x,getFieldValidity:L,registerOnchange:M,reload:T,reset:$}),[q,w,U,W,I,r,b,u,F,L,x,M,T,$]);return a.useEffect(()=>{if(g.current){const t=F();console.log(t),m.current=t,c.current=t}return()=>{m.current={},c.current={},E(!1),s()}},[k]),{ref:g,lastReloadedAt:k,isDirty:l,isError:R,errors:f,numberFields:o,subscribe:G,actions:N}};exports.Controller=ie;exports.Form=le;exports.useForm=Ee;exports.useValidateForm=ne;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import ue, { createContext as le, useContext as ie, useEffect as K, useState as X, useRef as P, useCallback as
|
|
1
|
+
import ue, { createContext as le, useContext as ie, useEffect as K, useState as X, useRef as P, useCallback as p, useMemo as ae } from "react";
|
|
2
2
|
var G = { exports: {} }, Y = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -14,18 +14,18 @@ function fe() {
|
|
|
14
14
|
if (ee) return Y;
|
|
15
15
|
ee = 1;
|
|
16
16
|
var o = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
17
|
-
function i(
|
|
18
|
-
var
|
|
19
|
-
if (a !== void 0 && (
|
|
17
|
+
function i(d, c, a) {
|
|
18
|
+
var m = null;
|
|
19
|
+
if (a !== void 0 && (m = "" + a), c.key !== void 0 && (m = "" + c.key), "key" in c) {
|
|
20
20
|
a = {};
|
|
21
|
-
for (var u in
|
|
22
|
-
u !== "key" && (a[u] =
|
|
23
|
-
} else a =
|
|
24
|
-
return
|
|
21
|
+
for (var u in c)
|
|
22
|
+
u !== "key" && (a[u] = c[u]);
|
|
23
|
+
} else a = c;
|
|
24
|
+
return c = a.ref, {
|
|
25
25
|
$$typeof: o,
|
|
26
|
-
type:
|
|
27
|
-
key:
|
|
28
|
-
ref:
|
|
26
|
+
type: d,
|
|
27
|
+
key: m,
|
|
28
|
+
ref: c !== void 0 ? c : null,
|
|
29
29
|
props: a
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -74,14 +74,14 @@ function de() {
|
|
|
74
74
|
case B:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
76
|
case W:
|
|
77
|
-
var
|
|
78
|
-
return e = e.displayName, e || (e =
|
|
77
|
+
var n = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
79
|
case A:
|
|
80
|
-
return
|
|
80
|
+
return n = e.displayName || null, n !== null ? n : o(e.type) || "Memo";
|
|
81
81
|
case C:
|
|
82
|
-
|
|
82
|
+
n = e._payload, e = e._init;
|
|
83
83
|
try {
|
|
84
|
-
return o(e(
|
|
84
|
+
return o(e(n));
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -93,50 +93,50 @@ function de() {
|
|
|
93
93
|
function i(e) {
|
|
94
94
|
try {
|
|
95
95
|
r(e);
|
|
96
|
-
var
|
|
96
|
+
var n = !1;
|
|
97
97
|
} catch {
|
|
98
|
-
|
|
98
|
+
n = !0;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
var l =
|
|
100
|
+
if (n) {
|
|
101
|
+
n = console;
|
|
102
|
+
var l = n.error, _ = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
103
|
return l.call(
|
|
104
|
-
|
|
104
|
+
n,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
|
|
106
|
+
_
|
|
107
107
|
), r(e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function d(e) {
|
|
111
111
|
if (e === h) return "<>";
|
|
112
112
|
if (typeof e == "object" && e !== null && e.$$typeof === C)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
|
-
var
|
|
116
|
-
return
|
|
115
|
+
var n = o(e);
|
|
116
|
+
return n ? "<" + n + ">" : "<...>";
|
|
117
117
|
} catch {
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function c() {
|
|
122
122
|
var e = D.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
125
|
function a() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
128
|
+
function m(e) {
|
|
129
|
+
if (t.call(e, "key")) {
|
|
130
|
+
var n = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (n && n.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function u(e,
|
|
135
|
+
function u(e, n) {
|
|
136
136
|
function l() {
|
|
137
137
|
k || (k = !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
|
+
n
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
142
|
l.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
@@ -144,22 +144,22 @@ function de() {
|
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function E() {
|
|
148
148
|
var e = o(this.type);
|
|
149
149
|
return y[e] || (y[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
|
|
153
|
+
function R(e, n, l, _, w, S, H, Z) {
|
|
154
154
|
return l = S.ref, e = {
|
|
155
|
-
$$typeof:
|
|
155
|
+
$$typeof: O,
|
|
156
156
|
type: e,
|
|
157
|
-
key:
|
|
157
|
+
key: n,
|
|
158
158
|
props: S,
|
|
159
|
-
_owner:
|
|
159
|
+
_owner: w
|
|
160
160
|
}, (l !== void 0 ? l : 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,94 +182,94 @@ function de() {
|
|
|
182
182
|
value: Z
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function g(e,
|
|
186
|
-
var v =
|
|
185
|
+
function g(e, n, l, _, w, S, H, Z) {
|
|
186
|
+
var v = n.children;
|
|
187
187
|
if (v !== void 0)
|
|
188
|
-
if (
|
|
188
|
+
if (_)
|
|
189
189
|
if (T(v)) {
|
|
190
|
-
for (
|
|
191
|
-
|
|
190
|
+
for (_ = 0; _ < v.length; _++)
|
|
191
|
+
s(v[_]);
|
|
192
192
|
Object.freeze && Object.freeze(v);
|
|
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
|
|
198
|
-
if (
|
|
197
|
+
else s(v);
|
|
198
|
+
if (t.call(n, "key")) {
|
|
199
199
|
v = o(e);
|
|
200
|
-
var x = Object.keys(
|
|
200
|
+
var x = Object.keys(n).filter(function(ce) {
|
|
201
201
|
return ce !== "key";
|
|
202
202
|
});
|
|
203
|
-
|
|
203
|
+
_ = 0 < x.length ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}", V[v + _] || (x = 0 < x.length ? "{" + x.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
|
-
|
|
210
|
+
_,
|
|
211
211
|
v,
|
|
212
212
|
x,
|
|
213
213
|
v
|
|
214
|
-
), V[v +
|
|
214
|
+
), V[v + _] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (v = null, l !== void 0 && (i(l), v = "" + l),
|
|
216
|
+
if (v = null, l !== void 0 && (i(l), v = "" + l), m(n) && (i(n.key), v = "" + n.key), "key" in n) {
|
|
217
217
|
l = {};
|
|
218
|
-
for (var Q in
|
|
219
|
-
Q !== "key" && (l[Q] =
|
|
220
|
-
} else l =
|
|
218
|
+
for (var Q in n)
|
|
219
|
+
Q !== "key" && (l[Q] = n[Q]);
|
|
220
|
+
} else l = n;
|
|
221
221
|
return v && u(
|
|
222
222
|
l,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
-
),
|
|
224
|
+
), R(
|
|
225
225
|
e,
|
|
226
226
|
v,
|
|
227
227
|
S,
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
w,
|
|
229
|
+
c(),
|
|
230
230
|
l,
|
|
231
231
|
H,
|
|
232
232
|
Z
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
235
|
+
function s(e) {
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === O && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
238
|
+
var b = ue, O = Symbol.for("react.transitional.element"), F = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), M = Symbol.for("react.profiler"), B = Symbol.for("react.consumer"), L = Symbol.for("react.context"), W = Symbol.for("react.forward_ref"), U = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), A = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), J = Symbol.for("react.activity"), N = Symbol.for("react.client.reference"), D = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, t = Object.prototype.hasOwnProperty, T = Array.isArray, f = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
|
-
|
|
241
|
+
b = {
|
|
242
242
|
"react-stack-bottom-frame": function(e) {
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var k, y = {},
|
|
247
|
-
|
|
246
|
+
var k, y = {}, j = b["react-stack-bottom-frame"].bind(
|
|
247
|
+
b,
|
|
248
248
|
a
|
|
249
|
-
)(), z =
|
|
250
|
-
I.Fragment = h, I.jsx = function(e,
|
|
249
|
+
)(), z = f(d(a)), V = {};
|
|
250
|
+
I.Fragment = h, I.jsx = function(e, n, l, _, w) {
|
|
251
251
|
var S = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return g(
|
|
253
253
|
e,
|
|
254
|
-
|
|
254
|
+
n,
|
|
255
255
|
l,
|
|
256
256
|
!1,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
S ? Error("react-stack-top-frame") :
|
|
260
|
-
S ?
|
|
257
|
+
_,
|
|
258
|
+
w,
|
|
259
|
+
S ? Error("react-stack-top-frame") : j,
|
|
260
|
+
S ? f(d(e)) : z
|
|
261
261
|
);
|
|
262
|
-
}, I.jsxs = function(e,
|
|
262
|
+
}, I.jsxs = function(e, n, l, _, w) {
|
|
263
263
|
var S = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return g(
|
|
265
265
|
e,
|
|
266
|
-
|
|
266
|
+
n,
|
|
267
267
|
l,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
S ? Error("react-stack-top-frame") :
|
|
272
|
-
S ?
|
|
269
|
+
_,
|
|
270
|
+
w,
|
|
271
|
+
S ? Error("react-stack-top-frame") : j,
|
|
272
|
+
S ? f(d(e)) : z
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}()), I;
|
|
@@ -279,151 +279,141 @@ function Ee() {
|
|
|
279
279
|
return te || (te = 1, process.env.NODE_ENV === "production" ? G.exports = fe() : G.exports = de()), G.exports;
|
|
280
280
|
}
|
|
281
281
|
var ne = Ee();
|
|
282
|
-
const se = le({}),
|
|
282
|
+
const se = le({}), be = () => ie(se), Te = ({
|
|
283
283
|
id: o,
|
|
284
284
|
form: r,
|
|
285
285
|
method: i,
|
|
286
|
-
action:
|
|
287
|
-
children:
|
|
286
|
+
action: d,
|
|
287
|
+
children: c,
|
|
288
288
|
onSubmit: a = () => {
|
|
289
289
|
},
|
|
290
|
-
onInput:
|
|
290
|
+
onInput: m = () => {
|
|
291
291
|
},
|
|
292
292
|
onChange: u = () => {
|
|
293
293
|
},
|
|
294
|
-
numberFields:
|
|
295
|
-
className:
|
|
294
|
+
numberFields: E = [],
|
|
295
|
+
className: R,
|
|
296
296
|
...g
|
|
297
297
|
}) => (K(() => r.actions.registerOnchange(u), [u]), /* @__PURE__ */ ne.jsx(se.Provider, { value: r, children: /* @__PURE__ */ ne.jsx(
|
|
298
298
|
"form",
|
|
299
299
|
{
|
|
300
300
|
ref: r == null ? void 0 : r.ref,
|
|
301
|
-
action:
|
|
302
|
-
className:
|
|
303
|
-
onSubmit: (
|
|
304
|
-
i ||
|
|
305
|
-
const
|
|
306
|
-
a(
|
|
301
|
+
action: d,
|
|
302
|
+
className: R,
|
|
303
|
+
onSubmit: (s) => {
|
|
304
|
+
i || s.preventDefault();
|
|
305
|
+
const b = r.actions.loadFormValues();
|
|
306
|
+
a(b);
|
|
307
307
|
},
|
|
308
|
-
onInput: (
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
r.actions.setFormState(
|
|
308
|
+
onInput: (s) => {
|
|
309
|
+
if (s.target.tagName === "FORM") {
|
|
310
|
+
const b = r.actions.loadFormValues();
|
|
311
|
+
r.actions.setFormState(b);
|
|
312
312
|
} else
|
|
313
|
-
|
|
313
|
+
m(s);
|
|
314
314
|
},
|
|
315
315
|
onChange: () => {
|
|
316
|
-
const
|
|
317
|
-
r.actions.setFormState(
|
|
316
|
+
const s = r.actions.loadFormValues();
|
|
317
|
+
r.actions.setFormState(s);
|
|
318
318
|
},
|
|
319
|
-
onReset: (
|
|
320
|
-
r && (
|
|
319
|
+
onReset: (s) => {
|
|
320
|
+
r && (s.preventDefault(), r.actions.reset());
|
|
321
321
|
},
|
|
322
322
|
...g,
|
|
323
|
-
children:
|
|
323
|
+
children: c
|
|
324
324
|
},
|
|
325
325
|
r == null ? void 0 : r.lastReloadedAt
|
|
326
|
-
) })), ge = ({ name: o, defaultValue: r, render: i = ({ ref:
|
|
327
|
-
const [
|
|
328
|
-
(
|
|
329
|
-
a.actions.setFormState((g) => ({ ...g, [o]:
|
|
326
|
+
) })), ge = ({ name: o, defaultValue: r, render: i = ({ ref: d, name: c, defaultValue: a, value: m, setValue: u }) => null }) => {
|
|
327
|
+
const [d, c] = X(r), a = be(), m = P(), u = p(
|
|
328
|
+
(E, { shouldDirty: R = !1 } = {}) => {
|
|
329
|
+
a.actions.setFormState((g) => ({ ...g, [o]: E }), { shouldDirty: R }), c(E);
|
|
330
330
|
},
|
|
331
|
-
[
|
|
331
|
+
[c, a.actions.setFormState]
|
|
332
332
|
);
|
|
333
|
-
return K(() => {
|
|
334
|
-
a.actions.setFormState((
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
});
|
|
338
|
-
return () => {
|
|
339
|
-
a.actions.setFormState(
|
|
340
|
-
(d) => (delete d[o], d),
|
|
341
|
-
{
|
|
342
|
-
shouldDirty: !1,
|
|
343
|
-
shouldOnChange: !1
|
|
344
|
-
}
|
|
345
|
-
), f();
|
|
346
|
-
};
|
|
347
|
-
}, []), i({ ref: b, name: o, defaultValue: r, value: m, setValue: u });
|
|
348
|
-
}, be = (o, r) => {
|
|
333
|
+
return K(() => (a.actions.setFormState((R) => ({ ...R, [o]: r }), { shouldDirty: !1 }), a.subscribe(o, (R, { shouldDirty: g = !0, shouldOnChange: s = !0 } = {}) => {
|
|
334
|
+
c(R), a.actions.setFormState((b) => ({ ...b, [o]: R }), { shouldDirty: g, shouldOnChange: s }), m.current && typeof m.current.dispatchEvent == "function" && s && m.current.dispatchEvent(new Event("change"));
|
|
335
|
+
})), []), i({ ref: m, name: o, defaultValue: r, value: d, setValue: u });
|
|
336
|
+
}, me = (o, r) => {
|
|
349
337
|
let i = !1;
|
|
350
|
-
return Object.keys(r).forEach((
|
|
351
|
-
if (!(
|
|
352
|
-
const
|
|
353
|
-
(typeof
|
|
338
|
+
return Object.keys(r).forEach((d) => {
|
|
339
|
+
if (!(d in o) || i) return;
|
|
340
|
+
const c = r[d], a = o[d];
|
|
341
|
+
(typeof c == "object" || c !== a) && (i = !0);
|
|
354
342
|
}), i;
|
|
355
343
|
}, oe = (o) => (typeof o.setCustomValidity == "function" && o.setCustomValidity(""), !o || typeof o.checkValidity != "function" || o.checkValidity() ? null : o.validationMessage), Re = () => {
|
|
356
|
-
const [o, r] = X({}), i = ae(() => Object.values(o).filter(Boolean).length > 0, [o]),
|
|
357
|
-
r((
|
|
358
|
-
}, []),
|
|
359
|
-
r((
|
|
360
|
-
}, []), a =
|
|
361
|
-
r((
|
|
362
|
-
}, []),
|
|
344
|
+
const [o, r] = X({}), i = ae(() => Object.values(o).filter(Boolean).length > 0, [o]), d = p((u, E) => {
|
|
345
|
+
r((R) => R[u] === E ? R : { ...R, [u]: E });
|
|
346
|
+
}, []), c = p((u) => {
|
|
347
|
+
r((E) => ({ ...E, ...u }));
|
|
348
|
+
}, []), a = p((u) => {
|
|
349
|
+
r((E) => E[u] ? { ...E, [u]: "" } : E);
|
|
350
|
+
}, []), m = p(() => {
|
|
363
351
|
r({});
|
|
364
352
|
}, []);
|
|
365
|
-
return { isError: i, errors: o, changeError:
|
|
366
|
-
},
|
|
367
|
-
const [o, r] = X(), i =
|
|
353
|
+
return { isError: i, errors: o, changeError: d, changeErrors: c, clearError: a, clearErrors: m };
|
|
354
|
+
}, pe = () => {
|
|
355
|
+
const [o, r] = X(), i = p(() => r((/* @__PURE__ */ new Date()).toString()), []);
|
|
368
356
|
return [o, i];
|
|
369
|
-
},
|
|
370
|
-
const { changeError: r, errors: i, changeErrors:
|
|
371
|
-
}), h = P(), $ =
|
|
372
|
-
(
|
|
373
|
-
let k =
|
|
374
|
-
typeof
|
|
357
|
+
}, _e = [], he = ({ numberFields: o = _e } = {}) => {
|
|
358
|
+
const { changeError: r, errors: i, changeErrors: d, clearError: c, clearErrors: a, isError: m } = Re(), [u, E] = X(!1), [R, g] = pe(), s = P({}), b = P({}), O = P({}), F = P(() => {
|
|
359
|
+
}), h = P(), $ = p(
|
|
360
|
+
(t, { shouldDirty: T = !0, shouldOnChange: f = !0 } = {}) => {
|
|
361
|
+
let k = t;
|
|
362
|
+
typeof t == "function" && (k = t(s.current)), s.current = k;
|
|
375
363
|
let y = u;
|
|
376
|
-
T && (y =
|
|
364
|
+
T && (y = me(s.current, b.current), y !== u && E(y)), f && F.current(s.current);
|
|
377
365
|
},
|
|
378
366
|
[u]
|
|
379
|
-
), M =
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
Object.keys(
|
|
383
|
-
const
|
|
384
|
-
|
|
367
|
+
), M = p(() => {
|
|
368
|
+
E(!1), a();
|
|
369
|
+
const t = O.current;
|
|
370
|
+
Object.keys(t).forEach((T) => {
|
|
371
|
+
const f = t[T];
|
|
372
|
+
f(b.current[T], { shouldDirty: !1, shouldOnChange: !1 });
|
|
385
373
|
}), h.current && h.current.reset(), g();
|
|
386
|
-
}, [a]), B =
|
|
387
|
-
const
|
|
388
|
-
return
|
|
389
|
-
|
|
390
|
-
|
|
374
|
+
}, [a]), B = p((t, T) => {
|
|
375
|
+
const f = O.current;
|
|
376
|
+
return f[t] = T, () => {
|
|
377
|
+
delete f[t], delete s.current[t], delete b.current[t], console.log(O, s, b);
|
|
378
|
+
};
|
|
379
|
+
}, []), L = p((t) => (F.current = t, () => F.current = () => {
|
|
380
|
+
})), W = p((t) => oe(t.target), []), U = p((t) => t ? s.current[t] : s.current, []), q = p(() => b.current, []), A = p(() => {
|
|
391
381
|
setTimeout(() => h.current.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
392
|
-
}, []), C =
|
|
393
|
-
(
|
|
394
|
-
const T = oe(
|
|
395
|
-
T ? r(
|
|
382
|
+
}, []), C = p(
|
|
383
|
+
(t) => {
|
|
384
|
+
const T = oe(t.target);
|
|
385
|
+
T ? r(t.target.name, T) : r(t.target.name, null);
|
|
396
386
|
},
|
|
397
387
|
[r]
|
|
398
|
-
), J =
|
|
399
|
-
(
|
|
400
|
-
const y =
|
|
401
|
-
switch (typeof
|
|
388
|
+
), J = p(
|
|
389
|
+
(t, T, { shouldDirty: f = !0, shouldOnChange: k = !0 } = {}) => {
|
|
390
|
+
const y = O.current;
|
|
391
|
+
switch (typeof t) {
|
|
402
392
|
case "string":
|
|
403
393
|
{
|
|
404
|
-
const
|
|
405
|
-
if (!
|
|
406
|
-
throw new Error(`${
|
|
407
|
-
|
|
394
|
+
const j = y[t];
|
|
395
|
+
if (!j)
|
|
396
|
+
throw new Error(`${t} is uncontrolled, please use Controller for it!`);
|
|
397
|
+
j(T, { shouldDirty: f, shouldOnChange: k }), k && A();
|
|
408
398
|
}
|
|
409
399
|
break;
|
|
410
400
|
case "object":
|
|
411
|
-
Object.entries(
|
|
412
|
-
const V = y[
|
|
401
|
+
Object.entries(t).forEach(([j, z]) => {
|
|
402
|
+
const V = y[j];
|
|
413
403
|
if (!V)
|
|
414
|
-
throw new Error(`${
|
|
415
|
-
V(z, { shouldDirty:
|
|
404
|
+
throw new Error(`${j} is uncontrolled, please use Controller for it!`);
|
|
405
|
+
V(z, { shouldDirty: f, shouldOnChange: k });
|
|
416
406
|
}), k && A();
|
|
417
407
|
default:
|
|
418
408
|
return;
|
|
419
409
|
}
|
|
420
410
|
},
|
|
421
411
|
[A]
|
|
422
|
-
), N =
|
|
423
|
-
const
|
|
424
|
-
return Object.keys(T).map((
|
|
425
|
-
|
|
426
|
-
}), o.forEach((
|
|
412
|
+
), N = p(() => {
|
|
413
|
+
const t = Object.fromEntries(new FormData(h.current)), T = O.current;
|
|
414
|
+
return Object.keys(T).map((f) => {
|
|
415
|
+
t[f] = s.current[f];
|
|
416
|
+
}), o.forEach((f) => t.hasOwnProperty(f) && (t[f] = +t[f])), t;
|
|
427
417
|
}, []), D = ae(
|
|
428
418
|
() => ({
|
|
429
419
|
setValue: J,
|
|
@@ -432,8 +422,8 @@ const se = le({}), me = () => ie(se), Te = ({
|
|
|
432
422
|
getFormState: U,
|
|
433
423
|
setFormState: $,
|
|
434
424
|
changeError: r,
|
|
435
|
-
changeErrors:
|
|
436
|
-
clearError:
|
|
425
|
+
changeErrors: d,
|
|
426
|
+
clearError: c,
|
|
437
427
|
clearErrors: a,
|
|
438
428
|
loadFormValues: N,
|
|
439
429
|
checkValidity: C,
|
|
@@ -449,8 +439,8 @@ const se = le({}), me = () => ie(se), Te = ({
|
|
|
449
439
|
U,
|
|
450
440
|
$,
|
|
451
441
|
r,
|
|
452
|
-
|
|
453
|
-
|
|
442
|
+
d,
|
|
443
|
+
c,
|
|
454
444
|
N,
|
|
455
445
|
W,
|
|
456
446
|
C,
|
|
@@ -461,13 +451,13 @@ const se = le({}), me = () => ie(se), Te = ({
|
|
|
461
451
|
);
|
|
462
452
|
return K(() => {
|
|
463
453
|
if (h.current) {
|
|
464
|
-
const
|
|
465
|
-
|
|
454
|
+
const t = N();
|
|
455
|
+
console.log(t), b.current = t, s.current = t;
|
|
466
456
|
}
|
|
467
457
|
return () => {
|
|
468
|
-
|
|
458
|
+
b.current = {}, s.current = {}, E(!1), a();
|
|
469
459
|
};
|
|
470
|
-
}, [
|
|
460
|
+
}, [R]), { ref: h, lastReloadedAt: R, isDirty: u, isError: m, errors: i, numberFields: o, subscribe: B, actions: D };
|
|
471
461
|
};
|
|
472
462
|
export {
|
|
473
463
|
ge as Controller,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(g,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],n):(g=typeof globalThis<"u"?globalThis:g||self,n(g.Name={},g.React))})(this,function(g,n){"use strict";var M={exports:{}},F={};/**
|
|
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 ae(){if(q)return F;q=1;var a=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function f(b,l,s){var R=null;if(s!==void 0&&(R=""+s),l.key!==void 0&&(R=""+l.key),"key"in l){s={};for(var u in l)u!=="key"&&(s[u]=l[u])}else s=l;return l=s.ref,{$$typeof:a,type:b,key:R,ref:l!==void 0?l:null,props:s}}return F.Fragment=t,F.jsx=f,F.jsxs=f,F}var x={};/**
|
|
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 se(){return $||($=1,process.env.NODE_ENV!=="production"&&function(){function
|
|
17
|
+
*/var $;function se(){return $||($=1,process.env.NODE_ENV!=="production"&&function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===D?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case S:return"Fragment";case W:return"Profiler";case L:return"StrictMode";case z:return"Suspense";case G:return"SuspenseList";case X: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 N:return"Portal";case U:return(e.displayName||"Context")+".Provider";case H:return(e._context.displayName||"Context")+".Consumer";case J:var o=e.render;return e=e.displayName,e||(e=o.displayName||o.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case A:return o=e.displayName||null,o!==null?o:a(e.type)||"Memo";case V:o=e._payload,e=e._init;try{return a(e(o))}catch{}}return null}function t(e){return""+e}function f(e){try{t(e);var o=!1}catch{o=!0}if(o){o=console;var i=o.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),t(e)}}function b(e){if(e===S)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===V)return"<...>";try{var o=a(e);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function l(){var e=Y.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function R(e){if(r.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function u(e,o){function i(){h||(h=!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)",o))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function E(){var e=a(this.type);return C[e]||(C[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 k(e,o,i,p,w,y,Z,Q){return i=y.ref,e={$$typeof:O,type:e,key:o,props:y,_owner:w},(i!==void 0?i: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 _(e,o,i,p,w,y,Z,Q){var v=o.children;if(v!==void 0)if(p)if(T(v)){for(p=0;p<v.length;p++)c(v[p]);Object.freeze&&Object.freeze(v)}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 c(v);if(r.call(o,"key")){v=a(e);var P=Object.keys(o).filter(function(me){return me!=="key"});p=0<P.length?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}",I[v+p]||(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} />`,p,
|
|
22
|
+
<%s key={someKey} {...props} />`,p,v,P,v),I[v+p]=!0)}if(v=null,i!==void 0&&(f(i),v=""+i),R(o)&&(f(o.key),v=""+o.key),"key"in o){i={};for(var K in o)K!=="key"&&(i[K]=o[K])}else i=o;return v&&u(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),k(e,v,y,w,l(),i,Z,Q)}function c(e){typeof e=="object"&&e!==null&&e.$$typeof===O&&e._store&&(e._store.validated=1)}var m=n,O=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),U=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),Y=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,r=Object.prototype.hasOwnProperty,T=Array.isArray,d=console.createTask?console.createTask:function(){return null};m={"react-stack-bottom-frame":function(e){return e()}};var h,C={},j=m["react-stack-bottom-frame"].bind(m,s)(),B=d(b(s)),I={};x.Fragment=S,x.jsx=function(e,o,i,p,w){var y=1e4>Y.recentlyCreatedOwnerStacks++;return _(e,o,i,!1,p,w,y?Error("react-stack-top-frame"):j,y?d(b(e)):B)},x.jsxs=function(e,o,i,p,w){var y=1e4>Y.recentlyCreatedOwnerStacks++;return _(e,o,i,!0,p,w,y?Error("react-stack-top-frame"):j,y?d(b(e)):B)}}()),x}var ee;function ce(){return ee||(ee=1,process.env.NODE_ENV==="production"?M.exports=ae():M.exports=se()),M.exports}var te=ce();const re=n.createContext({}),le=()=>n.useContext(re),ue=({id:a,form:t,method:f,action:b,children:l,onSubmit:s=()=>{},onInput:R=()=>{},onChange:u=()=>{},numberFields:E=[],className:k,..._})=>(n.useEffect(()=>t.actions.registerOnchange(u),[u]),te.jsx(re.Provider,{value:t,children:te.jsx("form",{ref:t==null?void 0:t.ref,action:b,className:k,onSubmit:c=>{f||c.preventDefault();const m=t.actions.loadFormValues();s(m)},onInput:c=>{if(c.target.tagName==="FORM"){const m=t.actions.loadFormValues();t.actions.setFormState(m)}else R(c)},onChange:()=>{const c=t.actions.loadFormValues();t.actions.setFormState(c)},onReset:c=>{t&&(c.preventDefault(),t.actions.reset())},..._,children:l},t==null?void 0:t.lastReloadedAt)})),ie=({name:a,defaultValue:t,render:f=({ref:b,name:l,defaultValue:s,value:R,setValue:u})=>null})=>{const[b,l]=n.useState(t),s=le(),R=n.useRef(),u=n.useCallback((E,{shouldDirty:k=!1}={})=>{s.actions.setFormState(_=>({..._,[a]:E}),{shouldDirty:k}),l(E)},[l,s.actions.setFormState]);return n.useEffect(()=>(s.actions.setFormState(k=>({...k,[a]:t}),{shouldDirty:!1}),s.subscribe(a,(k,{shouldDirty:_=!0,shouldOnChange:c=!0}={})=>{l(k),s.actions.setFormState(m=>({...m,[a]:k}),{shouldDirty:_,shouldOnChange:c}),R.current&&typeof R.current.dispatchEvent=="function"&&c&&R.current.dispatchEvent(new Event("change"))})),[]),f({ref:R,name:a,defaultValue:t,value:b,setValue:u})},fe=(a,t)=>{let f=!1;return Object.keys(t).forEach(b=>{if(!(b in a)||f)return;const l=t[b],s=a[b];(typeof l=="object"||l!==s)&&(f=!0)}),f},ne=a=>(typeof a.setCustomValidity=="function"&&a.setCustomValidity(""),!a||typeof a.checkValidity!="function"||a.checkValidity()?null:a.validationMessage),oe=()=>{const[a,t]=n.useState({}),f=n.useMemo(()=>Object.values(a).filter(Boolean).length>0,[a]),b=n.useCallback((u,E)=>{t(k=>k[u]===E?k:{...k,[u]:E})},[]),l=n.useCallback(u=>{t(E=>({...E,...u}))},[]),s=n.useCallback(u=>{t(E=>E[u]?{...E,[u]:""}:E)},[]),R=n.useCallback(()=>{t({})},[]);return{isError:f,errors:a,changeError:b,changeErrors:l,clearError:s,clearErrors:R}},de=()=>{const[a,t]=n.useState(),f=n.useCallback(()=>t(new Date().toString()),[]);return[a,f]},be=[],Ee=({numberFields:a=be}={})=>{const{changeError:t,errors:f,changeErrors:b,clearError:l,clearErrors:s,isError:R}=oe(),[u,E]=n.useState(!1),[k,_]=de(),c=n.useRef({}),m=n.useRef({}),O=n.useRef({}),N=n.useRef(()=>{}),S=n.useRef(),L=n.useCallback((r,{shouldDirty:T=!0,shouldOnChange:d=!0}={})=>{let h=r;typeof r=="function"&&(h=r(c.current)),c.current=h;let C=u;T&&(C=fe(c.current,m.current),C!==u&&E(C)),d&&N.current(c.current)},[u]),W=n.useCallback(()=>{E(!1),s();const r=O.current;Object.keys(r).forEach(T=>{const d=r[T];d(m.current[T],{shouldDirty:!1,shouldOnChange:!1})}),S.current&&S.current.reset(),_()},[s]),H=n.useCallback((r,T)=>{const d=O.current;return d[r]=T,()=>{delete d[r],delete c.current[r],delete m.current[r],console.log(O,c,m)}},[]),U=n.useCallback(r=>(N.current=r,()=>N.current=()=>{})),J=n.useCallback(r=>ne(r.target),[]),z=n.useCallback(r=>r?c.current[r]:c.current,[]),G=n.useCallback(()=>m.current,[]),A=n.useCallback(()=>{setTimeout(()=>S.current.dispatchEvent(new Event("input",{bubbles:!0})))},[]),V=n.useCallback(r=>{const T=ne(r.target);T?t(r.target.name,T):t(r.target.name,null)},[t]),X=n.useCallback((r,T,{shouldDirty:d=!0,shouldOnChange:h=!0}={})=>{const C=O.current;switch(typeof r){case"string":{const j=C[r];if(!j)throw new Error(`${r} is uncontrolled, please use Controller for it!`);j(T,{shouldDirty:d,shouldOnChange:h}),h&&A()}break;case"object":Object.entries(r).forEach(([j,B])=>{const I=C[j];if(!I)throw new Error(`${j} is uncontrolled, please use Controller for it!`);I(B,{shouldDirty:d,shouldOnChange:h})}),h&&A();default:return}},[A]),D=n.useCallback(()=>{const r=Object.fromEntries(new FormData(S.current)),T=O.current;return Object.keys(T).map(d=>{r[d]=c.current[d]}),a.forEach(d=>r.hasOwnProperty(d)&&(r[d]=+r[d])),r},[]),Y=n.useMemo(()=>({setValue:X,instantChange:A,getDefaultValues:G,getFormState:z,setFormState:L,changeError:t,changeErrors:b,clearError:l,clearErrors:s,loadFormValues:D,checkValidity:V,getFieldValidity:J,registerOnchange:U,reload:_,reset:W}),[X,A,G,z,L,t,b,l,D,J,V,U,_,W]);return n.useEffect(()=>{if(S.current){const r=D();console.log(r),m.current=r,c.current=r}return()=>{m.current={},c.current={},E(!1),s()}},[k]),{ref:S,lastReloadedAt:k,isDirty:u,isError:R,errors:f,numberFields:a,subscribe:H,actions:Y}};g.Controller=ie,g.Form=ue,g.useForm=Ee,g.useValidateForm=oe,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|