attaform 0.20.0 → 0.20.2
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 +4 -1
- package/dist/chunks/devtools.cjs +2 -2
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +2 -2
- package/dist/chunks/devtools.mjs.map +1 -1
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +5 -5
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.SfhU0OEY.d.ts → attaform.99cfHcIt.d.cts} +26 -9
- package/dist/shared/{attaform.SfhU0OEY.d.mts → attaform.99cfHcIt.d.mts} +26 -9
- package/dist/shared/{attaform.SfhU0OEY.d.cts → attaform.99cfHcIt.d.ts} +26 -9
- package/dist/shared/{attaform.BWgAFnsj.mjs → attaform.BGk8cfw2.mjs} +14 -10
- package/dist/shared/attaform.BGk8cfw2.mjs.map +1 -0
- package/dist/shared/{attaform.DoKXru-a.d.mts → attaform.BXinSW2T.d.mts} +1 -1
- package/dist/shared/{attaform.Dmb6itxC.cjs → attaform.B_hph5AE.cjs} +14 -10
- package/dist/shared/attaform.B_hph5AE.cjs.map +1 -0
- package/dist/shared/{attaform.DEBvCjeH.mjs → attaform.C5aYC_T8.mjs} +4 -4
- package/dist/shared/{attaform.DEBvCjeH.mjs.map → attaform.C5aYC_T8.mjs.map} +1 -1
- package/dist/shared/{attaform.CIn4bMsD.cjs → attaform.Cd4AOfwu.cjs} +4 -4
- package/dist/shared/{attaform.CIn4bMsD.cjs.map → attaform.Cd4AOfwu.cjs.map} +1 -1
- package/dist/shared/{attaform.EZG6fOFb.mjs → attaform.CnrxbkB6.mjs} +2 -2
- package/dist/shared/{attaform.EZG6fOFb.mjs.map → attaform.CnrxbkB6.mjs.map} +1 -1
- package/dist/shared/{attaform.DL4CQ-oW.cjs → attaform.CwLjUqmQ.cjs} +101 -50
- package/dist/shared/attaform.CwLjUqmQ.cjs.map +1 -0
- package/dist/shared/{attaform.GbDo_lJi.d.cts → attaform.CywE4y8x.d.cts} +1 -1
- package/dist/shared/{attaform.BPxsYtTe.cjs → attaform.D2SCCd4O.cjs} +2 -2
- package/dist/shared/{attaform.BPxsYtTe.cjs.map → attaform.D2SCCd4O.cjs.map} +1 -1
- package/dist/shared/{attaform.jgzuNZVC.cjs → attaform.DAKrGhxc.cjs} +4 -4
- package/dist/shared/{attaform.jgzuNZVC.cjs.map → attaform.DAKrGhxc.cjs.map} +1 -1
- package/dist/shared/{attaform.Dl5kDY-A.d.ts → attaform.DN5CvZrg.d.ts} +1 -1
- package/dist/shared/{attaform.D5-1XGQU.d.cts → attaform.DbRgDFa7.d.cts} +1 -1
- package/dist/shared/{attaform.DvA-CJJW.mjs → attaform.Dt7dEcHk.mjs} +4 -4
- package/dist/shared/{attaform.DvA-CJJW.mjs.map → attaform.Dt7dEcHk.mjs.map} +1 -1
- package/dist/shared/{attaform.BKozEdTr.mjs → attaform.QG5TG8lB.mjs} +51 -35
- package/dist/shared/attaform.QG5TG8lB.mjs.map +1 -0
- package/dist/shared/{attaform.EMzJcQci.d.mts → attaform.ceGEAEMk.d.ts} +1 -1
- package/dist/shared/{attaform.Bh3ACtts.d.ts → attaform.sWm8B15V.d.mts} +1 -1
- package/dist/shared/{attaform.CKFbKFb6.mjs → attaform.tiWEVznj.mjs} +100 -51
- package/dist/shared/attaform.tiWEVznj.mjs.map +1 -0
- package/dist/shared/{attaform.BPy-4qRx.cjs → attaform.z5j3LwJz.cjs} +51 -34
- package/dist/shared/attaform.z5j3LwJz.cjs.map +1 -0
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +3 -3
- package/dist/zod-v3.d.mts +3 -3
- package/dist/zod-v3.d.ts +3 -3
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +4 -4
- package/dist/zod-v4.d.mts +4 -4
- package/dist/zod-v4.d.ts +4 -4
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +5 -5
- package/dist/zod.d.cts +5 -5
- package/dist/zod.d.mts +5 -5
- package/dist/zod.d.ts +5 -5
- package/dist/zod.mjs +6 -6
- package/package.json +4 -3
- package/dist/shared/attaform.BKozEdTr.mjs.map +0 -1
- package/dist/shared/attaform.BPy-4qRx.cjs.map +0 -1
- package/dist/shared/attaform.BWgAFnsj.mjs.map +0 -1
- package/dist/shared/attaform.CKFbKFb6.mjs.map +0 -1
- package/dist/shared/attaform.DL4CQ-oW.cjs.map +0 -1
- package/dist/shared/attaform.Dmb6itxC.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as getRegistryFromApp, E as pathKeyToDotted } from './attaform.QG5TG8lB.mjs';
|
|
2
2
|
|
|
3
3
|
function renderAttaformState(app) {
|
|
4
4
|
const registry = getRegistryFromApp(app);
|
|
@@ -32,4 +32,4 @@ function hydrateAttaformState(app, payload) {
|
|
|
32
32
|
const DEVTOOLS_WINDOW_KEY = "__attaform_devtools__";
|
|
33
33
|
|
|
34
34
|
export { DEVTOOLS_WINDOW_KEY as D, hydrateAttaformState as h, renderAttaformState as r };
|
|
35
|
-
//# sourceMappingURL=attaform.
|
|
35
|
+
//# sourceMappingURL=attaform.CnrxbkB6.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attaform.
|
|
1
|
+
{"version":3,"file":"attaform.CnrxbkB6.mjs","sources":["../../src/runtime/core/serialize.ts","../../src/runtime/core/devtools-shared.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormKey } from '../types/types-api'\nimport { pathKeyToDotted, type PathKey } from './paths'\nimport { getRegistryFromApp, type SerializedFormData } from './registry'\n\n/**\n * Serialised snapshot of every form in a Vue app, produced by\n * `renderAttaformState` and consumed by `hydrateAttaformState`.\n *\n * JSON-safe — pass to `JSON.stringify`, `devalue`, or any other\n * serialiser before embedding in your SSR payload.\n */\nexport type SerializedAttaformState = {\n /** Tuples of `[formKey, snapshot]` for every form in the app. */\n readonly forms: ReadonlyArray<readonly [FormKey, SerializedFormData]>\n}\n\n/**\n * Snapshot every form on a Vue app for SSR. Call from your server\n * entry after rendering the app:\n *\n * ```ts\n * import { renderToString } from '@vue/server-renderer'\n * import { renderAttaformState, escapeForInlineScript } from 'attaform'\n *\n * const html = await renderToString(app)\n * const state = renderAttaformState(app)\n * const payload = escapeForInlineScript(JSON.stringify(state))\n *\n * return `\n * ${html}\n * <script>window.__ATTAFORM_STATE__ = ${payload}</script>\n * `\n * ```\n *\n * Pair with `hydrateAttaformState` on the client to restore the\n * forms in their server-rendered state. Nuxt users don't need this —\n * `attaform/nuxt` wires SSR automatically.\n */\nexport function renderAttaformState(app: App): SerializedAttaformState {\n const registry = getRegistryFromApp(app)\n const forms: Array<readonly [FormKey, SerializedFormData]> = []\n for (const [key, state] of registry.forms) {\n // Skip the blank field when the set is empty so the\n // wire payload stays minimal for forms that don't use it. The\n // optional shape on the consuming side handles the absence\n // cleanly (defaults to \"no blank paths\"). PathKey → dotted at\n // the boundary so the wire shape matches the rest of the\n // public path notation.\n const transientList: string[] = []\n for (const pk of state.blankPaths) {\n const d = pathKeyToDotted(pk as PathKey)\n if (d !== null) transientList.push(d)\n }\n forms.push([\n key,\n {\n form: state.form.value,\n schemaErrors: Array.from(state.schemaErrors.entries()),\n userErrors: Array.from(state.userErrors.entries()),\n fields: Array.from(state.fields.entries()),\n ...(transientList.length > 0 ? { blankPaths: transientList } : {}),\n },\n ])\n }\n return { forms }\n}\n\n/**\n * Restore forms from a server-rendered snapshot on the client. Call\n * from your client entry before mounting:\n *\n * ```ts\n * import { createApp } from 'vue'\n * import { createAttaform, hydrateAttaformState } from 'attaform'\n *\n * const app = createApp(App).use(createAttaform())\n * hydrateAttaformState(app, window.__ATTAFORM_STATE__)\n * app.mount('#app')\n * ```\n *\n * The next `useForm({ key })` call for each serialised form picks up\n * the snapshot transparently — no further action is required.\n */\nexport function hydrateAttaformState(app: App, payload: SerializedAttaformState): void {\n const registry = getRegistryFromApp(app)\n for (const [key, data] of payload.forms) {\n registry.pendingHydration.set(key, data)\n }\n}\n","/**\n * Shared building blocks for Attaform's two devtools surfaces — the Vue\n * DevTools (Chrome-extension) inspector wired up in `./devtools.ts`, and\n * the Nuxt DevTools (overlay) panel wired up via `../../nuxt.ts` +\n * `../pages/_attaform_devtools.vue`.\n *\n * Houses the window-bridge contract both surfaces consume so a new\n * bridge field lands in one file. Both surfaces render RAW form values\n * by design — DevTools is a dev-only surface, and redaction across every\n * place a value surfaces is impractical security theater rather than a\n * real safeguard.\n */\nimport type { AttaformRegistry } from './registry'\n\n/**\n * Property key on `window` that the Nuxt-side dev plugin attaches the\n * bridge object to. The iframe-mounted overlay panel reads\n * `window.parent[DEVTOOLS_WINDOW_KEY]` to reach the host app's registry.\n *\n * Underscored + namespaced to make accidental collision with consumer\n * globals vanishingly unlikely. Stable across versions — bumping it\n * would silently disconnect older library builds from newer overlay\n * panels in the same browser tab during a library upgrade.\n */\nexport const DEVTOOLS_WINDOW_KEY = '__attaform_devtools__'\n\n/**\n * Shape of the object the host plugin attaches to `window` in dev mode.\n * The iframe overlay panel reads this to discover the live registry and\n * render its forms.\n *\n * Single-registry assumption: the latest `createAttaform()` install\n * wins. Multi-app pages (rare; typically only seen in micro-frontend\n * setups) will only see one app's forms in the panel. Documented but\n * not actively supported — the alternative (a Set of registries with\n * union-rendering) is a future call if a real consumer hits it.\n */\nexport interface AttaformDevtoolsBridge {\n registry: AttaformRegistry\n /**\n * The library version, surfaced in the panel's footer for support /\n * bug-report context. Read from `package.json` at host-plugin init.\n */\n version: string\n}\n\ndeclare global {\n interface Window {\n [DEVTOOLS_WINDOW_KEY]?: AttaformDevtoolsBridge\n }\n}\n"],"names":[],"mappings":";;AAuCO,SAAS,oBAAoB,GAAA,EAAmC;AACrE,EAAA,MAAM,QAAA,GAAW,mBAAmB,GAAG,CAAA;AACvC,EAAA,MAAM,QAAuD,EAAC;AAC9D,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,CAAA,IAAK,SAAS,KAAA,EAAO;AAOzC,IAAA,MAAM,gBAA0B,EAAC;AACjC,IAAA,KAAA,MAAW,EAAA,IAAM,MAAM,UAAA,EAAY;AACjC,MAAA,MAAM,CAAA,GAAI,gBAAgB,EAAa,CAAA;AACvC,MAAA,IAAI,CAAA,KAAM,IAAA,EAAM,aAAA,CAAc,IAAA,CAAK,CAAC,CAAA;AAAA,IACtC;AACA,IAAA,KAAA,CAAM,IAAA,CAAK;AAAA,MACT,GAAA;AAAA,MACA;AAAA,QACE,IAAA,EAAM,MAAM,IAAA,CAAK,KAAA;AAAA,QACjB,cAAc,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,SAAS,CAAA;AAAA,QACrD,YAAY,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,UAAA,CAAW,SAAS,CAAA;AAAA,QACjD,QAAQ,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,SAAS,CAAA;AAAA,QACzC,GAAI,cAAc,MAAA,GAAS,CAAA,GAAI,EAAE,UAAA,EAAY,aAAA,KAAkB;AAAC;AAClE,KACD,CAAA;AAAA,EACH;AACA,EAAA,OAAO,EAAE,KAAA,EAAM;AACjB;AAkBO,SAAS,oBAAA,CAAqB,KAAU,OAAA,EAAwC;AACrF,EAAA,MAAM,QAAA,GAAW,mBAAmB,GAAG,CAAA;AACvC,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,IAAI,CAAA,IAAK,QAAQ,KAAA,EAAO;AACvC,IAAA,QAAA,CAAS,gBAAA,CAAiB,GAAA,CAAI,GAAA,EAAK,IAAI,CAAA;AAAA,EACzC;AACF;;ACjEO,MAAM,mBAAA,GAAsB;;;;"}
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const paths = require('./attaform.
|
|
4
|
+
const paths = require('./attaform.z5j3LwJz.cjs');
|
|
5
|
+
|
|
6
|
+
function safeAssign(target, key, value) {
|
|
7
|
+
if (key === "__proto__") {
|
|
8
|
+
Object.defineProperty(target, key, {
|
|
9
|
+
value,
|
|
10
|
+
writable: true,
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true
|
|
13
|
+
});
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
target[key] = value;
|
|
17
|
+
}
|
|
18
|
+
function safeOwnRead(target, key) {
|
|
19
|
+
if (key === "__proto__") {
|
|
20
|
+
const desc = Object.getOwnPropertyDescriptor(target, "__proto__");
|
|
21
|
+
return desc?.value;
|
|
22
|
+
}
|
|
23
|
+
return target[key];
|
|
24
|
+
}
|
|
25
|
+
function safeOwnHas(target, key) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(target, key);
|
|
27
|
+
}
|
|
5
28
|
|
|
6
29
|
const NOT_FOUND = Symbol("NOT_FOUND");
|
|
7
30
|
function descendStep(value, segment) {
|
|
@@ -64,8 +87,8 @@ function setAtPathOffset(root, path, value, offset) {
|
|
|
64
87
|
arr[head] = setAtPathOffset(arr[head], path, value, nextOffset);
|
|
65
88
|
return arr;
|
|
66
89
|
}
|
|
67
|
-
const rec = isPlainRecord(root) ?
|
|
68
|
-
rec
|
|
90
|
+
const rec = isPlainRecord(root) ? { ...root } : {};
|
|
91
|
+
safeAssign(rec, head, setAtPathOffset(safeOwnRead(rec, head), path, value, nextOffset));
|
|
69
92
|
return rec;
|
|
70
93
|
}
|
|
71
94
|
function deleteAtPath(root, path) {
|
|
@@ -94,9 +117,9 @@ function deleteAtPathOffset(root, path, offset) {
|
|
|
94
117
|
delete rec2[head];
|
|
95
118
|
return rec2;
|
|
96
119
|
}
|
|
97
|
-
if (!(head
|
|
120
|
+
if (!safeOwnHas(root, head)) return root;
|
|
98
121
|
const rec = { ...root };
|
|
99
|
-
rec
|
|
122
|
+
safeAssign(rec, head, deleteAtPathOffset(safeOwnRead(rec, head), path, nextOffset));
|
|
100
123
|
return rec;
|
|
101
124
|
}
|
|
102
125
|
function resolveArrayShape(schema, scratch) {
|
|
@@ -165,27 +188,27 @@ function mergeStructuralImpl(schema, scratch, consumer, defaultValue) {
|
|
|
165
188
|
return consumer;
|
|
166
189
|
}
|
|
167
190
|
let mutated = false;
|
|
168
|
-
const out =
|
|
191
|
+
const out = { ...consumer };
|
|
169
192
|
for (const key of Object.keys(defaultValue)) {
|
|
170
|
-
if (!(key
|
|
171
|
-
const defAtKey = defaultValue
|
|
193
|
+
if (!safeOwnHas(consumer, key)) {
|
|
194
|
+
const defAtKey = safeOwnRead(defaultValue, key);
|
|
172
195
|
scratch.push(key);
|
|
173
196
|
const filled = mergeStructuralImpl(schema, scratch, void 0, defAtKey);
|
|
174
197
|
scratch.pop();
|
|
175
198
|
if (filled !== void 0) {
|
|
176
|
-
out
|
|
199
|
+
safeAssign(out, key, filled);
|
|
177
200
|
mutated = true;
|
|
178
201
|
}
|
|
179
202
|
}
|
|
180
203
|
}
|
|
181
204
|
for (const key of Object.keys(consumer)) {
|
|
182
|
-
const cVal = consumer
|
|
205
|
+
const cVal = safeOwnRead(consumer, key);
|
|
183
206
|
if (cVal === void 0) continue;
|
|
184
207
|
scratch.push(key);
|
|
185
|
-
const merged = mergeStructuralImpl(schema, scratch, cVal, defaultValue
|
|
208
|
+
const merged = mergeStructuralImpl(schema, scratch, cVal, safeOwnRead(defaultValue, key));
|
|
186
209
|
scratch.pop();
|
|
187
210
|
if (merged !== cVal) {
|
|
188
|
-
out
|
|
211
|
+
safeAssign(out, key, merged);
|
|
189
212
|
mutated = true;
|
|
190
213
|
}
|
|
191
214
|
}
|
|
@@ -379,7 +402,8 @@ function applyChangedKeys(target, source) {
|
|
|
379
402
|
}
|
|
380
403
|
for (const k of changedFirstSegments) {
|
|
381
404
|
if (typeof k === "symbol") continue;
|
|
382
|
-
|
|
405
|
+
const key = String(k);
|
|
406
|
+
safeAssign(t, key, safeOwnRead(s, key));
|
|
383
407
|
}
|
|
384
408
|
}
|
|
385
409
|
return true;
|
|
@@ -429,9 +453,9 @@ function structuralSnapshot(value) {
|
|
|
429
453
|
return out2;
|
|
430
454
|
}
|
|
431
455
|
const src = value;
|
|
432
|
-
const out =
|
|
456
|
+
const out = {};
|
|
433
457
|
for (const k of Object.keys(src)) {
|
|
434
|
-
out
|
|
458
|
+
safeAssign(out, k, structuralSnapshot(safeOwnRead(src, k)));
|
|
435
459
|
}
|
|
436
460
|
return out;
|
|
437
461
|
}
|
|
@@ -1095,7 +1119,7 @@ function errorAwareContainerKeys(state, segments) {
|
|
|
1095
1119
|
}
|
|
1096
1120
|
function materializeErrors(state, containerSegments) {
|
|
1097
1121
|
const liveContainer = getAtPath(state.form.value, containerSegments);
|
|
1098
|
-
const tree = Array.isArray(liveContainer) ? [] :
|
|
1122
|
+
const tree = Array.isArray(liveContainer) ? [] : {};
|
|
1099
1123
|
const collect = (store, applyActivePathFilter) => {
|
|
1100
1124
|
entries: for (const [pathKey, errors] of store) {
|
|
1101
1125
|
if (errors.length === 0) continue;
|
|
@@ -1143,18 +1167,18 @@ function placeAt(tree, path, errors) {
|
|
|
1143
1167
|
const nextSeg = path[i + 1];
|
|
1144
1168
|
const key = typeof seg === "number" ? String(seg) : seg;
|
|
1145
1169
|
const cursorRecord2 = cursor;
|
|
1146
|
-
let child = cursorRecord2
|
|
1170
|
+
let child = safeOwnRead(cursorRecord2, key);
|
|
1147
1171
|
if (child === null || child === void 0 || typeof child !== "object") {
|
|
1148
|
-
child = typeof nextSeg === "number" ? [] :
|
|
1149
|
-
cursorRecord2
|
|
1172
|
+
child = typeof nextSeg === "number" ? [] : {};
|
|
1173
|
+
safeAssign(cursorRecord2, key, child);
|
|
1150
1174
|
}
|
|
1151
1175
|
cursor = child;
|
|
1152
1176
|
}
|
|
1153
1177
|
const lastSeg = path[path.length - 1];
|
|
1154
1178
|
const lastKey = typeof lastSeg === "number" ? String(lastSeg) : lastSeg;
|
|
1155
1179
|
const cursorRecord = cursor;
|
|
1156
|
-
const existing = cursorRecord
|
|
1157
|
-
cursorRecord
|
|
1180
|
+
const existing = safeOwnRead(cursorRecord, lastKey);
|
|
1181
|
+
safeAssign(cursorRecord, lastKey, Array.isArray(existing) ? [...existing, ...errors] : errors);
|
|
1158
1182
|
}
|
|
1159
1183
|
|
|
1160
1184
|
function buildFieldArrayApi(state) {
|
|
@@ -1550,10 +1574,10 @@ function stripUnacknowledgedSensitiveLeaves(form, optedInPaths, isSensitivePath)
|
|
|
1550
1574
|
if (value === null || typeof value !== "object") return value;
|
|
1551
1575
|
if (Array.isArray(value)) return value.map((item, i) => walk([...path, i], item));
|
|
1552
1576
|
if (!isPlainRecord(value)) return value;
|
|
1553
|
-
const out =
|
|
1577
|
+
const out = {};
|
|
1554
1578
|
for (const key of Object.keys(value)) {
|
|
1555
1579
|
const walked = walk([...path, key], value[key]);
|
|
1556
|
-
if (walked !== void 0) out
|
|
1580
|
+
if (walked !== void 0) safeAssign(out, key, walked);
|
|
1557
1581
|
}
|
|
1558
1582
|
return out;
|
|
1559
1583
|
};
|
|
@@ -1585,10 +1609,19 @@ function mergeDeep(target, source, path, schema) {
|
|
|
1585
1609
|
if (sourceDisc !== void 0) {
|
|
1586
1610
|
const variantDefault = du.getVariantDefault(sourceDisc);
|
|
1587
1611
|
if (isPlainRecord(variantDefault)) {
|
|
1588
|
-
const out2 =
|
|
1612
|
+
const out2 = { ...variantDefault };
|
|
1589
1613
|
for (const key of Object.keys(sourceRecord)) {
|
|
1590
|
-
if (!(key
|
|
1591
|
-
|
|
1614
|
+
if (!safeOwnHas(variantDefault, key) && key !== du.discriminatorKey) continue;
|
|
1615
|
+
safeAssign(
|
|
1616
|
+
out2,
|
|
1617
|
+
key,
|
|
1618
|
+
mergeDeep(
|
|
1619
|
+
safeOwnRead(out2, key),
|
|
1620
|
+
safeOwnRead(sourceRecord, key),
|
|
1621
|
+
[...path, key],
|
|
1622
|
+
schema
|
|
1623
|
+
)
|
|
1624
|
+
);
|
|
1592
1625
|
}
|
|
1593
1626
|
return out2;
|
|
1594
1627
|
}
|
|
@@ -1597,9 +1630,18 @@ function mergeDeep(target, source, path, schema) {
|
|
|
1597
1630
|
}
|
|
1598
1631
|
}
|
|
1599
1632
|
const mergeTarget = target;
|
|
1600
|
-
const out = isPlainRecord(mergeTarget) ?
|
|
1633
|
+
const out = isPlainRecord(mergeTarget) ? { ...mergeTarget } : {};
|
|
1601
1634
|
for (const key of Object.keys(source)) {
|
|
1602
|
-
|
|
1635
|
+
safeAssign(
|
|
1636
|
+
out,
|
|
1637
|
+
key,
|
|
1638
|
+
mergeDeep(
|
|
1639
|
+
safeOwnRead(out, key),
|
|
1640
|
+
safeOwnRead(source, key),
|
|
1641
|
+
[...path, key],
|
|
1642
|
+
schema
|
|
1643
|
+
)
|
|
1644
|
+
);
|
|
1603
1645
|
}
|
|
1604
1646
|
return out;
|
|
1605
1647
|
}
|
|
@@ -2266,6 +2308,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2266
2308
|
const isRequired = state.schema.isRequiredAtPath(segments);
|
|
2267
2309
|
const ariaEnabled = options?.autoAria ?? formAutoAria;
|
|
2268
2310
|
const ariaDisplayState = getDisplayStateAt !== void 0 ? vue.computed(() => getDisplayStateAt(segments)) : void 0;
|
|
2311
|
+
let boundElement = null;
|
|
2269
2312
|
const internalRv = {
|
|
2270
2313
|
innerRef,
|
|
2271
2314
|
displayValue,
|
|
@@ -2284,6 +2327,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2284
2327
|
state.markInteracted(segments);
|
|
2285
2328
|
},
|
|
2286
2329
|
registerElement: (element) => {
|
|
2330
|
+
boundElement = element;
|
|
2287
2331
|
if (!paths.INTERACTIVE_TAG_NAMES.has(element.tagName)) return;
|
|
2288
2332
|
const added = state.registerElement(segments, element, formInstanceId);
|
|
2289
2333
|
if (added) attachFocusListeners(state, segments, element, instanceMeta);
|
|
@@ -2291,9 +2335,11 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2291
2335
|
deregisterElement: (element) => {
|
|
2292
2336
|
detachFocusListeners(element);
|
|
2293
2337
|
state.deregisterElement(segments, element);
|
|
2338
|
+
if (boundElement === element) boundElement = null;
|
|
2294
2339
|
},
|
|
2295
2340
|
setValueWithInternalPath: (value, meta) => {
|
|
2296
|
-
|
|
2341
|
+
const resolvedMeta = meta === void 0 && boundElement !== null ? { persist: state.persistOptIns.hasOptIn(paths.getOrAssignElementId(boundElement), pathKey) } : meta;
|
|
2342
|
+
return state.setValueAtPath(segments, value, withInstanceMeta(resolvedMeta));
|
|
2297
2343
|
},
|
|
2298
2344
|
// Called by the `vRegisterHint` compile-time transform's wrapping
|
|
2299
2345
|
// IIFE on every server-side render of `<element v-register="…">`.
|
|
@@ -2383,17 +2429,17 @@ function walk(input, segments, schema, paths) {
|
|
|
2383
2429
|
if (slim !== null && slim !== void 0 && typeof slim === "object" && !Array.isArray(slim) && !(slim instanceof Date) && !(slim instanceof RegExp) && !(slim instanceof Map) && !(slim instanceof Set)) {
|
|
2384
2430
|
for (const k of Object.keys(slim)) allKeys.add(k);
|
|
2385
2431
|
}
|
|
2386
|
-
const out =
|
|
2432
|
+
const out = {};
|
|
2387
2433
|
let mutated = allKeys.size !== inputKeys.length;
|
|
2388
2434
|
for (const key of allKeys) {
|
|
2389
2435
|
const orig = input[key];
|
|
2390
2436
|
if (orig === void 0 && inputKeysSet.has(key)) {
|
|
2391
|
-
out
|
|
2437
|
+
safeAssign(out, key, void 0);
|
|
2392
2438
|
mutated = true;
|
|
2393
2439
|
continue;
|
|
2394
2440
|
}
|
|
2395
2441
|
const walked = walk(orig, [...segments, key], schema, paths);
|
|
2396
|
-
out
|
|
2442
|
+
safeAssign(out, key, walked);
|
|
2397
2443
|
if (walked !== orig) mutated = true;
|
|
2398
2444
|
}
|
|
2399
2445
|
return mutated ? out : input;
|
|
@@ -2412,9 +2458,13 @@ function walkUnspecified(slim, segments, paths$1) {
|
|
|
2412
2458
|
}
|
|
2413
2459
|
if (Array.isArray(slim)) return slim;
|
|
2414
2460
|
if (slim !== null && typeof slim === "object") {
|
|
2415
|
-
const out =
|
|
2461
|
+
const out = {};
|
|
2416
2462
|
for (const key of Object.keys(slim)) {
|
|
2417
|
-
|
|
2463
|
+
safeAssign(
|
|
2464
|
+
out,
|
|
2465
|
+
key,
|
|
2466
|
+
walkUnspecified(slim[key], [...segments, key], paths$1)
|
|
2467
|
+
);
|
|
2418
2468
|
}
|
|
2419
2469
|
return out;
|
|
2420
2470
|
}
|
|
@@ -2445,11 +2495,11 @@ function substitute(input, segments, schema, paths) {
|
|
|
2445
2495
|
}
|
|
2446
2496
|
if (typeof input === "object") {
|
|
2447
2497
|
let mutated = false;
|
|
2448
|
-
const out =
|
|
2498
|
+
const out = {};
|
|
2449
2499
|
for (const key of Object.keys(input)) {
|
|
2450
2500
|
const orig = input[key];
|
|
2451
2501
|
const walked = substitute(orig, [...segments, key], schema, paths);
|
|
2452
|
-
out
|
|
2502
|
+
safeAssign(out, key, walked);
|
|
2453
2503
|
if (walked !== orig) mutated = true;
|
|
2454
2504
|
}
|
|
2455
2505
|
return mutated ? out : input;
|
|
@@ -3059,9 +3109,9 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3059
3109
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3060
3110
|
return EMPTY_FIELD_RECORD;
|
|
3061
3111
|
}
|
|
3062
|
-
const out =
|
|
3112
|
+
const out = {};
|
|
3063
3113
|
for (const key of Object.keys(value)) {
|
|
3064
|
-
out
|
|
3114
|
+
safeAssign(out, key, callTerminal(`${path}.${key}`));
|
|
3065
3115
|
}
|
|
3066
3116
|
return Object.freeze(out);
|
|
3067
3117
|
}
|
|
@@ -3183,14 +3233,14 @@ function walkDuStubs(schema, value, path, warned) {
|
|
|
3183
3233
|
);
|
|
3184
3234
|
}
|
|
3185
3235
|
}
|
|
3186
|
-
const stub =
|
|
3187
|
-
stub
|
|
3236
|
+
const stub = {};
|
|
3237
|
+
safeAssign(stub, du.discriminatorKey, discValue);
|
|
3188
3238
|
return stub;
|
|
3189
3239
|
}
|
|
3190
3240
|
}
|
|
3191
|
-
const out =
|
|
3241
|
+
const out = {};
|
|
3192
3242
|
for (const k of Object.keys(rec)) {
|
|
3193
|
-
out
|
|
3243
|
+
safeAssign(out, k, walkDuStubs(schema, rec[k], [...path, k], warned));
|
|
3194
3244
|
}
|
|
3195
3245
|
return out;
|
|
3196
3246
|
}
|
|
@@ -3273,8 +3323,8 @@ function cloneVariantSnapshot(value) {
|
|
|
3273
3323
|
return out2;
|
|
3274
3324
|
}
|
|
3275
3325
|
const src = raw;
|
|
3276
|
-
const out =
|
|
3277
|
-
for (const k of Object.keys(src)) out
|
|
3326
|
+
const out = {};
|
|
3327
|
+
for (const k of Object.keys(src)) safeAssign(out, k, cloneVariantSnapshot(src[k]));
|
|
3278
3328
|
return out;
|
|
3279
3329
|
}
|
|
3280
3330
|
|
|
@@ -5197,9 +5247,8 @@ function wirePersistence(state, config) {
|
|
|
5197
5247
|
if (isDisposed()) return;
|
|
5198
5248
|
const raw = await adapter.getItem(key);
|
|
5199
5249
|
const existing = readPersistedPayload(raw);
|
|
5200
|
-
const baseForm = existing?.data.form ?? /* @__PURE__ */ Object.create(null);
|
|
5201
5250
|
const value = getAtPath(vue.toRaw(state.form.value), path);
|
|
5202
|
-
const nextForm = setAtPath(
|
|
5251
|
+
const nextForm = setAtPath(existing?.data.form ?? {}, path, value);
|
|
5203
5252
|
const { key: pathKey } = paths.canonicalizePath(path);
|
|
5204
5253
|
const transientSet = new Set(
|
|
5205
5254
|
(existing?.data.blankPaths ?? []).filter(
|
|
@@ -5391,15 +5440,15 @@ function stripSensitivePathsDeep(value, pathSoFar, isSensitivePath) {
|
|
|
5391
5440
|
}
|
|
5392
5441
|
const proto = Object.getPrototypeOf(value);
|
|
5393
5442
|
if (proto !== Object.prototype && proto !== null) return value;
|
|
5394
|
-
const out =
|
|
5443
|
+
const out = {};
|
|
5395
5444
|
const src = value;
|
|
5396
5445
|
for (const key of Object.keys(src)) {
|
|
5397
5446
|
const childPath = [...pathSoFar, key];
|
|
5398
5447
|
if (isSensitivePath(childPath)) {
|
|
5399
|
-
out
|
|
5448
|
+
safeAssign(out, key, void 0);
|
|
5400
5449
|
continue;
|
|
5401
5450
|
}
|
|
5402
|
-
out
|
|
5451
|
+
safeAssign(out, key, stripSensitivePathsDeep(src[key], childPath, isSensitivePath));
|
|
5403
5452
|
}
|
|
5404
5453
|
return out;
|
|
5405
5454
|
}
|
|
@@ -7171,9 +7220,11 @@ exports.isPlainRecord = isPlainRecord;
|
|
|
7171
7220
|
exports.isUnset = isUnset;
|
|
7172
7221
|
exports.lazy = lazy;
|
|
7173
7222
|
exports.normalizeNumericOption = normalizeNumericOption;
|
|
7223
|
+
exports.safeAssign = safeAssign;
|
|
7224
|
+
exports.safeOwnRead = safeOwnRead;
|
|
7174
7225
|
exports.setAtPath = setAtPath;
|
|
7175
7226
|
exports.slimKindOf = slimKindOf;
|
|
7176
7227
|
exports.unset = unset;
|
|
7177
7228
|
exports.useAbstractForm = useAbstractForm;
|
|
7178
7229
|
exports.useWizard = useWizard;
|
|
7179
|
-
//# sourceMappingURL=attaform.
|
|
7230
|
+
//# sourceMappingURL=attaform.CwLjUqmQ.cjs.map
|