attaform 0.27.3 → 0.27.5
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.cjs +2 -2
- package/dist/abstract.d.cts +4 -4
- package/dist/abstract.d.mts +4 -4
- package/dist/abstract.d.ts +4 -4
- package/dist/abstract.mjs +2 -2
- 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 +3 -3
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +3 -3
- 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 +1 -1
- package/dist/runtime/plugins/attaform.mjs +1 -1
- package/dist/shared/{attaform.BjGedLx2.d.cts → attaform.B3abZaCV.d.cts} +58 -16
- package/dist/shared/{attaform.DeHCOlC8.cjs → attaform.Bh8A6YAc.cjs} +4 -4
- package/dist/shared/{attaform.DeHCOlC8.cjs.map → attaform.Bh8A6YAc.cjs.map} +1 -1
- package/dist/shared/{attaform.BBaMFa-k.cjs → attaform.Biytrv0-.cjs} +3 -3
- package/dist/shared/{attaform.CgsQZdy1.mjs.map → attaform.Biytrv0-.cjs.map} +1 -1
- package/dist/shared/{attaform.BqkFQ2B9.mjs → attaform.BypWgXRB.mjs} +91 -32
- package/dist/shared/attaform.BypWgXRB.mjs.map +1 -0
- package/dist/shared/{attaform.Mg4g-J0z.cjs → attaform.CF-EnyJn.cjs} +5 -5
- package/dist/shared/{attaform.Mg4g-J0z.cjs.map → attaform.CF-EnyJn.cjs.map} +1 -1
- package/dist/shared/{attaform.C8zVmank.d.ts → attaform.CIBMfxg9.d.ts} +1 -1
- package/dist/shared/{attaform.CEZP3i3I.d.mts → attaform.CJ1Z9Mz4.d.mts} +58 -16
- package/dist/shared/{attaform.BKxpBJVF.mjs → attaform.CTiZ9Rrv.mjs} +3 -3
- package/dist/shared/{attaform.BKxpBJVF.mjs.map → attaform.CTiZ9Rrv.mjs.map} +1 -1
- package/dist/shared/{attaform.ij2W7VTw.cjs → attaform.Cg1rUfcF.cjs} +91 -32
- package/dist/shared/attaform.Cg1rUfcF.cjs.map +1 -0
- package/dist/shared/{attaform.DuVCclwv.mjs → attaform.Cg_8gFQ7.mjs} +4 -4
- package/dist/shared/{attaform.DuVCclwv.mjs.map → attaform.Cg_8gFQ7.mjs.map} +1 -1
- package/dist/shared/{attaform.BOIpRdeG.cjs → attaform.Crv0RNiz.cjs} +4 -4
- package/dist/shared/{attaform.BOIpRdeG.cjs.map → attaform.Crv0RNiz.cjs.map} +1 -1
- package/dist/shared/{attaform.BIPSHY5U.d.ts → attaform.CzL2CZ8U.d.cts} +8 -1
- package/dist/shared/{attaform.BIPSHY5U.d.cts → attaform.CzL2CZ8U.d.mts} +8 -1
- package/dist/shared/{attaform.BIPSHY5U.d.mts → attaform.CzL2CZ8U.d.ts} +8 -1
- package/dist/shared/{attaform.C925L0WA.d.mts → attaform.DYwyM5Cp.d.cts} +1 -1
- package/dist/shared/{attaform.DHQjaGMP.mjs → attaform.Dc1mx48r.mjs} +5 -5
- package/dist/shared/{attaform.DHQjaGMP.mjs.map → attaform.Dc1mx48r.mjs.map} +1 -1
- package/dist/shared/{attaform.gqOCvpSB.d.ts → attaform.DcFDQVpa.d.ts} +58 -16
- package/dist/shared/{attaform.DDIn4fv-.mjs → attaform.Dkjh_F30.mjs} +4 -4
- package/dist/shared/{attaform.DDIn4fv-.mjs.map → attaform.Dkjh_F30.mjs.map} +1 -1
- package/dist/shared/{attaform.CnvbLiIO.d.cts → attaform.DrHOqB-d.d.mts} +1 -1
- package/dist/shared/{attaform.dX58Auwf.cjs → attaform.f2zyNh5d.cjs} +3 -3
- package/dist/shared/{attaform.dX58Auwf.cjs.map → attaform.f2zyNh5d.cjs.map} +1 -1
- package/dist/shared/{attaform.CgsQZdy1.mjs → attaform.nMaz2C5P.mjs} +3 -3
- package/dist/shared/{attaform.BBaMFa-k.cjs.map → attaform.nMaz2C5P.mjs.map} +1 -1
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +3 -3
- package/dist/zod-v3.d.mts +3 -3
- package/dist/zod-v3.d.ts +3 -3
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +6 -6
- package/dist/zod-v4.d.mts +6 -6
- package/dist/zod-v4.d.ts +6 -6
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +3 -3
- package/dist/zod.d.cts +3 -3
- package/dist/zod.d.mts +3 -3
- package/dist/zod.d.ts +3 -3
- package/dist/zod.mjs +3 -3
- package/package.json +1 -1
- package/dist/shared/attaform.BqkFQ2B9.mjs.map +0 -1
- package/dist/shared/attaform.ij2W7VTw.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const devtoolsShared = require('./attaform.
|
|
4
|
+
const devtoolsShared = require('./attaform.Biytrv0-.cjs');
|
|
5
5
|
const registerProtocol = require('./attaform.yUrz7C2z.cjs');
|
|
6
6
|
|
|
7
7
|
function safeAssign(target, key, value) {
|
|
@@ -2509,8 +2509,8 @@ function buildRegister(state, formInstanceId, instanceConfig) {
|
|
|
2509
2509
|
markConnectedOptimistically: () => {
|
|
2510
2510
|
state.markConnectedOptimistically(segments);
|
|
2511
2511
|
},
|
|
2512
|
-
markHostConnected: (connected) => {
|
|
2513
|
-
state.markHostConnected(segments, connected);
|
|
2512
|
+
markHostConnected: (connected, hostEl) => {
|
|
2513
|
+
state.markHostConnected(segments, connected, hostEl, formInstanceId);
|
|
2514
2514
|
},
|
|
2515
2515
|
markFocused: (focused) => {
|
|
2516
2516
|
state.markFocused(
|
|
@@ -4068,6 +4068,25 @@ function mergeObjectKeys(target, source, path, schema) {
|
|
|
4068
4068
|
}
|
|
4069
4069
|
|
|
4070
4070
|
const isContainer = (value) => Array.isArray(value) || isPlainRecord(value);
|
|
4071
|
+
const HOST_FOCUS_TARGET_SELECTOR = [
|
|
4072
|
+
'input:not([type="hidden"])',
|
|
4073
|
+
"select",
|
|
4074
|
+
"textarea",
|
|
4075
|
+
"button",
|
|
4076
|
+
"a[href]",
|
|
4077
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
4078
|
+
'[contenteditable="true"]'
|
|
4079
|
+
].join(", ");
|
|
4080
|
+
function resolveHostFocusTarget(hostRoot) {
|
|
4081
|
+
const candidates = hostRoot.querySelectorAll(HOST_FOCUS_TARGET_SELECTOR);
|
|
4082
|
+
for (const el of candidates) {
|
|
4083
|
+
if (!el.isConnected) continue;
|
|
4084
|
+
if (el.offsetParent === null) continue;
|
|
4085
|
+
if (el.matches(":disabled")) continue;
|
|
4086
|
+
return el;
|
|
4087
|
+
}
|
|
4088
|
+
return hostRoot;
|
|
4089
|
+
}
|
|
4071
4090
|
function isHydratedFieldRecord(value) {
|
|
4072
4091
|
if (typeof value !== "object" || value === null) return false;
|
|
4073
4092
|
const r = value;
|
|
@@ -4253,6 +4272,7 @@ function createFormStore(options) {
|
|
|
4253
4272
|
const fields = vue.reactive(/* @__PURE__ */ new Map());
|
|
4254
4273
|
const elements = vue.reactive(/* @__PURE__ */ new Map());
|
|
4255
4274
|
const elementToFormInstance = /* @__PURE__ */ new WeakMap();
|
|
4275
|
+
const hostTargets = /* @__PURE__ */ new Map();
|
|
4256
4276
|
let sortedRegistrationsCache = null;
|
|
4257
4277
|
const schemaErrors = vue.reactive(/* @__PURE__ */ new Map());
|
|
4258
4278
|
const userErrors = vue.reactive(/* @__PURE__ */ new Map());
|
|
@@ -5125,6 +5145,7 @@ function createFormStore(options) {
|
|
|
5125
5145
|
record.elements.add(raw);
|
|
5126
5146
|
}
|
|
5127
5147
|
elementToFormInstance.set(element, formInstanceId);
|
|
5148
|
+
hostTargets.delete(key);
|
|
5128
5149
|
sortedRegistrationsCache = null;
|
|
5129
5150
|
const current = fields.get(key);
|
|
5130
5151
|
touchFieldRecord(key, path, {
|
|
@@ -5162,10 +5183,14 @@ function createFormStore(options) {
|
|
|
5162
5183
|
blurred: current?.blurred ?? true
|
|
5163
5184
|
});
|
|
5164
5185
|
}
|
|
5165
|
-
function markHostConnected(path, connected) {
|
|
5186
|
+
function markHostConnected(path, connected, hostEl, formInstanceId) {
|
|
5166
5187
|
const { key } = devtoolsShared.canonicalizePath(path);
|
|
5167
5188
|
const current = fields.get(key);
|
|
5168
5189
|
if (connected) {
|
|
5190
|
+
if (!elements.has(key)) {
|
|
5191
|
+
hostTargets.set(key, { path, hostRoot: hostEl, formInstanceId });
|
|
5192
|
+
sortedRegistrationsCache = null;
|
|
5193
|
+
}
|
|
5169
5194
|
if (current?.connected === true) return;
|
|
5170
5195
|
touchFieldRecord(key, path, {
|
|
5171
5196
|
connected: true,
|
|
@@ -5173,6 +5198,7 @@ function createFormStore(options) {
|
|
|
5173
5198
|
blurred: current?.blurred ?? true
|
|
5174
5199
|
});
|
|
5175
5200
|
} else {
|
|
5201
|
+
if (hostTargets.delete(key)) sortedRegistrationsCache = null;
|
|
5176
5202
|
if (current?.connected !== true) return;
|
|
5177
5203
|
touchFieldRecord(key, path, { connected: false, focused: null, blurred: null });
|
|
5178
5204
|
}
|
|
@@ -5507,18 +5533,35 @@ function createFormStore(options) {
|
|
|
5507
5533
|
function getFirstErrorElement(formInstanceId) {
|
|
5508
5534
|
sortedRegistrationsCache ?? (sortedRegistrationsCache = rebuildSortedRegistrations());
|
|
5509
5535
|
for (const entry of sortedRegistrationsCache) {
|
|
5510
|
-
if (
|
|
5536
|
+
if (entry.formInstanceId !== formInstanceId) continue;
|
|
5511
5537
|
if (!entry.element.isConnected) continue;
|
|
5512
5538
|
if (entry.element.offsetParent === null) continue;
|
|
5513
5539
|
if (getErrorsForPath(entry.path).length === 0) continue;
|
|
5514
|
-
|
|
5540
|
+
const element = entry.host ? resolveHostFocusTarget(entry.element) : entry.element;
|
|
5541
|
+
return { path: entry.path, element };
|
|
5515
5542
|
}
|
|
5516
5543
|
return null;
|
|
5517
5544
|
}
|
|
5518
5545
|
function rebuildSortedRegistrations() {
|
|
5519
5546
|
const flat = [];
|
|
5520
5547
|
for (const [, record] of elements) {
|
|
5521
|
-
for (const el of record.elements)
|
|
5548
|
+
for (const el of record.elements) {
|
|
5549
|
+
flat.push({
|
|
5550
|
+
path: record.path,
|
|
5551
|
+
element: el,
|
|
5552
|
+
host: false,
|
|
5553
|
+
formInstanceId: elementToFormInstance.get(el) ?? ""
|
|
5554
|
+
});
|
|
5555
|
+
}
|
|
5556
|
+
}
|
|
5557
|
+
for (const [key, target] of hostTargets) {
|
|
5558
|
+
if (elements.has(key)) continue;
|
|
5559
|
+
flat.push({
|
|
5560
|
+
path: target.path,
|
|
5561
|
+
element: target.hostRoot,
|
|
5562
|
+
host: true,
|
|
5563
|
+
formInstanceId: target.formInstanceId
|
|
5564
|
+
});
|
|
5522
5565
|
}
|
|
5523
5566
|
flat.sort(
|
|
5524
5567
|
(a, b) => a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1
|
|
@@ -6689,24 +6732,6 @@ function useWizard(options) {
|
|
|
6689
6732
|
(slot) => isGateMarker(slot) || isLazyMarker(slot) || typeof slot === "function"
|
|
6690
6733
|
);
|
|
6691
6734
|
const clearedGates = vue.reactive(/* @__PURE__ */ new Set());
|
|
6692
|
-
const seededSampled = /* @__PURE__ */ new Set();
|
|
6693
|
-
function isGateVerdictSettled(key) {
|
|
6694
|
-
const store = registry.forms.get(key);
|
|
6695
|
-
if (store === void 0) return false;
|
|
6696
|
-
return store.defaultsResolved.value === true && store.firstValidationDone.value === true && store.activeValidations.value === 0;
|
|
6697
|
-
}
|
|
6698
|
-
function isGateFormValid(key) {
|
|
6699
|
-
const form = formsRecord.value[key] ?? formsAccumulator.get(key);
|
|
6700
|
-
if (form === void 0) return false;
|
|
6701
|
-
return asStatusSource(form).meta?.valid ?? false;
|
|
6702
|
-
}
|
|
6703
|
-
function sampleSeededGate(key) {
|
|
6704
|
-
if (seededSampled.has(key)) return;
|
|
6705
|
-
if (noopForms.has(key)) return;
|
|
6706
|
-
if (!isGateVerdictSettled(key)) return;
|
|
6707
|
-
seededSampled.add(key);
|
|
6708
|
-
if (isGateFormValid(key)) clearedGates.add(key);
|
|
6709
|
-
}
|
|
6710
6735
|
const gateSubs = /* @__PURE__ */ new Map();
|
|
6711
6736
|
function reconcileGates() {
|
|
6712
6737
|
const gateKeys = /* @__PURE__ */ new Set();
|
|
@@ -6723,7 +6748,6 @@ function useWizard(options) {
|
|
|
6723
6748
|
);
|
|
6724
6749
|
}
|
|
6725
6750
|
}
|
|
6726
|
-
sampleSeededGate(key);
|
|
6727
6751
|
}
|
|
6728
6752
|
for (const [key, unsub] of gateSubs) {
|
|
6729
6753
|
if (!gateKeys.has(key)) {
|
|
@@ -6781,8 +6805,7 @@ function useWizard(options) {
|
|
|
6781
6805
|
for (const step of compiledSteps.value) {
|
|
6782
6806
|
if (!step.isGate) continue;
|
|
6783
6807
|
const store = registry.forms.get(step.key);
|
|
6784
|
-
|
|
6785
|
-
parts.push(`${step.key}:${store !== void 0 ? 1 : 0}:${settled ? 1 : 0}`);
|
|
6808
|
+
parts.push(`${step.key}:${store !== void 0 ? 1 : 0}`);
|
|
6786
6809
|
}
|
|
6787
6810
|
return parts.join("|");
|
|
6788
6811
|
},
|
|
@@ -6815,20 +6838,30 @@ function useWizard(options) {
|
|
|
6815
6838
|
});
|
|
6816
6839
|
}
|
|
6817
6840
|
}
|
|
6841
|
+
function applyGateSeed(map) {
|
|
6842
|
+
if (map === void 0 || !mightGate) return;
|
|
6843
|
+
const gates = gatePositions.value;
|
|
6844
|
+
for (const key of Object.keys(map)) {
|
|
6845
|
+
if (map[key]?.gate === "cleared" && gates.includes(key)) clearedGates.add(key);
|
|
6846
|
+
}
|
|
6847
|
+
}
|
|
6818
6848
|
const seedRef = vue.ref(void 0);
|
|
6819
6849
|
const seedInput = options.defaultStatuses;
|
|
6820
6850
|
if (seedInput !== void 0) {
|
|
6821
6851
|
const resolved = resolveTrichotomy(seedInput);
|
|
6822
6852
|
if (resolved.kind === "sync") {
|
|
6823
6853
|
seedRef.value = resolved.value;
|
|
6854
|
+
applyGateSeed(resolved.value);
|
|
6824
6855
|
} else {
|
|
6825
6856
|
const eager = resolved.factory();
|
|
6826
6857
|
if (eager instanceof Promise) {
|
|
6827
6858
|
void eager.then((value) => {
|
|
6828
6859
|
seedRef.value = value;
|
|
6860
|
+
applyGateSeed(value);
|
|
6829
6861
|
});
|
|
6830
6862
|
} else {
|
|
6831
6863
|
seedRef.value = eager;
|
|
6864
|
+
applyGateSeed(eager);
|
|
6832
6865
|
}
|
|
6833
6866
|
}
|
|
6834
6867
|
}
|
|
@@ -6860,7 +6893,7 @@ function useWizard(options) {
|
|
|
6860
6893
|
return locked || gate !== null ? { ...NOOP_VALID_STATUS, locked, gate } : NOOP_VALID_STATUS;
|
|
6861
6894
|
}
|
|
6862
6895
|
const seed = seedRef.value?.[form.key];
|
|
6863
|
-
if (seed !== void 0) return { ...seed, locked, gate };
|
|
6896
|
+
if (seed !== void 0) return { ...PENDING_STATUS, ...seed, locked, gate };
|
|
6864
6897
|
return locked || gate !== null ? { ...PENDING_STATUS, locked, gate } : PENDING_STATUS;
|
|
6865
6898
|
});
|
|
6866
6899
|
statusCache.set(form.key, computedStatus);
|
|
@@ -7352,14 +7385,16 @@ function useWizard(options) {
|
|
|
7352
7385
|
submitError.value = null;
|
|
7353
7386
|
if (mightGate) {
|
|
7354
7387
|
clearedGates.clear();
|
|
7355
|
-
seededSampled.clear();
|
|
7356
7388
|
}
|
|
7357
7389
|
lazyEpoch.value += 1;
|
|
7358
7390
|
for (const step of compiledSteps.value) {
|
|
7359
7391
|
const full = asSubmissionSource(step.form);
|
|
7360
7392
|
if (typeof full.reset === "function") full.reset();
|
|
7361
7393
|
}
|
|
7362
|
-
if (mightGate)
|
|
7394
|
+
if (mightGate) {
|
|
7395
|
+
reconcileGates();
|
|
7396
|
+
applyGateSeed(seedRef.value);
|
|
7397
|
+
}
|
|
7363
7398
|
const firstStep = compiledSteps.value[0];
|
|
7364
7399
|
if (firstStep !== void 0) {
|
|
7365
7400
|
const landing = commitActiveKey(firstStep.key);
|
|
@@ -7370,6 +7405,29 @@ function useWizard(options) {
|
|
|
7370
7405
|
}
|
|
7371
7406
|
}
|
|
7372
7407
|
}
|
|
7408
|
+
async function relock(key, commit) {
|
|
7409
|
+
if (!mightGate || !gatePositions.value.includes(key)) {
|
|
7410
|
+
if (devtoolsShared.__DEV__) {
|
|
7411
|
+
console.warn(
|
|
7412
|
+
`[attaform] useWizard.relock(${JSON.stringify(key)}): no gate at that key; nothing to re-lock.`
|
|
7413
|
+
);
|
|
7414
|
+
}
|
|
7415
|
+
return false;
|
|
7416
|
+
}
|
|
7417
|
+
try {
|
|
7418
|
+
await commit();
|
|
7419
|
+
} catch (err) {
|
|
7420
|
+
if (devtoolsShared.__DEV__) {
|
|
7421
|
+
console.warn(
|
|
7422
|
+
`[attaform] useWizard.relock(${JSON.stringify(key)}): commit threw, so the gate was not re-sealed.`,
|
|
7423
|
+
err
|
|
7424
|
+
);
|
|
7425
|
+
}
|
|
7426
|
+
return false;
|
|
7427
|
+
}
|
|
7428
|
+
clearedGates.delete(key);
|
|
7429
|
+
return true;
|
|
7430
|
+
}
|
|
7373
7431
|
if (mightGate) {
|
|
7374
7432
|
vue.watchEffect(() => {
|
|
7375
7433
|
const key = activeKey.value;
|
|
@@ -7395,6 +7453,7 @@ function useWizard(options) {
|
|
|
7395
7453
|
tryNext,
|
|
7396
7454
|
handleSubmit,
|
|
7397
7455
|
reset,
|
|
7456
|
+
relock,
|
|
7398
7457
|
get currentStep() {
|
|
7399
7458
|
return currentStep.value;
|
|
7400
7459
|
},
|
|
@@ -7597,4 +7656,4 @@ exports.unset = unset;
|
|
|
7597
7656
|
exports.useAbstractForm = useAbstractForm;
|
|
7598
7657
|
exports.useRegister = useRegister;
|
|
7599
7658
|
exports.useWizard = useWizard;
|
|
7600
|
-
//# sourceMappingURL=attaform.
|
|
7659
|
+
//# sourceMappingURL=attaform.Cg1rUfcF.cjs.map
|