attaform 0.29.0 → 0.30.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.
- package/dist/abstract.d.mts +5 -5
- 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 +1 -1
- 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.BK6Ge2qR.mjs} +34 -188
- package/dist/dev/shared/{attaform-dev.A-TpJW0B.mjs → attaform-dev.BQc5QV3Y.mjs} +1 -19
- package/dist/dev/shared/{attaform-dev.DrzObAZo.mjs → attaform-dev.BcNtyOmf.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.ButTkwHd.mjs → attaform-dev.BcYT6tFh.mjs} +7 -8
- package/dist/dev/shared/{attaform-dev.BgM6FdtA.mjs → attaform-dev.BisFstxh.mjs} +91 -59
- package/dist/dev/shared/{attaform-dev.DHuydLAC.mjs → attaform-dev.CQ2rJiAX.mjs} +560 -631
- package/dist/dev/shared/{attaform-dev.D8aoKb89.mjs → attaform-dev.D6CLvaQT.mjs} +8 -8
- package/dist/dev/shared/{attaform-dev.q6UutkCx.mjs → attaform-dev.DTrHonpc.mjs} +69 -120
- package/dist/dev/shared/{attaform-dev.DD5m2W51.mjs → attaform-dev.DUZckyV8.mjs} +1 -3
- 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 +2 -2
- package/dist/directive.mjs +1 -1
- package/dist/history.d.mts +1 -1
- package/dist/history.mjs +1 -2
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.mts +2 -11
- package/dist/nuxt.mjs +0 -1
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/shared/{attaform.DffRL5pP.mjs → attaform.B3resMQ1.mjs} +8 -8
- package/dist/shared/{attaform.Cvao8bW5.mjs → attaform.BRDDQeHV.mjs} +6 -6
- package/dist/shared/{attaform.C2MVyuxC.mjs → attaform.BXneBxEj.mjs} +34 -188
- package/dist/shared/{attaform.BndjUUYX.mjs → attaform.ByWP6kSx.mjs} +4 -4
- package/dist/shared/{attaform.D1fnTifF.mjs → attaform.CJ8DpRGj.mjs} +69 -120
- package/dist/shared/{attaform.B0dKL8ST.mjs → attaform.CUfrMK7t.mjs} +91 -59
- package/dist/shared/{attaform.CZYt_5N_.mjs → attaform.CdZIEf7_.mjs} +1 -19
- package/dist/shared/{attaform.axHXVQO7.d.mts → attaform.Clz0ArIi.d.mts} +1 -1
- package/dist/shared/{attaform.CZMAYwSK.mjs → attaform.DNJOWjQw.mjs} +559 -588
- package/dist/shared/{attaform.CIWLMY-R.d.mts → attaform.Rc9u4Vfw.d.mts} +1 -1
- package/dist/shared/{attaform.DDtqHYv1.d.mts → attaform.UGyOK83T.d.mts} +115 -214
- package/dist/shared/{attaform.D0x-qSXm.mjs → attaform.WiGdIqgx.mjs} +1 -3
- package/dist/shared/{attaform.CsoeRi3P.d.mts → attaform.bKLzMU0o.d.mts} +99 -493
- package/dist/vite.mjs +5 -0
- package/dist/zod-v3.d.mts +4 -4
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +9 -9
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +5 -5
- package/package.json +3 -2
- 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
|
@@ -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 callConsumerSchemaFn } from './attaform.
|
|
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.CUfrMK7t.mjs';
|
|
2
|
+
import { h as getAtPath, j as humanize, c as useAbstractForm } from './attaform.DNJOWjQw.mjs';
|
|
3
|
+
import { c as callConsumerSchemaFn } from './attaform.BRDDQeHV.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;
|
|
@@ -301,10 +308,6 @@ function unwrapLazy(schema) {
|
|
|
301
308
|
if (typeof getter !== "function") return void 0;
|
|
302
309
|
return callConsumerSchemaFn(() => getter(), void 0);
|
|
303
310
|
}
|
|
304
|
-
function getLazyGetter(schema) {
|
|
305
|
-
const def = readDef(schema);
|
|
306
|
-
return typeof def?.getter === "function" ? def.getter : void 0;
|
|
307
|
-
}
|
|
308
311
|
function getLiteralValues(schema) {
|
|
309
312
|
const def = readDef(schema);
|
|
310
313
|
const v = def?.value;
|
|
@@ -445,7 +448,6 @@ const V3_INTROSPECTOR = {
|
|
|
445
448
|
// Walker accessors (D2 / D3 / D5).
|
|
446
449
|
getArrayElement,
|
|
447
450
|
getSetValueType,
|
|
448
|
-
getRecordKeyType,
|
|
449
451
|
getRecordValueType,
|
|
450
452
|
getMapKeyType: (schema) => kindOf(schema) === "map" ? getMapKeyType(schema) : void 0,
|
|
451
453
|
getMapValueType: (schema) => kindOf(schema) === "map" ? getMapValueType(schema) : void 0,
|
|
@@ -463,7 +465,6 @@ const V3_INTROSPECTOR = {
|
|
|
463
465
|
unwrapPipeIn,
|
|
464
466
|
unwrapPipeOut,
|
|
465
467
|
unwrapLazy,
|
|
466
|
-
getLazyGetter,
|
|
467
468
|
getDefaultValue,
|
|
468
469
|
getCatchDefault,
|
|
469
470
|
hasCatchValue
|
|
@@ -599,22 +600,22 @@ function rebuildDiscriminatedUnion(original, options) {
|
|
|
599
600
|
if (replacement !== void 0) optionsMap.set(value, replacement);
|
|
600
601
|
}
|
|
601
602
|
}
|
|
603
|
+
if (discriminatedOptionsAreMapped(original)) {
|
|
604
|
+
return rebuildWithDef(original, { options: optionsMap });
|
|
605
|
+
}
|
|
602
606
|
return rebuildWithDef(original, { options, optionsMap });
|
|
603
607
|
}
|
|
604
608
|
function rebuildEffects(original, source, effect) {
|
|
605
609
|
return rebuildWithDef(original, { schema: source, effect });
|
|
606
610
|
}
|
|
607
611
|
|
|
608
|
-
function stripAsyncChecks(schema) {
|
|
609
|
-
return walkEffects(schema, "strip");
|
|
610
|
-
}
|
|
611
612
|
function wrapAsyncSafeRefinements(schema) {
|
|
612
|
-
return walkEffects(schema
|
|
613
|
+
return walkEffects(schema);
|
|
613
614
|
}
|
|
614
615
|
function isThenable(value) {
|
|
615
616
|
return value !== null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
616
617
|
}
|
|
617
|
-
function walkEffects(schema
|
|
618
|
+
function walkEffects(schema) {
|
|
618
619
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
619
620
|
function recurse(s) {
|
|
620
621
|
const candidate = s;
|
|
@@ -624,7 +625,6 @@ function walkEffects(schema, policy) {
|
|
|
624
625
|
if (isZodSchemaType(s, "ZodEffects")) {
|
|
625
626
|
const inner = unwrapEffectsSource(s);
|
|
626
627
|
if (inner === void 0) return s;
|
|
627
|
-
if (policy === "strip") return recurse(inner);
|
|
628
628
|
const effect = getEffect(s);
|
|
629
629
|
const rebuiltInner = recurse(inner);
|
|
630
630
|
const original = effect?.["refinement"];
|
|
@@ -797,18 +797,18 @@ function zodAdapter(zodSchema) {
|
|
|
797
797
|
`[attaform] AF15 attaform.dev/e/af15 '${name}'`
|
|
798
798
|
);
|
|
799
799
|
}
|
|
800
|
-
return (
|
|
800
|
+
return (_formKey, options) => sharedV3Schemas(
|
|
801
801
|
zodSchema,
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
802
|
+
options.maxRecursionDepth,
|
|
803
|
+
() => createAbstractSchema(
|
|
804
|
+
zodSchema,
|
|
805
|
+
V3_INTROSPECTOR,
|
|
806
|
+
buildV3Services(options.maxRecursionDepth),
|
|
807
|
+
options
|
|
808
|
+
)
|
|
806
809
|
);
|
|
807
810
|
}
|
|
808
|
-
|
|
809
|
-
const { fingerprintZodSchema } = await import('../chunks/fingerprint.mjs');
|
|
810
|
-
return fingerprintZodSchema(schema);
|
|
811
|
-
}
|
|
811
|
+
const sharedV3Schemas = createSharedSchemaStore();
|
|
812
812
|
const syncSafeCache = /* @__PURE__ */ new WeakMap();
|
|
813
813
|
function syncSafe(schema) {
|
|
814
814
|
const cached = syncSafeCache.get(schema);
|
|
@@ -829,7 +829,6 @@ function buildV3Services(maxRecursionDepth) {
|
|
|
829
829
|
return normalizeIssuePaths(issues, schema, data, maxRecursionDepth, peelAllV3Wrappers);
|
|
830
830
|
};
|
|
831
831
|
return {
|
|
832
|
-
fingerprint: (schema) => lazyFingerprint(schema),
|
|
833
832
|
getNestedSchemasAtPath: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
|
|
834
833
|
// v3 pre-strips refinements / defaults / wrappers off the root for
|
|
835
834
|
// slim-mode walks — `getSlimPrimitiveTypesAtPath` and
|
|
@@ -840,8 +839,8 @@ function buildV3Services(maxRecursionDepth) {
|
|
|
840
839
|
// unstripped walks coincide — same aliasing v4 always had.
|
|
841
840
|
getNestedSchemasInSlimMode: (schema, path, maxRecursionDepth2) => getNestedZodSchemasAtPath(schema, path, maxRecursionDepth2),
|
|
842
841
|
slimPrimitivesOf: (schema, _maxRecursionDepth) => slimPrimitivesV3(schema),
|
|
843
|
-
deriveDefault: (schema, useDefault
|
|
844
|
-
|
|
842
|
+
deriveDefault: (schema, useDefault) => getDefaultValuesFromZodSchema(schema, useDefault),
|
|
843
|
+
runGetDefaults: (schema, config, maxRecursionDepth2) => runGetDefaultsV3(schema, config, maxRecursionDepth2),
|
|
845
844
|
unwrapStructuralWrappers: (schema) => unwrapStructuralLeafV3(schema),
|
|
846
845
|
unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
|
|
847
846
|
peelAllWrappers: (schema) => peelAllV3Wrappers(schema),
|
|
@@ -860,11 +859,10 @@ function buildV3Services(maxRecursionDepth) {
|
|
|
860
859
|
// historical shape) — `getSchemasAtPath` consumers may probe any
|
|
861
860
|
// method on the result. The factory call rebuilds the full surface
|
|
862
861
|
// against the sub-schema with its own per-form caches.
|
|
863
|
-
makeSubSchema: (sub,
|
|
862
|
+
makeSubSchema: (sub, maxRecursionDepth2) => createAbstractSchema(
|
|
864
863
|
sub,
|
|
865
864
|
V3_INTROSPECTOR,
|
|
866
865
|
buildV3Services(maxRecursionDepth2),
|
|
867
|
-
formKey,
|
|
868
866
|
{ maxRecursionDepth: maxRecursionDepth2 }
|
|
869
867
|
)
|
|
870
868
|
};
|
|
@@ -1077,16 +1075,8 @@ function peelAllV3Wrappers(schema) {
|
|
|
1077
1075
|
}
|
|
1078
1076
|
return current;
|
|
1079
1077
|
}
|
|
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
|
-
});
|
|
1078
|
+
function getDefaultValuesFromZodSchema(formSchema, useDefaultSchemaValues) {
|
|
1079
|
+
return deriveDefaultWalk(formSchema, useDefaultSchemaValues, V3_INTROSPECTOR, 64);
|
|
1090
1080
|
}
|
|
1091
1081
|
function resolveFieldMetaAtPathV3(rootSchema, path, maxRecursionDepth) {
|
|
1092
1082
|
const lastSegment = path.length === 0 ? "" : path[path.length - 1];
|
|
@@ -1117,92 +1107,51 @@ function resolveFieldMetaAtPathV3(rootSchema, path, maxRecursionDepth) {
|
|
|
1117
1107
|
meta: Object.freeze({ ...payload ?? {} })
|
|
1118
1108
|
};
|
|
1119
1109
|
}
|
|
1120
|
-
function
|
|
1110
|
+
function runGetDefaultsV3(rootSchema, config, maxRecursionDepth) {
|
|
1121
1111
|
const defaultValuesWithoutConstraints = getDefaultValuesFromZodSchema(
|
|
1122
1112
|
rootSchema,
|
|
1123
|
-
config.useDefaultSchemaValues
|
|
1124
|
-
formKey
|
|
1113
|
+
config.useDefaultSchemaValues
|
|
1125
1114
|
);
|
|
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(
|
|
1115
|
+
const rawDefaultValues = config.constraints === void 0 ? defaultValuesWithoutConstraints : fixStructuralDefaults(
|
|
1189
1116
|
rootSchema,
|
|
1190
|
-
|
|
1117
|
+
mergeDeep(defaultValuesWithoutConstraints, config.constraints),
|
|
1191
1118
|
config.useDefaultSchemaValues,
|
|
1192
1119
|
maxRecursionDepth,
|
|
1193
1120
|
{
|
|
1194
1121
|
intro: V3_INTROSPECTOR,
|
|
1195
1122
|
slimPrimitivesOf: (s) => slimPrimitivesV3(s),
|
|
1196
|
-
deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault
|
|
1123
|
+
deriveDefault: (s, useDefault) => getDefaultValuesFromZodSchema(s, useDefault),
|
|
1197
1124
|
unwrapToDiscriminatedUnion: (s) => unwrapToDiscriminatedUnion(s)
|
|
1198
1125
|
}
|
|
1199
|
-
);
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1126
|
+
).data;
|
|
1127
|
+
if (containsAsyncTransform(rootSchema)) {
|
|
1128
|
+
return {
|
|
1129
|
+
data: rawDefaultValues,
|
|
1130
|
+
errors: void 0,
|
|
1131
|
+
success: true
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
try {
|
|
1135
|
+
const parseResult = syncSafe(rootSchema).safeParse(rawDefaultValues);
|
|
1136
|
+
if (parseResult.success) {
|
|
1137
|
+
return {
|
|
1138
|
+
data: rawDefaultValues,
|
|
1139
|
+
errors: void 0,
|
|
1140
|
+
success: true
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
return {
|
|
1144
|
+
data: rawDefaultValues,
|
|
1145
|
+
errors: zodIssuesToValidationErrors(parseResult.error.issues),
|
|
1146
|
+
success: false
|
|
1147
|
+
};
|
|
1148
|
+
} catch {
|
|
1149
|
+
return {
|
|
1150
|
+
data: rawDefaultValues,
|
|
1151
|
+
errors: void 0,
|
|
1152
|
+
success: true
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1206
1155
|
}
|
|
1207
1156
|
|
|
1208
1157
|
function useForm(configuration) {
|