@fluentui/react-tooltip 0.0.0-nightlydd0f007b3f20220119.1 → 0.0.0-nightlye0b8e1fa6920220128.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +43 -25
- package/CHANGELOG.md +16 -14
- package/dist/react-tooltip.d.ts +21 -37
- package/lib/components/Tooltip/Tooltip.d.ts +2 -2
- package/lib/components/Tooltip/Tooltip.js +8 -9
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.types.d.ts +15 -29
- package/lib/components/Tooltip/renderTooltip.d.ts +1 -1
- package/lib/components/Tooltip/renderTooltip.js +3 -3
- package/lib/components/Tooltip/renderTooltip.js.map +1 -1
- package/lib/components/Tooltip/useTooltip.d.ts +3 -5
- package/lib/components/Tooltip/useTooltip.js +33 -34
- package/lib/components/Tooltip/useTooltip.js.map +1 -1
- package/lib/components/Tooltip/useTooltipStyles.d.ts +1 -1
- package/lib/components/Tooltip/useTooltipStyles.js +7 -7
- package/lib/components/Tooltip/useTooltipStyles.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.d.ts +2 -2
- package/lib-commonjs/components/Tooltip/Tooltip.js +7 -7
- package/lib-commonjs/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.types.d.ts +15 -29
- package/lib-commonjs/components/Tooltip/renderTooltip.d.ts +1 -1
- package/lib-commonjs/components/Tooltip/renderTooltip.js +5 -5
- package/lib-commonjs/components/Tooltip/renderTooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltip.d.ts +3 -5
- package/lib-commonjs/components/Tooltip/useTooltip.js +34 -35
- package/lib-commonjs/components/Tooltip/useTooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltipStyles.d.ts +1 -1
- package/lib-commonjs/components/Tooltip/useTooltipStyles.js +10 -10
- package/lib-commonjs/components/Tooltip/useTooltipStyles.js.map +1 -1
- package/package.json +8 -10
package/CHANGELOG.json
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
"name": "@fluentui/react-tooltip",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-tooltip_v0.0.0-
|
7
|
-
"version": "0.0.0-
|
5
|
+
"date": "Fri, 28 Jan 2022 04:13:23 GMT",
|
6
|
+
"tag": "@fluentui/react-tooltip_v0.0.0-nightlye0b8e1fa6920220128.1",
|
7
|
+
"version": "0.0.0-nightlye0b8e1fa6920220128.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
11
11
|
"author": "email not defined",
|
12
12
|
"package": "@fluentui/react-tooltip",
|
13
|
-
"commit": "
|
13
|
+
"commit": "90d10ec8c2d159575962c4d3d913317633b44a7a",
|
14
14
|
"comment": "Release nightly v9"
|
15
15
|
},
|
16
16
|
{
|
@@ -31,12 +31,24 @@
|
|
31
31
|
"commit": "1bbb753830028fbf133858d523ae2d56ceefeecf",
|
32
32
|
"comment": "update styles to not use CSS shorthands"
|
33
33
|
},
|
34
|
+
{
|
35
|
+
"author": "behowell@microsoft.com",
|
36
|
+
"package": "@fluentui/react-tooltip",
|
37
|
+
"commit": "317209bb5cd57c40f35bc42060acb7e3cce5ec95",
|
38
|
+
"comment": "BREAKING: Rename component hooks add the suffix _unstable, as their API has not been finalized yet"
|
39
|
+
},
|
34
40
|
{
|
35
41
|
"author": "behowell@microsoft.com",
|
36
42
|
"package": "@fluentui/react-tooltip",
|
37
43
|
"commit": "7cc28ed8320b00f42d91c63882f10316db2205c5",
|
38
44
|
"comment": "Remove component's shorthandProps array"
|
39
45
|
},
|
46
|
+
{
|
47
|
+
"author": "Humberto.Morimoto@microsoft.com",
|
48
|
+
"package": "@fluentui/react-tooltip",
|
49
|
+
"commit": "e0b8e1fa6980077e7b311fd1c72c28d3e4305db0",
|
50
|
+
"comment": "Updating based on changes to composition types."
|
51
|
+
},
|
40
52
|
{
|
41
53
|
"author": "behowell@microsoft.com",
|
42
54
|
"package": "@fluentui/react-tooltip",
|
@@ -50,58 +62,58 @@
|
|
50
62
|
"comment": "Remove Tooltip's inverted prop in favor of the appearance prop"
|
51
63
|
},
|
52
64
|
{
|
53
|
-
"author": "
|
65
|
+
"author": "olfedias@microsoft.com",
|
54
66
|
"package": "@fluentui/react-tooltip",
|
55
|
-
"
|
56
|
-
"
|
67
|
+
"commit": "02e6236e4db8e1b591223475896537e905bf3580",
|
68
|
+
"comment": "BREAKING: implement `content` slot"
|
57
69
|
},
|
58
70
|
{
|
59
|
-
"author": "
|
71
|
+
"author": "olfedias@microsoft.com",
|
60
72
|
"package": "@fluentui/react-tooltip",
|
61
|
-
"
|
62
|
-
"
|
73
|
+
"commit": "17c0b18d7983d414095661bf9f57e14c0c22685d",
|
74
|
+
"comment": "Replace make-styles packages with griffel equivalents."
|
63
75
|
},
|
64
76
|
{
|
65
|
-
"author": "
|
77
|
+
"author": "behowell@microsoft.com",
|
66
78
|
"package": "@fluentui/react-tooltip",
|
67
|
-
"
|
68
|
-
"
|
79
|
+
"commit": "58ae40d6817b1fa4e095a94707dfef5050aa4c11",
|
80
|
+
"comment": "Replace `triggerAriaAttribute` prop with `relationship` and make it required with no default"
|
69
81
|
},
|
70
82
|
{
|
71
83
|
"author": "beachball",
|
72
84
|
"package": "@fluentui/react-tooltip",
|
73
|
-
"comment": "Bump @fluentui/react-
|
74
|
-
"commit": "
|
85
|
+
"comment": "Bump @fluentui/react-portal to v0.0.0-nightlye0b8e1fa6920220128.1",
|
86
|
+
"commit": "90d10ec8c2d159575962c4d3d913317633b44a7a"
|
75
87
|
},
|
76
88
|
{
|
77
89
|
"author": "beachball",
|
78
90
|
"package": "@fluentui/react-tooltip",
|
79
|
-
"comment": "Bump @fluentui/react-
|
80
|
-
"commit": "
|
91
|
+
"comment": "Bump @fluentui/react-positioning to v0.0.0-nightlye0b8e1fa6920220128.1",
|
92
|
+
"commit": "90d10ec8c2d159575962c4d3d913317633b44a7a"
|
81
93
|
},
|
82
94
|
{
|
83
95
|
"author": "beachball",
|
84
96
|
"package": "@fluentui/react-tooltip",
|
85
|
-
"comment": "Bump @fluentui/react-
|
86
|
-
"commit": "
|
97
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightlye0b8e1fa6920220128.1",
|
98
|
+
"commit": "90d10ec8c2d159575962c4d3d913317633b44a7a"
|
87
99
|
},
|
88
100
|
{
|
89
101
|
"author": "beachball",
|
90
102
|
"package": "@fluentui/react-tooltip",
|
91
|
-
"comment": "Bump @fluentui/
|
92
|
-
"commit": "
|
103
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightlye0b8e1fa6920220128.1",
|
104
|
+
"commit": "90d10ec8c2d159575962c4d3d913317633b44a7a"
|
93
105
|
},
|
94
106
|
{
|
95
107
|
"author": "beachball",
|
96
108
|
"package": "@fluentui/react-tooltip",
|
97
|
-
"comment": "Bump @fluentui/
|
98
|
-
"commit": "
|
109
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightlye0b8e1fa6920220128.1",
|
110
|
+
"commit": "90d10ec8c2d159575962c4d3d913317633b44a7a"
|
99
111
|
},
|
100
112
|
{
|
101
113
|
"author": "beachball",
|
102
114
|
"package": "@fluentui/react-tooltip",
|
103
|
-
"comment": "Bump @fluentui/react-conformance-
|
104
|
-
"commit": "
|
115
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightlye0b8e1fa6920220128.1",
|
116
|
+
"commit": "90d10ec8c2d159575962c4d3d913317633b44a7a"
|
105
117
|
}
|
106
118
|
],
|
107
119
|
"none": [
|
@@ -117,6 +129,12 @@
|
|
117
129
|
"commit": "b59f44ed5db37b457476fdb3ec86ff273b776646",
|
118
130
|
"comment": "Migrate package to use solution tsconfigs"
|
119
131
|
},
|
132
|
+
{
|
133
|
+
"author": "olfedias@microsoft.com",
|
134
|
+
"package": "@fluentui/react-tooltip",
|
135
|
+
"commit": "c061e98be4b4a718c72a144a1f60bb5515824612",
|
136
|
+
"comment": "remove inline-style-expand-shorthand from tsconfigs"
|
137
|
+
},
|
120
138
|
{
|
121
139
|
"author": "elcraig@microsoft.com",
|
122
140
|
"package": "@fluentui/react-tooltip",
|
package/CHANGELOG.md
CHANGED
@@ -1,32 +1,34 @@
|
|
1
1
|
# Change Log - @fluentui/react-tooltip
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 28 Jan 2022 04:13:23 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-
|
7
|
+
## [0.0.0-nightlye0b8e1fa6920220128.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v0.0.0-nightlye0b8e1fa6920220128.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.0.0-beta.5..@fluentui/react-tooltip_v0.0.0-
|
9
|
+
Fri, 28 Jan 2022 04:13:23 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.0.0-beta.5..@fluentui/react-tooltip_v0.0.0-nightlye0b8e1fa6920220128.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
|
-
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/
|
14
|
+
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/90d10ec8c2d159575962c4d3d913317633b44a7a) by email not defined)
|
15
15
|
- Move arrowHeight and tooltipBorderRadius into a shared constants.ts file ([PR #21204](https://github.com/microsoft/fluentui/pull/21204) by behowell@microsoft.com)
|
16
16
|
- Replacing use of functions in makeStyles with direct use of tokens. ([PR #21058](https://github.com/microsoft/fluentui/pull/21058) by Humberto.Morimoto@microsoft.com)
|
17
17
|
- update styles to not use CSS shorthands ([PR #20795](https://github.com/microsoft/fluentui/pull/20795) by olfedias@microsoft.com)
|
18
|
+
- BREAKING: Rename component hooks add the suffix _unstable, as their API has not been finalized yet ([PR #21365](https://github.com/microsoft/fluentui/pull/21365) by behowell@microsoft.com)
|
18
19
|
- Remove component's shorthandProps array ([PR #21134](https://github.com/microsoft/fluentui/pull/21134) by behowell@microsoft.com)
|
20
|
+
- Updating based on changes to composition types. ([PR #20891](https://github.com/microsoft/fluentui/pull/20891) by Humberto.Morimoto@microsoft.com)
|
19
21
|
- Fix tooltip arrow rendering, and add high contrast border around Tooltip ([PR #21086](https://github.com/microsoft/fluentui/pull/21086) by behowell@microsoft.com)
|
20
22
|
- Remove Tooltip's inverted prop in favor of the appearance prop ([PR #21327](https://github.com/microsoft/fluentui/pull/21327) by behowell@microsoft.com)
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
24
|
-
- Bump @fluentui/react-
|
25
|
-
- Bump @fluentui/react-
|
26
|
-
- Bump @fluentui/react-
|
27
|
-
- Bump @fluentui/
|
28
|
-
- Bump @fluentui/
|
29
|
-
- Bump @fluentui/react-conformance-
|
23
|
+
- BREAKING: implement `content` slot ([PR #21470](https://github.com/microsoft/fluentui/pull/21470) by olfedias@microsoft.com)
|
24
|
+
- Replace make-styles packages with griffel equivalents. ([PR #21422](https://github.com/microsoft/fluentui/pull/21422) by olfedias@microsoft.com)
|
25
|
+
- Replace `triggerAriaAttribute` prop with `relationship` and make it required with no default ([PR #21331](https://github.com/microsoft/fluentui/pull/21331) by behowell@microsoft.com)
|
26
|
+
- Bump @fluentui/react-portal to v0.0.0-nightlye0b8e1fa6920220128.1 ([commit](https://github.com/microsoft/fluentui/commit/90d10ec8c2d159575962c4d3d913317633b44a7a) by beachball)
|
27
|
+
- Bump @fluentui/react-positioning to v0.0.0-nightlye0b8e1fa6920220128.1 ([commit](https://github.com/microsoft/fluentui/commit/90d10ec8c2d159575962c4d3d913317633b44a7a) by beachball)
|
28
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightlye0b8e1fa6920220128.1 ([commit](https://github.com/microsoft/fluentui/commit/90d10ec8c2d159575962c4d3d913317633b44a7a) by beachball)
|
29
|
+
- Bump @fluentui/react-theme to v0.0.0-nightlye0b8e1fa6920220128.1 ([commit](https://github.com/microsoft/fluentui/commit/90d10ec8c2d159575962c4d3d913317633b44a7a) by beachball)
|
30
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightlye0b8e1fa6920220128.1 ([commit](https://github.com/microsoft/fluentui/commit/90d10ec8c2d159575962c4d3d913317633b44a7a) by beachball)
|
31
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightlye0b8e1fa6920220128.1 ([commit](https://github.com/microsoft/fluentui/commit/90d10ec8c2d159575962c4d3d913317633b44a7a) by beachball)
|
30
32
|
|
31
33
|
## [9.0.0-beta.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.0.0-beta.5)
|
32
34
|
|
package/dist/react-tooltip.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import type { ComponentProps } from '@fluentui/react-utilities';
|
2
2
|
import type { ComponentState } from '@fluentui/react-utilities';
|
3
|
-
import type {
|
4
|
-
import type { IntrinsicShorthandProps } from '@fluentui/react-utilities';
|
3
|
+
import type { IntrinsicSlotProps } from '@fluentui/react-utilities';
|
5
4
|
import type { PositioningShorthand } from '@fluentui/react-positioning';
|
6
5
|
import * as React_2 from 'react';
|
7
6
|
|
@@ -15,12 +14,12 @@ export declare type OnVisibleChangeData = {
|
|
15
14
|
/**
|
16
15
|
* Render the final JSX of Tooltip
|
17
16
|
*/
|
18
|
-
export declare const
|
17
|
+
export declare const renderTooltip_unstable: (state: TooltipState) => JSX.Element;
|
19
18
|
|
20
19
|
/**
|
21
20
|
* A tooltip provides light weight contextual information on top of its target element.
|
22
21
|
*/
|
23
|
-
export declare const Tooltip:
|
22
|
+
export declare const Tooltip: React_2.FC<TooltipProps>;
|
24
23
|
|
25
24
|
export declare const tooltipClassName = "fui-Tooltip";
|
26
25
|
|
@@ -36,10 +35,6 @@ export declare type TooltipCommons = {
|
|
36
35
|
* @defaultvalue normal
|
37
36
|
*/
|
38
37
|
appearance?: 'normal' | 'inverted';
|
39
|
-
/**
|
40
|
-
* The content displayed inside the tooltip.
|
41
|
-
*/
|
42
|
-
content: React_2.ReactNode;
|
43
38
|
/**
|
44
39
|
* Render an arrow pointing to the target element
|
45
40
|
*
|
@@ -66,15 +61,15 @@ export declare type TooltipCommons = {
|
|
66
61
|
*/
|
67
62
|
onVisibleChange?: (event: React_2.PointerEvent<HTMLElement> | React_2.FocusEvent<HTMLElement> | undefined, data: OnVisibleChangeData) => void;
|
68
63
|
/**
|
69
|
-
* Specifies
|
70
|
-
* * `label` - Set aria-label to the tooltip's content. Requires content to be a string; if not, uses `labelledby`.
|
71
|
-
* * `labelledby` - Set aria-labelledby to the tooltip's id. The id is generated if not provided.
|
72
|
-
* * `describedby` - Set aria-describedby to the tooltip's id. The id is generated if not provided.
|
73
|
-
* * null - Do not set any aria attributes on the trigger element.
|
64
|
+
* (Required) Specifies whether this tooltip is acting as the description or label of its trigger element.
|
74
65
|
*
|
75
|
-
*
|
66
|
+
* * `label` - The tooltip sets the trigger's aria-label or aria-labelledby attribute. This is useful for buttons
|
67
|
+
* displaying only an icon, for example.
|
68
|
+
* * `description` - The tooltip sets the trigger's aria-description or aria-describedby attribute.
|
69
|
+
* * `inaccessible` - No aria attributes are set on the trigger. This makes the tooltip's content inaccessible to
|
70
|
+
* screen readers, and should only be used if the tooltip's text is available by some other means.
|
76
71
|
*/
|
77
|
-
|
72
|
+
relationship: 'label' | 'description' | 'inaccessible';
|
78
73
|
/**
|
79
74
|
* Delay before the tooltip is shown, in milliseconds.
|
80
75
|
*
|
@@ -92,36 +87,26 @@ export declare type TooltipCommons = {
|
|
92
87
|
/**
|
93
88
|
* Properties for Tooltip
|
94
89
|
*/
|
95
|
-
export declare type TooltipProps = ComponentProps<TooltipSlots> & Partial<Omit<TooltipCommons, '
|
90
|
+
export declare type TooltipProps = Omit<ComponentProps<TooltipSlots>, 'content'> & Required<Pick<ComponentProps<TooltipSlots>, 'content'>> & Partial<Omit<TooltipCommons, 'relationship'>> & Pick<TooltipCommons, 'relationship'> & {
|
91
|
+
children?: (React_2.ReactElement & {
|
92
|
+
ref?: React_2.Ref<unknown>;
|
93
|
+
}) | ((props: TooltipTriggerProps) => React_2.ReactNode) | null;
|
94
|
+
};
|
96
95
|
|
97
96
|
/**
|
98
97
|
* Slot properties for Tooltip
|
99
98
|
*/
|
100
99
|
export declare type TooltipSlots = {
|
101
|
-
|
102
|
-
/**
|
103
|
-
* The child is the element that triggers the Tooltip. It will have additional properties added,
|
104
|
-
* including events and aria properties.
|
105
|
-
* Alternatively, children can be a render function that takes the props and adds
|
106
|
-
* them to the appropriate elements.
|
107
|
-
*/
|
108
|
-
children?: (React_2.ReactElement<React_2.HTMLAttributes<HTMLElement>> & {
|
109
|
-
ref?: React_2.Ref<unknown>;
|
110
|
-
}) | ((props: TooltipTriggerProps) => React_2.ReactNode) | null;
|
111
|
-
};
|
100
|
+
content: IntrinsicSlotProps<'div'>;
|
112
101
|
};
|
113
102
|
|
114
103
|
/**
|
115
104
|
* State used in rendering Tooltip
|
116
105
|
*/
|
117
106
|
export declare type TooltipState = ComponentState<TooltipSlots> & TooltipCommons & {
|
107
|
+
children?: React_2.ReactNode;
|
118
108
|
/**
|
119
109
|
* Whether the tooltip should be rendered to the DOM.
|
120
|
-
*
|
121
|
-
* Normally the tooltip will only be rendered when visible. However, if
|
122
|
-
* triggerAriaAttribute is labelledby or describedby, the tooltip will
|
123
|
-
* always be rendered even when hidden so that those aria attributes
|
124
|
-
* to always refer to a valid DOM element.
|
125
110
|
*/
|
126
111
|
shouldRenderTooltip?: boolean;
|
127
112
|
/**
|
@@ -144,17 +129,16 @@ export declare type TooltipTriggerProps = {
|
|
144
129
|
/**
|
145
130
|
* Create the state required to render Tooltip.
|
146
131
|
*
|
147
|
-
* The returned state can be modified with hooks such as
|
148
|
-
* before being passed to
|
132
|
+
* The returned state can be modified with hooks such as useTooltipStyles_unstable,
|
133
|
+
* before being passed to renderTooltip_unstable.
|
149
134
|
*
|
150
135
|
* @param props - props from this instance of Tooltip
|
151
|
-
* @param ref - reference to root HTMLElement of Tooltip
|
152
136
|
*/
|
153
|
-
export declare const
|
137
|
+
export declare const useTooltip_unstable: (props: TooltipProps) => TooltipState;
|
154
138
|
|
155
139
|
/**
|
156
140
|
* Apply styling to the Tooltip slots based on the state
|
157
141
|
*/
|
158
|
-
export declare const
|
142
|
+
export declare const useTooltipStyles_unstable: (state: TooltipState) => TooltipState;
|
159
143
|
|
160
144
|
export { }
|
@@ -1,6 +1,6 @@
|
|
1
|
+
import * as React from 'react';
|
1
2
|
import type { TooltipProps } from './Tooltip.types';
|
2
|
-
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
3
3
|
/**
|
4
4
|
* A tooltip provides light weight contextual information on top of its target element.
|
5
5
|
*/
|
6
|
-
export declare const Tooltip:
|
6
|
+
export declare const Tooltip: React.FC<TooltipProps>;
|
@@ -1,15 +1,14 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { useTooltipStyles } from './useTooltipStyles';
|
1
|
+
import { useTooltip_unstable } from './useTooltip';
|
2
|
+
import { renderTooltip_unstable } from './renderTooltip';
|
3
|
+
import { useTooltipStyles_unstable } from './useTooltipStyles';
|
5
4
|
/**
|
6
5
|
* A tooltip provides light weight contextual information on top of its target element.
|
7
6
|
*/
|
8
7
|
|
9
|
-
export const Tooltip =
|
10
|
-
const state =
|
11
|
-
|
12
|
-
return
|
13
|
-
}
|
8
|
+
export const Tooltip = props => {
|
9
|
+
const state = useTooltip_unstable(props);
|
10
|
+
useTooltipStyles_unstable(state);
|
11
|
+
return renderTooltip_unstable(state);
|
12
|
+
};
|
14
13
|
Tooltip.displayName = 'Tooltip';
|
15
14
|
//# sourceMappingURL=Tooltip.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,SAAS,mBAAT,QAAoC,cAApC;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AACA,SAAS,yBAAT,QAA0C,oBAA1C;AAGA;;AAEG;;AACH,OAAO,MAAM,OAAO,GAA2B,KAAK,IAAG;AACrD,QAAM,KAAK,GAAG,mBAAmB,CAAC,KAAD,CAAjC;AAEA,EAAA,yBAAyB,CAAC,KAAD,CAAzB;AACA,SAAO,sBAAsB,CAAC,KAAD,CAA7B;AACD,CALM;AAOP,OAAO,CAAC,WAAR,GAAsB,SAAtB","sourceRoot":""}
|
@@ -1,21 +1,11 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import type { PositioningShorthand } from '@fluentui/react-positioning';
|
3
|
-
import type { ComponentProps, ComponentState,
|
3
|
+
import type { ComponentProps, ComponentState, IntrinsicSlotProps } from '@fluentui/react-utilities';
|
4
4
|
/**
|
5
5
|
* Slot properties for Tooltip
|
6
6
|
*/
|
7
7
|
export declare type TooltipSlots = {
|
8
|
-
|
9
|
-
/**
|
10
|
-
* The child is the element that triggers the Tooltip. It will have additional properties added,
|
11
|
-
* including events and aria properties.
|
12
|
-
* Alternatively, children can be a render function that takes the props and adds
|
13
|
-
* them to the appropriate elements.
|
14
|
-
*/
|
15
|
-
children?: (React.ReactElement<React.HTMLAttributes<HTMLElement>> & {
|
16
|
-
ref?: React.Ref<unknown>;
|
17
|
-
}) | ((props: TooltipTriggerProps) => React.ReactNode) | null;
|
18
|
-
};
|
8
|
+
content: IntrinsicSlotProps<'div'>;
|
19
9
|
};
|
20
10
|
/**
|
21
11
|
* Properties and state for Tooltip
|
@@ -29,10 +19,6 @@ export declare type TooltipCommons = {
|
|
29
19
|
* @defaultvalue normal
|
30
20
|
*/
|
31
21
|
appearance?: 'normal' | 'inverted';
|
32
|
-
/**
|
33
|
-
* The content displayed inside the tooltip.
|
34
|
-
*/
|
35
|
-
content: React.ReactNode;
|
36
22
|
/**
|
37
23
|
* Render an arrow pointing to the target element
|
38
24
|
*
|
@@ -59,15 +45,15 @@ export declare type TooltipCommons = {
|
|
59
45
|
*/
|
60
46
|
onVisibleChange?: (event: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined, data: OnVisibleChangeData) => void;
|
61
47
|
/**
|
62
|
-
* Specifies
|
63
|
-
* * `label` - Set aria-label to the tooltip's content. Requires content to be a string; if not, uses `labelledby`.
|
64
|
-
* * `labelledby` - Set aria-labelledby to the tooltip's id. The id is generated if not provided.
|
65
|
-
* * `describedby` - Set aria-describedby to the tooltip's id. The id is generated if not provided.
|
66
|
-
* * null - Do not set any aria attributes on the trigger element.
|
48
|
+
* (Required) Specifies whether this tooltip is acting as the description or label of its trigger element.
|
67
49
|
*
|
68
|
-
*
|
50
|
+
* * `label` - The tooltip sets the trigger's aria-label or aria-labelledby attribute. This is useful for buttons
|
51
|
+
* displaying only an icon, for example.
|
52
|
+
* * `description` - The tooltip sets the trigger's aria-description or aria-describedby attribute.
|
53
|
+
* * `inaccessible` - No aria attributes are set on the trigger. This makes the tooltip's content inaccessible to
|
54
|
+
* screen readers, and should only be used if the tooltip's text is available by some other means.
|
69
55
|
*/
|
70
|
-
|
56
|
+
relationship: 'label' | 'description' | 'inaccessible';
|
71
57
|
/**
|
72
58
|
* Delay before the tooltip is shown, in milliseconds.
|
73
59
|
*
|
@@ -96,18 +82,18 @@ export declare type OnVisibleChangeData = {
|
|
96
82
|
/**
|
97
83
|
* Properties for Tooltip
|
98
84
|
*/
|
99
|
-
export declare type TooltipProps = ComponentProps<TooltipSlots> & Partial<Omit<TooltipCommons, '
|
85
|
+
export declare type TooltipProps = Omit<ComponentProps<TooltipSlots>, 'content'> & Required<Pick<ComponentProps<TooltipSlots>, 'content'>> & Partial<Omit<TooltipCommons, 'relationship'>> & Pick<TooltipCommons, 'relationship'> & {
|
86
|
+
children?: (React.ReactElement & {
|
87
|
+
ref?: React.Ref<unknown>;
|
88
|
+
}) | ((props: TooltipTriggerProps) => React.ReactNode) | null;
|
89
|
+
};
|
100
90
|
/**
|
101
91
|
* State used in rendering Tooltip
|
102
92
|
*/
|
103
93
|
export declare type TooltipState = ComponentState<TooltipSlots> & TooltipCommons & {
|
94
|
+
children?: React.ReactNode;
|
104
95
|
/**
|
105
96
|
* Whether the tooltip should be rendered to the DOM.
|
106
|
-
*
|
107
|
-
* Normally the tooltip will only be rendered when visible. However, if
|
108
|
-
* triggerAriaAttribute is labelledby or describedby, the tooltip will
|
109
|
-
* always be rendered even when hidden so that those aria attributes
|
110
|
-
* to always refer to a valid DOM element.
|
111
97
|
*/
|
112
98
|
shouldRenderTooltip?: boolean;
|
113
99
|
/**
|
@@ -5,15 +5,15 @@ import { getSlots } from '@fluentui/react-utilities';
|
|
5
5
|
* Render the final JSX of Tooltip
|
6
6
|
*/
|
7
7
|
|
8
|
-
export const
|
8
|
+
export const renderTooltip_unstable = state => {
|
9
9
|
const {
|
10
10
|
slots,
|
11
11
|
slotProps
|
12
12
|
} = getSlots(state);
|
13
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, state.
|
13
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(slots.content, { ...slotProps.content
|
14
14
|
}, state.withArrow && /*#__PURE__*/React.createElement("div", {
|
15
15
|
ref: state.arrowRef,
|
16
16
|
className: state.arrowClassName
|
17
|
-
}), state.content)));
|
17
|
+
}), state.content.children)));
|
18
18
|
};
|
19
19
|
//# sourceMappingURL=renderTooltip.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Tooltip/renderTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,MAAT,QAAuB,wBAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,
|
1
|
+
{"version":3,"sources":["../../../src/components/Tooltip/renderTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,MAAT,QAAuB,wBAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,sBAAsB,GAAI,KAAD,IAAwB;AAC5D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAe,KAAf,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EACG,KAAK,CAAC,QADT,EAEG,KAAK,CAAC,mBAAN,iBACC,KAAA,CAAA,aAAA,CAAC,MAAD,EAAO,IAAP,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;AAAf,GAAd,EACG,KAAK,CAAC,SAAN,iBAAmB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAK,IAAA,GAAG,EAAE,KAAK,CAAC,QAAhB;AAA0B,IAAA,SAAS,EAAE,KAAK,CAAC;AAA3C,GAAA,CADtB,EAEG,KAAK,CAAC,OAAN,CAAc,QAFjB,CADF,CAHJ,CADF;AAaD,CAhBM","sourceRoot":""}
|
@@ -1,12 +1,10 @@
|
|
1
|
-
import * as React from 'react';
|
2
1
|
import type { TooltipProps, TooltipState } from './Tooltip.types';
|
3
2
|
/**
|
4
3
|
* Create the state required to render Tooltip.
|
5
4
|
*
|
6
|
-
* The returned state can be modified with hooks such as
|
7
|
-
* before being passed to
|
5
|
+
* The returned state can be modified with hooks such as useTooltipStyles_unstable,
|
6
|
+
* before being passed to renderTooltip_unstable.
|
8
7
|
*
|
9
8
|
* @param props - props from this instance of Tooltip
|
10
|
-
* @param ref - reference to root HTMLElement of Tooltip
|
11
9
|
*/
|
12
|
-
export declare const
|
10
|
+
export declare const useTooltip_unstable: (props: TooltipProps) => TooltipState;
|
@@ -1,19 +1,18 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { mergeArrowOffset, resolvePositioningShorthand, usePopper } from '@fluentui/react-positioning';
|
3
3
|
import { TooltipContext, useFluent } from '@fluentui/react-shared-contexts';
|
4
|
-
import { applyTriggerPropsToChildren,
|
4
|
+
import { applyTriggerPropsToChildren, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useIsSSR, useMergedRefs, useTimeout } from '@fluentui/react-utilities';
|
5
5
|
import { arrowHeight, tooltipBorderRadius } from './private/constants';
|
6
6
|
/**
|
7
7
|
* Create the state required to render Tooltip.
|
8
8
|
*
|
9
|
-
* The returned state can be modified with hooks such as
|
10
|
-
* before being passed to
|
9
|
+
* The returned state can be modified with hooks such as useTooltipStyles_unstable,
|
10
|
+
* before being passed to renderTooltip_unstable.
|
11
11
|
*
|
12
12
|
* @param props - props from this instance of Tooltip
|
13
|
-
* @param ref - reference to root HTMLElement of Tooltip
|
14
13
|
*/
|
15
14
|
|
16
|
-
export const
|
15
|
+
export const useTooltip_unstable = props => {
|
17
16
|
var _a, _b, _c, _d;
|
18
17
|
|
19
18
|
const context = React.useContext(TooltipContext);
|
@@ -23,12 +22,13 @@ export const useTooltip = (props, ref) => {
|
|
23
22
|
} = useFluent();
|
24
23
|
const [setDelayTimeout, clearDelayTimeout] = useTimeout();
|
25
24
|
const {
|
26
|
-
content,
|
27
25
|
appearance,
|
26
|
+
children,
|
27
|
+
content,
|
28
28
|
withArrow,
|
29
29
|
positioning,
|
30
30
|
onVisibleChange,
|
31
|
-
|
31
|
+
relationship,
|
32
32
|
showDelay = 250,
|
33
33
|
hideDelay = 250
|
34
34
|
} = props;
|
@@ -49,26 +49,26 @@ export const useTooltip = (props, ref) => {
|
|
49
49
|
});
|
50
50
|
}, [clearDelayTimeout, setVisibleInternal, onVisibleChange]);
|
51
51
|
const state = {
|
52
|
-
content,
|
53
52
|
withArrow,
|
54
53
|
positioning,
|
55
54
|
showDelay,
|
56
55
|
hideDelay,
|
57
|
-
|
56
|
+
relationship,
|
58
57
|
visible,
|
59
58
|
shouldRenderTooltip: visible,
|
60
59
|
appearance,
|
61
60
|
// Slots
|
62
61
|
components: {
|
63
|
-
|
62
|
+
content: 'div'
|
64
63
|
},
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
content: resolveShorthand(content, {
|
65
|
+
defaultProps: {
|
66
|
+
role: 'tooltip'
|
67
|
+
},
|
68
|
+
required: true
|
70
69
|
})
|
71
70
|
};
|
71
|
+
state.content.id = useId('tooltip-', state.content.id);
|
72
72
|
const popperOptions = {
|
73
73
|
enabled: state.visible,
|
74
74
|
arrowPadding: 2 * tooltipBorderRadius,
|
@@ -87,7 +87,7 @@ export const useTooltip = (props, ref) => {
|
|
87
87
|
containerRef,
|
88
88
|
arrowRef
|
89
89
|
} = usePopper(popperOptions);
|
90
|
-
state.
|
90
|
+
state.content.ref = useMergedRefs(state.content.ref, containerRef);
|
91
91
|
state.arrowRef = arrowRef; // When this tooltip is visible, hide any other tooltips, and register it
|
92
92
|
// as the visibleTooltip with the TooltipContext.
|
93
93
|
// Also add a listener on document to hide the tooltip if Escape is pressed
|
@@ -155,9 +155,9 @@ export const useTooltip = (props, ref) => {
|
|
155
155
|
}, [setDelayTimeout, setVisible, state.hideDelay, targetDocument]); // Cancel the hide timer when the pointer enters the tooltip, and restart it when the mouse leaves.
|
156
156
|
// This keeps the tooltip visible when the pointer is moved over it.
|
157
157
|
|
158
|
-
state.
|
159
|
-
state.
|
160
|
-
const child = /*#__PURE__*/React.isValidElement(
|
158
|
+
state.content.onPointerEnter = useMergedCallbacks(state.content.onPointerEnter, clearDelayTimeout);
|
159
|
+
state.content.onPointerLeave = useMergedCallbacks(state.content.onPointerLeave, onLeaveTrigger);
|
160
|
+
const child = /*#__PURE__*/React.isValidElement(children) ? children : undefined; // The props to add to the trigger element (child)
|
161
161
|
|
162
162
|
const triggerProps = {
|
163
163
|
onPointerEnter: useMergedCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onPointerEnter, onEnterTrigger),
|
@@ -173,26 +173,25 @@ export const useTooltip = (props, ref) => {
|
|
173
173
|
triggerProps.ref = childTargetRef;
|
174
174
|
}
|
175
175
|
|
176
|
-
if (
|
177
|
-
// aria-label only works if the content is a string. Otherwise, need to use labelledby.
|
178
|
-
if (typeof state.content === 'string') {
|
179
|
-
triggerProps['aria-label'] = state.content;
|
180
|
-
} else {
|
181
|
-
state.
|
182
|
-
}
|
183
|
-
}
|
176
|
+
if (relationship === 'label') {
|
177
|
+
// aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
|
178
|
+
if (typeof state.content.children === 'string') {
|
179
|
+
triggerProps['aria-label'] = state.content.children;
|
180
|
+
} else if (!isServerSideRender) {
|
181
|
+
triggerProps['aria-labelledby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
|
184
182
|
|
185
|
-
|
186
|
-
|
183
|
+
state.shouldRenderTooltip = true;
|
184
|
+
}
|
185
|
+
} else if (relationship === 'description') {
|
186
|
+
if (!isServerSideRender) {
|
187
|
+
triggerProps['aria-describedby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
|
187
188
|
|
188
|
-
|
189
|
-
|
190
|
-
triggerProps['aria-describedby'] = state.root.id;
|
191
|
-
state.shouldRenderTooltip = true;
|
189
|
+
state.shouldRenderTooltip = true;
|
190
|
+
}
|
192
191
|
} // Apply the trigger props to the child, either by calling the render function, or cloning with the new props
|
193
192
|
|
194
193
|
|
195
|
-
state.
|
194
|
+
state.children = applyTriggerPropsToChildren(children, triggerProps);
|
196
195
|
return state;
|
197
196
|
};
|
198
197
|
/**
|