react-simple-formkit 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 ie;function Re(){if(ie)return Q;ie=1;var s=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function l(f,h,E){var g=null;if(E!==void 0&&(g=""+E),h.key!==void 0&&(g=""+h.key),"key"in h){E={};for(var R in h)R!=="key"&&(E[R]=h[R])}else E=h;return h=E.ref,{$$typeof:s,type:f,key:g,ref:h!==void 0?h:null,props:E}}return Q.Fragment=u,Q.jsx=l,Q.jsxs=l,Q}var K={};/**
9
+ */var ie;function ke(){if(ie)return Q;ie=1;var s=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function l(i,E,h){var g=null;if(h!==void 0&&(g=""+h),E.key!==void 0&&(g=""+E.key),"key"in E){h={};for(var k in E)k!=="key"&&(h[k]=E[k])}else h=E;return E=h.ref,{$$typeof:s,type:i,key:g,ref:E!==void 0?E:null,props:h}}return Q.Fragment=u,Q.jsx=l,Q.jsxs=l,Q}var K={};/**
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 fe;function ve(){return fe||(fe=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===z?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case b:return"Fragment";case x:return"Profiler";case A:return"StrictMode";case ee:return"Suspense";case re:return"SuspenseList";case P:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case d:return"Portal";case oe:return(e.displayName||"Context")+".Provider";case M:return(e._context.displayName||"Context")+".Consumer";case q:var o=e.render;return e=e.displayName,e||(e=o.displayName||o.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case te:return o=e.displayName||null,o!==null?o:s(e.type)||"Memo";case J:o=e._payload,e=e._init;try{return s(e(o))}catch{}}return null}function u(e){return""+e}function l(e){try{u(e);var o=!1}catch{o=!0}if(o){o=console;var k=o.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return k.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),u(e)}}function f(e){if(e===b)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===J)return"<...>";try{var o=s(e);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function h(){var e=V.A;return e===null?null:e.getOwner()}function E(){return Error("react-stack-top-frame")}function g(e){if($.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function R(e,o){function k(){G||(G=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",o))}k.isReactWarning=!0,Object.defineProperty(e,"key",{get:k,configurable:!0})}function v(){var e=s(this.type);return H[e]||(H[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function F(e,o,k,p,O,_,B,I){return k=_.ref,e={$$typeof:c,type:e,key:o,props:_,_owner:O},(k!==void 0?k:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:v}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:I}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function i(e,o,k,p,O,_,B,I){var y=o.children;if(y!==void 0)if(p)if(W(y)){for(p=0;p<y.length;p++)m(y[p]);Object.freeze&&Object.freeze(y)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(y);if($.call(o,"key")){y=s(e);var N=Object.keys(o).filter(function(se){return se!=="key"});p=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",Z[y+p]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var fe;function ve(){return fe||(fe=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===z?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case b:return"Fragment";case x:return"Profiler";case A:return"StrictMode";case ee:return"Suspense";case re:return"SuspenseList";case P:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case d:return"Portal";case oe:return(e.displayName||"Context")+".Provider";case M:return(e._context.displayName||"Context")+".Consumer";case q:var o=e.render;return e=e.displayName,e||(e=o.displayName||o.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case te:return o=e.displayName||null,o!==null?o:s(e.type)||"Memo";case J:o=e._payload,e=e._init;try{return s(e(o))}catch{}}return null}function u(e){return""+e}function l(e){try{u(e);var o=!1}catch{o=!0}if(o){o=console;var R=o.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return R.call(o,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),u(e)}}function i(e){if(e===b)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===J)return"<...>";try{var o=s(e);return o?"<"+o+">":"<...>"}catch{return"<...>"}}function E(){var e=V.A;return e===null?null:e.getOwner()}function h(){return Error("react-stack-top-frame")}function g(e){if($.call(e,"key")){var o=Object.getOwnPropertyDescriptor(e,"key").get;if(o&&o.isReactWarning)return!1}return e.key!==void 0}function k(e,o){function R(){G||(G=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",o))}R.isReactWarning=!0,Object.defineProperty(e,"key",{get:R,configurable:!0})}function v(){var e=s(this.type);return H[e]||(H[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function F(e,o,R,p,O,_,B,I){return R=_.ref,e={$$typeof:c,type:e,key:o,props:_,_owner:O},(R!==void 0?R:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:v}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:I}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,o,R,p,O,_,B,I){var y=o.children;if(y!==void 0)if(p)if(W(y)){for(p=0;p<y.length;p++)m(y[p]);Object.freeze&&Object.freeze(y)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(y);if($.call(o,"key")){y=s(e);var N=Object.keys(o).filter(function(se){return se!=="key"});p=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",Z[y+p]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,p,y,N,y),Z[y+p]=!0)}if(y=null,k!==void 0&&(l(k),y=""+k),g(o)&&(l(o.key),y=""+o.key),"key"in o){k={};for(var j in o)j!=="key"&&(k[j]=o[j])}else k=o;return y&&R(k,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,y,_,O,h(),k,B,I)}function m(e){typeof e=="object"&&e!==null&&e.$$typeof===c&&e._store&&(e._store.validated=1)}var a=t,c=Symbol.for("react.transitional.element"),d=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),oe=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),z=Symbol.for("react.client.reference"),V=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,W=Array.isArray,D=console.createTask?console.createTask:function(){return null};a={"react-stack-bottom-frame":function(e){return e()}};var G,H={},X=a["react-stack-bottom-frame"].bind(a,E)(),S=D(f(E)),Z={};K.Fragment=b,K.jsx=function(e,o,k,p,O){var _=1e4>V.recentlyCreatedOwnerStacks++;return i(e,o,k,!1,p,O,_?Error("react-stack-top-frame"):X,_?D(f(e)):S)},K.jsxs=function(e,o,k,p,O){var _=1e4>V.recentlyCreatedOwnerStacks++;return i(e,o,k,!0,p,O,_?Error("react-stack-top-frame"):X,_?D(f(e)):S)}}()),K}var be;function Ce(){return be||(be=1,process.env.NODE_ENV==="production"?ue.exports=Re():ue.exports=ve()),ue.exports}var de=Ce();const C=()=>{},Ee=t.createContext({ref:null,watch:C,actions:{reset:C,resetField:C,setValue:C,getValues:C,getErrors:C,getFieldStates:C,getFormStates:C,setError:C,clearError:C,clearErrors:C,checkValidity:C,getNumberFields:C,getFieldValidity:C,getDefaultValues:C,setFieldState:C,resetFieldState:C,getControlledFields:C},registerController:C,registerHookWatcher:C,lastReloadedAt:C,loadFormValues:C,getWatchValue:C,channels:{}}),le=()=>t.useContext(Ee),Se=({id:s,control:u,method:l,action:f,children:h,onSubmit:E=()=>{},onInput:g=()=>{},onChange:R=()=>{},onBlur:v=()=>{},onReset:F=()=>{},numberFields:i=[],className:m,...a})=>(t.useEffect(()=>{const c=u.channels.subscribe("onChange",R),d=u.channels.subscribe("onBlur",v);return()=>{c(),d()}},[]),de.jsx(Ee.Provider,{value:u,children:de.jsx("form",{id:s,ref:u.ref,action:f,method:l,className:m,onInput:g,onSubmit:c=>{l||c.preventDefault();const d=u.loadFormValues();E(d)},onChange:c=>{const d=c.target.name;!d||u.actions.getControlledFields().has(d)||u.actions.setValue(d,c.target.value)},onBlur:c=>{const d=c.target.name;if(!d||u.actions.getControlledFields().has(d))return;const b=c.target.value;u.channels.publish("onBlur",d,b,u.actions.getValues())},onReset:c=>{u.actions.reset(),F(c)},...a,children:h},u.lastReloadedAt)})),ge=({control:s,name:u,compute:l})=>{const{getWatchValue:f,registerHookWatcher:h}=s||le(),E=f({name:u,compute:l}),[g,R]=t.useState(E);return t.useEffect(()=>{const v=h({name:u,compute:l,value:g,setValue:R});return()=>v.forEach(F=>F())},[]),g},me=({name:s,defaultValue:u})=>{const{actions:l,registerController:f,channels:h}=le(),E=t.useRef(),g=l.getDefaultValues()[s]||u||"",[R,v]=t.useState(g),F=ge({name:`fieldStates.${s}`}),i=t.useCallback((a,{shouldDirty:c=!0,shouldOnChange:d=!0}={})=>{var A,x;let b=a;(A=a==null?void 0:a.target)!=null&&A.value&&(b=a.target.value),(x=a==null?void 0:a.target)!=null&&x.checked&&(b=a.target.checked+""),v(b),l.setValue(s,b,{shouldDirty:c,shouldOnChange:d})},[l.setValue]),m=t.useCallback(a=>{const c=l.getValues(),d=a??c[s];h.publish("onBlur",s,d,c)},[]);return t.useEffect(()=>f(s,v),[]),{ref:E,name:s,defaultValue:g,value:R,onChange:i,onBlur:m,fieldState:F}},pe=({name:s,defaultValue:u,render:l=({ref:f,name:h,defaultValue:E,value:g,onChange:R,onBlur:v,customState:F,setCustomState:i})=>null})=>{const f=me({name:s,defaultValue:u});return l(f)},ye=["errors","fieldStates","formState"],ae=(s={},u="")=>u.split(".").reduce((l,f)=>l&&l[f]!==void 0?l[f]:void 0,s),we=(s={},u="",l)=>{let f=s;const h=u.split(".");return h.forEach((E,g)=>{if(g<h.length-1){f[E]||(f[E]={}),f=f[E];return}f[E]=l}),s},U=s=>ye.some(u=>s.startsWith(u))?s:"values."+s,Fe=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],he=s=>{typeof s.setCustomValidity=="function"&&s.setCustomValidity("");let u=s.validity,l=Fe.find(f=>u[f]);if(l)return{type:l,message:s.validationMessage}};class Te{constructor(){this.events=new Map,this.watchEvents=new Map}getWatchEvents(){return this.watchEvents}getEvents(){return this.events}subscribe(u,l){return this.events.has(u)||this.events.set(u,new Set),this.events.get(u).add(l),()=>{var f;return(f=this.events.get(u))==null?void 0:f.delete(l)}}subscribeWatch(u,l){this.watchEvents.has(u)||(this.watchEvents.set(u,new Set),this.watchEvents.get(u).add(l))}publish(u,...l){this.events.forEach((f,h)=>{u.includes(h)&&f.forEach(E=>E(...l))}),this.watchEvents.forEach((f,h)=>{u.includes(h)&&f.forEach(E=>E(...l))})}reset(){this.events.clear(),this.watchEvents.clear()}}const _e=()=>{const s=t.useRef(new Te),u=t.useCallback((R,...v)=>{s.current.publish(R,...v)},[]),l=t.useCallback((R,v)=>s.current.subscribe(R,v),[]),f=t.useCallback((R,v)=>{s.current.subscribeWatch(R,v)},[]),h=t.useCallback(()=>s.current.getEvents(),[]),E=t.useCallback(()=>s.current.getWatchEvents(),[]),g=t.useCallback(()=>{s.current.reset()},[]);return{publish:u,subscribe:l,reset:g,getEvents:h,subscribeWatch:f,getWatchEvents:E}},Ae=()=>{const[s,u]=t.useState(),l=t.useCallback(()=>u(new Date().toString()),[]);return[s,l]},Oe=()=>{const[,s]=t.useState({});return t.useCallback(()=>s({}),[])},Pe=({channels:s,getValues:u,getErrors:l,getFieldStates:f,getFormState:h})=>{const E=Oe(),g=t.useCallback(({name:i,compute:m})=>{if(typeof m=="function")return m(u());if(Array.isArray(i)){const a={};return i.forEach(c=>{a[c]=g({name:c})}),a}return ae({...u(),errors:{...l()},formState:{...h()},fieldStates:{...f()}},i)},[]),R=t.useCallback(i=>{if(!i)return s.subscribeWatch("values",()=>E()),u();if(typeof i=="string"){const m=U(i);return s.subscribeWatch(m,()=>E()),g({name:i})}if(Array.isArray(i)){const m={};return i.forEach(a=>{const c=U(a);s.subscribeWatch(c,()=>E()),m[a]=g({name:a})}),{...m}}throw new Error("Parameters of watch must be string or array of string")},[]),v=t.useCallback(({name:i,compute:m,setValue:a})=>{if(typeof m=="function")return[s.subscribe("values",()=>{const d=g({compute:m});a(d)})];if(!i)return[s.subscribe("values",()=>{a(u())})];if(typeof i=="string"){const c=U(i);return[s.subscribe(c,()=>{const b=g({name:i});a(b)})]}if(Array.isArray(i)){const c=g({name:i}),d=[];return i.forEach(b=>{const A=U(b),x=s.subscribe(A,()=>{const M=g({name:b});c[b]=M,a({...c})});d.push(x)}),d}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),F=t.useCallback((i,m)=>{if(!i)return s.subscribe("values",m);if(typeof i=="string"){const a=U(i);return s.subscribe(a,m)}if(Array.isArray(i)){const a={},c=[];return i.forEach(d=>{const b=U(d),A=s.subscribe(b,()=>{a[d]=g({name:d}),m({...a})});c.push(A)}),c}throw new Error("Parameters of name must be string or array of string")},[s]);return{watch:R,registerHookWatcher:v,getWatchValue:g,subscribe:F}},ce={isDirty:!1,isTouched:!1,error:null},je=[],xe={},Ne=({numberFields:s=je,defaultValues:u=xe,shouldUnRegister:l=!1,shouldConvertNumber:f=!1}={})=>{const[h,E]=Ae(),g=t.useRef(),R=t.useRef(!1),v=t.useRef(!1),F=t.useRef(s),i=t.useRef(new Map),m=t.useRef({}),a=t.useRef({}),c=t.useRef({...u}),d=t.useRef({...u}),b=_e(),A=t.useCallback(()=>{a.current=Object.keys(d.current).reduce((r,n)=>({...r,[n]:{...ce}}),{})},[]),x=t.useCallback((r={})=>{d.current={...d.current,...r},c.current={...d.current},i.current.forEach((n,w)=>{n(d.current[w])}),R.current=!1,m.current={},F.current=s,i.current=new Map,b.reset(),A(),s.length>0&&(f=!0),E()},[]),M=t.useCallback(()=>{const r=Object.fromEntries(new FormData(g.current));return i.current.forEach((w,T)=>{r[T]=c.current[T]}),f&&F.current.forEach(w=>r.hasOwnProperty(w)&&(r[w]=Number(r[w])||0)),{...c.current,...r}},[]),oe=t.useCallback(()=>!!Object.values($()).find(r=>r.isDirty),[]),q=t.useCallback(()=>!!Object.values(V()).find(r=>!!r),[]),ee=t.useCallback(r=>he(r.target),[]),re=t.useCallback(()=>d.current,[]),te=t.useCallback(()=>F.current,[]),J=t.useCallback(()=>i.current,[]),P=t.useCallback((r,n)=>n?Array.isArray(n)?n.reduce((w,T)=>({...w,[T]:ae(r,T)}),{}):ae(r,n):{...r},[]),z=t.useCallback(r=>P(c.current,r),[P]),V=t.useCallback(r=>P(m.current,r),[P]),$=t.useCallback(r=>P(a.current,r),[P]),W=t.useCallback(r=>P({isDirty:R.current,isError:v.current,errorFields:Object.keys(m.current).filter(n=>!!m.current[n]),dirtyFields:Object.keys(a.current).filter(n=>a.current[n].isDirty),touchedFields:Object.keys(a.current).filter(n=>a.current[n].isTouched)},r),[P]),{watch:D,registerHookWatcher:G,getWatchValue:H,subscribe:X}=Pe({channels:b,getValues:z,getErrors:V,getFieldStates:$,getFormState:W}),S=t.useCallback((r,n,w)=>{const T=a.current[r]||{...ce};ae(T,n)!==w&&(we(a.current,`${r}.${n}`,w),b.publish(`fieldStates.${r}.${n}`,w),n==="error"&&b.publish("formState.errorFields",W("errorFields")),n==="isDirty"&&b.publish("formState.dirtyFields",W("dirtyFields")),n==="isTouched"&&b.publish("formState.touchedFields",W("touchedFields")))},[]),Z=t.useCallback(r=>{S(r,"isDirty",!1),S(r,"isTouched",!1),S(r,"error",null)},[S]),e=t.useCallback((r,n)=>{if(m.current[r]===n)return;m.current[r]=n,S(r,"error",n),b.publish(`errors.${r}`,n);const T=q();v.current!==T&&(v.current=T,b.publish("formState.isError",T))},[S]),o=t.useCallback(r=>{if(!m.current[r])return;m.current[r]=null,S(r,"error",null),b.publish(`errors.${r}`,null);const n=q();v.current!==n&&(v.current=n,b.publish("formState.isError",n))},[S]),k=t.useCallback(()=>{if(Object.keys(m.current)===0)return;Object.keys(m.current).forEach(n=>o(n)),m.current={};const r=q();v.current!==r&&(v.current=r,b.publish("formState.isError",r))},[]),p=t.useCallback(r=>{const n=he(r.target);n?e(r.target.name,n):o(r.target.name)},[e,o]),O=t.useCallback((r,n,{shouldDirty:w=!0,shouldOnChange:T=!0}={})=>{if(n===c.current[r])return;f&&F.current.includes(r)&&(n=Number(n)||void 0),S(r,"isTouched",!0);const ne=n!==d.current[r];w&&a.current[r].isDirty!==ne&&S(r,"isDirty",ne);const Y=oe();R.current!==Y&&(R.current=Y,b.publish("formState.isDirty",Y)),c.current[r]=n;const L=i.current.get(r);L&&L(n),b.publish(`values.${r}`,n,{shouldDirty:w,shouldOnChange:T}),T&&b.publish("onChange",r,n,c.current)},[S]),_=t.useCallback((r,n)=>(i.current.set(r,n),a.current[r]={...ce},()=>{l&&i.current.delete(r)}),[]),B=t.useCallback((r,{keepError:n,keepDirty:w,keepTouched:T,keepCustomState:ne,defaultValue:Y})=>{const L=i.current.get(r);if(!L)throw new Error(`Cannot reset "${r}" because it's uncontrolled field`);d.current[r]=Y,c.current[r]=Y,L&&L(Y),n||o(r),w||S(r,"isDirty",!1),T||S(r,"isTouched",!1)},[o,S]),I=t.useCallback((r,n=j.getValues(r))=>{b.publish("onBlur",r,n,j.getValues())},[]),y=t.useCallback(r=>b.subscribe("onChange",r),[]),N=t.useCallback(r=>b.subscribe("onBlur",r),[]),j=t.useMemo(()=>({subscribe:X,reset:x,resetField:B,setValue:O,getValues:z,getErrors:V,getFieldStates:$,getFormState:W,setError:e,clearError:o,clearErrors:k,checkValidity:p,getNumberFields:te,getFieldValidity:ee,getDefaultValues:re,setFieldState:S,triggerFieldBlur:I,resetFieldState:Z,getControlledFields:J,subscribeChange:y,subscribeBlur:N,getEvents:b.getEvents,getWatchEvents:b.getWatchEvents}),[X,x,B,O,z,V,$,W,e,o,k,p,te,ee,re,S,Z,I,J,y,N]),se=t.useMemo(()=>({ref:g,watch:D,actions:j,registerController:_,registerHookWatcher:G,lastReloadedAt:h,loadFormValues:M,getWatchValue:H,channels:b}),[g,D,j,_,G,h,M,H,b]),ke=t.useMemo(()=>({control:se,actions:j,watch:D}),[h,se,j,D]);return t.useLayoutEffect(()=>{if([...g.current.querySelectorAll("[name]")].forEach(n=>{!n.defaultValue&&!i.current.has(n.name)&&d.current[n.name]&&(n.defaultValue=d.current[n.name]),n.type==="number"&&!F.current.includes(n.name)&&F.current.push(n.name)}),g.current){const n=M();c.current={...n},d.current={...n}}},[h]),t.useLayoutEffect(()=>{A()},[]),ke};exports.Controller=pe;exports.Form=Se;exports.useController=me;exports.useForm=Ne;exports.useFormContext=le;exports.useWatch=ge;
22
+ <%s key={someKey} {...props} />`,p,y,N,y),Z[y+p]=!0)}if(y=null,R!==void 0&&(l(R),y=""+R),g(o)&&(l(o.key),y=""+o.key),"key"in o){R={};for(var j in o)j!=="key"&&(R[j]=o[j])}else R=o;return y&&k(R,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,y,_,O,E(),R,B,I)}function m(e){typeof e=="object"&&e!==null&&e.$$typeof===c&&e._store&&(e._store.validated=1)}var a=t,c=Symbol.for("react.transitional.element"),d=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),oe=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),z=Symbol.for("react.client.reference"),V=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,W=Array.isArray,D=console.createTask?console.createTask:function(){return null};a={"react-stack-bottom-frame":function(e){return e()}};var G,H={},X=a["react-stack-bottom-frame"].bind(a,h)(),S=D(i(h)),Z={};K.Fragment=b,K.jsx=function(e,o,R,p,O){var _=1e4>V.recentlyCreatedOwnerStacks++;return f(e,o,R,!1,p,O,_?Error("react-stack-top-frame"):X,_?D(i(e)):S)},K.jsxs=function(e,o,R,p,O){var _=1e4>V.recentlyCreatedOwnerStacks++;return f(e,o,R,!0,p,O,_?Error("react-stack-top-frame"):X,_?D(i(e)):S)}}()),K}var be;function Ce(){return be||(be=1,process.env.NODE_ENV==="production"?ue.exports=ke():ue.exports=ve()),ue.exports}var de=Ce();const C=()=>{},Ee=t.createContext({ref:null,watch:C,actions:{reset:C,resetField:C,setValue:C,getValues:C,getErrors:C,getFieldStates:C,getFormStates:C,setError:C,clearError:C,clearErrors:C,checkValidity:C,getNumberFields:C,getFieldValidity:C,getDefaultValues:C,setFieldState:C,resetFieldState:C,getControlledFields:C},registerController:C,registerHookWatcher:C,lastReloadedAt:C,loadFormValues:C,getWatchValue:C,channels:{}}),le=()=>t.useContext(Ee),Se=({id:s,control:u,method:l,action:i,children:E,onSubmit:h=()=>{},onInput:g=()=>{},onChange:k=()=>{},onBlur:v=()=>{},onReset:F=()=>{},numberFields:f=[],className:m,...a})=>(t.useEffect(()=>{const c=u.channels.subscribe("onChange",k),d=u.channels.subscribe("onBlur",v);return()=>{c(),d()}},[u.lastReloadedAt]),de.jsx(Ee.Provider,{value:u,children:de.jsx("form",{id:s,ref:u.ref,action:i,method:l,className:m,onInput:g,onSubmit:c=>{l||c.preventDefault();const d=u.loadFormValues();h(d)},onChange:c=>{const d=c.target.name;!d||u.actions.getControlledFields().has(d)||u.actions.setValue(d,c.target.value)},onBlur:c=>{const d=c.target.name;if(!d||u.actions.getControlledFields().has(d))return;const b=c.target.value;u.channels.publish("onBlur",d,b,u.actions.getValues())},onReset:c=>{u.actions.reset(),F(c)},...a,children:E},u.lastReloadedAt)})),ge=({control:s,name:u,compute:l})=>{const{getWatchValue:i,registerHookWatcher:E}=s||le(),h=i({name:u,compute:l}),[g,k]=t.useState(h);return t.useEffect(()=>{const v=E({name:u,compute:l,value:g,setValue:k});return()=>v.forEach(F=>F())},[]),g},me=({name:s,defaultValue:u})=>{const{actions:l,registerController:i,channels:E}=le(),h=t.useRef(),g=l.getDefaultValues()[s]||u||"",[k,v]=t.useState(g),F=ge({name:`fieldStates.${s}`}),f=t.useCallback((a,{shouldDirty:c=!0,shouldOnChange:d=!0}={})=>{var A,x;let b=a;(A=a==null?void 0:a.target)!=null&&A.value&&(b=a.target.value),(x=a==null?void 0:a.target)!=null&&x.checked&&(b=a.target.checked+""),v(b),l.setValue(s,b,{shouldDirty:c,shouldOnChange:d})},[l.setValue]),m=t.useCallback(a=>{const c=l.getValues(),d=a??c[s];E.publish("onBlur",s,d,c)},[]);return t.useEffect(()=>i(s,v),[]),{ref:h,name:s,defaultValue:g,value:k,onChange:f,onBlur:m,fieldState:F}},pe=({name:s,defaultValue:u,render:l=({ref:i,name:E,defaultValue:h,value:g,onChange:k,onBlur:v,fieldState:F})=>null})=>{const i=me({name:s,defaultValue:u});return l(i)},ye=["errors","fieldStates","formState"],ae=(s={},u="")=>u.split(".").reduce((l,i)=>l&&l[i]!==void 0?l[i]:void 0,s),we=(s={},u="",l)=>{let i=s;const E=u.split(".");return E.forEach((h,g)=>{g<E.length-1&&(i[h]||(i[h]={}),g===E.length-2&&(i[h]={...i[h]}),i=i[h]),i[h]=l}),s},U=s=>ye.some(u=>s.startsWith(u))?s:"values."+s,Fe=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],he=s=>{typeof s.setCustomValidity=="function"&&s.setCustomValidity("");let u=s.validity,l=Fe.find(i=>u[i]);if(l)return{type:l,message:s.validationMessage}};class Te{constructor(){this.events=new Map,this.watchEvents=new Map}getWatchEvents(){return this.watchEvents}getEvents(){return this.events}subscribe(u,l){return this.events.has(u)||this.events.set(u,new Set),this.events.get(u).add(l),()=>{var i;return(i=this.events.get(u))==null?void 0:i.delete(l)}}subscribeWatch(u,l){this.watchEvents.has(u)||(this.watchEvents.set(u,new Set),this.watchEvents.get(u).add(l))}publish(u,...l){this.events.forEach((i,E)=>{u.includes(E)&&i.forEach(h=>h(...l))}),this.watchEvents.forEach((i,E)=>{u.includes(E)&&i.forEach(h=>h(...l))})}reset(){this.events.clear(),this.watchEvents.clear()}}const _e=()=>{const s=t.useRef(new Te),u=t.useCallback((k,...v)=>{s.current.publish(k,...v)},[]),l=t.useCallback((k,v)=>s.current.subscribe(k,v),[]),i=t.useCallback((k,v)=>{s.current.subscribeWatch(k,v)},[]),E=t.useCallback(()=>s.current.getEvents(),[]),h=t.useCallback(()=>s.current.getWatchEvents(),[]),g=t.useCallback(()=>{s.current.reset()},[]);return{publish:u,subscribe:l,reset:g,getEvents:E,subscribeWatch:i,getWatchEvents:h}},Ae=()=>{const[s,u]=t.useState(),l=t.useCallback(()=>u(new Date().toString()),[]);return[s,l]},Oe=()=>{const[,s]=t.useState({});return t.useCallback(()=>s({}),[])},Pe=({channels:s,getValues:u,getErrors:l,getFieldStates:i,getFormState:E})=>{const h=Oe(),g=t.useCallback(({name:f,compute:m})=>{if(typeof m=="function")return m(u());if(Array.isArray(f)){const a={};return f.forEach(c=>{a[c]=g({name:c})}),a}return ae({...u(),errors:{...l()},formState:{...E()},fieldStates:{...i()}},f)},[]),k=t.useCallback(f=>{if(!f)return s.subscribeWatch("values",()=>h()),u();if(typeof f=="string"){const m=U(f);return s.subscribeWatch(m,()=>h()),g({name:f})}if(Array.isArray(f)){const m={};return f.forEach(a=>{const c=U(a);s.subscribeWatch(c,()=>h()),m[a]=g({name:a})}),{...m}}throw new Error("Parameters of watch must be string or array of string")},[]),v=t.useCallback(({name:f,compute:m,setValue:a})=>{if(typeof m=="function")return[s.subscribe("values",()=>{const d=g({compute:m});a(d)})];if(!f)return[s.subscribe("values",()=>{a(u())})];if(typeof f=="string"){const c=U(f);return[s.subscribe(c,()=>{const b=g({name:f});a(b)})]}if(Array.isArray(f)){const c=g({name:f}),d=[];return f.forEach(b=>{const A=U(b),x=s.subscribe(A,()=>{const M=g({name:b});c[b]=M,a({...c})});d.push(x)}),d}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),F=t.useCallback((f,m)=>{if(!f)return s.subscribe("values",m);if(typeof f=="string"){const a=U(f);return s.subscribe(a,m)}if(Array.isArray(f)){const a={},c=[];return f.forEach(d=>{const b=U(d),A=s.subscribe(b,()=>{a[d]=g({name:d}),m({...a})});c.push(A)}),c}throw new Error("Parameters of name must be string or array of string")},[s]);return{watch:k,registerHookWatcher:v,getWatchValue:g,subscribe:F}},ce={isDirty:!1,isTouched:!1,error:null},je=[],xe={},Ne=({numberFields:s=je,defaultValues:u=xe,shouldUnRegister:l=!1,shouldConvertNumber:i=!1}={})=>{const[E,h]=Ae(),g=t.useRef(),k=t.useRef(!1),v=t.useRef(!1),F=t.useRef(s),f=t.useRef(new Map),m=t.useRef({}),a=t.useRef({}),c=t.useRef({...u}),d=t.useRef({...u}),b=_e(),A=t.useCallback(()=>{a.current=Object.keys(d.current).reduce((r,n)=>({...r,[n]:{...ce}}),{})},[]),x=t.useCallback((r={})=>{d.current={...d.current,...r},c.current={...d.current},f.current.forEach((n,w)=>{n(d.current[w])}),k.current=!1,m.current={},F.current=s,f.current=new Map,b.reset(),A(),s.length>0&&(i=!0),h()},[]),M=t.useCallback(()=>{const r=Object.fromEntries(new FormData(g.current));return f.current.forEach((w,T)=>{r[T]=c.current[T]}),i&&F.current.forEach(w=>r.hasOwnProperty(w)&&(r[w]=Number(r[w])||0)),{...c.current,...r}},[]),oe=t.useCallback(()=>!!Object.values($()).find(r=>r.isDirty),[]),q=t.useCallback(()=>!!Object.values(V()).find(r=>!!r),[]),ee=t.useCallback(r=>he(r.target),[]),re=t.useCallback(()=>d.current,[]),te=t.useCallback(()=>F.current,[]),J=t.useCallback(()=>f.current,[]),P=t.useCallback((r,n)=>n?Array.isArray(n)?n.reduce((w,T)=>({...w,[T]:ae(r,T)}),{}):ae(r,n):{...r},[]),z=t.useCallback(r=>P(c.current,r),[P]),V=t.useCallback(r=>P(m.current,r),[P]),$=t.useCallback(r=>P(a.current,r),[P]),W=t.useCallback(r=>P({isDirty:k.current,isError:v.current,errorFields:Object.keys(m.current).filter(n=>!!m.current[n]),dirtyFields:Object.keys(a.current).filter(n=>a.current[n].isDirty),touchedFields:Object.keys(a.current).filter(n=>a.current[n].isTouched)},r),[P]),{watch:D,registerHookWatcher:G,getWatchValue:H,subscribe:X}=Pe({channels:b,getValues:z,getErrors:V,getFieldStates:$,getFormState:W}),S=t.useCallback((r,n,w)=>{const T=a.current[r]||{...ce};ae(T,n)!==w&&(we(a.current,`${r}.${n}`,w),b.publish(`fieldStates.${r}.${n}`,w),n==="error"&&b.publish("formState.errorFields",W("errorFields")),n==="isDirty"&&b.publish("formState.dirtyFields",W("dirtyFields")),n==="isTouched"&&b.publish("formState.touchedFields",W("touchedFields")))},[]),Z=t.useCallback(r=>{S(r,"isDirty",!1),S(r,"isTouched",!1),S(r,"error",null)},[S]),e=t.useCallback((r,n)=>{if(m.current[r]===n)return;m.current[r]=n,S(r,"error",n),b.publish(`errors.${r}`,n);const T=q();v.current!==T&&(v.current=T,b.publish("formState.isError",T))},[S]),o=t.useCallback(r=>{if(!m.current[r])return;m.current[r]=null,S(r,"error",null),b.publish(`errors.${r}`,null);const n=q();v.current!==n&&(v.current=n,b.publish("formState.isError",n))},[S]),R=t.useCallback(()=>{if(Object.keys(m.current)===0)return;Object.keys(m.current).forEach(n=>o(n)),m.current={};const r=q();v.current!==r&&(v.current=r,b.publish("formState.isError",r))},[]),p=t.useCallback(r=>{const n=he(r.target);n?e(r.target.name,n):o(r.target.name)},[e,o]),O=t.useCallback((r,n,{shouldDirty:w=!0,shouldOnChange:T=!0}={})=>{if(n===c.current[r])return;i&&F.current.includes(r)&&(n=Number(n)||void 0),S(r,"isTouched",!0);const ne=n!==d.current[r];w&&a.current[r].isDirty!==ne&&S(r,"isDirty",ne);const Y=oe();k.current!==Y&&(k.current=Y,b.publish("formState.isDirty",Y)),c.current[r]=n;const L=f.current.get(r);L&&L(n),b.publish(`values.${r}`,n,{shouldDirty:w,shouldOnChange:T}),T&&b.publish("onChange",r,n,c.current)},[S]),_=t.useCallback((r,n)=>(f.current.set(r,n),a.current[r]={...ce},()=>{l&&f.current.delete(r)}),[]),B=t.useCallback((r,{keepError:n,keepDirty:w,keepTouched:T,keepCustomState:ne,defaultValue:Y})=>{const L=f.current.get(r);if(!L)throw new Error(`Cannot reset "${r}" because it's uncontrolled field`);d.current[r]=Y,c.current[r]=Y,L&&L(Y),n||o(r),w||S(r,"isDirty",!1),T||S(r,"isTouched",!1)},[o,S]),I=t.useCallback((r,n=j.getValues(r))=>{b.publish("onBlur",r,n,j.getValues())},[]),y=t.useCallback(r=>b.subscribe("onChange",r),[]),N=t.useCallback(r=>b.subscribe("onBlur",r),[]),j=t.useMemo(()=>({subscribe:X,reset:x,resetField:B,setValue:O,getValues:z,getErrors:V,getFieldStates:$,getFormState:W,setError:e,clearError:o,clearErrors:R,checkValidity:p,getNumberFields:te,getFieldValidity:ee,getDefaultValues:re,setFieldState:S,triggerFieldBlur:I,resetFieldState:Z,getControlledFields:J,subscribeChange:y,subscribeBlur:N,getEvents:b.getEvents,getWatchEvents:b.getWatchEvents}),[X,x,B,O,z,V,$,W,e,o,R,p,te,ee,re,S,Z,I,J,y,N]),se=t.useMemo(()=>({ref:g,watch:D,actions:j,registerController:_,registerHookWatcher:G,lastReloadedAt:E,loadFormValues:M,getWatchValue:H,channels:b}),[g,D,j,_,G,E,M,H,b]),Re=t.useMemo(()=>({control:se,actions:j,watch:D}),[E,se,j,D]);return t.useLayoutEffect(()=>{if([...g.current.querySelectorAll("[name]")].forEach(n=>{!n.defaultValue&&!f.current.has(n.name)&&d.current[n.name]&&(n.defaultValue=d.current[n.name]),n.type==="number"&&!F.current.includes(n.name)&&F.current.push(n.name)}),g.current){const n=M();c.current={...n},d.current={...n}}},[E]),t.useLayoutEffect(()=>{A()},[]),Re};exports.Controller=pe;exports.Form=Se;exports.useController=me;exports.useForm=Ne;exports.useFormContext=le;exports.useWatch=ge;
@@ -14,19 +14,19 @@ function Te() {
14
14
  if (he) return K;
15
15
  he = 1;
16
16
  var t = Symbol.for("react.transitional.element"), s = Symbol.for("react.fragment");
17
- function a(l, h, E) {
18
- var g = null;
19
- if (E !== void 0 && (g = "" + E), h.key !== void 0 && (g = "" + h.key), "key" in h) {
20
- E = {};
21
- for (var R in h)
22
- R !== "key" && (E[R] = h[R]);
23
- } else E = h;
24
- return h = E.ref, {
17
+ function a(i, g, h) {
18
+ var E = null;
19
+ if (h !== void 0 && (E = "" + h), g.key !== void 0 && (E = "" + g.key), "key" in g) {
20
+ h = {};
21
+ for (var R in g)
22
+ R !== "key" && (h[R] = g[R]);
23
+ } else h = g;
24
+ return g = h.ref, {
25
25
  $$typeof: t,
26
- type: l,
27
- key: g,
28
- ref: h !== void 0 ? h : null,
29
- props: E
26
+ type: i,
27
+ key: E,
28
+ ref: g !== void 0 ? g : null,
29
+ props: h
30
30
  };
31
31
  }
32
32
  return K.Fragment = s, K.jsx = a, K.jsxs = a, K;
@@ -41,9 +41,9 @@ var ee = {};
41
41
  * This source code is licensed under the MIT license found in the
42
42
  * LICENSE file in the root directory of this source tree.
43
43
  */
44
- var Ee;
44
+ var ge;
45
45
  function _e() {
46
- return Ee || (Ee = 1, process.env.NODE_ENV !== "production" && function() {
46
+ return ge || (ge = 1, process.env.NODE_ENV !== "production" && function() {
47
47
  function t(e) {
48
48
  if (e == null) return null;
49
49
  if (typeof e == "function")
@@ -107,7 +107,7 @@ function _e() {
107
107
  ), s(e);
108
108
  }
109
109
  }
110
- function l(e) {
110
+ function i(e) {
111
111
  if (e === f) return "<>";
112
112
  if (typeof e == "object" && e !== null && e.$$typeof === z)
113
113
  return "<...>";
@@ -118,14 +118,14 @@ function _e() {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
- function h() {
121
+ function g() {
122
122
  var e = W.A;
123
123
  return e === null ? null : e.getOwner();
124
124
  }
125
- function E() {
125
+ function h() {
126
126
  return Error("react-stack-top-frame");
127
127
  }
128
- function g(e) {
128
+ function E(e) {
129
129
  if (Y.call(e, "key")) {
130
130
  var u = Object.getOwnPropertyDescriptor(e, "key").get;
131
131
  if (u && u.isReactWarning) return !1;
@@ -182,7 +182,7 @@ function _e() {
182
182
  value: L
183
183
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
184
184
  }
185
- function i(e, u, v, w, C, A, I, L) {
185
+ function l(e, u, v, w, C, A, I, L) {
186
186
  var F = u.children;
187
187
  if (F !== void 0)
188
188
  if (w)
@@ -213,7 +213,7 @@ React keys must be passed directly to JSX without using spread:
213
213
  F
214
214
  ), Q[F + w] = !0);
215
215
  }
216
- if (F = null, v !== void 0 && (a(v), F = "" + v), g(u) && (a(u.key), F = "" + u.key), "key" in u) {
216
+ if (F = null, v !== void 0 && (a(v), F = "" + v), E(u) && (a(u.key), F = "" + u.key), "key" in u) {
217
217
  v = {};
218
218
  for (var x in u)
219
219
  x !== "key" && (v[x] = u[x]);
@@ -226,7 +226,7 @@ React keys must be passed directly to JSX without using spread:
226
226
  F,
227
227
  A,
228
228
  C,
229
- h(),
229
+ g(),
230
230
  v,
231
231
  I,
232
232
  L
@@ -245,11 +245,11 @@ React keys must be passed directly to JSX without using spread:
245
245
  };
246
246
  var H, X = {}, Z = o["react-stack-bottom-frame"].bind(
247
247
  o,
248
- E
249
- )(), y = $(l(E)), Q = {};
248
+ h
249
+ )(), y = $(i(h)), Q = {};
250
250
  ee.Fragment = f, ee.jsx = function(e, u, v, w, C) {
251
251
  var A = 1e4 > W.recentlyCreatedOwnerStacks++;
252
- return i(
252
+ return l(
253
253
  e,
254
254
  u,
255
255
  v,
@@ -257,11 +257,11 @@ React keys must be passed directly to JSX without using spread:
257
257
  w,
258
258
  C,
259
259
  A ? Error("react-stack-top-frame") : Z,
260
- A ? $(l(e)) : y
260
+ A ? $(i(e)) : y
261
261
  );
262
262
  }, ee.jsxs = function(e, u, v, w, C) {
263
263
  var A = 1e4 > W.recentlyCreatedOwnerStacks++;
264
- return i(
264
+ return l(
265
265
  e,
266
266
  u,
267
267
  v,
@@ -269,14 +269,14 @@ React keys must be passed directly to JSX without using spread:
269
269
  w,
270
270
  C,
271
271
  A ? Error("react-stack-top-frame") : Z,
272
- A ? $(l(e)) : y
272
+ A ? $(i(e)) : y
273
273
  );
274
274
  };
275
275
  }()), ee;
276
276
  }
277
- var ge;
277
+ var Ee;
278
278
  function ke() {
279
- return ge || (ge = 1, process.env.NODE_ENV === "production" ? ue.exports = Te() : ue.exports = _e()), ue.exports;
279
+ return Ee || (Ee = 1, process.env.NODE_ENV === "production" ? ue.exports = Te() : ue.exports = _e()), ue.exports;
280
280
  }
281
281
  var me = ke();
282
282
  const S = () => {
@@ -312,11 +312,11 @@ const S = () => {
312
312
  id: t,
313
313
  control: s,
314
314
  method: a,
315
- action: l,
316
- children: h,
317
- onSubmit: E = () => {
315
+ action: i,
316
+ children: g,
317
+ onSubmit: h = () => {
318
318
  },
319
- onInput: g = () => {
319
+ onInput: E = () => {
320
320
  },
321
321
  onChange: R = () => {
322
322
  },
@@ -324,7 +324,7 @@ const S = () => {
324
324
  },
325
325
  onReset: _ = () => {
326
326
  },
327
- numberFields: i = [],
327
+ numberFields: l = [],
328
328
  className: m,
329
329
  ...o
330
330
  }) => (de(() => {
@@ -332,19 +332,19 @@ const S = () => {
332
332
  return () => {
333
333
  c(), b();
334
334
  };
335
- }, []), /* @__PURE__ */ me.jsx(Re.Provider, { value: s, children: /* @__PURE__ */ me.jsx(
335
+ }, [s.lastReloadedAt]), /* @__PURE__ */ me.jsx(Re.Provider, { value: s, children: /* @__PURE__ */ me.jsx(
336
336
  "form",
337
337
  {
338
338
  id: t,
339
339
  ref: s.ref,
340
- action: l,
340
+ action: i,
341
341
  method: a,
342
342
  className: m,
343
- onInput: g,
343
+ onInput: E,
344
344
  onSubmit: (c) => {
345
345
  a || c.preventDefault();
346
346
  const b = s.loadFormValues();
347
- E(b);
347
+ h(b);
348
348
  },
349
349
  onChange: (c) => {
350
350
  const b = c.target.name;
@@ -360,17 +360,17 @@ const S = () => {
360
360
  s.actions.reset(), _(c);
361
361
  },
362
362
  ...o,
363
- children: h
363
+ children: g
364
364
  },
365
365
  s.lastReloadedAt
366
366
  ) })), Ae = ({ control: t, name: s, compute: a }) => {
367
- const { getWatchValue: l, registerHookWatcher: h } = t || pe(), E = l({ name: s, compute: a }), [g, R] = ae(E);
367
+ const { getWatchValue: i, registerHookWatcher: g } = t || pe(), h = i({ name: s, compute: a }), [E, R] = ae(h);
368
368
  return de(() => {
369
- const p = h({ name: s, compute: a, value: g, setValue: R });
369
+ const p = g({ name: s, compute: a, value: E, setValue: R });
370
370
  return () => p.forEach((_) => _());
371
- }, []), g;
371
+ }, []), E;
372
372
  }, Oe = ({ name: t, defaultValue: s }) => {
373
- const { actions: a, registerController: l, channels: h } = pe(), E = P(), g = a.getDefaultValues()[t] || s || "", [R, p] = ae(g), _ = Ae({ name: `fieldStates.${t}` }), i = d(
373
+ const { actions: a, registerController: i, channels: g } = pe(), h = P(), E = a.getDefaultValues()[t] || s || "", [R, p] = ae(E), _ = Ae({ name: `fieldStates.${t}` }), l = d(
374
374
  (o, { shouldDirty: c = !0, shouldOnChange: b = !0 } = {}) => {
375
375
  var O, N;
376
376
  let f = o;
@@ -379,25 +379,21 @@ const S = () => {
379
379
  [a.setValue]
380
380
  ), m = d((o) => {
381
381
  const c = a.getValues(), b = o ?? c[t];
382
- h.publish("onBlur", t, b, c);
382
+ g.publish("onBlur", t, b, c);
383
383
  }, []);
384
- return de(() => l(t, p), []), { ref: E, name: t, defaultValue: g, value: R, onChange: i, onBlur: m, fieldState: _ };
384
+ return de(() => i(t, p), []), { ref: h, name: t, defaultValue: E, value: R, onChange: l, onBlur: m, fieldState: _ };
385
385
  }, Le = ({
386
386
  name: t,
387
387
  defaultValue: s,
388
- render: a = ({ ref: l, name: h, defaultValue: E, value: g, onChange: R, onBlur: p, customState: _, setCustomState: i }) => null
388
+ render: a = ({ ref: i, name: g, defaultValue: h, value: E, onChange: R, onBlur: p, fieldState: _ }) => null
389
389
  }) => {
390
- const l = Oe({ name: t, defaultValue: s });
391
- return a(l);
392
- }, Ce = ["errors", "fieldStates", "formState"], ce = (t = {}, s = "") => s.split(".").reduce((a, l) => a && a[l] !== void 0 ? a[l] : void 0, t), Pe = (t = {}, s = "", a) => {
393
- let l = t;
394
- const h = s.split(".");
395
- return h.forEach((E, g) => {
396
- if (g < h.length - 1) {
397
- l[E] || (l[E] = {}), l = l[E];
398
- return;
399
- }
400
- l[E] = a;
390
+ const i = Oe({ name: t, defaultValue: s });
391
+ return a(i);
392
+ }, Ce = ["errors", "fieldStates", "formState"], ce = (t = {}, s = "") => s.split(".").reduce((a, i) => a && a[i] !== void 0 ? a[i] : void 0, t), Pe = (t = {}, s = "", a) => {
393
+ let i = t;
394
+ const g = s.split(".");
395
+ return g.forEach((h, E) => {
396
+ E < g.length - 1 && (i[h] || (i[h] = {}), E === g.length - 2 && (i[h] = { ...i[h] }), i = i[h]), i[h] = a;
401
397
  }), t;
402
398
  }, q = (t) => Ce.some((s) => t.startsWith(s)) ? t : "values." + t, je = [
403
399
  "badInput",
@@ -412,7 +408,7 @@ const S = () => {
412
408
  "valueMissing"
413
409
  ], ve = (t) => {
414
410
  typeof t.setCustomValidity == "function" && t.setCustomValidity("");
415
- let s = t.validity, a = je.find((l) => s[l]);
411
+ let s = t.validity, a = je.find((i) => s[i]);
416
412
  if (a) return { type: a, message: t.validationMessage };
417
413
  };
418
414
  class xe {
@@ -427,18 +423,18 @@ class xe {
427
423
  }
428
424
  subscribe(s, a) {
429
425
  return this.events.has(s) || this.events.set(s, /* @__PURE__ */ new Set()), this.events.get(s).add(a), () => {
430
- var l;
431
- return (l = this.events.get(s)) == null ? void 0 : l.delete(a);
426
+ var i;
427
+ return (i = this.events.get(s)) == null ? void 0 : i.delete(a);
432
428
  };
433
429
  }
434
430
  subscribeWatch(s, a) {
435
431
  this.watchEvents.has(s) || (this.watchEvents.set(s, /* @__PURE__ */ new Set()), this.watchEvents.get(s).add(a));
436
432
  }
437
433
  publish(s, ...a) {
438
- this.events.forEach((l, h) => {
439
- s.includes(h) && l.forEach((E) => E(...a));
440
- }), this.watchEvents.forEach((l, h) => {
441
- s.includes(h) && l.forEach((E) => E(...a));
434
+ this.events.forEach((i, g) => {
435
+ s.includes(g) && i.forEach((h) => h(...a));
436
+ }), this.watchEvents.forEach((i, g) => {
437
+ s.includes(g) && i.forEach((h) => h(...a));
442
438
  });
443
439
  }
444
440
  reset() {
@@ -448,73 +444,73 @@ class xe {
448
444
  const Ne = () => {
449
445
  const t = P(new xe()), s = d((R, ...p) => {
450
446
  t.current.publish(R, ...p);
451
- }, []), a = d((R, p) => t.current.subscribe(R, p), []), l = d((R, p) => {
447
+ }, []), a = d((R, p) => t.current.subscribe(R, p), []), i = d((R, p) => {
452
448
  t.current.subscribeWatch(R, p);
453
- }, []), h = d(() => t.current.getEvents(), []), E = d(() => t.current.getWatchEvents(), []), g = d(() => {
449
+ }, []), g = d(() => t.current.getEvents(), []), h = d(() => t.current.getWatchEvents(), []), E = d(() => {
454
450
  t.current.reset();
455
451
  }, []);
456
- return { publish: s, subscribe: a, reset: g, getEvents: h, subscribeWatch: l, getWatchEvents: E };
452
+ return { publish: s, subscribe: a, reset: E, getEvents: g, subscribeWatch: i, getWatchEvents: h };
457
453
  }, Ve = () => {
458
454
  const [t, s] = ae(), a = d(() => s((/* @__PURE__ */ new Date()).toString()), []);
459
455
  return [t, a];
460
456
  }, We = () => {
461
457
  const [, t] = ae({});
462
458
  return d(() => t({}), []);
463
- }, De = ({ channels: t, getValues: s, getErrors: a, getFieldStates: l, getFormState: h }) => {
464
- const E = We(), g = d(({ name: i, compute: m }) => {
459
+ }, De = ({ channels: t, getValues: s, getErrors: a, getFieldStates: i, getFormState: g }) => {
460
+ const h = We(), E = d(({ name: l, compute: m }) => {
465
461
  if (typeof m == "function") return m(s());
466
- if (Array.isArray(i)) {
462
+ if (Array.isArray(l)) {
467
463
  const o = {};
468
- return i.forEach((c) => {
469
- o[c] = g({ name: c });
464
+ return l.forEach((c) => {
465
+ o[c] = E({ name: c });
470
466
  }), o;
471
467
  }
472
468
  return ce(
473
469
  {
474
470
  ...s(),
475
471
  errors: { ...a() },
476
- formState: { ...h() },
477
- fieldStates: { ...l() }
472
+ formState: { ...g() },
473
+ fieldStates: { ...i() }
478
474
  },
479
- i
475
+ l
480
476
  );
481
- }, []), R = d((i) => {
482
- if (!i)
483
- return t.subscribeWatch("values", () => E()), s();
484
- if (typeof i == "string") {
485
- const m = q(i);
486
- return t.subscribeWatch(m, () => E()), g({ name: i });
477
+ }, []), R = d((l) => {
478
+ if (!l)
479
+ return t.subscribeWatch("values", () => h()), s();
480
+ if (typeof l == "string") {
481
+ const m = q(l);
482
+ return t.subscribeWatch(m, () => h()), E({ name: l });
487
483
  }
488
- if (Array.isArray(i)) {
484
+ if (Array.isArray(l)) {
489
485
  const m = {};
490
- return i.forEach((o) => {
486
+ return l.forEach((o) => {
491
487
  const c = q(o);
492
- t.subscribeWatch(c, () => E()), m[o] = g({ name: o });
488
+ t.subscribeWatch(c, () => h()), m[o] = E({ name: o });
493
489
  }), { ...m };
494
490
  }
495
491
  throw new Error("Parameters of watch must be string or array of string");
496
- }, []), p = d(({ name: i, compute: m, setValue: o }) => {
492
+ }, []), p = d(({ name: l, compute: m, setValue: o }) => {
497
493
  if (typeof m == "function")
498
494
  return [t.subscribe("values", () => {
499
- const b = g({ compute: m });
495
+ const b = E({ compute: m });
500
496
  o(b);
501
497
  })];
502
- if (!i)
498
+ if (!l)
503
499
  return [t.subscribe("values", () => {
504
500
  o(s());
505
501
  })];
506
- if (typeof i == "string") {
507
- const c = q(i);
502
+ if (typeof l == "string") {
503
+ const c = q(l);
508
504
  return [t.subscribe(c, () => {
509
- const f = g({ name: i });
505
+ const f = E({ name: l });
510
506
  o(f);
511
507
  })];
512
508
  }
513
- if (Array.isArray(i)) {
514
- const c = g({ name: i }), b = [];
515
- return i.forEach((f) => {
509
+ if (Array.isArray(l)) {
510
+ const c = E({ name: l }), b = [];
511
+ return l.forEach((f) => {
516
512
  const O = q(f), N = t.subscribe(O, () => {
517
- const M = g({ name: f });
513
+ const M = E({ name: f });
518
514
  c[f] = M, o({ ...c });
519
515
  });
520
516
  b.push(N);
@@ -522,18 +518,18 @@ const Ne = () => {
522
518
  }
523
519
  throw new Error("Parameters of name must be string or array of string or compute must be a function");
524
520
  }, []), _ = d(
525
- (i, m) => {
526
- if (!i)
521
+ (l, m) => {
522
+ if (!l)
527
523
  return t.subscribe("values", m);
528
- if (typeof i == "string") {
529
- const o = q(i);
524
+ if (typeof l == "string") {
525
+ const o = q(l);
530
526
  return t.subscribe(o, m);
531
527
  }
532
- if (Array.isArray(i)) {
528
+ if (Array.isArray(l)) {
533
529
  const o = {}, c = [];
534
- return i.forEach((b) => {
530
+ return l.forEach((b) => {
535
531
  const f = q(b), O = t.subscribe(f, () => {
536
- o[b] = g({ name: b }), m({ ...o });
532
+ o[b] = E({ name: b }), m({ ...o });
537
533
  });
538
534
  c.push(O);
539
535
  }), c;
@@ -542,27 +538,27 @@ const Ne = () => {
542
538
  },
543
539
  [t]
544
540
  );
545
- return { watch: R, registerHookWatcher: p, getWatchValue: g, subscribe: _ };
541
+ return { watch: R, registerHookWatcher: p, getWatchValue: E, subscribe: _ };
546
542
  }, fe = { isDirty: !1, isTouched: !1, error: null }, $e = [], Me = {}, Ue = ({
547
543
  numberFields: t = $e,
548
544
  defaultValues: s = Me,
549
545
  shouldUnRegister: a = !1,
550
- shouldConvertNumber: l = !1
546
+ shouldConvertNumber: i = !1
551
547
  } = {}) => {
552
- const [h, E] = Ve(), g = P(), R = P(!1), p = P(!1), _ = P(t), i = P(/* @__PURE__ */ new Map()), m = P({}), o = P({}), c = P({ ...s }), b = P({ ...s }), f = Ne(), O = d(() => {
548
+ const [g, h] = Ve(), E = P(), R = P(!1), p = P(!1), _ = P(t), l = P(/* @__PURE__ */ new Map()), m = P({}), o = P({}), c = P({ ...s }), b = P({ ...s }), f = Ne(), O = d(() => {
553
549
  o.current = Object.keys(b.current).reduce((r, n) => ({ ...r, [n]: { ...fe } }), {});
554
550
  }, []), N = d((r = {}) => {
555
- b.current = { ...b.current, ...r }, c.current = { ...b.current }, i.current.forEach((n, T) => {
551
+ b.current = { ...b.current, ...r }, c.current = { ...b.current }, l.current.forEach((n, T) => {
556
552
  n(b.current[T]);
557
- }), R.current = !1, m.current = {}, _.current = t, i.current = /* @__PURE__ */ new Map(), f.reset(), O(), t.length > 0 && (l = !0), E();
553
+ }), R.current = !1, m.current = {}, _.current = t, l.current = /* @__PURE__ */ new Map(), f.reset(), O(), t.length > 0 && (i = !0), h();
558
554
  }, []), M = d(() => {
559
- const r = Object.fromEntries(new FormData(g.current));
560
- return i.current.forEach((T, k) => {
555
+ const r = Object.fromEntries(new FormData(E.current));
556
+ return l.current.forEach((T, k) => {
561
557
  r[k] = c.current[k];
562
- }), l && _.current.forEach(
558
+ }), i && _.current.forEach(
563
559
  (T) => r.hasOwnProperty(T) && (r[T] = Number(r[T]) || 0)
564
560
  ), { ...c.current, ...r };
565
- }, []), ie = d(() => !!Object.values(Y()).find((r) => r.isDirty), []), J = d(() => !!Object.values(W()).find((r) => !!r), []), re = d((r) => ve(r.target), []), te = d(() => b.current, []), ne = d(() => _.current, []), z = d(() => i.current, []), j = d((r, n) => n ? Array.isArray(n) ? n.reduce((T, k) => ({ ...T, [k]: ce(r, k) }), {}) : ce(r, n) : { ...r }, []), G = d((r) => j(c.current, r), [j]), W = d((r) => j(m.current, r), [j]), Y = d((r) => j(o.current, r), [j]), D = d(
561
+ }, []), ie = d(() => !!Object.values(Y()).find((r) => r.isDirty), []), J = d(() => !!Object.values(W()).find((r) => !!r), []), re = d((r) => ve(r.target), []), te = d(() => b.current, []), ne = d(() => _.current, []), z = d(() => l.current, []), j = d((r, n) => n ? Array.isArray(n) ? n.reduce((T, k) => ({ ...T, [k]: ce(r, k) }), {}) : ce(r, n) : { ...r }, []), G = d((r) => j(c.current, r), [j]), W = d((r) => j(m.current, r), [j]), Y = d((r) => j(o.current, r), [j]), D = d(
566
562
  (r) => j(
567
563
  {
568
564
  isDirty: R.current,
@@ -618,20 +614,20 @@ const Ne = () => {
618
614
  ), C = d(
619
615
  (r, n, { shouldDirty: T = !0, shouldOnChange: k = !0 } = {}) => {
620
616
  if (n === c.current[r]) return;
621
- l && _.current.includes(r) && (n = Number(n) || void 0), y(r, "isTouched", !0);
617
+ i && _.current.includes(r) && (n = Number(n) || void 0), y(r, "isTouched", !0);
622
618
  const oe = n !== b.current[r];
623
619
  T && o.current[r].isDirty !== oe && y(r, "isDirty", oe);
624
620
  const B = ie();
625
621
  R.current !== B && (R.current = B, f.publish("formState.isDirty", B)), c.current[r] = n;
626
- const U = i.current.get(r);
622
+ const U = l.current.get(r);
627
623
  U && U(n), f.publish(`values.${r}`, n, { shouldDirty: T, shouldOnChange: k }), k && f.publish("onChange", r, n, c.current);
628
624
  },
629
625
  [y]
630
- ), A = d((r, n) => (i.current.set(r, n), o.current[r] = { ...fe }, () => {
631
- a && i.current.delete(r);
626
+ ), A = d((r, n) => (l.current.set(r, n), o.current[r] = { ...fe }, () => {
627
+ a && l.current.delete(r);
632
628
  }), []), I = d(
633
629
  (r, { keepError: n, keepDirty: T, keepTouched: k, keepCustomState: oe, defaultValue: B }) => {
634
- const U = i.current.get(r);
630
+ const U = l.current.get(r);
635
631
  if (!U)
636
632
  throw new Error(`Cannot reset "${r}" because it's uncontrolled field`);
637
633
  b.current[r] = B, c.current[r] = B, U && U(B), n || u(r), T || y(r, "isDirty", !1), k || y(r, "isTouched", !1);
@@ -690,36 +686,36 @@ const Ne = () => {
690
686
  ]
691
687
  ), se = le(
692
688
  () => ({
693
- ref: g,
689
+ ref: E,
694
690
  watch: $,
695
691
  actions: x,
696
692
  registerController: A,
697
693
  registerHookWatcher: H,
698
- lastReloadedAt: h,
694
+ lastReloadedAt: g,
699
695
  loadFormValues: M,
700
696
  getWatchValue: X,
701
697
  channels: f
702
698
  }),
703
699
  [
704
- g,
700
+ E,
705
701
  $,
706
702
  x,
707
703
  A,
708
704
  H,
709
- h,
705
+ g,
710
706
  M,
711
707
  X,
712
708
  f
713
709
  ]
714
- ), Se = le(() => ({ control: se, actions: x, watch: $ }), [h, se, x, $]);
710
+ ), Se = le(() => ({ control: se, actions: x, watch: $ }), [g, se, x, $]);
715
711
  return be(() => {
716
- if ([...g.current.querySelectorAll("[name]")].forEach((n) => {
717
- !n.defaultValue && !i.current.has(n.name) && b.current[n.name] && (n.defaultValue = b.current[n.name]), n.type === "number" && !_.current.includes(n.name) && _.current.push(n.name);
718
- }), g.current) {
712
+ if ([...E.current.querySelectorAll("[name]")].forEach((n) => {
713
+ !n.defaultValue && !l.current.has(n.name) && b.current[n.name] && (n.defaultValue = b.current[n.name]), n.type === "number" && !_.current.includes(n.name) && _.current.push(n.name);
714
+ }), E.current) {
719
715
  const n = M();
720
716
  c.current = { ...n }, b.current = { ...n };
721
717
  }
722
- }, [h]), be(() => {
718
+ }, [g]), be(() => {
723
719
  O();
724
720
  }, []), Se;
725
721
  };
@@ -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 fe;function Re(){if(fe)return G;fe=1;var s=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function l(f,h,E){var m=null;if(E!==void 0&&(m=""+E),h.key!==void 0&&(m=""+h.key),"key"in h){E={};for(var R in h)R!=="key"&&(E[R]=h[R])}else E=h;return h=E.ref,{$$typeof:s,type:f,key:m,ref:h!==void 0?h:null,props:E}}return G.Fragment=a,G.jsx=l,G.jsxs=l,G}var H={};/**
9
+ */var fe;function ke(){if(fe)return G;fe=1;var s=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function l(i,E,h){var g=null;if(h!==void 0&&(g=""+h),E.key!==void 0&&(g=""+E.key),"key"in E){h={};for(var k in E)k!=="key"&&(h[k]=E[k])}else h=E;return E=h.ref,{$$typeof:s,type:i,key:g,ref:E!==void 0?E:null,props:h}}return G.Fragment=a,G.jsx=l,G.jsxs=l,G}var H={};/**
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 de;function ve(){return de||(de=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case d:return"Fragment";case x:return"Profiler";case O:return"StrictMode";case se:return"Suspense";case ne:return"SuspenseList";case j:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case b:return"Portal";case ie:return(e.displayName||"Context")+".Provider";case Y:return(e._context.displayName||"Context")+".Consumer";case X:var c=e.render;return e=e.displayName,e||(e=c.displayName||c.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return c=e.displayName||null,c!==null?c:s(e.type)||"Memo";case Z:c=e._payload,e=e._init;try{return s(e(c))}catch{}}return null}function a(e){return""+e}function l(e){try{a(e);var c=!1}catch{c=!0}if(c){c=console;var k=c.error,y=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return k.call(c,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",y),a(e)}}function f(e){if(e===d)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===Z)return"<...>";try{var c=s(e);return c?"<"+c+">":"<...>"}catch{return"<...>"}}function h(){var e=W.A;return e===null?null:e.getOwner()}function E(){return Error("react-stack-top-frame")}function m(e){if(B.call(e,"key")){var c=Object.getOwnPropertyDescriptor(e,"key").get;if(c&&c.isReactWarning)return!1}return e.key!==void 0}function R(e,c){function k(){K||(K=!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)",c))}k.isReactWarning=!0,Object.defineProperty(e,"key",{get:k,configurable:!0})}function v(){var e=s(this.type);return q[e]||(q[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function F(e,c,k,y,P,_,U,J){return k=_.ref,e={$$typeof:u,type:e,key:c,props:_,_owner:P},(k!==void 0?k:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:v}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function i(e,c,k,y,P,_,U,J){var p=c.children;if(p!==void 0)if(y)if(D(p)){for(y=0;y<p.length;y++)g(p[y]);Object.freeze&&Object.freeze(p)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else g(p);if(B.call(c,"key")){p=s(e);var V=Object.keys(c).filter(function(oe){return oe!=="key"});y=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",ee[p+y]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var de;function ve(){return de||(de=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case d:return"Fragment";case V:return"Profiler";case O:return"StrictMode";case se:return"Suspense";case ne:return"SuspenseList";case j:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case b:return"Portal";case ie:return(e.displayName||"Context")+".Provider";case Y:return(e._context.displayName||"Context")+".Consumer";case X:var c=e.render;return e=e.displayName,e||(e=c.displayName||c.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return c=e.displayName||null,c!==null?c:s(e.type)||"Memo";case Z:c=e._payload,e=e._init;try{return s(e(c))}catch{}}return null}function a(e){return""+e}function l(e){try{a(e);var c=!1}catch{c=!0}if(c){c=console;var R=c.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return R.call(c,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),a(e)}}function i(e){if(e===d)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===Z)return"<...>";try{var c=s(e);return c?"<"+c+">":"<...>"}catch{return"<...>"}}function E(){var e=W.A;return e===null?null:e.getOwner()}function h(){return Error("react-stack-top-frame")}function g(e){if(B.call(e,"key")){var c=Object.getOwnPropertyDescriptor(e,"key").get;if(c&&c.isReactWarning)return!1}return e.key!==void 0}function k(e,c){function R(){K||(K=!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)",c))}R.isReactWarning=!0,Object.defineProperty(e,"key",{get:R,configurable:!0})}function v(){var e=s(this.type);return q[e]||(q[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function F(e,c,R,p,P,_,U,J){return R=_.ref,e={$$typeof:u,type:e,key:c,props:_,_owner:P},(R!==void 0?R:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:v}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,c,R,p,P,_,U,J){var y=c.children;if(y!==void 0)if(p)if(D(y)){for(p=0;p<y.length;p++)m(y[p]);Object.freeze&&Object.freeze(y)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(y);if(B.call(c,"key")){y=s(e);var x=Object.keys(c).filter(function(oe){return oe!=="key"});p=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",ee[y+p]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,y,p,V,p),ee[p+y]=!0)}if(p=null,k!==void 0&&(l(k),p=""+k),m(c)&&(l(c.key),p=""+c.key),"key"in c){k={};for(var N in c)N!=="key"&&(k[N]=c[N])}else k=c;return p&&R(k,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,p,_,P,h(),k,U,J)}function g(e){typeof e=="object"&&e!==null&&e.$$typeof===u&&e._store&&(e._store.validated=1)}var o=r,u=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),ie=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),W=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=Object.prototype.hasOwnProperty,D=Array.isArray,M=console.createTask?console.createTask:function(){return null};o={"react-stack-bottom-frame":function(e){return e()}};var K,q={},$=o["react-stack-bottom-frame"].bind(o,E)(),S=M(f(E)),ee={};H.Fragment=d,H.jsx=function(e,c,k,y,P){var _=1e4>W.recentlyCreatedOwnerStacks++;return i(e,c,k,!1,y,P,_?Error("react-stack-top-frame"):$,_?M(f(e)):S)},H.jsxs=function(e,c,k,y,P){var _=1e4>W.recentlyCreatedOwnerStacks++;return i(e,c,k,!0,y,P,_?Error("react-stack-top-frame"):$,_?M(f(e)):S)}}()),H}var be;function Ce(){return be||(be=1,process.env.NODE_ENV==="production"?te.exports=Re():te.exports=ve()),te.exports}var he=Ce();const C=()=>{},Ee=r.createContext({ref:null,watch:C,actions:{reset:C,resetField:C,setValue:C,getValues:C,getErrors:C,getFieldStates:C,getFormStates:C,setError:C,clearError:C,clearErrors:C,checkValidity:C,getNumberFields:C,getFieldValidity:C,getDefaultValues:C,setFieldState:C,resetFieldState:C,getControlledFields:C},registerController:C,registerHookWatcher:C,lastReloadedAt:C,loadFormValues:C,getWatchValue:C,channels:{}}),ue=()=>r.useContext(Ee),Se=({id:s,control:a,method:l,action:f,children:h,onSubmit:E=()=>{},onInput:m=()=>{},onChange:R=()=>{},onBlur:v=()=>{},onReset:F=()=>{},numberFields:i=[],className:g,...o})=>(r.useEffect(()=>{const u=a.channels.subscribe("onChange",R),b=a.channels.subscribe("onBlur",v);return()=>{u(),b()}},[]),he.jsx(Ee.Provider,{value:a,children:he.jsx("form",{id:s,ref:a.ref,action:f,method:l,className:g,onInput:m,onSubmit:u=>{l||u.preventDefault();const b=a.loadFormValues();E(b)},onChange:u=>{const b=u.target.name;!b||a.actions.getControlledFields().has(b)||a.actions.setValue(b,u.target.value)},onBlur:u=>{const b=u.target.name;if(!b||a.actions.getControlledFields().has(b))return;const d=u.target.value;a.channels.publish("onBlur",b,d,a.actions.getValues())},onReset:u=>{a.actions.reset(),F(u)},...o,children:h},a.lastReloadedAt)})),me=({control:s,name:a,compute:l})=>{const{getWatchValue:f,registerHookWatcher:h}=s||ue(),E=f({name:a,compute:l}),[m,R]=r.useState(E);return r.useEffect(()=>{const v=h({name:a,compute:l,value:m,setValue:R});return()=>v.forEach(F=>F())},[]),m},ge=({name:s,defaultValue:a})=>{const{actions:l,registerController:f,channels:h}=ue(),E=r.useRef(),m=l.getDefaultValues()[s]||a||"",[R,v]=r.useState(m),F=me({name:`fieldStates.${s}`}),i=r.useCallback((o,{shouldDirty:u=!0,shouldOnChange:b=!0}={})=>{var O,x;let d=o;(O=o==null?void 0:o.target)!=null&&O.value&&(d=o.target.value),(x=o==null?void 0:o.target)!=null&&x.checked&&(d=o.target.checked+""),v(d),l.setValue(s,d,{shouldDirty:u,shouldOnChange:b})},[l.setValue]),g=r.useCallback(o=>{const u=l.getValues(),b=o??u[s];h.publish("onBlur",s,b,u)},[]);return r.useEffect(()=>f(s,v),[]),{ref:E,name:s,defaultValue:m,value:R,onChange:i,onBlur:g,fieldState:F}},ye=({name:s,defaultValue:a,render:l=({ref:f,name:h,defaultValue:E,value:m,onChange:R,onBlur:v,customState:F,setCustomState:i})=>null})=>{const f=ge({name:s,defaultValue:a});return l(f)},pe=["errors","fieldStates","formState"],re=(s={},a="")=>a.split(".").reduce((l,f)=>l&&l[f]!==void 0?l[f]:void 0,s),we=(s={},a="",l)=>{let f=s;const h=a.split(".");return h.forEach((E,m)=>{if(m<h.length-1){f[E]||(f[E]={}),f=f[E];return}f[E]=l}),s},L=s=>pe.some(a=>s.startsWith(a))?s:"values."+s,Fe=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],ke=s=>{typeof s.setCustomValidity=="function"&&s.setCustomValidity("");let a=s.validity,l=Fe.find(f=>a[f]);if(l)return{type:l,message:s.validationMessage}};class Te{constructor(){this.events=new Map,this.watchEvents=new Map}getWatchEvents(){return this.watchEvents}getEvents(){return this.events}subscribe(a,l){return this.events.has(a)||this.events.set(a,new Set),this.events.get(a).add(l),()=>{var f;return(f=this.events.get(a))==null?void 0:f.delete(l)}}subscribeWatch(a,l){this.watchEvents.has(a)||(this.watchEvents.set(a,new Set),this.watchEvents.get(a).add(l))}publish(a,...l){this.events.forEach((f,h)=>{a.includes(h)&&f.forEach(E=>E(...l))}),this.watchEvents.forEach((f,h)=>{a.includes(h)&&f.forEach(E=>E(...l))})}reset(){this.events.clear(),this.watchEvents.clear()}}const _e=()=>{const s=r.useRef(new Te),a=r.useCallback((R,...v)=>{s.current.publish(R,...v)},[]),l=r.useCallback((R,v)=>s.current.subscribe(R,v),[]),f=r.useCallback((R,v)=>{s.current.subscribeWatch(R,v)},[]),h=r.useCallback(()=>s.current.getEvents(),[]),E=r.useCallback(()=>s.current.getWatchEvents(),[]),m=r.useCallback(()=>{s.current.reset()},[]);return{publish:a,subscribe:l,reset:m,getEvents:h,subscribeWatch:f,getWatchEvents:E}},Ae=()=>{const[s,a]=r.useState(),l=r.useCallback(()=>a(new Date().toString()),[]);return[s,l]},Oe=()=>{const[,s]=r.useState({});return r.useCallback(()=>s({}),[])},Pe=({channels:s,getValues:a,getErrors:l,getFieldStates:f,getFormState:h})=>{const E=Oe(),m=r.useCallback(({name:i,compute:g})=>{if(typeof g=="function")return g(a());if(Array.isArray(i)){const o={};return i.forEach(u=>{o[u]=m({name:u})}),o}return re({...a(),errors:{...l()},formState:{...h()},fieldStates:{...f()}},i)},[]),R=r.useCallback(i=>{if(!i)return s.subscribeWatch("values",()=>E()),a();if(typeof i=="string"){const g=L(i);return s.subscribeWatch(g,()=>E()),m({name:i})}if(Array.isArray(i)){const g={};return i.forEach(o=>{const u=L(o);s.subscribeWatch(u,()=>E()),g[o]=m({name:o})}),{...g}}throw new Error("Parameters of watch must be string or array of string")},[]),v=r.useCallback(({name:i,compute:g,setValue:o})=>{if(typeof g=="function")return[s.subscribe("values",()=>{const b=m({compute:g});o(b)})];if(!i)return[s.subscribe("values",()=>{o(a())})];if(typeof i=="string"){const u=L(i);return[s.subscribe(u,()=>{const d=m({name:i});o(d)})]}if(Array.isArray(i)){const u=m({name:i}),b=[];return i.forEach(d=>{const O=L(d),x=s.subscribe(O,()=>{const Y=m({name:d});u[d]=Y,o({...u})});b.push(x)}),b}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),F=r.useCallback((i,g)=>{if(!i)return s.subscribe("values",g);if(typeof i=="string"){const o=L(i);return s.subscribe(o,g)}if(Array.isArray(i)){const o={},u=[];return i.forEach(b=>{const d=L(b),O=s.subscribe(d,()=>{o[b]=m({name:b}),g({...o})});u.push(O)}),u}throw new Error("Parameters of name must be string or array of string")},[s]);return{watch:R,registerHookWatcher:v,getWatchValue:m,subscribe:F}},le={isDirty:!1,isTouched:!1,error:null},je=[],Ne={},xe=({numberFields:s=je,defaultValues:a=Ne,shouldUnRegister:l=!1,shouldConvertNumber:f=!1}={})=>{const[h,E]=Ae(),m=r.useRef(),R=r.useRef(!1),v=r.useRef(!1),F=r.useRef(s),i=r.useRef(new Map),g=r.useRef({}),o=r.useRef({}),u=r.useRef({...a}),b=r.useRef({...a}),d=_e(),O=r.useCallback(()=>{o.current=Object.keys(b.current).reduce((t,n)=>({...t,[n]:{...le}}),{})},[]),x=r.useCallback((t={})=>{b.current={...b.current,...t},u.current={...b.current},i.current.forEach((n,w)=>{n(b.current[w])}),R.current=!1,g.current={},F.current=s,i.current=new Map,d.reset(),O(),s.length>0&&(f=!0),E()},[]),Y=r.useCallback(()=>{const t=Object.fromEntries(new FormData(m.current));return i.current.forEach((w,T)=>{t[T]=u.current[T]}),f&&F.current.forEach(w=>t.hasOwnProperty(w)&&(t[w]=Number(t[w])||0)),{...u.current,...t}},[]),ie=r.useCallback(()=>!!Object.values(B()).find(t=>t.isDirty),[]),X=r.useCallback(()=>!!Object.values(W()).find(t=>!!t),[]),se=r.useCallback(t=>ke(t.target),[]),ne=r.useCallback(()=>b.current,[]),ae=r.useCallback(()=>F.current,[]),Z=r.useCallback(()=>i.current,[]),j=r.useCallback((t,n)=>n?Array.isArray(n)?n.reduce((w,T)=>({...w,[T]:re(t,T)}),{}):re(t,n):{...t},[]),Q=r.useCallback(t=>j(u.current,t),[j]),W=r.useCallback(t=>j(g.current,t),[j]),B=r.useCallback(t=>j(o.current,t),[j]),D=r.useCallback(t=>j({isDirty:R.current,isError:v.current,errorFields:Object.keys(g.current).filter(n=>!!g.current[n]),dirtyFields:Object.keys(o.current).filter(n=>o.current[n].isDirty),touchedFields:Object.keys(o.current).filter(n=>o.current[n].isTouched)},t),[j]),{watch:M,registerHookWatcher:K,getWatchValue:q,subscribe:$}=Pe({channels:d,getValues:Q,getErrors:W,getFieldStates:B,getFormState:D}),S=r.useCallback((t,n,w)=>{const T=o.current[t]||{...le};re(T,n)!==w&&(we(o.current,`${t}.${n}`,w),d.publish(`fieldStates.${t}.${n}`,w),n==="error"&&d.publish("formState.errorFields",D("errorFields")),n==="isDirty"&&d.publish("formState.dirtyFields",D("dirtyFields")),n==="isTouched"&&d.publish("formState.touchedFields",D("touchedFields")))},[]),ee=r.useCallback(t=>{S(t,"isDirty",!1),S(t,"isTouched",!1),S(t,"error",null)},[S]),e=r.useCallback((t,n)=>{if(g.current[t]===n)return;g.current[t]=n,S(t,"error",n),d.publish(`errors.${t}`,n);const T=X();v.current!==T&&(v.current=T,d.publish("formState.isError",T))},[S]),c=r.useCallback(t=>{if(!g.current[t])return;g.current[t]=null,S(t,"error",null),d.publish(`errors.${t}`,null);const n=X();v.current!==n&&(v.current=n,d.publish("formState.isError",n))},[S]),k=r.useCallback(()=>{if(Object.keys(g.current)===0)return;Object.keys(g.current).forEach(n=>c(n)),g.current={};const t=X();v.current!==t&&(v.current=t,d.publish("formState.isError",t))},[]),y=r.useCallback(t=>{const n=ke(t.target);n?e(t.target.name,n):c(t.target.name)},[e,c]),P=r.useCallback((t,n,{shouldDirty:w=!0,shouldOnChange:T=!0}={})=>{if(n===u.current[t])return;f&&F.current.includes(t)&&(n=Number(n)||void 0),S(t,"isTouched",!0);const ce=n!==b.current[t];w&&o.current[t].isDirty!==ce&&S(t,"isDirty",ce);const I=ie();R.current!==I&&(R.current=I,d.publish("formState.isDirty",I)),u.current[t]=n;const z=i.current.get(t);z&&z(n),d.publish(`values.${t}`,n,{shouldDirty:w,shouldOnChange:T}),T&&d.publish("onChange",t,n,u.current)},[S]),_=r.useCallback((t,n)=>(i.current.set(t,n),o.current[t]={...le},()=>{l&&i.current.delete(t)}),[]),U=r.useCallback((t,{keepError:n,keepDirty:w,keepTouched:T,keepCustomState:ce,defaultValue:I})=>{const z=i.current.get(t);if(!z)throw new Error(`Cannot reset "${t}" because it's uncontrolled field`);b.current[t]=I,u.current[t]=I,z&&z(I),n||c(t),w||S(t,"isDirty",!1),T||S(t,"isTouched",!1)},[c,S]),J=r.useCallback((t,n=N.getValues(t))=>{d.publish("onBlur",t,n,N.getValues())},[]),p=r.useCallback(t=>d.subscribe("onChange",t),[]),V=r.useCallback(t=>d.subscribe("onBlur",t),[]),N=r.useMemo(()=>({subscribe:$,reset:x,resetField:U,setValue:P,getValues:Q,getErrors:W,getFieldStates:B,getFormState:D,setError:e,clearError:c,clearErrors:k,checkValidity:y,getNumberFields:ae,getFieldValidity:se,getDefaultValues:ne,setFieldState:S,triggerFieldBlur:J,resetFieldState:ee,getControlledFields:Z,subscribeChange:p,subscribeBlur:V,getEvents:d.getEvents,getWatchEvents:d.getWatchEvents}),[$,x,U,P,Q,W,B,D,e,c,k,y,ae,se,ne,S,ee,J,Z,p,V]),oe=r.useMemo(()=>({ref:m,watch:M,actions:N,registerController:_,registerHookWatcher:K,lastReloadedAt:h,loadFormValues:Y,getWatchValue:q,channels:d}),[m,M,N,_,K,h,Y,q,d]),Ve=r.useMemo(()=>({control:oe,actions:N,watch:M}),[h,oe,N,M]);return r.useLayoutEffect(()=>{if([...m.current.querySelectorAll("[name]")].forEach(n=>{!n.defaultValue&&!i.current.has(n.name)&&b.current[n.name]&&(n.defaultValue=b.current[n.name]),n.type==="number"&&!F.current.includes(n.name)&&F.current.push(n.name)}),m.current){const n=Y();u.current={...n},b.current={...n}}},[h]),r.useLayoutEffect(()=>{O()},[]),Ve};A.Controller=ye,A.Form=Se,A.useController=ge,A.useForm=xe,A.useFormContext=ue,A.useWatch=me,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
22
+ <%s key={someKey} {...props} />`,p,y,x,y),ee[y+p]=!0)}if(y=null,R!==void 0&&(l(R),y=""+R),g(c)&&(l(c.key),y=""+c.key),"key"in c){R={};for(var N in c)N!=="key"&&(R[N]=c[N])}else R=c;return y&&k(R,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,y,_,P,E(),R,U,J)}function m(e){typeof e=="object"&&e!==null&&e.$$typeof===u&&e._store&&(e._store.validated=1)}var o=r,u=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),V=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),ie=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),se=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),ae=Symbol.for("react.memo"),Z=Symbol.for("react.lazy"),j=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),W=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=Object.prototype.hasOwnProperty,D=Array.isArray,M=console.createTask?console.createTask:function(){return null};o={"react-stack-bottom-frame":function(e){return e()}};var K,q={},$=o["react-stack-bottom-frame"].bind(o,h)(),S=M(i(h)),ee={};H.Fragment=d,H.jsx=function(e,c,R,p,P){var _=1e4>W.recentlyCreatedOwnerStacks++;return f(e,c,R,!1,p,P,_?Error("react-stack-top-frame"):$,_?M(i(e)):S)},H.jsxs=function(e,c,R,p,P){var _=1e4>W.recentlyCreatedOwnerStacks++;return f(e,c,R,!0,p,P,_?Error("react-stack-top-frame"):$,_?M(i(e)):S)}}()),H}var be;function Ce(){return be||(be=1,process.env.NODE_ENV==="production"?te.exports=ke():te.exports=ve()),te.exports}var he=Ce();const C=()=>{},Ee=r.createContext({ref:null,watch:C,actions:{reset:C,resetField:C,setValue:C,getValues:C,getErrors:C,getFieldStates:C,getFormStates:C,setError:C,clearError:C,clearErrors:C,checkValidity:C,getNumberFields:C,getFieldValidity:C,getDefaultValues:C,setFieldState:C,resetFieldState:C,getControlledFields:C},registerController:C,registerHookWatcher:C,lastReloadedAt:C,loadFormValues:C,getWatchValue:C,channels:{}}),ue=()=>r.useContext(Ee),Se=({id:s,control:a,method:l,action:i,children:E,onSubmit:h=()=>{},onInput:g=()=>{},onChange:k=()=>{},onBlur:v=()=>{},onReset:F=()=>{},numberFields:f=[],className:m,...o})=>(r.useEffect(()=>{const u=a.channels.subscribe("onChange",k),b=a.channels.subscribe("onBlur",v);return()=>{u(),b()}},[a.lastReloadedAt]),he.jsx(Ee.Provider,{value:a,children:he.jsx("form",{id:s,ref:a.ref,action:i,method:l,className:m,onInput:g,onSubmit:u=>{l||u.preventDefault();const b=a.loadFormValues();h(b)},onChange:u=>{const b=u.target.name;!b||a.actions.getControlledFields().has(b)||a.actions.setValue(b,u.target.value)},onBlur:u=>{const b=u.target.name;if(!b||a.actions.getControlledFields().has(b))return;const d=u.target.value;a.channels.publish("onBlur",b,d,a.actions.getValues())},onReset:u=>{a.actions.reset(),F(u)},...o,children:E},a.lastReloadedAt)})),ge=({control:s,name:a,compute:l})=>{const{getWatchValue:i,registerHookWatcher:E}=s||ue(),h=i({name:a,compute:l}),[g,k]=r.useState(h);return r.useEffect(()=>{const v=E({name:a,compute:l,value:g,setValue:k});return()=>v.forEach(F=>F())},[]),g},me=({name:s,defaultValue:a})=>{const{actions:l,registerController:i,channels:E}=ue(),h=r.useRef(),g=l.getDefaultValues()[s]||a||"",[k,v]=r.useState(g),F=ge({name:`fieldStates.${s}`}),f=r.useCallback((o,{shouldDirty:u=!0,shouldOnChange:b=!0}={})=>{var O,V;let d=o;(O=o==null?void 0:o.target)!=null&&O.value&&(d=o.target.value),(V=o==null?void 0:o.target)!=null&&V.checked&&(d=o.target.checked+""),v(d),l.setValue(s,d,{shouldDirty:u,shouldOnChange:b})},[l.setValue]),m=r.useCallback(o=>{const u=l.getValues(),b=o??u[s];E.publish("onBlur",s,b,u)},[]);return r.useEffect(()=>i(s,v),[]),{ref:h,name:s,defaultValue:g,value:k,onChange:f,onBlur:m,fieldState:F}},pe=({name:s,defaultValue:a,render:l=({ref:i,name:E,defaultValue:h,value:g,onChange:k,onBlur:v,fieldState:F})=>null})=>{const i=me({name:s,defaultValue:a});return l(i)},ye=["errors","fieldStates","formState"],re=(s={},a="")=>a.split(".").reduce((l,i)=>l&&l[i]!==void 0?l[i]:void 0,s),we=(s={},a="",l)=>{let i=s;const E=a.split(".");return E.forEach((h,g)=>{g<E.length-1&&(i[h]||(i[h]={}),g===E.length-2&&(i[h]={...i[h]}),i=i[h]),i[h]=l}),s},L=s=>ye.some(a=>s.startsWith(a))?s:"values."+s,Fe=["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"],Re=s=>{typeof s.setCustomValidity=="function"&&s.setCustomValidity("");let a=s.validity,l=Fe.find(i=>a[i]);if(l)return{type:l,message:s.validationMessage}};class Te{constructor(){this.events=new Map,this.watchEvents=new Map}getWatchEvents(){return this.watchEvents}getEvents(){return this.events}subscribe(a,l){return this.events.has(a)||this.events.set(a,new Set),this.events.get(a).add(l),()=>{var i;return(i=this.events.get(a))==null?void 0:i.delete(l)}}subscribeWatch(a,l){this.watchEvents.has(a)||(this.watchEvents.set(a,new Set),this.watchEvents.get(a).add(l))}publish(a,...l){this.events.forEach((i,E)=>{a.includes(E)&&i.forEach(h=>h(...l))}),this.watchEvents.forEach((i,E)=>{a.includes(E)&&i.forEach(h=>h(...l))})}reset(){this.events.clear(),this.watchEvents.clear()}}const _e=()=>{const s=r.useRef(new Te),a=r.useCallback((k,...v)=>{s.current.publish(k,...v)},[]),l=r.useCallback((k,v)=>s.current.subscribe(k,v),[]),i=r.useCallback((k,v)=>{s.current.subscribeWatch(k,v)},[]),E=r.useCallback(()=>s.current.getEvents(),[]),h=r.useCallback(()=>s.current.getWatchEvents(),[]),g=r.useCallback(()=>{s.current.reset()},[]);return{publish:a,subscribe:l,reset:g,getEvents:E,subscribeWatch:i,getWatchEvents:h}},Ae=()=>{const[s,a]=r.useState(),l=r.useCallback(()=>a(new Date().toString()),[]);return[s,l]},Oe=()=>{const[,s]=r.useState({});return r.useCallback(()=>s({}),[])},Pe=({channels:s,getValues:a,getErrors:l,getFieldStates:i,getFormState:E})=>{const h=Oe(),g=r.useCallback(({name:f,compute:m})=>{if(typeof m=="function")return m(a());if(Array.isArray(f)){const o={};return f.forEach(u=>{o[u]=g({name:u})}),o}return re({...a(),errors:{...l()},formState:{...E()},fieldStates:{...i()}},f)},[]),k=r.useCallback(f=>{if(!f)return s.subscribeWatch("values",()=>h()),a();if(typeof f=="string"){const m=L(f);return s.subscribeWatch(m,()=>h()),g({name:f})}if(Array.isArray(f)){const m={};return f.forEach(o=>{const u=L(o);s.subscribeWatch(u,()=>h()),m[o]=g({name:o})}),{...m}}throw new Error("Parameters of watch must be string or array of string")},[]),v=r.useCallback(({name:f,compute:m,setValue:o})=>{if(typeof m=="function")return[s.subscribe("values",()=>{const b=g({compute:m});o(b)})];if(!f)return[s.subscribe("values",()=>{o(a())})];if(typeof f=="string"){const u=L(f);return[s.subscribe(u,()=>{const d=g({name:f});o(d)})]}if(Array.isArray(f)){const u=g({name:f}),b=[];return f.forEach(d=>{const O=L(d),V=s.subscribe(O,()=>{const Y=g({name:d});u[d]=Y,o({...u})});b.push(V)}),b}throw new Error("Parameters of name must be string or array of string or compute must be a function")},[]),F=r.useCallback((f,m)=>{if(!f)return s.subscribe("values",m);if(typeof f=="string"){const o=L(f);return s.subscribe(o,m)}if(Array.isArray(f)){const o={},u=[];return f.forEach(b=>{const d=L(b),O=s.subscribe(d,()=>{o[b]=g({name:b}),m({...o})});u.push(O)}),u}throw new Error("Parameters of name must be string or array of string")},[s]);return{watch:k,registerHookWatcher:v,getWatchValue:g,subscribe:F}},le={isDirty:!1,isTouched:!1,error:null},je=[],Ne={},Ve=({numberFields:s=je,defaultValues:a=Ne,shouldUnRegister:l=!1,shouldConvertNumber:i=!1}={})=>{const[E,h]=Ae(),g=r.useRef(),k=r.useRef(!1),v=r.useRef(!1),F=r.useRef(s),f=r.useRef(new Map),m=r.useRef({}),o=r.useRef({}),u=r.useRef({...a}),b=r.useRef({...a}),d=_e(),O=r.useCallback(()=>{o.current=Object.keys(b.current).reduce((t,n)=>({...t,[n]:{...le}}),{})},[]),V=r.useCallback((t={})=>{b.current={...b.current,...t},u.current={...b.current},f.current.forEach((n,w)=>{n(b.current[w])}),k.current=!1,m.current={},F.current=s,f.current=new Map,d.reset(),O(),s.length>0&&(i=!0),h()},[]),Y=r.useCallback(()=>{const t=Object.fromEntries(new FormData(g.current));return f.current.forEach((w,T)=>{t[T]=u.current[T]}),i&&F.current.forEach(w=>t.hasOwnProperty(w)&&(t[w]=Number(t[w])||0)),{...u.current,...t}},[]),ie=r.useCallback(()=>!!Object.values(B()).find(t=>t.isDirty),[]),X=r.useCallback(()=>!!Object.values(W()).find(t=>!!t),[]),se=r.useCallback(t=>Re(t.target),[]),ne=r.useCallback(()=>b.current,[]),ae=r.useCallback(()=>F.current,[]),Z=r.useCallback(()=>f.current,[]),j=r.useCallback((t,n)=>n?Array.isArray(n)?n.reduce((w,T)=>({...w,[T]:re(t,T)}),{}):re(t,n):{...t},[]),Q=r.useCallback(t=>j(u.current,t),[j]),W=r.useCallback(t=>j(m.current,t),[j]),B=r.useCallback(t=>j(o.current,t),[j]),D=r.useCallback(t=>j({isDirty:k.current,isError:v.current,errorFields:Object.keys(m.current).filter(n=>!!m.current[n]),dirtyFields:Object.keys(o.current).filter(n=>o.current[n].isDirty),touchedFields:Object.keys(o.current).filter(n=>o.current[n].isTouched)},t),[j]),{watch:M,registerHookWatcher:K,getWatchValue:q,subscribe:$}=Pe({channels:d,getValues:Q,getErrors:W,getFieldStates:B,getFormState:D}),S=r.useCallback((t,n,w)=>{const T=o.current[t]||{...le};re(T,n)!==w&&(we(o.current,`${t}.${n}`,w),d.publish(`fieldStates.${t}.${n}`,w),n==="error"&&d.publish("formState.errorFields",D("errorFields")),n==="isDirty"&&d.publish("formState.dirtyFields",D("dirtyFields")),n==="isTouched"&&d.publish("formState.touchedFields",D("touchedFields")))},[]),ee=r.useCallback(t=>{S(t,"isDirty",!1),S(t,"isTouched",!1),S(t,"error",null)},[S]),e=r.useCallback((t,n)=>{if(m.current[t]===n)return;m.current[t]=n,S(t,"error",n),d.publish(`errors.${t}`,n);const T=X();v.current!==T&&(v.current=T,d.publish("formState.isError",T))},[S]),c=r.useCallback(t=>{if(!m.current[t])return;m.current[t]=null,S(t,"error",null),d.publish(`errors.${t}`,null);const n=X();v.current!==n&&(v.current=n,d.publish("formState.isError",n))},[S]),R=r.useCallback(()=>{if(Object.keys(m.current)===0)return;Object.keys(m.current).forEach(n=>c(n)),m.current={};const t=X();v.current!==t&&(v.current=t,d.publish("formState.isError",t))},[]),p=r.useCallback(t=>{const n=Re(t.target);n?e(t.target.name,n):c(t.target.name)},[e,c]),P=r.useCallback((t,n,{shouldDirty:w=!0,shouldOnChange:T=!0}={})=>{if(n===u.current[t])return;i&&F.current.includes(t)&&(n=Number(n)||void 0),S(t,"isTouched",!0);const ce=n!==b.current[t];w&&o.current[t].isDirty!==ce&&S(t,"isDirty",ce);const I=ie();k.current!==I&&(k.current=I,d.publish("formState.isDirty",I)),u.current[t]=n;const z=f.current.get(t);z&&z(n),d.publish(`values.${t}`,n,{shouldDirty:w,shouldOnChange:T}),T&&d.publish("onChange",t,n,u.current)},[S]),_=r.useCallback((t,n)=>(f.current.set(t,n),o.current[t]={...le},()=>{l&&f.current.delete(t)}),[]),U=r.useCallback((t,{keepError:n,keepDirty:w,keepTouched:T,keepCustomState:ce,defaultValue:I})=>{const z=f.current.get(t);if(!z)throw new Error(`Cannot reset "${t}" because it's uncontrolled field`);b.current[t]=I,u.current[t]=I,z&&z(I),n||c(t),w||S(t,"isDirty",!1),T||S(t,"isTouched",!1)},[c,S]),J=r.useCallback((t,n=N.getValues(t))=>{d.publish("onBlur",t,n,N.getValues())},[]),y=r.useCallback(t=>d.subscribe("onChange",t),[]),x=r.useCallback(t=>d.subscribe("onBlur",t),[]),N=r.useMemo(()=>({subscribe:$,reset:V,resetField:U,setValue:P,getValues:Q,getErrors:W,getFieldStates:B,getFormState:D,setError:e,clearError:c,clearErrors:R,checkValidity:p,getNumberFields:ae,getFieldValidity:se,getDefaultValues:ne,setFieldState:S,triggerFieldBlur:J,resetFieldState:ee,getControlledFields:Z,subscribeChange:y,subscribeBlur:x,getEvents:d.getEvents,getWatchEvents:d.getWatchEvents}),[$,V,U,P,Q,W,B,D,e,c,R,p,ae,se,ne,S,ee,J,Z,y,x]),oe=r.useMemo(()=>({ref:g,watch:M,actions:N,registerController:_,registerHookWatcher:K,lastReloadedAt:E,loadFormValues:Y,getWatchValue:q,channels:d}),[g,M,N,_,K,E,Y,q,d]),xe=r.useMemo(()=>({control:oe,actions:N,watch:M}),[E,oe,N,M]);return r.useLayoutEffect(()=>{if([...g.current.querySelectorAll("[name]")].forEach(n=>{!n.defaultValue&&!f.current.has(n.name)&&b.current[n.name]&&(n.defaultValue=b.current[n.name]),n.type==="number"&&!F.current.includes(n.name)&&F.current.push(n.name)}),g.current){const n=Y();u.current={...n},b.current={...n}}},[E]),r.useLayoutEffect(()=>{O()},[]),xe};A.Controller=pe,A.Form=Se,A.useController=me,A.useForm=Ve,A.useFormContext=ue,A.useWatch=ge,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-formkit",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "keywords": [
5
5
  "react formkit",
6
6
  "react ez formkit",
@@ -37,7 +37,8 @@
37
37
  "react": "^19.1.0",
38
38
  "react-dom": "^19.1.0",
39
39
  "react-simple-formkit": "^2.1.4",
40
- "vite": "^6.0.7"
40
+ "vite": "^6.0.7",
41
+ "zod": "^4.4.3"
41
42
  },
42
43
  "peerDependencies": {
43
44
  "react": "^19.1.0",