handsontable 0.0.0-next-9379dd1-20231020 → 0.0.0-next-b0a4ea2-20231024
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/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +13 -12
- package/dist/handsontable.full.css +13 -12
- package/dist/handsontable.full.js +1864 -1143
- package/dist/handsontable.full.min.css +5 -5
- package/dist/handsontable.full.min.js +70 -70
- package/dist/handsontable.js +1864 -1143
- package/dist/handsontable.min.css +5 -5
- package/dist/handsontable.min.js +24 -24
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/contextMenu/menu/defaultShortcutsList.js +88 -0
- package/plugins/contextMenu/menu/defaultShortcutsList.mjs +84 -0
- package/plugins/contextMenu/menu/menu.js +87 -151
- package/plugins/contextMenu/menu/menu.mjs +90 -154
- package/plugins/contextMenu/menu/menuItemRenderer.js +58 -0
- package/plugins/contextMenu/menu/menuItemRenderer.mjs +54 -0
- package/plugins/contextMenu/menu/navigator.js +19 -144
- package/plugins/contextMenu/menu/navigator.mjs +18 -143
- package/plugins/contextMenu/menu/shortcuts.js +114 -0
- package/plugins/contextMenu/menu/shortcuts.mjs +110 -0
- package/plugins/dropdownMenu/dropdownMenu.js +32 -4
- package/plugins/dropdownMenu/dropdownMenu.mjs +33 -5
- package/plugins/filters/component/_base.js +23 -8
- package/plugins/filters/component/_base.mjs +23 -8
- package/plugins/filters/component/actionBar.js +29 -27
- package/plugins/filters/component/actionBar.mjs +26 -23
- package/plugins/filters/component/condition.js +46 -59
- package/plugins/filters/component/condition.mjs +40 -52
- package/plugins/filters/component/operators.js +21 -22
- package/plugins/filters/component/operators.mjs +18 -18
- package/plugins/filters/component/value.js +35 -26
- package/plugins/filters/component/value.mjs +32 -22
- package/plugins/filters/filters.js +75 -48
- package/plugins/filters/filters.mjs +68 -41
- package/plugins/filters/menu/focusController.js +123 -0
- package/plugins/filters/menu/focusController.mjs +119 -0
- package/plugins/filters/menu/focusNavigator.js +30 -0
- package/plugins/filters/menu/focusNavigator.mjs +26 -0
- package/plugins/filters/ui/_base.js +35 -13
- package/plugins/filters/ui/_base.mjs +35 -13
- package/plugins/filters/ui/input.js +43 -32
- package/plugins/filters/ui/input.mjs +42 -30
- package/plugins/filters/ui/link.js +44 -12
- package/plugins/filters/ui/link.mjs +44 -11
- package/plugins/filters/ui/multipleSelect.js +234 -129
- package/plugins/filters/ui/multipleSelect.mjs +232 -127
- package/plugins/filters/ui/radioInput.js +42 -18
- package/plugins/filters/ui/radioInput.mjs +42 -17
- package/plugins/filters/ui/select.js +144 -75
- package/plugins/filters/ui/select.mjs +140 -70
- package/shortcuts/context.js +3 -2
- package/shortcuts/context.mjs +3 -2
- package/utils/paginator.js +151 -0
- package/utils/paginator.mjs +147 -0
@@ -1,148 +1,23 @@
|
|
1
|
-
import "
|
2
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
3
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
4
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
5
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
6
|
-
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
7
|
-
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
8
|
-
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
9
|
-
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
10
|
-
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; } }
|
1
|
+
import { createPaginator } from "../../../utils/paginator.mjs";
|
11
2
|
import { isSeparator, isDisabled, isSelectionDisabled } from "./utils.mjs";
|
12
3
|
/**
|
13
|
-
*
|
4
|
+
* Creates navigator for menus and submenus.
|
14
5
|
*
|
15
|
-
* @
|
16
|
-
* @
|
6
|
+
* @param {Handsontable} hotMenu The Handsontable instance of the menu.
|
7
|
+
* @returns {Paginator}
|
17
8
|
*/
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
* @type {Handsontable}
|
33
|
-
*/
|
34
|
-
_classPrivateFieldInitSpec(this, _hotMenu, {
|
35
|
-
writable: true,
|
36
|
-
value: void 0
|
37
|
-
});
|
38
|
-
/**
|
39
|
-
* The index of the current selected menu item.
|
40
|
-
*
|
41
|
-
* @type {number}
|
42
|
-
*/
|
43
|
-
_classPrivateFieldInitSpec(this, _current, {
|
44
|
-
writable: true,
|
45
|
-
value: -1
|
46
|
-
});
|
47
|
-
/**
|
48
|
-
* The index of the previously selected menu item.
|
49
|
-
*
|
50
|
-
* @type {number}
|
51
|
-
*/
|
52
|
-
_classPrivateFieldInitSpec(this, _prev, {
|
53
|
-
writable: true,
|
54
|
-
value: -1
|
55
|
-
});
|
56
|
-
/**
|
57
|
-
* The collection of the already visited menu item indexes. The collection allows for preventing
|
58
|
-
* infinite loops in cases when all menu items are disabled, or there is only one item available
|
59
|
-
* and the navigation is triggered.
|
60
|
-
*
|
61
|
-
* @type {Set<number>}
|
62
|
-
*/
|
63
|
-
_classPrivateFieldInitSpec(this, _visited, {
|
64
|
-
writable: true,
|
65
|
-
value: new Set()
|
66
|
-
});
|
67
|
-
}
|
68
|
-
/**
|
69
|
-
* Sets the menu Handsontable instance.
|
70
|
-
*
|
71
|
-
* @param {Handsontable} hotMenu The menu Handsontable instance.
|
72
|
-
*/
|
73
|
-
setMenu(hotMenu) {
|
74
|
-
_classPrivateFieldSet(this, _hotMenu, hotMenu);
|
75
|
-
}
|
76
|
-
|
77
|
-
/**
|
78
|
-
* Selects the first menu item in the menu.
|
79
|
-
*/
|
80
|
-
selectFirst() {
|
81
|
-
_classPrivateFieldGet(this, _visited).clear();
|
82
|
-
_classPrivateFieldSet(this, _current, 0);
|
83
|
-
_classPrivateFieldSet(this, _prev, _classPrivateFieldGet(this, _current) - 1);
|
84
|
-
_classPrivateMethodGet(this, _updateMenuSelection, _updateMenuSelection2).call(this);
|
85
|
-
}
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Selects the last menu item in the menu.
|
89
|
-
*/
|
90
|
-
selectLast() {
|
91
|
-
_classPrivateFieldGet(this, _visited).clear();
|
92
|
-
_classPrivateFieldSet(this, _current, _classPrivateFieldGet(this, _hotMenu).countRows() - 1);
|
93
|
-
_classPrivateFieldSet(this, _prev, _classPrivateFieldGet(this, _current) + 1);
|
94
|
-
_classPrivateMethodGet(this, _updateMenuSelection, _updateMenuSelection2).call(this);
|
95
|
-
}
|
96
|
-
|
97
|
-
/**
|
98
|
-
* Selects the next menu item in the menu. The navigator tries to select the closes non-disabled menu
|
99
|
-
* item. When all next items are disabled the first (or next non-disabled) menu item is selected.
|
100
|
-
*/
|
101
|
-
selectNext() {
|
102
|
-
_classPrivateFieldGet(this, _visited).clear();
|
103
|
-
_classPrivateFieldSet(this, _current, _classPrivateFieldGet(this, _current) + 1);
|
104
|
-
_classPrivateMethodGet(this, _updateMenuSelection, _updateMenuSelection2).call(this);
|
105
|
-
}
|
106
|
-
|
107
|
-
/**
|
108
|
-
* Selects the previous menu item in the menu. The navigator tries to select the closes non-disabled menu
|
109
|
-
* item. When all previous items are disabled the last (or previous non-disabled) menu item is selected.
|
110
|
-
*/
|
111
|
-
selectPrev() {
|
112
|
-
_classPrivateFieldGet(this, _visited).clear();
|
113
|
-
_classPrivateFieldSet(this, _current, _classPrivateFieldGet(this, _current) - 1);
|
114
|
-
_classPrivateMethodGet(this, _updateMenuSelection, _updateMenuSelection2).call(this);
|
115
|
-
}
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Clears the internal state to the initial values.
|
119
|
-
*/
|
120
|
-
clear() {
|
121
|
-
_classPrivateFieldGet(this, _visited).clear();
|
122
|
-
_classPrivateFieldSet(this, _prev, -1);
|
123
|
-
_classPrivateFieldSet(this, _current, -1);
|
124
|
-
}
|
125
|
-
}
|
126
|
-
function _updateMenuSelection2() {
|
127
|
-
const maxItems = _classPrivateFieldGet(this, _hotMenu).countRows() - 1;
|
128
|
-
if (_classPrivateFieldGet(this, _current) < 0) {
|
129
|
-
_classPrivateFieldSet(this, _current, maxItems);
|
130
|
-
_classPrivateFieldSet(this, _prev, maxItems);
|
131
|
-
}
|
132
|
-
if (_classPrivateFieldGet(this, _current) > maxItems) {
|
133
|
-
_classPrivateFieldSet(this, _current, 0);
|
134
|
-
_classPrivateFieldSet(this, _prev, -1);
|
135
|
-
}
|
136
|
-
if (_classPrivateFieldGet(this, _visited).has(_classPrivateFieldGet(this, _current))) {
|
137
|
-
return;
|
138
|
-
}
|
139
|
-
const cell = _classPrivateFieldGet(this, _hotMenu).getCell(_classPrivateFieldGet(this, _current), 0);
|
140
|
-
_classPrivateFieldGet(this, _visited).add(_classPrivateFieldGet(this, _current));
|
141
|
-
if (!cell || isSeparator(cell) || isDisabled(cell) || isSelectionDisabled(cell)) {
|
142
|
-
_classPrivateFieldSet(this, _current, _classPrivateFieldGet(this, _current) + (_classPrivateFieldGet(this, _current) > _classPrivateFieldGet(this, _prev) ? 1 : -1));
|
143
|
-
_classPrivateMethodGet(this, _updateMenuSelection, _updateMenuSelection2).call(this);
|
144
|
-
} else {
|
145
|
-
_classPrivateFieldGet(this, _hotMenu).selectCell(_classPrivateFieldGet(this, _current), 0);
|
146
|
-
}
|
147
|
-
_classPrivateFieldSet(this, _prev, _classPrivateFieldGet(this, _current));
|
9
|
+
export function createMenuNavigator(hotMenu) {
|
10
|
+
return createPaginator({
|
11
|
+
size: () => hotMenu.countRows(),
|
12
|
+
onItemSelect(currentItem, directItemChange) {
|
13
|
+
const cell = hotMenu.getCell(currentItem, 0);
|
14
|
+
if (!cell || isSeparator(cell) || isDisabled(cell) || isSelectionDisabled(cell)) {
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
hotMenu.selectCell(currentItem, 0, ...(directItemChange ? [currentItem, 0, false, false] : []));
|
18
|
+
},
|
19
|
+
onClear() {
|
20
|
+
hotMenu.deselectCell();
|
21
|
+
}
|
22
|
+
});
|
148
23
|
}
|
@@ -0,0 +1,114 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.createKeyboardShortcutsCtrl = createKeyboardShortcutsCtrl;
|
5
|
+
require("core-js/modules/es.array.push.js");
|
6
|
+
var _defaultShortcutsList = require("./defaultShortcutsList");
|
7
|
+
const SHORTCUTS_CONTEXT = 'menu';
|
8
|
+
const SHORTCUTS_GROUP = SHORTCUTS_CONTEXT;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* @typedef KeyboardShortcutsMenuController
|
12
|
+
* @property {function(KeyboardShortcut[]): void} addCustomShortcuts Adds (by replacing) new keyboard shortcuts to the menu.
|
13
|
+
* @property {function(string): number} getContext Gets the keyboard shortcuts context by name.
|
14
|
+
* @property {function(string): void} listen Sets the active keyboard shortcuts context of the menu.
|
15
|
+
*/
|
16
|
+
/**
|
17
|
+
* Creates the controller object that allows extending the keyboard shortcuts of the menu.
|
18
|
+
*
|
19
|
+
* @param {Menu} menu The menu instance.
|
20
|
+
* @param {Array<{ shortcuts: KeyboardShortcut, contextName: string }>} [customKeyboardShortcuts] The list of the custom keyboard shortcuts.
|
21
|
+
* @returns {KeyboardShortcutsMenuController}
|
22
|
+
*/
|
23
|
+
function createKeyboardShortcutsCtrl(menu) {
|
24
|
+
let customKeyboardShortcuts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
25
|
+
const customShortcuts = [];
|
26
|
+
_addShortcuts((0, _defaultShortcutsList.createDefaultShortcutsList)(menu));
|
27
|
+
customKeyboardShortcuts.forEach(_ref => {
|
28
|
+
let {
|
29
|
+
shortcuts,
|
30
|
+
contextName
|
31
|
+
} = _ref;
|
32
|
+
addCustomShortcuts(shortcuts, contextName);
|
33
|
+
});
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Adds keyboard shortcuts to the menu.
|
37
|
+
*
|
38
|
+
* @param {KeyboardShortcut[]} shortcuts Keyboard shortcuts to add.
|
39
|
+
* @param {string} [contextName] The context name to create or use.
|
40
|
+
*/
|
41
|
+
function _addShortcuts(shortcuts, contextName) {
|
42
|
+
getContext(contextName).addShortcuts(shortcuts, {
|
43
|
+
group: SHORTCUTS_CONTEXT
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Adds custom keyboard shortcuts to the menu.
|
49
|
+
*
|
50
|
+
* @param {KeyboardShortcut[]} shortcuts Keyboard shortcuts to add.
|
51
|
+
* @param {string} [contextName] The context name to create or use.
|
52
|
+
*/
|
53
|
+
function addCustomShortcuts(shortcuts, contextName) {
|
54
|
+
const context = getContext(contextName);
|
55
|
+
shortcuts.forEach(_ref2 => {
|
56
|
+
let {
|
57
|
+
keys
|
58
|
+
} = _ref2;
|
59
|
+
keys.forEach(k => context.removeShortcutsByKeys(k));
|
60
|
+
});
|
61
|
+
customShortcuts.push({
|
62
|
+
shortcuts,
|
63
|
+
contextName
|
64
|
+
});
|
65
|
+
_addShortcuts(shortcuts, contextName);
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Gets all registered custom keyboard shortcuts.
|
70
|
+
*
|
71
|
+
* @returns {Array<{ shortcuts: KeyboardShortcut, contextName: string }>}
|
72
|
+
*/
|
73
|
+
function getCustomShortcuts() {
|
74
|
+
return [...customShortcuts];
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Gets the context name.
|
79
|
+
*
|
80
|
+
* @param {string} contextName The context name.
|
81
|
+
* @returns {string}
|
82
|
+
*/
|
83
|
+
function _getContextName(contextName) {
|
84
|
+
return contextName ? `${SHORTCUTS_GROUP}:${contextName}` : SHORTCUTS_GROUP;
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Gets the keyboard shortcut context by its name.
|
89
|
+
*
|
90
|
+
* @param {string} contextName The context name.
|
91
|
+
* @returns {object}
|
92
|
+
*/
|
93
|
+
function getContext(contextName) {
|
94
|
+
var _manager$getContext;
|
95
|
+
const manager = menu.hotMenu.getShortcutManager();
|
96
|
+
const name = _getContextName(contextName);
|
97
|
+
return (_manager$getContext = manager.getContext(name)) !== null && _manager$getContext !== void 0 ? _manager$getContext : manager.addContext(name);
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Makes the specified context active.
|
102
|
+
*
|
103
|
+
* @param {string} contextName The context name.
|
104
|
+
*/
|
105
|
+
function listen(contextName) {
|
106
|
+
menu.hotMenu.getShortcutManager().setActiveContextName(_getContextName(contextName));
|
107
|
+
}
|
108
|
+
return {
|
109
|
+
addCustomShortcuts,
|
110
|
+
getCustomShortcuts,
|
111
|
+
getContext,
|
112
|
+
listen
|
113
|
+
};
|
114
|
+
}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import "core-js/modules/es.array.push.js";
|
2
|
+
import { createDefaultShortcutsList } from "./defaultShortcutsList.mjs";
|
3
|
+
const SHORTCUTS_CONTEXT = 'menu';
|
4
|
+
const SHORTCUTS_GROUP = SHORTCUTS_CONTEXT;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @typedef KeyboardShortcutsMenuController
|
8
|
+
* @property {function(KeyboardShortcut[]): void} addCustomShortcuts Adds (by replacing) new keyboard shortcuts to the menu.
|
9
|
+
* @property {function(string): number} getContext Gets the keyboard shortcuts context by name.
|
10
|
+
* @property {function(string): void} listen Sets the active keyboard shortcuts context of the menu.
|
11
|
+
*/
|
12
|
+
/**
|
13
|
+
* Creates the controller object that allows extending the keyboard shortcuts of the menu.
|
14
|
+
*
|
15
|
+
* @param {Menu} menu The menu instance.
|
16
|
+
* @param {Array<{ shortcuts: KeyboardShortcut, contextName: string }>} [customKeyboardShortcuts] The list of the custom keyboard shortcuts.
|
17
|
+
* @returns {KeyboardShortcutsMenuController}
|
18
|
+
*/
|
19
|
+
export function createKeyboardShortcutsCtrl(menu) {
|
20
|
+
let customKeyboardShortcuts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
21
|
+
const customShortcuts = [];
|
22
|
+
_addShortcuts(createDefaultShortcutsList(menu));
|
23
|
+
customKeyboardShortcuts.forEach(_ref => {
|
24
|
+
let {
|
25
|
+
shortcuts,
|
26
|
+
contextName
|
27
|
+
} = _ref;
|
28
|
+
addCustomShortcuts(shortcuts, contextName);
|
29
|
+
});
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Adds keyboard shortcuts to the menu.
|
33
|
+
*
|
34
|
+
* @param {KeyboardShortcut[]} shortcuts Keyboard shortcuts to add.
|
35
|
+
* @param {string} [contextName] The context name to create or use.
|
36
|
+
*/
|
37
|
+
function _addShortcuts(shortcuts, contextName) {
|
38
|
+
getContext(contextName).addShortcuts(shortcuts, {
|
39
|
+
group: SHORTCUTS_CONTEXT
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Adds custom keyboard shortcuts to the menu.
|
45
|
+
*
|
46
|
+
* @param {KeyboardShortcut[]} shortcuts Keyboard shortcuts to add.
|
47
|
+
* @param {string} [contextName] The context name to create or use.
|
48
|
+
*/
|
49
|
+
function addCustomShortcuts(shortcuts, contextName) {
|
50
|
+
const context = getContext(contextName);
|
51
|
+
shortcuts.forEach(_ref2 => {
|
52
|
+
let {
|
53
|
+
keys
|
54
|
+
} = _ref2;
|
55
|
+
keys.forEach(k => context.removeShortcutsByKeys(k));
|
56
|
+
});
|
57
|
+
customShortcuts.push({
|
58
|
+
shortcuts,
|
59
|
+
contextName
|
60
|
+
});
|
61
|
+
_addShortcuts(shortcuts, contextName);
|
62
|
+
}
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Gets all registered custom keyboard shortcuts.
|
66
|
+
*
|
67
|
+
* @returns {Array<{ shortcuts: KeyboardShortcut, contextName: string }>}
|
68
|
+
*/
|
69
|
+
function getCustomShortcuts() {
|
70
|
+
return [...customShortcuts];
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Gets the context name.
|
75
|
+
*
|
76
|
+
* @param {string} contextName The context name.
|
77
|
+
* @returns {string}
|
78
|
+
*/
|
79
|
+
function _getContextName(contextName) {
|
80
|
+
return contextName ? `${SHORTCUTS_GROUP}:${contextName}` : SHORTCUTS_GROUP;
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Gets the keyboard shortcut context by its name.
|
85
|
+
*
|
86
|
+
* @param {string} contextName The context name.
|
87
|
+
* @returns {object}
|
88
|
+
*/
|
89
|
+
function getContext(contextName) {
|
90
|
+
var _manager$getContext;
|
91
|
+
const manager = menu.hotMenu.getShortcutManager();
|
92
|
+
const name = _getContextName(contextName);
|
93
|
+
return (_manager$getContext = manager.getContext(name)) !== null && _manager$getContext !== void 0 ? _manager$getContext : manager.addContext(name);
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Makes the specified context active.
|
98
|
+
*
|
99
|
+
* @param {string} contextName The context name.
|
100
|
+
*/
|
101
|
+
function listen(contextName) {
|
102
|
+
menu.hotMenu.getShortcutManager().setActiveContextName(_getContextName(contextName));
|
103
|
+
}
|
104
|
+
return {
|
105
|
+
addCustomShortcuts,
|
106
|
+
getCustomShortcuts,
|
107
|
+
getContext,
|
108
|
+
listen
|
109
|
+
};
|
110
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
4
5
|
var _base = require("../base");
|
5
6
|
var _array = require("../../helpers/array");
|
6
7
|
var _object = require("../../helpers/object");
|
@@ -14,6 +15,9 @@ var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
|
|
14
15
|
var _predefinedItems = require("../contextMenu/predefinedItems");
|
15
16
|
var _a11y = require("../../helpers/a11y");
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
19
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
20
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
17
21
|
_pluginHooks.default.getSingleton().register('afterDropdownMenuDefaultOptions');
|
18
22
|
_pluginHooks.default.getSingleton().register('beforeDropdownMenuShow');
|
19
23
|
_pluginHooks.default.getSingleton().register('afterDropdownMenuShow');
|
@@ -76,7 +80,7 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
|
|
76
80
|
* ```
|
77
81
|
* :::
|
78
82
|
*/
|
79
|
-
|
83
|
+
var _addCustomShortcuts = /*#__PURE__*/new WeakSet();
|
80
84
|
class DropdownMenu extends _base.BasePlugin {
|
81
85
|
static get PLUGIN_KEY() {
|
82
86
|
return PLUGIN_KEY;
|
@@ -104,6 +108,12 @@ class DropdownMenu extends _base.BasePlugin {
|
|
104
108
|
* @private
|
105
109
|
* @type {EventManager}
|
106
110
|
*/
|
111
|
+
/**
|
112
|
+
* Add custom shortcuts to the provided menu instance.
|
113
|
+
*
|
114
|
+
* @param {Menu} menuInstance The menu instance.
|
115
|
+
*/
|
116
|
+
_classPrivateMethodInitSpec(this, _addCustomShortcuts);
|
107
117
|
this.eventManager = new _eventManager.default(this);
|
108
118
|
/**
|
109
119
|
* Instance of {@link CommandExecutor}.
|
@@ -179,6 +189,7 @@ class DropdownMenu extends _base.BasePlugin {
|
|
179
189
|
this.menu.setMenuItems(menuItems);
|
180
190
|
this.menu.addLocalHook('beforeOpen', () => this.onMenuBeforeOpen());
|
181
191
|
this.menu.addLocalHook('afterOpen', () => this.onMenuAfterOpen());
|
192
|
+
this.menu.addLocalHook('afterSubmenuOpen', subMenuInstance => this.onSubMenuAfterOpen(subMenuInstance));
|
182
193
|
this.menu.addLocalHook('afterClose', () => this.onMenuAfterClose());
|
183
194
|
this.menu.addLocalHook('executeCommand', function () {
|
184
195
|
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
@@ -222,7 +233,7 @@ class DropdownMenu extends _base.BasePlugin {
|
|
222
233
|
* @private
|
223
234
|
*/
|
224
235
|
registerShortcuts() {
|
225
|
-
const
|
236
|
+
const gridContext = this.hot.getShortcutManager().getContext('grid');
|
226
237
|
const callback = () => {
|
227
238
|
const {
|
228
239
|
highlight
|
@@ -243,7 +254,7 @@ class DropdownMenu extends _base.BasePlugin {
|
|
243
254
|
});
|
244
255
|
}
|
245
256
|
};
|
246
|
-
|
257
|
+
gridContext.addShortcuts([{
|
247
258
|
keys: [['Shift', 'Alt', 'ArrowDown'], ['Control/Meta', 'Enter']],
|
248
259
|
callback,
|
249
260
|
runOnlyIf: () => {
|
@@ -372,7 +383,6 @@ class DropdownMenu extends _base.BasePlugin {
|
|
372
383
|
}
|
373
384
|
}
|
374
385
|
}
|
375
|
-
|
376
386
|
/**
|
377
387
|
* Table click listener.
|
378
388
|
*
|
@@ -430,6 +440,7 @@ class DropdownMenu extends _base.BasePlugin {
|
|
430
440
|
button.tabIndex = -1;
|
431
441
|
if (this.hot.getSettings().ariaTags) {
|
432
442
|
(0, _element.setAttribute)(button, [(0, _a11y.A11Y_HIDDEN)()]);
|
443
|
+
(0, _element.setAttribute)(TH, [(0, _a11y.A11Y_HASPOPUP)('menu')]);
|
433
444
|
}
|
434
445
|
|
435
446
|
// prevent page reload on button click
|
@@ -457,6 +468,17 @@ class DropdownMenu extends _base.BasePlugin {
|
|
457
468
|
*/
|
458
469
|
onMenuAfterOpen() {
|
459
470
|
this.hot.runHooks('afterDropdownMenuShow', this);
|
471
|
+
_classPrivateMethodGet(this, _addCustomShortcuts, _addCustomShortcuts2).call(this, this.menu);
|
472
|
+
}
|
473
|
+
|
474
|
+
/**
|
475
|
+
* Listener for the `afterSubmenuOpen` hook.
|
476
|
+
*
|
477
|
+
* @private
|
478
|
+
* @param {Menu} subMenuInstance The opened sub menu instance.
|
479
|
+
*/
|
480
|
+
onSubMenuAfterOpen(subMenuInstance) {
|
481
|
+
_classPrivateMethodGet(this, _addCustomShortcuts, _addCustomShortcuts2).call(this, subMenuInstance);
|
460
482
|
}
|
461
483
|
|
462
484
|
/**
|
@@ -482,6 +504,12 @@ class DropdownMenu extends _base.BasePlugin {
|
|
482
504
|
}
|
483
505
|
}
|
484
506
|
exports.DropdownMenu = DropdownMenu;
|
507
|
+
function _addCustomShortcuts2(menuInstance) {
|
508
|
+
menuInstance.getKeyboardShortcutsCtrl().addCustomShortcuts([{
|
509
|
+
keys: [['Control/Meta', 'A']],
|
510
|
+
callback: () => false
|
511
|
+
}]);
|
512
|
+
}
|
485
513
|
DropdownMenu.SEPARATOR = {
|
486
514
|
name: _predefinedItems.SEPARATOR
|
487
515
|
};
|
@@ -1,3 +1,7 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
3
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
4
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
1
5
|
import { BasePlugin } from "../base/index.mjs";
|
2
6
|
import { arrayEach } from "../../helpers/array.mjs";
|
3
7
|
import { objectEach } from "../../helpers/object.mjs";
|
@@ -9,7 +13,7 @@ import { ItemsFactory } from "../contextMenu/itemsFactory.mjs";
|
|
9
13
|
import { Menu } from "../contextMenu/menu/index.mjs";
|
10
14
|
import Hooks from "../../pluginHooks.mjs";
|
11
15
|
import { COLUMN_LEFT, COLUMN_RIGHT, REMOVE_COLUMN, CLEAR_COLUMN, READ_ONLY, ALIGNMENT, SEPARATOR } from "../contextMenu/predefinedItems/index.mjs";
|
12
|
-
import { A11Y_HIDDEN } from "../../helpers/a11y.mjs";
|
16
|
+
import { A11Y_HASPOPUP, A11Y_HIDDEN } from "../../helpers/a11y.mjs";
|
13
17
|
Hooks.getSingleton().register('afterDropdownMenuDefaultOptions');
|
14
18
|
Hooks.getSingleton().register('beforeDropdownMenuShow');
|
15
19
|
Hooks.getSingleton().register('afterDropdownMenuShow');
|
@@ -70,7 +74,7 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
|
|
70
74
|
* ```
|
71
75
|
* :::
|
72
76
|
*/
|
73
|
-
|
77
|
+
var _addCustomShortcuts = /*#__PURE__*/new WeakSet();
|
74
78
|
export class DropdownMenu extends BasePlugin {
|
75
79
|
static get PLUGIN_KEY() {
|
76
80
|
return PLUGIN_KEY;
|
@@ -98,6 +102,12 @@ export class DropdownMenu extends BasePlugin {
|
|
98
102
|
* @private
|
99
103
|
* @type {EventManager}
|
100
104
|
*/
|
105
|
+
/**
|
106
|
+
* Add custom shortcuts to the provided menu instance.
|
107
|
+
*
|
108
|
+
* @param {Menu} menuInstance The menu instance.
|
109
|
+
*/
|
110
|
+
_classPrivateMethodInitSpec(this, _addCustomShortcuts);
|
101
111
|
this.eventManager = new EventManager(this);
|
102
112
|
/**
|
103
113
|
* Instance of {@link CommandExecutor}.
|
@@ -173,6 +183,7 @@ export class DropdownMenu extends BasePlugin {
|
|
173
183
|
this.menu.setMenuItems(menuItems);
|
174
184
|
this.menu.addLocalHook('beforeOpen', () => this.onMenuBeforeOpen());
|
175
185
|
this.menu.addLocalHook('afterOpen', () => this.onMenuAfterOpen());
|
186
|
+
this.menu.addLocalHook('afterSubmenuOpen', subMenuInstance => this.onSubMenuAfterOpen(subMenuInstance));
|
176
187
|
this.menu.addLocalHook('afterClose', () => this.onMenuAfterClose());
|
177
188
|
this.menu.addLocalHook('executeCommand', function () {
|
178
189
|
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
@@ -216,7 +227,7 @@ export class DropdownMenu extends BasePlugin {
|
|
216
227
|
* @private
|
217
228
|
*/
|
218
229
|
registerShortcuts() {
|
219
|
-
const
|
230
|
+
const gridContext = this.hot.getShortcutManager().getContext('grid');
|
220
231
|
const callback = () => {
|
221
232
|
const {
|
222
233
|
highlight
|
@@ -237,7 +248,7 @@ export class DropdownMenu extends BasePlugin {
|
|
237
248
|
});
|
238
249
|
}
|
239
250
|
};
|
240
|
-
|
251
|
+
gridContext.addShortcuts([{
|
241
252
|
keys: [['Shift', 'Alt', 'ArrowDown'], ['Control/Meta', 'Enter']],
|
242
253
|
callback,
|
243
254
|
runOnlyIf: () => {
|
@@ -366,7 +377,6 @@ export class DropdownMenu extends BasePlugin {
|
|
366
377
|
}
|
367
378
|
}
|
368
379
|
}
|
369
|
-
|
370
380
|
/**
|
371
381
|
* Table click listener.
|
372
382
|
*
|
@@ -424,6 +434,7 @@ export class DropdownMenu extends BasePlugin {
|
|
424
434
|
button.tabIndex = -1;
|
425
435
|
if (this.hot.getSettings().ariaTags) {
|
426
436
|
setAttribute(button, [A11Y_HIDDEN()]);
|
437
|
+
setAttribute(TH, [A11Y_HASPOPUP('menu')]);
|
427
438
|
}
|
428
439
|
|
429
440
|
// prevent page reload on button click
|
@@ -451,6 +462,17 @@ export class DropdownMenu extends BasePlugin {
|
|
451
462
|
*/
|
452
463
|
onMenuAfterOpen() {
|
453
464
|
this.hot.runHooks('afterDropdownMenuShow', this);
|
465
|
+
_classPrivateMethodGet(this, _addCustomShortcuts, _addCustomShortcuts2).call(this, this.menu);
|
466
|
+
}
|
467
|
+
|
468
|
+
/**
|
469
|
+
* Listener for the `afterSubmenuOpen` hook.
|
470
|
+
*
|
471
|
+
* @private
|
472
|
+
* @param {Menu} subMenuInstance The opened sub menu instance.
|
473
|
+
*/
|
474
|
+
onSubMenuAfterOpen(subMenuInstance) {
|
475
|
+
_classPrivateMethodGet(this, _addCustomShortcuts, _addCustomShortcuts2).call(this, subMenuInstance);
|
454
476
|
}
|
455
477
|
|
456
478
|
/**
|
@@ -475,6 +497,12 @@ export class DropdownMenu extends BasePlugin {
|
|
475
497
|
super.destroy();
|
476
498
|
}
|
477
499
|
}
|
500
|
+
function _addCustomShortcuts2(menuInstance) {
|
501
|
+
menuInstance.getKeyboardShortcutsCtrl().addCustomShortcuts([{
|
502
|
+
keys: [['Control/Meta', 'A']],
|
503
|
+
callback: () => false
|
504
|
+
}]);
|
505
|
+
}
|
478
506
|
DropdownMenu.SEPARATOR = {
|
479
507
|
name: SEPARATOR
|
480
508
|
};
|
@@ -7,6 +7,9 @@ var _object = require("../../../helpers/object");
|
|
7
7
|
var _localHooks = _interopRequireDefault(require("../../../mixins/localHooks"));
|
8
8
|
var _translations = require("../../../translations");
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
12
|
+
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); }
|
10
13
|
/**
|
11
14
|
* @private
|
12
15
|
* @class BaseComponent
|
@@ -22,39 +25,52 @@ class BaseComponent {
|
|
22
25
|
*
|
23
26
|
* @type {Core}
|
24
27
|
*/
|
25
|
-
this
|
28
|
+
_defineProperty(this, "hot", void 0);
|
26
29
|
/**
|
27
30
|
* The component uniq id.
|
28
31
|
*
|
29
32
|
* @type {string}
|
30
33
|
*/
|
31
|
-
this
|
34
|
+
_defineProperty(this, "id", void 0);
|
32
35
|
/**
|
33
36
|
* List of registered component UI elements.
|
34
37
|
*
|
35
38
|
* @type {Array}
|
36
39
|
*/
|
37
|
-
this
|
40
|
+
_defineProperty(this, "elements", []);
|
38
41
|
/**
|
39
42
|
* Flag which determines if element is hidden.
|
40
43
|
*
|
41
44
|
* @type {boolean}
|
42
45
|
*/
|
43
|
-
this
|
46
|
+
_defineProperty(this, "hidden", false);
|
44
47
|
/**
|
45
48
|
* The component states id.
|
46
49
|
*
|
47
50
|
* @type {string}
|
48
51
|
*/
|
49
|
-
this
|
52
|
+
_defineProperty(this, "stateId", '');
|
50
53
|
/**
|
51
54
|
* Index map which stores component states for each column.
|
52
55
|
*
|
53
56
|
* @type {LinkedPhysicalIndexToValueMap|null}
|
54
57
|
*/
|
58
|
+
_defineProperty(this, "state", void 0);
|
59
|
+
this.hot = hotInstance;
|
60
|
+
this.id = id;
|
61
|
+
this.stateId = `Filters.component.${this.id}`;
|
55
62
|
this.state = stateless ? null : this.hot.columnIndexMapper.registerMap(this.stateId, new _translations.LinkedPhysicalIndexToValueMap());
|
56
63
|
}
|
57
64
|
|
65
|
+
/**
|
66
|
+
* Gets the list of elements from which the component is built.
|
67
|
+
*
|
68
|
+
* @returns {BaseUI[]}
|
69
|
+
*/
|
70
|
+
getElements() {
|
71
|
+
return this.elements;
|
72
|
+
}
|
73
|
+
|
58
74
|
/**
|
59
75
|
* Reset elements to its initial state.
|
60
76
|
*/
|
@@ -137,6 +153,5 @@ class BaseComponent {
|
|
137
153
|
this.hot = null;
|
138
154
|
}
|
139
155
|
}
|
140
|
-
|
141
|
-
|
142
|
-
exports.default = _default;
|
156
|
+
exports.BaseComponent = BaseComponent;
|
157
|
+
(0, _object.mixin)(BaseComponent, _localHooks.default);
|