attaform 0.26.0 → 0.27.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/README.md +21 -11
- package/bin/attaform.mjs +125 -0
- package/dist/abstract.cjs +47 -0
- package/dist/abstract.cjs.map +1 -0
- package/dist/abstract.d.cts +42 -0
- package/dist/abstract.d.mts +42 -0
- package/dist/abstract.d.ts +42 -0
- package/dist/abstract.mjs +4 -0
- package/dist/abstract.mjs.map +1 -0
- package/dist/chunks/devtools.cjs +2 -2
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +1 -1
- package/dist/chunks/fingerprint2.cjs +1 -1
- package/dist/chunks/fingerprint2.mjs +1 -1
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.cjs.map +1 -1
- package/dist/esbuild.d.cts +3 -3
- package/dist/esbuild.d.mts +3 -3
- package/dist/esbuild.d.ts +3 -3
- package/dist/esbuild.mjs +2 -2
- package/dist/esbuild.mjs.map +1 -1
- package/dist/index.cjs +41 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -282
- package/dist/index.d.mts +194 -282
- package/dist/index.d.ts +194 -282
- package/dist/index.mjs +4 -25
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.cjs +3 -1
- package/dist/nuxt.cjs.map +1 -1
- package/dist/nuxt.d.cts +17 -4
- package/dist/nuxt.d.mts +17 -4
- package/dist/nuxt.d.ts +17 -4
- package/dist/nuxt.mjs +4 -2
- package/dist/nuxt.mjs.map +1 -1
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.cts +3 -3
- package/dist/rollup.d.mts +3 -3
- package/dist/rollup.d.ts +3 -3
- package/dist/rollup.mjs +2 -2
- package/dist/rollup.mjs.map +1 -1
- package/dist/rspack.cjs +1 -1
- package/dist/rspack.d.cts +1 -1
- package/dist/rspack.d.mts +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.mjs +1 -1
- package/dist/runtime/plugins/attaform.cjs +4 -5
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +1 -2
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/{attaform.BRzKBj2g.cjs → attaform.8tFZu1Ub.cjs} +2 -2
- package/dist/shared/{attaform.BRzKBj2g.cjs.map → attaform.8tFZu1Ub.cjs.map} +1 -1
- package/dist/shared/{attaform.k9V0py0s.mjs → attaform.BERt5YMU.mjs} +2 -2
- package/dist/shared/{attaform.k9V0py0s.mjs.map → attaform.BERt5YMU.mjs.map} +1 -1
- package/dist/shared/{attaform.DSOIz08n.mjs → attaform.BceJrhQ7.mjs} +5 -5
- package/dist/shared/{attaform.DSOIz08n.mjs.map → attaform.BceJrhQ7.mjs.map} +1 -1
- package/dist/shared/{attaform.DBNjHgNj.d.cts → attaform.C3WnCDXz.d.cts} +11 -9
- package/dist/shared/{attaform.DBNjHgNj.d.mts → attaform.C3WnCDXz.d.mts} +11 -9
- package/dist/shared/{attaform.DBNjHgNj.d.ts → attaform.C3WnCDXz.d.ts} +11 -9
- package/dist/shared/{attaform.DuzQYscR.d.mts → attaform.C9fPTxjB.d.cts} +5 -5
- package/dist/shared/{attaform.DuzQYscR.d.ts → attaform.C9fPTxjB.d.mts} +5 -5
- package/dist/shared/{attaform.DuzQYscR.d.cts → attaform.C9fPTxjB.d.ts} +5 -5
- package/dist/shared/{attaform.Be5otUVw.d.ts → attaform.CC_y1_Ej.d.ts} +33 -33
- package/dist/shared/{attaform.ceYeVkjn.d.ts → attaform.CEXUlUkc.d.ts} +1579 -1192
- package/dist/shared/{attaform.tZ0YKisf.cjs → attaform.C__F01CE.cjs} +15 -15
- package/dist/shared/{attaform.tZ0YKisf.cjs.map → attaform.C__F01CE.cjs.map} +1 -1
- package/dist/shared/{attaform.BPl-ECRT.cjs → attaform.Co5LNRnv.cjs} +162 -129
- package/dist/shared/attaform.Co5LNRnv.cjs.map +1 -0
- package/dist/shared/{attaform.B71rfNL5.d.mts → attaform.CpXHK60W.d.cts} +33 -33
- package/dist/shared/{attaform.BFfY7HRI.d.cts → attaform.CvVYOvZF.d.mts} +33 -33
- package/dist/shared/{attaform.BoYqnIPI.mjs → attaform.CyQxTOdX.mjs} +55 -36
- package/dist/shared/attaform.CyQxTOdX.mjs.map +1 -0
- package/dist/shared/{attaform.CEY_WLRJ.d.mts → attaform.D99pd7JG.d.cts} +1579 -1192
- package/dist/shared/{attaform.CXVmZtFq.mjs → attaform.DDAmSFnl.mjs} +4 -4
- package/dist/shared/{attaform.CXVmZtFq.mjs.map → attaform.DDAmSFnl.mjs.map} +1 -1
- package/dist/shared/{attaform.Du9RZp8m.cjs → attaform.DQT7_-FO.cjs} +272 -252
- package/dist/shared/attaform.DQT7_-FO.cjs.map +1 -0
- package/dist/shared/{attaform.DGhIix5D.mjs → attaform.Da8EdI2t.mjs} +160 -129
- package/dist/shared/attaform.Da8EdI2t.mjs.map +1 -0
- package/dist/shared/{attaform.Cs0UZ7q6.cjs → attaform.DhVgG2jh.cjs} +16 -16
- package/dist/shared/{attaform.Cs0UZ7q6.cjs.map → attaform.DhVgG2jh.cjs.map} +1 -1
- package/dist/shared/{attaform.sHkHv_98.mjs → attaform.DhnPb6nK.mjs} +6 -3
- package/dist/shared/attaform.DhnPb6nK.mjs.map +1 -0
- package/dist/shared/attaform.DkD0DR7R.mjs +42 -0
- package/dist/shared/attaform.DkD0DR7R.mjs.map +1 -0
- package/dist/shared/{attaform.CSXDW2tO.mjs → attaform.DlSu08F5.mjs} +4 -4
- package/dist/shared/{attaform.CSXDW2tO.mjs.map → attaform.DlSu08F5.mjs.map} +1 -1
- package/dist/shared/{attaform.LEWUFqUw.cjs → attaform.DoQm_Vkd.cjs} +7 -3
- package/dist/shared/attaform.DoQm_Vkd.cjs.map +1 -0
- package/dist/shared/{attaform.BQflyVOL.cjs → attaform.Drsi43GG.cjs} +19 -19
- package/dist/shared/{attaform.BQflyVOL.cjs.map → attaform.Drsi43GG.cjs.map} +1 -1
- package/dist/shared/attaform.K6Thc6By.cjs +46 -0
- package/dist/shared/attaform.K6Thc6By.cjs.map +1 -0
- package/dist/shared/{attaform.Vp2-CWZB.mjs → attaform.KvlEedlF.mjs} +3 -3
- package/dist/shared/{attaform.Vp2-CWZB.mjs.map → attaform.KvlEedlF.mjs.map} +1 -1
- package/dist/shared/{attaform.BRGIpZo4.cjs → attaform.RaTzp1WF.cjs} +3 -3
- package/dist/shared/attaform.RaTzp1WF.cjs.map +1 -0
- package/dist/shared/{attaform.MgaYKlPP.d.cts → attaform.kBkYlKP_.d.mts} +1579 -1192
- package/dist/shared/{attaform.C3Doa9Pt.mjs → attaform.v0fQtWyA.mjs} +3 -3
- package/dist/shared/attaform.v0fQtWyA.mjs.map +1 -0
- package/dist/shared/{attaform.ZXZ6dH72.cjs → attaform.yUrz7C2z.cjs} +3 -3
- package/dist/shared/{attaform.ZXZ6dH72.cjs.map → attaform.yUrz7C2z.cjs.map} +1 -1
- package/dist/transforms.cjs +1 -1
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +21 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +70 -17
- package/dist/vite.d.mts +70 -17
- package/dist/vite.d.ts +70 -17
- package/dist/vite.mjs +20 -4
- package/dist/vite.mjs.map +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.mjs +1 -1
- package/dist/zod-v3.cjs +41 -10
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +5 -5
- package/dist/zod-v3.d.mts +5 -5
- package/dist/zod-v3.d.ts +5 -5
- package/dist/zod-v3.mjs +4 -2
- package/dist/zod-v3.mjs.map +1 -1
- package/dist/zod-v4.cjs +41 -10
- package/dist/zod-v4.cjs.map +1 -1
- package/dist/zod-v4.d.cts +7 -7
- package/dist/zod-v4.d.mts +7 -7
- package/dist/zod-v4.d.ts +7 -7
- package/dist/zod-v4.mjs +4 -2
- package/dist/zod-v4.mjs.map +1 -1
- package/dist/zod.cjs +44 -49
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +6 -248
- package/dist/zod.d.mts +6 -248
- package/dist/zod.d.ts +6 -248
- package/dist/zod.mjs +4 -42
- package/dist/zod.mjs.map +1 -1
- package/package.json +12 -2
- package/skills/attaform/SKILL.md +128 -0
- package/skills/attaform/references/custom-components.md +72 -0
- package/skills/attaform/references/errors.md +62 -0
- package/skills/attaform/references/ssr.md +26 -0
- package/skills/attaform/references/validation.md +40 -0
- package/skills/attaform/references/wizards.md +104 -0
- package/dist/shared/attaform.55hFR_cl.d.ts +0 -97
- package/dist/shared/attaform.BPl-ECRT.cjs.map +0 -1
- package/dist/shared/attaform.BRGIpZo4.cjs.map +0 -1
- package/dist/shared/attaform.BoYqnIPI.mjs.map +0 -1
- package/dist/shared/attaform.C3Doa9Pt.mjs.map +0 -1
- package/dist/shared/attaform.D51IwDtP.cjs +0 -39
- package/dist/shared/attaform.D51IwDtP.cjs.map +0 -1
- package/dist/shared/attaform.DGhIix5D.mjs.map +0 -1
- package/dist/shared/attaform.DJRz_bzM.d.cts +0 -97
- package/dist/shared/attaform.Du9RZp8m.cjs.map +0 -1
- package/dist/shared/attaform.JPsaqjLl.d.mts +0 -97
- package/dist/shared/attaform.LEWUFqUw.cjs.map +0 -1
- package/dist/shared/attaform.NqYEzRcM.mjs +0 -35
- package/dist/shared/attaform.NqYEzRcM.mjs.map +0 -1
- package/dist/shared/attaform.sHkHv_98.mjs.map +0 -1
- package/dist/shared/{attaform.DdjDqTah.d.ts → attaform.DRUT703x.d.cts} +14 -14
- package/dist/shared/{attaform.DdjDqTah.d.cts → attaform.DRUT703x.d.mts} +14 -14
- package/dist/shared/{attaform.DdjDqTah.d.mts → attaform.DRUT703x.d.ts} +14 -14
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const
|
|
5
|
-
const registerProtocol = require('./attaform.
|
|
4
|
+
const devtoolsShared = require('./attaform.Co5LNRnv.cjs');
|
|
5
|
+
const registerProtocol = require('./attaform.yUrz7C2z.cjs');
|
|
6
6
|
|
|
7
7
|
function safeAssign(target, key, value) {
|
|
8
8
|
if (key === "__proto__") {
|
|
@@ -31,7 +31,7 @@ function safeOwnHas(target, key) {
|
|
|
31
31
|
return Object.prototype.hasOwnProperty.call(target, key);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const NOT_FOUND = Symbol("NOT_FOUND");
|
|
34
|
+
const NOT_FOUND = /* @__PURE__ */ Symbol("NOT_FOUND");
|
|
35
35
|
function descendStep(value, segment) {
|
|
36
36
|
if (value === null || value === void 0) return NOT_FOUND;
|
|
37
37
|
if (typeof value !== "object") return NOT_FOUND;
|
|
@@ -434,7 +434,7 @@ function applyChangedKeys(target, source, arrayOpPath, currentPath) {
|
|
|
434
434
|
const targetIsArray = Array.isArray(target);
|
|
435
435
|
const sourceIsArray = Array.isArray(source);
|
|
436
436
|
if (targetIsArray !== sourceIsArray) return false;
|
|
437
|
-
const ROOT_SENTINEL = Symbol.for("attaform.applyChangedKeys.rootMismatch");
|
|
437
|
+
const ROOT_SENTINEL = /* @__PURE__ */ Symbol.for("attaform.applyChangedKeys.rootMismatch");
|
|
438
438
|
const changedFirstSegments = /* @__PURE__ */ new Set();
|
|
439
439
|
diffAndApply(target, source, [], (patch) => {
|
|
440
440
|
if (patch.path.length === 0) {
|
|
@@ -447,7 +447,7 @@ function applyChangedKeys(target, source, arrayOpPath, currentPath) {
|
|
|
447
447
|
if (targetIsArray) {
|
|
448
448
|
const t = target;
|
|
449
449
|
const s = source;
|
|
450
|
-
if (arrayOpPath === null ||
|
|
450
|
+
if (arrayOpPath === null || devtoolsShared.pathsEqual(currentPath, arrayOpPath)) {
|
|
451
451
|
if (t.length > s.length) t.length = s.length;
|
|
452
452
|
for (const idx of changedFirstSegments) {
|
|
453
453
|
if (typeof idx === "symbol") continue;
|
|
@@ -463,7 +463,7 @@ function applyChangedKeys(target, source, arrayOpPath, currentPath) {
|
|
|
463
463
|
const childPath = appendSegment(currentPath, i);
|
|
464
464
|
const curEl = t[i];
|
|
465
465
|
const nextEl = s[i];
|
|
466
|
-
if (
|
|
466
|
+
if (devtoolsShared.isPathPrefix(childPath, arrayOpPath) && isDescendable(curEl) && isDescendable(nextEl) && applyChangedKeys(curEl, nextEl, arrayOpPath, childPath)) {
|
|
467
467
|
continue;
|
|
468
468
|
}
|
|
469
469
|
t[i] = nextEl;
|
|
@@ -671,7 +671,7 @@ function normalizeNumericOption(config) {
|
|
|
671
671
|
const { value, source, allowInfinity, min, defaultValue } = config;
|
|
672
672
|
if (allowInfinity && value === Infinity) return Infinity;
|
|
673
673
|
if (typeof value !== "number" || Number.isNaN(value) || value === Infinity || value === -Infinity) {
|
|
674
|
-
if (
|
|
674
|
+
if (devtoolsShared.__DEV__) {
|
|
675
675
|
const acceptedDescription = allowInfinity ? "a non-negative integer or Infinity" : "a non-negative finite integer";
|
|
676
676
|
console.warn(
|
|
677
677
|
`[attaform] ${source} must be ${acceptedDescription}; got ${String(value)}. Falling back to ${String(defaultValue)}.`
|
|
@@ -750,7 +750,7 @@ function buildFieldStateAccessor(state, formInstanceId, getFormMetaBase, options
|
|
|
750
750
|
const cache = /* @__PURE__ */ new Map();
|
|
751
751
|
const predicate = options?.getDisplayState;
|
|
752
752
|
return function getFieldState(pathInput) {
|
|
753
|
-
const { segments, key } =
|
|
753
|
+
const { segments, key } = devtoolsShared.canonicalizePath(pathInput);
|
|
754
754
|
const cached = cache.get(key);
|
|
755
755
|
if (cached !== void 0) return cached;
|
|
756
756
|
const c = vue.computed(
|
|
@@ -887,7 +887,7 @@ function buildContainerFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
887
887
|
const blurredLeafSegments = [];
|
|
888
888
|
const descendantLeaves = [];
|
|
889
889
|
visitActiveLeafPaths(value, segments, (leafSegments) => {
|
|
890
|
-
const { key: leafKey } =
|
|
890
|
+
const { key: leafKey } = devtoolsShared.keyForSegments(leafSegments);
|
|
891
891
|
const entry = state.originals.get(leafKey);
|
|
892
892
|
if (entry === void 0) return;
|
|
893
893
|
descendantLeaves.push({ key: leafKey, segments: entry.segments });
|
|
@@ -942,7 +942,7 @@ function buildContainerFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
942
942
|
if (ePath.length === segments.length && ePath.every((s, i) => s === segments[i])) return false;
|
|
943
943
|
if (submissionAttempts > 0) return true;
|
|
944
944
|
if (ePath.length === 1 && ePath[0] === "") return blurredAfterInteraction;
|
|
945
|
-
return blurredLeafSegments.some((s) =>
|
|
945
|
+
return blurredLeafSegments.some((s) => devtoolsShared.isPathPrefix(ePath, s));
|
|
946
946
|
});
|
|
947
947
|
if (!asyncPending && state.pathHasAsyncValidation(segments)) asyncPending = true;
|
|
948
948
|
if ((state.fieldValidationCounts.get(key) ?? 0) > 0) {
|
|
@@ -1047,7 +1047,7 @@ function decorateWithDerivedProps(base, state, getFormMetaBase, key, validatingS
|
|
|
1047
1047
|
try {
|
|
1048
1048
|
machine = state.displayEngine.resolve(key, ctx, predicate);
|
|
1049
1049
|
} catch (err) {
|
|
1050
|
-
if (
|
|
1050
|
+
if (devtoolsShared.__DEV__ && !warnedDisplayStatePredicates.has(predicate)) {
|
|
1051
1051
|
warnedDisplayStatePredicates.add(predicate);
|
|
1052
1052
|
console.warn(
|
|
1053
1053
|
"[attaform] custom getDisplayState threw \u2014 falling back to defaultDisplayState. Subsequent throws from the same predicate will not warn again.",
|
|
@@ -1076,9 +1076,9 @@ function aggregateErrorsAt(state, prefix) {
|
|
|
1076
1076
|
const collect = (errs) => {
|
|
1077
1077
|
for (const [pathKey, list] of errs) {
|
|
1078
1078
|
if (list.length === 0) continue;
|
|
1079
|
-
const segs =
|
|
1079
|
+
const segs = devtoolsShared.segmentsForPathKey(pathKey);
|
|
1080
1080
|
if (segs === null) continue;
|
|
1081
|
-
if (!
|
|
1081
|
+
if (!devtoolsShared.isPathPrefix(prefix, segs)) continue;
|
|
1082
1082
|
if (segs.length > 0 && !hasAtPath(formValue, segs)) continue;
|
|
1083
1083
|
const ordinal = state.ensurePathOrdinal(pathKey);
|
|
1084
1084
|
const existing = buckets.get(ordinal);
|
|
@@ -1120,7 +1120,7 @@ function isArrayPath(state, segments) {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
|
|
1122
1122
|
function warnReadOnly(surface, action, key) {
|
|
1123
|
-
if (!
|
|
1123
|
+
if (!devtoolsShared.__DEV__) return;
|
|
1124
1124
|
const phrase = action === "write" ? `write to "${String(key)}"` : `${action} of "${String(key)}"`;
|
|
1125
1125
|
console.warn(
|
|
1126
1126
|
`[attaform] ${surface} is read-only \u2014 ${phrase} was ignored. Mutate the form via setValue / the directive / field-array helpers instead.`
|
|
@@ -1204,7 +1204,7 @@ function buildSurfaceProxy(opts) {
|
|
|
1204
1204
|
}
|
|
1205
1205
|
return opts.resolveCallTarget(segments);
|
|
1206
1206
|
}
|
|
1207
|
-
const { segments: argSegs } =
|
|
1207
|
+
const { segments: argSegs } = devtoolsShared.canonicalizePath(arg);
|
|
1208
1208
|
return opts.resolveCallTarget(argSegs);
|
|
1209
1209
|
},
|
|
1210
1210
|
get(_, key) {
|
|
@@ -1406,14 +1406,14 @@ function buildErrorsProxy(state) {
|
|
|
1406
1406
|
const merged = [];
|
|
1407
1407
|
if (isContainerSelfAccess) {
|
|
1408
1408
|
const containerPath = path.slice(0, -1);
|
|
1409
|
-
const containerKey =
|
|
1410
|
-
const literalKey =
|
|
1409
|
+
const containerKey = devtoolsShared.canonicalizePath(containerPath).key;
|
|
1410
|
+
const literalKey = devtoolsShared.canonicalizePath(path).key;
|
|
1411
1411
|
const active2 = hasAtPath(state.form.value, containerPath);
|
|
1412
1412
|
collectAtKey(containerKey, active2, merged);
|
|
1413
1413
|
if (literalKey !== containerKey) collectAtKey(literalKey, active2, merged);
|
|
1414
1414
|
return merged;
|
|
1415
1415
|
}
|
|
1416
|
-
const { key } =
|
|
1416
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
1417
1417
|
const active = hasAtPath(state.form.value, path);
|
|
1418
1418
|
collectAtKey(key, active, merged);
|
|
1419
1419
|
return merged;
|
|
@@ -1477,10 +1477,10 @@ function errorAwareContainerKeys(state, segments) {
|
|
|
1477
1477
|
const walk = (store, applyActivePathFilter) => {
|
|
1478
1478
|
for (const [pathKey, errors] of store) {
|
|
1479
1479
|
if (errors.length === 0) continue;
|
|
1480
|
-
const decoded =
|
|
1480
|
+
const decoded = devtoolsShared.segmentsForPathKey(pathKey);
|
|
1481
1481
|
if (decoded === null) continue;
|
|
1482
1482
|
if (decoded.length <= segments.length) continue;
|
|
1483
|
-
if (!
|
|
1483
|
+
if (!devtoolsShared.isPathPrefix(segments, decoded)) continue;
|
|
1484
1484
|
if (applyActivePathFilter && !hasAtPath(formValue, decoded)) continue;
|
|
1485
1485
|
const nextSeg = decoded[segments.length];
|
|
1486
1486
|
keys.add(typeof nextSeg === "number" ? String(nextSeg) : nextSeg);
|
|
@@ -1497,10 +1497,10 @@ function materializeErrors(state, containerSegments) {
|
|
|
1497
1497
|
const collect = (store, applyActivePathFilter) => {
|
|
1498
1498
|
entries: for (const [pathKey, errors] of store) {
|
|
1499
1499
|
if (errors.length === 0) continue;
|
|
1500
|
-
const fullPath =
|
|
1500
|
+
const fullPath = devtoolsShared.segmentsForPathKey(pathKey);
|
|
1501
1501
|
if (fullPath === null) continue;
|
|
1502
1502
|
if (fullPath.length === 0) {
|
|
1503
|
-
if (containerSegments.length === 0) placeAt(tree, [
|
|
1503
|
+
if (containerSegments.length === 0) placeAt(tree, [devtoolsShared.ROOT_PATH_KEY], errors);
|
|
1504
1504
|
continue;
|
|
1505
1505
|
}
|
|
1506
1506
|
if (fullPath.length < containerSegments.length) continue;
|
|
@@ -1551,12 +1551,12 @@ function placeAt(tree, path, errors) {
|
|
|
1551
1551
|
|
|
1552
1552
|
function buildFieldArrayApi(state) {
|
|
1553
1553
|
function readArray(path) {
|
|
1554
|
-
const segments =
|
|
1554
|
+
const segments = devtoolsShared.canonicalizePath(path).segments;
|
|
1555
1555
|
const current = state.getValueAtPath(segments);
|
|
1556
1556
|
return Array.isArray(current) ? current.slice() : [];
|
|
1557
1557
|
}
|
|
1558
1558
|
function writeArray(path, next, arrayOp) {
|
|
1559
|
-
const { segments } =
|
|
1559
|
+
const { segments } = devtoolsShared.canonicalizePath(path);
|
|
1560
1560
|
const meta = {
|
|
1561
1561
|
...arrayOp !== void 0 ? { arrayOp } : {}
|
|
1562
1562
|
};
|
|
@@ -1710,7 +1710,7 @@ function buildFieldStateProxy(state, formInstanceId, getFormMetaBase, options) {
|
|
|
1710
1710
|
// module), which would violate the documented "writes are
|
|
1711
1711
|
// ignored" contract. Mirrors `values-proxy` / `wizard-statuses-proxy`.
|
|
1712
1712
|
set: (_, key) => {
|
|
1713
|
-
if (
|
|
1713
|
+
if (devtoolsShared.__DEV__) {
|
|
1714
1714
|
console.warn(
|
|
1715
1715
|
`[attaform] form.fields(path) is read-only \u2014 write to "${String(key)}" was ignored. Use form.setValue / the directive / field-array helpers instead.`
|
|
1716
1716
|
);
|
|
@@ -1718,7 +1718,7 @@ function buildFieldStateProxy(state, formInstanceId, getFormMetaBase, options) {
|
|
|
1718
1718
|
return true;
|
|
1719
1719
|
},
|
|
1720
1720
|
deleteProperty: (_, key) => {
|
|
1721
|
-
if (
|
|
1721
|
+
if (devtoolsShared.__DEV__) {
|
|
1722
1722
|
console.warn(
|
|
1723
1723
|
`[attaform] form.fields(path) is read-only \u2014 delete of "${String(key)}" was ignored.`
|
|
1724
1724
|
);
|
|
@@ -1726,7 +1726,7 @@ function buildFieldStateProxy(state, formInstanceId, getFormMetaBase, options) {
|
|
|
1726
1726
|
return true;
|
|
1727
1727
|
},
|
|
1728
1728
|
defineProperty: (_, key) => {
|
|
1729
|
-
if (
|
|
1729
|
+
if (devtoolsShared.__DEV__) {
|
|
1730
1730
|
console.warn(
|
|
1731
1731
|
`[attaform] form.fields(path) is read-only \u2014 define of "${String(key)}" was ignored.`
|
|
1732
1732
|
);
|
|
@@ -1781,7 +1781,7 @@ function walk$1(value, basePath, schema, snapshotFieldStateAt) {
|
|
|
1781
1781
|
return result;
|
|
1782
1782
|
}
|
|
1783
1783
|
|
|
1784
|
-
const warnedNoScopeStores =
|
|
1784
|
+
const warnedNoScopeStores = devtoolsShared.__DEV__ ? /* @__PURE__ */ new WeakSet() : null;
|
|
1785
1785
|
function isErrorInputLike(value) {
|
|
1786
1786
|
if (value instanceof Error) return true;
|
|
1787
1787
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -1792,19 +1792,19 @@ function deriveSubmitErrors(err, formKey) {
|
|
|
1792
1792
|
if (Array.isArray(err) && err.length > 0 && err.every(isErrorInputLike)) {
|
|
1793
1793
|
return {
|
|
1794
1794
|
entries: err.map(
|
|
1795
|
-
(item) =>
|
|
1795
|
+
(item) => devtoolsShared.normalizeErrorInput(item, void 0, formKey, AttaformErrorCode.SubmitError)
|
|
1796
1796
|
),
|
|
1797
1797
|
messageless: false
|
|
1798
1798
|
};
|
|
1799
1799
|
}
|
|
1800
1800
|
if (isErrorInputLike(err)) {
|
|
1801
1801
|
return {
|
|
1802
|
-
entries: [
|
|
1802
|
+
entries: [devtoolsShared.normalizeErrorInput(err, void 0, formKey, AttaformErrorCode.SubmitError)],
|
|
1803
1803
|
messageless: false
|
|
1804
1804
|
};
|
|
1805
1805
|
}
|
|
1806
1806
|
return {
|
|
1807
|
-
entries: [
|
|
1807
|
+
entries: [devtoolsShared.normalizeErrorInput({}, void 0, formKey, AttaformErrorCode.SubmitError)],
|
|
1808
1808
|
messageless: true
|
|
1809
1809
|
};
|
|
1810
1810
|
}
|
|
@@ -1859,7 +1859,7 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
1859
1859
|
});
|
|
1860
1860
|
if (vue.getCurrentScope() !== void 0) {
|
|
1861
1861
|
vue.onScopeDispose(stop);
|
|
1862
|
-
} else if (
|
|
1862
|
+
} else if (devtoolsShared.__DEV__ && warnedNoScopeStores !== null && !warnedNoScopeStores.has(state)) {
|
|
1863
1863
|
warnedNoScopeStores.add(state);
|
|
1864
1864
|
console.warn(
|
|
1865
1865
|
"[attaform] validate() called outside a Vue effect scope; its reactive watcher will leak until the form is garbage-collected. Fix: call validate() inside setup() / a child component, or wrap the call in `effectScope().run(...)`."
|
|
@@ -1976,7 +1976,7 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
1976
1976
|
try {
|
|
1977
1977
|
await onError(merged.errors);
|
|
1978
1978
|
} catch (cause) {
|
|
1979
|
-
throw new
|
|
1979
|
+
throw new devtoolsShared.SubmitErrorHandlerError("User-provided onError threw", { cause });
|
|
1980
1980
|
}
|
|
1981
1981
|
}
|
|
1982
1982
|
return;
|
|
@@ -1997,12 +1997,12 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
1997
1997
|
state.emitSubmitSuccess();
|
|
1998
1998
|
} catch (err) {
|
|
1999
1999
|
if (state.submissionGeneration.value === genAtEntry) {
|
|
2000
|
-
state.submitError.value =
|
|
2001
|
-
if (!(err instanceof
|
|
2000
|
+
state.submitError.value = devtoolsShared.toError(err);
|
|
2001
|
+
if (!(err instanceof devtoolsShared.SubmitErrorHandlerError)) {
|
|
2002
2002
|
const { entries, messageless } = deriveSubmitErrors(err, state.formKey);
|
|
2003
2003
|
const byPath = /* @__PURE__ */ new Map();
|
|
2004
2004
|
for (const entry of entries) {
|
|
2005
|
-
const { key } =
|
|
2005
|
+
const { key } = devtoolsShared.canonicalizePath(entry.path);
|
|
2006
2006
|
const bucket = byPath.get(key);
|
|
2007
2007
|
if (bucket === void 0) byPath.set(key, { segments: entry.path, entries: [entry] });
|
|
2008
2008
|
else bucket.entries.push(entry);
|
|
@@ -2011,7 +2011,7 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
2011
2011
|
state.setUserErrorsForPath(segments, bucket);
|
|
2012
2012
|
}
|
|
2013
2013
|
applyInvalidSubmitPolicy(state, formInstanceId, invalidPolicy);
|
|
2014
|
-
if (
|
|
2014
|
+
if (devtoolsShared.__DEV__ && messageless) {
|
|
2015
2015
|
console.warn(
|
|
2016
2016
|
"[attaform] handleSubmit callback threw a non-Error value; throw an Error or a ValidationError ({ message, path? }) so the failure surfaces with a usable message."
|
|
2017
2017
|
);
|
|
@@ -2034,7 +2034,7 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
2034
2034
|
return { validate, validateAsync, parse, handleSubmit };
|
|
2035
2035
|
}
|
|
2036
2036
|
function toSegments(pathInput) {
|
|
2037
|
-
return
|
|
2037
|
+
return devtoolsShared.canonicalizePath(pathInput).segments;
|
|
2038
2038
|
}
|
|
2039
2039
|
function settled(response) {
|
|
2040
2040
|
if (response.success) {
|
|
@@ -2058,7 +2058,7 @@ function collectScopedBlankErrors(state, scope) {
|
|
|
2058
2058
|
const errors = [];
|
|
2059
2059
|
for (const [pathKey, entries] of derived) {
|
|
2060
2060
|
if (scope !== void 0) {
|
|
2061
|
-
const segments =
|
|
2061
|
+
const segments = devtoolsShared.segmentsForPathKey(pathKey);
|
|
2062
2062
|
if (segments === null) continue;
|
|
2063
2063
|
if (!pathStartsWith(segments, scope)) continue;
|
|
2064
2064
|
}
|
|
@@ -2089,7 +2089,7 @@ function applyInvalidSubmitPolicy(state, formInstanceId, policy) {
|
|
|
2089
2089
|
target.element.focus({ preventScroll: true, focusVisible: true });
|
|
2090
2090
|
}
|
|
2091
2091
|
|
|
2092
|
-
const warnedRejections =
|
|
2092
|
+
const warnedRejections = devtoolsShared.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
|
|
2093
2093
|
function shouldWarnOnce$1(store, key) {
|
|
2094
2094
|
if (warnedRejections === null) return false;
|
|
2095
2095
|
let set = warnedRejections.get(store);
|
|
@@ -2163,7 +2163,7 @@ function walk(schema, store, path, value) {
|
|
|
2163
2163
|
return true;
|
|
2164
2164
|
}
|
|
2165
2165
|
function reportRejection(store, path, kind, accepted) {
|
|
2166
|
-
if (!
|
|
2166
|
+
if (!devtoolsShared.__DEV__) return;
|
|
2167
2167
|
const dotted = path.map((s) => String(s)).join(".") || "(root)";
|
|
2168
2168
|
const key = `${dotted}::${kind}`;
|
|
2169
2169
|
if (!shouldWarnOnce$1(store, key)) return;
|
|
@@ -2237,13 +2237,13 @@ function indexRules(rules) {
|
|
|
2237
2237
|
for (const entry of rules) {
|
|
2238
2238
|
const candidate = entry;
|
|
2239
2239
|
if (candidate === null || typeof candidate !== "object" || typeof candidate.transform !== "function") {
|
|
2240
|
-
if (
|
|
2240
|
+
if (devtoolsShared.__DEV__) {
|
|
2241
2241
|
console.warn("[attaform] coercion entry missing or invalid `transform` \u2014 skipped.");
|
|
2242
2242
|
}
|
|
2243
2243
|
continue;
|
|
2244
2244
|
}
|
|
2245
2245
|
const key = `${entry.input}->${entry.output}`;
|
|
2246
|
-
if (idx.has(key) &&
|
|
2246
|
+
if (idx.has(key) && devtoolsShared.__DEV__) {
|
|
2247
2247
|
console.warn(`[attaform] duplicate coercion rule for '${key}' \u2014 last entry wins.`);
|
|
2248
2248
|
}
|
|
2249
2249
|
idx.set(key, entry);
|
|
@@ -2272,7 +2272,7 @@ function pickScalarTarget(accepted) {
|
|
|
2272
2272
|
if (accepted.has("bigint")) return "bigint";
|
|
2273
2273
|
return null;
|
|
2274
2274
|
}
|
|
2275
|
-
const warnedCoerce =
|
|
2275
|
+
const warnedCoerce = devtoolsShared.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
|
|
2276
2276
|
const sharedWarnStore = {};
|
|
2277
2277
|
function shouldWarnOnce(key) {
|
|
2278
2278
|
if (warnedCoerce === null) return false;
|
|
@@ -2297,7 +2297,7 @@ function coerceScalar(value, accepted, index) {
|
|
|
2297
2297
|
try {
|
|
2298
2298
|
result = entry.transform(value);
|
|
2299
2299
|
} catch (err) {
|
|
2300
|
-
if (
|
|
2300
|
+
if (devtoolsShared.__DEV__ && shouldWarnOnce(`${entry.input}->${entry.output}::throw`)) {
|
|
2301
2301
|
console.warn(
|
|
2302
2302
|
`[attaform] coercion '${entry.input}->${entry.output}' threw \u2014 write passes through.`,
|
|
2303
2303
|
err
|
|
@@ -2308,7 +2308,7 @@ function coerceScalar(value, accepted, index) {
|
|
|
2308
2308
|
if (!result.coerced) return value;
|
|
2309
2309
|
const returnedKind = slimKindOf(result.value);
|
|
2310
2310
|
if (returnedKind !== entry.output) {
|
|
2311
|
-
if (
|
|
2311
|
+
if (devtoolsShared.__DEV__ && shouldWarnOnce(`${entry.input}->${entry.output}::wrong-kind:${returnedKind}`)) {
|
|
2312
2312
|
console.warn(
|
|
2313
2313
|
`[attaform] coercion '${entry.input}->${entry.output}' produced a ${returnedKind} \u2014 write passes through.`
|
|
2314
2314
|
);
|
|
@@ -2316,7 +2316,7 @@ function coerceScalar(value, accepted, index) {
|
|
|
2316
2316
|
return value;
|
|
2317
2317
|
}
|
|
2318
2318
|
if (entry.output === "number" && !Number.isFinite(result.value)) {
|
|
2319
|
-
if (
|
|
2319
|
+
if (devtoolsShared.__DEV__ && shouldWarnOnce(`${entry.input}->${entry.output}::nan`)) {
|
|
2320
2320
|
console.warn(
|
|
2321
2321
|
`[attaform] coercion '${entry.input}->${entry.output}' produced a non-finite number \u2014 write passes through.`
|
|
2322
2322
|
);
|
|
@@ -2359,7 +2359,7 @@ function coerceValue(value, accepted, elementAccepted, index) {
|
|
|
2359
2359
|
|
|
2360
2360
|
const warnedMultiRootHosts = /* @__PURE__ */ new Set();
|
|
2361
2361
|
const EMPTY_TRANSFORMS = Object.freeze([]);
|
|
2362
|
-
const attaformListenersSymbol = Symbol.for("attaform:focus-listeners");
|
|
2362
|
+
const attaformListenersSymbol = /* @__PURE__ */ Symbol.for("attaform:focus-listeners");
|
|
2363
2363
|
function attachFocusListeners(state, segments, element, instanceMeta) {
|
|
2364
2364
|
const target = element;
|
|
2365
2365
|
if (target[attaformListenersSymbol] !== void 0) return;
|
|
@@ -2394,7 +2394,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2394
2394
|
};
|
|
2395
2395
|
const lastTypedFormByPath = /* @__PURE__ */ new Map();
|
|
2396
2396
|
return function register(pathInput, options) {
|
|
2397
|
-
const { segments, key: pathKey } =
|
|
2397
|
+
const { segments, key: pathKey } = devtoolsShared.canonicalizePath(pathInput);
|
|
2398
2398
|
const innerRef = vue.computed(() => state.getValueAtPath(segments));
|
|
2399
2399
|
let lastTypedForm = lastTypedFormByPath.get(pathKey);
|
|
2400
2400
|
if (lastTypedForm === void 0) {
|
|
@@ -2451,7 +2451,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2451
2451
|
state.markInteracted(segments);
|
|
2452
2452
|
},
|
|
2453
2453
|
registerElement: (element) => {
|
|
2454
|
-
if (!
|
|
2454
|
+
if (!devtoolsShared.INTERACTIVE_TAG_NAMES.has(element.tagName)) return;
|
|
2455
2455
|
const added = state.registerElement(segments, element, formInstanceId);
|
|
2456
2456
|
if (added) attachFocusListeners(state, segments, element, instanceMeta);
|
|
2457
2457
|
},
|
|
@@ -2465,7 +2465,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2465
2465
|
setValueFromHost: (value) => {
|
|
2466
2466
|
state.markInteracted(segments);
|
|
2467
2467
|
const accepted = state.setValueAtPath(segments, value, withInstanceMeta(void 0));
|
|
2468
|
-
if (
|
|
2468
|
+
if (devtoolsShared.__DEV__) {
|
|
2469
2469
|
const dedupeKey = `${formInstanceId}:${pathKey}`;
|
|
2470
2470
|
const isWired = () => (state.elements.get(pathKey)?.elements.size ?? 0) > 0 || state.getFieldRecord(segments)?.connected === true;
|
|
2471
2471
|
if (!warnedMultiRootHosts.has(dedupeKey) && !isWired()) {
|
|
@@ -2549,7 +2549,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2549
2549
|
};
|
|
2550
2550
|
}
|
|
2551
2551
|
|
|
2552
|
-
const unset = Symbol.for("attaform/unset");
|
|
2552
|
+
const unset = /* @__PURE__ */ Symbol.for("attaform/unset");
|
|
2553
2553
|
function isUnset(value) {
|
|
2554
2554
|
return value === unset;
|
|
2555
2555
|
}
|
|
@@ -2622,10 +2622,10 @@ function walkCore(input, segments, schema, paths, synthesizeSchemaKeys) {
|
|
|
2622
2622
|
}
|
|
2623
2623
|
return input;
|
|
2624
2624
|
}
|
|
2625
|
-
function walkUnspecified(slim, segments, paths
|
|
2625
|
+
function walkUnspecified(slim, segments, paths) {
|
|
2626
2626
|
if (isPrimitiveOrEmpty(slim)) {
|
|
2627
2627
|
if (isSlimNumericPrimitive(slim)) {
|
|
2628
|
-
paths
|
|
2628
|
+
paths.push(devtoolsShared.canonicalizePath(segments).key);
|
|
2629
2629
|
}
|
|
2630
2630
|
return slim;
|
|
2631
2631
|
}
|
|
@@ -2639,7 +2639,7 @@ function walkUnspecified(slim, segments, paths$1) {
|
|
|
2639
2639
|
safeAssign(
|
|
2640
2640
|
out,
|
|
2641
2641
|
key,
|
|
2642
|
-
walkUnspecified(slim[key], [...segments, key], paths
|
|
2642
|
+
walkUnspecified(slim[key], [...segments, key], paths)
|
|
2643
2643
|
);
|
|
2644
2644
|
}
|
|
2645
2645
|
return out;
|
|
@@ -2667,27 +2667,27 @@ function blankForKind(slimDefault) {
|
|
|
2667
2667
|
if (slimDefault === null) return null;
|
|
2668
2668
|
return void 0;
|
|
2669
2669
|
}
|
|
2670
|
-
function expandUnsetAt(segments, schema, paths
|
|
2670
|
+
function expandUnsetAt(segments, schema, paths) {
|
|
2671
2671
|
const du = schema.getUnionDiscriminatorAtPath(segments);
|
|
2672
2672
|
if (du !== void 0) {
|
|
2673
2673
|
const discPath = [...segments, du.discriminatorKey];
|
|
2674
2674
|
const discSlim = schema.getEmptyValueAtPath(discPath);
|
|
2675
|
-
paths
|
|
2675
|
+
paths.push(devtoolsShared.canonicalizePath(discPath).key);
|
|
2676
2676
|
return { [du.discriminatorKey]: blankForKind(discSlim) };
|
|
2677
2677
|
}
|
|
2678
2678
|
const slim = schema.getEmptyValueAtPath(segments);
|
|
2679
2679
|
if (isPrimitiveOrEmpty(slim)) {
|
|
2680
|
-
paths
|
|
2680
|
+
paths.push(devtoolsShared.canonicalizePath(segments).key);
|
|
2681
2681
|
return slim;
|
|
2682
2682
|
}
|
|
2683
2683
|
if (isOpaqueLeaf(slim)) {
|
|
2684
|
-
paths
|
|
2684
|
+
paths.push(devtoolsShared.canonicalizePath(segments).key);
|
|
2685
2685
|
return slim;
|
|
2686
2686
|
}
|
|
2687
2687
|
if (Array.isArray(slim)) return slim;
|
|
2688
2688
|
const result = {};
|
|
2689
2689
|
for (const key of Object.keys(slim)) {
|
|
2690
|
-
result[key] = expandUnsetAt([...segments, key], schema, paths
|
|
2690
|
+
result[key] = expandUnsetAt([...segments, key], schema, paths);
|
|
2691
2691
|
}
|
|
2692
2692
|
return result;
|
|
2693
2693
|
}
|
|
@@ -2791,7 +2791,7 @@ function buildValuesProxy(form) {
|
|
|
2791
2791
|
// (`getAtPath`), so `form.values('a.hasOwnProperty')` resolves the
|
|
2792
2792
|
// stored value. Per-level reads still propagate Vue's tracking for
|
|
2793
2793
|
// ordinary keys.
|
|
2794
|
-
resolveCall: (arg) => getAtPath(inner.value,
|
|
2794
|
+
resolveCall: (arg) => getAtPath(inner.value, devtoolsShared.canonicalizePath(arg).segments),
|
|
2795
2795
|
ownKeys: () => Reflect.ownKeys(inner.value),
|
|
2796
2796
|
hasKey: (key) => Reflect.has(inner.value, key),
|
|
2797
2797
|
describeKey: (key) => {
|
|
@@ -2814,9 +2814,9 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2814
2814
|
if (instanceMeta === void 0) return meta;
|
|
2815
2815
|
return meta === void 0 ? { instance: instanceMeta } : { ...meta, instance: instanceMeta };
|
|
2816
2816
|
};
|
|
2817
|
-
const reMarkBlanksAfterSubstitution = (paths
|
|
2818
|
-
for (const pathKey of paths
|
|
2819
|
-
const blankSegments =
|
|
2817
|
+
const reMarkBlanksAfterSubstitution = (paths) => {
|
|
2818
|
+
for (const pathKey of paths) {
|
|
2819
|
+
const blankSegments = devtoolsShared.segmentsForPathKey(pathKey);
|
|
2820
2820
|
if (blankSegments === null) continue;
|
|
2821
2821
|
state.setValueAtPath(
|
|
2822
2822
|
blankSegments,
|
|
@@ -2829,8 +2829,8 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2829
2829
|
let rollup;
|
|
2830
2830
|
const rootBase = () => rollup ?? (rollup = buildContainerFieldStateBase(
|
|
2831
2831
|
state,
|
|
2832
|
-
|
|
2833
|
-
|
|
2832
|
+
devtoolsShared.ROOT_PATH,
|
|
2833
|
+
devtoolsShared.ROOT_PATH_KEY,
|
|
2834
2834
|
formInstanceId
|
|
2835
2835
|
).base);
|
|
2836
2836
|
return {
|
|
@@ -2970,7 +2970,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2970
2970
|
const validateAsync = (pathInput) => validateAsyncBuilt(pathInput);
|
|
2971
2971
|
const parse = (pathInput) => parseBuilt(pathInput);
|
|
2972
2972
|
function pathToRef(pathInput) {
|
|
2973
|
-
const segments =
|
|
2973
|
+
const segments = devtoolsShared.canonicalizePath(pathInput).segments;
|
|
2974
2974
|
return vue.computed(() => getAtPath(state.form.value, segments));
|
|
2975
2975
|
}
|
|
2976
2976
|
function setValueImpl(pathOrValue, maybeValue) {
|
|
@@ -2988,7 +2988,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2988
2988
|
reMarkBlanksAfterSubstitution(walked2.paths);
|
|
2989
2989
|
return true;
|
|
2990
2990
|
}
|
|
2991
|
-
const segments =
|
|
2991
|
+
const segments = devtoolsShared.canonicalizePath(pathOrValue).segments;
|
|
2992
2992
|
const writeUnsetAt = () => {
|
|
2993
2993
|
const last = segments.length > 0 ? segments[segments.length - 1] : void 0;
|
|
2994
2994
|
if (typeof last === "string") {
|
|
@@ -3006,14 +3006,14 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3006
3006
|
state.schema,
|
|
3007
3007
|
blankPaths
|
|
3008
3008
|
);
|
|
3009
|
-
const segmentsKey =
|
|
3009
|
+
const segmentsKey = devtoolsShared.canonicalizePath(segments).key;
|
|
3010
3010
|
if (blankPaths.length === 1 && blankPaths[0] === segmentsKey) {
|
|
3011
3011
|
return state.setValueAtPath(segments, expanded, writeMeta({ blank: true }));
|
|
3012
3012
|
}
|
|
3013
3013
|
const ok2 = state.setValueAtPath(segments, expanded, writeMeta());
|
|
3014
3014
|
if (!ok2) return false;
|
|
3015
3015
|
for (const pathKey of blankPaths) {
|
|
3016
|
-
const blankSegments =
|
|
3016
|
+
const blankSegments = devtoolsShared.segmentsForPathKey(pathKey);
|
|
3017
3017
|
if (blankSegments === null) continue;
|
|
3018
3018
|
state.setValueAtPath(
|
|
3019
3019
|
blankSegments,
|
|
@@ -3052,19 +3052,19 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3052
3052
|
function setErrors(arg1, arg2) {
|
|
3053
3053
|
const isScoped = arguments.length >= 2 && (typeof arg1 === "string" || Array.isArray(arg1));
|
|
3054
3054
|
if (isScoped) {
|
|
3055
|
-
const { segments, key } =
|
|
3055
|
+
const { segments, key } = devtoolsShared.canonicalizePath(arg1);
|
|
3056
3056
|
const input2 = arg2;
|
|
3057
3057
|
const resolved2 = typeof input2 === "function" ? input2((state.userErrors.get(key) ?? []).slice()) : input2;
|
|
3058
3058
|
state.setUserErrorsForPath(
|
|
3059
3059
|
segments,
|
|
3060
|
-
|
|
3060
|
+
devtoolsShared.normalizeErrorInputs(resolved2, segments, state.formKey, AttaformErrorCode.UserError)
|
|
3061
3061
|
);
|
|
3062
3062
|
return;
|
|
3063
3063
|
}
|
|
3064
3064
|
const input = arg1;
|
|
3065
3065
|
const resolved = typeof input === "function" ? input(flattenUserErrors()) : input;
|
|
3066
3066
|
state.setAllUserErrors(
|
|
3067
|
-
|
|
3067
|
+
devtoolsShared.normalizeErrorInputs(resolved, void 0, state.formKey, AttaformErrorCode.UserError)
|
|
3068
3068
|
);
|
|
3069
3069
|
}
|
|
3070
3070
|
function clearErrors(path) {
|
|
@@ -3073,7 +3073,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3073
3073
|
state.clearUserErrors();
|
|
3074
3074
|
return;
|
|
3075
3075
|
}
|
|
3076
|
-
const segments =
|
|
3076
|
+
const segments = devtoolsShared.canonicalizePath(path).segments;
|
|
3077
3077
|
state.clearSchemaErrors(segments);
|
|
3078
3078
|
state.clearUserErrors(segments);
|
|
3079
3079
|
}
|
|
@@ -3277,7 +3277,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3277
3277
|
}
|
|
3278
3278
|
};
|
|
3279
3279
|
const resetField = (pathInput) => {
|
|
3280
|
-
const segments =
|
|
3280
|
+
const segments = devtoolsShared.canonicalizePath(pathInput).segments;
|
|
3281
3281
|
state.resetField(segments);
|
|
3282
3282
|
};
|
|
3283
3283
|
function clear(pathInput) {
|
|
@@ -3287,7 +3287,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3287
3287
|
return setValueImpl(pathInput, unset);
|
|
3288
3288
|
}
|
|
3289
3289
|
function touch(pathInput) {
|
|
3290
|
-
const segments = pathInput === void 0 ?
|
|
3290
|
+
const segments = pathInput === void 0 ? devtoolsShared.ROOT_PATH : devtoolsShared.canonicalizePath(pathInput).segments;
|
|
3291
3291
|
state.touchAtPath(segments);
|
|
3292
3292
|
}
|
|
3293
3293
|
const focusFirstError = (options2) => {
|
|
@@ -3308,26 +3308,26 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3308
3308
|
const fieldArrays = buildFieldArrayApi(state);
|
|
3309
3309
|
const blankPathsView = vue.computed(() => {
|
|
3310
3310
|
const keys = /* @__PURE__ */ new Set();
|
|
3311
|
-
const paths
|
|
3311
|
+
const paths = [];
|
|
3312
3312
|
for (const pk of state.blankPaths) {
|
|
3313
3313
|
keys.add(pk);
|
|
3314
|
-
const segs =
|
|
3315
|
-
if (segs !== null) paths
|
|
3314
|
+
const segs = devtoolsShared.segmentsForPathKey(pk);
|
|
3315
|
+
if (segs !== null) paths.push(segs);
|
|
3316
3316
|
}
|
|
3317
|
-
Object.freeze(paths
|
|
3317
|
+
Object.freeze(paths);
|
|
3318
3318
|
const view = {
|
|
3319
3319
|
get size() {
|
|
3320
3320
|
return keys.size;
|
|
3321
3321
|
},
|
|
3322
3322
|
has(input) {
|
|
3323
|
-
const { key } =
|
|
3323
|
+
const { key } = devtoolsShared.canonicalizePath(input);
|
|
3324
3324
|
return keys.has(key);
|
|
3325
3325
|
},
|
|
3326
3326
|
values() {
|
|
3327
|
-
return paths
|
|
3327
|
+
return paths;
|
|
3328
3328
|
},
|
|
3329
3329
|
[Symbol.iterator]() {
|
|
3330
|
-
return paths
|
|
3330
|
+
return paths[Symbol.iterator]();
|
|
3331
3331
|
}
|
|
3332
3332
|
};
|
|
3333
3333
|
return Object.freeze(view);
|
|
@@ -3350,7 +3350,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3350
3350
|
const callTerminal = fieldStateProxy;
|
|
3351
3351
|
const EMPTY_FIELD_LIST = Object.freeze([]);
|
|
3352
3352
|
function list(path) {
|
|
3353
|
-
const { segments } =
|
|
3353
|
+
const { segments } = devtoolsShared.canonicalizePath(path);
|
|
3354
3354
|
const value = state.getValueAtPath(segments);
|
|
3355
3355
|
if (!Array.isArray(value)) return EMPTY_FIELD_LIST;
|
|
3356
3356
|
const out = new Array(value.length);
|
|
@@ -3359,7 +3359,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3359
3359
|
}
|
|
3360
3360
|
const EMPTY_FIELD_RECORD = Object.freeze({});
|
|
3361
3361
|
function record(path) {
|
|
3362
|
-
const segments = path === void 0 ? [] :
|
|
3362
|
+
const segments = path === void 0 ? [] : devtoolsShared.canonicalizePath(path).segments;
|
|
3363
3363
|
const value = state.getValueAtPath(segments);
|
|
3364
3364
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3365
3365
|
return EMPTY_FIELD_RECORD;
|
|
@@ -3457,6 +3457,33 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3457
3457
|
return api;
|
|
3458
3458
|
}
|
|
3459
3459
|
|
|
3460
|
+
function captureUserCallSite() {
|
|
3461
|
+
const raw = new Error().stack;
|
|
3462
|
+
if (typeof raw !== "string") return void 0;
|
|
3463
|
+
const lines = raw.split("\n");
|
|
3464
|
+
for (let i = 1; i < lines.length; i++) {
|
|
3465
|
+
const frame = lines[i];
|
|
3466
|
+
if (frame === void 0) continue;
|
|
3467
|
+
if (/attaform[/-]forms?/i.test(frame)) continue;
|
|
3468
|
+
if (/\bforms\.[A-Za-z0-9_-]+\.m?js\b/.test(frame)) continue;
|
|
3469
|
+
const trimmed = frame.trim();
|
|
3470
|
+
if (trimmed.length === 0) continue;
|
|
3471
|
+
return shortenSourceFrame(trimmed);
|
|
3472
|
+
}
|
|
3473
|
+
return void 0;
|
|
3474
|
+
}
|
|
3475
|
+
function shortenSourceFrame(frame) {
|
|
3476
|
+
const match = /(?:^|\s|\()([^\s()]+):(\d+):\d+\)?$/.exec(frame);
|
|
3477
|
+
if (match === null) return frame;
|
|
3478
|
+
const [, urlOrPath, line] = match;
|
|
3479
|
+
if (urlOrPath === void 0 || line === void 0) return frame;
|
|
3480
|
+
let path = urlOrPath;
|
|
3481
|
+
path = path.replace(/^[a-z]+:\/\/[^/]+\//i, "");
|
|
3482
|
+
path = path.replace(/^_nuxt\//, "");
|
|
3483
|
+
path = path.replace(/^\//, "");
|
|
3484
|
+
return `(${path}:${line})`;
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3460
3487
|
const IDLE = Object.freeze({ display: "idle" });
|
|
3461
3488
|
const MAX_DELAY = 2147483647;
|
|
3462
3489
|
function createDisplayEngine(ssr) {
|
|
@@ -3562,7 +3589,7 @@ function walkDuStubs(schema, value, path, warned) {
|
|
|
3562
3589
|
const discValue = rec[du.discriminatorKey];
|
|
3563
3590
|
if (discValue !== void 0 && !du.isVariantSelected(discValue)) {
|
|
3564
3591
|
const isKindBlank = discValue === "" || discValue === 0 || discValue === 0n || discValue === false || discValue === null;
|
|
3565
|
-
if (!isKindBlank && warned !== void 0 &&
|
|
3592
|
+
if (!isKindBlank && warned !== void 0 && devtoolsShared.__DEV__) {
|
|
3566
3593
|
const dotted = path.map((s) => String(s)).join(".") || "(root)";
|
|
3567
3594
|
const key = `${dotted}::${String(discValue)}`;
|
|
3568
3595
|
if (!warned.has(key)) {
|
|
@@ -3588,9 +3615,9 @@ function createVariantMemory() {
|
|
|
3588
3615
|
const memory = /* @__PURE__ */ new Map();
|
|
3589
3616
|
function clearAtArrayIndices(arrayPath, indexFilter) {
|
|
3590
3617
|
for (const memKey of [...memory.keys()]) {
|
|
3591
|
-
const segs =
|
|
3618
|
+
const segs = devtoolsShared.segmentsForPathKey(memKey);
|
|
3592
3619
|
if (segs === null) continue;
|
|
3593
|
-
if (!
|
|
3620
|
+
if (!devtoolsShared.isPathPrefix(arrayPath, segs)) continue;
|
|
3594
3621
|
if (segs.length <= arrayPath.length) continue;
|
|
3595
3622
|
const idxSeg = segs[arrayPath.length];
|
|
3596
3623
|
if (typeof idxSeg !== "number") continue;
|
|
@@ -3603,9 +3630,9 @@ function createVariantMemory() {
|
|
|
3603
3630
|
},
|
|
3604
3631
|
clearUnderPath(parentPath) {
|
|
3605
3632
|
for (const memKey of [...memory.keys()]) {
|
|
3606
|
-
const segs =
|
|
3633
|
+
const segs = devtoolsShared.segmentsForPathKey(memKey);
|
|
3607
3634
|
if (segs === null) continue;
|
|
3608
|
-
if (
|
|
3635
|
+
if (devtoolsShared.isPathPrefix(parentPath, segs)) memory.delete(memKey);
|
|
3609
3636
|
}
|
|
3610
3637
|
},
|
|
3611
3638
|
applyArrayOp(arrayPath, op) {
|
|
@@ -3698,11 +3725,11 @@ function createArrayIdentity(getArrayLength) {
|
|
|
3698
3725
|
tokenAt(arraySegs, index) {
|
|
3699
3726
|
const len = getArrayLength(arraySegs);
|
|
3700
3727
|
if (index < 0 || index >= len) return "";
|
|
3701
|
-
const ids = ensure(
|
|
3728
|
+
const ids = ensure(devtoolsShared.canonicalizePath(arraySegs).key, len);
|
|
3702
3729
|
return ids[index] ?? "";
|
|
3703
3730
|
},
|
|
3704
3731
|
applyOp(arraySegs, op) {
|
|
3705
|
-
const arrayKey =
|
|
3732
|
+
const arrayKey = devtoolsShared.canonicalizePath(arraySegs).key;
|
|
3706
3733
|
const postLen = getArrayLength(arraySegs);
|
|
3707
3734
|
const preLen = op.kind === "insert" ? postLen - 1 : op.kind === "remove" ? postLen + 1 : postLen;
|
|
3708
3735
|
const ids = ensure(arrayKey, Math.max(0, preLen));
|
|
@@ -3735,9 +3762,9 @@ function createArrayIdentity(getArrayLength) {
|
|
|
3735
3762
|
const idxPos = arrayPath.length;
|
|
3736
3763
|
const snapshots = [];
|
|
3737
3764
|
for (const [key, value] of store) {
|
|
3738
|
-
const segments =
|
|
3765
|
+
const segments = devtoolsShared.segmentsForPathKey(key);
|
|
3739
3766
|
if (segments === null) continue;
|
|
3740
|
-
if (!
|
|
3767
|
+
if (!devtoolsShared.isPathPrefix(arrayPath, segments)) continue;
|
|
3741
3768
|
if (segments.length <= idxPos) continue;
|
|
3742
3769
|
const idxSeg = segments[idxPos];
|
|
3743
3770
|
if (typeof idxSeg !== "number") continue;
|
|
@@ -3747,33 +3774,33 @@ function createArrayIdentity(getArrayLength) {
|
|
|
3747
3774
|
snapshots.push({ segments: [...segments], index: idxSeg, value });
|
|
3748
3775
|
}
|
|
3749
3776
|
if (snapshots.length === 0) return;
|
|
3750
|
-
for (const snap of snapshots) store.delete(
|
|
3777
|
+
for (const snap of snapshots) store.delete(devtoolsShared.canonicalizePath(snap.segments).key);
|
|
3751
3778
|
for (const snap of snapshots) {
|
|
3752
3779
|
const target = remap.moved.get(snap.index);
|
|
3753
3780
|
if (target === void 0) continue;
|
|
3754
3781
|
const relocated = snap.segments.slice();
|
|
3755
3782
|
relocated[idxPos] = target;
|
|
3756
|
-
store.set(
|
|
3783
|
+
store.set(devtoolsShared.canonicalizePath(relocated).key, snap.value);
|
|
3757
3784
|
}
|
|
3758
3785
|
};
|
|
3759
3786
|
relocate(tokens);
|
|
3760
3787
|
relocate(baselines);
|
|
3761
3788
|
},
|
|
3762
3789
|
realign(arraySegs) {
|
|
3763
|
-
ensure(
|
|
3790
|
+
ensure(devtoolsShared.canonicalizePath(arraySegs).key, getArrayLength(arraySegs));
|
|
3764
3791
|
},
|
|
3765
3792
|
hasStructuralChangeUnder(prefix) {
|
|
3766
3793
|
for (const arrayKey of tokens.keys()) {
|
|
3767
3794
|
if (orderPristineForKey(arrayKey)) continue;
|
|
3768
|
-
const segs =
|
|
3795
|
+
const segs = devtoolsShared.segmentsForPathKey(arrayKey);
|
|
3769
3796
|
if (segs === null) continue;
|
|
3770
|
-
if (
|
|
3797
|
+
if (devtoolsShared.isPathPrefix(prefix, segs)) return true;
|
|
3771
3798
|
}
|
|
3772
3799
|
return false;
|
|
3773
3800
|
},
|
|
3774
3801
|
rebaselineAll() {
|
|
3775
3802
|
for (const arrayKey of [...tokens.keys()]) {
|
|
3776
|
-
const segs =
|
|
3803
|
+
const segs = devtoolsShared.segmentsForPathKey(arrayKey);
|
|
3777
3804
|
if (segs === null) continue;
|
|
3778
3805
|
const ids = ensure(arrayKey, getArrayLength(segs));
|
|
3779
3806
|
baselines.set(arrayKey, [...ids]);
|
|
@@ -3827,9 +3854,9 @@ function changedIndices(remap) {
|
|
|
3827
3854
|
return changed;
|
|
3828
3855
|
}
|
|
3829
3856
|
function elementIndexUnder(arrayPath, key, idxPos) {
|
|
3830
|
-
const segments =
|
|
3857
|
+
const segments = devtoolsShared.segmentsForPathKey(key);
|
|
3831
3858
|
if (segments === null) return null;
|
|
3832
|
-
if (!
|
|
3859
|
+
if (!devtoolsShared.isPathPrefix(arrayPath, segments)) return null;
|
|
3833
3860
|
if (segments.length <= idxPos) return null;
|
|
3834
3861
|
const index = segments[idxPos];
|
|
3835
3862
|
return typeof index === "number" ? index : null;
|
|
@@ -3841,16 +3868,16 @@ function migrateMapSubtree(map, arrayPath, remap, rewriteValue) {
|
|
|
3841
3868
|
const index = elementIndexUnder(arrayPath, key, idxPos);
|
|
3842
3869
|
if (index === null) continue;
|
|
3843
3870
|
if (!remap.moved.has(index) && !remap.vacated.has(index)) continue;
|
|
3844
|
-
snapshots.push({ segments: [...
|
|
3871
|
+
snapshots.push({ segments: [...devtoolsShared.segmentsForPathKey(key)], index, value });
|
|
3845
3872
|
}
|
|
3846
3873
|
if (snapshots.length === 0) return;
|
|
3847
|
-
for (const snap of snapshots) map.delete(
|
|
3874
|
+
for (const snap of snapshots) map.delete(devtoolsShared.canonicalizePath(snap.segments).key);
|
|
3848
3875
|
for (const snap of snapshots) {
|
|
3849
3876
|
const target = remap.moved.get(snap.index);
|
|
3850
3877
|
if (target === void 0) continue;
|
|
3851
3878
|
const relocated = snap.segments.slice();
|
|
3852
3879
|
relocated[idxPos] = target;
|
|
3853
|
-
map.set(
|
|
3880
|
+
map.set(devtoolsShared.canonicalizePath(relocated).key, rewriteValue(snap.value, relocated));
|
|
3854
3881
|
}
|
|
3855
3882
|
}
|
|
3856
3883
|
function migrateSetSubtree(set, arrayPath, remap) {
|
|
@@ -3860,16 +3887,16 @@ function migrateSetSubtree(set, arrayPath, remap) {
|
|
|
3860
3887
|
const index = elementIndexUnder(arrayPath, key, idxPos);
|
|
3861
3888
|
if (index === null) continue;
|
|
3862
3889
|
if (!remap.moved.has(index) && !remap.vacated.has(index)) continue;
|
|
3863
|
-
snapshots.push({ segments: [...
|
|
3890
|
+
snapshots.push({ segments: [...devtoolsShared.segmentsForPathKey(key)], index });
|
|
3864
3891
|
}
|
|
3865
3892
|
if (snapshots.length === 0) return;
|
|
3866
|
-
for (const snap of snapshots) set.delete(
|
|
3893
|
+
for (const snap of snapshots) set.delete(devtoolsShared.canonicalizePath(snap.segments).key);
|
|
3867
3894
|
for (const snap of snapshots) {
|
|
3868
3895
|
const target = remap.moved.get(snap.index);
|
|
3869
3896
|
if (target === void 0) continue;
|
|
3870
3897
|
const relocated = snap.segments.slice();
|
|
3871
3898
|
relocated[idxPos] = target;
|
|
3872
|
-
set.add(
|
|
3899
|
+
set.add(devtoolsShared.canonicalizePath(relocated).key);
|
|
3873
3900
|
}
|
|
3874
3901
|
}
|
|
3875
3902
|
|
|
@@ -3919,7 +3946,7 @@ function createArrayBookkeeping(deps) {
|
|
|
3919
3946
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3920
3947
|
diffAndApply(void 0, getAtPath(form.value, elementPath), elementPath, (patch) => {
|
|
3921
3948
|
if (patch.kind !== "added") return;
|
|
3922
|
-
const { key } =
|
|
3949
|
+
const { key } = devtoolsShared.canonicalizePath(patch.path);
|
|
3923
3950
|
if (!originals.has(key)) originals.set(key, { segments: patch.path, value: void 0 });
|
|
3924
3951
|
touchFieldRecord(key, patch.path, { updatedAt: now });
|
|
3925
3952
|
});
|
|
@@ -3929,9 +3956,9 @@ function createArrayBookkeeping(deps) {
|
|
|
3929
3956
|
if (changed.size === 0) return;
|
|
3930
3957
|
const idxPos = arrayPath.length;
|
|
3931
3958
|
for (const key of [...schemaErrors.keys()]) {
|
|
3932
|
-
const segs =
|
|
3959
|
+
const segs = devtoolsShared.segmentsForPathKey(key);
|
|
3933
3960
|
if (segs === null) continue;
|
|
3934
|
-
if (!
|
|
3961
|
+
if (!devtoolsShared.isPathPrefix(arrayPath, segs)) continue;
|
|
3935
3962
|
if (segs.length <= idxPos) continue;
|
|
3936
3963
|
const idx = segs[idxPos];
|
|
3937
3964
|
if (typeof idx === "number" && changed.has(idx)) schemaErrors.delete(key);
|
|
@@ -3941,9 +3968,9 @@ function createArrayBookkeeping(deps) {
|
|
|
3941
3968
|
if (remap.vacated.size === 0) return;
|
|
3942
3969
|
const idxPos = arrayPath.length;
|
|
3943
3970
|
for (const [key, entry] of [...fieldValidationState]) {
|
|
3944
|
-
const segs =
|
|
3971
|
+
const segs = devtoolsShared.segmentsForPathKey(key);
|
|
3945
3972
|
if (segs === null) continue;
|
|
3946
|
-
if (!
|
|
3973
|
+
if (!devtoolsShared.isPathPrefix(arrayPath, segs)) continue;
|
|
3947
3974
|
if (segs.length <= idxPos) continue;
|
|
3948
3975
|
const idx = segs[idxPos];
|
|
3949
3976
|
if (typeof idx !== "number" || !remap.vacated.has(idx)) continue;
|
|
@@ -4047,13 +4074,13 @@ function isHydratedValidationErrorArray(value) {
|
|
|
4047
4074
|
return true;
|
|
4048
4075
|
}
|
|
4049
4076
|
function warnMalformedHydration(formKey, kind, rawKey) {
|
|
4050
|
-
if (!
|
|
4077
|
+
if (!devtoolsShared.__DEV__) return;
|
|
4051
4078
|
console.warn(
|
|
4052
4079
|
`[attaform] hydration: skipping malformed ${kind} entry at key '${rawKey}' on form '${formKey}'. This usually means the SSR bundle is on a different version than the client (rolling deploy / stale cache).`
|
|
4053
4080
|
);
|
|
4054
4081
|
}
|
|
4055
4082
|
function isPathKeyUnder(existingKey, parentPath) {
|
|
4056
|
-
const parsed =
|
|
4083
|
+
const parsed = devtoolsShared.segmentsForPathKey(existingKey);
|
|
4057
4084
|
if (parsed === null) return false;
|
|
4058
4085
|
if (parsed.length <= parentPath.length) return false;
|
|
4059
4086
|
for (let i = 0; i < parentPath.length; i++) {
|
|
@@ -4088,7 +4115,7 @@ function stripSymbolsDeep(value) {
|
|
|
4088
4115
|
return mutated ? out : value;
|
|
4089
4116
|
}
|
|
4090
4117
|
function walkAuthoredFromConstraints(value, prefix, out) {
|
|
4091
|
-
if (prefix.length > 0) out.add(
|
|
4118
|
+
if (prefix.length > 0) out.add(devtoolsShared.canonicalizePath(prefix).key);
|
|
4092
4119
|
if (isPlainRecord(value)) {
|
|
4093
4120
|
for (const k of Object.keys(value)) {
|
|
4094
4121
|
walkAuthoredFromConstraints(value[k], [...prefix, k], out);
|
|
@@ -4130,7 +4157,7 @@ function walkAuthoredFromSchemaDiff(withDefaults, withoutDefaults, prefix, out)
|
|
|
4130
4157
|
return;
|
|
4131
4158
|
}
|
|
4132
4159
|
if (!Object.is(withDefaults, withoutDefaults) && prefix.length > 0) {
|
|
4133
|
-
out.add(
|
|
4160
|
+
out.add(devtoolsShared.canonicalizePath(prefix).key);
|
|
4134
4161
|
}
|
|
4135
4162
|
}
|
|
4136
4163
|
function createFormStore(options) {
|
|
@@ -4180,7 +4207,7 @@ function createFormStore(options) {
|
|
|
4180
4207
|
if (pathSegments.length === 0) return true;
|
|
4181
4208
|
const value = getAtPath(form.value, pathSegments);
|
|
4182
4209
|
if (value !== void 0) return true;
|
|
4183
|
-
if (authoredPaths.has(
|
|
4210
|
+
if (authoredPaths.has(devtoolsShared.canonicalizePath(pathSegments).key)) return true;
|
|
4184
4211
|
return !schema.isPreprocessOrCoerceLeaf(pathSegments);
|
|
4185
4212
|
});
|
|
4186
4213
|
}
|
|
@@ -4211,7 +4238,7 @@ function createFormStore(options) {
|
|
|
4211
4238
|
const blankPaths = vue.reactive(/* @__PURE__ */ new Set());
|
|
4212
4239
|
const originalBlankPaths = /* @__PURE__ */ new Set();
|
|
4213
4240
|
for (const raw of initialTransientList) {
|
|
4214
|
-
const key =
|
|
4241
|
+
const key = devtoolsShared.coerceToPathKey(raw);
|
|
4215
4242
|
blankPaths.add(key);
|
|
4216
4243
|
originalBlankPaths.add(key);
|
|
4217
4244
|
}
|
|
@@ -4231,7 +4258,7 @@ function createFormStore(options) {
|
|
|
4231
4258
|
const result = /* @__PURE__ */ new Map();
|
|
4232
4259
|
if (blankPaths.size === 0) return result;
|
|
4233
4260
|
for (const pathKey of blankPaths) {
|
|
4234
|
-
const segments =
|
|
4261
|
+
const segments = devtoolsShared.segmentsForPathKey(pathKey);
|
|
4235
4262
|
if (segments === null) continue;
|
|
4236
4263
|
if (!schema.isRequiredAtPath(segments)) continue;
|
|
4237
4264
|
result.set(pathKey, [makeBlankRequiredError(segments, formKey)]);
|
|
@@ -4263,7 +4290,7 @@ function createFormStore(options) {
|
|
|
4263
4290
|
});
|
|
4264
4291
|
const pathAsyncCache = /* @__PURE__ */ new Map();
|
|
4265
4292
|
function pathHasAsyncValidation(path) {
|
|
4266
|
-
const { key } =
|
|
4293
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
4267
4294
|
return pathHasAsyncValidationByKey(key, path);
|
|
4268
4295
|
}
|
|
4269
4296
|
function pathHasAsyncValidationByKey(key, segments) {
|
|
@@ -4367,9 +4394,9 @@ function createFormStore(options) {
|
|
|
4367
4394
|
}
|
|
4368
4395
|
function cancelTransformsUnder(prefix) {
|
|
4369
4396
|
for (const [key, run] of [...transformRuns]) {
|
|
4370
|
-
const segs =
|
|
4397
|
+
const segs = devtoolsShared.segmentsForPathKey(key);
|
|
4371
4398
|
if (segs === null) continue;
|
|
4372
|
-
if (!
|
|
4399
|
+
if (!devtoolsShared.isPathPrefix(prefix, segs)) continue;
|
|
4373
4400
|
releaseTransformRun(key, run);
|
|
4374
4401
|
transformRuns.delete(key);
|
|
4375
4402
|
transformErrors.delete(key);
|
|
@@ -4383,7 +4410,7 @@ function createFormStore(options) {
|
|
|
4383
4410
|
transformWaiters.push({ key: null, resolve });
|
|
4384
4411
|
});
|
|
4385
4412
|
}
|
|
4386
|
-
const { key } =
|
|
4413
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
4387
4414
|
if ((fieldTransformCounts.get(key) ?? 0) === 0) return Promise.resolve();
|
|
4388
4415
|
return new Promise((resolve) => {
|
|
4389
4416
|
transformWaiters.push({ key, resolve });
|
|
@@ -4392,7 +4419,7 @@ function createFormStore(options) {
|
|
|
4392
4419
|
const initStamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4393
4420
|
diffAndApply({}, schemaInitialData, [], (patch) => {
|
|
4394
4421
|
if (patch.kind !== "added") return;
|
|
4395
|
-
const { key } =
|
|
4422
|
+
const { key } = devtoolsShared.canonicalizePath(patch.path);
|
|
4396
4423
|
originals.set(key, { segments: patch.path, value: patch.newValue });
|
|
4397
4424
|
ensurePathOrdinal(key);
|
|
4398
4425
|
});
|
|
@@ -4421,7 +4448,7 @@ function createFormStore(options) {
|
|
|
4421
4448
|
} else {
|
|
4422
4449
|
diffAndApply({}, initialData, [], (patch) => {
|
|
4423
4450
|
if (patch.kind !== "added") return;
|
|
4424
|
-
const { key } =
|
|
4451
|
+
const { key } = devtoolsShared.canonicalizePath(patch.path);
|
|
4425
4452
|
fields.set(key, {
|
|
4426
4453
|
path: patch.path,
|
|
4427
4454
|
updatedAt: initStamp,
|
|
@@ -4487,7 +4514,7 @@ function createFormStore(options) {
|
|
|
4487
4514
|
function commitWritePatches(patches, meta) {
|
|
4488
4515
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4489
4516
|
for (const patch of patches) {
|
|
4490
|
-
const { key } =
|
|
4517
|
+
const { key } = devtoolsShared.canonicalizePath(patch.path);
|
|
4491
4518
|
if (patch.kind === "added" && !originals.has(key)) {
|
|
4492
4519
|
originals.set(key, { segments: patch.path, value: void 0 });
|
|
4493
4520
|
}
|
|
@@ -4649,7 +4676,7 @@ function createFormStore(options) {
|
|
|
4649
4676
|
}
|
|
4650
4677
|
}
|
|
4651
4678
|
const currentValue = getAtPath(form.value, path);
|
|
4652
|
-
const pathKey =
|
|
4679
|
+
const pathKey = devtoolsShared.canonicalizePath(path).key;
|
|
4653
4680
|
if (meta?.blank === true) {
|
|
4654
4681
|
blankPaths.add(pathKey);
|
|
4655
4682
|
} else {
|
|
@@ -4709,7 +4736,7 @@ function createFormStore(options) {
|
|
|
4709
4736
|
arrayIdentity.realign(path);
|
|
4710
4737
|
} else if (isContainer(currentValue) && !isContainer(value)) {
|
|
4711
4738
|
if (subtreeHadRealBaseline(path, currentValue)) {
|
|
4712
|
-
removedSubtrees.add(
|
|
4739
|
+
removedSubtrees.add(devtoolsShared.canonicalizePath(path).key);
|
|
4713
4740
|
}
|
|
4714
4741
|
}
|
|
4715
4742
|
const effectiveModeAfterWrite = meta?.instance?.validateOn ?? fieldValidationMode;
|
|
@@ -4723,7 +4750,7 @@ function createFormStore(options) {
|
|
|
4723
4750
|
}
|
|
4724
4751
|
function reshapeUnionVariant(parentPath, oldDiscValue, newDiscValue, variantDefault, consumerOverrides, meta) {
|
|
4725
4752
|
const sameDisc = Object.is(oldDiscValue, newDiscValue);
|
|
4726
|
-
const parentKey =
|
|
4753
|
+
const parentKey = devtoolsShared.canonicalizePath(parentPath).key;
|
|
4727
4754
|
let baseline = variantDefault;
|
|
4728
4755
|
let restoredBlanks;
|
|
4729
4756
|
const effectiveRemember = meta?.instance?.rememberVariants ?? rememberVariants;
|
|
@@ -4778,7 +4805,7 @@ function createFormStore(options) {
|
|
|
4778
4805
|
path: [...parentPath, ...err.path]
|
|
4779
4806
|
}));
|
|
4780
4807
|
applySchemaErrorsForSubtree(parentPath, reStamped);
|
|
4781
|
-
const { key: parentKey2 } =
|
|
4808
|
+
const { key: parentKey2 } = devtoolsShared.canonicalizePath(parentPath);
|
|
4782
4809
|
const prevValidation = fieldValidationState.get(parentKey2);
|
|
4783
4810
|
if (prevValidation !== void 0) {
|
|
4784
4811
|
if (prevValidation.timer !== null) clearTimeout(prevValidation.timer);
|
|
@@ -4802,7 +4829,7 @@ function createFormStore(options) {
|
|
|
4802
4829
|
const effectiveMode = override?.mode ?? fieldValidationMode;
|
|
4803
4830
|
if (effectiveMode === "submit") return;
|
|
4804
4831
|
const effectiveDebounce = override?.debounceMs ?? fieldValidationDebounceMs;
|
|
4805
|
-
const { key } =
|
|
4832
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
4806
4833
|
const prev = fieldValidationState.get(key);
|
|
4807
4834
|
if (prev !== void 0) {
|
|
4808
4835
|
if (prev.timer !== null) clearTimeout(prev.timer);
|
|
@@ -4833,7 +4860,7 @@ function createFormStore(options) {
|
|
|
4833
4860
|
const subtreeScope = path.length > 0 && schema.hasContainerOrRootRefine?.() === false;
|
|
4834
4861
|
const scopePath = subtreeScope ? path : void 0;
|
|
4835
4862
|
const dataAtScope = subtreeScope ? getAtPath(form.value, path) : form.value;
|
|
4836
|
-
const scopeKey = subtreeScope ?
|
|
4863
|
+
const scopeKey = subtreeScope ? devtoolsShared.canonicalizePath(path).key : devtoolsShared.ROOT_PATH_KEY;
|
|
4837
4864
|
void Promise.resolve().then(() => schema.validateAtPath(dataAtScope, scopePath)).then((response) => {
|
|
4838
4865
|
if (fresh.aborted) return;
|
|
4839
4866
|
if (myEpoch <= lastCommittedEpoch) return;
|
|
@@ -4878,9 +4905,9 @@ function createFormStore(options) {
|
|
|
4878
4905
|
}
|
|
4879
4906
|
function cancelFieldValidationUnder(prefix) {
|
|
4880
4907
|
for (const [key, entry] of [...fieldValidationState]) {
|
|
4881
|
-
const segs =
|
|
4908
|
+
const segs = devtoolsShared.segmentsForPathKey(key);
|
|
4882
4909
|
if (segs === null) continue;
|
|
4883
|
-
if (!
|
|
4910
|
+
if (!devtoolsShared.isPathPrefix(prefix, segs)) continue;
|
|
4884
4911
|
if (entry.timer !== null) {
|
|
4885
4912
|
clearTimeout(entry.timer);
|
|
4886
4913
|
} else if (!entry.settled && !entry.released) {
|
|
@@ -4953,7 +4980,7 @@ function createFormStore(options) {
|
|
|
4953
4980
|
}
|
|
4954
4981
|
function appendErrorsTo(map, entries) {
|
|
4955
4982
|
for (const raw of entries) {
|
|
4956
|
-
const { key } =
|
|
4983
|
+
const { key } = devtoolsShared.canonicalizePath(raw.path);
|
|
4957
4984
|
const current = map.get(key);
|
|
4958
4985
|
if (current === void 0) {
|
|
4959
4986
|
map.set(key, [raw]);
|
|
@@ -4971,11 +4998,11 @@ function createFormStore(options) {
|
|
|
4971
4998
|
map.clear();
|
|
4972
4999
|
return;
|
|
4973
5000
|
}
|
|
4974
|
-
const { key } =
|
|
5001
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
4975
5002
|
map.delete(key);
|
|
4976
5003
|
}
|
|
4977
5004
|
function setSchemaErrorsForPath(path, entries) {
|
|
4978
|
-
const { key } =
|
|
5005
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
4979
5006
|
if (entries.length === 0) {
|
|
4980
5007
|
schemaErrors.delete(key);
|
|
4981
5008
|
return;
|
|
@@ -4983,10 +5010,10 @@ function createFormStore(options) {
|
|
|
4983
5010
|
schemaErrors.set(key, [...entries]);
|
|
4984
5011
|
}
|
|
4985
5012
|
function applySchemaErrorsForSubtree(path, entries) {
|
|
4986
|
-
const parentKey =
|
|
5013
|
+
const parentKey = devtoolsShared.canonicalizePath(path).key;
|
|
4987
5014
|
const grouped = /* @__PURE__ */ new Map();
|
|
4988
5015
|
for (const raw of entries) {
|
|
4989
|
-
const { key } =
|
|
5016
|
+
const { key } = devtoolsShared.canonicalizePath(raw.path);
|
|
4990
5017
|
const list = grouped.get(key);
|
|
4991
5018
|
if (list === void 0) grouped.set(key, [raw]);
|
|
4992
5019
|
else list.push(raw);
|
|
@@ -5012,7 +5039,7 @@ function createFormStore(options) {
|
|
|
5012
5039
|
replaceErrorsIn(userErrors, entries);
|
|
5013
5040
|
}
|
|
5014
5041
|
function setUserErrorsForPath(path, entries) {
|
|
5015
|
-
const { key } =
|
|
5042
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5016
5043
|
if (entries.length === 0) {
|
|
5017
5044
|
userErrors.delete(key);
|
|
5018
5045
|
return;
|
|
@@ -5023,7 +5050,7 @@ function createFormStore(options) {
|
|
|
5023
5050
|
clearErrorsIn(userErrors, path);
|
|
5024
5051
|
}
|
|
5025
5052
|
function getErrorsForPath(path) {
|
|
5026
|
-
const { key } =
|
|
5053
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5027
5054
|
const schemaForKey = schemaErrors.get(key);
|
|
5028
5055
|
const userForKey = userErrors.get(key);
|
|
5029
5056
|
const blankForKey = derivedBlankErrors.value.get(key);
|
|
@@ -5037,7 +5064,7 @@ function createFormStore(options) {
|
|
|
5037
5064
|
return result;
|
|
5038
5065
|
}
|
|
5039
5066
|
function registerElement(path, element, formInstanceId) {
|
|
5040
|
-
const { key } =
|
|
5067
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5041
5068
|
const record = elements.get(key);
|
|
5042
5069
|
const raw = vue.markRaw(element);
|
|
5043
5070
|
if (record === void 0) {
|
|
@@ -5057,7 +5084,7 @@ function createFormStore(options) {
|
|
|
5057
5084
|
return true;
|
|
5058
5085
|
}
|
|
5059
5086
|
function deregisterElement(path, element) {
|
|
5060
|
-
const { key } =
|
|
5087
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5061
5088
|
const record = elements.get(key);
|
|
5062
5089
|
if (record === void 0) return 0;
|
|
5063
5090
|
const removed = record.elements.delete(element);
|
|
@@ -5075,7 +5102,7 @@ function createFormStore(options) {
|
|
|
5075
5102
|
}
|
|
5076
5103
|
function markConnectedOptimistically(path) {
|
|
5077
5104
|
if (!ssr) return;
|
|
5078
|
-
const { key } =
|
|
5105
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5079
5106
|
const current = fields.get(key);
|
|
5080
5107
|
if (current?.connected === true) return;
|
|
5081
5108
|
touchFieldRecord(key, path, {
|
|
@@ -5085,7 +5112,7 @@ function createFormStore(options) {
|
|
|
5085
5112
|
});
|
|
5086
5113
|
}
|
|
5087
5114
|
function markHostConnected(path, connected) {
|
|
5088
|
-
const { key } =
|
|
5115
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5089
5116
|
const current = fields.get(key);
|
|
5090
5117
|
if (connected) {
|
|
5091
5118
|
if (current?.connected === true) return;
|
|
@@ -5100,7 +5127,7 @@ function createFormStore(options) {
|
|
|
5100
5127
|
}
|
|
5101
5128
|
}
|
|
5102
5129
|
function markFocused(path, focused, meta) {
|
|
5103
|
-
const { key } =
|
|
5130
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5104
5131
|
const current = fields.get(key);
|
|
5105
5132
|
touchFieldRecord(key, path, {
|
|
5106
5133
|
focused,
|
|
@@ -5120,7 +5147,7 @@ function createFormStore(options) {
|
|
|
5120
5147
|
let snapshot = void 0;
|
|
5121
5148
|
let snapshotScopeLength = 0;
|
|
5122
5149
|
for (let i = path.length; i >= 0; i--) {
|
|
5123
|
-
const ancestorKey =
|
|
5150
|
+
const ancestorKey = devtoolsShared.canonicalizePath(path.slice(0, i)).key;
|
|
5124
5151
|
const entry = pathSnapshots.get(ancestorKey);
|
|
5125
5152
|
if (entry !== void 0) {
|
|
5126
5153
|
snapshot = entry;
|
|
@@ -5147,7 +5174,7 @@ function createFormStore(options) {
|
|
|
5147
5174
|
}
|
|
5148
5175
|
}
|
|
5149
5176
|
function markInteracted(path) {
|
|
5150
|
-
const { key } =
|
|
5177
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5151
5178
|
if (fields.get(key)?.interacted === true) return;
|
|
5152
5179
|
touchFieldRecord(key, path, { interacted: true });
|
|
5153
5180
|
}
|
|
@@ -5155,15 +5182,15 @@ function createFormStore(options) {
|
|
|
5155
5182
|
const formValue = form.value;
|
|
5156
5183
|
let touchedAny = false;
|
|
5157
5184
|
for (const [, entry] of originals) {
|
|
5158
|
-
if (!
|
|
5185
|
+
if (!devtoolsShared.isPathPrefix(segments, entry.segments)) continue;
|
|
5159
5186
|
if (!hasAtPath(formValue, entry.segments)) continue;
|
|
5160
5187
|
touchedAny = true;
|
|
5161
|
-
const leafKey =
|
|
5188
|
+
const leafKey = devtoolsShared.canonicalizePath(entry.segments).key;
|
|
5162
5189
|
const current = fields.get(leafKey);
|
|
5163
5190
|
if (current?.touched === true) continue;
|
|
5164
5191
|
touchFieldRecord(leafKey, entry.segments, { touched: true });
|
|
5165
5192
|
}
|
|
5166
|
-
if (!touchedAny &&
|
|
5193
|
+
if (!touchedAny && devtoolsShared.__DEV__) {
|
|
5167
5194
|
console.warn(
|
|
5168
5195
|
`[attaform] form.touch(): no fields resolved at path ${JSON.stringify(segments)}. Check the path matches an existing field or container.`
|
|
5169
5196
|
);
|
|
@@ -5226,25 +5253,25 @@ function createFormStore(options) {
|
|
|
5226
5253
|
}
|
|
5227
5254
|
}
|
|
5228
5255
|
function clearHydrationFailedEntry() {
|
|
5229
|
-
const existing = schemaErrors.get(
|
|
5256
|
+
const existing = schemaErrors.get(devtoolsShared.ROOT_PATH_KEY);
|
|
5230
5257
|
if (existing === void 0) return;
|
|
5231
5258
|
const filtered = existing.filter((e) => e.code !== AttaformErrorCode.HydrationFailed);
|
|
5232
5259
|
if (filtered.length === 0) {
|
|
5233
|
-
schemaErrors.delete(
|
|
5260
|
+
schemaErrors.delete(devtoolsShared.ROOT_PATH_KEY);
|
|
5234
5261
|
} else {
|
|
5235
|
-
schemaErrors.set(
|
|
5262
|
+
schemaErrors.set(devtoolsShared.ROOT_PATH_KEY, filtered);
|
|
5236
5263
|
}
|
|
5237
5264
|
}
|
|
5238
5265
|
function appendHydrationFailedEntry(error) {
|
|
5239
5266
|
const message = error instanceof Error ? error.message : typeof error === "string" ? error : "Hydration failed";
|
|
5240
5267
|
const entry = {
|
|
5241
5268
|
message,
|
|
5242
|
-
path: [...
|
|
5269
|
+
path: [...devtoolsShared.ROOT_PATH],
|
|
5243
5270
|
formKey,
|
|
5244
5271
|
code: AttaformErrorCode.HydrationFailed
|
|
5245
5272
|
};
|
|
5246
|
-
const existing = schemaErrors.get(
|
|
5247
|
-
schemaErrors.set(
|
|
5273
|
+
const existing = schemaErrors.get(devtoolsShared.ROOT_PATH_KEY) ?? [];
|
|
5274
|
+
schemaErrors.set(devtoolsShared.ROOT_PATH_KEY, [...existing, entry]);
|
|
5248
5275
|
return entry;
|
|
5249
5276
|
}
|
|
5250
5277
|
function reset(nextDefaultValues) {
|
|
@@ -5263,7 +5290,7 @@ function createFormStore(options) {
|
|
|
5263
5290
|
originals.clear();
|
|
5264
5291
|
diffAndApply({}, next, [], (patch) => {
|
|
5265
5292
|
if (patch.kind !== "added") return;
|
|
5266
|
-
const { key } =
|
|
5293
|
+
const { key } = devtoolsShared.canonicalizePath(patch.path);
|
|
5267
5294
|
originals.set(key, { segments: patch.path, value: patch.newValue });
|
|
5268
5295
|
});
|
|
5269
5296
|
if (nextDefaultValues !== void 0) {
|
|
@@ -5323,14 +5350,14 @@ function createFormStore(options) {
|
|
|
5323
5350
|
}
|
|
5324
5351
|
}
|
|
5325
5352
|
function resetField(path) {
|
|
5326
|
-
const { key: targetKey, segments: targetSegments } =
|
|
5353
|
+
const { key: targetKey, segments: targetSegments } = devtoolsShared.canonicalizePath(path);
|
|
5327
5354
|
variantMemory.clearUnderPath(targetSegments);
|
|
5328
5355
|
cancelFieldValidationUnder(targetSegments);
|
|
5329
5356
|
cancelTransformsUnder(targetSegments);
|
|
5330
5357
|
for (const [snapKey] of [...pathSnapshots]) {
|
|
5331
|
-
const segs =
|
|
5358
|
+
const segs = devtoolsShared.segmentsForPathKey(snapKey);
|
|
5332
5359
|
if (segs === null) continue;
|
|
5333
|
-
if (
|
|
5360
|
+
if (devtoolsShared.isPathPrefix(targetSegments, segs)) pathSnapshots.delete(snapKey);
|
|
5334
5361
|
}
|
|
5335
5362
|
const leafEntry = originals.get(targetKey);
|
|
5336
5363
|
if (leafEntry !== void 0) {
|
|
@@ -5345,7 +5372,7 @@ function createFormStore(options) {
|
|
|
5345
5372
|
let anyMatch = false;
|
|
5346
5373
|
for (const [, entry] of originals) {
|
|
5347
5374
|
const leafSegments = entry.segments;
|
|
5348
|
-
if (!
|
|
5375
|
+
if (!devtoolsShared.isPathPrefix(targetSegments, leafSegments)) continue;
|
|
5349
5376
|
if (leafSegments.length === targetSegments.length) continue;
|
|
5350
5377
|
anyMatch = true;
|
|
5351
5378
|
const relative = leafSegments.slice(targetSegments.length);
|
|
@@ -5366,14 +5393,14 @@ function createFormStore(options) {
|
|
|
5366
5393
|
deleteErrorsUnderPrefix(schemaErrors, targetSegments);
|
|
5367
5394
|
deleteErrorsUnderPrefix(userErrors, targetSegments);
|
|
5368
5395
|
for (const [fieldKey, record] of Array.from(fields.entries())) {
|
|
5369
|
-
if (
|
|
5396
|
+
if (devtoolsShared.isPathPrefix(targetSegments, record.path)) clearFieldRecordFlags(fieldKey);
|
|
5370
5397
|
}
|
|
5371
5398
|
}
|
|
5372
5399
|
function deleteErrorsUnderPrefix(map, prefix) {
|
|
5373
5400
|
for (const [errorKey, errs] of Array.from(map.entries())) {
|
|
5374
5401
|
const first = errs[0];
|
|
5375
5402
|
if (first === void 0) continue;
|
|
5376
|
-
if (
|
|
5403
|
+
if (devtoolsShared.isPathPrefix(prefix, first.path)) {
|
|
5377
5404
|
map.delete(errorKey);
|
|
5378
5405
|
}
|
|
5379
5406
|
}
|
|
@@ -5384,7 +5411,7 @@ function createFormStore(options) {
|
|
|
5384
5411
|
fields.set(pathKey, withClearedHistoryFlags(record, (/* @__PURE__ */ new Date()).toISOString()));
|
|
5385
5412
|
}
|
|
5386
5413
|
function isPristineAtPath(path) {
|
|
5387
|
-
const { key, segments } =
|
|
5414
|
+
const { key, segments } = devtoolsShared.canonicalizePath(path);
|
|
5388
5415
|
return isPristineAtPathByKey(key, segments);
|
|
5389
5416
|
}
|
|
5390
5417
|
function isPristineAtPathByKey(key, segments) {
|
|
@@ -5400,7 +5427,7 @@ function createFormStore(options) {
|
|
|
5400
5427
|
let had = false;
|
|
5401
5428
|
diffAndApply(removedValue, void 0, prefix, (patch) => {
|
|
5402
5429
|
if (had || patch.kind !== "removed") return;
|
|
5403
|
-
const record = originals.get(
|
|
5430
|
+
const record = originals.get(devtoolsShared.canonicalizePath(patch.path).key);
|
|
5404
5431
|
if (record?.value !== void 0) had = true;
|
|
5405
5432
|
});
|
|
5406
5433
|
return had;
|
|
@@ -5408,20 +5435,20 @@ function createFormStore(options) {
|
|
|
5408
5435
|
function hasRemovedSubtreeUnder(prefix) {
|
|
5409
5436
|
if (removedSubtrees.size === 0) return false;
|
|
5410
5437
|
for (const key of removedSubtrees) {
|
|
5411
|
-
const segments =
|
|
5438
|
+
const segments = devtoolsShared.segmentsForPathKey(key);
|
|
5412
5439
|
if (segments === null) continue;
|
|
5413
|
-
if (!
|
|
5440
|
+
if (!devtoolsShared.isPathPrefix(prefix, segments)) continue;
|
|
5414
5441
|
if (isContainer(getAtPath(vue.toRaw(form.value), segments))) continue;
|
|
5415
5442
|
return true;
|
|
5416
5443
|
}
|
|
5417
5444
|
return false;
|
|
5418
5445
|
}
|
|
5419
5446
|
function getFieldRecord(path) {
|
|
5420
|
-
const { key } =
|
|
5447
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5421
5448
|
return fields.get(key);
|
|
5422
5449
|
}
|
|
5423
5450
|
function getOriginalAtPath(path) {
|
|
5424
|
-
const { key } =
|
|
5451
|
+
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5425
5452
|
return originals.get(key)?.value;
|
|
5426
5453
|
}
|
|
5427
5454
|
function getFirstErrorElement(formInstanceId) {
|
|
@@ -5537,33 +5564,6 @@ function createFormStore(options) {
|
|
|
5537
5564
|
};
|
|
5538
5565
|
}
|
|
5539
5566
|
|
|
5540
|
-
function captureUserCallSite() {
|
|
5541
|
-
const raw = new Error().stack;
|
|
5542
|
-
if (typeof raw !== "string") return void 0;
|
|
5543
|
-
const lines = raw.split("\n");
|
|
5544
|
-
for (let i = 1; i < lines.length; i++) {
|
|
5545
|
-
const frame = lines[i];
|
|
5546
|
-
if (frame === void 0) continue;
|
|
5547
|
-
if (/attaform[/-]forms?/i.test(frame)) continue;
|
|
5548
|
-
if (/\bforms\.[A-Za-z0-9_-]+\.m?js\b/.test(frame)) continue;
|
|
5549
|
-
const trimmed = frame.trim();
|
|
5550
|
-
if (trimmed.length === 0) continue;
|
|
5551
|
-
return shortenSourceFrame(trimmed);
|
|
5552
|
-
}
|
|
5553
|
-
return void 0;
|
|
5554
|
-
}
|
|
5555
|
-
function shortenSourceFrame(frame) {
|
|
5556
|
-
const match = /(?:^|\s|\()([^\s()]+):(\d+):\d+\)?$/.exec(frame);
|
|
5557
|
-
if (match === null) return frame;
|
|
5558
|
-
const [, urlOrPath, line] = match;
|
|
5559
|
-
if (urlOrPath === void 0 || line === void 0) return frame;
|
|
5560
|
-
let path = urlOrPath;
|
|
5561
|
-
path = path.replace(/^[a-z]+:\/\/[^/]+\//i, "");
|
|
5562
|
-
path = path.replace(/^_nuxt\//, "");
|
|
5563
|
-
path = path.replace(/^\//, "");
|
|
5564
|
-
return `(${path}:${line})`;
|
|
5565
|
-
}
|
|
5566
|
-
|
|
5567
5567
|
function getComputedSchema(formKey, schemaOrCallback, options) {
|
|
5568
5568
|
if (typeof schemaOrCallback === "function") return schemaOrCallback(formKey, options);
|
|
5569
5569
|
return schemaOrCallback;
|
|
@@ -5604,7 +5604,7 @@ function errorFieldsEqual(av, bvi) {
|
|
|
5604
5604
|
if (av.message !== bvi.message) return false;
|
|
5605
5605
|
if (av.code !== bvi.code) return false;
|
|
5606
5606
|
if (av.formKey !== bvi.formKey) return false;
|
|
5607
|
-
if (av.path !== bvi.path && !
|
|
5607
|
+
if (av.path !== bvi.path && !devtoolsShared.pathsEqual(av.path, bvi.path)) return false;
|
|
5608
5608
|
return dataEqual(av.data, bvi.data);
|
|
5609
5609
|
}
|
|
5610
5610
|
function errorsEqual(a, b) {
|
|
@@ -5779,12 +5779,12 @@ function resolveTrichotomy(input) {
|
|
|
5779
5779
|
|
|
5780
5780
|
function useAbstractForm(configuration, options) {
|
|
5781
5781
|
if (configuration === void 0 || configuration === null || configuration.schema === void 0) {
|
|
5782
|
-
throw new
|
|
5782
|
+
throw new devtoolsShared.InvalidUseFormConfigError();
|
|
5783
5783
|
}
|
|
5784
5784
|
const key = resolveFormKey(configuration.key);
|
|
5785
5785
|
const instance = vue.getCurrentInstance();
|
|
5786
|
-
if (instance !== null)
|
|
5787
|
-
const registry = options?.registry ??
|
|
5786
|
+
if (instance !== null) devtoolsShared.ensureAttaformInstalled(instance.appContext.app);
|
|
5787
|
+
const registry = options?.registry ?? devtoolsShared.useRegistry();
|
|
5788
5788
|
const resolvedDefaults = resolveTrichotomy(configuration.defaultValues);
|
|
5789
5789
|
const materialisedDefaults = resolvedDefaults.kind === "sync" ? resolvedDefaults.value : void 0;
|
|
5790
5790
|
const { defaultValues: _droppedDefaults, ...configWithoutDefaults } = configuration;
|
|
@@ -5799,7 +5799,7 @@ function useAbstractForm(configuration, options) {
|
|
|
5799
5799
|
});
|
|
5800
5800
|
const resolvedSchema = getComputedSchema(key, configuration.schema, { maxRecursionDepth });
|
|
5801
5801
|
const existing = registry.forms.get(key);
|
|
5802
|
-
if (
|
|
5802
|
+
if (devtoolsShared.__DEV__ && existing !== void 0) {
|
|
5803
5803
|
void import('../chunks/dev-key-collision-warnings.cjs').then((m) => {
|
|
5804
5804
|
void m.warnOnSchemaFingerprintMismatch(key, existing.schema, resolvedSchema);
|
|
5805
5805
|
});
|
|
@@ -5836,11 +5836,11 @@ function useAbstractForm(configuration, options) {
|
|
|
5836
5836
|
}
|
|
5837
5837
|
if (configuration.key === void 0) {
|
|
5838
5838
|
recordAmbientProvide(registry.ssr);
|
|
5839
|
-
vue.provide(
|
|
5839
|
+
vue.provide(devtoolsShared.kFormContext, state);
|
|
5840
5840
|
}
|
|
5841
5841
|
const formInstanceId = vue.getCurrentInstance() !== null ? vue.useId() : `atta:form-instance:${formInstanceCounter++}`;
|
|
5842
5842
|
if (vue.getCurrentInstance() !== null) {
|
|
5843
|
-
vue.provide(
|
|
5843
|
+
vue.provide(devtoolsShared.kFormInstanceId, formInstanceId);
|
|
5844
5844
|
}
|
|
5845
5845
|
const apiOptions = {};
|
|
5846
5846
|
if (merged.onInvalidSubmit !== void 0) {
|
|
@@ -5947,9 +5947,9 @@ function buildFreshState(key, schema, configuration, registry) {
|
|
|
5947
5947
|
}
|
|
5948
5948
|
let anonCounter = 0;
|
|
5949
5949
|
let formInstanceCounter = 0;
|
|
5950
|
-
const ambientProvideHistory =
|
|
5950
|
+
const ambientProvideHistory = devtoolsShared.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
|
|
5951
5951
|
function recordAmbientProvide(ssr) {
|
|
5952
|
-
if (!
|
|
5952
|
+
if (!devtoolsShared.__DEV__ || ssr || ambientProvideHistory === null) return;
|
|
5953
5953
|
const instance = vue.getCurrentInstance();
|
|
5954
5954
|
if (instance === null) return;
|
|
5955
5955
|
const instanceKey = instance;
|
|
@@ -5966,7 +5966,7 @@ function recordAmbientProvide(ssr) {
|
|
|
5966
5966
|
function resolveFormKey(key) {
|
|
5967
5967
|
if (key !== void 0 && key !== null && key !== "") {
|
|
5968
5968
|
if (key.startsWith(RESERVED_KEY_PREFIX)) {
|
|
5969
|
-
throw new
|
|
5969
|
+
throw new devtoolsShared.ReservedFormKeyError(key);
|
|
5970
5970
|
}
|
|
5971
5971
|
return key;
|
|
5972
5972
|
}
|
|
@@ -5981,8 +5981,8 @@ function injectForm(input) {
|
|
|
5981
5981
|
const key = typeof input === "string" ? input : input?.key;
|
|
5982
5982
|
const ssrAccessed = typeof input === "object" && input !== null ? input.__ssrAccessed === true : false;
|
|
5983
5983
|
const instance = vue.getCurrentInstance();
|
|
5984
|
-
if (instance !== null)
|
|
5985
|
-
const registry =
|
|
5984
|
+
if (instance !== null) devtoolsShared.ensureAttaformInstalled(instance.appContext.app);
|
|
5985
|
+
const registry = devtoolsShared.useRegistry();
|
|
5986
5986
|
const state = resolveState(key, registry);
|
|
5987
5987
|
if (state === null) return null;
|
|
5988
5988
|
if (vue.getCurrentScope() !== void 0) {
|
|
@@ -5998,7 +5998,7 @@ function injectForm(input) {
|
|
|
5998
5998
|
if (history !== void 0) {
|
|
5999
5999
|
apiOptions.history = history;
|
|
6000
6000
|
}
|
|
6001
|
-
const ambientInstanceId = vue.getCurrentInstance() !== null ? vue.inject(
|
|
6001
|
+
const ambientInstanceId = vue.getCurrentInstance() !== null ? vue.inject(devtoolsShared.kFormInstanceId, null) : null;
|
|
6002
6002
|
const formInstanceId = ambientInstanceId ?? (vue.getCurrentInstance() !== null ? vue.useId() : `atta:form-instance-injected:${injectedInstanceCounter++}`);
|
|
6003
6003
|
return buildFormApi(
|
|
6004
6004
|
state,
|
|
@@ -6015,7 +6015,7 @@ function resolveState(key, registry) {
|
|
|
6015
6015
|
}
|
|
6016
6016
|
return stored;
|
|
6017
6017
|
}
|
|
6018
|
-
const ambient = vue.inject(
|
|
6018
|
+
const ambient = vue.inject(devtoolsShared.kFormContext, null);
|
|
6019
6019
|
if (ambient === null) return null;
|
|
6020
6020
|
warnIfAmbientProviderHadDuplicates();
|
|
6021
6021
|
return ambient;
|
|
@@ -6026,7 +6026,7 @@ function availableKeysHint$1(forms) {
|
|
|
6026
6026
|
return `Registered keys: ${addressable.map((key) => `'${key}'`).join(", ")}.`;
|
|
6027
6027
|
}
|
|
6028
6028
|
function warnMiss$1(detail, ssr, forms) {
|
|
6029
|
-
if (!
|
|
6029
|
+
if (!devtoolsShared.__DEV__ || ssr) return;
|
|
6030
6030
|
const frame = captureUserCallSite();
|
|
6031
6031
|
const parts = [`[attaform] injectForm: ${detail}. Returning null.`];
|
|
6032
6032
|
const keys = availableKeysHint$1(forms);
|
|
@@ -6038,7 +6038,7 @@ function warnMiss$1(detail, ssr, forms) {
|
|
|
6038
6038
|
console.warn(parts.join(" "));
|
|
6039
6039
|
}
|
|
6040
6040
|
function warnIfAmbientProviderHadDuplicates() {
|
|
6041
|
-
if (!
|
|
6041
|
+
if (!devtoolsShared.__DEV__ || ambientProvideHistory === null) return;
|
|
6042
6042
|
let ancestor = vue.getCurrentInstance()?.parent ?? null;
|
|
6043
6043
|
while (ancestor !== null) {
|
|
6044
6044
|
const history = ambientProvideHistory.get(ancestor);
|
|
@@ -6055,7 +6055,7 @@ function warnIfAmbientProviderHadDuplicates() {
|
|
|
6055
6055
|
}
|
|
6056
6056
|
}
|
|
6057
6057
|
|
|
6058
|
-
const warnedNoParentRV =
|
|
6058
|
+
const warnedNoParentRV = devtoolsShared.__DEV__ ? /* @__PURE__ */ new WeakSet() : null;
|
|
6059
6059
|
let warnedOutsideSetup = false;
|
|
6060
6060
|
function makeRegisterValueProxy(capturedRegisterValue) {
|
|
6061
6061
|
return new Proxy({}, {
|
|
@@ -6094,7 +6094,7 @@ function useRegister() {
|
|
|
6094
6094
|
warnOutsideSetup();
|
|
6095
6095
|
return makeRegisterValueProxy(vue.shallowRef(void 0));
|
|
6096
6096
|
}
|
|
6097
|
-
|
|
6097
|
+
devtoolsShared.ensureAttaformInstalled(instance.appContext.app);
|
|
6098
6098
|
const capturedRegisterValue = vue.shallowRef(void 0);
|
|
6099
6099
|
const refreshAndStripBridgeAttrs = () => {
|
|
6100
6100
|
const rawAttrs = instance.attrs;
|
|
@@ -6132,7 +6132,7 @@ function useRegister() {
|
|
|
6132
6132
|
return makeRegisterValueProxy(capturedRegisterValue);
|
|
6133
6133
|
}
|
|
6134
6134
|
function warnOutsideSetup() {
|
|
6135
|
-
if (!
|
|
6135
|
+
if (!devtoolsShared.__DEV__) return;
|
|
6136
6136
|
if (warnedOutsideSetup) return;
|
|
6137
6137
|
warnedOutsideSetup = true;
|
|
6138
6138
|
const frame = captureUserCallSite();
|
|
@@ -6141,7 +6141,7 @@ function warnOutsideSetup() {
|
|
|
6141
6141
|
);
|
|
6142
6142
|
}
|
|
6143
6143
|
function warnNoParentRV(instance) {
|
|
6144
|
-
if (!
|
|
6144
|
+
if (!devtoolsShared.__DEV__ || warnedNoParentRV === null) return;
|
|
6145
6145
|
if (warnedNoParentRV.has(instance)) return;
|
|
6146
6146
|
warnedNoParentRV.add(instance);
|
|
6147
6147
|
const frame = captureUserCallSite();
|
|
@@ -6150,7 +6150,7 @@ function warnNoParentRV(instance) {
|
|
|
6150
6150
|
);
|
|
6151
6151
|
}
|
|
6152
6152
|
|
|
6153
|
-
const LAZY_BRAND = Symbol.for("attaform/wizard-lazy");
|
|
6153
|
+
const LAZY_BRAND = /* @__PURE__ */ Symbol.for("attaform/wizard-lazy");
|
|
6154
6154
|
function lazy(resolve) {
|
|
6155
6155
|
return { [LAZY_BRAND]: true, resolve };
|
|
6156
6156
|
}
|
|
@@ -6300,12 +6300,12 @@ function asHandleSubmitSource(form) {
|
|
|
6300
6300
|
}
|
|
6301
6301
|
function useWizard(options) {
|
|
6302
6302
|
const rawSteps = Array.isArray(options.steps) ? options.steps : [];
|
|
6303
|
-
if (rawSteps.length === 0 &&
|
|
6303
|
+
if (rawSteps.length === 0 && devtoolsShared.__DEV__) {
|
|
6304
6304
|
console.error(
|
|
6305
6305
|
"[attaform] useWizard({ steps }): expected a non-empty array of step slots. Continuing with an empty step list \u2014 wizard.currentStep reads as undefined, navigation refuses, handleSubmit no-ops."
|
|
6306
6306
|
);
|
|
6307
6307
|
}
|
|
6308
|
-
const registry =
|
|
6308
|
+
const registry = devtoolsShared.useRegistry();
|
|
6309
6309
|
const noopForms = /* @__PURE__ */ new Map();
|
|
6310
6310
|
const lazyNoopScope = vue.effectScope(true);
|
|
6311
6311
|
for (const slot of rawSteps) {
|
|
@@ -6436,7 +6436,7 @@ function useWizard(options) {
|
|
|
6436
6436
|
const form = resolveSlot(slot, i, slotCtx);
|
|
6437
6437
|
if (form === void 0) continue;
|
|
6438
6438
|
if (seen.has(form.key)) {
|
|
6439
|
-
if (
|
|
6439
|
+
if (devtoolsShared.__DEV__) {
|
|
6440
6440
|
console.warn(
|
|
6441
6441
|
`[attaform] useWizard: step "${form.key}" appears in more than one slot. The wizard treats the first occurrence as canonical and drops later duplicates.`
|
|
6442
6442
|
);
|
|
@@ -6695,7 +6695,7 @@ function useWizard(options) {
|
|
|
6695
6695
|
}
|
|
6696
6696
|
});
|
|
6697
6697
|
const statuses = buildWizardStatusesProxy(statusesRecord);
|
|
6698
|
-
if (
|
|
6698
|
+
if (devtoolsShared.__DEV__ && seedRef.value !== void 0) {
|
|
6699
6699
|
const seedMap = seedRef.value;
|
|
6700
6700
|
const known = new Set(compiledSteps.value.map((s) => s.key));
|
|
6701
6701
|
const unknown = [];
|
|
@@ -6734,7 +6734,7 @@ function useWizard(options) {
|
|
|
6734
6734
|
const visited = vue.ref([]);
|
|
6735
6735
|
const wantsDefaultUrlSync = options.restore !== false || options.persist !== false;
|
|
6736
6736
|
const historyHandle = wantsDefaultUrlSync ? createWizardHistory(DEFAULT_STEP_PARAM) : NOOP_WIZARD_HISTORY;
|
|
6737
|
-
const injectedResolver = vue.inject(
|
|
6737
|
+
const injectedResolver = vue.inject(devtoolsShared.kAttaformWizardActiveStepResolver, null);
|
|
6738
6738
|
const urlMirror = vue.ref(void 0);
|
|
6739
6739
|
const initialUrlValue = injectedResolver !== null ? injectedResolver(DEFAULT_STEP_PARAM) : historyHandle.read();
|
|
6740
6740
|
urlMirror.value = initialUrlValue;
|
|
@@ -6767,7 +6767,7 @@ function useWizard(options) {
|
|
|
6767
6767
|
if (restoredStep !== void 0 && isCompiledKey(restoredStep)) {
|
|
6768
6768
|
initialKey = restoredStep;
|
|
6769
6769
|
} else {
|
|
6770
|
-
if (
|
|
6770
|
+
if (devtoolsShared.__DEV__ && restoredStep !== void 0 && restoredStep !== "" && !isCompiledKey(restoredStep)) {
|
|
6771
6771
|
console.warn(
|
|
6772
6772
|
`[attaform] useWizard: restore() yielded step "${restoredStep}" which is not in the compiled step list. Falling back to the first step.`
|
|
6773
6773
|
);
|
|
@@ -6800,7 +6800,7 @@ function useWizard(options) {
|
|
|
6800
6800
|
(step) => {
|
|
6801
6801
|
if (step === void 0) return;
|
|
6802
6802
|
if (!isCompiledKey(step)) {
|
|
6803
|
-
if (
|
|
6803
|
+
if (devtoolsShared.__DEV__) {
|
|
6804
6804
|
console.warn(
|
|
6805
6805
|
`[attaform] useWizard: restore() yielded step "${step}" which is not in the compiled step list. Ignoring.`
|
|
6806
6806
|
);
|
|
@@ -6857,7 +6857,7 @@ function useWizard(options) {
|
|
|
6857
6857
|
}
|
|
6858
6858
|
async function next() {
|
|
6859
6859
|
if (submitting.value) {
|
|
6860
|
-
if (
|
|
6860
|
+
if (devtoolsShared.__DEV__) {
|
|
6861
6861
|
console.warn(
|
|
6862
6862
|
`[attaform] wizard.next(): blocked while a submit is in flight. Wait for handleSubmit to settle.`
|
|
6863
6863
|
);
|
|
@@ -6866,14 +6866,14 @@ function useWizard(options) {
|
|
|
6866
6866
|
}
|
|
6867
6867
|
const list = compiledSteps.value;
|
|
6868
6868
|
if (list.length === 0) {
|
|
6869
|
-
if (
|
|
6869
|
+
if (devtoolsShared.__DEV__) {
|
|
6870
6870
|
console.warn(`[attaform] wizard.next(): wizard has no compiled steps; no-op.`);
|
|
6871
6871
|
}
|
|
6872
6872
|
return;
|
|
6873
6873
|
}
|
|
6874
6874
|
const idx = activeIndex.value;
|
|
6875
6875
|
if (idx < 0 || idx >= list.length - 1) {
|
|
6876
|
-
if (
|
|
6876
|
+
if (devtoolsShared.__DEV__) {
|
|
6877
6877
|
console.warn(
|
|
6878
6878
|
`[attaform] wizard.next(): already on the final step ("${activeKey.value}"). Use wizard.handleSubmit() to submit.`
|
|
6879
6879
|
);
|
|
@@ -6886,21 +6886,21 @@ function useWizard(options) {
|
|
|
6886
6886
|
}
|
|
6887
6887
|
async function tryNext() {
|
|
6888
6888
|
if (submitting.value) {
|
|
6889
|
-
if (
|
|
6889
|
+
if (devtoolsShared.__DEV__) {
|
|
6890
6890
|
console.warn(`[attaform] wizard.tryNext(): blocked while a submit is in flight.`);
|
|
6891
6891
|
}
|
|
6892
6892
|
return false;
|
|
6893
6893
|
}
|
|
6894
6894
|
const list = compiledSteps.value;
|
|
6895
6895
|
if (list.length === 0) {
|
|
6896
|
-
if (
|
|
6896
|
+
if (devtoolsShared.__DEV__) {
|
|
6897
6897
|
console.warn(`[attaform] wizard.tryNext(): wizard has no compiled steps; no-op.`);
|
|
6898
6898
|
}
|
|
6899
6899
|
return false;
|
|
6900
6900
|
}
|
|
6901
6901
|
const idx = activeIndex.value;
|
|
6902
6902
|
if (idx < 0 || idx >= list.length - 1) {
|
|
6903
|
-
if (
|
|
6903
|
+
if (devtoolsShared.__DEV__) {
|
|
6904
6904
|
console.warn(
|
|
6905
6905
|
`[attaform] wizard.tryNext(): already on the final step ("${activeKey.value}"). Use wizard.handleSubmit() to submit.`
|
|
6906
6906
|
);
|
|
@@ -6919,20 +6919,20 @@ function useWizard(options) {
|
|
|
6919
6919
|
}
|
|
6920
6920
|
function back() {
|
|
6921
6921
|
if (submitting.value) {
|
|
6922
|
-
if (
|
|
6922
|
+
if (devtoolsShared.__DEV__) {
|
|
6923
6923
|
console.warn(`[attaform] wizard.back(): blocked while a submit is in flight.`);
|
|
6924
6924
|
}
|
|
6925
6925
|
return;
|
|
6926
6926
|
}
|
|
6927
6927
|
if (compiledSteps.value.length === 0) {
|
|
6928
|
-
if (
|
|
6928
|
+
if (devtoolsShared.__DEV__) {
|
|
6929
6929
|
console.warn(`[attaform] wizard.back(): wizard has no compiled steps; no-op.`);
|
|
6930
6930
|
}
|
|
6931
6931
|
return;
|
|
6932
6932
|
}
|
|
6933
6933
|
const idx = activeIndex.value;
|
|
6934
6934
|
if (idx <= 0) {
|
|
6935
|
-
if (
|
|
6935
|
+
if (devtoolsShared.__DEV__) {
|
|
6936
6936
|
console.warn(`[attaform] wizard.back(): already on the first step ("${activeKey.value}").`);
|
|
6937
6937
|
}
|
|
6938
6938
|
return;
|
|
@@ -6943,13 +6943,13 @@ function useWizard(options) {
|
|
|
6943
6943
|
}
|
|
6944
6944
|
function goTo(key) {
|
|
6945
6945
|
if (submitting.value) {
|
|
6946
|
-
if (
|
|
6946
|
+
if (devtoolsShared.__DEV__) {
|
|
6947
6947
|
console.warn(`[attaform] wizard.goTo(): blocked while a submit is in flight.`);
|
|
6948
6948
|
}
|
|
6949
6949
|
return;
|
|
6950
6950
|
}
|
|
6951
6951
|
if (!isCompiledKey(key)) {
|
|
6952
|
-
if (
|
|
6952
|
+
if (devtoolsShared.__DEV__) {
|
|
6953
6953
|
const known = compiledSteps.value.map((s) => `"${s.key}"`).join(", ");
|
|
6954
6954
|
console.warn(`[attaform] wizard.goTo("${key}"): unknown step key. Known keys: ${known}.`);
|
|
6955
6955
|
}
|
|
@@ -7033,13 +7033,13 @@ function useWizard(options) {
|
|
|
7033
7033
|
event.preventDefault();
|
|
7034
7034
|
}
|
|
7035
7035
|
if (compiledSteps.value.length === 0) {
|
|
7036
|
-
if (
|
|
7036
|
+
if (devtoolsShared.__DEV__) {
|
|
7037
7037
|
console.warn(`[attaform] wizard.handleSubmit: wizard has no compiled steps; no-op.`);
|
|
7038
7038
|
}
|
|
7039
7039
|
return;
|
|
7040
7040
|
}
|
|
7041
7041
|
if (submitting.value) {
|
|
7042
|
-
if (
|
|
7042
|
+
if (devtoolsShared.__DEV__) {
|
|
7043
7043
|
console.warn(
|
|
7044
7044
|
`[attaform] wizard.handleSubmit: re-entrant submit while a prior call is still in flight; resolving no-op.`
|
|
7045
7045
|
);
|
|
@@ -7089,7 +7089,7 @@ function useWizard(options) {
|
|
|
7089
7089
|
try {
|
|
7090
7090
|
await onError(callbackErrors);
|
|
7091
7091
|
} catch (cause) {
|
|
7092
|
-
throw new
|
|
7092
|
+
throw new devtoolsShared.SubmitErrorHandlerError("User-provided onError threw", { cause });
|
|
7093
7093
|
}
|
|
7094
7094
|
}
|
|
7095
7095
|
return;
|
|
@@ -7101,12 +7101,12 @@ function useWizard(options) {
|
|
|
7101
7101
|
try {
|
|
7102
7102
|
await onError(errors);
|
|
7103
7103
|
} catch (cause) {
|
|
7104
|
-
throw new
|
|
7104
|
+
throw new devtoolsShared.SubmitErrorHandlerError("User-provided onError threw", { cause });
|
|
7105
7105
|
}
|
|
7106
7106
|
}
|
|
7107
7107
|
}
|
|
7108
7108
|
} catch (err) {
|
|
7109
|
-
submitError.value =
|
|
7109
|
+
submitError.value = devtoolsShared.toError(err);
|
|
7110
7110
|
} finally {
|
|
7111
7111
|
submitting.value = false;
|
|
7112
7112
|
}
|
|
@@ -7202,7 +7202,7 @@ function useWizard(options) {
|
|
|
7202
7202
|
const existing = registry.wizards.get(wizardKey);
|
|
7203
7203
|
if (existing === void 0) {
|
|
7204
7204
|
registry.wizards.set(wizardKey, handle);
|
|
7205
|
-
} else if (
|
|
7205
|
+
} else if (devtoolsShared.__DEV__ && explicitKey !== void 0) {
|
|
7206
7206
|
console.warn(
|
|
7207
7207
|
`[attaform] useWizard({ key: "${wizardKey}" }): a wizard with this key is already registered. Keeping the existing handle. Pass a unique key to each useWizard call, or share the original handle via injectWizard("${wizardKey}").`
|
|
7208
7208
|
);
|
|
@@ -7213,14 +7213,14 @@ function useWizard(options) {
|
|
|
7213
7213
|
}
|
|
7214
7214
|
if (vue.getCurrentInstance() !== null && explicitKey === void 0) {
|
|
7215
7215
|
recordAmbientWizardProvide(registry.ssr);
|
|
7216
|
-
vue.provide(
|
|
7216
|
+
vue.provide(devtoolsShared.kAttaformAncestorWizard, handle);
|
|
7217
7217
|
}
|
|
7218
7218
|
return handle;
|
|
7219
7219
|
}
|
|
7220
7220
|
let anonWizardCounter = 0;
|
|
7221
|
-
const ambientWizardProvideHistory =
|
|
7221
|
+
const ambientWizardProvideHistory = devtoolsShared.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
|
|
7222
7222
|
function recordAmbientWizardProvide(ssr) {
|
|
7223
|
-
if (!
|
|
7223
|
+
if (!devtoolsShared.__DEV__ || ssr || ambientWizardProvideHistory === null) return;
|
|
7224
7224
|
const instance = vue.getCurrentInstance();
|
|
7225
7225
|
if (instance === null) return;
|
|
7226
7226
|
const instanceKey = instance;
|
|
@@ -7250,8 +7250,8 @@ function isAnyForm(value) {
|
|
|
7250
7250
|
function injectWizard(input) {
|
|
7251
7251
|
const key = typeof input === "string" ? input : input?.key;
|
|
7252
7252
|
const instance = vue.getCurrentInstance();
|
|
7253
|
-
if (instance !== null)
|
|
7254
|
-
const registry =
|
|
7253
|
+
if (instance !== null) devtoolsShared.ensureAttaformInstalled(instance.appContext.app);
|
|
7254
|
+
const registry = devtoolsShared.useRegistry();
|
|
7255
7255
|
if (key !== void 0) {
|
|
7256
7256
|
const handle = registry.wizards.get(key);
|
|
7257
7257
|
if (handle === void 0) {
|
|
@@ -7268,7 +7268,7 @@ function injectWizard(input) {
|
|
|
7268
7268
|
}
|
|
7269
7269
|
return handle;
|
|
7270
7270
|
}
|
|
7271
|
-
const ambient = vue.inject(
|
|
7271
|
+
const ambient = vue.inject(devtoolsShared.kAttaformAncestorWizard, null);
|
|
7272
7272
|
if (ambient === null) return null;
|
|
7273
7273
|
warnIfAmbientWizardProviderHadDuplicates();
|
|
7274
7274
|
return ambient;
|
|
@@ -7279,7 +7279,7 @@ function availableKeysHint(wizards) {
|
|
|
7279
7279
|
return `Registered keys: ${keys}.`;
|
|
7280
7280
|
}
|
|
7281
7281
|
function warnMiss(detail, ssr, hint) {
|
|
7282
|
-
if (!
|
|
7282
|
+
if (!devtoolsShared.__DEV__ || ssr) return;
|
|
7283
7283
|
const frame = captureUserCallSite();
|
|
7284
7284
|
const parts = [`[attaform] injectWizard: ${detail}. Returning null.`];
|
|
7285
7285
|
if (hint !== void 0) parts.push(hint);
|
|
@@ -7290,7 +7290,7 @@ function warnMiss(detail, ssr, hint) {
|
|
|
7290
7290
|
console.warn(parts.join(" "));
|
|
7291
7291
|
}
|
|
7292
7292
|
function warnIfAmbientWizardProviderHadDuplicates() {
|
|
7293
|
-
if (!
|
|
7293
|
+
if (!devtoolsShared.__DEV__ || ambientWizardProvideHistory === null) return;
|
|
7294
7294
|
let ancestor = vue.getCurrentInstance()?.parent ?? null;
|
|
7295
7295
|
while (ancestor !== null) {
|
|
7296
7296
|
const history = ambientWizardProvideHistory.get(ancestor);
|
|
@@ -7307,11 +7307,31 @@ function warnIfAmbientWizardProviderHadDuplicates() {
|
|
|
7307
7307
|
}
|
|
7308
7308
|
}
|
|
7309
7309
|
|
|
7310
|
+
function escapeForInlineScript(json) {
|
|
7311
|
+
return json.replace(/[<>&\u2028\u2029]/g, (char) => {
|
|
7312
|
+
switch (char) {
|
|
7313
|
+
case "<":
|
|
7314
|
+
return "\\u003c";
|
|
7315
|
+
case ">":
|
|
7316
|
+
return "\\u003e";
|
|
7317
|
+
case "&":
|
|
7318
|
+
return "\\u0026";
|
|
7319
|
+
case "\u2028":
|
|
7320
|
+
return "\\u2028";
|
|
7321
|
+
case "\u2029":
|
|
7322
|
+
return "\\u2029";
|
|
7323
|
+
default:
|
|
7324
|
+
return char;
|
|
7325
|
+
}
|
|
7326
|
+
});
|
|
7327
|
+
}
|
|
7328
|
+
|
|
7310
7329
|
exports.AttaformErrorCode = AttaformErrorCode;
|
|
7311
7330
|
exports.DEFAULT_TIMINGS = DEFAULT_TIMINGS;
|
|
7312
7331
|
exports.defaultCoercionRules = defaultCoercionRules;
|
|
7313
7332
|
exports.defaultDisplayState = defaultDisplayState;
|
|
7314
7333
|
exports.defineCoercion = defineCoercion;
|
|
7334
|
+
exports.escapeForInlineScript = escapeForInlineScript;
|
|
7315
7335
|
exports.getAtPath = getAtPath;
|
|
7316
7336
|
exports.humanize = humanize;
|
|
7317
7337
|
exports.injectForm = injectForm;
|
|
@@ -7328,4 +7348,4 @@ exports.unset = unset;
|
|
|
7328
7348
|
exports.useAbstractForm = useAbstractForm;
|
|
7329
7349
|
exports.useRegister = useRegister;
|
|
7330
7350
|
exports.useWizard = useWizard;
|
|
7331
|
-
//# sourceMappingURL=attaform.
|
|
7351
|
+
//# sourceMappingURL=attaform.DQT7_-FO.cjs.map
|