@genesislcap/foundation-utils 14.422.2-alpha-1f9504f.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 +163 -612
- 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 +0 -4
- package/dist/dts/shortcut-manager/shortcut-listener.d.ts.map +1 -1
- package/dist/dts/shortcut-manager/shortcut-manager.d.ts +0 -50
- 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 +21 -59
- package/dist/esm/shortcut-manager/shortcut-manager.js +19 -112
- package/dist/foundation-utils.api.json +82 -1272
- package/dist/foundation-utils.d.ts +0 -93
- 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 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/design-system/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/design-system/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shortcut-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shortcut-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
|
|
@@ -8,7 +8,6 @@ import { ShortcutManager } from './shortcut-manager';
|
|
|
8
8
|
export declare class FoundationShortcutListener extends FASTElement {
|
|
9
9
|
shortcutManager: ShortcutManager;
|
|
10
10
|
private keyListener;
|
|
11
|
-
private stateSubscription;
|
|
12
11
|
private isListening;
|
|
13
12
|
connectedCallback(): void;
|
|
14
13
|
disconnectedCallback(): void;
|
|
@@ -17,9 +16,6 @@ export declare class FoundationShortcutListener extends FASTElement {
|
|
|
17
16
|
private removeKeyListener;
|
|
18
17
|
private handleKeyDown;
|
|
19
18
|
private extractKeyFromCode;
|
|
20
|
-
private getDeepActiveElement;
|
|
21
|
-
private getEventElement;
|
|
22
|
-
private isEditableContext;
|
|
23
19
|
private isInputElement;
|
|
24
20
|
}
|
|
25
21
|
//# sourceMappingURL=shortcut-listener.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shortcut-listener.d.ts","sourceRoot":"","sources":["../../../src/shortcut-manager/shortcut-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"shortcut-listener.d.ts","sourceRoot":"","sources":["../../../src/shortcut-manager/shortcut-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;GAIG;AACH,qBAGa,0BAA2B,SAAQ,WAAW;IAChC,eAAe,EAAE,eAAe,CAAC;IAE1D,OAAO,CAAC,WAAW,CAAiD;IACpE,OAAO,CAAC,WAAW,CAAS;IAE5B,iBAAiB;IAKjB,oBAAoB;IAKpB,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,aAAa;IA6BrB,OAAO,CAAC,kBAAkB;IA6C1B,OAAO,CAAC,cAAc;CAuBvB"}
|
|
@@ -7,25 +7,6 @@ export type ShortcutExecutionStatus = {
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
tooltip?: string;
|
|
9
9
|
};
|
|
10
|
-
export type ShortcutDesignSystemPrefix = 'rapid' | 'zero';
|
|
11
|
-
export type ShortcutEditableContextConfig = {
|
|
12
|
-
/**
|
|
13
|
-
* Which design systems should be considered when detecting editable custom elements.
|
|
14
|
-
* @default ['rapid']
|
|
15
|
-
*/
|
|
16
|
-
designSystems?: ShortcutDesignSystemPrefix[];
|
|
17
|
-
/**
|
|
18
|
-
* Optional app-specific selectors for editable host elements.
|
|
19
|
-
* @default []
|
|
20
|
-
*/
|
|
21
|
-
customEditableSelectors?: string[];
|
|
22
|
-
};
|
|
23
|
-
export type ShortcutBlockedMessageConfig = {
|
|
24
|
-
defaultMessage?: string;
|
|
25
|
-
inputMessage?: string;
|
|
26
|
-
pausedMessage?: string;
|
|
27
|
-
elementFocusMessage?: string;
|
|
28
|
-
};
|
|
29
10
|
/**
|
|
30
11
|
* A definition of a keyboard shortcut
|
|
31
12
|
* @public
|
|
@@ -92,22 +73,6 @@ export interface ShortcutManager {
|
|
|
92
73
|
isPaused: boolean;
|
|
93
74
|
isPaused$: Observable<boolean>;
|
|
94
75
|
isPausedSubject: BehaviorSubject<boolean>;
|
|
95
|
-
/**
|
|
96
|
-
* Register a global execution guard.
|
|
97
|
-
* @remarks Guards are evaluated before shortcut-specific canExecute checks.
|
|
98
|
-
*/
|
|
99
|
-
registerExecutionGuard(id: string, guard: () => ShortcutExecutionStatus | boolean): void;
|
|
100
|
-
unregisterExecutionGuard(id: string): void;
|
|
101
|
-
clearExecutionGuards(): void;
|
|
102
|
-
/**
|
|
103
|
-
* Configure editable-context detection used by shortcut listeners.
|
|
104
|
-
* @remarks This is intended to be set once during app startup.
|
|
105
|
-
*/
|
|
106
|
-
configureEditableContext(config?: ShortcutEditableContextConfig): void;
|
|
107
|
-
getEditableContextConfig(): Required<ShortcutEditableContextConfig>;
|
|
108
|
-
getEditableSelector(): string;
|
|
109
|
-
configureBlockedMessages(config?: ShortcutBlockedMessageConfig): void;
|
|
110
|
-
getBlockedMessages(): Required<ShortcutBlockedMessageConfig>;
|
|
111
76
|
}
|
|
112
77
|
/**
|
|
113
78
|
* Default implementation of the ShortcutManager interface
|
|
@@ -119,10 +84,6 @@ export declare class DefaultShortcutManager implements ShortcutManager {
|
|
|
119
84
|
private keyCombinationMap;
|
|
120
85
|
private _isPausedSubject;
|
|
121
86
|
private _activeContext;
|
|
122
|
-
private executionGuards;
|
|
123
|
-
private editableContextConfig;
|
|
124
|
-
private editableSelector;
|
|
125
|
-
private blockedMessageConfig;
|
|
126
87
|
get isPaused(): boolean;
|
|
127
88
|
get isPaused$(): Observable<boolean>;
|
|
128
89
|
get isPausedSubject(): BehaviorSubject<boolean>;
|
|
@@ -141,14 +102,6 @@ export declare class DefaultShortcutManager implements ShortcutManager {
|
|
|
141
102
|
setActiveContext(context: string): void;
|
|
142
103
|
getActiveContext(): string | undefined;
|
|
143
104
|
clearActiveContext(): void;
|
|
144
|
-
registerExecutionGuard(id: string, guard: () => ShortcutExecutionStatus | boolean): void;
|
|
145
|
-
unregisterExecutionGuard(id: string): void;
|
|
146
|
-
clearExecutionGuards(): void;
|
|
147
|
-
configureEditableContext(config?: ShortcutEditableContextConfig): void;
|
|
148
|
-
getEditableContextConfig(): Required<ShortcutEditableContextConfig>;
|
|
149
|
-
getEditableSelector(): string;
|
|
150
|
-
configureBlockedMessages(config?: ShortcutBlockedMessageConfig): void;
|
|
151
|
-
getBlockedMessages(): Required<ShortcutBlockedMessageConfig>;
|
|
152
105
|
pause(): void;
|
|
153
106
|
resume(): void;
|
|
154
107
|
/**
|
|
@@ -158,9 +111,6 @@ export declare class DefaultShortcutManager implements ShortcutManager {
|
|
|
158
111
|
private normalizeShortcutDefinition;
|
|
159
112
|
private createKeyCombinationKey;
|
|
160
113
|
private isElementFocused;
|
|
161
|
-
private getExecutionStatus;
|
|
162
|
-
private getExecutionGuardStatus;
|
|
163
|
-
private refreshEditableSelector;
|
|
164
114
|
}
|
|
165
115
|
/**
|
|
166
116
|
* A dependency injection token for the ShortcutManager interface.
|
|
@@ -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;AAInD;;;KAGK;AACL,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,UAA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,EACf,MAAM,UAAQ,EACd,QAAQ,UAAQ,EAChB,OAAO,UAAQ,GACd,kBAAkB,GAAG,SAAS;IAqCjC,WAAW,IAAI,MAAM,EAAE;IAIvB,wBAAwB,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAIxE,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAMtC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKvC,gBAAgB,IAAI,MAAM,GAAG,SAAS;IAItC,kBAAkB,IAAI,IAAI;IAI1B,KAAK,IAAI,IAAI;IAIb,MAAM,IAAI,IAAI;IAId;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAYnC,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,gBAAgB;CAMzB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,uEAE3B,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
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.
|
|
@@ -12,7 +11,6 @@ let FoundationShortcutListener = class FoundationShortcutListener extends FASTEl
|
|
|
12
11
|
constructor() {
|
|
13
12
|
super(...arguments);
|
|
14
13
|
this.keyListener = null;
|
|
15
|
-
this.stateSubscription = null;
|
|
16
14
|
this.isListening = false;
|
|
17
15
|
}
|
|
18
16
|
connectedCallback() {
|
|
@@ -20,17 +18,12 @@ let FoundationShortcutListener = class FoundationShortcutListener extends FASTEl
|
|
|
20
18
|
this.setupStateSubscription();
|
|
21
19
|
}
|
|
22
20
|
disconnectedCallback() {
|
|
23
|
-
var _a;
|
|
24
21
|
super.disconnectedCallback();
|
|
25
|
-
(_a = this.stateSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
26
|
-
this.stateSubscription = null;
|
|
27
22
|
this.removeKeyListener();
|
|
28
23
|
}
|
|
29
24
|
setupStateSubscription() {
|
|
30
|
-
var _a;
|
|
31
25
|
// Subscribe to the pause state changes
|
|
32
|
-
|
|
33
|
-
this.stateSubscription = this.shortcutManager.isPaused$.subscribe((isPaused) => {
|
|
26
|
+
this.shortcutManager.isPaused$.subscribe((isPaused) => {
|
|
34
27
|
if (isPaused) {
|
|
35
28
|
this.removeKeyListener();
|
|
36
29
|
}
|
|
@@ -58,39 +51,21 @@ let FoundationShortcutListener = class FoundationShortcutListener extends FASTEl
|
|
|
58
51
|
this.isListening = false;
|
|
59
52
|
}
|
|
60
53
|
handleKeyDown(event) {
|
|
61
|
-
const manager = this.shortcutManager;
|
|
62
|
-
const blockedMessages = manager.getBlockedMessages();
|
|
63
|
-
const editableSelector = manager.getEditableSelector();
|
|
64
|
-
// Extract key from event.code with proper mapping for all key types
|
|
65
|
-
const key = this.extractKeyFromCode(event.code);
|
|
66
|
-
const shortcut = manager.findShortcutByKeyCombination(key, event.ctrlKey, event.altKey, event.shiftKey, event.metaKey);
|
|
67
|
-
if (!shortcut) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
54
|
// Don't handle shortcuts if the service is paused
|
|
71
|
-
if (
|
|
72
|
-
emitShortcutBlockedEvent({
|
|
73
|
-
shortcutId: shortcut.id,
|
|
74
|
-
context: shortcut.context,
|
|
75
|
-
reason: 'paused',
|
|
76
|
-
message: blockedMessages.pausedMessage,
|
|
77
|
-
});
|
|
55
|
+
if (this.shortcutManager.isPaused) {
|
|
78
56
|
return;
|
|
79
57
|
}
|
|
80
|
-
// Don't handle shortcuts
|
|
81
|
-
if (this.
|
|
82
|
-
emitShortcutBlockedEvent({
|
|
83
|
-
shortcutId: shortcut.id,
|
|
84
|
-
context: shortcut.context,
|
|
85
|
-
reason: 'editable-context',
|
|
86
|
-
message: blockedMessages.inputMessage,
|
|
87
|
-
});
|
|
58
|
+
// Don't handle shortcuts if user is typing in an input field
|
|
59
|
+
if (this.isInputElement(event.target)) {
|
|
88
60
|
return;
|
|
89
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);
|
|
90
65
|
if (shortcut) {
|
|
91
66
|
event.preventDefault();
|
|
92
67
|
event.stopPropagation();
|
|
93
|
-
|
|
68
|
+
this.shortcutManager.executeShortcut(shortcut.id);
|
|
94
69
|
}
|
|
95
70
|
}
|
|
96
71
|
extractKeyFromCode(code) {
|
|
@@ -134,37 +109,24 @@ let FoundationShortcutListener = class FoundationShortcutListener extends FASTEl
|
|
|
134
109
|
};
|
|
135
110
|
return specialKeyMap[code] || code.toLowerCase();
|
|
136
111
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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;
|
|
142
119
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
getEventElement(event) {
|
|
146
|
-
var _a, _b, _c;
|
|
147
|
-
const path = (_b = (_a = event.composedPath) === null || _a === void 0 ? void 0 : _a.call(event)) !== null && _b !== void 0 ? _b : [];
|
|
148
|
-
const fromPath = path.find((entry) => entry instanceof Element);
|
|
149
|
-
return (_c = fromPath !== null && fromPath !== void 0 ? fromPath : event.target) !== null && _c !== void 0 ? _c : null;
|
|
150
|
-
}
|
|
151
|
-
isEditableContext(event, editableSelector) {
|
|
152
|
-
const eventElement = this.getEventElement(event);
|
|
153
|
-
if (eventElement && this.isInputElement(eventElement, editableSelector)) {
|
|
120
|
+
// Check for contenteditable
|
|
121
|
+
if (element.contentEditable === 'true') {
|
|
154
122
|
return true;
|
|
155
123
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (!element)
|
|
160
|
-
return false;
|
|
161
|
-
const isEditableContent = (value) => value !== null && value !== undefined && value.toLowerCase() !== 'false';
|
|
162
|
-
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)) {
|
|
163
127
|
return true;
|
|
164
128
|
}
|
|
165
|
-
|
|
166
|
-
return false;
|
|
167
|
-
return element.matches(editableSelector) || !!element.closest(editableSelector);
|
|
129
|
+
return false;
|
|
168
130
|
}
|
|
169
131
|
};
|
|
170
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
|
}
|
|
@@ -152,12 +146,6 @@ export class DefaultShortcutManager {
|
|
|
152
146
|
}
|
|
153
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
|
-
});
|
|
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
|
-
});
|
|
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
|
-
});
|
|
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,51 +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(nextDesignSystems.length > 0
|
|
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;
|
|
298
|
-
this.blockedMessageConfig = {
|
|
299
|
-
defaultMessage: ((_a = config.defaultMessage) === null || _a === void 0 ? void 0 : _a.trim()) || DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.defaultMessage,
|
|
300
|
-
inputMessage: ((_b = config.inputMessage) === null || _b === void 0 ? void 0 : _b.trim()) || DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.inputMessage,
|
|
301
|
-
pausedMessage: ((_c = config.pausedMessage) === null || _c === void 0 ? void 0 : _c.trim()) || DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.pausedMessage,
|
|
302
|
-
elementFocusMessage: ((_d = config.elementFocusMessage) === null || _d === void 0 ? void 0 : _d.trim()) ||
|
|
303
|
-
DEFAULT_SHORTCUT_BLOCKED_MESSAGE_CONFIG.elementFocusMessage,
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
getBlockedMessages() {
|
|
307
|
-
return Object.assign({}, this.blockedMessageConfig);
|
|
308
|
-
}
|
|
309
242
|
pause() {
|
|
310
243
|
this._isPausedSubject.next(true);
|
|
311
244
|
}
|
|
@@ -345,32 +278,6 @@ export class DefaultShortcutManager {
|
|
|
345
278
|
}
|
|
346
279
|
return false;
|
|
347
280
|
}
|
|
348
|
-
getExecutionStatus(shortcut) {
|
|
349
|
-
if (this.isPaused) {
|
|
350
|
-
return { disabled: true, tooltip: this.blockedMessageConfig.pausedMessage };
|
|
351
|
-
}
|
|
352
|
-
const guardStatus = this.getExecutionGuardStatus();
|
|
353
|
-
if (guardStatus.disabled) {
|
|
354
|
-
return guardStatus;
|
|
355
|
-
}
|
|
356
|
-
if (shortcut.canExecute) {
|
|
357
|
-
return shortcut.canExecute();
|
|
358
|
-
}
|
|
359
|
-
return { disabled: false, tooltip: undefined };
|
|
360
|
-
}
|
|
361
|
-
getExecutionGuardStatus() {
|
|
362
|
-
for (const guard of this.executionGuards.values()) {
|
|
363
|
-
const result = guard();
|
|
364
|
-
const status = typeof result === 'boolean' ? { disabled: result } : result;
|
|
365
|
-
if (status === null || status === void 0 ? void 0 : status.disabled) {
|
|
366
|
-
return { disabled: true, tooltip: status.tooltip };
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return { disabled: false, tooltip: undefined };
|
|
370
|
-
}
|
|
371
|
-
refreshEditableSelector() {
|
|
372
|
-
this.editableSelector = buildEditableElementSelector(this.editableContextConfig.designSystems, this.editableContextConfig.customEditableSelectors);
|
|
373
|
-
}
|
|
374
281
|
}
|
|
375
282
|
/**
|
|
376
283
|
* A dependency injection token for the ShortcutManager interface.
|