attaform 0.27.2 → 0.27.4

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.
Files changed (51) hide show
  1. package/dist/abstract.cjs +1 -1
  2. package/dist/abstract.d.cts +2 -2
  3. package/dist/abstract.d.mts +2 -2
  4. package/dist/abstract.d.ts +2 -2
  5. package/dist/abstract.mjs +1 -1
  6. package/dist/chunks/fingerprint2.cjs +1 -1
  7. package/dist/chunks/fingerprint2.mjs +1 -1
  8. package/dist/index.cjs +2 -2
  9. package/dist/index.d.cts +1 -1
  10. package/dist/index.d.mts +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.mjs +2 -2
  13. package/dist/shared/{attaform.BF1mYHru.cjs → attaform.B3spfqIA.cjs} +3 -3
  14. package/dist/shared/{attaform.BF1mYHru.cjs.map → attaform.B3spfqIA.cjs.map} +1 -1
  15. package/dist/shared/{attaform.gyed1fGh.mjs → attaform.BrVzB14N.mjs} +3 -3
  16. package/dist/shared/{attaform.gyed1fGh.mjs.map → attaform.BrVzB14N.mjs.map} +1 -1
  17. package/dist/shared/{attaform.C1SJy524.cjs → attaform.C9arOC5p.cjs} +4 -4
  18. package/dist/shared/{attaform.C1SJy524.cjs.map → attaform.C9arOC5p.cjs.map} +1 -1
  19. package/dist/shared/{attaform.6IZBjA1Q.mjs → attaform.CC4KCx_q.mjs} +4 -4
  20. package/dist/shared/{attaform.6IZBjA1Q.mjs.map → attaform.CC4KCx_q.mjs.map} +1 -1
  21. package/dist/shared/{attaform.CIPwCQe8.cjs → attaform.CX2NHAFs.cjs} +2 -2
  22. package/dist/shared/{attaform.CIPwCQe8.cjs.map → attaform.CX2NHAFs.cjs.map} +1 -1
  23. package/dist/shared/{attaform.DIJTp_Kv.d.cts → attaform.Cjh6b6xU.d.cts} +64 -16
  24. package/dist/shared/{attaform.DGCijpZT.mjs → attaform.CuUx4jWI.mjs} +53 -30
  25. package/dist/shared/{attaform.CXHebpij.cjs.map → attaform.CuUx4jWI.mjs.map} +1 -1
  26. package/dist/shared/{attaform.B2d0FszH.d.ts → attaform.DKtXMaJB.d.ts} +64 -16
  27. package/dist/shared/{attaform.CvaPYOZu.cjs → attaform.DXwJVUNS.cjs} +3 -3
  28. package/dist/shared/{attaform.CvaPYOZu.cjs.map → attaform.DXwJVUNS.cjs.map} +1 -1
  29. package/dist/shared/{attaform.CXHebpij.cjs → attaform.Ib2seKUE.cjs} +53 -30
  30. package/dist/shared/{attaform.DGCijpZT.mjs.map → attaform.Ib2seKUE.cjs.map} +1 -1
  31. package/dist/shared/{attaform.BAlfXoAx.mjs → attaform.a1GnhjVk.mjs} +2 -2
  32. package/dist/shared/{attaform.BAlfXoAx.mjs.map → attaform.a1GnhjVk.mjs.map} +1 -1
  33. package/dist/shared/{attaform.Dcj-OS43.d.mts → attaform.gj8dtOlx.d.mts} +64 -16
  34. package/dist/shared/{attaform.yOE3udL1.mjs → attaform.shkNCMEz.mjs} +3 -3
  35. package/dist/shared/{attaform.yOE3udL1.mjs.map → attaform.shkNCMEz.mjs.map} +1 -1
  36. package/dist/zod-v3.cjs +2 -2
  37. package/dist/zod-v3.d.cts +1 -1
  38. package/dist/zod-v3.d.mts +1 -1
  39. package/dist/zod-v3.d.ts +1 -1
  40. package/dist/zod-v3.mjs +2 -2
  41. package/dist/zod-v4.cjs +2 -2
  42. package/dist/zod-v4.d.cts +2 -2
  43. package/dist/zod-v4.d.mts +2 -2
  44. package/dist/zod-v4.d.ts +2 -2
  45. package/dist/zod-v4.mjs +2 -2
  46. package/dist/zod.cjs +2 -2
  47. package/dist/zod.d.cts +1 -1
  48. package/dist/zod.d.mts +1 -1
  49. package/dist/zod.d.ts +1 -1
  50. package/dist/zod.mjs +2 -2
  51. package/package.json +1 -1
@@ -6348,14 +6348,16 @@ const PENDING_STATUS = {
6348
6348
  dirty: false,
6349
6349
  submitted: false,
6350
6350
  errorCount: 0,
6351
- locked: false
6351
+ locked: false,
6352
+ gate: null
6352
6353
  };
6353
6354
  const NOOP_VALID_STATUS = {
6354
6355
  valid: true,
6355
6356
  dirty: false,
6356
6357
  submitted: false,
6357
6358
  errorCount: 0,
6358
- locked: false
6359
+ locked: false,
6360
+ gate: null
6359
6361
  };
6360
6362
  const EMPTY_LOCK_SET = /* @__PURE__ */ new Set();
6361
6363
  function asStatusSource(form) {
@@ -6687,24 +6689,6 @@ function useWizard(options) {
6687
6689
  (slot) => isGateMarker(slot) || isLazyMarker(slot) || typeof slot === "function"
6688
6690
  );
6689
6691
  const clearedGates = vue.reactive(/* @__PURE__ */ new Set());
6690
- const seededSampled = /* @__PURE__ */ new Set();
6691
- function isGateVerdictSettled(key) {
6692
- const store = registry.forms.get(key);
6693
- if (store === void 0) return false;
6694
- return store.defaultsResolved.value === true && store.firstValidationDone.value === true && store.activeValidations.value === 0;
6695
- }
6696
- function isGateFormValid(key) {
6697
- const form = formsRecord.value[key] ?? formsAccumulator.get(key);
6698
- if (form === void 0) return false;
6699
- return asStatusSource(form).meta?.valid ?? false;
6700
- }
6701
- function sampleSeededGate(key) {
6702
- if (seededSampled.has(key)) return;
6703
- if (noopForms.has(key)) return;
6704
- if (!isGateVerdictSettled(key)) return;
6705
- seededSampled.add(key);
6706
- if (isGateFormValid(key)) clearedGates.add(key);
6707
- }
6708
6692
  const gateSubs = /* @__PURE__ */ new Map();
6709
6693
  function reconcileGates() {
6710
6694
  const gateKeys = /* @__PURE__ */ new Set();
@@ -6721,7 +6705,6 @@ function useWizard(options) {
6721
6705
  );
6722
6706
  }
6723
6707
  }
6724
- sampleSeededGate(key);
6725
6708
  }
6726
6709
  for (const [key, unsub] of gateSubs) {
6727
6710
  if (!gateKeys.has(key)) {
@@ -6779,8 +6762,7 @@ function useWizard(options) {
6779
6762
  for (const step of compiledSteps.value) {
6780
6763
  if (!step.isGate) continue;
6781
6764
  const store = registry.forms.get(step.key);
6782
- const settled = store !== void 0 && isGateVerdictSettled(step.key);
6783
- parts.push(`${step.key}:${store !== void 0 ? 1 : 0}:${settled ? 1 : 0}`);
6765
+ parts.push(`${step.key}:${store !== void 0 ? 1 : 0}`);
6784
6766
  }
6785
6767
  return parts.join("|");
6786
6768
  },
@@ -6813,20 +6795,30 @@ function useWizard(options) {
6813
6795
  });
6814
6796
  }
6815
6797
  }
6798
+ function applyGateSeed(map) {
6799
+ if (map === void 0 || !mightGate) return;
6800
+ const gates = gatePositions.value;
6801
+ for (const key of Object.keys(map)) {
6802
+ if (map[key]?.gate === "cleared" && gates.includes(key)) clearedGates.add(key);
6803
+ }
6804
+ }
6816
6805
  const seedRef = vue.ref(void 0);
6817
6806
  const seedInput = options.defaultStatuses;
6818
6807
  if (seedInput !== void 0) {
6819
6808
  const resolved = resolveTrichotomy(seedInput);
6820
6809
  if (resolved.kind === "sync") {
6821
6810
  seedRef.value = resolved.value;
6811
+ applyGateSeed(resolved.value);
6822
6812
  } else {
6823
6813
  const eager = resolved.factory();
6824
6814
  if (eager instanceof Promise) {
6825
6815
  void eager.then((value) => {
6826
6816
  seedRef.value = value;
6817
+ applyGateSeed(value);
6827
6818
  });
6828
6819
  } else {
6829
6820
  seedRef.value = eager;
6821
+ applyGateSeed(eager);
6830
6822
  }
6831
6823
  }
6832
6824
  }
@@ -6837,6 +6829,10 @@ function useWizard(options) {
6837
6829
  const source = asStatusSource(form);
6838
6830
  const computedStatus = vue.computed(() => {
6839
6831
  const locked = navLockSet.value.has(form.key);
6832
+ let gate = null;
6833
+ if (gatePositions.value.includes(form.key)) {
6834
+ gate = clearedGates.has(form.key) ? "cleared" : "uncleared";
6835
+ }
6840
6836
  if (isFormReady(form.key)) {
6841
6837
  const meta = source.meta;
6842
6838
  if (meta !== void 0 && meta !== null) {
@@ -6845,16 +6841,17 @@ function useWizard(options) {
6845
6841
  dirty: meta.dirty,
6846
6842
  submitted: meta.submitted,
6847
6843
  errorCount: meta.errorCount,
6848
- locked
6844
+ locked,
6845
+ gate
6849
6846
  };
6850
6847
  }
6851
6848
  }
6852
6849
  if (noopForms.has(form.key)) {
6853
- return locked ? { ...NOOP_VALID_STATUS, locked: true } : NOOP_VALID_STATUS;
6850
+ return locked || gate !== null ? { ...NOOP_VALID_STATUS, locked, gate } : NOOP_VALID_STATUS;
6854
6851
  }
6855
6852
  const seed = seedRef.value?.[form.key];
6856
- if (seed !== void 0) return { ...seed, locked };
6857
- return locked ? { ...PENDING_STATUS, locked: true } : PENDING_STATUS;
6853
+ if (seed !== void 0) return { ...PENDING_STATUS, ...seed, locked, gate };
6854
+ return locked || gate !== null ? { ...PENDING_STATUS, locked, gate } : PENDING_STATUS;
6858
6855
  });
6859
6856
  statusCache.set(form.key, computedStatus);
6860
6857
  return computedStatus;
@@ -7345,14 +7342,16 @@ function useWizard(options) {
7345
7342
  submitError.value = null;
7346
7343
  if (mightGate) {
7347
7344
  clearedGates.clear();
7348
- seededSampled.clear();
7349
7345
  }
7350
7346
  lazyEpoch.value += 1;
7351
7347
  for (const step of compiledSteps.value) {
7352
7348
  const full = asSubmissionSource(step.form);
7353
7349
  if (typeof full.reset === "function") full.reset();
7354
7350
  }
7355
- if (mightGate) reconcileGates();
7351
+ if (mightGate) {
7352
+ reconcileGates();
7353
+ applyGateSeed(seedRef.value);
7354
+ }
7356
7355
  const firstStep = compiledSteps.value[0];
7357
7356
  if (firstStep !== void 0) {
7358
7357
  const landing = commitActiveKey(firstStep.key);
@@ -7363,6 +7362,29 @@ function useWizard(options) {
7363
7362
  }
7364
7363
  }
7365
7364
  }
7365
+ async function relock(key, commit) {
7366
+ if (!mightGate || !gatePositions.value.includes(key)) {
7367
+ if (devtoolsShared.__DEV__) {
7368
+ console.warn(
7369
+ `[attaform] useWizard.relock(${JSON.stringify(key)}): no gate at that key; nothing to re-lock.`
7370
+ );
7371
+ }
7372
+ return false;
7373
+ }
7374
+ try {
7375
+ await commit();
7376
+ } catch (err) {
7377
+ if (devtoolsShared.__DEV__) {
7378
+ console.warn(
7379
+ `[attaform] useWizard.relock(${JSON.stringify(key)}): commit threw, so the gate was not re-sealed.`,
7380
+ err
7381
+ );
7382
+ }
7383
+ return false;
7384
+ }
7385
+ clearedGates.delete(key);
7386
+ return true;
7387
+ }
7366
7388
  if (mightGate) {
7367
7389
  vue.watchEffect(() => {
7368
7390
  const key = activeKey.value;
@@ -7388,6 +7410,7 @@ function useWizard(options) {
7388
7410
  tryNext,
7389
7411
  handleSubmit,
7390
7412
  reset,
7413
+ relock,
7391
7414
  get currentStep() {
7392
7415
  return currentStep.value;
7393
7416
  },
@@ -7590,4 +7613,4 @@ exports.unset = unset;
7590
7613
  exports.useAbstractForm = useAbstractForm;
7591
7614
  exports.useRegister = useRegister;
7592
7615
  exports.useWizard = useWizard;
7593
- //# sourceMappingURL=attaform.CXHebpij.cjs.map
7616
+ //# sourceMappingURL=attaform.Ib2seKUE.cjs.map