attaform 0.17.2 → 0.18.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/README.md +77 -36
- package/dist/chunks/devtools.cjs +10 -37
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +10 -37
- package/dist/chunks/devtools.mjs.map +1 -1
- package/dist/chunks/indexeddb.cjs +4 -4
- package/dist/chunks/indexeddb.cjs.map +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +2 -2
- package/dist/chunks/local-storage.cjs.map +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +2 -2
- package/dist/chunks/session-storage.cjs.map +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +42 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -196
- package/dist/index.d.mts +159 -196
- package/dist/index.d.ts +159 -196
- package/dist/index.mjs +5 -7
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.cjs +31 -40
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.cts +8 -1
- package/dist/nuxt.d.mts +8 -1
- package/dist/nuxt.d.ts +8 -1
- package/dist/nuxt.mjs +32 -41
- package/dist/nuxt.mjs.map +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.d.vue.ts +7 -0
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +453 -0
- package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +7 -0
- package/dist/runtime/components/DevtoolsValueTree.d.vue.ts +37 -0
- package/dist/runtime/components/DevtoolsValueTree.vue +192 -0
- package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +37 -0
- package/dist/runtime/plugins/attaform.cjs +17 -6
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +15 -4
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/attaform.5UhpSVFI.cjs +63 -0
- package/dist/shared/attaform.5UhpSVFI.cjs.map +1 -0
- package/dist/shared/attaform.BDdFdjeX.mjs +57 -0
- package/dist/shared/attaform.BDdFdjeX.mjs.map +1 -0
- package/dist/shared/attaform.Bgu9l6OG.d.cts +1651 -0
- package/dist/shared/attaform.BmDBu4ql.d.ts +1651 -0
- package/dist/shared/{attaform.Dee2rU1P.cjs → attaform.BqK_L4gK.cjs} +310 -24
- package/dist/shared/attaform.BqK_L4gK.cjs.map +1 -0
- package/dist/shared/{attaform.C_5aB6EQ.d.ts → attaform.BsMdl-35.d.cts} +754 -146
- package/dist/shared/{attaform.C_5aB6EQ.d.mts → attaform.BsMdl-35.d.mts} +754 -146
- package/dist/shared/{attaform.C_5aB6EQ.d.cts → attaform.BsMdl-35.d.ts} +754 -146
- package/dist/shared/attaform.Bubm_slq.cjs.map +1 -1
- package/dist/shared/{attaform.C6lbmMUe.d.ts → attaform.C3x1hKJC.d.mts} +4 -4
- package/dist/shared/{attaform.CuE-bS1C.d.mts → attaform.CWs1Z3p7.d.ts} +57 -23
- package/dist/shared/attaform.CXpzmj38.mjs.map +1 -1
- package/dist/shared/{attaform.C5MH4lNh.d.mts → attaform.CjmJpfLH.d.ts} +4 -4
- package/dist/shared/{attaform.Drt6fivF.mjs → attaform.CtNUB9nf.mjs} +74 -76
- package/dist/shared/attaform.CtNUB9nf.mjs.map +1 -0
- package/dist/shared/{attaform.C0iFnTN0.d.ts → attaform.D-hDvb98.d.cts} +57 -23
- package/dist/shared/attaform.DAH3kvav.d.mts +1651 -0
- package/dist/shared/{attaform.BPRHR3Zs.cjs → attaform.DUHru0OF.cjs} +83 -85
- package/dist/shared/attaform.DUHru0OF.cjs.map +1 -0
- package/dist/shared/{attaform.BV40t5y2.cjs → attaform.Dlk1jMuv.cjs} +245 -108
- package/dist/shared/attaform.Dlk1jMuv.cjs.map +1 -0
- package/dist/shared/{attaform.B3ZaPIzS.mjs → attaform.DsC3rZHG.mjs} +1804 -219
- package/dist/shared/attaform.DsC3rZHG.mjs.map +1 -0
- package/dist/shared/{attaform.DtMN-MAm.d.cts → attaform.Dzi89x8N.d.cts} +4 -4
- package/dist/shared/{attaform.Cer8JO_P.cjs → attaform.II89Pcf4.cjs} +1860 -272
- package/dist/shared/attaform.II89Pcf4.cjs.map +1 -0
- package/dist/shared/{attaform.CIEQgJnM.mjs → attaform.Xhg0AYNa.mjs} +300 -26
- package/dist/shared/attaform.Xhg0AYNa.mjs.map +1 -0
- package/dist/shared/{attaform.CpERWz3u.mjs → attaform.Xt0A3QUd.mjs} +232 -95
- package/dist/shared/attaform.Xt0A3QUd.mjs.map +1 -0
- package/dist/shared/{attaform.CHorcsIU.d.cts → attaform.bH7WvNad.d.mts} +57 -23
- package/dist/vite.cjs +270 -2
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +266 -2
- package/dist/vite.mjs.map +1 -1
- package/dist/zod-v3.cjs +11 -8
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +6 -6
- package/dist/zod-v3.d.mts +6 -6
- package/dist/zod-v3.d.ts +6 -6
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +11 -8
- package/dist/zod-v4.cjs.map +1 -1
- package/dist/zod-v4.d.cts +5 -5
- package/dist/zod-v4.d.mts +5 -5
- package/dist/zod-v4.d.ts +5 -5
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +15 -16
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +127 -40
- package/dist/zod.d.mts +127 -40
- package/dist/zod.d.ts +127 -40
- package/dist/zod.mjs +7 -11
- package/dist/zod.mjs.map +1 -1
- package/package.json +19 -5
- package/dist/shared/attaform.B1jvxsOF.d.mts +0 -156
- package/dist/shared/attaform.B3ZaPIzS.mjs.map +0 -1
- package/dist/shared/attaform.BBM2muQ9.cjs +0 -101
- package/dist/shared/attaform.BBM2muQ9.cjs.map +0 -1
- package/dist/shared/attaform.BPRHR3Zs.cjs.map +0 -1
- package/dist/shared/attaform.BV40t5y2.cjs.map +0 -1
- package/dist/shared/attaform.C6qzEdIM.d.cts +0 -156
- package/dist/shared/attaform.C8LVFVVe.cjs +0 -32
- package/dist/shared/attaform.C8LVFVVe.cjs.map +0 -1
- package/dist/shared/attaform.CIEQgJnM.mjs.map +0 -1
- package/dist/shared/attaform.CTwNcpLE.d.ts +0 -156
- package/dist/shared/attaform.Cer8JO_P.cjs.map +0 -1
- package/dist/shared/attaform.CpERWz3u.mjs.map +0 -1
- package/dist/shared/attaform.Dee2rU1P.cjs.map +0 -1
- package/dist/shared/attaform.Drt6fivF.mjs.map +0 -1
- package/dist/shared/attaform.Vo-Kft0t.mjs +0 -29
- package/dist/shared/attaform.Vo-Kft0t.mjs.map +0 -1
- package/dist/shared/attaform.h1sq3BFu.mjs +0 -92
- package/dist/shared/attaform.h1sq3BFu.mjs.map +0 -1
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const lodashEs = require('lodash-es');
|
|
4
4
|
const zod = require('zod');
|
|
5
|
-
const
|
|
6
|
-
const paths = require('./attaform.
|
|
5
|
+
const injectWizard = require('./attaform.II89Pcf4.cjs');
|
|
6
|
+
const paths = require('./attaform.BqK_L4gK.cjs');
|
|
7
7
|
const fieldMetaStore = require('./attaform.C8CyvYa_.cjs');
|
|
8
|
-
const plugin = require('./attaform.Dee2rU1P.cjs');
|
|
9
8
|
|
|
10
9
|
const fieldMeta = fieldMetaStore.fieldMetaStore;
|
|
11
10
|
function withMeta(schema, payload) {
|
|
@@ -19,7 +18,7 @@ function getFieldMeta(schema) {
|
|
|
19
18
|
return fieldMetaStore.getFieldMetaForSchema(schema);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
class UnsupportedSchemaError extends
|
|
21
|
+
class UnsupportedSchemaError extends paths.AttaformError {
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
function isZodSchemaType(schema, expectedType) {
|
|
@@ -328,22 +327,37 @@ const PERMISSIVE_V3 = /* @__PURE__ */ new Set([
|
|
|
328
327
|
"symbol",
|
|
329
328
|
"function",
|
|
330
329
|
"map",
|
|
331
|
-
"set"
|
|
330
|
+
"set",
|
|
331
|
+
"file"
|
|
332
332
|
]);
|
|
333
|
+
const KIND_STRING = /* @__PURE__ */ new Set(["string"]);
|
|
334
|
+
const KIND_NUMBER = /* @__PURE__ */ new Set(["number"]);
|
|
335
|
+
const KIND_BOOLEAN = /* @__PURE__ */ new Set(["boolean"]);
|
|
336
|
+
const KIND_BIGINT = /* @__PURE__ */ new Set(["bigint"]);
|
|
337
|
+
const KIND_DATE = /* @__PURE__ */ new Set(["date"]);
|
|
338
|
+
const KIND_NULL = /* @__PURE__ */ new Set(["null"]);
|
|
339
|
+
const KIND_UNDEFINED = /* @__PURE__ */ new Set(["undefined"]);
|
|
340
|
+
const KIND_OBJECT = /* @__PURE__ */ new Set(["object"]);
|
|
341
|
+
const KIND_ARRAY = /* @__PURE__ */ new Set(["array"]);
|
|
342
|
+
const KIND_SET = /* @__PURE__ */ new Set(["set"]);
|
|
343
|
+
const EMPTY_KINDS = /* @__PURE__ */ new Set();
|
|
333
344
|
const MAX_LAZY_DEPTH_V3 = 64;
|
|
334
345
|
function slimPrimitivesV3(schema, depth = 0) {
|
|
335
|
-
|
|
346
|
+
return new Set(walk(schema, depth));
|
|
347
|
+
}
|
|
348
|
+
function walk(schema, depth) {
|
|
349
|
+
if (depth > MAX_LAZY_DEPTH_V3) return PERMISSIVE_V3;
|
|
336
350
|
const def = schema._def;
|
|
337
351
|
const typeName = def?.typeName;
|
|
338
|
-
if (isZodSchemaType(schema, "ZodString")) return
|
|
339
|
-
if (isZodSchemaType(schema, "ZodNumber")) return
|
|
340
|
-
if (isZodSchemaType(schema, "ZodBoolean")) return
|
|
341
|
-
if (isZodSchemaType(schema, "ZodBigInt")) return
|
|
342
|
-
if (isZodSchemaType(schema, "ZodDate")) return
|
|
343
|
-
if (isZodSchemaType(schema, "ZodNull")) return
|
|
344
|
-
if (isZodSchemaType(schema, "ZodUndefined")) return
|
|
345
|
-
if (typeName === "ZodVoid") return
|
|
346
|
-
if (typeName === "ZodNaN") return
|
|
352
|
+
if (isZodSchemaType(schema, "ZodString")) return KIND_STRING;
|
|
353
|
+
if (isZodSchemaType(schema, "ZodNumber")) return KIND_NUMBER;
|
|
354
|
+
if (isZodSchemaType(schema, "ZodBoolean")) return KIND_BOOLEAN;
|
|
355
|
+
if (isZodSchemaType(schema, "ZodBigInt")) return KIND_BIGINT;
|
|
356
|
+
if (isZodSchemaType(schema, "ZodDate")) return KIND_DATE;
|
|
357
|
+
if (isZodSchemaType(schema, "ZodNull")) return KIND_NULL;
|
|
358
|
+
if (isZodSchemaType(schema, "ZodUndefined")) return KIND_UNDEFINED;
|
|
359
|
+
if (typeName === "ZodVoid") return KIND_UNDEFINED;
|
|
360
|
+
if (typeName === "ZodNaN") return KIND_NUMBER;
|
|
347
361
|
if (isZodSchemaType(schema, "ZodEnum")) {
|
|
348
362
|
const options = schema.options;
|
|
349
363
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -351,70 +365,72 @@ function slimPrimitivesV3(schema, depth = 0) {
|
|
|
351
365
|
if (typeof v === "string") out.add("string");
|
|
352
366
|
else if (typeof v === "number") out.add("number");
|
|
353
367
|
}
|
|
354
|
-
return out.size === 0 ?
|
|
368
|
+
return out.size === 0 ? KIND_STRING : out;
|
|
355
369
|
}
|
|
356
370
|
if (isZodSchemaType(schema, "ZodLiteral")) {
|
|
357
371
|
const value = schema.value;
|
|
358
372
|
return /* @__PURE__ */ new Set([slimKindOfRawV3(value)]);
|
|
359
373
|
}
|
|
360
374
|
if (isZodSchemaType(schema, "ZodObject") || typeName === "ZodRecord") {
|
|
361
|
-
return
|
|
375
|
+
return KIND_OBJECT;
|
|
362
376
|
}
|
|
363
377
|
if (isZodSchemaType(schema, "ZodArray") || typeName === "ZodTuple") {
|
|
364
|
-
return
|
|
378
|
+
return KIND_ARRAY;
|
|
365
379
|
}
|
|
366
380
|
if (isZodSchemaType(schema, "ZodSet")) {
|
|
367
|
-
return
|
|
381
|
+
return KIND_SET;
|
|
368
382
|
}
|
|
369
383
|
if (isZodSchemaType(schema, "ZodOptional")) {
|
|
370
384
|
const inner = def?.innerType;
|
|
371
|
-
const innerSet = inner === void 0 ?
|
|
372
|
-
innerSet
|
|
373
|
-
|
|
385
|
+
const innerSet = inner === void 0 ? EMPTY_KINDS : walk(inner, depth + 1);
|
|
386
|
+
const out = new Set(innerSet);
|
|
387
|
+
out.add("undefined");
|
|
388
|
+
return out;
|
|
374
389
|
}
|
|
375
390
|
if (isZodSchemaType(schema, "ZodNullable")) {
|
|
376
391
|
const inner = def?.innerType;
|
|
377
|
-
const innerSet = inner === void 0 ?
|
|
378
|
-
innerSet
|
|
379
|
-
|
|
392
|
+
const innerSet = inner === void 0 ? EMPTY_KINDS : walk(inner, depth + 1);
|
|
393
|
+
const out = new Set(innerSet);
|
|
394
|
+
out.add("null");
|
|
395
|
+
return out;
|
|
380
396
|
}
|
|
381
397
|
if (isZodSchemaType(schema, "ZodDefault") || isZodSchemaType(schema, "ZodReadonly") || isZodSchemaType(schema, "ZodCatch") || isZodSchemaType(schema, "ZodBranded")) {
|
|
382
398
|
const inner = def?.innerType ?? def?.type;
|
|
383
|
-
return inner === void 0 ?
|
|
399
|
+
return inner === void 0 ? PERMISSIVE_V3 : walk(inner, depth + 1);
|
|
384
400
|
}
|
|
385
401
|
if (isZodSchemaType(schema, "ZodEffects")) {
|
|
386
402
|
const inner = def?.schema;
|
|
387
|
-
return inner === void 0 ?
|
|
403
|
+
return inner === void 0 ? PERMISSIVE_V3 : walk(inner, depth + 1);
|
|
388
404
|
}
|
|
389
405
|
if (isZodSchemaType(schema, "ZodPipeline")) {
|
|
390
406
|
const inner = def?.in;
|
|
391
|
-
return inner === void 0 ?
|
|
407
|
+
return inner === void 0 ? PERMISSIVE_V3 : walk(inner, depth + 1);
|
|
392
408
|
}
|
|
393
409
|
if (typeName === "ZodLazy") {
|
|
394
410
|
const getter = def?.getter;
|
|
395
|
-
if (typeof getter !== "function") return
|
|
396
|
-
return
|
|
411
|
+
if (typeof getter !== "function") return PERMISSIVE_V3;
|
|
412
|
+
return walk(getter(), depth + 1);
|
|
397
413
|
}
|
|
398
414
|
if (isZodSchemaType(schema, "ZodUnion") || isZodSchemaType(schema, "ZodDiscriminatedUnion")) {
|
|
399
415
|
const options = def?.options ?? [];
|
|
400
416
|
const out = /* @__PURE__ */ new Set();
|
|
401
417
|
for (const opt of options) {
|
|
402
|
-
for (const k of
|
|
418
|
+
for (const k of walk(opt, depth + 1)) out.add(k);
|
|
403
419
|
}
|
|
404
|
-
return out.size === 0 ?
|
|
420
|
+
return out.size === 0 ? PERMISSIVE_V3 : out;
|
|
405
421
|
}
|
|
406
422
|
if (typeName === "ZodIntersection") {
|
|
407
423
|
const left = def?.left;
|
|
408
424
|
const right = def?.right;
|
|
409
|
-
const leftSet = left === void 0 ?
|
|
410
|
-
const rightSet = right === void 0 ?
|
|
425
|
+
const leftSet = left === void 0 ? PERMISSIVE_V3 : walk(left, depth + 1);
|
|
426
|
+
const rightSet = right === void 0 ? PERMISSIVE_V3 : walk(right, depth + 1);
|
|
411
427
|
const out = /* @__PURE__ */ new Set();
|
|
412
428
|
for (const k of leftSet) if (rightSet.has(k)) out.add(k);
|
|
413
429
|
return out;
|
|
414
430
|
}
|
|
415
|
-
if (typeName === "ZodNever") return
|
|
416
|
-
if (typeName === "ZodAny" || typeName === "ZodUnknown") return
|
|
417
|
-
return
|
|
431
|
+
if (typeName === "ZodNever") return EMPTY_KINDS;
|
|
432
|
+
if (typeName === "ZodAny" || typeName === "ZodUnknown") return PERMISSIVE_V3;
|
|
433
|
+
return PERMISSIVE_V3;
|
|
418
434
|
}
|
|
419
435
|
function slimKindOfRawV3(value) {
|
|
420
436
|
if (value === null) return "null";
|
|
@@ -477,6 +493,7 @@ function zodAdapter(zodSchema) {
|
|
|
477
493
|
}
|
|
478
494
|
}
|
|
479
495
|
const leafCache = /* @__PURE__ */ new Map();
|
|
496
|
+
const preprocessOrCoerceCache = /* @__PURE__ */ new Map();
|
|
480
497
|
const abstractSchema = {
|
|
481
498
|
fingerprint: () => fingerprintZodSchema(_zodSchema),
|
|
482
499
|
getDefaultValues(config) {
|
|
@@ -537,9 +554,9 @@ function zodAdapter(zodSchema) {
|
|
|
537
554
|
}
|
|
538
555
|
const candidate = schemasAtPath[0];
|
|
539
556
|
if (candidate !== void 0) {
|
|
540
|
-
const valueAtPath =
|
|
557
|
+
const valueAtPath = injectWizard.getAtPath(rawDefaultValues, path);
|
|
541
558
|
const slimKinds = slimPrimitivesV3(candidate);
|
|
542
|
-
if (slimKinds.size > 0 && slimKinds.has(
|
|
559
|
+
if (slimKinds.size > 0 && slimKinds.has(injectWizard.slimKindOf(valueAtPath))) {
|
|
543
560
|
continue;
|
|
544
561
|
}
|
|
545
562
|
}
|
|
@@ -615,35 +632,6 @@ function zodAdapter(zodSchema) {
|
|
|
615
632
|
formKey: _formKey
|
|
616
633
|
};
|
|
617
634
|
},
|
|
618
|
-
normalizeWriteValueAtPath(value, path) {
|
|
619
|
-
const candidates = path.length === 0 ? [_zodSchema] : getNestedZodSchemasAtPath(_zodSchema, path);
|
|
620
|
-
const [first] = candidates;
|
|
621
|
-
if (first === void 0) return value;
|
|
622
|
-
let current = first;
|
|
623
|
-
let result = value;
|
|
624
|
-
for (let i = 0; i < 64; i++) {
|
|
625
|
-
if (!isZodSchemaType(current, "ZodEffects")) break;
|
|
626
|
-
const def = current._def;
|
|
627
|
-
const effect = def.effect;
|
|
628
|
-
if (effect?.type !== "preprocess") break;
|
|
629
|
-
const fn = effect.transform;
|
|
630
|
-
if (typeof fn !== "function") break;
|
|
631
|
-
let next;
|
|
632
|
-
try {
|
|
633
|
-
next = fn(result);
|
|
634
|
-
} catch (cause) {
|
|
635
|
-
throw new Error(
|
|
636
|
-
`[attaform] input normalization at path "${path.join(".")}" threw \u2014 write rejected.`,
|
|
637
|
-
{ cause }
|
|
638
|
-
);
|
|
639
|
-
}
|
|
640
|
-
if (next instanceof Promise) return value;
|
|
641
|
-
result = next;
|
|
642
|
-
if (def.schema === void 0) break;
|
|
643
|
-
current = def.schema;
|
|
644
|
-
}
|
|
645
|
-
return result;
|
|
646
|
-
},
|
|
647
635
|
getDefaultAtPath(path) {
|
|
648
636
|
if (path.length === 0) {
|
|
649
637
|
return getDefaultValuesFromZodSchema(_zodSchema, true, _formKey);
|
|
@@ -774,6 +762,26 @@ function zodAdapter(zodSchema) {
|
|
|
774
762
|
leafCache.set(cacheKey, isLeaf);
|
|
775
763
|
return isLeaf;
|
|
776
764
|
},
|
|
765
|
+
isPreprocessOrCoerceLeaf(path) {
|
|
766
|
+
const cacheKey = paths.canonicalizePath(path).key;
|
|
767
|
+
const cached = preprocessOrCoerceCache.get(cacheKey);
|
|
768
|
+
if (cached !== void 0) return cached;
|
|
769
|
+
let hit = false;
|
|
770
|
+
for (let i = 0; i <= path.length && !hit; i++) {
|
|
771
|
+
const prefix = path.slice(0, i);
|
|
772
|
+
const candidates = prefix.length === 0 ? [_zodSchema] : getNestedZodSchemasAtPath(_zodSchema, prefix);
|
|
773
|
+
for (const candidate of candidates) {
|
|
774
|
+
if (!isZodSchemaType(candidate, "ZodEffects")) continue;
|
|
775
|
+
const def = candidate._def;
|
|
776
|
+
if (def.effect?.type === "preprocess") {
|
|
777
|
+
hit = true;
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
preprocessOrCoerceCache.set(cacheKey, hit);
|
|
783
|
+
return hit;
|
|
784
|
+
},
|
|
777
785
|
validateAtPath(data, path, options) {
|
|
778
786
|
const trySync = options?.sync === true;
|
|
779
787
|
if (trySync) {
|
|
@@ -863,7 +871,7 @@ function zodIssuesToValidationErrors(issues, formKey) {
|
|
|
863
871
|
code = `zod:${issue.code}`;
|
|
864
872
|
} else {
|
|
865
873
|
code = "zod:unknown";
|
|
866
|
-
if (
|
|
874
|
+
if (paths.__DEV__ && !warnedZodCodeMissing) {
|
|
867
875
|
warnedZodCodeMissing = true;
|
|
868
876
|
console.warn(
|
|
869
877
|
"[attaform] zod-v3 adapter received an issue with no string `code`; stamping `'zod:unknown'`. This usually means a custom Zod plugin emitted an issue without the standard code field."
|
|
@@ -902,7 +910,7 @@ const NO_SCHEMAS_FOUND_AT_PATH_OF_CONCRETE_SCHEMA = (path, formKey) => [
|
|
|
902
910
|
message: `Programming Error: useForm.validateAtPath failed to find 1 or more schemas corresponding to the path ${path} in the concrete schema. Does the nested schema exist on form with key '${formKey}'?`,
|
|
903
911
|
path,
|
|
904
912
|
formKey,
|
|
905
|
-
code:
|
|
913
|
+
code: injectWizard.AttaformErrorCode.PathNotFound
|
|
906
914
|
}
|
|
907
915
|
];
|
|
908
916
|
function getNestedZodSchemasAtPath(zodSchema, segments) {
|
|
@@ -1549,7 +1557,7 @@ function resolveFieldMetaAtPathV3(rootSchema, path) {
|
|
|
1549
1557
|
const target = path.length === 0 ? rootSchema : walkV3ToLeafSchema(rootSchema, path);
|
|
1550
1558
|
if (target === void 0) {
|
|
1551
1559
|
return {
|
|
1552
|
-
label:
|
|
1560
|
+
label: injectWizard.humanize(lastSegment),
|
|
1553
1561
|
description: void 0,
|
|
1554
1562
|
placeholder: void 0,
|
|
1555
1563
|
meta: Object.freeze({})
|
|
@@ -1561,7 +1569,7 @@ function resolveFieldMetaAtPathV3(rootSchema, path) {
|
|
|
1561
1569
|
const peeledDescription = peeled !== target && typeof peeled.description === "string" ? peeled.description : void 0;
|
|
1562
1570
|
const schemaDescription = targetDescription ?? peeledDescription;
|
|
1563
1571
|
return {
|
|
1564
|
-
label: payload?.label ??
|
|
1572
|
+
label: payload?.label ?? injectWizard.humanize(lastSegment),
|
|
1565
1573
|
description: payload?.description ?? schemaDescription ?? void 0,
|
|
1566
1574
|
placeholder: payload?.placeholder ?? void 0,
|
|
1567
1575
|
meta: Object.freeze({ ...payload ?? {} })
|
|
@@ -1570,25 +1578,15 @@ function resolveFieldMetaAtPathV3(rootSchema, path) {
|
|
|
1570
1578
|
|
|
1571
1579
|
function useForm(configuration) {
|
|
1572
1580
|
if (configuration === void 0 || configuration === null || configuration.schema === void 0) {
|
|
1573
|
-
throw new
|
|
1581
|
+
throw new paths.InvalidUseFormConfigError();
|
|
1574
1582
|
}
|
|
1575
1583
|
function isZodType(value) {
|
|
1576
1584
|
return typeof value === "object" && value !== null && "_def" in value;
|
|
1577
1585
|
}
|
|
1578
1586
|
const { schema } = configuration;
|
|
1579
1587
|
const abstractSchema = isZodType(schema) ? zodAdapter(schema) : schema;
|
|
1580
|
-
return
|
|
1588
|
+
return injectWizard.useAbstractForm({
|
|
1581
1589
|
...configuration,
|
|
1582
|
-
// `zodAdapter`'s constraint on its third generic is
|
|
1583
|
-
// `GetValueFormType extends TypeWithNullableDynamicKeys<FormSchema>`,
|
|
1584
|
-
// and `Schema` at this implementation overload is only constrained
|
|
1585
|
-
// by `extends z.ZodSchema<unknown>` — too loose for
|
|
1586
|
-
// `z.output<UnwrapZodObject<typeof schema>>` to resolve concretely.
|
|
1587
|
-
// Pass `TypeWithNullableDynamicKeys<typeof schema>` here purely to
|
|
1588
|
-
// satisfy the adapter's constraint at the structural-cast layer.
|
|
1589
|
-
// The PUBLIC signature's `GetValueFormType` default (line 67) is
|
|
1590
|
-
// what consumers see — that's `z.output<UnwrapZodObject<Schema>>`,
|
|
1591
|
-
// matching the docstring promise. Runtime is unaffected either way.
|
|
1592
1590
|
schema: abstractSchema,
|
|
1593
1591
|
defaultValues: configuration.defaultValues
|
|
1594
1592
|
});
|
|
@@ -1599,4 +1597,4 @@ exports.isZodSchemaType = isZodSchemaType;
|
|
|
1599
1597
|
exports.useForm = useForm;
|
|
1600
1598
|
exports.withMeta = withMeta;
|
|
1601
1599
|
exports.zodAdapter = zodAdapter;
|
|
1602
|
-
//# sourceMappingURL=attaform.
|
|
1600
|
+
//# sourceMappingURL=attaform.DUHru0OF.cjs.map
|