@tanstack/form-core 1.24.2 → 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 +33 -13
- package/dist/cjs/FormApi.cjs.map +1 -1
- package/dist/esm/FormApi.js +33 -13
- package/dist/esm/FormApi.js.map +1 -1
- package/package.json +1 -1
- package/src/FormApi.ts +41 -21
package/src/FormApi.ts
CHANGED
|
@@ -2318,13 +2318,18 @@ export class FormApi<
|
|
|
2318
2318
|
mergeOpts(options, { dontValidate: true }),
|
|
2319
2319
|
)
|
|
2320
2320
|
|
|
2321
|
-
|
|
2322
|
-
|
|
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
|
+
}
|
|
2323
2326
|
|
|
2324
2327
|
// Shift down all meta after validating to make sure the new field has been mounted
|
|
2325
2328
|
metaHelper(this).handleArrayFieldMetaShift(field, index, 'insert')
|
|
2326
2329
|
|
|
2327
|
-
|
|
2330
|
+
if (!dontValidate) {
|
|
2331
|
+
await this.validateArrayFieldsStartingFrom(field, index, 'change')
|
|
2332
|
+
}
|
|
2328
2333
|
}
|
|
2329
2334
|
|
|
2330
2335
|
/**
|
|
@@ -2348,9 +2353,12 @@ export class FormApi<
|
|
|
2348
2353
|
mergeOpts(options, { dontValidate: true }),
|
|
2349
2354
|
)
|
|
2350
2355
|
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
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
|
+
}
|
|
2354
2362
|
}
|
|
2355
2363
|
|
|
2356
2364
|
/**
|
|
@@ -2385,9 +2393,12 @@ export class FormApi<
|
|
|
2385
2393
|
this.deleteField(start as never)
|
|
2386
2394
|
}
|
|
2387
2395
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
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
|
+
}
|
|
2391
2402
|
}
|
|
2392
2403
|
|
|
2393
2404
|
/**
|
|
@@ -2412,11 +2423,14 @@ export class FormApi<
|
|
|
2412
2423
|
// Swap meta
|
|
2413
2424
|
metaHelper(this).handleArrayFieldMetaShift(field, index1, 'swap', index2)
|
|
2414
2425
|
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
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
|
+
}
|
|
2420
2434
|
}
|
|
2421
2435
|
|
|
2422
2436
|
/**
|
|
@@ -2441,11 +2455,14 @@ export class FormApi<
|
|
|
2441
2455
|
// Move meta between index1 and index2
|
|
2442
2456
|
metaHelper(this).handleArrayFieldMetaShift(field, index1, 'move', index2)
|
|
2443
2457
|
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
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
|
+
}
|
|
2449
2466
|
}
|
|
2450
2467
|
|
|
2451
2468
|
/**
|
|
@@ -2474,8 +2491,11 @@ export class FormApi<
|
|
|
2474
2491
|
}
|
|
2475
2492
|
}
|
|
2476
2493
|
|
|
2477
|
-
|
|
2478
|
-
|
|
2494
|
+
const dontValidate = options?.dontValidate ?? false
|
|
2495
|
+
if (!dontValidate) {
|
|
2496
|
+
// validate array change
|
|
2497
|
+
this.validateField(field, 'change')
|
|
2498
|
+
}
|
|
2479
2499
|
}
|
|
2480
2500
|
|
|
2481
2501
|
/**
|