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.
Files changed (88) 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 +5 -4
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +4 -4
  8. package/dist/index.d.mts +4 -4
  9. package/dist/index.d.ts +4 -4
  10. package/dist/index.mjs +4 -3
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/nuxt.d.cts +1 -1
  13. package/dist/nuxt.d.mts +1 -1
  14. package/dist/nuxt.d.ts +1 -1
  15. package/dist/runtime/plugins/attaform.cjs +2 -2
  16. package/dist/runtime/plugins/attaform.mjs +2 -2
  17. package/dist/shared/{attaform.CAWKNCzc.mjs → attaform.0-00cYGw.mjs} +2 -2
  18. package/dist/shared/{attaform.CAWKNCzc.mjs.map → attaform.0-00cYGw.mjs.map} +1 -1
  19. package/dist/shared/{attaform.DdUYEhkV.d.cts → attaform.0zueP54D.d.mts} +33 -15
  20. package/dist/shared/{attaform.Z1qTwOYE.cjs → attaform.B57G7ePY.cjs} +4 -4
  21. package/dist/shared/{attaform.BJ_W7q3U.mjs.map → attaform.B57G7ePY.cjs.map} +1 -1
  22. package/dist/shared/{attaform.DwkU0oY9.cjs → attaform.B7UdTs_o.cjs} +79 -75
  23. package/dist/shared/attaform.B7UdTs_o.cjs.map +1 -0
  24. package/dist/shared/{attaform.CuBdtfbe.mjs → attaform.BI7M3wK8.mjs} +88 -16
  25. package/dist/shared/attaform.BI7M3wK8.mjs.map +1 -0
  26. package/dist/shared/{attaform.nycEksJn.cjs → attaform.BOi6n2Pn.cjs} +2 -2
  27. package/dist/shared/{attaform.nycEksJn.cjs.map → attaform.BOi6n2Pn.cjs.map} +1 -1
  28. package/dist/shared/{attaform.BJ_W7q3U.mjs → attaform.B_-nZHtM.mjs} +4 -4
  29. package/dist/shared/{attaform.Z1qTwOYE.cjs.map → attaform.B_-nZHtM.mjs.map} +1 -1
  30. package/dist/shared/{attaform.o95Kjd3U.mjs → attaform.BjUaX7s8.mjs} +3 -3
  31. package/dist/shared/{attaform.o95Kjd3U.mjs.map → attaform.BjUaX7s8.mjs.map} +1 -1
  32. package/dist/shared/{attaform.BNmkKz0q.d.mts → attaform.BjiHiYAZ.d.ts} +3 -2
  33. package/dist/shared/{attaform.C42wL7EJ.cjs → attaform.Bos7wVZw.cjs} +90 -18
  34. package/dist/shared/attaform.Bos7wVZw.cjs.map +1 -0
  35. package/dist/shared/{attaform.CwFZGv5-.d.ts → attaform.Bx6pgrIy.d.cts} +3 -2
  36. package/dist/shared/{attaform.Df-s8j1X.mjs → attaform.C0au8oXd.mjs} +36 -29
  37. package/dist/shared/attaform.C0au8oXd.mjs.map +1 -0
  38. package/dist/shared/attaform.CjdepGnw.cjs +27 -0
  39. package/dist/shared/attaform.CjdepGnw.cjs.map +1 -0
  40. package/dist/shared/{attaform.BnUXV01g.cjs → attaform.D-gYGj5z.cjs} +4 -4
  41. package/dist/shared/{attaform.C-dAB90u.mjs.map → attaform.D-gYGj5z.cjs.map} +1 -1
  42. package/dist/shared/{attaform.C6eE50re.d.ts → attaform.DHjRN5JP.d.cts} +33 -15
  43. package/dist/shared/{attaform.CR6wGvNu.cjs → attaform.DK6_Ctv7.cjs} +10 -4
  44. package/dist/shared/attaform.DK6_Ctv7.cjs.map +1 -0
  45. package/dist/shared/{attaform.GJbSmwLB.d.mts → attaform.DUc6cetN.d.cts} +62 -13
  46. package/dist/shared/{attaform.GJbSmwLB.d.cts → attaform.DUc6cetN.d.mts} +62 -13
  47. package/dist/shared/{attaform.GJbSmwLB.d.ts → attaform.DUc6cetN.d.ts} +62 -13
  48. package/dist/shared/{attaform.BV_HyaMO.cjs → attaform.DdfLrIgM.cjs} +3 -3
  49. package/dist/shared/{attaform.BV_HyaMO.cjs.map → attaform.DdfLrIgM.cjs.map} +1 -1
  50. package/dist/shared/{attaform.K-3glmiT.d.cts → attaform.DvqdxvNU.d.mts} +3 -2
  51. package/dist/shared/{attaform.BFWb6hDk.mjs → attaform.DwCtxauq.mjs} +10 -4
  52. package/dist/shared/attaform.DwCtxauq.mjs.map +1 -0
  53. package/dist/shared/{attaform.C-dAB90u.mjs → attaform.K1MbxmIu.mjs} +4 -4
  54. package/dist/shared/{attaform.BnUXV01g.cjs.map → attaform.K1MbxmIu.mjs.map} +1 -1
  55. package/dist/shared/attaform.WvcckZMD.mjs +21 -0
  56. package/dist/shared/attaform.WvcckZMD.mjs.map +1 -0
  57. package/dist/shared/{attaform.DiWNbKWa.d.mts → attaform.yqcYwt0d.d.ts} +33 -15
  58. package/dist/transforms.cjs +1 -1
  59. package/dist/transforms.d.cts +4 -1
  60. package/dist/transforms.d.mts +4 -1
  61. package/dist/transforms.d.ts +4 -1
  62. package/dist/transforms.mjs +1 -1
  63. package/dist/vite.cjs +1 -1
  64. package/dist/vite.mjs +1 -1
  65. package/dist/zod-v3.cjs +2 -2
  66. package/dist/zod-v3.d.cts +8 -5
  67. package/dist/zod-v3.d.mts +8 -5
  68. package/dist/zod-v3.d.ts +8 -5
  69. package/dist/zod-v3.mjs +2 -2
  70. package/dist/zod-v4.cjs +2 -2
  71. package/dist/zod-v4.d.cts +5 -5
  72. package/dist/zod-v4.d.mts +5 -5
  73. package/dist/zod-v4.d.ts +5 -5
  74. package/dist/zod-v4.mjs +2 -2
  75. package/dist/zod.cjs +5 -5
  76. package/dist/zod.cjs.map +1 -1
  77. package/dist/zod.d.cts +23 -7
  78. package/dist/zod.d.mts +23 -7
  79. package/dist/zod.d.ts +23 -7
  80. package/dist/zod.mjs +5 -5
  81. package/dist/zod.mjs.map +1 -1
  82. package/package.json +1 -1
  83. package/dist/shared/attaform.BFWb6hDk.mjs.map +0 -1
  84. package/dist/shared/attaform.C42wL7EJ.cjs.map +0 -1
  85. package/dist/shared/attaform.CR6wGvNu.cjs.map +0 -1
  86. package/dist/shared/attaform.CuBdtfbe.mjs.map +0 -1
  87. package/dist/shared/attaform.Df-s8j1X.mjs.map +0 -1
  88. package/dist/shared/attaform.DwkU0oY9.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { G as GenericForm, u as FlatPath, O as NestedType, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, D as DefaultValuesInput, af as ValidateOnConfig, b as UseFormReturnType } from './attaform.GJbSmwLB.js';
2
+ import { G as GenericForm, u as FlatPath, O as NestedType, F as FormKey, U as UseFormConfiguration, a as AbstractSchema, ar as AcceptableDefaults, af as ValidateOnConfig, b as UseFormReturnType } from './attaform.DUc6cetN.cjs';
3
3
 
4
4
  /**
5
5
  * The shape `form.values.<key>` returns at runtime.
@@ -223,8 +223,9 @@ type PathOutput<Schema extends z.ZodType, Path extends string> = z.output<Schema
223
223
  type FormOf<Schema extends SupportedRootSchema> = z.input<Schema> extends GenericForm ? z.input<Schema> : never;
224
224
  type OutOf<Schema extends SupportedRootSchema> = z.output<Schema> extends GenericForm ? z.output<Schema> : never;
225
225
  type ReadOf<Schema extends SupportedRootSchema> = StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never;
226
- declare function useForm<Schema extends SupportedRootSchema, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<FormOf<Schema>, OutOf<Schema>, AbstractSchema<FormOf<Schema>, OutOf<Schema>>, DefaultValuesInput<FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
226
+ declare function useForm<Schema extends SupportedRootSchema, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<FormOf<Schema>, OutOf<Schema>, AbstractSchema<FormOf<Schema>, OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
227
227
  schema: Schema;
228
+ defaultValues?: AcceptableDefaults<FormOf<Schema>, z.input<Schema>>;
228
229
  } & ValidateOnConfig): UseFormReturnType<FormOf<Schema>, OutOf<Schema>, ReadOf<Schema>, K>;
229
230
 
230
231
  export { useForm as u };
@@ -1,4 +1,5 @@
1
- import { shallowReactive, getCurrentInstance, inject, isRef, effectScope, watch, warn, nextTick } from 'vue';
1
+ import { shallowReactive, getCurrentInstance, inject, effectScope, watch, warn, nextTick } from 'vue';
2
+ import { i as isRegisterValue, a as isTransforming, S as SSR_COMPONENT_HOST_MODIFIER, R as REGISTER_OWNER_MARKER, V as V_REGISTER_MARKER } from './attaform.WvcckZMD.mjs';
2
3
 
3
4
  const __DEV__ = (typeof process !== "undefined" ? process.env.NODE_ENV : "production") !== "production";
4
5
 
@@ -259,21 +260,7 @@ function invokeArrayFns(fns, ...args) {
259
260
  }
260
261
  }
261
262
 
262
- const V_REGISTER_MARKER = Symbol.for("attaform:v-register-directive");
263
- const REGISTER_OWNER_MARKER = Symbol.for("attaform:register-owner-marker");
264
- function isRegisterValue(val) {
265
- if (typeof val !== "object" || val === null) return false;
266
- if (!("innerRef" in val)) return false;
267
- if (!isRef(val.innerRef)) return false;
268
- if (!("registerElement" in val)) return false;
269
- if (typeof val.registerElement !== "function") return false;
270
- if (!("setValueWithInternalPath" in val)) return false;
271
- if (typeof val.setValueWithInternalPath !== "function") return false;
272
- return true;
273
- }
274
- function isTransforming(value) {
275
- return isRegisterValue(value) && value.transforming;
276
- }
263
+ const INTERACTIVE_TAG_NAMES = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
277
264
 
278
265
  const MANAGED_ARIA_ATTRS = [
279
266
  "aria-invalid",
@@ -302,36 +289,52 @@ function setAriaAttr(el, attr, value) {
302
289
  if (value === null) el.removeAttribute(attr);
303
290
  else el.setAttribute(attr, value);
304
291
  }
305
- function resolveAriaValue(attr, rv, ds) {
292
+ function resolveAriaValue(attr, rv, ds, suppressRequired) {
306
293
  switch (attr) {
307
294
  case "aria-invalid":
308
295
  return ds === "error" ? "true" : null;
309
296
  case "aria-busy":
310
297
  return ds === "pending" ? "true" : null;
311
298
  case "aria-required":
312
- return rv.isRequired === true ? "true" : null;
299
+ return rv.isRequired === true && !suppressRequired ? "true" : null;
313
300
  case "aria-describedby":
314
301
  return ds === "error" && rv.aria?.errorId !== void 0 ? rv.aria.errorId : null;
315
302
  default:
316
303
  return null;
317
304
  }
318
305
  }
319
- function applyAria(el, rv) {
306
+ function suppressesRequired(rv, isCheckbox) {
307
+ if (!isCheckbox) return false;
308
+ const model = rv.innerRef.value;
309
+ return isArray(model) || isSet(model);
310
+ }
311
+ function isCheckboxInput(tagName, type) {
312
+ return tagName === "INPUT" && typeof type === "string" && type.toLowerCase() === "checkbox";
313
+ }
314
+ function applyAria(el, rv, vnode) {
320
315
  if (rv.ariaEnabled !== true || rv.ariaDisplayState === void 0) return;
316
+ if (!INTERACTIVE_TAG_NAMES.has(el.tagName)) return;
321
317
  const locks = el[ariaLockKey] ?? EMPTY_ARIA_LOCKS;
322
318
  const ds = rv.ariaDisplayState.value;
319
+ const vnodeType = vnode?.props?.["type"];
320
+ const checkbox = isCheckboxInput(
321
+ el.tagName,
322
+ typeof vnodeType === "string" ? vnodeType : el.type
323
+ );
324
+ const suppressRequired = suppressesRequired(rv, checkbox);
323
325
  for (const attr of MANAGED_ARIA_ATTRS) {
324
- if (!locks.has(attr)) setAriaAttr(el, attr, resolveAriaValue(attr, rv, ds));
326
+ if (!locks.has(attr)) setAriaAttr(el, attr, resolveAriaValue(attr, rv, ds, suppressRequired));
325
327
  }
326
328
  }
327
329
  function setupAria(el, rv, vnode) {
328
330
  if (rv.ariaEnabled !== true || rv.ariaDisplayState === void 0) return;
331
+ if (!INTERACTIVE_TAG_NAMES.has(el.tagName)) return;
329
332
  mergeAriaLocks(el, vnode);
330
- applyAria(el, rv);
333
+ applyAria(el, rv, vnode);
331
334
  const displayState = rv.ariaDisplayState;
332
335
  const scope = effectScope(true);
333
336
  scope.run(() => {
334
- watch(displayState, () => applyAria(el, rv), { flush: "post" });
337
+ watch(displayState, () => applyAria(el, rv, vnode), { flush: "post" });
335
338
  });
336
339
  el[ariaScopeKey] = () => scope.stop();
337
340
  }
@@ -339,10 +342,12 @@ function getSSRAriaProps(rv, vnode) {
339
342
  if (rv.ariaEnabled !== true || rv.ariaDisplayState === void 0) return void 0;
340
343
  const props = vnode?.props ?? null;
341
344
  const ds = rv.ariaDisplayState.value;
345
+ const tagName = typeof vnode?.type === "string" ? vnode.type.toUpperCase() : "";
346
+ const suppressRequired = suppressesRequired(rv, isCheckboxInput(tagName, props?.["type"]));
342
347
  const out = {};
343
348
  for (const attr of MANAGED_ARIA_ATTRS) {
344
349
  if (props !== null && attr in props) continue;
345
- const value = resolveAriaValue(attr, rv, ds);
350
+ const value = resolveAriaValue(attr, rv, ds, suppressRequired);
346
351
  if (value !== null) out[attr] = value;
347
352
  }
348
353
  return out;
@@ -695,8 +700,6 @@ function teardownValueSync(el) {
695
700
  delete carrier[valueSyncScopeKey];
696
701
  }
697
702
 
698
- const INTERACTIVE_TAG_NAMES = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
699
-
700
703
  function writeLastTypedForm(rv, next) {
701
704
  rv.lastTypedForm.value = next;
702
705
  }
@@ -1212,7 +1215,7 @@ const vRegisterDynamic = {
1212
1215
  setupAria(ariaEl, value, vnode);
1213
1216
  } else {
1214
1217
  mergeAriaLocks(ariaEl, vnode);
1215
- applyAria(ariaEl, value);
1218
+ applyAria(ariaEl, value, vnode);
1216
1219
  }
1217
1220
  }
1218
1221
  },
@@ -1241,7 +1244,11 @@ const vRegisterDynamic = {
1241
1244
  const rv = binding.value;
1242
1245
  if (!isRegisterValue(rv)) return void 0;
1243
1246
  const realVnode = vnode ?? null;
1244
- const ariaProps = getSSRAriaProps(rv, realVnode);
1247
+ const isInteractiveElementVnode = realVnode !== null && typeof realVnode.type === "string" && INTERACTIVE_TAG_NAMES.has(realVnode.type.toUpperCase());
1248
+ const modifiers = binding.modifiers;
1249
+ const isComponentHostModifier = modifiers?.[SSR_COMPONENT_HOST_MODIFIER] === true;
1250
+ const suppressHostAria = isComponentHostModifier || realVnode !== null && !isInteractiveElementVnode;
1251
+ const ariaProps = suppressHostAria ? void 0 : getSSRAriaProps(rv, realVnode);
1245
1252
  const formStateProps = realVnode !== null ? getSSRFormStateProps(rv, realVnode) : void 0;
1246
1253
  if (ariaProps === void 0 && formStateProps === void 0) return void 0;
1247
1254
  return { ...ariaProps, ...formStateProps };
@@ -1442,5 +1449,5 @@ function pathsEqual(a, b) {
1442
1449
  return true;
1443
1450
  }
1444
1451
 
1445
- export { AttaformError as A, REGISTER_OWNER_MARKER as B, kAttaformAncestorWizard as C, InvalidPathError as I, OutsideSetupError as O, ROOT_PATH as R, SubmitErrorHandlerError as S, V_REGISTER_MARKER as V, __DEV__ as _, InvalidUseFormConfigError as a, ROOT_PATH_KEY as b, RegistryNotInstalledError as c, ReservedFormKeyError as d, assignKey as e, canonicalizePath as f, createAttaform as g, createRegistry as h, getRegistryFromApp as i, isPathPrefix as j, isRegisterValue as k, kAttaformRegistry as l, kAttaformWizardActiveStepResolver as m, pathKeyToDotted as n, pathsEqual as o, parseDottedPath as p, keyForSegments as q, INTERACTIVE_TAG_NAMES as r, segmentsForPathKey as s, toError as t, useRegistry as u, vRegister as v, coerceToPathKey as w, ensureAttaformInstalled as x, kFormContext as y, kFormInstanceId as z };
1446
- //# sourceMappingURL=attaform.Df-s8j1X.mjs.map
1452
+ export { AttaformError as A, InvalidPathError as I, OutsideSetupError as O, ROOT_PATH as R, SubmitErrorHandlerError as S, __DEV__ as _, InvalidUseFormConfigError as a, ROOT_PATH_KEY as b, RegistryNotInstalledError as c, ReservedFormKeyError as d, assignKey as e, canonicalizePath as f, createAttaform as g, createRegistry as h, getRegistryFromApp as i, isPathPrefix as j, kAttaformRegistry as k, kAttaformWizardActiveStepResolver as l, pathKeyToDotted as m, pathsEqual as n, keyForSegments as o, parseDottedPath as p, INTERACTIVE_TAG_NAMES as q, coerceToPathKey as r, segmentsForPathKey as s, toError as t, useRegistry as u, vRegister as v, ensureAttaformInstalled as w, kFormContext as x, kFormInstanceId as y, kAttaformAncestorWizard as z };
1453
+ //# sourceMappingURL=attaform.C0au8oXd.mjs.map