UNPKG

131 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4require("core-js/modules/es.error.cause.js");
5require("core-js/modules/es.array.push.js");
6require("core-js/modules/es.array.unscopables.flat-map.js");
7var _array = require("./helpers/array");
8var _object = require("./helpers/object");
9var _string = require("./helpers/string");
10var _console = require("./helpers/console");
11var _templateLiteralTag = require("./helpers/templateLiteralTag");
12var _function = require("./helpers/function");
13function _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; }
14function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
15function _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); }
16/* eslint-disable jsdoc/require-description-complete-sentence */
17/**
18 * @description
19 *
20 * ::: only-for javascript
21 * Handsontable events are the common interface that function in 2 ways: as __callbacks__ and as __hooks__.
22 * :::
23 *
24 * ::: only-for react
25 * This page lists all the **Handsontable hooks** – callbacks that let you react before or after an action occurs.
26 *
27 * Read more on the [Events and hooks](@/guides/getting-started/events-and-hooks/events-and-hooks.md) page.
28 * :::
29 *
30 * @example
31 *
32 * ::: only-for javascript
33 * ```js
34 * // using events as callbacks
35 * ...
36 * const hot1 = new Handsontable(document.getElementById('example1'), {
37 * afterChange: function(changes, source) {
38 * $.ajax({
39 * url: "save.php',
40 * data: change
41 * });
42 * }
43 * });
44 * ...
45 * ```
46 * :::
47 *
48 * ::: only-for react
49 * ```jsx
50 * <HotTable
51 * afterChange={(changes, source) => {
52 * fetch('save.php', {
53 * method: 'POST',
54 * headers: {
55 * 'Accept': 'application/json',
56 * 'Content-Type': 'application/json'
57 * },
58 * body: JSON.stringify(changes)
59 * });
60 * }}
61 * />
62 * :::
63 *
64 * ::: only-for javascript
65 * ```js
66 * // using events as plugin hooks
67 * ...
68 * const hot1 = new Handsontable(document.getElementById('example1'), {
69 * myPlugin: true
70 * });
71 *
72 * const hot2 = new Handsontable(document.getElementById('example2'), {
73 * myPlugin: false
74 * });
75 *
76 * // global hook
77 * Handsontable.hooks.add('afterChange', function() {
78 * // Fired twice - for hot1 and hot2
79 * if (this.getSettings().myPlugin) {
80 * // function body - will only run for hot1
81 * }
82 * });
83 *
84 * // local hook (has same effect as a callback)
85 * hot2.addHook('afterChange', function() {
86 * // function body - will only run in #example2
87 * });
88 * ```
89 * :::
90 *
91 * ::: only-for react
92 * ```jsx
93 * const hotRef1 = useRef(null);
94 * const hotRef2 = useRef(null);
95 *
96 * // Using events as plugin hooks:
97 * ...
98 *
99 * <HotTable
100 * ref={hotRef1}
101 * myPlugin={true}
102 * });
103 *
104 * <HotTable
105 * ref={hotRef2}
106 * myPlugin={false}
107 * });
108 *
109 * ...
110 *
111 * const hot2 = hotRef2.current.hotInstance;
112 * // local hook (has same effect as a callback)
113 * hot2.addHook('afterChange', function() {
114 * // function body - will only run in #example2
115 * });
116 *
117 * // global hook
118 * Handsontable.hooks.add('afterChange', function() {
119 * // Fired twice - for hot1 and hot2
120 * if (this.getSettings().myPlugin) {
121 * // function body - will only run for first instance
122 * }
123 * });
124 * :::
125 * ...
126 */
127
128// @TODO: Move plugin description hooks to plugin?
129const REGISTERED_HOOKS = [/* eslint-disable jsdoc/require-description-complete-sentence */
130/**
131 * Fired after resetting a cell's meta. This happens when the {@link Core#updateSettings} method is called.
132 *
133 * @event Hooks#afterCellMetaReset
134 */
135'afterCellMetaReset',
136/**
137 * Fired after one or more cells has been changed. The changes are triggered in any situation when the
138 * value is entered using an editor or changed using API (e.q [`setDataAtCell`](@/api/core.md#setdataatcell) method).
139 *
140 * __Note:__ For performance reasons, the `changes` array is null for `"loadData"` source.
141 *
142 * @event Hooks#afterChange
143 * @param {Array[]} changes 2D array containing information about each of the edited cells `[[row, prop, oldVal, newVal], ...]`. `row` is a visual row index.
144 * @param {string} [source] String that identifies source of hook call ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
145 * @example
146 * ::: only-for javascript
147 * ```js
148 * new Handsontable(element, {
149 * afterChange: (changes) => {
150 * changes?.forEach(([row, prop, oldValue, newValue]) => {
151 * // Some logic...
152 * });
153 * }
154 * })
155 * ```
156 * :::
157 *
158 * ::: only-for react
159 * ```jsx
160 * <HotTable
161 * afterChange={(changes, source) => {
162 * changes?.forEach(([row, prop, oldValue, newValue]) => {
163 * // Some logic...
164 * });
165 * }}
166 * />
167 * ```
168 * :::
169 */
170'afterChange',
171/**
172 * Fired each time user opens {@link ContextMenu} and after setting up the Context Menu's default options. These options are a collection
173 * which user can select by setting an array of keys or an array of objects in {@link Options#contextMenu} option.
174 *
175 * @event Hooks#afterContextMenuDefaultOptions
176 * @param {Array} predefinedItems An array of objects containing information about the pre-defined Context Menu items.
177 */
178'afterContextMenuDefaultOptions',
179/**
180 * Fired each time user opens {@link ContextMenu} plugin before setting up the Context Menu's items but after filtering these options by
181 * user ([`contextMenu`](@/api/options.md#contextmenu) option). This hook can by helpful to determine if user use specified menu item or to set up
182 * one of the menu item to by always visible.
183 *
184 * @event Hooks#beforeContextMenuSetItems
185 * @param {object[]} menuItems An array of objects containing information about to generated Context Menu items.
186 */
187'beforeContextMenuSetItems',
188/**
189 * Fired by {@link DropdownMenu} plugin after setting up the Dropdown Menu's default options. These options are a
190 * collection which user can select by setting an array of keys or an array of objects in {@link Options#dropdownMenu}
191 * option.
192 *
193 * @event Hooks#afterDropdownMenuDefaultOptions
194 * @param {object[]} predefinedItems An array of objects containing information about the pre-defined Context Menu items.
195 */
196'afterDropdownMenuDefaultOptions',
197/**
198 * Fired by {@link DropdownMenu} plugin before setting up the Dropdown Menu's items but after filtering these options
199 * by user ([`dropdownMenu`](@/api/options.md#dropdownmenu) option). This hook can by helpful to determine if user use specified menu item or to set
200 * up one of the menu item to by always visible.
201 *
202 * @event Hooks#beforeDropdownMenuSetItems
203 * @param {object[]} menuItems An array of objects containing information about to generated Dropdown Menu items.
204 */
205'beforeDropdownMenuSetItems',
206/**
207 * Fired by {@link ContextMenu} plugin after hiding the Context Menu. This hook is fired when {@link Options#contextMenu}
208 * option is enabled.
209 *
210 * @event Hooks#afterContextMenuHide
211 * @param {object} context The Context Menu plugin instance.
212 */
213'afterContextMenuHide',
214/**
215 * Fired by {@link ContextMenu} plugin before opening the Context Menu. This hook is fired when {@link Options#contextMenu}
216 * option is enabled.
217 *
218 * @event Hooks#beforeContextMenuShow
219 * @param {object} context The Context Menu instance.
220 */
221'beforeContextMenuShow',
222/**
223 * Fired by {@link ContextMenu} plugin after opening the Context Menu. This hook is fired when {@link Options#contextMenu}
224 * option is enabled.
225 *
226 * @event Hooks#afterContextMenuShow
227 * @param {object} context The Context Menu plugin instance.
228 */
229'afterContextMenuShow',
230/**
231 * Fired by {@link CopyPaste} plugin after reaching the copy limit while copying data. This hook is fired when
232 * {@link Options#copyPaste} option is enabled.
233 *
234 * @event Hooks#afterCopyLimit
235 * @param {number} selectedRows Count of selected copyable rows.
236 * @param {number} selectedColumns Count of selected copyable columns.
237 * @param {number} copyRowsLimit Current copy rows limit.
238 * @param {number} copyColumnsLimit Current copy columns limit.
239 */
240'afterCopyLimit',
241/**
242 * Fired before created a new column.
243 *
244 * @event Hooks#beforeCreateCol
245 * @param {number} index Represents the visual index of first newly created column in the data source array.
246 * @param {number} amount Number of newly created columns in the data source array.
247 * @param {string} [source] String that identifies source of hook call
248 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
249 * @returns {*} If `false` then creating columns is cancelled.
250 * @example
251 * ::: only-for javascript
252 * ```js
253 * // Return `false` to cancel column inserting.
254 * new Handsontable(element, {
255 * beforeCreateCol: function(data, coords) {
256 * return false;
257 * }
258 * });
259 * ```
260 * :::
261 *
262 * ::: only-for react
263 * ```jsx
264 * // Return `false` to cancel column inserting.
265 * <HotTable
266 * beforeCreateCol={(data, coords) => {
267 * return false;
268 * }}
269 * />
270 * ```
271 * :::
272 */
273'beforeCreateCol',
274/**
275 * Fired after the order of columns has changed.
276 * This hook is fired by changing column indexes of any type supported by the {@link IndexMapper}.
277 *
278 * @event Hooks#afterColumnSequenceChange
279 * @param {'init'|'remove'|'insert'|'move'|'update'} [source] A string that indicates what caused the change to the order of columns.
280 */
281'afterColumnSequenceChange',
282/**
283 * Fired after created a new column.
284 *
285 * @event Hooks#afterCreateCol
286 * @param {number} index Represents the visual index of first newly created column in the data source.
287 * @param {number} amount Number of newly created columns in the data source.
288 * @param {string} [source] String that identifies source of hook call
289 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
290 */
291'afterCreateCol',
292/**
293 * Fired before created a new row.
294 *
295 * @event Hooks#beforeCreateRow
296 * @param {number} index Represents the visual index of first newly created row in the data source array.
297 * @param {number} amount Number of newly created rows in the data source array.
298 * @param {string} [source] String that identifies source of hook call
299 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
300 * @returns {*|boolean} If false is returned the action is canceled.
301 */
302'beforeCreateRow',
303/**
304 * Fired after created a new row.
305 *
306 * @event Hooks#afterCreateRow
307 * @param {number} index Represents the visual index of first newly created row in the data source array.
308 * @param {number} amount Number of newly created rows in the data source array.
309 * @param {string} [source] String that identifies source of hook call
310 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
311 */
312'afterCreateRow',
313/**
314 * Fired after all selected cells are deselected.
315 *
316 * @event Hooks#afterDeselect
317 */
318'afterDeselect',
319/**
320 * Fired after destroying the Handsontable instance.
321 *
322 * @event Hooks#afterDestroy
323 */
324'afterDestroy',
325/**
326 * Hook fired after `keydown` event is handled.
327 *
328 * @event Hooks#afterDocumentKeyDown
329 * @param {Event} event A native `keydown` event object.
330 */
331'afterDocumentKeyDown',
332/**
333 * Fired inside the Walkontable's selection `draw` method. Can be used to add additional class names to cells, depending on the current selection.
334 *
335 * @event Hooks#afterDrawSelection
336 * @param {number} currentRow Row index of the currently processed cell.
337 * @param {number} currentColumn Column index of the currently cell.
338 * @param {number[]} cornersOfSelection Array of the current selection in a form of `[startRow, startColumn, endRow, endColumn]`.
339 * @param {number|undefined} layerLevel Number indicating which layer of selection is currently processed.
340 * @since 0.38.1
341 * @returns {string|undefined} Can return a `String`, which will act as an additional `className` to be added to the currently processed cell.
342 */
343'afterDrawSelection',
344/**
345 * Fired inside the Walkontable's `refreshSelections` method. Can be used to remove additional class names from all cells in the table.
346 *
347 * @event Hooks#beforeRemoveCellClassNames
348 * @since 0.38.1
349 * @returns {string[]|undefined} Can return an `Array` of `String`s. Each of these strings will act like class names to be removed from all the cells in the table.
350 */
351'beforeRemoveCellClassNames',
352/**
353 * Fired after getting the cell settings.
354 *
355 * @event Hooks#afterGetCellMeta
356 * @param {number} row Visual row index.
357 * @param {number} column Visual column index.
358 * @param {object} cellProperties Object containing the cell properties.
359 */
360'afterGetCellMeta',
361/**
362 * Fired after retrieving information about a column header and appending it to the table header.
363 *
364 * @event Hooks#afterGetColHeader
365 * @param {number} column Visual column index.
366 * @param {HTMLTableCellElement} TH Header's TH element.
367 * @param {number} [headerLevel=0] (Since 12.2.0) Header level index. Accepts positive (0 to n)
368 * and negative (-1 to -n) values. For positive values, 0 points to the
369 * topmost header. For negative values, -1 points to the bottom-most
370 * header (the header closest to the cells).
371 */
372'afterGetColHeader',
373/**
374 * Fired after retrieving information about a row header and appending it to the table header.
375 *
376 * @event Hooks#afterGetRowHeader
377 * @param {number} row Visual row index.
378 * @param {HTMLTableCellElement} TH Header's TH element.
379 */
380'afterGetRowHeader',
381/**
382 * Fired after the Handsontable instance is initiated.
383 *
384 * @event Hooks#afterInit
385 */
386'afterInit',
387/**
388 * Fired after Handsontable's [`data`](@/api/options.md#data)
389 * gets modified by the [`loadData()`](@/api/core.md#loaddata) method
390 * or the [`updateSettings()`](@/api/core.md#updatesettings) method.
391 *
392 * Read more:
393 * - [Binding to data](@/guides/getting-started/binding-to-data/binding-to-data.md)
394 * - [Saving data](@/guides/getting-started/saving-data/saving-data.md)
395 *
396 * @event Hooks#afterLoadData
397 * @param {Array} sourceData An [array of arrays](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-arrays), or an [array of objects](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-objects), that contains Handsontable's data
398 * @param {boolean} initialLoad A flag that indicates whether the data was loaded at Handsontable's initialization (`true`) or later (`false`)
399 * @param {string} source The source of the call
400 */
401'afterLoadData',
402/**
403 * Fired after the [`updateData()`](@/api/core.md#updatedata) method
404 * modifies Handsontable's [`data`](@/api/options.md#data).
405 *
406 * Read more:
407 * - [Binding to data](@/guides/getting-started/binding-to-data/binding-to-data.md)
408 * - [Saving data](@/guides/getting-started/saving-data/saving-data.md)
409 *
410 * @event Hooks#afterUpdateData
411 * @since 11.1.0
412 * @param {Array} sourceData An [array of arrays](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-arrays), or an [array of objects](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-objects), that contains Handsontable's data
413 * @param {boolean} initialLoad A flag that indicates whether the data was loaded at Handsontable's initialization (`true`) or later (`false`)
414 * @param {string} source The source of the call
415 */
416'afterUpdateData',
417/**
418 * Fired after a scroll event, which is identified as a momentum scroll (e.g. on an iPad).
419 *
420 * @event Hooks#afterMomentumScroll
421 */
422'afterMomentumScroll',
423/**
424 * Fired after a `mousedown` event is triggered on the cell corner (the drag handle).
425 *
426 * @event Hooks#afterOnCellCornerMouseDown
427 * @param {Event} event `mousedown` event object.
428 */
429'afterOnCellCornerMouseDown',
430/**
431 * Fired after a `dblclick` event is triggered on the cell corner (the drag handle).
432 *
433 * @event Hooks#afterOnCellCornerDblClick
434 * @param {Event} event `dblclick` event object.
435 */
436'afterOnCellCornerDblClick',
437/**
438 * Fired after clicking on a cell or row/column header. In case the row/column header was clicked, the coordinate
439 * indexes are negative.
440 *
441 * For example clicking on the row header of cell (0, 0) results with `afterOnCellMouseDown` called
442 * with coordinates `{row: 0, col: -1}`.
443 *
444 * @event Hooks#afterOnCellMouseDown
445 * @param {Event} event `mousedown` event object.
446 * @param {CellCoords} coords Coordinates object containing the visual row and visual column indexes of the clicked cell.
447 * @param {HTMLTableCellElement} TD Cell's TD (or TH) element.
448 */
449'afterOnCellMouseDown',
450/**
451 * Fired after clicking on a cell or row/column header. In case the row/column header was clicked, the coordinate
452 * indexes are negative.
453 *
454 * For example clicking on the row header of cell (0, 0) results with `afterOnCellMouseUp` called
455 * with coordinates `{row: 0, col: -1}`.
456 *
457 * @event Hooks#afterOnCellMouseUp
458 * @param {Event} event `mouseup` event object.
459 * @param {CellCoords} coords Coordinates object containing the visual row and visual column indexes of the clicked cell.
460 * @param {HTMLTableCellElement} TD Cell's TD (or TH) element.
461 */
462'afterOnCellMouseUp',
463/**
464 * Fired after clicking right mouse button on a cell or row/column header.
465 *
466 * For example clicking on the row header of cell (0, 0) results with `afterOnCellContextMenu` called
467 * with coordinates `{row: 0, col: -1}`.
468 *
469 * @event Hooks#afterOnCellContextMenu
470 * @since 4.1.0
471 * @param {Event} event `contextmenu` event object.
472 * @param {CellCoords} coords Coordinates object containing the visual row and visual column indexes of the clicked cell.
473 * @param {HTMLTableCellElement} TD Cell's TD (or TH) element.
474 */
475'afterOnCellContextMenu',
476/**
477 * Fired after hovering a cell or row/column header with the mouse cursor. In case the row/column header was
478 * hovered, the index is negative.
479 *
480 * For example, hovering over the row header of cell (0, 0) results with `afterOnCellMouseOver` called
481 * with coords `{row: 0, col: -1}`.
482 *
483 * @event Hooks#afterOnCellMouseOver
484 * @param {Event} event `mouseover` event object.
485 * @param {CellCoords} coords Hovered cell's visual coordinate object.
486 * @param {HTMLTableCellElement} TD Cell's TD (or TH) element.
487 */
488'afterOnCellMouseOver',
489/**
490 * Fired after leaving a cell or row/column header with the mouse cursor.
491 *
492 * @event Hooks#afterOnCellMouseOut
493 * @param {Event} event `mouseout` event object.
494 * @param {CellCoords} coords Leaved cell's visual coordinate object.
495 * @param {HTMLTableCellElement} TD Cell's TD (or TH) element.
496 */
497'afterOnCellMouseOut',
498/**
499 * Fired after one or more columns are removed.
500 *
501 * @event Hooks#afterRemoveCol
502 * @param {number} index Visual index of starter column.
503 * @param {number} amount An amount of removed columns.
504 * @param {number[]} physicalColumns An array of physical columns removed from the data source.
505 * @param {string} [source] String that identifies source of hook call
506 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
507 */
508'afterRemoveCol',
509/**
510 * Fired after one or more rows are removed.
511 *
512 * @event Hooks#afterRemoveRow
513 * @param {number} index Visual index of starter row.
514 * @param {number} amount An amount of removed rows.
515 * @param {number[]} physicalRows An array of physical rows removed from the data source.
516 * @param {string} [source] String that identifies source of hook call
517 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
518 */
519'afterRemoveRow',
520/**
521 * Fired before starting rendering the cell.
522 *
523 * @event Hooks#beforeRenderer
524 * @param {HTMLTableCellElement} TD Currently rendered cell's TD element.
525 * @param {number} row Visual row index.
526 * @param {number} column Visual column index.
527 * @param {string|number} prop Column property name or a column index, if datasource is an array of arrays.
528 * @param {*} value Value of the rendered cell.
529 * @param {object} cellProperties Object containing the cell's properties.
530 */
531'beforeRenderer',
532/**
533 * Fired after finishing rendering the cell (after the renderer finishes).
534 *
535 * @event Hooks#afterRenderer
536 * @param {HTMLTableCellElement} TD Currently rendered cell's TD element.
537 * @param {number} row Visual row index.
538 * @param {number} column Visual column index.
539 * @param {string|number} prop Column property name or a column index, if datasource is an array of arrays.
540 * @param {*} value Value of the rendered cell.
541 * @param {object} cellProperties Object containing the cell's properties.
542 */
543'afterRenderer',
544/**
545 * Fired after the order of rows has changed.
546 * This hook is fired by changing row indexes of any type supported by the {@link IndexMapper}.
547 *
548 * @event Hooks#afterRowSequenceChange
549 * @param {'init'|'remove'|'insert'|'move'|'update'} [source] A string that indicates what caused the change to the order of rows.
550 */
551'afterRowSequenceChange',
552/**
553 * Fired before the vertical viewport scroll. Triggered by the [`scrollViewportTo()`](@/api/core.md#scrollviewportto)
554 * method or table internals.
555 *
556 * @since 14.0.0
557 * @event Hooks#beforeViewportScrollVertically
558 * @param {number} visualRow Visual row index.
559 * @returns {number | boolean} Returns modified row index (or the same as passed in the method argument) to which
560 * the viewport will be scrolled. If the returned value is `false`, the scrolling will be canceled.
561 */
562'beforeViewportScrollVertically',
563/**
564 * Fired before the horizontal viewport scroll. Triggered by the [`scrollViewportTo()`](@/api/core.md#scrollviewportto)
565 * method or table internals.
566 *
567 * @since 14.0.0
568 * @event Hooks#beforeViewportScrollHorizontally
569 * @param {number} visualColumn Visual column index.
570 * @returns {number | boolean} Returns modified column index (or the same as passed in the method argument) to which
571 * the viewport will be scrolled. If the returned value is `false`, the scrolling will be canceled.
572 */
573'beforeViewportScrollHorizontally',
574/**
575 * Fired before the vertical or horizontal viewport scroll. Triggered by the [`scrollViewportTo()`](@/api/core.md#scrollviewportto)
576 * method or table internals.
577 *
578 * @since 14.0.0
579 * @event Hooks#beforeViewportScroll
580 */
581'beforeViewportScroll',
582/**
583 * Fired after the horizontal scroll event.
584 *
585 * @event Hooks#afterScrollHorizontally
586 */
587'afterScrollHorizontally',
588/**
589 * Fired after the vertical scroll event.
590 *
591 * @event Hooks#afterScrollVertically
592 */
593'afterScrollVertically',
594/**
595 * Fired after the vertical or horizontal scroll event.
596 *
597 * @since 14.0.0
598 * @event Hooks#afterScroll
599 */
600'afterScroll',
601/**
602 * Fired after one or more cells are selected (e.g. during mouse move).
603 *
604 * @event Hooks#afterSelection
605 * @param {number} row Selection start visual row index.
606 * @param {number} column Selection start visual column index.
607 * @param {number} row2 Selection end visual row index.
608 * @param {number} column2 Selection end visual column index.
609 * @param {object} preventScrolling A reference to the observable object with the `value` property.
610 * Property `preventScrolling.value` expects a boolean value that
611 * Handsontable uses to control scroll behavior after selection.
612 * @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
613 * @example
614 * ::: only-for javascript
615 * ```js
616 * new Handsontable(element, {
617 * afterSelection: (row, column, row2, column2, preventScrolling, selectionLayerLevel) => {
618 * // If set to `false` (default): when cell selection is outside the viewport,
619 * // Handsontable scrolls the viewport to cell selection's end corner.
620 * // If set to `true`: when cell selection is outside the viewport,
621 * // Handsontable doesn't scroll to cell selection's end corner.
622 * preventScrolling.value = true;
623 * }
624 * })
625 * ```
626 * :::
627 *
628 * ::: only-for react
629 * ```jsx
630 * <HotTable
631 * afterSelection={(row, column, row2, column2, preventScrolling, selectionLayerLevel) => {
632 * // If set to `false` (default): when cell selection is outside the viewport,
633 * // Handsontable scrolls the viewport to cell selection's end corner.
634 * // If set to `true`: when cell selection is outside the viewport,
635 * // Handsontable doesn't scroll to cell selection's end corner.
636 * preventScrolling.value = true;
637 * }}
638 * />
639 * ```
640 * :::
641 */
642'afterSelection',
643/**
644 * Fired after one or more cells are selected.
645 *
646 * The `prop` and `prop2` arguments represent the source object property name instead of the column number.
647 *
648 * @event Hooks#afterSelectionByProp
649 * @param {number} row Selection start visual row index.
650 * @param {string} prop Selection start data source object property name.
651 * @param {number} row2 Selection end visual row index.
652 * @param {string} prop2 Selection end data source object property name.
653 * @param {object} preventScrolling A reference to the observable object with the `value` property.
654 * Property `preventScrolling.value` expects a boolean value that
655 * Handsontable uses to control scroll behavior after selection.
656 * @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
657 * @example
658 * ```js
659 * ::: only-for javascript
660 * new Handsontable(element, {
661 * afterSelectionByProp: (row, column, row2, column2, preventScrolling, selectionLayerLevel) => {
662 * // setting if prevent scrolling after selection
663 * preventScrolling.value = true;
664 * }
665 * })
666 * ```
667 * :::
668 *
669 * ::: only-for react
670 * ```jsx
671 * <HotTable
672 * afterSelectionByProp={(row, column, row2, column2, preventScrolling, selectionLayerLevel) => {
673 * // setting if prevent scrolling after selection
674 * preventScrolling.value = true;
675 * }}
676 * />
677 * ```
678 * :::
679 */
680'afterSelectionByProp',
681/**
682 * Fired after one or more cells are selected (e.g. on mouse up).
683 *
684 * @event Hooks#afterSelectionEnd
685 * @param {number} row Selection start visual row index.
686 * @param {number} column Selection start visual column index.
687 * @param {number} row2 Selection end visual row index.
688 * @param {number} column2 Selection end visual column index.
689 * @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
690 */
691'afterSelectionEnd',
692/**
693 * Fired after one or more cells are selected (e.g. on mouse up).
694 *
695 * The `prop` and `prop2` arguments represent the source object property name instead of the column number.
696 *
697 * @event Hooks#afterSelectionEndByProp
698 * @param {number} row Selection start visual row index.
699 * @param {string} prop Selection start data source object property index.
700 * @param {number} row2 Selection end visual row index.
701 * @param {string} prop2 Selection end data source object property index.
702 * @param {number} selectionLayerLevel The number which indicates what selection layer is currently modified.
703 */
704'afterSelectionEndByProp',
705/**
706 * Fired after the focus position within a selected range is changed.
707 *
708 * @since 14.3.0
709 * @event Hooks#afterSelectionFocusSet
710 * @param {number} row The focus visual row index position.
711 * @param {number} column The focus visual column index position.
712 * @param {object} preventScrolling A reference to the observable object with the `value` property.
713 * Property `preventScrolling.value` expects a boolean value that
714 * Handsontable uses to control scroll behavior after selection.
715 * @example
716 * ```js
717 * ::: only-for javascript
718 * new Handsontable(element, {
719 * afterSelectionFocusSet: (row, column, preventScrolling) => {
720 * // If set to `false` (default): when focused cell selection is outside the viewport,
721 * // Handsontable scrolls the viewport to that cell.
722 * // If set to `true`: when focused cell selection is outside the viewport,
723 * // Handsontable doesn't scroll the viewport.
724 * preventScrolling.value = true;
725 * }
726 * })
727 * ```
728 * :::
729 *
730 * ::: only-for react
731 * ```jsx
732 * <HotTable
733 * afterSelectionFocusSet={(row, column, preventScrolling) => {
734 * // If set to `false` (default): when focused cell selection is outside the viewport,
735 * // Handsontable scrolls the viewport to that cell.
736 * // If set to `true`: when focused cell selection is outside the viewport,
737 * // Handsontable doesn't scroll the viewport.
738 * preventScrolling.value = true;
739 * }}
740 * />
741 * ```
742 * :::
743 */
744'afterSelectionFocusSet',
745/**
746 * Fired before one or more columns are selected (e.g. During mouse header click or {@link Core#selectColumns} API call).
747 *
748 * @since 14.0.0
749 * @event Hooks#beforeSelectColumns
750 * @param {CellCoords} from Selection start coords object.
751 * @param {CellCoords} to Selection end coords object.
752 * @param {CellCoords} highlight Selection cell focus coords object.
753 * @example
754 * ::: only-for javascript
755 * ```js
756 * new Handsontable(element, {
757 * beforeSelectColumns: (from, to, highlight) => {
758 * // Extend the column selection by one column left and one column right.
759 * from.col = Math.max(from.col - 1, 0);
760 * to.col = Math.min(to.col + 1, this.countCols() - 1);
761 * }
762 * })
763 * ```
764 * :::
765 *
766 * ::: only-for react
767 * ```jsx
768 * <HotTable
769 * beforeSelectColumns={(from, to, highlight) => {
770 * // Extend the column selection by one column left and one column right.
771 * from.col = Math.max(from.col - 1, 0);
772 * to.col = Math.min(to.col + 1, this.countCols() - 1);
773 * }}
774 * />
775 * ```
776 * :::
777 */
778'beforeSelectColumns',
779/**
780 * Fired after one or more columns are selected (e.g. during mouse header click or {@link Core#selectColumns} API call).
781 *
782 * @since 14.0.0
783 * @event Hooks#afterSelectColumns
784 * @param {CellCoords} from Selection start coords object.
785 * @param {CellCoords} to Selection end coords object.
786 * @param {CellCoords} highlight Selection cell focus coords object.
787 */
788'afterSelectColumns',
789/**
790 * Fired before one or more rows are selected (e.g. during mouse header click or {@link Core#selectRows} API call).
791 *
792 * @since 14.0.0
793 * @event Hooks#beforeSelectRows
794 * @param {CellCoords} from Selection start coords object.
795 * @param {CellCoords} to Selection end coords object.
796 * @param {CellCoords} highlight Selection cell focus coords object.
797 * @example
798 * ::: only-for javascript
799 * ```js
800 * new Handsontable(element, {
801 * beforeSelectRows: (from, to, highlight) => {
802 * // Extend the row selection by one row up and one row bottom more.
803 * from.row = Math.max(from.row - 1, 0);
804 * to.row = Math.min(to.row + 1, this.countRows() - 1);
805 * }
806 * })
807 * ```
808 * :::
809 *
810 * ::: only-for react
811 * ```jsx
812 * <HotTable
813 * beforeSelectRows={(from, to, highlight) => {
814 * // Extend the row selection by one row up and one row bottom more.
815 * from.row = Math.max(from.row - 1, 0);
816 * to.row = Math.min(to.row + 1, this.countRows() - 1);
817 * }}
818 * />
819 * ```
820 * :::
821 */
822'beforeSelectRows',
823/**
824 * Fired after one or more rows are selected (e.g. during mouse header click or {@link Core#selectRows} API call).
825 *
826 * @since 14.0.0
827 * @event Hooks#afterSelectRows
828 * @param {CellCoords} from Selection start coords object.
829 * @param {CellCoords} to Selection end coords object.
830 * @param {CellCoords} highlight Selection cell focus coords object.
831 */
832'afterSelectRows',
833/**
834 * Fired after cell meta is changed.
835 *
836 * @event Hooks#afterSetCellMeta
837 * @param {number} row Visual row index.
838 * @param {number} column Visual column index.
839 * @param {string} key The updated meta key.
840 * @param {*} value The updated meta value.
841 */
842'afterSetCellMeta',
843/**
844 * Fired after cell meta is removed.
845 *
846 * @event Hooks#afterRemoveCellMeta
847 * @param {number} row Visual row index.
848 * @param {number} column Visual column index.
849 * @param {string} key The removed meta key.
850 * @param {*} value Value which was under removed key of cell meta.
851 */
852'afterRemoveCellMeta',
853/**
854 * Fired after cell data was changed.
855 *
856 * @event Hooks#afterSetDataAtCell
857 * @param {Array} changes An array of changes in format `[[row, column, oldValue, value], ...]`.
858 * @param {string} [source] String that identifies source of hook call
859 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
860 */
861'afterSetDataAtCell',
862/**
863 * Fired after cell data was changed.
864 * Called only when [`setDataAtRowProp`](@/api/core.md#setdataatrowprop) was executed.
865 *
866 * @event Hooks#afterSetDataAtRowProp
867 * @param {Array} changes An array of changes in format `[[row, prop, oldValue, value], ...]`.
868 * @param {string} [source] String that identifies source of hook call
869 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
870 */
871'afterSetDataAtRowProp',
872/**
873 * Fired after cell source data was changed.
874 *
875 * @event Hooks#afterSetSourceDataAtCell
876 * @since 8.0.0
877 * @param {Array} changes An array of changes in format `[[row, column, oldValue, value], ...]`.
878 * @param {string} [source] String that identifies source of hook call.
879 */
880'afterSetSourceDataAtCell',
881/**
882 * Fired after calling the [`updateSettings`](@/api/core.md#updatesettings) method.
883 *
884 * @event Hooks#afterUpdateSettings
885 * @param {object} newSettings New settings object.
886 */
887'afterUpdateSettings',
888/**
889 * @description
890 * A plugin hook executed after validator function, only if validator function is defined.
891 * Validation result is the first parameter. This can be used to determinate if validation passed successfully or not.
892 *
893 * __Returning false from the callback will mark the cell as invalid__.
894 *
895 * @event Hooks#afterValidate
896 * @param {boolean} isValid `true` if valid, `false` if not.
897 * @param {*} value The value in question.
898 * @param {number} row Visual row index.
899 * @param {string|number} prop Property name / visual column index.
900 * @param {string} [source] String that identifies source of hook call
901 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
902 * @returns {undefined | boolean} If `false` the cell will be marked as invalid, `true` otherwise.
903 */
904'afterValidate',
905/**
906 * Fired before successful change of language (when proper language code was set).
907 *
908 * @event Hooks#beforeLanguageChange
909 * @since 0.35.0
910 * @param {string} languageCode New language code.
911 */
912'beforeLanguageChange',
913/**
914 * Fired after successful change of language (when proper language code was set).
915 *
916 * @event Hooks#afterLanguageChange
917 * @since 0.35.0
918 * @param {string} languageCode New language code.
919 */
920'afterLanguageChange',
921/**
922 * Fired by {@link Autofill} plugin before populating the data in the autofill feature. This hook is fired when
923 * {@link Options#fillHandle} option is enabled.
924 *
925 * @event Hooks#beforeAutofill
926 * @param {Array[]} selectionData Data the autofill operation will start from.
927 * @param {CellRange} sourceRange The range values will be filled from.
928 * @param {CellRange} targetRange The range new values will be filled into.
929 * @param {string} direction Declares the direction of the autofill. Possible values: `up`, `down`, `left`, `right`.
930 *
931 * @returns {boolean|Array[]} If false, the operation is cancelled. If array of arrays, the returned data
932 * will be passed into [`populateFromArray`](@/api/core.md#populatefromarray) instead of the default autofill
933 * algorithm's result.
934 */
935'beforeAutofill',
936/**
937 * Fired by {@link Autofill} plugin after populating the data in the autofill feature. This hook is fired when
938 * {@link Options#fillHandle} option is enabled.
939 *
940 * @event Hooks#afterAutofill
941 * @since 8.0.0
942 * @param {Array[]} fillData The data that was used to fill the `targetRange`. If `beforeAutofill` was used
943 * and returned `[[]]`, this will be the same object that was returned from `beforeAutofill`.
944 * @param {CellRange} sourceRange The range values will be filled from.
945 * @param {CellRange} targetRange The range new values will be filled into.
946 * @param {string} direction Declares the direction of the autofill. Possible values: `up`, `down`, `left`, `right`.
947 */
948'afterAutofill',
949/**
950 * Fired before aligning the cell contents.
951 *
952 * @event Hooks#beforeCellAlignment
953 * @param {object} stateBefore An object with class names defining the cell alignment.
954 * @param {CellRange[]} range An array of `CellRange` coordinates where the alignment will be applied.
955 * @param {string} type Type of the alignment - either `horizontal` or `vertical`.
956 * @param {string} alignmentClass String defining the alignment class added to the cell.
957 * Possible values: `htLeft` , `htCenter`, `htRight`, `htJustify`, `htTop`, `htMiddle`, `htBottom`.
958 */
959'beforeCellAlignment',
960/**
961 * Fired before one or more cells are changed.
962 *
963 * Use this hook to silently alter the user's changes before Handsontable re-renders.
964 *
965 * To ignore the user's changes, use a nullified array or return `false`.
966 *
967 * @event Hooks#beforeChange
968 * @param {Array[]} changes 2D array containing information about each of the edited cells `[[row, prop, oldVal, newVal], ...]`. `row` is a visual row index.
969 * @param {string} [source] String that identifies source of hook call
970 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
971 * @returns {undefined | boolean} If `false` all changes were cancelled, `true` otherwise.
972 * @example
973 * ::: only-for javascript
974 * ```js
975 * // to alter a single change, overwrite the value with `changes[i][3]`
976 * new Handsontable(element, {
977 * beforeChange: (changes, source) => {
978 * // [[row, prop, oldVal, newVal], ...]
979 * changes[0][3] = 10;
980 * }
981 * });
982 *
983 * // to ignore a single change, set `changes[i]` to `null`
984 * // or remove `changes[i]` from the array, by using `changes.splice(i, 1)`
985 * new Handsontable(element, {
986 * beforeChange: (changes, source) => {
987 * // [[row, prop, oldVal, newVal], ...]
988 * changes[0] = null;
989 * }
990 * });
991 *
992 * // to ignore all changes, return `false`
993 * // or set the array's length to 0, by using `changes.length = 0`
994 * new Handsontable(element, {
995 * beforeChange: (changes, source) => {
996 * // [[row, prop, oldVal, newVal], ...]
997 * return false;
998 * }
999 * });
1000 * ```
1001 * :::
1002 *
1003 * ::: only-for react
1004 * ```jsx
1005 * // to alter a single change, overwrite the desired value with `changes[i][3]`
1006 * <HotTable
1007 * beforeChange={(changes, source) => {
1008 * // [[row, prop, oldVal, newVal], ...]
1009 * changes[0][3] = 10;
1010 * }}
1011 * />
1012 *
1013 * // to ignore a single change, set `changes[i]` to `null`
1014 * // or remove `changes[i]` from the array, by using changes.splice(i, 1).
1015 * <HotTable
1016 * beforeChange={(changes, source) => {
1017 * // [[row, prop, oldVal, newVal], ...]
1018 * changes[0] = null;
1019 * }}
1020 * />
1021 *
1022 * // to ignore all changes, return `false`
1023 * // or set the array's length to 0 (`changes.length = 0`)
1024 * <HotTable
1025 * beforeChange={(changes, source) => {
1026 * // [[row, prop, oldVal, newVal], ...]
1027 * return false;
1028 * }}
1029 * />
1030 * ```
1031 * :::
1032 */
1033'beforeChange',
1034/**
1035 * Fired right before rendering the changes.
1036 *
1037 * @event Hooks#beforeChangeRender
1038 * @param {Array[]} changes Array in form of `[row, prop, oldValue, newValue]`.
1039 * @param {string} [source] String that identifies source of hook call
1040 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
1041 */
1042'beforeChangeRender',
1043/**
1044 * Fired before drawing the borders.
1045 *
1046 * @event Hooks#beforeDrawBorders
1047 * @param {Array} corners Array specifying the current selection borders.
1048 * @param {string} borderClassName Specifies the border class name.
1049 */
1050'beforeDrawBorders',
1051/**
1052 * Fired before getting cell settings.
1053 *
1054 * @event Hooks#beforeGetCellMeta
1055 * @param {number} row Visual row index.
1056 * @param {number} column Visual column index.
1057 * @param {object} cellProperties Object containing the cell's properties.
1058 */
1059'beforeGetCellMeta',
1060/**
1061 * Fired before cell meta is removed.
1062 *
1063 * @event Hooks#beforeRemoveCellMeta
1064 * @param {number} row Visual row index.
1065 * @param {number} column Visual column index.
1066 * @param {string} key The removed meta key.
1067 * @param {*} value Value which is under removed key of cell meta.
1068 * @returns {*|boolean} If false is returned the action is canceled.
1069 */
1070'beforeRemoveCellMeta',
1071/**
1072 * Fired before the Handsontable instance is initiated.
1073 *
1074 * @event Hooks#beforeInit
1075 */
1076'beforeInit',
1077/**
1078 * Fired before the Walkontable instance is initiated.
1079 *
1080 * @event Hooks#beforeInitWalkontable
1081 * @param {object} walkontableConfig Walkontable configuration object.
1082 */
1083'beforeInitWalkontable',
1084/**
1085 * Fired before Handsontable's [`data`](@/api/options.md#data)
1086 * gets modified by the [`loadData()`](@/api/core.md#loaddata) method
1087 * or the [`updateSettings()`](@/api/core.md#updatesettings) method.
1088 *
1089 * Read more:
1090 * - [Binding to data](@/guides/getting-started/binding-to-data/binding-to-data.md)
1091 * - [Saving data](@/guides/getting-started/saving-data/saving-data.md)
1092 *
1093 * @event Hooks#beforeLoadData
1094 * @since 8.0.0
1095 * @param {Array} sourceData An [array of arrays](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-arrays), or an [array of objects](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-objects), that contains Handsontable's data
1096 * @param {boolean} initialLoad A flag that indicates whether the data was loaded at Handsontable's initialization (`true`) or later (`false`)
1097 * @param {string} source The source of the call
1098 * @returns {Array} The returned array will be used as Handsontable's new dataset.
1099 */
1100'beforeLoadData',
1101/**
1102 * Fired before the [`updateData()`](@/api/core.md#updatedata) method
1103 * modifies Handsontable's [`data`](@/api/options.md#data).
1104 *
1105 * Read more:
1106 * - [Binding to data](@/guides/getting-started/binding-to-data/binding-to-data.md)
1107 * - [Saving data](@/guides/getting-started/saving-data/saving-data.md)
1108 *
1109 * @event Hooks#beforeUpdateData
1110 * @since 11.1.0
1111 * @param {Array} sourceData An [array of arrays](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-arrays), or an [array of objects](@/guides/getting-started/binding-to-data/binding-to-data.md#array-of-objects), that contains Handsontable's data
1112 * @param {boolean} initialLoad A flag that indicates whether the data was loaded at Handsontable's initialization (`true`) or later (`false`)
1113 * @param {string} source The source of the call
1114 * @returns {Array} The returned array will be used as Handsontable's new dataset.
1115 */
1116'beforeUpdateData',
1117/**
1118 * Hook fired before `keydown` event is handled. It can be used to stop default key bindings.
1119 *
1120 * __Note__: To prevent default behavior you need to call `false` in your `beforeKeyDown` handler.
1121 *
1122 * @event Hooks#beforeKeyDown
1123 * @param {Event} event Original DOM event.
1124 */
1125'beforeKeyDown',
1126/**
1127 * Fired after the user clicked a cell, but before all the calculations related with it.
1128 *
1129 * @event Hooks#beforeOnCellMouseDown
1130 * @param {Event} event The `mousedown` event object.
1131 * @param {CellCoords} coords Cell coords object containing the visual coordinates of the clicked cell.
1132 * @param {HTMLTableCellElement} TD TD element.
1133 * @param {object} controller An object with properties `row`, `column` and `cell`. Each property contains
1134 * a boolean value that allows or disallows changing the selection for that particular area.
1135 */
1136'beforeOnCellMouseDown',
1137/**
1138 * Fired after the user clicked a cell.
1139 *
1140 * @event Hooks#beforeOnCellMouseUp
1141 * @param {Event} event The `mouseup` event object.
1142 * @param {CellCoords} coords Cell coords object containing the visual coordinates of the clicked cell.
1143 * @param {HTMLTableCellElement} TD TD element.
1144 */
1145'beforeOnCellMouseUp',
1146/**
1147 * Fired after the user clicked a cell, but before all the calculations related with it.
1148 *
1149 * @event Hooks#beforeOnCellContextMenu
1150 * @since 4.1.0
1151 * @param {Event} event The `contextmenu` event object.
1152 * @param {CellCoords} coords Cell coords object containing the visual coordinates of the clicked cell.
1153 * @param {HTMLTableCellElement} TD TD element.
1154 */
1155'beforeOnCellContextMenu',
1156/**
1157 * Fired after the user moved cursor over a cell, but before all the calculations related with it.
1158 *
1159 * @event Hooks#beforeOnCellMouseOver
1160 * @param {Event} event The `mouseover` event object.
1161 * @param {CellCoords} coords CellCoords object containing the visual coordinates of the clicked cell.
1162 * @param {HTMLTableCellElement} TD TD element.
1163 * @param {object} controller An object with properties `row`, `column` and `cell`. Each property contains
1164 * a boolean value that allows or disallows changing the selection for that particular area.
1165 */
1166'beforeOnCellMouseOver',
1167/**
1168 * Fired after the user moved cursor out from a cell, but before all the calculations related with it.
1169 *
1170 * @event Hooks#beforeOnCellMouseOut
1171 * @param {Event} event The `mouseout` event object.
1172 * @param {CellCoords} coords CellCoords object containing the visual coordinates of the leaved cell.
1173 * @param {HTMLTableCellElement} TD TD element.
1174 */
1175'beforeOnCellMouseOut',
1176/**
1177 * Fired before one or more columns are about to be removed.
1178 *
1179 * @event Hooks#beforeRemoveCol
1180 * @param {number} index Visual index of starter column.
1181 * @param {number} amount Amount of columns to be removed.
1182 * @param {number[]} physicalColumns An array of physical columns removed from the data source.
1183 * @param {string} [source] String that identifies source of hook call
1184 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
1185 * @returns {*|boolean} If false is returned the action is canceled.
1186 */
1187'beforeRemoveCol',
1188/**
1189 * Fired when one or more rows are about to be removed.
1190 *
1191 * @event Hooks#beforeRemoveRow
1192 * @param {number} index Visual index of starter row.
1193 * @param {number} amount Amount of rows to be removed.
1194 * @param {number[]} physicalRows An array of physical rows removed from the data source.
1195 * @param {string} [source] String that identifies source of hook call
1196 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
1197 * @returns {*|boolean} If false is returned the action is canceled.
1198 */
1199'beforeRemoveRow',
1200/**
1201 * Fired before Handsontable's view-rendering engine is rendered.
1202 *
1203 * __Note:__ In Handsontable 9.x and earlier, the `beforeViewRender` hook was named `beforeRender`.
1204 *
1205 * @event Hooks#beforeViewRender
1206 * @since 10.0.0
1207 * @param {boolean} isForced If set to `true`, the rendering gets triggered by a change of settings, a change of
1208 * data, or a logic that needs a full Handsontable render cycle.
1209 * If set to `false`, the rendering gets triggered by scrolling or moving the selection.
1210 * @param {object} skipRender Object with `skipRender` property, if it is set to `true ` the next rendering cycle will be skipped.
1211 */
1212'beforeViewRender',
1213/**
1214 * Fired after Handsontable's view-rendering engine is rendered,
1215 * but before redrawing the selection borders and before scroll syncing.
1216 *
1217 * __Note:__ In Handsontable 9.x and earlier, the `afterViewRender` hook was named `afterRender`.
1218 *
1219 * @event Hooks#afterViewRender
1220 * @since 10.0.0
1221 * @param {boolean} isForced If set to `true`, the rendering gets triggered by a change of settings, a change of
1222 * data, or a logic that needs a full Handsontable render cycle.
1223 * If set to `false`, the rendering gets triggered by scrolling or moving the selection.
1224 */
1225'afterViewRender',
1226/**
1227 * Fired before Handsontable's view-rendering engine updates the view.
1228 *
1229 * The `beforeRender` event is fired right after the Handsontable
1230 * business logic is executed and right before the rendering engine starts calling
1231 * the Core logic, renderers, cell meta objects etc. to update the view.
1232 *
1233 * @event Hooks#beforeRender
1234 * @param {boolean} isForced If set to `true`, the rendering gets triggered by a change of settings, a change of
1235 * data, or a logic that needs a full Handsontable render cycle.
1236 * If set to `false`, the rendering gets triggered by scrolling or moving the selection.
1237 */
1238'beforeRender',
1239/**
1240 * Fired after Handsontable's view-rendering engine updates the view.
1241 *
1242 * @event Hooks#afterRender
1243 * @param {boolean} isForced If set to `true`, the rendering gets triggered by a change of settings, a change of
1244 * data, or a logic that needs a full Handsontable render cycle.
1245 * If set to `false`, the rendering gets triggered by scrolling or moving the selection.
1246 */
1247'afterRender',
1248/**
1249 * When the focus position is moved to the next or previous row caused by the {@link Options#autoWrapRow} option
1250 * the hook is triggered.
1251 *
1252 * @since 14.0.0
1253 * @event Hooks#beforeRowWrap
1254 * @param {boolean} isWrapEnabled Tells whether the row wrapping is going to happen.
1255 * There may be situations where the option does not work even though it is enabled.
1256 * This is due to the priority of other options that may block the feature.
1257 * For example, when the {@link Options#minSpareCols} is defined, the {@link Options#autoWrapRow} option is not checked.
1258 * Thus, row wrapping is off.
1259 * @param {CellCoords} newCoords The new focus position. It is an object with keys `row` and `col`, where a value of `-1` indicates a header.
1260 * @param {boolean} isFlipped `true` if the row index was flipped, `false` otherwise.
1261 * Flipped index means that the user reached the last row and the focus is moved to the first row or vice versa.
1262 */
1263'beforeRowWrap',
1264/**
1265 * When the focus position is moved to the next or previous column caused by the {@link Options#autoWrapCol} option
1266 * the hook is triggered.
1267 *
1268 * @since 14.0.0
1269 * @event Hooks#beforeColumnWrap
1270 * @param {boolean} isWrapEnabled Tells whether the column wrapping is going to happen.
1271 * There may be situations where the option does not work even though it is enabled.
1272 * This is due to the priority of other options that may block the feature.
1273 * For example, when the {@link Options#minSpareRows} is defined, the {@link Options#autoWrapCol} option is not checked.
1274 * Thus, column wrapping is off.
1275 * @param {CellCoords} newCoords The new focus position. It is an object with keys `row` and `col`, where a value of `-1` indicates a header.
1276 * @param {boolean} isFlipped `true` if the column index was flipped, `false` otherwise.
1277 * Flipped index means that the user reached the last column and the focus is moved to the first column or vice versa.
1278 */
1279'beforeColumnWrap',
1280/**
1281 * Fired before cell meta is changed.
1282 *
1283 * @event Hooks#beforeSetCellMeta
1284 * @since 8.0.0
1285 * @param {number} row Visual row index.
1286 * @param {number} column Visual column index.
1287 * @param {string} key The updated meta key.
1288 * @param {*} value The updated meta value.
1289 * @returns {boolean|undefined} If false is returned the action is canceled.
1290 */
1291'beforeSetCellMeta',
1292/**
1293 * Fired before setting focus selection.
1294 *
1295 * @since 14.3.0
1296 * @event Hooks#beforeSelectionFocusSet
1297 * @param {CellCoords} coords CellCoords instance.
1298 */
1299'beforeSelectionFocusSet',
1300/**
1301 * Fired before setting range is started but not finished yet.
1302 *
1303 * @event Hooks#beforeSetRangeStartOnly
1304 * @param {CellCoords} coords `CellCoords` instance.
1305 */
1306'beforeSetRangeStartOnly',
1307/**
1308 * Fired before setting range is started.
1309 *
1310 * @event Hooks#beforeSetRangeStart
1311 * @param {CellCoords} coords `CellCoords` instance.
1312 */
1313'beforeSetRangeStart',
1314/**
1315 * Fired before setting range is ended.
1316 *
1317 * @event Hooks#beforeSetRangeEnd
1318 * @param {CellCoords} coords `CellCoords` instance.
1319 */
1320'beforeSetRangeEnd',
1321/**
1322 * Fired before applying selection coordinates to the renderable coordinates for Walkontable (rendering engine).
1323 * It occurs even when cell coordinates remain unchanged and activates during cell selection and drag selection.
1324 * The behavior of Shift+Tab differs from Arrow Left when there's no further movement possible.
1325 *
1326 * @since 14.0.0
1327 * @event Hooks#beforeSelectionHighlightSet
1328 */
1329'beforeSelectionHighlightSet',
1330/**
1331 * Fired before the logic of handling a touch scroll, when user started scrolling on a touch-enabled device.
1332 *
1333 * @event Hooks#beforeTouchScroll
1334 */
1335'beforeTouchScroll',
1336/**
1337 * Fired before cell validation, only if validator function is defined. This can be used to manipulate the value
1338 * of changed cell before it is applied to the validator function.
1339 *
1340 * __Note:__ this will not affect values of changes. This will change value *ONLY* for validation.
1341 *
1342 * @event Hooks#beforeValidate
1343 * @param {*} value Value of the cell.
1344 * @param {number} row Visual row index.
1345 * @param {string|number} prop Property name / column index.
1346 * @param {string} [source] String that identifies source of hook call
1347 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
1348 */
1349'beforeValidate',
1350/**
1351 * Fired before cell value is rendered into the DOM (through renderer function). This can be used to manipulate the
1352 * value which is passed to the renderer without modifying the renderer itself.
1353 *
1354 * @event Hooks#beforeValueRender
1355 * @param {*} value Cell value to render.
1356 * @param {object} cellProperties An object containing the cell properties.
1357 */
1358'beforeValueRender',
1359/**
1360 * Fired after Handsontable instance is constructed (using `new` operator).
1361 *
1362 * @event Hooks#construct
1363 */
1364'construct',
1365/**
1366 * Fired after Handsontable instance is initiated but before table is rendered.
1367 *
1368 * @event Hooks#init
1369 */
1370'init',
1371/**
1372 * Fired when a column header index is about to be modified by a callback function.
1373 *
1374 * @event Hooks#modifyColHeader
1375 * @param {number} column Visual column header index.
1376 */
1377'modifyColHeader',
1378/**
1379 * Fired when a column width is about to be modified by a callback function.
1380 *
1381 * @event Hooks#modifyColWidth
1382 * @param {number} width Current column width.
1383 * @param {number} column Visual column index.
1384 */
1385'modifyColWidth',
1386/**
1387 * Fired when rendering the list of values in the multiple-selection component of the Filters dropdown.
1388 * The hook allows modifying the displayed values in that component.
1389 *
1390 * @since 14.2.0
1391 * @event Hooks#modifyFiltersMultiSelectValue
1392 * @param {object} item The item in the list of values.
1393 * @param {object} meta The cell properties object.
1394 */
1395'modifyFiltersMultiSelectValue',
1396/**
1397 * Fired when focusing a cell or a header element. Allows replacing the element to be focused by returning a
1398 * different HTML element.
1399 *
1400 * @since 14.0.0
1401 * @event Hooks#modifyFocusedElement
1402 * @param {number} row Row index.
1403 * @param {number} column Column index.
1404 * @param {HTMLElement|undefined} focusedElement The element to be focused. `null` for focusedElement is intended when focused cell is hidden.
1405 */
1406'modifyFocusedElement',
1407/**
1408 * Fired when a row header index is about to be modified by a callback function.
1409 *
1410 * @event Hooks#modifyRowHeader
1411 * @param {number} row Visual row header index.
1412 */
1413'modifyRowHeader',
1414/**
1415 * Fired when a row height is about to be modified by a callback function.
1416 *
1417 * @event Hooks#modifyRowHeight
1418 * @param {number} height Row height.
1419 * @param {number} row Visual row index.
1420 */
1421'modifyRowHeight',
1422/**
1423 * Fired when a row height is about to be modified by a callback function. The hook allows to change the row height
1424 * for the specified overlay type.
1425 *
1426 * @since 14.5.0
1427 * @event Hooks#modifyRowHeightByOverlayName
1428 * @param {number} height Row height.
1429 * @param {number} row Visual row index.
1430 * @param {'inline_start'|'top'|'top_inline_start_corner'|'bottom'|'bottom_inline_start_corner'|'master'} overlayName Overlay name.
1431 */
1432'modifyRowHeightByOverlayName',
1433/**
1434 * Fired when a data was retrieved or modified.
1435 *
1436 * @event Hooks#modifyData
1437 * @param {number} row Physical row index.
1438 * @param {number} column Visual column index.
1439 * @param {object} valueHolder Object which contains original value which can be modified by overwriting `.value` property.
1440 * @param {string} ioMode String which indicates for what operation hook is fired (`get` or `set`).
1441 */
1442'modifyData',
1443/**
1444 * Fired when a data was retrieved or modified from the source data set.
1445 *
1446 * @event Hooks#modifySourceData
1447 * @since 8.0.0
1448 * @param {number} row Physical row index.
1449 * @param {number} column Physical column index or property name.
1450 * @param {object} valueHolder Object which contains original value which can be modified by overwriting `.value` property.
1451 * @param {string} ioMode String which indicates for what operation hook is fired (`get` or `set`).
1452 */
1453'modifySourceData',
1454/**
1455 * Fired when a data was retrieved or modified.
1456 *
1457 * @event Hooks#modifyRowData
1458 * @param {number} row Physical row index.
1459 */
1460'modifyRowData',
1461/**
1462 * Used to modify the cell coordinates when using the [`getCell`](@/api/core.md#getcell) method, opening editor, getting value from the editor
1463 * and saving values from the closed editor.
1464 *
1465 * @event Hooks#modifyGetCellCoords
1466 * @since 0.36.0
1467 * @param {number} row Visual row index.
1468 * @param {number} column Visual column index.
1469 * @param {boolean} topmost If set to `true`, it returns the TD element from the topmost overlay. For example,
1470 * if the wanted cell is in the range of fixed rows, it will return a TD element
1471 * from the `top` overlay.
1472 * @returns {undefined|number[]}
1473 */
1474'modifyGetCellCoords',
1475/**
1476 * Used to modify the cell coordinates when the table is activated (going into the listen mode).
1477 *
1478 * @event Hooks#modifyFocusOnTabNavigation
1479 * @since 14.0.0
1480 * @param {'from_above' | 'from_below'} tabActivationDir The browsers Tab navigation direction. Depending on
1481 * whether the user activated the table from the element above or below, another cell can be selected.
1482 * @param {CellCoords} visualCoords The coords that will be used to select a cell.
1483 */
1484'modifyFocusOnTabNavigation',
1485/**
1486 * Allows modify the visual row index that is used to retrieve the row header element (TH) before it's
1487 * highlighted (proper CSS class names are added). Modifying the visual row index allows building a custom
1488 * implementation of the nested headers feature or other features that require highlighting other DOM
1489 * elements than that the rendering engine, by default, would have highlighted.
1490 *
1491 * @event Hooks#beforeHighlightingRowHeader
1492 * @since 8.4.0
1493 * @param {number} row Visual row index.
1494 * @param {number} headerLevel Column header level (0 = most distant to the table).
1495 * @param {object} highlightMeta An object that contains additional information about processed selection.
1496 * @returns {number|undefined}
1497 */
1498'beforeHighlightingRowHeader',
1499/**
1500 * Allows modify the visual column index that is used to retrieve the column header element (TH) before it's
1501 * highlighted (proper CSS class names are added). Modifying the visual column index allows building a custom
1502 * implementation of the nested headers feature or other features that require highlighting other DOM
1503 * elements than that the rendering engine, by default, would have highlighted.
1504 *
1505 * @event Hooks#beforeHighlightingColumnHeader
1506 * @since 8.4.0
1507 * @param {number} column Visual column index.
1508 * @param {number} headerLevel Row header level (0 = most distant to the table).
1509 * @param {object} highlightMeta An object that contains additional information about processed selection.
1510 * @returns {number|undefined}
1511 */
1512'beforeHighlightingColumnHeader',
1513/**
1514 * Fired by {@link PersistentState} plugin, after loading value, saved under given key, from browser local storage.
1515 *
1516 * The `persistentStateLoad` hook is fired even when the {@link Options#persistentState} option is disabled.
1517 *
1518 * @event Hooks#persistentStateLoad
1519 * @param {string} key Key.
1520 * @param {object} valuePlaceholder Object containing the loaded value under `valuePlaceholder.value` (if no value have been saved, `value` key will be undefined).
1521 */
1522'persistentStateLoad',
1523/**
1524 * Fired by {@link PersistentState} plugin after resetting data from local storage. If no key is given, all values associated with table will be cleared.
1525 * This hook is fired when {@link Options#persistentState} option is enabled.
1526 *
1527 * @event Hooks#persistentStateReset
1528 * @param {string} [key] Key.
1529 */
1530'persistentStateReset',
1531/**
1532 * Fired by {@link PersistentState} plugin, after saving value under given key in browser local storage.
1533 *
1534 * The `persistentStateSave` hook is fired even when the {@link Options#persistentState} option is disabled.
1535 *
1536 * @event Hooks#persistentStateSave
1537 * @param {string} key Key.
1538 * @param {Mixed} value Value to save.
1539 */
1540'persistentStateSave',
1541/**
1542 * Fired by {@link ColumnSorting} and {@link MultiColumnSorting} plugins before sorting the column. If you return `false` value inside callback for hook, then sorting
1543 * will be not applied by the Handsontable (useful for server-side sorting).
1544 *
1545 * This hook is fired when {@link Options#columnSorting} or {@link Options#multiColumnSorting} option is enabled.
1546 *
1547 * @event Hooks#beforeColumnSort
1548 * @param {Array} currentSortConfig Current sort configuration (for all sorted columns).
1549 * @param {Array} destinationSortConfigs Destination sort configuration (for all sorted columns).
1550 * @returns {boolean | undefined} If `false` the column will not be sorted, `true` otherwise.
1551 */
1552'beforeColumnSort',
1553/**
1554 * Fired by {@link ColumnSorting} and {@link MultiColumnSorting} plugins after sorting the column. This hook is fired when {@link Options#columnSorting}
1555 * or {@link Options#multiColumnSorting} option is enabled.
1556 *
1557 * @event Hooks#afterColumnSort
1558 * @param {Array} currentSortConfig Current sort configuration (for all sorted columns).
1559 * @param {Array} destinationSortConfigs Destination sort configuration (for all sorted columns).
1560 */
1561'afterColumnSort',
1562/**
1563 * Fired by {@link Autofill} plugin after setting range of autofill. This hook is fired when {@link Options#fillHandle}
1564 * option is enabled.
1565 *
1566 * @event Hooks#modifyAutofillRange
1567 * @param {Array} startArea Array of visual coordinates of the starting point for the drag-down operation (`[startRow, startColumn, endRow, endColumn]`).
1568 * @param {Array} entireArea Array of visual coordinates of the entire area of the drag-down operation (`[startRow, startColumn, endRow, endColumn]`).
1569 */
1570'modifyAutofillRange',
1571/**
1572 * Fired to allow modifying the copyable range with a callback function.
1573 *
1574 * @event Hooks#modifyCopyableRange
1575 * @param {Array[]} copyableRanges Array of objects defining copyable cells.
1576 */
1577'modifyCopyableRange',
1578/**
1579 * Fired by {@link CopyPaste} plugin before copying the values to the clipboard and before clearing values of
1580 * the selected cells. This hook is fired when {@link Options#copyPaste} option is enabled.
1581 *
1582 * @event Hooks#beforeCut
1583 * @param {Array[]} data An array of arrays which contains data to cut.
1584 * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1585 * which will be cut out.
1586 * @returns {*} If returns `false` then operation of the cutting out is canceled.
1587 * @example
1588 * ::: only-for javascript
1589 * ```js
1590 * // To disregard a single row, remove it from the array using data.splice(i, 1).
1591 * new Handsontable(element, {
1592 * beforeCut: function(data, coords) {
1593 * // data -> [[1, 2, 3], [4, 5, 6]]
1594 * data.splice(0, 1);
1595 * // data -> [[4, 5, 6]]
1596 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1597 * }
1598 * });
1599 * // To cancel a cutting action, just return `false`.
1600 * new Handsontable(element, {
1601 * beforeCut: function(data, coords) {
1602 * return false;
1603 * }
1604 * });
1605 * ```
1606 * :::
1607 *
1608 * ::: only-for react
1609 * ```jsx
1610 * // To disregard a single row, remove it from the array using data.splice(i, 1).
1611 * <HotTable
1612 * beforeCut={(data, coords) => {
1613 * // data -> [[1, 2, 3], [4, 5, 6]]
1614 * data.splice(0, 1);
1615 * // data -> [[4, 5, 6]]
1616 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1617 * }}
1618 * />
1619 * // To cancel a cutting action, just return `false`.
1620 * <HotTable
1621 * beforeCut={(data, coords) => {
1622 * return false;
1623 * }}
1624 * />
1625 * ```
1626 * :::
1627 */
1628'beforeCut',
1629/**
1630 * Fired by {@link CopyPaste} plugin after data was cut out from the table. This hook is fired when
1631 * {@link Options#copyPaste} option is enabled.
1632 *
1633 * @event Hooks#afterCut
1634 * @param {Array[]} data An array of arrays with the cut data.
1635 * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1636 * which was cut out.
1637 */
1638'afterCut',
1639/**
1640 * Fired before values are copied to the clipboard.
1641 *
1642 * @event Hooks#beforeCopy
1643 * @param {Array[]} data An array of arrays which contains data to copied.
1644 * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1645 * which will copied.
1646 * @param {{ columnHeadersCount: number }} copiedHeadersCount (Since 12.3.0) The number of copied column headers.
1647 * @returns {*} If returns `false` then copying is canceled.
1648 *
1649 * @example
1650 * ::: only-for javascript
1651 * ```js
1652 * // To disregard a single row, remove it from array using data.splice(i, 1).
1653 * ...
1654 * new Handsontable(document.getElementById('example'), {
1655 * beforeCopy: (data, coords) => {
1656 * // data -> [[1, 2, 3], [4, 5, 6]]
1657 * data.splice(0, 1);
1658 * // data -> [[4, 5, 6]]
1659 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1660 * }
1661 * });
1662 * ...
1663 *
1664 * // To cancel copying, return false from the callback.
1665 * ...
1666 * new Handsontable(document.getElementById('example'), {
1667 * beforeCopy: (data, coords) => {
1668 * return false;
1669 * }
1670 * });
1671 * ...
1672 * ```
1673 * :::
1674 *
1675 * ::: only-for react
1676 * ```jsx
1677 * // To disregard a single row, remove it from array using data.splice(i, 1).
1678 * ...
1679 * <HotTable
1680 * beforeCopy={(data, coords) => {
1681 * // data -> [[1, 2, 3], [4, 5, 6]]
1682 * data.splice(0, 1);
1683 * // data -> [[4, 5, 6]]
1684 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1685 * }}
1686 * />
1687 * ...
1688 *
1689 * // To cancel copying, return false from the callback.
1690 * ...
1691 * <HotTable
1692 * beforeCopy={(data, coords) => {
1693 * return false;
1694 * }}
1695 * />
1696 * ...
1697 * ```
1698 * :::
1699 */
1700'beforeCopy',
1701/**
1702 * Fired by {@link CopyPaste} plugin after data are pasted into table. This hook is fired when {@link Options#copyPaste}
1703 * option is enabled.
1704 *
1705 * @event Hooks#afterCopy
1706 * @param {Array[]} data An array of arrays which contains the copied data.
1707 * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1708 * which was copied.
1709 * @param {{ columnHeadersCount: number }} copiedHeadersCount (Since 12.3.0) The number of copied column headers.
1710 */
1711'afterCopy',
1712/**
1713 * Fired by {@link CopyPaste} plugin before values are pasted into table. This hook is fired when
1714 * {@link Options#copyPaste} option is enabled.
1715 *
1716 * @event Hooks#beforePaste
1717 * @param {Array[]} data An array of arrays which contains data to paste.
1718 * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1719 * that correspond to the previously selected area.
1720 * @returns {*} If returns `false` then pasting is canceled.
1721 * @example
1722 * ```js
1723 * ::: only-for javascript
1724 * // To disregard a single row, remove it from array using data.splice(i, 1).
1725 * new Handsontable(example, {
1726 * beforePaste: (data, coords) => {
1727 * // data -> [[1, 2, 3], [4, 5, 6]]
1728 * data.splice(0, 1);
1729 * // data -> [[4, 5, 6]]
1730 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1731 * }
1732 * });
1733 * // To cancel pasting, return false from the callback.
1734 * new Handsontable(example, {
1735 * beforePaste: (data, coords) => {
1736 * return false;
1737 * }
1738 * });
1739 * ```
1740 * :::
1741 *
1742 * ::: only-for react
1743 * ```jsx
1744 * // To disregard a single row, remove it from array using data.splice(i, 1).
1745 * <HotTable
1746 * beforePaste={(data, coords) => {
1747 * // data -> [[1, 2, 3], [4, 5, 6]]
1748 * data.splice(0, 1);
1749 * // data -> [[4, 5, 6]]
1750 * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
1751 * }}
1752 * />
1753 * // To cancel pasting, return false from the callback.
1754 * <HotTable
1755 * beforePaste={(data, coords) => {
1756 * return false;
1757 * }}
1758 * />
1759 * ```
1760 * :::
1761 */
1762'beforePaste',
1763/**
1764 * Fired by {@link CopyPaste} plugin after values are pasted into table. This hook is fired when
1765 * {@link Options#copyPaste} option is enabled.
1766 *
1767 * @event Hooks#afterPaste
1768 * @param {Array[]} data An array of arrays with the pasted data.
1769 * @param {object[]} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
1770 * that correspond to the previously selected area.
1771 */
1772'afterPaste',
1773/**
1774 * Fired by the {@link ManualColumnFreeze} plugin, before freezing a column.
1775 *
1776 * @event Hooks#beforeColumnFreeze
1777 * @since 12.1.0
1778 * @param {number} column The visual index of the column that is going to freeze.
1779 * @param {boolean} freezePerformed If `true`: the column is going to freeze. If `false`: the column is not going to freeze (which might happen if the column is already frozen).
1780 * @returns {boolean|undefined} If `false`: the column is not going to freeze, and the `afterColumnFreeze` hook won't fire.
1781 */
1782'beforeColumnFreeze',
1783/**
1784 * Fired by the {@link ManualColumnFreeze} plugin, right after freezing a column.
1785 *
1786 * @event Hooks#afterColumnFreeze
1787 * @since 12.1.0
1788 * @param {number} column The visual index of the frozen column.
1789 * @param {boolean} freezePerformed If `true`: the column got successfully frozen. If `false`: the column didn't get frozen.
1790 */
1791'afterColumnFreeze',
1792/**
1793 * Fired by {@link ManualColumnMove} plugin before change order of the visual indexes. This hook is fired when
1794 * {@link Options#manualColumnMove} option is enabled.
1795 *
1796 * @event Hooks#beforeColumnMove
1797 * @param {Array} movedColumns Array of visual column indexes to be moved.
1798 * @param {number} finalIndex Visual column index, being a start index for the moved columns.
1799 * Points to where the elements will be placed after the moving action.
1800 * To check visualization of final index please take a look at
1801 * [documentation](@/guides/columns/column-moving/column-moving.md).
1802 * @param {number|undefined} dropIndex Visual column index, being a drop index for the moved columns.
1803 * Points to where we are going to drop the moved elements. To check
1804 * visualization of drop index please take a look at
1805 * [documentation](@/guides/columns/column-moving/column-moving.md).
1806 * It's `undefined` when `dragColumns` function wasn't called.
1807 * @param {boolean} movePossible Indicates if it's possible to move rows to the desired position.
1808 * @returns {undefined | boolean} If `false` the column will not be moved, `true` otherwise.
1809 */
1810'beforeColumnMove',
1811/**
1812 * Fired by {@link ManualColumnMove} plugin after changing order of the visual indexes.
1813 * This hook is fired when {@link Options#manualColumnMove} option is enabled.
1814 *
1815 * @event Hooks#afterColumnMove
1816 * @param {Array} movedColumns Array of visual column indexes to be moved.
1817 * @param {number} finalIndex Visual column index, being a start index for the moved columns.
1818 * Points to where the elements will be placed after the moving action.
1819 * To check visualization of final index please take a look at
1820 * [documentation](@/guides/columns/column-moving/column-moving.md).
1821 * @param {number|undefined} dropIndex Visual column index, being a drop index for the moved columns.
1822 * Points to where we are going to drop the moved elements.
1823 * To check visualization of drop index please take a look at
1824 * [documentation](@/guides/columns/column-moving/column-moving.md).
1825 * It's `undefined` when `dragColumns` function wasn't called.
1826 * @param {boolean} movePossible Indicates if it was possible to move columns to the desired position.
1827 * @param {boolean} orderChanged Indicates if order of columns was changed by move.
1828 */
1829'afterColumnMove',
1830/**
1831 * Fired by the {@link ManualColumnFreeze} plugin, before unfreezing a column.
1832 *
1833 * @event Hooks#beforeColumnUnfreeze
1834 * @since 12.1.0
1835 * @param {number} column The visual index of the column that is going to unfreeze.
1836 * @param {boolean} unfreezePerformed If `true`: the column is going to unfreeze. If `false`: the column is not going to unfreeze (which might happen if the column is already unfrozen).
1837 * @returns {boolean|undefined} If `false`: the column is not going to unfreeze, and the `afterColumnUnfreeze` hook won't fire.
1838 */
1839'beforeColumnUnfreeze',
1840/**
1841 * Fired by the {@link ManualColumnFreeze} plugin, right after unfreezing a column.
1842 *
1843 * @event Hooks#afterColumnUnfreeze
1844 * @since 12.1.0
1845 * @param {number} column The visual index of the unfrozen column.
1846 * @param {boolean} unfreezePerformed If `true`: the column got successfully unfrozen. If `false`: the column didn't get unfrozen.
1847 */
1848'afterColumnUnfreeze',
1849/**
1850 * Fired by {@link ManualRowMove} plugin before changing the order of the visual indexes. This hook is fired when
1851 * {@link Options#manualRowMove} option is enabled.
1852 *
1853 * @event Hooks#beforeRowMove
1854 * @param {Array} movedRows Array of visual row indexes to be moved.
1855 * @param {number} finalIndex Visual row index, being a start index for the moved rows.
1856 * Points to where the elements will be placed after the moving action.
1857 * To check visualization of final index please take a look at
1858 * [documentation](@/guides/rows/row-moving/row-moving.md).
1859 * @param {number|undefined} dropIndex Visual row index, being a drop index for the moved rows.
1860 * Points to where we are going to drop the moved elements.
1861 * To check visualization of drop index please take a look at
1862 * [documentation](@/guides/rows/row-moving/row-moving.md).
1863 * It's `undefined` when `dragRows` function wasn't called.
1864 * @param {boolean} movePossible Indicates if it's possible to move rows to the desired position.
1865 * @returns {*|boolean} If false is returned the action is canceled.
1866 */
1867'beforeRowMove',
1868/**
1869 * Fired by {@link ManualRowMove} plugin after changing the order of the visual indexes.
1870 * This hook is fired when {@link Options#manualRowMove} option is enabled.
1871 *
1872 * @event Hooks#afterRowMove
1873 * @param {Array} movedRows Array of visual row indexes to be moved.
1874 * @param {number} finalIndex Visual row index, being a start index for the moved rows.
1875 * Points to where the elements will be placed after the moving action.
1876 * To check visualization of final index please take a look at
1877 * [documentation](@/guides/rows/row-moving/row-moving.md).
1878 * @param {number|undefined} dropIndex Visual row index, being a drop index for the moved rows.
1879 * Points to where we are going to drop the moved elements.
1880 * To check visualization of drop index please take a look at
1881 * [documentation](@/guides/rows/row-moving/row-moving.md).
1882 * It's `undefined` when `dragRows` function wasn't called.
1883 * @param {boolean} movePossible Indicates if it was possible to move rows to the desired position.
1884 * @param {boolean} orderChanged Indicates if order of rows was changed by move.
1885 */
1886'afterRowMove',
1887/**
1888 * Fired by {@link ManualColumnResize} plugin before rendering the table with modified column sizes. This hook is
1889 * fired when {@link Options#manualColumnResize} option is enabled.
1890 *
1891 * @event Hooks#beforeColumnResize
1892 * @param {number} newSize Calculated new column width.
1893 * @param {number} column Visual index of the resized column.
1894 * @param {boolean} isDoubleClick Flag that determines whether there was a double-click.
1895 * @returns {number} Returns a new column size or `undefined`, if column size should be calculated automatically.
1896 */
1897'beforeColumnResize',
1898/**
1899 * Fired by {@link ManualColumnResize} plugin after rendering the table with modified column sizes. This hook is
1900 * fired when {@link Options#manualColumnResize} option is enabled.
1901 *
1902 * @event Hooks#afterColumnResize
1903 * @param {number} newSize Calculated new column width.
1904 * @param {number} column Visual index of the resized column.
1905 * @param {boolean} isDoubleClick Flag that determines whether there was a double-click.
1906 */
1907'afterColumnResize',
1908/**
1909 * Fired by {@link ManualRowResize} plugin before rendering the table with modified row sizes. This hook is
1910 * fired when {@link Options#manualRowResize} option is enabled.
1911 *
1912 * @event Hooks#beforeRowResize
1913 * @param {number} newSize Calculated new row height.
1914 * @param {number} row Visual index of the resized row.
1915 * @param {boolean} isDoubleClick Flag that determines whether there was a double-click.
1916 * @returns {number|undefined} Returns the new row size or `undefined` if row size should be calculated automatically.
1917 */
1918'beforeRowResize',
1919/**
1920 * Fired by {@link ManualRowResize} plugin after rendering the table with modified row sizes. This hook is
1921 * fired when {@link Options#manualRowResize} option is enabled.
1922 *
1923 * @event Hooks#afterRowResize
1924 * @param {number} newSize Calculated new row height.
1925 * @param {number} row Visual index of the resized row.
1926 * @param {boolean} isDoubleClick Flag that determines whether there was a double-click.
1927 */
1928'afterRowResize',
1929/**
1930 * Fired after getting the column header renderers.
1931 *
1932 * @event Hooks#afterGetColumnHeaderRenderers
1933 * @param {Function[]} renderers An array of the column header renderers.
1934 */
1935'afterGetColumnHeaderRenderers',
1936/**
1937 * Fired after getting the row header renderers.
1938 *
1939 * @event Hooks#afterGetRowHeaderRenderers
1940 * @param {Function[]} renderers An array of the row header renderers.
1941 */
1942'afterGetRowHeaderRenderers',
1943/**
1944 * Fired before applying stretched column width to column.
1945 *
1946 * @event Hooks#beforeStretchingColumnWidth
1947 * @param {number} stretchedWidth Calculated width.
1948 * @param {number} column Visual column index.
1949 * @returns {number|undefined} Returns new width which will be applied to the column element.
1950 */
1951'beforeStretchingColumnWidth',
1952/**
1953 * Fired by the [`Filters`](@/api/filters.md) plugin,
1954 * before a [column filter](@/guides/columns/column-filter/column-filter.md) gets applied.
1955 *
1956 * [`beforeFilter`](#beforefilter) takes two arguments: `conditionsStack` and `previousConditionsStack`, both are
1957 * arrays of objects.
1958 *
1959 * Each object represents one of your [column filters](@/api/filters.md#addcondition),
1960 * and consists of the following properties:
1961 *
1962 * | Property | Possible values | Description |
1963 * | ------------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
1964 * | `column` | Number | A visual index of the column to which the filter will be applied. |
1965 * | `conditions` | Array of objects | Each object represents one condition. For details, see [`addCondition()`](@/api/filters.md#addcondition). |
1966 * | `operation` | `'conjunction'` \| `'disjunction'` \| `'disjunctionWithExtraCondition'` | An operation to perform on your set of `conditions`. For details, see [`addCondition()`](@/api/filters.md#addcondition). |
1967 *
1968 * An example of the format of the `conditionsStack` argument:
1969 *
1970 * ```js
1971 * [
1972 * {
1973 * column: 2,
1974 * conditions: [
1975 * {name: 'begins_with', args: [['S']]}
1976 * ],
1977 * operation: 'conjunction'
1978 * },
1979 * {
1980 * column: 4,
1981 * conditions: [
1982 * {name: 'not_empty', args: []}
1983 * ],
1984 * operation: 'conjunction'
1985 * },
1986 * ]
1987 * ```
1988 *
1989 * To perform server-side filtering (i.e., to not apply filtering to Handsontable's UI),
1990 * set [`beforeFilter`](#beforefilter) to return `false`:
1991 *
1992 * ```js
1993 * new Handsontable(document.getElementById('example'), {
1994 * beforeFilter: (conditionsStack) => {
1995 * return false;
1996 * }
1997 * });
1998 *```
1999 *
2000 * Read more:
2001 * - [Guides: Column filter](@/guides/columns/column-filter/column-filter.md)
2002 * - [Hooks: `afterFilter`](#afterfilter)
2003 * - [Options: `filters`](@/api/options.md#filters)
2004 * - [Plugins: `Filters`](@/api/filters.md)
2005 * – [Plugin methods: `addCondition()`](@/api/filters.md#addcondition)
2006 *
2007 * @event Hooks#beforeFilter
2008 * @param {object[]} conditionsStack An array of objects with your [column filters](@/api/filters.md#addcondition).
2009 * @param {object[]|null} previousConditionsStack An array of objects with your previous [column filters](@/api/filters.md#addcondition). It can also be `null` if there was no previous filters applied or the conditions did not change between performing the `filter` action.
2010 * @returns {boolean} To perform server-side filtering (i.e., to not apply filtering to Handsontable's UI), return `false`.
2011 */
2012'beforeFilter',
2013/**
2014 * Fired by the [`Filters`](@/api/filters.md) plugin,
2015 * after a [column filter](@/guides/columns/column-filter/column-filter.md) gets applied.
2016 *
2017 * [`afterFilter`](#afterfilter) takes one argument (`conditionsStack`), which is an array of objects.
2018 * Each object represents one of your [column filters](@/api/filters.md#addcondition),
2019 * and consists of the following properties:
2020 *
2021 * | Property | Possible values | Description |
2022 * | ------------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
2023 * | `column` | Number | A visual index of the column to which the filter was applied. |
2024 * | `conditions` | Array of objects | Each object represents one condition. For details, see [`addCondition()`](@/api/filters.md#addcondition). |
2025 * | `operation` | `'conjunction'` \| `'disjunction'` \| `'disjunctionWithExtraCondition'` | An operation to perform on your set of `conditions`. For details, see [`addCondition()`](@/api/filters.md#addcondition). |
2026 *
2027 * An example of the format of the `conditionsStack` argument:
2028 *
2029 * ```js
2030 * [
2031 * {
2032 * column: 2,
2033 * conditions: [
2034 * {name: 'begins_with', args: [['S']]}
2035 * ],
2036 * operation: 'conjunction'
2037 * },
2038 * {
2039 * column: 4,
2040 * conditions: [
2041 * {name: 'not_empty', args: []}
2042 * ],
2043 * operation: 'conjunction'
2044 * },
2045 * ]
2046 * ```
2047 *
2048 * Read more:
2049 * - [Guides: Column filter](@/guides/columns/column-filter/column-filter.md)
2050 * - [Hooks: `beforeFilter`](#beforefilter)
2051 * - [Options: `filters`](@/api/options.md#filters)
2052 * - [Plugins: `Filters`](@/api/filters.md)
2053 * – [Plugin methods: `addCondition()`](@/api/filters.md#addcondition)
2054 *
2055 * @event Hooks#afterFilter
2056 * @param {object[]} conditionsStack An array of objects with your [column filters](@/api/filters.md#addcondition).
2057 */
2058'afterFilter',
2059/**
2060 * Fired by the {@link Formulas} plugin, when any cell value changes.
2061 *
2062 * Returns an array of objects that contains:
2063 * - The addresses (`sheet`, `row`, `col`) and new values (`newValue`) of the changed cells.
2064 * - The addresses and new values of any cells that had to be recalculated (because their formulas depend on the cells that changed).
2065 *
2066 * This hook gets also fired on Handsontable's initialization, returning the addresses and values of all cells.
2067 *
2068 * Read more:
2069 * - [Guides: Formula calculation](@/guides/formulas/formula-calculation/formula-calculation.md)
2070 * - [HyperFormula documentation: `valuesUpdated`](https://hyperformula.handsontable.com/api/interfaces/listeners.html#valuesupdated)
2071 *
2072 * @since 9.0.0
2073 * @event Hooks#afterFormulasValuesUpdate
2074 * @param {Array} changes The addresses and new values of all the changed and recalculated cells.
2075 */
2076'afterFormulasValuesUpdate',
2077/**
2078 * Fired when a named expression is added to the Formulas' engine instance.
2079 *
2080 * @since 9.0.0
2081 * @event Hooks#afterNamedExpressionAdded
2082 * @param {string} namedExpressionName The name of the added expression.
2083 * @param {Array} changes The values and location of applied changes.
2084 */
2085'afterNamedExpressionAdded',
2086/**
2087 * Fired when a named expression is removed from the Formulas' engine instance.
2088 *
2089 * @since 9.0.0
2090 * @event Hooks#afterNamedExpressionRemoved
2091 * @param {string} namedExpressionName The name of the removed expression.
2092 * @param {Array} changes The values and location of applied changes.
2093 */
2094'afterNamedExpressionRemoved',
2095/**
2096 * Fired when a new sheet is added to the Formulas' engine instance.
2097 *
2098 * @since 9.0.0
2099 * @event Hooks#afterSheetAdded
2100 * @param {string} addedSheetDisplayName The name of the added sheet.
2101 */
2102'afterSheetAdded',
2103/**
2104 * Fired when a sheet in the Formulas' engine instance is renamed.
2105 *
2106 * @since 9.0.0
2107 * @event Hooks#afterSheetRenamed
2108 * @param {string} oldDisplayName The old name of the sheet.
2109 * @param {string} newDisplayName The new name of the sheet.
2110 */
2111'afterSheetRenamed',
2112/**
2113 * Fired when a sheet is removed from the Formulas' engine instance.
2114 *
2115 * @since 9.0.0
2116 * @event Hooks#afterSheetRemoved
2117 * @param {string} removedSheetDisplayName The removed sheet name.
2118 * @param {Array} changes The values and location of applied changes.
2119 */
2120'afterSheetRemoved',
2121/**
2122 * Fired while retrieving the column header height.
2123 *
2124 * @event Hooks#modifyColumnHeaderHeight
2125 */
2126'modifyColumnHeaderHeight',
2127/**
2128 * Fired while retrieving a column header's value.
2129 *
2130 * @since 12.3.0
2131 * @event Hooks#modifyColumnHeaderValue
2132 * @param {string} value A column header value.
2133 * @param {number} visualColumnIndex A visual column index.
2134 * @param {number} [headerLevel=0] Header level index. Accepts positive (`0` to `n`)
2135 * and negative (`-1` to `-n`) values. For positive values, `0` points to the
2136 * topmost header. For negative values, `-1` points to the bottom-most
2137 * header (the header closest to the cells).
2138 * @returns {string} The column header value to be updated.
2139 */
2140'modifyColumnHeaderValue',
2141/**
2142 * Fired by {@link UndoRedo} plugin before the undo action. Contains information about the action that is being undone.
2143 * This hook is fired when {@link Options#undo} option is enabled.
2144 *
2145 * @event Hooks#beforeUndo
2146 * @param {object} action The action object. Contains information about the action being undone. The `actionType`
2147 * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
2148 * @returns {*|boolean} If false is returned the action is canceled.
2149 */
2150'beforeUndo',
2151/**
2152 * Fired by {@link UndoRedo} plugin before changing undo stack.
2153 *
2154 * @event Hooks#beforeUndoStackChange
2155 * @since 8.4.0
2156 * @param {Array} doneActions Stack of actions which may be undone.
2157 * @param {string} [source] String that identifies source of action
2158 * ([list of all available sources](@/guides/getting-started/events-and-hooks/events-and-hooks.md#definition-for-source-argument)).
2159 * @returns {*|boolean} If false is returned the action of changing undo stack is canceled.
2160 */
2161'beforeUndoStackChange',
2162/**
2163 * Fired by {@link UndoRedo} plugin after the undo action. Contains information about the action that is being undone.
2164 * This hook is fired when {@link Options#undo} option is enabled.
2165 *
2166 * @event Hooks#afterUndo
2167 * @param {object} action The action object. Contains information about the action being undone. The `actionType`
2168 * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
2169 */
2170'afterUndo',
2171/**
2172 * Fired by {@link UndoRedo} plugin after changing undo stack.
2173 *
2174 * @event Hooks#afterUndoStackChange
2175 * @since 8.4.0
2176 * @param {Array} doneActionsBefore Stack of actions which could be undone before performing new action.
2177 * @param {Array} doneActionsAfter Stack of actions which can be undone after performing new action.
2178 */
2179'afterUndoStackChange',
2180/**
2181 * Fired by {@link UndoRedo} plugin before the redo action. Contains information about the action that is being redone.
2182 * This hook is fired when {@link Options#undo} option is enabled.
2183 *
2184 * @event Hooks#beforeRedo
2185 * @param {object} action The action object. Contains information about the action being redone. The `actionType`
2186 * property of the object specifies the type of the action in a String format (e.g. `'remove_row'`).
2187 * @returns {*|boolean} If false is returned the action is canceled.
2188 */
2189'beforeRedo',
2190/**
2191 * Fired by {@link UndoRedo} plugin before changing redo stack.
2192 *
2193 * @event Hooks#beforeRedoStackChange
2194 * @since 8.4.0
2195 * @param {Array} undoneActions Stack of actions which may be redone.
2196 */
2197'beforeRedoStackChange',
2198/**
2199 * Fired by {@link UndoRedo} plugin after the redo action. Contains information about the action that is being redone.
2200 * This hook is fired when {@link Options#undo} option is enabled.
2201 *
2202 * @event Hooks#afterRedo
2203 * @param {object} action The action object. Contains information about the action being redone. The `actionType`
2204 * property of the object specifies the type of the action in a String format (e.g. `'remove_row'`).
2205 */
2206'afterRedo',
2207/**
2208 * Fired by {@link UndoRedo} plugin after changing redo stack.
2209 *
2210 * @event Hooks#afterRedoStackChange
2211 * @since 8.4.0
2212 * @param {Array} undoneActionsBefore Stack of actions which could be redone before performing new action.
2213 * @param {Array} undoneActionsAfter Stack of actions which can be redone after performing new action.
2214 */
2215'afterRedoStackChange',
2216/**
2217 * Fired while retrieving the row header width.
2218 *
2219 * @event Hooks#modifyRowHeaderWidth
2220 * @param {number} rowHeaderWidth Row header width.
2221 */
2222'modifyRowHeaderWidth',
2223/**
2224 * Fired when the focus of the selection is being modified (e.g. Moving the focus with the enter/tab keys).
2225 *
2226 * @since 14.3.0
2227 * @event Hooks#modifyTransformFocus
2228 * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
2229 */
2230'modifyTransformFocus',
2231/**
2232 * Fired when the start of the selection is being modified (e.g. Moving the selection with the arrow keys).
2233 *
2234 * @event Hooks#modifyTransformStart
2235 * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
2236 */
2237'modifyTransformStart',
2238/**
2239 * Fired when the end of the selection is being modified (e.g. Moving the selection with the arrow keys).
2240 *
2241 * @event Hooks#modifyTransformEnd
2242 * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
2243 */
2244'modifyTransformEnd',
2245/**
2246 * Fired after the focus of the selection is being modified (e.g. Moving the focus with the enter/tab keys).
2247 *
2248 * @since 14.3.0
2249 * @event Hooks#afterModifyTransformFocus
2250 * @param {CellCoords} coords Coords of the freshly focused cell.
2251 * @param {number} rowTransformDir `-1` if trying to focus a cell with a negative row index. `0` otherwise.
2252 * @param {number} colTransformDir `-1` if trying to focus a cell with a negative column index. `0` otherwise.
2253 */
2254'afterModifyTransformFocus',
2255/**
2256 * Fired after the start of the selection is being modified (e.g. Moving the selection with the arrow keys).
2257 *
2258 * @event Hooks#afterModifyTransformStart
2259 * @param {CellCoords} coords Coords of the freshly selected cell.
2260 * @param {number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
2261 * @param {number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
2262 */
2263'afterModifyTransformStart',
2264/**
2265 * Fired after the end of the selection is being modified (e.g. Moving the selection with the arrow keys).
2266 *
2267 * @event Hooks#afterModifyTransformEnd
2268 * @param {CellCoords} coords Visual coords of the freshly selected cell.
2269 * @param {number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
2270 * @param {number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
2271 */
2272'afterModifyTransformEnd',
2273/**
2274 * Fired inside the `viewportRowCalculatorOverride` method. Allows modifying the row calculator parameters.
2275 *
2276 * @event Hooks#afterViewportRowCalculatorOverride
2277 * @param {object} calc The row calculator.
2278 */
2279'afterViewportRowCalculatorOverride',
2280/**
2281 * Fired inside the `viewportColumnCalculatorOverride` method. Allows modifying the row calculator parameters.
2282 *
2283 * @event Hooks#afterViewportColumnCalculatorOverride
2284 * @param {object} calc The row calculator.
2285 */
2286'afterViewportColumnCalculatorOverride',
2287/**
2288 * Fired after initializing all the plugins.
2289 * This hook should be added before Handsontable is initialized.
2290 *
2291 * @event Hooks#afterPluginsInitialized
2292 *
2293 * @example
2294 * ```js
2295 * Handsontable.hooks.add('afterPluginsInitialized', myCallback);
2296 * ```
2297 */
2298'afterPluginsInitialized',
2299/**
2300 * Fired by {@link HiddenRows} plugin before marking the rows as hidden. Fired only if the {@link Options#hiddenRows} option is enabled.
2301 * Returning `false` in the callback will prevent the hiding action from completing.
2302 *
2303 * @event Hooks#beforeHideRows
2304 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical row indexes.
2305 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical row indexes.
2306 * @param {boolean} actionPossible `true`, if provided row indexes are valid, `false` otherwise.
2307 * @returns {undefined|boolean} If the callback returns `false`, the hiding action will not be completed.
2308 */
2309'beforeHideRows',
2310/**
2311 * Fired by {@link HiddenRows} plugin after marking the rows as hidden. Fired only if the {@link Options#hiddenRows} option is enabled.
2312 *
2313 * @event Hooks#afterHideRows
2314 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical row indexes.
2315 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical row indexes.
2316 * @param {boolean} actionPossible `true`, if provided row indexes are valid, `false` otherwise.
2317 * @param {boolean} stateChanged `true`, if the action affected any non-hidden rows, `false` otherwise.
2318 */
2319'afterHideRows',
2320/**
2321 * Fired by {@link HiddenRows} plugin before marking the rows as not hidden. Fired only if the {@link Options#hiddenRows} option is enabled.
2322 * Returning `false` in the callback will prevent the row revealing action from completing.
2323 *
2324 * @event Hooks#beforeUnhideRows
2325 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical row indexes.
2326 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical row indexes.
2327 * @param {boolean} actionPossible `true`, if provided row indexes are valid, `false` otherwise.
2328 * @returns {undefined|boolean} If the callback returns `false`, the revealing action will not be completed.
2329 */
2330'beforeUnhideRows',
2331/**
2332 * Fired by {@link HiddenRows} plugin after marking the rows as not hidden. Fired only if the {@link Options#hiddenRows} option is enabled.
2333 *
2334 * @event Hooks#afterUnhideRows
2335 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical row indexes.
2336 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical row indexes.
2337 * @param {boolean} actionPossible `true`, if provided row indexes are valid, `false` otherwise.
2338 * @param {boolean} stateChanged `true`, if the action affected any hidden rows, `false` otherwise.
2339 */
2340'afterUnhideRows',
2341/**
2342 * Fired by {@link HiddenColumns} plugin before marking the columns as hidden. Fired only if the {@link Options#hiddenColumns} option is enabled.
2343 * Returning `false` in the callback will prevent the hiding action from completing.
2344 *
2345 * @event Hooks#beforeHideColumns
2346 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical column indexes.
2347 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical column indexes.
2348 * @param {boolean} actionPossible `true`, if the provided column indexes are valid, `false` otherwise.
2349 * @returns {undefined|boolean} If the callback returns `false`, the hiding action will not be completed.
2350 */
2351'beforeHideColumns',
2352/**
2353 * Fired by {@link HiddenColumns} plugin after marking the columns as hidden. Fired only if the {@link Options#hiddenColumns} option is enabled.
2354 *
2355 * @event Hooks#afterHideColumns
2356 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical column indexes.
2357 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical column indexes.
2358 * @param {boolean} actionPossible `true`, if the provided column indexes are valid, `false` otherwise.
2359 * @param {boolean} stateChanged `true`, if the action affected any non-hidden columns, `false` otherwise.
2360 */
2361'afterHideColumns',
2362/**
2363 * Fired by {@link HiddenColumns} plugin before marking the columns as not hidden. Fired only if the {@link Options#hiddenColumns} option is enabled.
2364 * Returning `false` in the callback will prevent the column revealing action from completing.
2365 *
2366 * @event Hooks#beforeUnhideColumns
2367 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical column indexes.
2368 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical column indexes.
2369 * @param {boolean} actionPossible `true`, if the provided column indexes are valid, `false` otherwise.
2370 * @returns {undefined|boolean} If the callback returns `false`, the hiding action will not be completed.
2371 */
2372'beforeUnhideColumns',
2373/**
2374 * Fired by {@link HiddenColumns} plugin after marking the columns as not hidden. Fired only if the {@link Options#hiddenColumns} option is enabled.
2375 *
2376 * @event Hooks#afterUnhideColumns
2377 * @param {Array} currentHideConfig Current hide configuration - a list of hidden physical column indexes.
2378 * @param {Array} destinationHideConfig Destination hide configuration - a list of hidden physical column indexes.
2379 * @param {boolean} actionPossible `true`, if the provided column indexes are valid, `false` otherwise.
2380 * @param {boolean} stateChanged `true`, if the action affected any hidden columns, `false` otherwise.
2381 */
2382'afterUnhideColumns',
2383/**
2384 * Fired by {@link TrimRows} plugin before trimming rows. This hook is fired when {@link Options#trimRows} option is enabled.
2385 *
2386 * @event Hooks#beforeTrimRow
2387 * @param {Array} currentTrimConfig Current trim configuration - a list of trimmed physical row indexes.
2388 * @param {Array} destinationTrimConfig Destination trim configuration - a list of trimmed physical row indexes.
2389 * @param {boolean} actionPossible `true`, if all of the row indexes are withing the bounds of the table, `false` otherwise.
2390 * @returns {undefined|boolean} If the callback returns `false`, the trimming action will not be completed.
2391 */
2392'beforeTrimRow',
2393/**
2394 * Fired by {@link TrimRows} plugin after trimming rows. This hook is fired when {@link Options#trimRows} option is enabled.
2395 *
2396 * @event Hooks#afterTrimRow
2397 * @param {Array} currentTrimConfig Current trim configuration - a list of trimmed physical row indexes.
2398 * @param {Array} destinationTrimConfig Destination trim configuration - a list of trimmed physical row indexes.
2399 * @param {boolean} actionPossible `true`, if all of the row indexes are withing the bounds of the table, `false` otherwise.
2400 * @param {boolean} stateChanged `true`, if the action affected any non-trimmed rows, `false` otherwise.
2401 * @returns {undefined|boolean} If the callback returns `false`, the trimming action will not be completed.
2402 */
2403'afterTrimRow',
2404/**
2405 * Fired by {@link TrimRows} plugin before untrimming rows. This hook is fired when {@link Options#trimRows} option is enabled.
2406 *
2407 * @event Hooks#beforeUntrimRow
2408 * @param {Array} currentTrimConfig Current trim configuration - a list of trimmed physical row indexes.
2409 * @param {Array} destinationTrimConfig Destination trim configuration - a list of trimmed physical row indexes.
2410 * @param {boolean} actionPossible `true`, if all of the row indexes are withing the bounds of the table, `false` otherwise.
2411 * @returns {undefined|boolean} If the callback returns `false`, the untrimming action will not be completed.
2412 */
2413'beforeUntrimRow',
2414/**
2415 * Fired by {@link TrimRows} plugin after untrimming rows. This hook is fired when {@link Options#trimRows} option is enabled.
2416 *
2417 * @event Hooks#afterUntrimRow
2418 * @param {Array} currentTrimConfig Current trim configuration - a list of trimmed physical row indexes.
2419 * @param {Array} destinationTrimConfig Destination trim configuration - a list of trimmed physical row indexes.
2420 * @param {boolean} actionPossible `true`, if all of the row indexes are withing the bounds of the table, `false` otherwise.
2421 * @param {boolean} stateChanged `true`, if the action affected any trimmed rows, `false` otherwise.
2422 * @returns {undefined|boolean} If the callback returns `false`, the untrimming action will not be completed.
2423 */
2424'afterUntrimRow',
2425/**
2426 * Fired by {@link DropdownMenu} plugin before opening the dropdown menu. This hook is fired when {@link Options#dropdownMenu}
2427 * option is enabled.
2428 *
2429 * @event Hooks#beforeDropdownMenuShow
2430 * @param {DropdownMenu} dropdownMenu The `DropdownMenu` instance.
2431 */
2432'beforeDropdownMenuShow',
2433/**
2434 * Fired by {@link DropdownMenu} plugin after opening the Dropdown Menu. This hook is fired when {@link Options#dropdownMenu}
2435 * option is enabled.
2436 *
2437 * @event Hooks#afterDropdownMenuShow
2438 * @param {DropdownMenu} dropdownMenu The `DropdownMenu` instance.
2439 */
2440'afterDropdownMenuShow',
2441/**
2442 * Fired by {@link DropdownMenu} plugin after hiding the Dropdown Menu. This hook is fired when {@link Options#dropdownMenu}
2443 * option is enabled.
2444 *
2445 * @event Hooks#afterDropdownMenuHide
2446 * @param {DropdownMenu} instance The `DropdownMenu` instance.
2447 */
2448'afterDropdownMenuHide',
2449/**
2450 * Fired by {@link NestedRows} plugin before adding a children to the `NestedRows` structure. This hook is fired when
2451 * {@link Options#nestedRows} option is enabled.
2452 *
2453 * @event Hooks#beforeAddChild
2454 * @param {object} parent The parent object.
2455 * @param {object|undefined} element The element added as a child. If `undefined`, a blank child was added.
2456 * @param {number|undefined} index The index within the parent where the new child was added. If `undefined`, the element was added as the last child.
2457 */
2458'beforeAddChild',
2459/**
2460 * Fired by {@link NestedRows} plugin after adding a children to the `NestedRows` structure. This hook is fired when
2461 * {@link Options#nestedRows} option is enabled.
2462 *
2463 * @event Hooks#afterAddChild
2464 * @param {object} parent The parent object.
2465 * @param {object|undefined} element The element added as a child. If `undefined`, a blank child was added.
2466 * @param {number|undefined} index The index within the parent where the new child was added. If `undefined`, the element was added as the last child.
2467 */
2468'afterAddChild',
2469/**
2470 * Fired by {@link NestedRows} plugin before detaching a child from its parent. This hook is fired when
2471 * {@link Options#nestedRows} option is enabled.
2472 *
2473 * @event Hooks#beforeDetachChild
2474 * @param {object} parent An object representing the parent from which the element is to be detached.
2475 * @param {object} element The detached element.
2476 */
2477'beforeDetachChild',
2478/**
2479 * Fired by {@link NestedRows} plugin after detaching a child from its parent. This hook is fired when
2480 * {@link Options#nestedRows} option is enabled.
2481 *
2482 * @event Hooks#afterDetachChild
2483 * @param {object} parent An object representing the parent from which the element was detached.
2484 * @param {object} element The detached element.
2485 * @param {number} finalElementPosition The final row index of the detached element.
2486 */
2487'afterDetachChild',
2488/**
2489 * Fired before the editor is opened and rendered.
2490 *
2491 * @since 14.2.0
2492 * @event Hooks#beforeBeginEditing
2493 * @param {number} row Visual row index of the edited cell.
2494 * @param {number} column Visual column index of the edited cell.
2495 * @param {*} initialValue The initial editor value.
2496 * @param {MouseEvent | KeyboardEvent} event The event which was responsible for opening the editor.
2497 * @param {boolean} fullEditMode `true` if the editor is opened in full edit mode, `false` otherwise.
2498 * Editor opened in full edit mode does not close after pressing Arrow keys.
2499 * @returns {boolean | undefined} If the callback returns `false,` the editor won't be opened after
2500 * the mouse double click or after pressing the Enter key. Returning `undefined` (or other value
2501 * than boolean) will result in default behavior, which disallows opening an editor for non-contiguous
2502 * selection (while pressing Ctrl/Cmd) and for multiple selected cells (while pressing SHIFT).
2503 * Returning `true` removes those restrictions.
2504 */
2505'beforeBeginEditing',
2506/**
2507 * Fired after the editor is opened and rendered.
2508 *
2509 * @event Hooks#afterBeginEditing
2510 * @param {number} row Visual row index of the edited cell.
2511 * @param {number} column Visual column index of the edited cell.
2512 */
2513'afterBeginEditing',
2514/**
2515 * Fired by {@link MergeCells} plugin before cell merging. This hook is fired when {@link Options#mergeCells}
2516 * option is enabled.
2517 *
2518 * @event Hooks#beforeMergeCells
2519 * @param {CellRange} cellRange Selection cell range.
2520 * @param {boolean} [auto=false] `true` if called automatically by the plugin.
2521 */
2522'beforeMergeCells',
2523/**
2524 * Fired by {@link MergeCells} plugin after cell merging. This hook is fired when {@link Options#mergeCells}
2525 * option is enabled.
2526 *
2527 * @event Hooks#afterMergeCells
2528 * @param {CellRange} cellRange Selection cell range.
2529 * @param {object} mergeParent The parent collection of the provided cell range.
2530 * @param {boolean} [auto=false] `true` if called automatically by the plugin.
2531 */
2532'afterMergeCells',
2533/**
2534 * Fired by {@link MergeCells} plugin before unmerging the cells. This hook is fired when {@link Options#mergeCells}
2535 * option is enabled.
2536 *
2537 * @event Hooks#beforeUnmergeCells
2538 * @param {CellRange} cellRange Selection cell range.
2539 * @param {boolean} [auto=false] `true` if called automatically by the plugin.
2540 */
2541'beforeUnmergeCells',
2542/**
2543 * Fired by {@link MergeCells} plugin after unmerging the cells. This hook is fired when {@link Options#mergeCells}
2544 * option is enabled.
2545 *
2546 * @event Hooks#afterUnmergeCells
2547 * @param {CellRange} cellRange Selection cell range.
2548 * @param {boolean} [auto=false] `true` if called automatically by the plugin.
2549 */
2550'afterUnmergeCells',
2551/**
2552 * Fired after the table was switched into listening mode. This allows Handsontable to capture keyboard events and
2553 * respond in the right way.
2554 *
2555 * @event Hooks#afterListen
2556 */
2557'afterListen',
2558/**
2559 * Fired after the table was switched off from the listening mode. This makes the Handsontable inert for any
2560 * keyboard events.
2561 *
2562 * @event Hooks#afterUnlisten
2563 */
2564'afterUnlisten',
2565/**
2566 * Fired after the window was resized or the size of the Handsontable root element was changed.
2567 *
2568 * @event Hooks#afterRefreshDimensions
2569 * @param {{ width: number, height: number }} previousDimensions Previous dimensions of the container.
2570 * @param {{ width: number, height: number }} currentDimensions Current dimensions of the container.
2571 * @param {boolean} stateChanged `true`, if the container was re-render, `false` otherwise.
2572 */
2573'afterRefreshDimensions',
2574/**
2575 * Cancellable hook, called after resizing a window or after detecting size change of the
2576 * Handsontable root element, but before redrawing a table.
2577 *
2578 * @event Hooks#beforeRefreshDimensions
2579 * @param {{ width: number, height: number }} previousDimensions Previous dimensions of the container.
2580 * @param {{ width: number, height: number }} currentDimensions Current dimensions of the container.
2581 * @param {boolean} actionPossible `true`, if current and previous dimensions are different, `false` otherwise.
2582 * @returns {undefined|boolean} If the callback returns `false`, the refresh action will not be completed.
2583 */
2584'beforeRefreshDimensions',
2585/**
2586 * Fired by {@link CollapsibleColumns} plugin before columns collapse. This hook is fired when {@link Options#collapsibleColumns} option is enabled.
2587 *
2588 * @event Hooks#beforeColumnCollapse
2589 * @since 8.0.0
2590 * @param {Array} currentCollapsedColumns Current collapsible configuration - a list of collapsible physical column indexes.
2591 * @param {Array} destinationCollapsedColumns Destination collapsible configuration - a list of collapsible physical column indexes.
2592 * @param {boolean} collapsePossible `true`, if all of the column indexes are withing the bounds of the collapsed sections, `false` otherwise.
2593 * @returns {undefined|boolean} If the callback returns `false`, the collapsing action will not be completed.
2594 */
2595'beforeColumnCollapse',
2596/**
2597 * Fired by {@link CollapsibleColumns} plugin before columns collapse. This hook is fired when {@link Options#collapsibleColumns} option is enabled.
2598 *
2599 * @event Hooks#afterColumnCollapse
2600 * @since 8.0.0
2601 * @param {Array} currentCollapsedColumns Current collapsible configuration - a list of collapsible physical column indexes.
2602 * @param {Array} destinationCollapsedColumns Destination collapsible configuration - a list of collapsible physical column indexes.
2603 * @param {boolean} collapsePossible `true`, if all of the column indexes are withing the bounds of the collapsed sections, `false` otherwise.
2604 * @param {boolean} successfullyCollapsed `true`, if the action affected any non-collapsible column, `false` otherwise.
2605 */
2606'afterColumnCollapse',
2607/**
2608 * Fired by {@link CollapsibleColumns} plugin before columns expand. This hook is fired when {@link Options#collapsibleColumns} option is enabled.
2609 *
2610 * @event Hooks#beforeColumnExpand
2611 * @since 8.0.0
2612 * @param {Array} currentCollapsedColumns Current collapsible configuration - a list of collapsible physical column indexes.
2613 * @param {Array} destinationCollapsedColumns Destination collapsible configuration - a list of collapsible physical column indexes.
2614 * @param {boolean} expandPossible `true`, if all of the column indexes are withing the bounds of the collapsed sections, `false` otherwise.
2615 * @returns {undefined|boolean} If the callback returns `false`, the expanding action will not be completed.
2616 */
2617'beforeColumnExpand',
2618/**
2619 * Fired by {@link CollapsibleColumns} plugin before columns expand. This hook is fired when {@link Options#collapsibleColumns} option is enabled.
2620 *
2621 * @event Hooks#afterColumnExpand
2622 * @since 8.0.0
2623 * @param {Array} currentCollapsedColumns Current collapsible configuration - a list of collapsible physical column indexes.
2624 * @param {Array} destinationCollapsedColumns Destination collapsible configuration - a list of collapsible physical column indexes.
2625 * @param {boolean} expandPossible `true`, if all of the column indexes are withing the bounds of the collapsed sections, `false` otherwise.
2626 * @param {boolean} successfullyExpanded `true`, if the action affected any non-collapsible column, `false` otherwise.
2627 */
2628'afterColumnExpand',
2629/**
2630 * Fired by {@link AutoColumnSize} plugin within SampleGenerator utility.
2631 *
2632 * @event Hooks#modifyAutoColumnSizeSeed
2633 * @since 8.4.0
2634 * @param {string|undefined} seed Seed ID, unique name to categorize samples.
2635 * @param {object} cellProperties Object containing the cell properties.
2636 * @param {*} cellValue Value of the cell.
2637 */
2638'modifyAutoColumnSizeSeed'];
2639
2640/**
2641 * Template warning message for removed hooks.
2642 *
2643 * @type {string}
2644 */
2645const REMOVED_MESSAGE = (0, _templateLiteralTag.toSingleLine)`The plugin hook "[hookName]" was removed in Handsontable [removedInVersion].\x20
2646 Please consult release notes https://github.com/handsontable/handsontable/releases/tag/[removedInVersion] to\x20
2647 learn about the migration path.`;
2648
2649/**
2650 * The list of the hooks which are removed from the API. The warning message is printed out in
2651 * the developer console when the hook is used.
2652 *
2653 * The Map key is represented by hook name and its value points to the Handsontable version
2654 * in which it was removed.
2655 *
2656 * @type {Map<string, string>}
2657 */
2658const REMOVED_HOOKS = new Map([['modifyRow', '8.0.0'], ['modifyCol', '8.0.0'], ['unmodifyRow', '8.0.0'], ['unmodifyCol', '8.0.0'], ['skipLengthCache', '8.0.0'], ['hiddenColumn', '8.0.0'], ['hiddenRow', '8.0.0']]);
2659
2660/* eslint-disable jsdoc/require-description-complete-sentence */
2661/**
2662 * The list of the hooks which are deprecated. The warning message is printed out in
2663 * the developer console when the hook is used.
2664 *
2665 * The Map key is represented by hook name and its value keeps message which whould be
2666 * printed out when the hook is used.
2667 *
2668 * Usage:
2669 * ```js
2670 * ...
2671 * New Map([
2672 * ['beforeColumnExpand', 'The plugin hook "beforeColumnExpand" is deprecated. Use "beforeColumnExpand2" instead.'],
2673 * ])
2674 * ...
2675 * ```
2676 *
2677 *
2678 * @type {Map<string, string>}
2679 */
2680/* eslint-enable jsdoc/require-description-complete-sentence */
2681const DEPRECATED_HOOKS = new Map([[]]);
2682const callbackOrder = new WeakMap();
2683class Hooks {
2684 static getSingleton() {
2685 return getGlobalSingleton();
2686 }
2687
2688 /**
2689 * @type {object}
2690 */
2691
2692 /**
2693 *
2694 */
2695 constructor() {
2696 _defineProperty(this, "globalBucket", void 0);
2697 this.globalBucket = this.createEmptyBucket();
2698 }
2699
2700 /**
2701 * Returns a new object with empty handlers related to every registered hook name.
2702 *
2703 * @returns {object} The empty bucket object.
2704 *
2705 * @example
2706 * ```js
2707 * Handsontable.hooks.createEmptyBucket();
2708 * // Results:
2709 * {
2710 * ...
2711 * afterCreateCol: [],
2712 * afterCreateRow: [],
2713 * beforeInit: [],
2714 * ...
2715 * }
2716 * ```
2717 */
2718 createEmptyBucket() {
2719 const bucket = Object.create(null);
2720
2721 // eslint-disable-next-line no-return-assign
2722 (0, _array.arrayEach)(REGISTERED_HOOKS, hook => {
2723 bucket[hook] = [];
2724 this.initOrderMap(bucket, hook);
2725 });
2726 return bucket;
2727 }
2728
2729 /**
2730 * Get hook bucket based on the context of the object or if argument is `undefined`, get the global hook bucket.
2731 *
2732 * @param {object} [context=null] A Handsontable instance.
2733 * @returns {object} Returns a global or Handsontable instance bucket.
2734 */
2735 getBucket() {
2736 let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2737 if (context) {
2738 if (!context.pluginHookBucket) {
2739 context.pluginHookBucket = this.createEmptyBucket();
2740 }
2741 return context.pluginHookBucket;
2742 }
2743 return this.globalBucket;
2744 }
2745
2746 /**
2747 * Adds a listener (globally or locally) to a specified hook name.
2748 * If the `context` parameter is provided, the hook will be added only to the instance it references.
2749 * Otherwise, the callback will be used everytime the hook fires on any Handsontable instance.
2750 * You can provide an array of callback functions as the `callback` argument, this way they will all be fired
2751 * once the hook is triggered.
2752 *
2753 * @see Core#addHook
2754 * @param {string} key Hook name.
2755 * @param {Function|Array} callback Callback function or an array of functions.
2756 * @param {object} [context=null] The context for the hook callback to be added - a Handsontable instance or leave empty.
2757 * @param {number} [orderIndex] Order index of the callback.
2758 * 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.
2759 * 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.
2760 * If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
2761 * @returns {Hooks} Instance of Hooks.
2762 *
2763 * @example
2764 * ```js
2765 * // single callback, added locally
2766 * Handsontable.hooks.add('beforeInit', myCallback, hotInstance);
2767 *
2768 * // single callback, added globally
2769 * Handsontable.hooks.add('beforeInit', myCallback);
2770 *
2771 * // multiple callbacks, added locally
2772 * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance);
2773 *
2774 * // multiple callbacks, added globally
2775 * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]);
2776 * ```
2777 */
2778 add(key, callback) {
2779 let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2780 let orderIndex = arguments.length > 3 ? arguments[3] : undefined;
2781 if (Array.isArray(callback)) {
2782 (0, _array.arrayEach)(callback, c => this.add(key, c, context));
2783 } else {
2784 if (REMOVED_HOOKS.has(key)) {
2785 (0, _console.warn)((0, _string.substitute)(REMOVED_MESSAGE, {
2786 hookName: key,
2787 removedInVersion: REMOVED_HOOKS.get(key)
2788 }));
2789 }
2790 if (DEPRECATED_HOOKS.has(key)) {
2791 (0, _console.warn)(DEPRECATED_HOOKS.get(key));
2792 }
2793 const bucket = this.getBucket(context);
2794 if (typeof bucket[key] === 'undefined') {
2795 this.register(key);
2796 bucket[key] = [];
2797 this.initOrderMap(bucket, key);
2798 }
2799 callback.skip = false;
2800 if (bucket[key].indexOf(callback) === -1) {
2801 // only add a hook if it has not already been added (adding the same hook twice is now silently ignored)
2802 let foundInitialHook = false;
2803 if (callback.initialHook) {
2804 (0, _array.arrayEach)(bucket[key], (cb, i) => {
2805 if (cb.initialHook) {
2806 bucket[key][i] = callback;
2807 foundInitialHook = true;
2808 return false;
2809 }
2810 });
2811 }
2812 if (!foundInitialHook) {
2813 bucket[key].push(callback);
2814 }
2815 }
2816 this.setCallbackOrderIndex(bucket, key, callback, orderIndex);
2817 this.orderBucketByOrderIndex(bucket, key);
2818 }
2819 return this;
2820 }
2821
2822 /**
2823 * Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket.
2824 *
2825 * @see Core#addHookOnce
2826 * @param {string} key Hook/Event name.
2827 * @param {Function|Array} callback Callback function.
2828 * @param {object} [context=null] A Handsontable instance.
2829 * @param {number} [orderIndex] Order index of the callback.
2830 * 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.
2831 * 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.
2832 * If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
2833 *
2834 * @example
2835 * ```js
2836 * Handsontable.hooks.once('beforeInit', myCallback, hotInstance);
2837 * ```
2838 */
2839 once(key, callback) {
2840 let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2841 let orderIndex = arguments.length > 3 ? arguments[3] : undefined;
2842 if (Array.isArray(callback)) {
2843 (0, _array.arrayEach)(callback, c => this.once(key, c, context));
2844 } else {
2845 callback.runOnce = true;
2846 this.add(key, callback, context, orderIndex);
2847 }
2848 }
2849
2850 /**
2851 * 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.
2852 *
2853 * @see Core#removeHook
2854 * @param {string} key Hook/Event name.
2855 * @param {Function} callback Callback function (needs the be the function that was previously added to the hook).
2856 * @param {object} [context=null] Handsontable instance.
2857 * @returns {boolean} Returns `true` if hook was removed, `false` otherwise.
2858 *
2859 * @example
2860 * ```js
2861 * Handsontable.hooks.remove('beforeInit', myCallback);
2862 * ```
2863 */
2864 remove(key, callback) {
2865 let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2866 const bucket = this.getBucket(context);
2867 if (typeof bucket[key] !== 'undefined') {
2868 if (bucket[key].indexOf(callback) >= 0) {
2869 callback.skip = true;
2870 return true;
2871 }
2872 }
2873 return false;
2874 }
2875
2876 /**
2877 * Checks whether there are any registered listeners for the provided hook name.
2878 * If the `context` parameter is provided, it only checks for listeners assigned to the given Handsontable instance.
2879 *
2880 * @param {string} key Hook name.
2881 * @param {object} [context=null] A Handsontable instance.
2882 * @returns {boolean} `true` for success, `false` otherwise.
2883 */
2884 has(key) {
2885 let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2886 const bucket = this.getBucket(context);
2887 return !!(bucket[key] !== undefined && bucket[key].length);
2888 }
2889
2890 /**
2891 * Runs all local and global callbacks assigned to the hook identified by the `key` parameter.
2892 * It returns either a return value from the last called callback or the first parameter (`p1`) passed to the `run` function.
2893 *
2894 * @see Core#runHooks
2895 * @param {object} context Handsontable instance.
2896 * @param {string} key Hook/Event name.
2897 * @param {*} [p1] Parameter to be passed as an argument to the callback function.
2898 * @param {*} [p2] Parameter to be passed as an argument to the callback function.
2899 * @param {*} [p3] Parameter to be passed as an argument to the callback function.
2900 * @param {*} [p4] Parameter to be passed as an argument to the callback function.
2901 * @param {*} [p5] Parameter to be passed as an argument to the callback function.
2902 * @param {*} [p6] Parameter to be passed as an argument to the callback function.
2903 * @returns {*} Either a return value from the last called callback or `p1`.
2904 *
2905 * @example
2906 * ```js
2907 * Handsontable.hooks.run(hot, 'beforeInit');
2908 * ```
2909 */
2910 run(context, key, p1, p2, p3, p4, p5, p6) {
2911 {
2912 const globalHandlers = this.globalBucket[key];
2913 const length = globalHandlers ? globalHandlers.length : 0;
2914 let index = 0;
2915 if (length) {
2916 // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
2917 while (index < length) {
2918 if (!globalHandlers[index] || globalHandlers[index].skip) {
2919 index += 1;
2920 /* eslint-disable no-continue */
2921 continue;
2922 }
2923 const res = (0, _function.fastCall)(globalHandlers[index], context, p1, p2, p3, p4, p5, p6);
2924 if (res !== undefined) {
2925 // eslint-disable-next-line no-param-reassign
2926 p1 = res;
2927 }
2928 if (globalHandlers[index] && globalHandlers[index].runOnce) {
2929 this.remove(key, globalHandlers[index]);
2930 }
2931 index += 1;
2932 }
2933 }
2934 }
2935 {
2936 const localHandlers = this.getBucket(context)[key];
2937 const length = localHandlers ? localHandlers.length : 0;
2938 let index = 0;
2939 if (length) {
2940 // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
2941 while (index < length) {
2942 if (!localHandlers[index] || localHandlers[index].skip) {
2943 index += 1;
2944 /* eslint-disable no-continue */
2945 continue;
2946 }
2947 const res = (0, _function.fastCall)(localHandlers[index], context, p1, p2, p3, p4, p5, p6);
2948 if (res !== undefined) {
2949 // eslint-disable-next-line no-param-reassign
2950 p1 = res;
2951 }
2952 if (localHandlers[index] && localHandlers[index].runOnce) {
2953 this.remove(key, localHandlers[index], context);
2954 }
2955 index += 1;
2956 }
2957 }
2958 }
2959 return p1;
2960 }
2961
2962 /**
2963 * Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed.
2964 *
2965 * @param {object} [context=null] A Handsontable instance.
2966 * @example
2967 * ```js
2968 * // destroy the global listeners
2969 * Handsontable.hooks.destroy();
2970 *
2971 * // destroy the local listeners
2972 * Handsontable.hooks.destroy(hotInstance);
2973 * ```
2974 */
2975 destroy() {
2976 let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2977 // eslint-disable-next-line no-return-assign
2978 (0, _object.objectEach)(this.getBucket(context), (value, key, bucket) => bucket[key].length = 0);
2979 }
2980
2981 /**
2982 * Registers a hook name (adds it to the list of the known hook names). Used by plugins.
2983 * It is not necessary to call register, but if you use it, your plugin hook will be used returned by
2984 * the `getRegistered` method. (which itself is used in the [demo](@/guides/getting-started/events-and-hooks/events-and-hooks.md)).
2985 *
2986 * @param {string} key The hook name.
2987 *
2988 * @example
2989 * ```js
2990 * Handsontable.hooks.register('myHook');
2991 * ```
2992 */
2993 register(key) {
2994 if (!this.isRegistered(key)) {
2995 REGISTERED_HOOKS.push(key);
2996 }
2997 }
2998
2999 /**
3000 * Deregisters a hook name (removes it from the list of known hook names).
3001 *
3002 * @param {string} key The hook name.
3003 *
3004 * @example
3005 * ```js
3006 * Handsontable.hooks.deregister('myHook');
3007 * ```
3008 */
3009 deregister(key) {
3010 if (this.isRegistered(key)) {
3011 REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
3012 }
3013 }
3014
3015 /**
3016 * Returns a boolean value depending on if a hook by such name has been removed or deprecated.
3017 *
3018 * @param {string} hookName The hook name to check.
3019 * @returns {boolean} Returns `true` if the provided hook name was marked as deprecated or
3020 * removed from API, `false` otherwise.
3021 * @example
3022 * ```js
3023 * Handsontable.hooks.isDeprecated('skipLengthCache');
3024 *
3025 * // Results:
3026 * true
3027 * ```
3028 */
3029 isDeprecated(hookName) {
3030 return DEPRECATED_HOOKS.has(hookName) || REMOVED_HOOKS.has(hookName);
3031 }
3032
3033 /**
3034 * Returns a boolean depending on if a hook by such name has been registered.
3035 *
3036 * @param {string} hookName The hook name to check.
3037 * @returns {boolean} `true` for success, `false` otherwise.
3038 * @example
3039 * ```js
3040 * Handsontable.hooks.isRegistered('beforeInit');
3041 *
3042 * // Results:
3043 * true
3044 * ```
3045 */
3046 isRegistered(hookName) {
3047 return REGISTERED_HOOKS.indexOf(hookName) >= 0;
3048 }
3049
3050 /**
3051 * Returns an array of registered hooks.
3052 *
3053 * @returns {Array} An array of registered hooks.
3054 *
3055 * @example
3056 * ```js
3057 * Handsontable.hooks.getRegistered();
3058 *
3059 * // Results:
3060 * [
3061 * ...
3062 * 'beforeInit',
3063 * 'beforeRender',
3064 * 'beforeSetRangeEnd',
3065 * 'beforeDrawBorders',
3066 * 'beforeChange',
3067 * ...
3068 * ]
3069 * ```
3070 */
3071 getRegistered() {
3072 return REGISTERED_HOOKS;
3073 }
3074
3075 /**
3076 * Sets the order index of the callback in the bucket object.
3077 *
3078 * @private
3079 * @param {object} bucket The bucket object.
3080 * @param {string} key Hook name.
3081 * @param {Function} callback Callback function.
3082 * @param {number|undefined} orderIndex Order index of the callback.
3083 */
3084 setCallbackOrderIndex(bucket, key, callback, orderIndex) {
3085 const normalizedOrderIndex = Number.isInteger(orderIndex) ? orderIndex : 0;
3086 const orderMap = this.getCallbackOrderMap(bucket, key);
3087 orderMap.set(normalizedOrderIndex, [...(orderMap.get(normalizedOrderIndex) || []), callback]);
3088 }
3089
3090 /**
3091 * Reorders the callbacks in the bucket object by their order index.
3092 *
3093 * @private
3094 * @param {objcet} bucket The bucket object.
3095 * @param {string} key Hook name.
3096 */
3097 orderBucketByOrderIndex(bucket, key) {
3098 const orderMap = this.getCallbackOrderMap(bucket, key);
3099 if (orderMap === undefined || orderMap.size === 0 || orderMap.size === 1 && orderMap.has(0)) {
3100 return;
3101 }
3102 bucket[key] = [...orderMap].sort((a, b) => a[0] - b[0]).flatMap(_ref => {
3103 let [, callbacks] = _ref;
3104 return callbacks;
3105 });
3106 }
3107
3108 /**
3109 * Extends the bucket object with the order property.
3110 *
3111 * @private
3112 * @param {object} bucket The bucket object.
3113 * @param {string} hook The hook name.
3114 */
3115 initOrderMap(bucket, hook) {
3116 if (!callbackOrder.has(bucket)) {
3117 callbackOrder.set(bucket, []);
3118 }
3119 callbackOrder.get(bucket)[hook] = new Map();
3120 }
3121
3122 /**
3123 * Returns the order map for the provided hook.
3124 *
3125 * @private
3126 * @param {object} bucket The bucket object.
3127 * @param {string} hook The hook name.
3128 * @returns {Map<number, Array<Function>>} Returns the order map for the provided hook.
3129 */
3130 getCallbackOrderMap(bucket, hook) {
3131 return callbackOrder.get(bucket)[hook];
3132 }
3133}
3134const globalSingleton = new Hooks();
3135
3136/**
3137 * @returns {Hooks}
3138 */
3139function getGlobalSingleton() {
3140 return globalSingleton;
3141}
3142var _default = exports.default = Hooks;
\No newline at end of file