attaform 0.21.1 → 0.21.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/dist/chunks/dev-key-collision-warnings.cjs +1 -1
- package/dist/chunks/dev-key-collision-warnings.mjs +1 -1
- package/dist/chunks/devtools.cjs +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/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/multi-tab-sync.cjs +2 -2
- package/dist/chunks/multi-tab-sync.mjs +2 -2
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/chunks/wire-persistence.cjs +2 -2
- package/dist/chunks/wire-persistence.mjs +2 -2
- package/dist/index.cjs +37 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -18
- package/dist/index.d.mts +20 -18
- package/dist/index.d.ts +20 -18
- package/dist/index.mjs +38 -25
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +396 -216
- package/dist/runtime/components/DevtoolsValueTree.vue +176 -114
- package/dist/runtime/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.D32WwKk6.cjs → attaform.B5LNzqQh.cjs} +243 -352
- package/dist/shared/attaform.B5LNzqQh.cjs.map +1 -0
- package/dist/shared/{attaform.S-pYLSo4.cjs → attaform.BBDIKtKY.cjs} +13 -16
- package/dist/shared/attaform.BBDIKtKY.cjs.map +1 -0
- package/dist/shared/{attaform.Bv7dRDWK.d.ts → attaform.BCcrLApm.d.mts} +54 -63
- package/dist/shared/{attaform.BupwXkj_.mjs → attaform.BFWb6hDk.mjs} +29 -23
- package/dist/shared/attaform.BFWb6hDk.mjs.map +1 -0
- package/dist/shared/{attaform.BWfliRIK.d.cts → attaform.BGf_J22U.d.ts} +54 -63
- package/dist/shared/{attaform.DMEP_ENr.mjs → attaform.BVeLgfEh.mjs} +14 -17
- package/dist/shared/attaform.BVeLgfEh.mjs.map +1 -0
- package/dist/shared/{attaform.MtrpT6Ki.d.ts → attaform.BYgioWLF.d.ts} +1 -1
- package/dist/shared/{attaform.NQ8mybyW.d.mts → attaform.BkjJfMvJ.d.cts} +54 -63
- package/dist/shared/{attaform.Duecg2NO.d.mts → attaform.BoY6RZUl.d.cts} +1 -1
- package/dist/shared/{attaform.Bq5sX7TF.cjs → attaform.BwLp9KM7.cjs} +2 -2
- package/dist/shared/{attaform.Bq5sX7TF.cjs.map → attaform.BwLp9KM7.cjs.map} +1 -1
- package/dist/shared/{attaform.CICFZ1iS.cjs → attaform.BwrowMp2.cjs} +19 -45
- package/dist/shared/attaform.BwrowMp2.cjs.map +1 -0
- package/dist/shared/{attaform.Y1ZGhM4k.mjs → attaform.C41gjp-a.mjs} +2 -2
- package/dist/shared/{attaform.Y1ZGhM4k.mjs.map → attaform.C41gjp-a.mjs.map} +1 -1
- package/dist/shared/{attaform.BM6YD9kZ.cjs → attaform.CR6wGvNu.cjs} +29 -23
- package/dist/shared/attaform.CR6wGvNu.cjs.map +1 -0
- package/dist/shared/{attaform.DR6RmxWZ.mjs → attaform.CTheKoTc.mjs} +341 -221
- package/dist/shared/attaform.CTheKoTc.mjs.map +1 -0
- package/dist/shared/{attaform.BSkvn43g.cjs → attaform.CcnF1AKJ.cjs} +4 -4
- package/dist/shared/attaform.CcnF1AKJ.cjs.map +1 -0
- package/dist/shared/{attaform.FudOcHaa.d.cts → attaform.CnEl--PF.d.mts} +1 -1
- package/dist/shared/{attaform.DozgVlCE.mjs → attaform.CrD73S4m.mjs} +4 -4
- package/dist/shared/attaform.CrD73S4m.mjs.map +1 -0
- package/dist/shared/{attaform.ClXwitZj.cjs → attaform.D2ZuIOCf.cjs} +347 -226
- package/dist/shared/attaform.D2ZuIOCf.cjs.map +1 -0
- package/dist/shared/{attaform.Be8NZG9M.mjs → attaform.D6GYGshL.mjs} +19 -45
- package/dist/shared/attaform.D6GYGshL.mjs.map +1 -0
- package/dist/shared/{attaform.pmtahXKy.mjs → attaform.DP-u7_tk.mjs} +243 -352
- package/dist/shared/attaform.DP-u7_tk.mjs.map +1 -0
- package/dist/shared/{attaform.D0dWZsJt.d.mts → attaform.ory-3WhV.d.cts} +128 -129
- package/dist/shared/{attaform.D0dWZsJt.d.cts → attaform.ory-3WhV.d.mts} +128 -129
- package/dist/shared/{attaform.D0dWZsJt.d.ts → attaform.ory-3WhV.d.ts} +128 -129
- package/dist/transforms.cjs +1 -1
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/zod-v3.cjs +3 -4
- package/dist/zod-v3.cjs.map +1 -1
- package/dist/zod-v3.d.cts +4 -4
- package/dist/zod-v3.d.mts +4 -4
- package/dist/zod-v3.d.ts +4 -4
- package/dist/zod-v3.mjs +2 -3
- package/dist/zod-v3.mjs.map +1 -1
- package/dist/zod-v4.cjs +3 -4
- package/dist/zod-v4.cjs.map +1 -1
- 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 +2 -3
- package/dist/zod-v4.mjs.map +1 -1
- package/dist/zod.cjs +6 -6
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +31 -22
- package/dist/zod.d.mts +31 -22
- package/dist/zod.d.ts +31 -22
- package/dist/zod.mjs +5 -6
- package/dist/zod.mjs.map +1 -1
- package/package.json +3 -11
- package/dist/shared/attaform.BM6YD9kZ.cjs.map +0 -1
- package/dist/shared/attaform.BSkvn43g.cjs.map +0 -1
- package/dist/shared/attaform.Be8NZG9M.mjs.map +0 -1
- package/dist/shared/attaform.BupwXkj_.mjs.map +0 -1
- package/dist/shared/attaform.CICFZ1iS.cjs.map +0 -1
- package/dist/shared/attaform.ClXwitZj.cjs.map +0 -1
- package/dist/shared/attaform.D32WwKk6.cjs.map +0 -1
- package/dist/shared/attaform.DMEP_ENr.mjs.map +0 -1
- package/dist/shared/attaform.DR6RmxWZ.mjs.map +0 -1
- package/dist/shared/attaform.DozgVlCE.mjs.map +0 -1
- package/dist/shared/attaform.S-pYLSo4.cjs.map +0 -1
- package/dist/shared/attaform.pmtahXKy.mjs.map +0 -1
- package/dist/shared/{attaform.DSD85fHb.d.cts → attaform.nf83TIR5.d.cts} +10 -10
- package/dist/shared/{attaform.DSD85fHb.d.mts → attaform.nf83TIR5.d.mts} +10 -10
- package/dist/shared/{attaform.DSD85fHb.d.ts → attaform.nf83TIR5.d.ts} +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const paths = require('./attaform.
|
|
4
|
+
const paths = require('./attaform.B5LNzqQh.cjs');
|
|
5
5
|
|
|
6
6
|
function safeAssign(target, key, value) {
|
|
7
7
|
if (key === "__proto__") {
|
|
@@ -162,68 +162,80 @@ function mergeStructuralImpl(schema, scratch, consumer, defaultValue) {
|
|
|
162
162
|
}
|
|
163
163
|
if (consumer === null) return null;
|
|
164
164
|
if (Array.isArray(consumer)) {
|
|
165
|
-
|
|
166
|
-
const isTuple = typeof shape === "number";
|
|
167
|
-
const targetLen = isTuple ? shape : consumer.length;
|
|
168
|
-
let cachedElementDefault;
|
|
169
|
-
let cachedElementDefaultRead = false;
|
|
170
|
-
let mutated = targetLen > consumer.length;
|
|
171
|
-
const out = consumer.slice();
|
|
172
|
-
while (out.length < targetLen) out.push(void 0);
|
|
173
|
-
for (let i = 0; i < targetLen; i++) {
|
|
174
|
-
scratch.push(i);
|
|
175
|
-
let elemDefault;
|
|
176
|
-
if (isTuple) {
|
|
177
|
-
elemDefault = schema.getDefaultAtPath(scratch);
|
|
178
|
-
} else {
|
|
179
|
-
if (!cachedElementDefaultRead) {
|
|
180
|
-
cachedElementDefault = schema.getDefaultAtPath(scratch);
|
|
181
|
-
cachedElementDefaultRead = true;
|
|
182
|
-
}
|
|
183
|
-
elemDefault = cachedElementDefault;
|
|
184
|
-
}
|
|
185
|
-
const consumerElem = i < consumer.length ? consumer[i] : void 0;
|
|
186
|
-
const merged = mergeStructuralImpl(schema, scratch, consumerElem, elemDefault);
|
|
187
|
-
scratch.pop();
|
|
188
|
-
if (merged !== consumerElem) {
|
|
189
|
-
out[i] = merged;
|
|
190
|
-
mutated = true;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return mutated ? out : consumer;
|
|
165
|
+
return mergeStructuralArray(schema, scratch, consumer);
|
|
194
166
|
}
|
|
195
167
|
if (isPlainRecord(consumer)) {
|
|
196
168
|
if (!isPlainRecord(defaultValue)) {
|
|
197
169
|
return consumer;
|
|
198
170
|
}
|
|
199
|
-
let mutated = false;
|
|
200
171
|
const out = { ...consumer };
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
172
|
+
const filledAny = fillMissingKeysFromDefault(schema, scratch, consumer, defaultValue, out);
|
|
173
|
+
const recursedAny = recurseIntoConsumerKeys(schema, scratch, consumer, defaultValue, out);
|
|
174
|
+
return filledAny || recursedAny ? out : consumer;
|
|
175
|
+
}
|
|
176
|
+
return consumer;
|
|
177
|
+
}
|
|
178
|
+
function mergeStructuralArray(schema, scratch, consumer) {
|
|
179
|
+
const shape = resolveArrayShape(schema, scratch);
|
|
180
|
+
const isTuple = typeof shape === "number";
|
|
181
|
+
const targetLen = isTuple ? shape : consumer.length;
|
|
182
|
+
let cachedElementDefault;
|
|
183
|
+
let cachedElementDefaultRead = false;
|
|
184
|
+
let mutated = targetLen > consumer.length;
|
|
185
|
+
const out = consumer.slice();
|
|
186
|
+
while (out.length < targetLen) out.push(void 0);
|
|
187
|
+
for (let i = 0; i < targetLen; i++) {
|
|
188
|
+
scratch.push(i);
|
|
189
|
+
let elemDefault;
|
|
190
|
+
if (isTuple) {
|
|
191
|
+
elemDefault = schema.getDefaultAtPath(scratch);
|
|
192
|
+
} else {
|
|
193
|
+
if (!cachedElementDefaultRead) {
|
|
194
|
+
cachedElementDefault = schema.getDefaultAtPath(scratch);
|
|
195
|
+
cachedElementDefaultRead = true;
|
|
211
196
|
}
|
|
197
|
+
elemDefault = cachedElementDefault;
|
|
212
198
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
199
|
+
const consumerElem = i < consumer.length ? consumer[i] : void 0;
|
|
200
|
+
const merged = mergeStructuralImpl(schema, scratch, consumerElem, elemDefault);
|
|
201
|
+
scratch.pop();
|
|
202
|
+
if (merged !== consumerElem) {
|
|
203
|
+
out[i] = merged;
|
|
204
|
+
mutated = true;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return mutated ? out : consumer;
|
|
208
|
+
}
|
|
209
|
+
function fillMissingKeysFromDefault(schema, scratch, consumer, defaultValue, out) {
|
|
210
|
+
let mutated = false;
|
|
211
|
+
for (const key of Object.keys(defaultValue)) {
|
|
212
|
+
if (!safeOwnHas(consumer, key)) {
|
|
213
|
+
const defAtKey = safeOwnRead(defaultValue, key);
|
|
216
214
|
scratch.push(key);
|
|
217
|
-
const
|
|
215
|
+
const filled = mergeStructuralImpl(schema, scratch, void 0, defAtKey);
|
|
218
216
|
scratch.pop();
|
|
219
|
-
if (
|
|
220
|
-
safeAssign(out, key,
|
|
217
|
+
if (filled !== void 0) {
|
|
218
|
+
safeAssign(out, key, filled);
|
|
221
219
|
mutated = true;
|
|
222
220
|
}
|
|
223
221
|
}
|
|
224
|
-
return mutated ? out : consumer;
|
|
225
222
|
}
|
|
226
|
-
return
|
|
223
|
+
return mutated;
|
|
224
|
+
}
|
|
225
|
+
function recurseIntoConsumerKeys(schema, scratch, consumer, defaultValue, out) {
|
|
226
|
+
let mutated = false;
|
|
227
|
+
for (const key of Object.keys(consumer)) {
|
|
228
|
+
const cVal = safeOwnRead(consumer, key);
|
|
229
|
+
if (cVal === void 0) continue;
|
|
230
|
+
scratch.push(key);
|
|
231
|
+
const merged = mergeStructuralImpl(schema, scratch, cVal, safeOwnRead(defaultValue, key));
|
|
232
|
+
scratch.pop();
|
|
233
|
+
if (merged !== cVal) {
|
|
234
|
+
safeAssign(out, key, merged);
|
|
235
|
+
mutated = true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return mutated;
|
|
227
239
|
}
|
|
228
240
|
function setAtPathWithSchemaFill(root, schema, fullPath, value) {
|
|
229
241
|
if (fullPath.length === 0) return value;
|
|
@@ -306,55 +318,27 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
|
|
|
306
318
|
const oldIsDescendable = isDescendable(oldValue);
|
|
307
319
|
const newIsDescendable = isDescendable(newValue);
|
|
308
320
|
if (oldValue === void 0 && newIsDescendable) {
|
|
309
|
-
|
|
310
|
-
for (let i = 0; i < newValue.length; i++) {
|
|
311
|
-
diffAndApply(void 0, newValue[i], appendSegment(prefix, i), visit);
|
|
312
|
-
}
|
|
313
|
-
} else {
|
|
314
|
-
const rec = newValue;
|
|
315
|
-
for (const k of Object.keys(rec)) {
|
|
316
|
-
diffAndApply(void 0, rec[k], appendSegment(prefix, k), visit);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
321
|
+
walkNewDescendable(newValue, prefix, visit);
|
|
319
322
|
return;
|
|
320
323
|
}
|
|
321
324
|
if (oldIsDescendable && newValue === void 0) {
|
|
322
|
-
|
|
323
|
-
for (let i = 0; i < oldValue.length; i++) {
|
|
324
|
-
diffAndApply(oldValue[i], void 0, appendSegment(prefix, i), visit);
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
const rec = oldValue;
|
|
328
|
-
for (const k of Object.keys(rec)) {
|
|
329
|
-
diffAndApply(rec[k], void 0, appendSegment(prefix, k), visit);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
325
|
+
walkOldDescendable(oldValue, prefix, visit);
|
|
332
326
|
return;
|
|
333
327
|
}
|
|
334
328
|
if (oldIsDescendable && newIsDescendable) {
|
|
335
329
|
const oldIsArray = Array.isArray(oldValue);
|
|
336
330
|
const newIsArray = Array.isArray(newValue);
|
|
337
331
|
if (oldIsArray && newIsArray) {
|
|
338
|
-
|
|
339
|
-
const newArr = newValue;
|
|
340
|
-
const max = Math.max(oldArr.length, newArr.length);
|
|
341
|
-
for (let i = 0; i < max; i++) {
|
|
342
|
-
diffAndApply(oldArr[i], newArr[i], appendSegment(prefix, i), visit);
|
|
343
|
-
}
|
|
332
|
+
diffArraysLockstep(oldValue, newValue, prefix, visit);
|
|
344
333
|
return;
|
|
345
334
|
}
|
|
346
335
|
if (!oldIsArray && !newIsArray) {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
for (const k of Object.keys(newRec)) {
|
|
355
|
-
if (seen.has(k)) continue;
|
|
356
|
-
diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
|
|
357
|
-
}
|
|
336
|
+
diffObjectsLockstep(
|
|
337
|
+
oldValue,
|
|
338
|
+
newValue,
|
|
339
|
+
prefix,
|
|
340
|
+
visit
|
|
341
|
+
);
|
|
358
342
|
return;
|
|
359
343
|
}
|
|
360
344
|
visit({ kind: "changed", path: prefix, oldValue, newValue });
|
|
@@ -378,6 +362,47 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
|
|
|
378
362
|
}
|
|
379
363
|
visit({ kind: "changed", path: prefix, oldValue, newValue });
|
|
380
364
|
}
|
|
365
|
+
function walkNewDescendable(newValue, prefix, visit) {
|
|
366
|
+
if (Array.isArray(newValue)) {
|
|
367
|
+
for (let i = 0; i < newValue.length; i++) {
|
|
368
|
+
diffAndApply(void 0, newValue[i], appendSegment(prefix, i), visit);
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
const rec = newValue;
|
|
372
|
+
for (const k of Object.keys(rec)) {
|
|
373
|
+
diffAndApply(void 0, rec[k], appendSegment(prefix, k), visit);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function walkOldDescendable(oldValue, prefix, visit) {
|
|
378
|
+
if (Array.isArray(oldValue)) {
|
|
379
|
+
for (let i = 0; i < oldValue.length; i++) {
|
|
380
|
+
diffAndApply(oldValue[i], void 0, appendSegment(prefix, i), visit);
|
|
381
|
+
}
|
|
382
|
+
} else {
|
|
383
|
+
const rec = oldValue;
|
|
384
|
+
for (const k of Object.keys(rec)) {
|
|
385
|
+
diffAndApply(rec[k], void 0, appendSegment(prefix, k), visit);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function diffArraysLockstep(oldArr, newArr, prefix, visit) {
|
|
390
|
+
const max = Math.max(oldArr.length, newArr.length);
|
|
391
|
+
for (let i = 0; i < max; i++) {
|
|
392
|
+
diffAndApply(oldArr[i], newArr[i], appendSegment(prefix, i), visit);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function diffObjectsLockstep(oldRec, newRec, prefix, visit) {
|
|
396
|
+
const seen = /* @__PURE__ */ new Set();
|
|
397
|
+
for (const k of Object.keys(oldRec)) {
|
|
398
|
+
seen.add(k);
|
|
399
|
+
diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
|
|
400
|
+
}
|
|
401
|
+
for (const k of Object.keys(newRec)) {
|
|
402
|
+
if (seen.has(k)) continue;
|
|
403
|
+
diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
381
406
|
function applyChangedKeys(target, source) {
|
|
382
407
|
if (!isDescendable(target) || !isDescendable(source)) return false;
|
|
383
408
|
const targetIsArray = Array.isArray(target);
|
|
@@ -625,6 +650,12 @@ function buildFieldStateAccessor(state, formInstanceId, getFormMetaBase, options
|
|
|
625
650
|
return c;
|
|
626
651
|
};
|
|
627
652
|
}
|
|
653
|
+
function resolveFieldMetaAndLabel(state, segments) {
|
|
654
|
+
const resolved = state.schema.getFieldMetaAtPath ? state.schema.getFieldMetaAtPath(segments) : EMPTY_RESOLVED_FIELD_META;
|
|
655
|
+
const lastSegment = segments.length === 0 ? "" : segments[segments.length - 1] ?? "";
|
|
656
|
+
const label = resolved.label || humanize(lastSegment);
|
|
657
|
+
return { resolved, label };
|
|
658
|
+
}
|
|
628
659
|
function buildLeafFieldStateBase(state, segments, key, formInstanceId) {
|
|
629
660
|
const record = state.fields.get(key);
|
|
630
661
|
const value = state.getValueAtPath(segments);
|
|
@@ -646,9 +677,7 @@ function buildLeafFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
646
677
|
const elementRecord = state.elements.get(key);
|
|
647
678
|
const elementsArr = elementRecord ? Object.freeze([...elementRecord.elements]) : EMPTY_ELEMENTS;
|
|
648
679
|
const firstElement = elementsArr[0] ?? null;
|
|
649
|
-
const resolved = state
|
|
650
|
-
const lastSegment = segments.length === 0 ? "" : segments[segments.length - 1] ?? "";
|
|
651
|
-
const label = resolved.label || humanize(lastSegment);
|
|
680
|
+
const { resolved, label } = resolveFieldMetaAndLabel(state, segments);
|
|
652
681
|
return {
|
|
653
682
|
value,
|
|
654
683
|
original,
|
|
@@ -785,9 +814,7 @@ function buildContainerFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
785
814
|
const ownTransformError = state.transformErrors.get(key) ?? null;
|
|
786
815
|
const gated = asyncPending && !state.firstValidationDone.value;
|
|
787
816
|
const valid = !gated && errors.length === 0 && !validating;
|
|
788
|
-
const resolved = state
|
|
789
|
-
const lastSegment = segments.length === 0 ? "" : segments[segments.length - 1] ?? "";
|
|
790
|
-
const label = resolved.label || humanize(lastSegment);
|
|
817
|
+
const { resolved, label } = resolveFieldMetaAndLabel(state, segments);
|
|
791
818
|
return {
|
|
792
819
|
base: {
|
|
793
820
|
value,
|
|
@@ -1570,20 +1597,20 @@ function buildFieldStateProxy(state, formInstanceId, getFormMetaBase, options) {
|
|
|
1570
1597
|
}
|
|
1571
1598
|
function materializeFields(state, containerSegments, snapshotFieldStateAt) {
|
|
1572
1599
|
const liveValue = getAtPath(state.form.value, containerSegments);
|
|
1573
|
-
return walk$
|
|
1600
|
+
return walk$1(liveValue, containerSegments, state.schema, snapshotFieldStateAt);
|
|
1574
1601
|
}
|
|
1575
|
-
function walk$
|
|
1602
|
+
function walk$1(value, basePath, schema, snapshotFieldStateAt) {
|
|
1576
1603
|
if (schema.isLeafAtPath(basePath)) return snapshotFieldStateAt(basePath);
|
|
1577
1604
|
if (value === null || value === void 0) return value;
|
|
1578
1605
|
if (typeof value !== "object") {
|
|
1579
1606
|
return value;
|
|
1580
1607
|
}
|
|
1581
1608
|
if (Array.isArray(value)) {
|
|
1582
|
-
return value.map((_, i) => walk$
|
|
1609
|
+
return value.map((_, i) => walk$1(value[i], [...basePath, i], schema, snapshotFieldStateAt));
|
|
1583
1610
|
}
|
|
1584
1611
|
const result = {};
|
|
1585
1612
|
for (const key of Object.keys(value)) {
|
|
1586
|
-
result[key] = walk$
|
|
1613
|
+
result[key] = walk$1(
|
|
1587
1614
|
value[key],
|
|
1588
1615
|
[...basePath, key],
|
|
1589
1616
|
schema,
|
|
@@ -1667,47 +1694,42 @@ function mergeDeep(target, source, path, schema) {
|
|
|
1667
1694
|
if (!isPlainRecord(source)) return source;
|
|
1668
1695
|
if (schema !== void 0) {
|
|
1669
1696
|
const du = schema.getUnionDiscriminatorAtPath(path);
|
|
1670
|
-
if (du !== void 0)
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
out2,
|
|
1684
|
-
key,
|
|
1685
|
-
mergeDeep(
|
|
1686
|
-
safeOwnRead(out2, key),
|
|
1687
|
-
safeOwnRead(sourceRecord, key),
|
|
1688
|
-
[...path, key],
|
|
1689
|
-
schema
|
|
1690
|
-
)
|
|
1691
|
-
);
|
|
1692
|
-
}
|
|
1693
|
-
return out2;
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
return {};
|
|
1697
|
+
if (du !== void 0) return mergeDuAwareKeys(source, path, schema, du);
|
|
1698
|
+
}
|
|
1699
|
+
return mergeObjectKeys(target, source, path, schema);
|
|
1700
|
+
}
|
|
1701
|
+
function mergeDuAwareKeys(source, path, schema, du) {
|
|
1702
|
+
const sourceDisc = source[du.discriminatorKey];
|
|
1703
|
+
if (sourceDisc !== void 0 && !du.isVariantSelected(sourceDisc)) {
|
|
1704
|
+
return { [du.discriminatorKey]: sourceDisc };
|
|
1705
|
+
}
|
|
1706
|
+
if (sourceDisc !== void 0) {
|
|
1707
|
+
const variantDefault = du.getVariantDefault(sourceDisc);
|
|
1708
|
+
if (isPlainRecord(variantDefault)) {
|
|
1709
|
+
return mergeVariantKeys(source, variantDefault, path, schema, du);
|
|
1697
1710
|
}
|
|
1698
1711
|
}
|
|
1699
|
-
|
|
1700
|
-
|
|
1712
|
+
return {};
|
|
1713
|
+
}
|
|
1714
|
+
function mergeVariantKeys(source, variantDefault, path, schema, du) {
|
|
1715
|
+
const out = { ...variantDefault };
|
|
1701
1716
|
for (const key of Object.keys(source)) {
|
|
1717
|
+
if (!safeOwnHas(variantDefault, key) && key !== du.discriminatorKey) continue;
|
|
1702
1718
|
safeAssign(
|
|
1703
1719
|
out,
|
|
1704
1720
|
key,
|
|
1705
|
-
mergeDeep(
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1721
|
+
mergeDeep(safeOwnRead(out, key), safeOwnRead(source, key), [...path, key], schema)
|
|
1722
|
+
);
|
|
1723
|
+
}
|
|
1724
|
+
return out;
|
|
1725
|
+
}
|
|
1726
|
+
function mergeObjectKeys(target, source, path, schema) {
|
|
1727
|
+
const out = isPlainRecord(target) ? { ...target } : {};
|
|
1728
|
+
for (const key of Object.keys(source)) {
|
|
1729
|
+
safeAssign(
|
|
1730
|
+
out,
|
|
1731
|
+
key,
|
|
1732
|
+
mergeDeep(safeOwnRead(out, key), safeOwnRead(source, key), [...path, key], schema)
|
|
1711
1733
|
);
|
|
1712
1734
|
}
|
|
1713
1735
|
return out;
|
|
@@ -2006,6 +2028,33 @@ function applyInvalidSubmitPolicy(state, formInstanceId, policy) {
|
|
|
2006
2028
|
target.element.focus({ preventScroll: true });
|
|
2007
2029
|
}
|
|
2008
2030
|
|
|
2031
|
+
function captureUserCallSite() {
|
|
2032
|
+
const raw = new Error().stack;
|
|
2033
|
+
if (typeof raw !== "string") return void 0;
|
|
2034
|
+
const lines = raw.split("\n");
|
|
2035
|
+
for (let i = 1; i < lines.length; i++) {
|
|
2036
|
+
const frame = lines[i];
|
|
2037
|
+
if (frame === void 0) continue;
|
|
2038
|
+
if (/attaform[/-]forms?/i.test(frame)) continue;
|
|
2039
|
+
if (/\bforms\.[A-Za-z0-9_-]+\.m?js\b/.test(frame)) continue;
|
|
2040
|
+
const trimmed = frame.trim();
|
|
2041
|
+
if (trimmed.length === 0) continue;
|
|
2042
|
+
return shortenSourceFrame(trimmed);
|
|
2043
|
+
}
|
|
2044
|
+
return void 0;
|
|
2045
|
+
}
|
|
2046
|
+
function shortenSourceFrame(frame) {
|
|
2047
|
+
const match = /(?:^|\s|\()([^\s()]+):(\d+):\d+\)?$/.exec(frame);
|
|
2048
|
+
if (match === null) return frame;
|
|
2049
|
+
const [, urlOrPath, line] = match;
|
|
2050
|
+
if (urlOrPath === void 0 || line === void 0) return frame;
|
|
2051
|
+
let path = urlOrPath;
|
|
2052
|
+
path = path.replace(/^[a-z]+:\/\/[^/]+\//i, "");
|
|
2053
|
+
path = path.replace(/^_nuxt\//, "");
|
|
2054
|
+
path = path.replace(/^\//, "");
|
|
2055
|
+
return `(${path}:${line})`;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2009
2058
|
function extractSchemaFields(schema) {
|
|
2010
2059
|
try {
|
|
2011
2060
|
const root = schema.getDefaultAtPath([]);
|
|
@@ -2064,9 +2113,9 @@ function isLeafValue(value) {
|
|
|
2064
2113
|
return true;
|
|
2065
2114
|
}
|
|
2066
2115
|
function isSlimPrimitiveValid(schema, store, path, value) {
|
|
2067
|
-
return walk
|
|
2116
|
+
return walk(schema, store, path, value);
|
|
2068
2117
|
}
|
|
2069
|
-
function walk
|
|
2118
|
+
function walk(schema, store, path, value) {
|
|
2070
2119
|
if (schema.isPreprocessOrCoerceLeaf(path)) return true;
|
|
2071
2120
|
const accepted = schema.getSlimPrimitiveTypesAtPath(path);
|
|
2072
2121
|
const kind = isLeafValue(value) ? slimKindOf(value) : Array.isArray(value) ? "array" : "object";
|
|
@@ -2076,13 +2125,13 @@ function walk$1(schema, store, path, value) {
|
|
|
2076
2125
|
}
|
|
2077
2126
|
if (Array.isArray(value)) {
|
|
2078
2127
|
for (let i = 0; i < value.length; i++) {
|
|
2079
|
-
if (!walk
|
|
2128
|
+
if (!walk(schema, store, [...path, i], value[i])) return false;
|
|
2080
2129
|
}
|
|
2081
2130
|
return true;
|
|
2082
2131
|
}
|
|
2083
2132
|
if (isPlainRecord(value)) {
|
|
2084
2133
|
for (const key of Object.keys(value)) {
|
|
2085
|
-
if (!walk
|
|
2134
|
+
if (!walk(schema, store, [...path, key], value[key])) {
|
|
2086
2135
|
return false;
|
|
2087
2136
|
}
|
|
2088
2137
|
}
|
|
@@ -2370,7 +2419,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2370
2419
|
throw new paths.AnonPersistError({
|
|
2371
2420
|
cause: "register-without-config",
|
|
2372
2421
|
schemaFields: extractSchemaFields(state.schema),
|
|
2373
|
-
callSite:
|
|
2422
|
+
callSite: captureUserCallSite()
|
|
2374
2423
|
});
|
|
2375
2424
|
}
|
|
2376
2425
|
const { aria } = computeFieldIdentity(formInstanceId, state.formKey, pathKey);
|
|
@@ -2482,49 +2531,60 @@ function walkUnsetSentinels(values, schema) {
|
|
|
2482
2531
|
walkUnspecified(rootSlim, [], paths);
|
|
2483
2532
|
return { cleanedValues: void 0, paths };
|
|
2484
2533
|
}
|
|
2485
|
-
const cleaned =
|
|
2534
|
+
const cleaned = walkCore(values, [], schema, paths, true);
|
|
2486
2535
|
return { cleanedValues: cleaned, paths };
|
|
2487
2536
|
}
|
|
2488
|
-
function
|
|
2537
|
+
function isOpaqueLeaf(value) {
|
|
2538
|
+
return value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || typeof value === "function";
|
|
2539
|
+
}
|
|
2540
|
+
function walkCore(input, segments, schema, paths, synthesizeSchemaKeys) {
|
|
2489
2541
|
if (isUnset(input)) {
|
|
2490
2542
|
return expandUnsetAt(segments, schema, paths);
|
|
2491
2543
|
}
|
|
2492
2544
|
if (input === void 0) {
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
if (input instanceof Date || input instanceof RegExp || input instanceof Map || input instanceof Set || typeof input === "function") {
|
|
2545
|
+
if (synthesizeSchemaKeys) {
|
|
2546
|
+
const slim = schema.getDefaultAtPath(segments);
|
|
2547
|
+
return walkUnspecified(slim, segments, paths);
|
|
2548
|
+
}
|
|
2498
2549
|
return input;
|
|
2499
2550
|
}
|
|
2551
|
+
if (input === null) return null;
|
|
2552
|
+
if (isOpaqueLeaf(input)) return input;
|
|
2500
2553
|
if (Array.isArray(input)) {
|
|
2501
2554
|
const out = new Array(input.length);
|
|
2502
2555
|
let mutated = false;
|
|
2503
2556
|
for (let i = 0; i < input.length; i++) {
|
|
2504
|
-
const walked =
|
|
2557
|
+
const walked = walkCore(input[i], [...segments, i], schema, paths, synthesizeSchemaKeys);
|
|
2505
2558
|
out[i] = walked;
|
|
2506
2559
|
if (walked !== input[i]) mutated = true;
|
|
2507
2560
|
}
|
|
2508
2561
|
return mutated ? out : input;
|
|
2509
2562
|
}
|
|
2510
2563
|
if (typeof input === "object") {
|
|
2511
|
-
const
|
|
2512
|
-
const inputKeys = Object.keys(
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2564
|
+
const obj = input;
|
|
2565
|
+
const inputKeys = Object.keys(obj);
|
|
2566
|
+
let keys = inputKeys;
|
|
2567
|
+
let mutated = false;
|
|
2568
|
+
let inputKeysSet = null;
|
|
2569
|
+
if (synthesizeSchemaKeys) {
|
|
2570
|
+
inputKeysSet = new Set(inputKeys);
|
|
2571
|
+
const allKeys = new Set(inputKeys);
|
|
2572
|
+
const slim = schema.getDefaultAtPath(segments);
|
|
2573
|
+
if (slim !== null && slim !== void 0 && typeof slim === "object" && !Array.isArray(slim) && !isOpaqueLeaf(slim)) {
|
|
2574
|
+
for (const k of Object.keys(slim)) allKeys.add(k);
|
|
2575
|
+
}
|
|
2576
|
+
keys = allKeys;
|
|
2577
|
+
mutated = allKeys.size !== inputKeys.length;
|
|
2517
2578
|
}
|
|
2518
2579
|
const out = {};
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
if (orig === void 0 && inputKeysSet.has(key)) {
|
|
2580
|
+
for (const key of keys) {
|
|
2581
|
+
const orig = obj[key];
|
|
2582
|
+
if (synthesizeSchemaKeys && orig === void 0 && inputKeysSet?.has(key) === true) {
|
|
2523
2583
|
safeAssign(out, key, void 0);
|
|
2524
2584
|
mutated = true;
|
|
2525
2585
|
continue;
|
|
2526
2586
|
}
|
|
2527
|
-
const walked =
|
|
2587
|
+
const walked = walkCore(orig, [...segments, key], schema, paths, synthesizeSchemaKeys);
|
|
2528
2588
|
safeAssign(out, key, walked);
|
|
2529
2589
|
if (walked !== orig) mutated = true;
|
|
2530
2590
|
}
|
|
@@ -2539,7 +2599,7 @@ function walkUnspecified(slim, segments, paths$1) {
|
|
|
2539
2599
|
}
|
|
2540
2600
|
return slim;
|
|
2541
2601
|
}
|
|
2542
|
-
if (slim
|
|
2602
|
+
if (isOpaqueLeaf(slim)) {
|
|
2543
2603
|
return slim;
|
|
2544
2604
|
}
|
|
2545
2605
|
if (Array.isArray(slim)) return slim;
|
|
@@ -2558,40 +2618,9 @@ function walkUnspecified(slim, segments, paths$1) {
|
|
|
2558
2618
|
}
|
|
2559
2619
|
function substituteUnsetSentinels(value, prefix, schema) {
|
|
2560
2620
|
const paths = [];
|
|
2561
|
-
const cleaned =
|
|
2621
|
+
const cleaned = walkCore(value, [...prefix], schema, paths, false);
|
|
2562
2622
|
return { cleanedValues: cleaned, paths };
|
|
2563
2623
|
}
|
|
2564
|
-
function substitute(input, segments, schema, paths) {
|
|
2565
|
-
if (isUnset(input)) {
|
|
2566
|
-
return expandUnsetAt(segments, schema, paths);
|
|
2567
|
-
}
|
|
2568
|
-
if (input === void 0 || input === null) return input;
|
|
2569
|
-
if (input instanceof Date || input instanceof RegExp || input instanceof Map || input instanceof Set || typeof input === "function") {
|
|
2570
|
-
return input;
|
|
2571
|
-
}
|
|
2572
|
-
if (Array.isArray(input)) {
|
|
2573
|
-
let mutated = false;
|
|
2574
|
-
const out = new Array(input.length);
|
|
2575
|
-
for (let i = 0; i < input.length; i++) {
|
|
2576
|
-
const walked = substitute(input[i], [...segments, i], schema, paths);
|
|
2577
|
-
out[i] = walked;
|
|
2578
|
-
if (walked !== input[i]) mutated = true;
|
|
2579
|
-
}
|
|
2580
|
-
return mutated ? out : input;
|
|
2581
|
-
}
|
|
2582
|
-
if (typeof input === "object") {
|
|
2583
|
-
let mutated = false;
|
|
2584
|
-
const out = {};
|
|
2585
|
-
for (const key of Object.keys(input)) {
|
|
2586
|
-
const orig = input[key];
|
|
2587
|
-
const walked = substitute(orig, [...segments, key], schema, paths);
|
|
2588
|
-
safeAssign(out, key, walked);
|
|
2589
|
-
if (walked !== orig) mutated = true;
|
|
2590
|
-
}
|
|
2591
|
-
return mutated ? out : input;
|
|
2592
|
-
}
|
|
2593
|
-
return input;
|
|
2594
|
-
}
|
|
2595
2624
|
function isPrimitiveOrEmpty(value) {
|
|
2596
2625
|
if (value === null || value === void 0) return true;
|
|
2597
2626
|
const t = typeof value;
|
|
@@ -2621,7 +2650,7 @@ function expandUnsetAt(segments, schema, paths$1) {
|
|
|
2621
2650
|
paths$1.push(paths.canonicalizePath(segments).key);
|
|
2622
2651
|
return slim;
|
|
2623
2652
|
}
|
|
2624
|
-
if (slim
|
|
2653
|
+
if (isOpaqueLeaf(slim)) {
|
|
2625
2654
|
paths$1.push(paths.canonicalizePath(segments).key);
|
|
2626
2655
|
return slim;
|
|
2627
2656
|
}
|
|
@@ -2755,6 +2784,17 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2755
2784
|
if (instanceMeta === void 0) return meta;
|
|
2756
2785
|
return meta === void 0 ? { instance: instanceMeta } : { ...meta, instance: instanceMeta };
|
|
2757
2786
|
};
|
|
2787
|
+
const reMarkBlanksAfterSubstitution = (paths$1) => {
|
|
2788
|
+
for (const pathKey of paths$1) {
|
|
2789
|
+
const blankSegments = paths.segmentsForPathKey(pathKey);
|
|
2790
|
+
if (blankSegments === null) continue;
|
|
2791
|
+
state.setValueAtPath(
|
|
2792
|
+
blankSegments,
|
|
2793
|
+
state.getValueAtPath(blankSegments),
|
|
2794
|
+
withInstanceMeta({ blank: true })
|
|
2795
|
+
);
|
|
2796
|
+
}
|
|
2797
|
+
};
|
|
2758
2798
|
const getFormMetaBase = () => {
|
|
2759
2799
|
const { base: rootBase } = buildContainerFieldStateBase(
|
|
2760
2800
|
state,
|
|
@@ -2812,15 +2852,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2812
2852
|
);
|
|
2813
2853
|
const ok2 = state.setValueAtPath([], walked2.cleanedValues, withInstanceMeta());
|
|
2814
2854
|
if (!ok2) return false;
|
|
2815
|
-
|
|
2816
|
-
const blankSegments = paths.segmentsForPathKey(pathKey);
|
|
2817
|
-
if (blankSegments === null) continue;
|
|
2818
|
-
state.setValueAtPath(
|
|
2819
|
-
blankSegments,
|
|
2820
|
-
state.getValueAtPath(blankSegments),
|
|
2821
|
-
withInstanceMeta({ blank: true })
|
|
2822
|
-
);
|
|
2823
|
-
}
|
|
2855
|
+
reMarkBlanksAfterSubstitution(walked2.paths);
|
|
2824
2856
|
return true;
|
|
2825
2857
|
}
|
|
2826
2858
|
const segments = paths.canonicalizePath(pathOrValue).segments;
|
|
@@ -2875,15 +2907,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2875
2907
|
);
|
|
2876
2908
|
const ok = state.setValueAtPath(segments, walked.cleanedValues, withInstanceMeta());
|
|
2877
2909
|
if (!ok) return false;
|
|
2878
|
-
|
|
2879
|
-
const blankSegments = paths.segmentsForPathKey(pathKey);
|
|
2880
|
-
if (blankSegments === null) continue;
|
|
2881
|
-
state.setValueAtPath(
|
|
2882
|
-
blankSegments,
|
|
2883
|
-
state.getValueAtPath(blankSegments),
|
|
2884
|
-
withInstanceMeta({ blank: true })
|
|
2885
|
-
);
|
|
2886
|
-
}
|
|
2910
|
+
reMarkBlanksAfterSubstitution(walked.paths);
|
|
2887
2911
|
return true;
|
|
2888
2912
|
}
|
|
2889
2913
|
const errorsProxy = buildErrorsProxy(state);
|
|
@@ -5306,6 +5330,20 @@ function captureErrorEntries(map) {
|
|
|
5306
5330
|
for (const [k, v] of map) out.push([k, [...v]]);
|
|
5307
5331
|
return out;
|
|
5308
5332
|
}
|
|
5333
|
+
function pathsEqual(a, b) {
|
|
5334
|
+
if (a.length !== b.length) return false;
|
|
5335
|
+
for (let j = 0; j < a.length; j++) {
|
|
5336
|
+
if (a[j] !== b[j]) return false;
|
|
5337
|
+
}
|
|
5338
|
+
return true;
|
|
5339
|
+
}
|
|
5340
|
+
function errorFieldsEqual(av, bvi) {
|
|
5341
|
+
if (av === bvi) return true;
|
|
5342
|
+
if (av.message !== bvi.message) return false;
|
|
5343
|
+
if (av.code !== bvi.code) return false;
|
|
5344
|
+
if (av.formKey !== bvi.formKey) return false;
|
|
5345
|
+
return av.path === bvi.path || pathsEqual(av.path, bvi.path);
|
|
5346
|
+
}
|
|
5309
5347
|
function errorsEqual(a, b) {
|
|
5310
5348
|
if (a.length !== b.length) return false;
|
|
5311
5349
|
const bMap = /* @__PURE__ */ new Map();
|
|
@@ -5315,18 +5353,7 @@ function errorsEqual(a, b) {
|
|
|
5315
5353
|
if (bv === void 0) return false;
|
|
5316
5354
|
if (v.length !== bv.length) return false;
|
|
5317
5355
|
for (let i = 0; i < v.length; i++) {
|
|
5318
|
-
|
|
5319
|
-
const bvi = bv[i];
|
|
5320
|
-
if (av === bvi) continue;
|
|
5321
|
-
if (av.message !== bvi.message) return false;
|
|
5322
|
-
if (av.code !== bvi.code) return false;
|
|
5323
|
-
if (av.formKey !== bvi.formKey) return false;
|
|
5324
|
-
if (av.path !== bvi.path) {
|
|
5325
|
-
if (av.path.length !== bvi.path.length) return false;
|
|
5326
|
-
for (let j = 0; j < av.path.length; j++) {
|
|
5327
|
-
if (av.path[j] !== bvi.path[j]) return false;
|
|
5328
|
-
}
|
|
5329
|
-
}
|
|
5356
|
+
if (!errorFieldsEqual(v[i], bv[i])) return false;
|
|
5330
5357
|
}
|
|
5331
5358
|
}
|
|
5332
5359
|
return true;
|
|
@@ -5540,7 +5567,7 @@ function useAbstractForm(configuration, options) {
|
|
|
5540
5567
|
throw new paths.AnonPersistError({
|
|
5541
5568
|
cause: "no-key",
|
|
5542
5569
|
schemaFields: extractSchemaFields(resolvedSchema),
|
|
5543
|
-
callSite:
|
|
5570
|
+
callSite: captureUserCallSite()
|
|
5544
5571
|
});
|
|
5545
5572
|
}
|
|
5546
5573
|
const existing = registry.forms.get(key);
|
|
@@ -5789,7 +5816,7 @@ function recordAmbientProvide(ssr) {
|
|
|
5789
5816
|
if (instance === null) return;
|
|
5790
5817
|
const instanceKey = instance;
|
|
5791
5818
|
const entry = {
|
|
5792
|
-
source:
|
|
5819
|
+
source: captureUserCallSite()
|
|
5793
5820
|
};
|
|
5794
5821
|
const existing = ambientProvideHistory.get(instanceKey);
|
|
5795
5822
|
if (existing === void 0) {
|
|
@@ -5828,7 +5855,7 @@ function enforceAnonPersistRule(formKey, ssr) {
|
|
|
5828
5855
|
if (paths.__DEV__)
|
|
5829
5856
|
throw new paths.AnonPersistError({
|
|
5830
5857
|
cause: "no-key",
|
|
5831
|
-
callSite:
|
|
5858
|
+
callSite: captureUserCallSite()
|
|
5832
5859
|
});
|
|
5833
5860
|
if (!ssr && !warnedAnonPersistKeys.has(formKey)) {
|
|
5834
5861
|
warnedAnonPersistKeys.add(formKey);
|
|
@@ -5885,7 +5912,7 @@ function resolveState(key, registry) {
|
|
|
5885
5912
|
}
|
|
5886
5913
|
function warnMiss$1(detail, ssr) {
|
|
5887
5914
|
if (!paths.__DEV__ || ssr) return;
|
|
5888
|
-
const frame =
|
|
5915
|
+
const frame = captureUserCallSite();
|
|
5889
5916
|
console.warn(
|
|
5890
5917
|
`[attaform] injectForm: ${detail}. Returning null.` + (frame !== void 0 ? ` ${frame}` : "")
|
|
5891
5918
|
);
|
|
@@ -5908,6 +5935,99 @@ function warnIfAmbientProviderHadDuplicates() {
|
|
|
5908
5935
|
}
|
|
5909
5936
|
}
|
|
5910
5937
|
|
|
5938
|
+
const warnedNoParentRV = paths.__DEV__ ? /* @__PURE__ */ new WeakSet() : null;
|
|
5939
|
+
let warnedOutsideSetup = false;
|
|
5940
|
+
function makeRegisterValueProxy(capturedRegisterValue) {
|
|
5941
|
+
return new Proxy({}, {
|
|
5942
|
+
get(_target, prop) {
|
|
5943
|
+
if (prop === "__v_isRef") return true;
|
|
5944
|
+
if (prop === "value") return capturedRegisterValue.value;
|
|
5945
|
+
const v = capturedRegisterValue.value;
|
|
5946
|
+
if (v === void 0) return void 0;
|
|
5947
|
+
return Reflect.get(v, prop);
|
|
5948
|
+
},
|
|
5949
|
+
has(_target, prop) {
|
|
5950
|
+
if (prop === "__v_isRef" || prop === "value") return true;
|
|
5951
|
+
const v = capturedRegisterValue.value;
|
|
5952
|
+
if (v === void 0) return false;
|
|
5953
|
+
return Reflect.has(v, prop);
|
|
5954
|
+
},
|
|
5955
|
+
ownKeys(_target) {
|
|
5956
|
+
const v = capturedRegisterValue.value;
|
|
5957
|
+
if (v === void 0) return [];
|
|
5958
|
+
return Reflect.ownKeys(v);
|
|
5959
|
+
},
|
|
5960
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
5961
|
+
const v = capturedRegisterValue.value;
|
|
5962
|
+
if (v === void 0) return void 0;
|
|
5963
|
+
const desc = Reflect.getOwnPropertyDescriptor(v, prop);
|
|
5964
|
+
if (desc !== void 0) {
|
|
5965
|
+
desc.configurable = true;
|
|
5966
|
+
}
|
|
5967
|
+
return desc;
|
|
5968
|
+
}
|
|
5969
|
+
});
|
|
5970
|
+
}
|
|
5971
|
+
function useRegister() {
|
|
5972
|
+
const instance = vue.getCurrentInstance();
|
|
5973
|
+
if (instance === null) {
|
|
5974
|
+
warnOutsideSetup();
|
|
5975
|
+
return makeRegisterValueProxy(vue.shallowRef(void 0));
|
|
5976
|
+
}
|
|
5977
|
+
paths.ensureAttaformInstalled(instance.appContext.app);
|
|
5978
|
+
const capturedRegisterValue = vue.shallowRef(void 0);
|
|
5979
|
+
const refreshAndStripBridgeAttrs = () => {
|
|
5980
|
+
const rawAttrs = instance.attrs;
|
|
5981
|
+
if ("registerValue" in rawAttrs) {
|
|
5982
|
+
capturedRegisterValue.value = rawAttrs["registerValue"];
|
|
5983
|
+
delete rawAttrs["registerValue"];
|
|
5984
|
+
} else {
|
|
5985
|
+
const dirs = instance.vnode.dirs;
|
|
5986
|
+
if (dirs !== null && dirs !== void 0) {
|
|
5987
|
+
for (const dir of dirs) {
|
|
5988
|
+
const marked = dir.dir?.[paths.V_REGISTER_MARKER];
|
|
5989
|
+
if (marked === true) {
|
|
5990
|
+
capturedRegisterValue.value = dir.value;
|
|
5991
|
+
break;
|
|
5992
|
+
}
|
|
5993
|
+
}
|
|
5994
|
+
}
|
|
5995
|
+
}
|
|
5996
|
+
if ("value" in rawAttrs) delete rawAttrs["value"];
|
|
5997
|
+
};
|
|
5998
|
+
refreshAndStripBridgeAttrs();
|
|
5999
|
+
vue.onBeforeMount(refreshAndStripBridgeAttrs);
|
|
6000
|
+
vue.onBeforeUpdate(refreshAndStripBridgeAttrs);
|
|
6001
|
+
vue.onMounted(() => {
|
|
6002
|
+
const el = instance.vnode.el;
|
|
6003
|
+
if (el !== null && el !== void 0 && typeof el === "object") {
|
|
6004
|
+
el[paths.REGISTER_OWNER_MARKER] = true;
|
|
6005
|
+
}
|
|
6006
|
+
if (capturedRegisterValue.value === void 0) {
|
|
6007
|
+
warnNoParentRV(instance);
|
|
6008
|
+
}
|
|
6009
|
+
});
|
|
6010
|
+
return makeRegisterValueProxy(capturedRegisterValue);
|
|
6011
|
+
}
|
|
6012
|
+
function warnOutsideSetup() {
|
|
6013
|
+
if (!paths.__DEV__) return;
|
|
6014
|
+
if (warnedOutsideSetup) return;
|
|
6015
|
+
warnedOutsideSetup = true;
|
|
6016
|
+
const frame = captureUserCallSite();
|
|
6017
|
+
console.warn(
|
|
6018
|
+
`[attaform] useRegister() called outside a component setup; returning an unbound RegisterValue proxy. Fix: call it inside <script setup> or a setup() function \u2014 not from an event handler or async callback.` + (frame !== void 0 ? ` ${frame}` : "")
|
|
6019
|
+
);
|
|
6020
|
+
}
|
|
6021
|
+
function warnNoParentRV(instance) {
|
|
6022
|
+
if (!paths.__DEV__ || warnedNoParentRV === null) return;
|
|
6023
|
+
if (warnedNoParentRV.has(instance)) return;
|
|
6024
|
+
warnedNoParentRV.add(instance);
|
|
6025
|
+
const frame = captureUserCallSite();
|
|
6026
|
+
console.warn(
|
|
6027
|
+
`[attaform] useRegister: no parent registerValue prop; RegisterValue fields will read as undefined. Pass v-register on the parent: \`<YourComponent v-register="form.register('field')" />\`.` + (frame !== void 0 ? ` ${frame}` : "")
|
|
6028
|
+
);
|
|
6029
|
+
}
|
|
6030
|
+
|
|
5911
6031
|
const LAZY_BRAND = Symbol.for("attaform/wizard-lazy");
|
|
5912
6032
|
function lazy(resolve) {
|
|
5913
6033
|
return { [LAZY_BRAND]: true, resolve };
|
|
@@ -6892,7 +7012,7 @@ function recordAmbientWizardProvide(ssr) {
|
|
|
6892
7012
|
if (instance === null) return;
|
|
6893
7013
|
const instanceKey = instance;
|
|
6894
7014
|
const entry = {
|
|
6895
|
-
source:
|
|
7015
|
+
source: captureUserCallSite()
|
|
6896
7016
|
};
|
|
6897
7017
|
const existing = ambientWizardProvideHistory.get(instanceKey);
|
|
6898
7018
|
if (existing === void 0) {
|
|
@@ -6947,7 +7067,7 @@ function availableKeysHint(wizards) {
|
|
|
6947
7067
|
}
|
|
6948
7068
|
function warnMiss(detail, ssr, hint) {
|
|
6949
7069
|
if (!paths.__DEV__ || ssr) return;
|
|
6950
|
-
const frame =
|
|
7070
|
+
const frame = captureUserCallSite();
|
|
6951
7071
|
const parts = [`[attaform] injectWizard: ${detail}. Returning null.`];
|
|
6952
7072
|
if (hint !== void 0) parts.push(hint);
|
|
6953
7073
|
if (frame !== void 0) parts.push(frame);
|
|
@@ -7001,5 +7121,6 @@ exports.slimKindOf = slimKindOf;
|
|
|
7001
7121
|
exports.structuralSnapshot = structuralSnapshot;
|
|
7002
7122
|
exports.unset = unset;
|
|
7003
7123
|
exports.useAbstractForm = useAbstractForm;
|
|
7124
|
+
exports.useRegister = useRegister;
|
|
7004
7125
|
exports.useWizard = useWizard;
|
|
7005
|
-
//# sourceMappingURL=attaform.
|
|
7126
|
+
//# sourceMappingURL=attaform.D2ZuIOCf.cjs.map
|