react-simple-formkit 1.1.11 → 1.1.14
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,c,s){var m=null;if(s!==void 0&&(m=""+s),c.key!==void 0&&(m=""+c.key),"key"in c){s={};for(var l in c)l!=="key"&&(s[l]=c[l])}else s=c;return c=s.ref,{$$typeof:o,type:b,key:m,ref:c!==void 0?c: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 c(){var e=N.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function m(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 R(e,n,i,v,O,h,X,B){return i=h.ref,e={$$typeof:j,type:e,key:n,props:h,_owner:O},(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,O,h,X,B){var _=n.children;if(_!==void 0)if(v)if(p(_)){for(v=0;v<_.length;v++)u(_[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 u(_);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),m(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),R(e,_,h,O,c(),i,X,B)}function u(e){typeof e=="object"&&e!==null&&e.$$typeof===j&&e._store&&(e._store.validated=1)}var k=a,j=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=k.__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};k={"react-stack-bottom-frame":function(e){return e()}};var S,y={},C=k["react-stack-bottom-frame"].bind(k,s)(),J=d(b(s)),V={};Y.Fragment=g,Y.jsx=function(e,n,i,v,O){var h=1e4>N.recentlyCreatedOwnerStacks++;return T(e,n,i,!1,v,O,h?Error("react-stack-top-frame"):C,h?d(b(e)):J)},Y.jsxs=function(e,n,i,v,O){var h=1e4>N.recentlyCreatedOwnerStacks++;return T(e,n,i,!0,v,O,h?Error("react-stack-top-frame"):C,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:c,onSubmit:s=()=>{},onInput:m=()=>{},onChange:l=()=>{},numberFields:E=[],className:R,...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:R,onSubmit:u=>{f||u.preventDefault();const k=r.actions.loadFormValues();s(k)},onInput:u=>{if(u.target.tagName==="FORM"){const k=r.actions.loadFormValues();r.actions.setFormState(k)}else m(u)},onChange:()=>{const u=r.actions.loadFormValues();r.actions.setFormState(u)},onReset:u=>{r&&(u.preventDefault(),r.actions.reset())},...T,children:c},r==null?void 0:r.lastReloadedAt)})),ie=({name:o,defaultValue:r,render:f=({ref:b,name:c,defaultValue:s,value:m,setValue:l})=>null})=>{const[b,c]=a.useState(r),s=ue(),m=a.useRef(),l=a.useCallback((E,{shouldDirty:R=!1}={})=>{s.actions.setFormState(T=>({...T,[o]:E}),{shouldDirty:R}),c(E)},[c,s.actions.setFormState]);return a.useEffect(()=>(s.actions.setFormState(R=>({...R,[o]:r}),{shouldDirty:!1}),s.subscribe(o,(R,{shouldDirty:T=!0,shouldOnChange:u=!0}={})=>{c(R),s.actions.setFormState(k=>({...k,[o]:R}),{shouldDirty:T,shouldOnChange:u}),m.current&&typeof m.current.dispatchEvent=="function"&&u&&m.current.dispatchEvent(new Event("change"))})),[]),f({ref:m,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 c=r[b],s=o[b];(typeof c=="object"||c!==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(R=>R[l]===E?R:{...R,[l]:E})},[]),c=a.useCallback(l=>{r(E=>({...E,...l}))},[]),s=a.useCallback(l=>{r(E=>E[l]?{...E,[l]:""}:E)},[]),m=a.useCallback(()=>{r({})},[]);return{isError:f,errors:o,changeError:b,changeErrors:c,clearError:s,clearErrors:m}},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:c,clearErrors:s,isError:m}=ne(),[l,E]=a.useState(!1),[R,T]=de(),u=a.useRef({}),k=a.useRef({}),j=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(u.current)),u.current=S;let y=l;p&&(y=fe(u.current,k.current),y!==l&&E(y)),d&&P.current(u.current)},[l]),$=a.useCallback(()=>{E(!1),s();const t=j.current;Object.keys(t).forEach(p=>{const d=t[p];d(k.current[p],{shouldDirty:!1,shouldOnChange:!1})}),g.current&&g.current.reset(),T()},[s]),G=a.useCallback((t,p)=>{const d=j.current;return d[t]=p,()=>{delete d[t],delete u.current[t],delete k.current[t]}},[]),M=a.useCallback(t=>(P.current=t,()=>P.current=()=>{})),L=a.useCallback(t=>re(t.target),[]),W=a.useCallback(t=>t?u.current[t]:u.current,[]),U=a.useCallback(()=>k.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=j.current;switch(typeof t){case"string":{const C=y[t];if(!C)throw new Error(`${t} is uncontrolled, please use Controller for it!`);C(p,{shouldDirty:d,shouldOnChange:S}),S&&w()}break;case"object":Object.entries(t).forEach(([C,J])=>{const V=y[C];if(!V)throw new Error(`${C} 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=j.current;return Object.keys(p).map(d=>{t[d]=u.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:c,clearErrors:s,loadFormValues:F,checkValidity:x,getFieldValidity:L,registerOnchange:M,reload:T,reset:$}),[q,w,U,W,I,r,b,c,F,L,x,M,T,$]);return a.useEffect(()=>{if(g.current){const t=F();console.log(t),k.current=t,u.current=t}return()=>{k.current={},u.current={},E(!1),s()}},[R]),{ref:g,lastReloadedAt:R,isDirty:l,isError:m,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,7 +14,7 @@ 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(
|
|
17
|
+
function i(d, s, a) {
|
|
18
18
|
var b = null;
|
|
19
19
|
if (a !== void 0 && (b = "" + a), s.key !== void 0 && (b = "" + s.key), "key" in s) {
|
|
20
20
|
a = {};
|
|
@@ -23,7 +23,7 @@ function fe() {
|
|
|
23
23
|
} else a = s;
|
|
24
24
|
return s = a.ref, {
|
|
25
25
|
$$typeof: o,
|
|
26
|
-
type:
|
|
26
|
+
type: d,
|
|
27
27
|
key: b,
|
|
28
28
|
ref: s !== void 0 ? s : null,
|
|
29
29
|
props: a
|
|
@@ -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,27 +93,27 @@ 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
|
}
|
|
@@ -126,17 +126,17 @@ function de() {
|
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
128
|
function b(e) {
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
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 m(e, n, l, _, j, S, H, Z) {
|
|
154
154
|
return l = S.ref, e = {
|
|
155
155
|
$$typeof: w,
|
|
156
156
|
type: e,
|
|
157
|
-
key:
|
|
157
|
+
key: n,
|
|
158
158
|
props: S,
|
|
159
159
|
_owner: j
|
|
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,46 +182,46 @@ 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, _, j, 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
|
-
c(v[
|
|
190
|
+
for (_ = 0; _ < v.length; _++)
|
|
191
|
+
c(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
197
|
else c(v);
|
|
198
|
-
if (
|
|
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), b(
|
|
216
|
+
if (v = null, l !== void 0 && (i(l), v = "" + l), b(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
|
+
), m(
|
|
225
225
|
e,
|
|
226
226
|
v,
|
|
227
227
|
S,
|
|
@@ -235,41 +235,41 @@ React keys must be passed directly to JSX without using spread:
|
|
|
235
235
|
function c(e) {
|
|
236
236
|
typeof e == "object" && e !== null && e.$$typeof === w && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var
|
|
238
|
+
var R = ue, w = 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 = R.__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
|
+
R = {
|
|
242
242
|
"react-stack-bottom-frame": function(e) {
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var k, y = {}, O =
|
|
247
|
-
|
|
246
|
+
var k, y = {}, O = R["react-stack-bottom-frame"].bind(
|
|
247
|
+
R,
|
|
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, _, j) {
|
|
251
251
|
var S = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return g(
|
|
253
253
|
e,
|
|
254
|
-
|
|
254
|
+
n,
|
|
255
255
|
l,
|
|
256
256
|
!1,
|
|
257
|
-
|
|
257
|
+
_,
|
|
258
258
|
j,
|
|
259
259
|
S ? Error("react-stack-top-frame") : O,
|
|
260
|
-
S ?
|
|
260
|
+
S ? f(d(e)) : z
|
|
261
261
|
);
|
|
262
|
-
}, I.jsxs = function(e,
|
|
262
|
+
}, I.jsxs = function(e, n, l, _, j) {
|
|
263
263
|
var S = 1e4 > D.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return g(
|
|
265
265
|
e,
|
|
266
|
-
|
|
266
|
+
n,
|
|
267
267
|
l,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
269
|
+
_,
|
|
270
270
|
j,
|
|
271
271
|
S ? Error("react-stack-top-frame") : O,
|
|
272
|
-
S ?
|
|
272
|
+
S ? f(d(e)) : z
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}()), I;
|
|
@@ -279,11 +279,11 @@ 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:
|
|
286
|
+
action: d,
|
|
287
287
|
children: s,
|
|
288
288
|
onSubmit: a = () => {
|
|
289
289
|
},
|
|
@@ -291,24 +291,24 @@ const se = le({}), me = () => ie(se), Te = ({
|
|
|
291
291
|
},
|
|
292
292
|
onChange: u = () => {
|
|
293
293
|
},
|
|
294
|
-
numberFields:
|
|
295
|
-
className:
|
|
294
|
+
numberFields: E = [],
|
|
295
|
+
className: m,
|
|
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:
|
|
301
|
+
action: d,
|
|
302
|
+
className: m,
|
|
303
303
|
onSubmit: (c) => {
|
|
304
304
|
i || c.preventDefault();
|
|
305
|
-
const
|
|
306
|
-
a(
|
|
305
|
+
const R = r.actions.loadFormValues();
|
|
306
|
+
a(R);
|
|
307
307
|
},
|
|
308
308
|
onInput: (c) => {
|
|
309
309
|
if (c.target.tagName === "FORM") {
|
|
310
|
-
const
|
|
311
|
-
r.actions.setFormState(
|
|
310
|
+
const R = r.actions.loadFormValues();
|
|
311
|
+
r.actions.setFormState(R);
|
|
312
312
|
} else
|
|
313
313
|
b(c);
|
|
314
314
|
},
|
|
@@ -323,107 +323,97 @@ const se = le({}), me = () => ie(se), Te = ({
|
|
|
323
323
|
children: s
|
|
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: s, defaultValue: a, value: b, setValue: u }) => null }) => {
|
|
327
|
+
const [d, s] = X(r), a = be(), b = P(), u = p(
|
|
328
|
+
(E, { shouldDirty: m = !1 } = {}) => {
|
|
329
|
+
a.actions.setFormState((g) => ({ ...g, [o]: E }), { shouldDirty: m }), s(E);
|
|
330
330
|
},
|
|
331
331
|
[s, 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((m) => ({ ...m, [o]: r }), { shouldDirty: !1 }), a.subscribe(o, (m, { shouldDirty: g = !0, shouldOnChange: c = !0 } = {}) => {
|
|
334
|
+
s(m), a.actions.setFormState((R) => ({ ...R, [o]: m }), { shouldDirty: g, shouldOnChange: c }), b.current && typeof b.current.dispatchEvent == "function" && c && b.current.dispatchEvent(new Event("change"));
|
|
335
|
+
})), []), i({ ref: b, 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 s = r[
|
|
338
|
+
return Object.keys(r).forEach((d) => {
|
|
339
|
+
if (!(d in o) || i) return;
|
|
340
|
+
const s = r[d], a = o[d];
|
|
353
341
|
(typeof s == "object" || s !== 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
|
-
}, []), s =
|
|
359
|
-
r((
|
|
360
|
-
}, []), a =
|
|
361
|
-
r((
|
|
362
|
-
}, []), b =
|
|
344
|
+
const [o, r] = X({}), i = ae(() => Object.values(o).filter(Boolean).length > 0, [o]), d = p((u, E) => {
|
|
345
|
+
r((m) => m[u] === E ? m : { ...m, [u]: E });
|
|
346
|
+
}, []), s = p((u) => {
|
|
347
|
+
r((E) => ({ ...E, ...u }));
|
|
348
|
+
}, []), a = p((u) => {
|
|
349
|
+
r((E) => E[u] ? { ...E, [u]: "" } : E);
|
|
350
|
+
}, []), b = 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: s, clearError: a, clearErrors: b };
|
|
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: s, clearErrors: a, isError: b } = Re(), [u, E] = X(!1), [m, g] = pe(), c = P({}), R = P({}), w = 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(c.current)), c.current = k;
|
|
375
363
|
let y = u;
|
|
376
|
-
T && (y =
|
|
364
|
+
T && (y = me(c.current, R.current), y !== u && E(y)), f && F.current(c.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 = w.current;
|
|
370
|
+
Object.keys(t).forEach((T) => {
|
|
371
|
+
const f = t[T];
|
|
372
|
+
f(R.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 = w.current;
|
|
376
|
+
return f[t] = T, () => {
|
|
377
|
+
delete f[t], delete c.current[t], delete R.current[t];
|
|
378
|
+
};
|
|
379
|
+
}, []), L = p((t) => (F.current = t, () => F.current = () => {
|
|
380
|
+
})), W = p((t) => oe(t.target), []), U = p((t) => t ? c.current[t] : c.current, []), q = p(() => R.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
|
-
(
|
|
388
|
+
), J = p(
|
|
389
|
+
(t, T, { shouldDirty: f = !0, shouldOnChange: k = !0 } = {}) => {
|
|
400
390
|
const y = w.current;
|
|
401
|
-
switch (typeof
|
|
391
|
+
switch (typeof t) {
|
|
402
392
|
case "string":
|
|
403
393
|
{
|
|
404
|
-
const O = y[
|
|
394
|
+
const O = y[t];
|
|
405
395
|
if (!O)
|
|
406
|
-
throw new Error(`${
|
|
407
|
-
O(T, { shouldDirty:
|
|
396
|
+
throw new Error(`${t} is uncontrolled, please use Controller for it!`);
|
|
397
|
+
O(T, { shouldDirty: f, shouldOnChange: k }), k && A();
|
|
408
398
|
}
|
|
409
399
|
break;
|
|
410
400
|
case "object":
|
|
411
|
-
Object.entries(
|
|
401
|
+
Object.entries(t).forEach(([O, z]) => {
|
|
412
402
|
const V = y[O];
|
|
413
403
|
if (!V)
|
|
414
404
|
throw new Error(`${O} is uncontrolled, please use Controller for it!`);
|
|
415
|
-
V(z, { shouldDirty:
|
|
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 = w.current;
|
|
414
|
+
return Object.keys(T).map((f) => {
|
|
415
|
+
t[f] = c.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,7 +422,7 @@ const se = le({}), me = () => ie(se), Te = ({
|
|
|
432
422
|
getFormState: U,
|
|
433
423
|
setFormState: $,
|
|
434
424
|
changeError: r,
|
|
435
|
-
changeErrors:
|
|
425
|
+
changeErrors: d,
|
|
436
426
|
clearError: s,
|
|
437
427
|
clearErrors: a,
|
|
438
428
|
loadFormValues: N,
|
|
@@ -449,7 +439,7 @@ const se = le({}), me = () => ie(se), Te = ({
|
|
|
449
439
|
U,
|
|
450
440
|
$,
|
|
451
441
|
r,
|
|
452
|
-
|
|
442
|
+
d,
|
|
453
443
|
s,
|
|
454
444
|
N,
|
|
455
445
|
W,
|
|
@@ -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), R.current = t, c.current = t;
|
|
466
456
|
}
|
|
467
457
|
return () => {
|
|
468
|
-
|
|
458
|
+
R.current = {}, c.current = {}, E(!1), a();
|
|
469
459
|
};
|
|
470
|
-
}, [
|
|
460
|
+
}, [m]), { ref: h, lastReloadedAt: m, isDirty: u, isError: b, 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 oe(){if(q)return
|
|
9
|
+
*/var q;function oe(){if(q)return F;q=1;var o=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function f(b,c,s){var m=null;if(s!==void 0&&(m=""+s),c.key!==void 0&&(m=""+c.key),"key"in c){s={};for(var u in c)u!=="key"&&(s[u]=c[u])}else s=c;return c=s.ref,{$$typeof:o,type:b,key:m,ref:c!==void 0?c: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 o(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===
|
|
17
|
+
*/var $;function se(){return $||($=1,process.env.NODE_ENV!=="production"&&function(){function o(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 a=e.render;return e=e.displayName,e||(e=a.displayName||a.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case A:return a=e.displayName||null,a!==null?a:o(e.type)||"Memo";case V:a=e._payload,e=e._init;try{return o(e(a))}catch{}}return null}function t(e){return""+e}function f(e){try{t(e);var a=!1}catch{a=!0}if(a){a=console;var i=a.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(a,"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 a=o(e);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function c(){var e=Y.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function m(e){if(r.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function u(e,a){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)",a))}i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}function E(){var e=o(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 R(e,a,i,p,j,y,Z,Q){return i=y.ref,e={$$typeof:w,type:e,key:a,props:y,_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: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,a,i,p,j,y,Z,Q){var v=a.children;if(v!==void 0)if(p)if(T(v)){for(p=0;p<v.length;p++)l(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 l(v);if(r.call(a,"key")){v=o(e);var P=Object.keys(a).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),m(a)&&(f(a.key),v=""+a.key),"key"in a){i={};for(var K in a)K!=="key"&&(i[K]=a[K])}else i=a;return v&&u(i,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,v,y,j,c(),i,Z,Q)}function l(e){typeof e=="object"&&e!==null&&e.$$typeof===w&&e._store&&(e._store.validated=1)}var k=n,w=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=k.__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};k={"react-stack-bottom-frame":function(e){return e()}};var h,C={},O=k["react-stack-bottom-frame"].bind(k,s)(),B=d(b(s)),I={};x.Fragment=S,x.jsx=function(e,a,i,p,j){var y=1e4>Y.recentlyCreatedOwnerStacks++;return _(e,a,i,!1,p,j,y?Error("react-stack-top-frame"):O,y?d(b(e)):B)},x.jsxs=function(e,a,i,p,j){var y=1e4>Y.recentlyCreatedOwnerStacks++;return _(e,a,i,!0,p,j,y?Error("react-stack-top-frame"):O,y?d(b(e)):B)}}()),x}var ee;function ce(){return ee||(ee=1,process.env.NODE_ENV==="production"?M.exports=oe():M.exports=se()),M.exports}var te=ce();const re=n.createContext({}),le=()=>n.useContext(re),ue=({id:o,form:t,method:f,action:b,children:c,onSubmit:s=()=>{},onInput:m=()=>{},onChange:u=()=>{},numberFields:E=[],className:R,..._})=>(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:R,onSubmit:l=>{f||l.preventDefault();const k=t.actions.loadFormValues();s(k)},onInput:l=>{if(l.target.tagName==="FORM"){const k=t.actions.loadFormValues();t.actions.setFormState(k)}else m(l)},onChange:()=>{const l=t.actions.loadFormValues();t.actions.setFormState(l)},onReset:l=>{t&&(l.preventDefault(),t.actions.reset())},..._,children:c},t==null?void 0:t.lastReloadedAt)})),ie=({name:o,defaultValue:t,render:f=({ref:b,name:c,defaultValue:s,value:m,setValue:u})=>null})=>{const[b,c]=n.useState(t),s=le(),m=n.useRef(),u=n.useCallback((E,{shouldDirty:R=!1}={})=>{s.actions.setFormState(_=>({..._,[o]:E}),{shouldDirty:R}),c(E)},[c,s.actions.setFormState]);return n.useEffect(()=>(s.actions.setFormState(R=>({...R,[o]:t}),{shouldDirty:!1}),s.subscribe(o,(R,{shouldDirty:_=!0,shouldOnChange:l=!0}={})=>{c(R),s.actions.setFormState(k=>({...k,[o]:R}),{shouldDirty:_,shouldOnChange:l}),m.current&&typeof m.current.dispatchEvent=="function"&&l&&m.current.dispatchEvent(new Event("change"))})),[]),f({ref:m,name:o,defaultValue:t,value:b,setValue:u})},fe=(o,t)=>{let f=!1;return Object.keys(t).forEach(b=>{if(!(b in o)||f)return;const c=t[b],s=o[b];(typeof c=="object"||c!==s)&&(f=!0)}),f},ne=o=>(typeof o.setCustomValidity=="function"&&o.setCustomValidity(""),!o||typeof o.checkValidity!="function"||o.checkValidity()?null:o.validationMessage),ae=()=>{const[o,t]=n.useState({}),f=n.useMemo(()=>Object.values(o).filter(Boolean).length>0,[o]),b=n.useCallback((u,E)=>{t(R=>R[u]===E?R:{...R,[u]:E})},[]),c=n.useCallback(u=>{t(E=>({...E,...u}))},[]),s=n.useCallback(u=>{t(E=>E[u]?{...E,[u]:""}:E)},[]),m=n.useCallback(()=>{t({})},[]);return{isError:f,errors:o,changeError:b,changeErrors:c,clearError:s,clearErrors:m}},de=()=>{const[o,t]=n.useState(),f=n.useCallback(()=>t(new Date().toString()),[]);return[o,f]},be=[],Ee=({numberFields:o=be}={})=>{const{changeError:t,errors:f,changeErrors:b,clearError:c,clearErrors:s,isError:m}=ae(),[u,E]=n.useState(!1),[R,_]=de(),l=n.useRef({}),k=n.useRef({}),w=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(l.current)),l.current=h;let C=u;T&&(C=fe(l.current,k.current),C!==u&&E(C)),d&&N.current(l.current)},[u]),W=n.useCallback(()=>{E(!1),s();const r=w.current;Object.keys(r).forEach(T=>{const d=r[T];d(k.current[T],{shouldDirty:!1,shouldOnChange:!1})}),S.current&&S.current.reset(),_()},[s]),H=n.useCallback((r,T)=>{const d=w.current;return d[r]=T,()=>{delete d[r],delete l.current[r],delete k.current[r]}},[]),U=n.useCallback(r=>(N.current=r,()=>N.current=()=>{})),J=n.useCallback(r=>ne(r.target),[]),z=n.useCallback(r=>r?l.current[r]:l.current,[]),G=n.useCallback(()=>k.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=w.current;switch(typeof r){case"string":{const O=C[r];if(!O)throw new Error(`${r} is uncontrolled, please use Controller for it!`);O(T,{shouldDirty:d,shouldOnChange:h}),h&&A()}break;case"object":Object.entries(r).forEach(([O,B])=>{const I=C[O];if(!I)throw new Error(`${O} 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=w.current;return Object.keys(T).map(d=>{r[d]=l.current[d]}),o.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:c,clearErrors:s,loadFormValues:D,checkValidity:V,getFieldValidity:J,registerOnchange:U,reload:_,reset:W}),[X,A,G,z,L,t,b,c,D,J,V,U,_,W]);return n.useEffect(()=>{if(S.current){const r=D();console.log(r),k.current=r,l.current=r}return()=>{k.current={},l.current={},E(!1),s()}},[R]),{ref:S,lastReloadedAt:R,isDirty:u,isError:m,errors:f,numberFields:o,subscribe:H,actions:Y}};g.Controller=ie,g.Form=ue,g.useForm=Ee,g.useValidateForm=ae,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|