handsontable 18.0.0-rc4 → 18.0.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 (127) hide show
  1. package/3rdparty/walkontable/src/renderer/cells.d.ts +0 -6
  2. package/3rdparty/walkontable/src/renderer/cells.js +2 -7
  3. package/3rdparty/walkontable/src/renderer/cells.mjs +2 -7
  4. package/3rdparty/walkontable/src/renderer/colGroup.js +1 -1
  5. package/3rdparty/walkontable/src/renderer/colGroup.mjs +1 -1
  6. package/3rdparty/walkontable/src/renderer/columnHeaderRows.js +1 -1
  7. package/3rdparty/walkontable/src/renderer/columnHeaderRows.mjs +1 -1
  8. package/3rdparty/walkontable/src/renderer/columnHeaders.d.ts +0 -6
  9. package/3rdparty/walkontable/src/renderer/columnHeaders.js +2 -7
  10. package/3rdparty/walkontable/src/renderer/columnHeaders.mjs +2 -7
  11. package/3rdparty/walkontable/src/renderer/rowHeaders.d.ts +0 -6
  12. package/3rdparty/walkontable/src/renderer/rowHeaders.js +5 -10
  13. package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +5 -10
  14. package/3rdparty/walkontable/src/renderer/rows.js +1 -1
  15. package/3rdparty/walkontable/src/renderer/rows.mjs +1 -1
  16. package/3rdparty/walkontable/src/utils/nodesPool.d.ts +10 -10
  17. package/3rdparty/walkontable/src/utils/nodesPool.js +16 -32
  18. package/3rdparty/walkontable/src/utils/nodesPool.mjs +11 -31
  19. package/3rdparty/walkontable/src/utils/orderView/constants.d.ts +0 -36
  20. package/3rdparty/walkontable/src/utils/orderView/constants.js +0 -24
  21. package/3rdparty/walkontable/src/utils/orderView/constants.mjs +0 -30
  22. package/3rdparty/walkontable/src/utils/orderView/view.d.ts +27 -20
  23. package/3rdparty/walkontable/src/utils/orderView/view.js +79 -16
  24. package/3rdparty/walkontable/src/utils/orderView/view.mjs +86 -17
  25. package/3rdparty/walkontable/src/utils/orderView/viewSize.d.ts +2 -14
  26. package/3rdparty/walkontable/src/utils/orderView/viewSize.js +2 -14
  27. package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +2 -14
  28. package/CHANGELOG.md +4 -1
  29. package/base.js +2 -2
  30. package/base.mjs +2 -2
  31. package/core/types.d.ts +4 -0
  32. package/core.js +25 -4
  33. package/core.mjs +25 -4
  34. package/dataMap/metaManager/index.d.ts +22 -0
  35. package/dataMap/metaManager/index.js +20 -0
  36. package/dataMap/metaManager/index.mjs +20 -0
  37. package/dataMap/metaManager/metaLayers/cellMeta.d.ts +30 -0
  38. package/dataMap/metaManager/metaLayers/cellMeta.js +110 -0
  39. package/dataMap/metaManager/metaLayers/cellMeta.mjs +111 -1
  40. package/dataMap/metaManager/metaSchema.js +9 -0
  41. package/dataMap/metaManager/metaSchema.mjs +9 -0
  42. package/dataMap/sourceDataValidator.d.ts +25 -2
  43. package/dataMap/sourceDataValidator.js +163 -29
  44. package/dataMap/sourceDataValidator.mjs +178 -30
  45. package/dist/handsontable.full.js +2182 -2392
  46. package/dist/handsontable.full.min.js +95 -95
  47. package/dist/handsontable.js +2182 -2387
  48. package/dist/handsontable.min.js +95 -95
  49. package/dist/themes/classic.js +2 -2
  50. package/dist/themes/classic.min.js +2 -2
  51. package/dist/themes/horizon.js +2 -2
  52. package/dist/themes/horizon.min.js +2 -2
  53. package/dist/themes/main.js +2 -2
  54. package/dist/themes/main.min.js +2 -2
  55. package/dist/themes/static/variables/colors/ant.js +2 -2
  56. package/dist/themes/static/variables/colors/ant.min.js +2 -2
  57. package/dist/themes/static/variables/colors/classic.js +2 -2
  58. package/dist/themes/static/variables/colors/classic.min.js +2 -2
  59. package/dist/themes/static/variables/colors/horizon.js +2 -2
  60. package/dist/themes/static/variables/colors/horizon.min.js +2 -2
  61. package/dist/themes/static/variables/colors/main.js +2 -2
  62. package/dist/themes/static/variables/colors/main.min.js +2 -2
  63. package/dist/themes/static/variables/colors/material.js +2 -2
  64. package/dist/themes/static/variables/colors/material.min.js +2 -2
  65. package/dist/themes/static/variables/colors/shadcn.js +2 -2
  66. package/dist/themes/static/variables/colors/shadcn.min.js +2 -2
  67. package/dist/themes/static/variables/density.js +2 -2
  68. package/dist/themes/static/variables/density.min.js +2 -2
  69. package/dist/themes/static/variables/helpers/iconsMap.js +2 -2
  70. package/dist/themes/static/variables/helpers/iconsMap.min.js +2 -2
  71. package/dist/themes/static/variables/icons/horizon.js +2 -2
  72. package/dist/themes/static/variables/icons/horizon.min.js +2 -2
  73. package/dist/themes/static/variables/icons/main.js +2 -2
  74. package/dist/themes/static/variables/icons/main.min.js +2 -2
  75. package/dist/themes/static/variables/sizing.js +2 -2
  76. package/dist/themes/static/variables/sizing.min.js +2 -2
  77. package/dist/themes/static/variables/tokens/classic.js +2 -2
  78. package/dist/themes/static/variables/tokens/classic.min.js +2 -2
  79. package/dist/themes/static/variables/tokens/horizon.js +2 -2
  80. package/dist/themes/static/variables/tokens/horizon.min.js +2 -2
  81. package/dist/themes/static/variables/tokens/main.js +2 -2
  82. package/dist/themes/static/variables/tokens/main.min.js +2 -2
  83. package/helpers/dom/element.js +13 -6
  84. package/helpers/dom/element.mjs +13 -6
  85. package/helpers/mixed.js +2 -2
  86. package/helpers/mixed.mjs +2 -2
  87. package/package.json +1 -1
  88. package/styles/handsontable.css +2 -2
  89. package/styles/handsontable.min.css +2 -2
  90. package/styles/handsontableStyles.js +1 -1
  91. package/styles/handsontableStyles.mjs +1 -1
  92. package/styles/ht-icons-horizon.min.css +2 -2
  93. package/styles/ht-icons-main.min.css +2 -2
  94. package/styles/ht-theme-classic-no-icons.min.css +2 -2
  95. package/styles/ht-theme-classic.min.css +2 -2
  96. package/styles/ht-theme-horizon-no-icons.min.css +2 -2
  97. package/styles/ht-theme-horizon.min.css +2 -2
  98. package/styles/ht-theme-main-no-icons.min.css +2 -2
  99. package/styles/ht-theme-main.min.css +2 -2
  100. package/utils/licenseNotification.js +1 -1
  101. package/utils/licenseNotification.mjs +1 -1
  102. package/validators/dateValidator/dateValidator.d.ts +3 -0
  103. package/validators/dateValidator/dateValidator.js +4 -0
  104. package/validators/dateValidator/dateValidator.mjs +4 -0
  105. package/validators/timeValidator/timeValidator.d.ts +3 -0
  106. package/validators/timeValidator/timeValidator.js +4 -0
  107. package/validators/timeValidator/timeValidator.mjs +4 -0
  108. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.d.mts +0 -1
  109. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.d.ts +0 -60
  110. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.js +0 -96
  111. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/differBasedRendererAdapter.mjs +0 -91
  112. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.d.mts +0 -1
  113. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.d.ts +0 -45
  114. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.js +0 -97
  115. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/directDomRendererAdapter.mjs +0 -91
  116. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.d.mts +0 -1
  117. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.d.ts +0 -10
  118. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.js +0 -19
  119. package/3rdparty/walkontable/src/utils/orderView/rendererAdapter/index.mjs +0 -14
  120. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.d.mts +0 -1
  121. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.d.ts +0 -44
  122. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.js +0 -138
  123. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/index.mjs +0 -133
  124. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.d.mts +0 -1
  125. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.d.ts +0 -57
  126. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.js +0 -137
  127. package/3rdparty/walkontable/src/utils/orderView/viewDiffer/viewOrder.mjs +0 -127
@@ -190,6 +190,28 @@ export default class MetaManager {
190
190
  * @returns {object[]}
191
191
  */
192
192
  getCellsMetaAtRow(physicalRow: number): Record<string, unknown>[];
193
+ /**
194
+ * Returns a flat snapshot of all cell meta properties that were set imperatively through
195
+ * `setCellMeta` (for example, by the user or by the context menu), keyed by physical coordinates.
196
+ * Used to preserve user-defined meta across a `clearCache` call during `updateSettings`.
197
+ *
198
+ * @returns {{physicalRow: number, physicalColumn: number, key: string, value: *}[]}
199
+ */
200
+ getUserDefinedCellMetas(): {
201
+ physicalRow: number;
202
+ physicalColumn: number;
203
+ key: string;
204
+ value: unknown;
205
+ }[];
206
+ /**
207
+ * Enables tracking of user-defined cell meta properties set through `setCellMeta`.
208
+ */
209
+ enableUserDefinedMetaRecording(): void;
210
+ /**
211
+ * Disables tracking of user-defined cell meta properties. Writes made while disabled are treated
212
+ * as declarative (for example, the `cell` option applied during `updateSettings`).
213
+ */
214
+ disableUserDefinedMetaRecording(): void;
193
215
  /**
194
216
  * Creates one or more rows at specific position.
195
217
  *
@@ -158,6 +158,26 @@ class MetaManager {
158
158
  return this.cellMeta.getMetasAtRow(physicalRow);
159
159
  }
160
160
  /**
161
+ * Returns a flat snapshot of all cell meta properties that were set imperatively through
162
+ * `setCellMeta` (for example, by the user or by the context menu), keyed by physical coordinates.
163
+ * Used to preserve user-defined meta across a `clearCache` call during `updateSettings`.
164
+ *
165
+ * @returns {{physicalRow: number, physicalColumn: number, key: string, value: *}[]}
166
+ */ getUserDefinedCellMetas() {
167
+ return this.cellMeta.getUserDefinedMetas();
168
+ }
169
+ /**
170
+ * Enables tracking of user-defined cell meta properties set through `setCellMeta`.
171
+ */ enableUserDefinedMetaRecording() {
172
+ this.cellMeta.enableUserDefinedMetaRecording();
173
+ }
174
+ /**
175
+ * Disables tracking of user-defined cell meta properties. Writes made while disabled are treated
176
+ * as declarative (for example, the `cell` option applied during `updateSettings`).
177
+ */ disableUserDefinedMetaRecording() {
178
+ this.cellMeta.disableUserDefinedMetaRecording();
179
+ }
180
+ /**
161
181
  * Creates one or more rows at specific position.
162
182
  *
163
183
  * @param {number} physicalRow The physical row index which points from what position the row is added.
@@ -143,6 +143,26 @@ class MetaManager {
143
143
  return this.cellMeta.getMetasAtRow(physicalRow);
144
144
  }
145
145
  /**
146
+ * Returns a flat snapshot of all cell meta properties that were set imperatively through
147
+ * `setCellMeta` (for example, by the user or by the context menu), keyed by physical coordinates.
148
+ * Used to preserve user-defined meta across a `clearCache` call during `updateSettings`.
149
+ *
150
+ * @returns {{physicalRow: number, physicalColumn: number, key: string, value: *}[]}
151
+ */ getUserDefinedCellMetas() {
152
+ return this.cellMeta.getUserDefinedMetas();
153
+ }
154
+ /**
155
+ * Enables tracking of user-defined cell meta properties set through `setCellMeta`.
156
+ */ enableUserDefinedMetaRecording() {
157
+ this.cellMeta.enableUserDefinedMetaRecording();
158
+ }
159
+ /**
160
+ * Disables tracking of user-defined cell meta properties. Writes made while disabled are treated
161
+ * as declarative (for example, the `cell` option applied during `updateSettings`).
162
+ */ disableUserDefinedMetaRecording() {
163
+ this.cellMeta.disableUserDefinedMetaRecording();
164
+ }
165
+ /**
146
166
  * Creates one or more rows at specific position.
147
167
  *
148
168
  * @param {number} physicalRow The physical row index which points from what position the row is added.
@@ -29,6 +29,7 @@ import type ColumnMeta from './columnMeta';
29
29
  * +-------------+
30
30
  */
31
31
  export default class CellMeta {
32
+ #private;
32
33
  /**
33
34
  * Reference to the ColumnMeta layer. While creating new cell meta objects, all new objects
34
35
  * inherit properties from the ColumnMeta layer.
@@ -48,6 +49,20 @@ export default class CellMeta {
48
49
  * Initializes the cell meta layer with a reference to the ColumnMeta layer used as the prototype source for new cell meta objects.
49
50
  */
50
51
  constructor(columnMeta: ColumnMeta);
52
+ /**
53
+ * Resumes tracking of user-defined cell meta properties by closing one suspension scope opened by
54
+ * `disableUserDefinedMetaRecording`. Recording becomes active again only once every suspension has
55
+ * been closed. Subsequent `setMeta` calls then mark their keys as user-defined, so they are
56
+ * preserved across `updateSettings`.
57
+ */
58
+ enableUserDefinedMetaRecording(): void;
59
+ /**
60
+ * Suspends tracking of user-defined cell meta properties. While suspended, `setMeta` calls are
61
+ * treated as declarative writes and de-mark their keys, so they are not preserved across
62
+ * `updateSettings`. Suspensions nest - each call must be matched by an `enableUserDefinedMetaRecording`
63
+ * call before recording resumes.
64
+ */
65
+ disableUserDefinedMetaRecording(): void;
51
66
  /**
52
67
  * Updates cell meta object by merging settings with the current state.
53
68
  *
@@ -130,6 +145,21 @@ export default class CellMeta {
130
145
  * @returns {object[]}
131
146
  */
132
147
  getMetasAtRow(physicalRow: number): Record<string, unknown>[];
148
+ /**
149
+ * Returns a flat snapshot of all cell meta properties that were set imperatively through
150
+ * `setMeta` (tracked in each cell's `_userDefinedMetaProps`). The coordinates are read from the
151
+ * map keys (physical indexes), not from the meta object's `row`/`col` properties, which are only
152
+ * populated on `getCellMeta` and become stale after row or column shifts. Used to preserve
153
+ * user-defined meta across a cache clear during `updateSettings`.
154
+ *
155
+ * @returns {{physicalRow: number, physicalColumn: number, key: string, value: *}[]}
156
+ */
157
+ getUserDefinedMetas(): {
158
+ physicalRow: number;
159
+ physicalColumn: number;
160
+ key: string;
161
+ value: unknown;
162
+ }[];
133
163
  /**
134
164
  * Clears all saved cell meta objects.
135
165
  */
@@ -13,13 +13,79 @@ const _lazyFactoryMap = /*#__PURE__*/ _interop_require_default(require("../lazyF
13
13
  const _object = require("../../../helpers/object");
14
14
  const _mixed = require("../../../helpers/mixed");
15
15
  const _number = require("../../../helpers/number");
16
+ function _check_private_redeclaration(obj, privateCollection) {
17
+ if (privateCollection.has(obj)) {
18
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
19
+ }
20
+ }
21
+ function _class_apply_descriptor_get(receiver, descriptor) {
22
+ if (descriptor.get) {
23
+ return descriptor.get.call(receiver);
24
+ }
25
+ return descriptor.value;
26
+ }
27
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
28
+ if (descriptor.set) {
29
+ descriptor.set.call(receiver, value);
30
+ } else {
31
+ if (!descriptor.writable) {
32
+ throw new TypeError("attempted to set read only private field");
33
+ }
34
+ descriptor.value = value;
35
+ }
36
+ }
37
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
38
+ if (!privateMap.has(receiver)) {
39
+ throw new TypeError("attempted to " + action + " private field on non-instance");
40
+ }
41
+ return privateMap.get(receiver);
42
+ }
43
+ function _class_private_field_get(receiver, privateMap) {
44
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
45
+ return _class_apply_descriptor_get(receiver, descriptor);
46
+ }
47
+ function _class_private_field_init(obj, privateMap, value) {
48
+ _check_private_redeclaration(obj, privateMap);
49
+ privateMap.set(obj, value);
50
+ }
51
+ function _class_private_field_set(receiver, privateMap, value) {
52
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
53
+ _class_apply_descriptor_set(receiver, descriptor, value);
54
+ return value;
55
+ }
16
56
  function _interop_require_default(obj) {
17
57
  return obj && obj.__esModule ? obj : {
18
58
  default: obj
19
59
  };
20
60
  }
61
+ var /**
62
+ * Counts how many times user-defined meta recording has been suspended without a matching
63
+ * resume. Recording is active only when the count is `0`. A counter (rather than a boolean) keeps
64
+ * nested suspend/resume scopes correct - for example, when a re-entrant `updateSettings` runs from
65
+ * a `setCellMeta` hook while the outer `cell` option loop is still applying declarative writes.
66
+ *
67
+ * @type {number}
68
+ */ _userDefinedMetaRecordingSuspendCount = /*#__PURE__*/ new WeakMap();
21
69
  class CellMeta {
22
70
  /**
71
+ * Resumes tracking of user-defined cell meta properties by closing one suspension scope opened by
72
+ * `disableUserDefinedMetaRecording`. Recording becomes active again only once every suspension has
73
+ * been closed. Subsequent `setMeta` calls then mark their keys as user-defined, so they are
74
+ * preserved across `updateSettings`.
75
+ */ enableUserDefinedMetaRecording() {
76
+ if (_class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) > 0) {
77
+ _class_private_field_set(this, _userDefinedMetaRecordingSuspendCount, _class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) - 1);
78
+ }
79
+ }
80
+ /**
81
+ * Suspends tracking of user-defined cell meta properties. While suspended, `setMeta` calls are
82
+ * treated as declarative writes and de-mark their keys, so they are not preserved across
83
+ * `updateSettings`. Suspensions nest - each call must be matched by an `enableUserDefinedMetaRecording`
84
+ * call before recording resumes.
85
+ */ disableUserDefinedMetaRecording() {
86
+ _class_private_field_set(this, _userDefinedMetaRecordingSuspendCount, _class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) + 1);
87
+ }
88
+ /**
23
89
  * Updates cell meta object by merging settings with the current state.
24
90
  *
25
91
  * @param {number} physicalRow The physical row index which points what cell meta object is updated.
@@ -86,6 +152,14 @@ class CellMeta {
86
152
  const cellMeta = this.metas.obtain(physicalRow).obtain(physicalColumn);
87
153
  cellMeta._automaticallyAssignedMetaProps?.delete(key);
88
154
  cellMeta[key] = value;
155
+ if (_class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) === 0) {
156
+ if (cellMeta._userDefinedMetaProps === undefined) {
157
+ cellMeta._userDefinedMetaProps = new Set();
158
+ }
159
+ cellMeta._userDefinedMetaProps.add(key);
160
+ } else {
161
+ cellMeta._userDefinedMetaProps?.delete(key);
162
+ }
89
163
  }
90
164
  /**
91
165
  * Removes a property defined by the "key" argument from the cell meta object.
@@ -96,6 +170,7 @@ class CellMeta {
96
170
  */ removeMeta(physicalRow, physicalColumn, key) {
97
171
  const cellMeta = this.metas.obtain(physicalRow).obtain(physicalColumn);
98
172
  delete cellMeta[key];
173
+ cellMeta._userDefinedMetaProps?.delete(key);
99
174
  }
100
175
  /**
101
176
  * Returns all cell meta objects that were created during the Handsontable operation. As cell meta
@@ -130,6 +205,36 @@ class CellMeta {
130
205
  return Array.from(rowsMeta.get(physicalRow)).sort(([a], [b])=>a - b).map(([, meta])=>meta);
131
206
  }
132
207
  /**
208
+ * Returns a flat snapshot of all cell meta properties that were set imperatively through
209
+ * `setMeta` (tracked in each cell's `_userDefinedMetaProps`). The coordinates are read from the
210
+ * map keys (physical indexes), not from the meta object's `row`/`col` properties, which are only
211
+ * populated on `getCellMeta` and become stale after row or column shifts. Used to preserve
212
+ * user-defined meta across a cache clear during `updateSettings`.
213
+ *
214
+ * @returns {{physicalRow: number, physicalColumn: number, key: string, value: *}[]}
215
+ */ getUserDefinedMetas() {
216
+ const result = [];
217
+ for (const [physicalRow, rowMap] of this.metas){
218
+ for (const [physicalColumn, meta] of rowMap){
219
+ const userDefinedProps = meta._userDefinedMetaProps;
220
+ if (userDefinedProps === undefined) {
221
+ continue; // eslint-disable-line no-continue
222
+ }
223
+ userDefinedProps.forEach((key)=>{
224
+ if ((0, _object.hasOwnProperty)(meta, key)) {
225
+ result.push({
226
+ physicalRow,
227
+ physicalColumn,
228
+ key,
229
+ value: meta[key]
230
+ });
231
+ }
232
+ });
233
+ }
234
+ }
235
+ return result;
236
+ }
237
+ /**
133
238
  * Clears all saved cell meta objects.
134
239
  */ clearCache() {
135
240
  this.metas.clear();
@@ -155,6 +260,10 @@ class CellMeta {
155
260
  /**
156
261
  * Initializes the cell meta layer with a reference to the ColumnMeta layer used as the prototype source for new cell meta objects.
157
262
  */ constructor(columnMeta){
263
+ _class_private_field_init(this, _userDefinedMetaRecordingSuspendCount, {
264
+ writable: true,
265
+ value: void 0
266
+ });
158
267
  /**
159
268
  * Holder for cell meta objects, organized as a grid of LazyFactoryMap of LazyFactoryMaps.
160
269
  * The access to the cell meta object is done through access to the row defined by the physical
@@ -162,6 +271,7 @@ class CellMeta {
162
271
  *
163
272
  * @type {LazyFactoryMap<number, LazyFactoryMap<number, object>>}
164
273
  */ this.metas = new _lazyFactoryMap.default(()=>this._createRow());
274
+ _class_private_field_set(this, _userDefinedMetaRecordingSuspendCount, 0);
165
275
  this.columnMeta = columnMeta;
166
276
  }
167
277
  }
@@ -1,10 +1,76 @@
1
+ function _check_private_redeclaration(obj, privateCollection) {
2
+ if (privateCollection.has(obj)) {
3
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
4
+ }
5
+ }
6
+ function _class_apply_descriptor_get(receiver, descriptor) {
7
+ if (descriptor.get) {
8
+ return descriptor.get.call(receiver);
9
+ }
10
+ return descriptor.value;
11
+ }
12
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
13
+ if (descriptor.set) {
14
+ descriptor.set.call(receiver, value);
15
+ } else {
16
+ if (!descriptor.writable) {
17
+ throw new TypeError("attempted to set read only private field");
18
+ }
19
+ descriptor.value = value;
20
+ }
21
+ }
22
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
23
+ if (!privateMap.has(receiver)) {
24
+ throw new TypeError("attempted to " + action + " private field on non-instance");
25
+ }
26
+ return privateMap.get(receiver);
27
+ }
28
+ function _class_private_field_get(receiver, privateMap) {
29
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
30
+ return _class_apply_descriptor_get(receiver, descriptor);
31
+ }
32
+ function _class_private_field_init(obj, privateMap, value) {
33
+ _check_private_redeclaration(obj, privateMap);
34
+ privateMap.set(obj, value);
35
+ }
36
+ function _class_private_field_set(receiver, privateMap, value) {
37
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
38
+ _class_apply_descriptor_set(receiver, descriptor, value);
39
+ return value;
40
+ }
1
41
  import { extendByMetaType, assert } from '../utils.mjs';
2
42
  import LazyFactoryMap from '../lazyFactoryMap.mjs';
3
- import { extend } from '../../../helpers/object.mjs';
43
+ import { extend, hasOwnProperty } from '../../../helpers/object.mjs';
4
44
  import { isDefined } from '../../../helpers/mixed.mjs';
5
45
  import { isUnsignedNumber } from '../../../helpers/number.mjs';
46
+ var /**
47
+ * Counts how many times user-defined meta recording has been suspended without a matching
48
+ * resume. Recording is active only when the count is `0`. A counter (rather than a boolean) keeps
49
+ * nested suspend/resume scopes correct - for example, when a re-entrant `updateSettings` runs from
50
+ * a `setCellMeta` hook while the outer `cell` option loop is still applying declarative writes.
51
+ *
52
+ * @type {number}
53
+ */ _userDefinedMetaRecordingSuspendCount = /*#__PURE__*/ new WeakMap();
6
54
  class CellMeta {
7
55
  /**
56
+ * Resumes tracking of user-defined cell meta properties by closing one suspension scope opened by
57
+ * `disableUserDefinedMetaRecording`. Recording becomes active again only once every suspension has
58
+ * been closed. Subsequent `setMeta` calls then mark their keys as user-defined, so they are
59
+ * preserved across `updateSettings`.
60
+ */ enableUserDefinedMetaRecording() {
61
+ if (_class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) > 0) {
62
+ _class_private_field_set(this, _userDefinedMetaRecordingSuspendCount, _class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) - 1);
63
+ }
64
+ }
65
+ /**
66
+ * Suspends tracking of user-defined cell meta properties. While suspended, `setMeta` calls are
67
+ * treated as declarative writes and de-mark their keys, so they are not preserved across
68
+ * `updateSettings`. Suspensions nest - each call must be matched by an `enableUserDefinedMetaRecording`
69
+ * call before recording resumes.
70
+ */ disableUserDefinedMetaRecording() {
71
+ _class_private_field_set(this, _userDefinedMetaRecordingSuspendCount, _class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) + 1);
72
+ }
73
+ /**
8
74
  * Updates cell meta object by merging settings with the current state.
9
75
  *
10
76
  * @param {number} physicalRow The physical row index which points what cell meta object is updated.
@@ -71,6 +137,14 @@ class CellMeta {
71
137
  const cellMeta = this.metas.obtain(physicalRow).obtain(physicalColumn);
72
138
  cellMeta._automaticallyAssignedMetaProps?.delete(key);
73
139
  cellMeta[key] = value;
140
+ if (_class_private_field_get(this, _userDefinedMetaRecordingSuspendCount) === 0) {
141
+ if (cellMeta._userDefinedMetaProps === undefined) {
142
+ cellMeta._userDefinedMetaProps = new Set();
143
+ }
144
+ cellMeta._userDefinedMetaProps.add(key);
145
+ } else {
146
+ cellMeta._userDefinedMetaProps?.delete(key);
147
+ }
74
148
  }
75
149
  /**
76
150
  * Removes a property defined by the "key" argument from the cell meta object.
@@ -81,6 +155,7 @@ class CellMeta {
81
155
  */ removeMeta(physicalRow, physicalColumn, key) {
82
156
  const cellMeta = this.metas.obtain(physicalRow).obtain(physicalColumn);
83
157
  delete cellMeta[key];
158
+ cellMeta._userDefinedMetaProps?.delete(key);
84
159
  }
85
160
  /**
86
161
  * Returns all cell meta objects that were created during the Handsontable operation. As cell meta
@@ -115,6 +190,36 @@ class CellMeta {
115
190
  return Array.from(rowsMeta.get(physicalRow)).sort(([a], [b])=>a - b).map(([, meta])=>meta);
116
191
  }
117
192
  /**
193
+ * Returns a flat snapshot of all cell meta properties that were set imperatively through
194
+ * `setMeta` (tracked in each cell's `_userDefinedMetaProps`). The coordinates are read from the
195
+ * map keys (physical indexes), not from the meta object's `row`/`col` properties, which are only
196
+ * populated on `getCellMeta` and become stale after row or column shifts. Used to preserve
197
+ * user-defined meta across a cache clear during `updateSettings`.
198
+ *
199
+ * @returns {{physicalRow: number, physicalColumn: number, key: string, value: *}[]}
200
+ */ getUserDefinedMetas() {
201
+ const result = [];
202
+ for (const [physicalRow, rowMap] of this.metas){
203
+ for (const [physicalColumn, meta] of rowMap){
204
+ const userDefinedProps = meta._userDefinedMetaProps;
205
+ if (userDefinedProps === undefined) {
206
+ continue; // eslint-disable-line no-continue
207
+ }
208
+ userDefinedProps.forEach((key)=>{
209
+ if (hasOwnProperty(meta, key)) {
210
+ result.push({
211
+ physicalRow,
212
+ physicalColumn,
213
+ key,
214
+ value: meta[key]
215
+ });
216
+ }
217
+ });
218
+ }
219
+ }
220
+ return result;
221
+ }
222
+ /**
118
223
  * Clears all saved cell meta objects.
119
224
  */ clearCache() {
120
225
  this.metas.clear();
@@ -140,6 +245,10 @@ class CellMeta {
140
245
  /**
141
246
  * Initializes the cell meta layer with a reference to the ColumnMeta layer used as the prototype source for new cell meta objects.
142
247
  */ constructor(columnMeta){
248
+ _class_private_field_init(this, _userDefinedMetaRecordingSuspendCount, {
249
+ writable: true,
250
+ value: void 0
251
+ });
143
252
  /**
144
253
  * Holder for cell meta objects, organized as a grid of LazyFactoryMap of LazyFactoryMaps.
145
254
  * The access to the cell meta object is done through access to the row defined by the physical
@@ -147,6 +256,7 @@ class CellMeta {
147
256
  *
148
257
  * @type {LazyFactoryMap<number, LazyFactoryMap<number, object>>}
149
258
  */ this.metas = new LazyFactoryMap(()=>this._createRow());
259
+ _class_private_field_set(this, _userDefinedMetaRecordingSuspendCount, 0);
150
260
  this.columnMeta = columnMeta;
151
261
  }
152
262
  }
@@ -137,6 +137,15 @@ const _default = ()=>{
137
137
  * @default undefined
138
138
  */ _automaticallyAssignedMetaProps: undefined,
139
139
  /**
140
+ * Information on which of the cell meta properties were set imperatively through `setCellMeta`
141
+ * (for example, by the user or by the context menu). These properties are preserved across
142
+ * `updateSettings` calls, unlike the properties applied from the declarative `cell` option.
143
+ *
144
+ * @private
145
+ * @type {Set}
146
+ * @default undefined
147
+ */ _userDefinedMetaProps: undefined,
148
+ /**
140
149
  * The `activeHeaderClassName` option lets you add a CSS class name
141
150
  * to every currently-active, currently-selected header (when a whole column or row is selected).
142
151
  *
@@ -127,6 +127,15 @@ import { isObjectEqual } from '../../helpers/object.mjs';
127
127
  * @default undefined
128
128
  */ _automaticallyAssignedMetaProps: undefined,
129
129
  /**
130
+ * Information on which of the cell meta properties were set imperatively through `setCellMeta`
131
+ * (for example, by the user or by the context menu). These properties are preserved across
132
+ * `updateSettings` calls, unlike the properties applied from the declarative `cell` option.
133
+ *
134
+ * @private
135
+ * @type {Set}
136
+ * @default undefined
137
+ */ _userDefinedMetaProps: undefined,
138
+ /**
130
139
  * The `activeHeaderClassName` option lets you add a CSS class name
131
140
  * to every currently-active, currently-selected header (when a whole column or row is selected).
132
141
  *
@@ -1,5 +1,14 @@
1
+ import type { HotInstance } from '../core/types';
2
+ type SourceDataValidatorFn = {
3
+ (value: unknown, cellMeta: CellMeta, source?: string): boolean;
4
+ /**
5
+ * When `true`, the validator's result depends only on the value and column/global-level meta, never
6
+ * on per-row meta — so a single column-level meta object can validate every row of the column.
7
+ */
8
+ rowIndependent?: boolean;
9
+ };
1
10
  type CellMeta = Record<string, unknown> & {
2
- sourceDataValidator?: (value: unknown, cellMeta: CellMeta, source?: string) => boolean;
11
+ sourceDataValidator?: SourceDataValidatorFn;
3
12
  sourceDataWarningMessage?: string;
4
13
  allowInvalid?: boolean;
5
14
  row?: number;
@@ -7,10 +16,24 @@ type CellMeta = Record<string, unknown> & {
7
16
  };
8
17
  /**
9
18
  * Runs source-data validator for a single cell.
19
+ *
20
+ * @param {unknown} value The value to validate.
21
+ * @param {object} cellMeta The cell meta object.
22
+ * @param {string} [source] The source identifier of the operation.
23
+ * @returns {boolean} `true` when the value is valid (or no validator is configured).
10
24
  */
11
25
  export declare function runSourceDataValidator(value: unknown, cellMeta: CellMeta, source?: string): boolean;
12
26
  /**
13
27
  * Runs source-data validators for all cells and emits one aggregated warning per cell type.
28
+ *
29
+ * For the common case (no `cells` function, no `cell` array, no `before`/`afterGetCellMeta` hooks, no
30
+ * imperatively-set cell meta, and only row-independent built-in source validators such as `date`/`time`),
31
+ * validation reuses one column-level meta per column — avoiding the O(rows*cols) cell-meta
32
+ * materialization that otherwise retains a meta object for every cell at load.
33
+ *
34
+ * @param {HotInstance} hotInstance The Handsontable instance.
35
+ * @param {string} [source] The source identifier of the operation.
36
+ * @returns {void}
14
37
  */
15
- export declare function runSourceDataValidators(hotInstance: Record<string, unknown>, source?: string): void;
38
+ export declare function runSourceDataValidators(hotInstance: HotInstance, source?: string): void;
16
39
  export {};