@tanstack/form-core 0.23.1 → 0.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/FieldApi.cjs +17 -0
- package/dist/cjs/FieldApi.cjs.map +1 -1
- package/dist/cjs/FieldApi.d.cts +220 -1
- package/dist/cjs/FormApi.cjs +14 -0
- package/dist/cjs/FormApi.cjs.map +1 -1
- package/dist/cjs/FormApi.d.cts +238 -0
- package/dist/cjs/mergeForm.cjs.map +1 -1
- package/dist/cjs/mergeForm.d.cts +3 -0
- package/dist/cjs/types.d.cts +14 -0
- package/dist/cjs/util-types.d.cts +18 -3
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/utils.d.cts +24 -0
- package/dist/esm/FieldApi.d.ts +220 -1
- package/dist/esm/FieldApi.js +17 -0
- package/dist/esm/FieldApi.js.map +1 -1
- package/dist/esm/FormApi.d.ts +238 -0
- package/dist/esm/FormApi.js +14 -0
- package/dist/esm/FormApi.js.map +1 -1
- package/dist/esm/mergeForm.d.ts +3 -0
- package/dist/esm/mergeForm.js.map +1 -1
- package/dist/esm/types.d.ts +14 -0
- package/dist/esm/util-types.d.ts +18 -3
- package/dist/esm/utils.d.ts +24 -0
- package/dist/esm/utils.js.map +1 -1
- package/package.json +7 -3
- package/src/FieldApi.ts +249 -4
- package/src/FormApi.ts +249 -12
- package/src/mergeForm.ts +3 -0
- package/src/types.ts +14 -2
- package/src/util-types.ts +18 -4
- package/src/utils.ts +24 -0
- package/src/tests/FieldApi.spec.ts +0 -1184
- package/src/tests/FieldApi.test-d.ts +0 -149
- package/src/tests/FormApi.spec.ts +0 -1523
- package/src/tests/formOptions.test.ts +0 -25
- package/src/tests/mutateMergeDeep.spec.ts +0 -32
- package/src/tests/util-types.test-d.ts +0 -171
- package/src/tests/utils.spec.ts +0 -131
- package/src/tests/utils.ts +0 -5
package/src/utils.ts
CHANGED
|
@@ -8,6 +8,9 @@ export type Updater<TInput, TOutput = TInput> =
|
|
|
8
8
|
| TOutput
|
|
9
9
|
| UpdaterFn<TInput, TOutput>
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
11
14
|
export function functionalUpdate<TInput, TOutput = TInput>(
|
|
12
15
|
updater: Updater<TInput, TOutput>,
|
|
13
16
|
input: TInput,
|
|
@@ -19,6 +22,7 @@ export function functionalUpdate<TInput, TOutput = TInput>(
|
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* Get a value from an object using a path, including dot notation.
|
|
25
|
+
* @private
|
|
22
26
|
*/
|
|
23
27
|
export function getBy(obj: any, path: any) {
|
|
24
28
|
const pathObj = makePathArray(path)
|
|
@@ -33,6 +37,7 @@ export function getBy(obj: any, path: any) {
|
|
|
33
37
|
|
|
34
38
|
/**
|
|
35
39
|
* Set a value on an object using a path, including dot notation.
|
|
40
|
+
* @private
|
|
36
41
|
*/
|
|
37
42
|
export function setBy(obj: any, _path: any, updater: Updater<any>) {
|
|
38
43
|
const path = makePathArray(_path)
|
|
@@ -75,6 +80,7 @@ export function setBy(obj: any, _path: any, updater: Updater<any>) {
|
|
|
75
80
|
|
|
76
81
|
/**
|
|
77
82
|
* Delete a field on an object using a path, including dot notation.
|
|
83
|
+
* @private
|
|
78
84
|
*/
|
|
79
85
|
export function deleteBy(obj: any, _path: any) {
|
|
80
86
|
const path = makePathArray(_path)
|
|
@@ -130,6 +136,9 @@ const reFindMultiplePeriods = /\.{2,}/gm
|
|
|
130
136
|
const intPrefix = '__int__'
|
|
131
137
|
const intReplace = `${intPrefix}$1`
|
|
132
138
|
|
|
139
|
+
/**
|
|
140
|
+
* @private
|
|
141
|
+
*/
|
|
133
142
|
export function makePathArray(str: string) {
|
|
134
143
|
if (typeof str !== 'string') {
|
|
135
144
|
throw new Error('Path must be a string.')
|
|
@@ -152,6 +161,9 @@ export function makePathArray(str: string) {
|
|
|
152
161
|
})
|
|
153
162
|
}
|
|
154
163
|
|
|
164
|
+
/**
|
|
165
|
+
* @private
|
|
166
|
+
*/
|
|
155
167
|
export function isNonEmptyArray(obj: any) {
|
|
156
168
|
return !(Array.isArray(obj) && obj.length === 0)
|
|
157
169
|
}
|
|
@@ -161,12 +173,18 @@ interface AsyncValidatorArrayPartialOptions<T> {
|
|
|
161
173
|
asyncDebounceMs?: number
|
|
162
174
|
}
|
|
163
175
|
|
|
176
|
+
/**
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
164
179
|
export interface AsyncValidator<T> {
|
|
165
180
|
cause: ValidationCause
|
|
166
181
|
validate: T
|
|
167
182
|
debounceMs: number
|
|
168
183
|
}
|
|
169
184
|
|
|
185
|
+
/**
|
|
186
|
+
* @private
|
|
187
|
+
*/
|
|
170
188
|
export function getAsyncValidatorArray<T>(
|
|
171
189
|
cause: ValidationCause,
|
|
172
190
|
options: AsyncValidatorArrayPartialOptions<T>,
|
|
@@ -240,11 +258,17 @@ interface SyncValidatorArrayPartialOptions<T> {
|
|
|
240
258
|
validators?: T
|
|
241
259
|
}
|
|
242
260
|
|
|
261
|
+
/**
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
243
264
|
export interface SyncValidator<T> {
|
|
244
265
|
cause: ValidationCause
|
|
245
266
|
validate: T
|
|
246
267
|
}
|
|
247
268
|
|
|
269
|
+
/**
|
|
270
|
+
* @private
|
|
271
|
+
*/
|
|
248
272
|
export function getSyncValidatorArray<T>(
|
|
249
273
|
cause: ValidationCause,
|
|
250
274
|
options: SyncValidatorArrayPartialOptions<T>,
|