@wordpress/compose 6.15.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 (211) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/build/higher-order/compose.js +0 -2
  4. package/build/higher-order/compose.js.map +1 -1
  5. package/build/higher-order/if-condition/index.js +2 -6
  6. package/build/higher-order/if-condition/index.js.map +1 -1
  7. package/build/higher-order/pipe.js +1 -5
  8. package/build/higher-order/pipe.js.map +1 -1
  9. package/build/higher-order/pure/index.js +2 -10
  10. package/build/higher-order/pure/index.js.map +1 -1
  11. package/build/higher-order/with-global-events/index.js +13 -32
  12. package/build/higher-order/with-global-events/index.js.map +1 -1
  13. package/build/higher-order/with-global-events/listener.js +5 -28
  14. package/build/higher-order/with-global-events/listener.js.map +1 -1
  15. package/build/higher-order/with-instance-id/index.js +4 -8
  16. package/build/higher-order/with-instance-id/index.js.map +1 -1
  17. package/build/higher-order/with-preferred-color-scheme/index.native.js +3 -6
  18. package/build/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  19. package/build/higher-order/with-safe-timeout/index.js +4 -14
  20. package/build/higher-order/with-safe-timeout/index.js.map +1 -1
  21. package/build/higher-order/with-state/index.js +3 -11
  22. package/build/higher-order/with-state/index.js.map +1 -1
  23. package/build/hooks/use-async-list/index.js +1 -14
  24. package/build/hooks/use-async-list/index.js.map +1 -1
  25. package/build/hooks/use-constrained-tabbing/index.js +14 -30
  26. package/build/hooks/use-constrained-tabbing/index.js.map +1 -1
  27. package/build/hooks/use-constrained-tabbing/index.native.js +4 -4
  28. package/build/hooks/use-constrained-tabbing/index.native.js.map +1 -1
  29. package/build/hooks/use-copy-on-click/index.js +6 -15
  30. package/build/hooks/use-copy-on-click/index.js.map +1 -1
  31. package/build/hooks/use-copy-to-clipboard/index.js +3 -11
  32. package/build/hooks/use-copy-to-clipboard/index.js.map +1 -1
  33. package/build/hooks/use-debounce/index.js +0 -4
  34. package/build/hooks/use-debounce/index.js.map +1 -1
  35. package/build/hooks/use-dialog/index.js +2 -12
  36. package/build/hooks/use-dialog/index.js.map +1 -1
  37. package/build/hooks/use-disabled/index.js +5 -15
  38. package/build/hooks/use-disabled/index.js.map +1 -1
  39. package/build/hooks/use-dragging/index.js +4 -11
  40. package/build/hooks/use-dragging/index.js.map +1 -1
  41. package/build/hooks/use-drop-zone/index.js +27 -66
  42. package/build/hooks/use-drop-zone/index.js.map +1 -1
  43. package/build/hooks/use-fixed-window-list/index.js +8 -34
  44. package/build/hooks/use-fixed-window-list/index.js.map +1 -1
  45. package/build/hooks/use-focus-on-mount/index.js +3 -14
  46. package/build/hooks/use-focus-on-mount/index.js.map +1 -1
  47. package/build/hooks/use-focus-outside/index.js +13 -19
  48. package/build/hooks/use-focus-outside/index.js.map +1 -1
  49. package/build/hooks/use-focus-outside/index.native.js +13 -21
  50. package/build/hooks/use-focus-outside/index.native.js.map +1 -1
  51. package/build/hooks/use-focus-return/index.js +14 -16
  52. package/build/hooks/use-focus-return/index.js.map +1 -1
  53. package/build/hooks/use-focusable-iframe/index.js +1 -5
  54. package/build/hooks/use-focusable-iframe/index.js.map +1 -1
  55. package/build/hooks/use-instance-id/index.js +3 -5
  56. package/build/hooks/use-instance-id/index.js.map +1 -1
  57. package/build/hooks/use-isomorphic-layout-effect/index.js +0 -2
  58. package/build/hooks/use-isomorphic-layout-effect/index.js.map +1 -1
  59. package/build/hooks/use-keyboard-shortcut/index.js +12 -28
  60. package/build/hooks/use-keyboard-shortcut/index.js.map +1 -1
  61. package/build/hooks/use-keyboard-shortcut/index.native.js +0 -2
  62. package/build/hooks/use-keyboard-shortcut/index.native.js.map +1 -1
  63. package/build/hooks/use-media-query/index.js +1 -9
  64. package/build/hooks/use-media-query/index.js.map +1 -1
  65. package/build/hooks/use-merge-refs/index.js +18 -24
  66. package/build/hooks/use-merge-refs/index.js.map +1 -1
  67. package/build/hooks/use-preferred-color-scheme/index.android.js +0 -5
  68. package/build/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
  69. package/build/hooks/use-preferred-color-scheme/index.ios.js +0 -2
  70. package/build/hooks/use-preferred-color-scheme/index.ios.js.map +1 -1
  71. package/build/hooks/use-preferred-color-scheme-style/index.native.js +2 -5
  72. package/build/hooks/use-preferred-color-scheme-style/index.native.js.map +1 -1
  73. package/build/hooks/use-previous/index.js +3 -4
  74. package/build/hooks/use-previous/index.js.map +1 -1
  75. package/build/hooks/use-reduced-motion/index.js +0 -4
  76. package/build/hooks/use-reduced-motion/index.js.map +1 -1
  77. package/build/hooks/use-ref-effect/index.js +0 -2
  78. package/build/hooks/use-ref-effect/index.js.map +1 -1
  79. package/build/hooks/use-resize-observer/index.js +23 -30
  80. package/build/hooks/use-resize-observer/index.js.map +1 -1
  81. package/build/hooks/use-resize-observer/index.native.js +0 -6
  82. package/build/hooks/use-resize-observer/index.native.js.map +1 -1
  83. package/build/hooks/use-throttle/index.js +0 -4
  84. package/build/hooks/use-throttle/index.js.map +1 -1
  85. package/build/hooks/use-viewport-match/index.js +4 -13
  86. package/build/hooks/use-viewport-match/index.js.map +1 -1
  87. package/build/hooks/use-warn-on-change/index.js +4 -14
  88. package/build/hooks/use-warn-on-change/index.js.map +1 -1
  89. package/build/index.js +0 -41
  90. package/build/index.js.map +1 -1
  91. package/build/index.native.js +0 -33
  92. package/build/index.native.js.map +1 -1
  93. package/build/utils/create-higher-order-component/index.js +1 -4
  94. package/build/utils/create-higher-order-component/index.js.map +1 -1
  95. package/build/utils/debounce/index.js +12 -37
  96. package/build/utils/debounce/index.js.map +1 -1
  97. package/build/utils/throttle/index.js +0 -5
  98. package/build/utils/throttle/index.js.map +1 -1
  99. package/build-module/higher-order/compose.js +1 -1
  100. package/build-module/higher-order/compose.js.map +1 -1
  101. package/build-module/higher-order/if-condition/index.js +3 -5
  102. package/build-module/higher-order/if-condition/index.js.map +1 -1
  103. package/build-module/higher-order/pipe.js +1 -4
  104. package/build-module/higher-order/pipe.js.map +1 -1
  105. package/build-module/higher-order/pure/index.js +4 -8
  106. package/build-module/higher-order/pure/index.js.map +1 -1
  107. package/build-module/higher-order/with-global-events/index.js +15 -29
  108. package/build-module/higher-order/with-global-events/index.js.map +1 -1
  109. package/build-module/higher-order/with-global-events/listener.js +5 -27
  110. package/build-module/higher-order/with-global-events/listener.js.map +1 -1
  111. package/build-module/higher-order/with-instance-id/index.js +5 -5
  112. package/build-module/higher-order/with-instance-id/index.js.map +1 -1
  113. package/build-module/higher-order/with-preferred-color-scheme/index.native.js +3 -3
  114. package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  115. package/build-module/higher-order/with-safe-timeout/index.js +6 -8
  116. package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
  117. package/build-module/higher-order/with-state/index.js +5 -9
  118. package/build-module/higher-order/with-state/index.js.map +1 -1
  119. package/build-module/hooks/use-async-list/index.js +1 -12
  120. package/build-module/hooks/use-async-list/index.js.map +1 -1
  121. package/build-module/hooks/use-constrained-tabbing/index.js +16 -27
  122. package/build-module/hooks/use-constrained-tabbing/index.js.map +1 -1
  123. package/build-module/hooks/use-constrained-tabbing/index.native.js +3 -3
  124. package/build-module/hooks/use-constrained-tabbing/index.native.js.map +1 -1
  125. package/build-module/hooks/use-copy-on-click/index.js +8 -12
  126. package/build-module/hooks/use-copy-on-click/index.js.map +1 -1
  127. package/build-module/hooks/use-copy-to-clipboard/index.js +6 -9
  128. package/build-module/hooks/use-copy-to-clipboard/index.js.map +1 -1
  129. package/build-module/hooks/use-debounce/index.js +3 -3
  130. package/build-module/hooks/use-debounce/index.js.map +1 -1
  131. package/build-module/hooks/use-dialog/index.js +3 -5
  132. package/build-module/hooks/use-dialog/index.js.map +1 -1
  133. package/build-module/hooks/use-disabled/index.js +6 -12
  134. package/build-module/hooks/use-disabled/index.js.map +1 -1
  135. package/build-module/hooks/use-dragging/index.js +6 -9
  136. package/build-module/hooks/use-dragging/index.js.map +1 -1
  137. package/build-module/hooks/use-drop-zone/index.js +29 -64
  138. package/build-module/hooks/use-drop-zone/index.js.map +1 -1
  139. package/build-module/hooks/use-fixed-window-list/index.js +8 -30
  140. package/build-module/hooks/use-fixed-window-list/index.js.map +1 -1
  141. package/build-module/hooks/use-focus-on-mount/index.js +4 -12
  142. package/build-module/hooks/use-focus-on-mount/index.js.map +1 -1
  143. package/build-module/hooks/use-focus-outside/index.js +14 -18
  144. package/build-module/hooks/use-focus-outside/index.js.map +1 -1
  145. package/build-module/hooks/use-focus-outside/index.native.js +14 -20
  146. package/build-module/hooks/use-focus-outside/index.native.js.map +1 -1
  147. package/build-module/hooks/use-focus-return/index.js +15 -15
  148. package/build-module/hooks/use-focus-return/index.js.map +1 -1
  149. package/build-module/hooks/use-focusable-iframe/index.js +2 -3
  150. package/build-module/hooks/use-focusable-iframe/index.js.map +1 -1
  151. package/build-module/hooks/use-instance-id/index.js +2 -3
  152. package/build-module/hooks/use-instance-id/index.js.map +1 -1
  153. package/build-module/hooks/use-isomorphic-layout-effect/index.js +1 -1
  154. package/build-module/hooks/use-isomorphic-layout-effect/index.js.map +1 -1
  155. package/build-module/hooks/use-keyboard-shortcut/index.js +14 -24
  156. package/build-module/hooks/use-keyboard-shortcut/index.js.map +1 -1
  157. package/build-module/hooks/use-keyboard-shortcut/index.native.js +0 -1
  158. package/build-module/hooks/use-keyboard-shortcut/index.native.js.map +1 -1
  159. package/build-module/hooks/use-media-query/index.js +2 -8
  160. package/build-module/hooks/use-media-query/index.js.map +1 -1
  161. package/build-module/hooks/use-merge-refs/index.js +19 -23
  162. package/build-module/hooks/use-merge-refs/index.js.map +1 -1
  163. package/build-module/hooks/use-preferred-color-scheme/index.android.js +1 -3
  164. package/build-module/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
  165. package/build-module/hooks/use-preferred-color-scheme/index.ios.js +1 -1
  166. package/build-module/hooks/use-preferred-color-scheme/index.ios.js.map +1 -1
  167. package/build-module/hooks/use-preferred-color-scheme-style/index.native.js +3 -3
  168. package/build-module/hooks/use-preferred-color-scheme-style/index.native.js.map +1 -1
  169. package/build-module/hooks/use-previous/index.js +4 -3
  170. package/build-module/hooks/use-previous/index.js.map +1 -1
  171. package/build-module/hooks/use-reduced-motion/index.js +1 -2
  172. package/build-module/hooks/use-reduced-motion/index.js.map +1 -1
  173. package/build-module/hooks/use-ref-effect/index.js +1 -1
  174. package/build-module/hooks/use-ref-effect/index.js.map +1 -1
  175. package/build-module/hooks/use-resize-observer/index.js +22 -30
  176. package/build-module/hooks/use-resize-observer/index.js.map +1 -1
  177. package/build-module/hooks/use-resize-observer/index.native.js +1 -6
  178. package/build-module/hooks/use-resize-observer/index.native.js.map +1 -1
  179. package/build-module/hooks/use-throttle/index.js +3 -3
  180. package/build-module/hooks/use-throttle/index.js.map +1 -1
  181. package/build-module/hooks/use-viewport-match/index.js +6 -11
  182. package/build-module/hooks/use-viewport-match/index.js.map +1 -1
  183. package/build-module/hooks/use-warn-on-change/index.js +6 -12
  184. package/build-module/hooks/use-warn-on-change/index.js.map +1 -1
  185. package/build-module/index.js +10 -7
  186. package/build-module/index.js.map +1 -1
  187. package/build-module/index.native.js +10 -7
  188. package/build-module/index.native.js.map +1 -1
  189. package/build-module/utils/create-higher-order-component/index.js +1 -2
  190. package/build-module/utils/create-higher-order-component/index.js.map +1 -1
  191. package/build-module/utils/debounce/index.js +12 -35
  192. package/build-module/utils/debounce/index.js.map +1 -1
  193. package/build-module/utils/throttle/index.js +0 -3
  194. package/build-module/utils/throttle/index.js.map +1 -1
  195. package/build-types/higher-order/with-instance-id/index.d.ts +1 -1
  196. package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
  197. package/build-types/higher-order/with-safe-timeout/index.d.ts +1 -1
  198. package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
  199. package/build-types/hooks/use-disabled/index.d.ts +1 -1
  200. package/build-types/hooks/use-disabled/index.d.ts.map +1 -1
  201. package/build-types/hooks/use-focus-return/index.d.ts +2 -4
  202. package/build-types/hooks/use-focus-return/index.d.ts.map +1 -1
  203. package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts +1 -1
  204. package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts.map +1 -1
  205. package/build-types/hooks/use-viewport-match/index.d.ts +1 -1
  206. package/package.json +8 -8
  207. package/src/higher-order/with-instance-id/index.tsx +2 -2
  208. package/src/higher-order/with-safe-timeout/index.tsx +2 -2
  209. package/src/hooks/use-focus-return/index.js +11 -6
  210. package/src/hooks/use-resize-observer/index.native.js +0 -1
  211. package/tsconfig.tsbuildinfo +1 -1
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * External dependencies
5
4
  */
@@ -8,7 +7,6 @@ import { createElement } from "@wordpress/element";
8
7
  * WordPress dependencies
9
8
  */
10
9
  import { useMemo, useRef, useCallback, useEffect, useState } from '@wordpress/element';
11
-
12
10
  // This of course could've been more streamlined with internal state instead of
13
11
  // refs, but then host hooks / components could not opt out of renders.
14
12
  // This could've been exported to its own module, but the current build doesn't
@@ -19,7 +17,6 @@ function useResolvedElement(subscriber, refOrElement) {
19
17
  const cleanupRef = useRef();
20
18
  const callSubscriber = useCallback(() => {
21
19
  let element = null;
22
-
23
20
  if (callbackRefElement.current) {
24
21
  element = callbackRefElement.current;
25
22
  } else if (refOrElement) {
@@ -29,28 +26,27 @@ function useResolvedElement(subscriber, refOrElement) {
29
26
  element = refOrElement.current;
30
27
  }
31
28
  }
32
-
33
29
  if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.reporter === callSubscriber) {
34
30
  return;
35
31
  }
36
-
37
32
  if (cleanupRef.current) {
38
- cleanupRef.current(); // Making sure the cleanup is not called accidentally multiple times.
39
-
33
+ cleanupRef.current();
34
+ // Making sure the cleanup is not called accidentally multiple times.
40
35
  cleanupRef.current = null;
41
36
  }
42
-
43
37
  lastReportRef.current = {
44
38
  reporter: callSubscriber,
45
39
  element
46
- }; // Only calling the subscriber, if there's an actual element to report.
40
+ };
47
41
 
42
+ // Only calling the subscriber, if there's an actual element to report.
48
43
  if (element) {
49
44
  cleanupRef.current = subscriber(element);
50
45
  }
51
- }, [refOrElement, subscriber]); // On each render, we check whether a ref changed, or if we got a new raw
52
- // element.
46
+ }, [refOrElement, subscriber]);
53
47
 
48
+ // On each render, we check whether a ref changed, or if we got a new raw
49
+ // element.
54
50
  useEffect(() => {
55
51
  // With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a
56
52
  // render accompanying that change as well.
@@ -63,7 +59,6 @@ function useResolvedElement(subscriber, refOrElement) {
63
59
  callSubscriber();
64
60
  }, [callSubscriber]);
65
61
  }
66
-
67
62
  // We're only using the first element of the size sequences, until future versions of the spec solidify on how
68
63
  // exactly it'll be used for fragments in multi-column scenarios:
69
64
  // From the spec:
@@ -99,17 +94,16 @@ const extractSize = (entry, boxProp, sizeType) => {
99
94
  // In real browser implementations of course these objects differ, but the width/height values should be equivalent.
100
95
  return entry.contentRect[sizeType === 'inlineSize' ? 'width' : 'height'];
101
96
  }
102
-
103
97
  return undefined;
104
- } // A couple bytes smaller than calling Array.isArray() and just as effective here.
105
-
98
+ }
106
99
 
107
- return entry[boxProp][0] ? entry[boxProp][0][sizeType] : // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
100
+ // A couple bytes smaller than calling Array.isArray() and just as effective here.
101
+ return entry[boxProp][0] ? entry[boxProp][0][sizeType] :
102
+ // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
108
103
  // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
109
104
  // @ts-ignore
110
105
  entry[boxProp][sizeType];
111
106
  };
112
-
113
107
  function useResizeObserver(opts = {}) {
114
108
  // Saving the callback as a ref. With this, I don't need to put onResize in the
115
109
  // effect dep array, and just passing in an anonymous function without memoising
@@ -117,30 +111,34 @@ function useResizeObserver(opts = {}) {
117
111
  const onResize = opts.onResize;
118
112
  const onResizeRef = useRef(undefined);
119
113
  onResizeRef.current = onResize;
120
- const round = opts.round || Math.round; // Using a single instance throughout the hook's lifetime
114
+ const round = opts.round || Math.round;
121
115
 
116
+ // Using a single instance throughout the hook's lifetime
122
117
  const resizeObserverRef = useRef();
123
118
  const [size, setSize] = useState({
124
119
  width: undefined,
125
120
  height: undefined
126
- }); // In certain edge cases the RO might want to report a size change just after
127
- // the component unmounted.
121
+ });
128
122
 
123
+ // In certain edge cases the RO might want to report a size change just after
124
+ // the component unmounted.
129
125
  const didUnmount = useRef(false);
130
126
  useEffect(() => {
131
127
  didUnmount.current = false;
132
128
  return () => {
133
129
  didUnmount.current = true;
134
130
  };
135
- }, []); // Using a ref to track the previous width / height to avoid unnecessary renders.
131
+ }, []);
136
132
 
133
+ // Using a ref to track the previous width / height to avoid unnecessary renders.
137
134
  const previous = useRef({
138
135
  width: undefined,
139
136
  height: undefined
140
- }); // This block is kinda like a useEffect, only it's called whenever a new
137
+ });
138
+
139
+ // This block is kinda like a useEffect, only it's called whenever a new
141
140
  // element could be resolved based on the ref option. It also has a cleanup
142
141
  // function.
143
-
144
142
  const refCallback = useResolvedElement(useCallback(element => {
145
143
  // We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.
146
144
  // This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.
@@ -151,18 +149,15 @@ function useResizeObserver(opts = {}) {
151
149
  instance: new ResizeObserver(entries => {
152
150
  const entry = entries[0];
153
151
  let boxProp = 'borderBoxSize';
154
-
155
152
  if (opts.box === 'border-box') {
156
153
  boxProp = 'borderBoxSize';
157
154
  } else {
158
155
  boxProp = opts.box === 'device-pixel-content-box' ? 'devicePixelContentBoxSize' : 'contentBoxSize';
159
156
  }
160
-
161
157
  const reportedWidth = extractSize(entry, boxProp, 'inlineSize');
162
158
  const reportedHeight = extractSize(entry, boxProp, 'blockSize');
163
159
  const newWidth = reportedWidth ? round(reportedWidth) : undefined;
164
160
  const newHeight = reportedHeight ? round(reportedHeight) : undefined;
165
-
166
161
  if (previous.current.width !== newWidth || previous.current.height !== newHeight) {
167
162
  const newSize = {
168
163
  width: newWidth,
@@ -170,7 +165,6 @@ function useResizeObserver(opts = {}) {
170
165
  };
171
166
  previous.current.width = newWidth;
172
167
  previous.current.height = newHeight;
173
-
174
168
  if (onResizeRef.current) {
175
169
  onResizeRef.current(newSize);
176
170
  } else if (!didUnmount.current) {
@@ -180,7 +174,6 @@ function useResizeObserver(opts = {}) {
180
174
  })
181
175
  };
182
176
  }
183
-
184
177
  resizeObserverRef.current.instance.observe(element, {
185
178
  box: opts.box
186
179
  });
@@ -196,6 +189,7 @@ function useResizeObserver(opts = {}) {
196
189
  height: size.height
197
190
  }), [refCallback, size ? size.width : null, size ? size.height : null]);
198
191
  }
192
+
199
193
  /**
200
194
  * Hook which allows to listen the resize event of any target element when it changes sizes.
201
195
  * _Note: `useResizeObserver` will report `null` until after first render.
@@ -215,8 +209,6 @@ function useResizeObserver(opts = {}) {
215
209
  * };
216
210
  * ```
217
211
  */
218
-
219
-
220
212
  export default function useResizeAware() {
221
213
  const {
222
214
  ref,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-resize-observer/index.tsx"],"names":["useMemo","useRef","useCallback","useEffect","useState","useResolvedElement","subscriber","refOrElement","callbackRefElement","lastReportRef","cleanupRef","callSubscriber","element","current","HTMLElement","reporter","extractSize","entry","boxProp","sizeType","contentRect","undefined","useResizeObserver","opts","onResize","onResizeRef","round","Math","resizeObserverRef","size","setSize","width","height","didUnmount","previous","refCallback","box","instance","ResizeObserver","entries","reportedWidth","reportedHeight","newWidth","newHeight","newSize","observe","unobserve","ref","useResizeAware","sizes","resizeListener","position","top","left","right","bottom","pointerEvents","opacity","overflow","zIndex"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,OADD,EAECC,MAFD,EAGCC,WAHD,EAICC,SAJD,EAKCC,QALD,QAMO,oBANP;;AAYA;AACA;AACA;AACA;AACA,SAASC,kBAAT,CACCC,UADD,EAECC,YAFD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AM,EAAE,CAAC;AATF,KADT;AAYC,mBAAY,MAZb;AAaC,IAAA,GAAG,EAAGZ;AAbP,IADD;AAiBA,SAAO,CAAEG,cAAF,EAAkBD,KAAlB,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport type { RefCallback, RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\nimport type { WPElement } from '@wordpress/element';\n\ntype SubscriberCleanup = () => void;\ntype SubscriberResponse = SubscriberCleanup | void;\n\n// This of course could've been more streamlined with internal state instead of\n// refs, but then host hooks / components could not opt out of renders.\n// This could've been exported to its own module, but the current build doesn't\n// seem to work with module imports and I had no more time to spend on this...\nfunction useResolvedElement< T extends HTMLElement >(\n\tsubscriber: ( element: T ) => SubscriberResponse,\n\trefOrElement?: T | RefObject< T > | null\n): RefCallback< T > {\n\tconst callbackRefElement = useRef< T | null >( null );\n\tconst lastReportRef = useRef< {\n\t\treporter: () => void;\n\t\telement: T | null;\n\t} | null >( null );\n\tconst cleanupRef = useRef< SubscriberResponse | null >();\n\n\tconst callSubscriber = useCallback( () => {\n\t\tlet element = null;\n\t\tif ( callbackRefElement.current ) {\n\t\t\telement = callbackRefElement.current;\n\t\t} else if ( refOrElement ) {\n\t\t\tif ( refOrElement instanceof HTMLElement ) {\n\t\t\t\telement = refOrElement;\n\t\t\t} else {\n\t\t\t\telement = refOrElement.current;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tlastReportRef.current &&\n\t\t\tlastReportRef.current.element === element &&\n\t\t\tlastReportRef.current.reporter === callSubscriber\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( cleanupRef.current ) {\n\t\t\tcleanupRef.current();\n\t\t\t// Making sure the cleanup is not called accidentally multiple times.\n\t\t\tcleanupRef.current = null;\n\t\t}\n\t\tlastReportRef.current = {\n\t\t\treporter: callSubscriber,\n\t\t\telement,\n\t\t};\n\n\t\t// Only calling the subscriber, if there's an actual element to report.\n\t\tif ( element ) {\n\t\t\tcleanupRef.current = subscriber( element );\n\t\t}\n\t}, [ refOrElement, subscriber ] );\n\n\t// On each render, we check whether a ref changed, or if we got a new raw\n\t// element.\n\tuseEffect( () => {\n\t\t// With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a\n\t\t// render accompanying that change as well.\n\t\t// To guarantee we always have the right element, one must use the ref callback provided instead, but we support\n\t\t// RefObjects to make the hook API more convenient in certain cases.\n\t\tcallSubscriber();\n\t}, [ callSubscriber ] );\n\n\treturn useCallback< RefCallback< T > >(\n\t\t( element ) => {\n\t\t\tcallbackRefElement.current = element;\n\t\t\tcallSubscriber();\n\t\t},\n\t\t[ callSubscriber ]\n\t);\n}\n\ntype ObservedSize = {\n\twidth: number | undefined;\n\theight: number | undefined;\n};\n\ntype ResizeHandler = ( size: ObservedSize ) => void;\n\ntype HookResponse< T extends HTMLElement > = {\n\tref: RefCallback< T >;\n} & ObservedSize;\n\n// Declaring my own type here instead of using the one provided by TS (available since 4.2.2), because this way I'm not\n// forcing consumers to use a specific TS version.\ntype ResizeObserverBoxOptions =\n\t| 'border-box'\n\t| 'content-box'\n\t| 'device-pixel-content-box';\n\ndeclare global {\n\tinterface ResizeObserverEntry {\n\t\treadonly devicePixelContentBoxSize: ReadonlyArray< ResizeObserverSize >;\n\t}\n}\n\n// We're only using the first element of the size sequences, until future versions of the spec solidify on how\n// exactly it'll be used for fragments in multi-column scenarios:\n// From the spec:\n// > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,\n// > which occur in multi-column scenarios. However the current definitions of content rect and border box do not\n// > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single\n// > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.\n// > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)\n//\n// Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,\n// regardless of the \"box\" option.\n// The spec states the following on this:\n// > This does not have any impact on which box dimensions are returned to the defined callback when the event\n// > is fired, it solely defines which box the author wishes to observe layout changes on.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// I'm not exactly clear on what this means, especially when you consider a later section stating the following:\n// > This section is non-normative. An author may desire to observe more than one CSS box.\n// > In this case, author will need to use multiple ResizeObservers.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.\n// For this reason I decided to only return the requested size,\n// even though it seems we have access to results for all box types.\n// This also means that we get to keep the current api, being able to return a simple { width, height } pair,\n// regardless of box option.\nconst extractSize = (\n\tentry: ResizeObserverEntry,\n\tboxProp: 'borderBoxSize' | 'contentBoxSize' | 'devicePixelContentBoxSize',\n\tsizeType: keyof ResizeObserverSize\n): number | undefined => {\n\tif ( ! entry[ boxProp ] ) {\n\t\tif ( boxProp === 'contentBoxSize' ) {\n\t\t\t// The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.\n\t\t\t// See the 6th step in the description for the RO algorithm:\n\t\t\t// https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h\n\t\t\t// > Set this.contentRect to logical this.contentBoxSize given target and observedBox of \"content-box\".\n\t\t\t// In real browser implementations of course these objects differ, but the width/height values should be equivalent.\n\t\t\treturn entry.contentRect[\n\t\t\t\tsizeType === 'inlineSize' ? 'width' : 'height'\n\t\t\t];\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t// A couple bytes smaller than calling Array.isArray() and just as effective here.\n\treturn entry[ boxProp ][ 0 ]\n\t\t? entry[ boxProp ][ 0 ][ sizeType ]\n\t\t: // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current\n\t\t // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.\n\t\t // @ts-ignore\n\t\t entry[ boxProp ][ sizeType ];\n};\n\ntype RoundingFunction = ( n: number ) => number;\n\nfunction useResizeObserver< T extends HTMLElement >(\n\topts: {\n\t\tref?: RefObject< T > | T | null | undefined;\n\t\tonResize?: ResizeHandler;\n\t\tbox?: ResizeObserverBoxOptions;\n\t\tround?: RoundingFunction;\n\t} = {}\n): HookResponse< T > {\n\t// Saving the callback as a ref. With this, I don't need to put onResize in the\n\t// effect dep array, and just passing in an anonymous function without memoising\n\t// will not reinstantiate the hook's ResizeObserver.\n\tconst onResize = opts.onResize;\n\tconst onResizeRef = useRef< ResizeHandler | undefined >( undefined );\n\tonResizeRef.current = onResize;\n\tconst round = opts.round || Math.round;\n\n\t// Using a single instance throughout the hook's lifetime\n\tconst resizeObserverRef = useRef< {\n\t\tbox?: ResizeObserverBoxOptions;\n\t\tround?: RoundingFunction;\n\t\tinstance: ResizeObserver;\n\t} >();\n\n\tconst [ size, setSize ] = useState< {\n\t\twidth?: number;\n\t\theight?: number;\n\t} >( {\n\t\twidth: undefined,\n\t\theight: undefined,\n\t} );\n\n\t// In certain edge cases the RO might want to report a size change just after\n\t// the component unmounted.\n\tconst didUnmount = useRef( false );\n\tuseEffect( () => {\n\t\tdidUnmount.current = false;\n\t\treturn () => {\n\t\t\tdidUnmount.current = true;\n\t\t};\n\t}, [] );\n\n\t// Using a ref to track the previous width / height to avoid unnecessary renders.\n\tconst previous: {\n\t\tcurrent: {\n\t\t\twidth?: number;\n\t\t\theight?: number;\n\t\t};\n\t} = useRef( {\n\t\twidth: undefined,\n\t\theight: undefined,\n\t} );\n\n\t// This block is kinda like a useEffect, only it's called whenever a new\n\t// element could be resolved based on the ref option. It also has a cleanup\n\t// function.\n\tconst refCallback = useResolvedElement< T >(\n\t\tuseCallback(\n\t\t\t( element ) => {\n\t\t\t\t// We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.\n\t\t\t\t// This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.\n\t\t\t\tif (\n\t\t\t\t\t! resizeObserverRef.current ||\n\t\t\t\t\tresizeObserverRef.current.box !== opts.box ||\n\t\t\t\t\tresizeObserverRef.current.round !== round\n\t\t\t\t) {\n\t\t\t\t\tresizeObserverRef.current = {\n\t\t\t\t\t\tbox: opts.box,\n\t\t\t\t\t\tround,\n\t\t\t\t\t\tinstance: new ResizeObserver( ( entries ) => {\n\t\t\t\t\t\t\tconst entry = entries[ 0 ];\n\n\t\t\t\t\t\t\tlet boxProp:\n\t\t\t\t\t\t\t\t| 'borderBoxSize'\n\t\t\t\t\t\t\t\t| 'contentBoxSize'\n\t\t\t\t\t\t\t\t| 'devicePixelContentBoxSize' = 'borderBoxSize';\n\t\t\t\t\t\t\tif ( opts.box === 'border-box' ) {\n\t\t\t\t\t\t\t\tboxProp = 'borderBoxSize';\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tboxProp =\n\t\t\t\t\t\t\t\t\topts.box === 'device-pixel-content-box'\n\t\t\t\t\t\t\t\t\t\t? 'devicePixelContentBoxSize'\n\t\t\t\t\t\t\t\t\t\t: 'contentBoxSize';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst reportedWidth = extractSize(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\tboxProp,\n\t\t\t\t\t\t\t\t'inlineSize'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst reportedHeight = extractSize(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\tboxProp,\n\t\t\t\t\t\t\t\t'blockSize'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst newWidth = reportedWidth\n\t\t\t\t\t\t\t\t? round( reportedWidth )\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\tconst newHeight = reportedHeight\n\t\t\t\t\t\t\t\t? round( reportedHeight )\n\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tprevious.current.width !== newWidth ||\n\t\t\t\t\t\t\t\tprevious.current.height !== newHeight\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconst newSize = {\n\t\t\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\t\t\theight: newHeight,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tprevious.current.width = newWidth;\n\t\t\t\t\t\t\t\tprevious.current.height = newHeight;\n\t\t\t\t\t\t\t\tif ( onResizeRef.current ) {\n\t\t\t\t\t\t\t\t\tonResizeRef.current( newSize );\n\t\t\t\t\t\t\t\t} else if ( ! didUnmount.current ) {\n\t\t\t\t\t\t\t\t\tsetSize( newSize );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} ),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tresizeObserverRef.current.instance.observe( element, {\n\t\t\t\t\tbox: opts.box,\n\t\t\t\t} );\n\n\t\t\t\treturn () => {\n\t\t\t\t\tif ( resizeObserverRef.current ) {\n\t\t\t\t\t\tresizeObserverRef.current.instance.unobserve( element );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ opts.box, round ]\n\t\t),\n\t\topts.ref\n\t);\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tref: refCallback,\n\t\t\twidth: size.width,\n\t\t\theight: size.height,\n\t\t} ),\n\t\t[ refCallback, size ? size.width : null, size ? size.height : null ]\n\t);\n}\n\n/**\n * Hook which allows to listen the resize event of any target element when it changes sizes.\n * _Note: `useResizeObserver` will report `null` until after first render.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nexport default function useResizeAware(): [\n\tWPElement,\n\t{ width: number | null; height: number | null }\n] {\n\tconst { ref, width, height } = useResizeObserver();\n\tconst sizes = useMemo( () => {\n\t\treturn { width: width ?? null, height: height ?? null };\n\t}, [ width, height ] );\n\tconst resizeListener = (\n\t\t<div\n\t\t\tstyle={ {\n\t\t\t\tposition: 'absolute',\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\tright: 0,\n\t\t\t\tbottom: 0,\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\topacity: 0,\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tzIndex: -1,\n\t\t\t} }\n\t\t\taria-hidden=\"true\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n\treturn [ resizeListener, sizes ];\n}\n"]}
1
+ {"version":3,"names":["useMemo","useRef","useCallback","useEffect","useState","useResolvedElement","subscriber","refOrElement","callbackRefElement","lastReportRef","cleanupRef","callSubscriber","element","current","HTMLElement","reporter","extractSize","entry","boxProp","sizeType","contentRect","undefined","useResizeObserver","opts","onResize","onResizeRef","round","Math","resizeObserverRef","size","setSize","width","height","didUnmount","previous","refCallback","box","instance","ResizeObserver","entries","reportedWidth","reportedHeight","newWidth","newHeight","newSize","observe","unobserve","ref","useResizeAware","sizes","resizeListener","createElement","style","position","top","left","right","bottom","pointerEvents","opacity","overflow","zIndex"],"sources":["@wordpress/compose/src/hooks/use-resize-observer/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { RefCallback, RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\nimport type { WPElement } from '@wordpress/element';\n\ntype SubscriberCleanup = () => void;\ntype SubscriberResponse = SubscriberCleanup | void;\n\n// This of course could've been more streamlined with internal state instead of\n// refs, but then host hooks / components could not opt out of renders.\n// This could've been exported to its own module, but the current build doesn't\n// seem to work with module imports and I had no more time to spend on this...\nfunction useResolvedElement< T extends HTMLElement >(\n\tsubscriber: ( element: T ) => SubscriberResponse,\n\trefOrElement?: T | RefObject< T > | null\n): RefCallback< T > {\n\tconst callbackRefElement = useRef< T | null >( null );\n\tconst lastReportRef = useRef< {\n\t\treporter: () => void;\n\t\telement: T | null;\n\t} | null >( null );\n\tconst cleanupRef = useRef< SubscriberResponse | null >();\n\n\tconst callSubscriber = useCallback( () => {\n\t\tlet element = null;\n\t\tif ( callbackRefElement.current ) {\n\t\t\telement = callbackRefElement.current;\n\t\t} else if ( refOrElement ) {\n\t\t\tif ( refOrElement instanceof HTMLElement ) {\n\t\t\t\telement = refOrElement;\n\t\t\t} else {\n\t\t\t\telement = refOrElement.current;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tlastReportRef.current &&\n\t\t\tlastReportRef.current.element === element &&\n\t\t\tlastReportRef.current.reporter === callSubscriber\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( cleanupRef.current ) {\n\t\t\tcleanupRef.current();\n\t\t\t// Making sure the cleanup is not called accidentally multiple times.\n\t\t\tcleanupRef.current = null;\n\t\t}\n\t\tlastReportRef.current = {\n\t\t\treporter: callSubscriber,\n\t\t\telement,\n\t\t};\n\n\t\t// Only calling the subscriber, if there's an actual element to report.\n\t\tif ( element ) {\n\t\t\tcleanupRef.current = subscriber( element );\n\t\t}\n\t}, [ refOrElement, subscriber ] );\n\n\t// On each render, we check whether a ref changed, or if we got a new raw\n\t// element.\n\tuseEffect( () => {\n\t\t// With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a\n\t\t// render accompanying that change as well.\n\t\t// To guarantee we always have the right element, one must use the ref callback provided instead, but we support\n\t\t// RefObjects to make the hook API more convenient in certain cases.\n\t\tcallSubscriber();\n\t}, [ callSubscriber ] );\n\n\treturn useCallback< RefCallback< T > >(\n\t\t( element ) => {\n\t\t\tcallbackRefElement.current = element;\n\t\t\tcallSubscriber();\n\t\t},\n\t\t[ callSubscriber ]\n\t);\n}\n\ntype ObservedSize = {\n\twidth: number | undefined;\n\theight: number | undefined;\n};\n\ntype ResizeHandler = ( size: ObservedSize ) => void;\n\ntype HookResponse< T extends HTMLElement > = {\n\tref: RefCallback< T >;\n} & ObservedSize;\n\n// Declaring my own type here instead of using the one provided by TS (available since 4.2.2), because this way I'm not\n// forcing consumers to use a specific TS version.\ntype ResizeObserverBoxOptions =\n\t| 'border-box'\n\t| 'content-box'\n\t| 'device-pixel-content-box';\n\ndeclare global {\n\tinterface ResizeObserverEntry {\n\t\treadonly devicePixelContentBoxSize: ReadonlyArray< ResizeObserverSize >;\n\t}\n}\n\n// We're only using the first element of the size sequences, until future versions of the spec solidify on how\n// exactly it'll be used for fragments in multi-column scenarios:\n// From the spec:\n// > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,\n// > which occur in multi-column scenarios. However the current definitions of content rect and border box do not\n// > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single\n// > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.\n// > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)\n//\n// Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,\n// regardless of the \"box\" option.\n// The spec states the following on this:\n// > This does not have any impact on which box dimensions are returned to the defined callback when the event\n// > is fired, it solely defines which box the author wishes to observe layout changes on.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// I'm not exactly clear on what this means, especially when you consider a later section stating the following:\n// > This section is non-normative. An author may desire to observe more than one CSS box.\n// > In this case, author will need to use multiple ResizeObservers.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.\n// For this reason I decided to only return the requested size,\n// even though it seems we have access to results for all box types.\n// This also means that we get to keep the current api, being able to return a simple { width, height } pair,\n// regardless of box option.\nconst extractSize = (\n\tentry: ResizeObserverEntry,\n\tboxProp: 'borderBoxSize' | 'contentBoxSize' | 'devicePixelContentBoxSize',\n\tsizeType: keyof ResizeObserverSize\n): number | undefined => {\n\tif ( ! entry[ boxProp ] ) {\n\t\tif ( boxProp === 'contentBoxSize' ) {\n\t\t\t// The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.\n\t\t\t// See the 6th step in the description for the RO algorithm:\n\t\t\t// https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h\n\t\t\t// > Set this.contentRect to logical this.contentBoxSize given target and observedBox of \"content-box\".\n\t\t\t// In real browser implementations of course these objects differ, but the width/height values should be equivalent.\n\t\t\treturn entry.contentRect[\n\t\t\t\tsizeType === 'inlineSize' ? 'width' : 'height'\n\t\t\t];\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t// A couple bytes smaller than calling Array.isArray() and just as effective here.\n\treturn entry[ boxProp ][ 0 ]\n\t\t? entry[ boxProp ][ 0 ][ sizeType ]\n\t\t: // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current\n\t\t // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.\n\t\t // @ts-ignore\n\t\t entry[ boxProp ][ sizeType ];\n};\n\ntype RoundingFunction = ( n: number ) => number;\n\nfunction useResizeObserver< T extends HTMLElement >(\n\topts: {\n\t\tref?: RefObject< T > | T | null | undefined;\n\t\tonResize?: ResizeHandler;\n\t\tbox?: ResizeObserverBoxOptions;\n\t\tround?: RoundingFunction;\n\t} = {}\n): HookResponse< T > {\n\t// Saving the callback as a ref. With this, I don't need to put onResize in the\n\t// effect dep array, and just passing in an anonymous function without memoising\n\t// will not reinstantiate the hook's ResizeObserver.\n\tconst onResize = opts.onResize;\n\tconst onResizeRef = useRef< ResizeHandler | undefined >( undefined );\n\tonResizeRef.current = onResize;\n\tconst round = opts.round || Math.round;\n\n\t// Using a single instance throughout the hook's lifetime\n\tconst resizeObserverRef = useRef< {\n\t\tbox?: ResizeObserverBoxOptions;\n\t\tround?: RoundingFunction;\n\t\tinstance: ResizeObserver;\n\t} >();\n\n\tconst [ size, setSize ] = useState< {\n\t\twidth?: number;\n\t\theight?: number;\n\t} >( {\n\t\twidth: undefined,\n\t\theight: undefined,\n\t} );\n\n\t// In certain edge cases the RO might want to report a size change just after\n\t// the component unmounted.\n\tconst didUnmount = useRef( false );\n\tuseEffect( () => {\n\t\tdidUnmount.current = false;\n\t\treturn () => {\n\t\t\tdidUnmount.current = true;\n\t\t};\n\t}, [] );\n\n\t// Using a ref to track the previous width / height to avoid unnecessary renders.\n\tconst previous: {\n\t\tcurrent: {\n\t\t\twidth?: number;\n\t\t\theight?: number;\n\t\t};\n\t} = useRef( {\n\t\twidth: undefined,\n\t\theight: undefined,\n\t} );\n\n\t// This block is kinda like a useEffect, only it's called whenever a new\n\t// element could be resolved based on the ref option. It also has a cleanup\n\t// function.\n\tconst refCallback = useResolvedElement< T >(\n\t\tuseCallback(\n\t\t\t( element ) => {\n\t\t\t\t// We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.\n\t\t\t\t// This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.\n\t\t\t\tif (\n\t\t\t\t\t! resizeObserverRef.current ||\n\t\t\t\t\tresizeObserverRef.current.box !== opts.box ||\n\t\t\t\t\tresizeObserverRef.current.round !== round\n\t\t\t\t) {\n\t\t\t\t\tresizeObserverRef.current = {\n\t\t\t\t\t\tbox: opts.box,\n\t\t\t\t\t\tround,\n\t\t\t\t\t\tinstance: new ResizeObserver( ( entries ) => {\n\t\t\t\t\t\t\tconst entry = entries[ 0 ];\n\n\t\t\t\t\t\t\tlet boxProp:\n\t\t\t\t\t\t\t\t| 'borderBoxSize'\n\t\t\t\t\t\t\t\t| 'contentBoxSize'\n\t\t\t\t\t\t\t\t| 'devicePixelContentBoxSize' = 'borderBoxSize';\n\t\t\t\t\t\t\tif ( opts.box === 'border-box' ) {\n\t\t\t\t\t\t\t\tboxProp = 'borderBoxSize';\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tboxProp =\n\t\t\t\t\t\t\t\t\topts.box === 'device-pixel-content-box'\n\t\t\t\t\t\t\t\t\t\t? 'devicePixelContentBoxSize'\n\t\t\t\t\t\t\t\t\t\t: 'contentBoxSize';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst reportedWidth = extractSize(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\tboxProp,\n\t\t\t\t\t\t\t\t'inlineSize'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst reportedHeight = extractSize(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\tboxProp,\n\t\t\t\t\t\t\t\t'blockSize'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst newWidth = reportedWidth\n\t\t\t\t\t\t\t\t? round( reportedWidth )\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\tconst newHeight = reportedHeight\n\t\t\t\t\t\t\t\t? round( reportedHeight )\n\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tprevious.current.width !== newWidth ||\n\t\t\t\t\t\t\t\tprevious.current.height !== newHeight\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconst newSize = {\n\t\t\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\t\t\theight: newHeight,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tprevious.current.width = newWidth;\n\t\t\t\t\t\t\t\tprevious.current.height = newHeight;\n\t\t\t\t\t\t\t\tif ( onResizeRef.current ) {\n\t\t\t\t\t\t\t\t\tonResizeRef.current( newSize );\n\t\t\t\t\t\t\t\t} else if ( ! didUnmount.current ) {\n\t\t\t\t\t\t\t\t\tsetSize( newSize );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} ),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tresizeObserverRef.current.instance.observe( element, {\n\t\t\t\t\tbox: opts.box,\n\t\t\t\t} );\n\n\t\t\t\treturn () => {\n\t\t\t\t\tif ( resizeObserverRef.current ) {\n\t\t\t\t\t\tresizeObserverRef.current.instance.unobserve( element );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ opts.box, round ]\n\t\t),\n\t\topts.ref\n\t);\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tref: refCallback,\n\t\t\twidth: size.width,\n\t\t\theight: size.height,\n\t\t} ),\n\t\t[ refCallback, size ? size.width : null, size ? size.height : null ]\n\t);\n}\n\n/**\n * Hook which allows to listen the resize event of any target element when it changes sizes.\n * _Note: `useResizeObserver` will report `null` until after first render.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nexport default function useResizeAware(): [\n\tWPElement,\n\t{ width: number | null; height: number | null }\n] {\n\tconst { ref, width, height } = useResizeObserver();\n\tconst sizes = useMemo( () => {\n\t\treturn { width: width ?? null, height: height ?? null };\n\t}, [ width, height ] );\n\tconst resizeListener = (\n\t\t<div\n\t\t\tstyle={ {\n\t\t\t\tposition: 'absolute',\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\tright: 0,\n\t\t\t\tbottom: 0,\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\topacity: 0,\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tzIndex: -1,\n\t\t\t} }\n\t\t\taria-hidden=\"true\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n\treturn [ resizeListener, sizes ];\n}\n"],"mappings":";AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,OAAO,EACPC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,QAAQ,QACF,oBAAoB;AAM3B;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAC1BC,UAAgD,EAChDC,YAAwC,EACrB;EACnB,MAAMC,kBAAkB,GAAGP,MAAM,CAAc,IAAK,CAAC;EACrD,MAAMQ,aAAa,GAAGR,MAAM,CAGhB,IAAK,CAAC;E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ED,GAAG;IAAEhB,KAAK;IAAEC;EAAO,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EAClD,MAAM2B,KAAK,GAAGjD,OAAO,CAAE,MAAM;IAC5B,OAAO;MAAE+B,KAAK,EAAEA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,IAAI;MAAEC,MAAM,EAAEA,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI;IAAK,CAAC;EACxD,CAAC,EAAE,CAAED,KAAK,EAAEC,MAAM,CAAG,CAAC;EACtB,MAAMkB,cAAc,GACnBC,aAAA;IACCC,KAAK,EAAG;MACPC,QAAQ,EAAE,UAAU;MACpBC,GAAG,EAAE,CAAC;MACNC,IAAI,EAAE,CAAC;MACPC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;MACTC,aAAa,EAAE,MAAM;MACrBC,OAAO,EAAE,CAAC;MACVC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE,CAAC;IACV,CAAG;IACH,eAAY,MAAM;IAClBd,GAAG,EAAGA;EAAK,CACX,CACD;EACD,OAAO,CAAEG,cAAc,EAAED,KAAK,CAAE;AACjC"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * External dependencies
5
4
  */
@@ -7,8 +6,8 @@ import { View, StyleSheet } from 'react-native';
7
6
  /**
8
7
  * WordPress dependencies
9
8
  */
10
-
11
9
  import { useState, useCallback } from '@wordpress/element';
10
+
12
11
  /**
13
12
  * Hook which allows to listen the resize event of any target element when it changes sizes.
14
13
  *
@@ -26,9 +25,7 @@ import { useState, useCallback } from '@wordpress/element';
26
25
  * );
27
26
  * };
28
27
  * ```
29
- *
30
28
  */
31
-
32
29
  const useResizeObserver = () => {
33
30
  const [measurements, setMeasurements] = useState(null);
34
31
  const onLayout = useCallback(({
@@ -45,7 +42,6 @@ const useResizeObserver = () => {
45
42
  height: Math.floor(height)
46
43
  };
47
44
  }
48
-
49
45
  return prevState;
50
46
  });
51
47
  }, []);
@@ -56,6 +52,5 @@ const useResizeObserver = () => {
56
52
  });
57
53
  return [observer, measurements];
58
54
  };
59
-
60
55
  export default useResizeObserver;
61
56
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-resize-observer/index.native.js"],"names":["View","StyleSheet","useState","useCallback","useResizeObserver","measurements","setMeasurements","onLayout","nativeEvent","width","height","layout","prevState","Math","floor","observer","absoluteFill"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AACA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,oBAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,iBAAiB,GAAG,MAAM;AAC/B,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoCJ,QAAQ,CAAE,IAAF,CAAlD;AAEA,QAAMK,QAAQ,GAAGJ,WAAW,CAAE,CAAE;AAAEK,IAAAA;AAAF,GAAF,KAAuB;AACpD,UAAM;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAoBF,WAAW,CAACG,MAAtC;AACAL,IAAAA,eAAe,CAAIM,SAAF,IAAiB;AACjC,UACC,CAAEA,SAAF,IACAA,SAAS,CAACH,KAAV,KAAoBA,KADpB,IAEAG,SAAS,CAACF,MAAV,KAAqBA,MAHtB,EAIE;AACD,eAAO;AACND,UAAAA,KAAK,EAAEI,IAAI,CAACC,KAAL,CAAYL,KAAZ,CADD;AAENC,UAAAA,MAAM,EAAEG,IAAI,CAACC,KAAL,CAAYJ,MAAZ;AAFF,SAAP;AAIA;;AACD,aAAOE,SAAP;AACA,KAZc,CAAf;AAaA,GAf2B,EAezB,EAfyB,CAA5B;AAiBA,QAAMG,QAAQ,GACb,cAAC,IAAD;AACC,IAAA,MAAM,EAAC,iBADR;AAEC,IAAA,KAAK,EAAGd,UAAU,CAACe,YAFpB;AAGC,IAAA,QAAQ,EAAGT;AAHZ,IADD;AAQA,SAAO,CAAEQ,QAAF,EAAYV,YAAZ,CAAP;AACA,CA7BD;;AA+BA,eAAeD,iBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View, StyleSheet } from 'react-native';\n/**\n * WordPress dependencies\n */\nimport { useState, useCallback } from '@wordpress/element';\n\n/**\n * Hook which allows to listen the resize event of any target element when it changes sizes.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<View>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</View>\n * \t);\n * };\n * ```\n *\n */\nconst useResizeObserver = () => {\n\tconst [ measurements, setMeasurements ] = useState( null );\n\n\tconst onLayout = useCallback( ( { nativeEvent } ) => {\n\t\tconst { width, height } = nativeEvent.layout;\n\t\tsetMeasurements( ( prevState ) => {\n\t\t\tif (\n\t\t\t\t! prevState ||\n\t\t\t\tprevState.width !== width ||\n\t\t\t\tprevState.height !== height\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\twidth: Math.floor( width ),\n\t\t\t\t\theight: Math.floor( height ),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn prevState;\n\t\t} );\n\t}, [] );\n\n\tconst observer = (\n\t\t<View\n\t\t\ttestID=\"resize-observer\"\n\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\tonLayout={ onLayout }\n\t\t/>\n\t);\n\n\treturn [ observer, measurements ];\n};\n\nexport default useResizeObserver;\n"]}
1
+ {"version":3,"names":["View","StyleSheet","useState","useCallback","useResizeObserver","measurements","setMeasurements","onLayout","nativeEvent","width","height","layout","prevState","Math","floor","observer","createElement","testID","style","absoluteFill"],"sources":["@wordpress/compose/src/hooks/use-resize-observer/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, StyleSheet } from 'react-native';\n/**\n * WordPress dependencies\n */\nimport { useState, useCallback } from '@wordpress/element';\n\n/**\n * Hook which allows to listen the resize event of any target element when it changes sizes.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<View>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</View>\n * \t);\n * };\n * ```\n */\nconst useResizeObserver = () => {\n\tconst [ measurements, setMeasurements ] = useState( null );\n\n\tconst onLayout = useCallback( ( { nativeEvent } ) => {\n\t\tconst { width, height } = nativeEvent.layout;\n\t\tsetMeasurements( ( prevState ) => {\n\t\t\tif (\n\t\t\t\t! prevState ||\n\t\t\t\tprevState.width !== width ||\n\t\t\t\tprevState.height !== height\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\twidth: Math.floor( width ),\n\t\t\t\t\theight: Math.floor( height ),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn prevState;\n\t\t} );\n\t}, [] );\n\n\tconst observer = (\n\t\t<View\n\t\t\ttestID=\"resize-observer\"\n\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\tonLayout={ onLayout }\n\t\t/>\n\t);\n\n\treturn [ observer, measurements ];\n};\n\nexport default useResizeObserver;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAC/C;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAGJ,QAAQ,CAAE,IAAK,CAAC;EAE1D,MAAMK,QAAQ,GAAGJ,WAAW,CAAE,CAAE;IAAEK;EAAY,CAAC,KAAM;IACpD,MAAM;MAAEC,KAAK;MAAEC;IAAO,CAAC,GAAGF,WAAW,CAACG,MAAM;IAC5CL,eAAe,CAAIM,SAAS,IAAM;MACjC,IACC,CAAEA,SAAS,IACXA,SAAS,CAACH,KAAK,KAAKA,KAAK,IACzBG,SAAS,CAACF,MAAM,KAAKA,MAAM,EAC1B;QACD,OAAO;UACND,KAAK,EAAEI,IAAI,CAACC,KAAK,CAAEL,KAAM,CAAC;UAC1BC,MAAM,EAAEG,IAAI,CAACC,KAAK,CAAEJ,MAAO;QAC5B,CAAC;MACF;MACA,OAAOE,SAAS;IACjB,CAAE,CAAC;EACJ,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMG,QAAQ,GACbC,aAAA,CAAChB,IAAI;IACJiB,MAAM,EAAC,iBAAiB;IACxBC,KAAK,EAAGjB,UAAU,CAACkB,YAAc;IACjCZ,QAAQ,EAAGA;EAAU,CACrB,CACD;EAED,OAAO,CAAEQ,QAAQ,EAAEV,YAAY,CAAE;AAClC,CAAC;AAED,eAAeD,iBAAiB"}
@@ -2,16 +2,17 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { useMemoOne } from 'use-memo-one';
5
+
5
6
  /**
6
7
  * WordPress dependencies
7
8
  */
8
-
9
9
  import { useEffect } from '@wordpress/element';
10
+
10
11
  /**
11
12
  * Internal dependencies
12
13
  */
13
-
14
14
  import { throttle } from '../../utils/throttle';
15
+
15
16
  /**
16
17
  * Throttles a function similar to Lodash's `throttle`. A new throttled function will
17
18
  * be returned and any scheduled calls cancelled if any of the arguments change,
@@ -27,7 +28,6 @@ import { throttle } from '../../utils/throttle';
27
28
  * @param {import('../../utils/throttle').ThrottleOptions} [options] The options object. See linked documentation for details.
28
29
  * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Throttled function.
29
30
  */
30
-
31
31
  export default function useThrottle(fn, wait, options) {
32
32
  const throttled = useMemoOne(() => throttle(fn, wait !== null && wait !== void 0 ? wait : 0, options), [fn, wait, options]);
33
33
  useEffect(() => () => throttled.cancel(), [throttled]);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"names":["useMemoOne","useEffect","throttle","useThrottle","fn","wait","options","throttled","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,sBAAzB;AAEA;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,QAAMC,SAAS,GAAGP,UAAU,CAC3B,MAAME,QAAQ,CAAEE,EAAF,EAAMC,IAAN,aAAMA,IAAN,cAAMA,IAAN,GAAc,CAAd,EAAiBC,OAAjB,CADa,EAE3B,CAAEF,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAF2B,CAA5B;AAIAL,EAAAA,SAAS,CAAE,MAAM,MAAMM,SAAS,CAACC,MAAV,EAAd,EAAkC,CAAED,SAAF,CAAlC,CAAT;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { throttle } from '../../utils/throttle';\n\n/**\n * Throttles a function similar to 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('../../utils/throttle').ThrottleOptions} [options] The options object. See linked documentation for details.\n * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Throttled function.\n */\nexport default function useThrottle( fn, wait, options ) {\n\tconst throttled = useMemoOne(\n\t\t() => throttle( fn, wait ?? 0, options ),\n\t\t[ fn, wait, options ]\n\t);\n\tuseEffect( () => () => throttled.cancel(), [ throttled ] );\n\treturn throttled;\n}\n"]}
1
+ {"version":3,"names":["useMemoOne","useEffect","throttle","useThrottle","fn","wait","options","throttled","cancel"],"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { throttle } from '../../utils/throttle';\n\n/**\n * Throttles a function similar to 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('../../utils/throttle').ThrottleOptions} [options] The options object. See linked documentation for details.\n * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Throttled function.\n */\nexport default function useThrottle( fn, wait, options ) {\n\tconst throttled = useMemoOne(\n\t\t() => throttle( fn, wait ?? 0, options ),\n\t\t[ fn, wait, options ]\n\t);\n\tuseEffect( () => () => throttled.cancel(), [ throttled ] );\n\treturn throttled;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,QAAQ,QAAQ,sBAAsB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAO,EAAG;EACxD,MAAMC,SAAS,GAAGP,UAAU,CAC3B,MAAME,QAAQ,CAAEE,EAAE,EAAEC,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAI,CAAC,EAAEC,OAAQ,CAAC,EACxC,CAAEF,EAAE,EAAEC,IAAI,EAAEC,OAAO,CACpB,CAAC;EACDL,SAAS,CAAE,MAAM,MAAMM,SAAS,CAACC,MAAM,CAAC,CAAC,EAAE,CAAED,SAAS,CAAG,CAAC;EAC1D,OAAOA,SAAS;AACjB"}
@@ -2,11 +2,12 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { createContext, useContext } from '@wordpress/element';
5
+
5
6
  /**
6
7
  * Internal dependencies
7
8
  */
8
-
9
9
  import useMediaQuery from '../use-media-query';
10
+
10
11
  /**
11
12
  * @typedef {"huge" | "wide" | "large" | "medium" | "small" | "mobile"} WPBreakpoint
12
13
  */
@@ -18,7 +19,6 @@ import useMediaQuery from '../use-media-query';
18
19
  *
19
20
  * @type {Record<WPBreakpoint, number>}
20
21
  */
21
-
22
22
  const BREAKPOINTS = {
23
23
  huge: 1440,
24
24
  wide: 1280,
@@ -27,6 +27,7 @@ const BREAKPOINTS = {
27
27
  small: 600,
28
28
  mobile: 480
29
29
  };
30
+
30
31
  /**
31
32
  * @typedef {">=" | "<"} WPViewportOperator
32
33
  */
@@ -36,24 +37,22 @@ const BREAKPOINTS = {
36
37
  *
37
38
  * @type {Record<WPViewportOperator, string>}
38
39
  */
39
-
40
40
  const CONDITIONS = {
41
41
  '>=': 'min-width',
42
42
  '<': 'max-width'
43
43
  };
44
+
44
45
  /**
45
46
  * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.
46
47
  *
47
48
  * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>}
48
49
  */
49
-
50
50
  const OPERATOR_EVALUATORS = {
51
51
  '>=': (breakpointValue, width) => width >= breakpointValue,
52
52
  '<': (breakpointValue, width) => width < breakpointValue
53
53
  };
54
- const ViewportMatchWidthContext = createContext(
55
- /** @type {null | number} */
56
- null);
54
+ const ViewportMatchWidthContext = createContext( /** @type {null | number} */null);
55
+
57
56
  /**
58
57
  * Returns true if the viewport matches the given query, or false otherwise.
59
58
  *
@@ -69,19 +68,15 @@ null);
69
68
  *
70
69
  * @return {boolean} Whether viewport matches query.
71
70
  */
72
-
73
71
  const useViewportMatch = (breakpoint, operator = '>=') => {
74
72
  const simulatedWidth = useContext(ViewportMatchWidthContext);
75
73
  const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
76
74
  const mediaQueryResult = useMediaQuery(mediaQuery || undefined);
77
-
78
75
  if (simulatedWidth) {
79
76
  return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth);
80
77
  }
81
-
82
78
  return mediaQueryResult;
83
79
  };
84
-
85
80
  useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
86
81
  export default useViewportMatch;
87
82
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-viewport-match/index.js"],"names":["createContext","useContext","useMediaQuery","BREAKPOINTS","huge","wide","large","medium","small","mobile","CONDITIONS","OPERATOR_EVALUATORS","breakpointValue","width","ViewportMatchWidthContext","useViewportMatch","breakpoint","operator","simulatedWidth","mediaQuery","mediaQueryResult","undefined","__experimentalWidthProvider","Provider"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,oBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,oBAA1B;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAAG;AACnBC,EAAAA,IAAI,EAAE,IADa;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAGnBC,EAAAA,KAAK,EAAE,GAHY;AAInBC,EAAAA,MAAM,EAAE,GAJW;AAKnBC,EAAAA,KAAK,EAAE,GALY;AAMnBC,EAAAA,MAAM,EAAE;AANW,CAApB;AASA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG;AAClB,QAAM,WADY;AAElB,OAAK;AAFa,CAAnB;AAKA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG;AAC3B,QAAM,CAAEC,eAAF,EAAmBC,KAAnB,KAA8BA,KAAK,IAAID,eADlB;AAE3B,OAAK,CAAEA,eAAF,EAAmBC,KAAnB,KAA8BA,KAAK,GAAGD;AAFhB,CAA5B;AAKA,MAAME,yBAAyB,GAAGd,aAAa;AAC9C;AAA+B,IADe,CAA/C;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMe,gBAAgB,GAAG,CAAEC,UAAF,EAAcC,QAAQ,GAAG,IAAzB,KAAmC;AAC3D,QAAMC,cAAc,GAAGjB,UAAU,CAAEa,yBAAF,CAAjC;AACA,QAAMK,UAAU,GACf,CAAED,cAAF,IACC,IAAIR,UAAU,CAAEO,QAAF,CAAc,KAAKd,WAAW,CAAEa,UAAF,CAAgB,KAF9D;AAGA,QAAMI,gBAAgB,GAAGlB,aAAa,CAAEiB,UAAU,IAAIE,SAAhB,CAAtC;;AACA,MAAKH,cAAL,EAAsB;AACrB,WAAOP,mBAAmB,CAAEM,QAAF,CAAnB,CACNd,WAAW,CAAEa,UAAF,CADL,EAENE,cAFM,CAAP;AAIA;;AACD,SAAOE,gBAAP;AACA,CAbD;;AAeAL,gBAAgB,CAACO,2BAAjB,GACCR,yBAAyB,CAACS,QAD3B;AAGA,eAAeR,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMediaQuery from '../use-media-query';\n\n/**\n * @typedef {\"huge\" | \"wide\" | \"large\" | \"medium\" | \"small\" | \"mobile\"} WPBreakpoint\n */\n\n/**\n * Hash of breakpoint names with pixel width at which it becomes effective.\n *\n * @see _breakpoints.scss\n *\n * @type {Record<WPBreakpoint, number>}\n */\nconst BREAKPOINTS = {\n\thuge: 1440,\n\twide: 1280,\n\tlarge: 960,\n\tmedium: 782,\n\tsmall: 600,\n\tmobile: 480,\n};\n\n/**\n * @typedef {\">=\" | \"<\"} WPViewportOperator\n */\n\n/**\n * Object mapping media query operators to the condition to be used.\n *\n * @type {Record<WPViewportOperator, string>}\n */\nconst CONDITIONS = {\n\t'>=': 'min-width',\n\t'<': 'max-width',\n};\n\n/**\n * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.\n *\n * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>}\n */\nconst OPERATOR_EVALUATORS = {\n\t'>=': ( breakpointValue, width ) => width >= breakpointValue,\n\t'<': ( breakpointValue, width ) => width < breakpointValue,\n};\n\nconst ViewportMatchWidthContext = createContext(\n\t/** @type {null | number} */ ( null )\n);\n\n/**\n * Returns true if the viewport matches the given query, or false otherwise.\n *\n * @param {WPBreakpoint} breakpoint Breakpoint size name.\n * @param {WPViewportOperator} [operator=\">=\"] Viewport operator.\n *\n * @example\n *\n * ```js\n * useViewportMatch( 'huge', '<' );\n * useViewportMatch( 'medium' );\n * ```\n *\n * @return {boolean} Whether viewport matches query.\n */\nconst useViewportMatch = ( breakpoint, operator = '>=' ) => {\n\tconst simulatedWidth = useContext( ViewportMatchWidthContext );\n\tconst mediaQuery =\n\t\t! simulatedWidth &&\n\t\t`(${ CONDITIONS[ operator ] }: ${ BREAKPOINTS[ breakpoint ] }px)`;\n\tconst mediaQueryResult = useMediaQuery( mediaQuery || undefined );\n\tif ( simulatedWidth ) {\n\t\treturn OPERATOR_EVALUATORS[ operator ](\n\t\t\tBREAKPOINTS[ breakpoint ],\n\t\t\tsimulatedWidth\n\t\t);\n\t}\n\treturn mediaQueryResult;\n};\n\nuseViewportMatch.__experimentalWidthProvider =\n\tViewportMatchWidthContext.Provider;\n\nexport default useViewportMatch;\n"]}
1
+ {"version":3,"names":["createContext","useContext","useMediaQuery","BREAKPOINTS","huge","wide","large","medium","small","mobile","CONDITIONS","OPERATOR_EVALUATORS",">=","breakpointValue","width","<","ViewportMatchWidthContext","useViewportMatch","breakpoint","operator","simulatedWidth","mediaQuery","mediaQueryResult","undefined","__experimentalWidthProvider","Provider"],"sources":["@wordpress/compose/src/hooks/use-viewport-match/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMediaQuery from '../use-media-query';\n\n/**\n * @typedef {\"huge\" | \"wide\" | \"large\" | \"medium\" | \"small\" | \"mobile\"} WPBreakpoint\n */\n\n/**\n * Hash of breakpoint names with pixel width at which it becomes effective.\n *\n * @see _breakpoints.scss\n *\n * @type {Record<WPBreakpoint, number>}\n */\nconst BREAKPOINTS = {\n\thuge: 1440,\n\twide: 1280,\n\tlarge: 960,\n\tmedium: 782,\n\tsmall: 600,\n\tmobile: 480,\n};\n\n/**\n * @typedef {\">=\" | \"<\"} WPViewportOperator\n */\n\n/**\n * Object mapping media query operators to the condition to be used.\n *\n * @type {Record<WPViewportOperator, string>}\n */\nconst CONDITIONS = {\n\t'>=': 'min-width',\n\t'<': 'max-width',\n};\n\n/**\n * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.\n *\n * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>}\n */\nconst OPERATOR_EVALUATORS = {\n\t'>=': ( breakpointValue, width ) => width >= breakpointValue,\n\t'<': ( breakpointValue, width ) => width < breakpointValue,\n};\n\nconst ViewportMatchWidthContext = createContext(\n\t/** @type {null | number} */ ( null )\n);\n\n/**\n * Returns true if the viewport matches the given query, or false otherwise.\n *\n * @param {WPBreakpoint} breakpoint Breakpoint size name.\n * @param {WPViewportOperator} [operator=\">=\"] Viewport operator.\n *\n * @example\n *\n * ```js\n * useViewportMatch( 'huge', '<' );\n * useViewportMatch( 'medium' );\n * ```\n *\n * @return {boolean} Whether viewport matches query.\n */\nconst useViewportMatch = ( breakpoint, operator = '>=' ) => {\n\tconst simulatedWidth = useContext( ViewportMatchWidthContext );\n\tconst mediaQuery =\n\t\t! simulatedWidth &&\n\t\t`(${ CONDITIONS[ operator ] }: ${ BREAKPOINTS[ breakpoint ] }px)`;\n\tconst mediaQueryResult = useMediaQuery( mediaQuery || undefined );\n\tif ( simulatedWidth ) {\n\t\treturn OPERATOR_EVALUATORS[ operator ](\n\t\t\tBREAKPOINTS[ breakpoint ],\n\t\t\tsimulatedWidth\n\t\t);\n\t}\n\treturn mediaQueryResult;\n};\n\nuseViewportMatch.__experimentalWidthProvider =\n\tViewportMatchWidthContext.Provider;\n\nexport default useViewportMatch;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,OAAOC,aAAa,MAAM,oBAAoB;;AAE9C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG;EACnBC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE,IAAI;EACVC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE,GAAG;EACXC,KAAK,EAAE,GAAG;EACVC,MAAM,EAAE;AACT,CAAC;;AAED;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG;EAClB,IAAI,EAAE,WAAW;EACjB,GAAG,EAAE;AACN,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,GAAG;EAC3B,IAAI,EAAEC,CAAEC,eAAe,EAAEC,KAAK,KAAMA,KAAK,IAAID,eAAe;EAC5D,GAAG,EAAEE,CAAEF,eAAe,EAAEC,KAAK,KAAMA,KAAK,GAAGD;AAC5C,CAAC;AAED,MAAMG,yBAAyB,GAAGhB,aAAa,EAC9C,4BAA+B,IAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMiB,gBAAgB,GAAGA,CAAEC,UAAU,EAAEC,QAAQ,GAAG,IAAI,KAAM;EAC3D,MAAMC,cAAc,GAAGnB,UAAU,CAAEe,yBAA0B,CAAC;EAC9D,MAAMK,UAAU,GACf,CAAED,cAAc,IACf,IAAIV,UAAU,CAAES,QAAQ,CAAI,KAAKhB,WAAW,CAAEe,UAAU,CAAI,KAAI;EAClE,MAAMI,gBAAgB,GAAGpB,aAAa,CAAEmB,UAAU,IAAIE,SAAU,CAAC;EACjE,IAAKH,cAAc,EAAG;IACrB,OAAOT,mBAAmB,CAAEQ,QAAQ,CAAE,CACrChB,WAAW,CAAEe,UAAU,CAAE,EACzBE,cACD,CAAC;EACF;EACA,OAAOE,gBAAgB;AACxB,CAAC;AAEDL,gBAAgB,CAACO,2BAA2B,GAC3CR,yBAAyB,CAACS,QAAQ;AAEnC,eAAeR,gBAAgB"}
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import usePrevious from '../use-previous'; // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
5
- // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
4
+ import usePrevious from '../use-previous';
6
5
 
6
+ // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case
7
+ // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
7
8
  /* eslint-disable jsdoc/check-types */
8
-
9
9
  /**
10
10
  * Hook that performs a shallow comparison between the preview value of an object
11
11
  * and the new one, if there's a difference, it prints it to the console.
@@ -24,19 +24,13 @@ import usePrevious from '../use-previous'; // Disable reason: Object and object
24
24
  * @param {object} object Object which changes to compare.
25
25
  * @param {string} prefix Just a prefix to show when console logging.
26
26
  */
27
-
28
27
  function useWarnOnChange(object, prefix = 'Change detection') {
29
28
  const previousValues = usePrevious(object);
30
29
  Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(([key, value]) => {
31
- if (value !== object[
32
- /** @type {keyof typeof object} */
33
- key]) {
30
+ if (value !== object[/** @type {keyof typeof object} */key]) {
34
31
  // eslint-disable-next-line no-console
35
- console.warn(`${prefix}: ${key} key changed:`, value, object[
36
- /** @type {keyof typeof object} */
37
- key]
38
- /* eslint-enable jsdoc/check-types */
39
- );
32
+ console.warn(`${prefix}: ${key} key changed:`, value, object[/** @type {keyof typeof object} */key]
33
+ /* eslint-enable jsdoc/check-types */);
40
34
  }
41
35
  });
42
36
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-warn-on-change/index.js"],"names":["usePrevious","useWarnOnChange","object","prefix","previousValues","Object","entries","forEach","key","value","console","warn"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAP,MAAwB,iBAAxB,C,CAEA;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,eAAT,CAA0BC,MAA1B,EAAkCC,MAAM,GAAG,kBAA3C,EAAgE;AAC/D,QAAMC,cAAc,GAAGJ,WAAW,CAAEE,MAAF,CAAlC;AAEAG,EAAAA,MAAM,CAACC,OAAP,CAAgBF,cAAhB,aAAgBA,cAAhB,cAAgBA,cAAhB,GAAkC,EAAlC,EAAuCG,OAAvC,CAAgD,CAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF,KAAsB;AACrE,QAAKA,KAAK,KAAKP,MAAM;AAAE;AAAqCM,IAAAA,GAAvC,CAArB,EAAsE;AACrE;AACAE,MAAAA,OAAO,CAACC,IAAR,CACE,GAAGR,MAAQ,KAAKK,GAAK,eADvB,EAECC,KAFD,EAGCP,MAAM;AAAE;AAAqCM,MAAAA,GAAvC;AACN;AAJD;AAMA;AACD,GAVD;AAWA;;AAED,eAAeP,eAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport usePrevious from '../use-previous';\n\n// Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case\n// but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript\n/* eslint-disable jsdoc/check-types */\n/**\n * Hook that performs a shallow comparison between the preview value of an object\n * and the new one, if there's a difference, it prints it to the console.\n * this is useful in performance related work, to check why a component re-renders.\n *\n * @example\n *\n * ```jsx\n * function MyComponent(props) {\n * useWarnOnChange(props);\n *\n * return \"Something\";\n * }\n * ```\n *\n * @param {object} object Object which changes to compare.\n * @param {string} prefix Just a prefix to show when console logging.\n */\nfunction useWarnOnChange( object, prefix = 'Change detection' ) {\n\tconst previousValues = usePrevious( object );\n\n\tObject.entries( previousValues ?? [] ).forEach( ( [ key, value ] ) => {\n\t\tif ( value !== object[ /** @type {keyof typeof object} */ ( key ) ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t`${ prefix }: ${ key } key changed:`,\n\t\t\t\tvalue,\n\t\t\t\tobject[ /** @type {keyof typeof object} */ ( key ) ]\n\t\t\t\t/* eslint-enable jsdoc/check-types */\n\t\t\t);\n\t\t}\n\t} );\n}\n\nexport default useWarnOnChange;\n"]}
1
+ {"version":3,"names":["usePrevious","useWarnOnChange","object","prefix","previousValues","Object","entries","forEach","key","value","console","warn"],"sources":["@wordpress/compose/src/hooks/use-warn-on-change/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport usePrevious from '../use-previous';\n\n// Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case\n// but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript\n/* eslint-disable jsdoc/check-types */\n/**\n * Hook that performs a shallow comparison between the preview value of an object\n * and the new one, if there's a difference, it prints it to the console.\n * this is useful in performance related work, to check why a component re-renders.\n *\n * @example\n *\n * ```jsx\n * function MyComponent(props) {\n * useWarnOnChange(props);\n *\n * return \"Something\";\n * }\n * ```\n *\n * @param {object} object Object which changes to compare.\n * @param {string} prefix Just a prefix to show when console logging.\n */\nfunction useWarnOnChange( object, prefix = 'Change detection' ) {\n\tconst previousValues = usePrevious( object );\n\n\tObject.entries( previousValues ?? [] ).forEach( ( [ key, value ] ) => {\n\t\tif ( value !== object[ /** @type {keyof typeof object} */ ( key ) ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t`${ prefix }: ${ key } key changed:`,\n\t\t\t\tvalue,\n\t\t\t\tobject[ /** @type {keyof typeof object} */ ( key ) ]\n\t\t\t\t/* eslint-enable jsdoc/check-types */\n\t\t\t);\n\t\t}\n\t} );\n}\n\nexport default useWarnOnChange;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,iBAAiB;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,MAAM,EAAEC,MAAM,GAAG,kBAAkB,EAAG;EAC/D,MAAMC,cAAc,GAAGJ,WAAW,CAAEE,MAAO,CAAC;EAE5CG,MAAM,CAACC,OAAO,CAAEF,cAAc,aAAdA,cAAc,cAAdA,cAAc,GAAI,EAAG,CAAC,CAACG,OAAO,CAAE,CAAE,CAAEC,GAAG,EAAEC,KAAK,CAAE,KAAM;IACrE,IAAKA,KAAK,KAAKP,MAAM,CAAE,kCAAqCM,GAAG,CAAI,EAAG;MACrE;MACAE,OAAO,CAACC,IAAI,CACV,GAAGR,MAAQ,KAAKK,GAAK,eAAc,EACpCC,KAAK,EACLP,MAAM,CAAE,kCAAqCM,GAAG;MAChD,qCACD,CAAC;IACF;EACD,CAAE,CAAC;AACJ;;AAEA,eAAeP,eAAe"}
@@ -1,20 +1,23 @@
1
1
  // The `createHigherOrderComponent` helper and helper types.
2
- export * from './utils/create-higher-order-component'; // The `debounce` helper and its types.
3
-
4
- export * from './utils/debounce'; // The `throttle` helper and its types.
5
-
6
- export * from './utils/throttle'; // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).
2
+ export * from './utils/create-higher-order-component';
3
+ // The `debounce` helper and its types.
4
+ export * from './utils/debounce';
5
+ // The `throttle` helper and its types.
6
+ export * from './utils/throttle';
7
7
 
8
+ // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).
8
9
  export { default as compose } from './higher-order/compose';
9
- export { default as pipe } from './higher-order/pipe'; // Higher-order components.
10
+ export { default as pipe } from './higher-order/pipe';
10
11
 
12
+ // Higher-order components.
11
13
  export { default as ifCondition } from './higher-order/if-condition';
12
14
  export { default as pure } from './higher-order/pure';
13
15
  export { default as withGlobalEvents } from './higher-order/with-global-events';
14
16
  export { default as withInstanceId } from './higher-order/with-instance-id';
15
17
  export { default as withSafeTimeout } from './higher-order/with-safe-timeout';
16
- export { default as withState } from './higher-order/with-state'; // Hooks.
18
+ export { default as withState } from './higher-order/with-state';
17
19
 
20
+ // Hooks.
18
21
  export { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';
19
22
  export { default as useCopyOnClick } from './hooks/use-copy-on-click';
20
23
  export { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/index.js"],"names":["default","compose","pipe","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","useConstrainedTabbing","useCopyOnClick","useCopyToClipboard","__experimentalUseDialog","useDisabled","__experimentalUseDragging","useFocusOnMount","__experimentalUseFocusOutside","useFocusReturn","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useViewportMatch","useResizeObserver","useAsyncList","useWarnOnChange","useDebounce","useThrottle","useMergeRefs","useRefEffect","__experimentalUseDropZone","useFocusableIframe","__experimentalUseFixedWindowList"],"mappings":"AAAA;AACA,cAAc,uCAAd,C,CACA;;AACA,cAAc,kBAAd,C,CACA;;AACA,cAA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,IAAI0B,YAApB,QAAwC,wBAAxC;AACA,SAAS1B,OAAO,IAAI2B,eAApB,QAA2C,4BAA3C;AACA,SAAS3B,OAAO,IAAI4B,WAApB,QAAuC,sBAAvC;AACA,SAAS5B,OAAO,IAAI6B,WAApB,QAAuC,sBAAvC;AACA,SAAS7B,OAAO,IAAI8B,YAApB,QAAwC,wBAAxC;AACA,SAAS9B,OAAO,IAAI+B,YAApB,QAAwC,wBAAxC;AACA,SAAS/B,OAAO,IAAIgC,yBAApB,QAAqD,uBAArD;AACA,SAAShC,OAAO,IAAIiC,kBAApB,QAA8C,8BAA9C;AACA,SAASjC,OAAO,IAAIkC,gCAApB,QAA4D,+BAA5D","sourcesContent":["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n// The `debounce` helper and its types.\nexport * from './utils/debounce';\n// The `throttle` helper and its types.\nexport * from './utils/throttle';\n\n// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).\nexport { default as compose } from './higher-order/compose';\nexport { default as pipe } from './higher-order/pipe';\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 useDisabled } from './hooks/use-disabled';\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"]}
1
+ {"version":3,"names":["default","compose","pipe","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","useConstrainedTabbing","useCopyOnClick","useCopyToClipboard","__experimentalUseDialog","useDisabled","__experimentalUseDragging","useFocusOnMount","__experimentalUseFocusOutside","useFocusReturn","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useViewportMatch","useResizeObserver","useAsyncList","useWarnOnChange","useDebounce","useThrottle","useMergeRefs","useRefEffect","__experimentalUseDropZone","useFocusableIframe","__experimentalUseFixedWindowList"],"sources":["@wordpress/compose/src/index.js"],"sourcesContent":["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n// The `debounce` helper and its types.\nexport * from './utils/debounce';\n// The `throttle` helper and its types.\nexport * from './utils/throttle';\n\n// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).\nexport { default as compose } from './higher-order/compose';\nexport { default as pipe } from './higher-order/pipe';\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 useDisabled } from './hooks/use-disabled';\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"],"mappings":"AAAA;AACA,cAAc,uCAAuC;AACrD;AACA,cAAc,kBAAkB;AAChC;AACA,cAAc,kBAAkB;;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BAAiB,QAAQ,6BAA6B;AAC1E,SAASzB,OAAO,IAAI0B,YAAY,QAAQ,wBAAwB;AAChE,SAAS1B,OAAO,IAAI2B,eAAe,QAAQ,4BAA4B;AACvE,SAAS3B,OAAO,IAAI4B,WAAW,QAAQ,sBAAsB;AAC7D,SAAS5B,OAAO,IAAI6B,WAAW,QAAQ,sBAAsB;AAC7D,SAAS7B,OAAO,IAAI8B,YAAY,QAAQ,wBAAwB;AAChE,SAAS9B,OAAO,IAAI+B,YAAY,QAAQ,wBAAwB;AAChE,SAAS/B,OAAO,IAAIgC,yBAAyB,QAAQ,uBAAuB;AAC5E,SAAShC,OAAO,IAAIiC,kBAAkB,QAAQ,8BAA8B;AAC5E,SAASjC,OAAO,IAAIkC,gCAAgC,QAAQ,+BAA+B"}
@@ -1,21 +1,24 @@
1
1
  // The `createHigherOrderComponent` helper and helper types.
2
- export * from './utils/create-higher-order-component'; // The `debounce` helper and its types.
3
-
4
- export * from './utils/debounce'; // The `throttle` helper and its types.
5
-
6
- export * from './utils/throttle'; // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).
2
+ export * from './utils/create-higher-order-component';
3
+ // The `debounce` helper and its types.
4
+ export * from './utils/debounce';
5
+ // The `throttle` helper and its types.
6
+ export * from './utils/throttle';
7
7
 
8
+ // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).
8
9
  export { default as compose } from './higher-order/compose';
9
- export { default as pipe } from './higher-order/pipe'; // Higher-order components.
10
+ export { default as pipe } from './higher-order/pipe';
10
11
 
12
+ // Higher-order components.
11
13
  export { default as ifCondition } from './higher-order/if-condition';
12
14
  export { default as pure } from './higher-order/pure';
13
15
  export { default as withGlobalEvents } from './higher-order/with-global-events';
14
16
  export { default as withInstanceId } from './higher-order/with-instance-id';
15
17
  export { default as withSafeTimeout } from './higher-order/with-safe-timeout';
16
18
  export { default as withState } from './higher-order/with-state';
17
- export { default as withPreferredColorScheme } from './higher-order/with-preferred-color-scheme'; // Hooks.
19
+ export { default as withPreferredColorScheme } from './higher-order/with-preferred-color-scheme';
18
20
 
21
+ // Hooks.
19
22
  export { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';
20
23
  export { default as __experimentalUseDragging } from './hooks/use-dragging';
21
24
  export { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';