attaform 0.30.1 → 0.31.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 +5 -5
- package/dist/abstract.mjs +4 -4
- package/dist/dev/abstract.mjs +4 -4
- package/dist/dev/chunks/devtools.mjs +3 -3
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +15 -2
- package/dist/dev/index.mjs +5 -5
- package/dist/dev/runtime/plugins/attaform.mjs +1 -1
- package/dist/dev/shared/{attaform-dev.zlvDr0WB.mjs → attaform-dev.04aupFBW.mjs} +3 -2
- package/dist/dev/shared/{attaform-dev.DxHdkkPG.mjs → attaform-dev.3uTCYwy8.mjs} +770 -254
- package/dist/dev/shared/{attaform-dev.BJK1kqHY.mjs → attaform-dev.BpVGFSFa.mjs} +88 -115
- package/dist/dev/shared/{attaform-dev.Chm4D6SJ.mjs → attaform-dev.Bu6wgrA5.mjs} +3 -3
- package/dist/dev/shared/{attaform-dev.BMQ3GcgD.mjs → attaform-dev.Cbx0AiQF.mjs} +476 -337
- package/dist/dev/shared/attaform-dev.CwYTWyPX.mjs +120 -0
- package/dist/dev/shared/{attaform-dev.DuEE4GU1.mjs → attaform-dev.D7lKyM_7.mjs} +4 -4
- package/dist/dev/shared/{attaform-dev.CT7MDjPy.mjs → attaform-dev.OceE0X3v.mjs} +154 -229
- package/dist/{shared/attaform.DRsANMok.mjs → dev/shared/attaform-dev.PTGM9KE1.mjs} +16 -15
- package/dist/{shared/attaform.8mfKZCwH.mjs → dev/shared/attaform-dev.n6n00owJ.mjs} +49 -128
- 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 +15 -2
- package/dist/index.d.mts +16 -55
- package/dist/index.mjs +5 -5
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +3 -3
- package/dist/runtime/plugins/attaform.mjs +1 -1
- package/dist/shared/{attaform.CO918TdU.mjs → attaform.B5b-HmhH.mjs} +88 -115
- package/dist/shared/{attaform.2FslhB9R.d.mts → attaform.B9PYKlhB.d.mts} +43 -19
- package/dist/shared/{attaform.D_f1WgYf.mjs → attaform.BPMOl562.mjs} +458 -319
- package/dist/{dev/shared/attaform-dev.CZz4GYZ6.mjs → shared/attaform.BPSqtU7a.mjs} +44 -156
- package/dist/shared/{attaform.CdZIEf7_.mjs → attaform.BhtAZysa.mjs} +3 -2
- package/dist/shared/{attaform.BcQwgWaq.d.mts → attaform.CYlF4P6X.d.mts} +58 -17
- package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.CdA9bfRv.mjs} +3 -3
- package/dist/shared/{attaform.BIWicztt.mjs → attaform.DAf4ehIe.mjs} +765 -251
- package/dist/shared/{attaform.ZYn2ahzJ.mjs → attaform.DBCbxlyk.mjs} +59 -1
- package/dist/shared/{attaform.L0kUn3vL.d.mts → attaform.DZOynI6c.d.mts} +1 -1
- package/dist/shared/{attaform.B2iebkPA.mjs → attaform.KEfNRDot.mjs} +4 -4
- package/dist/shared/attaform._1Zp3mDG.mjs +96 -0
- package/dist/shared/{attaform.Br8EBn5B.d.mts → attaform.i13OEHJF.d.mts} +195 -38
- package/dist/{dev/shared/attaform-dev.BUIFcTYf.mjs → shared/attaform.j9xI_ObC.mjs} +16 -15
- package/dist/shared/{attaform.D_pt1gOj.mjs → attaform.u6jfHoed.mjs} +154 -229
- package/dist/transforms.mjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/zod-v3.d.mts +4 -4
- package/dist/zod-v3.mjs +6 -6
- package/dist/zod-v4.d.mts +22 -16
- package/dist/zod-v4.mjs +6 -6
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +5 -5
- package/package.json +2 -1
- package/skills/attaform/SKILL.md +2 -1
- package/skills/attaform/references/custom-components.md +4 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { j as humanize, c as useAbstractForm } from './attaform-dev.
|
|
2
|
-
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.
|
|
3
|
-
import { s as slimPrimitivesWalk, d as deriveDefaultWalk, m as mergeDeep, f as fixStructuralDefaults, w as walkPathSegments, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, e as getFieldMetaListForSchema, g as getFieldMetaForSchema } from './attaform-dev.
|
|
4
|
-
import {
|
|
1
|
+
import { j as humanize, c as useAbstractForm } from './attaform-dev.3uTCYwy8.mjs';
|
|
2
|
+
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.04aupFBW.mjs';
|
|
3
|
+
import { s as slimPrimitivesWalk, d as deriveDefaultWalk, m as mergeDeep, f as fixStructuralDefaults, w as walkPathSegments, c as createAbstractSchema, a as createSharedSchemaStore, b as buildFieldMetaPathMap, e as getFieldMetaListForSchema, g as getFieldMetaForSchema } from './attaform-dev.PTGM9KE1.mjs';
|
|
4
|
+
import { d as callConsumerFn } from './attaform-dev.CwYTWyPX.mjs';
|
|
5
5
|
|
|
6
6
|
function readDef(schema) {
|
|
7
7
|
if (schema === null || typeof schema !== "object") return void 0;
|
|
@@ -119,9 +119,7 @@ function isCoercePrimitive(schema) {
|
|
|
119
119
|
return readDef(schema)?.coerce === true;
|
|
120
120
|
}
|
|
121
121
|
function isPreprocessNode(schema) {
|
|
122
|
-
|
|
123
|
-
const pipeIn = unwrapPipeIn(schema);
|
|
124
|
-
return pipeIn !== void 0 && kindOf(pipeIn) === "transform";
|
|
122
|
+
return kindOf(schema) === "pipe" && kindOf(readDef(schema)?.in) === "transform";
|
|
125
123
|
}
|
|
126
124
|
function unwrapPipeOut(schema) {
|
|
127
125
|
const def = readDef(schema);
|
|
@@ -183,6 +181,9 @@ function getDiscriminatedOptions(schema) {
|
|
|
183
181
|
return Array.isArray(options) ? options : [];
|
|
184
182
|
}
|
|
185
183
|
function assertZodVersion(schema) {
|
|
184
|
+
assertZodV4Node(schema);
|
|
185
|
+
}
|
|
186
|
+
function assertZodV4Node(schema) {
|
|
186
187
|
const def = readDef(schema);
|
|
187
188
|
if (def?.type === void 0) {
|
|
188
189
|
throw new Error(
|
|
@@ -202,60 +203,6 @@ const DESCEND_SINGLE = [
|
|
|
202
203
|
];
|
|
203
204
|
const DESCEND_RECORD = ["shape", "entries"];
|
|
204
205
|
const DESCEND_LIST = ["options", "items"];
|
|
205
|
-
function walkSchemaTree(schema, visit, seen) {
|
|
206
|
-
const visited = seen ?? /* @__PURE__ */ new WeakSet();
|
|
207
|
-
const candidate = schema;
|
|
208
|
-
if (typeof candidate !== "object" || candidate === null) return false;
|
|
209
|
-
if (visited.has(candidate)) return false;
|
|
210
|
-
visited.add(candidate);
|
|
211
|
-
if (visit(schema)) return true;
|
|
212
|
-
const def = readDef(schema);
|
|
213
|
-
if (def === void 0) return false;
|
|
214
|
-
const slots = def;
|
|
215
|
-
for (const key of DESCEND_SINGLE) {
|
|
216
|
-
const child = slots[key];
|
|
217
|
-
if (child !== void 0 && walkSchemaTree(child, visit, visited)) return true;
|
|
218
|
-
}
|
|
219
|
-
for (const key of DESCEND_RECORD) {
|
|
220
|
-
const record = slots[key];
|
|
221
|
-
if (record !== void 0) {
|
|
222
|
-
for (const sub of Object.values(record)) {
|
|
223
|
-
if (walkSchemaTree(sub, visit, visited)) return true;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
for (const key of DESCEND_LIST) {
|
|
228
|
-
const list = slots[key];
|
|
229
|
-
if (list !== void 0) {
|
|
230
|
-
for (const sub of list) {
|
|
231
|
-
if (walkSchemaTree(sub, visit, visited)) return true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (typeof def.getter === "function") {
|
|
236
|
-
try {
|
|
237
|
-
const inner = def.getter();
|
|
238
|
-
if (walkSchemaTree(inner, visit, visited)) return true;
|
|
239
|
-
} catch {
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
function containsDiscriminatedUnion(schema, seen) {
|
|
245
|
-
return walkSchemaTree(schema, (node) => kindOf(node) === "discriminated-union", seen);
|
|
246
|
-
}
|
|
247
|
-
function containsAsyncRefine(schema, seen) {
|
|
248
|
-
return walkSchemaTree(
|
|
249
|
-
schema,
|
|
250
|
-
(node) => {
|
|
251
|
-
for (const check of getChecks(node)) {
|
|
252
|
-
if (isAsyncCheck(check)) return true;
|
|
253
|
-
}
|
|
254
|
-
return false;
|
|
255
|
-
},
|
|
256
|
-
seen
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
206
|
const CONTAINER_SLOTS = [
|
|
260
207
|
"shape",
|
|
261
208
|
"entries",
|
|
@@ -267,31 +214,60 @@ const CONTAINER_SLOTS = [
|
|
|
267
214
|
"left",
|
|
268
215
|
"right"
|
|
269
216
|
];
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
217
|
+
const capabilityMemo = /* @__PURE__ */ new WeakMap();
|
|
218
|
+
function capabilitiesOf(schema) {
|
|
219
|
+
let capabilities = capabilityMemo.get(schema);
|
|
220
|
+
if (capabilities === void 0) {
|
|
221
|
+
capabilities = scanCapabilities(schema);
|
|
222
|
+
const key = schema;
|
|
223
|
+
if (typeof key === "object" && key !== null) capabilityMemo.set(key, capabilities);
|
|
224
|
+
}
|
|
225
|
+
return capabilities;
|
|
226
|
+
}
|
|
227
|
+
function scanCapabilities(schema) {
|
|
228
|
+
const capabilities = {
|
|
229
|
+
asyncRefine: false,
|
|
230
|
+
asyncTransform: false,
|
|
231
|
+
discriminatedUnion: false,
|
|
232
|
+
containerOrRootRefine: false,
|
|
233
|
+
preprocessOrCoerce: false
|
|
234
|
+
};
|
|
235
|
+
walkCapabilities(schema, capabilities, /* @__PURE__ */ new WeakSet());
|
|
236
|
+
return capabilities;
|
|
237
|
+
}
|
|
238
|
+
function walkCapabilities(node, capabilities, visited) {
|
|
239
|
+
if (typeof node !== "object" || node === null || visited.has(node)) return;
|
|
240
|
+
visited.add(node);
|
|
241
|
+
const def = readDef(node);
|
|
242
|
+
if (def === void 0) return;
|
|
243
|
+
const checks = getChecks(node);
|
|
244
|
+
if (checks.some(isAsyncCheck)) capabilities.asyncRefine = true;
|
|
245
|
+
if (checks.some(isVerdictCheck) && CONTAINER_SLOTS.some((key) => def[key] !== void 0)) {
|
|
246
|
+
capabilities.containerOrRootRefine = true;
|
|
247
|
+
}
|
|
248
|
+
if (typeof def.transform === "function" && def.transform.constructor.name === "AsyncFunction") {
|
|
249
|
+
capabilities.asyncTransform = true;
|
|
250
|
+
}
|
|
251
|
+
if (kindOf(node) === "discriminated-union") capabilities.discriminatedUnion = true;
|
|
252
|
+
if (isCoercePrimitive(node) || isPreprocessNode(node)) capabilities.preprocessOrCoerce = true;
|
|
253
|
+
for (const key of DESCEND_SINGLE) walkCapabilities(def[key], capabilities, visited);
|
|
254
|
+
for (const key of DESCEND_RECORD) {
|
|
255
|
+
for (const sub of Object.values(def[key] ?? {})) walkCapabilities(sub, capabilities, visited);
|
|
256
|
+
}
|
|
257
|
+
for (const key of DESCEND_LIST) {
|
|
258
|
+
for (const sub of def[key] ?? []) walkCapabilities(sub, capabilities, visited);
|
|
259
|
+
}
|
|
260
|
+
if (typeof def.getter === "function") {
|
|
261
|
+
try {
|
|
262
|
+
walkCapabilities(def.getter(), capabilities, visited);
|
|
263
|
+
} catch {
|
|
264
|
+
}
|
|
265
|
+
}
|
|
282
266
|
}
|
|
283
|
-
function
|
|
284
|
-
return
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const def = readDef(node);
|
|
288
|
-
if (def === void 0) return false;
|
|
289
|
-
const fn = def.transform;
|
|
290
|
-
if (typeof fn !== "function") return false;
|
|
291
|
-
return fn.constructor.name === "AsyncFunction";
|
|
292
|
-
},
|
|
293
|
-
seen
|
|
294
|
-
);
|
|
267
|
+
function isVerdictCheck(check) {
|
|
268
|
+
if (typeof check !== "object" || check === null) return true;
|
|
269
|
+
const kind = check._zod?.def?.check;
|
|
270
|
+
return kind !== "describe" && kind !== "meta";
|
|
295
271
|
}
|
|
296
272
|
function isAsyncCheck(check) {
|
|
297
273
|
if (typeof check !== "object" || check === null) return false;
|
|
@@ -356,17 +332,14 @@ function zodIssuesToValidationErrors(issues) {
|
|
|
356
332
|
|
|
357
333
|
const V4_INTROSPECTOR = {
|
|
358
334
|
kindOf: (schema) => kindOf(schema),
|
|
359
|
-
getObjectShape
|
|
335
|
+
getObjectShape,
|
|
360
336
|
getTupleItems,
|
|
361
|
-
getDiscriminatedOptions
|
|
337
|
+
getDiscriminatedOptions,
|
|
362
338
|
getDiscriminator,
|
|
363
339
|
getLiteralValues,
|
|
364
340
|
isPreprocessNode,
|
|
365
341
|
isCoercePrimitive,
|
|
366
|
-
|
|
367
|
-
containsAsyncTransform,
|
|
368
|
-
containsDiscriminatedUnion,
|
|
369
|
-
hasContainerOrRootRefine,
|
|
342
|
+
capabilitiesOf,
|
|
370
343
|
// Walker accessors (D2 / D3 / D5).
|
|
371
344
|
getArrayElement: (schema) => {
|
|
372
345
|
if (kindOf(schema) !== "array") return void 0;
|
|
@@ -393,7 +366,7 @@ const V4_INTROSPECTOR = {
|
|
|
393
366
|
};
|
|
394
367
|
|
|
395
368
|
function slimPrimitivesOf(schema, maxRecursionDepth) {
|
|
396
|
-
return
|
|
369
|
+
return slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth);
|
|
397
370
|
}
|
|
398
371
|
|
|
399
372
|
function deriveDefault(schema, useDefault, maxRecursionDepth) {
|
|
@@ -525,7 +498,7 @@ function isLeafRequired(schema, depth = 0) {
|
|
|
525
498
|
return true;
|
|
526
499
|
}
|
|
527
500
|
function zodV4Adapter(rootSchema) {
|
|
528
|
-
|
|
501
|
+
assertZodV4Node(rootSchema);
|
|
529
502
|
assertKeyedRoot(rootSchema);
|
|
530
503
|
return (_formKey, options) => sharedV4Schemas(
|
|
531
504
|
rootSchema,
|
|
@@ -549,6 +522,7 @@ function buildV4Services() {
|
|
|
549
522
|
slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),
|
|
550
523
|
deriveDefault: (schema, useDefault, maxRecursionDepth) => deriveDefault(schema, useDefault, maxRecursionDepth),
|
|
551
524
|
runGetDefaults: (schema, config, maxRecursionDepth) => runGetDefaultsV4(schema, config, maxRecursionDepth),
|
|
525
|
+
validateSync: (schema, data) => validateSyncV4(schema, data),
|
|
552
526
|
unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),
|
|
553
527
|
unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
|
|
554
528
|
peelAllWrappers: (schema) => peelAllWrappers(schema),
|
|
@@ -567,37 +541,35 @@ function buildV4Services() {
|
|
|
567
541
|
};
|
|
568
542
|
}
|
|
569
543
|
function runGetDefaultsV4(rootSchema, config, maxRecursionDepth) {
|
|
570
|
-
|
|
544
|
+
return getDefaultValuesFromZodSchema({
|
|
571
545
|
schema: rootSchema,
|
|
572
546
|
useDefaultSchemaValues: config.useDefaultSchemaValues,
|
|
573
547
|
constraints: config.constraints,
|
|
574
548
|
maxRecursionDepth
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
549
|
+
}).data;
|
|
550
|
+
}
|
|
551
|
+
const verdictRan = /* @__PURE__ */ new WeakMap();
|
|
552
|
+
function validateSyncV4(rootSchema, data) {
|
|
553
|
+
const { asyncRefine, asyncTransform } = capabilitiesOf(rootSchema);
|
|
554
|
+
if (asyncRefine || asyncTransform) return [];
|
|
579
555
|
try {
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return {
|
|
585
|
-
data,
|
|
586
|
-
errors: zodIssuesToValidationErrors(parseResult.error.issues),
|
|
587
|
-
success: false
|
|
588
|
-
};
|
|
556
|
+
const jitless = !verdictRan.has(rootSchema);
|
|
557
|
+
if (jitless) verdictRan.set(rootSchema, true);
|
|
558
|
+
const parseResult = rootSchema.safeParse(data, { jitless });
|
|
559
|
+
return parseResult.success ? [] : zodIssuesToValidationErrors(parseResult.error.issues);
|
|
589
560
|
} catch {
|
|
590
|
-
return
|
|
561
|
+
return [];
|
|
591
562
|
}
|
|
592
563
|
}
|
|
593
564
|
function buildSubSchemaStubV4(schema, maxRecursionDepth) {
|
|
594
565
|
return {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
566
|
+
// Async work of either kind, as the root's `needsAsyncValidation`
|
|
567
|
+
// counts it: the field's `valid` waits for the first async pass.
|
|
568
|
+
needsAsyncValidation: () => {
|
|
569
|
+
const { asyncRefine, asyncTransform } = scanCapabilities(schema);
|
|
570
|
+
return asyncRefine || asyncTransform;
|
|
571
|
+
},
|
|
572
|
+
getDefaultValues: () => deriveDefault(schema, true, maxRecursionDepth),
|
|
601
573
|
getSchemasAtPath: () => [],
|
|
602
574
|
validateAtPath: async (data) => {
|
|
603
575
|
const result = await schema.safeParseAsync(data);
|
|
@@ -647,7 +619,8 @@ function resolveFieldMetaAtPath(rootSchema, path, maxRecursionDepth) {
|
|
|
647
619
|
};
|
|
648
620
|
}
|
|
649
621
|
function readDescription(schema) {
|
|
650
|
-
const
|
|
622
|
+
const scope = globalThis;
|
|
623
|
+
const candidate = scope.__zod_globalRegistry?.get(schema)?.description ?? schema.description;
|
|
651
624
|
return typeof candidate === "string" ? candidate : void 0;
|
|
652
625
|
}
|
|
653
626
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.
|
|
1
|
+
import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.04aupFBW.mjs';
|
|
2
2
|
import { shallowReactive, getCurrentInstance, inject } from 'vue';
|
|
3
3
|
|
|
4
4
|
function detectSSR(options = {}) {
|
|
@@ -182,8 +182,8 @@ function renderAttaformState(app) {
|
|
|
182
182
|
// The wire shape stays two per-source arrays; the tagged store
|
|
183
183
|
// splits at the boundary and the client replays each side into
|
|
184
184
|
// its cell half.
|
|
185
|
-
schemaErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.schema.length > 0).map(([key2, cell]) => [key2, cell.schema]),
|
|
186
|
-
userErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.user.length > 0).map(([key2, cell]) => [key2, cell.user]),
|
|
185
|
+
schemaErrors: [...state.errorCells().entries()].filter(([, cell]) => cell.schema.length > 0).map(([key2, cell]) => [key2, cell.schema]),
|
|
186
|
+
userErrors: [...state.errorCells().entries()].filter(([, cell]) => cell.user.length > 0).map(([key2, cell]) => [key2, cell.user]),
|
|
187
187
|
fields: Array.from(state.fields.entries()),
|
|
188
188
|
...transientList.length > 0 ? { blankPaths: transientList } : {}
|
|
189
189
|
}
|