attaform 0.24.4 → 0.25.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.
Files changed (89) hide show
  1. package/dist/chunks/devtools.cjs +1 -1
  2. package/dist/chunks/devtools.mjs +1 -1
  3. package/dist/chunks/fingerprint2.cjs +1 -1
  4. package/dist/chunks/fingerprint2.mjs +1 -1
  5. package/dist/index.cjs +4 -4
  6. package/dist/index.d.cts +4 -4
  7. package/dist/index.d.mts +4 -4
  8. package/dist/index.d.ts +4 -4
  9. package/dist/index.mjs +4 -4
  10. package/dist/nuxt.d.cts +1 -1
  11. package/dist/nuxt.d.mts +1 -1
  12. package/dist/nuxt.d.ts +1 -1
  13. package/dist/runtime/plugins/attaform.cjs +2 -2
  14. package/dist/runtime/plugins/attaform.mjs +2 -2
  15. package/dist/shared/{attaform.CAVK56f8.cjs → attaform.3heDHayA.cjs} +25 -2
  16. package/dist/shared/attaform.3heDHayA.cjs.map +1 -0
  17. package/dist/shared/{attaform.B1N47eDM.d.ts → attaform.8vmdOURQ.d.mts} +116 -56
  18. package/dist/shared/{attaform.EeVCVnoH.d.ts → attaform.B3cgZE3c.d.ts} +1 -1
  19. package/dist/shared/{attaform.CqW4gF_Z.d.cts → attaform.B5GFS3Su.d.cts} +116 -56
  20. package/dist/shared/{attaform.CBMI57RP.cjs → attaform.B5YcWrKi.cjs} +3 -3
  21. package/dist/shared/{attaform.CBMI57RP.cjs.map → attaform.B5YcWrKi.cjs.map} +1 -1
  22. package/dist/shared/{attaform.Ib7oSpxj.d.cts → attaform.BJt4ZCkM.d.mts} +1 -1
  23. package/dist/shared/{attaform.DWKcw1ud.cjs → attaform.BRzKBj2g.cjs} +101 -4
  24. package/dist/shared/attaform.BRzKBj2g.cjs.map +1 -0
  25. package/dist/shared/{attaform.Buedl_UL.cjs → attaform.BkUzunyB.cjs} +116 -38
  26. package/dist/shared/attaform.BkUzunyB.cjs.map +1 -0
  27. package/dist/shared/{attaform.ChY7tIrn.mjs → attaform.CN4ZEGo6.mjs} +4 -4
  28. package/dist/shared/{attaform.ChY7tIrn.mjs.map → attaform.CN4ZEGo6.mjs.map} +1 -1
  29. package/dist/shared/{attaform.DwsfkfSY.mjs → attaform.CqwcTExO.mjs} +25 -2
  30. package/dist/shared/attaform.CqwcTExO.mjs.map +1 -0
  31. package/dist/shared/{attaform.lcTiMoma.mjs → attaform.CwXXbZIQ.mjs} +3 -3
  32. package/dist/shared/{attaform.lcTiMoma.mjs.map → attaform.CwXXbZIQ.mjs.map} +1 -1
  33. package/dist/shared/{attaform.iJ4y3sHU.mjs → attaform.DK3xUBkj.mjs} +116 -38
  34. package/dist/shared/attaform.DK3xUBkj.mjs.map +1 -0
  35. package/dist/shared/{attaform.CwqTCeTZ.mjs → attaform.DMNnfQq_.mjs} +4 -4
  36. package/dist/shared/{attaform.CwqTCeTZ.mjs.map → attaform.DMNnfQq_.mjs.map} +1 -1
  37. package/dist/shared/{attaform.f0l5ydy1.d.mts → attaform.DS_zBcdr.d.ts} +116 -56
  38. package/dist/shared/{attaform.DTn1J0Eq.d.mts → attaform.DmKLa4tL.d.cts} +1 -1
  39. package/dist/shared/{attaform.CZpUm-2l.mjs → attaform.OLtKd9gM.mjs} +2 -2
  40. package/dist/shared/{attaform.CZpUm-2l.mjs.map → attaform.OLtKd9gM.mjs.map} +1 -1
  41. package/dist/shared/{attaform.WvcckZMD.mjs → attaform.Vp2-CWZB.mjs} +3 -2
  42. package/dist/shared/attaform.Vp2-CWZB.mjs.map +1 -0
  43. package/dist/shared/{attaform.Bnm0FQaH.cjs → attaform.Xe8dATED.cjs} +4 -4
  44. package/dist/shared/{attaform.Bnm0FQaH.cjs.map → attaform.Xe8dATED.cjs.map} +1 -1
  45. package/dist/shared/{attaform.CjdepGnw.cjs → attaform.ZXZ6dH72.cjs} +3 -1
  46. package/dist/shared/attaform.ZXZ6dH72.cjs.map +1 -0
  47. package/dist/shared/{attaform.QFrCtJBO.d.mts → attaform.i_LA3X9o.d.cts} +16 -2
  48. package/dist/shared/{attaform.QFrCtJBO.d.cts → attaform.i_LA3X9o.d.mts} +16 -2
  49. package/dist/shared/{attaform.QFrCtJBO.d.ts → attaform.i_LA3X9o.d.ts} +16 -2
  50. package/dist/shared/{attaform.QwLSdxuk.mjs → attaform.k9V0py0s.mjs} +101 -5
  51. package/dist/shared/attaform.k9V0py0s.mjs.map +1 -0
  52. package/dist/shared/{attaform.CE-KJZ0j.cjs → attaform.sks1MFVO.cjs} +4 -4
  53. package/dist/shared/{attaform.CE-KJZ0j.cjs.map → attaform.sks1MFVO.cjs.map} +1 -1
  54. package/dist/shared/{attaform.AkX9wzfY.cjs → attaform.xBDo0Ko0.cjs} +2 -2
  55. package/dist/shared/{attaform.AkX9wzfY.cjs.map → attaform.xBDo0Ko0.cjs.map} +1 -1
  56. package/dist/transforms.cjs +2 -1
  57. package/dist/transforms.cjs.map +1 -1
  58. package/dist/transforms.d.cts +13 -1
  59. package/dist/transforms.d.mts +13 -1
  60. package/dist/transforms.d.ts +13 -1
  61. package/dist/transforms.mjs +1 -1
  62. package/dist/vite.cjs +2 -1
  63. package/dist/vite.cjs.map +1 -1
  64. package/dist/vite.mjs +2 -1
  65. package/dist/vite.mjs.map +1 -1
  66. package/dist/zod-v3.cjs +2 -2
  67. package/dist/zod-v3.d.cts +3 -3
  68. package/dist/zod-v3.d.mts +3 -3
  69. package/dist/zod-v3.d.ts +3 -3
  70. package/dist/zod-v3.mjs +2 -2
  71. package/dist/zod-v4.cjs +2 -2
  72. package/dist/zod-v4.d.cts +5 -5
  73. package/dist/zod-v4.d.mts +5 -5
  74. package/dist/zod-v4.d.ts +5 -5
  75. package/dist/zod-v4.mjs +2 -2
  76. package/dist/zod.cjs +5 -5
  77. package/dist/zod.d.cts +5 -5
  78. package/dist/zod.d.mts +5 -5
  79. package/dist/zod.d.ts +5 -5
  80. package/dist/zod.mjs +5 -5
  81. package/package.json +1 -1
  82. package/dist/shared/attaform.Buedl_UL.cjs.map +0 -1
  83. package/dist/shared/attaform.CAVK56f8.cjs.map +0 -1
  84. package/dist/shared/attaform.CjdepGnw.cjs.map +0 -1
  85. package/dist/shared/attaform.DWKcw1ud.cjs.map +0 -1
  86. package/dist/shared/attaform.DwsfkfSY.mjs.map +0 -1
  87. package/dist/shared/attaform.QwLSdxuk.mjs.map +0 -1
  88. package/dist/shared/attaform.WvcckZMD.mjs.map +0 -1
  89. package/dist/shared/attaform.iJ4y3sHU.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { computed, ref, watchEffect, getCurrentScope, onScopeDispose, shallowReadonly, nextTick, warn, readonly, toRaw, reactive, watch, markRaw, triggerRef, shallowRef, getCurrentInstance, onServerPrefetch, provide, useId, inject, onBeforeMount, onBeforeUpdate, onMounted, effectScope } from 'vue';
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.DwsfkfSY.mjs';
3
- import { R as REGISTER_OWNER_MARKER, V as V_REGISTER_MARKER } from './attaform.WvcckZMD.mjs';
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.CqwcTExO.mjs';
3
+ import { R as REGISTER_OWNER_MARKER, b as V_REGISTER_MARKER } from './attaform.Vp2-CWZB.mjs';
4
4
 
5
5
  function safeAssign(target, key, value) {
6
6
  if (key === "__proto__") {
@@ -2018,11 +2018,11 @@ function applyInvalidSubmitPolicy(state, formInstanceId, policy) {
2018
2018
  return;
2019
2019
  }
2020
2020
  if (policy === "focus-first-error") {
2021
- target.element.focus();
2021
+ target.element.focus({ focusVisible: true });
2022
2022
  return;
2023
2023
  }
2024
2024
  target.element.scrollIntoView();
2025
- target.element.focus({ preventScroll: true });
2025
+ target.element.focus({ preventScroll: true, focusVisible: true });
2026
2026
  }
2027
2027
 
2028
2028
  const warnedRejections = __DEV__ ? /* @__PURE__ */ new WeakMap() : null;
@@ -3227,7 +3227,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
3227
3227
  const focusFirstError = (options2) => {
3228
3228
  const target = state.getFirstErrorElement(formInstanceId);
3229
3229
  if (target === null) return false;
3230
- target.element.focus(options2);
3230
+ target.element.focus({ focusVisible: true, ...options2 });
3231
3231
  return true;
3232
3232
  };
3233
3233
  const scrollToFirstError = (options2) => {
@@ -5364,10 +5364,7 @@ function createFormStore(options) {
5364
5364
  if (elementToFormInstance.get(entry.element) !== formInstanceId) continue;
5365
5365
  if (!entry.element.isConnected) continue;
5366
5366
  if (entry.element.offsetParent === null) continue;
5367
- const { key } = canonicalizePath(entry.path);
5368
- const hasSchemaErr = (schemaErrors.get(key)?.length ?? 0) > 0;
5369
- const hasUserErr = (userErrors.get(key)?.length ?? 0) > 0;
5370
- if (!hasSchemaErr && !hasUserErr) continue;
5367
+ if (getErrorsForPath(entry.path).length === 0) continue;
5371
5368
  return { path: entry.path, element: entry.element };
5372
5369
  }
5373
5370
  return null;
@@ -5947,7 +5944,7 @@ function resolveState(key, registry) {
5947
5944
  if (key !== void 0) {
5948
5945
  const stored = registry.forms.get(key);
5949
5946
  if (stored === void 0) {
5950
- warnMiss$1(`no form registered for key '${key}'`, registry.ssr);
5947
+ warnMiss$1(`no form registered for key '${key}'`, registry.ssr, registry.forms);
5951
5948
  return null;
5952
5949
  }
5953
5950
  return stored;
@@ -5957,12 +5954,22 @@ function resolveState(key, registry) {
5957
5954
  warnIfAmbientProviderHadDuplicates();
5958
5955
  return ambient;
5959
5956
  }
5960
- function warnMiss$1(detail, ssr) {
5957
+ function availableKeysHint$1(forms) {
5958
+ const addressable = [...forms.keys()].filter((key) => !key.startsWith(RESERVED_KEY_PREFIX));
5959
+ if (addressable.length === 0) return void 0;
5960
+ return `Registered keys: ${addressable.map((key) => `'${key}'`).join(", ")}.`;
5961
+ }
5962
+ function warnMiss$1(detail, ssr, forms) {
5961
5963
  if (!__DEV__ || ssr) return;
5962
5964
  const frame = captureUserCallSite();
5963
- console.warn(
5964
- `[attaform] injectForm: ${detail}. Returning null.` + (frame !== void 0 ? ` ${frame}` : "")
5965
+ const parts = [`[attaform] injectForm: ${detail}. Returning null.`];
5966
+ const keys = availableKeysHint$1(forms);
5967
+ if (keys !== void 0) parts.push(keys);
5968
+ parts.push(
5969
+ `A form created by a child or sibling component is not registered until that component's own setup runs, which happens after this point. Lift its useForm({ key }) call to a common ancestor, or read the form after mount.`
5965
5970
  );
5971
+ if (frame !== void 0) parts.push(frame);
5972
+ console.warn(parts.join(" "));
5966
5973
  }
5967
5974
  function warnIfAmbientProviderHadDuplicates() {
5968
5975
  if (!__DEV__ || ambientProvideHistory === null) return;
@@ -6222,6 +6229,9 @@ function asStatusSource(form) {
6222
6229
  function asSubmissionSource(form) {
6223
6230
  return form;
6224
6231
  }
6232
+ function asHandleSubmitSource(form) {
6233
+ return form;
6234
+ }
6225
6235
  function useWizard(options) {
6226
6236
  const rawSteps = Array.isArray(options.steps) ? options.steps : [];
6227
6237
  if (rawSteps.length === 0 && __DEV__) {
@@ -6316,6 +6326,7 @@ function useWizard(options) {
6316
6326
  }
6317
6327
  };
6318
6328
  function resolveSlot(slot, index, ctx) {
6329
+ if (slot === void 0 || slot === null) return void 0;
6319
6330
  if (typeof slot === "string") {
6320
6331
  return getOrBuildNoop(slot);
6321
6332
  }
@@ -6331,7 +6342,7 @@ function useWizard(options) {
6331
6342
  return void 0;
6332
6343
  }
6333
6344
  function resolveSlotResult(result) {
6334
- if (result === void 0) return void 0;
6345
+ if (result === void 0 || result === null) return void 0;
6335
6346
  if (typeof result === "string") {
6336
6347
  return getOrBuildNoop(result);
6337
6348
  }
@@ -6399,6 +6410,50 @@ function useWizard(options) {
6399
6410
  const first = list[0];
6400
6411
  return first === void 0 ? void 0 : first.form;
6401
6412
  });
6413
+ watch(compiledSteps, (list, prevList) => {
6414
+ const key = activeKey.value;
6415
+ if (key === "") return;
6416
+ if (list.some((step) => step.key === key)) return;
6417
+ if (list.length === 0) {
6418
+ activeKey.value = "";
6419
+ return;
6420
+ }
6421
+ const oldIndex = prevList.findIndex((step) => step.key === key);
6422
+ const slid = list[oldIndex < 0 ? 0 : Math.min(oldIndex, list.length - 1)];
6423
+ if (slid !== void 0) activeKey.value = slid.key;
6424
+ });
6425
+ const activeFormFacade = new Proxy({}, {
6426
+ get(_target, prop) {
6427
+ const form = activeForm.value;
6428
+ if (form === void 0) return void 0;
6429
+ if (prop === "handleSubmit") {
6430
+ const lateBound = (onValid, onInvalid) => {
6431
+ return (event) => {
6432
+ const current = activeForm.value;
6433
+ if (current === void 0) return Promise.resolve();
6434
+ return asHandleSubmitSource(current).handleSubmit(onValid, onInvalid)(event);
6435
+ };
6436
+ };
6437
+ return lateBound;
6438
+ }
6439
+ return Reflect.get(form, prop, form);
6440
+ },
6441
+ has(_target, prop) {
6442
+ const form = activeForm.value;
6443
+ return form === void 0 ? false : Reflect.has(form, prop);
6444
+ },
6445
+ ownKeys(_target) {
6446
+ const form = activeForm.value;
6447
+ return form === void 0 ? [] : Reflect.ownKeys(form);
6448
+ },
6449
+ getOwnPropertyDescriptor(_target, prop) {
6450
+ const form = activeForm.value;
6451
+ if (form === void 0) return void 0;
6452
+ const descriptor = Reflect.getOwnPropertyDescriptor(form, prop);
6453
+ if (descriptor === void 0) return void 0;
6454
+ return { ...descriptor, configurable: true };
6455
+ }
6456
+ });
6402
6457
  const isFinalStep = computed(() => {
6403
6458
  const list = compiledSteps.value;
6404
6459
  const idx = activeIndex.value;
@@ -6763,6 +6818,39 @@ function useWizard(options) {
6763
6818
  const target = list[idx + 1];
6764
6819
  moveTo(target.key);
6765
6820
  }
6821
+ async function tryNext() {
6822
+ if (submitting.value) {
6823
+ if (__DEV__) {
6824
+ console.warn(`[attaform] wizard.tryNext(): blocked while a submit is in flight.`);
6825
+ }
6826
+ return false;
6827
+ }
6828
+ const list = compiledSteps.value;
6829
+ if (list.length === 0) {
6830
+ if (__DEV__) {
6831
+ console.warn(`[attaform] wizard.tryNext(): wizard has no compiled steps; no-op.`);
6832
+ }
6833
+ return false;
6834
+ }
6835
+ const idx = activeIndex.value;
6836
+ if (idx < 0 || idx >= list.length - 1) {
6837
+ if (__DEV__) {
6838
+ console.warn(
6839
+ `[attaform] wizard.tryNext(): already on the final step ("${activeKey.value}"). Use wizard.handleSubmit() to submit.`
6840
+ );
6841
+ }
6842
+ return false;
6843
+ }
6844
+ const form = activeForm.value;
6845
+ if (form === void 0) return false;
6846
+ let advanced = false;
6847
+ await asHandleSubmitSource(form).handleSubmit(() => {
6848
+ const before = activeKey.value;
6849
+ next();
6850
+ advanced = activeKey.value !== before;
6851
+ })();
6852
+ return advanced;
6853
+ }
6766
6854
  function back() {
6767
6855
  if (submitting.value) {
6768
6856
  if (__DEV__) {
@@ -6899,20 +6987,13 @@ function useWizard(options) {
6899
6987
  const final = isFinalStep.value;
6900
6988
  const list = compiledSteps.value;
6901
6989
  const results = /* @__PURE__ */ new Map();
6902
- if (final) {
6903
- await Promise.all(
6904
- list.map(async (step) => {
6905
- registry.forms.get(step.key)?.clearUserErrors();
6906
- const result = await processOne(step.form);
6907
- results.set(step.key, result);
6908
- })
6909
- );
6910
- } else {
6911
- const active = activeForm.value;
6912
- registry.forms.get(active.key)?.clearUserErrors();
6913
- const result = await processOne(active);
6914
- results.set(active.key, result);
6915
- }
6990
+ await Promise.all(
6991
+ list.map(async (step) => {
6992
+ registry.forms.get(step.key)?.clearUserErrors();
6993
+ const result = await processOne(step.form);
6994
+ results.set(step.key, result);
6995
+ })
6996
+ );
6916
6997
  for (const key of results.keys()) {
6917
6998
  const store = registry.forms.get(key);
6918
6999
  if (store !== void 0) {
@@ -6947,14 +7028,7 @@ function useWizard(options) {
6947
7028
  }
6948
7029
  return;
6949
7030
  }
6950
- if (final) {
6951
- done.value = true;
6952
- } else {
6953
- recordDeparture(currentKey);
6954
- const idx = activeIndex.value;
6955
- const target = list[idx + 1];
6956
- if (target !== void 0) moveTo(target.key);
6957
- }
7031
+ done.value = true;
6958
7032
  } else {
6959
7033
  await focusFirstWizardError(errors);
6960
7034
  if (onError !== void 0) {
@@ -7004,13 +7078,14 @@ function useWizard(options) {
7004
7078
  next,
7005
7079
  back,
7006
7080
  goTo,
7081
+ tryNext,
7007
7082
  handleSubmit,
7008
7083
  reset,
7009
7084
  get currentStep() {
7010
7085
  return currentStep.value;
7011
7086
  },
7012
7087
  get activeForm() {
7013
- return activeForm.value;
7088
+ return activeForm.value === void 0 ? void 0 : activeFormFacade;
7014
7089
  },
7015
7090
  get activeIndex() {
7016
7091
  return activeIndex.value;
@@ -7142,6 +7217,9 @@ function warnMiss(detail, ssr, hint) {
7142
7217
  const frame = captureUserCallSite();
7143
7218
  const parts = [`[attaform] injectWizard: ${detail}. Returning null.`];
7144
7219
  if (hint !== void 0) parts.push(hint);
7220
+ parts.push(
7221
+ `A wizard created by a child or sibling component is not registered until that component's own setup runs, which happens after this point. Lift its useWizard({ key }) call to a common ancestor, or read the wizard after mount.`
7222
+ );
7145
7223
  if (frame !== void 0) parts.push(frame);
7146
7224
  console.warn(parts.join(" "));
7147
7225
  }
@@ -7164,4 +7242,4 @@ function warnIfAmbientWizardProviderHadDuplicates() {
7164
7242
  }
7165
7243
 
7166
7244
  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 };
7167
- //# sourceMappingURL=attaform.iJ4y3sHU.mjs.map
7245
+ //# sourceMappingURL=attaform.DK3xUBkj.mjs.map