@wordpress/keycodes 4.9.0 → 4.11.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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.11.0 (2024-10-30)
6
+
7
+ ## 4.10.0 (2024-10-16)
8
+
5
9
  ## 4.9.0 (2024-10-03)
6
10
 
7
11
  ## 4.8.0 (2024-09-19)
package/build/index.js CHANGED
@@ -211,7 +211,7 @@ const modifiers = exports.modifiers = {
211
211
  * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw
212
212
  * shortcuts.
213
213
  */
214
- const rawShortcut = exports.rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
214
+ const rawShortcut = exports.rawShortcut = mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
215
215
  return /** @type {WPKeyHandler<string>} */(character, _isApple = _platform.isAppleOS) => {
216
216
  return [...modifier(_isApple), character.toLowerCase()].join('+');
217
217
  };
@@ -230,7 +230,7 @@ const rawShortcut = exports.rawShortcut = mapValues(modifiers, ( /** @type {WPMo
230
230
  * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to
231
231
  * shortcut sequences.
232
232
  */
233
- const displayShortcutList = exports.displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
233
+ const displayShortcutList = exports.displayShortcutList = mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
234
234
  return /** @type {WPKeyHandler<string[]>} */(character, _isApple = _platform.isAppleOS) => {
235
235
  const isApple = _isApple();
236
236
  const replacementKeyMap = {
@@ -266,7 +266,7 @@ const displayShortcutList = exports.displayShortcutList = mapValues(modifiers, (
266
266
  * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
267
267
  * display shortcuts.
268
268
  */
269
- const displayShortcut = exports.displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKeyHandler<string[]>} */shortcutList) => {
269
+ const displayShortcut = exports.displayShortcut = mapValues(displayShortcutList, (/** @type {WPKeyHandler<string[]>} */shortcutList) => {
270
270
  return /** @type {WPKeyHandler<string>} */(character, _isApple = _platform.isAppleOS) => shortcutList(character, _isApple).join('');
271
271
  });
272
272
 
@@ -284,7 +284,7 @@ const displayShortcut = exports.displayShortcut = mapValues(displayShortcutList,
284
284
  * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
285
285
  * shortcut ARIA labels.
286
286
  */
287
- const shortcutAriaLabel = exports.shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
287
+ const shortcutAriaLabel = exports.shortcutAriaLabel = mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
288
288
  return /** @type {WPKeyHandler<string>} */(character, _isApple = _platform.isAppleOS) => {
289
289
  const isApple = _isApple();
290
290
  /** @type {Record<string,string>} */
@@ -318,7 +318,7 @@ const shortcutAriaLabel = exports.shortcutAriaLabel = mapValues(modifiers, ( /**
318
318
  * @return {Array<WPModifierPart>} Active modifier constants.
319
319
  */
320
320
  function getEventModifiers(event) {
321
- return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[( /** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
321
+ return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[(/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
322
322
  `${key}Key`)]);
323
323
  }
324
324
 
@@ -336,7 +336,7 @@ function getEventModifiers(event) {
336
336
  * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions
337
337
  * to match events.
338
338
  */
339
- const isKeyboardEvent = exports.isKeyboardEvent = mapValues(modifiers, ( /** @type {WPModifier} */getModifiers) => {
339
+ const isKeyboardEvent = exports.isKeyboardEvent = mapValues(modifiers, (/** @type {WPModifier} */getModifiers) => {
340
340
  return /** @type {WPEventKeyHandler} */(event, character, _isApple = _platform.isAppleOS) => {
341
341
  const mods = getModifiers(_isApple);
342
342
  const eventMods = getEventModifiers(event);
@@ -355,7 +355,7 @@ const isKeyboardEvent = exports.isKeyboardEvent = mapValues(modifiers, ( /** @ty
355
355
  }
356
356
  let key = event.key.toLowerCase();
357
357
  if (!character) {
358
- return mods.includes( /** @type {WPModifierPart} */key);
358
+ return mods.includes(/** @type {WPModifierPart} */key);
359
359
  }
360
360
  if (event.altKey && character.length === 1) {
361
361
  key = String.fromCharCode(event.keyCode).toLowerCase();
@@ -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;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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","ignoreList":[]}
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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AAI4D,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,CAAE,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","ignoreList":[]}
@@ -200,7 +200,7 @@ export const modifiers = {
200
200
  * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw
201
201
  * shortcuts.
202
202
  */
203
- export const rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
203
+ export const rawShortcut = mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
204
204
  return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
205
205
  return [...modifier(_isApple), character.toLowerCase()].join('+');
206
206
  };
@@ -219,7 +219,7 @@ export const rawShortcut = mapValues(modifiers, ( /** @type {WPModifier} */modif
219
219
  * @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to
220
220
  * shortcut sequences.
221
221
  */
222
- export const displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
222
+ export const displayShortcutList = mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
223
223
  return /** @type {WPKeyHandler<string[]>} */(character, _isApple = isAppleOS) => {
224
224
  const isApple = _isApple();
225
225
  const replacementKeyMap = {
@@ -255,7 +255,7 @@ export const displayShortcutList = mapValues(modifiers, ( /** @type {WPModifier}
255
255
  * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
256
256
  * display shortcuts.
257
257
  */
258
- export const displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKeyHandler<string[]>} */shortcutList) => {
258
+ export const displayShortcut = mapValues(displayShortcutList, (/** @type {WPKeyHandler<string[]>} */shortcutList) => {
259
259
  return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => shortcutList(character, _isApple).join('');
260
260
  });
261
261
 
@@ -273,7 +273,7 @@ export const displayShortcut = mapValues(displayShortcutList, ( /** @type {WPKey
273
273
  * @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
274
274
  * shortcut ARIA labels.
275
275
  */
276
- export const shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} */modifier) => {
276
+ export const shortcutAriaLabel = mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
277
277
  return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
278
278
  const isApple = _isApple();
279
279
  /** @type {Record<string,string>} */
@@ -307,7 +307,7 @@ export const shortcutAriaLabel = mapValues(modifiers, ( /** @type {WPModifier} *
307
307
  * @return {Array<WPModifierPart>} Active modifier constants.
308
308
  */
309
309
  function getEventModifiers(event) {
310
- return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[( /** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
310
+ return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[(/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
311
311
  `${key}Key`)]);
312
312
  }
313
313
 
@@ -325,7 +325,7 @@ function getEventModifiers(event) {
325
325
  * @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions
326
326
  * to match events.
327
327
  */
328
- export const isKeyboardEvent = mapValues(modifiers, ( /** @type {WPModifier} */getModifiers) => {
328
+ export const isKeyboardEvent = mapValues(modifiers, (/** @type {WPModifier} */getModifiers) => {
329
329
  return /** @type {WPEventKeyHandler} */(event, character, _isApple = isAppleOS) => {
330
330
  const mods = getModifiers(_isApple);
331
331
  const eventMods = getEventModifiers(event);
@@ -344,7 +344,7 @@ export const isKeyboardEvent = mapValues(modifiers, ( /** @type {WPModifier} */g
344
344
  }
345
345
  let key = event.key.toLowerCase();
346
346
  if (!character) {
347
- return mods.includes( /** @type {WPModifierPart} */key);
347
+ return mods.includes(/** @type {WPModifierPart} */key);
348
348
  }
349
349
  if (event.altKey && character.length === 1) {
350
350
  key = String.fromCharCode(event.keyCode).toLowerCase();
@@ -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;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,GAAG,EAAE;;AAEpB;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAG,EAAE;;AAEvB;AACA;AACA;AACA,OAAO,MAAMC,IAAI,GAAG,EAAE;;AAEtB;AACA;AACA;AACA,OAAO,MAAMC,MAAM,GAAG,EAAE;;AAExB;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAG,GAAG;;AAEtB;AACA;AACA;AACA,OAAO,MAAMC,GAAG,GAAG,KAAK;;AA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AS,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","ignoreList":[]}
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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-1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/keycodes",
3
- "version": "4.9.0",
3
+ "version": "4.11.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,11 +28,12 @@
28
28
  "types": "build-types",
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "@babel/runtime": "^7.16.0",
32
- "@wordpress/i18n": "^5.9.0"
31
+ "@babel/runtime": "7.25.7",
32
+ "@wordpress/i18n": "*"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "2e5495c635910cb34bfaca3c6258d2e989f66214"
37
+ "wpScript": true,
38
+ "gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
38
39
  }