@react-aria/tooltip 3.6.4 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +7 -11
- package/dist/main.js +7 -10
- package/dist/main.js.map +1 -1
- package/dist/module.js +7 -11
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/useTooltipTrigger.ts +7 -6
package/dist/import.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {filterDOMProps as $kgVYN$filterDOMProps, mergeProps as $kgVYN$mergeProps, useId as $kgVYN$useId} from "@react-aria/utils";
|
|
2
|
-
import {useHover as $kgVYN$useHover, getInteractionModality as $kgVYN$getInteractionModality, isFocusVisible as $kgVYN$isFocusVisible
|
|
2
|
+
import {useHover as $kgVYN$useHover, getInteractionModality as $kgVYN$getInteractionModality, isFocusVisible as $kgVYN$isFocusVisible} from "@react-aria/interactions";
|
|
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
|
|
|
@@ -30,12 +30,8 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
|
30
30
|
labelable: true
|
|
31
31
|
});
|
|
32
32
|
let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
|
|
33
|
-
onHoverStart: ()=>
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
onHoverEnd: ()=>{
|
|
37
|
-
return state === null || state === void 0 ? void 0 : state.close();
|
|
38
|
-
}
|
|
33
|
+
onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
|
|
34
|
+
onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
|
|
39
35
|
});
|
|
40
36
|
return {
|
|
41
37
|
tooltipProps: (0, $kgVYN$mergeProps)(domProps, hoverProps, {
|
|
@@ -131,9 +127,6 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
131
127
|
onHoverStart: onHoverStart,
|
|
132
128
|
onHoverEnd: onHoverEnd
|
|
133
129
|
});
|
|
134
|
-
let { pressProps: pressProps } = (0, $kgVYN$usePress)({
|
|
135
|
-
onPressStart: onPressStart
|
|
136
|
-
});
|
|
137
130
|
let { focusableProps: focusableProps } = (0, $kgVYN$useFocusable)({
|
|
138
131
|
isDisabled: isDisabled,
|
|
139
132
|
onFocus: onFocus,
|
|
@@ -142,7 +135,10 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
142
135
|
return {
|
|
143
136
|
triggerProps: {
|
|
144
137
|
"aria-describedby": state.isOpen ? tooltipId : undefined,
|
|
145
|
-
...(0, $kgVYN$mergeProps)(focusableProps, hoverProps,
|
|
138
|
+
...(0, $kgVYN$mergeProps)(focusableProps, hoverProps, {
|
|
139
|
+
onPointerDown: onPressStart,
|
|
140
|
+
onKeyDown: onPressStart
|
|
141
|
+
})
|
|
146
142
|
},
|
|
147
143
|
tooltipProps: {
|
|
148
144
|
id: tooltipId
|
package/dist/main.js
CHANGED
|
@@ -3,6 +3,7 @@ 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
|
+
|
|
6
7
|
function $parcel$export(e, n, v, s) {
|
|
7
8
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
9
|
}
|
|
@@ -36,12 +37,8 @@ function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
|
|
|
36
37
|
labelable: true
|
|
37
38
|
});
|
|
38
39
|
let { hoverProps: hoverProps } = (0, $aGFp5$reactariainteractions.useHover)({
|
|
39
|
-
onHoverStart: ()=>
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
onHoverEnd: ()=>{
|
|
43
|
-
return state === null || state === void 0 ? void 0 : state.close();
|
|
44
|
-
}
|
|
40
|
+
onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
|
|
41
|
+
onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
|
|
45
42
|
});
|
|
46
43
|
return {
|
|
47
44
|
tooltipProps: (0, $aGFp5$reactariautils.mergeProps)(domProps, hoverProps, {
|
|
@@ -137,9 +134,6 @@ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
137
134
|
onHoverStart: onHoverStart,
|
|
138
135
|
onHoverEnd: onHoverEnd
|
|
139
136
|
});
|
|
140
|
-
let { pressProps: pressProps } = (0, $aGFp5$reactariainteractions.usePress)({
|
|
141
|
-
onPressStart: onPressStart
|
|
142
|
-
});
|
|
143
137
|
let { focusableProps: focusableProps } = (0, $aGFp5$reactariafocus.useFocusable)({
|
|
144
138
|
isDisabled: isDisabled,
|
|
145
139
|
onFocus: onFocus,
|
|
@@ -148,7 +142,10 @@ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
148
142
|
return {
|
|
149
143
|
triggerProps: {
|
|
150
144
|
"aria-describedby": state.isOpen ? tooltipId : undefined,
|
|
151
|
-
...(0, $aGFp5$reactariautils.mergeProps)(focusableProps, hoverProps,
|
|
145
|
+
...(0, $aGFp5$reactariautils.mergeProps)(focusableProps, hoverProps, {
|
|
146
|
+
onPointerDown: onPressStart,
|
|
147
|
+
onKeyDown: onPressStart
|
|
148
|
+
})
|
|
152
149
|
},
|
|
153
150
|
tooltipProps: {
|
|
154
151
|
id: tooltipId
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,oC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CAAqC;QACrC,IAAI,CAAA,GAAA,mDAAqB,QAAQ,WAC/B,UAAU,OAAO,GAAG;aAEpB,UAAU,OAAO,GAAG;QAEtB;IACF;IAEA,IAAI,aAAa;QACf,IAAI,YAAY,SACd;QAEF,iEAAiE;QACjE,UAAU,OAAO,GAAG;QACpB,UAAU,OAAO,GAAG;QACpB;IACF;IAEA,IAAI,eAAe;QACjB,oEAAoE;QACpE,UAAU,OAAO,GAAG;QACpB,UAAU,OAAO,GAAG;QACpB,WAAW;IACb;IAEA,IAAI,UAAU;QACZ,IAAI,YAAY,CAAA,GAAA,2CAAa;QAC7B,IAAI,WAAW;YACb,UAAU,OAAO,GAAG;YACpB;QACF;IACF;IAEA,IAAI,SAAS;QACX,UAAU,OAAO,GAAG;QACpB,UAAU,OAAO,GAAG;QACpB,WAAW;IACb;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBAC1B;sBACA;oBACA;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE;oBAClC;iBACA;gBACA;IACF,GAAG;IAEH,OAAO;QACL,cAAc;YACZ,oBAAoB,MAAM,MAAM,GAAG,YAAY;YAC/C,GAAG,CAAA,GAAA,gCAAS,EAAE,gBAAgB,YAAY;gBACxC,eAAe;gBACf,WAAW;YACb,EAAE;QACJ;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF;","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} from '@react-types/shared';\nimport {getInteractionModality, isFocusVisible, useHover} 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';\n\nexport interface TooltipTriggerAria {\n /**\n * Props for the trigger element.\n */\n triggerProps: DOMAttributes,\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 e.stopPropagation();\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 {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, {\n onPointerDown: onPressStart,\n onKeyDown: onPressStart\n })\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {filterDOMProps as $kgVYN$filterDOMProps, mergeProps as $kgVYN$mergeProps, useId as $kgVYN$useId} from "@react-aria/utils";
|
|
2
|
-
import {useHover as $kgVYN$useHover, getInteractionModality as $kgVYN$getInteractionModality, isFocusVisible as $kgVYN$isFocusVisible
|
|
2
|
+
import {useHover as $kgVYN$useHover, getInteractionModality as $kgVYN$getInteractionModality, isFocusVisible as $kgVYN$isFocusVisible} from "@react-aria/interactions";
|
|
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
|
|
|
@@ -30,12 +30,8 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
|
30
30
|
labelable: true
|
|
31
31
|
});
|
|
32
32
|
let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
|
|
33
|
-
onHoverStart: ()=>
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
onHoverEnd: ()=>{
|
|
37
|
-
return state === null || state === void 0 ? void 0 : state.close();
|
|
38
|
-
}
|
|
33
|
+
onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
|
|
34
|
+
onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
|
|
39
35
|
});
|
|
40
36
|
return {
|
|
41
37
|
tooltipProps: (0, $kgVYN$mergeProps)(domProps, hoverProps, {
|
|
@@ -131,9 +127,6 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
131
127
|
onHoverStart: onHoverStart,
|
|
132
128
|
onHoverEnd: onHoverEnd
|
|
133
129
|
});
|
|
134
|
-
let { pressProps: pressProps } = (0, $kgVYN$usePress)({
|
|
135
|
-
onPressStart: onPressStart
|
|
136
|
-
});
|
|
137
130
|
let { focusableProps: focusableProps } = (0, $kgVYN$useFocusable)({
|
|
138
131
|
isDisabled: isDisabled,
|
|
139
132
|
onFocus: onFocus,
|
|
@@ -142,7 +135,10 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
|
|
|
142
135
|
return {
|
|
143
136
|
triggerProps: {
|
|
144
137
|
"aria-describedby": state.isOpen ? tooltipId : undefined,
|
|
145
|
-
...(0, $kgVYN$mergeProps)(focusableProps, hoverProps,
|
|
138
|
+
...(0, $kgVYN$mergeProps)(focusableProps, hoverProps, {
|
|
139
|
+
onPointerDown: onPressStart,
|
|
140
|
+
onKeyDown: onPressStart
|
|
141
|
+
})
|
|
146
142
|
},
|
|
147
143
|
tooltipProps: {
|
|
148
144
|
id: tooltipId
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO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M,EAAE;YAChB,SAAS,gBAAgB,CAAC,WAAW,WAAW;YAChD,OAAO;gBACL,SAAS,mBAAmB,CAAC,WAAW,WAAW;YACrD;QACF;IACF,GAAG;QAAC;QAAK;KAAM;IAEf,IAAI,eAAe;QACjB,IAAI,YAAY,SACd;QAEF,uFAAuF;QACvF,kGAAkG;QAClG,uGAAuG;QACvG,qCAAqC;QACrC,IAAI,CAAA,GAAA,6BAAqB,QAAQ,WAC/B,UAAU,OAAO,GAAG;aAEpB,UAAU,OAAO,GAAG;QAEtB;IACF;IAEA,IAAI,aAAa;QACf,IAAI,YAAY,SACd;QAEF,iEAAiE;QACjE,UAAU,OAAO,GAAG;QACpB,UAAU,OAAO,GAAG;QACpB;IACF;IAEA,IAAI,eAAe;QACjB,oEAAoE;QACpE,UAAU,OAAO,GAAG;QACpB,UAAU,OAAO,GAAG;QACpB,WAAW;IACb;IAEA,IAAI,UAAU;QACZ,IAAI,YAAY,CAAA,GAAA,qBAAa;QAC7B,IAAI,WAAW;YACb,UAAU,OAAO,GAAG;YACpB;QACF;IACF;IAEA,IAAI,SAAS;QACX,UAAU,OAAO,GAAG;QACpB,UAAU,OAAO,GAAG;QACpB,WAAW;IACb;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBAC1B;sBACA;oBACA;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE;oBAClC;iBACA;gBACA;IACF,GAAG;IAEH,OAAO;QACL,cAAc;YACZ,oBAAoB,MAAM,MAAM,GAAG,YAAY;YAC/C,GAAG,CAAA,GAAA,iBAAS,EAAE,gBAAgB,YAAY;gBACxC,eAAe;gBACf,WAAW;YACb,EAAE;QACJ;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF;","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} from '@react-types/shared';\nimport {getInteractionModality, isFocusVisible, useHover} 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';\n\nexport interface TooltipTriggerAria {\n /**\n * Props for the trigger element.\n */\n triggerProps: DOMAttributes,\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 e.stopPropagation();\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 {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, {\n onPointerDown: onPressStart,\n onKeyDown: onPressStart\n })\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AriaTooltipProps, TooltipTriggerProps } from "@react-types/tooltip";
|
|
2
|
-
import { DOMAttributes, FocusableElement
|
|
2
|
+
import { DOMAttributes, FocusableElement } from "@react-types/shared";
|
|
3
3
|
import { TooltipTriggerState } from "@react-stately/tooltip";
|
|
4
|
-
import { HoverProps, PressProps } from "@react-aria/interactions";
|
|
5
4
|
import { RefObject } from "react";
|
|
6
5
|
export interface TooltipAria {
|
|
7
6
|
/**
|
|
@@ -17,7 +16,7 @@ export interface TooltipTriggerAria {
|
|
|
17
16
|
/**
|
|
18
17
|
* Props for the trigger element.
|
|
19
18
|
*/
|
|
20
|
-
triggerProps: DOMAttributes
|
|
19
|
+
triggerProps: DOMAttributes;
|
|
21
20
|
/**
|
|
22
21
|
* Props for the overlay container element.
|
|
23
22
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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,CAAC,GAAI,kBAAkB,CAiH/I;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/tooltip",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/focus": "^3.
|
|
26
|
-
"@react-aria/interactions": "^3.
|
|
27
|
-
"@react-aria/utils": "^3.
|
|
28
|
-
"@react-stately/tooltip": "^3.4.
|
|
29
|
-
"@react-types/shared": "^3.
|
|
30
|
-
"@react-types/tooltip": "^3.4.
|
|
25
|
+
"@react-aria/focus": "^3.16.0",
|
|
26
|
+
"@react-aria/interactions": "^3.20.1",
|
|
27
|
+
"@react-aria/utils": "^3.23.0",
|
|
28
|
+
"@react-stately/tooltip": "^3.4.6",
|
|
29
|
+
"@react-types/shared": "^3.22.0",
|
|
30
|
+
"@react-types/tooltip": "^3.4.6",
|
|
31
31
|
"@swc/helpers": "^0.5.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "86b38c87868ce7f262e0df905e5ac4eb2653791d"
|
|
40
40
|
}
|
package/src/useTooltipTrigger.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {DOMAttributes, FocusableElement
|
|
14
|
-
import {getInteractionModality,
|
|
13
|
+
import {DOMAttributes, FocusableElement} from '@react-types/shared';
|
|
14
|
+
import {getInteractionModality, isFocusVisible, useHover} from '@react-aria/interactions';
|
|
15
15
|
import {mergeProps, useId} from '@react-aria/utils';
|
|
16
16
|
import {RefObject, useEffect, useRef} from 'react';
|
|
17
17
|
import {TooltipTriggerProps} from '@react-types/tooltip';
|
|
@@ -22,7 +22,7 @@ export interface TooltipTriggerAria {
|
|
|
22
22
|
/**
|
|
23
23
|
* Props for the trigger element.
|
|
24
24
|
*/
|
|
25
|
-
triggerProps: DOMAttributes
|
|
25
|
+
triggerProps: DOMAttributes,
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Props for the overlay container element.
|
|
@@ -129,8 +129,6 @@ export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTrig
|
|
|
129
129
|
onHoverEnd
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
let {pressProps} = usePress({onPressStart});
|
|
133
|
-
|
|
134
132
|
let {focusableProps} = useFocusable({
|
|
135
133
|
isDisabled,
|
|
136
134
|
onFocus,
|
|
@@ -140,7 +138,10 @@ export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTrig
|
|
|
140
138
|
return {
|
|
141
139
|
triggerProps: {
|
|
142
140
|
'aria-describedby': state.isOpen ? tooltipId : undefined,
|
|
143
|
-
...mergeProps(focusableProps, hoverProps,
|
|
141
|
+
...mergeProps(focusableProps, hoverProps, {
|
|
142
|
+
onPointerDown: onPressStart,
|
|
143
|
+
onKeyDown: onPressStart
|
|
144
|
+
})
|
|
144
145
|
},
|
|
145
146
|
tooltipProps: {
|
|
146
147
|
id: tooltipId
|