@react-aria/tooltip 3.3.3 → 3.3.4

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
@@ -9,13 +9,33 @@ function $parcel$export(e, n, v, s) {
9
9
 
10
10
  $parcel$export(module.exports, "useTooltip", () => $199fa2aaa84f20b7$export$1c4b08e0eca38426);
11
11
  $parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$export$a6da6c504e4bba8b);
12
-
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
+ * Copyright 2020 Adobe. All rights reserved.
24
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
+ * you may not use this file except in compliance with the License. You may obtain a copy
26
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
+ *
28
+ * Unless required by applicable law or agreed to in writing, software distributed under
29
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
+ * OF ANY KIND, either express or implied. See the License for the specific language
31
+ * governing permissions and limitations under the License.
32
+ */
13
33
 
14
34
  function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
15
- let domProps = $aGFp5$reactariautils.filterDOMProps(props, {
35
+ let domProps = (0, $aGFp5$reactariautils.filterDOMProps)(props, {
16
36
  labelable: true
17
37
  });
18
- let { hoverProps: hoverProps } = $aGFp5$reactariainteractions.useHover({
38
+ let { hoverProps: hoverProps } = (0, $aGFp5$reactariainteractions.useHover)({
19
39
  onHoverStart: ()=>{
20
40
  return state === null || state === void 0 ? void 0 : state.open(true);
21
41
  },
@@ -24,41 +44,51 @@ function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
24
44
  }
25
45
  });
26
46
  return {
27
- tooltipProps: $aGFp5$reactariautils.mergeProps(domProps, hoverProps, {
28
- role: 'tooltip'
47
+ tooltipProps: (0, $aGFp5$reactariautils.mergeProps)(domProps, hoverProps, {
48
+ role: "tooltip"
29
49
  })
30
50
  };
31
51
  }
32
52
 
33
53
 
34
-
54
+ /*
55
+ * Copyright 2020 Adobe. All rights reserved.
56
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
57
+ * you may not use this file except in compliance with the License. You may obtain a copy
58
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
59
+ *
60
+ * Unless required by applicable law or agreed to in writing, software distributed under
61
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
62
+ * OF ANY KIND, either express or implied. See the License for the specific language
63
+ * governing permissions and limitations under the License.
64
+ */
35
65
 
36
66
 
37
67
 
38
68
 
39
69
  function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
40
70
  let { isDisabled: isDisabled , trigger: trigger } = props;
41
- let tooltipId = $aGFp5$reactariautils.useId();
42
- let isHovered = $aGFp5$react.useRef(false);
43
- let isFocused = $aGFp5$react.useRef(false);
71
+ let tooltipId = (0, $aGFp5$reactariautils.useId)();
72
+ let isHovered = (0, $aGFp5$react.useRef)(false);
73
+ let isFocused = (0, $aGFp5$react.useRef)(false);
44
74
  let handleShow = ()=>{
45
75
  if (isHovered.current || isFocused.current) state.open(isFocused.current);
46
76
  };
47
77
  let handleHide = (immediate)=>{
48
78
  if (!isHovered.current && !isFocused.current) state.close(immediate);
49
79
  };
50
- $aGFp5$react.useEffect(()=>{
80
+ (0, $aGFp5$react.useEffect)(()=>{
51
81
  let onKeyDown = (e)=>{
52
82
  if (ref && ref.current) // Escape after clicking something can give it keyboard focus
53
83
  // dismiss tooltip on esc key press
54
84
  {
55
- if (e.key === 'Escape') state.close(true);
85
+ if (e.key === "Escape") state.close(true);
56
86
  }
57
87
  };
58
88
  if (state.isOpen) {
59
- document.addEventListener('keydown', onKeyDown, true);
89
+ document.addEventListener("keydown", onKeyDown, true);
60
90
  return ()=>{
61
- document.removeEventListener('keydown', onKeyDown, true);
91
+ document.removeEventListener("keydown", onKeyDown, true);
62
92
  };
63
93
  }
64
94
  }, [
@@ -66,17 +96,17 @@ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
66
96
  state
67
97
  ]);
68
98
  let onHoverStart = ()=>{
69
- if (trigger === 'focus') return;
99
+ if (trigger === "focus") return;
70
100
  // In chrome, if you hover a trigger, then another element obscures it, due to keyboard
71
101
  // interactions for example, hover will end. When hover is restored after that element disappears,
72
102
  // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
73
103
  // is the result of moving the mouse.
74
- if ($aGFp5$reactariainteractions.getInteractionModality() === 'pointer') isHovered.current = true;
104
+ if ((0, $aGFp5$reactariainteractions.getInteractionModality)() === "pointer") isHovered.current = true;
75
105
  else isHovered.current = false;
76
106
  handleShow();
77
107
  };
78
108
  let onHoverEnd = ()=>{
79
- if (trigger === 'focus') return;
109
+ if (trigger === "focus") return;
80
110
  // no matter how the trigger is left, we should close the tooltip
81
111
  isFocused.current = false;
82
112
  isHovered.current = false;
@@ -89,7 +119,7 @@ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
89
119
  handleHide(true);
90
120
  };
91
121
  let onFocus = ()=>{
92
- let isVisible = $aGFp5$reactariainteractions.isFocusVisible();
122
+ let isVisible = (0, $aGFp5$reactariainteractions.isFocusVisible)();
93
123
  if (isVisible) {
94
124
  isFocused.current = true;
95
125
  handleShow();
@@ -100,23 +130,23 @@ function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
100
130
  isHovered.current = false;
101
131
  handleHide(true);
102
132
  };
103
- let { hoverProps: hoverProps } = $aGFp5$reactariainteractions.useHover({
133
+ let { hoverProps: hoverProps } = (0, $aGFp5$reactariainteractions.useHover)({
104
134
  isDisabled: isDisabled,
105
135
  onHoverStart: onHoverStart,
106
136
  onHoverEnd: onHoverEnd
107
137
  });
108
- let { pressProps: pressProps } = $aGFp5$reactariainteractions.usePress({
138
+ let { pressProps: pressProps } = (0, $aGFp5$reactariainteractions.usePress)({
109
139
  onPressStart: onPressStart
110
140
  });
111
- let { focusableProps: focusableProps } = $aGFp5$reactariafocus.useFocusable({
141
+ let { focusableProps: focusableProps } = (0, $aGFp5$reactariafocus.useFocusable)({
112
142
  isDisabled: isDisabled,
113
143
  onFocus: onFocus,
114
144
  onBlur: onBlur
115
145
  }, ref);
116
146
  return {
117
147
  triggerProps: {
118
- 'aria-describedby': state.isOpen ? tooltipId : undefined,
119
- ...$aGFp5$reactariautils.mergeProps(focusableProps, hoverProps, pressProps)
148
+ "aria-describedby": state.isOpen ? tooltipId : undefined,
149
+ ...(0, $aGFp5$reactariautils.mergeProps)(focusableProps, hoverProps, pressProps)
120
150
  },
121
151
  tooltipProps: {
122
152
  id: tooltipId
package/dist/main.js.map CHANGED
@@ -1 +1 @@
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,KAAK,KAAL,IAAI,CAAJ,CAAY,GAAZ,IAAI,CAAJ,CAAY,GAAZ,KAAK,CAAE,KAAK;;IA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AY;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"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;AAgBO,SAAS,0CAAW,KAAuB,EAAE,KAA2B,EAAe;IAC5F,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW,IAAI;IAAA;IAErD,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;QAC1B,cAAc;YAAM,OAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,IAAI,CAAC,IAAI;;QACpC,YAAY;YAAM,OAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,KAAK;;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,gCAAU,AAAD,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF;;CD/BC,GACD;AEXA;;;;;;;;;;CAUC,GAED;;;;;AAyBO,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAAgC,EAAuB;IAC/I,IAAI,cACF,WAAU,WACV,QAAO,EACR,GAAG;IAEJ,IAAI,YAAY,CAAA,GAAA,2BAAK,AAAD;IAEpB,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE,KAAK;IAC5B,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE,KAAK;IAE5B,IAAI,aAAa,IAAM;QACrB,IAAI,UAAU,OAAO,IAAI,UAAU,OAAO,EACxC,MAAM,IAAI,CAAC,UAAU,OAAO;IAEhC;IAEA,IAAI,aAAa,CAAC,YAAwB;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GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;oBAC1B;sBACA;oBACA;IACF;IAEA,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;sBAAC;IAAY;IAEzC,IAAI,kBAAC,eAAc,EAAC,GAAG,CAAA,GAAA,kCAAY,AAAD,EAAE;oBAClC;iBACA;gBACA;IACF,GAAG;IAEH,OAAO;QACL,cAAc;YACZ,oBAAoB,MAAM,MAAM,GAAG,YAAY,SAAS;YACxD,GAAG,CAAA,GAAA,gCAAS,EAAE,gBAAgB,YAAY,WAAW;QACvD;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, 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,13 +3,33 @@ 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
-
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
7
27
 
8
28
  function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
9
- let domProps = $kgVYN$filterDOMProps(props, {
29
+ let domProps = (0, $kgVYN$filterDOMProps)(props, {
10
30
  labelable: true
11
31
  });
12
- let { hoverProps: hoverProps } = $kgVYN$useHover({
32
+ let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
13
33
  onHoverStart: ()=>{
14
34
  return state === null || state === void 0 ? void 0 : state.open(true);
15
35
  },
@@ -18,41 +38,51 @@ function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
18
38
  }
19
39
  });
20
40
  return {
21
- tooltipProps: $kgVYN$mergeProps(domProps, hoverProps, {
22
- role: 'tooltip'
41
+ tooltipProps: (0, $kgVYN$mergeProps)(domProps, hoverProps, {
42
+ role: "tooltip"
23
43
  })
24
44
  };
25
45
  }
26
46
 
27
47
 
28
-
48
+ /*
49
+ * Copyright 2020 Adobe. All rights reserved.
50
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
51
+ * you may not use this file except in compliance with the License. You may obtain a copy
52
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
53
+ *
54
+ * Unless required by applicable law or agreed to in writing, software distributed under
55
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
56
+ * OF ANY KIND, either express or implied. See the License for the specific language
57
+ * governing permissions and limitations under the License.
58
+ */
29
59
 
30
60
 
31
61
 
32
62
 
33
63
  function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
34
64
  let { isDisabled: isDisabled , trigger: trigger } = props;
35
- let tooltipId = $kgVYN$useId();
36
- let isHovered = $kgVYN$useRef(false);
37
- let isFocused = $kgVYN$useRef(false);
65
+ let tooltipId = (0, $kgVYN$useId)();
66
+ let isHovered = (0, $kgVYN$useRef)(false);
67
+ let isFocused = (0, $kgVYN$useRef)(false);
38
68
  let handleShow = ()=>{
39
69
  if (isHovered.current || isFocused.current) state.open(isFocused.current);
40
70
  };
41
71
  let handleHide = (immediate)=>{
42
72
  if (!isHovered.current && !isFocused.current) state.close(immediate);
43
73
  };
44
- $kgVYN$useEffect(()=>{
74
+ (0, $kgVYN$useEffect)(()=>{
45
75
  let onKeyDown = (e)=>{
46
76
  if (ref && ref.current) // Escape after clicking something can give it keyboard focus
47
77
  // dismiss tooltip on esc key press
48
78
  {
49
- if (e.key === 'Escape') state.close(true);
79
+ if (e.key === "Escape") state.close(true);
50
80
  }
51
81
  };
52
82
  if (state.isOpen) {
53
- document.addEventListener('keydown', onKeyDown, true);
83
+ document.addEventListener("keydown", onKeyDown, true);
54
84
  return ()=>{
55
- document.removeEventListener('keydown', onKeyDown, true);
85
+ document.removeEventListener("keydown", onKeyDown, true);
56
86
  };
57
87
  }
58
88
  }, [
@@ -60,17 +90,17 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
60
90
  state
61
91
  ]);
62
92
  let onHoverStart = ()=>{
63
- if (trigger === 'focus') return;
93
+ if (trigger === "focus") return;
64
94
  // In chrome, if you hover a trigger, then another element obscures it, due to keyboard
65
95
  // interactions for example, hover will end. When hover is restored after that element disappears,
66
96
  // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
67
97
  // is the result of moving the mouse.
68
- if ($kgVYN$getInteractionModality() === 'pointer') isHovered.current = true;
98
+ if ((0, $kgVYN$getInteractionModality)() === "pointer") isHovered.current = true;
69
99
  else isHovered.current = false;
70
100
  handleShow();
71
101
  };
72
102
  let onHoverEnd = ()=>{
73
- if (trigger === 'focus') return;
103
+ if (trigger === "focus") return;
74
104
  // no matter how the trigger is left, we should close the tooltip
75
105
  isFocused.current = false;
76
106
  isHovered.current = false;
@@ -83,7 +113,7 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
83
113
  handleHide(true);
84
114
  };
85
115
  let onFocus = ()=>{
86
- let isVisible = $kgVYN$isFocusVisible();
116
+ let isVisible = (0, $kgVYN$isFocusVisible)();
87
117
  if (isVisible) {
88
118
  isFocused.current = true;
89
119
  handleShow();
@@ -94,23 +124,23 @@ function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
94
124
  isHovered.current = false;
95
125
  handleHide(true);
96
126
  };
97
- let { hoverProps: hoverProps } = $kgVYN$useHover({
127
+ let { hoverProps: hoverProps } = (0, $kgVYN$useHover)({
98
128
  isDisabled: isDisabled,
99
129
  onHoverStart: onHoverStart,
100
130
  onHoverEnd: onHoverEnd
101
131
  });
102
- let { pressProps: pressProps } = $kgVYN$usePress({
132
+ let { pressProps: pressProps } = (0, $kgVYN$usePress)({
103
133
  onPressStart: onPressStart
104
134
  });
105
- let { focusableProps: focusableProps } = $kgVYN$useFocusable({
135
+ let { focusableProps: focusableProps } = (0, $kgVYN$useFocusable)({
106
136
  isDisabled: isDisabled,
107
137
  onFocus: onFocus,
108
138
  onBlur: onBlur
109
139
  }, ref);
110
140
  return {
111
141
  triggerProps: {
112
- 'aria-describedby': state.isOpen ? tooltipId : undefined,
113
- ...$kgVYN$mergeProps(focusableProps, hoverProps, pressProps)
142
+ "aria-describedby": state.isOpen ? tooltipId : undefined,
143
+ ...(0, $kgVYN$mergeProps)(focusableProps, hoverProps, pressProps)
114
144
  },
115
145
  tooltipProps: {
116
146
  id: tooltipId
@@ -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,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,y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AC,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 */\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"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;AAgBO,SAAS,0CAAW,KAAuB,EAAE,KAA2B,EAAe;IAC5F,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW,IAAI;IAAA;IAErD,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,eAAQ,AAAD,EAAE;QAC1B,cAAc;YAAM,OAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,IAAI,CAAC,IAAI;;QACpC,YAAY;YAAM,OAAA,kBAAA,mBAAA,KAAA,IAAA,MAAO,KAAK;;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,iBAAU,AAAD,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF;;CD/BC,GACD;AEXA;;;;;;;;;;CAUC,GAED;;;;;AAyBO,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAAgC,EAAuB;IAC/I,IAAI,cACF,WAAU,WACV,QAAO,EACR,GAAG;IAEJ,IAAI,YAAY,CAAA,GAAA,YAAK,AAAD;IAEpB,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE,KAAK;IAC5B,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE,KAAK;IAE5B,IAAI,aAAa,IAAM;QACrB,IAAI,UAAU,OAAO,IAAI,UAAU,OAAO,EACxC,MAAM,IAAI,CAAC,UAAU,OAAO;IAEhC;IAEA,IAAI,aAAa,CAAC,YAAwB;QACxC,IAAI,CAAC,UAAU,OAAO,IAAI,CAAC,UAAU,OAAO,EAC1C,MAAM,KAAK,CAAC;IAEhB;IAEA,CAAA,GAAA,gBAAS,AAAD,EAAE,IAAM;QACd,IAAI,YAAY,CAAC,IAAM;YACrB,IAAI,OAAO,IAAI,OAA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,GAAA,mBAAY,AAAD,EAAE;oBAClC;iBACA;gBACA;IACF,GAAG;IAEH,OAAO;QACL,cAAc;YACZ,oBAAoB,MAAM,MAAM,GAAG,YAAY,SAAS;YACxD,GAAG,CAAA,GAAA,iBAAS,EAAE,gBAAgB,YAAY,WAAW;QACvD;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, 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/tooltip",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -17,13 +17,13 @@
17
17
  "url": "https://github.com/adobe/react-spectrum"
18
18
  },
19
19
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/focus": "^3.10.0",
22
- "@react-aria/interactions": "^3.13.0",
23
- "@react-aria/utils": "^3.14.1",
24
- "@react-stately/tooltip": "^3.2.3",
20
+ "@react-aria/focus": "^3.10.1",
21
+ "@react-aria/interactions": "^3.13.1",
22
+ "@react-aria/utils": "^3.14.2",
23
+ "@react-stately/tooltip": "^3.2.4",
25
24
  "@react-types/shared": "^3.16.0",
26
- "@react-types/tooltip": "^3.2.5"
25
+ "@react-types/tooltip": "^3.2.5",
26
+ "@swc/helpers": "^0.4.14"
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": "2954307ddbefe149241685440c81f80ece6b2c83"
34
+ "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
35
35
  }