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,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const paths = require('./attaform.CAVK56f8.cjs');
5
- const registerProtocol = require('./attaform.CjdepGnw.cjs');
4
+ const paths = require('./attaform.3heDHayA.cjs');
5
+ const registerProtocol = require('./attaform.ZXZ6dH72.cjs');
6
6
 
7
7
  function safeAssign(target, key, value) {
8
8
  if (key === "__proto__") {
@@ -2020,11 +2020,11 @@ function applyInvalidSubmitPolicy(state, formInstanceId, policy) {
2020
2020
  return;
2021
2021
  }
2022
2022
  if (policy === "focus-first-error") {
2023
- target.element.focus();
2023
+ target.element.focus({ focusVisible: true });
2024
2024
  return;
2025
2025
  }
2026
2026
  target.element.scrollIntoView();
2027
- target.element.focus({ preventScroll: true });
2027
+ target.element.focus({ preventScroll: true, focusVisible: true });
2028
2028
  }
2029
2029
 
2030
2030
  const warnedRejections = paths.__DEV__ ? /* @__PURE__ */ new WeakMap() : null;
@@ -3229,7 +3229,7 @@ function buildFormApi(state, formInstanceId, options = {}) {
3229
3229
  const focusFirstError = (options2) => {
3230
3230
  const target = state.getFirstErrorElement(formInstanceId);
3231
3231
  if (target === null) return false;
3232
- target.element.focus(options2);
3232
+ target.element.focus({ focusVisible: true, ...options2 });
3233
3233
  return true;
3234
3234
  };
3235
3235
  const scrollToFirstError = (options2) => {
@@ -5366,10 +5366,7 @@ function createFormStore(options) {
5366
5366
  if (elementToFormInstance.get(entry.element) !== formInstanceId) continue;
5367
5367
  if (!entry.element.isConnected) continue;
5368
5368
  if (entry.element.offsetParent === null) continue;
5369
- const { key } = paths.canonicalizePath(entry.path);
5370
- const hasSchemaErr = (schemaErrors.get(key)?.length ?? 0) > 0;
5371
- const hasUserErr = (userErrors.get(key)?.length ?? 0) > 0;
5372
- if (!hasSchemaErr && !hasUserErr) continue;
5369
+ if (getErrorsForPath(entry.path).length === 0) continue;
5373
5370
  return { path: entry.path, element: entry.element };
5374
5371
  }
5375
5372
  return null;
@@ -5949,7 +5946,7 @@ function resolveState(key, registry) {
5949
5946
  if (key !== void 0) {
5950
5947
  const stored = registry.forms.get(key);
5951
5948
  if (stored === void 0) {
5952
- warnMiss$1(`no form registered for key '${key}'`, registry.ssr);
5949
+ warnMiss$1(`no form registered for key '${key}'`, registry.ssr, registry.forms);
5953
5950
  return null;
5954
5951
  }
5955
5952
  return stored;
@@ -5959,12 +5956,22 @@ function resolveState(key, registry) {
5959
5956
  warnIfAmbientProviderHadDuplicates();
5960
5957
  return ambient;
5961
5958
  }
5962
- function warnMiss$1(detail, ssr) {
5959
+ function availableKeysHint$1(forms) {
5960
+ const addressable = [...forms.keys()].filter((key) => !key.startsWith(RESERVED_KEY_PREFIX));
5961
+ if (addressable.length === 0) return void 0;
5962
+ return `Registered keys: ${addressable.map((key) => `'${key}'`).join(", ")}.`;
5963
+ }
5964
+ function warnMiss$1(detail, ssr, forms) {
5963
5965
  if (!paths.__DEV__ || ssr) return;
5964
5966
  const frame = captureUserCallSite();
5965
- console.warn(
5966
- `[attaform] injectForm: ${detail}. Returning null.` + (frame !== void 0 ? ` ${frame}` : "")
5967
+ const parts = [`[attaform] injectForm: ${detail}. Returning null.`];
5968
+ const keys = availableKeysHint$1(forms);
5969
+ if (keys !== void 0) parts.push(keys);
5970
+ parts.push(
5971
+ `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.`
5967
5972
  );
5973
+ if (frame !== void 0) parts.push(frame);
5974
+ console.warn(parts.join(" "));
5968
5975
  }
5969
5976
  function warnIfAmbientProviderHadDuplicates() {
5970
5977
  if (!paths.__DEV__ || ambientProvideHistory === null) return;
@@ -6224,6 +6231,9 @@ function asStatusSource(form) {
6224
6231
  function asSubmissionSource(form) {
6225
6232
  return form;
6226
6233
  }
6234
+ function asHandleSubmitSource(form) {
6235
+ return form;
6236
+ }
6227
6237
  function useWizard(options) {
6228
6238
  const rawSteps = Array.isArray(options.steps) ? options.steps : [];
6229
6239
  if (rawSteps.length === 0 && paths.__DEV__) {
@@ -6318,6 +6328,7 @@ function useWizard(options) {
6318
6328
  }
6319
6329
  };
6320
6330
  function resolveSlot(slot, index, ctx) {
6331
+ if (slot === void 0 || slot === null) return void 0;
6321
6332
  if (typeof slot === "string") {
6322
6333
  return getOrBuildNoop(slot);
6323
6334
  }
@@ -6333,7 +6344,7 @@ function useWizard(options) {
6333
6344
  return void 0;
6334
6345
  }
6335
6346
  function resolveSlotResult(result) {
6336
- if (result === void 0) return void 0;
6347
+ if (result === void 0 || result === null) return void 0;
6337
6348
  if (typeof result === "string") {
6338
6349
  return getOrBuildNoop(result);
6339
6350
  }
@@ -6401,6 +6412,50 @@ function useWizard(options) {
6401
6412
  const first = list[0];
6402
6413
  return first === void 0 ? void 0 : first.form;
6403
6414
  });
6415
+ vue.watch(compiledSteps, (list, prevList) => {
6416
+ const key = activeKey.value;
6417
+ if (key === "") return;
6418
+ if (list.some((step) => step.key === key)) return;
6419
+ if (list.length === 0) {
6420
+ activeKey.value = "";
6421
+ return;
6422
+ }
6423
+ const oldIndex = prevList.findIndex((step) => step.key === key);
6424
+ const slid = list[oldIndex < 0 ? 0 : Math.min(oldIndex, list.length - 1)];
6425
+ if (slid !== void 0) activeKey.value = slid.key;
6426
+ });
6427
+ const activeFormFacade = new Proxy({}, {
6428
+ get(_target, prop) {
6429
+ const form = activeForm.value;
6430
+ if (form === void 0) return void 0;
6431
+ if (prop === "handleSubmit") {
6432
+ const lateBound = (onValid, onInvalid) => {
6433
+ return (event) => {
6434
+ const current = activeForm.value;
6435
+ if (current === void 0) return Promise.resolve();
6436
+ return asHandleSubmitSource(current).handleSubmit(onValid, onInvalid)(event);
6437
+ };
6438
+ };
6439
+ return lateBound;
6440
+ }
6441
+ return Reflect.get(form, prop, form);
6442
+ },
6443
+ has(_target, prop) {
6444
+ const form = activeForm.value;
6445
+ return form === void 0 ? false : Reflect.has(form, prop);
6446
+ },
6447
+ ownKeys(_target) {
6448
+ const form = activeForm.value;
6449
+ return form === void 0 ? [] : Reflect.ownKeys(form);
6450
+ },
6451
+ getOwnPropertyDescriptor(_target, prop) {
6452
+ const form = activeForm.value;
6453
+ if (form === void 0) return void 0;
6454
+ const descriptor = Reflect.getOwnPropertyDescriptor(form, prop);
6455
+ if (descriptor === void 0) return void 0;
6456
+ return { ...descriptor, configurable: true };
6457
+ }
6458
+ });
6404
6459
  const isFinalStep = vue.computed(() => {
6405
6460
  const list = compiledSteps.value;
6406
6461
  const idx = activeIndex.value;
@@ -6765,6 +6820,39 @@ function useWizard(options) {
6765
6820
  const target = list[idx + 1];
6766
6821
  moveTo(target.key);
6767
6822
  }
6823
+ async function tryNext() {
6824
+ if (submitting.value) {
6825
+ if (paths.__DEV__) {
6826
+ console.warn(`[attaform] wizard.tryNext(): blocked while a submit is in flight.`);
6827
+ }
6828
+ return false;
6829
+ }
6830
+ const list = compiledSteps.value;
6831
+ if (list.length === 0) {
6832
+ if (paths.__DEV__) {
6833
+ console.warn(`[attaform] wizard.tryNext(): wizard has no compiled steps; no-op.`);
6834
+ }
6835
+ return false;
6836
+ }
6837
+ const idx = activeIndex.value;
6838
+ if (idx < 0 || idx >= list.length - 1) {
6839
+ if (paths.__DEV__) {
6840
+ console.warn(
6841
+ `[attaform] wizard.tryNext(): already on the final step ("${activeKey.value}"). Use wizard.handleSubmit() to submit.`
6842
+ );
6843
+ }
6844
+ return false;
6845
+ }
6846
+ const form = activeForm.value;
6847
+ if (form === void 0) return false;
6848
+ let advanced = false;
6849
+ await asHandleSubmitSource(form).handleSubmit(() => {
6850
+ const before = activeKey.value;
6851
+ next();
6852
+ advanced = activeKey.value !== before;
6853
+ })();
6854
+ return advanced;
6855
+ }
6768
6856
  function back() {
6769
6857
  if (submitting.value) {
6770
6858
  if (paths.__DEV__) {
@@ -6901,20 +6989,13 @@ function useWizard(options) {
6901
6989
  const final = isFinalStep.value;
6902
6990
  const list = compiledSteps.value;
6903
6991
  const results = /* @__PURE__ */ new Map();
6904
- if (final) {
6905
- await Promise.all(
6906
- list.map(async (step) => {
6907
- registry.forms.get(step.key)?.clearUserErrors();
6908
- const result = await processOne(step.form);
6909
- results.set(step.key, result);
6910
- })
6911
- );
6912
- } else {
6913
- const active = activeForm.value;
6914
- registry.forms.get(active.key)?.clearUserErrors();
6915
- const result = await processOne(active);
6916
- results.set(active.key, result);
6917
- }
6992
+ await Promise.all(
6993
+ list.map(async (step) => {
6994
+ registry.forms.get(step.key)?.clearUserErrors();
6995
+ const result = await processOne(step.form);
6996
+ results.set(step.key, result);
6997
+ })
6998
+ );
6918
6999
  for (const key of results.keys()) {
6919
7000
  const store = registry.forms.get(key);
6920
7001
  if (store !== void 0) {
@@ -6949,14 +7030,7 @@ function useWizard(options) {
6949
7030
  }
6950
7031
  return;
6951
7032
  }
6952
- if (final) {
6953
- done.value = true;
6954
- } else {
6955
- recordDeparture(currentKey);
6956
- const idx = activeIndex.value;
6957
- const target = list[idx + 1];
6958
- if (target !== void 0) moveTo(target.key);
6959
- }
7033
+ done.value = true;
6960
7034
  } else {
6961
7035
  await focusFirstWizardError(errors);
6962
7036
  if (onError !== void 0) {
@@ -7006,13 +7080,14 @@ function useWizard(options) {
7006
7080
  next,
7007
7081
  back,
7008
7082
  goTo,
7083
+ tryNext,
7009
7084
  handleSubmit,
7010
7085
  reset,
7011
7086
  get currentStep() {
7012
7087
  return currentStep.value;
7013
7088
  },
7014
7089
  get activeForm() {
7015
- return activeForm.value;
7090
+ return activeForm.value === void 0 ? void 0 : activeFormFacade;
7016
7091
  },
7017
7092
  get activeIndex() {
7018
7093
  return activeIndex.value;
@@ -7144,6 +7219,9 @@ function warnMiss(detail, ssr, hint) {
7144
7219
  const frame = captureUserCallSite();
7145
7220
  const parts = [`[attaform] injectWizard: ${detail}. Returning null.`];
7146
7221
  if (hint !== void 0) parts.push(hint);
7222
+ parts.push(
7223
+ `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.`
7224
+ );
7147
7225
  if (frame !== void 0) parts.push(frame);
7148
7226
  console.warn(parts.join(" "));
7149
7227
  }
@@ -7186,4 +7264,4 @@ exports.unset = unset;
7186
7264
  exports.useAbstractForm = useAbstractForm;
7187
7265
  exports.useRegister = useRegister;
7188
7266
  exports.useWizard = useWizard;
7189
- //# sourceMappingURL=attaform.Buedl_UL.cjs.map
7267
+ //# sourceMappingURL=attaform.BkUzunyB.cjs.map