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