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