@wordpress/keyboard-shortcuts 4.16.0 → 4.17.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/shortcut-provider.js +5 -9
  3. package/build/components/shortcut-provider.js.map +1 -1
  4. package/build/context.js +1 -2
  5. package/build/context.js.map +1 -1
  6. package/build/hooks/use-shortcut-event-match.js +1 -6
  7. package/build/hooks/use-shortcut-event-match.js.map +1 -1
  8. package/build/hooks/use-shortcut.js +0 -7
  9. package/build/hooks/use-shortcut.js.map +1 -1
  10. package/build/hooks/use-shortcut.native.js +0 -2
  11. package/build/hooks/use-shortcut.native.js.map +1 -1
  12. package/build/index.js +0 -5
  13. package/build/index.js.map +1 -1
  14. package/build/store/actions.js +1 -3
  15. package/build/store/actions.js.map +1 -1
  16. package/build/store/index.js +2 -9
  17. package/build/store/index.js.map +1 -1
  18. package/build/store/reducer.js +2 -5
  19. package/build/store/reducer.js.map +1 -1
  20. package/build/store/selectors.js +9 -19
  21. package/build/store/selectors.js.map +1 -1
  22. package/build-module/components/shortcut-provider.js +5 -8
  23. package/build-module/components/shortcut-provider.js.map +1 -1
  24. package/build-module/context.js.map +1 -1
  25. package/build-module/hooks/use-shortcut-event-match.js +3 -4
  26. package/build-module/hooks/use-shortcut-event-match.js.map +1 -1
  27. package/build-module/hooks/use-shortcut.js +2 -4
  28. package/build-module/hooks/use-shortcut.js.map +1 -1
  29. package/build-module/hooks/use-shortcut.native.js +0 -1
  30. package/build-module/hooks/use-shortcut.native.js.map +1 -1
  31. package/build-module/index.js.map +1 -1
  32. package/build-module/store/actions.js +1 -1
  33. package/build-module/store/actions.js.map +1 -1
  34. package/build-module/store/index.js +2 -2
  35. package/build-module/store/index.js.map +1 -1
  36. package/build-module/store/reducer.js +2 -4
  37. package/build-module/store/reducer.js.map +1 -1
  38. package/build-module/store/selectors.js +11 -13
  39. package/build-module/store/selectors.js.map +1 -1
  40. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.17.0 (2023-08-16)
6
+
5
7
  ## 4.16.0 (2023-08-10)
6
8
 
7
9
  ## 4.15.0 (2023-07-20)
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ShortcutProvider = ShortcutProvider;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  var _context = require("../context");
11
-
12
9
  /**
13
10
  * WordPress dependencies
14
11
  */
@@ -16,9 +13,11 @@ var _context = require("../context");
16
13
  /**
17
14
  * Internal dependencies
18
15
  */
16
+
19
17
  const {
20
18
  Provider
21
19
  } = _context.context;
20
+
22
21
  /**
23
22
  * Handles callbacks added to context by `useShortcut`.
24
23
  *
@@ -26,23 +25,20 @@ const {
26
25
  *
27
26
  * @return {import('@wordpress/element').WPElement} Component.
28
27
  */
29
-
30
28
  function ShortcutProvider(props) {
31
29
  const keyboardShortcuts = (0, _element.useRef)(new Set());
32
-
33
30
  function onKeyDown(event) {
34
31
  if (props.onKeyDown) props.onKeyDown(event);
35
-
36
32
  for (const keyboardShortcut of keyboardShortcuts.current) {
37
33
  keyboardShortcut(event);
38
34
  }
39
35
  }
40
- /* eslint-disable jsx-a11y/no-static-element-interactions */
41
-
42
36
 
37
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
43
38
  return (0, _element.createElement)(Provider, {
44
39
  value: keyboardShortcuts
45
- }, (0, _element.createElement)("div", { ...props,
40
+ }, (0, _element.createElement)("div", {
41
+ ...props,
46
42
  onKeyDown: onKeyDown
47
43
  }));
48
44
  /* eslint-enable jsx-a11y/no-static-element-interactions */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"names":["Provider","context","ShortcutProvider","props","keyboardShortcuts","Set","onKeyDown","event","keyboardShortcut","current"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAeC,gBAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,QAAMC,iBAAiB,GAAG,qBAAQ,IAAIC,GAAJ,EAAR,CAA1B;;AAEA,WAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,QAAKJ,KAAK,CAACG,SAAX,EAAuBH,KAAK,CAACG,SAAN,CAAiBC,KAAjB;;AAEvB,SAAM,MAAMC,gBAAZ,IAAgCJ,iBAAiB,CAACK,OAAlD,EAA4D;AAC3DD,MAAAA,gBAAgB,CAAED,KAAF,CAAhB;AACA;AACD;AAED;;;AACA,SACC,4BAAC,QAAD;AAAU,IAAA,KAAK,EAAGH;AAAlB,KACC,wCAAUD,KAAV;AAAkB,IAAA,SAAS,EAAGG;AAA9B,IADD,CADD;AAKA;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {import('@wordpress/element').WPElement} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"]}
1
+ {"version":3,"names":["_element","require","_context","Provider","context","ShortcutProvider","props","keyboardShortcuts","useRef","Set","onKeyDown","event","keyboardShortcut","current","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {import('@wordpress/element').WPElement} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAM;EAAEE;AAAS,CAAC,GAAGC,gBAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAAE,IAAIC,GAAG,CAAC,CAAE,CAAC;EAE7C,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKL,KAAK,CAACI,SAAS,EAAGJ,KAAK,CAACI,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIL,iBAAiB,CAACM,OAAO,EAAG;MAC3DD,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACC,IAAAX,QAAA,CAAAc,aAAA,EAACX,QAAQ;IAACY,KAAK,EAAGR;EAAmB,GACpC,IAAAP,QAAA,CAAAc,aAAA;IAAA,GAAUR,KAAK;IAAGI,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD"}
package/build/context.js CHANGED
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.context = void 0;
7
-
8
7
  var _element = require("@wordpress/element");
9
-
10
8
  /**
11
9
  * WordPress dependencies
12
10
  */
11
+
13
12
  const context = (0, _element.createContext)();
14
13
  exports.context = context;
15
14
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/context.js"],"names":["context"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGO,MAAMA,OAAO,GAAG,6BAAhB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const context = createContext();\n"]}
1
+ {"version":3,"names":["_element","require","context","createContext","exports"],"sources":["@wordpress/keyboard-shortcuts/src/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const context = createContext();\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,OAAO,GAAG,IAAAC,sBAAa,EAAC,CAAC;AAACC,OAAA,CAAAF,OAAA,GAAAA,OAAA"}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useShortcutEventMatch;
7
-
8
7
  var _data = require("@wordpress/data");
9
-
10
8
  var _keycodes = require("@wordpress/keycodes");
11
-
12
9
  var _store = require("../store");
13
-
14
10
  /**
15
11
  * WordPress dependencies
16
12
  */
@@ -29,6 +25,7 @@ function useShortcutEventMatch() {
29
25
  const {
30
26
  getAllShortcutKeyCombinations
31
27
  } = (0, _data.useSelect)(_store.store);
28
+
32
29
  /**
33
30
  * A function to check if a keyboard event matches a predefined shortcut
34
31
  * combination.
@@ -38,7 +35,6 @@ function useShortcutEventMatch() {
38
35
  *
39
36
  * @return {boolean} True if the event matches any shortcuts, false if not.
40
37
  */
41
-
42
38
  function isMatch(name, event) {
43
39
  return getAllShortcutKeyCombinations(name).some(({
44
40
  modifier,
@@ -47,7 +43,6 @@ function useShortcutEventMatch() {
47
43
  return _keycodes.isKeyboardEvent[modifier](event, character);
48
44
  });
49
45
  }
50
-
51
46
  return isMatch;
52
47
  }
53
48
  //# sourceMappingURL=use-shortcut-event-match.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"names":["useShortcutEventMatch","getAllShortcutKeyCombinations","keyboardShortcutsStore","isMatch","name","event","some","modifier","character","isKeyboardEvent"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA;AAAF,MAAoC,qBACzCC,YADyC,CAA1C;AAIA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,WAASC,OAAT,CAAkBC,IAAlB,EAAwBC,KAAxB,EAAgC;AAC/B,WAAOJ,6BAA6B,CAAEG,IAAF,CAA7B,CAAsCE,IAAtC,CACN,CAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,KAAF,KAA+B;AAC9B,aAAOC,0BAAiBF,QAAjB,EAA6BF,KAA7B,EAAoCG,SAApC,CAAP;AACA,KAHK,CAAP;AAKA;;AAED,SAAOL,OAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"]}
1
+ {"version":3,"names":["_data","require","_keycodes","_store","useShortcutEventMatch","getAllShortcutKeyCombinations","useSelect","keyboardShortcutsStore","isMatch","name","event","some","modifier","character","isKeyboardEvent"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAA8B,CAAC,GAAG,IAAAC,eAAS,EAClDC,YACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,SAASC,OAAOA,CAAEC,IAAI,EAAEC,KAAK,EAAG;IAC/B,OAAOL,6BAA6B,CAAEI,IAAK,CAAC,CAACE,IAAI,CAChD,CAAE;MAAEC,QAAQ;MAAEC;IAAU,CAAC,KAAM;MAC9B,OAAOC,yBAAe,CAAEF,QAAQ,CAAE,CAAEF,KAAK,EAAEG,SAAU,CAAC;IACvD,CACD,CAAC;EACF;EAEA,OAAOL,OAAO;AACf"}
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = useShortcut;
9
-
10
8
  var _element = require("@wordpress/element");
11
-
12
9
  var _useShortcutEventMatch = _interopRequireDefault(require("./use-shortcut-event-match"));
13
-
14
10
  var _context = require("../context");
15
-
16
11
  /**
17
12
  * WordPress dependencies
18
13
  */
@@ -40,13 +35,11 @@ function useShortcut(name, callback, {
40
35
  if (isDisabled) {
41
36
  return;
42
37
  }
43
-
44
38
  function _callback(event) {
45
39
  if (isMatch(name, event)) {
46
40
  callbackRef.current(event);
47
41
  }
48
42
  }
49
-
50
43
  shortcuts.current.add(_callback);
51
44
  return () => {
52
45
  shortcuts.current.delete(_callback);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"names":["useShortcut","name","callback","isDisabled","shortcuts","context","isMatch","callbackRef","current","_callback","event","add","delete"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,IAAtB,EAA4BC,QAA5B,EAAsC;AAAEC,EAAAA;AAAF,IAAiB,EAAvD,EAA4D;AAC1E,QAAMC,SAAS,GAAG,yBAAYC,gBAAZ,CAAlB;AACA,QAAMC,OAAO,GAAG,qCAAhB;AACA,QAAMC,WAAW,GAAG,sBAApB;AACAA,EAAAA,WAAW,CAACC,OAAZ,GAAsBN,QAAtB;AAEA,0BAAW,MAAM;AAChB,QAAKC,UAAL,EAAkB;AACjB;AACA;;AAED,aAASM,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UAAKJ,OAAO,CAAEL,IAAF,EAAQS,KAAR,CAAZ,EAA8B;AAC7BH,QAAAA,WAAW,CAACC,OAAZ,CAAqBE,KAArB;AACA;AACD;;AAEDN,IAAAA,SAAS,CAACI,OAAV,CAAkBG,GAAlB,CAAuBF,SAAvB;AACA,WAAO,MAAM;AACZL,MAAAA,SAAS,CAACI,OAAV,CAAkBI,MAAlB,CAA0BH,SAA1B;AACA,KAFD;AAGA,GAfD,EAeG,CAAER,IAAF,EAAQE,UAAR,CAfH;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut( name, callback, { isDisabled } = {} ) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\tcallbackRef.current = callback;\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.current.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.current.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled ] );\n}\n"]}
1
+ {"version":3,"names":["_element","require","_useShortcutEventMatch","_interopRequireDefault","_context","useShortcut","name","callback","isDisabled","shortcuts","useContext","context","isMatch","useShortcutEventMatch","callbackRef","useRef","current","useEffect","_callback","event","add","delete"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut( name, callback, { isDisabled } = {} ) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\tcallbackRef.current = callback;\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.current.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.current.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled ] );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASI,WAAWA,CAAEC,IAAI,EAAEC,QAAQ,EAAE;EAAEC;AAAW,CAAC,GAAG,CAAC,CAAC,EAAG;EAC1E,MAAMC,SAAS,GAAG,IAAAC,mBAAU,EAAEC,gBAAQ,CAAC;EACvC,MAAMC,OAAO,GAAG,IAAAC,8BAAqB,EAAC,CAAC;EACvC,MAAMC,WAAW,GAAG,IAAAC,eAAM,EAAC,CAAC;EAC5BD,WAAW,CAACE,OAAO,GAAGT,QAAQ;EAE9B,IAAAU,kBAAS,EAAE,MAAM;IAChB,IAAKT,UAAU,EAAG;MACjB;IACD;IAEA,SAASU,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKP,OAAO,CAAEN,IAAI,EAAEa,KAAM,CAAC,EAAG;QAC7BL,WAAW,CAACE,OAAO,CAAEG,KAAM,CAAC;MAC7B;IACD;IAEAV,SAAS,CAACO,OAAO,CAACI,GAAG,CAAEF,SAAU,CAAC;IAClC,OAAO,MAAM;MACZT,SAAS,CAACO,OAAO,CAACK,MAAM,CAAEH,SAAU,CAAC;IACtC,CAAC;EACF,CAAC,EAAE,CAAEZ,IAAI,EAAEE,UAAU,CAAG,CAAC;AAC1B"}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  const useShortcut = () => null;
9
-
10
8
  var _default = useShortcut;
11
9
  exports.default = _default;
12
10
  //# sourceMappingURL=use-shortcut.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.native.js"],"names":["useShortcut"],"mappings":";;;;;;;AAAA,MAAMA,WAAW,GAAG,MAAM,IAA1B;;eACeA,W","sourcesContent":["const useShortcut = () => null;\nexport default useShortcut;\n"]}
1
+ {"version":3,"names":["useShortcut","_default","exports","default"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.native.js"],"sourcesContent":["const useShortcut = () => null;\nexport default useShortcut;\n"],"mappings":";;;;;;AAAA,MAAMA,WAAW,GAAGA,CAAA,KAAM,IAAI;AAAC,IAAAC,QAAA,GAChBD,WAAW;AAAAE,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
package/build/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -29,12 +28,8 @@ Object.defineProperty(exports, "useShortcut", {
29
28
  return _useShortcut.default;
30
29
  }
31
30
  });
32
-
33
31
  var _store = require("./store");
34
-
35
32
  var _useShortcut = _interopRequireDefault(require("./hooks/use-shortcut"));
36
-
37
33
  var _shortcutProvider = require("./components/shortcut-provider");
38
-
39
34
  var _useShortcutEventMatch = _interopRequireDefault(require("./hooks/use-shortcut-event-match"));
40
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA","sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"]}
1
+ {"version":3,"names":["_store","require","_useShortcut","_interopRequireDefault","_shortcutProvider","_useShortcutEventMatch"],"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA"}
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.registerShortcut = registerShortcut;
7
7
  exports.unregisterShortcut = unregisterShortcut;
8
-
9
8
  /** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
10
9
 
11
10
  /**
@@ -90,6 +89,7 @@ function registerShortcut({
90
89
  description
91
90
  };
92
91
  }
92
+
93
93
  /**
94
94
  * Returns an action object used to unregister a keyboard shortcut.
95
95
  *
@@ -127,8 +127,6 @@ function registerShortcut({
127
127
  *```
128
128
  * @return {Object} action.
129
129
  */
130
-
131
-
132
130
  function unregisterShortcut(name) {
133
131
  return {
134
132
  type: 'UNREGISTER_SHORTCUT',
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"mappings":";;;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2B;AACjCC,EAAAA,IADiC;AAEjCC,EAAAA,QAFiC;AAGjCC,EAAAA,WAHiC;AAIjCC,EAAAA,cAJiC;AAKjCC,EAAAA;AALiC,CAA3B,EAMH;AACH,SAAO;AACNC,IAAAA,IAAI,EAAE,mBADA;AAENL,IAAAA,IAFM;AAGNC,IAAAA,QAHM;AAINE,IAAAA,cAJM;AAKNC,IAAAA,OALM;AAMNF,IAAAA;AANM,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,kBAAT,CAA6BN,IAA7B,EAAoC;AAC1C,SAAO;AACNK,IAAAA,IAAI,EAAE,qBADA;AAENL,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"]}
1
+ {"version":3,"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAAE;EACjCC,IAAI;EACJC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,OAAO;IACNC,IAAI,EAAE,mBAAmB;IACzBL,IAAI;IACJC,QAAQ;IACRE,cAAc;IACdC,OAAO;IACPF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,kBAAkBA,CAAEN,IAAI,EAAG;EAC1C,OAAO;IACNK,IAAI,EAAE,qBAAqB;IAC3BL;EACD,CAAC;AACF"}
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.store = void 0;
9
-
10
8
  var _data = require("@wordpress/data");
11
-
12
9
  var _reducer = _interopRequireDefault(require("./reducer"));
13
-
14
10
  var actions = _interopRequireWildcard(require("./actions"));
15
-
16
11
  var selectors = _interopRequireWildcard(require("./selectors"));
17
-
18
12
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
13
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
14
  /**
23
15
  * WordPress dependencies
24
16
  */
@@ -26,7 +18,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
26
18
  /**
27
19
  * Internal dependencies
28
20
  */
21
+
29
22
  const STORE_NAME = 'core/keyboard-shortcuts';
23
+
30
24
  /**
31
25
  * Store definition for the keyboard shortcuts namespace.
32
26
  *
@@ -34,7 +28,6 @@ const STORE_NAME = 'core/keyboard-shortcuts';
34
28
  *
35
29
  * @type {Object}
36
30
  */
37
-
38
31
  const store = (0, _data.createReduxStore)(STORE_NAME, {
39
32
  reducer: _reducer.default,
40
33
  actions,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/index.js"],"names":["STORE_NAME","store","reducer","actions","selectors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,UAAU,GAAG,yBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,KAAK,GAAG,4BAAkBD,UAAlB,EAA8B;AAClDE,EAAAA,OAAO,EAAPA,gBADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAA9B,CAAd;;AAMP,oBAAUH,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/keyboard-shortcuts';\n\n/**\n * Store definition for the keyboard shortcuts namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"]}
1
+ {"version":3,"names":["_data","require","_reducer","_interopRequireDefault","actions","_interopRequireWildcard","selectors","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","STORE_NAME","store","createReduxStore","reducer","exports","register"],"sources":["@wordpress/keyboard-shortcuts/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/keyboard-shortcuts';\n\n/**\n * Store definition for the keyboard shortcuts namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,uBAAA,CAAAJ,OAAA;AAAyC,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;AAVzC;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAMW,UAAU,GAAG,yBAAyB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,GAAG,IAAAC,sBAAgB,EAAEF,UAAU,EAAE;EAClDG,OAAO,EAAPA,gBAAO;EACP5B,OAAO;EACPE;AACD,CAAE,CAAC;AAAC2B,OAAA,CAAAH,KAAA,GAAAA,KAAA;AAEJ,IAAAI,cAAQ,EAAEJ,KAAM,CAAC"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  /**
9
8
  * Reducer returning the registered shortcuts
10
9
  *
@@ -16,7 +15,8 @@ exports.default = void 0;
16
15
  function reducer(state = {}, action) {
17
16
  switch (action.type) {
18
17
  case 'REGISTER_SHORTCUT':
19
- return { ...state,
18
+ return {
19
+ ...state,
20
20
  [action.name]: {
21
21
  category: action.category,
22
22
  keyCombination: action.keyCombination,
@@ -24,7 +24,6 @@ function reducer(state = {}, action) {
24
24
  description: action.description
25
25
  }
26
26
  };
27
-
28
27
  case 'UNREGISTER_SHORTCUT':
29
28
  const {
30
29
  [action.name]: actionName,
@@ -32,10 +31,8 @@ function reducer(state = {}, action) {
32
31
  } = state;
33
32
  return remainingState;
34
33
  }
35
-
36
34
  return state;
37
35
  }
38
-
39
36
  var _default = reducer;
40
37
  exports.default = _default;
41
38
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"names":["reducer","state","action","type","name","category","keyCombination","aliases","description","actionName","remainingState"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,CAAkBC,KAAK,GAAG,EAA1B,EAA8BC,MAA9B,EAAuC;AACtC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,mBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBC,UAAAA,QAAQ,EAAEH,MAAM,CAACG,QADD;AAEhBC,UAAAA,cAAc,EAAEJ,MAAM,CAACI,cAFP;AAGhBC,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAHA;AAIhBC,UAAAA,WAAW,EAAEN,MAAM,CAACM;AAJJ;AAFX,OAAP;;AASD,SAAK,qBAAL;AACC,YAAM;AAAE,SAAEN,MAAM,CAACE,IAAT,GAAiBK,UAAnB;AAA+B,WAAGC;AAAlC,UAAqDT,KAA3D;AACA,aAAOS,cAAP;AAbF;;AAgBA,SAAOT,KAAP;AACA;;eAEcD,O","sourcesContent":["/**\n * Reducer returning the registered shortcuts\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction reducer( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_SHORTCUT':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\tkeyCombination: action.keyCombination,\n\t\t\t\t\taliases: action.aliases,\n\t\t\t\t\tdescription: action.description,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_SHORTCUT':\n\t\t\tconst { [ action.name ]: actionName, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"]}
1
+ {"version":3,"names":["reducer","state","action","type","name","category","keyCombination","aliases","description","actionName","remainingState","_default","exports","default"],"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"sourcesContent":["/**\n * Reducer returning the registered shortcuts\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction reducer( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_SHORTCUT':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\tkeyCombination: action.keyCombination,\n\t\t\t\t\taliases: action.aliases,\n\t\t\t\t\tdescription: action.description,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_SHORTCUT':\n\t\t\tconst { [ action.name ]: actionName, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAOA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACtC,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,mBAAmB;MACvB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChBC,QAAQ,EAAEH,MAAM,CAACG,QAAQ;UACzBC,cAAc,EAAEJ,MAAM,CAACI,cAAc;UACrCC,OAAO,EAAEL,MAAM,CAACK,OAAO;UACvBC,WAAW,EAAEN,MAAM,CAACM;QACrB;MACD,CAAC;IACF,KAAK,qBAAqB;MACzB,MAAM;QAAE,CAAEN,MAAM,CAACE,IAAI,GAAIK,UAAU;QAAE,GAAGC;MAAe,CAAC,GAAGT,KAAK;MAChE,OAAOS,cAAc;EACvB;EAEA,OAAOT,KAAK;AACb;AAAC,IAAAU,QAAA,GAEcX,OAAO;AAAAY,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -10,11 +9,8 @@ exports.getShortcutAliases = getShortcutAliases;
10
9
  exports.getShortcutDescription = getShortcutDescription;
11
10
  exports.getShortcutKeyCombination = getShortcutKeyCombination;
12
11
  exports.getShortcutRepresentation = getShortcutRepresentation;
13
-
14
12
  var _rememo = _interopRequireDefault(require("rememo"));
15
-
16
13
  var _keycodes = require("@wordpress/keycodes");
17
-
18
14
  /**
19
15
  * External dependencies
20
16
  */
@@ -34,6 +30,7 @@ var _keycodes = require("@wordpress/keycodes");
34
30
  * @type {Array<any>}
35
31
  */
36
32
  const EMPTY_ARRAY = [];
33
+
37
34
  /**
38
35
  * Shortcut formatting methods.
39
36
  *
@@ -41,12 +38,12 @@ const EMPTY_ARRAY = [];
41
38
  * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
42
39
  * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.
43
40
  */
44
-
45
41
  const FORMATTING_METHODS = {
46
42
  display: _keycodes.displayShortcut,
47
43
  raw: _keycodes.rawShortcut,
48
44
  ariaLabel: _keycodes.shortcutAriaLabel
49
45
  };
46
+
50
47
  /**
51
48
  * Returns a string representing the key combination.
52
49
  *
@@ -56,14 +53,13 @@ const FORMATTING_METHODS = {
56
53
  *
57
54
  * @return {string?} Shortcut representation.
58
55
  */
59
-
60
56
  function getKeyCombinationRepresentation(shortcut, representation) {
61
57
  if (!shortcut) {
62
58
  return null;
63
59
  }
64
-
65
60
  return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
66
61
  }
62
+
67
63
  /**
68
64
  * Returns the main key combination for a given shortcut name.
69
65
  *
@@ -105,11 +101,10 @@ function getKeyCombinationRepresentation(shortcut, representation) {
105
101
  *
106
102
  * @return {WPShortcutKeyCombination?} Key combination.
107
103
  */
108
-
109
-
110
104
  function getShortcutKeyCombination(state, name) {
111
105
  return state[name] ? state[name].keyCombination : null;
112
106
  }
107
+
113
108
  /**
114
109
  * Returns a string representing the main key combination for a given shortcut name.
115
110
  *
@@ -148,12 +143,11 @@ function getShortcutKeyCombination(state, name) {
148
143
  *
149
144
  * @return {string?} Shortcut representation.
150
145
  */
151
-
152
-
153
146
  function getShortcutRepresentation(state, name, representation = 'display') {
154
147
  const shortcut = getShortcutKeyCombination(state, name);
155
148
  return getKeyCombinationRepresentation(shortcut, representation);
156
149
  }
150
+
157
151
  /**
158
152
  * Returns the shortcut description given its name.
159
153
  *
@@ -182,11 +176,10 @@ function getShortcutRepresentation(state, name, representation = 'display') {
182
176
  *```
183
177
  * @return {string?} Shortcut description.
184
178
  */
185
-
186
-
187
179
  function getShortcutDescription(state, name) {
188
180
  return state[name] ? state[name].description : null;
189
181
  }
182
+
190
183
  /**
191
184
  * Returns the aliases for a given shortcut name.
192
185
  *
@@ -233,11 +226,10 @@ function getShortcutDescription(state, name) {
233
226
  *
234
227
  * @return {WPShortcutKeyCombination[]} Key combinations.
235
228
  */
236
-
237
-
238
229
  function getShortcutAliases(state, name) {
239
230
  return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
240
231
  }
232
+
241
233
  /**
242
234
  * Returns the shortcuts that include aliases for a given shortcut name.
243
235
  *
@@ -287,11 +279,10 @@ function getShortcutAliases(state, name) {
287
279
  *
288
280
  * @return {WPShortcutKeyCombination[]} Key combinations.
289
281
  */
290
-
291
-
292
282
  const getAllShortcutKeyCombinations = (0, _rememo.default)((state, name) => {
293
283
  return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
294
284
  }, (state, name) => [state[name]]);
285
+
295
286
  /**
296
287
  * Returns the raw representation of all the keyboard combinations of a given shortcut name.
297
288
  *
@@ -341,11 +332,11 @@ const getAllShortcutKeyCombinations = (0, _rememo.default)((state, name) => {
341
332
  *
342
333
  * @return {string[]} Shortcuts.
343
334
  */
344
-
345
335
  exports.getAllShortcutKeyCombinations = getAllShortcutKeyCombinations;
346
336
  const getAllShortcutRawKeyCombinations = (0, _rememo.default)((state, name) => {
347
337
  return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
348
338
  }, (state, name) => [state[name]]);
339
+
349
340
  /**
350
341
  * Returns the shortcut names list for a given category name.
351
342
  *
@@ -379,7 +370,6 @@ const getAllShortcutRawKeyCombinations = (0, _rememo.default)((state, name) => {
379
370
  *```
380
371
  * @return {string[]} Shortcut names.
381
372
  */
382
-
383
373
  exports.getAllShortcutRawKeyCombinations = getAllShortcutRawKeyCombinations;
384
374
  const getCategoryShortcuts = (0, _rememo.default)((state, categoryName) => {
385
375
  return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/selectors.js"],"names":["EMPTY_ARRAY","FORMATTING_METHODS","display","displayShortcut","raw","rawShortcut","ariaLabel","shortcutAriaLabel","getKeyCombinationRepresentation","shortcut","representation","modifier","character","getShortcutKeyCombination","state","name","keyCombination","getShortcutRepresentation","getShortcutDescription","description","getShortcutAliases","aliases","getAllShortcutKeyCombinations","filter","Boolean","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","category"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,kBAAkB,GAAG;AAC1BC,EAAAA,OAAO,EAAEC,yBADiB;AAE1BC,EAAAA,GAAG,EAAEC,qBAFqB;AAG1BC,EAAAA,SAAS,EAAEC;AAHe,CAA3B;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,+BAAT,CAA0CC,QAA1C,EAAoDC,cAApD,EAAqE;AACpE,MAAK,CAAED,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SAAOA,QAAQ,CAACE,QAAT,GACJV,kBAAkB,CAAES,cAAF,CAAlB,CAAsCD,QAAQ,CAACE,QAA/C,EACAF,QAAQ,CAACG,SADT,CADI,GAIJH,QAAQ,CAACG,SAJZ;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,yBAAT,CAAoCC,KAApC,EAA2CC,IAA3C,EAAkD;AACxD,SAAOD,KAAK,CAAEC,IAAF,CAAL,GAAgBD,KAAK,CAAEC,IAAF,CAAL,CAAcC,cAA9B,GAA+C,IAAtD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,yBAAT,CACNH,KADM,EAENC,IAFM,EAGNL,cAAc,GAAG,SAHX,EAIL;AACD,QAAMD,QAAQ,GAAGI,yBAAyB,CAAEC,KAAF,EAASC,IAAT,CAA1C;AACA,SAAOP,+BAA+B,CAAEC,QAAF,EAAYC,cAAZ,CAAtC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASQ,sBAAT,CAAiCJ,KAAjC,EAAwCC,IAAxC,EAA+C;AACrD,SAAOD,KAAK,CAAEC,IAAF,CAAL,GAAgBD,KAAK,CAAEC,IAAF,CAAL,CAAcI,WAA9B,GAA4C,IAAnD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,kBAAT,CAA6BN,KAA7B,EAAoCC,IAApC,EAA2C;AACjD,SAAOD,KAAK,CAAEC,IAAF,CAAL,IAAiBD,KAAK,CAAEC,IAAF,CAAL,CAAcM,OAA/B,GACJP,KAAK,CAAEC,IAAF,CAAL,CAAcM,OADV,GAEJrB,WAFH;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMsB,6BAA6B,GAAG,qBAC5C,CAAER,KAAF,EAASC,IAAT,KAAmB;AAClB,SAAO,CACNF,yBAAyB,CAAEC,KAAF,EAASC,IAAT,CADnB,EAEN,GAAGK,kBAAkB,CAAEN,KAAF,EAASC,IAAT,CAFf,EAGLQ,MAHK,CAGGC,OAHH,CAAP;AAIA,CAN2C,EAO5C,CAAEV,KAAF,EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAPyB,CAAtC;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMU,gCAAgC,GAAG,qBAC/C,CAAEX,KAAF,EAASC,IAAT,KAAmB;AAClB,SAAOO,6BAA6B,CAAER,KAAF,EAASC,IAAT,CAA7B,CAA6CW,GAA7C,CACJC,WAAF,IACCnB,+BAA+B,CAAEmB,WAAF,EAAe,KAAf,CAF1B,CAAP;AAIA,CAN8C,EAO/C,CAAEb,KAAF,EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAP4B,CAAzC;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMa,oBAAoB,GAAG,qBACnC,CAAEd,KAAF,EAASe,YAAT,KAA2B;AAC1B,SAAOC,MAAM,CAACC,OAAP,CAAgBjB,KAAhB,EACLS,MADK,CACG,CAAE,GAAId,QAAJ,CAAF,KAAsBA,QAAQ,CAACuB,QAAT,KAAsBH,YAD/C,EAELH,GAFK,CAEA,CAAE,CAAEX,IAAF,CAAF,KAAgBA,IAFhB,CAAP;AAGA,CALkC,EAMjCD,KAAF,IAAa,CAAEA,KAAF,CANsB,CAA7B","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tdisplayShortcut,\n\tshortcutAriaLabel,\n\trawShortcut,\n} from '@wordpress/keycodes';\n\n/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */\n\n/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Shortcut formatting methods.\n *\n * @property {WPKeycodeHandlerByModifier} display Display formatting.\n * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.\n * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.\n */\nconst FORMATTING_METHODS = {\n\tdisplay: displayShortcut,\n\traw: rawShortcut,\n\tariaLabel: shortcutAriaLabel,\n};\n\n/**\n * Returns a string representing the key combination.\n *\n * @param {?WPShortcutKeyCombination} shortcut Key combination.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n *\n * @return {string?} Shortcut representation.\n */\nfunction getKeyCombinationRepresentation( shortcut, representation ) {\n\tif ( ! shortcut ) {\n\t\treturn null;\n\t}\n\n\treturn shortcut.modifier\n\t\t? FORMATTING_METHODS[ representation ][ shortcut.modifier ](\n\t\t\t\tshortcut.character\n\t\t )\n\t\t: shortcut.character;\n}\n\n/**\n * Returns the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const {character, modifier} = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * <div>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </div>\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination?} Key combination.\n */\nexport function getShortcutKeyCombination( state, name ) {\n\treturn state[ name ] ? state[ name ].keyCombination : null;\n}\n\n/**\n * Returns a string representing the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const {display, raw, ariaLabel} = useSelect(\n * ( select ) =>{\n * return {\n * display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region' ),\n * raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region','raw' ),\n * ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region', 'ariaLabel')\n * }\n * },\n * []\n * );\n *\n * return (\n * <ul>\n * <li>{ sprintf( 'display string: %s', display ) }</li>\n * <li>{ sprintf( 'raw string: %s', raw ) }</li>\n * <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>\n * </ul>\n * );\n * };\n *```\n *\n * @return {string?} Shortcut representation.\n */\nexport function getShortcutRepresentation(\n\tstate,\n\tname,\n\trepresentation = 'display'\n) {\n\tconst shortcut = getShortcutKeyCombination( state, name );\n\treturn getKeyCombinationRepresentation( shortcut, representation );\n}\n\n/**\n * Returns the shortcut description given its name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutDescription = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutDescription( 'core/edit-post/next-region' ),\n * []\n * );\n *\n * return shortcutDescription ? (\n * <div>{ shortcutDescription }</div>\n * ) : (\n * <div>{ __( 'No description.' ) }</div>\n * );\n * };\n *```\n * @return {string?} Shortcut description.\n */\nexport function getShortcutDescription( state, name ) {\n\treturn state[ name ] ? state[ name ].description : null;\n}\n\n/**\n * Returns the aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutAliases = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutAliases(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * shortcutAliases.length > 0 && (\n * <ul>\n * { shortcutAliases.map( ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport function getShortcutAliases( state, name ) {\n\treturn state[ name ] && state[ name ].aliases\n\t\t? state[ name ].aliases\n\t\t: EMPTY_ARRAY;\n}\n\n/**\n * Returns the shortcuts that include aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutKeyCombinations.map(\n * ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t].filter( Boolean );\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the raw representation of all the keyboard combinations of a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutRawKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutRawKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutRawKeyCombinations.map(\n * ( shortcutRawKeyCombination, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * ' <code>%s</code>',\n * shortcutRawKeyCombination\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations( state, name ).map(\n\t\t\t( combination ) =>\n\t\t\t\tgetKeyCombinationRepresentation( combination, 'raw' )\n\t\t);\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the shortcut names list for a given category name.\n *\n * @param {Object} state Global state.\n * @param {string} name Category name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const categoryShortcuts = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getCategoryShortcuts(\n * 'block'\n * ),\n * []\n * );\n *\n * return (\n * categoryShortcuts.length > 0 && (\n * <ul>\n * { categoryShortcuts.map( ( categoryShortcut ) => (\n * <li key={ categoryShortcut }>{ categoryShortcut }</li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n * @return {string[]} Shortcut names.\n */\nexport const getCategoryShortcuts = createSelector(\n\t( state, categoryName ) => {\n\t\treturn Object.entries( state )\n\t\t\t.filter( ( [ , shortcut ] ) => shortcut.category === categoryName )\n\t\t\t.map( ( [ name ] ) => name );\n\t},\n\t( state ) => [ state ]\n);\n"]}
1
+ {"version":3,"names":["_rememo","_interopRequireDefault","require","_keycodes","EMPTY_ARRAY","FORMATTING_METHODS","display","displayShortcut","raw","rawShortcut","ariaLabel","shortcutAriaLabel","getKeyCombinationRepresentation","shortcut","representation","modifier","character","getShortcutKeyCombination","state","name","keyCombination","getShortcutRepresentation","getShortcutDescription","description","getShortcutAliases","aliases","getAllShortcutKeyCombinations","createSelector","filter","Boolean","exports","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","category"],"sources":["@wordpress/keyboard-shortcuts/src/store/selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tdisplayShortcut,\n\tshortcutAriaLabel,\n\trawShortcut,\n} from '@wordpress/keycodes';\n\n/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */\n\n/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Shortcut formatting methods.\n *\n * @property {WPKeycodeHandlerByModifier} display Display formatting.\n * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.\n * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.\n */\nconst FORMATTING_METHODS = {\n\tdisplay: displayShortcut,\n\traw: rawShortcut,\n\tariaLabel: shortcutAriaLabel,\n};\n\n/**\n * Returns a string representing the key combination.\n *\n * @param {?WPShortcutKeyCombination} shortcut Key combination.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n *\n * @return {string?} Shortcut representation.\n */\nfunction getKeyCombinationRepresentation( shortcut, representation ) {\n\tif ( ! shortcut ) {\n\t\treturn null;\n\t}\n\n\treturn shortcut.modifier\n\t\t? FORMATTING_METHODS[ representation ][ shortcut.modifier ](\n\t\t\t\tshortcut.character\n\t\t )\n\t\t: shortcut.character;\n}\n\n/**\n * Returns the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const {character, modifier} = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * <div>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </div>\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination?} Key combination.\n */\nexport function getShortcutKeyCombination( state, name ) {\n\treturn state[ name ] ? state[ name ].keyCombination : null;\n}\n\n/**\n * Returns a string representing the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const {display, raw, ariaLabel} = useSelect(\n * ( select ) =>{\n * return {\n * display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region' ),\n * raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region','raw' ),\n * ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region', 'ariaLabel')\n * }\n * },\n * []\n * );\n *\n * return (\n * <ul>\n * <li>{ sprintf( 'display string: %s', display ) }</li>\n * <li>{ sprintf( 'raw string: %s', raw ) }</li>\n * <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>\n * </ul>\n * );\n * };\n *```\n *\n * @return {string?} Shortcut representation.\n */\nexport function getShortcutRepresentation(\n\tstate,\n\tname,\n\trepresentation = 'display'\n) {\n\tconst shortcut = getShortcutKeyCombination( state, name );\n\treturn getKeyCombinationRepresentation( shortcut, representation );\n}\n\n/**\n * Returns the shortcut description given its name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutDescription = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutDescription( 'core/edit-post/next-region' ),\n * []\n * );\n *\n * return shortcutDescription ? (\n * <div>{ shortcutDescription }</div>\n * ) : (\n * <div>{ __( 'No description.' ) }</div>\n * );\n * };\n *```\n * @return {string?} Shortcut description.\n */\nexport function getShortcutDescription( state, name ) {\n\treturn state[ name ] ? state[ name ].description : null;\n}\n\n/**\n * Returns the aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutAliases = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutAliases(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * shortcutAliases.length > 0 && (\n * <ul>\n * { shortcutAliases.map( ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport function getShortcutAliases( state, name ) {\n\treturn state[ name ] && state[ name ].aliases\n\t\t? state[ name ].aliases\n\t\t: EMPTY_ARRAY;\n}\n\n/**\n * Returns the shortcuts that include aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutKeyCombinations.map(\n * ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t].filter( Boolean );\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the raw representation of all the keyboard combinations of a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutRawKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutRawKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutRawKeyCombinations.map(\n * ( shortcutRawKeyCombination, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * ' <code>%s</code>',\n * shortcutRawKeyCombination\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations( state, name ).map(\n\t\t\t( combination ) =>\n\t\t\t\tgetKeyCombinationRepresentation( combination, 'raw' )\n\t\t);\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the shortcut names list for a given category name.\n *\n * @param {Object} state Global state.\n * @param {string} name Category name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const categoryShortcuts = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getCategoryShortcuts(\n * 'block'\n * ),\n * []\n * );\n *\n * return (\n * categoryShortcuts.length > 0 && (\n * <ul>\n * { categoryShortcuts.map( ( categoryShortcut ) => (\n * <li key={ categoryShortcut }>{ categoryShortcut }</li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n * @return {string[]} Shortcut names.\n */\nexport const getCategoryShortcuts = createSelector(\n\t( state, categoryName ) => {\n\t\treturn Object.entries( state )\n\t\t\t.filter( ( [ , shortcut ] ) => shortcut.category === categoryName )\n\t\t\t.map( ( [ name ] ) => name );\n\t},\n\t( state ) => [ state ]\n);\n"],"mappings":";;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAME,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;EAC1BC,OAAO,EAAEC,yBAAe;EACxBC,GAAG,EAAEC,qBAAW;EAChBC,SAAS,EAAEC;AACZ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,+BAA+BA,CAAEC,QAAQ,EAAEC,cAAc,EAAG;EACpE,IAAK,CAAED,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOA,QAAQ,CAACE,QAAQ,GACrBV,kBAAkB,CAAES,cAAc,CAAE,CAAED,QAAQ,CAACE,QAAQ,CAAE,CACzDF,QAAQ,CAACG,SACT,CAAC,GACDH,QAAQ,CAACG,SAAS;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CAAEC,KAAK,EAAEC,IAAI,EAAG;EACxD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACC,cAAc,GAAG,IAAI;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CACxCH,KAAK,EACLC,IAAI,EACJL,cAAc,GAAG,SAAS,EACzB;EACD,MAAMD,QAAQ,GAAGI,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC;EACzD,OAAOP,+BAA+B,CAAEC,QAAQ,EAAEC,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,sBAAsBA,CAAEJ,KAAK,EAAEC,IAAI,EAAG;EACrD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACI,WAAW,GAAG,IAAI;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAEN,KAAK,EAAEC,IAAI,EAAG;EACjD,OAAOD,KAAK,CAAEC,IAAI,CAAE,IAAID,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GAC1CP,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GACrBrB,WAAW;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMsB,6BAA6B,GAAG,IAAAC,eAAc,EAC1D,CAAET,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAO,CACNF,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC,EACxC,GAAGK,kBAAkB,CAAEN,KAAK,EAAEC,IAAK,CAAC,CACpC,CAACS,MAAM,CAAEC,OAAQ,CAAC;AACpB,CAAC,EACD,CAAEX,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAhDAW,OAAA,CAAAJ,6BAAA,GAAAA,6BAAA;AAiDO,MAAMK,gCAAgC,GAAG,IAAAJ,eAAc,EAC7D,CAAET,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAOO,6BAA6B,CAAER,KAAK,EAAEC,IAAK,CAAC,CAACa,GAAG,CACpDC,WAAW,IACZrB,+BAA+B,CAAEqB,WAAW,EAAE,KAAM,CACtD,CAAC;AACF,CAAC,EACD,CAAEf,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAhCAW,OAAA,CAAAC,gCAAA,GAAAA,gCAAA;AAiCO,MAAMG,oBAAoB,GAAG,IAAAP,eAAc,EACjD,CAAET,KAAK,EAAEiB,YAAY,KAAM;EAC1B,OAAOC,MAAM,CAACC,OAAO,CAAEnB,KAAM,CAAC,CAC5BU,MAAM,CAAE,CAAE,GAAIf,QAAQ,CAAE,KAAMA,QAAQ,CAACyB,QAAQ,KAAKH,YAAa,CAAC,CAClEH,GAAG,CAAE,CAAE,CAAEb,IAAI,CAAE,KAAMA,IAAK,CAAC;AAC9B,CAAC,EACCD,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC;AAACY,OAAA,CAAAI,oBAAA,GAAAA,oBAAA"}
@@ -1,17 +1,17 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
6
5
  import { useRef } from '@wordpress/element';
6
+
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
-
11
10
  import { context } from '../context';
12
11
  const {
13
12
  Provider
14
13
  } = context;
14
+
15
15
  /**
16
16
  * Handles callbacks added to context by `useShortcut`.
17
17
  *
@@ -19,23 +19,20 @@ const {
19
19
  *
20
20
  * @return {import('@wordpress/element').WPElement} Component.
21
21
  */
22
-
23
22
  export function ShortcutProvider(props) {
24
23
  const keyboardShortcuts = useRef(new Set());
25
-
26
24
  function onKeyDown(event) {
27
25
  if (props.onKeyDown) props.onKeyDown(event);
28
-
29
26
  for (const keyboardShortcut of keyboardShortcuts.current) {
30
27
  keyboardShortcut(event);
31
28
  }
32
29
  }
33
- /* eslint-disable jsx-a11y/no-static-element-interactions */
34
-
35
30
 
31
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
36
32
  return createElement(Provider, {
37
33
  value: keyboardShortcuts
38
- }, createElement("div", { ...props,
34
+ }, createElement("div", {
35
+ ...props,
39
36
  onKeyDown: onKeyDown
40
37
  }));
41
38
  /* eslint-enable jsx-a11y/no-static-element-interactions */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"names":["useRef","context","Provider","ShortcutProvider","props","keyboardShortcuts","Set","onKeyDown","event","keyboardShortcut","current"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,YAAxB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAeD,OAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,gBAAT,CAA2BC,KAA3B,EAAmC;AACzC,QAAMC,iBAAiB,GAAGL,MAAM,CAAE,IAAIM,GAAJ,EAAF,CAAhC;;AAEA,WAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,QAAKJ,KAAK,CAACG,SAAX,EAAuBH,KAAK,CAACG,SAAN,CAAiBC,KAAjB;;AAEvB,SAAM,MAAMC,gBAAZ,IAAgCJ,iBAAiB,CAACK,OAAlD,EAA4D;AAC3DD,MAAAA,gBAAgB,CAAED,KAAF,CAAhB;AACA;AACD;AAED;;;AACA,SACC,cAAC,QAAD;AAAU,IAAA,KAAK,EAAGH;AAAlB,KACC,0BAAUD,KAAV;AAAkB,IAAA,SAAS,EAAGG;AAA9B,IADD,CADD;AAKA;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {import('@wordpress/element').WPElement} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"]}
1
+ {"version":3,"names":["useRef","context","Provider","ShortcutProvider","props","keyboardShortcuts","Set","onKeyDown","event","keyboardShortcut","current","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {import('@wordpress/element').WPElement} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,YAAY;AAEpC,MAAM;EAAEC;AAAS,CAAC,GAAGD,OAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAMC,iBAAiB,GAAGL,MAAM,CAAE,IAAIM,GAAG,CAAC,CAAE,CAAC;EAE7C,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKJ,KAAK,CAACG,SAAS,EAAGH,KAAK,CAACG,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIJ,iBAAiB,CAACK,OAAO,EAAG;MAC3DD,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACCG,aAAA,CAACT,QAAQ;IAACU,KAAK,EAAGP;EAAmB,GACpCM,aAAA;IAAA,GAAUP,KAAK;IAAGG,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/context.js"],"names":["createContext","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA,OAAO,MAAMC,OAAO,GAAGD,aAAa,EAA7B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const context = createContext();\n"]}
1
+ {"version":3,"names":["createContext","context"],"sources":["@wordpress/keyboard-shortcuts/src/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const context = createContext();\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;AAElD,OAAO,MAAMC,OAAO,GAAGD,aAAa,CAAC,CAAC"}
@@ -3,22 +3,23 @@
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
5
  import { isKeyboardEvent } from '@wordpress/keycodes';
6
+
6
7
  /**
7
8
  * Internal dependencies
8
9
  */
9
-
10
10
  import { store as keyboardShortcutsStore } from '../store';
11
+
11
12
  /**
12
13
  * Returns a function to check if a keyboard event matches a shortcut name.
13
14
  *
14
15
  * @return {Function} A function to check if a keyboard event matches a
15
16
  * predefined shortcut combination.
16
17
  */
17
-
18
18
  export default function useShortcutEventMatch() {
19
19
  const {
20
20
  getAllShortcutKeyCombinations
21
21
  } = useSelect(keyboardShortcutsStore);
22
+
22
23
  /**
23
24
  * A function to check if a keyboard event matches a predefined shortcut
24
25
  * combination.
@@ -28,7 +29,6 @@ export default function useShortcutEventMatch() {
28
29
  *
29
30
  * @return {boolean} True if the event matches any shortcuts, false if not.
30
31
  */
31
-
32
32
  function isMatch(name, event) {
33
33
  return getAllShortcutKeyCombinations(name).some(({
34
34
  modifier,
@@ -37,7 +37,6 @@ export default function useShortcutEventMatch() {
37
37
  return isKeyboardEvent[modifier](event, character);
38
38
  });
39
39
  }
40
-
41
40
  return isMatch;
42
41
  }
43
42
  //# sourceMappingURL=use-shortcut-event-match.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"names":["useSelect","isKeyboardEvent","store","keyboardShortcutsStore","useShortcutEventMatch","getAllShortcutKeyCombinations","isMatch","name","event","some","modifier","character"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,eAAT,QAAgC,qBAAhC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,sBAAlB,QAAgD,UAAhD;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,qBAAT,GAAiC;AAC/C,QAAM;AAAEC,IAAAA;AAAF,MAAoCL,SAAS,CAClDG,sBADkD,CAAnD;AAIA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,WAASG,OAAT,CAAkBC,IAAlB,EAAwBC,KAAxB,EAAgC;AAC/B,WAAOH,6BAA6B,CAAEE,IAAF,CAA7B,CAAsCE,IAAtC,CACN,CAAE;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,KAAF,KAA+B;AAC9B,aAAOV,eAAe,CAAES,QAAF,CAAf,CAA6BF,KAA7B,EAAoCG,SAApC,CAAP;AACA,KAHK,CAAP;AAKA;;AAED,SAAOL,OAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"]}
1
+ {"version":3,"names":["useSelect","isKeyboardEvent","store","keyboardShortcutsStore","useShortcutEventMatch","getAllShortcutKeyCombinations","isMatch","name","event","some","modifier","character"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,qBAAqB;;AAErD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,sBAAsB,QAAQ,UAAU;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAA8B,CAAC,GAAGL,SAAS,CAClDG,sBACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,SAASG,OAAOA,CAAEC,IAAI,EAAEC,KAAK,EAAG;IAC/B,OAAOH,6BAA6B,CAAEE,IAAK,CAAC,CAACE,IAAI,CAChD,CAAE;MAAEC,QAAQ;MAAEC;IAAU,CAAC,KAAM;MAC9B,OAAOV,eAAe,CAAES,QAAQ,CAAE,CAAEF,KAAK,EAAEG,SAAU,CAAC;IACvD,CACD,CAAC;EACF;EAEA,OAAOL,OAAO;AACf"}
@@ -2,12 +2,13 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useContext, useEffect, useRef } from '@wordpress/element';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import useShortcutEventMatch from './use-shortcut-event-match';
10
10
  import { context } from '../context';
11
+
11
12
  /**
12
13
  * Attach a keyboard shortcut handler.
13
14
  *
@@ -16,7 +17,6 @@ import { context } from '../context';
16
17
  * @param {Object} options Shortcut options.
17
18
  * @param {boolean} options.isDisabled Whether to disable to shortut.
18
19
  */
19
-
20
20
  export default function useShortcut(name, callback, {
21
21
  isDisabled
22
22
  } = {}) {
@@ -28,13 +28,11 @@ export default function useShortcut(name, callback, {
28
28
  if (isDisabled) {
29
29
  return;
30
30
  }
31
-
32
31
  function _callback(event) {
33
32
  if (isMatch(name, event)) {
34
33
  callbackRef.current(event);
35
34
  }
36
35
  }
37
-
38
36
  shortcuts.current.add(_callback);
39
37
  return () => {
40
38
  shortcuts.current.delete(_callback);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"names":["useContext","useEffect","useRef","useShortcutEventMatch","context","useShortcut","name","callback","isDisabled","shortcuts","isMatch","callbackRef","current","_callback","event","add","delete"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,SAArB,EAAgCC,MAAhC,QAA8C,oBAA9C;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,SAASC,OAAT,QAAwB,YAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsBC,IAAtB,EAA4BC,QAA5B,EAAsC;AAAEC,EAAAA;AAAF,IAAiB,EAAvD,EAA4D;AAC1E,QAAMC,SAAS,GAAGT,UAAU,CAAEI,OAAF,CAA5B;AACA,QAAMM,OAAO,GAAGP,qBAAqB,EAArC;AACA,QAAMQ,WAAW,GAAGT,MAAM,EAA1B;AACAS,EAAAA,WAAW,CAACC,OAAZ,GAAsBL,QAAtB;AAEAN,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKO,UAAL,EAAkB;AACjB;AACA;;AAED,aAASK,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UAAKJ,OAAO,CAAEJ,IAAF,EAAQQ,KAAR,CAAZ,EAA8B;AAC7BH,QAAAA,WAAW,CAACC,OAAZ,CAAqBE,KAArB;AACA;AACD;;AAEDL,IAAAA,SAAS,CAACG,OAAV,CAAkBG,GAAlB,CAAuBF,SAAvB;AACA,WAAO,MAAM;AACZJ,MAAAA,SAAS,CAACG,OAAV,CAAkBI,MAAlB,CAA0BH,SAA1B;AACA,KAFD;AAGA,GAfQ,EAeN,CAAEP,IAAF,EAAQE,UAAR,CAfM,CAAT;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut( name, callback, { isDisabled } = {} ) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\tcallbackRef.current = callback;\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.current.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.current.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled ] );\n}\n"]}
1
+ {"version":3,"names":["useContext","useEffect","useRef","useShortcutEventMatch","context","useShortcut","name","callback","isDisabled","shortcuts","isMatch","callbackRef","current","_callback","event","add","delete"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut( name, callback, { isDisabled } = {} ) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\tcallbackRef.current = callback;\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.current.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.current.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,SAASC,OAAO,QAAQ,YAAY;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAAEC,IAAI,EAAEC,QAAQ,EAAE;EAAEC;AAAW,CAAC,GAAG,CAAC,CAAC,EAAG;EAC1E,MAAMC,SAAS,GAAGT,UAAU,CAAEI,OAAQ,CAAC;EACvC,MAAMM,OAAO,GAAGP,qBAAqB,CAAC,CAAC;EACvC,MAAMQ,WAAW,GAAGT,MAAM,CAAC,CAAC;EAC5BS,WAAW,CAACC,OAAO,GAAGL,QAAQ;EAE9BN,SAAS,CAAE,MAAM;IAChB,IAAKO,UAAU,EAAG;MACjB;IACD;IAEA,SAASK,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKJ,OAAO,CAAEJ,IAAI,EAAEQ,KAAM,CAAC,EAAG;QAC7BH,WAAW,CAACC,OAAO,CAAEE,KAAM,CAAC;MAC7B;IACD;IAEAL,SAAS,CAACG,OAAO,CAACG,GAAG,CAAEF,SAAU,CAAC;IAClC,OAAO,MAAM;MACZJ,SAAS,CAACG,OAAO,CAACI,MAAM,CAAEH,SAAU,CAAC;IACtC,CAAC;EACF,CAAC,EAAE,CAAEP,IAAI,EAAEE,UAAU,CAAG,CAAC;AAC1B"}
@@ -1,4 +1,3 @@
1
1
  const useShortcut = () => null;
2
-
3
2
  export default useShortcut;
4
3
  //# sourceMappingURL=use-shortcut.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.native.js"],"names":["useShortcut"],"mappings":"AAAA,MAAMA,WAAW,GAAG,MAAM,IAA1B;;AACA,eAAeA,WAAf","sourcesContent":["const useShortcut = () => null;\nexport default useShortcut;\n"]}
1
+ {"version":3,"names":["useShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.native.js"],"sourcesContent":["const useShortcut = () => null;\nexport default useShortcut;\n"],"mappings":"AAAA,MAAMA,WAAW,GAAGA,CAAA,KAAM,IAAI;AAC9B,eAAeA,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"names":["store","default","useShortcut","ShortcutProvider","__unstableUseShortcutEventMatch"],"mappings":"AAAA,SAASA,KAAT,QAAsB,SAAtB;AACA,SAASC,OAAO,IAAIC,WAApB,QAAuC,sBAAvC;AACA,SAASC,gBAAT,QAAiC,gCAAjC;AACA,SAASF,OAAO,IAAIG,+BAApB,QAA2D,kCAA3D","sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"]}
1
+ {"version":3,"names":["store","default","useShortcut","ShortcutProvider","__unstableUseShortcutEventMatch"],"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,SAAS;AAC/B,SAASC,OAAO,IAAIC,WAAW,QAAQ,sBAAsB;AAC7D,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,SAASF,OAAO,IAAIG,+BAA+B,QAAQ,kCAAkC"}
@@ -82,6 +82,7 @@ export function registerShortcut({
82
82
  description
83
83
  };
84
84
  }
85
+
85
86
  /**
86
87
  * Returns an action object used to unregister a keyboard shortcut.
87
88
  *
@@ -119,7 +120,6 @@ export function registerShortcut({
119
120
  *```
120
121
  * @return {Object} action.
121
122
  */
122
-
123
123
  export function unregisterShortcut(name) {
124
124
  return {
125
125
  type: 'UNREGISTER_SHORTCUT',
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAT,CAA2B;AACjCC,EAAAA,IADiC;AAEjCC,EAAAA,QAFiC;AAGjCC,EAAAA,WAHiC;AAIjCC,EAAAA,cAJiC;AAKjCC,EAAAA;AALiC,CAA3B,EAMH;AACH,SAAO;AACNC,IAAAA,IAAI,EAAE,mBADA;AAENL,IAAAA,IAFM;AAGNC,IAAAA,QAHM;AAINE,IAAAA,cAJM;AAKNC,IAAAA,OALM;AAMNF,IAAAA;AANM,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,kBAAT,CAA6BN,IAA7B,EAAoC;AAC1C,SAAO;AACNK,IAAAA,IAAI,EAAE,qBADA;AAENL,IAAAA;AAFM,GAAP;AAIA","sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"]}
1
+ {"version":3,"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { useEffect } from '@wordpress/element';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAAE;EACjCC,IAAI;EACJC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,OAAO;IACNC,IAAI,EAAE,mBAAmB;IACzBL,IAAI;IACJC,QAAQ;IACRE,cAAc;IACdC,OAAO;IACPF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,kBAAkBA,CAAEN,IAAI,EAAG;EAC1C,OAAO;IACNK,IAAI,EAAE,qBAAqB;IAC3BL;EACD,CAAC;AACF"}
@@ -2,14 +2,15 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createReduxStore, register } from '@wordpress/data';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import reducer from './reducer';
10
10
  import * as actions from './actions';
11
11
  import * as selectors from './selectors';
12
12
  const STORE_NAME = 'core/keyboard-shortcuts';
13
+
13
14
  /**
14
15
  * Store definition for the keyboard shortcuts namespace.
15
16
  *
@@ -17,7 +18,6 @@ const STORE_NAME = 'core/keyboard-shortcuts';
17
18
  *
18
19
  * @type {Object}
19
20
  */
20
-
21
21
  export const store = createReduxStore(STORE_NAME, {
22
22
  reducer,
23
23
  actions,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/index.js"],"names":["createReduxStore","register","reducer","actions","selectors","STORE_NAME","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,QAA3B,QAA2C,iBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AAEA,MAAMC,UAAU,GAAG,yBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAF,EAAc;AAClDH,EAAAA,OADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAAd,CAA9B;AAMPH,QAAQ,CAAEK,KAAF,CAAR","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/keyboard-shortcuts';\n\n/**\n * Store definition for the keyboard shortcuts namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"]}
1
+ {"version":3,"names":["createReduxStore","register","reducer","actions","selectors","STORE_NAME","store"],"sources":["@wordpress/keyboard-shortcuts/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/keyboard-shortcuts';\n\n/**\n * Store definition for the keyboard shortcuts namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,SAAS,MAAM,aAAa;AAExC,MAAMC,UAAU,GAAG,yBAAyB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAU,EAAE;EAClDH,OAAO;EACPC,OAAO;EACPC;AACD,CAAE,CAAC;AAEHH,QAAQ,CAAEK,KAAM,CAAC"}
@@ -9,7 +9,8 @@
9
9
  function reducer(state = {}, action) {
10
10
  switch (action.type) {
11
11
  case 'REGISTER_SHORTCUT':
12
- return { ...state,
12
+ return {
13
+ ...state,
13
14
  [action.name]: {
14
15
  category: action.category,
15
16
  keyCombination: action.keyCombination,
@@ -17,7 +18,6 @@ function reducer(state = {}, action) {
17
18
  description: action.description
18
19
  }
19
20
  };
20
-
21
21
  case 'UNREGISTER_SHORTCUT':
22
22
  const {
23
23
  [action.name]: actionName,
@@ -25,9 +25,7 @@ function reducer(state = {}, action) {
25
25
  } = state;
26
26
  return remainingState;
27
27
  }
28
-
29
28
  return state;
30
29
  }
31
-
32
30
  export default reducer;
33
31
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"names":["reducer","state","action","type","name","category","keyCombination","aliases","description","actionName","remainingState"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,CAAkBC,KAAK,GAAG,EAA1B,EAA8BC,MAA9B,EAAuC;AACtC,UAASA,MAAM,CAACC,IAAhB;AACC,SAAK,mBAAL;AACC,aAAO,EACN,GAAGF,KADG;AAEN,SAAEC,MAAM,CAACE,IAAT,GAAiB;AAChBC,UAAAA,QAAQ,EAAEH,MAAM,CAACG,QADD;AAEhBC,UAAAA,cAAc,EAAEJ,MAAM,CAACI,cAFP;AAGhBC,UAAAA,OAAO,EAAEL,MAAM,CAACK,OAHA;AAIhBC,UAAAA,WAAW,EAAEN,MAAM,CAACM;AAJJ;AAFX,OAAP;;AASD,SAAK,qBAAL;AACC,YAAM;AAAE,SAAEN,MAAM,CAACE,IAAT,GAAiBK,UAAnB;AAA+B,WAAGC;AAAlC,UAAqDT,KAA3D;AACA,aAAOS,cAAP;AAbF;;AAgBA,SAAOT,KAAP;AACA;;AAED,eAAeD,OAAf","sourcesContent":["/**\n * Reducer returning the registered shortcuts\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction reducer( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_SHORTCUT':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\tkeyCombination: action.keyCombination,\n\t\t\t\t\taliases: action.aliases,\n\t\t\t\t\tdescription: action.description,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_SHORTCUT':\n\t\t\tconst { [ action.name ]: actionName, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"]}
1
+ {"version":3,"names":["reducer","state","action","type","name","category","keyCombination","aliases","description","actionName","remainingState"],"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"sourcesContent":["/**\n * Reducer returning the registered shortcuts\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction reducer( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_SHORTCUT':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\tkeyCombination: action.keyCombination,\n\t\t\t\t\taliases: action.aliases,\n\t\t\t\t\tdescription: action.description,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_SHORTCUT':\n\t\t\tconst { [ action.name ]: actionName, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAOA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACtC,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,mBAAmB;MACvB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChBC,QAAQ,EAAEH,MAAM,CAACG,QAAQ;UACzBC,cAAc,EAAEJ,MAAM,CAACI,cAAc;UACrCC,OAAO,EAAEL,MAAM,CAACK,OAAO;UACvBC,WAAW,EAAEN,MAAM,CAACM;QACrB;MACD,CAAC;IACF,KAAK,qBAAqB;MACzB,MAAM;QAAE,CAAEN,MAAM,CAACE,IAAI,GAAIK,UAAU;QAAE,GAAGC;MAAe,CAAC,GAAGT,KAAK;MAChE,OAAOS,cAAc;EACvB;EAEA,OAAOT,KAAK;AACb;AAEA,eAAeD,OAAO"}
@@ -2,11 +2,12 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
+
5
6
  /**
6
7
  * WordPress dependencies
7
8
  */
8
-
9
9
  import { displayShortcut, shortcutAriaLabel, rawShortcut } from '@wordpress/keycodes';
10
+
10
11
  /** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
11
12
 
12
13
  /** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */
@@ -17,8 +18,8 @@ import { displayShortcut, shortcutAriaLabel, rawShortcut } from '@wordpress/keyc
17
18
  *
18
19
  * @type {Array<any>}
19
20
  */
20
-
21
21
  const EMPTY_ARRAY = [];
22
+
22
23
  /**
23
24
  * Shortcut formatting methods.
24
25
  *
@@ -26,12 +27,12 @@ const EMPTY_ARRAY = [];
26
27
  * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
27
28
  * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.
28
29
  */
29
-
30
30
  const FORMATTING_METHODS = {
31
31
  display: displayShortcut,
32
32
  raw: rawShortcut,
33
33
  ariaLabel: shortcutAriaLabel
34
34
  };
35
+
35
36
  /**
36
37
  * Returns a string representing the key combination.
37
38
  *
@@ -41,14 +42,13 @@ const FORMATTING_METHODS = {
41
42
  *
42
43
  * @return {string?} Shortcut representation.
43
44
  */
44
-
45
45
  function getKeyCombinationRepresentation(shortcut, representation) {
46
46
  if (!shortcut) {
47
47
  return null;
48
48
  }
49
-
50
49
  return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
51
50
  }
51
+
52
52
  /**
53
53
  * Returns the main key combination for a given shortcut name.
54
54
  *
@@ -90,11 +90,10 @@ function getKeyCombinationRepresentation(shortcut, representation) {
90
90
  *
91
91
  * @return {WPShortcutKeyCombination?} Key combination.
92
92
  */
93
-
94
-
95
93
  export function getShortcutKeyCombination(state, name) {
96
94
  return state[name] ? state[name].keyCombination : null;
97
95
  }
96
+
98
97
  /**
99
98
  * Returns a string representing the main key combination for a given shortcut name.
100
99
  *
@@ -133,11 +132,11 @@ export function getShortcutKeyCombination(state, name) {
133
132
  *
134
133
  * @return {string?} Shortcut representation.
135
134
  */
136
-
137
135
  export function getShortcutRepresentation(state, name, representation = 'display') {
138
136
  const shortcut = getShortcutKeyCombination(state, name);
139
137
  return getKeyCombinationRepresentation(shortcut, representation);
140
138
  }
139
+
141
140
  /**
142
141
  * Returns the shortcut description given its name.
143
142
  *
@@ -166,10 +165,10 @@ export function getShortcutRepresentation(state, name, representation = 'display
166
165
  *```
167
166
  * @return {string?} Shortcut description.
168
167
  */
169
-
170
168
  export function getShortcutDescription(state, name) {
171
169
  return state[name] ? state[name].description : null;
172
170
  }
171
+
173
172
  /**
174
173
  * Returns the aliases for a given shortcut name.
175
174
  *
@@ -216,10 +215,10 @@ export function getShortcutDescription(state, name) {
216
215
  *
217
216
  * @return {WPShortcutKeyCombination[]} Key combinations.
218
217
  */
219
-
220
218
  export function getShortcutAliases(state, name) {
221
219
  return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
222
220
  }
221
+
223
222
  /**
224
223
  * Returns the shortcuts that include aliases for a given shortcut name.
225
224
  *
@@ -269,10 +268,10 @@ export function getShortcutAliases(state, name) {
269
268
  *
270
269
  * @return {WPShortcutKeyCombination[]} Key combinations.
271
270
  */
272
-
273
271
  export const getAllShortcutKeyCombinations = createSelector((state, name) => {
274
272
  return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
275
273
  }, (state, name) => [state[name]]);
274
+
276
275
  /**
277
276
  * Returns the raw representation of all the keyboard combinations of a given shortcut name.
278
277
  *
@@ -322,10 +321,10 @@ export const getAllShortcutKeyCombinations = createSelector((state, name) => {
322
321
  *
323
322
  * @return {string[]} Shortcuts.
324
323
  */
325
-
326
324
  export const getAllShortcutRawKeyCombinations = createSelector((state, name) => {
327
325
  return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
328
326
  }, (state, name) => [state[name]]);
327
+
329
328
  /**
330
329
  * Returns the shortcut names list for a given category name.
331
330
  *
@@ -359,7 +358,6 @@ export const getAllShortcutRawKeyCombinations = createSelector((state, name) =>
359
358
  *```
360
359
  * @return {string[]} Shortcut names.
361
360
  */
362
-
363
361
  export const getCategoryShortcuts = createSelector((state, categoryName) => {
364
362
  return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
365
363
  }, state => [state]);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/selectors.js"],"names":["createSelector","displayShortcut","shortcutAriaLabel","rawShortcut","EMPTY_ARRAY","FORMATTING_METHODS","display","raw","ariaLabel","getKeyCombinationRepresentation","shortcut","representation","modifier","character","getShortcutKeyCombination","state","name","keyCombination","getShortcutRepresentation","getShortcutDescription","description","getShortcutAliases","aliases","getAllShortcutKeyCombinations","filter","Boolean","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","category"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SACCC,eADD,EAECC,iBAFD,EAGCC,WAHD,QAIO,qBAJP;AAMA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,kBAAkB,GAAG;AAC1BC,EAAAA,OAAO,EAAEL,eADiB;AAE1BM,EAAAA,GAAG,EAAEJ,WAFqB;AAG1BK,EAAAA,SAAS,EAAEN;AAHe,CAA3B;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASO,+BAAT,CAA0CC,QAA1C,EAAoDC,cAApD,EAAqE;AACpE,MAAK,CAAED,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,SAAOA,QAAQ,CAACE,QAAT,GACJP,kBAAkB,CAAEM,cAAF,CAAlB,CAAsCD,QAAQ,CAACE,QAA/C,EACAF,QAAQ,CAACG,SADT,CADI,GAIJH,QAAQ,CAACG,SAJZ;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,yBAAT,CAAoCC,KAApC,EAA2CC,IAA3C,EAAkD;AACxD,SAAOD,KAAK,CAAEC,IAAF,CAAL,GAAgBD,KAAK,CAAEC,IAAF,CAAL,CAAcC,cAA9B,GAA+C,IAAtD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,yBAAT,CACNH,KADM,EAENC,IAFM,EAGNL,cAAc,GAAG,SAHX,EAIL;AACD,QAAMD,QAAQ,GAAGI,yBAAyB,CAAEC,KAAF,EAASC,IAAT,CAA1C;AACA,SAAOP,+BAA+B,CAAEC,QAAF,EAAYC,cAAZ,CAAtC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASQ,sBAAT,CAAiCJ,KAAjC,EAAwCC,IAAxC,EAA+C;AACrD,SAAOD,KAAK,CAAEC,IAAF,CAAL,GAAgBD,KAAK,CAAEC,IAAF,CAAL,CAAcI,WAA9B,GAA4C,IAAnD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BN,KAA7B,EAAoCC,IAApC,EAA2C;AACjD,SAAOD,KAAK,CAAEC,IAAF,CAAL,IAAiBD,KAAK,CAAEC,IAAF,CAAL,CAAcM,OAA/B,GACJP,KAAK,CAAEC,IAAF,CAAL,CAAcM,OADV,GAEJlB,WAFH;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMmB,6BAA6B,GAAGvB,cAAc,CAC1D,CAAEe,KAAF,EAASC,IAAT,KAAmB;AAClB,SAAO,CACNF,yBAAyB,CAAEC,KAAF,EAASC,IAAT,CADnB,EAEN,GAAGK,kBAAkB,CAAEN,KAAF,EAASC,IAAT,CAFf,EAGLQ,MAHK,CAGGC,OAHH,CAAP;AAIA,CANyD,EAO1D,CAAEV,KAAF,EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAPuC,CAApD;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMU,gCAAgC,GAAG1B,cAAc,CAC7D,CAAEe,KAAF,EAASC,IAAT,KAAmB;AAClB,SAAOO,6BAA6B,CAAER,KAAF,EAASC,IAAT,CAA7B,CAA6CW,GAA7C,CACJC,WAAF,IACCnB,+BAA+B,CAAEmB,WAAF,EAAe,KAAf,CAF1B,CAAP;AAIA,CAN4D,EAO7D,CAAEb,KAAF,EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAP0C,CAAvD;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMa,oBAAoB,GAAG7B,cAAc,CACjD,CAAEe,KAAF,EAASe,YAAT,KAA2B;AAC1B,SAAOC,MAAM,CAACC,OAAP,CAAgBjB,KAAhB,EACLS,MADK,CACG,CAAE,GAAId,QAAJ,CAAF,KAAsBA,QAAQ,CAACuB,QAAT,KAAsBH,YAD/C,EAELH,GAFK,CAEA,CAAE,CAAEX,IAAF,CAAF,KAAgBA,IAFhB,CAAP;AAGA,CALgD,EAM/CD,KAAF,IAAa,CAAEA,KAAF,CANoC,CAA3C","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tdisplayShortcut,\n\tshortcutAriaLabel,\n\trawShortcut,\n} from '@wordpress/keycodes';\n\n/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */\n\n/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Shortcut formatting methods.\n *\n * @property {WPKeycodeHandlerByModifier} display Display formatting.\n * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.\n * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.\n */\nconst FORMATTING_METHODS = {\n\tdisplay: displayShortcut,\n\traw: rawShortcut,\n\tariaLabel: shortcutAriaLabel,\n};\n\n/**\n * Returns a string representing the key combination.\n *\n * @param {?WPShortcutKeyCombination} shortcut Key combination.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n *\n * @return {string?} Shortcut representation.\n */\nfunction getKeyCombinationRepresentation( shortcut, representation ) {\n\tif ( ! shortcut ) {\n\t\treturn null;\n\t}\n\n\treturn shortcut.modifier\n\t\t? FORMATTING_METHODS[ representation ][ shortcut.modifier ](\n\t\t\t\tshortcut.character\n\t\t )\n\t\t: shortcut.character;\n}\n\n/**\n * Returns the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const {character, modifier} = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * <div>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </div>\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination?} Key combination.\n */\nexport function getShortcutKeyCombination( state, name ) {\n\treturn state[ name ] ? state[ name ].keyCombination : null;\n}\n\n/**\n * Returns a string representing the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const {display, raw, ariaLabel} = useSelect(\n * ( select ) =>{\n * return {\n * display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region' ),\n * raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region','raw' ),\n * ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region', 'ariaLabel')\n * }\n * },\n * []\n * );\n *\n * return (\n * <ul>\n * <li>{ sprintf( 'display string: %s', display ) }</li>\n * <li>{ sprintf( 'raw string: %s', raw ) }</li>\n * <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>\n * </ul>\n * );\n * };\n *```\n *\n * @return {string?} Shortcut representation.\n */\nexport function getShortcutRepresentation(\n\tstate,\n\tname,\n\trepresentation = 'display'\n) {\n\tconst shortcut = getShortcutKeyCombination( state, name );\n\treturn getKeyCombinationRepresentation( shortcut, representation );\n}\n\n/**\n * Returns the shortcut description given its name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutDescription = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutDescription( 'core/edit-post/next-region' ),\n * []\n * );\n *\n * return shortcutDescription ? (\n * <div>{ shortcutDescription }</div>\n * ) : (\n * <div>{ __( 'No description.' ) }</div>\n * );\n * };\n *```\n * @return {string?} Shortcut description.\n */\nexport function getShortcutDescription( state, name ) {\n\treturn state[ name ] ? state[ name ].description : null;\n}\n\n/**\n * Returns the aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutAliases = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutAliases(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * shortcutAliases.length > 0 && (\n * <ul>\n * { shortcutAliases.map( ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport function getShortcutAliases( state, name ) {\n\treturn state[ name ] && state[ name ].aliases\n\t\t? state[ name ].aliases\n\t\t: EMPTY_ARRAY;\n}\n\n/**\n * Returns the shortcuts that include aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutKeyCombinations.map(\n * ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t].filter( Boolean );\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the raw representation of all the keyboard combinations of a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutRawKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutRawKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutRawKeyCombinations.map(\n * ( shortcutRawKeyCombination, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * ' <code>%s</code>',\n * shortcutRawKeyCombination\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations( state, name ).map(\n\t\t\t( combination ) =>\n\t\t\t\tgetKeyCombinationRepresentation( combination, 'raw' )\n\t\t);\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the shortcut names list for a given category name.\n *\n * @param {Object} state Global state.\n * @param {string} name Category name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const categoryShortcuts = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getCategoryShortcuts(\n * 'block'\n * ),\n * []\n * );\n *\n * return (\n * categoryShortcuts.length > 0 && (\n * <ul>\n * { categoryShortcuts.map( ( categoryShortcut ) => (\n * <li key={ categoryShortcut }>{ categoryShortcut }</li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n * @return {string[]} Shortcut names.\n */\nexport const getCategoryShortcuts = createSelector(\n\t( state, categoryName ) => {\n\t\treturn Object.entries( state )\n\t\t\t.filter( ( [ , shortcut ] ) => shortcut.category === categoryName )\n\t\t\t.map( ( [ name ] ) => name );\n\t},\n\t( state ) => [ state ]\n);\n"]}
1
+ {"version":3,"names":["createSelector","displayShortcut","shortcutAriaLabel","rawShortcut","EMPTY_ARRAY","FORMATTING_METHODS","display","raw","ariaLabel","getKeyCombinationRepresentation","shortcut","representation","modifier","character","getShortcutKeyCombination","state","name","keyCombination","getShortcutRepresentation","getShortcutDescription","description","getShortcutAliases","aliases","getAllShortcutKeyCombinations","filter","Boolean","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","category"],"sources":["@wordpress/keyboard-shortcuts/src/store/selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tdisplayShortcut,\n\tshortcutAriaLabel,\n\trawShortcut,\n} from '@wordpress/keycodes';\n\n/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */\n\n/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Shortcut formatting methods.\n *\n * @property {WPKeycodeHandlerByModifier} display Display formatting.\n * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.\n * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.\n */\nconst FORMATTING_METHODS = {\n\tdisplay: displayShortcut,\n\traw: rawShortcut,\n\tariaLabel: shortcutAriaLabel,\n};\n\n/**\n * Returns a string representing the key combination.\n *\n * @param {?WPShortcutKeyCombination} shortcut Key combination.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n *\n * @return {string?} Shortcut representation.\n */\nfunction getKeyCombinationRepresentation( shortcut, representation ) {\n\tif ( ! shortcut ) {\n\t\treturn null;\n\t}\n\n\treturn shortcut.modifier\n\t\t? FORMATTING_METHODS[ representation ][ shortcut.modifier ](\n\t\t\t\tshortcut.character\n\t\t )\n\t\t: shortcut.character;\n}\n\n/**\n * Returns the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const {character, modifier} = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * <div>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </div>\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination?} Key combination.\n */\nexport function getShortcutKeyCombination( state, name ) {\n\treturn state[ name ] ? state[ name ].keyCombination : null;\n}\n\n/**\n * Returns a string representing the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const {display, raw, ariaLabel} = useSelect(\n * ( select ) =>{\n * return {\n * display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region' ),\n * raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region','raw' ),\n * ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region', 'ariaLabel')\n * }\n * },\n * []\n * );\n *\n * return (\n * <ul>\n * <li>{ sprintf( 'display string: %s', display ) }</li>\n * <li>{ sprintf( 'raw string: %s', raw ) }</li>\n * <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>\n * </ul>\n * );\n * };\n *```\n *\n * @return {string?} Shortcut representation.\n */\nexport function getShortcutRepresentation(\n\tstate,\n\tname,\n\trepresentation = 'display'\n) {\n\tconst shortcut = getShortcutKeyCombination( state, name );\n\treturn getKeyCombinationRepresentation( shortcut, representation );\n}\n\n/**\n * Returns the shortcut description given its name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutDescription = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutDescription( 'core/edit-post/next-region' ),\n * []\n * );\n *\n * return shortcutDescription ? (\n * <div>{ shortcutDescription }</div>\n * ) : (\n * <div>{ __( 'No description.' ) }</div>\n * );\n * };\n *```\n * @return {string?} Shortcut description.\n */\nexport function getShortcutDescription( state, name ) {\n\treturn state[ name ] ? state[ name ].description : null;\n}\n\n/**\n * Returns the aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutAliases = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutAliases(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * shortcutAliases.length > 0 && (\n * <ul>\n * { shortcutAliases.map( ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport function getShortcutAliases( state, name ) {\n\treturn state[ name ] && state[ name ].aliases\n\t\t? state[ name ].aliases\n\t\t: EMPTY_ARRAY;\n}\n\n/**\n * Returns the shortcuts that include aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutKeyCombinations.map(\n * ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t].filter( Boolean );\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the raw representation of all the keyboard combinations of a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutRawKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutRawKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutRawKeyCombinations.map(\n * ( shortcutRawKeyCombination, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * ' <code>%s</code>',\n * shortcutRawKeyCombination\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations( state, name ).map(\n\t\t\t( combination ) =>\n\t\t\t\tgetKeyCombinationRepresentation( combination, 'raw' )\n\t\t);\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the shortcut names list for a given category name.\n *\n * @param {Object} state Global state.\n * @param {string} name Category name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const categoryShortcuts = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getCategoryShortcuts(\n * 'block'\n * ),\n * []\n * );\n *\n * return (\n * categoryShortcuts.length > 0 && (\n * <ul>\n * { categoryShortcuts.map( ( categoryShortcut ) => (\n * <li key={ categoryShortcut }>{ categoryShortcut }</li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n * @return {string[]} Shortcut names.\n */\nexport const getCategoryShortcuts = createSelector(\n\t( state, categoryName ) => {\n\t\treturn Object.entries( state )\n\t\t\t.filter( ( [ , shortcut ] ) => shortcut.category === categoryName )\n\t\t\t.map( ( [ name ] ) => name );\n\t},\n\t( state ) => [ state ]\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAc,MAAM,QAAQ;;AAEnC;AACA;AACA;AACA,SACCC,eAAe,EACfC,iBAAiB,EACjBC,WAAW,QACL,qBAAqB;;AAE5B;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;EAC1BC,OAAO,EAAEL,eAAe;EACxBM,GAAG,EAAEJ,WAAW;EAChBK,SAAS,EAAEN;AACZ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASO,+BAA+BA,CAAEC,QAAQ,EAAEC,cAAc,EAAG;EACpE,IAAK,CAAED,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOA,QAAQ,CAACE,QAAQ,GACrBP,kBAAkB,CAAEM,cAAc,CAAE,CAAED,QAAQ,CAACE,QAAQ,CAAE,CACzDF,QAAQ,CAACG,SACT,CAAC,GACDH,QAAQ,CAACG,SAAS;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAEC,KAAK,EAAEC,IAAI,EAAG;EACxD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACC,cAAc,GAAG,IAAI;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACxCH,KAAK,EACLC,IAAI,EACJL,cAAc,GAAG,SAAS,EACzB;EACD,MAAMD,QAAQ,GAAGI,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC;EACzD,OAAOP,+BAA+B,CAAEC,QAAQ,EAAEC,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,sBAAsBA,CAAEJ,KAAK,EAAEC,IAAI,EAAG;EACrD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACI,WAAW,GAAG,IAAI;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAEN,KAAK,EAAEC,IAAI,EAAG;EACjD,OAAOD,KAAK,CAAEC,IAAI,CAAE,IAAID,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GAC1CP,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GACrBlB,WAAW;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMmB,6BAA6B,GAAGvB,cAAc,CAC1D,CAAEe,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAO,CACNF,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC,EACxC,GAAGK,kBAAkB,CAAEN,KAAK,EAAEC,IAAK,CAAC,CACpC,CAACQ,MAAM,CAAEC,OAAQ,CAAC;AACpB,CAAC,EACD,CAAEV,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMU,gCAAgC,GAAG1B,cAAc,CAC7D,CAAEe,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAOO,6BAA6B,CAAER,KAAK,EAAEC,IAAK,CAAC,CAACW,GAAG,CACpDC,WAAW,IACZnB,+BAA+B,CAAEmB,WAAW,EAAE,KAAM,CACtD,CAAC;AACF,CAAC,EACD,CAAEb,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMa,oBAAoB,GAAG7B,cAAc,CACjD,CAAEe,KAAK,EAAEe,YAAY,KAAM;EAC1B,OAAOC,MAAM,CAACC,OAAO,CAAEjB,KAAM,CAAC,CAC5BS,MAAM,CAAE,CAAE,GAAId,QAAQ,CAAE,KAAMA,QAAQ,CAACuB,QAAQ,KAAKH,YAAa,CAAC,CAClEH,GAAG,CAAE,CAAE,CAAEX,IAAI,CAAE,KAAMA,IAAK,CAAC;AAC9B,CAAC,EACCD,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/keyboard-shortcuts",
3
- "version": "4.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "Handling keyboard shortcuts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,9 +26,9 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/data": "^9.9.0",
30
- "@wordpress/element": "^5.16.0",
31
- "@wordpress/keycodes": "^3.39.0",
29
+ "@wordpress/data": "^9.10.0",
30
+ "@wordpress/element": "^5.17.0",
31
+ "@wordpress/keycodes": "^3.40.0",
32
32
  "rememo": "^4.0.2"
33
33
  },
34
34
  "peerDependencies": {
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
40
+ "gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
41
41
  }