@fluentui/react-tooltip 9.2.15 → 9.2.16
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +46 -1
- package/CHANGELOG.md +16 -2
- package/lib/Tooltip.js +0 -1
- package/lib/Tooltip.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +5 -7
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.types.js +0 -1
- package/lib/components/Tooltip/Tooltip.types.js.map +1 -1
- package/lib/components/Tooltip/index.js +0 -1
- package/lib/components/Tooltip/index.js.map +1 -1
- package/lib/components/Tooltip/private/constants.js +2 -4
- package/lib/components/Tooltip/private/constants.js.map +1 -1
- package/lib/components/Tooltip/renderTooltip.js +9 -14
- package/lib/components/Tooltip/renderTooltip.js.map +1 -1
- package/lib/components/Tooltip/useTooltip.js +177 -177
- package/lib/components/Tooltip/useTooltip.js.map +1 -1
- package/lib/components/Tooltip/useTooltipStyles.styles.js.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Tooltip.js +0 -3
- package/lib-commonjs/Tooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.js +1 -3
- package/lib-commonjs/components/Tooltip/Tooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/Tooltip.types.js +0 -3
- package/lib-commonjs/components/Tooltip/Tooltip.types.js.map +1 -1
- package/lib-commonjs/components/Tooltip/index.js +0 -3
- package/lib-commonjs/components/Tooltip/index.js.map +1 -1
- package/lib-commonjs/components/Tooltip/private/constants.js +1 -3
- package/lib-commonjs/components/Tooltip/private/constants.js.map +1 -1
- package/lib-commonjs/components/Tooltip/renderTooltip.js +1 -3
- package/lib-commonjs/components/Tooltip/renderTooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltip.js +1 -3
- package/lib-commonjs/components/Tooltip/useTooltip.js.map +1 -1
- package/lib-commonjs/components/Tooltip/useTooltipStyles.styles.js +0 -2
- package/lib-commonjs/components/Tooltip/useTooltipStyles.styles.js.map +1 -1
- package/lib-commonjs/index.js +0 -3
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,52 @@
|
|
2
2
|
"name": "@fluentui/react-tooltip",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Wed, 31 May 2023 06:43:05 GMT",
|
6
|
+
"tag": "@fluentui/react-tooltip_v9.2.16",
|
7
|
+
"version": "9.2.16",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "seanmonahan@microsoft.com",
|
12
|
+
"package": "@fluentui/react-tooltip",
|
13
|
+
"commit": "d640b972d7ac86bfb76ae6c6329f12cdd33b3b7c",
|
14
|
+
"comment": "chore: Update Griffel to v1.5.7."
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-tooltip",
|
19
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.6",
|
20
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-tooltip",
|
25
|
+
"comment": "Bump @fluentui/react-portal to v9.2.12",
|
26
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"author": "beachball",
|
30
|
+
"package": "@fluentui/react-tooltip",
|
31
|
+
"comment": "Bump @fluentui/react-positioning to v9.6.0",
|
32
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"author": "beachball",
|
36
|
+
"package": "@fluentui/react-tooltip",
|
37
|
+
"comment": "Bump @fluentui/react-utilities to v9.9.2",
|
38
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"author": "beachball",
|
42
|
+
"package": "@fluentui/react-tooltip",
|
43
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.22",
|
44
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
45
|
+
}
|
46
|
+
]
|
47
|
+
}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"date": "Thu, 25 May 2023 10:00:48 GMT",
|
6
51
|
"tag": "@fluentui/react-tooltip_v9.2.15",
|
7
52
|
"version": "9.2.15",
|
8
53
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,26 @@
|
|
1
1
|
# Change Log - @fluentui/react-tooltip
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Wed, 31 May 2023 06:43:05 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.2.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.2.16)
|
8
|
+
|
9
|
+
Wed, 31 May 2023 06:43:05 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.2.15..@fluentui/react-tooltip_v9.2.16)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: Update Griffel to v1.5.7. ([PR #27925](https://github.com/microsoft/fluentui/pull/27925) by seanmonahan@microsoft.com)
|
15
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.0-alpha.6 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
16
|
+
- Bump @fluentui/react-portal to v9.2.12 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
17
|
+
- Bump @fluentui/react-positioning to v9.6.0 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
18
|
+
- Bump @fluentui/react-utilities to v9.9.2 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
19
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.22 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
20
|
+
|
7
21
|
## [9.2.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-tooltip_v9.2.15)
|
8
22
|
|
9
|
-
Thu, 25 May 2023
|
23
|
+
Thu, 25 May 2023 10:00:48 GMT
|
10
24
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tooltip_v9.2.14..@fluentui/react-tooltip_v9.2.15)
|
11
25
|
|
12
26
|
### Patches
|
package/lib/Tooltip.js
CHANGED
package/lib/Tooltip.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["Tooltip.ts"],"sourcesContent":["export * from './components/Tooltip/index';\n"],"names":[],"mappings":"AAAA,cAAc,6BAA6B"}
|
@@ -5,14 +5,12 @@ import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
|
|
5
5
|
import { useTooltipStyles_unstable } from './useTooltipStyles.styles';
|
6
6
|
/**
|
7
7
|
* A tooltip provides light weight contextual information on top of its target element.
|
8
|
-
*/
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
return renderTooltip_unstable(state);
|
8
|
+
*/ export const Tooltip = (props)=>{
|
9
|
+
const state = useTooltip_unstable(props);
|
10
|
+
useTooltipStyles_unstable(state);
|
11
|
+
useCustomStyleHook_unstable('useTooltipStyles_unstable')(state);
|
12
|
+
return renderTooltip_unstable(state);
|
14
13
|
};
|
15
14
|
Tooltip.displayName = 'Tooltip';
|
16
15
|
// type casting here is required to ensure internal type FluentTriggerComponent is not leaked
|
17
16
|
Tooltip.isFluentTriggerComponent = true;
|
18
|
-
//# sourceMappingURL=Tooltip.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["Tooltip.tsx"],"sourcesContent":["import * 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":["React","useTooltip_unstable","renderTooltip_unstable","useCustomStyleHook_unstable","useTooltipStyles_unstable","Tooltip","props","state","displayName","isFluentTriggerComponent"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,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,QAAS;IACtD,MAAMC,QAAQN,oBAAoBK;IAElCF,0BAA0BG;IAE1BJ,4BAA4B,6BAA6BI;IAEzD,OAAOL,uBAAuBK;AAChC,EAAE;AAEFF,QAAQG,WAAW,GAAG;AACtB,6FAA6F;AAC5FH,QAAmCI,wBAAwB,GAAG,IAAI"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["Tooltip.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { ComponentProps, ComponentState, 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' | 'aria-label' | 'aria-labelledby' | 'onBlur' | 'onFocus' | 'onPointerEnter' | 'onPointerLeave'\n>;\n\n/**\n * Data for the Tooltip's onVisibleChange event.\n */\nexport type OnVisibleChangeData = {\n visible: boolean;\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 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\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?: React.ReactElement | 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"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './Tooltip';\nexport * from './Tooltip.types';\nexport * from './renderTooltip';\nexport * from './useTooltip';\nexport * from './useTooltipStyles.styles';\n"],"names":[],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,kBAAkB;AAChC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,4BAA4B"}
|
@@ -1,12 +1,10 @@
|
|
1
1
|
/**
|
2
2
|
* The height of the tooltip's arrow in pixels.
|
3
|
-
*/export const arrowHeight = 6;
|
3
|
+
*/ export const arrowHeight = 6;
|
4
4
|
/**
|
5
5
|
* The default value of the tooltip's border radius (borderRadiusMedium).
|
6
6
|
*
|
7
7
|
* Unfortunately, Popper requires it to be specified as a variable instead of using CSS.
|
8
8
|
* While we could use getComputedStyle, that adds a performance penalty for something that
|
9
9
|
* will likely never change.
|
10
|
-
*/
|
11
|
-
export const tooltipBorderRadius = 4;
|
12
|
-
//# sourceMappingURL=constants.js.map
|
10
|
+
*/ export const tooltipBorderRadius = 4;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["constants.ts"],"sourcesContent":["/**\n * The height of the tooltip's arrow in pixels.\n */\nexport const arrowHeight = 6;\n\n/**\n * The default value of the tooltip's border radius (borderRadiusMedium).\n *\n * Unfortunately, Popper requires it to be specified as a variable instead of using CSS.\n * While we could use getComputedStyle, that adds a performance penalty for something that\n * will likely never change.\n */\nexport const tooltipBorderRadius = 4;\n"],"names":["arrowHeight","tooltipBorderRadius"],"mappings":"AAAA;;CAEC,GACD,OAAO,MAAMA,cAAc,EAAE;AAE7B;;;;;;CAMC,GACD,OAAO,MAAMC,sBAAsB,EAAE"}
|
@@ -1,20 +1,15 @@
|
|
1
|
-
/** @jsxRuntime classic */ /** @jsxFrag React.Fragment */ /** @jsx createElement */import * as React from 'react';
|
1
|
+
/** @jsxRuntime classic */ /** @jsxFrag React.Fragment */ /** @jsx createElement */ import * as React from 'react';
|
2
2
|
import { Portal } from '@fluentui/react-portal';
|
3
3
|
import { createElement } from '@fluentui/react-jsx-runtime';
|
4
4
|
import { getSlotsNext } from '@fluentui/react-utilities';
|
5
5
|
/**
|
6
6
|
* Render the final JSX of Tooltip
|
7
|
-
*/
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
slotProps
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
}, /*#__PURE__*/createElement(slots.content, slotProps.content, state.withArrow && /*#__PURE__*/createElement("div", {
|
16
|
-
ref: state.arrowRef,
|
17
|
-
className: state.arrowClassName
|
18
|
-
}), state.content.children)));
|
7
|
+
*/ export const renderTooltip_unstable = (state)=>{
|
8
|
+
const { slots , slotProps } = getSlotsNext(state);
|
9
|
+
return /*#__PURE__*/ createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/ createElement(Portal, {
|
10
|
+
mountNode: state.mountNode
|
11
|
+
}, /*#__PURE__*/ createElement(slots.content, slotProps.content, state.withArrow && /*#__PURE__*/ createElement("div", {
|
12
|
+
ref: state.arrowRef,
|
13
|
+
className: state.arrowClassName
|
14
|
+
}), state.content.children)));
|
19
15
|
};
|
20
|
-
//# sourceMappingURL=renderTooltip.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["renderTooltip.tsx"],"sourcesContent":["/** @jsxRuntime classic */\n/** @jsxFrag React.Fragment */\n/** @jsx createElement */\n\nimport * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\n\nimport { createElement } from '@fluentui/react-jsx-runtime';\n\nimport { getSlotsNext } from '@fluentui/react-utilities';\nimport type { TooltipSlots, TooltipState } from './Tooltip.types';\n\n/**\n * Render the final JSX of Tooltip\n */\nexport const renderTooltip_unstable = (state: TooltipState) => {\n const { slots, slotProps } = getSlotsNext<TooltipSlots>(state);\n\n return (\n <>\n {state.children}\n {state.shouldRenderTooltip && (\n <Portal mountNode={state.mountNode}>\n <slots.content {...slotProps.content}>\n {state.withArrow && <div ref={state.arrowRef} className={state.arrowClassName} />}\n {state.content.children}\n </slots.content>\n </Portal>\n )}\n </>\n );\n};\n"],"names":["React","Portal","createElement","getSlotsNext","renderTooltip_unstable","state","slots","slotProps","children","shouldRenderTooltip","mountNode","content","withArrow","div","ref","arrowRef","className","arrowClassName"],"mappings":"AAAA,wBAAwB,GACxB,4BAA4B,GAC5B,uBAAuB,GAEvB,YAAYA,WAAW,QAAQ;AAC/B,SAASC,MAAM,QAAQ,yBAAyB;AAEhD,SAASC,aAAa,QAAQ,8BAA8B;AAE5D,SAASC,YAAY,QAAQ,4BAA4B;AAGzD;;CAEC,GACD,OAAO,MAAMC,yBAAyB,CAACC,QAAwB;IAC7D,MAAM,EAAEC,MAAK,EAAEC,UAAS,EAAE,GAAGJ,aAA2BE;IAExD,qBACE,AAjBJ,cADA,cAA8B,QAmBvBA,MAAMG,QAAQ,EACdH,MAAMI,mBAAmB,kBACxB,AApBR,cAoBSR;QAAOS,WAAWL,MAAMK,SAAS;qBAChC,AArBV,cAqBWJ,MAAMK,OAAO,EAAKJ,UAAUI,OAAO,EACjCN,MAAMO,SAAS,kBAAI,AAtBhC,cAsBiCC;QAAIC,KAAKT,MAAMU,QAAQ;QAAEC,WAAWX,MAAMY,cAAc;QAC5EZ,MAAMM,OAAO,CAACH,QAAQ;AAMnC,EAAE"}
|
@@ -11,186 +11,186 @@ import { Escape } from '@fluentui/keyboard-keys';
|
|
11
11
|
* before being passed to renderTooltip_unstable.
|
12
12
|
*
|
13
13
|
* @param props - props from this instance of Tooltip
|
14
|
-
*/
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
appearance = 'normal',
|
25
|
-
children,
|
26
|
-
content,
|
27
|
-
withArrow = false,
|
28
|
-
positioning = 'above',
|
29
|
-
onVisibleChange,
|
30
|
-
relationship,
|
31
|
-
showDelay = 250,
|
32
|
-
hideDelay = 250,
|
33
|
-
mountNode
|
34
|
-
} = props;
|
35
|
-
const [visible, setVisibleInternal] = useControllableState({
|
36
|
-
state: props.visible,
|
37
|
-
initialState: false
|
38
|
-
});
|
39
|
-
const setVisible = React.useCallback((newVisible, ev) => {
|
40
|
-
clearDelayTimeout();
|
41
|
-
setVisibleInternal(oldVisible => {
|
42
|
-
if (newVisible !== oldVisible) {
|
43
|
-
onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {
|
44
|
-
visible: newVisible
|
45
|
-
});
|
46
|
-
}
|
47
|
-
return newVisible;
|
14
|
+
*/ export const useTooltip_unstable = (props)=>{
|
15
|
+
var _child_props, _child_props1, _child_props2, _child_props3;
|
16
|
+
const context = useTooltipVisibility();
|
17
|
+
const isServerSideRender = useIsSSR();
|
18
|
+
const { targetDocument } = useFluent();
|
19
|
+
const [setDelayTimeout, clearDelayTimeout] = useTimeout();
|
20
|
+
const { appearance ='normal' , children , content , withArrow =false , positioning ='above' , onVisibleChange , relationship , showDelay =250 , hideDelay =250 , mountNode } = props;
|
21
|
+
const [visible, setVisibleInternal] = useControllableState({
|
22
|
+
state: props.visible,
|
23
|
+
initialState: false
|
48
24
|
});
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
appearance,
|
59
|
-
mountNode,
|
60
|
-
// Slots
|
61
|
-
components: {
|
62
|
-
content: 'div'
|
63
|
-
},
|
64
|
-
content: resolveShorthand(content, {
|
65
|
-
defaultProps: {
|
66
|
-
role: 'tooltip'
|
67
|
-
},
|
68
|
-
required: true
|
69
|
-
})
|
70
|
-
};
|
71
|
-
state.content.id = useId('tooltip-', state.content.id);
|
72
|
-
const positioningOptions = {
|
73
|
-
enabled: state.visible,
|
74
|
-
arrowPadding: 2 * tooltipBorderRadius,
|
75
|
-
position: 'above',
|
76
|
-
align: 'center',
|
77
|
-
offset: 4,
|
78
|
-
...resolvePositioningShorthand(state.positioning)
|
79
|
-
};
|
80
|
-
if (state.withArrow) {
|
81
|
-
positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);
|
82
|
-
}
|
83
|
-
const {
|
84
|
-
targetRef,
|
85
|
-
containerRef,
|
86
|
-
arrowRef
|
87
|
-
} = usePositioning(positioningOptions);
|
88
|
-
state.content.ref = useMergedRefs(state.content.ref, containerRef);
|
89
|
-
state.arrowRef = arrowRef;
|
90
|
-
// When this tooltip is visible, hide any other tooltips, and register it
|
91
|
-
// as the visibleTooltip with the TooltipContext.
|
92
|
-
// Also add a listener on document to hide the tooltip if Escape is pressed
|
93
|
-
useIsomorphicLayoutEffect(() => {
|
94
|
-
if (visible) {
|
95
|
-
var _context_visibleTooltip;
|
96
|
-
const thisTooltip = {
|
97
|
-
hide: () => setVisible(false)
|
98
|
-
};
|
99
|
-
(_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();
|
100
|
-
context.visibleTooltip = thisTooltip;
|
101
|
-
const onDocumentKeyDown = ev => {
|
102
|
-
if (ev.key === Escape) {
|
103
|
-
thisTooltip.hide();
|
104
|
-
// stop propagation to avoid conflicting with other elements that listen for `Escape`
|
105
|
-
// e,g: Dialog, Popover, Menu
|
106
|
-
ev.stopPropagation();
|
107
|
-
}
|
108
|
-
};
|
109
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {
|
110
|
-
// As this event is added at targeted document,
|
111
|
-
// we need to capture the event to be sure keydown handling from tooltip happens first
|
112
|
-
capture: true
|
113
|
-
});
|
114
|
-
return () => {
|
115
|
-
if (context.visibleTooltip === thisTooltip) {
|
116
|
-
context.visibleTooltip = undefined;
|
117
|
-
}
|
118
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
|
119
|
-
capture: true
|
25
|
+
const setVisible = React.useCallback((newVisible, ev)=>{
|
26
|
+
clearDelayTimeout();
|
27
|
+
setVisibleInternal((oldVisible)=>{
|
28
|
+
if (newVisible !== oldVisible) {
|
29
|
+
onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {
|
30
|
+
visible: newVisible
|
31
|
+
});
|
32
|
+
}
|
33
|
+
return newVisible;
|
120
34
|
});
|
121
|
-
|
35
|
+
}, [
|
36
|
+
clearDelayTimeout,
|
37
|
+
setVisibleInternal,
|
38
|
+
onVisibleChange
|
39
|
+
]);
|
40
|
+
const state = {
|
41
|
+
withArrow,
|
42
|
+
positioning,
|
43
|
+
showDelay,
|
44
|
+
hideDelay,
|
45
|
+
relationship,
|
46
|
+
visible,
|
47
|
+
shouldRenderTooltip: visible,
|
48
|
+
appearance,
|
49
|
+
mountNode,
|
50
|
+
// Slots
|
51
|
+
components: {
|
52
|
+
content: 'div'
|
53
|
+
},
|
54
|
+
content: resolveShorthand(content, {
|
55
|
+
defaultProps: {
|
56
|
+
role: 'tooltip'
|
57
|
+
},
|
58
|
+
required: true
|
59
|
+
})
|
60
|
+
};
|
61
|
+
state.content.id = useId('tooltip-', state.content.id);
|
62
|
+
const positioningOptions = {
|
63
|
+
enabled: state.visible,
|
64
|
+
arrowPadding: 2 * tooltipBorderRadius,
|
65
|
+
position: 'above',
|
66
|
+
align: 'center',
|
67
|
+
offset: 4,
|
68
|
+
...resolvePositioningShorthand(state.positioning)
|
69
|
+
};
|
70
|
+
if (state.withArrow) {
|
71
|
+
positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);
|
122
72
|
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
73
|
+
const { targetRef , containerRef , arrowRef } = usePositioning(positioningOptions);
|
74
|
+
state.content.ref = useMergedRefs(state.content.ref, containerRef);
|
75
|
+
state.arrowRef = arrowRef;
|
76
|
+
// When this tooltip is visible, hide any other tooltips, and register it
|
77
|
+
// as the visibleTooltip with the TooltipContext.
|
78
|
+
// Also add a listener on document to hide the tooltip if Escape is pressed
|
79
|
+
useIsomorphicLayoutEffect(()=>{
|
80
|
+
if (visible) {
|
81
|
+
var _context_visibleTooltip;
|
82
|
+
const thisTooltip = {
|
83
|
+
hide: ()=>setVisible(false)
|
84
|
+
};
|
85
|
+
(_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();
|
86
|
+
context.visibleTooltip = thisTooltip;
|
87
|
+
const onDocumentKeyDown = (ev)=>{
|
88
|
+
if (ev.key === Escape) {
|
89
|
+
thisTooltip.hide();
|
90
|
+
// stop propagation to avoid conflicting with other elements that listen for `Escape`
|
91
|
+
// e,g: Dialog, Popover, Menu
|
92
|
+
ev.stopPropagation();
|
93
|
+
}
|
94
|
+
};
|
95
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {
|
96
|
+
// As this event is added at targeted document,
|
97
|
+
// we need to capture the event to be sure keydown handling from tooltip happens first
|
98
|
+
capture: true
|
99
|
+
});
|
100
|
+
return ()=>{
|
101
|
+
if (context.visibleTooltip === thisTooltip) {
|
102
|
+
context.visibleTooltip = undefined;
|
103
|
+
}
|
104
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
|
105
|
+
capture: true
|
106
|
+
});
|
107
|
+
};
|
108
|
+
}
|
109
|
+
}, [
|
110
|
+
context,
|
111
|
+
targetDocument,
|
112
|
+
visible,
|
113
|
+
setVisible
|
114
|
+
]);
|
115
|
+
// The focused element gets a blur event when the document loses focus
|
116
|
+
// (e.g. switching tabs in the browser), but we don't want to show the
|
117
|
+
// tooltip again when the document gets focus back. Handle this case by
|
118
|
+
// checking if the blurred element is still the document's activeElement.
|
119
|
+
// See https://github.com/microsoft/fluentui/issues/13541
|
120
|
+
const ignoreNextFocusEventRef = React.useRef(false);
|
121
|
+
// Listener for onPointerEnter and onFocus on the trigger element
|
122
|
+
const onEnterTrigger = React.useCallback((ev)=>{
|
123
|
+
if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {
|
124
|
+
ignoreNextFocusEventRef.current = false;
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
// Show immediately if another tooltip is already visible
|
128
|
+
const delay = context.visibleTooltip ? 0 : state.showDelay;
|
129
|
+
setDelayTimeout(()=>{
|
130
|
+
setVisible(true, ev);
|
131
|
+
}, delay);
|
132
|
+
ev.persist(); // Persist the event since the setVisible call will happen asynchronously
|
133
|
+
}, [
|
134
|
+
setDelayTimeout,
|
135
|
+
setVisible,
|
136
|
+
state.showDelay,
|
137
|
+
context
|
138
|
+
]);
|
139
|
+
// Listener for onPointerLeave and onBlur on the trigger element
|
140
|
+
const onLeaveTrigger = React.useCallback((ev)=>{
|
141
|
+
let delay = state.hideDelay;
|
142
|
+
if (ev.type === 'blur') {
|
143
|
+
// Hide immediately when losing focus
|
144
|
+
delay = 0;
|
145
|
+
ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;
|
146
|
+
}
|
147
|
+
setDelayTimeout(()=>{
|
148
|
+
setVisible(false, ev);
|
149
|
+
}, delay);
|
150
|
+
ev.persist(); // Persist the event since the setVisible call will happen asynchronously
|
151
|
+
}, [
|
152
|
+
setDelayTimeout,
|
153
|
+
setVisible,
|
154
|
+
state.hideDelay,
|
155
|
+
targetDocument
|
156
|
+
]);
|
157
|
+
// Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.
|
158
|
+
// This keeps the tooltip visible when the mouse is moved over it, or it has focus within.
|
159
|
+
state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);
|
160
|
+
state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);
|
161
|
+
state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);
|
162
|
+
state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);
|
163
|
+
const child = getTriggerChild(children);
|
164
|
+
const triggerAriaProps = {};
|
165
|
+
if (relationship === 'label') {
|
166
|
+
// aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
|
167
|
+
if (typeof state.content.children === 'string') {
|
168
|
+
triggerAriaProps['aria-label'] = state.content.children;
|
169
|
+
} else {
|
170
|
+
triggerAriaProps['aria-labelledby'] = state.content.id;
|
171
|
+
// Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
|
172
|
+
state.shouldRenderTooltip = true;
|
173
|
+
}
|
174
|
+
} else if (relationship === 'description') {
|
175
|
+
triggerAriaProps['aria-describedby'] = state.content.id;
|
176
|
+
// Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
|
177
|
+
state.shouldRenderTooltip = true;
|
150
178
|
}
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
ev.persist(); // Persist the event since the setVisible call will happen asynchronously
|
155
|
-
}, [setDelayTimeout, setVisible, state.hideDelay, targetDocument]);
|
156
|
-
// Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.
|
157
|
-
// This keeps the tooltip visible when the mouse is moved over it, or it has focus within.
|
158
|
-
state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);
|
159
|
-
state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);
|
160
|
-
state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);
|
161
|
-
state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);
|
162
|
-
const child = getTriggerChild(children);
|
163
|
-
const triggerAriaProps = {};
|
164
|
-
if (relationship === 'label') {
|
165
|
-
// aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
|
166
|
-
if (typeof state.content.children === 'string') {
|
167
|
-
triggerAriaProps['aria-label'] = state.content.children;
|
168
|
-
} else {
|
169
|
-
triggerAriaProps['aria-labelledby'] = state.content.id;
|
170
|
-
// Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
|
171
|
-
state.shouldRenderTooltip = true;
|
179
|
+
// Don't render the Tooltip in SSR to avoid hydration errors
|
180
|
+
if (isServerSideRender) {
|
181
|
+
state.shouldRenderTooltip = false;
|
172
182
|
}
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
...(child === null || child === void 0 ? void 0 : child.props),
|
187
|
-
// If the target prop is not provided, attach targetRef to the trigger element's ref prop
|
188
|
-
ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
|
189
|
-
onPointerEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),
|
190
|
-
onPointerLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),
|
191
|
-
onFocus: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),
|
192
|
-
onBlur: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))
|
193
|
-
});
|
194
|
-
return state;
|
183
|
+
const childTargetRef = useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);
|
184
|
+
// Apply the trigger props to the child, either by calling the render function, or cloning with the new props
|
185
|
+
state.children = applyTriggerPropsToChildren(children, {
|
186
|
+
...triggerAriaProps,
|
187
|
+
...child === null || child === void 0 ? void 0 : child.props,
|
188
|
+
// If the target prop is not provided, attach targetRef to the trigger element's ref prop
|
189
|
+
ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
|
190
|
+
onPointerEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),
|
191
|
+
onPointerLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),
|
192
|
+
onFocus: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),
|
193
|
+
onBlur: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))
|
194
|
+
});
|
195
|
+
return state;
|
195
196
|
};
|
196
|
-
//# sourceMappingURL=useTooltip.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","applyTriggerPropsToChildren","resolveShorthand","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","useTimeout","getTriggerChild","mergeCallbacks","useEventCallback","arrowHeight","tooltipBorderRadius","Escape","useTooltip_unstable","props","_child_props","_child_props1","_child_props2","_child_props3","context","isServerSideRender","targetDocument","setDelayTimeout","clearDelayTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","state","initialState","setVisible","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","defaultProps","role","required","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","ref","_context_visibleTooltip","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","child","triggerAriaProps","childTargetRef"],"sources":["../../../src/components/Tooltip/useTooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport {\n useTooltipVisibility_unstable as useTooltipVisibility,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport {\n applyTriggerPropsToChildren,\n resolveShorthand,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n useTimeout,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport type { TooltipProps, TooltipState, TooltipChildProps } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { Escape } from '@fluentui/keyboard-keys';\n\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */\nexport const useTooltip_unstable = (props: TooltipProps): TooltipState => {\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n\n const {\n appearance = 'normal',\n children,\n content,\n withArrow = false,\n positioning = 'above',\n onVisibleChange,\n relationship,\n showDelay = 250,\n hideDelay = 250,\n mountNode,\n } = props;\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n const setVisible = React.useCallback(\n (newVisible: boolean, ev?: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (newVisible !== oldVisible) {\n onVisibleChange?.(ev, { visible: newVisible });\n }\n return newVisible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\n\n const state: TooltipState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: 'tooltip',\n },\n required: true,\n }),\n };\n\n state.content.id = useId('tooltip-', state.content.id);\n\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above' as const,\n align: 'center' as const,\n offset: 4,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n\n const {\n targetRef,\n containerRef,\n arrowRef,\n }: {\n targetRef: React.MutableRefObject<unknown>;\n containerRef: React.MutableRefObject<HTMLDivElement>;\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(() => {\n if (visible) {\n const thisTooltip = { hide: () => setVisible(false) };\n\n context.visibleTooltip?.hide();\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n\n targetDocument?.addEventListener('keydown', onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true,\n });\n\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n\n targetDocument?.removeEventListener('keydown', onDocumentKeyDown, { capture: true });\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n\n setDelayTimeout(() => {\n setVisible(true, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.showDelay, context],\n );\n\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n let delay = state.hideDelay;\n\n if (ev.type === 'blur') {\n // Hide immediately when losing focus\n delay = 0;\n\n ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(false, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.hideDelay, targetDocument],\n );\n\n // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.\n // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);\n\n const child = getTriggerChild(children);\n\n const triggerAriaProps: Pick<TooltipChildProps, 'aria-label' | 'aria-labelledby' | 'aria-describedby'> = {};\n\n if (relationship === 'label') {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === 'string') {\n triggerAriaProps['aria-label'] = state.content.children;\n } else {\n triggerAriaProps['aria-labelledby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === 'description') {\n triggerAriaProps['aria-describedby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n\n const childTargetRef = useMergedRefs(child?.ref, targetRef);\n\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child?.props,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child?.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child?.props?.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child?.props?.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child?.props?.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child?.props?.onBlur, onLeaveTrigger)),\n });\n\n return state;\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,EAAEC,2BAA2B,EAAEC,cAAc,QAAQ;AAC9E,SACEC,6BAAA,IAAiCC,oBAAoB,EACrDC,kBAAA,IAAsBC,SAAS,QAC1B;AACP,SACEC,2BAA2B,EAC3BC,gBAAgB,EAChBC,oBAAoB,EACpBC,KAAK,EACLC,yBAAyB,EACzBC,QAAQ,EACRC,aAAa,EACbC,UAAU,EACVC,eAAe,EACfC,cAAc,EACdC,gBAAgB,QACX;AAEP,SAASC,WAAW,EAAEC,mBAAmB,QAAQ;AACjD,SAASC,MAAM,QAAQ;AAEvB;;;;;;;;AAQA,OAAO,MAAMC,mBAAA,GAAuBC,KAAA,IAAsC;MA6MtBC,YAAA,EACAC,aAAA,EACPC,aAAA,EACDC,aAAA;EA/M1C,MAAMC,OAAA,GAAUvB,oBAAA;EAChB,MAAMwB,kBAAA,GAAqBhB,QAAA;EAC3B,MAAM;IAAEiB;EAAc,CAAE,GAAGvB,SAAA;EAC3B,MAAM,CAACwB,eAAA,EAAiBC,iBAAA,CAAkB,GAAGjB,UAAA;EAE7C,MAAM;IACJkB,UAAA,GAAa;IACbC,QAAA;IACAC,OAAA;IACAC,SAAA,GAAY,KAAK;IACjBC,WAAA,GAAc;IACdC,eAAA;IACAC,YAAA;IACAC,SAAA,GAAY;IACZC,SAAA,GAAY;IACZC;EAAS,CACV,GAAG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E,KAAK;IACf;IACA4C,GAAA,EAAKT,kBAAA,CAAmB8B,MAAM,KAAKX,SAAA,GAAYkB,cAAA,GAAiBF,KAAA,aAAAA,KAAA,uBAAAA,KAAA,CAAO1B,GAAG;IAC1EsB,cAAA,EAAgBvE,gBAAA,CAAiBD,cAAA,CAAe4E,KAAA,aAAAA,KAAA,wBAAArE,YAAA,GAAAqE,KAAA,CAAOtE,KAAK,cAAZC,YAAA,uBAAAA,YAAA,CAAciE,cAAF,EAAkBR,cAAA;IAC9ES,cAAA,EAAgBxE,gBAAA,CAAiBD,cAAA,CAAe4E,KAAA,aAAAA,KAAA,wBAAApE,aAAA,GAAAoE,KAAA,CAAOtE,KAAK,cAAZE,aAAA,uBAAAA,aAAA,CAAciE,cAAF,EAAkBJ,cAAA;IAC9EK,OAAA,EAASzE,gBAAA,CAAiBD,cAAA,CAAe4E,KAAA,aAAAA,KAAA,wBAAAnE,aAAA,GAAAmE,KAAA,CAAOtE,KAAK,cAAZG,aAAA,uBAAAA,aAAA,CAAciE,OAAF,EAAWV,cAAA;IAChEW,MAAA,EAAQ1E,gBAAA,CAAiBD,cAAA,CAAe4E,KAAA,aAAAA,KAAA,wBAAAlE,aAAA,GAAAkE,KAAA,CAAOtE,KAAK,cAAZI,aAAA,uBAAAA,aAAA,CAAciE,MAAF,EAAUN,cAAA;EAChE;EAEA,OAAOzC,KAAA;AACT"}
|
1
|
+
{"version":3,"sources":["useTooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport {\n useTooltipVisibility_unstable as useTooltipVisibility,\n useFluent_unstable as useFluent,\n} from '@fluentui/react-shared-contexts';\nimport {\n applyTriggerPropsToChildren,\n resolveShorthand,\n useControllableState,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n useTimeout,\n getTriggerChild,\n mergeCallbacks,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport type { TooltipProps, TooltipState, TooltipChildProps } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { Escape } from '@fluentui/keyboard-keys';\n\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */\nexport const useTooltip_unstable = (props: TooltipProps): TooltipState => {\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n\n const {\n appearance = 'normal',\n children,\n content,\n withArrow = false,\n positioning = 'above',\n onVisibleChange,\n relationship,\n showDelay = 250,\n hideDelay = 250,\n mountNode,\n } = props;\n\n const [visible, setVisibleInternal] = useControllableState({ state: props.visible, initialState: false });\n const setVisible = React.useCallback(\n (newVisible: boolean, ev?: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (newVisible !== oldVisible) {\n onVisibleChange?.(ev, { visible: newVisible });\n }\n return newVisible;\n });\n },\n [clearDelayTimeout, setVisibleInternal, onVisibleChange],\n );\n\n const state: TooltipState = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: 'div',\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: 'tooltip',\n },\n required: true,\n }),\n };\n\n state.content.id = useId('tooltip-', state.content.id);\n\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above' as const,\n align: 'center' as const,\n offset: 4,\n ...resolvePositioningShorthand(state.positioning),\n };\n\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n\n const {\n targetRef,\n containerRef,\n arrowRef,\n }: {\n targetRef: React.MutableRefObject<unknown>;\n containerRef: React.MutableRefObject<HTMLDivElement>;\n arrowRef: React.MutableRefObject<HTMLDivElement>;\n } = usePositioning(positioningOptions);\n\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(() => {\n if (visible) {\n const thisTooltip = { hide: () => setVisible(false) };\n\n context.visibleTooltip?.hide();\n context.visibleTooltip = thisTooltip;\n\n const onDocumentKeyDown = (ev: KeyboardEvent) => {\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n\n targetDocument?.addEventListener('keydown', onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true,\n });\n\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n\n targetDocument?.removeEventListener('keydown', onDocumentKeyDown, { capture: true });\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n\n setDelayTimeout(() => {\n setVisible(true, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.showDelay, context],\n );\n\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(\n (ev: React.PointerEvent<HTMLElement> | React.FocusEvent<HTMLElement>) => {\n let delay = state.hideDelay;\n\n if (ev.type === 'blur') {\n // Hide immediately when losing focus\n delay = 0;\n\n ignoreNextFocusEventRef.current = targetDocument?.activeElement === ev.target;\n }\n\n setDelayTimeout(() => {\n setVisible(false, ev);\n }, delay);\n\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n },\n [setDelayTimeout, setVisible, state.hideDelay, targetDocument],\n );\n\n // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.\n // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);\n\n const child = getTriggerChild(children);\n\n const triggerAriaProps: Pick<TooltipChildProps, 'aria-label' | 'aria-labelledby' | 'aria-describedby'> = {};\n\n if (relationship === 'label') {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === 'string') {\n triggerAriaProps['aria-label'] = state.content.children;\n } else {\n triggerAriaProps['aria-labelledby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === 'description') {\n triggerAriaProps['aria-describedby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n\n const childTargetRef = useMergedRefs(child?.ref, targetRef);\n\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child?.props,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child?.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child?.props?.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child?.props?.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child?.props?.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child?.props?.onBlur, onLeaveTrigger)),\n });\n\n return state;\n};\n"],"names":["React","mergeArrowOffset","resolvePositioningShorthand","usePositioning","useTooltipVisibility_unstable","useTooltipVisibility","useFluent_unstable","useFluent","applyTriggerPropsToChildren","resolveShorthand","useControllableState","useId","useIsomorphicLayoutEffect","useIsSSR","useMergedRefs","useTimeout","getTriggerChild","mergeCallbacks","useEventCallback","arrowHeight","tooltipBorderRadius","Escape","useTooltip_unstable","props","child","context","isServerSideRender","targetDocument","setDelayTimeout","clearDelayTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","state","initialState","setVisible","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","defaultProps","role","required","id","positioningOptions","enabled","arrowPadding","position","align","offset","targetRef","containerRef","arrowRef","ref","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","triggerAriaProps","childTargetRef"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AAC5G,SACEC,iCAAiCC,oBAAoB,EACrDC,sBAAsBC,SAAS,QAC1B,kCAAkC;AACzC,SACEC,2BAA2B,EAC3BC,gBAAgB,EAChBC,oBAAoB,EACp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,mBAAmB6B,MAAM,KAAKX,YAAYiB,iBAAiBlE,kBAAAA,mBAAAA,KAAAA,IAAAA,MAAOwC,GAAG;QAC1EqB,gBAAgBnE,iBAAiBD,eAAeO,kBAAAA,mBAAAA,KAAAA,IAAAA,CAAAA,eAAAA,MAAOD,KAAK,cAAZC,0BAAAA,KAAAA,IAAAA,aAAc6D,cAAF,EAAkBR;QAC9ES,gBAAgBpE,iBAAiBD,eAAeO,kBAAAA,mBAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAK,cAAZC,2BAAAA,KAAAA,IAAAA,cAAc8D,cAAF,EAAkBJ;QAC9EK,SAASrE,iBAAiBD,eAAeO,kBAAAA,mBAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAK,cAAZC,2BAAAA,KAAAA,IAAAA,cAAc+D,OAAF,EAAWV;QAChEW,QAAQtE,iBAAiBD,eAAeO,kBAAAA,mBAAAA,KAAAA,IAAAA,CAAAA,gBAAAA,MAAOD,KAAK,cAAZC,2BAAAA,KAAAA,IAAAA,cAAcgE,MAAF,EAAUN;IAChE;IAEA,OAAOxC;AACT,EAAE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["shorthands","__styles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Bbmb7ep","Beyfa6y","B7oj6ja","Btl43ni","B4j52fo","Bekrc4i","Bn0qgzm","ibv6hh","icvyot","vrafjx","oivjwe","wvpqe5","g2u3we","h3c5rm","B9xav0g","zhjwy3","z8tnut","z189sj","Byoj8tv","uwmqm3","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bcdw1i0","Bj3rh1h","a9b677","Bqenvij","Ftih45","B1puzpu","Brfgrao","Bcvre1j","Ccq8qp","Baz25je","cmx5o7","B4f6apu","m598lv","Bk5zm6e","y0oebl","qa3bma","Bqjgrrk","Budzafs","Hv9wc6","hl6cv3","Bh2vraf","yayu3t","wedwtw","rhl9o9","Bu8t5uz","B6q6orb","Bwwlvwl","d","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"sources":["
|
1
|
+
{"version":3,"names":["shorthands","__styles","mergeClasses","createArrowStyles","tokens","arrowHeight","tooltipClassNames","content","useStyles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Bbmb7ep","Beyfa6y","B7oj6ja","Btl43ni","B4j52fo","Bekrc4i","Bn0qgzm","ibv6hh","icvyot","vrafjx","oivjwe","wvpqe5","g2u3we","h3c5rm","B9xav0g","zhjwy3","z8tnut","z189sj","Byoj8tv","uwmqm3","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bcdw1i0","Bj3rh1h","a9b677","Bqenvij","Ftih45","B1puzpu","Brfgrao","Bcvre1j","Ccq8qp","Baz25je","cmx5o7","B4f6apu","m598lv","Bk5zm6e","y0oebl","qa3bma","Bqjgrrk","Budzafs","Hv9wc6","hl6cv3","Bh2vraf","yayu3t","wedwtw","rhl9o9","Bu8t5uz","B6q6orb","Bwwlvwl","d","useTooltipStyles_unstable","state","styles","className","appearance","arrowClassName"],"sources":["useTooltipStyles.styles.js"],"sourcesContent":["import { shorthands, 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 ...shorthands.borderRadius(tokens.borderRadiusMedium),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n ...shorthands.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 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,SAASA,UAAU,EAAAC,QAAA,EAAcC,YAAY,QAAQ,gBAAgB;AACrE,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,OAAA;IAAAC,OAAA;IAAAC,MAAA;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,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAC,OAAA;IAAA9B,MAAA;EAAA;EAAA+B,QAAA;IAAAJ,MAAA;IAAAC,MAAA;EAAA;EAAAI,KAAA;IAAAC,MAAA;IAAAN,MAAA;IAAAO,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,CA2BrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,yBAAyB,GAAIC,KAAK,IAAG;EAClD,MAAMC,MAAM,GAAGlE,SAAS,CAAC,CAAC;EAC1BiE,KAAK,CAAClE,OAAO,CAACoE,SAAS,GAAGzE,YAAY,CAACI,iBAAiB,CAACC,OAAO,EAAEmE,MAAM,CAACjE,IAAI,EAAEgE,KAAK,CAACG,UAAU,KAAK,UAAU,IAAIF,MAAM,CAACjC,QAAQ,EAAEgC,KAAK,CAACjC,OAAO,IAAIkC,MAAM,CAAClC,OAAO,EAAEiC,KAAK,CAAClE,OAAO,CAACoE,SAAS,CAAC;EAC5LF,KAAK,CAACI,cAAc,GAAGH,MAAM,CAAChC,KAAK;EACnC,OAAO+B,KAAK;AAChB,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n Tooltip,\n renderTooltip_unstable,\n tooltipClassNames,\n useTooltipStyles_unstable,\n useTooltip_unstable,\n} from './Tooltip';\nexport type {\n OnVisibleChangeData,\n TooltipProps,\n TooltipSlots,\n TooltipState,\n TooltipChildProps as TooltipTriggerProps,\n} from './Tooltip';\n"],"names":["Tooltip","renderTooltip_unstable","tooltipClassNames","useTooltipStyles_unstable","useTooltip_unstable"],"mappings":"AAAA,SACEA,OAAO,EACPC,sBAAsB,EACtBC,iBAAiB,EACjBC,yBAAyB,EACzBC,mBAAmB,QACd,YAAY"}
|
package/lib-commonjs/Tooltip.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["Tooltip.js"],"sourcesContent":["export * from './components/Tooltip/index';\n"],"names":[],"mappings":";;;;;oBAAc"}
|
@@ -20,6 +20,4 @@ const Tooltip = (props)=>{
|
|
20
20
|
};
|
21
21
|
Tooltip.displayName = 'Tooltip';
|
22
22
|
// type casting here is required to ensure internal type FluentTriggerComponent is not leaked
|
23
|
-
Tooltip.isFluentTriggerComponent = true;
|
24
|
-
|
25
|
-
//# sourceMappingURL=Tooltip.js.map
|
23
|
+
Tooltip.isFluentTriggerComponent = true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["Tooltip.js"],"sourcesContent":["import * 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';\n/**\n * A tooltip provides light weight contextual information on top of its target element.\n */ export const Tooltip = (props)=>{\n const state = useTooltip_unstable(props);\n useTooltipStyles_unstable(state);\n useCustomStyleHook_unstable('useTooltipStyles_unstable')(state);\n return renderTooltip_unstable(state);\n};\nTooltip.displayName = 'Tooltip';\n// type casting here is required to ensure internal type FluentTriggerComponent is not leaked\nTooltip.isFluentTriggerComponent = true;\n"],"names":["Tooltip","props","state","useTooltip_unstable","useTooltipStyles_unstable","useCustomStyleHook_unstable","renderTooltip_unstable","displayName","isFluentTriggerComponent"],"mappings":";;;;+BAOiBA;;aAAAA;;;6DAPM;4BACa;+BACG;qCACK;wCACF;AAG/B,MAAMA,UAAU,CAACC,QAAQ;IAChC,MAAMC,QAAQC,IAAAA,+BAAmB,EAACF;IAClCG,IAAAA,iDAAyB,EAACF;IAC1BG,IAAAA,gDAA2B,EAAC,6BAA6BH;IACzD,OAAOI,IAAAA,qCAAsB,EAACJ;AAClC;AACAF,QAAQO,WAAW,GAAG;AACtB,6FAA6F;AAC7FP,QAAQQ,wBAAwB,GAAG,IAAI"}
|
@@ -4,6 +4,3 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
});
|
5
5
|
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
6
6
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
7
|
-
//# sourceMappingURL=Tooltip.types.js.map
|
8
|
-
|
9
|
-
//# sourceMappingURL=Tooltip.types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["Tooltip.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
|
@@ -8,6 +8,3 @@ _exportStar(require("./Tooltip.types"), exports);
|
|
8
8
|
_exportStar(require("./renderTooltip"), exports);
|
9
9
|
_exportStar(require("./useTooltip"), exports);
|
10
10
|
_exportStar(require("./useTooltipStyles.styles"), exports);
|
11
|
-
//# sourceMappingURL=index.js.map
|
12
|
-
|
13
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './Tooltip';\nexport * from './Tooltip.types';\nexport * from './renderTooltip';\nexport * from './useTooltip';\nexport * from './useTooltipStyles.styles';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["constants.js"],"sourcesContent":["/**\n * The height of the tooltip's arrow in pixels.\n */ export const arrowHeight = 6;\n/**\n * The default value of the tooltip's border radius (borderRadiusMedium).\n *\n * Unfortunately, Popper requires it to be specified as a variable instead of using CSS.\n * While we could use getComputedStyle, that adds a performance penalty for something that\n * will likely never change.\n */ export const tooltipBorderRadius = 4;\n"],"names":["arrowHeight","tooltipBorderRadius"],"mappings":"AAAA;;CAEC;;;;;;;;;;;IAAgBA,WAAW,MAAXA;IAOAC,mBAAmB,MAAnBA;;AAPN,MAAMD,cAAc;AAOpB,MAAMC,sBAAsB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["renderTooltip.js"],"sourcesContent":["/** @jsxRuntime classic */ /** @jsxFrag React.Fragment */ /** @jsx createElement */ import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { createElement } from '@fluentui/react-jsx-runtime';\nimport { getSlotsNext } from '@fluentui/react-utilities';\n/**\n * Render the final JSX of Tooltip\n */ export const renderTooltip_unstable = (state)=>{\n const { slots , slotProps } = getSlotsNext(state);\n return /*#__PURE__*/ createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/ createElement(Portal, {\n mountNode: state.mountNode\n }, /*#__PURE__*/ createElement(slots.content, slotProps.content, state.withArrow && /*#__PURE__*/ createElement(\"div\", {\n ref: state.arrowRef,\n className: state.arrowClassName\n }), state.content.children)));\n};\n"],"names":["renderTooltip_unstable","state","slots","slotProps","getSlotsNext","createElement","React","Fragment","children","shouldRenderTooltip","Portal","mountNode","content","withArrow","ref","arrowRef","className","arrowClassName"],"mappings":"AAAA,wBAAwB,GAAG,4BAA4B,GAAG,uBAAuB;;;;+BAMhEA;;aAAAA;;;6DAN0F;6BACpF;iCACO;gCACD;AAGlB,MAAMA,yBAAyB,CAACC,QAAQ;IAC/C,MAAM,EAAEC,MAAK,EAAGC,UAAS,EAAG,GAAGC,IAAAA,4BAAY,EAACH;IAC5C,OAAO,WAAW,GAAGI,IAAAA,8BAAa,EAACC,OAAMC,QAAQ,EAAE,IAAI,EAAEN,MAAMO,QAAQ,EAAEP,MAAMQ,mBAAmB,IAAI,WAAW,GAAGJ,IAAAA,8BAAa,EAACK,mBAAM,EAAE;QACtIC,WAAWV,MAAMU,SAAS;IAC9B,GAAG,WAAW,GAAGN,IAAAA,8BAAa,EAACH,MAAMU,OAAO,EAAET,UAAUS,OAAO,EAAEX,MAAMY,SAAS,IAAI,WAAW,GAAGR,IAAAA,8BAAa,EAAC,OAAO;QACnHS,KAAKb,MAAMc,QAAQ;QACnBC,WAAWf,MAAMgB,cAAc;IACnC,IAAIhB,MAAMW,OAAO,CAACJ,QAAQ;AAC9B"}
|
@@ -195,6 +195,4 @@ const useTooltip_unstable = (props)=>{
|
|
195
195
|
onBlur: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))
|
196
196
|
});
|
197
197
|
return state;
|
198
|
-
};
|
199
|
-
|
200
|
-
//# sourceMappingURL=useTooltip.js.map
|
198
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../lib/components/Tooltip/useTooltip.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useTooltipVisibility_unstable as useTooltipVisibility, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyTriggerPropsToChildren, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useIsSSR, useMergedRefs, useTimeout, getTriggerChild, mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { Escape } from '@fluentui/keyboard-keys';\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */\nexport const useTooltip_unstable = props => {\n var _child_props, _child_props1, _child_props2, _child_props3;\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const {\n targetDocument\n } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n const {\n appearance = 'normal',\n children,\n content,\n withArrow = false,\n positioning = 'above',\n onVisibleChange,\n relationship,\n showDelay = 250,\n hideDelay = 250,\n mountNode\n } = props;\n const [visible, setVisibleInternal] = useControllableState({\n state: props.visible,\n initialState: false\n });\n const setVisible = React.useCallback((newVisible, ev) => {\n clearDelayTimeout();\n setVisibleInternal(oldVisible => {\n if (newVisible !== oldVisible) {\n onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {\n visible: newVisible\n });\n }\n return newVisible;\n });\n }, [clearDelayTimeout, setVisibleInternal, onVisibleChange]);\n const state = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: 'div'\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: 'tooltip'\n },\n required: true\n })\n };\n state.content.id = useId('tooltip-', state.content.id);\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above',\n align: 'center',\n offset: 4,\n ...resolvePositioningShorthand(state.positioning)\n };\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n const {\n targetRef,\n containerRef,\n arrowRef\n } = usePositioning(positioningOptions);\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(() => {\n if (visible) {\n var _context_visibleTooltip;\n const thisTooltip = {\n hide: () => setVisible(false)\n };\n (_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();\n context.visibleTooltip = thisTooltip;\n const onDocumentKeyDown = ev => {\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true\n });\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {\n capture: true\n });\n };\n }\n }, [context, targetDocument, visible, setVisible]);\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback(ev => {\n if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n setDelayTimeout(() => {\n setVisible(true, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [setDelayTimeout, setVisible, state.showDelay, context]);\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback(ev => {\n let delay = state.hideDelay;\n if (ev.type === 'blur') {\n // Hide immediately when losing focus\n delay = 0;\n ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;\n }\n setDelayTimeout(() => {\n setVisible(false, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [setDelayTimeout, setVisible, state.hideDelay, targetDocument]);\n // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.\n // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.\n state.content.onPointerEnter = mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n state.content.onFocus = mergeCallbacks(state.content.onFocus, clearDelayTimeout);\n state.content.onBlur = mergeCallbacks(state.content.onBlur, onLeaveTrigger);\n const child = getTriggerChild(children);\n const triggerAriaProps = {};\n if (relationship === 'label') {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === 'string') {\n triggerAriaProps['aria-label'] = state.content.children;\n } else {\n triggerAriaProps['aria-labelledby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === 'description') {\n triggerAriaProps['aria-describedby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n const childTargetRef = useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...(child === null || child === void 0 ? void 0 : child.props),\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))\n });\n return state;\n};\n//# sourceMappingURL=useTooltip.js.map"],"names":["useTooltip_unstable","props","_child_props","_child_props1","_child_props2","_child_props3","context","useTooltipVisibility","isServerSideRender","useIsSSR","targetDocument","useFluent","setDelayTimeout","clearDelayTimeout","useTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","useControllableState","state","initialState","setVisible","React","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","resolveShorthand","defaultProps","role","required","id","useId","positioningOptions","enabled","arrowPadding","tooltipBorderRadius","position","align","offset","resolvePositioningShorthand","mergeArrowOffset","arrowHeight","targetRef","containerRef","arrowRef","usePositioning","ref","useMergedRefs","useIsomorphicLayoutEffect","_context_visibleTooltip","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","Escape","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","mergeCallbacks","onPointerLeave","onFocus","onBlur","child","getTriggerChild","triggerAriaProps","childTargetRef","applyTriggerPropsToChildren","useEventCallback"],"mappings":";;;;+BAcaA;;aAAAA;;;6DAdU;kCACuD;qCACyB;gCACuG;2BAC7J;8BAC1B;AAShB,MAAMA,sBAAsBC,CAAAA,QAAS;IAC1C,IAAIC,cAAcC,eAAeC,eAAeC;IAChD,MAAMC,UAAUC,IAAAA,kDAAoB;IACpC,MAAMC,qBAAqBC,IAAAA,wBAAQ;IACnC,MAAM,EACJC,eA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F,KAAK;QAC7D,yFAAyF;QACzFyD,KAAKd,mBAAmBsC,MAAM,KAAKX,YAAYoB,iBAAiBH,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAM9B,GAAG;QACvHyB,gBAAgBU,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAI,AAACtF,CAAAA,eAAesF,MAAMvF,KAAK,AAAD,MAAO,IAAI,IAAIC,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAaiF,cAAc,EAAER;QACvMU,gBAAgBQ,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAI,AAACrF,CAAAA,gBAAgBqF,MAAMvF,KAAK,AAAD,MAAO,IAAI,IAAIE,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAckF,cAAc,EAAEL;QAC1MM,SAASO,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAI,AAACpF,CAAAA,gBAAgBoF,MAAMvF,KAAK,AAAD,MAAO,IAAI,IAAIG,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAckF,OAAO,EAAEX;QAC5LY,QAAQM,IAAAA,gCAAgB,EAACT,IAAAA,8BAAc,EAACI,UAAU,IAAI,IAAIA,UAAU,KAAK,IAAI,KAAK,IAAI,AAACnF,CAAAA,gBAAgBmF,MAAMvF,KAAK,AAAD,MAAO,IAAI,IAAII,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAckF,MAAM,EAAEP;IAC5L;IACA,OAAOpD;AACT,GACA,sCAAsC"}
|
1
|
+
{"version":3,"sources":["useTooltip.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useTooltipVisibility_unstable as useTooltipVisibility, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { applyTriggerPropsToChildren, resolveShorthand, useControllableState, useId, useIsomorphicLayoutEffect, useIsSSR, useMergedRefs, useTimeout, getTriggerChild, mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\nimport { Escape } from '@fluentui/keyboard-keys';\n/**\n * Create the state required to render Tooltip.\n *\n * The returned state can be modified with hooks such as useTooltipStyles_unstable,\n * before being passed to renderTooltip_unstable.\n *\n * @param props - props from this instance of Tooltip\n */ export const useTooltip_unstable = (props)=>{\n var _child_props, _child_props1, _child_props2, _child_props3;\n const context = useTooltipVisibility();\n const isServerSideRender = useIsSSR();\n const { targetDocument } = useFluent();\n const [setDelayTimeout, clearDelayTimeout] = useTimeout();\n const { appearance ='normal' , children , content , withArrow =false , positioning ='above' , onVisibleChange , relationship , showDelay =250 , hideDelay =250 , mountNode } = props;\n const [visible, setVisibleInternal] = useControllableState({\n state: props.visible,\n initialState: false\n });\n const setVisible = React.useCallback((newVisible, ev)=>{\n clearDelayTimeout();\n setVisibleInternal((oldVisible)=>{\n if (newVisible !== oldVisible) {\n onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {\n visible: newVisible\n });\n }\n return newVisible;\n });\n }, [\n clearDelayTimeout,\n setVisibleInternal,\n onVisibleChange\n ]);\n const state = {\n withArrow,\n positioning,\n showDelay,\n hideDelay,\n relationship,\n visible,\n shouldRenderTooltip: visible,\n appearance,\n mountNode,\n // Slots\n components: {\n content: 'div'\n },\n content: resolveShorthand(content, {\n defaultProps: {\n role: 'tooltip'\n },\n required: true\n })\n };\n state.content.id = useId('tooltip-', state.content.id);\n const positioningOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above',\n align: 'center',\n offset: 4,\n ...resolvePositioningShorthand(state.positioning)\n };\n if (state.withArrow) {\n positioningOptions.offset = mergeArrowOffset(positioningOptions.offset, arrowHeight);\n }\n const { targetRef , containerRef , arrowRef } = usePositioning(positioningOptions);\n state.content.ref = useMergedRefs(state.content.ref, containerRef);\n state.arrowRef = arrowRef;\n // When this tooltip is visible, hide any other tooltips, and register it\n // as the visibleTooltip with the TooltipContext.\n // Also add a listener on document to hide the tooltip if Escape is pressed\n useIsomorphicLayoutEffect(()=>{\n if (visible) {\n var _context_visibleTooltip;\n const thisTooltip = {\n hide: ()=>setVisible(false)\n };\n (_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();\n context.visibleTooltip = thisTooltip;\n const onDocumentKeyDown = (ev)=>{\n if (ev.key === Escape) {\n thisTooltip.hide();\n // stop propagation to avoid conflicting with other elements that listen for `Escape`\n // e,g: Dialog, Popover, Menu\n ev.stopPropagation();\n }\n };\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {\n // As this event is added at targeted document,\n // we need to capture the event to be sure keydown handling from tooltip happens first\n capture: true\n });\n return ()=>{\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {\n capture: true\n });\n };\n }\n }, [\n context,\n targetDocument,\n visible,\n setVisible\n ]);\n // The focused element gets a blur event when the document loses focus\n // (e.g. switching tabs in the browser), but we don't want to show the\n // tooltip again when the document gets focus back. Handle this case by\n // checking if the blurred element is still the document's activeElement.\n // See https://github.com/microsoft/fluentui/issues/13541\n const ignoreNextFocusEventRef = React.useRef(false);\n // Listener for onPointerEnter and onFocus on the trigger element\n const onEnterTrigger = React.useCallback((ev)=>{\n if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {\n ignoreNextFocusEventRef.current = false;\n return;\n }\n // Show immediately if another tooltip is already visible\n const delay = context.visibleTooltip ? 0 : state.showDelay;\n setDelayTimeout(()=>{\n setVisible(true, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [\n setDelayTimeout,\n setVisible,\n state.showDelay,\n context\n ]);\n // Listener for onPointerLeave and onBlur on the trigger element\n const onLeaveTrigger = React.useCallback((ev)=>{\n let delay = state.hideDelay;\n if (ev.type === 'blur') {\n // Hide immediately when losing focus\n delay = 0;\n ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;\n }\n setDelayTimeout(()=>{\n setVisible(false, ev);\n }, delay);\n ev.persist(); // Persist the event since the setVisible call will happen asynchronously\n }, [\n setDelayTimeout,\n setVisible,\n state.hideDelay,\n targetDocument\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 const child = getTriggerChild(children);\n const triggerAriaProps = {};\n if (relationship === 'label') {\n // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.\n if (typeof state.content.children === 'string') {\n triggerAriaProps['aria-label'] = state.content.children;\n } else {\n triggerAriaProps['aria-labelledby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n } else if (relationship === 'description') {\n triggerAriaProps['aria-describedby'] = state.content.id;\n // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element\n state.shouldRenderTooltip = true;\n }\n // Don't render the Tooltip in SSR to avoid hydration errors\n if (isServerSideRender) {\n state.shouldRenderTooltip = false;\n }\n const childTargetRef = useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);\n // Apply the trigger props to the child, either by calling the render function, or cloning with the new props\n state.children = applyTriggerPropsToChildren(children, {\n ...triggerAriaProps,\n ...child === null || child === void 0 ? void 0 : child.props,\n // If the target prop is not provided, attach targetRef to the trigger element's ref prop\n ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,\n onPointerEnter: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),\n onPointerLeave: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),\n onFocus: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),\n onBlur: useEventCallback(mergeCallbacks(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))\n });\n return state;\n};\n"],"names":["useTooltip_unstable","props","_child_props","_child_props1","_child_props2","_child_props3","context","useTooltipVisibility","isServerSideRender","useIsSSR","targetDocument","useFluent","setDelayTimeout","clearDelayTimeout","useTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","useControllableState","state","initialState","setVisible","React","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","resolveShorthand","defaultProps","role","required","id","useId","positioningOptions","enabled","arrowPadding","tooltipBorderRadius","position","align","offset","resolvePositioningShorthand","mergeArrowOffset","arrowHeight","targetRef","containerRef","arrowRef","usePositioning","ref","useMergedRefs","useIsomorphicLayoutEffect","_context_visibleTooltip","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","Escape","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","mergeCallbacks","onPointerLeave","onFocus","onBlur","child","getTriggerChild","triggerAriaProps","childTargetRef","applyTriggerPropsToChildren","useEventCallback"],"mappings":";;;;+BAaiBA;;aAAAA;;;6DAbM;kCACuD;qCACyB;gCACuG;2BAC7J;8BAC1B;AAQZ,MAAMA,sBAAsB,CAACC,QAAQ;IAC5C,IAAIC,cAAcC,eAAeC,eAAeC;IAChD,MAAMC,UAAUC,IAAAA,kDAAoB;IACpC,MAAMC,qBAAqBC,IAAAA,wBAAQ;IACnC,MAAM,EAAEC,eAAc,EAAG,GAAGC,IAAAA,uCAAS;IACrC,MAAM,CAACC,iBAAiBC,kBAAkB,GAAGC,IAAAA,0BAAU;IACvD,MAAM,EAAEC,YAAY,SAAQ,EAAGC,SAAQ,EAAGC,QAAO,EAAGC,WAAW,KAAK,CAAA,EAAGC,aAAa,QAAO,EAAGC,gBAAe,EAAGC,aAAY,EAAGC,WAAW,IAAG,EAAGC,WAAW,IAAG,EAAGC,UAAS,EAAG,GAAGvB;IAChL,MAAM,CAACwB,SAASC,mBAAmB,GAAGC,IAAAA,oCAAoB,EAAC;QACvDC,OAAO3B,MAAMwB,OAAO;QACpBI,cAAc,KAAK;IACvB;IACA,MAAMC,aAAaC,OAAMC,WAAW,CAAC,CAACC,YAAYC,KAAK;QACnDrB;QACAa,mBAAmB,CAACS,aAAa;YAC7B,IAAIF,eAAeE,YAAY;gBAC3Bf,oBAAoB,IAAI,IAAIA,oBAAoB,KAAK,IAAI,KAAK,IAAIA,gBAAgBc,IAAI;oBAClFT,SAASQ;gBACb,EAAE;YACN,CAAC;YACD,OAAOA;QACX;IACJ,GAAG;QACCpB;QACAa;QACAN;KACH;IACD,MAAMQ,QAAQ;QACVV;QACAC;QACAG;QACAC;QACAF;QACAI;QACAW,qBAAqBX;QACrBV;QACAS;QACA,QAAQ;QACRa,YAAY;YACRpB,SAAS;QACb;QACAA,SAASqB,IAAAA,gCAAgB,EAACrB,SAAS;YAC/BsB,cAAc;gBACVC,MAAM;YACV;YACAC,UAAU,I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I,AAACnF,CAAAA,gBAAgBmF,MAAMvF,KAAK,AAAD,MAAO,IAAI,IAAII,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAckF,MAAM,EAAEP;IAC9L;IACA,OAAOpD;AACX"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["useTooltipStyles.styles.js"],"sourcesContent":["import { shorthands, __styles, mergeClasses } from '@griffel/react';\nimport { createArrowStyles } from '@fluentui/react-positioning';\nimport { tokens } from '@fluentui/react-theme';\nimport { arrowHeight } from './private/constants';\nexport const tooltipClassNames = {\n content: 'fui-Tooltip__content'\n};\n/**\n * Styles for the tooltip\n */\nconst useStyles = /*#__PURE__*/__styles({\n root: {\n mc9l5x: \"fjseox\",\n B7ck84d: \"f1ewtqcl\",\n B2u0y6b: \"f132xexn\",\n Bceei9c: \"f158kwzp\",\n Bahqtrf: \"fk6fouc\",\n Be2twd7: \"fy9rknc\",\n Bg96gwp: \"fwrc4pm\",\n Bbmb7ep: [\"f1aa9q02\", \"f16jpd5f\"],\n Beyfa6y: [\"f16jpd5f\", \"f1aa9q02\"],\n B7oj6ja: [\"f1jar5jt\", \"fyu767a\"],\n Btl43ni: [\"fyu767a\", \"f1jar5jt\"],\n B4j52fo: \"f5ogflp\",\n Bekrc4i: [\"f1hqa2wf\", \"finvdd3\"],\n Bn0qgzm: \"f1f09k3d\",\n ibv6hh: [\"finvdd3\", \"f1hqa2wf\"],\n icvyot: \"fzkkow9\",\n vrafjx: [\"fcdblym\", \"fjik90z\"],\n oivjwe: \"fg706s2\",\n wvpqe5: [\"fjik90z\", \"fcdblym\"],\n g2u3we: \"fghlq4f\",\n h3c5rm: [\"f1gn591s\", \"fjscplz\"],\n B9xav0g: \"fb073pr\",\n zhjwy3: [\"fjscplz\", \"f1gn591s\"],\n z8tnut: \"f10ra9hq\",\n z189sj: [\"fd9xhir\", \"f1jlaasf\"],\n Byoj8tv: \"f1d7kygh\",\n uwmqm3: [\"f1jlaasf\", \"fd9xhir\"],\n De3pzq: \"fxugw4r\",\n sj55zd: \"f19n0e5\",\n Bhu2qc9: \"fxeb0a7\"\n },\n visible: {\n mc9l5x: \"ftgm304\"\n },\n inverted: {\n De3pzq: \"fg3r6xk\",\n sj55zd: \"fonrgv7\"\n },\n arrow: {\n qhf8xq: \"f1euv43f\",\n De3pzq: \"f1u2r49w\",\n Bcdw1i0: \"fd7fpy0\",\n Bj3rh1h: \"f1bsuimh\",\n a9b677: \"f1ekdpwm\",\n Bqenvij: \"f83vc9z\",\n Ftih45: \"f1wl9k8s\",\n B1puzpu: \"f1wkw4r9\",\n Brfgrao: \"f1j7ml58\",\n Bcvre1j: \"fyl8oag\",\n Ccq8qp: \"frdoeuz\",\n Baz25je: \"fb81m9q\",\n cmx5o7: \"f1ljr5q2\",\n B4f6apu: \"fyfemzf\",\n m598lv: \"focyt6c\",\n Bk5zm6e: \"fnhxbxj\",\n y0oebl: \"fdw6hkg\",\n qa3bma: \"f11yjt3y\",\n Bqjgrrk: \"f1172wan\",\n Budzafs: [\"f9e5op9\", \"f112wvtl\"],\n Hv9wc6: [\"ftj5xct\", \"fyavhwi\"],\n hl6cv3: \"f1773hnp\",\n Bh2vraf: \"f1n8855c\",\n yayu3t: \"f1v7783n\",\n wedwtw: \"fsw6im5\",\n rhl9o9: \"fh2hsk5\",\n Bu8t5uz: \"f159pzir\",\n B6q6orb: \"f11yvu4\",\n Bwwlvwl: \"fm1ycve\"\n }\n}, {\n d: [\".fjseox{display:none;}\", \".f1ewtqcl{box-sizing:border-box;}\", \".f132xexn{max-width:240px;}\", \".f158kwzp{cursor:default;}\", \".fk6fouc{font-family:var(--fontFamilyBase);}\", \".fy9rknc{font-size:var(--fontSizeBase200);}\", \".fwrc4pm{line-height:var(--lineHeightBase200);}\", \".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}\", \".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}\", \".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}\", \".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}\", \".f5ogflp{border-top-width:1px;}\", \".f1hqa2wf{border-right-width:1px;}\", \".finvdd3{border-left-width:1px;}\", \".f1f09k3d{border-bottom-width:1px;}\", \".fzkkow9{border-top-style:solid;}\", \".fcdblym{border-right-style:solid;}\", \".fjik90z{border-left-style:solid;}\", \".fg706s2{border-bottom-style:solid;}\", \".fghlq4f{border-top-color:var(--colorTransparentStroke);}\", \".f1gn591s{border-right-color:var(--colorTransparentStroke);}\", \".fjscplz{border-left-color:var(--colorTransparentStroke);}\", \".fb073pr{border-bottom-color:var(--colorTransparentStroke);}\", \".f10ra9hq{padding-top:4px;}\", \".fd9xhir{padding-right:11px;}\", \".f1jlaasf{padding-left:11px;}\", \".f1d7kygh{padding-bottom:6px;}\", \".fxugw4r{background-color:var(--colorNeutralBackground1);}\", \".f19n0e5{color:var(--colorNeutralForeground1);}\", \".fxeb0a7{-webkit-filter:drop-shadow(0 0 2px var(--colorNeutralShadowAmbient)) drop-shadow(0 4px 8px var(--colorNeutralShadowKey));filter:drop-shadow(0 0 2px var(--colorNeutralShadowAmbient)) drop-shadow(0 4px 8px var(--colorNeutralShadowKey));}\", \".ftgm304{display:block;}\", \".fg3r6xk{background-color:var(--colorNeutralBackgroundStatic);}\", \".fonrgv7{color:var(--colorNeutralForegroundStaticInverted);}\", \".f1euv43f{position:absolute;}\", \".f1u2r49w{background-color:inherit;}\", \".fd7fpy0{visibility:hidden;}\", \".f1bsuimh{z-index:-1;}\", \".f1ekdpwm{width:8.484px;}\", \".f83vc9z{height:8.484px;}\", \".f1wl9k8s::before{content:\\\"\\\";}\", \".f1wkw4r9::before{visibility:visible;}\", \".f1j7ml58::before{position:absolute;}\", \".fyl8oag::before{box-sizing:border-box;}\", \".frdoeuz::before{width:inherit;}\", \".fb81m9q::before{height:inherit;}\", \".f1ljr5q2::before{background-color:inherit;}\", \".fyfemzf::before{border-right-width:1px;}\", \".focyt6c::before{border-right-style:solid;}\", \".fnhxbxj::before{border-right-color:var(--colorTransparentStroke);}\", \".fdw6hkg::before{border-bottom-width:1px;}\", \".f11yjt3y::before{border-bottom-style:solid;}\", \".f1172wan::before{border-bottom-color:var(--colorTransparentStroke);}\", \".f9e5op9::before{border-bottom-right-radius:var(--borderRadiusSmall);}\", \".f112wvtl::before{border-bottom-left-radius:var(--borderRadiusSmall);}\", \".ftj5xct::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(45deg);}\", \".fyavhwi::before{-webkit-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-moz-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);-ms-transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);transform:rotate(var(--angle)) translate(0, 50%) rotate(-45deg);}\", \"[data-popper-placement^=\\\"top\\\"] .f1773hnp{bottom:-1px;}\", \"[data-popper-placement^=\\\"top\\\"] .f1n8855c{--angle:0;}\", \"[data-popper-placement^=\\\"right\\\"] .f1v7783n{left:-1px;}\", \"[data-popper-placement^=\\\"right\\\"] .fsw6im5{--angle:90deg;}\", \"[data-popper-placement^=\\\"bottom\\\"] .fh2hsk5{top:-1px;}\", \"[data-popper-placement^=\\\"bottom\\\"] .f159pzir{--angle:180deg;}\", \"[data-popper-placement^=\\\"left\\\"] .f11yvu4{right:-1px;}\", \"[data-popper-placement^=\\\"left\\\"] .fm1ycve{--angle:270deg;}\"]\n});\n/**\n * Apply styling to the Tooltip slots based on the state\n */\nexport const useTooltipStyles_unstable = state => {\n const styles = useStyles();\n state.content.className = mergeClasses(tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);\n state.arrowClassName = styles.arrow;\n return state;\n};\n//# sourceMappingURL=useTooltipStyles.styles.js.map"],"names":["tooltipClassNames","useTooltipStyles_unstable","content","useStyles","__styles","root","mc9l5x","B7ck84d","B2u0y6b","Bceei9c","Bahqtrf","Be2twd7","Bg96gwp","Bbmb7ep","Beyfa6y","B7oj6ja","Btl43ni","B4j52fo","Bekrc4i","Bn0qgzm","ibv6hh","icvyot","vrafjx","oivjwe","wvpqe5","g2u3we","h3c5rm","B9xav0g","zhjwy3","z8tnut","z189sj","Byoj8tv","uwmqm3","De3pzq","sj55zd","Bhu2qc9","visible","inverted","arrow","qhf8xq","Bcdw1i0","Bj3rh1h","a9b677","Bqenvij","Ftih45","B1puzpu","Brfgrao","Bcvre1j","Ccq8qp","Baz25je","cmx5o7","B4f6apu","m598lv","Bk5zm6e","y0oebl","qa3bma","Bqjgrrk","Budzafs","Hv9wc6","hl6cv3","Bh2vraf","yayu3t","wedwtw","rhl9o9","Bu8t5uz","B6q6orb","Bwwlvwl","d","state","styles","className","mergeClasses","appearance","arrowClassName"],"mappings":";;;;;;;;;;;IAIaA,iBAAiB,MAAjBA;IAmFAC,yBAAyB,MAAzBA;;uBAvFsC;AAI5C,MAAMD,oBAAoB;IAC/BE,SAAS;AACX;AACA;;CAEC,GACD,MAAMC,YAAY,WAAW,GAAEC,IAAAA,kBAAQ,EAAC;IACtCC,MAAM;QACJC,QAAQ;QACRC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,SAAS;QACTC,SAAS;YAAC;YAAY;SAAW;QACjCC,SAAS;YAAC;YAAY;SAAW;QACjCC,SAAS;YAAC;YAAY;SAAU;QAChCC,SAAS;YAAC;YAAW;SAAW;QAChCC,SAAS;QACTC,SAAS;YAAC;YAAY;SAAU;QAChCC,SAAS;QACTC,QAAQ;YAAC;YAAW;SAAW;QAC/BC,QAAQ;QACRC,QAAQ;YAAC;YAAW;SAAU;QAC9BC,QAAQ;QACRC,QAAQ;YAAC;YAAW;SAAU;QAC9BC,QAAQ;QACRC,QAAQ;YAAC;YAAY;SAAU;QAC/B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E;IACfiE,MAAMlE,OAAO,CAACoE,SAAS,GAAGC,IAAAA,mBAAY,EAACvE,kBAAkBE,OAAO,EAAEmE,OAAOhE,IAAI,EAAE+D,MAAMI,UAAU,KAAK,cAAcH,OAAOhC,QAAQ,EAAE+B,MAAMhC,OAAO,IAAIiC,OAAOjC,OAAO,EAAEgC,MAAMlE,OAAO,CAACoE,SAAS;IAC3LF,MAAMK,cAAc,GAAGJ,OAAO/B,KAAK;IACnC,OAAO8B;AACT,GACA,mDAAmD"}
|
package/lib-commonjs/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { Tooltip, renderTooltip_unstable, tooltipClassNames, useTooltipStyles_unstable, useTooltip_unstable } from './Tooltip';\n"],"names":["Tooltip","renderTooltip_unstable","tooltipClassNames","useTooltipStyles_unstable","useTooltip_unstable"],"mappings":";;;;;;;;;;;IAASA,OAAO,MAAPA,gBAAO;IAAEC,sBAAsB,MAAtBA,+BAAsB;IAAEC,iBAAiB,MAAjBA,0BAAiB;IAAEC,yBAAyB,MAAzBA,kCAAyB;IAAEC,mBAAmB,MAAnBA,4BAAmB;;yBAAQ"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-tooltip",
|
3
|
-
"version": "9.2.
|
3
|
+
"version": "9.2.16",
|
4
4
|
"description": "React components for building web experiences",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -28,19 +28,19 @@
|
|
28
28
|
"devDependencies": {
|
29
29
|
"@fluentui/eslint-plugin": "*",
|
30
30
|
"@fluentui/react-conformance": "*",
|
31
|
-
"@fluentui/react-conformance-griffel": "9.0.0-beta.
|
31
|
+
"@fluentui/react-conformance-griffel": "9.0.0-beta.22",
|
32
32
|
"@fluentui/scripts-api-extractor": "*",
|
33
33
|
"@fluentui/scripts-tasks": "*"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
36
|
"@fluentui/keyboard-keys": "^9.0.3",
|
37
|
-
"@fluentui/react-jsx-runtime": "9.0.0-alpha.
|
38
|
-
"@fluentui/react-portal": "^9.2.
|
39
|
-
"@fluentui/react-positioning": "^9.
|
37
|
+
"@fluentui/react-jsx-runtime": "9.0.0-alpha.6",
|
38
|
+
"@fluentui/react-portal": "^9.2.12",
|
39
|
+
"@fluentui/react-positioning": "^9.6.0",
|
40
40
|
"@fluentui/react-shared-contexts": "^9.5.0",
|
41
41
|
"@fluentui/react-theme": "^9.1.8",
|
42
|
-
"@fluentui/react-utilities": "^9.9.
|
43
|
-
"@griffel/react": "^1.5.
|
42
|
+
"@fluentui/react-utilities": "^9.9.2",
|
43
|
+
"@griffel/react": "^1.5.7",
|
44
44
|
"@swc/helpers": "^0.4.14"
|
45
45
|
},
|
46
46
|
"peerDependencies": {
|