attaform 0.29.0 → 0.30.1

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/abstract.d.mts +15 -21
  2. package/dist/abstract.mjs +4 -4
  3. package/dist/dev/abstract.mjs +4 -4
  4. package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
  5. package/dist/dev/chunks/devtools.mjs +2 -2
  6. package/dist/dev/directive.mjs +1 -1
  7. package/dist/dev/history.mjs +1 -2
  8. package/dist/dev/index.mjs +5 -5
  9. package/dist/dev/runtime/plugins/attaform.mjs +3 -3
  10. package/dist/dev/shared/{attaform-dev.BO-71R54.mjs → attaform-dev.BJK1kqHY.mjs} +44 -198
  11. package/dist/dev/shared/{attaform-dev.D8aoKb89.mjs → attaform-dev.BMQ3GcgD.mjs} +51 -64
  12. package/dist/dev/shared/{attaform-dev.BgM6FdtA.mjs → attaform-dev.BUIFcTYf.mjs} +94 -62
  13. package/dist/dev/shared/{attaform-dev.q6UutkCx.mjs → attaform-dev.CT7MDjPy.mjs} +92 -152
  14. package/dist/dev/shared/{attaform-dev.ButTkwHd.mjs → attaform-dev.CZz4GYZ6.mjs} +26 -15
  15. package/dist/dev/shared/{attaform-dev.DD5m2W51.mjs → attaform-dev.Chm4D6SJ.mjs} +2 -4
  16. package/dist/dev/shared/{attaform-dev.DrzObAZo.mjs → attaform-dev.DuEE4GU1.mjs} +4 -4
  17. package/dist/dev/shared/{attaform-dev.DHuydLAC.mjs → attaform-dev.DxHdkkPG.mjs} +674 -734
  18. package/dist/dev/shared/{attaform-dev.A-TpJW0B.mjs → attaform-dev.zlvDr0WB.mjs} +3 -21
  19. package/dist/dev/zod-v3.mjs +6 -6
  20. package/dist/dev/zod-v4.mjs +6 -6
  21. package/dist/dev/zod.mjs +5 -5
  22. package/dist/directive.d.mts +4 -4
  23. package/dist/directive.mjs +1 -1
  24. package/dist/esbuild.d.mts +11 -0
  25. package/dist/esbuild.mjs +1 -1
  26. package/dist/history.d.mts +3 -32
  27. package/dist/history.mjs +1 -2
  28. package/dist/index.d.mts +67 -70
  29. package/dist/index.mjs +5 -5
  30. package/dist/nuxt.d.mts +6 -14
  31. package/dist/nuxt.mjs +3 -7
  32. package/dist/rollup.d.mts +11 -0
  33. package/dist/rollup.mjs +1 -1
  34. package/dist/rspack.d.mts +19 -11
  35. package/dist/rspack.mjs +1 -1
  36. package/dist/runtime/components/AttaformDevtoolsPanel.vue +12 -12
  37. package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
  38. package/dist/runtime/plugins/attaform.mjs +3 -3
  39. package/dist/shared/{attaform.CIWLMY-R.d.mts → attaform.2FslhB9R.d.mts} +83 -95
  40. package/dist/shared/{attaform.Cvao8bW5.mjs → attaform.8mfKZCwH.mjs} +7 -7
  41. package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
  42. package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
  43. package/dist/shared/{attaform.BndjUUYX.mjs → attaform.B2iebkPA.mjs} +4 -4
  44. package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
  45. package/dist/shared/{attaform.CZMAYwSK.mjs → attaform.BIWicztt.mjs} +651 -678
  46. package/dist/shared/attaform.BcQwgWaq.d.mts +2153 -0
  47. package/dist/shared/attaform.Br8EBn5B.d.mts +4553 -0
  48. package/dist/shared/{attaform.C2MVyuxC.mjs → attaform.CO918TdU.mjs} +44 -198
  49. package/dist/shared/{attaform.CZYt_5N_.mjs → attaform.CdZIEf7_.mjs} +1 -19
  50. package/dist/shared/{attaform.B0dKL8ST.mjs → attaform.DRsANMok.mjs} +94 -62
  51. package/dist/shared/{attaform.DffRL5pP.mjs → attaform.D_f1WgYf.mjs} +46 -59
  52. package/dist/shared/{attaform.D1fnTifF.mjs → attaform.D_pt1gOj.mjs} +92 -150
  53. package/dist/shared/attaform.L0kUn3vL.d.mts +42 -0
  54. package/dist/shared/{attaform.D0x-qSXm.mjs → attaform.WiGdIqgx.mjs} +1 -3
  55. package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.ZYn2ahzJ.mjs} +3 -3
  56. package/dist/transforms.d.mts +153 -26
  57. package/dist/transforms.mjs +1 -1
  58. package/dist/vite.d.mts +29 -52
  59. package/dist/vite.mjs +8 -3
  60. package/dist/webpack.d.mts +20 -12
  61. package/dist/webpack.mjs +1 -1
  62. package/dist/zod-v3.d.mts +90 -96
  63. package/dist/zod-v3.mjs +6 -6
  64. package/dist/zod-v4.d.mts +119 -119
  65. package/dist/zod-v4.mjs +6 -6
  66. package/dist/zod.d.mts +5 -5
  67. package/dist/zod.mjs +5 -5
  68. package/package.json +9 -7
  69. package/skills/attaform/SKILL.md +1 -1
  70. package/skills/attaform/references/custom-components.md +1 -1
  71. package/dist/chunks/fingerprint.mjs +0 -183
  72. package/dist/chunks/fingerprint2.mjs +0 -159
  73. package/dist/dev/chunks/fingerprint.mjs +0 -183
  74. package/dist/dev/chunks/fingerprint2.mjs +0 -159
  75. package/dist/dev/shared/attaform-dev.BxfsuwBR.mjs +0 -44
  76. package/dist/shared/attaform.BxfsuwBR.mjs +0 -44
  77. package/dist/shared/attaform.CsoeRi3P.d.mts +0 -5155
  78. package/dist/shared/attaform.DDtqHYv1.d.mts +0 -2465
  79. package/dist/shared/attaform.axHXVQO7.d.mts +0 -44
@@ -1,7 +1,7 @@
1
- import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, m as mergeDeep, f as fixStructuralDefaults, d as deriveDefaultWalk, a as getFieldMetaListForSchema } from './attaform.B0dKL8ST.mjs';
2
- import { p as getAtPath, q as humanize, h as useAbstractForm } from './attaform.CZMAYwSK.mjs';
3
- import { c as callConsumerSchemaFn } from './attaform.Cvao8bW5.mjs';
4
- import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.CZYt_5N_.mjs';
1
+ import { w as walkPathSegments, s as slimPrimitivesWalk, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, g as getFieldMetaForSchema, f as fixStructuralDefaults, m as mergeDeep, d as deriveDefaultWalk, e as getFieldMetaListForSchema } from './attaform.DRsANMok.mjs';
2
+ import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform.BIWicztt.mjs';
3
+ import { c as callConsumerFn } from './attaform.8mfKZCwH.mjs';
4
+ import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.CdZIEf7_.mjs';
5
5
 
6
6
  function isZodSchemaType(schema, expectedType) {
7
7
  if (typeof schema !== "object" || schema === null) return false;
@@ -127,22 +127,29 @@ function getTupleItems(schema) {
127
127
  const def = readDef(schema);
128
128
  return def?.items ?? [];
129
129
  }
130
+ function readOptionList(options) {
131
+ if (options === void 0) return [];
132
+ if (options instanceof Map) return [...options.values()];
133
+ return [...options];
134
+ }
130
135
  function getUnionOptions(schema) {
131
- const def = readDef(schema);
132
- return def?.options ?? [];
136
+ return readOptionList(readDef(schema)?.options);
133
137
  }
134
138
  function getDiscriminatedOptions(schema) {
135
- const def = readDef(schema);
136
- return def?.options ?? [];
139
+ return readOptionList(readDef(schema)?.options);
137
140
  }
138
141
  function getDiscriminator(schema) {
139
142
  const def = readDef(schema);
140
143
  return def?.discriminator;
141
144
  }
142
145
  function getDiscriminatedOptionsMap(schema) {
143
- const map = readDef(schema)?.optionsMap;
146
+ const def = readDef(schema);
147
+ const map = def?.optionsMap ?? def?.options;
144
148
  return map instanceof Map ? map : void 0;
145
149
  }
150
+ function discriminatedOptionsAreMapped(schema) {
151
+ return readDef(schema)?.options instanceof Map;
152
+ }
146
153
  function getIntersectionLeft(schema) {
147
154
  const def = readDef(schema);
148
155
  return def?.left;
@@ -299,11 +306,7 @@ function unwrapLazy(schema) {
299
306
  const def = readDef(schema);
300
307
  const getter = def?.getter;
301
308
  if (typeof getter !== "function") return void 0;
302
- return callConsumerSchemaFn(() => getter(), void 0);
303
- }
304
- function getLazyGetter(schema) {
305
- const def = readDef(schema);
306
- return typeof def?.getter === "function" ? def.getter : void 0;
309
+ return callConsumerFn(() => getter(), void 0);
307
310
  }
308
311
  function getLiteralValues(schema) {
309
312
  const def = readDef(schema);
@@ -320,15 +323,13 @@ function getDefaultValue(schema) {
320
323
  const def = readDef(schema);
321
324
  const thunk = def?.defaultValue;
322
325
  if (typeof thunk !== "function") return void 0;
323
- return callConsumerSchemaFn(() => thunk(), void 0);
326
+ return callConsumerFn(() => thunk(), void 0);
324
327
  }
325
328
  function getCatchDefault(schema) {
326
329
  const def = readDef(schema);
327
330
  const cv = def?.catchValue;
328
331
  if (typeof cv !== "function") return void 0;
329
- return callConsumerSchemaFn(
330
- () => cv({ error: null, input: void 0 }),
331
- void 0);
332
+ return callConsumerFn(() => cv({ error: null, input: void 0 }), void 0);
332
333
  }
333
334
  function hasCatchValue(schema) {
334
335
  const def = readDef(schema);
@@ -445,7 +446,6 @@ const V3_INTROSPECTOR = {
445
446
  // Walker accessors (D2 / D3 / D5).
446
447
  getArrayElement,
447
448
  getSetValueType,
448
- getRecordKeyType,
449
449
  getRecordValueType,
450
450
  getMapKeyType: (schema) => kindOf(schema) === "map" ? getMapKeyType(schema) : void 0,
451
451
  getMapValueType: (schema) => kindOf(schema) === "map" ? getMapValueType(schema) : void 0,
@@ -463,7 +463,6 @@ const V3_INTROSPECTOR = {
463
463
  unwrapPipeIn,
464
464
  unwrapPipeOut,
465
465
  unwrapLazy,
466
- getLazyGetter,
467
466
  getDefaultValue,
468
467
  getCatchDefault,
469
468
  hasCatchValue
@@ -599,22 +598,22 @@ function rebuildDiscriminatedUnion(original, options) {
599
598
  if (replacement !== void 0) optionsMap.set(value, replacement);
600
599
  }
601
600
  }
601
+ if (discriminatedOptionsAreMapped(original)) {
602
+ return rebuildWithDef(original, { options: optionsMap });
603
+ }
602
604
  return rebuildWithDef(original, { options, optionsMap });
603
605
  }
604
606
  function rebuildEffects(original, source, effect) {
605
607
  return rebuildWithDef(original, { schema: source, effect });
606
608
  }
607
609
 
608
- function stripAsyncChecks(schema) {
609
- return walkEffects(schema, "strip");
610
- }
611
610
  function wrapAsyncSafeRefinements(schema) {
612
- return walkEffects(schema, "wrap");
611
+ return walkEffects(schema);
613
612
  }
614
613
  function isThenable(value) {
615
614
  return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
616
615
  }
617
- function walkEffects(schema, policy) {
616
+ function walkEffects(schema) {
618
617
  const seen = /* @__PURE__ */ new WeakSet();
619
618
  function recurse(s) {
620
619
  const candidate = s;
@@ -624,7 +623,6 @@ function walkEffects(schema, policy) {
624
623
  if (isZodSchemaType(s, "ZodEffects")) {
625
624
  const inner = unwrapEffectsSource(s);
626
625
  if (inner === void 0) return s;
627
- if (policy === "strip") return recurse(inner);
628
626
  const effect = getEffect(s);
629
627
  const rebuiltInner = recurse(inner);
630
628
  const original = effect?.["refinement"];
@@ -797,18 +795,18 @@ function zodAdapter(zodSchema) {
797
795
  `[attaform] AF15 attaform.dev/e/af15 '${name}'`
798
796
  );
799
797
  }
800
- return (formKey, options) => createAbstractSchema(
798
+ return (_formKey, options) => sharedV3Schemas(
801
799
  zodSchema,
802
- V3_INTROSPECTOR,
803
- buildV3Services(options.maxRecursionDepth),
804
- formKey,
805
- options
800
+ options.maxRecursionDepth,
801
+ () => createAbstractSchema(
802
+ zodSchema,
803
+ V3_INTROSPECTOR,
804
+ buildV3Services(options.maxRecursionDepth),
805
+ options
806
+ )
806
807
  );
807
808
  }
808
- async function lazyFingerprint(schema) {
809
- const { fingerprintZodSchema } = await import('../chunks/fingerprint.mjs');
810
- return fingerprintZodSchema(schema);
811
- }
809
+ const sharedV3Schemas = createSharedSchemaStore();
812
810
  const syncSafeCache = /* @__PURE__ */ new WeakMap();
813
811
  function syncSafe(schema) {
814
812
  const cached = syncSafeCache.get(schema);
@@ -829,19 +827,14 @@ function buildV3Services(maxRecursionDepth) {
829
827
  return normalizeIssuePaths(issues, schema, data, maxRecursionDepth, peelAllV3Wrappers);
830
828
  };
831
829
  return {
832
- fingerprint: (schema) => lazyFingerprint(schema),
833
830
  getNestedSchemasAtPath: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
834
- // v3 pre-strips refinements / defaults / wrappers off the root for
835
- // slim-mode walks — `getSlimPrimitiveTypesAtPath` and
836
- // `getSchemasAtPath` both consume this variant so the yielded
837
- // candidates reflect the slim shape.
838
- // The slim-root projection is gone (size-teardown P7): the shared
839
- // path walker peels wrappers / effects inline, so the slim and
840
- // unstripped walks coincide — same aliasing v4 always had.
831
+ // The shared path walker peels wrappers and effects inline, so the
832
+ // slim and unstripped walks coincide and the root needs no slim
833
+ // projection of its own. Same aliasing v4 has.
841
834
  getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
842
835
  slimPrimitivesOf: (schema, _maxRecursionDepth) => slimPrimitivesV3(schema),
843
- deriveDefault: (schema, useDefault, _maxRecursionDepth, formKey) => getDefaultValuesFromZodSchema(schema, useDefault, formKey),
844
- runStrictGetDefaults: (schema, config, formKey, maxRecursionDepth2) => runStrictGetDefaultsV3(schema, config, formKey, maxRecursionDepth2),
836
+ deriveDefault: (schema, useDefault) => getDefaultValuesFromZodSchema(schema, useDefault),
837
+ runGetDefaults: (schema, config, maxRecursionDepth2) => runGetDefaultsV3(schema, config, maxRecursionDepth2),
845
838
  unwrapStructuralWrappers: (schema) => unwrapStructuralLeafV3(schema),
846
839
  unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
847
840
  peelAllWrappers: (schema) => peelAllV3Wrappers(schema),
@@ -856,15 +849,14 @@ function buildV3Services(maxRecursionDepth) {
856
849
  const result = await schema.safeParseAsync(data);
857
850
  return result.success ? { success: true, data: result.data } : { success: false, issues: refileIssues(schema, data, result.error.issues) };
858
851
  },
859
- // v3 returns the full recursive AbstractSchema for sub-schemas (the
860
- // historical shape) — `getSchemasAtPath` consumers may probe any
861
- // method on the result. The factory call rebuilds the full surface
862
- // against the sub-schema with its own per-form caches.
863
- makeSubSchema: (sub, formKey, maxRecursionDepth2) => createAbstractSchema(
852
+ // A `getSchemasAtPath` consumer may probe any method on the result,
853
+ // so a sub-schema comes back as a full recursive AbstractSchema: the
854
+ // factory call rebuilds the whole surface against it, with its own
855
+ // per-form caches.
856
+ makeSubSchema: (sub, maxRecursionDepth2) => createAbstractSchema(
864
857
  sub,
865
858
  V3_INTROSPECTOR,
866
859
  buildV3Services(maxRecursionDepth2),
867
- formKey,
868
860
  { maxRecursionDepth: maxRecursionDepth2 }
869
861
  )
870
862
  };
@@ -880,17 +872,16 @@ function zodIssuesToValidationErrors(issues) {
880
872
  }
881
873
  validationErrors.push({
882
874
  message: issue.message,
883
- // `ValidationError.path` is `(string | number)[]` per the
884
- // public type. v3's `issue.path` is the same in the standard
885
- // case, but a custom check via `ctx.addIssue({ path: [...] })`
886
- // can smuggle a Symbol through — the public surface promised
887
- // strings/numbers, so coerce defensively to keep the contract.
888
- // Mirrors v4's behaviour at the same site.
875
+ // `ValidationError.path` is `(string | number)[]` publicly, and
876
+ // v3's `issue.path` matches in the standard case, but a custom
877
+ // check calling `ctx.addIssue({ path: [...] })` can smuggle a
878
+ // Symbol through. Coerce to keep the promise. v4 does the same
879
+ // here.
889
880
  //
890
- // Adapter-side paths stay schema-relative — the validation
891
- // pipeline in `create-form-store.ts` prepends the parent path
892
- // to absolutise, then routes form-level (absolute path length 0)
893
- // entries to the empty-string bucket at storage time.
881
+ // Adapter-side paths stay schema-RELATIVE: the validation pipeline
882
+ // in `core/create-form-store.ts` prepends the parent path to
883
+ // absolutise, then routes form-level entries, those whose absolute
884
+ // path is empty, to the empty-string bucket at storage time.
894
885
  path: coercePathSegments(issue.path),
895
886
  code
896
887
  });
@@ -922,10 +913,10 @@ function unwrapStructuralLeafV3(schema) {
922
913
  return current;
923
914
  }
924
915
  function isStructuralV3Kind(schema) {
925
- return isZodSchemaType(schema, "ZodObject") || isZodSchemaType(schema, "ZodArray") || isZodSchemaType(schema, "ZodRecord") || isZodSchemaType(schema, "ZodTuple") || isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion") || // Wrappers that themselves resolve to a structural type — keep
926
- // peeling at the next iteration.
927
- isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodEffects") || // Newer transparent wrappers (v3.23+). Each wraps a single inner
928
- // schema with no structural impact — `peelV3Wrappers` resolves them.
916
+ return isZodSchemaType(schema, "ZodObject") || isZodSchemaType(schema, "ZodArray") || isZodSchemaType(schema, "ZodRecord") || isZodSchemaType(schema, "ZodTuple") || isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion") || // Wrappers that themselves resolve to a structural type; keep
917
+ // peeling next iteration.
918
+ isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodEffects") || // Newer transparent wrappers (v3.23+), each wrapping one inner
919
+ // schema with no structural impact. `peelV3Wrappers` resolves them.
929
920
  isZodSchemaType(schema, "ZodPipeline") || isZodSchemaType(schema, "ZodReadonly") || isZodSchemaType(schema, "ZodBranded");
930
921
  }
931
922
  function peelV3Wrappers(schema) {
@@ -1077,16 +1068,8 @@ function peelAllV3Wrappers(schema) {
1077
1068
  }
1078
1069
  return current;
1079
1070
  }
1080
- function getDefaultValuesFromZodSchema(formSchema, useDefaultSchemaValues, formKey) {
1081
- return deriveDefaultWalk(formSchema, useDefaultSchemaValues, V3_INTROSPECTOR, 64, {
1082
- unsupportedKindFallback: (schema) => {
1083
- const kindName = schema.constructor?.name ?? "unknown";
1084
- console.warn(
1085
- `[attaform] AF13 attaform.dev/e/af13 '${kindName}' on '${formKey}'`
1086
- );
1087
- return null;
1088
- }
1089
- });
1071
+ function getDefaultValuesFromZodSchema(formSchema, useDefaultSchemaValues) {
1072
+ return deriveDefaultWalk(formSchema, useDefaultSchemaValues, V3_INTROSPECTOR, 64);
1090
1073
  }
1091
1074
  function resolveFieldMetaAtPathV3(rootSchema, path, maxRecursionDepth) {
1092
1075
  const lastSegment = path.length === 0 ? "" : path[path.length - 1];
@@ -1117,92 +1100,51 @@ function resolveFieldMetaAtPathV3(rootSchema, path, maxRecursionDepth) {
1117
1100
  meta: Object.freeze({ ...payload ?? {} })
1118
1101
  };
1119
1102
  }
1120
- function runStrictGetDefaultsV3(rootSchema, config, formKey, maxRecursionDepth) {
1103
+ function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
1121
1104
  const defaultValuesWithoutConstraints = getDefaultValuesFromZodSchema(
1122
1105
  rootSchema,
1123
- config.useDefaultSchemaValues,
1124
- formKey
1106
+ config.useDefaultSchemaValues
1125
1107
  );
1126
- const rawDefaultValues = mergeDeep(defaultValuesWithoutConstraints, config.constraints);
1127
- if ((config.strict ?? true) !== false) {
1128
- if (containsAsyncTransform(rootSchema)) {
1129
- return {
1130
- data: rawDefaultValues,
1131
- errors: void 0,
1132
- success: true,
1133
- formKey
1134
- };
1135
- }
1136
- try {
1137
- const strictResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
1138
- if (strictResult.success) {
1139
- return {
1140
- data: rawDefaultValues,
1141
- errors: void 0,
1142
- success: true,
1143
- formKey
1144
- };
1145
- }
1146
- return {
1147
- data: rawDefaultValues,
1148
- errors: zodIssuesToValidationErrors(strictResult.error.issues),
1149
- success: false,
1150
- formKey
1151
- };
1152
- } catch (err) {
1153
- const isAsyncDetect = err instanceof Error && err.message.includes("Async refinement encountered");
1154
- if (isAsyncDetect) {
1155
- try {
1156
- const strippedResult = syncSafe(stripAsyncChecks(rootSchema)).safeParse(rawDefaultValues);
1157
- if (strippedResult.success) {
1158
- return {
1159
- data: rawDefaultValues,
1160
- errors: void 0,
1161
- success: true,
1162
- formKey
1163
- };
1164
- }
1165
- return {
1166
- data: rawDefaultValues,
1167
- errors: zodIssuesToValidationErrors(strippedResult.error.issues),
1168
- success: false,
1169
- formKey
1170
- };
1171
- } catch {
1172
- return {
1173
- data: rawDefaultValues,
1174
- errors: void 0,
1175
- success: true,
1176
- formKey
1177
- };
1178
- }
1179
- }
1180
- return {
1181
- data: rawDefaultValues,
1182
- errors: void 0,
1183
- success: true,
1184
- formKey
1185
- };
1186
- }
1187
- }
1188
- const fixed = fixStructuralDefaults(
1108
+ const rawDefaultValues = config.constraints === void 0 ? defaultValuesWithoutConstraints : fixStructuralDefaults(
1189
1109
  rootSchema,
1190
- rawDefaultValues,
1110
+ mergeDeep(defaultValuesWithoutConstraints, config.constraints),
1191
1111
  config.useDefaultSchemaValues,
1192
1112
  maxRecursionDepth,
1193
1113
  {
1194
1114
  intro: V3_INTROSPECTOR,
1195
1115
  slimPrimitivesOf: (s) => slimPrimitivesV3(s),
1196
- deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault, formKey),
1116
+ deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault),
1197
1117
  unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
1198
1118
  }
1199
- );
1200
- return {
1201
- data: fixed.data,
1202
- errors: void 0,
1203
- success: true,
1204
- formKey
1205
- };
1119
+ ).data;
1120
+ if (containsAsyncTransform(rootSchema)) {
1121
+ return {
1122
+ data: rawDefaultValues,
1123
+ errors: void 0,
1124
+ success: true
1125
+ };
1126
+ }
1127
+ try {
1128
+ const parseResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
1129
+ if (parseResult.success) {
1130
+ return {
1131
+ data: rawDefaultValues,
1132
+ errors: void 0,
1133
+ success: true
1134
+ };
1135
+ }
1136
+ return {
1137
+ data: rawDefaultValues,
1138
+ errors: zodIssuesToValidationErrors(parseResult.error.issues),
1139
+ success: false
1140
+ };
1141
+ } catch {
1142
+ return {
1143
+ data: rawDefaultValues,
1144
+ errors: void 0,
1145
+ success: true
1146
+ };
1147
+ }
1206
1148
  }
1207
1149
 
1208
1150
  function useForm(configuration) {
@@ -0,0 +1,42 @@
1
+ import { App } from 'vue';
2
+ import { ao as RegisterModelDynamicCustomDirective } from './attaform.Br8EBn5B.mjs';
3
+
4
+ /**
5
+ * The `v-register` directive. Bind a form field to a native input, select,
6
+ * textarea, checkbox or radio:
7
+ *
8
+ * ```vue
9
+ * <input v-register="form.register('email')" />
10
+ * <select v-register="form.register('country')">
11
+ * <option value="us">US</option>
12
+ * <option value="uk">UK</option>
13
+ * </select>
14
+ * ```
15
+ *
16
+ * The binding strategy follows the element's `tagName` and `type`. Delivered by
17
+ * the Vite and Nuxt plugins' compile-time binding, or by
18
+ * `installVRegister(app)` everywhere else. Most consumers never import it
19
+ * directly; it is exposed for integrations that wire directives by hand.
20
+ */
21
+ declare const vRegister: RegisterModelDynamicCustomDirective;
22
+ /**
23
+ * Register the `v-register` directive app-wide. The one-line setup for an app
24
+ * whose templates are compiled without Attaform's Vite or Nuxt plugin: a
25
+ * webpack-family bundler, a no-build page, or runtime-compiled templates.
26
+ *
27
+ * ```ts
28
+ * import { createApp } from 'vue'
29
+ * import { installVRegister } from 'attaform/directive'
30
+ *
31
+ * const app = createApp(App)
32
+ * installVRegister(app)
33
+ * ```
34
+ *
35
+ * Vite and Nuxt consumers do not call this; their build plugin binds each
36
+ * template's `v-register` at compile time. Idempotent: a second call for the
37
+ * same app is a no-op, and a directive the consumer registered under the same
38
+ * name is left in place.
39
+ */
40
+ declare function installVRegister(app: App): void;
41
+
42
+ export { installVRegister as i, vRegister as v };
@@ -1,4 +1,4 @@
1
- import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform.CZYt_5N_.mjs';
1
+ import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform.CdZIEf7_.mjs';
2
2
  import { shallowReactive, getCurrentInstance, inject } from 'vue';
3
3
 
4
4
  function detectSSR(options = {}) {
@@ -17,7 +17,6 @@ const kFormContext = /* @__PURE__ */ Symbol.for("attaform:form-context");
17
17
  const kFormInstanceId = /* @__PURE__ */ Symbol.for("attaform:form-instance-id");
18
18
  function createRegistry(options = {}) {
19
19
  const ssr = detectSSR(options);
20
- const defaults = Object.freeze({ ...options.defaults ?? {} });
21
20
  const forms = shallowReactive(/* @__PURE__ */ new Map());
22
21
  const wizards = shallowReactive(/* @__PURE__ */ new Map());
23
22
  const pendingHydration = shallowReactive(/* @__PURE__ */ new Map());
@@ -102,7 +101,6 @@ function createRegistry(options = {}) {
102
101
  wizards,
103
102
  pendingHydration,
104
103
  ssr,
105
- defaults,
106
104
  trackConsumer,
107
105
  trackWizardConsumer,
108
106
  enqueuePrefetch,
@@ -756,9 +756,9 @@ function injectPreamble(element, captured) {
756
756
  ),
757
757
  exp,
758
758
  modifiers: [],
759
- // Reuse the host element's source location so any runtime error
760
- // in the synthesized expression points at the consumer's template
761
- // line, not at the dummyLoc that pre-fix was line 0.
759
+ // The host element's source location, so a runtime error in the
760
+ // synthesized expression points at the consumer's template line
761
+ // rather than at line 0.
762
762
  loc: element.loc
763
763
  };
764
764
  element.props.unshift(directive);