handsontable 0.0.0-next-be16baf-20230809 → 0.0.0-next-912c214-20230818
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +293 -176
- package/core.mjs +293 -176
- package/dataMap/metaManager/metaSchema.js +0 -41
- package/dataMap/metaManager/metaSchema.mjs +0 -41
- package/dist/handsontable.css +4 -24
- package/dist/handsontable.full.css +4 -24
- package/dist/handsontable.full.js +5592 -8690
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +25 -25
- package/dist/handsontable.js +8038 -11136
- 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/baseEditor/baseEditor.d.ts +1 -0
- 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 +10 -14
- package/plugins/copyPaste/copyPaste.mjs +10 -14
- 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/manualColumnResize/manualColumnResize.js +6 -0
- package/plugins/manualColumnResize/manualColumnResize.mjs +7 -1
- package/plugins/mergeCells/mergeCells.js +17 -5
- package/plugins/mergeCells/mergeCells.mjs +17 -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 -293
- package/selection/selection.mjs +153 -290
- 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
|
-
|
337
|
-
|
338
|
-
|
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();
|
294
|
+
}
|
295
|
+
if (areAnyRowsRendered) {
|
296
|
+
headerCellRange.from.row = -1;
|
343
297
|
}
|
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();
|
298
|
+
if (areAnyColumnsRendered) {
|
299
|
+
headerCellRange.from.col = -1;
|
348
300
|
}
|
349
|
-
if (
|
350
|
-
|
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();
|
351
308
|
}
|
352
|
-
if (
|
353
|
-
|
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,50 +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} | false} [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
|
-
var _this$getSelectedRang;
|
572
514
|
let includeRowHeaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
573
515
|
let includeColumnHeaders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
574
|
-
let focusPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
575
516
|
const nrOfRows = this.tableProps.countRows();
|
576
517
|
const nrOfColumns = this.tableProps.countCols();
|
577
|
-
const countRowHeaders = this.tableProps.countRowHeaders();
|
578
|
-
const countColHeaders = this.tableProps.countColHeaders();
|
579
|
-
const rowFrom = includeRowHeaders ? -countColHeaders : 0;
|
580
|
-
const columnFrom = includeColumnHeaders ? -countRowHeaders : 0;
|
581
518
|
|
582
519
|
// We can't select cells when there is no data.
|
583
|
-
if (
|
520
|
+
if (!includeRowHeaders && !includeColumnHeaders && (nrOfRows === 0 || nrOfColumns === 0)) {
|
584
521
|
return;
|
585
522
|
}
|
586
|
-
|
587
|
-
let isSelectedByCorner = false;
|
588
|
-
if (focusPosition && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.row) && Number.isInteger(focusPosition === null || focusPosition === void 0 ? void 0 : focusPosition.col)) {
|
589
|
-
isSelectedByCorner = focusPosition.row < 0 && focusPosition.col < 0;
|
590
|
-
highlight = this.tableProps.createCellCoords(clamp(focusPosition.row, rowFrom, nrOfRows - 1), clamp(focusPosition.col, columnFrom, nrOfColumns - 1));
|
591
|
-
}
|
592
|
-
const startCoords = this.tableProps.createCellCoords(rowFrom, columnFrom);
|
523
|
+
const startCoords = this.tableProps.createCellCoords(includeColumnHeaders ? -1 : 0, includeRowHeaders ? -1 : 0);
|
593
524
|
const endCoords = this.tableProps.createCellCoords(nrOfRows - 1, nrOfColumns - 1);
|
594
525
|
this.clear();
|
595
|
-
this.setRangeStartOnly(startCoords
|
596
|
-
|
597
|
-
|
598
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
599
|
-
} else if (columnFrom < 0) {
|
600
|
-
this.selectedByRowHeader.add(this.getLayerLevel());
|
601
|
-
} else if (rowFrom < 0) {
|
602
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
603
|
-
}
|
526
|
+
this.setRangeStartOnly(startCoords);
|
527
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
528
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
604
529
|
this.setRangeEnd(endCoords);
|
605
530
|
this.finish();
|
606
531
|
}
|
@@ -627,29 +552,21 @@ class Selection {
|
|
627
552
|
propToCol: prop => this.tableProps.propToCol(prop),
|
628
553
|
keepDirection: true
|
629
554
|
});
|
630
|
-
const
|
631
|
-
const
|
632
|
-
countRows: this.tableProps.countRows(),
|
633
|
-
countCols: this.tableProps.countCols(),
|
634
|
-
countRowHeaders: navigableHeaders ? this.tableProps.countRowHeaders() : 0,
|
635
|
-
countColHeaders: navigableHeaders ? this.tableProps.countColHeaders() : 0
|
636
|
-
};
|
555
|
+
const nrOfRows = this.tableProps.countRows();
|
556
|
+
const nrOfColumns = this.tableProps.countCols();
|
637
557
|
|
638
558
|
// Check if every layer of the coordinates are valid.
|
639
559
|
const isValid = !selectionRanges.some(selection => {
|
640
|
-
const
|
641
|
-
const
|
642
|
-
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;
|
643
563
|
});
|
644
564
|
if (isValid) {
|
645
565
|
this.clear();
|
646
566
|
arrayEach(selectionRanges, selection => {
|
647
|
-
const
|
648
|
-
|
649
|
-
|
650
|
-
} = selectionSchemaNormalizer(selection);
|
651
|
-
this.setRangeStartOnly(from.clone(), false);
|
652
|
-
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));
|
653
570
|
this.finish();
|
654
571
|
});
|
655
572
|
}
|
@@ -662,43 +579,22 @@ class Selection {
|
|
662
579
|
*
|
663
580
|
* @param {number|string} startColumn Visual column index or column property from which the selection starts.
|
664
581
|
* @param {number|string} [endColumn] Visual column index or column property from to the selection finishes.
|
665
|
-
* @param {number} [
|
666
|
-
*
|
667
|
-
*
|
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
|
+
*
|
668
585
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
669
586
|
*/
|
670
587
|
selectColumns(startColumn) {
|
671
588
|
let endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
|
672
|
-
let
|
589
|
+
let headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
673
590
|
const start = typeof startColumn === 'string' ? this.tableProps.propToCol(startColumn) : startColumn;
|
674
591
|
const end = typeof endColumn === 'string' ? this.tableProps.propToCol(endColumn) : endColumn;
|
675
|
-
const
|
676
|
-
const
|
677
|
-
const
|
678
|
-
const columnHeaderLastIndex = countColHeaders === 0 ? 0 : -countColHeaders;
|
679
|
-
const fromCoords = new CellCoords(columnHeaderLastIndex, start);
|
680
|
-
const toCoords = new CellCoords(countRows - 1, end);
|
681
|
-
const isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
|
682
|
-
countRows,
|
683
|
-
countCols,
|
684
|
-
countRowHeaders: 0,
|
685
|
-
countColHeaders
|
686
|
-
});
|
592
|
+
const nrOfColumns = this.tableProps.countCols();
|
593
|
+
const nrOfRows = this.tableProps.countRows();
|
594
|
+
const isValid = isValidCoord(start, nrOfColumns) && isValidCoord(end, nrOfColumns);
|
687
595
|
if (isValid) {
|
688
|
-
|
689
|
-
|
690
|
-
const from = this.tableProps.createCellCoords(fromRow, start);
|
691
|
-
const to = this.tableProps.createCellCoords(toRow, end);
|
692
|
-
const highlight = this.tableProps.createCellCoords(clamp(focusPosition, columnHeaderLastIndex, countRows - 1), start);
|
693
|
-
this.runLocalHooks('beforeSelectColumns', from, to, highlight);
|
694
|
-
|
695
|
-
// disallow modifying row axis for that hooks
|
696
|
-
from.row = fromRow;
|
697
|
-
to.row = toRow;
|
698
|
-
this.setRangeStartOnly(from, void 0, highlight);
|
699
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
700
|
-
this.setRangeEnd(to);
|
701
|
-
this.runLocalHooks('afterSelectColumns', from, to, highlight);
|
596
|
+
this.setRangeStartOnly(this.tableProps.createCellCoords(headerLevel, start));
|
597
|
+
this.setRangeEnd(this.tableProps.createCellCoords(nrOfRows - 1, end));
|
702
598
|
this.finish();
|
703
599
|
}
|
704
600
|
return isValid;
|
@@ -709,41 +605,20 @@ class Selection {
|
|
709
605
|
*
|
710
606
|
* @param {number} startRow Visual row index from which the selection starts.
|
711
607
|
* @param {number} [endRow] Visual row index from to the selection finishes.
|
712
|
-
* @param {number} [
|
713
|
-
*
|
714
|
-
*
|
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.
|
715
611
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
716
612
|
*/
|
717
613
|
selectRows(startRow) {
|
718
614
|
let endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
|
719
|
-
let
|
720
|
-
const
|
721
|
-
const
|
722
|
-
const
|
723
|
-
const rowHeaderLastIndex = countRowHeaders === 0 ? 0 : -countRowHeaders;
|
724
|
-
const fromCoords = new CellCoords(startRow, rowHeaderLastIndex);
|
725
|
-
const toCoords = new CellCoords(endRow, countCols - 1);
|
726
|
-
const isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
|
727
|
-
countRows,
|
728
|
-
countCols,
|
729
|
-
countRowHeaders,
|
730
|
-
countColHeaders: 0
|
731
|
-
});
|
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);
|
732
619
|
if (isValid) {
|
733
|
-
|
734
|
-
|
735
|
-
const from = this.tableProps.createCellCoords(startRow, fromColumn);
|
736
|
-
const to = this.tableProps.createCellCoords(endRow, toColumn);
|
737
|
-
const highlight = this.tableProps.createCellCoords(startRow, clamp(focusPosition, rowHeaderLastIndex, countCols - 1));
|
738
|
-
this.runLocalHooks('beforeSelectRows', from, to, highlight);
|
739
|
-
|
740
|
-
// disallow modifying column axis for that hooks
|
741
|
-
from.col = fromColumn;
|
742
|
-
to.col = toColumn;
|
743
|
-
this.setRangeStartOnly(from, void 0, highlight);
|
744
|
-
this.selectedByRowHeader.add(this.getLayerLevel());
|
745
|
-
this.setRangeEnd(to);
|
746
|
-
this.runLocalHooks('afterSelectRows', from, to, highlight);
|
620
|
+
this.setRangeStartOnly(this.tableProps.createCellCoords(startRow, headerLevel));
|
621
|
+
this.setRangeEnd(this.tableProps.createCellCoords(endRow, nrOfColumns - 1));
|
747
622
|
this.finish();
|
748
623
|
}
|
749
624
|
return isValid;
|
@@ -760,31 +635,19 @@ class Selection {
|
|
760
635
|
if (!this.isSelected()) {
|
761
636
|
return;
|
762
637
|
}
|
763
|
-
const
|
638
|
+
const cellHighlight = this.highlight.getCell();
|
764
639
|
const currentLayer = this.getLayerLevel();
|
765
|
-
|
640
|
+
cellHighlight.commit().syncWith(this.selectedRange.current());
|
766
641
|
|
767
642
|
// Rewriting rendered ranges going through all layers.
|
768
643
|
for (let layerLevel = 0; layerLevel < this.selectedRange.size(); layerLevel += 1) {
|
769
644
|
this.highlight.useLayerLevel(layerLevel);
|
770
|
-
const areaHighlight = this.highlight.
|
771
|
-
const
|
772
|
-
const
|
773
|
-
const columnHeaderHighlight = this.highlight.createColumnHeader();
|
774
|
-
const activeRowHeaderHighlight = this.highlight.createActiveRowHeader();
|
775
|
-
const activeColumnHeaderHighlight = this.highlight.createActiveColumnHeader();
|
776
|
-
const activeCornerHeaderHighlight = this.highlight.createActiveCornerHeader();
|
777
|
-
const rowHighlight = this.highlight.createRowHighlight();
|
778
|
-
const columnHighlight = this.highlight.createColumnHighlight();
|
645
|
+
const areaHighlight = this.highlight.createOrGetArea();
|
646
|
+
const headerHighlight = this.highlight.createOrGetHeader();
|
647
|
+
const activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
|
779
648
|
areaHighlight.commit();
|
780
|
-
|
781
|
-
|
782
|
-
columnHeaderHighlight.commit();
|
783
|
-
activeRowHeaderHighlight.commit();
|
784
|
-
activeColumnHeaderHighlight.commit();
|
785
|
-
activeCornerHeaderHighlight.commit();
|
786
|
-
rowHighlight.commit();
|
787
|
-
columnHighlight.commit();
|
649
|
+
headerHighlight.commit();
|
650
|
+
activeHeaderHighlight.commit();
|
788
651
|
}
|
789
652
|
|
790
653
|
// Reverting starting layer for the Highlight.
|