handsontable 0.0.0-next-08765b9-20230714 → 0.0.0-next-6b996e8-20230714
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/{selection/border/border.js → border.js} +12 -7
- package/3rdparty/walkontable/src/{selection/border/border.mjs → border.mjs} +12 -7
- package/3rdparty/walkontable/src/cell/coords.d.ts +1 -6
- package/3rdparty/walkontable/src/cell/coords.js +11 -50
- package/3rdparty/walkontable/src/cell/coords.mjs +11 -50
- package/3rdparty/walkontable/src/cell/range.d.ts +2 -9
- package/3rdparty/walkontable/src/cell/range.js +7 -38
- package/3rdparty/walkontable/src/cell/range.mjs +7 -38
- package/3rdparty/walkontable/src/core/_base.js +3 -9
- package/3rdparty/walkontable/src/core/_base.mjs +3 -9
- package/3rdparty/walkontable/src/core/clone.js +2 -2
- package/3rdparty/walkontable/src/core/clone.mjs +2 -2
- package/3rdparty/walkontable/src/core/core.js +2 -3
- package/3rdparty/walkontable/src/core/core.mjs +2 -3
- package/3rdparty/walkontable/src/event.js +7 -7
- package/3rdparty/walkontable/src/event.mjs +7 -7
- package/3rdparty/walkontable/src/facade/core.js +2 -2
- package/3rdparty/walkontable/src/facade/core.mjs +2 -2
- package/3rdparty/walkontable/src/index.js +2 -10
- package/3rdparty/walkontable/src/index.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/_base.js +1 -1
- package/3rdparty/walkontable/src/overlay/_base.mjs +1 -1
- package/3rdparty/walkontable/src/overlay/inlineStart.js +6 -2
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +6 -2
- package/3rdparty/walkontable/src/overlay/top.js +6 -2
- package/3rdparty/walkontable/src/overlay/top.mjs +6 -2
- package/3rdparty/walkontable/src/selection.js +295 -0
- package/3rdparty/walkontable/src/selection.mjs +290 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +0 -9
- package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +0 -9
- package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +0 -9
- package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +0 -9
- package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +0 -9
- package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +0 -9
- package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +0 -9
- package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +0 -9
- package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +0 -9
- package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +0 -9
- package/3rdparty/walkontable/src/table.js +78 -6
- package/3rdparty/walkontable/src/table.mjs +79 -7
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/common.d.ts +1 -1
- package/core.d.ts +3 -6
- package/core.js +290 -173
- package/core.mjs +290 -173
- package/dataMap/metaManager/metaSchema.js +0 -41
- package/dataMap/metaManager/metaSchema.mjs +0 -41
- package/dist/handsontable.css +3 -19
- package/dist/handsontable.full.css +3 -19
- package/dist/handsontable.full.js +5369 -8671
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +25 -25
- package/dist/handsontable.js +8117 -11419
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +19 -19
- package/editorManager.js +75 -11
- package/editorManager.mjs +74 -11
- package/editors/textEditor/textEditor.js +11 -3
- package/editors/textEditor/textEditor.mjs +12 -4
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/helpers/number.d.ts +0 -1
- package/helpers/number.js +0 -18
- package/helpers/number.mjs +0 -17
- package/package.json +1 -1
- package/pluginHooks.d.ts +1 -7
- package/pluginHooks.js +1 -106
- package/pluginHooks.mjs +1 -106
- package/plugins/collapsibleColumns/collapsibleColumns.js +4 -58
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +4 -58
- package/plugins/columnSorting/columnSorting.js +0 -38
- package/plugins/columnSorting/columnSorting.mjs +2 -38
- package/plugins/columnSorting/index.js +1 -3
- package/plugins/columnSorting/index.mjs +1 -1
- package/plugins/comments/commentEditor.js +0 -1
- package/plugins/comments/commentEditor.mjs +0 -1
- package/plugins/comments/comments.js +189 -251
- package/plugins/comments/comments.mjs +190 -250
- package/plugins/contextMenu/contextMenu.d.ts +1 -1
- package/plugins/contextMenu/contextMenu.js +30 -72
- package/plugins/contextMenu/contextMenu.mjs +31 -73
- package/plugins/contextMenu/predefinedItems/alignment.js +0 -7
- package/plugins/contextMenu/predefinedItems/alignment.mjs +0 -7
- package/plugins/contextMenu/predefinedItems/clearColumn.js +3 -5
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +3 -5
- package/plugins/contextMenu/predefinedItems/columnLeft.js +3 -5
- package/plugins/contextMenu/predefinedItems/columnLeft.mjs +3 -5
- package/plugins/contextMenu/predefinedItems/columnRight.js +3 -5
- package/plugins/contextMenu/predefinedItems/columnRight.mjs +3 -5
- package/plugins/contextMenu/predefinedItems/readOnly.js +0 -7
- package/plugins/contextMenu/predefinedItems/readOnly.mjs +0 -7
- package/plugins/contextMenu/predefinedItems/removeColumn.js +5 -7
- package/plugins/contextMenu/predefinedItems/removeColumn.mjs +3 -5
- package/plugins/contextMenu/predefinedItems/removeRow.js +5 -7
- package/plugins/contextMenu/predefinedItems/removeRow.mjs +3 -5
- package/plugins/contextMenu/predefinedItems/rowAbove.js +3 -5
- package/plugins/contextMenu/predefinedItems/rowAbove.mjs +3 -5
- package/plugins/contextMenu/predefinedItems/rowBelow.js +3 -5
- package/plugins/contextMenu/predefinedItems/rowBelow.mjs +3 -5
- package/plugins/contextMenu/utils.js +16 -28
- package/plugins/contextMenu/utils.mjs +15 -27
- package/plugins/copyPaste/contextMenuItem/copy.js +0 -7
- package/plugins/copyPaste/contextMenuItem/copy.mjs +0 -7
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +1 -9
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +1 -9
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +1 -9
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +1 -9
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +1 -9
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +1 -9
- package/plugins/copyPaste/contextMenuItem/cut.js +0 -7
- package/plugins/copyPaste/contextMenuItem/cut.mjs +0 -7
- package/plugins/copyPaste/copyPaste.js +2 -6
- package/plugins/copyPaste/copyPaste.mjs +2 -6
- package/plugins/customBorders/customBorders.js +20 -23
- package/plugins/customBorders/customBorders.mjs +21 -24
- package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
- package/plugins/dropdownMenu/dropdownMenu.js +32 -89
- package/plugins/dropdownMenu/dropdownMenu.mjs +32 -89
- package/plugins/filters/filters.js +14 -31
- package/plugins/filters/filters.mjs +13 -30
- package/plugins/mergeCells/mergeCells.js +16 -5
- package/plugins/mergeCells/mergeCells.mjs +16 -5
- package/plugins/multiColumnSorting/multiColumnSorting.js +2 -37
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -37
- package/plugins/nestedHeaders/nestedHeaders.js +8 -121
- package/plugins/nestedHeaders/nestedHeaders.mjs +8 -121
- package/plugins/nestedHeaders/stateManager/index.js +0 -37
- package/plugins/nestedHeaders/stateManager/index.mjs +0 -37
- package/plugins/nestedRows/nestedRows.js +0 -41
- package/plugins/nestedRows/nestedRows.mjs +0 -41
- package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
- package/selection/highlight/constants.js +15 -0
- package/selection/highlight/constants.mjs +6 -0
- package/selection/highlight/highlight.js +71 -256
- package/selection/highlight/highlight.mjs +71 -250
- package/selection/highlight/types/activeHeader.js +8 -10
- package/selection/highlight/types/activeHeader.mjs +8 -10
- package/selection/highlight/types/area.js +18 -6
- package/selection/highlight/types/area.mjs +18 -6
- package/selection/highlight/types/{focus.js → cell.js} +7 -5
- package/selection/highlight/types/{focus.mjs → cell.mjs} +7 -5
- package/selection/highlight/types/customSelection.js +9 -7
- package/selection/highlight/types/customSelection.mjs +9 -7
- package/selection/highlight/types/fill.js +7 -5
- package/selection/highlight/types/fill.mjs +7 -5
- package/selection/highlight/types/header.js +18 -9
- package/selection/highlight/types/header.mjs +18 -9
- package/selection/highlight/types/index.js +35 -0
- package/selection/highlight/types/index.mjs +31 -0
- package/selection/highlight/visualSelection.js +27 -31
- package/selection/highlight/visualSelection.mjs +27 -31
- package/selection/index.js +7 -4
- package/selection/index.mjs +3 -2
- package/selection/mouseEventHandler.js +1 -1
- package/selection/mouseEventHandler.mjs +1 -1
- package/selection/range.js +8 -8
- package/selection/range.mjs +8 -8
- package/selection/selection.js +154 -290
- package/selection/selection.mjs +153 -287
- package/selection/transformation.js +90 -232
- package/selection/transformation.mjs +90 -232
- package/selection/utils.js +21 -15
- package/selection/utils.mjs +21 -16
- package/settings.d.ts +0 -2
- package/shortcuts/manager.js +0 -2
- package/shortcuts/manager.mjs +0 -2
- package/shortcuts/recorder.js +2 -2
- package/shortcuts/recorder.mjs +2 -2
- package/shortcuts/utils.js +5 -19
- package/shortcuts/utils.mjs +4 -18
- package/tableView.js +13 -67
- package/tableView.mjs +13 -67
- package/3rdparty/walkontable/src/selection/border/constants.js +0 -16
- package/3rdparty/walkontable/src/selection/border/constants.mjs +0 -12
- package/3rdparty/walkontable/src/selection/constants.js +0 -62
- package/3rdparty/walkontable/src/selection/constants.mjs +0 -51
- package/3rdparty/walkontable/src/selection/index.js +0 -26
- package/3rdparty/walkontable/src/selection/index.mjs +0 -5
- package/3rdparty/walkontable/src/selection/manager.js +0 -259
- package/3rdparty/walkontable/src/selection/manager.mjs +0 -254
- package/3rdparty/walkontable/src/selection/scanner.js +0 -270
- package/3rdparty/walkontable/src/selection/scanner.mjs +0 -267
- package/3rdparty/walkontable/src/selection/selection.js +0 -101
- package/3rdparty/walkontable/src/selection/selection.mjs +0 -96
- package/core/focusCatcher/focusDetector.js +0 -58
- package/core/focusCatcher/focusDetector.mjs +0 -54
- package/core/focusCatcher/index.js +0 -142
- package/core/focusCatcher/index.mjs +0 -138
- package/core/index.js +0 -9
- package/core/index.mjs +0 -1
- package/plugins/comments/contextMenuItem/addEditComment.js +0 -41
- package/plugins/comments/contextMenuItem/addEditComment.mjs +0 -35
- package/plugins/comments/contextMenuItem/readOnlyComment.js +0 -49
- package/plugins/comments/contextMenuItem/readOnlyComment.mjs +0 -43
- package/plugins/comments/contextMenuItem/removeComment.js +0 -38
- package/plugins/comments/contextMenuItem/removeComment.mjs +0 -32
- package/selection/highlight/types/areaLayered.js +0 -31
- package/selection/highlight/types/areaLayered.mjs +0 -26
- package/selection/highlight/types/column.js +0 -27
- package/selection/highlight/types/column.mjs +0 -22
- package/selection/highlight/types/row.js +0 -27
- package/selection/highlight/types/row.mjs +0 -22
- package/shortcutContexts/commands/editor/closeAndSave.js +0 -12
- package/shortcutContexts/commands/editor/closeAndSave.mjs +0 -8
- package/shortcutContexts/commands/editor/closeWithoutSaving.js +0 -12
- package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +0 -8
- package/shortcutContexts/commands/editor/fastOpen.js +0 -16
- package/shortcutContexts/commands/editor/fastOpen.mjs +0 -12
- package/shortcutContexts/commands/editor/index.js +0 -16
- package/shortcutContexts/commands/editor/index.mjs +0 -12
- package/shortcutContexts/commands/editor/open.js +0 -27
- package/shortcutContexts/commands/editor/open.mjs +0 -23
- package/shortcutContexts/commands/emptySelectedCells.js +0 -11
- package/shortcutContexts/commands/emptySelectedCells.mjs +0 -7
- package/shortcutContexts/commands/extendCellsSelection/down.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +0 -11
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +0 -21
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +0 -17
- package/shortcutContexts/commands/extendCellsSelection/index.js +0 -26
- package/shortcutContexts/commands/extendCellsSelection/index.mjs +0 -22
- package/shortcutContexts/commands/extendCellsSelection/left.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +0 -11
- package/shortcutContexts/commands/extendCellsSelection/right.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +0 -11
- package/shortcutContexts/commands/extendCellsSelection/toColumns.js +0 -19
- package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +0 -15
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +0 -29
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +0 -25
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +0 -19
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +0 -15
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +0 -19
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +0 -15
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +0 -29
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +0 -25
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +0 -29
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +0 -25
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +0 -29
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +0 -25
- package/shortcutContexts/commands/extendCellsSelection/toRows.js +0 -19
- package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +0 -15
- package/shortcutContexts/commands/extendCellsSelection/up.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +0 -11
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +0 -21
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +0 -17
- package/shortcutContexts/commands/index.js +0 -35
- package/shortcutContexts/commands/index.mjs +0 -31
- package/shortcutContexts/commands/moveCellSelection/down.js +0 -13
- package/shortcutContexts/commands/moveCellSelection/down.mjs +0 -9
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +0 -31
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +0 -27
- package/shortcutContexts/commands/moveCellSelection/index.js +0 -28
- package/shortcutContexts/commands/moveCellSelection/index.mjs +0 -24
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +0 -12
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +0 -8
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +0 -12
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +0 -8
- package/shortcutContexts/commands/moveCellSelection/left.js +0 -10
- package/shortcutContexts/commands/moveCellSelection/left.mjs +0 -6
- package/shortcutContexts/commands/moveCellSelection/right.js +0 -10
- package/shortcutContexts/commands/moveCellSelection/right.mjs +0 -6
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +0 -17
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +0 -13
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +0 -18
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +0 -14
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +0 -14
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +0 -10
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +0 -17
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +0 -13
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +0 -19
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +0 -15
- package/shortcutContexts/commands/moveCellSelection/toMostRight.js +0 -21
- package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +0 -17
- package/shortcutContexts/commands/moveCellSelection/toMostTop.js +0 -17
- package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +0 -13
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +0 -19
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +0 -15
- package/shortcutContexts/commands/moveCellSelection/up.js +0 -13
- package/shortcutContexts/commands/moveCellSelection/up.mjs +0 -9
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +0 -31
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +0 -27
- package/shortcutContexts/commands/populateSelectedCellsData.js +0 -29
- package/shortcutContexts/commands/populateSelectedCellsData.mjs +0 -25
- package/shortcutContexts/commands/scrollToFocusedCell.js +0 -36
- package/shortcutContexts/commands/scrollToFocusedCell.mjs +0 -32
- package/shortcutContexts/commands/selectAll.js +0 -10
- package/shortcutContexts/commands/selectAll.mjs +0 -6
- package/shortcutContexts/constants.js +0 -13
- package/shortcutContexts/constants.mjs +0 -8
- package/shortcutContexts/editor.js +0 -25
- package/shortcutContexts/editor.mjs +0 -21
- package/shortcutContexts/grid.js +0 -163
- package/shortcutContexts/grid.mjs +0 -159
- package/shortcutContexts/index.js +0 -24
- package/shortcutContexts/index.mjs +0 -11
package/selection/selection.mjs
CHANGED
@@ -1,17 +1,13 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
|
-
|
3
|
-
|
4
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
5
|
-
import { CellCoords, CellRange } from "./../3rdparty/walkontable/src/index.mjs";
|
6
|
-
import Highlight, { AREA_TYPE, HEADER_TYPE, FOCUS_TYPE } from "./highlight/highlight.mjs";
|
2
|
+
import Highlight from "./highlight/highlight.mjs";
|
3
|
+
import { AREA_TYPE, HEADER_TYPE, CELL_TYPE } from "./highlight/constants.mjs";
|
7
4
|
import SelectionRange from "./range.mjs";
|
8
5
|
import { createObjectPropListener, mixin } from "./../helpers/object.mjs";
|
9
6
|
import { isUndefined } from "./../helpers/mixed.mjs";
|
10
|
-
import { clamp } from "./../helpers/number.mjs";
|
11
7
|
import { arrayEach } from "./../helpers/array.mjs";
|
12
8
|
import localHooks from "./../mixins/localHooks.mjs";
|
13
9
|
import Transformation from "./transformation.mjs";
|
14
|
-
import { detectSelectionType, normalizeSelectionFactory, SELECTION_TYPE_EMPTY, SELECTION_TYPE_UNRECOGNIZED } from "./utils.mjs";
|
10
|
+
import { detectSelectionType, isValidCoord, normalizeSelectionFactory, SELECTION_TYPE_EMPTY, SELECTION_TYPE_UNRECOGNIZED } from "./utils.mjs";
|
15
11
|
import { toSingleLine } from "./../helpers/templateLiteralTag.mjs";
|
16
12
|
/**
|
17
13
|
* @class Selection
|
@@ -25,62 +21,57 @@ class Selection {
|
|
25
21
|
*
|
26
22
|
* @type {GridSettings}
|
27
23
|
*/
|
28
|
-
|
24
|
+
this.settings = settings;
|
29
25
|
/**
|
30
26
|
* An additional object with dynamically defined properties which describes table state.
|
31
27
|
*
|
32
28
|
* @type {object}
|
33
29
|
*/
|
34
|
-
|
30
|
+
this.tableProps = tableProps;
|
35
31
|
/**
|
36
32
|
* The flag which determines if the selection is in progress.
|
37
33
|
*
|
38
34
|
* @type {boolean}
|
39
35
|
*/
|
40
|
-
|
36
|
+
this.inProgress = false;
|
41
37
|
/**
|
42
|
-
*
|
38
|
+
* The flag indicates that selection was performed by clicking the corner overlay.
|
43
39
|
*
|
44
|
-
* @type {
|
40
|
+
* @type {boolean}
|
45
41
|
*/
|
46
|
-
|
47
|
-
return this.tableProps.createCellRange(highlight, from, to);
|
48
|
-
}));
|
42
|
+
this.selectedByCorner = false;
|
49
43
|
/**
|
50
|
-
*
|
44
|
+
* The collection of the selection layer levels where the whole row was selected using the row header or
|
45
|
+
* the corner header.
|
51
46
|
*
|
52
|
-
* @type {
|
47
|
+
* @type {Set.<number>}
|
53
48
|
*/
|
54
|
-
|
49
|
+
this.selectedByRowHeader = new Set();
|
55
50
|
/**
|
56
|
-
* The
|
51
|
+
* The collection of the selection layer levels where the whole column was selected using the column header or
|
52
|
+
* the corner header.
|
57
53
|
*
|
58
|
-
* @type {
|
54
|
+
* @type {Set.<number>}
|
59
55
|
*/
|
60
|
-
|
56
|
+
this.selectedByColumnHeader = new Set();
|
61
57
|
/**
|
62
|
-
*
|
63
|
-
* the corner header.
|
58
|
+
* Selection data layer (handle visual coordinates).
|
64
59
|
*
|
65
|
-
* @type {
|
60
|
+
* @type {SelectionRange}
|
66
61
|
*/
|
67
|
-
|
62
|
+
this.selectedRange = new SelectionRange((highlight, from, to) => {
|
63
|
+
return this.tableProps.createCellRange(highlight, from, to);
|
64
|
+
});
|
68
65
|
/**
|
69
|
-
*
|
70
|
-
* the corner header.
|
66
|
+
* Visualization layer.
|
71
67
|
*
|
72
|
-
* @type {
|
68
|
+
* @type {Highlight}
|
73
69
|
*/
|
74
|
-
_defineProperty(this, "selectedByColumnHeader", new Set());
|
75
|
-
this.settings = settings;
|
76
|
-
this.tableProps = tableProps;
|
77
70
|
this.highlight = new Highlight({
|
78
71
|
headerClassName: settings.currentHeaderClassName,
|
79
72
|
activeHeaderClassName: settings.activeHeaderClassName,
|
80
73
|
rowClassName: settings.currentRowClassName,
|
81
74
|
columnClassName: settings.currentColClassName,
|
82
|
-
rowIndexMapper: this.tableProps.rowIndexMapper,
|
83
|
-
columnIndexMapper: this.tableProps.columnIndexMapper,
|
84
75
|
disabledCellSelection: (row, column) => this.tableProps.isDisabledCellSelection(row, column),
|
85
76
|
cellCornerVisible: function () {
|
86
77
|
return _this.isCellCornerVisible(...arguments);
|
@@ -91,19 +82,21 @@ class Selection {
|
|
91
82
|
visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
|
92
83
|
renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
|
93
84
|
createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
|
94
|
-
createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to)
|
85
|
+
createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to),
|
86
|
+
rowIndexMapper: () => this.tableProps.rowIndexMapper(),
|
87
|
+
columnIndexMapper: () => this.tableProps.columnIndexMapper()
|
95
88
|
});
|
89
|
+
/**
|
90
|
+
* The module for modifying coordinates.
|
91
|
+
*
|
92
|
+
* @type {Transformation}
|
93
|
+
*/
|
96
94
|
this.transformation = new Transformation(this.selectedRange, {
|
97
|
-
|
98
|
-
|
99
|
-
countRenderableRows: () => this.tableProps.countRenderableRows(),
|
100
|
-
countRenderableColumns: () => this.tableProps.countRenderableColumns(),
|
101
|
-
countRowHeaders: () => this.tableProps.countRowHeaders(),
|
102
|
-
countColHeaders: () => this.tableProps.countColHeaders(),
|
95
|
+
countRows: () => this.tableProps.countRowsTranslated(),
|
96
|
+
countCols: () => this.tableProps.countColsTranslated(),
|
103
97
|
visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
|
104
98
|
renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
|
105
99
|
createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
|
106
|
-
navigableHeaders: () => settings.navigableHeaders,
|
107
100
|
fixedRowsBottom: () => settings.fixedRowsBottom,
|
108
101
|
minSpareRows: () => settings.minSpareRows,
|
109
102
|
minSpareCols: () => settings.minSpareCols,
|
@@ -158,14 +151,14 @@ class Selection {
|
|
158
151
|
}
|
159
152
|
|
160
153
|
/**
|
161
|
-
* Indicate that selection process began. It sets
|
154
|
+
* Indicate that selection process began. It sets internaly `.inProgress` property to `true`.
|
162
155
|
*/
|
163
156
|
begin() {
|
164
157
|
this.inProgress = true;
|
165
158
|
}
|
166
159
|
|
167
160
|
/**
|
168
|
-
* Indicate that selection process finished. It sets
|
161
|
+
* Indicate that selection process finished. It sets internaly `.inProgress` property to `false`.
|
169
162
|
*/
|
170
163
|
finish() {
|
171
164
|
this.runLocalHooks('afterSelectionFinished', Array.from(this.selectedRange));
|
@@ -190,25 +183,33 @@ class Selection {
|
|
190
183
|
* the default trigger will be used.
|
191
184
|
* @param {boolean} [fragment=false] If `true`, the selection will be treated as a partial selection where the
|
192
185
|
* `setRangeEnd` method won't be called on every `setRangeStart` call.
|
193
|
-
* @param {CellCoords} [highlightCoords] If set, allows changing the coordinates of the highlight/focus cell.
|
194
186
|
*/
|
195
187
|
setRangeStart(coords, multipleSelection) {
|
196
188
|
let fragment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
197
|
-
let highlightCoords = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : coords;
|
198
189
|
const isMultipleMode = this.settings.selectionMode === 'multiple';
|
199
190
|
const isMultipleSelection = isUndefined(multipleSelection) ? this.tableProps.getShortcutManager().isCtrlPressed() : multipleSelection;
|
191
|
+
const isRowNegative = coords.row < 0;
|
192
|
+
const isColumnNegative = coords.col < 0;
|
193
|
+
const selectedByCorner = isRowNegative && isColumnNegative;
|
200
194
|
// We are creating copy. We would like to modify just the start of the selection by below hook. Then original coords
|
201
195
|
// should be handled by next methods.
|
202
196
|
const coordsClone = coords.clone();
|
197
|
+
this.selectedByCorner = selectedByCorner;
|
203
198
|
this.runLocalHooks(`beforeSetRangeStart${fragment ? 'Only' : ''}`, coordsClone);
|
204
199
|
if (!isMultipleMode || isMultipleMode && !isMultipleSelection && isUndefined(multipleSelection)) {
|
205
200
|
this.selectedRange.clear();
|
206
201
|
}
|
207
|
-
this.selectedRange.add(coordsClone)
|
202
|
+
this.selectedRange.add(coordsClone);
|
208
203
|
if (this.getLayerLevel() === 0) {
|
209
204
|
this.selectedByRowHeader.clear();
|
210
205
|
this.selectedByColumnHeader.clear();
|
211
206
|
}
|
207
|
+
if (!selectedByCorner && isColumnNegative) {
|
208
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
209
|
+
}
|
210
|
+
if (!selectedByCorner && isRowNegative) {
|
211
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
212
|
+
}
|
212
213
|
if (!fragment) {
|
213
214
|
this.setRangeEnd(coords);
|
214
215
|
}
|
@@ -221,11 +222,9 @@ class Selection {
|
|
221
222
|
* @param {boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
|
222
223
|
* only when 'selectionMode' is set as 'multiple'. If the argument is not defined
|
223
224
|
* the default trigger will be used.
|
224
|
-
* @param {CellCoords} [highlightCoords] If set, allows changing the coordinates of the highlight/focus cell.
|
225
225
|
*/
|
226
226
|
setRangeStartOnly(coords, multipleSelection) {
|
227
|
-
|
228
|
-
this.setRangeStart(coords, multipleSelection, true, highlightCoords);
|
227
|
+
this.setRangeStart(coords, multipleSelection, true);
|
229
228
|
}
|
230
229
|
|
231
230
|
/**
|
@@ -237,39 +236,21 @@ class Selection {
|
|
237
236
|
if (this.selectedRange.isEmpty()) {
|
238
237
|
return;
|
239
238
|
}
|
240
|
-
const coordsClone = coords.clone();
|
241
|
-
const countRows = this.tableProps.countRows();
|
242
|
-
const countCols = this.tableProps.countCols();
|
243
|
-
const isSingle = this.selectedRange.current().clone().setTo(coords).isSingleHeader();
|
244
239
|
|
245
|
-
//
|
246
|
-
//
|
247
|
-
|
248
|
-
return;
|
249
|
-
}
|
240
|
+
// We are creating copy. We would like to modify just the end of the selection by below hook. Then original coords
|
241
|
+
// should be handled by next methods.
|
242
|
+
const coordsClone = coords.clone();
|
250
243
|
this.runLocalHooks('beforeSetRangeEnd', coordsClone);
|
251
244
|
this.begin();
|
252
245
|
const cellRange = this.selectedRange.current();
|
253
|
-
if (
|
254
|
-
cellRange.
|
255
|
-
}
|
256
|
-
if (this.settings.selectionMode === 'single') {
|
257
|
-
cellRange.setFrom(cellRange.highlight);
|
258
|
-
cellRange.setTo(cellRange.highlight);
|
259
|
-
} else {
|
260
|
-
cellRange.setTo(coordsClone);
|
246
|
+
if (this.settings.selectionMode !== 'single') {
|
247
|
+
cellRange.setTo(this.tableProps.createCellCoords(coordsClone.row, coordsClone.col));
|
261
248
|
}
|
262
249
|
|
263
|
-
//
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
}
|
268
|
-
}
|
269
|
-
const focusHighlight = this.highlight.getFocus();
|
270
|
-
focusHighlight.clear();
|
271
|
-
if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
|
272
|
-
focusHighlight.add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
|
250
|
+
// Set up current selection.
|
251
|
+
this.highlight.getCell().clear();
|
252
|
+
if (this.highlight.isEnabledFor(CELL_TYPE, cellRange.highlight)) {
|
253
|
+
this.highlight.getCell().add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
|
273
254
|
}
|
274
255
|
const layerLevel = this.getLayerLevel();
|
275
256
|
|
@@ -277,80 +258,69 @@ class Selection {
|
|
277
258
|
// indication that the new selection is performing.
|
278
259
|
if (layerLevel < this.highlight.layerLevel) {
|
279
260
|
arrayEach(this.highlight.getAreas(), highlight => void highlight.clear());
|
280
|
-
arrayEach(this.highlight.
|
281
|
-
arrayEach(this.highlight.
|
282
|
-
arrayEach(this.highlight.getColumnHeaders(), highlight => void highlight.clear());
|
283
|
-
arrayEach(this.highlight.getActiveRowHeaders(), highlight => void highlight.clear());
|
284
|
-
arrayEach(this.highlight.getActiveColumnHeaders(), highlight => void highlight.clear());
|
285
|
-
arrayEach(this.highlight.getActiveCornerHeaders(), highlight => void highlight.clear());
|
286
|
-
arrayEach(this.highlight.getRowHighlights(), highlight => void highlight.clear());
|
287
|
-
arrayEach(this.highlight.getColumnHighlights(), highlight => void highlight.clear());
|
261
|
+
arrayEach(this.highlight.getHeaders(), highlight => void highlight.clear());
|
262
|
+
arrayEach(this.highlight.getActiveHeaders(), highlight => void highlight.clear());
|
288
263
|
}
|
289
264
|
this.highlight.useLayerLevel(layerLevel);
|
290
|
-
const areaHighlight = this.highlight.
|
291
|
-
const
|
292
|
-
const
|
293
|
-
const columnHeaderHighlight = this.highlight.createColumnHeader();
|
294
|
-
const activeRowHeaderHighlight = this.highlight.createActiveRowHeader();
|
295
|
-
const activeColumnHeaderHighlight = this.highlight.createActiveColumnHeader();
|
296
|
-
const activeCornerHeaderHighlight = this.highlight.createActiveCornerHeader();
|
297
|
-
const rowHighlight = this.highlight.createRowHighlight();
|
298
|
-
const columnHighlight = this.highlight.createColumnHighlight();
|
265
|
+
const areaHighlight = this.highlight.createOrGetArea();
|
266
|
+
const headerHighlight = this.highlight.createOrGetHeader();
|
267
|
+
const activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
|
299
268
|
areaHighlight.clear();
|
300
|
-
|
301
|
-
|
302
|
-
columnHeaderHighlight.clear();
|
303
|
-
activeRowHeaderHighlight.clear();
|
304
|
-
activeColumnHeaderHighlight.clear();
|
305
|
-
activeCornerHeaderHighlight.clear();
|
306
|
-
rowHighlight.clear();
|
307
|
-
columnHighlight.clear();
|
269
|
+
headerHighlight.clear();
|
270
|
+
activeHeaderHighlight.clear();
|
308
271
|
if (this.highlight.isEnabledFor(AREA_TYPE, cellRange.highlight) && (this.isMultiple() || layerLevel >= 1)) {
|
309
272
|
areaHighlight.add(cellRange.from).add(cellRange.to).commit();
|
310
|
-
layeredAreaHighlight.add(cellRange.from).add(cellRange.to).commit();
|
311
273
|
if (layerLevel === 1) {
|
312
274
|
// For single cell selection in the same layer, we do not create area selection to prevent blue background.
|
313
275
|
// When non-consecutive selection is performed we have to add that missing area selection to the previous layer
|
314
276
|
// based on previous coordinates. It only occurs when the previous selection wasn't select multiple cells.
|
315
277
|
const previousRange = this.selectedRange.previous();
|
316
|
-
this.highlight.useLayerLevel(layerLevel - 1)
|
317
|
-
this.highlight.createArea().add(previousRange.from).commit()
|
318
|
-
// Range may start with hidden indexes. Commit would not found start point (as we add just the `from` coords).
|
319
|
-
.syncWith(previousRange);
|
320
|
-
this.highlight.createLayeredArea().add(previousRange.from).commit()
|
278
|
+
this.highlight.useLayerLevel(layerLevel - 1).createOrGetArea().add(previousRange.from).commit()
|
321
279
|
// Range may start with hidden indexes. Commit would not found start point (as we add just the `from` coords).
|
322
280
|
.syncWith(previousRange);
|
323
281
|
this.highlight.useLayerLevel(layerLevel);
|
324
282
|
}
|
325
283
|
}
|
326
284
|
if (this.highlight.isEnabledFor(HEADER_TYPE, cellRange.highlight)) {
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
columnHighlight.add(columnCoordsFrom).commit();
|
337
|
-
} else {
|
338
|
-
rowHeaderHighlight.add(rowCoordsFrom).add(rowCoordsTo).commit();
|
339
|
-
columnHeaderHighlight.add(columnCoordsFrom).add(columnCoordsTo).commit();
|
340
|
-
rowHighlight.add(rowCoordsFrom).add(rowCoordsTo).commit();
|
341
|
-
columnHighlight.add(columnCoordsFrom).add(columnCoordsTo).commit();
|
342
|
-
}
|
285
|
+
// The header selection generally contains cell selection. In a case when all rows (or columns)
|
286
|
+
// are hidden that visual coordinates are translated to renderable coordinates that do not exist.
|
287
|
+
// Hence no header highlight is generated. In that case, to make a column (or a row) header
|
288
|
+
// highlight, the row and column index has to point to the header (the negative value). See #7052.
|
289
|
+
const areAnyRowsRendered = this.tableProps.countRowsTranslated() === 0;
|
290
|
+
const areAnyColumnsRendered = this.tableProps.countColsTranslated() === 0;
|
291
|
+
let headerCellRange = cellRange;
|
292
|
+
if (areAnyRowsRendered || areAnyColumnsRendered) {
|
293
|
+
headerCellRange = cellRange.clone();
|
343
294
|
}
|
344
|
-
|
345
|
-
|
346
|
-
if (highlightRowHeaders) {
|
347
|
-
activeRowHeaderHighlight.add(this.tableProps.createCellCoords(Math.max(cellRange.from.row, 0), Math.min(-this.tableProps.countRowHeaders(), -1))).add(this.tableProps.createCellCoords(Math.max(cellRange.to.row, 0), -1)).commit();
|
295
|
+
if (areAnyRowsRendered) {
|
296
|
+
headerCellRange.from.row = -1;
|
348
297
|
}
|
349
|
-
if (
|
350
|
-
|
298
|
+
if (areAnyColumnsRendered) {
|
299
|
+
headerCellRange.from.col = -1;
|
351
300
|
}
|
352
|
-
if (
|
353
|
-
|
301
|
+
if (this.settings.selectionMode === 'single') {
|
302
|
+
if (this.isSelectedByAnyHeader()) {
|
303
|
+
headerCellRange.from.normalize();
|
304
|
+
}
|
305
|
+
headerHighlight.add(headerCellRange.from).commit();
|
306
|
+
} else {
|
307
|
+
headerHighlight.add(headerCellRange.from).add(headerCellRange.to).commit();
|
308
|
+
}
|
309
|
+
if (this.isEntireRowSelected()) {
|
310
|
+
const isRowSelected = this.tableProps.countCols() === cellRange.getWidth();
|
311
|
+
|
312
|
+
// Make sure that the whole row is selected (in case where selectionMode is set to 'single')
|
313
|
+
if (isRowSelected) {
|
314
|
+
activeHeaderHighlight.add(this.tableProps.createCellCoords(cellRange.from.row, -1)).add(this.tableProps.createCellCoords(cellRange.to.row, -1)).commit();
|
315
|
+
}
|
316
|
+
}
|
317
|
+
if (this.isEntireColumnSelected()) {
|
318
|
+
const isColumnSelected = this.tableProps.countRows() === cellRange.getHeight();
|
319
|
+
|
320
|
+
// Make sure that the whole column is selected (in case where selectionMode is set to 'single')
|
321
|
+
if (isColumnSelected) {
|
322
|
+
activeHeaderHighlight.add(this.tableProps.createCellCoords(-1, cellRange.from.col)).add(this.tableProps.createCellCoords(-1, cellRange.to.col)).commit();
|
323
|
+
}
|
354
324
|
}
|
355
325
|
}
|
356
326
|
this.runLocalHooks('afterSetRangeEnd', coords);
|
@@ -373,12 +343,12 @@ class Selection {
|
|
373
343
|
*
|
374
344
|
* @param {number} rowDelta Rows number to move, value can be passed as negative number.
|
375
345
|
* @param {number} colDelta Columns number to move, value can be passed as negative number.
|
376
|
-
* @param {boolean} [
|
377
|
-
*
|
346
|
+
* @param {boolean} [force=false] If `true` the new rows/columns will be created if necessary. Otherwise, row/column will
|
347
|
+
* be created according to `minSpareRows/minSpareCols` settings of Handsontable.
|
378
348
|
*/
|
379
349
|
transformStart(rowDelta, colDelta) {
|
380
|
-
let
|
381
|
-
this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta,
|
350
|
+
let force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
351
|
+
this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, force));
|
382
352
|
}
|
383
353
|
|
384
354
|
/**
|
@@ -419,7 +389,7 @@ class Selection {
|
|
419
389
|
*/
|
420
390
|
isSelectedByRowHeader() {
|
421
391
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
422
|
-
return !this.isSelectedByCorner(layerLevel) &&
|
392
|
+
return !this.isSelectedByCorner(layerLevel) && this.isEntireRowSelected(layerLevel);
|
423
393
|
}
|
424
394
|
|
425
395
|
/**
|
@@ -431,19 +401,7 @@ class Selection {
|
|
431
401
|
*/
|
432
402
|
isEntireRowSelected() {
|
433
403
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
434
|
-
|
435
|
-
const {
|
436
|
-
col
|
437
|
-
} = range.getOuterTopStartCorner();
|
438
|
-
const rowHeaders = this.tableProps.countRowHeaders();
|
439
|
-
const countCols = this.tableProps.countCols();
|
440
|
-
return (rowHeaders > 0 && col < 0 || rowHeaders === 0) && range.getWidth() === countCols;
|
441
|
-
};
|
442
|
-
if (layerLevel === -1) {
|
443
|
-
return Array.from(this.selectedRange).some(range => tester(range));
|
444
|
-
}
|
445
|
-
const range = this.selectedRange.peekByIndex(layerLevel);
|
446
|
-
return range ? tester(range) : false;
|
404
|
+
return layerLevel === -1 ? this.selectedByRowHeader.size > 0 : this.selectedByRowHeader.has(layerLevel);
|
447
405
|
}
|
448
406
|
|
449
407
|
/**
|
@@ -456,7 +414,7 @@ class Selection {
|
|
456
414
|
*/
|
457
415
|
isSelectedByColumnHeader() {
|
458
416
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
459
|
-
return !this.isSelectedByCorner() &&
|
417
|
+
return !this.isSelectedByCorner() && this.isEntireColumnSelected(layerLevel);
|
460
418
|
}
|
461
419
|
|
462
420
|
/**
|
@@ -468,19 +426,7 @@ class Selection {
|
|
468
426
|
*/
|
469
427
|
isEntireColumnSelected() {
|
470
428
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
471
|
-
|
472
|
-
const {
|
473
|
-
row
|
474
|
-
} = range.getOuterTopStartCorner();
|
475
|
-
const colHeaders = this.tableProps.countColHeaders();
|
476
|
-
const countRows = this.tableProps.countRows();
|
477
|
-
return (colHeaders > 0 && row < 0 || colHeaders === 0) && range.getHeight() === countRows;
|
478
|
-
};
|
479
|
-
if (layerLevel === -1) {
|
480
|
-
return Array.from(this.selectedRange).some(range => tester(range));
|
481
|
-
}
|
482
|
-
const range = this.selectedRange.peekByIndex(layerLevel);
|
483
|
-
return range ? tester(range) : false;
|
429
|
+
return layerLevel === -1 ? this.selectedByColumnHeader.size > 0 : this.selectedByColumnHeader.has(layerLevel);
|
484
430
|
}
|
485
431
|
|
486
432
|
/**
|
@@ -498,7 +444,7 @@ class Selection {
|
|
498
444
|
* @returns {boolean}
|
499
445
|
*/
|
500
446
|
isSelectedByCorner() {
|
501
|
-
return this.
|
447
|
+
return this.selectedByCorner;
|
502
448
|
}
|
503
449
|
|
504
450
|
/**
|
@@ -557,47 +503,29 @@ class Selection {
|
|
557
503
|
}
|
558
504
|
|
559
505
|
/**
|
560
|
-
*
|
506
|
+
* Select all cells.
|
561
507
|
*
|
562
|
-
* @param {boolean} [includeRowHeaders=false] `true` If the selection should include the row headers,
|
563
|
-
*
|
564
|
-
* @param {boolean} [includeColumnHeaders=false] `true` If the selection should include the column
|
565
|
-
*
|
566
|
-
* @param {{row: number, col: number}} [focusPosition] The argument allows changing the cell/header
|
567
|
-
* focus position. The value takes an object with a `row` and `col` properties from -N to N, where
|
568
|
-
* negative values point to the headers and positive values point to the cell range.
|
508
|
+
* @param {boolean} [includeRowHeaders=false] `true` If the selection should include the row headers, `false`
|
509
|
+
* otherwise.
|
510
|
+
* @param {boolean} [includeColumnHeaders=false] `true` If the selection should include the column headers, `false`
|
511
|
+
* otherwise.
|
569
512
|
*/
|
570
513
|
selectAll() {
|
571
514
|
let includeRowHeaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
572
515
|
let includeColumnHeaders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
573
|
-
let focusPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
574
|
-
row: this.tableProps.countColHeaders() > 0 ? -this.tableProps.countColHeaders() : 0,
|
575
|
-
col: this.tableProps.countRowHeaders() > 0 ? -this.tableProps.countRowHeaders() : 0
|
576
|
-
};
|
577
516
|
const nrOfRows = this.tableProps.countRows();
|
578
517
|
const nrOfColumns = this.tableProps.countCols();
|
579
|
-
const countRowHeaders = this.tableProps.countRowHeaders();
|
580
|
-
const countColHeaders = this.tableProps.countColHeaders();
|
581
|
-
const rowFrom = includeRowHeaders ? -countColHeaders : 0;
|
582
|
-
const columnFrom = includeColumnHeaders ? -countRowHeaders : 0;
|
583
518
|
|
584
519
|
// We can't select cells when there is no data.
|
585
|
-
if (
|
520
|
+
if (!includeRowHeaders && !includeColumnHeaders && (nrOfRows === 0 || nrOfColumns === 0)) {
|
586
521
|
return;
|
587
522
|
}
|
588
|
-
const
|
589
|
-
const highlightColumn = Number.isInteger(focusPosition.col) ? focusPosition.col : 0;
|
590
|
-
const startCoords = this.tableProps.createCellCoords(rowFrom, columnFrom);
|
591
|
-
const highlight = this.tableProps.createCellCoords(clamp(highlightRow, rowFrom, nrOfRows - 1), clamp(highlightColumn, columnFrom, nrOfColumns - 1));
|
523
|
+
const startCoords = this.tableProps.createCellCoords(includeColumnHeaders ? -1 : 0, includeRowHeaders ? -1 : 0);
|
592
524
|
const endCoords = this.tableProps.createCellCoords(nrOfRows - 1, nrOfColumns - 1);
|
593
525
|
this.clear();
|
594
|
-
this.setRangeStartOnly(startCoords
|
595
|
-
|
596
|
-
|
597
|
-
}
|
598
|
-
if (rowFrom < 0) {
|
599
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
600
|
-
}
|
526
|
+
this.setRangeStartOnly(startCoords);
|
527
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
528
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
601
529
|
this.setRangeEnd(endCoords);
|
602
530
|
this.finish();
|
603
531
|
}
|
@@ -624,29 +552,21 @@ class Selection {
|
|
624
552
|
propToCol: prop => this.tableProps.propToCol(prop),
|
625
553
|
keepDirection: true
|
626
554
|
});
|
627
|
-
const
|
628
|
-
const
|
629
|
-
countRows: this.tableProps.countRows(),
|
630
|
-
countCols: this.tableProps.countCols(),
|
631
|
-
countRowHeaders: navigableHeaders ? this.tableProps.countRowHeaders() : 0,
|
632
|
-
countColHeaders: navigableHeaders ? this.tableProps.countColHeaders() : 0
|
633
|
-
};
|
555
|
+
const nrOfRows = this.tableProps.countRows();
|
556
|
+
const nrOfColumns = this.tableProps.countCols();
|
634
557
|
|
635
558
|
// Check if every layer of the coordinates are valid.
|
636
559
|
const isValid = !selectionRanges.some(selection => {
|
637
|
-
const
|
638
|
-
const
|
639
|
-
return !
|
560
|
+
const [rowStart, columnStart, rowEnd, columnEnd] = selectionSchemaNormalizer(selection);
|
561
|
+
const _isValid = isValidCoord(rowStart, nrOfRows) && isValidCoord(columnStart, nrOfColumns) && isValidCoord(rowEnd, nrOfRows) && isValidCoord(columnEnd, nrOfColumns);
|
562
|
+
return !_isValid;
|
640
563
|
});
|
641
564
|
if (isValid) {
|
642
565
|
this.clear();
|
643
566
|
arrayEach(selectionRanges, selection => {
|
644
|
-
const
|
645
|
-
|
646
|
-
|
647
|
-
} = selectionSchemaNormalizer(selection);
|
648
|
-
this.setRangeStartOnly(from.clone(), false);
|
649
|
-
this.setRangeEnd(to.clone());
|
567
|
+
const [rowStart, columnStart, rowEnd, columnEnd] = selectionSchemaNormalizer(selection);
|
568
|
+
this.setRangeStartOnly(this.tableProps.createCellCoords(rowStart, columnStart), false);
|
569
|
+
this.setRangeEnd(this.tableProps.createCellCoords(rowEnd, columnEnd));
|
650
570
|
this.finish();
|
651
571
|
});
|
652
572
|
}
|
@@ -659,43 +579,22 @@ class Selection {
|
|
659
579
|
*
|
660
580
|
* @param {number|string} startColumn Visual column index or column property from which the selection starts.
|
661
581
|
* @param {number|string} [endColumn] Visual column index or column property from to the selection finishes.
|
662
|
-
* @param {number} [
|
663
|
-
*
|
664
|
-
*
|
582
|
+
* @param {number} [headerLevel=-1] A row header index that triggers the column selection. The value can
|
583
|
+
* take -1 to -N, where -1 means the header closest to the cells.
|
584
|
+
*
|
665
585
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
666
586
|
*/
|
667
587
|
selectColumns(startColumn) {
|
668
588
|
let endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
|
669
|
-
let
|
589
|
+
let headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
670
590
|
const start = typeof startColumn === 'string' ? this.tableProps.propToCol(startColumn) : startColumn;
|
671
591
|
const end = typeof endColumn === 'string' ? this.tableProps.propToCol(endColumn) : endColumn;
|
672
|
-
const
|
673
|
-
const
|
674
|
-
const
|
675
|
-
const columnHeaderLastIndex = countColHeaders === 0 ? 0 : -countColHeaders;
|
676
|
-
const fromCoords = new CellCoords(columnHeaderLastIndex, start);
|
677
|
-
const toCoords = new CellCoords(countRows - 1, end);
|
678
|
-
const isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
|
679
|
-
countRows,
|
680
|
-
countCols,
|
681
|
-
countRowHeaders: 0,
|
682
|
-
countColHeaders
|
683
|
-
});
|
592
|
+
const nrOfColumns = this.tableProps.countCols();
|
593
|
+
const nrOfRows = this.tableProps.countRows();
|
594
|
+
const isValid = isValidCoord(start, nrOfColumns) && isValidCoord(end, nrOfColumns);
|
684
595
|
if (isValid) {
|
685
|
-
|
686
|
-
|
687
|
-
const from = this.tableProps.createCellCoords(fromRow, start);
|
688
|
-
const to = this.tableProps.createCellCoords(toRow, end);
|
689
|
-
const highlight = this.tableProps.createCellCoords(clamp(focusPosition, columnHeaderLastIndex, countRows - 1), start);
|
690
|
-
this.runLocalHooks('beforeSelectColumns', from, to, highlight);
|
691
|
-
|
692
|
-
// disallow modifying row axis for that hooks
|
693
|
-
from.row = fromRow;
|
694
|
-
to.row = toRow;
|
695
|
-
this.setRangeStartOnly(from, void 0, highlight);
|
696
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
697
|
-
this.setRangeEnd(to);
|
698
|
-
this.runLocalHooks('afterSelectColumns', from, to, highlight);
|
596
|
+
this.setRangeStartOnly(this.tableProps.createCellCoords(headerLevel, start));
|
597
|
+
this.setRangeEnd(this.tableProps.createCellCoords(nrOfRows - 1, end));
|
699
598
|
this.finish();
|
700
599
|
}
|
701
600
|
return isValid;
|
@@ -706,41 +605,20 @@ class Selection {
|
|
706
605
|
*
|
707
606
|
* @param {number} startRow Visual row index from which the selection starts.
|
708
607
|
* @param {number} [endRow] Visual row index from to the selection finishes.
|
709
|
-
* @param {number} [
|
710
|
-
*
|
711
|
-
*
|
608
|
+
* @param {number} [headerLevel=-1] A column header index that triggers the row selection.
|
609
|
+
* The value can take -1 to -N, where -1 means the header
|
610
|
+
* closest to the cells.
|
712
611
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
713
612
|
*/
|
714
613
|
selectRows(startRow) {
|
715
614
|
let endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
|
716
|
-
let
|
717
|
-
const
|
718
|
-
const
|
719
|
-
const
|
720
|
-
const rowHeaderLastIndex = countRowHeaders === 0 ? 0 : -countRowHeaders;
|
721
|
-
const fromCoords = new CellCoords(startRow, rowHeaderLastIndex);
|
722
|
-
const toCoords = new CellCoords(endRow, countCols - 1);
|
723
|
-
const isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
|
724
|
-
countRows,
|
725
|
-
countCols,
|
726
|
-
countRowHeaders,
|
727
|
-
countColHeaders: 0
|
728
|
-
});
|
615
|
+
let headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
616
|
+
const nrOfRows = this.tableProps.countRows();
|
617
|
+
const nrOfColumns = this.tableProps.countCols();
|
618
|
+
const isValid = isValidCoord(startRow, nrOfRows) && isValidCoord(endRow, nrOfRows);
|
729
619
|
if (isValid) {
|
730
|
-
|
731
|
-
|
732
|
-
const from = this.tableProps.createCellCoords(startRow, fromColumn);
|
733
|
-
const to = this.tableProps.createCellCoords(endRow, toColumn);
|
734
|
-
const highlight = this.tableProps.createCellCoords(startRow, clamp(focusPosition, rowHeaderLastIndex, countCols - 1));
|
735
|
-
this.runLocalHooks('beforeSelectRows', from, to, highlight);
|
736
|
-
|
737
|
-
// disallow modifying column axis for that hooks
|
738
|
-
from.col = fromColumn;
|
739
|
-
to.col = toColumn;
|
740
|
-
this.setRangeStartOnly(from, void 0, highlight);
|
741
|
-
this.selectedByRowHeader.add(this.getLayerLevel());
|
742
|
-
this.setRangeEnd(to);
|
743
|
-
this.runLocalHooks('afterSelectRows', from, to, highlight);
|
620
|
+
this.setRangeStartOnly(this.tableProps.createCellCoords(startRow, headerLevel));
|
621
|
+
this.setRangeEnd(this.tableProps.createCellCoords(endRow, nrOfColumns - 1));
|
744
622
|
this.finish();
|
745
623
|
}
|
746
624
|
return isValid;
|
@@ -757,31 +635,19 @@ class Selection {
|
|
757
635
|
if (!this.isSelected()) {
|
758
636
|
return;
|
759
637
|
}
|
760
|
-
const
|
638
|
+
const cellHighlight = this.highlight.getCell();
|
761
639
|
const currentLayer = this.getLayerLevel();
|
762
|
-
|
640
|
+
cellHighlight.commit().syncWith(this.selectedRange.current());
|
763
641
|
|
764
642
|
// Rewriting rendered ranges going through all layers.
|
765
643
|
for (let layerLevel = 0; layerLevel < this.selectedRange.size(); layerLevel += 1) {
|
766
644
|
this.highlight.useLayerLevel(layerLevel);
|
767
|
-
const areaHighlight = this.highlight.
|
768
|
-
const
|
769
|
-
const
|
770
|
-
const columnHeaderHighlight = this.highlight.createColumnHeader();
|
771
|
-
const activeRowHeaderHighlight = this.highlight.createActiveRowHeader();
|
772
|
-
const activeColumnHeaderHighlight = this.highlight.createActiveColumnHeader();
|
773
|
-
const activeCornerHeaderHighlight = this.highlight.createActiveCornerHeader();
|
774
|
-
const rowHighlight = this.highlight.createRowHighlight();
|
775
|
-
const columnHighlight = this.highlight.createColumnHighlight();
|
645
|
+
const areaHighlight = this.highlight.createOrGetArea();
|
646
|
+
const headerHighlight = this.highlight.createOrGetHeader();
|
647
|
+
const activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
|
776
648
|
areaHighlight.commit();
|
777
|
-
|
778
|
-
|
779
|
-
columnHeaderHighlight.commit();
|
780
|
-
activeRowHeaderHighlight.commit();
|
781
|
-
activeColumnHeaderHighlight.commit();
|
782
|
-
activeCornerHeaderHighlight.commit();
|
783
|
-
rowHighlight.commit();
|
784
|
-
columnHighlight.commit();
|
649
|
+
headerHighlight.commit();
|
650
|
+
activeHeaderHighlight.commit();
|
785
651
|
}
|
786
652
|
|
787
653
|
// Reverting starting layer for the Highlight.
|