attaform 0.21.2 → 0.22.0

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.
Files changed (79) hide show
  1. package/dist/chunks/dev-key-collision-warnings.cjs +1 -1
  2. package/dist/chunks/dev-key-collision-warnings.mjs +1 -1
  3. package/dist/chunks/devtools.cjs +1 -1
  4. package/dist/chunks/devtools.mjs +1 -1
  5. package/dist/chunks/fingerprint2.cjs +1 -1
  6. package/dist/chunks/fingerprint2.mjs +1 -1
  7. package/dist/chunks/indexeddb.cjs +1 -1
  8. package/dist/chunks/indexeddb.mjs +1 -1
  9. package/dist/chunks/local-storage.cjs +1 -1
  10. package/dist/chunks/local-storage.mjs +1 -1
  11. package/dist/chunks/multi-tab-sync.cjs +2 -2
  12. package/dist/chunks/multi-tab-sync.mjs +2 -2
  13. package/dist/chunks/session-storage.cjs +1 -1
  14. package/dist/chunks/session-storage.mjs +1 -1
  15. package/dist/chunks/wire-persistence.cjs +2 -2
  16. package/dist/chunks/wire-persistence.mjs +2 -2
  17. package/dist/index.cjs +3 -3
  18. package/dist/index.d.cts +4 -4
  19. package/dist/index.d.mts +4 -4
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.mjs +5 -5
  22. package/dist/nuxt.d.cts +1 -1
  23. package/dist/nuxt.d.mts +1 -1
  24. package/dist/nuxt.d.ts +1 -1
  25. package/dist/runtime/plugins/attaform.cjs +2 -2
  26. package/dist/runtime/plugins/attaform.mjs +2 -2
  27. package/dist/shared/{attaform.B5LNzqQh.cjs → attaform.01iKS_lz.cjs} +18 -5
  28. package/dist/shared/{attaform.DP-u7_tk.mjs.map → attaform.01iKS_lz.cjs.map} +1 -1
  29. package/dist/shared/{attaform.C41gjp-a.mjs → attaform.6xE0Lcfd.mjs} +2 -2
  30. package/dist/shared/{attaform.C41gjp-a.mjs.map → attaform.6xE0Lcfd.mjs.map} +1 -1
  31. package/dist/shared/{attaform.BBDIKtKY.cjs → attaform.AyujQoHp.cjs} +4 -4
  32. package/dist/shared/{attaform.BBDIKtKY.cjs.map → attaform.AyujQoHp.cjs.map} +1 -1
  33. package/dist/shared/{attaform.BGf_J22U.d.ts → attaform.BGwNZ9GV.d.cts} +10 -2
  34. package/dist/shared/{attaform.DP-u7_tk.mjs → attaform.BKFwekY2.mjs} +16 -6
  35. package/dist/shared/{attaform.B5LNzqQh.cjs.map → attaform.BKFwekY2.mjs.map} +1 -1
  36. package/dist/shared/{attaform.CcnF1AKJ.cjs → attaform.C-RtnCJM.cjs} +116 -47
  37. package/dist/shared/attaform.C-RtnCJM.cjs.map +1 -0
  38. package/dist/shared/{attaform.BkjJfMvJ.d.cts → attaform.CCCeEPwa.d.mts} +10 -2
  39. package/dist/shared/{attaform.BwLp9KM7.cjs → attaform.CRzpFCjV.cjs} +2 -2
  40. package/dist/shared/{attaform.BwLp9KM7.cjs.map → attaform.CRzpFCjV.cjs.map} +1 -1
  41. package/dist/shared/{attaform.D2ZuIOCf.cjs → attaform.CjMcwV7W.cjs} +557 -126
  42. package/dist/shared/attaform.CjMcwV7W.cjs.map +1 -0
  43. package/dist/shared/{attaform.CTheKoTc.mjs → attaform.CsB-iKbU.mjs} +557 -126
  44. package/dist/shared/attaform.CsB-iKbU.mjs.map +1 -0
  45. package/dist/shared/{attaform.BCcrLApm.d.mts → attaform.D4XYaasQ.d.ts} +10 -2
  46. package/dist/shared/{attaform.D6GYGshL.mjs → attaform.DCjgGir_.mjs} +3 -3
  47. package/dist/shared/{attaform.D6GYGshL.mjs.map → attaform.DCjgGir_.mjs.map} +1 -1
  48. package/dist/shared/{attaform.BVeLgfEh.mjs → attaform.DNuiFCXG.mjs} +4 -4
  49. package/dist/shared/{attaform.BVeLgfEh.mjs.map → attaform.DNuiFCXG.mjs.map} +1 -1
  50. package/dist/shared/{attaform.BYgioWLF.d.ts → attaform.DUMWQefY.d.ts} +1 -1
  51. package/dist/shared/{attaform.CrD73S4m.mjs → attaform.DgCfLqay.mjs} +116 -47
  52. package/dist/shared/attaform.DgCfLqay.mjs.map +1 -0
  53. package/dist/shared/{attaform.ory-3WhV.d.ts → attaform.DvUH4a3o.d.cts} +181 -6
  54. package/dist/shared/{attaform.ory-3WhV.d.cts → attaform.DvUH4a3o.d.mts} +181 -6
  55. package/dist/shared/{attaform.ory-3WhV.d.mts → attaform.DvUH4a3o.d.ts} +181 -6
  56. package/dist/shared/{attaform.BoY6RZUl.d.cts → attaform.FN0vaQAg.d.mts} +1 -1
  57. package/dist/shared/{attaform.BwrowMp2.cjs → attaform.Q3eAD2wD.cjs} +3 -3
  58. package/dist/shared/{attaform.BwrowMp2.cjs.map → attaform.Q3eAD2wD.cjs.map} +1 -1
  59. package/dist/shared/{attaform.CnEl--PF.d.mts → attaform.aekT7mMx.d.cts} +1 -1
  60. package/dist/zod-v3.cjs +2 -2
  61. package/dist/zod-v3.d.cts +3 -3
  62. package/dist/zod-v3.d.mts +3 -3
  63. package/dist/zod-v3.d.ts +3 -3
  64. package/dist/zod-v3.mjs +2 -2
  65. package/dist/zod-v4.cjs +2 -2
  66. package/dist/zod-v4.d.cts +4 -4
  67. package/dist/zod-v4.d.mts +4 -4
  68. package/dist/zod-v4.d.ts +4 -4
  69. package/dist/zod-v4.mjs +2 -2
  70. package/dist/zod.cjs +5 -5
  71. package/dist/zod.d.cts +5 -5
  72. package/dist/zod.d.mts +5 -5
  73. package/dist/zod.d.ts +5 -5
  74. package/dist/zod.mjs +5 -5
  75. package/package.json +2 -2
  76. package/dist/shared/attaform.CTheKoTc.mjs.map +0 -1
  77. package/dist/shared/attaform.CcnF1AKJ.cjs.map +0 -1
  78. package/dist/shared/attaform.CrD73S4m.mjs.map +0 -1
  79. package/dist/shared/attaform.D2ZuIOCf.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { G as GenericForm, w as FlatPath, S as NestedType, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, am as ValidateOnConfig, b as UseFormReturnType } from './attaform.ory-3WhV.js';
2
+ import { G as GenericForm, w as FlatPath, S as NestedType, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, au as ValidateOnConfig, b as UseFormReturnType } from './attaform.DvUH4a3o.js';
3
3
 
4
4
  /**
5
5
  * The shape `form.values.<key>` returns at runtime.
@@ -1,7 +1,6 @@
1
- import { z } from 'zod';
2
- import { f as fieldMetaStore, g as getFieldMetaForSchema, a as getFieldMetaListForSchema, s as slimPrimitivesWalk, c as createAbstractSchema, w as walkPathSegments, d as deriveDefaultWalk, b as getFieldMetaPathMap, m as mergeDeep, p as peelEmbeddedDefault, N as NO_EMBEDDED_DEFAULT } from './attaform.D6GYGshL.mjs';
3
- import { E as humanize, t as getAtPath, h as slimKindOf, v as setAtPath, r as useAbstractForm } from './attaform.CTheKoTc.mjs';
4
- import { b as AttaformError, _ as __DEV__, a as canonicalizePath, d as InvalidUseFormConfigError } from './attaform.DP-u7_tk.mjs';
1
+ import { f as fieldMetaStore, g as getFieldMetaForSchema, a as getFieldMetaListForSchema, s as slimPrimitivesWalk, c as createAbstractSchema, w as walkPathSegments, d as deriveDefaultWalk, b as getFieldMetaPathMap, m as mergeDeep, p as peelEmbeddedDefault, N as NO_EMBEDDED_DEFAULT } from './attaform.DCjgGir_.mjs';
2
+ import { E as humanize, t as getAtPath, h as slimKindOf, v as setAtPath, r as useAbstractForm } from './attaform.CsB-iKbU.mjs';
3
+ import { b as AttaformError, _ as __DEV__, a as canonicalizePath, d as InvalidUseFormConfigError } from './attaform.BKFwekY2.mjs';
5
4
 
6
5
  const fieldMeta = fieldMetaStore;
7
6
  function withMeta(schema, payload) {
@@ -54,9 +53,6 @@ function clone(value, seen) {
54
53
  return copy;
55
54
  }
56
55
 
57
- class UnsupportedSchemaError extends AttaformError {
58
- }
59
-
60
56
  function isZodSchemaType(schema, expectedType) {
61
57
  if (typeof schema !== "object" || schema === null) return false;
62
58
  const maybeDef = schema._def;
@@ -191,6 +187,10 @@ function getDiscriminator(schema) {
191
187
  const def = readDef(schema);
192
188
  return def?.discriminator;
193
189
  }
190
+ function getDiscriminatedOptionsMap(schema) {
191
+ const map = readDef(schema)?.optionsMap;
192
+ return map instanceof Map ? map : void 0;
193
+ }
194
194
  function getIntersectionLeft(schema) {
195
195
  const def = readDef(schema);
196
196
  return def?.left;
@@ -471,6 +471,71 @@ function isContainerAfterWrapperPeel(schema) {
471
471
  return isZodSchemaType(cur, "ZodObject") || isZodSchemaType(cur, "ZodArray") || isZodSchemaType(cur, "ZodTuple") || isZodSchemaType(cur, "ZodIntersection") || isZodSchemaType(cur, "ZodUnion") || isZodSchemaType(cur, "ZodDiscriminatedUnion") || isZodSchemaType(cur, "ZodRecord") || isZodSchemaType(cur, "ZodSet");
472
472
  }
473
473
 
474
+ function rebuildWithDef(original, defPatch) {
475
+ const node = Object.create(Object.getPrototypeOf(original));
476
+ node._def = { ...original._def, ...defPatch };
477
+ return node;
478
+ }
479
+ function rebuildObject(original, shape) {
480
+ const node = rebuildWithDef(original, { shape: () => shape, unknownKeys: "strip" });
481
+ node._cached = null;
482
+ return node;
483
+ }
484
+ function rebuildArray(original, element) {
485
+ return rebuildWithDef(original, {
486
+ type: element,
487
+ minLength: null,
488
+ maxLength: null,
489
+ exactLength: null
490
+ });
491
+ }
492
+ function rebuildSet(original, valueType) {
493
+ return rebuildWithDef(original, {
494
+ valueType,
495
+ minSize: null,
496
+ maxSize: null
497
+ });
498
+ }
499
+ function rebuildRecord(original, valueType, keyType) {
500
+ const patch = { valueType };
501
+ if (keyType !== void 0) patch["keyType"] = keyType;
502
+ return rebuildWithDef(original, patch);
503
+ }
504
+ function rebuildTuple(original, items) {
505
+ return rebuildWithDef(original, { items, rest: null });
506
+ }
507
+ function rebuildUnion(original, options) {
508
+ return rebuildWithDef(original, { options });
509
+ }
510
+ function rebuildIntersection(original, left, right) {
511
+ return rebuildWithDef(original, { left, right });
512
+ }
513
+ function rebuildWrapperInner(original, inner) {
514
+ return rebuildWithDef(original, { innerType: inner });
515
+ }
516
+ function rebuildLazy(original, target) {
517
+ return rebuildWithDef(original, { getter: () => target });
518
+ }
519
+ function stripLeafChecks(original) {
520
+ return rebuildWithDef(original, { checks: [] });
521
+ }
522
+ function rebuildDiscriminatedUnion(original, options) {
523
+ const originalOptions = getDiscriminatedOptions(original);
524
+ const originalMap = getDiscriminatedOptionsMap(original);
525
+ const optionsMap = /* @__PURE__ */ new Map();
526
+ if (originalMap !== void 0) {
527
+ for (const [value, originalOption] of originalMap) {
528
+ const index = originalOptions.indexOf(originalOption);
529
+ const replacement = index >= 0 ? options[index] : void 0;
530
+ if (replacement !== void 0) optionsMap.set(value, replacement);
531
+ }
532
+ }
533
+ return rebuildWithDef(original, { options, optionsMap });
534
+ }
535
+
536
+ class UnsupportedSchemaError extends AttaformError {
537
+ }
538
+
474
539
  const UNSUPPORTED_TYPE_NAMES = /* @__PURE__ */ new Set(["ZodPromise", "ZodFunction", "ZodMap", "ZodSymbol"]);
475
540
  function labelPath(path) {
476
541
  return path.length === 0 ? "<root>" : path.join(".");
@@ -614,11 +679,11 @@ function stripAsyncChecks(schema) {
614
679
  }
615
680
  if (isZodSchemaType(s, "ZodOptional")) {
616
681
  const inner = unwrapInner(s);
617
- return inner === void 0 ? s : z.optional(recurse(inner));
682
+ return inner === void 0 ? s : rebuildWrapperInner(s, recurse(inner));
618
683
  }
619
684
  if (isZodSchemaType(s, "ZodNullable")) {
620
685
  const inner = unwrapInner(s);
621
- return inner === void 0 ? s : z.nullable(recurse(inner));
686
+ return inner === void 0 ? s : rebuildWrapperInner(s, recurse(inner));
622
687
  }
623
688
  if (isZodSchemaType(s, "ZodDefault")) {
624
689
  const inner = unwrapInner(s);
@@ -644,7 +709,7 @@ function stripAsyncChecks(schema) {
644
709
  const inner = unwrapLazy(s);
645
710
  if (inner === void 0) return s;
646
711
  const stripped = recurse(inner);
647
- return z.lazy(() => stripped);
712
+ return rebuildLazy(s, stripped);
648
713
  }
649
714
  if (isZodSchemaType(s, "ZodPipeline")) {
650
715
  const inSide = unwrapPipeIn(s);
@@ -656,33 +721,32 @@ function stripAsyncChecks(schema) {
656
721
  for (const [k, v] of Object.entries(shape)) {
657
722
  next[k] = recurse(v);
658
723
  }
659
- return carryObjectChecks(z.object(next), s);
724
+ return carryObjectChecks(rebuildObject(s, next), s);
660
725
  }
661
726
  if (isZodSchemaType(s, "ZodArray")) {
662
727
  const element = getArrayElement(s);
663
728
  if (element === void 0) return s;
664
- return carryArrayChecks(z.array(recurse(element)), s);
729
+ return carryArrayChecks(rebuildArray(s, recurse(element)), s);
665
730
  }
666
731
  if (isZodSchemaType(s, "ZodSet")) {
667
732
  const valueType = getSetValueType(s);
668
733
  if (valueType === void 0) return s;
669
- return carrySetChecks(z.set(recurse(valueType)), s);
734
+ return carrySetChecks(rebuildSet(s, recurse(valueType)), s);
670
735
  }
671
736
  if (isZodSchemaType(s, "ZodTuple")) {
672
737
  const items = getTupleItems(s).map(recurse);
673
- const rebuilt = z.tuple(items);
674
- return rebuilt;
738
+ return rebuildTuple(s, items);
675
739
  }
676
740
  if (isZodSchemaType(s, "ZodRecord")) {
677
741
  const keyType = getRecordKeyType(s);
678
742
  const valueType = getRecordValueType(s);
679
743
  if (valueType === void 0) return s;
680
744
  const next = recurse(valueType);
681
- return keyType === void 0 ? z.record(next) : z.record(keyType, next);
745
+ return keyType === void 0 ? rebuildRecord(s, next) : rebuildRecord(s, next, keyType);
682
746
  }
683
747
  if (isZodSchemaType(s, "ZodUnion")) {
684
748
  const options = getUnionOptions(s).map(recurse);
685
- return z.union(options);
749
+ return rebuildUnion(s, options);
686
750
  }
687
751
  if (isZodSchemaType(s, "ZodDiscriminatedUnion")) {
688
752
  const discKey = getDiscriminator(s);
@@ -690,16 +754,13 @@ function stripAsyncChecks(schema) {
690
754
  (o) => recurse(o)
691
755
  );
692
756
  if (discKey === void 0 || options.length === 0) return s;
693
- return z.discriminatedUnion(
694
- discKey,
695
- options
696
- );
757
+ return rebuildDiscriminatedUnion(s, options);
697
758
  }
698
759
  if (isZodSchemaType(s, "ZodIntersection")) {
699
760
  const left = getIntersectionLeft(s);
700
761
  const right = getIntersectionRight(s);
701
762
  if (left === void 0 || right === void 0) return s;
702
- return z.intersection(recurse(left), recurse(right));
763
+ return rebuildIntersection(s, recurse(left), recurse(right));
703
764
  }
704
765
  return s;
705
766
  }
@@ -1098,15 +1159,15 @@ function stripRefinements(schema) {
1098
1159
  function _stripRefinements(_schema, depth) {
1099
1160
  if (depth >= MAX_UNWRAP_STEPS) return _schema;
1100
1161
  if (isZodSchemaType(_schema, "ZodString") && hasChecks(_schema)) {
1101
- return z.string();
1162
+ return stripLeafChecks(_schema);
1102
1163
  }
1103
1164
  if (isZodSchemaType(_schema, "ZodNumber") && hasChecks(_schema)) {
1104
- return z.number();
1165
+ return stripLeafChecks(_schema);
1105
1166
  }
1106
1167
  if (isZodSchemaType(_schema, "ZodArray")) {
1107
1168
  const inner = getArrayElement(_schema);
1108
1169
  if (!inner) return _schema;
1109
- return z.array(_stripRefinements(inner, depth + 1));
1170
+ return rebuildArray(_schema, _stripRefinements(inner, depth + 1));
1110
1171
  }
1111
1172
  if (isZodSchemaType(_schema, "ZodObject")) {
1112
1173
  const strippedShape = Object.fromEntries(
@@ -1115,7 +1176,7 @@ function stripRefinements(schema) {
1115
1176
  _stripRefinements(value, depth + 1)
1116
1177
  ])
1117
1178
  );
1118
- return z.object(strippedShape);
1179
+ return rebuildObject(_schema, strippedShape);
1119
1180
  }
1120
1181
  if (isZodSchemaType(_schema, "ZodEffects")) {
1121
1182
  const inner = unwrapEffectsSource(_schema);
@@ -1125,12 +1186,12 @@ function stripRefinements(schema) {
1125
1186
  if (isZodSchemaType(_schema, "ZodOptional")) {
1126
1187
  const inner = unwrapInner(_schema);
1127
1188
  if (!inner) return _schema;
1128
- return z.optional(_stripRefinements(inner, depth + 1));
1189
+ return rebuildWrapperInner(_schema, _stripRefinements(inner, depth + 1));
1129
1190
  }
1130
1191
  if (isZodSchemaType(_schema, "ZodNullable")) {
1131
1192
  const inner = unwrapInner(_schema);
1132
1193
  if (!inner) return _schema;
1133
- return z.nullable(_stripRefinements(inner, depth + 1));
1194
+ return rebuildWrapperInner(_schema, _stripRefinements(inner, depth + 1));
1134
1195
  }
1135
1196
  if (isZodSchemaType(_schema, "ZodReadonly")) {
1136
1197
  const inner = unwrapInner(_schema);
@@ -1150,13 +1211,13 @@ function stripRefinements(schema) {
1150
1211
  if (isZodSchemaType(_schema, "ZodSet")) {
1151
1212
  const valueType = getSetValueType(_schema);
1152
1213
  if (!valueType) return _schema;
1153
- return z.set(_stripRefinements(valueType, depth + 1));
1214
+ return rebuildSet(_schema, _stripRefinements(valueType, depth + 1));
1154
1215
  }
1155
1216
  if (isZodSchemaType(_schema, "ZodTuple")) {
1156
1217
  const items = getTupleItems(_schema);
1157
1218
  if (items.length === 0) return _schema;
1158
1219
  const stripped = items.map((it) => _stripRefinements(it, depth + 1));
1159
- return z.tuple(stripped);
1220
+ return rebuildTuple(_schema, stripped);
1160
1221
  }
1161
1222
  if (isZodSchemaType(_schema, "ZodRecord")) {
1162
1223
  const valueType = getRecordValueType(_schema);
@@ -1164,15 +1225,15 @@ function stripRefinements(schema) {
1164
1225
  const value = _stripRefinements(valueType, depth + 1);
1165
1226
  const keyType = getRecordKeyType(_schema);
1166
1227
  if (keyType) {
1167
- return z.record(keyType, value);
1228
+ return rebuildRecord(_schema, value, keyType);
1168
1229
  }
1169
- return z.record(value);
1230
+ return rebuildRecord(_schema, value);
1170
1231
  }
1171
1232
  if (isZodSchemaType(_schema, "ZodUnion")) {
1172
1233
  const options = getUnionOptions(_schema);
1173
1234
  if (options.length === 0) return _schema;
1174
1235
  const stripped = options.map((o) => _stripRefinements(o, depth + 1));
1175
- return z.union(stripped);
1236
+ return rebuildUnion(_schema, stripped);
1176
1237
  }
1177
1238
  if (isZodSchemaType(_schema, "ZodDiscriminatedUnion")) {
1178
1239
  const discKey = getDiscriminator(_schema);
@@ -1181,22 +1242,23 @@ function stripRefinements(schema) {
1181
1242
  const stripped = options.map(
1182
1243
  (o) => _stripRefinements(o, depth + 1)
1183
1244
  );
1184
- return z.discriminatedUnion(
1185
- discKey,
1186
- stripped
1187
- );
1245
+ return rebuildDiscriminatedUnion(_schema, stripped);
1188
1246
  }
1189
1247
  if (isZodSchemaType(_schema, "ZodIntersection")) {
1190
1248
  const left = getIntersectionLeft(_schema);
1191
1249
  const right = getIntersectionRight(_schema);
1192
1250
  if (!left || !right) return _schema;
1193
- return z.intersection(_stripRefinements(left, depth + 1), _stripRefinements(right, depth + 1));
1251
+ return rebuildIntersection(
1252
+ _schema,
1253
+ _stripRefinements(left, depth + 1),
1254
+ _stripRefinements(right, depth + 1)
1255
+ );
1194
1256
  }
1195
1257
  if (isZodSchemaType(_schema, "ZodLazy")) {
1196
1258
  const inner = unwrapLazy(_schema);
1197
1259
  if (!inner) return _schema;
1198
1260
  const stripped = _stripRefinements(inner, depth + 1);
1199
- return z.lazy(() => stripped);
1261
+ return rebuildLazy(_schema, stripped);
1200
1262
  }
1201
1263
  return _schema;
1202
1264
  }
@@ -1236,12 +1298,12 @@ function getSlimSchema(config) {
1236
1298
  for (const [key, value] of Object.entries(getObjectShape(_schema))) {
1237
1299
  newShape[key] = _getSlimSchema(value);
1238
1300
  }
1239
- return z.object(newShape);
1301
+ return rebuildObject(_schema, newShape);
1240
1302
  }
1241
1303
  if (isZodSchemaType(_schema, "ZodArray")) {
1242
1304
  const inner = getArrayElement(_schema);
1243
1305
  if (!inner) return _schema;
1244
- return z.array(_getSlimSchema(inner));
1306
+ return rebuildArray(_schema, _getSlimSchema(inner));
1245
1307
  }
1246
1308
  if (isZodSchemaType(_schema, "ZodRecord")) {
1247
1309
  const keyType = getRecordKeyType(_schema);
@@ -1249,7 +1311,7 @@ function getSlimSchema(config) {
1249
1311
  if (!keyType || !valueType) return _schema;
1250
1312
  const key = _getSlimSchema(keyType);
1251
1313
  const value = _getSlimSchema(valueType);
1252
- return z.record(key, value);
1314
+ return rebuildRecord(_schema, value, key);
1253
1315
  }
1254
1316
  if (isZodSchemaType(_schema, "ZodDiscriminatedUnion")) {
1255
1317
  const slimmedSchemas = [];
@@ -1260,8 +1322,8 @@ function getSlimSchema(config) {
1260
1322
  const deepCloneSlimmedSchema = cloneSchemaDeep(slimmedSchema);
1261
1323
  slimmedSchemas.push(deepCloneSlimmedSchema);
1262
1324
  }
1263
- return z.discriminatedUnion(
1264
- discKey,
1325
+ return rebuildDiscriminatedUnion(
1326
+ _schema,
1265
1327
  slimmedSchemas
1266
1328
  );
1267
1329
  }
@@ -1526,7 +1588,10 @@ function runStrictGetDefaultsV3(rootSchema, config, formKey, maxRecursionDepth)
1526
1588
  formKey
1527
1589
  };
1528
1590
  }
1529
- function getNestedSchemasInSlimModeV3(rootSchema, path, maxRecursionDepth) {
1591
+ const slimRootCacheV3 = /* @__PURE__ */ new WeakMap();
1592
+ function getSlimRootV3(rootSchema) {
1593
+ const cached = slimRootCacheV3.get(rootSchema);
1594
+ if (cached !== void 0) return cached;
1530
1595
  const [strippedSchema] = stripRootSchema(rootSchema, {
1531
1596
  stripDefaultValues: true,
1532
1597
  stripNullable: true,
@@ -1537,7 +1602,11 @@ function getNestedSchemasInSlimModeV3(rootSchema, path, maxRecursionDepth) {
1537
1602
  schema: strippedSchema,
1538
1603
  stripConfig: { stripDefaultValues: true, stripZodEffects: true }
1539
1604
  });
1540
- return getNestedZodSchemasAtPath(slimSchema, path, maxRecursionDepth);
1605
+ slimRootCacheV3.set(rootSchema, slimSchema);
1606
+ return slimSchema;
1607
+ }
1608
+ function getNestedSchemasInSlimModeV3(rootSchema, path, maxRecursionDepth) {
1609
+ return getNestedZodSchemasAtPath(getSlimRootV3(rootSchema), path, maxRecursionDepth);
1541
1610
  }
1542
1611
 
1543
1612
  function useForm(configuration) {
@@ -1557,4 +1626,4 @@ function useForm(configuration) {
1557
1626
  }
1558
1627
 
1559
1628
  export { fieldMeta as f, isZodSchemaType as i, useForm as u, withMeta as w, zodAdapter as z };
1560
- //# sourceMappingURL=attaform.CrD73S4m.mjs.map
1629
+ //# sourceMappingURL=attaform.DgCfLqay.mjs.map