@react-aria/tooltip 3.9.2 → 3.10.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 CHANGED
@@ -1,5 +1,4 @@
1
- import {useTooltip as $326e436e94273fe1$export$1c4b08e0eca38426} from "./useTooltip.mjs";
2
- import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./useTooltipTrigger.mjs";
1
+ import {useTooltip as $9751a99326b0a0b1$re_export$useTooltip, useTooltipTrigger as $9751a99326b0a0b1$re_export$useTooltipTrigger} from "react-aria/useTooltipTrigger";
3
2
 
4
3
  /*
5
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -14,6 +13,5 @@ import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./
14
13
  */
15
14
 
16
15
 
17
-
18
- export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip, $4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
16
+ export {$9751a99326b0a0b1$re_export$useTooltip as useTooltip, $9751a99326b0a0b1$re_export$useTooltipTrigger as useTooltipTrigger};
19
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,13 +1,12 @@
1
- var $199fa2aaa84f20b7$exports = require("./useTooltip.main.js");
2
- var $f017bbc46d58d42a$exports = require("./useTooltipTrigger.main.js");
1
+ var $jBLb2$reactariauseTooltipTrigger = require("react-aria/useTooltipTrigger");
3
2
 
4
3
 
5
4
  function $parcel$export(e, n, v, s) {
6
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
6
  }
8
7
 
9
- $parcel$export(module.exports, "useTooltip", () => $199fa2aaa84f20b7$exports.useTooltip);
10
- $parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$exports.useTooltipTrigger);
8
+ $parcel$export(module.exports, "useTooltip", function () { return $jBLb2$reactariauseTooltipTrigger.useTooltip; });
9
+ $parcel$export(module.exports, "useTooltipTrigger", function () { return $jBLb2$reactariauseTooltipTrigger.useTooltipTrigger; });
11
10
  /*
12
11
  * Copyright 2020 Adobe. All rights reserved.
13
12
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -21,5 +20,4 @@ $parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$expo
21
20
  */
22
21
 
23
22
 
24
-
25
23
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTooltip, useTooltipTrigger} from 'react-aria/useTooltipTrigger';\n\nexport type {TooltipProps, AriaTooltipProps, TooltipAria, TooltipTriggerAria} from 'react-aria/useTooltipTrigger';\nexport type {TooltipTriggerProps} from 'react-stately/useTooltipTriggerState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,5 +1,4 @@
1
- import {useTooltip as $326e436e94273fe1$export$1c4b08e0eca38426} from "./useTooltip.module.js";
2
- import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./useTooltipTrigger.module.js";
1
+ import {useTooltip as $9751a99326b0a0b1$re_export$useTooltip, useTooltipTrigger as $9751a99326b0a0b1$re_export$useTooltipTrigger} from "react-aria/useTooltipTrigger";
3
2
 
4
3
  /*
5
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -14,6 +13,5 @@ import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./
14
13
  */
15
14
 
16
15
 
17
-
18
- export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip, $4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
16
+ export {$9751a99326b0a0b1$re_export$useTooltip as useTooltip, $9751a99326b0a0b1$re_export$useTooltipTrigger as useTooltipTrigger};
19
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTooltip, useTooltipTrigger} from 'react-aria/useTooltipTrigger';\n\nexport type {TooltipProps, AriaTooltipProps, TooltipAria, TooltipTriggerAria} from 'react-aria/useTooltipTrigger';\nexport type {TooltipTriggerProps} from 'react-stately/useTooltipTriggerState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,3 @@
1
+ export { useTooltip, useTooltipTrigger } from 'react-aria/useTooltipTrigger';
2
+ export type { TooltipProps, AriaTooltipProps, TooltipAria, TooltipTriggerAria } from 'react-aria/useTooltipTrigger';
3
+ export type { TooltipTriggerProps } from 'react-stately/useTooltipTriggerState';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-aria/tooltip",
3
- "version": "3.9.2",
3
+ "version": "3.10.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/import.mjs",
13
+ "require": "./dist/main.js"
14
+ },
15
+ "./package.json": "./package.json"
16
16
  },
17
- "types": "dist/types.d.ts",
17
+ "types": "dist/types/src/index.d.ts",
18
18
  "source": "src/index.ts",
19
19
  "files": [
20
20
  "dist",
@@ -26,12 +26,9 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-aria/interactions": "^3.27.1",
30
- "@react-aria/utils": "^3.33.1",
31
- "@react-stately/tooltip": "^3.5.11",
32
- "@react-types/shared": "^3.33.1",
33
- "@react-types/tooltip": "^3.5.2",
34
- "@swc/helpers": "^0.5.0"
29
+ "@swc/helpers": "^0.5.0",
30
+ "react-aria": "3.48.0",
31
+ "react-stately": "3.46.0"
35
32
  },
36
33
  "peerDependencies": {
37
34
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
@@ -40,5 +37,8 @@
40
37
  "publishConfig": {
41
38
  "access": "public"
42
39
  },
43
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
40
+ "targets": {
41
+ "types": false
42
+ },
43
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
44
44
  }
package/src/index.ts CHANGED
@@ -9,8 +9,7 @@
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
- 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';
12
+ export {useTooltip, useTooltipTrigger} from 'react-aria/useTooltipTrigger';
13
+
14
+ export type {TooltipProps, AriaTooltipProps, TooltipAria, TooltipTriggerAria} from 'react-aria/useTooltipTrigger';
15
+ export type {TooltipTriggerProps} from 'react-stately/useTooltipTriggerState';
package/dist/types.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import { AriaTooltipProps, TooltipTriggerProps } from "@react-types/tooltip";
2
- import { DOMAttributes, FocusableElement, RefObject } from "@react-types/shared";
3
- import { TooltipTriggerState } from "@react-stately/tooltip";
4
- export interface TooltipAria {
5
- /**
6
- * Props for the tooltip element.
7
- */
8
- tooltipProps: DOMAttributes;
9
- }
10
- /**
11
- * Provides the accessibility implementation for a Tooltip component.
12
- */
13
- export function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria;
14
- export interface TooltipTriggerAria {
15
- /**
16
- * Props for the trigger element.
17
- */
18
- triggerProps: DOMAttributes;
19
- /**
20
- * Props for the overlay container element.
21
- */
22
- tooltipProps: DOMAttributes;
23
- }
24
- /**
25
- * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button
26
- * that shows a description when focused or hovered.
27
- */
28
- export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement | null>): TooltipTriggerAria;
29
- export type { AriaTooltipProps, TooltipTriggerProps } from '@react-types/tooltip';
30
-
31
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
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;ACtBD;IACE;;OAEG;IACH,YAAY,EAAE,aAAa,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED;;;GAGG;AACH,kCAAkC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAI,kBAAkB,CAuHtJ;AC7ID,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"}
@@ -1,38 +0,0 @@
1
- var $1ztb7$reactariautils = require("@react-aria/utils");
2
- var $1ztb7$reactariainteractions = require("@react-aria/interactions");
3
-
4
-
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
-
9
- $parcel$export(module.exports, "useTooltip", () => $199fa2aaa84f20b7$export$1c4b08e0eca38426);
10
- /*
11
- * Copyright 2020 Adobe. All rights reserved.
12
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
13
- * you may not use this file except in compliance with the License. You may obtain a copy
14
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
15
- *
16
- * Unless required by applicable law or agreed to in writing, software distributed under
17
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
18
- * OF ANY KIND, either express or implied. See the License for the specific language
19
- * governing permissions and limitations under the License.
20
- */
21
-
22
- function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
23
- let domProps = (0, $1ztb7$reactariautils.filterDOMProps)(props, {
24
- labelable: true
25
- });
26
- let { hoverProps: hoverProps } = (0, $1ztb7$reactariainteractions.useHover)({
27
- onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
28
- onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
29
- });
30
- return {
31
- tooltipProps: (0, $1ztb7$reactariautils.mergeProps)(domProps, hoverProps, {
32
- role: 'tooltip'
33
- })
34
- };
35
- }
36
-
37
-
38
- //# sourceMappingURL=useTooltip.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,cAAc,IAAM,kBAAA,4BAAA,MAAO,IAAI,CAAC;QAChC,YAAY,IAAM,kBAAA,4BAAA,MAAO,KAAK;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltip.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\n"],"names":[],"version":3,"file":"useTooltip.main.js.map"}
@@ -1,33 +0,0 @@
1
- import {filterDOMProps as $kwmr2$filterDOMProps, mergeProps as $kwmr2$mergeProps} from "@react-aria/utils";
2
- import {useHover as $kwmr2$useHover} from "@react-aria/interactions";
3
-
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
-
16
- function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
17
- let domProps = (0, $kwmr2$filterDOMProps)(props, {
18
- labelable: true
19
- });
20
- let { hoverProps: hoverProps } = (0, $kwmr2$useHover)({
21
- onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
22
- onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
23
- });
24
- return {
25
- tooltipProps: (0, $kwmr2$mergeProps)(domProps, hoverProps, {
26
- role: 'tooltip'
27
- })
28
- };
29
- }
30
-
31
-
32
- export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip};
33
- //# sourceMappingURL=useTooltip.module.js.map
@@ -1,33 +0,0 @@
1
- import {filterDOMProps as $kwmr2$filterDOMProps, mergeProps as $kwmr2$mergeProps} from "@react-aria/utils";
2
- import {useHover as $kwmr2$useHover} from "@react-aria/interactions";
3
-
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
-
16
- function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
17
- let domProps = (0, $kwmr2$filterDOMProps)(props, {
18
- labelable: true
19
- });
20
- let { hoverProps: hoverProps } = (0, $kwmr2$useHover)({
21
- onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
22
- onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
23
- });
24
- return {
25
- tooltipProps: (0, $kwmr2$mergeProps)(domProps, hoverProps, {
26
- role: 'tooltip'
27
- })
28
- };
29
- }
30
-
31
-
32
- export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip};
33
- //# sourceMappingURL=useTooltip.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,cAAc,IAAM,kBAAA,4BAAA,MAAO,IAAI,CAAC;QAChC,YAAY,IAAM,kBAAA,4BAAA,MAAO,KAAK;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltip.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\n"],"names":[],"version":3,"file":"useTooltip.module.js.map"}
@@ -1,119 +0,0 @@
1
- var $jCY2B$reactariainteractions = require("@react-aria/interactions");
2
- var $jCY2B$reactariautils = require("@react-aria/utils");
3
- var $jCY2B$react = require("react");
4
-
5
-
6
- function $parcel$export(e, n, v, s) {
7
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
- }
9
-
10
- $parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$export$a6da6c504e4bba8b);
11
- /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */
22
-
23
-
24
- function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
25
- let { isDisabled: isDisabled, trigger: trigger, shouldCloseOnPress: shouldCloseOnPress = true } = props;
26
- let tooltipId = (0, $jCY2B$reactariautils.useId)();
27
- let isHovered = (0, $jCY2B$react.useRef)(false);
28
- let isFocused = (0, $jCY2B$react.useRef)(false);
29
- let handleShow = ()=>{
30
- if (isHovered.current || isFocused.current) state.open(isFocused.current);
31
- };
32
- let handleHide = (immediate)=>{
33
- if (!isHovered.current && !isFocused.current) state.close(immediate);
34
- };
35
- (0, $jCY2B$react.useEffect)(()=>{
36
- let onKeyDown = (e)=>{
37
- if (ref && ref.current) // Escape after clicking something can give it keyboard focus
38
- // dismiss tooltip on esc key press
39
- {
40
- if (e.key === 'Escape') {
41
- e.stopPropagation();
42
- state.close(true);
43
- }
44
- }
45
- };
46
- if (state.isOpen) {
47
- document.addEventListener('keydown', onKeyDown, true);
48
- return ()=>{
49
- document.removeEventListener('keydown', onKeyDown, true);
50
- };
51
- }
52
- }, [
53
- ref,
54
- state
55
- ]);
56
- let onHoverStart = ()=>{
57
- if (trigger === 'focus') return;
58
- // In chrome, if you hover a trigger, then another element obscures it, due to keyboard
59
- // interactions for example, hover will end. When hover is restored after that element disappears,
60
- // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
61
- // is the result of moving the mouse.
62
- if ((0, $jCY2B$reactariainteractions.getInteractionModality)() === 'pointer') isHovered.current = true;
63
- else isHovered.current = false;
64
- handleShow();
65
- };
66
- let onHoverEnd = ()=>{
67
- if (trigger === 'focus') return;
68
- // no matter how the trigger is left, we should close the tooltip
69
- isFocused.current = false;
70
- isHovered.current = false;
71
- handleHide();
72
- };
73
- let onPressStart = ()=>{
74
- // if shouldCloseOnPress is false, we should not close the tooltip
75
- if (!shouldCloseOnPress) return;
76
- // no matter how the trigger is pressed, we should close the tooltip
77
- isFocused.current = false;
78
- isHovered.current = false;
79
- handleHide(true);
80
- };
81
- let onFocus = ()=>{
82
- let isVisible = (0, $jCY2B$reactariainteractions.isFocusVisible)();
83
- if (isVisible) {
84
- isFocused.current = true;
85
- handleShow();
86
- }
87
- };
88
- let onBlur = ()=>{
89
- isFocused.current = false;
90
- isHovered.current = false;
91
- handleHide(true);
92
- };
93
- let { hoverProps: hoverProps } = (0, $jCY2B$reactariainteractions.useHover)({
94
- isDisabled: isDisabled,
95
- onHoverStart: onHoverStart,
96
- onHoverEnd: onHoverEnd
97
- });
98
- let { focusableProps: focusableProps } = (0, $jCY2B$reactariainteractions.useFocusable)({
99
- isDisabled: isDisabled,
100
- onFocus: onFocus,
101
- onBlur: onBlur
102
- }, ref);
103
- return {
104
- triggerProps: {
105
- 'aria-describedby': state.isOpen ? tooltipId : undefined,
106
- ...(0, $jCY2B$reactariautils.mergeProps)(focusableProps, hoverProps, {
107
- onPointerDown: onPressStart,
108
- onKeyDown: onPressStart
109
- }),
110
- tabIndex: undefined
111
- },
112
- tooltipProps: {
113
- id: tooltipId
114
- }
115
- };
116
- }
117
-
118
-
119
- //# sourceMappingURL=useTooltipTrigger.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAyBM,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAAuC;IAC/H,IAAI,cACF,UAAU,WACV,OAAO,sBACP,qBAAqB,MACtB,GAAG;IAEJ,IAAI,YAAY,CAAA,GAAA,2BAAI;IAEpB,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IACvB,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IAEvB,IAAI,aAAa;QACf,IAAI,UAAU,OAAO,IAAI,UAAU,OAAO,EACxC,MAAM,IAAI,CAAC,UAAU,OAAO;IAEhC;IAEA,IAAI,aAAa,CAAC;QAChB,IAAI,CAAC,UAAU,OAAO,IAAI,CAAC,UAAU,OAAO,EAC1C,MAAM,KAAK,CAAC;IAEhB;IAEA,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,YAAY,CAAC;YACf,IAAI,OAAO,IAAI,OAAO,EACpB,6DAA6D;YAC7D,mCAAmC;YACnC;gBAAA,IAAI,EAAE,GAAG,KAAK,UAAU;oBACtB,EAAE,eAAe;oBACjB,MAAM,KAAK,CAAC;gBACd;YAAA;QAEJ;QACA,IAAI,MAAM,MAAM,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,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,kEAAkE;QAClE,IAAI,CAAC,oBACH;QAEF,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,yCAAW,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;YACF,UAAU;QACZ;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltipTrigger.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {getInteractionModality, isFocusVisible, useFocusable, useHover} from '@react-aria/interactions';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {TooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useEffect, useRef} from 'react';\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 | null>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger,\n shouldCloseOnPress = true\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 // if shouldCloseOnPress is false, we should not close the tooltip\n if (!shouldCloseOnPress) {\n return;\n }\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 tabIndex: undefined\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"useTooltipTrigger.main.js.map"}
@@ -1,114 +0,0 @@
1
- import {getInteractionModality as $6VwSn$getInteractionModality, isFocusVisible as $6VwSn$isFocusVisible, useHover as $6VwSn$useHover, useFocusable as $6VwSn$useFocusable} from "@react-aria/interactions";
2
- import {useId as $6VwSn$useId, mergeProps as $6VwSn$mergeProps} from "@react-aria/utils";
3
- import {useRef as $6VwSn$useRef, useEffect as $6VwSn$useEffect} from "react";
4
-
5
- /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */
16
-
17
-
18
- function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
19
- let { isDisabled: isDisabled, trigger: trigger, shouldCloseOnPress: shouldCloseOnPress = true } = props;
20
- let tooltipId = (0, $6VwSn$useId)();
21
- let isHovered = (0, $6VwSn$useRef)(false);
22
- let isFocused = (0, $6VwSn$useRef)(false);
23
- let handleShow = ()=>{
24
- if (isHovered.current || isFocused.current) state.open(isFocused.current);
25
- };
26
- let handleHide = (immediate)=>{
27
- if (!isHovered.current && !isFocused.current) state.close(immediate);
28
- };
29
- (0, $6VwSn$useEffect)(()=>{
30
- let onKeyDown = (e)=>{
31
- if (ref && ref.current) // Escape after clicking something can give it keyboard focus
32
- // dismiss tooltip on esc key press
33
- {
34
- if (e.key === 'Escape') {
35
- e.stopPropagation();
36
- state.close(true);
37
- }
38
- }
39
- };
40
- if (state.isOpen) {
41
- document.addEventListener('keydown', onKeyDown, true);
42
- return ()=>{
43
- document.removeEventListener('keydown', onKeyDown, true);
44
- };
45
- }
46
- }, [
47
- ref,
48
- state
49
- ]);
50
- let onHoverStart = ()=>{
51
- if (trigger === 'focus') return;
52
- // In chrome, if you hover a trigger, then another element obscures it, due to keyboard
53
- // interactions for example, hover will end. When hover is restored after that element disappears,
54
- // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
55
- // is the result of moving the mouse.
56
- if ((0, $6VwSn$getInteractionModality)() === 'pointer') isHovered.current = true;
57
- else isHovered.current = false;
58
- handleShow();
59
- };
60
- let onHoverEnd = ()=>{
61
- if (trigger === 'focus') return;
62
- // no matter how the trigger is left, we should close the tooltip
63
- isFocused.current = false;
64
- isHovered.current = false;
65
- handleHide();
66
- };
67
- let onPressStart = ()=>{
68
- // if shouldCloseOnPress is false, we should not close the tooltip
69
- if (!shouldCloseOnPress) return;
70
- // no matter how the trigger is pressed, we should close the tooltip
71
- isFocused.current = false;
72
- isHovered.current = false;
73
- handleHide(true);
74
- };
75
- let onFocus = ()=>{
76
- let isVisible = (0, $6VwSn$isFocusVisible)();
77
- if (isVisible) {
78
- isFocused.current = true;
79
- handleShow();
80
- }
81
- };
82
- let onBlur = ()=>{
83
- isFocused.current = false;
84
- isHovered.current = false;
85
- handleHide(true);
86
- };
87
- let { hoverProps: hoverProps } = (0, $6VwSn$useHover)({
88
- isDisabled: isDisabled,
89
- onHoverStart: onHoverStart,
90
- onHoverEnd: onHoverEnd
91
- });
92
- let { focusableProps: focusableProps } = (0, $6VwSn$useFocusable)({
93
- isDisabled: isDisabled,
94
- onFocus: onFocus,
95
- onBlur: onBlur
96
- }, ref);
97
- return {
98
- triggerProps: {
99
- 'aria-describedby': state.isOpen ? tooltipId : undefined,
100
- ...(0, $6VwSn$mergeProps)(focusableProps, hoverProps, {
101
- onPointerDown: onPressStart,
102
- onKeyDown: onPressStart
103
- }),
104
- tabIndex: undefined
105
- },
106
- tooltipProps: {
107
- id: tooltipId
108
- }
109
- };
110
- }
111
-
112
-
113
- export {$4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
114
- //# sourceMappingURL=useTooltipTrigger.module.js.map
@@ -1,114 +0,0 @@
1
- import {getInteractionModality as $6VwSn$getInteractionModality, isFocusVisible as $6VwSn$isFocusVisible, useHover as $6VwSn$useHover, useFocusable as $6VwSn$useFocusable} from "@react-aria/interactions";
2
- import {useId as $6VwSn$useId, mergeProps as $6VwSn$mergeProps} from "@react-aria/utils";
3
- import {useRef as $6VwSn$useRef, useEffect as $6VwSn$useEffect} from "react";
4
-
5
- /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */
16
-
17
-
18
- function $4e1b34546679e357$export$a6da6c504e4bba8b(props, state, ref) {
19
- let { isDisabled: isDisabled, trigger: trigger, shouldCloseOnPress: shouldCloseOnPress = true } = props;
20
- let tooltipId = (0, $6VwSn$useId)();
21
- let isHovered = (0, $6VwSn$useRef)(false);
22
- let isFocused = (0, $6VwSn$useRef)(false);
23
- let handleShow = ()=>{
24
- if (isHovered.current || isFocused.current) state.open(isFocused.current);
25
- };
26
- let handleHide = (immediate)=>{
27
- if (!isHovered.current && !isFocused.current) state.close(immediate);
28
- };
29
- (0, $6VwSn$useEffect)(()=>{
30
- let onKeyDown = (e)=>{
31
- if (ref && ref.current) // Escape after clicking something can give it keyboard focus
32
- // dismiss tooltip on esc key press
33
- {
34
- if (e.key === 'Escape') {
35
- e.stopPropagation();
36
- state.close(true);
37
- }
38
- }
39
- };
40
- if (state.isOpen) {
41
- document.addEventListener('keydown', onKeyDown, true);
42
- return ()=>{
43
- document.removeEventListener('keydown', onKeyDown, true);
44
- };
45
- }
46
- }, [
47
- ref,
48
- state
49
- ]);
50
- let onHoverStart = ()=>{
51
- if (trigger === 'focus') return;
52
- // In chrome, if you hover a trigger, then another element obscures it, due to keyboard
53
- // interactions for example, hover will end. When hover is restored after that element disappears,
54
- // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
55
- // is the result of moving the mouse.
56
- if ((0, $6VwSn$getInteractionModality)() === 'pointer') isHovered.current = true;
57
- else isHovered.current = false;
58
- handleShow();
59
- };
60
- let onHoverEnd = ()=>{
61
- if (trigger === 'focus') return;
62
- // no matter how the trigger is left, we should close the tooltip
63
- isFocused.current = false;
64
- isHovered.current = false;
65
- handleHide();
66
- };
67
- let onPressStart = ()=>{
68
- // if shouldCloseOnPress is false, we should not close the tooltip
69
- if (!shouldCloseOnPress) return;
70
- // no matter how the trigger is pressed, we should close the tooltip
71
- isFocused.current = false;
72
- isHovered.current = false;
73
- handleHide(true);
74
- };
75
- let onFocus = ()=>{
76
- let isVisible = (0, $6VwSn$isFocusVisible)();
77
- if (isVisible) {
78
- isFocused.current = true;
79
- handleShow();
80
- }
81
- };
82
- let onBlur = ()=>{
83
- isFocused.current = false;
84
- isHovered.current = false;
85
- handleHide(true);
86
- };
87
- let { hoverProps: hoverProps } = (0, $6VwSn$useHover)({
88
- isDisabled: isDisabled,
89
- onHoverStart: onHoverStart,
90
- onHoverEnd: onHoverEnd
91
- });
92
- let { focusableProps: focusableProps } = (0, $6VwSn$useFocusable)({
93
- isDisabled: isDisabled,
94
- onFocus: onFocus,
95
- onBlur: onBlur
96
- }, ref);
97
- return {
98
- triggerProps: {
99
- 'aria-describedby': state.isOpen ? tooltipId : undefined,
100
- ...(0, $6VwSn$mergeProps)(focusableProps, hoverProps, {
101
- onPointerDown: onPressStart,
102
- onKeyDown: onPressStart
103
- }),
104
- tabIndex: undefined
105
- },
106
- tooltipProps: {
107
- id: tooltipId
108
- }
109
- };
110
- }
111
-
112
-
113
- export {$4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
114
- //# sourceMappingURL=useTooltipTrigger.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAyBM,SAAS,0CAAkB,KAA0B,EAAE,KAA0B,EAAE,GAAuC;IAC/H,IAAI,cACF,UAAU,WACV,OAAO,sBACP,qBAAqB,MACtB,GAAG;IAEJ,IAAI,YAAY,CAAA,GAAA,YAAI;IAEpB,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IAEvB,IAAI,aAAa;QACf,IAAI,UAAU,OAAO,IAAI,UAAU,OAAO,EACxC,MAAM,IAAI,CAAC,UAAU,OAAO;IAEhC;IAEA,IAAI,aAAa,CAAC;QAChB,IAAI,CAAC,UAAU,OAAO,IAAI,CAAC,UAAU,OAAO,EAC1C,MAAM,KAAK,CAAC;IAEhB;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,YAAY,CAAC;YACf,IAAI,OAAO,IAAI,OAAO,EACpB,6DAA6D;YAC7D,mCAAmC;YACnC;gBAAA,IAAI,EAAE,GAAG,KAAK,UAAU;oBACtB,EAAE,eAAe;oBACjB,MAAM,KAAK,CAAC;gBACd;YAAA;QAEJ;QACA,IAAI,MAAM,MAAM,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,kEAAkE;QAClE,IAAI,CAAC,oBACH;QAEF,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;YACF,UAAU;QACZ;QACA,cAAc;YACZ,IAAI;QACN;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltipTrigger.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {getInteractionModality, isFocusVisible, useFocusable, useHover} from '@react-aria/interactions';\nimport {mergeProps, useId} from '@react-aria/utils';\nimport {TooltipTriggerProps} from '@react-types/tooltip';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useEffect, useRef} from 'react';\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 | null>) : TooltipTriggerAria {\n let {\n isDisabled,\n trigger,\n shouldCloseOnPress = true\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 // if shouldCloseOnPress is false, we should not close the tooltip\n if (!shouldCloseOnPress) {\n return;\n }\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 tabIndex: undefined\n },\n tooltipProps: {\n id: tooltipId\n }\n };\n}\n"],"names":[],"version":3,"file":"useTooltipTrigger.module.js.map"}
package/src/useTooltip.ts DELETED
@@ -1,42 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {AriaTooltipProps} from '@react-types/tooltip';
14
- import {DOMAttributes} from '@react-types/shared';
15
- import {filterDOMProps, mergeProps} from '@react-aria/utils';
16
- import {TooltipTriggerState} from '@react-stately/tooltip';
17
- import {useHover} from '@react-aria/interactions';
18
-
19
- export interface TooltipAria {
20
- /**
21
- * Props for the tooltip element.
22
- */
23
- tooltipProps: DOMAttributes
24
- }
25
-
26
- /**
27
- * Provides the accessibility implementation for a Tooltip component.
28
- */
29
- export function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {
30
- let domProps = filterDOMProps(props, {labelable: true});
31
-
32
- let {hoverProps} = useHover({
33
- onHoverStart: () => state?.open(true),
34
- onHoverEnd: () => state?.close()
35
- });
36
-
37
- return {
38
- tooltipProps: mergeProps(domProps, hoverProps, {
39
- role: 'tooltip'
40
- })
41
- };
42
- }
@@ -1,155 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
14
- import {getInteractionModality, isFocusVisible, useFocusable, useHover} from '@react-aria/interactions';
15
- import {mergeProps, useId} from '@react-aria/utils';
16
- import {TooltipTriggerProps} from '@react-types/tooltip';
17
- import {TooltipTriggerState} from '@react-stately/tooltip';
18
- import {useEffect, useRef} from 'react';
19
-
20
- export interface TooltipTriggerAria {
21
- /**
22
- * Props for the trigger element.
23
- */
24
- triggerProps: DOMAttributes,
25
-
26
- /**
27
- * Props for the overlay container element.
28
- */
29
- tooltipProps: DOMAttributes
30
- }
31
-
32
- /**
33
- * Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button
34
- * that shows a description when focused or hovered.
35
- */
36
- export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement | null>) : TooltipTriggerAria {
37
- let {
38
- isDisabled,
39
- trigger,
40
- shouldCloseOnPress = true
41
- } = props;
42
-
43
- let tooltipId = useId();
44
-
45
- let isHovered = useRef(false);
46
- let isFocused = useRef(false);
47
-
48
- let handleShow = () => {
49
- if (isHovered.current || isFocused.current) {
50
- state.open(isFocused.current);
51
- }
52
- };
53
-
54
- let handleHide = (immediate?: boolean) => {
55
- if (!isHovered.current && !isFocused.current) {
56
- state.close(immediate);
57
- }
58
- };
59
-
60
- useEffect(() => {
61
- let onKeyDown = (e) => {
62
- if (ref && ref.current) {
63
- // Escape after clicking something can give it keyboard focus
64
- // dismiss tooltip on esc key press
65
- if (e.key === 'Escape') {
66
- e.stopPropagation();
67
- state.close(true);
68
- }
69
- }
70
- };
71
- if (state.isOpen) {
72
- document.addEventListener('keydown', onKeyDown, true);
73
- return () => {
74
- document.removeEventListener('keydown', onKeyDown, true);
75
- };
76
- }
77
- }, [ref, state]);
78
-
79
- let onHoverStart = () => {
80
- if (trigger === 'focus') {
81
- return;
82
- }
83
- // In chrome, if you hover a trigger, then another element obscures it, due to keyboard
84
- // interactions for example, hover will end. When hover is restored after that element disappears,
85
- // focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
86
- // is the result of moving the mouse.
87
- if (getInteractionModality() === 'pointer') {
88
- isHovered.current = true;
89
- } else {
90
- isHovered.current = false;
91
- }
92
- handleShow();
93
- };
94
-
95
- let onHoverEnd = () => {
96
- if (trigger === 'focus') {
97
- return;
98
- }
99
- // no matter how the trigger is left, we should close the tooltip
100
- isFocused.current = false;
101
- isHovered.current = false;
102
- handleHide();
103
- };
104
-
105
- let onPressStart = () => {
106
- // if shouldCloseOnPress is false, we should not close the tooltip
107
- if (!shouldCloseOnPress) {
108
- return;
109
- }
110
- // no matter how the trigger is pressed, we should close the tooltip
111
- isFocused.current = false;
112
- isHovered.current = false;
113
- handleHide(true);
114
- };
115
-
116
- let onFocus = () => {
117
- let isVisible = isFocusVisible();
118
- if (isVisible) {
119
- isFocused.current = true;
120
- handleShow();
121
- }
122
- };
123
-
124
- let onBlur = () => {
125
- isFocused.current = false;
126
- isHovered.current = false;
127
- handleHide(true);
128
- };
129
-
130
- let {hoverProps} = useHover({
131
- isDisabled,
132
- onHoverStart,
133
- onHoverEnd
134
- });
135
-
136
- let {focusableProps} = useFocusable({
137
- isDisabled,
138
- onFocus,
139
- onBlur
140
- }, ref);
141
-
142
- return {
143
- triggerProps: {
144
- 'aria-describedby': state.isOpen ? tooltipId : undefined,
145
- ...mergeProps(focusableProps, hoverProps, {
146
- onPointerDown: onPressStart,
147
- onKeyDown: onPressStart
148
- }),
149
- tabIndex: undefined
150
- },
151
- tooltipProps: {
152
- id: tooltipId
153
- }
154
- };
155
- }