@genesislcap/foundation-utils 14.422.2-alpha-0a3f40b.0 → 14.424.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 +236 -692
- package/dist/dts/design-system/index.d.ts +0 -1
- package/dist/dts/design-system/index.d.ts.map +1 -1
- package/dist/dts/formatters/localeNumberParser.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/formatters/localeNumberParser.js +11 -2
- 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":"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":"localeNumberParser.d.ts","sourceRoot":"","sources":["../../../src/formatters/localeNumberParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeNumberParser.d.ts","sourceRoot":"","sources":["../../../src/formatters/localeNumberParser.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,qBAAa,YAAY;IACvB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAM;gBACR,MAAM,EAAE,MAAM;IAc1B,KAAK,CAAC,YAAY,EAAE,MAAM;IAa1B,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;CAG5C"}
|
|
@@ -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"}
|
|
@@ -11,13 +11,11 @@ export declare class FoundationShortcutListener extends FASTElement {
|
|
|
11
11
|
private isListening;
|
|
12
12
|
connectedCallback(): void;
|
|
13
13
|
disconnectedCallback(): void;
|
|
14
|
+
private setupStateSubscription;
|
|
14
15
|
private addKeyListener;
|
|
15
16
|
private removeKeyListener;
|
|
16
17
|
private handleKeyDown;
|
|
17
18
|
private extractKeyFromCode;
|
|
18
|
-
private getDeepActiveElement;
|
|
19
|
-
private getEventElement;
|
|
20
|
-
private isEditableContext;
|
|
21
19
|
private isInputElement;
|
|
22
20
|
}
|
|
23
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
|
|
@@ -71,13 +52,13 @@ export interface ShortcutManager {
|
|
|
71
52
|
* @param id - The id of the shortcut to execute
|
|
72
53
|
* @remarks This method will execute the shortcut in the active context
|
|
73
54
|
*/
|
|
74
|
-
executeShortcut(id: string
|
|
55
|
+
executeShortcut(id: string): void;
|
|
75
56
|
/**
|
|
76
57
|
* Execute a shortcut by its id and context
|
|
77
58
|
* @param context - The context of the shortcut to execute
|
|
78
59
|
* @param id - The id of the shortcut to execute
|
|
79
60
|
*/
|
|
80
|
-
executeShortcutByContext(context: string, id: string
|
|
61
|
+
executeShortcutByContext(context: string, id: string): void;
|
|
81
62
|
getShortcuts(): ShortcutDefinition[];
|
|
82
63
|
getShortcutsByContext(context: string): ShortcutDefinition[];
|
|
83
64
|
getContexts(): string[];
|
|
@@ -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>;
|
|
@@ -130,8 +91,8 @@ export declare class DefaultShortcutManager implements ShortcutManager {
|
|
|
130
91
|
registerShortcut(shortcut: ShortcutDefinition): ShortcutRegistrationResult;
|
|
131
92
|
unregisterShortcut(context: string, id: string): void;
|
|
132
93
|
unregisterShortcutsByContext(context: string): void;
|
|
133
|
-
executeShortcut(id: string
|
|
134
|
-
executeShortcutByContext(context: string, id: string
|
|
94
|
+
executeShortcut(id: string): void;
|
|
95
|
+
executeShortcutByContext(context: string, id: string): void;
|
|
135
96
|
getShortcuts(): ShortcutDefinition[];
|
|
136
97
|
getShortcutsByContext(context: string): ShortcutDefinition[];
|
|
137
98
|
findShortcutByKeyCombination(key: string, ctrlKey?: boolean, altKey?: boolean, shiftKey?: boolean, metaKey?: boolean): ShortcutDefinition | undefined;
|
|
@@ -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,OAA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jC,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IA+B3D,YAAY,IAAI,kBAAkB,EAAE;IASpC,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,EAAE;IAK5D,4BAA4B,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,UAAQ,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,5 +1,11 @@
|
|
|
1
1
|
const FORMAT_PARTS = 12345.6;
|
|
2
2
|
const FORMAT_NUMERALS = 9876543210;
|
|
3
|
+
const SHORTCUT_MULTIPLIERS = {
|
|
4
|
+
k: 1000,
|
|
5
|
+
m: 1000000,
|
|
6
|
+
b: 1000000000,
|
|
7
|
+
};
|
|
8
|
+
const SHORTCUT_REGEX = /^(.*?)([kmb])$/i;
|
|
3
9
|
/**
|
|
4
10
|
* @public
|
|
5
11
|
*/
|
|
@@ -17,12 +23,15 @@ export class NumberParser {
|
|
|
17
23
|
this._index = (d) => index.get(d);
|
|
18
24
|
}
|
|
19
25
|
parse(localeNumber) {
|
|
20
|
-
|
|
26
|
+
const shortcutMatch = localeNumber.trim().match(SHORTCUT_REGEX);
|
|
27
|
+
const multiplier = shortcutMatch ? SHORTCUT_MULTIPLIERS[shortcutMatch[2].toLowerCase()] : 1;
|
|
28
|
+
const normalized = shortcutMatch ? shortcutMatch[1] : localeNumber;
|
|
29
|
+
return (localeNumber = normalized
|
|
21
30
|
.trim()
|
|
22
31
|
.replace(this._group, '')
|
|
23
32
|
.replace(this._decimal, '.')
|
|
24
33
|
.replace(this._numeral, this._index))
|
|
25
|
-
? +localeNumber
|
|
34
|
+
? +localeNumber * multiplier
|
|
26
35
|
: NaN;
|
|
27
36
|
}
|
|
28
37
|
hasSeparator(localeNumber) {
|
|
@@ -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.
|
|
@@ -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.
|