react-simple-formkit 1.1.3 → 1.1.5
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.
|
@@ -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 ee;function ie(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===w?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case C:return"Fragment";case O:return"Profiler";case
|
|
17
|
+
*/var ee;function ie(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===w?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case C:return"Fragment";case O:return"Profiler";case P:return"StrictMode";case G:return"Suspense";case U:return"SuspenseList";case J: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 F:return"Portal";case N:return(e.displayName||"Context")+".Provider";case L: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 q:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case V:r=e._payload,e=e._init;try{return s(e(r))}catch{}}return null}function n(e){return""+e}function f(e){try{n(e);var r=!1}catch{r=!0}if(r){r=console;var c=r.error,_=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.",_),n(e)}}function i(e){if(e===C)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===V)return"<...>";try{var r=s(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function u(){var e=A.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function E(e){if(D.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function l(e,r){function c(){t||(t=!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 R(){var e=s(this.type);return k[e]||(k[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 d(e,r,c,_,j,h,X,B){return c=h.ref,e={$$typeof:g,type:e,key:r,props:h,_owner:j},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):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,_,j,h,X,B){var v=r.children;if(v!==void 0)if(_)if(Y(v)){for(_=0;_<v.length;_++)m(v[_]);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 m(v);if(D.call(r,"key")){v=s(e);var x=Object.keys(r).filter(function(ue){return ue!=="key"});_=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",y[v+_]||(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} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,_,v,x,v),y[v+_]=!0)}if(v=null,c!==void 0&&(f(c),v=""+c),E(r)&&(f(r.key),v=""+r.key),"key"in r){c={};for(var H in r)H!=="key"&&(c[H]=r[H])}else c=r;return v&&l(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),d(e,v,h,j,u(),c,X,B)}function m(e){typeof e=="object"&&e!==null&&e.$$typeof===g&&e._store&&(e._store.validated=1)}var p=a,g=Symbol.for("react.transitional.element"),F=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),N=Symbol.for("react.context"),W=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),U=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),w=Symbol.for("react.client.reference"),A=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,Y=Array.isArray,I=console.createTask?console.createTask:function(){return null};p={"react-stack-bottom-frame":function(e){return e()}};var t,k={},b=p["react-stack-bottom-frame"].bind(p,o)(),S=I(i(o)),y={};M.Fragment=C,M.jsx=function(e,r,c,_,j){var h=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,c,!1,_,j,h?Error("react-stack-top-frame"):b,h?I(i(e)):S)},M.jsxs=function(e,r,c,_,j){var h=1e4>A.recentlyCreatedOwnerStacks++;return T(e,r,c,!0,_,j,h?Error("react-stack-top-frame"):b,h?I(i(e)):S)}}()),M}var re;function fe(){return re||(re=1,process.env.NODE_ENV==="production"?z.exports=le():z.exports=ie()),z.exports}var te=fe();const ae=a.createContext({}),de=()=>a.useContext(ae),be=(s,n)=>{let f=!1;return Object.keys(n).forEach(i=>{if(!(i in s)||f)return;const u=n[i],o=s[i];(typeof u=="object"||u!==o)&&(f=!0)}),f},ne=s=>(typeof s.setCustomValidity=="function"&&s.setCustomValidity(""),!s||typeof s.checkValidity!="function"||s.checkValidity()?null:s.validationMessage),se=({id:s,form:n,method:f,action:i,children:u,onSubmit:o=()=>{},onInput:E=()=>{},onChange:l=()=>{},numberFields:R=[],className:d,...T})=>(a.useEffect(()=>n.actions.registerOnchange(l),[l]),te.jsx(ae.Provider,{value:n,children:te.jsx("form",{ref:n==null?void 0:n.ref,action:i,className:d,onSubmit:m=>{f||m.preventDefault();const p=n.actions.loadFormValues();o(p)},onInput:m=>{if(m.target.tagName==="FORM"){const p=n.actions.loadFormValues();n.actions.setFormState(p)}else E(m)},onChange:()=>{const m=n.actions.loadFormValues();n.actions.setFormState(m)},onReset:m=>{n&&(m.preventDefault(),n.actions.reset())},...T,children:u},n==null?void 0:n.lastReloadedAt)})),oe=({name:s,defaultValue:n,render:f=({ref:i,name:u,defaultValue:o,value:E,setValue:l})=>null})=>{const[i,u]=a.useState(n),o=de(),E=a.useRef(),l=a.useCallback((R,{shouldDirty:d=!1}={})=>{o.actions.setFormState(T=>({...T,[s]:R}),{shouldDirty:d}),u(R)},[u,o.actions.setFormState]);return a.useEffect(()=>(o.actions.setFormState(d=>({...d,[s]:n}),{shouldDirty:!1}),o.subscribe(s,(d,{shouldDirty:T=!0,shouldOnChange:m=!0}={})=>{u(d),o.actions.setFormState(p=>({...p,[s]:d}),{shouldDirty:T,shouldOnChange:m}),E.current&&typeof E.current.dispatchEvent=="function"&&m&&E.current.dispatchEvent(new Event("change"))})),[]),f({ref:E,name:s,defaultValue:n,value:i,setValue:l})},Q=()=>{const[s,n]=a.useState({}),f=a.useMemo(()=>Object.values(s).filter(Boolean).length>0,[s]),i=a.useCallback((l,R)=>{n(d=>d[l]===R?d:{...d,[l]:R})},[]),u=a.useCallback(l=>{n(R=>({...R,...l}))},[]),o=a.useCallback(l=>{n(R=>R[l]?{...R,[l]:""}:R)},[]),E=a.useCallback(()=>{n({})},[]);return{isError:f,errors:s,changeError:i,changeErrors:u,clearError:o,clearErrors:E}},Z={defaultValues:{},numberFields:[]},ce=(s=Z)=>{const{defaultValues:n=Z.defaultValues,numberFields:f=Z.numberFields}=s,{changeError:i,errors:u,changeErrors:o,clearError:E,clearErrors:l,isError:R}=Q(),[d,T]=a.useState(!1),[m,p]=a.useState(null),g=a.useRef({}),F=a.useRef(n),C=a.useRef({}),P=a.useRef(()=>{}),O=a.useRef(),L=a.useCallback((t,{shouldDirty:k=!0,shouldOnChange:b=!0}={})=>{let S=t;typeof t=="function"&&(S=t(g.current)),g.current=S;let y=d;k&&(y=be(g.current,F.current),y!==d&&T(y)),b&&P.current(g.current)},[d]),N=a.useCallback(()=>p(new Date().toString()),[]),W=a.useCallback(()=>{T(!1),l();const t=C.current;Object.keys(t).forEach(k=>{const b=t[k];b(F.current[k],{shouldDirty:!1,shouldOnChange:!1})}),O.current&&O.current.reset(),N()},[l]),G=a.useCallback((t,k)=>{const b=C.current;return b[t]=k,()=>b[t]=null},[]),U=a.useCallback(t=>(P.current=t,()=>P.current=()=>{})),q=a.useCallback(t=>ne(t.target),[]),V=a.useCallback(t=>t?g.current[t]:g.current,[]),J=a.useCallback(()=>F.current,[]),w=a.useCallback(()=>{setTimeout(()=>O.current.dispatchEvent(new Event("input",{bubbles:!0})))},[]),A=a.useCallback(t=>{const k=ne(t.target);k?i(t.target.name,k):i(t.target.name,null)},[i]),D=a.useCallback((t,k,{shouldDirty:b=!0,shouldOnChange:S=!0}={})=>{const y=C.current;switch(typeof t){case"string":{const e=y[t];if(!e)throw new Error(`${t} is uncontrolled, please use Controller for it!`);e(k,{shouldDirty:b,shouldOnChange:S}),S&&w()}break;case"object":Object.entries(t).forEach(([e,r])=>{const c=y[e];if(!c)throw new Error(`${e} is uncontrolled, please use Controller for it!`);c(r,{shouldDirty:b,shouldOnChange:S})}),S&&w();default:return}},[w]),Y=a.useCallback(()=>{const t=Object.fromEntries(new FormData(O.current)),k=C.current;return Object.keys(k).map(b=>{t[b]=g.current[b]}),f.forEach(b=>t.hasOwnProperty(b)&&(t[b]=+t[b])),t},[]),I=a.useMemo(()=>({setValue:D,instantChange:w,getDefaultValues:J,getFormState:V,setFormState:L,changeError:i,changeErrors:o,clearError:E,clearErrors:l,loadFormValues:Y,checkValidity:A,getFieldValidity:q,registerOnchange:U,reload:N,reset:W}),[D,w,J,V,L,i,o,E,Y,q,A,U,N,W]);return a.useEffect(()=>{if(O.current){const t=Y();F.current={...t,...n},g.current={...t,...n}}},[m]),{ref:O,lastReloadedAt:m,isDirty:d,isError:R,errors:u,numberFields:f,subscribe:G,actions:I}},Ee={Form:se,Controller:oe,useForm:ce,useValidateForm:Q};exports.Controller=oe;exports.Form=se;exports.default=Ee;exports.useForm=ce;exports.useValidateForm=Q;
|
|
@@ -54,7 +54,7 @@ function be() {
|
|
|
54
54
|
return "Fragment";
|
|
55
55
|
case j:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case N:
|
|
58
58
|
return "StrictMode";
|
|
59
59
|
case B:
|
|
60
60
|
return "Suspense";
|
|
@@ -67,9 +67,9 @@ function be() {
|
|
|
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 N:
|
|
71
|
-
return "Portal";
|
|
72
70
|
case A:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case V:
|
|
73
73
|
return (e.displayName || "Context") + ".Provider";
|
|
74
74
|
case W:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
@@ -99,11 +99,11 @@ function be() {
|
|
|
99
99
|
}
|
|
100
100
|
if (r) {
|
|
101
101
|
r = console;
|
|
102
|
-
var s = r.error,
|
|
102
|
+
var s = r.error, _ = 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
|
-
|
|
106
|
+
_
|
|
107
107
|
), n(e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -144,22 +144,22 @@ function be() {
|
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function m() {
|
|
148
148
|
var e = o(this.type);
|
|
149
|
-
return
|
|
149
|
+
return p[e] || (p[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 f(e, r, s,
|
|
154
|
-
return s =
|
|
155
|
-
$$typeof:
|
|
153
|
+
function f(e, r, s, _, w, S, H, Z) {
|
|
154
|
+
return s = S.ref, e = {
|
|
155
|
+
$$typeof: h,
|
|
156
156
|
type: e,
|
|
157
157
|
key: r,
|
|
158
|
-
props:
|
|
158
|
+
props: S,
|
|
159
159
|
_owner: w
|
|
160
160
|
}, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
161
|
enumerable: !1,
|
|
162
|
-
get:
|
|
162
|
+
get: m
|
|
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,36 +182,36 @@ function be() {
|
|
|
182
182
|
value: Z
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function g(e, r, s,
|
|
185
|
+
function g(e, r, s, _, w, S, H, Z) {
|
|
186
186
|
var v = r.children;
|
|
187
187
|
if (v !== void 0)
|
|
188
|
-
if (
|
|
188
|
+
if (_)
|
|
189
189
|
if (I(v)) {
|
|
190
|
-
for (
|
|
191
|
-
|
|
190
|
+
for (_ = 0; _ < v.length; _++)
|
|
191
|
+
b(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
|
|
197
|
+
else b(v);
|
|
198
198
|
if (Y.call(r, "key")) {
|
|
199
199
|
v = o(e);
|
|
200
200
|
var P = Object.keys(r).filter(function(le) {
|
|
201
201
|
return le !== "key";
|
|
202
202
|
});
|
|
203
|
-
|
|
203
|
+
_ = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", y[v + _] || (P = 0 < P.length ? "{" + P.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
|
P,
|
|
213
213
|
v
|
|
214
|
-
), y[v +
|
|
214
|
+
), y[v + _] = !0);
|
|
215
215
|
}
|
|
216
216
|
if (v = null, s !== void 0 && (i(s), v = "" + s), E(r) && (i(r.key), v = "" + r.key), "key" in r) {
|
|
217
217
|
s = {};
|
|
@@ -224,7 +224,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
224
224
|
), f(
|
|
225
225
|
e,
|
|
226
226
|
v,
|
|
227
|
-
|
|
227
|
+
S,
|
|
228
228
|
w,
|
|
229
229
|
c(),
|
|
230
230
|
s,
|
|
@@ -232,10 +232,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
232
232
|
Z
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
235
|
+
function b(e) {
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === h && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var T = ie,
|
|
238
|
+
var T = ie, h = Symbol.for("react.transitional.element"), A = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), N = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), W = Symbol.for("react.consumer"), V = Symbol.for("react.context"), U = Symbol.for("react.forward_ref"), B = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), J = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), z = Symbol.for("react.activity"), x = Symbol.for("react.client.reference"), F = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, I = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
241
|
T = {
|
|
@@ -243,33 +243,33 @@ React keys must be passed directly to JSX without using spread:
|
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var t,
|
|
246
|
+
var t, p = {}, d = T["react-stack-bottom-frame"].bind(
|
|
247
247
|
T,
|
|
248
248
|
a
|
|
249
|
-
)(),
|
|
250
|
-
L.Fragment = O, L.jsx = function(e, r, s,
|
|
251
|
-
var
|
|
249
|
+
)(), k = $(l(a)), y = {};
|
|
250
|
+
L.Fragment = O, L.jsx = function(e, r, s, _, w) {
|
|
251
|
+
var S = 1e4 > F.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return g(
|
|
253
253
|
e,
|
|
254
254
|
r,
|
|
255
255
|
s,
|
|
256
256
|
!1,
|
|
257
|
-
|
|
257
|
+
_,
|
|
258
258
|
w,
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
S ? Error("react-stack-top-frame") : d,
|
|
260
|
+
S ? $(l(e)) : k
|
|
261
261
|
);
|
|
262
|
-
}, L.jsxs = function(e, r, s,
|
|
263
|
-
var
|
|
262
|
+
}, L.jsxs = function(e, r, s, _, w) {
|
|
263
|
+
var S = 1e4 > F.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return g(
|
|
265
265
|
e,
|
|
266
266
|
r,
|
|
267
267
|
s,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
269
|
+
_,
|
|
270
270
|
w,
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
S ? Error("react-stack-top-frame") : d,
|
|
272
|
+
S ? $(l(e)) : k
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}()), L;
|
|
@@ -286,7 +286,7 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
286
286
|
const c = n[l], a = o[l];
|
|
287
287
|
(typeof c == "object" || c !== a) && (i = !0);
|
|
288
288
|
}), i;
|
|
289
|
-
}, ae = (o) => (typeof o.setCustomValidity == "function" && o.setCustomValidity(""), !o || typeof o.checkValidity != "function" || o.checkValidity() ? null : o.validationMessage),
|
|
289
|
+
}, ae = (o) => (typeof o.setCustomValidity == "function" && o.setCustomValidity(""), !o || typeof o.checkValidity != "function" || o.checkValidity() ? null : o.validationMessage), _e = ({
|
|
290
290
|
id: o,
|
|
291
291
|
form: n,
|
|
292
292
|
method: i,
|
|
@@ -298,7 +298,7 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
298
298
|
},
|
|
299
299
|
onChange: u = () => {
|
|
300
300
|
},
|
|
301
|
-
numberFields:
|
|
301
|
+
numberFields: m = [],
|
|
302
302
|
className: f,
|
|
303
303
|
...g
|
|
304
304
|
}) => (ee(() => n.actions.registerOnchange(u), [u]), /* @__PURE__ */ oe.jsx(ce.Provider, { value: n, children: /* @__PURE__ */ oe.jsx(
|
|
@@ -307,46 +307,46 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
307
307
|
ref: n == null ? void 0 : n.ref,
|
|
308
308
|
action: l,
|
|
309
309
|
className: f,
|
|
310
|
-
onSubmit: (
|
|
311
|
-
i ||
|
|
310
|
+
onSubmit: (b) => {
|
|
311
|
+
i || b.preventDefault();
|
|
312
312
|
const T = n.actions.loadFormValues();
|
|
313
313
|
a(T);
|
|
314
314
|
},
|
|
315
|
-
onInput: (
|
|
316
|
-
if (
|
|
315
|
+
onInput: (b) => {
|
|
316
|
+
if (b.target.tagName === "FORM") {
|
|
317
317
|
const T = n.actions.loadFormValues();
|
|
318
318
|
n.actions.setFormState(T);
|
|
319
319
|
} else
|
|
320
|
-
E(
|
|
320
|
+
E(b);
|
|
321
321
|
},
|
|
322
322
|
onChange: () => {
|
|
323
|
-
const
|
|
324
|
-
n.actions.setFormState(
|
|
323
|
+
const b = n.actions.loadFormValues();
|
|
324
|
+
n.actions.setFormState(b);
|
|
325
325
|
},
|
|
326
|
-
onReset: (
|
|
327
|
-
n && (
|
|
326
|
+
onReset: (b) => {
|
|
327
|
+
n && (b.preventDefault(), n.actions.reset());
|
|
328
328
|
},
|
|
329
329
|
...g,
|
|
330
330
|
children: c
|
|
331
331
|
},
|
|
332
332
|
n == null ? void 0 : n.lastReloadedAt
|
|
333
|
-
) })),
|
|
333
|
+
) })), ve = ({ name: o, defaultValue: n, render: i = ({ ref: l, name: c, defaultValue: a, value: E, setValue: u }) => null }) => {
|
|
334
334
|
const [l, c] = X(n), a = Re(), E = C(), u = R(
|
|
335
|
-
(
|
|
336
|
-
a.actions.setFormState((g) => ({ ...g, [o]:
|
|
335
|
+
(m, { shouldDirty: f = !1 } = {}) => {
|
|
336
|
+
a.actions.setFormState((g) => ({ ...g, [o]: m }), { shouldDirty: f }), c(m);
|
|
337
337
|
},
|
|
338
338
|
[c, a.actions.setFormState]
|
|
339
339
|
);
|
|
340
|
-
return ee(() => (a.actions.setFormState((f) => ({ ...f, [o]: n }), { shouldDirty: !1 }), a.subscribe(o, (f, { shouldDirty: g = !0, shouldOnChange:
|
|
341
|
-
c(f), a.actions.setFormState((T) => ({ ...T, [o]: f }), { shouldDirty: g, shouldOnChange:
|
|
340
|
+
return ee(() => (a.actions.setFormState((f) => ({ ...f, [o]: n }), { shouldDirty: !1 }), a.subscribe(o, (f, { shouldDirty: g = !0, shouldOnChange: b = !0 } = {}) => {
|
|
341
|
+
c(f), a.actions.setFormState((T) => ({ ...T, [o]: f }), { shouldDirty: g, shouldOnChange: b }), E.current && typeof E.current.dispatchEvent == "function" && b && E.current.dispatchEvent(new Event("change"));
|
|
342
342
|
})), []), i({ ref: E, name: o, defaultValue: n, value: l, setValue: u });
|
|
343
343
|
}, ue = () => {
|
|
344
|
-
const [o, n] = X({}), i = se(() => Object.values(o).filter(Boolean).length > 0, [o]), l = R((u,
|
|
345
|
-
n((f) => f[u] ===
|
|
344
|
+
const [o, n] = X({}), i = se(() => Object.values(o).filter(Boolean).length > 0, [o]), l = R((u, m) => {
|
|
345
|
+
n((f) => f[u] === m ? f : { ...f, [u]: m });
|
|
346
346
|
}, []), c = R((u) => {
|
|
347
|
-
n((
|
|
347
|
+
n((m) => ({ ...m, ...u }));
|
|
348
348
|
}, []), a = R((u) => {
|
|
349
|
-
n((
|
|
349
|
+
n((m) => m[u] ? { ...m, [u]: "" } : m);
|
|
350
350
|
}, []), E = R(() => {
|
|
351
351
|
n({});
|
|
352
352
|
}, []);
|
|
@@ -355,33 +355,36 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
355
355
|
defaultValues: {},
|
|
356
356
|
numberFields: []
|
|
357
357
|
}, Te = (o = K) => {
|
|
358
|
-
const { defaultValues: n = K.defaultValues, numberFields: i = K.numberFields } = o, { changeError: l, errors: c, changeErrors: a, clearError: E, clearErrors: u, isError:
|
|
358
|
+
const { defaultValues: n = K.defaultValues, numberFields: i = K.numberFields } = o, { changeError: l, errors: c, changeErrors: a, clearError: E, clearErrors: u, isError: m } = ue(), [f, g] = X(!1), [b, T] = X(null), h = C({}), A = C(n), O = C({}), N = C(() => {
|
|
359
359
|
}), j = C(), W = R(
|
|
360
|
-
(t, { shouldDirty:
|
|
361
|
-
let
|
|
362
|
-
typeof t == "function" && (
|
|
360
|
+
(t, { shouldDirty: p = !0, shouldOnChange: d = !0 } = {}) => {
|
|
361
|
+
let k = t;
|
|
362
|
+
typeof t == "function" && (k = t(h.current)), h.current = k;
|
|
363
363
|
let y = f;
|
|
364
|
-
|
|
364
|
+
p && (y = pe(h.current, A.current), y !== f && g(y)), d && N.current(h.current);
|
|
365
365
|
},
|
|
366
366
|
[f]
|
|
367
|
-
),
|
|
367
|
+
), V = R(() => T((/* @__PURE__ */ new Date()).toString()), []), U = R(() => {
|
|
368
368
|
g(!1), u();
|
|
369
369
|
const t = O.current;
|
|
370
|
-
Object.
|
|
371
|
-
|
|
370
|
+
Object.keys(t).forEach((p) => {
|
|
371
|
+
const d = t[p];
|
|
372
|
+
d(A.current[p], { shouldDirty: !1, shouldOnChange: !1 });
|
|
373
|
+
}), j.current && j.current.reset(), V();
|
|
374
|
+
}, [u]), B = R((t, p) => {
|
|
372
375
|
const d = O.current;
|
|
373
|
-
return d[t] =
|
|
374
|
-
}, []), q = R((t) => (
|
|
375
|
-
})), J = R((t) => ae(t.target), []), D = R((t) => t ?
|
|
376
|
+
return d[t] = p, () => d[t] = null;
|
|
377
|
+
}, []), q = R((t) => (N.current = t, () => N.current = () => {
|
|
378
|
+
})), J = R((t) => ae(t.target), []), D = R((t) => t ? h.current[t] : h.current, []), z = R(() => A.current, []), x = R(() => {
|
|
376
379
|
setTimeout(() => j.current.dispatchEvent(new Event("input", { bubbles: !0 })));
|
|
377
380
|
}, []), F = R(
|
|
378
381
|
(t) => {
|
|
379
|
-
const
|
|
380
|
-
|
|
382
|
+
const p = ae(t.target);
|
|
383
|
+
p ? l(t.target.name, p) : l(t.target.name, null);
|
|
381
384
|
},
|
|
382
385
|
[l]
|
|
383
386
|
), Y = R(
|
|
384
|
-
(t,
|
|
387
|
+
(t, p, { shouldDirty: d = !0, shouldOnChange: k = !0 } = {}) => {
|
|
385
388
|
const y = O.current;
|
|
386
389
|
switch (typeof t) {
|
|
387
390
|
case "string":
|
|
@@ -389,7 +392,7 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
389
392
|
const e = y[t];
|
|
390
393
|
if (!e)
|
|
391
394
|
throw new Error(`${t} is uncontrolled, please use Controller for it!`);
|
|
392
|
-
e(
|
|
395
|
+
e(p, { shouldDirty: d, shouldOnChange: k }), k && x();
|
|
393
396
|
}
|
|
394
397
|
break;
|
|
395
398
|
case "object":
|
|
@@ -397,17 +400,17 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
397
400
|
const s = y[e];
|
|
398
401
|
if (!s)
|
|
399
402
|
throw new Error(`${e} is uncontrolled, please use Controller for it!`);
|
|
400
|
-
s(r, { shouldDirty: d, shouldOnChange:
|
|
401
|
-
}),
|
|
403
|
+
s(r, { shouldDirty: d, shouldOnChange: k });
|
|
404
|
+
}), k && x();
|
|
402
405
|
default:
|
|
403
406
|
return;
|
|
404
407
|
}
|
|
405
408
|
},
|
|
406
409
|
[x]
|
|
407
410
|
), I = R(() => {
|
|
408
|
-
const t = Object.fromEntries(new FormData(j.current)),
|
|
409
|
-
return Object.keys(
|
|
410
|
-
t[d] =
|
|
411
|
+
const t = Object.fromEntries(new FormData(j.current)), p = O.current;
|
|
412
|
+
return Object.keys(p).map((d) => {
|
|
413
|
+
t[d] = h.current[d];
|
|
411
414
|
}), i.forEach((d) => t.hasOwnProperty(d) && (t[d] = +t[d])), t;
|
|
412
415
|
}, []), $ = se(
|
|
413
416
|
() => ({
|
|
@@ -424,7 +427,7 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
424
427
|
checkValidity: F,
|
|
425
428
|
getFieldValidity: J,
|
|
426
429
|
registerOnchange: q,
|
|
427
|
-
reload:
|
|
430
|
+
reload: V,
|
|
428
431
|
reset: U
|
|
429
432
|
}),
|
|
430
433
|
[
|
|
@@ -440,26 +443,26 @@ const ce = fe({}), Re = () => de(ce), pe = (o, n) => {
|
|
|
440
443
|
J,
|
|
441
444
|
F,
|
|
442
445
|
q,
|
|
443
|
-
|
|
446
|
+
V,
|
|
444
447
|
U
|
|
445
448
|
]
|
|
446
449
|
);
|
|
447
450
|
return ee(() => {
|
|
448
451
|
if (j.current) {
|
|
449
452
|
const t = I();
|
|
450
|
-
|
|
453
|
+
A.current = { ...t, ...n }, h.current = { ...t, ...n };
|
|
451
454
|
}
|
|
452
|
-
}, [
|
|
453
|
-
},
|
|
454
|
-
Form:
|
|
455
|
-
Controller:
|
|
455
|
+
}, [b]), { ref: j, lastReloadedAt: b, isDirty: f, isError: m, errors: c, numberFields: i, subscribe: B, actions: $ };
|
|
456
|
+
}, he = {
|
|
457
|
+
Form: _e,
|
|
458
|
+
Controller: ve,
|
|
456
459
|
useForm: Te,
|
|
457
460
|
useValidateForm: ue
|
|
458
461
|
};
|
|
459
462
|
export {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
+
ve as Controller,
|
|
464
|
+
_e as Form,
|
|
465
|
+
he as default,
|
|
463
466
|
Te as useForm,
|
|
464
467
|
ue as useValidateForm
|
|
465
468
|
};
|
|
@@ -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 te;function ie(){return te||(te=1,process.env.NODE_ENV!=="production"&&function(){function s(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 O:return"Fragment";case j:return"Profiler";case
|
|
17
|
+
*/var te;function ie(){return te||(te=1,process.env.NODE_ENV!=="production"&&function(){function s(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 O:return"Fragment";case j:return"Profiler";case D:return"StrictMode";case Q:return"Suspense";case G:return"SuspenseList";case B: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 A:return"Portal";case Y:return(e.displayName||"Context")+".Provider";case J:return(e._context.displayName||"Context")+".Consumer";case z:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case X:return t=e.displayName||null,t!==null?t:s(e.type)||"Memo";case I:t=e._payload,e=e._init;try{return s(e(t))}catch{}}return null}function a(e){return""+e}function f(e){try{a(e);var t=!1}catch{t=!0}if(t){t=console;var c=t.error,p=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.",p),a(e)}}function i(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===I)return"<...>";try{var t=s(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function l(){var e=P.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function E(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function u(e,t){function c(){n||(n=!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 R(){var e=s(this.type);return k[e]||(k[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 d(e,t,c,p,w,y,K,q){return c=y.ref,e={$$typeof:S,type:e,key:t,props:y,_owner:w},(c!==void 0?c:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):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:K}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function g(e,t,c,p,w,y,K,q){var _=t.children;if(_!==void 0)if(p)if(L(_)){for(p=0;p<_.length;p++)m(_[p]);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 m(_);if(M.call(t,"key")){_=s(e);var x=Object.keys(t).filter(function(me){return me!=="key"});p=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",C[_+p]||(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} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,p,_,x,_),C[_+p]=!0)}if(_=null,c!==void 0&&(f(c),_=""+c),E(t)&&(f(t.key),_=""+t.key),"key"in t){c={};for(var $ in t)$!=="key"&&(c[$]=t[$])}else c=t;return _&&u(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),d(e,_,y,w,l(),c,K,q)}function m(e){typeof e=="object"&&e!==null&&e.$$typeof===S&&e._store&&(e._store.validated=1)}var v=r,S=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),J=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),P=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,L=Array.isArray,W=console.createTask?console.createTask:function(){return null};v={"react-stack-bottom-frame":function(e){return e()}};var n,k={},b=v["react-stack-bottom-frame"].bind(v,o)(),h=W(i(o)),C={};V.Fragment=O,V.jsx=function(e,t,c,p,w){var y=1e4>P.recentlyCreatedOwnerStacks++;return g(e,t,c,!1,p,w,y?Error("react-stack-top-frame"):b,y?W(i(e)):h)},V.jsxs=function(e,t,c,p,w){var y=1e4>P.recentlyCreatedOwnerStacks++;return g(e,t,c,!0,p,w,y?Error("react-stack-top-frame"):b,y?W(i(e)):h)}}()),V}var re;function fe(){return re||(re=1,process.env.NODE_ENV==="production"?U.exports=ue():U.exports=ie()),U.exports}var ne=fe();const ae=r.createContext({}),de=()=>r.useContext(ae),be=(s,a)=>{let f=!1;return Object.keys(a).forEach(i=>{if(!(i in s)||f)return;const l=a[i],o=s[i];(typeof l=="object"||l!==o)&&(f=!0)}),f},se=s=>(typeof s.setCustomValidity=="function"&&s.setCustomValidity(""),!s||typeof s.checkValidity!="function"||s.checkValidity()?null:s.validationMessage),oe=({id:s,form:a,method:f,action:i,children:l,onSubmit:o=()=>{},onInput:E=()=>{},onChange:u=()=>{},numberFields:R=[],className:d,...g})=>(r.useEffect(()=>a.actions.registerOnchange(u),[u]),ne.jsx(ae.Provider,{value:a,children:ne.jsx("form",{ref:a==null?void 0:a.ref,action:i,className:d,onSubmit:m=>{f||m.preventDefault();const v=a.actions.loadFormValues();o(v)},onInput:m=>{if(m.target.tagName==="FORM"){const v=a.actions.loadFormValues();a.actions.setFormState(v)}else E(m)},onChange:()=>{const m=a.actions.loadFormValues();a.actions.setFormState(m)},onReset:m=>{a&&(m.preventDefault(),a.actions.reset())},...g,children:l},a==null?void 0:a.lastReloadedAt)})),ce=({name:s,defaultValue:a,render:f=({ref:i,name:l,defaultValue:o,value:E,setValue:u})=>null})=>{const[i,l]=r.useState(a),o=de(),E=r.useRef(),u=r.useCallback((R,{shouldDirty:d=!1}={})=>{o.actions.setFormState(g=>({...g,[s]:R}),{shouldDirty:d}),l(R)},[l,o.actions.setFormState]);return r.useEffect(()=>(o.actions.setFormState(d=>({...d,[s]:a}),{shouldDirty:!1}),o.subscribe(s,(d,{shouldDirty:g=!0,shouldOnChange:m=!0}={})=>{l(d),o.actions.setFormState(v=>({...v,[s]:d}),{shouldDirty:g,shouldOnChange:m}),E.current&&typeof E.current.dispatchEvent=="function"&&m&&E.current.dispatchEvent(new Event("change"))})),[]),f({ref:E,name:s,defaultValue:a,value:i,setValue:u})},H=()=>{const[s,a]=r.useState({}),f=r.useMemo(()=>Object.values(s).filter(Boolean).length>0,[s]),i=r.useCallback((u,R)=>{a(d=>d[u]===R?d:{...d,[u]:R})},[]),l=r.useCallback(u=>{a(R=>({...R,...u}))},[]),o=r.useCallback(u=>{a(R=>R[u]?{...R,[u]:""}:R)},[]),E=r.useCallback(()=>{a({})},[]);return{isError:f,errors:s,changeError:i,changeErrors:l,clearError:o,clearErrors:E}},Z={defaultValues:{},numberFields:[]},le=(s=Z)=>{const{defaultValues:a=Z.defaultValues,numberFields:f=Z.numberFields}=s,{changeError:i,errors:l,changeErrors:o,clearError:E,clearErrors:u,isError:R}=H(),[d,g]=r.useState(!1),[m,v]=r.useState(null),S=r.useRef({}),A=r.useRef(a),O=r.useRef({}),D=r.useRef(()=>{}),j=r.useRef(),J=r.useCallback((n,{shouldDirty:k=!0,shouldOnChange:b=!0}={})=>{let h=n;typeof n=="function"&&(h=n(S.current)),S.current=h;let C=d;k&&(C=be(S.current,A.current),C!==d&&g(C)),b&&D.current(S.current)},[d]),Y=r.useCallback(()=>v(new Date().toString()),[]),z=r.useCallback(()=>{g(!1),u();const n=O.current;Object.keys(n).forEach(k=>{const b=n[k];b(A.current[k],{shouldDirty:!1,shouldOnChange:!1})}),j.current&&j.current.reset(),Y()},[u]),Q=r.useCallback((n,k)=>{const b=O.current;return b[n]=k,()=>b[n]=null},[]),G=r.useCallback(n=>(D.current=n,()=>D.current=()=>{})),X=r.useCallback(n=>se(n.target),[]),I=r.useCallback(n=>n?S.current[n]:S.current,[]),B=r.useCallback(()=>A.current,[]),F=r.useCallback(()=>{setTimeout(()=>j.current.dispatchEvent(new Event("input",{bubbles:!0})))},[]),P=r.useCallback(n=>{const k=se(n.target);k?i(n.target.name,k):i(n.target.name,null)},[i]),M=r.useCallback((n,k,{shouldDirty:b=!0,shouldOnChange:h=!0}={})=>{const C=O.current;switch(typeof n){case"string":{const e=C[n];if(!e)throw new Error(`${n} is uncontrolled, please use Controller for it!`);e(k,{shouldDirty:b,shouldOnChange:h}),h&&F()}break;case"object":Object.entries(n).forEach(([e,t])=>{const c=C[e];if(!c)throw new Error(`${e} is uncontrolled, please use Controller for it!`);c(t,{shouldDirty:b,shouldOnChange:h})}),h&&F();default:return}},[F]),L=r.useCallback(()=>{const n=Object.fromEntries(new FormData(j.current)),k=O.current;return Object.keys(k).map(b=>{n[b]=S.current[b]}),f.forEach(b=>n.hasOwnProperty(b)&&(n[b]=+n[b])),n},[]),W=r.useMemo(()=>({setValue:M,instantChange:F,getDefaultValues:B,getFormState:I,setFormState:J,changeError:i,changeErrors:o,clearError:E,clearErrors:u,loadFormValues:L,checkValidity:P,getFieldValidity:X,registerOnchange:G,reload:Y,reset:z}),[M,F,B,I,J,i,o,E,L,X,P,G,Y,z]);return r.useEffect(()=>{if(j.current){const n=L();A.current={...n,...a},S.current={...n,...a}}},[m]),{ref:j,lastReloadedAt:m,isDirty:d,isError:R,errors:l,numberFields:f,subscribe:Q,actions:W}},Ee={Form:oe,Controller:ce,useForm:le,useValidateForm:H};T.Controller=ce,T.Form=oe,T.default=Ee,T.useForm=le,T.useValidateForm=H,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|