@wordpress/compose 6.16.0 → 6.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/higher-order/compose.js +0 -2
  3. package/build/higher-order/compose.js.map +1 -1
  4. package/build/higher-order/if-condition/index.js +2 -6
  5. package/build/higher-order/if-condition/index.js.map +1 -1
  6. package/build/higher-order/pipe.js +1 -5
  7. package/build/higher-order/pipe.js.map +1 -1
  8. package/build/higher-order/pure/index.js +2 -10
  9. package/build/higher-order/pure/index.js.map +1 -1
  10. package/build/higher-order/with-global-events/index.js +13 -32
  11. package/build/higher-order/with-global-events/index.js.map +1 -1
  12. package/build/higher-order/with-global-events/listener.js +5 -28
  13. package/build/higher-order/with-global-events/listener.js.map +1 -1
  14. package/build/higher-order/with-instance-id/index.js +4 -8
  15. package/build/higher-order/with-instance-id/index.js.map +1 -1
  16. package/build/higher-order/with-preferred-color-scheme/index.native.js +3 -6
  17. package/build/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  18. package/build/higher-order/with-safe-timeout/index.js +4 -14
  19. package/build/higher-order/with-safe-timeout/index.js.map +1 -1
  20. package/build/higher-order/with-state/index.js +3 -11
  21. package/build/higher-order/with-state/index.js.map +1 -1
  22. package/build/hooks/use-async-list/index.js +1 -14
  23. package/build/hooks/use-async-list/index.js.map +1 -1
  24. package/build/hooks/use-constrained-tabbing/index.js +14 -30
  25. package/build/hooks/use-constrained-tabbing/index.js.map +1 -1
  26. package/build/hooks/use-constrained-tabbing/index.native.js +4 -4
  27. package/build/hooks/use-constrained-tabbing/index.native.js.map +1 -1
  28. package/build/hooks/use-copy-on-click/index.js +6 -15
  29. package/build/hooks/use-copy-on-click/index.js.map +1 -1
  30. package/build/hooks/use-copy-to-clipboard/index.js +3 -11
  31. package/build/hooks/use-copy-to-clipboard/index.js.map +1 -1
  32. package/build/hooks/use-debounce/index.js +0 -4
  33. package/build/hooks/use-debounce/index.js.map +1 -1
  34. package/build/hooks/use-dialog/index.js +2 -12
  35. package/build/hooks/use-dialog/index.js.map +1 -1
  36. package/build/hooks/use-disabled/index.js +5 -15
  37. package/build/hooks/use-disabled/index.js.map +1 -1
  38. package/build/hooks/use-dragging/index.js +4 -11
  39. package/build/hooks/use-dragging/index.js.map +1 -1
  40. package/build/hooks/use-drop-zone/index.js +27 -66
  41. package/build/hooks/use-drop-zone/index.js.map +1 -1
  42. package/build/hooks/use-fixed-window-list/index.js +8 -34
  43. package/build/hooks/use-fixed-window-list/index.js.map +1 -1
  44. package/build/hooks/use-focus-on-mount/index.js +3 -14
  45. package/build/hooks/use-focus-on-mount/index.js.map +1 -1
  46. package/build/hooks/use-focus-outside/index.js +13 -19
  47. package/build/hooks/use-focus-outside/index.js.map +1 -1
  48. package/build/hooks/use-focus-outside/index.native.js +13 -21
  49. package/build/hooks/use-focus-outside/index.native.js.map +1 -1
  50. package/build/hooks/use-focus-return/index.js +7 -15
  51. package/build/hooks/use-focus-return/index.js.map +1 -1
  52. package/build/hooks/use-focusable-iframe/index.js +1 -5
  53. package/build/hooks/use-focusable-iframe/index.js.map +1 -1
  54. package/build/hooks/use-instance-id/index.js +3 -5
  55. package/build/hooks/use-instance-id/index.js.map +1 -1
  56. package/build/hooks/use-isomorphic-layout-effect/index.js +0 -2
  57. package/build/hooks/use-isomorphic-layout-effect/index.js.map +1 -1
  58. package/build/hooks/use-keyboard-shortcut/index.js +12 -28
  59. package/build/hooks/use-keyboard-shortcut/index.js.map +1 -1
  60. package/build/hooks/use-keyboard-shortcut/index.native.js +0 -2
  61. package/build/hooks/use-keyboard-shortcut/index.native.js.map +1 -1
  62. package/build/hooks/use-media-query/index.js +1 -9
  63. package/build/hooks/use-media-query/index.js.map +1 -1
  64. package/build/hooks/use-merge-refs/index.js +18 -24
  65. package/build/hooks/use-merge-refs/index.js.map +1 -1
  66. package/build/hooks/use-preferred-color-scheme/index.android.js +0 -5
  67. package/build/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
  68. package/build/hooks/use-preferred-color-scheme/index.ios.js +0 -2
  69. package/build/hooks/use-preferred-color-scheme/index.ios.js.map +1 -1
  70. package/build/hooks/use-preferred-color-scheme-style/index.native.js +2 -5
  71. package/build/hooks/use-preferred-color-scheme-style/index.native.js.map +1 -1
  72. package/build/hooks/use-previous/index.js +3 -4
  73. package/build/hooks/use-previous/index.js.map +1 -1
  74. package/build/hooks/use-reduced-motion/index.js +0 -4
  75. package/build/hooks/use-reduced-motion/index.js.map +1 -1
  76. package/build/hooks/use-ref-effect/index.js +0 -2
  77. package/build/hooks/use-ref-effect/index.js.map +1 -1
  78. package/build/hooks/use-resize-observer/index.js +23 -30
  79. package/build/hooks/use-resize-observer/index.js.map +1 -1
  80. package/build/hooks/use-resize-observer/index.native.js +0 -6
  81. package/build/hooks/use-resize-observer/index.native.js.map +1 -1
  82. package/build/hooks/use-throttle/index.js +0 -4
  83. package/build/hooks/use-throttle/index.js.map +1 -1
  84. package/build/hooks/use-viewport-match/index.js +4 -13
  85. package/build/hooks/use-viewport-match/index.js.map +1 -1
  86. package/build/hooks/use-warn-on-change/index.js +4 -14
  87. package/build/hooks/use-warn-on-change/index.js.map +1 -1
  88. package/build/index.js +0 -41
  89. package/build/index.js.map +1 -1
  90. package/build/index.native.js +0 -33
  91. package/build/index.native.js.map +1 -1
  92. package/build/utils/create-higher-order-component/index.js +1 -4
  93. package/build/utils/create-higher-order-component/index.js.map +1 -1
  94. package/build/utils/debounce/index.js +12 -37
  95. package/build/utils/debounce/index.js.map +1 -1
  96. package/build/utils/throttle/index.js +0 -5
  97. package/build/utils/throttle/index.js.map +1 -1
  98. package/build-module/higher-order/compose.js +1 -1
  99. package/build-module/higher-order/compose.js.map +1 -1
  100. package/build-module/higher-order/if-condition/index.js +3 -5
  101. package/build-module/higher-order/if-condition/index.js.map +1 -1
  102. package/build-module/higher-order/pipe.js +1 -4
  103. package/build-module/higher-order/pipe.js.map +1 -1
  104. package/build-module/higher-order/pure/index.js +4 -8
  105. package/build-module/higher-order/pure/index.js.map +1 -1
  106. package/build-module/higher-order/with-global-events/index.js +15 -29
  107. package/build-module/higher-order/with-global-events/index.js.map +1 -1
  108. package/build-module/higher-order/with-global-events/listener.js +5 -27
  109. package/build-module/higher-order/with-global-events/listener.js.map +1 -1
  110. package/build-module/higher-order/with-instance-id/index.js +5 -5
  111. package/build-module/higher-order/with-instance-id/index.js.map +1 -1
  112. package/build-module/higher-order/with-preferred-color-scheme/index.native.js +3 -3
  113. package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  114. package/build-module/higher-order/with-safe-timeout/index.js +6 -8
  115. package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
  116. package/build-module/higher-order/with-state/index.js +5 -9
  117. package/build-module/higher-order/with-state/index.js.map +1 -1
  118. package/build-module/hooks/use-async-list/index.js +1 -12
  119. package/build-module/hooks/use-async-list/index.js.map +1 -1
  120. package/build-module/hooks/use-constrained-tabbing/index.js +16 -27
  121. package/build-module/hooks/use-constrained-tabbing/index.js.map +1 -1
  122. package/build-module/hooks/use-constrained-tabbing/index.native.js +3 -3
  123. package/build-module/hooks/use-constrained-tabbing/index.native.js.map +1 -1
  124. package/build-module/hooks/use-copy-on-click/index.js +8 -12
  125. package/build-module/hooks/use-copy-on-click/index.js.map +1 -1
  126. package/build-module/hooks/use-copy-to-clipboard/index.js +6 -9
  127. package/build-module/hooks/use-copy-to-clipboard/index.js.map +1 -1
  128. package/build-module/hooks/use-debounce/index.js +3 -3
  129. package/build-module/hooks/use-debounce/index.js.map +1 -1
  130. package/build-module/hooks/use-dialog/index.js +3 -5
  131. package/build-module/hooks/use-dialog/index.js.map +1 -1
  132. package/build-module/hooks/use-disabled/index.js +6 -12
  133. package/build-module/hooks/use-disabled/index.js.map +1 -1
  134. package/build-module/hooks/use-dragging/index.js +6 -9
  135. package/build-module/hooks/use-dragging/index.js.map +1 -1
  136. package/build-module/hooks/use-drop-zone/index.js +29 -64
  137. package/build-module/hooks/use-drop-zone/index.js.map +1 -1
  138. package/build-module/hooks/use-fixed-window-list/index.js +8 -30
  139. package/build-module/hooks/use-fixed-window-list/index.js.map +1 -1
  140. package/build-module/hooks/use-focus-on-mount/index.js +4 -12
  141. package/build-module/hooks/use-focus-on-mount/index.js.map +1 -1
  142. package/build-module/hooks/use-focus-outside/index.js +14 -18
  143. package/build-module/hooks/use-focus-outside/index.js.map +1 -1
  144. package/build-module/hooks/use-focus-outside/index.native.js +14 -20
  145. package/build-module/hooks/use-focus-outside/index.native.js.map +1 -1
  146. package/build-module/hooks/use-focus-return/index.js +8 -14
  147. package/build-module/hooks/use-focus-return/index.js.map +1 -1
  148. package/build-module/hooks/use-focusable-iframe/index.js +2 -3
  149. package/build-module/hooks/use-focusable-iframe/index.js.map +1 -1
  150. package/build-module/hooks/use-instance-id/index.js +2 -3
  151. package/build-module/hooks/use-instance-id/index.js.map +1 -1
  152. package/build-module/hooks/use-isomorphic-layout-effect/index.js +1 -1
  153. package/build-module/hooks/use-isomorphic-layout-effect/index.js.map +1 -1
  154. package/build-module/hooks/use-keyboard-shortcut/index.js +14 -24
  155. package/build-module/hooks/use-keyboard-shortcut/index.js.map +1 -1
  156. package/build-module/hooks/use-keyboard-shortcut/index.native.js +0 -1
  157. package/build-module/hooks/use-keyboard-shortcut/index.native.js.map +1 -1
  158. package/build-module/hooks/use-media-query/index.js +2 -8
  159. package/build-module/hooks/use-media-query/index.js.map +1 -1
  160. package/build-module/hooks/use-merge-refs/index.js +19 -23
  161. package/build-module/hooks/use-merge-refs/index.js.map +1 -1
  162. package/build-module/hooks/use-preferred-color-scheme/index.android.js +1 -3
  163. package/build-module/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
  164. package/build-module/hooks/use-preferred-color-scheme/index.ios.js +1 -1
  165. package/build-module/hooks/use-preferred-color-scheme/index.ios.js.map +1 -1
  166. package/build-module/hooks/use-preferred-color-scheme-style/index.native.js +3 -3
  167. package/build-module/hooks/use-preferred-color-scheme-style/index.native.js.map +1 -1
  168. package/build-module/hooks/use-previous/index.js +4 -3
  169. package/build-module/hooks/use-previous/index.js.map +1 -1
  170. package/build-module/hooks/use-reduced-motion/index.js +1 -2
  171. package/build-module/hooks/use-reduced-motion/index.js.map +1 -1
  172. package/build-module/hooks/use-ref-effect/index.js +1 -1
  173. package/build-module/hooks/use-ref-effect/index.js.map +1 -1
  174. package/build-module/hooks/use-resize-observer/index.js +22 -30
  175. package/build-module/hooks/use-resize-observer/index.js.map +1 -1
  176. package/build-module/hooks/use-resize-observer/index.native.js +1 -6
  177. package/build-module/hooks/use-resize-observer/index.native.js.map +1 -1
  178. package/build-module/hooks/use-throttle/index.js +3 -3
  179. package/build-module/hooks/use-throttle/index.js.map +1 -1
  180. package/build-module/hooks/use-viewport-match/index.js +6 -11
  181. package/build-module/hooks/use-viewport-match/index.js.map +1 -1
  182. package/build-module/hooks/use-warn-on-change/index.js +6 -12
  183. package/build-module/hooks/use-warn-on-change/index.js.map +1 -1
  184. package/build-module/index.js +10 -7
  185. package/build-module/index.js.map +1 -1
  186. package/build-module/index.native.js +10 -7
  187. package/build-module/index.native.js.map +1 -1
  188. package/build-module/utils/create-higher-order-component/index.js +1 -2
  189. package/build-module/utils/create-higher-order-component/index.js.map +1 -1
  190. package/build-module/utils/debounce/index.js +12 -35
  191. package/build-module/utils/debounce/index.js.map +1 -1
  192. package/build-module/utils/throttle/index.js +0 -3
  193. package/build-module/utils/throttle/index.js.map +1 -1
  194. package/build-types/higher-order/with-instance-id/index.d.ts +1 -1
  195. package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
  196. package/build-types/higher-order/with-safe-timeout/index.d.ts +1 -1
  197. package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
  198. package/build-types/hooks/use-disabled/index.d.ts +1 -1
  199. package/build-types/hooks/use-disabled/index.d.ts.map +1 -1
  200. package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts +1 -1
  201. package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts.map +1 -1
  202. package/build-types/hooks/use-viewport-match/index.d.ts +1 -1
  203. package/package.json +8 -8
  204. package/src/higher-order/with-instance-id/index.tsx +2 -2
  205. package/src/higher-order/with-safe-timeout/index.tsx +2 -2
  206. package/src/hooks/use-resize-observer/index.native.js +0 -1
  207. package/tsconfig.tsbuildinfo +1 -1
@@ -3,12 +3,13 @@
3
3
  */
4
4
  import Mousetrap from 'mousetrap';
5
5
  import 'mousetrap/plugins/global-bind/mousetrap-global-bind';
6
+
6
7
  /**
7
8
  * WordPress dependencies
8
9
  */
9
-
10
10
  import { useEffect, useRef } from '@wordpress/element';
11
11
  import { isAppleOS } from '@wordpress/keycodes';
12
+
12
13
  /**
13
14
  * A block selection object.
14
15
  *
@@ -21,7 +22,6 @@ import { isAppleOS } from '@wordpress/keycodes';
21
22
  */
22
23
 
23
24
  /* eslint-disable jsdoc/valid-types */
24
-
25
25
  /**
26
26
  * Attach a keyboard shortcut handler.
27
27
  *
@@ -31,9 +31,7 @@ import { isAppleOS } from '@wordpress/keycodes';
31
31
  * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.
32
32
  * @param {WPKeyboardShortcutConfig} options Shortcut options.
33
33
  */
34
-
35
- function useKeyboardShortcut(
36
- /* eslint-enable jsdoc/valid-types */
34
+ function useKeyboardShortcut( /* eslint-enable jsdoc/valid-types */
37
35
  shortcuts, callback, {
38
36
  bindGlobal = false,
39
37
  eventName = 'keydown',
@@ -49,37 +47,30 @@ shortcuts, callback, {
49
47
  if (isDisabled) {
50
48
  return;
51
49
  }
52
-
53
- const mousetrap = new Mousetrap(target && target.current ? target.current : // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
50
+ const mousetrap = new Mousetrap(target && target.current ? target.current :
51
+ // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
54
52
  // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's
55
53
  // necessary to maintain the existing behavior.
56
-
57
- /** @type {Element} */
58
-
59
- /** @type {unknown} */
54
+ /** @type {Element} */ /** @type {unknown} */
60
55
  document);
61
56
  const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts];
62
57
  shortcutsArray.forEach(shortcut => {
63
- const keys = shortcut.split('+'); // Determines whether a key is a modifier by the length of the string.
58
+ const keys = shortcut.split('+');
59
+ // Determines whether a key is a modifier by the length of the string.
64
60
  // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that
65
61
  // the modifiers are Shift and Cmd because they're not a single character.
66
-
67
62
  const modifiers = new Set(keys.filter(value => value.length > 1));
68
63
  const hasAlt = modifiers.has('alt');
69
- const hasShift = modifiers.has('shift'); // This should be better moved to the shortcut registration instead.
64
+ const hasShift = modifiers.has('shift');
70
65
 
66
+ // This should be better moved to the shortcut registration instead.
71
67
  if (isAppleOS() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
72
68
  throw new Error(`Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`);
73
69
  }
74
-
75
- const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; // @ts-ignore `bindGlobal` is an undocumented property
76
-
77
- mousetrap[bindFn](shortcut, (
78
- /* eslint-disable jsdoc/valid-types */
79
-
80
- /** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */
81
- ...args) =>
82
- /* eslint-enable jsdoc/valid-types */
70
+ const bindFn = bindGlobal ? 'bindGlobal' : 'bind';
71
+ // @ts-ignore `bindGlobal` is an undocumented property
72
+ mousetrap[bindFn](shortcut, ( /* eslint-disable jsdoc/valid-types */
73
+ /** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */...args) => /* eslint-enable jsdoc/valid-types */
83
74
  currentCallback.current(...args), eventName);
84
75
  });
85
76
  return () => {
@@ -87,6 +78,5 @@ shortcuts, callback, {
87
78
  };
88
79
  }, [shortcuts, bindGlobal, eventName, target, isDisabled]);
89
80
  }
90
-
91
81
  export default useKeyboardShortcut;
92
82
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-keyboard-shortcut/index.js"],"names":["Mousetrap","useEffect","useRef","isAppleOS","useKeyboardShortcut","shortcuts","callback","bindGlobal","eventName","isDisabled","target","currentCallback","current","mousetrap","document","shortcutsArray","Array","isArray","forEach","shortcut","keys","split","modifiers","Set","filter","value","length","hasAlt","has","hasShift","size","Error","bindFn","args","reset"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,WAAtB;AACA,OAAO,qDAAP;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AACA,SAASC,SAAT,QAA0B,qBAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,mBAAT;AACC;AACAC,SAFD,EAGCC,QAHD,EAIC;AACCC,EAAAA,UAAU,GAAG,KADd;AAECC,EAAAA,SAAS,GAAG,SAFb;AAGCC,EAAAA,UAAU,GAAG,KAHd;AAGqB;AACpBC,EAAAA;AAJD,IAKI,EATL,EAUE;AACD,QAAMC,eAAe,GAAGT,MAAM,CAAEI,QAAF,CAA9B;AACAL,EAAAA,SAAS,CAAE,MAAM;AAChBU,IAAAA,eAAe,CAACC,OAAhB,GAA0BN,QAA1B;AACA,GAFQ,EAEN,CAAEA,QAAF,CAFM,CAAT;AAIAL,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKQ,UAAL,EAAkB;AACjB;AACA;;AACD,UAAMI,SAAS,GAAG,IAAIb,SAAJ,CACjBU,MAAM,IAAIA,MAAM,CAACE,OAAjB,GACGF,MAAM,CAACE,OADV,GAEG;AACA;AACA;;AACA;;AAAyB;AAAyBE,IAAAA,QANpC,CAAlB;AAQA,UAAMC,cAAc,GAAGC,KAAK,CAACC,OAAN,CAAeZ,SAAf,IACpBA,SADoB,GAEpB,CAAEA,SAAF,CAFH;AAGAU,IAAAA,cAAc,CAACG,OAAf,CAA0BC,QAAF,IAAgB;AACvC,YAAMC,IAAI,GAAGD,QAAQ,CAACE,KAAT,CAAgB,GAAhB,CAAb,CADuC,CAEvC;AACA;AACA;;AACA,YAAMC,SAAS,GAAG,IAAIC,GAAJ,CACjBH,IAAI,CAACI,MAAL,CAAeC,KAAF,IAAaA,KAAK,CAACC,MAAN,GAAe,CAAzC,CADiB,CAAlB;AAGA,YAAMC,MAAM,GAAGL,SAAS,CAACM,GAAV,CAAe,KAAf,CAAf;AACA,YAAMC,QAAQ,GAAGP,SAAS,CAACM,GAAV,CAAe,OAAf,CAAjB,CATuC,CAWvC;;AACA,UACCzB,SAAS,OACLmB,SAAS,CAACQ,IAAV,KAAmB,CAAnB,IAAwBH,MAA1B,IACCL,SAAS,CAACQ,IAAV,KAAmB,CAAnB,IAAwBH,MAAxB,IAAkCE,QAF5B,CADV,EAIE;AACD,cAAM,IAAIE,KAAJ,CACJ,eAAeZ,QAAU,iEADrB,CAAN;AAGA;;AAED,YAAMa,MAAM,GAAGzB,UAAU,GAAG,YAAH,GAAkB,MAA3C,CAtBuC,CAuBvC;;AACAM,MAAAA,SAAS,CAAEmB,MAAF,CAAT,CACCb,QADD,EAEC;AACC;;AACA;AAA6E,SAAGc,IAFjF;AAIC;AACAtB,MAAAA,eAAe,CAACC,OAAhB,CAAyB,GAAGqB,IAA5B,CAPF,EAQCzB,SARD;AAUA,KAlCD;AAoCA,WAAO,MAAM;AACZK,MAAAA,SAAS,CAACqB,KAAV;AACA,KAFD;AAGA,GAtDQ,EAsDN,CAAE7B,SAAF,EAAaE,UAAb,EAAyBC,SAAzB,EAAoCE,MAApC,EAA4CD,UAA5C,CAtDM,CAAT;AAuDA;;AAED,eAAeL,mBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport Mousetrap from 'mousetrap';\nimport 'mousetrap/plugins/global-bind/mousetrap-global-bind';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * A block selection object.\n *\n * @typedef {Object} WPKeyboardShortcutConfig\n *\n * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.\n * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.\n * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.\n * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Attach a keyboard shortcut handler.\n *\n * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.\n *\n * @param {string[]|string} shortcuts Keyboard Shortcuts.\n * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.\n * @param {WPKeyboardShortcutConfig} options Shortcut options.\n */\nfunction useKeyboardShortcut(\n\t/* eslint-enable jsdoc/valid-types */\n\tshortcuts,\n\tcallback,\n\t{\n\t\tbindGlobal = false,\n\t\teventName = 'keydown',\n\t\tisDisabled = false, // This is important for performance considerations.\n\t\ttarget,\n\t} = {}\n) {\n\tconst currentCallback = useRef( callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst mousetrap = new Mousetrap(\n\t\t\ttarget && target.current\n\t\t\t\t? target.current\n\t\t\t\t: // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.\n\t\t\t\t // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's\n\t\t\t\t // necessary to maintain the existing behavior.\n\t\t\t\t /** @type {Element} */ ( /** @type {unknown} */ ( document ) )\n\t\t);\n\t\tconst shortcutsArray = Array.isArray( shortcuts )\n\t\t\t? shortcuts\n\t\t\t: [ shortcuts ];\n\t\tshortcutsArray.forEach( ( shortcut ) => {\n\t\t\tconst keys = shortcut.split( '+' );\n\t\t\t// Determines whether a key is a modifier by the length of the string.\n\t\t\t// E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that\n\t\t\t// the modifiers are Shift and Cmd because they're not a single character.\n\t\t\tconst modifiers = new Set(\n\t\t\t\tkeys.filter( ( value ) => value.length > 1 )\n\t\t\t);\n\t\t\tconst hasAlt = modifiers.has( 'alt' );\n\t\t\tconst hasShift = modifiers.has( 'shift' );\n\n\t\t\t// This should be better moved to the shortcut registration instead.\n\t\t\tif (\n\t\t\t\tisAppleOS() &&\n\t\t\t\t( ( modifiers.size === 1 && hasAlt ) ||\n\t\t\t\t\t( modifiers.size === 2 && hasAlt && hasShift ) )\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot bind ${ shortcut }. Alt and Shift+Alt modifiers are reserved for character input.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst bindFn = bindGlobal ? 'bindGlobal' : 'bind';\n\t\t\t// @ts-ignore `bindGlobal` is an undocumented property\n\t\t\tmousetrap[ bindFn ](\n\t\t\t\tshortcut,\n\t\t\t\t(\n\t\t\t\t\t/* eslint-disable jsdoc/valid-types */\n\t\t\t\t\t/** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */ ...args\n\t\t\t\t) =>\n\t\t\t\t\t/* eslint-enable jsdoc/valid-types */\n\t\t\t\t\tcurrentCallback.current( ...args ),\n\t\t\t\teventName\n\t\t\t);\n\t\t} );\n\n\t\treturn () => {\n\t\t\tmousetrap.reset();\n\t\t};\n\t}, [ shortcuts, bindGlobal, eventName, target, isDisabled ] );\n}\n\nexport default useKeyboardShortcut;\n"]}
1
+ {"version":3,"names":["Mousetrap","useEffect","useRef","isAppleOS","useKeyboardShortcut","shortcuts","callback","bindGlobal","eventName","isDisabled","target","currentCallback","current","mousetrap","document","shortcutsArray","Array","isArray","forEach","shortcut","keys","split","modifiers","Set","filter","value","length","hasAlt","has","hasShift","size","Error","bindFn","args","reset"],"sources":["@wordpress/compose/src/hooks/use-keyboard-shortcut/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport Mousetrap from 'mousetrap';\nimport 'mousetrap/plugins/global-bind/mousetrap-global-bind';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * A block selection object.\n *\n * @typedef {Object} WPKeyboardShortcutConfig\n *\n * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.\n * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.\n * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.\n * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Attach a keyboard shortcut handler.\n *\n * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.\n *\n * @param {string[]|string} shortcuts Keyboard Shortcuts.\n * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.\n * @param {WPKeyboardShortcutConfig} options Shortcut options.\n */\nfunction useKeyboardShortcut(\n\t/* eslint-enable jsdoc/valid-types */\n\tshortcuts,\n\tcallback,\n\t{\n\t\tbindGlobal = false,\n\t\teventName = 'keydown',\n\t\tisDisabled = false, // This is important for performance considerations.\n\t\ttarget,\n\t} = {}\n) {\n\tconst currentCallback = useRef( callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst mousetrap = new Mousetrap(\n\t\t\ttarget && target.current\n\t\t\t\t? target.current\n\t\t\t\t: // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.\n\t\t\t\t // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's\n\t\t\t\t // necessary to maintain the existing behavior.\n\t\t\t\t /** @type {Element} */ ( /** @type {unknown} */ ( document ) )\n\t\t);\n\t\tconst shortcutsArray = Array.isArray( shortcuts )\n\t\t\t? shortcuts\n\t\t\t: [ shortcuts ];\n\t\tshortcutsArray.forEach( ( shortcut ) => {\n\t\t\tconst keys = shortcut.split( '+' );\n\t\t\t// Determines whether a key is a modifier by the length of the string.\n\t\t\t// E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that\n\t\t\t// the modifiers are Shift and Cmd because they're not a single character.\n\t\t\tconst modifiers = new Set(\n\t\t\t\tkeys.filter( ( value ) => value.length > 1 )\n\t\t\t);\n\t\t\tconst hasAlt = modifiers.has( 'alt' );\n\t\t\tconst hasShift = modifiers.has( 'shift' );\n\n\t\t\t// This should be better moved to the shortcut registration instead.\n\t\t\tif (\n\t\t\t\tisAppleOS() &&\n\t\t\t\t( ( modifiers.size === 1 && hasAlt ) ||\n\t\t\t\t\t( modifiers.size === 2 && hasAlt && hasShift ) )\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot bind ${ shortcut }. Alt and Shift+Alt modifiers are reserved for character input.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst bindFn = bindGlobal ? 'bindGlobal' : 'bind';\n\t\t\t// @ts-ignore `bindGlobal` is an undocumented property\n\t\t\tmousetrap[ bindFn ](\n\t\t\t\tshortcut,\n\t\t\t\t(\n\t\t\t\t\t/* eslint-disable jsdoc/valid-types */\n\t\t\t\t\t/** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */ ...args\n\t\t\t\t) =>\n\t\t\t\t\t/* eslint-enable jsdoc/valid-types */\n\t\t\t\t\tcurrentCallback.current( ...args ),\n\t\t\t\teventName\n\t\t\t);\n\t\t} );\n\n\t\treturn () => {\n\t\t\tmousetrap.reset();\n\t\t};\n\t}, [ shortcuts, bindGlobal, eventName, target, isDisabled ] );\n}\n\nexport default useKeyboardShortcut;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,WAAW;AACjC,OAAO,qDAAqD;;AAE5D;AACA;AACA;AACA,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACtD,SAASC,SAAS,QAAQ,qBAAqB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,mBAAmBA,CAAA,CAC3B;AACAC,SAAS,EACTC,QAAQ,EACR;EACCC,UAAU,GAAG,KAAK;EAClBC,SAAS,GAAG,SAAS;EACrBC,UAAU,GAAG,KAAK;EAAE;EACpBC;AACD,CAAC,GAAG,CAAC,CAAC,EACL;EACD,MAAMC,eAAe,GAAGT,MAAM,CAAEI,QAAS,CAAC;EAC1CL,SAAS,CAAE,MAAM;IAChBU,eAAe,CAACC,OAAO,GAAGN,QAAQ;EACnC,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjBL,SAAS,CAAE,MAAM;IAChB,IAAKQ,UAAU,EAAG;MACjB;IACD;IACA,MAAMI,SAAS,GAAG,IAAIb,SAAS,CAC9BU,MAAM,IAAIA,MAAM,CAACE,OAAO,GACrBF,MAAM,CAACE,OAAO;IACd;IACA;IACA;IACA,uBAAyB;IAAyBE,QACtD,CAAC;IACD,MAAMC,cAAc,GAAGC,KAAK,CAACC,OAAO,CAAEZ,SAAU,CAAC,GAC9CA,SAAS,GACT,CAAEA,SAAS,CAAE;IAChBU,cAAc,CAACG,OAAO,CAAIC,QAAQ,IAAM;MACvC,MAAMC,IAAI,GAAGD,QAAQ,CAACE,KAAK,CAAE,GAAI,CAAC;MAClC;MACA;MACA;MACA,MAAMC,SAAS,GAAG,IAAIC,GAAG,CACxBH,IAAI,CAACI,MAAM,CAAIC,KAAK,IAAMA,KAAK,CAACC,MAAM,GAAG,CAAE,CAC5C,CAAC;MACD,MAAMC,MAAM,GAAGL,SAAS,CAACM,GAAG,CAAE,KAAM,CAAC;MACrC,MAAMC,QAAQ,GAAGP,SAAS,CAACM,GAAG,CAAE,OAAQ,CAAC;;MAEzC;MACA,IACCzB,SAAS,CAAC,CAAC,KACPmB,SAAS,CAACQ,IAAI,KAAK,CAAC,IAAIH,MAAM,IAC/BL,SAAS,CAACQ,IAAI,KAAK,CAAC,IAAIH,MAAM,IAAIE,QAAU,CAAE,EAChD;QACD,MAAM,IAAIE,KAAK,CACb,eAAeZ,QAAU,iEAC3B,CAAC;MACF;MAEA,MAAMa,MAAM,GAAGzB,UAAU,GAAG,YAAY,GAAG,MAAM;MACjD;MACAM,SAAS,CAAEmB,MAAM,CAAE,CAClBb,QAAQ,EACR,EACC;MACA,4EAA6E,GAAGc,IAAI,KAEpF;MACAtB,eAAe,CAACC,OAAO,CAAE,GAAGqB,IAAK,CAAC,EACnCzB,SACD,CAAC;IACF,CAAE,CAAC;IAEH,OAAO,MAAM;MACZK,SAAS,CAACqB,KAAK,CAAC,CAAC;IAClB,CAAC;EACF,CAAC,EAAE,CAAE7B,SAAS,EAAEE,UAAU,EAAEC,SAAS,EAAEE,MAAM,EAAED,UAAU,CAAG,CAAC;AAC9D;AAEA,eAAeL,mBAAmB"}
@@ -1,4 +1,3 @@
1
1
  const useKeyboardShortcut = () => null;
2
-
3
2
  export default useKeyboardShortcut;
4
3
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-keyboard-shortcut/index.native.js"],"names":["useKeyboardShortcut"],"mappings":"AAAA,MAAMA,mBAAmB,GAAG,MAAM,IAAlC;;AACA,eAAeA,mBAAf","sourcesContent":["const useKeyboardShortcut = () => null;\nexport default useKeyboardShortcut;\n"]}
1
+ {"version":3,"names":["useKeyboardShortcut"],"sources":["@wordpress/compose/src/hooks/use-keyboard-shortcut/index.native.js"],"sourcesContent":["const useKeyboardShortcut = () => null;\nexport default useKeyboardShortcut;\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAGA,CAAA,KAAM,IAAI;AACtC,eAAeA,mBAAmB"}
@@ -2,28 +2,26 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useMemo, useSyncExternalStore } from '@wordpress/element';
5
+
5
6
  /**
6
7
  * A new MediaQueryList object for the media query
7
8
  *
8
9
  * @param {string} [query] Media Query.
9
10
  * @return {MediaQueryList|null} A new object for the media query
10
11
  */
11
-
12
12
  function getMediaQueryList(query) {
13
13
  if (query && typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
14
14
  return window.matchMedia(query);
15
15
  }
16
-
17
16
  return null;
18
17
  }
18
+
19
19
  /**
20
20
  * Runs a media query and returns its value when it changes.
21
21
  *
22
22
  * @param {string} [query] Media Query.
23
23
  * @return {boolean} return value of the media query.
24
24
  */
25
-
26
-
27
25
  export default function useMediaQuery(query) {
28
26
  const source = useMemo(() => {
29
27
  const mediaQueryList = getMediaQueryList(query);
@@ -33,19 +31,15 @@ export default function useMediaQuery(query) {
33
31
  if (!mediaQueryList) {
34
32
  return () => {};
35
33
  }
36
-
37
34
  mediaQueryList.addEventListener('change', onStoreChange);
38
35
  return () => {
39
36
  mediaQueryList.removeEventListener('change', onStoreChange);
40
37
  };
41
38
  },
42
-
43
39
  getValue() {
44
40
  var _mediaQueryList$match;
45
-
46
41
  return (_mediaQueryList$match = mediaQueryList?.matches) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false;
47
42
  }
48
-
49
43
  };
50
44
  }, [query]);
51
45
  return useSyncExternalStore(source.subscribe, source.getValue, () => false);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-media-query/index.js"],"names":["useMemo","useSyncExternalStore","getMediaQueryList","query","window","matchMedia","useMediaQuery","source","mediaQueryList","subscribe","onStoreChange","addEventListener","removeEventListener","getValue","matches"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,oBAAlB,QAA8C,oBAA9C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AACnC,MACCA,KAAK,IACL,OAAOC,MAAP,KAAkB,WADlB,IAEA,OAAOA,MAAM,CAACC,UAAd,KAA6B,UAH9B,EAIE;AACD,WAAOD,MAAM,CAACC,UAAP,CAAmBF,KAAnB,CAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASG,aAAT,CAAwBH,KAAxB,EAAgC;AAC9C,QAAMI,MAAM,GAAGP,OAAO,CAAE,MAAM;AAC7B,UAAMQ,cAAc,GAAGN,iBAAiB,CAAEC,KAAF,CAAxC;AAEA,WAAO;AACN;AACAM,MAAAA,SAAS,CAAEC,aAAF,EAAkB;AAC1B,YAAK,CAAEF,cAAP,EAAwB;AACvB,iBAAO,MAAM,CAAE,CAAf;AACA;;AAEDA,QAAAA,cAAc,CAACG,gBAAf,CAAiC,QAAjC,EAA2CD,aAA3C;AACA,eAAO,MAAM;AACZF,UAAAA,cAAc,CAACI,mBAAf,CACC,QADD,EAECF,aAFD;AAIA,SALD;AAMA,OAdK;;AAeNG,MAAAA,QAAQ,GAAG;AAAA;;AACV,wCAAOL,cAAc,EAAEM,OAAvB,yEAAkC,KAAlC;AACA;;AAjBK,KAAP;AAmBA,GAtBqB,EAsBnB,CAAEX,KAAF,CAtBmB,CAAtB;AAwBA,SAAOF,oBAAoB,CAC1BM,MAAM,CAACE,SADmB,EAE1BF,MAAM,CAACM,QAFmB,EAG1B,MAAM,KAHoB,CAA3B;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\n\n/**\n * A new MediaQueryList object for the media query\n *\n * @param {string} [query] Media Query.\n * @return {MediaQueryList|null} A new object for the media query\n */\nfunction getMediaQueryList( query ) {\n\tif (\n\t\tquery &&\n\t\ttypeof window !== 'undefined' &&\n\t\ttypeof window.matchMedia === 'function'\n\t) {\n\t\treturn window.matchMedia( query );\n\t}\n\n\treturn null;\n}\n\n/**\n * Runs a media query and returns its value when it changes.\n *\n * @param {string} [query] Media Query.\n * @return {boolean} return value of the media query.\n */\nexport default function useMediaQuery( query ) {\n\tconst source = useMemo( () => {\n\t\tconst mediaQueryList = getMediaQueryList( query );\n\n\t\treturn {\n\t\t\t/** @type {(onStoreChange: () => void) => () => void} */\n\t\t\tsubscribe( onStoreChange ) {\n\t\t\t\tif ( ! mediaQueryList ) {\n\t\t\t\t\treturn () => {};\n\t\t\t\t}\n\n\t\t\t\tmediaQueryList.addEventListener( 'change', onStoreChange );\n\t\t\t\treturn () => {\n\t\t\t\t\tmediaQueryList.removeEventListener(\n\t\t\t\t\t\t'change',\n\t\t\t\t\t\tonStoreChange\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\treturn mediaQueryList?.matches ?? false;\n\t\t\t},\n\t\t};\n\t}, [ query ] );\n\n\treturn useSyncExternalStore(\n\t\tsource.subscribe,\n\t\tsource.getValue,\n\t\t() => false\n\t);\n}\n"]}
1
+ {"version":3,"names":["useMemo","useSyncExternalStore","getMediaQueryList","query","window","matchMedia","useMediaQuery","source","mediaQueryList","subscribe","onStoreChange","addEventListener","removeEventListener","getValue","_mediaQueryList$match","matches"],"sources":["@wordpress/compose/src/hooks/use-media-query/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\n\n/**\n * A new MediaQueryList object for the media query\n *\n * @param {string} [query] Media Query.\n * @return {MediaQueryList|null} A new object for the media query\n */\nfunction getMediaQueryList( query ) {\n\tif (\n\t\tquery &&\n\t\ttypeof window !== 'undefined' &&\n\t\ttypeof window.matchMedia === 'function'\n\t) {\n\t\treturn window.matchMedia( query );\n\t}\n\n\treturn null;\n}\n\n/**\n * Runs a media query and returns its value when it changes.\n *\n * @param {string} [query] Media Query.\n * @return {boolean} return value of the media query.\n */\nexport default function useMediaQuery( query ) {\n\tconst source = useMemo( () => {\n\t\tconst mediaQueryList = getMediaQueryList( query );\n\n\t\treturn {\n\t\t\t/** @type {(onStoreChange: () => void) => () => void} */\n\t\t\tsubscribe( onStoreChange ) {\n\t\t\t\tif ( ! mediaQueryList ) {\n\t\t\t\t\treturn () => {};\n\t\t\t\t}\n\n\t\t\t\tmediaQueryList.addEventListener( 'change', onStoreChange );\n\t\t\t\treturn () => {\n\t\t\t\t\tmediaQueryList.removeEventListener(\n\t\t\t\t\t\t'change',\n\t\t\t\t\t\tonStoreChange\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\treturn mediaQueryList?.matches ?? false;\n\t\t\t},\n\t\t};\n\t}, [ query ] );\n\n\treturn useSyncExternalStore(\n\t\tsource.subscribe,\n\t\tsource.getValue,\n\t\t() => false\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,oBAAoB,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,IACCA,KAAK,IACL,OAAOC,MAAM,KAAK,WAAW,IAC7B,OAAOA,MAAM,CAACC,UAAU,KAAK,UAAU,EACtC;IACD,OAAOD,MAAM,CAACC,UAAU,CAAEF,KAAM,CAAC;EAClC;EAEA,OAAO,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASG,aAAaA,CAAEH,KAAK,EAAG;EAC9C,MAAMI,MAAM,GAAGP,OAAO,CAAE,MAAM;IAC7B,MAAMQ,cAAc,GAAGN,iBAAiB,CAAEC,KAAM,CAAC;IAEjD,OAAO;MACN;MACAM,SAASA,CAAEC,aAAa,EAAG;QAC1B,IAAK,CAAEF,cAAc,EAAG;UACvB,OAAO,MAAM,CAAC,CAAC;QAChB;QAEAA,cAAc,CAACG,gBAAgB,CAAE,QAAQ,EAAED,aAAc,CAAC;QAC1D,OAAO,MAAM;UACZF,cAAc,CAACI,mBAAmB,CACjC,QAAQ,EACRF,aACD,CAAC;QACF,CAAC;MACF,CAAC;MACDG,QAAQA,CAAA,EAAG;QAAA,IAAAC,qBAAA;QACV,QAAAA,qBAAA,GAAON,cAAc,EAAEO,OAAO,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,KAAK;MACxC;IACD,CAAC;EACF,CAAC,EAAE,CAAEX,KAAK,CAAG,CAAC;EAEd,OAAOF,oBAAoB,CAC1BM,MAAM,CAACE,SAAS,EAChBF,MAAM,CAACM,QAAQ,EACf,MAAM,KACP,CAAC;AACF"}
@@ -2,13 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useRef, useCallback, useLayoutEffect } from '@wordpress/element';
5
- /* eslint-disable jsdoc/valid-types */
6
5
 
6
+ /* eslint-disable jsdoc/valid-types */
7
7
  /**
8
8
  * @template T
9
9
  * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef
10
10
  */
11
-
12
11
  /* eslint-enable jsdoc/valid-types */
13
12
 
14
13
  /**
@@ -16,18 +15,16 @@ import { useRef, useCallback, useLayoutEffect } from '@wordpress/element';
16
15
  * @param {import('react').Ref<T>} ref
17
16
  * @param {T} value
18
17
  */
19
-
20
18
  function assignRef(ref, value) {
21
19
  if (typeof ref === 'function') {
22
20
  ref(value);
23
21
  } else if (ref && ref.hasOwnProperty('current')) {
24
22
  /* eslint-disable jsdoc/no-undefined-types */
25
-
26
- /** @type {import('react').MutableRefObject<T>} */
27
- ref.current = value;
23
+ /** @type {import('react').MutableRefObject<T>} */ref.current = value;
28
24
  /* eslint-enable jsdoc/no-undefined-types */
29
25
  }
30
26
  }
27
+
31
28
  /**
32
29
  * Merges refs into one ref callback.
33
30
  *
@@ -71,57 +68,56 @@ function assignRef(ref, value) {
71
68
  *
72
69
  * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.
73
70
  */
74
-
75
-
76
71
  export default function useMergeRefs(refs) {
77
72
  const element = useRef();
78
73
  const isAttached = useRef(false);
79
74
  const didElementChange = useRef(false);
80
75
  /* eslint-disable jsdoc/no-undefined-types */
81
-
82
76
  /** @type {import('react').MutableRefObject<TRef[]>} */
83
-
84
77
  /* eslint-enable jsdoc/no-undefined-types */
85
-
86
78
  const previousRefs = useRef([]);
87
- const currentRefs = useRef(refs); // Update on render before the ref callback is called, so the ref callback
79
+ const currentRefs = useRef(refs);
80
+
81
+ // Update on render before the ref callback is called, so the ref callback
88
82
  // always has access to the current refs.
83
+ currentRefs.current = refs;
89
84
 
90
- currentRefs.current = refs; // If any of the refs change, call the previous ref with `null` and the new
85
+ // If any of the refs change, call the previous ref with `null` and the new
91
86
  // ref with the node, except when the element changes in the same cycle, in
92
87
  // which case the ref callbacks will already have been called.
93
-
94
88
  useLayoutEffect(() => {
95
89
  if (didElementChange.current === false && isAttached.current === true) {
96
90
  refs.forEach((ref, index) => {
97
91
  const previousRef = previousRefs.current[index];
98
-
99
92
  if (ref !== previousRef) {
100
93
  assignRef(previousRef, null);
101
94
  assignRef(ref, element.current);
102
95
  }
103
96
  });
104
97
  }
105
-
106
98
  previousRefs.current = refs;
107
- }, refs); // No dependencies, must be reset after every render so ref callbacks are
108
- // correctly called after a ref change.
99
+ }, refs);
109
100
 
101
+ // No dependencies, must be reset after every render so ref callbacks are
102
+ // correctly called after a ref change.
110
103
  useLayoutEffect(() => {
111
104
  didElementChange.current = false;
112
- }); // There should be no dependencies so that `callback` is only called when
113
- // the node changes.
105
+ });
114
106
 
107
+ // There should be no dependencies so that `callback` is only called when
108
+ // the node changes.
115
109
  return useCallback(value => {
116
110
  // Update the element so it can be used when calling ref callbacks on a
117
111
  // dependency change.
118
112
  assignRef(element, value);
119
113
  didElementChange.current = true;
120
- isAttached.current = value !== null; // When an element changes, the current ref callback should be called
121
- // with the new element and the previous one with `null`.
114
+ isAttached.current = value !== null;
122
115
 
123
- const refsToAssign = value ? currentRefs.current : previousRefs.current; // Update the latest refs.
116
+ // When an element changes, the current ref callback should be called
117
+ // with the new element and the previous one with `null`.
118
+ const refsToAssign = value ? currentRefs.current : previousRefs.current;
124
119
 
120
+ // Update the latest refs.
125
121
  for (const ref of refsToAssign) {
126
122
  assignRef(ref, value);
127
123
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-merge-refs/index.js"],"names":["useRef","useCallback","useLayoutEffect","assignRef","ref","value","hasOwnProperty","current","useMergeRefs","refs","element","isAttached","didElementChange","previousRefs","currentRefs","forEach","index","previousRef","refsToAssign"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,WAAjB,EAA8BC,eAA9B,QAAqD,oBAArD;AAEA;;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA,SAASC,SAAT,CAAoBC,GAApB,EAAyBC,KAAzB,EAAiC;AAChC,MAAK,OAAOD,GAAP,KAAe,UAApB,EAAiC;AAChCA,IAAAA,GAAG,CAAEC,KAAF,CAAH;AACA,GAFD,MAEO,IAAKD,GAAG,IAAIA,GAAG,CAACE,cAAJ,CAAoB,SAApB,CAAZ,EAA8C;AACpD;;AACA;AAAqDF,IAAAA,GAAF,CAAQG,OAAR,GAClDF,KADkD;AAEnD;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASG,YAAT,CAAuBC,IAAvB,EAA8B;AAC5C,QAAMC,OAAO,GAAGV,MAAM,EAAtB;AACA,QAAMW,UAAU,GAAGX,MAAM,CAAE,KAAF,CAAzB;AACA,QAAMY,gBAAgB,GAAGZ,MAAM,CAAE,KAAF,CAA/B;AACA;;AACA;;AACA;;AACA,QAAMa,YAAY,GAAGb,MAAM,CAAE,EAAF,CAA3B;AACA,QAAMc,WAAW,GAAGd,MAAM,CAAES,IAAF,CAA1B,CAR4C,CAU5C;AACA;;AACAK,EAAAA,WAAW,CAACP,OAAZ,GAAsBE,IAAtB,CAZ4C,CAc5C;AACA;AACA;;AACAP,EAAAA,eAAe,CAAE,MAAM;AACtB,QACCU,gBAAgB,CAACL,OAAjB,KAA6B,KAA7B,IACAI,UAAU,CAACJ,OAAX,KAAuB,IAFxB,EAGE;AACDE,MAAAA,IAAI,CAACM,OAAL,CAAc,CAAEX,GAAF,EAAOY,KAAP,KAAkB;AAC/B,cAAMC,WAAW,GAAGJ,YAAY,CAACN,OAAb,CAAsBS,KAAtB,CAApB;;AACA,YAAKZ,GAAG,KAAKa,WAAb,EAA2B;AAC1Bd,UAAAA,SAAS,CAAEc,WAAF,EAAe,IAAf,CAAT;AACAd,UAAAA,SAAS,CAAEC,GAAF,EAAOM,OAAO,CAACH,OAAf,CAAT;AACA;AACD,OAND;AAOA;;AAEDM,IAAAA,YAAY,CAACN,OAAb,GAAuBE,IAAvB;AACA,GAfc,EAeZA,IAfY,CAAf,CAjB4C,CAkC5C;AACA;;AACAP,EAAAA,eAAe,CAAE,MAAM;AACtBU,IAAAA,gBAAgB,CAACL,OAAjB,GAA2B,KAA3B;AACA,GAFc,CAAf,CApC4C,CAwC5C;AACA;;AACA,SAAON,WAAW,CAAII,KAAF,IAAa;AAChC;AACA;AACAF,IAAAA,SAAS,CAAEO,OAAF,EAAWL,KAAX,CAAT;AAEAO,IAAAA,gBAAgB,CAACL,OAAjB,GAA2B,IAA3B;AACAI,IAAAA,UAAU,CAACJ,OAAX,GAAqBF,KAAK,KAAK,IAA/B,CANgC,CAQhC;AACA;;AACA,UAAMa,YAAY,GAAGb,KAAK,GAAGS,WAAW,CAACP,OAAf,GAAyBM,YAAY,CAACN,OAAhE,CAVgC,CAYhC;;AACA,SAAM,MAAMH,GAAZ,IAAmBc,YAAnB,EAAkC;AACjCf,MAAAA,SAAS,CAAEC,GAAF,EAAOC,KAAP,CAAT;AACA;AACD,GAhBiB,EAgBf,EAhBe,CAAlB;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useCallback, useLayoutEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @template T\n * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * @template T\n * @param {import('react').Ref<T>} ref\n * @param {T} value\n */\nfunction assignRef( ref, value ) {\n\tif ( typeof ref === 'function' ) {\n\t\tref( value );\n\t} else if ( ref && ref.hasOwnProperty( 'current' ) ) {\n\t\t/* eslint-disable jsdoc/no-undefined-types */\n\t\t/** @type {import('react').MutableRefObject<T>} */ ( ref ).current =\n\t\t\tvalue;\n\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t}\n}\n\n/**\n * Merges refs into one ref callback.\n *\n * It also ensures that the merged ref callbacks are only called when they\n * change (as a result of a `useCallback` dependency update) OR when the ref\n * value changes, just as React does when passing a single ref callback to the\n * component.\n *\n * As expected, if you pass a new function on every render, the ref callback\n * will be called after every render.\n *\n * If you don't wish a ref callback to be called after every render, wrap it\n * with `useCallback( callback, dependencies )`. When a dependency changes, the\n * old ref callback will be called with `null` and the new ref callback will be\n * called with the same value.\n *\n * To make ref callbacks easier to use, you can also pass the result of\n * `useRefEffect`, which makes cleanup easier by allowing you to return a\n * cleanup function instead of handling `null`.\n *\n * It's also possible to _disable_ a ref (and its behaviour) by simply not\n * passing the ref.\n *\n * ```jsx\n * const ref = useRefEffect( ( node ) => {\n * node.addEventListener( ... );\n * return () => {\n * node.removeEventListener( ... );\n * };\n * }, [ ...dependencies ] );\n * const otherRef = useRef();\n * const mergedRefs useMergeRefs( [\n * enabled && ref,\n * otherRef,\n * ] );\n * return <div ref={ mergedRefs } />;\n * ```\n *\n * @template {import('react').Ref<any>} TRef\n * @param {Array<TRef>} refs The refs to be merged.\n *\n * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.\n */\nexport default function useMergeRefs( refs ) {\n\tconst element = useRef();\n\tconst isAttached = useRef( false );\n\tconst didElementChange = useRef( false );\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {import('react').MutableRefObject<TRef[]>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst previousRefs = useRef( [] );\n\tconst currentRefs = useRef( refs );\n\n\t// Update on render before the ref callback is called, so the ref callback\n\t// always has access to the current refs.\n\tcurrentRefs.current = refs;\n\n\t// If any of the refs change, call the previous ref with `null` and the new\n\t// ref with the node, except when the element changes in the same cycle, in\n\t// which case the ref callbacks will already have been called.\n\tuseLayoutEffect( () => {\n\t\tif (\n\t\t\tdidElementChange.current === false &&\n\t\t\tisAttached.current === true\n\t\t) {\n\t\t\trefs.forEach( ( ref, index ) => {\n\t\t\t\tconst previousRef = previousRefs.current[ index ];\n\t\t\t\tif ( ref !== previousRef ) {\n\t\t\t\t\tassignRef( previousRef, null );\n\t\t\t\t\tassignRef( ref, element.current );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tpreviousRefs.current = refs;\n\t}, refs );\n\n\t// No dependencies, must be reset after every render so ref callbacks are\n\t// correctly called after a ref change.\n\tuseLayoutEffect( () => {\n\t\tdidElementChange.current = false;\n\t} );\n\n\t// There should be no dependencies so that `callback` is only called when\n\t// the node changes.\n\treturn useCallback( ( value ) => {\n\t\t// Update the element so it can be used when calling ref callbacks on a\n\t\t// dependency change.\n\t\tassignRef( element, value );\n\n\t\tdidElementChange.current = true;\n\t\tisAttached.current = value !== null;\n\n\t\t// When an element changes, the current ref callback should be called\n\t\t// with the new element and the previous one with `null`.\n\t\tconst refsToAssign = value ? currentRefs.current : previousRefs.current;\n\n\t\t// Update the latest refs.\n\t\tfor ( const ref of refsToAssign ) {\n\t\t\tassignRef( ref, value );\n\t\t}\n\t}, [] );\n}\n"]}
1
+ {"version":3,"names":["useRef","useCallback","useLayoutEffect","assignRef","ref","value","hasOwnProperty","current","useMergeRefs","refs","element","isAttached","didElementChange","previousRefs","currentRefs","forEach","index","previousRef","refsToAssign"],"sources":["@wordpress/compose/src/hooks/use-merge-refs/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useCallback, useLayoutEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @template T\n * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * @template T\n * @param {import('react').Ref<T>} ref\n * @param {T} value\n */\nfunction assignRef( ref, value ) {\n\tif ( typeof ref === 'function' ) {\n\t\tref( value );\n\t} else if ( ref && ref.hasOwnProperty( 'current' ) ) {\n\t\t/* eslint-disable jsdoc/no-undefined-types */\n\t\t/** @type {import('react').MutableRefObject<T>} */ ( ref ).current =\n\t\t\tvalue;\n\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t}\n}\n\n/**\n * Merges refs into one ref callback.\n *\n * It also ensures that the merged ref callbacks are only called when they\n * change (as a result of a `useCallback` dependency update) OR when the ref\n * value changes, just as React does when passing a single ref callback to the\n * component.\n *\n * As expected, if you pass a new function on every render, the ref callback\n * will be called after every render.\n *\n * If you don't wish a ref callback to be called after every render, wrap it\n * with `useCallback( callback, dependencies )`. When a dependency changes, the\n * old ref callback will be called with `null` and the new ref callback will be\n * called with the same value.\n *\n * To make ref callbacks easier to use, you can also pass the result of\n * `useRefEffect`, which makes cleanup easier by allowing you to return a\n * cleanup function instead of handling `null`.\n *\n * It's also possible to _disable_ a ref (and its behaviour) by simply not\n * passing the ref.\n *\n * ```jsx\n * const ref = useRefEffect( ( node ) => {\n * node.addEventListener( ... );\n * return () => {\n * node.removeEventListener( ... );\n * };\n * }, [ ...dependencies ] );\n * const otherRef = useRef();\n * const mergedRefs useMergeRefs( [\n * enabled && ref,\n * otherRef,\n * ] );\n * return <div ref={ mergedRefs } />;\n * ```\n *\n * @template {import('react').Ref<any>} TRef\n * @param {Array<TRef>} refs The refs to be merged.\n *\n * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.\n */\nexport default function useMergeRefs( refs ) {\n\tconst element = useRef();\n\tconst isAttached = useRef( false );\n\tconst didElementChange = useRef( false );\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {import('react').MutableRefObject<TRef[]>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst previousRefs = useRef( [] );\n\tconst currentRefs = useRef( refs );\n\n\t// Update on render before the ref callback is called, so the ref callback\n\t// always has access to the current refs.\n\tcurrentRefs.current = refs;\n\n\t// If any of the refs change, call the previous ref with `null` and the new\n\t// ref with the node, except when the element changes in the same cycle, in\n\t// which case the ref callbacks will already have been called.\n\tuseLayoutEffect( () => {\n\t\tif (\n\t\t\tdidElementChange.current === false &&\n\t\t\tisAttached.current === true\n\t\t) {\n\t\t\trefs.forEach( ( ref, index ) => {\n\t\t\t\tconst previousRef = previousRefs.current[ index ];\n\t\t\t\tif ( ref !== previousRef ) {\n\t\t\t\t\tassignRef( previousRef, null );\n\t\t\t\t\tassignRef( ref, element.current );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tpreviousRefs.current = refs;\n\t}, refs );\n\n\t// No dependencies, must be reset after every render so ref callbacks are\n\t// correctly called after a ref change.\n\tuseLayoutEffect( () => {\n\t\tdidElementChange.current = false;\n\t} );\n\n\t// There should be no dependencies so that `callback` is only called when\n\t// the node changes.\n\treturn useCallback( ( value ) => {\n\t\t// Update the element so it can be used when calling ref callbacks on a\n\t\t// dependency change.\n\t\tassignRef( element, value );\n\n\t\tdidElementChange.current = true;\n\t\tisAttached.current = value !== null;\n\n\t\t// When an element changes, the current ref callback should be called\n\t\t// with the new element and the previous one with `null`.\n\t\tconst refsToAssign = value ? currentRefs.current : previousRefs.current;\n\n\t\t// Update the latest refs.\n\t\tfor ( const ref of refsToAssign ) {\n\t\t\tassignRef( ref, value );\n\t\t}\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,WAAW,EAAEC,eAAe,QAAQ,oBAAoB;;AAEzE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAAEC,GAAG,EAAEC,KAAK,EAAG;EAChC,IAAK,OAAOD,GAAG,KAAK,UAAU,EAAG;IAChCA,GAAG,CAAEC,KAAM,CAAC;EACb,CAAC,MAAM,IAAKD,GAAG,IAAIA,GAAG,CAACE,cAAc,CAAE,SAAU,CAAC,EAAG;IACpD;IACA,kDAAqDF,GAAG,CAAGG,OAAO,GACjEF,KAAK;IACN;EACD;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASG,YAAYA,CAAEC,IAAI,EAAG;EAC5C,MAAMC,OAAO,GAAGV,MAAM,CAAC,CAAC;EACxB,MAAMW,UAAU,GAAGX,MAAM,CAAE,KAAM,CAAC;EAClC,MAAMY,gBAAgB,GAAGZ,MAAM,CAAE,KAAM,CAAC;EACxC;EACA;EACA;EACA,MAAMa,YAAY,GAAGb,MAAM,CAAE,EAAG,CAAC;EACjC,MAAMc,WAAW,GAAGd,MAAM,CAAES,IAAK,CAAC;;EAElC;EACA;EACAK,WAAW,CAACP,OAAO,GAAGE,IAAI;;EAE1B;EACA;EACA;EACAP,eAAe,CAAE,MAAM;IACtB,IACCU,gBAAgB,CAACL,OAAO,KAAK,KAAK,IAClCI,UAAU,CAACJ,OAAO,KAAK,IAAI,EAC1B;MACDE,IAAI,CAACM,OAAO,CAAE,CAAEX,GAAG,EAAEY,KAAK,KAAM;QAC/B,MAAMC,WAAW,GAAGJ,YAAY,CAACN,OAAO,CAAES,KAAK,CAAE;QACjD,IAAKZ,GAAG,KAAKa,WAAW,EAAG;UAC1Bd,SAAS,CAAEc,WAAW,EAAE,IAAK,CAAC;UAC9Bd,SAAS,CAAEC,GAAG,EAAEM,OAAO,CAACH,OAAQ,CAAC;QAClC;MACD,CAAE,CAAC;IACJ;IAEAM,YAAY,CAACN,OAAO,GAAGE,IAAI;EAC5B,CAAC,EAAEA,IAAK,CAAC;;EAET;EACA;EACAP,eAAe,CAAE,MAAM;IACtBU,gBAAgB,CAACL,OAAO,GAAG,KAAK;EACjC,CAAE,CAAC;;EAEH;EACA;EACA,OAAON,WAAW,CAAII,KAAK,IAAM;IAChC;IACA;IACAF,SAAS,CAAEO,OAAO,EAAEL,KAAM,CAAC;IAE3BO,gBAAgB,CAACL,OAAO,GAAG,IAAI;IAC/BI,UAAU,CAACJ,OAAO,GAAGF,KAAK,KAAK,IAAI;;IAEnC;IACA;IACA,MAAMa,YAAY,GAAGb,KAAK,GAAGS,WAAW,CAACP,OAAO,GAAGM,YAAY,CAACN,OAAO;;IAEvE;IACA,KAAM,MAAMH,GAAG,IAAIc,YAAY,EAAG;MACjCf,SAAS,CAAEC,GAAG,EAAEC,KAAM,CAAC;IACxB;EACD,CAAC,EAAE,EAAG,CAAC;AACR"}
@@ -3,12 +3,12 @@
3
3
  */
4
4
  import { useState, useEffect } from '@wordpress/element';
5
5
  import { subscribePreferredColorScheme, isInitialColorSchemeDark } from '@wordpress/react-native-bridge';
6
+
6
7
  /**
7
8
  * Returns the color scheme value when it changes. Possible values: [ 'light', 'dark' ]
8
9
  *
9
10
  * @return {string} return current color scheme.
10
11
  */
11
-
12
12
  function usePreferredColorScheme() {
13
13
  const [currentColorScheme, setCurrentColorScheme] = useState(isInitialColorSchemeDark ? 'dark' : 'light');
14
14
  useEffect(() => {
@@ -16,7 +16,6 @@ function usePreferredColorScheme() {
16
16
  isPreferredColorSchemeDark
17
17
  }) => {
18
18
  const colorScheme = isPreferredColorSchemeDark ? 'dark' : 'light';
19
-
20
19
  if (colorScheme !== currentColorScheme) {
21
20
  setCurrentColorScheme(colorScheme);
22
21
  }
@@ -24,6 +23,5 @@ function usePreferredColorScheme() {
24
23
  });
25
24
  return currentColorScheme;
26
25
  }
27
-
28
26
  export default usePreferredColorScheme;
29
27
  //# sourceMappingURL=index.android.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-preferred-color-scheme/index.android.js"],"names":["useState","useEffect","subscribePreferredColorScheme","isInitialColorSchemeDark","usePreferredColorScheme","currentColorScheme","setCurrentColorScheme","isPreferredColorSchemeDark","colorScheme"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SACCC,6BADD,EAECC,wBAFD,QAGO,gCAHP;AAKA;AACA;AACA;AACA;AACA;;AACA,SAASC,uBAAT,GAAmC;AAClC,QAAM,CAAEC,kBAAF,EAAsBC,qBAAtB,IAAgDN,QAAQ,CAC7DG,wBAAwB,GAAG,MAAH,GAAY,OADyB,CAA9D;AAGAF,EAAAA,SAAS,CAAE,MAAM;AAChBC,IAAAA,6BAA6B,CAAE,CAAE;AAAEK,MAAAA;AAAF,KAAF,KAAsC;AACpE,YAAMC,WAAW,GAAGD,0BAA0B,GAAG,MAAH,GAAY,OAA1D;;AACA,UAAKC,WAAW,KAAKH,kBAArB,EAA0C;AACzCC,QAAAA,qBAAqB,CAAEE,WAAF,CAArB;AACA;AACD,KAL4B,CAA7B;AAMA,GAPQ,CAAT;AAQA,SAAOH,kBAAP;AACA;;AAED,eAAeD,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tsubscribePreferredColorScheme,\n\tisInitialColorSchemeDark,\n} from '@wordpress/react-native-bridge';\n\n/**\n * Returns the color scheme value when it changes. Possible values: [ 'light', 'dark' ]\n *\n * @return {string} return current color scheme.\n */\nfunction usePreferredColorScheme() {\n\tconst [ currentColorScheme, setCurrentColorScheme ] = useState(\n\t\tisInitialColorSchemeDark ? 'dark' : 'light'\n\t);\n\tuseEffect( () => {\n\t\tsubscribePreferredColorScheme( ( { isPreferredColorSchemeDark } ) => {\n\t\t\tconst colorScheme = isPreferredColorSchemeDark ? 'dark' : 'light';\n\t\t\tif ( colorScheme !== currentColorScheme ) {\n\t\t\t\tsetCurrentColorScheme( colorScheme );\n\t\t\t}\n\t\t} );\n\t} );\n\treturn currentColorScheme;\n}\n\nexport default usePreferredColorScheme;\n"]}
1
+ {"version":3,"names":["useState","useEffect","subscribePreferredColorScheme","isInitialColorSchemeDark","usePreferredColorScheme","currentColorScheme","setCurrentColorScheme","isPreferredColorSchemeDark","colorScheme"],"sources":["@wordpress/compose/src/hooks/use-preferred-color-scheme/index.android.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tsubscribePreferredColorScheme,\n\tisInitialColorSchemeDark,\n} from '@wordpress/react-native-bridge';\n\n/**\n * Returns the color scheme value when it changes. Possible values: [ 'light', 'dark' ]\n *\n * @return {string} return current color scheme.\n */\nfunction usePreferredColorScheme() {\n\tconst [ currentColorScheme, setCurrentColorScheme ] = useState(\n\t\tisInitialColorSchemeDark ? 'dark' : 'light'\n\t);\n\tuseEffect( () => {\n\t\tsubscribePreferredColorScheme( ( { isPreferredColorSchemeDark } ) => {\n\t\t\tconst colorScheme = isPreferredColorSchemeDark ? 'dark' : 'light';\n\t\t\tif ( colorScheme !== currentColorScheme ) {\n\t\t\t\tsetCurrentColorScheme( colorScheme );\n\t\t\t}\n\t\t} );\n\t} );\n\treturn currentColorScheme;\n}\n\nexport default usePreferredColorScheme;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;AACxD,SACCC,6BAA6B,EAC7BC,wBAAwB,QAClB,gCAAgC;;AAEvC;AACA;AACA;AACA;AACA;AACA,SAASC,uBAAuBA,CAAA,EAAG;EAClC,MAAM,CAAEC,kBAAkB,EAAEC,qBAAqB,CAAE,GAAGN,QAAQ,CAC7DG,wBAAwB,GAAG,MAAM,GAAG,OACrC,CAAC;EACDF,SAAS,CAAE,MAAM;IAChBC,6BAA6B,CAAE,CAAE;MAAEK;IAA2B,CAAC,KAAM;MACpE,MAAMC,WAAW,GAAGD,0BAA0B,GAAG,MAAM,GAAG,OAAO;MACjE,IAAKC,WAAW,KAAKH,kBAAkB,EAAG;QACzCC,qBAAqB,CAAEE,WAAY,CAAC;MACrC;IACD,CAAE,CAAC;EACJ,CAAE,CAAC;EACH,OAAOH,kBAAkB;AAC1B;AAEA,eAAeD,uBAAuB"}
@@ -2,12 +2,12 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { useColorScheme } from 'react-native';
5
+
5
6
  /**
6
7
  * Returns the color scheme value when it changes. Possible values: [ 'light', 'dark' ]
7
8
  *
8
9
  * @return {string} return current color scheme.
9
10
  */
10
-
11
11
  const usePreferredColorScheme = useColorScheme;
12
12
  export default usePreferredColorScheme;
13
13
  //# sourceMappingURL=index.ios.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-preferred-color-scheme/index.ios.js"],"names":["useColorScheme","usePreferredColorScheme"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAT,QAA+B,cAA/B;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAGD,cAAhC;AAEA,eAAeC,uBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { useColorScheme } from 'react-native';\n\n/**\n * Returns the color scheme value when it changes. Possible values: [ 'light', 'dark' ]\n *\n * @return {string} return current color scheme.\n */\nconst usePreferredColorScheme = useColorScheme;\n\nexport default usePreferredColorScheme;\n"]}
1
+ {"version":3,"names":["useColorScheme","usePreferredColorScheme"],"sources":["@wordpress/compose/src/hooks/use-preferred-color-scheme/index.ios.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useColorScheme } from 'react-native';\n\n/**\n * Returns the color scheme value when it changes. Possible values: [ 'light', 'dark' ]\n *\n * @return {string} return current color scheme.\n */\nconst usePreferredColorScheme = useColorScheme;\n\nexport default usePreferredColorScheme;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,cAAc;;AAE7C;AACA;AACA;AACA;AACA;AACA,MAAMC,uBAAuB,GAAGD,cAAc;AAE9C,eAAeC,uBAAuB"}
@@ -2,6 +2,7 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import usePreferredColorScheme from '../use-preferred-color-scheme';
5
+
5
6
  /**
6
7
  * Selects which of the passed style objects should be applied depending on the
7
8
  * user's preferred color scheme.
@@ -22,14 +23,13 @@ import usePreferredColorScheme from '../use-preferred-color-scheme';
22
23
  * @param {Object} darkStyle
23
24
  * @return {Object} the combined styles depending on the current color scheme
24
25
  */
25
-
26
26
  const usePreferredColorSchemeStyle = (lightStyle, darkStyle) => {
27
27
  const colorScheme = usePreferredColorScheme();
28
28
  const isDarkMode = colorScheme === 'dark';
29
- return isDarkMode ? { ...lightStyle,
29
+ return isDarkMode ? {
30
+ ...lightStyle,
30
31
  ...darkStyle
31
32
  } : lightStyle;
32
33
  };
33
-
34
34
  export default usePreferredColorSchemeStyle;
35
35
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-preferred-color-scheme-style/index.native.js"],"names":["usePreferredColorScheme","usePreferredColorSchemeStyle","lightStyle","darkStyle","colorScheme","isDarkMode"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,uBAAP,MAAoC,+BAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,4BAA4B,GAAG,CAAEC,UAAF,EAAcC,SAAd,KAA6B;AACjE,QAAMC,WAAW,GAAGJ,uBAAuB,EAA3C;AACA,QAAMK,UAAU,GAAGD,WAAW,KAAK,MAAnC;AAEA,SAAOC,UAAU,GAAG,EAAE,GAAGH,UAAL;AAAiB,OAAGC;AAApB,GAAH,GAAqCD,UAAtD;AACA,CALD;;AAOA,eAAeD,4BAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport usePreferredColorScheme from '../use-preferred-color-scheme';\n\n/**\n * Selects which of the passed style objects should be applied depending on the\n * user's preferred color scheme.\n *\n * The \"light\" color schemed is assumed to be the default, and its styles are\n * always applied. The \"dark\" styles will always extend those defined for the\n * light case.\n *\n * @example\n * const light = { padding: 10, backgroundColor: 'white' };\n * const dark = { backgroundColor: 'black' };\n * usePreferredColorSchemeStyle( light, dark);\n * // On light mode:\n * // => { padding: 10, backgroundColor: 'white' }\n * // On dark mode:\n * // => { padding: 10, backgroundColor: 'black' }\n * @param {Object} lightStyle\n * @param {Object} darkStyle\n * @return {Object} the combined styles depending on the current color scheme\n */\nconst usePreferredColorSchemeStyle = ( lightStyle, darkStyle ) => {\n\tconst colorScheme = usePreferredColorScheme();\n\tconst isDarkMode = colorScheme === 'dark';\n\n\treturn isDarkMode ? { ...lightStyle, ...darkStyle } : lightStyle;\n};\n\nexport default usePreferredColorSchemeStyle;\n"]}
1
+ {"version":3,"names":["usePreferredColorScheme","usePreferredColorSchemeStyle","lightStyle","darkStyle","colorScheme","isDarkMode"],"sources":["@wordpress/compose/src/hooks/use-preferred-color-scheme-style/index.native.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport usePreferredColorScheme from '../use-preferred-color-scheme';\n\n/**\n * Selects which of the passed style objects should be applied depending on the\n * user's preferred color scheme.\n *\n * The \"light\" color schemed is assumed to be the default, and its styles are\n * always applied. The \"dark\" styles will always extend those defined for the\n * light case.\n *\n * @example\n * const light = { padding: 10, backgroundColor: 'white' };\n * const dark = { backgroundColor: 'black' };\n * usePreferredColorSchemeStyle( light, dark);\n * // On light mode:\n * // => { padding: 10, backgroundColor: 'white' }\n * // On dark mode:\n * // => { padding: 10, backgroundColor: 'black' }\n * @param {Object} lightStyle\n * @param {Object} darkStyle\n * @return {Object} the combined styles depending on the current color scheme\n */\nconst usePreferredColorSchemeStyle = ( lightStyle, darkStyle ) => {\n\tconst colorScheme = usePreferredColorScheme();\n\tconst isDarkMode = colorScheme === 'dark';\n\n\treturn isDarkMode ? { ...lightStyle, ...darkStyle } : lightStyle;\n};\n\nexport default usePreferredColorSchemeStyle;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,uBAAuB,MAAM,+BAA+B;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,4BAA4B,GAAGA,CAAEC,UAAU,EAAEC,SAAS,KAAM;EACjE,MAAMC,WAAW,GAAGJ,uBAAuB,CAAC,CAAC;EAC7C,MAAMK,UAAU,GAAGD,WAAW,KAAK,MAAM;EAEzC,OAAOC,UAAU,GAAG;IAAE,GAAGH,UAAU;IAAE,GAAGC;EAAU,CAAC,GAAGD,UAAU;AACjE,CAAC;AAED,eAAeD,4BAA4B"}
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useEffect, useRef } from '@wordpress/element';
5
+
5
6
  /**
6
7
  * Use something's value from the previous render.
7
8
  * Based on https://usehooks.com/usePrevious/.
@@ -10,15 +11,15 @@ import { useEffect, useRef } from '@wordpress/element';
10
11
  *
11
12
  * @return The value from the previous render.
12
13
  */
13
-
14
14
  export default function usePrevious(value) {
15
- const ref = useRef(); // Store current value in ref.
15
+ const ref = useRef();
16
16
 
17
+ // Store current value in ref.
17
18
  useEffect(() => {
18
19
  ref.current = value;
19
20
  }, [value]); // Re-run when value changes.
20
- // Return previous value (happens before update in useEffect above).
21
21
 
22
+ // Return previous value (happens before update in useEffect above).
22
23
  return ref.current;
23
24
  }
24
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-previous/index.ts"],"names":["useEffect","useRef","usePrevious","value","ref","current"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAA2BC,KAA3B,EAAqD;AACnE,QAAMC,GAAG,GAAGH,MAAM,EAAlB,CADmE,CAGnE;;AACAD,EAAAA,SAAS,CAAE,MAAM;AAChBI,IAAAA,GAAG,CAACC,OAAJ,GAAcF,KAAd;AACA,GAFQ,EAEN,CAAEA,KAAF,CAFM,CAAT,CAJmE,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"]}
1
+ {"version":3,"names":["useEffect","useRef","usePrevious","value","ref","current"],"sources":["@wordpress/compose/src/hooks/use-previous/index.ts"],"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"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAAOC,KAAQ,EAAkB;EACnE,MAAMC,GAAG,GAAGH,MAAM,CAAM,CAAC;;EAEzB;EACAD,SAAS,CAAE,MAAM;IAChBI,GAAG,CAACC,OAAO,GAAGF,KAAK;EACpB,CAAC,EAAE,CAAEA,KAAK,CAAG,CAAC,CAAC,CAAC;;EAEhB;EACA,OAAOC,GAAG,CAACC,OAAO;AACnB"}
@@ -2,13 +2,12 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import useMediaQuery from '../use-media-query';
5
+
5
6
  /**
6
7
  * Hook returning whether the user has a preference for reduced motion.
7
8
  *
8
9
  * @return {boolean} Reduced motion preference value.
9
10
  */
10
-
11
11
  const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)');
12
-
13
12
  export default useReducedMotion;
14
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-reduced-motion/index.js"],"names":["useMediaQuery","useReducedMotion"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,oBAA1B;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,MACxBD,aAAa,CAAE,kCAAF,CADd;;AAGA,eAAeC,gBAAf","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"]}
1
+ {"version":3,"names":["useMediaQuery","useReducedMotion"],"sources":["@wordpress/compose/src/hooks/use-reduced-motion/index.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,oBAAoB;;AAE9C;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAGA,CAAA,KACxBD,aAAa,CAAE,kCAAmC,CAAC;AAEpD,eAAeC,gBAAgB"}
@@ -6,6 +6,7 @@
6
6
  * WordPress dependencies
7
7
  */
8
8
  import { useCallback, useRef } from '@wordpress/element';
9
+
9
10
  /**
10
11
  * Effect-like ref callback. Just like with `useEffect`, this allows you to
11
12
  * return a cleanup function to be run if the ref changes or one of the
@@ -25,7 +26,6 @@ import { useCallback, useRef } from '@wordpress/element';
25
26
  *
26
27
  * @return Ref callback.
27
28
  */
28
-
29
29
  export default function useRefEffect(callback, dependencies) {
30
30
  const cleanup = useRef();
31
31
  return useCallback(node => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-ref-effect/index.ts"],"names":["useCallback","useRef","useRefEffect","callback","dependencies","cleanup","node","current"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,YAAT,CACdC,QADc,EAEdC,YAFc,EAGmB;AACjC,QAAMC,OAAO,GAAGJ,MAAM,EAAtB;AACA,SAAOD,WAAW,CAAIM,IAAF,IAA6B;AAChD,QAAKA,IAAL,EAAY;AACXD,MAAAA,OAAO,CAACE,OAAR,GAAkBJ,QAAQ,CAAEG,IAAF,CAA1B;AACA,KAFD,MAEO,IAAKD,OAAO,CAACE,OAAb,EAAuB;AAC7BF,MAAAA,OAAO,CAACE,OAAR;AACA;AACD,GANiB,EAMfH,YANe,CAAlB;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport type { DependencyList, RefCallback } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\n\n/**\n * Effect-like ref callback. Just like with `useEffect`, this allows you to\n * return a cleanup function to be run if the ref changes or one of the\n * dependencies changes. The ref is provided as an argument to the callback\n * functions. The main difference between this and `useEffect` is that\n * the `useEffect` callback is not called when the ref changes, but this is.\n * Pass the returned ref callback as the component's ref and merge multiple refs\n * with `useMergeRefs`.\n *\n * It's worth noting that if the dependencies array is empty, there's not\n * strictly a need to clean up event handlers for example, because the node is\n * to be removed. It *is* necessary if you add dependencies because the ref\n * callback will be called multiple times for the same node.\n *\n * @param callback Callback with ref as argument.\n * @param dependencies Dependencies of the callback.\n *\n * @return Ref callback.\n */\nexport default function useRefEffect< TElement = Node >(\n\tcallback: ( node: TElement ) => ( () => void ) | void,\n\tdependencies: DependencyList\n): RefCallback< TElement | null > {\n\tconst cleanup = useRef< ( () => void ) | void >();\n\treturn useCallback( ( node: TElement | null ) => {\n\t\tif ( node ) {\n\t\t\tcleanup.current = callback( node );\n\t\t} else if ( cleanup.current ) {\n\t\t\tcleanup.current();\n\t\t}\n\t}, dependencies );\n}\n"]}
1
+ {"version":3,"names":["useCallback","useRef","useRefEffect","callback","dependencies","cleanup","node","current"],"sources":["@wordpress/compose/src/hooks/use-ref-effect/index.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { DependencyList, RefCallback } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\n\n/**\n * Effect-like ref callback. Just like with `useEffect`, this allows you to\n * return a cleanup function to be run if the ref changes or one of the\n * dependencies changes. The ref is provided as an argument to the callback\n * functions. The main difference between this and `useEffect` is that\n * the `useEffect` callback is not called when the ref changes, but this is.\n * Pass the returned ref callback as the component's ref and merge multiple refs\n * with `useMergeRefs`.\n *\n * It's worth noting that if the dependencies array is empty, there's not\n * strictly a need to clean up event handlers for example, because the node is\n * to be removed. It *is* necessary if you add dependencies because the ref\n * callback will be called multiple times for the same node.\n *\n * @param callback Callback with ref as argument.\n * @param dependencies Dependencies of the callback.\n *\n * @return Ref callback.\n */\nexport default function useRefEffect< TElement = Node >(\n\tcallback: ( node: TElement ) => ( () => void ) | void,\n\tdependencies: DependencyList\n): RefCallback< TElement | null > {\n\tconst cleanup = useRef< ( () => void ) | void >();\n\treturn useCallback( ( node: TElement | null ) => {\n\t\tif ( node ) {\n\t\t\tcleanup.current = callback( node );\n\t\t} else if ( cleanup.current ) {\n\t\t\tcleanup.current();\n\t\t}\n\t}, dependencies );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CACnCC,QAAqD,EACrDC,YAA4B,EACK;EACjC,MAAMC,OAAO,GAAGJ,MAAM,CAA0B,CAAC;EACjD,OAAOD,WAAW,CAAIM,IAAqB,IAAM;IAChD,IAAKA,IAAI,EAAG;MACXD,OAAO,CAACE,OAAO,GAAGJ,QAAQ,CAAEG,IAAK,CAAC;IACnC,CAAC,MAAM,IAAKD,OAAO,CAACE,OAAO,EAAG;MAC7BF,OAAO,CAACE,OAAO,CAAC,CAAC;IAClB;EACD,CAAC,EAAEH,YAAa,CAAC;AAClB"}