@wordpress/keyboard-shortcuts 4.19.1 → 4.19.3

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.
@@ -28,10 +28,10 @@ const {
28
28
  * @return {import('@wordpress/element').WPElement} Component.
29
29
  */
30
30
  function ShortcutProvider(props) {
31
- const keyboardShortcuts = (0, _element.useRef)(new Set());
31
+ const [keyboardShortcuts] = (0, _element.useState)(() => new Set());
32
32
  function onKeyDown(event) {
33
33
  if (props.onKeyDown) props.onKeyDown(event);
34
- for (const keyboardShortcut of keyboardShortcuts.current) {
34
+ for (const keyboardShortcut of keyboardShortcuts) {
35
35
  keyboardShortcut(event);
36
36
  }
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_context","Provider","context","ShortcutProvider","props","keyboardShortcuts","useRef","Set","onKeyDown","event","keyboardShortcut","current","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n * 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 {import('@wordpress/element').WPElement} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAM;EAAEE;AAAS,CAAC,GAAGC,gBAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAAE,IAAIC,GAAG,CAAC,CAAE,CAAC;EAE7C,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKL,KAAK,CAACI,SAAS,EAAGJ,KAAK,CAACI,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIL,iBAAiB,CAACM,OAAO,EAAG;MAC3DD,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACC,IAAAX,QAAA,CAAAc,aAAA,EAACX,QAAQ;IAACY,KAAK,EAAGR;EAAmB,GACpC,IAAAP,QAAA,CAAAc,aAAA;IAAA,GAAUR,KAAK;IAAGI,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD"}
1
+ {"version":3,"names":["_element","require","_context","Provider","context","ShortcutProvider","props","keyboardShortcuts","useState","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 {import('@wordpress/element').WPElement} 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,IAAAX,QAAA,CAAAa,aAAA,EAACV,QAAQ;IAACW,KAAK,EAAGP;EAAmB,GACpC,IAAAP,QAAA,CAAAa,aAAA;IAAA,GAAUP,KAAK;IAAGI,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD"}
@@ -2,7 +2,7 @@ import { createElement } from "@wordpress/element";
2
2
  /**
3
3
  * WordPress dependencies
4
4
  */
5
- import { useRef } from '@wordpress/element';
5
+ import { useState } from '@wordpress/element';
6
6
 
7
7
  /**
8
8
  * Internal dependencies
@@ -22,10 +22,10 @@ const {
22
22
  * @return {import('@wordpress/element').WPElement} Component.
23
23
  */
24
24
  export function ShortcutProvider(props) {
25
- const keyboardShortcuts = useRef(new Set());
25
+ const [keyboardShortcuts] = useState(() => new Set());
26
26
  function onKeyDown(event) {
27
27
  if (props.onKeyDown) props.onKeyDown(event);
28
- for (const keyboardShortcut of keyboardShortcuts.current) {
28
+ for (const keyboardShortcut of keyboardShortcuts) {
29
29
  keyboardShortcut(event);
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useRef","context","Provider","ShortcutProvider","props","keyboardShortcuts","Set","onKeyDown","event","keyboardShortcut","current","createElement","value"],"sources":["@wordpress/keyboard-shortcuts/src/components/shortcut-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { context } from '../context';\n\nconst { Provider } = context;\n\n/**\n * Handles callbacks added to context by `useShortcut`.\n * 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 {import('@wordpress/element').WPElement} Component.\n */\nexport function ShortcutProvider( props ) {\n\tconst keyboardShortcuts = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( props.onKeyDown ) props.onKeyDown( event );\n\n\t\tfor ( const keyboardShortcut of keyboardShortcuts.current ) {\n\t\t\tkeyboardShortcut( event );\n\t\t}\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions */\n\treturn (\n\t\t<Provider value={ keyboardShortcuts }>\n\t\t\t<div { ...props } onKeyDown={ onKeyDown } />\n\t\t</Provider>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions */\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,YAAY;AAEpC,MAAM;EAAEC;AAAS,CAAC,GAAGD,OAAO;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAAEC,KAAK,EAAG;EACzC,MAAMC,iBAAiB,GAAGL,MAAM,CAAE,IAAIM,GAAG,CAAC,CAAE,CAAC;EAE7C,SAASC,SAASA,CAAEC,KAAK,EAAG;IAC3B,IAAKJ,KAAK,CAACG,SAAS,EAAGH,KAAK,CAACG,SAAS,CAAEC,KAAM,CAAC;IAE/C,KAAM,MAAMC,gBAAgB,IAAIJ,iBAAiB,CAACK,OAAO,EAAG;MAC3DD,gBAAgB,CAAED,KAAM,CAAC;IAC1B;EACD;;EAEA;EACA,OACCG,aAAA,CAACT,QAAQ;IAACU,KAAK,EAAGP;EAAmB,GACpCM,aAAA;IAAA,GAAUP,KAAK;IAAGG,SAAS,EAAGA;EAAW,CAAE,CAClC,CAAC;EAEZ;AACD"}
1
+ {"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 {import('@wordpress/element').WPElement} 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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/keyboard-shortcuts",
3
- "version": "4.19.1",
3
+ "version": "4.19.3",
4
4
  "description": "Handling keyboard shortcuts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,9 +26,9 @@
26
26
  "react-native": "src/index",
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.16.0",
29
- "@wordpress/data": "^9.12.1",
30
- "@wordpress/element": "^5.19.1",
31
- "@wordpress/keycodes": "^3.42.1",
29
+ "@wordpress/data": "^9.12.3",
30
+ "@wordpress/element": "^5.19.3",
31
+ "@wordpress/keycodes": "^3.42.3",
32
32
  "rememo": "^4.0.2"
33
33
  },
34
34
  "peerDependencies": {
@@ -37,5 +37,5 @@
37
37
  "publishConfig": {
38
38
  "access": "public"
39
39
  },
40
- "gitHead": "4987d16acb5c41b62704dc4f88225acb97ddd698"
40
+ "gitHead": "6256f93c37705d142f75a99f1fc808540ca7dca8"
41
41
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useRef } from '@wordpress/element';
4
+ import { useState } from '@wordpress/element';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -20,12 +20,12 @@ const { Provider } = context;
20
20
  * @return {import('@wordpress/element').WPElement} Component.
21
21
  */
22
22
  export function ShortcutProvider( props ) {
23
- const keyboardShortcuts = useRef( new Set() );
23
+ const [ keyboardShortcuts ] = useState( () => new Set() );
24
24
 
25
25
  function onKeyDown( event ) {
26
26
  if ( props.onKeyDown ) props.onKeyDown( event );
27
27
 
28
- for ( const keyboardShortcut of keyboardShortcuts.current ) {
28
+ for ( const keyboardShortcut of keyboardShortcuts ) {
29
29
  keyboardShortcut( event );
30
30
  }
31
31
  }