@wordpress/keycodes 4.37.0 → 4.38.1-next.79a2f3cdd.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 +5 -1
- package/LICENSE.md +1 -1
- package/README.md +34 -1
- package/build/{index.js → index.cjs} +12 -2
- package/build/index.cjs.map +7 -0
- package/build/{platform.js → platform.cjs} +1 -1
- package/build-module/{index.js → index.mjs} +11 -2
- package/build-module/index.mjs.map +7 -0
- package/build-module/{platform.js → platform.mjs} +1 -1
- package/build-types/index.d.ts +35 -1
- package/build-types/index.d.ts.map +1 -1
- package/package.json +14 -7
- package/src/index.ts +48 -1
- package/src/test/index.ts +239 -0
- package/build/index.js.map +0 -7
- package/build-module/index.js.map +0 -7
- package/tsconfig.json +0 -5
- package/tsconfig.tsbuildinfo +0 -1
- /package/build/{platform.js.map → platform.cjs.map} +0 -0
- /package/build-module/{platform.js.map → platform.mjs.map} +0 -0
package/CHANGELOG.md
CHANGED
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -42,6 +42,39 @@ onKeyDown( event ) {
|
|
|
42
42
|
|
|
43
43
|
Keycode for ALT key.
|
|
44
44
|
|
|
45
|
+
### ariaKeyShortcut
|
|
46
|
+
|
|
47
|
+
An object that contains functions to get shortcuts in a format compatible with the [`aria-keyshortcuts` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts).
|
|
48
|
+
|
|
49
|
+
**Note**: The provided shortcut character strings (ie. not the modifiers) should follow the values specified in the [UI Events KeyboardEvent key Values spec](https://www.w3.org/TR/uievents-key/) — for example, "Enter", "Tab", "ArrowRight", "PageDown", "Escape", "Plus", or "F1". The spacebar key should be represented with the "Space" string (an exception to the UI Events KeyboardEvent key Values spec).
|
|
50
|
+
|
|
51
|
+
_Related_
|
|
52
|
+
|
|
53
|
+
- <https://www.w3.org/TR/wai-aria-1.2/#aria-keyshortcuts>
|
|
54
|
+
- <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts>
|
|
55
|
+
- <https://www.w3.org/TR/uievents-key/>
|
|
56
|
+
|
|
57
|
+
_Usage_
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
// Assuming macOS:
|
|
61
|
+
ariaKeyShortcut.primary( 'm' );
|
|
62
|
+
// "Meta+M"
|
|
63
|
+
|
|
64
|
+
ariaKeyShortcut.primaryAlt( 'm' );
|
|
65
|
+
// "Meta+Alt+M"
|
|
66
|
+
|
|
67
|
+
// Assuming Windows:
|
|
68
|
+
ariaKeyShortcut.primary( 'm' );
|
|
69
|
+
// "Control+M"
|
|
70
|
+
|
|
71
|
+
ariaKeyShortcut.primaryAlt( 'm' );
|
|
72
|
+
// "Control+Alt+M"
|
|
73
|
+
|
|
74
|
+
ariaKeyShortcut.primaryShift( 'del' );
|
|
75
|
+
// "Control+Shift+Delete"
|
|
76
|
+
```
|
|
77
|
+
|
|
45
78
|
### BACKSPACE
|
|
46
79
|
|
|
47
80
|
Keycode for BACKSPACE key.
|
|
@@ -167,7 +200,7 @@ _Usage_
|
|
|
167
200
|
```js
|
|
168
201
|
// Assuming macOS:
|
|
169
202
|
rawShortcut.primary( 'm' );
|
|
170
|
-
// "meta+m"
|
|
203
|
+
// "meta+m"
|
|
171
204
|
```
|
|
172
205
|
|
|
173
206
|
### RIGHT
|
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
TAB: () => TAB,
|
|
41
41
|
UP: () => UP,
|
|
42
42
|
ZERO: () => ZERO,
|
|
43
|
+
ariaKeyShortcut: () => ariaKeyShortcut,
|
|
43
44
|
displayShortcut: () => displayShortcut,
|
|
44
45
|
displayShortcutList: () => displayShortcutList,
|
|
45
46
|
isAppleOS: () => import_platform.isAppleOS,
|
|
@@ -50,7 +51,7 @@ __export(index_exports, {
|
|
|
50
51
|
});
|
|
51
52
|
module.exports = __toCommonJS(index_exports);
|
|
52
53
|
var import_i18n = require("@wordpress/i18n");
|
|
53
|
-
var import_platform = require("./platform");
|
|
54
|
+
var import_platform = require("./platform.cjs");
|
|
54
55
|
var BACKSPACE = 8;
|
|
55
56
|
var TAB = 9;
|
|
56
57
|
var ENTER = 13;
|
|
@@ -102,6 +103,14 @@ var rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
|
|
102
103
|
);
|
|
103
104
|
};
|
|
104
105
|
});
|
|
106
|
+
var ariaKeyShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
|
107
|
+
return (character, _isApple = import_platform.isAppleOS) => {
|
|
108
|
+
return [
|
|
109
|
+
...modifier(_isApple).map((key) => key === CTRL ? "Control" : key).map((key) => capitaliseFirstCharacter(key)),
|
|
110
|
+
capitaliseFirstCharacter(character)
|
|
111
|
+
].join("+");
|
|
112
|
+
};
|
|
113
|
+
});
|
|
105
114
|
var displayShortcutList = /* @__PURE__ */ mapValues(
|
|
106
115
|
modifiers,
|
|
107
116
|
(modifier) => {
|
|
@@ -222,6 +231,7 @@ var isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => {
|
|
|
222
231
|
TAB,
|
|
223
232
|
UP,
|
|
224
233
|
ZERO,
|
|
234
|
+
ariaKeyShortcut,
|
|
225
235
|
displayShortcut,
|
|
226
236
|
displayShortcutList,
|
|
227
237
|
isAppleOS,
|
|
@@ -230,4 +240,4 @@ var isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => {
|
|
|
230
240
|
rawShortcut,
|
|
231
241
|
shortcutAriaLabel
|
|
232
242
|
});
|
|
233
|
-
//# sourceMappingURL=index.
|
|
243
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 * An object that contains functions to get shortcuts in a format compatible\n * with the [`aria-keyshortcuts` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts).\n *\n * **Note**: The provided shortcut character strings (ie. not the modifiers) should follow\n * the values specified in the [UI Events KeyboardEvent key Values spec](https://www.w3.org/TR/uievents-key/) \u2014 for example, \"Enter\", \"Tab\", \"ArrowRight\", \"PageDown\",\n * \"Escape\", \"Plus\", or \"F1\". The spacebar key should be represented with the\n * \"Space\" string (an exception to the UI Events KeyboardEvent key Values spec).\n *\n * @see https://www.w3.org/TR/wai-aria-1.2/#aria-keyshortcuts\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts\n * @see https://www.w3.org/TR/uievents-key/\n *\n * @example\n * ```js\n * // Assuming macOS:\n * ariaKeyShortcut.primary( 'm' )\n * // \"Meta+M\"\n *\n * ariaKeyShortcut.primaryAlt( 'm' )\n * // \"Meta+Alt+M\"\n *\n * // Assuming Windows:\n * ariaKeyShortcut.primary( 'm' )\n * // \"Control+M\"\n *\n * ariaKeyShortcut.primaryAlt( 'm' )\n * // \"Control+Alt+M\"\n *\n * ariaKeyShortcut.primaryShift( 'del' )\n * // \"Control+Shift+Delete\"\n * ```\n */\nexport const ariaKeyShortcut: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( modifier: WPModifier ) => {\n\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\treturn [\n\t\t\t\t...modifier( _isApple )\n\t\t\t\t\t// Swap 'ctrl' for 'control' (spec-compliant)\n\t\t\t\t\t.map( ( key ) => ( key === CTRL ? 'Control' : key ) )\n\t\t\t\t\t.map( ( key ) => capitaliseFirstCharacter( key ) ),\n\t\t\t\tcapitaliseFirstCharacter( character ),\n\t\t\t].join( '+' );\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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,UAAM,OAAO,aAAc,QAAS;AACpC,UAAM,YAAY,kBAAmB,KAAM;AAE3C,UAAM,6BAAuD;AAAA,MAC5D,OAAO;AAAA,MACP,WAAW;AAAA;AAAA,MAEX,QAAQ;AAAA,MACR,SAAS;AAAA,IACV;AAEA,UAAM,WAAW,KAAK;AAAA,MACrB,CAAE,QAAS,CAAE,UAAU,SAAU,GAAI;AAAA,IACtC;AACA,UAAM,gBAAgB,UAAU;AAAA,MAC/B,CAAE,QAAS,CAAE,KAAK,SAAU,GAAI;AAAA,IACjC;AAEA,QAAK,SAAS,SAAS,KAAK,cAAc,SAAS,GAAI;AACtD,aAAO;AAAA,IACR;AAEA,QAAI,MAAM,MAAM,IAAI,YAAY;AAEhC,QAAK,CAAE,WAAY;AAClB,aAAO,KAAK,SAAU,GAAsB;AAAA,IAC7C;AAEA,QAAK,MAAM,UAAU,UAAU,WAAW,GAAI;AAC7C,YAAM,OAAO,aAAc,MAAM,OAAQ,EAAE,YAAY;AAAA,IACxD;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,6 +1,6 @@
|
|
|
1
1
|
// packages/keycodes/src/index.ts
|
|
2
2
|
import { __ } from "@wordpress/i18n";
|
|
3
|
-
import { isAppleOS } from "./platform";
|
|
3
|
+
import { isAppleOS } from "./platform.mjs";
|
|
4
4
|
var BACKSPACE = 8;
|
|
5
5
|
var TAB = 9;
|
|
6
6
|
var ENTER = 13;
|
|
@@ -52,6 +52,14 @@ var rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
|
|
52
52
|
);
|
|
53
53
|
};
|
|
54
54
|
});
|
|
55
|
+
var ariaKeyShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
|
56
|
+
return (character, _isApple = isAppleOS) => {
|
|
57
|
+
return [
|
|
58
|
+
...modifier(_isApple).map((key) => key === CTRL ? "Control" : key).map((key) => capitaliseFirstCharacter(key)),
|
|
59
|
+
capitaliseFirstCharacter(character)
|
|
60
|
+
].join("+");
|
|
61
|
+
};
|
|
62
|
+
});
|
|
55
63
|
var displayShortcutList = /* @__PURE__ */ mapValues(
|
|
56
64
|
modifiers,
|
|
57
65
|
(modifier) => {
|
|
@@ -171,6 +179,7 @@ export {
|
|
|
171
179
|
TAB,
|
|
172
180
|
UP,
|
|
173
181
|
ZERO,
|
|
182
|
+
ariaKeyShortcut,
|
|
174
183
|
displayShortcut,
|
|
175
184
|
displayShortcutList,
|
|
176
185
|
isAppleOS,
|
|
@@ -179,4 +188,4 @@ export {
|
|
|
179
188
|
rawShortcut,
|
|
180
189
|
shortcutAriaLabel
|
|
181
190
|
};
|
|
182
|
-
//# sourceMappingURL=index.
|
|
191
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 * An object that contains functions to get shortcuts in a format compatible\n * with the [`aria-keyshortcuts` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts).\n *\n * **Note**: The provided shortcut character strings (ie. not the modifiers) should follow\n * the values specified in the [UI Events KeyboardEvent key Values spec](https://www.w3.org/TR/uievents-key/) \u2014 for example, \"Enter\", \"Tab\", \"ArrowRight\", \"PageDown\",\n * \"Escape\", \"Plus\", or \"F1\". The spacebar key should be represented with the\n * \"Space\" string (an exception to the UI Events KeyboardEvent key Values spec).\n *\n * @see https://www.w3.org/TR/wai-aria-1.2/#aria-keyshortcuts\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts\n * @see https://www.w3.org/TR/uievents-key/\n *\n * @example\n * ```js\n * // Assuming macOS:\n * ariaKeyShortcut.primary( 'm' )\n * // \"Meta+M\"\n *\n * ariaKeyShortcut.primaryAlt( 'm' )\n * // \"Meta+Alt+M\"\n *\n * // Assuming Windows:\n * ariaKeyShortcut.primary( 'm' )\n * // \"Control+M\"\n *\n * ariaKeyShortcut.primaryAlt( 'm' )\n * // \"Control+Alt+M\"\n *\n * ariaKeyShortcut.primaryShift( 'del' )\n * // \"Control+Shift+Delete\"\n * ```\n */\nexport const ariaKeyShortcut: WPModifierHandler< WPKeyHandler< string > > =\n\t/* @__PURE__ */\n\tmapValues( modifiers, ( modifier: WPModifier ) => {\n\t\treturn ( character: string, _isApple = isAppleOS ) => {\n\t\t\treturn [\n\t\t\t\t...modifier( _isApple )\n\t\t\t\t\t// Swap 'ctrl' for 'control' (spec-compliant)\n\t\t\t\t\t.map( ( key ) => ( key === CTRL ? 'Control' : key ) )\n\t\t\t\t\t.map( ( key ) => capitaliseFirstCharacter( key ) ),\n\t\t\t\tcapitaliseFirstCharacter( character ),\n\t\t\t].join( '+' );\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,IAAM,YAAY;AAKlB,IAAM,MAAM;AAKZ,IAAM,QAAQ;AAKd,IAAM,SAAS;AAKf,IAAM,QAAQ;AAKd,IAAM,SAAS;AAKf,IAAM,WAAW;AAKjB,IAAM,MAAM;AAKZ,IAAM,OAAO;AAKb,IAAM,OAAO;AAKb,IAAM,KAAK;AAKX,IAAM,QAAQ;AAKd,IAAM,OAAO;AAKb,IAAM,SAAS;AAKf,IAAM,MAAM;AAKZ,IAAM,MAAM;AAKZ,IAAM,OAAO;AAKb,IAAM,UAAU;AAKhB,IAAM,QAAQ;AAKd,IAAM,OAAO;AASpB,SAAS,yBAA0B,QAAyB;AAC3D,SAAO,OAAO,SAAS,IACpB,OAAO,YAAY,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AA,IACxD;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
|
+
}
|
package/build-types/index.d.ts
CHANGED
|
@@ -121,10 +121,44 @@ export declare const modifiers: WPModifierHandler<WPModifier>;
|
|
|
121
121
|
* ```js
|
|
122
122
|
* // Assuming macOS:
|
|
123
123
|
* rawShortcut.primary( 'm' )
|
|
124
|
-
* // "meta+m"
|
|
124
|
+
* // "meta+m"
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
127
|
export declare const rawShortcut: WPModifierHandler<WPKeyHandler<string>>;
|
|
128
|
+
/**
|
|
129
|
+
* An object that contains functions to get shortcuts in a format compatible
|
|
130
|
+
* with the [`aria-keyshortcuts` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts).
|
|
131
|
+
*
|
|
132
|
+
* **Note**: The provided shortcut character strings (ie. not the modifiers) should follow
|
|
133
|
+
* the values specified in the [UI Events KeyboardEvent key Values spec](https://www.w3.org/TR/uievents-key/) — for example, "Enter", "Tab", "ArrowRight", "PageDown",
|
|
134
|
+
* "Escape", "Plus", or "F1". The spacebar key should be represented with the
|
|
135
|
+
* "Space" string (an exception to the UI Events KeyboardEvent key Values spec).
|
|
136
|
+
*
|
|
137
|
+
* @see https://www.w3.org/TR/wai-aria-1.2/#aria-keyshortcuts
|
|
138
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts
|
|
139
|
+
* @see https://www.w3.org/TR/uievents-key/
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```js
|
|
143
|
+
* // Assuming macOS:
|
|
144
|
+
* ariaKeyShortcut.primary( 'm' )
|
|
145
|
+
* // "Meta+M"
|
|
146
|
+
*
|
|
147
|
+
* ariaKeyShortcut.primaryAlt( 'm' )
|
|
148
|
+
* // "Meta+Alt+M"
|
|
149
|
+
*
|
|
150
|
+
* // Assuming Windows:
|
|
151
|
+
* ariaKeyShortcut.primary( 'm' )
|
|
152
|
+
* // "Control+M"
|
|
153
|
+
*
|
|
154
|
+
* ariaKeyShortcut.primaryAlt( 'm' )
|
|
155
|
+
* // "Control+Alt+M"
|
|
156
|
+
*
|
|
157
|
+
* ariaKeyShortcut.primaryShift( 'del' )
|
|
158
|
+
* // "Control+Shift+Delete"
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export declare const ariaKeyShortcut: WPModifierHandler<WPKeyHandler<string>>;
|
|
128
162
|
/**
|
|
129
163
|
* Return an array of the parts of a keyboard shortcut chord for display.
|
|
130
164
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEjE,MAAM,MAAM,cAAc,GACvB,OAAO,GAAG,GACV,OAAO,IAAI,GACX,OAAO,OAAO,GACd,OAAO,KAAK,CAAC;AAEhB,MAAM,MAAM,iBAAiB,GAC1B,SAAS,GACT,cAAc,GACd,YAAY,GACZ,WAAW,GACX,QAAQ,GACR,MAAM,GACN,KAAK,GACL,WAAW,GACX,OAAO,GACP,UAAU,GACV,WAAW,CAAC;AAEf;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAE,CAAC,IAAK,MAAM,CAAE,iBAAiB,EAAE,CAAC,CAAE,CAAC;AAEpE,MAAM,MAAM,YAAY,CAAE,CAAC,I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M,GAAG,QAAQ,CAAC;AAEzB;;GAEG;AACH,eAAO,MAAM,IAAI,SAAS,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,OAAO,SAAS,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,KAAK,UAAU,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,IAAI,KAAK,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,CAAC;AAmCrB;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,iBAAiB,CAAE,UAAU,CAepD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAE,YAAY,CAAE,MAAM,CAAE,CAQ/D,CAAC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAE,YAAY,CAAE,MAAM,CAAE,CAYnE,CAAC;AAEL;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAClD,YAAY,CAAE,MAAM,EAAE,CAAE,CAkCvB,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAE,YAAY,CAAE,MAAM,CAAE,CAQrE,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBAAiB,CAAE,YAAY,CAAE,MAAM,CAAE,CA0BrE,CAAC;AAqBL;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAE,iBAAiB,CAwD9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/keycodes",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.38.1-next.79a2f3cdd.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",
|
|
@@ -22,13 +22,20 @@
|
|
|
22
22
|
"node": ">=18.12.0",
|
|
23
23
|
"npm": ">=8.19.2"
|
|
24
24
|
},
|
|
25
|
-
"
|
|
26
|
-
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"build",
|
|
28
|
+
"build-module",
|
|
29
|
+
"build-types",
|
|
30
|
+
"*.md"
|
|
31
|
+
],
|
|
32
|
+
"main": "build/index.cjs",
|
|
33
|
+
"module": "build-module/index.mjs",
|
|
27
34
|
"exports": {
|
|
28
35
|
".": {
|
|
29
36
|
"types": "./build-types/index.d.ts",
|
|
30
|
-
"import": "./build-module/index.
|
|
31
|
-
"require": "./build/index.
|
|
37
|
+
"import": "./build-module/index.mjs",
|
|
38
|
+
"require": "./build/index.cjs"
|
|
32
39
|
},
|
|
33
40
|
"./package.json": "./package.json"
|
|
34
41
|
},
|
|
@@ -37,10 +44,10 @@
|
|
|
37
44
|
"types": "build-types",
|
|
38
45
|
"sideEffects": false,
|
|
39
46
|
"dependencies": {
|
|
40
|
-
"@wordpress/i18n": "^6.10.0"
|
|
47
|
+
"@wordpress/i18n": "^6.10.1-next.79a2f3cdd.0"
|
|
41
48
|
},
|
|
42
49
|
"publishConfig": {
|
|
43
50
|
"access": "public"
|
|
44
51
|
},
|
|
45
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "6a324496a37d9a333a11d4d7fe5fb93b8152a5ba"
|
|
46
53
|
}
|
package/src/index.ts
CHANGED
|
@@ -227,7 +227,7 @@ export const modifiers: WPModifierHandler< WPModifier > = {
|
|
|
227
227
|
* ```js
|
|
228
228
|
* // Assuming macOS:
|
|
229
229
|
* rawShortcut.primary( 'm' )
|
|
230
|
-
* // "meta+m"
|
|
230
|
+
* // "meta+m"
|
|
231
231
|
* ```
|
|
232
232
|
*/
|
|
233
233
|
export const rawShortcut: WPModifierHandler< WPKeyHandler< string > > =
|
|
@@ -240,6 +240,53 @@ export const rawShortcut: WPModifierHandler< WPKeyHandler< string > > =
|
|
|
240
240
|
};
|
|
241
241
|
} );
|
|
242
242
|
|
|
243
|
+
/**
|
|
244
|
+
* An object that contains functions to get shortcuts in a format compatible
|
|
245
|
+
* with the [`aria-keyshortcuts` HTML attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts).
|
|
246
|
+
*
|
|
247
|
+
* **Note**: The provided shortcut character strings (ie. not the modifiers) should follow
|
|
248
|
+
* the values specified in the [UI Events KeyboardEvent key Values spec](https://www.w3.org/TR/uievents-key/) — for example, "Enter", "Tab", "ArrowRight", "PageDown",
|
|
249
|
+
* "Escape", "Plus", or "F1". The spacebar key should be represented with the
|
|
250
|
+
* "Space" string (an exception to the UI Events KeyboardEvent key Values spec).
|
|
251
|
+
*
|
|
252
|
+
* @see https://www.w3.org/TR/wai-aria-1.2/#aria-keyshortcuts
|
|
253
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-keyshortcuts
|
|
254
|
+
* @see https://www.w3.org/TR/uievents-key/
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```js
|
|
258
|
+
* // Assuming macOS:
|
|
259
|
+
* ariaKeyShortcut.primary( 'm' )
|
|
260
|
+
* // "Meta+M"
|
|
261
|
+
*
|
|
262
|
+
* ariaKeyShortcut.primaryAlt( 'm' )
|
|
263
|
+
* // "Meta+Alt+M"
|
|
264
|
+
*
|
|
265
|
+
* // Assuming Windows:
|
|
266
|
+
* ariaKeyShortcut.primary( 'm' )
|
|
267
|
+
* // "Control+M"
|
|
268
|
+
*
|
|
269
|
+
* ariaKeyShortcut.primaryAlt( 'm' )
|
|
270
|
+
* // "Control+Alt+M"
|
|
271
|
+
*
|
|
272
|
+
* ariaKeyShortcut.primaryShift( 'del' )
|
|
273
|
+
* // "Control+Shift+Delete"
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
export const ariaKeyShortcut: WPModifierHandler< WPKeyHandler< string > > =
|
|
277
|
+
/* @__PURE__ */
|
|
278
|
+
mapValues( modifiers, ( modifier: WPModifier ) => {
|
|
279
|
+
return ( character: string, _isApple = isAppleOS ) => {
|
|
280
|
+
return [
|
|
281
|
+
...modifier( _isApple )
|
|
282
|
+
// Swap 'ctrl' for 'control' (spec-compliant)
|
|
283
|
+
.map( ( key ) => ( key === CTRL ? 'Control' : key ) )
|
|
284
|
+
.map( ( key ) => capitaliseFirstCharacter( key ) ),
|
|
285
|
+
capitaliseFirstCharacter( character ),
|
|
286
|
+
].join( '+' );
|
|
287
|
+
};
|
|
288
|
+
} );
|
|
289
|
+
|
|
243
290
|
/**
|
|
244
291
|
* Return an array of the parts of a keyboard shortcut chord for display.
|
|
245
292
|
*
|
package/src/test/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
displayShortcutList,
|
|
6
6
|
displayShortcut,
|
|
7
7
|
rawShortcut,
|
|
8
|
+
ariaKeyShortcut,
|
|
8
9
|
shortcutAriaLabel,
|
|
9
10
|
isKeyboardEvent,
|
|
10
11
|
} from '..';
|
|
@@ -270,6 +271,244 @@ describe( 'rawShortcut', () => {
|
|
|
270
271
|
} );
|
|
271
272
|
} );
|
|
272
273
|
|
|
274
|
+
describe( 'ariaKeyShortcut', () => {
|
|
275
|
+
describe( 'modifier key formatting', () => {
|
|
276
|
+
it( 'should use "Control" (not "ctrl") on Windows', () => {
|
|
277
|
+
const shortcut = ariaKeyShortcut.primary( 'm', isAppleOSFalse );
|
|
278
|
+
expect( shortcut ).toEqual( 'Control+M' );
|
|
279
|
+
} );
|
|
280
|
+
|
|
281
|
+
it( 'should use "Meta" for Command key on MacOS', () => {
|
|
282
|
+
const shortcut = ariaKeyShortcut.primary( 'm', isAppleOSTrue );
|
|
283
|
+
expect( shortcut ).toEqual( 'Meta+M' );
|
|
284
|
+
} );
|
|
285
|
+
|
|
286
|
+
it( 'should capitalize modifier keys (Shift, Alt)', () => {
|
|
287
|
+
const shortcut = ariaKeyShortcut.secondary( 'm', isAppleOSFalse );
|
|
288
|
+
expect( shortcut ).toEqual( 'Control+Shift+Alt+M' );
|
|
289
|
+
} );
|
|
290
|
+
|
|
291
|
+
it( 'should handle multiple modifiers on MacOS', () => {
|
|
292
|
+
const shortcut = ariaKeyShortcut.secondary( 'm', isAppleOSTrue );
|
|
293
|
+
expect( shortcut ).toEqual( 'Shift+Alt+Meta+M' );
|
|
294
|
+
} );
|
|
295
|
+
} );
|
|
296
|
+
|
|
297
|
+
describe( 'character handling', () => {
|
|
298
|
+
it( 'should uppercase single letter characters', () => {
|
|
299
|
+
const shortcut = ariaKeyShortcut.primary( 'k', isAppleOSFalse );
|
|
300
|
+
expect( shortcut ).toEqual( 'Control+K' );
|
|
301
|
+
} );
|
|
302
|
+
|
|
303
|
+
it( 'should pass through number characters', () => {
|
|
304
|
+
const shortcut = ariaKeyShortcut.primary( '1', isAppleOSFalse );
|
|
305
|
+
expect( shortcut ).toEqual( 'Control+1' );
|
|
306
|
+
} );
|
|
307
|
+
|
|
308
|
+
it( 'should capitalize multi-character key names', () => {
|
|
309
|
+
const shortcut = ariaKeyShortcut.primary( 'enter', isAppleOSFalse );
|
|
310
|
+
expect( shortcut ).toEqual( 'Control+Enter' );
|
|
311
|
+
} );
|
|
312
|
+
|
|
313
|
+
it( 'should pass through special characters unchanged', () => {
|
|
314
|
+
const shortcut = ariaKeyShortcut.primary( '.', isAppleOSFalse );
|
|
315
|
+
expect( shortcut ).toEqual( 'Control+.' );
|
|
316
|
+
} );
|
|
317
|
+
|
|
318
|
+
it( 'should output just the character when no modifier is used', () => {
|
|
319
|
+
const shortcut = ariaKeyShortcut.undefined( 'F1', isAppleOSFalse );
|
|
320
|
+
expect( shortcut ).toEqual( 'F1' );
|
|
321
|
+
} );
|
|
322
|
+
} );
|
|
323
|
+
} );
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Tests for handling KeyboardEvent.key-style values.
|
|
327
|
+
*
|
|
328
|
+
* These tests document how each shortcut function handles named keys
|
|
329
|
+
* (like "Enter", "Tab", "Delete") as opposed to single character keys.
|
|
330
|
+
*
|
|
331
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
|
|
332
|
+
*/
|
|
333
|
+
describe( 'KeyboardEvent.key value handling', () => {
|
|
334
|
+
const namedKeys = [
|
|
335
|
+
// Whitespace keys
|
|
336
|
+
'Tab',
|
|
337
|
+
'Enter',
|
|
338
|
+
'Space',
|
|
339
|
+
// Navigation keys
|
|
340
|
+
'ArrowUp',
|
|
341
|
+
'ArrowDown',
|
|
342
|
+
'ArrowLeft',
|
|
343
|
+
'ArrowRight',
|
|
344
|
+
'End',
|
|
345
|
+
'Home',
|
|
346
|
+
'PageDown',
|
|
347
|
+
'PageUp',
|
|
348
|
+
// Editing keys
|
|
349
|
+
'Backspace',
|
|
350
|
+
'Delete',
|
|
351
|
+
'Insert',
|
|
352
|
+
// UI keys
|
|
353
|
+
'Escape',
|
|
354
|
+
// Function keys
|
|
355
|
+
'F1',
|
|
356
|
+
'F10',
|
|
357
|
+
];
|
|
358
|
+
|
|
359
|
+
// Also test the lowercase/shorthand versions commonly used in the codebase
|
|
360
|
+
const shorthandKeys = [ 'del', 'esc', 'enter', 'tab', 'space' ];
|
|
361
|
+
|
|
362
|
+
describe( 'rawShortcut', () => {
|
|
363
|
+
it( 'lowercases named keys', () => {
|
|
364
|
+
expect( rawShortcut.primary( 'Enter', isAppleOSFalse ) ).toEqual(
|
|
365
|
+
'ctrl+enter'
|
|
366
|
+
);
|
|
367
|
+
expect( rawShortcut.primary( 'Delete', isAppleOSFalse ) ).toEqual(
|
|
368
|
+
'ctrl+delete'
|
|
369
|
+
);
|
|
370
|
+
expect( rawShortcut.primary( 'ArrowUp', isAppleOSFalse ) ).toEqual(
|
|
371
|
+
'ctrl+arrowup'
|
|
372
|
+
);
|
|
373
|
+
} );
|
|
374
|
+
|
|
375
|
+
it( 'passes through shorthand keys lowercased', () => {
|
|
376
|
+
expect( rawShortcut.primary( 'del', isAppleOSFalse ) ).toEqual(
|
|
377
|
+
'ctrl+del'
|
|
378
|
+
);
|
|
379
|
+
expect( rawShortcut.primary( 'esc', isAppleOSFalse ) ).toEqual(
|
|
380
|
+
'ctrl+esc'
|
|
381
|
+
);
|
|
382
|
+
} );
|
|
383
|
+
|
|
384
|
+
it.each( namedKeys )(
|
|
385
|
+
'outputs %s lowercased with modifier',
|
|
386
|
+
( key ) => {
|
|
387
|
+
const shortcut = rawShortcut.primary( key, isAppleOSFalse );
|
|
388
|
+
expect( shortcut ).toEqual( `ctrl+${ key.toLowerCase() }` );
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
} );
|
|
392
|
+
|
|
393
|
+
describe( 'displayShortcut', () => {
|
|
394
|
+
it( 'capitalizes first letter of named keys', () => {
|
|
395
|
+
expect(
|
|
396
|
+
displayShortcut.primary( 'enter', isAppleOSFalse )
|
|
397
|
+
).toEqual( 'Ctrl+Enter' );
|
|
398
|
+
expect( displayShortcut.primary( 'del', isAppleOSFalse ) ).toEqual(
|
|
399
|
+
'Ctrl+Del'
|
|
400
|
+
);
|
|
401
|
+
expect(
|
|
402
|
+
displayShortcut.primary( 'arrowup', isAppleOSFalse )
|
|
403
|
+
).toEqual( 'Ctrl+Arrowup' );
|
|
404
|
+
} );
|
|
405
|
+
|
|
406
|
+
it( 'preserves casing of already-capitalized keys', () => {
|
|
407
|
+
expect(
|
|
408
|
+
displayShortcut.primary( 'Enter', isAppleOSFalse )
|
|
409
|
+
).toEqual( 'Ctrl+Enter' );
|
|
410
|
+
expect(
|
|
411
|
+
displayShortcut.primary( 'ArrowUp', isAppleOSFalse )
|
|
412
|
+
).toEqual( 'Ctrl+ArrowUp' );
|
|
413
|
+
} );
|
|
414
|
+
|
|
415
|
+
it.each( namedKeys )(
|
|
416
|
+
'outputs %s with capitalized first letter',
|
|
417
|
+
( key ) => {
|
|
418
|
+
const shortcut = displayShortcut.primary( key, isAppleOSFalse );
|
|
419
|
+
// capitaliseFirstCharacter keeps the rest of the string as-is
|
|
420
|
+
const expected = key.charAt( 0 ).toUpperCase() + key.slice( 1 );
|
|
421
|
+
expect( shortcut ).toEqual( `Ctrl+${ expected }` );
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
it.each( shorthandKeys )( 'capitalizes shorthand key %s', ( key ) => {
|
|
426
|
+
const shortcut = displayShortcut.primary( key, isAppleOSFalse );
|
|
427
|
+
const expected = key.charAt( 0 ).toUpperCase() + key.slice( 1 );
|
|
428
|
+
expect( shortcut ).toEqual( `Ctrl+${ expected }` );
|
|
429
|
+
} );
|
|
430
|
+
} );
|
|
431
|
+
|
|
432
|
+
describe( 'displayShortcutList', () => {
|
|
433
|
+
it( 'capitalizes first letter of named keys in list', () => {
|
|
434
|
+
expect(
|
|
435
|
+
displayShortcutList.primary( 'enter', isAppleOSFalse )
|
|
436
|
+
).toEqual( [ 'Ctrl', '+', 'Enter' ] );
|
|
437
|
+
expect(
|
|
438
|
+
displayShortcutList.primary( 'PageDown', isAppleOSFalse )
|
|
439
|
+
).toEqual( [ 'Ctrl', '+', 'PageDown' ] );
|
|
440
|
+
} );
|
|
441
|
+
} );
|
|
442
|
+
|
|
443
|
+
describe( 'shortcutAriaLabel', () => {
|
|
444
|
+
it( 'capitalizes first letter of named keys', () => {
|
|
445
|
+
expect(
|
|
446
|
+
shortcutAriaLabel.primary( 'enter', isAppleOSFalse )
|
|
447
|
+
).toEqual( 'Control + Enter' );
|
|
448
|
+
expect(
|
|
449
|
+
shortcutAriaLabel.primary( 'Delete', isAppleOSFalse )
|
|
450
|
+
).toEqual( 'Control + Delete' );
|
|
451
|
+
} );
|
|
452
|
+
|
|
453
|
+
it( 'does not have special mappings for most named keys', () => {
|
|
454
|
+
// Unlike period/comma which are mapped, named keys are just capitalized
|
|
455
|
+
expect(
|
|
456
|
+
shortcutAriaLabel.primary( 'ArrowUp', isAppleOSFalse )
|
|
457
|
+
).toEqual( 'Control + ArrowUp' );
|
|
458
|
+
expect(
|
|
459
|
+
shortcutAriaLabel.primary( 'Escape', isAppleOSFalse )
|
|
460
|
+
).toEqual( 'Control + Escape' );
|
|
461
|
+
} );
|
|
462
|
+
|
|
463
|
+
it.each( namedKeys )(
|
|
464
|
+
'outputs %s with capitalized first letter',
|
|
465
|
+
( key ) => {
|
|
466
|
+
const shortcut = shortcutAriaLabel.primary(
|
|
467
|
+
key,
|
|
468
|
+
isAppleOSFalse
|
|
469
|
+
);
|
|
470
|
+
const expected = key.charAt( 0 ).toUpperCase() + key.slice( 1 );
|
|
471
|
+
expect( shortcut ).toEqual( `Control + ${ expected }` );
|
|
472
|
+
}
|
|
473
|
+
);
|
|
474
|
+
} );
|
|
475
|
+
|
|
476
|
+
describe( 'ariaKeyShortcut', () => {
|
|
477
|
+
it( 'capitalizes first letter of named keys', () => {
|
|
478
|
+
expect(
|
|
479
|
+
ariaKeyShortcut.primary( 'enter', isAppleOSFalse )
|
|
480
|
+
).toEqual( 'Control+Enter' );
|
|
481
|
+
expect(
|
|
482
|
+
ariaKeyShortcut.primary( 'Delete', isAppleOSFalse )
|
|
483
|
+
).toEqual( 'Control+Delete' );
|
|
484
|
+
} );
|
|
485
|
+
|
|
486
|
+
it( 'preserves casing after first character', () => {
|
|
487
|
+
expect(
|
|
488
|
+
ariaKeyShortcut.primary( 'ArrowUp', isAppleOSFalse )
|
|
489
|
+
).toEqual( 'Control+ArrowUp' );
|
|
490
|
+
expect(
|
|
491
|
+
ariaKeyShortcut.primary( 'PageDown', isAppleOSFalse )
|
|
492
|
+
).toEqual( 'Control+PageDown' );
|
|
493
|
+
} );
|
|
494
|
+
|
|
495
|
+
it.each( namedKeys )(
|
|
496
|
+
'outputs %s with capitalized first letter',
|
|
497
|
+
( key ) => {
|
|
498
|
+
const shortcut = ariaKeyShortcut.primary( key, isAppleOSFalse );
|
|
499
|
+
const expected = key.charAt( 0 ).toUpperCase() + key.slice( 1 );
|
|
500
|
+
expect( shortcut ).toEqual( `Control+${ expected }` );
|
|
501
|
+
}
|
|
502
|
+
);
|
|
503
|
+
|
|
504
|
+
it.each( shorthandKeys )( 'capitalizes shorthand key %s', ( key ) => {
|
|
505
|
+
const shortcut = ariaKeyShortcut.primary( key, isAppleOSFalse );
|
|
506
|
+
const expected = key.charAt( 0 ).toUpperCase() + key.slice( 1 );
|
|
507
|
+
expect( shortcut ).toEqual( `Control+${ expected }` );
|
|
508
|
+
} );
|
|
509
|
+
} );
|
|
510
|
+
} );
|
|
511
|
+
|
|
273
512
|
describe( 'isKeyboardEvent', () => {
|
|
274
513
|
afterEach( () => {
|
|
275
514
|
while ( document.body.firstChild ) {
|
package/build/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,kBAAmB;AAKnB,sBAA0B;AAgDnB,IAAM,YAAY;AAKlB,IAAM,MAAM;AAKZ,IAAM,QAAQ;AAKd,IAAM,SAAS;AAKf,IAAM,QAAQ;AAKd,IAAM,SAAS;AAKf,IAAM,WAAW;AAKjB,IAAM,MAAM;AAKZ,IAAM,OAAO;AAKb,IAAM,OAAO;AAKb,IAAM,KAAK;AAKX,IAAM,QAAQ;AAKd,IAAM,OAAO;AAKb,IAAM,SAAS;AAKf,IAAM,MAAM;AAKZ,IAAM,MAAM;AAKZ,IAAM,OAAO;AAKb,IAAM,UAAU;AAKhB,IAAM,QAAQ;AAKd,IAAM,OAAO;AASpB,SAAS,yBAA0B,QAAyB;AAC3D,SAAO,OAAO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
@@ -1,7 +0,0 @@
|
|
|
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\t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AAE,KAAK,SAAU,GAAI;AAAA,IACjC;AAEA,QAAK,SAAS,SAAS,KAAK,cAAc,SAAS,GAAI;AACtD,aAAO;AAAA,IACR;AAEA,QAAI,MAAM,MAAM,IAAI,YAAY;AAEhC,QAAK,CAAE,WAAY;AAClB,aAAO,KAAK,SAAU,GAAsB;AAAA,IAC7C;AAEA,QAAK,MAAM,UAAU,UAAU,WAAW,GAAI;AAC7C,YAAM,OAAO,aAAc,MAAM,OAAQ,EAAE,YAAY;AAAA,IACxD;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
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.es2024.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2024.collection.d.ts","../../node_modules/typescript/lib/lib.es2024.object.d.ts","../../node_modules/typescript/lib/lib.es2024.promise.d.ts","../../node_modules/typescript/lib/lib.es2024.regexp.d.ts","../../node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2024.string.d.ts","../../node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.promise.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.iterator.d.ts","../../node_modules/typescript/lib/lib.esnext.float16.d.ts","../../node_modules/typescript/lib/lib.esnext.error.d.ts","../../node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/@tannin/sprintf/types/index.d.ts","../../node_modules/@tannin/sprintf/src/index.d.ts","../../node_modules/tannin/index.d.ts","../i18n/build-types/types.d.ts","../i18n/build-types/sprintf.d.ts","../hooks/build-types/createAddHook.d.ts","../hooks/build-types/types.d.ts","../hooks/build-types/createRemoveHook.d.ts","../hooks/build-types/createHasHook.d.ts","../hooks/build-types/createRunHook.d.ts","../hooks/build-types/createCurrentHook.d.ts","../hooks/build-types/createDoingHook.d.ts","../hooks/build-types/createDidHook.d.ts","../hooks/build-types/createHooks.d.ts","../hooks/build-types/index.d.ts","../i18n/build-types/create-i18n.d.ts","../i18n/build-types/default-i18n.d.ts","../i18n/build-types/index.d.ts","./src/platform.ts","../../node_modules/@types/react/global.d.ts","../../node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/react/index.d.ts","./src/index.ts"],"fileIdsList":[[83],[102,103,104],[97],[89],[88,89,90,91,92,93,94,95],[88,89,90,91,92,94,95,96],[96],[86,97],[86],[86,87,98,99],[84,85],[100,101,105]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"8fd575e12870e9944c7e1d62e1f5a73fcf23dd8d3a321f2a2c74c20d022283fe","impliedFormat":1},{"version":"2ab096661c711e4a81cc464fa1e6feb929a54f5340b46b0a07ac6bbf857471f0","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"df83c2a6c73228b625b0beb6669c7ee2a09c914637e2d35170723ad49c0f5cd4","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"87dc0f382502f5bbce5129bdc0aea21e19a3abbc19259e0b43ae038a9fc4e326","affectsGlobalScope":true,"impliedFormat":1},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true,"impliedFormat":1},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ece9f17b3866cc077099c73f4983bddbcb1dc7ddb943227f1ec070f529dedd1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true,"impliedFormat":1},{"version":"1c9319a09485199c1f7b0498f2988d6d2249793ef67edda49d1e584746be9032","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3a2a0cee0f03ffdde24d89660eba2685bfbdeae955a6c67e8c4c9fd28928eeb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"51ad4c928303041605b4d7ae32e0c1ee387d43a24cd6f1ebf4a2699e1076d4fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"60037901da1a425516449b9a20073aa03386cce92f7a1fd902d7602be3a7c2e9","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"22adec94ef7047a6c9d1af3cb96be87a335908bf9ef386ae9fd50eeb37f44c47","affectsGlobalScope":true,"impliedFormat":1},{"version":"196cb558a13d4533a5163286f30b0509ce0210e4b316c56c38d4c0fd2fb38405","affectsGlobalScope":true,"impliedFormat":1},{"version":"73f78680d4c08509933daf80947902f6ff41b6230f94dd002ae372620adb0f60","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5239f5c01bcfa9cd32f37c496cf19c61d69d37e48be9de612b541aac915805b","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"48b226b89c6d27cbdcd4ab135e08dd8f942a888548d066ff15fa25d0b92014af","impliedFormat":99},{"version":"7c8f354ebfae57b7db67e7b00e3e98ce949f2d2804d7fd34b9dd7c6880e7eb2a","impliedFormat":99},{"version":"0d1179b6e77f3c31405e0c31f52f13bc4270555bdd3157f0bc855d5e7fe2c4cf","impliedFormat":1},"497a2fc9f9029fab0cc80a784845867c5af173fbe16881500b62edd6919ba3ce","ccbb4955fbd599f75be76bc0f6b9ffa9264dc59c507a2aeecb41dec88bb5f3f6","e89c5f3e57750498ecc0904025a5faaa2067a54ce82dac6ba2b8cf0cfd41ccc2","09fe1d225f4a83f48ea5f67f1be80f6e674280a4f8c38d0ebd649862237066bb","4ad429086c5d55543eb1146b31a2de27e54ad772d1626d19b80502b3fff43b84","6b089383aa85af6dd1619a6fb9468a1eec60c2ce83be3f4fc691a323275860c4","cdbced29135877ea367650ee1c49c482a46cbbd0befdbfb730e8780d5982aa41","5461443f907ddbae5a8b8cd9a32ac614e396bf505acd4b09245d4ec0b1dbebd2","26a0c627921511b17209aa6e90510e25a424b8cb1b08ac74d29d98bfb35e1959","6508e23a7d089883b385ab273c9ae40301e953e987c4363bdbc6f788b88ff9ce","ee1a1f6f69c6e3f7cdb0fd5a920d72cd9c2e69229919ad0d7b590dda51348bca","d150550f9f93d9b865bdba497dfee108bfc0af237d186fb173af51a0646e3643","2aef2be50a4cc4626209af6c7735a3be2eb9d8643fb189c72a21ea4d467231c7","4c74dd582fab386fc92df4c0f214f0e6ac3d522b73f5dae2ebcf8094c50cf08b","f07884c953b96279eaed286f01f6b3deeea5d889125db08b27ee6e9dbd3e369b",{"version":"442de40df36db9b2569f8c37902cfe5928406bf851a2baaace3a544d88f27667","signature":"5689bbb026f9c964c62cea8932316041877fbeacaabbafa98294cd067b850de8"},{"version":"55461596dc873b866911ef4e640fae4c39da7ac1fbc7ef5e649cb2f2fb42c349","affectsGlobalScope":true,"impliedFormat":1},{"version":"4c68749a564a6facdf675416d75789ee5a557afda8960e0803cf6711fa569288","impliedFormat":1},{"version":"f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","impliedFormat":1},{"version":"8ca4709dbd22a34bcc1ebf93e1877645bdb02ebd3f3d9a211a299a8db2ee4ba1","affectsGlobalScope":true,"impliedFormat":1},{"version":"384fd55c467bc0cdc9f458b21f707fbd549f0eafed7d5b9445e2abbb8430d65b","signature":"eee058526b3f30491b0ee6ce996a86b73f3d308a90b3868f6a9bd0b67e537823"}],"root":[101,106],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"checkJs":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"rootDir":"./src","skipDefaultLibCheck":true,"strict":true,"target":99},"referencedMap":[[84,1],[105,2],[88,3],[93,4],[95,4],[94,4],[91,4],[96,5],[90,4],[92,4],[97,6],[89,7],[98,8],[99,9],[100,10],[87,9],[86,11],[106,12]],"latestChangedDtsFile":"./build-types/index.d.ts","version":"5.9.3"}
|
|
File without changes
|
|
File without changes
|