@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,30 +0,0 @@
1
- var $4FGhO$react = require("react");
2
-
3
-
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$export(module.exports, "useDeepMemo", () => $20e6e72fbf5dc81e$export$722debc0e56fea39);
9
- /*
10
- * Copyright 2023 Adobe. All rights reserved.
11
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License. You may obtain a copy
13
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software distributed under
16
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
- * OF ANY KIND, either express or implied. See the License for the specific language
18
- * governing permissions and limitations under the License.
19
- */ /* eslint-disable rulesdir/pure-render */
20
- function $20e6e72fbf5dc81e$export$722debc0e56fea39(value, isEqual) {
21
- // Using a ref during render is ok here because it's only an optimization – both values are equivalent.
22
- // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
23
- let lastValue = (0, $4FGhO$react.useRef)(null);
24
- if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
25
- lastValue.current = value;
26
- return value;
27
- }
28
-
29
-
30
- //# sourceMappingURL=useDeepMemo.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,uCAAuC;AAIhC,SAAS,0CAAe,KAAQ,EAAE,OAAgC;IACvE,uGAAuG;IACvG,yGAAyG;IACzG,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAY;IACjC,IAAI,SAAS,UAAU,OAAO,IAAI,QAAQ,OAAO,UAAU,OAAO,GAChE,QAAQ,UAAU,OAAO;IAG3B,UAAU,OAAO,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/utils/src/useDeepMemo.ts"],"sourcesContent":["/*\n * Copyright 2023 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\n/* eslint-disable rulesdir/pure-render */\n\nimport {useRef} from 'react';\n\nexport function useDeepMemo<T>(value: T, isEqual: (a: T, b: T) => boolean): T {\n // Using a ref during render is ok here because it's only an optimization – both values are equivalent.\n // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.\n let lastValue = useRef<T | null>(null);\n if (value && lastValue.current && isEqual(value, lastValue.current)) {\n value = lastValue.current;\n }\n\n lastValue.current = value;\n return value;\n}\n"],"names":[],"version":3,"file":"useDeepMemo.main.js.map"}
@@ -1,25 +0,0 @@
1
- import {useRef as $jtQ6z$useRef} from "react";
2
-
3
- /*
4
- * Copyright 2023 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */ /* eslint-disable rulesdir/pure-render */
14
- function $5a387cc49350e6db$export$722debc0e56fea39(value, isEqual) {
15
- // Using a ref during render is ok here because it's only an optimization – both values are equivalent.
16
- // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
17
- let lastValue = (0, $jtQ6z$useRef)(null);
18
- if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
19
- lastValue.current = value;
20
- return value;
21
- }
22
-
23
-
24
- export {$5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo};
25
- //# sourceMappingURL=useDeepMemo.module.js.map
@@ -1,25 +0,0 @@
1
- import {useRef as $jtQ6z$useRef} from "react";
2
-
3
- /*
4
- * Copyright 2023 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */ /* eslint-disable rulesdir/pure-render */
14
- function $5a387cc49350e6db$export$722debc0e56fea39(value, isEqual) {
15
- // Using a ref during render is ok here because it's only an optimization – both values are equivalent.
16
- // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.
17
- let lastValue = (0, $jtQ6z$useRef)(null);
18
- if (value && lastValue.current && isEqual(value, lastValue.current)) value = lastValue.current;
19
- lastValue.current = value;
20
- return value;
21
- }
22
-
23
-
24
- export {$5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo};
25
- //# sourceMappingURL=useDeepMemo.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,uCAAuC;AAIhC,SAAS,0CAAe,KAAQ,EAAE,OAAgC;IACvE,uGAAuG;IACvG,yGAAyG;IACzG,IAAI,YAAY,CAAA,GAAA,aAAK,EAAY;IACjC,IAAI,SAAS,UAAU,OAAO,IAAI,QAAQ,OAAO,UAAU,OAAO,GAChE,QAAQ,UAAU,OAAO;IAG3B,UAAU,OAAO,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/utils/src/useDeepMemo.ts"],"sourcesContent":["/*\n * Copyright 2023 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\n/* eslint-disable rulesdir/pure-render */\n\nimport {useRef} from 'react';\n\nexport function useDeepMemo<T>(value: T, isEqual: (a: T, b: T) => boolean): T {\n // Using a ref during render is ok here because it's only an optimization – both values are equivalent.\n // If a render is thrown away, it'll still work the same no matter if the next render is the same or not.\n let lastValue = useRef<T | null>(null);\n if (value && lastValue.current && isEqual(value, lastValue.current)) {\n value = lastValue.current;\n }\n\n lastValue.current = value;\n return value;\n}\n"],"names":[],"version":3,"file":"useDeepMemo.module.js.map"}
@@ -1,59 +0,0 @@
1
- var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
2
- var $7PjpK$react = require("react");
3
-
4
-
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
-
9
- $parcel$export(module.exports, "useDescription", () => $34da4502ea8120db$export$f8aeda7b10753fa1);
10
- /*
11
- * Copyright 2020 Adobe. All rights reserved.
12
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License. You may obtain a copy
14
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software distributed under
17
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
- * OF ANY KIND, either express or implied. See the License for the specific language
19
- * governing permissions and limitations under the License.
20
- */
21
-
22
- let $34da4502ea8120db$var$descriptionId = 0;
23
- const $34da4502ea8120db$var$descriptionNodes = new Map();
24
- function $34da4502ea8120db$export$f8aeda7b10753fa1(description) {
25
- let [id, setId] = (0, $7PjpK$react.useState)();
26
- (0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
27
- if (!description) return;
28
- let desc = $34da4502ea8120db$var$descriptionNodes.get(description);
29
- if (!desc) {
30
- let id = `react-aria-description-${$34da4502ea8120db$var$descriptionId++}`;
31
- setId(id);
32
- let node = document.createElement('div');
33
- node.id = id;
34
- node.style.display = 'none';
35
- node.textContent = description;
36
- document.body.appendChild(node);
37
- desc = {
38
- refCount: 0,
39
- element: node
40
- };
41
- $34da4502ea8120db$var$descriptionNodes.set(description, desc);
42
- } else setId(desc.element.id);
43
- desc.refCount++;
44
- return ()=>{
45
- if (desc && --desc.refCount === 0) {
46
- desc.element.remove();
47
- $34da4502ea8120db$var$descriptionNodes.delete(description);
48
- }
49
- };
50
- }, [
51
- description
52
- ]);
53
- return {
54
- 'aria-describedby': description ? id : undefined
55
- };
56
- }
57
-
58
-
59
- //# sourceMappingURL=useDescription.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMD,IAAI,sCAAgB;AACpB,MAAM,yCAAmB,IAAI;AAEtB,SAAS,0CAAe,WAAoB;IACjD,IAAI,CAAC,IAAI,MAAM,GAAG,CAAA,GAAA,qBAAO;IAEzB,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,CAAC,aACH;QAGF,IAAI,OAAO,uCAAiB,GAAG,CAAC;QAChC,IAAI,CAAC,MAAM;YACT,IAAI,KAAK,CAAC,uBAAuB,EAAE,uCAAiB;YACpD,MAAM;YAEN,IAAI,OAAO,SAAS,aAAa,CAAC;YAClC,KAAK,EAAE,GAAG;YACV,KAAK,KAAK,CAAC,OAAO,GAAG;YACrB,KAAK,WAAW,GAAG;YACnB,SAAS,IAAI,CAAC,WAAW,CAAC;YAC1B,OAAO;gBAAC,UAAU;gBAAG,SAAS;YAAI;YAClC,uCAAiB,GAAG,CAAC,aAAa;QACpC,OACE,MAAM,KAAK,OAAO,CAAC,EAAE;QAGvB,KAAK,QAAQ;QACb,OAAO;YACL,IAAI,QAAQ,EAAE,KAAK,QAAQ,KAAK,GAAG;gBACjC,KAAK,OAAO,CAAC,MAAM;gBACnB,uCAAiB,MAAM,CAAC;YAC1B;QACF;IACF,GAAG;QAAC;KAAY;IAEhB,OAAO;QACL,oBAAoB,cAAc,KAAK;IACzC;AACF","sources":["packages/@react-aria/utils/src/useDescription.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 {AriaLabelingProps} from '@react-types/shared';\nimport {useLayoutEffect} from './useLayoutEffect';\nimport {useState} from 'react';\n\nlet descriptionId = 0;\nconst descriptionNodes = new Map<string, {refCount: number, element: Element}>();\n\nexport function useDescription(description?: string): AriaLabelingProps {\n let [id, setId] = useState<string | undefined>();\n\n useLayoutEffect(() => {\n if (!description) {\n return;\n }\n\n let desc = descriptionNodes.get(description);\n if (!desc) {\n let id = `react-aria-description-${descriptionId++}`;\n setId(id);\n\n let node = document.createElement('div');\n node.id = id;\n node.style.display = 'none';\n node.textContent = description;\n document.body.appendChild(node);\n desc = {refCount: 0, element: node};\n descriptionNodes.set(description, desc);\n } else {\n setId(desc.element.id);\n }\n\n desc.refCount++;\n return () => {\n if (desc && --desc.refCount === 0) {\n desc.element.remove();\n descriptionNodes.delete(description);\n }\n };\n }, [description]);\n\n return {\n 'aria-describedby': description ? id : undefined\n };\n}\n"],"names":[],"version":3,"file":"useDescription.main.js.map"}
@@ -1,54 +0,0 @@
1
- import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
2
- import {useState as $hQ5Hp$useState} 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
- let $ef06256079686ba0$var$descriptionId = 0;
17
- const $ef06256079686ba0$var$descriptionNodes = new Map();
18
- function $ef06256079686ba0$export$f8aeda7b10753fa1(description) {
19
- let [id, setId] = (0, $hQ5Hp$useState)();
20
- (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
21
- if (!description) return;
22
- let desc = $ef06256079686ba0$var$descriptionNodes.get(description);
23
- if (!desc) {
24
- let id = `react-aria-description-${$ef06256079686ba0$var$descriptionId++}`;
25
- setId(id);
26
- let node = document.createElement('div');
27
- node.id = id;
28
- node.style.display = 'none';
29
- node.textContent = description;
30
- document.body.appendChild(node);
31
- desc = {
32
- refCount: 0,
33
- element: node
34
- };
35
- $ef06256079686ba0$var$descriptionNodes.set(description, desc);
36
- } else setId(desc.element.id);
37
- desc.refCount++;
38
- return ()=>{
39
- if (desc && --desc.refCount === 0) {
40
- desc.element.remove();
41
- $ef06256079686ba0$var$descriptionNodes.delete(description);
42
- }
43
- };
44
- }, [
45
- description
46
- ]);
47
- return {
48
- 'aria-describedby': description ? id : undefined
49
- };
50
- }
51
-
52
-
53
- export {$ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription};
54
- //# sourceMappingURL=useDescription.module.js.map
@@ -1,54 +0,0 @@
1
- import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
2
- import {useState as $hQ5Hp$useState} 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
- let $ef06256079686ba0$var$descriptionId = 0;
17
- const $ef06256079686ba0$var$descriptionNodes = new Map();
18
- function $ef06256079686ba0$export$f8aeda7b10753fa1(description) {
19
- let [id, setId] = (0, $hQ5Hp$useState)();
20
- (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
21
- if (!description) return;
22
- let desc = $ef06256079686ba0$var$descriptionNodes.get(description);
23
- if (!desc) {
24
- let id = `react-aria-description-${$ef06256079686ba0$var$descriptionId++}`;
25
- setId(id);
26
- let node = document.createElement('div');
27
- node.id = id;
28
- node.style.display = 'none';
29
- node.textContent = description;
30
- document.body.appendChild(node);
31
- desc = {
32
- refCount: 0,
33
- element: node
34
- };
35
- $ef06256079686ba0$var$descriptionNodes.set(description, desc);
36
- } else setId(desc.element.id);
37
- desc.refCount++;
38
- return ()=>{
39
- if (desc && --desc.refCount === 0) {
40
- desc.element.remove();
41
- $ef06256079686ba0$var$descriptionNodes.delete(description);
42
- }
43
- };
44
- }, [
45
- description
46
- ]);
47
- return {
48
- 'aria-describedby': description ? id : undefined
49
- };
50
- }
51
-
52
-
53
- export {$ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription};
54
- //# sourceMappingURL=useDescription.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMD,IAAI,sCAAgB;AACpB,MAAM,yCAAmB,IAAI;AAEtB,SAAS,0CAAe,WAAoB;IACjD,IAAI,CAAC,IAAI,MAAM,GAAG,CAAA,GAAA,eAAO;IAEzB,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,CAAC,aACH;QAGF,IAAI,OAAO,uCAAiB,GAAG,CAAC;QAChC,IAAI,CAAC,MAAM;YACT,IAAI,KAAK,CAAC,uBAAuB,EAAE,uCAAiB;YACpD,MAAM;YAEN,IAAI,OAAO,SAAS,aAAa,CAAC;YAClC,KAAK,EAAE,GAAG;YACV,KAAK,KAAK,CAAC,OAAO,GAAG;YACrB,KAAK,WAAW,GAAG;YACnB,SAAS,IAAI,CAAC,WAAW,CAAC;YAC1B,OAAO;gBAAC,UAAU;gBAAG,SAAS;YAAI;YAClC,uCAAiB,GAAG,CAAC,aAAa;QACpC,OACE,MAAM,KAAK,OAAO,CAAC,EAAE;QAGvB,KAAK,QAAQ;QACb,OAAO;YACL,IAAI,QAAQ,EAAE,KAAK,QAAQ,KAAK,GAAG;gBACjC,KAAK,OAAO,CAAC,MAAM;gBACnB,uCAAiB,MAAM,CAAC;YAC1B;QACF;IACF,GAAG;QAAC;KAAY;IAEhB,OAAO;QACL,oBAAoB,cAAc,KAAK;IACzC;AACF","sources":["packages/@react-aria/utils/src/useDescription.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 {AriaLabelingProps} from '@react-types/shared';\nimport {useLayoutEffect} from './useLayoutEffect';\nimport {useState} from 'react';\n\nlet descriptionId = 0;\nconst descriptionNodes = new Map<string, {refCount: number, element: Element}>();\n\nexport function useDescription(description?: string): AriaLabelingProps {\n let [id, setId] = useState<string | undefined>();\n\n useLayoutEffect(() => {\n if (!description) {\n return;\n }\n\n let desc = descriptionNodes.get(description);\n if (!desc) {\n let id = `react-aria-description-${descriptionId++}`;\n setId(id);\n\n let node = document.createElement('div');\n node.id = id;\n node.style.display = 'none';\n node.textContent = description;\n document.body.appendChild(node);\n desc = {refCount: 0, element: node};\n descriptionNodes.set(description, desc);\n } else {\n setId(desc.element.id);\n }\n\n desc.refCount++;\n return () => {\n if (desc && --desc.refCount === 0) {\n desc.element.remove();\n descriptionNodes.delete(description);\n }\n };\n }, [description]);\n\n return {\n 'aria-describedby': description ? id : undefined\n };\n}\n"],"names":[],"version":3,"file":"useDescription.module.js.map"}
@@ -1,141 +0,0 @@
1
- var $d723bea02f3e2567$exports = require("./DOMFunctions.main.js");
2
- var $16ec41ef3e36c19c$exports = require("./getOffset.main.js");
3
- var $hK8r3$react = require("react");
4
-
5
-
6
- function $parcel$export(e, n, v, s) {
7
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
- }
9
-
10
- $parcel$export(module.exports, "useDrag1D", () => $28ed3fb20343b78b$export$7bbed75feba39706);
11
- /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */ /* eslint-disable rulesdir/pure-render */
22
-
23
-
24
- // Keep track of elements that we are currently handling dragging for via useDrag1D.
25
- // If there's an ancestor and a descendant both using useDrag1D(), and the user starts
26
- // dragging the descendant, we don't want useDrag1D events to fire for the ancestor.
27
- const $28ed3fb20343b78b$var$draggingElements = [];
28
- function $28ed3fb20343b78b$export$7bbed75feba39706(props) {
29
- console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');
30
- let { containerRef: containerRef, reverse: reverse, orientation: orientation, onHover: onHover, onDrag: onDrag, onPositionChange: onPositionChange, onIncrement: onIncrement, onDecrement: onDecrement, onIncrementToMax: onIncrementToMax, onDecrementToMin: onDecrementToMin, onCollapseToggle: onCollapseToggle } = props;
31
- let getPosition = (e)=>orientation === 'horizontal' ? e.clientX : e.clientY;
32
- let getNextOffset = (e)=>{
33
- let containerOffset = (0, $16ec41ef3e36c19c$exports.getOffset)(containerRef.current, reverse, orientation);
34
- let mouseOffset = getPosition(e);
35
- let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;
36
- return nextOffset;
37
- };
38
- let dragging = (0, $hK8r3$react.useRef)(false);
39
- let prevPosition = (0, $hK8r3$react.useRef)(0);
40
- // Keep track of the current handlers in a ref so that the events can access them.
41
- let handlers = (0, $hK8r3$react.useRef)({
42
- onPositionChange: onPositionChange,
43
- onDrag: onDrag
44
- });
45
- handlers.current.onDrag = onDrag;
46
- handlers.current.onPositionChange = onPositionChange;
47
- let onMouseDragged = (e)=>{
48
- e.preventDefault();
49
- let nextOffset = getNextOffset(e);
50
- if (!dragging.current) {
51
- dragging.current = true;
52
- if (handlers.current.onDrag) handlers.current.onDrag(true);
53
- if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
54
- }
55
- if (prevPosition.current === nextOffset) return;
56
- prevPosition.current = nextOffset;
57
- if (onPositionChange) onPositionChange(nextOffset);
58
- };
59
- let onMouseUp = (e)=>{
60
- let target = (0, $d723bea02f3e2567$exports.getEventTarget)(e);
61
- dragging.current = false;
62
- let nextOffset = getNextOffset(e);
63
- if (handlers.current.onDrag) handlers.current.onDrag(false);
64
- if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
65
- $28ed3fb20343b78b$var$draggingElements.splice($28ed3fb20343b78b$var$draggingElements.indexOf(target), 1);
66
- window.removeEventListener('mouseup', onMouseUp, false);
67
- window.removeEventListener('mousemove', onMouseDragged, false);
68
- };
69
- let onMouseDown = (e)=>{
70
- const target = e.currentTarget;
71
- // If we're already handling dragging on a descendant with useDrag1D, then
72
- // we don't want to handle the drag motion on this target as well.
73
- if ($28ed3fb20343b78b$var$draggingElements.some((elt)=>(0, $d723bea02f3e2567$exports.nodeContains)(target, elt))) return;
74
- $28ed3fb20343b78b$var$draggingElements.push(target);
75
- window.addEventListener('mousemove', onMouseDragged, false);
76
- window.addEventListener('mouseup', onMouseUp, false);
77
- };
78
- let onMouseEnter = ()=>{
79
- if (onHover) onHover(true);
80
- };
81
- let onMouseOut = ()=>{
82
- if (onHover) onHover(false);
83
- };
84
- let onKeyDown = (e)=>{
85
- switch(e.key){
86
- case 'Left':
87
- case 'ArrowLeft':
88
- if (orientation === 'horizontal') {
89
- e.preventDefault();
90
- if (onDecrement && !reverse) onDecrement();
91
- else if (onIncrement && reverse) onIncrement();
92
- }
93
- break;
94
- case 'Up':
95
- case 'ArrowUp':
96
- if (orientation === 'vertical') {
97
- e.preventDefault();
98
- if (onDecrement && !reverse) onDecrement();
99
- else if (onIncrement && reverse) onIncrement();
100
- }
101
- break;
102
- case 'Right':
103
- case 'ArrowRight':
104
- if (orientation === 'horizontal') {
105
- e.preventDefault();
106
- if (onIncrement && !reverse) onIncrement();
107
- else if (onDecrement && reverse) onDecrement();
108
- }
109
- break;
110
- case 'Down':
111
- case 'ArrowDown':
112
- if (orientation === 'vertical') {
113
- e.preventDefault();
114
- if (onIncrement && !reverse) onIncrement();
115
- else if (onDecrement && reverse) onDecrement();
116
- }
117
- break;
118
- case 'Home':
119
- e.preventDefault();
120
- if (onDecrementToMin) onDecrementToMin();
121
- break;
122
- case 'End':
123
- e.preventDefault();
124
- if (onIncrementToMax) onIncrementToMax();
125
- break;
126
- case 'Enter':
127
- e.preventDefault();
128
- if (onCollapseToggle) onCollapseToggle();
129
- break;
130
- }
131
- };
132
- return {
133
- onMouseDown: onMouseDown,
134
- onMouseEnter: onMouseEnter,
135
- onMouseOut: onMouseOut,
136
- onKeyDown: onKeyDown
137
- };
138
- }
139
-
140
-
141
- //# sourceMappingURL=useDrag1D.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":"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","sources":["packages/@react-aria/utils/src/useDrag1D.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\n /* eslint-disable rulesdir/pure-render */\n\nimport {getEventTarget, nodeContains} from './shadowdom/DOMFunctions';\nimport {getOffset} from './getOffset';\nimport {Orientation} from '@react-types/shared';\nimport React, {HTMLAttributes, MutableRefObject, useRef} from 'react';\n\ninterface UseDrag1DProps {\n containerRef: MutableRefObject<HTMLElement>,\n reverse?: boolean,\n orientation?: Orientation,\n onHover?: (hovered: boolean) => void,\n onDrag?: (dragging: boolean) => void,\n onPositionChange?: (position: number) => void,\n onIncrement?: () => void,\n onDecrement?: () => void,\n onIncrementToMax?: () => void,\n onDecrementToMin?: () => void,\n onCollapseToggle?: () => void\n}\n\n// Keep track of elements that we are currently handling dragging for via useDrag1D.\n// If there's an ancestor and a descendant both using useDrag1D(), and the user starts\n// dragging the descendant, we don't want useDrag1D events to fire for the ancestor.\nconst draggingElements: HTMLElement[] = [];\n\n// created for splitview, this should be reusable for things like sliders/dials\n// It also handles keyboard events on the target allowing for increment/decrement by a given stepsize as well as minifying/maximizing and toggling between minified and previous size\n// It can also take a 'reverse' param to say if we should measure from the right/bottom instead of the top/left\n// It can also handle either a vertical or horizontal movement, but not both at the same time\n\nexport function useDrag1D(props: UseDrag1DProps): HTMLAttributes<HTMLElement> {\n console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');\n let {containerRef, reverse, orientation, onHover, onDrag, onPositionChange, onIncrement, onDecrement, onIncrementToMax, onDecrementToMin, onCollapseToggle} = props;\n let getPosition = (e) => orientation === 'horizontal' ? e.clientX : e.clientY;\n let getNextOffset = (e: MouseEvent) => {\n let containerOffset = getOffset(containerRef.current, reverse, orientation);\n let mouseOffset = getPosition(e);\n let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;\n return nextOffset;\n };\n let dragging = useRef(false);\n let prevPosition = useRef(0);\n\n // Keep track of the current handlers in a ref so that the events can access them.\n let handlers = useRef({onPositionChange, onDrag});\n handlers.current.onDrag = onDrag;\n handlers.current.onPositionChange = onPositionChange;\n\n let onMouseDragged = (e: MouseEvent) => {\n e.preventDefault();\n let nextOffset = getNextOffset(e);\n if (!dragging.current) {\n dragging.current = true;\n if (handlers.current.onDrag) {\n handlers.current.onDrag(true);\n }\n if (handlers.current.onPositionChange) {\n handlers.current.onPositionChange(nextOffset);\n }\n }\n if (prevPosition.current === nextOffset) {\n return;\n }\n prevPosition.current = nextOffset;\n if (onPositionChange) {\n onPositionChange(nextOffset);\n }\n };\n\n let onMouseUp = (e: MouseEvent) => {\n let target = getEventTarget(e) as HTMLElement;\n dragging.current = false;\n let nextOffset = getNextOffset(e);\n if (handlers.current.onDrag) {\n handlers.current.onDrag(false);\n }\n if (handlers.current.onPositionChange) {\n handlers.current.onPositionChange(nextOffset);\n }\n\n draggingElements.splice(draggingElements.indexOf(target), 1);\n window.removeEventListener('mouseup', onMouseUp, false);\n window.removeEventListener('mousemove', onMouseDragged, false);\n };\n\n let onMouseDown = (e: React.MouseEvent<HTMLElement>) => {\n const target = e.currentTarget;\n // If we're already handling dragging on a descendant with useDrag1D, then\n // we don't want to handle the drag motion on this target as well.\n if (draggingElements.some(elt => nodeContains(target, elt))) {\n return;\n }\n draggingElements.push(target);\n window.addEventListener('mousemove', onMouseDragged, false);\n window.addEventListener('mouseup', onMouseUp, false);\n };\n\n let onMouseEnter = () => {\n if (onHover) {\n onHover(true);\n }\n };\n\n let onMouseOut = () => {\n if (onHover) {\n onHover(false);\n }\n };\n\n let onKeyDown = (e) => {\n switch (e.key) {\n case 'Left':\n case 'ArrowLeft':\n if (orientation === 'horizontal') {\n e.preventDefault();\n if (onDecrement && !reverse) {\n onDecrement();\n } else if (onIncrement && reverse) {\n onIncrement();\n }\n }\n break;\n case 'Up':\n case 'ArrowUp':\n if (orientation === 'vertical') {\n e.preventDefault();\n if (onDecrement && !reverse) {\n onDecrement();\n } else if (onIncrement && reverse) {\n onIncrement();\n }\n }\n break;\n case 'Right':\n case 'ArrowRight':\n if (orientation === 'horizontal') {\n e.preventDefault();\n if (onIncrement && !reverse) {\n onIncrement();\n } else if (onDecrement && reverse) {\n onDecrement();\n }\n }\n break;\n case 'Down':\n case 'ArrowDown':\n if (orientation === 'vertical') {\n e.preventDefault();\n if (onIncrement && !reverse) {\n onIncrement();\n } else if (onDecrement && reverse) {\n onDecrement();\n }\n }\n break;\n case 'Home':\n e.preventDefault();\n if (onDecrementToMin) {\n onDecrementToMin();\n }\n break;\n case 'End':\n e.preventDefault();\n if (onIncrementToMax) {\n onIncrementToMax();\n }\n break;\n case 'Enter':\n e.preventDefault();\n if (onCollapseToggle) {\n onCollapseToggle();\n }\n break;\n }\n };\n\n return {onMouseDown, onMouseEnter, onMouseOut, onKeyDown};\n}\n"],"names":[],"version":3,"file":"useDrag1D.main.js.map"}
@@ -1,136 +0,0 @@
1
- import {getEventTarget as $d4ee10de306f2510$export$e58f029f0fbfdb29, nodeContains as $d4ee10de306f2510$export$4282f70798064fe0} from "./DOMFunctions.mjs";
2
- import {getOffset as $ab71dadb03a6fb2e$export$622cea445a1c5b7d} from "./getOffset.mjs";
3
- import {useRef as $1rnCS$useRef} from "react";
4
-
5
- /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */ /* eslint-disable rulesdir/pure-render */
16
-
17
-
18
- // Keep track of elements that we are currently handling dragging for via useDrag1D.
19
- // If there's an ancestor and a descendant both using useDrag1D(), and the user starts
20
- // dragging the descendant, we don't want useDrag1D events to fire for the ancestor.
21
- const $9cc09df9fd7676be$var$draggingElements = [];
22
- function $9cc09df9fd7676be$export$7bbed75feba39706(props) {
23
- console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');
24
- let { containerRef: containerRef, reverse: reverse, orientation: orientation, onHover: onHover, onDrag: onDrag, onPositionChange: onPositionChange, onIncrement: onIncrement, onDecrement: onDecrement, onIncrementToMax: onIncrementToMax, onDecrementToMin: onDecrementToMin, onCollapseToggle: onCollapseToggle } = props;
25
- let getPosition = (e)=>orientation === 'horizontal' ? e.clientX : e.clientY;
26
- let getNextOffset = (e)=>{
27
- let containerOffset = (0, $ab71dadb03a6fb2e$export$622cea445a1c5b7d)(containerRef.current, reverse, orientation);
28
- let mouseOffset = getPosition(e);
29
- let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;
30
- return nextOffset;
31
- };
32
- let dragging = (0, $1rnCS$useRef)(false);
33
- let prevPosition = (0, $1rnCS$useRef)(0);
34
- // Keep track of the current handlers in a ref so that the events can access them.
35
- let handlers = (0, $1rnCS$useRef)({
36
- onPositionChange: onPositionChange,
37
- onDrag: onDrag
38
- });
39
- handlers.current.onDrag = onDrag;
40
- handlers.current.onPositionChange = onPositionChange;
41
- let onMouseDragged = (e)=>{
42
- e.preventDefault();
43
- let nextOffset = getNextOffset(e);
44
- if (!dragging.current) {
45
- dragging.current = true;
46
- if (handlers.current.onDrag) handlers.current.onDrag(true);
47
- if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
48
- }
49
- if (prevPosition.current === nextOffset) return;
50
- prevPosition.current = nextOffset;
51
- if (onPositionChange) onPositionChange(nextOffset);
52
- };
53
- let onMouseUp = (e)=>{
54
- let target = (0, $d4ee10de306f2510$export$e58f029f0fbfdb29)(e);
55
- dragging.current = false;
56
- let nextOffset = getNextOffset(e);
57
- if (handlers.current.onDrag) handlers.current.onDrag(false);
58
- if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
59
- $9cc09df9fd7676be$var$draggingElements.splice($9cc09df9fd7676be$var$draggingElements.indexOf(target), 1);
60
- window.removeEventListener('mouseup', onMouseUp, false);
61
- window.removeEventListener('mousemove', onMouseDragged, false);
62
- };
63
- let onMouseDown = (e)=>{
64
- const target = e.currentTarget;
65
- // If we're already handling dragging on a descendant with useDrag1D, then
66
- // we don't want to handle the drag motion on this target as well.
67
- if ($9cc09df9fd7676be$var$draggingElements.some((elt)=>(0, $d4ee10de306f2510$export$4282f70798064fe0)(target, elt))) return;
68
- $9cc09df9fd7676be$var$draggingElements.push(target);
69
- window.addEventListener('mousemove', onMouseDragged, false);
70
- window.addEventListener('mouseup', onMouseUp, false);
71
- };
72
- let onMouseEnter = ()=>{
73
- if (onHover) onHover(true);
74
- };
75
- let onMouseOut = ()=>{
76
- if (onHover) onHover(false);
77
- };
78
- let onKeyDown = (e)=>{
79
- switch(e.key){
80
- case 'Left':
81
- case 'ArrowLeft':
82
- if (orientation === 'horizontal') {
83
- e.preventDefault();
84
- if (onDecrement && !reverse) onDecrement();
85
- else if (onIncrement && reverse) onIncrement();
86
- }
87
- break;
88
- case 'Up':
89
- case 'ArrowUp':
90
- if (orientation === 'vertical') {
91
- e.preventDefault();
92
- if (onDecrement && !reverse) onDecrement();
93
- else if (onIncrement && reverse) onIncrement();
94
- }
95
- break;
96
- case 'Right':
97
- case 'ArrowRight':
98
- if (orientation === 'horizontal') {
99
- e.preventDefault();
100
- if (onIncrement && !reverse) onIncrement();
101
- else if (onDecrement && reverse) onDecrement();
102
- }
103
- break;
104
- case 'Down':
105
- case 'ArrowDown':
106
- if (orientation === 'vertical') {
107
- e.preventDefault();
108
- if (onIncrement && !reverse) onIncrement();
109
- else if (onDecrement && reverse) onDecrement();
110
- }
111
- break;
112
- case 'Home':
113
- e.preventDefault();
114
- if (onDecrementToMin) onDecrementToMin();
115
- break;
116
- case 'End':
117
- e.preventDefault();
118
- if (onIncrementToMax) onIncrementToMax();
119
- break;
120
- case 'Enter':
121
- e.preventDefault();
122
- if (onCollapseToggle) onCollapseToggle();
123
- break;
124
- }
125
- };
126
- return {
127
- onMouseDown: onMouseDown,
128
- onMouseEnter: onMouseEnter,
129
- onMouseOut: onMouseOut,
130
- onKeyDown: onKeyDown
131
- };
132
- }
133
-
134
-
135
- export {$9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D};
136
- //# sourceMappingURL=useDrag1D.module.js.map