handsontable 14.3.0 → 14.4.0-next-f62dd73-20240521

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. package/3rdparty/walkontable/src/calculator/viewportRows.js +3 -3
  2. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +3 -3
  3. package/3rdparty/walkontable/src/core/_base.js +1 -1
  4. package/3rdparty/walkontable/src/core/_base.mjs +1 -1
  5. package/3rdparty/walkontable/src/overlay/_base.js +24 -20
  6. package/3rdparty/walkontable/src/overlay/_base.mjs +24 -20
  7. package/3rdparty/walkontable/src/overlay/bottom.js +3 -6
  8. package/3rdparty/walkontable/src/overlay/bottom.mjs +3 -6
  9. package/3rdparty/walkontable/src/overlay/inlineStart.js +22 -19
  10. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +22 -19
  11. package/3rdparty/walkontable/src/overlay/top.js +13 -12
  12. package/3rdparty/walkontable/src/overlay/top.mjs +13 -12
  13. package/3rdparty/walkontable/src/overlays.js +46 -24
  14. package/3rdparty/walkontable/src/overlays.mjs +46 -24
  15. package/3rdparty/walkontable/src/selection/manager.js +7 -0
  16. package/3rdparty/walkontable/src/selection/manager.mjs +7 -0
  17. package/3rdparty/walkontable/src/selection/scanner.js +7 -0
  18. package/3rdparty/walkontable/src/selection/scanner.mjs +7 -0
  19. package/3rdparty/walkontable/src/table.js +10 -11
  20. package/3rdparty/walkontable/src/table.mjs +10 -11
  21. package/3rdparty/walkontable/src/utils/columnStretching.js +4 -0
  22. package/3rdparty/walkontable/src/utils/columnStretching.mjs +4 -0
  23. package/3rdparty/walkontable/src/viewport.js +18 -10
  24. package/3rdparty/walkontable/src/viewport.mjs +18 -10
  25. package/CHANGELOG.md +37 -0
  26. package/base.js +2 -2
  27. package/base.mjs +2 -2
  28. package/core.d.ts +2 -2
  29. package/core.js +93 -162
  30. package/core.mjs +93 -162
  31. package/dataMap/dataMap.js +10 -4
  32. package/dataMap/dataMap.mjs +10 -4
  33. package/dataMap/dataSource.js +16 -3
  34. package/dataMap/dataSource.mjs +16 -3
  35. package/dataMap/metaManager/lazyFactoryMap.js +7 -0
  36. package/dataMap/metaManager/lazyFactoryMap.mjs +7 -0
  37. package/dataMap/metaManager/metaSchema.js +38 -0
  38. package/dataMap/metaManager/metaSchema.mjs +38 -0
  39. package/dataMap/metaManager/mods/dynamicCellMeta.js +7 -0
  40. package/dataMap/metaManager/mods/dynamicCellMeta.mjs +7 -0
  41. package/dataMap/metaManager/mods/extendMetaProperties.js +44 -31
  42. package/dataMap/metaManager/mods/extendMetaProperties.mjs +44 -31
  43. package/dataMap/metaManager/utils.js +7 -0
  44. package/dataMap/metaManager/utils.mjs +7 -0
  45. package/dist/handsontable.css +4 -5
  46. package/dist/handsontable.full.css +4 -5
  47. package/dist/handsontable.full.js +5878 -4657
  48. package/dist/handsontable.full.min.css +4 -4
  49. package/dist/handsontable.full.min.js +59 -59
  50. package/dist/handsontable.js +5383 -4277
  51. package/dist/handsontable.min.css +4 -4
  52. package/dist/handsontable.min.js +20 -20
  53. package/editorManager.js +0 -67
  54. package/editorManager.mjs +0 -67
  55. package/editors/autocompleteEditor/autocompleteEditor.js +6 -4
  56. package/editors/autocompleteEditor/autocompleteEditor.mjs +6 -4
  57. package/editors/baseEditor/baseEditor.js +1 -36
  58. package/editors/baseEditor/baseEditor.mjs +2 -37
  59. package/editors/dateEditor/dateEditor.js +4 -1
  60. package/editors/dateEditor/dateEditor.mjs +4 -1
  61. package/editors/dropdownEditor/dropdownEditor.js +8 -5
  62. package/editors/dropdownEditor/dropdownEditor.mjs +8 -5
  63. package/editors/handsontableEditor/handsontableEditor.js +2 -2
  64. package/editors/handsontableEditor/handsontableEditor.mjs +2 -2
  65. package/editors/selectEditor/selectEditor.js +1 -9
  66. package/editors/selectEditor/selectEditor.mjs +1 -9
  67. package/editors/textEditor/textEditor.js +2 -11
  68. package/editors/textEditor/textEditor.mjs +2 -11
  69. package/focusManager.js +3 -5
  70. package/focusManager.mjs +3 -5
  71. package/helpers/array.js +7 -0
  72. package/helpers/array.mjs +7 -0
  73. package/helpers/mixed.js +2 -2
  74. package/helpers/mixed.mjs +2 -2
  75. package/helpers/number.js +12 -2
  76. package/helpers/number.mjs +12 -2
  77. package/package.json +3 -3
  78. package/pluginHooks.d.ts +1 -1
  79. package/pluginHooks.js +79 -2
  80. package/pluginHooks.mjs +79 -2
  81. package/plugins/autoColumnSize/autoColumnSize.js +7 -0
  82. package/plugins/autoColumnSize/autoColumnSize.mjs +7 -0
  83. package/plugins/autoRowSize/autoRowSize.js +2 -2
  84. package/plugins/autoRowSize/autoRowSize.mjs +2 -2
  85. package/plugins/autofill/autofill.js +1 -1
  86. package/plugins/autofill/autofill.mjs +1 -1
  87. package/plugins/base/base.d.ts +1 -1
  88. package/plugins/base/base.js +6 -2
  89. package/plugins/base/base.mjs +6 -2
  90. package/plugins/collapsibleColumns/collapsibleColumns.js +1 -1
  91. package/plugins/collapsibleColumns/collapsibleColumns.mjs +1 -1
  92. package/plugins/columnSorting/sortFunction/date.js +2 -46
  93. package/plugins/columnSorting/sortFunction/date.mjs +2 -45
  94. package/plugins/columnSorting/sortFunction/time.js +17 -0
  95. package/plugins/columnSorting/sortFunction/time.mjs +13 -0
  96. package/plugins/columnSorting/sortService/registry.js +4 -2
  97. package/plugins/columnSorting/sortService/registry.mjs +3 -1
  98. package/plugins/columnSorting/utils.js +64 -0
  99. package/plugins/columnSorting/utils.mjs +62 -0
  100. package/plugins/columnSummary/columnSummary.js +27 -10
  101. package/plugins/columnSummary/columnSummary.mjs +27 -10
  102. package/plugins/columnSummary/endpoints.js +15 -0
  103. package/plugins/columnSummary/endpoints.mjs +15 -0
  104. package/plugins/comments/comments.js +2 -8
  105. package/plugins/comments/comments.mjs +2 -8
  106. package/plugins/comments/contextMenuItem/addEditComment.js +0 -1
  107. package/plugins/comments/contextMenuItem/addEditComment.mjs +0 -1
  108. package/plugins/contextMenu/contextMenu.d.ts +1 -1
  109. package/plugins/copyPaste/copyPaste.js +9 -2
  110. package/plugins/copyPaste/copyPaste.mjs +9 -2
  111. package/plugins/copyPaste/pasteEvent.js +1 -0
  112. package/plugins/copyPaste/pasteEvent.mjs +1 -0
  113. package/plugins/filters/filters.js +1 -1
  114. package/plugins/filters/filters.mjs +1 -1
  115. package/plugins/filters/ui/multipleSelect.js +22 -14
  116. package/plugins/filters/ui/multipleSelect.mjs +22 -14
  117. package/plugins/filters/utils.js +7 -0
  118. package/plugins/filters/utils.mjs +7 -0
  119. package/plugins/formulas/formulas.d.ts +10 -0
  120. package/plugins/formulas/formulas.js +11 -2
  121. package/plugins/formulas/formulas.mjs +11 -2
  122. package/plugins/hiddenColumns/contextMenuItem/hideColumn.js +1 -1
  123. package/plugins/hiddenColumns/contextMenuItem/hideColumn.mjs +1 -1
  124. package/plugins/hiddenColumns/contextMenuItem/showColumn.js +1 -1
  125. package/plugins/hiddenColumns/contextMenuItem/showColumn.mjs +1 -1
  126. package/plugins/hiddenColumns/hiddenColumns.js +8 -1
  127. package/plugins/hiddenColumns/hiddenColumns.mjs +8 -1
  128. package/plugins/hiddenRows/contextMenuItem/hideRow.js +1 -1
  129. package/plugins/hiddenRows/contextMenuItem/hideRow.mjs +1 -1
  130. package/plugins/hiddenRows/contextMenuItem/showRow.js +1 -1
  131. package/plugins/hiddenRows/contextMenuItem/showRow.mjs +1 -1
  132. package/plugins/hiddenRows/hiddenRows.js +7 -0
  133. package/plugins/hiddenRows/hiddenRows.mjs +7 -0
  134. package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.js +1 -1
  135. package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.mjs +1 -1
  136. package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.js +1 -1
  137. package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.mjs +1 -1
  138. package/plugins/manualColumnMove/manualColumnMove.js +1 -1
  139. package/plugins/manualColumnMove/manualColumnMove.mjs +1 -1
  140. package/plugins/manualColumnResize/manualColumnResize.js +3 -3
  141. package/plugins/manualColumnResize/manualColumnResize.mjs +3 -3
  142. package/plugins/manualRowMove/manualRowMove.js +1 -1
  143. package/plugins/manualRowMove/manualRowMove.mjs +1 -1
  144. package/plugins/manualRowResize/manualRowResize.d.ts +1 -0
  145. package/plugins/manualRowResize/manualRowResize.js +11 -2
  146. package/plugins/manualRowResize/manualRowResize.mjs +11 -2
  147. package/plugins/mergeCells/cellsCollection.js +7 -0
  148. package/plugins/mergeCells/cellsCollection.mjs +7 -0
  149. package/plugins/mergeCells/mergeCells.js +7 -0
  150. package/plugins/mergeCells/mergeCells.mjs +7 -0
  151. package/plugins/nestedHeaders/stateManager/nodeModifiers/collapse.js +7 -0
  152. package/plugins/nestedHeaders/stateManager/nodeModifiers/collapse.mjs +7 -0
  153. package/plugins/nestedHeaders/stateManager/nodeModifiers/expand.js +7 -0
  154. package/plugins/nestedHeaders/stateManager/nodeModifiers/expand.mjs +7 -0
  155. package/plugins/nestedRows/nestedRows.js +7 -0
  156. package/plugins/nestedRows/nestedRows.mjs +7 -0
  157. package/plugins/trimRows/trimRows.js +7 -0
  158. package/plugins/trimRows/trimRows.mjs +7 -0
  159. package/selection/selection.js +163 -4
  160. package/selection/selection.mjs +163 -4
  161. package/selection/utils.js +7 -0
  162. package/selection/utils.mjs +7 -0
  163. package/settings.d.ts +1 -0
  164. package/shortcutContexts/commands/editor/closeAndSave.js +2 -3
  165. package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -3
  166. package/shortcutContexts/commands/editor/closeAndSaveByArrowKeys.js +27 -0
  167. package/shortcutContexts/commands/editor/closeAndSaveByArrowKeys.mjs +24 -0
  168. package/shortcutContexts/commands/editor/closeAndSaveByEnter.js +11 -0
  169. package/shortcutContexts/commands/editor/closeAndSaveByEnter.mjs +8 -0
  170. package/shortcutContexts/commands/editor/index.js +3 -1
  171. package/shortcutContexts/commands/editor/index.mjs +3 -1
  172. package/shortcutContexts/editor.js +9 -1
  173. package/shortcutContexts/editor.mjs +9 -1
  174. package/shortcutContexts/index.js +1 -1
  175. package/shortcutContexts/index.mjs +1 -1
  176. package/shortcuts/keyObserver.js +7 -0
  177. package/shortcuts/keyObserver.mjs +7 -0
  178. package/shortcuts/utils.js +7 -0
  179. package/shortcuts/utils.mjs +7 -0
  180. package/tableView.js +1 -4
  181. package/tableView.mjs +1 -4
  182. package/translations/changesObservable/observable.js +7 -0
  183. package/translations/changesObservable/observable.mjs +7 -0
  184. package/translations/indexMapper.js +7 -0
  185. package/translations/indexMapper.mjs +8 -1
  186. package/utils/dataStructures/uniqueSet.js +7 -0
  187. package/utils/dataStructures/uniqueSet.mjs +7 -0
  188. package/utils/ghostTable.js +0 -4
  189. package/utils/ghostTable.mjs +0 -4
  190. package/utils/paginator.js +7 -0
  191. package/utils/paginator.mjs +7 -0
  192. package/validators/dateValidator/dateValidator.js +1 -3
  193. package/validators/dateValidator/dateValidator.mjs +1 -3
  194. package/validators/timeValidator/timeValidator.js +1 -3
  195. package/validators/timeValidator/timeValidator.mjs +1 -3
package/core.mjs CHANGED
@@ -1,5 +1,12 @@
1
1
  import "core-js/modules/es.error.cause.js";
2
2
  import "core-js/modules/es.array.push.js";
3
+ import "core-js/modules/esnext.set.difference.v2.js";
4
+ import "core-js/modules/esnext.set.intersection.v2.js";
5
+ import "core-js/modules/esnext.set.is-disjoint-from.v2.js";
6
+ import "core-js/modules/esnext.set.is-subset-of.v2.js";
7
+ import "core-js/modules/esnext.set.is-superset-of.v2.js";
8
+ import "core-js/modules/esnext.set.symmetric-difference.v2.js";
9
+ import "core-js/modules/esnext.set.union.v2.js";
3
10
  import "core-js/modules/web.immediate.js";
4
11
  import { addClass, empty, observeVisibilityChangeOnce, removeClass } from "./helpers/dom/element.mjs";
5
12
  import { isFunction } from "./helpers/function.mjs";
@@ -325,7 +332,7 @@ export default function Core(rootElement, userSettings) {
325
332
  hiddenIndexesChanged
326
333
  } = _ref;
327
334
  if (hiddenIndexesChanged) {
328
- this.selection.refresh();
335
+ this.selection.commit();
329
336
  }
330
337
  };
331
338
  this.columnIndexMapper.addLocalHook('cacheUpdated', onIndexMapperCacheUpdate);
@@ -360,7 +367,11 @@ export default function Core(rootElement, userSettings) {
360
367
  } else {
361
368
  removeClass(this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
362
369
  }
363
- this._refreshBorders(null);
370
+ if (selection.getSelectionSource() !== 'shift') {
371
+ editorManager.closeEditor(null);
372
+ }
373
+ instance.view.render();
374
+ editorManager.prepareEditor();
364
375
  });
365
376
  this.selection.addLocalHook('beforeSetFocus', cellCoords => {
366
377
  this.runHooks('beforeSelectionFocusSet', cellCoords.row, cellCoords.col);
@@ -371,7 +382,9 @@ export default function Core(rootElement, userSettings) {
371
382
  if (!preventScrolling.isTouched() || preventScrolling.isTouched() && !preventScrolling.value) {
372
383
  viewportScroller.scrollTo(cellCoords);
373
384
  }
374
- this._refreshBorders(null);
385
+ editorManager.closeEditor();
386
+ instance.view.render();
387
+ editorManager.prepareEditor();
375
388
  });
376
389
  this.selection.addLocalHook('afterSelectionFinished', cellRanges => {
377
390
  const selectionLayerLevel = cellRanges.length - 1;
@@ -389,8 +402,8 @@ export default function Core(rootElement, userSettings) {
389
402
  }
390
403
  });
391
404
  this.selection.addLocalHook('afterDeselect', () => {
392
- editorManager.destroyEditor();
393
- this._refreshBorders();
405
+ editorManager.closeEditor();
406
+ instance.view.render();
394
407
  removeClass(this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
395
408
  this.runHooks('afterDeselect');
396
409
  });
@@ -545,39 +558,7 @@ export default function Core(rootElement, userSettings) {
545
558
  source,
546
559
  mode: insertRowMode
547
560
  });
548
- if (rowDelta) {
549
- const currentSelectedRange = selection.selectedRange.current();
550
- const currentFromRange = currentSelectedRange === null || currentSelectedRange === void 0 ? void 0 : currentSelectedRange.from;
551
- const currentFromRow = currentFromRange === null || currentFromRange === void 0 ? void 0 : currentFromRange.row;
552
- const startVisualRowIndex = instance.toVisualRow(startRowPhysicalIndex);
553
- if (selection.isSelectedByCorner()) {
554
- selection.selectAll(true, true, {
555
- disableHeadersHighlight: true
556
- });
557
- } else if (isDefined(currentFromRow) && currentFromRow >= startVisualRowIndex) {
558
- // Moving the selection (if it exists) downward – it should be applied to the "old" row.
559
- // TODO: The logic here should be handled by selection module.
560
- const {
561
- row: currentToRow,
562
- col: currentToColumn
563
- } = currentSelectedRange.to;
564
- let currentFromColumn = currentFromRange.col;
565
-
566
- // Workaround: headers are not stored inside selection.
567
- if (selection.isSelectedByRowHeader()) {
568
- currentFromColumn = -1;
569
- }
570
-
571
- // Remove from the stack the last added selection as that selection below will be
572
- // replaced by new transformed selection.
573
- selection.getSelectedRange().pop();
574
- // I can't use transforms as they don't work in negative indexes.
575
- selection.setRangeStartOnly(instance._createCellCoords(currentFromRow + rowDelta, currentFromColumn), true);
576
- selection.setRangeEnd(instance._createCellCoords(currentToRow + rowDelta, currentToColumn)); // will call render() internally
577
- } else {
578
- instance._refreshBorders(); // it will call render and prepare methods
579
- }
580
- }
561
+ selection.shiftRows(instance.toVisualRow(startRowPhysicalIndex), rowDelta);
581
562
  break;
582
563
  case 'insert_col_start':
583
564
  case 'insert_col_end':
@@ -600,38 +581,7 @@ export default function Core(rootElement, userSettings) {
600
581
  spliceArray.length += colDelta; // inserts empty (undefined) elements at the end of an array
601
582
  Array.prototype.splice.apply(tableMeta.colHeaders, spliceArray); // inserts empty (undefined) elements into the colHeader array
602
583
  }
603
- const currentSelectedRange = selection.selectedRange.current();
604
- const currentFromRange = currentSelectedRange === null || currentSelectedRange === void 0 ? void 0 : currentSelectedRange.from;
605
- const currentFromColumn = currentFromRange === null || currentFromRange === void 0 ? void 0 : currentFromRange.col;
606
- const startVisualColumnIndex = instance.toVisualColumn(startColumnPhysicalIndex);
607
- if (selection.isSelectedByCorner()) {
608
- selection.selectAll(true, true, {
609
- disableHeadersHighlight: true
610
- });
611
- } else if (isDefined(currentFromColumn) && currentFromColumn >= startVisualColumnIndex) {
612
- // Moving the selection (if it exists) rightward – it should be applied to the "old" column.
613
- // TODO: The logic here should be handled by selection module.
614
- const {
615
- row: currentToRow,
616
- col: currentToColumn
617
- } = currentSelectedRange.to;
618
- let currentFromRow = currentFromRange.row;
619
-
620
- // Workaround: headers are not stored inside selection.
621
- if (selection.isSelectedByColumnHeader()) {
622
- currentFromRow = -1;
623
- }
624
-
625
- // Remove from the stack the last added selection as that selection below will be
626
- // replaced by new transformed selection.
627
- selection.getSelectedRange().pop();
628
-
629
- // I can't use transforms as they don't work in negative indexes.
630
- selection.setRangeStartOnly(instance._createCellCoords(currentFromRow, currentFromColumn + colDelta), true);
631
- selection.setRangeEnd(instance._createCellCoords(currentToRow, currentToColumn + colDelta)); // will call render() internally
632
- } else {
633
- instance._refreshBorders(); // it will call render and prepare methods
634
- }
584
+ selection.shiftColumns(instance.toVisualColumn(startColumnPhysicalIndex), colDelta);
635
585
  }
636
586
  break;
637
587
  case 'remove_row':
@@ -656,7 +606,22 @@ export default function Core(rootElement, userSettings) {
656
606
  if (!wasRemoved) {
657
607
  return;
658
608
  }
609
+ if (selection.isSelected()) {
610
+ const {
611
+ row
612
+ } = instance.getSelectedRangeLast().highlight;
613
+ if (row >= groupIndex && row <= groupIndex + groupAmount - 1) {
614
+ editorManager.closeEditor(true);
615
+ }
616
+ }
659
617
  const totalRows = instance.countRows();
618
+ if (totalRows === 0) {
619
+ selection.deselect();
620
+ } else if (source === 'ContextMenu.removeRow') {
621
+ selection.refresh();
622
+ } else {
623
+ selection.shiftRows(groupIndex, -groupAmount);
624
+ }
660
625
  const fixedRowsTop = tableMeta.fixedRowsTop;
661
626
  if (fixedRowsTop >= calcIndex + 1) {
662
627
  tableMeta.fixedRowsTop -= Math.min(groupAmount, fixedRowsTop - calcIndex);
@@ -673,8 +638,6 @@ export default function Core(rootElement, userSettings) {
673
638
  } else {
674
639
  removeRow([[index, amount]]);
675
640
  }
676
- grid.adjustRowsAndCols();
677
- instance._refreshBorders(); // it will call render and prepare methods
678
641
  break;
679
642
  case 'remove_col':
680
643
  const removeCol = indexes => {
@@ -699,6 +662,22 @@ export default function Core(rootElement, userSettings) {
699
662
  if (!wasRemoved) {
700
663
  return;
701
664
  }
665
+ if (selection.isSelected()) {
666
+ const {
667
+ col
668
+ } = instance.getSelectedRangeLast().highlight;
669
+ if (col >= groupIndex && col <= groupIndex + groupAmount - 1) {
670
+ editorManager.closeEditor(true);
671
+ }
672
+ }
673
+ const totalColumns = instance.countCols();
674
+ if (totalColumns === 0) {
675
+ selection.deselect();
676
+ } else if (source === 'ContextMenu.removeColumn') {
677
+ selection.refresh();
678
+ } else {
679
+ selection.shiftColumns(groupIndex, -groupAmount);
680
+ }
702
681
  const fixedColumnsStart = tableMeta.fixedColumnsStart;
703
682
  if (fixedColumnsStart >= calcIndex + 1) {
704
683
  tableMeta.fixedColumnsStart -= Math.min(groupAmount, fixedColumnsStart - calcIndex);
@@ -717,13 +696,11 @@ export default function Core(rootElement, userSettings) {
717
696
  } else {
718
697
  removeCol([[index, amount]]);
719
698
  }
720
- grid.adjustRowsAndCols();
721
- instance._refreshBorders(); // it will call render and prepare methods
722
-
723
699
  break;
724
700
  default:
725
701
  throw new Error(`There is no such action "${action}"`);
726
702
  }
703
+ instance.view.render();
727
704
  if (!keepEmptyRows) {
728
705
  grid.adjustRowsAndCols(); // makes sure that we did not add rows that will be removed in next refresh
729
706
  }
@@ -738,9 +715,6 @@ export default function Core(rootElement, userSettings) {
738
715
  const minSpareRows = tableMeta.minSpareRows;
739
716
  const minCols = tableMeta.minCols;
740
717
  const minSpareCols = tableMeta.minSpareCols;
741
- if (instance.countRows() === 0 && instance.countCols() === 0) {
742
- selection.deselect();
743
- }
744
718
  if (minRows) {
745
719
  // should I add empty rows to data source to meet minRows?
746
720
  const nrOfRows = instance.countRows();
@@ -799,55 +773,6 @@ export default function Core(rootElement, userSettings) {
799
773
  });
800
774
  }
801
775
  }
802
- if (selection.isSelected()) {
803
- const rowCount = instance.countRows();
804
- const colCount = instance.countCols();
805
- arrayEach(selection.selectedRange, range => {
806
- let selectionChanged = false;
807
- let fromRow = range.from.row;
808
- let fromCol = range.from.col;
809
- let toRow = range.to.row;
810
- let toCol = range.to.col;
811
-
812
- // if selection is outside, move selection to last row
813
- if (fromRow > rowCount - 1) {
814
- fromRow = rowCount - 1;
815
- selectionChanged = true;
816
- if (toRow > fromRow) {
817
- toRow = fromRow;
818
- }
819
- } else if (toRow > rowCount - 1) {
820
- toRow = rowCount - 1;
821
- selectionChanged = true;
822
- if (fromRow > toRow) {
823
- fromRow = toRow;
824
- }
825
- }
826
- // if selection is outside, move selection to last row
827
- if (fromCol > colCount - 1) {
828
- fromCol = colCount - 1;
829
- selectionChanged = true;
830
- if (toCol > fromCol) {
831
- toCol = fromCol;
832
- }
833
- } else if (toCol > colCount - 1) {
834
- toCol = colCount - 1;
835
- selectionChanged = true;
836
- if (fromCol > toCol) {
837
- fromCol = toCol;
838
- }
839
- }
840
- if (selectionChanged) {
841
- if (fromCol < 0) {
842
- instance.selectRows(fromRow, toRow, fromCol);
843
- } else if (fromRow < 0) {
844
- instance.selectColumns(fromCol, toCol, fromRow);
845
- } else {
846
- instance.selectCell(fromRow, fromCol, toRow, toCol);
847
- }
848
- }
849
- });
850
- }
851
776
  if (instance.view) {
852
777
  instance.view.adjustElementsSize();
853
778
  }
@@ -1192,8 +1117,18 @@ export default function Core(rootElement, userSettings) {
1192
1117
  };
1193
1118
  for (let i = changes.length - 1; i >= 0; i--) {
1194
1119
  const [row, prop,, newValue] = changes[i];
1195
- const col = datamap.propToCol(prop);
1196
- const cellProperties = instance.getCellMeta(row, col);
1120
+ const visualCol = datamap.propToCol(prop);
1121
+ let cellProperties;
1122
+ if (Number.isInteger(visualCol)) {
1123
+ cellProperties = instance.getCellMeta(row, visualCol);
1124
+ } else {
1125
+ // If there's no requested visual column, we can use the table meta as the cell properties when retrieving
1126
+ // the cell validator.
1127
+ cellProperties = {
1128
+ ...Object.getPrototypeOf(tableMeta),
1129
+ ...tableMeta
1130
+ };
1131
+ }
1197
1132
  if (cellProperties.type === 'numeric' && typeof newValue === 'string' && isNumericLike(newValue)) {
1198
1133
  changes[i][3] = getParsedNumber(newValue);
1199
1134
  }
@@ -1284,9 +1219,9 @@ export default function Core(rootElement, userSettings) {
1284
1219
  instance.forceFullRender = true; // used when data was changed
1285
1220
  grid.adjustRowsAndCols();
1286
1221
  instance.runHooks('beforeChangeRender', changes, source);
1287
- editorManager.lockEditor();
1288
- instance._refreshBorders(null);
1289
- editorManager.unlockEditor();
1222
+ editorManager.closeEditor();
1223
+ instance.view.render();
1224
+ editorManager.prepareEditor();
1290
1225
  instance.view.adjustElementsSize();
1291
1226
  instance.runHooks('afterChange', changes, source || 'edit');
1292
1227
  const activeEditor = instance.getActiveEditor();
@@ -1497,6 +1432,9 @@ export default function Core(rootElement, userSettings) {
1497
1432
  for (i = 0, ilen = input.length; i < ilen; i++) {
1498
1433
  changes.push([input[i][0], input[i][1], dataSource.getAtCell(this.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
1499
1434
  }
1435
+
1436
+ // TODO: I don't think `prop` should be used as `changeSource` here, but removing it would be a breaking change.
1437
+ // We should remove it with the next major release.
1500
1438
  if (!changeSource && typeof row === 'object') {
1501
1439
  changeSource = prop;
1502
1440
  }
@@ -1563,7 +1501,11 @@ export default function Core(rootElement, userSettings) {
1563
1501
  this.destroyEditor = function () {
1564
1502
  let revertOriginal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1565
1503
  let prepareEditorIfNeeded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1566
- instance._refreshBorders(revertOriginal, prepareEditorIfNeeded);
1504
+ editorManager.closeEditor(revertOriginal);
1505
+ instance.view.render();
1506
+ if (prepareEditorIfNeeded && selection.isSelected()) {
1507
+ editorManager.prepareEditor();
1508
+ }
1567
1509
  };
1568
1510
 
1569
1511
  /**
@@ -1826,7 +1768,7 @@ export default function Core(rootElement, userSettings) {
1826
1768
  if (this.renderCall) {
1827
1769
  this.render();
1828
1770
  } else {
1829
- this._refreshBorders(null);
1771
+ instance.view.render();
1830
1772
  }
1831
1773
  }
1832
1774
  };
@@ -1847,9 +1789,7 @@ export default function Core(rootElement, userSettings) {
1847
1789
  this.forceFullRender = true; // used when data was changed
1848
1790
 
1849
1791
  if (!this.isRenderSuspended()) {
1850
- editorManager.lockEditor();
1851
- this._refreshBorders(null);
1852
- editorManager.unlockEditor();
1792
+ instance.view.render();
1853
1793
  }
1854
1794
  }
1855
1795
  };
@@ -2116,6 +2056,7 @@ export default function Core(rootElement, userSettings) {
2116
2056
  instance.columnIndexMapper.fitToLength(this.getInitialColumnCount());
2117
2057
  instance.rowIndexMapper.fitToLength(this.countSourceRows());
2118
2058
  grid.adjustRowsAndCols();
2059
+ selection.refresh();
2119
2060
  }, {
2120
2061
  hotInstance: instance,
2121
2062
  dataMap: datamap,
@@ -2156,6 +2097,7 @@ export default function Core(rootElement, userSettings) {
2156
2097
  metaManager.clearCellsCache();
2157
2098
  instance.initIndexMappers();
2158
2099
  grid.adjustRowsAndCols();
2100
+ selection.refresh();
2159
2101
  if (firstRun) {
2160
2102
  firstRun = [null, 'loadData'];
2161
2103
  }
@@ -2443,10 +2385,8 @@ export default function Core(rootElement, userSettings) {
2443
2385
  grid.adjustRowsAndCols();
2444
2386
  if (instance.view && !firstRun) {
2445
2387
  instance.forceFullRender = true; // used when data was changed
2446
- editorManager.lockEditor();
2447
- instance._refreshBorders(null);
2388
+ instance.view.render();
2448
2389
  instance.view._wt.wtOverlays.adjustElementsSize();
2449
- editorManager.unlockEditor();
2450
2390
  }
2451
2391
  if (!init && instance.view && (currentHeight === '' || height === '' || height === undefined) && currentHeight !== height) {
2452
2392
  instance.view._wt.wtOverlays.updateMainScrollableElements();
@@ -2598,7 +2538,7 @@ export default function Core(rootElement, userSettings) {
2598
2538
  }
2599
2539
  renderableRowIndex = this.rowIndexMapper.getRenderableFromVisualIndex(row);
2600
2540
  }
2601
- if (renderableRowIndex === null || renderableColumnIndex === null) {
2541
+ if (renderableRowIndex === null || renderableColumnIndex === null || renderableRowIndex === undefined || renderableColumnIndex === undefined) {
2602
2542
  return null;
2603
2543
  }
2604
2544
  return instance.view.getCellAtCoords(instance._createCellCoords(renderableRowIndex, renderableColumnIndex), topmost);
@@ -4344,13 +4284,17 @@ export default function Core(rootElement, userSettings) {
4344
4284
  * @see Hooks#add
4345
4285
  * @param {string} key Hook name (see {@link Hooks}).
4346
4286
  * @param {Function|Array} callback Function or array of functions.
4287
+ * @param {number} [orderIndex] Order index of the callback.
4288
+ * 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.
4289
+ * 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.
4290
+ * If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
4347
4291
  * @example
4348
4292
  * ```js
4349
4293
  * hot.addHook('beforeInit', myCallback);
4350
4294
  * ```
4351
4295
  */
4352
- this.addHook = function (key, callback) {
4353
- Hooks.getSingleton().add(key, callback, instance);
4296
+ this.addHook = function (key, callback, orderIndex) {
4297
+ Hooks.getSingleton().add(key, callback, instance, orderIndex);
4354
4298
  };
4355
4299
 
4356
4300
  /**
@@ -4381,13 +4325,17 @@ export default function Core(rootElement, userSettings) {
4381
4325
  * @see Hooks#once
4382
4326
  * @param {string} key Hook name (see {@link Hooks}).
4383
4327
  * @param {Function|Array} callback Function or array of functions.
4328
+ * @param {number} [orderIndex] Order index of the callback.
4329
+ * 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.
4330
+ * 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.
4331
+ * If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
4384
4332
  * @example
4385
4333
  * ```js
4386
4334
  * hot.addHookOnce('beforeInit', myCallback);
4387
4335
  * ```
4388
4336
  */
4389
- this.addHookOnce = function (key, callback) {
4390
- Hooks.getSingleton().once(key, callback, instance);
4337
+ this.addHookOnce = function (key, callback, orderIndex) {
4338
+ Hooks.getSingleton().once(key, callback, instance, orderIndex);
4391
4339
  };
4392
4340
 
4393
4341
  /**
@@ -4524,23 +4472,6 @@ export default function Core(rootElement, userSettings) {
4524
4472
  });
4525
4473
  };
4526
4474
 
4527
- /**
4528
- * Refresh selection borders. This is temporary method relic after selection rewrite.
4529
- *
4530
- * @private
4531
- * @param {boolean} [revertOriginal=false] If `true`, the previous value will be restored. Otherwise, the edited value will be saved.
4532
- * @param {boolean} [prepareEditorIfNeeded=true] If `true` the editor under the selected cell will be prepared to open.
4533
- */
4534
- this._refreshBorders = function () {
4535
- let revertOriginal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4536
- let prepareEditorIfNeeded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
4537
- editorManager.destroyEditor(revertOriginal);
4538
- instance.view.render();
4539
- if (prepareEditorIfNeeded && selection.isSelected()) {
4540
- editorManager.prepareEditor();
4541
- }
4542
- };
4543
-
4544
4475
  /**
4545
4476
  * Gets the instance of the EditorManager.
4546
4477
  *
@@ -671,17 +671,20 @@ class DataMap {
671
671
  dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
672
672
  //
673
673
 
674
+ const {
675
+ dataDotNotation
676
+ } = this.hot.getSettings();
674
677
  let value = null;
675
678
 
676
679
  // try to get value under property `prop` (includes dot)
677
680
  if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
678
681
  value = dataRow[prop];
679
- } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
680
- const sliced = prop.split('.');
682
+ } else if (dataDotNotation && typeof prop === 'string' && prop.indexOf('.') > -1) {
681
683
  let out = dataRow;
682
684
  if (!out) {
683
685
  return null;
684
686
  }
687
+ const sliced = prop.split('.');
685
688
  for (let i = 0, ilen = sliced.length; i < ilen; i++) {
686
689
  out = out[sliced[i]];
687
690
  if (typeof out === 'undefined') {
@@ -739,15 +742,18 @@ class DataMap {
739
742
  newValue = valueHolder.value;
740
743
  }
741
744
  }
745
+ const {
746
+ dataDotNotation
747
+ } = this.hot.getSettings();
742
748
 
743
749
  // try to set value under property `prop` (includes dot)
744
750
  if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
745
751
  dataRow[prop] = newValue;
746
- } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
747
- const sliced = prop.split('.');
752
+ } else if (dataDotNotation && typeof prop === 'string' && prop.indexOf('.') > -1) {
748
753
  let out = dataRow;
749
754
  let i = 0;
750
755
  let ilen;
756
+ const sliced = prop.split('.');
751
757
  for (i = 0, ilen = sliced.length - 1; i < ilen; i++) {
752
758
  if (typeof out[sliced[i]] === 'undefined') {
753
759
  out[sliced[i]] = {};
@@ -667,17 +667,20 @@ class DataMap {
667
667
  dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
668
668
  //
669
669
 
670
+ const {
671
+ dataDotNotation
672
+ } = this.hot.getSettings();
670
673
  let value = null;
671
674
 
672
675
  // try to get value under property `prop` (includes dot)
673
676
  if (dataRow && dataRow.hasOwnProperty && hasOwnProperty(dataRow, prop)) {
674
677
  value = dataRow[prop];
675
- } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
676
- const sliced = prop.split('.');
678
+ } else if (dataDotNotation && typeof prop === 'string' && prop.indexOf('.') > -1) {
677
679
  let out = dataRow;
678
680
  if (!out) {
679
681
  return null;
680
682
  }
683
+ const sliced = prop.split('.');
681
684
  for (let i = 0, ilen = sliced.length; i < ilen; i++) {
682
685
  out = out[sliced[i]];
683
686
  if (typeof out === 'undefined') {
@@ -735,15 +738,18 @@ class DataMap {
735
738
  newValue = valueHolder.value;
736
739
  }
737
740
  }
741
+ const {
742
+ dataDotNotation
743
+ } = this.hot.getSettings();
738
744
 
739
745
  // try to set value under property `prop` (includes dot)
740
746
  if (dataRow && dataRow.hasOwnProperty && hasOwnProperty(dataRow, prop)) {
741
747
  dataRow[prop] = newValue;
742
- } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
743
- const sliced = prop.split('.');
748
+ } else if (dataDotNotation && typeof prop === 'string' && prop.indexOf('.') > -1) {
744
749
  let out = dataRow;
745
750
  let i = 0;
746
751
  let ilen;
752
+ const sliced = prop.split('.');
747
753
  for (i = 0, ilen = sliced.length - 1; i < ilen; i++) {
748
754
  if (typeof out[sliced[i]] === 'undefined') {
749
755
  out[sliced[i]] = {};
@@ -110,6 +110,9 @@ class DataSource {
110
110
  getAtRow(row, startColumn, endColumn) {
111
111
  let toArray = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
112
112
  const getAllProps = startColumn === undefined && endColumn === undefined;
113
+ const {
114
+ dataDotNotation
115
+ } = this.hot.getSettings();
113
116
  let dataRow = null;
114
117
  let newDataRow = null;
115
118
  dataRow = this.modifyRowData(row);
@@ -140,14 +143,21 @@ class DataSource {
140
143
  const cellValue = this.getAtPhysicalCell(row, prop, dataRow);
141
144
  if (toArray) {
142
145
  newDataRow.push(cellValue);
143
- } else {
146
+ } else if (dataDotNotation) {
144
147
  (0, _object.setProperty)(newDataRow, prop, cellValue);
148
+ } else {
149
+ newDataRow[prop] = cellValue;
145
150
  }
146
151
  }
147
152
  });
148
153
  } else {
149
154
  (0, _object.objectEach)(dataRow, (value, prop) => {
150
- (0, _object.setProperty)(newDataRow, prop, this.getAtPhysicalCell(row, prop, dataRow));
155
+ const cellValue = this.getAtPhysicalCell(row, prop, dataRow);
156
+ if (dataDotNotation) {
157
+ (0, _object.setProperty)(newDataRow, prop, cellValue);
158
+ } else {
159
+ newDataRow[prop] = cellValue;
160
+ }
151
161
  });
152
162
  }
153
163
  }
@@ -194,7 +204,10 @@ class DataSource {
194
204
  let result = null;
195
205
  if (dataRow) {
196
206
  if (typeof column === 'string') {
197
- result = (0, _object.getProperty)(dataRow, column);
207
+ const {
208
+ dataDotNotation
209
+ } = this.hot.getSettings();
210
+ result = dataDotNotation ? (0, _object.getProperty)(dataRow, column) : dataRow[column];
198
211
  } else if (typeof column === 'function') {
199
212
  result = column(dataRow);
200
213
  } else {
@@ -107,6 +107,9 @@ class DataSource {
107
107
  getAtRow(row, startColumn, endColumn) {
108
108
  let toArray = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
109
109
  const getAllProps = startColumn === undefined && endColumn === undefined;
110
+ const {
111
+ dataDotNotation
112
+ } = this.hot.getSettings();
110
113
  let dataRow = null;
111
114
  let newDataRow = null;
112
115
  dataRow = this.modifyRowData(row);
@@ -137,14 +140,21 @@ class DataSource {
137
140
  const cellValue = this.getAtPhysicalCell(row, prop, dataRow);
138
141
  if (toArray) {
139
142
  newDataRow.push(cellValue);
140
- } else {
143
+ } else if (dataDotNotation) {
141
144
  setProperty(newDataRow, prop, cellValue);
145
+ } else {
146
+ newDataRow[prop] = cellValue;
142
147
  }
143
148
  }
144
149
  });
145
150
  } else {
146
151
  objectEach(dataRow, (value, prop) => {
147
- setProperty(newDataRow, prop, this.getAtPhysicalCell(row, prop, dataRow));
152
+ const cellValue = this.getAtPhysicalCell(row, prop, dataRow);
153
+ if (dataDotNotation) {
154
+ setProperty(newDataRow, prop, cellValue);
155
+ } else {
156
+ newDataRow[prop] = cellValue;
157
+ }
148
158
  });
149
159
  }
150
160
  }
@@ -191,7 +201,10 @@ class DataSource {
191
201
  let result = null;
192
202
  if (dataRow) {
193
203
  if (typeof column === 'string') {
194
- result = getProperty(dataRow, column);
204
+ const {
205
+ dataDotNotation
206
+ } = this.hot.getSettings();
207
+ result = dataDotNotation ? getProperty(dataRow, column) : dataRow[column];
195
208
  } else if (typeof column === 'function') {
196
209
  result = column(dataRow);
197
210
  } else {
@@ -3,6 +3,13 @@
3
3
  exports.__esModule = true;
4
4
  require("core-js/modules/es.error.cause.js");
5
5
  require("core-js/modules/es.array.push.js");
6
+ require("core-js/modules/esnext.set.difference.v2.js");
7
+ require("core-js/modules/esnext.set.intersection.v2.js");
8
+ require("core-js/modules/esnext.set.is-disjoint-from.v2.js");
9
+ require("core-js/modules/esnext.set.is-subset-of.v2.js");
10
+ require("core-js/modules/esnext.set.is-superset-of.v2.js");
11
+ require("core-js/modules/esnext.set.symmetric-difference.v2.js");
12
+ require("core-js/modules/esnext.set.union.v2.js");
6
13
  var _array = require("../../helpers/array");
7
14
  var _utils = require("./utils");
8
15
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -1,5 +1,12 @@
1
1
  import "core-js/modules/es.error.cause.js";
2
2
  import "core-js/modules/es.array.push.js";
3
+ import "core-js/modules/esnext.set.difference.v2.js";
4
+ import "core-js/modules/esnext.set.intersection.v2.js";
5
+ import "core-js/modules/esnext.set.is-disjoint-from.v2.js";
6
+ import "core-js/modules/esnext.set.is-subset-of.v2.js";
7
+ import "core-js/modules/esnext.set.is-superset-of.v2.js";
8
+ import "core-js/modules/esnext.set.symmetric-difference.v2.js";
9
+ import "core-js/modules/esnext.set.union.v2.js";
3
10
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
12
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }