@react-aria/tooltip 3.2.0 → 3.3.1

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/main.js CHANGED
@@ -3,28 +3,12 @@ var $aGFp5$reactariainteractions = require("@react-aria/interactions");
3
3
  var $aGFp5$react = require("react");
4
4
  var $aGFp5$reactariafocus = require("@react-aria/focus");
5
5
 
6
- function $parcel$exportWildcard(dest, source) {
7
- Object.keys(source).forEach(function(key) {
8
- if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
9
- return;
10
- }
11
-
12
- Object.defineProperty(dest, key, {
13
- enumerable: true,
14
- get: function get() {
15
- return source[key];
16
- }
17
- });
18
- });
19
-
20
- return dest;
21
- }
22
6
  function $parcel$export(e, n, v, s) {
23
7
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
24
8
  }
25
- var $199fa2aaa84f20b7$exports = {};
26
9
 
27
- $parcel$export($199fa2aaa84f20b7$exports, "useTooltip", () => $199fa2aaa84f20b7$export$1c4b08e0eca38426);
10
+ $parcel$export(module.exports, "useTooltip", () => $199fa2aaa84f20b7$export$1c4b08e0eca38426);
11
+ $parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$export$a6da6c504e4bba8b);
28
12
 
29
13
 
30
14
  function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
@@ -47,9 +31,6 @@ function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
47
31
  }
48
32
 
49
33
 
50
- var $f017bbc46d58d42a$exports = {};
51
-
52
- $parcel$export($f017bbc46d58d42a$exports, "useTooltipTrigger", () => $f017bbc46d58d42a$export$a6da6c504e4bba8b);
53
34
 
54
35
 
55
36
 
@@ -144,8 +125,6 @@ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
144
125
  }
145
126
 
146
127
 
147
- $parcel$exportWildcard(module.exports, $199fa2aaa84f20b7$exports);
148
- $parcel$exportWildc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AO,GAAG,KAAK;QACzB,UAAU;IACZ,CAAC;IAED,GAAG,CAAC,YAAY,OAAS,CAAC;QACxB,EAAoE,AAApE,kEAAoE;QACpE,SAAS,CAAC,OAAO,GAAG,KAAK;QACzB,SAAS,CAAC,OAAO,GAAG,KAAK;QACzB,UAAU,CAAC,IAAI;IACjB,CAAC;IAED,GAAG,CAAC,OAAO,OAAS,CAAC;QACnB,GAAG,CAAC,SAAS,GAAG,2CAAc;QAC9B,EAAE,EAAE,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,OAAO,GAAG,IAAI;YACxB,UAAU;QACZ,CAAC;IACH,CAAC;IAED,GAAG,CAAC,MAAM,OAAS,CAAC;QAClB,SAAS,CAAC,OAAO,GAAG,KAAK;QACzB,SAAS,CAAC,OAAO,GAAG,KAAK;QACzB,UAAU,CAAC,IAAI;IACjB,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;oBAC3B,UAAU;sBACV,YAAY;oBACZ,UAAU;IACZ,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;sBAAA,YAAY;IAAA,CAAC;IAE1C,GAAG,CAAC,CAAC,iBAAA,cAAc,EAAA,CAAC,GAAG,kCAAY,CAAC,CAAC;oBACnC,UAAU;iBACV,OAAO;gBACP,MAAM;IACR,CAAC,EAAE,GAAG;IAEN,MAAM,CAAC,CAAC;QACN,YAAY,EAAE,CAAC;YACb,CAAkB,mBAAE,KAAK,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS;eACrD,gCAAU,CAAC,cAAc,EAAE,UAAU,EAAE,UAAU;QACtD,CAAC;QACD,YAAY,EAAE,CAAC;YACb,EAAE,EAAE,SAAS;QACf,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/tooltip/src/index.ts","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\nexport * from './useTooltip';\nexport * from './useTooltipTrigger';\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} from '@react-aria/utils';\nimport {HTMLAttributes} from 'react';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\ninterface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: HTMLAttributes<HTMLElement>\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","/*\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 {getInteractionModality, HoverProps, isFocusVisible, PressProps, usePress} from '@react-aria/interactions';\nimport {HTMLAttributes, RefObject, useEffect, useRef} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {TooltipTriggerProps} 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 /**\n * Props for the trigger element.\n */\n triggerProps: HTMLAttributes<HTMLElement> & PressProps & HoverProps & FocusEvents,\n\n /**\n * Props for the overlay container element.\n */\n tooltipProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button\n * that shows a description when focused or hovered.\n */\nexport function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<HTMLElement>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n if (isHovered.current || isFocused.current) {\n state.open(isFocused.current);\n }\n };\n\n let handleHide = (immediate?: boolean) => {\n if (!isHovered.current && !isFocused.current) {\n state.close(immediate);\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(true);\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown, true);\n return () => {\n document.removeEventListener('keydown', onKeyDown, true);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n if (trigger === 'focus') {\n return;\n }\n // In chrome, if you hover a trigger, then another element obscures it, due to keyboard\n // interactions for example, hover will end. When hover is restored after that element disappears,\n // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover\n // is the result of moving the mouse.\n if (getInteractionModality() === 'pointer') {\n isHovered.current = true;\n } else {\n isHovered.current = false;\n }\n handleShow();\n };\n\n let onHoverEnd = () => {\n if (trigger === 'focus') {\n return;\n }\n // no matter how the trigger is left, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide();\n };\n\n let onPressStart = () => {\n // no matter how the trigger is pressed, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n\n let onBlur = () => {\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\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.isOpen ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;SC4BgB,yCAAU,CAAC,KAAuB,EAAE,KAA2B,EAAe,CAAC;IAC7F,GAAG,CAAC,QAAQ,GAAG,oCAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEtD,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;QAC3B,YAAY;mBAAQ,KAAK,aAAL,KAAK,KAAL,IAAI,CAAJ,CAAW,GAAX,IAAI,CAAJ,CAAW,GAAX,KAAK,CAAE,IAAI,CAAC,IAAI;;QACpC,UAAU;mBAAQ,KAAK,aAAL,KA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AAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;oBAC3B,UAAU;sBACV,YAAY;oBACZ,UAAU;IACZ,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;sBAAA,YAAY;IAAA,CAAC;IAE1C,GAAG,CAAC,CAAC,iBAAA,cAAc,EAAA,CAAC,GAAG,kCAAY,CAAC,CAAC;oBACnC,UAAU;iBACV,OAAO;gBACP,MAAM;IACR,CAAC,EAAE,GAAG;IAEN,MAAM,CAAC,CAAC;QACN,YAAY,EAAE,CAAC;YACb,CAAkB,mBAAE,KAAK,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS;eACrD,gCAAU,CAAC,cAAc,EAAE,UAAU,EAAE,UAAU;QACtD,CAAC;QACD,YAAY,EAAE,CAAC;YACb,EAAE,EAAE,SAAS;QACf,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/tooltip/src/index.ts","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 */\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","/*\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","/*\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 {DOMAttributes, FocusableElement, FocusEvents} from '@react-types/shared';\nimport {getInteractionModality, HoverProps, isFocusVisible, PressProps, usePress} from '@react-aria/interactions';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {TooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useFocusable} from '@react-aria/focus';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipTriggerAria {\n /**\n * Props for the trigger element.\n */\n triggerProps: DOMAttributes & PressProps & HoverProps & FocusEvents,\n\n /**\n * Props for the overlay container element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button\n * that shows a description when focused or hovered.\n */\nexport function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n if (isHovered.current || isFocused.current) {\n state.open(isFocused.current);\n }\n };\n\n let handleHide = (immediate?: boolean) => {\n if (!isHovered.current && !isFocused.current) {\n state.close(immediate);\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(true);\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown, true);\n return () => {\n document.removeEventListener('keydown', onKeyDown, true);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n if (trigger === 'focus') {\n return;\n }\n // In chrome, if you hover a trigger, then another element obscures it, due to keyboard\n // interactions for example, hover will end. When hover is restored after that element disappears,\n // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover\n // is the result of moving the mouse.\n if (getInteractionModality() === 'pointer') {\n isHovered.current = true;\n } else {\n isHovered.current = false;\n }\n handleShow();\n };\n\n let onHoverEnd = () => {\n if (trigger === 'focus') {\n return;\n }\n // no matter how the trigger is left, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide();\n };\n\n let onPressStart = () => {\n // no matter how the trigger is pressed, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n\n let onBlur = () => {\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\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.isOpen ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -3,12 +3,6 @@ import {useHover as $kgVYN$useHover, getInteractionModality as $kgVYN$getInterac
3
3
  import {useRef as $kgVYN$useRef, useEffect as $kgVYN$useEffect} from "react";
4
4
  import {useFocusable as $kgVYN$useFocusable} from "@react-aria/focus";
5
5
 
6
- function $parcel$export(e, n, v, s) {
7
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
- }
9
- var $326e436e94273fe1$exports = {};
10
-
11
- $parcel$export($326e436e94273fe1$exports, "useTooltip", () => $326e436e94273fe1$export$1c4b08e0eca38426);
12
6
 
13
7
 
14
8
  function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
@@ -31,9 +25,6 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
31
25
  }
32
26
 
33
27
 
34
- var $4e1b34546679e357$exports = {};
35
-
36
- $parcel$export($4e1b34546679e357$exports, "useTooltipTrigger", () => $4e1b34546679e357$export$a6da6c504e4bba8b);
37
28
 
38
29
 
39
30
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;SC4BgB,yCAAU,CAAC,KAAuB,EAAE,KAA2B,EAAe,CAAC;IAC7F,GAAG,CAAC,QAAQ,GAAG,qBAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEtD,GAAG,CAAC,CAAC,aAAA,U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O,GAAG,IAAI;YACxB,UAAU;QACZ,CAAC;IACH,CAAC;IAED,GAAG,CAAC,MAAM,OAAS,CAAC;QAClB,SAAS,CAAC,OAAO,GAAG,KAAK;QACzB,SAAS,CAAC,OAAO,GAAG,KAAK;QACzB,UAAU,CAAC,IAAI;IACjB,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,eAAQ,CAAC,CAAC;oBAC3B,UAAU;sBACV,YAAY;oBACZ,UAAU;IACZ,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,eAAQ,CAAC,CAAC;sBAAA,YAAY;IAAA,CAAC;IAE1C,GAAG,CAAC,CAAC,iBAAA,cAAc,EAAA,CAAC,GAAG,mBAAY,CAAC,CAAC;oBACnC,UAAU;iBACV,OAAO;gBACP,MAAM;IACR,CAAC,EAAE,GAAG;IAEN,MAAM,CAAC,CAAC;QACN,YAAY,EAAE,CAAC;YACb,CAAkB,mBAAE,KAAK,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS;eACrD,iBAAU,CAAC,cAAc,EAAE,UAAU,EAAE,UAAU;QACtD,CAAC;QACD,YAAY,EAAE,CAAC;YACb,EAAE,EAAE,SAAS;QACf,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/tooltip/src/index.ts","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\nexport * from './useTooltip';\nexport * from './useTooltipTrigger';\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} from '@react-aria/utils';\nimport {HTMLAttributes} from 'react';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\ninterface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: HTMLAttributes<HTMLElement>\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","/*\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 {getInteractionModality, HoverProps, isFocusVisible, PressProps, usePress} from '@react-aria/interactions';\nimport {HTMLAttributes, RefObject, useEffect, useRef} from 'react';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {TooltipTriggerProps} 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 /**\n * Props for the trigger element.\n */\n triggerProps: HTMLAttributes<HTMLElement> & PressProps & HoverProps & FocusEvents,\n\n /**\n * Props for the overlay container element.\n */\n tooltipProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button\n * that shows a description when focused or hovered.\n */\nexport function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<HTMLElement>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n if (isHovered.current || isFocused.current) {\n state.open(isFocused.current);\n }\n };\n\n let handleHide = (immediate?: boolean) => {\n if (!isHovered.current && !isFocused.current) {\n state.close(immediate);\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(true);\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown, true);\n return () => {\n document.removeEventListener('keydown', onKeyDown, true);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n if (trigger === 'focus') {\n return;\n }\n // In chrome, if you hover a trigger, then another element obscures it, due to keyboard\n // interactions for example, hover will end. When hover is restored after that element disappears,\n // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover\n // is the result of moving the mouse.\n if (getInteractionModality() === 'pointer') {\n isHovered.current = true;\n } else {\n isHovered.current = false;\n }\n handleShow();\n };\n\n let onHoverEnd = () => {\n if (trigger === 'focus') {\n return;\n }\n // no matter how the trigger is left, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide();\n };\n\n let onPressStart = () => {\n // no matter how the trigger is pressed, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n\n let onBlur = () => {\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\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.isOpen ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;SC4BgB,yCAAU,CAAC,KAAuB,EAAE,KAA2B,EAAe,CAAC;IAC7F,GAAG,CAAC,QAAQ,GAAG,qBAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEtD,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,eAAQ,CAAC,CAAC;QAC3B,YAAY;mBAAQ,KAAK,aAAL,KAAK,KAAL,IAAI,CAAJ,CAAW,GAAX,IAAI,CAAJ,CAAW,GAAX,KAAK,CAAE,IAAI,CAAC,IAAI;;QACpC,UAAU;mBAAQ,KAAK,aAAL,KAAK,KAAL,IAAI,CAAJ,CAAY,GAAZ,IAAI,CAAJ,CAAY,GAAZ,KAAK,CAAE,KAAK;;IAChC,CAAC;IAED,MAAM,CAAC,CAAC;QACN,YAAY,EAAE,iBAAU,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;YAC9C,IAAI,EAAE,CAAS;QACjB,CAAC;IACH,CAAC;AACH,CAAC;;;;;;;;SCJe,yCAAiB,CAAC,KAA0B,EAAE,KAA0B,EAAE,GAAgC,EAAuB,CAAC;IAChJ,GAAG,CAAC,CAAC,aACH,UAAU,YAC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M,CAAC,CAAC;QACN,YAAY,EAAE,CAAC;YACb,CAAkB,mBAAE,KAAK,CAAC,MAAM,GAAG,SAAS,GAAG,SAAS;eACrD,iBAAU,CAAC,cAAc,EAAE,UAAU,EAAE,UAAU;QACtD,CAAC;QACD,YAAY,EAAE,CAAC;YACb,EAAE,EAAE,SAAS;QACf,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/tooltip/src/index.ts","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 */\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","/*\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","/*\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 {DOMAttributes, FocusableElement, FocusEvents} from '@react-types/shared';\nimport {getInteractionModality, HoverProps, isFocusVisible, PressProps, usePress} from '@react-aria/interactions';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {TooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useFocusable} from '@react-aria/focus';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipTriggerAria {\n /**\n * Props for the trigger element.\n */\n triggerProps: DOMAttributes & PressProps & HoverProps & FocusEvents,\n\n /**\n * Props for the overlay container element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button\n * that shows a description when focused or hovered.\n */\nexport function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger\n } = props;\n\n let tooltipId = useId();\n\n let isHovered = useRef(false);\n let isFocused = useRef(false);\n\n let handleShow = () => {\n if (isHovered.current || isFocused.current) {\n state.open(isFocused.current);\n }\n };\n\n let handleHide = (immediate?: boolean) => {\n if (!isHovered.current && !isFocused.current) {\n state.close(immediate);\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(true);\n }\n }\n };\n if (state.isOpen) {\n document.addEventListener('keydown', onKeyDown, true);\n return () => {\n document.removeEventListener('keydown', onKeyDown, true);\n };\n }\n }, [ref, state]);\n\n let onHoverStart = () => {\n if (trigger === 'focus') {\n return;\n }\n // In chrome, if you hover a trigger, then another element obscures it, due to keyboard\n // interactions for example, hover will end. When hover is restored after that element disappears,\n // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover\n // is the result of moving the mouse.\n if (getInteractionModality() === 'pointer') {\n isHovered.current = true;\n } else {\n isHovered.current = false;\n }\n handleShow();\n };\n\n let onHoverEnd = () => {\n if (trigger === 'focus') {\n return;\n }\n // no matter how the trigger is left, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide();\n };\n\n let onPressStart = () => {\n // no matter how the trigger is pressed, we should close the tooltip\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\n };\n\n let onFocus = () => {\n let isVisible = isFocusVisible();\n if (isVisible) {\n isFocused.current = true;\n handleShow();\n }\n };\n\n let onBlur = () => {\n isFocused.current = false;\n isHovered.current = false;\n handleHide(true);\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.isOpen ? tooltipId : undefined,\n ...mergeProps(focusableProps, hoverProps, pressProps)\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,32 +1,33 @@
1
1
  import { AriaTooltipProps, TooltipTriggerProps } from "@react-types/tooltip";
2
- import { HTMLAttributes, RefObject } from "react";
2
+ import { DOMAttributes, FocusableElement, FocusEvents } from "@react-types/shared";
3
3
  import { TooltipTriggerState } from "@react-stately/tooltip";
4
- import { FocusEvents } from "@react-types/shared";
5
4
  import { HoverProps, PressProps } from "@react-aria/interactions";
6
- interface TooltipAria {
5
+ import { RefObject } from "react";
6
+ export interface TooltipAria {
7
7
  /**
8
8
  * Props for the tooltip element.
9
9
  */
10
- tooltipProps: HTMLAttributes<HTMLElement>;
10
+ tooltipProps: DOMAttributes;
11
11
  }
12
12
  /**
13
13
  * Provides the accessibility implementation for a Tooltip component.
14
14
  */
15
15
  export function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria;
16
- interface TooltipTriggerAria {
16
+ export interface TooltipTriggerAria {
17
17
  /**
18
18
  * Props for the trigger element.
19
19
  */
20
- triggerProps: HTMLAttributes<HTMLElement> & PressProps & HoverProps & FocusEvents;
20
+ triggerProps: DOMAttributes & PressProps & HoverProps & FocusEvents;
21
21
  /**
22
22
  * Props for the overlay container element.
23
23
  */
24
- tooltipProps: HTMLAttributes<HTMLElement>;
24
+ tooltipProps: DOMAttributes;
25
25
  }
26
26
  /**
27
27
  * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button
28
28
  * that shows a description when focused or hovered.
29
29
  */
30
- export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<HTMLElement>): TooltipTriggerAria;
30
+ export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement>): TooltipTriggerAria;
31
+ export type { AriaTooltipProps, TooltipTriggerProps } from '@react-types/tooltip';
31
32
 
32
33
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;;;AAkBA;IACE;;OAEG;IACH,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAED;;GAEG;AACH,2BAA2B,KAAK,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAa5F;ACpBD;IACE;;OAEG;IACH,YAAY,EAAE,eAAe,WAAW,CAAC,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;IAElF;;OAEG;IACH,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAED;;;GAGG;AACH,kCAAkC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAI,kBAAkB,CA+G1I","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 */\n\nexport * from './useTooltip';\nexport * from './useTooltipTrigger';\n"],"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;ACpBD;IACE;;OAEG;IACH,YAAY,EAAE,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;IAEpE;;OAEG;IACH,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED;;;GAGG;AACH,kCAAkC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAI,kBAAkB,CA+G/I;ACvID,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/tooltip",
3
- "version": "3.2.0",
3
+ "version": "3.3.1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,12 +18,12 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-aria/focus": "^3.6.0",
22
- "@react-aria/interactions": "^3.9.0",
23
- "@react-aria/utils": "^3.13.0",
24
- "@react-stately/tooltip": "^3.1.0",
25
- "@react-types/shared": "^3.13.0",
26
- "@react-types/tooltip": "^3.2.0"
21
+ "@react-aria/focus": "^3.8.0",
22
+ "@react-aria/interactions": "^3.11.0",
23
+ "@react-aria/utils": "^3.13.3",
24
+ "@react-stately/tooltip": "^3.2.1",
25
+ "@react-types/shared": "^3.14.1",
26
+ "@react-types/tooltip": "^3.2.3"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "8f921ec5094e7c2b3c301bcb6133372e35a2052b"
34
+ "gitHead": "b03ef51e6317547dd0a840f151e59d039b1e1fd3"
35
35
  }
package/src/index.ts CHANGED
@@ -9,6 +9,8 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- export * from './useTooltip';
14
- export * from './useTooltipTrigger';
12
+ export {useTooltip} from './useTooltip';
13
+ export {useTooltipTrigger} from './useTooltipTrigger';
14
+ export type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';
15
+ export type {TooltipAria} from './useTooltip';
16
+ export type {TooltipTriggerAria} from './useTooltipTrigger';
package/src/useTooltip.ts CHANGED
@@ -11,16 +11,16 @@
11
11
  */
12
12
 
13
13
  import {AriaTooltipProps} from '@react-types/tooltip';
14
+ import {DOMAttributes} from '@react-types/shared';
14
15
  import {filterDOMProps, mergeProps} from '@react-aria/utils';
15
- import {HTMLAttributes} from 'react';
16
16
  import {TooltipTriggerState} from '@react-stately/tooltip';
17
17
  import {useHover} from '@react-aria/interactions';
18
18
 
19
- interface TooltipAria {
19
+ export interface TooltipAria {
20
20
  /**
21
21
  * Props for the tooltip element.
22
22
  */
23
- tooltipProps: HTMLAttributes<HTMLElement>
23
+ tooltipProps: DOMAttributes
24
24
  }
25
25
 
26
26
  /**
@@ -10,32 +10,32 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {FocusEvents} from '@react-types/shared';
13
+ import {DOMAttributes, FocusableElement, FocusEvents} from '@react-types/shared';
14
14
  import {getInteractionModality, HoverProps, isFocusVisible, PressProps, usePress} from '@react-aria/interactions';
15
- import {HTMLAttributes, RefObject, useEffect, useRef} from 'react';
16
15
  import {mergeProps, useId} from '@react-aria/utils';
16
+ import {RefObject, useEffect, useRef} from 'react';
17
17
  import {TooltipTriggerProps} from '@react-types/tooltip';
18
18
  import {TooltipTriggerState} from '@react-stately/tooltip';
19
19
  import {useFocusable} from '@react-aria/focus';
20
20
  import {useHover} from '@react-aria/interactions';
21
21
 
22
- interface TooltipTriggerAria {
22
+ export interface TooltipTriggerAria {
23
23
  /**
24
24
  * Props for the trigger element.
25
25
  */
26
- triggerProps: HTMLAttributes<HTMLElement> & PressProps & HoverProps & FocusEvents,
26
+ triggerProps: DOMAttributes & PressProps & HoverProps & FocusEvents,
27
27
 
28
28
  /**
29
29
  * Props for the overlay container element.
30
30
  */
31
- tooltipProps: HTMLAttributes<HTMLElement>
31
+ tooltipProps: DOMAttributes
32
32
  }
33
33
 
34
34
  /**
35
35
  * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button
36
36
  * that shows a description when focused or hovered.
37
37
  */
38
- export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<HTMLElement>) : TooltipTriggerAria {
38
+ export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement>) : TooltipTriggerAria {
39
39
  let {
40
40
  isDisabled,
41
41
  trigger