@fluentui/react-tooltip 9.10.0 → 9.10.2
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/CHANGELOG.md +29 -2
- package/dist/index.d.ts +1 -1
- package/lib/components/Tooltip/Tooltip.js +0 -1
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.types.js +1 -1
- package/lib/components/Tooltip/Tooltip.types.js.map +1 -1
- package/lib/components/Tooltip/useTooltipBase.js +27 -2
- package/lib/components/Tooltip/useTooltipBase.js.map +1 -1
- package/lib/components/Tooltip/useTooltipStyles.styles.js +2 -0
- package/lib/components/Tooltip/useTooltipStyles.styles.js.map +1 -1
- package/lib/components/Tooltip/useTooltipStyles.styles.raw.js +2 -0
- package/lib/components/Tooltip/useTooltipStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.js +0 -2
- package/lib-commonjs/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.types.js +0 -2
- package/lib-commonjs/components/Tooltip/Tooltip.types.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltipBase.js +23 -0
- package/lib-commonjs/components/Tooltip/useTooltipBase.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltipStyles.styles.js +2 -0
- package/lib-commonjs/components/Tooltip/useTooltipStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltipStyles.styles.raw.js +2 -0
- package/lib-commonjs/components/Tooltip/useTooltipStyles.styles.raw.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-tooltip
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 26 May 2026 09:33:36 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.10.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.10.2)
|
|
8
|
+
|
|
9
|
+
Tue, 26 May 2026 09:33:36 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.10.1..@fluentui/react-tooltip_v9.10.2)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- fix: dismiss Tooltip when the document becomes hidden (e.g. tab backgrounded or app switched on mobile) ([PR #36023](https://github.com/microsoft/fluentui/pull/36023) by 198982749+Copilot@users.noreply.github.com)
|
|
15
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.3 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
16
|
+
- Bump @fluentui/react-portal to v9.8.13 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
17
|
+
- Bump @fluentui/react-positioning to v9.22.2 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
18
|
+
- Bump @fluentui/react-tabster to v9.26.15 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
19
|
+
- Bump @fluentui/react-utilities to v9.26.4 ([PR #36246](https://github.com/microsoft/fluentui/pull/36246) by beachball)
|
|
20
|
+
|
|
21
|
+
## [9.10.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.10.1)
|
|
22
|
+
|
|
23
|
+
Thu, 23 Apr 2026 14:21:05 GMT
|
|
24
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.10.0..@fluentui/react-tooltip_v9.10.1)
|
|
25
|
+
|
|
26
|
+
### Patches
|
|
27
|
+
|
|
28
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.2 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
29
|
+
- Bump @fluentui/react-portal to v9.8.12 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
30
|
+
- Bump @fluentui/react-positioning to v9.22.1 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
31
|
+
- Bump @fluentui/react-tabster to v9.26.14 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
32
|
+
- Bump @fluentui/react-utilities to v9.26.3 ([PR #36035](https://github.com/microsoft/fluentui/pull/36035) by beachball)
|
|
33
|
+
|
|
7
34
|
## [9.10.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.10.0)
|
|
8
35
|
|
|
9
|
-
Wed, 01 Apr 2026 15:
|
|
36
|
+
Wed, 01 Apr 2026 15:52:43 GMT
|
|
10
37
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.9.3..@fluentui/react-tooltip_v9.10.0)
|
|
11
38
|
|
|
12
39
|
### Minor changes
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ComponentState } from '@fluentui/react-utilities';
|
|
|
3
3
|
import type { JSXElement } from '@fluentui/react-utilities';
|
|
4
4
|
import type { PortalProps } from '@fluentui/react-portal';
|
|
5
5
|
import type { PositioningShorthand } from '@fluentui/react-positioning';
|
|
6
|
-
import * as React_2 from 'react';
|
|
6
|
+
import type * as React_2 from 'react';
|
|
7
7
|
import type { Slot } from '@fluentui/react-utilities';
|
|
8
8
|
import type { SlotClassNames } from '@fluentui/react-utilities';
|
|
9
9
|
import type { TriggerProps } from '@fluentui/react-utilities';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useTooltip_unstable } from './useTooltip';\nimport { renderTooltip_unstable } from './renderTooltip';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\nimport { useTooltipStyles_unstable } from './useTooltipStyles.styles';\nimport type { TooltipProps } from './Tooltip.types';\nimport type { FluentTriggerComponent } from '@fluentui/react-utilities';\n\n/**\n * A tooltip provides light weight contextual information on top of its target element.\n */\nexport const Tooltip: React.FC<TooltipProps> = props => {\n const state = useTooltip_unstable(props);\n\n useTooltipStyles_unstable(state);\n\n useCustomStyleHook_unstable('useTooltipStyles_unstable')(state);\n\n return renderTooltip_unstable(state);\n};\n\nTooltip.displayName = 'Tooltip';\n// type casting here is required to ensure internal type FluentTriggerComponent is not leaked\n(Tooltip as FluentTriggerComponent).isFluentTriggerComponent = true;\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useTooltip_unstable } from './useTooltip';\nimport { renderTooltip_unstable } from './renderTooltip';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\nimport { useTooltipStyles_unstable } from './useTooltipStyles.styles';\nimport type { TooltipProps } from './Tooltip.types';\nimport type { FluentTriggerComponent } from '@fluentui/react-utilities';\n\n/**\n * A tooltip provides light weight contextual information on top of its target element.\n */\nexport const Tooltip: React.FC<TooltipProps> = props => {\n const state = useTooltip_unstable(props);\n\n useTooltipStyles_unstable(state);\n\n useCustomStyleHook_unstable('useTooltipStyles_unstable')(state);\n\n return renderTooltip_unstable(state);\n};\n\nTooltip.displayName = 'Tooltip';\n// type casting here is required to ensure internal type FluentTriggerComponent is not leaked\n(Tooltip as FluentTriggerComponent).isFluentTriggerComponent = true;\n"],"names":["useTooltip_unstable","renderTooltip_unstable","useCustomStyleHook_unstable","useTooltipStyles_unstable","Tooltip","props","state","displayName","isFluentTriggerComponent"],"mappings":"AAAA;AAGA,SAASA,mBAAmB,QAAQ,eAAe;AACnD,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,2BAA2B,QAAQ,kCAAkC;AAC9E,SAASC,yBAAyB,QAAQ,4BAA4B;AAItE;;CAEC,GACD,OAAO,MAAMC,UAAkCC,CAAAA;IAC7C,MAAMC,QAAQN,oBAAoBK;IAElCF,0BAA0BG;IAE1BJ,4BAA4B,6BAA6BI;IAEzD,OAAOL,uBAAuBK;AAChC,EAAE;AAEFF,QAAQG,WAAW,GAAG;AACtB,6FAA6F;AAC5FH,QAAmCI,wBAAwB,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { ComponentProps, ComponentState, JSXElement, Slot, TriggerProps } from '@fluentui/react-utilities';\nimport type { PortalProps } from '@fluentui/react-portal';\n\n/**\n * Slot properties for Tooltip\n */\nexport type TooltipSlots = {\n /**\n * The text or JSX content of the tooltip.\n */\n content: NonNullable<Slot<'div'>>;\n};\n\n/**\n * The properties that are added to the child of the Tooltip\n */\nexport type TooltipChildProps = {\n ref?: React.Ref<unknown>;\n} & Pick<\n React.HTMLAttributes<HTMLElement>,\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onFocus'\n | 'onPointerEnter'\n | 'onPointerLeave'\n | 'aria-haspopup'\n | 'aria-expanded'\n>;\n\n/**\n * Data for the Tooltip's onVisibleChange event.\n */\nexport type OnVisibleChangeData = {\n visible: boolean;\n\n /**\n * The event object, if this visibility change was triggered by a keyboard event on the document element\n * (such as Escape to hide the visible tooltip). Otherwise undefined.\n */\n documentKeyboardEvent?: KeyboardEvent;\n};\n\n/**\n * Properties for Tooltip\n */\nexport type TooltipProps = ComponentProps<TooltipSlots> &\n TriggerProps<TooltipChildProps> &\n Pick<PortalProps, 'mountNode'> & {\n /**\n * The tooltip's visual appearance.\n * * `normal` - Uses the theme's background and text colors.\n * * `inverted` - Higher contrast variant that uses the theme's inverted colors.\n *\n * @default normal\n */\n appearance?: 'normal' | 'inverted';\n /**\n * Delay before the tooltip is hidden, in milliseconds.\n *\n * @default 250\n */\n hideDelay?: number;\n\n /**\n * Notification when the visibility of the tooltip is changing.\n *\n * **Note**: for backwards compatibility, `event` will be undefined if this was triggered by a keyboard event on\n * the document element. Use `data.documentKeyboardEvent` if the keyboard event object is needed.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onVisibleChange?: (\n event: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined,\n data: OnVisibleChangeData,\n ) => void;\n\n /**\n * Configure the positioning of the tooltip\n *\n * @default above\n */\n positioning?: PositioningShorthand;\n\n /**\n * (Required) Specifies whether this tooltip is acting as the description or label of its trigger element.\n *\n * * `label` - The tooltip sets the trigger's aria-label or aria-labelledby attribute. This is useful for buttons\n * displaying only an icon, for example.\n * * `description` - The tooltip sets the trigger's aria-description or aria-describedby attribute.\n * * `inaccessible` - No aria attributes are set on the trigger. This makes the tooltip's content inaccessible to\n * screen readers, and should only be used if the tooltip's text is available by some other means.\n */\n relationship: 'label' | 'description' | 'inaccessible';\n\n /**\n * Delay before the tooltip is shown, in milliseconds.\n *\n * @default 250\n */\n showDelay?: number;\n\n /**\n * Control the tooltip's visibility programatically.\n *\n * This can be used in conjunction with onVisibleChange to modify the tooltip's show and hide behavior.\n *\n * If not provided, the visibility will be controlled by the tooltip itself, based on hover and focus events on the\n * trigger (child) element.\n *\n * @default false\n */\n visible?: boolean;\n\n /**\n * Render an arrow pointing to the target element\n *\n * @default false\n */\n withArrow?: boolean;\n };\n\nexport type TooltipBaseProps = Omit<TooltipProps, 'appearance'>;\n\n/**\n * State used in rendering Tooltip\n */\nexport type TooltipState = ComponentState<TooltipSlots> &\n Pick<TooltipProps, 'mountNode' | 'relationship'> &\n Required<Pick<TooltipProps, 'appearance' | 'hideDelay' | 'positioning' | 'showDelay' | 'visible' | 'withArrow'>> & {\n children?: JSXElement | null;\n\n /**\n * Whether the tooltip should be rendered to the DOM.\n */\n shouldRenderTooltip?: boolean;\n\n /**\n * Ref to the arrow element\n */\n arrowRef?: React.Ref<HTMLDivElement>;\n\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n\nexport type TooltipBaseState = Omit<TooltipState, 'appearance'>;\n"],"names":[
|
|
1
|
+
{"version":3,"sources":["../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { ComponentProps, ComponentState, JSXElement, Slot, TriggerProps } from '@fluentui/react-utilities';\nimport type { PortalProps } from '@fluentui/react-portal';\n\n/**\n * Slot properties for Tooltip\n */\nexport type TooltipSlots = {\n /**\n * The text or JSX content of the tooltip.\n */\n content: NonNullable<Slot<'div'>>;\n};\n\n/**\n * The properties that are added to the child of the Tooltip\n */\nexport type TooltipChildProps = {\n ref?: React.Ref<unknown>;\n} & Pick<\n React.HTMLAttributes<HTMLElement>,\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onFocus'\n | 'onPointerEnter'\n | 'onPointerLeave'\n | 'aria-haspopup'\n | 'aria-expanded'\n>;\n\n/**\n * Data for the Tooltip's onVisibleChange event.\n */\nexport type OnVisibleChangeData = {\n visible: boolean;\n\n /**\n * The event object, if this visibility change was triggered by a keyboard event on the document element\n * (such as Escape to hide the visible tooltip). Otherwise undefined.\n */\n documentKeyboardEvent?: KeyboardEvent;\n};\n\n/**\n * Properties for Tooltip\n */\nexport type TooltipProps = ComponentProps<TooltipSlots> &\n TriggerProps<TooltipChildProps> &\n Pick<PortalProps, 'mountNode'> & {\n /**\n * The tooltip's visual appearance.\n * * `normal` - Uses the theme's background and text colors.\n * * `inverted` - Higher contrast variant that uses the theme's inverted colors.\n *\n * @default normal\n */\n appearance?: 'normal' | 'inverted';\n /**\n * Delay before the tooltip is hidden, in milliseconds.\n *\n * @default 250\n */\n hideDelay?: number;\n\n /**\n * Notification when the visibility of the tooltip is changing.\n *\n * **Note**: for backwards compatibility, `event` will be undefined if this was triggered by a keyboard event on\n * the document element. Use `data.documentKeyboardEvent` if the keyboard event object is needed.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onVisibleChange?: (\n event: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined,\n data: OnVisibleChangeData,\n ) => void;\n\n /**\n * Configure the positioning of the tooltip\n *\n * @default above\n */\n positioning?: PositioningShorthand;\n\n /**\n * (Required) Specifies whether this tooltip is acting as the description or label of its trigger element.\n *\n * * `label` - The tooltip sets the trigger's aria-label or aria-labelledby attribute. This is useful for buttons\n * displaying only an icon, for example.\n * * `description` - The tooltip sets the trigger's aria-description or aria-describedby attribute.\n * * `inaccessible` - No aria attributes are set on the trigger. This makes the tooltip's content inaccessible to\n * screen readers, and should only be used if the tooltip's text is available by some other means.\n */\n relationship: 'label' | 'description' | 'inaccessible';\n\n /**\n * Delay before the tooltip is shown, in milliseconds.\n *\n * @default 250\n */\n showDelay?: number;\n\n /**\n * Control the tooltip's visibility programatically.\n *\n * This can be used in conjunction with onVisibleChange to modify the tooltip's show and hide behavior.\n *\n * If not provided, the visibility will be controlled by the tooltip itself, based on hover and focus events on the\n * trigger (child) element.\n *\n * @default false\n */\n visible?: boolean;\n\n /**\n * Render an arrow pointing to the target element\n *\n * @default false\n */\n withArrow?: boolean;\n };\n\nexport type TooltipBaseProps = Omit<TooltipProps, 'appearance'>;\n\n/**\n * State used in rendering Tooltip\n */\nexport type TooltipState = ComponentState<TooltipSlots> &\n Pick<TooltipProps, 'mountNode' | 'relationship'> &\n Required<Pick<TooltipProps, 'appearance' | 'hideDelay' | 'positioning' | 'showDelay' | 'visible' | 'withArrow'>> & {\n children?: JSXElement | null;\n\n /**\n * Whether the tooltip should be rendered to the DOM.\n */\n shouldRenderTooltip?: boolean;\n\n /**\n * Ref to the arrow element\n */\n arrowRef?: React.Ref<HTMLDivElement>;\n\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n\nexport type TooltipBaseState = Omit<TooltipState, 'appearance'>;\n"],"names":[],"mappings":"AAsJA,WAAgE"}
|
|
@@ -87,6 +87,7 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
|
87
87
|
})
|
|
88
88
|
};
|
|
89
89
|
(_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();
|
|
90
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
90
91
|
context.visibleTooltip = thisTooltip;
|
|
91
92
|
const onDocumentKeyDown = (ev)=>{
|
|
92
93
|
if (ev.key === Escape && !ev.defaultPrevented) {
|
|
@@ -101,6 +102,15 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
|
101
102
|
// we need to capture the event to be sure keydown handling from tooltip happens first
|
|
102
103
|
capture: true
|
|
103
104
|
});
|
|
105
|
+
// Dismiss the tooltip when the document becomes hidden (e.g. tab backgrounded,
|
|
106
|
+
// app switched on mobile). The original trigger (hover/tap/focus) is no longer
|
|
107
|
+
// active in this case, so persisting the tooltip is a stale UI state.
|
|
108
|
+
const onDocumentVisibilityChange = ()=>{
|
|
109
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.visibilityState) === 'hidden') {
|
|
110
|
+
thisTooltip.hide();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('visibilitychange', onDocumentVisibilityChange);
|
|
104
114
|
return ()=>{
|
|
105
115
|
if (context.visibleTooltip === thisTooltip) {
|
|
106
116
|
context.visibleTooltip = undefined;
|
|
@@ -108,6 +118,7 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
|
108
118
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
|
|
109
119
|
capture: true
|
|
110
120
|
});
|
|
121
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('visibilitychange', onDocumentVisibilityChange);
|
|
111
122
|
};
|
|
112
123
|
}
|
|
113
124
|
}, [
|
|
@@ -120,7 +131,8 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
|
120
131
|
// See comments where this is set for more info.
|
|
121
132
|
const ignoreNextFocusEventRef = React.useRef(false);
|
|
122
133
|
// Listener for onPointerEnter and onFocus on the trigger element
|
|
123
|
-
const onEnterTrigger = React.useCallback(
|
|
134
|
+
const onEnterTrigger = React.useCallback(// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
135
|
+
(ev)=>{
|
|
124
136
|
if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {
|
|
125
137
|
ignoreNextFocusEventRef.current = false;
|
|
126
138
|
return;
|
|
@@ -162,7 +174,8 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
|
162
174
|
};
|
|
163
175
|
});
|
|
164
176
|
// Listener for onPointerLeave and onBlur on the trigger element
|
|
165
|
-
const onLeaveTrigger = React.useCallback(
|
|
177
|
+
const onLeaveTrigger = React.useCallback(// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
178
|
+
(ev)=>{
|
|
166
179
|
let delay = state.hideDelay;
|
|
167
180
|
if (ev.type === 'blur') {
|
|
168
181
|
// Hide immediately when losing focus
|
|
@@ -188,9 +201,13 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
|
188
201
|
]);
|
|
189
202
|
// Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.
|
|
190
203
|
// This keeps the tooltip visible when the mouse is moved over it, or it has focus within.
|
|
204
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
191
205
|
state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);
|
|
206
|
+
// eslint-disable-next-line react-hooks/immutability, react-hooks/refs
|
|
192
207
|
state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);
|
|
208
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
193
209
|
state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);
|
|
210
|
+
// eslint-disable-next-line react-hooks/immutability, react-hooks/refs
|
|
194
211
|
state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);
|
|
195
212
|
const child = getTriggerChild(children);
|
|
196
213
|
const triggerAriaProps = {};
|
|
@@ -202,27 +219,35 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
|
202
219
|
} else {
|
|
203
220
|
triggerAriaProps['aria-labelledby'] = state.content.id;
|
|
204
221
|
// Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
|
|
222
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
205
223
|
state.shouldRenderTooltip = true;
|
|
206
224
|
}
|
|
207
225
|
} else if (relationship === 'description') {
|
|
208
226
|
triggerAriaProps['aria-describedby'] = state.content.id;
|
|
209
227
|
// Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
|
|
228
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
210
229
|
state.shouldRenderTooltip = true;
|
|
211
230
|
}
|
|
212
231
|
// Case 1: Don't render the Tooltip in SSR to avoid hydration errors
|
|
213
232
|
// Case 2: Don't render the Tooltip, if it triggers Menu or another popup and it's already opened
|
|
214
233
|
if (isServerSideRender || isPopupExpanded) {
|
|
234
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
215
235
|
state.shouldRenderTooltip = false;
|
|
216
236
|
}
|
|
217
237
|
// Apply the trigger props to the child, either by calling the render function, or cloning with the new props
|
|
238
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
218
239
|
state.children = applyTriggerPropsToChildren(children, {
|
|
219
240
|
...triggerAriaProps,
|
|
220
241
|
...child === null || child === void 0 ? void 0 : child.props,
|
|
221
242
|
ref: useMergedRefs(getReactElementRef(child), keyborgListenerCallbackRef, // If the target prop is not provided, attach targetRef to the trigger element's ref prop
|
|
222
243
|
positioningOptions.target === undefined ? targetRef : undefined),
|
|
244
|
+
// eslint-disable-next-line react-hooks/refs
|
|
223
245
|
onPointerEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onPointerEnter, onEnterTrigger)),
|
|
246
|
+
// eslint-disable-next-line react-hooks/refs
|
|
224
247
|
onPointerLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props4 = child.props) === null || _child_props4 === void 0 ? void 0 : _child_props4.onPointerLeave, onLeaveTrigger)),
|
|
248
|
+
// eslint-disable-next-line react-hooks/refs
|
|
225
249
|
onFocus: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props5 = child.props) === null || _child_props5 === void 0 ? void 0 : _child_props5.onFocus, onEnterTrigger)),
|
|
250
|
+
// eslint-disable-next-line react-hooks/refs
|
|
226
251
|
onBlur: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props6 = child.props) === null || _child_props6 === void 0 ? void 0 : _child_props6.onBlur, onLeaveTrigger))
|
|
227
252
|
});
|
|
228
253
|
return state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/useTooltipBase.tsx"],"sourcesContent":["'use client';\n\nimport * 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 type { KeyborgFocusInEvent } from '@fluentui/react-tabster';\nimport { KEYBORG_FOCUSIN, useIsNavigatingWithKeyboard } from '@fluentui/react-tabster';\nimport {\n applyTriggerPropsToChildren,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n slot,\n getReactElementRef,\n} from '@fluentui/react-utilities';\nimport type { TooltipBaseProps, TooltipBaseState, TooltipChildProps, OnVisibleChangeData } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { useTooltipTimeout } from './private/useTooltipTimeout';\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 useTooltipBase_unstable = (props: TooltipBaseProps): TooltipBaseState => {\n 'use no memo';\n\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n\n const {\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 state: TooltipBaseState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: slot.always(content, {\n defaultProps: {\n role: 'tooltip',\n },\n elementType: 'div',\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n targetRef: React.MutableRefObject<unknown>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n containerRef: React.MutableRefObject<HTMLDivElement>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n const [setDelayTimeout, clearDelayTimeout] = useTooltipTimeout(containerRef);\n\n const setVisible = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined, data: OnVisibleChangeData) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (data.visible !== oldVisible) {\n onVisibleChange?.(ev, data);\n }\n return data.visible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\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 = {\n hide: (ev?: KeyboardEvent) => setVisible(undefined, { visible: false, documentKeyboardEvent: ev }),\n };\n\n context.visibleTooltip?.hide();\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape && !ev.defaultPrevented) {\n thisTooltip.hide(ev);\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu and Tooltip\n ev.preventDefault();\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 // Used to skip showing the tooltip in certain situations when the trigger is focused.\n // See comments where this is set for more info.\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(ev, { visible: true });\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 const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();\n\n // Callback ref that attaches a keyborg:focusin event listener.\n const [keyborgListenerCallbackRef] = React.useState(() => {\n const onKeyborgFocusIn = ((ev: KeyborgFocusInEvent) => {\n // Skip showing the tooltip if focus moved programmatically.\n // For example, we don't want to show the tooltip when a dialog is closed\n // and Tabster programmatically restores focus to the trigger button.\n // See https://github.com/microsoft/fluentui/issues/27576\n if (ev.detail?.isFocusedProgrammatically && !isNavigatingWithKeyboard()) {\n ignoreNextFocusEventRef.current = true;\n }\n }) as EventListener;\n\n // Save the current element to remove the listener when the ref changes\n let current: Element | null = null;\n\n // Callback ref that attaches the listener to the element\n return (element: Element | null) => {\n current?.removeEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n element?.addEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n current = element;\n };\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 // 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 ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(ev, { visible: false });\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 const isPopupExpanded =\n child?.props?.['aria-haspopup'] &&\n (child?.props?.['aria-expanded'] === true || child?.props?.['aria-expanded'] === 'true');\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 // Case 1: Don't render the Tooltip in SSR to avoid hydration errors\n // Case 2: Don't render the Tooltip, if it triggers Menu or another popup and it's already opened\n if (isServerSideRender || isPopupExpanded) {\n state.shouldRenderTooltip = false;\n }\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 ref: useMergedRefs(\n getReactElementRef<HTMLButtonElement>(child),\n keyborgListenerCallbackRef,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n positioningOptions.target === undefined ? targetRef : undefined,\n ),\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"],"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","KEYBORG_FOCUSIN","useIsNavigatingWithKeyboard","applyTriggerPropsToChildren","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","getTriggerChild","mergeCallbacks","useEventCallback","slot","getReactElementRef","arrowHeight","tooltipBorderRadius","useTooltipTimeout","Escape","useTooltipBase_unstable","props","child","context","isServerSideRender","targetDocument","visible","setVisibleInternal","state","initialState","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","shouldRenderTooltip","components","always","defaultProps","role","elementType","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","setDelayTimeout","clearDelayTimeout","setVisible","useCallback","ev","data","oldVisible","ref","thisTooltip","hide","undefined","documentKeyboardEvent","visibleTooltip","onDocumentKeyDown","key","defaultPrevented","preventDefault","addEventListener","capture","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","isNavigatingWithKeyboard","keyborgListenerCallbackRef","useState","onKeyborgFocusIn","detail","isFocusedProgrammatically","element","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","triggerAriaProps","isPopupExpanded"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AAC5G,SACEC,iCAAiCC,oBAAoB,EACrDC,sBAAsBC,SAAS,QAC1B,kCAAkC;AAEzC,SAASC,eAAe,EAAEC,2BAA2B,QAAQ,0BAA0B;AACvF,SACEC,2BAA2B,EAC3BC,oBAAoB,EACpBC,KAAK,EACLC,yBAAyB,EACzBC,QAAQ,EACRC,aAAa,EACbC,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,IAAI,EACJC,kBAAkB,QACb,4BAA4B;AAEnC,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,sBAAs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,OAAO,CAACD,QAAQ;QACzD,OAAO;YACLkE,gBAAgB,CAAC,kBAAkB,GAAGpE,MAAMG,OAAO,CAACc,EAAE;YACtD,8FAA8F;YAC9FjB,MAAMW,mBAAmB,GAAG;QAC9B;IACF,OAAO,IAAIJ,iBAAiB,eAAe;QACzC6D,gBAAgB,CAAC,mBAAmB,GAAGpE,MAAMG,OAAO,CAACc,EAAE;QACvD,+FAA+F;QAC/FjB,MAAMW,mBAAmB,GAAG;IAC9B;IAEA,oEAAoE;IACpE,iGAAiG;IACjG,IAAIf,sBAAsByE,iBAAiB;QACzCrE,MAAMW,mBAAmB,GAAG;IAC9B;IAEA,6GAA6G;IAC7GX,MAAME,QAAQ,GAAGzB,4BAA4ByB,UAAU;QACrD,GAAGkE,gBAAgB;WAChB1E,kBAAAA,4BAAAA,MAAOD,KAAK,AAAf;QACAyC,KAAKpD,cACHK,mBAAsCO,QACtC6D,4BACA,yFAAyF;QACzFrC,mBAAmB6C,MAAM,KAAK1B,YAAYb,YAAYa;QAExD2B,gBAAgB/E,iBAAiBD,eAAeU,kBAAAA,6BAAAA,gBAAAA,MAAOD,KAAK,cAAZC,oCAAAA,cAAcsE,cAAc,EAAEf;QAC9EgB,gBAAgBhF,iBAAiBD,eAAeU,kBAAAA,6BAAAA,gBAAAA,MAAOD,KAAK,cAAZC,oCAAAA,cAAcuE,cAAc,EAAEJ;QAC9EK,SAASjF,iBAAiBD,eAAeU,kBAAAA,6BAAAA,gBAAAA,MAAOD,KAAK,cAAZC,oCAAAA,cAAcwE,OAAO,EAAEjB;QAChEkB,QAAQlF,iBAAiBD,eAAeU,kBAAAA,6BAAAA,gBAAAA,MAAOD,KAAK,cAAZC,oCAAAA,cAAcyE,MAAM,EAAEN;IAChE;IAEA,OAAO7D;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Tooltip/useTooltipBase.tsx"],"sourcesContent":["'use client';\n\nimport * 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 type { KeyborgFocusInEvent } from '@fluentui/react-tabster';\nimport { KEYBORG_FOCUSIN, useIsNavigatingWithKeyboard } from '@fluentui/react-tabster';\nimport {\n applyTriggerPropsToChildren,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n slot,\n getReactElementRef,\n} from '@fluentui/react-utilities';\nimport type { TooltipBaseProps, TooltipBaseState, TooltipChildProps, OnVisibleChangeData } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { useTooltipTimeout } from './private/useTooltipTimeout';\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 useTooltipBase_unstable = (props: TooltipBaseProps): TooltipBaseState => {\n 'use no memo';\n\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n\n const {\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 state: TooltipBaseState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: slot.always(content, {\n defaultProps: {\n role: 'tooltip',\n },\n elementType: 'div',\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n targetRef: React.MutableRefObject<unknown>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n containerRef: React.MutableRefObject<HTMLDivElement>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n const [setDelayTimeout, clearDelayTimeout] = useTooltipTimeout(containerRef);\n\n const setVisible = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined, data: OnVisibleChangeData) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (data.visible !== oldVisible) {\n onVisibleChange?.(ev, data);\n }\n return data.visible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\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 = {\n hide: (ev?: KeyboardEvent) => setVisible(undefined, { visible: false, documentKeyboardEvent: ev }),\n };\n\n context.visibleTooltip?.hide();\n // eslint-disable-next-line react-hooks/immutability\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape && !ev.defaultPrevented) {\n thisTooltip.hide(ev);\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu and Tooltip\n ev.preventDefault();\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 // Dismiss the tooltip when the document becomes hidden (e.g. tab backgrounded,\n // app switched on mobile). The original trigger (hover/tap/focus) is no longer\n // active in this case, so persisting the tooltip is a stale UI state.\n const onDocumentVisibilityChange = () => {\n if (targetDocument?.visibilityState === 'hidden') {\n thisTooltip.hide();\n }\n };\n\n targetDocument?.addEventListener('visibilitychange', onDocumentVisibilityChange);\n\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n\n targetDocument?.removeEventListener('keydown', onDocumentKeyDown, { capture: true });\n targetDocument?.removeEventListener('visibilitychange', onDocumentVisibilityChange);\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n\n // Used to skip showing the tooltip in certain situations when the trigger is focused.\n // See comments where this is set for more info.\n const ignoreNextFocusEventRef = React.useRef(false);\n\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(\n // eslint-disable-next-line react-hooks/preserve-manual-memoization\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(ev, { visible: true });\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 const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();\n\n // Callback ref that attaches a keyborg:focusin event listener.\n const [keyborgListenerCallbackRef] = React.useState(() => {\n const onKeyborgFocusIn = ((ev: KeyborgFocusInEvent) => {\n // Skip showing the tooltip if focus moved programmatically.\n // For example, we don't want to show the tooltip when a dialog is closed\n // and Tabster programmatically restores focus to the trigger button.\n // See https://github.com/microsoft/fluentui/issues/27576\n if (ev.detail?.isFocusedProgrammatically && !isNavigatingWithKeyboard()) {\n ignoreNextFocusEventRef.current = true;\n }\n }) as EventListener;\n\n // Save the current element to remove the listener when the ref changes\n let current: Element | null = null;\n\n // Callback ref that attaches the listener to the element\n return (element: Element | null) => {\n current?.removeEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n element?.addEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n current = element;\n };\n });\n\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(\n // eslint-disable-next-line react-hooks/preserve-manual-memoization\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 // 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 ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(ev, { visible: false });\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 // eslint-disable-next-line react-hooks/immutability\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n // eslint-disable-next-line react-hooks/immutability, react-hooks/refs\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n // eslint-disable-next-line react-hooks/immutability\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n // eslint-disable-next-line react-hooks/immutability, react-hooks/refs\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 const isPopupExpanded =\n child?.props?.['aria-haspopup'] &&\n (child?.props?.['aria-expanded'] === true || child?.props?.['aria-expanded'] === 'true');\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 // eslint-disable-next-line react-hooks/immutability\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 // eslint-disable-next-line react-hooks/immutability\n state.shouldRenderTooltip = true;\n }\n\n // Case 1: Don't render the Tooltip in SSR to avoid hydration errors\n // Case 2: Don't render the Tooltip, if it triggers Menu or another popup and it's already opened\n if (isServerSideRender || isPopupExpanded) {\n // eslint-disable-next-line react-hooks/immutability\n state.shouldRenderTooltip = false;\n }\n\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n // eslint-disable-next-line react-hooks/immutability\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child?.props,\n ref: useMergedRefs(\n getReactElementRef<HTMLButtonElement>(child),\n keyborgListenerCallbackRef,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n positioningOptions.target === undefined ? targetRef : undefined,\n ),\n // eslint-disable-next-line react-hooks/refs\n onPointerEnter: useEventCallback(mergeCallbacks(child?.props?.onPointerEnter, onEnterTrigger)),\n // eslint-disable-next-line react-hooks/refs\n onPointerLeave: useEventCallback(mergeCallbacks(child?.props?.onPointerLeave, onLeaveTrigger)),\n // eslint-disable-next-line react-hooks/refs\n onFocus: useEventCallback(mergeCallbacks(child?.props?.onFocus, onEnterTrigger)),\n // eslint-disable-next-line react-hooks/refs\n onBlur: useEventCallback(mergeCallbacks(child?.props?.onBlur, onLeaveTrigger)),\n });\n\n return state;\n};\n"],"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","KEYBORG_FOCUSIN","useIsNavigatingWithKeyboard","applyTriggerPropsToChildren","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","getTriggerChild","mergeCallbacks","useEventCallback","slot","getReactElementRef","arrowHeight","tooltipBorderRadius","useTooltipTimeout","Escape","useTooltipBase_unstable","props","child","context","isServerSideRender","targetDocument","visible","setVisibleInternal","state","initialState","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","shouldRenderTooltip","components","always","defaultProps","role","elementType","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","setDelayTimeout","clearDelayTimeout","setVisible","useCallback","ev","data","oldVisible","ref","thisTooltip","hide","undefined","documentKeyboardEvent","visibleTooltip","onDocumentKeyDown","key","defaultPrevented","preventDefault","addEventListener","capture","onDocumentVisibilityChange","visibilityState","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","isNavigatingWithKeyboard","keyborgListenerCallbackRef","useState","onKeyborgFocusIn","detail","isFocusedProgrammatically","element","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","triggerAriaProps","isPopupExpanded"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AAC5G,SACEC,iCAAiCC,oBAAoB,EACrDC,sBAAsBC,SAAS,QAC1B,kCAAkC;AAEzC,SAASC,eAAe,EAAEC,2BAA2B,QAAQ,0BAA0B;AACvF,SACEC,2BAA2B,EAC3BC,oBAAoB,EACpBC,KAAK,EACLC,yBAAyB,EACzBC,QAAQ,EACRC,aAAa,EACbC,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,IAAI,EACJC,kBAAkB,QACb,4BAA4B;AAEnC,SAASC,WAAW,EAAEC,mBAA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AA4C;QAC5CgB,gBAAgBlF,iBAAiBD,eAAeU,kBAAAA,6BAAAA,gBAAAA,MAAOD,KAAK,cAAZC,oCAAAA,cAAcyE,cAAc,EAAEJ;QAC9E,4CAA4C;QAC5CK,SAASnF,iBAAiBD,eAAeU,kBAAAA,6BAAAA,gBAAAA,MAAOD,KAAK,cAAZC,oCAAAA,cAAc0E,OAAO,EAAEjB;QAChE,4CAA4C;QAC5CkB,QAAQpF,iBAAiBD,eAAeU,kBAAAA,6BAAAA,gBAAAA,MAAOD,KAAK,cAAZC,oCAAAA,cAAc2E,MAAM,EAAEN;IAChE;IAEA,OAAO/D;AACT,EAAE"}
|
|
@@ -128,7 +128,9 @@ export const useTooltipStyles_unstable = state => {
|
|
|
128
128
|
'use no memo';
|
|
129
129
|
|
|
130
130
|
const styles = useStyles();
|
|
131
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
131
132
|
state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
|
|
133
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
132
134
|
state.arrowClassName = styles.arrow;
|
|
133
135
|
return state;
|
|
134
136
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__styles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Btd35i7","Beyfa6y","Bbmb7ep","Btl43ni","B7oj6ja","Dimara","Bgfg5da","B9xav0g","oivjwe","Bn0qgzm","B4g9neb","zhjwy3","wvpqe5","ibv6hh","u1mtju","h3c5rm","vrafjx","Bekrc4i","i8vvqc","g2u3we","icvyot","B4j52fo","irswps","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bj3rh1h","rhnwrx","Bdy53xb","B2eet1l","Bz10aip","Bqenvij","a9b677","Ftih45","Br0sdwz","cmx5o7","susq4k","Biibvgv","Bicfajf","qehafq","Brs5u8j","Ccq8qp","Baz25je","Bcgcnre","Bqjgrrk","qa3bma","y0oebl","Biqmznv","Bm6vgfq","Bbv0w2i","uvfttm","eqrjj","Bk5zm6e","m598lv","B4f6apu","ydt019","Bq4z7u6","Bdkvgpv","B0qfbqy","kj8mxx","r59vdv","Bkw5xw4","hl6cv3","aea9ga","yayu3t","Bhsv975","rhl9o9","B7gxrvb","B6q6orb","B0lu1f8","d","p","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"sources":["useTooltipStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, 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 */ const useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px',\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter: `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` + `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`\n },\n visible: {\n display: 'block'\n },\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted\n },\n arrow: createArrowStyles({\n arrowHeight\n })\n});\n/**\n * Apply styling to the Tooltip slots based on the state\n */ export const useTooltipStyles_unstable = (state)=>{\n 'use no memo';\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"],"mappings":"AAAA,YAAY;;AACZ,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,OAAO,EAAE;AACb,CAAC;AACD;AACA;AACA;AAAI,MAAMC,SAAS,gBAAGP,QAAA;EAAAQ,IAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,OAAA;IAAAtC,MAAA;EAAA;EAAAuC,QAAA;IAAAJ,MAAA;IAAAC,MAAA;EAAA;EAAAI,KAAA;IAAAvC,OAAA;IAAAwC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAT,MAAA;IAAAU,OAAA;IAAArC,OAAA;IAAAsC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,KAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;IAAAC,CAAA;EAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;AAAA,CA4BrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,yBAAyB,GAAIC,KAAK,IAAG;EAClD,aAAa;;EACb,MAAMC,MAAM,GAAG5F,SAAS,CAAC,CAAC;
|
|
1
|
+
{"version":3,"names":["__styles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Btd35i7","Beyfa6y","Bbmb7ep","Btl43ni","B7oj6ja","Dimara","Bgfg5da","B9xav0g","oivjwe","Bn0qgzm","B4g9neb","zhjwy3","wvpqe5","ibv6hh","u1mtju","h3c5rm","vrafjx","Bekrc4i","i8vvqc","g2u3we","icvyot","B4j52fo","irswps","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bj3rh1h","rhnwrx","Bdy53xb","B2eet1l","Bz10aip","Bqenvij","a9b677","Ftih45","Br0sdwz","cmx5o7","susq4k","Biibvgv","Bicfajf","qehafq","Brs5u8j","Ccq8qp","Baz25je","Bcgcnre","Bqjgrrk","qa3bma","y0oebl","Biqmznv","Bm6vgfq","Bbv0w2i","uvfttm","eqrjj","Bk5zm6e","m598lv","B4f6apu","ydt019","Bq4z7u6","Bdkvgpv","B0qfbqy","kj8mxx","r59vdv","Bkw5xw4","hl6cv3","aea9ga","yayu3t","Bhsv975","rhl9o9","B7gxrvb","B6q6orb","B0lu1f8","d","p","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"sources":["useTooltipStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, 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 */ const useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px',\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter: `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` + `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`\n },\n visible: {\n display: 'block'\n },\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted\n },\n arrow: createArrowStyles({\n arrowHeight\n })\n});\n/**\n * Apply styling to the Tooltip slots based on the state\n */ export const useTooltipStyles_unstable = (state)=>{\n 'use no memo';\n const styles = useStyles();\n // eslint-disable-next-line react-hooks/immutability\n state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);\n // eslint-disable-next-line react-hooks/immutability\n state.arrowClassName = styles.arrow;\n return state;\n};\n"],"mappings":"AAAA,YAAY;;AACZ,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,OAAO,EAAE;AACb,CAAC;AACD;AACA;AACA;AAAI,MAAMC,SAAS,gBAAGP,QAAA;EAAAQ,IAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,OAAA;IAAAtC,MAAA;EAAA;EAAAuC,QAAA;IAAAJ,MAAA;IAAAC,MAAA;EAAA;EAAAI,KAAA;IAAAvC,OAAA;IAAAwC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAT,MAAA;IAAAU,OAAA;IAAArC,OAAA;IAAAsC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,KAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;IAAAC,CAAA;EAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;AAAA,CA4BrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,yBAAyB,GAAIC,KAAK,IAAG;EAClD,aAAa;;EACb,MAAMC,MAAM,GAAG5F,SAAS,CAAC,CAAC;EAC1B;EACA2F,KAAK,CAAC5F,OAAO,CAAC8F,SAAS,GAAGnG,YAAY,CAACI,iBAAiB,CAACC,OAAO,EAAE6F,MAAM,CAAC3F,IAAI,EAAE0F,KAAK,CAACG,UAAU,KAAK,UAAU,IAAIF,MAAM,CAACnD,QAAQ,EAAEkD,KAAK,CAACnD,OAAO,IAAIoD,MAAM,CAACpD,OAAO,EAAEmD,KAAK,CAAC5F,OAAO,CAAC8F,SAAS,CAAC;EAC5L;EACAF,KAAK,CAACI,cAAc,GAAGH,MAAM,CAAClD,KAAK;EACnC,OAAOiD,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -42,7 +42,9 @@ export const tooltipClassNames = {
|
|
|
42
42
|
*/ export const useTooltipStyles_unstable = (state)=>{
|
|
43
43
|
'use no memo';
|
|
44
44
|
const styles = useStyles();
|
|
45
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
45
46
|
state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
|
|
47
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
46
48
|
state.arrowClassName = styles.arrow;
|
|
47
49
|
return state;
|
|
48
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/useTooltipStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport { arrowHeight } from './private/constants';\nimport type { TooltipSlots, TooltipState } from './Tooltip.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const tooltipClassNames: SlotClassNames<TooltipSlots> = {\n content: 'fui-Tooltip__content',\n};\n\n/**\n * Styles for the tooltip\n */\nconst useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px', // '5px 12px 7px 12px' minus the border width '1px'\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter:\n `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` +\n `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`,\n },\n\n visible: {\n display: 'block',\n },\n\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted,\n },\n\n arrow: createArrowStyles({ arrowHeight }),\n});\n\n/**\n * Apply styling to the Tooltip slots based on the state\n */\nexport const useTooltipStyles_unstable = (state: TooltipState): TooltipState => {\n 'use no memo';\n\n const styles = useStyles();\n\n state.content.className = mergeClasses(\n tooltipClassNames.content,\n styles.root,\n state.appearance === 'inverted' && styles.inverted,\n state.visible && styles.visible,\n state.content.className,\n );\n\n state.arrowClassName = styles.arrow;\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","display","boxSizing","maxWidth","cursor","fontFamily","fontFamilyBase","fontSize","fontSizeBase200","lineHeight","lineHeightBase200","overflowWrap","borderRadius","borderRadiusMedium","border","colorTransparentStroke","padding","backgroundColor","colorNeutralBackground1","color","colorNeutralForeground1","filter","colorNeutralShadowAmbient","colorNeutralShadowKey","visible","inverted","colorNeutralBackgroundStatic","colorNeutralForegroundStaticInverted","arrow","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"mappings":"AAAA;AAEA,SAASA,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC1D,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,WAAW,QAAQ,sBAAsB;AAIlD,OAAO,MAAMC,oBAAkD;IAC7DC,SAAS;AACX,EAAE;AAEF;;CAEC,GACD,MAAMC,YAAYP,WAAW;IAC3BQ,MAAM;QACJC,SAAS;QACTC,WAAW;QACXC,UAAU;QACVC,QAAQ;QACRC,YAAYV,OAAOW,cAAc;QACjCC,UAAUZ,OAAOa,eAAe;QAChCC,YAAYd,OAAOe,iBAAiB;QACpCC,cAAc;QACdC,cAAcjB,OAAOkB,kBAAkB;QACvCC,QAAQ,CAAC,UAAU,EAAEnB,OAAOoB,sBAAsB,EAAE;QACpDC,SAAS;QACTC,iBAAiBtB,OAAOuB,uBAAuB;QAC/CC,OAAOxB,OAAOyB,uBAAuB;QAErC,uFAAuF;QACvFC,QACE,CAAC,oBAAoB,EAAE1B,OAAO2B,yBAAyB,CAAC,EAAE,CAAC,GAC3D,CAAC,sBAAsB,EAAE3B,OAAO4B,qBAAqB,CAAC,CAAC,CAAC;IAC5D;IAEAC,SAAS;QACPvB,SAAS;IACX;IAEAwB,UAAU;QACRR,iBAAiBtB,OAAO+B,4BAA4B;QACpDP,OAAOxB,OAAOgC,oCAAoC;IACpD;IAEAC,OAAOlC,kBAAkB;QAAEE;IAAY;AACzC;AAEA;;CAEC,GACD,OAAO,MAAMiC,4BAA4B,CAACC;IACxC;IAEA,MAAMC,SAAShC;IAEf+B,MAAMhC,OAAO,CAACkC,SAAS,GAAGvC,aACxBI,kBAAkBC,OAAO,EACzBiC,OAAO/B,IAAI,EACX8B,MAAMG,UAAU,KAAK,cAAcF,OAAON,QAAQ,EAClDK,MAAMN,OAAO,IAAIO,OAAOP,OAAO,EAC/BM,MAAMhC,OAAO,CAACkC,SAAS;
|
|
1
|
+
{"version":3,"sources":["../src/components/Tooltip/useTooltipStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport { arrowHeight } from './private/constants';\nimport type { TooltipSlots, TooltipState } from './Tooltip.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const tooltipClassNames: SlotClassNames<TooltipSlots> = {\n content: 'fui-Tooltip__content',\n};\n\n/**\n * Styles for the tooltip\n */\nconst useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px', // '5px 12px 7px 12px' minus the border width '1px'\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter:\n `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` +\n `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`,\n },\n\n visible: {\n display: 'block',\n },\n\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted,\n },\n\n arrow: createArrowStyles({ arrowHeight }),\n});\n\n/**\n * Apply styling to the Tooltip slots based on the state\n */\nexport const useTooltipStyles_unstable = (state: TooltipState): TooltipState => {\n 'use no memo';\n\n const styles = useStyles();\n\n // eslint-disable-next-line react-hooks/immutability\n state.content.className = mergeClasses(\n tooltipClassNames.content,\n styles.root,\n state.appearance === 'inverted' && styles.inverted,\n state.visible && styles.visible,\n state.content.className,\n );\n\n // eslint-disable-next-line react-hooks/immutability\n state.arrowClassName = styles.arrow;\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","display","boxSizing","maxWidth","cursor","fontFamily","fontFamilyBase","fontSize","fontSizeBase200","lineHeight","lineHeightBase200","overflowWrap","borderRadius","borderRadiusMedium","border","colorTransparentStroke","padding","backgroundColor","colorNeutralBackground1","color","colorNeutralForeground1","filter","colorNeutralShadowAmbient","colorNeutralShadowKey","visible","inverted","colorNeutralBackgroundStatic","colorNeutralForegroundStaticInverted","arrow","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"mappings":"AAAA;AAEA,SAASA,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAC1D,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,WAAW,QAAQ,sBAAsB;AAIlD,OAAO,MAAMC,oBAAkD;IAC7DC,SAAS;AACX,EAAE;AAEF;;CAEC,GACD,MAAMC,YAAYP,WAAW;IAC3BQ,MAAM;QACJC,SAAS;QACTC,WAAW;QACXC,UAAU;QACVC,QAAQ;QACRC,YAAYV,OAAOW,cAAc;QACjCC,UAAUZ,OAAOa,eAAe;QAChCC,YAAYd,OAAOe,iBAAiB;QACpCC,cAAc;QACdC,cAAcjB,OAAOkB,kBAAkB;QACvCC,QAAQ,CAAC,UAAU,EAAEnB,OAAOoB,sBAAsB,EAAE;QACpDC,SAAS;QACTC,iBAAiBtB,OAAOuB,uBAAuB;QAC/CC,OAAOxB,OAAOyB,uBAAuB;QAErC,uFAAuF;QACvFC,QACE,CAAC,oBAAoB,EAAE1B,OAAO2B,yBAAyB,CAAC,EAAE,CAAC,GAC3D,CAAC,sBAAsB,EAAE3B,OAAO4B,qBAAqB,CAAC,CAAC,CAAC;IAC5D;IAEAC,SAAS;QACPvB,SAAS;IACX;IAEAwB,UAAU;QACRR,iBAAiBtB,OAAO+B,4BAA4B;QACpDP,OAAOxB,OAAOgC,oCAAoC;IACpD;IAEAC,OAAOlC,kBAAkB;QAAEE;IAAY;AACzC;AAEA;;CAEC,GACD,OAAO,MAAMiC,4BAA4B,CAACC;IACxC;IAEA,MAAMC,SAAShC;IAEf,oDAAoD;IACpD+B,MAAMhC,OAAO,CAACkC,SAAS,GAAGvC,aACxBI,kBAAkBC,OAAO,EACzBiC,OAAO/B,IAAI,EACX8B,MAAMG,UAAU,KAAK,cAAcF,OAAON,QAAQ,EAClDK,MAAMN,OAAO,IAAIO,OAAOP,OAAO,EAC/BM,MAAMhC,OAAO,CAACkC,SAAS;IAGzB,oDAAoD;IACpDF,MAAMI,cAAc,GAAGH,OAAOH,KAAK;IAEnC,OAAOE;AACT,EAAE"}
|
|
@@ -9,8 +9,6 @@ Object.defineProperty(exports, "Tooltip", {
|
|
|
9
9
|
return Tooltip;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
12
|
const _useTooltip = require("./useTooltip");
|
|
15
13
|
const _renderTooltip = require("./renderTooltip");
|
|
16
14
|
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useTooltip_unstable } from './useTooltip';\nimport { renderTooltip_unstable } from './renderTooltip';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\nimport { useTooltipStyles_unstable } from './useTooltipStyles.styles';\nimport type { TooltipProps } from './Tooltip.types';\nimport type { FluentTriggerComponent } from '@fluentui/react-utilities';\n\n/**\n * A tooltip provides light weight contextual information on top of its target element.\n */\nexport const Tooltip: React.FC<TooltipProps> = props => {\n const state = useTooltip_unstable(props);\n\n useTooltipStyles_unstable(state);\n\n useCustomStyleHook_unstable('useTooltipStyles_unstable')(state);\n\n return renderTooltip_unstable(state);\n};\n\nTooltip.displayName = 'Tooltip';\n// type casting here is required to ensure internal type FluentTriggerComponent is not leaked\n(Tooltip as FluentTriggerComponent).isFluentTriggerComponent = true;\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useTooltip_unstable } from './useTooltip';\nimport { renderTooltip_unstable } from './renderTooltip';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\nimport { useTooltipStyles_unstable } from './useTooltipStyles.styles';\nimport type { TooltipProps } from './Tooltip.types';\nimport type { FluentTriggerComponent } from '@fluentui/react-utilities';\n\n/**\n * A tooltip provides light weight contextual information on top of its target element.\n */\nexport const Tooltip: React.FC<TooltipProps> = props => {\n const state = useTooltip_unstable(props);\n\n useTooltipStyles_unstable(state);\n\n useCustomStyleHook_unstable('useTooltipStyles_unstable')(state);\n\n return renderTooltip_unstable(state);\n};\n\nTooltip.displayName = 'Tooltip';\n// type casting here is required to ensure internal type FluentTriggerComponent is not leaked\n(Tooltip as FluentTriggerComponent).isFluentTriggerComponent = true;\n"],"names":["useTooltip_unstable","renderTooltip_unstable","useCustomStyleHook_unstable","useTooltipStyles_unstable","Tooltip","props","state","displayName","isFluentTriggerComponent"],"mappings":"AAAA;;;;;;;;;;;4BAGoC,eAAe;+BACZ,kBAAkB;qCACb,kCAAkC;wCACpC,4BAA4B;AAO/D,MAAMI,UAAkCC,CAAAA;IAC7C,MAAMC,YAAQN,+BAAAA,EAAoBK;QAElCF,iDAAAA,EAA0BG;QAE1BJ,gDAAAA,EAA4B,6BAA6BI;IAEzD,WAAOL,qCAAAA,EAAuBK;AAChC,EAAE;AAEFF,QAAQG,WAAW,GAAG;AACtB,6FAA6F;AAC5FH,QAAmCI,wBAAwB,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { ComponentProps, ComponentState, JSXElement, Slot, TriggerProps } from '@fluentui/react-utilities';\nimport type { PortalProps } from '@fluentui/react-portal';\n\n/**\n * Slot properties for Tooltip\n */\nexport type TooltipSlots = {\n /**\n * The text or JSX content of the tooltip.\n */\n content: NonNullable<Slot<'div'>>;\n};\n\n/**\n * The properties that are added to the child of the Tooltip\n */\nexport type TooltipChildProps = {\n ref?: React.Ref<unknown>;\n} & Pick<\n React.HTMLAttributes<HTMLElement>,\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onFocus'\n | 'onPointerEnter'\n | 'onPointerLeave'\n | 'aria-haspopup'\n | 'aria-expanded'\n>;\n\n/**\n * Data for the Tooltip's onVisibleChange event.\n */\nexport type OnVisibleChangeData = {\n visible: boolean;\n\n /**\n * The event object, if this visibility change was triggered by a keyboard event on the document element\n * (such as Escape to hide the visible tooltip). Otherwise undefined.\n */\n documentKeyboardEvent?: KeyboardEvent;\n};\n\n/**\n * Properties for Tooltip\n */\nexport type TooltipProps = ComponentProps<TooltipSlots> &\n TriggerProps<TooltipChildProps> &\n Pick<PortalProps, 'mountNode'> & {\n /**\n * The tooltip's visual appearance.\n * * `normal` - Uses the theme's background and text colors.\n * * `inverted` - Higher contrast variant that uses the theme's inverted colors.\n *\n * @default normal\n */\n appearance?: 'normal' | 'inverted';\n /**\n * Delay before the tooltip is hidden, in milliseconds.\n *\n * @default 250\n */\n hideDelay?: number;\n\n /**\n * Notification when the visibility of the tooltip is changing.\n *\n * **Note**: for backwards compatibility, `event` will be undefined if this was triggered by a keyboard event on\n * the document element. Use `data.documentKeyboardEvent` if the keyboard event object is needed.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onVisibleChange?: (\n event: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined,\n data: OnVisibleChangeData,\n ) => void;\n\n /**\n * Configure the positioning of the tooltip\n *\n * @default above\n */\n positioning?: PositioningShorthand;\n\n /**\n * (Required) Specifies whether this tooltip is acting as the description or label of its trigger element.\n *\n * * `label` - The tooltip sets the trigger's aria-label or aria-labelledby attribute. This is useful for buttons\n * displaying only an icon, for example.\n * * `description` - The tooltip sets the trigger's aria-description or aria-describedby attribute.\n * * `inaccessible` - No aria attributes are set on the trigger. This makes the tooltip's content inaccessible to\n * screen readers, and should only be used if the tooltip's text is available by some other means.\n */\n relationship: 'label' | 'description' | 'inaccessible';\n\n /**\n * Delay before the tooltip is shown, in milliseconds.\n *\n * @default 250\n */\n showDelay?: number;\n\n /**\n * Control the tooltip's visibility programatically.\n *\n * This can be used in conjunction with onVisibleChange to modify the tooltip's show and hide behavior.\n *\n * If not provided, the visibility will be controlled by the tooltip itself, based on hover and focus events on the\n * trigger (child) element.\n *\n * @default false\n */\n visible?: boolean;\n\n /**\n * Render an arrow pointing to the target element\n *\n * @default false\n */\n withArrow?: boolean;\n };\n\nexport type TooltipBaseProps = Omit<TooltipProps, 'appearance'>;\n\n/**\n * State used in rendering Tooltip\n */\nexport type TooltipState = ComponentState<TooltipSlots> &\n Pick<TooltipProps, 'mountNode' | 'relationship'> &\n Required<Pick<TooltipProps, 'appearance' | 'hideDelay' | 'positioning' | 'showDelay' | 'visible' | 'withArrow'>> & {\n children?: JSXElement | null;\n\n /**\n * Whether the tooltip should be rendered to the DOM.\n */\n shouldRenderTooltip?: boolean;\n\n /**\n * Ref to the arrow element\n */\n arrowRef?: React.Ref<HTMLDivElement>;\n\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n\nexport type TooltipBaseState = Omit<TooltipState, 'appearance'>;\n"],"names":[
|
|
1
|
+
{"version":3,"sources":["../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { ComponentProps, ComponentState, JSXElement, Slot, TriggerProps } from '@fluentui/react-utilities';\nimport type { PortalProps } from '@fluentui/react-portal';\n\n/**\n * Slot properties for Tooltip\n */\nexport type TooltipSlots = {\n /**\n * The text or JSX content of the tooltip.\n */\n content: NonNullable<Slot<'div'>>;\n};\n\n/**\n * The properties that are added to the child of the Tooltip\n */\nexport type TooltipChildProps = {\n ref?: React.Ref<unknown>;\n} & Pick<\n React.HTMLAttributes<HTMLElement>,\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onFocus'\n | 'onPointerEnter'\n | 'onPointerLeave'\n | 'aria-haspopup'\n | 'aria-expanded'\n>;\n\n/**\n * Data for the Tooltip's onVisibleChange event.\n */\nexport type OnVisibleChangeData = {\n visible: boolean;\n\n /**\n * The event object, if this visibility change was triggered by a keyboard event on the document element\n * (such as Escape to hide the visible tooltip). Otherwise undefined.\n */\n documentKeyboardEvent?: KeyboardEvent;\n};\n\n/**\n * Properties for Tooltip\n */\nexport type TooltipProps = ComponentProps<TooltipSlots> &\n TriggerProps<TooltipChildProps> &\n Pick<PortalProps, 'mountNode'> & {\n /**\n * The tooltip's visual appearance.\n * * `normal` - Uses the theme's background and text colors.\n * * `inverted` - Higher contrast variant that uses the theme's inverted colors.\n *\n * @default normal\n */\n appearance?: 'normal' | 'inverted';\n /**\n * Delay before the tooltip is hidden, in milliseconds.\n *\n * @default 250\n */\n hideDelay?: number;\n\n /**\n * Notification when the visibility of the tooltip is changing.\n *\n * **Note**: for backwards compatibility, `event` will be undefined if this was triggered by a keyboard event on\n * the document element. Use `data.documentKeyboardEvent` if the keyboard event object is needed.\n */\n // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onVisibleChange?: (\n event: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined,\n data: OnVisibleChangeData,\n ) => void;\n\n /**\n * Configure the positioning of the tooltip\n *\n * @default above\n */\n positioning?: PositioningShorthand;\n\n /**\n * (Required) Specifies whether this tooltip is acting as the description or label of its trigger element.\n *\n * * `label` - The tooltip sets the trigger's aria-label or aria-labelledby attribute. This is useful for buttons\n * displaying only an icon, for example.\n * * `description` - The tooltip sets the trigger's aria-description or aria-describedby attribute.\n * * `inaccessible` - No aria attributes are set on the trigger. This makes the tooltip's content inaccessible to\n * screen readers, and should only be used if the tooltip's text is available by some other means.\n */\n relationship: 'label' | 'description' | 'inaccessible';\n\n /**\n * Delay before the tooltip is shown, in milliseconds.\n *\n * @default 250\n */\n showDelay?: number;\n\n /**\n * Control the tooltip's visibility programatically.\n *\n * This can be used in conjunction with onVisibleChange to modify the tooltip's show and hide behavior.\n *\n * If not provided, the visibility will be controlled by the tooltip itself, based on hover and focus events on the\n * trigger (child) element.\n *\n * @default false\n */\n visible?: boolean;\n\n /**\n * Render an arrow pointing to the target element\n *\n * @default false\n */\n withArrow?: boolean;\n };\n\nexport type TooltipBaseProps = Omit<TooltipProps, 'appearance'>;\n\n/**\n * State used in rendering Tooltip\n */\nexport type TooltipState = ComponentState<TooltipSlots> &\n Pick<TooltipProps, 'mountNode' | 'relationship'> &\n Required<Pick<TooltipProps, 'appearance' | 'hideDelay' | 'positioning' | 'showDelay' | 'visible' | 'withArrow'>> & {\n children?: JSXElement | null;\n\n /**\n * Whether the tooltip should be rendered to the DOM.\n */\n shouldRenderTooltip?: boolean;\n\n /**\n * Ref to the arrow element\n */\n arrowRef?: React.Ref<HTMLDivElement>;\n\n /**\n * CSS class for the arrow element\n */\n arrowClassName?: string;\n };\n\nexport type TooltipBaseState = Omit<TooltipState, 'appearance'>;\n"],"names":[],"mappings":""}
|
|
@@ -91,6 +91,7 @@ const useTooltipBase_unstable = (props)=>{
|
|
|
91
91
|
})
|
|
92
92
|
};
|
|
93
93
|
(_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();
|
|
94
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
94
95
|
context.visibleTooltip = thisTooltip;
|
|
95
96
|
const onDocumentKeyDown = (ev)=>{
|
|
96
97
|
if (ev.key === _keyboardkeys.Escape && !ev.defaultPrevented) {
|
|
@@ -105,6 +106,15 @@ const useTooltipBase_unstable = (props)=>{
|
|
|
105
106
|
// we need to capture the event to be sure keydown handling from tooltip happens first
|
|
106
107
|
capture: true
|
|
107
108
|
});
|
|
109
|
+
// Dismiss the tooltip when the document becomes hidden (e.g. tab backgrounded,
|
|
110
|
+
// app switched on mobile). The original trigger (hover/tap/focus) is no longer
|
|
111
|
+
// active in this case, so persisting the tooltip is a stale UI state.
|
|
112
|
+
const onDocumentVisibilityChange = ()=>{
|
|
113
|
+
if ((targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.visibilityState) === 'hidden') {
|
|
114
|
+
thisTooltip.hide();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('visibilitychange', onDocumentVisibilityChange);
|
|
108
118
|
return ()=>{
|
|
109
119
|
if (context.visibleTooltip === thisTooltip) {
|
|
110
120
|
context.visibleTooltip = undefined;
|
|
@@ -112,6 +122,7 @@ const useTooltipBase_unstable = (props)=>{
|
|
|
112
122
|
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
|
|
113
123
|
capture: true
|
|
114
124
|
});
|
|
125
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('visibilitychange', onDocumentVisibilityChange);
|
|
115
126
|
};
|
|
116
127
|
}
|
|
117
128
|
}, [
|
|
@@ -192,9 +203,13 @@ const useTooltipBase_unstable = (props)=>{
|
|
|
192
203
|
]);
|
|
193
204
|
// Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.
|
|
194
205
|
// This keeps the tooltip visible when the mouse is moved over it, or it has focus within.
|
|
206
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
195
207
|
state.content.onPointerEnter = (0, _reactutilities.mergeCallbacks)(state.content.onPointerEnter, clearDelayTimeout);
|
|
208
|
+
// eslint-disable-next-line react-hooks/immutability, react-hooks/refs
|
|
196
209
|
state.content.onPointerLeave = (0, _reactutilities.mergeCallbacks)(state.content.onPointerLeave, onLeaveTrigger);
|
|
210
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
197
211
|
state.content.onFocus = (0, _reactutilities.mergeCallbacks)(state.content.onFocus, clearDelayTimeout);
|
|
212
|
+
// eslint-disable-next-line react-hooks/immutability, react-hooks/refs
|
|
198
213
|
state.content.onBlur = (0, _reactutilities.mergeCallbacks)(state.content.onBlur, onLeaveTrigger);
|
|
199
214
|
const child = (0, _reactutilities.getTriggerChild)(children);
|
|
200
215
|
const triggerAriaProps = {};
|
|
@@ -206,26 +221,34 @@ const useTooltipBase_unstable = (props)=>{
|
|
|
206
221
|
} else {
|
|
207
222
|
triggerAriaProps['aria-labelledby'] = state.content.id;
|
|
208
223
|
// Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
|
|
224
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
209
225
|
state.shouldRenderTooltip = true;
|
|
210
226
|
}
|
|
211
227
|
} else if (relationship === 'description') {
|
|
212
228
|
triggerAriaProps['aria-describedby'] = state.content.id;
|
|
213
229
|
// Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
|
|
230
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
214
231
|
state.shouldRenderTooltip = true;
|
|
215
232
|
}
|
|
216
233
|
// Case 1: Don't render the Tooltip in SSR to avoid hydration errors
|
|
217
234
|
// Case 2: Don't render the Tooltip, if it triggers Menu or another popup and it's already opened
|
|
218
235
|
if (isServerSideRender || isPopupExpanded) {
|
|
236
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
219
237
|
state.shouldRenderTooltip = false;
|
|
220
238
|
}
|
|
221
239
|
// Apply the trigger props to the child, either by calling the render function, or cloning with the new props
|
|
240
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
222
241
|
state.children = (0, _reactutilities.applyTriggerPropsToChildren)(children, {
|
|
223
242
|
...triggerAriaProps,
|
|
224
243
|
...child === null || child === void 0 ? void 0 : child.props,
|
|
225
244
|
ref: (0, _reactutilities.useMergedRefs)((0, _reactutilities.getReactElementRef)(child), keyborgListenerCallbackRef, positioningOptions.target === undefined ? targetRef : undefined),
|
|
245
|
+
// eslint-disable-next-line react-hooks/refs
|
|
226
246
|
onPointerEnter: (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.onPointerEnter, onEnterTrigger)),
|
|
247
|
+
// eslint-disable-next-line react-hooks/refs
|
|
227
248
|
onPointerLeave: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props4 = child.props) === null || _child_props4 === void 0 ? void 0 : _child_props4.onPointerLeave, onLeaveTrigger)),
|
|
249
|
+
// eslint-disable-next-line react-hooks/refs
|
|
228
250
|
onFocus: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props5 = child.props) === null || _child_props5 === void 0 ? void 0 : _child_props5.onFocus, onEnterTrigger)),
|
|
251
|
+
// eslint-disable-next-line react-hooks/refs
|
|
229
252
|
onBlur: (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props6 = child.props) === null || _child_props6 === void 0 ? void 0 : _child_props6.onBlur, onLeaveTrigger))
|
|
230
253
|
});
|
|
231
254
|
return state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/useTooltipBase.tsx"],"sourcesContent":["'use client';\n\nimport * 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 type { KeyborgFocusInEvent } from '@fluentui/react-tabster';\nimport { KEYBORG_FOCUSIN, useIsNavigatingWithKeyboard } from '@fluentui/react-tabster';\nimport {\n applyTriggerPropsToChildren,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n slot,\n getReactElementRef,\n} from '@fluentui/react-utilities';\nimport type { TooltipBaseProps, TooltipBaseState, TooltipChildProps, OnVisibleChangeData } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { useTooltipTimeout } from './private/useTooltipTimeout';\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 useTooltipBase_unstable = (props: TooltipBaseProps): TooltipBaseState => {\n 'use no memo';\n\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n\n const {\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 state: TooltipBaseState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: slot.always(content, {\n defaultProps: {\n role: 'tooltip',\n },\n elementType: 'div',\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n targetRef: React.MutableRefObject<unknown>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n containerRef: React.MutableRefObject<HTMLDivElement>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n const [setDelayTimeout, clearDelayTimeout] = useTooltipTimeout(containerRef);\n\n const setVisible = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined, data: OnVisibleChangeData) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (data.visible !== oldVisible) {\n onVisibleChange?.(ev, data);\n }\n return data.visible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\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 = {\n hide: (ev?: KeyboardEvent) => setVisible(undefined, { visible: false, documentKeyboardEvent: ev }),\n };\n\n context.visibleTooltip?.hide();\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape && !ev.defaultPrevented) {\n thisTooltip.hide(ev);\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu and Tooltip\n ev.preventDefault();\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 // Used to skip showing the tooltip in certain situations when the trigger is focused.\n // See comments where this is set for more info.\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(ev, { visible: true });\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 const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();\n\n // Callback ref that attaches a keyborg:focusin event listener.\n const [keyborgListenerCallbackRef] = React.useState(() => {\n const onKeyborgFocusIn = ((ev: KeyborgFocusInEvent) => {\n // Skip showing the tooltip if focus moved programmatically.\n // For example, we don't want to show the tooltip when a dialog is closed\n // and Tabster programmatically restores focus to the trigger button.\n // See https://github.com/microsoft/fluentui/issues/27576\n if (ev.detail?.isFocusedProgrammatically && !isNavigatingWithKeyboard()) {\n ignoreNextFocusEventRef.current = true;\n }\n }) as EventListener;\n\n // Save the current element to remove the listener when the ref changes\n let current: Element | null = null;\n\n // Callback ref that attaches the listener to the element\n return (element: Element | null) => {\n current?.removeEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n element?.addEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n current = element;\n };\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 // 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 ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(ev, { visible: false });\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 const isPopupExpanded =\n child?.props?.['aria-haspopup'] &&\n (child?.props?.['aria-expanded'] === true || child?.props?.['aria-expanded'] === 'true');\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 // Case 1: Don't render the Tooltip in SSR to avoid hydration errors\n // Case 2: Don't render the Tooltip, if it triggers Menu or another popup and it's already opened\n if (isServerSideRender || isPopupExpanded) {\n state.shouldRenderTooltip = false;\n }\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 ref: useMergedRefs(\n getReactElementRef<HTMLButtonElement>(child),\n keyborgListenerCallbackRef,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n positioningOptions.target === undefined ? targetRef : undefined,\n ),\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"],"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","KEYBORG_FOCUSIN","useIsNavigatingWithKeyboard","applyTriggerPropsToChildren","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","getTriggerChild","mergeCallbacks","useEventCallback","slot","getReactElementRef","arrowHeight","tooltipBorderRadius","useTooltipTimeout","Escape","useTooltipBase_unstable","props","child","context","isServerSideRender","targetDocument","visible","setVisibleInternal","state","initialState","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","shouldRenderTooltip","components","always","defaultProps","role","elementType","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","setDelayTimeout","clearDelayTimeout","setVisible","useCallback","ev","data","oldVisible","ref","thisTooltip","hide","undefined","documentKeyboardEvent","visibleTooltip","onDocumentKeyDown","key","defaultPrevented","preventDefault","addEventListener","capture","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","isNavigatingWithKeyboard","keyborgListenerCallbackRef","useState","onKeyborgFocusIn","detail","isFocusedProgrammatically","element","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","triggerAriaProps","isPopupExpanded"],"mappings":"AAAA;;;;;+BAoCayB;;;;;;;iEAlCU,QAAQ;kCAC+C,8BAA8B;qCAIrG,kCAAkC;8BAEoB,0BAA0B;gCAahF,4BAA4B;2BAEc,sBAAsB;mCACrC,8BAA8B;8BACzC,0BAA0B;AAU1C,gCAAgC,CAACC;IACtC;QAkNEC,cACCA,eAA4CA,eAiCGA,eACAA,eACPA,eACDA;IArP1C,MAAMC,cAAUvB,kDAAAA;IAChB,MAAMwB,yBAAqBf,wBAAAA;IAC3B,MAAM,EAAEgB,cAAc,EAAE,OAAGvB,uCAAAA;IAE3B,MAAM,CAACwB,SAASC,mBAAmB,OAAGrB,oCAAAA,EAAqB;QAAEsB,OAAOP,MAAMK,OAAO;QAAEG,cAAc;IAAM;IAEvG,MAAM,EACJC,QAAQ,EACRC,OAAO,EACPC,YAAY,KAAK,EACjBC,cAAc,OAAO,EACrBC,eAAe,EACfC,YAAY,EACZC,YAAY,GAAG,EACfC,YAAY,GAAG,EACfC,SAAS,EACV,GAAGjB;IAEJ,MAAMO,QAA0B;QAC9BI;QACAC;QACAG;QACAC;QACAF;QACAT;QACAa,qBAAqBb;QACrBY;QACA,QAAQ;QACRE,YAAY;YACVT,SAAS;QACX;QACAA,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A,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAAA,AAAK,MAAA,QAAZC,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAcwE,OAAO,EAAEjB;QAChEkB,YAAQlF,gCAAAA,MAAiBD,8BAAAA,EAAeU,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAAA,AAAK,MAAA,QAAZC,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAcyE,MAAM,EAAEN;IAChE;IAEA,OAAO7D;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../src/components/Tooltip/useTooltipBase.tsx"],"sourcesContent":["'use client';\n\nimport * 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 type { KeyborgFocusInEvent } from '@fluentui/react-tabster';\nimport { KEYBORG_FOCUSIN, useIsNavigatingWithKeyboard } from '@fluentui/react-tabster';\nimport {\n applyTriggerPropsToChildren,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n slot,\n getReactElementRef,\n} from '@fluentui/react-utilities';\nimport type { TooltipBaseProps, TooltipBaseState, TooltipChildProps, OnVisibleChangeData } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { useTooltipTimeout } from './private/useTooltipTimeout';\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 useTooltipBase_unstable = (props: TooltipBaseProps): TooltipBaseState => {\n 'use no memo';\n\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n\n const {\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 state: TooltipBaseState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: slot.always(content, {\n defaultProps: {\n role: 'tooltip',\n },\n elementType: 'div',\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 // eslint-disable-next-line @typescript-eslint/no-deprecated\n targetRef: React.MutableRefObject<unknown>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n containerRef: React.MutableRefObject<HTMLDivElement>;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n const [setDelayTimeout, clearDelayTimeout] = useTooltipTimeout(containerRef);\n\n const setVisible = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement> | undefined, data: OnVisibleChangeData) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (data.visible !== oldVisible) {\n onVisibleChange?.(ev, data);\n }\n return data.visible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\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 = {\n hide: (ev?: KeyboardEvent) => setVisible(undefined, { visible: false, documentKeyboardEvent: ev }),\n };\n\n context.visibleTooltip?.hide();\n // eslint-disable-next-line react-hooks/immutability\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape && !ev.defaultPrevented) {\n thisTooltip.hide(ev);\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu and Tooltip\n ev.preventDefault();\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 // Dismiss the tooltip when the document becomes hidden (e.g. tab backgrounded,\n // app switched on mobile). The original trigger (hover/tap/focus) is no longer\n // active in this case, so persisting the tooltip is a stale UI state.\n const onDocumentVisibilityChange = () => {\n if (targetDocument?.visibilityState === 'hidden') {\n thisTooltip.hide();\n }\n };\n\n targetDocument?.addEventListener('visibilitychange', onDocumentVisibilityChange);\n\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n\n targetDocument?.removeEventListener('keydown', onDocumentKeyDown, { capture: true });\n targetDocument?.removeEventListener('visibilitychange', onDocumentVisibilityChange);\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n\n // Used to skip showing the tooltip in certain situations when the trigger is focused.\n // See comments where this is set for more info.\n const ignoreNextFocusEventRef = React.useRef(false);\n\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(\n // eslint-disable-next-line react-hooks/preserve-manual-memoization\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(ev, { visible: true });\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 const isNavigatingWithKeyboard = useIsNavigatingWithKeyboard();\n\n // Callback ref that attaches a keyborg:focusin event listener.\n const [keyborgListenerCallbackRef] = React.useState(() => {\n const onKeyborgFocusIn = ((ev: KeyborgFocusInEvent) => {\n // Skip showing the tooltip if focus moved programmatically.\n // For example, we don't want to show the tooltip when a dialog is closed\n // and Tabster programmatically restores focus to the trigger button.\n // See https://github.com/microsoft/fluentui/issues/27576\n if (ev.detail?.isFocusedProgrammatically && !isNavigatingWithKeyboard()) {\n ignoreNextFocusEventRef.current = true;\n }\n }) as EventListener;\n\n // Save the current element to remove the listener when the ref changes\n let current: Element | null = null;\n\n // Callback ref that attaches the listener to the element\n return (element: Element | null) => {\n current?.removeEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n element?.addEventListener(KEYBORG_FOCUSIN, onKeyborgFocusIn);\n current = element;\n };\n });\n\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(\n // eslint-disable-next-line react-hooks/preserve-manual-memoization\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 // 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 ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(ev, { visible: false });\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 // eslint-disable-next-line react-hooks/immutability\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n // eslint-disable-next-line react-hooks/immutability, react-hooks/refs\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n // eslint-disable-next-line react-hooks/immutability\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n // eslint-disable-next-line react-hooks/immutability, react-hooks/refs\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 const isPopupExpanded =\n child?.props?.['aria-haspopup'] &&\n (child?.props?.['aria-expanded'] === true || child?.props?.['aria-expanded'] === 'true');\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 // eslint-disable-next-line react-hooks/immutability\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 // eslint-disable-next-line react-hooks/immutability\n state.shouldRenderTooltip = true;\n }\n\n // Case 1: Don't render the Tooltip in SSR to avoid hydration errors\n // Case 2: Don't render the Tooltip, if it triggers Menu or another popup and it's already opened\n if (isServerSideRender || isPopupExpanded) {\n // eslint-disable-next-line react-hooks/immutability\n state.shouldRenderTooltip = false;\n }\n\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n // eslint-disable-next-line react-hooks/immutability\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child?.props,\n ref: useMergedRefs(\n getReactElementRef<HTMLButtonElement>(child),\n keyborgListenerCallbackRef,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n positioningOptions.target === undefined ? targetRef : undefined,\n ),\n // eslint-disable-next-line react-hooks/refs\n onPointerEnter: useEventCallback(mergeCallbacks(child?.props?.onPointerEnter, onEnterTrigger)),\n // eslint-disable-next-line react-hooks/refs\n onPointerLeave: useEventCallback(mergeCallbacks(child?.props?.onPointerLeave, onLeaveTrigger)),\n // eslint-disable-next-line react-hooks/refs\n onFocus: useEventCallback(mergeCallbacks(child?.props?.onFocus, onEnterTrigger)),\n // eslint-disable-next-line react-hooks/refs\n onBlur: useEventCallback(mergeCallbacks(child?.props?.onBlur, onLeaveTrigger)),\n });\n\n return state;\n};\n"],"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","KEYBORG_FOCUSIN","useIsNavigatingWithKeyboard","applyTriggerPropsToChildren","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","getTriggerChild","mergeCallbacks","useEventCallback","slot","getReactElementRef","arrowHeight","tooltipBorderRadius","useTooltipTimeout","Escape","useTooltipBase_unstable","props","child","context","isServerSideRender","targetDocument","visible","setVisibleInternal","state","initialState","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","shouldRenderTooltip","components","always","defaultProps","role","elementType","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","setDelayTimeout","clearDelayTimeout","setVisible","useCallback","ev","data","oldVisible","ref","thisTooltip","hide","undefined","documentKeyboardEvent","visibleTooltip","onDocumentKeyDown","key","defaultPrevented","preventDefault","addEventListener","capture","onDocumentVisibilityChange","visibilityState","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","isNavigatingWithKeyboard","keyborgListenerCallbackRef","useState","onKeyborgFocusIn","detail","isFocusedProgrammatically","element","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","triggerAriaProps","isPopupExpanded"],"mappings":"AAAA;;;;;+BAoCayB;;;;;;;iEAlCU,QAAQ;kCAC+C,8BAA8B;qCAIrG,kCAAkC;8BAEoB,0BAA0B;gCAahF,4BAA4B;2BAEc,sBAAsB;mCACrC,8BAA8B;8BACzC,0BAA0B;AAU1C,gCAAgC,CAACC;IACtC;QAqOEC,cACCA,eAA4CA,eAsCGA,eAEAA,eAEPA,eAEDA;IAhR1C,MAAMC,cAAUvB,kDAAAA;IAChB,MAAMwB,yBAAqBf,wBAAAA;IAC3B,MAAM,EAAEgB,cAAc,EAAE,OAAGvB,uCAAAA;IAE3B,MAAM,CAACwB,SAASC,mBAAmB,OAAGrB,oCAAAA,EAAqB;QAAEsB,OAAOP,MAAMK,OAAO;QAAEG,cAAc;IAAM;IAEvG,MAAM,EACJC,QAAQ,EACRC,OAAO,EACPC,YAAY,KAAK,EACjBC,cAAc,OAAO,EACrBC,eAAe,EACfC,YAAY,EACZC,YAAY,GAAG,EACfC,YAAY,GAAG,EACfC,SAAS,EACV,GAAGjB;IAEJ,MAAMO,QAA0B;QAC9BI;QACAC;QACAG;QACAC;QACAF;QACAT;QACAa,qBAAqBb;QACrBY;QACA,QAAQ;QACRE,YAAY;YACVT,SAAS;QACX;QACAA,SAASjB,oBAAAA,CAAK2B,MAAM,CAACV,SAAS;YAC5BW,cAAc;gBACZC,MAAM;YACR;YACAC,aAAa;QACf;IACF;IAEAhB,MAAMG,OAAO,CAACc,EAAE,OAAGtC,qBAAAA,EAAM,YAAYqB,MAAMG,OAAO,CAACc,EAAE;IAErD,MAAMC,qBAAqB;QACzBC,SAASnB,MAAMF,OAAO;QACtBsB,cAAc,IAAI/B,8BAAAA;QAClBgC,UAAU;QACVC,OAAO;QACPC,QAAQ;QACR,OAAGtD,6CAAAA,EAA4B+B,MAAMK,WAAW,CAAC;IACnD;IAEA,IAAIL,MAA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QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAAA,AAAK,MAAA,QAAZC,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAcyE,cAAc,EAAEJ;QAC9E,4CAA4C;QAC5CK,aAASnF,gCAAAA,MAAiBD,8BAAAA,EAAeU,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAAA,AAAK,MAAA,QAAZC,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAc0E,OAAO,EAAEjB;QAChE,4CAA4C;QAC5CkB,YAAQpF,gCAAAA,MAAiBD,8BAAAA,EAAeU,UAAAA,QAAAA,UAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAAA,AAAK,MAAA,QAAZC,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAc2E,MAAM,EAAEN;IAChE;IAEA,OAAO/D;AACT,EAAE"}
|
|
@@ -197,7 +197,9 @@ const tooltipClassNames = {
|
|
|
197
197
|
const useTooltipStyles_unstable = (state)=>{
|
|
198
198
|
'use no memo';
|
|
199
199
|
const styles = useStyles();
|
|
200
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
200
201
|
state.content.className = (0, _react.mergeClasses)(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
|
|
202
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
201
203
|
state.arrowClassName = styles.arrow;
|
|
202
204
|
return state;
|
|
203
205
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTooltipStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, 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 */ const useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px',\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter: `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` + `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`\n },\n visible: {\n display: 'block'\n },\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted\n },\n arrow: createArrowStyles({\n arrowHeight\n })\n});\n/**\n * Apply styling to the Tooltip slots based on the state\n */ export const useTooltipStyles_unstable = (state)=>{\n 'use no memo';\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"],"names":["__styles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Btd35i7","Beyfa6y","Bbmb7ep","Btl43ni","B7oj6ja","Dimara","Bgfg5da","B9xav0g","oivjwe","Bn0qgzm","B4g9neb","zhjwy3","wvpqe5","ibv6hh","u1mtju","h3c5rm","vrafjx","Bekrc4i","i8vvqc","g2u3we","icvyot","B4j52fo","irswps","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bj3rh1h","rhnwrx","Bdy53xb","B2eet1l","Bz10aip","Bqenvij","a9b677","Ftih45","Br0sdwz","cmx5o7","susq4k","Biibvgv","Bicfajf","qehafq","Brs5u8j","Ccq8qp","Baz25je","Bcgcnre","Bqjgrrk","qa3bma","y0oebl","Biqmznv","Bm6vgfq","Bbv0w2i","uvfttm","eqrjj","Bk5zm6e","m598lv","B4f6apu","ydt019","Bq4z7u6","Bdkvgpv","B0qfbqy","kj8mxx","r59vdv","Bkw5xw4","hl6cv3","aea9ga","yayu3t","Bhsv975","rhl9o9","B7gxrvb","B6q6orb","B0lu1f8","d","p","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"mappings":"AAAA,YAAY;;;;;;;;;;;;IAKCK,iBAAiB;;;6BAoCY
|
|
1
|
+
{"version":3,"sources":["useTooltipStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, 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 */ const useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px',\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter: `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` + `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`\n },\n visible: {\n display: 'block'\n },\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted\n },\n arrow: createArrowStyles({\n arrowHeight\n })\n});\n/**\n * Apply styling to the Tooltip slots based on the state\n */ export const useTooltipStyles_unstable = (state)=>{\n 'use no memo';\n const styles = useStyles();\n // eslint-disable-next-line react-hooks/immutability\n state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);\n // eslint-disable-next-line react-hooks/immutability\n state.arrowClassName = styles.arrow;\n return state;\n};\n"],"names":["__styles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Btd35i7","Beyfa6y","Bbmb7ep","Btl43ni","B7oj6ja","Dimara","Bgfg5da","B9xav0g","oivjwe","Bn0qgzm","B4g9neb","zhjwy3","wvpqe5","ibv6hh","u1mtju","h3c5rm","vrafjx","Bekrc4i","i8vvqc","g2u3we","icvyot","B4j52fo","irswps","Byoj8tv","uwmqm3","z189sj","z8tnut","B0ocmuz","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bj3rh1h","rhnwrx","Bdy53xb","B2eet1l","Bz10aip","Bqenvij","a9b677","Ftih45","Br0sdwz","cmx5o7","susq4k","Biibvgv","Bicfajf","qehafq","Brs5u8j","Ccq8qp","Baz25je","Bcgcnre","Bqjgrrk","qa3bma","y0oebl","Biqmznv","Bm6vgfq","Bbv0w2i","uvfttm","eqrjj","Bk5zm6e","m598lv","B4f6apu","ydt019","Bq4z7u6","Bdkvgpv","B0qfbqy","kj8mxx","r59vdv","Bkw5xw4","hl6cv3","aea9ga","yayu3t","Bhsv975","rhl9o9","B7gxrvb","B6q6orb","B0lu1f8","d","p","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"mappings":"AAAA,YAAY;;;;;;;;;;;;IAKCK,iBAAiB;;;6BAoCY;eAAzB4F;;;uBAxCwB,gBAAgB;AAIlD,0BAA0B;IAC7B3F,OAAO,EAAE;AACb,CAAC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GS,mCAAmCE,KAAK,IAAG;IAClD,aAAa;IACb,MAAMC,MAAM,GAAG5F,SAAS,CAAC,CAAC;IAC1B,oDAAA;IACA2F,KAAK,CAAC5F,OAAO,CAAC8F,SAAS,OAAGnG,mBAAY,EAACI,iBAAiB,CAACC,OAAO,EAAE6F,MAAM,CAAC3F,IAAI,EAAE0F,KAAK,CAACG,UAAU,KAAK,UAAU,IAAIF,MAAM,CAACnD,QAAQ,EAAEkD,KAAK,CAACnD,OAAO,IAAIoD,MAAM,CAACpD,OAAO,EAAEmD,KAAK,CAAC5F,OAAO,CAAC8F,SAAS,CAAC;IAC5L,oDAAA;IACAF,KAAK,CAACI,cAAc,GAAGH,MAAM,CAAClD,KAAK;IACnC,OAAOiD,KAAK;AAChB,CAAC"}
|
|
@@ -58,7 +58,9 @@ const tooltipClassNames = {
|
|
|
58
58
|
const useTooltipStyles_unstable = (state)=>{
|
|
59
59
|
'use no memo';
|
|
60
60
|
const styles = useStyles();
|
|
61
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
61
62
|
state.content.className = (0, _react.mergeClasses)(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
|
|
63
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
62
64
|
state.arrowClassName = styles.arrow;
|
|
63
65
|
return state;
|
|
64
66
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Tooltip/useTooltipStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport { arrowHeight } from './private/constants';\nimport type { TooltipSlots, TooltipState } from './Tooltip.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const tooltipClassNames: SlotClassNames<TooltipSlots> = {\n content: 'fui-Tooltip__content',\n};\n\n/**\n * Styles for the tooltip\n */\nconst useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px', // '5px 12px 7px 12px' minus the border width '1px'\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter:\n `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` +\n `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`,\n },\n\n visible: {\n display: 'block',\n },\n\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted,\n },\n\n arrow: createArrowStyles({ arrowHeight }),\n});\n\n/**\n * Apply styling to the Tooltip slots based on the state\n */\nexport const useTooltipStyles_unstable = (state: TooltipState): TooltipState => {\n 'use no memo';\n\n const styles = useStyles();\n\n state.content.className = mergeClasses(\n tooltipClassNames.content,\n styles.root,\n state.appearance === 'inverted' && styles.inverted,\n state.visible && styles.visible,\n state.content.className,\n );\n\n state.arrowClassName = styles.arrow;\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","display","boxSizing","maxWidth","cursor","fontFamily","fontFamilyBase","fontSize","fontSizeBase200","lineHeight","lineHeightBase200","overflowWrap","borderRadius","borderRadiusMedium","border","colorTransparentStroke","padding","backgroundColor","colorNeutralBackground1","color","colorNeutralForeground1","filter","colorNeutralShadowAmbient","colorNeutralShadowKey","visible","inverted","colorNeutralBackgroundStatic","colorNeutralForegroundStaticInverted","arrow","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"mappings":"AAAA;;;;;;;;;;;;IASaK,iBAAAA;;;IA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../src/components/Tooltip/useTooltipStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport { createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport { arrowHeight } from './private/constants';\nimport type { TooltipSlots, TooltipState } from './Tooltip.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const tooltipClassNames: SlotClassNames<TooltipSlots> = {\n content: 'fui-Tooltip__content',\n};\n\n/**\n * Styles for the tooltip\n */\nconst useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n overflowWrap: 'break-word',\n borderRadius: tokens.borderRadiusMedium,\n border: `1px solid ${tokens.colorTransparentStroke}`,\n padding: '4px 11px 6px 11px', // '5px 12px 7px 12px' minus the border width '1px'\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter:\n `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` +\n `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`,\n },\n\n visible: {\n display: 'block',\n },\n\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundStatic,\n color: tokens.colorNeutralForegroundStaticInverted,\n },\n\n arrow: createArrowStyles({ arrowHeight }),\n});\n\n/**\n * Apply styling to the Tooltip slots based on the state\n */\nexport const useTooltipStyles_unstable = (state: TooltipState): TooltipState => {\n 'use no memo';\n\n const styles = useStyles();\n\n // eslint-disable-next-line react-hooks/immutability\n state.content.className = mergeClasses(\n tooltipClassNames.content,\n styles.root,\n state.appearance === 'inverted' && styles.inverted,\n state.visible && styles.visible,\n state.content.className,\n );\n\n // eslint-disable-next-line react-hooks/immutability\n state.arrowClassName = styles.arrow;\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","display","boxSizing","maxWidth","cursor","fontFamily","fontFamilyBase","fontSize","fontSizeBase200","lineHeight","lineHeightBase200","overflowWrap","borderRadius","borderRadiusMedium","border","colorTransparentStroke","padding","backgroundColor","colorNeutralBackground1","color","colorNeutralForeground1","filter","colorNeutralShadowAmbient","colorNeutralShadowKey","visible","inverted","colorNeutralBackgroundStatic","colorNeutralForegroundStaticInverted","arrow","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"mappings":"AAAA;;;;;;;;;;;;IASaK,iBAAAA;;;IA4CAgC,yBAAAA;;;;uBAnD4B,iBAAiB;kCACxB,8BAA8B;4BACzC,wBAAwB;2BACnB,sBAAsB;AAI3C,0BAAwD;IAC7D/B,SAAS;AACX,EAAE;AAEF;;CAEC,GACD,MAAMC,gBAAYP,iBAAAA,EAAW;IAC3BQ,MAAM;QACJC,SAAS;QACTC,WAAW;QACXC,UAAU;QACVC,QAAQ;QACRC,YAAYV,kBAAAA,CAAOW,cAAc;QACjCC,UAAUZ,kBAAAA,CAAOa,eAAe;QAChCC,YAAYd,kBAAAA,CAAOe,iBAAiB;QACpCC,cAAc;QACdC,cAAcjB,kBAAAA,CAAOkB,kBAAkB;QACvCC,QAAQ,CAAC,UAAU,EAAEnB,kBAAAA,CAAOoB,sBAAsB,EAAE;QACpDC,SAAS;QACTC,iBAAiBtB,kBAAAA,CAAOuB,uBAAuB;QAC/CC,OAAOxB,kBAAAA,CAAOyB,uBAAuB;QAErC,uFAAuF;QACvFC,QACE,CAAC,oBAAoB,EAAE1B,kBAAAA,CAAO2B,yBAAyB,CAAC,EAAE,CAAC,GAC3D,CAAC,sBAAsB,EAAE3B,kBAAAA,CAAO4B,qBAAqB,CAAC,CAAC,CAAC;IAC5D;IAEAC,SAAS;QACPvB,SAAS;IACX;IAEAwB,UAAU;QACRR,iBAAiBtB,kBAAAA,CAAO+B,4BAA4B;QACpDP,OAAOxB,kBAAAA,CAAOgC,oCAAoC;IACpD;IAEAC,WAAOlC,mCAAAA,EAAkB;qBAAEE,sBAAAA;IAAY;AACzC;AAKO,kCAAkC,CAACkC;IACxC;IAEA,MAAMC,SAAShC;IAEf,oDAAoD;IACpD+B,MAAMhC,OAAO,CAACkC,SAAS,OAAGvC,mBAAAA,EACxBI,kBAAkBC,OAAO,EACzBiC,OAAO/B,IAAI,EACX8B,MAAMG,UAAU,KAAK,cAAcF,OAAON,QAAQ,EAClDK,MAAMN,OAAO,IAAIO,OAAOP,OAAO,EAC/BM,MAAMhC,OAAO,CAACkC,SAAS;IAGzB,oDAAoD;IACpDF,MAAMI,cAAc,GAAGH,OAAOH,KAAK;IAEnC,OAAOE;AACT,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-tooltip",
|
|
3
|
-
"version": "9.10.
|
|
3
|
+
"version": "9.10.2",
|
|
4
4
|
"description": "React components for building web experiences",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@fluentui/keyboard-keys": "^9.0.8",
|
|
16
|
-
"@fluentui/react-jsx-runtime": "^9.4.
|
|
17
|
-
"@fluentui/react-portal": "^9.8.
|
|
18
|
-
"@fluentui/react-positioning": "^9.22.
|
|
16
|
+
"@fluentui/react-jsx-runtime": "^9.4.3",
|
|
17
|
+
"@fluentui/react-portal": "^9.8.13",
|
|
18
|
+
"@fluentui/react-positioning": "^9.22.2",
|
|
19
19
|
"@fluentui/react-shared-contexts": "^9.26.2",
|
|
20
|
-
"@fluentui/react-tabster": "^9.26.
|
|
20
|
+
"@fluentui/react-tabster": "^9.26.15",
|
|
21
21
|
"@fluentui/react-theme": "^9.2.1",
|
|
22
|
-
"@fluentui/react-utilities": "^9.26.
|
|
22
|
+
"@fluentui/react-utilities": "^9.26.4",
|
|
23
23
|
"@griffel/react": "^1.5.32",
|
|
24
24
|
"@swc/helpers": "^0.5.1"
|
|
25
25
|
},
|