attaform 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/shared/{attaform.jgzuNZVC.cjs → attaform.BCBxTyMC.cjs} +3 -3
- package/dist/shared/{attaform.jgzuNZVC.cjs.map → attaform.BCBxTyMC.cjs.map} +1 -1
- package/dist/shared/{attaform.CKFbKFb6.mjs → attaform.BqZuwLTK.mjs} +94 -49
- package/dist/shared/attaform.BqZuwLTK.mjs.map +1 -0
- package/dist/shared/{attaform.CIn4bMsD.cjs → attaform.BrrXNmfK.cjs} +3 -3
- package/dist/shared/{attaform.CIn4bMsD.cjs.map → attaform.BrrXNmfK.cjs.map} +1 -1
- package/dist/shared/{attaform.DvA-CJJW.mjs → attaform.D6CwqkPx.mjs} +3 -3
- package/dist/shared/{attaform.DvA-CJJW.mjs.map → attaform.D6CwqkPx.mjs.map} +1 -1
- package/dist/shared/{attaform.Dmb6itxC.cjs → attaform.DHRWn-cu.cjs} +13 -9
- package/dist/shared/attaform.DHRWn-cu.cjs.map +1 -0
- package/dist/shared/{attaform.DL4CQ-oW.cjs → attaform.DLnE5bZa.cjs} +95 -48
- package/dist/shared/attaform.DLnE5bZa.cjs.map +1 -0
- package/dist/shared/{attaform.DEBvCjeH.mjs → attaform.iWo9soNX.mjs} +3 -3
- package/dist/shared/{attaform.DEBvCjeH.mjs.map → attaform.iWo9soNX.mjs.map} +1 -1
- package/dist/shared/{attaform.BWgAFnsj.mjs → attaform.tVkmQh5w.mjs} +13 -9
- package/dist/shared/attaform.tVkmQh5w.mjs.map +1 -0
- package/dist/zod-v3.cjs +2 -2
- package/dist/zod-v3.mjs +2 -2
- package/dist/zod-v4.cjs +2 -2
- package/dist/zod-v4.mjs +2 -2
- package/dist/zod.cjs +4 -4
- package/dist/zod.mjs +4 -4
- package/package.json +2 -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,6 +1,29 @@
|
|
|
1
1
|
import { computed, ref, watchEffect, getCurrentScope, onScopeDispose, shallowReadonly, readonly, reactive, toRaw, watch, markRaw, shallowRef, getCurrentInstance, onServerPrefetch, provide, useId, inject, effectScope, nextTick } from 'vue';
|
|
2
2
|
import { _ as __DEV__, j as canonicalizePath, E as segmentsForPathKey, s as isPathPrefix, b as FORM_ERRORS_PATH_KEY, S as SubmitErrorHandlerError, A as AnonPersistError, k as captureUserCallSite, I as INTERACTIVE_TAG_NAMES, e as ROOT_PATH_KEY, R as ROOT_PATH, h as allowSensitivePersist, F as FORM_ERRORS_PATH, l as coerceToPathKey, u as isSensitivePath, o as createPersistOptInRegistry, d as InvalidUseFormConfigError, q as ensureAttaformInstalled, H as useRegistry, y as kFormContext, z as kFormInstanceId, g as ReservedFormKeyError, n as createIsSensitivePath, x as kAttaformWizardActiveStepResolver, v as kAttaformAncestorWizard } from './attaform.BKozEdTr.mjs';
|
|
3
3
|
|
|
4
|
+
function safeAssign(target, key, value) {
|
|
5
|
+
if (key === "__proto__") {
|
|
6
|
+
Object.defineProperty(target, key, {
|
|
7
|
+
value,
|
|
8
|
+
writable: true,
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true
|
|
11
|
+
});
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
target[key] = value;
|
|
15
|
+
}
|
|
16
|
+
function safeOwnRead(target, key) {
|
|
17
|
+
if (key === "__proto__") {
|
|
18
|
+
const desc = Object.getOwnPropertyDescriptor(target, "__proto__");
|
|
19
|
+
return desc?.value;
|
|
20
|
+
}
|
|
21
|
+
return target[key];
|
|
22
|
+
}
|
|
23
|
+
function safeOwnHas(target, key) {
|
|
24
|
+
return Object.prototype.hasOwnProperty.call(target, key);
|
|
25
|
+
}
|
|
26
|
+
|
|
4
27
|
const NOT_FOUND = Symbol("NOT_FOUND");
|
|
5
28
|
function descendStep(value, segment) {
|
|
6
29
|
if (value === null || value === void 0) return NOT_FOUND;
|
|
@@ -62,8 +85,8 @@ function setAtPathOffset(root, path, value, offset) {
|
|
|
62
85
|
arr[head] = setAtPathOffset(arr[head], path, value, nextOffset);
|
|
63
86
|
return arr;
|
|
64
87
|
}
|
|
65
|
-
const rec = isPlainRecord(root) ?
|
|
66
|
-
rec
|
|
88
|
+
const rec = isPlainRecord(root) ? { ...root } : {};
|
|
89
|
+
safeAssign(rec, head, setAtPathOffset(safeOwnRead(rec, head), path, value, nextOffset));
|
|
67
90
|
return rec;
|
|
68
91
|
}
|
|
69
92
|
function deleteAtPath(root, path) {
|
|
@@ -92,9 +115,9 @@ function deleteAtPathOffset(root, path, offset) {
|
|
|
92
115
|
delete rec2[head];
|
|
93
116
|
return rec2;
|
|
94
117
|
}
|
|
95
|
-
if (!(head
|
|
118
|
+
if (!safeOwnHas(root, head)) return root;
|
|
96
119
|
const rec = { ...root };
|
|
97
|
-
rec
|
|
120
|
+
safeAssign(rec, head, deleteAtPathOffset(safeOwnRead(rec, head), path, nextOffset));
|
|
98
121
|
return rec;
|
|
99
122
|
}
|
|
100
123
|
function resolveArrayShape(schema, scratch) {
|
|
@@ -163,27 +186,27 @@ function mergeStructuralImpl(schema, scratch, consumer, defaultValue) {
|
|
|
163
186
|
return consumer;
|
|
164
187
|
}
|
|
165
188
|
let mutated = false;
|
|
166
|
-
const out =
|
|
189
|
+
const out = { ...consumer };
|
|
167
190
|
for (const key of Object.keys(defaultValue)) {
|
|
168
|
-
if (!(key
|
|
169
|
-
const defAtKey = defaultValue
|
|
191
|
+
if (!safeOwnHas(consumer, key)) {
|
|
192
|
+
const defAtKey = safeOwnRead(defaultValue, key);
|
|
170
193
|
scratch.push(key);
|
|
171
194
|
const filled = mergeStructuralImpl(schema, scratch, void 0, defAtKey);
|
|
172
195
|
scratch.pop();
|
|
173
196
|
if (filled !== void 0) {
|
|
174
|
-
out
|
|
197
|
+
safeAssign(out, key, filled);
|
|
175
198
|
mutated = true;
|
|
176
199
|
}
|
|
177
200
|
}
|
|
178
201
|
}
|
|
179
202
|
for (const key of Object.keys(consumer)) {
|
|
180
|
-
const cVal = consumer
|
|
203
|
+
const cVal = safeOwnRead(consumer, key);
|
|
181
204
|
if (cVal === void 0) continue;
|
|
182
205
|
scratch.push(key);
|
|
183
|
-
const merged = mergeStructuralImpl(schema, scratch, cVal, defaultValue
|
|
206
|
+
const merged = mergeStructuralImpl(schema, scratch, cVal, safeOwnRead(defaultValue, key));
|
|
184
207
|
scratch.pop();
|
|
185
208
|
if (merged !== cVal) {
|
|
186
|
-
out
|
|
209
|
+
safeAssign(out, key, merged);
|
|
187
210
|
mutated = true;
|
|
188
211
|
}
|
|
189
212
|
}
|
|
@@ -377,7 +400,8 @@ function applyChangedKeys(target, source) {
|
|
|
377
400
|
}
|
|
378
401
|
for (const k of changedFirstSegments) {
|
|
379
402
|
if (typeof k === "symbol") continue;
|
|
380
|
-
|
|
403
|
+
const key = String(k);
|
|
404
|
+
safeAssign(t, key, safeOwnRead(s, key));
|
|
381
405
|
}
|
|
382
406
|
}
|
|
383
407
|
return true;
|
|
@@ -427,9 +451,9 @@ function structuralSnapshot(value) {
|
|
|
427
451
|
return out2;
|
|
428
452
|
}
|
|
429
453
|
const src = value;
|
|
430
|
-
const out =
|
|
454
|
+
const out = {};
|
|
431
455
|
for (const k of Object.keys(src)) {
|
|
432
|
-
out
|
|
456
|
+
safeAssign(out, k, structuralSnapshot(safeOwnRead(src, k)));
|
|
433
457
|
}
|
|
434
458
|
return out;
|
|
435
459
|
}
|
|
@@ -1093,7 +1117,7 @@ function errorAwareContainerKeys(state, segments) {
|
|
|
1093
1117
|
}
|
|
1094
1118
|
function materializeErrors(state, containerSegments) {
|
|
1095
1119
|
const liveContainer = getAtPath(state.form.value, containerSegments);
|
|
1096
|
-
const tree = Array.isArray(liveContainer) ? [] :
|
|
1120
|
+
const tree = Array.isArray(liveContainer) ? [] : {};
|
|
1097
1121
|
const collect = (store, applyActivePathFilter) => {
|
|
1098
1122
|
entries: for (const [pathKey, errors] of store) {
|
|
1099
1123
|
if (errors.length === 0) continue;
|
|
@@ -1141,18 +1165,18 @@ function placeAt(tree, path, errors) {
|
|
|
1141
1165
|
const nextSeg = path[i + 1];
|
|
1142
1166
|
const key = typeof seg === "number" ? String(seg) : seg;
|
|
1143
1167
|
const cursorRecord2 = cursor;
|
|
1144
|
-
let child = cursorRecord2
|
|
1168
|
+
let child = safeOwnRead(cursorRecord2, key);
|
|
1145
1169
|
if (child === null || child === void 0 || typeof child !== "object") {
|
|
1146
|
-
child = typeof nextSeg === "number" ? [] :
|
|
1147
|
-
cursorRecord2
|
|
1170
|
+
child = typeof nextSeg === "number" ? [] : {};
|
|
1171
|
+
safeAssign(cursorRecord2, key, child);
|
|
1148
1172
|
}
|
|
1149
1173
|
cursor = child;
|
|
1150
1174
|
}
|
|
1151
1175
|
const lastSeg = path[path.length - 1];
|
|
1152
1176
|
const lastKey = typeof lastSeg === "number" ? String(lastSeg) : lastSeg;
|
|
1153
1177
|
const cursorRecord = cursor;
|
|
1154
|
-
const existing = cursorRecord
|
|
1155
|
-
cursorRecord
|
|
1178
|
+
const existing = safeOwnRead(cursorRecord, lastKey);
|
|
1179
|
+
safeAssign(cursorRecord, lastKey, Array.isArray(existing) ? [...existing, ...errors] : errors);
|
|
1156
1180
|
}
|
|
1157
1181
|
|
|
1158
1182
|
function buildFieldArrayApi(state) {
|
|
@@ -1548,10 +1572,10 @@ function stripUnacknowledgedSensitiveLeaves(form, optedInPaths, isSensitivePath)
|
|
|
1548
1572
|
if (value === null || typeof value !== "object") return value;
|
|
1549
1573
|
if (Array.isArray(value)) return value.map((item, i) => walk([...path, i], item));
|
|
1550
1574
|
if (!isPlainRecord(value)) return value;
|
|
1551
|
-
const out =
|
|
1575
|
+
const out = {};
|
|
1552
1576
|
for (const key of Object.keys(value)) {
|
|
1553
1577
|
const walked = walk([...path, key], value[key]);
|
|
1554
|
-
if (walked !== void 0) out
|
|
1578
|
+
if (walked !== void 0) safeAssign(out, key, walked);
|
|
1555
1579
|
}
|
|
1556
1580
|
return out;
|
|
1557
1581
|
};
|
|
@@ -1583,10 +1607,19 @@ function mergeDeep(target, source, path, schema) {
|
|
|
1583
1607
|
if (sourceDisc !== void 0) {
|
|
1584
1608
|
const variantDefault = du.getVariantDefault(sourceDisc);
|
|
1585
1609
|
if (isPlainRecord(variantDefault)) {
|
|
1586
|
-
const out2 =
|
|
1610
|
+
const out2 = { ...variantDefault };
|
|
1587
1611
|
for (const key of Object.keys(sourceRecord)) {
|
|
1588
|
-
if (!(key
|
|
1589
|
-
|
|
1612
|
+
if (!safeOwnHas(variantDefault, key) && key !== du.discriminatorKey) continue;
|
|
1613
|
+
safeAssign(
|
|
1614
|
+
out2,
|
|
1615
|
+
key,
|
|
1616
|
+
mergeDeep(
|
|
1617
|
+
safeOwnRead(out2, key),
|
|
1618
|
+
safeOwnRead(sourceRecord, key),
|
|
1619
|
+
[...path, key],
|
|
1620
|
+
schema
|
|
1621
|
+
)
|
|
1622
|
+
);
|
|
1590
1623
|
}
|
|
1591
1624
|
return out2;
|
|
1592
1625
|
}
|
|
@@ -1595,9 +1628,18 @@ function mergeDeep(target, source, path, schema) {
|
|
|
1595
1628
|
}
|
|
1596
1629
|
}
|
|
1597
1630
|
const mergeTarget = target;
|
|
1598
|
-
const out = isPlainRecord(mergeTarget) ?
|
|
1631
|
+
const out = isPlainRecord(mergeTarget) ? { ...mergeTarget } : {};
|
|
1599
1632
|
for (const key of Object.keys(source)) {
|
|
1600
|
-
|
|
1633
|
+
safeAssign(
|
|
1634
|
+
out,
|
|
1635
|
+
key,
|
|
1636
|
+
mergeDeep(
|
|
1637
|
+
safeOwnRead(out, key),
|
|
1638
|
+
safeOwnRead(source, key),
|
|
1639
|
+
[...path, key],
|
|
1640
|
+
schema
|
|
1641
|
+
)
|
|
1642
|
+
);
|
|
1601
1643
|
}
|
|
1602
1644
|
return out;
|
|
1603
1645
|
}
|
|
@@ -2381,17 +2423,17 @@ function walk(input, segments, schema, paths) {
|
|
|
2381
2423
|
if (slim !== null && slim !== void 0 && typeof slim === "object" && !Array.isArray(slim) && !(slim instanceof Date) && !(slim instanceof RegExp) && !(slim instanceof Map) && !(slim instanceof Set)) {
|
|
2382
2424
|
for (const k of Object.keys(slim)) allKeys.add(k);
|
|
2383
2425
|
}
|
|
2384
|
-
const out =
|
|
2426
|
+
const out = {};
|
|
2385
2427
|
let mutated = allKeys.size !== inputKeys.length;
|
|
2386
2428
|
for (const key of allKeys) {
|
|
2387
2429
|
const orig = input[key];
|
|
2388
2430
|
if (orig === void 0 && inputKeysSet.has(key)) {
|
|
2389
|
-
out
|
|
2431
|
+
safeAssign(out, key, void 0);
|
|
2390
2432
|
mutated = true;
|
|
2391
2433
|
continue;
|
|
2392
2434
|
}
|
|
2393
2435
|
const walked = walk(orig, [...segments, key], schema, paths);
|
|
2394
|
-
out
|
|
2436
|
+
safeAssign(out, key, walked);
|
|
2395
2437
|
if (walked !== orig) mutated = true;
|
|
2396
2438
|
}
|
|
2397
2439
|
return mutated ? out : input;
|
|
@@ -2410,9 +2452,13 @@ function walkUnspecified(slim, segments, paths) {
|
|
|
2410
2452
|
}
|
|
2411
2453
|
if (Array.isArray(slim)) return slim;
|
|
2412
2454
|
if (slim !== null && typeof slim === "object") {
|
|
2413
|
-
const out =
|
|
2455
|
+
const out = {};
|
|
2414
2456
|
for (const key of Object.keys(slim)) {
|
|
2415
|
-
|
|
2457
|
+
safeAssign(
|
|
2458
|
+
out,
|
|
2459
|
+
key,
|
|
2460
|
+
walkUnspecified(slim[key], [...segments, key], paths)
|
|
2461
|
+
);
|
|
2416
2462
|
}
|
|
2417
2463
|
return out;
|
|
2418
2464
|
}
|
|
@@ -2443,11 +2489,11 @@ function substitute(input, segments, schema, paths) {
|
|
|
2443
2489
|
}
|
|
2444
2490
|
if (typeof input === "object") {
|
|
2445
2491
|
let mutated = false;
|
|
2446
|
-
const out =
|
|
2492
|
+
const out = {};
|
|
2447
2493
|
for (const key of Object.keys(input)) {
|
|
2448
2494
|
const orig = input[key];
|
|
2449
2495
|
const walked = substitute(orig, [...segments, key], schema, paths);
|
|
2450
|
-
out
|
|
2496
|
+
safeAssign(out, key, walked);
|
|
2451
2497
|
if (walked !== orig) mutated = true;
|
|
2452
2498
|
}
|
|
2453
2499
|
return mutated ? out : input;
|
|
@@ -3057,9 +3103,9 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
3057
3103
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3058
3104
|
return EMPTY_FIELD_RECORD;
|
|
3059
3105
|
}
|
|
3060
|
-
const out =
|
|
3106
|
+
const out = {};
|
|
3061
3107
|
for (const key of Object.keys(value)) {
|
|
3062
|
-
out
|
|
3108
|
+
safeAssign(out, key, callTerminal(`${path}.${key}`));
|
|
3063
3109
|
}
|
|
3064
3110
|
return Object.freeze(out);
|
|
3065
3111
|
}
|
|
@@ -3181,14 +3227,14 @@ function walkDuStubs(schema, value, path, warned) {
|
|
|
3181
3227
|
);
|
|
3182
3228
|
}
|
|
3183
3229
|
}
|
|
3184
|
-
const stub =
|
|
3185
|
-
stub
|
|
3230
|
+
const stub = {};
|
|
3231
|
+
safeAssign(stub, du.discriminatorKey, discValue);
|
|
3186
3232
|
return stub;
|
|
3187
3233
|
}
|
|
3188
3234
|
}
|
|
3189
|
-
const out =
|
|
3235
|
+
const out = {};
|
|
3190
3236
|
for (const k of Object.keys(rec)) {
|
|
3191
|
-
out
|
|
3237
|
+
safeAssign(out, k, walkDuStubs(schema, rec[k], [...path, k], warned));
|
|
3192
3238
|
}
|
|
3193
3239
|
return out;
|
|
3194
3240
|
}
|
|
@@ -3271,8 +3317,8 @@ function cloneVariantSnapshot(value) {
|
|
|
3271
3317
|
return out2;
|
|
3272
3318
|
}
|
|
3273
3319
|
const src = raw;
|
|
3274
|
-
const out =
|
|
3275
|
-
for (const k of Object.keys(src)) out
|
|
3320
|
+
const out = {};
|
|
3321
|
+
for (const k of Object.keys(src)) safeAssign(out, k, cloneVariantSnapshot(src[k]));
|
|
3276
3322
|
return out;
|
|
3277
3323
|
}
|
|
3278
3324
|
|
|
@@ -5195,9 +5241,8 @@ function wirePersistence(state, config) {
|
|
|
5195
5241
|
if (isDisposed()) return;
|
|
5196
5242
|
const raw = await adapter.getItem(key);
|
|
5197
5243
|
const existing = readPersistedPayload(raw);
|
|
5198
|
-
const baseForm = existing?.data.form ?? /* @__PURE__ */ Object.create(null);
|
|
5199
5244
|
const value = getAtPath(toRaw(state.form.value), path);
|
|
5200
|
-
const nextForm = setAtPath(
|
|
5245
|
+
const nextForm = setAtPath(existing?.data.form ?? {}, path, value);
|
|
5201
5246
|
const { key: pathKey } = canonicalizePath(path);
|
|
5202
5247
|
const transientSet = new Set(
|
|
5203
5248
|
(existing?.data.blankPaths ?? []).filter(
|
|
@@ -5389,15 +5434,15 @@ function stripSensitivePathsDeep(value, pathSoFar, isSensitivePath) {
|
|
|
5389
5434
|
}
|
|
5390
5435
|
const proto = Object.getPrototypeOf(value);
|
|
5391
5436
|
if (proto !== Object.prototype && proto !== null) return value;
|
|
5392
|
-
const out =
|
|
5437
|
+
const out = {};
|
|
5393
5438
|
const src = value;
|
|
5394
5439
|
for (const key of Object.keys(src)) {
|
|
5395
5440
|
const childPath = [...pathSoFar, key];
|
|
5396
5441
|
if (isSensitivePath(childPath)) {
|
|
5397
|
-
out
|
|
5442
|
+
safeAssign(out, key, void 0);
|
|
5398
5443
|
continue;
|
|
5399
5444
|
}
|
|
5400
|
-
out
|
|
5445
|
+
safeAssign(out, key, stripSensitivePathsDeep(src[key], childPath, isSensitivePath));
|
|
5401
5446
|
}
|
|
5402
5447
|
return out;
|
|
5403
5448
|
}
|
|
@@ -7157,5 +7202,5 @@ function warnIfAmbientWizardProviderHadDuplicates() {
|
|
|
7157
7202
|
}
|
|
7158
7203
|
}
|
|
7159
7204
|
|
|
7160
|
-
export { AttaformErrorCode as A, defaultDisplayState as a, defineCoercion as b, injectWizard as c, defaultCoercionRules as d, isPlainRecord as e, isUnset as f, getAtPath as g, humanize as h, injectForm as i,
|
|
7161
|
-
//# sourceMappingURL=attaform.
|
|
7205
|
+
export { AttaformErrorCode as A, defaultDisplayState as a, defineCoercion as b, injectWizard as c, defaultCoercionRules as d, isPlainRecord as e, isUnset as f, getAtPath as g, humanize as h, injectForm as i, safeOwnRead as j, setAtPath as k, lazy as l, slimKindOf as m, normalizeNumericOption as n, useAbstractForm as o, useWizard as p, safeAssign as s, unset as u };
|
|
7206
|
+
//# sourceMappingURL=attaform.BqZuwLTK.mjs.map
|