handsontable 0.0.0-next-59715d3-20230523 → 0.0.0-next-93e34dc-20230601
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 +61 -12
- package/3rdparty/walkontable/src/cell/coords.mjs +61 -12
- package/3rdparty/walkontable/src/cell/range.d.ts +9 -2
- package/3rdparty/walkontable/src/cell/range.js +44 -7
- package/3rdparty/walkontable/src/cell/range.mjs +44 -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 -4
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +2 -4
- package/3rdparty/walkontable/src/overlay/top.js +2 -4
- package/3rdparty/walkontable/src/overlay/top.mjs +2 -4
- 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 +18 -0
- package/3rdparty/walkontable/src/selection/border/constants.mjs +13 -0
- package/3rdparty/walkontable/src/selection/constants.js +63 -0
- package/3rdparty/walkontable/src/selection/constants.mjs +51 -0
- package/3rdparty/walkontable/src/selection/index.js +30 -0
- package/3rdparty/walkontable/src/selection/index.mjs +5 -0
- package/3rdparty/walkontable/src/selection/manager.js +328 -0
- package/3rdparty/walkontable/src/selection/manager.mjs +322 -0
- package/3rdparty/walkontable/src/selection/scanner.js +363 -0
- package/3rdparty/walkontable/src/selection/scanner.mjs +359 -0
- package/3rdparty/walkontable/src/selection/selection.js +133 -0
- package/3rdparty/walkontable/src/selection/selection.mjs +127 -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 +7 -79
- package/3rdparty/walkontable/src/table.mjs +8 -80
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core.d.ts +5 -3
- package/core.js +82 -300
- package/core.mjs +82 -300
- package/dataMap/metaManager/metaSchema.js +15 -0
- package/dataMap/metaManager/metaSchema.mjs +15 -0
- package/dist/handsontable.css +8 -3
- package/dist/handsontable.full.css +8 -3
- package/dist/handsontable.full.js +12245 -9953
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +120 -120
- package/dist/handsontable.js +15898 -13606
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +4 -4
- package/editorManager.js +20 -82
- package/editorManager.mjs +25 -86
- 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.js +1 -1
- package/pluginHooks.mjs +1 -1
- package/plugins/copyPaste/copyPaste.js +5 -1
- package/plugins/copyPaste/copyPaste.mjs +5 -1
- package/plugins/customBorders/customBorders.js +18 -52
- package/plugins/customBorders/customBorders.mjs +19 -53
- package/plugins/mergeCells/mergeCells.js +5 -18
- package/plugins/mergeCells/mergeCells.mjs +5 -18
- package/plugins/nestedHeaders/nestedHeaders.js +89 -9
- package/plugins/nestedHeaders/nestedHeaders.mjs +89 -9
- package/plugins/nestedHeaders/stateManager/index.js +37 -0
- package/plugins/nestedHeaders/stateManager/index.mjs +37 -0
- package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
- package/selection/highlight/highlight.js +311 -88
- package/selection/highlight/highlight.mjs +301 -84
- package/selection/highlight/types/activeHeader.js +10 -9
- package/selection/highlight/types/activeHeader.mjs +10 -8
- package/selection/highlight/types/area.js +12 -27
- package/selection/highlight/types/area.mjs +16 -30
- package/selection/highlight/types/areaLayered.js +54 -0
- package/selection/highlight/types/areaLayered.mjs +49 -0
- package/selection/highlight/types/column.js +50 -0
- package/selection/highlight/types/column.mjs +45 -0
- package/selection/highlight/types/customSelection.js +7 -10
- package/selection/highlight/types/customSelection.mjs +7 -9
- package/selection/highlight/types/fill.js +5 -8
- package/selection/highlight/types/fill.mjs +5 -7
- package/selection/highlight/types/{cell.js → focus.js} +5 -8
- package/selection/highlight/types/{cell.mjs → focus.mjs} +5 -7
- package/selection/highlight/types/header.js +10 -20
- package/selection/highlight/types/header.mjs +10 -19
- package/selection/highlight/types/{index.js → row.js} +27 -31
- package/selection/highlight/types/{index.mjs → row.mjs} +24 -29
- package/selection/highlight/visualSelection.js +23 -28
- package/selection/highlight/visualSelection.mjs +23 -28
- 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 +296 -180
- package/selection/selection.mjs +291 -179
- package/selection/transformation.js +233 -96
- package/selection/transformation.mjs +230 -93
- package/selection/utils.js +12 -35
- package/selection/utils.mjs +13 -35
- package/settings.d.ts +1 -0
- package/shortcutContexts/commands/editor/closeAndSave.js +15 -0
- package/shortcutContexts/commands/editor/closeAndSave.mjs +10 -0
- package/shortcutContexts/commands/editor/closeWithoutSaving.js +13 -0
- package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +8 -0
- package/shortcutContexts/commands/editor/fastOpen.js +16 -0
- package/shortcutContexts/commands/editor/fastOpen.mjs +11 -0
- package/shortcutContexts/commands/editor/index.js +16 -0
- package/shortcutContexts/commands/editor/index.mjs +12 -0
- package/shortcutContexts/commands/editor/open.js +29 -0
- package/shortcutContexts/commands/editor/open.mjs +24 -0
- package/shortcutContexts/commands/emptySelectedCells.js +12 -0
- package/shortcutContexts/commands/emptySelectedCells.mjs +7 -0
- package/shortcutContexts/commands/extendCellsSelection/down.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +10 -0
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +21 -0
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +16 -0
- package/shortcutContexts/commands/extendCellsSelection/index.js +24 -0
- package/shortcutContexts/commands/extendCellsSelection/index.mjs +20 -0
- package/shortcutContexts/commands/extendCellsSelection/left.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +10 -0
- package/shortcutContexts/commands/extendCellsSelection/right.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +10 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +22 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +17 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +17 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +12 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +17 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +12 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +39 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +34 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +39 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +34 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +22 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +17 -0
- package/shortcutContexts/commands/extendCellsSelection/up.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +10 -0
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +21 -0
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +16 -0
- package/shortcutContexts/commands/index.js +51 -0
- package/shortcutContexts/commands/index.mjs +47 -0
- package/shortcutContexts/commands/moveCellSelection/down.js +12 -0
- package/shortcutContexts/commands/moveCellSelection/down.mjs +7 -0
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +11 -0
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +6 -0
- package/shortcutContexts/commands/moveCellSelection/index.js +28 -0
- package/shortcutContexts/commands/moveCellSelection/index.mjs +24 -0
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +13 -0
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +8 -0
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +13 -0
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +8 -0
- package/shortcutContexts/commands/moveCellSelection/left.js +11 -0
- package/shortcutContexts/commands/moveCellSelection/left.mjs +6 -0
- package/shortcutContexts/commands/moveCellSelection/right.js +11 -0
- package/shortcutContexts/commands/moveCellSelection/right.mjs +6 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +16 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +11 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +17 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +12 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +13 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +8 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +16 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +11 -0
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +35 -0
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +30 -0
- package/shortcutContexts/commands/moveCellSelection/toMostRight.js +35 -0
- package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +30 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTop.js +16 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +11 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +18 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +13 -0
- package/shortcutContexts/commands/moveCellSelection/up.js +12 -0
- package/shortcutContexts/commands/moveCellSelection/up.mjs +7 -0
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +11 -0
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +6 -0
- package/shortcutContexts/commands/populateSelectedCellsData.js +35 -0
- package/shortcutContexts/commands/populateSelectedCellsData.mjs +30 -0
- package/shortcutContexts/commands/selectAll.js +11 -0
- package/shortcutContexts/commands/selectAll.mjs +6 -0
- package/shortcutContexts/constants.js +19 -0
- package/shortcutContexts/constants.mjs +12 -0
- package/shortcutContexts/editor.js +29 -0
- package/shortcutContexts/editor.mjs +25 -0
- package/shortcutContexts/grid.js +232 -0
- package/shortcutContexts/grid.mjs +228 -0
- package/shortcutContexts/index.js +29 -0
- package/shortcutContexts/index.mjs +15 -0
- package/tableView.js +58 -9
- package/tableView.mjs +58 -9
- package/3rdparty/walkontable/src/selection.js +0 -354
- package/3rdparty/walkontable/src/selection.mjs +0 -348
- package/selection/highlight/constants.js +0 -16
- package/selection/highlight/constants.mjs +0 -6
@@ -0,0 +1,359 @@
|
|
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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
3
|
+
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."); }
|
4
|
+
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); }
|
5
|
+
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; }
|
6
|
+
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; } }
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
8
|
+
import "core-js/modules/es.array.iterator.js";
|
9
|
+
import "core-js/modules/es.object.to-string.js";
|
10
|
+
import "core-js/modules/es.set.js";
|
11
|
+
import "core-js/modules/es.string.iterator.js";
|
12
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
13
|
+
import "core-js/modules/es.weak-map.js";
|
14
|
+
import "core-js/modules/es.weak-set.js";
|
15
|
+
import "core-js/modules/es.symbol.to-primitive.js";
|
16
|
+
import "core-js/modules/es.date.to-primitive.js";
|
17
|
+
import "core-js/modules/es.symbol.js";
|
18
|
+
import "core-js/modules/es.symbol.description.js";
|
19
|
+
import "core-js/modules/es.number.constructor.js";
|
20
|
+
import "core-js/modules/es.symbol.iterator.js";
|
21
|
+
import "core-js/modules/es.array.slice.js";
|
22
|
+
import "core-js/modules/es.function.name.js";
|
23
|
+
import "core-js/modules/es.array.from.js";
|
24
|
+
import "core-js/modules/es.regexp.exec.js";
|
25
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
26
|
+
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); } }
|
27
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
28
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
29
|
+
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); }
|
30
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
31
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
32
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
33
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
34
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
35
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
36
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
37
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
38
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
39
|
+
/* eslint-disable no-continue */
|
40
|
+
import { addClass } from "../../../../helpers/dom/element.mjs";
|
41
|
+
/**
|
42
|
+
* Selection scanner module scans the rendered cells and headers and if it finds an intersection with
|
43
|
+
* the coordinates of the Selection class (highlight) it returns the DOM elements.
|
44
|
+
*
|
45
|
+
* @private
|
46
|
+
*/
|
47
|
+
var _selection = /*#__PURE__*/new WeakMap();
|
48
|
+
var _activeOverlaysWot = /*#__PURE__*/new WeakMap();
|
49
|
+
var _scanCellsRange = /*#__PURE__*/new WeakSet();
|
50
|
+
export var SelectionScanner = /*#__PURE__*/function () {
|
51
|
+
function SelectionScanner() {
|
52
|
+
_classCallCheck(this, SelectionScanner);
|
53
|
+
/**
|
54
|
+
* The method triggers a callback for each rendered cell.
|
55
|
+
*
|
56
|
+
* @param {function(number, number): void} callback The callback function to trigger.
|
57
|
+
*/
|
58
|
+
_classPrivateMethodInitSpec(this, _scanCellsRange);
|
59
|
+
/**
|
60
|
+
* Active Selection instance to process.
|
61
|
+
*
|
62
|
+
* @type {Selection}
|
63
|
+
*/
|
64
|
+
_classPrivateFieldInitSpec(this, _selection, {
|
65
|
+
writable: true,
|
66
|
+
value: void 0
|
67
|
+
});
|
68
|
+
/**
|
69
|
+
* The Walkontable instance that the scans depends on.
|
70
|
+
*
|
71
|
+
* @type {Walkontable}
|
72
|
+
*/
|
73
|
+
_classPrivateFieldInitSpec(this, _activeOverlaysWot, {
|
74
|
+
writable: true,
|
75
|
+
value: void 0
|
76
|
+
});
|
77
|
+
}
|
78
|
+
_createClass(SelectionScanner, [{
|
79
|
+
key: "setActiveOverlay",
|
80
|
+
value:
|
81
|
+
/**
|
82
|
+
* Sets the Walkontable instance that will be taking into account while scanning the table.
|
83
|
+
*
|
84
|
+
* @param {Walkontable} activeOverlaysWot The Walkontable instance.
|
85
|
+
* @returns {SelectionScanner}
|
86
|
+
*/
|
87
|
+
function setActiveOverlay(activeOverlaysWot) {
|
88
|
+
_classPrivateFieldSet(this, _activeOverlaysWot, activeOverlaysWot);
|
89
|
+
return this;
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Sets the Selection instance to process.
|
94
|
+
*
|
95
|
+
* @param {Selection} selection The Selection instance.
|
96
|
+
* @returns {SelectionScanner}
|
97
|
+
*/
|
98
|
+
}, {
|
99
|
+
key: "setActiveSelection",
|
100
|
+
value: function setActiveSelection(selection) {
|
101
|
+
_classPrivateFieldSet(this, _selection, selection);
|
102
|
+
return this;
|
103
|
+
}
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Scans the rendered table with selection and returns elements that intersects
|
107
|
+
* with selection coordinates.
|
108
|
+
*
|
109
|
+
* @returns {HTMLTableElement[]}
|
110
|
+
*/
|
111
|
+
}, {
|
112
|
+
key: "scan",
|
113
|
+
value: function scan() {
|
114
|
+
var selectionType = _classPrivateFieldGet(this, _selection).settings.selectionType;
|
115
|
+
var elements = new Set();
|
116
|
+
|
117
|
+
// TODO(improvement): use heuristics from coords to detect what type of scan
|
118
|
+
// the Selection needs instead of using `selectionType` property.
|
119
|
+
if (selectionType === 'active-header') {
|
120
|
+
this.scanColumnsInHeadersRange(function (element) {
|
121
|
+
return elements.add(element);
|
122
|
+
});
|
123
|
+
this.scanRowsInHeadersRange(function (element) {
|
124
|
+
return elements.add(element);
|
125
|
+
});
|
126
|
+
} else if (selectionType === 'area') {
|
127
|
+
this.scanCellsRange(function (element) {
|
128
|
+
return elements.add(element);
|
129
|
+
});
|
130
|
+
} else if (selectionType === 'focus') {
|
131
|
+
this.scanColumnsInHeadersRange(function (element) {
|
132
|
+
return elements.add(element);
|
133
|
+
});
|
134
|
+
this.scanRowsInHeadersRange(function (element) {
|
135
|
+
return elements.add(element);
|
136
|
+
});
|
137
|
+
this.scanCellsRange(function (element) {
|
138
|
+
return elements.add(element);
|
139
|
+
});
|
140
|
+
} else if (selectionType === 'fill') {
|
141
|
+
this.scanCellsRange(function (element) {
|
142
|
+
return elements.add(element);
|
143
|
+
});
|
144
|
+
} else if (selectionType === 'header') {
|
145
|
+
this.scanColumnsInHeadersRange(function (element) {
|
146
|
+
return elements.add(element);
|
147
|
+
});
|
148
|
+
this.scanRowsInHeadersRange(function (element) {
|
149
|
+
return elements.add(element);
|
150
|
+
});
|
151
|
+
} else if (selectionType === 'row') {
|
152
|
+
this.scanRowsInHeadersRange(function (element) {
|
153
|
+
return elements.add(element);
|
154
|
+
});
|
155
|
+
this.scanRowsInCellsRange(function (element) {
|
156
|
+
return elements.add(element);
|
157
|
+
});
|
158
|
+
} else if (selectionType === 'column') {
|
159
|
+
this.scanColumnsInHeadersRange(function (element) {
|
160
|
+
return elements.add(element);
|
161
|
+
});
|
162
|
+
this.scanColumnsInCellsRange(function (element) {
|
163
|
+
return elements.add(element);
|
164
|
+
});
|
165
|
+
}
|
166
|
+
return elements;
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Scans the table (only rendered headers) and collect all column headers (TH) that match
|
171
|
+
* the coordinates passed in the Selection instance.
|
172
|
+
*
|
173
|
+
* @param {function(HTMLTableElement): void} callback The callback function to trigger.
|
174
|
+
*/
|
175
|
+
}, {
|
176
|
+
key: "scanColumnsInHeadersRange",
|
177
|
+
value: function scanColumnsInHeadersRange(callback) {
|
178
|
+
var _classPrivateFieldGet2 = _classPrivateFieldGet(this, _selection).getCorners(),
|
179
|
+
_classPrivateFieldGet3 = _slicedToArray(_classPrivateFieldGet2, 4),
|
180
|
+
topRow = _classPrivateFieldGet3[0],
|
181
|
+
topColumn = _classPrivateFieldGet3[1],
|
182
|
+
bottomRow = _classPrivateFieldGet3[2],
|
183
|
+
bottomColumn = _classPrivateFieldGet3[3];
|
184
|
+
var _classPrivateFieldGet4 = _classPrivateFieldGet(this, _activeOverlaysWot),
|
185
|
+
wtTable = _classPrivateFieldGet4.wtTable;
|
186
|
+
var renderedColumnsCount = wtTable.getRenderedColumnsCount();
|
187
|
+
var columnHeadersCount = wtTable.getColumnHeadersCount();
|
188
|
+
var cursor = 0;
|
189
|
+
for (var column = -wtTable.getRowHeadersCount(); column < renderedColumnsCount; column++) {
|
190
|
+
var sourceColumn = wtTable.columnFilter.renderedToSource(column);
|
191
|
+
if (sourceColumn < topColumn || sourceColumn > bottomColumn) {
|
192
|
+
continue;
|
193
|
+
}
|
194
|
+
for (var headerLevel = -columnHeadersCount; headerLevel < 0; headerLevel++) {
|
195
|
+
if (headerLevel < topRow || headerLevel > bottomRow) {
|
196
|
+
continue;
|
197
|
+
}
|
198
|
+
var positiveBasedHeaderLevel = headerLevel + columnHeadersCount;
|
199
|
+
var TH = wtTable.getColumnHeader(sourceColumn, positiveBasedHeaderLevel);
|
200
|
+
var newSourceCol = _classPrivateFieldGet(this, _activeOverlaysWot).getSetting('onBeforeHighlightingColumnHeader', sourceColumn, positiveBasedHeaderLevel, {
|
201
|
+
selectionType: _classPrivateFieldGet(this, _selection).settings.selectionType,
|
202
|
+
columnCursor: cursor,
|
203
|
+
selectionWidth: bottomColumn - topColumn + 1
|
204
|
+
});
|
205
|
+
if (newSourceCol === null) {
|
206
|
+
continue;
|
207
|
+
}
|
208
|
+
if (newSourceCol !== sourceColumn) {
|
209
|
+
TH = wtTable.getColumnHeader(newSourceCol, positiveBasedHeaderLevel);
|
210
|
+
}
|
211
|
+
callback(TH);
|
212
|
+
}
|
213
|
+
cursor += 1;
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
/**
|
218
|
+
* Scans the table (only rendered headers) and collect all row headers (TH) that match
|
219
|
+
* the coordinates passed in the Selection instance.
|
220
|
+
*
|
221
|
+
* @param {function(HTMLTableElement): void} callback The callback function to trigger.
|
222
|
+
*/
|
223
|
+
}, {
|
224
|
+
key: "scanRowsInHeadersRange",
|
225
|
+
value: function scanRowsInHeadersRange(callback) {
|
226
|
+
var _classPrivateFieldGet5 = _classPrivateFieldGet(this, _selection).getCorners(),
|
227
|
+
_classPrivateFieldGet6 = _slicedToArray(_classPrivateFieldGet5, 4),
|
228
|
+
topRow = _classPrivateFieldGet6[0],
|
229
|
+
topColumn = _classPrivateFieldGet6[1],
|
230
|
+
bottomRow = _classPrivateFieldGet6[2],
|
231
|
+
bottomColumn = _classPrivateFieldGet6[3];
|
232
|
+
var _classPrivateFieldGet7 = _classPrivateFieldGet(this, _activeOverlaysWot),
|
233
|
+
wtTable = _classPrivateFieldGet7.wtTable;
|
234
|
+
var renderedRowsCount = wtTable.getRenderedRowsCount();
|
235
|
+
var rowHeadersCount = wtTable.getRowHeadersCount();
|
236
|
+
var cursor = 0;
|
237
|
+
for (var row = -wtTable.getColumnHeadersCount(); row < renderedRowsCount; row++) {
|
238
|
+
var sourceRow = wtTable.rowFilter.renderedToSource(row);
|
239
|
+
if (sourceRow < topRow || sourceRow > bottomRow) {
|
240
|
+
continue;
|
241
|
+
}
|
242
|
+
for (var headerLevel = -rowHeadersCount; headerLevel < 0; headerLevel++) {
|
243
|
+
if (headerLevel < topColumn || headerLevel > bottomColumn) {
|
244
|
+
continue;
|
245
|
+
}
|
246
|
+
var positiveBasedHeaderLevel = headerLevel + rowHeadersCount;
|
247
|
+
var TH = wtTable.getRowHeader(sourceRow, positiveBasedHeaderLevel);
|
248
|
+
var newSourceRow = _classPrivateFieldGet(this, _activeOverlaysWot).getSetting('onBeforeHighlightingRowHeader', sourceRow, positiveBasedHeaderLevel, {
|
249
|
+
selectionType: _classPrivateFieldGet(this, _selection).settings.selectionType,
|
250
|
+
rowCursor: cursor,
|
251
|
+
selectionHeight: bottomRow - topRow + 1
|
252
|
+
});
|
253
|
+
if (newSourceRow === null) {
|
254
|
+
continue;
|
255
|
+
}
|
256
|
+
if (newSourceRow !== sourceRow) {
|
257
|
+
TH = wtTable.getRowHeader(newSourceRow, positiveBasedHeaderLevel);
|
258
|
+
}
|
259
|
+
callback(TH);
|
260
|
+
}
|
261
|
+
cursor += 1;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Scans the table (only rendered cells) and collect all cells (TR) that match
|
267
|
+
* the coordinates passed in the Selection instance.
|
268
|
+
*
|
269
|
+
* @param {function(HTMLTableElement): void} callback The callback function to trigger.
|
270
|
+
*/
|
271
|
+
}, {
|
272
|
+
key: "scanCellsRange",
|
273
|
+
value: function scanCellsRange(callback) {
|
274
|
+
var _this = this;
|
275
|
+
var _classPrivateFieldGet8 = _classPrivateFieldGet(this, _selection).getCorners(),
|
276
|
+
_classPrivateFieldGet9 = _slicedToArray(_classPrivateFieldGet8, 4),
|
277
|
+
topRow = _classPrivateFieldGet9[0],
|
278
|
+
topColumn = _classPrivateFieldGet9[1],
|
279
|
+
bottomRow = _classPrivateFieldGet9[2],
|
280
|
+
bottomColumn = _classPrivateFieldGet9[3];
|
281
|
+
var _classPrivateFieldGet10 = _classPrivateFieldGet(this, _activeOverlaysWot),
|
282
|
+
wtTable = _classPrivateFieldGet10.wtTable;
|
283
|
+
_classPrivateMethodGet(this, _scanCellsRange, _scanCellsRange2).call(this, function (sourceRow, sourceColumn) {
|
284
|
+
if (sourceRow >= topRow && sourceRow <= bottomRow && sourceColumn >= topColumn && sourceColumn <= bottomColumn) {
|
285
|
+
var cell = wtTable.getCell(_classPrivateFieldGet(_this, _activeOverlaysWot).createCellCoords(sourceRow, sourceColumn));
|
286
|
+
|
287
|
+
// support for old API
|
288
|
+
var additionalSelectionClass = _classPrivateFieldGet(_this, _activeOverlaysWot).getSetting('onAfterDrawSelection', sourceRow, sourceColumn, _classPrivateFieldGet(_this, _selection).settings.layerLevel);
|
289
|
+
if (typeof additionalSelectionClass === 'string') {
|
290
|
+
addClass(cell, additionalSelectionClass);
|
291
|
+
}
|
292
|
+
callback(cell);
|
293
|
+
}
|
294
|
+
});
|
295
|
+
}
|
296
|
+
|
297
|
+
/**
|
298
|
+
* Scans the table (only rendered cells) and collects all cells (TR) that match the coordinates
|
299
|
+
* passed in the Selection instance but only for the X axis (rows).
|
300
|
+
*
|
301
|
+
* @param {function(HTMLTableElement): void} callback The callback function to trigger.
|
302
|
+
*/
|
303
|
+
}, {
|
304
|
+
key: "scanRowsInCellsRange",
|
305
|
+
value: function scanRowsInCellsRange(callback) {
|
306
|
+
var _this2 = this;
|
307
|
+
// eslint-disable-next-line comma-spacing
|
308
|
+
var _classPrivateFieldGet11 = _classPrivateFieldGet(this, _selection).getCorners(),
|
309
|
+
_classPrivateFieldGet12 = _slicedToArray(_classPrivateFieldGet11, 3),
|
310
|
+
topRow = _classPrivateFieldGet12[0],
|
311
|
+
bottomRow = _classPrivateFieldGet12[2];
|
312
|
+
var _classPrivateFieldGet13 = _classPrivateFieldGet(this, _activeOverlaysWot),
|
313
|
+
wtTable = _classPrivateFieldGet13.wtTable;
|
314
|
+
_classPrivateMethodGet(this, _scanCellsRange, _scanCellsRange2).call(this, function (sourceRow, sourceColumn) {
|
315
|
+
if (sourceRow >= topRow && sourceRow <= bottomRow) {
|
316
|
+
var cell = wtTable.getCell(_classPrivateFieldGet(_this2, _activeOverlaysWot).createCellCoords(sourceRow, sourceColumn));
|
317
|
+
callback(cell);
|
318
|
+
}
|
319
|
+
});
|
320
|
+
}
|
321
|
+
|
322
|
+
/**
|
323
|
+
* Scans the table (only rendered cells) and collects all cells (TR) that match the coordinates
|
324
|
+
* passed in the Selection instance but only for the Y axis (columns).
|
325
|
+
*
|
326
|
+
* @param {function(HTMLTableElement): void} callback The callback function to trigger.
|
327
|
+
*/
|
328
|
+
}, {
|
329
|
+
key: "scanColumnsInCellsRange",
|
330
|
+
value: function scanColumnsInCellsRange(callback) {
|
331
|
+
var _this3 = this;
|
332
|
+
var _classPrivateFieldGet14 = _classPrivateFieldGet(this, _selection).getCorners(),
|
333
|
+
_classPrivateFieldGet15 = _slicedToArray(_classPrivateFieldGet14, 4),
|
334
|
+
topColumn = _classPrivateFieldGet15[1],
|
335
|
+
bottomColumn = _classPrivateFieldGet15[3];
|
336
|
+
var _classPrivateFieldGet16 = _classPrivateFieldGet(this, _activeOverlaysWot),
|
337
|
+
wtTable = _classPrivateFieldGet16.wtTable;
|
338
|
+
_classPrivateMethodGet(this, _scanCellsRange, _scanCellsRange2).call(this, function (sourceRow, sourceColumn) {
|
339
|
+
if (sourceColumn >= topColumn && sourceColumn <= bottomColumn) {
|
340
|
+
var cell = wtTable.getCell(_classPrivateFieldGet(_this3, _activeOverlaysWot).createCellCoords(sourceRow, sourceColumn));
|
341
|
+
callback(cell);
|
342
|
+
}
|
343
|
+
});
|
344
|
+
}
|
345
|
+
}]);
|
346
|
+
return SelectionScanner;
|
347
|
+
}();
|
348
|
+
function _scanCellsRange2(callback) {
|
349
|
+
var _classPrivateFieldGet17 = _classPrivateFieldGet(this, _activeOverlaysWot),
|
350
|
+
wtTable = _classPrivateFieldGet17.wtTable;
|
351
|
+
var renderedRowsCount = wtTable.getRenderedRowsCount();
|
352
|
+
var renderedColumnsCount = wtTable.getRenderedColumnsCount();
|
353
|
+
for (var row = 0; row < renderedRowsCount; row += 1) {
|
354
|
+
var sourceRow = wtTable.rowFilter.renderedToSource(row);
|
355
|
+
for (var column = 0; column < renderedColumnsCount; column += 1) {
|
356
|
+
callback(sourceRow, wtTable.columnFilter.renderedToSource(column));
|
357
|
+
}
|
358
|
+
}
|
359
|
+
}
|
@@ -0,0 +1,133 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
require("core-js/modules/es.symbol.iterator.js");
|
4
|
+
require("core-js/modules/es.array.iterator.js");
|
5
|
+
require("core-js/modules/es.string.iterator.js");
|
6
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
7
|
+
exports.__esModule = true;
|
8
|
+
exports.default = void 0;
|
9
|
+
require("core-js/modules/es.symbol.to-primitive.js");
|
10
|
+
require("core-js/modules/es.date.to-primitive.js");
|
11
|
+
require("core-js/modules/es.symbol.js");
|
12
|
+
require("core-js/modules/es.symbol.description.js");
|
13
|
+
require("core-js/modules/es.object.to-string.js");
|
14
|
+
require("core-js/modules/es.number.constructor.js");
|
15
|
+
var _object = require("../../../../helpers/object");
|
16
|
+
var _localHooks = _interopRequireDefault(require("../../../../mixins/localHooks"));
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
|
+
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); }
|
19
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
20
|
+
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); } }
|
21
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
22
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
23
|
+
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); }
|
24
|
+
/**
|
25
|
+
* The Selection class allows highlighting (by applying CSS class) the table's cells or headers
|
26
|
+
* and setting up the borders if defined in the settings.
|
27
|
+
*
|
28
|
+
* The Selection coordinates may point to the cells (positive numbers) or headers (negative numbers).
|
29
|
+
*
|
30
|
+
* @class Selection
|
31
|
+
*/
|
32
|
+
var Selection = /*#__PURE__*/function () {
|
33
|
+
/**
|
34
|
+
* @param {object} settings The selection settings object. @todo type.
|
35
|
+
* @param {CellRange} cellRange The cell range instance.
|
36
|
+
*/
|
37
|
+
function Selection(settings, cellRange) {
|
38
|
+
_classCallCheck(this, Selection);
|
39
|
+
this.settings = settings;
|
40
|
+
this.cellRange = cellRange || null;
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Checks if selection is empty.
|
45
|
+
*
|
46
|
+
* @returns {boolean}
|
47
|
+
*/
|
48
|
+
_createClass(Selection, [{
|
49
|
+
key: "isEmpty",
|
50
|
+
value: function isEmpty() {
|
51
|
+
return this.cellRange === null;
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Adds a cell coords to the selection.
|
56
|
+
*
|
57
|
+
* @param {CellCoords} coords The cell coordinates to add.
|
58
|
+
* @returns {Selection}
|
59
|
+
*/
|
60
|
+
}, {
|
61
|
+
key: "add",
|
62
|
+
value: function add(coords) {
|
63
|
+
if (this.isEmpty()) {
|
64
|
+
this.cellRange = this.settings.createCellRange(coords);
|
65
|
+
} else {
|
66
|
+
this.cellRange.expand(coords);
|
67
|
+
}
|
68
|
+
return this;
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
|
73
|
+
* information about success.
|
74
|
+
*
|
75
|
+
* @param {CellCoords} oldCoords An old cell coordinates to replace.
|
76
|
+
* @param {CellCoords} newCoords The new cell coordinates.
|
77
|
+
* @returns {boolean}
|
78
|
+
*/
|
79
|
+
}, {
|
80
|
+
key: "replace",
|
81
|
+
value: function replace(oldCoords, newCoords) {
|
82
|
+
if (!this.isEmpty()) {
|
83
|
+
if (this.cellRange.from.isEqual(oldCoords)) {
|
84
|
+
this.cellRange.from = newCoords;
|
85
|
+
return true;
|
86
|
+
}
|
87
|
+
if (this.cellRange.to.isEqual(oldCoords)) {
|
88
|
+
this.cellRange.to = newCoords;
|
89
|
+
return true;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
return false;
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Clears selection.
|
97
|
+
*
|
98
|
+
* @returns {Selection}
|
99
|
+
*/
|
100
|
+
}, {
|
101
|
+
key: "clear",
|
102
|
+
value: function clear() {
|
103
|
+
this.cellRange = null;
|
104
|
+
return this;
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Returns the top left (or top right in RTL) and bottom right (or bottom left in RTL) selection coordinates.
|
109
|
+
*
|
110
|
+
* @returns {number[]} Returns array of coordinates for example `[1, 1, 5, 5]`.
|
111
|
+
*/
|
112
|
+
}, {
|
113
|
+
key: "getCorners",
|
114
|
+
value: function getCorners() {
|
115
|
+
var topStart = this.cellRange.getOuterTopStartCorner();
|
116
|
+
var bottomEnd = this.cellRange.getOuterBottomEndCorner();
|
117
|
+
return [topStart.row, topStart.col, bottomEnd.row, bottomEnd.col];
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Destroys the instance.
|
122
|
+
*/
|
123
|
+
}, {
|
124
|
+
key: "destroy",
|
125
|
+
value: function destroy() {
|
126
|
+
this.runLocalHooks('destroy');
|
127
|
+
}
|
128
|
+
}]);
|
129
|
+
return Selection;
|
130
|
+
}();
|
131
|
+
(0, _object.mixin)(Selection, _localHooks.default);
|
132
|
+
var _default = Selection;
|
133
|
+
exports.default = _default;
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import "core-js/modules/es.symbol.to-primitive.js";
|
2
|
+
import "core-js/modules/es.date.to-primitive.js";
|
3
|
+
import "core-js/modules/es.symbol.js";
|
4
|
+
import "core-js/modules/es.symbol.description.js";
|
5
|
+
import "core-js/modules/es.object.to-string.js";
|
6
|
+
import "core-js/modules/es.number.constructor.js";
|
7
|
+
import "core-js/modules/es.symbol.iterator.js";
|
8
|
+
import "core-js/modules/es.array.iterator.js";
|
9
|
+
import "core-js/modules/es.string.iterator.js";
|
10
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
11
|
+
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); }
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
13
|
+
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); } }
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
16
|
+
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); }
|
17
|
+
import { mixin } from "../../../../helpers/object.mjs";
|
18
|
+
import localHooks from "../../../../mixins/localHooks.mjs";
|
19
|
+
/**
|
20
|
+
* The Selection class allows highlighting (by applying CSS class) the table's cells or headers
|
21
|
+
* and setting up the borders if defined in the settings.
|
22
|
+
*
|
23
|
+
* The Selection coordinates may point to the cells (positive numbers) or headers (negative numbers).
|
24
|
+
*
|
25
|
+
* @class Selection
|
26
|
+
*/
|
27
|
+
var Selection = /*#__PURE__*/function () {
|
28
|
+
/**
|
29
|
+
* @param {object} settings The selection settings object. @todo type.
|
30
|
+
* @param {CellRange} cellRange The cell range instance.
|
31
|
+
*/
|
32
|
+
function Selection(settings, cellRange) {
|
33
|
+
_classCallCheck(this, Selection);
|
34
|
+
this.settings = settings;
|
35
|
+
this.cellRange = cellRange || null;
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Checks if selection is empty.
|
40
|
+
*
|
41
|
+
* @returns {boolean}
|
42
|
+
*/
|
43
|
+
_createClass(Selection, [{
|
44
|
+
key: "isEmpty",
|
45
|
+
value: function isEmpty() {
|
46
|
+
return this.cellRange === null;
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Adds a cell coords to the selection.
|
51
|
+
*
|
52
|
+
* @param {CellCoords} coords The cell coordinates to add.
|
53
|
+
* @returns {Selection}
|
54
|
+
*/
|
55
|
+
}, {
|
56
|
+
key: "add",
|
57
|
+
value: function add(coords) {
|
58
|
+
if (this.isEmpty()) {
|
59
|
+
this.cellRange = this.settings.createCellRange(coords);
|
60
|
+
} else {
|
61
|
+
this.cellRange.expand(coords);
|
62
|
+
}
|
63
|
+
return this;
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
|
68
|
+
* information about success.
|
69
|
+
*
|
70
|
+
* @param {CellCoords} oldCoords An old cell coordinates to replace.
|
71
|
+
* @param {CellCoords} newCoords The new cell coordinates.
|
72
|
+
* @returns {boolean}
|
73
|
+
*/
|
74
|
+
}, {
|
75
|
+
key: "replace",
|
76
|
+
value: function replace(oldCoords, newCoords) {
|
77
|
+
if (!this.isEmpty()) {
|
78
|
+
if (this.cellRange.from.isEqual(oldCoords)) {
|
79
|
+
this.cellRange.from = newCoords;
|
80
|
+
return true;
|
81
|
+
}
|
82
|
+
if (this.cellRange.to.isEqual(oldCoords)) {
|
83
|
+
this.cellRange.to = newCoords;
|
84
|
+
return true;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
return false;
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Clears selection.
|
92
|
+
*
|
93
|
+
* @returns {Selection}
|
94
|
+
*/
|
95
|
+
}, {
|
96
|
+
key: "clear",
|
97
|
+
value: function clear() {
|
98
|
+
this.cellRange = null;
|
99
|
+
return this;
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Returns the top left (or top right in RTL) and bottom right (or bottom left in RTL) selection coordinates.
|
104
|
+
*
|
105
|
+
* @returns {number[]} Returns array of coordinates for example `[1, 1, 5, 5]`.
|
106
|
+
*/
|
107
|
+
}, {
|
108
|
+
key: "getCorners",
|
109
|
+
value: function getCorners() {
|
110
|
+
var topStart = this.cellRange.getOuterTopStartCorner();
|
111
|
+
var bottomEnd = this.cellRange.getOuterBottomEndCorner();
|
112
|
+
return [topStart.row, topStart.col, bottomEnd.row, bottomEnd.col];
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Destroys the instance.
|
117
|
+
*/
|
118
|
+
}, {
|
119
|
+
key: "destroy",
|
120
|
+
value: function destroy() {
|
121
|
+
this.runLocalHooks('destroy');
|
122
|
+
}
|
123
|
+
}]);
|
124
|
+
return Selection;
|
125
|
+
}();
|
126
|
+
mixin(Selection, localHooks);
|
127
|
+
export default Selection;
|
@@ -83,6 +83,15 @@ var calculatedColumns = {
|
|
83
83
|
*/
|
84
84
|
getVisibleColumnsCount: function getVisibleColumnsCount() {
|
85
85
|
return this.dataAccessObject.countColumnsVisible;
|
86
|
+
},
|
87
|
+
/**
|
88
|
+
* Get the number of rendered row headers.
|
89
|
+
*
|
90
|
+
* @returns {number}
|
91
|
+
* @this Table
|
92
|
+
*/
|
93
|
+
getRowHeadersCount: function getRowHeadersCount() {
|
94
|
+
return this.dataAccessObject.rowHeaders.length;
|
86
95
|
}
|
87
96
|
};
|
88
97
|
(0, _object.defineGetter)(calculatedColumns, 'MIXIN_NAME', MIXIN_NAME, {
|
@@ -79,6 +79,15 @@ var calculatedColumns = {
|
|
79
79
|
*/
|
80
80
|
getVisibleColumnsCount: function getVisibleColumnsCount() {
|
81
81
|
return this.dataAccessObject.countColumnsVisible;
|
82
|
+
},
|
83
|
+
/**
|
84
|
+
* Get the number of rendered row headers.
|
85
|
+
*
|
86
|
+
* @returns {number}
|
87
|
+
* @this Table
|
88
|
+
*/
|
89
|
+
getRowHeadersCount: function getRowHeadersCount() {
|
90
|
+
return this.dataAccessObject.rowHeaders.length;
|
82
91
|
}
|
83
92
|
};
|
84
93
|
defineGetter(calculatedColumns, 'MIXIN_NAME', MIXIN_NAME, {
|
@@ -83,6 +83,15 @@ var calculatedRows = {
|
|
83
83
|
*/
|
84
84
|
getVisibleRowsCount: function getVisibleRowsCount() {
|
85
85
|
return this.dataAccessObject.countRowsVisible;
|
86
|
+
},
|
87
|
+
/**
|
88
|
+
* Get the number of rendered column headers.
|
89
|
+
*
|
90
|
+
* @returns {number}
|
91
|
+
* @this Table
|
92
|
+
*/
|
93
|
+
getColumnHeadersCount: function getColumnHeadersCount() {
|
94
|
+
return this.dataAccessObject.columnHeaders.length;
|
86
95
|
}
|
87
96
|
};
|
88
97
|
(0, _object.defineGetter)(calculatedRows, 'MIXIN_NAME', MIXIN_NAME, {
|