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.js
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
5
|
-
var
|
6
|
-
var
|
5
|
+
var _src = require("./../3rdparty/walkontable/src");
|
6
|
+
var _highlight = _interopRequireWildcard(require("./highlight/highlight"));
|
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");
|
10
11
|
var _array = require("./../helpers/array");
|
11
12
|
var _localHooks = _interopRequireDefault(require("./../mixins/localHooks"));
|
12
13
|
var _transformation = _interopRequireDefault(require("./transformation"));
|
13
14
|
var _utils = require("./utils");
|
14
15
|
var _templateLiteralTag = require("./../helpers/templateLiteralTag");
|
15
16
|
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); }
|
16
22
|
/**
|
17
23
|
* @class Selection
|
18
24
|
* @util
|
@@ -25,57 +31,62 @@ class Selection {
|
|
25
31
|
*
|
26
32
|
* @type {GridSettings}
|
27
33
|
*/
|
28
|
-
this
|
34
|
+
_defineProperty(this, "settings", void 0);
|
29
35
|
/**
|
30
36
|
* An additional object with dynamically defined properties which describes table state.
|
31
37
|
*
|
32
38
|
* @type {object}
|
33
39
|
*/
|
34
|
-
this
|
40
|
+
_defineProperty(this, "tableProps", void 0);
|
35
41
|
/**
|
36
42
|
* The flag which determines if the selection is in progress.
|
37
43
|
*
|
38
44
|
* @type {boolean}
|
39
45
|
*/
|
40
|
-
this
|
46
|
+
_defineProperty(this, "inProgress", false);
|
41
47
|
/**
|
42
|
-
*
|
48
|
+
* Selection data layer (handle visual coordinates).
|
43
49
|
*
|
44
|
-
* @type {
|
50
|
+
* @type {SelectionRange}
|
45
51
|
*/
|
46
|
-
this.
|
52
|
+
_defineProperty(this, "selectedRange", new _range.default((highlight, from, to) => {
|
53
|
+
return this.tableProps.createCellRange(highlight, from, to);
|
54
|
+
}));
|
47
55
|
/**
|
48
|
-
*
|
49
|
-
* the corner header.
|
56
|
+
* Visualization layer.
|
50
57
|
*
|
51
|
-
* @type {
|
58
|
+
* @type {Highlight}
|
52
59
|
*/
|
53
|
-
this
|
60
|
+
_defineProperty(this, "highlight", void 0);
|
54
61
|
/**
|
55
|
-
* The
|
56
|
-
* the corner header.
|
62
|
+
* The module for modifying coordinates.
|
57
63
|
*
|
58
|
-
* @type {
|
64
|
+
* @type {Transformation}
|
59
65
|
*/
|
60
|
-
this
|
66
|
+
_defineProperty(this, "transformation", void 0);
|
61
67
|
/**
|
62
|
-
*
|
68
|
+
* The collection of the selection layer levels where the whole row was selected using the row header or
|
69
|
+
* the corner header.
|
63
70
|
*
|
64
|
-
* @type {
|
71
|
+
* @type {Set<number>}
|
65
72
|
*/
|
66
|
-
this
|
67
|
-
return this.tableProps.createCellRange(highlight, from, to);
|
68
|
-
});
|
73
|
+
_defineProperty(this, "selectedByRowHeader", new Set());
|
69
74
|
/**
|
70
|
-
*
|
75
|
+
* The collection of the selection layer levels where the whole column was selected using the column header or
|
76
|
+
* the corner header.
|
71
77
|
*
|
72
|
-
* @type {
|
78
|
+
* @type {Set<number>}
|
73
79
|
*/
|
80
|
+
_defineProperty(this, "selectedByColumnHeader", new Set());
|
81
|
+
this.settings = settings;
|
82
|
+
this.tableProps = tableProps;
|
74
83
|
this.highlight = new _highlight.default({
|
75
84
|
headerClassName: settings.currentHeaderClassName,
|
76
85
|
activeHeaderClassName: settings.activeHeaderClassName,
|
77
86
|
rowClassName: settings.currentRowClassName,
|
78
87
|
columnClassName: settings.currentColClassName,
|
88
|
+
rowIndexMapper: this.tableProps.rowIndexMapper,
|
89
|
+
columnIndexMapper: this.tableProps.columnIndexMapper,
|
79
90
|
disabledCellSelection: (row, column) => this.tableProps.isDisabledCellSelection(row, column),
|
80
91
|
cellCornerVisible: function () {
|
81
92
|
return _this.isCellCornerVisible(...arguments);
|
@@ -86,21 +97,19 @@ class Selection {
|
|
86
97
|
visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
|
87
98
|
renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
|
88
99
|
createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
|
89
|
-
createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to)
|
90
|
-
rowIndexMapper: () => this.tableProps.rowIndexMapper(),
|
91
|
-
columnIndexMapper: () => this.tableProps.columnIndexMapper()
|
100
|
+
createCellRange: (highlight, from, to) => this.tableProps.createCellRange(highlight, from, to)
|
92
101
|
});
|
93
|
-
/**
|
94
|
-
* The module for modifying coordinates.
|
95
|
-
*
|
96
|
-
* @type {Transformation}
|
97
|
-
*/
|
98
102
|
this.transformation = new _transformation.default(this.selectedRange, {
|
99
|
-
|
100
|
-
|
103
|
+
rowIndexMapper: this.tableProps.rowIndexMapper,
|
104
|
+
columnIndexMapper: this.tableProps.columnIndexMapper,
|
105
|
+
countRenderableRows: () => this.tableProps.countRenderableRows(),
|
106
|
+
countRenderableColumns: () => this.tableProps.countRenderableColumns(),
|
107
|
+
countRowHeaders: () => this.tableProps.countRowHeaders(),
|
108
|
+
countColHeaders: () => this.tableProps.countColHeaders(),
|
101
109
|
visualToRenderableCoords: coords => this.tableProps.visualToRenderableCoords(coords),
|
102
110
|
renderableToVisualCoords: coords => this.tableProps.renderableToVisualCoords(coords),
|
103
111
|
createCellCoords: (row, column) => this.tableProps.createCellCoords(row, column),
|
112
|
+
navigableHeaders: () => settings.navigableHeaders,
|
104
113
|
fixedRowsBottom: () => settings.fixedRowsBottom,
|
105
114
|
minSpareRows: () => settings.minSpareRows,
|
106
115
|
minSpareCols: () => settings.minSpareCols,
|
@@ -155,14 +164,14 @@ class Selection {
|
|
155
164
|
}
|
156
165
|
|
157
166
|
/**
|
158
|
-
* Indicate that selection process began. It sets
|
167
|
+
* Indicate that selection process began. It sets internally `.inProgress` property to `true`.
|
159
168
|
*/
|
160
169
|
begin() {
|
161
170
|
this.inProgress = true;
|
162
171
|
}
|
163
172
|
|
164
173
|
/**
|
165
|
-
* Indicate that selection process finished. It sets
|
174
|
+
* Indicate that selection process finished. It sets internally `.inProgress` property to `false`.
|
166
175
|
*/
|
167
176
|
finish() {
|
168
177
|
this.runLocalHooks('afterSelectionFinished', Array.from(this.selectedRange));
|
@@ -187,33 +196,25 @@ class Selection {
|
|
187
196
|
* the default trigger will be used.
|
188
197
|
* @param {boolean} [fragment=false] If `true`, the selection will be treated as a partial selection where the
|
189
198
|
* `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.
|
190
200
|
*/
|
191
201
|
setRangeStart(coords, multipleSelection) {
|
192
202
|
let fragment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
203
|
+
let highlightCoords = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : coords;
|
193
204
|
const isMultipleMode = this.settings.selectionMode === 'multiple';
|
194
205
|
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;
|
198
206
|
// We are creating copy. We would like to modify just the start of the selection by below hook. Then original coords
|
199
207
|
// should be handled by next methods.
|
200
208
|
const coordsClone = coords.clone();
|
201
|
-
this.selectedByCorner = selectedByCorner;
|
202
209
|
this.runLocalHooks(`beforeSetRangeStart${fragment ? 'Only' : ''}`, coordsClone);
|
203
210
|
if (!isMultipleMode || isMultipleMode && !isMultipleSelection && (0, _mixed.isUndefined)(multipleSelection)) {
|
204
211
|
this.selectedRange.clear();
|
205
212
|
}
|
206
|
-
this.selectedRange.add(coordsClone);
|
213
|
+
this.selectedRange.add(coordsClone).current().setHighlight(highlightCoords.clone());
|
207
214
|
if (this.getLayerLevel() === 0) {
|
208
215
|
this.selectedByRowHeader.clear();
|
209
216
|
this.selectedByColumnHeader.clear();
|
210
217
|
}
|
211
|
-
if (!selectedByCorner && isColumnNegative) {
|
212
|
-
this.selectedByRowHeader.add(this.getLayerLevel());
|
213
|
-
}
|
214
|
-
if (!selectedByCorner && isRowNegative) {
|
215
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
216
|
-
}
|
217
218
|
if (!fragment) {
|
218
219
|
this.setRangeEnd(coords);
|
219
220
|
}
|
@@ -226,9 +227,11 @@ class Selection {
|
|
226
227
|
* @param {boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
|
227
228
|
* only when 'selectionMode' is set as 'multiple'. If the argument is not defined
|
228
229
|
* the default trigger will be used.
|
230
|
+
* @param {CellCoords} [highlightCoords] If set, allows changing the coordinates of the highlight/focus cell.
|
229
231
|
*/
|
230
232
|
setRangeStartOnly(coords, multipleSelection) {
|
231
|
-
|
233
|
+
let highlightCoords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : coords;
|
234
|
+
this.setRangeStart(coords, multipleSelection, true, highlightCoords);
|
232
235
|
}
|
233
236
|
|
234
237
|
/**
|
@@ -240,21 +243,39 @@ class Selection {
|
|
240
243
|
if (this.selectedRange.isEmpty()) {
|
241
244
|
return;
|
242
245
|
}
|
243
|
-
|
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
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
|
+
|
251
|
+
// Ignore processing the end range when the header selection starts overlapping the corner and
|
252
|
+
// the selection is not a single header highlight.
|
253
|
+
if ((countRows > 0 || countCols > 0) && (countRows === 0 && coordsClone.col < 0 && !isSingle || countCols === 0 && coordsClone.row < 0 && !isSingle)) {
|
254
|
+
return;
|
255
|
+
}
|
247
256
|
this.runLocalHooks('beforeSetRangeEnd', coordsClone);
|
248
257
|
this.begin();
|
249
258
|
const cellRange = this.selectedRange.current();
|
250
|
-
if (this.settings.
|
251
|
-
cellRange.
|
259
|
+
if (!this.settings.navigableHeaders) {
|
260
|
+
cellRange.highlight.normalize();
|
261
|
+
}
|
262
|
+
if (this.settings.selectionMode === 'single') {
|
263
|
+
cellRange.setFrom(cellRange.highlight);
|
264
|
+
cellRange.setTo(cellRange.highlight);
|
265
|
+
} else {
|
266
|
+
cellRange.setTo(coordsClone);
|
252
267
|
}
|
253
268
|
|
254
|
-
//
|
255
|
-
|
256
|
-
|
257
|
-
|
269
|
+
// Prevent creating "area" selection that overlaps headers.
|
270
|
+
if (countRows > 0 && countCols > 0) {
|
271
|
+
if (!this.settings.navigableHeaders || this.settings.navigableHeaders && !cellRange.isSingleHeader()) {
|
272
|
+
cellRange.to.normalize();
|
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);
|
258
279
|
}
|
259
280
|
const layerLevel = this.getLayerLevel();
|
260
281
|
|
@@ -262,69 +283,80 @@ class Selection {
|
|
262
283
|
// indication that the new selection is performing.
|
263
284
|
if (layerLevel < this.highlight.layerLevel) {
|
264
285
|
(0, _array.arrayEach)(this.highlight.getAreas(), highlight => void highlight.clear());
|
265
|
-
(0, _array.arrayEach)(this.highlight.
|
266
|
-
(0, _array.arrayEach)(this.highlight.
|
286
|
+
(0, _array.arrayEach)(this.highlight.getLayeredAreas(), highlight => void highlight.clear());
|
287
|
+
(0, _array.arrayEach)(this.highlight.getRowHeaders(), highlight => void highlight.clear());
|
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());
|
267
294
|
}
|
268
295
|
this.highlight.useLayerLevel(layerLevel);
|
269
|
-
const areaHighlight = this.highlight.
|
270
|
-
const
|
271
|
-
const
|
296
|
+
const areaHighlight = this.highlight.createArea();
|
297
|
+
const layeredAreaHighlight = this.highlight.createLayeredArea();
|
298
|
+
const rowHeaderHighlight = this.highlight.createRowHeader();
|
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();
|
272
305
|
areaHighlight.clear();
|
273
|
-
|
274
|
-
|
275
|
-
|
306
|
+
layeredAreaHighlight.clear();
|
307
|
+
rowHeaderHighlight.clear();
|
308
|
+
columnHeaderHighlight.clear();
|
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)) {
|
276
315
|
areaHighlight.add(cellRange.from).add(cellRange.to).commit();
|
316
|
+
layeredAreaHighlight.add(cellRange.from).add(cellRange.to).commit();
|
277
317
|
if (layerLevel === 1) {
|
278
318
|
// For single cell selection in the same layer, we do not create area selection to prevent blue background.
|
279
319
|
// When non-consecutive selection is performed we have to add that missing area selection to the previous layer
|
280
320
|
// based on previous coordinates. It only occurs when the previous selection wasn't select multiple cells.
|
281
321
|
const previousRange = this.selectedRange.previous();
|
282
|
-
this.highlight.useLayerLevel(layerLevel - 1)
|
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()
|
283
327
|
// Range may start with hidden indexes. Commit would not found start point (as we add just the `from` coords).
|
284
328
|
.syncWith(previousRange);
|
285
329
|
this.highlight.useLayerLevel(layerLevel);
|
286
330
|
}
|
287
331
|
}
|
288
|
-
if (this.highlight.isEnabledFor(
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
}
|
305
|
-
if (this.settings.selectionMode === 'single') {
|
306
|
-
if (this.isSelectedByAnyHeader()) {
|
307
|
-
headerCellRange.from.normalize();
|
332
|
+
if (this.highlight.isEnabledFor(_highlight.HEADER_TYPE, cellRange.highlight)) {
|
333
|
+
if (!cellRange.isSingleHeader()) {
|
334
|
+
const rowCoordsFrom = this.tableProps.createCellCoords(Math.max(cellRange.from.row, 0), -1);
|
335
|
+
const rowCoordsTo = this.tableProps.createCellCoords(cellRange.to.row, -1);
|
336
|
+
const columnCoordsFrom = this.tableProps.createCellCoords(-1, Math.max(cellRange.from.col, 0));
|
337
|
+
const columnCoordsTo = this.tableProps.createCellCoords(-1, cellRange.to.col);
|
338
|
+
if (this.settings.selectionMode === 'single') {
|
339
|
+
rowHeaderHighlight.add(rowCoordsFrom).commit();
|
340
|
+
columnHeaderHighlight.add(columnCoordsFrom).commit();
|
341
|
+
rowHighlight.add(rowCoordsFrom).commit();
|
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();
|
308
348
|
}
|
309
|
-
headerHighlight.add(headerCellRange.from).commit();
|
310
|
-
} else {
|
311
|
-
headerHighlight.add(headerCellRange.from).add(headerCellRange.to).commit();
|
312
349
|
}
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
if (isRowSelected) {
|
318
|
-
activeHeaderHighlight.add(this.tableProps.createCellCoords(cellRange.from.row, -1)).add(this.tableProps.createCellCoords(cellRange.to.row, -1)).commit();
|
319
|
-
}
|
350
|
+
const highlightRowHeaders = this.isEntireRowSelected() && (countCols > 0 && countCols === cellRange.getWidth() || countCols === 0 && (this.isSelectedByRowHeader() || this.isSelectedByCorner()));
|
351
|
+
const highlightColumnHeaders = this.isEntireColumnSelected() && (countRows > 0 && countRows === cellRange.getHeight() || countRows === 0 && (this.isSelectedByColumnHeader() || this.isSelectedByCorner()));
|
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();
|
320
354
|
}
|
321
|
-
if (
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
activeHeaderHighlight.add(this.tableProps.createCellCoords(-1, cellRange.from.col)).add(this.tableProps.createCellCoords(-1, cellRange.to.col)).commit();
|
327
|
-
}
|
355
|
+
if (highlightColumnHeaders) {
|
356
|
+
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();
|
357
|
+
}
|
358
|
+
if (highlightRowHeaders && highlightColumnHeaders) {
|
359
|
+
activeCornerHeaderHighlight.add(this.tableProps.createCellCoords(-this.tableProps.countColHeaders(), -this.tableProps.countRowHeaders())).add(this.tableProps.createCellCoords(-1, -1)).commit();
|
328
360
|
}
|
329
361
|
}
|
330
362
|
this.runLocalHooks('afterSetRangeEnd', coords);
|
@@ -347,12 +379,12 @@ class Selection {
|
|
347
379
|
*
|
348
380
|
* @param {number} rowDelta Rows number to move, value can be passed as negative number.
|
349
381
|
* @param {number} colDelta Columns number to move, value can be passed as negative number.
|
350
|
-
* @param {boolean} [
|
351
|
-
*
|
382
|
+
* @param {boolean} [createMissingRecords=false] If `true` the new rows/columns will be created if necessary.
|
383
|
+
* Otherwise, row/column will be created according to `minSpareRows/minSpareCols` settings of Handsontable.
|
352
384
|
*/
|
353
385
|
transformStart(rowDelta, colDelta) {
|
354
|
-
let
|
355
|
-
this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta,
|
386
|
+
let createMissingRecords = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
387
|
+
this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, createMissingRecords));
|
356
388
|
}
|
357
389
|
|
358
390
|
/**
|
@@ -393,7 +425,7 @@ class Selection {
|
|
393
425
|
*/
|
394
426
|
isSelectedByRowHeader() {
|
395
427
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
396
|
-
return !this.isSelectedByCorner(layerLevel) && this.
|
428
|
+
return !this.isSelectedByCorner(layerLevel) && (layerLevel === -1 ? this.selectedByRowHeader.size > 0 : this.selectedByRowHeader.has(layerLevel));
|
397
429
|
}
|
398
430
|
|
399
431
|
/**
|
@@ -405,7 +437,19 @@ class Selection {
|
|
405
437
|
*/
|
406
438
|
isEntireRowSelected() {
|
407
439
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
408
|
-
|
440
|
+
const tester = range => {
|
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;
|
409
453
|
}
|
410
454
|
|
411
455
|
/**
|
@@ -418,7 +462,7 @@ class Selection {
|
|
418
462
|
*/
|
419
463
|
isSelectedByColumnHeader() {
|
420
464
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
421
|
-
return !this.isSelectedByCorner() && this.
|
465
|
+
return !this.isSelectedByCorner() && (layerLevel === -1 ? this.selectedByColumnHeader.size > 0 : this.selectedByColumnHeader.has(layerLevel));
|
422
466
|
}
|
423
467
|
|
424
468
|
/**
|
@@ -430,7 +474,19 @@ class Selection {
|
|
430
474
|
*/
|
431
475
|
isEntireColumnSelected() {
|
432
476
|
let layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
433
|
-
|
477
|
+
const tester = range => {
|
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;
|
434
490
|
}
|
435
491
|
|
436
492
|
/**
|
@@ -448,7 +504,7 @@ class Selection {
|
|
448
504
|
* @returns {boolean}
|
449
505
|
*/
|
450
506
|
isSelectedByCorner() {
|
451
|
-
return this.
|
507
|
+
return this.selectedByColumnHeader.has(this.getLayerLevel()) && this.selectedByRowHeader.has(this.getLayerLevel());
|
452
508
|
}
|
453
509
|
|
454
510
|
/**
|
@@ -507,29 +563,47 @@ class Selection {
|
|
507
563
|
}
|
508
564
|
|
509
565
|
/**
|
510
|
-
*
|
566
|
+
* Selects all cells and headers.
|
511
567
|
*
|
512
|
-
* @param {boolean} [includeRowHeaders=false] `true` If the selection should include the row headers,
|
513
|
-
* otherwise.
|
514
|
-
* @param {boolean} [includeColumnHeaders=false] `true` If the selection should include the column
|
515
|
-
* otherwise.
|
568
|
+
* @param {boolean} [includeRowHeaders=false] `true` If the selection should include the row headers,
|
569
|
+
* `false` otherwise.
|
570
|
+
* @param {boolean} [includeColumnHeaders=false] `true` If the selection should include the column
|
571
|
+
* headers, `false` otherwise.
|
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.
|
516
575
|
*/
|
517
576
|
selectAll() {
|
518
577
|
let includeRowHeaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
519
578
|
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
|
+
};
|
520
583
|
const nrOfRows = this.tableProps.countRows();
|
521
584
|
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;
|
522
589
|
|
523
590
|
// We can't select cells when there is no data.
|
524
|
-
if (
|
591
|
+
if (rowFrom === 0 && columnFrom === 0 && (nrOfRows === 0 || nrOfColumns === 0)) {
|
525
592
|
return;
|
526
593
|
}
|
527
|
-
const
|
594
|
+
const highlightRow = Number.isInteger(focusPosition.row) ? focusPosition.row : 0;
|
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));
|
528
598
|
const endCoords = this.tableProps.createCellCoords(nrOfRows - 1, nrOfColumns - 1);
|
529
599
|
this.clear();
|
530
|
-
this.setRangeStartOnly(startCoords);
|
531
|
-
|
532
|
-
|
600
|
+
this.setRangeStartOnly(startCoords, void 0, highlight);
|
601
|
+
if (columnFrom < 0) {
|
602
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
603
|
+
}
|
604
|
+
if (rowFrom < 0) {
|
605
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
606
|
+
}
|
533
607
|
this.setRangeEnd(endCoords);
|
534
608
|
this.finish();
|
535
609
|
}
|
@@ -556,21 +630,29 @@ class Selection {
|
|
556
630
|
propToCol: prop => this.tableProps.propToCol(prop),
|
557
631
|
keepDirection: true
|
558
632
|
});
|
559
|
-
const
|
560
|
-
const
|
633
|
+
const navigableHeaders = this.settings.navigableHeaders;
|
634
|
+
const tableParams = {
|
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
|
+
};
|
561
640
|
|
562
641
|
// Check if every layer of the coordinates are valid.
|
563
642
|
const isValid = !selectionRanges.some(selection => {
|
564
|
-
const
|
565
|
-
const
|
566
|
-
return !
|
643
|
+
const cellRange = selectionSchemaNormalizer(selection);
|
644
|
+
const rangeValidity = cellRange.isValid(tableParams);
|
645
|
+
return !(rangeValidity && !cellRange.containsHeaders() || rangeValidity && cellRange.containsHeaders() && cellRange.isSingleHeader());
|
567
646
|
});
|
568
647
|
if (isValid) {
|
569
648
|
this.clear();
|
570
649
|
(0, _array.arrayEach)(selectionRanges, selection => {
|
571
|
-
const
|
572
|
-
|
573
|
-
|
650
|
+
const {
|
651
|
+
from,
|
652
|
+
to
|
653
|
+
} = selectionSchemaNormalizer(selection);
|
654
|
+
this.setRangeStartOnly(from.clone(), false);
|
655
|
+
this.setRangeEnd(to.clone());
|
574
656
|
this.finish();
|
575
657
|
});
|
576
658
|
}
|
@@ -583,22 +665,43 @@ class Selection {
|
|
583
665
|
*
|
584
666
|
* @param {number|string} startColumn Visual column index or column property from which the selection starts.
|
585
667
|
* @param {number|string} [endColumn] Visual column index or column property from to the selection finishes.
|
586
|
-
* @param {number} [
|
587
|
-
*
|
588
|
-
*
|
668
|
+
* @param {number} [focusPosition=0] The argument allows changing the cell/header focus position.
|
669
|
+
* The value can take visual row index from -N to N, where negative values
|
670
|
+
* point to the headers and positive values point to the cell range.
|
589
671
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
590
672
|
*/
|
591
673
|
selectColumns(startColumn) {
|
592
674
|
let endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
|
593
|
-
let
|
675
|
+
let focusPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
594
676
|
const start = typeof startColumn === 'string' ? this.tableProps.propToCol(startColumn) : startColumn;
|
595
677
|
const end = typeof endColumn === 'string' ? this.tableProps.propToCol(endColumn) : endColumn;
|
596
|
-
const
|
597
|
-
const
|
598
|
-
const
|
678
|
+
const countRows = this.tableProps.countRows();
|
679
|
+
const countCols = this.tableProps.countCols();
|
680
|
+
const countColHeaders = this.tableProps.countColHeaders();
|
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
|
+
});
|
599
690
|
if (isValid) {
|
600
|
-
|
601
|
-
|
691
|
+
const fromRow = countColHeaders === 0 ? 0 : (0, _number.clamp)(focusPosition, columnHeaderLastIndex, -1);
|
692
|
+
const toRow = countRows - 1;
|
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);
|
602
705
|
this.finish();
|
603
706
|
}
|
604
707
|
return isValid;
|
@@ -609,20 +712,41 @@ class Selection {
|
|
609
712
|
*
|
610
713
|
* @param {number} startRow Visual row index from which the selection starts.
|
611
714
|
* @param {number} [endRow] Visual row index from to the selection finishes.
|
612
|
-
* @param {number} [
|
613
|
-
*
|
614
|
-
*
|
715
|
+
* @param {number} [focusPosition=0] The argument allows changing the cell/header focus position.
|
716
|
+
* The value can take visual column index from -N to N, where negative values
|
717
|
+
* point to the headers and positive values point to the cell range.
|
615
718
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
616
719
|
*/
|
617
720
|
selectRows(startRow) {
|
618
721
|
let endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
|
619
|
-
let
|
620
|
-
const
|
621
|
-
const
|
622
|
-
const
|
722
|
+
let focusPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
723
|
+
const countRows = this.tableProps.countRows();
|
724
|
+
const countCols = this.tableProps.countCols();
|
725
|
+
const countRowHeaders = this.tableProps.countRowHeaders();
|
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
|
+
});
|
623
735
|
if (isValid) {
|
624
|
-
|
625
|
-
|
736
|
+
const fromColumn = countRowHeaders === 0 ? 0 : (0, _number.clamp)(focusPosition, rowHeaderLastIndex, -1);
|
737
|
+
const toColumn = countCols - 1;
|
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);
|
626
750
|
this.finish();
|
627
751
|
}
|
628
752
|
return isValid;
|
@@ -639,19 +763,31 @@ class Selection {
|
|
639
763
|
if (!this.isSelected()) {
|
640
764
|
return;
|
641
765
|
}
|
642
|
-
const
|
766
|
+
const focusHighlight = this.highlight.getFocus();
|
643
767
|
const currentLayer = this.getLayerLevel();
|
644
|
-
|
768
|
+
focusHighlight.commit().syncWith(this.selectedRange.current());
|
645
769
|
|
646
770
|
// Rewriting rendered ranges going through all layers.
|
647
771
|
for (let layerLevel = 0; layerLevel < this.selectedRange.size(); layerLevel += 1) {
|
648
772
|
this.highlight.useLayerLevel(layerLevel);
|
649
|
-
const areaHighlight = this.highlight.
|
650
|
-
const
|
651
|
-
const
|
773
|
+
const areaHighlight = this.highlight.createArea();
|
774
|
+
const areaLayeredHighlight = this.highlight.createLayeredArea();
|
775
|
+
const rowHeaderHighlight = this.highlight.createRowHeader();
|
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();
|
652
782
|
areaHighlight.commit();
|
653
|
-
|
654
|
-
|
783
|
+
areaLayeredHighlight.commit();
|
784
|
+
rowHeaderHighlight.commit();
|
785
|
+
columnHeaderHighlight.commit();
|
786
|
+
activeRowHeaderHighlight.commit();
|
787
|
+
activeColumnHeaderHighlight.commit();
|
788
|
+
activeCornerHeaderHighlight.commit();
|
789
|
+
rowHighlight.commit();
|
790
|
+
columnHighlight.commit();
|
655
791
|
}
|
656
792
|
|
657
793
|
// Reverting starting layer for the Highlight.
|