@genesislcap/foundation-utils 14.422.2-alpha-0a3f40b.0 → 14.423.0
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/custom-elements.json +5 -461
- package/dist/dts/design-system/index.d.ts +0 -1
- package/dist/dts/design-system/index.d.ts.map +1 -1
- package/dist/dts/shortcut-manager/index.d.ts +0 -1
- package/dist/dts/shortcut-manager/index.d.ts.map +1 -1
- package/dist/dts/shortcut-manager/shortcut-listener.d.ts +1 -3
- package/dist/dts/shortcut-manager/shortcut-listener.d.ts.map +1 -1
- package/dist/dts/shortcut-manager/shortcut-manager.d.ts +4 -54
- package/dist/dts/shortcut-manager/shortcut-manager.d.ts.map +1 -1
- package/dist/esm/design-system/index.js +0 -1
- package/dist/esm/shortcut-manager/index.js +0 -1
- package/dist/esm/shortcut-manager/shortcut-listener.js +37 -49
- package/dist/esm/shortcut-manager/shortcut-manager.js +22 -114
- package/dist/foundation-utils.api.json +30 -1325
- package/dist/foundation-utils.d.ts +5 -96
- package/package.json +11 -11
- package/dist/dts/design-system/editable-elements.d.ts +0 -12
- package/dist/dts/design-system/editable-elements.d.ts.map +0 -1
- package/dist/dts/shortcut-manager/shortcut-events.d.ts +0 -16
- package/dist/dts/shortcut-manager/shortcut-events.d.ts.map +0 -1
- package/dist/esm/design-system/editable-elements.js +0 -42
- package/dist/esm/shortcut-manager/shortcut-events.js +0 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shortcut-manager.d.ts","sourceRoot":"","sources":["../../../src/shortcut-manager/shortcut-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"shortcut-manager.d.ts","sourceRoot":"","sources":["../../../src/shortcut-manager/shortcut-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIn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import { customElement, FASTElement } from '@microsoft/fast-element';
|
|
3
3
|
import { inject } from '@microsoft/fast-foundation';
|
|
4
|
-
import { emitShortcutBlockedEvent } from './shortcut-events';
|
|
5
4
|
import { ShortcutManager } from './shortcut-manager';
|
|
6
5
|
/**
|
|
7
6
|
* A custom element that listens for keyboard shortcuts.
|
|
@@ -16,12 +15,27 @@ let FoundationShortcutListener = class FoundationShortcutListener extends FASTEl
|
|
|
16
15
|
}
|
|
17
16
|
connectedCallback() {
|
|
18
17
|
super.connectedCallback();
|
|
19
|
-
this.
|
|
18
|
+
this.setupStateSubscription();
|
|
20
19
|
}
|
|
21
20
|
disconnectedCallback() {
|
|
22
21
|
super.disconnectedCallback();
|
|
23
22
|
this.removeKeyListener();
|
|
24
23
|
}
|
|
24
|
+
setupStateSubscription() {
|
|
25
|
+
// Subscribe to the pause state changes
|
|
26
|
+
this.shortcutManager.isPaused$.subscribe((isPaused) => {
|
|
27
|
+
if (isPaused) {
|
|
28
|
+
this.removeKeyListener();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.addKeyListener();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
// Set initial state
|
|
35
|
+
if (!this.shortcutManager.isPaused) {
|
|
36
|
+
this.addKeyListener();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
25
39
|
addKeyListener() {
|
|
26
40
|
if (this.isListening)
|
|
27
41
|
return;
|
|
@@ -37,34 +51,21 @@ let FoundationShortcutListener = class FoundationShortcutListener extends FASTEl
|
|
|
37
51
|
this.isListening = false;
|
|
38
52
|
}
|
|
39
53
|
handleKeyDown(event) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const blockedMessages = manager.getBlockedMessages();
|
|
43
|
-
const editableSelector = manager.getEditableSelector();
|
|
44
|
-
const eventTarget = (_a = this.getEventElement(event)) !== null && _a !== void 0 ? _a : this;
|
|
45
|
-
const hasModifier = event.ctrlKey || event.altKey || event.shiftKey || event.metaKey;
|
|
46
|
-
// Extract key from event.code with proper mapping for all key types
|
|
47
|
-
const key = this.extractKeyFromCode(event.code);
|
|
48
|
-
const shortcut = manager.findShortcutByKeyCombination(key, event.ctrlKey, event.altKey, event.shiftKey, event.metaKey);
|
|
49
|
-
if (!shortcut) {
|
|
54
|
+
// Don't handle shortcuts if the service is paused
|
|
55
|
+
if (this.shortcutManager.isPaused) {
|
|
50
56
|
return;
|
|
51
57
|
}
|
|
52
|
-
// Don't handle shortcuts
|
|
53
|
-
if (this.
|
|
54
|
-
if (hasModifier) {
|
|
55
|
-
emitShortcutBlockedEvent({
|
|
56
|
-
shortcutId: shortcut.id,
|
|
57
|
-
context: shortcut.context,
|
|
58
|
-
reason: 'editable-context',
|
|
59
|
-
message: blockedMessages.inputMessage,
|
|
60
|
-
}, eventTarget);
|
|
61
|
-
}
|
|
58
|
+
// Don't handle shortcuts if user is typing in an input field
|
|
59
|
+
if (this.isInputElement(event.target)) {
|
|
62
60
|
return;
|
|
63
61
|
}
|
|
62
|
+
// Extract key from event.code with proper mapping for all key types
|
|
63
|
+
const key = this.extractKeyFromCode(event.code);
|
|
64
|
+
const shortcut = this.shortcutManager.findShortcutByKeyCombination(key, event.ctrlKey, event.altKey, event.shiftKey, event.metaKey);
|
|
64
65
|
if (shortcut) {
|
|
65
66
|
event.preventDefault();
|
|
66
67
|
event.stopPropagation();
|
|
67
|
-
|
|
68
|
+
this.shortcutManager.executeShortcut(shortcut.id);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
extractKeyFromCode(code) {
|
|
@@ -108,37 +109,24 @@ let FoundationShortcutListener = class FoundationShortcutListener extends FASTEl
|
|
|
108
109
|
};
|
|
109
110
|
return specialKeyMap[code] || code.toLowerCase();
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
isInputElement(element) {
|
|
113
|
+
if (!element)
|
|
114
|
+
return false;
|
|
115
|
+
const inputTypes = ['input', 'textarea', 'select'];
|
|
116
|
+
const tagName = element.tagName.toLowerCase();
|
|
117
|
+
if (inputTypes.includes(tagName)) {
|
|
118
|
+
return true;
|
|
116
119
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
getEventElement(event) {
|
|
120
|
-
var _a, _b, _c;
|
|
121
|
-
const path = (_b = (_a = event.composedPath) === null || _a === void 0 ? void 0 : _a.call(event)) !== null && _b !== void 0 ? _b : [];
|
|
122
|
-
const fromPath = path.find((entry) => entry instanceof Element);
|
|
123
|
-
return (_c = fromPath !== null && fromPath !== void 0 ? fromPath : event.target) !== null && _c !== void 0 ? _c : null;
|
|
124
|
-
}
|
|
125
|
-
isEditableContext(event, editableSelector) {
|
|
126
|
-
const eventElement = this.getEventElement(event);
|
|
127
|
-
if (eventElement && this.isInputElement(eventElement, editableSelector)) {
|
|
120
|
+
// Check for contenteditable
|
|
121
|
+
if (element.contentEditable === 'true') {
|
|
128
122
|
return true;
|
|
129
123
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (!element)
|
|
134
|
-
return false;
|
|
135
|
-
const isEditableContent = (value) => value !== null && value !== undefined && value.toLowerCase() !== 'false';
|
|
136
|
-
if (isEditableContent(element.getAttribute('contenteditable')) || element.isContentEditable) {
|
|
124
|
+
// Check for role="textbox" or similar
|
|
125
|
+
const role = element.getAttribute('role');
|
|
126
|
+
if (role && ['textbox', 'searchbox', 'combobox'].includes(role)) {
|
|
137
127
|
return true;
|
|
138
128
|
}
|
|
139
|
-
|
|
140
|
-
return false;
|
|
141
|
-
return element.matches(editableSelector) || !!element.closest(editableSelector);
|
|
129
|
+
return false;
|
|
142
130
|
}
|
|
143
131
|
};
|
|
144
132
|
__decorate([
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { DI } from '@microsoft/fast-foundation';
|
|
2
2
|
import { BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { buildEditableElementSelector } from '../design-system/editable-elements';
|
|
4
3
|
import { logger } from '../utils';
|
|
5
4
|
import { OperatingSystemUtils } from '../utils/os-platform';
|
|
6
|
-
import { SHORTCUT_BLOCKED_DEFAULT_MESSAGE, SHORTCUT_BLOCKED_INPUT_MESSAGE, SHORTCUT_BLOCKED_ELEMENT_FOCUS_MESSAGE, SHORTCUT_BLOCKED_PAUSED_MESSAGE, emitShortcutBlockedEvent, } from './shortcut-events';
|
|
7
|
-
const DEFAULT_SHORTCUT_EDITABLE_CONTEXT_CONFIG = {
|
|
8
|
-
designSystems: ['rapid'],
|
|
9
|
-
customEditableSelectors: [],
|
|
10
|
-
};
|
|
11
|
-
const DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG = {
|
|
12
|
-
defaultMessage: SHORTCUT_BLOCKED_DEFAULT_MESSAGE,
|
|
13
|
-
inputMessage: SHORTCUT_BLOCKED_INPUT_MESSAGE,
|
|
14
|
-
pausedMessage: SHORTCUT_BLOCKED_PAUSED_MESSAGE,
|
|
15
|
-
elementFocusMessage: SHORTCUT_BLOCKED_ELEMENT_FOCUS_MESSAGE,
|
|
16
|
-
};
|
|
17
5
|
/**
|
|
18
6
|
* Default implementation of the ShortcutManager interface
|
|
19
7
|
* @public
|
|
@@ -24,10 +12,6 @@ export class DefaultShortcutManager {
|
|
|
24
12
|
this.shortcutLookup = new Map(); // context:id -> ShortcutDefinition for quick lookups
|
|
25
13
|
this.keyCombinationMap = new Map(); // key combination -> set of "context:id" strings
|
|
26
14
|
this._isPausedSubject = new BehaviorSubject(false);
|
|
27
|
-
this.executionGuards = new Map();
|
|
28
|
-
this.editableContextConfig = Object.assign({}, DEFAULT_SHORTCUT_EDITABLE_CONTEXT_CONFIG);
|
|
29
|
-
this.editableSelector = buildEditableElementSelector(DEFAULT_SHORTCUT_EDITABLE_CONTEXT_CONFIG.designSystems, DEFAULT_SHORTCUT_EDITABLE_CONTEXT_CONFIG.customEditableSelectors);
|
|
30
|
-
this.blockedMessageConfig = Object.assign({}, DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG);
|
|
31
15
|
}
|
|
32
16
|
get isPaused() {
|
|
33
17
|
return this._isPausedSubject.value;
|
|
@@ -104,12 +88,22 @@ export class DefaultShortcutManager {
|
|
|
104
88
|
keyCombinationDisplay,
|
|
105
89
|
// Functions that can be directly used in AG Grid menu items
|
|
106
90
|
disabled: () => {
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
if (this.isPaused)
|
|
92
|
+
return true;
|
|
93
|
+
if (normalizedShortcut.canExecute) {
|
|
94
|
+
const status = normalizedShortcut.canExecute();
|
|
95
|
+
return status.disabled || false;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
109
98
|
},
|
|
110
99
|
tooltip: () => {
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
if (this.isPaused)
|
|
101
|
+
return 'Shortcuts are paused';
|
|
102
|
+
if (normalizedShortcut.canExecute) {
|
|
103
|
+
const status = normalizedShortcut.canExecute();
|
|
104
|
+
return status.tooltip;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
113
107
|
},
|
|
114
108
|
};
|
|
115
109
|
}
|
|
@@ -147,17 +141,11 @@ export class DefaultShortcutManager {
|
|
|
147
141
|
shortcutIds.forEach((id) => this.unregisterShortcut(context, id));
|
|
148
142
|
}
|
|
149
143
|
}
|
|
150
|
-
executeShortcut(id
|
|
151
|
-
this.executeShortcutByContext(this.getActiveContext(), id
|
|
144
|
+
executeShortcut(id) {
|
|
145
|
+
this.executeShortcutByContext(this.getActiveContext(), id);
|
|
152
146
|
}
|
|
153
|
-
executeShortcutByContext(context, id
|
|
147
|
+
executeShortcutByContext(context, id) {
|
|
154
148
|
if (this.isPaused) {
|
|
155
|
-
emitShortcutBlockedEvent({
|
|
156
|
-
shortcutId: id,
|
|
157
|
-
context,
|
|
158
|
-
reason: 'paused',
|
|
159
|
-
message: this.blockedMessageConfig.pausedMessage,
|
|
160
|
-
}, eventTarget);
|
|
161
149
|
return; // Don't execute shortcuts when paused
|
|
162
150
|
}
|
|
163
151
|
const contextMap = this.shortcuts.get(context);
|
|
@@ -166,24 +154,14 @@ export class DefaultShortcutManager {
|
|
|
166
154
|
if (shortcut) {
|
|
167
155
|
// Check if shortcut requires a specific element to be focused
|
|
168
156
|
if (shortcut.elementRef && !this.isElementFocused(shortcut.elementRef)) {
|
|
169
|
-
emitShortcutBlockedEvent({
|
|
170
|
-
shortcutId: id,
|
|
171
|
-
context,
|
|
172
|
-
reason: 'element-not-focused',
|
|
173
|
-
message: this.blockedMessageConfig.elementFocusMessage,
|
|
174
|
-
}, eventTarget);
|
|
175
157
|
return; // Don't execute if the required element is not focused
|
|
176
158
|
}
|
|
177
159
|
// Check if shortcut can be executed
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
reason: 'disabled',
|
|
184
|
-
message: executionStatus.tooltip || this.blockedMessageConfig.defaultMessage,
|
|
185
|
-
}, eventTarget);
|
|
186
|
-
return; // Don't execute if disabled
|
|
160
|
+
if (shortcut.canExecute) {
|
|
161
|
+
const executionStatus = shortcut.canExecute();
|
|
162
|
+
if (executionStatus.disabled) {
|
|
163
|
+
return; // Don't execute if disabled
|
|
164
|
+
}
|
|
187
165
|
}
|
|
188
166
|
try {
|
|
189
167
|
shortcut.action();
|
|
@@ -261,50 +239,6 @@ export class DefaultShortcutManager {
|
|
|
261
239
|
clearActiveContext() {
|
|
262
240
|
this._activeContext = undefined;
|
|
263
241
|
}
|
|
264
|
-
registerExecutionGuard(id, guard) {
|
|
265
|
-
this.executionGuards.set(id, guard);
|
|
266
|
-
}
|
|
267
|
-
unregisterExecutionGuard(id) {
|
|
268
|
-
this.executionGuards.delete(id);
|
|
269
|
-
}
|
|
270
|
-
clearExecutionGuards() {
|
|
271
|
-
this.executionGuards.clear();
|
|
272
|
-
}
|
|
273
|
-
configureEditableContext(config = {}) {
|
|
274
|
-
var _a, _b;
|
|
275
|
-
const nextDesignSystems = ((_a = config.designSystems) !== null && _a !== void 0 ? _a : DEFAULT_SHORTCUT_EDITABLE_CONTEXT_CONFIG.designSystems).filter((value) => value === 'rapid' || value === 'zero');
|
|
276
|
-
const nextCustomSelectors = ((_b = config.customEditableSelectors) !== null && _b !== void 0 ? _b : DEFAULT_SHORTCUT_EDITABLE_CONTEXT_CONFIG.customEditableSelectors)
|
|
277
|
-
.map((value) => value === null || value === void 0 ? void 0 : value.trim())
|
|
278
|
-
.filter((value) => !!value);
|
|
279
|
-
this.editableContextConfig = {
|
|
280
|
-
designSystems: Array.from(new Set(config.designSystems !== undefined
|
|
281
|
-
? nextDesignSystems
|
|
282
|
-
: DEFAULT_SHORTCUT_EDITABLE_CONTEXT_CONFIG.designSystems)),
|
|
283
|
-
customEditableSelectors: Array.from(new Set(nextCustomSelectors)),
|
|
284
|
-
};
|
|
285
|
-
this.refreshEditableSelector();
|
|
286
|
-
}
|
|
287
|
-
getEditableContextConfig() {
|
|
288
|
-
return {
|
|
289
|
-
designSystems: [...this.editableContextConfig.designSystems],
|
|
290
|
-
customEditableSelectors: [...this.editableContextConfig.customEditableSelectors],
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
getEditableSelector() {
|
|
294
|
-
return this.editableSelector;
|
|
295
|
-
}
|
|
296
|
-
configureBlockedMessages(config = {}) {
|
|
297
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
298
|
-
this.blockedMessageConfig = {
|
|
299
|
-
defaultMessage: (_b = (_a = config.defaultMessage) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.defaultMessage,
|
|
300
|
-
inputMessage: (_d = (_c = config.inputMessage) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.inputMessage,
|
|
301
|
-
pausedMessage: (_f = (_e = config.pausedMessage) === null || _e === void 0 ? void 0 : _e.trim()) !== null && _f !== void 0 ? _f : DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.pausedMessage,
|
|
302
|
-
elementFocusMessage: (_h = (_g = config.elementFocusMessage) === null || _g === void 0 ? void 0 : _g.trim()) !== null && _h !== void 0 ? _h : DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.elementFocusMessage,
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
getBlockedMessages() {
|
|
306
|
-
return Object.assign({}, this.blockedMessageConfig);
|
|
307
|
-
}
|
|
308
242
|
pause() {
|
|
309
243
|
this._isPausedSubject.next(true);
|
|
310
244
|
}
|
|
@@ -344,32 +278,6 @@ export class DefaultShortcutManager {
|
|
|
344
278
|
}
|
|
345
279
|
return false;
|
|
346
280
|
}
|
|
347
|
-
getExecutionStatus(shortcut) {
|
|
348
|
-
if (this.isPaused) {
|
|
349
|
-
return { disabled: true, tooltip: this.blockedMessageConfig.pausedMessage };
|
|
350
|
-
}
|
|
351
|
-
const guardStatus = this.getExecutionGuardStatus();
|
|
352
|
-
if (guardStatus.disabled) {
|
|
353
|
-
return guardStatus;
|
|
354
|
-
}
|
|
355
|
-
if (shortcut.canExecute) {
|
|
356
|
-
return shortcut.canExecute();
|
|
357
|
-
}
|
|
358
|
-
return { disabled: false, tooltip: undefined };
|
|
359
|
-
}
|
|
360
|
-
getExecutionGuardStatus() {
|
|
361
|
-
for (const guard of this.executionGuards.values()) {
|
|
362
|
-
const result = guard();
|
|
363
|
-
const status = typeof result === 'boolean' ? { disabled: result } : result;
|
|
364
|
-
if (status === null || status === void 0 ? void 0 : status.disabled) {
|
|
365
|
-
return { disabled: true, tooltip: status.tooltip };
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return { disabled: false, tooltip: undefined };
|
|
369
|
-
}
|
|
370
|
-
refreshEditableSelector() {
|
|
371
|
-
this.editableSelector = buildEditableElementSelector(this.editableContextConfig.designSystems, this.editableContextConfig.customEditableSelectors);
|
|
372
|
-
}
|
|
373
281
|
}
|
|
374
282
|
/**
|
|
375
283
|
* A dependency injection token for the ShortcutManager interface.
|