react-simple-formkit 2.4.6 → 2.4.7
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.
|
@@ -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 ge;function Ae(){if(ge)return ee;ge=1;var o=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function c(
|
|
9
|
+
*/var ge;function Ae(){if(ge)return ee;ge=1;var o=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function c(f,a,d){var u=null;if(d!==void 0&&(u=""+d),a.key!==void 0&&(u=""+a.key),"key"in a){d={};for(var h in a)h!=="key"&&(d[h]=a[h])}else d=a;return a=d.ref,{$$typeof:o,type:f,key:u,ref:a!==void 0?a:null,props:d}}return ee.Fragment=t,ee.jsx=c,ee.jsxs=c,ee}var re={};/**
|
|
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 he;function _e(){return he||(he=1,process.env.NODE_ENV!=="production"&&function(){function o(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===te?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case v:return"Fragment";case S:return"Profiler";case w:return"StrictMode";case x:return"Suspense";case q:return"SuspenseList";case
|
|
17
|
+
*/var he;function _e(){return he||(he=1,process.env.NODE_ENV!=="production"&&function(){function o(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===te?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case v:return"Fragment";case S:return"Profiler";case w:return"StrictMode";case x:return"Suspense";case q:return"SuspenseList";case k:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case p:return"Portal";case A:return(r.displayName||"Context")+".Provider";case T:return(r._context.displayName||"Context")+".Consumer";case P:var g=r.render;return r=r.displayName,r||(r=g.displayName||g.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case z:return g=r.displayName||null,g!==null?g:o(r.type)||"Memo";case G:g=r._payload,r=r._init;try{return o(r(g))}catch{}}return null}function t(r){return""+r}function c(r){try{t(r);var g=!1}catch{g=!0}if(g){g=console;var F=g.error,j=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return F.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",j),t(r)}}function f(r){if(r===v)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===G)return"<...>";try{var g=o(r);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function a(){var r=Z.A;return r===null?null:r.getOwner()}function d(){return Error("react-stack-top-frame")}function u(r){if(se.call(r,"key")){var g=Object.getOwnPropertyDescriptor(r,"key").get;if(g&&g.isReactWarning)return!1}return r.key!==void 0}function h(r,g){function F(){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)",g))}F.isReactWarning=!0,Object.defineProperty(r,"key",{get:F,configurable:!0})}function E(){var r=o(this.type);return ne[r]||(ne[r]=!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.")),r=this.props.ref,r!==void 0?r:null}function C(r,g,F,j,Y,I,X,K){return F=I.ref,r={$$typeof:_,type:r,key:g,props:I,_owner:Y},(F!==void 0?F:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:E}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:K}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function m(r,g,F,j,Y,I,X,K){var O=g.children;if(O!==void 0)if(j)if(le(O)){for(j=0;j<O.length;j++)l(O[j]);Object.freeze&&Object.freeze(O)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else l(O);if(se.call(g,"key")){O=o(r);var L=Object.keys(g).filter(function(ie){return ie!=="key"});j=0<L.length?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}",ue[O+j]||(L=0<L.length?"{"+L.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} />`,j,O,L,O),ue[O+j]=!0)}if(O=null,F!==void 0&&(c(F),O=""+F),u(g)&&(c(g.key),O=""+g.key),"key"in g){F={};for(var Q in g)Q!=="key"&&(F[Q]=g[Q])}else F=g;return O&&h(F,typeof r=="function"?r.displayName||r.name||"Unknown":r),C(r,O,I,Y,a(),F,X,K)}function l(r){typeof r=="object"&&r!==null&&r.$$typeof===_&&r._store&&(r._store.validated=1)}var R=n,_=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),Z=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se=Object.prototype.hasOwnProperty,le=Array.isArray,H=console.createTask?console.createTask:function(){return null};R={"react-stack-bottom-frame":function(r){return r()}};var J,ne={},W=R["react-stack-bottom-frame"].bind(R,f)(),oe=H(i(f)),ue={};re.Fragment=v,re.jsx=function(r,g,F,j,Y){var I=1e4>Z.recentlyCreatedOwnerStacks++;return m(r,g,F,!1,j,Y,I?Error("react-stack-top-frame"):W,I?H(i(r)):oe)},re.jsxs=function(r,g,F,j,Y){var I=1e4>Z.recentlyCreatedOwnerStacks++;return m(r,g,F,!0,j,Y,I?Error("react-stack-top-frame"):W,I?H(i(r)):oe)}}()),re}var Ee;function Oe(){return Ee||(Ee=1,process.env.NODE_ENV==="production"?ae.exports=Ae():ae.exports=_e()),ae.exports}var me=Oe();const y=()=>{},ve=n.createContext({ref:null,watch:y,actions:{subscribe:y,reset:y,trigger:y,reload:y,resetField:y,setValue:y,getValues:y,getErrors:y,getFieldStates:y,getFormState:y,setError:y,clearError:y,clearErrors:y,checkValidity:y,getFieldValidity:y,getDefaultValues:y,setFieldState:y,triggerFieldBlur:y,resetFieldState:y,getControlledFields:y,setFormState:y,getEvents:y,getWatchEvents:y,addGroups:y},registerController:y,registerHookWatcher:y,lastReloadedAt:y,loadFormValues:y,getWatchValue:y,channels:{}}),be=()=>n.useContext(ve),je=({id:o,control:t,method:c,action:i,children:a,onChange:f,onBlur:u,onSubmit:h=()=>{},onInput:E=()=>{},onReset:C=()=>{},numberFields:m=[],className:l,...R})=>{const _=n.useCallback(k=>{t.ref&&(t.ref.current=k,t.ref.current&&t.initForm())},[t]);return n.useEffect(()=>{let k=()=>{},v=()=>{};return f&&(k=t.channels.subscribe("onChange",f)),u&&(v=t.channels.subscribe("onBlur",u)),()=>{k(),v()}},[t.lastReloadedAt]),me.jsx(ve.Provider,{value:t,children:me.jsx("form",{id:o,ref:_,action:i,method:c,className:l,onInput:E,onSubmit:k=>{c||k.preventDefault();const v=t.loadFormValues();h(v)},onChange:k=>{const v=k.target.name;!v||t.actions.getControlledFields().has(v)||t.actions.setValue(v,k.target.value)},onBlur:k=>{const v=k.target.name;if(!v||t.actions.getControlledFields().has(v))return;const w=k.target.value;t.channels.publish("onBlur",v,w,t.actions.getValues()),t.triggerBlurWatchers(v)},onReset:k=>{t.actions.reset(),C(k)},...R,children:a},t.lastReloadedAt)})},de={isDirty:!1,isTouched:!1,error:null},Re={lastReset:null,isDirty:!1,isError:!1,errorFields:[],dirtyFields:[],touchedFields:[]},we={},Pe=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],D=(o={},t="")=>t.split(".").reduce((c,i)=>c&&c[i]!==void 0?c[i]:void 0,o),M=(o={},t="",c)=>{const i=Array.isArray(o)?[...o]:{...o};let a=i;const f=t.split(".");return f.forEach((u,h)=>{h<f.length-1?(a[u]||(a[u]=/^\d+$/.test(f[h+1])?[]:{}),Array.isArray(a[u])?a[u]=[...a[u]]:a[u]={...a[u]},a=a[u]):a[u]=c}),i},Se=o=>{let t=Array.isArray(o)?[...o]:{...o};return Object.keys(t).forEach(c=>{if(c.includes(".")){const i=D(t,c);t=M(t,c,i||""),delete t[c]}}),t},$e=["errors","fieldStates","formState"],U=o=>$e.some(t=>o.startsWith(t))?o:"values."+o,Ce=o=>{typeof o.setCustomValidity=="function"&&o.setCustomValidity("");let t=o.validity,c=Pe.find(i=>t[i]);if(c)return{type:c,message:o.validationMessage}},ye=(o=new Set,t={},c="")=>Object.keys(t||{}).reduce((i,a)=>{const f=(t||{})[a];return o.has(c+a)?[...i,...ye(o,f,c+a+".")]:f!=null&&f.isDirty?[...i,c+a]:i},[]),ke=(o=new Set,t={},c="")=>Object.keys(t||{}).reduce((i,a)=>{const f=(t||{})[a];return o.has(c+a)?[...i,...ke(o,f,c+a+".")]:f!=null&&f.isTouched?[...i,c+a]:i},[]),pe=(o=new Set,t={},c="")=>Object.keys(t||{}).reduce((i,a)=>{const f=(t||{})[a];return o.has(c+a)?[...i,...pe(o,f,c+a+".")]:f?[...i,c+a]:i},[]),Fe=({control:o,name:t,compute:c,mode:i})=>{const{getWatchValue:a,registerHookWatcher:f}=o||be(),u=a({name:t,compute:c}),[h,E]=n.useState(u);return n.useEffect(()=>f({name:t,compute:c,value:h,setValue:E,mode:i}),[]),h},Te=({control:o,name:t,defaultValue:c,shouldUnRegister:i})=>{const{actions:a,registerController:f,channels:u,getWatchValue:h,triggerBlurWatchers:E}=o||be(),C=n.useRef(),m=n.useRef(),l=D(a.getDefaultValues(),t)||c||"",R=Fe({name:t})??l,[_,k]=n.useState({}),v=n.useCallback((S,{shouldDirty:T=!0,shouldOnChange:A=!0}={})=>{var x;let P=S;((x=S==null?void 0:S.target)==null?void 0:x.value)!==void 0&&(P=S.target.value),a.setValue(t,P,{shouldDirty:T,shouldOnChange:A})},[a.setValue]),w=n.useCallback(S=>{const T=a.getValues(),A=S??D(T,t);u.publish("onBlur",t,A,T),E(t)},[]);return n.useEffect(()=>{const S=f(t,{shouldUnRegister:i});return()=>{S&&S(),m.current&&m.current()}},[i,t]),new Proxy({ref:C,name:t,defaultValue:l,value:R,onChange:v,onBlur:w,fieldState:_},{get(S,T,A){return typeof T=="string"&&T==="fieldState"&&(m.current&&m.current(),m.current=a.subscribe(`fieldStates.${t}`,()=>{k(h({name:`fieldStates.${t}`}))})),Reflect.get(S,T,A)}})},Ne=({name:o,control:t,shouldUnRegister:c,defaultValue:i,render:a=({ref:f,name:u,defaultValue:h,value:E,onChange:C,onBlur:m,fieldState:l})=>null})=>{const f=Te({name:o,defaultValue:i,shouldUnRegister:c,control:t});return a(f)},De=()=>{const[o,t]=n.useState(),c=n.useCallback(()=>t(new Date().toString()),[]);return[o,c]},xe=()=>{const[,o]=n.useState({});return n.useCallback(()=>o({}),[])},We=({channels:o,getWatchValue:t})=>{const c=xe(),i=n.useCallback((u,h="onChange")=>{if(!u)return o.subscribeWatch("values",()=>c()),t();if(typeof u=="string"){let E=U(u);h==="onBlur"&&(E=`blur.${E}`),o.subscribeWatch(E,(C,m)=>{C!==m&&c()})}return Array.isArray(u)&&u.forEach(E=>{let C=U(E);h==="onBlur"&&(C=`blur.${C}`),o.subscribeWatch(C,(m,l)=>{m!==l&&c()})}),t({name:u})},[]),a=n.useCallback(({name:u,compute:h,setValue:E,mode:C="onChange"})=>{if(typeof h=="function")return o.subscribe("values",()=>{const l=t({compute:h});E(l)});if(!u)return o.subscribe("values",()=>{E(t())});if(typeof u=="string"){let m=U(u);return C==="onBlur"&&(m=`blur.${m}`),o.subscribe(m,()=>{const R=t({name:u});E(R)})}if(Array.isArray(u)){const m=[];return u.forEach(l=>{let R=U(l);C==="onBlur"&&(R=`blur.${R}`);const _=o.subscribe(R,()=>{const k=t({name:u});E(k)});m.push(_)}),()=>m.forEach(l=>l())}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),f=n.useCallback((u,h,E="onChange")=>{if(!u)return o.subscribe("values",()=>h(t()));if(["onChange","onBlur"].includes(u))return o.subscribe(u,h);if(typeof u=="string"){let C=U(u);return E==="onBlur"&&(C=`blur.${C}`),o.subscribe(C,()=>h(t({name:u})))}if(Array.isArray(u)){const C=[];return u.forEach(m=>{let l=U(m);E==="onBlur"&&(l=`blur.${l}`);const R=o.subscribe(l,()=>{h(t({name:u}))});C.push(R)}),()=>C.forEach(m=>m())}throw new Error("Parameters of name must be string or array of string")},[]);return{watch:i,registerHookWatcher:a,getWatchValue:t,subscribe:f}},Be=({getWatchValue:o})=>{const t=n.useRef(new Map),c=n.useRef(new Map),i=n.useCallback(()=>c.current,[]),a=n.useCallback(()=>t.current,[]),f=n.useCallback(()=>{t.current.clear(),c.current.clear()},[]),u=l=>l.replace("values.","").replace("values",""),h=n.useCallback((l,...R)=>{const _=l.split(".");_.forEach((k,v)=>{const w=_.slice(0,_.length-v).join("."),S=t.current.get(w),T=c.current.get(w);if(v>0){const A=R[0],P=o({name:u(w)});R=[M(P,l.replace(w,""),A)]}S&&S.forEach(A=>A(...R)),T&&T.forEach(A=>A(...R))})},[]),E=n.useCallback((l,{trickle:R=!1,bubble:_=!1})=>{const k=l.split(".");let v=[o({name:u(l)})];k.forEach((w,S)=>{const T=k.slice(0,k.length-S).join("."),A=t.current.get(T),P=c.current.get(T);if(S>0&&_){const x=v[0],q=o({name:u(T)});v=[M(q,l.replace(T,""),x)]}A&&(S===0||_)&&A.forEach(x=>x(...v)),P&&(S===0||_)&&P.forEach(x=>x(...v))}),R&&(t.current.forEach((w,S)=>{S.startsWith(l)&&w.forEach(T=>T(o({name:u(S)})))}),c.current.forEach((w,S)=>{S.startsWith(l)&&w.forEach(T=>T(o({name:u(S)})))}))},[]),C=n.useCallback((l,R)=>(t.current.has(l)||t.current.set(l,new Set),t.current.get(l).add(R),()=>{var _;return(_=t.current.get(l))==null?void 0:_.delete(R)}),[]),m=n.useCallback((l,R)=>{c.current.has(l)||(c.current.set(l,new Set),c.current.get(l).add(R))},[]);return{reset:f,publish:h,subscribe:C,subscribeWatch:m,getEvents:a,getWatchEvents:i,trigger:E}},Ie=({defaultValues:o=we,shouldUnRegister:t=!1,groups:c=[]}={})=>{const[i,a]=De(),f=n.useRef(),u=n.useRef({}),h=n.useRef({}),E=n.useRef({...Re}),C=n.useRef({...o}),m=n.useRef({...o}),l=n.useRef(new Set),R=n.useRef(new Set(c)),_=n.useCallback((e,s=m.current)=>Object.keys(s).reduce((d,b)=>{if(typeof s[b]=="object")return{...d,[b]:_(e,s[b])};const $={...e?{}:h.current[b]||{},...de};return{...d,[b]:$}},{}),[]),k=n.useCallback((e={},{clearCustomFormStates:s=!1,clearCustomFieldStates:d=!1,groups:b=R.current}={})=>{u.current={},m.current={...m.current,...e},C.current={...m.current},l.current=new Set,R.current=new Set(b),E.current={...s?{}:E.current,...Re},h.current=_(d),p.reset(),a()},[]),v=n.useCallback(()=>{let e=Object.fromEntries(new FormData(f.current));l.current.forEach(d=>{e=M(e,d,D(C.current,d))});let s={...C.current,...e};return Se(s)},[]),w=n.useCallback(e=>Ce(e.target),[]),S=n.useCallback(()=>m.current,[]),T=n.useCallback(()=>l.current,[]),A=n.useCallback((e,s)=>s?Array.isArray(s)?s.reduce((d,b)=>({...d,[b]:D(e,b)}),{}):D(e,s):{...e},[]),P=n.useCallback(e=>A(C.current,e),[A]),x=n.useCallback(e=>A(u.current,e),[A]),q=n.useCallback(e=>A(h.current,e),[A]),z=n.useCallback(e=>A({...E.current,lastReset:i},e),[i]),G=n.useCallback(({name:e,compute:s}={})=>!e&&!s||e==="values"?P():typeof s=="function"?s(P()):Array.isArray(e)?e.reduce((d,b)=>({...d,[b]:G({name:b})}),{}):D({...C.current,errors:u.current,fieldStates:h.current,formState:z()},e),[]),p=Be({getWatchValue:G}),{watch:te,registerHookWatcher:Z,subscribe:se}=We({getWatchValue:G,channels:p}),le=n.useCallback((e,s)=>{typeof s=="function"&&(s=s(z(e)));const d=E.current,b=D(d,e);b!==s&&(E.current=M(E.current,e,s),p.publish(`formState.${e}`,s,b))},[]),H=n.useCallback((e,s)=>{typeof s=="function"&&(s=s(x(e))),W(e,"error",s)},[]),J=n.useCallback(e=>{W(e,"error",null)},[]),ne=n.useCallback(()=>{E.current.isError&&Object.keys(u.current).forEach(e=>J(e))},[]),W=n.useCallback((e,s,d)=>{try{if(typeof d=="function"&&(d=d(q(e))),R.current.has(e))if(typeof d=="object"&&d!==null){Object.keys(d).forEach(N=>{W(`${e}.${N}`,s,d[N])});return}else return console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);const b=D(h.current,e)||{...de},$=D(b,s);if($!==d){if(h.current=M(h.current,`${e}.${s}`,d),p.publish(`fieldStates.${e}.${s}`,d,$),s==="error"){const N=D(u.current,e),B=d||null;N!==B&&(u.current=M(u.current,e,B),p.publish(`errors.${e}`,B,N));const V=pe(R.current,u.current);E.current.errorFields=V,p.publish("formState.errorFields",V);const ce=V.length>0;if(E.current.isError!==ce){const fe=E.current.isError;E.current.isError=ce,p.publish("formState.isError",ce,fe)}}if(s==="isDirty"){const N=ye(R.current,h.current);E.current.dirtyFields=N,p.publish("formState.dirtyFields",N);const B=N.length>0;if(E.current.isDirty!==B){const V=E.current.isDirty;E.current.isDirty=B,p.publish("formState.isDirty",B,V)}}if(s==="isTouched"){const N=ke(R.current,h.current);E.current.touchedFields=N,p.publish("formState.touchedFields",N)}}}catch(b){console.log(b)}},[]),oe=n.useCallback(e=>{W(e,"isDirty",!1),W(e,"isTouched",!1),W(e,"error",!1)},[]),ue=n.useCallback(e=>{const s=Ce(e.target);s?H(e.target.name,s):J(e.target.name)},[]),r=n.useCallback((e,s,{shouldDirty:d=!0,shouldOnChange:b=!0}={})=>{if(typeof s=="function"&&(s=s(P(e))),R.current.has(e)){typeof s=="object"&&s!==null?Object.keys(s).forEach(B=>{r(`${e}.${B}`,s[B],{shouldDirty:d,shouldOnChange:b})}):console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);return}const $=D(C.current,e);if(s===$)return;if(C.current=M(C.current,e,s),p.publish(`values.${e}`,s,$),e.includes(".")){const B=e.split("."),V=B.findIndex((ce,fe)=>!R.current.has(B.slice(0,fe+1).join(".")));V!==-1&&(e=B.slice(0,V+1).join("."))}s&&W(e,"isTouched",!0);const N=s!==(D(m.current,e)||"");d&&W(e,"isDirty",N),b&&p.publish("onChange",e,s,$)},[]),g=n.useCallback(e=>{const s=e.split(".");let d="";s.forEach((b,$)=>{$<s.length-1&&(d=d?`${d}.${b}`:b,R.current.add(d))})},[]),F=n.useCallback(e=>{Array.isArray(e)?e.forEach(s=>g(s+".")):g(e+".")},[]),j=n.useCallback((e="",{shouldUnRegister:s=t}={})=>e?(l.current.add(e),h.current=M(h.current,e,{...de}),e.includes(".")&&g(e),()=>{s&&l.current.delete(e)}):console.error("Controller must have a name"),[]),Y=n.useCallback((e,{keepError:s,keepDirty:d,keepTouched:b,defaultValue:$})=>{if(!l.current.has(e))throw new Error(`Cannot reset "${e}" because it's uncontrolled field`);m.current=M(m.current,e,$),C.current=M(C.current,e,$),p.publish(`values.${e}`,$),s||J(e),d||W(e,"isDirty",!1),b||W(e,"isTouched",!1)},[]),I=n.useCallback((e,{bubble:s,trickle:d}={})=>{if(!e)return p.trigger("values",{bubble:s,trickle:d??!0});if(!Array.isArray(e)){const b=U(e);p.trigger(b,{bubble:s,trickle:d});return}e.forEach(b=>{const $=U(b);p.trigger($,{bubble:s,trickle:d})})},[]),X=n.useCallback(e=>{p.publish(`blur.values.${e}`,P(e)),p.publish(`blur.errors.${e}`,x(e));const s=q(e);Object.keys(s||{}).forEach(b=>{p.publish(`blur.fieldStates.${e}.${b}`,s[b])});const d=z();Object.keys(d||{}).forEach(b=>{p.publish(`blur.formState.${b}`,d[b])})},[]),K=n.useCallback((e,s=P(e))=>{p.publish("onBlur",e,s,P()),X(e)},[]),O=n.useMemo(()=>({subscribe:se,reset:k,trigger:I,reload:a,resetField:Y,setValue:r,getValues:P,getErrors:x,getFieldStates:q,getFormState:z,setError:H,clearError:J,clearErrors:ne,checkValidity:ue,getFieldValidity:w,getDefaultValues:S,setFieldState:W,triggerFieldBlur:K,resetFieldState:oe,getControlledFields:T,setFormState:le,getEvents:p.getEvents,getWatchEvents:p.getWatchEvents,addGroups:F}),[i]),L=n.useCallback(()=>{[...f.current.querySelectorAll("[name]")].forEach(d=>{const b=d.name||"";b.includes(".")&&g(b),!d.defaultValue&&!l.current.has(b)&&D(m.current,b)&&(d.defaultValue=D(m.current,b))});const s=v();C.current={...s},m.current={...s}},[]),Q=n.useMemo(()=>({ref:f,watch:te,actions:O,initForm:L,registerController:j,registerHookWatcher:Z,lastReloadedAt:i,loadFormValues:v,getWatchValue:G,triggerBlurWatchers:X,channels:p}),[i]),ie=n.useMemo(()=>({control:Q,actions:O,watch:te}),[i]);return n.useLayoutEffect(()=>{f.current&&L()},[i]),n.useLayoutEffect(()=>{h.current=_(!1)},[]),ie};exports.Controller=Ne;exports.Form=je;exports.restoreFromDotNotation=Se;exports.useController=Te;exports.useForm=Ie;exports.useFormContext=be;exports.useWatch=Fe;
|
|
22
|
+
<%s key={someKey} {...props} />`,j,O,L,O),ue[O+j]=!0)}if(O=null,F!==void 0&&(c(F),O=""+F),u(g)&&(c(g.key),O=""+g.key),"key"in g){F={};for(var Q in g)Q!=="key"&&(F[Q]=g[Q])}else F=g;return O&&h(F,typeof r=="function"?r.displayName||r.name||"Unknown":r),C(r,O,I,Y,a(),F,X,K)}function l(r){typeof r=="object"&&r!==null&&r.$$typeof===_&&r._store&&(r._store.validated=1)}var R=n,_=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),Z=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se=Object.prototype.hasOwnProperty,le=Array.isArray,H=console.createTask?console.createTask:function(){return null};R={"react-stack-bottom-frame":function(r){return r()}};var J,ne={},W=R["react-stack-bottom-frame"].bind(R,d)(),oe=H(f(d)),ue={};re.Fragment=v,re.jsx=function(r,g,F,j,Y){var I=1e4>Z.recentlyCreatedOwnerStacks++;return m(r,g,F,!1,j,Y,I?Error("react-stack-top-frame"):W,I?H(f(r)):oe)},re.jsxs=function(r,g,F,j,Y){var I=1e4>Z.recentlyCreatedOwnerStacks++;return m(r,g,F,!0,j,Y,I?Error("react-stack-top-frame"):W,I?H(f(r)):oe)}}()),re}var Ee;function Oe(){return Ee||(Ee=1,process.env.NODE_ENV==="production"?ae.exports=Ae():ae.exports=_e()),ae.exports}var me=Oe();const y=()=>{},ve=n.createContext({ref:null,watch:y,actions:{subscribe:y,reset:y,trigger:y,reload:y,resetField:y,setValue:y,getValues:y,getErrors:y,getFieldStates:y,getFormState:y,setError:y,clearError:y,clearErrors:y,checkValidity:y,getFieldValidity:y,getDefaultValues:y,setFieldState:y,triggerFieldBlur:y,resetFieldState:y,getControlledFields:y,setFormState:y,getEvents:y,getWatchEvents:y,addGroups:y},registerController:y,registerHookWatcher:y,lastReloadedAt:y,loadFormValues:y,getWatchValue:y,channels:{}}),be=()=>n.useContext(ve),je=({id:o,control:t,method:c,action:f,children:a,onChange:d,onBlur:u,onSubmit:h=()=>{},onInput:E=()=>{},onReset:C=()=>{},numberFields:m=[],className:l,...R})=>{const _=n.useCallback(p=>{t.ref&&(t.ref.current=p,t.ref.current&&t.initForm())},[t]);return n.useEffect(()=>{let p=()=>{},v=()=>{};return d&&(p=t.channels.subscribe("onChange",d)),u&&(v=t.channels.subscribe("onBlur",u)),()=>{p(),v()}},[t.lastReloadedAt]),me.jsx(ve.Provider,{value:t,children:me.jsx("form",{id:o,ref:_,action:f,method:c,className:l,onInput:E,onSubmit:p=>{c||p.preventDefault();const v=t.loadFormValues();h(v)},onChange:p=>{const v=p.target.name;!v||t.actions.getControlledFields().has(v)||t.actions.setValue(v,p.target.value)},onBlur:p=>{const v=p.target.name;if(!v||t.actions.getControlledFields().has(v))return;const w=p.target.value;t.channels.publish("onBlur",v,w,t.actions.getValues()),t.triggerBlurWatchers(v)},onReset:p=>{t.actions.reset(),C(p)},...R,children:a},t.lastReloadedAt)})},de={isDirty:!1,isTouched:!1,error:null},Re={lastReset:null,isDirty:!1,isError:!1,errorFields:[],dirtyFields:[],touchedFields:[]},we={},Pe=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],D=(o={},t="")=>t.split(".").reduce((c,f)=>c&&c[f]!==void 0?c[f]:void 0,o),M=(o={},t="",c)=>{const f=Array.isArray(o)?[...o]:{...o};let a=f;const d=t.split(".");return d.forEach((u,h)=>{h<d.length-1?(a[u]||(a[u]=/^\d+$/.test(d[h+1])?[]:{}),Array.isArray(a[u])?a[u]=[...a[u]]:a[u]={...a[u]},a=a[u]):a[u]=c}),f},Se=o=>{let t=Array.isArray(o)?[...o]:{...o};return Object.keys(t).forEach(c=>{if(c.includes(".")){const f=D(t,c);t=M(t,c,f||""),delete t[c]}}),t},$e=["errors","fieldStates","formState"],U=o=>$e.some(t=>o.startsWith(t))?o:"values."+o,Ce=o=>{typeof o.setCustomValidity=="function"&&o.setCustomValidity("");let t=o.validity,c=Pe.find(f=>t[f]);if(c)return{type:c,message:o.validationMessage}},ye=(o=new Set,t={},c="")=>Object.keys(t||{}).reduce((f,a)=>{const d=(t||{})[a];return o.has(c+a)?[...f,...ye(o,d,c+a+".")]:d!=null&&d.isDirty?[...f,c+a]:f},[]),ke=(o=new Set,t={},c="")=>Object.keys(t||{}).reduce((f,a)=>{const d=(t||{})[a];return o.has(c+a)?[...f,...ke(o,d,c+a+".")]:d!=null&&d.isTouched?[...f,c+a]:f},[]),pe=(o=new Set,t={},c="")=>Object.keys(t||{}).reduce((f,a)=>{const d=(t||{})[a];return o.has(c+a)?[...f,...pe(o,d,c+a+".")]:d?[...f,c+a]:f},[]),Fe=({control:o,name:t,compute:c,mode:f})=>{const{getWatchValue:a,registerHookWatcher:d}=o||be(),u=a({name:t,compute:c}),[h,E]=n.useState(u);return n.useEffect(()=>d({name:t,compute:c,value:h,setValue:E,mode:f}),[]),h},Te=({control:o,name:t,defaultValue:c,shouldUnRegister:f})=>{const{actions:a,registerController:d,channels:u,getWatchValue:h,triggerBlurWatchers:E}=o||be(),C=n.useRef(),m=n.useRef(),l=D(a.getDefaultValues(),t)||c||"",R=Fe({name:t})??l,[_,p]=n.useState({}),v=n.useCallback((S,{shouldDirty:T=!0,shouldOnChange:A=!0}={})=>{var x;let P=S;((x=S==null?void 0:S.target)==null?void 0:x.value)!==void 0&&(P=S.target.value),a.setValue(t,P,{shouldDirty:T,shouldOnChange:A})},[a.setValue]),w=n.useCallback(S=>{const T=a.getValues(),A=S??D(T,t);u.publish("onBlur",t,A,T),E(t)},[]);return n.useEffect(()=>{const S=d(t,{shouldUnRegister:f});return()=>{S&&S(),m.current&&m.current()}},[f,t]),new Proxy({ref:C,name:t,defaultValue:l,value:R,onChange:v,onBlur:w,fieldState:_},{get(S,T,A){return typeof T=="string"&&T==="fieldState"&&(m.current&&m.current(),m.current=a.subscribe(`fieldStates.${t}`,()=>{p(h({name:`fieldStates.${t}`}))})),Reflect.get(S,T,A)}})},Ne=({name:o,control:t,shouldUnRegister:c,defaultValue:f,render:a=({ref:d,name:u,defaultValue:h,value:E,onChange:C,onBlur:m,fieldState:l})=>null})=>{const d=Te({name:o,defaultValue:f,shouldUnRegister:c,control:t});return a(d)},De=()=>{const[o,t]=n.useState(),c=n.useCallback(()=>t(new Date().toString()),[]);return[o,c]},xe=()=>{const[,o]=n.useState({});return n.useCallback(()=>o({}),[])},We=({channels:o,getWatchValue:t})=>{const c=xe(),f=n.useCallback((u,h="onChange")=>{if(!u)return o.subscribeWatch("values",()=>c()),t();if(typeof u=="string"){let E=U(u);h==="onBlur"&&(E=`blur.${E}`),o.subscribeWatch(E,(C,m)=>{C!==m&&c()})}return Array.isArray(u)&&u.forEach(E=>{let C=U(E);h==="onBlur"&&(C=`blur.${C}`),o.subscribeWatch(C,(m,l)=>{m!==l&&c()})}),t({name:u})},[]),a=n.useCallback(({name:u,compute:h,setValue:E,mode:C="onChange"})=>{if(typeof h=="function")return o.subscribe("values",()=>{const l=t({compute:h});E(l)});if(!u)return o.subscribe("values",()=>{E(t())});if(typeof u=="string"){let m=U(u);return C==="onBlur"&&(m=`blur.${m}`),o.subscribe(m,()=>{const R=t({name:u});E(R)})}if(Array.isArray(u)){const m=[];return u.forEach(l=>{let R=U(l);C==="onBlur"&&(R=`blur.${R}`);const _=o.subscribe(R,()=>{const p=t({name:u});E(p)});m.push(_)}),()=>m.forEach(l=>l())}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),d=n.useCallback((u,h,E="onChange")=>{if(!u)return o.subscribe("values",()=>h(t()));if(["onChange","onBlur"].includes(u))return o.subscribe(u,h);if(typeof u=="string"){let C=U(u);return E==="onBlur"&&(C=`blur.${C}`),o.subscribe(C,()=>h(t({name:u})))}if(Array.isArray(u)){const C=[];return u.forEach(m=>{let l=U(m);E==="onBlur"&&(l=`blur.${l}`);const R=o.subscribe(l,()=>{h(t({name:u}))});C.push(R)}),()=>C.forEach(m=>m())}throw new Error("Parameters of name must be string or array of string")},[]);return{watch:f,registerHookWatcher:a,getWatchValue:t,subscribe:d}},Be=({getWatchValue:o})=>{const t=n.useRef(new Map),c=n.useRef(new Map),f=n.useCallback(()=>c.current,[]),a=n.useCallback(()=>t.current,[]),d=n.useCallback(()=>{t.current.clear(),c.current.clear()},[]),u=l=>l.replace("values.","").replace("values",""),h=n.useCallback((l,...R)=>{const _=l.split(".");_.forEach((p,v)=>{const w=_.slice(0,_.length-v).join("."),S=t.current.get(w),T=c.current.get(w);if(v>0){const A=R[0],P=o({name:u(w)});R=[M(P,l.replace(w,""),A)]}S&&S.forEach(A=>A(...R)),T&&T.forEach(A=>A(...R))})},[]),E=n.useCallback((l,{trickle:R=!1,bubble:_=!1})=>{const p=l.split(".");let v=[o({name:u(l)})];p.forEach((w,S)=>{const T=p.slice(0,p.length-S).join("."),A=t.current.get(T),P=c.current.get(T);if(S>0&&_){const x=v[0],q=o({name:u(T)});v=[M(q,l.replace(T,""),x)]}A&&(S===0||_)&&A.forEach(x=>x(...v)),P&&(S===0||_)&&P.forEach(x=>x(...v))}),R&&(t.current.forEach((w,S)=>{S.startsWith(l)&&w.forEach(T=>T(o({name:u(S)})))}),c.current.forEach((w,S)=>{S.startsWith(l)&&w.forEach(T=>T(o({name:u(S)})))}))},[]),C=n.useCallback((l,R)=>(t.current.has(l)||t.current.set(l,new Set),t.current.get(l).add(R),()=>{var _;return(_=t.current.get(l))==null?void 0:_.delete(R)}),[]),m=n.useCallback((l,R)=>{c.current.has(l)||(c.current.set(l,new Set),c.current.get(l).add(R))},[]);return{reset:d,publish:h,subscribe:C,subscribeWatch:m,getEvents:a,getWatchEvents:f,trigger:E}},Ie=({defaultValues:o=we,shouldUnRegister:t=!1,groups:c=[]}={})=>{const[f,a]=De(),d=n.useRef(),u=n.useRef({}),h=n.useRef({}),E=n.useRef({...Re}),C=n.useRef({...o}),m=n.useRef({...o}),l=n.useRef(new Set),R=n.useRef(new Set(c)),_=n.useCallback((e,s=m.current)=>Object.keys(s).reduce((i,b)=>{if(typeof s[b]=="object")return{...i,[b]:_(e,s[b])};const $={...e?{}:h.current[b]||{},...de};return{...i,[b]:$}},{}),[]),p=n.useCallback((e={},{clearCustomFormStates:s=!1,clearCustomFieldStates:i=!1,groups:b=R.current}={})=>{u.current={},m.current={...m.current,...e},C.current={...m.current},l.current=new Set,R.current=new Set(b),E.current={...s?{}:E.current,...Re},h.current=_(i),k.reset(),a()},[]),v=n.useCallback(()=>{let e=Object.fromEntries(new FormData(d.current));l.current.forEach(i=>{e=M(e,i,D(C.current,i))});let s={...C.current,...e};return Se(s)},[]),w=n.useCallback(e=>Ce(e.target),[]),S=n.useCallback(()=>m.current,[]),T=n.useCallback(()=>l.current,[]),A=n.useCallback((e,s)=>s?Array.isArray(s)?s.reduce((i,b)=>({...i,[b]:D(e,b)}),{}):D(e,s):{...e},[]),P=n.useCallback(e=>A(C.current,e),[A]),x=n.useCallback(e=>A(u.current,e),[A]),q=n.useCallback(e=>A(h.current,e),[A]),z=n.useCallback(e=>A({...E.current,lastReset:f},e),[f]),G=n.useCallback(({name:e,compute:s}={})=>!e&&!s||e==="values"?P():typeof s=="function"?s(P()):Array.isArray(e)?e.reduce((i,b)=>({...i,[b]:G({name:b})}),{}):D({...C.current,errors:u.current,fieldStates:h.current,formState:z()},e),[]),k=Be({getWatchValue:G}),{watch:te,registerHookWatcher:Z,subscribe:se}=We({getWatchValue:G,channels:k}),le=n.useCallback((e,s)=>{typeof s=="function"&&(s=s(z(e)));const i=E.current,b=D(i,e);b!==s&&(E.current=M(E.current,e,s),k.publish(`formState.${e}`,s,b))},[]),H=n.useCallback((e,s)=>{typeof s=="function"&&(s=s(x(e))),W(e,"error",s)},[]),J=n.useCallback(e=>{W(e,"error",null)},[]),ne=n.useCallback(()=>{E.current.isError&&Object.keys(u.current).forEach(e=>J(e))},[]),W=n.useCallback((e,s,i)=>{try{if(typeof i=="function"&&(i=i(q(e))),R.current.has(e))if(typeof i=="object"&&i!==null){Object.keys(i).forEach(N=>{W(`${e}.${N}`,s,i[N])});return}else return console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);const b=D(h.current,e)||{...de},$=D(b,s);if($!==i){if(h.current=M(h.current,`${e}.${s}`,i),k.publish(`fieldStates.${e}.${s}`,i,$),s==="error"){const N=D(u.current,e),B=i||null;N!==B&&(u.current=M(u.current,e,B),k.publish(`errors.${e}`,B,N));const V=pe(R.current,u.current);E.current.errorFields=V,k.publish("formState.errorFields",V);const ce=V.length>0;if(E.current.isError!==ce){const fe=E.current.isError;E.current.isError=ce,k.publish("formState.isError",ce,fe)}}if(s==="isDirty"){const N=ye(R.current,h.current);E.current.dirtyFields=N,k.publish("formState.dirtyFields",N);const B=N.length>0;if(E.current.isDirty!==B){const V=E.current.isDirty;E.current.isDirty=B,k.publish("formState.isDirty",B,V)}}if(s==="isTouched"){const N=ke(R.current,h.current);E.current.touchedFields=N,k.publish("formState.touchedFields",N)}}}catch(b){console.log(b)}},[]),oe=n.useCallback(e=>{W(e,"isDirty",!1),W(e,"isTouched",!1),W(e,"error",null)},[]),ue=n.useCallback(e=>{const s=Ce(e.target);s?H(e.target.name,s):J(e.target.name)},[]),r=n.useCallback((e,s,{shouldDirty:i=!0,shouldOnChange:b=!0}={})=>{if(typeof s=="function"&&(s=s(P(e))),R.current.has(e)){typeof s=="object"&&s!==null?Object.keys(s).forEach(B=>{r(`${e}.${B}`,s[B],{shouldDirty:i,shouldOnChange:b})}):console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);return}const $=D(C.current,e);if(s===$)return;if(C.current=M(C.current,e,s),k.publish(`values.${e}`,s,$),e.includes(".")){const B=e.split("."),V=B.findIndex((ce,fe)=>!R.current.has(B.slice(0,fe+1).join(".")));V!==-1&&(e=B.slice(0,V+1).join("."))}s&&W(e,"isTouched",!0);const N=s!==(D(m.current,e)||"");i&&W(e,"isDirty",N),b&&k.publish("onChange",e,s,$)},[]),g=n.useCallback(e=>{const s=e.split(".");let i="";s.forEach((b,$)=>{$<s.length-1&&(i=i?`${i}.${b}`:b,R.current.add(i))})},[]),F=n.useCallback(e=>{Array.isArray(e)?e.forEach(s=>g(s+".")):g(e+".")},[]),j=n.useCallback((e="",{shouldUnRegister:s=t}={})=>e?(l.current.add(e),h.current=M(h.current,e,{...de}),e.includes(".")&&g(e),()=>{s&&(r(e,void 0,{shouldDirty:!1,shouldOnChange:!1}),l.current.delete(e))}):console.error("Controller must have a name"),[]),Y=n.useCallback((e,{keepError:s,keepDirty:i,keepTouched:b,defaultValue:$})=>{if(!l.current.has(e))throw new Error(`Cannot reset "${e}" because it's uncontrolled field`);m.current=M(m.current,e,$),C.current=M(C.current,e,$),k.publish(`values.${e}`,$),s||J(e),i||W(e,"isDirty",!1),b||W(e,"isTouched",!1)},[]),I=n.useCallback((e,{bubble:s,trickle:i}={})=>{if(!e){k.trigger("values",{bubble:s,trickle:i??!0}),k.trigger("blur.values",{bubble:s,trickle:i??!0});return}if(!Array.isArray(e)){const b=U(e);k.trigger(b,{bubble:s,trickle:i}),k.trigger(`blur.${b}`,{bubble:s,trickle:i});return}e.forEach(b=>{const $=U(b);k.trigger($,{bubble:s,trickle:i}),k.trigger(`blur.${$}`,{bubble:s,trickle:i})})},[]),X=n.useCallback(e=>{k.publish(`blur.values.${e}`,P(e)),k.publish(`blur.errors.${e}`,x(e));const s=q(e);Object.keys(s||{}).forEach(b=>{k.publish(`blur.fieldStates.${e}.${b}`,s[b])});const i=z();Object.keys(i||{}).forEach(b=>{k.publish(`blur.formState.${b}`,i[b])})},[]),K=n.useCallback((e,s=P(e))=>{k.publish("onBlur",e,s,P()),X(e)},[]),O=n.useMemo(()=>({subscribe:se,reset:p,trigger:I,reload:a,resetField:Y,setValue:r,getValues:P,getErrors:x,getFieldStates:q,getFormState:z,setError:H,clearError:J,clearErrors:ne,checkValidity:ue,getFieldValidity:w,getDefaultValues:S,setFieldState:W,triggerFieldBlur:K,resetFieldState:oe,getControlledFields:T,setFormState:le,getEvents:k.getEvents,getWatchEvents:k.getWatchEvents,addGroups:F}),[f]),L=n.useCallback(()=>{[...d.current.querySelectorAll("[name]")].forEach(i=>{const b=i.name||"";b.includes(".")&&g(b),!i.defaultValue&&!l.current.has(b)&&D(m.current,b)&&(i.defaultValue=D(m.current,b))});const s=v();C.current={...s},m.current={...s}},[]),Q=n.useMemo(()=>({ref:d,watch:te,actions:O,initForm:L,registerController:j,registerHookWatcher:Z,lastReloadedAt:f,loadFormValues:v,getWatchValue:G,triggerBlurWatchers:X,channels:k}),[f]),ie=n.useMemo(()=>({control:Q,actions:O,watch:te}),[f]);return n.useLayoutEffect(()=>{d.current&&L()},[f]),n.useLayoutEffect(()=>{h.current=_(!1)},[]),ie};exports.Controller=Ne;exports.Form=je;exports.restoreFromDotNotation=Se;exports.useController=Te;exports.useForm=Ie;exports.useFormContext=be;exports.useWatch=Fe;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import jr, { createContext as wr, useContext as
|
|
1
|
+
import jr, { createContext as wr, useContext as $r, useCallback as h, useEffect as Er, useState as lr, useRef as Y, useMemo as hr, useLayoutEffect as mr } from "react";
|
|
2
2
|
var ir = { exports: {} }, er = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -10,23 +10,23 @@ var ir = { exports: {} }, er = {};
|
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
12
|
var vr;
|
|
13
|
-
function
|
|
13
|
+
function Pr() {
|
|
14
14
|
if (vr) return er;
|
|
15
15
|
vr = 1;
|
|
16
16
|
var s = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
|
|
17
|
-
function u(
|
|
17
|
+
function u(l, c, f) {
|
|
18
18
|
var o = null;
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
for (var
|
|
22
|
-
|
|
23
|
-
} else
|
|
24
|
-
return c =
|
|
19
|
+
if (f !== void 0 && (o = "" + f), c.key !== void 0 && (o = "" + c.key), "key" in c) {
|
|
20
|
+
f = {};
|
|
21
|
+
for (var b in c)
|
|
22
|
+
b !== "key" && (f[b] = c[b]);
|
|
23
|
+
} else f = c;
|
|
24
|
+
return c = f.ref, {
|
|
25
25
|
$$typeof: s,
|
|
26
|
-
type:
|
|
26
|
+
type: l,
|
|
27
27
|
key: o,
|
|
28
28
|
ref: c !== void 0 ? c : null,
|
|
29
|
-
props:
|
|
29
|
+
props: f
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
return er.Fragment = t, er.jsx = u, er.jsxs = u, er;
|
|
@@ -54,26 +54,26 @@ function kr() {
|
|
|
54
54
|
return "Fragment";
|
|
55
55
|
case y:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case $:
|
|
58
58
|
return "StrictMode";
|
|
59
59
|
case x:
|
|
60
60
|
return "Suspense";
|
|
61
61
|
case q:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case F:
|
|
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 A:
|
|
71
71
|
return "Portal";
|
|
72
72
|
case O:
|
|
73
73
|
return (e.displayName || "Context") + ".Provider";
|
|
74
74
|
case _:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
76
|
+
case P:
|
|
77
77
|
var g = e.render;
|
|
78
78
|
return e = e.displayName, e || (e = g.displayName || g.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
79
|
case H:
|
|
@@ -107,7 +107,7 @@ function kr() {
|
|
|
107
107
|
), t(e);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function l(e) {
|
|
111
111
|
if (e === S) return "<>";
|
|
112
112
|
if (typeof e == "object" && e !== null && e.$$typeof === J)
|
|
113
113
|
return "<...>";
|
|
@@ -122,7 +122,7 @@ function kr() {
|
|
|
122
122
|
var e = K.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function f() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
128
|
function o(e) {
|
|
@@ -132,7 +132,7 @@ function kr() {
|
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function b(e, g) {
|
|
136
136
|
function T() {
|
|
137
137
|
z || (z = !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)",
|
|
@@ -218,7 +218,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
218
218
|
for (var rr in g)
|
|
219
219
|
rr !== "key" && (T[rr] = g[rr]);
|
|
220
220
|
} else T = g;
|
|
221
|
-
return j &&
|
|
221
|
+
return j && b(
|
|
222
222
|
T,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
224
|
), R(
|
|
@@ -235,7 +235,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
235
235
|
function a(e) {
|
|
236
236
|
typeof e == "object" && e !== null && e.$$typeof === C && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var v = jr, C = Symbol.for("react.transitional.element"),
|
|
238
|
+
var v = jr, C = Symbol.for("react.transitional.element"), A = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), O = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), x = Symbol.for("react.suspense"), q = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), J = Symbol.for("react.lazy"), F = Symbol.for("react.activity"), nr = Symbol.for("react.client.reference"), K = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, sr = Object.prototype.hasOwnProperty, fr = Array.isArray, X = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
241
|
v = {
|
|
@@ -245,8 +245,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
245
245
|
};
|
|
246
246
|
var z, or = {}, W = v["react-stack-bottom-frame"].bind(
|
|
247
247
|
v,
|
|
248
|
-
|
|
249
|
-
)(), ur = X(
|
|
248
|
+
f
|
|
249
|
+
)(), ur = X(l(f)), cr = {};
|
|
250
250
|
tr.Fragment = S, tr.jsx = function(e, g, T, w, L) {
|
|
251
251
|
var I = 1e4 > K.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return m(
|
|
@@ -257,7 +257,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
257
257
|
w,
|
|
258
258
|
L,
|
|
259
259
|
I ? Error("react-stack-top-frame") : W,
|
|
260
|
-
I ? X(
|
|
260
|
+
I ? X(l(e)) : ur
|
|
261
261
|
);
|
|
262
262
|
}, tr.jsxs = function(e, g, T, w, L) {
|
|
263
263
|
var I = 1e4 > K.recentlyCreatedOwnerStacks++;
|
|
@@ -269,14 +269,14 @@ React keys must be passed directly to JSX without using spread:
|
|
|
269
269
|
w,
|
|
270
270
|
L,
|
|
271
271
|
I ? Error("react-stack-top-frame") : W,
|
|
272
|
-
I ? X(
|
|
272
|
+
I ? X(l(e)) : ur
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}()), tr;
|
|
276
276
|
}
|
|
277
277
|
var Sr;
|
|
278
278
|
function Nr() {
|
|
279
|
-
return Sr || (Sr = 1, process.env.NODE_ENV === "production" ? ir.exports =
|
|
279
|
+
return Sr || (Sr = 1, process.env.NODE_ENV === "production" ? ir.exports = Pr() : ir.exports = kr()), ir.exports;
|
|
280
280
|
}
|
|
281
281
|
var yr = Nr();
|
|
282
282
|
const p = () => {
|
|
@@ -315,15 +315,15 @@ const p = () => {
|
|
|
315
315
|
loadFormValues: p,
|
|
316
316
|
getWatchValue: p,
|
|
317
317
|
channels: {}
|
|
318
|
-
}), Tr = () =>
|
|
318
|
+
}), Tr = () => $r(Ar), qr = ({
|
|
319
319
|
id: s,
|
|
320
320
|
control: t,
|
|
321
321
|
method: u,
|
|
322
|
-
action:
|
|
322
|
+
action: l,
|
|
323
323
|
children: c,
|
|
324
|
-
onChange:
|
|
324
|
+
onChange: f,
|
|
325
325
|
onBlur: o,
|
|
326
|
-
onSubmit:
|
|
326
|
+
onSubmit: b = () => {
|
|
327
327
|
},
|
|
328
328
|
onInput: E = () => {
|
|
329
329
|
},
|
|
@@ -333,52 +333,52 @@ const p = () => {
|
|
|
333
333
|
className: a,
|
|
334
334
|
...v
|
|
335
335
|
}) => {
|
|
336
|
-
const C =
|
|
337
|
-
(
|
|
338
|
-
t.ref && (t.ref.current =
|
|
336
|
+
const C = h(
|
|
337
|
+
(A) => {
|
|
338
|
+
t.ref && (t.ref.current = A, t.ref.current && t.initForm());
|
|
339
339
|
},
|
|
340
340
|
[t]
|
|
341
341
|
);
|
|
342
342
|
return Er(() => {
|
|
343
|
-
let
|
|
343
|
+
let A = () => {
|
|
344
344
|
}, S = () => {
|
|
345
345
|
};
|
|
346
|
-
return
|
|
347
|
-
|
|
346
|
+
return f && (A = t.channels.subscribe("onChange", f)), o && (S = t.channels.subscribe("onBlur", o)), () => {
|
|
347
|
+
A(), S();
|
|
348
348
|
};
|
|
349
349
|
}, [t.lastReloadedAt]), /* @__PURE__ */ yr.jsx(Ar.Provider, { value: t, children: /* @__PURE__ */ yr.jsx(
|
|
350
350
|
"form",
|
|
351
351
|
{
|
|
352
352
|
id: s,
|
|
353
353
|
ref: C,
|
|
354
|
-
action:
|
|
354
|
+
action: l,
|
|
355
355
|
method: u,
|
|
356
356
|
className: a,
|
|
357
357
|
onInput: E,
|
|
358
|
-
onSubmit: (
|
|
359
|
-
u ||
|
|
358
|
+
onSubmit: (A) => {
|
|
359
|
+
u || A.preventDefault();
|
|
360
360
|
const S = t.loadFormValues();
|
|
361
|
-
|
|
361
|
+
b(S);
|
|
362
362
|
},
|
|
363
|
-
onChange: (
|
|
364
|
-
const S =
|
|
365
|
-
!S || t.actions.getControlledFields().has(S) || t.actions.setValue(S,
|
|
363
|
+
onChange: (A) => {
|
|
364
|
+
const S = A.target.name;
|
|
365
|
+
!S || t.actions.getControlledFields().has(S) || t.actions.setValue(S, A.target.value);
|
|
366
366
|
},
|
|
367
|
-
onBlur: (
|
|
368
|
-
const S =
|
|
367
|
+
onBlur: (A) => {
|
|
368
|
+
const S = A.target.name;
|
|
369
369
|
if (!S || t.actions.getControlledFields().has(S)) return;
|
|
370
|
-
const
|
|
371
|
-
t.channels.publish("onBlur", S,
|
|
370
|
+
const $ = A.target.value;
|
|
371
|
+
t.channels.publish("onBlur", S, $, t.actions.getValues()), t.triggerBlurWatchers(S);
|
|
372
372
|
},
|
|
373
|
-
onReset: (
|
|
374
|
-
t.actions.reset(), R(
|
|
373
|
+
onReset: (A) => {
|
|
374
|
+
t.actions.reset(), R(A);
|
|
375
375
|
},
|
|
376
376
|
...v,
|
|
377
377
|
children: c
|
|
378
378
|
},
|
|
379
379
|
t.lastReloadedAt
|
|
380
380
|
) });
|
|
381
|
-
},
|
|
381
|
+
}, br = { isDirty: !1, isTouched: !1, error: null }, pr = {
|
|
382
382
|
lastReset: null,
|
|
383
383
|
isDirty: !1,
|
|
384
384
|
isError: !1,
|
|
@@ -396,60 +396,60 @@ const p = () => {
|
|
|
396
396
|
"tooShort",
|
|
397
397
|
"typeMismatch",
|
|
398
398
|
"valueMissing"
|
|
399
|
-
], D = (s = {}, t = "") => t.split(".").reduce((u,
|
|
400
|
-
const
|
|
401
|
-
let c =
|
|
402
|
-
const
|
|
403
|
-
return
|
|
404
|
-
|
|
405
|
-
}),
|
|
399
|
+
], D = (s = {}, t = "") => t.split(".").reduce((u, l) => u && u[l] !== void 0 ? u[l] : void 0, s), M = (s = {}, t = "", u) => {
|
|
400
|
+
const l = Array.isArray(s) ? [...s] : { ...s };
|
|
401
|
+
let c = l;
|
|
402
|
+
const f = t.split(".");
|
|
403
|
+
return f.forEach((o, b) => {
|
|
404
|
+
b < f.length - 1 ? (c[o] || (c[o] = /^\d+$/.test(f[b + 1]) ? [] : {}), Array.isArray(c[o]) ? c[o] = [...c[o]] : c[o] = { ...c[o] }, c = c[o]) : c[o] = u;
|
|
405
|
+
}), l;
|
|
406
406
|
}, Wr = (s) => {
|
|
407
407
|
let t = Array.isArray(s) ? [...s] : { ...s };
|
|
408
408
|
return Object.keys(t).forEach((u) => {
|
|
409
409
|
if (u.includes(".")) {
|
|
410
|
-
const
|
|
411
|
-
t = M(t, u,
|
|
410
|
+
const l = D(t, u);
|
|
411
|
+
t = M(t, u, l || ""), delete t[u];
|
|
412
412
|
}
|
|
413
413
|
}), t;
|
|
414
414
|
}, Br = ["errors", "fieldStates", "formState"], G = (s) => Br.some((t) => s.startsWith(t)) ? s : "values." + s, Fr = (s) => {
|
|
415
415
|
typeof s.setCustomValidity == "function" && s.setCustomValidity("");
|
|
416
|
-
let t = s.validity, u = xr.find((
|
|
416
|
+
let t = s.validity, u = xr.find((l) => t[l]);
|
|
417
417
|
if (u) return { type: u, message: s.validationMessage };
|
|
418
|
-
}, _r = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((
|
|
419
|
-
const
|
|
420
|
-
return s.has(u + c) ? [...
|
|
421
|
-
}, []), Or = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((
|
|
422
|
-
const
|
|
423
|
-
return s.has(u + c) ? [...
|
|
424
|
-
}, []), Cr = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((
|
|
425
|
-
const
|
|
426
|
-
return s.has(u + c) ? [...
|
|
427
|
-
}, []), Ir = ({ control: s, name: t, compute: u, mode:
|
|
428
|
-
const { getWatchValue: c, registerHookWatcher:
|
|
429
|
-
return Er(() =>
|
|
430
|
-
}, Yr = ({ control: s, name: t, defaultValue: u, shouldUnRegister:
|
|
431
|
-
const { actions: c, registerController:
|
|
418
|
+
}, _r = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((l, c) => {
|
|
419
|
+
const f = (t || {})[c];
|
|
420
|
+
return s.has(u + c) ? [...l, ..._r(s, f, u + c + ".")] : f != null && f.isDirty ? [...l, u + c] : l;
|
|
421
|
+
}, []), Or = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((l, c) => {
|
|
422
|
+
const f = (t || {})[c];
|
|
423
|
+
return s.has(u + c) ? [...l, ...Or(s, f, u + c + ".")] : f != null && f.isTouched ? [...l, u + c] : l;
|
|
424
|
+
}, []), Cr = (s = /* @__PURE__ */ new Set(), t = {}, u = "") => Object.keys(t || {}).reduce((l, c) => {
|
|
425
|
+
const f = (t || {})[c];
|
|
426
|
+
return s.has(u + c) ? [...l, ...Cr(s, f, u + c + ".")] : f ? [...l, u + c] : l;
|
|
427
|
+
}, []), Ir = ({ control: s, name: t, compute: u, mode: l }) => {
|
|
428
|
+
const { getWatchValue: c, registerHookWatcher: f } = s || Tr(), o = c({ name: t, compute: u }), [b, E] = lr(o);
|
|
429
|
+
return Er(() => f({ name: t, compute: u, value: b, setValue: E, mode: l }), []), b;
|
|
430
|
+
}, Yr = ({ control: s, name: t, defaultValue: u, shouldUnRegister: l }) => {
|
|
431
|
+
const { actions: c, registerController: f, channels: o, getWatchValue: b, triggerBlurWatchers: E } = s || Tr(), R = Y(), m = Y(), a = D(c.getDefaultValues(), t) || u || "", v = Ir({ name: t }) ?? a, [C, A] = lr({}), S = h(
|
|
432
432
|
(y, { shouldDirty: _ = !0, shouldOnChange: O = !0 } = {}) => {
|
|
433
433
|
var x;
|
|
434
|
-
let
|
|
435
|
-
((x = y == null ? void 0 : y.target) == null ? void 0 : x.value) !== void 0 && (
|
|
434
|
+
let P = y;
|
|
435
|
+
((x = y == null ? void 0 : y.target) == null ? void 0 : x.value) !== void 0 && (P = y.target.value), c.setValue(t, P, { shouldDirty: _, shouldOnChange: O });
|
|
436
436
|
},
|
|
437
437
|
[c.setValue]
|
|
438
|
-
),
|
|
438
|
+
), $ = h((y) => {
|
|
439
439
|
const _ = c.getValues(), O = y ?? D(_, t);
|
|
440
440
|
o.publish("onBlur", t, O, _), E(t);
|
|
441
441
|
}, []);
|
|
442
442
|
return Er(() => {
|
|
443
|
-
const y =
|
|
443
|
+
const y = f(t, { shouldUnRegister: l });
|
|
444
444
|
return () => {
|
|
445
445
|
y && y(), m.current && m.current();
|
|
446
446
|
};
|
|
447
|
-
}, [
|
|
448
|
-
{ ref: R, name: t, defaultValue: a, value: v, onChange: S, onBlur:
|
|
447
|
+
}, [l, t]), new Proxy(
|
|
448
|
+
{ ref: R, name: t, defaultValue: a, value: v, onChange: S, onBlur: $, fieldState: C },
|
|
449
449
|
{
|
|
450
450
|
get(y, _, O) {
|
|
451
451
|
return typeof _ == "string" && _ === "fieldState" && (m.current && m.current(), m.current = c.subscribe(`fieldStates.${t}`, () => {
|
|
452
|
-
|
|
452
|
+
A(b({ name: `fieldStates.${t}` }));
|
|
453
453
|
})), Reflect.get(y, _, O);
|
|
454
454
|
}
|
|
455
455
|
}
|
|
@@ -458,37 +458,37 @@ const p = () => {
|
|
|
458
458
|
name: s,
|
|
459
459
|
control: t,
|
|
460
460
|
shouldUnRegister: u,
|
|
461
|
-
defaultValue:
|
|
462
|
-
render: c = ({ ref:
|
|
461
|
+
defaultValue: l,
|
|
462
|
+
render: c = ({ ref: f, name: o, defaultValue: b, value: E, onChange: R, onBlur: m, fieldState: a }) => null
|
|
463
463
|
}) => {
|
|
464
|
-
const
|
|
465
|
-
return c(
|
|
464
|
+
const f = Yr({ name: s, defaultValue: l, shouldUnRegister: u, control: t });
|
|
465
|
+
return c(f);
|
|
466
466
|
}, Mr = () => {
|
|
467
|
-
const [s, t] = lr(), u =
|
|
467
|
+
const [s, t] = lr(), u = h(() => t((/* @__PURE__ */ new Date()).toString()), []);
|
|
468
468
|
return [s, u];
|
|
469
469
|
}, Lr = () => {
|
|
470
470
|
const [, s] = lr({});
|
|
471
|
-
return
|
|
471
|
+
return h(() => s({}), []);
|
|
472
472
|
}, Vr = ({ channels: s, getWatchValue: t }) => {
|
|
473
|
-
const u = Lr(),
|
|
473
|
+
const u = Lr(), l = h((o, b = "onChange") => {
|
|
474
474
|
if (!o)
|
|
475
475
|
return s.subscribeWatch("values", () => u()), t();
|
|
476
476
|
if (typeof o == "string") {
|
|
477
477
|
let E = G(o);
|
|
478
|
-
|
|
478
|
+
b === "onBlur" && (E = `blur.${E}`), s.subscribeWatch(E, (R, m) => {
|
|
479
479
|
R !== m && u();
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
482
|
return Array.isArray(o) && o.forEach((E) => {
|
|
483
483
|
let R = G(E);
|
|
484
|
-
|
|
484
|
+
b === "onBlur" && (R = `blur.${R}`), s.subscribeWatch(R, (m, a) => {
|
|
485
485
|
m !== a && u();
|
|
486
486
|
});
|
|
487
487
|
}), t({ name: o });
|
|
488
|
-
}, []), c =
|
|
489
|
-
if (typeof
|
|
488
|
+
}, []), c = h(({ name: o, compute: b, setValue: E, mode: R = "onChange" }) => {
|
|
489
|
+
if (typeof b == "function")
|
|
490
490
|
return s.subscribe("values", () => {
|
|
491
|
-
const a = t({ compute:
|
|
491
|
+
const a = t({ compute: b });
|
|
492
492
|
E(a);
|
|
493
493
|
});
|
|
494
494
|
if (!o)
|
|
@@ -508,21 +508,21 @@ const p = () => {
|
|
|
508
508
|
let v = G(a);
|
|
509
509
|
R === "onBlur" && (v = `blur.${v}`);
|
|
510
510
|
const C = s.subscribe(v, () => {
|
|
511
|
-
const
|
|
512
|
-
E(
|
|
511
|
+
const A = t({ name: o });
|
|
512
|
+
E(A);
|
|
513
513
|
});
|
|
514
514
|
m.push(C);
|
|
515
515
|
}), () => m.forEach((a) => a());
|
|
516
516
|
}
|
|
517
517
|
throw new Error("Parameters of name must be string or array of string or compute must be a function");
|
|
518
|
-
}, []),
|
|
518
|
+
}, []), f = h((o, b, E = "onChange") => {
|
|
519
519
|
if (!o)
|
|
520
|
-
return s.subscribe("values", () =>
|
|
520
|
+
return s.subscribe("values", () => b(t()));
|
|
521
521
|
if (["onChange", "onBlur"].includes(o))
|
|
522
|
-
return s.subscribe(o,
|
|
522
|
+
return s.subscribe(o, b);
|
|
523
523
|
if (typeof o == "string") {
|
|
524
524
|
let R = G(o);
|
|
525
|
-
return E === "onBlur" && (R = `blur.${R}`), s.subscribe(R, () =>
|
|
525
|
+
return E === "onBlur" && (R = `blur.${R}`), s.subscribe(R, () => b(t({ name: o })));
|
|
526
526
|
}
|
|
527
527
|
if (Array.isArray(o)) {
|
|
528
528
|
const R = [];
|
|
@@ -530,139 +530,139 @@ const p = () => {
|
|
|
530
530
|
let a = G(m);
|
|
531
531
|
E === "onBlur" && (a = `blur.${a}`);
|
|
532
532
|
const v = s.subscribe(a, () => {
|
|
533
|
-
|
|
533
|
+
b(t({ name: o }));
|
|
534
534
|
});
|
|
535
535
|
R.push(v);
|
|
536
536
|
}), () => R.forEach((m) => m());
|
|
537
537
|
}
|
|
538
538
|
throw new Error("Parameters of name must be string or array of string");
|
|
539
539
|
}, []);
|
|
540
|
-
return { watch:
|
|
540
|
+
return { watch: l, registerHookWatcher: c, getWatchValue: t, subscribe: f };
|
|
541
541
|
}, Ur = ({ getWatchValue: s }) => {
|
|
542
|
-
const t = Y(/* @__PURE__ */ new Map()), u = Y(/* @__PURE__ */ new Map()),
|
|
542
|
+
const t = Y(/* @__PURE__ */ new Map()), u = Y(/* @__PURE__ */ new Map()), l = h(() => u.current, []), c = h(() => t.current, []), f = h(() => {
|
|
543
543
|
t.current.clear(), u.current.clear();
|
|
544
|
-
}, []), o = (a) => a.replace("values.", "").replace("values", ""),
|
|
544
|
+
}, []), o = (a) => a.replace("values.", "").replace("values", ""), b = h((a, ...v) => {
|
|
545
545
|
const C = a.split(".");
|
|
546
|
-
C.forEach((
|
|
547
|
-
const
|
|
546
|
+
C.forEach((A, S) => {
|
|
547
|
+
const $ = C.slice(0, C.length - S).join("."), y = t.current.get($), _ = u.current.get($);
|
|
548
548
|
if (S > 0) {
|
|
549
|
-
const O = v[0],
|
|
550
|
-
v = [M(
|
|
549
|
+
const O = v[0], P = s({ name: o($) });
|
|
550
|
+
v = [M(P, a.replace($, ""), O)];
|
|
551
551
|
}
|
|
552
552
|
y && y.forEach((O) => O(...v)), _ && _.forEach((O) => O(...v));
|
|
553
553
|
});
|
|
554
|
-
}, []), E =
|
|
555
|
-
const
|
|
554
|
+
}, []), E = h((a, { trickle: v = !1, bubble: C = !1 }) => {
|
|
555
|
+
const A = a.split(".");
|
|
556
556
|
let S = [s({ name: o(a) })];
|
|
557
|
-
|
|
558
|
-
const _ =
|
|
557
|
+
A.forEach(($, y) => {
|
|
558
|
+
const _ = A.slice(0, A.length - y).join("."), O = t.current.get(_), P = u.current.get(_);
|
|
559
559
|
if (y > 0 && C) {
|
|
560
560
|
const x = S[0], q = s({ name: o(_) });
|
|
561
561
|
S = [M(q, a.replace(_, ""), x)];
|
|
562
562
|
}
|
|
563
|
-
O && (y === 0 || C) && O.forEach((x) => x(...S)),
|
|
564
|
-
}), v && (t.current.forEach((
|
|
565
|
-
y.startsWith(a) &&
|
|
566
|
-
}), u.current.forEach((
|
|
567
|
-
y.startsWith(a) &&
|
|
563
|
+
O && (y === 0 || C) && O.forEach((x) => x(...S)), P && (y === 0 || C) && P.forEach((x) => x(...S));
|
|
564
|
+
}), v && (t.current.forEach(($, y) => {
|
|
565
|
+
y.startsWith(a) && $.forEach((_) => _(s({ name: o(y) })));
|
|
566
|
+
}), u.current.forEach(($, y) => {
|
|
567
|
+
y.startsWith(a) && $.forEach((_) => _(s({ name: o(y) })));
|
|
568
568
|
}));
|
|
569
|
-
}, []), R =
|
|
569
|
+
}, []), R = h((a, v) => (t.current.has(a) || t.current.set(a, /* @__PURE__ */ new Set()), t.current.get(a).add(v), () => {
|
|
570
570
|
var C;
|
|
571
571
|
return (C = t.current.get(a)) == null ? void 0 : C.delete(v);
|
|
572
|
-
}), []), m =
|
|
572
|
+
}), []), m = h((a, v) => {
|
|
573
573
|
u.current.has(a) || (u.current.set(a, /* @__PURE__ */ new Set()), u.current.get(a).add(v));
|
|
574
574
|
}, []);
|
|
575
|
-
return { reset:
|
|
575
|
+
return { reset: f, publish: b, subscribe: R, subscribeWatch: m, getEvents: c, getWatchEvents: l, trigger: E };
|
|
576
576
|
}, zr = ({ defaultValues: s = Dr, shouldUnRegister: t = !1, groups: u = [] } = {}) => {
|
|
577
|
-
const [
|
|
577
|
+
const [l, c] = Mr(), f = Y(), o = Y({}), b = Y({}), E = Y({ ...pr }), R = Y({ ...s }), m = Y({ ...s }), a = Y(/* @__PURE__ */ new Set()), v = Y(new Set(u)), C = h((r, n = m.current) => Object.keys(n).reduce((i, d) => {
|
|
578
578
|
if (typeof n[d] == "object")
|
|
579
|
-
return { ...
|
|
580
|
-
const k = { ...r ? {} :
|
|
581
|
-
return { ...
|
|
582
|
-
}, {}), []),
|
|
583
|
-
(r = {}, { clearCustomFormStates: n = !1, clearCustomFieldStates:
|
|
584
|
-
o.current = {}, m.current = { ...m.current, ...r }, R.current = { ...m.current }, a.current = /* @__PURE__ */ new Set(), v.current = new Set(d), E.current = { ...n ? {} : E.current, ...pr },
|
|
579
|
+
return { ...i, [d]: C(r, n[d]) };
|
|
580
|
+
const k = { ...r ? {} : b.current[d] || {}, ...br };
|
|
581
|
+
return { ...i, [d]: k };
|
|
582
|
+
}, {}), []), A = h(
|
|
583
|
+
(r = {}, { clearCustomFormStates: n = !1, clearCustomFieldStates: i = !1, groups: d = v.current } = {}) => {
|
|
584
|
+
o.current = {}, m.current = { ...m.current, ...r }, R.current = { ...m.current }, a.current = /* @__PURE__ */ new Set(), v.current = new Set(d), E.current = { ...n ? {} : E.current, ...pr }, b.current = C(i), F.reset(), c();
|
|
585
585
|
},
|
|
586
586
|
[]
|
|
587
|
-
), S =
|
|
588
|
-
let r = Object.fromEntries(new FormData(
|
|
589
|
-
a.current.forEach((
|
|
590
|
-
r = M(r,
|
|
587
|
+
), S = h(() => {
|
|
588
|
+
let r = Object.fromEntries(new FormData(f.current));
|
|
589
|
+
a.current.forEach((i) => {
|
|
590
|
+
r = M(r, i, D(R.current, i));
|
|
591
591
|
});
|
|
592
592
|
let n = { ...R.current, ...r };
|
|
593
593
|
return Wr(n);
|
|
594
|
-
}, []),
|
|
595
|
-
(r) => O({ ...E.current, lastReset:
|
|
596
|
-
[
|
|
597
|
-
), J =
|
|
594
|
+
}, []), $ = h((r) => Fr(r.target), []), y = h(() => m.current, []), _ = h(() => a.current, []), O = h((r, n) => n ? Array.isArray(n) ? n.reduce((i, d) => ({ ...i, [d]: D(r, d) }), {}) : D(r, n) : { ...r }, []), P = h((r) => O(R.current, r), [O]), x = h((r) => O(o.current, r), [O]), q = h((r) => O(b.current, r), [O]), H = h(
|
|
595
|
+
(r) => O({ ...E.current, lastReset: l }, r),
|
|
596
|
+
[l]
|
|
597
|
+
), J = h(({ name: r, compute: n } = {}) => !r && !n || r === "values" ? P() : typeof n == "function" ? n(P()) : Array.isArray(r) ? r.reduce((i, d) => ({ ...i, [d]: J({ name: d }) }), {}) : D(
|
|
598
598
|
{
|
|
599
599
|
...R.current,
|
|
600
600
|
errors: o.current,
|
|
601
|
-
fieldStates:
|
|
601
|
+
fieldStates: b.current,
|
|
602
602
|
formState: H()
|
|
603
603
|
},
|
|
604
604
|
r
|
|
605
|
-
), []),
|
|
605
|
+
), []), F = Ur({ getWatchValue: J }), { watch: nr, registerHookWatcher: K, subscribe: sr } = Vr({ getWatchValue: J, channels: F }), fr = h((r, n) => {
|
|
606
606
|
typeof n == "function" && (n = n(H(r)));
|
|
607
|
-
const
|
|
608
|
-
d !== n && (E.current = M(E.current, r, n),
|
|
609
|
-
}, []), X =
|
|
607
|
+
const i = E.current, d = D(i, r);
|
|
608
|
+
d !== n && (E.current = M(E.current, r, n), F.publish(`formState.${r}`, n, d));
|
|
609
|
+
}, []), X = h((r, n) => {
|
|
610
610
|
typeof n == "function" && (n = n(x(r))), W(r, "error", n);
|
|
611
|
-
}, []), z =
|
|
611
|
+
}, []), z = h((r) => {
|
|
612
612
|
W(r, "error", null);
|
|
613
|
-
}, []), or =
|
|
613
|
+
}, []), or = h(() => {
|
|
614
614
|
E.current.isError && Object.keys(o.current).forEach((r) => z(r));
|
|
615
|
-
}, []), W =
|
|
615
|
+
}, []), W = h((r, n, i) => {
|
|
616
616
|
try {
|
|
617
|
-
if (typeof
|
|
618
|
-
if (typeof
|
|
619
|
-
Object.keys(
|
|
620
|
-
W(`${r}.${N}`, n,
|
|
617
|
+
if (typeof i == "function" && (i = i(q(r))), v.current.has(r))
|
|
618
|
+
if (typeof i == "object" && i !== null) {
|
|
619
|
+
Object.keys(i).forEach((N) => {
|
|
620
|
+
W(`${r}.${N}`, n, i[N]);
|
|
621
621
|
});
|
|
622
622
|
return;
|
|
623
623
|
} else
|
|
624
624
|
return console.error(
|
|
625
625
|
`Cannot set primitive value for nested parent field "${r}". Please set value for its children or provide an object.`
|
|
626
626
|
);
|
|
627
|
-
const d = D(
|
|
628
|
-
if (k !==
|
|
629
|
-
if (
|
|
630
|
-
const N = D(o.current, r), B =
|
|
631
|
-
N !== B && (o.current = M(o.current, r, B),
|
|
627
|
+
const d = D(b.current, r) || { ...br }, k = D(d, n);
|
|
628
|
+
if (k !== i) {
|
|
629
|
+
if (b.current = M(b.current, `${r}.${n}`, i), F.publish(`fieldStates.${r}.${n}`, i, k), n === "error") {
|
|
630
|
+
const N = D(o.current, r), B = i || null;
|
|
631
|
+
N !== B && (o.current = M(o.current, r, B), F.publish(`errors.${r}`, B, N));
|
|
632
632
|
const U = Cr(v.current, o.current);
|
|
633
|
-
E.current.errorFields = U,
|
|
633
|
+
E.current.errorFields = U, F.publish("formState.errorFields", U);
|
|
634
634
|
const ar = U.length > 0;
|
|
635
635
|
if (E.current.isError !== ar) {
|
|
636
636
|
const gr = E.current.isError;
|
|
637
|
-
E.current.isError = ar,
|
|
637
|
+
E.current.isError = ar, F.publish("formState.isError", ar, gr);
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
640
|
if (n === "isDirty") {
|
|
641
|
-
const N = _r(v.current,
|
|
642
|
-
E.current.dirtyFields = N,
|
|
641
|
+
const N = _r(v.current, b.current);
|
|
642
|
+
E.current.dirtyFields = N, F.publish("formState.dirtyFields", N);
|
|
643
643
|
const B = N.length > 0;
|
|
644
644
|
if (E.current.isDirty !== B) {
|
|
645
645
|
const U = E.current.isDirty;
|
|
646
|
-
E.current.isDirty = B,
|
|
646
|
+
E.current.isDirty = B, F.publish("formState.isDirty", B, U);
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
if (n === "isTouched") {
|
|
650
|
-
const N = Or(v.current,
|
|
651
|
-
E.current.touchedFields = N,
|
|
650
|
+
const N = Or(v.current, b.current);
|
|
651
|
+
E.current.touchedFields = N, F.publish("formState.touchedFields", N);
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
} catch (d) {
|
|
655
655
|
console.log(d);
|
|
656
656
|
}
|
|
657
|
-
}, []), ur =
|
|
658
|
-
W(r, "isDirty", !1), W(r, "isTouched", !1), W(r, "error",
|
|
659
|
-
}, []), cr =
|
|
657
|
+
}, []), ur = h((r) => {
|
|
658
|
+
W(r, "isDirty", !1), W(r, "isTouched", !1), W(r, "error", null);
|
|
659
|
+
}, []), cr = h((r) => {
|
|
660
660
|
const n = Fr(r.target);
|
|
661
661
|
n ? X(r.target.name, n) : z(r.target.name);
|
|
662
|
-
}, []), e =
|
|
663
|
-
if (typeof n == "function" && (n = n(
|
|
662
|
+
}, []), e = h((r, n, { shouldDirty: i = !0, shouldOnChange: d = !0 } = {}) => {
|
|
663
|
+
if (typeof n == "function" && (n = n(P(r))), v.current.has(r)) {
|
|
664
664
|
typeof n == "object" && n !== null ? Object.keys(n).forEach((B) => {
|
|
665
|
-
e(`${r}.${B}`, n[B], { shouldDirty:
|
|
665
|
+
e(`${r}.${B}`, n[B], { shouldDirty: i, shouldOnChange: d });
|
|
666
666
|
}) : console.error(
|
|
667
667
|
`Cannot set primitive value for nested parent field "${r}". Please set value for its children or provide an object.`
|
|
668
668
|
);
|
|
@@ -670,7 +670,7 @@ const p = () => {
|
|
|
670
670
|
}
|
|
671
671
|
const k = D(R.current, r);
|
|
672
672
|
if (n === k) return;
|
|
673
|
-
if (R.current = M(R.current, r, n),
|
|
673
|
+
if (R.current = M(R.current, r, n), F.publish(`values.${r}`, n, k), r.includes(".")) {
|
|
674
674
|
const B = r.split("."), U = B.findIndex(
|
|
675
675
|
(ar, gr) => !v.current.has(B.slice(0, gr + 1).join("."))
|
|
676
676
|
);
|
|
@@ -678,56 +678,59 @@ const p = () => {
|
|
|
678
678
|
}
|
|
679
679
|
n && W(r, "isTouched", !0);
|
|
680
680
|
const N = n !== (D(m.current, r) || "");
|
|
681
|
-
|
|
682
|
-
}, []), g =
|
|
681
|
+
i && W(r, "isDirty", N), d && F.publish("onChange", r, n, k);
|
|
682
|
+
}, []), g = h((r) => {
|
|
683
683
|
const n = r.split(".");
|
|
684
|
-
let
|
|
684
|
+
let i = "";
|
|
685
685
|
n.forEach((d, k) => {
|
|
686
|
-
k < n.length - 1 && (
|
|
686
|
+
k < n.length - 1 && (i = i ? `${i}.${d}` : d, v.current.add(i));
|
|
687
687
|
});
|
|
688
|
-
}, []), T =
|
|
688
|
+
}, []), T = h((r) => {
|
|
689
689
|
Array.isArray(r) ? r.forEach((n) => g(n + ".")) : g(r + ".");
|
|
690
|
-
}, []), w =
|
|
691
|
-
(r = "", { shouldUnRegister: n = t } = {}) => r ? (a.current.add(r),
|
|
692
|
-
n && a.current.delete(r);
|
|
690
|
+
}, []), w = h(
|
|
691
|
+
(r = "", { shouldUnRegister: n = t } = {}) => r ? (a.current.add(r), b.current = M(b.current, r, { ...br }), r.includes(".") && g(r), () => {
|
|
692
|
+
n && (e(r, void 0, { shouldDirty: !1, shouldOnChange: !1 }), a.current.delete(r));
|
|
693
693
|
}) : console.error("Controller must have a name"),
|
|
694
694
|
[]
|
|
695
|
-
), L =
|
|
695
|
+
), L = h((r, { keepError: n, keepDirty: i, keepTouched: d, defaultValue: k }) => {
|
|
696
696
|
if (!a.current.has(r))
|
|
697
697
|
throw new Error(`Cannot reset "${r}" because it's uncontrolled field`);
|
|
698
|
-
m.current = M(m.current, r, k), R.current = M(R.current, r, k),
|
|
699
|
-
}, []), I =
|
|
700
|
-
if (!r)
|
|
698
|
+
m.current = M(m.current, r, k), R.current = M(R.current, r, k), F.publish(`values.${r}`, k), n || z(r), i || W(r, "isDirty", !1), d || W(r, "isTouched", !1);
|
|
699
|
+
}, []), I = h((r, { bubble: n, trickle: i } = {}) => {
|
|
700
|
+
if (!r) {
|
|
701
|
+
F.trigger("values", { bubble: n, trickle: i ?? !0 }), F.trigger("blur.values", { bubble: n, trickle: i ?? !0 });
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
701
704
|
if (!Array.isArray(r)) {
|
|
702
705
|
const d = G(r);
|
|
703
|
-
|
|
706
|
+
F.trigger(d, { bubble: n, trickle: i }), F.trigger(`blur.${d}`, { bubble: n, trickle: i });
|
|
704
707
|
return;
|
|
705
708
|
}
|
|
706
709
|
r.forEach((d) => {
|
|
707
710
|
const k = G(d);
|
|
708
|
-
|
|
711
|
+
F.trigger(k, { bubble: n, trickle: i }), F.trigger(`blur.${k}`, { bubble: n, trickle: i });
|
|
709
712
|
});
|
|
710
|
-
}, []), Z =
|
|
711
|
-
|
|
713
|
+
}, []), Z = h((r) => {
|
|
714
|
+
F.publish(`blur.values.${r}`, P(r)), F.publish(`blur.errors.${r}`, x(r));
|
|
712
715
|
const n = q(r);
|
|
713
716
|
Object.keys(n || {}).forEach((d) => {
|
|
714
|
-
|
|
717
|
+
F.publish(`blur.fieldStates.${r}.${d}`, n[d]);
|
|
715
718
|
});
|
|
716
|
-
const
|
|
717
|
-
Object.keys(
|
|
718
|
-
|
|
719
|
+
const i = H();
|
|
720
|
+
Object.keys(i || {}).forEach((d) => {
|
|
721
|
+
F.publish(`blur.formState.${d}`, i[d]);
|
|
719
722
|
});
|
|
720
|
-
}, []), Q =
|
|
721
|
-
|
|
722
|
-
}, []), j =
|
|
723
|
+
}, []), Q = h((r, n = P(r)) => {
|
|
724
|
+
F.publish("onBlur", r, n, P()), Z(r);
|
|
725
|
+
}, []), j = hr(
|
|
723
726
|
() => ({
|
|
724
727
|
subscribe: sr,
|
|
725
|
-
reset:
|
|
728
|
+
reset: A,
|
|
726
729
|
trigger: I,
|
|
727
730
|
reload: c,
|
|
728
731
|
resetField: L,
|
|
729
732
|
setValue: e,
|
|
730
|
-
getValues:
|
|
733
|
+
getValues: P,
|
|
731
734
|
getErrors: x,
|
|
732
735
|
getFieldStates: q,
|
|
733
736
|
getFormState: H,
|
|
@@ -735,45 +738,45 @@ const p = () => {
|
|
|
735
738
|
clearError: z,
|
|
736
739
|
clearErrors: or,
|
|
737
740
|
checkValidity: cr,
|
|
738
|
-
getFieldValidity:
|
|
741
|
+
getFieldValidity: $,
|
|
739
742
|
getDefaultValues: y,
|
|
740
743
|
setFieldState: W,
|
|
741
744
|
triggerFieldBlur: Q,
|
|
742
745
|
resetFieldState: ur,
|
|
743
746
|
getControlledFields: _,
|
|
744
747
|
setFormState: fr,
|
|
745
|
-
getEvents:
|
|
746
|
-
getWatchEvents:
|
|
748
|
+
getEvents: F.getEvents,
|
|
749
|
+
getWatchEvents: F.getWatchEvents,
|
|
747
750
|
addGroups: T
|
|
748
751
|
}),
|
|
749
|
-
[
|
|
750
|
-
), V =
|
|
751
|
-
[...
|
|
752
|
-
const d =
|
|
753
|
-
d.includes(".") && g(d), !
|
|
752
|
+
[l]
|
|
753
|
+
), V = h(() => {
|
|
754
|
+
[...f.current.querySelectorAll("[name]")].forEach((i) => {
|
|
755
|
+
const d = i.name || "";
|
|
756
|
+
d.includes(".") && g(d), !i.defaultValue && !a.current.has(d) && D(m.current, d) && (i.defaultValue = D(m.current, d));
|
|
754
757
|
});
|
|
755
758
|
const n = S();
|
|
756
759
|
R.current = { ...n }, m.current = { ...n };
|
|
757
|
-
}, []), rr =
|
|
760
|
+
}, []), rr = hr(
|
|
758
761
|
() => ({
|
|
759
|
-
ref:
|
|
762
|
+
ref: f,
|
|
760
763
|
watch: nr,
|
|
761
764
|
actions: j,
|
|
762
765
|
initForm: V,
|
|
763
766
|
registerController: w,
|
|
764
767
|
registerHookWatcher: K,
|
|
765
|
-
lastReloadedAt:
|
|
768
|
+
lastReloadedAt: l,
|
|
766
769
|
loadFormValues: S,
|
|
767
770
|
getWatchValue: J,
|
|
768
771
|
triggerBlurWatchers: Z,
|
|
769
|
-
channels:
|
|
772
|
+
channels: F
|
|
770
773
|
}),
|
|
771
|
-
[
|
|
772
|
-
), dr =
|
|
774
|
+
[l]
|
|
775
|
+
), dr = hr(() => ({ control: rr, actions: j, watch: nr }), [l]);
|
|
773
776
|
return mr(() => {
|
|
774
|
-
|
|
775
|
-
}, [
|
|
776
|
-
|
|
777
|
+
f.current && V();
|
|
778
|
+
}, [l]), mr(() => {
|
|
779
|
+
b.current = C(!1);
|
|
777
780
|
}, []), dr;
|
|
778
781
|
};
|
|
779
782
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(M,
|
|
1
|
+
(function(M,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],n):(M=typeof globalThis<"u"?globalThis:M||self,n(M.Name={},M.React))})(this,function(M,n){"use strict";var se={exports:{}},q={};/**
|
|
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 he;function _e(){if(he)return q;he=1;var o=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(
|
|
9
|
+
*/var he;function _e(){if(he)return q;he=1;var o=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function a(f,u,d){var c=null;if(d!==void 0&&(c=""+d),u.key!==void 0&&(c=""+u.key),"key"in u){d={};for(var h in u)h!=="key"&&(d[h]=u[h])}else d=u;return u=d.ref,{$$typeof:o,type:f,key:c,ref:u!==void 0?u:null,props:d}}return q.Fragment=t,q.jsx=a,q.jsxs=a,q}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 Ee;function Oe(){return Ee||(Ee=1,process.env.NODE_ENV!=="production"&&function(){function o(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===ne?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case S:return"Fragment";case y:return"Profiler";case w:return"StrictMode";case W:return"Suspense";case z:return"SuspenseList";case
|
|
17
|
+
*/var Ee;function Oe(){return Ee||(Ee=1,process.env.NODE_ENV!=="production"&&function(){function o(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===ne?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case S:return"Fragment";case y:return"Profiler";case w:return"StrictMode";case W:return"Suspense";case z:return"SuspenseList";case k:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case p:return"Portal";case A:return(r.displayName||"Context")+".Provider";case T:return(r._context.displayName||"Context")+".Consumer";case P:var g=r.render;return r=r.displayName,r||(r=g.displayName||g.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Z:return g=r.displayName||null,g!==null?g:o(r.type)||"Memo";case H:g=r._payload,r=r._init;try{return o(r(g))}catch{}}return null}function t(r){return""+r}function a(r){try{t(r);var g=!1}catch{g=!0}if(g){g=console;var F=g.error,j=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return F.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",j),t(r)}}function f(r){if(r===S)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===H)return"<...>";try{var g=o(r);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function u(){var r=ee.A;return r===null?null:r.getOwner()}function d(){return Error("react-stack-top-frame")}function c(r){if(oe.call(r,"key")){var g=Object.getOwnPropertyDescriptor(r,"key").get;if(g&&g.isReactWarning)return!1}return r.key!==void 0}function h(r,g){function F(){X||(X=!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)",g))}F.isReactWarning=!0,Object.defineProperty(r,"key",{get:F,configurable:!0})}function E(){var r=o(this.type);return ce[r]||(ce[r]=!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.")),r=this.props.ref,r!==void 0?r:null}function C(r,g,F,j,V,Y,Q,re){return F=Y.ref,r={$$typeof:_,type:r,key:g,props:Y,_owner:V},(F!==void 0?F:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:E}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:re}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function m(r,g,F,j,V,Y,Q,re){var O=g.children;if(O!==void 0)if(j)if(de(O)){for(j=0;j<O.length;j++)l(O[j]);Object.freeze&&Object.freeze(O)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else l(O);if(oe.call(g,"key")){O=o(r);var U=Object.keys(g).filter(function(be){return be!=="key"});j=0<U.length?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}",ue[O+j]||(U=0<U.length?"{"+U.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} />`,j,O,U,O),ue[O+j]=!0)}if(O=null,F!==void 0&&(a(F),O=""+F),c(g)&&(a(g.key),O=""+g.key),"key"in g){F={};for(var te in g)te!=="key"&&(F[te]=g[te])}else F=g;return O&&h(F,typeof r=="function"?r.displayName||r.name||"Unknown":r),C(r,O,Y,V,u(),F,Q,re)}function l(r){typeof r=="object"&&r!==null&&r.$$typeof===_&&r._store&&(r._store.validated=1)}var R=s,_=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),ee=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe=Object.prototype.hasOwnProperty,de=Array.isArray,K=console.createTask?console.createTask:function(){return null};R={"react-stack-bottom-frame":function(r){return r()}};var X,ce={},B=R["react-stack-bottom-frame"].bind(R,f)(),ae=K(i(f)),ue={};$.Fragment=S,$.jsx=function(r,g,F,j,V){var Y=1e4>ee.recentlyCreatedOwnerStacks++;return m(r,g,F,!1,j,V,Y?Error("react-stack-top-frame"):B,Y?K(i(r)):ae)},$.jsxs=function(r,g,F,j,V){var Y=1e4>ee.recentlyCreatedOwnerStacks++;return m(r,g,F,!0,j,V,Y?Error("react-stack-top-frame"):B,Y?K(i(r)):ae)}}()),$}var me;function je(){return me||(me=1,process.env.NODE_ENV==="production"?se.exports=_e():se.exports=Oe()),se.exports}var Re=je();const v=()=>{},Ce=s.createContext({ref:null,watch:v,actions:{subscribe:v,reset:v,trigger:v,reload:v,resetField:v,setValue:v,getValues:v,getErrors:v,getFieldStates:v,getFormState:v,setError:v,clearError:v,clearErrors:v,checkValidity:v,getFieldValidity:v,getDefaultValues:v,setFieldState:v,triggerFieldBlur:v,resetFieldState:v,getControlledFields:v,setFormState:v,getEvents:v,getWatchEvents:v,addGroups:v},registerController:v,registerHookWatcher:v,lastReloadedAt:v,loadFormValues:v,getWatchValue:v,channels:{}}),ie=()=>s.useContext(Ce),we=({id:o,control:t,method:a,action:i,children:u,onChange:f,onBlur:c,onSubmit:h=()=>{},onInput:E=()=>{},onReset:C=()=>{},numberFields:m=[],className:l,...R})=>{const _=s.useCallback(k=>{t.ref&&(t.ref.current=k,t.ref.current&&t.initForm())},[t]);return s.useEffect(()=>{let k=()=>{},S=()=>{};return f&&(k=t.channels.subscribe("onChange",f)),c&&(S=t.channels.subscribe("onBlur",c)),()=>{k(),S()}},[t.lastReloadedAt]),Re.jsx(Ce.Provider,{value:t,children:Re.jsx("form",{id:o,ref:_,action:i,method:a,className:l,onInput:E,onSubmit:k=>{a||k.preventDefault();const S=t.loadFormValues();h(S)},onChange:k=>{const S=k.target.name;!S||t.actions.getControlledFields().has(S)||t.actions.setValue(S,k.target.value)},onBlur:k=>{const S=k.target.name;if(!S||t.actions.getControlledFields().has(S))return;const w=k.target.value;t.channels.publish("onBlur",S,w,t.actions.getValues()),t.triggerBlurWatchers(S)},onReset:k=>{t.actions.reset(),C(k)},...R,children:u},t.lastReloadedAt)})},fe={isDirty:!1,isTouched:!1,error:null},ve={lastReset:null,isDirty:!1,isError:!1,errorFields:[],dirtyFields:[],touchedFields:[]},Pe={},Ne=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],D=(o={},t="")=>t.split(".").reduce((a,i)=>a&&a[i]!==void 0?a[i]:void 0,o),L=(o={},t="",a)=>{const i=Array.isArray(o)?[...o]:{...o};let u=i;const f=t.split(".");return f.forEach((c,h)=>{h<f.length-1?(u[c]||(u[c]=/^\d+$/.test(f[h+1])?[]:{}),Array.isArray(u[c])?u[c]=[...u[c]]:u[c]={...u[c]},u=u[c]):u[c]=a}),i},Se=o=>{let t=Array.isArray(o)?[...o]:{...o};return Object.keys(t).forEach(a=>{if(a.includes(".")){const i=D(t,a);t=L(t,a,i||""),delete t[a]}}),t},De=["errors","fieldStates","formState"],G=o=>De.some(t=>o.startsWith(t))?o:"values."+o,ye=o=>{typeof o.setCustomValidity=="function"&&o.setCustomValidity("");let t=o.validity,a=Ne.find(i=>t[i]);if(a)return{type:a,message:o.validationMessage}},ke=(o=new Set,t={},a="")=>Object.keys(t||{}).reduce((i,u)=>{const f=(t||{})[u];return o.has(a+u)?[...i,...ke(o,f,a+u+".")]:f!=null&&f.isDirty?[...i,a+u]:i},[]),pe=(o=new Set,t={},a="")=>Object.keys(t||{}).reduce((i,u)=>{const f=(t||{})[u];return o.has(a+u)?[...i,...pe(o,f,a+u+".")]:f!=null&&f.isTouched?[...i,a+u]:i},[]),Fe=(o=new Set,t={},a="")=>Object.keys(t||{}).reduce((i,u)=>{const f=(t||{})[u];return o.has(a+u)?[...i,...Fe(o,f,a+u+".")]:f?[...i,a+u]:i},[]),Te=({control:o,name:t,compute:a,mode:i})=>{const{getWatchValue:u,registerHookWatcher:f}=o||ie(),c=u({name:t,compute:a}),[h,E]=s.useState(c);return s.useEffect(()=>f({name:t,compute:a,value:h,setValue:E,mode:i}),[]),h},Ae=({control:o,name:t,defaultValue:a,shouldUnRegister:i})=>{const{actions:u,registerController:f,channels:c,getWatchValue:h,triggerBlurWatchers:E}=o||ie(),C=s.useRef(),m=s.useRef(),l=D(u.getDefaultValues(),t)||a||"",R=Te({name:t})??l,[_,k]=s.useState({}),S=s.useCallback((y,{shouldDirty:T=!0,shouldOnChange:A=!0}={})=>{var W;let P=y;((W=y==null?void 0:y.target)==null?void 0:W.value)!==void 0&&(P=y.target.value),u.setValue(t,P,{shouldDirty:T,shouldOnChange:A})},[u.setValue]),w=s.useCallback(y=>{const T=u.getValues(),A=y??D(T,t);c.publish("onBlur",t,A,T),E(t)},[]);return s.useEffect(()=>{const y=f(t,{shouldUnRegister:i});return()=>{y&&y(),m.current&&m.current()}},[i,t]),new Proxy({ref:C,name:t,defaultValue:l,value:R,onChange:S,onBlur:w,fieldState:_},{get(y,T,A){return typeof T=="string"&&T==="fieldState"&&(m.current&&m.current(),m.current=u.subscribe(`fieldStates.${t}`,()=>{k(h({name:`fieldStates.${t}`}))})),Reflect.get(y,T,A)}})},xe=({name:o,control:t,shouldUnRegister:a,defaultValue:i,render:u=({ref:f,name:c,defaultValue:h,value:E,onChange:C,onBlur:m,fieldState:l})=>null})=>{const f=Ae({name:o,defaultValue:i,shouldUnRegister:a,control:t});return u(f)},We=()=>{const[o,t]=s.useState(),a=s.useCallback(()=>t(new Date().toString()),[]);return[o,a]},Be=()=>{const[,o]=s.useState({});return s.useCallback(()=>o({}),[])},Ie=({channels:o,getWatchValue:t})=>{const a=Be(),i=s.useCallback((c,h="onChange")=>{if(!c)return o.subscribeWatch("values",()=>a()),t();if(typeof c=="string"){let E=G(c);h==="onBlur"&&(E=`blur.${E}`),o.subscribeWatch(E,(C,m)=>{C!==m&&a()})}return Array.isArray(c)&&c.forEach(E=>{let C=G(E);h==="onBlur"&&(C=`blur.${C}`),o.subscribeWatch(C,(m,l)=>{m!==l&&a()})}),t({name:c})},[]),u=s.useCallback(({name:c,compute:h,setValue:E,mode:C="onChange"})=>{if(typeof h=="function")return o.subscribe("values",()=>{const l=t({compute:h});E(l)});if(!c)return o.subscribe("values",()=>{E(t())});if(typeof c=="string"){let m=G(c);return C==="onBlur"&&(m=`blur.${m}`),o.subscribe(m,()=>{const R=t({name:c});E(R)})}if(Array.isArray(c)){const m=[];return c.forEach(l=>{let R=G(l);C==="onBlur"&&(R=`blur.${R}`);const _=o.subscribe(R,()=>{const k=t({name:c});E(k)});m.push(_)}),()=>m.forEach(l=>l())}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),f=s.useCallback((c,h,E="onChange")=>{if(!c)return o.subscribe("values",()=>h(t()));if(["onChange","onBlur"].includes(c))return o.subscribe(c,h);if(typeof c=="string"){let C=G(c);return E==="onBlur"&&(C=`blur.${C}`),o.subscribe(C,()=>h(t({name:c})))}if(Array.isArray(c)){const C=[];return c.forEach(m=>{let l=G(m);E==="onBlur"&&(l=`blur.${l}`);const R=o.subscribe(l,()=>{h(t({name:c}))});C.push(R)}),()=>C.forEach(m=>m())}throw new Error("Parameters of name must be string or array of string")},[]);return{watch:i,registerHookWatcher:u,getWatchValue:t,subscribe:f}},Me=({getWatchValue:o})=>{const t=s.useRef(new Map),a=s.useRef(new Map),i=s.useCallback(()=>a.current,[]),u=s.useCallback(()=>t.current,[]),f=s.useCallback(()=>{t.current.clear(),a.current.clear()},[]),c=l=>l.replace("values.","").replace("values",""),h=s.useCallback((l,...R)=>{const _=l.split(".");_.forEach((k,S)=>{const w=_.slice(0,_.length-S).join("."),y=t.current.get(w),T=a.current.get(w);if(S>0){const A=R[0],P=o({name:c(w)});R=[L(P,l.replace(w,""),A)]}y&&y.forEach(A=>A(...R)),T&&T.forEach(A=>A(...R))})},[]),E=s.useCallback((l,{trickle:R=!1,bubble:_=!1})=>{const k=l.split(".");let S=[o({name:c(l)})];k.forEach((w,y)=>{const T=k.slice(0,k.length-y).join("."),A=t.current.get(T),P=a.current.get(T);if(y>0&&_){const W=S[0],z=o({name:c(T)});S=[L(z,l.replace(T,""),W)]}A&&(y===0||_)&&A.forEach(W=>W(...S)),P&&(y===0||_)&&P.forEach(W=>W(...S))}),R&&(t.current.forEach((w,y)=>{y.startsWith(l)&&w.forEach(T=>T(o({name:c(y)})))}),a.current.forEach((w,y)=>{y.startsWith(l)&&w.forEach(T=>T(o({name:c(y)})))}))},[]),C=s.useCallback((l,R)=>(t.current.has(l)||t.current.set(l,new Set),t.current.get(l).add(R),()=>{var _;return(_=t.current.get(l))==null?void 0:_.delete(R)}),[]),m=s.useCallback((l,R)=>{a.current.has(l)||(a.current.set(l,new Set),a.current.get(l).add(R))},[]);return{reset:f,publish:h,subscribe:C,subscribeWatch:m,getEvents:u,getWatchEvents:i,trigger:E}},Ye=({defaultValues:o=Pe,shouldUnRegister:t=!1,groups:a=[]}={})=>{const[i,u]=We(),f=s.useRef(),c=s.useRef({}),h=s.useRef({}),E=s.useRef({...ve}),C=s.useRef({...o}),m=s.useRef({...o}),l=s.useRef(new Set),R=s.useRef(new Set(a)),_=s.useCallback((e,n=m.current)=>Object.keys(n).reduce((d,b)=>{if(typeof n[b]=="object")return{...d,[b]:_(e,n[b])};const N={...e?{}:h.current[b]||{},...fe};return{...d,[b]:N}},{}),[]),k=s.useCallback((e={},{clearCustomFormStates:n=!1,clearCustomFieldStates:d=!1,groups:b=R.current}={})=>{c.current={},m.current={...m.current,...e},C.current={...m.current},l.current=new Set,R.current=new Set(b),E.current={...n?{}:E.current,...ve},h.current=_(d),p.reset(),u()},[]),S=s.useCallback(()=>{let e=Object.fromEntries(new FormData(f.current));l.current.forEach(d=>{e=L(e,d,D(C.current,d))});let n={...C.current,...e};return Se(n)},[]),w=s.useCallback(e=>ye(e.target),[]),y=s.useCallback(()=>m.current,[]),T=s.useCallback(()=>l.current,[]),A=s.useCallback((e,n)=>n?Array.isArray(n)?n.reduce((d,b)=>({...d,[b]:D(e,b)}),{}):D(e,n):{...e},[]),P=s.useCallback(e=>A(C.current,e),[A]),W=s.useCallback(e=>A(c.current,e),[A]),z=s.useCallback(e=>A(h.current,e),[A]),Z=s.useCallback(e=>A({...E.current,lastReset:i},e),[i]),H=s.useCallback(({name:e,compute:n}={})=>!e&&!n||e==="values"?P():typeof n=="function"?n(P()):Array.isArray(e)?e.reduce((d,b)=>({...d,[b]:H({name:b})}),{}):D({...C.current,errors:c.current,fieldStates:h.current,formState:Z()},e),[]),p=Me({getWatchValue:H}),{watch:ne,registerHookWatcher:ee,subscribe:oe}=Ie({getWatchValue:H,channels:p}),de=s.useCallback((e,n)=>{typeof n=="function"&&(n=n(Z(e)));const d=E.current,b=D(d,e);b!==n&&(E.current=L(E.current,e,n),p.publish(`formState.${e}`,n,b))},[]),K=s.useCallback((e,n)=>{typeof n=="function"&&(n=n(W(e))),B(e,"error",n)},[]),X=s.useCallback(e=>{B(e,"error",null)},[]),ce=s.useCallback(()=>{E.current.isError&&Object.keys(c.current).forEach(e=>X(e))},[]),B=s.useCallback((e,n,d)=>{try{if(typeof d=="function"&&(d=d(z(e))),R.current.has(e))if(typeof d=="object"&&d!==null){Object.keys(d).forEach(x=>{B(`${e}.${x}`,n,d[x])});return}else return console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);const b=D(h.current,e)||{...fe},N=D(b,n);if(N!==d){if(h.current=L(h.current,`${e}.${n}`,d),p.publish(`fieldStates.${e}.${n}`,d,N),n==="error"){const x=D(c.current,e),I=d||null;x!==I&&(c.current=L(c.current,e,I),p.publish(`errors.${e}`,I,x));const J=Fe(R.current,c.current);E.current.errorFields=J,p.publish("formState.errorFields",J);const le=J.length>0;if(E.current.isError!==le){const ge=E.current.isError;E.current.isError=le,p.publish("formState.isError",le,ge)}}if(n==="isDirty"){const x=ke(R.current,h.current);E.current.dirtyFields=x,p.publish("formState.dirtyFields",x);const I=x.length>0;if(E.current.isDirty!==I){const J=E.current.isDirty;E.current.isDirty=I,p.publish("formState.isDirty",I,J)}}if(n==="isTouched"){const x=pe(R.current,h.current);E.current.touchedFields=x,p.publish("formState.touchedFields",x)}}}catch(b){console.log(b)}},[]),ae=s.useCallback(e=>{B(e,"isDirty",!1),B(e,"isTouched",!1),B(e,"error",!1)},[]),ue=s.useCallback(e=>{const n=ye(e.target);n?K(e.target.name,n):X(e.target.name)},[]),r=s.useCallback((e,n,{shouldDirty:d=!0,shouldOnChange:b=!0}={})=>{if(typeof n=="function"&&(n=n(P(e))),R.current.has(e)){typeof n=="object"&&n!==null?Object.keys(n).forEach(I=>{r(`${e}.${I}`,n[I],{shouldDirty:d,shouldOnChange:b})}):console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);return}const N=D(C.current,e);if(n===N)return;if(C.current=L(C.current,e,n),p.publish(`values.${e}`,n,N),e.includes(".")){const I=e.split("."),J=I.findIndex((le,ge)=>!R.current.has(I.slice(0,ge+1).join(".")));J!==-1&&(e=I.slice(0,J+1).join("."))}n&&B(e,"isTouched",!0);const x=n!==(D(m.current,e)||"");d&&B(e,"isDirty",x),b&&p.publish("onChange",e,n,N)},[]),g=s.useCallback(e=>{const n=e.split(".");let d="";n.forEach((b,N)=>{N<n.length-1&&(d=d?`${d}.${b}`:b,R.current.add(d))})},[]),F=s.useCallback(e=>{Array.isArray(e)?e.forEach(n=>g(n+".")):g(e+".")},[]),j=s.useCallback((e="",{shouldUnRegister:n=t}={})=>e?(l.current.add(e),h.current=L(h.current,e,{...fe}),e.includes(".")&&g(e),()=>{n&&l.current.delete(e)}):console.error("Controller must have a name"),[]),V=s.useCallback((e,{keepError:n,keepDirty:d,keepTouched:b,defaultValue:N})=>{if(!l.current.has(e))throw new Error(`Cannot reset "${e}" because it's uncontrolled field`);m.current=L(m.current,e,N),C.current=L(C.current,e,N),p.publish(`values.${e}`,N),n||X(e),d||B(e,"isDirty",!1),b||B(e,"isTouched",!1)},[]),Y=s.useCallback((e,{bubble:n,trickle:d}={})=>{if(!e)return p.trigger("values",{bubble:n,trickle:d??!0});if(!Array.isArray(e)){const b=G(e);p.trigger(b,{bubble:n,trickle:d});return}e.forEach(b=>{const N=G(b);p.trigger(N,{bubble:n,trickle:d})})},[]),Q=s.useCallback(e=>{p.publish(`blur.values.${e}`,P(e)),p.publish(`blur.errors.${e}`,W(e));const n=z(e);Object.keys(n||{}).forEach(b=>{p.publish(`blur.fieldStates.${e}.${b}`,n[b])});const d=Z();Object.keys(d||{}).forEach(b=>{p.publish(`blur.formState.${b}`,d[b])})},[]),re=s.useCallback((e,n=P(e))=>{p.publish("onBlur",e,n,P()),Q(e)},[]),O=s.useMemo(()=>({subscribe:oe,reset:k,trigger:Y,reload:u,resetField:V,setValue:r,getValues:P,getErrors:W,getFieldStates:z,getFormState:Z,setError:K,clearError:X,clearErrors:ce,checkValidity:ue,getFieldValidity:w,getDefaultValues:y,setFieldState:B,triggerFieldBlur:re,resetFieldState:ae,getControlledFields:T,setFormState:de,getEvents:p.getEvents,getWatchEvents:p.getWatchEvents,addGroups:F}),[i]),U=s.useCallback(()=>{[...f.current.querySelectorAll("[name]")].forEach(d=>{const b=d.name||"";b.includes(".")&&g(b),!d.defaultValue&&!l.current.has(b)&&D(m.current,b)&&(d.defaultValue=D(m.current,b))});const n=S();C.current={...n},m.current={...n}},[]),te=s.useMemo(()=>({ref:f,watch:ne,actions:O,initForm:U,registerController:j,registerHookWatcher:ee,lastReloadedAt:i,loadFormValues:S,getWatchValue:H,triggerBlurWatchers:Q,channels:p}),[i]),be=s.useMemo(()=>({control:te,actions:O,watch:ne}),[i]);return s.useLayoutEffect(()=>{f.current&&U()},[i]),s.useLayoutEffect(()=>{h.current=_(!1)},[]),be};M.Controller=xe,M.Form=we,M.restoreFromDotNotation=Se,M.useController=Ae,M.useForm=Ye,M.useFormContext=ie,M.useWatch=Te,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
22
|
+
<%s key={someKey} {...props} />`,j,O,U,O),ue[O+j]=!0)}if(O=null,F!==void 0&&(a(F),O=""+F),c(g)&&(a(g.key),O=""+g.key),"key"in g){F={};for(var te in g)te!=="key"&&(F[te]=g[te])}else F=g;return O&&h(F,typeof r=="function"?r.displayName||r.name||"Unknown":r),C(r,O,Y,V,u(),F,Q,re)}function l(r){typeof r=="object"&&r!==null&&r.$$typeof===_&&r._store&&(r._store.validated=1)}var R=n,_=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),H=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),ee=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe=Object.prototype.hasOwnProperty,de=Array.isArray,K=console.createTask?console.createTask:function(){return null};R={"react-stack-bottom-frame":function(r){return r()}};var X,ce={},B=R["react-stack-bottom-frame"].bind(R,d)(),ae=K(f(d)),ue={};$.Fragment=S,$.jsx=function(r,g,F,j,V){var Y=1e4>ee.recentlyCreatedOwnerStacks++;return m(r,g,F,!1,j,V,Y?Error("react-stack-top-frame"):B,Y?K(f(r)):ae)},$.jsxs=function(r,g,F,j,V){var Y=1e4>ee.recentlyCreatedOwnerStacks++;return m(r,g,F,!0,j,V,Y?Error("react-stack-top-frame"):B,Y?K(f(r)):ae)}}()),$}var me;function je(){return me||(me=1,process.env.NODE_ENV==="production"?se.exports=_e():se.exports=Oe()),se.exports}var Re=je();const v=()=>{},Ce=n.createContext({ref:null,watch:v,actions:{subscribe:v,reset:v,trigger:v,reload:v,resetField:v,setValue:v,getValues:v,getErrors:v,getFieldStates:v,getFormState:v,setError:v,clearError:v,clearErrors:v,checkValidity:v,getFieldValidity:v,getDefaultValues:v,setFieldState:v,triggerFieldBlur:v,resetFieldState:v,getControlledFields:v,setFormState:v,getEvents:v,getWatchEvents:v,addGroups:v},registerController:v,registerHookWatcher:v,lastReloadedAt:v,loadFormValues:v,getWatchValue:v,channels:{}}),ie=()=>n.useContext(Ce),we=({id:o,control:t,method:a,action:f,children:u,onChange:d,onBlur:c,onSubmit:h=()=>{},onInput:E=()=>{},onReset:C=()=>{},numberFields:m=[],className:l,...R})=>{const _=n.useCallback(p=>{t.ref&&(t.ref.current=p,t.ref.current&&t.initForm())},[t]);return n.useEffect(()=>{let p=()=>{},S=()=>{};return d&&(p=t.channels.subscribe("onChange",d)),c&&(S=t.channels.subscribe("onBlur",c)),()=>{p(),S()}},[t.lastReloadedAt]),Re.jsx(Ce.Provider,{value:t,children:Re.jsx("form",{id:o,ref:_,action:f,method:a,className:l,onInput:E,onSubmit:p=>{a||p.preventDefault();const S=t.loadFormValues();h(S)},onChange:p=>{const S=p.target.name;!S||t.actions.getControlledFields().has(S)||t.actions.setValue(S,p.target.value)},onBlur:p=>{const S=p.target.name;if(!S||t.actions.getControlledFields().has(S))return;const w=p.target.value;t.channels.publish("onBlur",S,w,t.actions.getValues()),t.triggerBlurWatchers(S)},onReset:p=>{t.actions.reset(),C(p)},...R,children:u},t.lastReloadedAt)})},fe={isDirty:!1,isTouched:!1,error:null},ve={lastReset:null,isDirty:!1,isError:!1,errorFields:[],dirtyFields:[],touchedFields:[]},Pe={},Ne=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],D=(o={},t="")=>t.split(".").reduce((a,f)=>a&&a[f]!==void 0?a[f]:void 0,o),L=(o={},t="",a)=>{const f=Array.isArray(o)?[...o]:{...o};let u=f;const d=t.split(".");return d.forEach((c,h)=>{h<d.length-1?(u[c]||(u[c]=/^\d+$/.test(d[h+1])?[]:{}),Array.isArray(u[c])?u[c]=[...u[c]]:u[c]={...u[c]},u=u[c]):u[c]=a}),f},Se=o=>{let t=Array.isArray(o)?[...o]:{...o};return Object.keys(t).forEach(a=>{if(a.includes(".")){const f=D(t,a);t=L(t,a,f||""),delete t[a]}}),t},De=["errors","fieldStates","formState"],G=o=>De.some(t=>o.startsWith(t))?o:"values."+o,ye=o=>{typeof o.setCustomValidity=="function"&&o.setCustomValidity("");let t=o.validity,a=Ne.find(f=>t[f]);if(a)return{type:a,message:o.validationMessage}},ke=(o=new Set,t={},a="")=>Object.keys(t||{}).reduce((f,u)=>{const d=(t||{})[u];return o.has(a+u)?[...f,...ke(o,d,a+u+".")]:d!=null&&d.isDirty?[...f,a+u]:f},[]),pe=(o=new Set,t={},a="")=>Object.keys(t||{}).reduce((f,u)=>{const d=(t||{})[u];return o.has(a+u)?[...f,...pe(o,d,a+u+".")]:d!=null&&d.isTouched?[...f,a+u]:f},[]),Fe=(o=new Set,t={},a="")=>Object.keys(t||{}).reduce((f,u)=>{const d=(t||{})[u];return o.has(a+u)?[...f,...Fe(o,d,a+u+".")]:d?[...f,a+u]:f},[]),Te=({control:o,name:t,compute:a,mode:f})=>{const{getWatchValue:u,registerHookWatcher:d}=o||ie(),c=u({name:t,compute:a}),[h,E]=n.useState(c);return n.useEffect(()=>d({name:t,compute:a,value:h,setValue:E,mode:f}),[]),h},Ae=({control:o,name:t,defaultValue:a,shouldUnRegister:f})=>{const{actions:u,registerController:d,channels:c,getWatchValue:h,triggerBlurWatchers:E}=o||ie(),C=n.useRef(),m=n.useRef(),l=D(u.getDefaultValues(),t)||a||"",R=Te({name:t})??l,[_,p]=n.useState({}),S=n.useCallback((y,{shouldDirty:T=!0,shouldOnChange:A=!0}={})=>{var W;let P=y;((W=y==null?void 0:y.target)==null?void 0:W.value)!==void 0&&(P=y.target.value),u.setValue(t,P,{shouldDirty:T,shouldOnChange:A})},[u.setValue]),w=n.useCallback(y=>{const T=u.getValues(),A=y??D(T,t);c.publish("onBlur",t,A,T),E(t)},[]);return n.useEffect(()=>{const y=d(t,{shouldUnRegister:f});return()=>{y&&y(),m.current&&m.current()}},[f,t]),new Proxy({ref:C,name:t,defaultValue:l,value:R,onChange:S,onBlur:w,fieldState:_},{get(y,T,A){return typeof T=="string"&&T==="fieldState"&&(m.current&&m.current(),m.current=u.subscribe(`fieldStates.${t}`,()=>{p(h({name:`fieldStates.${t}`}))})),Reflect.get(y,T,A)}})},xe=({name:o,control:t,shouldUnRegister:a,defaultValue:f,render:u=({ref:d,name:c,defaultValue:h,value:E,onChange:C,onBlur:m,fieldState:l})=>null})=>{const d=Ae({name:o,defaultValue:f,shouldUnRegister:a,control:t});return u(d)},We=()=>{const[o,t]=n.useState(),a=n.useCallback(()=>t(new Date().toString()),[]);return[o,a]},Be=()=>{const[,o]=n.useState({});return n.useCallback(()=>o({}),[])},Ie=({channels:o,getWatchValue:t})=>{const a=Be(),f=n.useCallback((c,h="onChange")=>{if(!c)return o.subscribeWatch("values",()=>a()),t();if(typeof c=="string"){let E=G(c);h==="onBlur"&&(E=`blur.${E}`),o.subscribeWatch(E,(C,m)=>{C!==m&&a()})}return Array.isArray(c)&&c.forEach(E=>{let C=G(E);h==="onBlur"&&(C=`blur.${C}`),o.subscribeWatch(C,(m,l)=>{m!==l&&a()})}),t({name:c})},[]),u=n.useCallback(({name:c,compute:h,setValue:E,mode:C="onChange"})=>{if(typeof h=="function")return o.subscribe("values",()=>{const l=t({compute:h});E(l)});if(!c)return o.subscribe("values",()=>{E(t())});if(typeof c=="string"){let m=G(c);return C==="onBlur"&&(m=`blur.${m}`),o.subscribe(m,()=>{const R=t({name:c});E(R)})}if(Array.isArray(c)){const m=[];return c.forEach(l=>{let R=G(l);C==="onBlur"&&(R=`blur.${R}`);const _=o.subscribe(R,()=>{const p=t({name:c});E(p)});m.push(_)}),()=>m.forEach(l=>l())}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),d=n.useCallback((c,h,E="onChange")=>{if(!c)return o.subscribe("values",()=>h(t()));if(["onChange","onBlur"].includes(c))return o.subscribe(c,h);if(typeof c=="string"){let C=G(c);return E==="onBlur"&&(C=`blur.${C}`),o.subscribe(C,()=>h(t({name:c})))}if(Array.isArray(c)){const C=[];return c.forEach(m=>{let l=G(m);E==="onBlur"&&(l=`blur.${l}`);const R=o.subscribe(l,()=>{h(t({name:c}))});C.push(R)}),()=>C.forEach(m=>m())}throw new Error("Parameters of name must be string or array of string")},[]);return{watch:f,registerHookWatcher:u,getWatchValue:t,subscribe:d}},Me=({getWatchValue:o})=>{const t=n.useRef(new Map),a=n.useRef(new Map),f=n.useCallback(()=>a.current,[]),u=n.useCallback(()=>t.current,[]),d=n.useCallback(()=>{t.current.clear(),a.current.clear()},[]),c=l=>l.replace("values.","").replace("values",""),h=n.useCallback((l,...R)=>{const _=l.split(".");_.forEach((p,S)=>{const w=_.slice(0,_.length-S).join("."),y=t.current.get(w),T=a.current.get(w);if(S>0){const A=R[0],P=o({name:c(w)});R=[L(P,l.replace(w,""),A)]}y&&y.forEach(A=>A(...R)),T&&T.forEach(A=>A(...R))})},[]),E=n.useCallback((l,{trickle:R=!1,bubble:_=!1})=>{const p=l.split(".");let S=[o({name:c(l)})];p.forEach((w,y)=>{const T=p.slice(0,p.length-y).join("."),A=t.current.get(T),P=a.current.get(T);if(y>0&&_){const W=S[0],z=o({name:c(T)});S=[L(z,l.replace(T,""),W)]}A&&(y===0||_)&&A.forEach(W=>W(...S)),P&&(y===0||_)&&P.forEach(W=>W(...S))}),R&&(t.current.forEach((w,y)=>{y.startsWith(l)&&w.forEach(T=>T(o({name:c(y)})))}),a.current.forEach((w,y)=>{y.startsWith(l)&&w.forEach(T=>T(o({name:c(y)})))}))},[]),C=n.useCallback((l,R)=>(t.current.has(l)||t.current.set(l,new Set),t.current.get(l).add(R),()=>{var _;return(_=t.current.get(l))==null?void 0:_.delete(R)}),[]),m=n.useCallback((l,R)=>{a.current.has(l)||(a.current.set(l,new Set),a.current.get(l).add(R))},[]);return{reset:d,publish:h,subscribe:C,subscribeWatch:m,getEvents:u,getWatchEvents:f,trigger:E}},Ye=({defaultValues:o=Pe,shouldUnRegister:t=!1,groups:a=[]}={})=>{const[f,u]=We(),d=n.useRef(),c=n.useRef({}),h=n.useRef({}),E=n.useRef({...ve}),C=n.useRef({...o}),m=n.useRef({...o}),l=n.useRef(new Set),R=n.useRef(new Set(a)),_=n.useCallback((e,s=m.current)=>Object.keys(s).reduce((i,b)=>{if(typeof s[b]=="object")return{...i,[b]:_(e,s[b])};const N={...e?{}:h.current[b]||{},...fe};return{...i,[b]:N}},{}),[]),p=n.useCallback((e={},{clearCustomFormStates:s=!1,clearCustomFieldStates:i=!1,groups:b=R.current}={})=>{c.current={},m.current={...m.current,...e},C.current={...m.current},l.current=new Set,R.current=new Set(b),E.current={...s?{}:E.current,...ve},h.current=_(i),k.reset(),u()},[]),S=n.useCallback(()=>{let e=Object.fromEntries(new FormData(d.current));l.current.forEach(i=>{e=L(e,i,D(C.current,i))});let s={...C.current,...e};return Se(s)},[]),w=n.useCallback(e=>ye(e.target),[]),y=n.useCallback(()=>m.current,[]),T=n.useCallback(()=>l.current,[]),A=n.useCallback((e,s)=>s?Array.isArray(s)?s.reduce((i,b)=>({...i,[b]:D(e,b)}),{}):D(e,s):{...e},[]),P=n.useCallback(e=>A(C.current,e),[A]),W=n.useCallback(e=>A(c.current,e),[A]),z=n.useCallback(e=>A(h.current,e),[A]),Z=n.useCallback(e=>A({...E.current,lastReset:f},e),[f]),H=n.useCallback(({name:e,compute:s}={})=>!e&&!s||e==="values"?P():typeof s=="function"?s(P()):Array.isArray(e)?e.reduce((i,b)=>({...i,[b]:H({name:b})}),{}):D({...C.current,errors:c.current,fieldStates:h.current,formState:Z()},e),[]),k=Me({getWatchValue:H}),{watch:ne,registerHookWatcher:ee,subscribe:oe}=Ie({getWatchValue:H,channels:k}),de=n.useCallback((e,s)=>{typeof s=="function"&&(s=s(Z(e)));const i=E.current,b=D(i,e);b!==s&&(E.current=L(E.current,e,s),k.publish(`formState.${e}`,s,b))},[]),K=n.useCallback((e,s)=>{typeof s=="function"&&(s=s(W(e))),B(e,"error",s)},[]),X=n.useCallback(e=>{B(e,"error",null)},[]),ce=n.useCallback(()=>{E.current.isError&&Object.keys(c.current).forEach(e=>X(e))},[]),B=n.useCallback((e,s,i)=>{try{if(typeof i=="function"&&(i=i(z(e))),R.current.has(e))if(typeof i=="object"&&i!==null){Object.keys(i).forEach(x=>{B(`${e}.${x}`,s,i[x])});return}else return console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);const b=D(h.current,e)||{...fe},N=D(b,s);if(N!==i){if(h.current=L(h.current,`${e}.${s}`,i),k.publish(`fieldStates.${e}.${s}`,i,N),s==="error"){const x=D(c.current,e),I=i||null;x!==I&&(c.current=L(c.current,e,I),k.publish(`errors.${e}`,I,x));const J=Fe(R.current,c.current);E.current.errorFields=J,k.publish("formState.errorFields",J);const le=J.length>0;if(E.current.isError!==le){const ge=E.current.isError;E.current.isError=le,k.publish("formState.isError",le,ge)}}if(s==="isDirty"){const x=ke(R.current,h.current);E.current.dirtyFields=x,k.publish("formState.dirtyFields",x);const I=x.length>0;if(E.current.isDirty!==I){const J=E.current.isDirty;E.current.isDirty=I,k.publish("formState.isDirty",I,J)}}if(s==="isTouched"){const x=pe(R.current,h.current);E.current.touchedFields=x,k.publish("formState.touchedFields",x)}}}catch(b){console.log(b)}},[]),ae=n.useCallback(e=>{B(e,"isDirty",!1),B(e,"isTouched",!1),B(e,"error",null)},[]),ue=n.useCallback(e=>{const s=ye(e.target);s?K(e.target.name,s):X(e.target.name)},[]),r=n.useCallback((e,s,{shouldDirty:i=!0,shouldOnChange:b=!0}={})=>{if(typeof s=="function"&&(s=s(P(e))),R.current.has(e)){typeof s=="object"&&s!==null?Object.keys(s).forEach(I=>{r(`${e}.${I}`,s[I],{shouldDirty:i,shouldOnChange:b})}):console.error(`Cannot set primitive value for nested parent field "${e}". Please set value for its children or provide an object.`);return}const N=D(C.current,e);if(s===N)return;if(C.current=L(C.current,e,s),k.publish(`values.${e}`,s,N),e.includes(".")){const I=e.split("."),J=I.findIndex((le,ge)=>!R.current.has(I.slice(0,ge+1).join(".")));J!==-1&&(e=I.slice(0,J+1).join("."))}s&&B(e,"isTouched",!0);const x=s!==(D(m.current,e)||"");i&&B(e,"isDirty",x),b&&k.publish("onChange",e,s,N)},[]),g=n.useCallback(e=>{const s=e.split(".");let i="";s.forEach((b,N)=>{N<s.length-1&&(i=i?`${i}.${b}`:b,R.current.add(i))})},[]),F=n.useCallback(e=>{Array.isArray(e)?e.forEach(s=>g(s+".")):g(e+".")},[]),j=n.useCallback((e="",{shouldUnRegister:s=t}={})=>e?(l.current.add(e),h.current=L(h.current,e,{...fe}),e.includes(".")&&g(e),()=>{s&&(r(e,void 0,{shouldDirty:!1,shouldOnChange:!1}),l.current.delete(e))}):console.error("Controller must have a name"),[]),V=n.useCallback((e,{keepError:s,keepDirty:i,keepTouched:b,defaultValue:N})=>{if(!l.current.has(e))throw new Error(`Cannot reset "${e}" because it's uncontrolled field`);m.current=L(m.current,e,N),C.current=L(C.current,e,N),k.publish(`values.${e}`,N),s||X(e),i||B(e,"isDirty",!1),b||B(e,"isTouched",!1)},[]),Y=n.useCallback((e,{bubble:s,trickle:i}={})=>{if(!e){k.trigger("values",{bubble:s,trickle:i??!0}),k.trigger("blur.values",{bubble:s,trickle:i??!0});return}if(!Array.isArray(e)){const b=G(e);k.trigger(b,{bubble:s,trickle:i}),k.trigger(`blur.${b}`,{bubble:s,trickle:i});return}e.forEach(b=>{const N=G(b);k.trigger(N,{bubble:s,trickle:i}),k.trigger(`blur.${N}`,{bubble:s,trickle:i})})},[]),Q=n.useCallback(e=>{k.publish(`blur.values.${e}`,P(e)),k.publish(`blur.errors.${e}`,W(e));const s=z(e);Object.keys(s||{}).forEach(b=>{k.publish(`blur.fieldStates.${e}.${b}`,s[b])});const i=Z();Object.keys(i||{}).forEach(b=>{k.publish(`blur.formState.${b}`,i[b])})},[]),re=n.useCallback((e,s=P(e))=>{k.publish("onBlur",e,s,P()),Q(e)},[]),O=n.useMemo(()=>({subscribe:oe,reset:p,trigger:Y,reload:u,resetField:V,setValue:r,getValues:P,getErrors:W,getFieldStates:z,getFormState:Z,setError:K,clearError:X,clearErrors:ce,checkValidity:ue,getFieldValidity:w,getDefaultValues:y,setFieldState:B,triggerFieldBlur:re,resetFieldState:ae,getControlledFields:T,setFormState:de,getEvents:k.getEvents,getWatchEvents:k.getWatchEvents,addGroups:F}),[f]),U=n.useCallback(()=>{[...d.current.querySelectorAll("[name]")].forEach(i=>{const b=i.name||"";b.includes(".")&&g(b),!i.defaultValue&&!l.current.has(b)&&D(m.current,b)&&(i.defaultValue=D(m.current,b))});const s=S();C.current={...s},m.current={...s}},[]),te=n.useMemo(()=>({ref:d,watch:ne,actions:O,initForm:U,registerController:j,registerHookWatcher:ee,lastReloadedAt:f,loadFormValues:S,getWatchValue:H,triggerBlurWatchers:Q,channels:k}),[f]),be=n.useMemo(()=>({control:te,actions:O,watch:ne}),[f]);return n.useLayoutEffect(()=>{d.current&&U()},[f]),n.useLayoutEffect(()=>{h.current=_(!1)},[]),be};M.Controller=xe,M.Form=we,M.restoreFromDotNotation=Se,M.useController=Ae,M.useForm=Ye,M.useFormContext=ie,M.useWatch=Te,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|