handsontable 0.0.0-next-93e34dc-20230601 → 0.0.0-next-b7cca45-20230605
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/{selection/border/border.js → border.js} +12 -7
- package/3rdparty/walkontable/src/{selection/border/border.mjs → border.mjs} +12 -7
- package/3rdparty/walkontable/src/cell/coords.d.ts +1 -6
- package/3rdparty/walkontable/src/cell/coords.js +12 -61
- package/3rdparty/walkontable/src/cell/coords.mjs +12 -61
- package/3rdparty/walkontable/src/cell/range.d.ts +2 -9
- package/3rdparty/walkontable/src/cell/range.js +7 -44
- package/3rdparty/walkontable/src/cell/range.mjs +7 -44
- 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 +4 -2
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +4 -2
- package/3rdparty/walkontable/src/overlay/top.js +4 -2
- package/3rdparty/walkontable/src/overlay/top.mjs +4 -2
- package/3rdparty/walkontable/src/selection.js +354 -0
- package/3rdparty/walkontable/src/selection.mjs +348 -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 +79 -7
- package/3rdparty/walkontable/src/table.mjs +80 -8
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core.d.ts +3 -5
- package/core.js +300 -82
- package/core.mjs +300 -82
- package/dataMap/metaManager/metaSchema.js +0 -15
- package/dataMap/metaManager/metaSchema.mjs +0 -15
- package/dist/handsontable.css +3 -8
- package/dist/handsontable.full.css +3 -8
- package/dist/handsontable.full.js +9926 -12218
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +120 -120
- package/dist/handsontable.js +14628 -16920
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +4 -4
- package/editorManager.js +82 -20
- package/editorManager.mjs +86 -25
- 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.js +1 -1
- package/pluginHooks.mjs +1 -1
- package/plugins/copyPaste/copyPaste.js +1 -5
- package/plugins/copyPaste/copyPaste.mjs +1 -5
- package/plugins/customBorders/customBorders.js +52 -18
- package/plugins/customBorders/customBorders.mjs +53 -19
- package/plugins/mergeCells/mergeCells.js +18 -5
- package/plugins/mergeCells/mergeCells.mjs +18 -5
- package/plugins/nestedHeaders/nestedHeaders.js +9 -89
- package/plugins/nestedHeaders/nestedHeaders.mjs +9 -89
- package/plugins/nestedHeaders/stateManager/index.js +0 -37
- package/plugins/nestedHeaders/stateManager/index.mjs +0 -37
- package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
- package/selection/highlight/constants.js +16 -0
- package/selection/highlight/constants.mjs +6 -0
- package/selection/highlight/highlight.js +88 -311
- package/selection/highlight/highlight.mjs +84 -301
- package/selection/highlight/types/activeHeader.js +9 -10
- package/selection/highlight/types/activeHeader.mjs +8 -10
- package/selection/highlight/types/area.js +27 -12
- package/selection/highlight/types/area.mjs +30 -16
- package/selection/highlight/types/{focus.js → cell.js} +8 -5
- package/selection/highlight/types/{focus.mjs → cell.mjs} +7 -5
- package/selection/highlight/types/customSelection.js +10 -7
- package/selection/highlight/types/customSelection.mjs +9 -7
- package/selection/highlight/types/fill.js +8 -5
- package/selection/highlight/types/fill.mjs +7 -5
- package/selection/highlight/types/header.js +20 -10
- package/selection/highlight/types/header.mjs +19 -10
- package/selection/highlight/types/{row.js → index.js} +31 -27
- package/selection/highlight/types/{row.mjs → index.mjs} +29 -24
- package/selection/highlight/visualSelection.js +28 -23
- package/selection/highlight/visualSelection.mjs +28 -23
- 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 +180 -296
- package/selection/selection.mjs +179 -291
- package/selection/transformation.js +96 -233
- package/selection/transformation.mjs +93 -230
- package/selection/utils.js +35 -12
- package/selection/utils.mjs +35 -13
- package/settings.d.ts +0 -1
- package/tableView.js +9 -58
- package/tableView.mjs +9 -58
- package/3rdparty/walkontable/src/selection/border/constants.js +0 -18
- package/3rdparty/walkontable/src/selection/border/constants.mjs +0 -13
- package/3rdparty/walkontable/src/selection/constants.js +0 -63
- package/3rdparty/walkontable/src/selection/constants.mjs +0 -51
- package/3rdparty/walkontable/src/selection/index.js +0 -30
- package/3rdparty/walkontable/src/selection/index.mjs +0 -5
- package/3rdparty/walkontable/src/selection/manager.js +0 -328
- package/3rdparty/walkontable/src/selection/manager.mjs +0 -322
- package/3rdparty/walkontable/src/selection/scanner.js +0 -363
- package/3rdparty/walkontable/src/selection/scanner.mjs +0 -359
- package/3rdparty/walkontable/src/selection/selection.js +0 -133
- package/3rdparty/walkontable/src/selection/selection.mjs +0 -127
- package/selection/highlight/types/areaLayered.js +0 -54
- package/selection/highlight/types/areaLayered.mjs +0 -49
- package/selection/highlight/types/column.js +0 -50
- package/selection/highlight/types/column.mjs +0 -45
- package/shortcutContexts/commands/editor/closeAndSave.js +0 -15
- package/shortcutContexts/commands/editor/closeAndSave.mjs +0 -10
- package/shortcutContexts/commands/editor/closeWithoutSaving.js +0 -13
- package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +0 -8
- package/shortcutContexts/commands/editor/fastOpen.js +0 -16
- package/shortcutContexts/commands/editor/fastOpen.mjs +0 -11
- package/shortcutContexts/commands/editor/index.js +0 -16
- package/shortcutContexts/commands/editor/index.mjs +0 -12
- package/shortcutContexts/commands/editor/open.js +0 -29
- package/shortcutContexts/commands/editor/open.mjs +0 -24
- package/shortcutContexts/commands/emptySelectedCells.js +0 -12
- package/shortcutContexts/commands/emptySelectedCells.mjs +0 -7
- package/shortcutContexts/commands/extendCellsSelection/down.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +0 -10
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +0 -21
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +0 -16
- package/shortcutContexts/commands/extendCellsSelection/index.js +0 -24
- package/shortcutContexts/commands/extendCellsSelection/index.mjs +0 -20
- package/shortcutContexts/commands/extendCellsSelection/left.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +0 -10
- package/shortcutContexts/commands/extendCellsSelection/right.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +0 -10
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +0 -22
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +0 -17
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +0 -17
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +0 -12
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +0 -17
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +0 -12
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +0 -39
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +0 -34
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +0 -39
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +0 -34
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +0 -22
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +0 -17
- package/shortcutContexts/commands/extendCellsSelection/up.js +0 -15
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +0 -10
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +0 -21
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +0 -16
- package/shortcutContexts/commands/index.js +0 -51
- package/shortcutContexts/commands/index.mjs +0 -47
- package/shortcutContexts/commands/moveCellSelection/down.js +0 -12
- package/shortcutContexts/commands/moveCellSelection/down.mjs +0 -7
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +0 -11
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +0 -6
- package/shortcutContexts/commands/moveCellSelection/index.js +0 -28
- package/shortcutContexts/commands/moveCellSelection/index.mjs +0 -24
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +0 -13
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +0 -8
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +0 -13
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +0 -8
- package/shortcutContexts/commands/moveCellSelection/left.js +0 -11
- package/shortcutContexts/commands/moveCellSelection/left.mjs +0 -6
- package/shortcutContexts/commands/moveCellSelection/right.js +0 -11
- package/shortcutContexts/commands/moveCellSelection/right.mjs +0 -6
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +0 -16
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +0 -11
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +0 -17
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +0 -12
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +0 -13
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +0 -8
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +0 -16
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +0 -11
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +0 -35
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +0 -30
- package/shortcutContexts/commands/moveCellSelection/toMostRight.js +0 -35
- package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +0 -30
- package/shortcutContexts/commands/moveCellSelection/toMostTop.js +0 -16
- package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +0 -11
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +0 -18
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +0 -13
- package/shortcutContexts/commands/moveCellSelection/up.js +0 -12
- package/shortcutContexts/commands/moveCellSelection/up.mjs +0 -7
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +0 -11
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +0 -6
- package/shortcutContexts/commands/populateSelectedCellsData.js +0 -35
- package/shortcutContexts/commands/populateSelectedCellsData.mjs +0 -30
- package/shortcutContexts/commands/selectAll.js +0 -11
- package/shortcutContexts/commands/selectAll.mjs +0 -6
- package/shortcutContexts/constants.js +0 -19
- package/shortcutContexts/constants.mjs +0 -12
- package/shortcutContexts/editor.js +0 -29
- package/shortcutContexts/editor.mjs +0 -25
- package/shortcutContexts/grid.js +0 -232
- package/shortcutContexts/grid.mjs +0 -228
- package/shortcutContexts/index.js +0 -29
- package/shortcutContexts/index.mjs +0 -15
package/selection/selection.mjs
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
2
2
|
var _templateObject;
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
7
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
3
9
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
4
10
|
import "core-js/modules/es.array.iterator.js";
|
5
11
|
import "core-js/modules/es.object.to-string.js";
|
@@ -20,22 +26,22 @@ import "core-js/modules/es.symbol.description.js";
|
|
20
26
|
import "core-js/modules/es.array.slice.js";
|
21
27
|
import "core-js/modules/es.object.freeze.js";
|
22
28
|
import "core-js/modules/es.symbol.iterator.js";
|
29
|
+
import "core-js/modules/es.function.name.js";
|
30
|
+
import "core-js/modules/es.regexp.exec.js";
|
23
31
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
24
32
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
25
33
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
26
|
-
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; }
|
27
34
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
28
35
|
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); }
|
29
|
-
import
|
30
|
-
import
|
36
|
+
import Highlight from "./highlight/highlight.mjs";
|
37
|
+
import { AREA_TYPE, HEADER_TYPE, CELL_TYPE } from "./highlight/constants.mjs";
|
31
38
|
import SelectionRange from "./range.mjs";
|
32
39
|
import { createObjectPropListener, mixin } from "./../helpers/object.mjs";
|
33
40
|
import { isUndefined } from "./../helpers/mixed.mjs";
|
34
|
-
import { clamp } from "./../helpers/number.mjs";
|
35
41
|
import { arrayEach } from "./../helpers/array.mjs";
|
36
42
|
import localHooks from "./../mixins/localHooks.mjs";
|
37
43
|
import Transformation from "./transformation.mjs";
|
38
|
-
import { detectSelectionType, normalizeSelectionFactory, SELECTION_TYPE_EMPTY, SELECTION_TYPE_UNRECOGNIZED } from "./utils.mjs";
|
44
|
+
import { detectSelectionType, isValidCoord, normalizeSelectionFactory, SELECTION_TYPE_EMPTY, SELECTION_TYPE_UNRECOGNIZED } from "./utils.mjs";
|
39
45
|
import { toSingleLine } from "./../helpers/templateLiteralTag.mjs";
|
40
46
|
/**
|
41
47
|
* @class Selection
|
@@ -50,62 +56,57 @@ var Selection = /*#__PURE__*/function () {
|
|
50
56
|
*
|
51
57
|
* @type {GridSettings}
|
52
58
|
*/
|
53
|
-
|
59
|
+
this.settings = settings;
|
54
60
|
/**
|
55
61
|
* An additional object with dynamically defined properties which describes table state.
|
56
62
|
*
|
57
63
|
* @type {object}
|
58
64
|
*/
|
59
|
-
|
65
|
+
this.tableProps = tableProps;
|
60
66
|
/**
|
61
67
|
* The flag which determines if the selection is in progress.
|
62
68
|
*
|
63
69
|
* @type {boolean}
|
64
70
|
*/
|
65
|
-
|
71
|
+
this.inProgress = false;
|
66
72
|
/**
|
67
|
-
*
|
73
|
+
* The flag indicates that selection was performed by clicking the corner overlay.
|
68
74
|
*
|
69
|
-
* @type {
|
75
|
+
* @type {boolean}
|
70
76
|
*/
|
71
|
-
|
72
|
-
return _this.tableProps.createCellRange(highlight, from, to);
|
73
|
-
}));
|
77
|
+
this.selectedByCorner = false;
|
74
78
|
/**
|
75
|
-
*
|
79
|
+
* The collection of the selection layer levels where the whole row was selected using the row header or
|
80
|
+
* the corner header.
|
76
81
|
*
|
77
|
-
* @type {
|
82
|
+
* @type {Set.<number>}
|
78
83
|
*/
|
79
|
-
|
84
|
+
this.selectedByRowHeader = new Set();
|
80
85
|
/**
|
81
|
-
* The
|
86
|
+
* The collection of the selection layer levels where the whole column was selected using the column header or
|
87
|
+
* the corner header.
|
82
88
|
*
|
83
|
-
* @type {
|
89
|
+
* @type {Set.<number>}
|
84
90
|
*/
|
85
|
-
|
91
|
+
this.selectedByColumnHeader = new Set();
|
86
92
|
/**
|
87
|
-
*
|
88
|
-
* the corner header.
|
93
|
+
* Selection data layer (handle visual coordinates).
|
89
94
|
*
|
90
|
-
* @type {
|
95
|
+
* @type {SelectionRange}
|
91
96
|
*/
|
92
|
-
|
97
|
+
this.selectedRange = new SelectionRange(function (highlight, from, to) {
|
98
|
+
return _this.tableProps.createCellRange(highlight, from, to);
|
99
|
+
});
|
93
100
|
/**
|
94
|
-
*
|
95
|
-
* the corner header.
|
101
|
+
* Visualization layer.
|
96
102
|
*
|
97
|
-
* @type {
|
103
|
+
* @type {Highlight}
|
98
104
|
*/
|
99
|
-
_defineProperty(this, "selectedByColumnHeader", new Set());
|
100
|
-
this.settings = settings;
|
101
|
-
this.tableProps = tableProps;
|
102
105
|
this.highlight = new Highlight({
|
103
106
|
headerClassName: settings.currentHeaderClassName,
|
104
107
|
activeHeaderClassName: settings.activeHeaderClassName,
|
105
108
|
rowClassName: settings.currentRowClassName,
|
106
109
|
columnClassName: settings.currentColClassName,
|
107
|
-
rowIndexMapper: this.tableProps.rowIndexMapper,
|
108
|
-
columnIndexMapper: this.tableProps.columnIndexMapper,
|
109
110
|
disabledCellSelection: function disabledCellSelection(row, column) {
|
110
111
|
return _this.tableProps.isDisabledCellSelection(row, column);
|
111
112
|
},
|
@@ -126,22 +127,25 @@ var Selection = /*#__PURE__*/function () {
|
|
126
127
|
},
|
127
128
|
createCellRange: function createCellRange(highlight, from, to) {
|
128
129
|
return _this.tableProps.createCellRange(highlight, from, to);
|
130
|
+
},
|
131
|
+
rowIndexMapper: function rowIndexMapper() {
|
132
|
+
return _this.tableProps.rowIndexMapper();
|
133
|
+
},
|
134
|
+
columnIndexMapper: function columnIndexMapper() {
|
135
|
+
return _this.tableProps.columnIndexMapper();
|
129
136
|
}
|
130
137
|
});
|
138
|
+
/**
|
139
|
+
* The module for modifying coordinates.
|
140
|
+
*
|
141
|
+
* @type {Transformation}
|
142
|
+
*/
|
131
143
|
this.transformation = new Transformation(this.selectedRange, {
|
132
|
-
|
133
|
-
|
134
|
-
countRenderableRows: function countRenderableRows() {
|
135
|
-
return _this.tableProps.countRenderableRows();
|
144
|
+
countRows: function countRows() {
|
145
|
+
return _this.tableProps.countRowsTranslated();
|
136
146
|
},
|
137
|
-
|
138
|
-
return _this.tableProps.
|
139
|
-
},
|
140
|
-
countRowHeaders: function countRowHeaders() {
|
141
|
-
return _this.tableProps.countRowHeaders();
|
142
|
-
},
|
143
|
-
countColHeaders: function countColHeaders() {
|
144
|
-
return _this.tableProps.countColHeaders();
|
147
|
+
countCols: function countCols() {
|
148
|
+
return _this.tableProps.countColsTranslated();
|
145
149
|
},
|
146
150
|
visualToRenderableCoords: function visualToRenderableCoords(coords) {
|
147
151
|
return _this.tableProps.visualToRenderableCoords(coords);
|
@@ -152,9 +156,6 @@ var Selection = /*#__PURE__*/function () {
|
|
152
156
|
createCellCoords: function createCellCoords(row, column) {
|
153
157
|
return _this.tableProps.createCellCoords(row, column);
|
154
158
|
},
|
155
|
-
navigableHeaders: function navigableHeaders() {
|
156
|
-
return settings.navigableHeaders;
|
157
|
-
},
|
158
159
|
fixedRowsBottom: function fixedRowsBottom() {
|
159
160
|
return settings.fixedRowsBottom;
|
160
161
|
},
|
@@ -259,27 +260,35 @@ var Selection = /*#__PURE__*/function () {
|
|
259
260
|
* the default trigger will be used.
|
260
261
|
* @param {boolean} [fragment=false] If `true`, the selection will be treated as a partial selection where the
|
261
262
|
* `setRangeEnd` method won't be called on every `setRangeStart` call.
|
262
|
-
* @param {CellCoords} [highlightCoords] If set, allows changing the coordinates of the highlight/focus cell.
|
263
263
|
*/
|
264
264
|
}, {
|
265
265
|
key: "setRangeStart",
|
266
266
|
value: function setRangeStart(coords, multipleSelection) {
|
267
267
|
var fragment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
268
|
-
var highlightCoords = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : coords;
|
269
268
|
var isMultipleMode = this.settings.selectionMode === 'multiple';
|
270
269
|
var isMultipleSelection = isUndefined(multipleSelection) ? this.tableProps.getShortcutManager().isCtrlPressed() : multipleSelection;
|
270
|
+
var isRowNegative = coords.row < 0;
|
271
|
+
var isColumnNegative = coords.col < 0;
|
272
|
+
var selectedByCorner = isRowNegative && isColumnNegative;
|
271
273
|
// We are creating copy. We would like to modify just the start of the selection by below hook. Then original coords
|
272
274
|
// should be handled by next methods.
|
273
275
|
var coordsClone = coords.clone();
|
276
|
+
this.selectedByCorner = selectedByCorner;
|
274
277
|
this.runLocalHooks("beforeSetRangeStart".concat(fragment ? 'Only' : ''), coordsClone);
|
275
278
|
if (!isMultipleMode || isMultipleMode && !isMultipleSelection && isUndefined(multipleSelection)) {
|
276
279
|
this.selectedRange.clear();
|
277
280
|
}
|
278
|
-
this.selectedRange.add(coordsClone)
|
281
|
+
this.selectedRange.add(coordsClone);
|
279
282
|
if (this.getLayerLevel() === 0) {
|
280
283
|
this.selectedByRowHeader.clear();
|
281
284
|
this.selectedByColumnHeader.clear();
|
282
285
|
}
|
286
|
+
if (!selectedByCorner && isColumnNegative) {
|
287
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
288
|
+
}
|
289
|
+
if (!selectedByCorner && isRowNegative) {
|
290
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
291
|
+
}
|
283
292
|
if (!fragment) {
|
284
293
|
this.setRangeEnd(coords);
|
285
294
|
}
|
@@ -292,13 +301,11 @@ var Selection = /*#__PURE__*/function () {
|
|
292
301
|
* @param {boolean} [multipleSelection] If `true`, selection will be worked in 'multiple' mode. This option works
|
293
302
|
* only when 'selectionMode' is set as 'multiple'. If the argument is not defined
|
294
303
|
* the default trigger will be used.
|
295
|
-
* @param {CellCoords} [highlightCoords] If set, allows changing the coordinates of the highlight/focus cell.
|
296
304
|
*/
|
297
305
|
}, {
|
298
306
|
key: "setRangeStartOnly",
|
299
307
|
value: function setRangeStartOnly(coords, multipleSelection) {
|
300
|
-
|
301
|
-
this.setRangeStart(coords, multipleSelection, true, highlightCoords);
|
308
|
+
this.setRangeStart(coords, multipleSelection, true);
|
302
309
|
}
|
303
310
|
|
304
311
|
/**
|
@@ -312,39 +319,21 @@ var Selection = /*#__PURE__*/function () {
|
|
312
319
|
if (this.selectedRange.isEmpty()) {
|
313
320
|
return;
|
314
321
|
}
|
315
|
-
var coordsClone = coords.clone();
|
316
|
-
var countRows = this.tableProps.countRows();
|
317
|
-
var countCols = this.tableProps.countCols();
|
318
|
-
var isSingle = this.selectedRange.current().clone().setTo(coords).isSingleHeader();
|
319
322
|
|
320
|
-
//
|
321
|
-
//
|
322
|
-
|
323
|
-
return;
|
324
|
-
}
|
323
|
+
// We are creating copy. We would like to modify just the end of the selection by below hook. Then original coords
|
324
|
+
// should be handled by next methods.
|
325
|
+
var coordsClone = coords.clone();
|
325
326
|
this.runLocalHooks('beforeSetRangeEnd', coordsClone);
|
326
327
|
this.begin();
|
327
328
|
var cellRange = this.selectedRange.current();
|
328
|
-
if (
|
329
|
-
cellRange.
|
330
|
-
}
|
331
|
-
if (this.settings.selectionMode === 'single') {
|
332
|
-
cellRange.setFrom(cellRange.highlight);
|
333
|
-
cellRange.setTo(cellRange.highlight);
|
334
|
-
} else {
|
335
|
-
cellRange.setTo(coordsClone);
|
329
|
+
if (this.settings.selectionMode !== 'single') {
|
330
|
+
cellRange.setTo(this.tableProps.createCellCoords(coordsClone.row, coordsClone.col));
|
336
331
|
}
|
337
332
|
|
338
|
-
//
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
}
|
343
|
-
}
|
344
|
-
var focusHighlight = this.highlight.getFocus();
|
345
|
-
focusHighlight.clear();
|
346
|
-
if (this.highlight.isEnabledFor(FOCUS_TYPE, cellRange.highlight)) {
|
347
|
-
focusHighlight.add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
|
333
|
+
// Set up current selection.
|
334
|
+
this.highlight.getCell().clear();
|
335
|
+
if (this.highlight.isEnabledFor(CELL_TYPE, cellRange.highlight)) {
|
336
|
+
this.highlight.getCell().add(this.selectedRange.current().highlight).commit().syncWith(cellRange);
|
348
337
|
}
|
349
338
|
var layerLevel = this.getLayerLevel();
|
350
339
|
|
@@ -354,96 +343,73 @@ var Selection = /*#__PURE__*/function () {
|
|
354
343
|
arrayEach(this.highlight.getAreas(), function (highlight) {
|
355
344
|
return void highlight.clear();
|
356
345
|
});
|
357
|
-
arrayEach(this.highlight.
|
358
|
-
return void highlight.clear();
|
359
|
-
});
|
360
|
-
arrayEach(this.highlight.getRowHeaders(), function (highlight) {
|
361
|
-
return void highlight.clear();
|
362
|
-
});
|
363
|
-
arrayEach(this.highlight.getColumnHeaders(), function (highlight) {
|
364
|
-
return void highlight.clear();
|
365
|
-
});
|
366
|
-
arrayEach(this.highlight.getActiveRowHeaders(), function (highlight) {
|
367
|
-
return void highlight.clear();
|
368
|
-
});
|
369
|
-
arrayEach(this.highlight.getActiveColumnHeaders(), function (highlight) {
|
346
|
+
arrayEach(this.highlight.getHeaders(), function (highlight) {
|
370
347
|
return void highlight.clear();
|
371
348
|
});
|
372
|
-
arrayEach(this.highlight.
|
373
|
-
return void highlight.clear();
|
374
|
-
});
|
375
|
-
arrayEach(this.highlight.getRowHighlights(), function (highlight) {
|
376
|
-
return void highlight.clear();
|
377
|
-
});
|
378
|
-
arrayEach(this.highlight.getColumnHighlights(), function (highlight) {
|
349
|
+
arrayEach(this.highlight.getActiveHeaders(), function (highlight) {
|
379
350
|
return void highlight.clear();
|
380
351
|
});
|
381
352
|
}
|
382
353
|
this.highlight.useLayerLevel(layerLevel);
|
383
|
-
var areaHighlight = this.highlight.
|
384
|
-
var
|
385
|
-
var
|
386
|
-
var columnHeaderHighlight = this.highlight.createColumnHeader();
|
387
|
-
var activeRowHeaderHighlight = this.highlight.createActiveRowHeader();
|
388
|
-
var activeColumnHeaderHighlight = this.highlight.createActiveColumnHeader();
|
389
|
-
var activeCornerHeaderHighlight = this.highlight.createActiveCornerHeader();
|
390
|
-
var rowHighlight = this.highlight.createRowHighlight();
|
391
|
-
var columnHighlight = this.highlight.createColumnHighlight();
|
354
|
+
var areaHighlight = this.highlight.createOrGetArea();
|
355
|
+
var headerHighlight = this.highlight.createOrGetHeader();
|
356
|
+
var activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
|
392
357
|
areaHighlight.clear();
|
393
|
-
|
394
|
-
|
395
|
-
columnHeaderHighlight.clear();
|
396
|
-
activeRowHeaderHighlight.clear();
|
397
|
-
activeColumnHeaderHighlight.clear();
|
398
|
-
activeCornerHeaderHighlight.clear();
|
399
|
-
rowHighlight.clear();
|
400
|
-
columnHighlight.clear();
|
358
|
+
headerHighlight.clear();
|
359
|
+
activeHeaderHighlight.clear();
|
401
360
|
if (this.highlight.isEnabledFor(AREA_TYPE, cellRange.highlight) && (this.isMultiple() || layerLevel >= 1)) {
|
402
361
|
areaHighlight.add(cellRange.from).add(cellRange.to).commit();
|
403
|
-
layeredAreaHighlight.add(cellRange.from).add(cellRange.to).commit();
|
404
362
|
if (layerLevel === 1) {
|
405
363
|
// For single cell selection in the same layer, we do not create area selection to prevent blue background.
|
406
364
|
// When non-consecutive selection is performed we have to add that missing area selection to the previous layer
|
407
365
|
// based on previous coordinates. It only occurs when the previous selection wasn't select multiple cells.
|
408
366
|
var previousRange = this.selectedRange.previous();
|
409
|
-
this.highlight.useLayerLevel(layerLevel - 1)
|
410
|
-
this.highlight.createArea().add(previousRange.from).commit()
|
411
|
-
// Range may start with hidden indexes. Commit would not found start point (as we add just the `from` coords).
|
412
|
-
.syncWith(previousRange);
|
413
|
-
this.highlight.createLayeredArea().add(previousRange.from).commit()
|
367
|
+
this.highlight.useLayerLevel(layerLevel - 1).createOrGetArea().add(previousRange.from).commit()
|
414
368
|
// Range may start with hidden indexes. Commit would not found start point (as we add just the `from` coords).
|
415
369
|
.syncWith(previousRange);
|
416
370
|
this.highlight.useLayerLevel(layerLevel);
|
417
371
|
}
|
418
372
|
}
|
419
373
|
if (this.highlight.isEnabledFor(HEADER_TYPE, cellRange.highlight)) {
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
columnHeaderHighlight.add(columnCoordsFrom).add(columnCoordsTo).commit();
|
433
|
-
rowHighlight.add(rowCoordsFrom).add(rowCoordsTo).commit();
|
434
|
-
columnHighlight.add(columnCoordsFrom).add(columnCoordsTo).commit();
|
435
|
-
}
|
374
|
+
// The header selection generally contains cell selection. In a case when all rows (or columns)
|
375
|
+
// are hidden that visual coordinates are translated to renderable coordinates that do not exist.
|
376
|
+
// Hence no header highlight is generated. In that case, to make a column (or a row) header
|
377
|
+
// highlight, the row and column index has to point to the header (the negative value). See #7052.
|
378
|
+
var areAnyRowsRendered = this.tableProps.countRowsTranslated() === 0;
|
379
|
+
var areAnyColumnsRendered = this.tableProps.countColsTranslated() === 0;
|
380
|
+
var headerCellRange = cellRange;
|
381
|
+
if (areAnyRowsRendered || areAnyColumnsRendered) {
|
382
|
+
headerCellRange = cellRange.clone();
|
383
|
+
}
|
384
|
+
if (areAnyRowsRendered) {
|
385
|
+
headerCellRange.from.row = -1;
|
436
386
|
}
|
437
|
-
|
438
|
-
|
439
|
-
if (highlightRowHeaders) {
|
440
|
-
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();
|
387
|
+
if (areAnyColumnsRendered) {
|
388
|
+
headerCellRange.from.col = -1;
|
441
389
|
}
|
442
|
-
if (
|
443
|
-
|
390
|
+
if (this.settings.selectionMode === 'single') {
|
391
|
+
if (this.isSelectedByAnyHeader()) {
|
392
|
+
headerCellRange.from.normalize();
|
393
|
+
}
|
394
|
+
headerHighlight.add(headerCellRange.from).commit();
|
395
|
+
} else {
|
396
|
+
headerHighlight.add(headerCellRange.from).add(headerCellRange.to).commit();
|
444
397
|
}
|
445
|
-
if (
|
446
|
-
|
398
|
+
if (this.isEntireRowSelected()) {
|
399
|
+
var isRowSelected = this.tableProps.countCols() === cellRange.getWidth();
|
400
|
+
|
401
|
+
// Make sure that the whole row is selected (in case where selectionMode is set to 'single')
|
402
|
+
if (isRowSelected) {
|
403
|
+
activeHeaderHighlight.add(this.tableProps.createCellCoords(cellRange.from.row, -1)).add(this.tableProps.createCellCoords(cellRange.to.row, -1)).commit();
|
404
|
+
}
|
405
|
+
}
|
406
|
+
if (this.isEntireColumnSelected()) {
|
407
|
+
var isColumnSelected = this.tableProps.countRows() === cellRange.getHeight();
|
408
|
+
|
409
|
+
// Make sure that the whole column is selected (in case where selectionMode is set to 'single')
|
410
|
+
if (isColumnSelected) {
|
411
|
+
activeHeaderHighlight.add(this.tableProps.createCellCoords(-1, cellRange.from.col)).add(this.tableProps.createCellCoords(-1, cellRange.to.col)).commit();
|
412
|
+
}
|
447
413
|
}
|
448
414
|
}
|
449
415
|
this.runLocalHooks('afterSetRangeEnd', coords);
|
@@ -468,14 +434,14 @@ var Selection = /*#__PURE__*/function () {
|
|
468
434
|
*
|
469
435
|
* @param {number} rowDelta Rows number to move, value can be passed as negative number.
|
470
436
|
* @param {number} colDelta Columns number to move, value can be passed as negative number.
|
471
|
-
* @param {boolean} [
|
472
|
-
*
|
437
|
+
* @param {boolean} [force=false] If `true` the new rows/columns will be created if necessary. Otherwise, row/column will
|
438
|
+
* be created according to `minSpareRows/minSpareCols` settings of Handsontable.
|
473
439
|
*/
|
474
440
|
}, {
|
475
441
|
key: "transformStart",
|
476
442
|
value: function transformStart(rowDelta, colDelta) {
|
477
|
-
var
|
478
|
-
this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta,
|
443
|
+
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
444
|
+
this.setRangeStart(this.transformation.transformStart(rowDelta, colDelta, force));
|
479
445
|
}
|
480
446
|
|
481
447
|
/**
|
@@ -524,7 +490,7 @@ var Selection = /*#__PURE__*/function () {
|
|
524
490
|
key: "isSelectedByRowHeader",
|
525
491
|
value: function isSelectedByRowHeader() {
|
526
492
|
var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
527
|
-
return !this.isSelectedByCorner(layerLevel) &&
|
493
|
+
return !this.isSelectedByCorner(layerLevel) && this.isEntireRowSelected(layerLevel);
|
528
494
|
}
|
529
495
|
|
530
496
|
/**
|
@@ -537,22 +503,8 @@ var Selection = /*#__PURE__*/function () {
|
|
537
503
|
}, {
|
538
504
|
key: "isEntireRowSelected",
|
539
505
|
value: function isEntireRowSelected() {
|
540
|
-
var _this2 = this;
|
541
506
|
var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
542
|
-
|
543
|
-
var _range$getOuterTopSta = range.getOuterTopStartCorner(),
|
544
|
-
col = _range$getOuterTopSta.col;
|
545
|
-
var rowHeaders = _this2.tableProps.countRowHeaders();
|
546
|
-
var countCols = _this2.tableProps.countCols();
|
547
|
-
return (rowHeaders > 0 && col < 0 || rowHeaders === 0) && range.getWidth() === countCols;
|
548
|
-
};
|
549
|
-
if (layerLevel === -1) {
|
550
|
-
return Array.from(this.selectedRange).some(function (range) {
|
551
|
-
return tester(range);
|
552
|
-
});
|
553
|
-
}
|
554
|
-
var range = this.selectedRange.peekByIndex(layerLevel);
|
555
|
-
return range ? tester(range) : false;
|
507
|
+
return layerLevel === -1 ? this.selectedByRowHeader.size > 0 : this.selectedByRowHeader.has(layerLevel);
|
556
508
|
}
|
557
509
|
|
558
510
|
/**
|
@@ -567,7 +519,7 @@ var Selection = /*#__PURE__*/function () {
|
|
567
519
|
key: "isSelectedByColumnHeader",
|
568
520
|
value: function isSelectedByColumnHeader() {
|
569
521
|
var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
570
|
-
return !this.isSelectedByCorner() &&
|
522
|
+
return !this.isSelectedByCorner() && this.isEntireColumnSelected(layerLevel);
|
571
523
|
}
|
572
524
|
|
573
525
|
/**
|
@@ -580,22 +532,8 @@ var Selection = /*#__PURE__*/function () {
|
|
580
532
|
}, {
|
581
533
|
key: "isEntireColumnSelected",
|
582
534
|
value: function isEntireColumnSelected() {
|
583
|
-
var _this3 = this;
|
584
535
|
var layerLevel = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getLayerLevel();
|
585
|
-
|
586
|
-
var _range$getOuterTopSta2 = range.getOuterTopStartCorner(),
|
587
|
-
row = _range$getOuterTopSta2.row;
|
588
|
-
var colHeaders = _this3.tableProps.countColHeaders();
|
589
|
-
var countRows = _this3.tableProps.countRows();
|
590
|
-
return (colHeaders > 0 && row < 0 || colHeaders === 0) && range.getHeight() === countRows;
|
591
|
-
};
|
592
|
-
if (layerLevel === -1) {
|
593
|
-
return Array.from(this.selectedRange).some(function (range) {
|
594
|
-
return tester(range);
|
595
|
-
});
|
596
|
-
}
|
597
|
-
var range = this.selectedRange.peekByIndex(layerLevel);
|
598
|
-
return range ? tester(range) : false;
|
536
|
+
return layerLevel === -1 ? this.selectedByColumnHeader.size > 0 : this.selectedByColumnHeader.has(layerLevel);
|
599
537
|
}
|
600
538
|
|
601
539
|
/**
|
@@ -617,7 +555,7 @@ var Selection = /*#__PURE__*/function () {
|
|
617
555
|
}, {
|
618
556
|
key: "isSelectedByCorner",
|
619
557
|
value: function isSelectedByCorner() {
|
620
|
-
return this.
|
558
|
+
return this.selectedByCorner;
|
621
559
|
}
|
622
560
|
|
623
561
|
/**
|
@@ -686,48 +624,31 @@ var Selection = /*#__PURE__*/function () {
|
|
686
624
|
}
|
687
625
|
|
688
626
|
/**
|
689
|
-
*
|
627
|
+
* Select all cells.
|
690
628
|
*
|
691
|
-
* @param {
|
692
|
-
*
|
693
|
-
*
|
694
|
-
*
|
695
|
-
* If a value is passed as a number (from -1 to -N), then it additionally allows moving the cell
|
696
|
-
* focus (highlight) to the header (available when the `navigableHeaders` is enabled).
|
629
|
+
* @param {boolean} [includeRowHeaders=false] `true` If the selection should include the row headers, `false`
|
630
|
+
* otherwise.
|
631
|
+
* @param {boolean} [includeColumnHeaders=false] `true` If the selection should include the column headers, `false`
|
632
|
+
* otherwise.
|
697
633
|
*/
|
698
634
|
}, {
|
699
635
|
key: "selectAll",
|
700
636
|
value: function selectAll() {
|
701
|
-
var
|
702
|
-
var
|
637
|
+
var includeRowHeaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
638
|
+
var includeColumnHeaders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
703
639
|
var nrOfRows = this.tableProps.countRows();
|
704
640
|
var nrOfColumns = this.tableProps.countCols();
|
705
|
-
var countRowHeaders = this.tableProps.countRowHeaders();
|
706
|
-
var countColHeaders = this.tableProps.countColHeaders();
|
707
|
-
var rowFrom = rowHeaderLevel ? -countColHeaders : 0;
|
708
|
-
if (Number.isInteger(rowHeaderLevel)) {
|
709
|
-
rowFrom = clamp(rowHeaderLevel, -countColHeaders, -1);
|
710
|
-
}
|
711
|
-
var columnFrom = columnHeaderLevel ? -countRowHeaders : 0;
|
712
|
-
if (Number.isInteger(columnHeaderLevel)) {
|
713
|
-
columnFrom = clamp(columnHeaderLevel, -countRowHeaders, -1);
|
714
|
-
}
|
715
641
|
|
716
642
|
// We can't select cells when there is no data.
|
717
|
-
if (
|
643
|
+
if (!includeRowHeaders && !includeColumnHeaders && (nrOfRows === 0 || nrOfColumns === 0)) {
|
718
644
|
return;
|
719
645
|
}
|
720
|
-
var startCoords = this.tableProps.createCellCoords(
|
721
|
-
var highlight = this.tableProps.createCellCoords(rowFrom, columnFrom);
|
646
|
+
var startCoords = this.tableProps.createCellCoords(includeColumnHeaders ? -1 : 0, includeRowHeaders ? -1 : 0);
|
722
647
|
var endCoords = this.tableProps.createCellCoords(nrOfRows - 1, nrOfColumns - 1);
|
723
648
|
this.clear();
|
724
|
-
this.setRangeStartOnly(startCoords
|
725
|
-
|
726
|
-
|
727
|
-
}
|
728
|
-
if (rowFrom < 0) {
|
729
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
730
|
-
}
|
649
|
+
this.setRangeStartOnly(startCoords);
|
650
|
+
this.selectedByRowHeader.add(this.getLayerLevel());
|
651
|
+
this.selectedByColumnHeader.add(this.getLayerLevel());
|
731
652
|
this.setRangeEnd(endCoords);
|
732
653
|
this.finish();
|
733
654
|
}
|
@@ -744,7 +665,7 @@ var Selection = /*#__PURE__*/function () {
|
|
744
665
|
}, {
|
745
666
|
key: "selectCells",
|
746
667
|
value: function selectCells(selectionRanges) {
|
747
|
-
var
|
668
|
+
var _this2 = this;
|
748
669
|
var selectionType = detectSelectionType(selectionRanges);
|
749
670
|
if (selectionType === SELECTION_TYPE_EMPTY) {
|
750
671
|
return false;
|
@@ -753,33 +674,36 @@ var Selection = /*#__PURE__*/function () {
|
|
753
674
|
}
|
754
675
|
var selectionSchemaNormalizer = normalizeSelectionFactory(selectionType, {
|
755
676
|
propToCol: function propToCol(prop) {
|
756
|
-
return
|
677
|
+
return _this2.tableProps.propToCol(prop);
|
757
678
|
},
|
758
679
|
keepDirection: true
|
759
680
|
});
|
760
|
-
var
|
761
|
-
var
|
762
|
-
countRows: this.tableProps.countRows(),
|
763
|
-
countCols: this.tableProps.countCols(),
|
764
|
-
countRowHeaders: navigableHeaders ? this.tableProps.countRowHeaders() : 0,
|
765
|
-
countColHeaders: navigableHeaders ? this.tableProps.countColHeaders() : 0
|
766
|
-
};
|
681
|
+
var nrOfRows = this.tableProps.countRows();
|
682
|
+
var nrOfColumns = this.tableProps.countCols();
|
767
683
|
|
768
684
|
// Check if every layer of the coordinates are valid.
|
769
685
|
var isValid = !selectionRanges.some(function (selection) {
|
770
|
-
var
|
771
|
-
|
772
|
-
|
686
|
+
var _selectionSchemaNorma = selectionSchemaNormalizer(selection),
|
687
|
+
_selectionSchemaNorma2 = _slicedToArray(_selectionSchemaNorma, 4),
|
688
|
+
rowStart = _selectionSchemaNorma2[0],
|
689
|
+
columnStart = _selectionSchemaNorma2[1],
|
690
|
+
rowEnd = _selectionSchemaNorma2[2],
|
691
|
+
columnEnd = _selectionSchemaNorma2[3];
|
692
|
+
var _isValid = isValidCoord(rowStart, nrOfRows) && isValidCoord(columnStart, nrOfColumns) && isValidCoord(rowEnd, nrOfRows) && isValidCoord(columnEnd, nrOfColumns);
|
693
|
+
return !_isValid;
|
773
694
|
});
|
774
695
|
if (isValid) {
|
775
696
|
this.clear();
|
776
697
|
arrayEach(selectionRanges, function (selection) {
|
777
|
-
var
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
698
|
+
var _selectionSchemaNorma3 = selectionSchemaNormalizer(selection),
|
699
|
+
_selectionSchemaNorma4 = _slicedToArray(_selectionSchemaNorma3, 4),
|
700
|
+
rowStart = _selectionSchemaNorma4[0],
|
701
|
+
columnStart = _selectionSchemaNorma4[1],
|
702
|
+
rowEnd = _selectionSchemaNorma4[2],
|
703
|
+
columnEnd = _selectionSchemaNorma4[3];
|
704
|
+
_this2.setRangeStartOnly(_this2.tableProps.createCellCoords(rowStart, columnStart), false);
|
705
|
+
_this2.setRangeEnd(_this2.tableProps.createCellCoords(rowEnd, columnEnd));
|
706
|
+
_this2.finish();
|
783
707
|
});
|
784
708
|
}
|
785
709
|
return isValid;
|
@@ -791,36 +715,24 @@ var Selection = /*#__PURE__*/function () {
|
|
791
715
|
*
|
792
716
|
* @param {number|string} startColumn Visual column index or column property from which the selection starts.
|
793
717
|
* @param {number|string} [endColumn] Visual column index or column property from to the selection finishes.
|
794
|
-
* @param {number} [headerLevel
|
795
|
-
*
|
796
|
-
*
|
718
|
+
* @param {number} [headerLevel=-1] A row header index that triggers the column selection. The value can
|
719
|
+
* take -1 to -N, where -1 means the header closest to the cells.
|
720
|
+
*
|
797
721
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
798
722
|
*/
|
799
723
|
}, {
|
800
724
|
key: "selectColumns",
|
801
725
|
value: function selectColumns(startColumn) {
|
802
726
|
var endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
|
803
|
-
var headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
727
|
+
var headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
804
728
|
var start = typeof startColumn === 'string' ? this.tableProps.propToCol(startColumn) : startColumn;
|
805
729
|
var end = typeof endColumn === 'string' ? this.tableProps.propToCol(endColumn) : endColumn;
|
806
|
-
var
|
807
|
-
var
|
808
|
-
var
|
809
|
-
var columnHeaderLastIndex = countColHeaders === 0 ? 0 : -countColHeaders;
|
810
|
-
var fromCoords = new CellCoords(columnHeaderLastIndex, start);
|
811
|
-
var toCoords = new CellCoords(countRows - 1, end);
|
812
|
-
var isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
|
813
|
-
countRows: countRows,
|
814
|
-
countCols: countCols,
|
815
|
-
countRowHeaders: 0,
|
816
|
-
countColHeaders: countColHeaders
|
817
|
-
});
|
730
|
+
var nrOfColumns = this.tableProps.countCols();
|
731
|
+
var nrOfRows = this.tableProps.countRows();
|
732
|
+
var isValid = isValidCoord(start, nrOfColumns) && isValidCoord(end, nrOfColumns);
|
818
733
|
if (isValid) {
|
819
|
-
|
820
|
-
|
821
|
-
this.setRangeStartOnly(from, void 0, highlight);
|
822
|
-
this.selectedByColumnHeader.add(this.getLayerLevel());
|
823
|
-
this.setRangeEnd(this.tableProps.createCellCoords(countRows - 1, end));
|
734
|
+
this.setRangeStartOnly(this.tableProps.createCellCoords(headerLevel, start));
|
735
|
+
this.setRangeEnd(this.tableProps.createCellCoords(nrOfRows - 1, end));
|
824
736
|
this.finish();
|
825
737
|
}
|
826
738
|
return isValid;
|
@@ -831,34 +743,22 @@ var Selection = /*#__PURE__*/function () {
|
|
831
743
|
*
|
832
744
|
* @param {number} startRow Visual row index from which the selection starts.
|
833
745
|
* @param {number} [endRow] Visual row index from to the selection finishes.
|
834
|
-
* @param {number} [headerLevel
|
835
|
-
*
|
836
|
-
*
|
746
|
+
* @param {number} [headerLevel=-1] A column header index that triggers the row selection.
|
747
|
+
* The value can take -1 to -N, where -1 means the header
|
748
|
+
* closest to the cells.
|
837
749
|
* @returns {boolean} Returns `true` if selection was successful, `false` otherwise.
|
838
750
|
*/
|
839
751
|
}, {
|
840
752
|
key: "selectRows",
|
841
753
|
value: function selectRows(startRow) {
|
842
754
|
var endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
|
843
|
-
var headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
844
|
-
var
|
845
|
-
var
|
846
|
-
var
|
847
|
-
var rowHeaderLastIndex = countRowHeaders === 0 ? 0 : -countRowHeaders;
|
848
|
-
var fromCoords = new CellCoords(startRow, rowHeaderLastIndex);
|
849
|
-
var toCoords = new CellCoords(endRow, countCols - 1);
|
850
|
-
var isValid = new CellRange(fromCoords, fromCoords, toCoords).isValid({
|
851
|
-
countRows: countRows,
|
852
|
-
countCols: countCols,
|
853
|
-
countRowHeaders: countRowHeaders,
|
854
|
-
countColHeaders: 0
|
855
|
-
});
|
755
|
+
var headerLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
756
|
+
var nrOfRows = this.tableProps.countRows();
|
757
|
+
var nrOfColumns = this.tableProps.countCols();
|
758
|
+
var isValid = isValidCoord(startRow, nrOfRows) && isValidCoord(endRow, nrOfRows);
|
856
759
|
if (isValid) {
|
857
|
-
|
858
|
-
|
859
|
-
this.setRangeStartOnly(from, void 0, highlight);
|
860
|
-
this.selectedByRowHeader.add(this.getLayerLevel());
|
861
|
-
this.setRangeEnd(this.tableProps.createCellCoords(endRow, countCols - 1));
|
760
|
+
this.setRangeStartOnly(this.tableProps.createCellCoords(startRow, headerLevel));
|
761
|
+
this.setRangeEnd(this.tableProps.createCellCoords(endRow, nrOfColumns - 1));
|
862
762
|
this.finish();
|
863
763
|
}
|
864
764
|
return isValid;
|
@@ -877,31 +777,19 @@ var Selection = /*#__PURE__*/function () {
|
|
877
777
|
if (!this.isSelected()) {
|
878
778
|
return;
|
879
779
|
}
|
880
|
-
var
|
780
|
+
var cellHighlight = this.highlight.getCell();
|
881
781
|
var currentLayer = this.getLayerLevel();
|
882
|
-
|
782
|
+
cellHighlight.commit().syncWith(this.selectedRange.current());
|
883
783
|
|
884
784
|
// Rewriting rendered ranges going through all layers.
|
885
785
|
for (var layerLevel = 0; layerLevel < this.selectedRange.size(); layerLevel += 1) {
|
886
786
|
this.highlight.useLayerLevel(layerLevel);
|
887
|
-
var areaHighlight = this.highlight.
|
888
|
-
var
|
889
|
-
var
|
890
|
-
var columnHeaderHighlight = this.highlight.createColumnHeader();
|
891
|
-
var activeRowHeaderHighlight = this.highlight.createActiveRowHeader();
|
892
|
-
var activeColumnHeaderHighlight = this.highlight.createActiveColumnHeader();
|
893
|
-
var activeCornerHeaderHighlight = this.highlight.createActiveCornerHeader();
|
894
|
-
var rowHighlight = this.highlight.createRowHighlight();
|
895
|
-
var columnHighlight = this.highlight.createColumnHighlight();
|
787
|
+
var areaHighlight = this.highlight.createOrGetArea();
|
788
|
+
var headerHighlight = this.highlight.createOrGetHeader();
|
789
|
+
var activeHeaderHighlight = this.highlight.createOrGetActiveHeader();
|
896
790
|
areaHighlight.commit();
|
897
|
-
|
898
|
-
|
899
|
-
columnHeaderHighlight.commit();
|
900
|
-
activeRowHeaderHighlight.commit();
|
901
|
-
activeColumnHeaderHighlight.commit();
|
902
|
-
activeCornerHeaderHighlight.commit();
|
903
|
-
rowHighlight.commit();
|
904
|
-
columnHighlight.commit();
|
791
|
+
headerHighlight.commit();
|
792
|
+
activeHeaderHighlight.commit();
|
905
793
|
}
|
906
794
|
|
907
795
|
// Reverting starting layer for the Highlight.
|