@tanstack/react-form 0.0.5 → 0.0.6

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.
Files changed (37) hide show
  1. package/build/cjs/Field.js +2 -5
  2. package/build/cjs/Field.js.map +1 -1
  3. package/build/cjs/createFormFactory.js +32 -0
  4. package/build/cjs/createFormFactory.js.map +1 -0
  5. package/build/cjs/formContext.js +1 -5
  6. package/build/cjs/formContext.js.map +1 -1
  7. package/build/cjs/index.js +14 -9
  8. package/build/cjs/index.js.map +1 -1
  9. package/build/cjs/useField.js +4 -12
  10. package/build/cjs/useField.js.map +1 -1
  11. package/build/cjs/useForm.js +6 -31
  12. package/build/cjs/useForm.js.map +1 -1
  13. package/build/esm/index.js +24 -50
  14. package/build/esm/index.js.map +1 -1
  15. package/build/stats-html.html +1 -1
  16. package/build/stats-react.json +145 -107
  17. package/build/types/form-core/src/FieldApi.d.ts +11 -10
  18. package/build/types/form-core/src/FormApi.d.ts +12 -12
  19. package/build/types/form-core/src/utils.d.ts +10 -10
  20. package/build/types/index.d.ts +22 -10
  21. package/build/types/react-form/src/Field.d.ts +3 -3
  22. package/build/types/react-form/src/createFormFactory.d.ts +9 -0
  23. package/build/types/react-form/src/formContext.d.ts +1 -1
  24. package/build/types/react-form/src/index.d.ts +10 -4
  25. package/build/types/react-form/src/useField.d.ts +9 -3
  26. package/build/types/react-form/src/useForm.d.ts +5 -3
  27. package/build/umd/index.development.js +24 -54
  28. package/build/umd/index.development.js.map +1 -1
  29. package/build/umd/index.production.js +2 -2
  30. package/build/umd/index.production.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/Field.tsx +2 -3
  33. package/src/createFormFactory.ts +22 -0
  34. package/src/formContext.ts +1 -5
  35. package/src/index.ts +35 -4
  36. package/src/useField.ts +13 -17
  37. package/src/useForm.tsx +11 -43
@@ -29,7 +29,7 @@ class l{listeners=new Set;batching=!1;queue=[];constructor(t,e){this.state=t,thi
29
29
  * LICENSE.md file in the root directory of this source tree.
30
30
  *
31
31
  * @license MIT
32
- */function r(t,e){return"function"==typeof t?t(e):t}function u(t,e){if(!e)throw new Error("A path string is required to use getBy");return p(e).reduce(((t,e)=>{if(void 0!==t)return t[e]}),t)}function h(t,e,i){const s=p(e);return function t(e){if(!s.length)return r(i,e);const a=s.shift();if("string"==typeof a)return"object"==typeof e?{...e,[a]:t(e[a])}:{[a]:t()};if("number"==typeof a){if(Array.isArray(e)){const i=e.slice(0,a);return[...i.length?i:new Array(a),t(e[a]),...e.slice(a+1)]}return[...new Array(a),t()]}throw new Error("Uh oh!")}(t)}const d=/^(\d*)$/gm,c=/\.(\d*)\./gm,f=/^(\d*)\./gm,m=/\.(\d*$)/gm,v=/\.{2,}/gm;function p(t){return t.replace("[",".").replace("]","").replace(d,"__int__$1").replace(c,".__int__$1.").replace(f,"__int__$1.").replace(m,".__int__$1").replace(v,".").split(".").map((t=>0===t.indexOf("__int__")?parseInt(t.substring("__int__".length),10):t))}function g(t){return{values:{},fieldMeta:{},canSubmit:!0,isFieldsValid:!1,isFieldsValidating:!1,isFormValid:!1,isFormValidating:!1,isSubmitted:!1,isSubmitting:!1,isTouched:!1,isValid:!1,isValidating:!1,submissionAttempts:0,formValidationCount:0,...t}}class b{constructor(t){var e,i;this.options={},this.fieldInfo={},this.validationMeta={},this.update=t=>{this.store.batch((()=>{t.defaultState&&t.defaultState!==this.options.defaultState&&this.store.setState((e=>({...e,...t.defaultState}))),t.defaultValues!==this.options.defaultValues&&this.store.setState((e=>({...e,values:t.defaultValues})))})),this.options=t},this.reset=()=>this.store.setState((()=>g(this.options.defaultValues))),this.validateAllFields=async()=>{const t=[];return this.store.batch((()=>{Object.values(this.fieldInfo).forEach((e=>{Object.values(e.instances).forEach((e=>{e.state.meta.isTouched||(e.setMeta((t=>({...t,isTouched:!0}))),e.options.validate&&t.push(e.validate()))}))}))})),Promise.all(t)},this.validateForm=async()=>{const{validate:t}=this.options;if(!t)return;this.store.setState((t=>({...t,isValidating:!0,formValidationCount:t.formValidationCount+1})));const e=this.state.formValidationCount,i=()=>e===this.state.formValidationCount;this.validationMeta.validationPromise||(this.validationMeta.validationPromise=new Promise(((t,e)=>{this.validationMeta.validationResolve=t,this.validationMeta.validationReject=e})));return(async()=>{try{const a=await t(this.state.values,this);var e,s;if(i())this.store.setState((t=>({...t,isValidating:!1,error:a?"string"==typeof a?a:"Invalid Form Values":null}))),null==(e=(s=this.validationMeta).validationResolve)||e.call(s,a)}catch(t){var a,n;if(i())null==(a=(n=this.validationMeta).validationReject)||a.call(n,t)}finally{delete this.validationMeta.validationPromise}})(),this.validationMeta.validationPromise},this.handleSubmit=async t=>{if(t.preventDefault(),t.stopPropagation(),this.store.setState((t=>({...t,isSubmitted:!1,submissionAttempts:t.submissionAttempts+1}))),!this.state.canSubmit)return;this.store.setState((t=>({...t,isSubmitting:!0})));const e=()=>{this.store.setState((t=>({...t,isSubmitting:!1})))};var i,s,a,n;if(await this.validateAllFields(),!this.state.isFieldsValid)return e(),void(null==(i=(s=this.options).onInvalidSubmit)||i.call(s,this.state.values,this));if(await this.validateForm(),!this.state.isValid)return e(),void(null==(a=(n=this.options).onInvalidSubmit)||a.call(n,this.state.values,this));try{var o,l;await(null==(o=(l=this.options).onSubmit)?void 0:o.call(l,this.state.values,this)),this.store.batch((()=>{this.store.setState((t=>({...t,isSubmitted:!0}))),e()}))}catch(t){throw e(),t}},this.getFieldValue=t=>u(this.state.values,t),this.getFieldMeta=t=>this.state.fieldMeta[t],this.getFieldInfo=t=>{var e;return(e=this.fieldInfo)[t]||(e[t]={instances:{}})},this.setFieldMeta=(t,e)=>{this.store.setState((i=>({...i,fieldMeta:{...i.fieldMeta,[t]:r(e,i.fieldMeta[t])}})))},this.setFieldValue=(t,e,i)=>{var s;const a=null==(s=null==i?void 0:i.touch)||s;this.store.batch((()=>{this.store.setState((i=>({...i,values:h(i.values,t,e)}))),a&&this.setFieldMeta(t,(t=>({...t,isTouched:!0})))}))},this.pushFieldValue=(t,e,i)=>this.setFieldValue(t,(t=>[...Array.isArray(t)?t:[],e]),i),this.insertFieldValue=(t,e,i,s)=>{this.setFieldValue(t,(t=>t.map(((t,s)=>s===e?i:t))),s)},this.spliceFieldValue=(t,e,i)=>{this.setFieldValue(t,(t=>t.filter(((t,i)=>i!==e))),i)},this.swapFieldValues=(t,e,i)=>{this.setFieldValue(t,(t=>{const s=t[e],a=t[i];return h(h(t,[e],a),[i],s)}))},this.store=new l(g({...null==t?void 0:t.defaultState,values:null!=(e=null==t?void 0:t.defaultValues)?e:null==t||null==(i=t.defaultState)?void 0:i.values,isFormValid:!(null!=t&&t.validate)}),{onUpdate:t=>{const e=Object.values(t.fieldMeta),i=e.some((t=>null==t?void 0:t.isValidating)),s=!e.some((t=>null==t?void 0:t.error)),a=e.some((t=>null==t?void 0:t.isTouched)),n=i||t.isFormValidating,o=!t.formError,l=s&&o,r=0===t.submissionAttempts&&!a||!n&&!t.isSubmitting&&l;t={...t,isFieldsValidating:i,isFieldsValid:s,isFormValid:o,isValid:l,canSubmit:r,isTouched:a},this.store.state=t,this.state=t}}),this.state=this.store.state,this.update(t||{})}}var y=0;function V(t){return"__private_"+y+++"_"+t}function F(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}let S=0;var w=V("updateStore"),M=V("leaseValidateAsync");class O{constructor(t){var e;this.options={},this.mount=()=>{const t=this.getInfo();t.instances[this.uid]=this;const e=this.form.store.subscribe((()=>{F(this,w)[w]()}));return()=>{e(),delete t.instances[this.uid],Object.keys(t.instances).length||delete this.form.fieldInfo[this.name]}},Object.defineProperty(this,w,{writable:!0,value:()=>{this.store.batch((()=>{const t=this.getValue(),e=this.getMeta();t!==this.state.value&&this.store.setState((e=>({...e,value:t}))),e!==this.state.meta&&this.store.setState((t=>({...t,meta:e})))}))}}),this.update=t=>{var e,i,s,a;this.options={validatePristine:null!=(e=this.form.options.defaultValidatePristine)&&e,validateOn:null!=(i=this.form.options.defaultValidateOn)?i:"change",validateAsyncOn:null!=(s=this.form.options.defaultValidateAsyncOn)?s:"blur",validateAsyncDebounceMs:null!=(a=this.form.options.defaultValidateAsyncDebounceMs)?a:0,...t},void 0===this.state.value&&void 0!==this.options.defaultValue&&this.setValue(this.options.defaultValue),void 0===this.getMeta()&&this.setMeta(this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(t,e)=>this.form.setFieldValue(this.name,t,e),this.getMeta=()=>this.form.getFieldMeta(this.name),this.setMeta=t=>this.form.setFieldMeta(this.name,t),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=t=>this.form.pushFieldValue(this.name,t),this.insertValue=(t,e)=>this.form.insertFieldValue(this.name,t,e),this.removeValue=t=>this.form.spliceFieldValue(this.name,t),this.swapValues=(t,e)=>this.form.swapFieldValues(this.name,t,e),this.getSubField=t=>new O({name:this.name+"."+t,form:this.form}),this.validateSync=async(t=this.state.value)=>{const{validate:e}=this.options;if(!e)return;const i=(this.getInfo().validationCount||0)+1;this.getInfo().validationCount=i;const s=j(e(t,this));this.state.meta.error!==s&&this.setMeta((t=>({...t,error:s}))),this.state.meta.error&&this.cancelValidateAsync()},Object.defineProperty(this,M,{writable:!0,value:()=>{const t=(this.getInfo().validationAsyncCount||0)+1;return this.getInfo().validationAsyncCount=t,t}}),this.cancelValidateAsync=()=>{F(this,M)[M](),this.setMeta((t=>({...t,isValidating:!1})))},this.validateAsync=async(t=this.state.value)=>{const{validateAsync:e,validateAsyncDebounceMs:i}=this.options;if(!e)return;!0!==this.state.meta.isValidating&&this.setMeta((t=>({...t,isValidating:!0})));const s=F(this,M)[M](),a=()=>s===this.getInfo().validationAsyncCount;if(this.getInfo().validationPromise||(this.getInfo().validationPromise=new Promise(((t,e)=>{this.getInfo().validationResolve=t,this.getInfo().validationReject=e}))),i>0&&await new Promise((t=>setTimeout(t,i))),a())try{const i=await e(t,this);if(a()){var n,o;const t=j(i);this.setMeta((e=>({...e,isValidating:!1,error:t}))),null==(n=(o=this.getInfo()).validationResolve)||n.call(o,t)}}catch(t){var l,r;if(a())throw null==(l=(r=this.getInfo()).validationReject)||l.call(r,t),t}finally{a()&&(this.setMeta((t=>({...t,isValidating:!1}))),delete this.getInfo().validationPromise)}return this.getInfo().validationPromise},this.shouldValidate=(t,e)=>{const{validateOn:i,validateAsyncOn:s}=this.options,a=function(t){return t?A[t]:3}(e);return Object.keys(A).some((e=>t?s:i===e&&a>=A[e]))},this.validate=async(t,e)=>{if(this.options.validatePristine||this.state.meta.isTouched)return this.shouldValidate(!1,t)&&this.validateSync(e),this.state.meta.error?this.state.meta.error:this.shouldValidate(!0,t)?this.validateAsync(e):void 0},this.getChangeProps=(t={})=>({...t,value:this.state.value,onChange:e=>{this.setValue(e),null==t.onChange||t.onChange(e)},onBlur:e=>{this.setMeta((t=>({...t,isTouched:!0}))),this.validate("blur"),null==t.onBlur||t.onBlur(e)}}),this.getInputProps=(t={})=>({...t,value:String(this.state.value),onChange:e=>{this.setValue(e.target.value),null==t.onChange||t.onChange(e.target.value)},onBlur:this.getChangeProps(t).onBlur}),this.form=t.form,this.uid=S++;let i="";this.form.fieldName&&(i=this.form.fieldName+"."),this.name=i+t.name,this.store=new l({value:this.getValue(),meta:null!=(e=this.getMeta())?e:{isValidating:!1,isTouched:!1,...this.options.defaultMeta}},{onUpdate:t=>{t.meta.touchedError=t.meta.isTouched?t.meta.error:void 0;const e=this.state;this.state=t,t.value!==e.value&&this.validate("change",t.value)}}),this.state=this.store.state,this.update(t)}}const A={change:0,blur:1,submit:2};function j(t){if(t)return"string"!=typeof t?"Invalid Form Values":t}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},_.apply(this,arguments)}
32
+ */function r(t,e){return"function"==typeof t?t(e):t}function u(t,e,i){const s=v(e);return function t(e){if(!s.length)return r(i,e);const a=s.shift();if("string"==typeof a)return"object"==typeof e?{...e,[a]:t(e[a])}:{[a]:t()};if("number"==typeof a){if(Array.isArray(e)){const i=e.slice(0,a);return[...i.length?i:new Array(a),t(e[a]),...e.slice(a+1)]}return[...new Array(a),t()]}throw new Error("Uh oh!")}(t)}const h=/^(\d*)$/gm,d=/\.(\d*)\./gm,c=/^(\d*)\./gm,f=/\.(\d*$)/gm,m=/\.{2,}/gm;function v(t){return t.replace("[",".").replace("]","").replace(h,"__int__$1").replace(d,".__int__$1.").replace(c,"__int__$1.").replace(f,".__int__$1").replace(m,".").split(".").map((t=>0===t.indexOf("__int__")?parseInt(t.substring("__int__".length),10):t))}function p(t){return{values:{},fieldMeta:{},canSubmit:!0,isFieldsValid:!1,isFieldsValidating:!1,isFormValid:!1,isFormValidating:!1,isSubmitted:!1,isSubmitting:!1,isTouched:!1,isValid:!1,isValidating:!1,submissionAttempts:0,formValidationCount:0,...t}}class g{constructor(t){var e,i;this.options={},this.fieldInfo={},this.validationMeta={},this.update=t=>{this.store.batch((()=>{t.defaultState&&t.defaultState!==this.options.defaultState&&this.store.setState((e=>({...e,...t.defaultState}))),t.defaultValues!==this.options.defaultValues&&this.store.setState((e=>({...e,values:t.defaultValues})))})),this.options=t},this.reset=()=>this.store.setState((()=>p(this.options.defaultValues))),this.validateAllFields=async()=>{const t=[];return this.store.batch((()=>{Object.values(this.fieldInfo).forEach((e=>{Object.values(e.instances).forEach((e=>{e.state.meta.isTouched||(e.setMeta((t=>({...t,isTouched:!0}))),e.options.validate&&t.push(e.validate()))}))}))})),Promise.all(t)},this.validateForm=async()=>{const{validate:t}=this.options;if(!t)return;this.store.setState((t=>({...t,isValidating:!0,formValidationCount:t.formValidationCount+1})));const e=this.state.formValidationCount,i=()=>e===this.state.formValidationCount;this.validationMeta.validationPromise||(this.validationMeta.validationPromise=new Promise(((t,e)=>{this.validationMeta.validationResolve=t,this.validationMeta.validationReject=e})));return(async()=>{try{const a=await t(this.state.values,this);var e,s;if(i())this.store.setState((t=>({...t,isValidating:!1,error:a?"string"==typeof a?a:"Invalid Form Values":null}))),null==(e=(s=this.validationMeta).validationResolve)||e.call(s,a)}catch(t){var a,n;if(i())null==(a=(n=this.validationMeta).validationReject)||a.call(n,t)}finally{delete this.validationMeta.validationPromise}})(),this.validationMeta.validationPromise},this.handleSubmit=async t=>{if(t.preventDefault(),t.stopPropagation(),this.store.setState((t=>({...t,isSubmitted:!1,submissionAttempts:t.submissionAttempts+1}))),!this.state.canSubmit)return;this.store.setState((t=>({...t,isSubmitting:!0})));const e=()=>{this.store.setState((t=>({...t,isSubmitting:!1})))};var i,s,a,n;if(await this.validateAllFields(),!this.state.isFieldsValid)return e(),void(null==(i=(s=this.options).onInvalidSubmit)||i.call(s,this.state.values,this));if(await this.validateForm(),!this.state.isValid)return e(),void(null==(a=(n=this.options).onInvalidSubmit)||a.call(n,this.state.values,this));try{var o,l;await(null==(o=(l=this.options).onSubmit)?void 0:o.call(l,this.state.values,this)),this.store.batch((()=>{this.store.setState((t=>({...t,isSubmitted:!0}))),e()}))}catch(t){throw e(),t}},this.getFieldValue=t=>function(t,e){if(!e)throw new Error("A path string is required to use getBy");return v(e).reduce(((t,e)=>{if(void 0!==t)return t[e]}),t)}(this.state.values,t),this.getFieldMeta=t=>this.state.fieldMeta[t],this.getFieldInfo=t=>{var e;return(e=this.fieldInfo)[t]||(e[t]={instances:{}})},this.setFieldMeta=(t,e)=>{this.store.setState((i=>({...i,fieldMeta:{...i.fieldMeta,[t]:r(e,i.fieldMeta[t])}})))},this.setFieldValue=(t,e,i)=>{var s;const a=null==(s=null==i?void 0:i.touch)||s;this.store.batch((()=>{this.store.setState((i=>({...i,values:u(i.values,t,e)}))),a&&this.setFieldMeta(t,(t=>({...t,isTouched:!0})))}))},this.pushFieldValue=(t,e,i)=>this.setFieldValue(t,(t=>[...Array.isArray(t)?t:[],e]),i),this.insertFieldValue=(t,e,i,s)=>{this.setFieldValue(t,(t=>t.map(((t,s)=>s===e?i:t))),s)},this.spliceFieldValue=(t,e,i)=>{this.setFieldValue(t,(t=>t.filter(((t,i)=>i!==e))),i)},this.swapFieldValues=(t,e,i)=>{this.setFieldValue(t,(t=>{const s=t[e],a=t[i];return u(u(t,[e],a),[i],s)}))},this.store=new l(p({...null==t?void 0:t.defaultState,values:null!=(e=null==t?void 0:t.defaultValues)?e:null==t||null==(i=t.defaultState)?void 0:i.values,isFormValid:!(null!=t&&t.validate)}),{onUpdate:t=>{const e=Object.values(t.fieldMeta),i=e.some((t=>null==t?void 0:t.isValidating)),s=!e.some((t=>null==t?void 0:t.error)),a=e.some((t=>null==t?void 0:t.isTouched)),n=i||t.isFormValidating,o=!t.formError,l=s&&o,r=0===t.submissionAttempts&&!a||!n&&!t.isSubmitting&&l;t={...t,isFieldsValidating:i,isFieldsValid:s,isFormValid:o,isValid:l,canSubmit:r,isTouched:a},this.store.state=t,this.state=t}}),this.state=this.store.state,this.update(t||{})}}var b=0;function V(t){return"__private_"+b+++"_"+t}function y(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}let F=0;var S=V("updateStore"),w=V("leaseValidateAsync");class M{constructor(t){var e;this.options={},this.mount=()=>{const t=this.getInfo();t.instances[this.uid]=this;const e=this.form.store.subscribe((()=>{y(this,S)[S]()}));return()=>{e(),delete t.instances[this.uid],Object.keys(t.instances).length||delete this.form.fieldInfo[this.name]}},Object.defineProperty(this,S,{writable:!0,value:()=>{this.store.batch((()=>{const t=this.getValue(),e=this.getMeta();t!==this.state.value&&this.store.setState((e=>({...e,value:t}))),e!==this.state.meta&&this.store.setState((t=>({...t,meta:e})))}))}}),this.update=t=>{var e,i,s,a;this.options={validatePristine:null!=(e=this.form.options.defaultValidatePristine)&&e,validateOn:null!=(i=this.form.options.defaultValidateOn)?i:"change",validateAsyncOn:null!=(s=this.form.options.defaultValidateAsyncOn)?s:"blur",validateAsyncDebounceMs:null!=(a=this.form.options.defaultValidateAsyncDebounceMs)?a:0,...t},void 0===this.state.value&&void 0!==this.options.defaultValue&&this.setValue(this.options.defaultValue),void 0===this.getMeta()&&this.setMeta(this.state.meta)},this.getValue=()=>this.form.getFieldValue(this.name),this.setValue=(t,e)=>this.form.setFieldValue(this.name,t,e),this.getMeta=()=>this.form.getFieldMeta(this.name),this.setMeta=t=>this.form.setFieldMeta(this.name,t),this.getInfo=()=>this.form.getFieldInfo(this.name),this.pushValue=t=>this.form.pushFieldValue(this.name,t),this.insertValue=(t,e)=>this.form.insertFieldValue(this.name,t,e),this.removeValue=t=>this.form.spliceFieldValue(this.name,t),this.swapValues=(t,e)=>this.form.swapFieldValues(this.name,t,e),this.getSubField=t=>new M({name:this.name+"."+t,form:this.form}),this.validateSync=async(t=this.state.value)=>{const{validate:e}=this.options;if(!e)return;const i=(this.getInfo().validationCount||0)+1;this.getInfo().validationCount=i;const s=_(e(t,this));this.state.meta.error!==s&&this.setMeta((t=>({...t,error:s}))),this.state.meta.error&&this.cancelValidateAsync()},Object.defineProperty(this,w,{writable:!0,value:()=>{const t=(this.getInfo().validationAsyncCount||0)+1;return this.getInfo().validationAsyncCount=t,t}}),this.cancelValidateAsync=()=>{y(this,w)[w](),this.setMeta((t=>({...t,isValidating:!1})))},this.validateAsync=async(t=this.state.value)=>{const{validateAsync:e,validateAsyncDebounceMs:i}=this.options;if(!e)return;!0!==this.state.meta.isValidating&&this.setMeta((t=>({...t,isValidating:!0})));const s=y(this,w)[w](),a=()=>s===this.getInfo().validationAsyncCount;if(this.getInfo().validationPromise||(this.getInfo().validationPromise=new Promise(((t,e)=>{this.getInfo().validationResolve=t,this.getInfo().validationReject=e}))),i>0&&await new Promise((t=>setTimeout(t,i))),a())try{const i=await e(t,this);if(a()){var n,o;const t=_(i);this.setMeta((e=>({...e,isValidating:!1,error:t}))),null==(n=(o=this.getInfo()).validationResolve)||n.call(o,t)}}catch(t){var l,r;if(a())throw null==(l=(r=this.getInfo()).validationReject)||l.call(r,t),t}finally{a()&&(this.setMeta((t=>({...t,isValidating:!1}))),delete this.getInfo().validationPromise)}return this.getInfo().validationPromise},this.shouldValidate=(t,e)=>{const{validateOn:i,validateAsyncOn:s}=this.options,a=function(t){return t?O[t]:3}(e);return Object.keys(O).some((e=>t?s:i===e&&a>=O[e]))},this.validate=async(t,e)=>{if(this.options.validatePristine||this.state.meta.isTouched)return this.shouldValidate(!1,t)&&this.validateSync(e),this.state.meta.error?this.state.meta.error:this.shouldValidate(!0,t)?this.validateAsync(e):void 0},this.getChangeProps=(t={})=>({...t,value:this.state.value,onChange:e=>{this.setValue(e),null==t.onChange||t.onChange(e)},onBlur:e=>{this.setMeta((t=>({...t,isTouched:!0}))),this.validate("blur"),null==t.onBlur||t.onBlur(e)}}),this.getInputProps=(t={})=>({...t,value:String(this.state.value),onChange:e=>{this.setValue(e.target.value),null==t.onChange||t.onChange(e.target.value)},onBlur:this.getChangeProps(t).onBlur}),this.form=t.form,this.uid=F++;let i="";this.form.fieldName&&(i=this.form.fieldName+"."),this.name=i+t.name,this.store=new l({value:this.getValue(),meta:null!=(e=this.getMeta())?e:{isValidating:!1,isTouched:!1,...this.options.defaultMeta}},{onUpdate:t=>{t.meta.touchedError=t.meta.isTouched?t.meta.error:void 0;const e=this.state;this.state=t,t.value!==e.value&&this.validate("change",t.value)}}),this.state=this.store.state,this.update(t)}}const O={change:0,blur:1,submit:2};function _(t){if(t)return"string"!=typeof t?"Invalid Form Values":t}function j(){return j=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},j.apply(this,arguments)}
33
33
  /**
34
34
  * react-store
35
35
  *
@@ -39,5 +39,5 @@ class l{listeners=new Set;batching=!1;queue=[];constructor(t,e){this.state=t,thi
39
39
  * LICENSE.md file in the root directory of this source tree.
40
40
  *
41
41
  * @license MIT
42
- */function P(t,i=(t=>t)){return e.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),i,I)}function I(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const i=Object.keys(t);if(i.length!==Object.keys(e).length)return!1;for(let s=0;s<i.length;s++)if(!Object.prototype.hasOwnProperty.call(e,i[s])||!Object.is(t[i[s]],e[i[s]]))return!1;return!0}const C=n.createContext(null);function E(t){return e=>T({...e,form:t})}function T(t){const e=function(t){const e=n.useContext(C);if(t)return t;if(!e)throw new Error("You are trying to use the form API outside of a form!");return e}(t.form),[i]=n.useState((()=>new O({...t,form:e})));return i.update({...t,form:e}),P(i.store),n.useEffect((()=>i.mount()),[i]),i}function R(t){return e=>n.createElement(x,_({},e,{form:t}))}function x({children:t,...e}){return r(t,T(e))}function B(t){return({children:e,noFormElement:i,...s})=>{const a=t.useStore((t=>t.isSubmitting));return o.default.createElement(C.Provider,{value:t},i?e:o.default.createElement("form",_({onSubmit:t.handleSubmit,disabled:a},s),t.options.debugForm?o.default.createElement("div",{style:{margin:"2rem 0"}},o.default.createElement("div",{style:{fontWeight:"bolder"}},"Form State"),o.default.createElement("pre",null,o.default.createElement("code",null,JSON.stringify(t,function(){const t=new Set;return(e,i)=>{if("object"==typeof i||Array.isArray(i)){if(t.has(i))return"(circular value)";t.add(i)}return"function"==typeof i?void 0:i}}(),2)))):null,e))}}t.Field=x,t.FieldApi=O,t.FormApi=b,t.createFieldComponent=R,t.createFormComponent=B,t.createUseField=E,t.functionalUpdate=r,t.getBy=u,t.getDefaultFormState=g,t.setBy=h,t.useField=T,t.useForm=function(t){const[e]=o.default.useState((()=>{const e=new b(t||{});return e.Form=B(e),e.Field=R(e),e.useField=E(e),e.useStore=t=>P(e.store,t),e.Subscribe=t=>r(t.children,P(e.store,t.selector)),e}));return e},Object.defineProperty(t,"__esModule",{value:!0})}));
42
+ */function A(t,i=(t=>t)){return e.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),i,P)}function P(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const i=Object.keys(t);if(i.length!==Object.keys(e).length)return!1;for(let s=0;s<i.length;s++)if(!Object.prototype.hasOwnProperty.call(e,i[s])||!Object.is(t[i[s]],e[i[s]]))return!1;return!0}const I=n.createContext(null);function C(){return t=>E(t)}function E(t){const e=function(){const t=n.useContext(I);if(!t)throw new Error("You are trying to use the form API outside of a form!");return t}(),[i]=n.useState((()=>new M({...t,form:e})));return i.update({...t,form:e}),A(i.store),n.useEffect((()=>i.mount()),[i]),i}function T(){return t=>n.createElement(R,t)}function R({children:t,...e}){return r(t,E(e))}function x(t){const[e]=o.default.useState((()=>{const e=new g(t);return e.Form=function(t){return({children:e,noFormElement:i,...s})=>{const a=t.useStore((t=>t.isSubmitting));return o.default.createElement(I.Provider,{value:t},i?e:o.default.createElement("form",j({onSubmit:t.handleSubmit,disabled:a},s),e))}}(e),e.Field=T(),e.useField=C(),e.useStore=t=>A(e.store,t),e.Subscribe=t=>r(t.children,A(e.store,t.selector)),e}));return e}t.Field=R,t.FieldApi=M,t.FormApi=g,t.createFormFactory=function(t){return{useForm:e=>x({...t,...e}),useField:C(),Field:T()}},t.functionalUpdate=r,t.useField=E,t.useForm=x,Object.defineProperty(t,"__esModule",{value:!0})}));
43
43
  //# sourceMappingURL=index.production.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.production.js","sources":["../../../../node_modules/.pnpm/@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","../../../form-core/build/esm/index.js","../../../../node_modules/.pnpm/@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js","../../src/formContext.ts","../../src/useField.ts","../../src/Field.tsx","../../src/useForm.tsx"],"sourcesContent":["/**\n * store\n *\n * Copyright (c) TanStack\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.md file in the root directory of this source tree.\n *\n * @license MIT\n */\nclass Store {\n listeners = new Set();\n batching = false;\n queue = [];\n constructor(initialState, options) {\n this.state = initialState;\n this.options = options;\n }\n subscribe = listener => {\n this.listeners.add(listener);\n const unsub = this.options?.onSubscribe?.(listener, this);\n return () => {\n this.listeners.delete(listener);\n unsub?.();\n };\n };\n setState = updater => {\n const previous = this.state;\n this.state = this.options?.updateFn ? this.options.updateFn(previous)(updater) : updater(previous);\n if (this.state === previous) return;\n this.options?.onUpdate?.(this.state, previous);\n this.queue.push(() => {\n this.listeners.forEach(listener => listener(this.state, previous));\n });\n this.#flush();\n };\n #flush = () => {\n if (this.batching) return;\n this.queue.forEach(cb => cb());\n this.queue = [];\n };\n batch = cb => {\n this.batching = true;\n cb();\n this.batching = false;\n this.#flush();\n };\n}\n\nexport { Store };\n//# sourceMappingURL=index.js.map\n","/**\n * form-core\n *\n * Copyright (c) TanStack\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.md file in the root directory of this source tree.\n *\n * @license MIT\n */\nimport { Store } from '@tanstack/store';\n\nfunction functionalUpdate(updater, input) {\n return typeof updater === 'function' ? updater(input) : updater;\n}\nfunction getBy(obj, path) {\n if (!path) {\n throw new Error('A path string is required to use getBy');\n }\n\n const pathArray = makePathArray(path);\n const pathObj = pathArray;\n return pathObj.reduce((current, pathPart) => {\n if (typeof current !== 'undefined') {\n return current[pathPart];\n }\n\n return undefined;\n }, obj);\n}\nfunction setBy(obj, _path, updater) {\n const path = makePathArray(_path);\n\n function doSet(parent) {\n if (!path.length) {\n return functionalUpdate(updater, parent);\n }\n\n const key = path.shift();\n\n if (typeof key === 'string') {\n if (typeof parent === 'object') {\n return { ...parent,\n [key]: doSet(parent[key])\n };\n }\n\n return {\n [key]: doSet()\n };\n }\n\n if (typeof key === 'number') {\n if (Array.isArray(parent)) {\n const prefix = parent.slice(0, key);\n return [...(prefix.length ? prefix : new Array(key)), doSet(parent[key]), ...parent.slice(key + 1)];\n }\n\n return [...new Array(key), doSet()];\n }\n\n throw new Error('Uh oh!');\n }\n\n return doSet(obj);\n}\nconst reFindNumbers0 = /^(\\d*)$/gm;\nconst reFindNumbers1 = /\\.(\\d*)\\./gm;\nconst reFindNumbers2 = /^(\\d*)\\./gm;\nconst reFindNumbers3 = /\\.(\\d*$)/gm;\nconst reFindMultiplePeriods = /\\.{2,}/gm;\n\nfunction makePathArray(str) {\n return str.replace('[', '.').replace(']', '').replace(reFindNumbers0, '__int__$1').replace(reFindNumbers1, '.__int__$1.').replace(reFindNumbers2, '__int__$1.').replace(reFindNumbers3, '.__int__$1').replace(reFindMultiplePeriods, '.').split('.').map(d => {\n if (d.indexOf('__int__') === 0) {\n return parseInt(d.substring('__int__'.length), 10);\n }\n\n return d;\n });\n}\n\nfunction getDefaultFormState(defaultState) {\n return {\n values: {},\n fieldMeta: {},\n canSubmit: true,\n isFieldsValid: false,\n isFieldsValidating: false,\n isFormValid: false,\n isFormValidating: false,\n isSubmitted: false,\n isSubmitting: false,\n isTouched: false,\n isValid: false,\n isValidating: false,\n submissionAttempts: 0,\n formValidationCount: 0,\n ...defaultState\n };\n}\nclass FormApi {\n // // This carries the context for nested fields\n constructor(_opts) {\n var _opts$defaultValues, _opts$defaultState;\n\n this.options = {};\n this.fieldInfo = {};\n this.validationMeta = {};\n\n this.update = options => {\n this.store.batch(() => {\n if (options.defaultState && options.defaultState !== this.options.defaultState) {\n this.store.setState(prev => ({ ...prev,\n ...options.defaultState\n }));\n }\n\n if (options.defaultValues !== this.options.defaultValues) {\n this.store.setState(prev => ({ ...prev,\n values: options.defaultValues\n }));\n }\n });\n this.options = options;\n };\n\n this.reset = () => this.store.setState(() => getDefaultFormState(this.options.defaultValues));\n\n this.validateAllFields = async () => {\n const fieldValidationPromises = [];\n this.store.batch(() => {\n void Object.values(this.fieldInfo).forEach(field => {\n Object.values(field.instances).forEach(instance => {\n // If any fields are not touched\n if (!instance.state.meta.isTouched) {\n // Mark them as touched\n instance.setMeta(prev => ({ ...prev,\n isTouched: true\n })); // Validate the field\n\n if (instance.options.validate) {\n fieldValidationPromises.push(instance.validate());\n }\n }\n });\n });\n });\n return Promise.all(fieldValidationPromises);\n };\n\n this.validateForm = async () => {\n const {\n validate\n } = this.options;\n\n if (!validate) {\n return;\n } // Use the formValidationCount for all field instances to\n // track freshness of the validation\n\n\n this.store.setState(prev => ({ ...prev,\n isValidating: true,\n formValidationCount: prev.formValidationCount + 1\n }));\n const formValidationCount = this.state.formValidationCount;\n\n const checkLatest = () => formValidationCount === this.state.formValidationCount;\n\n if (!this.validationMeta.validationPromise) {\n this.validationMeta.validationPromise = new Promise((resolve, reject) => {\n this.validationMeta.validationResolve = resolve;\n this.validationMeta.validationReject = reject;\n });\n }\n\n const doValidation = async () => {\n try {\n const error = await validate(this.state.values, this);\n\n if (checkLatest()) {\n var _this$validationMeta$, _this$validationMeta;\n\n this.store.setState(prev => ({ ...prev,\n isValidating: false,\n error: error ? typeof error === 'string' ? error : 'Invalid Form Values' : null\n }));\n (_this$validationMeta$ = (_this$validationMeta = this.validationMeta).validationResolve) == null ? void 0 : _this$validationMeta$.call(_this$validationMeta, error);\n }\n } catch (err) {\n if (checkLatest()) {\n var _this$validationMeta$2, _this$validationMeta2;\n\n (_this$validationMeta$2 = (_this$validationMeta2 = this.validationMeta).validationReject) == null ? void 0 : _this$validationMeta$2.call(_this$validationMeta2, err);\n }\n } finally {\n delete this.validationMeta.validationPromise;\n }\n };\n\n doValidation();\n return this.validationMeta.validationPromise;\n };\n\n this.handleSubmit = async e => {\n e.preventDefault();\n e.stopPropagation(); // Check to see that the form and all fields have been touched\n // If they have not, touch them all and run validation\n // Run form validation\n // Submit the form\n\n this.store.setState(old => ({ ...old,\n // Submittion attempts mark the form as not submitted\n isSubmitted: false,\n // Count submission attempts\n submissionAttempts: old.submissionAttempts + 1\n })); // Don't let invalid forms submit\n\n if (!this.state.canSubmit) return;\n this.store.setState(d => ({ ...d,\n isSubmitting: true\n }));\n\n const done = () => {\n this.store.setState(prev => ({ ...prev,\n isSubmitting: false\n }));\n }; // Validate all fields\n\n\n await this.validateAllFields(); // Fields are invalid, do not submit\n\n if (!this.state.isFieldsValid) {\n var _this$options$onInval, _this$options;\n\n done();\n (_this$options$onInval = (_this$options = this.options).onInvalidSubmit) == null ? void 0 : _this$options$onInval.call(_this$options, this.state.values, this);\n return;\n } // Run validation for the form\n\n\n await this.validateForm();\n\n if (!this.state.isValid) {\n var _this$options$onInval2, _this$options2;\n\n done();\n (_this$options$onInval2 = (_this$options2 = this.options).onInvalidSubmit) == null ? void 0 : _this$options$onInval2.call(_this$options2, this.state.values, this);\n return;\n }\n\n try {\n var _this$options$onSubmi, _this$options3;\n\n // Run the submit code\n await ((_this$options$onSubmi = (_this$options3 = this.options).onSubmit) == null ? void 0 : _this$options$onSubmi.call(_this$options3, this.state.values, this));\n this.store.batch(() => {\n this.store.setState(prev => ({ ...prev,\n isSubmitted: true\n }));\n done();\n });\n } catch (err) {\n done();\n throw err;\n }\n };\n\n this.getFieldValue = field => getBy(this.state.values, field);\n\n this.getFieldMeta = field => {\n return this.state.fieldMeta[field];\n };\n\n this.getFieldInfo = field => {\n var _this$fieldInfo;\n\n return (_this$fieldInfo = this.fieldInfo)[field] || (_this$fieldInfo[field] = {\n instances: {}\n });\n };\n\n this.setFieldMeta = (field, updater) => {\n this.store.setState(prev => {\n return { ...prev,\n fieldMeta: { ...prev.fieldMeta,\n [field]: functionalUpdate(updater, prev.fieldMeta[field])\n }\n };\n });\n };\n\n this.setFieldValue = (field, updater, opts) => {\n var _opts$touch;\n\n const touch = (_opts$touch = opts == null ? void 0 : opts.touch) != null ? _opts$touch : true;\n this.store.batch(() => {\n this.store.setState(prev => {\n return { ...prev,\n values: setBy(prev.values, field, updater)\n };\n });\n\n if (touch) {\n this.setFieldMeta(field, prev => ({ ...prev,\n isTouched: true\n }));\n }\n });\n };\n\n this.pushFieldValue = (field, value, opts) => {\n return this.setFieldValue(field, prev => [...(Array.isArray(prev) ? prev : []), value], opts);\n };\n\n this.insertFieldValue = (field, index, value, opts) => {\n this.setFieldValue(field, prev => {\n // invariant( // TODO: bring in invariant\n // Array.isArray(prev),\n // `Cannot insert a field value into a non-array field. Check that this field's existing value is an array: ${field}.`\n // )\n return prev.map((d, i) => i === index ? value : d);\n }, opts);\n };\n\n this.spliceFieldValue = (field, index, opts) => {\n this.setFieldValue(field, prev => {\n // invariant( // TODO: bring in invariant\n // Array.isArray(prev),\n // `Cannot insert a field value into a non-array field. Check that this field's existing value is an array: ${field}.`\n // )\n return prev.filter((_d, i) => i !== index);\n }, opts);\n };\n\n this.swapFieldValues = (field, index1, index2) => {\n this.setFieldValue(field, prev => {\n const prev1 = prev[index1];\n const prev2 = prev[index2];\n return setBy(setBy(prev, [index1], prev2), [index2], prev1);\n });\n };\n\n this.store = new Store(getDefaultFormState({ ...(_opts == null ? void 0 : _opts.defaultState),\n values: (_opts$defaultValues = _opts == null ? void 0 : _opts.defaultValues) != null ? _opts$defaultValues : _opts == null ? void 0 : (_opts$defaultState = _opts.defaultState) == null ? void 0 : _opts$defaultState.values,\n isFormValid: !(_opts != null && _opts.validate)\n }), {\n onUpdate: next => {\n // Computed state\n const fieldMetaValues = Object.values(next.fieldMeta);\n const isFieldsValidating = fieldMetaValues.some(field => field == null ? void 0 : field.isValidating);\n const isFieldsValid = !fieldMetaValues.some(field => field == null ? void 0 : field.error);\n const isTouched = fieldMetaValues.some(field => field == null ? void 0 : field.isTouched);\n const isValidating = isFieldsValidating || next.isFormValidating;\n const isFormValid = !next.formError;\n const isValid = isFieldsValid && isFormValid;\n const canSubmit = next.submissionAttempts === 0 && !isTouched || !isValidating && !next.isSubmitting && isValid;\n next = { ...next,\n isFieldsValidating,\n isFieldsValid,\n isFormValid,\n isValid,\n canSubmit,\n isTouched\n }; // Create a shortcut for the state\n // Write it back to the store\n\n this.store.state = next;\n this.state = next;\n }\n });\n this.state = this.store.state;\n this.update(_opts || {});\n }\n\n}\n\nvar id = 0;\n\nfunction _classPrivateFieldLooseKey(name) {\n return \"__private_\" + id++ + \"_\" + name;\n}\n\nfunction _classPrivateFieldLooseBase(receiver, privateKey) {\n if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {\n throw new TypeError(\"attempted to use private field on non-instance\");\n }\n\n return receiver;\n}\n\nlet uid = 0;\n\nvar _updateStore = /*#__PURE__*/_classPrivateFieldLooseKey(\"updateStore\");\n\nvar _leaseValidateAsync = /*#__PURE__*/_classPrivateFieldLooseKey(\"leaseValidateAsync\");\n\nclass FieldApi {\n constructor(_opts) {\n var _this$getMeta;\n\n this.options = {};\n\n this.mount = () => {\n const info = this.getInfo();\n info.instances[this.uid] = this;\n const unsubscribe = this.form.store.subscribe(() => {\n _classPrivateFieldLooseBase(this, _updateStore)[_updateStore]();\n });\n return () => {\n unsubscribe();\n delete info.instances[this.uid];\n\n if (!Object.keys(info.instances).length) {\n delete this.form.fieldInfo[this.name];\n }\n };\n };\n\n Object.defineProperty(this, _updateStore, {\n writable: true,\n value: () => {\n this.store.batch(() => {\n const nextValue = this.getValue();\n const nextMeta = this.getMeta();\n\n if (nextValue !== this.state.value) {\n this.store.setState(prev => ({ ...prev,\n value: nextValue\n }));\n }\n\n if (nextMeta !== this.state.meta) {\n this.store.setState(prev => ({ ...prev,\n meta: nextMeta\n }));\n }\n });\n }\n });\n\n this.update = opts => {\n var _this$form$options$de, _this$form$options$de2, _this$form$options$de3, _this$form$options$de4;\n\n this.options = {\n validatePristine: (_this$form$options$de = this.form.options.defaultValidatePristine) != null ? _this$form$options$de : false,\n validateOn: (_this$form$options$de2 = this.form.options.defaultValidateOn) != null ? _this$form$options$de2 : 'change',\n validateAsyncOn: (_this$form$options$de3 = this.form.options.defaultValidateAsyncOn) != null ? _this$form$options$de3 : 'blur',\n validateAsyncDebounceMs: (_this$form$options$de4 = this.form.options.defaultValidateAsyncDebounceMs) != null ? _this$form$options$de4 : 0,\n ...opts\n }; // Default Value\n\n if (this.state.value === undefined && this.options.defaultValue !== undefined) {\n this.setValue(this.options.defaultValue);\n } // Default Meta\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\n\n if (this.getMeta() === undefined) {\n this.setMeta(this.state.meta);\n }\n };\n\n this.getValue = () => this.form.getFieldValue(this.name);\n\n this.setValue = (updater, options) => this.form.setFieldValue(this.name, updater, options);\n\n this.getMeta = () => this.form.getFieldMeta(this.name);\n\n this.setMeta = updater => this.form.setFieldMeta(this.name, updater);\n\n this.getInfo = () => this.form.getFieldInfo(this.name);\n\n this.pushValue = value => this.form.pushFieldValue(this.name, value);\n\n this.insertValue = (index, value) => this.form.insertFieldValue(this.name, index, value);\n\n this.removeValue = index => this.form.spliceFieldValue(this.name, index);\n\n this.swapValues = (aIndex, bIndex) => this.form.swapFieldValues(this.name, aIndex, bIndex);\n\n this.getSubField = name => new FieldApi({\n name: this.name + \".\" + name,\n form: this.form\n });\n\n this.validateSync = async (value = this.state.value) => {\n const {\n validate\n } = this.options;\n\n if (!validate) {\n return;\n } // Use the validationCount for all field instances to\n // track freshness of the validation\n\n\n const validationCount = (this.getInfo().validationCount || 0) + 1;\n this.getInfo().validationCount = validationCount;\n const error = normalizeError(validate(value, this));\n\n if (this.state.meta.error !== error) {\n this.setMeta(prev => ({ ...prev,\n error\n }));\n } // If a sync error is encountered, cancel any async validation\n\n\n if (this.state.meta.error) {\n this.cancelValidateAsync();\n }\n };\n\n Object.defineProperty(this, _leaseValidateAsync, {\n writable: true,\n value: () => {\n const count = (this.getInfo().validationAsyncCount || 0) + 1;\n this.getInfo().validationAsyncCount = count;\n return count;\n }\n });\n\n this.cancelValidateAsync = () => {\n // Lease a new validation count to ignore any pending validations\n _classPrivateFieldLooseBase(this, _leaseValidateAsync)[_leaseValidateAsync](); // Cancel any pending validation state\n\n\n this.setMeta(prev => ({ ...prev,\n isValidating: false\n }));\n };\n\n this.validateAsync = async (value = this.state.value) => {\n const {\n validateAsync,\n validateAsyncDebounceMs\n } = this.options;\n\n if (!validateAsync) {\n return;\n }\n\n if (this.state.meta.isValidating !== true) this.setMeta(prev => ({ ...prev,\n isValidating: true\n })); // Use the validationCount for all field instances to\n // track freshness of the validation\n\n const validationAsyncCount = _classPrivateFieldLooseBase(this, _leaseValidateAsync)[_leaseValidateAsync]();\n\n const checkLatest = () => validationAsyncCount === this.getInfo().validationAsyncCount;\n\n if (!this.getInfo().validationPromise) {\n this.getInfo().validationPromise = new Promise((resolve, reject) => {\n this.getInfo().validationResolve = resolve;\n this.getInfo().validationReject = reject;\n });\n }\n\n if (validateAsyncDebounceMs > 0) {\n await new Promise(r => setTimeout(r, validateAsyncDebounceMs));\n } // Only kick off validation if this validation is the latest attempt\n\n\n if (checkLatest()) {\n try {\n const rawError = await validateAsync(value, this);\n\n if (checkLatest()) {\n var _this$getInfo$validat, _this$getInfo;\n\n const error = normalizeError(rawError);\n this.setMeta(prev => ({ ...prev,\n isValidating: false,\n error\n }));\n (_this$getInfo$validat = (_this$getInfo = this.getInfo()).validationResolve) == null ? void 0 : _this$getInfo$validat.call(_this$getInfo, error);\n }\n } catch (error) {\n if (checkLatest()) {\n var _this$getInfo$validat2, _this$getInfo2;\n\n (_this$getInfo$validat2 = (_this$getInfo2 = this.getInfo()).validationReject) == null ? void 0 : _this$getInfo$validat2.call(_this$getInfo2, error);\n throw error;\n }\n } finally {\n if (checkLatest()) {\n this.setMeta(prev => ({ ...prev,\n isValidating: false\n }));\n delete this.getInfo().validationPromise;\n }\n }\n } // Always return the latest validation promise to the caller\n\n\n return this.getInfo().validationPromise;\n };\n\n this.shouldValidate = (isAsync, cause) => {\n const {\n validateOn,\n validateAsyncOn\n } = this.options;\n const level = getValidationCauseLevel(cause); // Must meet *at least* the validation level to validate,\n // e.g. if validateOn is 'change' and validateCause is 'blur',\n // the field will still validate\n\n return Object.keys(validateCauseLevels).some(d => isAsync ? validateAsyncOn : validateOn === d && level >= validateCauseLevels[d]);\n };\n\n this.validate = async (cause, value) => {\n // If the field is pristine and validatePristine is false, do not validate\n if (!this.options.validatePristine && !this.state.meta.isTouched) return; // Attempt to sync validate first\n\n if (this.shouldValidate(false, cause)) {\n this.validateSync(value);\n } // If there is an error, return it, do not attempt async validation\n\n\n if (this.state.meta.error) {\n return this.state.meta.error;\n } // No error? Attempt async validation\n\n\n if (this.shouldValidate(true, cause)) {\n return this.validateAsync(value);\n } // If there is no sync error or async validation attempt, there is no error\n\n\n return undefined;\n };\n\n this.getChangeProps = (props = {}) => {\n return { ...props,\n value: this.state.value,\n onChange: value => {\n this.setValue(value);\n props.onChange == null ? void 0 : props.onChange(value);\n },\n onBlur: e => {\n this.setMeta(prev => ({ ...prev,\n isTouched: true\n }));\n this.validate('blur');\n props.onBlur == null ? void 0 : props.onBlur(e);\n }\n };\n };\n\n this.getInputProps = (props = {}) => {\n return { ...props,\n value: String(this.state.value),\n onChange: e => {\n this.setValue(e.target.value);\n props.onChange == null ? void 0 : props.onChange(e.target.value);\n },\n onBlur: this.getChangeProps(props).onBlur\n };\n };\n\n this.form = _opts.form;\n this.uid = uid++; // Support field prefixing from FieldScope\n\n let fieldPrefix = '';\n\n if (this.form.fieldName) {\n fieldPrefix = this.form.fieldName + \".\";\n }\n\n this.name = fieldPrefix + _opts.name;\n this.store = new Store({\n value: this.getValue(),\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n meta: (_this$getMeta = this.getMeta()) != null ? _this$getMeta : {\n isValidating: false,\n isTouched: false,\n ...this.options.defaultMeta\n }\n }, {\n onUpdate: next => {\n next.meta.touchedError = next.meta.isTouched ? next.meta.error : undefined; // Do not validate pristine fields\n\n const prevState = this.state;\n this.state = next;\n\n if (next.value !== prevState.value) {\n this.validate('change', next.value);\n }\n }\n });\n this.state = this.store.state;\n this.update(_opts);\n }\n\n}\nconst validateCauseLevels = {\n change: 0,\n blur: 1,\n submit: 2\n};\n\nfunction getValidationCauseLevel(cause) {\n return !cause ? 3 : validateCauseLevels[cause];\n}\n\nfunction normalizeError(rawError) {\n if (rawError) {\n if (typeof rawError !== 'string') {\n return 'Invalid Form Values';\n }\n\n return rawError;\n }\n\n return undefined;\n}\n\nexport { FieldApi, FormApi, functionalUpdate, getBy, getDefaultFormState, setBy };\n//# sourceMappingURL=index.js.map\n","/**\n * react-store\n *\n * Copyright (c) TanStack\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.md file in the root directory of this source tree.\n *\n * @license MIT\n */\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';\nexport * from '@tanstack/store';\n\nfunction useStore(store, selector = d => d) {\n const slice = useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow);\n return slice;\n}\nfunction shallow(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {\n return false;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (let i = 0; i < keysA.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {\n return false;\n }\n }\n return true;\n}\n\nexport { shallow, useStore };\n//# sourceMappingURL=index.js.map\n","import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<FormApi<any> | null>(null)\n\nexport function useFormContext(customFormApi?: FormApi<any>) {\n const formApi = React.useContext(formContext)\n\n if (customFormApi) {\n return customFormApi\n }\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n","import * as React from 'react'\n//\nimport { useStore } from '@tanstack/react-store'\nimport type {\n DeepKeys,\n DeepValue,\n FieldOptions,\n FormApi,\n} from '@tanstack/form-core'\nimport { FieldApi } from '@tanstack/form-core'\nimport { useFormContext } from './formContext'\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: TField } & FieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function createUseField<TFormData>(formApi: FormApi<TFormData>) {\n const useFormField: UseField<TFormData> = (opts) => {\n return useField({ ...opts, form: formApi } as any)\n }\n\n return useFormField\n}\n\nexport function useField<TData, TFormData>(\n opts: FieldOptions<TData, TFormData> & {\n // selector: (state: FieldApi<TData, TFormData>) => TSelected\n },\n): FieldApi<TData, TFormData> {\n // invariant( // TODO:\n // opts.name,\n // `useField: A field is required to use this hook. eg, useField('myField', options)`\n // )\n\n // Get the form API either manually or from context\n const formApi = useFormContext(opts.form)\n\n const [fieldApi] = React.useState<FieldApi<TData, TFormData>>(\n () => new FieldApi({ ...opts, form: formApi }),\n )\n\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi })\n\n useStore(fieldApi.store)\n\n // Instantiates field meta and removes it when unrendered\n React.useEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi\n}\n","import * as React from 'react'\nimport {\n functionalUpdate,\n type DeepKeys,\n type DeepValue,\n type FieldApi,\n type FieldOptions,\n type FormApi,\n} from '@tanstack/form-core'\nimport { useField } from './useField'\n\n//\n\nexport type FieldComponent<TFormData> = <TField extends DeepKeys<TFormData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<DeepValue<TFormData, TField>, TFormData>) => any\n name: TField\n} & Omit<FieldOptions<DeepValue<TFormData, TField>, TFormData>, 'name'>) => any\n\nexport function createFieldComponent<TFormData>(formApi: FormApi<TFormData>) {\n const ConnectedField: FieldComponent<TFormData> = (props) => (\n <Field {...(props as any)} form={formApi} />\n )\n return ConnectedField\n}\n\nexport function Field<TData, TFormData>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TFormData>) => any\n} & FieldOptions<TData, TFormData>) {\n const fieldApi = useField(fieldOptions as any)\n return functionalUpdate(children, fieldApi as any)\n}\n","import type { FormState, FormOptions } from '@tanstack/form-core'\nimport { FormApi, functionalUpdate } from '@tanstack/form-core'\nimport type { NoInfer } from '@tanstack/react-store'\nimport { useStore } from '@tanstack/react-store'\nimport React from 'react'\nimport { createFieldComponent, type FieldComponent } from './Field'\nimport { createUseField, type UseField } from './useField'\nimport { formContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Form: FormComponent\n Field: FieldComponent<TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n children:\n | ((state: NoInfer<TSelected>) => React.ReactNode)\n | React.ReactNode\n }) => any\n }\n}\n//\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const [formApi] = React.useState(() => {\n // @ts-ignore\n const api = new FormApi<TData>(opts || {})\n\n api.Form = createFormComponent(api)\n api.Field = createFieldComponent(api)\n api.useField = createUseField(api)\n api.useStore = (\n // @ts-ignore\n selector,\n ) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useStore(api.store, selector) as any\n }\n api.Subscribe = (\n // @ts-ignore\n props,\n ) => {\n return functionalUpdate(\n props.children,\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStore(api.store, props.selector),\n ) as any\n }\n\n return api\n })\n\n // React.useEffect(() => formApi.mount(), [])\n\n return formApi\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nexport function createFormComponent(formApi: FormApi<any>) {\n const Form: FormComponent = ({ children, noFormElement, ...rest }) => {\n const isSubmitting = formApi.useStore((state) => state.isSubmitting)\n\n return (\n <formContext.Provider value={formApi}>\n {noFormElement ? (\n children\n ) : (\n <form\n onSubmit={formApi.handleSubmit}\n disabled={isSubmitting}\n {...rest}\n >\n {formApi.options.debugForm ? (\n <div\n style={{\n margin: '2rem 0',\n }}\n >\n <div\n style={{\n fontWeight: 'bolder',\n }}\n >\n Form State\n </div>\n <pre>\n <code>\n {JSON.stringify(formApi, safeStringifyReplace(), 2)}\n </code>\n </pre>\n </div>\n ) : null}\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n\nfunction safeStringifyReplace() {\n const set = new Set()\n return (_key: string, value: any) => {\n if (typeof value === 'object' || Array.isArray(value)) {\n if (set.has(value)) {\n return '(circular value)'\n }\n set.add(value)\n }\n return typeof value === 'function' ? undefined : value\n }\n}\n"],"names":["Store","listeners","Set","batching","queue","constructor","initialState","options","this","state","subscribe","listener","add","unsub","onSubscribe","delete","setState","updater","previous","updateFn","onUpdate","push","forEach","flush","cb","batch","functionalUpdate","input","getBy","obj","path","Error","makePathArray","reduce","current","pathPart","setBy","_path","doSet","parent","length","key","shift","Array","isArray","prefix","slice","reFindNumbers0","reFindNumbers1","reFindNumbers2","reFindNumbers3","reFindMultiplePeriods","str","replace","split","map","d","indexOf","parseInt","substring","getDefaultFormState","defaultState","values","fieldMeta","canSubmit","isFieldsValid","isFieldsValidating","isFormValid","isFormValidating","isSubmitted","isSubmitting","isTouched","isValid","isValidating","submissionAttempts","formValidationCount","FormApi","_opts","_opts$defaultValues","_opts$defaultState","fieldInfo","validationMeta","update","store","prev","defaultValues","reset","validateAllFields","async","fieldValidationPromises","Object","field","instances","instance","meta","setMeta","validate","Promise","all","validateForm","checkLatest","validationPromise","resolve","reject","validationResolve","validationReject","error","_this$validationMeta$","_this$validationMeta","call","err","_this$validationMeta$2","_this$validationMeta2","doValidation","handleSubmit","e","preventDefault","stopPropagation","old","done","_this$options$onInval","_this$options","_this$options$onInval2","_this$options2","onInvalidSubmit","_this$options$onSubmi","_this$options3","onSubmit","getFieldValue","getFieldMeta","getFieldInfo","_this$fieldInfo","setFieldMeta","setFieldValue","opts","_opts$touch","touch","pushFieldValue","value","insertFieldValue","index","i","spliceFieldValue","filter","_d","swapFieldValues","index1","index2","prev1","prev2","next","fieldMetaValues","some","formError","id","_classPrivateFieldLooseKey","name","_classPrivateFieldLooseBase","receiver","privateKey","prototype","hasOwnProperty","TypeError","uid","_updateStore","_leaseValidateAsync","FieldApi","_this$getMeta","mount","info","getInfo","unsubscribe","form","keys","defineProperty","writable","nextValue","getValue","nextMeta","getMeta","_this$form$options$de","_this$form$options$de2","_this$form$options$de3","_this$form$options$de4","validatePristine","defaultValidatePristine","validateOn","defaultValidateOn","validateAsyncOn","defaultValidateAsyncOn","validateAsyncDebounceMs","defaultValidateAsyncDebounceMs","undefined","defaultValue","setValue","pushValue","insertValue","removeValue","swapValues","aIndex","bIndex","getSubField","validateSync","validationCount","normalizeError","cancelValidateAsync","count","validationAsyncCount","validateAsync","r","setTimeout","rawError","_this$getInfo$validat","_this$getInfo","_this$getInfo$validat2","_this$getInfo2","shouldValidate","isAsync","cause","level","validateCauseLevels","getValidationCauseLevel","getChangeProps","props","onChange","onBlur","getInputProps","String","target","fieldPrefix","fieldName","defaultMeta","touchedError","prevState","change","blur","submit","useStore","selector","useSyncExternalStoreWithSelector","shallow","objA","objB","is","keysA","formContext","React","createContext","createUseField","formApi","useField","customFormApi","useContext","useFormContext","fieldApi","useState","useEffect","createFieldComponent","createElement","Field","children","fieldOptions","createFormComponent","noFormElement","rest","Provider","_extends","disabled","debugForm","style","margin","fontWeight","JSON","stringify","set","_key","has","safeStringifyReplace","api","Form","Subscribe"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,MAAMA,EACJC,UAAY,IAAIC,IAChBC,UAAW,EACXC,MAAQ,GACRC,YAAYC,EAAcC,GACxBC,KAAKC,MAAQH,EACbE,KAAKD,QAAUA,EAEjBG,UAAYC,IACVH,KAAKP,UAAUW,IAAID,GACnB,MAAME,EAAQL,KAAKD,SAASO,cAAcH,EAAUH,MACpD,MAAO,KACLA,KAAKP,UAAUc,OAAOJ,GACtBE,QAGJG,SAAWC,IACT,MAAMC,EAAWV,KAAKC,MACtBD,KAAKC,MAAQD,KAAKD,SAASY,SAAWX,KAAKD,QAAQY,SAASD,EAAtBV,CAAgCS,GAAWA,EAAQC,GACrFV,KAAKC,QAAUS,IACnBV,KAAKD,SAASa,WAAWZ,KAAKC,MAAOS,GACrCV,KAAKJ,MAAMiB,M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AI8H,GAEV,MAAwB,mBAAVA,OAAuBsD,EAAYtD,GAxBR2I,GAAwB,MAIrD,KACHjB,oMA3EN,SAAwB9H,GAC7B,MAAOmH,GAAWH,EAAK,QAACS,UAAS,KAE/B,MAAMuB,EAAM,IAAI1M,EAAe0D,GAAQ,IAuBvC,OArBAgJ,EAAIC,KAAOjB,EAAoBgB,GAC/BA,EAAInB,MAAQF,EAAqBqB,GACjCA,EAAI5B,SAAWF,EAAe8B,GAC9BA,EAAIzC,SAEFC,GAGOD,EAASyC,EAAInM,MAAO2J,GAE7BwC,EAAIE,UAEFzD,GAEOrM,EACLqM,EAAMqC,SAENvB,EAASyC,EAAInM,MAAO4I,EAAMe,WAIvBwC,KAKT,OAAO7B"}
1
+ {"version":3,"file":"index.production.js","sources":["../../../../node_modules/.pnpm/@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js","../../../form-core/build/esm/index.js","../../../../node_modules/.pnpm/@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js","../../src/formContext.ts","../../src/useField.ts","../../src/Field.tsx","../../src/useForm.tsx","../../src/createFormFactory.ts"],"sourcesContent":["/**\n * store\n *\n * Copyright (c) TanStack\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.md file in the root directory of this source tree.\n *\n * @license MIT\n */\nclass Store {\n listeners = new Set();\n batching = false;\n queue = [];\n constructor(initialState, options) {\n this.state = initialState;\n this.options = options;\n }\n subscribe = listener => {\n this.listeners.add(listener);\n const unsub = this.options?.onSubscribe?.(listener, this);\n return () => {\n this.listeners.delete(listener);\n unsub?.();\n };\n };\n setState = updater => {\n const previous = this.state;\n this.state = this.options?.updateFn ? this.options.updateFn(previous)(updater) : updater(previous);\n if (this.state === previous) return;\n this.options?.onUpdate?.(this.state, previous);\n this.queue.push(() => {\n this.listeners.forEach(listener => listener(this.state, previous));\n });\n this.#flush();\n };\n #flush = () => {\n if (this.batching) return;\n this.queue.forEach(cb => cb());\n this.queue = [];\n };\n batch = cb => {\n this.batching = true;\n cb();\n this.batching = false;\n this.#flush();\n };\n}\n\nexport { Store };\n//# sourceMappingURL=index.js.map\n","/**\n * form-core\n *\n * Copyright (c) TanStack\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.md file in the root directory of this source tree.\n *\n * @license MIT\n */\nimport { Store } from '@tanstack/store';\n\nfunction functionalUpdate(updater, input) {\n return typeof updater === 'function' ? updater(input) : updater;\n}\nfunction getBy(obj, path) {\n if (!path) {\n throw new Error('A path string is required to use getBy');\n }\n\n const pathArray = makePathArray(path);\n const pathObj = pathArray;\n return pathObj.reduce((current, pathPart) => {\n if (typeof current !== 'undefined') {\n return current[pathPart];\n }\n\n return undefined;\n }, obj);\n}\nfunction setBy(obj, _path, updater) {\n const path = makePathArray(_path);\n\n function doSet(parent) {\n if (!path.length) {\n return functionalUpdate(updater, parent);\n }\n\n const key = path.shift();\n\n if (typeof key === 'string') {\n if (typeof parent === 'object') {\n return { ...parent,\n [key]: doSet(parent[key])\n };\n }\n\n return {\n [key]: doSet()\n };\n }\n\n if (typeof key === 'number') {\n if (Array.isArray(parent)) {\n const prefix = parent.slice(0, key);\n return [...(prefix.length ? prefix : new Array(key)), doSet(parent[key]), ...parent.slice(key + 1)];\n }\n\n return [...new Array(key), doSet()];\n }\n\n throw new Error('Uh oh!');\n }\n\n return doSet(obj);\n}\nconst reFindNumbers0 = /^(\\d*)$/gm;\nconst reFindNumbers1 = /\\.(\\d*)\\./gm;\nconst reFindNumbers2 = /^(\\d*)\\./gm;\nconst reFindNumbers3 = /\\.(\\d*$)/gm;\nconst reFindMultiplePeriods = /\\.{2,}/gm;\n\nfunction makePathArray(str) {\n return str.replace('[', '.').replace(']', '').replace(reFindNumbers0, '__int__$1').replace(reFindNumbers1, '.__int__$1.').replace(reFindNumbers2, '__int__$1.').replace(reFindNumbers3, '.__int__$1').replace(reFindMultiplePeriods, '.').split('.').map(d => {\n if (d.indexOf('__int__') === 0) {\n return parseInt(d.substring('__int__'.length), 10);\n }\n\n return d;\n });\n}\n\nfunction getDefaultFormState(defaultState) {\n return {\n values: {},\n fieldMeta: {},\n canSubmit: true,\n isFieldsValid: false,\n isFieldsValidating: false,\n isFormValid: false,\n isFormValidating: false,\n isSubmitted: false,\n isSubmitting: false,\n isTouched: false,\n isValid: false,\n isValidating: false,\n submissionAttempts: 0,\n formValidationCount: 0,\n ...defaultState\n };\n}\n\nclass FormApi {\n // // This carries the context for nested fields\n constructor(_opts) {\n var _opts$defaultValues, _opts$defaultState;\n\n this.options = {};\n this.fieldInfo = {};\n this.validationMeta = {};\n\n this.update = options => {\n this.store.batch(() => {\n if (options.defaultState && options.defaultState !== this.options.defaultState) {\n this.store.setState(prev => ({ ...prev,\n ...options.defaultState\n }));\n }\n\n if (options.defaultValues !== this.options.defaultValues) {\n this.store.setState(prev => ({ ...prev,\n values: options.defaultValues\n }));\n }\n });\n this.options = options;\n };\n\n this.reset = () => this.store.setState(() => getDefaultFormState(this.options.defaultValues));\n\n this.validateAllFields = async () => {\n const fieldValidationPromises = [];\n this.store.batch(() => {\n void Object.values(this.fieldInfo).forEach(field => {\n Object.values(field.instances).forEach(instance => {\n // If any fields are not touched\n if (!instance.state.meta.isTouched) {\n // Mark them as touched\n instance.setMeta(prev => ({ ...prev,\n isTouched: true\n })); // Validate the field\n\n if (instance.options.validate) {\n fieldValidationPromises.push(instance.validate());\n }\n }\n });\n });\n });\n return Promise.all(fieldValidationPromises);\n };\n\n this.validateForm = async () => {\n const {\n validate\n } = this.options;\n\n if (!validate) {\n return;\n } // Use the formValidationCount for all field instances to\n // track freshness of the validation\n\n\n this.store.setState(prev => ({ ...prev,\n isValidating: true,\n formValidationCount: prev.formValidationCount + 1\n }));\n const formValidationCount = this.state.formValidationCount;\n\n const checkLatest = () => formValidationCount === this.state.formValidationCount;\n\n if (!this.validationMeta.validationPromise) {\n this.validationMeta.validationPromise = new Promise((resolve, reject) => {\n this.validationMeta.validationResolve = resolve;\n this.validationMeta.validationReject = reject;\n });\n }\n\n const doValidation = async () => {\n try {\n const error = await validate(this.state.values, this);\n\n if (checkLatest()) {\n var _this$validationMeta$, _this$validationMeta;\n\n this.store.setState(prev => ({ ...prev,\n isValidating: false,\n error: error ? typeof error === 'string' ? error : 'Invalid Form Values' : null\n }));\n (_this$validationMeta$ = (_this$validationMeta = this.validationMeta).validationResolve) == null ? void 0 : _this$validationMeta$.call(_this$validationMeta, error);\n }\n } catch (err) {\n if (checkLatest()) {\n var _this$validationMeta$2, _this$validationMeta2;\n\n (_this$validationMeta$2 = (_this$validationMeta2 = this.validationMeta).validationReject) == null ? void 0 : _this$validationMeta$2.call(_this$validationMeta2, err);\n }\n } finally {\n delete this.validationMeta.validationPromise;\n }\n };\n\n doValidation();\n return this.validationMeta.validationPromise;\n };\n\n this.handleSubmit = async e => {\n e.preventDefault();\n e.stopPropagation(); // Check to see that the form and all fields have been touched\n // If they have not, touch them all and run validation\n // Run form validation\n // Submit the form\n\n this.store.setState(old => ({ ...old,\n // Submittion attempts mark the form as not submitted\n isSubmitted: false,\n // Count submission attempts\n submissionAttempts: old.submissionAttempts + 1\n })); // Don't let invalid forms submit\n\n if (!this.state.canSubmit) return;\n this.store.setState(d => ({ ...d,\n isSubmitting: true\n }));\n\n const done = () => {\n this.store.setState(prev => ({ ...prev,\n isSubmitting: false\n }));\n }; // Validate all fields\n\n\n await this.validateAllFields(); // Fields are invalid, do not submit\n\n if (!this.state.isFieldsValid) {\n var _this$options$onInval, _this$options;\n\n done();\n (_this$options$onInval = (_this$options = this.options).onInvalidSubmit) == null ? void 0 : _this$options$onInval.call(_this$options, this.state.values, this);\n return;\n } // Run validation for the form\n\n\n await this.validateForm();\n\n if (!this.state.isValid) {\n var _this$options$onInval2, _this$options2;\n\n done();\n (_this$options$onInval2 = (_this$options2 = this.options).onInvalidSubmit) == null ? void 0 : _this$options$onInval2.call(_this$options2, this.state.values, this);\n return;\n }\n\n try {\n var _this$options$onSubmi, _this$options3;\n\n // Run the submit code\n await ((_this$options$onSubmi = (_this$options3 = this.options).onSubmit) == null ? void 0 : _this$options$onSubmi.call(_this$options3, this.state.values, this));\n this.store.batch(() => {\n this.store.setState(prev => ({ ...prev,\n isSubmitted: true\n }));\n done();\n });\n } catch (err) {\n done();\n throw err;\n }\n };\n\n this.getFieldValue = field => getBy(this.state.values, field);\n\n this.getFieldMeta = field => {\n return this.state.fieldMeta[field];\n };\n\n this.getFieldInfo = field => {\n var _this$fieldInfo;\n\n return (_this$fieldInfo = this.fieldInfo)[field] || (_this$fieldInfo[field] = {\n instances: {}\n });\n };\n\n this.setFieldMeta = (field, updater) => {\n this.store.setState(prev => {\n return { ...prev,\n fieldMeta: { ...prev.fieldMeta,\n [field]: functionalUpdate(updater, prev.fieldMeta[field])\n }\n };\n });\n };\n\n this.setFieldValue = (field, updater, opts) => {\n var _opts$touch;\n\n const touch = (_opts$touch = opts == null ? void 0 : opts.touch) != null ? _opts$touch : true;\n this.store.batch(() => {\n this.store.setState(prev => {\n return { ...prev,\n values: setBy(prev.values, field, updater)\n };\n });\n\n if (touch) {\n this.setFieldMeta(field, prev => ({ ...prev,\n isTouched: true\n }));\n }\n });\n };\n\n this.pushFieldValue = (field, value, opts) => {\n return this.setFieldValue(field, prev => [...(Array.isArray(prev) ? prev : []), value], opts);\n };\n\n this.insertFieldValue = (field, index, value, opts) => {\n this.setFieldValue(field, prev => {\n // invariant( // TODO: bring in invariant\n // Array.isArray(prev),\n // `Cannot insert a field value into a non-array field. Check that this field's existing value is an array: ${field}.`\n // )\n return prev.map((d, i) => i === index ? value : d);\n }, opts);\n };\n\n this.spliceFieldValue = (field, index, opts) => {\n this.setFieldValue(field, prev => {\n // invariant( // TODO: bring in invariant\n // Array.isArray(prev),\n // `Cannot insert a field value into a non-array field. Check that this field's existing value is an array: ${field}.`\n // )\n return prev.filter((_d, i) => i !== index);\n }, opts);\n };\n\n this.swapFieldValues = (field, index1, index2) => {\n this.setFieldValue(field, prev => {\n const prev1 = prev[index1];\n const prev2 = prev[index2];\n return setBy(setBy(prev, [index1], prev2), [index2], prev1);\n });\n };\n\n this.store = new Store(getDefaultFormState({ ...(_opts == null ? void 0 : _opts.defaultState),\n values: (_opts$defaultValues = _opts == null ? void 0 : _opts.defaultValues) != null ? _opts$defaultValues : _opts == null ? void 0 : (_opts$defaultState = _opts.defaultState) == null ? void 0 : _opts$defaultState.values,\n isFormValid: !(_opts != null && _opts.validate)\n }), {\n onUpdate: next => {\n // Computed state\n const fieldMetaValues = Object.values(next.fieldMeta);\n const isFieldsValidating = fieldMetaValues.some(field => field == null ? void 0 : field.isValidating);\n const isFieldsValid = !fieldMetaValues.some(field => field == null ? void 0 : field.error);\n const isTouched = fieldMetaValues.some(field => field == null ? void 0 : field.isTouched);\n const isValidating = isFieldsValidating || next.isFormValidating;\n const isFormValid = !next.formError;\n const isValid = isFieldsValid && isFormValid;\n const canSubmit = next.submissionAttempts === 0 && !isTouched || !isValidating && !next.isSubmitting && isValid;\n next = { ...next,\n isFieldsValidating,\n isFieldsValid,\n isFormValid,\n isValid,\n canSubmit,\n isTouched\n }; // Create a shortcut for the state\n // Write it back to the store\n\n this.store.state = next;\n this.state = next;\n }\n });\n this.state = this.store.state;\n this.update(_opts || {});\n }\n\n}\n\nvar id = 0;\n\nfunction _classPrivateFieldLooseKey(name) {\n return \"__private_\" + id++ + \"_\" + name;\n}\n\nfunction _classPrivateFieldLooseBase(receiver, privateKey) {\n if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {\n throw new TypeError(\"attempted to use private field on non-instance\");\n }\n\n return receiver;\n}\n\nlet uid = 0;\n\nvar _updateStore = /*#__PURE__*/_classPrivateFieldLooseKey(\"updateStore\");\n\nvar _leaseValidateAsync = /*#__PURE__*/_classPrivateFieldLooseKey(\"leaseValidateAsync\");\n\nclass FieldApi {\n constructor(_opts) {\n var _this$getMeta;\n\n this.options = {};\n\n this.mount = () => {\n const info = this.getInfo();\n info.instances[this.uid] = this;\n const unsubscribe = this.form.store.subscribe(() => {\n _classPrivateFieldLooseBase(this, _updateStore)[_updateStore]();\n });\n return () => {\n unsubscribe();\n delete info.instances[this.uid];\n\n if (!Object.keys(info.instances).length) {\n delete this.form.fieldInfo[this.name];\n }\n };\n };\n\n Object.defineProperty(this, _updateStore, {\n writable: true,\n value: () => {\n this.store.batch(() => {\n const nextValue = this.getValue();\n const nextMeta = this.getMeta();\n\n if (nextValue !== this.state.value) {\n this.store.setState(prev => ({ ...prev,\n value: nextValue\n }));\n }\n\n if (nextMeta !== this.state.meta) {\n this.store.setState(prev => ({ ...prev,\n meta: nextMeta\n }));\n }\n });\n }\n });\n\n this.update = opts => {\n var _this$form$options$de, _this$form$options$de2, _this$form$options$de3, _this$form$options$de4;\n\n this.options = {\n validatePristine: (_this$form$options$de = this.form.options.defaultValidatePristine) != null ? _this$form$options$de : false,\n validateOn: (_this$form$options$de2 = this.form.options.defaultValidateOn) != null ? _this$form$options$de2 : 'change',\n validateAsyncOn: (_this$form$options$de3 = this.form.options.defaultValidateAsyncOn) != null ? _this$form$options$de3 : 'blur',\n validateAsyncDebounceMs: (_this$form$options$de4 = this.form.options.defaultValidateAsyncDebounceMs) != null ? _this$form$options$de4 : 0,\n ...opts\n }; // Default Value\n\n if (this.state.value === undefined && this.options.defaultValue !== undefined) {\n this.setValue(this.options.defaultValue);\n } // Default Meta\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n\n\n if (this.getMeta() === undefined) {\n this.setMeta(this.state.meta);\n }\n };\n\n this.getValue = () => this.form.getFieldValue(this.name);\n\n this.setValue = (updater, options) => this.form.setFieldValue(this.name, updater, options);\n\n this.getMeta = () => this.form.getFieldMeta(this.name);\n\n this.setMeta = updater => this.form.setFieldMeta(this.name, updater);\n\n this.getInfo = () => this.form.getFieldInfo(this.name);\n\n this.pushValue = value => this.form.pushFieldValue(this.name, value);\n\n this.insertValue = (index, value) => this.form.insertFieldValue(this.name, index, value);\n\n this.removeValue = index => this.form.spliceFieldValue(this.name, index);\n\n this.swapValues = (aIndex, bIndex) => this.form.swapFieldValues(this.name, aIndex, bIndex);\n\n this.getSubField = name => new FieldApi({\n name: this.name + \".\" + name,\n form: this.form\n });\n\n this.validateSync = async (value = this.state.value) => {\n const {\n validate\n } = this.options;\n\n if (!validate) {\n return;\n } // Use the validationCount for all field instances to\n // track freshness of the validation\n\n\n const validationCount = (this.getInfo().validationCount || 0) + 1;\n this.getInfo().validationCount = validationCount;\n const error = normalizeError(validate(value, this));\n\n if (this.state.meta.error !== error) {\n this.setMeta(prev => ({ ...prev,\n error\n }));\n } // If a sync error is encountered, cancel any async validation\n\n\n if (this.state.meta.error) {\n this.cancelValidateAsync();\n }\n };\n\n Object.defineProperty(this, _leaseValidateAsync, {\n writable: true,\n value: () => {\n const count = (this.getInfo().validationAsyncCount || 0) + 1;\n this.getInfo().validationAsyncCount = count;\n return count;\n }\n });\n\n this.cancelValidateAsync = () => {\n // Lease a new validation count to ignore any pending validations\n _classPrivateFieldLooseBase(this, _leaseValidateAsync)[_leaseValidateAsync](); // Cancel any pending validation state\n\n\n this.setMeta(prev => ({ ...prev,\n isValidating: false\n }));\n };\n\n this.validateAsync = async (value = this.state.value) => {\n const {\n validateAsync,\n validateAsyncDebounceMs\n } = this.options;\n\n if (!validateAsync) {\n return;\n }\n\n if (this.state.meta.isValidating !== true) this.setMeta(prev => ({ ...prev,\n isValidating: true\n })); // Use the validationCount for all field instances to\n // track freshness of the validation\n\n const validationAsyncCount = _classPrivateFieldLooseBase(this, _leaseValidateAsync)[_leaseValidateAsync]();\n\n const checkLatest = () => validationAsyncCount === this.getInfo().validationAsyncCount;\n\n if (!this.getInfo().validationPromise) {\n this.getInfo().validationPromise = new Promise((resolve, reject) => {\n this.getInfo().validationResolve = resolve;\n this.getInfo().validationReject = reject;\n });\n }\n\n if (validateAsyncDebounceMs > 0) {\n await new Promise(r => setTimeout(r, validateAsyncDebounceMs));\n } // Only kick off validation if this validation is the latest attempt\n\n\n if (checkLatest()) {\n try {\n const rawError = await validateAsync(value, this);\n\n if (checkLatest()) {\n var _this$getInfo$validat, _this$getInfo;\n\n const error = normalizeError(rawError);\n this.setMeta(prev => ({ ...prev,\n isValidating: false,\n error\n }));\n (_this$getInfo$validat = (_this$getInfo = this.getInfo()).validationResolve) == null ? void 0 : _this$getInfo$validat.call(_this$getInfo, error);\n }\n } catch (error) {\n if (checkLatest()) {\n var _this$getInfo$validat2, _this$getInfo2;\n\n (_this$getInfo$validat2 = (_this$getInfo2 = this.getInfo()).validationReject) == null ? void 0 : _this$getInfo$validat2.call(_this$getInfo2, error);\n throw error;\n }\n } finally {\n if (checkLatest()) {\n this.setMeta(prev => ({ ...prev,\n isValidating: false\n }));\n delete this.getInfo().validationPromise;\n }\n }\n } // Always return the latest validation promise to the caller\n\n\n return this.getInfo().validationPromise;\n };\n\n this.shouldValidate = (isAsync, cause) => {\n const {\n validateOn,\n validateAsyncOn\n } = this.options;\n const level = getValidationCauseLevel(cause); // Must meet *at least* the validation level to validate,\n // e.g. if validateOn is 'change' and validateCause is 'blur',\n // the field will still validate\n\n return Object.keys(validateCauseLevels).some(d => isAsync ? validateAsyncOn : validateOn === d && level >= validateCauseLevels[d]);\n };\n\n this.validate = async (cause, value) => {\n // If the field is pristine and validatePristine is false, do not validate\n if (!this.options.validatePristine && !this.state.meta.isTouched) return; // Attempt to sync validate first\n\n if (this.shouldValidate(false, cause)) {\n this.validateSync(value);\n } // If there is an error, return it, do not attempt async validation\n\n\n if (this.state.meta.error) {\n return this.state.meta.error;\n } // No error? Attempt async validation\n\n\n if (this.shouldValidate(true, cause)) {\n return this.validateAsync(value);\n } // If there is no sync error or async validation attempt, there is no error\n\n\n return undefined;\n };\n\n this.getChangeProps = (props = {}) => {\n return { ...props,\n value: this.state.value,\n onChange: value => {\n this.setValue(value);\n props.onChange == null ? void 0 : props.onChange(value);\n },\n onBlur: e => {\n this.setMeta(prev => ({ ...prev,\n isTouched: true\n }));\n this.validate('blur');\n props.onBlur == null ? void 0 : props.onBlur(e);\n }\n };\n };\n\n this.getInputProps = (props = {}) => {\n return { ...props,\n value: String(this.state.value),\n onChange: e => {\n this.setValue(e.target.value);\n props.onChange == null ? void 0 : props.onChange(e.target.value);\n },\n onBlur: this.getChangeProps(props).onBlur\n };\n };\n\n this.form = _opts.form;\n this.uid = uid++; // Support field prefixing from FieldScope\n\n let fieldPrefix = '';\n\n if (this.form.fieldName) {\n fieldPrefix = this.form.fieldName + \".\";\n }\n\n this.name = fieldPrefix + _opts.name;\n this.store = new Store({\n value: this.getValue(),\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n meta: (_this$getMeta = this.getMeta()) != null ? _this$getMeta : {\n isValidating: false,\n isTouched: false,\n ...this.options.defaultMeta\n }\n }, {\n onUpdate: next => {\n next.meta.touchedError = next.meta.isTouched ? next.meta.error : undefined; // Do not validate pristine fields\n\n const prevState = this.state;\n this.state = next;\n\n if (next.value !== prevState.value) {\n this.validate('change', next.value);\n }\n }\n });\n this.state = this.store.state;\n this.update(_opts);\n }\n\n}\nconst validateCauseLevels = {\n change: 0,\n blur: 1,\n submit: 2\n};\n\nfunction getValidationCauseLevel(cause) {\n return !cause ? 3 : validateCauseLevels[cause];\n}\n\nfunction normalizeError(rawError) {\n if (rawError) {\n if (typeof rawError !== 'string') {\n return 'Invalid Form Values';\n }\n\n return rawError;\n }\n\n return undefined;\n}\n\nexport { FieldApi, FormApi, functionalUpdate, getBy, setBy };\n//# sourceMappingURL=index.js.map\n","/**\n * react-store\n *\n * Copyright (c) TanStack\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE.md file in the root directory of this source tree.\n *\n * @license MIT\n */\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';\nexport * from '@tanstack/store';\n\nfunction useStore(store, selector = d => d) {\n const slice = useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow);\n return slice;\n}\nfunction shallow(objA, objB) {\n if (Object.is(objA, objB)) {\n return true;\n }\n if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {\n return false;\n }\n const keysA = Object.keys(objA);\n if (keysA.length !== Object.keys(objB).length) {\n return false;\n }\n for (let i = 0; i < keysA.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {\n return false;\n }\n }\n return true;\n}\n\nexport { shallow, useStore };\n//# sourceMappingURL=index.js.map\n","import type { FormApi } from '@tanstack/form-core'\nimport * as React from 'react'\n\nexport const formContext = React.createContext<FormApi<any> | null>(null)\n\nexport function useFormContext() {\n const formApi = React.useContext(formContext)\n\n if (!formApi) {\n throw new Error(`You are trying to use the form API outside of a form!`)\n }\n\n return formApi\n}\n","import * as React from 'react'\n//\nimport { useStore } from '@tanstack/react-store'\nimport type { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core'\nimport { FieldApi } from '@tanstack/form-core'\nimport { useFormContext } from './formContext'\nimport type { FormFactory } from './createFormFactory'\n\ndeclare module '@tanstack/form-core' {\n // eslint-disable-next-line no-shadow\n interface FieldOptions<TData, TFormData> {\n formFactory?: FormFactory<TFormData>\n }\n}\n\nexport type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(\n opts?: { name: TField } & FieldOptions<\n DeepValue<TFormData, TField>,\n TFormData\n >,\n) => FieldApi<DeepValue<TFormData, TField>, TFormData>\n\nexport function createUseField<TFormData>(): UseField<TFormData> {\n return (opts) => {\n return useField(opts as any)\n }\n}\n\nexport function useField<TData, TFormData>(\n opts: FieldOptions<TData, TFormData> & {\n // selector: (state: FieldApi<TData, TFormData>) => TSelected\n },\n): FieldApi<TData, TFormData> {\n // Get the form API either manually or from context\n const formApi = useFormContext()\n\n const [fieldApi] = React.useState<FieldApi<TData, TFormData>>(\n () => new FieldApi({ ...opts, form: formApi }),\n )\n\n // Keep options up to date as they are rendered\n fieldApi.update({ ...opts, form: formApi })\n\n useStore(fieldApi.store)\n\n // Instantiates field meta and removes it when unrendered\n React.useEffect(() => fieldApi.mount(), [fieldApi])\n\n return fieldApi\n}\n","import * as React from 'react'\nimport {\n functionalUpdate,\n type DeepKeys,\n type DeepValue,\n type FieldApi,\n type FieldOptions,\n} from '@tanstack/form-core'\nimport { useField } from './useField'\n\n//\n\nexport type FieldComponent<TFormData> = <TField extends DeepKeys<TFormData>>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<DeepValue<TFormData, TField>, TFormData>) => any\n name: TField\n} & Omit<FieldOptions<DeepValue<TFormData, TField>, TFormData>, 'name'>) => any\n\nexport function createFieldComponent<TFormData>() {\n const ConnectedField: FieldComponent<TFormData> = (props) => (\n <Field {...(props as any)} />\n )\n return ConnectedField\n}\n\nexport function Field<TData, TFormData>({\n children,\n ...fieldOptions\n}: {\n children: (fieldApi: FieldApi<TData, TFormData>) => any\n} & FieldOptions<TData, TFormData>) {\n const fieldApi = useField(fieldOptions as any)\n return functionalUpdate(children, fieldApi as any)\n}\n","import type { FormState, FormOptions } from '@tanstack/form-core'\nimport { FormApi, functionalUpdate } from '@tanstack/form-core'\nimport type { NoInfer } from '@tanstack/react-store'\nimport { useStore } from '@tanstack/react-store'\nimport React from 'react'\nimport { createFieldComponent, type FieldComponent } from './Field'\nimport { createUseField, type UseField } from './useField'\nimport { formContext } from './formContext'\n\ndeclare module '@tanstack/form-core' {\n interface Register {\n FormSubmitEvent: React.FormEvent<HTMLFormElement>\n }\n\n // eslint-disable-next-line no-shadow\n interface FormApi<TFormData> {\n Form: FormComponent\n Field: FieldComponent<TFormData>\n useField: UseField<TFormData>\n useStore: <TSelected = NoInfer<FormState<TFormData>>>(\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected,\n ) => TSelected\n Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {\n selector?: (state: NoInfer<FormState<TFormData>>) => TSelected\n children:\n | ((state: NoInfer<TSelected>) => React.ReactNode)\n | React.ReactNode\n }) => any\n }\n}\n\nexport function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {\n const [formApi] = React.useState(() => {\n // @ts-ignore\n const api = new FormApi<TData>(opts)\n\n api.Form = createFormComponent(api)\n api.Field = createFieldComponent<TData>()\n api.useField = createUseField<TData>()\n api.useStore = (\n // @ts-ignore\n selector,\n ) => {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useStore(api.store, selector as any) as any\n }\n api.Subscribe = (\n // @ts-ignore\n props,\n ) => {\n return functionalUpdate(\n props.children,\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useStore(api.store, props.selector as any),\n ) as any\n }\n\n return api\n })\n\n return formApi as any\n}\n\nexport type FormProps = React.HTMLProps<HTMLFormElement> & {\n children: React.ReactNode\n noFormElement?: boolean\n}\n\nexport type FormComponent = (props: FormProps) => any\n\nfunction createFormComponent(formApi: FormApi<any>) {\n const Form: FormComponent = ({ children, noFormElement, ...rest }) => {\n const isSubmitting = formApi.useStore((state) => state.isSubmitting)\n\n return (\n <formContext.Provider value={formApi}>\n {noFormElement ? (\n children\n ) : (\n <form\n onSubmit={formApi.handleSubmit}\n disabled={isSubmitting}\n {...rest}\n >\n {children}\n </form>\n )}\n </formContext.Provider>\n )\n }\n\n return Form\n}\n","import type { FormApi, FormOptions } from '@tanstack/form-core'\nimport { createUseField, type UseField } from './useField'\nimport { useForm } from './useForm'\nimport { createFieldComponent, type FieldComponent } from './Field'\n\nexport type FormFactory<TFormData> = {\n useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>\n useField: UseField<TFormData>\n Field: FieldComponent<TFormData>\n}\n\nexport function createFormFactory<TFormData>(\n defaultOpts?: FormOptions<TFormData>,\n): FormFactory<TFormData> {\n return {\n useForm: (opts) => {\n return useForm<TFormData>({ ...defaultOpts, ...opts } as any) as any\n },\n useField: createUseField<TFormData>(),\n Field: createFieldComponent<TFormData>(),\n }\n}\n"],"names":["Store","listeners","Set","batching","queue","constructor","initialState","options","this","state","subscribe","listener","add","unsub","onSubscribe","delete","setState","updater","previous","updateFn","onUpdate","push","forEach","flush","cb","batch","functionalUpdate","input","setBy","obj","_path","path","makePathArray","doSet","parent","length","key","shift","Array","isArray","prefix","slice","Error","reFindNumbers0","reFindNumbers1","reFindNumbers2","reFindNumbers3","reFindMultiplePeriods","str","replace","split","map","d","indexOf","parseInt","substring","getDefaultFormState","defaultState","values","fieldMeta","canSubmit","isFieldsValid","isFieldsValidating","isFormValid","isFormValidating","isSubmitted","isSubmitting","isTouched","isValid","isValidating","submissionAttempts","formValidationCount","FormApi","_opts","_opts$defaultValues","_opts$defaultState","fieldInfo","validationMeta","update","store","prev","defaultValues","reset","validateAllFields","async","fieldValidationPromises","Object","field","instances","instance","meta","setMeta","validate","Promise","all","validateForm","checkLatest","validationPromise","resolve","reject","validationResolve","validationReject","error","_this$validationMeta$","_this$validationMeta","call","err","_this$validationMeta$2","_this$validationMeta2","doValidation","handleSubmit","e","preventDefault","stopPropagation","old","done","_this$options$onInval","_this$options","_this$options$onInval2","_this$options2","onInvalidSubmit","_this$options$onSubmi","_this$options3","onSubmit","getFieldValue","reduce","current","pathPart","getBy","getFieldMeta","getFieldInfo","_this$fieldInfo","setFieldMeta","setFieldValue","opts","_opts$touch","touch","pushFieldValue","value","insertFieldValue","index","i","spliceFieldValue","filter","_d","swapFieldValues","index1","index2","prev1","prev2","next","fieldMetaValues","some","formError","id","_classPrivateFieldLooseKey","name","_classPrivateFieldLooseBase","receiver","privateKey","prototype","hasOwnProperty","TypeError","uid","_updateStore","_leaseValidateAsync","FieldApi","_this$getMeta","mount","info","getInfo","unsubscribe","form","keys","defineProperty","writable","nextValue","getValue","nextMeta","getMeta","_this$form$options$de","_this$form$options$de2","_this$form$options$de3","_this$form$options$de4","validatePristine","defaultValidatePristine","validateOn","defaultValidateOn","validateAsyncOn","defaultValidateAsyncOn","validateAsyncDebounceMs","defaultValidateAsyncDebounceMs","undefined","defaultValue","setValue","pushValue","insertValue","removeValue","swapValues","aIndex","bIndex","getSubField","validateSync","validationCount","normalizeError","cancelValidateAsync","count","validationAsyncCount","validateAsync","r","setTimeout","rawError","_this$getInfo$validat","_this$getInfo","_this$getInfo$validat2","_this$getInfo2","shouldValidate","isAsync","cause","level","validateCauseLevels","getValidationCauseLevel","getChangeProps","props","onChange","onBlur","getInputProps","String","target","fieldPrefix","fieldName","defaultMeta","touchedError","prevState","change","blur","submit","useStore","selector","useSyncExternalStoreWithSelector","shallow","objA","objB","is","keysA","formContext","React","createContext","createUseField","useField","formApi","useContext","useFormContext","fieldApi","useState","useEffect","createFieldComponent","Field","children","fieldOptions","useForm","api","Form","noFormElement","rest","createElement","Provider","_extends","disabled","createFormComponent","Subscribe","defaultOpts"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,MAAMA,EACJC,UAAY,IAAIC,IAChBC,UAAW,EACXC,MAAQ,GACRC,YAAYC,EAAcC,GACxBC,KAAKC,MAAQH,EACbE,KAAKD,QAAUA,EAEjBG,UAAYC,IACVH,KAAKP,UAAUW,IAAID,GACnB,MAAME,EAAQL,KAAKD,SAASO,cAAcH,EAAUH,MACpD,MAAO,KACLA,KAAKP,UAAUc,OAAOJ,GACtBE,QAGJG,SAAWC,IACT,MAAMC,EAAWV,KAAKC,MACtBD,KAAKC,MAAQD,KAAKD,SAASY,SAAWX,KAAKD,QAAQY,SAASD,EAAtBV,CAAgCS,GAAWA,EAAQC,GACrFV,KAAKC,QAAUS,IACnBV,KAAKD,SAASa,WAAWZ,KAAKC,MAAOS,GACrCV,KAAKJ,MAAMiB,MAAK,KACdb,KAAKP,UAAUqB,SAAQX,GAAYA,EAASH,KAAKC,MAAOS,QAE1DV,MAAKe,MAEPA,GAAS,KACHf,KAAKL,WACTK,KAAKJ,MAAMkB,SAAQE,GAAMA,MACzBhB,KAAKJ,MAAQ,KAEfqB,MAAQD,IACNhB,KAAKL,UAAW,EAChBqB,IACAhB,KAAKL,UAAW,EAChBK,MAAKe;;;;;;;;;;KCjCT,SAASG,EAAiBT,EAASU,GACjC,MAA0B,mBAAZV,EAAyBA,EAAQU,GAASV,EAiB1D,SAASW,EAAMC,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AACW,EAAWlC,GAKT,SAASkC,GAAwBC,SACtCA,KACGC,IAKH,OAAOzO,EAAiBwO,EADPT,EAASU,ICFrB,SAASC,EAAe9H,GAC7B,MAAOoH,GAAWJ,EAAK,QAACQ,UAAS,KAE/B,MAAMO,EAAM,IAAI7L,EAAe8D,GAuB/B,OArBA+H,EAAIC,KAkCR,SAA6BZ,GAqB3B,MApB4B,EAAGQ,WAAUK,mBAAkBC,MACzD,MAAMtM,EAAewL,EAAQb,UAAUpO,GAAUA,EAAMyD,eAEvD,OACEoL,UAAAmB,cAACpB,EAAYqB,SAAb,CAAsBhI,MAAOgH,GAC1Ba,EACCL,EAEAZ,EAAAA,QAAAmB,cAAA,OAAAE,EAAA,CACEhJ,SAAU+H,EAAQ5I,aAClB8J,SAAU1M,GACNsM,GAEHN,KAhDEW,CAAoBR,GAC/BA,EAAIJ,MAAQD,IACZK,EAAIZ,SAAWD,IACfa,EAAIxB,SAEFC,GAGOD,EAASwB,EAAItL,MAAO+J,GAE7BuB,EAAIS,UAEF/C,GAEOrM,EACLqM,EAAMmC,SAENrB,EAASwB,EAAItL,MAAOgJ,EAAMe,WAIvBuB,KAGT,OAAOX,yDCjDF,SACLqB,GAEA,MAAO,CACLX,QAAU9H,GACD8H,EAAmB,IAAKW,KAAgBzI,IAEjDmH,SAAUD,IACVS,MAAOD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-form",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "Powerful, type-safe forms for React.",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@tanstack/react-store": "0.0.1-beta.84",
32
- "@tanstack/form-core": "0.0.5"
32
+ "@tanstack/form-core": "0.0.6"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^17.0.0 || ^18.0.0",
package/src/Field.tsx CHANGED
@@ -5,7 +5,6 @@ import {
5
5
  type DeepValue,
6
6
  type FieldApi,
7
7
  type FieldOptions,
8
- type FormApi,
9
8
  } from '@tanstack/form-core'
10
9
  import { useField } from './useField'
11
10
 
@@ -19,9 +18,9 @@ export type FieldComponent<TFormData> = <TField extends DeepKeys<TFormData>>({
19
18
  name: TField
20
19
  } & Omit<FieldOptions<DeepValue<TFormData, TField>, TFormData>, 'name'>) => any
21
20
 
22
- export function createFieldComponent<TFormData>(formApi: FormApi<TFormData>) {
21
+ export function createFieldComponent<TFormData>() {
23
22
  const ConnectedField: FieldComponent<TFormData> = (props) => (
24
- <Field {...(props as any)} form={formApi} />
23
+ <Field {...(props as any)} />
25
24
  )
26
25
  return ConnectedField
27
26
  }
@@ -0,0 +1,22 @@
1
+ import type { FormApi, FormOptions } from '@tanstack/form-core'
2
+ import { createUseField, type UseField } from './useField'
3
+ import { useForm } from './useForm'
4
+ import { createFieldComponent, type FieldComponent } from './Field'
5
+
6
+ export type FormFactory<TFormData> = {
7
+ useForm: (opts?: FormOptions<TFormData>) => FormApi<TFormData>
8
+ useField: UseField<TFormData>
9
+ Field: FieldComponent<TFormData>
10
+ }
11
+
12
+ export function createFormFactory<TFormData>(
13
+ defaultOpts?: FormOptions<TFormData>,
14
+ ): FormFactory<TFormData> {
15
+ return {
16
+ useForm: (opts) => {
17
+ return useForm<TFormData>({ ...defaultOpts, ...opts } as any) as any
18
+ },
19
+ useField: createUseField<TFormData>(),
20
+ Field: createFieldComponent<TFormData>(),
21
+ }
22
+ }
@@ -3,13 +3,9 @@ import * as React from 'react'
3
3
 
4
4
  export const formContext = React.createContext<FormApi<any> | null>(null)
5
5
 
6
- export function useFormContext(customFormApi?: FormApi<any>) {
6
+ export function useFormContext() {
7
7
  const formApi = React.useContext(formContext)
8
8
 
9
- if (customFormApi) {
10
- return customFormApi
11
- }
12
-
13
9
  if (!formApi) {
14
10
  throw new Error(`You are trying to use the form API outside of a form!`)
15
11
  }
package/src/index.ts CHANGED
@@ -1,4 +1,35 @@
1
- export * from '@tanstack/form-core'
2
- export * from './useForm'
3
- export * from './Field'
4
- export * from './useField'
1
+ export type {
2
+ ChangeProps,
3
+ DeepKeys,
4
+ DeepValue,
5
+ FieldApiOptions,
6
+ FieldInfo,
7
+ FieldMeta,
8
+ FieldOptions,
9
+ FieldState,
10
+ FormOptions,
11
+ FormState,
12
+ InputProps,
13
+ RequiredByKey,
14
+ Updater,
15
+ UpdaterFn,
16
+ UserChangeProps,
17
+ UserInputProps,
18
+ ValidationCause,
19
+ ValidationError,
20
+ ValidationMeta,
21
+ } from '@tanstack/form-core'
22
+
23
+ export { FormApi, FieldApi, functionalUpdate } from '@tanstack/form-core'
24
+
25
+ export type { FormComponent, FormProps } from './useForm'
26
+ export { useForm } from './useForm'
27
+
28
+ export type { FieldComponent } from './Field'
29
+ export { Field } from './Field'
30
+
31
+ export type { UseField } from './useField'
32
+ export { useField } from './useField'
33
+
34
+ export type { FormFactory } from './createFormFactory'
35
+ export { createFormFactory } from './createFormFactory'
package/src/useField.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  import * as React from 'react'
2
2
  //
3
3
  import { useStore } from '@tanstack/react-store'
4
- import type {
5
- DeepKeys,
6
- DeepValue,
7
- FieldOptions,
8
- FormApi,
9
- } from '@tanstack/form-core'
4
+ import type { DeepKeys, DeepValue, FieldOptions } from '@tanstack/form-core'
10
5
  import { FieldApi } from '@tanstack/form-core'
11
6
  import { useFormContext } from './formContext'
7
+ import type { FormFactory } from './createFormFactory'
8
+
9
+ declare module '@tanstack/form-core' {
10
+ // eslint-disable-next-line no-shadow
11
+ interface FieldOptions<TData, TFormData> {
12
+ formFactory?: FormFactory<TFormData>
13
+ }
14
+ }
12
15
 
13
16
  export type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(
14
17
  opts?: { name: TField } & FieldOptions<
@@ -17,12 +20,10 @@ export type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(
17
20
  >,
18
21
  ) => FieldApi<DeepValue<TFormData, TField>, TFormData>
19
22
 
20
- export function createUseField<TFormData>(formApi: FormApi<TFormData>) {
21
- const useFormField: UseField<TFormData> = (opts) => {
22
- return useField({ ...opts, form: formApi } as any)
23
+ export function createUseField<TFormData>(): UseField<TFormData> {
24
+ return (opts) => {
25
+ return useField(opts as any)
23
26
  }
24
-
25
- return useFormField
26
27
  }
27
28
 
28
29
  export function useField<TData, TFormData>(
@@ -30,13 +31,8 @@ export function useField<TData, TFormData>(
30
31
  // selector: (state: FieldApi<TData, TFormData>) => TSelected
31
32
  },
32
33
  ): FieldApi<TData, TFormData> {
33
- // invariant( // TODO:
34
- // opts.name,
35
- // `useField: A field is required to use this hook. eg, useField('myField', options)`
36
- // )
37
-
38
34
  // Get the form API either manually or from context
39
- const formApi = useFormContext(opts.form)
35
+ const formApi = useFormContext()
40
36
 
41
37
  const [fieldApi] = React.useState<FieldApi<TData, TFormData>>(
42
38
  () => new FieldApi({ ...opts, form: formApi }),
package/src/useForm.tsx CHANGED
@@ -8,6 +8,10 @@ import { createUseField, type UseField } from './useField'
8
8
  import { formContext } from './formContext'
9
9
 
10
10
  declare module '@tanstack/form-core' {
11
+ interface Register {
12
+ FormSubmitEvent: React.FormEvent<HTMLFormElement>
13
+ }
14
+
11
15
  // eslint-disable-next-line no-shadow
12
16
  interface FormApi<TFormData> {
13
17
  Form: FormComponent
@@ -24,22 +28,21 @@ declare module '@tanstack/form-core' {
24
28
  }) => any
25
29
  }
26
30
  }
27
- //
28
31
 
29
32
  export function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {
30
33
  const [formApi] = React.useState(() => {
31
34
  // @ts-ignore
32
- const api = new FormApi<TData>(opts || {})
35
+ const api = new FormApi<TData>(opts)
33
36
 
34
37
  api.Form = createFormComponent(api)
35
- api.Field = createFieldComponent(api)
36
- api.useField = createUseField(api)
38
+ api.Field = createFieldComponent<TData>()
39
+ api.useField = createUseField<TData>()
37
40
  api.useStore = (
38
41
  // @ts-ignore
39
42
  selector,
40
43
  ) => {
41
44
  // eslint-disable-next-line react-hooks/rules-of-hooks
42
- return useStore(api.store, selector) as any
45
+ return useStore(api.store, selector as any) as any
43
46
  }
44
47
  api.Subscribe = (
45
48
  // @ts-ignore
@@ -48,16 +51,14 @@ export function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData> {
48
51
  return functionalUpdate(
49
52
  props.children,
50
53
  // eslint-disable-next-line react-hooks/rules-of-hooks
51
- useStore(api.store, props.selector),
54
+ useStore(api.store, props.selector as any),
52
55
  ) as any
53
56
  }
54
57
 
55
58
  return api
56
59
  })
57
60
 
58
- // React.useEffect(() => formApi.mount(), [])
59
-
60
- return formApi
61
+ return formApi as any
61
62
  }
62
63
 
63
64
  export type FormProps = React.HTMLProps<HTMLFormElement> & {
@@ -67,7 +68,7 @@ export type FormProps = React.HTMLProps<HTMLFormElement> & {
67
68
 
68
69
  export type FormComponent = (props: FormProps) => any
69
70
 
70
- export function createFormComponent(formApi: FormApi<any>) {
71
+ function createFormComponent(formApi: FormApi<any>) {
71
72
  const Form: FormComponent = ({ children, noFormElement, ...rest }) => {
72
73
  const isSubmitting = formApi.useStore((state) => state.isSubmitting)
73
74
 
@@ -81,26 +82,6 @@ export function createFormComponent(formApi: FormApi<any>) {
81
82
  disabled={isSubmitting}
82
83
  {...rest}
83
84
  >
84
- {formApi.options.debugForm ? (
85
- <div
86
- style={{
87
- margin: '2rem 0',
88
- }}
89
- >
90
- <div
91
- style={{
92
- fontWeight: 'bolder',
93
- }}
94
- >
95
- Form State
96
- </div>
97
- <pre>
98
- <code>
99
- {JSON.stringify(formApi, safeStringifyReplace(), 2)}
100
- </code>
101
- </pre>
102
- </div>
103
- ) : null}
104
85
  {children}
105
86
  </form>
106
87
  )}
@@ -110,16 +91,3 @@ export function createFormComponent(formApi: FormApi<any>) {
110
91
 
111
92
  return Form
112
93
  }
113
-
114
- function safeStringifyReplace() {
115
- const set = new Set()
116
- return (_key: string, value: any) => {
117
- if (typeof value === 'object' || Array.isArray(value)) {
118
- if (set.has(value)) {
119
- return '(circular value)'
120
- }
121
- set.add(value)
122
- }
123
- return typeof value === 'function' ? undefined : value
124
- }
125
- }