@react-stately/tooltip 3.4.8-nightly.4552 → 3.4.8-nightly.4558

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.
package/dist/import.mjs CHANGED
@@ -1,17 +1,6 @@
1
- import {useMemo as $1OhDq$useMemo, useRef as $1OhDq$useRef, useEffect as $1OhDq$useEffect} from "react";
2
- import {useOverlayTriggerState as $1OhDq$useOverlayTriggerState} from "@react-stately/overlays";
1
+ import {useTooltipTriggerState as $8796f90736e175cb$export$4d40659c25ecb50b} from "./useTooltipTriggerState.mjs";
3
2
 
4
3
  /*
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
4
  * Copyright 2020 Adobe. All rights reserved.
16
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -23,97 +12,6 @@ import {useOverlayTriggerState as $1OhDq$useOverlayTriggerState} from "@react-st
23
12
  * governing permissions and limitations under the License.
24
13
  */
25
14
 
26
- const $8796f90736e175cb$var$TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design
27
- const $8796f90736e175cb$var$TOOLTIP_COOLDOWN = 500;
28
- let $8796f90736e175cb$var$tooltips = {};
29
- let $8796f90736e175cb$var$tooltipId = 0;
30
- let $8796f90736e175cb$var$globalWarmedUp = false;
31
- let $8796f90736e175cb$var$globalWarmUpTimeout = null;
32
- let $8796f90736e175cb$var$globalCooldownTimeout = null;
33
- function $8796f90736e175cb$export$4d40659c25ecb50b(props = {}) {
34
- let { delay: delay = $8796f90736e175cb$var$TOOLTIP_DELAY, closeDelay: closeDelay = $8796f90736e175cb$var$TOOLTIP_COOLDOWN } = props;
35
- let { isOpen: isOpen, open: open, close: close } = (0, $1OhDq$useOverlayTriggerState)(props);
36
- let id = (0, $1OhDq$useMemo)(()=>`${++$8796f90736e175cb$var$tooltipId}`, []);
37
- let closeTimeout = (0, $1OhDq$useRef)();
38
- let ensureTooltipEntry = ()=>{
39
- $8796f90736e175cb$var$tooltips[id] = hideTooltip;
40
- };
41
- let closeOpenTooltips = ()=>{
42
- for(let hideTooltipId in $8796f90736e175cb$var$tooltips)if (hideTooltipId !== id) {
43
- $8796f90736e175cb$var$tooltips[hideTooltipId](true);
44
- delete $8796f90736e175cb$var$tooltips[hideTooltipId];
45
- }
46
- };
47
- let showTooltip = ()=>{
48
- clearTimeout(closeTimeout.current);
49
- closeTimeout.current = null;
50
- closeOpenTooltips();
51
- ensureTooltipEntry();
52
- $8796f90736e175cb$var$globalWarmedUp = true;
53
- open();
54
- if ($8796f90736e175cb$var$globalWarmUpTimeout) {
55
- clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
56
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
57
- }
58
- if ($8796f90736e175cb$var$globalCooldownTimeout) {
59
- clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
60
- $8796f90736e175cb$var$globalCooldownTimeout = null;
61
- }
62
- };
63
- let hideTooltip = (immediate)=>{
64
- if (immediate || closeDelay <= 0) {
65
- clearTimeout(closeTimeout.current);
66
- closeTimeout.current = null;
67
- close();
68
- } else if (!closeTimeout.current) closeTimeout.current = setTimeout(()=>{
69
- closeTimeout.current = null;
70
- close();
71
- }, closeDelay);
72
- if ($8796f90736e175cb$var$globalWarmUpTimeout) {
73
- clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
74
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
75
- }
76
- if ($8796f90736e175cb$var$globalWarmedUp) {
77
- if ($8796f90736e175cb$var$globalCooldownTimeout) clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
78
- $8796f90736e175cb$var$globalCooldownTimeout = setTimeout(()=>{
79
- delete $8796f90736e175cb$var$tooltips[id];
80
- $8796f90736e175cb$var$globalCooldownTimeout = null;
81
- $8796f90736e175cb$var$globalWarmedUp = false;
82
- }, Math.max($8796f90736e175cb$var$TOOLTIP_COOLDOWN, closeDelay));
83
- }
84
- };
85
- let warmupTooltip = ()=>{
86
- closeOpenTooltips();
87
- ensureTooltipEntry();
88
- if (!isOpen && !$8796f90736e175cb$var$globalWarmUpTimeout && !$8796f90736e175cb$var$globalWarmedUp) $8796f90736e175cb$var$globalWarmUpTimeout = setTimeout(()=>{
89
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
90
- $8796f90736e175cb$var$globalWarmedUp = true;
91
- showTooltip();
92
- }, delay);
93
- else if (!isOpen) showTooltip();
94
- };
95
- // eslint-disable-next-line arrow-body-style
96
- (0, $1OhDq$useEffect)(()=>{
97
- return ()=>{
98
- clearTimeout(closeTimeout.current);
99
- let tooltip = $8796f90736e175cb$var$tooltips[id];
100
- if (tooltip) delete $8796f90736e175cb$var$tooltips[id];
101
- };
102
- }, [
103
- id
104
- ]);
105
- return {
106
- isOpen: isOpen,
107
- open: (immediate)=>{
108
- if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
109
- else showTooltip();
110
- },
111
- close: hideTooltip
112
- };
113
- }
114
-
115
-
116
-
117
15
 
118
16
  export {$8796f90736e175cb$export$4d40659c25ecb50b as useTooltipTriggerState};
119
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,23 +1,12 @@
1
- var $8aPAr$react = require("react");
2
- var $8aPAr$reactstatelyoverlays = require("@react-stately/overlays");
1
+ var $3391baedd777a697$exports = require("./useTooltipTriggerState.main.js");
3
2
 
4
3
 
5
4
  function $parcel$export(e, n, v, s) {
6
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
6
  }
8
7
 
9
- $parcel$export(module.exports, "useTooltipTriggerState", () => $3391baedd777a697$export$4d40659c25ecb50b);
8
+ $parcel$export(module.exports, "useTooltipTriggerState", () => $3391baedd777a697$exports.useTooltipTriggerState);
10
9
  /*
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
10
  * Copyright 2020 Adobe. All rights reserved.
22
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
12
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -29,96 +18,5 @@ $parcel$export(module.exports, "useTooltipTriggerState", () => $3391baedd777a697
29
18
  * governing permissions and limitations under the License.
30
19
  */
31
20
 
32
- const $3391baedd777a697$var$TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design
33
- const $3391baedd777a697$var$TOOLTIP_COOLDOWN = 500;
34
- let $3391baedd777a697$var$tooltips = {};
35
- let $3391baedd777a697$var$tooltipId = 0;
36
- let $3391baedd777a697$var$globalWarmedUp = false;
37
- let $3391baedd777a697$var$globalWarmUpTimeout = null;
38
- let $3391baedd777a697$var$globalCooldownTimeout = null;
39
- function $3391baedd777a697$export$4d40659c25ecb50b(props = {}) {
40
- let { delay: delay = $3391baedd777a697$var$TOOLTIP_DELAY, closeDelay: closeDelay = $3391baedd777a697$var$TOOLTIP_COOLDOWN } = props;
41
- let { isOpen: isOpen, open: open, close: close } = (0, $8aPAr$reactstatelyoverlays.useOverlayTriggerState)(props);
42
- let id = (0, $8aPAr$react.useMemo)(()=>`${++$3391baedd777a697$var$tooltipId}`, []);
43
- let closeTimeout = (0, $8aPAr$react.useRef)();
44
- let ensureTooltipEntry = ()=>{
45
- $3391baedd777a697$var$tooltips[id] = hideTooltip;
46
- };
47
- let closeOpenTooltips = ()=>{
48
- for(let hideTooltipId in $3391baedd777a697$var$tooltips)if (hideTooltipId !== id) {
49
- $3391baedd777a697$var$tooltips[hideTooltipId](true);
50
- delete $3391baedd777a697$var$tooltips[hideTooltipId];
51
- }
52
- };
53
- let showTooltip = ()=>{
54
- clearTimeout(closeTimeout.current);
55
- closeTimeout.current = null;
56
- closeOpenTooltips();
57
- ensureTooltipEntry();
58
- $3391baedd777a697$var$globalWarmedUp = true;
59
- open();
60
- if ($3391baedd777a697$var$globalWarmUpTimeout) {
61
- clearTimeout($3391baedd777a697$var$globalWarmUpTimeout);
62
- $3391baedd777a697$var$globalWarmUpTimeout = null;
63
- }
64
- if ($3391baedd777a697$var$globalCooldownTimeout) {
65
- clearTimeout($3391baedd777a697$var$globalCooldownTimeout);
66
- $3391baedd777a697$var$globalCooldownTimeout = null;
67
- }
68
- };
69
- let hideTooltip = (immediate)=>{
70
- if (immediate || closeDelay <= 0) {
71
- clearTimeout(closeTimeout.current);
72
- closeTimeout.current = null;
73
- close();
74
- } else if (!closeTimeout.current) closeTimeout.current = setTimeout(()=>{
75
- closeTimeout.current = null;
76
- close();
77
- }, closeDelay);
78
- if ($3391baedd777a697$var$globalWarmUpTimeout) {
79
- clearTimeout($3391baedd777a697$var$globalWarmUpTimeout);
80
- $3391baedd777a697$var$globalWarmUpTimeout = null;
81
- }
82
- if ($3391baedd777a697$var$globalWarmedUp) {
83
- if ($3391baedd777a697$var$globalCooldownTimeout) clearTimeout($3391baedd777a697$var$globalCooldownTimeout);
84
- $3391baedd777a697$var$globalCooldownTimeout = setTimeout(()=>{
85
- delete $3391baedd777a697$var$tooltips[id];
86
- $3391baedd777a697$var$globalCooldownTimeout = null;
87
- $3391baedd777a697$var$globalWarmedUp = false;
88
- }, Math.max($3391baedd777a697$var$TOOLTIP_COOLDOWN, closeDelay));
89
- }
90
- };
91
- let warmupTooltip = ()=>{
92
- closeOpenTooltips();
93
- ensureTooltipEntry();
94
- if (!isOpen && !$3391baedd777a697$var$globalWarmUpTimeout && !$3391baedd777a697$var$globalWarmedUp) $3391baedd777a697$var$globalWarmUpTimeout = setTimeout(()=>{
95
- $3391baedd777a697$var$globalWarmUpTimeout = null;
96
- $3391baedd777a697$var$globalWarmedUp = true;
97
- showTooltip();
98
- }, delay);
99
- else if (!isOpen) showTooltip();
100
- };
101
- // eslint-disable-next-line arrow-body-style
102
- (0, $8aPAr$react.useEffect)(()=>{
103
- return ()=>{
104
- clearTimeout(closeTimeout.current);
105
- let tooltip = $3391baedd777a697$var$tooltips[id];
106
- if (tooltip) delete $3391baedd777a697$var$tooltips[id];
107
- };
108
- }, [
109
- id
110
- ]);
111
- return {
112
- isOpen: isOpen,
113
- open: (immediate)=>{
114
- if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
115
- else showTooltip();
116
- },
117
- close: hideTooltip
118
- };
119
- }
120
-
121
-
122
-
123
21
 
124
22
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAMD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAezB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAAsB;AAC1B,IAAI,8CAAwB;AAOrB,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,kDAAqB,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,oBAAM,EAAE,IAAM,CAAC,EAAE,EAAE,gCAAU,CAAC,EAAE,EAAE;IAC3C,IAAI,eAAe,CAAA,GAAA,mBAAK;IAExB,IAAI,qBAAqB;QACvB,8BAAQ,CAAC,GAAG,GAAG;IACjB;IAEA,IAAI,oBAAoB;QACtB,IAAK,IAAI,iBAAiB,+BACxB,IAAI,kBAAkB,IAAI;YACxB,8BAAQ,CAAC,cAAc,CAAC;YACxB,OAAO,8BAAQ,CAAC,cAAc;QAChC;IAEJ;IAEA,IAAI,cAAc;QAChB,aAAa,aAAa,OAAO;QACjC,aAAa,OAAO,GAAG;QACvB;QACA;QACA,uCAAiB;QACjB;QACA,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,6CAAuB;YACzB,aAAa;YACb,8CAAwB;QAC1B;IACF;IAEA,IAAI,cAAc,CAAC;QACjB,IAAI,aAAa,cAAc,GAAG;YAChC,aAAa,aAAa,OAAO;YACjC,aAAa,OAAO,GAAG;YACvB;QACF,OAAO,IAAI,CAAC,aAAa,OAAO,EAC9B,aAAa,OAAO,GAAG,WAAW;YAChC,aAAa,OAAO,GAAG;YACvB;QACF,GAAG;QAGL,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,sCAAgB;YAClB,IAAI,6CACF,aAAa;YAEf,8CAAwB,WAAW;gBACjC,OAAO,8BAAQ,CAAC,GAAG;gBACnB,8CAAwB;gBACxB,uCAAiB;YACnB,GAAG,KAAK,GAAG,CAAC,wCAAkB;QAChC;IACF;IAEA,IAAI,gBAAgB;QAClB;QACA;QACA,IAAI,CAAC,UAAU,CAAC,6CAAuB,CAAC,sCACtC,4CAAsB,WAAW;YAC/B,4CAAsB;YACtB,uCAAiB;YACjB;QACF,GAAG;aACE,IAAI,CAAC,QACV;IAEJ;IAEA,4CAA4C;IAC5C,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,aAAa,aAAa,OAAO;YACjC,IAAI,UAAU,8BAAQ,CAAC,GAAG;YAC1B,IAAI,SACF,OAAO,8BAAQ,CAAC,GAAG;QAEvB;IACF,GAAG;QAAC;KAAG;IAEP,OAAO;gBACL;QACA,MAAM,CAAC;YACL,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA;QAEJ;QACA,OAAO;IACT;AACF;;CDrIC","sources":["packages/@react-stately/tooltip/src/index.ts","packages/@react-stately/tooltip/src/useTooltipTriggerState.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\nexport {useTooltipTriggerState} from './useTooltipTriggerState';\n\nexport type {TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipTriggerState} from './useTooltipTriggerState';\n","/*\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 {TooltipTriggerProps} from '@react-types/tooltip';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useOverlayTriggerState} from '@react-stately/overlays';\n\nconst TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n isOpen: boolean,\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void,\n /** Hides the tooltip. */\n close(immediate?: boolean): void\n}\n\nlet tooltips = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout = null;\nlet globalCooldownTimeout = null;\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function useTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n let {delay = TOOLTIP_DELAY, closeDelay = TOOLTIP_COOLDOWN} = props;\n let {isOpen, open, close} = useOverlayTriggerState(props);\n let id = useMemo(() => `${++tooltipId}`, []);\n let closeTimeout = useRef<ReturnType<typeof setTimeout>>();\n\n let ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n let closeOpenTooltips = () => {\n for (let hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n tooltips[hideTooltipId](true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n let showTooltip = () => {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n closeOpenTooltips();\n ensureTooltipEntry();\n globalWarmedUp = true;\n open();\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n let hideTooltip = (immediate?: boolean) => {\n if (immediate || closeDelay <= 0) {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n close();\n } else if (!closeTimeout.current) {\n closeTimeout.current = setTimeout(() => {\n closeTimeout.current = null;\n close();\n }, closeDelay);\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(() => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n }, Math.max(TOOLTIP_COOLDOWN, closeDelay));\n }\n };\n\n let warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n if (!isOpen && !globalWarmUpTimeout && !globalWarmedUp) {\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n showTooltip();\n }, delay);\n } else if (!isOpen) {\n showTooltip();\n }\n };\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(closeTimeout.current);\n let tooltip = tooltips[id];\n if (tooltip) {\n delete tooltips[id];\n }\n };\n }, [id]);\n\n return {\n isOpen,\n open: (immediate) => {\n if (!immediate && delay > 0 && !closeTimeout.current) {\n warmupTooltip();\n } else {\n showTooltip();\n }\n },\n close: hideTooltip\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/tooltip/src/index.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\nexport {useTooltipTriggerState} from './useTooltipTriggerState';\n\nexport type {TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipTriggerState} from './useTooltipTriggerState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,17 +1,6 @@
1
- import {useMemo as $1OhDq$useMemo, useRef as $1OhDq$useRef, useEffect as $1OhDq$useEffect} from "react";
2
- import {useOverlayTriggerState as $1OhDq$useOverlayTriggerState} from "@react-stately/overlays";
1
+ import {useTooltipTriggerState as $8796f90736e175cb$export$4d40659c25ecb50b} from "./useTooltipTriggerState.module.js";
3
2
 
4
3
  /*
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
4
  * Copyright 2020 Adobe. All rights reserved.
16
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -23,97 +12,6 @@ import {useOverlayTriggerState as $1OhDq$useOverlayTriggerState} from "@react-st
23
12
  * governing permissions and limitations under the License.
24
13
  */
25
14
 
26
- const $8796f90736e175cb$var$TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design
27
- const $8796f90736e175cb$var$TOOLTIP_COOLDOWN = 500;
28
- let $8796f90736e175cb$var$tooltips = {};
29
- let $8796f90736e175cb$var$tooltipId = 0;
30
- let $8796f90736e175cb$var$globalWarmedUp = false;
31
- let $8796f90736e175cb$var$globalWarmUpTimeout = null;
32
- let $8796f90736e175cb$var$globalCooldownTimeout = null;
33
- function $8796f90736e175cb$export$4d40659c25ecb50b(props = {}) {
34
- let { delay: delay = $8796f90736e175cb$var$TOOLTIP_DELAY, closeDelay: closeDelay = $8796f90736e175cb$var$TOOLTIP_COOLDOWN } = props;
35
- let { isOpen: isOpen, open: open, close: close } = (0, $1OhDq$useOverlayTriggerState)(props);
36
- let id = (0, $1OhDq$useMemo)(()=>`${++$8796f90736e175cb$var$tooltipId}`, []);
37
- let closeTimeout = (0, $1OhDq$useRef)();
38
- let ensureTooltipEntry = ()=>{
39
- $8796f90736e175cb$var$tooltips[id] = hideTooltip;
40
- };
41
- let closeOpenTooltips = ()=>{
42
- for(let hideTooltipId in $8796f90736e175cb$var$tooltips)if (hideTooltipId !== id) {
43
- $8796f90736e175cb$var$tooltips[hideTooltipId](true);
44
- delete $8796f90736e175cb$var$tooltips[hideTooltipId];
45
- }
46
- };
47
- let showTooltip = ()=>{
48
- clearTimeout(closeTimeout.current);
49
- closeTimeout.current = null;
50
- closeOpenTooltips();
51
- ensureTooltipEntry();
52
- $8796f90736e175cb$var$globalWarmedUp = true;
53
- open();
54
- if ($8796f90736e175cb$var$globalWarmUpTimeout) {
55
- clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
56
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
57
- }
58
- if ($8796f90736e175cb$var$globalCooldownTimeout) {
59
- clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
60
- $8796f90736e175cb$var$globalCooldownTimeout = null;
61
- }
62
- };
63
- let hideTooltip = (immediate)=>{
64
- if (immediate || closeDelay <= 0) {
65
- clearTimeout(closeTimeout.current);
66
- closeTimeout.current = null;
67
- close();
68
- } else if (!closeTimeout.current) closeTimeout.current = setTimeout(()=>{
69
- closeTimeout.current = null;
70
- close();
71
- }, closeDelay);
72
- if ($8796f90736e175cb$var$globalWarmUpTimeout) {
73
- clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
74
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
75
- }
76
- if ($8796f90736e175cb$var$globalWarmedUp) {
77
- if ($8796f90736e175cb$var$globalCooldownTimeout) clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
78
- $8796f90736e175cb$var$globalCooldownTimeout = setTimeout(()=>{
79
- delete $8796f90736e175cb$var$tooltips[id];
80
- $8796f90736e175cb$var$globalCooldownTimeout = null;
81
- $8796f90736e175cb$var$globalWarmedUp = false;
82
- }, Math.max($8796f90736e175cb$var$TOOLTIP_COOLDOWN, closeDelay));
83
- }
84
- };
85
- let warmupTooltip = ()=>{
86
- closeOpenTooltips();
87
- ensureTooltipEntry();
88
- if (!isOpen && !$8796f90736e175cb$var$globalWarmUpTimeout && !$8796f90736e175cb$var$globalWarmedUp) $8796f90736e175cb$var$globalWarmUpTimeout = setTimeout(()=>{
89
- $8796f90736e175cb$var$globalWarmUpTimeout = null;
90
- $8796f90736e175cb$var$globalWarmedUp = true;
91
- showTooltip();
92
- }, delay);
93
- else if (!isOpen) showTooltip();
94
- };
95
- // eslint-disable-next-line arrow-body-style
96
- (0, $1OhDq$useEffect)(()=>{
97
- return ()=>{
98
- clearTimeout(closeTimeout.current);
99
- let tooltip = $8796f90736e175cb$var$tooltips[id];
100
- if (tooltip) delete $8796f90736e175cb$var$tooltips[id];
101
- };
102
- }, [
103
- id
104
- ]);
105
- return {
106
- isOpen: isOpen,
107
- open: (immediate)=>{
108
- if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
109
- else showTooltip();
110
- },
111
- close: hideTooltip
112
- };
113
- }
114
-
115
-
116
-
117
15
 
118
16
  export {$8796f90736e175cb$export$4d40659c25ecb50b as useTooltipTriggerState};
119
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAMD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAezB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAAsB;AAC1B,IAAI,8CAAwB;AAOrB,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,6BAAqB,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,cAAM,EAAE,IAAM,CAAC,EAAE,EAAE,gCAAU,CAAC,EAAE,EAAE;IAC3C,IAAI,eAAe,CAAA,GAAA,aAAK;IAExB,IAAI,qBAAqB;QACvB,8BAAQ,CAAC,GAAG,GAAG;IACjB;IAEA,IAAI,oBAAoB;QACtB,IAAK,IAAI,iBAAiB,+BACxB,IAAI,kBAAkB,IAAI;YACxB,8BAAQ,CAAC,cAAc,CAAC;YACxB,OAAO,8BAAQ,CAAC,cAAc;QAChC;IAEJ;IAEA,IAAI,cAAc;QAChB,aAAa,aAAa,OAAO;QACjC,aAAa,OAAO,GAAG;QACvB;QACA;QACA,uCAAiB;QACjB;QACA,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,6CAAuB;YACzB,aAAa;YACb,8CAAwB;QAC1B;IACF;IAEA,IAAI,cAAc,CAAC;QACjB,IAAI,aAAa,cAAc,GAAG;YAChC,aAAa,aAAa,OAAO;YACjC,aAAa,OAAO,GAAG;YACvB;QACF,OAAO,IAAI,CAAC,aAAa,OAAO,EAC9B,aAAa,OAAO,GAAG,WAAW;YAChC,aAAa,OAAO,GAAG;YACvB;QACF,GAAG;QAGL,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,sCAAgB;YAClB,IAAI,6CACF,aAAa;YAEf,8CAAwB,WAAW;gBACjC,OAAO,8BAAQ,CAAC,GAAG;gBACnB,8CAAwB;gBACxB,uCAAiB;YACnB,GAAG,KAAK,GAAG,CAAC,wCAAkB;QAChC;IACF;IAEA,IAAI,gBAAgB;QAClB;QACA;QACA,IAAI,CAAC,UAAU,CAAC,6CAAuB,CAAC,sCACtC,4CAAsB,WAAW;YAC/B,4CAAsB;YACtB,uCAAiB;YACjB;QACF,GAAG;aACE,IAAI,CAAC,QACV;IAEJ;IAEA,4CAA4C;IAC5C,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,aAAa,aAAa,OAAO;YACjC,IAAI,UAAU,8BAAQ,CAAC,GAAG;YAC1B,IAAI,SACF,OAAO,8BAAQ,CAAC,GAAG;QAEvB;IACF,GAAG;QAAC;KAAG;IAEP,OAAO;gBACL;QACA,MAAM,CAAC;YACL,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA;QAEJ;QACA,OAAO;IACT;AACF;;CDrIC","sources":["packages/@react-stately/tooltip/src/index.ts","packages/@react-stately/tooltip/src/useTooltipTriggerState.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\nexport {useTooltipTriggerState} from './useTooltipTriggerState';\n\nexport type {TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipTriggerState} from './useTooltipTriggerState';\n","/*\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 {TooltipTriggerProps} from '@react-types/tooltip';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useOverlayTriggerState} from '@react-stately/overlays';\n\nconst TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n isOpen: boolean,\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void,\n /** Hides the tooltip. */\n close(immediate?: boolean): void\n}\n\nlet tooltips = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout = null;\nlet globalCooldownTimeout = null;\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function useTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n let {delay = TOOLTIP_DELAY, closeDelay = TOOLTIP_COOLDOWN} = props;\n let {isOpen, open, close} = useOverlayTriggerState(props);\n let id = useMemo(() => `${++tooltipId}`, []);\n let closeTimeout = useRef<ReturnType<typeof setTimeout>>();\n\n let ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n let closeOpenTooltips = () => {\n for (let hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n tooltips[hideTooltipId](true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n let showTooltip = () => {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n closeOpenTooltips();\n ensureTooltipEntry();\n globalWarmedUp = true;\n open();\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n let hideTooltip = (immediate?: boolean) => {\n if (immediate || closeDelay <= 0) {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n close();\n } else if (!closeTimeout.current) {\n closeTimeout.current = setTimeout(() => {\n closeTimeout.current = null;\n close();\n }, closeDelay);\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(() => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n }, Math.max(TOOLTIP_COOLDOWN, closeDelay));\n }\n };\n\n let warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n if (!isOpen && !globalWarmUpTimeout && !globalWarmedUp) {\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n showTooltip();\n }, delay);\n } else if (!isOpen) {\n showTooltip();\n }\n };\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(closeTimeout.current);\n let tooltip = tooltips[id];\n if (tooltip) {\n delete tooltips[id];\n }\n };\n }, [id]);\n\n return {\n isOpen,\n open: (immediate) => {\n if (!immediate && delay > 0 && !closeTimeout.current) {\n warmupTooltip();\n } else {\n showTooltip();\n }\n },\n close: hideTooltip\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/tooltip/src/index.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\nexport {useTooltipTriggerState} from './useTooltipTriggerState';\n\nexport type {TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipTriggerState} from './useTooltipTriggerState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,112 @@
1
+ var $w0mn6$react = require("react");
2
+ var $w0mn6$reactstatelyoverlays = require("@react-stately/overlays");
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, "useTooltipTriggerState", () => $3391baedd777a697$export$4d40659c25ecb50b);
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
+ const $3391baedd777a697$var$TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design
23
+ const $3391baedd777a697$var$TOOLTIP_COOLDOWN = 500;
24
+ let $3391baedd777a697$var$tooltips = {};
25
+ let $3391baedd777a697$var$tooltipId = 0;
26
+ let $3391baedd777a697$var$globalWarmedUp = false;
27
+ let $3391baedd777a697$var$globalWarmUpTimeout = null;
28
+ let $3391baedd777a697$var$globalCooldownTimeout = null;
29
+ function $3391baedd777a697$export$4d40659c25ecb50b(props = {}) {
30
+ let { delay: delay = $3391baedd777a697$var$TOOLTIP_DELAY, closeDelay: closeDelay = $3391baedd777a697$var$TOOLTIP_COOLDOWN } = props;
31
+ let { isOpen: isOpen, open: open, close: close } = (0, $w0mn6$reactstatelyoverlays.useOverlayTriggerState)(props);
32
+ let id = (0, $w0mn6$react.useMemo)(()=>`${++$3391baedd777a697$var$tooltipId}`, []);
33
+ let closeTimeout = (0, $w0mn6$react.useRef)();
34
+ let ensureTooltipEntry = ()=>{
35
+ $3391baedd777a697$var$tooltips[id] = hideTooltip;
36
+ };
37
+ let closeOpenTooltips = ()=>{
38
+ for(let hideTooltipId in $3391baedd777a697$var$tooltips)if (hideTooltipId !== id) {
39
+ $3391baedd777a697$var$tooltips[hideTooltipId](true);
40
+ delete $3391baedd777a697$var$tooltips[hideTooltipId];
41
+ }
42
+ };
43
+ let showTooltip = ()=>{
44
+ clearTimeout(closeTimeout.current);
45
+ closeTimeout.current = null;
46
+ closeOpenTooltips();
47
+ ensureTooltipEntry();
48
+ $3391baedd777a697$var$globalWarmedUp = true;
49
+ open();
50
+ if ($3391baedd777a697$var$globalWarmUpTimeout) {
51
+ clearTimeout($3391baedd777a697$var$globalWarmUpTimeout);
52
+ $3391baedd777a697$var$globalWarmUpTimeout = null;
53
+ }
54
+ if ($3391baedd777a697$var$globalCooldownTimeout) {
55
+ clearTimeout($3391baedd777a697$var$globalCooldownTimeout);
56
+ $3391baedd777a697$var$globalCooldownTimeout = null;
57
+ }
58
+ };
59
+ let hideTooltip = (immediate)=>{
60
+ if (immediate || closeDelay <= 0) {
61
+ clearTimeout(closeTimeout.current);
62
+ closeTimeout.current = null;
63
+ close();
64
+ } else if (!closeTimeout.current) closeTimeout.current = setTimeout(()=>{
65
+ closeTimeout.current = null;
66
+ close();
67
+ }, closeDelay);
68
+ if ($3391baedd777a697$var$globalWarmUpTimeout) {
69
+ clearTimeout($3391baedd777a697$var$globalWarmUpTimeout);
70
+ $3391baedd777a697$var$globalWarmUpTimeout = null;
71
+ }
72
+ if ($3391baedd777a697$var$globalWarmedUp) {
73
+ if ($3391baedd777a697$var$globalCooldownTimeout) clearTimeout($3391baedd777a697$var$globalCooldownTimeout);
74
+ $3391baedd777a697$var$globalCooldownTimeout = setTimeout(()=>{
75
+ delete $3391baedd777a697$var$tooltips[id];
76
+ $3391baedd777a697$var$globalCooldownTimeout = null;
77
+ $3391baedd777a697$var$globalWarmedUp = false;
78
+ }, Math.max($3391baedd777a697$var$TOOLTIP_COOLDOWN, closeDelay));
79
+ }
80
+ };
81
+ let warmupTooltip = ()=>{
82
+ closeOpenTooltips();
83
+ ensureTooltipEntry();
84
+ if (!isOpen && !$3391baedd777a697$var$globalWarmUpTimeout && !$3391baedd777a697$var$globalWarmedUp) $3391baedd777a697$var$globalWarmUpTimeout = setTimeout(()=>{
85
+ $3391baedd777a697$var$globalWarmUpTimeout = null;
86
+ $3391baedd777a697$var$globalWarmedUp = true;
87
+ showTooltip();
88
+ }, delay);
89
+ else if (!isOpen) showTooltip();
90
+ };
91
+ // eslint-disable-next-line arrow-body-style
92
+ (0, $w0mn6$react.useEffect)(()=>{
93
+ return ()=>{
94
+ clearTimeout(closeTimeout.current);
95
+ let tooltip = $3391baedd777a697$var$tooltips[id];
96
+ if (tooltip) delete $3391baedd777a697$var$tooltips[id];
97
+ };
98
+ }, [
99
+ id
100
+ ]);
101
+ return {
102
+ isOpen: isOpen,
103
+ open: (immediate)=>{
104
+ if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
105
+ else showTooltip();
106
+ },
107
+ close: hideTooltip
108
+ };
109
+ }
110
+
111
+
112
+ //# sourceMappingURL=useTooltipTriggerState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAezB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAAsB;AAC1B,IAAI,8CAAwB;AAOrB,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,kDAAqB,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,oBAAM,EAAE,IAAM,CAAC,EAAE,EAAE,gCAAU,CAAC,EAAE,EAAE;IAC3C,IAAI,eAAe,CAAA,GAAA,mBAAK;IAExB,IAAI,qBAAqB;QACvB,8BAAQ,CAAC,GAAG,GAAG;IACjB;IAEA,IAAI,oBAAoB;QACtB,IAAK,IAAI,iBAAiB,+BACxB,IAAI,kBAAkB,IAAI;YACxB,8BAAQ,CAAC,cAAc,CAAC;YACxB,OAAO,8BAAQ,CAAC,cAAc;QAChC;IAEJ;IAEA,IAAI,cAAc;QAChB,aAAa,aAAa,OAAO;QACjC,aAAa,OAAO,GAAG;QACvB;QACA;QACA,uCAAiB;QACjB;QACA,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,6CAAuB;YACzB,aAAa;YACb,8CAAwB;QAC1B;IACF;IAEA,IAAI,cAAc,CAAC;QACjB,IAAI,aAAa,cAAc,GAAG;YAChC,aAAa,aAAa,OAAO;YACjC,aAAa,OAAO,GAAG;YACvB;QACF,OAAO,IAAI,CAAC,aAAa,OAAO,EAC9B,aAAa,OAAO,GAAG,WAAW;YAChC,aAAa,OAAO,GAAG;YACvB;QACF,GAAG;QAGL,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,sCAAgB;YAClB,IAAI,6CACF,aAAa;YAEf,8CAAwB,WAAW;gBACjC,OAAO,8BAAQ,CAAC,GAAG;gBACnB,8CAAwB;gBACxB,uCAAiB;YACnB,GAAG,KAAK,GAAG,CAAC,wCAAkB;QAChC;IACF;IAEA,IAAI,gBAAgB;QAClB;QACA;QACA,IAAI,CAAC,UAAU,CAAC,6CAAuB,CAAC,sCACtC,4CAAsB,WAAW;YAC/B,4CAAsB;YACtB,uCAAiB;YACjB;QACF,GAAG;aACE,IAAI,CAAC,QACV;IAEJ;IAEA,4CAA4C;IAC5C,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,aAAa,aAAa,OAAO;YACjC,IAAI,UAAU,8BAAQ,CAAC,GAAG;YAC1B,IAAI,SACF,OAAO,8BAAQ,CAAC,GAAG;QAEvB;IACF,GAAG;QAAC;KAAG;IAEP,OAAO;gBACL;QACA,MAAM,CAAC;YACL,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA;QAEJ;QACA,OAAO;IACT;AACF","sources":["packages/@react-stately/tooltip/src/useTooltipTriggerState.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 {TooltipTriggerProps} from '@react-types/tooltip';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useOverlayTriggerState} from '@react-stately/overlays';\n\nconst TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n isOpen: boolean,\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void,\n /** Hides the tooltip. */\n close(immediate?: boolean): void\n}\n\nlet tooltips = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout = null;\nlet globalCooldownTimeout = null;\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function useTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n let {delay = TOOLTIP_DELAY, closeDelay = TOOLTIP_COOLDOWN} = props;\n let {isOpen, open, close} = useOverlayTriggerState(props);\n let id = useMemo(() => `${++tooltipId}`, []);\n let closeTimeout = useRef<ReturnType<typeof setTimeout>>();\n\n let ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n let closeOpenTooltips = () => {\n for (let hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n tooltips[hideTooltipId](true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n let showTooltip = () => {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n closeOpenTooltips();\n ensureTooltipEntry();\n globalWarmedUp = true;\n open();\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n let hideTooltip = (immediate?: boolean) => {\n if (immediate || closeDelay <= 0) {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n close();\n } else if (!closeTimeout.current) {\n closeTimeout.current = setTimeout(() => {\n closeTimeout.current = null;\n close();\n }, closeDelay);\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(() => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n }, Math.max(TOOLTIP_COOLDOWN, closeDelay));\n }\n };\n\n let warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n if (!isOpen && !globalWarmUpTimeout && !globalWarmedUp) {\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n showTooltip();\n }, delay);\n } else if (!isOpen) {\n showTooltip();\n }\n };\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(closeTimeout.current);\n let tooltip = tooltips[id];\n if (tooltip) {\n delete tooltips[id];\n }\n };\n }, [id]);\n\n return {\n isOpen,\n open: (immediate) => {\n if (!immediate && delay > 0 && !closeTimeout.current) {\n warmupTooltip();\n } else {\n showTooltip();\n }\n },\n close: hideTooltip\n };\n}\n"],"names":[],"version":3,"file":"useTooltipTriggerState.main.js.map"}
@@ -0,0 +1,107 @@
1
+ import {useMemo as $50cCT$useMemo, useRef as $50cCT$useRef, useEffect as $50cCT$useEffect} from "react";
2
+ import {useOverlayTriggerState as $50cCT$useOverlayTriggerState} from "@react-stately/overlays";
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
+ const $8796f90736e175cb$var$TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design
17
+ const $8796f90736e175cb$var$TOOLTIP_COOLDOWN = 500;
18
+ let $8796f90736e175cb$var$tooltips = {};
19
+ let $8796f90736e175cb$var$tooltipId = 0;
20
+ let $8796f90736e175cb$var$globalWarmedUp = false;
21
+ let $8796f90736e175cb$var$globalWarmUpTimeout = null;
22
+ let $8796f90736e175cb$var$globalCooldownTimeout = null;
23
+ function $8796f90736e175cb$export$4d40659c25ecb50b(props = {}) {
24
+ let { delay: delay = $8796f90736e175cb$var$TOOLTIP_DELAY, closeDelay: closeDelay = $8796f90736e175cb$var$TOOLTIP_COOLDOWN } = props;
25
+ let { isOpen: isOpen, open: open, close: close } = (0, $50cCT$useOverlayTriggerState)(props);
26
+ let id = (0, $50cCT$useMemo)(()=>`${++$8796f90736e175cb$var$tooltipId}`, []);
27
+ let closeTimeout = (0, $50cCT$useRef)();
28
+ let ensureTooltipEntry = ()=>{
29
+ $8796f90736e175cb$var$tooltips[id] = hideTooltip;
30
+ };
31
+ let closeOpenTooltips = ()=>{
32
+ for(let hideTooltipId in $8796f90736e175cb$var$tooltips)if (hideTooltipId !== id) {
33
+ $8796f90736e175cb$var$tooltips[hideTooltipId](true);
34
+ delete $8796f90736e175cb$var$tooltips[hideTooltipId];
35
+ }
36
+ };
37
+ let showTooltip = ()=>{
38
+ clearTimeout(closeTimeout.current);
39
+ closeTimeout.current = null;
40
+ closeOpenTooltips();
41
+ ensureTooltipEntry();
42
+ $8796f90736e175cb$var$globalWarmedUp = true;
43
+ open();
44
+ if ($8796f90736e175cb$var$globalWarmUpTimeout) {
45
+ clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
46
+ $8796f90736e175cb$var$globalWarmUpTimeout = null;
47
+ }
48
+ if ($8796f90736e175cb$var$globalCooldownTimeout) {
49
+ clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
50
+ $8796f90736e175cb$var$globalCooldownTimeout = null;
51
+ }
52
+ };
53
+ let hideTooltip = (immediate)=>{
54
+ if (immediate || closeDelay <= 0) {
55
+ clearTimeout(closeTimeout.current);
56
+ closeTimeout.current = null;
57
+ close();
58
+ } else if (!closeTimeout.current) closeTimeout.current = setTimeout(()=>{
59
+ closeTimeout.current = null;
60
+ close();
61
+ }, closeDelay);
62
+ if ($8796f90736e175cb$var$globalWarmUpTimeout) {
63
+ clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
64
+ $8796f90736e175cb$var$globalWarmUpTimeout = null;
65
+ }
66
+ if ($8796f90736e175cb$var$globalWarmedUp) {
67
+ if ($8796f90736e175cb$var$globalCooldownTimeout) clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
68
+ $8796f90736e175cb$var$globalCooldownTimeout = setTimeout(()=>{
69
+ delete $8796f90736e175cb$var$tooltips[id];
70
+ $8796f90736e175cb$var$globalCooldownTimeout = null;
71
+ $8796f90736e175cb$var$globalWarmedUp = false;
72
+ }, Math.max($8796f90736e175cb$var$TOOLTIP_COOLDOWN, closeDelay));
73
+ }
74
+ };
75
+ let warmupTooltip = ()=>{
76
+ closeOpenTooltips();
77
+ ensureTooltipEntry();
78
+ if (!isOpen && !$8796f90736e175cb$var$globalWarmUpTimeout && !$8796f90736e175cb$var$globalWarmedUp) $8796f90736e175cb$var$globalWarmUpTimeout = setTimeout(()=>{
79
+ $8796f90736e175cb$var$globalWarmUpTimeout = null;
80
+ $8796f90736e175cb$var$globalWarmedUp = true;
81
+ showTooltip();
82
+ }, delay);
83
+ else if (!isOpen) showTooltip();
84
+ };
85
+ // eslint-disable-next-line arrow-body-style
86
+ (0, $50cCT$useEffect)(()=>{
87
+ return ()=>{
88
+ clearTimeout(closeTimeout.current);
89
+ let tooltip = $8796f90736e175cb$var$tooltips[id];
90
+ if (tooltip) delete $8796f90736e175cb$var$tooltips[id];
91
+ };
92
+ }, [
93
+ id
94
+ ]);
95
+ return {
96
+ isOpen: isOpen,
97
+ open: (immediate)=>{
98
+ if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
99
+ else showTooltip();
100
+ },
101
+ close: hideTooltip
102
+ };
103
+ }
104
+
105
+
106
+ export {$8796f90736e175cb$export$4d40659c25ecb50b as useTooltipTriggerState};
107
+ //# sourceMappingURL=useTooltipTriggerState.mjs.map
@@ -0,0 +1,107 @@
1
+ import {useMemo as $50cCT$useMemo, useRef as $50cCT$useRef, useEffect as $50cCT$useEffect} from "react";
2
+ import {useOverlayTriggerState as $50cCT$useOverlayTriggerState} from "@react-stately/overlays";
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
+ const $8796f90736e175cb$var$TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design
17
+ const $8796f90736e175cb$var$TOOLTIP_COOLDOWN = 500;
18
+ let $8796f90736e175cb$var$tooltips = {};
19
+ let $8796f90736e175cb$var$tooltipId = 0;
20
+ let $8796f90736e175cb$var$globalWarmedUp = false;
21
+ let $8796f90736e175cb$var$globalWarmUpTimeout = null;
22
+ let $8796f90736e175cb$var$globalCooldownTimeout = null;
23
+ function $8796f90736e175cb$export$4d40659c25ecb50b(props = {}) {
24
+ let { delay: delay = $8796f90736e175cb$var$TOOLTIP_DELAY, closeDelay: closeDelay = $8796f90736e175cb$var$TOOLTIP_COOLDOWN } = props;
25
+ let { isOpen: isOpen, open: open, close: close } = (0, $50cCT$useOverlayTriggerState)(props);
26
+ let id = (0, $50cCT$useMemo)(()=>`${++$8796f90736e175cb$var$tooltipId}`, []);
27
+ let closeTimeout = (0, $50cCT$useRef)();
28
+ let ensureTooltipEntry = ()=>{
29
+ $8796f90736e175cb$var$tooltips[id] = hideTooltip;
30
+ };
31
+ let closeOpenTooltips = ()=>{
32
+ for(let hideTooltipId in $8796f90736e175cb$var$tooltips)if (hideTooltipId !== id) {
33
+ $8796f90736e175cb$var$tooltips[hideTooltipId](true);
34
+ delete $8796f90736e175cb$var$tooltips[hideTooltipId];
35
+ }
36
+ };
37
+ let showTooltip = ()=>{
38
+ clearTimeout(closeTimeout.current);
39
+ closeTimeout.current = null;
40
+ closeOpenTooltips();
41
+ ensureTooltipEntry();
42
+ $8796f90736e175cb$var$globalWarmedUp = true;
43
+ open();
44
+ if ($8796f90736e175cb$var$globalWarmUpTimeout) {
45
+ clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
46
+ $8796f90736e175cb$var$globalWarmUpTimeout = null;
47
+ }
48
+ if ($8796f90736e175cb$var$globalCooldownTimeout) {
49
+ clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
50
+ $8796f90736e175cb$var$globalCooldownTimeout = null;
51
+ }
52
+ };
53
+ let hideTooltip = (immediate)=>{
54
+ if (immediate || closeDelay <= 0) {
55
+ clearTimeout(closeTimeout.current);
56
+ closeTimeout.current = null;
57
+ close();
58
+ } else if (!closeTimeout.current) closeTimeout.current = setTimeout(()=>{
59
+ closeTimeout.current = null;
60
+ close();
61
+ }, closeDelay);
62
+ if ($8796f90736e175cb$var$globalWarmUpTimeout) {
63
+ clearTimeout($8796f90736e175cb$var$globalWarmUpTimeout);
64
+ $8796f90736e175cb$var$globalWarmUpTimeout = null;
65
+ }
66
+ if ($8796f90736e175cb$var$globalWarmedUp) {
67
+ if ($8796f90736e175cb$var$globalCooldownTimeout) clearTimeout($8796f90736e175cb$var$globalCooldownTimeout);
68
+ $8796f90736e175cb$var$globalCooldownTimeout = setTimeout(()=>{
69
+ delete $8796f90736e175cb$var$tooltips[id];
70
+ $8796f90736e175cb$var$globalCooldownTimeout = null;
71
+ $8796f90736e175cb$var$globalWarmedUp = false;
72
+ }, Math.max($8796f90736e175cb$var$TOOLTIP_COOLDOWN, closeDelay));
73
+ }
74
+ };
75
+ let warmupTooltip = ()=>{
76
+ closeOpenTooltips();
77
+ ensureTooltipEntry();
78
+ if (!isOpen && !$8796f90736e175cb$var$globalWarmUpTimeout && !$8796f90736e175cb$var$globalWarmedUp) $8796f90736e175cb$var$globalWarmUpTimeout = setTimeout(()=>{
79
+ $8796f90736e175cb$var$globalWarmUpTimeout = null;
80
+ $8796f90736e175cb$var$globalWarmedUp = true;
81
+ showTooltip();
82
+ }, delay);
83
+ else if (!isOpen) showTooltip();
84
+ };
85
+ // eslint-disable-next-line arrow-body-style
86
+ (0, $50cCT$useEffect)(()=>{
87
+ return ()=>{
88
+ clearTimeout(closeTimeout.current);
89
+ let tooltip = $8796f90736e175cb$var$tooltips[id];
90
+ if (tooltip) delete $8796f90736e175cb$var$tooltips[id];
91
+ };
92
+ }, [
93
+ id
94
+ ]);
95
+ return {
96
+ isOpen: isOpen,
97
+ open: (immediate)=>{
98
+ if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
99
+ else showTooltip();
100
+ },
101
+ close: hideTooltip
102
+ };
103
+ }
104
+
105
+
106
+ export {$8796f90736e175cb$export$4d40659c25ecb50b as useTooltipTriggerState};
107
+ //# sourceMappingURL=useTooltipTriggerState.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAMD,MAAM,sCAAgB,MAAM,yDAAyD;AACrF,MAAM,yCAAmB;AAezB,IAAI,iCAAW,CAAC;AAChB,IAAI,kCAAY;AAChB,IAAI,uCAAiB;AACrB,IAAI,4CAAsB;AAC1B,IAAI,8CAAwB;AAOrB,SAAS,0CAAuB,QAA6B,CAAC,CAAC;IACpE,IAAI,SAAC,QAAQ,iDAAe,aAAa,wCAAiB,GAAG;IAC7D,IAAI,UAAC,MAAM,QAAE,IAAI,SAAE,KAAK,EAAC,GAAG,CAAA,GAAA,6BAAqB,EAAE;IACnD,IAAI,KAAK,CAAA,GAAA,cAAM,EAAE,IAAM,CAAC,EAAE,EAAE,gCAAU,CAAC,EAAE,EAAE;IAC3C,IAAI,eAAe,CAAA,GAAA,aAAK;IAExB,IAAI,qBAAqB;QACvB,8BAAQ,CAAC,GAAG,GAAG;IACjB;IAEA,IAAI,oBAAoB;QACtB,IAAK,IAAI,iBAAiB,+BACxB,IAAI,kBAAkB,IAAI;YACxB,8BAAQ,CAAC,cAAc,CAAC;YACxB,OAAO,8BAAQ,CAAC,cAAc;QAChC;IAEJ;IAEA,IAAI,cAAc;QAChB,aAAa,aAAa,OAAO;QACjC,aAAa,OAAO,GAAG;QACvB;QACA;QACA,uCAAiB;QACjB;QACA,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,6CAAuB;YACzB,aAAa;YACb,8CAAwB;QAC1B;IACF;IAEA,IAAI,cAAc,CAAC;QACjB,IAAI,aAAa,cAAc,GAAG;YAChC,aAAa,aAAa,OAAO;YACjC,aAAa,OAAO,GAAG;YACvB;QACF,OAAO,IAAI,CAAC,aAAa,OAAO,EAC9B,aAAa,OAAO,GAAG,WAAW;YAChC,aAAa,OAAO,GAAG;YACvB;QACF,GAAG;QAGL,IAAI,2CAAqB;YACvB,aAAa;YACb,4CAAsB;QACxB;QACA,IAAI,sCAAgB;YAClB,IAAI,6CACF,aAAa;YAEf,8CAAwB,WAAW;gBACjC,OAAO,8BAAQ,CAAC,GAAG;gBACnB,8CAAwB;gBACxB,uCAAiB;YACnB,GAAG,KAAK,GAAG,CAAC,wCAAkB;QAChC;IACF;IAEA,IAAI,gBAAgB;QAClB;QACA;QACA,IAAI,CAAC,UAAU,CAAC,6CAAuB,CAAC,sCACtC,4CAAsB,WAAW;YAC/B,4CAAsB;YACtB,uCAAiB;YACjB;QACF,GAAG;aACE,IAAI,CAAC,QACV;IAEJ;IAEA,4CAA4C;IAC5C,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,aAAa,aAAa,OAAO;YACjC,IAAI,UAAU,8BAAQ,CAAC,GAAG;YAC1B,IAAI,SACF,OAAO,8BAAQ,CAAC,GAAG;QAEvB;IACF,GAAG;QAAC;KAAG;IAEP,OAAO;gBACL;QACA,MAAM,CAAC;YACL,IAAI,CAAC,aAAa,QAAQ,KAAK,CAAC,aAAa,OAAO,EAClD;iBAEA;QAEJ;QACA,OAAO;IACT;AACF","sources":["packages/@react-stately/tooltip/src/useTooltipTriggerState.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 {TooltipTriggerProps} from '@react-types/tooltip';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useOverlayTriggerState} from '@react-stately/overlays';\n\nconst TOOLTIP_DELAY = 1500; // this seems to be a 1.5 second delay, check with design\nconst TOOLTIP_COOLDOWN = 500;\n\nexport interface TooltipTriggerState {\n /** Whether the tooltip is currently showing. */\n isOpen: boolean,\n /**\n * Shows the tooltip. By default, the tooltip becomes visible after a delay\n * depending on a global warmup timer. The `immediate` option shows the\n * tooltip immediately instead.\n */\n open(immediate?: boolean): void,\n /** Hides the tooltip. */\n close(immediate?: boolean): void\n}\n\nlet tooltips = {};\nlet tooltipId = 0;\nlet globalWarmedUp = false;\nlet globalWarmUpTimeout = null;\nlet globalCooldownTimeout = null;\n\n/**\n * Manages state for a tooltip trigger. Tracks whether the tooltip is open, and provides\n * methods to toggle this state. Ensures only one tooltip is open at a time and controls\n * the delay for showing a tooltip.\n */\nexport function useTooltipTriggerState(props: TooltipTriggerProps = {}): TooltipTriggerState {\n let {delay = TOOLTIP_DELAY, closeDelay = TOOLTIP_COOLDOWN} = props;\n let {isOpen, open, close} = useOverlayTriggerState(props);\n let id = useMemo(() => `${++tooltipId}`, []);\n let closeTimeout = useRef<ReturnType<typeof setTimeout>>();\n\n let ensureTooltipEntry = () => {\n tooltips[id] = hideTooltip;\n };\n\n let closeOpenTooltips = () => {\n for (let hideTooltipId in tooltips) {\n if (hideTooltipId !== id) {\n tooltips[hideTooltipId](true);\n delete tooltips[hideTooltipId];\n }\n }\n };\n\n let showTooltip = () => {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n closeOpenTooltips();\n ensureTooltipEntry();\n globalWarmedUp = true;\n open();\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n globalCooldownTimeout = null;\n }\n };\n\n let hideTooltip = (immediate?: boolean) => {\n if (immediate || closeDelay <= 0) {\n clearTimeout(closeTimeout.current);\n closeTimeout.current = null;\n close();\n } else if (!closeTimeout.current) {\n closeTimeout.current = setTimeout(() => {\n closeTimeout.current = null;\n close();\n }, closeDelay);\n }\n\n if (globalWarmUpTimeout) {\n clearTimeout(globalWarmUpTimeout);\n globalWarmUpTimeout = null;\n }\n if (globalWarmedUp) {\n if (globalCooldownTimeout) {\n clearTimeout(globalCooldownTimeout);\n }\n globalCooldownTimeout = setTimeout(() => {\n delete tooltips[id];\n globalCooldownTimeout = null;\n globalWarmedUp = false;\n }, Math.max(TOOLTIP_COOLDOWN, closeDelay));\n }\n };\n\n let warmupTooltip = () => {\n closeOpenTooltips();\n ensureTooltipEntry();\n if (!isOpen && !globalWarmUpTimeout && !globalWarmedUp) {\n globalWarmUpTimeout = setTimeout(() => {\n globalWarmUpTimeout = null;\n globalWarmedUp = true;\n showTooltip();\n }, delay);\n } else if (!isOpen) {\n showTooltip();\n }\n };\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(closeTimeout.current);\n let tooltip = tooltips[id];\n if (tooltip) {\n delete tooltips[id];\n }\n };\n }, [id]);\n\n return {\n isOpen,\n open: (immediate) => {\n if (!immediate && delay > 0 && !closeTimeout.current) {\n warmupTooltip();\n } else {\n showTooltip();\n }\n },\n close: hideTooltip\n };\n}\n"],"names":[],"version":3,"file":"useTooltipTriggerState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/tooltip",
3
- "version": "3.4.8-nightly.4552+64ed13090",
3
+ "version": "3.4.8-nightly.4558+c5e4b3701",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,8 +22,8 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/overlays": "3.6.6-nightly.4552+64ed13090",
26
- "@react-types/tooltip": "3.4.8-nightly.4552+64ed13090",
25
+ "@react-stately/overlays": "3.6.6-nightly.4558+c5e4b3701",
26
+ "@react-types/tooltip": "3.4.8-nightly.4558+c5e4b3701",
27
27
  "@swc/helpers": "^0.5.0"
28
28
  },
29
29
  "peerDependencies": {
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "64ed13090ce77cc0e4cb4cd5602e75f655bff6bb"
35
+ "gitHead": "c5e4b3701fdb89eb551f1b3697ac253f06ef68fa"
36
36
  }