react-hook-form
Advanced tools
Comparing version 7.55.0-next.0 to 7.55.0-next.1
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("react"),t=e=>"checkbox"===e.type,r=e=>e instanceof Date,s=e=>null==e;const a=e=>"object"==typeof e;var i=e=>!s(e)&&!Array.isArray(e)&&a(e)&&!r(e),n=e=>i(e)&&e.target?t(e.target)?e.target.checked:e.target.value:e,o=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),l="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function u(e){let t;const r=Array.isArray(e),s="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(l&&(e instanceof Blob||s)||!r&&!i(e))return e;if(t=r?[]:{},r||(e=>{const t=e.constructor&&e.constructor.prototype;return i(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)e.hasOwnProperty(r)&&(t[r]=u(e[r]));else t=e}return t}var d=e=>Array.isArray(e)?e.filter(Boolean):[],c=e=>void 0===e,f=(e,t,r)=>{if(!t||!i(e))return r;const a=d(t.split(/[,[\].]+?/)).reduce(((e,t)=>s(e)?e:e[t]),e);return c(a)||a===e?c(e[t])?r:e[t]:a},m=e=>"boolean"==typeof e,y=e=>/^\w*$/.test(e),g=e=>d(e.replace(/["|']|\]/g,"").split(/\.|\[/)),_=(e,t,r)=>{let s=-1;const a=y(t)?[t]:g(t),n=a.length,o=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==o){const r=e[t];n=i(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=n,e=e[t]}return e};const b="blur",p="focusout",v="change",h="onBlur",V="onChange",x="onSubmit",F="onTouched",A="all",S="max",w="min",k="maxLength",D="minLength",E="pattern",C="required",O="validate",j=e.createContext(null),T=()=>e.useContext(j);var N=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const a=i;return t._proxyFormState[a]!==A&&(t._proxyFormState[a]=!s||A),r&&(r[a]=!0),e[a]}});return a};function M(t){const r=T(),{control:s=r.control,disabled:a,name:i,exact:n}=t||{},[o,l]=e.useState(s._formState),u=e.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=e.useRef(i);return d.current=i,e.useEffect((()=>s._subscribe({name:d.current,formState:u.current,exact:n,callback:e=>{!a&&l({...s._formState,...e})}})),[s,a,n]),e.useEffect((()=>{u.current.isValid&&s._setValid(!0)}),[s]),e.useMemo((()=>N(o,s,u.current,!1)),[o,s])}var U=e=>"string"==typeof e,B=(e,t,r,s,a)=>U(e)?(s&&t.watch.add(e),f(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),f(r,e)))):(s&&(t.watchAll=!0),r);function L(t){const r=T(),{control:s=r.control,name:a,defaultValue:i,disabled:n,exact:o}=t||{},l=e.useRef(a);l.current=a,e.useEffect((()=>s._subscribe({name:l.current,formState:{values:!0},exact:o,callback:e=>!n&&c(u(B(l.current,s._names,e.values||s._formValues,!1,i)))})),[s,i,n,o]);const[d,c]=e.useState(s._getWatch(a,i));return e.useEffect((()=>s._removeUnmounted())),d}function R(t){const r=T(),{name:s,disabled:a,control:i=r.control,shouldUnregister:l}=t,d=o(i._names.array,s),y=L({control:i,name:s,defaultValue:f(i._formValues,s,f(i._defaultValues,s,t.defaultValue)),exact:!0}),g=M({control:i,name:s,exact:!0}),p=e.useRef(i.register(s,{...t.rules,value:y,...m(t.disabled)?{disabled:t.disabled}:{}})),h=e.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!f(g.errors,s)},isDirty:{enumerable:!0,get:()=>!!f(g.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!f(g.touchedFields,s)},isValidating:{enumerable:!0,get:()=>!!f(g.validatingFields,s)},error:{enumerable:!0,get:()=>f(g.errors,s)}})),[g,s]),V=e.useMemo((()=>({name:s,value:y,...m(a)||g.disabled?{disabled:g.disabled||a}:{},onChange:e=>p.current.onChange({target:{value:n(e),name:s},type:v}),onBlur:()=>p.current.onBlur({target:{value:f(i._formValues,s),name:s},type:b}),ref:e=>{const t=f(i._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}})),[s,i._formValues,a,g.disabled,y,i._fields]);return e.useEffect((()=>{const e=i._options.shouldUnregister||l,t=(e,t)=>{const r=f(i._fields,e);r&&r._f&&(r._f.mount=t)};if(t(s,!0),e){const e=u(f(i._options.defaultValues,s));_(i._defaultValues,s,e),c(f(i._formValues,s))&&_(i._formValues,s,e)}return!d&&i.register(s),()=>{(d?e&&!i._state.action:e)?i.unregister(s):t(s,!1)}}),[s,i,d,l]),e.useEffect((()=>{i._setDisabledField({disabled:a,fields:i._fields,name:s})}),[a,s,i]),e.useMemo((()=>({field:V,formState:g,fieldState:h})),[V,g,h])}const P=e=>{const t={};for(const r of Object.keys(e))if(a(e[r])&&null!==e[r]){const s=P(e[r]);for(const e of Object.keys(s))t[`${r}.${e}`]=s[e]}else t[r]=e[r];return t},q="post";var W=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},$=e=>Array.isArray(e)?e:[e],I=()=>{let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}},H=e=>s(e)||!a(e);function J(e,t){if(H(e)||H(t))return e===t;if(r(e)&&r(t))return e.getTime()===t.getTime();const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const n of s){const s=e[n];if(!a.includes(n))return!1;if("ref"!==n){const e=t[n];if(r(s)&&r(e)||i(s)&&i(e)||Array.isArray(s)&&Array.isArray(e)?!J(s,e):s!==e)return!1}}return!0}var z=e=>i(e)&&!Object.keys(e).length,G=e=>"file"===e.type,K=e=>"function"==typeof e,Q=e=>{if(!l)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},X=e=>"select-multiple"===e.type,Y=e=>"radio"===e.type,Z=e=>Q(e)&&e.isConnected;function ee(e,t){const r=Array.isArray(t)?t:y(t)?[t]:g(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=c(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(i(s)&&z(s)||Array.isArray(s)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!c(e[t]))return!1;return!0}(s))&&ee(e,r.slice(0,-1)),e}var te=e=>{for(const t in e)if(K(e[t]))return!0;return!1};function re(e,t={}){const r=Array.isArray(e);if(i(e)||r)for(const r in e)Array.isArray(e[r])||i(e[r])&&!te(e[r])?(t[r]=Array.isArray(e[r])?[]:{},re(e[r],t[r])):s(e[r])||(t[r]=!0);return t}function se(e,t,r){const a=Array.isArray(e);if(i(e)||a)for(const a in e)Array.isArray(e[a])||i(e[a])&&!te(e[a])?c(t)||H(r[a])?r[a]=Array.isArray(e[a])?re(e[a],[]):{...re(e[a])}:se(e[a],s(t)?{}:t[a],r[a]):r[a]=!J(e[a],t[a]);return r}var ae=(e,t)=>se(e,t,re(t));const ie={value:!1,isValid:!1},ne={value:!0,isValid:!0};var oe=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!c(e[0].attributes.value)?c(e[0].value)||""===e[0].value?ne:{value:e[0].value,isValid:!0}:ne:ie}return ie},le=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>c(e)?e:t?""===e?NaN:e?+e:e:r&&U(e)?new Date(e):s?s(e):e;const ue={isValid:!1,value:null};var de=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),ue):ue;function ce(e){const r=e.ref;return G(r)?r.files:Y(r)?de(e.refs).value:X(r)?[...r.selectedOptions].map((({value:e})=>e)):t(r)?oe(e.refs).value:le(c(r.value)?e.ref.value:r.value,e)}var fe=e=>e instanceof RegExp,me=e=>c(e)?e:fe(e)?e.source:i(e)?fe(e.value)?e.value.source:e.value:e,ye=e=>({isOnSubmit:!e||e===x,isOnBlur:e===h,isOnChange:e===V,isOnAll:e===A,isOnTouch:e===F});const ge="AsyncFunction";var _e=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))));const be=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const r=f(e,a);if(r){const{_f:e,...n}=r;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],a)&&!s)return!0;if(e.ref&&t(e.ref,e.name)&&!s)return!0;if(be(n,t))break}else if(i(n)&&be(n,t))break}}};function pe(e,t,r){const s=f(e,r);if(s||y(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),i=f(t,s),n=f(e,s);if(i&&!Array.isArray(i)&&r!==s)return{name:r};if(n&&n.type)return{name:s,error:n};a.pop()}return{name:r}}var ve=(e,t,r)=>{const s=$(f(e,r));return _(s,"root",t[r]),_(e,r,s),e},he=e=>U(e);function Ve(e,t,r="validate"){if(he(e)||Array.isArray(e)&&e.every(he)||m(e)&&!e)return{type:r,message:he(e)?e:"",ref:t}}var xe=e=>i(e)&&!fe(e)?e:{value:e,message:""},Fe=async(e,r,a,n,o,l)=>{const{ref:u,refs:d,required:y,maxLength:g,minLength:_,min:b,max:p,pattern:v,validate:h,name:V,valueAsNumber:x,mount:F}=e._f,A=f(a,V);if(!F||r.has(V))return{};const j=d?d[0]:u,T=e=>{o&&j.reportValidity&&(j.setCustomValidity(m(e)?"":e||""),j.reportValidity())},N={},M=Y(u),B=t(u),L=M||B,R=(x||G(u))&&c(u.value)&&c(A)||Q(u)&&""===u.value||""===A||Array.isArray(A)&&!A.length,P=W.bind(null,V,n,N),q=(e,t,r,s=k,a=D)=>{const i=e?t:r;N[V]={type:e?s:a,message:i,ref:u,...P(e?s:a,i)}};if(l?!Array.isArray(A)||!A.length:y&&(!L&&(R||s(A))||m(A)&&!A||B&&!oe(d).isValid||M&&!de(d).isValid)){const{value:e,message:t}=he(y)?{value:!!y,message:y}:xe(y);if(e&&(N[V]={type:C,message:t,ref:j,...P(C,t)},!n))return T(t),N}if(!(R||s(b)&&s(p))){let e,t;const r=xe(p),a=xe(b);if(s(A)||isNaN(A)){const s=u.valueAsDate||new Date(A),i=e=>new Date((new Date).toDateString()+" "+e),n="time"==u.type,o="week"==u.type;U(r.value)&&A&&(e=n?i(A)>i(r.value):o?A>r.value:s>new Date(r.value)),U(a.value)&&A&&(t=n?i(A)<i(a.value):o?A<a.value:s<new Date(a.value))}else{const i=u.valueAsNumber||(A?+A:A);s(r.value)||(e=i>r.value),s(a.value)||(t=i<a.value)}if((e||t)&&(q(!!e,r.message,a.message,S,w),!n))return T(N[V].message),N}if((g||_)&&!R&&(U(A)||l&&Array.isArray(A))){const e=xe(g),t=xe(_),r=!s(e.value)&&A.length>+e.value,a=!s(t.value)&&A.length<+t.value;if((r||a)&&(q(r,e.message,t.message),!n))return T(N[V].message),N}if(v&&!R&&U(A)){const{value:e,message:t}=xe(v);if(fe(e)&&!A.match(e)&&(N[V]={type:E,message:t,ref:u,...P(E,t)},!n))return T(t),N}if(h)if(K(h)){const e=Ve(await h(A,a),j);if(e&&(N[V]={...e,...P(O,e.message)},!n))return T(e.message),N}else if(i(h)){let e={};for(const t in h){if(!z(e)&&!n)break;const r=Ve(await h[t](A,a),j,t);r&&(e={...r,...P(t,r.message)},T(r.message),n&&(N[V]=e))}if(!z(e)&&(N[V]={ref:j,...e},!n))return N}return T(!0),N};const Ae={mode:x,reValidateMode:V,shouldFocusError:!0};function Se(e={}){let a,y={...Ae,...e},g={submitCount:0,isDirty:!1,isLoading:K(y.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:y.errors||{},disabled:y.disabled||!1},v={},h=(i(y.defaultValues)||i(y.values))&&u(y.defaultValues||y.values)||{},V=y.shouldUnregister?{}:u(h),x={action:!1,mount:!1,watch:!1},F={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},S=0;const w={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let k={...w};const D={array:I(),state:I()},E=ye(y.mode),C=ye(y.reValidateMode),O=y.criteriaMode===A,j=async e=>{if(!y.disabled&&(w.isValid||k.isValid||e)){const e=y.resolver?z((await R()).errors):await P(v,!0);e!==g.isValid&&D.state.next({isValid:e})}},T=(e,t)=>{!y.disabled&&(w.isValidating||w.validatingFields||k.isValidating||k.validatingFields)&&((e||Array.from(F.mount)).forEach((e=>{e&&(t?_(g.validatingFields,e,t):ee(g.validatingFields,e))})),D.state.next({validatingFields:g.validatingFields,isValidating:!z(g.validatingFields)}))},N=(e,t,r,s)=>{const a=f(v,e);if(a){const i=f(V,e,c(r)?f(h,e):r);c(i)||s&&s.defaultChecked||t?_(V,e,t?i:ce(a._f)):H(e,i),x.mount&&j()}},M=(e,t,r,s,a)=>{let i=!1,n=!1;const o={name:e};if(!y.disabled){const l=!!(f(v,e)&&f(v,e)._f&&f(v,e)._f.disabled);if(!r||s){(w.isDirty||k.isDirty)&&(n=g.isDirty,g.isDirty=o.isDirty=q(),i=n!==o.isDirty);const r=l||J(f(h,e),t);n=!(l||!f(g.dirtyFields,e)),r||l?ee(g.dirtyFields,e):_(g.dirtyFields,e,!0),o.dirtyFields=g.dirtyFields,i=i||(w.dirtyFields||k.dirtyFields)&&n!==!r}if(r){const t=f(g.touchedFields,e);t||(_(g.touchedFields,e,r),o.touchedFields=g.touchedFields,i=i||(w.touchedFields||k.touchedFields)&&t!==r)}i&&a&&D.state.next(o)}return i?o:{}},L=(e,t,r,s)=>{const i=f(g.errors,e),n=(w.isValid||k.isValid)&&m(t)&&g.isValid!==t;var o;if(y.delayError&&r?(o=()=>((e,t)=>{_(g.errors,e,t),D.state.next({errors:g.errors})})(e,r),a=e=>{clearTimeout(S),S=setTimeout(o,e)},a(y.delayError)):(clearTimeout(S),a=null,r?_(g.errors,e,r):ee(g.errors,e)),(r?!J(i,r):i)||!z(s)||n){const r={...s,...n&&m(t)?{isValid:t}:{},errors:g.errors,name:e};g={...g,...r},D.state.next(r)}},R=async e=>{T(e,!0);const t=await y.resolver(V,y.context,((e,t,r,s)=>{const a={};for(const r of e){const e=f(t,r);e&&_(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||F.mount,v,y.criteriaMode,y.shouldUseNativeValidation));return T(e),t},P=async(e,t,r={valid:!0})=>{for(const a in e){const n=e[a];if(n){const{_f:e,...o}=n;if(e){const o=F.array.has(e.name),l=n._f&&(!!(s=n._f)&&!!s.validate&&!!(K(s.validate)&&s.validate.constructor.name===ge||i(s.validate)&&Object.values(s.validate).find((e=>e.constructor.name===ge))));l&&w.validatingFields&&T([a],!0);const u=await Fe(n,F.disabled,V,O,y.shouldUseNativeValidation&&!t,o);if(l&&w.validatingFields&&T([a]),u[e.name]&&(r.valid=!1,t))break;!t&&(f(u,e.name)?o?ve(g.errors,u,e.name):_(g.errors,e.name,u[e.name]):ee(g.errors,e.name))}!z(o)&&await P(o,t,r)}}var s;return r.valid},q=(e,t)=>!y.disabled&&(e&&t&&_(V,e,t),!J(oe(),h)),W=(e,t,r)=>B(e,F,{...x.mount?V:c(t)?h:U(e)?{[e]:t}:t},r,t),H=(e,r,a={})=>{const i=f(v,e);let n=r;if(i){const a=i._f;a&&(!a.disabled&&_(V,e,le(r,a)),n=Q(a.ref)&&s(r)?"":r,X(a.ref)?[...a.ref.options].forEach((e=>e.selected=n.includes(e.value))):a.refs?t(a.ref)?a.refs.length>1?a.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):a.refs[0]&&(a.refs[0].checked=!!n):a.refs.forEach((e=>e.checked=e.value===n)):G(a.ref)?a.ref.value="":(a.ref.value=n,a.ref.type||D.state.next({name:e,values:{...V}})))}(a.shouldDirty||a.shouldTouch)&&M(e,n,a.shouldTouch,a.shouldDirty,!0),a.shouldValidate&&ne(e)},te=(e,t,s)=>{for(const a in t){const n=t[a],o=`${e}.${a}`,l=f(v,o);(F.array.has(e)||i(n)||l&&!l._f)&&!r(n)?te(o,n,s):H(o,n,s)}},re=(e,t,r={})=>{const a=f(v,e),i=F.array.has(e),n=u(t);_(V,e,n),i?(D.array.next({name:e,values:{...V}}),(w.isDirty||w.dirtyFields||k.isDirty||k.dirtyFields)&&r.shouldDirty&&D.state.next({name:e,dirtyFields:ae(h,V),isDirty:q(e,n)})):!a||a._f||s(n)?H(e,n,r):te(e,n,r),_e(e,F)&&D.state.next({...g}),D.state.next({name:x.mount?e:void 0,values:{...V}})},se=async e=>{x.mount=!0;const t=e.target;let s=t.name,i=!0;const o=f(v,s),l=e=>{i=Number.isNaN(e)||r(e)&&isNaN(e.getTime())||J(e,f(V,s,e))};if(o){let r,d;const c=t.type?ce(o._f):n(e),m=e.type===b||e.type===p,h=!((u=o._f).mount&&(u.required||u.min||u.max||u.maxLength||u.minLength||u.pattern||u.validate)||y.resolver||f(g.errors,s)||o._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(m,f(g.touchedFields,s),g.isSubmitted,C,E),x=_e(s,F,m);_(V,s,c),m?(o._f.onBlur&&o._f.onBlur(e),a&&a(0)):o._f.onChange&&o._f.onChange(e);const A=M(s,c,m),S=!z(A)||x;if(!m&&D.state.next({name:s,type:e.type,values:{...V}}),h)return(w.isValid||k.isValid)&&("onBlur"===y.mode&&m?j():m||j()),S&&D.state.next({name:s,...x?{}:A});if(!m&&x&&D.state.next({...g}),y.resolver){const{errors:e}=await R([s]);if(l(c),i){const t=pe(g.errors,v,s),a=pe(e,v,t.name||s);r=a.error,s=a.name,d=z(e)}}else T([s],!0),r=(await Fe(o,F.disabled,V,O,y.shouldUseNativeValidation))[s],T([s]),l(c),i&&(r?d=!1:(w.isValid||k.isValid)&&(d=await P(v,!0)));i&&(o._f.deps&&ne(o._f.deps),L(s,d,r,A))}var u},ie=(e,t)=>{if(f(g.errors,t)&&e.focus)return e.focus(),1},ne=async(e,t={})=>{let r,s;const a=$(e);if(y.resolver){const t=await(async e=>{const{errors:t}=await R(e);if(e)for(const r of e){const e=f(t,r);e?_(g.errors,r,e):ee(g.errors,r)}else g.errors=t;return t})(c(e)?e:a);r=z(t),s=e?!a.some((e=>f(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=f(v,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||g.isValid)&&j()):s=r=await P(v);return D.state.next({...!U(e)||(w.isValid||k.isValid)&&r!==g.isValid?{}:{name:e},...y.resolver||!e?{isValid:r}:{},errors:g.errors}),t.shouldFocus&&!s&&be(v,ie,e?a:F.mount),s},oe=e=>{const t={...x.mount?V:h};return c(e)?t:U(e)?f(t,e):e.map((e=>f(t,e)))},ue=(e,t)=>({invalid:!!f((t||g).errors,e),isDirty:!!f((t||g).dirtyFields,e),error:f((t||g).errors,e),isValidating:!!f(g.validatingFields,e),isTouched:!!f((t||g).touchedFields,e)}),de=(e,t,r)=>{const s=(f(v,e,{_f:{}})._f||{}).ref,a=f(g.errors,e)||{},{ref:i,message:n,type:o,...l}=a;_(g.errors,e,{...l,...t,ref:s}),D.state.next({name:e,errors:g.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},fe=e=>D.state.subscribe({next:t=>{var r,s,a;r=e.name,s=t.name,a=e.exact,r&&s&&r!==s&&!$(r).some((e=>e&&(a?e===s:e.startsWith(s)||s.startsWith(e))))||!((e,t,r,s)=>{r(e);const{name:a,...i}=e;return z(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find((e=>t[e]===(!s||A)))})(t,e.formState||w,Ee,e.reRenderRoot)||e.callback({values:V,...g,...t})}}).unsubscribe,he=(e,t={})=>{for(const r of e?$(e):F.mount)F.mount.delete(r),F.array.delete(r),t.keepValue||(ee(v,r),ee(V,r)),!t.keepError&&ee(g.errors,r),!t.keepDirty&&ee(g.dirtyFields,r),!t.keepTouched&&ee(g.touchedFields,r),!t.keepIsValidating&&ee(g.validatingFields,r),!y.shouldUnregister&&!t.keepDefaultValue&&ee(h,r);D.state.next({values:{...V}}),D.state.next({...g,...t.keepDirty?{isDirty:q()}:{}}),!t.keepIsValid&&j()},Ve=({disabled:e,name:t,field:r,fields:s})=>{(m(e)&&x.mount||e||F.disabled.has(t))&&(e?F.disabled.add(t):F.disabled.delete(t),M(t,ce(r?r._f:f(s,t)._f),!1,!1,!0))},xe=(e,r={})=>{let s=f(v,e);const a=m(r.disabled)||m(y.disabled);return _(v,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...r}}),F.mount.add(e),s?Ve({field:s,disabled:m(r.disabled)?r.disabled:y.disabled,name:e}):N(e,!0,r.value),{...a?{disabled:r.disabled||y.disabled}:{},...y.progressive?{required:!!r.required,min:me(r.min),max:me(r.max),minLength:me(r.minLength),maxLength:me(r.maxLength),pattern:me(r.pattern)}:{},name:e,onChange:se,onBlur:se,ref:a=>{if(a){xe(e,r),s=f(v,e);const i=c(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,n=(e=>Y(e)||t(e))(i),o=s._f.refs||[];if(n?o.find((e=>e===i)):i===s._f.ref)return;_(v,e,{_f:{...s._f,...n?{refs:[...o.filter(Z),i,...Array.isArray(f(h,e))?[{}]:[]],ref:{type:i.type,name:e}}:{ref:i}}}),N(e,!1,void 0,i)}else s=f(v,e,{}),s._f&&(s._f.mount=!1),(y.shouldUnregister||r.shouldUnregister)&&(!o(F.array,e)||!x.action)&&F.unMount.add(e)}}},Se=()=>y.shouldFocusError&&be(v,ie,F.mount),we=(e,t)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=u(V);if(F.disabled.size)for(const e of F.disabled)_(a,e,void 0);if(D.state.next({isSubmitting:!0}),y.resolver){const{errors:e,values:t}=await R();g.errors=e,a=t}else await P(v);if(ee(g.errors,"root"),z(g.errors)){D.state.next({errors:{}});try{await e(a,r)}catch(e){s=e}}else t&&await t({...g.errors},r),Se(),setTimeout(Se);if(D.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:z(g.errors)&&!s,submitCount:g.submitCount+1,errors:g.errors}),s)throw s},ke=(e,t={})=>{const r=e?u(e):h,s=u(r),a=z(e),i=a?h:s;if(t.keepDefaultValues||(h=r),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...F.mount,...Object.keys(ae(h,V))]);for(const t of Array.from(e))f(g.dirtyFields,t)?_(i,t,f(V,t)):re(t,f(i,t))}else{if(l&&c(e))for(const e of F.mount){const t=f(v,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(Q(e)){const t=e.closest("form");if(t){t.reset();break}}}}v={}}V=y.shouldUnregister?t.keepDefaultValues?u(h):{}:u(i),D.array.next({values:{...i}}),D.state.next({values:{...i}})}F={mount:t.keepDirtyValues?F.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},x.mount=!w.isValid||!!t.keepIsValid||!!t.keepDirtyValues,x.watch=!!y.shouldUnregister,D.state.next({submitCount:t.keepSubmitCount?g.submitCount:0,isDirty:!a&&(t.keepDirty?g.isDirty:!(!t.keepDefaultValues||J(e,h))),isSubmitted:!!t.keepIsSubmitted&&g.isSubmitted,dirtyFields:a?{}:t.keepDirtyValues?t.keepDefaultValues&&V?ae(h,V):g.dirtyFields:t.keepDefaultValues&&e?ae(h,e):t.keepDirty?g.dirtyFields:{},touchedFields:t.keepTouched?g.touchedFields:{},errors:t.keepErrors?g.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&g.isSubmitSuccessful,isSubmitting:!1})},De=(e,t)=>ke(K(e)?e(V):e,t),Ee=e=>{g={...g,...e}},Ce={control:{register:xe,unregister:he,getFieldState:ue,handleSubmit:we,setError:de,_subscribe:fe,_runSchema:R,_getWatch:W,_getDirty:q,_setValid:j,_setFieldArray:(e,t=[],r,s,a=!0,i=!0)=>{if(s&&r&&!y.disabled){if(x.action=!0,i&&Array.isArray(f(v,e))){const t=r(f(v,e),s.argA,s.argB);a&&_(v,e,t)}if(i&&Array.isArray(f(g.errors,e))){const t=r(f(g.errors,e),s.argA,s.argB);a&&_(g.errors,e,t),((e,t)=>{!d(f(e,t)).length&&ee(e,t)})(g.errors,e)}if((w.touchedFields||k.touchedFields)&&i&&Array.isArray(f(g.touchedFields,e))){const t=r(f(g.touchedFields,e),s.argA,s.argB);a&&_(g.touchedFields,e,t)}(w.dirtyFields||k.dirtyFields)&&(g.dirtyFields=ae(h,V)),D.state.next({name:e,isDirty:q(e,t),dirtyFields:g.dirtyFields,errors:g.errors,isValid:g.isValid})}else _(V,e,t)},_setDisabledField:Ve,_setErrors:e=>{g.errors=e,D.state.next({errors:g.errors,isValid:!1})},_getFieldArray:e=>d(f(x.mount?V:h,e,y.shouldUnregister?f(h,e,[]):[])),_reset:ke,_resetDefaultValues:()=>K(y.defaultValues)&&y.defaultValues().then((e=>{De(e,y.resetOptions),D.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of F.unMount){const t=f(v,e);t&&(t._f.refs?t._f.refs.every((e=>!Z(e))):!Z(t._f.ref))&&he(e)}F.unMount=new Set},_disableForm:e=>{m(e)&&(D.state.next({disabled:e}),be(v,((t,r)=>{const s=f(v,r);s&&(t.disabled=s._f.disabled||e,Array.isArray(s._f.refs)&&s._f.refs.forEach((t=>{t.disabled=s._f.disabled||e})))}),0,!1))},_subjects:D,_proxyFormState:w,get _fields(){return v},get _formValues(){return V},get _state(){return x},set _state(e){x=e},get _defaultValues(){return h},get _names(){return F},set _names(e){F=e},get _formState(){return g},get _options(){return y},set _options(e){y={...y,...e}}},subscribe:e=>(x.mount=!0,k={...k,...e.formState},fe({...e,formState:k})),trigger:ne,register:xe,handleSubmit:we,watch:(e,t)=>K(e)?D.state.subscribe({next:r=>e(W(void 0,t),r)}):W(e,t,!0),setValue:re,getValues:oe,reset:De,resetField:(e,t={})=>{f(v,e)&&(c(t.defaultValue)?re(e,u(f(h,e))):(re(e,t.defaultValue),_(h,e,u(t.defaultValue))),t.keepTouched||ee(g.touchedFields,e),t.keepDirty||(ee(g.dirtyFields,e),g.isDirty=t.defaultValue?q(e,u(f(h,e))):q()),t.keepError||(ee(g.errors,e),w.isValid&&j()),D.state.next({...g}))},clearErrors:e=>{e&&$(e).forEach((e=>ee(g.errors,e))),D.state.next({errors:e?g.errors:{}})},unregister:he,setError:de,setFocus:(e,t={})=>{const r=f(v,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&K(e.select)&&e.select())}},getFieldState:ue};return{...Ce,formControl:Ce}}var we=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},ke=(e,t,r={})=>r.shouldFocus||c(r.shouldFocus)?r.focusName||`${e}.${c(r.focusIndex)?t:r.focusIndex}.`:"",De=(e,t)=>[...e,...$(t)],Ee=e=>Array.isArray(e)?e.map((()=>{})):void 0;function Ce(e,t,r){return[...e.slice(0,t),...$(r),...e.slice(t)]}var Oe=(e,t,r)=>Array.isArray(e)?(c(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],je=(e,t)=>[...$(t),...$(e)];var Te=(e,t)=>c(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return d(s).length?s:[]}(e,$(t).sort(((e,t)=>e-t))),Ne=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},Me=(e,t,r)=>(e[t]=r,e);exports.Controller=e=>e.render(R(e)),exports.Form=function(t){const r=T(),[s,a]=e.useState(!1),{control:i=r.control,onSubmit:n,children:o,action:l,method:u=q,headers:d,encType:c,onError:f,render:m,onSuccess:y,validateStatus:g,..._}=t,b=async e=>{let r=!1,s="";await i.handleSubmit((async t=>{const a=new FormData;let o="";try{o=JSON.stringify(t)}catch(e){}const m=P(i._formValues);for(const e in m)a.append(e,m[e]);if(n&&await n({data:t,event:e,method:u,formData:a,formDataJson:o}),l)try{const e=[d&&d["Content-Type"],c].some((e=>e&&e.includes("json"))),t=await fetch(String(l),{method:u,headers:{...d,...c?{"Content-Type":c}:{}},body:e?o:a});t&&(g?!g(t.status):t.status<200||t.status>=300)?(r=!0,f&&f({response:t}),s=String(t.status)):y&&y({response:t})}catch(e){r=!0,f&&f({error:e})}}))(e),r&&t.control&&(t.control._subjects.state.next({isSubmitSuccessful:!1}),t.control.setError("root.server",{type:s}))};return e.useEffect((()=>{a(!0)}),[]),m?e.createElement(e.Fragment,null,m({submit:b})):e.createElement("form",{noValidate:s,action:l,method:u,encType:c,onSubmit:b,..._},o)},exports.FormProvider=t=>{const{children:r,...s}=t;return e.createElement(j.Provider,{value:s},r)},exports.appendErrors=W,exports.createFormControl=Se,exports.get=f,exports.set=_,exports.useController=R,exports.useFieldArray=function(t){const r=T(),{control:s=r.control,name:a,keyName:i="id",shouldUnregister:n,rules:o}=t,[l,d]=e.useState(s._getFieldArray(a)),c=e.useRef(s._getFieldArray(a).map(we)),m=e.useRef(l),y=e.useRef(a),g=e.useRef(!1);y.current=a,m.current=l,s._names.array.add(a),o&&s.register(a,o),e.useEffect((()=>s._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===y.current||!t){const t=f(e,y.current);Array.isArray(t)&&(d(t),c.current=t.map(we))}}}).unsubscribe),[s]);const b=e.useCallback((e=>{g.current=!0,s._setFieldArray(a,e)}),[s,a]);return e.useEffect((()=>{if(s._state.action=!1,_e(a,s._names)&&s._subjects.state.next({...s._formState}),g.current&&(!ye(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._runSchema([a]).then((e=>{const t=f(e.errors,a),r=f(s._formState.errors,a);(r?!t&&r.type||t&&(r.type!==t.type||r.message!==t.message):t&&t.type)&&(t?_(s._formState.errors,a,t):ee(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=f(s._fields,a);!e||!e._f||ye(s._options.reValidateMode).isOnSubmit&&ye(s._options.mode).isOnSubmit||Fe(e,s._names.disabled,s._formValues,s._options.criteriaMode===A,s._options.shouldUseNativeValidation,!0).then((e=>!z(e)&&s._subjects.state.next({errors:ve(s._formState.errors,e,a)})))}s._subjects.state.next({name:a,values:{...s._formValues}}),s._names.focus&&be(s._fields,((e,t)=>{if(s._names.focus&&t.startsWith(s._names.focus)&&e.focus)return e.focus(),1})),s._names.focus="",s._setValid(),g.current=!1}),[l,a,s]),e.useEffect((()=>(!f(s._formValues,a)&&s._setFieldArray(a),()=>{(s._options.shouldUnregister||n)&&s.unregister(a)})),[a,s,i,n]),{swap:e.useCallback(((e,t)=>{const r=s._getFieldArray(a);Ne(r,e,t),Ne(c.current,e,t),b(r),d(r),s._setFieldArray(a,r,Ne,{argA:e,argB:t},!1)}),[b,a,s]),move:e.useCallback(((e,t)=>{const r=s._getFieldArray(a);Oe(r,e,t),Oe(c.current,e,t),b(r),d(r),s._setFieldArray(a,r,Oe,{argA:e,argB:t},!1)}),[b,a,s]),prepend:e.useCallback(((e,t)=>{const r=$(u(e)),i=je(s._getFieldArray(a),r);s._names.focus=ke(a,0,t),c.current=je(c.current,r.map(we)),b(i),d(i),s._setFieldArray(a,i,je,{argA:Ee(e)})}),[b,a,s]),append:e.useCallback(((e,t)=>{const r=$(u(e)),i=De(s._getFieldArray(a),r);s._names.focus=ke(a,i.length-1,t),c.current=De(c.current,r.map(we)),b(i),d(i),s._setFieldArray(a,i,De,{argA:Ee(e)})}),[b,a,s]),remove:e.useCallback((e=>{const t=Te(s._getFieldArray(a),e);c.current=Te(c.current,e),b(t),d(t),!Array.isArray(f(s._fields,a))&&_(s._fields,a,void 0),s._setFieldArray(a,t,Te,{argA:e})}),[b,a,s]),insert:e.useCallback(((e,t,r)=>{const i=$(u(t)),n=Ce(s._getFieldArray(a),e,i);s._names.focus=ke(a,e,r),c.current=Ce(c.current,e,i.map(we)),b(n),d(n),s._setFieldArray(a,n,Ce,{argA:e,argB:Ee(t)})}),[b,a,s]),update:e.useCallback(((e,t)=>{const r=u(t),i=Me(s._getFieldArray(a),e,r);c.current=[...i].map(((t,r)=>t&&r!==e?c.current[r]:we())),b(i),d([...i]),s._setFieldArray(a,i,Me,{argA:e,argB:r},!0,!1)}),[b,a,s]),replace:e.useCallback((e=>{const t=$(u(e));c.current=t.map(we),b([...t]),d([...t]),s._setFieldArray(a,[...t],(e=>e),{},!0,!1)}),[b,a,s]),fields:e.useMemo((()=>l.map(((e,t)=>({...e,[i]:c.current[t]||we()})))),[l,i])}},exports.useForm=function(t={}){const r=e.useRef(void 0),s=e.useRef(void 0),[a,i]=e.useState({isDirty:!1,isValidating:!1,isLoading:K(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,defaultValues:K(t.defaultValues)?void 0:t.defaultValues});r.current||(r.current={...t.control?t.control:Se(t),formState:a});const n=r.current.control;return n._options=t,e.useEffect((()=>n._subscribe({formState:n._proxyFormState,callback:()=>i({...n._formState}),reRenderRoot:!0})),[n]),e.useEffect((()=>n._disableForm(t.disabled)),[n,t.disabled]),e.useEffect((()=>{if(n._proxyFormState.isDirty){const e=n._getDirty();e!==a.isDirty&&n._subjects.state.next({isDirty:e})}}),[n,a.isDirty]),e.useEffect((()=>{t.values&&!J(t.values,s.current)?(n._reset(t.values,n._options.resetOptions),s.current=t.values,i((e=>({...e})))):n._resetDefaultValues()}),[t.values,n]),e.useEffect((()=>{t.errors&&n._setErrors(t.errors)}),[t.errors,n]),e.useEffect((()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),e.useEffect((()=>{t.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})}),[t.shouldUnregister,n]),r.current.formState=N(a,n),r.current},exports.useFormContext=T,exports.useFormState=M,exports.useWatch=L; | ||
"use strict";var e=require("react"),t=e=>"checkbox"===e.type,r=e=>e instanceof Date,s=e=>null==e;const a=e=>"object"==typeof e;var i=e=>!s(e)&&!Array.isArray(e)&&a(e)&&!r(e),n=e=>i(e)&&e.target?t(e.target)?e.target.checked:e.target.value:e,o=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),l="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function u(e){let t;const r=Array.isArray(e),s="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(l&&(e instanceof Blob||s)||!r&&!i(e))return e;if(t=r?[]:{},r||(e=>{const t=e.constructor&&e.constructor.prototype;return i(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)e.hasOwnProperty(r)&&(t[r]=u(e[r]));else t=e}return t}var d=e=>Array.isArray(e)?e.filter(Boolean):[],c=e=>void 0===e,f=(e,t,r)=>{if(!t||!i(e))return r;const a=d(t.split(/[,[\].]+?/)).reduce(((e,t)=>s(e)?e:e[t]),e);return c(a)||a===e?c(e[t])?r:e[t]:a},m=e=>"boolean"==typeof e,y=e=>/^\w*$/.test(e),g=e=>d(e.replace(/["|']|\]/g,"").split(/\.|\[/)),_=(e,t,r)=>{let s=-1;const a=y(t)?[t]:g(t),n=a.length,o=n-1;for(;++s<n;){const t=a[s];let n=r;if(s!==o){const r=e[t];n=i(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=n,e=e[t]}return e};const b="blur",p="focusout",v="change",h="onBlur",V="onChange",x="onSubmit",F="onTouched",A="all",S="max",w="min",k="maxLength",D="minLength",E="pattern",C="required",O="validate",j=e.createContext(null),T=()=>e.useContext(j);var N=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const a=i;return t._proxyFormState[a]!==A&&(t._proxyFormState[a]=!s||A),r&&(r[a]=!0),e[a]}});return a};function M(t){const r=T(),{control:s=r.control,disabled:a,name:i,exact:n}=t||{},[o,l]=e.useState(s._formState),u=e.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=e.useRef(i);return d.current=i,e.useEffect((()=>s._subscribe({name:d.current,formState:u.current,exact:n,callback:e=>{!a&&l({...s._formState,...e})}})),[s,a,n]),e.useEffect((()=>{u.current.isValid&&s._setValid(!0)}),[s]),e.useMemo((()=>N(o,s,u.current,!1)),[o,s])}var U=e=>"string"==typeof e,B=(e,t,r,s,a)=>U(e)?(s&&t.watch.add(e),f(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),f(r,e)))):(s&&(t.watchAll=!0),r);function L(t){const r=T(),{control:s=r.control,name:a,defaultValue:i,disabled:n,exact:o}=t||{},l=e.useRef(a);l.current=a,e.useEffect((()=>s._subscribe({name:l.current,formState:{values:!0},exact:o,callback:e=>!n&&c(u(B(l.current,s._names,e.values||s._formValues,!1,i)))})),[s,i,n,o]);const[d,c]=e.useState(s._getWatch(a,i));return e.useEffect((()=>s._removeUnmounted())),d}function R(t){const r=T(),{name:s,disabled:a,control:i=r.control,shouldUnregister:l}=t,d=o(i._names.array,s),y=L({control:i,name:s,defaultValue:f(i._formValues,s,f(i._defaultValues,s,t.defaultValue)),exact:!0}),g=M({control:i,name:s,exact:!0}),p=e.useRef(i.register(s,{...t.rules,value:y,...m(t.disabled)?{disabled:t.disabled}:{}})),h=e.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!f(g.errors,s)},isDirty:{enumerable:!0,get:()=>!!f(g.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!f(g.touchedFields,s)},isValidating:{enumerable:!0,get:()=>!!f(g.validatingFields,s)},error:{enumerable:!0,get:()=>f(g.errors,s)}})),[g,s]),V=e.useMemo((()=>({name:s,value:y,...m(a)||g.disabled?{disabled:g.disabled||a}:{},onChange:e=>p.current.onChange({target:{value:n(e),name:s},type:v}),onBlur:()=>p.current.onBlur({target:{value:f(i._formValues,s),name:s},type:b}),ref:e=>{const t=f(i._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}})),[s,i._formValues,a,g.disabled,y,i._fields]);return e.useEffect((()=>{const e=i._options.shouldUnregister||l,t=(e,t)=>{const r=f(i._fields,e);r&&r._f&&(r._f.mount=t)};if(t(s,!0),e){const e=u(f(i._options.defaultValues,s));_(i._defaultValues,s,e),c(f(i._formValues,s))&&_(i._formValues,s,e)}return!d&&i.register(s),()=>{(d?e&&!i._state.action:e)?i.unregister(s):t(s,!1)}}),[s,i,d,l]),e.useEffect((()=>{i._setDisabledField({disabled:a,fields:i._fields,name:s})}),[a,s,i]),e.useMemo((()=>({field:V,formState:g,fieldState:h})),[V,g,h])}const P=e=>{const t={};for(const r of Object.keys(e))if(a(e[r])&&null!==e[r]){const s=P(e[r]);for(const e of Object.keys(s))t[`${r}.${e}`]=s[e]}else t[r]=e[r];return t},q="post";var W=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},$=e=>Array.isArray(e)?e:[e],I=()=>{let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}},H=e=>s(e)||!a(e);function J(e,t){if(H(e)||H(t))return e===t;if(r(e)&&r(t))return e.getTime()===t.getTime();const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;for(const n of s){const s=e[n];if(!a.includes(n))return!1;if("ref"!==n){const e=t[n];if(r(s)&&r(e)||i(s)&&i(e)||Array.isArray(s)&&Array.isArray(e)?!J(s,e):s!==e)return!1}}return!0}var z=e=>i(e)&&!Object.keys(e).length,G=e=>"file"===e.type,K=e=>"function"==typeof e,Q=e=>{if(!l)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},X=e=>"select-multiple"===e.type,Y=e=>"radio"===e.type,Z=e=>Q(e)&&e.isConnected;function ee(e,t){const r=Array.isArray(t)?t:y(t)?[t]:g(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=c(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,n=r[a];return s&&delete s[n],0!==a&&(i(s)&&z(s)||Array.isArray(s)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!c(e[t]))return!1;return!0}(s))&&ee(e,r.slice(0,-1)),e}var te=e=>{for(const t in e)if(K(e[t]))return!0;return!1};function re(e,t={}){const r=Array.isArray(e);if(i(e)||r)for(const r in e)Array.isArray(e[r])||i(e[r])&&!te(e[r])?(t[r]=Array.isArray(e[r])?[]:{},re(e[r],t[r])):s(e[r])||(t[r]=!0);return t}function se(e,t,r){const a=Array.isArray(e);if(i(e)||a)for(const a in e)Array.isArray(e[a])||i(e[a])&&!te(e[a])?c(t)||H(r[a])?r[a]=Array.isArray(e[a])?re(e[a],[]):{...re(e[a])}:se(e[a],s(t)?{}:t[a],r[a]):r[a]=!J(e[a],t[a]);return r}var ae=(e,t)=>se(e,t,re(t));const ie={value:!1,isValid:!1},ne={value:!0,isValid:!0};var oe=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!c(e[0].attributes.value)?c(e[0].value)||""===e[0].value?ne:{value:e[0].value,isValid:!0}:ne:ie}return ie},le=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>c(e)?e:t?""===e?NaN:e?+e:e:r&&U(e)?new Date(e):s?s(e):e;const ue={isValid:!1,value:null};var de=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),ue):ue;function ce(e){const r=e.ref;return G(r)?r.files:Y(r)?de(e.refs).value:X(r)?[...r.selectedOptions].map((({value:e})=>e)):t(r)?oe(e.refs).value:le(c(r.value)?e.ref.value:r.value,e)}var fe=e=>e instanceof RegExp,me=e=>c(e)?e:fe(e)?e.source:i(e)?fe(e.value)?e.value.source:e.value:e,ye=e=>({isOnSubmit:!e||e===x,isOnBlur:e===h,isOnChange:e===V,isOnAll:e===A,isOnTouch:e===F});const ge="AsyncFunction";var _e=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))));const be=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const r=f(e,a);if(r){const{_f:e,...n}=r;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],a)&&!s)return!0;if(e.ref&&t(e.ref,e.name)&&!s)return!0;if(be(n,t))break}else if(i(n)&&be(n,t))break}}};function pe(e,t,r){const s=f(e,r);if(s||y(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),i=f(t,s),n=f(e,s);if(i&&!Array.isArray(i)&&r!==s)return{name:r};if(n&&n.type)return{name:s,error:n};a.pop()}return{name:r}}var ve=(e,t,r)=>{const s=$(f(e,r));return _(s,"root",t[r]),_(e,r,s),e},he=e=>U(e);function Ve(e,t,r="validate"){if(he(e)||Array.isArray(e)&&e.every(he)||m(e)&&!e)return{type:r,message:he(e)?e:"",ref:t}}var xe=e=>i(e)&&!fe(e)?e:{value:e,message:""},Fe=async(e,r,a,n,o,l)=>{const{ref:u,refs:d,required:y,maxLength:g,minLength:_,min:b,max:p,pattern:v,validate:h,name:V,valueAsNumber:x,mount:F}=e._f,A=f(a,V);if(!F||r.has(V))return{};const j=d?d[0]:u,T=e=>{o&&j.reportValidity&&(j.setCustomValidity(m(e)?"":e||""),j.reportValidity())},N={},M=Y(u),B=t(u),L=M||B,R=(x||G(u))&&c(u.value)&&c(A)||Q(u)&&""===u.value||""===A||Array.isArray(A)&&!A.length,P=W.bind(null,V,n,N),q=(e,t,r,s=k,a=D)=>{const i=e?t:r;N[V]={type:e?s:a,message:i,ref:u,...P(e?s:a,i)}};if(l?!Array.isArray(A)||!A.length:y&&(!L&&(R||s(A))||m(A)&&!A||B&&!oe(d).isValid||M&&!de(d).isValid)){const{value:e,message:t}=he(y)?{value:!!y,message:y}:xe(y);if(e&&(N[V]={type:C,message:t,ref:j,...P(C,t)},!n))return T(t),N}if(!(R||s(b)&&s(p))){let e,t;const r=xe(p),a=xe(b);if(s(A)||isNaN(A)){const s=u.valueAsDate||new Date(A),i=e=>new Date((new Date).toDateString()+" "+e),n="time"==u.type,o="week"==u.type;U(r.value)&&A&&(e=n?i(A)>i(r.value):o?A>r.value:s>new Date(r.value)),U(a.value)&&A&&(t=n?i(A)<i(a.value):o?A<a.value:s<new Date(a.value))}else{const i=u.valueAsNumber||(A?+A:A);s(r.value)||(e=i>r.value),s(a.value)||(t=i<a.value)}if((e||t)&&(q(!!e,r.message,a.message,S,w),!n))return T(N[V].message),N}if((g||_)&&!R&&(U(A)||l&&Array.isArray(A))){const e=xe(g),t=xe(_),r=!s(e.value)&&A.length>+e.value,a=!s(t.value)&&A.length<+t.value;if((r||a)&&(q(r,e.message,t.message),!n))return T(N[V].message),N}if(v&&!R&&U(A)){const{value:e,message:t}=xe(v);if(fe(e)&&!A.match(e)&&(N[V]={type:E,message:t,ref:u,...P(E,t)},!n))return T(t),N}if(h)if(K(h)){const e=Ve(await h(A,a),j);if(e&&(N[V]={...e,...P(O,e.message)},!n))return T(e.message),N}else if(i(h)){let e={};for(const t in h){if(!z(e)&&!n)break;const r=Ve(await h[t](A,a),j,t);r&&(e={...r,...P(t,r.message)},T(r.message),n&&(N[V]=e))}if(!z(e)&&(N[V]={ref:j,...e},!n))return N}return T(!0),N};const Ae={mode:x,reValidateMode:V,shouldFocusError:!0};function Se(e={}){let a,y={...Ae,...e},g={submitCount:0,isDirty:!1,isLoading:K(y.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:y.errors||{},disabled:y.disabled||!1},v={},h=(i(y.defaultValues)||i(y.values))&&u(y.defaultValues||y.values)||{},V=y.shouldUnregister?{}:u(h),x={action:!1,mount:!1,watch:!1},F={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},S=0;const w={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let k={...w};const D={array:I(),state:I()},E=ye(y.mode),C=ye(y.reValidateMode),O=y.criteriaMode===A,j=async e=>{if(!y.disabled&&(w.isValid||k.isValid||e)){const e=y.resolver?z((await R()).errors):await P(v,!0);e!==g.isValid&&D.state.next({isValid:e})}},T=(e,t)=>{!y.disabled&&(w.isValidating||w.validatingFields||k.isValidating||k.validatingFields)&&((e||Array.from(F.mount)).forEach((e=>{e&&(t?_(g.validatingFields,e,t):ee(g.validatingFields,e))})),D.state.next({validatingFields:g.validatingFields,isValidating:!z(g.validatingFields)}))},N=(e,t,r,s)=>{const a=f(v,e);if(a){const i=f(V,e,c(r)?f(h,e):r);c(i)||s&&s.defaultChecked||t?_(V,e,t?i:ce(a._f)):H(e,i),x.mount&&j()}},M=(e,t,r,s,a)=>{let i=!1,n=!1;const o={name:e};if(!y.disabled){const l=!!(f(v,e)&&f(v,e)._f&&f(v,e)._f.disabled);if(!r||s){(w.isDirty||k.isDirty)&&(n=g.isDirty,g.isDirty=o.isDirty=q(),i=n!==o.isDirty);const r=l||J(f(h,e),t);n=!(l||!f(g.dirtyFields,e)),r||l?ee(g.dirtyFields,e):_(g.dirtyFields,e,!0),o.dirtyFields=g.dirtyFields,i=i||(w.dirtyFields||k.dirtyFields)&&n!==!r}if(r){const t=f(g.touchedFields,e);t||(_(g.touchedFields,e,r),o.touchedFields=g.touchedFields,i=i||(w.touchedFields||k.touchedFields)&&t!==r)}i&&a&&D.state.next(o)}return i?o:{}},L=(e,t,r,s)=>{const i=f(g.errors,e),n=(w.isValid||k.isValid)&&m(t)&&g.isValid!==t;var o;if(y.delayError&&r?(o=()=>((e,t)=>{_(g.errors,e,t),D.state.next({errors:g.errors})})(e,r),a=e=>{clearTimeout(S),S=setTimeout(o,e)},a(y.delayError)):(clearTimeout(S),a=null,r?_(g.errors,e,r):ee(g.errors,e)),(r?!J(i,r):i)||!z(s)||n){const r={...s,...n&&m(t)?{isValid:t}:{},errors:g.errors,name:e};g={...g,...r},D.state.next(r)}},R=async e=>{T(e,!0);const t=await y.resolver(V,y.context,((e,t,r,s)=>{const a={};for(const r of e){const e=f(t,r);e&&_(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||F.mount,v,y.criteriaMode,y.shouldUseNativeValidation));return T(e),t},P=async(e,t,r={valid:!0})=>{for(const a in e){const n=e[a];if(n){const{_f:e,...o}=n;if(e){const o=F.array.has(e.name),l=n._f&&(!!(s=n._f)&&!!s.validate&&!!(K(s.validate)&&s.validate.constructor.name===ge||i(s.validate)&&Object.values(s.validate).find((e=>e.constructor.name===ge))));l&&w.validatingFields&&T([a],!0);const u=await Fe(n,F.disabled,V,O,y.shouldUseNativeValidation&&!t,o);if(l&&w.validatingFields&&T([a]),u[e.name]&&(r.valid=!1,t))break;!t&&(f(u,e.name)?o?ve(g.errors,u,e.name):_(g.errors,e.name,u[e.name]):ee(g.errors,e.name))}!z(o)&&await P(o,t,r)}}var s;return r.valid},q=(e,t)=>!y.disabled&&(e&&t&&_(V,e,t),!J(oe(),h)),W=(e,t,r)=>B(e,F,{...x.mount?V:c(t)?h:U(e)?{[e]:t}:t},r,t),H=(e,r,a={})=>{const i=f(v,e);let n=r;if(i){const a=i._f;a&&(!a.disabled&&_(V,e,le(r,a)),n=Q(a.ref)&&s(r)?"":r,X(a.ref)?[...a.ref.options].forEach((e=>e.selected=n.includes(e.value))):a.refs?t(a.ref)?a.refs.length>1?a.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):a.refs[0]&&(a.refs[0].checked=!!n):a.refs.forEach((e=>e.checked=e.value===n)):G(a.ref)?a.ref.value="":(a.ref.value=n,a.ref.type||D.state.next({name:e,values:{...V}})))}(a.shouldDirty||a.shouldTouch)&&M(e,n,a.shouldTouch,a.shouldDirty,!0),a.shouldValidate&&ne(e)},te=(e,t,s)=>{for(const a in t){const n=t[a],o=`${e}.${a}`,l=f(v,o);(F.array.has(e)||i(n)||l&&!l._f)&&!r(n)?te(o,n,s):H(o,n,s)}},re=(e,t,r={})=>{const a=f(v,e),i=F.array.has(e),n=u(t);_(V,e,n),i?(D.array.next({name:e,values:{...V}}),(w.isDirty||w.dirtyFields||k.isDirty||k.dirtyFields)&&r.shouldDirty&&D.state.next({name:e,dirtyFields:ae(h,V),isDirty:q(e,n)})):!a||a._f||s(n)?H(e,n,r):te(e,n,r),_e(e,F)&&D.state.next({...g}),D.state.next({name:x.mount?e:void 0,values:{...V}})},se=async e=>{x.mount=!0;const t=e.target;let s=t.name,i=!0;const o=f(v,s),l=e=>{i=Number.isNaN(e)||r(e)&&isNaN(e.getTime())||J(e,f(V,s,e))};if(o){let r,d;const c=t.type?ce(o._f):n(e),m=e.type===b||e.type===p,h=!((u=o._f).mount&&(u.required||u.min||u.max||u.maxLength||u.minLength||u.pattern||u.validate)||y.resolver||f(g.errors,s)||o._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(m,f(g.touchedFields,s),g.isSubmitted,C,E),x=_e(s,F,m);_(V,s,c),m?(o._f.onBlur&&o._f.onBlur(e),a&&a(0)):o._f.onChange&&o._f.onChange(e);const A=M(s,c,m),S=!z(A)||x;if(!m&&D.state.next({name:s,type:e.type,values:{...V}}),h)return(w.isValid||k.isValid)&&("onBlur"===y.mode&&m?j():m||j()),S&&D.state.next({name:s,...x?{}:A});if(!m&&x&&D.state.next({...g}),y.resolver){const{errors:e}=await R([s]);if(l(c),i){const t=pe(g.errors,v,s),a=pe(e,v,t.name||s);r=a.error,s=a.name,d=z(e)}}else T([s],!0),r=(await Fe(o,F.disabled,V,O,y.shouldUseNativeValidation))[s],T([s]),l(c),i&&(r?d=!1:(w.isValid||k.isValid)&&(d=await P(v,!0)));i&&(o._f.deps&&ne(o._f.deps),L(s,d,r,A))}var u},ie=(e,t)=>{if(f(g.errors,t)&&e.focus)return e.focus(),1},ne=async(e,t={})=>{let r,s;const a=$(e);if(y.resolver){const t=await(async e=>{const{errors:t}=await R(e);if(e)for(const r of e){const e=f(t,r);e?_(g.errors,r,e):ee(g.errors,r)}else g.errors=t;return t})(c(e)?e:a);r=z(t),s=e?!a.some((e=>f(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=f(v,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||g.isValid)&&j()):s=r=await P(v);return D.state.next({...!U(e)||(w.isValid||k.isValid)&&r!==g.isValid?{}:{name:e},...y.resolver||!e?{isValid:r}:{},errors:g.errors}),t.shouldFocus&&!s&&be(v,ie,e?a:F.mount),s},oe=e=>{const t={...x.mount?V:h};return c(e)?t:U(e)?f(t,e):e.map((e=>f(t,e)))},ue=(e,t)=>({invalid:!!f((t||g).errors,e),isDirty:!!f((t||g).dirtyFields,e),error:f((t||g).errors,e),isValidating:!!f(g.validatingFields,e),isTouched:!!f((t||g).touchedFields,e)}),de=(e,t,r)=>{const s=(f(v,e,{_f:{}})._f||{}).ref,a=f(g.errors,e)||{},{ref:i,message:n,type:o,...l}=a;_(g.errors,e,{...l,...t,ref:s}),D.state.next({name:e,errors:g.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},fe=e=>D.state.subscribe({next:t=>{var r,s,a;r=e.name,s=t.name,a=e.exact,r&&s&&r!==s&&!$(r).some((e=>e&&(a?e===s:e.startsWith(s)||s.startsWith(e))))||!((e,t,r,s)=>{r(e);const{name:a,...i}=e;return z(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find((e=>t[e]===(!s||A)))})(t,e.formState||w,Ee,e.reRenderRoot)||e.callback({values:V,...g,...t})}}).unsubscribe,he=(e,t={})=>{for(const r of e?$(e):F.mount)F.mount.delete(r),F.array.delete(r),t.keepValue||(ee(v,r),ee(V,r)),!t.keepError&&ee(g.errors,r),!t.keepDirty&&ee(g.dirtyFields,r),!t.keepTouched&&ee(g.touchedFields,r),!t.keepIsValidating&&ee(g.validatingFields,r),!y.shouldUnregister&&!t.keepDefaultValue&&ee(h,r);D.state.next({values:{...V}}),D.state.next({...g,...t.keepDirty?{isDirty:q()}:{}}),!t.keepIsValid&&j()},Ve=({disabled:e,name:t,field:r,fields:s})=>{(m(e)&&x.mount||e||F.disabled.has(t))&&(e?F.disabled.add(t):F.disabled.delete(t),M(t,ce(r?r._f:f(s,t)._f),!1,!1,!0))},xe=(e,r={})=>{let s=f(v,e);const a=m(r.disabled)||m(y.disabled);return _(v,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...r}}),F.mount.add(e),s?Ve({field:s,disabled:m(r.disabled)?r.disabled:y.disabled,name:e}):N(e,!0,r.value),{...a?{disabled:r.disabled||y.disabled}:{},...y.progressive?{required:!!r.required,min:me(r.min),max:me(r.max),minLength:me(r.minLength),maxLength:me(r.maxLength),pattern:me(r.pattern)}:{},name:e,onChange:se,onBlur:se,ref:a=>{if(a){xe(e,r),s=f(v,e);const i=c(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,n=(e=>Y(e)||t(e))(i),o=s._f.refs||[];if(n?o.find((e=>e===i)):i===s._f.ref)return;_(v,e,{_f:{...s._f,...n?{refs:[...o.filter(Z),i,...Array.isArray(f(h,e))?[{}]:[]],ref:{type:i.type,name:e}}:{ref:i}}}),N(e,!1,void 0,i)}else s=f(v,e,{}),s._f&&(s._f.mount=!1),(y.shouldUnregister||r.shouldUnregister)&&(!o(F.array,e)||!x.action)&&F.unMount.add(e)}}},Se=()=>y.shouldFocusError&&be(v,ie,F.mount),we=(e,t)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=u(V);if(F.disabled.size)for(const e of F.disabled)_(a,e,void 0);if(D.state.next({isSubmitting:!0}),y.resolver){const{errors:e,values:t}=await R();g.errors=e,a=t}else await P(v);if(ee(g.errors,"root"),z(g.errors)){D.state.next({errors:{}});try{await e(a,r)}catch(e){s=e}}else t&&await t({...g.errors},r),Se(),setTimeout(Se);if(D.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:z(g.errors)&&!s,submitCount:g.submitCount+1,errors:g.errors}),s)throw s},ke=(e,t={})=>{const r=e?u(e):h,s=u(r),a=z(e),i=a?h:s;if(t.keepDefaultValues||(h=r),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...F.mount,...Object.keys(ae(h,V))]);for(const t of Array.from(e))f(g.dirtyFields,t)?_(i,t,f(V,t)):re(t,f(i,t))}else{if(l&&c(e))for(const e of F.mount){const t=f(v,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(Q(e)){const t=e.closest("form");if(t){t.reset();break}}}}v={}}V=y.shouldUnregister?t.keepDefaultValues?u(h):{}:u(i),D.array.next({values:{...i}}),D.state.next({values:{...i}})}F={mount:t.keepDirtyValues?F.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},x.mount=!w.isValid||!!t.keepIsValid||!!t.keepDirtyValues,x.watch=!!y.shouldUnregister,D.state.next({submitCount:t.keepSubmitCount?g.submitCount:0,isDirty:!a&&(t.keepDirty?g.isDirty:!(!t.keepDefaultValues||J(e,h))),isSubmitted:!!t.keepIsSubmitted&&g.isSubmitted,dirtyFields:a?{}:t.keepDirtyValues?t.keepDefaultValues&&V?ae(h,V):g.dirtyFields:t.keepDefaultValues&&e?ae(h,e):t.keepDirty?g.dirtyFields:{},touchedFields:t.keepTouched?g.touchedFields:{},errors:t.keepErrors?g.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&g.isSubmitSuccessful,isSubmitting:!1})},De=(e,t)=>ke(K(e)?e(V):e,t),Ee=e=>{g={...g,...e}},Ce={control:{register:xe,unregister:he,getFieldState:ue,handleSubmit:we,setError:de,_subscribe:fe,_runSchema:R,_getWatch:W,_getDirty:q,_setValid:j,_setFieldArray:(e,t=[],r,s,a=!0,i=!0)=>{if(s&&r&&!y.disabled){if(x.action=!0,i&&Array.isArray(f(v,e))){const t=r(f(v,e),s.argA,s.argB);a&&_(v,e,t)}if(i&&Array.isArray(f(g.errors,e))){const t=r(f(g.errors,e),s.argA,s.argB);a&&_(g.errors,e,t),((e,t)=>{!d(f(e,t)).length&&ee(e,t)})(g.errors,e)}if((w.touchedFields||k.touchedFields)&&i&&Array.isArray(f(g.touchedFields,e))){const t=r(f(g.touchedFields,e),s.argA,s.argB);a&&_(g.touchedFields,e,t)}(w.dirtyFields||k.dirtyFields)&&(g.dirtyFields=ae(h,V)),D.state.next({name:e,isDirty:q(e,t),dirtyFields:g.dirtyFields,errors:g.errors,isValid:g.isValid})}else _(V,e,t)},_setDisabledField:Ve,_setErrors:e=>{g.errors=e,D.state.next({errors:g.errors,isValid:!1})},_getFieldArray:e=>d(f(x.mount?V:h,e,y.shouldUnregister?f(h,e,[]):[])),_reset:ke,_resetDefaultValues:()=>K(y.defaultValues)&&y.defaultValues().then((e=>{De(e,y.resetOptions),D.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of F.unMount){const t=f(v,e);t&&(t._f.refs?t._f.refs.every((e=>!Z(e))):!Z(t._f.ref))&&he(e)}F.unMount=new Set},_disableForm:e=>{m(e)&&(D.state.next({disabled:e}),be(v,((t,r)=>{const s=f(v,r);s&&(t.disabled=s._f.disabled||e,Array.isArray(s._f.refs)&&s._f.refs.forEach((t=>{t.disabled=s._f.disabled||e})))}),0,!1))},_subjects:D,_proxyFormState:w,get _fields(){return v},get _formValues(){return V},get _state(){return x},set _state(e){x=e},get _defaultValues(){return h},get _names(){return F},set _names(e){F=e},get _formState(){return g},get _options(){return y},set _options(e){y={...y,...e}}},subscribe:e=>(x.mount=!0,k={...k,...e.formState},fe({...e,formState:k})),trigger:ne,register:xe,handleSubmit:we,watch:(e,t)=>K(e)?D.state.subscribe({next:r=>e(W(void 0,t),r)}):W(e,t,!0),setValue:re,getValues:oe,reset:De,resetField:(e,t={})=>{f(v,e)&&(c(t.defaultValue)?re(e,u(f(h,e))):(re(e,t.defaultValue),_(h,e,u(t.defaultValue))),t.keepTouched||ee(g.touchedFields,e),t.keepDirty||(ee(g.dirtyFields,e),g.isDirty=t.defaultValue?q(e,u(f(h,e))):q()),t.keepError||(ee(g.errors,e),w.isValid&&j()),D.state.next({...g}))},clearErrors:e=>{e&&$(e).forEach((e=>ee(g.errors,e))),D.state.next({errors:e?g.errors:{}})},unregister:he,setError:de,setFocus:(e,t={})=>{const r=f(v,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&K(e.select)&&e.select())}},getFieldState:ue};return{...Ce,formControl:Ce}}var we=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},ke=(e,t,r={})=>r.shouldFocus||c(r.shouldFocus)?r.focusName||`${e}.${c(r.focusIndex)?t:r.focusIndex}.`:"",De=(e,t)=>[...e,...$(t)],Ee=e=>Array.isArray(e)?e.map((()=>{})):void 0;function Ce(e,t,r){return[...e.slice(0,t),...$(r),...e.slice(t)]}var Oe=(e,t,r)=>Array.isArray(e)?(c(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],je=(e,t)=>[...$(t),...$(e)];var Te=(e,t)=>c(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return d(s).length?s:[]}(e,$(t).sort(((e,t)=>e-t))),Ne=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},Me=(e,t,r)=>(e[t]=r,e);exports.Controller=e=>e.render(R(e)),exports.Form=function(t){const r=T(),[s,a]=e.useState(!1),{control:i=r.control,onSubmit:n,children:o,action:l,method:u=q,headers:d,encType:c,onError:f,render:m,onSuccess:y,validateStatus:g,..._}=t,b=async e=>{let r=!1,s="";await i.handleSubmit((async t=>{const a=new FormData;let o="";try{o=JSON.stringify(t)}catch(e){}const m=P(i._formValues);for(const e in m)a.append(e,m[e]);if(n&&await n({data:t,event:e,method:u,formData:a,formDataJson:o}),l)try{const e=[d&&d["Content-Type"],c].some((e=>e&&e.includes("json"))),t=await fetch(String(l),{method:u,headers:{...d,...c?{"Content-Type":c}:{}},body:e?o:a});t&&(g?!g(t.status):t.status<200||t.status>=300)?(r=!0,f&&f({response:t}),s=String(t.status)):y&&y({response:t})}catch(e){r=!0,f&&f({error:e})}}))(e),r&&t.control&&(t.control._subjects.state.next({isSubmitSuccessful:!1}),t.control.setError("root.server",{type:s}))};return e.useEffect((()=>{a(!0)}),[]),m?e.createElement(e.Fragment,null,m({submit:b})):e.createElement("form",{noValidate:s,action:l,method:u,encType:c,onSubmit:b,..._},o)},exports.FormProvider=t=>{const{children:r,...s}=t;return e.createElement(j.Provider,{value:s},r)},exports.appendErrors=W,exports.createFormControl=Se,exports.get=f,exports.set=_,exports.useController=R,exports.useFieldArray=function(t){const r=T(),{control:s=r.control,name:a,keyName:i="id",shouldUnregister:n,rules:o}=t,[l,d]=e.useState(s._getFieldArray(a)),c=e.useRef(s._getFieldArray(a).map(we)),m=e.useRef(l),y=e.useRef(a),g=e.useRef(!1);y.current=a,m.current=l,s._names.array.add(a),o&&s.register(a,o),e.useEffect((()=>s._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===y.current||!t){const t=f(e,y.current);Array.isArray(t)&&(d(t),c.current=t.map(we))}}}).unsubscribe),[s]);const b=e.useCallback((e=>{g.current=!0,s._setFieldArray(a,e)}),[s,a]);return e.useEffect((()=>{if(s._state.action=!1,_e(a,s._names)&&s._subjects.state.next({...s._formState}),g.current&&(!ye(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._runSchema([a]).then((e=>{const t=f(e.errors,a),r=f(s._formState.errors,a);(r?!t&&r.type||t&&(r.type!==t.type||r.message!==t.message):t&&t.type)&&(t?_(s._formState.errors,a,t):ee(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=f(s._fields,a);!e||!e._f||ye(s._options.reValidateMode).isOnSubmit&&ye(s._options.mode).isOnSubmit||Fe(e,s._names.disabled,s._formValues,s._options.criteriaMode===A,s._options.shouldUseNativeValidation,!0).then((e=>!z(e)&&s._subjects.state.next({errors:ve(s._formState.errors,e,a)})))}s._subjects.state.next({name:a,values:{...s._formValues}}),s._names.focus&&be(s._fields,((e,t)=>{if(s._names.focus&&t.startsWith(s._names.focus)&&e.focus)return e.focus(),1})),s._names.focus="",s._setValid(),g.current=!1}),[l,a,s]),e.useEffect((()=>(!f(s._formValues,a)&&s._setFieldArray(a),()=>{(s._options.shouldUnregister||n)&&s.unregister(a)})),[a,s,i,n]),{swap:e.useCallback(((e,t)=>{const r=s._getFieldArray(a);Ne(r,e,t),Ne(c.current,e,t),b(r),d(r),s._setFieldArray(a,r,Ne,{argA:e,argB:t},!1)}),[b,a,s]),move:e.useCallback(((e,t)=>{const r=s._getFieldArray(a);Oe(r,e,t),Oe(c.current,e,t),b(r),d(r),s._setFieldArray(a,r,Oe,{argA:e,argB:t},!1)}),[b,a,s]),prepend:e.useCallback(((e,t)=>{const r=$(u(e)),i=je(s._getFieldArray(a),r);s._names.focus=ke(a,0,t),c.current=je(c.current,r.map(we)),b(i),d(i),s._setFieldArray(a,i,je,{argA:Ee(e)})}),[b,a,s]),append:e.useCallback(((e,t)=>{const r=$(u(e)),i=De(s._getFieldArray(a),r);s._names.focus=ke(a,i.length-1,t),c.current=De(c.current,r.map(we)),b(i),d(i),s._setFieldArray(a,i,De,{argA:Ee(e)})}),[b,a,s]),remove:e.useCallback((e=>{const t=Te(s._getFieldArray(a),e);c.current=Te(c.current,e),b(t),d(t),!Array.isArray(f(s._fields,a))&&_(s._fields,a,void 0),s._setFieldArray(a,t,Te,{argA:e})}),[b,a,s]),insert:e.useCallback(((e,t,r)=>{const i=$(u(t)),n=Ce(s._getFieldArray(a),e,i);s._names.focus=ke(a,e,r),c.current=Ce(c.current,e,i.map(we)),b(n),d(n),s._setFieldArray(a,n,Ce,{argA:e,argB:Ee(t)})}),[b,a,s]),update:e.useCallback(((e,t)=>{const r=u(t),i=Me(s._getFieldArray(a),e,r);c.current=[...i].map(((t,r)=>t&&r!==e?c.current[r]:we())),b(i),d([...i]),s._setFieldArray(a,i,Me,{argA:e,argB:r},!0,!1)}),[b,a,s]),replace:e.useCallback((e=>{const t=$(u(e));c.current=t.map(we),b([...t]),d([...t]),s._setFieldArray(a,[...t],(e=>e),{},!0,!1)}),[b,a,s]),fields:e.useMemo((()=>l.map(((e,t)=>({...e,[i]:c.current[t]||we()})))),[l,i])}},exports.useForm=function(t={}){const r=e.useRef(void 0),s=e.useRef(void 0),[a,i]=e.useState({isDirty:!1,isValidating:!1,isLoading:K(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,defaultValues:K(t.defaultValues)?void 0:t.defaultValues});r.current||(r.current={...t.formControl?t.formControl:Se(t),formState:a});const n=r.current.control;return n._options=t,e.useEffect((()=>n._subscribe({formState:n._proxyFormState,callback:()=>i({...n._formState}),reRenderRoot:!0})),[n]),e.useEffect((()=>n._disableForm(t.disabled)),[n,t.disabled]),e.useEffect((()=>{if(n._proxyFormState.isDirty){const e=n._getDirty();e!==a.isDirty&&n._subjects.state.next({isDirty:e})}}),[n,a.isDirty]),e.useEffect((()=>{t.values&&!J(t.values,s.current)?(n._reset(t.values,n._options.resetOptions),s.current=t.values,i((e=>({...e})))):n._resetDefaultValues()}),[t.values,n]),e.useEffect((()=>{t.errors&&n._setErrors(t.errors)}),[t.errors,n]),e.useEffect((()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),e.useEffect((()=>{t.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})}),[t.shouldUnregister,n]),r.current.formState=N(a,n),r.current},exports.useFormContext=T,exports.useFormState=M,exports.useWatch=L; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactHookForm={},e.React)}(this,(function(e,t){"use strict";var r=e=>"checkbox"===e.type,s=e=>e instanceof Date,a=e=>null==e;const i=e=>"object"==typeof e;var n=e=>!a(e)&&!Array.isArray(e)&&i(e)&&!s(e),o=e=>n(e)&&e.target?r(e.target)?e.target.checked:e.target.value:e,l=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),u="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function d(e){let t;const r=Array.isArray(e),s="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(u&&(e instanceof Blob||s)||!r&&!n(e))return e;if(t=r?[]:{},r||(e=>{const t=e.constructor&&e.constructor.prototype;return n(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)e.hasOwnProperty(r)&&(t[r]=d(e[r]));else t=e}return t}var c=e=>Array.isArray(e)?e.filter(Boolean):[],f=e=>void 0===e,m=(e,t,r)=>{if(!t||!n(e))return r;const s=c(t.split(/[,[\].]+?/)).reduce(((e,t)=>a(e)?e:e[t]),e);return f(s)||s===e?f(e[t])?r:e[t]:s},y=e=>"boolean"==typeof e,g=e=>/^\w*$/.test(e),_=e=>c(e.replace(/["|']|\]/g,"").split(/\.|\[/)),b=(e,t,r)=>{let s=-1;const a=g(t)?[t]:_(t),i=a.length,o=i-1;for(;++s<i;){const t=a[s];let i=r;if(s!==o){const r=e[t];i=n(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=i,e=e[t]}return e};const h="blur",v="focusout",p="change",V="onBlur",F="onChange",A="onSubmit",x="onTouched",S="all",w="max",k="min",D="maxLength",E="minLength",C="pattern",O="required",j="validate",T=t.createContext(null),N=()=>t.useContext(T);var M=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const a=i;return t._proxyFormState[a]!==S&&(t._proxyFormState[a]=!s||S),r&&(r[a]=!0),e[a]}});return a};function U(e){const r=N(),{control:s=r.control,disabled:a,name:i,exact:n}=e||{},[o,l]=t.useState(s._formState),u=t.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=t.useRef(i);return d.current=i,t.useEffect((()=>s._subscribe({name:d.current,formState:u.current,exact:n,callback:e=>{!a&&l({...s._formState,...e})}})),[s,a,n]),t.useEffect((()=>{u.current.isValid&&s._setValid(!0)}),[s]),t.useMemo((()=>M(o,s,u.current,!1)),[o,s])}var B=e=>"string"==typeof e,L=(e,t,r,s,a)=>B(e)?(s&&t.watch.add(e),m(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),m(r,e)))):(s&&(t.watchAll=!0),r);function R(e){const r=N(),{control:s=r.control,name:a,defaultValue:i,disabled:n,exact:o}=e||{},l=t.useRef(a);l.current=a,t.useEffect((()=>s._subscribe({name:l.current,formState:{values:!0},exact:o,callback:e=>!n&&c(d(L(l.current,s._names,e.values||s._formValues,!1,i)))})),[s,i,n,o]);const[u,c]=t.useState(s._getWatch(a,i));return t.useEffect((()=>s._removeUnmounted())),u}function P(e){const r=N(),{name:s,disabled:a,control:i=r.control,shouldUnregister:n}=e,u=l(i._names.array,s),c=R({control:i,name:s,defaultValue:m(i._formValues,s,m(i._defaultValues,s,e.defaultValue)),exact:!0}),g=U({control:i,name:s,exact:!0}),_=t.useRef(i.register(s,{...e.rules,value:c,...y(e.disabled)?{disabled:e.disabled}:{}})),v=t.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!m(g.errors,s)},isDirty:{enumerable:!0,get:()=>!!m(g.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!m(g.touchedFields,s)},isValidating:{enumerable:!0,get:()=>!!m(g.validatingFields,s)},error:{enumerable:!0,get:()=>m(g.errors,s)}})),[g,s]),V=t.useMemo((()=>({name:s,value:c,...y(a)||g.disabled?{disabled:g.disabled||a}:{},onChange:e=>_.current.onChange({target:{value:o(e),name:s},type:p}),onBlur:()=>_.current.onBlur({target:{value:m(i._formValues,s),name:s},type:h}),ref:e=>{const t=m(i._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}})),[s,i._formValues,a,g.disabled,c,i._fields]);return t.useEffect((()=>{const e=i._options.shouldUnregister||n,t=(e,t)=>{const r=m(i._fields,e);r&&r._f&&(r._f.mount=t)};if(t(s,!0),e){const e=d(m(i._options.defaultValues,s));b(i._defaultValues,s,e),f(m(i._formValues,s))&&b(i._formValues,s,e)}return!u&&i.register(s),()=>{(u?e&&!i._state.action:e)?i.unregister(s):t(s,!1)}}),[s,i,u,n]),t.useEffect((()=>{i._setDisabledField({disabled:a,fields:i._fields,name:s})}),[a,s,i]),t.useMemo((()=>({field:V,formState:g,fieldState:v})),[V,g,v])}const q=e=>{const t={};for(const r of Object.keys(e))if(i(e[r])&&null!==e[r]){const s=q(e[r]);for(const e of Object.keys(s))t[`${r}.${e}`]=s[e]}else t[r]=e[r];return t},W="post";var $=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},I=e=>Array.isArray(e)?e:[e],H=()=>{let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}},J=e=>a(e)||!i(e);function z(e,t){if(J(e)||J(t))return e===t;if(s(e)&&s(t))return e.getTime()===t.getTime();const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const i of r){const r=e[i];if(!a.includes(i))return!1;if("ref"!==i){const e=t[i];if(s(r)&&s(e)||n(r)&&n(e)||Array.isArray(r)&&Array.isArray(e)?!z(r,e):r!==e)return!1}}return!0}var G=e=>n(e)&&!Object.keys(e).length,K=e=>"file"===e.type,Q=e=>"function"==typeof e,X=e=>{if(!u)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Y=e=>"select-multiple"===e.type,Z=e=>"radio"===e.type,ee=e=>X(e)&&e.isConnected;function te(e,t){const r=Array.isArray(t)?t:g(t)?[t]:_(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=f(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,i=r[a];return s&&delete s[i],0!==a&&(n(s)&&G(s)||Array.isArray(s)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!f(e[t]))return!1;return!0}(s))&&te(e,r.slice(0,-1)),e}var re=e=>{for(const t in e)if(Q(e[t]))return!0;return!1};function se(e,t={}){const r=Array.isArray(e);if(n(e)||r)for(const r in e)Array.isArray(e[r])||n(e[r])&&!re(e[r])?(t[r]=Array.isArray(e[r])?[]:{},se(e[r],t[r])):a(e[r])||(t[r]=!0);return t}function ae(e,t,r){const s=Array.isArray(e);if(n(e)||s)for(const s in e)Array.isArray(e[s])||n(e[s])&&!re(e[s])?f(t)||J(r[s])?r[s]=Array.isArray(e[s])?se(e[s],[]):{...se(e[s])}:ae(e[s],a(t)?{}:t[s],r[s]):r[s]=!z(e[s],t[s]);return r}var ie=(e,t)=>ae(e,t,se(t));const ne={value:!1,isValid:!1},oe={value:!0,isValid:!0};var le=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!f(e[0].attributes.value)?f(e[0].value)||""===e[0].value?oe:{value:e[0].value,isValid:!0}:oe:ne}return ne},ue=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>f(e)?e:t?""===e?NaN:e?+e:e:r&&B(e)?new Date(e):s?s(e):e;const de={isValid:!1,value:null};var ce=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),de):de;function fe(e){const t=e.ref;return K(t)?t.files:Z(t)?ce(e.refs).value:Y(t)?[...t.selectedOptions].map((({value:e})=>e)):r(t)?le(e.refs).value:ue(f(t.value)?e.ref.value:t.value,e)}var me=e=>e instanceof RegExp,ye=e=>f(e)?e:me(e)?e.source:n(e)?me(e.value)?e.value.source:e.value:e,ge=e=>({isOnSubmit:!e||e===A,isOnBlur:e===V,isOnChange:e===F,isOnAll:e===S,isOnTouch:e===x});const _e="AsyncFunction";var be=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))));const he=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const r=m(e,a);if(r){const{_f:e,...i}=r;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],a)&&!s)return!0;if(e.ref&&t(e.ref,e.name)&&!s)return!0;if(he(i,t))break}else if(n(i)&&he(i,t))break}}};function ve(e,t,r){const s=m(e,r);if(s||g(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),i=m(t,s),n=m(e,s);if(i&&!Array.isArray(i)&&r!==s)return{name:r};if(n&&n.type)return{name:s,error:n};a.pop()}return{name:r}}var pe=(e,t,r)=>{const s=I(m(e,r));return b(s,"root",t[r]),b(e,r,s),e},Ve=e=>B(e);function Fe(e,t,r="validate"){if(Ve(e)||Array.isArray(e)&&e.every(Ve)||y(e)&&!e)return{type:r,message:Ve(e)?e:"",ref:t}}var Ae=e=>n(e)&&!me(e)?e:{value:e,message:""},xe=async(e,t,s,i,o,l)=>{const{ref:u,refs:d,required:c,maxLength:g,minLength:_,min:b,max:h,pattern:v,validate:p,name:V,valueAsNumber:F,mount:A}=e._f,x=m(s,V);if(!A||t.has(V))return{};const S=d?d[0]:u,T=e=>{o&&S.reportValidity&&(S.setCustomValidity(y(e)?"":e||""),S.reportValidity())},N={},M=Z(u),U=r(u),L=M||U,R=(F||K(u))&&f(u.value)&&f(x)||X(u)&&""===u.value||""===x||Array.isArray(x)&&!x.length,P=$.bind(null,V,i,N),q=(e,t,r,s=D,a=E)=>{const i=e?t:r;N[V]={type:e?s:a,message:i,ref:u,...P(e?s:a,i)}};if(l?!Array.isArray(x)||!x.length:c&&(!L&&(R||a(x))||y(x)&&!x||U&&!le(d).isValid||M&&!ce(d).isValid)){const{value:e,message:t}=Ve(c)?{value:!!c,message:c}:Ae(c);if(e&&(N[V]={type:O,message:t,ref:S,...P(O,t)},!i))return T(t),N}if(!(R||a(b)&&a(h))){let e,t;const r=Ae(h),s=Ae(b);if(a(x)||isNaN(x)){const a=u.valueAsDate||new Date(x),i=e=>new Date((new Date).toDateString()+" "+e),n="time"==u.type,o="week"==u.type;B(r.value)&&x&&(e=n?i(x)>i(r.value):o?x>r.value:a>new Date(r.value)),B(s.value)&&x&&(t=n?i(x)<i(s.value):o?x<s.value:a<new Date(s.value))}else{const i=u.valueAsNumber||(x?+x:x);a(r.value)||(e=i>r.value),a(s.value)||(t=i<s.value)}if((e||t)&&(q(!!e,r.message,s.message,w,k),!i))return T(N[V].message),N}if((g||_)&&!R&&(B(x)||l&&Array.isArray(x))){const e=Ae(g),t=Ae(_),r=!a(e.value)&&x.length>+e.value,s=!a(t.value)&&x.length<+t.value;if((r||s)&&(q(r,e.message,t.message),!i))return T(N[V].message),N}if(v&&!R&&B(x)){const{value:e,message:t}=Ae(v);if(me(e)&&!x.match(e)&&(N[V]={type:C,message:t,ref:u,...P(C,t)},!i))return T(t),N}if(p)if(Q(p)){const e=Fe(await p(x,s),S);if(e&&(N[V]={...e,...P(j,e.message)},!i))return T(e.message),N}else if(n(p)){let e={};for(const t in p){if(!G(e)&&!i)break;const r=Fe(await p[t](x,s),S,t);r&&(e={...r,...P(t,r.message)},T(r.message),i&&(N[V]=e))}if(!G(e)&&(N[V]={ref:S,...e},!i))return N}return T(!0),N};const Se={mode:A,reValidateMode:F,shouldFocusError:!0};function we(e={}){let t,i={...Se,...e},g={submitCount:0,isDirty:!1,isLoading:Q(i.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:i.errors||{},disabled:i.disabled||!1},_={},p=(n(i.defaultValues)||n(i.values))&&d(i.defaultValues||i.values)||{},V=i.shouldUnregister?{}:d(p),F={action:!1,mount:!1,watch:!1},A={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},x=0;const w={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let k={...w};const D={array:H(),state:H()},E=ge(i.mode),C=ge(i.reValidateMode),O=i.criteriaMode===S,j=async e=>{if(!i.disabled&&(w.isValid||k.isValid||e)){const e=i.resolver?G((await R()).errors):await P(_,!0);e!==g.isValid&&D.state.next({isValid:e})}},T=(e,t)=>{!i.disabled&&(w.isValidating||w.validatingFields||k.isValidating||k.validatingFields)&&((e||Array.from(A.mount)).forEach((e=>{e&&(t?b(g.validatingFields,e,t):te(g.validatingFields,e))})),D.state.next({validatingFields:g.validatingFields,isValidating:!G(g.validatingFields)}))},N=(e,t,r,s)=>{const a=m(_,e);if(a){const i=m(V,e,f(r)?m(p,e):r);f(i)||s&&s.defaultChecked||t?b(V,e,t?i:fe(a._f)):$(e,i),F.mount&&j()}},M=(e,t,r,s,a)=>{let n=!1,o=!1;const l={name:e};if(!i.disabled){const i=!!(m(_,e)&&m(_,e)._f&&m(_,e)._f.disabled);if(!r||s){(w.isDirty||k.isDirty)&&(o=g.isDirty,g.isDirty=l.isDirty=q(),n=o!==l.isDirty);const r=i||z(m(p,e),t);o=!(i||!m(g.dirtyFields,e)),r||i?te(g.dirtyFields,e):b(g.dirtyFields,e,!0),l.dirtyFields=g.dirtyFields,n=n||(w.dirtyFields||k.dirtyFields)&&o!==!r}if(r){const t=m(g.touchedFields,e);t||(b(g.touchedFields,e,r),l.touchedFields=g.touchedFields,n=n||(w.touchedFields||k.touchedFields)&&t!==r)}n&&a&&D.state.next(l)}return n?l:{}},U=(e,r,s,a)=>{const n=m(g.errors,e),o=(w.isValid||k.isValid)&&y(r)&&g.isValid!==r;var l;if(i.delayError&&s?(l=()=>((e,t)=>{b(g.errors,e,t),D.state.next({errors:g.errors})})(e,s),t=e=>{clearTimeout(x),x=setTimeout(l,e)},t(i.delayError)):(clearTimeout(x),t=null,s?b(g.errors,e,s):te(g.errors,e)),(s?!z(n,s):n)||!G(a)||o){const t={...a,...o&&y(r)?{isValid:r}:{},errors:g.errors,name:e};g={...g,...t},D.state.next(t)}},R=async e=>{T(e,!0);const t=await i.resolver(V,i.context,((e,t,r,s)=>{const a={};for(const r of e){const e=m(t,r);e&&b(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||A.mount,_,i.criteriaMode,i.shouldUseNativeValidation));return T(e),t},P=async(e,t,r={valid:!0})=>{for(const a in e){const o=e[a];if(o){const{_f:e,...l}=o;if(e){const l=A.array.has(e.name),u=o._f&&(!!(s=o._f)&&!!s.validate&&!!(Q(s.validate)&&s.validate.constructor.name===_e||n(s.validate)&&Object.values(s.validate).find((e=>e.constructor.name===_e))));u&&w.validatingFields&&T([a],!0);const d=await xe(o,A.disabled,V,O,i.shouldUseNativeValidation&&!t,l);if(u&&w.validatingFields&&T([a]),d[e.name]&&(r.valid=!1,t))break;!t&&(m(d,e.name)?l?pe(g.errors,d,e.name):b(g.errors,e.name,d[e.name]):te(g.errors,e.name))}!G(l)&&await P(l,t,r)}}var s;return r.valid},q=(e,t)=>!i.disabled&&(e&&t&&b(V,e,t),!z(oe(),p)),W=(e,t,r)=>L(e,A,{...F.mount?V:f(t)?p:B(e)?{[e]:t}:t},r,t),$=(e,t,s={})=>{const i=m(_,e);let n=t;if(i){const s=i._f;s&&(!s.disabled&&b(V,e,ue(t,s)),n=X(s.ref)&&a(t)?"":t,Y(s.ref)?[...s.ref.options].forEach((e=>e.selected=n.includes(e.value))):s.refs?r(s.ref)?s.refs.length>1?s.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):s.refs[0]&&(s.refs[0].checked=!!n):s.refs.forEach((e=>e.checked=e.value===n)):K(s.ref)?s.ref.value="":(s.ref.value=n,s.ref.type||D.state.next({name:e,values:{...V}})))}(s.shouldDirty||s.shouldTouch)&&M(e,n,s.shouldTouch,s.shouldDirty,!0),s.shouldValidate&&ne(e)},J=(e,t,r)=>{for(const a in t){const i=t[a],o=`${e}.${a}`,l=m(_,o);(A.array.has(e)||n(i)||l&&!l._f)&&!s(i)?J(o,i,r):$(o,i,r)}},re=(e,t,r={})=>{const s=m(_,e),i=A.array.has(e),n=d(t);b(V,e,n),i?(D.array.next({name:e,values:{...V}}),(w.isDirty||w.dirtyFields||k.isDirty||k.dirtyFields)&&r.shouldDirty&&D.state.next({name:e,dirtyFields:ie(p,V),isDirty:q(e,n)})):!s||s._f||a(n)?$(e,n,r):J(e,n,r),be(e,A)&&D.state.next({...g}),D.state.next({name:F.mount?e:void 0,values:{...V}})},se=async e=>{F.mount=!0;const r=e.target;let a=r.name,n=!0;const l=m(_,a),u=e=>{n=Number.isNaN(e)||s(e)&&isNaN(e.getTime())||z(e,m(V,a,e))};if(l){let s,c;const f=r.type?fe(l._f):o(e),y=e.type===h||e.type===v,p=!((d=l._f).mount&&(d.required||d.min||d.max||d.maxLength||d.minLength||d.pattern||d.validate)||i.resolver||m(g.errors,a)||l._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(y,m(g.touchedFields,a),g.isSubmitted,C,E),F=be(a,A,y);b(V,a,f),y?(l._f.onBlur&&l._f.onBlur(e),t&&t(0)):l._f.onChange&&l._f.onChange(e);const x=M(a,f,y),S=!G(x)||F;if(!y&&D.state.next({name:a,type:e.type,values:{...V}}),p)return(w.isValid||k.isValid)&&("onBlur"===i.mode&&y?j():y||j()),S&&D.state.next({name:a,...F?{}:x});if(!y&&F&&D.state.next({...g}),i.resolver){const{errors:e}=await R([a]);if(u(f),n){const t=ve(g.errors,_,a),r=ve(e,_,t.name||a);s=r.error,a=r.name,c=G(e)}}else T([a],!0),s=(await xe(l,A.disabled,V,O,i.shouldUseNativeValidation))[a],T([a]),u(f),n&&(s?c=!1:(w.isValid||k.isValid)&&(c=await P(_,!0)));n&&(l._f.deps&&ne(l._f.deps),U(a,c,s,x))}var d},ae=(e,t)=>{if(m(g.errors,t)&&e.focus)return e.focus(),1},ne=async(e,t={})=>{let r,s;const a=I(e);if(i.resolver){const t=await(async e=>{const{errors:t}=await R(e);if(e)for(const r of e){const e=m(t,r);e?b(g.errors,r,e):te(g.errors,r)}else g.errors=t;return t})(f(e)?e:a);r=G(t),s=e?!a.some((e=>m(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=m(_,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||g.isValid)&&j()):s=r=await P(_);return D.state.next({...!B(e)||(w.isValid||k.isValid)&&r!==g.isValid?{}:{name:e},...i.resolver||!e?{isValid:r}:{},errors:g.errors}),t.shouldFocus&&!s&&he(_,ae,e?a:A.mount),s},oe=e=>{const t={...F.mount?V:p};return f(e)?t:B(e)?m(t,e):e.map((e=>m(t,e)))},le=(e,t)=>({invalid:!!m((t||g).errors,e),isDirty:!!m((t||g).dirtyFields,e),error:m((t||g).errors,e),isValidating:!!m(g.validatingFields,e),isTouched:!!m((t||g).touchedFields,e)}),de=(e,t,r)=>{const s=(m(_,e,{_f:{}})._f||{}).ref,a=m(g.errors,e)||{},{ref:i,message:n,type:o,...l}=a;b(g.errors,e,{...l,...t,ref:s}),D.state.next({name:e,errors:g.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},ce=e=>D.state.subscribe({next:t=>{var r,s,a;r=e.name,s=t.name,a=e.exact,r&&s&&r!==s&&!I(r).some((e=>e&&(a?e===s:e.startsWith(s)||s.startsWith(e))))||!((e,t,r,s)=>{r(e);const{name:a,...i}=e;return G(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find((e=>t[e]===(!s||S)))})(t,e.formState||w,Ee,e.reRenderRoot)||e.callback({values:V,...g,...t})}}).unsubscribe,me=(e,t={})=>{for(const r of e?I(e):A.mount)A.mount.delete(r),A.array.delete(r),t.keepValue||(te(_,r),te(V,r)),!t.keepError&&te(g.errors,r),!t.keepDirty&&te(g.dirtyFields,r),!t.keepTouched&&te(g.touchedFields,r),!t.keepIsValidating&&te(g.validatingFields,r),!i.shouldUnregister&&!t.keepDefaultValue&&te(p,r);D.state.next({values:{...V}}),D.state.next({...g,...t.keepDirty?{isDirty:q()}:{}}),!t.keepIsValid&&j()},Ve=({disabled:e,name:t,field:r,fields:s})=>{(y(e)&&F.mount||e||A.disabled.has(t))&&(e?A.disabled.add(t):A.disabled.delete(t),M(t,fe(r?r._f:m(s,t)._f),!1,!1,!0))},Fe=(e,t={})=>{let s=m(_,e);const a=y(t.disabled)||y(i.disabled);return b(_,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...t}}),A.mount.add(e),s?Ve({field:s,disabled:y(t.disabled)?t.disabled:i.disabled,name:e}):N(e,!0,t.value),{...a?{disabled:t.disabled||i.disabled}:{},...i.progressive?{required:!!t.required,min:ye(t.min),max:ye(t.max),minLength:ye(t.minLength),maxLength:ye(t.maxLength),pattern:ye(t.pattern)}:{},name:e,onChange:se,onBlur:se,ref:a=>{if(a){Fe(e,t),s=m(_,e);const i=f(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,n=(e=>Z(e)||r(e))(i),o=s._f.refs||[];if(n?o.find((e=>e===i)):i===s._f.ref)return;b(_,e,{_f:{...s._f,...n?{refs:[...o.filter(ee),i,...Array.isArray(m(p,e))?[{}]:[]],ref:{type:i.type,name:e}}:{ref:i}}}),N(e,!1,void 0,i)}else s=m(_,e,{}),s._f&&(s._f.mount=!1),(i.shouldUnregister||t.shouldUnregister)&&(!l(A.array,e)||!F.action)&&A.unMount.add(e)}}},Ae=()=>i.shouldFocusError&&he(_,ae,A.mount),we=(e,t)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=d(V);if(A.disabled.size)for(const e of A.disabled)b(a,e,void 0);if(D.state.next({isSubmitting:!0}),i.resolver){const{errors:e,values:t}=await R();g.errors=e,a=t}else await P(_);if(te(g.errors,"root"),G(g.errors)){D.state.next({errors:{}});try{await e(a,r)}catch(e){s=e}}else t&&await t({...g.errors},r),Ae(),setTimeout(Ae);if(D.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(g.errors)&&!s,submitCount:g.submitCount+1,errors:g.errors}),s)throw s},ke=(e,t={})=>{const r=e?d(e):p,s=d(r),a=G(e),n=a?p:s;if(t.keepDefaultValues||(p=r),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...A.mount,...Object.keys(ie(p,V))]);for(const t of Array.from(e))m(g.dirtyFields,t)?b(n,t,m(V,t)):re(t,m(n,t))}else{if(u&&f(e))for(const e of A.mount){const t=m(_,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(X(e)){const t=e.closest("form");if(t){t.reset();break}}}}_={}}V=i.shouldUnregister?t.keepDefaultValues?d(p):{}:d(n),D.array.next({values:{...n}}),D.state.next({values:{...n}})}A={mount:t.keepDirtyValues?A.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},F.mount=!w.isValid||!!t.keepIsValid||!!t.keepDirtyValues,F.watch=!!i.shouldUnregister,D.state.next({submitCount:t.keepSubmitCount?g.submitCount:0,isDirty:!a&&(t.keepDirty?g.isDirty:!(!t.keepDefaultValues||z(e,p))),isSubmitted:!!t.keepIsSubmitted&&g.isSubmitted,dirtyFields:a?{}:t.keepDirtyValues?t.keepDefaultValues&&V?ie(p,V):g.dirtyFields:t.keepDefaultValues&&e?ie(p,e):t.keepDirty?g.dirtyFields:{},touchedFields:t.keepTouched?g.touchedFields:{},errors:t.keepErrors?g.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&g.isSubmitSuccessful,isSubmitting:!1})},De=(e,t)=>ke(Q(e)?e(V):e,t),Ee=e=>{g={...g,...e}},Ce={control:{register:Fe,unregister:me,getFieldState:le,handleSubmit:we,setError:de,_subscribe:ce,_runSchema:R,_getWatch:W,_getDirty:q,_setValid:j,_setFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r&&!i.disabled){if(F.action=!0,n&&Array.isArray(m(_,e))){const t=r(m(_,e),s.argA,s.argB);a&&b(_,e,t)}if(n&&Array.isArray(m(g.errors,e))){const t=r(m(g.errors,e),s.argA,s.argB);a&&b(g.errors,e,t),((e,t)=>{!c(m(e,t)).length&&te(e,t)})(g.errors,e)}if((w.touchedFields||k.touchedFields)&&n&&Array.isArray(m(g.touchedFields,e))){const t=r(m(g.touchedFields,e),s.argA,s.argB);a&&b(g.touchedFields,e,t)}(w.dirtyFields||k.dirtyFields)&&(g.dirtyFields=ie(p,V)),D.state.next({name:e,isDirty:q(e,t),dirtyFields:g.dirtyFields,errors:g.errors,isValid:g.isValid})}else b(V,e,t)},_setDisabledField:Ve,_setErrors:e=>{g.errors=e,D.state.next({errors:g.errors,isValid:!1})},_getFieldArray:e=>c(m(F.mount?V:p,e,i.shouldUnregister?m(p,e,[]):[])),_reset:ke,_resetDefaultValues:()=>Q(i.defaultValues)&&i.defaultValues().then((e=>{De(e,i.resetOptions),D.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of A.unMount){const t=m(_,e);t&&(t._f.refs?t._f.refs.every((e=>!ee(e))):!ee(t._f.ref))&&me(e)}A.unMount=new Set},_disableForm:e=>{y(e)&&(D.state.next({disabled:e}),he(_,((t,r)=>{const s=m(_,r);s&&(t.disabled=s._f.disabled||e,Array.isArray(s._f.refs)&&s._f.refs.forEach((t=>{t.disabled=s._f.disabled||e})))}),0,!1))},_subjects:D,_proxyFormState:w,get _fields(){return _},get _formValues(){return V},get _state(){return F},set _state(e){F=e},get _defaultValues(){return p},get _names(){return A},set _names(e){A=e},get _formState(){return g},get _options(){return i},set _options(e){i={...i,...e}}},subscribe:e=>(F.mount=!0,k={...k,...e.formState},ce({...e,formState:k})),trigger:ne,register:Fe,handleSubmit:we,watch:(e,t)=>Q(e)?D.state.subscribe({next:r=>e(W(void 0,t),r)}):W(e,t,!0),setValue:re,getValues:oe,reset:De,resetField:(e,t={})=>{m(_,e)&&(f(t.defaultValue)?re(e,d(m(p,e))):(re(e,t.defaultValue),b(p,e,d(t.defaultValue))),t.keepTouched||te(g.touchedFields,e),t.keepDirty||(te(g.dirtyFields,e),g.isDirty=t.defaultValue?q(e,d(m(p,e))):q()),t.keepError||(te(g.errors,e),w.isValid&&j()),D.state.next({...g}))},clearErrors:e=>{e&&I(e).forEach((e=>te(g.errors,e))),D.state.next({errors:e?g.errors:{}})},unregister:me,setError:de,setFocus:(e,t={})=>{const r=m(_,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&Q(e.select)&&e.select())}},getFieldState:le};return{...Ce,formControl:Ce}}var ke=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},De=(e,t,r={})=>r.shouldFocus||f(r.shouldFocus)?r.focusName||`${e}.${f(r.focusIndex)?t:r.focusIndex}.`:"",Ee=(e,t)=>[...e,...I(t)],Ce=e=>Array.isArray(e)?e.map((()=>{})):void 0;function Oe(e,t,r){return[...e.slice(0,t),...I(r),...e.slice(t)]}var je=(e,t,r)=>Array.isArray(e)?(f(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],Te=(e,t)=>[...I(t),...I(e)];var Ne=(e,t)=>f(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return c(s).length?s:[]}(e,I(t).sort(((e,t)=>e-t))),Me=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},Ue=(e,t,r)=>(e[t]=r,e);e.Controller=e=>e.render(P(e)),e.Form=function(e){const r=N(),[s,a]=t.useState(!1),{control:i=r.control,onSubmit:n,children:o,action:l,method:u=W,headers:d,encType:c,onError:f,render:m,onSuccess:y,validateStatus:g,..._}=e,b=async t=>{let r=!1,s="";await i.handleSubmit((async e=>{const a=new FormData;let o="";try{o=JSON.stringify(e)}catch(e){}const m=q(i._formValues);for(const e in m)a.append(e,m[e]);if(n&&await n({data:e,event:t,method:u,formData:a,formDataJson:o}),l)try{const e=[d&&d["Content-Type"],c].some((e=>e&&e.includes("json"))),t=await fetch(String(l),{method:u,headers:{...d,...c?{"Content-Type":c}:{}},body:e?o:a});t&&(g?!g(t.status):t.status<200||t.status>=300)?(r=!0,f&&f({response:t}),s=String(t.status)):y&&y({response:t})}catch(e){r=!0,f&&f({error:e})}}))(t),r&&e.control&&(e.control._subjects.state.next({isSubmitSuccessful:!1}),e.control.setError("root.server",{type:s}))};return t.useEffect((()=>{a(!0)}),[]),m?t.createElement(t.Fragment,null,m({submit:b})):t.createElement("form",{noValidate:s,action:l,method:u,encType:c,onSubmit:b,..._},o)},e.FormProvider=e=>{const{children:r,...s}=e;return t.createElement(T.Provider,{value:s},r)},e.appendErrors=$,e.createFormControl=we,e.get=m,e.set=b,e.useController=P,e.useFieldArray=function(e){const r=N(),{control:s=r.control,name:a,keyName:i="id",shouldUnregister:n,rules:o}=e,[l,u]=t.useState(s._getFieldArray(a)),c=t.useRef(s._getFieldArray(a).map(ke)),f=t.useRef(l),y=t.useRef(a),g=t.useRef(!1);y.current=a,f.current=l,s._names.array.add(a),o&&s.register(a,o),t.useEffect((()=>s._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===y.current||!t){const t=m(e,y.current);Array.isArray(t)&&(u(t),c.current=t.map(ke))}}}).unsubscribe),[s]);const _=t.useCallback((e=>{g.current=!0,s._setFieldArray(a,e)}),[s,a]);return t.useEffect((()=>{if(s._state.action=!1,be(a,s._names)&&s._subjects.state.next({...s._formState}),g.current&&(!ge(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._runSchema([a]).then((e=>{const t=m(e.errors,a),r=m(s._formState.errors,a);(r?!t&&r.type||t&&(r.type!==t.type||r.message!==t.message):t&&t.type)&&(t?b(s._formState.errors,a,t):te(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=m(s._fields,a);!e||!e._f||ge(s._options.reValidateMode).isOnSubmit&&ge(s._options.mode).isOnSubmit||xe(e,s._names.disabled,s._formValues,s._options.criteriaMode===S,s._options.shouldUseNativeValidation,!0).then((e=>!G(e)&&s._subjects.state.next({errors:pe(s._formState.errors,e,a)})))}s._subjects.state.next({name:a,values:{...s._formValues}}),s._names.focus&&he(s._fields,((e,t)=>{if(s._names.focus&&t.startsWith(s._names.focus)&&e.focus)return e.focus(),1})),s._names.focus="",s._setValid(),g.current=!1}),[l,a,s]),t.useEffect((()=>(!m(s._formValues,a)&&s._setFieldArray(a),()=>{(s._options.shouldUnregister||n)&&s.unregister(a)})),[a,s,i,n]),{swap:t.useCallback(((e,t)=>{const r=s._getFieldArray(a);Me(r,e,t),Me(c.current,e,t),_(r),u(r),s._setFieldArray(a,r,Me,{argA:e,argB:t},!1)}),[_,a,s]),move:t.useCallback(((e,t)=>{const r=s._getFieldArray(a);je(r,e,t),je(c.current,e,t),_(r),u(r),s._setFieldArray(a,r,je,{argA:e,argB:t},!1)}),[_,a,s]),prepend:t.useCallback(((e,t)=>{const r=I(d(e)),i=Te(s._getFieldArray(a),r);s._names.focus=De(a,0,t),c.current=Te(c.current,r.map(ke)),_(i),u(i),s._setFieldArray(a,i,Te,{argA:Ce(e)})}),[_,a,s]),append:t.useCallback(((e,t)=>{const r=I(d(e)),i=Ee(s._getFieldArray(a),r);s._names.focus=De(a,i.length-1,t),c.current=Ee(c.current,r.map(ke)),_(i),u(i),s._setFieldArray(a,i,Ee,{argA:Ce(e)})}),[_,a,s]),remove:t.useCallback((e=>{const t=Ne(s._getFieldArray(a),e);c.current=Ne(c.current,e),_(t),u(t),!Array.isArray(m(s._fields,a))&&b(s._fields,a,void 0),s._setFieldArray(a,t,Ne,{argA:e})}),[_,a,s]),insert:t.useCallback(((e,t,r)=>{const i=I(d(t)),n=Oe(s._getFieldArray(a),e,i);s._names.focus=De(a,e,r),c.current=Oe(c.current,e,i.map(ke)),_(n),u(n),s._setFieldArray(a,n,Oe,{argA:e,argB:Ce(t)})}),[_,a,s]),update:t.useCallback(((e,t)=>{const r=d(t),i=Ue(s._getFieldArray(a),e,r);c.current=[...i].map(((t,r)=>t&&r!==e?c.current[r]:ke())),_(i),u([...i]),s._setFieldArray(a,i,Ue,{argA:e,argB:r},!0,!1)}),[_,a,s]),replace:t.useCallback((e=>{const t=I(d(e));c.current=t.map(ke),_([...t]),u([...t]),s._setFieldArray(a,[...t],(e=>e),{},!0,!1)}),[_,a,s]),fields:t.useMemo((()=>l.map(((e,t)=>({...e,[i]:c.current[t]||ke()})))),[l,i])}},e.useForm=function(e={}){const r=t.useRef(void 0),s=t.useRef(void 0),[a,i]=t.useState({isDirty:!1,isValidating:!1,isLoading:Q(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Q(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...e.control?e.control:we(e),formState:a});const n=r.current.control;return n._options=e,t.useEffect((()=>n._subscribe({formState:n._proxyFormState,callback:()=>i({...n._formState}),reRenderRoot:!0})),[n]),t.useEffect((()=>n._disableForm(e.disabled)),[n,e.disabled]),t.useEffect((()=>{if(n._proxyFormState.isDirty){const e=n._getDirty();e!==a.isDirty&&n._subjects.state.next({isDirty:e})}}),[n,a.isDirty]),t.useEffect((()=>{e.values&&!z(e.values,s.current)?(n._reset(e.values,n._options.resetOptions),s.current=e.values,i((e=>({...e})))):n._resetDefaultValues()}),[e.values,n]),t.useEffect((()=>{e.errors&&n._setErrors(e.errors)}),[e.errors,n]),t.useEffect((()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),t.useEffect((()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})}),[e.shouldUnregister,n]),r.current.formState=M(a,n),r.current},e.useFormContext=N,e.useFormState=U,e.useWatch=R})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactHookForm={},e.React)}(this,(function(e,t){"use strict";var r=e=>"checkbox"===e.type,s=e=>e instanceof Date,a=e=>null==e;const i=e=>"object"==typeof e;var n=e=>!a(e)&&!Array.isArray(e)&&i(e)&&!s(e),o=e=>n(e)&&e.target?r(e.target)?e.target.checked:e.target.value:e,l=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),u="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function d(e){let t;const r=Array.isArray(e),s="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(u&&(e instanceof Blob||s)||!r&&!n(e))return e;if(t=r?[]:{},r||(e=>{const t=e.constructor&&e.constructor.prototype;return n(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)e.hasOwnProperty(r)&&(t[r]=d(e[r]));else t=e}return t}var c=e=>Array.isArray(e)?e.filter(Boolean):[],f=e=>void 0===e,m=(e,t,r)=>{if(!t||!n(e))return r;const s=c(t.split(/[,[\].]+?/)).reduce(((e,t)=>a(e)?e:e[t]),e);return f(s)||s===e?f(e[t])?r:e[t]:s},y=e=>"boolean"==typeof e,g=e=>/^\w*$/.test(e),_=e=>c(e.replace(/["|']|\]/g,"").split(/\.|\[/)),b=(e,t,r)=>{let s=-1;const a=g(t)?[t]:_(t),i=a.length,o=i-1;for(;++s<i;){const t=a[s];let i=r;if(s!==o){const r=e[t];i=n(r)||Array.isArray(r)?r:isNaN(+a[s+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=i,e=e[t]}return e};const h="blur",v="focusout",p="change",V="onBlur",F="onChange",A="onSubmit",x="onTouched",S="all",w="max",k="min",D="maxLength",E="minLength",C="pattern",O="required",j="validate",T=t.createContext(null),N=()=>t.useContext(T);var M=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const a=i;return t._proxyFormState[a]!==S&&(t._proxyFormState[a]=!s||S),r&&(r[a]=!0),e[a]}});return a};function U(e){const r=N(),{control:s=r.control,disabled:a,name:i,exact:n}=e||{},[o,l]=t.useState(s._formState),u=t.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),d=t.useRef(i);return d.current=i,t.useEffect((()=>s._subscribe({name:d.current,formState:u.current,exact:n,callback:e=>{!a&&l({...s._formState,...e})}})),[s,a,n]),t.useEffect((()=>{u.current.isValid&&s._setValid(!0)}),[s]),t.useMemo((()=>M(o,s,u.current,!1)),[o,s])}var B=e=>"string"==typeof e,L=(e,t,r,s,a)=>B(e)?(s&&t.watch.add(e),m(r,e,a)):Array.isArray(e)?e.map((e=>(s&&t.watch.add(e),m(r,e)))):(s&&(t.watchAll=!0),r);function R(e){const r=N(),{control:s=r.control,name:a,defaultValue:i,disabled:n,exact:o}=e||{},l=t.useRef(a);l.current=a,t.useEffect((()=>s._subscribe({name:l.current,formState:{values:!0},exact:o,callback:e=>!n&&c(d(L(l.current,s._names,e.values||s._formValues,!1,i)))})),[s,i,n,o]);const[u,c]=t.useState(s._getWatch(a,i));return t.useEffect((()=>s._removeUnmounted())),u}function P(e){const r=N(),{name:s,disabled:a,control:i=r.control,shouldUnregister:n}=e,u=l(i._names.array,s),c=R({control:i,name:s,defaultValue:m(i._formValues,s,m(i._defaultValues,s,e.defaultValue)),exact:!0}),g=U({control:i,name:s,exact:!0}),_=t.useRef(i.register(s,{...e.rules,value:c,...y(e.disabled)?{disabled:e.disabled}:{}})),v=t.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!m(g.errors,s)},isDirty:{enumerable:!0,get:()=>!!m(g.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!m(g.touchedFields,s)},isValidating:{enumerable:!0,get:()=>!!m(g.validatingFields,s)},error:{enumerable:!0,get:()=>m(g.errors,s)}})),[g,s]),V=t.useMemo((()=>({name:s,value:c,...y(a)||g.disabled?{disabled:g.disabled||a}:{},onChange:e=>_.current.onChange({target:{value:o(e),name:s},type:p}),onBlur:()=>_.current.onBlur({target:{value:m(i._formValues,s),name:s},type:h}),ref:e=>{const t=m(i._fields,s);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}})),[s,i._formValues,a,g.disabled,c,i._fields]);return t.useEffect((()=>{const e=i._options.shouldUnregister||n,t=(e,t)=>{const r=m(i._fields,e);r&&r._f&&(r._f.mount=t)};if(t(s,!0),e){const e=d(m(i._options.defaultValues,s));b(i._defaultValues,s,e),f(m(i._formValues,s))&&b(i._formValues,s,e)}return!u&&i.register(s),()=>{(u?e&&!i._state.action:e)?i.unregister(s):t(s,!1)}}),[s,i,u,n]),t.useEffect((()=>{i._setDisabledField({disabled:a,fields:i._fields,name:s})}),[a,s,i]),t.useMemo((()=>({field:V,formState:g,fieldState:v})),[V,g,v])}const q=e=>{const t={};for(const r of Object.keys(e))if(i(e[r])&&null!==e[r]){const s=q(e[r]);for(const e of Object.keys(s))t[`${r}.${e}`]=s[e]}else t[r]=e[r];return t},W="post";var $=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},I=e=>Array.isArray(e)?e:[e],H=()=>{let e=[];return{get observers(){return e},next:t=>{for(const r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}},J=e=>a(e)||!i(e);function z(e,t){if(J(e)||J(t))return e===t;if(s(e)&&s(t))return e.getTime()===t.getTime();const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const i of r){const r=e[i];if(!a.includes(i))return!1;if("ref"!==i){const e=t[i];if(s(r)&&s(e)||n(r)&&n(e)||Array.isArray(r)&&Array.isArray(e)?!z(r,e):r!==e)return!1}}return!0}var G=e=>n(e)&&!Object.keys(e).length,K=e=>"file"===e.type,Q=e=>"function"==typeof e,X=e=>{if(!u)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Y=e=>"select-multiple"===e.type,Z=e=>"radio"===e.type,ee=e=>X(e)&&e.isConnected;function te(e,t){const r=Array.isArray(t)?t:g(t)?[t]:_(t),s=1===r.length?e:function(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=f(e)?s++:e[t[s++]];return e}(e,r),a=r.length-1,i=r[a];return s&&delete s[i],0!==a&&(n(s)&&G(s)||Array.isArray(s)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!f(e[t]))return!1;return!0}(s))&&te(e,r.slice(0,-1)),e}var re=e=>{for(const t in e)if(Q(e[t]))return!0;return!1};function se(e,t={}){const r=Array.isArray(e);if(n(e)||r)for(const r in e)Array.isArray(e[r])||n(e[r])&&!re(e[r])?(t[r]=Array.isArray(e[r])?[]:{},se(e[r],t[r])):a(e[r])||(t[r]=!0);return t}function ae(e,t,r){const s=Array.isArray(e);if(n(e)||s)for(const s in e)Array.isArray(e[s])||n(e[s])&&!re(e[s])?f(t)||J(r[s])?r[s]=Array.isArray(e[s])?se(e[s],[]):{...se(e[s])}:ae(e[s],a(t)?{}:t[s],r[s]):r[s]=!z(e[s],t[s]);return r}var ie=(e,t)=>ae(e,t,se(t));const ne={value:!1,isValid:!1},oe={value:!0,isValid:!0};var le=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!f(e[0].attributes.value)?f(e[0].value)||""===e[0].value?oe:{value:e[0].value,isValid:!0}:oe:ne}return ne},ue=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>f(e)?e:t?""===e?NaN:e?+e:e:r&&B(e)?new Date(e):s?s(e):e;const de={isValid:!1,value:null};var ce=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),de):de;function fe(e){const t=e.ref;return K(t)?t.files:Z(t)?ce(e.refs).value:Y(t)?[...t.selectedOptions].map((({value:e})=>e)):r(t)?le(e.refs).value:ue(f(t.value)?e.ref.value:t.value,e)}var me=e=>e instanceof RegExp,ye=e=>f(e)?e:me(e)?e.source:n(e)?me(e.value)?e.value.source:e.value:e,ge=e=>({isOnSubmit:!e||e===A,isOnBlur:e===V,isOnChange:e===F,isOnAll:e===S,isOnTouch:e===x});const _e="AsyncFunction";var be=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))));const he=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const r=m(e,a);if(r){const{_f:e,...i}=r;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],a)&&!s)return!0;if(e.ref&&t(e.ref,e.name)&&!s)return!0;if(he(i,t))break}else if(n(i)&&he(i,t))break}}};function ve(e,t,r){const s=m(e,r);if(s||g(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const s=a.join("."),i=m(t,s),n=m(e,s);if(i&&!Array.isArray(i)&&r!==s)return{name:r};if(n&&n.type)return{name:s,error:n};a.pop()}return{name:r}}var pe=(e,t,r)=>{const s=I(m(e,r));return b(s,"root",t[r]),b(e,r,s),e},Ve=e=>B(e);function Fe(e,t,r="validate"){if(Ve(e)||Array.isArray(e)&&e.every(Ve)||y(e)&&!e)return{type:r,message:Ve(e)?e:"",ref:t}}var Ae=e=>n(e)&&!me(e)?e:{value:e,message:""},xe=async(e,t,s,i,o,l)=>{const{ref:u,refs:d,required:c,maxLength:g,minLength:_,min:b,max:h,pattern:v,validate:p,name:V,valueAsNumber:F,mount:A}=e._f,x=m(s,V);if(!A||t.has(V))return{};const S=d?d[0]:u,T=e=>{o&&S.reportValidity&&(S.setCustomValidity(y(e)?"":e||""),S.reportValidity())},N={},M=Z(u),U=r(u),L=M||U,R=(F||K(u))&&f(u.value)&&f(x)||X(u)&&""===u.value||""===x||Array.isArray(x)&&!x.length,P=$.bind(null,V,i,N),q=(e,t,r,s=D,a=E)=>{const i=e?t:r;N[V]={type:e?s:a,message:i,ref:u,...P(e?s:a,i)}};if(l?!Array.isArray(x)||!x.length:c&&(!L&&(R||a(x))||y(x)&&!x||U&&!le(d).isValid||M&&!ce(d).isValid)){const{value:e,message:t}=Ve(c)?{value:!!c,message:c}:Ae(c);if(e&&(N[V]={type:O,message:t,ref:S,...P(O,t)},!i))return T(t),N}if(!(R||a(b)&&a(h))){let e,t;const r=Ae(h),s=Ae(b);if(a(x)||isNaN(x)){const a=u.valueAsDate||new Date(x),i=e=>new Date((new Date).toDateString()+" "+e),n="time"==u.type,o="week"==u.type;B(r.value)&&x&&(e=n?i(x)>i(r.value):o?x>r.value:a>new Date(r.value)),B(s.value)&&x&&(t=n?i(x)<i(s.value):o?x<s.value:a<new Date(s.value))}else{const i=u.valueAsNumber||(x?+x:x);a(r.value)||(e=i>r.value),a(s.value)||(t=i<s.value)}if((e||t)&&(q(!!e,r.message,s.message,w,k),!i))return T(N[V].message),N}if((g||_)&&!R&&(B(x)||l&&Array.isArray(x))){const e=Ae(g),t=Ae(_),r=!a(e.value)&&x.length>+e.value,s=!a(t.value)&&x.length<+t.value;if((r||s)&&(q(r,e.message,t.message),!i))return T(N[V].message),N}if(v&&!R&&B(x)){const{value:e,message:t}=Ae(v);if(me(e)&&!x.match(e)&&(N[V]={type:C,message:t,ref:u,...P(C,t)},!i))return T(t),N}if(p)if(Q(p)){const e=Fe(await p(x,s),S);if(e&&(N[V]={...e,...P(j,e.message)},!i))return T(e.message),N}else if(n(p)){let e={};for(const t in p){if(!G(e)&&!i)break;const r=Fe(await p[t](x,s),S,t);r&&(e={...r,...P(t,r.message)},T(r.message),i&&(N[V]=e))}if(!G(e)&&(N[V]={ref:S,...e},!i))return N}return T(!0),N};const Se={mode:A,reValidateMode:F,shouldFocusError:!0};function we(e={}){let t,i={...Se,...e},g={submitCount:0,isDirty:!1,isLoading:Q(i.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:i.errors||{},disabled:i.disabled||!1},_={},p=(n(i.defaultValues)||n(i.values))&&d(i.defaultValues||i.values)||{},V=i.shouldUnregister?{}:d(p),F={action:!1,mount:!1,watch:!1},A={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},x=0;const w={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let k={...w};const D={array:H(),state:H()},E=ge(i.mode),C=ge(i.reValidateMode),O=i.criteriaMode===S,j=async e=>{if(!i.disabled&&(w.isValid||k.isValid||e)){const e=i.resolver?G((await R()).errors):await P(_,!0);e!==g.isValid&&D.state.next({isValid:e})}},T=(e,t)=>{!i.disabled&&(w.isValidating||w.validatingFields||k.isValidating||k.validatingFields)&&((e||Array.from(A.mount)).forEach((e=>{e&&(t?b(g.validatingFields,e,t):te(g.validatingFields,e))})),D.state.next({validatingFields:g.validatingFields,isValidating:!G(g.validatingFields)}))},N=(e,t,r,s)=>{const a=m(_,e);if(a){const i=m(V,e,f(r)?m(p,e):r);f(i)||s&&s.defaultChecked||t?b(V,e,t?i:fe(a._f)):$(e,i),F.mount&&j()}},M=(e,t,r,s,a)=>{let n=!1,o=!1;const l={name:e};if(!i.disabled){const i=!!(m(_,e)&&m(_,e)._f&&m(_,e)._f.disabled);if(!r||s){(w.isDirty||k.isDirty)&&(o=g.isDirty,g.isDirty=l.isDirty=q(),n=o!==l.isDirty);const r=i||z(m(p,e),t);o=!(i||!m(g.dirtyFields,e)),r||i?te(g.dirtyFields,e):b(g.dirtyFields,e,!0),l.dirtyFields=g.dirtyFields,n=n||(w.dirtyFields||k.dirtyFields)&&o!==!r}if(r){const t=m(g.touchedFields,e);t||(b(g.touchedFields,e,r),l.touchedFields=g.touchedFields,n=n||(w.touchedFields||k.touchedFields)&&t!==r)}n&&a&&D.state.next(l)}return n?l:{}},U=(e,r,s,a)=>{const n=m(g.errors,e),o=(w.isValid||k.isValid)&&y(r)&&g.isValid!==r;var l;if(i.delayError&&s?(l=()=>((e,t)=>{b(g.errors,e,t),D.state.next({errors:g.errors})})(e,s),t=e=>{clearTimeout(x),x=setTimeout(l,e)},t(i.delayError)):(clearTimeout(x),t=null,s?b(g.errors,e,s):te(g.errors,e)),(s?!z(n,s):n)||!G(a)||o){const t={...a,...o&&y(r)?{isValid:r}:{},errors:g.errors,name:e};g={...g,...t},D.state.next(t)}},R=async e=>{T(e,!0);const t=await i.resolver(V,i.context,((e,t,r,s)=>{const a={};for(const r of e){const e=m(t,r);e&&b(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}})(e||A.mount,_,i.criteriaMode,i.shouldUseNativeValidation));return T(e),t},P=async(e,t,r={valid:!0})=>{for(const a in e){const o=e[a];if(o){const{_f:e,...l}=o;if(e){const l=A.array.has(e.name),u=o._f&&(!!(s=o._f)&&!!s.validate&&!!(Q(s.validate)&&s.validate.constructor.name===_e||n(s.validate)&&Object.values(s.validate).find((e=>e.constructor.name===_e))));u&&w.validatingFields&&T([a],!0);const d=await xe(o,A.disabled,V,O,i.shouldUseNativeValidation&&!t,l);if(u&&w.validatingFields&&T([a]),d[e.name]&&(r.valid=!1,t))break;!t&&(m(d,e.name)?l?pe(g.errors,d,e.name):b(g.errors,e.name,d[e.name]):te(g.errors,e.name))}!G(l)&&await P(l,t,r)}}var s;return r.valid},q=(e,t)=>!i.disabled&&(e&&t&&b(V,e,t),!z(oe(),p)),W=(e,t,r)=>L(e,A,{...F.mount?V:f(t)?p:B(e)?{[e]:t}:t},r,t),$=(e,t,s={})=>{const i=m(_,e);let n=t;if(i){const s=i._f;s&&(!s.disabled&&b(V,e,ue(t,s)),n=X(s.ref)&&a(t)?"":t,Y(s.ref)?[...s.ref.options].forEach((e=>e.selected=n.includes(e.value))):s.refs?r(s.ref)?s.refs.length>1?s.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(n)?!!n.find((t=>t===e.value)):n===e.value))):s.refs[0]&&(s.refs[0].checked=!!n):s.refs.forEach((e=>e.checked=e.value===n)):K(s.ref)?s.ref.value="":(s.ref.value=n,s.ref.type||D.state.next({name:e,values:{...V}})))}(s.shouldDirty||s.shouldTouch)&&M(e,n,s.shouldTouch,s.shouldDirty,!0),s.shouldValidate&&ne(e)},J=(e,t,r)=>{for(const a in t){const i=t[a],o=`${e}.${a}`,l=m(_,o);(A.array.has(e)||n(i)||l&&!l._f)&&!s(i)?J(o,i,r):$(o,i,r)}},re=(e,t,r={})=>{const s=m(_,e),i=A.array.has(e),n=d(t);b(V,e,n),i?(D.array.next({name:e,values:{...V}}),(w.isDirty||w.dirtyFields||k.isDirty||k.dirtyFields)&&r.shouldDirty&&D.state.next({name:e,dirtyFields:ie(p,V),isDirty:q(e,n)})):!s||s._f||a(n)?$(e,n,r):J(e,n,r),be(e,A)&&D.state.next({...g}),D.state.next({name:F.mount?e:void 0,values:{...V}})},se=async e=>{F.mount=!0;const r=e.target;let a=r.name,n=!0;const l=m(_,a),u=e=>{n=Number.isNaN(e)||s(e)&&isNaN(e.getTime())||z(e,m(V,a,e))};if(l){let s,c;const f=r.type?fe(l._f):o(e),y=e.type===h||e.type===v,p=!((d=l._f).mount&&(d.required||d.min||d.max||d.maxLength||d.minLength||d.pattern||d.validate)||i.resolver||m(g.errors,a)||l._f.deps)||((e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:!(r?s.isOnChange:a.isOnChange)||e))(y,m(g.touchedFields,a),g.isSubmitted,C,E),F=be(a,A,y);b(V,a,f),y?(l._f.onBlur&&l._f.onBlur(e),t&&t(0)):l._f.onChange&&l._f.onChange(e);const x=M(a,f,y),S=!G(x)||F;if(!y&&D.state.next({name:a,type:e.type,values:{...V}}),p)return(w.isValid||k.isValid)&&("onBlur"===i.mode&&y?j():y||j()),S&&D.state.next({name:a,...F?{}:x});if(!y&&F&&D.state.next({...g}),i.resolver){const{errors:e}=await R([a]);if(u(f),n){const t=ve(g.errors,_,a),r=ve(e,_,t.name||a);s=r.error,a=r.name,c=G(e)}}else T([a],!0),s=(await xe(l,A.disabled,V,O,i.shouldUseNativeValidation))[a],T([a]),u(f),n&&(s?c=!1:(w.isValid||k.isValid)&&(c=await P(_,!0)));n&&(l._f.deps&&ne(l._f.deps),U(a,c,s,x))}var d},ae=(e,t)=>{if(m(g.errors,t)&&e.focus)return e.focus(),1},ne=async(e,t={})=>{let r,s;const a=I(e);if(i.resolver){const t=await(async e=>{const{errors:t}=await R(e);if(e)for(const r of e){const e=m(t,r);e?b(g.errors,r,e):te(g.errors,r)}else g.errors=t;return t})(f(e)?e:a);r=G(t),s=e?!a.some((e=>m(t,e))):r}else e?(s=(await Promise.all(a.map((async e=>{const t=m(_,e);return await P(t&&t._f?{[e]:t}:t)})))).every(Boolean),(s||g.isValid)&&j()):s=r=await P(_);return D.state.next({...!B(e)||(w.isValid||k.isValid)&&r!==g.isValid?{}:{name:e},...i.resolver||!e?{isValid:r}:{},errors:g.errors}),t.shouldFocus&&!s&&he(_,ae,e?a:A.mount),s},oe=e=>{const t={...F.mount?V:p};return f(e)?t:B(e)?m(t,e):e.map((e=>m(t,e)))},le=(e,t)=>({invalid:!!m((t||g).errors,e),isDirty:!!m((t||g).dirtyFields,e),error:m((t||g).errors,e),isValidating:!!m(g.validatingFields,e),isTouched:!!m((t||g).touchedFields,e)}),de=(e,t,r)=>{const s=(m(_,e,{_f:{}})._f||{}).ref,a=m(g.errors,e)||{},{ref:i,message:n,type:o,...l}=a;b(g.errors,e,{...l,...t,ref:s}),D.state.next({name:e,errors:g.errors,isValid:!1}),r&&r.shouldFocus&&s&&s.focus&&s.focus()},ce=e=>D.state.subscribe({next:t=>{var r,s,a;r=e.name,s=t.name,a=e.exact,r&&s&&r!==s&&!I(r).some((e=>e&&(a?e===s:e.startsWith(s)||s.startsWith(e))))||!((e,t,r,s)=>{r(e);const{name:a,...i}=e;return G(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find((e=>t[e]===(!s||S)))})(t,e.formState||w,Ee,e.reRenderRoot)||e.callback({values:V,...g,...t})}}).unsubscribe,me=(e,t={})=>{for(const r of e?I(e):A.mount)A.mount.delete(r),A.array.delete(r),t.keepValue||(te(_,r),te(V,r)),!t.keepError&&te(g.errors,r),!t.keepDirty&&te(g.dirtyFields,r),!t.keepTouched&&te(g.touchedFields,r),!t.keepIsValidating&&te(g.validatingFields,r),!i.shouldUnregister&&!t.keepDefaultValue&&te(p,r);D.state.next({values:{...V}}),D.state.next({...g,...t.keepDirty?{isDirty:q()}:{}}),!t.keepIsValid&&j()},Ve=({disabled:e,name:t,field:r,fields:s})=>{(y(e)&&F.mount||e||A.disabled.has(t))&&(e?A.disabled.add(t):A.disabled.delete(t),M(t,fe(r?r._f:m(s,t)._f),!1,!1,!0))},Fe=(e,t={})=>{let s=m(_,e);const a=y(t.disabled)||y(i.disabled);return b(_,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...t}}),A.mount.add(e),s?Ve({field:s,disabled:y(t.disabled)?t.disabled:i.disabled,name:e}):N(e,!0,t.value),{...a?{disabled:t.disabled||i.disabled}:{},...i.progressive?{required:!!t.required,min:ye(t.min),max:ye(t.max),minLength:ye(t.minLength),maxLength:ye(t.maxLength),pattern:ye(t.pattern)}:{},name:e,onChange:se,onBlur:se,ref:a=>{if(a){Fe(e,t),s=m(_,e);const i=f(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,n=(e=>Z(e)||r(e))(i),o=s._f.refs||[];if(n?o.find((e=>e===i)):i===s._f.ref)return;b(_,e,{_f:{...s._f,...n?{refs:[...o.filter(ee),i,...Array.isArray(m(p,e))?[{}]:[]],ref:{type:i.type,name:e}}:{ref:i}}}),N(e,!1,void 0,i)}else s=m(_,e,{}),s._f&&(s._f.mount=!1),(i.shouldUnregister||t.shouldUnregister)&&(!l(A.array,e)||!F.action)&&A.unMount.add(e)}}},Ae=()=>i.shouldFocusError&&he(_,ae,A.mount),we=(e,t)=>async r=>{let s;r&&(r.preventDefault&&r.preventDefault(),r.persist&&r.persist());let a=d(V);if(A.disabled.size)for(const e of A.disabled)b(a,e,void 0);if(D.state.next({isSubmitting:!0}),i.resolver){const{errors:e,values:t}=await R();g.errors=e,a=t}else await P(_);if(te(g.errors,"root"),G(g.errors)){D.state.next({errors:{}});try{await e(a,r)}catch(e){s=e}}else t&&await t({...g.errors},r),Ae(),setTimeout(Ae);if(D.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:G(g.errors)&&!s,submitCount:g.submitCount+1,errors:g.errors}),s)throw s},ke=(e,t={})=>{const r=e?d(e):p,s=d(r),a=G(e),n=a?p:s;if(t.keepDefaultValues||(p=r),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...A.mount,...Object.keys(ie(p,V))]);for(const t of Array.from(e))m(g.dirtyFields,t)?b(n,t,m(V,t)):re(t,m(n,t))}else{if(u&&f(e))for(const e of A.mount){const t=m(_,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(X(e)){const t=e.closest("form");if(t){t.reset();break}}}}_={}}V=i.shouldUnregister?t.keepDefaultValues?d(p):{}:d(n),D.array.next({values:{...n}}),D.state.next({values:{...n}})}A={mount:t.keepDirtyValues?A.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},F.mount=!w.isValid||!!t.keepIsValid||!!t.keepDirtyValues,F.watch=!!i.shouldUnregister,D.state.next({submitCount:t.keepSubmitCount?g.submitCount:0,isDirty:!a&&(t.keepDirty?g.isDirty:!(!t.keepDefaultValues||z(e,p))),isSubmitted:!!t.keepIsSubmitted&&g.isSubmitted,dirtyFields:a?{}:t.keepDirtyValues?t.keepDefaultValues&&V?ie(p,V):g.dirtyFields:t.keepDefaultValues&&e?ie(p,e):t.keepDirty?g.dirtyFields:{},touchedFields:t.keepTouched?g.touchedFields:{},errors:t.keepErrors?g.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&g.isSubmitSuccessful,isSubmitting:!1})},De=(e,t)=>ke(Q(e)?e(V):e,t),Ee=e=>{g={...g,...e}},Ce={control:{register:Fe,unregister:me,getFieldState:le,handleSubmit:we,setError:de,_subscribe:ce,_runSchema:R,_getWatch:W,_getDirty:q,_setValid:j,_setFieldArray:(e,t=[],r,s,a=!0,n=!0)=>{if(s&&r&&!i.disabled){if(F.action=!0,n&&Array.isArray(m(_,e))){const t=r(m(_,e),s.argA,s.argB);a&&b(_,e,t)}if(n&&Array.isArray(m(g.errors,e))){const t=r(m(g.errors,e),s.argA,s.argB);a&&b(g.errors,e,t),((e,t)=>{!c(m(e,t)).length&&te(e,t)})(g.errors,e)}if((w.touchedFields||k.touchedFields)&&n&&Array.isArray(m(g.touchedFields,e))){const t=r(m(g.touchedFields,e),s.argA,s.argB);a&&b(g.touchedFields,e,t)}(w.dirtyFields||k.dirtyFields)&&(g.dirtyFields=ie(p,V)),D.state.next({name:e,isDirty:q(e,t),dirtyFields:g.dirtyFields,errors:g.errors,isValid:g.isValid})}else b(V,e,t)},_setDisabledField:Ve,_setErrors:e=>{g.errors=e,D.state.next({errors:g.errors,isValid:!1})},_getFieldArray:e=>c(m(F.mount?V:p,e,i.shouldUnregister?m(p,e,[]):[])),_reset:ke,_resetDefaultValues:()=>Q(i.defaultValues)&&i.defaultValues().then((e=>{De(e,i.resetOptions),D.state.next({isLoading:!1})})),_removeUnmounted:()=>{for(const e of A.unMount){const t=m(_,e);t&&(t._f.refs?t._f.refs.every((e=>!ee(e))):!ee(t._f.ref))&&me(e)}A.unMount=new Set},_disableForm:e=>{y(e)&&(D.state.next({disabled:e}),he(_,((t,r)=>{const s=m(_,r);s&&(t.disabled=s._f.disabled||e,Array.isArray(s._f.refs)&&s._f.refs.forEach((t=>{t.disabled=s._f.disabled||e})))}),0,!1))},_subjects:D,_proxyFormState:w,get _fields(){return _},get _formValues(){return V},get _state(){return F},set _state(e){F=e},get _defaultValues(){return p},get _names(){return A},set _names(e){A=e},get _formState(){return g},get _options(){return i},set _options(e){i={...i,...e}}},subscribe:e=>(F.mount=!0,k={...k,...e.formState},ce({...e,formState:k})),trigger:ne,register:Fe,handleSubmit:we,watch:(e,t)=>Q(e)?D.state.subscribe({next:r=>e(W(void 0,t),r)}):W(e,t,!0),setValue:re,getValues:oe,reset:De,resetField:(e,t={})=>{m(_,e)&&(f(t.defaultValue)?re(e,d(m(p,e))):(re(e,t.defaultValue),b(p,e,d(t.defaultValue))),t.keepTouched||te(g.touchedFields,e),t.keepDirty||(te(g.dirtyFields,e),g.isDirty=t.defaultValue?q(e,d(m(p,e))):q()),t.keepError||(te(g.errors,e),w.isValid&&j()),D.state.next({...g}))},clearErrors:e=>{e&&I(e).forEach((e=>te(g.errors,e))),D.state.next({errors:e?g.errors:{}})},unregister:me,setError:de,setFocus:(e,t={})=>{const r=m(_,e),s=r&&r._f;if(s){const e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&Q(e.select)&&e.select())}},getFieldState:le};return{...Ce,formControl:Ce}}var ke=()=>{const e="undefined"==typeof performance?Date.now():1e3*performance.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(16*Math.random()+e)%16|0;return("x"==t?r:3&r|8).toString(16)}))},De=(e,t,r={})=>r.shouldFocus||f(r.shouldFocus)?r.focusName||`${e}.${f(r.focusIndex)?t:r.focusIndex}.`:"",Ee=(e,t)=>[...e,...I(t)],Ce=e=>Array.isArray(e)?e.map((()=>{})):void 0;function Oe(e,t,r){return[...e.slice(0,t),...I(r),...e.slice(t)]}var je=(e,t,r)=>Array.isArray(e)?(f(e[r])&&(e[r]=void 0),e.splice(r,0,e.splice(t,1)[0]),e):[],Te=(e,t)=>[...I(t),...I(e)];var Ne=(e,t)=>f(t)?[]:function(e,t){let r=0;const s=[...e];for(const e of t)s.splice(e-r,1),r++;return c(s).length?s:[]}(e,I(t).sort(((e,t)=>e-t))),Me=(e,t,r)=>{[e[t],e[r]]=[e[r],e[t]]},Ue=(e,t,r)=>(e[t]=r,e);e.Controller=e=>e.render(P(e)),e.Form=function(e){const r=N(),[s,a]=t.useState(!1),{control:i=r.control,onSubmit:n,children:o,action:l,method:u=W,headers:d,encType:c,onError:f,render:m,onSuccess:y,validateStatus:g,..._}=e,b=async t=>{let r=!1,s="";await i.handleSubmit((async e=>{const a=new FormData;let o="";try{o=JSON.stringify(e)}catch(e){}const m=q(i._formValues);for(const e in m)a.append(e,m[e]);if(n&&await n({data:e,event:t,method:u,formData:a,formDataJson:o}),l)try{const e=[d&&d["Content-Type"],c].some((e=>e&&e.includes("json"))),t=await fetch(String(l),{method:u,headers:{...d,...c?{"Content-Type":c}:{}},body:e?o:a});t&&(g?!g(t.status):t.status<200||t.status>=300)?(r=!0,f&&f({response:t}),s=String(t.status)):y&&y({response:t})}catch(e){r=!0,f&&f({error:e})}}))(t),r&&e.control&&(e.control._subjects.state.next({isSubmitSuccessful:!1}),e.control.setError("root.server",{type:s}))};return t.useEffect((()=>{a(!0)}),[]),m?t.createElement(t.Fragment,null,m({submit:b})):t.createElement("form",{noValidate:s,action:l,method:u,encType:c,onSubmit:b,..._},o)},e.FormProvider=e=>{const{children:r,...s}=e;return t.createElement(T.Provider,{value:s},r)},e.appendErrors=$,e.createFormControl=we,e.get=m,e.set=b,e.useController=P,e.useFieldArray=function(e){const r=N(),{control:s=r.control,name:a,keyName:i="id",shouldUnregister:n,rules:o}=e,[l,u]=t.useState(s._getFieldArray(a)),c=t.useRef(s._getFieldArray(a).map(ke)),f=t.useRef(l),y=t.useRef(a),g=t.useRef(!1);y.current=a,f.current=l,s._names.array.add(a),o&&s.register(a,o),t.useEffect((()=>s._subjects.array.subscribe({next:({values:e,name:t})=>{if(t===y.current||!t){const t=m(e,y.current);Array.isArray(t)&&(u(t),c.current=t.map(ke))}}}).unsubscribe),[s]);const _=t.useCallback((e=>{g.current=!0,s._setFieldArray(a,e)}),[s,a]);return t.useEffect((()=>{if(s._state.action=!1,be(a,s._names)&&s._subjects.state.next({...s._formState}),g.current&&(!ge(s._options.mode).isOnSubmit||s._formState.isSubmitted))if(s._options.resolver)s._runSchema([a]).then((e=>{const t=m(e.errors,a),r=m(s._formState.errors,a);(r?!t&&r.type||t&&(r.type!==t.type||r.message!==t.message):t&&t.type)&&(t?b(s._formState.errors,a,t):te(s._formState.errors,a),s._subjects.state.next({errors:s._formState.errors}))}));else{const e=m(s._fields,a);!e||!e._f||ge(s._options.reValidateMode).isOnSubmit&&ge(s._options.mode).isOnSubmit||xe(e,s._names.disabled,s._formValues,s._options.criteriaMode===S,s._options.shouldUseNativeValidation,!0).then((e=>!G(e)&&s._subjects.state.next({errors:pe(s._formState.errors,e,a)})))}s._subjects.state.next({name:a,values:{...s._formValues}}),s._names.focus&&he(s._fields,((e,t)=>{if(s._names.focus&&t.startsWith(s._names.focus)&&e.focus)return e.focus(),1})),s._names.focus="",s._setValid(),g.current=!1}),[l,a,s]),t.useEffect((()=>(!m(s._formValues,a)&&s._setFieldArray(a),()=>{(s._options.shouldUnregister||n)&&s.unregister(a)})),[a,s,i,n]),{swap:t.useCallback(((e,t)=>{const r=s._getFieldArray(a);Me(r,e,t),Me(c.current,e,t),_(r),u(r),s._setFieldArray(a,r,Me,{argA:e,argB:t},!1)}),[_,a,s]),move:t.useCallback(((e,t)=>{const r=s._getFieldArray(a);je(r,e,t),je(c.current,e,t),_(r),u(r),s._setFieldArray(a,r,je,{argA:e,argB:t},!1)}),[_,a,s]),prepend:t.useCallback(((e,t)=>{const r=I(d(e)),i=Te(s._getFieldArray(a),r);s._names.focus=De(a,0,t),c.current=Te(c.current,r.map(ke)),_(i),u(i),s._setFieldArray(a,i,Te,{argA:Ce(e)})}),[_,a,s]),append:t.useCallback(((e,t)=>{const r=I(d(e)),i=Ee(s._getFieldArray(a),r);s._names.focus=De(a,i.length-1,t),c.current=Ee(c.current,r.map(ke)),_(i),u(i),s._setFieldArray(a,i,Ee,{argA:Ce(e)})}),[_,a,s]),remove:t.useCallback((e=>{const t=Ne(s._getFieldArray(a),e);c.current=Ne(c.current,e),_(t),u(t),!Array.isArray(m(s._fields,a))&&b(s._fields,a,void 0),s._setFieldArray(a,t,Ne,{argA:e})}),[_,a,s]),insert:t.useCallback(((e,t,r)=>{const i=I(d(t)),n=Oe(s._getFieldArray(a),e,i);s._names.focus=De(a,e,r),c.current=Oe(c.current,e,i.map(ke)),_(n),u(n),s._setFieldArray(a,n,Oe,{argA:e,argB:Ce(t)})}),[_,a,s]),update:t.useCallback(((e,t)=>{const r=d(t),i=Ue(s._getFieldArray(a),e,r);c.current=[...i].map(((t,r)=>t&&r!==e?c.current[r]:ke())),_(i),u([...i]),s._setFieldArray(a,i,Ue,{argA:e,argB:r},!0,!1)}),[_,a,s]),replace:t.useCallback((e=>{const t=I(d(e));c.current=t.map(ke),_([...t]),u([...t]),s._setFieldArray(a,[...t],(e=>e),{},!0,!1)}),[_,a,s]),fields:t.useMemo((()=>l.map(((e,t)=>({...e,[i]:c.current[t]||ke()})))),[l,i])}},e.useForm=function(e={}){const r=t.useRef(void 0),s=t.useRef(void 0),[a,i]=t.useState({isDirty:!1,isValidating:!1,isLoading:Q(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Q(e.defaultValues)?void 0:e.defaultValues});r.current||(r.current={...e.formControl?e.formControl:we(e),formState:a});const n=r.current.control;return n._options=e,t.useEffect((()=>n._subscribe({formState:n._proxyFormState,callback:()=>i({...n._formState}),reRenderRoot:!0})),[n]),t.useEffect((()=>n._disableForm(e.disabled)),[n,e.disabled]),t.useEffect((()=>{if(n._proxyFormState.isDirty){const e=n._getDirty();e!==a.isDirty&&n._subjects.state.next({isDirty:e})}}),[n,a.isDirty]),t.useEffect((()=>{e.values&&!z(e.values,s.current)?(n._reset(e.values,n._options.resetOptions),s.current=e.values,i((e=>({...e})))):n._resetDefaultValues()}),[e.values,n]),t.useEffect((()=>{e.errors&&n._setErrors(e.errors)}),[e.errors,n]),t.useEffect((()=>{n._state.mount||(n._setValid(),n._state.mount=!0),n._state.watch&&(n._state.watch=!1,n._subjects.state.next({...n._formState})),n._removeUnmounted()})),t.useEffect((()=>{e.shouldUnregister&&n._subjects.state.next({values:n._getWatch()})}),[e.shouldUnregister,n]),r.current.formState=M(a,n),r.current},e.useFormContext=N,e.useFormState=U,e.useWatch=R})); | ||
//# sourceMappingURL=index.umd.js.map |
@@ -76,3 +76,3 @@ import React from 'react'; | ||
delayError: number; | ||
control?: Omit<UseFormReturn<TFieldValues, TContext>, 'formState'>; | ||
formControl?: Omit<UseFormReturn<TFieldValues, TContext>, 'formState'>; | ||
}>; | ||
@@ -79,0 +79,0 @@ export type FieldNamesMarkedBoolean<TFieldValues extends FieldValues> = DeepMap<DeepPartial<TFieldValues>, boolean>; |
{ | ||
"name": "react-hook-form", | ||
"description": "Performant, flexible and extensible forms library for React Hooks", | ||
"version": "7.55.0-next.0", | ||
"version": "7.55.0-next.1", | ||
"main": "dist/index.cjs.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.esm.mjs", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1115470