@react-aria/tooltip 3.0.0-alpha.0 → 3.0.0-nightly-641446f65-240905

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.
@@ -0,0 +1,19 @@
1
+ import {useTooltip as $326e436e94273fe1$export$1c4b08e0eca38426} from "./useTooltip.mjs";
2
+ import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./useTooltipTrigger.mjs";
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
+
17
+
18
+ export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip, $4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
19
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,143 +1,25 @@
1
- var {
2
- useFocusable
3
- } = require("@react-aria/focus");
1
+ var $199fa2aaa84f20b7$exports = require("./useTooltip.main.js");
2
+ var $f017bbc46d58d42a$exports = require("./useTooltipTrigger.main.js");
4
3
 
5
- var {
6
- useEffect,
7
- useRef
8
- } = require("react");
9
4
 
10
- var {
11
- isFocusVisible,
12
- usePress,
13
- useHover
14
- } = require("@react-aria/interactions");
15
-
16
- var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
17
-
18
- var {
19
- filterDOMProps,
20
- mergeProps,
21
- useId
22
- } = require("@react-aria/utils");
23
-
24
- function $parcel$interopDefault(a) {
25
- return a && a.__esModule ? a.default : a;
26
- }
27
-
28
- function useTooltip(props) {
29
- let {
30
- id,
31
- role = 'tooltip'
32
- } = props;
33
- let domProps = filterDOMProps(props);
34
- return {
35
- tooltipProps: mergeProps(domProps, {
36
- role,
37
- id: useId(id)
38
- })
39
- };
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
40
7
  }
41
8
 
42
- exports.useTooltip = useTooltip;
43
-
44
- function useTooltipTrigger(props, state, ref) {
45
- let {
46
- isDisabled
47
- } = props;
48
- let tooltipId = useId();
49
- let isHovered = useRef(false);
50
- let isFocused = useRef(false);
51
-
52
- let handleShow = () => {
53
- state.open(isFocused.current);
54
- };
55
-
56
- let handleHide = () => {
57
- if (!isHovered.current && !isFocused.current) {
58
- state.close();
59
- }
60
- };
61
-
62
- useEffect(() => {
63
- let onKeyDown = e => {
64
- if (ref && ref.current) {
65
- // Escape after clicking something can give it keyboard focus
66
- // dismiss tooltip on esc key press
67
- if (e.key === 'Escape') {
68
- state.close();
69
- }
70
- }
71
- };
9
+ $parcel$export(module.exports, "useTooltip", () => $199fa2aaa84f20b7$exports.useTooltip);
10
+ $parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$exports.useTooltipTrigger);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
72
22
 
73
- if (state.isOpen) {
74
- document.addEventListener('keydown', onKeyDown);
75
- return () => {
76
- document.removeEventListener('keydown', onKeyDown);
77
- };
78
- }
79
- }, [ref, state]);
80
23
 
81
- let onHoverStart = () => {
82
- isHovered.current = true;
83
- handleShow();
84
- };
85
-
86
- let onHoverEnd = () => {
87
- isHovered.current = false;
88
- handleHide();
89
- };
90
-
91
- let onPressStart = () => {
92
- if (isFocused.current) {
93
- isFocused.current = false;
94
- }
95
-
96
- handleHide();
97
- };
98
-
99
- let onFocus = () => {
100
- let isVisible = isFocusVisible();
101
-
102
- if (isVisible) {
103
- isFocused.current = true;
104
- handleShow();
105
- }
106
- };
107
-
108
- let onBlur = () => {
109
- isFocused.current = false;
110
- handleHide();
111
- };
112
-
113
- let {
114
- hoverProps
115
- } = useHover({
116
- isDisabled,
117
- onHoverStart,
118
- onHoverEnd
119
- });
120
- let {
121
- pressProps
122
- } = usePress({
123
- onPressStart
124
- });
125
- let {
126
- focusableProps
127
- } = useFocusable({
128
- isDisabled,
129
- onFocus,
130
- onBlur
131
- }, ref);
132
- return {
133
- triggerProps: _babelRuntimeHelpersExtends({
134
- 'aria-describedby': state.open ? tooltipId : undefined
135
- }, mergeProps(focusableProps, hoverProps, pressProps)),
136
- tooltipProps: {
137
- id: tooltipId
138
- }
139
- };
140
- }
141
24
 
142
- exports.useTooltipTrigger = useTooltipTrigger;
143
25
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACkBM,SAASG,UAAT,CAAoBC,KAApB,EAA0D;AAC/D,MAAI;AACFC,IAAAA,EADE;AAEFC,IAAAA,IAAI,GAAG;AAFL,MAGAF,KAHJ;AAKA,MAAIG,QAAQ,GAAGC,cAAc,CAACJ,KAAD,CAA7B;AAEA,SAAO;AACLK,IAAAA,YAAY,EAAEC,UAAU,CAACH,QAAD,EAAW;AACjCD,MAAAA,IADiC;AAEjCD,MAAAA,EAAE,EAAEM,KAAK,CAACN,EAAD;AAFwB,KAAX;AADnB,GAAP;AAMD;;;;ACRM,SAASO,iBAAT,CAA2BR,KAA3B,EAA2DS,KAA3D,EAAuFC,GAAvF,EAAyI;AAC9I,MAAI;AACFC,IAAAA;AADE,MAEAX,KAFJ;AAIA,MAAIY,SAAS,GAAGL,KAAK,EAArB;AAEA,MAAIM,SAAS,GAAGC,MAAM,CAAC,KAAD,CAAtB;AACA,MAAIC,SAAS,GAAGD,MAAM,CAAC,KAAD,CAAtB;;AAEA,MAAIE,UAAU,GAAG,MAAM;AACrBP,IAAAA,KAAK,CAACQ,IAAN,CAAWF,SAAS,CAACG,OAArB;AACD,GAFD;;AAIA,MAAIC,UAAU,GAAG,MAAM;AACrB,QAAI,CAACN,SAAS,CAACK,OAAX,IAAsB,CAACH,SAAS,CAACG,OAArC,EAA8C;AAC5CT,MAAAA,KAAK,CAACW,KAAN;AACD;AACF,GAJD;;AAMAC,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIC,SAAS,GAAIC,CAAD,IAAO;AACrB,UAAIb,GAAG,IAAIA,GAAG,CAACQ,OAAf,EAAwB;AACtB;AACA;AACA,YAAIK,CAAC,CAACC,GAAF,KAAU,QAAd,EAAwB;AACtBf,UAAAA,KAAK,CAACW,KAAN;AACD;AACF;AACF,KARD;;AASA,QAAIX,KAAK,CAACgB,MAAV,EAAkB;AAChBC,MAAAA,QAAQ,CAACC,gBAAT,CAA0B,SAA1B,EAAqCL,SAArC;AACA,aAAO,MAAM;AACXI,QAAAA,QAAQ,CAACE,mBAAT,CAA6B,SAA7B,EAAwCN,SAAxC;AACD,OAFD;AAGD;AACF,GAhBQ,EAgBN,CAACZ,GAAD,EAAMD,KAAN,CAhBM,CAAT;;AAkBA,MAAIoB,YAAY,GAAG,MAAM;AACvBhB,IAAAA,SAAS,CAACK,OAAV,GAAoB,IAApB;AACAF,IAAAA,UAAU;AACX,GAHD;;AAIA,MAAIc,UAAU,GAAG,MAAM;AACrBjB,IAAAA,SAAS,CAACK,OAAV,GAAoB,KAApB;AACAC,IAAAA,UAAU;AACX,GAHD;;AAIA,MAAIY,YAAY,GAAG,MAAM;AACvB,QAAIhB,SAAS,CAACG,OAAd,EAAuB;AACrBH,MAAAA,SAAS,CAACG,OAAV,GAAoB,KAApB;AACD;;AACDC,IAAAA,UAAU;AACX,GALD;;AAMA,MAAIa,OAAO,GAAG,MAAM;AAClB,QAAIC,SAAS,GAAGC,cAAc,EAA9B;;AACA,QAAID,SAAJ,EAAe;AACblB,MAAAA,SAAS,CAACG,OAAV,GAAoB,IAApB;AACAF,MAAAA,UAAU;AACX;AACF,GAND;;AAOA,MAAImB,MAAM,GAAG,MAAM;AACjBpB,IAAAA,SAAS,CAACG,OAAV,GAAoB,KAApB;AACAC,IAAAA,UAAU;AACX,GAHD;;AAKA,MAAI;AAACiB,IAAAA;AAAD,MAAeC,QAAQ,CAAC;AAC1B1B,IAAAA,UAD0B;AAE1BkB,IAAAA,YAF0B;AAG1BC,IAAAA;AAH0B,GAAD,CAA3B;AAMA,MAAI;AAACQ,IAAAA;AAAD,MAAeC,QAAQ,CAAC;AAACR,IAAAA;AAAD,GAAD,CAA3B;AAEA,MAAI;AAACS,IAAAA;AAAD,MAAmBC,YAAY,CAAC;AAClC9B,IAAAA,UADkC;AAElCqB,IAAAA,OAFkC;AAGlCG,IAAAA;AAHkC,GAAD,EAIhCzB,GAJgC,CAAnC;AAMA,SAAO;AACLgC,IAAAA,YAAY;AACV,0BAAoBjC,KAAK,CAACQ,IAAN,GAAaL,SAAb,GAAyB+B;AADnC,OAEPrC,UAAU,CAACkC,cAAD,EAAiBJ,UAAjB,EAA6BE,UAA7B,CAFH,CADP;AAKLjC,IAAAA,YAAY,EAAE;AACZJ,MAAAA,EAAE,EAAEW;AADQ;AALT,GAAP;AASD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/tooltip/src/useTooltip.ts","./packages/@react-aria/tooltip/src/useTooltipTrigger.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\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 {AriaTooltipProps} from '@react-types/tooltip';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {HTMLAttributes} from 'react';\n\ninterface TooltipAria {\n tooltipProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useTooltip(props: AriaTooltipProps): TooltipAria {\n let {\n id,\n role = 'tooltip'\n } = props;\n\n let domProps = filterDOMProps(props);\n\n return {\n tooltipProps: mergeProps(domProps, {\n role,\n id: useId(id)\n })\n };\n}\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 {FocusEvents} from '@react-types/shared';\nimport {HoverProps, isFocusVisible, PressProps, usePress} from '@react-aria/interactions';\nimport {HTMLAttributes, RefObject, useEffect, useRef} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {TooltipTriggerAriaProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useFocusable} from '@react-aria/focus';\nimport {useHover} from '@react-aria/interactions';\n\ninterface TooltipTriggerAria {\n triggerProps: HTMLAttributes<HTMLElement> & PressProps & HoverProps & FocusEvents,\n tooltipProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useTooltipTrigger(props: TooltipTriggerAriaProps, state: TooltipTriggerState, ref: RefObject<HTMLElement>) : TooltipTriggerAria {\n let {\n isDisabled\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n state.open(isFocused.current);\n };\n\n let handleHide = () => {\n if (!isHovered.current && !isFocused.current) {\n state.close();\n }\n };\n\n useEffect(() => {\n let onKeyDown = (e) => {\n if (ref && ref.current) {\n // Escape after clicking something can give it keyboard focus\n // dismiss tooltip on esc key press\n if (e.key === 'Escape') {\n state.close();\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown);\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n isHovered.current = true;\n handleShow();\n };\n let onHoverEnd = () => {\n isHovered.current = false;\n handleHide();\n };\n let onPressStart = () => {\n if (isFocused.current) {\n isFocused.current = false;\n }\n handleHide();\n };\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n let onBlur = () => {\n isFocused.current = false;\n handleHide();\n };\n\n let {hoverProps} = useHover({\n isDisabled,\n onHoverStart,\n onHoverEnd\n });\n\n let {pressProps} = usePress({onPressStart});\n\n let {focusableProps} = useFocusable({\n isDisabled,\n onFocus,\n onBlur\n }, ref);\n\n return {\n triggerProps: {\n 'aria-describedby': state.open ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useTooltip","props","id","role","domProps","filterDOMProps","tooltipProps","mergeProps","useId","useTooltipTrigger","state","ref","isDisabled","tooltipId","isHovered","useRef","isFocused","handleShow","open","current","handleHide","close","useEffect","onKeyDown","e","key","isOpen","document","addEventListener","removeEventListener","onHoverStart","onHoverEnd","onPressStart","onFocus","isVisible","isFocusVisible","onBlur","hoverProps","useHover","pressProps","usePress","focusableProps","useFocusable","triggerProps","undefined"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/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 */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,116 +1,19 @@
1
- import { useFocusable } from "@react-aria/focus";
2
- import { useEffect, useRef } from "react";
3
- import { isFocusVisible, usePress, useHover } from "@react-aria/interactions";
4
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
5
- import { filterDOMProps, mergeProps, useId } from "@react-aria/utils";
6
- export function useTooltip(props) {
7
- let {
8
- id,
9
- role = 'tooltip'
10
- } = props;
11
- let domProps = filterDOMProps(props);
12
- return {
13
- tooltipProps: mergeProps(domProps, {
14
- role,
15
- id: useId(id)
16
- })
17
- };
18
- }
19
- export function useTooltipTrigger(props, state, ref) {
20
- let {
21
- isDisabled
22
- } = props;
23
- let tooltipId = useId();
24
- let isHovered = useRef(false);
25
- let isFocused = useRef(false);
1
+ import {useTooltip as $326e436e94273fe1$export$1c4b08e0eca38426} from "./useTooltip.module.js";
2
+ import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./useTooltipTrigger.module.js";
26
3
 
27
- let handleShow = () => {
28
- state.open(isFocused.current);
29
- };
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
+ */
30
15
 
31
- let handleHide = () => {
32
- if (!isHovered.current && !isFocused.current) {
33
- state.close();
34
- }
35
- };
36
16
 
37
- useEffect(() => {
38
- let onKeyDown = e => {
39
- if (ref && ref.current) {
40
- // Escape after clicking something can give it keyboard focus
41
- // dismiss tooltip on esc key press
42
- if (e.key === 'Escape') {
43
- state.close();
44
- }
45
- }
46
- };
47
17
 
48
- if (state.isOpen) {
49
- document.addEventListener('keydown', onKeyDown);
50
- return () => {
51
- document.removeEventListener('keydown', onKeyDown);
52
- };
53
- }
54
- }, [ref, state]);
55
-
56
- let onHoverStart = () => {
57
- isHovered.current = true;
58
- handleShow();
59
- };
60
-
61
- let onHoverEnd = () => {
62
- isHovered.current = false;
63
- handleHide();
64
- };
65
-
66
- let onPressStart = () => {
67
- if (isFocused.current) {
68
- isFocused.current = false;
69
- }
70
-
71
- handleHide();
72
- };
73
-
74
- let onFocus = () => {
75
- let isVisible = isFocusVisible();
76
-
77
- if (isVisible) {
78
- isFocused.current = true;
79
- handleShow();
80
- }
81
- };
82
-
83
- let onBlur = () => {
84
- isFocused.current = false;
85
- handleHide();
86
- };
87
-
88
- let {
89
- hoverProps
90
- } = useHover({
91
- isDisabled,
92
- onHoverStart,
93
- onHoverEnd
94
- });
95
- let {
96
- pressProps
97
- } = usePress({
98
- onPressStart
99
- });
100
- let {
101
- focusableProps
102
- } = useFocusable({
103
- isDisabled,
104
- onFocus,
105
- onBlur
106
- }, ref);
107
- return {
108
- triggerProps: _babelRuntimeHelpersEsmExtends({
109
- 'aria-describedby': state.open ? tooltipId : undefined
110
- }, mergeProps(focusableProps, hoverProps, pressProps)),
111
- tooltipProps: {
112
- id: tooltipId
113
- }
114
- };
115
- }
18
+ export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip, $4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
116
19
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":"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","sources":["./packages/@react-aria/tooltip/src/useTooltip.ts","./packages/@react-aria/tooltip/src/useTooltipTrigger.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 {AriaTooltipProps} from '@react-types/tooltip';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {HTMLAttributes} from 'react';\n\ninterface TooltipAria {\n tooltipProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useTooltip(props: AriaTooltipProps): TooltipAria {\n let {\n id,\n role = 'tooltip'\n } = props;\n\n let domProps = filterDOMProps(props);\n\n return {\n tooltipProps: mergeProps(domProps, {\n role,\n id: useId(id)\n })\n };\n}\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 {FocusEvents} from '@react-types/shared';\nimport {HoverProps, isFocusVisible, PressProps, usePress} from '@react-aria/interactions';\nimport {HTMLAttributes, RefObject, useEffect, useRef} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {TooltipTriggerAriaProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useFocusable} from '@react-aria/focus';\nimport {useHover} from '@react-aria/interactions';\n\ninterface TooltipTriggerAria {\n triggerProps: HTMLAttributes<HTMLElement> & PressProps & HoverProps & FocusEvents,\n tooltipProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useTooltipTrigger(props: TooltipTriggerAriaProps, state: TooltipTriggerState, ref: RefObject<HTMLElement>) : TooltipTriggerAria {\n let {\n isDisabled\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n state.open(isFocused.current);\n };\n\n let handleHide = () => {\n if (!isHovered.current && !isFocused.current) {\n state.close();\n }\n };\n\n useEffect(() => {\n let onKeyDown = (e) => {\n if (ref && ref.current) {\n // Escape after clicking something can give it keyboard focus\n // dismiss tooltip on esc key press\n if (e.key === 'Escape') {\n state.close();\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown);\n return () => {\n document.removeEventListener('keydown', onKeyDown);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n isHovered.current = true;\n handleShow();\n };\n let onHoverEnd = () => {\n isHovered.current = false;\n handleHide();\n };\n let onPressStart = () => {\n if (isFocused.current) {\n isFocused.current = false;\n }\n handleHide();\n };\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n let onBlur = () => {\n isFocused.current = false;\n handleHide();\n };\n\n let {hoverProps} = useHover({\n isDisabled,\n onHoverStart,\n onHoverEnd\n });\n\n let {pressProps} = usePress({onPressStart});\n\n let {focusableProps} = useFocusable({\n isDisabled,\n onFocus,\n onBlur\n }, ref);\n\n return {\n triggerProps: {\n 'aria-describedby': state.open ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":["useTooltip","props","id","role","domProps","filterDOMProps","tooltipProps","mergeProps","useId","useTooltipTrigger","state","ref","isDisabled","tooltipId","isHovered","useRef","isFocused","handleShow","open","current","handleHide","close","useEffect","onKeyDown","e","key","isOpen","document","addEventListener","removeEventListener","onHoverStart","onHoverEnd","onPressStart","onFocus","isVisible","isFocusVisible","onBlur","hoverProps","useHover","pressProps","usePress","focusableProps","useFocusable","triggerProps","undefined"],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/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 */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,16 +1,31 @@
1
- import { AriaTooltipProps, TooltipTriggerAriaProps } from "@react-types/tooltip";
2
- import { HTMLAttributes, RefObject } from "react";
3
- import { FocusEvents } from "@react-types/shared";
4
- import { HoverProps, PressProps } from "@react-aria/interactions";
1
+ import { AriaTooltipProps, TooltipTriggerProps } from "@react-types/tooltip";
2
+ import { DOMAttributes, FocusableElement, RefObject } from "@react-types/shared";
5
3
  import { TooltipTriggerState } from "@react-stately/tooltip";
6
- interface TooltipAria {
7
- tooltipProps: HTMLAttributes<HTMLElement>;
4
+ export interface TooltipAria {
5
+ /**
6
+ * Props for the tooltip element.
7
+ */
8
+ tooltipProps: DOMAttributes;
8
9
  }
9
- export function useTooltip(props: AriaTooltipProps): TooltipAria;
10
- interface TooltipTriggerAria {
11
- triggerProps: HTMLAttributes<HTMLElement> & PressProps & HoverProps & FocusEvents;
12
- tooltipProps: HTMLAttributes<HTMLElement>;
10
+ /**
11
+ * Provides the accessibility implementation for a Tooltip component.
12
+ */
13
+ export function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria;
14
+ export interface TooltipTriggerAria {
15
+ /**
16
+ * Props for the trigger element.
17
+ */
18
+ triggerProps: DOMAttributes;
19
+ /**
20
+ * Props for the overlay container element.
21
+ */
22
+ tooltipProps: DOMAttributes;
13
23
  }
14
- export function useTooltipTrigger(props: TooltipTriggerAriaProps, state: TooltipTriggerState, ref: RefObject<HTMLElement>): TooltipTriggerAria;
24
+ /**
25
+ * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button
26
+ * that shows a description when focused or hovered.
27
+ */
28
+ export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement | null>): TooltipTriggerAria;
29
+ export type { AriaTooltipProps, TooltipTriggerProps } from '@react-types/tooltip';
15
30
 
16
31
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":"A;A;A;A;A;AAgBA;IACE,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAED,2BAA2B,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAc/D;ACbD;IACE,YAAY,EAAE,eAAe,WAAW,CAAC,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;IAClF,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAED,kCAAkC,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAI,kBAAkB,CAuF9I","sources":["./packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/useTooltip.ts","./packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/useTooltipTrigger.ts","./packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":[null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AAkBA;IACE;;OAEG;IACH,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED;;GAEG;AACH,2BAA2B,KAAK,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAa5F;ACrBD;IACE;;OAEG;IACH,YAAY,EAAE,aAAa,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED;;;GAGG;AACH,kCAAkC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAI,kBAAkB,CAiHtJ;ACxID,YAAY,EAAC,gBAAgB,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC","sources":["packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/useTooltip.ts","packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/useTooltipTrigger.ts","packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/index.ts","packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":[null,null,null,"/*\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 */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,38 @@
1
+ var $1ztb7$reactariautils = require("@react-aria/utils");
2
+ var $1ztb7$reactariainteractions = require("@react-aria/interactions");
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, "useTooltip", () => $199fa2aaa84f20b7$export$1c4b08e0eca38426);
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
+ function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
23
+ let domProps = (0, $1ztb7$reactariautils.filterDOMProps)(props, {
24
+ labelable: true
25
+ });
26
+ let { hoverProps: hoverProps } = (0, $1ztb7$reactariainteractions.useHover)({
27
+ onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
28
+ onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
29
+ });
30
+ return {
31
+ tooltipProps: (0, $1ztb7$reactariautils.mergeProps)(domProps, hoverProps, {
32
+ role: 'tooltip'
33
+ })
34
+ };
35
+ }
36
+
37
+
38
+ //# sourceMappingURL=useTooltip.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,cAAc,IAAM,kBAAA,4BAAA,MAAO,IAAI,CAAC;QAChC,YAAY,IAAM,kBAAA,4BAAA,MAAO,KAAK;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltip.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 {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\n"],"names":[],"version":3,"file":"useTooltip.main.js.map"}
@@ -0,0 +1,33 @@
1
+ import {filterDOMProps as $kwmr2$filterDOMProps, mergeProps as $kwmr2$mergeProps} from "@react-aria/utils";
2
+ import {useHover as $kwmr2$useHover} from "@react-aria/interactions";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
17
+ let domProps = (0, $kwmr2$filterDOMProps)(props, {
18
+ labelable: true
19
+ });
20
+ let { hoverProps: hoverProps } = (0, $kwmr2$useHover)({
21
+ onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
22
+ onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
23
+ });
24
+ return {
25
+ tooltipProps: (0, $kwmr2$mergeProps)(domProps, hoverProps, {
26
+ role: 'tooltip'
27
+ })
28
+ };
29
+ }
30
+
31
+
32
+ export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip};
33
+ //# sourceMappingURL=useTooltip.module.js.map
@@ -0,0 +1,33 @@
1
+ import {filterDOMProps as $kwmr2$filterDOMProps, mergeProps as $kwmr2$mergeProps} from "@react-aria/utils";
2
+ import {useHover as $kwmr2$useHover} from "@react-aria/interactions";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
17
+ let domProps = (0, $kwmr2$filterDOMProps)(props, {
18
+ labelable: true
19
+ });
20
+ let { hoverProps: hoverProps } = (0, $kwmr2$useHover)({
21
+ onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
22
+ onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
23
+ });
24
+ return {
25
+ tooltipProps: (0, $kwmr2$mergeProps)(domProps, hoverProps, {
26
+ role: 'tooltip'
27
+ })
28
+ };
29
+ }
30
+
31
+
32
+ export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip};
33
+ //# sourceMappingURL=useTooltip.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,cAAc,IAAM,kBAAA,4BAAA,MAAO,IAAI,CAAC;QAChC,YAAY,IAAM,kBAAA,4BAAA,MAAO,KAAK;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltip.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 {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\n"],"names":[],"version":3,"file":"useTooltip.module.js.map"}
@@ -0,0 +1,118 @@
1
+ var $jCY2B$reactariainteractions = require("@react-aria/interactions");
2
+ var $jCY2B$reactariautils = require("@react-aria/utils");
3
+ var $jCY2B$react = require("react");
4
+ var $jCY2B$reactariafocus = require("@react-aria/focus");
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, "useTooltipTrigger", () => $f017bbc46d58d42a$export$a6da6c504e4bba8b);
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */
23
+
24
+
25
+
26
+ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
27
+ let { isDisabled: isDisabled, trigger: trigger } = props;
28
+ let tooltipId = (0, $jCY2B$reactariautils.useId)();
29
+ let isHovered = (0, $jCY2B$react.useRef)(false);
30
+ let isFocused = (0, $jCY2B$react.useRef)(false);
31
+ let handleShow = ()=>{
32
+ if (isHovered.current || isFocused.current) state.open(isFocused.current);
33
+ };
34
+ let handleHide = (immediate)=>{
35
+ if (!isHovered.current && !isFocused.current) state.close(immediate);
36
+ };
37
+ (0, $jCY2B$react.useEffect)(()=>{
38
+ let onKeyDown = (e)=>{
39
+ if (ref && ref.current) // Escape after clicking something can give it keyboard focus
40
+ // dismiss tooltip on esc key press
41
+ {
42
+ if (e.key === 'Escape') {
43
+ e.stopPropagation();
44
+ state.close(true);
45
+ }
46
+ }
47
+ };
48
+ if (state.isOpen) {
49
+ document.addEventListener('keydown', onKeyDown, true);
50
+ return ()=>{
51
+ document.removeEventListener('keydown', onKeyDown, true);
52
+ };
53
+ }
54
+ }, [
55
+ ref,
56
+ state
57
+ ]);
58
+ let onHoverStart = ()=>{
59
+ if (trigger === 'focus') return;
60
+ // In chrome, if you hover a trigger, then another element obscures it, due to keyboard
61
+ // interactions for example, hover will end. When hover is restored after that element disappears,
62
+ // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
63
+ // is the result of moving the mouse.
64
+ if ((0, $jCY2B$reactariainteractions.getInteractionModality)() === 'pointer') isHovered.current = true;
65
+ else isHovered.current = false;
66
+ handleShow();
67
+ };
68
+ let onHoverEnd = ()=>{
69
+ if (trigger === 'focus') return;
70
+ // no matter how the trigger is left, we should close the tooltip
71
+ isFocused.current = false;
72
+ isHovered.current = false;
73
+ handleHide();
74
+ };
75
+ let onPressStart = ()=>{
76
+ // no matter how the trigger is pressed, we should close the tooltip
77
+ isFocused.current = false;
78
+ isHovered.current = false;
79
+ handleHide(true);
80
+ };
81
+ let onFocus = ()=>{
82
+ let isVisible = (0, $jCY2B$reactariainteractions.isFocusVisible)();
83
+ if (isVisible) {
84
+ isFocused.current = true;
85
+ handleShow();
86
+ }
87
+ };
88
+ let onBlur = ()=>{
89
+ isFocused.current = false;
90
+ isHovered.current = false;
91
+ handleHide(true);
92
+ };
93
+ let { hoverProps: hoverProps } = (0, $jCY2B$reactariainteractions.useHover)({
94
+ isDisabled: isDisabled,
95
+ onHoverStart: onHoverStart,
96
+ onHoverEnd: onHoverEnd
97
+ });
98
+ let { focusableProps: focusableProps } = (0, $jCY2B$reactariafocus.useFocusable)({
99
+ isDisabled: isDisabled,
100
+ onFocus: onFocus,
101
+ onBlur: onBlur
102
+ }, ref);
103
+ return {
104
+ triggerProps: {
105
+ 'aria-describedby': state.isOpen ? tooltipId : undefined,
106
+ ...(0, $jCY2B$reactariautils.mergeProps)(focusableProps, hoverProps, {
107
+ onPointerDown: onPressStart,
108
+ onKeyDown: onPressStart
109
+ })
110
+ },
111
+ tooltipProps: {
112
+ id: tooltipId
113
+ }
114
+ };
115
+ }
116
+
117
+
118
+ //# sourceMappingURL=useTooltipTrigger.main.js.map