@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/build/platform.js CHANGED
@@ -1,26 +1,38 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var platform_exports = {};
20
+ __export(platform_exports, {
21
+ isAppleOS: () => isAppleOS
5
22
  });
6
- exports.isAppleOS = isAppleOS;
7
- /**
8
- * Return true if platform is MacOS.
9
- *
10
- * @param _window window object by default; used for DI testing.
11
- *
12
- * @return True if MacOS; false otherwise.
13
- */
23
+ module.exports = __toCommonJS(platform_exports);
14
24
  function isAppleOS(_window) {
15
25
  if (!_window) {
16
- if (typeof window === 'undefined') {
26
+ if (typeof window === "undefined") {
17
27
  return false;
18
28
  }
19
29
  _window = window;
20
30
  }
21
- const {
22
- platform
23
- } = _window.navigator;
24
- return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
31
+ const { platform } = _window.navigator;
32
+ return platform.indexOf("Mac") !== -1 || ["iPad", "iPhone"].includes(platform);
25
33
  }
26
- //# sourceMappingURL=platform.js.map
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ isAppleOS
37
+ });
38
+ //# sourceMappingURL=platform.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["isAppleOS","_window","window","platform","navigator","indexOf","includes"],"sources":["@wordpress/keycodes/src/platform.ts"],"sourcesContent":["/**\n * Return true if platform is MacOS.\n *\n * @param _window window object by default; used for DI testing.\n *\n * @return True if MacOS; false otherwise.\n */\nexport function isAppleOS( _window?: Window ): boolean {\n\tif ( ! _window ) {\n\t\tif ( typeof window === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t_window = window;\n\t}\n\n\tconst { platform } = _window.navigator;\n\n\treturn (\n\t\tplatform.indexOf( 'Mac' ) !== -1 ||\n\t\t[ 'iPad', 'iPhone' ].includes( platform )\n\t);\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAASA,CAAEC,OAAgB,EAAY;EACtD,IAAK,CAAEA,OAAO,EAAG;IAChB,IAAK,OAAOC,MAAM,KAAK,WAAW,EAAG;MACpC,OAAO,KAAK;IACb;IAEAD,OAAO,GAAGC,MAAM;EACjB;EAEA,MAAM;IAAEC;EAAS,CAAC,GAAGF,OAAO,CAACG,SAAS;EAEtC,OACCD,QAAQ,CAACE,OAAO,CAAE,KAAM,CAAC,KAAK,CAAC,CAAC,IAChC,CAAE,MAAM,EAAE,QAAQ,CAAE,CAACC,QAAQ,CAAEH,QAAS,CAAC;AAE3C","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/platform.ts"],
4
+ "sourcesContent": ["/**\n * Return true if platform is MacOS.\n *\n * @param _window window object by default; used for DI testing.\n *\n * @return True if MacOS; false otherwise.\n */\nexport function isAppleOS( _window?: Window ): boolean {\n\tif ( ! _window ) {\n\t\tif ( typeof window === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t_window = window;\n\t}\n\n\tconst { platform } = _window.navigator;\n\n\treturn (\n\t\tplatform.indexOf( 'Mac' ) !== -1 ||\n\t\t[ 'iPad', 'iPhone' ].includes( platform )\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,UAAW,SAA4B;AACtD,MAAK,CAAE,SAAU;AAChB,QAAK,OAAO,WAAW,aAAc;AACpC,aAAO;AAAA,IACR;AAEA,cAAU;AAAA,EACX;AAEA,QAAM,EAAE,SAAS,IAAI,QAAQ;AAE7B,SACC,SAAS,QAAS,KAAM,MAAM,MAC9B,CAAE,QAAQ,QAAS,EAAE,SAAU,QAAS;AAE1C;",
6
+ "names": []
7
+ }
@@ -1,167 +1,42 @@
1
- /**
2
- * Note: The order of the modifier keys in many of the [foo]Shortcut()
3
- * functions in this file are intentional and should not be changed. They're
4
- * designed to fit with the standard menu keyboard shortcuts shown in the
5
- * user's platform.
6
- *
7
- * For example, on MacOS menu shortcuts will place Shift before Command, but
8
- * on Windows Control will usually come first. So don't provide your own
9
- * shortcut combos directly to keyboardShortcut().
10
- */
11
-
12
- /**
13
- * WordPress dependencies
14
- */
15
- import { __ } from '@wordpress/i18n';
16
-
17
- /**
18
- * Internal dependencies
19
- */
20
- import { isAppleOS } from './platform';
21
-
22
- /**
23
- * External dependencies
24
- */
25
-
26
- /**
27
- * An object of handler functions for each of the possible modifier
28
- * combinations. A handler will return a value for a given key.
29
- */
30
-
31
- /**
32
- * Keycode for BACKSPACE key.
33
- */
34
- export const BACKSPACE = 8;
35
-
36
- /**
37
- * Keycode for TAB key.
38
- */
39
- export const TAB = 9;
40
-
41
- /**
42
- * Keycode for ENTER key.
43
- */
44
- export const ENTER = 13;
45
-
46
- /**
47
- * Keycode for ESCAPE key.
48
- */
49
- export const ESCAPE = 27;
50
-
51
- /**
52
- * Keycode for SPACE key.
53
- */
54
- export const SPACE = 32;
55
-
56
- /**
57
- * Keycode for PAGEUP key.
58
- */
59
- export const PAGEUP = 33;
60
-
61
- /**
62
- * Keycode for PAGEDOWN key.
63
- */
64
- export const PAGEDOWN = 34;
65
-
66
- /**
67
- * Keycode for END key.
68
- */
69
- export const END = 35;
70
-
71
- /**
72
- * Keycode for HOME key.
73
- */
74
- export const HOME = 36;
75
-
76
- /**
77
- * Keycode for LEFT key.
78
- */
79
- export const LEFT = 37;
80
-
81
- /**
82
- * Keycode for UP key.
83
- */
84
- export const UP = 38;
85
-
86
- /**
87
- * Keycode for RIGHT key.
88
- */
89
- export const RIGHT = 39;
90
-
91
- /**
92
- * Keycode for DOWN key.
93
- */
94
- export const DOWN = 40;
95
-
96
- /**
97
- * Keycode for DELETE key.
98
- */
99
- export const DELETE = 46;
100
-
101
- /**
102
- * Keycode for F10 key.
103
- */
104
- export const F10 = 121;
105
-
106
- /**
107
- * Keycode for ALT key.
108
- */
109
- export const ALT = 'alt';
110
-
111
- /**
112
- * Keycode for CTRL key.
113
- */
114
- export const CTRL = 'ctrl';
115
-
116
- /**
117
- * Keycode for COMMAND/META key.
118
- */
119
- export const COMMAND = 'meta';
120
-
121
- /**
122
- * Keycode for SHIFT key.
123
- */
124
- export const SHIFT = 'shift';
125
-
126
- /**
127
- * Keycode for ZERO key.
128
- */
129
- export const ZERO = 48;
130
- export { isAppleOS };
131
-
132
- /**
133
- * Capitalise the first character of a string.
134
- * @param string String to capitalise.
135
- * @return Capitalised string.
136
- */
1
+ import { __ } from "@wordpress/i18n";
2
+ import { isAppleOS } from "./platform";
3
+ const BACKSPACE = 8;
4
+ const TAB = 9;
5
+ const ENTER = 13;
6
+ const ESCAPE = 27;
7
+ const SPACE = 32;
8
+ const PAGEUP = 33;
9
+ const PAGEDOWN = 34;
10
+ const END = 35;
11
+ const HOME = 36;
12
+ const LEFT = 37;
13
+ const UP = 38;
14
+ const RIGHT = 39;
15
+ const DOWN = 40;
16
+ const DELETE = 46;
17
+ const F10 = 121;
18
+ const ALT = "alt";
19
+ const CTRL = "ctrl";
20
+ const COMMAND = "meta";
21
+ const SHIFT = "shift";
22
+ const ZERO = 48;
137
23
  function capitaliseFirstCharacter(string) {
138
24
  return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1);
139
25
  }
140
-
141
- /**
142
- * Map the values of an object with a specified callback and return the result object.
143
- *
144
- * @template T The object type
145
- * @template R The return type of the mapping function
146
- *
147
- * @param object Object to map values of.
148
- * @param mapFn Mapping function to apply to each value.
149
- * @return Object with the same keys and transformed values.
150
- */
151
26
  function mapValues(object, mapFn) {
152
- return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, mapFn(value)]));
27
+ return Object.fromEntries(
28
+ Object.entries(object).map(([key, value]) => [
29
+ key,
30
+ mapFn(value)
31
+ ])
32
+ );
153
33
  }
154
-
155
- /**
156
- * Object that contains functions that return the available modifier
157
- * depending on platform.
158
- */
159
- export const modifiers = {
160
- primary: _isApple => _isApple() ? [COMMAND] : [CTRL],
161
- primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
162
- primaryAlt: _isApple => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
163
- secondary: _isApple => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
164
- access: _isApple => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
34
+ const modifiers = {
35
+ primary: (_isApple) => _isApple() ? [COMMAND] : [CTRL],
36
+ primaryShift: (_isApple) => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
37
+ primaryAlt: (_isApple) => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
38
+ secondary: (_isApple) => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
39
+ access: (_isApple) => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
165
40
  ctrl: () => [CTRL],
166
41
  alt: () => [ALT],
167
42
  ctrlShift: () => [CTRL, SHIFT],
@@ -169,156 +44,92 @@ export const modifiers = {
169
44
  shiftAlt: () => [SHIFT, ALT],
170
45
  undefined: () => []
171
46
  };
172
-
173
- /**
174
- * An object that contains functions to get raw shortcuts.
175
- *
176
- * These are intended for user with the KeyboardShortcuts.
177
- *
178
- * @example
179
- * ```js
180
- * // Assuming macOS:
181
- * rawShortcut.primary( 'm' )
182
- * // "meta+m""
183
- * ```
184
- */
185
- export const rawShortcut = /* @__PURE__ */
186
- mapValues(modifiers, modifier => {
47
+ const rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
187
48
  return (character, _isApple = isAppleOS) => {
188
- return [...modifier(_isApple), character.toLowerCase()].join('+');
49
+ return [...modifier(_isApple), character.toLowerCase()].join(
50
+ "+"
51
+ );
189
52
  };
190
53
  });
191
-
192
- /**
193
- * Return an array of the parts of a keyboard shortcut chord for display.
194
- *
195
- * @example
196
- * ```js
197
- * // Assuming macOS:
198
- * displayShortcutList.primary( 'm' );
199
- * // [ "⌘", "M" ]
200
- * ```
201
- *
202
- * Keyed map of functions to shortcut sequences.
203
- */
204
- export const displayShortcutList = /* @__PURE__ */
205
- mapValues(modifiers, modifier => {
206
- return (character, _isApple = isAppleOS) => {
207
- const isApple = _isApple();
208
- const replacementKeyMap = {
209
- [ALT]: isApple ? '⌥' : 'Alt',
210
- [CTRL]: isApple ? '⌃' : 'Ctrl',
211
- // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
212
- [COMMAND]: '⌘',
213
- [SHIFT]: isApple ? '⇧' : 'Shift'
54
+ const displayShortcutList = /* @__PURE__ */ mapValues(
55
+ modifiers,
56
+ (modifier) => {
57
+ return (character, _isApple = isAppleOS) => {
58
+ const isApple = _isApple();
59
+ const replacementKeyMap = {
60
+ [ALT]: isApple ? "\u2325" : "Alt",
61
+ [CTRL]: isApple ? "\u2303" : "Ctrl",
62
+ // Make sure is the U+2303 UP ARROWHEAD unicode character and not the caret character.
63
+ [COMMAND]: "\u2318",
64
+ [SHIFT]: isApple ? "\u21E7" : "Shift"
65
+ };
66
+ const modifierKeys = modifier(_isApple).reduce(
67
+ (accumulator, key) => {
68
+ const replacementKey = replacementKeyMap[key] ?? key;
69
+ if (isApple) {
70
+ return [...accumulator, replacementKey];
71
+ }
72
+ return [...accumulator, replacementKey, "+"];
73
+ },
74
+ []
75
+ );
76
+ return [
77
+ ...modifierKeys,
78
+ capitaliseFirstCharacter(character)
79
+ ];
214
80
  };
215
- const modifierKeys = modifier(_isApple).reduce((accumulator, key) => {
216
- var _replacementKeyMap$ke;
217
- const replacementKey = (_replacementKeyMap$ke = replacementKeyMap[key]) !== null && _replacementKeyMap$ke !== void 0 ? _replacementKeyMap$ke : key;
218
- // If on the Mac, adhere to platform convention and don't show plus between keys.
219
- if (isApple) {
220
- return [...accumulator, replacementKey];
221
- }
222
- return [...accumulator, replacementKey, '+'];
223
- }, []);
224
- return [...modifierKeys, capitaliseFirstCharacter(character)];
225
- };
226
- });
227
-
228
- /**
229
- * An object that contains functions to display shortcuts.
230
- *
231
- * @example
232
- * ```js
233
- * // Assuming macOS:
234
- * displayShortcut.primary( 'm' );
235
- * // "⌘M"
236
- * ```
237
- *
238
- * Keyed map of functions to display shortcuts.
239
- */
240
- export const displayShortcut = /* @__PURE__ */
241
- mapValues(displayShortcutList, shortcutList => {
242
- return (character, _isApple = isAppleOS) => shortcutList(character, _isApple).join('');
243
- });
244
-
245
- /**
246
- * An object that contains functions to return an aria label for a keyboard
247
- * shortcut.
248
- *
249
- * @example
250
- * ```js
251
- * // Assuming macOS:
252
- * shortcutAriaLabel.primary( '.' );
253
- * // "Command + Period"
254
- * ```
255
- *
256
- * Keyed map of functions to shortcut ARIA labels.
257
- */
258
- export const shortcutAriaLabel = /* @__PURE__ */
259
- mapValues(modifiers, modifier => {
81
+ }
82
+ );
83
+ const displayShortcut = /* @__PURE__ */ mapValues(
84
+ displayShortcutList,
85
+ (shortcutList) => {
86
+ return (character, _isApple = isAppleOS) => shortcutList(character, _isApple).join("");
87
+ }
88
+ );
89
+ const shortcutAriaLabel = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
260
90
  return (character, _isApple = isAppleOS) => {
261
91
  const isApple = _isApple();
262
92
  const replacementKeyMap = {
263
- [SHIFT]: 'Shift',
264
- [COMMAND]: isApple ? 'Command' : 'Control',
265
- [CTRL]: 'Control',
266
- [ALT]: isApple ? 'Option' : 'Alt',
93
+ [SHIFT]: "Shift",
94
+ [COMMAND]: isApple ? "Command" : "Control",
95
+ [CTRL]: "Control",
96
+ [ALT]: isApple ? "Option" : "Alt",
267
97
  /* translators: comma as in the character ',' */
268
- ',': __('Comma'),
98
+ ",": __("Comma"),
269
99
  /* translators: period as in the character '.' */
270
- '.': __('Period'),
100
+ ".": __("Period"),
271
101
  /* translators: backtick as in the character '`' */
272
- '`': __('Backtick'),
102
+ "`": __("Backtick"),
273
103
  /* translators: tilde as in the character '~' */
274
- '~': __('Tilde')
104
+ "~": __("Tilde")
275
105
  };
276
- return [...modifier(_isApple), character].map(key => {
277
- var _replacementKeyMap$ke2;
278
- return capitaliseFirstCharacter((_replacementKeyMap$ke2 = replacementKeyMap[key]) !== null && _replacementKeyMap$ke2 !== void 0 ? _replacementKeyMap$ke2 : key);
279
- }).join(isApple ? ' ' : ' + ');
106
+ return [...modifier(_isApple), character].map(
107
+ (key) => capitaliseFirstCharacter(replacementKeyMap[key] ?? key)
108
+ ).join(isApple ? " " : " + ");
280
109
  };
281
110
  });
282
-
283
- /**
284
- * From a given KeyboardEvent, returns an array of active modifier constants for
285
- * the event.
286
- *
287
- * @param event Keyboard event.
288
- *
289
- * @return Active modifier constants.
290
- */
291
111
  function getEventModifiers(event) {
292
- return [ALT, CTRL, COMMAND, SHIFT].filter(key => event[`${key}Key`]);
112
+ return [ALT, CTRL, COMMAND, SHIFT].filter(
113
+ (key) => event[`${key}Key`]
114
+ );
293
115
  }
294
-
295
- /**
296
- * An object that contains functions to check if a keyboard event matches a
297
- * predefined shortcut combination.
298
- *
299
- * @example
300
- * ```js
301
- * // Assuming an event for ⌘M key press:
302
- * isKeyboardEvent.primary( event, 'm' );
303
- * // true
304
- * ```
305
- *
306
- * Keyed map of functions to match events.
307
- */
308
- export const isKeyboardEvent = /* @__PURE__ */
309
- mapValues(modifiers, getModifiers => {
116
+ const isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => {
310
117
  return (event, character, _isApple = isAppleOS) => {
311
118
  const mods = getModifiers(_isApple);
312
119
  const eventMods = getEventModifiers(event);
313
120
  const replacementWithShiftKeyMap = {
314
- Comma: ',',
315
- Backslash: '\\',
121
+ Comma: ",",
122
+ Backslash: "\\",
316
123
  // Windows returns `\` for both IntlRo and IntlYen.
317
- IntlRo: '\\',
318
- IntlYen: '\\'
124
+ IntlRo: "\\",
125
+ IntlYen: "\\"
319
126
  };
320
- const modsDiff = mods.filter(mod => !eventMods.includes(mod));
321
- const eventModsDiff = eventMods.filter(mod => !mods.includes(mod));
127
+ const modsDiff = mods.filter(
128
+ (mod) => !eventMods.includes(mod)
129
+ );
130
+ const eventModsDiff = eventMods.filter(
131
+ (mod) => !mods.includes(mod)
132
+ );
322
133
  if (modsDiff.length > 0 || eventModsDiff.length > 0) {
323
134
  return false;
324
135
  }
@@ -329,21 +140,42 @@ mapValues(modifiers, getModifiers => {
329
140
  if (event.altKey && character.length === 1) {
330
141
  key = String.fromCharCode(event.keyCode).toLowerCase();
331
142
  }
332
-
333
- // `event.key` returns the value of the key pressed, taking into the state of
334
- // modifier keys such as `Shift`. If the shift key is pressed, a different
335
- // value may be returned depending on the keyboard layout. It is necessary to
336
- // convert to the physical key value that don't take into account keyboard
337
- // layout or modifier key state.
338
143
  if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) {
339
144
  key = replacementWithShiftKeyMap[event.code];
340
145
  }
341
-
342
- // For backwards compatibility.
343
- if (character === 'del') {
344
- character = 'delete';
146
+ if (character === "del") {
147
+ character = "delete";
345
148
  }
346
149
  return key === character.toLowerCase();
347
150
  };
348
151
  });
349
- //# sourceMappingURL=index.js.map
152
+ export {
153
+ ALT,
154
+ BACKSPACE,
155
+ COMMAND,
156
+ CTRL,
157
+ DELETE,
158
+ DOWN,
159
+ END,
160
+ ENTER,
161
+ ESCAPE,
162
+ F10,
163
+ HOME,
164
+ LEFT,
165
+ PAGEDOWN,
166
+ PAGEUP,
167
+ RIGHT,
168
+ SHIFT,
169
+ SPACE,
170
+ TAB,
171
+ UP,
172
+ ZERO,
173
+ displayShortcut,
174
+ displayShortcutList,
175
+ isAppleOS,
176
+ isKeyboardEvent,
177
+ modifiers,
178
+ rawShortcut,
179
+ shortcutAriaLabel
180
+ };
181
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
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.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":"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;AACA;AACA;;AAsBA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,CAAC;;AAE1B;AACA;AAC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IACD,MAAME,aAAa,GAAGT,SAAS,CAACJ,MAAM,CACnCW,GAAG,IAAM,CAAER,IAAI,CAACS,QAAQ,CAAED,GAAI,CACjC,CAAC;IAED,IAAKD,QAAQ,CAACvD,MAAM,GAAG,CAAC,IAAI0D,aAAa,CAAC1D,MAAM,GAAG,CAAC,EAAG;MACtD,OAAO,KAAK;IACb;IAEA,IAAIW,GAAG,GAAGiC,KAAK,CAACjC,GAAG,CAACkB,WAAW,CAAC,CAAC;IAEjC,IAAK,CAAED,SAAS,EAAG;MAClB,OAAOoB,IAAI,CAACS,QAAQ,CAAE9C,GAAsB,CAAC;IAC9C;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,CAAE,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "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"],
5
+ "mappings": "AAcA,SAAS,UAAU;AAKnB,SAAS,iBAAiB;AAgDnB,MAAM,YAAY;AAKlB,MAAM,MAAM;AAKZ,MAAM,QAAQ;AAKd,MAAM,SAAS;AAKf,MAAM,QAAQ;AAKd,MAAM,SAAS;AAKf,MAAM,WAAW;AAKjB,MAAM,MAAM;A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xD;AAOA,QACC,MAAM,YACN,UAAU,WAAW,KACrB,2BAA4B,MAAM,IAAK,GACtC;AACD,YAAM,2BAA4B,MAAM,IAAK;AAAA,IAC9C;AAGA,QAAK,cAAc,OAAQ;AAC1B,kBAAY;AAAA,IACb;AAEA,WAAO,QAAQ,UAAU,YAAY;AAAA,EACtC;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -1,20 +1,14 @@
1
- /**
2
- * Return true if platform is MacOS.
3
- *
4
- * @param _window window object by default; used for DI testing.
5
- *
6
- * @return True if MacOS; false otherwise.
7
- */
8
- export function isAppleOS(_window) {
1
+ function isAppleOS(_window) {
9
2
  if (!_window) {
10
- if (typeof window === 'undefined') {
3
+ if (typeof window === "undefined") {
11
4
  return false;
12
5
  }
13
6
  _window = window;
14
7
  }
15
- const {
16
- platform
17
- } = _window.navigator;
18
- return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
8
+ const { platform } = _window.navigator;
9
+ return platform.indexOf("Mac") !== -1 || ["iPad", "iPhone"].includes(platform);
19
10
  }
20
- //# sourceMappingURL=platform.js.map
11
+ export {
12
+ isAppleOS
13
+ };
14
+ //# sourceMappingURL=platform.js.map