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
@@ -914,6 +914,10 @@ function buildContainerFieldStateBase(state, segments, key, formInstanceId) {
914
914
  pristine = false;
915
915
  dirty = true;
916
916
  }
917
+ if (!dirty && state.hasRemovedSubtreeUnder(segments)) {
918
+ pristine = false;
919
+ dirty = true;
920
+ }
917
921
  const errors = aggregateErrorsAt(state, segments);
918
922
  const revealedDescendantError = errors.length > 0 && errors.some((e) => {
919
923
  const ePath = e.path;
@@ -3900,6 +3904,7 @@ function mergeObjectKeys(target, source, path, schema) {
3900
3904
  return out;
3901
3905
  }
3902
3906
 
3907
+ const isContainer = (value) => Array.isArray(value) || isPlainRecord(value);
3903
3908
  function isHydratedFieldRecord(value) {
3904
3909
  if (typeof value !== "object" || value === null) return false;
3905
3910
  const r = value;
@@ -4089,6 +4094,7 @@ function createFormStore(options) {
4089
4094
  const schemaErrors = reactive(/* @__PURE__ */ new Map());
4090
4095
  const userErrors = reactive(/* @__PURE__ */ new Map());
4091
4096
  const originals = reactive(/* @__PURE__ */ new Map());
4097
+ const removedSubtrees = /* @__PURE__ */ new Set();
4092
4098
  const initialTransientList = hydration?.blankPaths ?? options.initialBlankPaths ?? [];
4093
4099
  const blankPaths = reactive(/* @__PURE__ */ new Set());
4094
4100
  const originalBlankPaths = /* @__PURE__ */ new Set();
@@ -4574,6 +4580,9 @@ function createFormStore(options) {
4574
4580
  return true;
4575
4581
  }
4576
4582
  const oldArrayLength = Array.isArray(currentValue) ? currentValue.length : 0;
4583
+ if (meta?.arrayOp === void 0 && Array.isArray(value) && Array.isArray(currentValue)) {
4584
+ arrayIdentity.realign(path);
4585
+ }
4577
4586
  applyTargetedWrite(path, completedValue, meta);
4578
4587
  if (meta?.arrayOp !== void 0) {
4579
4588
  const remap = remapForOp(meta.arrayOp, oldArrayLength);
@@ -4586,6 +4595,10 @@ function createFormStore(options) {
4586
4595
  } else if (Array.isArray(value) && Array.isArray(currentValue)) {
4587
4596
  variantMemory.clearUnderPath(path);
4588
4597
  arrayIdentity.realign(path);
4598
+ } else if (isContainer(currentValue) && !isContainer(value)) {
4599
+ if (subtreeHadRealBaseline(path, currentValue)) {
4600
+ removedSubtrees.add(canonicalizePath(path).key);
4601
+ }
4589
4602
  }
4590
4603
  const effectiveModeAfterWrite = meta?.instance?.validateOn ?? fieldValidationMode;
4591
4604
  if (effectiveModeAfterWrite === "change") {
@@ -5119,6 +5132,7 @@ function createFormStore(options) {
5119
5132
  rebuildAuthoredPaths(resetSource, next);
5120
5133
  applyFormReplacement(next);
5121
5134
  arrayIdentity.rebaselineAll();
5135
+ removedSubtrees.clear();
5122
5136
  originals.clear();
5123
5137
  diffAndApply({}, next, [], (patch) => {
5124
5138
  if (patch.kind !== "added") return;
@@ -5255,6 +5269,26 @@ function createFormStore(options) {
5255
5269
  function hasStructuralChangeUnder(path) {
5256
5270
  return arrayIdentity.hasStructuralChangeUnder(path);
5257
5271
  }
5272
+ function subtreeHadRealBaseline(prefix, removedValue) {
5273
+ let had = false;
5274
+ diffAndApply(removedValue, void 0, prefix, (patch) => {
5275
+ if (had || patch.kind !== "removed") return;
5276
+ const record = originals.get(canonicalizePath(patch.path).key);
5277
+ if (record?.value !== void 0) had = true;
5278
+ });
5279
+ return had;
5280
+ }
5281
+ function hasRemovedSubtreeUnder(prefix) {
5282
+ if (removedSubtrees.size === 0) return false;
5283
+ for (const key of removedSubtrees) {
5284
+ const segments = segmentsForPathKey(key);
5285
+ if (segments === null) continue;
5286
+ if (!isPathPrefix(prefix, segments)) continue;
5287
+ if (isContainer(getAtPath(toRaw(form.value), segments))) continue;
5288
+ return true;
5289
+ }
5290
+ return false;
5291
+ }
5258
5292
  function getFieldRecord(path) {
5259
5293
  const { key } = canonicalizePath(path);
5260
5294
  return fields.get(key);
@@ -5350,6 +5384,7 @@ function createFormStore(options) {
5350
5384
  isPristineAtPath,
5351
5385
  isPristineAtPathByKey,
5352
5386
  hasStructuralChangeUnder,
5387
+ hasRemovedSubtreeUnder,
5353
5388
  getFieldRecord,
5354
5389
  getOriginalAtPath,
5355
5390
  getFirstErrorElement,
@@ -7065,4 +7100,4 @@ function warnIfAmbientWizardProviderHadDuplicates() {
7065
7100
  }
7066
7101
 
7067
7102
  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 };
7068
- //# sourceMappingURL=attaform.NWrEGrNo.mjs.map
7103
+ //# sourceMappingURL=attaform.BI7M3wK8.mjs.map