@tanstack/form-core
Advanced tools
+48
-41
@@ -40,3 +40,40 @@ "use strict"; | ||
| const cleanupStoreDerived = this.store.mount(); | ||
| const cleanupDevtoolBroadcast = this.store.subscribe(() => { | ||
| utils.throttleFormState(this); | ||
| }); | ||
| const cleanupFormStateListener = EventClient.formEventClient.on( | ||
| "request-form-state", | ||
| (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| EventClient.formEventClient.emit("form-api", { | ||
| id: this._formId, | ||
| state: this.store.state, | ||
| options: this.options | ||
| }); | ||
| } | ||
| } | ||
| ); | ||
| const cleanupFormResetListener = EventClient.formEventClient.on( | ||
| "request-form-reset", | ||
| (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this.reset(); | ||
| } | ||
| } | ||
| ); | ||
| const cleanupFormForceSubmitListener = EventClient.formEventClient.on( | ||
| "request-form-force-submit", | ||
| (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this._devtoolsSubmissionOverride = true; | ||
| this.handleSubmit(); | ||
| this._devtoolsSubmissionOverride = false; | ||
| } | ||
| } | ||
| ); | ||
| const cleanup = () => { | ||
| cleanupFormForceSubmitListener(); | ||
| cleanupFormResetListener(); | ||
| cleanupFormStateListener(); | ||
| cleanupDevtoolBroadcast(); | ||
| cleanupFieldMetaDerived(); | ||
@@ -180,10 +217,11 @@ cleanupStoreDerived(); | ||
| const errorMapKey = getErrorMapKey(validateObj.cause); | ||
| for (const field of Object.keys( | ||
| this.state.fieldMeta | ||
| )) { | ||
| if (this.baseStore.state.fieldMetaBase[field] === void 0) { | ||
| const allFieldsToProcess = /* @__PURE__ */ new Set([ | ||
| ...Object.keys(this.state.fieldMeta), | ||
| ...Object.keys(fieldErrors || {}) | ||
| ]); | ||
| for (const field of allFieldsToProcess) { | ||
| if (this.baseStore.state.fieldMetaBase[field] === void 0 && !fieldErrors?.[field]) { | ||
| continue; | ||
| } | ||
| const fieldMeta = this.getFieldMeta(field); | ||
| if (!fieldMeta) continue; | ||
| const fieldMeta = this.getFieldMeta(field) ?? metaHelper.defaultFieldMeta; | ||
| const { | ||
@@ -196,8 +234,4 @@ errorMap: currentErrorMap, | ||
| newFormValidatorError, | ||
| isPreviousErrorFromFormValidator: ( | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| currentErrorMapSource?.[errorMapKey] === "form" | ||
| ), | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| previousErrorValue: currentErrorMap?.[errorMapKey] | ||
| isPreviousErrorFromFormValidator: currentErrorMapSource[errorMapKey] === "form", | ||
| previousErrorValue: currentErrorMap[errorMapKey] | ||
| }); | ||
@@ -210,7 +244,4 @@ if (newSource === "form") { | ||
| } | ||
| if ( | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| currentErrorMap?.[errorMapKey] !== newErrorValue | ||
| ) { | ||
| this.setFieldMeta(field, (prev) => ({ | ||
| if (currentErrorMap[errorMapKey] !== newErrorValue) { | ||
| this.setFieldMeta(field, (prev = metaHelper.defaultFieldMeta) => ({ | ||
| ...prev, | ||
@@ -976,26 +1007,2 @@ errorMap: { | ||
| this.update(opts || {}); | ||
| this.store.subscribe(() => { | ||
| utils.throttleFormState(this); | ||
| }); | ||
| EventClient.formEventClient.on("request-form-state", (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| EventClient.formEventClient.emit("form-api", { | ||
| id: this._formId, | ||
| state: this.store.state, | ||
| options: this.options | ||
| }); | ||
| } | ||
| }); | ||
| EventClient.formEventClient.on("request-form-reset", (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this.reset(); | ||
| } | ||
| }); | ||
| EventClient.formEventClient.on("request-form-force-submit", (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this._devtoolsSubmissionOverride = true; | ||
| this.handleSubmit(); | ||
| this._devtoolsSubmissionOverride = false; | ||
| } | ||
| }); | ||
| } | ||
@@ -1002,0 +1009,0 @@ get state() { |
+49
-42
| import { batch, Store, Derived } from "@tanstack/store"; | ||
| import { evaluate, getSyncValidatorArray, determineFormLevelErrorSourceAndValue, getAsyncValidatorArray, getBy, functionalUpdate, setBy, deleteBy, mergeOpts, isGlobalFormValidationError, uuid, isNonEmptyArray, throttleFormState } from "./utils.js"; | ||
| import { throttleFormState, evaluate, getSyncValidatorArray, determineFormLevelErrorSourceAndValue, getAsyncValidatorArray, getBy, functionalUpdate, setBy, deleteBy, mergeOpts, isGlobalFormValidationError, uuid, isNonEmptyArray } from "./utils.js"; | ||
| import { defaultValidationLogic } from "./ValidationLogic.js"; | ||
@@ -38,3 +38,40 @@ import { standardSchemaValidators, isStandardSchemaValidator } from "./standardSchemaValidator.js"; | ||
| const cleanupStoreDerived = this.store.mount(); | ||
| const cleanupDevtoolBroadcast = this.store.subscribe(() => { | ||
| throttleFormState(this); | ||
| }); | ||
| const cleanupFormStateListener = formEventClient.on( | ||
| "request-form-state", | ||
| (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| formEventClient.emit("form-api", { | ||
| id: this._formId, | ||
| state: this.store.state, | ||
| options: this.options | ||
| }); | ||
| } | ||
| } | ||
| ); | ||
| const cleanupFormResetListener = formEventClient.on( | ||
| "request-form-reset", | ||
| (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this.reset(); | ||
| } | ||
| } | ||
| ); | ||
| const cleanupFormForceSubmitListener = formEventClient.on( | ||
| "request-form-force-submit", | ||
| (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this._devtoolsSubmissionOverride = true; | ||
| this.handleSubmit(); | ||
| this._devtoolsSubmissionOverride = false; | ||
| } | ||
| } | ||
| ); | ||
| const cleanup = () => { | ||
| cleanupFormForceSubmitListener(); | ||
| cleanupFormResetListener(); | ||
| cleanupFormStateListener(); | ||
| cleanupDevtoolBroadcast(); | ||
| cleanupFieldMetaDerived(); | ||
@@ -178,10 +215,11 @@ cleanupStoreDerived(); | ||
| const errorMapKey = getErrorMapKey(validateObj.cause); | ||
| for (const field of Object.keys( | ||
| this.state.fieldMeta | ||
| )) { | ||
| if (this.baseStore.state.fieldMetaBase[field] === void 0) { | ||
| const allFieldsToProcess = /* @__PURE__ */ new Set([ | ||
| ...Object.keys(this.state.fieldMeta), | ||
| ...Object.keys(fieldErrors || {}) | ||
| ]); | ||
| for (const field of allFieldsToProcess) { | ||
| if (this.baseStore.state.fieldMetaBase[field] === void 0 && !fieldErrors?.[field]) { | ||
| continue; | ||
| } | ||
| const fieldMeta = this.getFieldMeta(field); | ||
| if (!fieldMeta) continue; | ||
| const fieldMeta = this.getFieldMeta(field) ?? defaultFieldMeta; | ||
| const { | ||
@@ -194,8 +232,4 @@ errorMap: currentErrorMap, | ||
| newFormValidatorError, | ||
| isPreviousErrorFromFormValidator: ( | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| currentErrorMapSource?.[errorMapKey] === "form" | ||
| ), | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| previousErrorValue: currentErrorMap?.[errorMapKey] | ||
| isPreviousErrorFromFormValidator: currentErrorMapSource[errorMapKey] === "form", | ||
| previousErrorValue: currentErrorMap[errorMapKey] | ||
| }); | ||
@@ -208,7 +242,4 @@ if (newSource === "form") { | ||
| } | ||
| if ( | ||
| // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
| currentErrorMap?.[errorMapKey] !== newErrorValue | ||
| ) { | ||
| this.setFieldMeta(field, (prev) => ({ | ||
| if (currentErrorMap[errorMapKey] !== newErrorValue) { | ||
| this.setFieldMeta(field, (prev = defaultFieldMeta) => ({ | ||
| ...prev, | ||
@@ -974,26 +1005,2 @@ errorMap: { | ||
| this.update(opts || {}); | ||
| this.store.subscribe(() => { | ||
| throttleFormState(this); | ||
| }); | ||
| formEventClient.on("request-form-state", (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| formEventClient.emit("form-api", { | ||
| id: this._formId, | ||
| state: this.store.state, | ||
| options: this.options | ||
| }); | ||
| } | ||
| }); | ||
| formEventClient.on("request-form-reset", (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this.reset(); | ||
| } | ||
| }); | ||
| formEventClient.on("request-form-force-submit", (e) => { | ||
| if (e.payload.id === this._formId) { | ||
| this._devtoolsSubmissionOverride = true; | ||
| this.handleSubmit(); | ||
| this._devtoolsSubmissionOverride = false; | ||
| } | ||
| }); | ||
| } | ||
@@ -1000,0 +1007,0 @@ get state() { |
+2
-2
| { | ||
| "name": "@tanstack/form-core", | ||
| "version": "1.27.4", | ||
| "version": "1.27.5", | ||
| "description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -40,3 +40,3 @@ "author": "tannerlinsley", | ||
| "dependencies": { | ||
| "@tanstack/devtools-event-client": "^0.3.5", | ||
| "@tanstack/devtools-event-client": "^0.4.0", | ||
| "@tanstack/pacer-lite": "^0.1.1", | ||
@@ -43,0 +43,0 @@ "@tanstack/store": "^0.7.7" |
+1
-0
@@ -1260,2 +1260,3 @@ import { Derived, batch } from '@tanstack/store' | ||
| this.update(this.options as never) | ||
| const { onMount } = this.options.validators || {} | ||
@@ -1262,0 +1263,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1080196
0.17%13563
0.19%+ Added
- Removed