attaform 0.30.1 → 0.31.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 +3 -3
- package/dist/dev/abstract.mjs +3 -3
- package/dist/dev/chunks/devtools.mjs +2 -2
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -1
- package/dist/dev/index.mjs +4 -4
- package/dist/dev/runtime/plugins/attaform.mjs +1 -1
- package/dist/dev/shared/{attaform-dev.Chm4D6SJ.mjs → attaform-dev.B1q-x9R9.mjs} +2 -2
- package/dist/dev/shared/{attaform-dev.BUIFcTYf.mjs → attaform-dev.Caibt7sb.mjs} +11 -10
- package/dist/dev/shared/{attaform-dev.CT7MDjPy.mjs → attaform-dev.CtyqGia7.mjs} +152 -227
- package/dist/dev/shared/{attaform-dev.BJK1kqHY.mjs → attaform-dev.DJ3nsWw6.mjs} +74 -110
- package/dist/dev/shared/{attaform-dev.DuEE4GU1.mjs → attaform-dev.DlaT4xGd.mjs} +3 -3
- package/dist/dev/shared/{attaform-dev.BMQ3GcgD.mjs → attaform-dev.k5X47GMD.mjs} +474 -336
- package/dist/dev/shared/{attaform-dev.DxHdkkPG.mjs → attaform-dev.y9x9Vp9F.mjs} +206 -127
- package/dist/dev/zod-v3.mjs +5 -5
- package/dist/dev/zod-v4.mjs +5 -5
- package/dist/dev/zod.mjs +4 -4
- 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 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +3 -3
- package/dist/runtime/plugins/attaform.mjs +1 -1
- package/dist/shared/{attaform.CO918TdU.mjs → attaform.BWUn8Kjy.mjs} +74 -110
- package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.C4shmwyJ.mjs} +2 -2
- package/dist/shared/{attaform.2FslhB9R.d.mts → attaform.CRVe8s82.d.mts} +1 -1
- package/dist/shared/{attaform.L0kUn3vL.d.mts → attaform.D9RqPgGu.d.mts} +1 -1
- package/dist/shared/{attaform.BcQwgWaq.d.mts → attaform.DAo0QBmS.d.mts} +28 -8
- package/dist/shared/{attaform.ZYn2ahzJ.mjs → attaform.DBCbxlyk.mjs} +59 -1
- package/dist/shared/{attaform.DRsANMok.mjs → attaform.DL2nl_QR.mjs} +11 -10
- package/dist/shared/{attaform.BIWicztt.mjs → attaform.DNPJPOO7.mjs} +204 -125
- package/dist/shared/{attaform.Br8EBn5B.d.mts → attaform.DZnrDrNb.d.mts} +136 -32
- package/dist/shared/{attaform.D_f1WgYf.mjs → attaform.DxKQsqFZ.mjs} +456 -318
- package/dist/shared/{attaform.B2iebkPA.mjs → attaform.L011tHgJ.mjs} +3 -3
- package/dist/shared/{attaform.D_pt1gOj.mjs → attaform.LUPC-2Qg.mjs} +152 -227
- 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 +5 -5
- package/dist/zod-v4.d.mts +13 -11
- package/dist/zod-v4.mjs +5 -5
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +4 -4
- package/package.json +1 -1
- package/skills/attaform/SKILL.md +1 -1
- package/skills/attaform/references/custom-components.md +4 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as humanize, c as useAbstractForm } from './attaform-dev.
|
|
1
|
+
import { j as humanize, c as useAbstractForm } from './attaform-dev.y9x9Vp9F.mjs';
|
|
2
2
|
import { A as AttaformError, e as canonicalizePath, a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.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.
|
|
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.Caibt7sb.mjs';
|
|
4
4
|
import { c as callConsumerFn } from './attaform-dev.CZz4GYZ6.mjs';
|
|
5
5
|
|
|
6
6
|
function readDef(schema) {
|
|
@@ -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);
|
|
@@ -202,60 +200,6 @@ const DESCEND_SINGLE = [
|
|
|
202
200
|
];
|
|
203
201
|
const DESCEND_RECORD = ["shape", "entries"];
|
|
204
202
|
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
203
|
const CONTAINER_SLOTS = [
|
|
260
204
|
"shape",
|
|
261
205
|
"entries",
|
|
@@ -267,31 +211,55 @@ const CONTAINER_SLOTS = [
|
|
|
267
211
|
"left",
|
|
268
212
|
"right"
|
|
269
213
|
];
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
);
|
|
214
|
+
const capabilityMemo = /* @__PURE__ */ new WeakMap();
|
|
215
|
+
function capabilitiesOf(schema) {
|
|
216
|
+
let capabilities = capabilityMemo.get(schema);
|
|
217
|
+
if (capabilities === void 0) {
|
|
218
|
+
capabilities = scanCapabilities(schema);
|
|
219
|
+
const key = schema;
|
|
220
|
+
if (typeof key === "object" && key !== null) capabilityMemo.set(key, capabilities);
|
|
221
|
+
}
|
|
222
|
+
return capabilities;
|
|
223
|
+
}
|
|
224
|
+
function scanCapabilities(schema) {
|
|
225
|
+
const capabilities = {
|
|
226
|
+
asyncRefine: false,
|
|
227
|
+
asyncTransform: false,
|
|
228
|
+
discriminatedUnion: false,
|
|
229
|
+
containerOrRootRefine: false,
|
|
230
|
+
preprocessOrCoerce: false
|
|
231
|
+
};
|
|
232
|
+
walkCapabilities(schema, capabilities, /* @__PURE__ */ new WeakSet());
|
|
233
|
+
return capabilities;
|
|
234
|
+
}
|
|
235
|
+
function walkCapabilities(node, capabilities, visited) {
|
|
236
|
+
if (typeof node !== "object" || node === null || visited.has(node)) return;
|
|
237
|
+
visited.add(node);
|
|
238
|
+
const def = readDef(node);
|
|
239
|
+
if (def === void 0) return;
|
|
240
|
+
const checks = getChecks(node);
|
|
241
|
+
if (checks.some(isAsyncCheck)) capabilities.asyncRefine = true;
|
|
242
|
+
if (checks.length > 0 && CONTAINER_SLOTS.some((key) => def[key] !== void 0)) {
|
|
243
|
+
capabilities.containerOrRootRefine = true;
|
|
244
|
+
}
|
|
245
|
+
if (typeof def.transform === "function" && def.transform.constructor.name === "AsyncFunction") {
|
|
246
|
+
capabilities.asyncTransform = true;
|
|
247
|
+
}
|
|
248
|
+
if (kindOf(node) === "discriminated-union") capabilities.discriminatedUnion = true;
|
|
249
|
+
if (isCoercePrimitive(node) || isPreprocessNode(node)) capabilities.preprocessOrCoerce = true;
|
|
250
|
+
for (const key of DESCEND_SINGLE) walkCapabilities(def[key], capabilities, visited);
|
|
251
|
+
for (const key of DESCEND_RECORD) {
|
|
252
|
+
for (const sub of Object.values(def[key] ?? {})) walkCapabilities(sub, capabilities, visited);
|
|
253
|
+
}
|
|
254
|
+
for (const key of DESCEND_LIST) {
|
|
255
|
+
for (const sub of def[key] ?? []) walkCapabilities(sub, capabilities, visited);
|
|
256
|
+
}
|
|
257
|
+
if (typeof def.getter === "function") {
|
|
258
|
+
try {
|
|
259
|
+
walkCapabilities(def.getter(), capabilities, visited);
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
295
263
|
}
|
|
296
264
|
function isAsyncCheck(check) {
|
|
297
265
|
if (typeof check !== "object" || check === null) return false;
|
|
@@ -363,10 +331,7 @@ const V4_INTROSPECTOR = {
|
|
|
363
331
|
getLiteralValues,
|
|
364
332
|
isPreprocessNode,
|
|
365
333
|
isCoercePrimitive,
|
|
366
|
-
|
|
367
|
-
containsAsyncTransform,
|
|
368
|
-
containsDiscriminatedUnion,
|
|
369
|
-
hasContainerOrRootRefine,
|
|
334
|
+
capabilitiesOf,
|
|
370
335
|
// Walker accessors (D2 / D3 / D5).
|
|
371
336
|
getArrayElement: (schema) => {
|
|
372
337
|
if (kindOf(schema) !== "array") return void 0;
|
|
@@ -393,7 +358,7 @@ const V4_INTROSPECTOR = {
|
|
|
393
358
|
};
|
|
394
359
|
|
|
395
360
|
function slimPrimitivesOf(schema, maxRecursionDepth) {
|
|
396
|
-
return
|
|
361
|
+
return slimPrimitivesWalk(schema, V4_INTROSPECTOR, maxRecursionDepth);
|
|
397
362
|
}
|
|
398
363
|
|
|
399
364
|
function deriveDefault(schema, useDefault, maxRecursionDepth) {
|
|
@@ -549,6 +514,7 @@ function buildV4Services() {
|
|
|
549
514
|
slimPrimitivesOf: (schema, maxRecursionDepth) => slimPrimitivesOf(schema, maxRecursionDepth),
|
|
550
515
|
deriveDefault: (schema, useDefault, maxRecursionDepth) => deriveDefault(schema, useDefault, maxRecursionDepth),
|
|
551
516
|
runGetDefaults: (schema, config, maxRecursionDepth) => runGetDefaultsV4(schema, config, maxRecursionDepth),
|
|
517
|
+
validateSync: (schema, data) => validateSyncV4(schema, data),
|
|
552
518
|
unwrapStructuralWrappers: (schema) => unwrapStructuralWrappers(schema),
|
|
553
519
|
unwrapToDiscriminatedUnion: (schema) => unwrapToDiscriminatedUnion(schema),
|
|
554
520
|
peelAllWrappers: (schema) => peelAllWrappers(schema),
|
|
@@ -567,37 +533,35 @@ function buildV4Services() {
|
|
|
567
533
|
};
|
|
568
534
|
}
|
|
569
535
|
function runGetDefaultsV4(rootSchema, config, maxRecursionDepth) {
|
|
570
|
-
|
|
536
|
+
return getDefaultValuesFromZodSchema({
|
|
571
537
|
schema: rootSchema,
|
|
572
538
|
useDefaultSchemaValues: config.useDefaultSchemaValues,
|
|
573
539
|
constraints: config.constraints,
|
|
574
540
|
maxRecursionDepth
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
541
|
+
}).data;
|
|
542
|
+
}
|
|
543
|
+
const verdictRan = /* @__PURE__ */ new WeakMap();
|
|
544
|
+
function validateSyncV4(rootSchema, data) {
|
|
545
|
+
const { asyncRefine, asyncTransform } = capabilitiesOf(rootSchema);
|
|
546
|
+
if (asyncRefine || asyncTransform) return [];
|
|
579
547
|
try {
|
|
580
|
-
const
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return {
|
|
585
|
-
data,
|
|
586
|
-
errors: zodIssuesToValidationErrors(parseResult.error.issues),
|
|
587
|
-
success: false
|
|
588
|
-
};
|
|
548
|
+
const jitless = !verdictRan.has(rootSchema);
|
|
549
|
+
if (jitless) verdictRan.set(rootSchema, true);
|
|
550
|
+
const parseResult = rootSchema.safeParse(data, { jitless });
|
|
551
|
+
return parseResult.success ? [] : zodIssuesToValidationErrors(parseResult.error.issues);
|
|
589
552
|
} catch {
|
|
590
|
-
return
|
|
553
|
+
return [];
|
|
591
554
|
}
|
|
592
555
|
}
|
|
593
556
|
function buildSubSchemaStubV4(schema, maxRecursionDepth) {
|
|
594
557
|
return {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
558
|
+
// Async work of either kind, as the root's `needsAsyncValidation`
|
|
559
|
+
// counts it: the field's `valid` waits for the first async pass.
|
|
560
|
+
needsAsyncValidation: () => {
|
|
561
|
+
const { asyncRefine, asyncTransform } = scanCapabilities(schema);
|
|
562
|
+
return asyncRefine || asyncTransform;
|
|
563
|
+
},
|
|
564
|
+
getDefaultValues: () => deriveDefault(schema, true, maxRecursionDepth),
|
|
601
565
|
getSchemasAtPath: () => [],
|
|
602
566
|
validateAtPath: async (data) => {
|
|
603
567
|
const result = await schema.safeParseAsync(data);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as InvalidUseFormConfigError } from './attaform-dev.zlvDr0WB.mjs';
|
|
2
|
-
import { u as useForm$2 } from './attaform-dev.
|
|
3
|
-
import { u as useForm$1 } from './attaform-dev.
|
|
4
|
-
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.
|
|
2
|
+
import { u as useForm$2 } from './attaform-dev.CtyqGia7.mjs';
|
|
3
|
+
import { u as useForm$1 } from './attaform-dev.DJ3nsWw6.mjs';
|
|
4
|
+
import { i as installingFieldMetaStore, g as getFieldMetaForSchema } from './attaform-dev.Caibt7sb.mjs';
|
|
5
5
|
|
|
6
6
|
function isZodV4SchemaShape(value) {
|
|
7
7
|
if (typeof value !== "object" || value === null) return false;
|