@wordpress/keyboard-shortcuts 3.7.0 → 3.10.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,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.10.0 (2022-06-29)
6
+
7
+ ## 3.9.0 (2022-06-15)
8
+
9
+ ## 3.8.0 (2022-06-01)
10
+
5
11
  ## 3.7.0 (2022-05-18)
6
12
 
7
13
  ## 3.6.0 (2022-05-04)
@@ -5,12 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _lodash = require("lodash");
9
-
10
- /**
11
- * External dependencies
12
- */
13
-
14
8
  /**
15
9
  * Reducer returning the registered shortcuts
16
10
  *
@@ -35,7 +29,11 @@ function reducer() {
35
29
  };
36
30
 
37
31
  case 'UNREGISTER_SHORTCUT':
38
- return (0, _lodash.omit)(state, action.name);
32
+ const {
33
+ [action.name]: actionName,
34
+ ...remainingState
35
+ } = state;
36
+ return remainingState;
39
37
  }
40
38
 
41
39
  return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"names":["reducer","state","action","type","name","category","keyCombination","aliases","description"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAT,GAAuC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;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,aAAO,kBAAMP,KAAN,EAAaC,MAAM,CAACE,IAApB,CAAP;AAZF;;AAeA,SAAOH,KAAP;AACA;;eAEcD,O","sourcesContent":["/**\n * External dependencies\n */\nimport { omit } from 'lodash';\n\n/**\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\treturn omit( state, action.name );\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"]}
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,GAAuC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;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"]}
@@ -13,8 +13,6 @@ exports.getShortcutRepresentation = getShortcutRepresentation;
13
13
 
14
14
  var _rememo = _interopRequireDefault(require("rememo"));
15
15
 
16
- var _lodash = require("lodash");
17
-
18
16
  var _keycodes = require("@wordpress/keycodes");
19
17
 
20
18
  /**
@@ -124,7 +122,7 @@ function getShortcutAliases(state, name) {
124
122
  }
125
123
 
126
124
  const getAllShortcutKeyCombinations = (0, _rememo.default)((state, name) => {
127
- return (0, _lodash.compact)([getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)]);
125
+ return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
128
126
  }, (state, name) => [state[name]]);
129
127
  /**
130
128
  * Returns the raw representation of all the keyboard combinations of a given shortcut 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","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","filter","category"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;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;;;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;;;AACO,SAASC,yBAAT,CACNH,KADM,EAENC,IAFM,EAIL;AAAA,MADDL,cACC,uEADgB,SAChB;AACD,QAAMD,QAAQ,GAAGI,yBAAyB,CAAEC,KAAF,EAASC,IAAT,CAA1C;AACA,SAAOP,+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,EAASa,YAAT,KAA2B;AAC1B,SAAOC,MAAM,CAACC,OAAP,CAAgBf,KAAhB,EACLgB,MADK,CACG;AAAA,QAAE,GAAIrB,QAAJ,CAAF;AAAA,WAAsBA,QAAQ,CAACsB,QAAT,KAAsBJ,YAA5C;AAAA,GADH,EAELH,GAFK,CAEA;AAAA,QAAE,CAAET,IAAF,CAAF;AAAA,WAAgBA,IAAhB;AAAA,GAFA,CAAP;AAGA,CALkC,EAMjCD,KAAF,IAAa,CAAEA,KAAF,CANsB,CAA7B","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\nimport { compact } from 'lodash';\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 * @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 *\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 * @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 *\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\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn compact( [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t] );\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 * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations(\n\t\t\tstate,\n\t\t\tname\n\t\t).map( ( combination ) =>\n\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 *\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,"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,C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EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAPyB,CAAtC;AAUP;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;;;AACO,MAAMa,oBAAoB,GAAG,qBACnC,CAAEd,KAAF,EAASe,YAAT,KAA2B;AAC1B,SAAOC,MAAM,CAACC,OAAP,CAAgBjB,KAAhB,EACLS,MADK,CACG;AAAA,QAAE,GAAId,QAAJ,CAAF;AAAA,WAAsBA,QAAQ,CAACuB,QAAT,KAAsBH,YAA5C;AAAA,GADH,EAELH,GAFK,CAEA;AAAA,QAAE,CAAEX,IAAF,CAAF;AAAA,WAAgBA,IAAhB;AAAA,GAFA,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 * @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 *\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 * @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 *\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\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 * @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 *\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,7 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { omit } from 'lodash';
5
1
  /**
6
2
  * Reducer returning the registered shortcuts
7
3
  *
@@ -10,7 +6,6 @@ import { omit } from 'lodash';
10
6
  *
11
7
  * @return {Object} Updated state.
12
8
  */
13
-
14
9
  function reducer() {
15
10
  let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
11
  let action = arguments.length > 1 ? arguments[1] : undefined;
@@ -27,7 +22,11 @@ function reducer() {
27
22
  };
28
23
 
29
24
  case 'UNREGISTER_SHORTCUT':
30
- return omit(state, action.name);
25
+ const {
26
+ [action.name]: actionName,
27
+ ...remainingState
28
+ } = state;
29
+ return remainingState;
31
30
  }
32
31
 
33
32
  return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"names":["omit","reducer","state","action","type","name","category","keyCombination","aliases","description"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,OAAT,GAAuC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;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,aAAOT,IAAI,CAAEE,KAAF,EAASC,MAAM,CAACE,IAAhB,CAAX;AAZF;;AAeA,SAAOH,KAAP;AACA;;AAED,eAAeD,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { omit } from 'lodash';\n\n/**\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\treturn omit( state, action.name );\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"]}
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,GAAuC;AAAA,MAArBC,KAAqB,uEAAb,EAAa;AAAA,MAATC,MAAS;;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"]}
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
- import { compact } from 'lodash';
6
5
  /**
7
6
  * WordPress dependencies
8
7
  */
@@ -104,7 +103,7 @@ export function getShortcutAliases(state, name) {
104
103
  return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
105
104
  }
106
105
  export const getAllShortcutKeyCombinations = createSelector((state, name) => {
107
- return compact([getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)]);
106
+ return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
108
107
  }, (state, name) => [state[name]]);
109
108
  /**
110
109
  * Returns the raw representation of all the keyboard combinations of a given shortcut name.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/keyboard-shortcuts/src/store/selectors.js"],"names":["createSelector","compact","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","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","filter","category"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AACA,SAASC,OAAT,QAAwB,QAAxB;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;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xB,cAAc,CAC1D,CAAEgB,KAAF,EAASC,IAAT,KAAmB;AAClB,SAAOhB,OAAO,CAAE,CACfc,yBAAyB,CAAEC,KAAF,EAASC,IAAT,CADV,EAEf,GAAGK,kBAAkB,CAAEN,KAAF,EAASC,IAAT,CAFN,CAAF,CAAd;AAIA,CANyD,EAO1D,CAAED,KAAF,EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAPuC,CAApD;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMQ,gCAAgC,GAAGzB,cAAc,CAC7D,CAAEgB,KAAF,EAASC,IAAT,KAAmB;AAClB,SAAOO,6BAA6B,CACnCR,KADmC,EAEnCC,IAFmC,CAA7B,CAGLS,GAHK,CAGEC,WAAF,IACNjB,+BAA+B,CAAEiB,WAAF,EAAe,KAAf,CAJzB,CAAP;AAMA,CAR4D,EAS7D,CAAEX,KAAF,EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAT0C,CAAvD;AAYP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMW,oBAAoB,GAAG5B,cAAc,CACjD,CAAEgB,KAAF,EAASa,YAAT,KAA2B;AAC1B,SAAOC,MAAM,CAACC,OAAP,CAAgBf,KAAhB,EACLgB,MADK,CACG;AAAA,QAAE,GAAIrB,QAAJ,CAAF;AAAA,WAAsBA,QAAQ,CAACsB,QAAT,KAAsBJ,YAA5C;AAAA,GADH,EAELH,GAFK,CAEA;AAAA,QAAE,CAAET,IAAF,CAAF;AAAA,WAAgBA,IAAhB;AAAA,GAFA,CAAP;AAGA,CALgD,EAM/CD,KAAF,IAAa,CAAEA,KAAF,CANoC,CAA3C","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\nimport { compact } from 'lodash';\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 * @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 *\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 * @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 *\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\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn compact( [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t] );\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 * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations(\n\t\t\tstate,\n\t\t\tname\n\t\t).map( ( combination ) =>\n\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 *\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,"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,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,OAAO,SAASC,yBAAT,CACNH,KADM,EAENC,IAFM,EAIL;AAAA,MADDL,cACC,uEADgB,SAChB;AACD,Q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EC,IAAF,CAAP,CAP0C,CAAvD;AAUP;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;AAAA,QAAE,GAAId,QAAJ,CAAF;AAAA,WAAsBA,QAAQ,CAACuB,QAAT,KAAsBH,YAA5C;AAAA,GADH,EAELH,GAFK,CAEA;AAAA,QAAE,CAAEX,IAAF,CAAF;AAAA,WAAgBA,IAAhB;AAAA,GAFA,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 * @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 *\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 * @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 *\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\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 * @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 *\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/keyboard-shortcuts",
3
- "version": "3.7.0",
3
+ "version": "3.10.0",
4
4
  "description": "Handling keyboard shortcuts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,11 +26,10 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/data": "^6.9.0",
30
- "@wordpress/element": "^4.7.0",
31
- "@wordpress/keycodes": "^3.9.0",
32
- "lodash": "^4.17.21",
33
- "rememo": "^3.0.0"
29
+ "@wordpress/data": "^6.12.0",
30
+ "@wordpress/element": "^4.10.0",
31
+ "@wordpress/keycodes": "^3.12.0",
32
+ "rememo": "^4.0.0"
34
33
  },
35
34
  "peerDependencies": {
36
35
  "react": "^17.0.0"
@@ -38,5 +37,5 @@
38
37
  "publishConfig": {
39
38
  "access": "public"
40
39
  },
41
- "gitHead": "198fa129cf1af8dc615918987ea6795cd40ab7df"
40
+ "gitHead": "a80eeb62ec7cb1418b9915c277e084a29d6665e3"
42
41
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { omit } from 'lodash';
5
-
6
1
  /**
7
2
  * Reducer returning the registered shortcuts
8
3
  *
@@ -24,7 +19,8 @@ function reducer( state = {}, action ) {
24
19
  },
25
20
  };
26
21
  case 'UNREGISTER_SHORTCUT':
27
- return omit( state, action.name );
22
+ const { [ action.name ]: actionName, ...remainingState } = state;
23
+ return remainingState;
28
24
  }
29
25
 
30
26
  return state;
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
- import { compact } from 'lodash';
6
5
 
7
6
  /**
8
7
  * WordPress dependencies
@@ -118,10 +117,10 @@ export function getShortcutAliases( state, name ) {
118
117
 
119
118
  export const getAllShortcutKeyCombinations = createSelector(
120
119
  ( state, name ) => {
121
- return compact( [
120
+ return [
122
121
  getShortcutKeyCombination( state, name ),
123
122
  ...getShortcutAliases( state, name ),
124
- ] );
123
+ ].filter( Boolean );
125
124
  },
126
125
  ( state, name ) => [ state[ name ] ]
127
126
  );
@@ -136,11 +135,9 @@ export const getAllShortcutKeyCombinations = createSelector(
136
135
  */
137
136
  export const getAllShortcutRawKeyCombinations = createSelector(
138
137
  ( state, name ) => {
139
- return getAllShortcutKeyCombinations(
140
- state,
141
- name
142
- ).map( ( combination ) =>
143
- getKeyCombinationRepresentation( combination, 'raw' )
138
+ return getAllShortcutKeyCombinations( state, name ).map(
139
+ ( combination ) =>
140
+ getKeyCombinationRepresentation( combination, 'raw' )
144
141
  );
145
142
  },
146
143
  ( state, name ) => [ state[ name ] ]