@wordpress/keyboard-shortcuts 4.27.0 → 4.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.28.0 (2024-02-09)
6
+
5
7
  ## 4.27.0 (2024-01-24)
6
8
 
7
9
  ## 4.26.0 (2024-01-10)
package/build/context.js CHANGED
@@ -15,7 +15,7 @@ const globalListener = event => {
15
15
  keyboardShortcut(event);
16
16
  }
17
17
  };
18
- const context = (0, _element.createContext)({
18
+ const context = exports.context = (0, _element.createContext)({
19
19
  add: shortcut => {
20
20
  if (globalShortcuts.size === 0) {
21
21
  document.addEventListener('keydown', globalListener);
@@ -29,5 +29,4 @@ const context = (0, _element.createContext)({
29
29
  }
30
30
  }
31
31
  });
32
- exports.context = context;
33
32
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","globalShortcuts","Set","globalListener","event","keyboardShortcut","context","createContext","add","shortcut","size","document","addEventListener","delete","removeEventListener","exports"],"sources":["@wordpress/keyboard-shortcuts/src/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst globalShortcuts = new Set();\nconst globalListener = ( event ) => {\n\tfor ( const keyboardShortcut of globalShortcuts ) {\n\t\tkeyboardShortcut( event );\n\t}\n};\n\nexport const context = createContext( {\n\tadd: ( shortcut ) => {\n\t\tif ( globalShortcuts.size === 0 ) {\n\t\t\tdocument.addEventListener( 'keydown', globalListener );\n\t\t}\n\t\tglobalShortcuts.add( shortcut );\n\t},\n\tdelete: ( shortcut ) => {\n\t\tglobalShortcuts.delete( shortcut );\n\t\tif ( globalShortcuts.size === 0 ) {\n\t\t\tdocument.removeEventListener( 'keydown', globalListener );\n\t\t}\n\t},\n} );\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC;AACjC,MAAMC,cAAc,GAAKC,KAAK,IAAM;EACnC,KAAM,MAAMC,gBAAgB,IAAIJ,eAAe,EAAG;IACjDI,gBAAgB,CAAED,KAAM,CAAC;EAC1B;AACD,CAAC;AAEM,MAAME,OAAO,GAAG,IAAAC,sBAAa,EAAE;EACrCC,GAAG,EAAIC,QAAQ,IAAM;IACpB,IAAKR,eAAe,CAACS,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACC,gBAAgB,CAAE,SAAS,EAAET,cAAe,CAAC;IACvD;IACAF,eAAe,CAACO,GAAG,CAAEC,QAAS,CAAC;EAChC,CAAC;EACDI,MAAM,EAAIJ,QAAQ,IAAM;IACvBR,eAAe,CAACY,MAAM,CAAEJ,QAAS,CAAC;IAClC,IAAKR,eAAe,CAACS,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACG,mBAAmB,CAAE,SAAS,EAAEX,cAAe,CAAC;IAC1D;EACD;AACD,CAAE,CAAC;AAACY,OAAA,CAAAT,OAAA,GAAAA,OAAA"}
1
+ {"version":3,"names":["_element","require","globalShortcuts","Set","globalListener","event","keyboardShortcut","context","exports","createContext","add","shortcut","size","document","addEventListener","delete","removeEventListener"],"sources":["@wordpress/keyboard-shortcuts/src/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nconst globalShortcuts = new Set();\nconst globalListener = ( event ) => {\n\tfor ( const keyboardShortcut of globalShortcuts ) {\n\t\tkeyboardShortcut( event );\n\t}\n};\n\nexport const context = createContext( {\n\tadd: ( shortcut ) => {\n\t\tif ( globalShortcuts.size === 0 ) {\n\t\t\tdocument.addEventListener( 'keydown', globalListener );\n\t\t}\n\t\tglobalShortcuts.add( shortcut );\n\t},\n\tdelete: ( shortcut ) => {\n\t\tglobalShortcuts.delete( shortcut );\n\t\tif ( globalShortcuts.size === 0 ) {\n\t\t\tdocument.removeEventListener( 'keydown', globalListener );\n\t\t}\n\t},\n} );\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC;AACjC,MAAMC,cAAc,GAAKC,KAAK,IAAM;EACnC,KAAM,MAAMC,gBAAgB,IAAIJ,eAAe,EAAG;IACjDI,gBAAgB,CAAED,KAAM,CAAC;EAC1B;AACD,CAAC;AAEM,MAAME,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,IAAAE,sBAAa,EAAE;EACrCC,GAAG,EAAIC,QAAQ,IAAM;IACpB,IAAKT,eAAe,CAACU,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACC,gBAAgB,CAAE,SAAS,EAAEV,cAAe,CAAC;IACvD;IACAF,eAAe,CAACQ,GAAG,CAAEC,QAAS,CAAC;EAChC,CAAC;EACDI,MAAM,EAAIJ,QAAQ,IAAM;IACvBT,eAAe,CAACa,MAAM,CAAEJ,QAAS,CAAC;IAClC,IAAKT,eAAe,CAACU,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACG,mBAAmB,CAAE,SAAS,EAAEZ,cAAe,CAAC;IAC1D;EACD;AACD,CAAE,CAAC"}
@@ -5,6 +5,5 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  const useShortcut = () => null;
8
- var _default = useShortcut;
9
- exports.default = _default;
8
+ var _default = exports.default = useShortcut;
10
9
  //# sourceMappingURL=use-shortcut.native.js.map
@@ -1 +1 @@
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"}
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,GAAAC,OAAA,CAAAC,OAAA,GAChBH,WAAW"}
@@ -9,8 +9,8 @@ var _data = require("@wordpress/data");
9
9
  var _reducer = _interopRequireDefault(require("./reducer"));
10
10
  var actions = _interopRequireWildcard(require("./actions"));
11
11
  var selectors = _interopRequireWildcard(require("./selectors"));
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); }
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; }
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
14
  /**
15
15
  * WordPress dependencies
16
16
  */
@@ -28,11 +28,10 @@ const STORE_NAME = 'core/keyboard-shortcuts';
28
28
  *
29
29
  * @type {Object}
30
30
  */
31
- const store = (0, _data.createReduxStore)(STORE_NAME, {
31
+ const store = exports.store = (0, _data.createReduxStore)(STORE_NAME, {
32
32
  reducer: _reducer.default,
33
33
  actions,
34
34
  selectors
35
35
  });
36
- exports.store = store;
37
36
  (0, _data.register)(store);
38
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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,IA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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"}
1
+ {"version":3,"names":["_data","require","_reducer","_interopRequireDefault","actions","_interopRequireWildcard","selectors","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","STORE_NAME","store","exports","createReduxStore","reducer","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,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAA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AAEJ,KAAM,CAAC"}
@@ -33,6 +33,5 @@ function reducer(state = {}, action) {
33
33
  }
34
34
  return state;
35
35
  }
36
- var _default = reducer;
37
- exports.default = _default;
36
+ var _default = exports.default = reducer;
38
37
  //# sourceMappingURL=reducer.js.map
@@ -1 +1 @@
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
+ {"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,GAAAC,OAAA,CAAAC,OAAA,GAEcb,OAAO"}
@@ -279,7 +279,7 @@ function getShortcutAliases(state, name) {
279
279
  *
280
280
  * @return {WPShortcutKeyCombination[]} Key combinations.
281
281
  */
282
- const getAllShortcutKeyCombinations = (0, _rememo.default)((state, name) => {
282
+ const getAllShortcutKeyCombinations = exports.getAllShortcutKeyCombinations = (0, _rememo.default)((state, name) => {
283
283
  return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
284
284
  }, (state, name) => [state[name]]);
285
285
 
@@ -332,8 +332,7 @@ const getAllShortcutKeyCombinations = (0, _rememo.default)((state, name) => {
332
332
  *
333
333
  * @return {string[]} Shortcuts.
334
334
  */
335
- exports.getAllShortcutKeyCombinations = getAllShortcutKeyCombinations;
336
- const getAllShortcutRawKeyCombinations = (0, _rememo.default)((state, name) => {
335
+ const getAllShortcutRawKeyCombinations = exports.getAllShortcutRawKeyCombinations = (0, _rememo.default)((state, name) => {
337
336
  return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
338
337
  }, (state, name) => [state[name]]);
339
338
 
@@ -370,9 +369,7 @@ const getAllShortcutRawKeyCombinations = (0, _rememo.default)((state, name) => {
370
369
  *```
371
370
  * @return {string[]} Shortcut names.
372
371
  */
373
- exports.getAllShortcutRawKeyCombinations = getAllShortcutRawKeyCombinations;
374
- const getCategoryShortcuts = (0, _rememo.default)((state, categoryName) => {
372
+ const getCategoryShortcuts = exports.getCategoryShortcuts = (0, _rememo.default)((state, categoryName) => {
375
373
  return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
376
374
  }, state => [state]);
377
- exports.getCategoryShortcuts = getCategoryShortcuts;
378
375
  //# sourceMappingURL=selectors.js.map
@@ -1 +1 @@
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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AAEb,IAAI,CAAE,KAAMA,IAAK,CAAC;AAC9B,CAAC,EACCD,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC;AAACY,OAAA,CAAAI,oBAAA,GAAAA,oBAAA"}
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","exports","createSelector","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":";;;;;;;;;;;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;AAC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M,CAAC,CAC5BW,MAAM,CAAE,CAAE,GAAIhB,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/keyboard-shortcuts",
3
- "version": "4.27.0",
3
+ "version": "4.28.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.20.0",
30
- "@wordpress/element": "^5.27.0",
31
- "@wordpress/keycodes": "^3.50.0",
29
+ "@wordpress/data": "^9.21.0",
30
+ "@wordpress/element": "^5.28.0",
31
+ "@wordpress/keycodes": "^3.51.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": "45de2cb4212fed7f2763e95f10300d1ff9d0ec08"
40
+ "gitHead": "eb796371e9630636a4a8837033807b0c4a06ed67"
41
41
  }