handsontable 0.0.0-next-8f89e29-20241003 → 0.0.0-next-3d1a0ea-20241007

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (113) hide show
  1. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.js +23 -0
  2. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.mjs +23 -0
  3. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.js +23 -0
  4. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.mjs +23 -0
  5. package/3rdparty/walkontable/src/core/_base.js +7 -0
  6. package/3rdparty/walkontable/src/core/_base.mjs +7 -0
  7. package/3rdparty/walkontable/src/facade/core.js +3 -0
  8. package/3rdparty/walkontable/src/facade/core.mjs +3 -0
  9. package/3rdparty/walkontable/src/overlay/_base.js +3 -0
  10. package/3rdparty/walkontable/src/overlay/_base.mjs +3 -0
  11. package/3rdparty/walkontable/src/selection/border/border.js +32 -44
  12. package/3rdparty/walkontable/src/selection/border/border.mjs +32 -44
  13. package/3rdparty/walkontable/src/selection/scanner.js +46 -11
  14. package/3rdparty/walkontable/src/selection/scanner.mjs +46 -11
  15. package/3rdparty/walkontable/src/settings.js +8 -0
  16. package/3rdparty/walkontable/src/settings.mjs +8 -0
  17. package/3rdparty/walkontable/src/table.js +6 -3
  18. package/3rdparty/walkontable/src/table.mjs +6 -3
  19. package/3rdparty/walkontable/src/viewport.js +26 -4
  20. package/3rdparty/walkontable/src/viewport.mjs +26 -4
  21. package/base.js +4 -4
  22. package/base.mjs +3 -3
  23. package/core/hooks/bucket.js +180 -0
  24. package/core/hooks/bucket.mjs +176 -0
  25. package/{pluginHooks.mjs → core/hooks/constants.js} +20 -486
  26. package/{pluginHooks.js → core/hooks/constants.mjs} +16 -489
  27. package/{pluginHooks.d.ts → core/hooks/index.d.ts} +17 -21
  28. package/core/hooks/index.js +385 -0
  29. package/core/hooks/index.mjs +381 -0
  30. package/core.d.ts +1 -1
  31. package/core.js +13 -12
  32. package/core.mjs +5 -4
  33. package/dataMap/metaManager/metaSchema.js +68 -2
  34. package/dataMap/metaManager/metaSchema.mjs +68 -2
  35. package/dataMap/metaManager/mods/dynamicCellMeta.js +2 -3
  36. package/dataMap/metaManager/mods/dynamicCellMeta.mjs +1 -1
  37. package/dist/handsontable.css +2 -2
  38. package/dist/handsontable.full.css +2 -2
  39. package/dist/handsontable.full.js +3009 -2582
  40. package/dist/handsontable.full.min.css +2 -2
  41. package/dist/handsontable.full.min.js +79 -79
  42. package/dist/handsontable.js +3011 -2584
  43. package/dist/handsontable.min.css +2 -2
  44. package/dist/handsontable.min.js +18 -18
  45. package/editorManager.js +2 -2
  46. package/editorManager.mjs +2 -2
  47. package/editors/baseEditor/baseEditor.js +23 -16
  48. package/editors/baseEditor/baseEditor.mjs +23 -16
  49. package/editors/dropdownEditor/dropdownEditor.js +2 -3
  50. package/editors/dropdownEditor/dropdownEditor.mjs +1 -1
  51. package/editors/registry.js +2 -2
  52. package/editors/registry.mjs +1 -1
  53. package/helpers/mixed.js +1 -1
  54. package/helpers/mixed.mjs +1 -1
  55. package/index.d.ts +2 -1
  56. package/package.json +1 -1
  57. package/plugins/autoColumnSize/autoColumnSize.js +18 -27
  58. package/plugins/autoColumnSize/autoColumnSize.mjs +18 -27
  59. package/plugins/autoRowSize/autoRowSize.js +16 -22
  60. package/plugins/autoRowSize/autoRowSize.mjs +17 -23
  61. package/plugins/autofill/autofill.js +4 -5
  62. package/plugins/autofill/autofill.mjs +1 -1
  63. package/plugins/base/base.d.ts +1 -1
  64. package/plugins/base/base.js +39 -0
  65. package/plugins/base/base.mjs +40 -1
  66. package/plugins/base/index.js +2 -1
  67. package/plugins/base/index.mjs +1 -1
  68. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +2 -5
  69. package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +2 -5
  70. package/plugins/columnSorting/columnSorting.js +3 -4
  71. package/plugins/columnSorting/columnSorting.mjs +1 -1
  72. package/plugins/comments/comments.js +7 -15
  73. package/plugins/comments/comments.mjs +8 -16
  74. package/plugins/contextMenu/contextMenu.js +6 -7
  75. package/plugins/contextMenu/contextMenu.mjs +1 -1
  76. package/plugins/copyPaste/copyPaste.js +29 -23
  77. package/plugins/copyPaste/copyPaste.mjs +21 -15
  78. package/plugins/dropdownMenu/dropdownMenu.js +6 -7
  79. package/plugins/dropdownMenu/dropdownMenu.mjs +1 -1
  80. package/plugins/formulas/formulas.js +7 -7
  81. package/plugins/formulas/formulas.mjs +1 -1
  82. package/plugins/hiddenColumns/hiddenColumns.js +19 -30
  83. package/plugins/hiddenColumns/hiddenColumns.mjs +15 -26
  84. package/plugins/hiddenRows/hiddenRows.js +18 -29
  85. package/plugins/hiddenRows/hiddenRows.mjs +14 -25
  86. package/plugins/manualColumnFreeze/manualColumnFreeze.js +5 -5
  87. package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +1 -1
  88. package/plugins/manualColumnMove/manualColumnMove.js +3 -3
  89. package/plugins/manualColumnMove/manualColumnMove.mjs +1 -1
  90. package/plugins/manualRowMove/manualRowMove.js +5 -5
  91. package/plugins/manualRowMove/manualRowMove.mjs +3 -3
  92. package/plugins/mergeCells/cellsCollection.js +15 -3
  93. package/plugins/mergeCells/cellsCollection.mjs +16 -4
  94. package/plugins/mergeCells/mergeCells.d.ts +6 -2
  95. package/plugins/mergeCells/mergeCells.js +78 -55
  96. package/plugins/mergeCells/mergeCells.mjs +76 -53
  97. package/plugins/mergeCells/renderer.js +13 -3
  98. package/plugins/mergeCells/renderer.mjs +13 -3
  99. package/plugins/persistentState/persistentState.js +4 -4
  100. package/plugins/persistentState/persistentState.mjs +1 -1
  101. package/plugins/undoRedo/undoRedo.js +4 -5
  102. package/plugins/undoRedo/undoRedo.mjs +3 -3
  103. package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
  104. package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
  105. package/settings.d.ts +3 -1
  106. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +1 -1
  107. package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +1 -1
  108. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +1 -1
  109. package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +1 -1
  110. package/shortcutContexts/commands/scrollToFocusedCell.js +4 -4
  111. package/shortcutContexts/commands/scrollToFocusedCell.mjs +4 -4
  112. package/tableView.js +40 -9
  113. package/tableView.mjs +40 -9
@@ -0,0 +1,381 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/es.array.push.js";
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ import { arrayEach } from "../../helpers/array.mjs";
7
+ import { substitute } from "../../helpers/string.mjs";
8
+ import { warn } from "../../helpers/console.mjs";
9
+ import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
10
+ import { fastCall } from "../../helpers/function.mjs";
11
+ import { REGISTERED_HOOKS, REMOVED_HOOKS, DEPRECATED_HOOKS } from "./constants.mjs";
12
+ import { HooksBucket } from "./bucket.mjs";
13
+ /**
14
+ * Template warning message for removed hooks.
15
+ *
16
+ * @type {string}
17
+ */
18
+ const REMOVED_MESSAGE = toSingleLine`The plugin hook "[hookName]" was removed in Handsontable [removedInVersion].\x20
19
+ Please consult release notes https://github.com/handsontable/handsontable/releases/tag/[removedInVersion] to\x20
20
+ learn about the migration path.`;
21
+ export class Hooks {
22
+ constructor() {
23
+ /**
24
+ * @type {HooksBucket}
25
+ */
26
+ _defineProperty(this, "globalBucket", new HooksBucket());
27
+ }
28
+ static getSingleton() {
29
+ return getGlobalSingleton();
30
+ }
31
+ /**
32
+ * Get hook bucket based on the context of the object or if argument is missing, get the global hook bucket.
33
+ *
34
+ * @param {object} [context=null] A Handsontable instance.
35
+ * @returns {HooksBucket} Returns a global or Handsontable instance bucket.
36
+ */
37
+ getBucket() {
38
+ let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
39
+ if (context) {
40
+ if (!context.pluginHookBucket) {
41
+ context.pluginHookBucket = new HooksBucket();
42
+ }
43
+ return context.pluginHookBucket;
44
+ }
45
+ return this.globalBucket;
46
+ }
47
+
48
+ /**
49
+ * Adds a listener (globally or locally) to a specified hook name.
50
+ * If the `context` parameter is provided, the hook will be added only to the instance it references.
51
+ * Otherwise, the callback will be used every time the hook fires on any Handsontable instance.
52
+ * You can provide an array of callback functions as the `callback` argument, this way they will all be fired
53
+ * once the hook is triggered.
54
+ *
55
+ * @param {string} key Hook name.
56
+ * @param {Function|Function[]} callback Callback function or an array of functions.
57
+ * @param {object} [context=null] The context for the hook callback to be added - a Handsontable instance or leave empty.
58
+ * @param {number} [orderIndex] Order index of the callback.
59
+ * If > 0, the callback will be added after the others, for example, with an index of 1, the callback will be added before the ones with an index of 2, 3, etc., but after the ones with an index of 0 and lower.
60
+ * If < 0, the callback will be added before the others, for example, with an index of -1, the callback will be added after the ones with an index of -2, -3, etc., but before the ones with an index of 0 and higher.
61
+ * If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
62
+ * @returns {Hooks} Instance of Hooks.
63
+ *
64
+ * @example
65
+ * ```js
66
+ * // single callback, added locally
67
+ * Handsontable.hooks.add('beforeInit', myCallback, hotInstance);
68
+ *
69
+ * // single callback, added globally
70
+ * Handsontable.hooks.add('beforeInit', myCallback);
71
+ *
72
+ * // multiple callbacks, added locally
73
+ * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance);
74
+ *
75
+ * // multiple callbacks, added globally
76
+ * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]);
77
+ * ```
78
+ */
79
+ add(key, callback) {
80
+ let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
81
+ let orderIndex = arguments.length > 3 ? arguments[3] : undefined;
82
+ if (Array.isArray(callback)) {
83
+ arrayEach(callback, c => this.add(key, c, context));
84
+ } else {
85
+ if (REMOVED_HOOKS.has(key)) {
86
+ warn(substitute(REMOVED_MESSAGE, {
87
+ hookName: key,
88
+ removedInVersion: REMOVED_HOOKS.get(key)
89
+ }));
90
+ }
91
+ if (DEPRECATED_HOOKS.has(key)) {
92
+ warn(DEPRECATED_HOOKS.get(key));
93
+ }
94
+ this.getBucket(context).add(key, callback, {
95
+ orderIndex,
96
+ runOnce: false
97
+ });
98
+ }
99
+ return this;
100
+ }
101
+
102
+ /**
103
+ * Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket.
104
+ *
105
+ * @param {string} key Hook/Event name.
106
+ * @param {Function|Function[]} callback Callback function.
107
+ * @param {object} [context=null] A Handsontable instance.
108
+ * @param {number} [orderIndex] Order index of the callback.
109
+ * If > 0, the callback will be added after the others, for example, with an index of 1, the callback will be added before the ones with an index of 2, 3, etc., but after the ones with an index of 0 and lower.
110
+ * If < 0, the callback will be added before the others, for example, with an index of -1, the callback will be added after the ones with an index of -2, -3, etc., but before the ones with an index of 0 and higher.
111
+ * If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
112
+ * @returns {Hooks} Instance of Hooks.
113
+ *
114
+ * @example
115
+ * ```js
116
+ * Handsontable.hooks.once('beforeInit', myCallback, hotInstance);
117
+ * ```
118
+ */
119
+ once(key, callback) {
120
+ let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
121
+ let orderIndex = arguments.length > 3 ? arguments[3] : undefined;
122
+ if (Array.isArray(callback)) {
123
+ arrayEach(callback, c => this.once(key, c, context));
124
+ } else {
125
+ this.getBucket(context).add(key, callback, {
126
+ orderIndex,
127
+ runOnce: true
128
+ });
129
+ }
130
+ return this;
131
+ }
132
+
133
+ /**
134
+ * Adds a listener to a specified hook. The added hook stays in the bucket at specified index position even after
135
+ * adding another one with the same hook name.
136
+ *
137
+ * @param {string} key Hook/Event name.
138
+ * @param {Function|Function[]} callback Callback function.
139
+ * @param {object} [context=null] A Handsontable instance.
140
+ * @returns {Hooks} Instance of Hooks.
141
+ *
142
+ * @example
143
+ * ```js
144
+ * Handsontable.hooks.addAsFixed('beforeInit', myCallback, hotInstance);
145
+ * ```
146
+ */
147
+ addAsFixed(key, callback) {
148
+ let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
149
+ if (Array.isArray(callback)) {
150
+ arrayEach(callback, c => this.addAsFixed(key, c, context));
151
+ } else {
152
+ this.getBucket(context).add(key, callback, {
153
+ initialHook: true
154
+ });
155
+ }
156
+ return this;
157
+ }
158
+
159
+ /**
160
+ * Removes a listener from a hook with a given name. If the `context` argument is provided, it removes a listener from a local hook assigned to the given Handsontable instance.
161
+ *
162
+ * @param {string} key Hook/Event name.
163
+ * @param {Function} callback Callback function (needs the be the function that was previously added to the hook).
164
+ * @param {object} [context=null] Handsontable instance.
165
+ * @returns {boolean} Returns `true` if hook was removed, `false` otherwise.
166
+ *
167
+ * @example
168
+ * ```js
169
+ * Handsontable.hooks.remove('beforeInit', myCallback);
170
+ * ```
171
+ */
172
+ remove(key, callback) {
173
+ let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
174
+ return this.getBucket(context).remove(key, callback);
175
+ }
176
+
177
+ /**
178
+ * Checks whether there are any registered listeners for the provided hook name.
179
+ * If the `context` parameter is provided, it only checks for listeners assigned to the given Handsontable instance.
180
+ *
181
+ * @param {string} key Hook name.
182
+ * @param {object} [context=null] A Handsontable instance.
183
+ * @returns {boolean} `true` for success, `false` otherwise.
184
+ */
185
+ has(key) {
186
+ let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
187
+ return this.getBucket(context).has(key);
188
+ }
189
+
190
+ /**
191
+ * Runs all local and global callbacks assigned to the hook identified by the `key` parameter.
192
+ * It returns either a return value from the last called callback or the first parameter (`p1`) passed to the `run` function.
193
+ *
194
+ * @param {object} context Handsontable instance.
195
+ * @param {string} key Hook/Event name.
196
+ * @param {*} [p1] Parameter to be passed as an argument to the callback function.
197
+ * @param {*} [p2] Parameter to be passed as an argument to the callback function.
198
+ * @param {*} [p3] Parameter to be passed as an argument to the callback function.
199
+ * @param {*} [p4] Parameter to be passed as an argument to the callback function.
200
+ * @param {*} [p5] Parameter to be passed as an argument to the callback function.
201
+ * @param {*} [p6] Parameter to be passed as an argument to the callback function.
202
+ * @returns {*} Either a return value from the last called callback or `p1`.
203
+ *
204
+ * @example
205
+ * ```js
206
+ * Handsontable.hooks.run(hot, 'beforeInit');
207
+ * ```
208
+ */
209
+ run(context, key, p1, p2, p3, p4, p5, p6) {
210
+ {
211
+ const globalHandlers = this.getBucket().getHooks(key);
212
+ const length = globalHandlers ? globalHandlers.length : 0;
213
+ let index = 0;
214
+ if (length) {
215
+ // Do not optimize this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
216
+ while (index < length) {
217
+ if (!globalHandlers[index] || globalHandlers[index].skip) {
218
+ index += 1;
219
+ /* eslint-disable no-continue */
220
+ continue;
221
+ }
222
+ const res = fastCall(globalHandlers[index].callback, context, p1, p2, p3, p4, p5, p6);
223
+ if (res !== undefined) {
224
+ // eslint-disable-next-line no-param-reassign
225
+ p1 = res;
226
+ }
227
+ if (globalHandlers[index] && globalHandlers[index].runOnce) {
228
+ this.remove(key, globalHandlers[index].callback);
229
+ }
230
+ index += 1;
231
+ }
232
+ }
233
+ }
234
+ {
235
+ const localHandlers = this.getBucket(context).getHooks(key);
236
+ const length = localHandlers ? localHandlers.length : 0;
237
+ let index = 0;
238
+ if (length) {
239
+ // Do not optimize this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
240
+ while (index < length) {
241
+ if (!localHandlers[index] || localHandlers[index].skip) {
242
+ index += 1;
243
+ /* eslint-disable no-continue */
244
+ continue;
245
+ }
246
+ const res = fastCall(localHandlers[index].callback, context, p1, p2, p3, p4, p5, p6);
247
+ if (res !== undefined) {
248
+ // eslint-disable-next-line no-param-reassign
249
+ p1 = res;
250
+ }
251
+ if (localHandlers[index] && localHandlers[index].runOnce) {
252
+ this.remove(key, localHandlers[index].callback, context);
253
+ }
254
+ index += 1;
255
+ }
256
+ }
257
+ }
258
+ return p1;
259
+ }
260
+
261
+ /**
262
+ * Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed.
263
+ *
264
+ * @param {object} [context=null] A Handsontable instance.
265
+ * @example
266
+ * ```js
267
+ * // destroy the global listeners
268
+ * Handsontable.hooks.destroy();
269
+ *
270
+ * // destroy the local listeners
271
+ * Handsontable.hooks.destroy(hotInstance);
272
+ * ```
273
+ */
274
+ destroy() {
275
+ let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
276
+ this.getBucket(context).destroy();
277
+ }
278
+
279
+ /**
280
+ * Registers a hook name (adds it to the list of the known hook names). Used by plugins.
281
+ * It is not necessary to call register, but if you use it, your plugin hook will be used returned by
282
+ * the `getRegistered` method. (which itself is used in the [demo](@/guides/getting-started/events-and-hooks/events-and-hooks.md)).
283
+ *
284
+ * @param {string} key The hook name.
285
+ *
286
+ * @example
287
+ * ```js
288
+ * Handsontable.hooks.register('myHook');
289
+ * ```
290
+ */
291
+ register(key) {
292
+ if (!this.isRegistered(key)) {
293
+ REGISTERED_HOOKS.push(key);
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Deregisters a hook name (removes it from the list of known hook names).
299
+ *
300
+ * @param {string} key The hook name.
301
+ *
302
+ * @example
303
+ * ```js
304
+ * Handsontable.hooks.deregister('myHook');
305
+ * ```
306
+ */
307
+ deregister(key) {
308
+ if (this.isRegistered(key)) {
309
+ REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Returns a boolean value depending on if a hook by such name has been removed or deprecated.
315
+ *
316
+ * @param {string} hookName The hook name to check.
317
+ * @returns {boolean} Returns `true` if the provided hook name was marked as deprecated or
318
+ * removed from API, `false` otherwise.
319
+ * @example
320
+ * ```js
321
+ * Handsontable.hooks.isDeprecated('skipLengthCache');
322
+ *
323
+ * // Results:
324
+ * true
325
+ * ```
326
+ */
327
+ isDeprecated(hookName) {
328
+ return DEPRECATED_HOOKS.has(hookName) || REMOVED_HOOKS.has(hookName);
329
+ }
330
+
331
+ /**
332
+ * Returns a boolean depending on if a hook by such name has been registered.
333
+ *
334
+ * @param {string} hookName The hook name to check.
335
+ * @returns {boolean} `true` for success, `false` otherwise.
336
+ * @example
337
+ * ```js
338
+ * Handsontable.hooks.isRegistered('beforeInit');
339
+ *
340
+ * // Results:
341
+ * true
342
+ * ```
343
+ */
344
+ isRegistered(hookName) {
345
+ return REGISTERED_HOOKS.indexOf(hookName) >= 0;
346
+ }
347
+
348
+ /**
349
+ * Returns an array of registered hooks.
350
+ *
351
+ * @returns {Array} An array of registered hooks.
352
+ *
353
+ * @example
354
+ * ```js
355
+ * Handsontable.hooks.getRegistered();
356
+ *
357
+ * // Results:
358
+ * [
359
+ * ...
360
+ * 'beforeInit',
361
+ * 'beforeRender',
362
+ * 'beforeSetRangeEnd',
363
+ * 'beforeDrawBorders',
364
+ * 'beforeChange',
365
+ * ...
366
+ * ]
367
+ * ```
368
+ */
369
+ getRegistered() {
370
+ return REGISTERED_HOOKS;
371
+ }
372
+ }
373
+ const globalSingleton = new Hooks();
374
+
375
+ /**
376
+ * @returns {Hooks}
377
+ */
378
+ function getGlobalSingleton() {
379
+ return globalSingleton;
380
+ }
381
+ export default Hooks;
package/core.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IndexMapper } from './translations';
2
- import { Events } from './pluginHooks';
2
+ import { Events } from './core/hooks';
3
3
  import {
4
4
  CellValue,
5
5
  RowObject,
package/core.js CHANGED
@@ -34,7 +34,7 @@ var _data = require("./helpers/data");
34
34
  var _translations = require("./translations");
35
35
  var _rootInstance = require("./utils/rootInstance");
36
36
  var _src = require("./3rdparty/walkontable/src");
37
- var _pluginHooks = _interopRequireDefault(require("./pluginHooks"));
37
+ var _hooks = require("./core/hooks");
38
38
  var _registry5 = require("./i18n/registry");
39
39
  var _utils = require("./i18n/utils");
40
40
  var _selection = require("./selection");
@@ -2293,10 +2293,11 @@ function Core(rootElement, userSettings) {
2293
2293
  } else if (i === 'tableClassName' && instance.table) {
2294
2294
  setClassName('tableClassName', settings.tableClassName);
2295
2295
  instance.view._wt.wtOverlays.syncOverlayTableClassNames();
2296
- } else if (_pluginHooks.default.getSingleton().isRegistered(i) || _pluginHooks.default.getSingleton().isDeprecated(i)) {
2297
- if ((0, _function.isFunction)(settings[i]) || Array.isArray(settings[i])) {
2298
- settings[i].initialHook = true;
2299
- instance.addHook(i, settings[i]);
2296
+ } else if (_hooks.Hooks.getSingleton().isRegistered(i) || _hooks.Hooks.getSingleton().isDeprecated(i)) {
2297
+ if ((0, _function.isFunction)(settings[i])) {
2298
+ _hooks.Hooks.getSingleton().addAsFixed(i, settings[i], instance);
2299
+ } else if (Array.isArray(settings[i])) {
2300
+ _hooks.Hooks.getSingleton().add(i, settings[i], instance);
2300
2301
  }
2301
2302
  } else if (!init && (0, _object.hasOwnProperty)(settings, i)) {
2302
2303
  // Update settings
@@ -4191,7 +4192,7 @@ function Core(rootElement, userSettings) {
4191
4192
  pluginsRegistry.clear();
4192
4193
  instance.runHooks('afterDestroy');
4193
4194
  }, true);
4194
- _pluginHooks.default.getSingleton().destroy(instance);
4195
+ _hooks.Hooks.getSingleton().destroy(instance);
4195
4196
  (0, _object.objectEach)(instance, (property, key, obj) => {
4196
4197
  // replace instance methods with post mortem
4197
4198
  if ((0, _function.isFunction)(property)) {
@@ -4455,7 +4456,7 @@ function Core(rootElement, userSettings) {
4455
4456
  * ```
4456
4457
  */
4457
4458
  this.addHook = function (key, callback, orderIndex) {
4458
- _pluginHooks.default.getSingleton().add(key, callback, instance, orderIndex);
4459
+ _hooks.Hooks.getSingleton().add(key, callback, instance, orderIndex);
4459
4460
  };
4460
4461
 
4461
4462
  /**
@@ -4474,7 +4475,7 @@ function Core(rootElement, userSettings) {
4474
4475
  * ```
4475
4476
  */
4476
4477
  this.hasHook = function (key) {
4477
- return _pluginHooks.default.getSingleton().has(key, instance) || _pluginHooks.default.getSingleton().has(key);
4478
+ return _hooks.Hooks.getSingleton().has(key, instance) || _hooks.Hooks.getSingleton().has(key);
4478
4479
  };
4479
4480
 
4480
4481
  /**
@@ -4496,7 +4497,7 @@ function Core(rootElement, userSettings) {
4496
4497
  * ```
4497
4498
  */
4498
4499
  this.addHookOnce = function (key, callback, orderIndex) {
4499
- _pluginHooks.default.getSingleton().once(key, callback, instance, orderIndex);
4500
+ _hooks.Hooks.getSingleton().once(key, callback, instance, orderIndex);
4500
4501
  };
4501
4502
 
4502
4503
  /**
@@ -4514,7 +4515,7 @@ function Core(rootElement, userSettings) {
4514
4515
  * ```
4515
4516
  */
4516
4517
  this.removeHook = function (key, callback) {
4517
- _pluginHooks.default.getSingleton().remove(key, callback, instance);
4518
+ _hooks.Hooks.getSingleton().remove(key, callback, instance);
4518
4519
  };
4519
4520
 
4520
4521
  /**
@@ -4541,7 +4542,7 @@ function Core(rootElement, userSettings) {
4541
4542
  * ```
4542
4543
  */
4543
4544
  this.runHooks = function (key, p1, p2, p3, p4, p5, p6) {
4544
- return _pluginHooks.default.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
4545
+ return _hooks.Hooks.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
4545
4546
  };
4546
4547
 
4547
4548
  /**
@@ -4731,5 +4732,5 @@ function Core(rootElement, userSettings) {
4731
4732
  });
4732
4733
  (0, _shortcutContexts.registerAllShortcutContexts)(instance);
4733
4734
  shortcutManager.setActiveContextName('grid');
4734
- _pluginHooks.default.getSingleton().run(instance, 'construct');
4735
+ _hooks.Hooks.getSingleton().run(instance, 'construct');
4735
4736
  }
package/core.mjs CHANGED
@@ -30,7 +30,7 @@ import { spreadsheetColumnLabel } from "./helpers/data.mjs";
30
30
  import { IndexMapper } from "./translations/index.mjs";
31
31
  import { registerAsRootInstance, hasValidParameter, isRootInstance } from "./utils/rootInstance.mjs";
32
32
  import { DEFAULT_COLUMN_WIDTH } from "./3rdparty/walkontable/src/index.mjs";
33
- import Hooks from "./pluginHooks.mjs";
33
+ import { Hooks } from "./core/hooks/index.mjs";
34
34
  import { hasLanguageDictionary, getValidLanguageCode, getTranslatedPhrase } from "./i18n/registry.mjs";
35
35
  import { warnUserAboutLanguageRegistration, normalizeLanguageCode } from "./i18n/utils.mjs";
36
36
  import { Selection } from "./selection/index.mjs";
@@ -2289,9 +2289,10 @@ export default function Core(rootElement, userSettings) {
2289
2289
  setClassName('tableClassName', settings.tableClassName);
2290
2290
  instance.view._wt.wtOverlays.syncOverlayTableClassNames();
2291
2291
  } else if (Hooks.getSingleton().isRegistered(i) || Hooks.getSingleton().isDeprecated(i)) {
2292
- if (isFunction(settings[i]) || Array.isArray(settings[i])) {
2293
- settings[i].initialHook = true;
2294
- instance.addHook(i, settings[i]);
2292
+ if (isFunction(settings[i])) {
2293
+ Hooks.getSingleton().addAsFixed(i, settings[i], instance);
2294
+ } else if (Array.isArray(settings[i])) {
2295
+ Hooks.getSingleton().add(i, settings[i], instance);
2295
2296
  }
2296
2297
  } else if (!init && hasOwnProperty(settings, i)) {
2297
2298
  // Update settings
@@ -4681,7 +4681,7 @@ var _default = () => {
4681
4681
  * - [Performance: Define the number of pre-rendered rows and columns](@/guides/optimization/performance/performance.md#define-the-number-of-pre-rendered-rows-and-columns)
4682
4682
  *
4683
4683
  * @memberof Options#
4684
- * @type {number|string}
4684
+ * @type {number|'auto'}
4685
4685
  * @default 'auto'
4686
4686
  * @category Core
4687
4687
  *
@@ -4711,7 +4711,7 @@ var _default = () => {
4711
4711
  * - [Column virtualization](@/guides/columns/column-virtualization/column-virtualization.md)
4712
4712
  *
4713
4713
  * @memberof Options#
4714
- * @type {number|string}
4714
+ * @type {number|'auto'}
4715
4715
  * @default 'auto'
4716
4716
  * @category Core
4717
4717
  *
@@ -4722,6 +4722,72 @@ var _default = () => {
4722
4722
  * ```
4723
4723
  */
4724
4724
  viewportRowRenderingOffset: 'auto',
4725
+ /**
4726
+ * @description
4727
+ * The `viewportColumnRenderingThreshold` option configures what column number starting from the left or right
4728
+ * (depends on the scroll direction) should trigger the rendering of columns outside of the grid's viewport.
4729
+ *
4730
+ * You can set the `viewportColumnRenderingThreshold` option to one of the following:
4731
+ *
4732
+ * | Setting | Description |
4733
+ * | ------------------ | ------------------------------------------------------- |
4734
+ * | `auto` | Triggers rendering at half the offset defined by [`viewportColumnRenderingOffset`](#viewportColumnRenderingOffset) option |
4735
+ * | A number | Sets the offset manually (`0` is a default) |
4736
+ *
4737
+ * The `viewportColumnRenderingThreshold` setting is ignored when [`renderAllColumn`](#renderAllColumn) is set to `true`.
4738
+ *
4739
+ * Read more:
4740
+ * - [Performance: Define the number of pre-rendered rows and columns](@/guides/optimization/performance/performance.md#define-the-number-of-pre-rendered-rows-and-columns)
4741
+ * - [Column virtualization](@/guides/columns/column-virtualization/column-virtualization.md)
4742
+ *
4743
+ * @memberof Options#
4744
+ * @since 1.14.7
4745
+ * @type {number|'auto'}
4746
+ * @default 0
4747
+ * @category Core
4748
+ *
4749
+ * @example
4750
+ * ```js
4751
+ * // render 12 columns outside of the grid's viewport
4752
+ * viewportColumnRenderingOffset: 12,
4753
+ * // the columns outside of the viewport will be rendered when the user scrolls to the 8th column from/to
4754
+ * viewportColumnRenderingThreshold: 8,
4755
+ * ```
4756
+ */
4757
+ viewportColumnRenderingThreshold: 0,
4758
+ /**
4759
+ * @description
4760
+ * The `viewportRowRenderingThreshold` option configures what row number starting from the top or bottom
4761
+ * (depends on the scroll direction) should trigger the rendering of rows outside of the grid's viewport.
4762
+ *
4763
+ * You can set the `viewportRowRenderingThreshold` option to one of the following:
4764
+ *
4765
+ * | Setting | Description |
4766
+ * | ------------------ | ------------------------------------------------------- |
4767
+ * | `auto` | Triggers rendering at half the offset defined by [`viewportRowRenderingOffset`](#viewportRowRenderingOffset) option |
4768
+ * | A number | Sets the offset manually (`0` is a default) |
4769
+ *
4770
+ * The `viewportRowRenderingThreshold` setting is ignored when [`renderAllRows`](#renderAllRows) is set to `true`.
4771
+ *
4772
+ * Read more:
4773
+ * - [Performance: Define the number of pre-rendered rows and columns](@/guides/optimization/performance/performance.md#define-the-number-of-pre-rendered-rows-and-columns)
4774
+ * - [Row virtualization](@/guides/rows/row-virtualization/row-virtualization.md)
4775
+ *
4776
+ * @memberof Options#
4777
+ * @since 1.14.7
4778
+ * @type {number|'auto'}
4779
+ * @default 0
4780
+ * @category Core
4781
+ *
4782
+ * @example
4783
+ * ```js
4784
+ * // render 12 rows outside of the grid's viewport
4785
+ * viewportRowRenderingOffset: 12,
4786
+ * // the rows outside of the viewport will be rendered when the user scrolls to the 8th row from/to
4787
+ * viewportRowRenderingThreshold: 8,
4788
+ * ```
4789
+ */
4790
+ viewportRowRenderingThreshold: 0,
4725
4791
  /**
4726
4792
  * The `visibleRows` option sets the height of the [`autocomplete`](@/guides/cell-types/autocomplete-cell-type/autocomplete-cell-type.md)
4727
4793
  * and [`dropdown`](@/guides/cell-types/dropdown-cell-type/dropdown-cell-type.md) lists.
@@ -4678,7 +4678,7 @@ export default () => {
4678
4678
  * - [Performance: Define the number of pre-rendered rows and columns](@/guides/optimization/performance/performance.md#define-the-number-of-pre-rendered-rows-and-columns)
4679
4679
  *
4680
4680
  * @memberof Options#
4681
- * @type {number|string}
4681
+ * @type {number|'auto'}
4682
4682
  * @default 'auto'
4683
4683
  * @category Core
4684
4684
  *
@@ -4708,7 +4708,7 @@ export default () => {
4708
4708
  * - [Column virtualization](@/guides/columns/column-virtualization/column-virtualization.md)
4709
4709
  *
4710
4710
  * @memberof Options#
4711
- * @type {number|string}
4711
+ * @type {number|'auto'}
4712
4712
  * @default 'auto'
4713
4713
  * @category Core
4714
4714
  *
@@ -4719,6 +4719,72 @@ export default () => {
4719
4719
  * ```
4720
4720
  */
4721
4721
  viewportRowRenderingOffset: 'auto',
4722
+ /**
4723
+ * @description
4724
+ * The `viewportColumnRenderingThreshold` option configures what column number starting from the left or right
4725
+ * (depends on the scroll direction) should trigger the rendering of columns outside of the grid's viewport.
4726
+ *
4727
+ * You can set the `viewportColumnRenderingThreshold` option to one of the following:
4728
+ *
4729
+ * | Setting | Description |
4730
+ * | ------------------ | ------------------------------------------------------- |
4731
+ * | `auto` | Triggers rendering at half the offset defined by [`viewportColumnRenderingOffset`](#viewportColumnRenderingOffset) option |
4732
+ * | A number | Sets the offset manually (`0` is a default) |
4733
+ *
4734
+ * The `viewportColumnRenderingThreshold` setting is ignored when [`renderAllColumn`](#renderAllColumn) is set to `true`.
4735
+ *
4736
+ * Read more:
4737
+ * - [Performance: Define the number of pre-rendered rows and columns](@/guides/optimization/performance/performance.md#define-the-number-of-pre-rendered-rows-and-columns)
4738
+ * - [Column virtualization](@/guides/columns/column-virtualization/column-virtualization.md)
4739
+ *
4740
+ * @memberof Options#
4741
+ * @since 1.14.7
4742
+ * @type {number|'auto'}
4743
+ * @default 0
4744
+ * @category Core
4745
+ *
4746
+ * @example
4747
+ * ```js
4748
+ * // render 12 columns outside of the grid's viewport
4749
+ * viewportColumnRenderingOffset: 12,
4750
+ * // the columns outside of the viewport will be rendered when the user scrolls to the 8th column from/to
4751
+ * viewportColumnRenderingThreshold: 8,
4752
+ * ```
4753
+ */
4754
+ viewportColumnRenderingThreshold: 0,
4755
+ /**
4756
+ * @description
4757
+ * The `viewportRowRenderingThreshold` option configures what row number starting from the top or bottom
4758
+ * (depends on the scroll direction) should trigger the rendering of rows outside of the grid's viewport.
4759
+ *
4760
+ * You can set the `viewportRowRenderingThreshold` option to one of the following:
4761
+ *
4762
+ * | Setting | Description |
4763
+ * | ------------------ | ------------------------------------------------------- |
4764
+ * | `auto` | Triggers rendering at half the offset defined by [`viewportRowRenderingOffset`](#viewportRowRenderingOffset) option |
4765
+ * | A number | Sets the offset manually (`0` is a default) |
4766
+ *
4767
+ * The `viewportRowRenderingThreshold` setting is ignored when [`renderAllRows`](#renderAllRows) is set to `true`.
4768
+ *
4769
+ * Read more:
4770
+ * - [Performance: Define the number of pre-rendered rows and columns](@/guides/optimization/performance/performance.md#define-the-number-of-pre-rendered-rows-and-columns)
4771
+ * - [Row virtualization](@/guides/rows/row-virtualization/row-virtualization.md)
4772
+ *
4773
+ * @memberof Options#
4774
+ * @since 1.14.7
4775
+ * @type {number|'auto'}
4776
+ * @default 0
4777
+ * @category Core
4778
+ *
4779
+ * @example
4780
+ * ```js
4781
+ * // render 12 rows outside of the grid's viewport
4782
+ * viewportRowRenderingOffset: 12,
4783
+ * // the rows outside of the viewport will be rendered when the user scrolls to the 8th row from/to
4784
+ * viewportRowRenderingThreshold: 8,
4785
+ * ```
4786
+ */
4787
+ viewportRowRenderingThreshold: 0,
4722
4788
  /**
4723
4789
  * The `visibleRows` option sets the height of the [`autocomplete`](@/guides/cell-types/autocomplete-cell-type/autocomplete-cell-type.md)
4724
4790
  * and [`dropdown`](@/guides/cell-types/dropdown-cell-type/dropdown-cell-type.md) lists.