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