react-f0rm 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a as FieldPath, N as Name, F as Form$1, V as ValidationMode, P as PathValueOf, b as FieldError, c as Path, O as Options } from './form-7sbcY2uT.js';
2
- export { d as FieldErrorEntry, e as FieldState, f as FormValidateFn, g as FormValidateMeta, H as HandleSubmitOptions, h as PathValue, R as ReValidateMode, i as ResetFieldOptions, j as ResetOptions, S as SetFieldOptions, k as SetFocusOptions, l as SetServerErrorsOptions, m as VALIDATION_OUTCOME, n as ValidateResult, o as ValidationOutcome, p as changeValue, q as changeValueByPath, r as clearErrors, s as createForm, t as ensureValidate, u as getDirtyFields, v as getError, w as getErrorByPath, x as getErrors, y as getFieldErrors, z as getFieldErrorsByPath, A as getFieldState, B as getFirstError, C as getTouchedFields, D as getValue, E as getValueByPath, G as getValues, I as handleSubmit, J as hasErrors, K as hasTouched, L as hasTouchedByPath, M as incrementSubmitCount, Q as isDirty, T as isTouched, U as removeField, W as removeFieldByPath, X as reset, Y as resetField, Z as setDisabled, _ as setError, $ as setErrorByPath, a0 as setFocus, a1 as setInitialValues, a2 as setIsSubmitting, a3 as setServerErrors, a4 as setSubmitSuccessful, a5 as setTouched, a6 as setTouchedByPath, a7 as setValidatingByPath, a8 as setValue, a9 as setValueByPath, aa as trigger, ab as unsetValidatingByPath, ac as validate } from './form-7sbcY2uT.js';
3
- import { V as Validator } from './validate-DXGZBon4.js';
1
+ import { a as FieldPath, N as Name, F as Form$1, V as ValidationMode, P as PathValueOf, b as FieldError, c as Path, O as Options } from './form-BNqHYba-.js';
2
+ export { d as FieldErrorEntry, e as FieldState, f as FormValidateFn, g as FormValidateMeta, H as HandleSubmitOptions, h as PathValue, R as ReValidateMode, i as ResetFieldOptions, j as ResetOptions, S as SetFieldOptions, k as SetFocusOptions, l as SetServerErrorsOptions, m as VALIDATION_OUTCOME, n as ValidateResult, o as ValidationOutcome, p as changeValue, q as changeValueByPath, r as clearErrors, s as createForm, t as ensureValidate, u as getDirtyFields, v as getError, w as getErrorByPath, x as getErrors, y as getFieldErrors, z as getFieldErrorsByPath, A as getFieldState, B as getFirstError, C as getTouchedFields, D as getValue, E as getValueByPath, G as getValues, I as handleSubmit, J as hasErrors, K as hasTouched, L as hasTouchedByPath, M as incrementSubmitCount, Q as isDirty, T as isTouched, U as removeField, W as removeFieldByPath, X as reset, Y as resetField, Z as revalidateFormOnChange, _ as setDisabled, $ as setError, a0 as setErrorByPath, a1 as setFocus, a2 as setInitialValues, a3 as setIsSubmitting, a4 as setServerErrors, a5 as setSubmitSuccessful, a6 as setTouched, a7 as setTouchedByPath, a8 as setValidatingByPath, a9 as setValue, aa as setValueByPath, ab as trigger, ac as unsetValidatingByPath, ad as validate } from './form-BNqHYba-.js';
3
+ import { V as Validator } from './validate-CbteZ-Jb.js';
4
4
  import * as React from 'react';
5
5
  import { ReactNode } from 'react';
6
6
  import { EventEmitter } from '@for-fun/event-emitter';
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import*as e from"react";import t,{useCallback as n,useRef as r,useState as o,useEffect as i,useMemo as u,useContext as s,useReducer as a,createContext as c,createElement as l}from"react";function f(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];(e.get(t)||[]).forEach(function(e){return e.apply(void 0,r)})}function d(e,t,n){var r=function(e,t){var n=e.get(t);if(n)return n;var r=new Set;return e.set(t,r),r}(e,t);return r.add(n),function(){return r.delete(n)}}const m=new Map;function h(e){if(Array.isArray(e))return e;const t=m.get(e);if(t)return t;const n=function(e){const t=[];let n="";const r=()=>{t.push(n),n=""};for(let o=0;o<e.length;o++){const i=e[o];if("."===i)""!==n&&r();else if("["===i){""!==n&&r();const i=e[o+1];if('"'===i||"'"===i){const n=e.indexOf(i,o+2);if(-1===n)throw new TypeError(`Unterminated quote in path: ${e}`);if("]"!==e[n+1])throw new TypeError(`Expected "]" after quoted segment in path: ${e}`);t.push(e.slice(o+2,n)),o=n+1}else{const n=e.indexOf("]",o+1);if(-1===n)throw new TypeError(`Unterminated bracket in path: ${e}`);const r=e.slice(o+1,n);t.push(/^-?\d+$/.test(r)?Number(r):r),o=n}}else n+=i}""===n&&0!==t.length||r();return t}(e);return m.set(e,n),n}function y(e,t){return t.reduce((e,t)=>{if(null!=e)return e[t]},e)}function v(e,t){if(!t.length||null==e)return e;const[n,...r]=t;if(r.length){const t=v(e[n],r);return t===e[n]?e:p(e,[n],t)}if(Array.isArray(e)){if(!(n in e))return e;const t=e.slice();return delete t[n],t}if("object"!=typeof e||!(n in e))return e;const o={...e};return delete o[n],o}function p(e,t,n){if(!t.length)return n;const[r,...o]=t;if("number"==typeof r){const t=Array.isArray(e)?e.slice():[];return t[r]=p(t[r],o,n),t}return{...e,[r]:p(e&&e[r],o,n)}}function g(e,t,n,r){if(!t.length)return n;let o=e,i=null,u="";for(let s=0;s<t.length;s++){const a=t[s];if(!r.has(o)){let t;t="number"==typeof a?Array.isArray(o)?o.slice():[]:{...o},r.add(t),0===s?e=t:i[u]=t,o=t}s===t.length-1?o[a]=n:(i=o,u=a,o=o[a])}return e}function b(e){return e&&"function"==typeof e.then}function k(e,t){if(Object.is(e,t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(!e||!t||"object"!=typeof e||"object"!=typeof t)return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!k(e[n],t[n]))return!1;return!0}const r=Object.getPrototypeOf(e);if(r!==Object.prototype&&null!==r)return!1;if(Object.getPrototypeOf(t)!==r)return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const n of o)if(!k(e[n],t[n]))return!1;return!0}function S(e,t,n,r){return new Promise((o,i)=>{if(r())return void i();if(n())return void o();const u=d(e,t,()=>{if(r())return u(),void i();n()&&(u(),o())})})}function E(e){const t=h(e);return{value:t,key:JSON.stringify(t)}}const w=Symbol("validation-outcome");function V(e){return{emitter:new Map,...e,mode:e?.mode??"onSubmit",reValidateMode:e?.reValidateMode??"onChange",disabled:e?.disabled??!1,initialValues:e?.initialValues??{},values:new Map,deleted:new Set,errors:new Map,touched:new Set,validators:new Map,changeHandlers:new Map,validating:new Set,parsedValues:void 0,isSubmitting:!1,submitCount:0,isSubmitSuccessful:void 0}}function O(e){const{initialValues:t,parsedValues:n,values:r,deleted:o}=e,i=new Set;let u=n??t;for(const[e,t]of r)u=g(u,JSON.parse(e),t,i);for(const e of o)u=v(u,JSON.parse(e));return u}function _(e,t){return A(e,E(t))}function A({initialValues:e,parsedValues:t,values:n,deleted:r},o){return n.has(o.key)?n.get(o.key):r.has(o.key)?void 0:y(t??e,o.value)}function x(e,t,n,r){T(e,E(t),n,r)}function T(e,t,n,r){const{emitter:o,values:i,deleted:u}=e;i.set(t.key,n),le(u,t),function(e,{key:t}){const n=X.get(e);if(!n?.size)return;const r=`${t.slice(0,-1)},`;for(const e of n.keys())e.startsWith(r)&&n.delete(e)}(e,t),!1===r?.shouldDirty&&ee(e,t,n),re(e),r?.shouldTouch&&G(e,t),r?.shouldValidate&&e.validators.get(t.key)?.(),f(o,"change",t)}function C(e,t,n,r){L(e,E(t),n,r)}function L(e,t,n,r){!1===r?.shouldDirty&&ee(e,t,n);const o=e.changeHandlers.get(t.key);o?o(n):T(e,t,n,r)}function j(e,t){return D(e,E(t))}function D({errors:e},t){return e.get(t.key)?.[0]}const M=[];function N(e,t){return B(e,E(t))}function B({errors:e},t){return e.get(t.key)??M}function P({errors:e}){const t=[];for(const[n,r]of e){const e=JSON.parse(n).join(".");for(const{type:n,message:o}of r)t.push({path:e,type:n,message:o})}return t}function $({errors:e}){return e.values().next().value?.[0]?.message}function q(e,t){const n=E(t),{values:r,touched:o,validating:i}=e,u=r.get(n.key);return{value:A(e,n),error:D(e,n),errors:B(e,n),isDirty:r.has(n.key)&&Z(e,n.key,n.value)!==u,isTouched:o.has(n.key),isValidating:i.has(n.key)}}function H({emitter:e,validating:t},n){t.delete(n.key),f(e,"validating",n)}function I({emitter:e,validating:t},n){t.add(n.key),f(e,"validating",n)}function R(e,t,n){U(e,E(t),n)}function U({emitter:e,errors:t},n,r){const o=function(e){if("string"==typeof e)return e?[{type:"custom",message:e}]:void 0;if(pe(e))return[e];if(!e)return;const t=[];return e.forEach(e=>{"string"==typeof e&&e?t.push({type:"custom",message:e}):pe(e)&&t.push(e)}),t.length?t:void 0}(r);o?t.set(n.key,o):t.delete(n.key),f(e,"errors",n)}function F(e,t){const{emitter:n,errors:r}=e;if(void 0===t)return r.clear(),void f(n,"errors");const o="string"==typeof t||ve(t)?[E(t)]:t.map(e=>E(e));for(const{key:e}of o)r.delete(e);for(const e of o)f(n,"errors",e)}function J(e,t,n){n?.keepExisting||F(e);for(const[n,r]of Object.entries(t))R(e,n,(Array.isArray(r)?r:[r]).map(e=>({type:"server",message:e})))}function W(e,t){G(e,E(t))}function G({emitter:e,touched:t},n){t.has(n.key)||(t.add(n.key),f(e,"touched",n))}function K(e,t){return z(e,E(t))}function z({touched:e},t){return e.has(t.key)}function Y(e){let t=!1;return Q(e,()=>{t=!0}),t}function Q(e,t){for(const[n,r]of e.values){const o=JSON.parse(n);Z(e,n,o)!==r&&t(o.join("."))}}const X=new WeakMap;function Z(e,t,n){const r=X.get(e);return r?.has(t)?r.get(t):y(e.initialValues,n)}function ee(e,{key:t},n){let r=X.get(e);r||(r=new Map,X.set(e,r)),r.set(t,n)}function te(e,t){const n=X.get(e);n&&(void 0===t?n.clear():n.delete(t))}const ne=new WeakMap;function re(e){const t=ne.get(e);t&&t.version++}function oe(e){const t={};return Q(e,e=>{t[e]=!0}),t}function ie(e){let t=ne.get(e);if(t){if(t.version>0){const n=oe(e);(function(e,t){const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(e=>!0===t[e])})(t.result,n)||(t.result=n),t.version=0}}else t={version:0,result:oe(e)},ne.set(e,t);return t.result}function ue({touched:e}){return Array.from(e,e=>JSON.parse(e).join("."))}function se({touched:e}){return e.size>0}function ae(e,t){ce(e,E(t))}function ce(e,{key:t,value:n}){const{emitter:r,values:o,touched:i,errors:u,validating:s,deleted:a}=e;o.delete(t),i.delete(t),u.delete(t),s.delete(t),te(e,t),function(e,t){for(let n=1;n<t.length;n++)if(e.has(JSON.stringify(t.slice(0,n))))return!0;const n=`${JSON.stringify(t).slice(0,-1)},`;for(const t of e.keys())if(t.startsWith(n))return!0;return!1}(o,n)||a.add(t),re(e),f(r,"change"),f(r,"touched"),f(r,"errors"),f(r,"validating")}function le(e,{key:t}){if(e.size)for(const n of e)(n===t||n.startsWith(`${t.slice(0,-1)},`)||t.startsWith(`${n.slice(0,-1)},`))&&e.delete(n)}function fe(e,t){e.initialValues===t||k(e.initialValues,t)||(e.initialValues=t,e.parsedValues=void 0,e.values.clear(),e.deleted.clear(),te(e),re(e),f(e.emitter,"change"))}function de(e,t,n){const r=n?.keepDirtyValues?Object.keys(ie(e)).map(t=>({key:t,value:_(e,t)})):[];e.initialValues=t,e.parsedValues=void 0,n?.keepErrors||F(e);const{emitter:o,touched:i,values:u,deleted:s,validating:a}=e;u.clear(),s.clear(),te(e),n?.keepTouched||i.clear(),a.clear(),n?.keepIsSubmitting||(e.isSubmitting=!1),n?.keepSubmitCount||(e.submitCount=0),n?.keepIsSubmitted||(e.isSubmitSuccessful=void 0),re(e);for(const{key:t,value:n}of r)T(e,E(t),n);f(o,"change"),f(o,"touched"),f(o,"validating"),f(o,"submitting"),f(o,"submitCount"),f(o,"submitSuccessful"),f(o,"reset")}function me(e,t,n){const r=E(t),{emitter:o,values:i,touched:u,errors:s,deleted:a}=e;if(i.delete(r.key),te(e,r.key),void 0!==e.parsedValues){e.parsedValues=v(e.parsedValues,r.value);const t=y(e.initialValues,r.value);void 0!==t&&i.set(r.key,t)}n&&"value"in n&&i.set(r.key,n.value),le(a,r),f(o,"change"),!n?.keepTouched&&u.delete(r.key)&&f(o,"touched",r),!n?.keepErrors&&s.delete(r.key)&&f(o,"errors",r),re(e)}function he({errors:e}){return e.size>0}async function ye(e,t){const n=()=>S(e.emitter,"validating",()=>Se(e),()=>!1);if(void 0===t)return e.validators.forEach(e=>e()),await n(),e.validate&&await Ve(e),!he(e);const r="string"==typeof t||ve(t)?[E(t).key]:t.map(e=>E(e).key);return r.forEach(t=>e.validators.get(t)?.()),await n(),r.every(t=>!e.errors.has(t))}function ve(e){return e.some(e=>"number"==typeof e)}function pe(e){return!!e&&"object"==typeof e&&"string"==typeof e.type&&"string"==typeof e.message}function ge(e,t,n=[]){Object.entries(t).forEach(([t,r])=>{const o=[...n,...h(t)];"string"==typeof r?r&&R(e,o,r):Array.isArray(r)||pe(r)?R(e,o,r):r&&"object"==typeof r&&ge(e,r,o)})}function be(e,t){if(t){if("object"==typeof t&&w in t){const n=t;return n.errors&&ge(e,n.errors),void function(e,t){void 0!==t&&t!==e.parsedValues&&(e.parsedValues=t,f(e.emitter,"change"))}(e,n.values)}ge(e,t)}}const ke="__form_validate__";function Se(e){for(const t of e.validating)if(t!==ke)return!1;return!0}const Ee=Symbol("form-validate-settled"),we=new WeakMap;function Ve(e){const t=e.validate;if(!t)return Promise.resolve();const n=e.validateDebounce??0;if(n<=0){const n=new AbortController;return Promise.resolve(t(O(e),{form:e,signal:n.signal})).then(t=>{be(e,t)})}const r=function(e){let t=we.get(e);return t||(t={timer:null,controller:null,round:null,marked:!1,waiters:[]},we.set(e,t)),t}(e);return null!==r.timer?clearTimeout(r.timer):(r.marked=!0,e.validating.add(ke),f(e.emitter,"validating")),r.timer=setTimeout(()=>{r.timer=null;const t=r.round={};(function(e,t,n){const r=e.validate;if(!r)return Promise.resolve();t.controller?.abort();const o=t.controller=new AbortController;let i;try{i=Promise.resolve(r(O(e),{form:e,signal:o.signal}))}catch(e){i=Promise.reject(e)}return i.then(r=>{t.round===n&&be(e,r)},e=>{if(t.round===n)throw e})})(e,r,t).then(()=>Oe(e,r,t,Ee),n=>Oe(e,r,t,n))},n),new Promise((e,t)=>{r.waiters.push({resolve:e,reject:t})})}function Oe(e,t,n,r){if(t.round!==n)return;if(t.round=null,null!==t.timer)return;t.marked&&(t.marked=!1,e.validating.delete(ke),f(e.emitter,"validating"));const o=t.waiters;t.waiters=[];for(const e of o)r===Ee?e.resolve():e.reject(r)}async function _e(e){if(e.validators.forEach(e=>e()),await S(e.emitter,"validating",()=>Se(e),()=>he(e)).catch(()=>{throw new Error($(e))}),e.validate&&(await Ve(e),he(e)))throw new Error($(e))}async function Ae(e){return _e(e).catch(e=>e.message)}function xe(e,t){e.isSubmitting=t,f(e.emitter,"submitting")}function Te(e){e.submitCount++,f(e.emitter,"submitCount")}function Ce(e,t){e.isSubmitSuccessful=t,f(e.emitter,"submitSuccessful")}function Le(e,t){e.disabled=t,f(e.emitter,"disabled")}function je(e){if(e.startsWith("["))try{const t=JSON.parse(e);if(Array.isArray(t))return t.join(".")}catch{}return e}function De(e,t){const{onSubmit:n,onValidSubmit:r,onInvalidSubmit:o,shouldFocusError:i=!0}=t??{};return async t=>{t&&"function"==typeof t.preventDefault&&t.preventDefault();const u=t?.currentTarget;xe(e,!0),Te(e);const s=O(e);if(u&&"function"==typeof u.checkValidity&&!1===u.checkValidity()){if(u.reportValidity(),i&&"function"==typeof u.querySelector){const e=u.querySelector(":invalid");e&&"function"==typeof e.focus&&e.focus()}return xe(e,!1),Ce(e,!1),void(o&&o(function(e){const t=[],{elements:n}=e;for(let e=0;e<n.length;e++){const r=n[e];r.name&&"function"==typeof r.checkValidity&&!r.checkValidity()&&t.push({path:je(r.name),type:"native",message:r.validationMessage})}return t}(u),s))}if(await Ae(e)){if(xe(e,!1),Ce(e,!1),i){const t=e.errors.keys().next().value;void 0!==t&&f(e.emitter,"focusError",t)}o&&o(P(e),s)}else try{const o=O(e);n&&await n(o,t),r&&await r(o,t),Ce(e,!0)}catch{Ce(e,!1)}finally{xe(e,!1)}}}function Me(e,t,n){const{key:r}=E(t);n?f(e.emitter,"focusError",r,n):f(e.emitter,"focusError",r)}function Ne(e,t){switch(e){case"required":return"This field is required";case"min":return`Must be at least ${t}`;case"max":return`Must be at most ${t}`;case"minLength":return`Must be at least ${t} characters`;case"maxLength":return`Must be at most ${t} characters`;case"pattern":return"Invalid format";default:return"Invalid value"}}var Be,Pe={exports:{}},$e={};var qe,He,Ie={};var Re=(He||(He=1,"production"===process.env.NODE_ENV?Pe.exports=function(){if(Be)return $e;Be=1;var e=t,n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=e.useState,o=e.useEffect,i=e.useLayoutEffect,u=e.useDebugValue;function s(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!n(e,r)}catch(e){return!0}}var a="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),a=r({inst:{value:n,getSnapshot:t}}),c=a[0].inst,l=a[1];return i(function(){c.value=n,c.getSnapshot=t,s(c)&&l({inst:c})},[e,n,t]),o(function(){return s(c)&&l({inst:c}),e(function(){s(c)&&l({inst:c})})},[e]),u(n),n};return $e.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:a,$e}():Pe.exports=(qe||(qe=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=t,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useState,i=n.useEffect,u=n.useLayoutEffect,s=n.useDebugValue,a=!1,c=!1,l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,l){a||void 0===n.startTransition||(a=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var f=l();if(!c){var d=l();r(f,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}var m=(d=o({inst:{value:f,getSnapshot:l}}))[0].inst,h=d[1];return u(function(){m.value=f,m.getSnapshot=l,e(m)&&h({inst:m})},[t,f,l]),i(function(){return e(m)&&h({inst:m}),t(function(){e(m)&&h({inst:m})})},[t]),s(f),f};Ie.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:l,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ie)),Pe.exports);function Ue(e,t){return e.startsWith(`${t.slice(0,-1)},`)}function Fe(e,t,n,r,o){const{key:i}=n;return d(e,t,e=>{(void 0===e||e.key===i||Ue(i,e.key)||"branch"===r&&Ue(e.key,i))&&o()})}function Je(e,t,n,r){return d(e,t,e=>{void 0!==e&&e.key!==n||r()})}function We(e,t){const{name:n,event:r="change",scope:o="branch",callback:i}=t;if(void 0===n)return d(e.emitter,r,i);const u=function(e){return Array.isArray(e)&&e.every(e=>"number"!=typeof e)}(n)?n:[n],s=u.map(t=>{const n=E(t);return"errors"===r||"touched"===r?Je(e.emitter,r,n.key,i):Fe(e.emitter,r,n,o,i)});return 1===s.length?s[0]:()=>s.forEach(e=>e())}function Ge(e){const[t]=o(()=>{const t=V(e);return e&&void 0!==e.values&&fe(t,e.values),t}),n=e&&e.initialValues,u=e&&e.values,s=r(null);null===s.current&&(s.current={done:!1,source:void 0}),i(()=>{const e=s.current;e.done&&(e.source===n||k(e.source,n))||(e.done=!0,e.source=n,fe(t,n))},[t,n]);const a=r(null);return null===a.current&&(a.current={done:!1,source:void 0}),i(()=>{if(void 0===u)return;const e=a.current;e.done&&(e.source===u||k(e.source,u))||(e.done=!0,e.source=u,fe(t,u))},[t,u]),t}function Ke(e,t){const o=r(null);null===o.current&&(o.current={hasValue:!1});const i=o.current,u=r(t);u.current=t;const s=n(()=>(i.hasValue||(i.value=u.current(),i.hasValue=!0),i.value),[i]),a=n(t=>{i.hasValue=!1;return e(()=>{i.hasValue=!1,t()})},[e,i]);return Re.useSyncExternalStore(a,s,s)}function ze(e,t,r){return Ke(n(n=>d(e,t,n),[e,t]),r)}function Ye(e,t){return Qe(e,E(t))}function Qe(e,t){const{emitter:r}=e,{key:o}=t;return Ke(n(e=>Fe(r,"change",t,"leaf",e),[r,o]),A.bind(null,e,t))}function Xe(e,t){return Ze(e,E(t))}function Ze(e,t){const{emitter:r}=e,{key:o}=t;return Ke(n(e=>Je(r,"touched",o,e),[r,o]),z.bind(null,e,t))}function et(e,t){return tt(e,E(t))?.message}function tt(e,t){const{emitter:r}=e,{key:o}=t;return Ke(n(e=>Je(r,"errors",o,e),[r,o]),D.bind(null,e,t))}function nt(e,t){return rt(e,E(t))}function rt(e,t){const{emitter:r}=e,{key:o}=t;return Ke(n(e=>Je(r,"errors",o,e),[r,o]),B.bind(null,e,t))}function ot(e){return ze(e.emitter,"change",Y.bind(null,e))}function it(e){return ze(e.emitter,"change",ie.bind(null,e))}function ut(e){return ze(e.emitter,"touched",ue.bind(null,e))}function st(e){return ze(e.emitter,"errors",he.bind(null,e))}function at(e){return ze(e.emitter,"submitting",()=>e.isSubmitting)}function ct(e){const{emitter:t}=e;return Ke(n(e=>{const n=d(t,"errors",e),r=d(t,"submitting",e);return()=>{n(),r()}},[t]),()=>!e.isSubmitting&&!he(e))}function lt(e){return ze(e.emitter,"submitCount",()=>e.submitCount)}function ft(e){const t=u(()=>E(h(e)),[e]);return u(()=>t,[t.key])}function dt(e){const t=function(e){const t=r(e);return t.current=e,t}(e);return n((...e)=>t.current(...e),[t])}function mt(e,t){if(!e)return t;const n=function(e){return t=>{if(e.required&&(""===t||null==t))return[{type:"required",message:"string"==typeof e.required?e.required:Ne("required")}];const n=[],r=(t,n)=>e.messages?.[t]??Ne(t,n);if(void 0!==e.min){const o=Number(t);!Number.isNaN(o)&&o<e.min&&n.push({type:"min",message:r("min",e.min)})}if(void 0!==e.max){const o=Number(t);!Number.isNaN(o)&&o>e.max&&n.push({type:"max",message:r("max",e.max)})}return void 0!==e.minLength&&"string"==typeof t&&t.length<e.minLength&&n.push({type:"minLength",message:r("minLength",e.minLength)}),void 0!==e.maxLength&&"string"==typeof t&&t.length>e.maxLength&&n.push({type:"maxLength",message:r("maxLength",e.maxLength)}),e.pattern&&!e.pattern.value.test(t)&&n.push({type:"pattern",message:e.messages?.pattern??e.pattern.message??Ne("pattern")}),n.length?n:void 0}}(e);return t?(e,r)=>{const o=n(e,r),i=e=>{const t=[...o??[]];return Array.isArray(e)?t.push(...e):e&&t.push(e),t.length?t:void 0},u=t(e,r);return b(u)?u.then(i):i(u)}:n}function ht({form:e,name:t,initialValue:n,shouldUnregister:u,validate:a,rules:c,validateDebounce:l,delayError:f,disabled:d,mode:m},h){const y=s(h),v=e||y;if(!v)throw new Error("no form provided");const p=ft(t),g=function(e,t,n,o){const u=s(kt),a=n||u;if(!a)throw new Error("no form provided");const c=r(null),l=r(e);l.current=e;const f=r(o?.debounce??0);return f.current=o?.debounce??0,i(()=>{let e=null,n=null,r=!1;const o=()=>{r||(r=!0,I(a,t))},i=()=>{r&&(r=!1,H(a,t))},u=()=>{e=null;const r=l.current;if(!r)return void i();n?.abort(),n=new AbortController;const u=c.current={};let s;try{s=r(A(a,t),{form:a,path:t,signal:n.signal})}catch(e){throw i(),e}if(!b(s))return U(a,t,s),void i();o(),s.then(e=>{u===c.current&&U(a,t,e)}).catch(()=>{}).finally(()=>{u===c.current&&(i(),c.current=null)})};return a.validators.set(t.key,()=>{const t=f.current;if(t>0)return null!==e?clearTimeout(e):o(),void(e=setTimeout(u,t));u()}),()=>{a.validators.delete(t.key),null!==e&&(clearTimeout(e),e=null),i(),n?.abort()}},[a,t.key]),dt(()=>a.validators.get(t.key)?.())}(mt(c,a),p,v,{debounce:l}),k=rt(v,p),S=function(e,t){const[n,r]=o(e);return i(()=>{if(void 0===t)return;if(0===e.length)return void r(e);if(n.length>0)return void r(e);const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t,n]),void 0===t?e:n}(k,f),E=S[0],w=E?.message,V=Qe(v,p),O=ze(v.emitter,"disabled",()=>v.disabled),_=m??v.mode;i(()=>{void 0!==n&&void 0===A(v,p)&&T(v,p,n)},[v,p,n]);const x=dt(e=>{T(v,p,e),("onChange"===_||"all"===_||"onTouched"===_&&z(v,p)||k.length>0&&"onChange"===v.reValidateMode)&&g()});i(()=>(v.changeHandlers.set(p.key,x),()=>{v.changeHandlers.get(p.key)===x&&v.changeHandlers.delete(p.key)}),[v,p.key,x]);const C=dt(()=>{G(v,p),("onBlur"===_||"onTouched"===_||"all"===_||k.length>0&&"onBlur"===v.reValidateMode)&&g()});return i(()=>()=>{!1!==u&&ce(v,p)},[p,v,u]),{form:v,value:V,error:w,errorObject:E,errors:S,onChange:x,onBlur:C,name:p.key,disabled:O||!!d}}function yt(e){return ht(e,kt)}let vt=0;function pt(){return"_"+ ++vt}function gt(e,t){const o=s(t),u=e.form||o;if(!u)throw new Error("no form provided");const c=ft(e.name),l=r([]),f=n(()=>A(u,c)||[],[u,c]),d=n(e=>{T(u,c,e)},[u,c]),m=n(()=>{const e=f();for(;l.current.length<e.length;)l.current.push(pt());for(;l.current.length>e.length;)l.current.pop();return l.current.map((e,t)=>({id:e,index:t}))},[f]),[h,y]=a(m,void 0,m);i(()=>Fe(u.emitter,"change",c,"branch",y),[u.emitter,c]);return{fields:h,append:dt(e=>{const t=f();l.current.push(pt()),d([...t,e])}),prepend:dt(e=>{const t=f();l.current.unshift(pt()),d([e,...t])}),insert:dt((e,t)=>{const n=f();l.current.splice(e,0,pt());const r=[...n.slice(0,e),t,...n.slice(e)];d(r)}),remove:dt(e=>{const t=f();l.current.splice(e,1);const n=t.filter((t,n)=>n!==e);d(n)}),swap:dt((e,t)=>{const n=f();[l.current[e],l.current[t]]=[l.current[t],l.current[e]];const r=[...n];[r[e],r[t]]=[r[t],r[e]],d(r)}),move:dt((e,t)=>{const n=f(),[r]=l.current.splice(e,1);l.current.splice(t,0,r);const o=[...n],[i]=o.splice(e,1);o.splice(t,0,i),d(o)}),replace:dt(e=>{l.current=e.map(()=>pt()),d([...e])}),update:dt((e,t)=>{const n=f();if(e<0||e>=n.length)return;const r=[...n];r[e]=t,d(r)})}}function bt(e){return gt(e,kt)}const kt=c(null),St=kt.Provider;function Et(){const e=s(kt);if(!e)throw new Error("no form provided");return e}function wt(){const e=c(null);return{context:e,FormProvider:function({form:t,children:n}){return l(e.Provider,{value:t},n)},useFormContext:function(){const t=s(e);if(!t)throw new Error("no form provided");return t},useField:function(t){return ht(t,e)},useFieldArray:function(t){return gt(t,e)}}}const Vt=c(null),Ot=Vt.Provider;function _t(){const e=s(Vt);if(!e)throw new Error("no group provided");return e}function At({form:t,context:n,initialValues:r,values:o,onSubmit:i,onValidSubmit:u,onInvalidSubmit:s,shouldFocusError:a,...c}){const l=Ge({initialValues:r,values:o}),f=t||l,d=De(f,{onSubmit:i,onValidSubmit:u,onInvalidSubmit:s,shouldFocusError:a}),{Provider:m}=n??kt;return e.createElement(m,{value:f},e.createElement("form",{...c,noValidate:!0,onSubmit:d}))}function xt(e){return e.replace(/["'[\],\s]+/g,"-").replace(/^-+|-+$/g,"")||"field"}function Tt(e,t,n){return{"aria-invalid":!!e||n["aria-invalid"],"aria-describedby":e?[n["aria-describedby"],xt(t)].filter(Boolean).join(" "):n["aria-describedby"]}}function Ct(e){return xt(E(e).key)}const Lt=e.forwardRef(({validate:t,eventToValue:n,initialValue:r,name:o,asProps:i,renderError:u,as:s,valueToProps:a,form:c,shouldUnregister:l,rules:f,validateDebounce:m,disabled:h,delayError:y,mode:v,...p},g)=>{const b=e.useRef(null),[k,S]=e.useState(0),E=e.useCallback(e=>{b.current=e,function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(g,e)},[g]),{value:w,onChange:V,onBlur:O,error:_,form:A,name:x,disabled:T}=yt({name:o,form:c,initialValue:r,shouldUnregister:l,rules:f,validateDebounce:m,delayError:y,disabled:h,mode:v,validate:(...e)=>{const n=b.current;if(!n||"function"!=typeof n.checkValidity||(n.setCustomValidity(""),!1!==n.checkValidity()))return t?t(...e):void 0;S(e=>e+1)}}),C=s||"input";e.useEffect(()=>{const e=b.current;e&&"function"==typeof e.setCustomValidity&&("string"==typeof _?(e.setCustomValidity(_),e.reportValidity()):e.setCustomValidity(""))},[_]),e.useEffect(()=>{k>0&&b.current?.reportValidity()},[k]),e.useEffect(()=>d(A.emitter,"focusError",(e,t)=>{if(e!==x)return;const n=b.current;n&&"function"==typeof n.focus&&(n.focus(),t?.shouldSelect&&"function"==typeof n.select&&n.select())}),[A,x]);const L=n??(e=>e.target.value),j=xt(x);return e.createElement(e.Fragment,null,e.createElement(C,{...p,name:x,onBlur:O,...i,...a?a(w):{value:w},...Tt(_,x,p),disabled:T,onChange:e=>V(L(e)),ref:E}),_&&u?e.createElement("span",{id:j,role:"alert"},u(_,j)):null)}),jt=e.forwardRef(({name:t,form:n,initialValue:r,shouldUnregister:o,validate:i,rules:u,validateDebounce:s,disabled:a,delayError:c,mode:l,...f},d)=>{const{value:m,onChange:h,onBlur:y,error:v,name:p,disabled:g}=yt({name:t,form:n,initialValue:r,shouldUnregister:o,validate:i,rules:u,validateDebounce:s,delayError:c,disabled:a,mode:l});return e.createElement("input",{...f,name:p,onBlur:y,type:"checkbox",checked:!!m,...Tt(v,p,f),disabled:g,onChange:e=>h(e.target.checked),ref:d})});function Dt(e,t){return e?Array.isArray(t)?t:[]:t??""}const Mt=e.forwardRef(({name:t,multiple:n,children:r,form:o,initialValue:i,shouldUnregister:u,validate:s,rules:a,validateDebounce:c,disabled:l,delayError:f,mode:d,...m},h)=>{const{value:y,onChange:v,onBlur:p,error:g,name:b,disabled:k}=yt({name:t,form:o,initialValue:i,shouldUnregister:u,validate:s,rules:a,validateDebounce:c,delayError:f,disabled:l,mode:d});return e.createElement("select",{...m,name:b,onBlur:p,multiple:n,value:Dt(n,y),...Tt(g,b,m),disabled:k,onChange:e=>v(n?Array.from(e.target.selectedOptions,e=>e.value):e.target.value),ref:h},r)});export{jt as Checkbox,Vt as CheckboxGroupContext,Ot as CheckboxGroupProvider,Lt as Field,At as Form,kt as FormContext,St as FormProvider,Mt as Select,w as VALIDATION_OUTCOME,C as changeValue,L as changeValueByPath,F as clearErrors,V as createForm,wt as createFormContext,_e as ensureValidate,Ct as fieldErrorId,ie as getDirtyFields,j as getError,D as getErrorByPath,P as getErrors,N as getFieldErrors,B as getFieldErrorsByPath,q as getFieldState,$ as getFirstError,ue as getTouchedFields,_ as getValue,A as getValueByPath,O as getValues,De as handleSubmit,he as hasErrors,K as hasTouched,z as hasTouchedByPath,Te as incrementSubmitCount,Y as isDirty,se as isTouched,ae as removeField,ce as removeFieldByPath,de as reset,me as resetField,Le as setDisabled,R as setError,U as setErrorByPath,Me as setFocus,fe as setInitialValues,xe as setIsSubmitting,J as setServerErrors,Ce as setSubmitSuccessful,W as setTouched,G as setTouchedByPath,I as setValidatingByPath,x as setValue,T as setValueByPath,We as subscribe,ye as trigger,H as unsetValidatingByPath,ct as useCanSubmit,_t as useCheckboxGroupContext,it as useDirtyFields,et as useError,tt as useErrorByPath,yt as useField,bt as useFieldArray,nt as useFieldErrors,rt as useFieldErrorsByPath,Ge as useForm,Et as useFormContext,st as useHasErrors,ot as useIsDirty,at as useIsSubmitting,lt as useSubmitCount,Xe as useTouched,Ze as useTouchedByPath,ut as useTouchedFields,Ye as useValue,Qe as useValueByPath,ze as useWatch,Ae as validate};
1
+ import*as e from"react";import t,{useCallback as n,useRef as r,useState as o,useEffect as i,useMemo as u,useContext as s,useReducer as a,createContext as c,createElement as l}from"react";function f(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];(e.get(t)||[]).forEach(function(e){return e.apply(void 0,r)})}function d(e,t,n){var r=function(e,t){var n=e.get(t);if(n)return n;var r=new Set;return e.set(t,r),r}(e,t);return r.add(n),function(){return r.delete(n)}}const m=new Map;function h(e){if(Array.isArray(e))return e;const t=m.get(e);if(t)return t;const n=function(e){const t=[];let n="";const r=()=>{t.push(n),n=""};for(let o=0;o<e.length;o++){const i=e[o];if("."===i)""!==n&&r();else if("["===i){""!==n&&r();const i=e[o+1];if('"'===i||"'"===i){const n=e.indexOf(i,o+2);if(-1===n)throw new TypeError(`Unterminated quote in path: ${e}`);if("]"!==e[n+1])throw new TypeError(`Expected "]" after quoted segment in path: ${e}`);t.push(e.slice(o+2,n)),o=n+1}else{const n=e.indexOf("]",o+1);if(-1===n)throw new TypeError(`Unterminated bracket in path: ${e}`);const r=e.slice(o+1,n);t.push(/^-?\d+$/.test(r)?Number(r):r),o=n}}else n+=i}""===n&&0!==t.length||r();return t}(e);return m.set(e,n),n}function v(e,t){return t.reduce((e,t)=>{if(null!=e)return e[t]},e)}function y(e,t){if(!t.length||null==e)return e;const[n,...r]=t;if(r.length){const t=y(e[n],r);return t===e[n]?e:p(e,[n],t)}if(Array.isArray(e)){if(!(n in e))return e;const t=e.slice();return delete t[n],t}if("object"!=typeof e||!(n in e))return e;const o={...e};return delete o[n],o}function p(e,t,n){if(!t.length)return n;const[r,...o]=t;if("number"==typeof r){const t=Array.isArray(e)?e.slice():[];return t[r]=p(t[r],o,n),t}return{...e,[r]:p(e&&e[r],o,n)}}function g(e,t,n,r){if(!t.length)return n;let o=e,i=null,u="";for(let s=0;s<t.length;s++){const a=t[s];if(!r.has(o)){let t;t="number"==typeof a?Array.isArray(o)?o.slice():[]:{...o},r.add(t),0===s?e=t:i[u]=t,o=t}s===t.length-1?o[a]=n:(i=o,u=a,o=o[a])}return e}function b(e){return e&&"function"==typeof e.then}function k(e,t){if(Object.is(e,t))return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(!e||!t||"object"!=typeof e||"object"!=typeof t)return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!k(e[n],t[n]))return!1;return!0}const r=Object.getPrototypeOf(e);if(r!==Object.prototype&&null!==r)return!1;if(Object.getPrototypeOf(t)!==r)return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const n of o)if(!k(e[n],t[n]))return!1;return!0}function S(e,t,n,r){return new Promise((o,i)=>{if(r())return void i();if(n())return void o();const u=d(e,t,()=>{if(r())return u(),void i();n()&&(u(),o())})})}function w(e){const t=h(e);return{value:t,key:JSON.stringify(t)}}const E=Symbol("validation-outcome");function V(e){return{emitter:new Map,...e,mode:e?.mode??"onSubmit",reValidateMode:e?.reValidateMode??"onChange",disabled:e?.disabled??!1,validateDeps:e?.validateDeps?new Set(e.validateDeps.map(e=>w(e).key)):void 0,initialValues:e?.initialValues??{},values:new Map,deleted:new Set,errors:new Map,touched:new Set,validators:new Map,changeHandlers:new Map,validating:new Set,parsedValues:void 0,isSubmitting:!1,submitCount:0,isSubmitSuccessful:void 0}}function O(e){const{initialValues:t,parsedValues:n,values:r,deleted:o}=e,i=new Set;let u=n??t;for(const[e,t]of r)u=g(u,JSON.parse(e),t,i);for(const e of o)u=y(u,JSON.parse(e));return u}function _(e,t){return A(e,w(t))}function A({initialValues:e,parsedValues:t,values:n,deleted:r},o){return n.has(o.key)?n.get(o.key):r.has(o.key)?void 0:v(t??e,o.value)}function T(e,t,n,r){x(e,w(t),n,r)}function x(e,t,n,r){const{emitter:o,values:i,deleted:u}=e;i.set(t.key,n),le(u,t),function(e,{key:t}){const n=X.get(e);if(!n?.size)return;const r=`${t.slice(0,-1)},`;for(const e of n.keys())e.startsWith(r)&&n.delete(e)}(e,t),!1===r?.shouldDirty&&ee(e,t,n),re(e),r?.shouldTouch&&G(e,t),r?.shouldValidate&&e.validators.get(t.key)?.(),f(o,"change",t)}function C(e,t,n,r){L(e,w(t),n,r)}function L(e,t,n,r){!1===r?.shouldDirty&&ee(e,t,n);const o=e.changeHandlers.get(t.key);o?o(n):x(e,t,n,r)}function D(e,t){return j(e,w(t))}function j({errors:e},t){return e.get(t.key)?.[0]}const M=[];function N(e,t){return B(e,w(t))}function B({errors:e},t){return e.get(t.key)??M}function P({errors:e}){const t=[];for(const[n,r]of e){const e=JSON.parse(n).join(".");for(const{type:n,message:o}of r)t.push({path:e,type:n,message:o})}return t}function $({errors:e}){return e.values().next().value?.[0]?.message}function q(e,t){const n=w(t),{values:r,touched:o,validating:i}=e,u=r.get(n.key);return{value:A(e,n),error:j(e,n),errors:B(e,n),isDirty:r.has(n.key)&&Z(e,n.key,n.value)!==u,isTouched:o.has(n.key),isValidating:i.has(n.key)}}function H({emitter:e,validating:t},n){t.delete(n.key),f(e,"validating",n)}function I({emitter:e,validating:t},n){t.add(n.key),f(e,"validating",n)}function R(e,t,n){J(e,w(t),n)}function J({emitter:e,errors:t},n,r){const o=function(e){if("string"==typeof e)return e?[{type:"custom",message:e}]:void 0;if(pe(e))return[e];if(!e)return;const t=[];return e.forEach(e=>{"string"==typeof e&&e?t.push({type:"custom",message:e}):pe(e)&&t.push(e)}),t.length?t:void 0}(r);o?t.set(n.key,o):t.delete(n.key),f(e,"errors",n)}function U(e,t){const{emitter:n,errors:r}=e;if(void 0===t)return r.clear(),void f(n,"errors");const o="string"==typeof t||ye(t)?[w(t)]:t.map(e=>w(e));for(const{key:e}of o)r.delete(e);for(const e of o)f(n,"errors",e)}function W(e,t,n){n?.keepExisting||U(e);for(const[n,r]of Object.entries(t))R(e,n,(Array.isArray(r)?r:[r]).map(e=>({type:"server",message:e})))}function F(e,t){G(e,w(t))}function G({emitter:e,touched:t},n){t.has(n.key)||(t.add(n.key),f(e,"touched",n))}function K(e,t){return z(e,w(t))}function z({touched:e},t){return e.has(t.key)}function Y(e){let t=!1;return Q(e,()=>{t=!0}),t}function Q(e,t){for(const[n,r]of e.values){const o=JSON.parse(n);Z(e,n,o)!==r&&t(o.join("."))}}const X=new WeakMap;function Z(e,t,n){const r=X.get(e);return r?.has(t)?r.get(t):v(e.initialValues,n)}function ee(e,{key:t},n){let r=X.get(e);r||(r=new Map,X.set(e,r)),r.set(t,n)}function te(e,t){const n=X.get(e);n&&(void 0===t?n.clear():n.delete(t))}const ne=new WeakMap;function re(e){const t=ne.get(e);t&&t.version++}function oe(e){const t={};return Q(e,e=>{t[e]=!0}),t}function ie(e){let t=ne.get(e);if(t){if(t.version>0){const n=oe(e);(function(e,t){const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(e=>!0===t[e])})(t.result,n)||(t.result=n),t.version=0}}else t={version:0,result:oe(e)},ne.set(e,t);return t.result}function ue({touched:e}){return Array.from(e,e=>JSON.parse(e).join("."))}function se({touched:e}){return e.size>0}function ae(e,t){ce(e,w(t))}function ce(e,{key:t,value:n}){const{emitter:r,values:o,touched:i,errors:u,validating:s,deleted:a}=e;o.delete(t),i.delete(t),u.delete(t),s.delete(t),te(e,t),function(e,t){for(let n=1;n<t.length;n++)if(e.has(JSON.stringify(t.slice(0,n))))return!0;const n=`${JSON.stringify(t).slice(0,-1)},`;for(const t of e.keys())if(t.startsWith(n))return!0;return!1}(o,n)||a.add(t),re(e),f(r,"change"),f(r,"touched"),f(r,"errors"),f(r,"validating")}function le(e,{key:t}){if(e.size)for(const n of e)(n===t||n.startsWith(`${t.slice(0,-1)},`)||t.startsWith(`${n.slice(0,-1)},`))&&e.delete(n)}function fe(e,t){e.initialValues===t||k(e.initialValues,t)||(e.initialValues=t,e.parsedValues=void 0,e.values.clear(),e.deleted.clear(),te(e),re(e),f(e.emitter,"change"))}function de(e,t,n){const r=n?.keepDirtyValues?Object.keys(ie(e)).map(t=>({key:t,value:_(e,t)})):[];e.initialValues=t,e.parsedValues=void 0,n?.keepErrors||U(e);const{emitter:o,touched:i,values:u,deleted:s,validating:a}=e;u.clear(),s.clear(),te(e),n?.keepTouched||i.clear(),a.clear(),n?.keepIsSubmitting||(e.isSubmitting=!1),n?.keepSubmitCount||(e.submitCount=0),n?.keepIsSubmitted||(e.isSubmitSuccessful=void 0),re(e);for(const{key:t,value:n}of r)x(e,w(t),n);f(o,"change"),f(o,"touched"),f(o,"validating"),f(o,"submitting"),f(o,"submitCount"),f(o,"submitSuccessful"),f(o,"reset")}function me(e,t,n){const r=w(t),{emitter:o,values:i,touched:u,errors:s,deleted:a}=e;if(i.delete(r.key),te(e,r.key),void 0!==e.parsedValues){e.parsedValues=y(e.parsedValues,r.value);const t=v(e.initialValues,r.value);void 0!==t&&i.set(r.key,t)}n&&"value"in n&&i.set(r.key,n.value),le(a,r),f(o,"change"),!n?.keepTouched&&u.delete(r.key)&&f(o,"touched",r),!n?.keepErrors&&s.delete(r.key)&&f(o,"errors",r),re(e)}function he({errors:e}){return e.size>0}async function ve(e,t){const n=()=>S(e.emitter,"validating",()=>Ee(e),()=>!1);if(void 0===t)return e.validators.forEach(e=>e()),await n(),e.validate&&await _e(e),!he(e);const r="string"==typeof t||ye(t)?[w(t).key]:t.map(e=>w(e).key);return r.forEach(t=>e.validators.get(t)?.()),await n(),r.every(t=>!e.errors.has(t))}function ye(e){return e.some(e=>"number"==typeof e)}function pe(e){return!!e&&"object"==typeof e&&"string"==typeof e.type&&"string"==typeof e.message}function ge(e,t,n=[],r){Object.entries(t).forEach(([t,o])=>{const i=[...n,...h(t)];"string"==typeof o?o&&(R(e,i,o),be(e,i,r)):Array.isArray(o)||pe(o)?(R(e,i,o),be(e,i,r)):o&&"object"==typeof o&&ge(e,o,i,r)})}function be(e,t,n){if(!n)return;const r=w(t),o=e.errors.get(r.key);o&&n.set(r.key,o)}function ke(e,t){const n=e.validateDeps?function(e){let t=Se.get(e);t||(t=new Map,Se.set(e,t));return t}(e):void 0;if(n&&(!function(e,t){for(const[n,r]of t){e.errors.get(n)===r&&(e.errors.delete(n),f(e.emitter,"errors",w(JSON.parse(n))))}}(e,n),n.clear()),t){if("object"==typeof t&&E in t){const r=t;return r.errors&&ge(e,r.errors,[],n),void function(e,t){void 0!==t&&t!==e.parsedValues&&(e.parsedValues=t,f(e.emitter,"change"))}(e,r.values)}ge(e,t,[],n)}}const Se=new WeakMap;const we="__form_validate__";function Ee(e){for(const t of e.validating)if(t!==we)return!1;return!0}const Ve=Symbol("form-validate-settled"),Oe=new WeakMap;function _e(e){const t=e.validate;if(!t)return Promise.resolve();const n=e.validateDebounce??0;if(n<=0){const n=new AbortController;return Promise.resolve(t(O(e),{form:e,signal:n.signal})).then(t=>{ke(e,t)})}const r=function(e){let t=Oe.get(e);return t||(t={timer:null,controller:null,round:null,marked:!1,waiters:[]},Oe.set(e,t)),t}(e);return null!==r.timer?clearTimeout(r.timer):(r.marked=!0,e.validating.add(we),f(e.emitter,"validating")),r.timer=setTimeout(()=>{r.timer=null;const t=r.round={};(function(e,t,n){const r=e.validate;if(!r)return Promise.resolve();t.controller?.abort();const o=t.controller=new AbortController;let i;try{i=Promise.resolve(r(O(e),{form:e,signal:o.signal}))}catch(e){i=Promise.reject(e)}return i.then(r=>{t.round===n&&ke(e,r)},e=>{if(t.round===n)throw e})})(e,r,t).then(()=>Ae(e,r,t,Ve),n=>Ae(e,r,t,n))},n),new Promise((e,t)=>{r.waiters.push({resolve:e,reject:t})})}function Ae(e,t,n,r){if(t.round!==n)return;if(t.round=null,null!==t.timer)return;t.marked&&(t.marked=!1,e.validating.delete(we),f(e.emitter,"validating"));const o=t.waiters;t.waiters=[];for(const e of o)r===Ve?e.resolve():e.reject(r)}function Te(e,t,n){e.validateDeps?.has(t.key)&&e.validate&&("onChange"===n||"all"===n||"onTouched"===n&&z(e,t)||"onChange"===e.reValidateMode&&function(e){const t=Se.get(e);if(!t)return!1;for(const[n,r]of t)if(e.errors.get(n)===r)return!0;return!1}(e))&&_e(e).catch(()=>{})}async function xe(e){if(e.validators.forEach(e=>e()),await S(e.emitter,"validating",()=>Ee(e),()=>he(e)).catch(()=>{throw new Error($(e))}),e.validate&&(await _e(e),he(e)))throw new Error($(e))}async function Ce(e){return xe(e).catch(e=>e.message)}function Le(e,t){e.isSubmitting=t,f(e.emitter,"submitting")}function De(e){e.submitCount++,f(e.emitter,"submitCount")}function je(e,t){e.isSubmitSuccessful=t,f(e.emitter,"submitSuccessful")}function Me(e,t){e.disabled=t,f(e.emitter,"disabled")}function Ne(e){if(e.startsWith("["))try{const t=JSON.parse(e);if(Array.isArray(t))return t.join(".")}catch{}return e}function Be(e,t){const{onSubmit:n,onValidSubmit:r,onInvalidSubmit:o,shouldFocusError:i=!0}=t??{};return async t=>{t&&"function"==typeof t.preventDefault&&t.preventDefault();const u=t?.currentTarget;Le(e,!0),De(e);const s=O(e);if(u&&"function"==typeof u.checkValidity&&!1===u.checkValidity()){if(u.reportValidity(),i&&"function"==typeof u.querySelector){const e=u.querySelector(":invalid");e&&"function"==typeof e.focus&&e.focus()}return Le(e,!1),je(e,!1),void(o&&o(function(e){const t=[],{elements:n}=e;for(let e=0;e<n.length;e++){const r=n[e];r.name&&"function"==typeof r.checkValidity&&!r.checkValidity()&&t.push({path:Ne(r.name),type:"native",message:r.validationMessage})}return t}(u),s))}if(await Ce(e)){if(Le(e,!1),je(e,!1),i){const t=e.errors.keys().next().value;void 0!==t&&f(e.emitter,"focusError",t)}o&&o(P(e),s)}else try{const o=O(e);n&&await n(o,t),r&&await r(o,t),je(e,!0)}catch{je(e,!1)}finally{Le(e,!1)}}}function Pe(e,t,n){const{key:r}=w(t);n?f(e.emitter,"focusError",r,n):f(e.emitter,"focusError",r)}function $e(e,t){switch(e){case"required":return"This field is required";case"min":return`Must be at least ${t}`;case"max":return`Must be at most ${t}`;case"minLength":return`Must be at least ${t} characters`;case"maxLength":return`Must be at most ${t} characters`;case"pattern":return"Invalid format";default:return"Invalid value"}}var qe,He={exports:{}},Ie={};var Re,Je,Ue={};var We=(Je||(Je=1,"production"===process.env.NODE_ENV?He.exports=function(){if(qe)return Ie;qe=1;var e=t,n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=e.useState,o=e.useEffect,i=e.useLayoutEffect,u=e.useDebugValue;function s(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!n(e,r)}catch(e){return!0}}var a="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),a=r({inst:{value:n,getSnapshot:t}}),c=a[0].inst,l=a[1];return i(function(){c.value=n,c.getSnapshot=t,s(c)&&l({inst:c})},[e,n,t]),o(function(){return s(c)&&l({inst:c}),e(function(){s(c)&&l({inst:c})})},[e]),u(n),n};return Ie.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:a,Ie}():He.exports=(Re||(Re=1,"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch(e){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=t,r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useState,i=n.useEffect,u=n.useLayoutEffect,s=n.useDebugValue,a=!1,c=!1,l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,l){a||void 0===n.startTransition||(a=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var f=l();if(!c){var d=l();r(f,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}var m=(d=o({inst:{value:f,getSnapshot:l}}))[0].inst,h=d[1];return u(function(){m.value=f,m.getSnapshot=l,e(m)&&h({inst:m})},[t,f,l]),i(function(){return e(m)&&h({inst:m}),t(function(){e(m)&&h({inst:m})})},[t]),s(f),f};Ue.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:l,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Ue)),He.exports);function Fe(e,t){return e.startsWith(`${t.slice(0,-1)},`)}function Ge(e,t,n,r,o){const{key:i}=n;return d(e,t,e=>{(void 0===e||e.key===i||Fe(i,e.key)||"branch"===r&&Fe(e.key,i))&&o()})}function Ke(e,t,n,r){return d(e,t,e=>{void 0!==e&&e.key!==n||r()})}function ze(e,t){const{name:n,event:r="change",scope:o="branch",callback:i}=t;if(void 0===n)return d(e.emitter,r,i);const u=function(e){return Array.isArray(e)&&e.every(e=>"number"!=typeof e)}(n)?n:[n],s=u.map(t=>{const n=w(t);return"errors"===r||"touched"===r?Ke(e.emitter,r,n.key,i):Ge(e.emitter,r,n,o,i)});return 1===s.length?s[0]:()=>s.forEach(e=>e())}function Ye(e){const[t]=o(()=>{const t=V(e);return e&&void 0!==e.values&&fe(t,e.values),t}),n=e&&e.initialValues,u=e&&e.values,s=r(null);null===s.current&&(s.current={done:!1,source:void 0}),i(()=>{const e=s.current;e.done&&(e.source===n||k(e.source,n))||(e.done=!0,e.source=n,fe(t,n))},[t,n]);const a=r(null);return null===a.current&&(a.current={done:!1,source:void 0}),i(()=>{if(void 0===u)return;const e=a.current;e.done&&(e.source===u||k(e.source,u))||(e.done=!0,e.source=u,fe(t,u))},[t,u]),t}function Qe(e,t){const o=r(null);null===o.current&&(o.current={hasValue:!1});const i=o.current,u=r(t);u.current=t;const s=n(()=>(i.hasValue||(i.value=u.current(),i.hasValue=!0),i.value),[i]),a=n(t=>{i.hasValue=!1;return e(()=>{i.hasValue=!1,t()})},[e,i]);return We.useSyncExternalStore(a,s,s)}function Xe(e,t,r){return Qe(n(n=>d(e,t,n),[e,t]),r)}function Ze(e,t){return et(e,w(t))}function et(e,t){const{emitter:r}=e,{key:o}=t;return Qe(n(e=>Ge(r,"change",t,"leaf",e),[r,o]),A.bind(null,e,t))}function tt(e,t){return nt(e,w(t))}function nt(e,t){const{emitter:r}=e,{key:o}=t;return Qe(n(e=>Ke(r,"touched",o,e),[r,o]),z.bind(null,e,t))}function rt(e,t){return ot(e,w(t))?.message}function ot(e,t){const{emitter:r}=e,{key:o}=t;return Qe(n(e=>Ke(r,"errors",o,e),[r,o]),j.bind(null,e,t))}function it(e,t){return ut(e,w(t))}function ut(e,t){const{emitter:r}=e,{key:o}=t;return Qe(n(e=>Ke(r,"errors",o,e),[r,o]),B.bind(null,e,t))}function st(e){return Xe(e.emitter,"change",Y.bind(null,e))}function at(e){return Xe(e.emitter,"change",ie.bind(null,e))}function ct(e){return Xe(e.emitter,"touched",ue.bind(null,e))}function lt(e){return Xe(e.emitter,"errors",he.bind(null,e))}function ft(e){return Xe(e.emitter,"submitting",()=>e.isSubmitting)}function dt(e){const{emitter:t}=e;return Qe(n(e=>{const n=d(t,"errors",e),r=d(t,"submitting",e);return()=>{n(),r()}},[t]),()=>!e.isSubmitting&&!he(e))}function mt(e){return Xe(e.emitter,"submitCount",()=>e.submitCount)}function ht(e){const t=u(()=>w(h(e)),[e]);return u(()=>t,[t.key])}function vt(e){const t=function(e){const t=r(e);return t.current=e,t}(e);return n((...e)=>t.current(...e),[t])}function yt(e,t){if(!e)return t;const n=function(e){return t=>{if(e.required&&(""===t||null==t))return[{type:"required",message:"string"==typeof e.required?e.required:$e("required")}];const n=[],r=(t,n)=>e.messages?.[t]??$e(t,n);if(void 0!==e.min){const o=Number(t);!Number.isNaN(o)&&o<e.min&&n.push({type:"min",message:r("min",e.min)})}if(void 0!==e.max){const o=Number(t);!Number.isNaN(o)&&o>e.max&&n.push({type:"max",message:r("max",e.max)})}return void 0!==e.minLength&&"string"==typeof t&&t.length<e.minLength&&n.push({type:"minLength",message:r("minLength",e.minLength)}),void 0!==e.maxLength&&"string"==typeof t&&t.length>e.maxLength&&n.push({type:"maxLength",message:r("maxLength",e.maxLength)}),e.pattern&&!e.pattern.value.test(t)&&n.push({type:"pattern",message:e.messages?.pattern??e.pattern.message??$e("pattern")}),n.length?n:void 0}}(e);return t?(e,r)=>{const o=n(e,r),i=e=>{const t=[...o??[]];return Array.isArray(e)?t.push(...e):e&&t.push(e),t.length?t:void 0},u=t(e,r);return b(u)?u.then(i):i(u)}:n}function pt({form:e,name:t,initialValue:n,shouldUnregister:u,validate:a,rules:c,validateDebounce:l,delayError:f,disabled:d,mode:m},h){const v=s(h),y=e||v;if(!y)throw new Error("no form provided");const p=ht(t),g=function(e,t,n,o){const u=s(Et),a=n||u;if(!a)throw new Error("no form provided");const c=r(null),l=r(e);l.current=e;const f=r(o?.debounce??0);return f.current=o?.debounce??0,i(()=>{let e=null,n=null,r=!1;const o=()=>{r||(r=!0,I(a,t))},i=()=>{r&&(r=!1,H(a,t))},u=()=>{e=null;const r=l.current;if(!r)return void i();n?.abort(),n=new AbortController;const u=c.current={};let s;try{s=r(A(a,t),{form:a,path:t,signal:n.signal})}catch(e){throw i(),e}if(!b(s))return J(a,t,s),void i();o(),s.then(e=>{u===c.current&&J(a,t,e)}).catch(()=>{}).finally(()=>{u===c.current&&(i(),c.current=null)})};return a.validators.set(t.key,()=>{const t=f.current;if(t>0)return null!==e?clearTimeout(e):o(),void(e=setTimeout(u,t));u()}),()=>{a.validators.delete(t.key),null!==e&&(clearTimeout(e),e=null),i(),n?.abort()}},[a,t.key]),vt(()=>a.validators.get(t.key)?.())}(yt(c,a),p,y,{debounce:l}),k=ut(y,p),S=function(e,t){const[n,r]=o(e);return i(()=>{if(void 0===t)return;if(0===e.length)return void r(e);if(n.length>0)return void r(e);const o=setTimeout(()=>r(e),t);return()=>clearTimeout(o)},[e,t,n]),void 0===t?e:n}(k,f),w=S[0],E=w?.message,V=et(y,p),O=Xe(y.emitter,"disabled",()=>y.disabled),_=m??y.mode;i(()=>{void 0!==n&&void 0===A(y,p)&&x(y,p,n)},[y,p,n]);const T=vt(e=>{x(y,p,e),("onChange"===_||"all"===_||"onTouched"===_&&z(y,p)||k.length>0&&"onChange"===y.reValidateMode)&&g(),Te(y,p,_)});i(()=>(y.changeHandlers.set(p.key,T),()=>{y.changeHandlers.get(p.key)===T&&y.changeHandlers.delete(p.key)}),[y,p.key,T]);const C=vt(()=>{G(y,p),("onBlur"===_||"onTouched"===_||"all"===_||k.length>0&&"onBlur"===y.reValidateMode)&&g()});return i(()=>()=>{!1!==u&&ce(y,p)},[p,y,u]),{form:y,value:V,error:E,errorObject:w,errors:S,onChange:T,onBlur:C,name:p.key,disabled:O||!!d}}function gt(e){return pt(e,Et)}let bt=0;function kt(){return"_"+ ++bt}function St(e,t){const o=s(t),u=e.form||o;if(!u)throw new Error("no form provided");const c=ht(e.name),l=r([]),f=n(()=>A(u,c)||[],[u,c]),d=n(e=>{x(u,c,e)},[u,c]),m=n(()=>{const e=f();for(;l.current.length<e.length;)l.current.push(kt());for(;l.current.length>e.length;)l.current.pop();return l.current.map((e,t)=>({id:e,index:t}))},[f]),[h,v]=a(m,void 0,m);i(()=>Ge(u.emitter,"change",c,"branch",v),[u.emitter,c]);return{fields:h,append:vt(e=>{const t=f();l.current.push(kt()),d([...t,e])}),prepend:vt(e=>{const t=f();l.current.unshift(kt()),d([e,...t])}),insert:vt((e,t)=>{const n=f();l.current.splice(e,0,kt());const r=[...n.slice(0,e),t,...n.slice(e)];d(r)}),remove:vt(e=>{const t=f();l.current.splice(e,1);const n=t.filter((t,n)=>n!==e);d(n)}),swap:vt((e,t)=>{const n=f();[l.current[e],l.current[t]]=[l.current[t],l.current[e]];const r=[...n];[r[e],r[t]]=[r[t],r[e]],d(r)}),move:vt((e,t)=>{const n=f(),[r]=l.current.splice(e,1);l.current.splice(t,0,r);const o=[...n],[i]=o.splice(e,1);o.splice(t,0,i),d(o)}),replace:vt(e=>{l.current=e.map(()=>kt()),d([...e])}),update:vt((e,t)=>{const n=f();if(e<0||e>=n.length)return;const r=[...n];r[e]=t,d(r)})}}function wt(e){return St(e,Et)}const Et=c(null),Vt=Et.Provider;function Ot(){const e=s(Et);if(!e)throw new Error("no form provided");return e}function _t(){const e=c(null);return{context:e,FormProvider:function({form:t,children:n}){return l(e.Provider,{value:t},n)},useFormContext:function(){const t=s(e);if(!t)throw new Error("no form provided");return t},useField:function(t){return pt(t,e)},useFieldArray:function(t){return St(t,e)}}}const At=c(null),Tt=At.Provider;function xt(){const e=s(At);if(!e)throw new Error("no group provided");return e}function Ct({form:t,context:n,initialValues:r,values:o,onSubmit:i,onValidSubmit:u,onInvalidSubmit:s,shouldFocusError:a,...c}){const l=Ye({initialValues:r,values:o}),f=t||l,d=Be(f,{onSubmit:i,onValidSubmit:u,onInvalidSubmit:s,shouldFocusError:a}),{Provider:m}=n??Et;return e.createElement(m,{value:f},e.createElement("form",{...c,noValidate:!0,onSubmit:d}))}function Lt(e){return e.replace(/["'[\],\s]+/g,"-").replace(/^-+|-+$/g,"")||"field"}function Dt(e,t,n){return{"aria-invalid":!!e||n["aria-invalid"],"aria-describedby":e?[n["aria-describedby"],Lt(t)].filter(Boolean).join(" "):n["aria-describedby"]}}function jt(e){return Lt(w(e).key)}const Mt=e.forwardRef(({validate:t,eventToValue:n,initialValue:r,name:o,asProps:i,renderError:u,as:s,valueToProps:a,form:c,shouldUnregister:l,rules:f,validateDebounce:m,disabled:h,delayError:v,mode:y,...p},g)=>{const b=e.useRef(null),[k,S]=e.useState(0),w=e.useCallback(e=>{b.current=e,function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(g,e)},[g]),{value:E,onChange:V,onBlur:O,error:_,form:A,name:T,disabled:x}=gt({name:o,form:c,initialValue:r,shouldUnregister:l,rules:f,validateDebounce:m,delayError:v,disabled:h,mode:y,validate:(...e)=>{const n=b.current;if(!n||"function"!=typeof n.checkValidity||(n.setCustomValidity(""),!1!==n.checkValidity()))return t?t(...e):void 0;S(e=>e+1)}}),C=s||"input";e.useEffect(()=>{const e=b.current;e&&"function"==typeof e.setCustomValidity&&("string"==typeof _?(e.setCustomValidity(_),e.reportValidity()):e.setCustomValidity(""))},[_]),e.useEffect(()=>{k>0&&b.current?.reportValidity()},[k]),e.useEffect(()=>d(A.emitter,"focusError",(e,t)=>{if(e!==T)return;const n=b.current;n&&"function"==typeof n.focus&&(n.focus(),t?.shouldSelect&&"function"==typeof n.select&&n.select())}),[A,T]);const L=n??(e=>e.target.value),D=Lt(T);return e.createElement(e.Fragment,null,e.createElement(C,{...p,name:T,onBlur:O,...i,...a?a(E):{value:E},...Dt(_,T,p),disabled:x,onChange:e=>V(L(e)),ref:w}),_&&u?e.createElement("span",{id:D,role:"alert"},u(_,D)):null)}),Nt=e.forwardRef(({name:t,form:n,initialValue:r,shouldUnregister:o,validate:i,rules:u,validateDebounce:s,disabled:a,delayError:c,mode:l,...f},d)=>{const{value:m,onChange:h,onBlur:v,error:y,name:p,disabled:g}=gt({name:t,form:n,initialValue:r,shouldUnregister:o,validate:i,rules:u,validateDebounce:s,delayError:c,disabled:a,mode:l});return e.createElement("input",{...f,name:p,onBlur:v,type:"checkbox",checked:!!m,...Dt(y,p,f),disabled:g,onChange:e=>h(e.target.checked),ref:d})});function Bt(e,t){return e?Array.isArray(t)?t:[]:t??""}const Pt=e.forwardRef(({name:t,multiple:n,children:r,form:o,initialValue:i,shouldUnregister:u,validate:s,rules:a,validateDebounce:c,disabled:l,delayError:f,mode:d,...m},h)=>{const{value:v,onChange:y,onBlur:p,error:g,name:b,disabled:k}=gt({name:t,form:o,initialValue:i,shouldUnregister:u,validate:s,rules:a,validateDebounce:c,delayError:f,disabled:l,mode:d});return e.createElement("select",{...m,name:b,onBlur:p,multiple:n,value:Bt(n,v),...Dt(g,b,m),disabled:k,onChange:e=>y(n?Array.from(e.target.selectedOptions,e=>e.value):e.target.value),ref:h},r)});export{Nt as Checkbox,At as CheckboxGroupContext,Tt as CheckboxGroupProvider,Mt as Field,Ct as Form,Et as FormContext,Vt as FormProvider,Pt as Select,E as VALIDATION_OUTCOME,C as changeValue,L as changeValueByPath,U as clearErrors,V as createForm,_t as createFormContext,xe as ensureValidate,jt as fieldErrorId,ie as getDirtyFields,D as getError,j as getErrorByPath,P as getErrors,N as getFieldErrors,B as getFieldErrorsByPath,q as getFieldState,$ as getFirstError,ue as getTouchedFields,_ as getValue,A as getValueByPath,O as getValues,Be as handleSubmit,he as hasErrors,K as hasTouched,z as hasTouchedByPath,De as incrementSubmitCount,Y as isDirty,se as isTouched,ae as removeField,ce as removeFieldByPath,de as reset,me as resetField,Te as revalidateFormOnChange,Me as setDisabled,R as setError,J as setErrorByPath,Pe as setFocus,fe as setInitialValues,Le as setIsSubmitting,W as setServerErrors,je as setSubmitSuccessful,F as setTouched,G as setTouchedByPath,I as setValidatingByPath,T as setValue,x as setValueByPath,ze as subscribe,ve as trigger,H as unsetValidatingByPath,dt as useCanSubmit,xt as useCheckboxGroupContext,at as useDirtyFields,rt as useError,ot as useErrorByPath,gt as useField,wt as useFieldArray,it as useFieldErrors,ut as useFieldErrorsByPath,Ye as useForm,Ot as useFormContext,lt as useHasErrors,st as useIsDirty,ft as useIsSubmitting,mt as useSubmitCount,tt as useTouched,nt as useTouchedByPath,ct as useTouchedFields,Ze as useValue,et as useValueByPath,Xe as useWatch,Ce as validate};
2
2
  //# sourceMappingURL=index.mjs.map