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.
- package/dist/abstract.d.mts +15 -21
- package/dist/abstract.mjs +4 -4
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/dev-key-collision-warnings.mjs +47 -8
- package/dist/dev/chunks/devtools.mjs +2 -2
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +3 -3
- package/dist/dev/shared/{attaform-dev.BO-71R54.mjs → attaform-dev.BJK1kqHY.mjs} +44 -198
- package/dist/dev/shared/{attaform-dev.D8aoKb89.mjs → attaform-dev.BMQ3GcgD.mjs} +51 -64
- package/dist/dev/shared/{attaform-dev.BgM6FdtA.mjs → attaform-dev.BUIFcTYf.mjs} +94 -62
- package/dist/dev/shared/{attaform-dev.q6UutkCx.mjs → attaform-dev.CT7MDjPy.mjs} +92 -152
- package/dist/dev/shared/{attaform-dev.ButTkwHd.mjs → attaform-dev.CZz4GYZ6.mjs} +26 -15
- package/dist/dev/shared/{attaform-dev.DD5m2W51.mjs → attaform-dev.Chm4D6SJ.mjs} +2 -4
- package/dist/dev/shared/{attaform-dev.DrzObAZo.mjs → attaform-dev.DuEE4GU1.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.DHuydLAC.mjs → attaform-dev.DxHdkkPG.mjs} +674 -734
- package/dist/dev/shared/{attaform-dev.A-TpJW0B.mjs → attaform-dev.zlvDr0WB.mjs} +3 -21
- package/dist/dev/zod-v3.mjs +6 -6
- package/dist/dev/zod-v4.mjs +6 -6
- package/dist/dev/zod.mjs +5 -5
- package/dist/directive.d.mts +4 -4
- package/dist/directive.mjs +1 -1
- package/dist/esbuild.d.mts +11 -0
- package/dist/esbuild.mjs +1 -1
- package/dist/history.d.mts +3 -32
- package/dist/history.mjs +1 -2
- package/dist/index.d.mts +67 -70
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.mts +6 -14
- package/dist/nuxt.mjs +3 -7
- package/dist/rollup.d.mts +11 -0
- package/dist/rollup.mjs +1 -1
- package/dist/rspack.d.mts +19 -11
- package/dist/rspack.mjs +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +12 -12
- package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/shared/{attaform.CIWLMY-R.d.mts → attaform.2FslhB9R.d.mts} +83 -95
- package/dist/shared/{attaform.Cvao8bW5.mjs → attaform.8mfKZCwH.mjs} +7 -7
- package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
- package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
- package/dist/shared/{attaform.BndjUUYX.mjs → attaform.B2iebkPA.mjs} +4 -4
- package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
- package/dist/shared/{attaform.CZMAYwSK.mjs → attaform.BIWicztt.mjs} +651 -678
- package/dist/shared/attaform.BcQwgWaq.d.mts +2153 -0
- package/dist/shared/attaform.Br8EBn5B.d.mts +4553 -0
- package/dist/shared/{attaform.C2MVyuxC.mjs → attaform.CO918TdU.mjs} +44 -198
- package/dist/shared/{attaform.CZYt_5N_.mjs → attaform.CdZIEf7_.mjs} +1 -19
- package/dist/shared/{attaform.B0dKL8ST.mjs → attaform.DRsANMok.mjs} +94 -62
- package/dist/shared/{attaform.DffRL5pP.mjs → attaform.D_f1WgYf.mjs} +46 -59
- package/dist/shared/{attaform.D1fnTifF.mjs → attaform.D_pt1gOj.mjs} +92 -150
- package/dist/shared/attaform.L0kUn3vL.d.mts +42 -0
- package/dist/shared/{attaform.D0x-qSXm.mjs → attaform.WiGdIqgx.mjs} +1 -3
- package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.ZYn2ahzJ.mjs} +3 -3
- package/dist/transforms.d.mts +153 -26
- package/dist/transforms.mjs +1 -1
- package/dist/vite.d.mts +29 -52
- package/dist/vite.mjs +8 -3
- package/dist/webpack.d.mts +20 -12
- package/dist/webpack.mjs +1 -1
- package/dist/zod-v3.d.mts +90 -96
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +119 -119
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +5 -5
- package/dist/zod.mjs +5 -5
- package/package.json +9 -7
- package/skills/attaform/SKILL.md +1 -1
- package/skills/attaform/references/custom-components.md +1 -1
- package/dist/chunks/fingerprint.mjs +0 -183
- package/dist/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/chunks/fingerprint.mjs +0 -183
- package/dist/dev/chunks/fingerprint2.mjs +0 -159
- package/dist/dev/shared/attaform-dev.BxfsuwBR.mjs +0 -44
- package/dist/shared/attaform.BxfsuwBR.mjs +0 -44
- package/dist/shared/attaform.CsoeRi3P.d.mts +0 -5155
- package/dist/shared/attaform.DDtqHYv1.d.mts +0 -2465
- 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,
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform.
|
|
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
|
-
|
|
132
|
-
return def?.options ?? [];
|
|
136
|
+
return readOptionList(readDef(schema)?.options);
|
|
133
137
|
}
|
|
134
138
|
function getDiscriminatedOptions(schema) {
|
|
135
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 (
|
|
798
|
+
return (_formKey, options) => sharedV3Schemas(
|
|
801
799
|
zodSchema,
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
800
|
+
options.maxRecursionDepth,
|
|
801
|
+
() => createAbstractSchema(
|
|
802
|
+
zodSchema,
|
|
803
|
+
V3_INTROSPECTOR,
|
|
804
|
+
buildV3Services(options.maxRecursionDepth),
|
|
805
|
+
options
|
|
806
|
+
)
|
|
806
807
|
);
|
|
807
808
|
}
|
|
808
|
-
|
|
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
|
-
//
|
|
835
|
-
// slim
|
|
836
|
-
//
|
|
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
|
|
844
|
-
|
|
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
|
-
//
|
|
860
|
-
//
|
|
861
|
-
//
|
|
862
|
-
//
|
|
863
|
-
makeSubSchema: (sub,
|
|
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)[]`
|
|
884
|
-
//
|
|
885
|
-
//
|
|
886
|
-
//
|
|
887
|
-
//
|
|
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-
|
|
891
|
-
//
|
|
892
|
-
//
|
|
893
|
-
//
|
|
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
|
|
926
|
-
// peeling
|
|
927
|
-
isZodSchemaType(schema, "ZodOptional") || isZodSchemaType(schema, "ZodNullable") || isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodEffects") || // Newer transparent wrappers (v3.23+)
|
|
928
|
-
// schema with no structural impact
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
|
1116
|
+
deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault),
|
|
1197
1117
|
unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
|
|
1198
1118
|
}
|
|
1199
|
-
);
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
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.
|
|
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
|
-
//
|
|
760
|
-
//
|
|
761
|
-
//
|
|
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);
|