@react-aria/utils 3.23.2 → 3.24.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 (171) hide show
  1. package/dist/chain.main.js +26 -0
  2. package/dist/chain.main.js.map +1 -0
  3. package/dist/chain.mjs +21 -0
  4. package/dist/chain.module.js +21 -0
  5. package/dist/chain.module.js.map +1 -0
  6. package/dist/domHelpers.main.js +19 -0
  7. package/dist/domHelpers.main.js.map +1 -0
  8. package/dist/domHelpers.mjs +13 -0
  9. package/dist/domHelpers.module.js +13 -0
  10. package/dist/domHelpers.module.js.map +1 -0
  11. package/dist/filterDOMProps.main.js +45 -0
  12. package/dist/filterDOMProps.main.js.map +1 -0
  13. package/dist/filterDOMProps.mjs +40 -0
  14. package/dist/filterDOMProps.module.js +40 -0
  15. package/dist/filterDOMProps.module.js.map +1 -0
  16. package/dist/focusWithoutScrolling.main.js +72 -0
  17. package/dist/focusWithoutScrolling.main.js.map +1 -0
  18. package/dist/focusWithoutScrolling.mjs +67 -0
  19. package/dist/focusWithoutScrolling.module.js +67 -0
  20. package/dist/focusWithoutScrolling.module.js.map +1 -0
  21. package/dist/getOffset.main.js +24 -0
  22. package/dist/getOffset.main.js.map +1 -0
  23. package/dist/getOffset.mjs +19 -0
  24. package/dist/getOffset.module.js +19 -0
  25. package/dist/getOffset.module.js.map +1 -0
  26. package/dist/getScrollParent.main.js +28 -0
  27. package/dist/getScrollParent.main.js.map +1 -0
  28. package/dist/getScrollParent.mjs +23 -0
  29. package/dist/getScrollParent.module.js +23 -0
  30. package/dist/getScrollParent.module.js.map +1 -0
  31. package/dist/getScrollParents.main.js +30 -0
  32. package/dist/getScrollParents.main.js.map +1 -0
  33. package/dist/getScrollParents.mjs +25 -0
  34. package/dist/getScrollParents.module.js +25 -0
  35. package/dist/getScrollParents.module.js.map +1 -0
  36. package/dist/import.mjs +32 -1232
  37. package/dist/isScrollable.main.js +25 -0
  38. package/dist/isScrollable.main.js.map +1 -0
  39. package/dist/isScrollable.mjs +20 -0
  40. package/dist/isScrollable.module.js +20 -0
  41. package/dist/isScrollable.module.js.map +1 -0
  42. package/dist/isVirtualEvent.main.js +41 -0
  43. package/dist/isVirtualEvent.main.js.map +1 -0
  44. package/dist/isVirtualEvent.mjs +35 -0
  45. package/dist/isVirtualEvent.module.js +35 -0
  46. package/dist/isVirtualEvent.module.js.map +1 -0
  47. package/dist/main.js +80 -1282
  48. package/dist/main.js.map +1 -1
  49. package/dist/mergeProps.main.js +51 -0
  50. package/dist/mergeProps.main.js.map +1 -0
  51. package/dist/mergeProps.mjs +42 -0
  52. package/dist/mergeProps.module.js +42 -0
  53. package/dist/mergeProps.module.js.map +1 -0
  54. package/dist/mergeRefs.main.js +28 -0
  55. package/dist/mergeRefs.main.js.map +1 -0
  56. package/dist/mergeRefs.mjs +23 -0
  57. package/dist/mergeRefs.module.js +23 -0
  58. package/dist/mergeRefs.module.js.map +1 -0
  59. package/dist/module.js +32 -1232
  60. package/dist/module.js.map +1 -1
  61. package/dist/openLink.main.js +143 -0
  62. package/dist/openLink.main.js.map +1 -0
  63. package/dist/openLink.mjs +129 -0
  64. package/dist/openLink.module.js +129 -0
  65. package/dist/openLink.module.js.map +1 -0
  66. package/dist/platform.main.js +64 -0
  67. package/dist/platform.main.js.map +1 -0
  68. package/dist/platform.mjs +51 -0
  69. package/dist/platform.module.js +51 -0
  70. package/dist/platform.module.js.map +1 -0
  71. package/dist/runAfterTransition.main.js +82 -0
  72. package/dist/runAfterTransition.main.js.map +1 -0
  73. package/dist/runAfterTransition.mjs +77 -0
  74. package/dist/runAfterTransition.module.js +77 -0
  75. package/dist/runAfterTransition.module.js.map +1 -0
  76. package/dist/scrollIntoView.main.js +96 -0
  77. package/dist/scrollIntoView.main.js.map +1 -0
  78. package/dist/scrollIntoView.mjs +90 -0
  79. package/dist/scrollIntoView.module.js +90 -0
  80. package/dist/scrollIntoView.module.js.map +1 -0
  81. package/dist/types.d.ts +17 -6
  82. package/dist/types.d.ts.map +1 -1
  83. package/dist/useDeepMemo.main.js +30 -0
  84. package/dist/useDeepMemo.main.js.map +1 -0
  85. package/dist/useDeepMemo.mjs +25 -0
  86. package/dist/useDeepMemo.module.js +25 -0
  87. package/dist/useDeepMemo.module.js.map +1 -0
  88. package/dist/useDescription.main.js +59 -0
  89. package/dist/useDescription.main.js.map +1 -0
  90. package/dist/useDescription.mjs +54 -0
  91. package/dist/useDescription.module.js +54 -0
  92. package/dist/useDescription.module.js.map +1 -0
  93. package/dist/useDrag1D.main.js +139 -0
  94. package/dist/useDrag1D.main.js.map +1 -0
  95. package/dist/useDrag1D.mjs +134 -0
  96. package/dist/useDrag1D.module.js +134 -0
  97. package/dist/useDrag1D.module.js.map +1 -0
  98. package/dist/useEffectEvent.main.js +37 -0
  99. package/dist/useEffectEvent.main.js.map +1 -0
  100. package/dist/useEffectEvent.mjs +32 -0
  101. package/dist/useEffectEvent.module.js +32 -0
  102. package/dist/useEffectEvent.module.js.map +1 -0
  103. package/dist/useEvent.main.js +42 -0
  104. package/dist/useEvent.main.js.map +1 -0
  105. package/dist/useEvent.mjs +37 -0
  106. package/dist/useEvent.module.js +37 -0
  107. package/dist/useEvent.module.js.map +1 -0
  108. package/dist/useFormReset.main.js +41 -0
  109. package/dist/useFormReset.main.js.map +1 -0
  110. package/dist/useFormReset.mjs +36 -0
  111. package/dist/useFormReset.module.js +36 -0
  112. package/dist/useFormReset.module.js.map +1 -0
  113. package/dist/useGlobalListeners.main.js +63 -0
  114. package/dist/useGlobalListeners.main.js.map +1 -0
  115. package/dist/useGlobalListeners.mjs +58 -0
  116. package/dist/useGlobalListeners.module.js +58 -0
  117. package/dist/useGlobalListeners.module.js.map +1 -0
  118. package/dist/useId.main.js +93 -0
  119. package/dist/useId.main.js.map +1 -0
  120. package/dist/useId.mjs +86 -0
  121. package/dist/useId.module.js +86 -0
  122. package/dist/useId.module.js.map +1 -0
  123. package/dist/useLabels.main.js +44 -0
  124. package/dist/useLabels.main.js.map +1 -0
  125. package/dist/useLabels.mjs +39 -0
  126. package/dist/useLabels.module.js +39 -0
  127. package/dist/useLabels.module.js.map +1 -0
  128. package/dist/useLayoutEffect.main.js +27 -0
  129. package/dist/useLayoutEffect.main.js.map +1 -0
  130. package/dist/useLayoutEffect.mjs +18 -0
  131. package/dist/useLayoutEffect.module.js +18 -0
  132. package/dist/useLayoutEffect.module.js.map +1 -0
  133. package/dist/useObjectRef.main.js +37 -0
  134. package/dist/useObjectRef.main.js.map +1 -0
  135. package/dist/useObjectRef.mjs +32 -0
  136. package/dist/useObjectRef.module.js +32 -0
  137. package/dist/useObjectRef.module.js.map +1 -0
  138. package/dist/useResizeObserver.main.js +40 -0
  139. package/dist/useResizeObserver.main.js.map +1 -0
  140. package/dist/useResizeObserver.mjs +35 -0
  141. package/dist/useResizeObserver.module.js +35 -0
  142. package/dist/useResizeObserver.module.js.map +1 -0
  143. package/dist/useSyncRef.main.js +32 -0
  144. package/dist/useSyncRef.main.js.map +1 -0
  145. package/dist/useSyncRef.mjs +27 -0
  146. package/dist/useSyncRef.module.js +27 -0
  147. package/dist/useSyncRef.module.js.map +1 -0
  148. package/dist/useUpdateEffect.main.js +38 -0
  149. package/dist/useUpdateEffect.main.js.map +1 -0
  150. package/dist/useUpdateEffect.mjs +33 -0
  151. package/dist/useUpdateEffect.module.js +33 -0
  152. package/dist/useUpdateEffect.module.js.map +1 -0
  153. package/dist/useValueEffect.main.js +58 -0
  154. package/dist/useValueEffect.main.js.map +1 -0
  155. package/dist/useValueEffect.mjs +53 -0
  156. package/dist/useValueEffect.module.js +53 -0
  157. package/dist/useValueEffect.module.js.map +1 -0
  158. package/dist/useViewportSize.main.js +56 -0
  159. package/dist/useViewportSize.main.js.map +1 -0
  160. package/dist/useViewportSize.mjs +51 -0
  161. package/dist/useViewportSize.module.js +51 -0
  162. package/dist/useViewportSize.module.js.map +1 -0
  163. package/package.json +5 -5
  164. package/src/filterDOMProps.ts +1 -0
  165. package/src/getScrollParent.ts +2 -10
  166. package/src/getScrollParents.ts +26 -0
  167. package/src/index.ts +4 -2
  168. package/src/isScrollable.ts +22 -0
  169. package/src/mergeRefs.ts +2 -2
  170. package/src/openLink.tsx +25 -9
  171. package/src/scrollIntoView.ts +3 -5
@@ -0,0 +1,32 @@
1
+ import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
2
+ import {useRef as $lmaYr$useRef, useCallback as $lmaYr$useCallback} from "react";
3
+
4
+ /*
5
+ * Copyright 2023 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 $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
17
+ const ref = (0, $lmaYr$useRef)(null);
18
+ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
19
+ ref.current = fn;
20
+ }, [
21
+ fn
22
+ ]);
23
+ // @ts-ignore
24
+ return (0, $lmaYr$useCallback)((...args)=>{
25
+ const f = ref.current;
26
+ return f === null || f === void 0 ? void 0 : f(...args);
27
+ }, []);
28
+ }
29
+
30
+
31
+ export {$8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent};
32
+ //# sourceMappingURL=useEffectEvent.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAKM,SAAS,0CAAmC,EAAM;IACvD,MAAM,MAAM,CAAA,GAAA,aAAK,EAAwB;IACzC,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,OAAO,GAAG;IAChB,GAAG;QAAC;KAAG;IACP,aAAa;IACb,OAAO,CAAA,GAAA,kBAAU,EAAK,CAAC,GAAG;QACxB,MAAM,IAAI,IAAI,OAAO;QACrB,OAAO,cAAA,wBAAA,KAAO;IAChB,GAAG,EAAE;AACP","sources":["packages/@react-aria/utils/src/useEffectEvent.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\nimport {useCallback, useRef} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEffectEvent<T extends Function>(fn?: T): T {\n const ref = useRef<T | null | undefined>(null);\n useLayoutEffect(() => {\n ref.current = fn;\n }, [fn]);\n // @ts-ignore\n return useCallback<T>((...args) => {\n const f = ref.current!;\n return f?.(...args);\n }, []);\n}\n"],"names":[],"version":3,"file":"useEffectEvent.module.js.map"}
@@ -0,0 +1,42 @@
1
+ var $1254e5bb94ac8761$exports = require("./useEffectEvent.main.js");
2
+ var $8UjJN$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, "useEvent", () => $2a8c0bb1629926c8$export$90fc3a17d93f704c);
10
+ /*
11
+ * Copyright 2021 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
+ function $2a8c0bb1629926c8$export$90fc3a17d93f704c(ref, event, handler, options) {
23
+ let handleEvent = (0, $1254e5bb94ac8761$exports.useEffectEvent)(handler);
24
+ let isDisabled = handler == null;
25
+ (0, $8UjJN$react.useEffect)(()=>{
26
+ if (isDisabled || !ref.current) return;
27
+ let element = ref.current;
28
+ element.addEventListener(event, handleEvent, options);
29
+ return ()=>{
30
+ element.removeEventListener(event, handleEvent, options);
31
+ };
32
+ }, [
33
+ ref,
34
+ event,
35
+ options,
36
+ isDisabled,
37
+ handleEvent
38
+ ]);
39
+ }
40
+
41
+
42
+ //# sourceMappingURL=useEvent.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAKM,SAAS,0CACd,GAA2B,EAC3B,KAAQ,EACR,OAAqE,EACrE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;IACjC,IAAI,aAAa,WAAW;IAE5B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,cAAc,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,UAAU,IAAI,OAAO;QACzB,QAAQ,gBAAgB,CAAC,OAAO,aAA8B;QAC9D,OAAO;YACL,QAAQ,mBAAmB,CAAC,OAAO,aAA8B;QACnE;IACF,GAAG;QAAC;QAAK;QAAO;QAAS;QAAY;KAAY;AACnD","sources":["packages/@react-aria/utils/src/useEvent.ts"],"sourcesContent":["/*\n * Copyright 2021 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 {RefObject, useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useEvent<K extends keyof GlobalEventHandlersEventMap>(\n ref: RefObject<EventTarget>,\n event: K,\n handler?: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n let handleEvent = useEffectEvent(handler);\n let isDisabled = handler == null;\n\n useEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n\n let element = ref.current;\n element.addEventListener(event, handleEvent as EventListener, options);\n return () => {\n element.removeEventListener(event, handleEvent as EventListener, options);\n };\n }, [ref, event, options, isDisabled, handleEvent]);\n}\n"],"names":[],"version":3,"file":"useEvent.main.js.map"}
@@ -0,0 +1,37 @@
1
+ import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.mjs";
2
+ import {useEffect as $ceQd6$useEffect} from "react";
3
+
4
+ /*
5
+ * Copyright 2021 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 $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler, options) {
17
+ let handleEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(handler);
18
+ let isDisabled = handler == null;
19
+ (0, $ceQd6$useEffect)(()=>{
20
+ if (isDisabled || !ref.current) return;
21
+ let element = ref.current;
22
+ element.addEventListener(event, handleEvent, options);
23
+ return ()=>{
24
+ element.removeEventListener(event, handleEvent, options);
25
+ };
26
+ }, [
27
+ ref,
28
+ event,
29
+ options,
30
+ isDisabled,
31
+ handleEvent
32
+ ]);
33
+ }
34
+
35
+
36
+ export {$e9faafb641e167db$export$90fc3a17d93f704c as useEvent};
37
+ //# sourceMappingURL=useEvent.mjs.map
@@ -0,0 +1,37 @@
1
+ import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.module.js";
2
+ import {useEffect as $ceQd6$useEffect} from "react";
3
+
4
+ /*
5
+ * Copyright 2021 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 $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler, options) {
17
+ let handleEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(handler);
18
+ let isDisabled = handler == null;
19
+ (0, $ceQd6$useEffect)(()=>{
20
+ if (isDisabled || !ref.current) return;
21
+ let element = ref.current;
22
+ element.addEventListener(event, handleEvent, options);
23
+ return ()=>{
24
+ element.removeEventListener(event, handleEvent, options);
25
+ };
26
+ }, [
27
+ ref,
28
+ event,
29
+ options,
30
+ isDisabled,
31
+ handleEvent
32
+ ]);
33
+ }
34
+
35
+
36
+ export {$e9faafb641e167db$export$90fc3a17d93f704c as useEvent};
37
+ //# sourceMappingURL=useEvent.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAKM,SAAS,0CACd,GAA2B,EAC3B,KAAQ,EACR,OAAqE,EACrE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,yCAAa,EAAE;IACjC,IAAI,aAAa,WAAW;IAE5B,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,cAAc,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,UAAU,IAAI,OAAO;QACzB,QAAQ,gBAAgB,CAAC,OAAO,aAA8B;QAC9D,OAAO;YACL,QAAQ,mBAAmB,CAAC,OAAO,aAA8B;QACnE;IACF,GAAG;QAAC;QAAK;QAAO;QAAS;QAAY;KAAY;AACnD","sources":["packages/@react-aria/utils/src/useEvent.ts"],"sourcesContent":["/*\n * Copyright 2021 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 {RefObject, useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useEvent<K extends keyof GlobalEventHandlersEventMap>(\n ref: RefObject<EventTarget>,\n event: K,\n handler?: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n let handleEvent = useEffectEvent(handler);\n let isDisabled = handler == null;\n\n useEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n\n let element = ref.current;\n element.addEventListener(event, handleEvent as EventListener, options);\n return () => {\n element.removeEventListener(event, handleEvent as EventListener, options);\n };\n }, [ref, event, options, isDisabled, handleEvent]);\n}\n"],"names":[],"version":3,"file":"useEvent.module.js.map"}
@@ -0,0 +1,41 @@
1
+ var $1254e5bb94ac8761$exports = require("./useEffectEvent.main.js");
2
+ var $81vbz$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, "useFormReset", () => $1f205e845604a423$export$5add1d006293d136);
10
+ /*
11
+ * Copyright 2023 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
+ function $1f205e845604a423$export$5add1d006293d136(ref, initialValue, onReset) {
23
+ let resetValue = (0, $81vbz$react.useRef)(initialValue);
24
+ let handleReset = (0, $1254e5bb94ac8761$exports.useEffectEvent)(()=>{
25
+ if (onReset) onReset(resetValue.current);
26
+ });
27
+ (0, $81vbz$react.useEffect)(()=>{
28
+ var _ref_current;
29
+ let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
30
+ form === null || form === void 0 ? void 0 : form.addEventListener("reset", handleReset);
31
+ return ()=>{
32
+ form === null || form === void 0 ? void 0 : form.removeEventListener("reset", handleReset);
33
+ };
34
+ }, [
35
+ ref,
36
+ handleReset
37
+ ]);
38
+ }
39
+
40
+
41
+ //# sourceMappingURL=useFormReset.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAIM,SAAS,0CACd,GAA0E,EAC1E,YAAe,EACf,OAA2B;IAE3B,IAAI,aAAa,CAAA,GAAA,mBAAK,EAAE;IACxB,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,IAAI,SACF,QAAQ,WAAW,OAAO;IAE9B;IAEA,CAAA,GAAA,sBAAQ,EAAE;YACG;QAAX,IAAI,OAAO,gBAAA,2BAAA,eAAA,IAAK,OAAO,cAAZ,mCAAA,aAAc,IAAI;QAC7B,iBAAA,2BAAA,KAAM,gBAAgB,CAAC,SAAS;QAChC,OAAO;YACL,iBAAA,2BAAA,KAAM,mBAAmB,CAAC,SAAS;QACrC;IACF,GAAG;QAAC;QAAK;KAAY;AACvB","sources":["packages/@react-aria/utils/src/useFormReset.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 */\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useFormReset<T>(\n ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>,\n initialValue: T,\n onReset: (value: T) => void\n) {\n let resetValue = useRef(initialValue);\n let handleReset = useEffectEvent(() => {\n if (onReset) {\n onReset(resetValue.current);\n }\n });\n\n useEffect(() => {\n let form = ref?.current?.form;\n form?.addEventListener('reset', handleReset);\n return () => {\n form?.removeEventListener('reset', handleReset);\n };\n }, [ref, handleReset]);\n}\n"],"names":[],"version":3,"file":"useFormReset.main.js.map"}
@@ -0,0 +1,36 @@
1
+ import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.mjs";
2
+ import {useRef as $8rM3G$useRef, useEffect as $8rM3G$useEffect} from "react";
3
+
4
+ /*
5
+ * Copyright 2023 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 $99facab73266f662$export$5add1d006293d136(ref, initialValue, onReset) {
17
+ let resetValue = (0, $8rM3G$useRef)(initialValue);
18
+ let handleReset = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(()=>{
19
+ if (onReset) onReset(resetValue.current);
20
+ });
21
+ (0, $8rM3G$useEffect)(()=>{
22
+ var _ref_current;
23
+ let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
24
+ form === null || form === void 0 ? void 0 : form.addEventListener("reset", handleReset);
25
+ return ()=>{
26
+ form === null || form === void 0 ? void 0 : form.removeEventListener("reset", handleReset);
27
+ };
28
+ }, [
29
+ ref,
30
+ handleReset
31
+ ]);
32
+ }
33
+
34
+
35
+ export {$99facab73266f662$export$5add1d006293d136 as useFormReset};
36
+ //# sourceMappingURL=useFormReset.mjs.map
@@ -0,0 +1,36 @@
1
+ import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.module.js";
2
+ import {useRef as $8rM3G$useRef, useEffect as $8rM3G$useEffect} from "react";
3
+
4
+ /*
5
+ * Copyright 2023 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 $99facab73266f662$export$5add1d006293d136(ref, initialValue, onReset) {
17
+ let resetValue = (0, $8rM3G$useRef)(initialValue);
18
+ let handleReset = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(()=>{
19
+ if (onReset) onReset(resetValue.current);
20
+ });
21
+ (0, $8rM3G$useEffect)(()=>{
22
+ var _ref_current;
23
+ let form = ref === null || ref === void 0 ? void 0 : (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.form;
24
+ form === null || form === void 0 ? void 0 : form.addEventListener("reset", handleReset);
25
+ return ()=>{
26
+ form === null || form === void 0 ? void 0 : form.removeEventListener("reset", handleReset);
27
+ };
28
+ }, [
29
+ ref,
30
+ handleReset
31
+ ]);
32
+ }
33
+
34
+
35
+ export {$99facab73266f662$export$5add1d006293d136 as useFormReset};
36
+ //# sourceMappingURL=useFormReset.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAIM,SAAS,0CACd,GAA0E,EAC1E,YAAe,EACf,OAA2B;IAE3B,IAAI,aAAa,CAAA,GAAA,aAAK,EAAE;IACxB,IAAI,cAAc,CAAA,GAAA,yCAAa,EAAE;QAC/B,IAAI,SACF,QAAQ,WAAW,OAAO;IAE9B;IAEA,CAAA,GAAA,gBAAQ,EAAE;YACG;QAAX,IAAI,OAAO,gBAAA,2BAAA,eAAA,IAAK,OAAO,cAAZ,mCAAA,aAAc,IAAI;QAC7B,iBAAA,2BAAA,KAAM,gBAAgB,CAAC,SAAS;QAChC,OAAO;YACL,iBAAA,2BAAA,KAAM,mBAAmB,CAAC,SAAS;QACrC;IACF,GAAG;QAAC;QAAK;KAAY;AACvB","sources":["packages/@react-aria/utils/src/useFormReset.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 */\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useFormReset<T>(\n ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>,\n initialValue: T,\n onReset: (value: T) => void\n) {\n let resetValue = useRef(initialValue);\n let handleReset = useEffectEvent(() => {\n if (onReset) {\n onReset(resetValue.current);\n }\n });\n\n useEffect(() => {\n let form = ref?.current?.form;\n form?.addEventListener('reset', handleReset);\n return () => {\n form?.removeEventListener('reset', handleReset);\n };\n }, [ref, handleReset]);\n}\n"],"names":[],"version":3,"file":"useFormReset.module.js.map"}
@@ -0,0 +1,63 @@
1
+ var $eHdSW$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, "useGlobalListeners", () => $4571ff54ac709100$export$4eaf04e54aa8eed6);
9
+ /*
10
+ * Copyright 2020 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
+ */
20
+ function $4571ff54ac709100$export$4eaf04e54aa8eed6() {
21
+ let globalListeners = (0, $eHdSW$react.useRef)(new Map());
22
+ let addGlobalListener = (0, $eHdSW$react.useCallback)((eventTarget, type, listener, options)=>{
23
+ // Make sure we remove the listener after it is called with the `once` option.
24
+ let fn = (options === null || options === void 0 ? void 0 : options.once) ? (...args)=>{
25
+ globalListeners.current.delete(listener);
26
+ listener(...args);
27
+ } : listener;
28
+ globalListeners.current.set(listener, {
29
+ type: type,
30
+ eventTarget: eventTarget,
31
+ fn: fn,
32
+ options: options
33
+ });
34
+ eventTarget.addEventListener(type, listener, options);
35
+ }, []);
36
+ let removeGlobalListener = (0, $eHdSW$react.useCallback)((eventTarget, type, listener, options)=>{
37
+ var _globalListeners_current_get;
38
+ let fn = ((_globalListeners_current_get = globalListeners.current.get(listener)) === null || _globalListeners_current_get === void 0 ? void 0 : _globalListeners_current_get.fn) || listener;
39
+ eventTarget.removeEventListener(type, fn, options);
40
+ globalListeners.current.delete(listener);
41
+ }, []);
42
+ let removeAllGlobalListeners = (0, $eHdSW$react.useCallback)(()=>{
43
+ globalListeners.current.forEach((value, key)=>{
44
+ removeGlobalListener(value.eventTarget, value.type, key, value.options);
45
+ });
46
+ }, [
47
+ removeGlobalListener
48
+ ]);
49
+ // eslint-disable-next-line arrow-body-style
50
+ (0, $eHdSW$react.useEffect)(()=>{
51
+ return removeAllGlobalListeners;
52
+ }, [
53
+ removeAllGlobalListeners
54
+ ]);
55
+ return {
56
+ addGlobalListener: addGlobalListener,
57
+ removeGlobalListener: removeGlobalListener,
58
+ removeAllGlobalListeners: removeAllGlobalListeners
59
+ };
60
+ }
61
+
62
+
63
+ //# sourceMappingURL=useGlobalListeners.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAYM,SAAS;IACd,IAAI,kBAAkB,CAAA,GAAA,mBAAK,EAAE,IAAI;IACjC,IAAI,oBAAoB,CAAA,GAAA,wBAAU,EAAE,CAAC,aAAa,MAAM,UAAU;QAChE,8EAA8E;QAC9E,IAAI,KAAK,CAAA,oBAAA,8BAAA,QAAS,IAAI,IAAG,CAAC,GAAG;YAC3B,gBAAgB,OAAO,CAAC,MAAM,CAAC;YAC/B,YAAY;QACd,IAAI;QACJ,gBAAgB,OAAO,CAAC,GAAG,CAAC,UAAU;kBAAC;yBAAM;gBAAa;qBAAI;QAAO;QACrE,YAAY,gBAAgB,CAAC,MAAM,UAAU;IAC/C,GAAG,EAAE;IACL,IAAI,uBAAuB,CAAA,GAAA,wBAAU,EAAE,CAAC,aAAa,MAAM,UAAU;YAC1D;QAAT,IAAI,KAAK,EAAA,+BAAA,gBAAgB,OAAO,CAAC,GAAG,CAAC,uBAA5B,mDAAA,6BAAuC,EAAE,KAAI;QACtD,YAAY,mBAAmB,CAAC,MAAM,IAAI;QAC1C,gBAAgB,OAAO,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE;IACL,IAAI,2BAA2B,CAAA,GAAA,wBAAU,EAAE;QACzC,gBAAgB,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO;YACtC,qBAAqB,MAAM,WAAW,EAAE,MAAM,IAAI,EAAE,KAAK,MAAM,OAAO;QACxE;IACF,GAAG;QAAC;KAAqB;IAEzB,4CAA4C;IAC5C,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;IACT,GAAG;QAAC;KAAyB;IAE7B,OAAO;2BAAC;8BAAmB;kCAAsB;IAAwB;AAC3E","sources":["packages/@react-aria/utils/src/useGlobalListeners.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 {useCallback, useEffect, useRef} from 'react';\n\ninterface GlobalListeners {\n addGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void,\n addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void,\n removeGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void,\n removeGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void,\n removeAllGlobalListeners(): void\n}\n\nexport function useGlobalListeners(): GlobalListeners {\n let globalListeners = useRef(new Map());\n let addGlobalListener = useCallback((eventTarget, type, listener, options) => {\n // Make sure we remove the listener after it is called with the `once` option.\n let fn = options?.once ? (...args) => {\n globalListeners.current.delete(listener);\n listener(...args);\n } : listener;\n globalListeners.current.set(listener, {type, eventTarget, fn, options});\n eventTarget.addEventListener(type, listener, options);\n }, []);\n let removeGlobalListener = useCallback((eventTarget, type, listener, options) => {\n let fn = globalListeners.current.get(listener)?.fn || listener;\n eventTarget.removeEventListener(type, fn, options);\n globalListeners.current.delete(listener);\n }, []);\n let removeAllGlobalListeners = useCallback(() => {\n globalListeners.current.forEach((value, key) => {\n removeGlobalListener(value.eventTarget, value.type, key, value.options);\n });\n }, [removeGlobalListener]);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return removeAllGlobalListeners;\n }, [removeAllGlobalListeners]);\n\n return {addGlobalListener, removeGlobalListener, removeAllGlobalListeners};\n}\n"],"names":[],"version":3,"file":"useGlobalListeners.main.js.map"}
@@ -0,0 +1,58 @@
1
+ import {useRef as $lPAwt$useRef, useCallback as $lPAwt$useCallback, useEffect as $lPAwt$useEffect} from "react";
2
+
3
+ /*
4
+ * Copyright 2020 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
+ */
14
+ function $03deb23ff14920c4$export$4eaf04e54aa8eed6() {
15
+ let globalListeners = (0, $lPAwt$useRef)(new Map());
16
+ let addGlobalListener = (0, $lPAwt$useCallback)((eventTarget, type, listener, options)=>{
17
+ // Make sure we remove the listener after it is called with the `once` option.
18
+ let fn = (options === null || options === void 0 ? void 0 : options.once) ? (...args)=>{
19
+ globalListeners.current.delete(listener);
20
+ listener(...args);
21
+ } : listener;
22
+ globalListeners.current.set(listener, {
23
+ type: type,
24
+ eventTarget: eventTarget,
25
+ fn: fn,
26
+ options: options
27
+ });
28
+ eventTarget.addEventListener(type, listener, options);
29
+ }, []);
30
+ let removeGlobalListener = (0, $lPAwt$useCallback)((eventTarget, type, listener, options)=>{
31
+ var _globalListeners_current_get;
32
+ let fn = ((_globalListeners_current_get = globalListeners.current.get(listener)) === null || _globalListeners_current_get === void 0 ? void 0 : _globalListeners_current_get.fn) || listener;
33
+ eventTarget.removeEventListener(type, fn, options);
34
+ globalListeners.current.delete(listener);
35
+ }, []);
36
+ let removeAllGlobalListeners = (0, $lPAwt$useCallback)(()=>{
37
+ globalListeners.current.forEach((value, key)=>{
38
+ removeGlobalListener(value.eventTarget, value.type, key, value.options);
39
+ });
40
+ }, [
41
+ removeGlobalListener
42
+ ]);
43
+ // eslint-disable-next-line arrow-body-style
44
+ (0, $lPAwt$useEffect)(()=>{
45
+ return removeAllGlobalListeners;
46
+ }, [
47
+ removeAllGlobalListeners
48
+ ]);
49
+ return {
50
+ addGlobalListener: addGlobalListener,
51
+ removeGlobalListener: removeGlobalListener,
52
+ removeAllGlobalListeners: removeAllGlobalListeners
53
+ };
54
+ }
55
+
56
+
57
+ export {$03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners};
58
+ //# sourceMappingURL=useGlobalListeners.mjs.map
@@ -0,0 +1,58 @@
1
+ import {useRef as $lPAwt$useRef, useCallback as $lPAwt$useCallback, useEffect as $lPAwt$useEffect} from "react";
2
+
3
+ /*
4
+ * Copyright 2020 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
+ */
14
+ function $03deb23ff14920c4$export$4eaf04e54aa8eed6() {
15
+ let globalListeners = (0, $lPAwt$useRef)(new Map());
16
+ let addGlobalListener = (0, $lPAwt$useCallback)((eventTarget, type, listener, options)=>{
17
+ // Make sure we remove the listener after it is called with the `once` option.
18
+ let fn = (options === null || options === void 0 ? void 0 : options.once) ? (...args)=>{
19
+ globalListeners.current.delete(listener);
20
+ listener(...args);
21
+ } : listener;
22
+ globalListeners.current.set(listener, {
23
+ type: type,
24
+ eventTarget: eventTarget,
25
+ fn: fn,
26
+ options: options
27
+ });
28
+ eventTarget.addEventListener(type, listener, options);
29
+ }, []);
30
+ let removeGlobalListener = (0, $lPAwt$useCallback)((eventTarget, type, listener, options)=>{
31
+ var _globalListeners_current_get;
32
+ let fn = ((_globalListeners_current_get = globalListeners.current.get(listener)) === null || _globalListeners_current_get === void 0 ? void 0 : _globalListeners_current_get.fn) || listener;
33
+ eventTarget.removeEventListener(type, fn, options);
34
+ globalListeners.current.delete(listener);
35
+ }, []);
36
+ let removeAllGlobalListeners = (0, $lPAwt$useCallback)(()=>{
37
+ globalListeners.current.forEach((value, key)=>{
38
+ removeGlobalListener(value.eventTarget, value.type, key, value.options);
39
+ });
40
+ }, [
41
+ removeGlobalListener
42
+ ]);
43
+ // eslint-disable-next-line arrow-body-style
44
+ (0, $lPAwt$useEffect)(()=>{
45
+ return removeAllGlobalListeners;
46
+ }, [
47
+ removeAllGlobalListeners
48
+ ]);
49
+ return {
50
+ addGlobalListener: addGlobalListener,
51
+ removeGlobalListener: removeGlobalListener,
52
+ removeAllGlobalListeners: removeAllGlobalListeners
53
+ };
54
+ }
55
+
56
+
57
+ export {$03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners};
58
+ //# sourceMappingURL=useGlobalListeners.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAYM,SAAS;IACd,IAAI,kBAAkB,CAAA,GAAA,aAAK,EAAE,IAAI;IACjC,IAAI,oBAAoB,CAAA,GAAA,kBAAU,EAAE,CAAC,aAAa,MAAM,UAAU;QAChE,8EAA8E;QAC9E,IAAI,KAAK,CAAA,oBAAA,8BAAA,QAAS,IAAI,IAAG,CAAC,GAAG;YAC3B,gBAAgB,OAAO,CAAC,MAAM,CAAC;YAC/B,YAAY;QACd,IAAI;QACJ,gBAAgB,OAAO,CAAC,GAAG,CAAC,UAAU;kBAAC;yBAAM;gBAAa;qBAAI;QAAO;QACrE,YAAY,gBAAgB,CAAC,MAAM,UAAU;IAC/C,GAAG,EAAE;IACL,IAAI,uBAAuB,CAAA,GAAA,kBAAU,EAAE,CAAC,aAAa,MAAM,UAAU;YAC1D;QAAT,IAAI,KAAK,EAAA,+BAAA,gBAAgB,OAAO,CAAC,GAAG,CAAC,uBAA5B,mDAAA,6BAAuC,EAAE,KAAI;QACtD,YAAY,mBAAmB,CAAC,MAAM,IAAI;QAC1C,gBAAgB,OAAO,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE;IACL,IAAI,2BAA2B,CAAA,GAAA,kBAAU,EAAE;QACzC,gBAAgB,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO;YACtC,qBAAqB,MAAM,WAAW,EAAE,MAAM,IAAI,EAAE,KAAK,MAAM,OAAO;QACxE;IACF,GAAG;QAAC;KAAqB;IAEzB,4CAA4C;IAC5C,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;IACT,GAAG;QAAC;KAAyB;IAE7B,OAAO;2BAAC;8BAAmB;kCAAsB;IAAwB;AAC3E","sources":["packages/@react-aria/utils/src/useGlobalListeners.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 {useCallback, useEffect, useRef} from 'react';\n\ninterface GlobalListeners {\n addGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void,\n addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void,\n removeGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void,\n removeGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void,\n removeAllGlobalListeners(): void\n}\n\nexport function useGlobalListeners(): GlobalListeners {\n let globalListeners = useRef(new Map());\n let addGlobalListener = useCallback((eventTarget, type, listener, options) => {\n // Make sure we remove the listener after it is called with the `once` option.\n let fn = options?.once ? (...args) => {\n globalListeners.current.delete(listener);\n listener(...args);\n } : listener;\n globalListeners.current.set(listener, {type, eventTarget, fn, options});\n eventTarget.addEventListener(type, listener, options);\n }, []);\n let removeGlobalListener = useCallback((eventTarget, type, listener, options) => {\n let fn = globalListeners.current.get(listener)?.fn || listener;\n eventTarget.removeEventListener(type, fn, options);\n globalListeners.current.delete(listener);\n }, []);\n let removeAllGlobalListeners = useCallback(() => {\n globalListeners.current.forEach((value, key) => {\n removeGlobalListener(value.eventTarget, value.type, key, value.options);\n });\n }, [removeGlobalListener]);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return removeAllGlobalListeners;\n }, [removeAllGlobalListeners]);\n\n return {addGlobalListener, removeGlobalListener, removeAllGlobalListeners};\n}\n"],"names":[],"version":3,"file":"useGlobalListeners.module.js.map"}
@@ -0,0 +1,93 @@
1
+ var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
2
+ var $19a2307bfabafaf1$exports = require("./useValueEffect.main.js");
3
+ var $dG5aF$react = require("react");
4
+ var $dG5aF$reactariassr = require("@react-aria/ssr");
5
+
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+
11
+ $parcel$export(module.exports, "useId", () => $8c61827343eed941$export$f680877a34711e37);
12
+ $parcel$export(module.exports, "mergeIds", () => $8c61827343eed941$export$cd8c9cb68f842629);
13
+ $parcel$export(module.exports, "useSlotId", () => $8c61827343eed941$export$b4cc09c592e8fdb8);
14
+ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+
27
+
28
+ // copied from SSRProvider.tsx to reduce exports, if needed again, consider sharing
29
+ let $8c61827343eed941$var$canUseDOM = Boolean(typeof window !== "undefined" && window.document && window.document.createElement);
30
+ let $8c61827343eed941$var$idsUpdaterMap = new Map();
31
+ function $8c61827343eed941$export$f680877a34711e37(defaultId) {
32
+ let [value, setValue] = (0, $dG5aF$react.useState)(defaultId);
33
+ let nextId = (0, $dG5aF$react.useRef)(null);
34
+ let res = (0, $dG5aF$reactariassr.useSSRSafeId)(value);
35
+ let updateValue = (0, $dG5aF$react.useCallback)((val)=>{
36
+ nextId.current = val;
37
+ }, []);
38
+ if ($8c61827343eed941$var$canUseDOM) $8c61827343eed941$var$idsUpdaterMap.set(res, updateValue);
39
+ (0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
40
+ let r = res;
41
+ return ()=>{
42
+ $8c61827343eed941$var$idsUpdaterMap.delete(r);
43
+ };
44
+ }, [
45
+ res
46
+ ]);
47
+ // This cannot cause an infinite loop because the ref is updated first.
48
+ // eslint-disable-next-line
49
+ (0, $dG5aF$react.useEffect)(()=>{
50
+ let newId = nextId.current;
51
+ if (newId) {
52
+ nextId.current = null;
53
+ setValue(newId);
54
+ }
55
+ });
56
+ return res;
57
+ }
58
+ function $8c61827343eed941$export$cd8c9cb68f842629(idA, idB) {
59
+ if (idA === idB) return idA;
60
+ let setIdA = $8c61827343eed941$var$idsUpdaterMap.get(idA);
61
+ if (setIdA) {
62
+ setIdA(idB);
63
+ return idB;
64
+ }
65
+ let setIdB = $8c61827343eed941$var$idsUpdaterMap.get(idB);
66
+ if (setIdB) {
67
+ setIdB(idA);
68
+ return idA;
69
+ }
70
+ return idB;
71
+ }
72
+ function $8c61827343eed941$export$b4cc09c592e8fdb8(depArray = []) {
73
+ let id = $8c61827343eed941$export$f680877a34711e37();
74
+ let [resolvedId, setResolvedId] = (0, $19a2307bfabafaf1$exports.useValueEffect)(id);
75
+ let updateId = (0, $dG5aF$react.useCallback)(()=>{
76
+ setResolvedId(function*() {
77
+ yield id;
78
+ yield document.getElementById(id) ? id : undefined;
79
+ });
80
+ }, [
81
+ id,
82
+ setResolvedId
83
+ ]);
84
+ (0, $78605a5d7424e31b$exports.useLayoutEffect)(updateId, [
85
+ id,
86
+ updateId,
87
+ ...depArray
88
+ ]);
89
+ return resolvedId;
90
+ }
91
+
92
+
93
+ //# sourceMappingURL=useId.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAOD,mFAAmF;AACnF,IAAI,kCAAY,QACd,OAAO,WAAW,eAClB,OAAO,QAAQ,IACf,OAAO,QAAQ,CAAC,aAAa;AAG/B,IAAI,sCAAkD,IAAI;AAMnD,SAAS,0CAAM,SAAkB;IACtC,IAAI,CAAC,OAAO,SAAS,GAAG,CAAA,GAAA,qBAAO,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,mBAAK,EAAE;IAEpB,IAAI,MAAM,CAAA,GAAA,gCAAW,EAAE;IAEvB,IAAI,cAAc,CAAA,GAAA,wBAAU,EAAE,CAAC;QAC7B,OAAO,OAAO,GAAG;IACnB,GAAG,EAAE;IAEL,IAAI,iCACF,oCAAc,GAAG,CAAC,KAAK;IAGzB,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,IAAI;QACR,OAAO;YACL,oCAAc,MAAM,CAAC;QACvB;IACF,GAAG;QAAC;KAAI;IAER,uEAAuE;IACvE,2BAA2B;IAC3B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,QAAQ,OAAO,OAAO;QAC1B,IAAI,OAAO;YACT,OAAO,OAAO,GAAG;YACjB,SAAS;QACX;IACF;IAEA,OAAO;AACT;AAMO,SAAS,0CAAS,GAAW,EAAE,GAAW;IAC/C,IAAI,QAAQ,KACV,OAAO;IAGT,IAAI,SAAS,oCAAc,GAAG,CAAC;IAC/B,IAAI,QAAQ;QACV,OAAO;QACP,OAAO;IACT;IAEA,IAAI,SAAS,oCAAc,GAAG,CAAC;IAC/B,IAAI,QAAQ;QACV,OAAO;QACP,OAAO;IACT;IAEA,OAAO;AACT;AAOO,SAAS,0CAAU,WAA+B,EAAE;IACzD,IAAI,KAAK;IACT,IAAI,CAAC,YAAY,cAAc,GAAG,CAAA,GAAA,wCAAa,EAAE;IACjD,IAAI,WAAW,CAAA,GAAA,wBAAU,EAAE;QACzB,cAAc;YACZ,MAAM;YAEN,MAAM,SAAS,cAAc,CAAC,MAAM,KAAK;QAC3C;IACF,GAAG;QAAC;QAAI;KAAc;IAEtB,CAAA,GAAA,yCAAc,EAAE,UAAU;QAAC;QAAI;WAAa;KAAS;IAErD,OAAO;AACT","sources":["packages/@react-aria/utils/src/useId.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 {useCallback, useEffect, useRef, useState} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\nimport {useSSRSafeId} from '@react-aria/ssr';\nimport {useValueEffect} from './';\n\n// copied from SSRProvider.tsx to reduce exports, if needed again, consider sharing\nlet canUseDOM = Boolean(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\nlet idsUpdaterMap: Map<string, (v: string) => void> = new Map();\n\n/**\n * If a default is not provided, generate an id.\n * @param defaultId - Default component id.\n */\nexport function useId(defaultId?: string): string {\n let [value, setValue] = useState(defaultId);\n let nextId = useRef(null);\n\n let res = useSSRSafeId(value);\n\n let updateValue = useCallback((val) => {\n nextId.current = val;\n }, []);\n\n if (canUseDOM) {\n idsUpdaterMap.set(res, updateValue);\n }\n\n useLayoutEffect(() => {\n let r = res;\n return () => {\n idsUpdaterMap.delete(r);\n };\n }, [res]);\n\n // This cannot cause an infinite loop because the ref is updated first.\n // eslint-disable-next-line\n useEffect(() => {\n let newId = nextId.current;\n if (newId) {\n nextId.current = null;\n setValue(newId);\n }\n });\n\n return res;\n}\n\n/**\n * Merges two ids.\n * Different ids will trigger a side-effect and re-render components hooked up with `useId`.\n */\nexport function mergeIds(idA: string, idB: string): string {\n if (idA === idB) {\n return idA;\n }\n\n let setIdA = idsUpdaterMap.get(idA);\n if (setIdA) {\n setIdA(idB);\n return idB;\n }\n\n let setIdB = idsUpdaterMap.get(idB);\n if (setIdB) {\n setIdB(idA);\n return idA;\n }\n\n return idB;\n}\n\n/**\n * Used to generate an id, and after render, check if that id is rendered so we know\n * if we can use it in places such as labelledby.\n * @param depArray - When to recalculate if the id is in the DOM.\n */\nexport function useSlotId(depArray: ReadonlyArray<any> = []): string {\n let id = useId();\n let [resolvedId, setResolvedId] = useValueEffect(id);\n let updateId = useCallback(() => {\n setResolvedId(function *() {\n yield id;\n\n yield document.getElementById(id) ? id : undefined;\n });\n }, [id, setResolvedId]);\n\n useLayoutEffect(updateId, [id, updateId, ...depArray]);\n\n return resolvedId;\n}\n"],"names":[],"version":3,"file":"useId.main.js.map"}