@fluentui/react-tooltip 0.0.0-nightly-20230317-1454.1 → 0.0.0-nightly-20230322-0439.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +2 -11
- package/CHANGELOG.json +80 -17
- package/CHANGELOG.md +28 -11
- package/lib/Tooltip.js +1 -1
- package/lib/components/Tooltip/Tooltip.js +6 -6
- package/lib/components/Tooltip/Tooltip.types.js +1 -1
- package/lib/components/Tooltip/index.js +5 -5
- package/lib/components/Tooltip/renderTooltip.js +3 -3
- package/lib/components/Tooltip/useTooltip.js +35 -33
- package/lib/components/Tooltip/useTooltip.js.map +1 -1
- package/lib/components/Tooltip/useTooltipStyles.js +6 -6
- package/lib/index.js +1 -1
- package/lib-commonjs/Tooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.js +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.types.js.map +1 -1
- package/lib-commonjs/components/Tooltip/index.js.map +1 -1
- package/lib-commonjs/components/Tooltip/renderTooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltip.js +28 -26
- package/lib-commonjs/components/Tooltip/useTooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltipStyles.js +11 -11
- package/lib-commonjs/components/Tooltip/useTooltipStyles.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +9 -8
package/.swcrc
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
-
"env": {
|
4
|
-
"targets": {
|
5
|
-
"chrome": "84",
|
6
|
-
"edge": "84",
|
7
|
-
"firefox": "75",
|
8
|
-
"opera": "73",
|
9
|
-
"safari": "14.1"
|
10
|
-
},
|
11
|
-
"bugfixes": true
|
12
|
-
},
|
13
3
|
"exclude": [
|
14
4
|
"/testing",
|
15
5
|
"/**/*.cy.ts",
|
@@ -32,7 +22,8 @@
|
|
32
22
|
"runtime": "classic",
|
33
23
|
"useSpread": true
|
34
24
|
}
|
35
|
-
}
|
25
|
+
},
|
26
|
+
"target": "es2019"
|
36
27
|
},
|
37
28
|
"minify": false,
|
38
29
|
"sourceMaps": true
|
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/react-tooltip",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-tooltip_v0.0.0-nightly-
|
7
|
-
"version": "0.0.0-nightly-
|
5
|
+
"date": "Wed, 22 Mar 2023 04:46:55 GMT",
|
6
|
+
"tag": "@fluentui/react-tooltip_v0.0.0-nightly-20230322-0439.1",
|
7
|
+
"version": "0.0.0-nightly-20230322-0439.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,44 +16,107 @@
|
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-tooltip",
|
19
|
-
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230322-0439.1",
|
20
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"author": "beachball",
|
24
24
|
"package": "@fluentui/react-tooltip",
|
25
|
-
"comment": "Bump @fluentui/react-portal to v0.0.0-nightly-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-portal to v0.0.0-nightly-20230322-0439.1",
|
26
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"author": "beachball",
|
30
30
|
"package": "@fluentui/react-tooltip",
|
31
|
-
"comment": "Bump @fluentui/react-positioning to v0.0.0-nightly-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-positioning to v0.0.0-nightly-20230322-0439.1",
|
32
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
33
33
|
},
|
34
34
|
{
|
35
35
|
"author": "beachball",
|
36
36
|
"package": "@fluentui/react-tooltip",
|
37
|
-
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
38
|
-
"commit": "
|
37
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230322-0439.1",
|
38
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"author": "beachball",
|
42
42
|
"package": "@fluentui/react-tooltip",
|
43
|
-
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-
|
44
|
-
"commit": "
|
43
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230322-0439.1",
|
44
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"author": "beachball",
|
48
48
|
"package": "@fluentui/react-tooltip",
|
49
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-
|
50
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230322-0439.1",
|
50
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"author": "beachball",
|
54
54
|
"package": "@fluentui/react-tooltip",
|
55
|
-
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
56
|
-
"commit": "
|
55
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230322-0439.1",
|
56
|
+
"commit": "49dde84493fc2c3e96abac5ce918169c9668ba66"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"date": "Tue, 21 Mar 2023 21:23:13 GMT",
|
63
|
+
"tag": "@fluentui/react-tooltip_v9.2.5",
|
64
|
+
"version": "9.2.5",
|
65
|
+
"comments": {
|
66
|
+
"patch": [
|
67
|
+
{
|
68
|
+
"author": "tristan.watanabe@gmail.com",
|
69
|
+
"package": "@fluentui/react-tooltip",
|
70
|
+
"commit": "ead1c6d4c2ac3f3596b62b8cbc07b0a03041f11f",
|
71
|
+
"comment": "fix: add node field to package.json exports map."
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"author": "tristan.watanabe@gmail.com",
|
75
|
+
"package": "@fluentui/react-tooltip",
|
76
|
+
"commit": "2fac1a139149bd13b76b1306207bc988dca9c72c",
|
77
|
+
"comment": "chore: migrate to swc transpilation approach."
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"author": "beachball",
|
81
|
+
"package": "@fluentui/react-tooltip",
|
82
|
+
"comment": "Bump @fluentui/keyboard-keys to v9.0.2",
|
83
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"author": "beachball",
|
87
|
+
"package": "@fluentui/react-tooltip",
|
88
|
+
"comment": "Bump @fluentui/react-portal to v9.2.2",
|
89
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"author": "beachball",
|
93
|
+
"package": "@fluentui/react-tooltip",
|
94
|
+
"comment": "Bump @fluentui/react-positioning to v9.5.6",
|
95
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"author": "beachball",
|
99
|
+
"package": "@fluentui/react-tooltip",
|
100
|
+
"comment": "Bump @fluentui/react-shared-contexts to v9.3.2",
|
101
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"author": "beachball",
|
105
|
+
"package": "@fluentui/react-tooltip",
|
106
|
+
"comment": "Bump @fluentui/react-theme to v9.1.7",
|
107
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"author": "beachball",
|
111
|
+
"package": "@fluentui/react-tooltip",
|
112
|
+
"comment": "Bump @fluentui/react-utilities to v9.7.2",
|
113
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"author": "beachball",
|
117
|
+
"package": "@fluentui/react-tooltip",
|
118
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20",
|
119
|
+
"commit": "b7a26f6263c80e3253c6b8338c33b73bae33e2b5"
|
57
120
|
}
|
58
121
|
]
|
59
122
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,24 +1,41 @@
|
|
1
1
|
# Change Log - @fluentui/react-tooltip
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 22 Mar 2023 04:46:55 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20230322-0439.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v0.0.0-nightly-20230322-0439.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.2.
|
9
|
+
Wed, 22 Mar 2023 04:46:55 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.2.5..@fluentui/react-tooltip_v0.0.0-nightly-20230322-0439.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-portal to v0.0.0-nightly-
|
17
|
-
- Bump @fluentui/react-positioning to v0.0.0-nightly-
|
18
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
19
|
-
- Bump @fluentui/react-theme to v0.0.0-nightly-
|
20
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
21
|
-
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
15
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
16
|
+
- Bump @fluentui/react-portal to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
17
|
+
- Bump @fluentui/react-positioning to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
18
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
19
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
20
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
21
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230322-0439.1 ([commit](https://github.com/microsoft/fluentui/commit/49dde84493fc2c3e96abac5ce918169c9668ba66) by beachball)
|
22
|
+
|
23
|
+
## [9.2.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.2.5)
|
24
|
+
|
25
|
+
Tue, 21 Mar 2023 21:23:13 GMT
|
26
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.2.4..@fluentui/react-tooltip_v9.2.5)
|
27
|
+
|
28
|
+
### Patches
|
29
|
+
|
30
|
+
- fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
|
31
|
+
- chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
|
32
|
+
- Bump @fluentui/keyboard-keys to v9.0.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
33
|
+
- Bump @fluentui/react-portal to v9.2.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
34
|
+
- Bump @fluentui/react-positioning to v9.5.6 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
35
|
+
- Bump @fluentui/react-shared-contexts to v9.3.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
36
|
+
- Bump @fluentui/react-theme to v9.1.7 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
37
|
+
- Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
38
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
|
22
39
|
|
23
40
|
## [9.2.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.2.4)
|
24
41
|
|
package/lib/Tooltip.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from
|
1
|
+
export * from './components/Tooltip/index';
|
2
2
|
//# sourceMappingURL=Tooltip.js.map
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { useTooltip_unstable } from
|
3
|
-
import { renderTooltip_unstable } from
|
4
|
-
import { useCustomStyleHooks_unstable } from
|
5
|
-
import { useTooltipStyles_unstable } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useTooltip_unstable } from './useTooltip';
|
3
|
+
import { renderTooltip_unstable } from './renderTooltip';
|
4
|
+
import { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';
|
5
|
+
import { useTooltipStyles_unstable } from './useTooltipStyles';
|
6
6
|
/**
|
7
7
|
* A tooltip provides light weight contextual information on top of its target element.
|
8
8
|
*/
|
@@ -15,7 +15,7 @@ export const Tooltip = props => {
|
|
15
15
|
useCustomStyles(state);
|
16
16
|
return renderTooltip_unstable(state);
|
17
17
|
};
|
18
|
-
Tooltip.displayName =
|
18
|
+
Tooltip.displayName = 'Tooltip';
|
19
19
|
// type casting here is required to ensure internal type FluentTriggerComponent is not leaked
|
20
20
|
Tooltip.isFluentTriggerComponent = true;
|
21
21
|
//# sourceMappingURL=Tooltip.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import * as React from
|
1
|
+
import * as React from 'react';
|
2
2
|
//# sourceMappingURL=Tooltip.types.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
3
|
-
export * from
|
4
|
-
export * from
|
5
|
-
export * from
|
1
|
+
export * from './Tooltip';
|
2
|
+
export * from './Tooltip.types';
|
3
|
+
export * from './renderTooltip';
|
4
|
+
export * from './useTooltip';
|
5
|
+
export * from './useTooltipStyles';
|
6
6
|
//# sourceMappingURL=index.js.map
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { Portal } from
|
3
|
-
import { getSlots } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { Portal } from '@fluentui/react-portal';
|
3
|
+
import { getSlots } from '@fluentui/react-utilities';
|
4
4
|
/**
|
5
5
|
* Render the final JSX of Tooltip
|
6
6
|
*/
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import * as React from
|
2
|
-
import { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from
|
3
|
-
import { useTooltipVisibility_unstable as useTooltipVisibility, useFluent_unstable as useFluent } from
|
4
|
-
import { applyTriggerPropsToChildren, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useIsSSR, useMergedRefs, useTimeout, getTriggerChild, mergeCallbacks, useEventCallback } from
|
5
|
-
import { arrowHeight, tooltipBorderRadius } from
|
6
|
-
import { Escape } from
|
1
|
+
import * as React from 'react';
|
2
|
+
import { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';
|
3
|
+
import { useTooltipVisibility_unstable as useTooltipVisibility, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
4
|
+
import { applyTriggerPropsToChildren, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useIsSSR, useMergedRefs, useTimeout, getTriggerChild, mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';
|
5
|
+
import { arrowHeight, tooltipBorderRadius } from './private/constants';
|
6
|
+
import { Escape } from '@fluentui/keyboard-keys';
|
7
7
|
/**
|
8
8
|
* Create the state required to render Tooltip.
|
9
9
|
*
|
@@ -13,6 +13,7 @@ import { Escape } from "@fluentui/keyboard-keys";
|
|
13
13
|
* @param props - props from this instance of Tooltip
|
14
14
|
*/
|
15
15
|
export const useTooltip_unstable = props => {
|
16
|
+
var _child_props, _child_props1, _child_props2, _child_props3;
|
16
17
|
const context = useTooltipVisibility();
|
17
18
|
const isServerSideRender = useIsSSR();
|
18
19
|
const {
|
@@ -20,11 +21,11 @@ export const useTooltip_unstable = props => {
|
|
20
21
|
} = useFluent();
|
21
22
|
const [setDelayTimeout, clearDelayTimeout] = useTimeout();
|
22
23
|
const {
|
23
|
-
appearance =
|
24
|
+
appearance = 'normal',
|
24
25
|
children,
|
25
26
|
content,
|
26
27
|
withArrow = false,
|
27
|
-
positioning =
|
28
|
+
positioning = 'above',
|
28
29
|
onVisibleChange,
|
29
30
|
relationship,
|
30
31
|
showDelay = 250,
|
@@ -39,7 +40,7 @@ export const useTooltip_unstable = props => {
|
|
39
40
|
clearDelayTimeout();
|
40
41
|
setVisibleInternal(oldVisible => {
|
41
42
|
if (newVisible !== oldVisible) {
|
42
|
-
onVisibleChange
|
43
|
+
onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {
|
43
44
|
visible: newVisible
|
44
45
|
});
|
45
46
|
}
|
@@ -58,21 +59,21 @@ export const useTooltip_unstable = props => {
|
|
58
59
|
mountNode,
|
59
60
|
// Slots
|
60
61
|
components: {
|
61
|
-
content:
|
62
|
+
content: 'div'
|
62
63
|
},
|
63
64
|
content: resolveShorthand(content, {
|
64
65
|
defaultProps: {
|
65
|
-
role:
|
66
|
+
role: 'tooltip'
|
66
67
|
},
|
67
68
|
required: true
|
68
69
|
})
|
69
70
|
};
|
70
|
-
state.content.id = useId(
|
71
|
+
state.content.id = useId('tooltip-', state.content.id);
|
71
72
|
const positioningOptions = {
|
72
73
|
enabled: state.visible,
|
73
74
|
arrowPadding: 2 * tooltipBorderRadius,
|
74
|
-
position:
|
75
|
-
align:
|
75
|
+
position: 'above',
|
76
|
+
align: 'center',
|
76
77
|
offset: 4,
|
77
78
|
...resolvePositioningShorthand(state.positioning)
|
78
79
|
};
|
@@ -91,10 +92,11 @@ export const useTooltip_unstable = props => {
|
|
91
92
|
// Also add a listener on document to hide the tooltip if Escape is pressed
|
92
93
|
useIsomorphicLayoutEffect(() => {
|
93
94
|
if (visible) {
|
95
|
+
var _context_visibleTooltip;
|
94
96
|
const thisTooltip = {
|
95
97
|
hide: () => setVisible(false)
|
96
98
|
};
|
97
|
-
context.visibleTooltip
|
99
|
+
(_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();
|
98
100
|
context.visibleTooltip = thisTooltip;
|
99
101
|
const onDocumentKeyDown = ev => {
|
100
102
|
if (ev.key === Escape) {
|
@@ -104,7 +106,7 @@ export const useTooltip_unstable = props => {
|
|
104
106
|
ev.stopPropagation();
|
105
107
|
}
|
106
108
|
};
|
107
|
-
targetDocument
|
109
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {
|
108
110
|
// As this event is added at targeted document,
|
109
111
|
// we need to capture the event to be sure keydown handling from tooltip happens first
|
110
112
|
capture: true
|
@@ -113,7 +115,7 @@ export const useTooltip_unstable = props => {
|
|
113
115
|
if (context.visibleTooltip === thisTooltip) {
|
114
116
|
context.visibleTooltip = undefined;
|
115
117
|
}
|
116
|
-
targetDocument
|
118
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
|
117
119
|
capture: true
|
118
120
|
});
|
119
121
|
};
|
@@ -127,7 +129,7 @@ export const useTooltip_unstable = props => {
|
|
127
129
|
const ignoreNextFocusEventRef = React.useRef(false);
|
128
130
|
// Listener for onPointerEnter and onFocus on the trigger element
|
129
131
|
const onEnterTrigger = React.useCallback(ev => {
|
130
|
-
if (ev.type ===
|
132
|
+
if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {
|
131
133
|
ignoreNextFocusEventRef.current = false;
|
132
134
|
return;
|
133
135
|
}
|
@@ -141,10 +143,10 @@ export const useTooltip_unstable = props => {
|
|
141
143
|
// Listener for onPointerLeave and onBlur on the trigger element
|
142
144
|
const onLeaveTrigger = React.useCallback(ev => {
|
143
145
|
let delay = state.hideDelay;
|
144
|
-
if (ev.type ===
|
146
|
+
if (ev.type === 'blur') {
|
145
147
|
// Hide immediately when losing focus
|
146
148
|
delay = 0;
|
147
|
-
ignoreNextFocusEventRef.current = targetDocument
|
149
|
+
ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;
|
148
150
|
}
|
149
151
|
setDelayTimeout(() => {
|
150
152
|
setVisible(false, ev);
|
@@ -159,17 +161,17 @@ export const useTooltip_unstable = props => {
|
|
159
161
|
state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);
|
160
162
|
const child = getTriggerChild(children);
|
161
163
|
const triggerAriaProps = {};
|
162
|
-
if (relationship ===
|
164
|
+
if (relationship === 'label') {
|
163
165
|
// aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
|
164
|
-
if (typeof state.content.children ===
|
165
|
-
triggerAriaProps[
|
166
|
+
if (typeof state.content.children === 'string') {
|
167
|
+
triggerAriaProps['aria-label'] = state.content.children;
|
166
168
|
} else {
|
167
|
-
triggerAriaProps[
|
169
|
+
triggerAriaProps['aria-labelledby'] = state.content.id;
|
168
170
|
// Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
|
169
171
|
state.shouldRenderTooltip = true;
|
170
172
|
}
|
171
|
-
} else if (relationship ===
|
172
|
-
triggerAriaProps[
|
173
|
+
} else if (relationship === 'description') {
|
174
|
+
triggerAriaProps['aria-describedby'] = state.content.id;
|
173
175
|
// Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
|
174
176
|
state.shouldRenderTooltip = true;
|
175
177
|
}
|
@@ -177,17 +179,17 @@ export const useTooltip_unstable = props => {
|
|
177
179
|
if (isServerSideRender) {
|
178
180
|
state.shouldRenderTooltip = false;
|
179
181
|
}
|
180
|
-
const childTargetRef = useMergedRefs(child
|
182
|
+
const childTargetRef = useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);
|
181
183
|
// Apply the trigger props to the child, either by calling the render function, or cloning with the new props
|
182
184
|
state.children = applyTriggerPropsToChildren(children, {
|
183
185
|
...triggerAriaProps,
|
184
|
-
...child
|
186
|
+
...(child === null || child === void 0 ? void 0 : child.props),
|
185
187
|
// If the target prop is not provided, attach targetRef to the trigger element's ref prop
|
186
|
-
ref: positioningOptions.target === undefined ? childTargetRef : child
|
187
|
-
onPointerEnter: useEventCallback(mergeCallbacks(child
|
188
|
-
onPointerLeave: useEventCallback(mergeCallbacks(child
|
189
|
-
onFocus: useEventCallback(mergeCallbacks(child
|
190
|
-
onBlur: useEventCallback(mergeCallbacks(child
|
188
|
+
ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
|
189
|
+
onPointerEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),
|
190
|
+
onPointerLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),
|
191
|
+
onFocus: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),
|
192
|
+
onBlur: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))
|
191
193
|
});
|
192
194
|
return state;
|
193
195
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","applyTriggerPropsToChildren","resolveShorthand","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","useTimeout","getTriggerChild","mergeCallbacks","useEventCallback","arrowHeight","tooltipBorderRadius","Escape","useTooltip_unstable","props","context","isServerSideRender","targetDocument","setDelayTimeout","clearDelayTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","state","initialState","setVisible","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","defaultProps","role","required","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","ref","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","child","triggerAriaProps","childTargetRef"],"sources":["../../../src/components/Tooltip/useTooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport {\n useTooltipVisibility_unstable as useTooltipVisibility,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport {\n applyTriggerPropsToChildren,\n resolveShorthand,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n useTimeout,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport type { TooltipProps, TooltipState, TooltipChildProps } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { Escape } from '@fluentui/keyboard-keys';\n\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */\nexport const useTooltip_unstable = (props: TooltipProps): TooltipState => {\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n\n const {\n appearance = 'normal',\n children,\n content,\n withArrow = false,\n positioning = 'above',\n onVisibleChange,\n relationship,\n showDelay = 250,\n hideDelay = 250,\n mountNode,\n } = props;\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n const setVisible = React.useCallback(\n (newVisible: boolean, ev?: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (newVisible !== oldVisible) {\n onVisibleChange?.(ev, { visible: newVisible });\n }\n return newVisible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\n\n const state: TooltipState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: 'tooltip',\n },\n required: true,\n }),\n };\n\n state.content.id = useId('tooltip-', state.content.id);\n\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above' as const,\n align: 'center' as const,\n offset: 4,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n\n const {\n targetRef,\n containerRef,\n arrowRef,\n }: {\n targetRef: React.MutableRefObject<unknown>;\n containerRef: React.MutableRefObject<HTMLDivElement>;\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(() => {\n if (visible) {\n const thisTooltip = { hide: () => setVisible(false) };\n\n context.visibleTooltip?.hide();\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n\n targetDocument?.addEventListener('keydown', onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true,\n });\n\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n\n targetDocument?.removeEventListener('keydown', onDocumentKeyDown, { capture: true });\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n\n setDelayTimeout(() => {\n setVisible(true, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.showDelay, context],\n );\n\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n let delay = state.hideDelay;\n\n if (ev.type === 'blur') {\n // Hide immediately when losing focus\n delay = 0;\n\n ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(false, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.hideDelay, targetDocument],\n );\n\n // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.\n // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);\n\n const child = getTriggerChild(children);\n\n const triggerAriaProps: Pick<TooltipChildProps, 'aria-label' | 'aria-labelledby' | 'aria-describedby'> = {};\n\n if (relationship === 'label') {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === 'string') {\n triggerAriaProps['aria-label'] = state.content.children;\n } else {\n triggerAriaProps['aria-labelledby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === 'description') {\n triggerAriaProps['aria-describedby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n\n const childTargetRef = useMergedRefs(child?.ref, targetRef);\n\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child?.props,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child?.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child?.props?.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child?.props?.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child?.props?.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child?.props?.onBlur, onLeaveTrigger)),\n });\n\n return state;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,EAAEC,2BAA2B,EAAEC,cAAc,QAAQ;AAC9E,SACEC,6BAAA,IAAiCC,oBAAoB,EACrDC,kBAAA,IAAsBC,SAAS,QAC1B;AACP,SACEC,2BAA2B,EAC3BC,gBAAgB,EAChBC,oBAAoB,EACpBC,KAAK,EACLC,yBAAyB,EACzBC,QAAQ,EACRC,aAAa,EACbC,UAAU,EACVC,eAAe,EACfC,cAAc,EACdC,gBAAgB,QACX;AAEP,SAASC,WAAW,EAAEC,mBAAmB,QAAQ;AACjD,SAASC,MAAM,QAAQ;AAEvB;;;;;;;;AAQA,OAAO,MAAMC,mBAAA,GAAuBC,KAAA,IAAsC;EACxE,MAAMC,OAAA,GAAUnB,oBAAA;EAChB,MAAMoB,kBAAA,GAAqBZ,QAAA;EAC3B,MAAM;IAAEa;EAAc,CAAE,GAAGnB,SAAA;EAC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f;IACAwC,GAAA,EAAKT,kBAAA,CAAmB6B,MAAM,KAAKX,SAAA,GAAYkB,cAAA,GAAiBF,KAAA,EAAOzB,GAAG;IAC1EqB,cAAA,EAAgBlE,gBAAA,CAAiBD,cAAA,CAAeuE,KAAA,EAAOjE,KAAA,EAAO6D,cAAA,EAAgBR,cAAA;IAC9ES,cAAA,EAAgBnE,gBAAA,CAAiBD,cAAA,CAAeuE,KAAA,EAAOjE,KAAA,EAAO8D,cAAA,EAAgBJ,cAAA;IAC9EK,OAAA,EAASpE,gBAAA,CAAiBD,cAAA,CAAeuE,KAAA,EAAOjE,KAAA,EAAO+D,OAAA,EAASV,cAAA;IAChEW,MAAA,EAAQrE,gBAAA,CAAiBD,cAAA,CAAeuE,KAAA,EAAOjE,KAAA,EAAOgE,MAAA,EAAQN,cAAA;EAChE;EAEA,OAAOxC,KAAA;AACT"}
|
1
|
+
{"version":3,"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","applyTriggerPropsToChildren","resolveShorthand","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","useTimeout","getTriggerChild","mergeCallbacks","useEventCallback","arrowHeight","tooltipBorderRadius","Escape","useTooltip_unstable","props","_child_props","_child_props1","_child_props2","_child_props3","context","isServerSideRender","targetDocument","setDelayTimeout","clearDelayTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","state","initialState","setVisible","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","defaultProps","role","required","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","ref","_context_visibleTooltip","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","child","triggerAriaProps","childTargetRef"],"sources":["../../../src/components/Tooltip/useTooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport {\n useTooltipVisibility_unstable as useTooltipVisibility,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport {\n applyTriggerPropsToChildren,\n resolveShorthand,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n useTimeout,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport type { TooltipProps, TooltipState, TooltipChildProps } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { Escape } from '@fluentui/keyboard-keys';\n\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */\nexport const useTooltip_unstable = (props: TooltipProps): TooltipState => {\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n\n const {\n appearance = 'normal',\n children,\n content,\n withArrow = false,\n positioning = 'above',\n onVisibleChange,\n relationship,\n showDelay = 250,\n hideDelay = 250,\n mountNode,\n } = props;\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n const setVisible = React.useCallback(\n (newVisible: boolean, ev?: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (newVisible !== oldVisible) {\n onVisibleChange?.(ev, { visible: newVisible });\n }\n return newVisible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\n\n const state: TooltipState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: 'tooltip',\n },\n required: true,\n }),\n };\n\n state.content.id = useId('tooltip-', state.content.id);\n\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above' as const,\n align: 'center' as const,\n offset: 4,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n\n const {\n targetRef,\n containerRef,\n arrowRef,\n }: {\n targetRef: React.MutableRefObject<unknown>;\n containerRef: React.MutableRefObject<HTMLDivElement>;\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(() => {\n if (visible) {\n const thisTooltip = { hide: () => setVisible(false) };\n\n context.visibleTooltip?.hide();\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n\n targetDocument?.addEventListener('keydown', onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true,\n });\n\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n\n targetDocument?.removeEventListener('keydown', onDocumentKeyDown, { capture: true });\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n\n setDelayTimeout(() => {\n setVisible(true, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.showDelay, context],\n );\n\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n let delay = state.hideDelay;\n\n if (ev.type === 'blur') {\n // Hide immediately when losing focus\n delay = 0;\n\n ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(false, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.hideDelay, targetDocument],\n );\n\n // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.\n // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);\n\n const child = getTriggerChild(children);\n\n const triggerAriaProps: Pick<TooltipChildProps, 'aria-label' | 'aria-labelledby' | 'aria-describedby'> = {};\n\n if (relationship === 'label') {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === 'string') {\n triggerAriaProps['aria-label'] = state.content.children;\n } else {\n triggerAriaProps['aria-labelledby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === 'description') {\n triggerAriaProps['aria-describedby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n\n const childTargetRef = useMergedRefs(child?.ref, targetRef);\n\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child?.props,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child?.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child?.props?.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child?.props?.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child?.props?.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child?.props?.onBlur, onLeaveTrigger)),\n });\n\n return state;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,EAAEC,2BAA2B,EAAEC,cAAc,QAAQ;AAC9E,SACEC,6BAAA,IAAiCC,oBAAoB,EACrDC,kBAAA,IAAsBC,SAAS,QAC1B;AACP,SACEC,2BAA2B,EAC3BC,gBAAgB,EAChBC,oBAAoB,EACpBC,KAAK,EACLC,yBAAyB,EACzBC,QAAQ,EACRC,aAAa,EACbC,UAAU,EACVC,eAAe,EACfC,cAAc,EACdC,gBAAgB,QACX;AAEP,SAASC,WAAW,EAAEC,mBAAmB,QAAQ;AACjD,SAASC,MAAM,QAAQ;AAEvB;;;;;;;;AAQA,OAAO,MAAMC,mBAAA,GAAuBC,KAAA,IAAsC;MA6MtBC,YAAA,EACAC,aAAA,EACPC,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C,KAAA;AACT"}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { shorthands, __styles, mergeClasses } from
|
2
|
-
import { createArrowStyles } from
|
3
|
-
import { tokens } from
|
4
|
-
import { arrowHeight } from
|
1
|
+
import { shorthands, __styles, mergeClasses } from '@griffel/react';
|
2
|
+
import { createArrowStyles } from '@fluentui/react-positioning';
|
3
|
+
import { tokens } from '@fluentui/react-theme';
|
4
|
+
import { arrowHeight } from './private/constants';
|
5
5
|
export const tooltipClassNames = {
|
6
|
-
content:
|
6
|
+
content: 'fui-Tooltip__content'
|
7
7
|
};
|
8
8
|
/**
|
9
9
|
* Styles for the tooltip
|
@@ -87,7 +87,7 @@ const useStyles = /*#__PURE__*/__styles({
|
|
87
87
|
*/
|
88
88
|
export const useTooltipStyles_unstable = state => {
|
89
89
|
const styles = useStyles();
|
90
|
-
state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance ===
|
90
|
+
state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
|
91
91
|
state.arrowClassName = styles.arrow;
|
92
92
|
return state;
|
93
93
|
};
|
package/lib/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export { Tooltip, renderTooltip_unstable, tooltipClassNames, useTooltipStyles_unstable, useTooltip_unstable } from
|
1
|
+
export { Tooltip, renderTooltip_unstable, tooltipClassNames, useTooltipStyles_unstable, useTooltip_unstable } from './Tooltip';
|
2
2
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/Tooltip.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../lib/Tooltip.js"],"sourcesContent":["export * from './components/Tooltip/index';\n//# sourceMappingURL=Tooltip.js.map"],"names":[],"mappings":";;;;;oBAAc;CACd,mCAAmC"}
|
@@ -19,7 +19,7 @@ const Tooltip = (props)=>{
|
|
19
19
|
useCustomStyles(state);
|
20
20
|
return (0, _renderTooltip.renderTooltip_unstable)(state);
|
21
21
|
};
|
22
|
-
Tooltip.displayName =
|
22
|
+
Tooltip.displayName = 'Tooltip';
|
23
23
|
// type casting here is required to ensure internal type FluentTriggerComponent is not leaked
|
24
24
|
Tooltip.isFluentTriggerComponent = true; //# sourceMappingURL=Tooltip.js.map
|
25
25
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Tooltip/Tooltip.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Tooltip/Tooltip.js"],"sourcesContent":["import * as React from 'react';\nimport { useTooltip_unstable } from './useTooltip';\nimport { renderTooltip_unstable } from './renderTooltip';\nimport { useCustomStyleHooks_unstable } from '@fluentui/react-shared-contexts';\nimport { useTooltipStyles_unstable } from './useTooltipStyles';\n/**\n * A tooltip provides light weight contextual information on top of its target element.\n */\nexport const Tooltip = props => {\n const state = useTooltip_unstable(props);\n useTooltipStyles_unstable(state);\n const {\n useTooltipStyles_unstable: useCustomStyles\n } = useCustomStyleHooks_unstable();\n useCustomStyles(state);\n return renderTooltip_unstable(state);\n};\nTooltip.displayName = 'Tooltip';\n// type casting here is required to ensure internal type FluentTriggerComponent is not leaked\nTooltip.isFluentTriggerComponent = true;\n//# sourceMappingURL=Tooltip.js.map"],"names":["Tooltip","props","state","useTooltip_unstable","useTooltipStyles_unstable","useCustomStyles","useCustomStyleHooks_unstable","renderTooltip_unstable","displayName","isFluentTriggerComponent"],"mappings":";;;;+BAQaA;;aAAAA;;;6DARU;4BACa;+BACG;qCACM;kCACH;AAInC,MAAMA,UAAUC,CAAAA,QAAS;IAC9B,MAAMC,QAAQC,IAAAA,+BAAmB,EAACF;IAClCG,IAAAA,2CAAyB,EAACF;IAC1B,MAAM,EACJE,2BAA2BC,gBAAe,EAC3C,GAAGC,IAAAA,iDAA4B;IAChCD,gBAAgBH;IAChB,OAAOK,IAAAA,qCAAsB,EAACL;AAChC;AACAF,QAAQQ,WAAW,GAAG;AACtB,6FAA6F;AAC7FR,QAAQS,wBAAwB,GAAG,IAAI,EACvC,mCAAmC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Tooltip/Tooltip.types.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Tooltip/Tooltip.types.js"],"sourcesContent":["import * as React from 'react';\n//# sourceMappingURL=Tooltip.types.js.map"],"names":[],"mappings":";;;;;6DAAuB;CACvB,yCAAyC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Tooltip/index.js"],"sourcesContent":["export * from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Tooltip/index.js"],"sourcesContent":["export * from './Tooltip';\nexport * from './Tooltip.types';\nexport * from './renderTooltip';\nexport * from './useTooltip';\nexport * from './useTooltipStyles';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;CACd,iCAAiC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Tooltip/renderTooltip.js"],"sourcesContent":["import * as React from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Tooltip/renderTooltip.js"],"sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\n/**\n * Render the final JSX of Tooltip\n */\nexport const renderTooltip_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n return /*#__PURE__*/React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/React.createElement(Portal, {\n mountNode: state.mountNode\n }, /*#__PURE__*/React.createElement(slots.content, slotProps.content, state.withArrow && /*#__PURE__*/React.createElement(\"div\", {\n ref: state.arrowRef,\n className: state.arrowClassName\n }), state.content.children)));\n};\n//# sourceMappingURL=renderTooltip.js.map"],"names":["renderTooltip_unstable","state","slots","slotProps","getSlots","React","createElement","Fragment","children","shouldRenderTooltip","Portal","mountNode","content","withArrow","ref","arrowRef","className","arrowClassName"],"mappings":";;;;+BAMaA;;aAAAA;;;6DANU;6BACA;gCACE;AAIlB,MAAMA,yBAAyBC,CAAAA,QAAS;IAC7C,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACH;IACb,OAAO,WAAW,GAAEI,OAAMC,aAAa,CAACD,OAAME,QAAQ,EAAE,IAAI,EAAEN,MAAMO,QAAQ,EAAEP,MAAMQ,mBAAmB,IAAI,WAAW,GAAEJ,OAAMC,aAAa,CAACI,mBAAM,EAAE;QAClJC,WAAWV,MAAMU,SAAS;IAC5B,GAAG,WAAW,GAAEN,OAAMC,aAAa,CAACJ,MAAMU,OAAO,EAAET,UAAUS,OAAO,EAAEX,MAAMY,SAAS,IAAI,WAAW,GAAER,OAAMC,aAAa,CAAC,OAAO;QAC/HQ,KAAKb,MAAMc,QAAQ;QACnBC,WAAWf,MAAMgB,cAAc;IACjC,IAAIhB,MAAMW,OAAO,CAACJ,QAAQ;AAC5B,GACA,yCAAyC"}
|
@@ -14,11 +14,12 @@ const _reactUtilities = require("@fluentui/react-utilities");
|
|
14
14
|
const _constants = require("./private/constants");
|
15
15
|
const _keyboardKeys = require("@fluentui/keyboard-keys");
|
16
16
|
const useTooltip_unstable = (props)=>{
|
17
|
+
var _child_props, _child_props1, _child_props2, _child_props3;
|
17
18
|
const context = (0, _reactSharedContexts.useTooltipVisibility_unstable)();
|
18
19
|
const isServerSideRender = (0, _reactUtilities.useIsSSR)();
|
19
20
|
const { targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
|
20
21
|
const [setDelayTimeout, clearDelayTimeout] = (0, _reactUtilities.useTimeout)();
|
21
|
-
const { appearance =
|
22
|
+
const { appearance ='normal' , children , content , withArrow =false , positioning ='above' , onVisibleChange , relationship , showDelay =250 , hideDelay =250 , mountNode } = props;
|
22
23
|
const [visible, setVisibleInternal] = (0, _reactUtilities.useControllableState)({
|
23
24
|
state: props.visible,
|
24
25
|
initialState: false
|
@@ -27,7 +28,7 @@ const useTooltip_unstable = (props)=>{
|
|
27
28
|
clearDelayTimeout();
|
28
29
|
setVisibleInternal((oldVisible)=>{
|
29
30
|
if (newVisible !== oldVisible) {
|
30
|
-
onVisibleChange
|
31
|
+
onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {
|
31
32
|
visible: newVisible
|
32
33
|
});
|
33
34
|
}
|
@@ -50,21 +51,21 @@ const useTooltip_unstable = (props)=>{
|
|
50
51
|
mountNode,
|
51
52
|
// Slots
|
52
53
|
components: {
|
53
|
-
content:
|
54
|
+
content: 'div'
|
54
55
|
},
|
55
56
|
content: (0, _reactUtilities.resolveShorthand)(content, {
|
56
57
|
defaultProps: {
|
57
|
-
role:
|
58
|
+
role: 'tooltip'
|
58
59
|
},
|
59
60
|
required: true
|
60
61
|
})
|
61
62
|
};
|
62
|
-
state.content.id = (0, _reactUtilities.useId)(
|
63
|
+
state.content.id = (0, _reactUtilities.useId)('tooltip-', state.content.id);
|
63
64
|
const positioningOptions = {
|
64
65
|
enabled: state.visible,
|
65
66
|
arrowPadding: 2 * _constants.tooltipBorderRadius,
|
66
|
-
position:
|
67
|
-
align:
|
67
|
+
position: 'above',
|
68
|
+
align: 'center',
|
68
69
|
offset: 4,
|
69
70
|
...(0, _reactPositioning.resolvePositioningShorthand)(state.positioning)
|
70
71
|
};
|
@@ -79,10 +80,11 @@ const useTooltip_unstable = (props)=>{
|
|
79
80
|
// Also add a listener on document to hide the tooltip if Escape is pressed
|
80
81
|
(0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
|
81
82
|
if (visible) {
|
83
|
+
var _context_visibleTooltip;
|
82
84
|
const thisTooltip = {
|
83
85
|
hide: ()=>setVisible(false)
|
84
86
|
};
|
85
|
-
context.visibleTooltip
|
87
|
+
(_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();
|
86
88
|
context.visibleTooltip = thisTooltip;
|
87
89
|
const onDocumentKeyDown = (ev)=>{
|
88
90
|
if (ev.key === _keyboardKeys.Escape) {
|
@@ -92,7 +94,7 @@ const useTooltip_unstable = (props)=>{
|
|
92
94
|
ev.stopPropagation();
|
93
95
|
}
|
94
96
|
};
|
95
|
-
targetDocument
|
97
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {
|
96
98
|
// As this event is added at targeted document,
|
97
99
|
// we need to capture the event to be sure keydown handling from tooltip happens first
|
98
100
|
capture: true
|
@@ -101,7 +103,7 @@ const useTooltip_unstable = (props)=>{
|
|
101
103
|
if (context.visibleTooltip === thisTooltip) {
|
102
104
|
context.visibleTooltip = undefined;
|
103
105
|
}
|
104
|
-
targetDocument
|
106
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
|
105
107
|
capture: true
|
106
108
|
});
|
107
109
|
};
|
@@ -120,7 +122,7 @@ const useTooltip_unstable = (props)=>{
|
|
120
122
|
const ignoreNextFocusEventRef = _react.useRef(false);
|
121
123
|
// Listener for onPointerEnter and onFocus on the trigger element
|
122
124
|
const onEnterTrigger = _react.useCallback((ev)=>{
|
123
|
-
if (ev.type ===
|
125
|
+
if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {
|
124
126
|
ignoreNextFocusEventRef.current = false;
|
125
127
|
return;
|
126
128
|
}
|
@@ -139,10 +141,10 @@ const useTooltip_unstable = (props)=>{
|
|
139
141
|
// Listener for onPointerLeave and onBlur on the trigger element
|
140
142
|
const onLeaveTrigger = _react.useCallback((ev)=>{
|
141
143
|
let delay = state.hideDelay;
|
142
|
-
if (ev.type ===
|
144
|
+
if (ev.type === 'blur') {
|
143
145
|
// Hide immediately when losing focus
|
144
146
|
delay = 0;
|
145
|
-
ignoreNextFocusEventRef.current = targetDocument
|
147
|
+
ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;
|
146
148
|
}
|
147
149
|
setDelayTimeout(()=>{
|
148
150
|
setVisible(false, ev);
|
@@ -162,17 +164,17 @@ const useTooltip_unstable = (props)=>{
|
|
162
164
|
state.content.onBlur = (0, _reactUtilities.mergeCallbacks)(state.content.onBlur, onLeaveTrigger);
|
163
165
|
const child = (0, _reactUtilities.getTriggerChild)(children);
|
164
166
|
const triggerAriaProps = {};
|
165
|
-
if (relationship ===
|
167
|
+
if (relationship === 'label') {
|
166
168
|
// aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
|
167
|
-
if (typeof state.content.children ===
|
168
|
-
triggerAriaProps[
|
169
|
+
if (typeof state.content.children === 'string') {
|
170
|
+
triggerAriaProps['aria-label'] = state.content.children;
|
169
171
|
} else {
|
170
|
-
triggerAriaProps[
|
172
|
+
triggerAriaProps['aria-labelledby'] = state.content.id;
|
171
173
|
// Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
|
172
174
|
state.shouldRenderTooltip = true;
|
173
175
|
}
|
174
|
-
} else if (relationship ===
|
175
|
-
triggerAriaProps[
|
176
|
+
} else if (relationship === 'description') {
|
177
|
+
triggerAriaProps['aria-describedby'] = state.content.id;
|
176
178
|
// Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
|
177
179
|
state.shouldRenderTooltip = true;
|
178
180
|
}
|
@@ -180,17 +182,17 @@ const useTooltip_unstable = (props)=>{
|
|
180
182
|
if (isServerSideRender) {
|
181
183
|
state.shouldRenderTooltip = false;
|
182
184
|
}
|
183
|
-
const childTargetRef = (0, _reactUtilities.useMergedRefs)(child
|
185
|
+
const childTargetRef = (0, _reactUtilities.useMergedRefs)(child === null || child === void 0 ? void 0 : child.ref, targetRef);
|
184
186
|
// Apply the trigger props to the child, either by calling the render function, or cloning with the new props
|
185
187
|
state.children = (0, _reactUtilities.applyTriggerPropsToChildren)(children, {
|
186
188
|
...triggerAriaProps,
|
187
|
-
...child
|
189
|
+
...child === null || child === void 0 ? void 0 : child.props,
|
188
190
|
// If the target prop is not provided, attach targetRef to the trigger element's ref prop
|
189
|
-
ref: positioningOptions.target === undefined ? childTargetRef : child
|
190
|
-
onPointerEnter: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child
|
191
|
-
onPointerLeave: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child
|
192
|
-
onFocus: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child
|
193
|
-
onBlur: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child
|
191
|
+
ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
|
192
|
+
onPointerEnter: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),
|
193
|
+
onPointerLeave: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),
|
194
|
+
onFocus: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),
|
195
|
+
onBlur: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))
|
194
196
|
});
|
195
197
|
return state;
|
196
198
|
}; //# sourceMappingURL=useTooltip.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Tooltip/useTooltip.js"],"sourcesContent":["import * as React from \"react\";\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from \"@fluentui/react-positioning\";\nimport { useTooltipVisibility_unstable as useTooltipVisibility, useFluent_unstable as useFluent } from \"@fluentui/react-shared-contexts\";\nimport { applyTriggerPropsToChildren, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useIsSSR, useMergedRefs, useTimeout, getTriggerChild, mergeCallbacks, useEventCallback } from \"@fluentui/react-utilities\";\nimport { arrowHeight, tooltipBorderRadius } from \"./private/constants\";\nimport { Escape } from \"@fluentui/keyboard-keys\";\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */\nexport const useTooltip_unstable = props => {\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const {\n targetDocument\n } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n const {\n appearance = \"normal\",\n children,\n content,\n withArrow = false,\n positioning = \"above\",\n onVisibleChange,\n relationship,\n showDelay = 250,\n hideDelay = 250,\n mountNode\n } = props;\n const [visible, setVisibleInternal] = useControllableState({\n state: props.visible,\n initialState: false\n });\n const setVisible = React.useCallback((newVisible, ev) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (newVisible !== oldVisible) {\n onVisibleChange?.(ev, {\n visible: newVisible\n });\n }\n return newVisible;\n });\n }, [clearDelayTimeout, setVisibleInternal, onVisibleChange]);\n const state = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: \"div\"\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: \"tooltip\"\n },\n required: true\n })\n };\n state.content.id = useId(\"tooltip-\", state.content.id);\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: \"above\",\n align: \"center\",\n offset: 4,\n ...resolvePositioningShorthand(state.positioning)\n };\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n const {\n targetRef,\n containerRef,\n arrowRef\n } = usePositioning(positioningOptions);\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(() => {\n if (visible) {\n const thisTooltip = {\n hide: () => setVisible(false)\n };\n context.visibleTooltip?.hide();\n context.visibleTooltip = thisTooltip;\n const onDocumentKeyDown = ev => {\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n targetDocument?.addEventListener(\"keydown\", onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true\n });\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n targetDocument?.removeEventListener(\"keydown\", onDocumentKeyDown, {\n capture: true\n });\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(ev => {\n if (ev.type === \"focus\" && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n setDelayTimeout(() => {\n setVisible(true, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [setDelayTimeout, setVisible, state.showDelay, context]);\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(ev => {\n let delay = state.hideDelay;\n if (ev.type === \"blur\") {\n // Hide immediately when losing focus\n delay = 0;\n ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n setDelayTimeout(() => {\n setVisible(false, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [setDelayTimeout, setVisible, state.hideDelay, targetDocument]);\n // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.\n // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);\n const child = getTriggerChild(children);\n const triggerAriaProps = {};\n if (relationship === \"label\") {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === \"string\") {\n triggerAriaProps[\"aria-label\"] = state.content.children;\n } else {\n triggerAriaProps[\"aria-labelledby\"] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === \"description\") {\n triggerAriaProps[\"aria-describedby\"] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n const childTargetRef = useMergedRefs(child?.ref, targetRef);\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child?.props,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child?.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child?.props?.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child?.props?.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child?.props?.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child?.props?.onBlur, onLeaveTrigger))\n });\n return state;\n};\n//# sourceMappingURL=useTooltip.js.map"],"names":["useTooltip_unstable","props","context","useTooltipVisibility","isServerSideRender","useIsSSR","targetDocument","useFluent","setDelayTimeout","clearDelayTimeout","useTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","useControllableState","state","initialState","setVisible","React","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","resolveShorthand","defaultProps","role","required","id","useId","positioningOptions","enabled","arrowPadding","tooltipBorderRadius","position","align","offset","resolvePositioningShorthand","mergeArrowOffset","arrowHeight","targetRef","containerRef","arrowRef","usePositioning","ref","useMergedRefs","useIsomorphicLayoutEffect","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","Escape","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","mergeCallbacks","onPointerLeave","onFocus","onBlur","child","getTriggerChild","triggerAriaProps","childTargetRef","applyTriggerPropsToChildren","useEventCallback"],"mappings":";;;;+BAcaA;;aAAAA;;;6DAdU;kCACuD;qCACyB;gCACuG;2BAC7J;8BAC1B;AAShB,MAAMA,sBAAsBC,CAAAA,QAAS;IAC1C,MAAMC,UAAUC,IAAAA,kDAAoB;IACpC,MAAMC,qBAAqBC,IAAAA,wBAAQ;IACnC,MAAM,EACJC,eAAc,EACf,GAAGC,IAAAA,uCAAS;IACb,MAAM,CAACC,iBAAiBC,kBAAkB,GAAGC,IAAAA,0BAAU;IACvD,MAAM,EACJC,YAAa,SAAQ,EACrBC,SAAQ,EACRC,QAAO,EACPC,WAAY,KAAK,CAAA,EACjBC,aAAc,QAAO,EACrBC,gBAAe,EACfC,aAAY,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AAMX,OAAO,CAACyB,EAAE;YACtD,8FAA8F;YAC9Fd,MAAMQ,mBAAmB,GAAG,IAAI;QAClC,CAAC;IACH,OAAO,IAAIf,iBAAiB,eAAe;QACzCoE,gBAAgB,CAAC,mBAAmB,GAAG7D,MAAMX,OAAO,CAACyB,EAAE;QACvD,+FAA+F;QAC/Fd,MAAMQ,mBAAmB,GAAG,IAAI;IAClC,CAAC;IACD,4DAA4D;IAC5D,IAAI5B,oBAAoB;QACtBoB,MAAMQ,mBAAmB,GAAG,KAAK;IACnC,CAAC;IACD,MAAMsD,iBAAiB/B,IAAAA,6BAAa,EAAC4B,OAAO7B,KAAKJ;IACjD,6GAA6G;IAC7G1B,MAAMZ,QAAQ,GAAG2E,IAAAA,2CAA2B,EAAC3E,UAAU;QACrD,GAAGyE,gBAAgB;QACnB,GAAGF,OAAOlF,KAAK;QACf,yFAAyF;QACzFqD,KAAKd,mBAAmBqC,MAAM,KAAKX,YAAYoB,iBAAiBH,OAAO7B,GAAG;QAC1EwB,gBAAgBU,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,OAAOlF,OAAO6E,gBAAgBR;QAC9EU,gBAAgBQ,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,OAAOlF,OAAO+E,gBAAgBL;QAC9EM,SAASO,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,OAAOlF,OAAOgF,SAASX;QAChEY,QAAQM,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,OAAOlF,OAAOiF,QAAQP;IAChE;IACA,OAAOnD;AACT,GACA,sCAAsC"}
|
1
|
+
{"version":3,"sources":["../../../lib/components/Tooltip/useTooltip.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useTooltipVisibility_unstable as useTooltipVisibility, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyTriggerPropsToChildren, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useIsSSR, useMergedRefs, useTimeout, getTriggerChild, mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { Escape } from '@fluentui/keyboard-keys';\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */\nexport const useTooltip_unstable = props => {\n var _child_props, _child_props1, _child_props2, _child_props3;\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const {\n targetDocument\n } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n const {\n appearance = 'normal',\n children,\n content,\n withArrow = false,\n positioning = 'above',\n onVisibleChange,\n relationship,\n showDelay = 250,\n hideDelay = 250,\n mountNode\n } = props;\n const [visible, setVisibleInternal] = useControllableState({\n state: props.visible,\n initialState: false\n });\n const setVisible = React.useCallback((newVisible, ev) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (newVisible !== oldVisible) {\n onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {\n visible: newVisible\n });\n }\n return newVisible;\n });\n }, [clearDelayTimeout, setVisibleInternal, onVisibleChange]);\n const state = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: 'div'\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: 'tooltip'\n },\n required: true\n })\n };\n state.content.id = useId('tooltip-', state.content.id);\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above',\n align: 'center',\n offset: 4,\n ...resolvePositioningShorthand(state.positioning)\n };\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n const {\n targetRef,\n containerRef,\n arrowRef\n } = usePositioning(positioningOptions);\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(() => {\n if (visible) {\n var _context_visibleTooltip;\n const thisTooltip = {\n hide: () => setVisible(false)\n };\n (_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();\n context.visibleTooltip = thisTooltip;\n const onDocumentKeyDown = ev => {\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true\n });\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {\n capture: true\n });\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(ev => {\n if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n setDelayTimeout(() => {\n setVisible(true, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [setDelayTimeout, setVisible, state.showDelay, context]);\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(ev => {\n let delay = state.hideDelay;\n if (ev.type === 'blur') {\n // Hide immediately when losing focus\n delay = 0;\n ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;\n }\n setDelayTimeout(() => {\n setVisible(false, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [setDelayTimeout, setVisible, state.hideDelay, targetDocument]);\n // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.\n // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);\n const child = getTriggerChild(children);\n const triggerAriaProps = {};\n if (relationship === 'label') {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === 'string') {\n triggerAriaProps['aria-label'] = state.content.children;\n } else {\n triggerAriaProps['aria-labelledby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === 'description') {\n triggerAriaProps['aria-describedby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n const childTargetRef = useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...(child === null || child === void 0 ? void 0 : child.props),\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))\n });\n return state;\n};\n//# sourceMappingURL=useTooltip.js.map"],"names":["useTooltip_unstable","props","_child_props","_child_props1","_child_props2","_child_props3","context","useTooltipVisibility","isServerSideRender","useIsSSR","targetDocument","useFluent","setDelayTimeout","clearDelayTimeout","useTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","useControllableState","state","initialState","setVisible","React","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","resolveShorthand","defaultProps","role","required","id","useId","positioningOptions","enabled","arrowPadding","tooltipBorderRadius","position","align","offset","resolvePositioningShorthand","mergeArrowOffset","arrowHeight","targetRef","containerRef","arrowRef","usePositioning","ref","useMergedRefs","useIsomorphicLayoutEffect","_context_visibleTooltip","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","Escape","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","mergeCallbacks","onPointerLeave","onFocus","onBlur","child","getTriggerChild","triggerAriaProps","childTargetRef","applyTriggerPropsToChildren","useEventCallback"],"mappings":";;;;+BAc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KAAK,IAAI,KAAK,IAAIA,cAAckF,MAAM,EAAEP;IAC5L;IACA,OAAOpD;AACT,GACA,sCAAsC"}
|
@@ -14,7 +14,7 @@ _export(exports, {
|
|
14
14
|
});
|
15
15
|
const _react = require("@griffel/react");
|
16
16
|
const tooltipClassNames = {
|
17
|
-
content:
|
17
|
+
content: 'fui-Tooltip__content'
|
18
18
|
};
|
19
19
|
/**
|
20
20
|
* Styles for the tooltip
|
@@ -172,7 +172,7 @@ const tooltipClassNames = {
|
|
172
172
|
".f1bsuimh{z-index:-1;}",
|
173
173
|
".f1ekdpwm{width:8.484px;}",
|
174
174
|
".f83vc9z{height:8.484px;}",
|
175
|
-
|
175
|
+
".f1wl9k8s::before{content:\"\";}",
|
176
176
|
".f1wkw4r9::before{visibility:visible;}",
|
177
177
|
".f1j7ml58::before{position:absolute;}",
|
178
178
|
".fyl8oag::before{box-sizing:border-box;}",
|
@@ -189,19 +189,19 @@ const tooltipClassNames = {
|
|
189
189
|
".f112wvtl::before{border-bottom-left-radius:var(--borderRadiusSmall);}",
|
190
190
|
".ftj5xct::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);}",
|
191
191
|
".fyavhwi::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);}",
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
192
|
+
"[data-popper-placement^=\"top\"] .f1773hnp{bottom:-1px;}",
|
193
|
+
"[data-popper-placement^=\"top\"] .f1n8855c{--angle:0;}",
|
194
|
+
"[data-popper-placement^=\"right\"] .f1v7783n{left:-1px;}",
|
195
|
+
"[data-popper-placement^=\"right\"] .fsw6im5{--angle:90deg;}",
|
196
|
+
"[data-popper-placement^=\"bottom\"] .fh2hsk5{top:-1px;}",
|
197
|
+
"[data-popper-placement^=\"bottom\"] .f159pzir{--angle:180deg;}",
|
198
|
+
"[data-popper-placement^=\"left\"] .f11yvu4{right:-1px;}",
|
199
|
+
"[data-popper-placement^=\"left\"] .fm1ycve{--angle:270deg;}"
|
200
200
|
]
|
201
201
|
});
|
202
202
|
const useTooltipStyles_unstable = (state)=>{
|
203
203
|
const styles = useStyles();
|
204
|
-
state.content.className = (0, _react.mergeClasses)(tooltipClassNames.content, styles.root, state.appearance ===
|
204
|
+
state.content.className = (0, _react.mergeClasses)(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
|
205
205
|
state.arrowClassName = styles.arrow;
|
206
206
|
return state;
|
207
207
|
}; //# sourceMappingURL=useTooltipStyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Tooltip/useTooltipStyles.js"],"sourcesContent":["import { shorthands, __styles, mergeClasses } from
|
1
|
+
{"version":3,"sources":["../../../lib/components/Tooltip/useTooltipStyles.js"],"sourcesContent":["import { shorthands, __styles, mergeClasses } from '@griffel/react';\nimport { createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport { arrowHeight } from './private/constants';\nexport const tooltipClassNames = {\n content: 'fui-Tooltip__content'\n};\n/**\n * Styles for the tooltip\n */\nconst useStyles = /*#__PURE__*/__styles({\n root: {\n mc9l5x: \"fjseox\",\n B7ck84d: \"f1ewtqcl\",\n B2u0y6b: \"f132xexn\",\n Bceei9c: \"f158kwzp\",\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fy9rknc\",\n Bg96gwp: \"fwrc4pm\",\n Bbmb7ep: [\"f1aa9q02\", \"f16jpd5f\"],\n Beyfa6y: [\"f16jpd5f\", \"f1aa9q02\"],\n B7oj6ja: [\"f1jar5jt\", \"fyu767a\"],\n Btl43ni: [\"fyu767a\", \"f1jar5jt\"],\n B4j52fo: \"f5ogflp\",\n Bekrc4i: [\"f1hqa2wf\", \"finvdd3\"],\n Bn0qgzm: \"f1f09k3d\",\n ibv6hh: [\"finvdd3\", \"f1hqa2wf\"],\n icvyot: \"fzkkow9\",\n vrafjx: [\"fcdblym\", \"fjik90z\"],\n oivjwe: \"fg706s2\",\n wvpqe5: [\"fjik90z\", \"fcdblym\"],\n g2u3we: \"fghlq4f\",\n h3c5rm: [\"f1gn591s\", \"fjscplz\"],\n B9xav0g: \"fb073pr\",\n zhjwy3: [\"fjscplz\", \"f1gn591s\"],\n z8tnut: \"f10ra9hq\",\n z189sj: [\"fd9xhir\", \"f1jlaasf\"],\n Byoj8tv: \"f1d7kygh\",\n uwmqm3: [\"f1jlaasf\", \"fd9xhir\"],\n De3pzq: \"fxugw4r\",\n sj55zd: \"f19n0e5\",\n Bhu2qc9: \"fxeb0a7\"\n },\n visible: {\n mc9l5x: \"ftgm304\"\n },\n inverted: {\n De3pzq: \"fg3r6xk\",\n sj55zd: \"fonrgv7\"\n },\n arrow: {\n qhf8xq: \"f1euv43f\",\n De3pzq: \"f1u2r49w\",\n Bcdw1i0: \"fd7fpy0\",\n Bj3rh1h: \"f1bsuimh\",\n a9b677: \"f1ekdpwm\",\n Bqenvij: \"f83vc9z\",\n Ftih45: \"f1wl9k8s\",\n B1puzpu: \"f1wkw4r9\",\n Brfgrao: \"f1j7ml58\",\n Bcvre1j: \"fyl8oag\",\n Ccq8qp: \"frdoeuz\",\n Baz25je: \"fb81m9q\",\n cmx5o7: \"f1ljr5q2\",\n B4f6apu: \"fyfemzf\",\n m598lv: \"focyt6c\",\n Bk5zm6e: \"fnhxbxj\",\n y0oebl: \"fdw6hkg\",\n qa3bma: \"f11yjt3y\",\n Bqjgrrk: \"f1172wan\",\n Budzafs: [\"f9e5op9\", \"f112wvtl\"],\n Hv9wc6: [\"ftj5xct\", \"fyavhwi\"],\n hl6cv3: \"f1773hnp\",\n Bh2vraf: \"f1n8855c\",\n yayu3t: \"f1v7783n\",\n wedwtw: \"fsw6im5\",\n rhl9o9: \"fh2hsk5\",\n Bu8t5uz: \"f159pzir\",\n B6q6orb: \"f11yvu4\",\n Bwwlvwl: \"fm1ycve\"\n }\n}, {\n d: [\".fjseox{display:none;}\", \".f1ewtqcl{box-sizing:border-box;}\", \".f132xexn{max-width:240px;}\", \".f158kwzp{cursor:default;}\", \".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fy9rknc{font-size:var(--fontSizeBase200);}\", \".fwrc4pm{line-height:var(--lineHeightBase200);}\", \".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}\", \".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}\", \".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}\", \".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}\", \".f5ogflp{border-top-width:1px;}\", \".f1hqa2wf{border-right-width:1px;}\", \".finvdd3{border-left-width:1px;}\", \".f1f09k3d{border-bottom-width:1px;}\", \".fzkkow9{border-top-style:solid;}\", \".fcdblym{border-right-style:solid;}\", \".fjik90z{border-left-style:solid;}\", \".fg706s2{border-bottom-style:solid;}\", \".fghlq4f{border-top-color:var(--colorTransparentStroke);}\", \".f1gn591s{border-right-color:var(--colorTransparentStroke);}\", \".fjscplz{border-left-color:var(--colorTransparentStroke);}\", \".fb073pr{border-bottom-color:var(--colorTransparentStroke);}\", \".f10ra9hq{padding-top:4px;}\", \".fd9xhir{padding-right:11px;}\", \".f1jlaasf{padding-left:11px;}\", \".f1d7kygh{padding-bottom:6px;}\", \".fxugw4r{background-color:var(--colorNeutralBackground1);}\", \".f19n0e5{color:var(--colorNeutralForeground1);}\", \".fxeb0a7{-webkit-filter:drop-shadow(0 0 2px var(--colorNeutralShadowAmbient)) drop-shadow(0 4px 8px var(--colorNeutralShadowKey));filter:drop-shadow(0 0 2px var(--colorNeutralShadowAmbient)) drop-shadow(0 4px 8px var(--colorNeutralShadowKey));}\", \".ftgm304{display:block;}\", \".fg3r6xk{background-color:var(--colorNeutralBackgroundStatic);}\", \".fonrgv7{color:var(--colorNeutralForegroundStaticInverted);}\", \".f1euv43f{position:absolute;}\", \".f1u2r49w{background-color:inherit;}\", \".fd7fpy0{visibility:hidden;}\", \".f1bsuimh{z-index:-1;}\", \".f1ekdpwm{width:8.484px;}\", \".f83vc9z{height:8.484px;}\", \".f1wl9k8s::before{content:\\\"\\\";}\", \".f1wkw4r9::before{visibility:visible;}\", \".f1j7ml58::before{position:absolute;}\", \".fyl8oag::before{box-sizing:border-box;}\", \".frdoeuz::before{width:inherit;}\", \".fb81m9q::before{height:inherit;}\", \".f1ljr5q2::before{background-color:inherit;}\", \".fyfemzf::before{border-right-width:1px;}\", \".focyt6c::before{border-right-style:solid;}\", \".fnhxbxj::before{border-right-color:var(--colorTransparentStroke);}\", \".fdw6hkg::before{border-bottom-width:1px;}\", \".f11yjt3y::before{border-bottom-style:solid;}\", \".f1172wan::before{border-bottom-color:var(--colorTransparentStroke);}\", \".f9e5op9::before{border-bottom-right-radius:var(--borderRadiusSmall);}\", \".f112wvtl::before{border-bottom-left-radius:var(--borderRadiusSmall);}\", \".ftj5xct::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);}\", \".fyavhwi::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);}\", \"[data-popper-placement^=\\\"top\\\"] .f1773hnp{bottom:-1px;}\", \"[data-popper-placement^=\\\"top\\\"] .f1n8855c{--angle:0;}\", \"[data-popper-placement^=\\\"right\\\"] .f1v7783n{left:-1px;}\", \"[data-popper-placement^=\\\"right\\\"] .fsw6im5{--angle:90deg;}\", \"[data-popper-placement^=\\\"bottom\\\"] .fh2hsk5{top:-1px;}\", \"[data-popper-placement^=\\\"bottom\\\"] .f159pzir{--angle:180deg;}\", \"[data-popper-placement^=\\\"left\\\"] .f11yvu4{right:-1px;}\", \"[data-popper-placement^=\\\"left\\\"] .fm1ycve{--angle:270deg;}\"]\n});\n/**\n * Apply styling to the Tooltip slots based on the state\n */\nexport const useTooltipStyles_unstable = state => {\n const styles = useStyles();\n state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);\n state.arrowClassName = styles.arrow;\n return state;\n};\n//# sourceMappingURL=useTooltipStyles.js.map"],"names":["tooltipClassNames","useTooltipStyles_unstable","content","useStyles","__styles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Bbmb7ep","Beyfa6y","B7oj6ja","Btl43ni","B4j52fo","Bekrc4i","Bn0qgzm","ibv6hh","icvyot","vrafjx","oivjwe","wvpqe5","g2u3we","h3c5rm","B9xav0g","zhjwy3","z8tnut","z189sj","Byoj8tv","uwmqm3","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bcdw1i0","Bj3rh1h","a9b677","Bqenvij","Ftih45","B1puzpu","Brfgrao","Bcvre1j","Ccq8qp","Baz25je","cmx5o7","B4f6apu","m598lv","Bk5zm6e","y0oebl","qa3bma","Bqjgrrk","Budzafs","Hv9wc6","hl6cv3","Bh2vraf","yayu3t","wedwtw","rhl9o9","Bu8t5uz","B6q6orb","Bwwlvwl","d","state","styles","className","mergeClasses","appearance","arrowClassName"],"mappings":";;;;;;;;;;;IAIaA,iBAAiB,MAAjBA;IAmFAC,yBAAyB,MAAzBA;;uBAvFsC;AAI5C,M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;AACF,GAAG;IACDC,GAAG;QAAC;QAA0B;QAAqC;QAA+B;QAA8B;QAAgD;QAA+C;QAAmD;QAAoE;QAAmE;QAAiE;QAA+D;QAAmC;QAAsC;QAAoC;QAAuC;QAAqC;QAAuC;QAAsC;QAAwC;QAA6D;QAAgE;QAA8D;QAAgE;QAA+B;QAAiC;QAAiC;QAAkC;QAA8D;QAAmD;QAAwP;QAA4B;QAAmE;QAAgE;QAAiC;QAAwC;QAAgC;QAA0B;QAA6B;QAA6B;QAAoC;QAA0C;QAAyC;QAA4C;QAAoC;QAAqC;QAAgD;QAA6C;QAA+C;QAAuE;QAA8C;QAAiD;QAAyE;QAA0E;QAA0E;QAAmS;QAAuS;QAA4D;QAA0D;QAA4D;QAA+D;QAA2D;QAAkE;QAA2D;KAA8D;AACxrH;AAIO,MAAMlE,4BAA4BmE,CAAAA,QAAS;IAChD,MAAMC,SAASlE;IACfiE,MAAMlE,OAAO,CAACoE,SAAS,GAAGC,IAAAA,mBAAY,EAACvE,kBAAkBE,OAAO,EAAEmE,OAAOhE,IAAI,EAAE+D,MAAMI,UAAU,KAAK,cAAcH,OAAOhC,QAAQ,EAAE+B,MAAMhC,OAAO,IAAIiC,OAAOjC,OAAO,EAAEgC,MAAMlE,OAAO,CAACoE,SAAS;IAC3LF,MAAMK,cAAc,GAAGJ,OAAO/B,KAAK;IACnC,OAAO8B;AACT,GACA,4CAA4C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { Tooltip, renderTooltip_unstable, tooltipClassNames, useTooltipStyles_unstable, useTooltip_unstable } from
|
1
|
+
{"version":3,"sources":["../lib/index.js"],"sourcesContent":["export { Tooltip, renderTooltip_unstable, tooltipClassNames, useTooltipStyles_unstable, useTooltip_unstable } from './Tooltip';\n//# sourceMappingURL=index.js.map"],"names":["Tooltip","renderTooltip_unstable","tooltipClassNames","useTooltipStyles_unstable","useTooltip_unstable"],"mappings":";;;;;;;;;;;IAASA,OAAO,MAAPA,gBAAO;IAAEC,sBAAsB,MAAtBA,+BAAsB;IAAEC,iBAAiB,MAAjBA,0BAAiB;IAAEC,yBAAyB,MAAzBA,kCAAyB;IAAEC,mBAAmB,MAAnBA,4BAAmB;;yBAAQ;CACnH,iCAAiC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-tooltip",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20230322-0439.1",
|
4
4
|
"description": "React components for building web experiences",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -27,17 +27,17 @@
|
|
27
27
|
"devDependencies": {
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
29
29
|
"@fluentui/react-conformance": "*",
|
30
|
-
"@fluentui/react-conformance-griffel": "0.0.0-nightly-
|
30
|
+
"@fluentui/react-conformance-griffel": "0.0.0-nightly-20230322-0439.1",
|
31
31
|
"@fluentui/scripts-api-extractor": "*",
|
32
32
|
"@fluentui/scripts-tasks": "*"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@fluentui/keyboard-keys": "0.0.0-nightly-
|
36
|
-
"@fluentui/react-portal": "0.0.0-nightly-
|
37
|
-
"@fluentui/react-positioning": "0.0.0-nightly-
|
38
|
-
"@fluentui/react-shared-contexts": "0.0.0-nightly-
|
39
|
-
"@fluentui/react-theme": "0.0.0-nightly-
|
40
|
-
"@fluentui/react-utilities": "0.0.0-nightly-
|
35
|
+
"@fluentui/keyboard-keys": "0.0.0-nightly-20230322-0439.1",
|
36
|
+
"@fluentui/react-portal": "0.0.0-nightly-20230322-0439.1",
|
37
|
+
"@fluentui/react-positioning": "0.0.0-nightly-20230322-0439.1",
|
38
|
+
"@fluentui/react-shared-contexts": "0.0.0-nightly-20230322-0439.1",
|
39
|
+
"@fluentui/react-theme": "0.0.0-nightly-20230322-0439.1",
|
40
|
+
"@fluentui/react-utilities": "0.0.0-nightly-20230322-0439.1",
|
41
41
|
"@griffel/react": "^1.5.2",
|
42
42
|
"@swc/helpers": "^0.4.14"
|
43
43
|
},
|
@@ -51,6 +51,7 @@
|
|
51
51
|
"exports": {
|
52
52
|
".": {
|
53
53
|
"types": "./dist/index.d.ts",
|
54
|
+
"node": "./lib-commonjs/index.js",
|
54
55
|
"import": "./lib/index.js",
|
55
56
|
"require": "./lib-commonjs/index.js"
|
56
57
|
},
|