@tanstack/form-core
Advanced tools
Comparing version 0.0.14 to 0.0.15
@@ -96,2 +96,3 @@ import type { DeepKeys, DeepValue, Updater } from './utils'; | ||
}) => void; | ||
_getMeta: () => FieldMeta | undefined; | ||
getMeta: () => FieldMeta; | ||
@@ -98,0 +99,0 @@ setMeta: (updater: Updater<FieldMeta>) => void; |
@@ -16,3 +16,3 @@ import { defineProperty as _defineProperty, classPrivateFieldInitSpec as _classPrivateFieldInitSpec, classPrivateFieldGet as _classPrivateFieldGet } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
constructor(_opts) { | ||
var _this$getMeta; | ||
var _this$_getMeta2; | ||
_defineProperty(this, "uid", void 0); | ||
@@ -85,4 +85,3 @@ _defineProperty(this, "form", void 0); | ||
// Default Meta | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (this.getMeta() === undefined) { | ||
if (this._getMeta() === undefined) { | ||
this.setMeta(this.state.meta); | ||
@@ -98,3 +97,11 @@ } | ||
}); | ||
_defineProperty(this, "getMeta", () => this.form.getFieldMeta(this.name)); | ||
_defineProperty(this, "_getMeta", () => this.form.getFieldMeta(this.name)); | ||
_defineProperty(this, "getMeta", () => { | ||
var _this$_getMeta; | ||
return (_this$_getMeta = this._getMeta()) != null ? _this$_getMeta : { | ||
isValidating: false, | ||
isTouched: false, | ||
...this.options.defaultMeta | ||
}; | ||
}); | ||
_defineProperty(this, "setMeta", updater => this.form.setFieldMeta(this.name, updater)); | ||
@@ -279,3 +286,3 @@ _defineProperty(this, "getInfo", () => this.form.getFieldInfo(this.name)); | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
meta: (_this$getMeta = this.getMeta()) != null ? _this$getMeta : { | ||
meta: (_this$_getMeta2 = this._getMeta()) != null ? _this$_getMeta2 : { | ||
isValidating: false, | ||
@@ -282,0 +289,0 @@ isTouched: false, |
@@ -16,3 +16,3 @@ import { defineProperty as _defineProperty, classPrivateFieldInitSpec as _classPrivateFieldInitSpec, classPrivateFieldGet as _classPrivateFieldGet } from './_virtual/_rollupPluginBabelHelpers.legacy.js'; | ||
constructor(_opts) { | ||
var _this$getMeta; | ||
var _this$_getMeta2; | ||
_defineProperty(this, "uid", void 0); | ||
@@ -85,4 +85,3 @@ _defineProperty(this, "form", void 0); | ||
// Default Meta | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (this.getMeta() === undefined) { | ||
if (this._getMeta() === undefined) { | ||
this.setMeta(this.state.meta); | ||
@@ -98,3 +97,11 @@ } | ||
}); | ||
_defineProperty(this, "getMeta", () => this.form.getFieldMeta(this.name)); | ||
_defineProperty(this, "_getMeta", () => this.form.getFieldMeta(this.name)); | ||
_defineProperty(this, "getMeta", () => { | ||
var _this$_getMeta; | ||
return (_this$_getMeta = this._getMeta()) != null ? _this$_getMeta : { | ||
isValidating: false, | ||
isTouched: false, | ||
...this.options.defaultMeta | ||
}; | ||
}); | ||
_defineProperty(this, "setMeta", updater => this.form.setFieldMeta(this.name, updater)); | ||
@@ -279,3 +286,3 @@ _defineProperty(this, "getInfo", () => this.form.getFieldInfo(this.name)); | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
meta: (_this$getMeta = this.getMeta()) != null ? _this$getMeta : { | ||
meta: (_this$_getMeta2 = this._getMeta()) != null ? _this$_getMeta2 : { | ||
isValidating: false, | ||
@@ -282,0 +289,0 @@ isTouched: false, |
@@ -66,3 +66,3 @@ import { Store } from '@tanstack/store'; | ||
getFieldValue: <TField extends DeepKeys<TFormData>>(field: TField) => DeepValue<TFormData, TField>; | ||
getFieldMeta: <TField extends DeepKeys<TFormData>>(field: TField) => FieldMeta; | ||
getFieldMeta: <TField extends DeepKeys<TFormData>>(field: TField) => FieldMeta | undefined; | ||
getFieldInfo: <TField extends DeepKeys<TFormData>>(field: TField) => Record<DeepKeys<TFormData>, FieldInfo<TFormData>>[TField]; | ||
@@ -69,0 +69,0 @@ setFieldMeta: <TField extends DeepKeys<TFormData>>(field: TField, updater: Updater<FieldMeta>) => void; |
@@ -41,7 +41,2 @@ import { defineProperty as _defineProperty } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
const shouldUpdateState = options.defaultState !== this.options.defaultState; | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (!shouldUpdateValues || !shouldUpdateValues) { | ||
return; | ||
} | ||
this.store.setState(() => getDefaultFormState(Object.assign({}, | ||
@@ -48,0 +43,0 @@ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition |
@@ -41,7 +41,2 @@ import { defineProperty as _defineProperty } from './_virtual/_rollupPluginBabelHelpers.legacy.js'; | ||
const shouldUpdateState = options.defaultState !== this.options.defaultState; | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (!shouldUpdateValues || !shouldUpdateValues) { | ||
return; | ||
} | ||
this.store.setState(() => getDefaultFormState(Object.assign({}, | ||
@@ -48,0 +43,0 @@ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition |
{ | ||
"name": "@tanstack/form-core", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "Powerful, type-safe, framework agnostic forms.", | ||
@@ -32,3 +32,3 @@ "author": "tannerlinsley", | ||
"dependencies": { | ||
"@tanstack/store": "0.0.1-beta.89" | ||
"@tanstack/store": "0.1.3" | ||
}, | ||
@@ -35,0 +35,0 @@ "scripts": { |
@@ -132,3 +132,3 @@ import type { DeepKeys, DeepValue, Updater } from './utils' | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
meta: this.getMeta() ?? { | ||
meta: this._getMeta() ?? { | ||
isValidating: false, | ||
@@ -215,4 +215,3 @@ isTouched: false, | ||
// Default Meta | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (this.getMeta() === undefined) { | ||
if (this._getMeta() === undefined) { | ||
this.setMeta(this.state.meta) | ||
@@ -234,3 +233,10 @@ } | ||
getMeta = (): FieldMeta => this.form.getFieldMeta(this.name) | ||
_getMeta = () => this.form.getFieldMeta(this.name) | ||
getMeta = () => | ||
this._getMeta() ?? | ||
({ | ||
isValidating: false, | ||
isTouched: false, | ||
...this.options.defaultMeta, | ||
} as FieldMeta) | ||
@@ -237,0 +243,0 @@ setMeta = (updater: Updater<FieldMeta>) => |
@@ -174,7 +174,2 @@ import { Store } from '@tanstack/store' | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (!shouldUpdateValues || !shouldUpdateValues) { | ||
return | ||
} | ||
this.store.setState(() => | ||
@@ -299,3 +294,3 @@ getDefaultFormState( | ||
field: TField, | ||
): FieldMeta => { | ||
): FieldMeta | undefined => { | ||
return this.state.fieldMeta[field] | ||
@@ -302,0 +297,0 @@ } |
@@ -179,2 +179,25 @@ import { expect } from 'vitest' | ||
}) | ||
it('should not throw errors when no meta info is stored on a field and a form re-renders', async () => { | ||
const form = new FormApi({ | ||
defaultValues: { | ||
name: 'test', | ||
}, | ||
}) | ||
const field = new FieldApi({ | ||
form, | ||
name: 'name', | ||
}) | ||
field.mount() | ||
expect(() => | ||
form.update({ | ||
defaultValues: { | ||
name: 'other', | ||
}, | ||
}), | ||
).not.toThrow() | ||
}) | ||
}) |
@@ -10,3 +10,3 @@ import { expect } from 'vitest' | ||
expect(form.state).toEqual({ | ||
values: undefined, | ||
values: {}, | ||
fieldMeta: {}, | ||
@@ -63,3 +63,3 @@ canSubmit: true, | ||
expect(form.state).toEqual({ | ||
values: undefined, | ||
values: {}, | ||
fieldMeta: {}, | ||
@@ -66,0 +66,0 @@ canSubmit: true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
392485
4182
+ Added@tanstack/store@0.1.3(transitive)
- Removed@tanstack/store@0.0.1-beta.89(transitive)
Updated@tanstack/store@0.1.3