@react-aria/utils 3.33.1 → 3.34.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 (262) hide show
  1. package/dist/import.mjs +47 -43
  2. package/dist/main.js +120 -115
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +47 -43
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +45 -0
  7. package/package.json +15 -15
  8. package/src/index.ts +45 -43
  9. package/dist/DOMFunctions.main.js +0 -57
  10. package/dist/DOMFunctions.main.js.map +0 -1
  11. package/dist/DOMFunctions.mjs +0 -49
  12. package/dist/DOMFunctions.module.js +0 -49
  13. package/dist/DOMFunctions.module.js.map +0 -1
  14. package/dist/ShadowTreeWalker.main.js +0 -200
  15. package/dist/ShadowTreeWalker.main.js.map +0 -1
  16. package/dist/ShadowTreeWalker.mjs +0 -194
  17. package/dist/ShadowTreeWalker.module.js +0 -194
  18. package/dist/ShadowTreeWalker.module.js.map +0 -1
  19. package/dist/animation.main.js +0 -97
  20. package/dist/animation.main.js.map +0 -1
  21. package/dist/animation.mjs +0 -91
  22. package/dist/animation.module.js +0 -91
  23. package/dist/animation.module.js.map +0 -1
  24. package/dist/chain.main.js +0 -26
  25. package/dist/chain.main.js.map +0 -1
  26. package/dist/chain.mjs +0 -21
  27. package/dist/chain.module.js +0 -21
  28. package/dist/chain.module.js.map +0 -1
  29. package/dist/constants.main.js +0 -23
  30. package/dist/constants.main.js.map +0 -1
  31. package/dist/constants.mjs +0 -17
  32. package/dist/constants.module.js +0 -17
  33. package/dist/constants.module.js.map +0 -1
  34. package/dist/domHelpers.main.js +0 -28
  35. package/dist/domHelpers.main.js.map +0 -1
  36. package/dist/domHelpers.mjs +0 -21
  37. package/dist/domHelpers.module.js +0 -21
  38. package/dist/domHelpers.module.js.map +0 -1
  39. package/dist/filterDOMProps.main.js +0 -88
  40. package/dist/filterDOMProps.main.js.map +0 -1
  41. package/dist/filterDOMProps.mjs +0 -83
  42. package/dist/filterDOMProps.module.js +0 -83
  43. package/dist/filterDOMProps.module.js.map +0 -1
  44. package/dist/focusWithoutScrolling.main.js +0 -72
  45. package/dist/focusWithoutScrolling.main.js.map +0 -1
  46. package/dist/focusWithoutScrolling.mjs +0 -67
  47. package/dist/focusWithoutScrolling.module.js +0 -67
  48. package/dist/focusWithoutScrolling.module.js.map +0 -1
  49. package/dist/getOffset.main.js +0 -24
  50. package/dist/getOffset.main.js.map +0 -1
  51. package/dist/getOffset.mjs +0 -19
  52. package/dist/getOffset.module.js +0 -19
  53. package/dist/getOffset.module.js.map +0 -1
  54. package/dist/getScrollParent.main.js +0 -28
  55. package/dist/getScrollParent.main.js.map +0 -1
  56. package/dist/getScrollParent.mjs +0 -23
  57. package/dist/getScrollParent.module.js +0 -23
  58. package/dist/getScrollParent.module.js.map +0 -1
  59. package/dist/getScrollParents.main.js +0 -31
  60. package/dist/getScrollParents.main.js.map +0 -1
  61. package/dist/getScrollParents.mjs +0 -26
  62. package/dist/getScrollParents.module.js +0 -26
  63. package/dist/getScrollParents.module.js.map +0 -1
  64. package/dist/inertValue.main.js +0 -19
  65. package/dist/inertValue.main.js.map +0 -1
  66. package/dist/inertValue.mjs +0 -14
  67. package/dist/inertValue.module.js +0 -14
  68. package/dist/inertValue.module.js.map +0 -1
  69. package/dist/isElementVisible.main.js +0 -45
  70. package/dist/isElementVisible.main.js.map +0 -1
  71. package/dist/isElementVisible.mjs +0 -40
  72. package/dist/isElementVisible.module.js +0 -40
  73. package/dist/isElementVisible.module.js.map +0 -1
  74. package/dist/isFocusable.main.js +0 -56
  75. package/dist/isFocusable.main.js.map +0 -1
  76. package/dist/isFocusable.mjs +0 -50
  77. package/dist/isFocusable.module.js +0 -50
  78. package/dist/isFocusable.module.js.map +0 -1
  79. package/dist/isScrollable.main.js +0 -29
  80. package/dist/isScrollable.main.js.map +0 -1
  81. package/dist/isScrollable.mjs +0 -24
  82. package/dist/isScrollable.module.js +0 -24
  83. package/dist/isScrollable.module.js.map +0 -1
  84. package/dist/isVirtualEvent.main.js +0 -41
  85. package/dist/isVirtualEvent.main.js.map +0 -1
  86. package/dist/isVirtualEvent.mjs +0 -35
  87. package/dist/isVirtualEvent.module.js +0 -35
  88. package/dist/isVirtualEvent.module.js.map +0 -1
  89. package/dist/keyboard.main.js +0 -42
  90. package/dist/keyboard.main.js.map +0 -1
  91. package/dist/keyboard.mjs +0 -36
  92. package/dist/keyboard.module.js +0 -36
  93. package/dist/keyboard.module.js.map +0 -1
  94. package/dist/mergeProps.main.js +0 -54
  95. package/dist/mergeProps.main.js.map +0 -1
  96. package/dist/mergeProps.mjs +0 -45
  97. package/dist/mergeProps.module.js +0 -45
  98. package/dist/mergeProps.module.js.map +0 -1
  99. package/dist/mergeRefs.main.js +0 -40
  100. package/dist/mergeRefs.main.js.map +0 -1
  101. package/dist/mergeRefs.mjs +0 -35
  102. package/dist/mergeRefs.module.js +0 -35
  103. package/dist/mergeRefs.module.js.map +0 -1
  104. package/dist/openLink.main.js +0 -169
  105. package/dist/openLink.main.js.map +0 -1
  106. package/dist/openLink.mjs +0 -153
  107. package/dist/openLink.module.js +0 -153
  108. package/dist/openLink.module.js.map +0 -1
  109. package/dist/platform.main.js +0 -73
  110. package/dist/platform.main.js.map +0 -1
  111. package/dist/platform.mjs +0 -60
  112. package/dist/platform.module.js +0 -60
  113. package/dist/platform.module.js.map +0 -1
  114. package/dist/runAfterTransition.main.js +0 -97
  115. package/dist/runAfterTransition.main.js.map +0 -1
  116. package/dist/runAfterTransition.mjs +0 -92
  117. package/dist/runAfterTransition.module.js +0 -92
  118. package/dist/runAfterTransition.module.js.map +0 -1
  119. package/dist/scrollIntoView.main.js +0 -138
  120. package/dist/scrollIntoView.main.js.map +0 -1
  121. package/dist/scrollIntoView.mjs +0 -132
  122. package/dist/scrollIntoView.module.js +0 -132
  123. package/dist/scrollIntoView.module.js.map +0 -1
  124. package/dist/types.d.ts +0 -299
  125. package/dist/types.d.ts.map +0 -1
  126. package/dist/useDeepMemo.main.js +0 -30
  127. package/dist/useDeepMemo.main.js.map +0 -1
  128. package/dist/useDeepMemo.mjs +0 -25
  129. package/dist/useDeepMemo.module.js +0 -25
  130. package/dist/useDeepMemo.module.js.map +0 -1
  131. package/dist/useDescription.main.js +0 -59
  132. package/dist/useDescription.main.js.map +0 -1
  133. package/dist/useDescription.mjs +0 -54
  134. package/dist/useDescription.module.js +0 -54
  135. package/dist/useDescription.module.js.map +0 -1
  136. package/dist/useDrag1D.main.js +0 -141
  137. package/dist/useDrag1D.main.js.map +0 -1
  138. package/dist/useDrag1D.mjs +0 -136
  139. package/dist/useDrag1D.module.js +0 -136
  140. package/dist/useDrag1D.module.js.map +0 -1
  141. package/dist/useEffectEvent.main.js +0 -45
  142. package/dist/useEffectEvent.main.js.map +0 -1
  143. package/dist/useEffectEvent.mjs +0 -36
  144. package/dist/useEffectEvent.module.js +0 -36
  145. package/dist/useEffectEvent.module.js.map +0 -1
  146. package/dist/useEvent.main.js +0 -41
  147. package/dist/useEvent.main.js.map +0 -1
  148. package/dist/useEvent.mjs +0 -36
  149. package/dist/useEvent.module.js +0 -36
  150. package/dist/useEvent.module.js.map +0 -1
  151. package/dist/useFormReset.main.js +0 -39
  152. package/dist/useFormReset.main.js.map +0 -1
  153. package/dist/useFormReset.mjs +0 -34
  154. package/dist/useFormReset.module.js +0 -34
  155. package/dist/useFormReset.module.js.map +0 -1
  156. package/dist/useGlobalListeners.main.js +0 -62
  157. package/dist/useGlobalListeners.main.js.map +0 -1
  158. package/dist/useGlobalListeners.mjs +0 -57
  159. package/dist/useGlobalListeners.module.js +0 -57
  160. package/dist/useGlobalListeners.module.js.map +0 -1
  161. package/dist/useId.main.js +0 -108
  162. package/dist/useId.main.js.map +0 -1
  163. package/dist/useId.mjs +0 -101
  164. package/dist/useId.module.js +0 -101
  165. package/dist/useId.module.js.map +0 -1
  166. package/dist/useLabels.main.js +0 -44
  167. package/dist/useLabels.main.js.map +0 -1
  168. package/dist/useLabels.mjs +0 -39
  169. package/dist/useLabels.module.js +0 -39
  170. package/dist/useLabels.module.js.map +0 -1
  171. package/dist/useLayoutEffect.main.js +0 -27
  172. package/dist/useLayoutEffect.main.js.map +0 -1
  173. package/dist/useLayoutEffect.mjs +0 -18
  174. package/dist/useLayoutEffect.module.js +0 -18
  175. package/dist/useLayoutEffect.module.js.map +0 -1
  176. package/dist/useLoadMore.main.js +0 -73
  177. package/dist/useLoadMore.main.js.map +0 -1
  178. package/dist/useLoadMore.mjs +0 -68
  179. package/dist/useLoadMore.module.js +0 -68
  180. package/dist/useLoadMore.module.js.map +0 -1
  181. package/dist/useLoadMoreSentinel.main.js +0 -58
  182. package/dist/useLoadMoreSentinel.main.js.map +0 -1
  183. package/dist/useLoadMoreSentinel.mjs +0 -53
  184. package/dist/useLoadMoreSentinel.module.js +0 -53
  185. package/dist/useLoadMoreSentinel.module.js.map +0 -1
  186. package/dist/useObjectRef.main.js +0 -58
  187. package/dist/useObjectRef.main.js.map +0 -1
  188. package/dist/useObjectRef.mjs +0 -53
  189. package/dist/useObjectRef.module.js +0 -53
  190. package/dist/useObjectRef.module.js.map +0 -1
  191. package/dist/useResizeObserver.main.js +0 -47
  192. package/dist/useResizeObserver.main.js.map +0 -1
  193. package/dist/useResizeObserver.mjs +0 -42
  194. package/dist/useResizeObserver.module.js +0 -42
  195. package/dist/useResizeObserver.module.js.map +0 -1
  196. package/dist/useSyncRef.main.js +0 -32
  197. package/dist/useSyncRef.main.js.map +0 -1
  198. package/dist/useSyncRef.mjs +0 -27
  199. package/dist/useSyncRef.module.js +0 -27
  200. package/dist/useSyncRef.module.js.map +0 -1
  201. package/dist/useUpdateEffect.main.js +0 -42
  202. package/dist/useUpdateEffect.main.js.map +0 -1
  203. package/dist/useUpdateEffect.mjs +0 -37
  204. package/dist/useUpdateEffect.module.js +0 -37
  205. package/dist/useUpdateEffect.module.js.map +0 -1
  206. package/dist/useUpdateLayoutEffect.main.js +0 -40
  207. package/dist/useUpdateLayoutEffect.main.js.map +0 -1
  208. package/dist/useUpdateLayoutEffect.mjs +0 -35
  209. package/dist/useUpdateLayoutEffect.module.js +0 -35
  210. package/dist/useUpdateLayoutEffect.module.js.map +0 -1
  211. package/dist/useValueEffect.main.js +0 -63
  212. package/dist/useValueEffect.main.js.map +0 -1
  213. package/dist/useValueEffect.mjs +0 -58
  214. package/dist/useValueEffect.module.js +0 -58
  215. package/dist/useValueEffect.module.js.map +0 -1
  216. package/dist/useViewportSize.main.js +0 -84
  217. package/dist/useViewportSize.main.js.map +0 -1
  218. package/dist/useViewportSize.mjs +0 -79
  219. package/dist/useViewportSize.module.js +0 -79
  220. package/dist/useViewportSize.module.js.map +0 -1
  221. package/src/animation.ts +0 -103
  222. package/src/chain.ts +0 -24
  223. package/src/constants.ts +0 -15
  224. package/src/domHelpers.ts +0 -33
  225. package/src/filterDOMProps.ts +0 -127
  226. package/src/focusWithoutScrolling.ts +0 -96
  227. package/src/getOffset.ts +0 -21
  228. package/src/getScrollParent.ts +0 -27
  229. package/src/getScrollParents.ts +0 -27
  230. package/src/inertValue.ts +0 -11
  231. package/src/isElementVisible.ts +0 -75
  232. package/src/isFocusable.ts +0 -56
  233. package/src/isScrollable.ts +0 -31
  234. package/src/isVirtualEvent.ts +0 -58
  235. package/src/keyboard.tsx +0 -48
  236. package/src/mergeProps.ts +0 -77
  237. package/src/mergeRefs.ts +0 -52
  238. package/src/openLink.tsx +0 -201
  239. package/src/platform.ts +0 -78
  240. package/src/runAfterTransition.ts +0 -124
  241. package/src/scrollIntoView.ts +0 -168
  242. package/src/shadowdom/DOMFunctions.ts +0 -100
  243. package/src/shadowdom/ShadowTreeWalker.ts +0 -319
  244. package/src/useDeepMemo.ts +0 -27
  245. package/src/useDescription.ts +0 -56
  246. package/src/useDrag1D.ts +0 -191
  247. package/src/useEffectEvent.ts +0 -30
  248. package/src/useEvent.ts +0 -37
  249. package/src/useFormReset.ts +0 -36
  250. package/src/useGlobalListeners.ts +0 -52
  251. package/src/useId.ts +0 -129
  252. package/src/useLabels.ts +0 -48
  253. package/src/useLayoutEffect.ts +0 -20
  254. package/src/useLoadMore.ts +0 -82
  255. package/src/useLoadMoreSentinel.ts +0 -63
  256. package/src/useObjectRef.ts +0 -69
  257. package/src/useResizeObserver.ts +0 -52
  258. package/src/useSyncRef.ts +0 -33
  259. package/src/useUpdateEffect.ts +0 -39
  260. package/src/useUpdateLayoutEffect.ts +0 -37
  261. package/src/useValueEffect.ts +0 -68
  262. package/src/useViewportSize.ts +0 -103
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAWM,SAAS,0CAAkB,YAA2B;IAC3D,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,qBAAO,EAAE;IACjC,iGAAiG;IACjG,sDAAsD;IACtD,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IACvB,IAAI,SAAyC,CAAA,GAAA,mBAAK,EAAuB;IAEzE,0EAA0E;IAC1E,yCAAyC;IACzC,IAAI,UAAU,CAAA,GAAA,mBAAK,EAAE;QACnB,IAAI,CAAC,OAAO,OAAO,EACjB;QAEF,uCAAuC;QACvC,IAAI,WAAW,OAAO,OAAO,CAAC,IAAI;QAElC,8CAA8C;QAC9C,IAAI,SAAS,IAAI,EAAE;YACjB,OAAO,OAAO,GAAG;YACjB;QACF;QAEA,iDAAiD;QACjD,8CAA8C;QAC9C,8DAA8D;QAC9D,IAAI,UAAU,OAAO,KAAK,SAAS,KAAK,EACtC,QAAQ,OAAO;aAEf,SAAS,SAAS,KAAK;IAE3B;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,UAAU,OAAO,GAAG;QACpB,uEAAuE;QACvE,IAAI,OAAO,OAAO,EAChB,QAAQ,OAAO;IAEnB;IAEA,IAAI,QAAQ,CAAA,GAAA,wBAAU,EAAE,CAAA;QACtB,OAAO,OAAO,GAAG,GAAG,UAAU,OAAO;QACrC,QAAQ,OAAO;IACjB,GAAG;QAAC;KAAQ;IAEZ,OAAO;QAAC;QAAO;KAAM;AACvB","sources":["packages/@react-aria/utils/src/useValueEffect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Dispatch, RefObject, useCallback, useRef, useState} from 'react';\nimport {useLayoutEffect} from './';\n\ntype SetValueAction<S> = (prev: S) => Generator<any, void, unknown>;\n\n// This hook works like `useState`, but when setting the value, you pass a generator function\n// that can yield multiple values. Each yielded value updates the state and waits for the next\n// layout effect, then continues the generator. This allows sequential updates to state to be\n// written linearly.\nexport function useValueEffect<S>(defaultValue: S | (() => S)): [S, Dispatch<SetValueAction<S>>] {\n let [value, setValue] = useState(defaultValue);\n // Keep an up to date copy of value in a ref so we can access the current value in the generator.\n // This allows us to maintain a stable queue function.\n let currValue = useRef(value);\n let effect: RefObject<Generator<S> | null> = useRef<Generator<S> | null>(null);\n\n // Store the function in a ref so we can always access the current version\n // which has the proper `value` in scope.\n let nextRef = useRef(() => {\n if (!effect.current) {\n return;\n }\n // Run the generator to the next yield.\n let newValue = effect.current.next();\n\n // If the generator is done, reset the effect.\n if (newValue.done) {\n effect.current = null;\n return;\n }\n\n // If the value is the same as the current value,\n // then continue to the next yield. Otherwise,\n // set the value in state and wait for the next layout effect.\n if (currValue.current === newValue.value) {\n nextRef.current();\n } else {\n setValue(newValue.value);\n }\n });\n\n useLayoutEffect(() => {\n currValue.current = value;\n // If there is an effect currently running, continue to the next yield.\n if (effect.current) {\n nextRef.current();\n }\n });\n\n let queue = useCallback(fn => {\n effect.current = fn(currValue.current);\n nextRef.current();\n }, [nextRef]);\n\n return [value, queue];\n}\n"],"names":[],"version":3,"file":"useValueEffect.main.js.map"}
@@ -1,58 +0,0 @@
1
- import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
2
- import {useState as $fCAlL$useState, useRef as $fCAlL$useRef, useCallback as $fCAlL$useCallback} from "react";
3
-
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
-
16
- function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
17
- let [value, setValue] = (0, $fCAlL$useState)(defaultValue);
18
- // Keep an up to date copy of value in a ref so we can access the current value in the generator.
19
- // This allows us to maintain a stable queue function.
20
- let currValue = (0, $fCAlL$useRef)(value);
21
- let effect = (0, $fCAlL$useRef)(null);
22
- // Store the function in a ref so we can always access the current version
23
- // which has the proper `value` in scope.
24
- let nextRef = (0, $fCAlL$useRef)(()=>{
25
- if (!effect.current) return;
26
- // Run the generator to the next yield.
27
- let newValue = effect.current.next();
28
- // If the generator is done, reset the effect.
29
- if (newValue.done) {
30
- effect.current = null;
31
- return;
32
- }
33
- // If the value is the same as the current value,
34
- // then continue to the next yield. Otherwise,
35
- // set the value in state and wait for the next layout effect.
36
- if (currValue.current === newValue.value) nextRef.current();
37
- else setValue(newValue.value);
38
- });
39
- (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
40
- currValue.current = value;
41
- // If there is an effect currently running, continue to the next yield.
42
- if (effect.current) nextRef.current();
43
- });
44
- let queue = (0, $fCAlL$useCallback)((fn)=>{
45
- effect.current = fn(currValue.current);
46
- nextRef.current();
47
- }, [
48
- nextRef
49
- ]);
50
- return [
51
- value,
52
- queue
53
- ];
54
- }
55
-
56
-
57
- export {$1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect};
58
- //# sourceMappingURL=useValueEffect.module.js.map
@@ -1,58 +0,0 @@
1
- import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
2
- import {useState as $fCAlL$useState, useRef as $fCAlL$useRef, useCallback as $fCAlL$useCallback} from "react";
3
-
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
-
16
- function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
17
- let [value, setValue] = (0, $fCAlL$useState)(defaultValue);
18
- // Keep an up to date copy of value in a ref so we can access the current value in the generator.
19
- // This allows us to maintain a stable queue function.
20
- let currValue = (0, $fCAlL$useRef)(value);
21
- let effect = (0, $fCAlL$useRef)(null);
22
- // Store the function in a ref so we can always access the current version
23
- // which has the proper `value` in scope.
24
- let nextRef = (0, $fCAlL$useRef)(()=>{
25
- if (!effect.current) return;
26
- // Run the generator to the next yield.
27
- let newValue = effect.current.next();
28
- // If the generator is done, reset the effect.
29
- if (newValue.done) {
30
- effect.current = null;
31
- return;
32
- }
33
- // If the value is the same as the current value,
34
- // then continue to the next yield. Otherwise,
35
- // set the value in state and wait for the next layout effect.
36
- if (currValue.current === newValue.value) nextRef.current();
37
- else setValue(newValue.value);
38
- });
39
- (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
40
- currValue.current = value;
41
- // If there is an effect currently running, continue to the next yield.
42
- if (effect.current) nextRef.current();
43
- });
44
- let queue = (0, $fCAlL$useCallback)((fn)=>{
45
- effect.current = fn(currValue.current);
46
- nextRef.current();
47
- }, [
48
- nextRef
49
- ]);
50
- return [
51
- value,
52
- queue
53
- ];
54
- }
55
-
56
-
57
- export {$1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect};
58
- //# sourceMappingURL=useValueEffect.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAWM,SAAS,0CAAkB,YAA2B;IAC3D,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,eAAO,EAAE;IACjC,iGAAiG;IACjG,sDAAsD;IACtD,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,SAAyC,CAAA,GAAA,aAAK,EAAuB;IAEzE,0EAA0E;IAC1E,yCAAyC;IACzC,IAAI,UAAU,CAAA,GAAA,aAAK,EAAE;QACnB,IAAI,CAAC,OAAO,OAAO,EACjB;QAEF,uCAAuC;QACvC,IAAI,WAAW,OAAO,OAAO,CAAC,IAAI;QAElC,8CAA8C;QAC9C,IAAI,SAAS,IAAI,EAAE;YACjB,OAAO,OAAO,GAAG;YACjB;QACF;QAEA,iDAAiD;QACjD,8CAA8C;QAC9C,8DAA8D;QAC9D,IAAI,UAAU,OAAO,KAAK,SAAS,KAAK,EACtC,QAAQ,OAAO;aAEf,SAAS,SAAS,KAAK;IAE3B;IAEA,CAAA,GAAA,yCAAc,EAAE;QACd,UAAU,OAAO,GAAG;QACpB,uEAAuE;QACvE,IAAI,OAAO,OAAO,EAChB,QAAQ,OAAO;IAEnB;IAEA,IAAI,QAAQ,CAAA,GAAA,kBAAU,EAAE,CAAA;QACtB,OAAO,OAAO,GAAG,GAAG,UAAU,OAAO;QACrC,QAAQ,OAAO;IACjB,GAAG;QAAC;KAAQ;IAEZ,OAAO;QAAC;QAAO;KAAM;AACvB","sources":["packages/@react-aria/utils/src/useValueEffect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Dispatch, RefObject, useCallback, useRef, useState} from 'react';\nimport {useLayoutEffect} from './';\n\ntype SetValueAction<S> = (prev: S) => Generator<any, void, unknown>;\n\n// This hook works like `useState`, but when setting the value, you pass a generator function\n// that can yield multiple values. Each yielded value updates the state and waits for the next\n// layout effect, then continues the generator. This allows sequential updates to state to be\n// written linearly.\nexport function useValueEffect<S>(defaultValue: S | (() => S)): [S, Dispatch<SetValueAction<S>>] {\n let [value, setValue] = useState(defaultValue);\n // Keep an up to date copy of value in a ref so we can access the current value in the generator.\n // This allows us to maintain a stable queue function.\n let currValue = useRef(value);\n let effect: RefObject<Generator<S> | null> = useRef<Generator<S> | null>(null);\n\n // Store the function in a ref so we can always access the current version\n // which has the proper `value` in scope.\n let nextRef = useRef(() => {\n if (!effect.current) {\n return;\n }\n // Run the generator to the next yield.\n let newValue = effect.current.next();\n\n // If the generator is done, reset the effect.\n if (newValue.done) {\n effect.current = null;\n return;\n }\n\n // If the value is the same as the current value,\n // then continue to the next yield. Otherwise,\n // set the value in state and wait for the next layout effect.\n if (currValue.current === newValue.value) {\n nextRef.current();\n } else {\n setValue(newValue.value);\n }\n });\n\n useLayoutEffect(() => {\n currValue.current = value;\n // If there is an effect currently running, continue to the next yield.\n if (effect.current) {\n nextRef.current();\n }\n });\n\n let queue = useCallback(fn => {\n effect.current = fn(currValue.current);\n nextRef.current();\n }, [nextRef]);\n\n return [value, queue];\n}\n"],"names":[],"version":3,"file":"useValueEffect.module.js.map"}
@@ -1,84 +0,0 @@
1
- var $d723bea02f3e2567$exports = require("./DOMFunctions.main.js");
2
- var $9e20cff0af27e8cc$exports = require("./platform.main.js");
3
- var $2308dc377e184bb0$exports = require("./keyboard.main.js");
4
- var $4gIVO$react = require("react");
5
- var $4gIVO$reactariassr = require("@react-aria/ssr");
6
-
7
-
8
- function $parcel$export(e, n, v, s) {
9
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
- }
11
-
12
- $parcel$export(module.exports, "useViewportSize", () => $8b24bab62f5c65ad$export$d699905dd57c73ca);
13
- /*
14
- * Copyright 2020 Adobe. All rights reserved.
15
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
- * you may not use this file except in compliance with the License. You may obtain a copy
17
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
- *
19
- * Unless required by applicable law or agreed to in writing, software distributed under
20
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
- * OF ANY KIND, either express or implied. See the License for the specific language
22
- * governing permissions and limitations under the License.
23
- */
24
-
25
-
26
-
27
-
28
- let $8b24bab62f5c65ad$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
29
- function $8b24bab62f5c65ad$export$d699905dd57c73ca() {
30
- let isSSR = (0, $4gIVO$reactariassr.useIsSSR)();
31
- let [size, setSize] = (0, $4gIVO$react.useState)(()=>isSSR ? {
32
- width: 0,
33
- height: 0
34
- } : $8b24bab62f5c65ad$var$getViewportSize());
35
- (0, $4gIVO$react.useEffect)(()=>{
36
- let updateSize = (newSize)=>{
37
- setSize((size)=>{
38
- if (newSize.width === size.width && newSize.height === size.height) return size;
39
- return newSize;
40
- });
41
- };
42
- // Use visualViewport api to track available height even on iOS virtual keyboard opening
43
- let onResize = ()=>{
44
- // Ignore updates when zoomed.
45
- if ($8b24bab62f5c65ad$var$visualViewport && $8b24bab62f5c65ad$var$visualViewport.scale > 1) return;
46
- updateSize($8b24bab62f5c65ad$var$getViewportSize());
47
- };
48
- // When closing the keyboard, iOS does not fire the visual viewport resize event until the animation is complete.
49
- // We can anticipate this and resize early by handling the blur event and using the layout size.
50
- let frame;
51
- let onBlur = (e)=>{
52
- if ($8b24bab62f5c65ad$var$visualViewport && $8b24bab62f5c65ad$var$visualViewport.scale > 1) return;
53
- if ((0, $2308dc377e184bb0$exports.willOpenKeyboard)((0, $d723bea02f3e2567$exports.getEventTarget)(e))) // Wait one frame to see if a new element gets focused.
54
- frame = requestAnimationFrame(()=>{
55
- let activeElement = (0, $d723bea02f3e2567$exports.getActiveElement)();
56
- if (!activeElement || !(0, $2308dc377e184bb0$exports.willOpenKeyboard)(activeElement)) updateSize({
57
- width: document.documentElement.clientWidth,
58
- height: document.documentElement.clientHeight
59
- });
60
- });
61
- };
62
- updateSize($8b24bab62f5c65ad$var$getViewportSize());
63
- if ((0, $9e20cff0af27e8cc$exports.isIOS)()) window.addEventListener('blur', onBlur, true);
64
- if (!$8b24bab62f5c65ad$var$visualViewport) window.addEventListener('resize', onResize);
65
- else $8b24bab62f5c65ad$var$visualViewport.addEventListener('resize', onResize);
66
- return ()=>{
67
- cancelAnimationFrame(frame);
68
- if ((0, $9e20cff0af27e8cc$exports.isIOS)()) window.removeEventListener('blur', onBlur, true);
69
- if (!$8b24bab62f5c65ad$var$visualViewport) window.removeEventListener('resize', onResize);
70
- else $8b24bab62f5c65ad$var$visualViewport.removeEventListener('resize', onResize);
71
- };
72
- }, []);
73
- return size;
74
- }
75
- function $8b24bab62f5c65ad$var$getViewportSize() {
76
- return {
77
- // Multiply by the visualViewport scale to get the "natural" size, unaffected by pinch zooming.
78
- width: $8b24bab62f5c65ad$var$visualViewport ? $8b24bab62f5c65ad$var$visualViewport.width * $8b24bab62f5c65ad$var$visualViewport.scale : document.documentElement.clientWidth,
79
- height: $8b24bab62f5c65ad$var$visualViewport ? $8b24bab62f5c65ad$var$visualViewport.height * $8b24bab62f5c65ad$var$visualViewport.scale : document.documentElement.clientHeight
80
- };
81
- }
82
-
83
-
84
- //# sourceMappingURL=useViewportSize.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAaD,IAAI,uCAAiB,OAAO,aAAa,eAAe,OAAO,cAAc;AAEtE,SAAS;IACd,IAAI,QAAQ,CAAA,GAAA,4BAAO;IACnB,IAAI,CAAC,MAAM,QAAQ,GAAG,CAAA,GAAA,qBAAO,EAAE,IAAM,QAAQ;YAAC,OAAO;YAAG,QAAQ;QAAC,IAAI;IAErE,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,aAAa,CAAC;YAChB,QAAQ,CAAA;gBACN,IAAI,QAAQ,KAAK,KAAK,KAAK,KAAK,IAAI,QAAQ,MAAM,KAAK,KAAK,MAAM,EAChE,OAAO;gBAET,OAAO;YACT;QACF;QAEA,wFAAwF;QACxF,IAAI,WAAW;YACb,8BAA8B;YAC9B,IAAI,wCAAkB,qCAAe,KAAK,GAAG,GAC3C;YAGF,WAAW;QACb;QAEA,iHAAiH;QACjH,gGAAgG;QAChG,IAAI;QACJ,IAAI,SAAS,CAAC;YACZ,IAAI,wCAAkB,qCAAe,KAAK,GAAG,GAC3C;YAGF,IAAI,CAAA,GAAA,0CAAe,EAAE,CAAA,GAAA,wCAAa,EAAE,KAClC,uDAAuD;YACvD,QAAQ,sBAAsB;gBAC5B,IAAI,gBAAgB,CAAA,GAAA,0CAAe;gBACnC,IAAI,CAAC,iBAAiB,CAAC,CAAA,GAAA,0CAAe,EAAE,gBACtC,WAAW;oBAAC,OAAO,SAAS,eAAe,CAAC,WAAW;oBAAE,QAAQ,SAAS,eAAe,CAAC,YAAY;gBAAA;YAE1G;QAEJ;QAEA,WAAW;QAEX,IAAI,CAAA,GAAA,+BAAI,KACN,OAAO,gBAAgB,CAAC,QAAQ,QAAQ;QAG1C,IAAI,CAAC,sCACH,OAAO,gBAAgB,CAAC,UAAU;aAElC,qCAAe,gBAAgB,CAAC,UAAU;QAG5C,OAAO;YACL,qBAAqB;YACrB,IAAI,CAAA,GAAA,+BAAI,KACN,OAAO,mBAAmB,CAAC,QAAQ,QAAQ;YAE7C,IAAI,CAAC,sCACH,OAAO,mBAAmB,CAAC,UAAU;iBAErC,qCAAe,mBAAmB,CAAC,UAAU;QAEjD;IACF,GAAG,EAAE;IAEL,OAAO;AACT;AAEA,SAAS;IACP,OAAO;QACL,+FAA+F;QAC/F,OAAO,uCAAiB,qCAAe,KAAK,GAAG,qCAAe,KAAK,GAAG,SAAS,eAAe,CAAC,WAAW;QAC1G,QAAQ,uCAAiB,qCAAe,MAAM,GAAG,qCAAe,KAAK,GAAG,SAAS,eAAe,CAAC,YAAY;IAC/G;AACF","sources":["packages/@react-aria/utils/src/useViewportSize.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getActiveElement, getEventTarget} from './shadowdom/DOMFunctions';\nimport {isIOS} from './platform';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\nimport {willOpenKeyboard} from './keyboard';\n\ninterface ViewportSize {\n width: number,\n height: number\n}\n\nlet visualViewport = typeof document !== 'undefined' && window.visualViewport;\n\nexport function useViewportSize(): ViewportSize {\n let isSSR = useIsSSR();\n let [size, setSize] = useState(() => isSSR ? {width: 0, height: 0} : getViewportSize());\n\n useEffect(() => {\n let updateSize = (newSize: ViewportSize) => {\n setSize(size => {\n if (newSize.width === size.width && newSize.height === size.height) {\n return size;\n }\n return newSize;\n });\n };\n\n // Use visualViewport api to track available height even on iOS virtual keyboard opening\n let onResize = () => {\n // Ignore updates when zoomed.\n if (visualViewport && visualViewport.scale > 1) {\n return;\n }\n\n updateSize(getViewportSize());\n };\n\n // When closing the keyboard, iOS does not fire the visual viewport resize event until the animation is complete.\n // We can anticipate this and resize early by handling the blur event and using the layout size.\n let frame: number;\n let onBlur = (e: FocusEvent) => {\n if (visualViewport && visualViewport.scale > 1) {\n return;\n }\n\n if (willOpenKeyboard(getEventTarget(e) as Element)) {\n // Wait one frame to see if a new element gets focused.\n frame = requestAnimationFrame(() => {\n let activeElement = getActiveElement();\n if (!activeElement || !willOpenKeyboard(activeElement)) {\n updateSize({width: document.documentElement.clientWidth, height: document.documentElement.clientHeight});\n }\n });\n }\n };\n\n updateSize(getViewportSize());\n\n if (isIOS()) {\n window.addEventListener('blur', onBlur, true);\n }\n\n if (!visualViewport) {\n window.addEventListener('resize', onResize);\n } else {\n visualViewport.addEventListener('resize', onResize);\n }\n\n return () => {\n cancelAnimationFrame(frame);\n if (isIOS()) {\n window.removeEventListener('blur', onBlur, true);\n }\n if (!visualViewport) {\n window.removeEventListener('resize', onResize);\n } else {\n visualViewport.removeEventListener('resize', onResize);\n }\n };\n }, []);\n\n return size;\n}\n\nfunction getViewportSize(): ViewportSize {\n return {\n // Multiply by the visualViewport scale to get the \"natural\" size, unaffected by pinch zooming.\n width: visualViewport ? visualViewport.width * visualViewport.scale : document.documentElement.clientWidth,\n height: visualViewport ? visualViewport.height * visualViewport.scale : document.documentElement.clientHeight\n };\n}\n"],"names":[],"version":3,"file":"useViewportSize.main.js.map"}
@@ -1,79 +0,0 @@
1
- import {getActiveElement as $d4ee10de306f2510$export$cd4e5573fbe2b576, getEventTarget as $d4ee10de306f2510$export$e58f029f0fbfdb29} from "./DOMFunctions.mjs";
2
- import {isIOS as $c87311424ea30a05$export$fedb369cb70207f1} from "./platform.mjs";
3
- import {willOpenKeyboard as $21f1aa98acb08317$export$c57958e35f31ed73} from "./keyboard.mjs";
4
- import {useState as $fuDHA$useState, useEffect as $fuDHA$useEffect} from "react";
5
- import {useIsSSR as $fuDHA$useIsSSR} from "@react-aria/ssr";
6
-
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */
18
-
19
-
20
-
21
-
22
- let $5df64b3807dc15ee$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
23
- function $5df64b3807dc15ee$export$d699905dd57c73ca() {
24
- let isSSR = (0, $fuDHA$useIsSSR)();
25
- let [size, setSize] = (0, $fuDHA$useState)(()=>isSSR ? {
26
- width: 0,
27
- height: 0
28
- } : $5df64b3807dc15ee$var$getViewportSize());
29
- (0, $fuDHA$useEffect)(()=>{
30
- let updateSize = (newSize)=>{
31
- setSize((size)=>{
32
- if (newSize.width === size.width && newSize.height === size.height) return size;
33
- return newSize;
34
- });
35
- };
36
- // Use visualViewport api to track available height even on iOS virtual keyboard opening
37
- let onResize = ()=>{
38
- // Ignore updates when zoomed.
39
- if ($5df64b3807dc15ee$var$visualViewport && $5df64b3807dc15ee$var$visualViewport.scale > 1) return;
40
- updateSize($5df64b3807dc15ee$var$getViewportSize());
41
- };
42
- // When closing the keyboard, iOS does not fire the visual viewport resize event until the animation is complete.
43
- // We can anticipate this and resize early by handling the blur event and using the layout size.
44
- let frame;
45
- let onBlur = (e)=>{
46
- if ($5df64b3807dc15ee$var$visualViewport && $5df64b3807dc15ee$var$visualViewport.scale > 1) return;
47
- if ((0, $21f1aa98acb08317$export$c57958e35f31ed73)((0, $d4ee10de306f2510$export$e58f029f0fbfdb29)(e))) // Wait one frame to see if a new element gets focused.
48
- frame = requestAnimationFrame(()=>{
49
- let activeElement = (0, $d4ee10de306f2510$export$cd4e5573fbe2b576)();
50
- if (!activeElement || !(0, $21f1aa98acb08317$export$c57958e35f31ed73)(activeElement)) updateSize({
51
- width: document.documentElement.clientWidth,
52
- height: document.documentElement.clientHeight
53
- });
54
- });
55
- };
56
- updateSize($5df64b3807dc15ee$var$getViewportSize());
57
- if ((0, $c87311424ea30a05$export$fedb369cb70207f1)()) window.addEventListener('blur', onBlur, true);
58
- if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener('resize', onResize);
59
- else $5df64b3807dc15ee$var$visualViewport.addEventListener('resize', onResize);
60
- return ()=>{
61
- cancelAnimationFrame(frame);
62
- if ((0, $c87311424ea30a05$export$fedb369cb70207f1)()) window.removeEventListener('blur', onBlur, true);
63
- if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener('resize', onResize);
64
- else $5df64b3807dc15ee$var$visualViewport.removeEventListener('resize', onResize);
65
- };
66
- }, []);
67
- return size;
68
- }
69
- function $5df64b3807dc15ee$var$getViewportSize() {
70
- return {
71
- // Multiply by the visualViewport scale to get the "natural" size, unaffected by pinch zooming.
72
- width: $5df64b3807dc15ee$var$visualViewport ? $5df64b3807dc15ee$var$visualViewport.width * $5df64b3807dc15ee$var$visualViewport.scale : document.documentElement.clientWidth,
73
- height: $5df64b3807dc15ee$var$visualViewport ? $5df64b3807dc15ee$var$visualViewport.height * $5df64b3807dc15ee$var$visualViewport.scale : document.documentElement.clientHeight
74
- };
75
- }
76
-
77
-
78
- export {$5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize};
79
- //# sourceMappingURL=useViewportSize.module.js.map
@@ -1,79 +0,0 @@
1
- import {getActiveElement as $d4ee10de306f2510$export$cd4e5573fbe2b576, getEventTarget as $d4ee10de306f2510$export$e58f029f0fbfdb29} from "./DOMFunctions.module.js";
2
- import {isIOS as $c87311424ea30a05$export$fedb369cb70207f1} from "./platform.module.js";
3
- import {willOpenKeyboard as $21f1aa98acb08317$export$c57958e35f31ed73} from "./keyboard.module.js";
4
- import {useState as $fuDHA$useState, useEffect as $fuDHA$useEffect} from "react";
5
- import {useIsSSR as $fuDHA$useIsSSR} from "@react-aria/ssr";
6
-
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */
18
-
19
-
20
-
21
-
22
- let $5df64b3807dc15ee$var$visualViewport = typeof document !== 'undefined' && window.visualViewport;
23
- function $5df64b3807dc15ee$export$d699905dd57c73ca() {
24
- let isSSR = (0, $fuDHA$useIsSSR)();
25
- let [size, setSize] = (0, $fuDHA$useState)(()=>isSSR ? {
26
- width: 0,
27
- height: 0
28
- } : $5df64b3807dc15ee$var$getViewportSize());
29
- (0, $fuDHA$useEffect)(()=>{
30
- let updateSize = (newSize)=>{
31
- setSize((size)=>{
32
- if (newSize.width === size.width && newSize.height === size.height) return size;
33
- return newSize;
34
- });
35
- };
36
- // Use visualViewport api to track available height even on iOS virtual keyboard opening
37
- let onResize = ()=>{
38
- // Ignore updates when zoomed.
39
- if ($5df64b3807dc15ee$var$visualViewport && $5df64b3807dc15ee$var$visualViewport.scale > 1) return;
40
- updateSize($5df64b3807dc15ee$var$getViewportSize());
41
- };
42
- // When closing the keyboard, iOS does not fire the visual viewport resize event until the animation is complete.
43
- // We can anticipate this and resize early by handling the blur event and using the layout size.
44
- let frame;
45
- let onBlur = (e)=>{
46
- if ($5df64b3807dc15ee$var$visualViewport && $5df64b3807dc15ee$var$visualViewport.scale > 1) return;
47
- if ((0, $21f1aa98acb08317$export$c57958e35f31ed73)((0, $d4ee10de306f2510$export$e58f029f0fbfdb29)(e))) // Wait one frame to see if a new element gets focused.
48
- frame = requestAnimationFrame(()=>{
49
- let activeElement = (0, $d4ee10de306f2510$export$cd4e5573fbe2b576)();
50
- if (!activeElement || !(0, $21f1aa98acb08317$export$c57958e35f31ed73)(activeElement)) updateSize({
51
- width: document.documentElement.clientWidth,
52
- height: document.documentElement.clientHeight
53
- });
54
- });
55
- };
56
- updateSize($5df64b3807dc15ee$var$getViewportSize());
57
- if ((0, $c87311424ea30a05$export$fedb369cb70207f1)()) window.addEventListener('blur', onBlur, true);
58
- if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener('resize', onResize);
59
- else $5df64b3807dc15ee$var$visualViewport.addEventListener('resize', onResize);
60
- return ()=>{
61
- cancelAnimationFrame(frame);
62
- if ((0, $c87311424ea30a05$export$fedb369cb70207f1)()) window.removeEventListener('blur', onBlur, true);
63
- if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener('resize', onResize);
64
- else $5df64b3807dc15ee$var$visualViewport.removeEventListener('resize', onResize);
65
- };
66
- }, []);
67
- return size;
68
- }
69
- function $5df64b3807dc15ee$var$getViewportSize() {
70
- return {
71
- // Multiply by the visualViewport scale to get the "natural" size, unaffected by pinch zooming.
72
- width: $5df64b3807dc15ee$var$visualViewport ? $5df64b3807dc15ee$var$visualViewport.width * $5df64b3807dc15ee$var$visualViewport.scale : document.documentElement.clientWidth,
73
- height: $5df64b3807dc15ee$var$visualViewport ? $5df64b3807dc15ee$var$visualViewport.height * $5df64b3807dc15ee$var$visualViewport.scale : document.documentElement.clientHeight
74
- };
75
- }
76
-
77
-
78
- export {$5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize};
79
- //# sourceMappingURL=useViewportSize.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAaD,IAAI,uCAAiB,OAAO,aAAa,eAAe,OAAO,cAAc;AAEtE,SAAS;IACd,IAAI,QAAQ,CAAA,GAAA,eAAO;IACnB,IAAI,CAAC,MAAM,QAAQ,GAAG,CAAA,GAAA,eAAO,EAAE,IAAM,QAAQ;YAAC,OAAO;YAAG,QAAQ;QAAC,IAAI;IAErE,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,aAAa,CAAC;YAChB,QAAQ,CAAA;gBACN,IAAI,QAAQ,KAAK,KAAK,KAAK,KAAK,IAAI,QAAQ,MAAM,KAAK,KAAK,MAAM,EAChE,OAAO;gBAET,OAAO;YACT;QACF;QAEA,wFAAwF;QACxF,IAAI,WAAW;YACb,8BAA8B;YAC9B,IAAI,wCAAkB,qCAAe,KAAK,GAAG,GAC3C;YAGF,WAAW;QACb;QAEA,iHAAiH;QACjH,gGAAgG;QAChG,IAAI;QACJ,IAAI,SAAS,CAAC;YACZ,IAAI,wCAAkB,qCAAe,KAAK,GAAG,GAC3C;YAGF,IAAI,CAAA,GAAA,yCAAe,EAAE,CAAA,GAAA,yCAAa,EAAE,KAClC,uDAAuD;YACvD,QAAQ,sBAAsB;gBAC5B,IAAI,gBAAgB,CAAA,GAAA,yCAAe;gBACnC,IAAI,CAAC,iBAAiB,CAAC,CAAA,GAAA,yCAAe,EAAE,gBACtC,WAAW;oBAAC,OAAO,SAAS,eAAe,CAAC,WAAW;oBAAE,QAAQ,SAAS,eAAe,CAAC,YAAY;gBAAA;YAE1G;QAEJ;QAEA,WAAW;QAEX,IAAI,CAAA,GAAA,yCAAI,KACN,OAAO,gBAAgB,CAAC,QAAQ,QAAQ;QAG1C,IAAI,CAAC,sCACH,OAAO,gBAAgB,CAAC,UAAU;aAElC,qCAAe,gBAAgB,CAAC,UAAU;QAG5C,OAAO;YACL,qBAAqB;YACrB,IAAI,CAAA,GAAA,yCAAI,KACN,OAAO,mBAAmB,CAAC,QAAQ,QAAQ;YAE7C,IAAI,CAAC,sCACH,OAAO,mBAAmB,CAAC,UAAU;iBAErC,qCAAe,mBAAmB,CAAC,UAAU;QAEjD;IACF,GAAG,EAAE;IAEL,OAAO;AACT;AAEA,SAAS;IACP,OAAO;QACL,+FAA+F;QAC/F,OAAO,uCAAiB,qCAAe,KAAK,GAAG,qCAAe,KAAK,GAAG,SAAS,eAAe,CAAC,WAAW;QAC1G,QAAQ,uCAAiB,qCAAe,MAAM,GAAG,qCAAe,KAAK,GAAG,SAAS,eAAe,CAAC,YAAY;IAC/G;AACF","sources":["packages/@react-aria/utils/src/useViewportSize.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getActiveElement, getEventTarget} from './shadowdom/DOMFunctions';\nimport {isIOS} from './platform';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\nimport {willOpenKeyboard} from './keyboard';\n\ninterface ViewportSize {\n width: number,\n height: number\n}\n\nlet visualViewport = typeof document !== 'undefined' && window.visualViewport;\n\nexport function useViewportSize(): ViewportSize {\n let isSSR = useIsSSR();\n let [size, setSize] = useState(() => isSSR ? {width: 0, height: 0} : getViewportSize());\n\n useEffect(() => {\n let updateSize = (newSize: ViewportSize) => {\n setSize(size => {\n if (newSize.width === size.width && newSize.height === size.height) {\n return size;\n }\n return newSize;\n });\n };\n\n // Use visualViewport api to track available height even on iOS virtual keyboard opening\n let onResize = () => {\n // Ignore updates when zoomed.\n if (visualViewport && visualViewport.scale > 1) {\n return;\n }\n\n updateSize(getViewportSize());\n };\n\n // When closing the keyboard, iOS does not fire the visual viewport resize event until the animation is complete.\n // We can anticipate this and resize early by handling the blur event and using the layout size.\n let frame: number;\n let onBlur = (e: FocusEvent) => {\n if (visualViewport && visualViewport.scale > 1) {\n return;\n }\n\n if (willOpenKeyboard(getEventTarget(e) as Element)) {\n // Wait one frame to see if a new element gets focused.\n frame = requestAnimationFrame(() => {\n let activeElement = getActiveElement();\n if (!activeElement || !willOpenKeyboard(activeElement)) {\n updateSize({width: document.documentElement.clientWidth, height: document.documentElement.clientHeight});\n }\n });\n }\n };\n\n updateSize(getViewportSize());\n\n if (isIOS()) {\n window.addEventListener('blur', onBlur, true);\n }\n\n if (!visualViewport) {\n window.addEventListener('resize', onResize);\n } else {\n visualViewport.addEventListener('resize', onResize);\n }\n\n return () => {\n cancelAnimationFrame(frame);\n if (isIOS()) {\n window.removeEventListener('blur', onBlur, true);\n }\n if (!visualViewport) {\n window.removeEventListener('resize', onResize);\n } else {\n visualViewport.removeEventListener('resize', onResize);\n }\n };\n }, []);\n\n return size;\n}\n\nfunction getViewportSize(): ViewportSize {\n return {\n // Multiply by the visualViewport scale to get the \"natural\" size, unaffected by pinch zooming.\n width: visualViewport ? visualViewport.width * visualViewport.scale : document.documentElement.clientWidth,\n height: visualViewport ? visualViewport.height * visualViewport.scale : document.documentElement.clientHeight\n };\n}\n"],"names":[],"version":3,"file":"useViewportSize.module.js.map"}
package/src/animation.ts DELETED
@@ -1,103 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {flushSync} from 'react-dom';
14
- import {RefObject, useCallback, useState} from 'react';
15
- import {useLayoutEffect} from './useLayoutEffect';
16
-
17
- export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true): boolean {
18
- let [isEntering, setEntering] = useState(true);
19
- let isAnimationReady = isEntering && isReady;
20
-
21
- // There are two cases for entry animations:
22
- // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.
23
- // 2. CSS transitions. The initial styles are applied during the isEntering state, and removed immediately, causing the transition to occur.
24
- //
25
- // In the second case, cancel any transitions that were triggered prior to the isEntering = false state (when the transition is supposed to start).
26
- // This can happen when isReady starts as false (e.g. popovers prior to placement calculation).
27
- useLayoutEffect(() => {
28
- if (isAnimationReady && ref.current && 'getAnimations' in ref.current) {
29
- for (let animation of ref.current.getAnimations()) {
30
- if (animation instanceof CSSTransition) {
31
- animation.cancel();
32
- }
33
- }
34
- }
35
- }, [ref, isAnimationReady]);
36
-
37
- useAnimation(ref, isAnimationReady, useCallback(() => setEntering(false), []));
38
- return isAnimationReady;
39
- }
40
-
41
- export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean): boolean {
42
- let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');
43
-
44
- switch (exitState) {
45
- case 'open':
46
- // If isOpen becomes false, set the state to exiting.
47
- if (!isOpen) {
48
- setExitState('exiting');
49
- }
50
- break;
51
- case 'closed':
52
- case 'exiting':
53
- // If we are exiting and isOpen becomes true, the animation was interrupted.
54
- // Reset the state to open.
55
- if (isOpen) {
56
- setExitState('open');
57
- }
58
- break;
59
- }
60
-
61
- let isExiting = exitState === 'exiting';
62
- useAnimation(
63
- ref,
64
- isExiting,
65
- useCallback(() => {
66
- // Set the state to closed, which will cause the element to be unmounted.
67
- setExitState(state => state === 'exiting' ? 'closed' : state);
68
- }, [])
69
- );
70
-
71
- return isExiting;
72
- }
73
-
74
- function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void): void {
75
- useLayoutEffect(() => {
76
- if (isActive && ref.current) {
77
- if (!('getAnimations' in ref.current)) {
78
- // JSDOM
79
- onEnd();
80
- return;
81
- }
82
-
83
- let animations = ref.current.getAnimations();
84
- if (animations.length === 0) {
85
- onEnd();
86
- return;
87
- }
88
-
89
- let canceled = false;
90
- Promise.all(animations.map(a => a.finished)).then(() => {
91
- if (!canceled) {
92
- flushSync(() => {
93
- onEnd();
94
- });
95
- }
96
- }).catch(() => {});
97
-
98
- return () => {
99
- canceled = true;
100
- };
101
- }
102
- }, [ref, isActive, onEnd]);
103
- }
package/src/chain.ts DELETED
@@ -1,24 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- /**
14
- * Calls all functions in the order they were chained with the same arguments.
15
- */
16
- export function chain(...callbacks: any[]): (...args: any[]) => void {
17
- return (...args: any[]) => {
18
- for (let callback of callbacks) {
19
- if (typeof callback === 'function') {
20
- callback(...args);
21
- }
22
- }
23
- };
24
- }
package/src/constants.ts DELETED
@@ -1,15 +0,0 @@
1
- /*
2
- * Copyright 2024 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- // Custom event names for updating the autocomplete's aria-activedecendant.
14
- export const CLEAR_FOCUS_EVENT = 'react-aria-clear-focus';
15
- export const FOCUS_EVENT = 'react-aria-focus';
package/src/domHelpers.ts DELETED
@@ -1,33 +0,0 @@
1
- export const getOwnerDocument = (el: Element | null | undefined): Document => {
2
- return el?.ownerDocument ?? document;
3
- };
4
-
5
- export const getOwnerWindow = (
6
- el: (Window & typeof globalThis) | Element | null | undefined
7
- ): Window & typeof globalThis => {
8
- if (el && 'window' in el && el.window === el) {
9
- return el;
10
- }
11
-
12
- const doc = getOwnerDocument(el as Element | null | undefined);
13
- return doc.defaultView || window;
14
- };
15
-
16
- /**
17
- * Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType property.
18
- */
19
- function isNode(value: unknown): value is Node {
20
- return value !== null &&
21
- typeof value === 'object' &&
22
- 'nodeType' in value &&
23
- typeof (value as Node).nodeType === 'number';
24
- }
25
- /**
26
- * Type guard that checks if a node is a ShadowRoot. Uses nodeType and host property checks to
27
- * distinguish ShadowRoot from other DocumentFragments.
28
- */
29
- export function isShadowRoot(node: Node | null): node is ShadowRoot {
30
- return isNode(node) &&
31
- node.nodeType === Node.DOCUMENT_FRAGMENT_NODE &&
32
- 'host' in node;
33
- }