handsontable 14.1.0 → 14.2.0-next-4873a35-20240228

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. package/3rdparty/walkontable/src/core/_base.js +12 -0
  2. package/3rdparty/walkontable/src/core/_base.mjs +12 -0
  3. package/3rdparty/walkontable/src/scroll.js +131 -98
  4. package/3rdparty/walkontable/src/scroll.mjs +133 -100
  5. package/3rdparty/walkontable/src/selection/border/border.js +3 -3
  6. package/3rdparty/walkontable/src/selection/border/border.mjs +3 -3
  7. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +26 -0
  8. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +26 -0
  9. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +26 -0
  10. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +26 -0
  11. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +20 -0
  12. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +20 -0
  13. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +20 -0
  14. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +20 -0
  15. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +20 -0
  16. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +20 -0
  17. package/3rdparty/walkontable/src/table.js +2 -0
  18. package/3rdparty/walkontable/src/table.mjs +2 -0
  19. package/3rdparty/walkontable/src/viewport.js +9 -0
  20. package/3rdparty/walkontable/src/viewport.mjs +10 -1
  21. package/CHANGELOG.md +38 -0
  22. package/base.js +2 -2
  23. package/base.mjs +2 -2
  24. package/core/index.js +6 -0
  25. package/core/index.mjs +2 -1
  26. package/core/viewportScroll/index.js +65 -0
  27. package/core/viewportScroll/index.mjs +61 -0
  28. package/core/viewportScroll/scrollStrategies/columnHeaderScroll.js +20 -0
  29. package/core/viewportScroll/scrollStrategies/columnHeaderScroll.mjs +16 -0
  30. package/core/viewportScroll/scrollStrategies/cornerHeaderScroll.js +14 -0
  31. package/core/viewportScroll/scrollStrategies/cornerHeaderScroll.mjs +10 -0
  32. package/core/viewportScroll/scrollStrategies/multipleScroll.js +15 -0
  33. package/core/viewportScroll/scrollStrategies/multipleScroll.mjs +11 -0
  34. package/core/viewportScroll/scrollStrategies/noncontiguousScroll.js +15 -0
  35. package/core/viewportScroll/scrollStrategies/noncontiguousScroll.mjs +11 -0
  36. package/core/viewportScroll/scrollStrategies/rowHeaderScroll.js +20 -0
  37. package/core/viewportScroll/scrollStrategies/rowHeaderScroll.mjs +16 -0
  38. package/core/viewportScroll/scrollStrategies/singleScroll.js +46 -0
  39. package/core/viewportScroll/scrollStrategies/singleScroll.mjs +42 -0
  40. package/core.d.ts +1 -1
  41. package/core.js +11 -52
  42. package/core.mjs +12 -53
  43. package/dataMap/metaManager/index.js +1 -1
  44. package/dataMap/metaManager/index.mjs +1 -1
  45. package/dataMap/metaManager/metaLayers/cellMeta.js +6 -1
  46. package/dataMap/metaManager/metaLayers/cellMeta.mjs +6 -1
  47. package/dataMap/metaManager/metaSchema.js +36 -12
  48. package/dataMap/metaManager/metaSchema.mjs +36 -12
  49. package/dist/handsontable.css +2 -2
  50. package/dist/handsontable.full.css +2 -2
  51. package/dist/handsontable.full.js +2996 -1928
  52. package/dist/handsontable.full.min.css +2 -2
  53. package/dist/handsontable.full.min.js +42 -42
  54. package/dist/handsontable.js +2998 -1930
  55. package/dist/handsontable.min.css +2 -2
  56. package/dist/handsontable.min.js +25 -25
  57. package/dist/languages/all.js +130 -25
  58. package/dist/languages/all.min.js +1 -1
  59. package/dist/languages/hr-HR.js +167 -0
  60. package/dist/languages/hr-HR.min.js +1 -0
  61. package/editorManager.js +15 -4
  62. package/editorManager.mjs +15 -4
  63. package/editors/autocompleteEditor/autocompleteEditor.js +2 -2
  64. package/editors/autocompleteEditor/autocompleteEditor.mjs +2 -2
  65. package/editors/baseEditor/baseEditor.js +1 -1
  66. package/editors/baseEditor/baseEditor.mjs +1 -1
  67. package/editors/checkboxEditor/checkboxEditor.js +5 -4
  68. package/editors/checkboxEditor/checkboxEditor.mjs +5 -4
  69. package/editors/dateEditor/dateEditor.js +1 -1
  70. package/editors/dateEditor/dateEditor.mjs +1 -1
  71. package/editors/dropdownEditor/dropdownEditor.js +1 -1
  72. package/editors/dropdownEditor/dropdownEditor.mjs +1 -1
  73. package/editors/handsontableEditor/handsontableEditor.js +1 -1
  74. package/editors/handsontableEditor/handsontableEditor.mjs +1 -1
  75. package/editors/selectEditor/selectEditor.js +1 -1
  76. package/editors/selectEditor/selectEditor.mjs +1 -1
  77. package/editors/textEditor/textEditor.js +1 -2
  78. package/editors/textEditor/textEditor.mjs +1 -2
  79. package/editors/timeEditor/timeEditor.js +1 -1
  80. package/editors/timeEditor/timeEditor.mjs +1 -1
  81. package/helpers/mixed.js +2 -2
  82. package/helpers/mixed.mjs +2 -2
  83. package/helpers/moves.js +86 -0
  84. package/helpers/moves.mjs +82 -0
  85. package/i18n/languages/hr-HR.js +96 -0
  86. package/i18n/languages/hr-HR.mjs +90 -0
  87. package/i18n/languages/index.js +2 -0
  88. package/i18n/languages/index.mjs +2 -1
  89. package/languages/all.js +130 -25
  90. package/languages/hr-HR.js +167 -0
  91. package/languages/hr-HR.mjs +92 -0
  92. package/languages/index.js +130 -25
  93. package/languages/index.mjs +2 -1
  94. package/package.json +11 -1
  95. package/pluginHooks.d.ts +4 -2
  96. package/pluginHooks.js +33 -3
  97. package/pluginHooks.mjs +33 -3
  98. package/plugins/autoColumnSize/autoColumnSize.js +6 -1
  99. package/plugins/autoColumnSize/autoColumnSize.mjs +6 -1
  100. package/plugins/autoRowSize/autoRowSize.js +5 -0
  101. package/plugins/autoRowSize/autoRowSize.mjs +5 -0
  102. package/plugins/autofill/autofill.js +3 -2
  103. package/plugins/autofill/autofill.mjs +3 -2
  104. package/plugins/dropdownMenu/dropdownMenu.js +58 -4
  105. package/plugins/dropdownMenu/dropdownMenu.mjs +58 -4
  106. package/plugins/filters/component/value.js +51 -5
  107. package/plugins/filters/component/value.mjs +51 -5
  108. package/plugins/filters/utils.js +1 -1
  109. package/plugins/filters/utils.mjs +1 -1
  110. package/plugins/formulas/formulas.js +10 -1
  111. package/plugins/formulas/formulas.mjs +10 -1
  112. package/plugins/formulas/indexSyncer/axisSyncer.js +3 -75
  113. package/plugins/formulas/indexSyncer/axisSyncer.mjs +3 -75
  114. package/plugins/manualColumnResize/manualColumnResize.js +3 -0
  115. package/plugins/manualColumnResize/manualColumnResize.mjs +3 -0
  116. package/plugins/mergeCells/cellsCollection.js +1 -1
  117. package/plugins/mergeCells/cellsCollection.mjs +1 -1
  118. package/plugins/mergeCells/mergeCells.js +30 -0
  119. package/plugins/mergeCells/mergeCells.mjs +30 -0
  120. package/plugins/undoRedo/undoRedo.js +61 -14
  121. package/plugins/undoRedo/undoRedo.mjs +61 -14
  122. package/renderers/autocompleteRenderer/autocompleteRenderer.js +1 -1
  123. package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +1 -1
  124. package/renderers/baseRenderer/baseRenderer.js +1 -1
  125. package/renderers/baseRenderer/baseRenderer.mjs +1 -1
  126. package/renderers/checkboxRenderer/checkboxRenderer.js +36 -8
  127. package/renderers/checkboxRenderer/checkboxRenderer.mjs +36 -8
  128. package/renderers/dateRenderer/dateRenderer.js +1 -1
  129. package/renderers/dateRenderer/dateRenderer.mjs +1 -1
  130. package/renderers/dropdownRenderer/dropdownRenderer.js +1 -1
  131. package/renderers/dropdownRenderer/dropdownRenderer.mjs +1 -1
  132. package/renderers/handsontableRenderer/handsontableRenderer.js +1 -1
  133. package/renderers/handsontableRenderer/handsontableRenderer.mjs +1 -1
  134. package/renderers/htmlRenderer/htmlRenderer.js +1 -1
  135. package/renderers/htmlRenderer/htmlRenderer.mjs +1 -1
  136. package/renderers/numericRenderer/index.js +2 -1
  137. package/renderers/numericRenderer/index.mjs +1 -1
  138. package/renderers/numericRenderer/numericRenderer.js +28 -13
  139. package/renderers/numericRenderer/numericRenderer.mjs +27 -13
  140. package/renderers/passwordRenderer/passwordRenderer.js +1 -1
  141. package/renderers/passwordRenderer/passwordRenderer.mjs +1 -1
  142. package/renderers/selectRenderer/selectRenderer.js +1 -1
  143. package/renderers/selectRenderer/selectRenderer.mjs +1 -1
  144. package/renderers/textRenderer/textRenderer.js +1 -1
  145. package/renderers/textRenderer/textRenderer.mjs +1 -1
  146. package/renderers/timeRenderer/timeRenderer.js +1 -1
  147. package/renderers/timeRenderer/timeRenderer.mjs +1 -1
  148. package/selection/mouseEventHandler.js +4 -0
  149. package/selection/mouseEventHandler.mjs +4 -0
  150. package/selection/selection.js +64 -5
  151. package/selection/selection.mjs +64 -5
  152. package/shortcuts/recorder.js +27 -8
  153. package/shortcuts/recorder.mjs +27 -8
  154. package/tableView.js +86 -5
  155. package/tableView.mjs +87 -6
  156. package/utils/autoResize.js +0 -1
  157. package/utils/autoResize.mjs +0 -1
  158. package/utils/ghostTable.js +6 -6
  159. package/utils/ghostTable.mjs +6 -6
  160. package/utils/parseTable.js +9 -1
  161. package/utils/parseTable.mjs +9 -1
@@ -36,6 +36,16 @@ const stickyRowsTop = {
36
36
  getFirstVisibleRow() {
37
37
  return this.getFirstRenderedRow();
38
38
  },
39
+ /**
40
+ * Get the source index of the first row partially visible in the viewport. If no rows are partially visible, returns an error code: -1.
41
+ * Assumes that all rendered rows are fully visible.
42
+ *
43
+ * @returns {number}
44
+ * @this Table
45
+ */
46
+ getFirstPartiallyVisibleRow() {
47
+ return this.getFirstRenderedRow();
48
+ },
39
49
  /**
40
50
  * Get the source index of the last rendered row. If no rows are rendered, returns an error code: -1.
41
51
  *
@@ -55,6 +65,16 @@ const stickyRowsTop = {
55
65
  getLastVisibleRow() {
56
66
  return this.getLastRenderedRow();
57
67
  },
68
+ /**
69
+ * Get the source index of the last row partially visible in the viewport. If no rows are partially visible, returns an error code: -1.
70
+ * Assumes that all rendered rows are fully visible.
71
+ *
72
+ * @returns {number}
73
+ * @this Table
74
+ */
75
+ getLastPartiallyVisibleRow() {
76
+ return this.getLastRenderedRow();
77
+ },
58
78
  /**
59
79
  * Get the number of rendered rows.
60
80
  *
@@ -33,6 +33,16 @@ const stickyRowsTop = {
33
33
  getFirstVisibleRow() {
34
34
  return this.getFirstRenderedRow();
35
35
  },
36
+ /**
37
+ * Get the source index of the first row partially visible in the viewport. If no rows are partially visible, returns an error code: -1.
38
+ * Assumes that all rendered rows are fully visible.
39
+ *
40
+ * @returns {number}
41
+ * @this Table
42
+ */
43
+ getFirstPartiallyVisibleRow() {
44
+ return this.getFirstRenderedRow();
45
+ },
36
46
  /**
37
47
  * Get the source index of the last rendered row. If no rows are rendered, returns an error code: -1.
38
48
  *
@@ -52,6 +62,16 @@ const stickyRowsTop = {
52
62
  getLastVisibleRow() {
53
63
  return this.getLastRenderedRow();
54
64
  },
65
+ /**
66
+ * Get the source index of the last row partially visible in the viewport. If no rows are partially visible, returns an error code: -1.
67
+ * Assumes that all rendered rows are fully visible.
68
+ *
69
+ * @returns {number}
70
+ * @this Table
71
+ */
72
+ getLastPartiallyVisibleRow() {
73
+ return this.getLastRenderedRow();
74
+ },
55
75
  /**
56
76
  * Get the number of rendered rows.
57
77
  *
@@ -272,6 +272,7 @@ class Table {
272
272
  if (this.isMaster) {
273
273
  // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
274
274
  wtViewport.createVisibleCalculators();
275
+ wtViewport.createPartiallyVisibleCalculators();
275
276
  }
276
277
  if (wtOverlays) {
277
278
  wtOverlays.refresh(true);
@@ -315,6 +316,7 @@ class Table {
315
316
  }
316
317
  if (this.isMaster) {
317
318
  this.dataAccessObject.wtViewport.createVisibleCalculators();
319
+ this.dataAccessObject.wtViewport.createPartiallyVisibleCalculators();
318
320
  this.dataAccessObject.wtOverlays.refresh(false);
319
321
  this.dataAccessObject.wtOverlays.applyToDOM();
320
322
  const hiderWidth = (0, _element.outerWidth)(this.hider);
@@ -268,6 +268,7 @@ class Table {
268
268
  if (this.isMaster) {
269
269
  // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
270
270
  wtViewport.createVisibleCalculators();
271
+ wtViewport.createPartiallyVisibleCalculators();
271
272
  }
272
273
  if (wtOverlays) {
273
274
  wtOverlays.refresh(true);
@@ -311,6 +312,7 @@ class Table {
311
312
  }
312
313
  if (this.isMaster) {
313
314
  this.dataAccessObject.wtViewport.createVisibleCalculators();
315
+ this.dataAccessObject.wtViewport.createPartiallyVisibleCalculators();
314
316
  this.dataAccessObject.wtOverlays.refresh(false);
315
317
  this.dataAccessObject.wtOverlays.applyToDOM();
316
318
  const hiderWidth = outerWidth(this.hider);
@@ -377,6 +377,15 @@ class Viewport {
377
377
  this.columnsVisibleCalculator = this.createColumnsCalculator(_calculator.FULLY_VISIBLE_TYPE);
378
378
  }
379
379
 
380
+ /**
381
+ * Creates rowsPartiallyVisibleCalculator and columnsPartiallyVisibleCalculator (after draw, to determine what are
382
+ * the actually partially visible rows and columns).
383
+ */
384
+ createPartiallyVisibleCalculators() {
385
+ this.rowsPartiallyVisibleCalculator = this.createRowsCalculator(_calculator.PARTIALLY_VISIBLE_TYPE);
386
+ this.columnsPartiallyVisibleCalculator = this.createColumnsCalculator(_calculator.PARTIALLY_VISIBLE_TYPE);
387
+ }
388
+
380
389
  /**
381
390
  * Returns information whether proposedRowsVisibleCalculator viewport
382
391
  * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator).
@@ -1,6 +1,6 @@
1
1
  import { getScrollbarWidth, getStyle, offset, outerHeight, outerWidth } from "../../../helpers/dom/element.mjs";
2
2
  import { objectEach } from "../../../helpers/object.mjs";
3
- import { RENDER_TYPE, FULLY_VISIBLE_TYPE, RenderAllColumnsCalculator, RenderAllRowsCalculator, ViewportColumnsCalculator, ViewportRowsCalculator } from "./calculator/index.mjs";
3
+ import { RENDER_TYPE, FULLY_VISIBLE_TYPE, PARTIALLY_VISIBLE_TYPE, RenderAllColumnsCalculator, RenderAllRowsCalculator, ViewportColumnsCalculator, ViewportRowsCalculator } from "./calculator/index.mjs";
4
4
  /**
5
5
  * @class Viewport
6
6
  */
@@ -374,6 +374,15 @@ class Viewport {
374
374
  this.columnsVisibleCalculator = this.createColumnsCalculator(FULLY_VISIBLE_TYPE);
375
375
  }
376
376
 
377
+ /**
378
+ * Creates rowsPartiallyVisibleCalculator and columnsPartiallyVisibleCalculator (after draw, to determine what are
379
+ * the actually partially visible rows and columns).
380
+ */
381
+ createPartiallyVisibleCalculators() {
382
+ this.rowsPartiallyVisibleCalculator = this.createRowsCalculator(PARTIALLY_VISIBLE_TYPE);
383
+ this.columnsPartiallyVisibleCalculator = this.createColumnsCalculator(PARTIALLY_VISIBLE_TYPE);
384
+ }
385
+
377
386
  /**
378
387
  * Returns information whether proposedRowsVisibleCalculator viewport
379
388
  * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator).
package/CHANGELOG.md CHANGED
@@ -9,6 +9,44 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
10
  <!-- UNVERSIONED -->
11
11
 
12
+ ## [14.2.0] - 2024-03-06
13
+
14
+ ### Added
15
+ - Added new `beforeBeginEditing` hook [#10699](https://github.com/handsontable/handsontable/pull/10699)
16
+ - Added an ability to prevent viewport scroll via `beforeViewportScrollVertically` and `beforeViewportScrollHorizontally` hooks. [#10724](https://github.com/handsontable/handsontable/pull/10724)
17
+ - Undo will work for moving columns [#10746](https://github.com/handsontable/handsontable/pull/10746)
18
+ - Added a `modifyFiltersMultiSelectValue` plugin hook and utilized it in the Filters' multi-selection component. [#10756](https://github.com/handsontable/handsontable/pull/10756)
19
+ - Adds localization for Croatian language [#10762](https://github.com/handsontable/handsontable/pull/10762)
20
+
21
+ ### Changed
22
+ - Improved behavior of the viewport scroll after a cell click. [#10709](https://github.com/handsontable/handsontable/pull/10709)
23
+ - Added `pikaday` to `handsontable`'s `dependencies` to ensure the backward compatibility of `14.1.0`. [#10715](https://github.com/handsontable/handsontable/pull/10715)
24
+ - Changed unnatural checkbox behaviour after double click [#10748](https://github.com/handsontable/handsontable/pull/10748)
25
+ - Changed the way checkbox-typed cells react to pressing `SPACE` and `ENTER` keys. [#10802](https://github.com/handsontable/handsontable/pull/10802)
26
+ - React: Improve react portal caching [#10758](https://github.com/handsontable/handsontable/pull/10758)
27
+
28
+ ### Removed
29
+ - removed versioned examples and gh workflow for publishing [#10766](https://github.com/handsontable/handsontable/pull/10766)
30
+
31
+ ### Fixed
32
+ - Fixed propToCol return type inference [#10631](https://github.com/handsontable/handsontable/issues/10631)
33
+ - Fixed row/column size calculations for hidden indexes [#10705](https://github.com/handsontable/handsontable/pull/10705)
34
+ - Execution of data getters in cells method won't throw an error anymore in specific situation [#10710](https://github.com/handsontable/handsontable/pull/10710)
35
+ - Fixed problems related to not syncing sheet rename from HF to HOT [#10719](https://github.com/handsontable/handsontable/pull/10719)
36
+ - Removing all columns/rows when HyperFormula is enabled won't cause an error [#10720](https://github.com/handsontable/handsontable/pull/10720)
37
+ - Fixed a problem with the text editor missing the vertical scrollbar on cells with larger amounts of content. [#10722](https://github.com/handsontable/handsontable/pull/10722)
38
+ - Fixed the `afterSelectionEnd` and `afterSelectionEndByProp` hooks overcall when the non-contiguous selection was applied [#10725](https://github.com/handsontable/handsontable/pull/10725)
39
+ - Cells pasted from clipboard's tables won't contain unnecessary line breaks [#10745](https://github.com/handsontable/handsontable/pull/10745)
40
+ - Focus on the Handsontable instance within the iframe won't persist for clicking outside the iframe [#10752](https://github.com/handsontable/handsontable/pull/10752)
41
+ - Hovering "handsontable" cell type header handles won't throw an error [#10761](https://github.com/handsontable/handsontable/pull/10761)
42
+ - Fixed a problem with the dropdown editor throwing an error when the cell value was represented by a `td` outside of the initial editor viewport. [#10763](https://github.com/handsontable/handsontable/pull/10763)
43
+ - Fixed input problems when using the browser's autocomplete + fixed an event listener leak. [#10795](https://github.com/handsontable/handsontable/pull/10795)
44
+ - Fixed a problem where the mobile selection handles were displayed on the context menus/dropdown menus. [#10816](https://github.com/handsontable/handsontable/pull/10816)
45
+ - Fixed a problem where the Autofill plugin's double-click feature treated cells filled with `0`s as empty. [#10817](https://github.com/handsontable/handsontable/pull/10817)
46
+ - Vue: chore: update peerDependencies of vue3 wrapper [#10571](https://github.com/handsontable/handsontable/issues/10571)
47
+ - React: Export HotTableClass from React wrapper [#10736](https://github.com/handsontable/handsontable/issues/10736)
48
+ - React: Fixed missing renderer and editor prop in react wrapper [#10768](https://github.com/handsontable/handsontable/pull/10768)
49
+
12
50
  ## [14.1.0] - 2024-01-16
13
51
 
14
52
  ### Added
package/base.js CHANGED
@@ -45,8 +45,8 @@ Handsontable.hooks = _pluginHooks.default.getSingleton();
45
45
  Handsontable.CellCoords = _src.CellCoords;
46
46
  Handsontable.CellRange = _src.CellRange;
47
47
  Handsontable.packageName = 'handsontable';
48
- Handsontable.buildDate = "16/01/2024 10:27:11";
49
- Handsontable.version = "14.1.0";
48
+ Handsontable.buildDate = "28/02/2024 15:23:03";
49
+ Handsontable.version = "14.2.0-next-4873a35-20240228";
50
50
  Handsontable.languages = {
51
51
  dictionaryKeys: _registry.dictionaryKeys,
52
52
  getLanguageDictionary: _registry.getLanguageDictionary,
package/base.mjs CHANGED
@@ -35,8 +35,8 @@ Handsontable.hooks = Hooks.getSingleton();
35
35
  Handsontable.CellCoords = CellCoords;
36
36
  Handsontable.CellRange = CellRange;
37
37
  Handsontable.packageName = 'handsontable';
38
- Handsontable.buildDate = "16/01/2024 10:27:23";
39
- Handsontable.version = "14.1.0";
38
+ Handsontable.buildDate = "28/02/2024 15:23:08";
39
+ Handsontable.version = "14.2.0-next-4873a35-20240228";
40
40
  Handsontable.languages = {
41
41
  dictionaryKeys,
42
42
  getLanguageDictionary,
package/core/index.js CHANGED
@@ -6,4 +6,10 @@ Object.keys(_focusCatcher).forEach(function (key) {
6
6
  if (key === "default" || key === "__esModule") return;
7
7
  if (key in exports && exports[key] === _focusCatcher[key]) return;
8
8
  exports[key] = _focusCatcher[key];
9
+ });
10
+ var _viewportScroll = require("./viewportScroll");
11
+ Object.keys(_viewportScroll).forEach(function (key) {
12
+ if (key === "default" || key === "__esModule") return;
13
+ if (key in exports && exports[key] === _viewportScroll[key]) return;
14
+ exports[key] = _viewportScroll[key];
9
15
  });
package/core/index.mjs CHANGED
@@ -1 +1,2 @@
1
- export * from "./focusCatcher/index.mjs";
1
+ export * from "./focusCatcher/index.mjs";
2
+ export * from "./viewportScroll/index.mjs";
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.createViewportScroller = createViewportScroller;
5
+ var _columnHeaderScroll = require("./scrollStrategies/columnHeaderScroll");
6
+ var _cornerHeaderScroll = require("./scrollStrategies/cornerHeaderScroll");
7
+ var _multipleScroll = require("./scrollStrategies/multipleScroll");
8
+ var _noncontiguousScroll = require("./scrollStrategies/noncontiguousScroll");
9
+ var _rowHeaderScroll = require("./scrollStrategies/rowHeaderScroll");
10
+ var _singleScroll = require("./scrollStrategies/singleScroll");
11
+ /**
12
+ * @typedef ViewportScroller
13
+ * @property {function(): void} resume Resumes the viewport scroller.
14
+ * @property {function(): void} suspend Suspends the viewport scroller until the `resume` method is called.
15
+ * @property {function(): void} skipNextScrollCycle Skip the next scroll cycle.
16
+ * @property {function(CellCoords): void} scrollTo Scroll the viewport to a given cell.
17
+ */
18
+ /**
19
+ * Installs a viewport scroller module. The module is responsible for scrolling the viewport to a given cell
20
+ * based on the selection type (single cell selection, multiple cells selection, header selection etc.).
21
+ * It's triggered by the selection module via the `afterSetRangeEnd` hook every time the selection changes.
22
+ *
23
+ * @param {Core} hot The Handsontable instance.
24
+ * @returns {ViewportScroller} The viewport scroller module.
25
+ */
26
+ function createViewportScroller(hot) {
27
+ const {
28
+ selection
29
+ } = hot;
30
+ let skipNextCall = false;
31
+ let isSuspended = false;
32
+ return {
33
+ resume() {
34
+ isSuspended = false;
35
+ },
36
+ suspend() {
37
+ isSuspended = true;
38
+ },
39
+ skipNextScrollCycle() {
40
+ skipNextCall = true;
41
+ },
42
+ scrollTo(cellCoords) {
43
+ var _scrollStrategy;
44
+ if (skipNextCall || isSuspended) {
45
+ skipNextCall = false;
46
+ return;
47
+ }
48
+ let scrollStrategy;
49
+ if (selection.isSelectedByCorner()) {
50
+ scrollStrategy = (0, _cornerHeaderScroll.cornerHeaderScrollStrategy)(hot);
51
+ } else if (selection.isSelectedByRowHeader()) {
52
+ scrollStrategy = (0, _rowHeaderScroll.rowHeaderScrollStrategy)(hot);
53
+ } else if (selection.isSelectedByColumnHeader()) {
54
+ scrollStrategy = (0, _columnHeaderScroll.columnHeaderScrollStrategy)(hot);
55
+ } else if (selection.getSelectedRange().size() === 1 && selection.isMultiple()) {
56
+ scrollStrategy = (0, _multipleScroll.multipleScrollStrategy)(hot);
57
+ } else if (selection.getSelectedRange().size() === 1 && !selection.isMultiple()) {
58
+ scrollStrategy = (0, _singleScroll.singleScrollStrategy)(hot);
59
+ } else if (selection.getSelectedRange().size() > 1) {
60
+ scrollStrategy = (0, _noncontiguousScroll.noncontiguousScrollStrategy)(hot);
61
+ }
62
+ (_scrollStrategy = scrollStrategy) === null || _scrollStrategy === void 0 || _scrollStrategy(cellCoords);
63
+ }
64
+ };
65
+ }
@@ -0,0 +1,61 @@
1
+ import { columnHeaderScrollStrategy } from "./scrollStrategies/columnHeaderScroll.mjs";
2
+ import { cornerHeaderScrollStrategy } from "./scrollStrategies/cornerHeaderScroll.mjs";
3
+ import { multipleScrollStrategy } from "./scrollStrategies/multipleScroll.mjs";
4
+ import { noncontiguousScrollStrategy } from "./scrollStrategies/noncontiguousScroll.mjs";
5
+ import { rowHeaderScrollStrategy } from "./scrollStrategies/rowHeaderScroll.mjs";
6
+ import { singleScrollStrategy } from "./scrollStrategies/singleScroll.mjs";
7
+ /**
8
+ * @typedef ViewportScroller
9
+ * @property {function(): void} resume Resumes the viewport scroller.
10
+ * @property {function(): void} suspend Suspends the viewport scroller until the `resume` method is called.
11
+ * @property {function(): void} skipNextScrollCycle Skip the next scroll cycle.
12
+ * @property {function(CellCoords): void} scrollTo Scroll the viewport to a given cell.
13
+ */
14
+ /**
15
+ * Installs a viewport scroller module. The module is responsible for scrolling the viewport to a given cell
16
+ * based on the selection type (single cell selection, multiple cells selection, header selection etc.).
17
+ * It's triggered by the selection module via the `afterSetRangeEnd` hook every time the selection changes.
18
+ *
19
+ * @param {Core} hot The Handsontable instance.
20
+ * @returns {ViewportScroller} The viewport scroller module.
21
+ */
22
+ export function createViewportScroller(hot) {
23
+ const {
24
+ selection
25
+ } = hot;
26
+ let skipNextCall = false;
27
+ let isSuspended = false;
28
+ return {
29
+ resume() {
30
+ isSuspended = false;
31
+ },
32
+ suspend() {
33
+ isSuspended = true;
34
+ },
35
+ skipNextScrollCycle() {
36
+ skipNextCall = true;
37
+ },
38
+ scrollTo(cellCoords) {
39
+ var _scrollStrategy;
40
+ if (skipNextCall || isSuspended) {
41
+ skipNextCall = false;
42
+ return;
43
+ }
44
+ let scrollStrategy;
45
+ if (selection.isSelectedByCorner()) {
46
+ scrollStrategy = cornerHeaderScrollStrategy(hot);
47
+ } else if (selection.isSelectedByRowHeader()) {
48
+ scrollStrategy = rowHeaderScrollStrategy(hot);
49
+ } else if (selection.isSelectedByColumnHeader()) {
50
+ scrollStrategy = columnHeaderScrollStrategy(hot);
51
+ } else if (selection.getSelectedRange().size() === 1 && selection.isMultiple()) {
52
+ scrollStrategy = multipleScrollStrategy(hot);
53
+ } else if (selection.getSelectedRange().size() === 1 && !selection.isMultiple()) {
54
+ scrollStrategy = singleScrollStrategy(hot);
55
+ } else if (selection.getSelectedRange().size() > 1) {
56
+ scrollStrategy = noncontiguousScrollStrategy(hot);
57
+ }
58
+ (_scrollStrategy = scrollStrategy) === null || _scrollStrategy === void 0 || _scrollStrategy(cellCoords);
59
+ }
60
+ };
61
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.columnHeaderScrollStrategy = columnHeaderScrollStrategy;
5
+ /**
6
+ * Scroll strategy for column header selection.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function columnHeaderScrollStrategy(hot) {
12
+ return _ref => {
13
+ let {
14
+ col
15
+ } = _ref;
16
+ hot.scrollViewportTo({
17
+ col
18
+ });
19
+ };
20
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Scroll strategy for column header selection.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function columnHeaderScrollStrategy(hot) {
8
+ return _ref => {
9
+ let {
10
+ col
11
+ } = _ref;
12
+ hot.scrollViewportTo({
13
+ col
14
+ });
15
+ };
16
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.cornerHeaderScrollStrategy = cornerHeaderScrollStrategy;
5
+ /**
6
+ * Scroll strategy for corner header selection.
7
+ *
8
+ * @returns {function(): function(CellCoords): void}
9
+ */
10
+ function cornerHeaderScrollStrategy() {
11
+ return () => {
12
+ // do not scroll the viewport when the corner is clicked
13
+ };
14
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Scroll strategy for corner header selection.
3
+ *
4
+ * @returns {function(): function(CellCoords): void}
5
+ */
6
+ export function cornerHeaderScrollStrategy() {
7
+ return () => {
8
+ // do not scroll the viewport when the corner is clicked
9
+ };
10
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.multipleScrollStrategy = multipleScrollStrategy;
5
+ /**
6
+ * Scroll strategy for multiple selections.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function multipleScrollStrategy(hot) {
12
+ return cellCoords => {
13
+ hot.scrollViewportTo(cellCoords.toObject());
14
+ };
15
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Scroll strategy for multiple selections.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function multipleScrollStrategy(hot) {
8
+ return cellCoords => {
9
+ hot.scrollViewportTo(cellCoords.toObject());
10
+ };
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.noncontiguousScrollStrategy = noncontiguousScrollStrategy;
5
+ /**
6
+ * Scroll strategy for non-contiguous selections.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function noncontiguousScrollStrategy(hot) {
12
+ return cellCoords => {
13
+ hot.scrollViewportTo(cellCoords.toObject());
14
+ };
15
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Scroll strategy for non-contiguous selections.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function noncontiguousScrollStrategy(hot) {
8
+ return cellCoords => {
9
+ hot.scrollViewportTo(cellCoords.toObject());
10
+ };
11
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.rowHeaderScrollStrategy = rowHeaderScrollStrategy;
5
+ /**
6
+ * Scroll strategy for row header selection.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): void}
10
+ */
11
+ function rowHeaderScrollStrategy(hot) {
12
+ return _ref => {
13
+ let {
14
+ row
15
+ } = _ref;
16
+ hot.scrollViewportTo({
17
+ row
18
+ });
19
+ };
20
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Scroll strategy for row header selection.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): void}
6
+ */
7
+ export function rowHeaderScrollStrategy(hot) {
8
+ return _ref => {
9
+ let {
10
+ row
11
+ } = _ref;
12
+ hot.scrollViewportTo({
13
+ row
14
+ });
15
+ };
16
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.singleScrollStrategy = singleScrollStrategy;
5
+ /**
6
+ * Scroll strategy for single cell selection.
7
+ *
8
+ * @param {Core} hot Handsontable instance.
9
+ * @returns {function(): function(CellCoords): { row: number, col: number } | void }
10
+ */
11
+ function singleScrollStrategy(hot) {
12
+ return cellCoords => {
13
+ const selectionSource = hot.selection.getSelectionSource();
14
+ const {
15
+ row,
16
+ col
17
+ } = cellCoords;
18
+
19
+ // navigating through the column headers (when `navigableHeaders` is enabled)
20
+ // scrolls the viewport horizontally only
21
+ if (row < 0 && col >= 0) {
22
+ hot.scrollViewportTo({
23
+ col
24
+ });
25
+
26
+ // navigating through the row headers (when `navigableHeaders` is enabled)
27
+ // scrolls the viewport vertically only
28
+ } else if (col < 0 && row >= 0) {
29
+ hot.scrollViewportTo({
30
+ row
31
+ });
32
+
33
+ // navigating through the cells
34
+ } else {
35
+ if (selectionSource === 'mouse') {
36
+ if (col === hot.view.getLastPartiallyVisibleColumn() || row === hot.view.getLastPartiallyVisibleRow()) {
37
+ return;
38
+ }
39
+ }
40
+ hot.scrollViewportTo({
41
+ row,
42
+ col
43
+ });
44
+ }
45
+ };
46
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Scroll strategy for single cell selection.
3
+ *
4
+ * @param {Core} hot Handsontable instance.
5
+ * @returns {function(): function(CellCoords): { row: number, col: number } | void }
6
+ */
7
+ export function singleScrollStrategy(hot) {
8
+ return cellCoords => {
9
+ const selectionSource = hot.selection.getSelectionSource();
10
+ const {
11
+ row,
12
+ col
13
+ } = cellCoords;
14
+
15
+ // navigating through the column headers (when `navigableHeaders` is enabled)
16
+ // scrolls the viewport horizontally only
17
+ if (row < 0 && col >= 0) {
18
+ hot.scrollViewportTo({
19
+ col
20
+ });
21
+
22
+ // navigating through the row headers (when `navigableHeaders` is enabled)
23
+ // scrolls the viewport vertically only
24
+ } else if (col < 0 && row >= 0) {
25
+ hot.scrollViewportTo({
26
+ row
27
+ });
28
+
29
+ // navigating through the cells
30
+ } else {
31
+ if (selectionSource === 'mouse') {
32
+ if (col === hot.view.getLastPartiallyVisibleColumn() || row === hot.view.getLastPartiallyVisibleRow()) {
33
+ return;
34
+ }
35
+ }
36
+ hot.scrollViewportTo({
37
+ row,
38
+ col
39
+ });
40
+ }
41
+ };
42
+ }
package/core.d.ts CHANGED
@@ -118,7 +118,7 @@ export default class Core {
118
118
  loadData(data: CellValue[][] | RowObject[], source?: string): void;
119
119
  populateFromArray(row: number, column: number, input: CellValue[][], endRow?: number,
120
120
  endColumn?: number, source?: string, method?: 'shift_down' | 'shift_right' | 'overwrite'): void;
121
- propToCol(prop: string | number): string | number;
121
+ propToCol<T extends number | string>(prop: string | number): T;
122
122
  redo(): void;
123
123
  refreshDimensions(): void;
124
124
  removeCellMeta(row: number, column: number, key: (keyof CellMeta) | string): void;