@wordpress/keycodes 3.49.0 → 3.51.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 +4 -0
- package/build/index.js +110 -142
- package/build/index.js.map +1 -1
- package/build-module/index.js +84 -90
- package/build-module/index.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/build/index.js
CHANGED
|
@@ -57,122 +57,102 @@ var _platform = require("./platform");
|
|
|
57
57
|
/**
|
|
58
58
|
* Keycode for BACKSPACE key.
|
|
59
59
|
*/
|
|
60
|
-
const BACKSPACE = 8;
|
|
60
|
+
const BACKSPACE = exports.BACKSPACE = 8;
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Keycode for TAB key.
|
|
64
64
|
*/
|
|
65
|
-
exports.
|
|
66
|
-
const TAB = 9;
|
|
65
|
+
const TAB = exports.TAB = 9;
|
|
67
66
|
|
|
68
67
|
/**
|
|
69
68
|
* Keycode for ENTER key.
|
|
70
69
|
*/
|
|
71
|
-
exports.
|
|
72
|
-
const ENTER = 13;
|
|
70
|
+
const ENTER = exports.ENTER = 13;
|
|
73
71
|
|
|
74
72
|
/**
|
|
75
73
|
* Keycode for ESCAPE key.
|
|
76
74
|
*/
|
|
77
|
-
exports.
|
|
78
|
-
const ESCAPE = 27;
|
|
75
|
+
const ESCAPE = exports.ESCAPE = 27;
|
|
79
76
|
|
|
80
77
|
/**
|
|
81
78
|
* Keycode for SPACE key.
|
|
82
79
|
*/
|
|
83
|
-
exports.
|
|
84
|
-
const SPACE = 32;
|
|
80
|
+
const SPACE = exports.SPACE = 32;
|
|
85
81
|
|
|
86
82
|
/**
|
|
87
83
|
* Keycode for PAGEUP key.
|
|
88
84
|
*/
|
|
89
|
-
exports.
|
|
90
|
-
const PAGEUP = 33;
|
|
85
|
+
const PAGEUP = exports.PAGEUP = 33;
|
|
91
86
|
|
|
92
87
|
/**
|
|
93
88
|
* Keycode for PAGEDOWN key.
|
|
94
89
|
*/
|
|
95
|
-
exports.
|
|
96
|
-
const PAGEDOWN = 34;
|
|
90
|
+
const PAGEDOWN = exports.PAGEDOWN = 34;
|
|
97
91
|
|
|
98
92
|
/**
|
|
99
93
|
* Keycode for END key.
|
|
100
94
|
*/
|
|
101
|
-
exports.
|
|
102
|
-
const END = 35;
|
|
95
|
+
const END = exports.END = 35;
|
|
103
96
|
|
|
104
97
|
/**
|
|
105
98
|
* Keycode for HOME key.
|
|
106
99
|
*/
|
|
107
|
-
exports.
|
|
108
|
-
const HOME = 36;
|
|
100
|
+
const HOME = exports.HOME = 36;
|
|
109
101
|
|
|
110
102
|
/**
|
|
111
103
|
* Keycode for LEFT key.
|
|
112
104
|
*/
|
|
113
|
-
exports.
|
|
114
|
-
const LEFT = 37;
|
|
105
|
+
const LEFT = exports.LEFT = 37;
|
|
115
106
|
|
|
116
107
|
/**
|
|
117
108
|
* Keycode for UP key.
|
|
118
109
|
*/
|
|
119
|
-
exports.
|
|
120
|
-
const UP = 38;
|
|
110
|
+
const UP = exports.UP = 38;
|
|
121
111
|
|
|
122
112
|
/**
|
|
123
113
|
* Keycode for RIGHT key.
|
|
124
114
|
*/
|
|
125
|
-
exports.
|
|
126
|
-
const RIGHT = 39;
|
|
115
|
+
const RIGHT = exports.RIGHT = 39;
|
|
127
116
|
|
|
128
117
|
/**
|
|
129
118
|
* Keycode for DOWN key.
|
|
130
119
|
*/
|
|
131
|
-
exports.
|
|
132
|
-
const DOWN = 40;
|
|
120
|
+
const DOWN = exports.DOWN = 40;
|
|
133
121
|
|
|
134
122
|
/**
|
|
135
123
|
* Keycode for DELETE key.
|
|
136
124
|
*/
|
|
137
|
-
exports.
|
|
138
|
-
const DELETE = 46;
|
|
125
|
+
const DELETE = exports.DELETE = 46;
|
|
139
126
|
|
|
140
127
|
/**
|
|
141
128
|
* Keycode for F10 key.
|
|
142
129
|
*/
|
|
143
|
-
exports.
|
|
144
|
-
const F10 = 121;
|
|
130
|
+
const F10 = exports.F10 = 121;
|
|
145
131
|
|
|
146
132
|
/**
|
|
147
133
|
* Keycode for ALT key.
|
|
148
134
|
*/
|
|
149
|
-
exports.
|
|
150
|
-
const ALT = 'alt';
|
|
135
|
+
const ALT = exports.ALT = 'alt';
|
|
151
136
|
|
|
152
137
|
/**
|
|
153
138
|
* Keycode for CTRL key.
|
|
154
139
|
*/
|
|
155
|
-
exports.
|
|
156
|
-
const CTRL = 'ctrl';
|
|
140
|
+
const CTRL = exports.CTRL = 'ctrl';
|
|
157
141
|
|
|
158
142
|
/**
|
|
159
143
|
* Keycode for COMMAND/META key.
|
|
160
144
|
*/
|
|
161
|
-
exports.
|
|
162
|
-
const COMMAND = 'meta';
|
|
145
|
+
const COMMAND = exports.COMMAND = 'meta';
|
|
163
146
|
|
|
164
147
|
/**
|
|
165
148
|
* Keycode for SHIFT key.
|
|
166
149
|
*/
|
|
167
|
-
exports.
|
|
168
|
-
const SHIFT = 'shift';
|
|
150
|
+
const SHIFT = exports.SHIFT = 'shift';
|
|
169
151
|
|
|
170
152
|
/**
|
|
171
153
|
* Keycode for ZERO key.
|
|
172
154
|
*/
|
|
173
|
-
exports.
|
|
174
|
-
const ZERO = 48;
|
|
175
|
-
exports.ZERO = ZERO;
|
|
155
|
+
const ZERO = exports.ZERO = 48;
|
|
176
156
|
/**
|
|
177
157
|
* Capitalise the first character of a string.
|
|
178
158
|
* @param {string} string String to capitalise.
|
|
@@ -202,7 +182,7 @@ function mapValues(object, mapFn) {
|
|
|
202
182
|
*
|
|
203
183
|
* @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}
|
|
204
184
|
*/
|
|
205
|
-
const modifiers = {
|
|
185
|
+
const modifiers = exports.modifiers = {
|
|
206
186
|
primary: _isApple => _isApple() ? [COMMAND] : [CTRL],
|
|
207
187
|
primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
|
|
208
188
|
primaryAlt: _isApple => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
|
|
@@ -231,12 +211,10 @@ const modifiers = {
|
|
|
231
211
|
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw
|
|
232
212
|
* shortcuts.
|
|
233
213
|
*/
|
|
234
|
-
exports.
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
);
|
|
214
|
+
const rawShortcut = exports.rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
|
215
|
+
return /** @type {WPKeyHandler<string>} */(character, _isApple = _platform.isAppleOS) => {
|
|
216
|
+
return [...modifier(_isApple), character.toLowerCase()].join('+');
|
|
217
|
+
};
|
|
240
218
|
});
|
|
241
219
|
|
|
242
220
|
/**
|
|
@@ -252,29 +230,27 @@ const rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modifier) =>
|
|
|
252
230
|
* @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to
|
|
253
231
|
* shortcut sequences.
|
|
254
232
|
*/
|
|
255
|
-
exports.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
);
|
|
233
|
+
const displayShortcutList = exports.displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
|
234
|
+
return /** @type {WPKeyHandler<string[]>} */(character, _isApple = _platform.isAppleOS) => {
|
|
235
|
+
const isApple = _isApple();
|
|
236
|
+
const replacementKeyMap = {
|
|
237
|
+
[ALT]: isApple ? '⌥' : 'Alt',
|
|
238
|
+
[CTRL]: isApple ? '⌃' : 'Ctrl',
|
|
239
|
+
// Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
|
|
240
|
+
[COMMAND]: '⌘',
|
|
241
|
+
[SHIFT]: isApple ? '⇧' : 'Shift'
|
|
242
|
+
};
|
|
243
|
+
const modifierKeys = modifier(_isApple).reduce((accumulator, key) => {
|
|
244
|
+
var _replacementKeyMap$ke;
|
|
245
|
+
const replacementKey = (_replacementKeyMap$ke = replacementKeyMap[key]) !== null && _replacementKeyMap$ke !== void 0 ? _replacementKeyMap$ke : key;
|
|
246
|
+
// If on the Mac, adhere to platform convention and don't show plus between keys.
|
|
247
|
+
if (isApple) {
|
|
248
|
+
return [...accumulator, replacementKey];
|
|
249
|
+
}
|
|
250
|
+
return [...accumulator, replacementKey, '+'];
|
|
251
|
+
}, /** @type {string[]} */[]);
|
|
252
|
+
return [...modifierKeys, capitaliseFirstCharacter(character)];
|
|
253
|
+
};
|
|
278
254
|
});
|
|
279
255
|
|
|
280
256
|
/**
|
|
@@ -290,10 +266,8 @@ const displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier} */modi
|
|
|
290
266
|
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
|
|
291
267
|
* display shortcuts.
|
|
292
268
|
*/
|
|
293
|
-
exports.
|
|
294
|
-
|
|
295
|
-
return (/** @type {WPKeyHandler<string>} */(character, _isApple = _platform.isAppleOS) => shortcutList(character, _isApple).join('')
|
|
296
|
-
);
|
|
269
|
+
const displayShortcut = exports.displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKeyHandler<string[]>} */shortcutList) => {
|
|
270
|
+
return /** @type {WPKeyHandler<string>} */(character, _isApple = _platform.isAppleOS) => shortcutList(character, _isApple).join('');
|
|
297
271
|
});
|
|
298
272
|
|
|
299
273
|
/**
|
|
@@ -310,31 +284,29 @@ const displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKeyHandler
|
|
|
310
284
|
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
|
|
311
285
|
* shortcut ARIA labels.
|
|
312
286
|
*/
|
|
313
|
-
exports.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
);
|
|
287
|
+
const shortcutAriaLabel = exports.shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
|
288
|
+
return /** @type {WPKeyHandler<string>} */(character, _isApple = _platform.isAppleOS) => {
|
|
289
|
+
const isApple = _isApple();
|
|
290
|
+
/** @type {Record<string,string>} */
|
|
291
|
+
const replacementKeyMap = {
|
|
292
|
+
[SHIFT]: 'Shift',
|
|
293
|
+
[COMMAND]: isApple ? 'Command' : 'Control',
|
|
294
|
+
[CTRL]: 'Control',
|
|
295
|
+
[ALT]: isApple ? 'Option' : 'Alt',
|
|
296
|
+
/* translators: comma as in the character ',' */
|
|
297
|
+
',': (0, _i18n.__)('Comma'),
|
|
298
|
+
/* translators: period as in the character '.' */
|
|
299
|
+
'.': (0, _i18n.__)('Period'),
|
|
300
|
+
/* translators: backtick as in the character '`' */
|
|
301
|
+
'`': (0, _i18n.__)('Backtick'),
|
|
302
|
+
/* translators: tilde as in the character '~' */
|
|
303
|
+
'~': (0, _i18n.__)('Tilde')
|
|
304
|
+
};
|
|
305
|
+
return [...modifier(_isApple), character].map(key => {
|
|
306
|
+
var _replacementKeyMap$ke2;
|
|
307
|
+
return capitaliseFirstCharacter((_replacementKeyMap$ke2 = replacementKeyMap[key]) !== null && _replacementKeyMap$ke2 !== void 0 ? _replacementKeyMap$ke2 : key);
|
|
308
|
+
}).join(isApple ? ' ' : ' + ');
|
|
309
|
+
};
|
|
338
310
|
});
|
|
339
311
|
|
|
340
312
|
/**
|
|
@@ -345,11 +317,9 @@ const shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} */modifi
|
|
|
345
317
|
*
|
|
346
318
|
* @return {Array<WPModifierPart>} Active modifier constants.
|
|
347
319
|
*/
|
|
348
|
-
exports.shortcutAriaLabel = shortcutAriaLabel;
|
|
349
320
|
function getEventModifiers(event) {
|
|
350
|
-
return
|
|
351
|
-
|
|
352
|
-
);
|
|
321
|
+
return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[( /** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
|
|
322
|
+
`${key}Key`)]);
|
|
353
323
|
}
|
|
354
324
|
|
|
355
325
|
/**
|
|
@@ -366,47 +336,45 @@ function getEventModifiers(event) {
|
|
|
366
336
|
* @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions
|
|
367
337
|
* to match events.
|
|
368
338
|
*/
|
|
369
|
-
const isKeyboardEvent = mapValues(modifiers, ( /** @type {WPModifier} */getModifiers) => {
|
|
370
|
-
return
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
339
|
+
const isKeyboardEvent = exports.isKeyboardEvent = mapValues(modifiers, ( /** @type {WPModifier} */getModifiers) => {
|
|
340
|
+
return /** @type {WPEventKeyHandler} */(event, character, _isApple = _platform.isAppleOS) => {
|
|
341
|
+
const mods = getModifiers(_isApple);
|
|
342
|
+
const eventMods = getEventModifiers(event);
|
|
343
|
+
/** @type {Record<string,string>} */
|
|
344
|
+
const replacementWithShiftKeyMap = {
|
|
345
|
+
Comma: ',',
|
|
346
|
+
Backslash: '\\',
|
|
347
|
+
// Windows returns `\` for both IntlRo and IntlYen.
|
|
348
|
+
IntlRo: '\\',
|
|
349
|
+
IntlYen: '\\'
|
|
350
|
+
};
|
|
351
|
+
const modsDiff = mods.filter(mod => !eventMods.includes(mod));
|
|
352
|
+
const eventModsDiff = eventMods.filter(mod => !mods.includes(mod));
|
|
353
|
+
if (modsDiff.length > 0 || eventModsDiff.length > 0) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
let key = event.key.toLowerCase();
|
|
357
|
+
if (!character) {
|
|
358
|
+
return mods.includes( /** @type {WPModifierPart} */key);
|
|
359
|
+
}
|
|
360
|
+
if (event.altKey && character.length === 1) {
|
|
361
|
+
key = String.fromCharCode(event.keyCode).toLowerCase();
|
|
362
|
+
}
|
|
393
363
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
364
|
+
// `event.key` returns the value of the key pressed, taking into the state of
|
|
365
|
+
// modifier keys such as `Shift`. If the shift key is pressed, a different
|
|
366
|
+
// value may be returned depending on the keyboard layout. It is necessary to
|
|
367
|
+
// convert to the physical key value that don't take into account keyboard
|
|
368
|
+
// layout or modifier key state.
|
|
369
|
+
if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) {
|
|
370
|
+
key = replacementWithShiftKeyMap[event.code];
|
|
371
|
+
}
|
|
402
372
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
return key === character.toLowerCase();
|
|
373
|
+
// For backwards compatibility.
|
|
374
|
+
if (character === 'del') {
|
|
375
|
+
character = 'delete';
|
|
408
376
|
}
|
|
409
|
-
|
|
377
|
+
return key === character.toLowerCase();
|
|
378
|
+
};
|
|
410
379
|
});
|
|
411
|
-
exports.isKeyboardEvent = isKeyboardEvent;
|
|
412
380
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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.js"],"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/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\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 *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: import('react').KeyboardEvent<HTMLElement> | KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/** @typedef {( isApple: () => boolean ) => WPModifierPart[]} WPModifier */\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 String to capitalise.\n * @return {string} Capitalised string.\n */\nfunction capitaliseFirstCharacter( 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 {{ [s: string]: any; } | ArrayLike<any>} T\n *\n * @param {T} object Object to map values of.\n * @param {( value: any ) => any} mapFn Mapping function\n *\n * @return {any} Active modifier constants.\n */\nfunction mapValues( object, mapFn ) {\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);\n}\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\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 *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\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/**\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 * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\tconst replacementKeyMap = {\n\t\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\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[ COMMAND ]: '⌘',\n\t\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t\t};\n\n\t\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t\t( accumulator, key ) => {\n\t\t\t\t\tconst replacementKey = replacementKeyMap[ key ] ?? key;\n\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\tif ( isApple ) {\n\t\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t\t},\n\t\t\t\t/** @type {string[]} */ ( [] )\n\t\t\t);\n\n\t\t\treturn [ ...modifierKeys, capitaliseFirstCharacter( character ) ];\n\t\t};\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( /** @type {WPKeyHandler<string[]>} */ shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementKeyMap = {\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/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {import('react').KeyboardEvent<HTMLElement> | KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\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 * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ getModifiers ) => {\n\t\treturn /** @type {WPEventKeyHandler} */ (\n\t\t\tevent,\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst mods = getModifiers( _isApple );\n\t\t\tconst eventMods = getEventModifiers( event );\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementWithShiftKeyMap = {\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( /** @type {WPModifierPart} */ ( key ) );\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);\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;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACO,MAAME,SAAS,GAAG,CAAC;;AAE1B;AACA;AACA;AAFAC,OAAA,CAAAD,SAAA,GAAAA,SAAA;AAGO,MAAME,GAAG,GAAG,CAAC;;AAEpB;AACA;AACA;AAFAD,OAAA,CAAAC,GAAA,GAAAA,GAAA;AAGO,MAAMC,KAAK,GAAG,EAAE;;AAEvB;AACA;AACA;AAFAF,OAAA,CAAAE,KAAA,GAAAA,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IAAKmC,KAAK,CAACe,MAAM,IAAIjC,SAAS,CAAC5B,MAAM,KAAK,CAAC,EAAG;QAC7CW,GAAG,GAAGmD,MAAM,CAACC,YAAY,CAAEjB,KAAK,CAACkB,OAAQ,CAAC,CAAClC,WAAW,CAAC,CAAC;MACzD;;MAEA;MACA;MACA;MACA;MACA;MACA,IACCgB,KAAK,CAACmB,QAAQ,IACdrC,SAAS,CAAC5B,MAAM,KAAK,CAAC,IACtBoD,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE,EACvC;QACDvD,GAAG,GAAGyC,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE;MAC/C;;MAEA;MACA,IAAKtC,SAAS,KAAK,KAAK,EAAG;QAC1BA,SAAS,GAAG,QAAQ;MACrB;MAEA,OAAOjB,GAAG,KAAKiB,SAAS,CAACE,WAAW,CAAC,CAAC;IACvC;EAAC;AACF,CACD,CAAC;AAACpD,OAAA,CAAAsE,eAAA,GAAAA,eAAA"}
|
|
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.js"],"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/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\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 *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: import('react').KeyboardEvent<HTMLElement> | KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/** @typedef {( isApple: () => boolean ) => WPModifierPart[]} WPModifier */\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 String to capitalise.\n * @return {string} Capitalised string.\n */\nfunction capitaliseFirstCharacter( 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 {{ [s: string]: any; } | ArrayLike<any>} T\n *\n * @param {T} object Object to map values of.\n * @param {( value: any ) => any} mapFn Mapping function\n *\n * @return {any} Active modifier constants.\n */\nfunction mapValues( object, mapFn ) {\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);\n}\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\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 *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\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/**\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 * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\tconst replacementKeyMap = {\n\t\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\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[ COMMAND ]: '⌘',\n\t\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t\t};\n\n\t\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t\t( accumulator, key ) => {\n\t\t\t\t\tconst replacementKey = replacementKeyMap[ key ] ?? key;\n\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\tif ( isApple ) {\n\t\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t\t},\n\t\t\t\t/** @type {string[]} */ ( [] )\n\t\t\t);\n\n\t\t\treturn [ ...modifierKeys, capitaliseFirstCharacter( character ) ];\n\t\t};\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( /** @type {WPKeyHandler<string[]>} */ shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementKeyMap = {\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/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {import('react').KeyboardEvent<HTMLElement> | KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\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 * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ getModifiers ) => {\n\t\treturn /** @type {WPEventKeyHandler} */ (\n\t\t\tevent,\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst mods = getModifiers( _isApple );\n\t\t\tconst eventMods = getEventModifiers( event );\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementWithShiftKeyMap = {\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( /** @type {WPModifierPart} */ ( key ) );\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);\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;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;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;;AAExB;AACA;AACA;AACO,MAAMC,QAAQ,GAAAN,OAAA,CAAAM,QAAA,GAAG,EAAE;;AAE1B;AACA;AACA;AACO,MAAMC,GAAG,GAAAP,OAAA,CAAAO,GAAA,GAAG,EAAE;;AAErB;AACA;AACA;AACO,MAAMC,IAAI,GAAAR,OAAA,CAAAQ,IAAA,GAAG,EAAE;;AAEtB;AACA;AACA;AACO,MAAMC,IAAI,GAAAT,OAAA,CAAAS,IAAA,GAAG,EAAE;;AAEtB;AACA;AACA;AACO,MAAMC,EAAE,GAAAV,OAAA,CAAAU,EAAA,GAAG,EAAE;;AAEpB;AACA;AACA;AACO,MAAMC,KAAK,GAAAX,OAAA,CAAAW,KAAA,GAAG,EAAE;;A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QAAQ,CAACzD,MAAM,GAAG,CAAC,IAAI4D,aAAa,CAAC5D,MAAM,GAAG,CAAC,EAAG;MACtD,OAAO,KAAK;IACb;IAEA,IAAIW,GAAG,GAAGmC,KAAK,CAACnC,GAAG,CAACmB,WAAW,CAAC,CAAC;IAEjC,IAAK,CAAEF,SAAS,EAAG;MAClB,OAAOsB,IAAI,CAACS,QAAQ,EAAE,6BAAgChD,GAAM,CAAC;IAC9D;IAEA,IAAKmC,KAAK,CAACe,MAAM,IAAIjC,SAAS,CAAC5B,MAAM,KAAK,CAAC,EAAG;MAC7CW,GAAG,GAAGmD,MAAM,CAACC,YAAY,CAAEjB,KAAK,CAACkB,OAAQ,CAAC,CAAClC,WAAW,CAAC,CAAC;IACzD;;IAEA;IACA;IACA;IACA;IACA;IACA,IACCgB,KAAK,CAACmB,QAAQ,IACdrC,SAAS,CAAC5B,MAAM,KAAK,CAAC,IACtBoD,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE,EACvC;MACDvD,GAAG,GAAGyC,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE;IAC/C;;IAEA;IACA,IAAKtC,SAAS,KAAK,KAAK,EAAG;MAC1BA,SAAS,GAAG,QAAQ;IACrB;IAEA,OAAOjB,GAAG,KAAKiB,SAAS,CAACE,WAAW,CAAC,CAAC;EACvC,CAAC;AACF,CACD,CAAC"}
|
package/build-module/index.js
CHANGED
|
@@ -201,10 +201,9 @@ export const modifiers = {
|
|
|
201
201
|
* shortcuts.
|
|
202
202
|
*/
|
|
203
203
|
export const rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
|
204
|
-
return
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
);
|
|
204
|
+
return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
|
|
205
|
+
return [...modifier(_isApple), character.toLowerCase()].join('+');
|
|
206
|
+
};
|
|
208
207
|
});
|
|
209
208
|
|
|
210
209
|
/**
|
|
@@ -221,27 +220,26 @@ export const rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modif
|
|
|
221
220
|
* shortcut sequences.
|
|
222
221
|
*/
|
|
223
222
|
export const displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
|
224
|
-
return
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
);
|
|
223
|
+
return /** @type {WPKeyHandler<string[]>} */(character, _isApple = isAppleOS) => {
|
|
224
|
+
const isApple = _isApple();
|
|
225
|
+
const replacementKeyMap = {
|
|
226
|
+
[ALT]: isApple ? '⌥' : 'Alt',
|
|
227
|
+
[CTRL]: isApple ? '⌃' : 'Ctrl',
|
|
228
|
+
// Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
|
|
229
|
+
[COMMAND]: '⌘',
|
|
230
|
+
[SHIFT]: isApple ? '⇧' : 'Shift'
|
|
231
|
+
};
|
|
232
|
+
const modifierKeys = modifier(_isApple).reduce((accumulator, key) => {
|
|
233
|
+
var _replacementKeyMap$ke;
|
|
234
|
+
const replacementKey = (_replacementKeyMap$ke = replacementKeyMap[key]) !== null && _replacementKeyMap$ke !== void 0 ? _replacementKeyMap$ke : key;
|
|
235
|
+
// If on the Mac, adhere to platform convention and don't show plus between keys.
|
|
236
|
+
if (isApple) {
|
|
237
|
+
return [...accumulator, replacementKey];
|
|
238
|
+
}
|
|
239
|
+
return [...accumulator, replacementKey, '+'];
|
|
240
|
+
}, /** @type {string[]} */[]);
|
|
241
|
+
return [...modifierKeys, capitaliseFirstCharacter(character)];
|
|
242
|
+
};
|
|
245
243
|
});
|
|
246
244
|
|
|
247
245
|
/**
|
|
@@ -258,8 +256,7 @@ export const displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier}
|
|
|
258
256
|
* display shortcuts.
|
|
259
257
|
*/
|
|
260
258
|
export const displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKeyHandler<string[]>} */shortcutList) => {
|
|
261
|
-
return
|
|
262
|
-
);
|
|
259
|
+
return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => shortcutList(character, _isApple).join('');
|
|
263
260
|
});
|
|
264
261
|
|
|
265
262
|
/**
|
|
@@ -277,29 +274,28 @@ export const displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKey
|
|
|
277
274
|
* shortcut ARIA labels.
|
|
278
275
|
*/
|
|
279
276
|
export const shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
|
|
280
|
-
return
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
);
|
|
277
|
+
return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
|
|
278
|
+
const isApple = _isApple();
|
|
279
|
+
/** @type {Record<string,string>} */
|
|
280
|
+
const replacementKeyMap = {
|
|
281
|
+
[SHIFT]: 'Shift',
|
|
282
|
+
[COMMAND]: isApple ? 'Command' : 'Control',
|
|
283
|
+
[CTRL]: 'Control',
|
|
284
|
+
[ALT]: isApple ? 'Option' : 'Alt',
|
|
285
|
+
/* translators: comma as in the character ',' */
|
|
286
|
+
',': __('Comma'),
|
|
287
|
+
/* translators: period as in the character '.' */
|
|
288
|
+
'.': __('Period'),
|
|
289
|
+
/* translators: backtick as in the character '`' */
|
|
290
|
+
'`': __('Backtick'),
|
|
291
|
+
/* translators: tilde as in the character '~' */
|
|
292
|
+
'~': __('Tilde')
|
|
293
|
+
};
|
|
294
|
+
return [...modifier(_isApple), character].map(key => {
|
|
295
|
+
var _replacementKeyMap$ke2;
|
|
296
|
+
return capitaliseFirstCharacter((_replacementKeyMap$ke2 = replacementKeyMap[key]) !== null && _replacementKeyMap$ke2 !== void 0 ? _replacementKeyMap$ke2 : key);
|
|
297
|
+
}).join(isApple ? ' ' : ' + ');
|
|
298
|
+
};
|
|
303
299
|
});
|
|
304
300
|
|
|
305
301
|
/**
|
|
@@ -311,9 +307,8 @@ export const shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} *
|
|
|
311
307
|
* @return {Array<WPModifierPart>} Active modifier constants.
|
|
312
308
|
*/
|
|
313
309
|
function getEventModifiers(event) {
|
|
314
|
-
return
|
|
315
|
-
|
|
316
|
-
);
|
|
310
|
+
return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[( /** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
|
|
311
|
+
`${key}Key`)]);
|
|
317
312
|
}
|
|
318
313
|
|
|
319
314
|
/**
|
|
@@ -331,45 +326,44 @@ function getEventModifiers(event) {
|
|
|
331
326
|
* to match events.
|
|
332
327
|
*/
|
|
333
328
|
export const isKeyboardEvent = mapValues(modifiers, ( /** @type {WPModifier} */getModifiers) => {
|
|
334
|
-
return
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
329
|
+
return /** @type {WPEventKeyHandler} */(event, character, _isApple = isAppleOS) => {
|
|
330
|
+
const mods = getModifiers(_isApple);
|
|
331
|
+
const eventMods = getEventModifiers(event);
|
|
332
|
+
/** @type {Record<string,string>} */
|
|
333
|
+
const replacementWithShiftKeyMap = {
|
|
334
|
+
Comma: ',',
|
|
335
|
+
Backslash: '\\',
|
|
336
|
+
// Windows returns `\` for both IntlRo and IntlYen.
|
|
337
|
+
IntlRo: '\\',
|
|
338
|
+
IntlYen: '\\'
|
|
339
|
+
};
|
|
340
|
+
const modsDiff = mods.filter(mod => !eventMods.includes(mod));
|
|
341
|
+
const eventModsDiff = eventMods.filter(mod => !mods.includes(mod));
|
|
342
|
+
if (modsDiff.length > 0 || eventModsDiff.length > 0) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
let key = event.key.toLowerCase();
|
|
346
|
+
if (!character) {
|
|
347
|
+
return mods.includes( /** @type {WPModifierPart} */key);
|
|
348
|
+
}
|
|
349
|
+
if (event.altKey && character.length === 1) {
|
|
350
|
+
key = String.fromCharCode(event.keyCode).toLowerCase();
|
|
351
|
+
}
|
|
357
352
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
353
|
+
// `event.key` returns the value of the key pressed, taking into the state of
|
|
354
|
+
// modifier keys such as `Shift`. If the shift key is pressed, a different
|
|
355
|
+
// value may be returned depending on the keyboard layout. It is necessary to
|
|
356
|
+
// convert to the physical key value that don't take into account keyboard
|
|
357
|
+
// layout or modifier key state.
|
|
358
|
+
if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) {
|
|
359
|
+
key = replacementWithShiftKeyMap[event.code];
|
|
360
|
+
}
|
|
366
361
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
return key === character.toLowerCase();
|
|
362
|
+
// For backwards compatibility.
|
|
363
|
+
if (character === 'del') {
|
|
364
|
+
character = 'delete';
|
|
372
365
|
}
|
|
373
|
-
|
|
366
|
+
return key === character.toLowerCase();
|
|
367
|
+
};
|
|
374
368
|
});
|
|
375
369
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","isAppleOS","BACKSPACE","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","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.js"],"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/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\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 *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: import('react').KeyboardEvent<HTMLElement> | KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/** @typedef {( isApple: () => boolean ) => WPModifierPart[]} WPModifier */\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 String to capitalise.\n * @return {string} Capitalised string.\n */\nfunction capitaliseFirstCharacter( 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 {{ [s: string]: any; } | ArrayLike<any>} T\n *\n * @param {T} object Object to map values of.\n * @param {( value: any ) => any} mapFn Mapping function\n *\n * @return {any} Active modifier constants.\n */\nfunction mapValues( object, mapFn ) {\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);\n}\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\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 *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\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/**\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 * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\tconst replacementKeyMap = {\n\t\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\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[ COMMAND ]: '⌘',\n\t\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t\t};\n\n\t\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t\t( accumulator, key ) => {\n\t\t\t\t\tconst replacementKey = replacementKeyMap[ key ] ?? key;\n\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\tif ( isApple ) {\n\t\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t\t},\n\t\t\t\t/** @type {string[]} */ ( [] )\n\t\t\t);\n\n\t\t\treturn [ ...modifierKeys, capitaliseFirstCharacter( character ) ];\n\t\t};\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( /** @type {WPKeyHandler<string[]>} */ shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementKeyMap = {\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/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {import('react').KeyboardEvent<HTMLElement> | KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\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 * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ getModifiers ) => {\n\t\treturn /** @type {WPEventKeyHandler} */ (\n\t\t\tevent,\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst mods = getModifiers( _isApple );\n\t\t\tconst eventMods = getEventModifiers( event );\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementWithShiftKeyMap = {\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( /** @type {WPModifierPart} */ ( key ) );\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);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,YAAY;;AAEtC;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,CAAC;;AAE1B;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAG,CAAC;;AAEpB;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAG,EAAE;;AAEvB;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAG,EAAE;;AAExB;AACA;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,GAAGT,SAAS,CAACJ,MAAM,CACnCW,GAAG,IAAM,CAAER,IAAI,CAACS,QAAQ,CAAED,GAAI,CACjC,CAAC;MAED,IAAKD,QAAQ,CAACvD,MAAM,GAAG,CAAC,IAAI0D,aAAa,CAAC1D,MAAM,GAAG,CAAC,EAAG;QACtD,OAAO,KAAK;MACb;MAEA,IAAIW,GAAG,GAAGiC,KAAK,CAACjC,GAAG,CAACkB,WAAW,CAAC,CAAC;MAEjC,IAAK,CAAED,SAAS,EAAG;QAClB,OAAOoB,IAAI,CAACS,QAAQ,EAAE,6BAAgC9C,GAAM,CAAC;MAC9D;MAEA,IAAKiC,KAAK,CAACe,MAAM,IAAI/B,SAAS,CAAC5B,MAAM,KAAK,CAAC,EAAG;QAC7CW,GAAG,GAAGiD,MAAM,CAACC,YAAY,CAAEjB,KAAK,CAACkB,OAAQ,CAAC,CAACjC,WAAW,CAAC,CAAC;MACzD;;MAEA;MACA;MACA;MACA;MACA;MACA,IACCe,KAAK,CAACmB,QAAQ,IACdnC,SAAS,CAAC5B,MAAM,KAAK,CAAC,IACtBkD,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE,EACvC;QACDrD,GAAG,GAAGuC,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE;MAC/C;;MAEA;MACA,IAAKpC,SAAS,KAAK,KAAK,EAAG;QAC1BA,SAAS,GAAG,QAAQ;MACrB;MAEA,OAAOjB,GAAG,KAAKiB,SAAS,CAACC,WAAW,CAAC,CAAC;IACvC;EAAC;AACF,CACD,CAAC"}
|
|
1
|
+
{"version":3,"names":["__","isAppleOS","BACKSPACE","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","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.js"],"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/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\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 *\n * @template T\n *\n * @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: import('react').KeyboardEvent<HTMLElement> | KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/** @typedef {( isApple: () => boolean ) => WPModifierPart[]} WPModifier */\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 String to capitalise.\n * @return {string} Capitalised string.\n */\nfunction capitaliseFirstCharacter( 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 {{ [s: string]: any; } | ArrayLike<any>} T\n *\n * @param {T} object Object to map values of.\n * @param {( value: any ) => any} mapFn Mapping function\n *\n * @return {any} Active modifier constants.\n */\nfunction mapValues( object, mapFn ) {\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);\n}\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\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 *\n * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\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/**\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 * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string[]>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\tconst replacementKeyMap = {\n\t\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\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[ COMMAND ]: '⌘',\n\t\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t\t};\n\n\t\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t\t( accumulator, key ) => {\n\t\t\t\t\tconst replacementKey = replacementKeyMap[ key ] ?? key;\n\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\tif ( isApple ) {\n\t\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t\t},\n\t\t\t\t/** @type {string[]} */ ( [] )\n\t\t\t);\n\n\t\t\treturn [ ...modifierKeys, capitaliseFirstCharacter( character ) ];\n\t\t};\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( /** @type {WPKeyHandler<string[]>} */ shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\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 * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ modifier ) => {\n\t\treturn /** @type {WPKeyHandler<string>} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst isApple = _isApple();\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementKeyMap = {\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/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {import('react').KeyboardEvent<HTMLElement> | KeyboardEvent} event Keyboard event.\n *\n * @return {Array<WPModifierPart>} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ (\n\t\t\t\t\t`${ key }Key`\n\t\t\t\t)\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 * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues(\n\tmodifiers,\n\t( /** @type {WPModifier} */ getModifiers ) => {\n\t\treturn /** @type {WPEventKeyHandler} */ (\n\t\t\tevent,\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => {\n\t\t\tconst mods = getModifiers( _isApple );\n\t\t\tconst eventMods = getEventModifiers( event );\n\t\t\t/** @type {Record<string,string>} */\n\t\t\tconst replacementWithShiftKeyMap = {\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( /** @type {WPModifierPart} */ ( key ) );\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);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,YAAY;;AAEtC;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,CAAC;;AAE1B;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAG,CAAC;;AAEpB;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAG,EAAE;;AAEvB;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAG,EAAE;;AAExB;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAG,EAAE;;AAEvB;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAG,EAAE;;AAExB;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,EAAE;;AAE1B;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAG,EAAE;;AAErB;AACA;AACA;AACA,OAAO,MAAMC,IAAI,GAAG,EAAE;;AAEtB;AACA;AACA;AACA,OAAO,MAAMC,IAAI,GAAG,EAAE;;AAEtB;AACA;AACA;AACA,OAAO,MAAMC,EAAE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E,6BAAgC9C,GAAM,CAAC;IAC9D;IAEA,IAAKiC,KAAK,CAACe,MAAM,IAAI/B,SAAS,CAAC5B,MAAM,KAAK,CAAC,EAAG;MAC7CW,GAAG,GAAGiD,MAAM,CAACC,YAAY,CAAEjB,KAAK,CAACkB,OAAQ,CAAC,CAACjC,WAAW,CAAC,CAAC;IACzD;;IAEA;IACA;IACA;IACA;IACA;IACA,IACCe,KAAK,CAACmB,QAAQ,IACdnC,SAAS,CAAC5B,MAAM,KAAK,CAAC,IACtBkD,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE,EACvC;MACDrD,GAAG,GAAGuC,0BAA0B,CAAEN,KAAK,CAACoB,IAAI,CAAE;IAC/C;;IAEA;IACA,IAAKpC,SAAS,KAAK,KAAK,EAAG;MAC1BA,SAAS,GAAG,QAAQ;IACrB;IAEA,OAAOjB,GAAG,KAAKiB,SAAS,CAACC,WAAW,CAAC,CAAC;EACvC,CAAC;AACF,CACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/keycodes",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.51.0",
|
|
4
4
|
"description": "Keycodes utilities for WordPress. Used to check for keyboard events across browsers/operating systems.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.16.0",
|
|
31
|
-
"@wordpress/i18n": "^4.
|
|
31
|
+
"@wordpress/i18n": "^4.51.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "eb796371e9630636a4a8837033807b0c4a06ed67"
|
|
37
37
|
}
|