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