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,5 +1,5 @@
|
|
|
1
|
-
import { computed, ref, watchEffect, getCurrentScope, onScopeDispose, shallowReadonly, readonly, toRaw, reactive, watch, markRaw, shallowRef, getCurrentInstance, onServerPrefetch, provide, useId, inject, effectScope, nextTick } from 'vue';
|
|
2
|
-
import { _ as __DEV__,
|
|
1
|
+
import { computed, ref, watchEffect, getCurrentScope, onScopeDispose, shallowReadonly, readonly, toRaw, reactive, watch, markRaw, shallowRef, getCurrentInstance, onServerPrefetch, provide, useId, inject, onBeforeMount, onBeforeUpdate, onMounted, effectScope, nextTick } from 'vue';
|
|
2
|
+
import { _ as __DEV__, a as canonicalizePath, s as segmentsForPathKey, l as isPathPrefix, F as FORM_ERRORS_PATH_KEY, S as SubmitErrorHandlerError, t as toError, A as AnonPersistError, q as INTERACTIVE_TAG_NAMES, r as getOrAssignElementId, e as ROOT_PATH_KEY, R as ROOT_PATH, w as allowSensitivePersist, x as FORM_ERRORS_PATH, y as coerceToPathKey, z as isSensitivePath, B as createPersistOptInRegistry, d as InvalidUseFormConfigError, C as ensureAttaformInstalled, u as useRegistry, E as kFormContext, G as kFormInstanceId, h as ReservedFormKeyError, H as createIsSensitivePath, J as REGISTER_OWNER_MARKER, V as V_REGISTER_MARKER, k as kAttaformWizardActiveStepResolver, K as kAttaformAncestorWizard } from './attaform.DP-u7_tk.mjs';
|
|
3
3
|
|
|
4
4
|
function safeAssign(target, key, value) {
|
|
5
5
|
if (key === "__proto__") {
|
|
@@ -160,68 +160,80 @@ function mergeStructuralImpl(schema, scratch, consumer, defaultValue) {
|
|
|
160
160
|
}
|
|
161
161
|
if (consumer === null) return null;
|
|
162
162
|
if (Array.isArray(consumer)) {
|
|
163
|
-
|
|
164
|
-
const isTuple = typeof shape === "number";
|
|
165
|
-
const targetLen = isTuple ? shape : consumer.length;
|
|
166
|
-
let cachedElementDefault;
|
|
167
|
-
let cachedElementDefaultRead = false;
|
|
168
|
-
let mutated = targetLen > consumer.length;
|
|
169
|
-
const out = consumer.slice();
|
|
170
|
-
while (out.length < targetLen) out.push(void 0);
|
|
171
|
-
for (let i = 0; i < targetLen; i++) {
|
|
172
|
-
scratch.push(i);
|
|
173
|
-
let elemDefault;
|
|
174
|
-
if (isTuple) {
|
|
175
|
-
elemDefault = schema.getDefaultAtPath(scratch);
|
|
176
|
-
} else {
|
|
177
|
-
if (!cachedElementDefaultRead) {
|
|
178
|
-
cachedElementDefault = schema.getDefaultAtPath(scratch);
|
|
179
|
-
cachedElementDefaultRead = true;
|
|
180
|
-
}
|
|
181
|
-
elemDefault = cachedElementDefault;
|
|
182
|
-
}
|
|
183
|
-
const consumerElem = i < consumer.length ? consumer[i] : void 0;
|
|
184
|
-
const merged = mergeStructuralImpl(schema, scratch, consumerElem, elemDefault);
|
|
185
|
-
scratch.pop();
|
|
186
|
-
if (merged !== consumerElem) {
|
|
187
|
-
out[i] = merged;
|
|
188
|
-
mutated = true;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return mutated ? out : consumer;
|
|
163
|
+
return mergeStructuralArray(schema, scratch, consumer);
|
|
192
164
|
}
|
|
193
165
|
if (isPlainRecord(consumer)) {
|
|
194
166
|
if (!isPlainRecord(defaultValue)) {
|
|
195
167
|
return consumer;
|
|
196
168
|
}
|
|
197
|
-
let mutated = false;
|
|
198
169
|
const out = { ...consumer };
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
170
|
+
const filledAny = fillMissingKeysFromDefault(schema, scratch, consumer, defaultValue, out);
|
|
171
|
+
const recursedAny = recurseIntoConsumerKeys(schema, scratch, consumer, defaultValue, out);
|
|
172
|
+
return filledAny || recursedAny ? out : consumer;
|
|
173
|
+
}
|
|
174
|
+
return consumer;
|
|
175
|
+
}
|
|
176
|
+
function mergeStructuralArray(schema, scratch, consumer) {
|
|
177
|
+
const shape = resolveArrayShape(schema, scratch);
|
|
178
|
+
const isTuple = typeof shape === "number";
|
|
179
|
+
const targetLen = isTuple ? shape : consumer.length;
|
|
180
|
+
let cachedElementDefault;
|
|
181
|
+
let cachedElementDefaultRead = false;
|
|
182
|
+
let mutated = targetLen > consumer.length;
|
|
183
|
+
const out = consumer.slice();
|
|
184
|
+
while (out.length < targetLen) out.push(void 0);
|
|
185
|
+
for (let i = 0; i < targetLen; i++) {
|
|
186
|
+
scratch.push(i);
|
|
187
|
+
let elemDefault;
|
|
188
|
+
if (isTuple) {
|
|
189
|
+
elemDefault = schema.getDefaultAtPath(scratch);
|
|
190
|
+
} else {
|
|
191
|
+
if (!cachedElementDefaultRead) {
|
|
192
|
+
cachedElementDefault = schema.getDefaultAtPath(scratch);
|
|
193
|
+
cachedElementDefaultRead = true;
|
|
209
194
|
}
|
|
195
|
+
elemDefault = cachedElementDefault;
|
|
210
196
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
197
|
+
const consumerElem = i < consumer.length ? consumer[i] : void 0;
|
|
198
|
+
const merged = mergeStructuralImpl(schema, scratch, consumerElem, elemDefault);
|
|
199
|
+
scratch.pop();
|
|
200
|
+
if (merged !== consumerElem) {
|
|
201
|
+
out[i] = merged;
|
|
202
|
+
mutated = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return mutated ? out : consumer;
|
|
206
|
+
}
|
|
207
|
+
function fillMissingKeysFromDefault(schema, scratch, consumer, defaultValue, out) {
|
|
208
|
+
let mutated = false;
|
|
209
|
+
for (const key of Object.keys(defaultValue)) {
|
|
210
|
+
if (!safeOwnHas(consumer, key)) {
|
|
211
|
+
const defAtKey = safeOwnRead(defaultValue, key);
|
|
214
212
|
scratch.push(key);
|
|
215
|
-
const
|
|
213
|
+
const filled = mergeStructuralImpl(schema, scratch, void 0, defAtKey);
|
|
216
214
|
scratch.pop();
|
|
217
|
-
if (
|
|
218
|
-
safeAssign(out, key,
|
|
215
|
+
if (filled !== void 0) {
|
|
216
|
+
safeAssign(out, key, filled);
|
|
219
217
|
mutated = true;
|
|
220
218
|
}
|
|
221
219
|
}
|
|
222
|
-
return mutated ? out : consumer;
|
|
223
220
|
}
|
|
224
|
-
return
|
|
221
|
+
return mutated;
|
|
222
|
+
}
|
|
223
|
+
function recurseIntoConsumerKeys(schema, scratch, consumer, defaultValue, out) {
|
|
224
|
+
let mutated = false;
|
|
225
|
+
for (const key of Object.keys(consumer)) {
|
|
226
|
+
const cVal = safeOwnRead(consumer, key);
|
|
227
|
+
if (cVal === void 0) continue;
|
|
228
|
+
scratch.push(key);
|
|
229
|
+
const merged = mergeStructuralImpl(schema, scratch, cVal, safeOwnRead(defaultValue, key));
|
|
230
|
+
scratch.pop();
|
|
231
|
+
if (merged !== cVal) {
|
|
232
|
+
safeAssign(out, key, merged);
|
|
233
|
+
mutated = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return mutated;
|
|
225
237
|
}
|
|
226
238
|
function setAtPathWithSchemaFill(root, schema, fullPath, value) {
|
|
227
239
|
if (fullPath.length === 0) return value;
|
|
@@ -304,55 +316,27 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
|
|
|
304
316
|
const oldIsDescendable = isDescendable(oldValue);
|
|
305
317
|
const newIsDescendable = isDescendable(newValue);
|
|
306
318
|
if (oldValue === void 0 && newIsDescendable) {
|
|
307
|
-
|
|
308
|
-
for (let i = 0; i < newValue.length; i++) {
|
|
309
|
-
diffAndApply(void 0, newValue[i], appendSegment(prefix, i), visit);
|
|
310
|
-
}
|
|
311
|
-
} else {
|
|
312
|
-
const rec = newValue;
|
|
313
|
-
for (const k of Object.keys(rec)) {
|
|
314
|
-
diffAndApply(void 0, rec[k], appendSegment(prefix, k), visit);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
319
|
+
walkNewDescendable(newValue, prefix, visit);
|
|
317
320
|
return;
|
|
318
321
|
}
|
|
319
322
|
if (oldIsDescendable && newValue === void 0) {
|
|
320
|
-
|
|
321
|
-
for (let i = 0; i < oldValue.length; i++) {
|
|
322
|
-
diffAndApply(oldValue[i], void 0, appendSegment(prefix, i), visit);
|
|
323
|
-
}
|
|
324
|
-
} else {
|
|
325
|
-
const rec = oldValue;
|
|
326
|
-
for (const k of Object.keys(rec)) {
|
|
327
|
-
diffAndApply(rec[k], void 0, appendSegment(prefix, k), visit);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
323
|
+
walkOldDescendable(oldValue, prefix, visit);
|
|
330
324
|
return;
|
|
331
325
|
}
|
|
332
326
|
if (oldIsDescendable && newIsDescendable) {
|
|
333
327
|
const oldIsArray = Array.isArray(oldValue);
|
|
334
328
|
const newIsArray = Array.isArray(newValue);
|
|
335
329
|
if (oldIsArray && newIsArray) {
|
|
336
|
-
|
|
337
|
-
const newArr = newValue;
|
|
338
|
-
const max = Math.max(oldArr.length, newArr.length);
|
|
339
|
-
for (let i = 0; i < max; i++) {
|
|
340
|
-
diffAndApply(oldArr[i], newArr[i], appendSegment(prefix, i), visit);
|
|
341
|
-
}
|
|
330
|
+
diffArraysLockstep(oldValue, newValue, prefix, visit);
|
|
342
331
|
return;
|
|
343
332
|
}
|
|
344
333
|
if (!oldIsArray && !newIsArray) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
for (const k of Object.keys(newRec)) {
|
|
353
|
-
if (seen.has(k)) continue;
|
|
354
|
-
diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
|
|
355
|
-
}
|
|
334
|
+
diffObjectsLockstep(
|
|
335
|
+
oldValue,
|
|
336
|
+
newValue,
|
|
337
|
+
prefix,
|
|
338
|
+
visit
|
|
339
|
+
);
|
|
356
340
|
return;
|
|
357
341
|
}
|
|
358
342
|
visit({ kind: "changed", path: prefix, oldValue, newValue });
|
|
@@ -376,6 +360,47 @@ function diffAndApply(oldValue, newValue, prefix, visit) {
|
|
|
376
360
|
}
|
|
377
361
|
visit({ kind: "changed", path: prefix, oldValue, newValue });
|
|
378
362
|
}
|
|
363
|
+
function walkNewDescendable(newValue, prefix, visit) {
|
|
364
|
+
if (Array.isArray(newValue)) {
|
|
365
|
+
for (let i = 0; i < newValue.length; i++) {
|
|
366
|
+
diffAndApply(void 0, newValue[i], appendSegment(prefix, i), visit);
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
const rec = newValue;
|
|
370
|
+
for (const k of Object.keys(rec)) {
|
|
371
|
+
diffAndApply(void 0, rec[k], appendSegment(prefix, k), visit);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function walkOldDescendable(oldValue, prefix, visit) {
|
|
376
|
+
if (Array.isArray(oldValue)) {
|
|
377
|
+
for (let i = 0; i < oldValue.length; i++) {
|
|
378
|
+
diffAndApply(oldValue[i], void 0, appendSegment(prefix, i), visit);
|
|
379
|
+
}
|
|
380
|
+
} else {
|
|
381
|
+
const rec = oldValue;
|
|
382
|
+
for (const k of Object.keys(rec)) {
|
|
383
|
+
diffAndApply(rec[k], void 0, appendSegment(prefix, k), visit);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function diffArraysLockstep(oldArr, newArr, prefix, visit) {
|
|
388
|
+
const max = Math.max(oldArr.length, newArr.length);
|
|
389
|
+
for (let i = 0; i < max; i++) {
|
|
390
|
+
diffAndApply(oldArr[i], newArr[i], appendSegment(prefix, i), visit);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function diffObjectsLockstep(oldRec, newRec, prefix, visit) {
|
|
394
|
+
const seen = /* @__PURE__ */ new Set();
|
|
395
|
+
for (const k of Object.keys(oldRec)) {
|
|
396
|
+
seen.add(k);
|
|
397
|
+
diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
|
|
398
|
+
}
|
|
399
|
+
for (const k of Object.keys(newRec)) {
|
|
400
|
+
if (seen.has(k)) continue;
|
|
401
|
+
diffAndApply(oldRec[k], newRec[k], appendSegment(prefix, k), visit);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
379
404
|
function applyChangedKeys(target, source) {
|
|
380
405
|
if (!isDescendable(target) || !isDescendable(source)) return false;
|
|
381
406
|
const targetIsArray = Array.isArray(target);
|
|
@@ -623,6 +648,12 @@ function buildFieldStateAccessor(state, formInstanceId, getFormMetaBase, options
|
|
|
623
648
|
return c;
|
|
624
649
|
};
|
|
625
650
|
}
|
|
651
|
+
function resolveFieldMetaAndLabel(state, segments) {
|
|
652
|
+
const resolved = state.schema.getFieldMetaAtPath ? state.schema.getFieldMetaAtPath(segments) : EMPTY_RESOLVED_FIELD_META;
|
|
653
|
+
const lastSegment = segments.length === 0 ? "" : segments[segments.length - 1] ?? "";
|
|
654
|
+
const label = resolved.label || humanize(lastSegment);
|
|
655
|
+
return { resolved, label };
|
|
656
|
+
}
|
|
626
657
|
function buildLeafFieldStateBase(state, segments, key, formInstanceId) {
|
|
627
658
|
const record = state.fields.get(key);
|
|
628
659
|
const value = state.getValueAtPath(segments);
|
|
@@ -644,9 +675,7 @@ function buildLeafFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
644
675
|
const elementRecord = state.elements.get(key);
|
|
645
676
|
const elementsArr = elementRecord ? Object.freeze([...elementRecord.elements]) : EMPTY_ELEMENTS;
|
|
646
677
|
const firstElement = elementsArr[0] ?? null;
|
|
647
|
-
const resolved = state
|
|
648
|
-
const lastSegment = segments.length === 0 ? "" : segments[segments.length - 1] ?? "";
|
|
649
|
-
const label = resolved.label || humanize(lastSegment);
|
|
678
|
+
const { resolved, label } = resolveFieldMetaAndLabel(state, segments);
|
|
650
679
|
return {
|
|
651
680
|
value,
|
|
652
681
|
original,
|
|
@@ -783,9 +812,7 @@ function buildContainerFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
783
812
|
const ownTransformError = state.transformErrors.get(key) ?? null;
|
|
784
813
|
const gated = asyncPending && !state.firstValidationDone.value;
|
|
785
814
|
const valid = !gated && errors.length === 0 && !validating;
|
|
786
|
-
const resolved = state
|
|
787
|
-
const lastSegment = segments.length === 0 ? "" : segments[segments.length - 1] ?? "";
|
|
788
|
-
const label = resolved.label || humanize(lastSegment);
|
|
815
|
+
const { resolved, label } = resolveFieldMetaAndLabel(state, segments);
|
|
789
816
|
return {
|
|
790
817
|
base: {
|
|
791
818
|
value,
|
|
@@ -1568,20 +1595,20 @@ function buildFieldStateProxy(state, formInstanceId, getFormMetaBase, options) {
|
|
|
1568
1595
|
}
|
|
1569
1596
|
function materializeFields(state, containerSegments, snapshotFieldStateAt) {
|
|
1570
1597
|
const liveValue = getAtPath(state.form.value, containerSegments);
|
|
1571
|
-
return walk$
|
|
1598
|
+
return walk$1(liveValue, containerSegments, state.schema, snapshotFieldStateAt);
|
|
1572
1599
|
}
|
|
1573
|
-
function walk$
|
|
1600
|
+
function walk$1(value, basePath, schema, snapshotFieldStateAt) {
|
|
1574
1601
|
if (schema.isLeafAtPath(basePath)) return snapshotFieldStateAt(basePath);
|
|
1575
1602
|
if (value === null || value === void 0) return value;
|
|
1576
1603
|
if (typeof value !== "object") {
|
|
1577
1604
|
return value;
|
|
1578
1605
|
}
|
|
1579
1606
|
if (Array.isArray(value)) {
|
|
1580
|
-
return value.map((_, i) => walk$
|
|
1607
|
+
return value.map((_, i) => walk$1(value[i], [...basePath, i], schema, snapshotFieldStateAt));
|
|
1581
1608
|
}
|
|
1582
1609
|
const result = {};
|
|
1583
1610
|
for (const key of Object.keys(value)) {
|
|
1584
|
-
result[key] = walk$
|
|
1611
|
+
result[key] = walk$1(
|
|
1585
1612
|
value[key],
|
|
1586
1613
|
[...basePath, key],
|
|
1587
1614
|
schema,
|
|
@@ -1665,47 +1692,42 @@ function mergeDeep(target, source, path, schema) {
|
|
|
1665
1692
|
if (!isPlainRecord(source)) return source;
|
|
1666
1693
|
if (schema !== void 0) {
|
|
1667
1694
|
const du = schema.getUnionDiscriminatorAtPath(path);
|
|
1668
|
-
if (du !== void 0)
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
out2,
|
|
1682
|
-
key,
|
|
1683
|
-
mergeDeep(
|
|
1684
|
-
safeOwnRead(out2, key),
|
|
1685
|
-
safeOwnRead(sourceRecord, key),
|
|
1686
|
-
[...path, key],
|
|
1687
|
-
schema
|
|
1688
|
-
)
|
|
1689
|
-
);
|
|
1690
|
-
}
|
|
1691
|
-
return out2;
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
return {};
|
|
1695
|
+
if (du !== void 0) return mergeDuAwareKeys(source, path, schema, du);
|
|
1696
|
+
}
|
|
1697
|
+
return mergeObjectKeys(target, source, path, schema);
|
|
1698
|
+
}
|
|
1699
|
+
function mergeDuAwareKeys(source, path, schema, du) {
|
|
1700
|
+
const sourceDisc = source[du.discriminatorKey];
|
|
1701
|
+
if (sourceDisc !== void 0 && !du.isVariantSelected(sourceDisc)) {
|
|
1702
|
+
return { [du.discriminatorKey]: sourceDisc };
|
|
1703
|
+
}
|
|
1704
|
+
if (sourceDisc !== void 0) {
|
|
1705
|
+
const variantDefault = du.getVariantDefault(sourceDisc);
|
|
1706
|
+
if (isPlainRecord(variantDefault)) {
|
|
1707
|
+
return mergeVariantKeys(source, variantDefault, path, schema, du);
|
|
1695
1708
|
}
|
|
1696
1709
|
}
|
|
1697
|
-
|
|
1698
|
-
|
|
1710
|
+
return {};
|
|
1711
|
+
}
|
|
1712
|
+
function mergeVariantKeys(source, variantDefault, path, schema, du) {
|
|
1713
|
+
const out = { ...variantDefault };
|
|
1699
1714
|
for (const key of Object.keys(source)) {
|
|
1715
|
+
if (!safeOwnHas(variantDefault, key) && key !== du.discriminatorKey) continue;
|
|
1700
1716
|
safeAssign(
|
|
1701
1717
|
out,
|
|
1702
1718
|
key,
|
|
1703
|
-
mergeDeep(
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1719
|
+
mergeDeep(safeOwnRead(out, key), safeOwnRead(source, key), [...path, key], schema)
|
|
1720
|
+
);
|
|
1721
|
+
}
|
|
1722
|
+
return out;
|
|
1723
|
+
}
|
|
1724
|
+
function mergeObjectKeys(target, source, path, schema) {
|
|
1725
|
+
const out = isPlainRecord(target) ? { ...target } : {};
|
|
1726
|
+
for (const key of Object.keys(source)) {
|
|
1727
|
+
safeAssign(
|
|
1728
|
+
out,
|
|
1729
|
+
key,
|
|
1730
|
+
mergeDeep(safeOwnRead(out, key), safeOwnRead(source, key), [...path, key], schema)
|
|
1709
1731
|
);
|
|
1710
1732
|
}
|
|
1711
1733
|
return out;
|
|
@@ -2004,6 +2026,33 @@ function applyInvalidSubmitPolicy(state, formInstanceId, policy) {
|
|
|
2004
2026
|
target.element.focus({ preventScroll: true });
|
|
2005
2027
|
}
|
|
2006
2028
|
|
|
2029
|
+
function captureUserCallSite() {
|
|
2030
|
+
const raw = new Error().stack;
|
|
2031
|
+
if (typeof raw !== "string") return void 0;
|
|
2032
|
+
const lines = raw.split("\n");
|
|
2033
|
+
for (let i = 1; i < lines.length; i++) {
|
|
2034
|
+
const frame = lines[i];
|
|
2035
|
+
if (frame === void 0) continue;
|
|
2036
|
+
if (/attaform[/-]forms?/i.test(frame)) continue;
|
|
2037
|
+
if (/\bforms\.[A-Za-z0-9_-]+\.m?js\b/.test(frame)) continue;
|
|
2038
|
+
const trimmed = frame.trim();
|
|
2039
|
+
if (trimmed.length === 0) continue;
|
|
2040
|
+
return shortenSourceFrame(trimmed);
|
|
2041
|
+
}
|
|
2042
|
+
return void 0;
|
|
2043
|
+
}
|
|
2044
|
+
function shortenSourceFrame(frame) {
|
|
2045
|
+
const match = /(?:^|\s|\()([^\s()]+):(\d+):\d+\)?$/.exec(frame);
|
|
2046
|
+
if (match === null) return frame;
|
|
2047
|
+
const [, urlOrPath, line] = match;
|
|
2048
|
+
if (urlOrPath === void 0 || line === void 0) return frame;
|
|
2049
|
+
let path = urlOrPath;
|
|
2050
|
+
path = path.replace(/^[a-z]+:\/\/[^/]+\//i, "");
|
|
2051
|
+
path = path.replace(/^_nuxt\//, "");
|
|
2052
|
+
path = path.replace(/^\//, "");
|
|
2053
|
+
return `(${path}:${line})`;
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2007
2056
|
function extractSchemaFields(schema) {
|
|
2008
2057
|
try {
|
|
2009
2058
|
const root = schema.getDefaultAtPath([]);
|
|
@@ -2062,9 +2111,9 @@ function isLeafValue(value) {
|
|
|
2062
2111
|
return true;
|
|
2063
2112
|
}
|
|
2064
2113
|
function isSlimPrimitiveValid(schema, store, path, value) {
|
|
2065
|
-
return walk
|
|
2114
|
+
return walk(schema, store, path, value);
|
|
2066
2115
|
}
|
|
2067
|
-
function walk
|
|
2116
|
+
function walk(schema, store, path, value) {
|
|
2068
2117
|
if (schema.isPreprocessOrCoerceLeaf(path)) return true;
|
|
2069
2118
|
const accepted = schema.getSlimPrimitiveTypesAtPath(path);
|
|
2070
2119
|
const kind = isLeafValue(value) ? slimKindOf(value) : Array.isArray(value) ? "array" : "object";
|
|
@@ -2074,13 +2123,13 @@ function walk$1(schema, store, path, value) {
|
|
|
2074
2123
|
}
|
|
2075
2124
|
if (Array.isArray(value)) {
|
|
2076
2125
|
for (let i = 0; i < value.length; i++) {
|
|
2077
|
-
if (!walk
|
|
2126
|
+
if (!walk(schema, store, [...path, i], value[i])) return false;
|
|
2078
2127
|
}
|
|
2079
2128
|
return true;
|
|
2080
2129
|
}
|
|
2081
2130
|
if (isPlainRecord(value)) {
|
|
2082
2131
|
for (const key of Object.keys(value)) {
|
|
2083
|
-
if (!walk
|
|
2132
|
+
if (!walk(schema, store, [...path, key], value[key])) {
|
|
2084
2133
|
return false;
|
|
2085
2134
|
}
|
|
2086
2135
|
}
|
|
@@ -2480,49 +2529,60 @@ function walkUnsetSentinels(values, schema) {
|
|
|
2480
2529
|
walkUnspecified(rootSlim, [], paths);
|
|
2481
2530
|
return { cleanedValues: void 0, paths };
|
|
2482
2531
|
}
|
|
2483
|
-
const cleaned =
|
|
2532
|
+
const cleaned = walkCore(values, [], schema, paths, true);
|
|
2484
2533
|
return { cleanedValues: cleaned, paths };
|
|
2485
2534
|
}
|
|
2486
|
-
function
|
|
2535
|
+
function isOpaqueLeaf(value) {
|
|
2536
|
+
return value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || typeof value === "function";
|
|
2537
|
+
}
|
|
2538
|
+
function walkCore(input, segments, schema, paths, synthesizeSchemaKeys) {
|
|
2487
2539
|
if (isUnset(input)) {
|
|
2488
2540
|
return expandUnsetAt(segments, schema, paths);
|
|
2489
2541
|
}
|
|
2490
2542
|
if (input === void 0) {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
if (input instanceof Date || input instanceof RegExp || input instanceof Map || input instanceof Set || typeof input === "function") {
|
|
2543
|
+
if (synthesizeSchemaKeys) {
|
|
2544
|
+
const slim = schema.getDefaultAtPath(segments);
|
|
2545
|
+
return walkUnspecified(slim, segments, paths);
|
|
2546
|
+
}
|
|
2496
2547
|
return input;
|
|
2497
2548
|
}
|
|
2549
|
+
if (input === null) return null;
|
|
2550
|
+
if (isOpaqueLeaf(input)) return input;
|
|
2498
2551
|
if (Array.isArray(input)) {
|
|
2499
2552
|
const out = new Array(input.length);
|
|
2500
2553
|
let mutated = false;
|
|
2501
2554
|
for (let i = 0; i < input.length; i++) {
|
|
2502
|
-
const walked =
|
|
2555
|
+
const walked = walkCore(input[i], [...segments, i], schema, paths, synthesizeSchemaKeys);
|
|
2503
2556
|
out[i] = walked;
|
|
2504
2557
|
if (walked !== input[i]) mutated = true;
|
|
2505
2558
|
}
|
|
2506
2559
|
return mutated ? out : input;
|
|
2507
2560
|
}
|
|
2508
2561
|
if (typeof input === "object") {
|
|
2509
|
-
const
|
|
2510
|
-
const inputKeys = Object.keys(
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2562
|
+
const obj = input;
|
|
2563
|
+
const inputKeys = Object.keys(obj);
|
|
2564
|
+
let keys = inputKeys;
|
|
2565
|
+
let mutated = false;
|
|
2566
|
+
let inputKeysSet = null;
|
|
2567
|
+
if (synthesizeSchemaKeys) {
|
|
2568
|
+
inputKeysSet = new Set(inputKeys);
|
|
2569
|
+
const allKeys = new Set(inputKeys);
|
|
2570
|
+
const slim = schema.getDefaultAtPath(segments);
|
|
2571
|
+
if (slim !== null && slim !== void 0 && typeof slim === "object" && !Array.isArray(slim) && !isOpaqueLeaf(slim)) {
|
|
2572
|
+
for (const k of Object.keys(slim)) allKeys.add(k);
|
|
2573
|
+
}
|
|
2574
|
+
keys = allKeys;
|
|
2575
|
+
mutated = allKeys.size !== inputKeys.length;
|
|
2515
2576
|
}
|
|
2516
2577
|
const out = {};
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
if (orig === void 0 && inputKeysSet.has(key)) {
|
|
2578
|
+
for (const key of keys) {
|
|
2579
|
+
const orig = obj[key];
|
|
2580
|
+
if (synthesizeSchemaKeys && orig === void 0 && inputKeysSet?.has(key) === true) {
|
|
2521
2581
|
safeAssign(out, key, void 0);
|
|
2522
2582
|
mutated = true;
|
|
2523
2583
|
continue;
|
|
2524
2584
|
}
|
|
2525
|
-
const walked =
|
|
2585
|
+
const walked = walkCore(orig, [...segments, key], schema, paths, synthesizeSchemaKeys);
|
|
2526
2586
|
safeAssign(out, key, walked);
|
|
2527
2587
|
if (walked !== orig) mutated = true;
|
|
2528
2588
|
}
|
|
@@ -2537,7 +2597,7 @@ function walkUnspecified(slim, segments, paths) {
|
|
|
2537
2597
|
}
|
|
2538
2598
|
return slim;
|
|
2539
2599
|
}
|
|
2540
|
-
if (slim
|
|
2600
|
+
if (isOpaqueLeaf(slim)) {
|
|
2541
2601
|
return slim;
|
|
2542
2602
|
}
|
|
2543
2603
|
if (Array.isArray(slim)) return slim;
|
|
@@ -2556,40 +2616,9 @@ function walkUnspecified(slim, segments, paths) {
|
|
|
2556
2616
|
}
|
|
2557
2617
|
function substituteUnsetSentinels(value, prefix, schema) {
|
|
2558
2618
|
const paths = [];
|
|
2559
|
-
const cleaned =
|
|
2619
|
+
const cleaned = walkCore(value, [...prefix], schema, paths, false);
|
|
2560
2620
|
return { cleanedValues: cleaned, paths };
|
|
2561
2621
|
}
|
|
2562
|
-
function substitute(input, segments, schema, paths) {
|
|
2563
|
-
if (isUnset(input)) {
|
|
2564
|
-
return expandUnsetAt(segments, schema, paths);
|
|
2565
|
-
}
|
|
2566
|
-
if (input === void 0 || input === null) return input;
|
|
2567
|
-
if (input instanceof Date || input instanceof RegExp || input instanceof Map || input instanceof Set || typeof input === "function") {
|
|
2568
|
-
return input;
|
|
2569
|
-
}
|
|
2570
|
-
if (Array.isArray(input)) {
|
|
2571
|
-
let mutated = false;
|
|
2572
|
-
const out = new Array(input.length);
|
|
2573
|
-
for (let i = 0; i < input.length; i++) {
|
|
2574
|
-
const walked = substitute(input[i], [...segments, i], schema, paths);
|
|
2575
|
-
out[i] = walked;
|
|
2576
|
-
if (walked !== input[i]) mutated = true;
|
|
2577
|
-
}
|
|
2578
|
-
return mutated ? out : input;
|
|
2579
|
-
}
|
|
2580
|
-
if (typeof input === "object") {
|
|
2581
|
-
let mutated = false;
|
|
2582
|
-
const out = {};
|
|
2583
|
-
for (const key of Object.keys(input)) {
|
|
2584
|
-
const orig = input[key];
|
|
2585
|
-
const walked = substitute(orig, [...segments, key], schema, paths);
|
|
2586
|
-
safeAssign(out, key, walked);
|
|
2587
|
-
if (walked !== orig) mutated = true;
|
|
2588
|
-
}
|
|
2589
|
-
return mutated ? out : input;
|
|
2590
|
-
}
|
|
2591
|
-
return input;
|
|
2592
|
-
}
|
|
2593
2622
|
function isPrimitiveOrEmpty(value) {
|
|
2594
2623
|
if (value === null || value === void 0) return true;
|
|
2595
2624
|
const t = typeof value;
|
|
@@ -2619,7 +2648,7 @@ function expandUnsetAt(segments, schema, paths) {
|
|
|
2619
2648
|
paths.push(canonicalizePath(segments).key);
|
|
2620
2649
|
return slim;
|
|
2621
2650
|
}
|
|
2622
|
-
if (slim
|
|
2651
|
+
if (isOpaqueLeaf(slim)) {
|
|
2623
2652
|
paths.push(canonicalizePath(segments).key);
|
|
2624
2653
|
return slim;
|
|
2625
2654
|
}
|
|
@@ -2753,6 +2782,17 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2753
2782
|
if (instanceMeta === void 0) return meta;
|
|
2754
2783
|
return meta === void 0 ? { instance: instanceMeta } : { ...meta, instance: instanceMeta };
|
|
2755
2784
|
};
|
|
2785
|
+
const reMarkBlanksAfterSubstitution = (paths) => {
|
|
2786
|
+
for (const pathKey of paths) {
|
|
2787
|
+
const blankSegments = segmentsForPathKey(pathKey);
|
|
2788
|
+
if (blankSegments === null) continue;
|
|
2789
|
+
state.setValueAtPath(
|
|
2790
|
+
blankSegments,
|
|
2791
|
+
state.getValueAtPath(blankSegments),
|
|
2792
|
+
withInstanceMeta({ blank: true })
|
|
2793
|
+
);
|
|
2794
|
+
}
|
|
2795
|
+
};
|
|
2756
2796
|
const getFormMetaBase = () => {
|
|
2757
2797
|
const { base: rootBase } = buildContainerFieldStateBase(
|
|
2758
2798
|
state,
|
|
@@ -2810,15 +2850,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2810
2850
|
);
|
|
2811
2851
|
const ok2 = state.setValueAtPath([], walked2.cleanedValues, withInstanceMeta());
|
|
2812
2852
|
if (!ok2) return false;
|
|
2813
|
-
|
|
2814
|
-
const blankSegments = segmentsForPathKey(pathKey);
|
|
2815
|
-
if (blankSegments === null) continue;
|
|
2816
|
-
state.setValueAtPath(
|
|
2817
|
-
blankSegments,
|
|
2818
|
-
state.getValueAtPath(blankSegments),
|
|
2819
|
-
withInstanceMeta({ blank: true })
|
|
2820
|
-
);
|
|
2821
|
-
}
|
|
2853
|
+
reMarkBlanksAfterSubstitution(walked2.paths);
|
|
2822
2854
|
return true;
|
|
2823
2855
|
}
|
|
2824
2856
|
const segments = canonicalizePath(pathOrValue).segments;
|
|
@@ -2873,15 +2905,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2873
2905
|
);
|
|
2874
2906
|
const ok = state.setValueAtPath(segments, walked.cleanedValues, withInstanceMeta());
|
|
2875
2907
|
if (!ok) return false;
|
|
2876
|
-
|
|
2877
|
-
const blankSegments = segmentsForPathKey(pathKey);
|
|
2878
|
-
if (blankSegments === null) continue;
|
|
2879
|
-
state.setValueAtPath(
|
|
2880
|
-
blankSegments,
|
|
2881
|
-
state.getValueAtPath(blankSegments),
|
|
2882
|
-
withInstanceMeta({ blank: true })
|
|
2883
|
-
);
|
|
2884
|
-
}
|
|
2908
|
+
reMarkBlanksAfterSubstitution(walked.paths);
|
|
2885
2909
|
return true;
|
|
2886
2910
|
}
|
|
2887
2911
|
const errorsProxy = buildErrorsProxy(state);
|
|
@@ -5304,6 +5328,20 @@ function captureErrorEntries(map) {
|
|
|
5304
5328
|
for (const [k, v] of map) out.push([k, [...v]]);
|
|
5305
5329
|
return out;
|
|
5306
5330
|
}
|
|
5331
|
+
function pathsEqual(a, b) {
|
|
5332
|
+
if (a.length !== b.length) return false;
|
|
5333
|
+
for (let j = 0; j < a.length; j++) {
|
|
5334
|
+
if (a[j] !== b[j]) return false;
|
|
5335
|
+
}
|
|
5336
|
+
return true;
|
|
5337
|
+
}
|
|
5338
|
+
function errorFieldsEqual(av, bvi) {
|
|
5339
|
+
if (av === bvi) return true;
|
|
5340
|
+
if (av.message !== bvi.message) return false;
|
|
5341
|
+
if (av.code !== bvi.code) return false;
|
|
5342
|
+
if (av.formKey !== bvi.formKey) return false;
|
|
5343
|
+
return av.path === bvi.path || pathsEqual(av.path, bvi.path);
|
|
5344
|
+
}
|
|
5307
5345
|
function errorsEqual(a, b) {
|
|
5308
5346
|
if (a.length !== b.length) return false;
|
|
5309
5347
|
const bMap = /* @__PURE__ */ new Map();
|
|
@@ -5313,18 +5351,7 @@ function errorsEqual(a, b) {
|
|
|
5313
5351
|
if (bv === void 0) return false;
|
|
5314
5352
|
if (v.length !== bv.length) return false;
|
|
5315
5353
|
for (let i = 0; i < v.length; i++) {
|
|
5316
|
-
|
|
5317
|
-
const bvi = bv[i];
|
|
5318
|
-
if (av === bvi) continue;
|
|
5319
|
-
if (av.message !== bvi.message) return false;
|
|
5320
|
-
if (av.code !== bvi.code) return false;
|
|
5321
|
-
if (av.formKey !== bvi.formKey) return false;
|
|
5322
|
-
if (av.path !== bvi.path) {
|
|
5323
|
-
if (av.path.length !== bvi.path.length) return false;
|
|
5324
|
-
for (let j = 0; j < av.path.length; j++) {
|
|
5325
|
-
if (av.path[j] !== bvi.path[j]) return false;
|
|
5326
|
-
}
|
|
5327
|
-
}
|
|
5354
|
+
if (!errorFieldsEqual(v[i], bv[i])) return false;
|
|
5328
5355
|
}
|
|
5329
5356
|
}
|
|
5330
5357
|
return true;
|
|
@@ -5906,6 +5933,99 @@ function warnIfAmbientProviderHadDuplicates() {
|
|
|
5906
5933
|
}
|
|
5907
5934
|
}
|
|
5908
5935
|
|
|
5936
|
+
const warnedNoParentRV = __DEV__ ? /* @__PURE__ */ new WeakSet() : null;
|
|
5937
|
+
let warnedOutsideSetup = false;
|
|
5938
|
+
function makeRegisterValueProxy(capturedRegisterValue) {
|
|
5939
|
+
return new Proxy({}, {
|
|
5940
|
+
get(_target, prop) {
|
|
5941
|
+
if (prop === "__v_isRef") return true;
|
|
5942
|
+
if (prop === "value") return capturedRegisterValue.value;
|
|
5943
|
+
const v = capturedRegisterValue.value;
|
|
5944
|
+
if (v === void 0) return void 0;
|
|
5945
|
+
return Reflect.get(v, prop);
|
|
5946
|
+
},
|
|
5947
|
+
has(_target, prop) {
|
|
5948
|
+
if (prop === "__v_isRef" || prop === "value") return true;
|
|
5949
|
+
const v = capturedRegisterValue.value;
|
|
5950
|
+
if (v === void 0) return false;
|
|
5951
|
+
return Reflect.has(v, prop);
|
|
5952
|
+
},
|
|
5953
|
+
ownKeys(_target) {
|
|
5954
|
+
const v = capturedRegisterValue.value;
|
|
5955
|
+
if (v === void 0) return [];
|
|
5956
|
+
return Reflect.ownKeys(v);
|
|
5957
|
+
},
|
|
5958
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
5959
|
+
const v = capturedRegisterValue.value;
|
|
5960
|
+
if (v === void 0) return void 0;
|
|
5961
|
+
const desc = Reflect.getOwnPropertyDescriptor(v, prop);
|
|
5962
|
+
if (desc !== void 0) {
|
|
5963
|
+
desc.configurable = true;
|
|
5964
|
+
}
|
|
5965
|
+
return desc;
|
|
5966
|
+
}
|
|
5967
|
+
});
|
|
5968
|
+
}
|
|
5969
|
+
function useRegister() {
|
|
5970
|
+
const instance = getCurrentInstance();
|
|
5971
|
+
if (instance === null) {
|
|
5972
|
+
warnOutsideSetup();
|
|
5973
|
+
return makeRegisterValueProxy(shallowRef(void 0));
|
|
5974
|
+
}
|
|
5975
|
+
ensureAttaformInstalled(instance.appContext.app);
|
|
5976
|
+
const capturedRegisterValue = shallowRef(void 0);
|
|
5977
|
+
const refreshAndStripBridgeAttrs = () => {
|
|
5978
|
+
const rawAttrs = instance.attrs;
|
|
5979
|
+
if ("registerValue" in rawAttrs) {
|
|
5980
|
+
capturedRegisterValue.value = rawAttrs["registerValue"];
|
|
5981
|
+
delete rawAttrs["registerValue"];
|
|
5982
|
+
} else {
|
|
5983
|
+
const dirs = instance.vnode.dirs;
|
|
5984
|
+
if (dirs !== null && dirs !== void 0) {
|
|
5985
|
+
for (const dir of dirs) {
|
|
5986
|
+
const marked = dir.dir?.[V_REGISTER_MARKER];
|
|
5987
|
+
if (marked === true) {
|
|
5988
|
+
capturedRegisterValue.value = dir.value;
|
|
5989
|
+
break;
|
|
5990
|
+
}
|
|
5991
|
+
}
|
|
5992
|
+
}
|
|
5993
|
+
}
|
|
5994
|
+
if ("value" in rawAttrs) delete rawAttrs["value"];
|
|
5995
|
+
};
|
|
5996
|
+
refreshAndStripBridgeAttrs();
|
|
5997
|
+
onBeforeMount(refreshAndStripBridgeAttrs);
|
|
5998
|
+
onBeforeUpdate(refreshAndStripBridgeAttrs);
|
|
5999
|
+
onMounted(() => {
|
|
6000
|
+
const el = instance.vnode.el;
|
|
6001
|
+
if (el !== null && el !== void 0 && typeof el === "object") {
|
|
6002
|
+
el[REGISTER_OWNER_MARKER] = true;
|
|
6003
|
+
}
|
|
6004
|
+
if (capturedRegisterValue.value === void 0) {
|
|
6005
|
+
warnNoParentRV(instance);
|
|
6006
|
+
}
|
|
6007
|
+
});
|
|
6008
|
+
return makeRegisterValueProxy(capturedRegisterValue);
|
|
6009
|
+
}
|
|
6010
|
+
function warnOutsideSetup() {
|
|
6011
|
+
if (!__DEV__) return;
|
|
6012
|
+
if (warnedOutsideSetup) return;
|
|
6013
|
+
warnedOutsideSetup = true;
|
|
6014
|
+
const frame = captureUserCallSite();
|
|
6015
|
+
console.warn(
|
|
6016
|
+
`[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}` : "")
|
|
6017
|
+
);
|
|
6018
|
+
}
|
|
6019
|
+
function warnNoParentRV(instance) {
|
|
6020
|
+
if (!__DEV__ || warnedNoParentRV === null) return;
|
|
6021
|
+
if (warnedNoParentRV.has(instance)) return;
|
|
6022
|
+
warnedNoParentRV.add(instance);
|
|
6023
|
+
const frame = captureUserCallSite();
|
|
6024
|
+
console.warn(
|
|
6025
|
+
`[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}` : "")
|
|
6026
|
+
);
|
|
6027
|
+
}
|
|
6028
|
+
|
|
5909
6029
|
const LAZY_BRAND = Symbol.for("attaform/wizard-lazy");
|
|
5910
6030
|
function lazy(resolve) {
|
|
5911
6031
|
return { [LAZY_BRAND]: true, resolve };
|
|
@@ -6969,5 +7089,5 @@ function warnIfAmbientWizardProviderHadDuplicates() {
|
|
|
6969
7089
|
}
|
|
6970
7090
|
}
|
|
6971
7091
|
|
|
6972
|
-
export { AttaformErrorCode as A,
|
|
6973
|
-
//# sourceMappingURL=attaform.
|
|
7092
|
+
export { AttaformErrorCode as A, deleteAtPath as B, safeOwnRead as C, DEFAULT_TIMINGS as D, humanize as E, PERSISTENCE_MODULE_KEY as P, injectWizard as a, isUnset as b, useRegister as c, useWizard as d, isPlainRecord as e, safeAssign as f, diffAndApply as g, slimKindOf as h, injectForm as i, applyPatchesForward as j, normalizeNumericOption as k, lazy as l, defaultCoercionRules as m, normalizePersistConfig as n, defaultDisplayState as o, defineCoercion as p, makeDefaultDisplayState as q, useAbstractForm as r, structuralSnapshot as s, getAtPath as t, unset as u, setAtPath as v, resolveStorageKeyBase as w, DEFAULT_PERSISTENCE_DEBOUNCE_MS as x, cleanupOrphanKeys as y, mergeSparseHydration as z };
|
|
7093
|
+
//# sourceMappingURL=attaform.CTheKoTc.mjs.map
|