@react-aria/tooltip 3.0.0-alpha.0 → 3.0.0-nightly-641446f65-240905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +19 -0
- package/dist/main.js +17 -135
- package/dist/main.js.map +1 -1
- package/dist/module.js +14 -111
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +26 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/useTooltip.main.js +38 -0
- package/dist/useTooltip.main.js.map +1 -0
- package/dist/useTooltip.mjs +33 -0
- package/dist/useTooltip.module.js +33 -0
- package/dist/useTooltip.module.js.map +1 -0
- package/dist/useTooltipTrigger.main.js +118 -0
- package/dist/useTooltipTrigger.main.js.map +1 -0
- package/dist/useTooltipTrigger.mjs +113 -0
- package/dist/useTooltipTrigger.module.js +113 -0
- package/dist/useTooltipTrigger.module.js.map +1 -0
- package/package.json +16 -12
- package/src/index.ts +5 -3
- package/src/useTooltip.ts +20 -13
- package/src/useTooltipTrigger.ts +62 -26
- package/LICENSE +0 -201
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {useTooltip as $326e436e94273fe1$export$1c4b08e0eca38426} from "./useTooltip.mjs";
|
|
2
|
+
import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./useTooltipTrigger.mjs";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip, $4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
|
|
19
|
+
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,143 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
} = require("@react-aria/focus");
|
|
1
|
+
var $199fa2aaa84f20b7$exports = require("./useTooltip.main.js");
|
|
2
|
+
var $f017bbc46d58d42a$exports = require("./useTooltipTrigger.main.js");
|
|
4
3
|
|
|
5
|
-
var {
|
|
6
|
-
useEffect,
|
|
7
|
-
useRef
|
|
8
|
-
} = require("react");
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
usePress,
|
|
13
|
-
useHover
|
|
14
|
-
} = require("@react-aria/interactions");
|
|
15
|
-
|
|
16
|
-
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
17
|
-
|
|
18
|
-
var {
|
|
19
|
-
filterDOMProps,
|
|
20
|
-
mergeProps,
|
|
21
|
-
useId
|
|
22
|
-
} = require("@react-aria/utils");
|
|
23
|
-
|
|
24
|
-
function $parcel$interopDefault(a) {
|
|
25
|
-
return a && a.__esModule ? a.default : a;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function useTooltip(props) {
|
|
29
|
-
let {
|
|
30
|
-
id,
|
|
31
|
-
role = 'tooltip'
|
|
32
|
-
} = props;
|
|
33
|
-
let domProps = filterDOMProps(props);
|
|
34
|
-
return {
|
|
35
|
-
tooltipProps: mergeProps(domProps, {
|
|
36
|
-
role,
|
|
37
|
-
id: useId(id)
|
|
38
|
-
})
|
|
39
|
-
};
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
40
7
|
}
|
|
41
8
|
|
|
42
|
-
exports
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
let handleHide = () => {
|
|
57
|
-
if (!isHovered.current && !isFocused.current) {
|
|
58
|
-
state.close();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
let onKeyDown = e => {
|
|
64
|
-
if (ref && ref.current) {
|
|
65
|
-
// Escape after clicking something can give it keyboard focus
|
|
66
|
-
// dismiss tooltip on esc key press
|
|
67
|
-
if (e.key === 'Escape') {
|
|
68
|
-
state.close();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
9
|
+
$parcel$export(module.exports, "useTooltip", () => $199fa2aaa84f20b7$exports.useTooltip);
|
|
10
|
+
$parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$exports.useTooltipTrigger);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
72
22
|
|
|
73
|
-
if (state.isOpen) {
|
|
74
|
-
document.addEventListener('keydown', onKeyDown);
|
|
75
|
-
return () => {
|
|
76
|
-
document.removeEventListener('keydown', onKeyDown);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}, [ref, state]);
|
|
80
23
|
|
|
81
|
-
let onHoverStart = () => {
|
|
82
|
-
isHovered.current = true;
|
|
83
|
-
handleShow();
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
let onHoverEnd = () => {
|
|
87
|
-
isHovered.current = false;
|
|
88
|
-
handleHide();
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
let onPressStart = () => {
|
|
92
|
-
if (isFocused.current) {
|
|
93
|
-
isFocused.current = false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
handleHide();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
let onFocus = () => {
|
|
100
|
-
let isVisible = isFocusVisible();
|
|
101
|
-
|
|
102
|
-
if (isVisible) {
|
|
103
|
-
isFocused.current = true;
|
|
104
|
-
handleShow();
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
let onBlur = () => {
|
|
109
|
-
isFocused.current = false;
|
|
110
|
-
handleHide();
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
let {
|
|
114
|
-
hoverProps
|
|
115
|
-
} = useHover({
|
|
116
|
-
isDisabled,
|
|
117
|
-
onHoverStart,
|
|
118
|
-
onHoverEnd
|
|
119
|
-
});
|
|
120
|
-
let {
|
|
121
|
-
pressProps
|
|
122
|
-
} = usePress({
|
|
123
|
-
onPressStart
|
|
124
|
-
});
|
|
125
|
-
let {
|
|
126
|
-
focusableProps
|
|
127
|
-
} = useFocusable({
|
|
128
|
-
isDisabled,
|
|
129
|
-
onFocus,
|
|
130
|
-
onBlur
|
|
131
|
-
}, ref);
|
|
132
|
-
return {
|
|
133
|
-
triggerProps: _babelRuntimeHelpersExtends({
|
|
134
|
-
'aria-describedby': state.open ? tooltipId : undefined
|
|
135
|
-
}, mergeProps(focusableProps, hoverProps, pressProps)),
|
|
136
|
-
tooltipProps: {
|
|
137
|
-
id: tooltipId
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
24
|
|
|
142
|
-
exports.useTooltipTrigger = useTooltipTrigger;
|
|
143
25
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,116 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { isFocusVisible, usePress, useHover } from "@react-aria/interactions";
|
|
4
|
-
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
import { filterDOMProps, mergeProps, useId } from "@react-aria/utils";
|
|
6
|
-
export function useTooltip(props) {
|
|
7
|
-
let {
|
|
8
|
-
id,
|
|
9
|
-
role = 'tooltip'
|
|
10
|
-
} = props;
|
|
11
|
-
let domProps = filterDOMProps(props);
|
|
12
|
-
return {
|
|
13
|
-
tooltipProps: mergeProps(domProps, {
|
|
14
|
-
role,
|
|
15
|
-
id: useId(id)
|
|
16
|
-
})
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export function useTooltipTrigger(props, state, ref) {
|
|
20
|
-
let {
|
|
21
|
-
isDisabled
|
|
22
|
-
} = props;
|
|
23
|
-
let tooltipId = useId();
|
|
24
|
-
let isHovered = useRef(false);
|
|
25
|
-
let isFocused = useRef(false);
|
|
1
|
+
import {useTooltip as $326e436e94273fe1$export$1c4b08e0eca38426} from "./useTooltip.module.js";
|
|
2
|
+
import {useTooltipTrigger as $4e1b34546679e357$export$a6da6c504e4bba8b} from "./useTooltipTrigger.module.js";
|
|
26
3
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
30
15
|
|
|
31
|
-
let handleHide = () => {
|
|
32
|
-
if (!isHovered.current && !isFocused.current) {
|
|
33
|
-
state.close();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
16
|
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
let onKeyDown = e => {
|
|
39
|
-
if (ref && ref.current) {
|
|
40
|
-
// Escape after clicking something can give it keyboard focus
|
|
41
|
-
// dismiss tooltip on esc key press
|
|
42
|
-
if (e.key === 'Escape') {
|
|
43
|
-
state.close();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
17
|
|
|
48
|
-
|
|
49
|
-
document.addEventListener('keydown', onKeyDown);
|
|
50
|
-
return () => {
|
|
51
|
-
document.removeEventListener('keydown', onKeyDown);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}, [ref, state]);
|
|
55
|
-
|
|
56
|
-
let onHoverStart = () => {
|
|
57
|
-
isHovered.current = true;
|
|
58
|
-
handleShow();
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
let onHoverEnd = () => {
|
|
62
|
-
isHovered.current = false;
|
|
63
|
-
handleHide();
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
let onPressStart = () => {
|
|
67
|
-
if (isFocused.current) {
|
|
68
|
-
isFocused.current = false;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
handleHide();
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
let onFocus = () => {
|
|
75
|
-
let isVisible = isFocusVisible();
|
|
76
|
-
|
|
77
|
-
if (isVisible) {
|
|
78
|
-
isFocused.current = true;
|
|
79
|
-
handleShow();
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
let onBlur = () => {
|
|
84
|
-
isFocused.current = false;
|
|
85
|
-
handleHide();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
let {
|
|
89
|
-
hoverProps
|
|
90
|
-
} = useHover({
|
|
91
|
-
isDisabled,
|
|
92
|
-
onHoverStart,
|
|
93
|
-
onHoverEnd
|
|
94
|
-
});
|
|
95
|
-
let {
|
|
96
|
-
pressProps
|
|
97
|
-
} = usePress({
|
|
98
|
-
onPressStart
|
|
99
|
-
});
|
|
100
|
-
let {
|
|
101
|
-
focusableProps
|
|
102
|
-
} = useFocusable({
|
|
103
|
-
isDisabled,
|
|
104
|
-
onFocus,
|
|
105
|
-
onBlur
|
|
106
|
-
}, ref);
|
|
107
|
-
return {
|
|
108
|
-
triggerProps: _babelRuntimeHelpersEsmExtends({
|
|
109
|
-
'aria-describedby': state.open ? tooltipId : undefined
|
|
110
|
-
}, mergeProps(focusableProps, hoverProps, pressProps)),
|
|
111
|
-
tooltipProps: {
|
|
112
|
-
id: tooltipId
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
18
|
+
export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip, $4e1b34546679e357$export$a6da6c504e4bba8b as useTooltipTrigger};
|
|
116
19
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
import { AriaTooltipProps,
|
|
2
|
-
import {
|
|
3
|
-
import { FocusEvents } from "@react-types/shared";
|
|
4
|
-
import { HoverProps, PressProps } from "@react-aria/interactions";
|
|
1
|
+
import { AriaTooltipProps, TooltipTriggerProps } from "@react-types/tooltip";
|
|
2
|
+
import { DOMAttributes, FocusableElement, RefObject } from "@react-types/shared";
|
|
5
3
|
import { TooltipTriggerState } from "@react-stately/tooltip";
|
|
6
|
-
interface TooltipAria {
|
|
7
|
-
|
|
4
|
+
export interface TooltipAria {
|
|
5
|
+
/**
|
|
6
|
+
* Props for the tooltip element.
|
|
7
|
+
*/
|
|
8
|
+
tooltipProps: DOMAttributes;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Provides the accessibility implementation for a Tooltip component.
|
|
12
|
+
*/
|
|
13
|
+
export function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria;
|
|
14
|
+
export interface TooltipTriggerAria {
|
|
15
|
+
/**
|
|
16
|
+
* Props for the trigger element.
|
|
17
|
+
*/
|
|
18
|
+
triggerProps: DOMAttributes;
|
|
19
|
+
/**
|
|
20
|
+
* Props for the overlay container element.
|
|
21
|
+
*/
|
|
22
|
+
tooltipProps: DOMAttributes;
|
|
13
23
|
}
|
|
14
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Provides the behavior and accessibility implementation for a tooltip trigger, e.g. a button
|
|
26
|
+
* that shows a description when focused or hovered.
|
|
27
|
+
*/
|
|
28
|
+
export function useTooltipTrigger(props: TooltipTriggerProps, state: TooltipTriggerState, ref: RefObject<FocusableElement | null>): TooltipTriggerAria;
|
|
29
|
+
export type { AriaTooltipProps, TooltipTriggerProps } from '@react-types/tooltip';
|
|
15
30
|
|
|
16
31
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;AAkBA;IACE;;OAEG;IACH,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED;;GAEG;AACH,2BAA2B,KAAK,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAa5F;ACrBD;IACE;;OAEG;IACH,YAAY,EAAE,aAAa,CAAC;IAE5B;;OAEG;IACH,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED;;;GAGG;AACH,kCAAkC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAI,kBAAkB,CAiHtJ;ACxID,YAAY,EAAC,gBAAgB,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC","sources":["packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/useTooltip.ts","packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/useTooltipTrigger.ts","packages/@react-aria/tooltip/src/packages/@react-aria/tooltip/src/index.ts","packages/@react-aria/tooltip/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTooltip} from './useTooltip';\nexport {useTooltipTrigger} from './useTooltipTrigger';\nexport type {AriaTooltipProps, TooltipTriggerProps} from '@react-types/tooltip';\nexport type {TooltipAria} from './useTooltip';\nexport type {TooltipTriggerAria} from './useTooltipTrigger';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var $1ztb7$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $1ztb7$reactariainteractions = require("@react-aria/interactions");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useTooltip", () => $199fa2aaa84f20b7$export$1c4b08e0eca38426);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function $199fa2aaa84f20b7$export$1c4b08e0eca38426(props, state) {
|
|
23
|
+
let domProps = (0, $1ztb7$reactariautils.filterDOMProps)(props, {
|
|
24
|
+
labelable: true
|
|
25
|
+
});
|
|
26
|
+
let { hoverProps: hoverProps } = (0, $1ztb7$reactariainteractions.useHover)({
|
|
27
|
+
onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
|
|
28
|
+
onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
tooltipProps: (0, $1ztb7$reactariautils.mergeProps)(domProps, hoverProps, {
|
|
32
|
+
role: 'tooltip'
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=useTooltip.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,cAAc,IAAM,kBAAA,4BAAA,MAAO,IAAI,CAAC;QAChC,YAAY,IAAM,kBAAA,4BAAA,MAAO,KAAK;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,gCAAS,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltip.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\n"],"names":[],"version":3,"file":"useTooltip.main.js.map"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {filterDOMProps as $kwmr2$filterDOMProps, mergeProps as $kwmr2$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {useHover as $kwmr2$useHover} from "@react-aria/interactions";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
17
|
+
let domProps = (0, $kwmr2$filterDOMProps)(props, {
|
|
18
|
+
labelable: true
|
|
19
|
+
});
|
|
20
|
+
let { hoverProps: hoverProps } = (0, $kwmr2$useHover)({
|
|
21
|
+
onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
|
|
22
|
+
onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
tooltipProps: (0, $kwmr2$mergeProps)(domProps, hoverProps, {
|
|
26
|
+
role: 'tooltip'
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip};
|
|
33
|
+
//# sourceMappingURL=useTooltip.module.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {filterDOMProps as $kwmr2$filterDOMProps, mergeProps as $kwmr2$mergeProps} from "@react-aria/utils";
|
|
2
|
+
import {useHover as $kwmr2$useHover} from "@react-aria/interactions";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $326e436e94273fe1$export$1c4b08e0eca38426(props, state) {
|
|
17
|
+
let domProps = (0, $kwmr2$filterDOMProps)(props, {
|
|
18
|
+
labelable: true
|
|
19
|
+
});
|
|
20
|
+
let { hoverProps: hoverProps } = (0, $kwmr2$useHover)({
|
|
21
|
+
onHoverStart: ()=>state === null || state === void 0 ? void 0 : state.open(true),
|
|
22
|
+
onHoverEnd: ()=>state === null || state === void 0 ? void 0 : state.close()
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
tooltipProps: (0, $kwmr2$mergeProps)(domProps, hoverProps, {
|
|
26
|
+
role: 'tooltip'
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export {$326e436e94273fe1$export$1c4b08e0eca38426 as useTooltip};
|
|
33
|
+
//# sourceMappingURL=useTooltip.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAkBM,SAAS,0CAAW,KAAuB,EAAE,KAA2B;IAC7E,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,cAAc,IAAM,kBAAA,4BAAA,MAAO,IAAI,CAAC;QAChC,YAAY,IAAM,kBAAA,4BAAA,MAAO,KAAK;IAChC;IAEA,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,EAAE,UAAU,YAAY;YAC7C,MAAM;QACR;IACF;AACF","sources":["packages/@react-aria/tooltip/src/useTooltip.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTooltipProps} from '@react-types/tooltip';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TooltipTriggerState} from '@react-stately/tooltip';\nimport {useHover} from '@react-aria/interactions';\n\nexport interface TooltipAria {\n /**\n * Props for the tooltip element.\n */\n tooltipProps: DOMAttributes\n}\n\n/**\n * Provides the accessibility implementation for a Tooltip component.\n */\nexport function useTooltip(props: AriaTooltipProps, state?: TooltipTriggerState): TooltipAria {\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {hoverProps} = useHover({\n onHoverStart: () => state?.open(true),\n onHoverEnd: () => state?.close()\n });\n\n return {\n tooltipProps: mergeProps(domProps, hoverProps, {\n role: 'tooltip'\n })\n };\n}\n"],"names":[],"version":3,"file":"useTooltip.module.js.map"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var $jCY2B$reactariainteractions = require("@react-aria/interactions");
|
|
2
|
+
var $jCY2B$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $jCY2B$react = require("react");
|
|
4
|
+
var $jCY2B$reactariafocus = require("@react-aria/focus");
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function $parcel$export(e, n, v, s) {
|
|
8
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
$parcel$export(module.exports, "useTooltipTrigger", () => $f017bbc46d58d42a$export$a6da6c504e4bba8b);
|
|
12
|
+
/*
|
|
13
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
14
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
16
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
19
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
20
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
21
|
+
* governing permissions and limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function $f017bbc46d58d42a$export$a6da6c504e4bba8b(props, state, ref) {
|
|
27
|
+
let { isDisabled: isDisabled, trigger: trigger } = props;
|
|
28
|
+
let tooltipId = (0, $jCY2B$reactariautils.useId)();
|
|
29
|
+
let isHovered = (0, $jCY2B$react.useRef)(false);
|
|
30
|
+
let isFocused = (0, $jCY2B$react.useRef)(false);
|
|
31
|
+
let handleShow = ()=>{
|
|
32
|
+
if (isHovered.current || isFocused.current) state.open(isFocused.current);
|
|
33
|
+
};
|
|
34
|
+
let handleHide = (immediate)=>{
|
|
35
|
+
if (!isHovered.current && !isFocused.current) state.close(immediate);
|
|
36
|
+
};
|
|
37
|
+
(0, $jCY2B$react.useEffect)(()=>{
|
|
38
|
+
let onKeyDown = (e)=>{
|
|
39
|
+
if (ref && ref.current) // Escape after clicking something can give it keyboard focus
|
|
40
|
+
// dismiss tooltip on esc key press
|
|
41
|
+
{
|
|
42
|
+
if (e.key === 'Escape') {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
state.close(true);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
if (state.isOpen) {
|
|
49
|
+
document.addEventListener('keydown', onKeyDown, true);
|
|
50
|
+
return ()=>{
|
|
51
|
+
document.removeEventListener('keydown', onKeyDown, true);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, [
|
|
55
|
+
ref,
|
|
56
|
+
state
|
|
57
|
+
]);
|
|
58
|
+
let onHoverStart = ()=>{
|
|
59
|
+
if (trigger === 'focus') return;
|
|
60
|
+
// In chrome, if you hover a trigger, then another element obscures it, due to keyboard
|
|
61
|
+
// interactions for example, hover will end. When hover is restored after that element disappears,
|
|
62
|
+
// focus moves on for example, then the tooltip will reopen. We check the modality to know if the hover
|
|
63
|
+
// is the result of moving the mouse.
|
|
64
|
+
if ((0, $jCY2B$reactariainteractions.getInteractionModality)() === 'pointer') isHovered.current = true;
|
|
65
|
+
else isHovered.current = false;
|
|
66
|
+
handleShow();
|
|
67
|
+
};
|
|
68
|
+
let onHoverEnd = ()=>{
|
|
69
|
+
if (trigger === 'focus') return;
|
|
70
|
+
// no matter how the trigger is left, we should close the tooltip
|
|
71
|
+
isFocused.current = false;
|
|
72
|
+
isHovered.current = false;
|
|
73
|
+
handleHide();
|
|
74
|
+
};
|
|
75
|
+
let onPressStart = ()=>{
|
|
76
|
+
// no matter how the trigger is pressed, we should close the tooltip
|
|
77
|
+
isFocused.current = false;
|
|
78
|
+
isHovered.current = false;
|
|
79
|
+
handleHide(true);
|
|
80
|
+
};
|
|
81
|
+
let onFocus = ()=>{
|
|
82
|
+
let isVisible = (0, $jCY2B$reactariainteractions.isFocusVisible)();
|
|
83
|
+
if (isVisible) {
|
|
84
|
+
isFocused.current = true;
|
|
85
|
+
handleShow();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
let onBlur = ()=>{
|
|
89
|
+
isFocused.current = false;
|
|
90
|
+
isHovered.current = false;
|
|
91
|
+
handleHide(true);
|
|
92
|
+
};
|
|
93
|
+
let { hoverProps: hoverProps } = (0, $jCY2B$reactariainteractions.useHover)({
|
|
94
|
+
isDisabled: isDisabled,
|
|
95
|
+
onHoverStart: onHoverStart,
|
|
96
|
+
onHoverEnd: onHoverEnd
|
|
97
|
+
});
|
|
98
|
+
let { focusableProps: focusableProps } = (0, $jCY2B$reactariafocus.useFocusable)({
|
|
99
|
+
isDisabled: isDisabled,
|
|
100
|
+
onFocus: onFocus,
|
|
101
|
+
onBlur: onBlur
|
|
102
|
+
}, ref);
|
|
103
|
+
return {
|
|
104
|
+
triggerProps: {
|
|
105
|
+
'aria-describedby': state.isOpen ? tooltipId : undefined,
|
|
106
|
+
...(0, $jCY2B$reactariautils.mergeProps)(focusableProps, hoverProps, {
|
|
107
|
+
onPointerDown: onPressStart,
|
|
108
|
+
onKeyDown: onPressStart
|
|
109
|
+
})
|
|
110
|
+
},
|
|
111
|
+
tooltipProps: {
|
|
112
|
+
id: tooltipId
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=useTooltipTrigger.main.js.map
|