@deephaven/components 0.5.2-beta.0 → 0.6.1-demo.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AutoCompleteInput.js +410 -448
- package/dist/AutoCompleteInput.js.map +1 -1
- package/dist/AutoResizeTextarea.js +17 -46
- package/dist/AutoResizeTextarea.js.map +1 -1
- package/dist/BasicModal.js +18 -19
- package/dist/BasicModal.js.map +1 -1
- package/dist/Button.js +30 -21
- package/dist/Button.js.map +1 -1
- package/dist/ButtonGroup.js +6 -4
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/ButtonOld.js +10 -8
- package/dist/ButtonOld.js.map +1 -1
- package/dist/CardFlip.js +10 -8
- package/dist/CardFlip.js.map +1 -1
- package/dist/Checkbox.js +18 -31
- package/dist/Checkbox.js.map +1 -1
- package/dist/Collapse.js +65 -105
- package/dist/Collapse.js.map +1 -1
- package/dist/ComboBox.js +432 -460
- package/dist/ComboBox.js.map +1 -1
- package/dist/CustomTimeSelect.js +485 -517
- package/dist/CustomTimeSelect.js.map +1 -1
- package/dist/DebouncedSearchInput.js +61 -91
- package/dist/DebouncedSearchInput.js.map +1 -1
- package/dist/DeephavenSpinner.js +6 -6
- package/dist/DeephavenSpinner.js.map +1 -1
- package/dist/DragUtils.js +65 -113
- package/dist/DragUtils.js.map +1 -1
- package/dist/DraggableItemList.d.ts +1 -0
- package/dist/DraggableItemList.d.ts.map +1 -1
- package/dist/DraggableItemList.js +219 -257
- package/dist/DraggableItemList.js.map +1 -1
- package/dist/HierarchicalCheckboxMenu.js +160 -227
- package/dist/HierarchicalCheckboxMenu.js.map +1 -1
- package/dist/ItemList.d.ts +4 -2
- package/dist/ItemList.d.ts.map +1 -1
- package/dist/ItemList.js +595 -598
- package/dist/ItemList.js.map +1 -1
- package/dist/ItemListItem.js +194 -215
- package/dist/ItemListItem.js.map +1 -1
- package/dist/LoadingOverlay.js +9 -10
- package/dist/LoadingOverlay.js.map +1 -1
- package/dist/LoadingSpinner.js +4 -3
- package/dist/LoadingSpinner.js.map +1 -1
- package/dist/MaskedInput.js +59 -70
- package/dist/MaskedInput.js.map +1 -1
- package/dist/Option.js +5 -3
- package/dist/Option.js.map +1 -1
- package/dist/RadioGroup.js +16 -34
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioItem.js +14 -33
- package/dist/RadioItem.js.map +1 -1
- package/dist/SearchInput.js +42 -75
- package/dist/SearchInput.js.map +1 -1
- package/dist/Select.js +10 -8
- package/dist/Select.js.map +1 -1
- package/dist/SelectValueList.js +97 -134
- package/dist/SelectValueList.js.map +1 -1
- package/dist/SocketedButton.js +13 -11
- package/dist/SocketedButton.js.map +1 -1
- package/dist/ThemeExport.js.map +1 -1
- package/dist/TimeInput.js +16 -53
- package/dist/TimeInput.js.map +1 -1
- package/dist/TimeSlider.js +62 -88
- package/dist/TimeSlider.js.map +1 -1
- package/dist/ToastNotification.js +14 -13
- package/dist/ToastNotification.js.map +1 -1
- package/dist/UISwitch.js +9 -8
- package/dist/UISwitch.js.map +1 -1
- package/dist/context-actions/ContextActionUtils.js +173 -231
- package/dist/context-actions/ContextActionUtils.js.map +1 -1
- package/dist/context-actions/ContextActions.js +135 -177
- package/dist/context-actions/ContextActions.js.map +1 -1
- package/dist/context-actions/ContextMenu.js +509 -543
- package/dist/context-actions/ContextMenu.js.map +1 -1
- package/dist/context-actions/ContextMenuItem.js +32 -22
- package/dist/context-actions/ContextMenuItem.js.map +1 -1
- package/dist/context-actions/ContextMenuRoot.js +112 -152
- package/dist/context-actions/ContextMenuRoot.js.map +1 -1
- package/dist/context-actions/GlobalContextAction.js +49 -84
- package/dist/context-actions/GlobalContextAction.js.map +1 -1
- package/dist/context-actions/GlobalContextActions.js +25 -57
- package/dist/context-actions/GlobalContextActions.js.map +1 -1
- package/dist/context-actions/index.js +4 -4
- package/dist/context-actions/index.js.map +1 -1
- package/dist/index.js +39 -39
- package/dist/index.js.map +1 -1
- package/dist/menu-actions/DropdownMenu.js +126 -159
- package/dist/menu-actions/DropdownMenu.js.map +1 -1
- package/dist/menu-actions/Menu.js +215 -245
- package/dist/menu-actions/Menu.js.map +1 -1
- package/dist/menu-actions/index.js +1 -1
- package/dist/menu-actions/index.js.map +1 -1
- package/dist/navigation/Menu.js +14 -18
- package/dist/navigation/Menu.js.map +1 -1
- package/dist/navigation/MenuItem.js +15 -14
- package/dist/navigation/MenuItem.js.map +1 -1
- package/dist/navigation/Page.js +7 -5
- package/dist/navigation/Page.js.map +1 -1
- package/dist/navigation/Stack.js +14 -39
- package/dist/navigation/Stack.js.map +1 -1
- package/dist/navigation/index.js +4 -4
- package/dist/navigation/index.js.map +1 -1
- package/dist/popper/Popper.js +209 -235
- package/dist/popper/Popper.js.map +1 -1
- package/dist/popper/Tooltip.js +227 -257
- package/dist/popper/Tooltip.js.map +1 -1
- package/dist/popper/index.js +2 -2
- package/dist/popper/index.js.map +1 -1
- package/dist/shortcuts/GlobalShortcuts.js +2 -2
- package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
- package/dist/shortcuts/Shortcut.js +263 -291
- package/dist/shortcuts/Shortcut.js.map +1 -1
- package/dist/shortcuts/ShortcutRegistry.js +48 -71
- package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
- package/dist/shortcuts/index.js +4 -4
- package/dist/shortcuts/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -54
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/shortcuts/GlobalShortcuts.ts"],"names":["ShortcutRegistry","MODIFIER","KEY","GLOBAL_SHORTCUTS","COPY","createAndAdd","id","name","shortcut","CTRL","C","macShortcut","CMD","isEditable","PASTE","V","SAVE","S","SELECT_ALL","A","LINKER","L","LINKER_CLOSE","ESCAPE"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/shortcuts/GlobalShortcuts.ts"],"names":["ShortcutRegistry","MODIFIER","KEY","GLOBAL_SHORTCUTS","COPY","createAndAdd","id","name","shortcut","CTRL","C","macShortcut","CMD","isEditable","PASTE","V","SAVE","S","SELECT_ALL","A","LINKER","L","LINKER_CLOSE","ESCAPE"],"mappings":"OAAOA,gB;SACEC,Q,EAAUC,G;AAEnB,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,IAAI,EAAEJ,gBAAgB,CAACK,YAAjB,CAA8B;AAClCC,IAAAA,EAAE,EAAE,aAD8B;AAElCC,IAAAA,IAAI,EAAE,MAF4B;AAGlCC,IAAAA,QAAQ,EAAE,CAACP,QAAQ,CAACQ,IAAV,EAAgBP,GAAG,CAACQ,CAApB,CAHwB;AAIlCC,IAAAA,WAAW,EAAE,CAACV,QAAQ,CAACW,GAAV,EAAeV,GAAG,CAACQ,CAAnB,CAJqB;AAKlCG,IAAAA,UAAU,EAAE;AALsB,GAA9B,CADiB;AAQvBC,EAAAA,KAAK,EAAEd,gBAAgB,CAACK,YAAjB,CAA8B;AACnCC,IAAAA,EAAE,EAAE,cAD+B;AAEnCC,IAAAA,IAAI,EAAE,OAF6B;AAGnCC,IAAAA,QAAQ,EAAE,CAACP,QAAQ,CAACQ,IAAV,EAAgBP,GAAG,CAACa,CAApB,CAHyB;AAInCJ,IAAAA,WAAW,EAAE,CAACV,QAAQ,CAACW,GAAV,EAAeV,GAAG,CAACa,CAAnB,CAJsB;AAKnCF,IAAAA,UAAU,EAAE;AALuB,GAA9B,CARgB;AAevBG,EAAAA,IAAI,EAAEhB,gBAAgB,CAACK,YAAjB,CAA8B;AAClCC,IAAAA,EAAE,EAAE,aAD8B;AAElCC,IAAAA,IAAI,EAAE,MAF4B;AAGlCC,IAAAA,QAAQ,EAAE,CAACP,QAAQ,CAACQ,IAAV,EAAgBP,GAAG,CAACe,CAApB,CAHwB;AAIlCN,IAAAA,WAAW,EAAE,CAACV,QAAQ,CAACW,GAAV,EAAeV,GAAG,CAACe,CAAnB,CAJqB;AAKlCJ,IAAAA,UAAU,EAAE;AALsB,GAA9B,CAfiB;AAsBvBK,EAAAA,UAAU,EAAElB,gBAAgB,CAACK,YAAjB,CAA8B;AACxCC,IAAAA,EAAE,EAAE,mBADoC;AAExCC,IAAAA,IAAI,EAAE,YAFkC;AAGxCC,IAAAA,QAAQ,EAAE,CAACP,QAAQ,CAACQ,IAAV,EAAgBP,GAAG,CAACiB,CAApB,CAH8B;AAIxCR,IAAAA,WAAW,EAAE,CAACV,QAAQ,CAACW,GAAV,EAAeV,GAAG,CAACiB,CAAnB,CAJ2B;AAKxCN,IAAAA,UAAU,EAAE;AAL4B,GAA9B,CAtBW;AA6BvBO,EAAAA,MAAM,EAAEpB,gBAAgB,CAACK,YAAjB,CAA8B;AACpCC,IAAAA,EAAE,EAAE,eADgC;AAEpCC,IAAAA,IAAI,EAAE,QAF8B;AAGpCC,IAAAA,QAAQ,EAAE,CAACP,QAAQ,CAACQ,IAAV,EAAgBP,GAAG,CAACmB,CAApB,CAH0B;AAIpCV,IAAAA,WAAW,EAAE,CAACV,QAAQ,CAACW,GAAV,EAAeV,GAAG,CAACmB,CAAnB;AAJuB,GAA9B,CA7Be;AAmCvBC,EAAAA,YAAY,EAAEtB,gBAAgB,CAACK,YAAjB,CAA8B;AAC1CC,IAAAA,EAAE,EAAE,qBADsC;AAE1CC,IAAAA,IAAI,EAAE,sBAFoC;AAG1CC,IAAAA,QAAQ,EAAE,CAACN,GAAG,CAACqB,MAAL,CAHgC;AAI1CZ,IAAAA,WAAW,EAAE,CAACT,GAAG,CAACqB,MAAL,CAJ6B;AAK1CV,IAAAA,UAAU,EAAE;AAL8B,GAA9B;AAnCS,CAAzB;AA4CA,eAAeV,gBAAf","sourcesContent":["import ShortcutRegistry from './ShortcutRegistry';\nimport { MODIFIER, KEY } from './Shortcut';\n\nconst GLOBAL_SHORTCUTS = {\n COPY: ShortcutRegistry.createAndAdd({\n id: 'GLOBAL.COPY',\n name: 'Copy',\n shortcut: [MODIFIER.CTRL, KEY.C],\n macShortcut: [MODIFIER.CMD, KEY.C],\n isEditable: false,\n }),\n PASTE: ShortcutRegistry.createAndAdd({\n id: 'GLOBAL.PASTE',\n name: 'Paste',\n shortcut: [MODIFIER.CTRL, KEY.V],\n macShortcut: [MODIFIER.CMD, KEY.V],\n isEditable: false,\n }),\n SAVE: ShortcutRegistry.createAndAdd({\n id: 'GLOBAL.SAVE',\n name: 'Save',\n shortcut: [MODIFIER.CTRL, KEY.S],\n macShortcut: [MODIFIER.CMD, KEY.S],\n isEditable: false,\n }),\n SELECT_ALL: ShortcutRegistry.createAndAdd({\n id: 'GLOBAL.SELECT_ALL',\n name: 'Select All',\n shortcut: [MODIFIER.CTRL, KEY.A],\n macShortcut: [MODIFIER.CMD, KEY.A],\n isEditable: false,\n }),\n LINKER: ShortcutRegistry.createAndAdd({\n id: 'GLOBAL.LINKER',\n name: 'Linker',\n shortcut: [MODIFIER.CTRL, KEY.L],\n macShortcut: [MODIFIER.CMD, KEY.L],\n }),\n LINKER_CLOSE: ShortcutRegistry.createAndAdd({\n id: 'GLOBAL.LINKER_CLOSE',\n name: 'Close Linker Overlay',\n shortcut: [KEY.ESCAPE],\n macShortcut: [KEY.ESCAPE],\n isEditable: false,\n }),\n};\n\nexport default GLOBAL_SHORTCUTS;\n"],"file":"GlobalShortcuts.js"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
-
|
|
3
|
-
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, descriptor.key, descriptor); } }
|
|
4
|
-
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
6
|
-
|
|
7
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
2
|
|
|
9
3
|
/* eslint-disable no-underscore-dangle */
|
|
10
|
-
import { ContextActionUtils } from
|
|
4
|
+
import { ContextActionUtils } from "../context-actions/index.js";
|
|
11
5
|
export var MODIFIER; // The value should match the KeyboardEvent.key value
|
|
12
6
|
// This is the value which will be displayed if no display overrides are done in the OS specific getDisplayString methods
|
|
13
7
|
|
|
@@ -98,17 +92,213 @@ export var KEY;
|
|
|
98
92
|
KEY["F12"] = "F12";
|
|
99
93
|
})(KEY || (KEY = {}));
|
|
100
94
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
95
|
+
export default class Shortcut {
|
|
96
|
+
// Unique identifier for the shortcut
|
|
97
|
+
// e.g. Rename, Save, Run Selected
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Use to check if a keyCode corresponds to an allowed key for a shortcut
|
|
101
|
+
* @param keyCode The keyCode to check. This should be the charCode of the key
|
|
102
|
+
* @returns Type predicate asserting the key is an allowed KEY
|
|
103
|
+
*/
|
|
104
|
+
static isAllowedKey(key) {
|
|
105
|
+
return Object.values(KEY).includes(key);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Checks if a KeyState has a valid key.
|
|
109
|
+
* @param state KeyState with any string as the key
|
|
110
|
+
* @returns True if KeyState is is using an allowed keyCode
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
static isValidKeyState(state) {
|
|
115
|
+
return state.keyValue === null || Shortcut.isAllowedKey(state.keyValue) && (Shortcut.isMacPlatform || !state.metaKey) && ( // MetaKey not allowed in windows
|
|
116
|
+
state.altKey || state.ctrlKey || state.metaKey || state.shiftKey || state.keyValue === KEY.ENTER || state.keyValue === KEY.DELETE);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Creates a KeyState from a valid array of modifier and key constants
|
|
121
|
+
* @param keys Array of keys in the shortcut. Modifiers first and key last. Should use the MODIFIER and KEY enums
|
|
122
|
+
* @returns KeyState representing the array of constants
|
|
123
|
+
*/
|
|
124
|
+
static createKeyState(keys) {
|
|
125
|
+
var keyState = {
|
|
126
|
+
altKey: false,
|
|
127
|
+
ctrlKey: false,
|
|
128
|
+
metaKey: false,
|
|
129
|
+
shiftKey: false,
|
|
130
|
+
keyValue: keys[keys.length - 1]
|
|
131
|
+
};
|
|
132
|
+
keys.forEach(key => {
|
|
133
|
+
switch (key) {
|
|
134
|
+
case MODIFIER.CTRL:
|
|
135
|
+
keyState.ctrlKey = true;
|
|
136
|
+
break;
|
|
137
|
+
|
|
138
|
+
case MODIFIER.ALT:
|
|
139
|
+
case MODIFIER.OPTION:
|
|
140
|
+
keyState.altKey = true;
|
|
141
|
+
break;
|
|
142
|
+
|
|
143
|
+
case MODIFIER.CMD:
|
|
144
|
+
keyState.metaKey = true;
|
|
145
|
+
break;
|
|
146
|
+
|
|
147
|
+
case MODIFIER.SHIFT:
|
|
148
|
+
keyState.shiftKey = true;
|
|
149
|
+
break;
|
|
150
|
+
|
|
151
|
+
default:
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
return keyState;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static getKeyStateFromEvent(e) {
|
|
159
|
+
var {
|
|
160
|
+
key: eventKey,
|
|
161
|
+
keyCode
|
|
162
|
+
} = e;
|
|
163
|
+
var key = '';
|
|
164
|
+
|
|
165
|
+
if (eventKey === 'Shift' || eventKey === 'Meta' || eventKey === 'Control' || eventKey === 'Alt') {
|
|
166
|
+
key = '';
|
|
167
|
+
} else if (!Shortcut.isAllowedKey(eventKey) && Shortcut.isAllowedKey(String.fromCharCode(keyCode))) {
|
|
168
|
+
key = String.fromCharCode(keyCode);
|
|
169
|
+
} else {
|
|
170
|
+
key = eventKey;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
keyValue: key,
|
|
175
|
+
altKey: e.altKey,
|
|
176
|
+
ctrlKey: e.ctrlKey,
|
|
177
|
+
metaKey: e.metaKey,
|
|
178
|
+
shiftKey: e.shiftKey
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Gets display string for Windows (and Linux + any other non-Mac OS)
|
|
183
|
+
* If the key is not an allowed key, the display will only display the modifiers
|
|
184
|
+
* @param keyState KeyState to get the display for
|
|
185
|
+
* @returns The string to display on Windows/non-Mac OS
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
static getWindowsDisplayText(keyState) {
|
|
190
|
+
var display = '';
|
|
191
|
+
|
|
192
|
+
if (keyState.ctrlKey) {
|
|
193
|
+
display += 'Ctrl+';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (keyState.altKey) {
|
|
197
|
+
display += 'Alt+';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (keyState.shiftKey) {
|
|
201
|
+
display += 'Shift+';
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (keyState.keyValue === KEY.ESCAPE) {
|
|
205
|
+
display += 'Esc';
|
|
206
|
+
} else if (keyState.keyValue !== null) {
|
|
207
|
+
display += keyState.keyValue;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return display;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Gets display string Mac OS
|
|
214
|
+
* If the key is not an allowed key, the display will only display the modifiers
|
|
215
|
+
* @param keyState KeyState to get the display for
|
|
216
|
+
* @returns The string to display on Mac OS
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
static getMacDisplayText(keyState) {
|
|
221
|
+
var display = '';
|
|
222
|
+
|
|
223
|
+
if (keyState.ctrlKey) {
|
|
224
|
+
display += '⌃';
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (keyState.altKey) {
|
|
228
|
+
display += '⌥';
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (keyState.shiftKey) {
|
|
232
|
+
display += '⇧';
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (keyState.metaKey) {
|
|
236
|
+
display += '⌘';
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
switch (keyState.keyValue) {
|
|
240
|
+
case KEY.ENTER:
|
|
241
|
+
display += '⏎';
|
|
242
|
+
break;
|
|
243
|
+
|
|
244
|
+
case KEY.ESCAPE:
|
|
245
|
+
display += '⎋';
|
|
246
|
+
break;
|
|
247
|
+
|
|
248
|
+
case KEY.BACKSPACE:
|
|
249
|
+
display += '⌫';
|
|
250
|
+
break;
|
|
251
|
+
|
|
252
|
+
case KEY.DELETE:
|
|
253
|
+
display += '⌦';
|
|
254
|
+
break;
|
|
255
|
+
|
|
256
|
+
case null:
|
|
257
|
+
break;
|
|
258
|
+
|
|
259
|
+
default:
|
|
260
|
+
display += keyState.keyValue;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return display;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Checks if 2 KeyStates match
|
|
267
|
+
* @param state1 First KeyState to compare
|
|
268
|
+
* @param state2 Second KeyState to compare
|
|
269
|
+
* @returns True if the KeyStates match and have non-null keyValues
|
|
270
|
+
*/
|
|
271
|
+
|
|
110
272
|
|
|
111
|
-
|
|
273
|
+
static doKeyStatesMatch(state1, state2) {
|
|
274
|
+
var _state1$keyValue, _state2$keyValue;
|
|
275
|
+
|
|
276
|
+
return ((_state1$keyValue = state1.keyValue) === null || _state1$keyValue === void 0 ? void 0 : _state1$keyValue.toUpperCase()) === ((_state2$keyValue = state2.keyValue) === null || _state2$keyValue === void 0 ? void 0 : _state2$keyValue.toUpperCase()) && state1.altKey === state2.altKey && state1.ctrlKey === state2.ctrlKey && state1.metaKey === state2.metaKey && state1.shiftKey === state2.shiftKey;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Gets the display string for the current OS from a KeyState.
|
|
280
|
+
* @param keyState KeyState to get the display for
|
|
281
|
+
* @returns Display string for the current OS
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
static getDisplayText(keyState) {
|
|
286
|
+
if (keyState.keyValue === null) {
|
|
287
|
+
return '';
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return Shortcut.isMacPlatform ? Shortcut.getMacDisplayText(keyState) : Shortcut.getWindowsDisplayText(keyState);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
constructor(_ref) {
|
|
294
|
+
var {
|
|
295
|
+
id,
|
|
296
|
+
shortcut,
|
|
297
|
+
macShortcut,
|
|
298
|
+
isEditable = true,
|
|
299
|
+
name,
|
|
300
|
+
tooltip
|
|
301
|
+
} = _ref;
|
|
112
302
|
|
|
113
303
|
_defineProperty(this, "id", void 0);
|
|
114
304
|
|
|
@@ -136,295 +326,79 @@ var Shortcut = /*#__PURE__*/function () {
|
|
|
136
326
|
*/
|
|
137
327
|
|
|
138
328
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* Gets the current keyState for the Shortcut
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
}, {
|
|
149
|
-
key: "getKeyState",
|
|
150
|
-
value: function getKeyState() {
|
|
151
|
-
return this.keyState;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Sets the KeyState if it is valid
|
|
155
|
-
* @param keyState
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
}, {
|
|
159
|
-
key: "setKeyState",
|
|
160
|
-
value: function setKeyState(keyState) {
|
|
161
|
-
if (Shortcut.isValidKeyState(keyState)) {
|
|
162
|
-
this.keyState = keyState;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Gets the default key state of the shortcut
|
|
167
|
-
* @returns Default key state
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
}, {
|
|
171
|
-
key: "getDefaultKeyState",
|
|
172
|
-
value: function getDefaultKeyState() {
|
|
173
|
-
return this.defaultKeyState;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Sets the shortcut to have null keyValue
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
}, {
|
|
180
|
-
key: "setToNull",
|
|
181
|
-
value: function setToNull() {
|
|
182
|
-
this.setKeyState(Shortcut.NULL_KEY_STATE);
|
|
183
|
-
}
|
|
184
|
-
}, {
|
|
185
|
-
key: "isNull",
|
|
186
|
-
value: function isNull() {
|
|
187
|
-
return Shortcut.doKeyStatesMatch(this.keyState, Shortcut.NULL_KEY_STATE);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Sets the shortcut to its default key state
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
}, {
|
|
194
|
-
key: "setToDefault",
|
|
195
|
-
value: function setToDefault() {
|
|
196
|
-
this.setKeyState(this.defaultKeyState);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Checks if a KeyState matches the KeyState for the shortcut
|
|
200
|
-
* @param keyState KeyState to check
|
|
201
|
-
* @returns True if the passed KeyState matches the Shortcut's KeyState
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
}, {
|
|
205
|
-
key: "matchesKeyState",
|
|
206
|
-
value: function matchesKeyState(keyState) {
|
|
207
|
-
return Shortcut.doKeyStatesMatch(keyState, this.keyState);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Alias for matchesKeyState
|
|
211
|
-
* @param e KeyboardEvent to check if the Shortcut matches
|
|
212
|
-
* @returns True if the event matches the Shortcut's KeyState
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
|
-
}, {
|
|
216
|
-
key: "matchesEvent",
|
|
217
|
-
value: function matchesEvent(e) {
|
|
218
|
-
return this.matchesKeyState(Shortcut.getKeyStateFromEvent(e));
|
|
219
|
-
}
|
|
220
|
-
}], [{
|
|
221
|
-
key: "isAllowedKey",
|
|
222
|
-
value: // Unique identifier for the shortcut
|
|
223
|
-
// e.g. Rename, Save, Run Selected
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Use to check if a keyCode corresponds to an allowed key for a shortcut
|
|
227
|
-
* @param keyCode The keyCode to check. This should be the charCode of the key
|
|
228
|
-
* @returns Type predicate asserting the key is an allowed KEY
|
|
229
|
-
*/
|
|
230
|
-
function isAllowedKey(key) {
|
|
231
|
-
return Object.values(KEY).includes(key);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Checks if a KeyState has a valid key.
|
|
235
|
-
* @param state KeyState with any string as the key
|
|
236
|
-
* @returns True if KeyState is is using an allowed keyCode
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
}, {
|
|
240
|
-
key: "isValidKeyState",
|
|
241
|
-
value: function isValidKeyState(state) {
|
|
242
|
-
return state.keyValue === null || Shortcut.isAllowedKey(state.keyValue) && (Shortcut.isMacPlatform || !state.metaKey) && ( // MetaKey not allowed in windows
|
|
243
|
-
state.altKey || state.ctrlKey || state.metaKey || state.shiftKey || state.keyValue === KEY.ENTER || state.keyValue === KEY.DELETE);
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "createKeyState",
|
|
247
|
-
value:
|
|
248
|
-
/**
|
|
249
|
-
* Creates a KeyState from a valid array of modifier and key constants
|
|
250
|
-
* @param keys Array of keys in the shortcut. Modifiers first and key last. Should use the MODIFIER and KEY enums
|
|
251
|
-
* @returns KeyState representing the array of constants
|
|
252
|
-
*/
|
|
253
|
-
function createKeyState(keys) {
|
|
254
|
-
var keyState = {
|
|
255
|
-
altKey: false,
|
|
256
|
-
ctrlKey: false,
|
|
257
|
-
metaKey: false,
|
|
258
|
-
shiftKey: false,
|
|
259
|
-
keyValue: keys[keys.length - 1]
|
|
260
|
-
};
|
|
261
|
-
keys.forEach(function (key) {
|
|
262
|
-
switch (key) {
|
|
263
|
-
case MODIFIER.CTRL:
|
|
264
|
-
keyState.ctrlKey = true;
|
|
265
|
-
break;
|
|
266
|
-
|
|
267
|
-
case MODIFIER.ALT:
|
|
268
|
-
case MODIFIER.OPTION:
|
|
269
|
-
keyState.altKey = true;
|
|
270
|
-
break;
|
|
271
|
-
|
|
272
|
-
case MODIFIER.CMD:
|
|
273
|
-
keyState.metaKey = true;
|
|
274
|
-
break;
|
|
275
|
-
|
|
276
|
-
case MODIFIER.SHIFT:
|
|
277
|
-
keyState.shiftKey = true;
|
|
278
|
-
break;
|
|
279
|
-
|
|
280
|
-
default:
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
return keyState;
|
|
285
|
-
}
|
|
286
|
-
}, {
|
|
287
|
-
key: "getKeyStateFromEvent",
|
|
288
|
-
value: function getKeyStateFromEvent(e) {
|
|
289
|
-
var eventKey = e.key,
|
|
290
|
-
keyCode = e.keyCode;
|
|
291
|
-
var key = '';
|
|
292
|
-
|
|
293
|
-
if (eventKey === 'Shift' || eventKey === 'Meta' || eventKey === 'Control' || eventKey === 'Alt') {
|
|
294
|
-
key = '';
|
|
295
|
-
} else if (!Shortcut.isAllowedKey(eventKey) && Shortcut.isAllowedKey(String.fromCharCode(keyCode))) {
|
|
296
|
-
key = String.fromCharCode(keyCode);
|
|
297
|
-
} else {
|
|
298
|
-
key = eventKey;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return {
|
|
302
|
-
keyValue: key,
|
|
303
|
-
altKey: e.altKey,
|
|
304
|
-
ctrlKey: e.ctrlKey,
|
|
305
|
-
metaKey: e.metaKey,
|
|
306
|
-
shiftKey: e.shiftKey
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Gets display string for Windows (and Linux + any other non-Mac OS)
|
|
311
|
-
* If the key is not an allowed key, the display will only display the modifiers
|
|
312
|
-
* @param keyState KeyState to get the display for
|
|
313
|
-
* @returns The string to display on Windows/non-Mac OS
|
|
314
|
-
*/
|
|
315
|
-
|
|
316
|
-
}, {
|
|
317
|
-
key: "getWindowsDisplayText",
|
|
318
|
-
value: function getWindowsDisplayText(keyState) {
|
|
319
|
-
var display = '';
|
|
320
|
-
|
|
321
|
-
if (keyState.ctrlKey) {
|
|
322
|
-
display += 'Ctrl+';
|
|
323
|
-
}
|
|
329
|
+
getDisplayText() {
|
|
330
|
+
return Shortcut.getDisplayText(this.keyState);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Gets the current keyState for the Shortcut
|
|
334
|
+
*/
|
|
324
335
|
|
|
325
|
-
if (keyState.altKey) {
|
|
326
|
-
display += 'Alt+';
|
|
327
|
-
}
|
|
328
336
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
337
|
+
getKeyState() {
|
|
338
|
+
return this.keyState;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Sets the KeyState if it is valid
|
|
342
|
+
* @param keyState
|
|
343
|
+
*/
|
|
332
344
|
|
|
333
|
-
if (keyState.keyValue === KEY.ESCAPE) {
|
|
334
|
-
display += 'Esc';
|
|
335
|
-
} else if (keyState.keyValue !== null) {
|
|
336
|
-
display += keyState.keyValue;
|
|
337
|
-
}
|
|
338
345
|
|
|
339
|
-
|
|
346
|
+
setKeyState(keyState) {
|
|
347
|
+
if (Shortcut.isValidKeyState(keyState)) {
|
|
348
|
+
this.keyState = keyState;
|
|
340
349
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
*/
|
|
347
|
-
|
|
348
|
-
}, {
|
|
349
|
-
key: "getMacDisplayText",
|
|
350
|
-
value: function getMacDisplayText(keyState) {
|
|
351
|
-
var display = '';
|
|
352
|
-
|
|
353
|
-
if (keyState.ctrlKey) {
|
|
354
|
-
display += '⌃';
|
|
355
|
-
}
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Gets the default key state of the shortcut
|
|
353
|
+
* @returns Default key state
|
|
354
|
+
*/
|
|
356
355
|
|
|
357
|
-
if (keyState.altKey) {
|
|
358
|
-
display += '⌥';
|
|
359
|
-
}
|
|
360
356
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
357
|
+
getDefaultKeyState() {
|
|
358
|
+
return this.defaultKeyState;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Sets the shortcut to have null keyValue
|
|
362
|
+
*/
|
|
364
363
|
|
|
365
|
-
if (keyState.metaKey) {
|
|
366
|
-
display += '⌘';
|
|
367
|
-
}
|
|
368
364
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
break;
|
|
365
|
+
setToNull() {
|
|
366
|
+
this.setKeyState(Shortcut.NULL_KEY_STATE);
|
|
367
|
+
}
|
|
373
368
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
369
|
+
isNull() {
|
|
370
|
+
return Shortcut.doKeyStatesMatch(this.keyState, Shortcut.NULL_KEY_STATE);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Sets the shortcut to its default key state
|
|
374
|
+
*/
|
|
377
375
|
|
|
378
|
-
case KEY.BACKSPACE:
|
|
379
|
-
display += '⌫';
|
|
380
|
-
break;
|
|
381
376
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
377
|
+
setToDefault() {
|
|
378
|
+
this.setKeyState(this.defaultKeyState);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Checks if a KeyState matches the KeyState for the shortcut
|
|
382
|
+
* @param keyState KeyState to check
|
|
383
|
+
* @returns True if the passed KeyState matches the Shortcut's KeyState
|
|
384
|
+
*/
|
|
385
385
|
|
|
386
|
-
case null:
|
|
387
|
-
break;
|
|
388
386
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
387
|
+
matchesKeyState(keyState) {
|
|
388
|
+
return Shortcut.doKeyStatesMatch(keyState, this.keyState);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Alias for matchesKeyState
|
|
392
|
+
* @param e KeyboardEvent to check if the Shortcut matches
|
|
393
|
+
* @returns True if the event matches the Shortcut's KeyState
|
|
394
|
+
*/
|
|
392
395
|
|
|
393
|
-
return display;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Checks if 2 KeyStates match
|
|
397
|
-
* @param state1 First KeyState to compare
|
|
398
|
-
* @param state2 Second KeyState to compare
|
|
399
|
-
* @returns True if the KeyStates match and have non-null keyValues
|
|
400
|
-
*/
|
|
401
|
-
|
|
402
|
-
}, {
|
|
403
|
-
key: "doKeyStatesMatch",
|
|
404
|
-
value: function doKeyStatesMatch(state1, state2) {
|
|
405
|
-
var _state1$keyValue, _state2$keyValue;
|
|
406
|
-
|
|
407
|
-
return ((_state1$keyValue = state1.keyValue) === null || _state1$keyValue === void 0 ? void 0 : _state1$keyValue.toUpperCase()) === ((_state2$keyValue = state2.keyValue) === null || _state2$keyValue === void 0 ? void 0 : _state2$keyValue.toUpperCase()) && state1.altKey === state2.altKey && state1.ctrlKey === state2.ctrlKey && state1.metaKey === state2.metaKey && state1.shiftKey === state2.shiftKey;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* Gets the display string for the current OS from a KeyState.
|
|
411
|
-
* @param keyState KeyState to get the display for
|
|
412
|
-
* @returns Display string for the current OS
|
|
413
|
-
*/
|
|
414
|
-
|
|
415
|
-
}, {
|
|
416
|
-
key: "getDisplayText",
|
|
417
|
-
value: function getDisplayText(keyState) {
|
|
418
|
-
if (keyState.keyValue === null) {
|
|
419
|
-
return '';
|
|
420
|
-
}
|
|
421
396
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
397
|
+
matchesEvent(e) {
|
|
398
|
+
return this.matchesKeyState(Shortcut.getKeyStateFromEvent(e));
|
|
399
|
+
}
|
|
425
400
|
|
|
426
|
-
|
|
427
|
-
}();
|
|
401
|
+
}
|
|
428
402
|
|
|
429
403
|
_defineProperty(Shortcut, "NULL_KEY_STATE", {
|
|
430
404
|
metaKey: false,
|
|
@@ -435,6 +409,4 @@ _defineProperty(Shortcut, "NULL_KEY_STATE", {
|
|
|
435
409
|
});
|
|
436
410
|
|
|
437
411
|
_defineProperty(Shortcut, "isMacPlatform", ContextActionUtils.isMacPlatform());
|
|
438
|
-
|
|
439
|
-
export { Shortcut as default };
|
|
440
412
|
//# sourceMappingURL=Shortcut.js.map
|