@wordpress/compose 5.0.1 → 5.0.5

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.
Files changed (89) hide show
  1. package/README.md +12 -3
  2. package/build/higher-order/if-condition/index.js.map +1 -1
  3. package/build/higher-order/pure/index.js.map +1 -1
  4. package/build/higher-order/with-instance-id/index.js.map +1 -1
  5. package/build/higher-order/with-safe-timeout/index.js.map +1 -1
  6. package/build/hooks/use-constrained-tabbing/index.js +46 -43
  7. package/build/hooks/use-constrained-tabbing/index.js.map +1 -1
  8. package/build/hooks/use-debounce/index.js +1 -1
  9. package/build/hooks/use-debounce/index.js.map +1 -1
  10. package/build/hooks/use-drop-zone/index.js +12 -6
  11. package/build/hooks/use-drop-zone/index.js.map +1 -1
  12. package/build/hooks/use-fixed-window-list/index.js +175 -0
  13. package/build/hooks/use-fixed-window-list/index.js.map +1 -0
  14. package/build/hooks/use-focusable-iframe/index.js +50 -0
  15. package/build/hooks/use-focusable-iframe/index.js.map +1 -0
  16. package/build/hooks/use-previous/index.js +3 -14
  17. package/build/hooks/use-previous/index.js.map +1 -1
  18. package/build/hooks/use-reduced-motion/index.js +1 -7
  19. package/build/hooks/use-reduced-motion/index.js.map +1 -1
  20. package/build/hooks/use-throttle/index.js +1 -1
  21. package/build/hooks/use-throttle/index.js.map +1 -1
  22. package/build/index.js +16 -0
  23. package/build/index.js.map +1 -1
  24. package/build-module/higher-order/if-condition/index.js +1 -1
  25. package/build-module/higher-order/if-condition/index.js.map +1 -1
  26. package/build-module/higher-order/pure/index.js +1 -1
  27. package/build-module/higher-order/pure/index.js.map +1 -1
  28. package/build-module/higher-order/with-instance-id/index.js +1 -2
  29. package/build-module/higher-order/with-instance-id/index.js.map +1 -1
  30. package/build-module/higher-order/with-safe-timeout/index.js +1 -1
  31. package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
  32. package/build-module/hooks/use-constrained-tabbing/index.js +41 -40
  33. package/build-module/hooks/use-constrained-tabbing/index.js.map +1 -1
  34. package/build-module/hooks/use-debounce/index.js +1 -1
  35. package/build-module/hooks/use-debounce/index.js.map +1 -1
  36. package/build-module/hooks/use-drop-zone/index.js +12 -6
  37. package/build-module/hooks/use-drop-zone/index.js.map +1 -1
  38. package/build-module/hooks/use-fixed-window-list/index.js +164 -0
  39. package/build-module/hooks/use-fixed-window-list/index.js.map +1 -0
  40. package/build-module/hooks/use-focusable-iframe/index.js +40 -0
  41. package/build-module/hooks/use-focusable-iframe/index.js.map +1 -0
  42. package/build-module/hooks/use-previous/index.js +3 -14
  43. package/build-module/hooks/use-previous/index.js.map +1 -1
  44. package/build-module/hooks/use-reduced-motion/index.js +2 -8
  45. package/build-module/hooks/use-reduced-motion/index.js.map +1 -1
  46. package/build-module/hooks/use-throttle/index.js +1 -1
  47. package/build-module/hooks/use-throttle/index.js.map +1 -1
  48. package/build-module/index.js +2 -0
  49. package/build-module/index.js.map +1 -1
  50. package/build-types/higher-order/if-condition/index.d.ts.map +1 -1
  51. package/build-types/higher-order/pure/index.d.ts.map +1 -1
  52. package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
  53. package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
  54. package/build-types/hooks/use-constrained-tabbing/index.d.ts.map +1 -1
  55. package/build-types/hooks/use-debounce/index.d.ts +2 -2
  56. package/build-types/hooks/use-debounce/index.d.ts.map +1 -1
  57. package/build-types/hooks/use-drop-zone/index.d.ts.map +1 -1
  58. package/build-types/hooks/use-fixed-window-list/index.d.ts +57 -0
  59. package/build-types/hooks/use-fixed-window-list/index.d.ts.map +1 -0
  60. package/build-types/hooks/use-focus-outside/index.d.ts +3 -3
  61. package/build-types/hooks/use-focus-outside/index.d.ts.map +1 -1
  62. package/build-types/hooks/use-focusable-iframe/index.d.ts +8 -0
  63. package/build-types/hooks/use-focusable-iframe/index.d.ts.map +1 -0
  64. package/build-types/hooks/use-previous/index.d.ts +2 -4
  65. package/build-types/hooks/use-previous/index.d.ts.map +1 -1
  66. package/build-types/hooks/use-reduced-motion/index.d.ts +5 -0
  67. package/build-types/hooks/use-reduced-motion/index.d.ts.map +1 -1
  68. package/build-types/hooks/use-throttle/index.d.ts +2 -2
  69. package/build-types/hooks/use-throttle/index.d.ts.map +1 -1
  70. package/build-types/hooks/use-viewport-match/index.d.ts +2 -2
  71. package/build-types/hooks/use-viewport-match/index.d.ts.map +1 -1
  72. package/build-types/index.d.ts +2 -0
  73. package/package.json +9 -9
  74. package/src/higher-order/if-condition/index.tsx +0 -1
  75. package/src/higher-order/pure/index.tsx +0 -1
  76. package/src/higher-order/with-instance-id/index.tsx +0 -1
  77. package/src/higher-order/with-safe-timeout/index.tsx +0 -1
  78. package/src/hooks/use-constrained-tabbing/index.js +39 -33
  79. package/src/hooks/use-debounce/index.js +1 -1
  80. package/src/hooks/use-drop-zone/index.js +11 -9
  81. package/src/hooks/use-fixed-window-list/index.js +174 -0
  82. package/src/hooks/use-focusable-iframe/README.md +29 -0
  83. package/src/hooks/use-focusable-iframe/index.js +34 -0
  84. package/src/hooks/use-previous/index.ts +24 -0
  85. package/src/hooks/use-reduced-motion/index.js +2 -13
  86. package/src/hooks/use-throttle/index.js +1 -1
  87. package/src/index.js +2 -0
  88. package/tsconfig.tsbuildinfo +1 -1694
  89. package/src/hooks/use-previous/index.js +0 -31
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = useFocusableIframe;
9
+
10
+ var _useRefEffect = _interopRequireDefault(require("../use-ref-effect"));
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ /**
17
+ * Dispatches a bubbling focus event when the iframe receives focus. Use
18
+ * `onFocus` as usual on the iframe or a parent element.
19
+ *
20
+ * @return {Object} Ref to pass to the iframe.
21
+ */
22
+ function useFocusableIframe() {
23
+ return (0, _useRefEffect.default)(element => {
24
+ const {
25
+ ownerDocument
26
+ } = element;
27
+ if (!ownerDocument) return;
28
+ const {
29
+ defaultView
30
+ } = ownerDocument;
31
+ if (!defaultView) return;
32
+ /**
33
+ * Checks whether the iframe is the activeElement, inferring that it has
34
+ * then received focus, and dispatches a focus event.
35
+ */
36
+
37
+ function checkFocus() {
38
+ if (ownerDocument && ownerDocument.activeElement === element) {
39
+ /** @type {HTMLElement} */
40
+ element.focus();
41
+ }
42
+ }
43
+
44
+ defaultView.addEventListener('blur', checkFocus);
45
+ return () => {
46
+ defaultView.removeEventListener('blur', checkFocus);
47
+ };
48
+ }, []);
49
+ }
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-focusable-iframe/index.js"],"names":["useFocusableIframe","element","ownerDocument","defaultView","checkFocus","activeElement","focus","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAT,GAA8B;AAC5C,SAAO,2BAAgBC,OAAF,IAAe;AACnC,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,OAA1B;AACA,QAAK,CAAEC,aAAP,EAAuB;AACvB,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,aAAxB;AACA,QAAK,CAAEC,WAAP,EAAqB;AAErB;AACF;AACA;AACA;;AACE,aAASC,UAAT,GAAsB;AACrB,UAAKF,aAAa,IAAIA,aAAa,CAACG,aAAd,KAAgCJ,OAAtD,EAAgE;AAC/D;AAA6BA,QAAAA,OAAF,CAAYK,KAAZ;AAC3B;AACD;;AAEDH,IAAAA,WAAW,CAACI,gBAAZ,CAA8B,MAA9B,EAAsCH,UAAtC;AACA,WAAO,MAAM;AACZD,MAAAA,WAAW,CAACK,mBAAZ,CAAiC,MAAjC,EAAyCJ,UAAzC;AACA,KAFD;AAGA,GApBM,EAoBJ,EApBI,CAAP;AAqBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * Dispatches a bubbling focus event when the iframe receives focus. Use\n * `onFocus` as usual on the iframe or a parent element.\n *\n * @return {Object} Ref to pass to the iframe.\n */\nexport default function useFocusableIframe() {\n\treturn useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tif ( ! ownerDocument ) return;\n\t\tconst { defaultView } = ownerDocument;\n\t\tif ( ! defaultView ) return;\n\n\t\t/**\n\t\t * Checks whether the iframe is the activeElement, inferring that it has\n\t\t * then received focus, and dispatches a focus event.\n\t\t */\n\t\tfunction checkFocus() {\n\t\t\tif ( ownerDocument && ownerDocument.activeElement === element ) {\n\t\t\t\t/** @type {HTMLElement} */ ( element ).focus();\n\t\t\t}\n\t\t}\n\n\t\tdefaultView.addEventListener( 'blur', checkFocus );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'blur', checkFocus );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -15,23 +15,12 @@ var _element = require("@wordpress/element");
15
15
  * Use something's value from the previous render.
16
16
  * Based on https://usehooks.com/usePrevious/.
17
17
  *
18
- * @template T
18
+ * @param value The value to track.
19
19
  *
20
- * @param {T} value The value to track.
21
- *
22
- * @return {T | undefined} The value from the previous render.
20
+ * @return The value from the previous render.
23
21
  */
24
22
  function usePrevious(value) {
25
- // Disable reason: without an explicit type detail, the type of ref will be
26
- // inferred based on the initial useRef argument, which is undefined.
27
- // https://github.com/WordPress/gutenberg/pull/22597#issuecomment-633588366
28
-
29
- /* eslint-disable jsdoc/no-undefined-types */
30
- const ref = (0, _element.useRef)(
31
- /** @type {T | undefined} */
32
- undefined);
33
- /* eslint-enable jsdoc/no-undefined-types */
34
- // Store current value in ref.
23
+ const ref = (0, _element.useRef)(); // Store current value in ref.
35
24
 
36
25
  (0, _element.useEffect)(() => {
37
26
  ref.current = value;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-previous/index.js"],"names":["usePrevious","value","ref","undefined","current"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,KAAtB,EAA8B;AAC5C;AACA;AACA;;AACA;AACA,QAAMC,GAAG,GAAG;AAAQ;AAA+BC,EAAAA,SAAvC,CAAZ;AACA;AAEA;;AACA,0BAAW,MAAM;AAChBD,IAAAA,GAAG,CAACE,OAAJ,GAAcH,KAAd;AACA,GAFD,EAEG,CAAEA,KAAF,CAFH,EAT4C,CAW5B;AAEhB;;AACA,SAAOC,GAAG,CAACE,OAAX;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Use something's value from the previous render.\n * Based on https://usehooks.com/usePrevious/.\n *\n * @template T\n *\n * @param {T} value The value to track.\n *\n * @return {T | undefined} The value from the previous render.\n */\nexport default function usePrevious( value ) {\n\t// Disable reason: without an explicit type detail, the type of ref will be\n\t// inferred based on the initial useRef argument, which is undefined.\n\t// https://github.com/WordPress/gutenberg/pull/22597#issuecomment-633588366\n\t/* eslint-disable jsdoc/no-undefined-types */\n\tconst ref = useRef( /** @type {T | undefined} */ ( undefined ) );\n\t/* eslint-enable jsdoc/no-undefined-types */\n\n\t// Store current value in ref.\n\tuseEffect( () => {\n\t\tref.current = value;\n\t}, [ value ] ); // Re-run when value changes.\n\n\t// Return previous value (happens before update in useEffect above).\n\treturn ref.current;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-previous/index.ts"],"names":["usePrevious","value","ref","current"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAA2BC,KAA3B,EAAqD;AACnE,QAAMC,GAAG,GAAG,sBAAZ,CADmE,CAGnE;;AACA,0BAAW,MAAM;AAChBA,IAAAA,GAAG,CAACC,OAAJ,GAAcF,KAAd;AACA,GAFD,EAEG,CAAEA,KAAF,CAFH,EAJmE,CAMnD;AAEhB;;AACA,SAAOC,GAAG,CAACC,OAAX;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Use something's value from the previous render.\n * Based on https://usehooks.com/usePrevious/.\n *\n * @param value The value to track.\n *\n * @return The value from the previous render.\n */\nexport default function usePrevious< T >( value: T ): T | undefined {\n\tconst ref = useRef< T >();\n\n\t// Store current value in ref.\n\tuseEffect( () => {\n\t\tref.current = value;\n\t}, [ value ] ); // Re-run when value changes.\n\n\t// Return previous value (happens before update in useEffect above).\n\treturn ref.current;\n}\n"]}
@@ -13,19 +13,13 @@ var _useMediaQuery = _interopRequireDefault(require("../use-media-query"));
13
13
  * Internal dependencies
14
14
  */
15
15
 
16
- /**
17
- * Whether or not the user agent is Internet Explorer.
18
- *
19
- * @type {boolean}
20
- */
21
- const IS_IE = typeof window !== 'undefined' && window.navigator.userAgent.indexOf('Trident') >= 0;
22
16
  /**
23
17
  * Hook returning whether the user has a preference for reduced motion.
24
18
  *
25
19
  * @return {boolean} Reduced motion preference value.
26
20
  */
21
+ const useReducedMotion = () => (0, _useMediaQuery.default)('(prefers-reduced-motion: reduce)');
27
22
 
28
- const useReducedMotion = process.env.FORCE_REDUCED_MOTION || IS_IE ? () => true : () => (0, _useMediaQuery.default)('(prefers-reduced-motion: reduce)');
29
23
  var _default = useReducedMotion;
30
24
  exports.default = _default;
31
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-reduced-motion/index.js"],"names":["IS_IE","window","navigator","userAgent","indexOf","useReducedMotion","process","env","FORCE_REDUCED_MOTION"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,KAAK,GACV,OAAOC,MAAP,KAAkB,WAAlB,IACAA,MAAM,CAACC,SAAP,CAAiBC,SAAjB,CAA2BC,OAA3B,CAAoC,SAApC,KAAmD,CAFpD;AAIA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GACrBC,OAAO,CAACC,GAAR,CAAYC,oBAAZ,IAAoCR,KAApC,GACG,MAAM,IADT,GAEG,MAAM,4BAAe,kCAAf,CAHV;eAKeK,gB","sourcesContent":["/**\n * Internal dependencies\n */\nimport useMediaQuery from '../use-media-query';\n\n/**\n * Whether or not the user agent is Internet Explorer.\n *\n * @type {boolean}\n */\nconst IS_IE =\n\ttypeof window !== 'undefined' &&\n\twindow.navigator.userAgent.indexOf( 'Trident' ) >= 0;\n\n/**\n * Hook returning whether the user has a preference for reduced motion.\n *\n * @return {boolean} Reduced motion preference value.\n */\nconst useReducedMotion =\n\tprocess.env.FORCE_REDUCED_MOTION || IS_IE\n\t\t? () => true\n\t\t: () => useMediaQuery( '(prefers-reduced-motion: reduce)' );\n\nexport default useReducedMotion;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-reduced-motion/index.js"],"names":["useReducedMotion"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,MAAMA,gBAAgB,GAAG,MACxB,4BAAe,kCAAf,CADD;;eAGeA,gB","sourcesContent":["/**\n * Internal dependencies\n */\nimport useMediaQuery from '../use-media-query';\n\n/**\n * Hook returning whether the user has a preference for reduced motion.\n *\n * @return {boolean} Reduced motion preference value.\n */\nconst useReducedMotion = () =>\n\tuseMediaQuery( '(prefers-reduced-motion: reduce)' );\n\nexport default useReducedMotion;\n"]}
@@ -32,7 +32,7 @@ var _element = require("@wordpress/element");
32
32
  * @param {TFunc} fn The function to throttle.
33
33
  * @param {number} [wait] The number of milliseconds to throttle invocations to.
34
34
  * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.
35
- * @return {TFunc & import('lodash').Cancelable} Throttled function.
35
+ * @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.
36
36
  */
37
37
  function useThrottle(fn, wait, options) {
38
38
  const throttled = (0, _useMemoOne.useMemoOne)(() => (0, _lodash.throttle)(fn, wait, options), [fn, wait, options]);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"names":["useThrottle","fn","wait","options","throttled","cancel"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD,QAAMC,SAAS,GAAG,4BAAY,MAAM,sBAAUH,EAAV,EAAcC,IAAd,EAAoBC,OAApB,CAAlB,EAAiD,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAjD,CAAlB;AAKA,0BAAW,MAAM,MAAMC,SAAS,CAACC,MAAV,EAAvB,EAA2C,CAAED,SAAF,CAA3C;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { throttle } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Throttles a function with Lodash's `throttle`. A new throttled function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to throttle, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/throttle/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to throttle.\n * @param {number} [wait] The number of milliseconds to throttle invocations to.\n * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.\n * @return {TFunc & import('lodash').Cancelable} Throttled function.\n */\nexport default function useThrottle( fn, wait, options ) {\n\tconst throttled = useMemoOne( () => throttle( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => throttled.cancel(), [ throttled ] );\n\treturn throttled;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"names":["useThrottle","fn","wait","options","throttled","cancel"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD,QAAMC,SAAS,GAAG,4BAAY,MAAM,sBAAUH,EAAV,EAAcC,IAAd,EAAoBC,OAApB,CAAlB,EAAiD,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAjD,CAAlB;AAKA,0BAAW,MAAM,MAAMC,SAAS,CAACC,MAAV,EAAvB,EAA2C,CAAED,SAAF,CAA3C;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { throttle } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Throttles a function with Lodash's `throttle`. A new throttled function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to throttle, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/throttle/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to throttle.\n * @param {number} [wait] The number of milliseconds to throttle invocations to.\n * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.\n * @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.\n */\nexport default function useThrottle( fn, wait, options ) {\n\tconst throttled = useMemoOne( () => throttle( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => throttled.cancel(), [ throttled ] );\n\treturn throttled;\n}\n"]}
package/build/index.js CHANGED
@@ -191,6 +191,18 @@ Object.defineProperty(exports, "__experimentalUseDropZone", {
191
191
  return _useDropZone.default;
192
192
  }
193
193
  });
194
+ Object.defineProperty(exports, "useFocusableIframe", {
195
+ enumerable: true,
196
+ get: function () {
197
+ return _useFocusableIframe.default;
198
+ }
199
+ });
200
+ Object.defineProperty(exports, "__experimentalUseFixedWindowList", {
201
+ enumerable: true,
202
+ get: function () {
203
+ return _useFixedWindowList.default;
204
+ }
205
+ });
194
206
 
195
207
  var _createHigherOrderComponent = _interopRequireDefault(require("./utils/create-higher-order-component"));
196
208
 
@@ -253,4 +265,8 @@ var _useMergeRefs = _interopRequireDefault(require("./hooks/use-merge-refs"));
253
265
  var _useRefEffect = _interopRequireDefault(require("./hooks/use-ref-effect"));
254
266
 
255
267
  var _useDropZone = _interopRequireDefault(require("./hooks/use-drop-zone"));
268
+
269
+ var _useFocusableIframe = _interopRequireDefault(require("./hooks/use-focusable-iframe"));
270
+
271
+ var _useFixedWindowList = _interopRequireDefault(require("./hooks/use-fixed-window-list"));
256
272
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["// Utils\nexport { default as createHigherOrderComponent } from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\n\n// Higher-order components\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["// Utils\nexport { default as createHigherOrderComponent } from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\n\n// Higher-order components\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\nexport { default as useFocusableIframe } from './hooks/use-focusable-iframe';\nexport { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';\n"]}
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * Internal dependencies
5
5
  */
6
- import createHigherOrderComponent from '../../utils/create-higher-order-component'; // eslint-disable-next-line no-duplicate-imports
6
+ import createHigherOrderComponent from '../../utils/create-higher-order-component';
7
7
 
8
8
  /**
9
9
  * Higher-order component creator, creating a new component which renders if
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["createHigherOrderComponent","ifCondition","predicate","WrappedComponent","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC,C,CACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAChBC,SADmB,IAGnBF,0BAA0B,CACvBG,gBAAF,IAA0BC,KAAF,IAAqB;AAC5C,MAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,WAAO,IAAP;AACA;;AAED,SAAO,cAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,CAPwB,EAQzB,aARyB,CAH3B;;AAcA,eAAeH,WAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { HigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Higher-order component creator, creating a new component which renders if\n * the given condition is satisfied or with the given optional prop name.\n *\n * @example\n * ```ts\n * type Props = { foo: string };\n * const Component = ( props: Props ) => <div>{ props.foo }</div>;\n * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );\n * <ConditionalComponent foo=\"\" />; // => null\n * <ConditionalComponent foo=\"bar\" />; // => <div>bar</div>;\n * ```\n *\n * @param predicate Function to test condition.\n *\n * @return Higher-order component.\n */\nconst ifCondition = < TProps, >(\n\tpredicate: ( props: TProps ) => boolean\n): HigherOrderComponent< TProps, TProps > =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props: TProps ) => {\n\t\t\tif ( ! predicate( props ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn <WrappedComponent { ...props } />;\n\t\t},\n\t\t'ifCondition'\n\t);\n\nexport default ifCondition;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["createHigherOrderComponent","ifCondition","predicate","WrappedComponent","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAChBC,SADmB,IAGnBF,0BAA0B,CACvBG,gBAAF,IAA0BC,KAAF,IAAqB;AAC5C,MAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,WAAO,IAAP;AACA;;AAED,SAAO,cAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,CAPwB,EAQzB,aARyB,CAH3B;;AAcA,eAAeH,WAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport type { HigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Higher-order component creator, creating a new component which renders if\n * the given condition is satisfied or with the given optional prop name.\n *\n * @example\n * ```ts\n * type Props = { foo: string };\n * const Component = ( props: Props ) => <div>{ props.foo }</div>;\n * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );\n * <ConditionalComponent foo=\"\" />; // => null\n * <ConditionalComponent foo=\"bar\" />; // => <div>bar</div>;\n * ```\n *\n * @param predicate Function to test condition.\n *\n * @return Higher-order component.\n */\nconst ifCondition = < TProps, >(\n\tpredicate: ( props: TProps ) => boolean\n): HigherOrderComponent< TProps, TProps > =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props: TProps ) => {\n\t\t\tif ( ! predicate( props ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn <WrappedComponent { ...props } />;\n\t\t},\n\t\t'ifCondition'\n\t);\n\nexport default ifCondition;\n"]}
@@ -9,7 +9,7 @@ import { Component } from '@wordpress/element';
9
9
  * Internal dependencies
10
10
  */
11
11
 
12
- import createHigherOrderComponent from '../../utils/create-higher-order-component'; // eslint-disable-next-line no-duplicate-imports
12
+ import createHigherOrderComponent from '../../utils/create-higher-order-component';
13
13
 
14
14
  /**
15
15
  * Given a component returns the enhanced component augmented with a component
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["isShallowEqual","Component","createHigherOrderComponent","pure","Wrapped","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,6BAA3B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC,C,CACA;;AASA;AACA;AACA;AACA;AACA,MAAMC,IAAgC,GAAGD,0BAA0B,CACrDE,OAAb,IAAmD;AAClD,MAAKA,OAAO,CAACC,SAAR,YAA6BJ,SAAlC,EAA8C;AAC7C,WAAO,cAAgBG,OAAhB,CAAsD;AAC5DE,MAAAA,qBAAqB,CAAEC,SAAF,EAAqBC,SAArB,EAAsC;AAC1D,eACC,CAAER,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAhB,IACA,CAAET,cAAc,CAAEQ,SAAF,EAAa,KAAKE,KAAlB,CAFjB;AAIA;;AAN2D,KAA7D;AAQA;;AAED,SAAO,cAAcT,SAAd,CAAkC;AACxCK,IAAAA,qBAAqB,CAAEC,SAAF,EAAsB;AAC1C,aAAO,CAAEP,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,cAAC,OAAD,EAAc,KAAKF,KAAnB,CAAP;AACA;;AAPuC,GAAzC;AASA,CAtBiE,EAuBlE,MAvBkE,CAAnE;AA0BA,eAAeN,IAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { SimpleHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only rerendering when its props/state change\n */\nconst pure: SimpleHigherOrderComponent = createHigherOrderComponent(\n\t< TProps, >( Wrapped: ComponentType< TProps > ) => {\n\t\tif ( Wrapped.prototype instanceof Component ) {\n\t\t\treturn class extends ( Wrapped as ComponentClass< TProps > ) {\n\t\t\t\tshouldComponentUpdate( nextProps: TProps, nextState: any ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\treturn class extends Component< TProps > {\n\t\t\tshouldComponentUpdate( nextProps: TProps ) {\n\t\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn <Wrapped { ...this.props } />;\n\t\t\t}\n\t\t};\n\t},\n\t'pure'\n);\n\nexport default pure;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["isShallowEqual","Component","createHigherOrderComponent","pure","Wrapped","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,6BAA3B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;;AASA;AACA;AACA;AACA;AACA,MAAMC,IAAgC,GAAGD,0BAA0B,CACrDE,OAAb,IAAmD;AAClD,MAAKA,OAAO,CAACC,SAAR,YAA6BJ,SAAlC,EAA8C;AAC7C,WAAO,cAAgBG,OAAhB,CAAsD;AAC5DE,MAAAA,qBAAqB,CAAEC,SAAF,EAAqBC,SAArB,EAAsC;AAC1D,eACC,CAAER,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAhB,IACA,CAAET,cAAc,CAAEQ,SAAF,EAAa,KAAKE,KAAlB,CAFjB;AAIA;;AAN2D,KAA7D;AAQA;;AAED,SAAO,cAAcT,SAAd,CAAkC;AACxCK,IAAAA,qBAAqB,CAAEC,SAAF,EAAsB;AAC1C,aAAO,CAAEP,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,cAAC,OAAD,EAAc,KAAKF,KAAnB,CAAP;AACA;;AAPuC,GAAzC;AASA,CAtBiE,EAuBlE,MAvBkE,CAAnE;AA0BA,eAAeN,IAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport type { SimpleHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only rerendering when its props/state change\n */\nconst pure: SimpleHigherOrderComponent = createHigherOrderComponent(\n\t< TProps, >( Wrapped: ComponentType< TProps > ) => {\n\t\tif ( Wrapped.prototype instanceof Component ) {\n\t\t\treturn class extends ( Wrapped as ComponentClass< TProps > ) {\n\t\t\t\tshouldComponentUpdate( nextProps: TProps, nextState: any ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\treturn class extends Component< TProps > {\n\t\t\tshouldComponentUpdate( nextProps: TProps ) {\n\t\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn <Wrapped { ...this.props } />;\n\t\t\t}\n\t\t};\n\t},\n\t'pure'\n);\n\nexport default pure;\n"]}
@@ -9,8 +9,7 @@ import { createElement } from "@wordpress/element";
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
- import createHigherOrderComponent from '../../utils/create-higher-order-component'; // eslint-disable-next-line no-duplicate-imports
13
-
12
+ import createHigherOrderComponent from '../../utils/create-higher-order-component';
14
13
  import useInstanceId from '../../hooks/use-instance-id';
15
14
  /**
16
15
  * A Higher Order Component used to be provide a unique instance ID by
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"names":["createHigherOrderComponent","useInstanceId","withInstanceId","WrappedComponent","props","instanceId"],"mappings":";;;AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC,C,CACA;;AAEA,OAAOC,aAAP,MAA0B,6BAA1B;AAEA;AACA;AACA;AACA;;AACA,MAAMC,cAEH,GAAGF,0BAA0B,CAE9BG,gBADD,IAEK;AACJ,SAASC,KAAF,IAA2C;AACjD,UAAMC,UAAU,GAAGJ,aAAa,CAAEE,gBAAF,CAAhC;AACA,WACC,cAAC,gBAAD,eACQC,KADR;AAEC,MAAA,UAAU,EAAGC;AAFd,OADD;AAMA,GARD;AASA,CAb8B,EAc/B,gBAd+B,CAFhC;AAmBA,eAAeH,cAAf","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { PropInjectingHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\n/**\n * A Higher Order Component used to be provide a unique instance ID by\n * component.\n */\nconst withInstanceId: PropInjectingHigherOrderComponent< {\n\tinstanceId: string | number;\n} > = createHigherOrderComponent(\n\t< TProps extends { instanceId: string | number } >(\n\t\tWrappedComponent: ComponentType< TProps >\n\t) => {\n\t\treturn ( props: Omit< TProps, 'instanceId' > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\treturn (\n\t\t\t\t<WrappedComponent\n\t\t\t\t\t{ ...( props as TProps ) }\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t/>\n\t\t\t);\n\t\t};\n\t},\n\t'withInstanceId'\n);\n\nexport default withInstanceId;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"names":["createHigherOrderComponent","useInstanceId","withInstanceId","WrappedComponent","props","instanceId"],"mappings":";;;AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC;AAEA,OAAOC,aAAP,MAA0B,6BAA1B;AAEA;AACA;AACA;AACA;;AACA,MAAMC,cAEH,GAAGF,0BAA0B,CAE9BG,gBADD,IAEK;AACJ,SAASC,KAAF,IAA2C;AACjD,UAAMC,UAAU,GAAGJ,aAAa,CAAEE,gBAAF,CAAhC;AACA,WACC,cAAC,gBAAD,eACQC,KADR;AAEC,MAAA,UAAU,EAAGC;AAFd,OADD;AAMA,GARD;AASA,CAb8B,EAc/B,gBAd+B,CAFhC;AAmBA,eAAeH,cAAf","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport type { PropInjectingHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\n/**\n * A Higher Order Component used to be provide a unique instance ID by\n * component.\n */\nconst withInstanceId: PropInjectingHigherOrderComponent< {\n\tinstanceId: string | number;\n} > = createHigherOrderComponent(\n\t< TProps extends { instanceId: string | number } >(\n\t\tWrappedComponent: ComponentType< TProps >\n\t) => {\n\t\treturn ( props: Omit< TProps, 'instanceId' > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\treturn (\n\t\t\t\t<WrappedComponent\n\t\t\t\t\t{ ...( props as TProps ) }\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t/>\n\t\t\t);\n\t\t};\n\t},\n\t'withInstanceId'\n);\n\nexport default withInstanceId;\n"]}
@@ -13,7 +13,7 @@ import { Component } from '@wordpress/element';
13
13
  * Internal dependencies
14
14
  */
15
15
 
16
- import createHigherOrderComponent from '../../utils/create-higher-order-component'; // eslint-disable-next-line no-duplicate-imports
16
+ import createHigherOrderComponent from '../../utils/create-higher-order-component';
17
17
 
18
18
  /**
19
19
  * A higher-order component used to provide and manage delayed function calls
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-safe-timeout/index.tsx"],"names":["without","Component","createHigherOrderComponent","withSafeTimeout","OriginalComponent","WrappedComponent","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id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AAO,cAAC,iBAAD,EAA0BJ,KAA1B,CAAP;AACA;;AAnCA,GAFF;AAuCA,CA3CmG,EA4CpG,iBA5CoG,CAArG;AA+CA,eAAeJ,eAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\n// eslint-disable-next-line no-duplicate-imports\nimport type { PropInjectingHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`\n * types here because those functions include functionality that is not handled\n * by this component, like the ability to pass extra arguments.\n *\n * In the case of this component, we only handle the simplest case where\n * `setTimeout` only accepts a function (not a string) and an optional delay.\n */\ntype TimeoutProps = {\n\tsetTimeout: ( fn: () => void, delay: number ) => number;\n\tclearTimeout: ( id: number ) => void;\n};\n\n/**\n * A higher-order component used to provide and manage delayed function calls\n * that ought to be bound to a component's lifecycle.\n */\nconst withSafeTimeout: PropInjectingHigherOrderComponent< TimeoutProps > = createHigherOrderComponent(\n\t< TProps extends TimeoutProps >(\n\t\tOriginalComponent: ComponentType< TProps >\n\t) => {\n\t\treturn class WrappedComponent extends Component<\n\t\t\tOmit< TProps, keyof TimeoutProps >\n\t\t> {\n\t\t\ttimeouts: number[];\n\n\t\t\tconstructor( props: any ) {\n\t\t\t\tsuper( props );\n\t\t\t\tthis.timeouts = [];\n\t\t\t\tthis.setTimeout = this.setTimeout.bind( this );\n\t\t\t\tthis.clearTimeout = this.clearTimeout.bind( this );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tthis.timeouts.forEach( clearTimeout );\n\t\t\t}\n\n\t\t\tsetTimeout( fn: ( ...args: any[] ) => void, delay: number ) {\n\t\t\t\tconst id = setTimeout( () => {\n\t\t\t\t\tfn();\n\t\t\t\t\tthis.clearTimeout( id );\n\t\t\t\t}, delay );\n\t\t\t\tthis.timeouts.push( id );\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tclearTimeout( id: number ) {\n\t\t\t\tclearTimeout( id );\n\t\t\t\tthis.timeouts = without( this.timeouts, id );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\tconst props = {\n\t\t\t\t\t...this.props,\n\t\t\t\t\tsetTimeout: this.setTimeout,\n\t\t\t\t\tclearTimeout: this.clearTimeout,\n\t\t\t\t};\n\t\t\t\treturn <OriginalComponent { ...( props as TProps ) } />;\n\t\t\t}\n\t\t};\n\t},\n\t'withSafeTimeout'\n);\n\nexport default withSafeTimeout;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-safe-timeout/index.tsx"],"names":["without","Component","createHigherOrderComponent","withSafeTimeout","OriginalComponent","WrappedComponent","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","render"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB,C,CACA;;AAGA;AACA;AACA;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;;AAgBA;AACA;AACA;AACA;AACA,MAAMC,eAAkE,GAAGD,0BAA0B,CAEnGE,iBADD,IAEK;AACJ,SAAO,MAAMC,gBAAN,SAA+BJ,SAA/B,CAEL;AAGDK,IAAAA,WAAW,CAAEC,KAAF,EAAe;AACzB,YAAOA,KAAP;AACA,WAAKC,QAAL,GAAgB,EAAhB;AACA,WAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAsB,IAAtB,CAAlB;AACA,WAAKC,YAAL,GAAoB,KAAKA,YAAL,CAAkBD,IAAlB,CAAwB,IAAxB,CAApB;AACA;;AAEDE,IAAAA,oBAAoB,GAAG;AACtB,WAAKJ,QAAL,CAAcK,OAAd,CAAuBF,YAAvB;AACA;;AAEDF,IAAAA,UAAU,CAAEK,EAAF,EAAkCC,KAAlC,EAAkD;AAC3D,YAAMC,EAAE,GAAGP,UAAU,CAAE,MAAM;AAC5BK,QAAAA,EAAE;AACF,aAAKH,YAAL,CAAmBK,EAAnB;AACA,OAHoB,EAGlBD,KAHkB,CAArB;AAIA,WAAKP,QAAL,CAAcS,IAAd,CAAoBD,EAApB;AACA,aAAOA,EAAP;AACA;;AAEDL,IAAAA,YAAY,CAAEK,EAAF,EAAe;AAC1BL,MAAAA,YAAY,CAAEK,EAAF,CAAZ;AACA,WAAKR,QAAL,GAAgBR,OAAO,CAAE,KAAKQ,QAAP,EAAiBQ,EAAjB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,YAAMX,KAAK,GAAG,EACb,GAAG,KAAKA,KADK;AAEbE,QAAAA,UAAU,EAAE,KAAKA,UAFJ;AAGbE,QAAAA,YAAY,EAAE,KAAKA;AAHN,OAAd;AAKA,aAAO,cAAC,iBAAD,EAA0BJ,KAA1B,CAAP;AACA;;AAnCA,GAFF;AAuCA,CA3CmG,EA4CpG,iBA5CoG,CAArG;AA+CA,eAAeJ,eAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport type { PropInjectingHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`\n * types here because those functions include functionality that is not handled\n * by this component, like the ability to pass extra arguments.\n *\n * In the case of this component, we only handle the simplest case where\n * `setTimeout` only accepts a function (not a string) and an optional delay.\n */\ntype TimeoutProps = {\n\tsetTimeout: ( fn: () => void, delay: number ) => number;\n\tclearTimeout: ( id: number ) => void;\n};\n\n/**\n * A higher-order component used to provide and manage delayed function calls\n * that ought to be bound to a component's lifecycle.\n */\nconst withSafeTimeout: PropInjectingHigherOrderComponent< TimeoutProps > = createHigherOrderComponent(\n\t< TProps extends TimeoutProps >(\n\t\tOriginalComponent: ComponentType< TProps >\n\t) => {\n\t\treturn class WrappedComponent extends Component<\n\t\t\tOmit< TProps, keyof TimeoutProps >\n\t\t> {\n\t\t\ttimeouts: number[];\n\n\t\t\tconstructor( props: any ) {\n\t\t\t\tsuper( props );\n\t\t\t\tthis.timeouts = [];\n\t\t\t\tthis.setTimeout = this.setTimeout.bind( this );\n\t\t\t\tthis.clearTimeout = this.clearTimeout.bind( this );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tthis.timeouts.forEach( clearTimeout );\n\t\t\t}\n\n\t\t\tsetTimeout( fn: ( ...args: any[] ) => void, delay: number ) {\n\t\t\t\tconst id = setTimeout( () => {\n\t\t\t\t\tfn();\n\t\t\t\t\tthis.clearTimeout( id );\n\t\t\t\t}, delay );\n\t\t\t\tthis.timeouts.push( id );\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tclearTimeout( id: number ) {\n\t\t\t\tclearTimeout( id );\n\t\t\t\tthis.timeouts = without( this.timeouts, id );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\tconst props = {\n\t\t\t\t\t...this.props,\n\t\t\t\t\tsetTimeout: this.setTimeout,\n\t\t\t\t\tclearTimeout: this.clearTimeout,\n\t\t\t\t};\n\t\t\t\treturn <OriginalComponent { ...( props as TProps ) } />;\n\t\t\t}\n\t\t};\n\t},\n\t'withSafeTimeout'\n);\n\nexport default withSafeTimeout;\n"]}
@@ -3,7 +3,11 @@
3
3
  */
4
4
  import { TAB } from '@wordpress/keycodes';
5
5
  import { focus } from '@wordpress/dom';
6
- import { useCallback } from '@wordpress/element';
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+
10
+ import useRefEffect from '../use-ref-effect';
7
11
  /**
8
12
  * In Dialogs/modals, the tabbing must be constrained to the content of
9
13
  * the wrapper element. This hook adds the behavior to the returned ref.
@@ -27,58 +31,55 @@ import { useCallback } from '@wordpress/element';
27
31
  */
28
32
 
29
33
  function useConstrainedTabbing() {
30
- const ref = useCallback(
31
- /** @type {Element} */
34
+ return useRefEffect(
35
+ /** @type {HTMLElement} */
32
36
  node => {
33
- if (!node) {
34
- return;
35
- }
37
+ /** @type {number|undefined} */
38
+ let timeoutId;
36
39
 
37
- node.addEventListener('keydown',
38
- /** @type {Event} */
39
- event => {
40
- if (!(event instanceof window.KeyboardEvent)) {
41
- return;
42
- }
40
+ function onKeyDown(
41
+ /** @type {KeyboardEvent} */
42
+ event) {
43
+ const {
44
+ keyCode,
45
+ shiftKey,
46
+ target
47
+ } = event;
43
48
 
44
- if (event.keyCode !== TAB) {
49
+ if (keyCode !== TAB) {
45
50
  return;
46
51
  }
47
52
 
48
- const tabbables = focus.tabbable.find(node);
53
+ const action = shiftKey ? 'findPrevious' : 'findNext';
54
+ const nextElement = focus.tabbable[action](
55
+ /** @type {HTMLElement} */
56
+ target) || null; // If the element that is about to receive focus is outside the
57
+ // area, move focus to a div and insert it at the start or end of
58
+ // the area, depending on the direction. Without preventing default
59
+ // behaviour, the browser will then move focus to the next element.
49
60
 
50
- if (!tabbables.length) {
61
+ if (node.contains(nextElement)) {
51
62
  return;
52
63
  }
53
64
 
54
- const firstTabbable = tabbables[0];
55
- const lastTabbable = tabbables[tabbables.length - 1];
56
-
57
- if (event.shiftKey && event.target === firstTabbable) {
58
- event.preventDefault();
59
- /** @type {HTMLElement} */
60
-
61
- lastTabbable.focus();
62
- } else if (!event.shiftKey && event.target === lastTabbable) {
63
- event.preventDefault();
64
- /** @type {HTMLElement} */
65
+ const domAction = shiftKey ? 'append' : 'prepend';
66
+ const {
67
+ ownerDocument
68
+ } = node;
69
+ const trap = ownerDocument.createElement('div');
70
+ trap.tabIndex = -1;
71
+ node[domAction](trap);
72
+ trap.focus(); // Remove after the browser moves focus to the next element.
65
73
 
66
- firstTabbable.focus();
67
- /*
68
- * When pressing Tab and none of the tabbables has focus, the keydown
69
- * event happens on the wrapper div: move focus on the first tabbable.
70
- */
71
- } else if (!tabbables.includes(
72
- /** @type {Element} */
73
- event.target)) {
74
- event.preventDefault();
75
- /** @type {HTMLElement} */
74
+ timeoutId = setTimeout(() => node.removeChild(trap));
75
+ }
76
76
 
77
- firstTabbable.focus();
78
- }
79
- });
77
+ node.addEventListener('keydown', onKeyDown);
78
+ return () => {
79
+ node.removeEventListener('keydown', onKeyDown);
80
+ clearTimeout(timeoutId);
81
+ };
80
82
  }, []);
81
- return ref;
82
83
  }
83
84
 
84
85
  export default useConstrainedTabbing;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-constrained-tabbing/index.js"],"names":["TAB","focus","useCallback","useConstrainedTabbing","ref","node","addEventListener","event","window","KeyboardEvent","keyCode","tabbables","tabbable","find","length","firstTabbable","lastTabbable","shiftKey","target","preventDefault","includes"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,qBAApB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,qBAAT,GAAiC;AAChC,QAAMC,GAAG,GAAGF,WAAW;AAAI;AAAuBG,EAAAA,IAAzB,IAAmC;AAC3D,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AACDA,IAAAA,IAAI,CAACC,gBAAL,CAAuB,SAAvB;AAAoC;AAAqBC,IAAAA,KAAvB,IAAkC;AACnE,UAAK,EAAIA,KAAK,YAAYC,MAAM,CAACC,aAA5B,CAAL,EAAmD;AAClD;AACA;;AAED,UAAKF,KAAK,CAACG,OAAN,KAAkBV,GAAvB,EAA6B;AAC5B;AACA;;AAED,YAAMW,SAAS,GAAGV,KAAK,CAACW,QAAN,CAAeC,IAAf,CAAqBR,IAArB,CAAlB;;AACA,UAAK,CAAEM,SAAS,CAACG,MAAjB,EAA0B;AACzB;AACA;;AACD,YAAMC,aAAa,GAAGJ,SAAS,CAAE,CAAF,CAA/B;AACA,YAAMK,YAAY,GAAGL,SAAS,CAAEA,SAAS,CAACG,MAAV,GAAmB,CAArB,CAA9B;;AAEA,UAAKP,KAAK,CAACU,QAAN,IAAkBV,KAAK,CAACW,MAAN,KAAiBH,aAAxC,EAAwD;AACvDR,QAAAA,KAAK,CAACY,cAAN;AACA;;AAA6BH,QAAAA,YAAF,CAAiBf,KAAjB;AAC3B,OAHD,MAGO,IAAK,CAAEM,KAAK,CAACU,QAAR,IAAoBV,KAAK,CAACW,MAAN,KAAiBF,YAA1C,EAAyD;AAC/DT,QAAAA,KAAK,CAACY,cAAN;AACA;;AAA6BJ,QAAAA,aAAF,CAAkBd,KAAlB;AAC3B;AACJ;AACA;AACA;AACI,OAPM,MAOA,IACN,CAAEU,SAAS,CAACS,QAAV;AAAoB;AAAyBb,MAAAA,KAAK,CAACW,MAAnD,CADI,EAEL;AACDX,QAAAA,KAAK,CAACY,cAAN;AACA;;AAA6BJ,QAAAA,aAAF,CAAkBd,KAAlB;AAC3B;AACD,KAhCD;AAiCA,GArCsB,EAqCpB,EArCoB,CAAvB;AAuCA,SAAOG,GAAP;AACA;;AAED,eAAeD,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { TAB } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * In Dialogs/modals, the tabbing must be constrained to the content of\n * the wrapper element. This hook adds the behavior to the returned ref.\n *\n * @return {import('react').RefCallback<Element>} Element Ref.\n *\n * @example\n * ```js\n * import { useConstrainedTabbing } from '@wordpress/compose';\n *\n * const ConstrainedTabbingExample = () => {\n * const constrainedTabbingRef = useConstrainedTabbing()\n * return (\n * <div ref={ constrainedTabbingRef }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nfunction useConstrainedTabbing() {\n\tconst ref = useCallback( ( /** @type {Element} */ node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\t\tnode.addEventListener( 'keydown', ( /** @type {Event} */ event ) => {\n\t\t\tif ( ! ( event instanceof window.KeyboardEvent ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst tabbables = focus.tabbable.find( node );\n\t\t\tif ( ! tabbables.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst firstTabbable = tabbables[ 0 ];\n\t\t\tconst lastTabbable = tabbables[ tabbables.length - 1 ];\n\n\t\t\tif ( event.shiftKey && event.target === firstTabbable ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t/** @type {HTMLElement} */ ( lastTabbable ).focus();\n\t\t\t} else if ( ! event.shiftKey && event.target === lastTabbable ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t/** @type {HTMLElement} */ ( firstTabbable ).focus();\n\t\t\t\t/*\n\t\t\t\t * When pressing Tab and none of the tabbables has focus, the keydown\n\t\t\t\t * event happens on the wrapper div: move focus on the first tabbable.\n\t\t\t\t */\n\t\t\t} else if (\n\t\t\t\t! tabbables.includes( /** @type {Element} */ ( event.target ) )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t/** @type {HTMLElement} */ ( firstTabbable ).focus();\n\t\t\t}\n\t\t} );\n\t}, [] );\n\n\treturn ref;\n}\n\nexport default useConstrainedTabbing;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-constrained-tabbing/index.js"],"names":["TAB","focus","useRefEffect","useConstrainedTabbing","node","timeoutId","onKeyDown","event","keyCode","shiftKey","target","action","nextElement","tabbable","contains","domAction","ownerDocument","trap","createElement","tabIndex","setTimeout","removeChild","addEventListener","removeEventListener","clearTimeout"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,qBAApB;A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kChB,SAAlC;AACA,WAAO,MAAM;AACZF,MAAAA,IAAI,CAACmB,mBAAL,CAA0B,SAA1B,EAAqCjB,SAArC;AACAkB,MAAAA,YAAY,CAAEnB,SAAF,CAAZ;AACA,KAHD;AAIA,GAzCkB,EAyChB,EAzCgB,CAAnB;AA0CA;;AAED,eAAeF,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { TAB } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * In Dialogs/modals, the tabbing must be constrained to the content of\n * the wrapper element. This hook adds the behavior to the returned ref.\n *\n * @return {import('react').RefCallback<Element>} Element Ref.\n *\n * @example\n * ```js\n * import { useConstrainedTabbing } from '@wordpress/compose';\n *\n * const ConstrainedTabbingExample = () => {\n * const constrainedTabbingRef = useConstrainedTabbing()\n * return (\n * <div ref={ constrainedTabbingRef }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nfunction useConstrainedTabbing() {\n\treturn useRefEffect( ( /** @type {HTMLElement} */ node ) => {\n\t\t/** @type {number|undefined} */\n\t\tlet timeoutId;\n\n\t\tfunction onKeyDown( /** @type {KeyboardEvent} */ event ) {\n\t\t\tconst { keyCode, shiftKey, target } = event;\n\n\t\t\tif ( keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst action = shiftKey ? 'findPrevious' : 'findNext';\n\t\t\tconst nextElement =\n\t\t\t\tfocus.tabbable[ action ](\n\t\t\t\t\t/** @type {HTMLElement} */ ( target )\n\t\t\t\t) || null;\n\n\t\t\t// If the element that is about to receive focus is outside the\n\t\t\t// area, move focus to a div and insert it at the start or end of\n\t\t\t// the area, depending on the direction. Without preventing default\n\t\t\t// behaviour, the browser will then move focus to the next element.\n\t\t\tif ( node.contains( nextElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst domAction = shiftKey ? 'append' : 'prepend';\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst trap = ownerDocument.createElement( 'div' );\n\n\t\t\ttrap.tabIndex = -1;\n\t\t\tnode[ domAction ]( trap );\n\t\t\ttrap.focus();\n\t\t\t// Remove after the browser moves focus to the next element.\n\t\t\ttimeoutId = setTimeout( () => node.removeChild( trap ) );\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tclearTimeout( timeoutId );\n\t\t};\n\t}, [] );\n}\n\nexport default useConstrainedTabbing;\n"]}
@@ -23,7 +23,7 @@ import { useEffect } from '@wordpress/element';
23
23
  * @param {TFunc} fn The function to debounce.
24
24
  * @param {number} [wait] The number of milliseconds to delay.
25
25
  * @param {import('lodash').DebounceSettings} [options] The options object.
26
- * @return {TFunc & import('lodash').Cancelable} Debounced function.
26
+ * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.
27
27
  */
28
28
 
29
29
  export default function useDebounce(fn, wait, options) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"names":["debounce","useMemoOne","useEffect","useDebounce","fn","wait","options","debounced","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD;AACA,QAAMC,SAAS,GAAGN,UAAU,CAAE,MAAMD,QAAQ,CAAEI,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAAhB,EAAuC,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAvC,CAA5B;AAKAJ,EAAAA,SAAS,CAAE,MAAM,MAAMK,SAAS,CAACC,MAAV,EAAd,EAAkC,CAAED,SAAF,CAAlC,CAAT;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Debounces a function with Lodash's `debounce`. A new debounced function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to debounce, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/debounce/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to debounce.\n * @param {number} [wait] The number of milliseconds to delay.\n * @param {import('lodash').DebounceSettings} [options] The options object.\n * @return {TFunc & import('lodash').Cancelable} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst debounced = useMemoOne( () => debounce( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"names":["debounce","useMemoOne","useEffect","useDebounce","fn","wait","options","debounced","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD;AACA,QAAMC,SAAS,GAAGN,UAAU,CAAE,MAAMD,QAAQ,CAAEI,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAAhB,EAAuC,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAvC,CAA5B;AAKAJ,EAAAA,SAAS,CAAE,MAAM,MAAMK,SAAS,CAACC,MAAV,EAAd,EAAkC,CAAED,SAAF,CAAlC,CAAT;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Debounces a function with Lodash's `debounce`. A new debounced function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to debounce, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/debounce/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to debounce.\n * @param {number} [wait] The number of milliseconds to delay.\n * @param {import('lodash').DebounceSettings} [options] The options object.\n * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst debounced = useMemoOne( () => debounce( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"]}
@@ -76,15 +76,23 @@ export default function useDropZone({
76
76
  /**
77
77
  * Checks if an element is in the drop zone.
78
78
  *
79
- * @param {HTMLElement|null} elementToCheck
79
+ * @param {EventTarget|null} targetToCheck
80
80
  *
81
81
  * @return {boolean} True if in drop zone, false if not.
82
82
  */
83
83
 
84
- function isElementInZone(elementToCheck) {
85
- if (!elementToCheck || !element.contains(elementToCheck)) {
84
+ function isElementInZone(targetToCheck) {
85
+ const {
86
+ defaultView
87
+ } = ownerDocument;
88
+
89
+ if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) {
86
90
  return false;
87
91
  }
92
+ /** @type {HTMLElement|null} */
93
+
94
+
95
+ let elementToCheck = targetToCheck;
88
96
 
89
97
  do {
90
98
  if (elementToCheck.dataset.isDropZone) {
@@ -156,9 +164,7 @@ export default function useDropZone({
156
164
  // leaving the drop zone, which means the `relatedTarget`
157
165
  // (element that has been entered) should be outside the drop
158
166
  // zone.
159
- if (isElementInZone(
160
- /** @type {HTMLElement|null} */
161
- event.relatedTarget)) {
167
+ if (isElementInZone(event.relatedTarget)) {
162
168
  return;
163
169
  }
164
170
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-drop-zone/index.js"],"names":["useRef","useRefEffect","useFreshRef","value","ref","current","useDropZone","isDisabled","onDrop","_onDrop","onDragStart","_onDragStart","onDragEnter","_onDragEnter","onDragLeave","_onDragLeave","onDragEnd","_onDragEnd","onDragOver","_onDragOver","onDropRef","onDragStartRef","onDragEnterRef","onDragLeaveRef","onDragEndRef","onDragOverRef","element","isDragging","ownerDocument","isElementInZone","elementToCheck","contains","dataset","isDropZone","parentElement","maybeDragStart","event","removeEventListener","addEventListener","maybeDragEnd","preventDefault","relatedTarget","defaultPrevented","dataTransfer","files","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B;;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAMC,GAAG,GAAGJ,MAAM,EAAlB;AACAI,EAAAA,GAAG,CAACC,OAAJ,GAAcF,KAAd;AACA,SAAOC,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASE,WAAT,CAAsB;AACpCC,EAAAA,UADoC;AAEpCC,EAAAA,MAAM,EAAEC,OAF4B;AA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AAAA,OAAO,CAACW,mBAAR,CAA6B,WAA7B,EAA0CzB,WAA1C;AACAc,MAAAA,OAAO,CAACW,mBAAR,CAA6B,UAA7B,EAAyCnB,UAAzC;AACAQ,MAAAA,OAAO,CAACW,mBAAR,CAA6B,WAA7B,EAA0CvB,WAA1C;AACAc,MAAAA,aAAa,CAACS,mBAAd,CAAmC,SAAnC,EAA8CE,YAA9C;AACAX,MAAAA,aAAa,CAACS,mBAAd,CAAmC,WAAnC,EAAgDE,YAAhD;AACAX,MAAAA,aAAa,CAACU,gBAAd,CAAgC,WAAhC,EAA6CH,cAA7C;AACA,KATD;AAUA,GAtKiB,EAuKlB,CAAE5B,UAAF,CAvKkB,CAAnB;AAyKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @template T\n * @param {T} value\n * @return {import('react').MutableRefObject<T>} A ref with the value.\n */\nfunction useFreshRef( value ) {\n\t/* eslint-enable jsdoc/valid-types */\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {import('react').MutableRefObject<T>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\t// Disable reason: We're doing something pretty JavaScript-y here where the\n\t// ref will always have a current value that is not null or undefined but it\n\t// needs to start as undefined. We don't want to change the return type so\n\t// it's easier to just ts-ignore this specific line that's complaining about\n\t// undefined not being part of T.\n\t// @ts-ignore\n\tconst ref = useRef();\n\tref.current = value;\n\treturn ref;\n}\n\n/**\n * A hook to facilitate drag and drop handling.\n *\n * @param {Object} props Named parameters.\n * @param {boolean} props.isDisabled Whether or not to disable the drop zone.\n * @param {(e: DragEvent) => void} props.onDragStart Called when dragging has started.\n * @param {(e: DragEvent) => void} props.onDragEnter Called when the zone is entered.\n * @param {(e: DragEvent) => void} props.onDragOver Called when the zone is moved within.\n * @param {(e: DragEvent) => void} props.onDragLeave Called when the zone is left.\n * @param {(e: MouseEvent) => void} props.onDragEnd Called when dragging has ended.\n * @param {(e: DragEvent) => void} props.onDrop Called when dropping in the zone.\n *\n * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element.\n */\nexport default function useDropZone( {\n\tisDisabled,\n\tonDrop: _onDrop,\n\tonDragStart: _onDragStart,\n\tonDragEnter: _onDragEnter,\n\tonDragLeave: _onDragLeave,\n\tonDragEnd: _onDragEnd,\n\tonDragOver: _onDragOver,\n} ) {\n\tconst onDropRef = useFreshRef( _onDrop );\n\tconst onDragStartRef = useFreshRef( _onDragStart );\n\tconst onDragEnterRef = useFreshRef( _onDragEnter );\n\tconst onDragLeaveRef = useFreshRef( _onDragLeave );\n\tconst onDragEndRef = useFreshRef( _onDragEnd );\n\tconst onDragOverRef = useFreshRef( _onDragOver );\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tif ( isDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet isDragging = false;\n\n\t\t\tconst { ownerDocument } = element;\n\n\t\t\t/**\n\t\t\t * Checks if an element is in the drop zone.\n\t\t\t *\n\t\t\t * @param {HTMLElement|null} elementToCheck\n\t\t\t *\n\t\t\t * @return {boolean} True if in drop zone, false if not.\n\t\t\t */\n\t\t\tfunction isElementInZone( elementToCheck ) {\n\t\t\t\tif (\n\t\t\t\t\t! elementToCheck ||\n\t\t\t\t\t! element.contains( elementToCheck )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tdo {\n\t\t\t\t\tif ( elementToCheck.dataset.isDropZone ) {\n\t\t\t\t\t\treturn elementToCheck === element;\n\t\t\t\t\t}\n\t\t\t\t} while ( ( elementToCheck = elementToCheck.parentElement ) );\n\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tfunction maybeDragStart( /** @type {DragEvent} */ event ) {\n\t\t\t\tif ( isDragging ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tisDragging = true;\n\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'dragenter',\n\t\t\t\t\tmaybeDragStart\n\t\t\t\t);\n\n\t\t\t\t// Note that `dragend` doesn't fire consistently for file and\n\t\t\t\t// HTML drag events where the drag origin is outside the browser\n\t\t\t\t// window. In Firefox it may also not fire if the originating\n\t\t\t\t// node is removed.\n\t\t\t\townerDocument.addEventListener( 'dragend', maybeDragEnd );\n\t\t\t\townerDocument.addEventListener( 'mousemove', maybeDragEnd );\n\n\t\t\t\tif ( onDragStartRef.current ) {\n\t\t\t\t\tonDragStartRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onDragEnter( /** @type {DragEvent} */ event ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// The `dragenter` event will also fire when entering child\n\t\t\t\t// elements, but we only want to call `onDragEnter` when\n\t\t\t\t// entering the drop zone, which means the `relatedTarget`\n\t\t\t\t// (element that has been left) should be outside the drop zone.\n\t\t\t\tif (\n\t\t\t\t\telement.contains(\n\t\t\t\t\t\t/** @type {Node} */ ( event.relatedTarget )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( onDragEnterRef.current ) {\n\t\t\t\t\tonDragEnterRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onDragOver( /** @type {DragEvent} */ event ) {\n\t\t\t\t// Only call onDragOver for the innermost hovered drop zones.\n\t\t\t\tif ( ! event.defaultPrevented && onDragOverRef.current ) {\n\t\t\t\t\tonDragOverRef.current( event );\n\t\t\t\t}\n\n\t\t\t\t// Prevent the browser default while also signalling to parent\n\t\t\t\t// drop zones that `onDragOver` is already handled.\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\n\t\t\tfunction onDragLeave( /** @type {DragEvent} */ event ) {\n\t\t\t\t// The `dragleave` event will also fire when leaving child\n\t\t\t\t// elements, but we only want to call `onDragLeave` when\n\t\t\t\t// leaving the drop zone, which means the `relatedTarget`\n\t\t\t\t// (element that has been entered) should be outside the drop\n\t\t\t\t// zone.\n\t\t\t\tif (\n\t\t\t\t\tisElementInZone(\n\t\t\t\t\t\t/** @type {HTMLElement|null} */ ( event.relatedTarget )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( onDragLeaveRef.current ) {\n\t\t\t\t\tonDragLeaveRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onDrop( /** @type {DragEvent} */ event ) {\n\t\t\t\t// Don't handle drop if an inner drop zone already handled it.\n\t\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Prevent the browser default while also signalling to parent\n\t\t\t\t// drop zones that `onDrop` is already handled.\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// This seemingly useless line has been shown to resolve a\n\t\t\t\t// Safari issue where files dragged directly from the dock are\n\t\t\t\t// not recognized.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tevent.dataTransfer && event.dataTransfer.files.length;\n\n\t\t\t\tif ( onDropRef.current ) {\n\t\t\t\t\tonDropRef.current( event );\n\t\t\t\t}\n\n\t\t\t\tmaybeDragEnd( event );\n\t\t\t}\n\n\t\t\tfunction maybeDragEnd( /** @type {MouseEvent} */ event ) {\n\t\t\t\tif ( ! isDragging ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tisDragging = false;\n\n\t\t\t\townerDocument.addEventListener( 'dragenter', maybeDragStart );\n\t\t\t\townerDocument.removeEventListener( 'dragend', maybeDragEnd );\n\t\t\t\townerDocument.removeEventListener( 'mousemove', maybeDragEnd );\n\n\t\t\t\tif ( onDragEndRef.current ) {\n\t\t\t\t\tonDragEndRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\telement.dataset.isDropZone = 'true';\n\t\t\telement.addEventListener( 'drop', onDrop );\n\t\t\telement.addEventListener( 'dragenter', onDragEnter );\n\t\t\telement.addEventListener( 'dragover', onDragOver );\n\t\t\telement.addEventListener( 'dragleave', onDragLeave );\n\t\t\t// The `dragstart` event doesn't fire if the drag started outside\n\t\t\t// the document.\n\t\t\townerDocument.addEventListener( 'dragenter', maybeDragStart );\n\n\t\t\treturn () => {\n\t\t\t\tdelete element.dataset.isDropZone;\n\t\t\t\telement.removeEventListener( 'drop', onDrop );\n\t\t\t\telement.removeEventListener( 'dragenter', onDragEnter );\n\t\t\t\telement.removeEventListener( 'dragover', onDragOver );\n\t\t\t\telement.removeEventListener( 'dragleave', onDragLeave );\n\t\t\t\townerDocument.removeEventListener( 'dragend', maybeDragEnd );\n\t\t\t\townerDocument.removeEventListener( 'mousemove', maybeDragEnd );\n\t\t\t\townerDocument.addEventListener( 'dragenter', maybeDragStart );\n\t\t\t};\n\t\t},\n\t\t[ isDisabled ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-drop-zone/index.js"],"names":["useRef","useRefEffect","useFreshRef","value","ref","current","useDropZone","isDisabled","onDrop","_onDrop","onDragStart","_onDragStart","onDragEnter","_onDragEnter","onDragLeave","_onDragLeave","onDragEnd","_onDragEnd","onDragOver","_onDragOver","onDropRef","onDragStartRef","onDragEnterRef","onDragLeaveRef","onDragEndRef","onDragOverRef","element","isDragging","ownerDocument","isElementInZone","targetToCheck","defaultView","HTMLElement","contains","elementToCheck","dataset","isDropZone","parentElement","maybeDragStart","event","removeEventListener","addEventListener","maybeDragEnd","preventDefault","relatedTarget","defaultPrevented","dataTransfer","files","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B;;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAMC,GAAG,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,OAAO,CAACe,gBAAR,CAA0B,WAA1B,EAAuC7B,WAAvC;AACAc,IAAAA,OAAO,CAACe,gBAAR,CAA0B,UAA1B,EAAsCvB,UAAtC;AACAQ,IAAAA,OAAO,CAACe,gBAAR,CAA0B,WAA1B,EAAuC3B,WAAvC,EAxJc,CAyJd;AACA;;AACAc,IAAAA,aAAa,CAACa,gBAAd,CAAgC,WAAhC,EAA6CH,cAA7C;AAEA,WAAO,MAAM;AACZ,aAAOZ,OAAO,CAACS,OAAR,CAAgBC,UAAvB;AACAV,MAAAA,OAAO,CAACc,mBAAR,CAA6B,MAA7B,EAAqChC,MAArC;AACAkB,MAAAA,OAAO,CAACc,mBAAR,CAA6B,WAA7B,EAA0C5B,WAA1C;AACAc,MAAAA,OAAO,CAACc,mBAAR,CAA6B,UAA7B,EAAyCtB,UAAzC;AACAQ,MAAAA,OAAO,CAACc,mBAAR,CAA6B,WAA7B,EAA0C1B,WAA1C;AACAc,MAAAA,aAAa,CAACY,mBAAd,CAAmC,SAAnC,EAA8CE,YAA9C;AACAd,MAAAA,aAAa,CAACY,mBAAd,CAAmC,WAAnC,EAAgDE,YAAhD;AACAd,MAAAA,aAAa,CAACa,gBAAd,CAAgC,WAAhC,EAA6CH,cAA7C;AACA,KATD;AAUA,GAxKiB,EAyKlB,CAAE/B,UAAF,CAzKkB,CAAnB;AA2KA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @template T\n * @param {T} value\n * @return {import('react').MutableRefObject<T>} A ref with the value.\n */\nfunction useFreshRef( value ) {\n\t/* eslint-enable jsdoc/valid-types */\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {import('react').MutableRefObject<T>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\t// Disable reason: We're doing something pretty JavaScript-y here where the\n\t// ref will always have a current value that is not null or undefined but it\n\t// needs to start as undefined. We don't want to change the return type so\n\t// it's easier to just ts-ignore this specific line that's complaining about\n\t// undefined not being part of T.\n\t// @ts-ignore\n\tconst ref = useRef();\n\tref.current = value;\n\treturn ref;\n}\n\n/**\n * A hook to facilitate drag and drop handling.\n *\n * @param {Object} props Named parameters.\n * @param {boolean} props.isDisabled Whether or not to disable the drop zone.\n * @param {(e: DragEvent) => void} props.onDragStart Called when dragging has started.\n * @param {(e: DragEvent) => void} props.onDragEnter Called when the zone is entered.\n * @param {(e: DragEvent) => void} props.onDragOver Called when the zone is moved within.\n * @param {(e: DragEvent) => void} props.onDragLeave Called when the zone is left.\n * @param {(e: MouseEvent) => void} props.onDragEnd Called when dragging has ended.\n * @param {(e: DragEvent) => void} props.onDrop Called when dropping in the zone.\n *\n * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element.\n */\nexport default function useDropZone( {\n\tisDisabled,\n\tonDrop: _onDrop,\n\tonDragStart: _onDragStart,\n\tonDragEnter: _onDragEnter,\n\tonDragLeave: _onDragLeave,\n\tonDragEnd: _onDragEnd,\n\tonDragOver: _onDragOver,\n} ) {\n\tconst onDropRef = useFreshRef( _onDrop );\n\tconst onDragStartRef = useFreshRef( _onDragStart );\n\tconst onDragEnterRef = useFreshRef( _onDragEnter );\n\tconst onDragLeaveRef = useFreshRef( _onDragLeave );\n\tconst onDragEndRef = useFreshRef( _onDragEnd );\n\tconst onDragOverRef = useFreshRef( _onDragOver );\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tif ( isDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet isDragging = false;\n\n\t\t\tconst { ownerDocument } = element;\n\n\t\t\t/**\n\t\t\t * Checks if an element is in the drop zone.\n\t\t\t *\n\t\t\t * @param {EventTarget|null} targetToCheck\n\t\t\t *\n\t\t\t * @return {boolean} True if in drop zone, false if not.\n\t\t\t */\n\t\t\tfunction isElementInZone( targetToCheck ) {\n\t\t\t\tconst { defaultView } = ownerDocument;\n\t\t\t\tif (\n\t\t\t\t\t! targetToCheck ||\n\t\t\t\t\t! defaultView ||\n\t\t\t\t\t! ( targetToCheck instanceof defaultView.HTMLElement ) ||\n\t\t\t\t\t! element.contains( targetToCheck )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\t/** @type {HTMLElement|null} */\n\t\t\t\tlet elementToCheck = targetToCheck;\n\n\t\t\t\tdo {\n\t\t\t\t\tif ( elementToCheck.dataset.isDropZone ) {\n\t\t\t\t\t\treturn elementToCheck === element;\n\t\t\t\t\t}\n\t\t\t\t} while ( ( elementToCheck = elementToCheck.parentElement ) );\n\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tfunction maybeDragStart( /** @type {DragEvent} */ event ) {\n\t\t\t\tif ( isDragging ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tisDragging = true;\n\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'dragenter',\n\t\t\t\t\tmaybeDragStart\n\t\t\t\t);\n\n\t\t\t\t// Note that `dragend` doesn't fire consistently for file and\n\t\t\t\t// HTML drag events where the drag origin is outside the browser\n\t\t\t\t// window. In Firefox it may also not fire if the originating\n\t\t\t\t// node is removed.\n\t\t\t\townerDocument.addEventListener( 'dragend', maybeDragEnd );\n\t\t\t\townerDocument.addEventListener( 'mousemove', maybeDragEnd );\n\n\t\t\t\tif ( onDragStartRef.current ) {\n\t\t\t\t\tonDragStartRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onDragEnter( /** @type {DragEvent} */ event ) {\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// The `dragenter` event will also fire when entering child\n\t\t\t\t// elements, but we only want to call `onDragEnter` when\n\t\t\t\t// entering the drop zone, which means the `relatedTarget`\n\t\t\t\t// (element that has been left) should be outside the drop zone.\n\t\t\t\tif (\n\t\t\t\t\telement.contains(\n\t\t\t\t\t\t/** @type {Node} */ ( event.relatedTarget )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( onDragEnterRef.current ) {\n\t\t\t\t\tonDragEnterRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onDragOver( /** @type {DragEvent} */ event ) {\n\t\t\t\t// Only call onDragOver for the innermost hovered drop zones.\n\t\t\t\tif ( ! event.defaultPrevented && onDragOverRef.current ) {\n\t\t\t\t\tonDragOverRef.current( event );\n\t\t\t\t}\n\n\t\t\t\t// Prevent the browser default while also signalling to parent\n\t\t\t\t// drop zones that `onDragOver` is already handled.\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\n\t\t\tfunction onDragLeave( /** @type {DragEvent} */ event ) {\n\t\t\t\t// The `dragleave` event will also fire when leaving child\n\t\t\t\t// elements, but we only want to call `onDragLeave` when\n\t\t\t\t// leaving the drop zone, which means the `relatedTarget`\n\t\t\t\t// (element that has been entered) should be outside the drop\n\t\t\t\t// zone.\n\t\t\t\tif ( isElementInZone( event.relatedTarget ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( onDragLeaveRef.current ) {\n\t\t\t\t\tonDragLeaveRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction onDrop( /** @type {DragEvent} */ event ) {\n\t\t\t\t// Don't handle drop if an inner drop zone already handled it.\n\t\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Prevent the browser default while also signalling to parent\n\t\t\t\t// drop zones that `onDrop` is already handled.\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\t// This seemingly useless line has been shown to resolve a\n\t\t\t\t// Safari issue where files dragged directly from the dock are\n\t\t\t\t// not recognized.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tevent.dataTransfer && event.dataTransfer.files.length;\n\n\t\t\t\tif ( onDropRef.current ) {\n\t\t\t\t\tonDropRef.current( event );\n\t\t\t\t}\n\n\t\t\t\tmaybeDragEnd( event );\n\t\t\t}\n\n\t\t\tfunction maybeDragEnd( /** @type {MouseEvent} */ event ) {\n\t\t\t\tif ( ! isDragging ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tisDragging = false;\n\n\t\t\t\townerDocument.addEventListener( 'dragenter', maybeDragStart );\n\t\t\t\townerDocument.removeEventListener( 'dragend', maybeDragEnd );\n\t\t\t\townerDocument.removeEventListener( 'mousemove', maybeDragEnd );\n\n\t\t\t\tif ( onDragEndRef.current ) {\n\t\t\t\t\tonDragEndRef.current( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\telement.dataset.isDropZone = 'true';\n\t\t\telement.addEventListener( 'drop', onDrop );\n\t\t\telement.addEventListener( 'dragenter', onDragEnter );\n\t\t\telement.addEventListener( 'dragover', onDragOver );\n\t\t\telement.addEventListener( 'dragleave', onDragLeave );\n\t\t\t// The `dragstart` event doesn't fire if the drag started outside\n\t\t\t// the document.\n\t\t\townerDocument.addEventListener( 'dragenter', maybeDragStart );\n\n\t\t\treturn () => {\n\t\t\t\tdelete element.dataset.isDropZone;\n\t\t\t\telement.removeEventListener( 'drop', onDrop );\n\t\t\t\telement.removeEventListener( 'dragenter', onDragEnter );\n\t\t\t\telement.removeEventListener( 'dragover', onDragOver );\n\t\t\t\telement.removeEventListener( 'dragleave', onDragLeave );\n\t\t\t\townerDocument.removeEventListener( 'dragend', maybeDragEnd );\n\t\t\t\townerDocument.removeEventListener( 'mousemove', maybeDragEnd );\n\t\t\t\townerDocument.addEventListener( 'dragenter', maybeDragStart );\n\t\t\t};\n\t\t},\n\t\t[ isDisabled ]\n\t);\n}\n"]}