@wordpress/keyboard-shortcuts 4.31.0 → 4.33.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 +4 -0
- package/build/components/shortcut-provider.js.map +1 -1
- package/build/context.js.map +1 -1
- package/build/hooks/use-shortcut-event-match.js.map +1 -1
- package/build/hooks/use-shortcut.js.map +1 -1
- package/build/hooks/use-shortcut.native.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +4 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/shortcut-provider.js.map +1 -1
- package/build-module/context.js.map +1 -1
- package/build-module/hooks/use-shortcut-event-match.js.map +1 -1
- package/build-module/hooks/use-shortcut.js.map +1 -1
- package/build-module/hooks/use-shortcut.native.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -5
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +5 -6
- package/src/store/selectors.js +1 -5
package/CHANGELOG.md
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_element","require","_context","Provider","context","ShortcutProvider","props","keyboardShortcuts","useState","Set","onKeyDown","event","keyboardShortcut","_react","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n * Adding a provider allows to register contextual shortcuts\n * that are only active when a certain part of the UI is focused.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {Element} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst [ keyboardShortcuts ] = useState( () => new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAM;EAAEE;AAAS,CAAC,GAAGC,gBAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAM,CAAEC,iBAAiB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,MAAM,IAAIC,GAAG,CAAC,CAAE,CAAC;EAEzD,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKL,KAAK,CAACI,SAAS,EAAGJ,KAAK,CAACI,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIL,iBAAiB,EAAG;MACnDK,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACC,IAAAE,MAAA,CAAAC,aAAA,EAACX,QAAQ;IAACY,KAAK,EAAGR;EAAmB,GACpC,IAAAM,MAAA,CAAAC,aAAA;IAAA,GAAUR,KAAK;IAAGI,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD"}
|
1
|
+
{"version":3,"names":["_element","require","_context","Provider","context","ShortcutProvider","props","keyboardShortcuts","useState","Set","onKeyDown","event","keyboardShortcut","_react","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n * Adding a provider allows to register contextual shortcuts\n * that are only active when a certain part of the UI is focused.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {Element} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst [ keyboardShortcuts ] = useState( () => new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAM;EAAEE;AAAS,CAAC,GAAGC,gBAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAM,CAAEC,iBAAiB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,MAAM,IAAIC,GAAG,CAAC,CAAE,CAAC;EAEzD,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKL,KAAK,CAACI,SAAS,EAAGJ,KAAK,CAACI,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIL,iBAAiB,EAAG;MACnDK,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACC,IAAAE,MAAA,CAAAC,aAAA,EAACX,QAAQ;IAACY,KAAK,EAAGR;EAAmB,GACpC,IAAAM,MAAA,CAAAC,aAAA;IAAA,GAAUR,KAAK;IAAGI,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD","ignoreList":[]}
|
package/build/context.js.map
CHANGED
@@ -1 +1 @@
|
|
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"}
|
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","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_data","require","_keycodes","_store","useShortcutEventMatch","getAllShortcutKeyCombinations","useSelect","keyboardShortcutsStore","isMatch","name","event","some","modifier","character","isKeyboardEvent"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAA8B,CAAC,GAAG,IAAAC,eAAS,EAClDC,YACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,SAASC,OAAOA,CAAEC,IAAI,EAAEC,KAAK,EAAG;IAC/B,OAAOL,6BAA6B,CAAEI,IAAK,CAAC,CAACE,IAAI,CAChD,CAAE;MAAEC,QAAQ;MAAEC;IAAU,CAAC,KAAM;MAC9B,OAAOC,yBAAe,CAAEF,QAAQ,CAAE,CAAEF,KAAK,EAAEG,SAAU,CAAC;IACvD,CACD,CAAC;EACF;EAEA,OAAOL,OAAO;AACf"}
|
1
|
+
{"version":3,"names":["_data","require","_keycodes","_store","useShortcutEventMatch","getAllShortcutKeyCombinations","useSelect","keyboardShortcutsStore","isMatch","name","event","some","modifier","character","isKeyboardEvent"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAA8B,CAAC,GAAG,IAAAC,eAAS,EAClDC,YACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,SAASC,OAAOA,CAAEC,IAAI,EAAEC,KAAK,EAAG;IAC/B,OAAOL,6BAA6B,CAAEI,IAAK,CAAC,CAACE,IAAI,CAChD,CAAE;MAAEC,QAAQ;MAAEC;IAAU,CAAC,KAAM;MAC9B,OAAOC,yBAAe,CAAEF,QAAQ,CAAE,CAAEF,KAAK,EAAEG,SAAU,CAAC;IACvD,CACD,CAAC;EACF;EAEA,OAAOL,OAAO;AACf","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_element","require","_useShortcutEventMatch","_interopRequireDefault","_context","useShortcut","name","callback","isDisabled","shortcuts","useContext","context","isMatch","useShortcutEventMatch","callbackRef","useRef","useEffect","current","_callback","event","add","delete"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut(\n\tname,\n\tcallback,\n\t{ isDisabled = false } = {}\n) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\n\tuseEffect( () => {\n\t\tcallbackRef.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled, shortcuts ] );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASI,WAAWA,CAClCC,IAAI,EACJC,QAAQ,EACR;EAAEC,UAAU,GAAG;AAAM,CAAC,GAAG,CAAC,CAAC,EAC1B;EACD,MAAMC,SAAS,GAAG,IAAAC,mBAAU,EAAEC,gBAAQ,CAAC;EACvC,MAAMC,OAAO,GAAG,IAAAC,8BAAqB,EAAC,CAAC;EACvC,MAAMC,WAAW,GAAG,IAAAC,eAAM,EAAC,CAAC;EAE5B,IAAAC,kBAAS,EAAE,MAAM;IAChBF,WAAW,CAACG,OAAO,GAAGV,QAAQ;EAC/B,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjB,IAAAS,kBAAS,EAAE,MAAM;IAChB,IAAKR,UAAU,EAAG;MACjB;IACD;IAEA,SAASU,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKP,OAAO,CAAEN,IAAI,EAAEa,KAAM,CAAC,EAAG;QAC7BL,WAAW,CAACG,OAAO,CAAEE,KAAM,CAAC;MAC7B;IACD;IAEAV,SAAS,CAACW,GAAG,CAAEF,SAAU,CAAC;IAC1B,OAAO,MAAM;MACZT,SAAS,CAACY,MAAM,CAAEH,SAAU,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,CAAEZ,IAAI,EAAEE,UAAU,EAAEC,SAAS,CAAG,CAAC;AACrC"}
|
1
|
+
{"version":3,"names":["_element","require","_useShortcutEventMatch","_interopRequireDefault","_context","useShortcut","name","callback","isDisabled","shortcuts","useContext","context","isMatch","useShortcutEventMatch","callbackRef","useRef","useEffect","current","_callback","event","add","delete"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut(\n\tname,\n\tcallback,\n\t{ isDisabled = false } = {}\n) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\n\tuseEffect( () => {\n\t\tcallbackRef.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled, shortcuts ] );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASI,WAAWA,CAClCC,IAAI,EACJC,QAAQ,EACR;EAAEC,UAAU,GAAG;AAAM,CAAC,GAAG,CAAC,CAAC,EAC1B;EACD,MAAMC,SAAS,GAAG,IAAAC,mBAAU,EAAEC,gBAAQ,CAAC;EACvC,MAAMC,OAAO,GAAG,IAAAC,8BAAqB,EAAC,CAAC;EACvC,MAAMC,WAAW,GAAG,IAAAC,eAAM,EAAC,CAAC;EAE5B,IAAAC,kBAAS,EAAE,MAAM;IAChBF,WAAW,CAACG,OAAO,GAAGV,QAAQ;EAC/B,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjB,IAAAS,kBAAS,EAAE,MAAM;IAChB,IAAKR,UAAU,EAAG;MACjB;IACD;IAEA,SAASU,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKP,OAAO,CAAEN,IAAI,EAAEa,KAAM,CAAC,EAAG;QAC7BL,WAAW,CAACG,OAAO,CAAEE,KAAM,CAAC;MAC7B;IACD;IAEAV,SAAS,CAACW,GAAG,CAAEF,SAAU,CAAC;IAC1B,OAAO,MAAM;MACZT,SAAS,CAACY,MAAM,CAAEH,SAAU,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,CAAEZ,IAAI,EAAEE,UAAU,EAAEC,SAAS,CAAG,CAAC;AACrC","ignoreList":[]}
|
@@ -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,GAAAC,OAAA,CAAAC,OAAA,GAChBH,WAAW"}
|
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","ignoreList":[]}
|
package/build/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_store","require","_useShortcut","_interopRequireDefault","_shortcutProvider","_useShortcutEventMatch"],"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA"}
|
1
|
+
{"version":3,"names":["_store","require","_useShortcut","_interopRequireDefault","_shortcutProvider","_useShortcutEventMatch"],"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAAE;EACjCC,IAAI;EACJC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,OAAO;IACNC,IAAI,EAAE,mBAAmB;IACzBL,IAAI;IACJC,QAAQ;IACRE,cAAc;IACdC,OAAO;IACPF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,kBAAkBA,CAAEN,IAAI,EAAG;EAC1C,OAAO;IACNK,IAAI,EAAE,qBAAqB;IAC3BL;EACD,CAAC;AACF"}
|
1
|
+
{"version":3,"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"],"mappings":";;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAAE;EACjCC,IAAI;EACJC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,OAAO;IACNC,IAAI,EAAE,mBAAmB;IACzBL,IAAI;IACJC,QAAQ;IACRE,cAAc;IACdC,OAAO;IACPF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,kBAAkBA,CAAEN,IAAI,EAAG;EAC1C,OAAO;IACNK,IAAI,EAAE,qBAAqB;IAC3BL;EACD,CAAC;AACF","ignoreList":[]}
|
package/build/store/index.js
CHANGED
@@ -10,7 +10,7 @@ var _reducer = _interopRequireDefault(require("./reducer"));
|
|
10
10
|
var actions = _interopRequireWildcard(require("./actions"));
|
11
11
|
var selectors = _interopRequireWildcard(require("./selectors"));
|
12
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 &&
|
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 && {}.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
|
*/
|
package/build/store/index.js.map
CHANGED
@@ -1 +1 @@
|
|
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","
|
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","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,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAVzC;AACA;AACA;;AAGA;AACA;AACA;;AAKA,MAAMW,UAAU,GAAG,yBAAyB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG,IAAAE,sBAAgB,EAAEH,UAAU,EAAE;EAClDI,OAAO,EAAPA,gBAAO;EACP3B,OAAO;EACPE;AACD,CAAE,CAAC;AAEH,IAAA0B,cAAQ,EAAEJ,KAAM,CAAC","ignoreList":[]}
|
@@ -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,GAAAC,OAAA,CAAAC,OAAA,GAEcb,OAAO"}
|
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","ignoreList":[]}
|
package/build/store/selectors.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
5
4
|
value: true
|
6
5
|
});
|
@@ -9,12 +8,8 @@ exports.getShortcutAliases = getShortcutAliases;
|
|
9
8
|
exports.getShortcutDescription = getShortcutDescription;
|
10
9
|
exports.getShortcutKeyCombination = getShortcutKeyCombination;
|
11
10
|
exports.getShortcutRepresentation = getShortcutRepresentation;
|
12
|
-
var
|
11
|
+
var _data = require("@wordpress/data");
|
13
12
|
var _keycodes = require("@wordpress/keycodes");
|
14
|
-
/**
|
15
|
-
* External dependencies
|
16
|
-
*/
|
17
|
-
|
18
13
|
/**
|
19
14
|
* WordPress dependencies
|
20
15
|
*/
|
@@ -279,7 +274,7 @@ function getShortcutAliases(state, name) {
|
|
279
274
|
*
|
280
275
|
* @return {WPShortcutKeyCombination[]} Key combinations.
|
281
276
|
*/
|
282
|
-
const getAllShortcutKeyCombinations = exports.getAllShortcutKeyCombinations = (0,
|
277
|
+
const getAllShortcutKeyCombinations = exports.getAllShortcutKeyCombinations = (0, _data.createSelector)((state, name) => {
|
283
278
|
return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
|
284
279
|
}, (state, name) => [state[name]]);
|
285
280
|
|
@@ -332,7 +327,7 @@ const getAllShortcutKeyCombinations = exports.getAllShortcutKeyCombinations = (0
|
|
332
327
|
*
|
333
328
|
* @return {string[]} Shortcuts.
|
334
329
|
*/
|
335
|
-
const getAllShortcutRawKeyCombinations = exports.getAllShortcutRawKeyCombinations = (0,
|
330
|
+
const getAllShortcutRawKeyCombinations = exports.getAllShortcutRawKeyCombinations = (0, _data.createSelector)((state, name) => {
|
336
331
|
return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
|
337
332
|
}, (state, name) => [state[name]]);
|
338
333
|
|
@@ -369,7 +364,7 @@ const getAllShortcutRawKeyCombinations = exports.getAllShortcutRawKeyCombination
|
|
369
364
|
*```
|
370
365
|
* @return {string[]} Shortcut names.
|
371
366
|
*/
|
372
|
-
const getCategoryShortcuts = exports.getCategoryShortcuts = (0,
|
367
|
+
const getCategoryShortcuts = exports.getCategoryShortcuts = (0, _data.createSelector)((state, categoryName) => {
|
373
368
|
return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
|
374
369
|
}, state => [state]);
|
375
370
|
//# 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","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;AACO,MAAMsB,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAG,IAAAE,eAAc,EAC1D,CAAEV,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAO,CACNF,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC,EACxC,GAAGK,kBAAkB,CAAEN,KAAK,EAAEC,IAAK,CAAC,CACpC,CAACU,MAAM,CAAEC,OAAQ,CAAC;AACpB,CAAC,EACD,CAAEZ,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMY,gCAAgC,GAAAJ,OAAA,CAAAI,gCAAA,GAAG,IAAAH,eAAc,EAC7D,CAAEV,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAOO,6BAA6B,CAAER,KAAK,EAAEC,IAAK,CAAC,CAACa,GAAG,CACpDC,WAAW,IACZrB,+BAA+B,CAAEqB,WAAW,EAAE,KAAM,CACtD,CAAC;AACF,CAAC,EACD,CAAEf,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMe,oBAAoB,GAAAP,OAAA,CAAAO,oBAAA,GAAG,IAAAN,eAAc,EACjD,CAAEV,KAAK,EAAEiB,YAAY,KAAM;EAC1B,OAAOC,MAAM,CAACC,OAAO,CAAEnB,KAAM,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"}
|
1
|
+
{"version":3,"names":["_data","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 * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\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,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAQA;;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,GAAAC,OAAA,CAAAD,6BAAA,GAAG,IAAAE,oBAAc,EAC1D,CAAEV,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAO,CACNF,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC,EACxC,GAAGK,kBAAkB,CAAEN,KAAK,EAAEC,IAAK,CAAC,CACpC,CAACU,MAAM,CAAEC,OAAQ,CAAC;AACpB,CAAC,EACD,CAAEZ,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMY,gCAAgC,GAAAJ,OAAA,CAAAI,gCAAA,GAAG,IAAAH,oBAAc,EAC7D,CAAEV,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAOO,6BAA6B,CAAER,KAAK,EAAEC,IAAK,CAAC,CAACa,GAAG,CACpDC,WAAW,IACZrB,+BAA+B,CAAEqB,WAAW,EAAE,KAAM,CACtD,CAAC;AACF,CAAC,EACD,CAAEf,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMe,oBAAoB,GAAAP,OAAA,CAAAO,oBAAA,GAAG,IAAAN,oBAAc,EACjD,CAAEV,KAAK,EAAEiB,YAAY,KAAM;EAC1B,OAAOC,MAAM,CAACC,OAAO,CAAEnB,KAAM,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","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useState","context","Provider","ShortcutProvider","props","keyboardShortcuts","Set","onKeyDown","event","keyboardShortcut","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n * Adding a provider allows to register contextual shortcuts\n * that are only active when a certain part of the UI is focused.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {Element} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst [ keyboardShortcuts ] = useState( () => new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,YAAY;AAEpC,MAAM;EAAEC;AAAS,CAAC,GAAGD,OAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAM,CAAEC,iBAAiB,CAAE,GAAGL,QAAQ,CAAE,MAAM,IAAIM,GAAG,CAAC,CAAE,CAAC;EAEzD,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKJ,KAAK,CAACG,SAAS,EAAGH,KAAK,CAACG,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIJ,iBAAiB,EAAG;MACnDI,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACCE,aAAA,CAACR,QAAQ;IAACS,KAAK,EAAGN;EAAmB,GACpCK,aAAA;IAAA,GAAUN,KAAK;IAAGG,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD"}
|
1
|
+
{"version":3,"names":["useState","context","Provider","ShortcutProvider","props","keyboardShortcuts","Set","onKeyDown","event","keyboardShortcut","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n * Adding a provider allows to register contextual shortcuts\n * that are only active when a certain part of the UI is focused.\n *\n * @param {Object} props Props to pass to `div`.\n *\n * @return {Element} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst [ keyboardShortcuts ] = useState( () => new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,YAAY;AAEpC,MAAM;EAAEC;AAAS,CAAC,GAAGD,OAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAM,CAAEC,iBAAiB,CAAE,GAAGL,QAAQ,CAAE,MAAM,IAAIM,GAAG,CAAC,CAAE,CAAC;EAEzD,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKJ,KAAK,CAACG,SAAS,EAAGH,KAAK,CAACG,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIJ,iBAAiB,EAAG;MACnDI,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACCE,aAAA,CAACR,QAAQ;IAACS,KAAK,EAAGN;EAAmB,GACpCK,aAAA;IAAA,GAAUN,KAAK;IAAGG,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createContext","globalShortcuts","Set","globalListener","event","keyboardShortcut","context","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":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;AAElD,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;AAED,OAAO,MAAME,OAAO,GAAGN,aAAa,CAAE;EACrCO,GAAG,EAAIC,QAAQ,IAAM;IACpB,IAAKP,eAAe,CAACQ,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACC,gBAAgB,CAAE,SAAS,EAAER,cAAe,CAAC;IACvD;IACAF,eAAe,CAACM,GAAG,CAAEC,QAAS,CAAC;EAChC,CAAC;EACDI,MAAM,EAAIJ,QAAQ,IAAM;IACvBP,eAAe,CAACW,MAAM,CAAEJ,QAAS,CAAC;IAClC,IAAKP,eAAe,CAACQ,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACG,mBAAmB,CAAE,SAAS,EAAEV,cAAe,CAAC;IAC1D;EACD;AACD,CAAE,CAAC"}
|
1
|
+
{"version":3,"names":["createContext","globalShortcuts","Set","globalListener","event","keyboardShortcut","context","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":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,oBAAoB;AAElD,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;AAED,OAAO,MAAME,OAAO,GAAGN,aAAa,CAAE;EACrCO,GAAG,EAAIC,QAAQ,IAAM;IACpB,IAAKP,eAAe,CAACQ,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACC,gBAAgB,CAAE,SAAS,EAAER,cAAe,CAAC;IACvD;IACAF,eAAe,CAACM,GAAG,CAAEC,QAAS,CAAC;EAChC,CAAC;EACDI,MAAM,EAAIJ,QAAQ,IAAM;IACvBP,eAAe,CAACW,MAAM,CAAEJ,QAAS,CAAC;IAClC,IAAKP,eAAe,CAACQ,IAAI,KAAK,CAAC,EAAG;MACjCC,QAAQ,CAACG,mBAAmB,CAAE,SAAS,EAAEV,cAAe,CAAC;IAC1D;EACD;AACD,CAAE,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useSelect","isKeyboardEvent","store","keyboardShortcutsStore","useShortcutEventMatch","getAllShortcutKeyCombinations","isMatch","name","event","some","modifier","character"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,qBAAqB;;AAErD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,sBAAsB,QAAQ,UAAU;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAA8B,CAAC,GAAGL,SAAS,CAClDG,sBACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,SAASG,OAAOA,CAAEC,IAAI,EAAEC,KAAK,EAAG;IAC/B,OAAOH,6BAA6B,CAAEE,IAAK,CAAC,CAACE,IAAI,CAChD,CAAE;MAAEC,QAAQ;MAAEC;IAAU,CAAC,KAAM;MAC9B,OAAOV,eAAe,CAAES,QAAQ,CAAE,CAAEF,KAAK,EAAEG,SAAU,CAAC;IACvD,CACD,CAAC;EACF;EAEA,OAAOL,OAAO;AACf"}
|
1
|
+
{"version":3,"names":["useSelect","isKeyboardEvent","store","keyboardShortcutsStore","useShortcutEventMatch","getAllShortcutKeyCombinations","isMatch","name","event","some","modifier","character"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut-event-match.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as keyboardShortcutsStore } from '../store';\n\n/**\n * Returns a function to check if a keyboard event matches a shortcut name.\n *\n * @return {Function} A function to check if a keyboard event matches a\n * predefined shortcut combination.\n */\nexport default function useShortcutEventMatch() {\n\tconst { getAllShortcutKeyCombinations } = useSelect(\n\t\tkeyboardShortcutsStore\n\t);\n\n\t/**\n\t * A function to check if a keyboard event matches a predefined shortcut\n\t * combination.\n\t *\n\t * @param {string} name Shortcut name.\n\t * @param {KeyboardEvent} event Event to check.\n\t *\n\t * @return {boolean} True if the event matches any shortcuts, false if not.\n\t */\n\tfunction isMatch( name, event ) {\n\t\treturn getAllShortcutKeyCombinations( name ).some(\n\t\t\t( { modifier, character } ) => {\n\t\t\t\treturn isKeyboardEvent[ modifier ]( event, character );\n\t\t\t}\n\t\t);\n\t}\n\n\treturn isMatch;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,qBAAqB;;AAErD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,sBAAsB,QAAQ,UAAU;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAA8B,CAAC,GAAGL,SAAS,CAClDG,sBACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,SAASG,OAAOA,CAAEC,IAAI,EAAEC,KAAK,EAAG;IAC/B,OAAOH,6BAA6B,CAAEE,IAAK,CAAC,CAACE,IAAI,CAChD,CAAE;MAAEC,QAAQ;MAAEC;IAAU,CAAC,KAAM;MAC9B,OAAOV,eAAe,CAAES,QAAQ,CAAE,CAAEF,KAAK,EAAEG,SAAU,CAAC;IACvD,CACD,CAAC;EACF;EAEA,OAAOL,OAAO;AACf","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useContext","useEffect","useRef","useShortcutEventMatch","context","useShortcut","name","callback","isDisabled","shortcuts","isMatch","callbackRef","current","_callback","event","add","delete"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut(\n\tname,\n\tcallback,\n\t{ isDisabled = false } = {}\n) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\n\tuseEffect( () => {\n\t\tcallbackRef.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled, shortcuts ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,SAASC,OAAO,QAAQ,YAAY;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAClCC,IAAI,EACJC,QAAQ,EACR;EAAEC,UAAU,GAAG;AAAM,CAAC,GAAG,CAAC,CAAC,EAC1B;EACD,MAAMC,SAAS,GAAGT,UAAU,CAAEI,OAAQ,CAAC;EACvC,MAAMM,OAAO,GAAGP,qBAAqB,CAAC,CAAC;EACvC,MAAMQ,WAAW,GAAGT,MAAM,CAAC,CAAC;EAE5BD,SAAS,CAAE,MAAM;IAChBU,WAAW,CAACC,OAAO,GAAGL,QAAQ;EAC/B,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjBN,SAAS,CAAE,MAAM;IAChB,IAAKO,UAAU,EAAG;MACjB;IACD;IAEA,SAASK,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKJ,OAAO,CAAEJ,IAAI,EAAEQ,KAAM,CAAC,EAAG;QAC7BH,WAAW,CAACC,OAAO,CAAEE,KAAM,CAAC;MAC7B;IACD;IAEAL,SAAS,CAACM,GAAG,CAAEF,SAAU,CAAC;IAC1B,OAAO,MAAM;MACZJ,SAAS,CAACO,MAAM,CAAEH,SAAU,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,CAAEP,IAAI,EAAEE,UAAU,EAAEC,SAAS,CAAG,CAAC;AACrC"}
|
1
|
+
{"version":3,"names":["useContext","useEffect","useRef","useShortcutEventMatch","context","useShortcut","name","callback","isDisabled","shortcuts","isMatch","callbackRef","current","_callback","event","add","delete"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useShortcutEventMatch from './use-shortcut-event-match';\nimport { context } from '../context';\n\n/**\n * Attach a keyboard shortcut handler.\n *\n * @param {string} name Shortcut name.\n * @param {Function} callback Shortcut callback.\n * @param {Object} options Shortcut options.\n * @param {boolean} options.isDisabled Whether to disable to shortut.\n */\nexport default function useShortcut(\n\tname,\n\tcallback,\n\t{ isDisabled = false } = {}\n) {\n\tconst shortcuts = useContext( context );\n\tconst isMatch = useShortcutEventMatch();\n\tconst callbackRef = useRef();\n\n\tuseEffect( () => {\n\t\tcallbackRef.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction _callback( event ) {\n\t\t\tif ( isMatch( name, event ) ) {\n\t\t\t\tcallbackRef.current( event );\n\t\t\t}\n\t\t}\n\n\t\tshortcuts.add( _callback );\n\t\treturn () => {\n\t\t\tshortcuts.delete( _callback );\n\t\t};\n\t}, [ name, isDisabled, shortcuts ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,SAASC,OAAO,QAAQ,YAAY;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAClCC,IAAI,EACJC,QAAQ,EACR;EAAEC,UAAU,GAAG;AAAM,CAAC,GAAG,CAAC,CAAC,EAC1B;EACD,MAAMC,SAAS,GAAGT,UAAU,CAAEI,OAAQ,CAAC;EACvC,MAAMM,OAAO,GAAGP,qBAAqB,CAAC,CAAC;EACvC,MAAMQ,WAAW,GAAGT,MAAM,CAAC,CAAC;EAE5BD,SAAS,CAAE,MAAM;IAChBU,WAAW,CAACC,OAAO,GAAGL,QAAQ;EAC/B,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjBN,SAAS,CAAE,MAAM;IAChB,IAAKO,UAAU,EAAG;MACjB;IACD;IAEA,SAASK,SAASA,CAAEC,KAAK,EAAG;MAC3B,IAAKJ,OAAO,CAAEJ,IAAI,EAAEQ,KAAM,CAAC,EAAG;QAC7BH,WAAW,CAACC,OAAO,CAAEE,KAAM,CAAC;MAC7B;IACD;IAEAL,SAAS,CAACM,GAAG,CAAEF,SAAU,CAAC;IAC1B,OAAO,MAAM;MACZJ,SAAS,CAACO,MAAM,CAAEH,SAAU,CAAC;IAC9B,CAAC;EACF,CAAC,EAAE,CAAEP,IAAI,EAAEE,UAAU,EAAEC,SAAS,CAAG,CAAC;AACrC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["useShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.native.js"],"sourcesContent":["const useShortcut = () => null;\nexport default useShortcut;\n"],"mappings":"AAAA,MAAMA,WAAW,GAAGA,CAAA,KAAM,IAAI;AAC9B,eAAeA,WAAW"}
|
1
|
+
{"version":3,"names":["useShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/hooks/use-shortcut.native.js"],"sourcesContent":["const useShortcut = () => null;\nexport default useShortcut;\n"],"mappings":"AAAA,MAAMA,WAAW,GAAGA,CAAA,KAAM,IAAI;AAC9B,eAAeA,WAAW","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["store","default","useShortcut","ShortcutProvider","__unstableUseShortcutEventMatch"],"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,SAAS;AAC/B,SAASC,OAAO,IAAIC,WAAW,QAAQ,sBAAsB;AAC7D,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,SAASF,OAAO,IAAIG,+BAA+B,QAAQ,kCAAkC"}
|
1
|
+
{"version":3,"names":["store","default","useShortcut","ShortcutProvider","__unstableUseShortcutEventMatch"],"sources":["@wordpress/keyboard-shortcuts/src/index.js"],"sourcesContent":["export { store } from './store';\nexport { default as useShortcut } from './hooks/use-shortcut';\nexport { ShortcutProvider } from './components/shortcut-provider';\nexport { default as __unstableUseShortcutEventMatch } from './hooks/use-shortcut-event-match';\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,SAAS;AAC/B,SAASC,OAAO,IAAIC,WAAW,QAAQ,sBAAsB;AAC7D,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,SAASF,OAAO,IAAIG,+BAA+B,QAAQ,kCAAkC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAAE;EACjCC,IAAI;EACJC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,OAAO;IACNC,IAAI,EAAE,mBAAmB;IACzBL,IAAI;IACJC,QAAQ;IACRE,cAAc;IACdC,OAAO;IACPF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,kBAAkBA,CAAEN,IAAI,EAAG;EAC1C,OAAO;IACNK,IAAI,EAAE,qBAAqB;IAC3BL;EACD,CAAC;AACF"}
|
1
|
+
{"version":3,"names":["registerShortcut","name","category","description","keyCombination","aliases","type","unregisterShortcut"],"sources":["@wordpress/keyboard-shortcuts/src/store/actions.js"],"sourcesContent":["/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */\n\n/**\n * Keyboard key combination.\n *\n * @typedef {Object} WPShortcutKeyCombination\n *\n * @property {string} character Character.\n * @property {WPKeycodeModifier|undefined} modifier Modifier.\n */\n\n/**\n * Configuration of a registered keyboard shortcut.\n *\n * @typedef {Object} WPShortcutConfig\n *\n * @property {string} name Shortcut name.\n * @property {string} category Shortcut category.\n * @property {string} description Shortcut description.\n * @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.\n * @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.\n */\n\n/**\n * Returns an action object used to register a new keyboard shortcut.\n *\n * @param {WPShortcutConfig} config Shortcut config.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { registerShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * registerShortcut( {\n * name: 'custom/my-custom-shortcut',\n * category: 'my-category',\n * description: __( 'My custom shortcut' ),\n * keyCombination: {\n * modifier: 'primary',\n * character: 'j',\n * },\n * } );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'custom/my-custom-shortcut'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is registered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is not registered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function registerShortcut( {\n\tname,\n\tcategory,\n\tdescription,\n\tkeyCombination,\n\taliases,\n} ) {\n\treturn {\n\t\ttype: 'REGISTER_SHORTCUT',\n\t\tname,\n\t\tcategory,\n\t\tkeyCombination,\n\t\taliases,\n\t\tdescription,\n\t};\n}\n\n/**\n * Returns an action object used to unregister a keyboard shortcut.\n *\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { useEffect } from 'react';\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect, useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );\n *\n * useEffect( () => {\n * unregisterShortcut( 'core/edit-post/next-region' );\n * }, [] );\n *\n * const shortcut = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return shortcut ? (\n * <p>{ __( 'Shortcut is not unregistered.' ) }</p>\n * ) : (\n * <p>{ __( 'Shortcut is unregistered.' ) }</p>\n * );\n * };\n *```\n * @return {Object} action.\n */\nexport function unregisterShortcut( name ) {\n\treturn {\n\t\ttype: 'UNREGISTER_SHORTCUT',\n\t\tname,\n\t};\n}\n"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,gBAAgBA,CAAE;EACjCC,IAAI;EACJC,QAAQ;EACRC,WAAW;EACXC,cAAc;EACdC;AACD,CAAC,EAAG;EACH,OAAO;IACNC,IAAI,EAAE,mBAAmB;IACzBL,IAAI;IACJC,QAAQ;IACRE,cAAc;IACdC,OAAO;IACPF;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,kBAAkBA,CAAEN,IAAI,EAAG;EAC1C,OAAO;IACNK,IAAI,EAAE,qBAAqB;IAC3BL;EACD,CAAC;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createReduxStore","register","reducer","actions","selectors","STORE_NAME","store"],"sources":["@wordpress/keyboard-shortcuts/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/keyboard-shortcuts';\n\n/**\n * Store definition for the keyboard shortcuts namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,SAAS,MAAM,aAAa;AAExC,MAAMC,UAAU,GAAG,yBAAyB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAU,EAAE;EAClDH,OAAO;EACPC,OAAO;EACPC;AACD,CAAE,CAAC;AAEHH,QAAQ,CAAEK,KAAM,CAAC"}
|
1
|
+
{"version":3,"names":["createReduxStore","register","reducer","actions","selectors","STORE_NAME","store"],"sources":["@wordpress/keyboard-shortcuts/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/keyboard-shortcuts';\n\n/**\n * Store definition for the keyboard shortcuts namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,SAAS,MAAM,aAAa;AAExC,MAAMC,UAAU,GAAG,yBAAyB;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAU,EAAE;EAClDH,OAAO;EACPC,OAAO;EACPC;AACD,CAAE,CAAC;AAEHH,QAAQ,CAAEK,KAAM,CAAC","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["reducer","state","action","type","name","category","keyCombination","aliases","description","actionName","remainingState"],"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"sourcesContent":["/**\n * Reducer returning the registered shortcuts\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction reducer( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_SHORTCUT':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\tkeyCombination: action.keyCombination,\n\t\t\t\t\taliases: action.aliases,\n\t\t\t\t\tdescription: action.description,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_SHORTCUT':\n\t\t\tconst { [ action.name ]: actionName, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAOA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACtC,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,mBAAmB;MACvB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChBC,QAAQ,EAAEH,MAAM,CAACG,QAAQ;UACzBC,cAAc,EAAEJ,MAAM,CAACI,cAAc;UACrCC,OAAO,EAAEL,MAAM,CAACK,OAAO;UACvBC,WAAW,EAAEN,MAAM,CAACM;QACrB;MACD,CAAC;IACF,KAAK,qBAAqB;MACzB,MAAM;QAAE,CAAEN,MAAM,CAACE,IAAI,GAAIK,UAAU;QAAE,GAAGC;MAAe,CAAC,GAAGT,KAAK;MAChE,OAAOS,cAAc;EACvB;EAEA,OAAOT,KAAK;AACb;AAEA,eAAeD,OAAO"}
|
1
|
+
{"version":3,"names":["reducer","state","action","type","name","category","keyCombination","aliases","description","actionName","remainingState"],"sources":["@wordpress/keyboard-shortcuts/src/store/reducer.js"],"sourcesContent":["/**\n * Reducer returning the registered shortcuts\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nfunction reducer( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'REGISTER_SHORTCUT':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.name ]: {\n\t\t\t\t\tcategory: action.category,\n\t\t\t\t\tkeyCombination: action.keyCombination,\n\t\t\t\t\taliases: action.aliases,\n\t\t\t\t\tdescription: action.description,\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'UNREGISTER_SHORTCUT':\n\t\t\tconst { [ action.name ]: actionName, ...remainingState } = state;\n\t\t\treturn remainingState;\n\t}\n\n\treturn state;\n}\n\nexport default reducer;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,OAAOA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACtC,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,mBAAmB;MACvB,OAAO;QACN,GAAGF,KAAK;QACR,CAAEC,MAAM,CAACE,IAAI,GAAI;UAChBC,QAAQ,EAAEH,MAAM,CAACG,QAAQ;UACzBC,cAAc,EAAEJ,MAAM,CAACI,cAAc;UACrCC,OAAO,EAAEL,MAAM,CAACK,OAAO;UACvBC,WAAW,EAAEN,MAAM,CAACM;QACrB;MACD,CAAC;IACF,KAAK,qBAAqB;MACzB,MAAM;QAAE,CAAEN,MAAM,CAACE,IAAI,GAAIK,UAAU;QAAE,GAAGC;MAAe,CAAC,GAAGT,KAAK;MAChE,OAAOS,cAAc;EACvB;EAEA,OAAOT,KAAK;AACb;AAEA,eAAeD,OAAO","ignoreList":[]}
|
@@ -1,11 +1,7 @@
|
|
1
|
-
/**
|
2
|
-
* External dependencies
|
3
|
-
*/
|
4
|
-
import createSelector from 'rememo';
|
5
|
-
|
6
1
|
/**
|
7
2
|
* WordPress dependencies
|
8
3
|
*/
|
4
|
+
import { createSelector } from '@wordpress/data';
|
9
5
|
import { displayShortcut, shortcutAriaLabel, rawShortcut } from '@wordpress/keycodes';
|
10
6
|
|
11
7
|
/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["createSelector","displayShortcut","shortcutAriaLabel","rawShortcut","EMPTY_ARRAY","FORMATTING_METHODS","display","raw","ariaLabel","getKeyCombinationRepresentation","shortcut","representation","modifier","character","getShortcutKeyCombination","state","name","keyCombination","getShortcutRepresentation","getShortcutDescription","description","getShortcutAliases","aliases","getAllShortcutKeyCombinations","filter","Boolean","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","category"],"sources":["@wordpress/keyboard-shortcuts/src/store/selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tdisplayShortcut,\n\tshortcutAriaLabel,\n\trawShortcut,\n} from '@wordpress/keycodes';\n\n/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */\n\n/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Shortcut formatting methods.\n *\n * @property {WPKeycodeHandlerByModifier} display Display formatting.\n * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.\n * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.\n */\nconst FORMATTING_METHODS = {\n\tdisplay: displayShortcut,\n\traw: rawShortcut,\n\tariaLabel: shortcutAriaLabel,\n};\n\n/**\n * Returns a string representing the key combination.\n *\n * @param {?WPShortcutKeyCombination} shortcut Key combination.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n *\n * @return {string?} Shortcut representation.\n */\nfunction getKeyCombinationRepresentation( shortcut, representation ) {\n\tif ( ! shortcut ) {\n\t\treturn null;\n\t}\n\n\treturn shortcut.modifier\n\t\t? FORMATTING_METHODS[ representation ][ shortcut.modifier ](\n\t\t\t\tshortcut.character\n\t\t )\n\t\t: shortcut.character;\n}\n\n/**\n * Returns the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const {character, modifier} = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * <div>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </div>\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination?} Key combination.\n */\nexport function getShortcutKeyCombination( state, name ) {\n\treturn state[ name ] ? state[ name ].keyCombination : null;\n}\n\n/**\n * Returns a string representing the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const {display, raw, ariaLabel} = useSelect(\n * ( select ) =>{\n * return {\n * display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region' ),\n * raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region','raw' ),\n * ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region', 'ariaLabel')\n * }\n * },\n * []\n * );\n *\n * return (\n * <ul>\n * <li>{ sprintf( 'display string: %s', display ) }</li>\n * <li>{ sprintf( 'raw string: %s', raw ) }</li>\n * <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>\n * </ul>\n * );\n * };\n *```\n *\n * @return {string?} Shortcut representation.\n */\nexport function getShortcutRepresentation(\n\tstate,\n\tname,\n\trepresentation = 'display'\n) {\n\tconst shortcut = getShortcutKeyCombination( state, name );\n\treturn getKeyCombinationRepresentation( shortcut, representation );\n}\n\n/**\n * Returns the shortcut description given its name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutDescription = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutDescription( 'core/edit-post/next-region' ),\n * []\n * );\n *\n * return shortcutDescription ? (\n * <div>{ shortcutDescription }</div>\n * ) : (\n * <div>{ __( 'No description.' ) }</div>\n * );\n * };\n *```\n * @return {string?} Shortcut description.\n */\nexport function getShortcutDescription( state, name ) {\n\treturn state[ name ] ? state[ name ].description : null;\n}\n\n/**\n * Returns the aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutAliases = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutAliases(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * shortcutAliases.length > 0 && (\n * <ul>\n * { shortcutAliases.map( ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport function getShortcutAliases( state, name ) {\n\treturn state[ name ] && state[ name ].aliases\n\t\t? state[ name ].aliases\n\t\t: EMPTY_ARRAY;\n}\n\n/**\n * Returns the shortcuts that include aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutKeyCombinations.map(\n * ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t].filter( Boolean );\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the raw representation of all the keyboard combinations of a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutRawKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutRawKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutRawKeyCombinations.map(\n * ( shortcutRawKeyCombination, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * ' <code>%s</code>',\n * shortcutRawKeyCombination\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations( state, name ).map(\n\t\t\t( combination ) =>\n\t\t\t\tgetKeyCombinationRepresentation( combination, 'raw' )\n\t\t);\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the shortcut names list for a given category name.\n *\n * @param {Object} state Global state.\n * @param {string} name Category name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const categoryShortcuts = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getCategoryShortcuts(\n * 'block'\n * ),\n * []\n * );\n *\n * return (\n * categoryShortcuts.length > 0 && (\n * <ul>\n * { categoryShortcuts.map( ( categoryShortcut ) => (\n * <li key={ categoryShortcut }>{ categoryShortcut }</li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n * @return {string[]} Shortcut names.\n */\nexport const getCategoryShortcuts = createSelector(\n\t( state, categoryName ) => {\n\t\treturn Object.entries( state )\n\t\t\t.filter( ( [ , shortcut ] ) => shortcut.category === categoryName )\n\t\t\t.map( ( [ name ] ) => name );\n\t},\n\t( state ) => [ state ]\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAc,MAAM,QAAQ;;AAEnC;AACA;AACA;AACA,SACCC,eAAe,EACfC,iBAAiB,EACjBC,WAAW,QACL,qBAAqB;;AAE5B;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;EAC1BC,OAAO,EAAEL,eAAe;EACxBM,GAAG,EAAEJ,WAAW;EAChBK,SAAS,EAAEN;AACZ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASO,+BAA+BA,CAAEC,QAAQ,EAAEC,cAAc,EAAG;EACpE,IAAK,CAAED,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOA,QAAQ,CAACE,QAAQ,GACrBP,kBAAkB,CAAEM,cAAc,CAAE,CAAED,QAAQ,CAACE,QAAQ,CAAE,CACzDF,QAAQ,CAACG,SACT,CAAC,GACDH,QAAQ,CAACG,SAAS;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAEC,KAAK,EAAEC,IAAI,EAAG;EACxD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACC,cAAc,GAAG,IAAI;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACxCH,KAAK,EACLC,IAAI,EACJL,cAAc,GAAG,SAAS,EACzB;EACD,MAAMD,QAAQ,GAAGI,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC;EACzD,OAAOP,+BAA+B,CAAEC,QAAQ,EAAEC,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,sBAAsBA,CAAEJ,KAAK,EAAEC,IAAI,EAAG;EACrD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACI,WAAW,GAAG,IAAI;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAEN,KAAK,EAAEC,IAAI,EAAG;EACjD,OAAOD,KAAK,CAAEC,IAAI,CAAE,IAAID,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GAC1CP,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GACrBlB,WAAW;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMmB,6BAA6B,GAAGvB,cAAc,CAC1D,CAAEe,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAO,CACNF,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC,EACxC,GAAGK,kBAAkB,CAAEN,KAAK,EAAEC,IAAK,CAAC,CACpC,CAACQ,MAAM,CAAEC,OAAQ,CAAC;AACpB,CAAC,EACD,CAAEV,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMU,gCAAgC,GAAG1B,cAAc,CAC7D,CAAEe,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAOO,6BAA6B,CAAER,KAAK,EAAEC,IAAK,CAAC,CAACW,GAAG,CACpDC,WAAW,IACZnB,+BAA+B,CAAEmB,WAAW,EAAE,KAAM,CACtD,CAAC;AACF,CAAC,EACD,CAAEb,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMa,oBAAoB,GAAG7B,cAAc,CACjD,CAAEe,KAAK,EAAEe,YAAY,KAAM;EAC1B,OAAOC,MAAM,CAACC,OAAO,CAAEjB,KAAM,CAAC,CAC5BS,MAAM,CAAE,CAAE,GAAId,QAAQ,CAAE,KAAMA,QAAQ,CAACuB,QAAQ,KAAKH,YAAa,CAAC,CAClEH,GAAG,CAAE,CAAE,CAAEX,IAAI,CAAE,KAAMA,IAAK,CAAC;AAC9B,CAAC,EACCD,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC"}
|
1
|
+
{"version":3,"names":["createSelector","displayShortcut","shortcutAriaLabel","rawShortcut","EMPTY_ARRAY","FORMATTING_METHODS","display","raw","ariaLabel","getKeyCombinationRepresentation","shortcut","representation","modifier","character","getShortcutKeyCombination","state","name","keyCombination","getShortcutRepresentation","getShortcutDescription","description","getShortcutAliases","aliases","getAllShortcutKeyCombinations","filter","Boolean","getAllShortcutRawKeyCombinations","map","combination","getCategoryShortcuts","categoryName","Object","entries","category"],"sources":["@wordpress/keyboard-shortcuts/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\nimport {\n\tdisplayShortcut,\n\tshortcutAriaLabel,\n\trawShortcut,\n} from '@wordpress/keycodes';\n\n/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */\n\n/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Shortcut formatting methods.\n *\n * @property {WPKeycodeHandlerByModifier} display Display formatting.\n * @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.\n * @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.\n */\nconst FORMATTING_METHODS = {\n\tdisplay: displayShortcut,\n\traw: rawShortcut,\n\tariaLabel: shortcutAriaLabel,\n};\n\n/**\n * Returns a string representing the key combination.\n *\n * @param {?WPShortcutKeyCombination} shortcut Key combination.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n *\n * @return {string?} Shortcut representation.\n */\nfunction getKeyCombinationRepresentation( shortcut, representation ) {\n\tif ( ! shortcut ) {\n\t\treturn null;\n\t}\n\n\treturn shortcut.modifier\n\t\t? FORMATTING_METHODS[ representation ][ shortcut.modifier ](\n\t\t\t\tshortcut.character\n\t\t )\n\t\t: shortcut.character;\n}\n\n/**\n * Returns the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const {character, modifier} = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutKeyCombination(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * <div>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </div>\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination?} Key combination.\n */\nexport function getShortcutKeyCombination( state, name ) {\n\treturn state[ name ] ? state[ name ].keyCombination : null;\n}\n\n/**\n * Returns a string representing the main key combination for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @param {keyof FORMATTING_METHODS} representation Type of representation\n * (display, raw, ariaLabel).\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const {display, raw, ariaLabel} = useSelect(\n * ( select ) =>{\n * return {\n * display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region' ),\n * raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region','raw' ),\n * ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/edit-post/next-region', 'ariaLabel')\n * }\n * },\n * []\n * );\n *\n * return (\n * <ul>\n * <li>{ sprintf( 'display string: %s', display ) }</li>\n * <li>{ sprintf( 'raw string: %s', raw ) }</li>\n * <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>\n * </ul>\n * );\n * };\n *```\n *\n * @return {string?} Shortcut representation.\n */\nexport function getShortcutRepresentation(\n\tstate,\n\tname,\n\trepresentation = 'display'\n) {\n\tconst shortcut = getShortcutKeyCombination( state, name );\n\treturn getKeyCombinationRepresentation( shortcut, representation );\n}\n\n/**\n * Returns the shortcut description given its name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutDescription = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutDescription( 'core/edit-post/next-region' ),\n * []\n * );\n *\n * return shortcutDescription ? (\n * <div>{ shortcutDescription }</div>\n * ) : (\n * <div>{ __( 'No description.' ) }</div>\n * );\n * };\n *```\n * @return {string?} Shortcut description.\n */\nexport function getShortcutDescription( state, name ) {\n\treturn state[ name ] ? state[ name ].description : null;\n}\n\n/**\n * Returns the aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n * const ExampleComponent = () => {\n * const shortcutAliases = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getShortcutAliases(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * shortcutAliases.length > 0 && (\n * <ul>\n * { shortcutAliases.map( ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport function getShortcutAliases( state, name ) {\n\treturn state[ name ] && state[ name ].aliases\n\t\t? state[ name ].aliases\n\t\t: EMPTY_ARRAY;\n}\n\n/**\n * Returns the shortcuts that include aliases for a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutKeyCombinations.map(\n * ( { character, modifier }, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * 'Character: <code>%s</code> / Modifier: <code>%s</code>',\n * character,\n * modifier\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {WPShortcutKeyCombination[]} Key combinations.\n */\nexport const getAllShortcutKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn [\n\t\t\tgetShortcutKeyCombination( state, name ),\n\t\t\t...getShortcutAliases( state, name ),\n\t\t].filter( Boolean );\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the raw representation of all the keyboard combinations of a given shortcut name.\n *\n * @param {Object} state Global state.\n * @param {string} name Shortcut name.\n *\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n * import { createInterpolateElement } from '@wordpress/element';\n * import { sprintf } from '@wordpress/i18n';\n *\n * const ExampleComponent = () => {\n * const allShortcutRawKeyCombinations = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(\n * 'core/edit-post/next-region'\n * ),\n * []\n * );\n *\n * return (\n * allShortcutRawKeyCombinations.length > 0 && (\n * <ul>\n * { allShortcutRawKeyCombinations.map(\n * ( shortcutRawKeyCombination, index ) => (\n * <li key={ index }>\n * { createInterpolateElement(\n * sprintf(\n * ' <code>%s</code>',\n * shortcutRawKeyCombination\n * ),\n * {\n * code: <code />,\n * }\n * ) }\n * </li>\n * )\n * ) }\n * </ul>\n * )\n * );\n * };\n *```\n *\n * @return {string[]} Shortcuts.\n */\nexport const getAllShortcutRawKeyCombinations = createSelector(\n\t( state, name ) => {\n\t\treturn getAllShortcutKeyCombinations( state, name ).map(\n\t\t\t( combination ) =>\n\t\t\t\tgetKeyCombinationRepresentation( combination, 'raw' )\n\t\t);\n\t},\n\t( state, name ) => [ state[ name ] ]\n);\n\n/**\n * Returns the shortcut names list for a given category name.\n *\n * @param {Object} state Global state.\n * @param {string} name Category name.\n * @example\n *\n *```js\n * import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n * import { useSelect } from '@wordpress/data';\n *\n * const ExampleComponent = () => {\n * const categoryShortcuts = useSelect(\n * ( select ) =>\n * select( keyboardShortcutsStore ).getCategoryShortcuts(\n * 'block'\n * ),\n * []\n * );\n *\n * return (\n * categoryShortcuts.length > 0 && (\n * <ul>\n * { categoryShortcuts.map( ( categoryShortcut ) => (\n * <li key={ categoryShortcut }>{ categoryShortcut }</li>\n * ) ) }\n * </ul>\n * )\n * );\n * };\n *```\n * @return {string[]} Shortcut names.\n */\nexport const getCategoryShortcuts = createSelector(\n\t( state, categoryName ) => {\n\t\treturn Object.entries( state )\n\t\t\t.filter( ( [ , shortcut ] ) => shortcut.category === categoryName )\n\t\t\t.map( ( [ name ] ) => name );\n\t},\n\t( state ) => [ state ]\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,iBAAiB;AAChD,SACCC,eAAe,EACfC,iBAAiB,EACjBC,WAAW,QACL,qBAAqB;;AAE5B;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;EAC1BC,OAAO,EAAEL,eAAe;EACxBM,GAAG,EAAEJ,WAAW;EAChBK,SAAS,EAAEN;AACZ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASO,+BAA+BA,CAAEC,QAAQ,EAAEC,cAAc,EAAG;EACpE,IAAK,CAAED,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOA,QAAQ,CAACE,QAAQ,GACrBP,kBAAkB,CAAEM,cAAc,CAAE,CAAED,QAAQ,CAACE,QAAQ,CAAE,CACzDF,QAAQ,CAACG,SACT,CAAC,GACDH,QAAQ,CAACG,SAAS;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAEC,KAAK,EAAEC,IAAI,EAAG;EACxD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACC,cAAc,GAAG,IAAI;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACxCH,KAAK,EACLC,IAAI,EACJL,cAAc,GAAG,SAAS,EACzB;EACD,MAAMD,QAAQ,GAAGI,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC;EACzD,OAAOP,+BAA+B,CAAEC,QAAQ,EAAEC,cAAe,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,sBAAsBA,CAAEJ,KAAK,EAAEC,IAAI,EAAG;EACrD,OAAOD,KAAK,CAAEC,IAAI,CAAE,GAAGD,KAAK,CAAEC,IAAI,CAAE,CAACI,WAAW,GAAG,IAAI;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAEN,KAAK,EAAEC,IAAI,EAAG;EACjD,OAAOD,KAAK,CAAEC,IAAI,CAAE,IAAID,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GAC1CP,KAAK,CAAEC,IAAI,CAAE,CAACM,OAAO,GACrBlB,WAAW;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMmB,6BAA6B,GAAGvB,cAAc,CAC1D,CAAEe,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAO,CACNF,yBAAyB,CAAEC,KAAK,EAAEC,IAAK,CAAC,EACxC,GAAGK,kBAAkB,CAAEN,KAAK,EAAEC,IAAK,CAAC,CACpC,CAACQ,MAAM,CAAEC,OAAQ,CAAC;AACpB,CAAC,EACD,CAAEV,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMU,gCAAgC,GAAG1B,cAAc,CAC7D,CAAEe,KAAK,EAAEC,IAAI,KAAM;EAClB,OAAOO,6BAA6B,CAAER,KAAK,EAAEC,IAAK,CAAC,CAACW,GAAG,CACpDC,WAAW,IACZnB,+BAA+B,CAAEmB,WAAW,EAAE,KAAM,CACtD,CAAC;AACF,CAAC,EACD,CAAEb,KAAK,EAAEC,IAAI,KAAM,CAAED,KAAK,CAAEC,IAAI,CAAE,CACnC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMa,oBAAoB,GAAG7B,cAAc,CACjD,CAAEe,KAAK,EAAEe,YAAY,KAAM;EAC1B,OAAOC,MAAM,CAACC,OAAO,CAAEjB,KAAM,CAAC,CAC5BS,MAAM,CAAE,CAAE,GAAId,QAAQ,CAAE,KAAMA,QAAQ,CAACuB,QAAQ,KAAKH,YAAa,CAAC,CAClEH,GAAG,CAAE,CAAE,CAAEX,IAAI,CAAE,KAAMA,IAAK,CAAC;AAC9B,CAAC,EACCD,KAAK,IAAM,CAAEA,KAAK,CACrB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@wordpress/keyboard-shortcuts",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.33.0",
|
4
4
|
"description": "Handling keyboard shortcuts.",
|
5
5
|
"author": "The WordPress Contributors",
|
6
6
|
"license": "GPL-2.0-or-later",
|
@@ -26,10 +26,9 @@
|
|
26
26
|
"react-native": "src/index",
|
27
27
|
"dependencies": {
|
28
28
|
"@babel/runtime": "^7.16.0",
|
29
|
-
"@wordpress/data": "^9.
|
30
|
-
"@wordpress/element": "^5.
|
31
|
-
"@wordpress/keycodes": "^3.
|
32
|
-
"rememo": "^4.0.2"
|
29
|
+
"@wordpress/data": "^9.26.0",
|
30
|
+
"@wordpress/element": "^5.33.0",
|
31
|
+
"@wordpress/keycodes": "^3.56.0"
|
33
32
|
},
|
34
33
|
"peerDependencies": {
|
35
34
|
"react": "^18.0.0"
|
@@ -37,5 +36,5 @@
|
|
37
36
|
"publishConfig": {
|
38
37
|
"access": "public"
|
39
38
|
},
|
40
|
-
"gitHead": "
|
39
|
+
"gitHead": "280403b4c1cf6cc2c55a6c4d56f9ef91145e4191"
|
41
40
|
}
|
package/src/store/selectors.js
CHANGED