@tanstack/form-core 1.24.1 → 1.24.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/FormApi.cjs +39 -13
- package/dist/cjs/FormApi.cjs.map +1 -1
- package/dist/esm/FormApi.js +39 -13
- package/dist/esm/FormApi.js.map +1 -1
- package/package.json +1 -1
- package/src/FormApi.ts +51 -21
package/package.json
CHANGED
package/src/FormApi.ts
CHANGED
|
@@ -1642,6 +1642,11 @@ export class FormApi<
|
|
|
1642
1642
|
for (const field of Object.keys(
|
|
1643
1643
|
this.state.fieldMeta,
|
|
1644
1644
|
) as DeepKeys<TFormData>[]) {
|
|
1645
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1646
|
+
if (this.baseStore.state.fieldMetaBase[field] === undefined) {
|
|
1647
|
+
continue
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1645
1650
|
const fieldMeta = this.getFieldMeta(field)
|
|
1646
1651
|
if (!fieldMeta) continue
|
|
1647
1652
|
|
|
@@ -1845,6 +1850,11 @@ export class FormApi<
|
|
|
1845
1850
|
for (const field of Object.keys(
|
|
1846
1851
|
this.state.fieldMeta,
|
|
1847
1852
|
) as DeepKeys<TFormData>[]) {
|
|
1853
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1854
|
+
if (this.baseStore.state.fieldMetaBase[field] === undefined) {
|
|
1855
|
+
continue
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1848
1858
|
const fieldMeta = this.getFieldMeta(field)
|
|
1849
1859
|
if (!fieldMeta) continue
|
|
1850
1860
|
|
|
@@ -2308,13 +2318,18 @@ export class FormApi<
|
|
|
2308
2318
|
mergeOpts(options, { dontValidate: true }),
|
|
2309
2319
|
)
|
|
2310
2320
|
|
|
2311
|
-
|
|
2312
|
-
|
|
2321
|
+
const dontValidate = options?.dontValidate ?? false
|
|
2322
|
+
if (!dontValidate) {
|
|
2323
|
+
// Validate the whole array + all fields that have shifted
|
|
2324
|
+
await this.validateField(field, 'change')
|
|
2325
|
+
}
|
|
2313
2326
|
|
|
2314
2327
|
// Shift down all meta after validating to make sure the new field has been mounted
|
|
2315
2328
|
metaHelper(this).handleArrayFieldMetaShift(field, index, 'insert')
|
|
2316
2329
|
|
|
2317
|
-
|
|
2330
|
+
if (!dontValidate) {
|
|
2331
|
+
await this.validateArrayFieldsStartingFrom(field, index, 'change')
|
|
2332
|
+
}
|
|
2318
2333
|
}
|
|
2319
2334
|
|
|
2320
2335
|
/**
|
|
@@ -2338,9 +2353,12 @@ export class FormApi<
|
|
|
2338
2353
|
mergeOpts(options, { dontValidate: true }),
|
|
2339
2354
|
)
|
|
2340
2355
|
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2356
|
+
const dontValidate = options?.dontValidate ?? false
|
|
2357
|
+
if (!dontValidate) {
|
|
2358
|
+
// Validate the whole array + all fields that have shifted
|
|
2359
|
+
await this.validateField(field, 'change')
|
|
2360
|
+
await this.validateArrayFieldsStartingFrom(field, index, 'change')
|
|
2361
|
+
}
|
|
2344
2362
|
}
|
|
2345
2363
|
|
|
2346
2364
|
/**
|
|
@@ -2375,9 +2393,12 @@ export class FormApi<
|
|
|
2375
2393
|
this.deleteField(start as never)
|
|
2376
2394
|
}
|
|
2377
2395
|
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2396
|
+
const dontValidate = options?.dontValidate ?? false
|
|
2397
|
+
if (!dontValidate) {
|
|
2398
|
+
// Validate the whole array + all fields that have shifted
|
|
2399
|
+
await this.validateField(field, 'change')
|
|
2400
|
+
await this.validateArrayFieldsStartingFrom(field, index, 'change')
|
|
2401
|
+
}
|
|
2381
2402
|
}
|
|
2382
2403
|
|
|
2383
2404
|
/**
|
|
@@ -2402,11 +2423,14 @@ export class FormApi<
|
|
|
2402
2423
|
// Swap meta
|
|
2403
2424
|
metaHelper(this).handleArrayFieldMetaShift(field, index1, 'swap', index2)
|
|
2404
2425
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2426
|
+
const dontValidate = options?.dontValidate ?? false
|
|
2427
|
+
if (!dontValidate) {
|
|
2428
|
+
// Validate the whole array
|
|
2429
|
+
this.validateField(field, 'change')
|
|
2430
|
+
// Validate the swapped fields
|
|
2431
|
+
this.validateField(`${field}[${index1}]` as DeepKeys<TFormData>, 'change')
|
|
2432
|
+
this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')
|
|
2433
|
+
}
|
|
2410
2434
|
}
|
|
2411
2435
|
|
|
2412
2436
|
/**
|
|
@@ -2431,11 +2455,14 @@ export class FormApi<
|
|
|
2431
2455
|
// Move meta between index1 and index2
|
|
2432
2456
|
metaHelper(this).handleArrayFieldMetaShift(field, index1, 'move', index2)
|
|
2433
2457
|
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2458
|
+
const dontValidate = options?.dontValidate ?? false
|
|
2459
|
+
if (!dontValidate) {
|
|
2460
|
+
// Validate the whole array
|
|
2461
|
+
this.validateField(field, 'change')
|
|
2462
|
+
// Validate the moved fields
|
|
2463
|
+
this.validateField(`${field}[${index1}]` as DeepKeys<TFormData>, 'change')
|
|
2464
|
+
this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')
|
|
2465
|
+
}
|
|
2439
2466
|
}
|
|
2440
2467
|
|
|
2441
2468
|
/**
|
|
@@ -2464,8 +2491,11 @@ export class FormApi<
|
|
|
2464
2491
|
}
|
|
2465
2492
|
}
|
|
2466
2493
|
|
|
2467
|
-
|
|
2468
|
-
|
|
2494
|
+
const dontValidate = options?.dontValidate ?? false
|
|
2495
|
+
if (!dontValidate) {
|
|
2496
|
+
// validate array change
|
|
2497
|
+
this.validateField(field, 'change')
|
|
2498
|
+
}
|
|
2469
2499
|
}
|
|
2470
2500
|
|
|
2471
2501
|
/**
|