@wordpress/compose 7.32.0 → 7.32.1-next.ff1cebbba.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 (235) hide show
  1. package/build/higher-order/compose.js +25 -20
  2. package/build/higher-order/compose.js.map +7 -1
  3. package/build/higher-order/if-condition/index.js +35 -41
  4. package/build/higher-order/if-condition/index.js.map +7 -1
  5. package/build/higher-order/pipe.js +32 -66
  6. package/build/higher-order/pipe.js.map +7 -1
  7. package/build/higher-order/pure/index.js +44 -37
  8. package/build/higher-order/pure/index.js.map +7 -1
  9. package/build/higher-order/with-global-events/index.js +64 -73
  10. package/build/higher-order/with-global-events/index.js.map +7 -1
  11. package/build/higher-order/with-global-events/listener.js +34 -21
  12. package/build/higher-order/with-global-events/listener.js.map +7 -1
  13. package/build/higher-order/with-instance-id/index.js +45 -27
  14. package/build/higher-order/with-instance-id/index.js.map +7 -1
  15. package/build/higher-order/with-safe-timeout/index.js +70 -66
  16. package/build/higher-order/with-safe-timeout/index.js.map +7 -1
  17. package/build/higher-order/with-state/index.js +52 -40
  18. package/build/higher-order/with-state/index.js.map +7 -1
  19. package/build/hooks/use-async-list/index.js +38 -42
  20. package/build/hooks/use-async-list/index.js.map +7 -1
  21. package/build/hooks/use-constrained-tabbing/index.js +54 -75
  22. package/build/hooks/use-constrained-tabbing/index.js.map +7 -1
  23. package/build/hooks/use-copy-on-click/index.js +46 -56
  24. package/build/hooks/use-copy-on-click/index.js.map +7 -1
  25. package/build/hooks/use-copy-to-clipboard/index.js +41 -51
  26. package/build/hooks/use-copy-to-clipboard/index.js.map +7 -1
  27. package/build/hooks/use-debounce/index.js +30 -37
  28. package/build/hooks/use-debounce/index.js.map +7 -1
  29. package/build/hooks/use-debounced-input/index.js +39 -27
  30. package/build/hooks/use-debounced-input/index.js.map +7 -1
  31. package/build/hooks/use-dialog/index.js +63 -55
  32. package/build/hooks/use-dialog/index.js.map +7 -1
  33. package/build/hooks/use-disabled/index.js +74 -82
  34. package/build/hooks/use-disabled/index.js.map +7 -1
  35. package/build/hooks/use-dragging/index.js +51 -48
  36. package/build/hooks/use-dragging/index.js.map +7 -1
  37. package/build/hooks/use-drop-zone/index.js +133 -168
  38. package/build/hooks/use-drop-zone/index.js.map +7 -1
  39. package/build/hooks/use-event/index.js +33 -45
  40. package/build/hooks/use-event/index.js.map +7 -1
  41. package/build/hooks/use-fixed-window-list/index.js +109 -97
  42. package/build/hooks/use-fixed-window-list/index.js.map +7 -1
  43. package/build/hooks/use-focus-on-mount/index.js +44 -57
  44. package/build/hooks/use-focus-on-mount/index.js.map +7 -1
  45. package/build/hooks/use-focus-outside/index.js +44 -102
  46. package/build/hooks/use-focus-outside/index.js.map +7 -1
  47. package/build/hooks/use-focus-return/index.js +35 -56
  48. package/build/hooks/use-focus-return/index.js.map +7 -1
  49. package/build/hooks/use-focusable-iframe/index.js +38 -35
  50. package/build/hooks/use-focusable-iframe/index.js.map +7 -1
  51. package/build/hooks/use-instance-id/index.js +26 -42
  52. package/build/hooks/use-instance-id/index.js.map +7 -1
  53. package/build/hooks/use-isomorphic-layout-effect/index.js +25 -17
  54. package/build/hooks/use-isomorphic-layout-effect/index.js.map +7 -1
  55. package/build/hooks/use-keyboard-shortcut/index.js +72 -69
  56. package/build/hooks/use-keyboard-shortcut/index.js.map +7 -1
  57. package/build/hooks/use-media-query/index.js +39 -35
  58. package/build/hooks/use-media-query/index.js.map +7 -1
  59. package/build/hooks/use-merge-refs/index.js +34 -102
  60. package/build/hooks/use-merge-refs/index.js.map +7 -1
  61. package/build/hooks/use-observable-value/index.js +31 -28
  62. package/build/hooks/use-observable-value/index.js.map +7 -1
  63. package/build/hooks/use-preferred-color-scheme/index.android.js +31 -23
  64. package/build/hooks/use-preferred-color-scheme/index.android.js.map +7 -1
  65. package/build/hooks/use-preferred-color-scheme/index.ios.js +25 -17
  66. package/build/hooks/use-preferred-color-scheme/index.ios.js.map +7 -1
  67. package/build/hooks/use-previous/index.js +26 -25
  68. package/build/hooks/use-previous/index.js.map +7 -1
  69. package/build/hooks/use-reduced-motion/index.js +35 -18
  70. package/build/hooks/use-reduced-motion/index.js.map +7 -1
  71. package/build/hooks/use-ref-effect/index.js +25 -35
  72. package/build/hooks/use-ref-effect/index.js.map +7 -1
  73. package/build/hooks/use-resize-observer/index.js +35 -67
  74. package/build/hooks/use-resize-observer/index.js.map +7 -1
  75. package/build/hooks/use-resize-observer/legacy/index.js +47 -103
  76. package/build/hooks/use-resize-observer/legacy/index.js.map +7 -1
  77. package/build/hooks/use-resize-observer/use-resize-observer.js +44 -36
  78. package/build/hooks/use-resize-observer/use-resize-observer.js.map +7 -1
  79. package/build/hooks/use-state-with-history/index.js +68 -63
  80. package/build/hooks/use-state-with-history/index.js.map +7 -1
  81. package/build/hooks/use-throttle/index.js +30 -37
  82. package/build/hooks/use-throttle/index.js.map +7 -1
  83. package/build/hooks/use-viewport-match/index.js +51 -70
  84. package/build/hooks/use-viewport-match/index.js.map +7 -1
  85. package/build/hooks/use-warn-on-change/index.js +50 -40
  86. package/build/hooks/use-warn-on-change/index.js.map +7 -1
  87. package/build/index.js +156 -358
  88. package/build/index.js.map +7 -1
  89. package/build/utils/create-higher-order-component/index.js +30 -34
  90. package/build/utils/create-higher-order-component/index.js.map +7 -1
  91. package/build/utils/debounce/index.js +38 -99
  92. package/build/utils/debounce/index.js.map +7 -1
  93. package/build/utils/observable-map/index.js +29 -19
  94. package/build/utils/observable-map/index.js.map +7 -1
  95. package/build/utils/throttle/index.js +30 -81
  96. package/build/utils/throttle/index.js.map +7 -1
  97. package/build-module/higher-order/compose.js +6 -15
  98. package/build-module/higher-order/compose.js.map +7 -1
  99. package/build-module/higher-order/if-condition/index.js +16 -37
  100. package/build-module/higher-order/if-condition/index.js.map +7 -1
  101. package/build-module/higher-order/pipe.js +10 -62
  102. package/build-module/higher-order/pipe.js.map +7 -1
  103. package/build-module/higher-order/pure/index.js +12 -29
  104. package/build-module/higher-order/pure/index.js.map +7 -1
  105. package/build-module/higher-order/with-global-events/index.js +34 -67
  106. package/build-module/higher-order/with-global-events/index.js.map +7 -1
  107. package/build-module/higher-order/with-global-events/listener.js +16 -17
  108. package/build-module/higher-order/with-global-events/listener.js.map +7 -1
  109. package/build-module/higher-order/with-instance-id/index.js +17 -22
  110. package/build-module/higher-order/with-instance-id/index.js.map +7 -1
  111. package/build-module/higher-order/with-safe-timeout/index.js +52 -62
  112. package/build-module/higher-order/with-safe-timeout/index.js.map +7 -1
  113. package/build-module/higher-order/with-state/index.js +23 -35
  114. package/build-module/higher-order/with-state/index.js.map +7 -1
  115. package/build-module/hooks/use-async-list/index.js +16 -33
  116. package/build-module/hooks/use-async-list/index.js.map +7 -1
  117. package/build-module/hooks/use-constrained-tabbing/index.js +26 -70
  118. package/build-module/hooks/use-constrained-tabbing/index.js.map +7 -1
  119. package/build-module/hooks/use-copy-on-click/index.js +14 -47
  120. package/build-module/hooks/use-copy-on-click/index.js.map +7 -1
  121. package/build-module/hooks/use-copy-to-clipboard/index.js +11 -44
  122. package/build-module/hooks/use-copy-to-clipboard/index.js.map +7 -1
  123. package/build-module/hooks/use-debounce/index.js +12 -33
  124. package/build-module/hooks/use-debounce/index.js.map +7 -1
  125. package/build-module/hooks/use-debounced-input/index.js +7 -18
  126. package/build-module/hooks/use-debounced-input/index.js.map +7 -1
  127. package/build-module/hooks/use-dialog/index.js +29 -43
  128. package/build-module/hooks/use-dialog/index.js.map +7 -1
  129. package/build-module/hooks/use-disabled/index.js +47 -78
  130. package/build-module/hooks/use-disabled/index.js.map +7 -1
  131. package/build-module/hooks/use-dragging/index.js +19 -39
  132. package/build-module/hooks/use-dragging/index.js.map +7 -1
  133. package/build-module/hooks/use-drop-zone/index.js +100 -158
  134. package/build-module/hooks/use-drop-zone/index.js.map +7 -1
  135. package/build-module/hooks/use-event/index.js +13 -39
  136. package/build-module/hooks/use-event/index.js.map +7 -1
  137. package/build-module/hooks/use-fixed-window-list/index.js +86 -87
  138. package/build-module/hooks/use-fixed-window-list/index.js.map +7 -1
  139. package/build-module/hooks/use-focus-on-mount/index.js +12 -48
  140. package/build-module/hooks/use-focus-on-mount/index.js.map +7 -1
  141. package/build-module/hooks/use-focus-outside/index.js +21 -93
  142. package/build-module/hooks/use-focus-outside/index.js.map +7 -1
  143. package/build-module/hooks/use-focus-return/index.js +13 -48
  144. package/build-module/hooks/use-focus-return/index.js.map +7 -1
  145. package/build-module/hooks/use-focusable-iframe/index.js +11 -31
  146. package/build-module/hooks/use-focusable-iframe/index.js.map +7 -1
  147. package/build-module/hooks/use-instance-id/index.js +7 -36
  148. package/build-module/hooks/use-instance-id/index.js.map +7 -1
  149. package/build-module/hooks/use-isomorphic-layout-effect/index.js +7 -13
  150. package/build-module/hooks/use-isomorphic-layout-effect/index.js.map +7 -1
  151. package/build-module/hooks/use-keyboard-shortcut/index.js +40 -60
  152. package/build-module/hooks/use-keyboard-shortcut/index.js.map +7 -1
  153. package/build-module/hooks/use-media-query/index.js +21 -30
  154. package/build-module/hooks/use-media-query/index.js.map +7 -1
  155. package/build-module/hooks/use-merge-refs/index.js +10 -92
  156. package/build-module/hooks/use-merge-refs/index.js.map +7 -1
  157. package/build-module/hooks/use-observable-value/index.js +13 -24
  158. package/build-module/hooks/use-observable-value/index.js.map +7 -1
  159. package/build-module/hooks/use-preferred-color-scheme/index.android.js +15 -18
  160. package/build-module/hooks/use-preferred-color-scheme/index.android.js.map +7 -1
  161. package/build-module/hooks/use-preferred-color-scheme/index.ios.js +6 -12
  162. package/build-module/hooks/use-preferred-color-scheme/index.ios.js.map +7 -1
  163. package/build-module/hooks/use-previous/index.js +7 -20
  164. package/build-module/hooks/use-previous/index.js.map +7 -1
  165. package/build-module/hooks/use-reduced-motion/index.js +7 -13
  166. package/build-module/hooks/use-reduced-motion/index.js.map +7 -1
  167. package/build-module/hooks/use-ref-effect/index.js +7 -31
  168. package/build-module/hooks/use-ref-effect/index.js.map +7 -1
  169. package/build-module/hooks/use-resize-observer/index.js +7 -61
  170. package/build-module/hooks/use-resize-observer/index.js.map +7 -1
  171. package/build-module/hooks/use-resize-observer/legacy/index.js +28 -96
  172. package/build-module/hooks/use-resize-observer/legacy/index.js.map +7 -1
  173. package/build-module/hooks/use-resize-observer/use-resize-observer.js +10 -28
  174. package/build-module/hooks/use-resize-observer/use-resize-observer.js.map +7 -1
  175. package/build-module/hooks/use-state-with-history/index.js +47 -55
  176. package/build-module/hooks/use-state-with-history/index.js.map +7 -1
  177. package/build-module/hooks/use-throttle/index.js +12 -33
  178. package/build-module/hooks/use-throttle/index.js.map +7 -1
  179. package/build-module/hooks/use-viewport-match/index.js +22 -64
  180. package/build-module/hooks/use-viewport-match/index.js.map +7 -1
  181. package/build-module/hooks/use-warn-on-change/index.js +21 -34
  182. package/build-module/hooks/use-warn-on-change/index.js.map +7 -1
  183. package/build-module/index.js +83 -53
  184. package/build-module/index.js.map +7 -1
  185. package/build-module/utils/create-higher-order-component/index.js +9 -30
  186. package/build-module/utils/create-higher-order-component/index.js.map +7 -1
  187. package/build-module/utils/debounce/index.js +17 -95
  188. package/build-module/utils/debounce/index.js.map +7 -1
  189. package/build-module/utils/observable-map/index.js +8 -16
  190. package/build-module/utils/observable-map/index.js.map +7 -1
  191. package/build-module/utils/throttle/index.js +8 -75
  192. package/build-module/utils/throttle/index.js.map +7 -1
  193. package/package.json +17 -10
  194. package/src/hooks/use-debounce/index.js +1 -1
  195. package/tsconfig.tsbuildinfo +1 -1
  196. package/build/higher-order/with-network-connectivity/index.native.js +0 -27
  197. package/build/higher-order/with-network-connectivity/index.native.js.map +0 -1
  198. package/build/higher-order/with-preferred-color-scheme/index.native.js +0 -37
  199. package/build/higher-order/with-preferred-color-scheme/index.native.js.map +0 -1
  200. package/build/hooks/use-constrained-tabbing/index.native.js +0 -20
  201. package/build/hooks/use-constrained-tabbing/index.native.js.map +0 -1
  202. package/build/hooks/use-focus-outside/index.native.js +0 -175
  203. package/build/hooks/use-focus-outside/index.native.js.map +0 -1
  204. package/build/hooks/use-keyboard-shortcut/index.native.js +0 -9
  205. package/build/hooks/use-keyboard-shortcut/index.native.js.map +0 -1
  206. package/build/hooks/use-network-connectivity/index.native.js +0 -58
  207. package/build/hooks/use-network-connectivity/index.native.js.map +0 -1
  208. package/build/hooks/use-preferred-color-scheme-style/index.native.js +0 -42
  209. package/build/hooks/use-preferred-color-scheme-style/index.native.js.map +0 -1
  210. package/build/hooks/use-resize-observer/index.native.js +0 -14
  211. package/build/hooks/use-resize-observer/index.native.js.map +0 -1
  212. package/build/hooks/use-resize-observer/legacy/index.native.js +0 -62
  213. package/build/hooks/use-resize-observer/legacy/index.native.js.map +0 -1
  214. package/build/index.native.js +0 -297
  215. package/build/index.native.js.map +0 -1
  216. package/build-module/higher-order/with-network-connectivity/index.native.js +0 -19
  217. package/build-module/higher-order/with-network-connectivity/index.native.js.map +0 -1
  218. package/build-module/higher-order/with-preferred-color-scheme/index.native.js +0 -29
  219. package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +0 -1
  220. package/build-module/hooks/use-constrained-tabbing/index.native.js +0 -13
  221. package/build-module/hooks/use-constrained-tabbing/index.native.js.map +0 -1
  222. package/build-module/hooks/use-focus-outside/index.native.js +0 -169
  223. package/build-module/hooks/use-focus-outside/index.native.js.map +0 -1
  224. package/build-module/hooks/use-keyboard-shortcut/index.native.js +0 -3
  225. package/build-module/hooks/use-keyboard-shortcut/index.native.js.map +0 -1
  226. package/build-module/hooks/use-network-connectivity/index.native.js +0 -52
  227. package/build-module/hooks/use-network-connectivity/index.native.js.map +0 -1
  228. package/build-module/hooks/use-preferred-color-scheme-style/index.native.js +0 -35
  229. package/build-module/hooks/use-preferred-color-scheme-style/index.native.js.map +0 -1
  230. package/build-module/hooks/use-resize-observer/index.native.js +0 -2
  231. package/build-module/hooks/use-resize-observer/index.native.js.map +0 -1
  232. package/build-module/hooks/use-resize-observer/legacy/index.native.js +0 -56
  233. package/build-module/hooks/use-resize-observer/legacy/index.native.js.map +0 -1
  234. package/build-module/index.native.js +0 -45
  235. package/build-module/index.native.js.map +0 -1
@@ -1,69 +1,17 @@
1
- /**
2
- * Parts of this source were derived and modified from lodash,
3
- * released under the MIT license.
4
- *
5
- * https://github.com/lodash/lodash
6
- *
7
- * Copyright JS Foundation and other contributors <https://js.foundation/>
8
- *
9
- * Based on Underscore.js, copyright Jeremy Ashkenas,
10
- * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
11
- *
12
- * This software consists of voluntary contributions made by many
13
- * individuals. For exact contribution history, see the revision history
14
- * available at https://github.com/lodash/lodash
15
- *
16
- * The following license applies to all parts of this software except as
17
- * documented below:
18
- *
19
- * ====
20
- *
21
- * Permission is hereby granted, free of charge, to any person obtaining
22
- * a copy of this software and associated documentation files (the
23
- * "Software"), to deal in the Software without restriction, including
24
- * without limitation the rights to use, copy, modify, merge, publish,
25
- * distribute, sublicense, and/or sell copies of the Software, and to
26
- * permit persons to whom the Software is furnished to do so, subject to
27
- * the following conditions:
28
- *
29
- * The above copyright notice and this permission notice shall be
30
- * included in all copies or substantial portions of the Software.
31
- *
32
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
36
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
37
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39
- */
40
-
41
- /**
42
- * Creates a pipe function.
43
- *
44
- * Allows to choose whether to perform left-to-right or right-to-left composition.
45
- *
46
- * @see https://lodash.com/docs/4#flow
47
- *
48
- * @param {boolean} reverse True if right-to-left, false for left-to-right composition.
49
- */
50
1
  const basePipe = (reverse = false) => (...funcs) => (...args) => {
51
2
  const functions = funcs.flat();
52
3
  if (reverse) {
53
4
  functions.reverse();
54
5
  }
55
- return functions.reduce((prev, func) => [func(...prev)], args)[0];
6
+ return functions.reduce(
7
+ (prev, func) => [func(...prev)],
8
+ args
9
+ )[0];
56
10
  };
57
-
58
- /**
59
- * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
60
- * composition, where each successive invocation is supplied the return value of the previous.
61
- *
62
- * This is inspired by `lodash`'s `flow` function.
63
- *
64
- * @see https://lodash.com/docs/4#flow
65
- */
66
11
  const pipe = basePipe();
67
- export { basePipe };
68
- export default pipe;
69
- //# sourceMappingURL=pipe.js.map
12
+ var pipe_default = pipe;
13
+ export {
14
+ basePipe,
15
+ pipe_default as default
16
+ };
17
+ //# sourceMappingURL=pipe.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["basePipe","reverse","funcs","args","functions","flat","reduce","prev","func","pipe"],"sources":["@wordpress/compose/src/higher-order/pipe.ts"],"sourcesContent":["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://lodash.com/docs/4#flow\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: Function[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://lodash.com/docs/4#flow\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GACbA,CAAEC,OAAgB,GAAG,KAAK,KAC1B,CAAE,GAAGC,KAAiB,KACtB,CAAE,GAAGC,IAAe,KAAM;EACzB,MAAMC,SAAS,GAAGF,KAAK,CAACG,IAAI,CAAC,CAAC;EAC9B,IAAKJ,OAAO,EAAG;IACdG,SAAS,CAACH,OAAO,CAAC,CAAC;EACpB;EACA,OAAOG,SAAS,CAACE,MAAM,CACtB,CAAEC,IAAI,EAAEC,IAAI,KAAM,CAAEA,IAAI,CAAE,GAAGD,IAAK,CAAC,CAAE,EACrCJ,IACD,CAAC,CAAE,CAAC,CAAE;AACP,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,IAAI,GAAGT,QAAQ,CAAC,CAAC;AAEvB,SAASA,QAAQ;AAEjB,eAAeS,IAAI","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/higher-order/pipe.ts"],
4
+ "sourcesContent": ["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://lodash.com/docs/4#flow\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: Function[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://lodash.com/docs/4#flow\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],
5
+ "mappings": "AAiDA,MAAM,WACL,CAAE,UAAmB,UACrB,IAAK,UACL,IAAK,SAAqB;AACzB,QAAM,YAAY,MAAM,KAAK;AAC7B,MAAK,SAAU;AACd,cAAU,QAAQ;AAAA,EACnB;AACA,SAAO,UAAU;AAAA,IAChB,CAAE,MAAM,SAAU,CAAE,KAAM,GAAG,IAAK,CAAE;AAAA,IACpC;AAAA,EACD,EAAG,CAAE;AACN;AAUD,MAAM,OAAO,SAAS;AAItB,IAAO,eAAQ;",
6
+ "names": []
7
+ }
@@ -1,26 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
-
5
- /**
6
- * WordPress dependencies
7
- */
8
- import isShallowEqual from '@wordpress/is-shallow-equal';
9
- import { Component } from '@wordpress/element';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
15
-
16
- /**
17
- * Given a component returns the enhanced component augmented with a component
18
- * only re-rendering when its props/state change
19
- *
20
- * @deprecated Use `memo` or `PureComponent` instead.
21
- */
22
- import { jsx as _jsx } from "react/jsx-runtime";
23
- const pure = createHigherOrderComponent(function (WrappedComponent) {
1
+ import { jsx } from "react/jsx-runtime";
2
+ import isShallowEqual from "@wordpress/is-shallow-equal";
3
+ import { Component } from "@wordpress/element";
4
+ import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
5
+ const pure = createHigherOrderComponent(function(WrappedComponent) {
24
6
  if (WrappedComponent.prototype instanceof Component) {
25
7
  return class extends WrappedComponent {
26
8
  shouldComponentUpdate(nextProps, nextState) {
@@ -33,11 +15,12 @@ const pure = createHigherOrderComponent(function (WrappedComponent) {
33
15
  return !isShallowEqual(nextProps, this.props);
34
16
  }
35
17
  render() {
36
- return /*#__PURE__*/_jsx(WrappedComponent, {
37
- ...this.props
38
- });
18
+ return /* @__PURE__ */ jsx(WrappedComponent, { ...this.props });
39
19
  }
40
20
  };
41
- }, 'pure');
42
- export default pure;
43
- //# sourceMappingURL=index.js.map
21
+ }, "pure");
22
+ var pure_default = pure;
23
+ export {
24
+ pure_default as default
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["isShallowEqual","Component","createHigherOrderComponent","jsx","_jsx","pure","WrappedComponent","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n *\n * @deprecated Use `memo` or `PureComponent` instead.\n */\nconst pure = createHigherOrderComponent( function < Props extends {} >(\n\tWrappedComponent: ComponentType< Props >\n): ComponentType< Props > {\n\tif ( WrappedComponent.prototype instanceof Component ) {\n\t\treturn class extends ( WrappedComponent as ComponentClass< Props > ) {\n\t\t\tshouldComponentUpdate( nextProps: Props, nextState: any ) {\n\t\t\t\treturn (\n\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn class extends Component< Props > {\n\t\tshouldComponentUpdate( nextProps: Props ) {\n\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t}\n\n\t\trender() {\n\t\t\treturn <WrappedComponent { ...this.props } />;\n\t\t}\n\t};\n}, 'pure' );\n\nexport default pure;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,cAAc,MAAM,6BAA6B;AACxD,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,0BAA0B,QAAQ,2CAA2C;;AAEtF;AACA;AACA;AACA;AACA;AACA;AALA,SAAAC,GAAA,IAAAC,IAAA;AAMA,MAAMC,IAAI,GAAGH,0BAA0B,CAAE,UACxCI,gBAAwC,EACf;EACzB,IAAKA,gBAAgB,CAACC,SAAS,YAAYN,SAAS,EAAG;IACtD,OAAO,cAAgBK,gBAAgB,CAA8B;MACpEE,qBAAqBA,CAAEC,SAAgB,EAAEC,SAAc,EAAG;QACzD,OACC,CAAEV,cAAc,CAAES,SAAS,EAAE,IAAI,CAACE,KAAM,CAAC,IACzC,CAAEX,cAAc,CAAEU,SAAS,EAAE,IAAI,CAACE,KAAM,CAAC;MAE3C;IACD,CAAC;EACF;EAEA,OAAO,cAAcX,SAAS,CAAU;IACvCO,qBAAqBA,CAAEC,SAAgB,EAAG;MACzC,OAAO,CAAET,cAAc,CAAES,SAAS,EAAE,IAAI,CAACE,KAAM,CAAC;IACjD;IAEAE,MAAMA,CAAA,EAAG;MACR,oBAAOT,IAAA,CAACE,gBAAgB;QAAA,GAAM,IAAI,CAACK;MAAK,CAAI,CAAC;IAC9C;EACD,CAAC;AACF,CAAC,EAAE,MAAO,CAAC;AAEX,eAAeN,IAAI","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/higher-order/pure/index.tsx"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n *\n * @deprecated Use `memo` or `PureComponent` instead.\n */\nconst pure = createHigherOrderComponent( function < Props extends {} >(\n\tWrappedComponent: ComponentType< Props >\n): ComponentType< Props > {\n\tif ( WrappedComponent.prototype instanceof Component ) {\n\t\treturn class extends ( WrappedComponent as ComponentClass< Props > ) {\n\t\t\tshouldComponentUpdate( nextProps: Props, nextState: any ) {\n\t\t\t\treturn (\n\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn class extends Component< Props > {\n\t\tshouldComponentUpdate( nextProps: Props ) {\n\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t}\n\n\t\trender() {\n\t\t\treturn <WrappedComponent { ...this.props } />;\n\t\t}\n\t};\n}, 'pure' );\n\nexport default pure;\n"],
5
+ "mappings": "AA0CU;AAlCV,OAAO,oBAAoB;AAC3B,SAAS,iBAAiB;AAK1B,SAAS,kCAAkC;AAQ3C,MAAM,OAAO,2BAA4B,SACxC,kBACyB;AACzB,MAAK,iBAAiB,qBAAqB,WAAY;AACtD,WAAO,cAAgB,iBAA8C;AAAA,MACpE,sBAAuB,WAAkB,WAAiB;AACzD,eACC,CAAE,eAAgB,WAAW,KAAK,KAAM,KACxC,CAAE,eAAgB,WAAW,KAAK,KAAM;AAAA,MAE1C;AAAA,IACD;AAAA,EACD;AAEA,SAAO,cAAc,UAAmB;AAAA,IACvC,sBAAuB,WAAmB;AACzC,aAAO,CAAE,eAAgB,WAAW,KAAK,KAAM;AAAA,IAChD;AAAA,IAEA,SAAS;AACR,aAAO,oBAAC,oBAAmB,GAAG,KAAK,OAAQ;AAAA,IAC5C;AAAA,EACD;AACD,GAAG,MAAO;AAEV,IAAO,eAAQ;",
6
+ "names": []
7
+ }
@@ -1,96 +1,63 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Component, forwardRef } from '@wordpress/element';
5
- import deprecated from '@wordpress/deprecated';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
11
- import Listener from './listener';
12
-
13
- /**
14
- * Listener instance responsible for managing document event handling.
15
- */
16
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Component, forwardRef } from "@wordpress/element";
3
+ import deprecated from "@wordpress/deprecated";
4
+ import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
5
+ import Listener from "./listener";
17
6
  const listener = new Listener();
18
-
19
- /* eslint-disable jsdoc/no-undefined-types */
20
- /**
21
- * Higher-order component creator which, given an object of DOM event types and
22
- * values corresponding to a callback function name on the component, will
23
- * create or update a window event handler to invoke the callback when an event
24
- * occurs. On behalf of the consuming developer, the higher-order component
25
- * manages unbinding when the component unmounts, and binding at most a single
26
- * event handler for the entire application.
27
- *
28
- * @deprecated
29
- *
30
- * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM
31
- * event type, the value a
32
- * name of the function on
33
- * the original component's
34
- * instance which handles
35
- * the event.
36
- *
37
- * @return {any} Higher-order component.
38
- */
39
- export default function withGlobalEvents(eventTypesToHandlers) {
40
- deprecated('wp.compose.withGlobalEvents', {
41
- since: '5.7',
42
- alternative: 'useEffect'
7
+ function withGlobalEvents(eventTypesToHandlers) {
8
+ deprecated("wp.compose.withGlobalEvents", {
9
+ since: "5.7",
10
+ alternative: "useEffect"
43
11
  });
44
-
45
- // @ts-ignore We don't need to fix the type-related issues because this is deprecated.
46
- return createHigherOrderComponent(WrappedComponent => {
12
+ return createHigherOrderComponent((WrappedComponent) => {
47
13
  class Wrapper extends Component {
48
- constructor(/** @type {any} */props) {
14
+ constructor(props) {
49
15
  super(props);
50
16
  this.handleEvent = this.handleEvent.bind(this);
51
17
  this.handleRef = this.handleRef.bind(this);
52
18
  }
53
19
  componentDidMount() {
54
- Object.keys(eventTypesToHandlers).forEach(eventType => {
20
+ Object.keys(eventTypesToHandlers).forEach((eventType) => {
55
21
  listener.add(eventType, this);
56
22
  });
57
23
  }
58
24
  componentWillUnmount() {
59
- Object.keys(eventTypesToHandlers).forEach(eventType => {
25
+ Object.keys(eventTypesToHandlers).forEach((eventType) => {
60
26
  listener.remove(eventType, this);
61
27
  });
62
28
  }
63
- handleEvent(/** @type {any} */event) {
64
- const handler = eventTypesToHandlers[(/** @type {keyof GlobalEventHandlersEventMap} */
65
- event.type
66
-
67
- /* eslint-enable jsdoc/no-undefined-types */)];
68
- if (typeof this.wrappedRef[handler] === 'function') {
29
+ handleEvent(event) {
30
+ const handler = eventTypesToHandlers[
31
+ /** @type {keyof GlobalEventHandlersEventMap} */
32
+ event.type
33
+ /* eslint-enable jsdoc/no-undefined-types */
34
+ ];
35
+ if (typeof this.wrappedRef[handler] === "function") {
69
36
  this.wrappedRef[handler](event);
70
37
  }
71
38
  }
72
- handleRef(/** @type {any} */el) {
39
+ handleRef(el) {
73
40
  this.wrappedRef = el;
74
- // Any component using `withGlobalEvents` that is not setting a `ref`
75
- // will cause `this.props.forwardedRef` to be `null`, so we need this
76
- // check.
77
41
  if (this.props.forwardedRef) {
78
42
  this.props.forwardedRef(el);
79
43
  }
80
44
  }
81
45
  render() {
82
- return /*#__PURE__*/_jsx(WrappedComponent, {
83
- ...this.props.ownProps,
84
- ref: this.handleRef
85
- });
46
+ return /* @__PURE__ */ jsx(
47
+ WrappedComponent,
48
+ {
49
+ ...this.props.ownProps,
50
+ ref: this.handleRef
51
+ }
52
+ );
86
53
  }
87
54
  }
88
55
  return forwardRef((props, ref) => {
89
- return /*#__PURE__*/_jsx(Wrapper, {
90
- ownProps: props,
91
- forwardedRef: ref
92
- });
56
+ return /* @__PURE__ */ jsx(Wrapper, { ownProps: props, forwardedRef: ref });
93
57
  });
94
- }, 'withGlobalEvents');
58
+ }, "withGlobalEvents");
95
59
  }
96
- //# sourceMappingURL=index.js.map
60
+ export {
61
+ withGlobalEvents as default
62
+ };
63
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Component","forwardRef","deprecated","createHigherOrderComponent","Listener","jsx","_jsx","listener","withGlobalEvents","eventTypesToHandlers","since","alternative","WrappedComponent","Wrapper","constructor","props","handleEvent","bind","handleRef","componentDidMount","Object","keys","forEach","eventType","add","componentWillUnmount","remove","event","handler","type","wrappedRef","el","forwardedRef","render","ownProps","ref"],"sources":["@wordpress/compose/src/higher-order/with-global-events/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport Listener from './listener';\n\n/**\n * Listener instance responsible for managing document event handling.\n */\nconst listener = new Listener();\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Higher-order component creator which, given an object of DOM event types and\n * values corresponding to a callback function name on the component, will\n * create or update a window event handler to invoke the callback when an event\n * occurs. On behalf of the consuming developer, the higher-order component\n * manages unbinding when the component unmounts, and binding at most a single\n * event handler for the entire application.\n *\n * @deprecated\n *\n * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM\n * event type, the value a\n * name of the function on\n * the original component's\n * instance which handles\n * the event.\n *\n * @return {any} Higher-order component.\n */\nexport default function withGlobalEvents( eventTypesToHandlers ) {\n\tdeprecated( 'wp.compose.withGlobalEvents', {\n\t\tsince: '5.7',\n\t\talternative: 'useEffect',\n\t} );\n\n\t// @ts-ignore We don't need to fix the type-related issues because this is deprecated.\n\treturn createHigherOrderComponent( ( WrappedComponent ) => {\n\t\tclass Wrapper extends Component {\n\t\t\tconstructor( /** @type {any} */ props ) {\n\t\t\t\tsuper( props );\n\n\t\t\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t\t\t\tthis.handleRef = this.handleRef.bind( this );\n\t\t\t}\n\n\t\t\tcomponentDidMount() {\n\t\t\t\tObject.keys( eventTypesToHandlers ).forEach( ( eventType ) => {\n\t\t\t\t\tlistener.add( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tObject.keys( eventTypesToHandlers ).forEach( ( eventType ) => {\n\t\t\t\t\tlistener.remove( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\thandleEvent( /** @type {any} */ event ) {\n\t\t\t\tconst handler =\n\t\t\t\t\teventTypesToHandlers[\n\t\t\t\t\t\t/** @type {keyof GlobalEventHandlersEventMap} */ (\n\t\t\t\t\t\t\tevent.type\n\t\t\t\t\t\t)\n\t\t\t\t\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t\t\t\t\t];\n\t\t\t\tif ( typeof this.wrappedRef[ handler ] === 'function' ) {\n\t\t\t\t\tthis.wrappedRef[ handler ]( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thandleRef( /** @type {any} */ el ) {\n\t\t\t\tthis.wrappedRef = el;\n\t\t\t\t// Any component using `withGlobalEvents` that is not setting a `ref`\n\t\t\t\t// will cause `this.props.forwardedRef` to be `null`, so we need this\n\t\t\t\t// check.\n\t\t\t\tif ( this.props.forwardedRef ) {\n\t\t\t\t\tthis.props.forwardedRef( el );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t{ ...this.props.ownProps }\n\t\t\t\t\t\tref={ this.handleRef }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn forwardRef( ( props, ref ) => {\n\t\t\treturn <Wrapper ownProps={ props } forwardedRef={ ref } />;\n\t\t} );\n\t}, 'withGlobalEvents' );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,UAAU,QAAQ,oBAAoB;AAC1D,OAAOC,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,SAASC,0BAA0B,QAAQ,2CAA2C;AACtF,OAAOC,QAAQ,MAAM,YAAY;;AAEjC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAGA,MAAMC,QAAQ,GAAG,IAAIH,QAAQ,CAAC,CAAC;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASI,gBAAgBA,CAAEC,oBAAoB,EAAG;EAChEP,UAAU,CAAE,6BAA6B,EAAE;IAC1CQ,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;;EAEH;EACA,OAAOR,0BAA0B,CAAIS,gBAAgB,IAAM;IAC1D,MAAMC,OAAO,SAASb,SAAS,CAAC;MAC/Bc,WAAWA,CAAE,kBAAmBC,KAAK,EAAG;QACvC,KAAK,CAAEA,KAAM,CAAC;QAEd,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAE,IAAK,CAAC;QAChD,IAAI,CAACC,SAAS,GAAG,IAAI,CAACA,SAAS,CAACD,IAAI,CAAE,IAAK,CAAC;MAC7C;MAEAE,iBAAiBA,CAAA,EAAG;QACnBC,MAAM,CAACC,IAAI,CAAEZ,oBAAqB,CAAC,CAACa,OAAO,CAAIC,SAAS,IAAM;UAC7DhB,QAAQ,CAACiB,GAAG,CAAED,SAAS,EAAE,IAAK,CAAC;QAChC,CAAE,CAAC;MACJ;MAEAE,oBAAoBA,CAAA,EAAG;QACtBL,MAAM,CAACC,IAAI,CAAEZ,oBAAqB,CAAC,CAACa,OAAO,CAAIC,SAAS,IAAM;UAC7DhB,QAAQ,CAACmB,MAAM,CAAEH,SAAS,EAAE,IAAK,CAAC;QACnC,CAAE,CAAC;MACJ;MAEAP,WAAWA,CAAE,kBAAmBW,KAAK,EAAG;QACvC,MAAMC,OAAO,GACZnB,oBAAoB,EACnB;QACCkB,KAAK,CAACE;;QAEP,8CACA;QACF,IAAK,OAAO,IAAI,CAACC,UAAU,CAAEF,OAAO,CAAE,KAAK,UAAU,EAAG;UACvD,IAAI,CAACE,UAAU,CAAEF,OAAO,CAAE,CAAED,KAAM,CAAC;QACpC;MACD;MAEAT,SAASA,CAAE,kBAAmBa,EAAE,EAAG;QAClC,IAAI,CAACD,UAAU,GAAGC,EAAE;QACpB;QACA;QACA;QACA,IAAK,IAAI,CAAChB,KAAK,CAACiB,YAAY,EAAG;UAC9B,IAAI,CAACjB,KAAK,CAACiB,YAAY,CAAED,EAAG,CAAC;QAC9B;MACD;MAEAE,MAAMA,CAAA,EAAG;QACR,oBACC3B,IAAA,CAACM,gBAAgB;UAAA,GACX,IAAI,CAACG,KAAK,CAACmB,QAAQ;UACxBC,GAAG,EAAG,IAAI,CAACjB;QAAW,CACtB,CAAC;MAEJ;IACD;IAEA,OAAOjB,UAAU,CAAE,CAAEc,KAAK,EAAEoB,GAAG,KAAM;MACpC,oBAAO7B,IAAA,CAACO,OAAO;QAACqB,QAAQ,EAAGnB,KAAO;QAACiB,YAAY,EAAGG;MAAK,CAAE,CAAC;IAC3D,CAAE,CAAC;EACJ,CAAC,EAAE,kBAAmB,CAAC;AACxB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/higher-order/with-global-events/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport Listener from './listener';\n\n/**\n * Listener instance responsible for managing document event handling.\n */\nconst listener = new Listener();\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Higher-order component creator which, given an object of DOM event types and\n * values corresponding to a callback function name on the component, will\n * create or update a window event handler to invoke the callback when an event\n * occurs. On behalf of the consuming developer, the higher-order component\n * manages unbinding when the component unmounts, and binding at most a single\n * event handler for the entire application.\n *\n * @deprecated\n *\n * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM\n * event type, the value a\n * name of the function on\n * the original component's\n * instance which handles\n * the event.\n *\n * @return {any} Higher-order component.\n */\nexport default function withGlobalEvents( eventTypesToHandlers ) {\n\tdeprecated( 'wp.compose.withGlobalEvents', {\n\t\tsince: '5.7',\n\t\talternative: 'useEffect',\n\t} );\n\n\t// @ts-ignore We don't need to fix the type-related issues because this is deprecated.\n\treturn createHigherOrderComponent( ( WrappedComponent ) => {\n\t\tclass Wrapper extends Component {\n\t\t\tconstructor( /** @type {any} */ props ) {\n\t\t\t\tsuper( props );\n\n\t\t\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t\t\t\tthis.handleRef = this.handleRef.bind( this );\n\t\t\t}\n\n\t\t\tcomponentDidMount() {\n\t\t\t\tObject.keys( eventTypesToHandlers ).forEach( ( eventType ) => {\n\t\t\t\t\tlistener.add( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tObject.keys( eventTypesToHandlers ).forEach( ( eventType ) => {\n\t\t\t\t\tlistener.remove( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\thandleEvent( /** @type {any} */ event ) {\n\t\t\t\tconst handler =\n\t\t\t\t\teventTypesToHandlers[\n\t\t\t\t\t\t/** @type {keyof GlobalEventHandlersEventMap} */ (\n\t\t\t\t\t\t\tevent.type\n\t\t\t\t\t\t)\n\t\t\t\t\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t\t\t\t\t];\n\t\t\t\tif ( typeof this.wrappedRef[ handler ] === 'function' ) {\n\t\t\t\t\tthis.wrappedRef[ handler ]( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thandleRef( /** @type {any} */ el ) {\n\t\t\t\tthis.wrappedRef = el;\n\t\t\t\t// Any component using `withGlobalEvents` that is not setting a `ref`\n\t\t\t\t// will cause `this.props.forwardedRef` to be `null`, so we need this\n\t\t\t\t// check.\n\t\t\t\tif ( this.props.forwardedRef ) {\n\t\t\t\t\tthis.props.forwardedRef( el );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t{ ...this.props.ownProps }\n\t\t\t\t\t\tref={ this.handleRef }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn forwardRef( ( props, ref ) => {\n\t\t\treturn <Wrapper ownProps={ props } forwardedRef={ ref } />;\n\t\t} );\n\t}, 'withGlobalEvents' );\n}\n"],
5
+ "mappings": "AA0FK;AAvFL,SAAS,WAAW,kBAAkB;AACtC,OAAO,gBAAgB;AAKvB,SAAS,kCAAkC;AAC3C,OAAO,cAAc;AAKrB,MAAM,WAAW,IAAI,SAAS;AAsBf,SAAR,iBAAmC,sBAAuB;AAChE,aAAY,+BAA+B;AAAA,IAC1C,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAGF,SAAO,2BAA4B,CAAE,qBAAsB;AAAA,IAC1D,MAAM,gBAAgB,UAAU;AAAA,MAC/B,YAAgC,OAAQ;AACvC,cAAO,KAAM;AAEb,aAAK,cAAc,KAAK,YAAY,KAAM,IAAK;AAC/C,aAAK,YAAY,KAAK,UAAU,KAAM,IAAK;AAAA,MAC5C;AAAA,MAEA,oBAAoB;AACnB,eAAO,KAAM,oBAAqB,EAAE,QAAS,CAAE,cAAe;AAC7D,mBAAS,IAAK,WAAW,IAAK;AAAA,QAC/B,CAAE;AAAA,MACH;AAAA,MAEA,uBAAuB;AACtB,eAAO,KAAM,oBAAqB,EAAE,QAAS,CAAE,cAAe;AAC7D,mBAAS,OAAQ,WAAW,IAAK;AAAA,QAClC,CAAE;AAAA,MACH;AAAA,MAEA,YAAgC,OAAQ;AACvC,cAAM,UACL;AAAA;AAAA,UAEE,MAAM;AAAA;AAAA,QAGR;AACD,YAAK,OAAO,KAAK,WAAY,OAAQ,MAAM,YAAa;AACvD,eAAK,WAAY,OAAQ,EAAG,KAAM;AAAA,QACnC;AAAA,MACD;AAAA,MAEA,UAA8B,IAAK;AAClC,aAAK,aAAa;AAIlB,YAAK,KAAK,MAAM,cAAe;AAC9B,eAAK,MAAM,aAAc,EAAG;AAAA,QAC7B;AAAA,MACD;AAAA,MAEA,SAAS;AACR,eACC;AAAA,UAAC;AAAA;AAAA,YACE,GAAG,KAAK,MAAM;AAAA,YAChB,KAAM,KAAK;AAAA;AAAA,QACZ;AAAA,MAEF;AAAA,IACD;AAEA,WAAO,WAAY,CAAE,OAAO,QAAS;AACpC,aAAO,oBAAC,WAAQ,UAAW,OAAQ,cAAe,KAAM;AAAA,IACzD,CAAE;AAAA,EACH,GAAG,kBAAmB;AACvB;",
6
+ "names": []
7
+ }
@@ -1,38 +1,37 @@
1
- /**
2
- * Class responsible for orchestrating event handling on the global window,
3
- * binding a single event to be shared across all handling instances, and
4
- * removing the handler when no instances are listening for the event.
5
- */
6
1
  class Listener {
7
2
  constructor() {
8
- /** @type {any} */
9
3
  this.listeners = {};
10
4
  this.handleEvent = this.handleEvent.bind(this);
11
5
  }
12
- add(/** @type {any} */eventType, /** @type {any} */instance) {
6
+ add(eventType, instance) {
13
7
  if (!this.listeners[eventType]) {
14
- // Adding first listener for this type, so bind event.
15
8
  window.addEventListener(eventType, this.handleEvent);
16
9
  this.listeners[eventType] = [];
17
10
  }
18
11
  this.listeners[eventType].push(instance);
19
12
  }
20
- remove(/** @type {any} */eventType, /** @type {any} */instance) {
13
+ remove(eventType, instance) {
21
14
  if (!this.listeners[eventType]) {
22
15
  return;
23
16
  }
24
- this.listeners[eventType] = this.listeners[eventType].filter((/** @type {any} */listener) => listener !== instance);
17
+ this.listeners[eventType] = this.listeners[eventType].filter(
18
+ (listener) => listener !== instance
19
+ );
25
20
  if (!this.listeners[eventType].length) {
26
- // Removing last listener for this type, so unbind event.
27
21
  window.removeEventListener(eventType, this.handleEvent);
28
22
  delete this.listeners[eventType];
29
23
  }
30
24
  }
31
- handleEvent(/** @type {any} */event) {
32
- this.listeners[event.type]?.forEach((/** @type {any} */instance) => {
33
- instance.handleEvent(event);
34
- });
25
+ handleEvent(event) {
26
+ this.listeners[event.type]?.forEach(
27
+ (instance) => {
28
+ instance.handleEvent(event);
29
+ }
30
+ );
35
31
  }
36
32
  }
37
- export default Listener;
38
- //# sourceMappingURL=listener.js.map
33
+ var listener_default = Listener;
34
+ export {
35
+ listener_default as default
36
+ };
37
+ //# sourceMappingURL=listener.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Listener","constructor","listeners","handleEvent","bind","add","eventType","instance","window","addEventListener","push","remove","filter","listener","length","removeEventListener","event","type","forEach"],"sources":["@wordpress/compose/src/higher-order/with-global-events/listener.js"],"sourcesContent":["/**\n * Class responsible for orchestrating event handling on the global window,\n * binding a single event to be shared across all handling instances, and\n * removing the handler when no instances are listening for the event.\n */\nclass Listener {\n\tconstructor() {\n\t\t/** @type {any} */\n\t\tthis.listeners = {};\n\n\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t}\n\n\tadd( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\t// Adding first listener for this type, so bind event.\n\t\t\twindow.addEventListener( eventType, this.handleEvent );\n\t\t\tthis.listeners[ eventType ] = [];\n\t\t}\n\n\t\tthis.listeners[ eventType ].push( instance );\n\t}\n\n\tremove( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.listeners[ eventType ] = this.listeners[ eventType ].filter(\n\t\t\t( /** @type {any} */ listener ) => listener !== instance\n\t\t);\n\n\t\tif ( ! this.listeners[ eventType ].length ) {\n\t\t\t// Removing last listener for this type, so unbind event.\n\t\t\twindow.removeEventListener( eventType, this.handleEvent );\n\t\t\tdelete this.listeners[ eventType ];\n\t\t}\n\t}\n\n\thandleEvent( /** @type {any} */ event ) {\n\t\tthis.listeners[ event.type ]?.forEach(\n\t\t\t( /** @type {any} */ instance ) => {\n\t\t\t\tinstance.handleEvent( event );\n\t\t\t}\n\t\t);\n\t}\n}\n\nexport default Listener;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,CAAC;EACdC,WAAWA,CAAA,EAAG;IACb;IACA,IAAI,CAACC,SAAS,GAAG,CAAC,CAAC;IAEnB,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAE,IAAK,CAAC;EACjD;EAEAC,GAAGA,CAAE,kBAAmBC,SAAS,EAAE,kBAAmBC,QAAQ,EAAG;IAChE,IAAK,CAAE,IAAI,CAACL,SAAS,CAAEI,SAAS,CAAE,EAAG;MACpC;MACAE,MAAM,CAACC,gBAAgB,CAAEH,SAAS,EAAE,IAAI,CAACH,WAAY,CAAC;MACtD,IAAI,CAACD,SAAS,CAAEI,SAAS,CAAE,GAAG,EAAE;IACjC;IAEA,IAAI,CAACJ,SAAS,CAAEI,SAAS,CAAE,CAACI,IAAI,CAAEH,QAAS,CAAC;EAC7C;EAEAI,MAAMA,CAAE,kBAAmBL,SAAS,EAAE,kBAAmBC,QAAQ,EAAG;IACnE,IAAK,CAAE,IAAI,CAACL,SAAS,CAAEI,SAAS,CAAE,EAAG;MACpC;IACD;IAEA,IAAI,CAACJ,SAAS,CAAEI,SAAS,CAAE,GAAG,IAAI,CAACJ,SAAS,CAAEI,SAAS,CAAE,CAACM,MAAM,CAC/D,CAAE,kBAAmBC,QAAQ,KAAMA,QAAQ,KAAKN,QACjD,CAAC;IAED,IAAK,CAAE,IAAI,CAACL,SAAS,CAAEI,SAAS,CAAE,CAACQ,MAAM,EAAG;MAC3C;MACAN,MAAM,CAACO,mBAAmB,CAAET,SAAS,EAAE,IAAI,CAACH,WAAY,CAAC;MACzD,OAAO,IAAI,CAACD,SAAS,CAAEI,SAAS,CAAE;IACnC;EACD;EAEAH,WAAWA,CAAE,kBAAmBa,KAAK,EAAG;IACvC,IAAI,CAACd,SAAS,CAAEc,KAAK,CAACC,IAAI,CAAE,EAAEC,OAAO,CACpC,CAAE,kBAAmBX,QAAQ,KAAM;MAClCA,QAAQ,CAACJ,WAAW,CAAEa,KAAM,CAAC;IAC9B,CACD,CAAC;EACF;AACD;AAEA,eAAehB,QAAQ","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/higher-order/with-global-events/listener.js"],
4
+ "sourcesContent": ["/**\n * Class responsible for orchestrating event handling on the global window,\n * binding a single event to be shared across all handling instances, and\n * removing the handler when no instances are listening for the event.\n */\nclass Listener {\n\tconstructor() {\n\t\t/** @type {any} */\n\t\tthis.listeners = {};\n\n\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t}\n\n\tadd( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\t// Adding first listener for this type, so bind event.\n\t\t\twindow.addEventListener( eventType, this.handleEvent );\n\t\t\tthis.listeners[ eventType ] = [];\n\t\t}\n\n\t\tthis.listeners[ eventType ].push( instance );\n\t}\n\n\tremove( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.listeners[ eventType ] = this.listeners[ eventType ].filter(\n\t\t\t( /** @type {any} */ listener ) => listener !== instance\n\t\t);\n\n\t\tif ( ! this.listeners[ eventType ].length ) {\n\t\t\t// Removing last listener for this type, so unbind event.\n\t\t\twindow.removeEventListener( eventType, this.handleEvent );\n\t\t\tdelete this.listeners[ eventType ];\n\t\t}\n\t}\n\n\thandleEvent( /** @type {any} */ event ) {\n\t\tthis.listeners[ event.type ]?.forEach(\n\t\t\t( /** @type {any} */ instance ) => {\n\t\t\t\tinstance.handleEvent( event );\n\t\t\t}\n\t\t);\n\t}\n}\n\nexport default Listener;\n"],
5
+ "mappings": "AAKA,MAAM,SAAS;AAAA,EACd,cAAc;AAEb,SAAK,YAAY,CAAC;AAElB,SAAK,cAAc,KAAK,YAAY,KAAM,IAAK;AAAA,EAChD;AAAA,EAEA,IAAwB,WAA8B,UAAW;AAChE,QAAK,CAAE,KAAK,UAAW,SAAU,GAAI;AAEpC,aAAO,iBAAkB,WAAW,KAAK,WAAY;AACrD,WAAK,UAAW,SAAU,IAAI,CAAC;AAAA,IAChC;AAEA,SAAK,UAAW,SAAU,EAAE,KAAM,QAAS;AAAA,EAC5C;AAAA,EAEA,OAA2B,WAA8B,UAAW;AACnE,QAAK,CAAE,KAAK,UAAW,SAAU,GAAI;AACpC;AAAA,IACD;AAEA,SAAK,UAAW,SAAU,IAAI,KAAK,UAAW,SAAU,EAAE;AAAA,MACzD,CAAqB,aAAc,aAAa;AAAA,IACjD;AAEA,QAAK,CAAE,KAAK,UAAW,SAAU,EAAE,QAAS;AAE3C,aAAO,oBAAqB,WAAW,KAAK,WAAY;AACxD,aAAO,KAAK,UAAW,SAAU;AAAA,IAClC;AAAA,EACD;AAAA,EAEA,YAAgC,OAAQ;AACvC,SAAK,UAAW,MAAM,IAAK,GAAG;AAAA,MAC7B,CAAqB,aAAc;AAClC,iBAAS,YAAa,KAAM;AAAA,MAC7B;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,mBAAQ;",
6
+ "names": []
7
+ }
@@ -1,22 +1,17 @@
1
- /**
2
- * Internal dependencies
3
- */
4
-
5
- import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
6
- import useInstanceId from '../../hooks/use-instance-id';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- /**
9
- * A Higher Order Component used to provide a unique instance ID by component.
10
- */
11
- const withInstanceId = createHigherOrderComponent(WrappedComponent => {
12
- return props => {
13
- const instanceId = useInstanceId(WrappedComponent);
14
- // @ts-ignore
15
- return /*#__PURE__*/_jsx(WrappedComponent, {
16
- ...props,
17
- instanceId: instanceId
18
- });
19
- };
20
- }, 'instanceId');
21
- export default withInstanceId;
22
- //# sourceMappingURL=index.js.map
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
3
+ import useInstanceId from "../../hooks/use-instance-id";
4
+ const withInstanceId = createHigherOrderComponent(
5
+ (WrappedComponent) => {
6
+ return (props) => {
7
+ const instanceId = useInstanceId(WrappedComponent);
8
+ return /* @__PURE__ */ jsx(WrappedComponent, { ...props, instanceId });
9
+ };
10
+ },
11
+ "instanceId"
12
+ );
13
+ var with_instance_id_default = withInstanceId;
14
+ export {
15
+ with_instance_id_default as default
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createHigherOrderComponent","useInstanceId","jsx","_jsx","withInstanceId","WrappedComponent","props","instanceId"],"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type {\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\ntype InstanceIdProps = { instanceId: string | number };\n\n/**\n * A Higher Order Component used to provide a unique instance ID by component.\n */\nconst withInstanceId = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, InstanceIdProps > >(\n\t\tWrappedComponent: C\n\t) => {\n\t\treturn ( props: WithoutInjectedProps< C, InstanceIdProps > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\t// @ts-ignore\n\t\t\treturn <WrappedComponent { ...props } instanceId={ instanceId } />;\n\t\t};\n\t},\n\t'instanceId'\n);\n\nexport default withInstanceId;\n"],"mappings":"AAAA;AACA;AACA;;AAKA,SAASA,0BAA0B,QAAQ,2CAA2C;AACtF,OAAOC,aAAa,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIxD;AACA;AACA;AACA,MAAMC,cAAc,GAAGJ,0BAA0B,CAE/CK,gBAAmB,IACf;EACJ,OAASC,KAAiD,IAAM;IAC/D,MAAMC,UAAU,GAAGN,aAAa,CAAEI,gBAAiB,CAAC;IACpD;IACA,oBAAOF,IAAA,CAACE,gBAAgB;MAAA,GAAMC,KAAK;MAAGC,UAAU,EAAGA;IAAY,CAAE,CAAC;EACnE,CAAC;AACF,CAAC,EACD,YACD,CAAC;AAED,eAAeH,cAAc","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/higher-order/with-instance-id/index.tsx"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\ntype InstanceIdProps = { instanceId: string | number };\n\n/**\n * A Higher Order Component used to provide a unique instance ID by component.\n */\nconst withInstanceId = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, InstanceIdProps > >(\n\t\tWrappedComponent: C\n\t) => {\n\t\treturn ( props: WithoutInjectedProps< C, InstanceIdProps > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\t// @ts-ignore\n\t\t\treturn <WrappedComponent { ...props } instanceId={ instanceId } />;\n\t\t};\n\t},\n\t'instanceId'\n);\n\nexport default withInstanceId;\n"],
5
+ "mappings": "AAsBU;AAfV,SAAS,kCAAkC;AAC3C,OAAO,mBAAmB;AAO1B,MAAM,iBAAiB;AAAA,EACtB,CACC,qBACI;AACJ,WAAO,CAAE,UAAuD;AAC/D,YAAM,aAAa,cAAe,gBAAiB;AAEnD,aAAO,oBAAC,oBAAmB,GAAG,OAAQ,YAA0B;AAAA,IACjE;AAAA,EACD;AAAA,EACA;AACD;AAEA,IAAO,2BAAQ;",
6
+ "names": []
7
+ }
@@ -1,62 +1,52 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Component } from '@wordpress/element';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
-
10
- import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
11
-
12
- /**
13
- * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`
14
- * types here because those functions include functionality that is not handled
15
- * by this component, like the ability to pass extra arguments.
16
- *
17
- * In the case of this component, we only handle the simplest case where
18
- * `setTimeout` only accepts a function (not a string) and an optional delay.
19
- */
20
- import { jsx as _jsx } from "react/jsx-runtime";
21
- /**
22
- * A higher-order component used to provide and manage delayed function calls
23
- * that ought to be bound to a component's lifecycle.
24
- */
25
- const withSafeTimeout = createHigherOrderComponent(OriginalComponent => {
26
- return class WrappedComponent extends Component {
27
- constructor(props) {
28
- super(props);
29
- this.timeouts = [];
30
- this.setTimeout = this.setTimeout.bind(this);
31
- this.clearTimeout = this.clearTimeout.bind(this);
32
- }
33
- componentWillUnmount() {
34
- this.timeouts.forEach(clearTimeout);
35
- }
36
- setTimeout(fn, delay) {
37
- const id = setTimeout(() => {
38
- fn();
39
- this.clearTimeout(id);
40
- }, delay);
41
- this.timeouts.push(id);
42
- return id;
43
- }
44
- clearTimeout(id) {
45
- clearTimeout(id);
46
- this.timeouts = this.timeouts.filter(timeoutId => timeoutId !== id);
47
- }
48
- render() {
49
- return (
50
- /*#__PURE__*/
51
- // @ts-ignore
52
- _jsx(OriginalComponent, {
53
- ...this.props,
54
- setTimeout: this.setTimeout,
55
- clearTimeout: this.clearTimeout
56
- })
57
- );
58
- }
59
- };
60
- }, 'withSafeTimeout');
61
- export default withSafeTimeout;
62
- //# sourceMappingURL=index.js.map
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Component } from "@wordpress/element";
3
+ import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
4
+ const withSafeTimeout = createHigherOrderComponent(
5
+ (OriginalComponent) => {
6
+ return class WrappedComponent extends Component {
7
+ timeouts;
8
+ constructor(props) {
9
+ super(props);
10
+ this.timeouts = [];
11
+ this.setTimeout = this.setTimeout.bind(this);
12
+ this.clearTimeout = this.clearTimeout.bind(this);
13
+ }
14
+ componentWillUnmount() {
15
+ this.timeouts.forEach(clearTimeout);
16
+ }
17
+ setTimeout(fn, delay) {
18
+ const id = setTimeout(() => {
19
+ fn();
20
+ this.clearTimeout(id);
21
+ }, delay);
22
+ this.timeouts.push(id);
23
+ return id;
24
+ }
25
+ clearTimeout(id) {
26
+ clearTimeout(id);
27
+ this.timeouts = this.timeouts.filter(
28
+ (timeoutId) => timeoutId !== id
29
+ );
30
+ }
31
+ render() {
32
+ return (
33
+ // @ts-ignore
34
+ /* @__PURE__ */ jsx(
35
+ OriginalComponent,
36
+ {
37
+ ...this.props,
38
+ setTimeout: this.setTimeout,
39
+ clearTimeout: this.clearTimeout
40
+ }
41
+ )
42
+ );
43
+ }
44
+ };
45
+ },
46
+ "withSafeTimeout"
47
+ );
48
+ var with_safe_timeout_default = withSafeTimeout;
49
+ export {
50
+ with_safe_timeout_default as default
51
+ };
52
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["Component","createHigherOrderComponent","jsx","_jsx","withSafeTimeout","OriginalComponent","WrappedComponent","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","filter","timeoutId","render"],"sources":["@wordpress/compose/src/higher-order/with-safe-timeout/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`\n * types here because those functions include functionality that is not handled\n * by this component, like the ability to pass extra arguments.\n *\n * In the case of this component, we only handle the simplest case where\n * `setTimeout` only accepts a function (not a string) and an optional delay.\n */\ninterface TimeoutProps {\n\tsetTimeout: ( fn: () => void, delay: number ) => number;\n\tclearTimeout: ( id: number ) => void;\n}\n\n/**\n * A higher-order component used to provide and manage delayed function calls\n * that ought to be bound to a component's lifecycle.\n */\nconst withSafeTimeout = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, TimeoutProps > >(\n\t\tOriginalComponent: C\n\t) => {\n\t\ttype WrappedProps = WithoutInjectedProps< C, TimeoutProps >;\n\t\treturn class WrappedComponent extends Component< WrappedProps > {\n\t\t\ttimeouts: number[];\n\n\t\t\tconstructor( props: WrappedProps ) {\n\t\t\t\tsuper( props );\n\t\t\t\tthis.timeouts = [];\n\t\t\t\tthis.setTimeout = this.setTimeout.bind( this );\n\t\t\t\tthis.clearTimeout = this.clearTimeout.bind( this );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tthis.timeouts.forEach( clearTimeout );\n\t\t\t}\n\n\t\t\tsetTimeout( fn: () => void, delay: number ) {\n\t\t\t\tconst id = setTimeout( () => {\n\t\t\t\t\tfn();\n\t\t\t\t\tthis.clearTimeout( id );\n\t\t\t\t}, delay );\n\t\t\t\tthis.timeouts.push( id );\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tclearTimeout( id: number ) {\n\t\t\t\tclearTimeout( id );\n\t\t\t\tthis.timeouts = this.timeouts.filter(\n\t\t\t\t\t( timeoutId ) => timeoutId !== id\n\t\t\t\t);\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...this.props }\n\t\t\t\t\t\tsetTimeout={ this.setTimeout }\n\t\t\t\t\t\tclearTimeout={ this.clearTimeout }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n\t'withSafeTimeout'\n);\n\nexport default withSafeTimeout;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;;AAKA,SAASC,0BAA0B,QAAQ,2CAA2C;;AAEtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,SAAAC,GAAA,IAAAC,IAAA;AAaA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGH,0BAA0B,CAEhDI,iBAAoB,IAChB;EAEJ,OAAO,MAAMC,gBAAgB,SAASN,SAAS,CAAiB;IAG/DO,WAAWA,CAAEC,KAAmB,EAAG;MAClC,KAAK,CAAEA,KAAM,CAAC;MACd,IAAI,CAACC,QAAQ,GAAG,EAAE;MAClB,IAAI,CAACC,UAAU,GAAG,IAAI,CAACA,UAAU,CAACC,IAAI,CAAE,IAAK,CAAC;MAC9C,IAAI,CAACC,YAAY,GAAG,IAAI,CAACA,YAAY,CAACD,IAAI,CAAE,IAAK,CAAC;IACnD;IAEAE,oBAAoBA,CAAA,EAAG;MACtB,IAAI,CAACJ,QAAQ,CAACK,OAAO,CAAEF,YAAa,CAAC;IACtC;IAEAF,UAAUA,CAAEK,EAAc,EAAEC,KAAa,EAAG;MAC3C,MAAMC,EAAE,GAAGP,UAAU,CAAE,MAAM;QAC5BK,EAAE,CAAC,CAAC;QACJ,IAAI,CAACH,YAAY,CAAEK,EAAG,CAAC;MACxB,CAAC,EAAED,KAAM,CAAC;MACV,IAAI,CAACP,QAAQ,CAACS,IAAI,CAAED,EAAG,CAAC;MACxB,OAAOA,EAAE;IACV;IAEAL,YAAYA,CAAEK,EAAU,EAAG;MAC1BL,YAAY,CAAEK,EAAG,CAAC;MAClB,IAAI,CAACR,QAAQ,GAAG,IAAI,CAACA,QAAQ,CAACU,MAAM,CACjCC,SAAS,IAAMA,SAAS,KAAKH,EAChC,CAAC;IACF;IAEAI,MAAMA,CAAA,EAAG;MACR;QAAA;QACC;QACAlB,IAAA,CAACE,iBAAiB;UAAA,GACZ,IAAI,CAACG,KAAK;UACfE,UAAU,EAAG,IAAI,CAACA,UAAY;UAC9BE,YAAY,EAAG,IAAI,CAACA;QAAc,CAClC;MAAC;IAEJ;EACD,CAAC;AACF,CAAC,EACD,iBACD,CAAC;AAED,eAAeR,eAAe","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/higher-order/with-safe-timeout/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`\n * types here because those functions include functionality that is not handled\n * by this component, like the ability to pass extra arguments.\n *\n * In the case of this component, we only handle the simplest case where\n * `setTimeout` only accepts a function (not a string) and an optional delay.\n */\ninterface TimeoutProps {\n\tsetTimeout: ( fn: () => void, delay: number ) => number;\n\tclearTimeout: ( id: number ) => void;\n}\n\n/**\n * A higher-order component used to provide and manage delayed function calls\n * that ought to be bound to a component's lifecycle.\n */\nconst withSafeTimeout = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, TimeoutProps > >(\n\t\tOriginalComponent: C\n\t) => {\n\t\ttype WrappedProps = WithoutInjectedProps< C, TimeoutProps >;\n\t\treturn class WrappedComponent extends Component< WrappedProps > {\n\t\t\ttimeouts: number[];\n\n\t\t\tconstructor( props: WrappedProps ) {\n\t\t\t\tsuper( props );\n\t\t\t\tthis.timeouts = [];\n\t\t\t\tthis.setTimeout = this.setTimeout.bind( this );\n\t\t\t\tthis.clearTimeout = this.clearTimeout.bind( this );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tthis.timeouts.forEach( clearTimeout );\n\t\t\t}\n\n\t\t\tsetTimeout( fn: () => void, delay: number ) {\n\t\t\t\tconst id = setTimeout( () => {\n\t\t\t\t\tfn();\n\t\t\t\t\tthis.clearTimeout( id );\n\t\t\t\t}, delay );\n\t\t\t\tthis.timeouts.push( id );\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tclearTimeout( id: number ) {\n\t\t\t\tclearTimeout( id );\n\t\t\t\tthis.timeouts = this.timeouts.filter(\n\t\t\t\t\t( timeoutId ) => timeoutId !== id\n\t\t\t\t);\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...this.props }\n\t\t\t\t\t\tsetTimeout={ this.setTimeout }\n\t\t\t\t\t\tclearTimeout={ this.clearTimeout }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n\t'withSafeTimeout'\n);\n\nexport default withSafeTimeout;\n"],
5
+ "mappings": "AAqEK;AAlEL,SAAS,iBAAiB;AAS1B,SAAS,kCAAkC;AAmB3C,MAAM,kBAAkB;AAAA,EACvB,CACC,sBACI;AAEJ,WAAO,MAAM,yBAAyB,UAA0B;AAAA,MAC/D;AAAA,MAEA,YAAa,OAAsB;AAClC,cAAO,KAAM;AACb,aAAK,WAAW,CAAC;AACjB,aAAK,aAAa,KAAK,WAAW,KAAM,IAAK;AAC7C,aAAK,eAAe,KAAK,aAAa,KAAM,IAAK;AAAA,MAClD;AAAA,MAEA,uBAAuB;AACtB,aAAK,SAAS,QAAS,YAAa;AAAA,MACrC;AAAA,MAEA,WAAY,IAAgB,OAAgB;AAC3C,cAAM,KAAK,WAAY,MAAM;AAC5B,aAAG;AACH,eAAK,aAAc,EAAG;AAAA,QACvB,GAAG,KAAM;AACT,aAAK,SAAS,KAAM,EAAG;AACvB,eAAO;AAAA,MACR;AAAA,MAEA,aAAc,IAAa;AAC1B,qBAAc,EAAG;AACjB,aAAK,WAAW,KAAK,SAAS;AAAA,UAC7B,CAAE,cAAe,cAAc;AAAA,QAChC;AAAA,MACD;AAAA,MAEA,SAAS;AACR;AAAA;AAAA,UAEC;AAAA,YAAC;AAAA;AAAA,cACE,GAAG,KAAK;AAAA,cACV,YAAa,KAAK;AAAA,cAClB,cAAe,KAAK;AAAA;AAAA,UACrB;AAAA;AAAA,MAEF;AAAA,IACD;AAAA,EACD;AAAA,EACA;AACD;AAEA,IAAO,4BAAQ;",
6
+ "names": []
7
+ }