@wordpress/keycodes 4.31.1-next.f56bd8138.0 → 4.32.1-next.47f435fc9.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/CHANGELOG.md +2 -0
- package/build/index.js +180 -309
- package/build/index.js.map +7 -1
- package/build/platform.js +29 -17
- package/build/platform.js.map +7 -1
- package/build-module/index.js +130 -298
- package/build-module/index.js.map +7 -1
- package/build-module/platform.js +8 -14
- package/build-module/platform.js.map +7 -1
- package/package.json +11 -4
- package/build/platform.native.js +0 -20
- package/build/platform.native.js.map +0 -1
- package/build-module/platform.native.js +0 -14
- package/build-module/platform.native.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/build/index.js
CHANGED
|
@@ -1,178 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
ALT: () => ALT,
|
|
22
|
+
BACKSPACE: () => BACKSPACE,
|
|
23
|
+
COMMAND: () => COMMAND,
|
|
24
|
+
CTRL: () => CTRL,
|
|
25
|
+
DELETE: () => DELETE,
|
|
26
|
+
DOWN: () => DOWN,
|
|
27
|
+
END: () => END,
|
|
28
|
+
ENTER: () => ENTER,
|
|
29
|
+
ESCAPE: () => ESCAPE,
|
|
30
|
+
F10: () => F10,
|
|
31
|
+
HOME: () => HOME,
|
|
32
|
+
LEFT: () => LEFT,
|
|
33
|
+
PAGEDOWN: () => PAGEDOWN,
|
|
34
|
+
PAGEUP: () => PAGEUP,
|
|
35
|
+
RIGHT: () => RIGHT,
|
|
36
|
+
SHIFT: () => SHIFT,
|
|
37
|
+
SPACE: () => SPACE,
|
|
38
|
+
TAB: () => TAB,
|
|
39
|
+
UP: () => UP,
|
|
40
|
+
ZERO: () => ZERO,
|
|
41
|
+
displayShortcut: () => displayShortcut,
|
|
42
|
+
displayShortcutList: () => displayShortcutList,
|
|
43
|
+
isAppleOS: () => import_platform.isAppleOS,
|
|
44
|
+
isKeyboardEvent: () => isKeyboardEvent,
|
|
45
|
+
modifiers: () => modifiers,
|
|
46
|
+
rawShortcut: () => rawShortcut,
|
|
47
|
+
shortcutAriaLabel: () => shortcutAriaLabel
|
|
12
48
|
});
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* External dependencies
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* An object of handler functions for each of the possible modifier
|
|
41
|
-
* combinations. A handler will return a value for a given key.
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Keycode for BACKSPACE key.
|
|
46
|
-
*/
|
|
47
|
-
const BACKSPACE = exports.BACKSPACE = 8;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Keycode for TAB key.
|
|
51
|
-
*/
|
|
52
|
-
const TAB = exports.TAB = 9;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Keycode for ENTER key.
|
|
56
|
-
*/
|
|
57
|
-
const ENTER = exports.ENTER = 13;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Keycode for ESCAPE key.
|
|
61
|
-
*/
|
|
62
|
-
const ESCAPE = exports.ESCAPE = 27;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Keycode for SPACE key.
|
|
66
|
-
*/
|
|
67
|
-
const SPACE = exports.SPACE = 32;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Keycode for PAGEUP key.
|
|
71
|
-
*/
|
|
72
|
-
const PAGEUP = exports.PAGEUP = 33;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Keycode for PAGEDOWN key.
|
|
76
|
-
*/
|
|
77
|
-
const PAGEDOWN = exports.PAGEDOWN = 34;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Keycode for END key.
|
|
81
|
-
*/
|
|
82
|
-
const END = exports.END = 35;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Keycode for HOME key.
|
|
86
|
-
*/
|
|
87
|
-
const HOME = exports.HOME = 36;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Keycode for LEFT key.
|
|
91
|
-
*/
|
|
92
|
-
const LEFT = exports.LEFT = 37;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Keycode for UP key.
|
|
96
|
-
*/
|
|
97
|
-
const UP = exports.UP = 38;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Keycode for RIGHT key.
|
|
101
|
-
*/
|
|
102
|
-
const RIGHT = exports.RIGHT = 39;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Keycode for DOWN key.
|
|
106
|
-
*/
|
|
107
|
-
const DOWN = exports.DOWN = 40;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Keycode for DELETE key.
|
|
111
|
-
*/
|
|
112
|
-
const DELETE = exports.DELETE = 46;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Keycode for F10 key.
|
|
116
|
-
*/
|
|
117
|
-
const F10 = exports.F10 = 121;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Keycode for ALT key.
|
|
121
|
-
*/
|
|
122
|
-
const ALT = exports.ALT = 'alt';
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Keycode for CTRL key.
|
|
126
|
-
*/
|
|
127
|
-
const CTRL = exports.CTRL = 'ctrl';
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Keycode for COMMAND/META key.
|
|
131
|
-
*/
|
|
132
|
-
const COMMAND = exports.COMMAND = 'meta';
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Keycode for SHIFT key.
|
|
136
|
-
*/
|
|
137
|
-
const SHIFT = exports.SHIFT = 'shift';
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Keycode for ZERO key.
|
|
141
|
-
*/
|
|
142
|
-
const ZERO = exports.ZERO = 48;
|
|
143
|
-
/**
|
|
144
|
-
* Capitalise the first character of a string.
|
|
145
|
-
* @param string String to capitalise.
|
|
146
|
-
* @return Capitalised string.
|
|
147
|
-
*/
|
|
49
|
+
module.exports = __toCommonJS(index_exports);
|
|
50
|
+
var import_i18n = require("@wordpress/i18n");
|
|
51
|
+
var import_platform = require("./platform");
|
|
52
|
+
const BACKSPACE = 8;
|
|
53
|
+
const TAB = 9;
|
|
54
|
+
const ENTER = 13;
|
|
55
|
+
const ESCAPE = 27;
|
|
56
|
+
const SPACE = 32;
|
|
57
|
+
const PAGEUP = 33;
|
|
58
|
+
const PAGEDOWN = 34;
|
|
59
|
+
const END = 35;
|
|
60
|
+
const HOME = 36;
|
|
61
|
+
const LEFT = 37;
|
|
62
|
+
const UP = 38;
|
|
63
|
+
const RIGHT = 39;
|
|
64
|
+
const DOWN = 40;
|
|
65
|
+
const DELETE = 46;
|
|
66
|
+
const F10 = 121;
|
|
67
|
+
const ALT = "alt";
|
|
68
|
+
const CTRL = "ctrl";
|
|
69
|
+
const COMMAND = "meta";
|
|
70
|
+
const SHIFT = "shift";
|
|
71
|
+
const ZERO = 48;
|
|
148
72
|
function capitaliseFirstCharacter(string) {
|
|
149
73
|
return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1);
|
|
150
74
|
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Map the values of an object with a specified callback and return the result object.
|
|
154
|
-
*
|
|
155
|
-
* @template T The object type
|
|
156
|
-
* @template R The return type of the mapping function
|
|
157
|
-
*
|
|
158
|
-
* @param object Object to map values of.
|
|
159
|
-
* @param mapFn Mapping function to apply to each value.
|
|
160
|
-
* @return Object with the same keys and transformed values.
|
|
161
|
-
*/
|
|
162
75
|
function mapValues(object, mapFn) {
|
|
163
|
-
return Object.fromEntries(
|
|
76
|
+
return Object.fromEntries(
|
|
77
|
+
Object.entries(object).map(([key, value]) => [
|
|
78
|
+
key,
|
|
79
|
+
mapFn(value)
|
|
80
|
+
])
|
|
81
|
+
);
|
|
164
82
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
primary: _isApple => _isApple() ? [COMMAND] : [CTRL],
|
|
172
|
-
primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
|
|
173
|
-
primaryAlt: _isApple => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
|
|
174
|
-
secondary: _isApple => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
|
|
175
|
-
access: _isApple => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
|
|
83
|
+
const modifiers = {
|
|
84
|
+
primary: (_isApple) => _isApple() ? [COMMAND] : [CTRL],
|
|
85
|
+
primaryShift: (_isApple) => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
|
|
86
|
+
primaryAlt: (_isApple) => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
|
|
87
|
+
secondary: (_isApple) => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
|
|
88
|
+
access: (_isApple) => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
|
|
176
89
|
ctrl: () => [CTRL],
|
|
177
90
|
alt: () => [ALT],
|
|
178
91
|
ctrlShift: () => [CTRL, SHIFT],
|
|
@@ -180,156 +93,92 @@ const modifiers = exports.modifiers = {
|
|
|
180
93
|
shiftAlt: () => [SHIFT, ALT],
|
|
181
94
|
undefined: () => []
|
|
182
95
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```js
|
|
191
|
-
* // Assuming macOS:
|
|
192
|
-
* rawShortcut.primary( 'm' )
|
|
193
|
-
* // "meta+m""
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
const rawShortcut = exports.rawShortcut = /* @__PURE__ */
|
|
197
|
-
mapValues(modifiers, modifier => {
|
|
198
|
-
return (character, _isApple = _platform.isAppleOS) => {
|
|
199
|
-
return [...modifier(_isApple), character.toLowerCase()].join('+');
|
|
96
|
+
const rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
|
97
|
+
return (character, _isApple = import_platform.isAppleOS) => {
|
|
98
|
+
return [...modifier(_isApple), character.toLowerCase()].join(
|
|
99
|
+
"+"
|
|
100
|
+
);
|
|
200
101
|
};
|
|
201
102
|
});
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
[
|
|
103
|
+
const displayShortcutList = /* @__PURE__ */ mapValues(
|
|
104
|
+
modifiers,
|
|
105
|
+
(modifier) => {
|
|
106
|
+
return (character, _isApple = import_platform.isAppleOS) => {
|
|
107
|
+
const isApple = _isApple();
|
|
108
|
+
const replacementKeyMap = {
|
|
109
|
+
[ALT]: isApple ? "\u2325" : "Alt",
|
|
110
|
+
[CTRL]: isApple ? "\u2303" : "Ctrl",
|
|
111
|
+
// Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
|
|
112
|
+
[COMMAND]: "\u2318",
|
|
113
|
+
[SHIFT]: isApple ? "\u21E7" : "Shift"
|
|
114
|
+
};
|
|
115
|
+
const modifierKeys = modifier(_isApple).reduce(
|
|
116
|
+
(accumulator, key) => {
|
|
117
|
+
const replacementKey = replacementKeyMap[key] ?? key;
|
|
118
|
+
if (isApple) {
|
|
119
|
+
return [...accumulator, replacementKey];
|
|
120
|
+
}
|
|
121
|
+
return [...accumulator, replacementKey, "+"];
|
|
122
|
+
},
|
|
123
|
+
[]
|
|
124
|
+
);
|
|
125
|
+
return [
|
|
126
|
+
...modifierKeys,
|
|
127
|
+
capitaliseFirstCharacter(character)
|
|
128
|
+
];
|
|
225
129
|
};
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
};
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* An object that contains functions to display shortcuts.
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```js
|
|
244
|
-
* // Assuming macOS:
|
|
245
|
-
* displayShortcut.primary( 'm' );
|
|
246
|
-
* // "⌘M"
|
|
247
|
-
* ```
|
|
248
|
-
*
|
|
249
|
-
* Keyed map of functions to display shortcuts.
|
|
250
|
-
*/
|
|
251
|
-
const displayShortcut = exports.displayShortcut = /* @__PURE__ */
|
|
252
|
-
mapValues(displayShortcutList, shortcutList => {
|
|
253
|
-
return (character, _isApple = _platform.isAppleOS) => shortcutList(character, _isApple).join('');
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* An object that contains functions to return an aria label for a keyboard
|
|
258
|
-
* shortcut.
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* ```js
|
|
262
|
-
* // Assuming macOS:
|
|
263
|
-
* shortcutAriaLabel.primary( '.' );
|
|
264
|
-
* // "Command + Period"
|
|
265
|
-
* ```
|
|
266
|
-
*
|
|
267
|
-
* Keyed map of functions to shortcut ARIA labels.
|
|
268
|
-
*/
|
|
269
|
-
const shortcutAriaLabel = exports.shortcutAriaLabel = /* @__PURE__ */
|
|
270
|
-
mapValues(modifiers, modifier => {
|
|
271
|
-
return (character, _isApple = _platform.isAppleOS) => {
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
const displayShortcut = /* @__PURE__ */ mapValues(
|
|
133
|
+
displayShortcutList,
|
|
134
|
+
(shortcutList) => {
|
|
135
|
+
return (character, _isApple = import_platform.isAppleOS) => shortcutList(character, _isApple).join("");
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
const shortcutAriaLabel = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
|
139
|
+
return (character, _isApple = import_platform.isAppleOS) => {
|
|
272
140
|
const isApple = _isApple();
|
|
273
141
|
const replacementKeyMap = {
|
|
274
|
-
[SHIFT]:
|
|
275
|
-
[COMMAND]: isApple ?
|
|
276
|
-
[CTRL]:
|
|
277
|
-
[ALT]: isApple ?
|
|
142
|
+
[SHIFT]: "Shift",
|
|
143
|
+
[COMMAND]: isApple ? "Command" : "Control",
|
|
144
|
+
[CTRL]: "Control",
|
|
145
|
+
[ALT]: isApple ? "Option" : "Alt",
|
|
278
146
|
/* translators: comma as in the character ',' */
|
|
279
|
-
|
|
147
|
+
",": (0, import_i18n.__)("Comma"),
|
|
280
148
|
/* translators: period as in the character '.' */
|
|
281
|
-
|
|
149
|
+
".": (0, import_i18n.__)("Period"),
|
|
282
150
|
/* translators: backtick as in the character '`' */
|
|
283
|
-
|
|
151
|
+
"`": (0, import_i18n.__)("Backtick"),
|
|
284
152
|
/* translators: tilde as in the character '~' */
|
|
285
|
-
|
|
153
|
+
"~": (0, import_i18n.__)("Tilde")
|
|
286
154
|
};
|
|
287
|
-
return [...modifier(_isApple), character].map(
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}).join(isApple ? ' ' : ' + ');
|
|
155
|
+
return [...modifier(_isApple), character].map(
|
|
156
|
+
(key) => capitaliseFirstCharacter(replacementKeyMap[key] ?? key)
|
|
157
|
+
).join(isApple ? " " : " + ");
|
|
291
158
|
};
|
|
292
159
|
});
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* From a given KeyboardEvent, returns an array of active modifier constants for
|
|
296
|
-
* the event.
|
|
297
|
-
*
|
|
298
|
-
* @param event Keyboard event.
|
|
299
|
-
*
|
|
300
|
-
* @return Active modifier constants.
|
|
301
|
-
*/
|
|
302
160
|
function getEventModifiers(event) {
|
|
303
|
-
return [ALT, CTRL, COMMAND, SHIFT].filter(
|
|
161
|
+
return [ALT, CTRL, COMMAND, SHIFT].filter(
|
|
162
|
+
(key) => event[`${key}Key`]
|
|
163
|
+
);
|
|
304
164
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* An object that contains functions to check if a keyboard event matches a
|
|
308
|
-
* predefined shortcut combination.
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* ```js
|
|
312
|
-
* // Assuming an event for ⌘M key press:
|
|
313
|
-
* isKeyboardEvent.primary( event, 'm' );
|
|
314
|
-
* // true
|
|
315
|
-
* ```
|
|
316
|
-
*
|
|
317
|
-
* Keyed map of functions to match events.
|
|
318
|
-
*/
|
|
319
|
-
const isKeyboardEvent = exports.isKeyboardEvent = /* @__PURE__ */
|
|
320
|
-
mapValues(modifiers, getModifiers => {
|
|
321
|
-
return (event, character, _isApple = _platform.isAppleOS) => {
|
|
165
|
+
const isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => {
|
|
166
|
+
return (event, character, _isApple = import_platform.isAppleOS) => {
|
|
322
167
|
const mods = getModifiers(_isApple);
|
|
323
168
|
const eventMods = getEventModifiers(event);
|
|
324
169
|
const replacementWithShiftKeyMap = {
|
|
325
|
-
Comma:
|
|
326
|
-
Backslash:
|
|
170
|
+
Comma: ",",
|
|
171
|
+
Backslash: "\\",
|
|
327
172
|
// Windows returns `\` for both IntlRo and IntlYen.
|
|
328
|
-
IntlRo:
|
|
329
|
-
IntlYen:
|
|
173
|
+
IntlRo: "\\",
|
|
174
|
+
IntlYen: "\\"
|
|
330
175
|
};
|
|
331
|
-
const modsDiff = mods.filter(
|
|
332
|
-
|
|
176
|
+
const modsDiff = mods.filter(
|
|
177
|
+
(mod) => !eventMods.includes(mod)
|
|
178
|
+
);
|
|
179
|
+
const eventModsDiff = eventMods.filter(
|
|
180
|
+
(mod) => !mods.includes(mod)
|
|
181
|
+
);
|
|
333
182
|
if (modsDiff.length > 0 || eventModsDiff.length > 0) {
|
|
334
183
|
return false;
|
|
335
184
|
}
|
|
@@ -340,21 +189,43 @@ mapValues(modifiers, getModifiers => {
|
|
|
340
189
|
if (event.altKey && character.length === 1) {
|
|
341
190
|
key = String.fromCharCode(event.keyCode).toLowerCase();
|
|
342
191
|
}
|
|
343
|
-
|
|
344
|
-
// `event.key` returns the value of the key pressed, taking into the state of
|
|
345
|
-
// modifier keys such as `Shift`. If the shift key is pressed, a different
|
|
346
|
-
// value may be returned depending on the keyboard layout. It is necessary to
|
|
347
|
-
// convert to the physical key value that don't take into account keyboard
|
|
348
|
-
// layout or modifier key state.
|
|
349
192
|
if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) {
|
|
350
193
|
key = replacementWithShiftKeyMap[event.code];
|
|
351
194
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (character === 'del') {
|
|
355
|
-
character = 'delete';
|
|
195
|
+
if (character === "del") {
|
|
196
|
+
character = "delete";
|
|
356
197
|
}
|
|
357
198
|
return key === character.toLowerCase();
|
|
358
199
|
};
|
|
359
200
|
});
|
|
360
|
-
|
|
201
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
202
|
+
0 && (module.exports = {
|
|
203
|
+
ALT,
|
|
204
|
+
BACKSPACE,
|
|
205
|
+
COMMAND,
|
|
206
|
+
CTRL,
|
|
207
|
+
DELETE,
|
|
208
|
+
DOWN,
|
|
209
|
+
END,
|
|
210
|
+
ENTER,
|
|
211
|
+
ESCAPE,
|
|
212
|
+
F10,
|
|
213
|
+
HOME,
|
|
214
|
+
LEFT,
|
|
215
|
+
PAGEDOWN,
|
|
216
|
+
PAGEUP,
|
|
217
|
+
RIGHT,
|
|
218
|
+
SHIFT,
|
|
219
|
+
SPACE,
|
|
220
|
+
TAB,
|
|
221
|
+
UP,
|
|
222
|
+
ZERO,
|
|
223
|
+
displayShortcut,
|
|
224
|
+
displayShortcutList,
|
|
225
|
+
isAppleOS,
|
|
226
|
+
isKeyboardEvent,
|
|
227
|
+
modifiers,
|
|
228
|
+
rawShortcut,
|
|
229
|
+
shortcutAriaLabel
|
|
230
|
+
});
|
|
231
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_platform","BACKSPACE","exports","TAB","ENTER","ESCAPE","SPACE","PAGEUP","PAGEDOWN","END","HOME","LEFT","UP","RIGHT","DOWN","DELETE","F10","ALT","CTRL","COMMAND","SHIFT","ZERO","capitaliseFirstCharacter","string","length","toUpperCase","charAt","slice","mapValues","object","mapFn","Object","fromEntries","entries","map","key","value","modifiers","primary","_isApple","primaryShift","primaryAlt","secondary","access","ctrl","alt","ctrlShift","shift","shiftAlt","undefined","rawShortcut","modifier","character","isAppleOS","toLowerCase","join","displayShortcutList","isApple","replacementKeyMap","modifierKeys","reduce","accumulator","_replacementKeyMap$ke","replacementKey","displayShortcut","shortcutList","shortcutAriaLabel","__","_replacementKeyMap$ke2","getEventModifiers","event","filter","isKeyboardEvent","getModifiers","mods","eventMods","replacementWithShiftKeyMap","Comma","Backslash","IntlRo","IntlYen","modsDiff","mod","includes","eventModsDiff","altKey","String","fromCharCode","keyCode","shiftKey","code"],"sources":["@wordpress/keycodes/src/index.ts"],"sourcesContent":["/**\n * Note: The order of the modifier keys in many of the [foo]Shortcut()\n * functions in this file are intentional and should not be changed. They're\n * designed to fit with the standard menu keyboard shortcuts shown in the\n * user's platform.\n *\n * For example, on MacOS menu shortcuts will place Shift before Command, but\n * on Windows Control will usually come first. So don't provide your own\n * shortcut combos directly to keyboardShortcut().\n */\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isAppleOS } from './platform';\n\n/**\n * External dependencies\n */\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\n\nexport type WPModifierPart =\n\t| typeof ALT\n\t| typeof CTRL\n\t| typeof COMMAND\n\t| typeof SHIFT;\n\nexport type WPKeycodeModifier =\n\t| 'primary'\n\t| 'primaryShift'\n\t| 'primaryAlt'\n\t| 'secondary'\n\t| 'access'\n\t| 'ctrl'\n\t| 'alt'\n\t| 'ctrlShift'\n\t| 'shift'\n\t| 'shiftAlt'\n\t| 'undefined';\n\n/**\n * An object of handler functions for each of the possible modifier\n * combinations. A handler will return a value for a given key.\n */\nexport type WPModifierHandler< T > = Record< WPKeycodeModifier, T >;\n\nexport type WPKeyHandler< T > = (\n\tcharacter: string,\n\tisApple?: () => boolean\n) => T;\n\nexport type WPEventKeyHandler = (\n\tevent: ReactKeyboardEvent< HTMLElement > | KeyboardEvent,\n\tcharacter: string,\n\tisApple?: () => boolean\n) => boolean;\n\nexport type WPModifier = ( isApple: () => boolean ) => WPModifierPart[];\n\n/**\n * Keycode for BACKSPACE key.\n */\nexport const BACKSPACE = 8;\n\n/**\n * Keycode for TAB key.\n */\nexport const TAB = 9;\n\n/**\n * Keycode for ENTER key.\n */\nexport const ENTER = 13;\n\n/**\n * Keycode for ESCAPE key.\n */\nexport const ESCAPE = 27;\n\n/**\n * Keycode for SPACE key.\n */\nexport const SPACE = 32;\n\n/**\n * Keycode for PAGEUP key.\n */\nexport const PAGEUP = 33;\n\n/**\n * Keycode for PAGEDOWN key.\n */\nexport const PAGEDOWN = 34;\n\n/**\n * Keycode for END key.\n */\nexport const END = 35;\n\n/**\n * Keycode for HOME key.\n */\nexport const HOME = 36;\n\n/**\n * Keycode for LEFT key.\n */\nexport const LEFT = 37;\n\n/**\n * Keycode for UP key.\n */\nexport const UP = 38;\n\n/**\n * Keycode for RIGHT key.\n */\nexport const RIGHT = 39;\n\n/**\n * Keycode for DOWN key.\n */\nexport const DOWN = 40;\n\n/**\n * Keycode for DELETE key.\n */\nexport const DELETE = 46;\n\n/**\n * Keycode for F10 key.\n */\nexport const F10 = 121;\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND/META key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Keycode for ZERO key.\n */\nexport const ZERO = 48;\n\nexport { isAppleOS };\n\n/**\n * Capitalise the first character of a string.\n * @param string String to capitalise.\n * @return Capitalised string.\n */\nfunction capitaliseFirstCharacter( string: string ): string {\n\treturn string.length < 2\n\t\t? string.toUpperCase()\n\t\t: string.charAt( 0 ).toUpperCase() + string.slice( 1 );\n}\n\n/**\n * Map the values of an object with a specified callback and return the result object.\n *\n * @template T The object type\n * @template R The return type of the mapping function\n *\n * @param object Object to map values of.\n * @param mapFn Mapping function to apply to each value.\n * @return Object with the same keys and transformed values.\n */\nfunction mapValues< T extends Record< string, any >, R >(\n\tobject: T,\n\tmapFn: ( value: T[ keyof T ] ) => R\n): Record< keyof T, R > {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tmapFn( value ),\n\t\t] )\n\t) as Record< keyof T, R >;\n}\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n */\nexport const modifiers: WPModifierHandler< WPModifier > = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n\n/**\n * An object that contains functions to get raw shortcuts.\n *\n * These are intended for user with the KeyboardShortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * rawShortcut.primary( 'm' )\n * // \"meta+m\"\"\n * ```\n */\nexport const rawShortcut: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( modifier: WPModifier ) => {\n\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\treturn [ ...modifier( _isApple ), character.toLowerCase() ].join(\n\t\t\t\t'+'\n\t\t\t);\n\t\t};\n\t} );\n\n/**\n * Return an array of the parts of a keyboard shortcut chord for display.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcutList.primary( 'm' );\n * // [ \"⌘\", \"M\" ]\n * ```\n *\n * Keyed map of functions to shortcut sequences.\n */\nexport const displayShortcutList: WPModifierHandler<\n\tWPKeyHandler< string[] >\n> =\n\t/* @__PURE__ */\n\tmapValues(\n\t\tmodifiers,\n\t\t( modifier: WPModifier ): WPKeyHandler< string[] > => {\n\t\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\t\tconst isApple = _isApple();\n\t\t\t\tconst replacementKeyMap = {\n\t\t\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\t\t\t\t\t[ CTRL ]: isApple ? '⌃' : 'Ctrl', // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.\n\t\t\t\t\t[ COMMAND ]: '⌘',\n\t\t\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t\t\t};\n\n\t\t\t\tconst modifierKeys = modifier( _isApple ).reduce< string[] >(\n\t\t\t\t\t( accumulator, key ) => {\n\t\t\t\t\t\tconst replacementKey = replacementKeyMap[ key ] ?? key;\n\t\t\t\t\t\t// If on the Mac, adhere to platform convention and don't show plus between keys.\n\t\t\t\t\t\tif ( isApple ) {\n\t\t\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\n\t\t\t\treturn [\n\t\t\t\t\t...modifierKeys,\n\t\t\t\t\tcapitaliseFirstCharacter( character ),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\t);\n\n/**\n * An object that contains functions to display shortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcut.primary( 'm' );\n * // \"⌘M\"\n * ```\n *\n * Keyed map of functions to display shortcuts.\n */\nexport const displayShortcut: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues(\n\t\tdisplayShortcutList,\n\t\t( shortcutList: WPKeyHandler< string[] > ): WPKeyHandler< string > => {\n\t\t\treturn ( character: string, _isApple = isAppleOS ) =>\n\t\t\t\tshortcutList( character, _isApple ).join( '' );\n\t\t}\n\t);\n\n/**\n * An object that contains functions to return an aria label for a keyboard\n * shortcut.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * shortcutAriaLabel.primary( '.' );\n * // \"Command + Period\"\n * ```\n *\n * Keyed map of functions to shortcut ARIA labels.\n */\nexport const shortcutAriaLabel: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( modifier: WPModifier ): WPKeyHandler< string > => {\n\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\tconst isApple = _isApple();\n\t\t\tconst replacementKeyMap: Record< string, string > = {\n\t\t\t\t[ SHIFT ]: 'Shift',\n\t\t\t\t[ COMMAND ]: isApple ? 'Command' : 'Control',\n\t\t\t\t[ CTRL ]: 'Control',\n\t\t\t\t[ ALT ]: isApple ? 'Option' : 'Alt',\n\t\t\t\t/* translators: comma as in the character ',' */\n\t\t\t\t',': __( 'Comma' ),\n\t\t\t\t/* translators: period as in the character '.' */\n\t\t\t\t'.': __( 'Period' ),\n\t\t\t\t/* translators: backtick as in the character '`' */\n\t\t\t\t'`': __( 'Backtick' ),\n\t\t\t\t/* translators: tilde as in the character '~' */\n\t\t\t\t'~': __( 'Tilde' ),\n\t\t\t};\n\n\t\t\treturn [ ...modifier( _isApple ), character ]\n\t\t\t\t.map( ( key ) =>\n\t\t\t\t\tcapitaliseFirstCharacter( replacementKeyMap[ key ] ?? key )\n\t\t\t\t)\n\t\t\t\t.join( isApple ? ' ' : ' + ' );\n\t\t};\n\t} );\n\n/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param event Keyboard event.\n *\n * @return Active modifier constants.\n */\nfunction getEventModifiers(\n\tevent: ReactKeyboardEvent< HTMLElement > | KeyboardEvent\n): WPModifierPart[] {\n\treturn ( [ ALT, CTRL, COMMAND, SHIFT ] as const ).filter(\n\t\t( key ) =>\n\t\t\t( event as KeyboardEvent )[\n\t\t\t\t`${ key }Key` as 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'\n\t\t\t]\n\t);\n}\n\n/**\n * An object that contains functions to check if a keyboard event matches a\n * predefined shortcut combination.\n *\n * @example\n * ```js\n * // Assuming an event for ⌘M key press:\n * isKeyboardEvent.primary( event, 'm' );\n * // true\n * ```\n *\n * Keyed map of functions to match events.\n */\nexport const isKeyboardEvent: WPModifierHandler< WPEventKeyHandler > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( getModifiers: WPModifier ): WPEventKeyHandler => {\n\t\treturn ( event, character, _isApple = isAppleOS ) => {\n\t\t\tconst mods = getModifiers( _isApple );\n\t\t\tconst eventMods = getEventModifiers( event );\n\n\t\t\tconst replacementWithShiftKeyMap: Record< string, string > = {\n\t\t\t\tComma: ',',\n\t\t\t\tBackslash: '\\\\',\n\t\t\t\t// Windows returns `\\` for both IntlRo and IntlYen.\n\t\t\t\tIntlRo: '\\\\',\n\t\t\t\tIntlYen: '\\\\',\n\t\t\t};\n\n\t\t\tconst modsDiff = mods.filter(\n\t\t\t\t( mod ) => ! eventMods.includes( mod )\n\t\t\t);\n\t\t\tconst eventModsDiff = eventMods.filter(\n\t\t\t\t( mod ) => ! mods.includes( mod )\n\t\t\t);\n\n\t\t\tif ( modsDiff.length > 0 || eventModsDiff.length > 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tlet key = event.key.toLowerCase();\n\n\t\t\tif ( ! character ) {\n\t\t\t\treturn mods.includes( key as WPModifierPart );\n\t\t\t}\n\n\t\t\tif ( event.altKey && character.length === 1 ) {\n\t\t\t\tkey = String.fromCharCode( event.keyCode ).toLowerCase();\n\t\t\t}\n\n\t\t\t// `event.key` returns the value of the key pressed, taking into the state of\n\t\t\t// modifier keys such as `Shift`. If the shift key is pressed, a different\n\t\t\t// value may be returned depending on the keyboard layout. It is necessary to\n\t\t\t// convert to the physical key value that don't take into account keyboard\n\t\t\t// layout or modifier key state.\n\t\t\tif (\n\t\t\t\tevent.shiftKey &&\n\t\t\t\tcharacter.length === 1 &&\n\t\t\t\treplacementWithShiftKeyMap[ event.code ]\n\t\t\t) {\n\t\t\t\tkey = replacementWithShiftKeyMap[ event.code ];\n\t\t\t}\n\n\t\t\t// For backwards compatibility.\n\t\t\tif ( character === 'del' ) {\n\t\t\t\tcharacter = 'delete';\n\t\t\t}\n\n\t\t\treturn key === character.toLowerCase();\n\t\t};\n\t} );\n"],"mappings":";;;;;;;;;;;;;AAcA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAD,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACO,MAAME,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,CAAC;;AAE1B;AACA;AACA;AACO,MAAME,GAAG,GAAAD,OAAA,CAAAC,GAAA,GAAG,CAAC;;AAEpB;AACA;AACA;AACO,MAAMC,KAAK,GAAAF,OAAA,CAAAE,KAAA,GAAG,EAAE;;AAEvB;AACA;AACA;AACO,MAAMC,MAAM,GAAAH,OAAA,CAAAG,MAAA,GAAG,EAAE;;AAExB;AACA;AACA;AACO,MAAMC,KAAK,GAAAJ,OAAA,CAAAI,KAAA,GAAG,EAAE;;AAEvB;AACA;AACA;AACO,MAAMC,MAAM,GAAAL,OAAA,CAAAK,MAAA,GAAG,EAAE;;AA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
+
"sourcesContent": ["/**\n * Note: The order of the modifier keys in many of the [foo]Shortcut()\n * functions in this file are intentional and should not be changed. They're\n * designed to fit with the standard menu keyboard shortcuts shown in the\n * user's platform.\n *\n * For example, on MacOS menu shortcuts will place Shift before Command, but\n * on Windows Control will usually come first. So don't provide your own\n * shortcut combos directly to keyboardShortcut().\n */\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isAppleOS } from './platform';\n\n/**\n * External dependencies\n */\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\n\nexport type WPModifierPart =\n\t| typeof ALT\n\t| typeof CTRL\n\t| typeof COMMAND\n\t| typeof SHIFT;\n\nexport type WPKeycodeModifier =\n\t| 'primary'\n\t| 'primaryShift'\n\t| 'primaryAlt'\n\t| 'secondary'\n\t| 'access'\n\t| 'ctrl'\n\t| 'alt'\n\t| 'ctrlShift'\n\t| 'shift'\n\t| 'shiftAlt'\n\t| 'undefined';\n\n/**\n * An object of handler functions for each of the possible modifier\n * combinations. A handler will return a value for a given key.\n */\nexport type WPModifierHandler< T > = Record< WPKeycodeModifier, T >;\n\nexport type WPKeyHandler< T > = (\n\tcharacter: string,\n\tisApple?: () => boolean\n) => T;\n\nexport type WPEventKeyHandler = (\n\tevent: ReactKeyboardEvent< HTMLElement > | KeyboardEvent,\n\tcharacter: string,\n\tisApple?: () => boolean\n) => boolean;\n\nexport type WPModifier = ( isApple: () => boolean ) => WPModifierPart[];\n\n/**\n * Keycode for BACKSPACE key.\n */\nexport const BACKSPACE = 8;\n\n/**\n * Keycode for TAB key.\n */\nexport const TAB = 9;\n\n/**\n * Keycode for ENTER key.\n */\nexport const ENTER = 13;\n\n/**\n * Keycode for ESCAPE key.\n */\nexport const ESCAPE = 27;\n\n/**\n * Keycode for SPACE key.\n */\nexport const SPACE = 32;\n\n/**\n * Keycode for PAGEUP key.\n */\nexport const PAGEUP = 33;\n\n/**\n * Keycode for PAGEDOWN key.\n */\nexport const PAGEDOWN = 34;\n\n/**\n * Keycode for END key.\n */\nexport const END = 35;\n\n/**\n * Keycode for HOME key.\n */\nexport const HOME = 36;\n\n/**\n * Keycode for LEFT key.\n */\nexport const LEFT = 37;\n\n/**\n * Keycode for UP key.\n */\nexport const UP = 38;\n\n/**\n * Keycode for RIGHT key.\n */\nexport const RIGHT = 39;\n\n/**\n * Keycode for DOWN key.\n */\nexport const DOWN = 40;\n\n/**\n * Keycode for DELETE key.\n */\nexport const DELETE = 46;\n\n/**\n * Keycode for F10 key.\n */\nexport const F10 = 121;\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND/META key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Keycode for ZERO key.\n */\nexport const ZERO = 48;\n\nexport { isAppleOS };\n\n/**\n * Capitalise the first character of a string.\n * @param string String to capitalise.\n * @return Capitalised string.\n */\nfunction capitaliseFirstCharacter( string: string ): string {\n\treturn string.length < 2\n\t\t? string.toUpperCase()\n\t\t: string.charAt( 0 ).toUpperCase() + string.slice( 1 );\n}\n\n/**\n * Map the values of an object with a specified callback and return the result object.\n *\n * @template T The object type\n * @template R The return type of the mapping function\n *\n * @param object Object to map values of.\n * @param mapFn Mapping function to apply to each value.\n * @return Object with the same keys and transformed values.\n */\nfunction mapValues< T extends Record< string, any >, R >(\n\tobject: T,\n\tmapFn: ( value: T[ keyof T ] ) => R\n): Record< keyof T, R > {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\tkey,\n\t\t\tmapFn( value ),\n\t\t] )\n\t) as Record< keyof T, R >;\n}\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n */\nexport const modifiers: WPModifierHandler< WPModifier > = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n\n/**\n * An object that contains functions to get raw shortcuts.\n *\n * These are intended for user with the KeyboardShortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * rawShortcut.primary( 'm' )\n * // \"meta+m\"\"\n * ```\n */\nexport const rawShortcut: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( modifier: WPModifier ) => {\n\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\treturn [ ...modifier( _isApple ), character.toLowerCase() ].join(\n\t\t\t\t'+'\n\t\t\t);\n\t\t};\n\t} );\n\n/**\n * Return an array of the parts of a keyboard shortcut chord for display.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcutList.primary( 'm' );\n * // [ \"\u2318\", \"M\" ]\n * ```\n *\n * Keyed map of functions to shortcut sequences.\n */\nexport const displayShortcutList: WPModifierHandler<\n\tWPKeyHandler< string[] >\n> =\n\t/* @__PURE__ */\n\tmapValues(\n\t\tmodifiers,\n\t\t( modifier: WPModifier ): WPKeyHandler< string[] > => {\n\t\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\t\tconst isApple = _isApple();\n\t\t\t\tconst replacementKeyMap = {\n\t\t\t\t\t[ ALT ]: isApple ? '\u2325' : 'Alt',\n\t\t\t\t\t[ CTRL ]: isApple ? '\u2303' : 'Ctrl', // Make sure \u2303 is the U+2303 UP ARROWHEAD unicode character and not the caret character.\n\t\t\t\t\t[ COMMAND ]: '\u2318',\n\t\t\t\t\t[ SHIFT ]: isApple ? '\u21E7' : 'Shift',\n\t\t\t\t};\n\n\t\t\t\tconst modifierKeys = modifier( _isApple ).reduce< string[] >(\n\t\t\t\t\t( accumulator, key ) => {\n\t\t\t\t\t\tconst replacementKey = replacementKeyMap[ key ] ?? key;\n\t\t\t\t\t\t// If on the Mac, adhere to platform convention and don't show plus between keys.\n\t\t\t\t\t\tif ( isApple ) {\n\t\t\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t\t\t},\n\t\t\t\t\t[]\n\t\t\t\t);\n\n\t\t\t\treturn [\n\t\t\t\t\t...modifierKeys,\n\t\t\t\t\tcapitaliseFirstCharacter( character ),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\t);\n\n/**\n * An object that contains functions to display shortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcut.primary( 'm' );\n * // \"\u2318M\"\n * ```\n *\n * Keyed map of functions to display shortcuts.\n */\nexport const displayShortcut: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues(\n\t\tdisplayShortcutList,\n\t\t( shortcutList: WPKeyHandler< string[] > ): WPKeyHandler< string > => {\n\t\t\treturn ( character: string, _isApple = isAppleOS ) =>\n\t\t\t\tshortcutList( character, _isApple ).join( '' );\n\t\t}\n\t);\n\n/**\n * An object that contains functions to return an aria label for a keyboard\n * shortcut.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * shortcutAriaLabel.primary( '.' );\n * // \"Command + Period\"\n * ```\n *\n * Keyed map of functions to shortcut ARIA labels.\n */\nexport const shortcutAriaLabel: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( modifier: WPModifier ): WPKeyHandler< string > => {\n\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\tconst isApple = _isApple();\n\t\t\tconst replacementKeyMap: Record< string, string > = {\n\t\t\t\t[ SHIFT ]: 'Shift',\n\t\t\t\t[ COMMAND ]: isApple ? 'Command' : 'Control',\n\t\t\t\t[ CTRL ]: 'Control',\n\t\t\t\t[ ALT ]: isApple ? 'Option' : 'Alt',\n\t\t\t\t/* translators: comma as in the character ',' */\n\t\t\t\t',': __( 'Comma' ),\n\t\t\t\t/* translators: period as in the character '.' */\n\t\t\t\t'.': __( 'Period' ),\n\t\t\t\t/* translators: backtick as in the character '`' */\n\t\t\t\t'`': __( 'Backtick' ),\n\t\t\t\t/* translators: tilde as in the character '~' */\n\t\t\t\t'~': __( 'Tilde' ),\n\t\t\t};\n\n\t\t\treturn [ ...modifier( _isApple ), character ]\n\t\t\t\t.map( ( key ) =>\n\t\t\t\t\tcapitaliseFirstCharacter( replacementKeyMap[ key ] ?? key )\n\t\t\t\t)\n\t\t\t\t.join( isApple ? ' ' : ' + ' );\n\t\t};\n\t} );\n\n/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param event Keyboard event.\n *\n * @return Active modifier constants.\n */\nfunction getEventModifiers(\n\tevent: ReactKeyboardEvent< HTMLElement > | KeyboardEvent\n): WPModifierPart[] {\n\treturn ( [ ALT, CTRL, COMMAND, SHIFT ] as const ).filter(\n\t\t( key ) =>\n\t\t\t( event as KeyboardEvent )[\n\t\t\t\t`${ key }Key` as 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'\n\t\t\t]\n\t);\n}\n\n/**\n * An object that contains functions to check if a keyboard event matches a\n * predefined shortcut combination.\n *\n * @example\n * ```js\n * // Assuming an event for \u2318M key press:\n * isKeyboardEvent.primary( event, 'm' );\n * // true\n * ```\n *\n * Keyed map of functions to match events.\n */\nexport const isKeyboardEvent: WPModifierHandler< WPEventKeyHandler > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( getModifiers: WPModifier ): WPEventKeyHandler => {\n\t\treturn ( event, character, _isApple = isAppleOS ) => {\n\t\t\tconst mods = getModifiers( _isApple );\n\t\t\tconst eventMods = getEventModifiers( event );\n\n\t\t\tconst replacementWithShiftKeyMap: Record< string, string > = {\n\t\t\t\tComma: ',',\n\t\t\t\tBackslash: '\\\\',\n\t\t\t\t// Windows returns `\\` for both IntlRo and IntlYen.\n\t\t\t\tIntlRo: '\\\\',\n\t\t\t\tIntlYen: '\\\\',\n\t\t\t};\n\n\t\t\tconst modsDiff = mods.filter(\n\t\t\t\t( mod ) => ! eventMods.includes( mod )\n\t\t\t);\n\t\t\tconst eventModsDiff = eventMods.filter(\n\t\t\t\t( mod ) => ! mods.includes( mod )\n\t\t\t);\n\n\t\t\tif ( modsDiff.length > 0 || eventModsDiff.length > 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tlet key = event.key.toLowerCase();\n\n\t\t\tif ( ! character ) {\n\t\t\t\treturn mods.includes( key as WPModifierPart );\n\t\t\t}\n\n\t\t\tif ( event.altKey && character.length === 1 ) {\n\t\t\t\tkey = String.fromCharCode( event.keyCode ).toLowerCase();\n\t\t\t}\n\n\t\t\t// `event.key` returns the value of the key pressed, taking into the state of\n\t\t\t// modifier keys such as `Shift`. If the shift key is pressed, a different\n\t\t\t// value may be returned depending on the keyboard layout. It is necessary to\n\t\t\t// convert to the physical key value that don't take into account keyboard\n\t\t\t// layout or modifier key state.\n\t\t\tif (\n\t\t\t\tevent.shiftKey &&\n\t\t\t\tcharacter.length === 1 &&\n\t\t\t\treplacementWithShiftKeyMap[ event.code ]\n\t\t\t) {\n\t\t\t\tkey = replacementWithShiftKeyMap[ event.code ];\n\t\t\t}\n\n\t\t\t// For backwards compatibility.\n\t\t\tif ( character === 'del' ) {\n\t\t\t\tcharacter = 'delete';\n\t\t\t}\n\n\t\t\treturn key === character.toLowerCase();\n\t\t};\n\t} );\n"],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