handsontable 0.0.0-next-8d0643b-20230809 → 0.0.0-next-be16baf-20230809
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/cell/coords.d.ts +6 -1
- package/3rdparty/walkontable/src/cell/coords.js +50 -11
- package/3rdparty/walkontable/src/cell/coords.mjs +50 -11
- package/3rdparty/walkontable/src/cell/range.d.ts +9 -2
- package/3rdparty/walkontable/src/cell/range.js +38 -7
- package/3rdparty/walkontable/src/cell/range.mjs +38 -7
- package/3rdparty/walkontable/src/core/_base.js +9 -3
- package/3rdparty/walkontable/src/core/_base.mjs +9 -3
- package/3rdparty/walkontable/src/core/clone.js +2 -2
- package/3rdparty/walkontable/src/core/clone.mjs +2 -2
- package/3rdparty/walkontable/src/core/core.js +3 -2
- package/3rdparty/walkontable/src/core/core.mjs +3 -2
- package/3rdparty/walkontable/src/event.js +7 -7
- package/3rdparty/walkontable/src/event.mjs +7 -7
- package/3rdparty/walkontable/src/facade/core.js +2 -2
- package/3rdparty/walkontable/src/facade/core.mjs +2 -2
- package/3rdparty/walkontable/src/index.js +10 -2
- package/3rdparty/walkontable/src/index.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/_base.js +1 -1
- package/3rdparty/walkontable/src/overlay/_base.mjs +1 -1
- package/3rdparty/walkontable/src/overlay/inlineStart.js +2 -6
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +2 -6
- package/3rdparty/walkontable/src/overlay/top.js +2 -6
- package/3rdparty/walkontable/src/overlay/top.mjs +2 -6
- package/3rdparty/walkontable/src/{border.js → selection/border/border.js} +7 -12
- package/3rdparty/walkontable/src/{border.mjs → selection/border/border.mjs} +7 -12
- package/3rdparty/walkontable/src/selection/border/constants.js +16 -0
- package/3rdparty/walkontable/src/selection/border/constants.mjs +12 -0
- package/3rdparty/walkontable/src/selection/constants.js +62 -0
- package/3rdparty/walkontable/src/selection/constants.mjs +51 -0
- package/3rdparty/walkontable/src/selection/index.js +26 -0
- package/3rdparty/walkontable/src/selection/index.mjs +5 -0
- package/3rdparty/walkontable/src/selection/manager.js +259 -0
- package/3rdparty/walkontable/src/selection/manager.mjs +254 -0
- package/3rdparty/walkontable/src/selection/scanner.js +270 -0
- package/3rdparty/walkontable/src/selection/scanner.mjs +267 -0
- package/3rdparty/walkontable/src/selection/selection.js +101 -0
- package/3rdparty/walkontable/src/selection/selection.mjs +96 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +9 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +9 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +9 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +9 -0
- package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +9 -0
- package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +9 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +9 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +9 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +9 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +9 -0
- package/3rdparty/walkontable/src/table.js +6 -78
- package/3rdparty/walkontable/src/table.mjs +7 -79
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/common.d.ts +1 -1
- package/core/focusCatcher/focusDetector.js +58 -0
- package/core/focusCatcher/focusDetector.mjs +54 -0
- package/core/focusCatcher/index.js +142 -0
- package/core/focusCatcher/index.mjs +138 -0
- package/core/index.js +9 -0
- package/core/index.mjs +1 -0
- package/core.d.ts +6 -3
- package/core.js +176 -293
- package/core.mjs +176 -293
- package/dataMap/metaManager/metaSchema.js +41 -0
- package/dataMap/metaManager/metaSchema.mjs +41 -0
- package/dist/handsontable.css +24 -4
- package/dist/handsontable.full.css +24 -4
- package/dist/handsontable.full.js +8682 -5378
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +25 -25
- package/dist/handsontable.js +10989 -7685
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +19 -19
- package/editorManager.js +11 -75
- package/editorManager.mjs +11 -74
- package/editors/baseEditor/baseEditor.d.ts +0 -1
- package/editors/textEditor/textEditor.js +3 -11
- package/editors/textEditor/textEditor.mjs +4 -12
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/helpers/number.d.ts +1 -0
- package/helpers/number.js +18 -0
- package/helpers/number.mjs +17 -0
- package/package.json +1 -1
- package/pluginHooks.d.ts +7 -1
- package/pluginHooks.js +106 -1
- package/pluginHooks.mjs +106 -1
- package/plugins/collapsibleColumns/collapsibleColumns.js +58 -4
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +58 -4
- package/plugins/columnSorting/columnSorting.js +38 -0
- package/plugins/columnSorting/columnSorting.mjs +38 -2
- package/plugins/columnSorting/index.js +3 -1
- package/plugins/columnSorting/index.mjs +1 -1
- package/plugins/comments/commentEditor.js +1 -0
- package/plugins/comments/commentEditor.mjs +1 -0
- package/plugins/comments/comments.js +251 -189
- package/plugins/comments/comments.mjs +250 -190
- package/plugins/comments/contextMenuItem/addEditComment.js +41 -0
- package/plugins/comments/contextMenuItem/addEditComment.mjs +35 -0
- package/plugins/comments/contextMenuItem/readOnlyComment.js +49 -0
- package/plugins/comments/contextMenuItem/readOnlyComment.mjs +43 -0
- package/plugins/comments/contextMenuItem/removeComment.js +38 -0
- package/plugins/comments/contextMenuItem/removeComment.mjs +32 -0
- package/plugins/contextMenu/contextMenu.d.ts +1 -1
- package/plugins/contextMenu/contextMenu.js +72 -30
- package/plugins/contextMenu/contextMenu.mjs +73 -31
- package/plugins/contextMenu/predefinedItems/alignment.js +7 -0
- package/plugins/contextMenu/predefinedItems/alignment.mjs +7 -0
- package/plugins/contextMenu/predefinedItems/clearColumn.js +5 -3
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/columnLeft.js +5 -3
- package/plugins/contextMenu/predefinedItems/columnLeft.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/columnRight.js +5 -3
- package/plugins/contextMenu/predefinedItems/columnRight.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/readOnly.js +7 -0
- package/plugins/contextMenu/predefinedItems/readOnly.mjs +7 -0
- package/plugins/contextMenu/predefinedItems/removeColumn.js +7 -5
- package/plugins/contextMenu/predefinedItems/removeColumn.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/removeRow.js +7 -5
- package/plugins/contextMenu/predefinedItems/removeRow.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/rowAbove.js +5 -3
- package/plugins/contextMenu/predefinedItems/rowAbove.mjs +5 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.js +5 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.mjs +5 -3
- package/plugins/contextMenu/utils.js +28 -16
- package/plugins/contextMenu/utils.mjs +27 -15
- package/plugins/copyPaste/contextMenuItem/copy.js +7 -0
- package/plugins/copyPaste/contextMenuItem/copy.mjs +7 -0
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +9 -1
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +9 -1
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +9 -1
- package/plugins/copyPaste/contextMenuItem/cut.js +7 -0
- package/plugins/copyPaste/contextMenuItem/cut.mjs +7 -0
- package/plugins/copyPaste/copyPaste.js +14 -10
- package/plugins/copyPaste/copyPaste.mjs +14 -10
- package/plugins/customBorders/customBorders.js +23 -20
- package/plugins/customBorders/customBorders.mjs +24 -21
- package/plugins/dropdownMenu/dropdownMenu.d.ts +1 -1
- package/plugins/dropdownMenu/dropdownMenu.js +89 -32
- package/plugins/dropdownMenu/dropdownMenu.mjs +89 -32
- package/plugins/filters/filters.js +31 -14
- package/plugins/filters/filters.mjs +30 -13
- package/plugins/mergeCells/mergeCells.js +5 -17
- package/plugins/mergeCells/mergeCells.mjs +5 -17
- package/plugins/multiColumnSorting/multiColumnSorting.js +37 -2
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +37 -2
- package/plugins/nestedHeaders/nestedHeaders.js +121 -8
- package/plugins/nestedHeaders/nestedHeaders.mjs +121 -8
- package/plugins/nestedHeaders/stateManager/index.js +37 -0
- package/plugins/nestedHeaders/stateManager/index.mjs +37 -0
- package/plugins/nestedRows/nestedRows.js +41 -0
- package/plugins/nestedRows/nestedRows.mjs +41 -0
- package/renderers/checkboxRenderer/checkboxRenderer.js +2 -2
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +1 -1
- package/selection/highlight/highlight.js +256 -71
- package/selection/highlight/highlight.mjs +250 -71
- package/selection/highlight/types/activeHeader.js +10 -8
- package/selection/highlight/types/activeHeader.mjs +10 -8
- package/selection/highlight/types/area.js +6 -18
- package/selection/highlight/types/area.mjs +6 -18
- package/selection/highlight/types/areaLayered.js +31 -0
- package/selection/highlight/types/areaLayered.mjs +26 -0
- package/selection/highlight/types/column.js +27 -0
- package/selection/highlight/types/column.mjs +22 -0
- package/selection/highlight/types/customSelection.js +7 -9
- package/selection/highlight/types/customSelection.mjs +7 -9
- package/selection/highlight/types/fill.js +5 -7
- package/selection/highlight/types/fill.mjs +5 -7
- package/selection/highlight/types/{cell.js → focus.js} +5 -7
- package/selection/highlight/types/{cell.mjs → focus.mjs} +5 -7
- package/selection/highlight/types/header.js +9 -18
- package/selection/highlight/types/header.mjs +9 -18
- package/selection/highlight/types/row.js +27 -0
- package/selection/highlight/types/row.mjs +22 -0
- package/selection/highlight/visualSelection.js +31 -27
- package/selection/highlight/visualSelection.mjs +31 -27
- package/selection/index.js +4 -7
- package/selection/index.mjs +2 -3
- package/selection/mouseEventHandler.js +1 -1
- package/selection/mouseEventHandler.mjs +1 -1
- package/selection/range.js +8 -8
- package/selection/range.mjs +8 -8
- package/selection/selection.js +293 -154
- package/selection/selection.mjs +290 -153
- package/selection/transformation.js +232 -90
- package/selection/transformation.mjs +232 -90
- package/selection/utils.js +15 -21
- package/selection/utils.mjs +16 -21
- package/settings.d.ts +2 -0
- package/shortcutContexts/commands/editor/closeAndSave.js +12 -0
- package/shortcutContexts/commands/editor/closeAndSave.mjs +8 -0
- package/shortcutContexts/commands/editor/closeWithoutSaving.js +12 -0
- package/shortcutContexts/commands/editor/closeWithoutSaving.mjs +8 -0
- package/shortcutContexts/commands/editor/fastOpen.js +16 -0
- package/shortcutContexts/commands/editor/fastOpen.mjs +12 -0
- package/shortcutContexts/commands/editor/index.js +16 -0
- package/shortcutContexts/commands/editor/index.mjs +12 -0
- package/shortcutContexts/commands/editor/open.js +27 -0
- package/shortcutContexts/commands/editor/open.mjs +23 -0
- package/shortcutContexts/commands/emptySelectedCells.js +11 -0
- package/shortcutContexts/commands/emptySelectedCells.mjs +7 -0
- package/shortcutContexts/commands/extendCellsSelection/down.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +11 -0
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +21 -0
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +17 -0
- package/shortcutContexts/commands/extendCellsSelection/index.js +26 -0
- package/shortcutContexts/commands/extendCellsSelection/index.mjs +22 -0
- package/shortcutContexts/commands/extendCellsSelection/left.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +11 -0
- package/shortcutContexts/commands/extendCellsSelection/right.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +11 -0
- package/shortcutContexts/commands/extendCellsSelection/toColumns.js +19 -0
- package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +15 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +29 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +25 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +19 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +15 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +19 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +15 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +29 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +25 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +29 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +25 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +29 -0
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +25 -0
- package/shortcutContexts/commands/extendCellsSelection/toRows.js +19 -0
- package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +15 -0
- package/shortcutContexts/commands/extendCellsSelection/up.js +15 -0
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +11 -0
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +21 -0
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +17 -0
- package/shortcutContexts/commands/index.js +35 -0
- package/shortcutContexts/commands/index.mjs +31 -0
- package/shortcutContexts/commands/moveCellSelection/down.js +13 -0
- package/shortcutContexts/commands/moveCellSelection/down.mjs +9 -0
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +31 -0
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +27 -0
- package/shortcutContexts/commands/moveCellSelection/index.js +28 -0
- package/shortcutContexts/commands/moveCellSelection/index.mjs +24 -0
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +12 -0
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +8 -0
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +12 -0
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +8 -0
- package/shortcutContexts/commands/moveCellSelection/left.js +10 -0
- package/shortcutContexts/commands/moveCellSelection/left.mjs +6 -0
- package/shortcutContexts/commands/moveCellSelection/right.js +10 -0
- package/shortcutContexts/commands/moveCellSelection/right.mjs +6 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +17 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +13 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.js +18 -0
- package/shortcutContexts/commands/moveCellSelection/toMostBottomInlineEnd.mjs +14 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +14 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +10 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +17 -0
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +13 -0
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +19 -0
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +15 -0
- package/shortcutContexts/commands/moveCellSelection/toMostRight.js +21 -0
- package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +17 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTop.js +17 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +13 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.js +19 -0
- package/shortcutContexts/commands/moveCellSelection/toMostTopInlineStart.mjs +15 -0
- package/shortcutContexts/commands/moveCellSelection/up.js +13 -0
- package/shortcutContexts/commands/moveCellSelection/up.mjs +9 -0
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +31 -0
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +27 -0
- package/shortcutContexts/commands/populateSelectedCellsData.js +29 -0
- package/shortcutContexts/commands/populateSelectedCellsData.mjs +25 -0
- package/shortcutContexts/commands/scrollToFocusedCell.js +36 -0
- package/shortcutContexts/commands/scrollToFocusedCell.mjs +32 -0
- package/shortcutContexts/commands/selectAll.js +10 -0
- package/shortcutContexts/commands/selectAll.mjs +6 -0
- package/shortcutContexts/constants.js +13 -0
- package/shortcutContexts/constants.mjs +8 -0
- package/shortcutContexts/editor.js +25 -0
- package/shortcutContexts/editor.mjs +21 -0
- package/shortcutContexts/grid.js +163 -0
- package/shortcutContexts/grid.mjs +159 -0
- package/shortcutContexts/index.js +24 -0
- package/shortcutContexts/index.mjs +11 -0
- package/shortcuts/manager.js +2 -0
- package/shortcuts/manager.mjs +2 -0
- package/shortcuts/recorder.js +2 -2
- package/shortcuts/recorder.mjs +2 -2
- package/shortcuts/utils.js +19 -5
- package/shortcuts/utils.mjs +18 -4
- package/tableView.js +67 -13
- package/tableView.mjs +67 -13
- package/3rdparty/walkontable/src/selection.js +0 -295
- package/3rdparty/walkontable/src/selection.mjs +0 -290
- package/selection/highlight/constants.js +0 -15
- package/selection/highlight/constants.mjs +0 -6
- package/selection/highlight/types/index.js +0 -35
- package/selection/highlight/types/index.mjs +0 -31
package/shortcuts/recorder.js
CHANGED
@@ -86,7 +86,7 @@ function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDown, call
|
|
86
86
|
if (event.keyCode === 229 || result === false || (0, _event.isImmediatePropagationStopped)(event)) {
|
87
87
|
return;
|
88
88
|
}
|
89
|
-
const pressedKey = (0, _utils.normalizeEventKey)(event
|
89
|
+
const pressedKey = (0, _utils.normalizeEventKey)(event);
|
90
90
|
let extraModifierKeys = [];
|
91
91
|
if (isModifierKey(pressedKey)) {
|
92
92
|
modifierKeysObserver.press(pressedKey);
|
@@ -112,7 +112,7 @@ function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDown, call
|
|
112
112
|
if (handleEvent(event) === false) {
|
113
113
|
return;
|
114
114
|
}
|
115
|
-
const pressedKey = (0, _utils.normalizeEventKey)(event
|
115
|
+
const pressedKey = (0, _utils.normalizeEventKey)(event);
|
116
116
|
if (isModifierKey(pressedKey) === false) {
|
117
117
|
return;
|
118
118
|
}
|
package/shortcuts/recorder.mjs
CHANGED
@@ -82,7 +82,7 @@ export function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDow
|
|
82
82
|
if (event.keyCode === 229 || result === false || isImmediatePropagationStopped(event)) {
|
83
83
|
return;
|
84
84
|
}
|
85
|
-
const pressedKey = normalizeEventKey(event
|
85
|
+
const pressedKey = normalizeEventKey(event);
|
86
86
|
let extraModifierKeys = [];
|
87
87
|
if (isModifierKey(pressedKey)) {
|
88
88
|
modifierKeysObserver.press(pressedKey);
|
@@ -108,7 +108,7 @@ export function useRecorder(ownerWindow, handleEvent, beforeKeyDown, afterKeyDow
|
|
108
108
|
if (handleEvent(event) === false) {
|
109
109
|
return;
|
110
110
|
}
|
111
|
-
const pressedKey = normalizeEventKey(event
|
111
|
+
const pressedKey = normalizeEventKey(event);
|
112
112
|
if (isModifierKey(pressedKey) === false) {
|
113
113
|
return;
|
114
114
|
}
|
package/shortcuts/utils.js
CHANGED
@@ -37,13 +37,27 @@ const getKeysList = normalizedKeys => {
|
|
37
37
|
};
|
38
38
|
|
39
39
|
/**
|
40
|
-
*
|
40
|
+
* The regex tests if the event.code matches to the pattern and it's used to extract letters and digits from
|
41
|
+
* the string.
|
42
|
+
*/
|
43
|
+
exports.getKeysList = getKeysList;
|
44
|
+
const codeToKeyRegExp = new RegExp('^(?:Key|Digit)([A-Z0-9])$');
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Normalizes a keyboard event key value to a key before its modification. When the keyboard event
|
48
|
+
* is triggered with Alt, Control or Shift keys the `key` property contains modified key e.g. for Alt+L
|
49
|
+
* it will be `ł`. But that value is only valid for polish keyboard layout. To fix that limitations, for
|
50
|
+
* letters and digits the value is taken from the `code` property which holds original value before
|
51
|
+
* transformation.
|
41
52
|
*
|
42
|
-
* @param {
|
53
|
+
* @param {Event} event The KeyboardEvent object.
|
43
54
|
* @returns {string}
|
44
55
|
*/
|
45
|
-
|
46
|
-
|
47
|
-
|
56
|
+
const normalizeEventKey = _ref => {
|
57
|
+
let {
|
58
|
+
key,
|
59
|
+
code
|
60
|
+
} = _ref;
|
61
|
+
return (codeToKeyRegExp.test(code) ? code.replace(codeToKeyRegExp, '$1') : key).toLowerCase();
|
48
62
|
};
|
49
63
|
exports.normalizeEventKey = normalizeEventKey;
|
package/shortcuts/utils.mjs
CHANGED
@@ -33,11 +33,25 @@ export const getKeysList = normalizedKeys => {
|
|
33
33
|
};
|
34
34
|
|
35
35
|
/**
|
36
|
-
*
|
36
|
+
* The regex tests if the event.code matches to the pattern and it's used to extract letters and digits from
|
37
|
+
* the string.
|
38
|
+
*/
|
39
|
+
const codeToKeyRegExp = new RegExp('^(?:Key|Digit)([A-Z0-9])$');
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Normalizes a keyboard event key value to a key before its modification. When the keyboard event
|
43
|
+
* is triggered with Alt, Control or Shift keys the `key` property contains modified key e.g. for Alt+L
|
44
|
+
* it will be `ł`. But that value is only valid for polish keyboard layout. To fix that limitations, for
|
45
|
+
* letters and digits the value is taken from the `code` property which holds original value before
|
46
|
+
* transformation.
|
37
47
|
*
|
38
|
-
* @param {
|
48
|
+
* @param {Event} event The KeyboardEvent object.
|
39
49
|
* @returns {string}
|
40
50
|
*/
|
41
|
-
export const normalizeEventKey =
|
42
|
-
|
51
|
+
export const normalizeEventKey = _ref => {
|
52
|
+
let {
|
53
|
+
key,
|
54
|
+
code
|
55
|
+
} = _ref;
|
56
|
+
return (codeToKeyRegExp.test(code) ? code.replace(codeToKeyRegExp, '$1') : key).toLowerCase();
|
43
57
|
};
|
package/tableView.js
CHANGED
@@ -312,11 +312,14 @@ class TableView {
|
|
312
312
|
});
|
313
313
|
this.eventManager.addEventListener(documentElement, 'mouseup', event => {
|
314
314
|
if (selection.isInProgress() && (0, _event.isLeftClick)(event)) {
|
315
|
-
// is left mouse button
|
316
315
|
selection.finish();
|
317
316
|
}
|
318
317
|
priv.mouseDown = false;
|
319
|
-
|
318
|
+
const isOutsideInputElement = (0, _element.isOutsideInput)(rootDocument.activeElement);
|
319
|
+
if (!isOutsideInputElement) {
|
320
|
+
return;
|
321
|
+
}
|
322
|
+
if (isOutsideInputElement || !selection.isSelected() && !selection.isSelectedByAnyHeader() && !rootElement.contains(event.target) && !(0, _event.isRightClick)(event)) {
|
320
323
|
this.instance.unlisten();
|
321
324
|
}
|
322
325
|
});
|
@@ -550,6 +553,40 @@ class TableView {
|
|
550
553
|
return this.countNotHiddenRowIndexes(visualFixedRowsBottom, 1);
|
551
554
|
}
|
552
555
|
|
556
|
+
/**
|
557
|
+
* The function returns the number of renderable column indexes within the passed range of the visual indexes.
|
558
|
+
*
|
559
|
+
* @param {number} columnStart The column visual start index.
|
560
|
+
* @param {number} columnEnd The column visual end index.
|
561
|
+
* @returns {number}
|
562
|
+
*/
|
563
|
+
countRenderableColumnsInRange(columnStart, columnEnd) {
|
564
|
+
let count = 0;
|
565
|
+
for (let column = columnStart; column <= columnEnd; column++) {
|
566
|
+
if (this.instance.columnIndexMapper.getRenderableFromVisualIndex(column) !== null) {
|
567
|
+
count += 1;
|
568
|
+
}
|
569
|
+
}
|
570
|
+
return count;
|
571
|
+
}
|
572
|
+
|
573
|
+
/**
|
574
|
+
* The function returns the number of renderable row indexes within the passed range of the visual indexes.
|
575
|
+
*
|
576
|
+
* @param {number} rowStart The row visual start index.
|
577
|
+
* @param {number} rowEnd The row visual end index.
|
578
|
+
* @returns {number}
|
579
|
+
*/
|
580
|
+
countRenderableRowsInRange(rowStart, rowEnd) {
|
581
|
+
let count = 0;
|
582
|
+
for (let row = rowStart; row <= rowEnd; row++) {
|
583
|
+
if (this.instance.rowIndexMapper.getRenderableFromVisualIndex(row) !== null) {
|
584
|
+
count += 1;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
return count;
|
588
|
+
}
|
589
|
+
|
553
590
|
/**
|
554
591
|
* Checks if at least one cell than belongs to the main table is not covered by the top, left or
|
555
592
|
* bottom overlay.
|
@@ -769,20 +806,40 @@ class TableView {
|
|
769
806
|
},
|
770
807
|
beforeDraw: (force, skipRender) => this.beforeRender(force, skipRender),
|
771
808
|
onDraw: force => this.afterRender(force),
|
772
|
-
onScrollVertically: () =>
|
773
|
-
|
809
|
+
onScrollVertically: () => {
|
810
|
+
this.instance.runHooks('afterScrollVertically');
|
811
|
+
this.instance.runHooks('afterScroll');
|
812
|
+
},
|
813
|
+
onScrollHorizontally: () => {
|
814
|
+
this.instance.runHooks('afterScrollHorizontally');
|
815
|
+
this.instance.runHooks('afterScroll');
|
816
|
+
},
|
774
817
|
onBeforeRemoveCellClassNames: () => this.instance.runHooks('beforeRemoveCellClassNames'),
|
775
818
|
onBeforeHighlightingRowHeader: (renderableRow, headerLevel, highlightMeta) => {
|
776
819
|
const rowMapper = this.instance.rowIndexMapper;
|
777
|
-
const
|
820
|
+
const areColumnHeadersSelected = renderableRow < 0;
|
821
|
+
let visualRow = renderableRow;
|
822
|
+
if (!areColumnHeadersSelected) {
|
823
|
+
visualRow = rowMapper.getVisualFromRenderableIndex(renderableRow);
|
824
|
+
}
|
778
825
|
const newVisualRow = this.instance.runHooks('beforeHighlightingRowHeader', visualRow, headerLevel, highlightMeta);
|
779
|
-
|
826
|
+
if (!areColumnHeadersSelected) {
|
827
|
+
return rowMapper.getRenderableFromVisualIndex(rowMapper.getNearestNotHiddenIndex(newVisualRow, 1));
|
828
|
+
}
|
829
|
+
return newVisualRow;
|
780
830
|
},
|
781
831
|
onBeforeHighlightingColumnHeader: (renderableColumn, headerLevel, highlightMeta) => {
|
782
832
|
const columnMapper = this.instance.columnIndexMapper;
|
783
|
-
const
|
833
|
+
const areRowHeadersSelected = renderableColumn < 0;
|
834
|
+
let visualColumn = renderableColumn;
|
835
|
+
if (!areRowHeadersSelected) {
|
836
|
+
visualColumn = columnMapper.getVisualFromRenderableIndex(renderableColumn);
|
837
|
+
}
|
784
838
|
const newVisualColumn = this.instance.runHooks('beforeHighlightingColumnHeader', visualColumn, headerLevel, highlightMeta);
|
785
|
-
|
839
|
+
if (!areRowHeadersSelected) {
|
840
|
+
return columnMapper.getRenderableFromVisualIndex(columnMapper.getNearestNotHiddenIndex(newVisualColumn, 1));
|
841
|
+
}
|
842
|
+
return newVisualColumn;
|
786
843
|
},
|
787
844
|
onAfterDrawSelection: (currentRow, currentColumn, layerLevel) => {
|
788
845
|
let cornersOfSelection;
|
@@ -790,10 +847,7 @@ class TableView {
|
|
790
847
|
const selectedRange = this.instance.selection.getSelectedRange();
|
791
848
|
const selectionRangeSize = selectedRange.size();
|
792
849
|
if (selectionRangeSize > 0) {
|
793
|
-
|
794
|
-
// Please look at the `SelectedRange` class and it's method for getting selection's layer for more information.
|
795
|
-
const selectionOffset = (layerLevel !== null && layerLevel !== void 0 ? layerLevel : 0) + 1 - selectionRangeSize;
|
796
|
-
const selectionForLayer = selectedRange.peekByIndex(selectionOffset);
|
850
|
+
const selectionForLayer = selectedRange.peekByIndex(layerLevel !== null && layerLevel !== void 0 ? layerLevel : 0);
|
797
851
|
cornersOfSelection = [selectionForLayer.from.row, selectionForLayer.from.col, selectionForLayer.to.row, selectionForLayer.to.col];
|
798
852
|
}
|
799
853
|
return this.instance.runHooks('afterDrawSelection', visualRowIndex, visualColumnIndex, cornersOfSelection, layerLevel);
|
@@ -946,7 +1000,7 @@ class TableView {
|
|
946
1000
|
*/
|
947
1001
|
isSelectedOnlyCell() {
|
948
1002
|
var _this$instance$getSel, _this$instance$getSel2;
|
949
|
-
return (_this$instance$getSel = (_this$instance$getSel2 = this.instance.getSelectedRangeLast()) === null || _this$instance$getSel2 === void 0 ? void 0 : _this$instance$getSel2.
|
1003
|
+
return (_this$instance$getSel = (_this$instance$getSel2 = this.instance.getSelectedRangeLast()) === null || _this$instance$getSel2 === void 0 ? void 0 : _this$instance$getSel2.isSingleCell()) !== null && _this$instance$getSel !== void 0 ? _this$instance$getSel : false;
|
950
1004
|
}
|
951
1005
|
|
952
1006
|
/**
|
package/tableView.mjs
CHANGED
@@ -308,11 +308,14 @@ class TableView {
|
|
308
308
|
});
|
309
309
|
this.eventManager.addEventListener(documentElement, 'mouseup', event => {
|
310
310
|
if (selection.isInProgress() && isLeftClick(event)) {
|
311
|
-
// is left mouse button
|
312
311
|
selection.finish();
|
313
312
|
}
|
314
313
|
priv.mouseDown = false;
|
315
|
-
|
314
|
+
const isOutsideInputElement = isOutsideInput(rootDocument.activeElement);
|
315
|
+
if (!isOutsideInputElement) {
|
316
|
+
return;
|
317
|
+
}
|
318
|
+
if (isOutsideInputElement || !selection.isSelected() && !selection.isSelectedByAnyHeader() && !rootElement.contains(event.target) && !isRightClick(event)) {
|
316
319
|
this.instance.unlisten();
|
317
320
|
}
|
318
321
|
});
|
@@ -546,6 +549,40 @@ class TableView {
|
|
546
549
|
return this.countNotHiddenRowIndexes(visualFixedRowsBottom, 1);
|
547
550
|
}
|
548
551
|
|
552
|
+
/**
|
553
|
+
* The function returns the number of renderable column indexes within the passed range of the visual indexes.
|
554
|
+
*
|
555
|
+
* @param {number} columnStart The column visual start index.
|
556
|
+
* @param {number} columnEnd The column visual end index.
|
557
|
+
* @returns {number}
|
558
|
+
*/
|
559
|
+
countRenderableColumnsInRange(columnStart, columnEnd) {
|
560
|
+
let count = 0;
|
561
|
+
for (let column = columnStart; column <= columnEnd; column++) {
|
562
|
+
if (this.instance.columnIndexMapper.getRenderableFromVisualIndex(column) !== null) {
|
563
|
+
count += 1;
|
564
|
+
}
|
565
|
+
}
|
566
|
+
return count;
|
567
|
+
}
|
568
|
+
|
569
|
+
/**
|
570
|
+
* The function returns the number of renderable row indexes within the passed range of the visual indexes.
|
571
|
+
*
|
572
|
+
* @param {number} rowStart The row visual start index.
|
573
|
+
* @param {number} rowEnd The row visual end index.
|
574
|
+
* @returns {number}
|
575
|
+
*/
|
576
|
+
countRenderableRowsInRange(rowStart, rowEnd) {
|
577
|
+
let count = 0;
|
578
|
+
for (let row = rowStart; row <= rowEnd; row++) {
|
579
|
+
if (this.instance.rowIndexMapper.getRenderableFromVisualIndex(row) !== null) {
|
580
|
+
count += 1;
|
581
|
+
}
|
582
|
+
}
|
583
|
+
return count;
|
584
|
+
}
|
585
|
+
|
549
586
|
/**
|
550
587
|
* Checks if at least one cell than belongs to the main table is not covered by the top, left or
|
551
588
|
* bottom overlay.
|
@@ -765,20 +802,40 @@ class TableView {
|
|
765
802
|
},
|
766
803
|
beforeDraw: (force, skipRender) => this.beforeRender(force, skipRender),
|
767
804
|
onDraw: force => this.afterRender(force),
|
768
|
-
onScrollVertically: () =>
|
769
|
-
|
805
|
+
onScrollVertically: () => {
|
806
|
+
this.instance.runHooks('afterScrollVertically');
|
807
|
+
this.instance.runHooks('afterScroll');
|
808
|
+
},
|
809
|
+
onScrollHorizontally: () => {
|
810
|
+
this.instance.runHooks('afterScrollHorizontally');
|
811
|
+
this.instance.runHooks('afterScroll');
|
812
|
+
},
|
770
813
|
onBeforeRemoveCellClassNames: () => this.instance.runHooks('beforeRemoveCellClassNames'),
|
771
814
|
onBeforeHighlightingRowHeader: (renderableRow, headerLevel, highlightMeta) => {
|
772
815
|
const rowMapper = this.instance.rowIndexMapper;
|
773
|
-
const
|
816
|
+
const areColumnHeadersSelected = renderableRow < 0;
|
817
|
+
let visualRow = renderableRow;
|
818
|
+
if (!areColumnHeadersSelected) {
|
819
|
+
visualRow = rowMapper.getVisualFromRenderableIndex(renderableRow);
|
820
|
+
}
|
774
821
|
const newVisualRow = this.instance.runHooks('beforeHighlightingRowHeader', visualRow, headerLevel, highlightMeta);
|
775
|
-
|
822
|
+
if (!areColumnHeadersSelected) {
|
823
|
+
return rowMapper.getRenderableFromVisualIndex(rowMapper.getNearestNotHiddenIndex(newVisualRow, 1));
|
824
|
+
}
|
825
|
+
return newVisualRow;
|
776
826
|
},
|
777
827
|
onBeforeHighlightingColumnHeader: (renderableColumn, headerLevel, highlightMeta) => {
|
778
828
|
const columnMapper = this.instance.columnIndexMapper;
|
779
|
-
const
|
829
|
+
const areRowHeadersSelected = renderableColumn < 0;
|
830
|
+
let visualColumn = renderableColumn;
|
831
|
+
if (!areRowHeadersSelected) {
|
832
|
+
visualColumn = columnMapper.getVisualFromRenderableIndex(renderableColumn);
|
833
|
+
}
|
780
834
|
const newVisualColumn = this.instance.runHooks('beforeHighlightingColumnHeader', visualColumn, headerLevel, highlightMeta);
|
781
|
-
|
835
|
+
if (!areRowHeadersSelected) {
|
836
|
+
return columnMapper.getRenderableFromVisualIndex(columnMapper.getNearestNotHiddenIndex(newVisualColumn, 1));
|
837
|
+
}
|
838
|
+
return newVisualColumn;
|
782
839
|
},
|
783
840
|
onAfterDrawSelection: (currentRow, currentColumn, layerLevel) => {
|
784
841
|
let cornersOfSelection;
|
@@ -786,10 +843,7 @@ class TableView {
|
|
786
843
|
const selectedRange = this.instance.selection.getSelectedRange();
|
787
844
|
const selectionRangeSize = selectedRange.size();
|
788
845
|
if (selectionRangeSize > 0) {
|
789
|
-
|
790
|
-
// Please look at the `SelectedRange` class and it's method for getting selection's layer for more information.
|
791
|
-
const selectionOffset = (layerLevel !== null && layerLevel !== void 0 ? layerLevel : 0) + 1 - selectionRangeSize;
|
792
|
-
const selectionForLayer = selectedRange.peekByIndex(selectionOffset);
|
846
|
+
const selectionForLayer = selectedRange.peekByIndex(layerLevel !== null && layerLevel !== void 0 ? layerLevel : 0);
|
793
847
|
cornersOfSelection = [selectionForLayer.from.row, selectionForLayer.from.col, selectionForLayer.to.row, selectionForLayer.to.col];
|
794
848
|
}
|
795
849
|
return this.instance.runHooks('afterDrawSelection', visualRowIndex, visualColumnIndex, cornersOfSelection, layerLevel);
|
@@ -942,7 +996,7 @@ class TableView {
|
|
942
996
|
*/
|
943
997
|
isSelectedOnlyCell() {
|
944
998
|
var _this$instance$getSel, _this$instance$getSel2;
|
945
|
-
return (_this$instance$getSel = (_this$instance$getSel2 = this.instance.getSelectedRangeLast()) === null || _this$instance$getSel2 === void 0 ? void 0 : _this$instance$getSel2.
|
999
|
+
return (_this$instance$getSel = (_this$instance$getSel2 = this.instance.getSelectedRangeLast()) === null || _this$instance$getSel2 === void 0 ? void 0 : _this$instance$getSel2.isSingleCell()) !== null && _this$instance$getSel !== void 0 ? _this$instance$getSel : false;
|
946
1000
|
}
|
947
1001
|
|
948
1002
|
/**
|
@@ -1,295 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
require("core-js/modules/es.array.push.js");
|
5
|
-
var _element = require("./../../../helpers/dom/element");
|
6
|
-
var _border = _interopRequireDefault(require("./border"));
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8
|
-
/**
|
9
|
-
* @class Selection
|
10
|
-
*/
|
11
|
-
class Selection {
|
12
|
-
/**
|
13
|
-
* @param {object} settings The selection settings object. @todo type.
|
14
|
-
* @param {CellRange} cellRange The cell range instance.
|
15
|
-
*/
|
16
|
-
constructor(settings, cellRange) {
|
17
|
-
this.settings = settings;
|
18
|
-
this.cellRange = cellRange || null;
|
19
|
-
this.instanceBorders = {};
|
20
|
-
this.classNames = [this.settings.className];
|
21
|
-
this.classNameGenerator = this.linearClassNameGenerator(this.settings.className, this.settings.layerLevel);
|
22
|
-
}
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
|
26
|
-
* borders per instance.
|
27
|
-
*
|
28
|
-
* @param {WalkontableFacade} wotInstance The Walkontable instance.
|
29
|
-
* @returns {Border}
|
30
|
-
*/
|
31
|
-
getBorder(wotInstance) {
|
32
|
-
if (!this.instanceBorders[wotInstance.guid]) {
|
33
|
-
this.instanceBorders[wotInstance.guid] = new _border.default(wotInstance, this.settings);
|
34
|
-
}
|
35
|
-
return this.instanceBorders[wotInstance.guid];
|
36
|
-
}
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Checks if selection is empty.
|
40
|
-
*
|
41
|
-
* @returns {boolean}
|
42
|
-
*/
|
43
|
-
isEmpty() {
|
44
|
-
return this.cellRange === null;
|
45
|
-
}
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Adds a cell coords to the selection.
|
49
|
-
*
|
50
|
-
* @param {CellCoords} coords The cell coordinates to add.
|
51
|
-
* @returns {Selection}
|
52
|
-
*/
|
53
|
-
add(coords) {
|
54
|
-
if (this.isEmpty()) {
|
55
|
-
this.cellRange = this.settings.createCellRange(coords);
|
56
|
-
} else {
|
57
|
-
this.cellRange.expand(coords);
|
58
|
-
}
|
59
|
-
return this;
|
60
|
-
}
|
61
|
-
|
62
|
-
/**
|
63
|
-
* If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
|
64
|
-
* information about success.
|
65
|
-
*
|
66
|
-
* @param {CellCoords} oldCoords An old cell coordinates to replace.
|
67
|
-
* @param {CellCoords} newCoords The new cell coordinates.
|
68
|
-
* @returns {boolean}
|
69
|
-
*/
|
70
|
-
replace(oldCoords, newCoords) {
|
71
|
-
if (!this.isEmpty()) {
|
72
|
-
if (this.cellRange.from.isEqual(oldCoords)) {
|
73
|
-
this.cellRange.from = newCoords;
|
74
|
-
return true;
|
75
|
-
}
|
76
|
-
if (this.cellRange.to.isEqual(oldCoords)) {
|
77
|
-
this.cellRange.to = newCoords;
|
78
|
-
return true;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
return false;
|
82
|
-
}
|
83
|
-
|
84
|
-
/**
|
85
|
-
* Clears selection.
|
86
|
-
*
|
87
|
-
* @returns {Selection}
|
88
|
-
*/
|
89
|
-
clear() {
|
90
|
-
this.cellRange = null;
|
91
|
-
return this;
|
92
|
-
}
|
93
|
-
|
94
|
-
/**
|
95
|
-
* Returns the top left (or top right in RTL) and bottom right (or bottom left in RTL) selection coordinates.
|
96
|
-
*
|
97
|
-
* @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`.
|
98
|
-
*/
|
99
|
-
getCorners() {
|
100
|
-
const topStart = this.cellRange.getOuterTopStartCorner();
|
101
|
-
const bottomEnd = this.cellRange.getOuterBottomEndCorner();
|
102
|
-
return [topStart.row, topStart.col, bottomEnd.row, bottomEnd.col];
|
103
|
-
}
|
104
|
-
|
105
|
-
/**
|
106
|
-
* Adds class name to cell element at given coords.
|
107
|
-
*
|
108
|
-
* @param {WalkontableFacade} wotInstance Walkontable instance.
|
109
|
-
* @param {number} sourceRow Cell row coord.
|
110
|
-
* @param {number} sourceColumn Cell column coord.
|
111
|
-
* @param {string} className Class name.
|
112
|
-
* @param {boolean} [markIntersections=false] If `true`, linear className generator will be used to add CSS classes
|
113
|
-
* in a continuous way.
|
114
|
-
* @returns {Selection}
|
115
|
-
*/
|
116
|
-
addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
|
117
|
-
let markIntersections = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
118
|
-
const TD = wotInstance.wtTable.getCell(this.settings.createCellCoords(sourceRow, sourceColumn));
|
119
|
-
if (typeof TD === 'object') {
|
120
|
-
let cellClassName = className;
|
121
|
-
if (markIntersections) {
|
122
|
-
cellClassName = this.classNameGenerator(TD);
|
123
|
-
if (!this.classNames.includes(cellClassName)) {
|
124
|
-
this.classNames.push(cellClassName);
|
125
|
-
}
|
126
|
-
}
|
127
|
-
(0, _element.addClass)(TD, cellClassName);
|
128
|
-
}
|
129
|
-
return this;
|
130
|
-
}
|
131
|
-
|
132
|
-
/**
|
133
|
-
* Generate helper for calculating classNames based on previously added base className.
|
134
|
-
* The generated className is always generated as a continuation of the previous className. For example, when
|
135
|
-
* the currently checked element has 'area-2' className the generated new className will be 'area-3'. When
|
136
|
-
* the element doesn't have any classNames than the base className will be returned ('area');.
|
137
|
-
*
|
138
|
-
* @param {string} baseClassName Base className to be used.
|
139
|
-
* @param {number} layerLevelOwner Layer level which the instance of the Selection belongs to.
|
140
|
-
* @returns {Function}
|
141
|
-
*/
|
142
|
-
linearClassNameGenerator(baseClassName, layerLevelOwner) {
|
143
|
-
// TODO: Make this recursive function Proper Tail Calls (TCO/PTC) friendly.
|
144
|
-
return function calcClassName(element) {
|
145
|
-
let previousIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
|
146
|
-
if (layerLevelOwner === 0 || previousIndex === 0) {
|
147
|
-
return baseClassName;
|
148
|
-
}
|
149
|
-
let index = previousIndex >= 0 ? previousIndex : layerLevelOwner;
|
150
|
-
let className = baseClassName;
|
151
|
-
index -= 1;
|
152
|
-
const previousClassName = index === 0 ? baseClassName : `${baseClassName}-${index}`;
|
153
|
-
if ((0, _element.hasClass)(element, previousClassName)) {
|
154
|
-
const currentLayer = index + 1;
|
155
|
-
className = `${baseClassName}-${currentLayer}`;
|
156
|
-
} else {
|
157
|
-
className = calcClassName(element, index);
|
158
|
-
}
|
159
|
-
return className;
|
160
|
-
};
|
161
|
-
}
|
162
|
-
|
163
|
-
/**
|
164
|
-
* @param {WalkontableFacade} wotInstance The Walkontable instance.
|
165
|
-
*/
|
166
|
-
draw(wotInstance) {
|
167
|
-
if (this.isEmpty()) {
|
168
|
-
if (this.settings.border) {
|
169
|
-
this.getBorder(wotInstance).disappear();
|
170
|
-
}
|
171
|
-
return;
|
172
|
-
}
|
173
|
-
const renderedRows = wotInstance.wtTable.getRenderedRowsCount();
|
174
|
-
const renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
|
175
|
-
const corners = this.getCorners();
|
176
|
-
const [topRow, topColumn, bottomRow, bottomColumn] = corners;
|
177
|
-
const {
|
178
|
-
highlightHeaderClassName,
|
179
|
-
highlightColumnClassName,
|
180
|
-
highlightRowClassName,
|
181
|
-
highlightOnlyClosestHeader,
|
182
|
-
selectionType
|
183
|
-
} = this.settings;
|
184
|
-
const isHeaderSelectionType = selectionType === void 0 || ['active-header', 'header'].includes(selectionType);
|
185
|
-
if (isHeaderSelectionType && topColumn !== null && bottomColumn !== null) {
|
186
|
-
let selectionColumnCursor = 0;
|
187
|
-
for (let column = 0; column < renderedColumns; column += 1) {
|
188
|
-
const sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
|
189
|
-
if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
|
190
|
-
let THs = wotInstance.wtTable.getColumnHeaders(sourceCol);
|
191
|
-
const closestHeaderLevel = THs.length - 1;
|
192
|
-
if (highlightOnlyClosestHeader && THs.length > 1) {
|
193
|
-
THs = [THs[closestHeaderLevel]];
|
194
|
-
}
|
195
|
-
for (let headerLevel = 0; headerLevel < THs.length; headerLevel += 1) {
|
196
|
-
const newClasses = [];
|
197
|
-
let TH = THs[headerLevel];
|
198
|
-
if (highlightHeaderClassName) {
|
199
|
-
newClasses.push(highlightHeaderClassName);
|
200
|
-
}
|
201
|
-
if (highlightColumnClassName) {
|
202
|
-
newClasses.push(highlightColumnClassName);
|
203
|
-
}
|
204
|
-
headerLevel = highlightOnlyClosestHeader ? closestHeaderLevel : headerLevel;
|
205
|
-
const newSourceCol = wotInstance.getSetting('onBeforeHighlightingColumnHeader', sourceCol, headerLevel, {
|
206
|
-
selectionType,
|
207
|
-
columnCursor: selectionColumnCursor,
|
208
|
-
selectionWidth: bottomColumn - topColumn + 1,
|
209
|
-
classNames: newClasses
|
210
|
-
});
|
211
|
-
if (newSourceCol !== sourceCol) {
|
212
|
-
TH = wotInstance.wtTable.getColumnHeader(newSourceCol, headerLevel);
|
213
|
-
}
|
214
|
-
(0, _element.addClass)(TH, newClasses);
|
215
|
-
}
|
216
|
-
selectionColumnCursor += 1;
|
217
|
-
}
|
218
|
-
}
|
219
|
-
}
|
220
|
-
if (topRow !== null && bottomRow !== null) {
|
221
|
-
let selectionRowCursor = 0;
|
222
|
-
for (let row = 0; row < renderedRows; row += 1) {
|
223
|
-
const sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
|
224
|
-
if (isHeaderSelectionType && sourceRow >= topRow && sourceRow <= bottomRow) {
|
225
|
-
let THs = wotInstance.wtTable.getRowHeaders(sourceRow);
|
226
|
-
const closestHeaderLevel = THs.length - 1;
|
227
|
-
if (highlightOnlyClosestHeader && THs.length > 1) {
|
228
|
-
THs = [THs[closestHeaderLevel]];
|
229
|
-
}
|
230
|
-
for (let headerLevel = 0; headerLevel < THs.length; headerLevel += 1) {
|
231
|
-
const newClasses = [];
|
232
|
-
let TH = THs[headerLevel];
|
233
|
-
if (highlightHeaderClassName) {
|
234
|
-
newClasses.push(highlightHeaderClassName);
|
235
|
-
}
|
236
|
-
if (highlightRowClassName) {
|
237
|
-
newClasses.push(highlightRowClassName);
|
238
|
-
}
|
239
|
-
headerLevel = highlightOnlyClosestHeader ? closestHeaderLevel : headerLevel;
|
240
|
-
const newSourceRow = wotInstance.getSetting('onBeforeHighlightingRowHeader', sourceRow, headerLevel, {
|
241
|
-
selectionType,
|
242
|
-
rowCursor: selectionRowCursor,
|
243
|
-
selectionHeight: bottomRow - topRow + 1,
|
244
|
-
classNames: newClasses
|
245
|
-
});
|
246
|
-
if (newSourceRow !== sourceRow) {
|
247
|
-
TH = wotInstance.wtTable.getRowHeader(newSourceRow, headerLevel);
|
248
|
-
}
|
249
|
-
(0, _element.addClass)(TH, newClasses);
|
250
|
-
}
|
251
|
-
selectionRowCursor += 1;
|
252
|
-
}
|
253
|
-
if (topColumn !== null && bottomColumn !== null) {
|
254
|
-
for (let column = 0; column < renderedColumns; column += 1) {
|
255
|
-
const sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
|
256
|
-
if (sourceRow >= topRow && sourceRow <= bottomRow && sourceCol >= topColumn && sourceCol <= bottomColumn) {
|
257
|
-
// selected cell
|
258
|
-
if (this.settings.className) {
|
259
|
-
this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className, this.settings.markIntersections);
|
260
|
-
}
|
261
|
-
} else if (sourceRow >= topRow && sourceRow <= bottomRow) {
|
262
|
-
// selection is in this row
|
263
|
-
if (highlightRowClassName) {
|
264
|
-
this.addClassAtCoords(wotInstance, sourceRow, sourceCol, highlightRowClassName);
|
265
|
-
}
|
266
|
-
} else if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
|
267
|
-
// selection is in this column
|
268
|
-
if (highlightColumnClassName) {
|
269
|
-
this.addClassAtCoords(wotInstance, sourceRow, sourceCol, highlightColumnClassName);
|
270
|
-
}
|
271
|
-
}
|
272
|
-
const additionalSelectionClass = wotInstance.getSetting('onAfterDrawSelection', sourceRow, sourceCol, this.settings.layerLevel);
|
273
|
-
if (typeof additionalSelectionClass === 'string') {
|
274
|
-
this.addClassAtCoords(wotInstance, sourceRow, sourceCol, additionalSelectionClass);
|
275
|
-
}
|
276
|
-
}
|
277
|
-
}
|
278
|
-
}
|
279
|
-
}
|
280
|
-
wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
|
281
|
-
if (this.settings.border) {
|
282
|
-
// warning! border.appear modifies corners!
|
283
|
-
this.getBorder(wotInstance).appear(corners);
|
284
|
-
}
|
285
|
-
}
|
286
|
-
|
287
|
-
/**
|
288
|
-
* Cleans up all the DOM state related to a Selection instance. Call this prior to deleting a Selection instance.
|
289
|
-
*/
|
290
|
-
destroy() {
|
291
|
-
Object.values(this.instanceBorders).forEach(border => border.destroy());
|
292
|
-
}
|
293
|
-
}
|
294
|
-
var _default = Selection;
|
295
|
-
exports.default = _default;
|