@wordpress/keyboard-shortcuts 3.8.0 → 3.9.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
@@ -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,CA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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,I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C,IAAF,CAAP,CAP4B,CAAzC;AAUP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMW,oBAAoB,GAAG,qBACnC,CAAEZ,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,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( 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 +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;AAC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AAO,MAAMmB,6BAA6B,GAAGxB,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,
|
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;A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AAGxB,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,CAAER,KAAF,EAASC,IAAT,CAA7B,CAA6CS,GAA7C,CACJC,WAAF,IACCjB,+BAA+B,CAAEiB,WAAF,EAAe,KAAf,CAF1B,CAAP;AAIA,CAN4D,EAO7D,CAAEX,KAAF,EAASC,IAAT,KAAmB,CAAED,KAAK,CAAEC,IAAF,CAAP,CAP0C,CAAvD;AAUP;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( 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.
|
3
|
+
"version": "3.9.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": "^6.
|
30
|
-
"@wordpress/element": "^4.
|
31
|
-
"@wordpress/keycodes": "^3.
|
29
|
+
"@wordpress/data": "^6.11.0",
|
30
|
+
"@wordpress/element": "^4.9.0",
|
31
|
+
"@wordpress/keycodes": "^3.11.0",
|
32
32
|
"lodash": "^4.17.21",
|
33
33
|
"rememo": "^4.0.0"
|
34
34
|
},
|
@@ -38,5 +38,5 @@
|
|
38
38
|
"publishConfig": {
|
39
39
|
"access": "public"
|
40
40
|
},
|
41
|
-
"gitHead": "
|
41
|
+
"gitHead": "48d5f37dfb52d2e77c8eeb662f9874cf141b8c6b"
|
42
42
|
}
|
package/src/store/selectors.js
CHANGED
@@ -136,11 +136,9 @@ export const getAllShortcutKeyCombinations = createSelector(
|
|
136
136
|
*/
|
137
137
|
export const getAllShortcutRawKeyCombinations = createSelector(
|
138
138
|
( state, name ) => {
|
139
|
-
return getAllShortcutKeyCombinations(
|
140
|
-
|
141
|
-
|
142
|
-
).map( ( combination ) =>
|
143
|
-
getKeyCombinationRepresentation( combination, 'raw' )
|
139
|
+
return getAllShortcutKeyCombinations( state, name ).map(
|
140
|
+
( combination ) =>
|
141
|
+
getKeyCombinationRepresentation( combination, 'raw' )
|
144
142
|
);
|
145
143
|
},
|
146
144
|
( state, name ) => [ state[ name ] ]
|