attaform 0.24.1 → 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 (68) hide show
  1. package/dist/chunks/fingerprint2.cjs +1 -1
  2. package/dist/chunks/fingerprint2.mjs +1 -1
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.cts +4 -4
  5. package/dist/index.d.mts +4 -4
  6. package/dist/index.d.ts +4 -4
  7. package/dist/index.mjs +1 -1
  8. package/dist/nuxt.d.cts +1 -1
  9. package/dist/nuxt.d.mts +1 -1
  10. package/dist/nuxt.d.ts +1 -1
  11. package/dist/shared/{attaform.BwAcpoRw.d.mts → attaform.0zueP54D.d.mts} +10 -1
  12. package/dist/shared/{attaform.Cn6JoG9o.cjs → attaform.B57G7ePY.cjs} +3 -3
  13. package/dist/shared/{attaform.FY5r1BpA.mjs.map → attaform.B57G7ePY.cjs.map} +1 -1
  14. package/dist/shared/{attaform.NWrEGrNo.mjs → attaform.BI7M3wK8.mjs} +36 -1
  15. package/dist/shared/attaform.BI7M3wK8.mjs.map +1 -0
  16. package/dist/shared/{attaform.FY5r1BpA.mjs → attaform.B_-nZHtM.mjs} +3 -3
  17. package/dist/shared/{attaform.Cn6JoG9o.cjs.map → attaform.B_-nZHtM.mjs.map} +1 -1
  18. package/dist/shared/{attaform.C-tQKknW.mjs → attaform.BjUaX7s8.mjs} +2 -2
  19. package/dist/shared/{attaform.C-tQKknW.mjs.map → attaform.BjUaX7s8.mjs.map} +1 -1
  20. package/dist/shared/{attaform.4zesozTg.d.mts → attaform.BjiHiYAZ.d.ts} +3 -2
  21. package/dist/shared/{attaform.DRQjF16I.cjs → attaform.Bos7wVZw.cjs} +36 -1
  22. package/dist/shared/attaform.Bos7wVZw.cjs.map +1 -0
  23. package/dist/shared/{attaform.Bk7vnQhG.d.cts → attaform.Bx6pgrIy.d.cts} +3 -2
  24. package/dist/shared/{attaform.CrrIaHM8.cjs → attaform.D-gYGj5z.cjs} +3 -3
  25. package/dist/shared/{attaform.BunnTiTw.mjs.map → attaform.D-gYGj5z.cjs.map} +1 -1
  26. package/dist/shared/{attaform.Bq6Copxn.d.cts → attaform.DHjRN5JP.d.cts} +10 -1
  27. package/dist/shared/{attaform.DwLw3Kzv.cjs → attaform.DK6_Ctv7.cjs} +4 -4
  28. package/dist/shared/attaform.DK6_Ctv7.cjs.map +1 -0
  29. package/dist/shared/{attaform.DBhrKb2j.d.mts → attaform.DUc6cetN.d.cts} +37 -1
  30. package/dist/shared/{attaform.DBhrKb2j.d.cts → attaform.DUc6cetN.d.mts} +37 -1
  31. package/dist/shared/{attaform.DBhrKb2j.d.ts → attaform.DUc6cetN.d.ts} +37 -1
  32. package/dist/shared/{attaform.C-1W0T1n.cjs → attaform.DdfLrIgM.cjs} +2 -2
  33. package/dist/shared/{attaform.C-1W0T1n.cjs.map → attaform.DdfLrIgM.cjs.map} +1 -1
  34. package/dist/shared/{attaform.Df4xXKbE.d.ts → attaform.DvqdxvNU.d.mts} +3 -2
  35. package/dist/shared/{attaform.DhXl0Kdr.mjs → attaform.DwCtxauq.mjs} +4 -4
  36. package/dist/shared/attaform.DwCtxauq.mjs.map +1 -0
  37. package/dist/shared/{attaform.BunnTiTw.mjs → attaform.K1MbxmIu.mjs} +3 -3
  38. package/dist/shared/{attaform.CrrIaHM8.cjs.map → attaform.K1MbxmIu.mjs.map} +1 -1
  39. package/dist/shared/{attaform.BrFPMFgi.d.ts → attaform.yqcYwt0d.d.ts} +10 -1
  40. package/dist/transforms.cjs +1 -1
  41. package/dist/transforms.d.cts +4 -1
  42. package/dist/transforms.d.mts +4 -1
  43. package/dist/transforms.d.ts +4 -1
  44. package/dist/transforms.mjs +1 -1
  45. package/dist/vite.cjs +1 -1
  46. package/dist/vite.mjs +1 -1
  47. package/dist/zod-v3.cjs +2 -2
  48. package/dist/zod-v3.d.cts +8 -5
  49. package/dist/zod-v3.d.mts +8 -5
  50. package/dist/zod-v3.d.ts +8 -5
  51. package/dist/zod-v3.mjs +2 -2
  52. package/dist/zod-v4.cjs +2 -2
  53. package/dist/zod-v4.d.cts +5 -5
  54. package/dist/zod-v4.d.mts +5 -5
  55. package/dist/zod-v4.d.ts +5 -5
  56. package/dist/zod-v4.mjs +2 -2
  57. package/dist/zod.cjs +4 -4
  58. package/dist/zod.cjs.map +1 -1
  59. package/dist/zod.d.cts +23 -7
  60. package/dist/zod.d.mts +23 -7
  61. package/dist/zod.d.ts +23 -7
  62. package/dist/zod.mjs +4 -4
  63. package/dist/zod.mjs.map +1 -1
  64. package/package.json +1 -1
  65. package/dist/shared/attaform.DRQjF16I.cjs.map +0 -1
  66. package/dist/shared/attaform.DhXl0Kdr.mjs.map +0 -1
  67. package/dist/shared/attaform.DwLw3Kzv.cjs.map +0 -1
  68. package/dist/shared/attaform.NWrEGrNo.mjs.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.DBhrKb2j.mjs';
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.js';
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 };
@@ -916,6 +916,10 @@ function buildContainerFieldStateBase(state, segments, key, formInstanceId) {
916
916
  pristine = false;
917
917
  dirty = true;
918
918
  }
919
+ if (!dirty && state.hasRemovedSubtreeUnder(segments)) {
920
+ pristine = false;
921
+ dirty = true;
922
+ }
919
923
  const errors = aggregateErrorsAt(state, segments);
920
924
  const revealedDescendantError = errors.length > 0 && errors.some((e) => {
921
925
  const ePath = e.path;
@@ -3902,6 +3906,7 @@ function mergeObjectKeys(target, source, path, schema) {
3902
3906
  return out;
3903
3907
  }
3904
3908
 
3909
+ const isContainer = (value) => Array.isArray(value) || isPlainRecord(value);
3905
3910
  function isHydratedFieldRecord(value) {
3906
3911
  if (typeof value !== "object" || value === null) return false;
3907
3912
  const r = value;
@@ -4091,6 +4096,7 @@ function createFormStore(options) {
4091
4096
  const schemaErrors = vue.reactive(/* @__PURE__ */ new Map());
4092
4097
  const userErrors = vue.reactive(/* @__PURE__ */ new Map());
4093
4098
  const originals = vue.reactive(/* @__PURE__ */ new Map());
4099
+ const removedSubtrees = /* @__PURE__ */ new Set();
4094
4100
  const initialTransientList = hydration?.blankPaths ?? options.initialBlankPaths ?? [];
4095
4101
  const blankPaths = vue.reactive(/* @__PURE__ */ new Set());
4096
4102
  const originalBlankPaths = /* @__PURE__ */ new Set();
@@ -4576,6 +4582,9 @@ function createFormStore(options) {
4576
4582
  return true;
4577
4583
  }
4578
4584
  const oldArrayLength = Array.isArray(currentValue) ? currentValue.length : 0;
4585
+ if (meta?.arrayOp === void 0 && Array.isArray(value) && Array.isArray(currentValue)) {
4586
+ arrayIdentity.realign(path);
4587
+ }
4579
4588
  applyTargetedWrite(path, completedValue, meta);
4580
4589
  if (meta?.arrayOp !== void 0) {
4581
4590
  const remap = remapForOp(meta.arrayOp, oldArrayLength);
@@ -4588,6 +4597,10 @@ function createFormStore(options) {
4588
4597
  } else if (Array.isArray(value) && Array.isArray(currentValue)) {
4589
4598
  variantMemory.clearUnderPath(path);
4590
4599
  arrayIdentity.realign(path);
4600
+ } else if (isContainer(currentValue) && !isContainer(value)) {
4601
+ if (subtreeHadRealBaseline(path, currentValue)) {
4602
+ removedSubtrees.add(paths.canonicalizePath(path).key);
4603
+ }
4591
4604
  }
4592
4605
  const effectiveModeAfterWrite = meta?.instance?.validateOn ?? fieldValidationMode;
4593
4606
  if (effectiveModeAfterWrite === "change") {
@@ -5121,6 +5134,7 @@ function createFormStore(options) {
5121
5134
  rebuildAuthoredPaths(resetSource, next);
5122
5135
  applyFormReplacement(next);
5123
5136
  arrayIdentity.rebaselineAll();
5137
+ removedSubtrees.clear();
5124
5138
  originals.clear();
5125
5139
  diffAndApply({}, next, [], (patch) => {
5126
5140
  if (patch.kind !== "added") return;
@@ -5257,6 +5271,26 @@ function createFormStore(options) {
5257
5271
  function hasStructuralChangeUnder(path) {
5258
5272
  return arrayIdentity.hasStructuralChangeUnder(path);
5259
5273
  }
5274
+ function subtreeHadRealBaseline(prefix, removedValue) {
5275
+ let had = false;
5276
+ diffAndApply(removedValue, void 0, prefix, (patch) => {
5277
+ if (had || patch.kind !== "removed") return;
5278
+ const record = originals.get(paths.canonicalizePath(patch.path).key);
5279
+ if (record?.value !== void 0) had = true;
5280
+ });
5281
+ return had;
5282
+ }
5283
+ function hasRemovedSubtreeUnder(prefix) {
5284
+ if (removedSubtrees.size === 0) return false;
5285
+ for (const key of removedSubtrees) {
5286
+ const segments = paths.segmentsForPathKey(key);
5287
+ if (segments === null) continue;
5288
+ if (!paths.isPathPrefix(prefix, segments)) continue;
5289
+ if (isContainer(getAtPath(vue.toRaw(form.value), segments))) continue;
5290
+ return true;
5291
+ }
5292
+ return false;
5293
+ }
5260
5294
  function getFieldRecord(path) {
5261
5295
  const { key } = paths.canonicalizePath(path);
5262
5296
  return fields.get(key);
@@ -5352,6 +5386,7 @@ function createFormStore(options) {
5352
5386
  isPristineAtPath,
5353
5387
  isPristineAtPathByKey,
5354
5388
  hasStructuralChangeUnder,
5389
+ hasRemovedSubtreeUnder,
5355
5390
  getFieldRecord,
5356
5391
  getOriginalAtPath,
5357
5392
  getFirstErrorElement,
@@ -7087,4 +7122,4 @@ exports.unset = unset;
7087
7122
  exports.useAbstractForm = useAbstractForm;
7088
7123
  exports.useRegister = useRegister;
7089
7124
  exports.useWizard = useWizard;
7090
- //# sourceMappingURL=attaform.DRQjF16I.cjs.map
7125
+ //# sourceMappingURL=attaform.Bos7wVZw.cjs.map