attaform 0.24.0 → 0.24.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/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/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +4 -3
- 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/plugins/attaform.cjs +2 -2
- package/dist/runtime/plugins/attaform.mjs +2 -2
- package/dist/shared/{attaform.CAWKNCzc.mjs → attaform.0-00cYGw.mjs} +2 -2
- package/dist/shared/{attaform.CAWKNCzc.mjs.map → attaform.0-00cYGw.mjs.map} +1 -1
- package/dist/shared/{attaform.DdUYEhkV.d.cts → attaform.0zueP54D.d.mts} +33 -15
- package/dist/shared/{attaform.Z1qTwOYE.cjs → attaform.B57G7ePY.cjs} +4 -4
- package/dist/shared/{attaform.BJ_W7q3U.mjs.map → attaform.B57G7ePY.cjs.map} +1 -1
- package/dist/shared/{attaform.DwkU0oY9.cjs → attaform.B7UdTs_o.cjs} +79 -75
- package/dist/shared/attaform.B7UdTs_o.cjs.map +1 -0
- package/dist/shared/{attaform.CuBdtfbe.mjs → attaform.BI7M3wK8.mjs} +88 -16
- package/dist/shared/attaform.BI7M3wK8.mjs.map +1 -0
- package/dist/shared/{attaform.nycEksJn.cjs → attaform.BOi6n2Pn.cjs} +2 -2
- package/dist/shared/{attaform.nycEksJn.cjs.map → attaform.BOi6n2Pn.cjs.map} +1 -1
- package/dist/shared/{attaform.BJ_W7q3U.mjs → attaform.B_-nZHtM.mjs} +4 -4
- package/dist/shared/{attaform.Z1qTwOYE.cjs.map → attaform.B_-nZHtM.mjs.map} +1 -1
- package/dist/shared/{attaform.o95Kjd3U.mjs → attaform.BjUaX7s8.mjs} +3 -3
- package/dist/shared/{attaform.o95Kjd3U.mjs.map → attaform.BjUaX7s8.mjs.map} +1 -1
- package/dist/shared/{attaform.BNmkKz0q.d.mts → attaform.BjiHiYAZ.d.ts} +3 -2
- package/dist/shared/{attaform.C42wL7EJ.cjs → attaform.Bos7wVZw.cjs} +90 -18
- package/dist/shared/attaform.Bos7wVZw.cjs.map +1 -0
- package/dist/shared/{attaform.CwFZGv5-.d.ts → attaform.Bx6pgrIy.d.cts} +3 -2
- package/dist/shared/{attaform.Df-s8j1X.mjs → attaform.C0au8oXd.mjs} +36 -29
- package/dist/shared/attaform.C0au8oXd.mjs.map +1 -0
- package/dist/shared/attaform.CjdepGnw.cjs +27 -0
- package/dist/shared/attaform.CjdepGnw.cjs.map +1 -0
- package/dist/shared/{attaform.BnUXV01g.cjs → attaform.D-gYGj5z.cjs} +4 -4
- package/dist/shared/{attaform.C-dAB90u.mjs.map → attaform.D-gYGj5z.cjs.map} +1 -1
- package/dist/shared/{attaform.C6eE50re.d.ts → attaform.DHjRN5JP.d.cts} +33 -15
- package/dist/shared/{attaform.CR6wGvNu.cjs → attaform.DK6_Ctv7.cjs} +10 -4
- package/dist/shared/attaform.DK6_Ctv7.cjs.map +1 -0
- package/dist/shared/{attaform.GJbSmwLB.d.mts → attaform.DUc6cetN.d.cts} +62 -13
- package/dist/shared/{attaform.GJbSmwLB.d.cts → attaform.DUc6cetN.d.mts} +62 -13
- package/dist/shared/{attaform.GJbSmwLB.d.ts → attaform.DUc6cetN.d.ts} +62 -13
- package/dist/shared/{attaform.BV_HyaMO.cjs → attaform.DdfLrIgM.cjs} +3 -3
- package/dist/shared/{attaform.BV_HyaMO.cjs.map → attaform.DdfLrIgM.cjs.map} +1 -1
- package/dist/shared/{attaform.K-3glmiT.d.cts → attaform.DvqdxvNU.d.mts} +3 -2
- package/dist/shared/{attaform.BFWb6hDk.mjs → attaform.DwCtxauq.mjs} +10 -4
- package/dist/shared/attaform.DwCtxauq.mjs.map +1 -0
- package/dist/shared/{attaform.C-dAB90u.mjs → attaform.K1MbxmIu.mjs} +4 -4
- package/dist/shared/{attaform.BnUXV01g.cjs.map → attaform.K1MbxmIu.mjs.map} +1 -1
- package/dist/shared/attaform.WvcckZMD.mjs +21 -0
- package/dist/shared/attaform.WvcckZMD.mjs.map +1 -0
- package/dist/shared/{attaform.DiWNbKWa.d.mts → attaform.yqcYwt0d.d.ts} +33 -15
- package/dist/transforms.cjs +1 -1
- package/dist/transforms.d.cts +4 -1
- package/dist/transforms.d.mts +4 -1
- package/dist/transforms.d.ts +4 -1
- package/dist/transforms.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/dist/zod-v3.cjs +2 -2
- package/dist/zod-v3.d.cts +8 -5
- package/dist/zod-v3.d.mts +8 -5
- package/dist/zod-v3.d.ts +8 -5
- package/dist/zod-v3.mjs +2 -2
- package/dist/zod-v4.cjs +2 -2
- package/dist/zod-v4.d.cts +5 -5
- package/dist/zod-v4.d.mts +5 -5
- package/dist/zod-v4.d.ts +5 -5
- package/dist/zod-v4.mjs +2 -2
- package/dist/zod.cjs +5 -5
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +23 -7
- package/dist/zod.d.mts +23 -7
- package/dist/zod.d.ts +23 -7
- package/dist/zod.mjs +5 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/shared/attaform.BFWb6hDk.mjs.map +0 -1
- package/dist/shared/attaform.C42wL7EJ.cjs.map +0 -1
- package/dist/shared/attaform.CR6wGvNu.cjs.map +0 -1
- package/dist/shared/attaform.CuBdtfbe.mjs.map +0 -1
- package/dist/shared/attaform.Df-s8j1X.mjs.map +0 -1
- package/dist/shared/attaform.DwkU0oY9.cjs.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, ref, watchEffect, getCurrentScope, onScopeDispose, shallowReadonly, readonly, toRaw, reactive, watch, markRaw, triggerRef, shallowRef, getCurrentInstance, onServerPrefetch, provide, useId, inject, onBeforeMount, onBeforeUpdate, onMounted, effectScope, nextTick } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { n as pathsEqual, j as isPathPrefix, _ as __DEV__, f as canonicalizePath, s as segmentsForPathKey, o as keyForSegments, b as ROOT_PATH_KEY, S as SubmitErrorHandlerError, t as toError, q as INTERACTIVE_TAG_NAMES, R as ROOT_PATH, r as coerceToPathKey, a as InvalidUseFormConfigError, w as ensureAttaformInstalled, u as useRegistry, x as kFormContext, y as kFormInstanceId, d as ReservedFormKeyError, l as kAttaformWizardActiveStepResolver, z as kAttaformAncestorWizard } from './attaform.C0au8oXd.mjs';
|
|
3
|
+
import { R as REGISTER_OWNER_MARKER, V as V_REGISTER_MARKER } from './attaform.WvcckZMD.mjs';
|
|
3
4
|
|
|
4
5
|
function safeAssign(target, key, value) {
|
|
5
6
|
if (key === "__proto__") {
|
|
@@ -913,6 +914,10 @@ function buildContainerFieldStateBase(state, segments, key, formInstanceId) {
|
|
|
913
914
|
pristine = false;
|
|
914
915
|
dirty = true;
|
|
915
916
|
}
|
|
917
|
+
if (!dirty && state.hasRemovedSubtreeUnder(segments)) {
|
|
918
|
+
pristine = false;
|
|
919
|
+
dirty = true;
|
|
920
|
+
}
|
|
916
921
|
const errors = aggregateErrorsAt(state, segments);
|
|
917
922
|
const revealedDescendantError = errors.length > 0 && errors.some((e) => {
|
|
918
923
|
const ePath = e.path;
|
|
@@ -1919,6 +1924,19 @@ function buildProcessForm(state, formInstanceId, options = {}) {
|
|
|
1919
1924
|
state.clearSchemaErrors();
|
|
1920
1925
|
}
|
|
1921
1926
|
await onSubmit(merged.data);
|
|
1927
|
+
if (state.userErrors.size > 0) {
|
|
1928
|
+
if (state.submissionGeneration.value === genAtEntry) {
|
|
1929
|
+
applyInvalidSubmitPolicy(state, formInstanceId, invalidPolicy);
|
|
1930
|
+
}
|
|
1931
|
+
if (onError !== void 0) {
|
|
1932
|
+
try {
|
|
1933
|
+
await onError(Array.from(state.userErrors.values()).flat());
|
|
1934
|
+
} catch (cause) {
|
|
1935
|
+
throw new SubmitErrorHandlerError("User-provided onError threw", { cause });
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1922
1940
|
if (state.submissionGeneration.value === genAtEntry) {
|
|
1923
1941
|
state.submitted.value = true;
|
|
1924
1942
|
}
|
|
@@ -3886,6 +3904,7 @@ function mergeObjectKeys(target, source, path, schema) {
|
|
|
3886
3904
|
return out;
|
|
3887
3905
|
}
|
|
3888
3906
|
|
|
3907
|
+
const isContainer = (value) => Array.isArray(value) || isPlainRecord(value);
|
|
3889
3908
|
function isHydratedFieldRecord(value) {
|
|
3890
3909
|
if (typeof value !== "object" || value === null) return false;
|
|
3891
3910
|
const r = value;
|
|
@@ -4075,6 +4094,7 @@ function createFormStore(options) {
|
|
|
4075
4094
|
const schemaErrors = reactive(/* @__PURE__ */ new Map());
|
|
4076
4095
|
const userErrors = reactive(/* @__PURE__ */ new Map());
|
|
4077
4096
|
const originals = reactive(/* @__PURE__ */ new Map());
|
|
4097
|
+
const removedSubtrees = /* @__PURE__ */ new Set();
|
|
4078
4098
|
const initialTransientList = hydration?.blankPaths ?? options.initialBlankPaths ?? [];
|
|
4079
4099
|
const blankPaths = reactive(/* @__PURE__ */ new Set());
|
|
4080
4100
|
const originalBlankPaths = /* @__PURE__ */ new Set();
|
|
@@ -4560,6 +4580,9 @@ function createFormStore(options) {
|
|
|
4560
4580
|
return true;
|
|
4561
4581
|
}
|
|
4562
4582
|
const oldArrayLength = Array.isArray(currentValue) ? currentValue.length : 0;
|
|
4583
|
+
if (meta?.arrayOp === void 0 && Array.isArray(value) && Array.isArray(currentValue)) {
|
|
4584
|
+
arrayIdentity.realign(path);
|
|
4585
|
+
}
|
|
4563
4586
|
applyTargetedWrite(path, completedValue, meta);
|
|
4564
4587
|
if (meta?.arrayOp !== void 0) {
|
|
4565
4588
|
const remap = remapForOp(meta.arrayOp, oldArrayLength);
|
|
@@ -4572,6 +4595,10 @@ function createFormStore(options) {
|
|
|
4572
4595
|
} else if (Array.isArray(value) && Array.isArray(currentValue)) {
|
|
4573
4596
|
variantMemory.clearUnderPath(path);
|
|
4574
4597
|
arrayIdentity.realign(path);
|
|
4598
|
+
} else if (isContainer(currentValue) && !isContainer(value)) {
|
|
4599
|
+
if (subtreeHadRealBaseline(path, currentValue)) {
|
|
4600
|
+
removedSubtrees.add(canonicalizePath(path).key);
|
|
4601
|
+
}
|
|
4575
4602
|
}
|
|
4576
4603
|
const effectiveModeAfterWrite = meta?.instance?.validateOn ?? fieldValidationMode;
|
|
4577
4604
|
if (effectiveModeAfterWrite === "change") {
|
|
@@ -5105,6 +5132,7 @@ function createFormStore(options) {
|
|
|
5105
5132
|
rebuildAuthoredPaths(resetSource, next);
|
|
5106
5133
|
applyFormReplacement(next);
|
|
5107
5134
|
arrayIdentity.rebaselineAll();
|
|
5135
|
+
removedSubtrees.clear();
|
|
5108
5136
|
originals.clear();
|
|
5109
5137
|
diffAndApply({}, next, [], (patch) => {
|
|
5110
5138
|
if (patch.kind !== "added") return;
|
|
@@ -5241,6 +5269,26 @@ function createFormStore(options) {
|
|
|
5241
5269
|
function hasStructuralChangeUnder(path) {
|
|
5242
5270
|
return arrayIdentity.hasStructuralChangeUnder(path);
|
|
5243
5271
|
}
|
|
5272
|
+
function subtreeHadRealBaseline(prefix, removedValue) {
|
|
5273
|
+
let had = false;
|
|
5274
|
+
diffAndApply(removedValue, void 0, prefix, (patch) => {
|
|
5275
|
+
if (had || patch.kind !== "removed") return;
|
|
5276
|
+
const record = originals.get(canonicalizePath(patch.path).key);
|
|
5277
|
+
if (record?.value !== void 0) had = true;
|
|
5278
|
+
});
|
|
5279
|
+
return had;
|
|
5280
|
+
}
|
|
5281
|
+
function hasRemovedSubtreeUnder(prefix) {
|
|
5282
|
+
if (removedSubtrees.size === 0) return false;
|
|
5283
|
+
for (const key of removedSubtrees) {
|
|
5284
|
+
const segments = segmentsForPathKey(key);
|
|
5285
|
+
if (segments === null) continue;
|
|
5286
|
+
if (!isPathPrefix(prefix, segments)) continue;
|
|
5287
|
+
if (isContainer(getAtPath(toRaw(form.value), segments))) continue;
|
|
5288
|
+
return true;
|
|
5289
|
+
}
|
|
5290
|
+
return false;
|
|
5291
|
+
}
|
|
5244
5292
|
function getFieldRecord(path) {
|
|
5245
5293
|
const { key } = canonicalizePath(path);
|
|
5246
5294
|
return fields.get(key);
|
|
@@ -5336,6 +5384,7 @@ function createFormStore(options) {
|
|
|
5336
5384
|
isPristineAtPath,
|
|
5337
5385
|
isPristineAtPathByKey,
|
|
5338
5386
|
hasStructuralChangeUnder,
|
|
5387
|
+
hasRemovedSubtreeUnder,
|
|
5339
5388
|
getFieldRecord,
|
|
5340
5389
|
getOriginalAtPath,
|
|
5341
5390
|
getFirstErrorElement,
|
|
@@ -6736,6 +6785,30 @@ function useWizard(options) {
|
|
|
6736
6785
|
}
|
|
6737
6786
|
return out;
|
|
6738
6787
|
}
|
|
6788
|
+
function collectCallbackErrors(keys) {
|
|
6789
|
+
const out = [];
|
|
6790
|
+
for (const key of keys) {
|
|
6791
|
+
const store = registry.forms.get(key);
|
|
6792
|
+
if (store === void 0) continue;
|
|
6793
|
+
for (const errs of store.userErrors.values()) {
|
|
6794
|
+
for (const err of errs) out.push(toWizardAggregateError(err, key));
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
return out;
|
|
6798
|
+
}
|
|
6799
|
+
async function focusFirstWizardError(errors) {
|
|
6800
|
+
if (options.focusFirstError === false) return;
|
|
6801
|
+
const firstFailedKey = errors[0]?.formKey;
|
|
6802
|
+
if (firstFailedKey === void 0 || !isCompiledKey(firstFailedKey)) return;
|
|
6803
|
+
moveTo(firstFailedKey);
|
|
6804
|
+
await nextTick();
|
|
6805
|
+
const failedForm = formsRecord.value[firstFailedKey];
|
|
6806
|
+
if (failedForm === void 0) return;
|
|
6807
|
+
const failedSource = asSubmissionSource(failedForm);
|
|
6808
|
+
if (typeof failedSource.applyInvalidSubmitPolicy === "function") {
|
|
6809
|
+
failedSource.applyInvalidSubmitPolicy();
|
|
6810
|
+
}
|
|
6811
|
+
}
|
|
6739
6812
|
function handleSubmit(onSubmit, onError) {
|
|
6740
6813
|
return async function submitHandler(event) {
|
|
6741
6814
|
if (event !== void 0 && typeof event.preventDefault === "function") {
|
|
@@ -6798,6 +6871,18 @@ function useWizard(options) {
|
|
|
6798
6871
|
}
|
|
6799
6872
|
const ctx = buildSubmitContext(valuesMap, currentKey, final);
|
|
6800
6873
|
await onSubmit(ctx);
|
|
6874
|
+
const callbackErrors = collectCallbackErrors(results.keys());
|
|
6875
|
+
if (callbackErrors.length > 0) {
|
|
6876
|
+
await focusFirstWizardError(callbackErrors);
|
|
6877
|
+
if (onError !== void 0) {
|
|
6878
|
+
try {
|
|
6879
|
+
await onError(callbackErrors);
|
|
6880
|
+
} catch (cause) {
|
|
6881
|
+
throw new SubmitErrorHandlerError("User-provided onError threw", { cause });
|
|
6882
|
+
}
|
|
6883
|
+
}
|
|
6884
|
+
return;
|
|
6885
|
+
}
|
|
6801
6886
|
if (final) {
|
|
6802
6887
|
done.value = true;
|
|
6803
6888
|
} else {
|
|
@@ -6807,20 +6892,7 @@ function useWizard(options) {
|
|
|
6807
6892
|
if (target !== void 0) moveTo(target.key);
|
|
6808
6893
|
}
|
|
6809
6894
|
} else {
|
|
6810
|
-
|
|
6811
|
-
const firstFailedKey = errors[0]?.formKey;
|
|
6812
|
-
if (firstFailedKey !== void 0 && isCompiledKey(firstFailedKey)) {
|
|
6813
|
-
moveTo(firstFailedKey);
|
|
6814
|
-
await nextTick();
|
|
6815
|
-
const failedForm = formsRecord.value[firstFailedKey];
|
|
6816
|
-
if (failedForm !== void 0) {
|
|
6817
|
-
const failedSource = asSubmissionSource(failedForm);
|
|
6818
|
-
if (typeof failedSource.applyInvalidSubmitPolicy === "function") {
|
|
6819
|
-
failedSource.applyInvalidSubmitPolicy();
|
|
6820
|
-
}
|
|
6821
|
-
}
|
|
6822
|
-
}
|
|
6823
|
-
}
|
|
6895
|
+
await focusFirstWizardError(errors);
|
|
6824
6896
|
if (onError !== void 0) {
|
|
6825
6897
|
try {
|
|
6826
6898
|
await onError(errors);
|
|
@@ -7028,4 +7100,4 @@ function warnIfAmbientWizardProviderHadDuplicates() {
|
|
|
7028
7100
|
}
|
|
7029
7101
|
|
|
7030
7102
|
export { AttaformErrorCode as A, DEFAULT_TIMINGS as D, injectWizard as a, isUnset as b, useRegister as c, useWizard as d, defaultCoercionRules as e, defaultDisplayState as f, defineCoercion as g, useAbstractForm as h, injectForm as i, isPlainRecord as j, safeAssign as k, lazy as l, makeDefaultDisplayState as m, slimKindOf as n, humanize as o, getAtPath as p, setAtPath as q, safeOwnRead as s, unset as u };
|
|
7031
|
-
//# sourceMappingURL=attaform.
|
|
7103
|
+
//# sourceMappingURL=attaform.BI7M3wK8.mjs.map
|