attaform 0.30.1 → 0.31.0
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/abstract.d.mts +5 -5
- package/dist/abstract.mjs +3 -3
- package/dist/dev/abstract.mjs +3 -3
- package/dist/dev/chunks/devtools.mjs +2 -2
- package/dist/dev/directive.mjs +1 -1
- package/dist/dev/history.mjs +1 -1
- package/dist/dev/index.mjs +4 -4
- package/dist/dev/runtime/plugins/attaform.mjs +1 -1
- package/dist/dev/shared/{attaform-dev.Chm4D6SJ.mjs → attaform-dev.B1q-x9R9.mjs} +2 -2
- package/dist/dev/shared/{attaform-dev.BUIFcTYf.mjs → attaform-dev.Caibt7sb.mjs} +11 -10
- package/dist/dev/shared/{attaform-dev.CT7MDjPy.mjs → attaform-dev.CtyqGia7.mjs} +152 -227
- package/dist/dev/shared/{attaform-dev.BJK1kqHY.mjs → attaform-dev.DJ3nsWw6.mjs} +74 -110
- package/dist/dev/shared/{attaform-dev.DuEE4GU1.mjs → attaform-dev.DlaT4xGd.mjs} +3 -3
- package/dist/dev/shared/{attaform-dev.BMQ3GcgD.mjs → attaform-dev.k5X47GMD.mjs} +474 -336
- package/dist/dev/shared/{attaform-dev.DxHdkkPG.mjs → attaform-dev.y9x9Vp9F.mjs} +206 -127
- package/dist/dev/zod-v3.mjs +5 -5
- package/dist/dev/zod-v4.mjs +5 -5
- package/dist/dev/zod.mjs +4 -4
- package/dist/directive.d.mts +2 -2
- package/dist/directive.mjs +1 -1
- package/dist/history.d.mts +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +4 -4
- package/dist/runtime/components/AttaformDevtoolsPanel.vue +3 -3
- package/dist/runtime/plugins/attaform.mjs +1 -1
- package/dist/shared/{attaform.CO918TdU.mjs → attaform.BWUn8Kjy.mjs} +74 -110
- package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.C4shmwyJ.mjs} +2 -2
- package/dist/shared/{attaform.2FslhB9R.d.mts → attaform.CRVe8s82.d.mts} +1 -1
- package/dist/shared/{attaform.L0kUn3vL.d.mts → attaform.D9RqPgGu.d.mts} +1 -1
- package/dist/shared/{attaform.BcQwgWaq.d.mts → attaform.DAo0QBmS.d.mts} +28 -8
- package/dist/shared/{attaform.ZYn2ahzJ.mjs → attaform.DBCbxlyk.mjs} +59 -1
- package/dist/shared/{attaform.DRsANMok.mjs → attaform.DL2nl_QR.mjs} +11 -10
- package/dist/shared/{attaform.BIWicztt.mjs → attaform.DNPJPOO7.mjs} +204 -125
- package/dist/shared/{attaform.Br8EBn5B.d.mts → attaform.DZnrDrNb.d.mts} +136 -32
- package/dist/shared/{attaform.D_f1WgYf.mjs → attaform.DxKQsqFZ.mjs} +456 -318
- package/dist/shared/{attaform.B2iebkPA.mjs → attaform.L011tHgJ.mjs} +3 -3
- package/dist/shared/{attaform.D_pt1gOj.mjs → attaform.LUPC-2Qg.mjs} +152 -227
- package/dist/transforms.mjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/zod-v3.d.mts +4 -4
- package/dist/zod-v3.mjs +5 -5
- package/dist/zod-v4.d.mts +13 -11
- package/dist/zod-v4.mjs +5 -5
- package/dist/zod.d.mts +4 -4
- package/dist/zod.mjs +4 -4
- package/package.json +1 -1
- package/skills/attaform/SKILL.md +1 -1
- package/skills/attaform/references/custom-components.md +4 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { computed, readonly, toRaw, ref, watchEffect, getCurrentScope, onScopeDispose, shallowReadonly, nextTick, warn, reactive, shallowReactive, shallowRef, toValue, watch, triggerRef, getCurrentInstance, onServerPrefetch, provide, useId, inject, onBeforeMount, onBeforeUpdate, onMounted
|
|
1
|
+
import { computed, readonly, toRaw, ref, watchEffect, getCurrentScope, onScopeDispose, shallowReadonly, nextTick, warn, reactive, shallowReactive, shallowRef, toValue, watch, triggerRef, getCurrentInstance, onServerPrefetch, provide, useId, inject, effectScope, onBeforeMount, onBeforeUpdate, onMounted } from 'vue';
|
|
2
2
|
import { A as ANONYMOUS_FORM_KEY_PREFIX, i as isShadowedKey, d as safeOwnHas, a as safeOwnRead, e as consumerHas, f as spreadConsumerRecord, g as copyConsumerArray, r as readConsumerIndex, b as safeAssign, h as consumerKeys, j as readConsumerProp, k as diffAndApply, p as pickDefined, s as structuralSnapshot, n as normalizeNumericOption, l as DEFAULT_FIELD_VALIDATION_DEBOUNCE_MS, m as consumerSymbolKeys, o as applyChangedKeys, R as RESERVED_KEY_PREFIX, q as DEFAULT_MAX_RECURSION_DEPTH, c as callConsumerFn, t as reportConsumerThrow, u as ANONYMOUS_WIZARD_KEY_PREFIX } from './attaform-dev.CZz4GYZ6.mjs';
|
|
3
|
-
import { e as ensureAttaformInstalled, u as useRegistry, d as kFormContext, f as kFormInstanceId, b as kAttaformWizardActiveStepResolver, i as kAttaformAncestorWizard } from './attaform-dev.
|
|
4
|
-
import { R as REGISTER_OWNER_MARKER, d as armDomBinding,
|
|
3
|
+
import { e as ensureAttaformInstalled, u as useRegistry, d as kFormContext, f as kFormInstanceId, b as kAttaformWizardActiveStepResolver, i as kAttaformAncestorWizard } from './attaform-dev.B1q-x9R9.mjs';
|
|
4
|
+
import { R as REGISTER_OWNER_MARKER, V as V_REGISTER_MARKER, d as armDomBinding, r as recordInheritedModifiers, w as withInheritedModifiers } from './attaform-dev.k5X47GMD.mjs';
|
|
5
5
|
import { i as isPathPrefix, e as canonicalizePath, k as keyForSegments, m as mapSegmentKeys, b as ROOT_PATH_KEY, s as segmentsForPathKey, S as SubmitErrorHandlerError, t as toError, j as groupErrorsByKey, n as normalizeErrorInput, h as SET_MEMBER_SEGMENT, R as ROOT_PATH, l as normalizeErrorInputs, a as InvalidUseFormConfigError, d as ReservedFormKeyError } from './attaform-dev.zlvDr0WB.mjs';
|
|
6
6
|
|
|
7
7
|
const AttaformErrorCode = {
|
|
@@ -531,7 +531,7 @@ function buildLeafFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
531
531
|
const value = state.getValueAtPath(segments);
|
|
532
532
|
const original = state.originals.get(key)?.value;
|
|
533
533
|
const pristine = state.isPristineAtPathByKey(key, segments);
|
|
534
|
-
const cell = state.errorCells.get(key);
|
|
534
|
+
const cell = state.errorCells().get(key);
|
|
535
535
|
const schemaForKey = cell !== void 0 && cell.schema.length > 0 ? cell.schema : void 0;
|
|
536
536
|
const blankForKey = state.blankPaths.has(key) && state.schema.isRequiredAtPath(segments) ? [makeBlankRequiredError(segments)] : void 0;
|
|
537
537
|
const userForKey = cell !== void 0 && cell.user.length > 0 ? cell.user : void 0;
|
|
@@ -820,7 +820,7 @@ function aggregateErrorsAt(state, prefix, prefixKey) {
|
|
|
820
820
|
const candidates = state.errorWindowAt(prefix, prefixKey);
|
|
821
821
|
if (candidates.length === 0) return [];
|
|
822
822
|
const formValue = state.form.value;
|
|
823
|
-
const cells = state.errorCells;
|
|
823
|
+
const cells = state.errorCells();
|
|
824
824
|
const buckets = /* @__PURE__ */ new Map();
|
|
825
825
|
for (const { key, segments } of candidates) {
|
|
826
826
|
if (!isPathPrefix(prefix, segments)) continue;
|
|
@@ -1102,7 +1102,7 @@ function buildErrorsSurface(state, sweep) {
|
|
|
1102
1102
|
});
|
|
1103
1103
|
}
|
|
1104
1104
|
function collectErrorsAt(state, key, segments, active, into) {
|
|
1105
|
-
const cell = state.errorCells.get(key);
|
|
1105
|
+
const cell = state.errorCells().get(key);
|
|
1106
1106
|
if (active) {
|
|
1107
1107
|
if (cell !== void 0) into.push(...cell.schema);
|
|
1108
1108
|
if (state.blankPaths.has(key) && state.schema.isRequiredAtPath(segments)) {
|
|
@@ -1689,7 +1689,7 @@ function createArrayBookkeeping(deps) {
|
|
|
1689
1689
|
...record,
|
|
1690
1690
|
path: segments
|
|
1691
1691
|
}));
|
|
1692
|
-
migrateMapSubtree(errorCells, arrayPath, remap, (cell, segments) => ({
|
|
1692
|
+
migrateMapSubtree(errorCells(), arrayPath, remap, (cell, segments) => ({
|
|
1693
1693
|
schema: NO_ERRORS,
|
|
1694
1694
|
user: cell.user.map((error) => ({ ...error, path: [...segments] }))
|
|
1695
1695
|
}));
|
|
@@ -1739,7 +1739,7 @@ function createArrayBookkeeping(deps) {
|
|
|
1739
1739
|
migrateElementState(arrayPath, remap);
|
|
1740
1740
|
for (const freshIndex of remap.fresh) seedFreshElement(arrayPath, freshIndex);
|
|
1741
1741
|
const changed = changedIndices(remap);
|
|
1742
|
-
evictSchemaVerdictsAtIndices(errorCells, arrayPath, changed);
|
|
1742
|
+
evictSchemaVerdictsAtIndices(errorCells(), arrayPath, changed);
|
|
1743
1743
|
abortValidationAtVacatedIndices(arrayPath, remap);
|
|
1744
1744
|
variantMemory.dropAtIndices(arrayPath, changed);
|
|
1745
1745
|
arrayIdentity.applyOp(arrayPath, remap);
|
|
@@ -2060,7 +2060,7 @@ function adapterThrowMessage(err) {
|
|
|
2060
2060
|
return "Adapter validateAtPath threw a non-Error value";
|
|
2061
2061
|
}
|
|
2062
2062
|
function hasUserErrorEntries(state) {
|
|
2063
|
-
for (const cell of state.errorCells.values()) {
|
|
2063
|
+
for (const cell of state.errorCells().values()) {
|
|
2064
2064
|
if (cell.user.length > 0) return true;
|
|
2065
2065
|
}
|
|
2066
2066
|
return false;
|
|
@@ -2171,9 +2171,9 @@ function reportRejection(store, path, kind, accepted) {
|
|
|
2171
2171
|
if (kind === "string" && accepted.has("number")) {
|
|
2172
2172
|
console.warn(
|
|
2173
2173
|
`[attaform] Cannot write a string to '${dotted}': the schema expects ${expected}.
|
|
2174
|
-
Fix:
|
|
2175
|
-
<input type="number" v-register="register('${dotted}')" />
|
|
2174
|
+
Fix: use the .number modifier on v-register, OR add type="number" to a native input:
|
|
2176
2175
|
<input v-register.number="register('${dotted}')" />
|
|
2176
|
+
<input type="number" v-register="register('${dotted}')" />
|
|
2177
2177
|
The write was a no-op.`
|
|
2178
2178
|
);
|
|
2179
2179
|
return;
|
|
@@ -2329,6 +2329,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2329
2329
|
const isRequired = state.schema.isRequiredAtPath(segments);
|
|
2330
2330
|
const ariaDisplayState = getDisplayStateAt !== void 0 ? computed(() => getDisplayStateAt(segments)) : void 0;
|
|
2331
2331
|
const markBlank = () => state.setValueAtPath(segments, slimDefault, withInstanceMeta({ blank: true }));
|
|
2332
|
+
const commitFromHost = (value) => value === "" && !acceptsString || value === null && !slimTypes.has("null") || value === void 0 && !acceptsUndefined ? markBlank() : state.setValueAtPath(segments, value, withInstanceMeta(void 0));
|
|
2332
2333
|
const internalRv = {
|
|
2333
2334
|
innerRef,
|
|
2334
2335
|
displayValue,
|
|
@@ -2345,7 +2346,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2345
2346
|
},
|
|
2346
2347
|
ensureDomBinding: (factory) => {
|
|
2347
2348
|
var _a;
|
|
2348
|
-
(_a = state.domBinding).value ?? (_a.value = factory(state));
|
|
2349
|
+
return (_a = state.domBinding).value ?? (_a.value = factory(state));
|
|
2349
2350
|
},
|
|
2350
2351
|
registerElement: (element) => {
|
|
2351
2352
|
const dom = state.domBinding.value;
|
|
@@ -2365,10 +2366,10 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2365
2366
|
setValueWithInternalPath: (value, meta) => {
|
|
2366
2367
|
return state.setValueAtPath(segments, value, withInstanceMeta(meta));
|
|
2367
2368
|
},
|
|
2368
|
-
|
|
2369
|
+
commitFromHost,
|
|
2370
|
+
setValueFromHost: (value, modifiers) => {
|
|
2369
2371
|
state.markInteracted(segments);
|
|
2370
|
-
const
|
|
2371
|
-
const accepted = isBlankSignal ? markBlank() : state.setValueAtPath(segments, value, withInstanceMeta(void 0));
|
|
2372
|
+
const accepted = state.domBinding.value?.hostChannel.write(internalRv, value, modifiers) ?? commitFromHost(value);
|
|
2372
2373
|
{
|
|
2373
2374
|
const dedupeKey = `${formInstanceId}:${pathKey}`;
|
|
2374
2375
|
const isWired = () => (state.domBinding.value?.elements.get(pathKey)?.elements.size ?? 0) > 0 || state.getFieldRecord(segments)?.connected === true;
|
|
@@ -2384,6 +2385,7 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2384
2385
|
}
|
|
2385
2386
|
return accepted;
|
|
2386
2387
|
},
|
|
2388
|
+
setValueFromHostInput: (payload, modifiers) => state.domBinding.value?.hostChannel.writeInput(internalRv, payload, modifiers) ?? false,
|
|
2387
2389
|
// Called by the `vRegisterHintTransform` compile-time transform's wrapping
|
|
2388
2390
|
// IIFE on every server-side render of `<element v-register="…">`.
|
|
2389
2391
|
// Without it, every SSR'd FieldState serialises `connected: false`
|
|
@@ -2457,25 +2459,24 @@ function isUnset(value) {
|
|
|
2457
2459
|
return value === unset;
|
|
2458
2460
|
}
|
|
2459
2461
|
|
|
2460
|
-
function walkUnsetSentinels(values, schema) {
|
|
2462
|
+
function walkUnsetSentinels(values, schema, rootDefault) {
|
|
2461
2463
|
const paths = [];
|
|
2462
2464
|
if (values === void 0) {
|
|
2463
|
-
|
|
2464
|
-
walkUnspecified(rootSlim, [], paths);
|
|
2465
|
+
walkUnspecified(rootDefault, [], paths);
|
|
2465
2466
|
return { cleanedValues: void 0, paths };
|
|
2466
2467
|
}
|
|
2467
|
-
const cleaned = walkCore(values, [], schema, paths,
|
|
2468
|
+
const cleaned = walkCore(values, [], schema, paths, { rootDefault });
|
|
2468
2469
|
return { cleanedValues: cleaned, paths };
|
|
2469
2470
|
}
|
|
2470
2471
|
function isRecursable(value) {
|
|
2471
2472
|
return Array.isArray(value) || isPlainRecord(value);
|
|
2472
2473
|
}
|
|
2473
|
-
function walkCore(input, segments, schema, paths,
|
|
2474
|
+
function walkCore(input, segments, schema, paths, synthesis) {
|
|
2474
2475
|
if (isUnset(input)) {
|
|
2475
2476
|
return expandUnsetAt(segments, schema, paths);
|
|
2476
2477
|
}
|
|
2477
2478
|
if (input === void 0) {
|
|
2478
|
-
if (
|
|
2479
|
+
if (synthesis !== null) {
|
|
2479
2480
|
const slim = schema.getDefaultAtPath(segments);
|
|
2480
2481
|
return walkUnspecified(slim, segments, paths);
|
|
2481
2482
|
}
|
|
@@ -2488,7 +2489,7 @@ function walkCore(input, segments, schema, paths, synthesizeSchemaKeys) {
|
|
|
2488
2489
|
let mutated = false;
|
|
2489
2490
|
for (let i = 0; i < input.length; i++) {
|
|
2490
2491
|
const original = readConsumerIndex(input, i);
|
|
2491
|
-
const walked = walkCore(original, [...segments, i], schema, paths,
|
|
2492
|
+
const walked = walkCore(original, [...segments, i], schema, paths, synthesis);
|
|
2492
2493
|
out[i] = walked;
|
|
2493
2494
|
if (walked !== original) mutated = true;
|
|
2494
2495
|
}
|
|
@@ -2500,10 +2501,10 @@ function walkCore(input, segments, schema, paths, synthesizeSchemaKeys) {
|
|
|
2500
2501
|
let keys = inputKeys;
|
|
2501
2502
|
let mutated = false;
|
|
2502
2503
|
let inputKeysSet = null;
|
|
2503
|
-
if (
|
|
2504
|
+
if (synthesis !== null) {
|
|
2504
2505
|
inputKeysSet = new Set(inputKeys);
|
|
2505
2506
|
const allKeys = new Set(inputKeys);
|
|
2506
|
-
const slim = schema.getDefaultAtPath(segments);
|
|
2507
|
+
const slim = segments.length === 0 ? synthesis.rootDefault : schema.getDefaultAtPath(segments);
|
|
2507
2508
|
if (isPlainRecord(slim)) {
|
|
2508
2509
|
for (const k of Object.keys(slim)) allKeys.add(k);
|
|
2509
2510
|
}
|
|
@@ -2513,12 +2514,12 @@ function walkCore(input, segments, schema, paths, synthesizeSchemaKeys) {
|
|
|
2513
2514
|
const out = {};
|
|
2514
2515
|
for (const key of keys) {
|
|
2515
2516
|
const orig = readConsumerProp(obj, key);
|
|
2516
|
-
if (
|
|
2517
|
+
if (synthesis !== null && orig === void 0 && inputKeysSet?.has(key) === true) {
|
|
2517
2518
|
safeAssign(out, key, void 0);
|
|
2518
2519
|
mutated = true;
|
|
2519
2520
|
continue;
|
|
2520
2521
|
}
|
|
2521
|
-
const walked = walkCore(orig, [...segments, key], schema, paths,
|
|
2522
|
+
const walked = walkCore(orig, [...segments, key], schema, paths, synthesis);
|
|
2522
2523
|
safeAssign(out, key, walked);
|
|
2523
2524
|
if (walked !== orig) mutated = true;
|
|
2524
2525
|
}
|
|
@@ -2542,7 +2543,7 @@ function walkUnspecified(slim, segments, paths) {
|
|
|
2542
2543
|
}
|
|
2543
2544
|
function substituteUnsetSentinels(value, prefix, schema) {
|
|
2544
2545
|
const paths = [];
|
|
2545
|
-
const cleaned = walkCore(value, [...prefix], schema, paths,
|
|
2546
|
+
const cleaned = walkCore(value, [...prefix], schema, paths, null);
|
|
2546
2547
|
return { cleanedValues: cleaned, paths };
|
|
2547
2548
|
}
|
|
2548
2549
|
function isPrimitiveOrEmpty(value) {
|
|
@@ -2707,7 +2708,18 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2707
2708
|
void state.submitted.value;
|
|
2708
2709
|
return metaBase;
|
|
2709
2710
|
};
|
|
2710
|
-
const
|
|
2711
|
+
const releases = [];
|
|
2712
|
+
const lease = (release) => {
|
|
2713
|
+
releases.push(release);
|
|
2714
|
+
return release;
|
|
2715
|
+
};
|
|
2716
|
+
onScopeDispose(() => {
|
|
2717
|
+
for (const release of releases) release();
|
|
2718
|
+
}, true);
|
|
2719
|
+
const pathSweep = {
|
|
2720
|
+
track: state.pathSweep.track,
|
|
2721
|
+
onEvict: (evict) => lease(state.pathSweep.onEvict(evict))
|
|
2722
|
+
};
|
|
2711
2723
|
const getRootFieldStateAt = buildFieldStateAccessor(
|
|
2712
2724
|
state,
|
|
2713
2725
|
formInstanceId,
|
|
@@ -2765,7 +2777,8 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2765
2777
|
const next = typeof pathOrValue === "function" ? pathOrValue(structuralSnapshot(state.form.value)) : pathOrValue;
|
|
2766
2778
|
const walked2 = walkUnsetSentinels(
|
|
2767
2779
|
next,
|
|
2768
|
-
state.schema
|
|
2780
|
+
state.schema,
|
|
2781
|
+
state.schema.getDefaultAtPath([])
|
|
2769
2782
|
);
|
|
2770
2783
|
const ok2 = state.setValueAtPath([], walked2.cleanedValues, writeMeta());
|
|
2771
2784
|
if (!ok2) return false;
|
|
@@ -2830,7 +2843,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2830
2843
|
const errorsProxy = buildErrorsSurface(state, pathSweep);
|
|
2831
2844
|
function flattenUserErrors() {
|
|
2832
2845
|
const all = [];
|
|
2833
|
-
for (const cell of state.errorCells.values()) all.push(...cell.user);
|
|
2846
|
+
for (const cell of state.errorCells().values()) all.push(...cell.user);
|
|
2834
2847
|
return all;
|
|
2835
2848
|
}
|
|
2836
2849
|
function setErrors(arg1, arg2) {
|
|
@@ -2838,7 +2851,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2838
2851
|
if (isScoped) {
|
|
2839
2852
|
const { segments, key } = canonicalizePath(arg1);
|
|
2840
2853
|
const input2 = arg2;
|
|
2841
|
-
const resolved2 = typeof input2 === "function" ? input2([...state.errorCells.get(key)?.user ?? []]) : input2;
|
|
2854
|
+
const resolved2 = typeof input2 === "function" ? input2([...state.errorCells().get(key)?.user ?? []]) : input2;
|
|
2842
2855
|
state.setUserErrorsForPath(
|
|
2843
2856
|
segments,
|
|
2844
2857
|
normalizeErrorInputs(resolved2, segments, AttaformErrorCode.UserError)
|
|
@@ -2866,7 +2879,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2866
2879
|
const departAttempts = computed(() => state.departAttempts.value);
|
|
2867
2880
|
const validating = computed(() => state.activeValidations.value > 0);
|
|
2868
2881
|
const valid = computed(
|
|
2869
|
-
() => state.firstValidationDone.value && state.errorCells.size === 0 && state.derivedBlankErrors.value.size === 0 && !validating.value
|
|
2882
|
+
() => state.firstValidationDone.value && state.errorCells().size === 0 && state.derivedBlankErrors.value.size === 0 && !validating.value
|
|
2870
2883
|
);
|
|
2871
2884
|
const history = options.history;
|
|
2872
2885
|
const formHistory = history === void 0 ? inertHistory() : readonly(
|
|
@@ -2982,7 +2995,10 @@ function buildFormApi(state, formInstanceId, options = {}) {
|
|
|
2982
2995
|
};
|
|
2983
2996
|
return Object.freeze(view);
|
|
2984
2997
|
});
|
|
2985
|
-
const valuesProxy = buildValuesSurface(
|
|
2998
|
+
const valuesProxy = buildValuesSurface(
|
|
2999
|
+
state.form,
|
|
3000
|
+
(listener) => lease(state.onFormChange(listener))
|
|
3001
|
+
);
|
|
2986
3002
|
const fieldStateProxy = buildFieldsSurface(state, getRootFieldStateAt, pathSweep);
|
|
2987
3003
|
const needsLazyGate = state.defaultValuesFactory.value !== void 0 || state.hasSsrPrefetch;
|
|
2988
3004
|
function gated(fn) {
|
|
@@ -3130,7 +3146,7 @@ function shortenSourceFrame(frame) {
|
|
|
3130
3146
|
const SWEEP_SLICE = 8;
|
|
3131
3147
|
function createDynamicPathSweep(deps) {
|
|
3132
3148
|
const dynamicKeys = /* @__PURE__ */ new Set();
|
|
3133
|
-
const evictors =
|
|
3149
|
+
const evictors = /* @__PURE__ */ new Set();
|
|
3134
3150
|
const isDynamicPath = (segments) => {
|
|
3135
3151
|
for (let i = 0; i < segments.length; i++) {
|
|
3136
3152
|
if (typeof segments[i] === "number") return true;
|
|
@@ -3161,7 +3177,10 @@ function createDynamicPathSweep(deps) {
|
|
|
3161
3177
|
if (isDynamicPath(segments)) dynamicKeys.add(key);
|
|
3162
3178
|
},
|
|
3163
3179
|
onEvict(evict) {
|
|
3164
|
-
evictors.
|
|
3180
|
+
evictors.add(evict);
|
|
3181
|
+
return () => {
|
|
3182
|
+
evictors.delete(evict);
|
|
3183
|
+
};
|
|
3165
3184
|
}
|
|
3166
3185
|
};
|
|
3167
3186
|
}
|
|
@@ -3365,7 +3384,7 @@ function mergeObjectKeys(target, source, path, schema) {
|
|
|
3365
3384
|
async function runFactoryAndApply(st, factory) {
|
|
3366
3385
|
try {
|
|
3367
3386
|
const value = await factory();
|
|
3368
|
-
walkAuthoredFromConstraints(value, [], st.authoredPaths);
|
|
3387
|
+
if (st.hasPreprocessOrCoerce) walkAuthoredFromConstraints(value, [], st.authoredPaths);
|
|
3369
3388
|
const full = mergeSparseHydration(
|
|
3370
3389
|
toRaw(st.form.value),
|
|
3371
3390
|
value,
|
|
@@ -3389,7 +3408,7 @@ async function runFactoryAndApply(st, factory) {
|
|
|
3389
3408
|
}
|
|
3390
3409
|
}
|
|
3391
3410
|
function clearHydrationFailedEntry(st) {
|
|
3392
|
-
const existing = st.errorCells.get(ROOT_PATH_KEY)?.schema;
|
|
3411
|
+
const existing = st.errorCells().get(ROOT_PATH_KEY)?.schema;
|
|
3393
3412
|
if (existing === void 0 || existing.length === 0) return;
|
|
3394
3413
|
const filtered = existing.filter((e) => e.code !== AttaformErrorCode.HydrationFailed);
|
|
3395
3414
|
if (filtered.length !== existing.length) {
|
|
@@ -3403,7 +3422,7 @@ function appendHydrationFailedEntry(st, error) {
|
|
|
3403
3422
|
path: [...ROOT_PATH],
|
|
3404
3423
|
code: AttaformErrorCode.HydrationFailed
|
|
3405
3424
|
};
|
|
3406
|
-
const existing = st.errorCells.get(ROOT_PATH_KEY)?.schema ?? [];
|
|
3425
|
+
const existing = st.errorCells().get(ROOT_PATH_KEY)?.schema ?? [];
|
|
3407
3426
|
st.setSchemaErrorsForPath([...ROOT_PATH], [...existing, entry]);
|
|
3408
3427
|
return entry;
|
|
3409
3428
|
}
|
|
@@ -3537,23 +3556,24 @@ function walkAuthoredFromSchemaDiff(withDefaults, withoutDefaults, prefix, out)
|
|
|
3537
3556
|
out.add(canonicalizePath(prefix).key);
|
|
3538
3557
|
}
|
|
3539
3558
|
}
|
|
3540
|
-
function
|
|
3541
|
-
|
|
3559
|
+
function computeBaseline(schema, source, schemaDefaults) {
|
|
3560
|
+
if (source === void 0) return schemaDefaults;
|
|
3542
3561
|
return schema.getDefaultValues({
|
|
3543
3562
|
useDefaultSchemaValues: true,
|
|
3544
|
-
constraints:
|
|
3563
|
+
constraints: mergeStructural(schema, [], source, schemaDefaults)
|
|
3545
3564
|
});
|
|
3546
3565
|
}
|
|
3547
3566
|
function initialFirstValidationGate(schema) {
|
|
3548
3567
|
return schema.needsAsyncValidation?.() !== true;
|
|
3549
3568
|
}
|
|
3550
|
-
function seedOriginalsFromBaseline(st, baseline
|
|
3569
|
+
function seedOriginalsFromBaseline(st, baseline) {
|
|
3551
3570
|
st.originals.clear();
|
|
3552
3571
|
diffAndApply({}, baseline, [], (patch) => {
|
|
3553
3572
|
if (patch.kind !== "added") return;
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3573
|
+
st.originals.set(canonicalizePath(patch.path).key, {
|
|
3574
|
+
segments: patch.path,
|
|
3575
|
+
value: patch.newValue
|
|
3576
|
+
});
|
|
3557
3577
|
});
|
|
3558
3578
|
}
|
|
3559
3579
|
function queueInitialAsyncValidation(st) {
|
|
@@ -3567,6 +3587,7 @@ function queueInitialAsyncValidation(st) {
|
|
|
3567
3587
|
}
|
|
3568
3588
|
}
|
|
3569
3589
|
function rebuildAuthoredPaths(st, constraints, schemaWithDefaultsData) {
|
|
3590
|
+
if (!st.hasPreprocessOrCoerce) return;
|
|
3570
3591
|
st.authoredPaths.clear();
|
|
3571
3592
|
if (constraints !== void 0) {
|
|
3572
3593
|
walkAuthoredFromConstraints(constraints, [], st.authoredPaths);
|
|
@@ -3600,6 +3621,7 @@ function ensurePathOrdinal(st, key) {
|
|
|
3600
3621
|
return ordinal;
|
|
3601
3622
|
}
|
|
3602
3623
|
function pathHasAsyncValidationByKey(st, key, segments) {
|
|
3624
|
+
if (st.schema.needsAsyncValidation?.() === false) return false;
|
|
3603
3625
|
const cached = st.pathAsyncCache.get(key);
|
|
3604
3626
|
if (cached !== void 0) return cached;
|
|
3605
3627
|
const candidates = st.schema.getSchemasAtPath(segments);
|
|
@@ -3934,16 +3956,19 @@ function setValueAtPath(st, path, value, meta) {
|
|
|
3934
3956
|
}
|
|
3935
3957
|
}
|
|
3936
3958
|
}
|
|
3937
|
-
|
|
3938
|
-
if (
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3959
|
+
let newlyAuthored = false;
|
|
3960
|
+
if (st.hasPreprocessOrCoerce) {
|
|
3961
|
+
const wasAuthoredBefore = st.authoredPaths.has(pathKey);
|
|
3962
|
+
if (arrayOpRemap !== null && Array.isArray(value)) {
|
|
3963
|
+
if (path.length > 0) st.authoredPaths.add(pathKey);
|
|
3964
|
+
for (const idx of arrayOpRemap.fresh) {
|
|
3965
|
+
walkAuthoredFromConstraints(value[idx], [...path, idx], st.authoredPaths);
|
|
3966
|
+
}
|
|
3967
|
+
} else {
|
|
3968
|
+
walkAuthoredFromConstraints(value, path, st.authoredPaths);
|
|
3942
3969
|
}
|
|
3943
|
-
|
|
3944
|
-
walkAuthoredFromConstraints(value, path, st.authoredPaths);
|
|
3970
|
+
newlyAuthored = !wasAuthoredBefore && st.authoredPaths.has(pathKey);
|
|
3945
3971
|
}
|
|
3946
|
-
const newlyAuthored = !wasAuthoredBefore && st.authoredPaths.has(pathKey);
|
|
3947
3972
|
let completedValue;
|
|
3948
3973
|
if (arrayOpRemap !== null && Array.isArray(value)) {
|
|
3949
3974
|
for (const idx of arrayOpRemap.fresh) {
|
|
@@ -4200,22 +4225,38 @@ function getValueAtPath(st, path) {
|
|
|
4200
4225
|
return getAtPath(st.form.value, path);
|
|
4201
4226
|
}
|
|
4202
4227
|
const ERROR_SOURCES = ["schema", "user"];
|
|
4228
|
+
function createErrorCells(schema, pristine) {
|
|
4229
|
+
const raw = /* @__PURE__ */ new Map();
|
|
4230
|
+
const cells = shallowReactive(raw);
|
|
4231
|
+
return (seed) => {
|
|
4232
|
+
const data = pristine;
|
|
4233
|
+
if (data !== void 0) {
|
|
4234
|
+
pristine = void 0;
|
|
4235
|
+
if (seed) {
|
|
4236
|
+
for (const [key, list] of groupErrorsByKey(schema.validateSync(data))) {
|
|
4237
|
+
raw.set(key, { schema: list, user: NO_ERRORS });
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4241
|
+
return cells;
|
|
4242
|
+
};
|
|
4243
|
+
}
|
|
4203
4244
|
function setErrorChannelForKey(st, key, src, entries) {
|
|
4204
|
-
const current = st.errorCells.get(key);
|
|
4245
|
+
const current = st.errorCells().get(key);
|
|
4205
4246
|
const schema = src === "schema" ? entries : current?.schema ?? NO_ERRORS;
|
|
4206
4247
|
const user = src === "user" ? entries : current?.user ?? NO_ERRORS;
|
|
4207
4248
|
if (schema.length === 0 && user.length === 0) {
|
|
4208
|
-
if (current !== void 0) st.errorCells.delete(key);
|
|
4249
|
+
if (current !== void 0) st.errorCells().delete(key);
|
|
4209
4250
|
return;
|
|
4210
4251
|
}
|
|
4211
|
-
st.errorCells.set(key, { schema, user });
|
|
4252
|
+
st.errorCells().set(key, { schema, user });
|
|
4212
4253
|
}
|
|
4213
4254
|
function replaceErrorChannel(st, src, entries) {
|
|
4214
4255
|
const other = src === "schema" ? "user" : "schema";
|
|
4215
4256
|
const grouped = groupErrorsByKey(entries);
|
|
4216
|
-
for (const [key, cell] of st.errorCells) {
|
|
4257
|
+
for (const [key, cell] of st.errorCells()) {
|
|
4217
4258
|
if (cell[other].length === 0) {
|
|
4218
|
-
st.errorCells.delete(key);
|
|
4259
|
+
st.errorCells().delete(key);
|
|
4219
4260
|
continue;
|
|
4220
4261
|
}
|
|
4221
4262
|
const fresh = grouped.get(key);
|
|
@@ -4240,8 +4281,9 @@ function clearErrorChannel(st, src, path) {
|
|
|
4240
4281
|
function applySchemaErrorsForSubtree(st, path, entries) {
|
|
4241
4282
|
const parentKey = canonicalizePath(path).key;
|
|
4242
4283
|
const grouped = groupErrorsByKey(entries);
|
|
4284
|
+
if (path.length === 0) st.skipErrorSeed();
|
|
4243
4285
|
if (!grouped.has(parentKey)) setErrorChannelForKey(st, parentKey, "schema", NO_ERRORS);
|
|
4244
|
-
for (const [existingKey, cell] of st.errorCells) {
|
|
4286
|
+
for (const [existingKey, cell] of st.errorCells()) {
|
|
4245
4287
|
if (existingKey === parentKey) continue;
|
|
4246
4288
|
if (cell.schema.length === 0) continue;
|
|
4247
4289
|
if (isPathKeyUnder(existingKey, path) && !grouped.has(existingKey)) {
|
|
@@ -4253,15 +4295,15 @@ function applySchemaErrorsForSubtree(st, path, entries) {
|
|
|
4253
4295
|
}
|
|
4254
4296
|
}
|
|
4255
4297
|
function restoreErrorCells(st, entries) {
|
|
4256
|
-
st.
|
|
4298
|
+
st.skipErrorSeed().clear();
|
|
4257
4299
|
for (const [key, cell] of entries) {
|
|
4258
4300
|
if (cell.schema.length === 0 && cell.user.length === 0) continue;
|
|
4259
|
-
st.errorCells.set(key, { schema: [...cell.schema], user: [...cell.user] });
|
|
4301
|
+
st.errorCells().set(key, { schema: [...cell.schema], user: [...cell.user] });
|
|
4260
4302
|
}
|
|
4261
4303
|
}
|
|
4262
4304
|
function getErrorsForPath(st, path) {
|
|
4263
4305
|
const { key } = canonicalizePath(path);
|
|
4264
|
-
const cell = st.errorCells.get(key);
|
|
4306
|
+
const cell = st.errorCells().get(key);
|
|
4265
4307
|
const blankForKey = st.derivedBlankErrors.value.get(key);
|
|
4266
4308
|
if (cell === void 0 && blankForKey === void 0) {
|
|
4267
4309
|
return [];
|
|
@@ -4423,7 +4465,14 @@ function adoptResolvedDefaults(st, value) {
|
|
|
4423
4465
|
st.schema
|
|
4424
4466
|
)
|
|
4425
4467
|
);
|
|
4426
|
-
seedOriginalsFromBaseline(
|
|
4468
|
+
seedOriginalsFromBaseline(
|
|
4469
|
+
st,
|
|
4470
|
+
computeBaseline(
|
|
4471
|
+
st.schema,
|
|
4472
|
+
st.defaultValues,
|
|
4473
|
+
st.schema.getDefaultValues({ useDefaultSchemaValues: true })
|
|
4474
|
+
)
|
|
4475
|
+
);
|
|
4427
4476
|
}
|
|
4428
4477
|
function reset(st, nextDefaultValues) {
|
|
4429
4478
|
const resetSource = nextDefaultValues === void 0 ? st.defaultValues : mergeSparseHydration(
|
|
@@ -4432,13 +4481,16 @@ function reset(st, nextDefaultValues) {
|
|
|
4432
4481
|
st.schema
|
|
4433
4482
|
);
|
|
4434
4483
|
st.defaultValues = structuralSnapshot(resetSource);
|
|
4435
|
-
const
|
|
4436
|
-
|
|
4484
|
+
const next = computeBaseline(
|
|
4485
|
+
st.schema,
|
|
4486
|
+
resetSource,
|
|
4487
|
+
st.schema.getDefaultValues({ useDefaultSchemaValues: true })
|
|
4488
|
+
);
|
|
4437
4489
|
rebuildAuthoredPaths(st, resetSource, next);
|
|
4438
4490
|
applyFormReplacement(st, next);
|
|
4439
4491
|
st.arrayIdentity.rebaselineAll();
|
|
4440
4492
|
st.removedSubtrees.clear();
|
|
4441
|
-
seedOriginalsFromBaseline(st, next
|
|
4493
|
+
seedOriginalsFromBaseline(st, next);
|
|
4442
4494
|
if (nextDefaultValues !== void 0) {
|
|
4443
4495
|
const mentioned = /* @__PURE__ */ new Set();
|
|
4444
4496
|
walkAuthoredFromConstraints(nextDefaultValues, [], mentioned);
|
|
@@ -4448,14 +4500,8 @@ function reset(st, nextDefaultValues) {
|
|
|
4448
4500
|
for (const key of st.originalBlankPaths) {
|
|
4449
4501
|
st.blankPaths.add(key);
|
|
4450
4502
|
}
|
|
4451
|
-
st.
|
|
4452
|
-
|
|
4453
|
-
replaceErrorChannel(st, "schema", resetResponse.errors);
|
|
4454
|
-
}
|
|
4455
|
-
const syncResult = st.schema.validateAtPath(st.form.value, void 0, { sync: true });
|
|
4456
|
-
if (!(syncResult instanceof Promise) && !syncResult.success) {
|
|
4457
|
-
applySchemaErrorsForSubtree(st, [], syncResult.errors);
|
|
4458
|
-
}
|
|
4503
|
+
st.skipErrorSeed().clear();
|
|
4504
|
+
replaceErrorChannel(st, "schema", st.schema.validateSync(next));
|
|
4459
4505
|
st.firstValidationDone.value = initialFirstValidationGate(st.schema);
|
|
4460
4506
|
queueInitialAsyncValidation(st);
|
|
4461
4507
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -4532,7 +4578,7 @@ function resetField(st, path) {
|
|
|
4532
4578
|
}
|
|
4533
4579
|
}
|
|
4534
4580
|
function deleteErrorCellsUnderPrefix(st, prefix) {
|
|
4535
|
-
for (const [errorKey, cell] of st.errorCells) {
|
|
4581
|
+
for (const [errorKey, cell] of st.errorCells()) {
|
|
4536
4582
|
for (const src of ERROR_SOURCES) {
|
|
4537
4583
|
const first = cell[src][0];
|
|
4538
4584
|
if (first !== void 0 && isPathPrefix(prefix, first.path)) {
|
|
@@ -4597,8 +4643,8 @@ function createFormStore(options) {
|
|
|
4597
4643
|
const fieldValidatingSince = reactive(/* @__PURE__ */ new Map());
|
|
4598
4644
|
const displayEngine = createDisplayEngine(ssr);
|
|
4599
4645
|
cleanupHooks.push(() => displayEngine.dispose());
|
|
4600
|
-
const
|
|
4601
|
-
const schemaInitialData =
|
|
4646
|
+
const ownDefaultValues = structuralSnapshot(defaultValues);
|
|
4647
|
+
const schemaInitialData = computeBaseline(schema, ownDefaultValues, options.schemaDefaults);
|
|
4602
4648
|
const authoredPaths = /* @__PURE__ */ new Set();
|
|
4603
4649
|
const initialData = hydration !== void 0 ? hydration.form : structuralSnapshot(schemaInitialData);
|
|
4604
4650
|
const hasDU = schema.hasDiscriminatedUnions?.() !== false;
|
|
@@ -4612,7 +4658,11 @@ function createFormStore(options) {
|
|
|
4612
4658
|
});
|
|
4613
4659
|
const fields = shallowReactive(/* @__PURE__ */ new Map());
|
|
4614
4660
|
const domBinding = shallowRef(null);
|
|
4615
|
-
const
|
|
4661
|
+
const errorStore = createErrorCells(
|
|
4662
|
+
schema,
|
|
4663
|
+
hydration === void 0 ? schemaInitialData : void 0
|
|
4664
|
+
);
|
|
4665
|
+
const errorCells = () => errorStore(true);
|
|
4616
4666
|
const originals = shallowReactive(/* @__PURE__ */ new Map());
|
|
4617
4667
|
const removedSubtrees = /* @__PURE__ */ new Set();
|
|
4618
4668
|
const blankPaths = reactive(/* @__PURE__ */ new Set());
|
|
@@ -4636,7 +4686,7 @@ function createFormStore(options) {
|
|
|
4636
4686
|
return result;
|
|
4637
4687
|
});
|
|
4638
4688
|
const errorPathIndex = computed(
|
|
4639
|
-
() => buildErrorPathIndex(errorCells, derivedBlankErrors.value)
|
|
4689
|
+
() => buildErrorPathIndex(errorCells(), derivedBlankErrors.value)
|
|
4640
4690
|
);
|
|
4641
4691
|
const submitting = ref(false);
|
|
4642
4692
|
const activeSubmissions = ref(0);
|
|
@@ -4776,18 +4826,16 @@ function createFormStore(options) {
|
|
|
4776
4826
|
blankPaths,
|
|
4777
4827
|
originalBlankPaths,
|
|
4778
4828
|
// --- kernel-internal state ---
|
|
4779
|
-
//
|
|
4780
|
-
//
|
|
4781
|
-
//
|
|
4782
|
-
|
|
4783
|
-
// mutating the form's defaults from outside. `reset()` snapshots for a
|
|
4784
|
-
// harder reason, where an alias IS reachable.
|
|
4785
|
-
defaultValues: structuralSnapshot(defaultValues),
|
|
4829
|
+
// The copy taken above, which also stops a consumer holding a reference to
|
|
4830
|
+
// the literal they passed from mutating the form's defaults from outside.
|
|
4831
|
+
// `reset()` snapshots for a harder reason, where an alias IS reachable.
|
|
4832
|
+
defaultValues: ownDefaultValues,
|
|
4786
4833
|
ssrPrefetch,
|
|
4787
4834
|
rememberVariants,
|
|
4788
4835
|
fieldValidationMode,
|
|
4789
4836
|
fieldValidationDebounceMs,
|
|
4790
4837
|
hasDU,
|
|
4838
|
+
hasPreprocessOrCoerce: schema.hasPreprocessOrCoerce?.() !== false,
|
|
4791
4839
|
fieldValidationState,
|
|
4792
4840
|
formChangeListeners,
|
|
4793
4841
|
submitSuccessListeners,
|
|
@@ -4803,6 +4851,7 @@ function createFormStore(options) {
|
|
|
4803
4851
|
transformRuns,
|
|
4804
4852
|
transformWaiters,
|
|
4805
4853
|
arrayBookkeeping,
|
|
4854
|
+
skipErrorSeed: () => errorStore(false),
|
|
4806
4855
|
nextOrdinal: 0,
|
|
4807
4856
|
scheduleEpoch: 0,
|
|
4808
4857
|
lastCommittedEpoch: 0,
|
|
@@ -4870,7 +4919,25 @@ function createFormStore(options) {
|
|
|
4870
4919
|
dispose: bind(dispose)
|
|
4871
4920
|
};
|
|
4872
4921
|
rebuildAuthoredPaths(st, defaultValues, schemaInitialData);
|
|
4873
|
-
|
|
4922
|
+
const initStamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4923
|
+
diffAndApply({}, schemaInitialData, [], (patch) => {
|
|
4924
|
+
if (patch.kind !== "added") return;
|
|
4925
|
+
const { key } = canonicalizePath(patch.path);
|
|
4926
|
+
originals.set(key, { segments: patch.path, value: patch.newValue });
|
|
4927
|
+
ensurePathOrdinal(st, key);
|
|
4928
|
+
if (hydration === void 0) {
|
|
4929
|
+
fields.set(key, {
|
|
4930
|
+
path: patch.path,
|
|
4931
|
+
updatedAt: initStamp,
|
|
4932
|
+
connected: false,
|
|
4933
|
+
focused: null,
|
|
4934
|
+
blurred: null,
|
|
4935
|
+
touched: false,
|
|
4936
|
+
interacted: false,
|
|
4937
|
+
blurredAfterInteraction: false
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
});
|
|
4874
4941
|
if (hydration !== void 0) {
|
|
4875
4942
|
for (const [rawKey, record] of hydration.fields) {
|
|
4876
4943
|
if (typeof rawKey !== "string" || !isHydratedFieldRecord(record)) {
|
|
@@ -4893,25 +4960,6 @@ function createFormStore(options) {
|
|
|
4893
4960
|
}
|
|
4894
4961
|
setErrorChannelForKey(st, rawKey, "user", errs);
|
|
4895
4962
|
}
|
|
4896
|
-
} else {
|
|
4897
|
-
const initStamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4898
|
-
diffAndApply({}, initialData, [], (patch) => {
|
|
4899
|
-
if (patch.kind !== "added") return;
|
|
4900
|
-
const { key } = canonicalizePath(patch.path);
|
|
4901
|
-
fields.set(key, {
|
|
4902
|
-
path: patch.path,
|
|
4903
|
-
updatedAt: initStamp,
|
|
4904
|
-
connected: false,
|
|
4905
|
-
focused: null,
|
|
4906
|
-
blurred: null,
|
|
4907
|
-
touched: false,
|
|
4908
|
-
interacted: false,
|
|
4909
|
-
blurredAfterInteraction: false
|
|
4910
|
-
});
|
|
4911
|
-
});
|
|
4912
|
-
if (!schemaResponse.success) {
|
|
4913
|
-
replaceErrorChannel(st, "schema", schemaResponse.errors);
|
|
4914
|
-
}
|
|
4915
4963
|
}
|
|
4916
4964
|
queueInitialAsyncValidation(st);
|
|
4917
4965
|
return st;
|
|
@@ -5009,9 +5057,11 @@ const HISTORY_MODULE_KEY = "history";
|
|
|
5009
5057
|
function buildFreshState(key, schema, configuration, registry) {
|
|
5010
5058
|
const pending = registry.pendingHydration.get(key);
|
|
5011
5059
|
if (pending !== void 0) registry.pendingHydration.delete(key);
|
|
5060
|
+
const schemaDefaults = schema.getDefaultValues({ useDefaultSchemaValues: true });
|
|
5012
5061
|
const walked = walkUnsetSentinels(
|
|
5013
5062
|
configuration.defaultValues,
|
|
5014
|
-
schema
|
|
5063
|
+
schema,
|
|
5064
|
+
schemaDefaults
|
|
5015
5065
|
);
|
|
5016
5066
|
let initialBlankPaths;
|
|
5017
5067
|
if (pending === void 0) {
|
|
@@ -5021,6 +5071,7 @@ function buildFreshState(key, schema, configuration, registry) {
|
|
|
5021
5071
|
formKey: key,
|
|
5022
5072
|
schema,
|
|
5023
5073
|
defaultValues: walked.cleanedValues,
|
|
5074
|
+
schemaDefaults,
|
|
5024
5075
|
hydration: pending,
|
|
5025
5076
|
ssr: registry.ssr,
|
|
5026
5077
|
...pickDefined({
|
|
@@ -5084,6 +5135,7 @@ function resolveFormKey(key) {
|
|
|
5084
5135
|
}
|
|
5085
5136
|
|
|
5086
5137
|
let injectedInstanceCounter = 0;
|
|
5138
|
+
const sharedApis = /* @__PURE__ */ new WeakMap();
|
|
5087
5139
|
function injectForm(input) {
|
|
5088
5140
|
const key = typeof input === "string" ? input : input?.key;
|
|
5089
5141
|
const ssrAccessed = typeof input === "object" && input !== null ? input.__ssrAccessed === true : false;
|
|
@@ -5106,12 +5158,37 @@ function injectForm(input) {
|
|
|
5106
5158
|
apiOptions.history = history;
|
|
5107
5159
|
}
|
|
5108
5160
|
const ambientInstanceId = getCurrentInstance() !== null ? inject(kFormInstanceId, null) : null;
|
|
5109
|
-
const
|
|
5110
|
-
return buildFormApi(
|
|
5161
|
+
const api = ambientInstanceId !== null ? shareApi(state, ambientInstanceId, apiOptions) : buildFormApi(
|
|
5111
5162
|
state,
|
|
5112
|
-
|
|
5163
|
+
getCurrentInstance() !== null ? useId() : `atta:form-instance-injected:${injectedInstanceCounter++}`,
|
|
5113
5164
|
apiOptions
|
|
5114
5165
|
);
|
|
5166
|
+
return api;
|
|
5167
|
+
}
|
|
5168
|
+
function shareApi(state, formInstanceId, options) {
|
|
5169
|
+
let instances = sharedApis.get(state);
|
|
5170
|
+
if (instances === void 0) {
|
|
5171
|
+
instances = /* @__PURE__ */ new Map();
|
|
5172
|
+
sharedApis.set(state, instances);
|
|
5173
|
+
}
|
|
5174
|
+
const byInstance = instances;
|
|
5175
|
+
let shared = byInstance.get(formInstanceId);
|
|
5176
|
+
if (shared === void 0) {
|
|
5177
|
+
const scope = effectScope(true);
|
|
5178
|
+
const api = scope.run(() => buildFormApi(state, formInstanceId, options));
|
|
5179
|
+
if (api === void 0) return buildFormApi(state, formInstanceId, options);
|
|
5180
|
+
shared = { api, scope, users: 0 };
|
|
5181
|
+
byInstance.set(formInstanceId, shared);
|
|
5182
|
+
}
|
|
5183
|
+
const entry = shared;
|
|
5184
|
+
entry.users += 1;
|
|
5185
|
+
onScopeDispose(() => {
|
|
5186
|
+
entry.users -= 1;
|
|
5187
|
+
if (entry.users > 0) return;
|
|
5188
|
+
entry.scope.stop();
|
|
5189
|
+
byInstance.delete(formInstanceId);
|
|
5190
|
+
});
|
|
5191
|
+
return entry.api;
|
|
5115
5192
|
}
|
|
5116
5193
|
function resolveState(key, registry) {
|
|
5117
5194
|
if (key !== void 0) {
|
|
@@ -5206,22 +5283,23 @@ function useRegister(options) {
|
|
|
5206
5283
|
const capturedRegisterValue = shallowRef(void 0);
|
|
5207
5284
|
const refreshAndStripBridgeAttrs = () => {
|
|
5208
5285
|
const rawAttrs = instance.attrs;
|
|
5286
|
+
const parentBinding = instance.vnode.dirs?.find(
|
|
5287
|
+
(dir) => dir.dir?.[V_REGISTER_MARKER] === true
|
|
5288
|
+
);
|
|
5209
5289
|
if ("registerValue" in rawAttrs) {
|
|
5210
5290
|
capturedRegisterValue.value = rawAttrs["registerValue"];
|
|
5211
5291
|
delete rawAttrs["registerValue"];
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
}
|
|
5224
|
-
}
|
|
5292
|
+
} else if (parentBinding !== void 0) {
|
|
5293
|
+
capturedRegisterValue.value = parentBinding.value;
|
|
5294
|
+
}
|
|
5295
|
+
const captured = capturedRegisterValue.value;
|
|
5296
|
+
if (captured !== void 0) {
|
|
5297
|
+
armDomBinding(captured);
|
|
5298
|
+
if (parentBinding !== void 0) {
|
|
5299
|
+
recordInheritedModifiers(
|
|
5300
|
+
captured,
|
|
5301
|
+
withInheritedModifiers(parentBinding.value, parentBinding.modifiers)
|
|
5302
|
+
);
|
|
5225
5303
|
}
|
|
5226
5304
|
}
|
|
5227
5305
|
if ("value" in rawAttrs) delete rawAttrs["value"];
|
|
@@ -5347,11 +5425,11 @@ const NOOP_SUCCESS = {
|
|
|
5347
5425
|
data: EMPTY_VALUE,
|
|
5348
5426
|
errors: void 0
|
|
5349
5427
|
};
|
|
5350
|
-
const NOOP_DEFAULTS = NOOP_SUCCESS;
|
|
5351
5428
|
let NOOP_SCHEMA;
|
|
5352
5429
|
function buildNoopWizardSchema() {
|
|
5353
5430
|
NOOP_SCHEMA ?? (NOOP_SCHEMA = {
|
|
5354
|
-
getDefaultValues: () =>
|
|
5431
|
+
getDefaultValues: () => EMPTY_VALUE,
|
|
5432
|
+
validateSync: () => [],
|
|
5355
5433
|
getDefaultAtPath: () => void 0,
|
|
5356
5434
|
getEmptyValueAtPath: () => void 0,
|
|
5357
5435
|
isPreprocessOrCoerceLeaf: () => false,
|
|
@@ -5367,7 +5445,8 @@ function buildNoopWizardSchema() {
|
|
|
5367
5445
|
isLeafAtPath: () => false,
|
|
5368
5446
|
isRequiredAtPath: () => false,
|
|
5369
5447
|
getUnionDiscriminatorAtPath: () => void 0,
|
|
5370
|
-
hasDiscriminatedUnions: () => false
|
|
5448
|
+
hasDiscriminatedUnions: () => false,
|
|
5449
|
+
hasPreprocessOrCoerce: () => false
|
|
5371
5450
|
});
|
|
5372
5451
|
return NOOP_SCHEMA;
|
|
5373
5452
|
}
|
|
@@ -6371,7 +6450,7 @@ function useWizard(options) {
|
|
|
6371
6450
|
for (const key of keys) {
|
|
6372
6451
|
const store = registry.forms.get(key);
|
|
6373
6452
|
if (store === void 0) continue;
|
|
6374
|
-
for (const cell of store.errorCells.values()) {
|
|
6453
|
+
for (const cell of store.errorCells().values()) {
|
|
6375
6454
|
for (const err of cell.user) out.push(toWizardAggregateError(err, key));
|
|
6376
6455
|
}
|
|
6377
6456
|
}
|