@fluentui/react-tooltip 0.0.0-nightly-20230223-0420.1 → 0.0.0-nightly-20230223-2115.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/.swcrc +33 -0
  2. package/CHANGELOG.json +17 -17
  3. package/CHANGELOG.md +11 -11
  4. package/lib/Tooltip.js.map +1 -1
  5. package/lib/components/Tooltip/Tooltip.js +1 -0
  6. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  7. package/lib/components/Tooltip/Tooltip.types.js +1 -1
  8. package/lib/components/Tooltip/Tooltip.types.js.map +1 -1
  9. package/lib/components/Tooltip/index.js.map +1 -1
  10. package/lib/components/Tooltip/private/constants.js +1 -2
  11. package/lib/components/Tooltip/private/constants.js.map +1 -1
  12. package/lib/components/Tooltip/renderTooltip.js +2 -3
  13. package/lib/components/Tooltip/renderTooltip.js.map +1 -1
  14. package/lib/components/Tooltip/useTooltip.js +7 -7
  15. package/lib/components/Tooltip/useTooltip.js.map +1 -1
  16. package/lib/components/Tooltip/useTooltipStyles.js.map +1 -1
  17. package/lib/index.js.map +1 -1
  18. package/lib-commonjs/Tooltip.js +5 -4
  19. package/lib-commonjs/Tooltip.js.map +1 -1
  20. package/lib-commonjs/components/Tooltip/Tooltip.js +17 -16
  21. package/lib-commonjs/components/Tooltip/Tooltip.js.map +1 -1
  22. package/lib-commonjs/components/Tooltip/Tooltip.types.js +5 -2
  23. package/lib-commonjs/components/Tooltip/Tooltip.types.js.map +1 -1
  24. package/lib-commonjs/components/Tooltip/index.js +9 -8
  25. package/lib-commonjs/components/Tooltip/index.js.map +1 -1
  26. package/lib-commonjs/components/Tooltip/private/constants.js +17 -16
  27. package/lib-commonjs/components/Tooltip/private/constants.js.map +1 -1
  28. package/lib-commonjs/components/Tooltip/renderTooltip.js +21 -24
  29. package/lib-commonjs/components/Tooltip/renderTooltip.js.map +1 -1
  30. package/lib-commonjs/components/Tooltip/useTooltip.js +191 -194
  31. package/lib-commonjs/components/Tooltip/useTooltip.js.map +1 -1
  32. package/lib-commonjs/components/Tooltip/useTooltipStyles.js +200 -92
  33. package/lib-commonjs/components/Tooltip/useTooltipStyles.js.map +1 -1
  34. package/lib-commonjs/index.js +16 -33
  35. package/lib-commonjs/index.js.map +1 -1
  36. package/package.json +10 -10
@@ -1,28 +1,25 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderTooltip_unstable", {
6
+ enumerable: true,
7
+ get: ()=>renderTooltip_unstable
5
8
  });
6
- exports.renderTooltip_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
9
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
10
- /**
11
- * Render the final JSX of Tooltip
12
- */
13
- const renderTooltip_unstable = state => {
14
- const {
15
- slots,
16
- slotProps
17
- } = react_utilities_1.getSlots(state);
18
- return React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && React.createElement(react_portal_1.Portal, {
19
- mountNode: state.mountNode
20
- }, React.createElement(slots.content, {
21
- ...slotProps.content
22
- }, state.withArrow && React.createElement("div", {
23
- ref: state.arrowRef,
24
- className: state.arrowClassName
25
- }), state.content.children)));
26
- };
27
- exports.renderTooltip_unstable = renderTooltip_unstable;
9
+ const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
10
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
11
+ const _extends = require("@swc/helpers/lib/_extends.js").default;
12
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
13
+ const _reactPortal = require("@fluentui/react-portal");
14
+ const _reactUtilities = require("@fluentui/react-utilities");
15
+ const renderTooltip_unstable = (state)=>{
16
+ const { slots , slotProps } = (0, _reactUtilities.getSlots)(state);
17
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/ _react.createElement(_reactPortal.Portal, {
18
+ mountNode: state.mountNode
19
+ }, /*#__PURE__*/ _react.createElement(slots.content, _extends({}, slotProps.content), state.withArrow && /*#__PURE__*/ _react.createElement("div", {
20
+ ref: state.arrowRef,
21
+ className: state.arrowClassName
22
+ }), state.content.children)));
23
+ }; //# sourceMappingURL=renderTooltip.js.map
24
+
28
25
  //# sourceMappingURL=renderTooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAGA;;;AAGO,MAAMA,sBAAsB,GAAIC,KAAmB,IAAI;EAC5D,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAeH,KAAK,CAAC;EAE1D,OACEI,0CACGJ,KAAK,CAACK,QAAQ,EACdL,KAAK,CAACM,mBAAmB,IACxBF,oBAACG,qBAAM;IAACC,SAAS,EAAER,KAAK,CAACQ;EAAS,GAChCJ,oBAACH,KAAK,CAACQ,OAAO;IAAA,GAAKP,SAAS,CAACO;EAAO,GACjCT,KAAK,CAACU,SAAS,IAAIN;IAAKO,GAAG,EAAEX,KAAK,CAACY,QAAQ;IAAEC,SAAS,EAAEb,KAAK,CAACc;EAAc,EAAI,EAChFd,KAAK,CAACS,OAAO,CAACJ,QAAQ,CACT,CAEnB,CACA;AAEP,CAAC;AAhBYU,8BAAsB","names":["renderTooltip_unstable","state","slots","slotProps","react_utilities_1","React","children","shouldRenderTooltip","react_portal_1","mountNode","content","withArrow","ref","arrowRef","className","arrowClassName","exports"],"sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-tooltip/src/components/Tooltip/renderTooltip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } 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 } = getSlots<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"]}
1
+ {"version":3,"sources":["../../../lib/components/Tooltip/renderTooltip.js"],"sourcesContent":["import _extends from \"@swc/helpers/src/_extends.mjs\";\nimport * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\n/**\n * Render the final JSX of Tooltip\n */\nexport const renderTooltip_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n return /*#__PURE__*/React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/React.createElement(Portal, {\n mountNode: state.mountNode\n }, /*#__PURE__*/React.createElement(slots.content, _extends({}, slotProps.content), state.withArrow && /*#__PURE__*/React.createElement(\"div\", {\n ref: state.arrowRef,\n className: state.arrowClassName\n }), state.content.children)));\n};\n//# sourceMappingURL=renderTooltip.js.map"],"names":["renderTooltip_unstable","state","slots","slotProps","getSlots","React","createElement","Fragment","children","shouldRenderTooltip","Portal","mountNode","content","_extends","withArrow","ref","arrowRef","className","arrowClassName"],"mappings":";;;;+BAOaA;;aAAAA;;;;yBAPQ;6DACE;6BACA;gCACE;AAIlB,MAAMA,yBAAyBC,CAAAA,QAAS;IAC7C,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACH;IACb,OAAO,WAAW,GAAEI,OAAMC,aAAa,CAACD,OAAME,QAAQ,EAAE,IAAI,EAAEN,MAAMO,QAAQ,EAAEP,MAAMQ,mBAAmB,IAAI,WAAW,GAAEJ,OAAMC,aAAa,CAACI,mBAAM,EAAE;QAClJC,WAAWV,MAAMU,SAAS;IAC5B,GAAG,WAAW,GAAEN,OAAMC,aAAa,CAACJ,MAAMU,OAAO,EAAEC,SAAS,CAAC,GAAGV,UAAUS,OAAO,GAAGX,MAAMa,SAAS,IAAI,WAAW,GAAET,OAAMC,aAAa,CAAC,OAAO;QAC7IS,KAAKd,MAAMe,QAAQ;QACnBC,WAAWhB,MAAMiB,cAAc;IACjC,IAAIjB,MAAMW,OAAO,CAACJ,QAAQ;AAC5B,GACA,yCAAyC"}
@@ -1,203 +1,200 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.useTooltip_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_positioning_1 = /*#__PURE__*/require("@fluentui/react-positioning");
9
- const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
10
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
- const constants_1 = /*#__PURE__*/require("./private/constants");
12
- const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
13
- /**
14
- * Create the state required to render Tooltip.
15
- *
16
- * The returned state can be modified with hooks such as useTooltipStyles_unstable,
17
- * before being passed to renderTooltip_unstable.
18
- *
19
- * @param props - props from this instance of Tooltip
20
- */
21
- const useTooltip_unstable = props => {
22
- var _a, _b, _c, _d;
23
- const context = react_shared_contexts_1.useTooltipVisibility_unstable();
24
- const isServerSideRender = react_utilities_1.useIsSSR();
25
- const {
26
- targetDocument
27
- } = react_shared_contexts_1.useFluent_unstable();
28
- const [setDelayTimeout, clearDelayTimeout] = react_utilities_1.useTimeout();
29
- const {
30
- appearance = 'normal',
31
- children,
32
- content,
33
- withArrow = false,
34
- positioning = 'above',
35
- onVisibleChange,
36
- relationship,
37
- showDelay = 250,
38
- hideDelay = 250,
39
- mountNode
40
- } = props;
41
- const [visible, setVisibleInternal] = react_utilities_1.useControllableState({
42
- state: props.visible,
43
- initialState: false
44
- });
45
- const setVisible = React.useCallback((newVisible, ev) => {
46
- clearDelayTimeout();
47
- setVisibleInternal(oldVisible => {
48
- if (newVisible !== oldVisible) {
49
- onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {
50
- visible: newVisible
51
- });
52
- }
53
- return newVisible;
5
+ Object.defineProperty(exports, "useTooltip_unstable", {
6
+ enumerable: true,
7
+ get: ()=>useTooltip_unstable
8
+ });
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _reactPositioning = require("@fluentui/react-positioning");
12
+ const _reactSharedContexts = require("@fluentui/react-shared-contexts");
13
+ const _reactUtilities = require("@fluentui/react-utilities");
14
+ const _constants = require("./private/constants");
15
+ const _keyboardKeys = require("@fluentui/keyboard-keys");
16
+ const useTooltip_unstable = (props)=>{
17
+ var _child_props, _child_props1, _child_props2, _child_props3;
18
+ const context = (0, _reactSharedContexts.useTooltipVisibility_unstable)();
19
+ const isServerSideRender = (0, _reactUtilities.useIsSSR)();
20
+ const { targetDocument } = (0, _reactSharedContexts.useFluent_unstable)();
21
+ const [setDelayTimeout, clearDelayTimeout] = (0, _reactUtilities.useTimeout)();
22
+ const { appearance ='normal' , children , content , withArrow =false , positioning ='above' , onVisibleChange , relationship , showDelay =250 , hideDelay =250 , mountNode } = props;
23
+ const [visible, setVisibleInternal] = (0, _reactUtilities.useControllableState)({
24
+ state: props.visible,
25
+ initialState: false
54
26
  });
55
- }, [clearDelayTimeout, setVisibleInternal, onVisibleChange]);
56
- const state = {
57
- withArrow,
58
- positioning,
59
- showDelay,
60
- hideDelay,
61
- relationship,
62
- visible,
63
- shouldRenderTooltip: visible,
64
- appearance,
65
- mountNode,
66
- // Slots
67
- components: {
68
- content: 'div'
69
- },
70
- content: react_utilities_1.resolveShorthand(content, {
71
- defaultProps: {
72
- role: 'tooltip'
73
- },
74
- required: true
75
- })
76
- };
77
- state.content.id = react_utilities_1.useId('tooltip-', state.content.id);
78
- const positioningOptions = {
79
- enabled: state.visible,
80
- arrowPadding: 2 * constants_1.tooltipBorderRadius,
81
- position: 'above',
82
- align: 'center',
83
- offset: 4,
84
- ...react_positioning_1.resolvePositioningShorthand(state.positioning)
85
- };
86
- if (state.withArrow) {
87
- positioningOptions.offset = react_positioning_1.mergeArrowOffset(positioningOptions.offset, constants_1.arrowHeight);
88
- }
89
- const {
90
- targetRef,
91
- containerRef,
92
- arrowRef
93
- } = react_positioning_1.usePositioning(positioningOptions);
94
- state.content.ref = react_utilities_1.useMergedRefs(state.content.ref, containerRef);
95
- state.arrowRef = arrowRef;
96
- // When this tooltip is visible, hide any other tooltips, and register it
97
- // as the visibleTooltip with the TooltipContext.
98
- // Also add a listener on document to hide the tooltip if Escape is pressed
99
- react_utilities_1.useIsomorphicLayoutEffect(() => {
100
- var _a;
101
- if (visible) {
102
- const thisTooltip = {
103
- hide: () => setVisible(false)
104
- };
105
- (_a = context.visibleTooltip) === null || _a === void 0 ? void 0 : _a.hide();
106
- context.visibleTooltip = thisTooltip;
107
- const onDocumentKeyDown = ev => {
108
- if (ev.key === keyboard_keys_1.Escape) {
109
- thisTooltip.hide();
110
- // stop propagation to avoid conflicting with other elements that listen for `Escape`
111
- // e,g: Dialog, Popover, Menu
112
- ev.stopPropagation();
113
- }
114
- };
115
- targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {
116
- // As this event is added at targeted document,
117
- // we need to capture the event to be sure keydown handling from tooltip happens first
118
- capture: true
119
- });
120
- return () => {
121
- if (context.visibleTooltip === thisTooltip) {
122
- context.visibleTooltip = undefined;
123
- }
124
- targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
125
- capture: true
27
+ const setVisible = _react.useCallback((newVisible, ev)=>{
28
+ clearDelayTimeout();
29
+ setVisibleInternal((oldVisible)=>{
30
+ if (newVisible !== oldVisible) {
31
+ onVisibleChange === null || onVisibleChange === void 0 ? void 0 : onVisibleChange(ev, {
32
+ visible: newVisible
33
+ });
34
+ }
35
+ return newVisible;
126
36
  });
127
- };
128
- }
129
- }, [context, targetDocument, visible, setVisible]);
130
- // The focused element gets a blur event when the document loses focus
131
- // (e.g. switching tabs in the browser), but we don't want to show the
132
- // tooltip again when the document gets focus back. Handle this case by
133
- // checking if the blurred element is still the document's activeElement.
134
- // See https://github.com/microsoft/fluentui/issues/13541
135
- const ignoreNextFocusEventRef = React.useRef(false);
136
- // Listener for onPointerEnter and onFocus on the trigger element
137
- const onEnterTrigger = React.useCallback(ev => {
138
- if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {
139
- ignoreNextFocusEventRef.current = false;
140
- return;
37
+ }, [
38
+ clearDelayTimeout,
39
+ setVisibleInternal,
40
+ onVisibleChange
41
+ ]);
42
+ const state = {
43
+ withArrow,
44
+ positioning,
45
+ showDelay,
46
+ hideDelay,
47
+ relationship,
48
+ visible,
49
+ shouldRenderTooltip: visible,
50
+ appearance,
51
+ mountNode,
52
+ // Slots
53
+ components: {
54
+ content: 'div'
55
+ },
56
+ content: (0, _reactUtilities.resolveShorthand)(content, {
57
+ defaultProps: {
58
+ role: 'tooltip'
59
+ },
60
+ required: true
61
+ })
62
+ };
63
+ state.content.id = (0, _reactUtilities.useId)('tooltip-', state.content.id);
64
+ const positioningOptions = {
65
+ enabled: state.visible,
66
+ arrowPadding: 2 * _constants.tooltipBorderRadius,
67
+ position: 'above',
68
+ align: 'center',
69
+ offset: 4,
70
+ ...(0, _reactPositioning.resolvePositioningShorthand)(state.positioning)
71
+ };
72
+ if (state.withArrow) {
73
+ positioningOptions.offset = (0, _reactPositioning.mergeArrowOffset)(positioningOptions.offset, _constants.arrowHeight);
141
74
  }
142
- // Show immediately if another tooltip is already visible
143
- const delay = context.visibleTooltip ? 0 : state.showDelay;
144
- setDelayTimeout(() => {
145
- setVisible(true, ev);
146
- }, delay);
147
- ev.persist(); // Persist the event since the setVisible call will happen asynchronously
148
- }, [setDelayTimeout, setVisible, state.showDelay, context]);
149
- // Listener for onPointerLeave and onBlur on the trigger element
150
- const onLeaveTrigger = React.useCallback(ev => {
151
- let delay = state.hideDelay;
152
- if (ev.type === 'blur') {
153
- // Hide immediately when losing focus
154
- delay = 0;
155
- ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;
75
+ const { targetRef , containerRef , arrowRef } = (0, _reactPositioning.usePositioning)(positioningOptions);
76
+ state.content.ref = (0, _reactUtilities.useMergedRefs)(state.content.ref, containerRef);
77
+ state.arrowRef = arrowRef;
78
+ // When this tooltip is visible, hide any other tooltips, and register it
79
+ // as the visibleTooltip with the TooltipContext.
80
+ // Also add a listener on document to hide the tooltip if Escape is pressed
81
+ (0, _reactUtilities.useIsomorphicLayoutEffect)(()=>{
82
+ if (visible) {
83
+ var _context_visibleTooltip;
84
+ const thisTooltip = {
85
+ hide: ()=>setVisible(false)
86
+ };
87
+ (_context_visibleTooltip = context.visibleTooltip) === null || _context_visibleTooltip === void 0 ? void 0 : _context_visibleTooltip.hide();
88
+ context.visibleTooltip = thisTooltip;
89
+ const onDocumentKeyDown = (ev)=>{
90
+ if (ev.key === _keyboardKeys.Escape) {
91
+ thisTooltip.hide();
92
+ // stop propagation to avoid conflicting with other elements that listen for `Escape`
93
+ // e,g: Dialog, Popover, Menu
94
+ ev.stopPropagation();
95
+ }
96
+ };
97
+ targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {
98
+ // As this event is added at targeted document,
99
+ // we need to capture the event to be sure keydown handling from tooltip happens first
100
+ capture: true
101
+ });
102
+ return ()=>{
103
+ if (context.visibleTooltip === thisTooltip) {
104
+ context.visibleTooltip = undefined;
105
+ }
106
+ targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
107
+ capture: true
108
+ });
109
+ };
110
+ }
111
+ }, [
112
+ context,
113
+ targetDocument,
114
+ visible,
115
+ setVisible
116
+ ]);
117
+ // The focused element gets a blur event when the document loses focus
118
+ // (e.g. switching tabs in the browser), but we don't want to show the
119
+ // tooltip again when the document gets focus back. Handle this case by
120
+ // checking if the blurred element is still the document's activeElement.
121
+ // See https://github.com/microsoft/fluentui/issues/13541
122
+ const ignoreNextFocusEventRef = _react.useRef(false);
123
+ // Listener for onPointerEnter and onFocus on the trigger element
124
+ const onEnterTrigger = _react.useCallback((ev)=>{
125
+ if (ev.type === 'focus' && ignoreNextFocusEventRef.current) {
126
+ ignoreNextFocusEventRef.current = false;
127
+ return;
128
+ }
129
+ // Show immediately if another tooltip is already visible
130
+ const delay = context.visibleTooltip ? 0 : state.showDelay;
131
+ setDelayTimeout(()=>{
132
+ setVisible(true, ev);
133
+ }, delay);
134
+ ev.persist(); // Persist the event since the setVisible call will happen asynchronously
135
+ }, [
136
+ setDelayTimeout,
137
+ setVisible,
138
+ state.showDelay,
139
+ context
140
+ ]);
141
+ // Listener for onPointerLeave and onBlur on the trigger element
142
+ const onLeaveTrigger = _react.useCallback((ev)=>{
143
+ let delay = state.hideDelay;
144
+ if (ev.type === 'blur') {
145
+ // Hide immediately when losing focus
146
+ delay = 0;
147
+ ignoreNextFocusEventRef.current = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement) === ev.target;
148
+ }
149
+ setDelayTimeout(()=>{
150
+ setVisible(false, ev);
151
+ }, delay);
152
+ ev.persist(); // Persist the event since the setVisible call will happen asynchronously
153
+ }, [
154
+ setDelayTimeout,
155
+ setVisible,
156
+ state.hideDelay,
157
+ targetDocument
158
+ ]);
159
+ // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.
160
+ // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.
161
+ state.content.onPointerEnter = (0, _reactUtilities.mergeCallbacks)(state.content.onPointerEnter, clearDelayTimeout);
162
+ state.content.onPointerLeave = (0, _reactUtilities.mergeCallbacks)(state.content.onPointerLeave, onLeaveTrigger);
163
+ state.content.onFocus = (0, _reactUtilities.mergeCallbacks)(state.content.onFocus, clearDelayTimeout);
164
+ state.content.onBlur = (0, _reactUtilities.mergeCallbacks)(state.content.onBlur, onLeaveTrigger);
165
+ const child = (0, _reactUtilities.getTriggerChild)(children);
166
+ const triggerAriaProps = {};
167
+ if (relationship === 'label') {
168
+ // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
169
+ if (typeof state.content.children === 'string') {
170
+ triggerAriaProps['aria-label'] = state.content.children;
171
+ } else {
172
+ triggerAriaProps['aria-labelledby'] = state.content.id;
173
+ // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
174
+ state.shouldRenderTooltip = true;
175
+ }
176
+ } else if (relationship === 'description') {
177
+ triggerAriaProps['aria-describedby'] = state.content.id;
178
+ // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
179
+ state.shouldRenderTooltip = true;
156
180
  }
157
- setDelayTimeout(() => {
158
- setVisible(false, ev);
159
- }, delay);
160
- ev.persist(); // Persist the event since the setVisible call will happen asynchronously
161
- }, [setDelayTimeout, setVisible, state.hideDelay, targetDocument]);
162
- // Cancel the hide timer when the mouse or focus enters the tooltip, and restart it when the mouse or focus leaves.
163
- // This keeps the tooltip visible when the mouse is moved over it, or it has focus within.
164
- state.content.onPointerEnter = react_utilities_1.mergeCallbacks(state.content.onPointerEnter, clearDelayTimeout);
165
- state.content.onPointerLeave = react_utilities_1.mergeCallbacks(state.content.onPointerLeave, onLeaveTrigger);
166
- state.content.onFocus = react_utilities_1.mergeCallbacks(state.content.onFocus, clearDelayTimeout);
167
- state.content.onBlur = react_utilities_1.mergeCallbacks(state.content.onBlur, onLeaveTrigger);
168
- const child = react_utilities_1.getTriggerChild(children);
169
- const triggerAriaProps = {};
170
- if (relationship === 'label') {
171
- // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
172
- if (typeof state.content.children === 'string') {
173
- triggerAriaProps['aria-label'] = state.content.children;
174
- } else {
175
- triggerAriaProps['aria-labelledby'] = state.content.id;
176
- // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
177
- state.shouldRenderTooltip = true;
181
+ // Don't render the Tooltip in SSR to avoid hydration errors
182
+ if (isServerSideRender) {
183
+ state.shouldRenderTooltip = false;
178
184
  }
179
- } else if (relationship === 'description') {
180
- triggerAriaProps['aria-describedby'] = state.content.id;
181
- // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
182
- state.shouldRenderTooltip = true;
183
- }
184
- // Don't render the Tooltip in SSR to avoid hydration errors
185
- if (isServerSideRender) {
186
- state.shouldRenderTooltip = false;
187
- }
188
- const childTargetRef = react_utilities_1.useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);
189
- // Apply the trigger props to the child, either by calling the render function, or cloning with the new props
190
- state.children = react_utilities_1.applyTriggerPropsToChildren(children, {
191
- ...triggerAriaProps,
192
- ...(child === null || child === void 0 ? void 0 : child.props),
193
- // If the target prop is not provided, attach targetRef to the trigger element's ref prop
194
- ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
195
- onPointerEnter: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onPointerEnter, onEnterTrigger)),
196
- onPointerLeave: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onPointerLeave, onLeaveTrigger)),
197
- onFocus: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onFocus, onEnterTrigger)),
198
- onBlur: react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onBlur, onLeaveTrigger))
199
- });
200
- return state;
201
- };
202
- exports.useTooltip_unstable = useTooltip_unstable;
185
+ const childTargetRef = (0, _reactUtilities.useMergedRefs)(child === null || child === void 0 ? void 0 : child.ref, targetRef);
186
+ // Apply the trigger props to the child, either by calling the render function, or cloning with the new props
187
+ state.children = (0, _reactUtilities.applyTriggerPropsToChildren)(children, {
188
+ ...triggerAriaProps,
189
+ ...child === null || child === void 0 ? void 0 : child.props,
190
+ // If the target prop is not provided, attach targetRef to the trigger element's ref prop
191
+ ref: positioningOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
192
+ onPointerEnter: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props = child.props) === null || _child_props === void 0 ? void 0 : _child_props.onPointerEnter, onEnterTrigger)),
193
+ onPointerLeave: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props1 = child.props) === null || _child_props1 === void 0 ? void 0 : _child_props1.onPointerLeave, onLeaveTrigger)),
194
+ onFocus: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props2 = child.props) === null || _child_props2 === void 0 ? void 0 : _child_props2.onFocus, onEnterTrigger)),
195
+ onBlur: (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)(child === null || child === void 0 ? void 0 : (_child_props3 = child.props) === null || _child_props3 === void 0 ? void 0 : _child_props3.onBlur, onLeaveTrigger))
196
+ });
197
+ return state;
198
+ }; //# sourceMappingURL=useTooltip.js.map
199
+
203
200
  //# sourceMappingURL=useTooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAIA;AAcA;AACA;AAEA;;;;;;;;AAQO,MAAMA,mBAAmB,GAAIC,KAAmB,IAAkB;;EACvE,MAAMC,OAAO,GAAGC,qDAAoB,EAAE;EACtC,MAAMC,kBAAkB,GAAGC,0BAAQ,EAAE;EACrC,MAAM;IAAEC;EAAc,CAAE,GAAGH,0CAAS,EAAE;EACtC,MAAM,CAACI,eAAe,EAAEC,iBAAiB,CAAC,G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AACuB,EAAE;IACvD;IACAb,KAAK,CAACQ,mBAAmB,GAAG,IAAI;;EAGlC;EACA,IAAIzB,kBAAkB,EAAE;IACtBiB,KAAK,CAACQ,mBAAmB,GAAG,KAAK;;EAGnC,MAAM6C,cAAc,GAAGrE,+BAAa,CAACmE,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE1B,GAAG,EAAEH,SAAS,CAAC;EAE3D;EACAtB,KAAK,CAACX,QAAQ,GAAGL,6CAA2B,CAACK,QAAQ,EAAE;IACrD,GAAG+D,gBAAgB;IACnB,IAAGD,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEvE,KAAK;IACf;IACA6C,GAAG,EAAEX,kBAAkB,CAACgC,MAAM,KAAKX,SAAS,GAAGkB,cAAc,GAAGF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE1B,GAAG;IAC1EsB,cAAc,EAAE/D,kCAAgB,CAACA,gCAAc,CAAC,WAAK,aAALmE,KAAK,uBAALA,KAAK,CAAEvE,KAAK,0CAAEmE,cAAc,EAAER,cAAc,CAAC,CAAC;IAC9FS,cAAc,EAAEhE,kCAAgB,CAACA,gCAAc,CAAC,WAAK,aAALmE,KAAK,uBAALA,KAAK,CAAEvE,KAAK,0CAAEoE,cAAc,EAAEJ,cAAc,CAAC,CAAC;IAC9FK,OAAO,EAAEjE,kCAAgB,CAACA,gCAAc,CAAC,WAAK,aAALmE,KAAK,uBAALA,KAAK,CAAEvE,KAAK,0CAAEqE,OAAO,EAAEV,cAAc,CAAC,CAAC;IAChFW,MAAM,EAAElE,kCAAgB,CAACA,gCAAc,CAAC,WAAK,aAALmE,KAAK,uBAALA,KAAK,CAAEvE,KAAK,0CAAEsE,MAAM,EAAEN,cAAc,CAAC;GAC9E,CAAC;EAEF,OAAO5C,KAAK;AACd,CAAC;AApNYsD,2BAAmB","names":["useTooltip_unstable","props","context","react_shared_contexts_1","isServerSideRender","react_utilities_1","targetDocument","setDelayTimeout","clearDelayTimeout","appearance","children","content","withArrow","positioning","onVisibleChange","relationship","showDelay","hideDelay","mountNode","visible","setVisibleInternal","state","initialState","setVisible","React","useCallback","newVisible","ev","oldVisible","shouldRenderTooltip","components","defaultProps","role","required","id","positioningOptions","enabled","arrowPadding","constants_1","position","align","offset","react_positioning_1","targetRef","containerRef","arrowRef","ref","thisTooltip","hide","visibleTooltip","onDocumentKeyDown","key","keyboard_keys_1","stopPropagation","addEventListener","capture","undefined","removeEventListener","ignoreNextFocusEventRef","useRef","onEnterTrigger","type","current","delay","persist","onLeaveTrigger","activeElement","target","onPointerEnter","onPointerLeave","onFocus","onBlur","child","triggerAriaProps","childTargetRef","exports"],"sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-tooltip/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"]}
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,eAAc,EACf,GAAGC,IAAAA,uCAAS;IACb,MAAM,CAACC,iBAAiBC,kBAAkB,GAAGC,IAAAA,0BAAU;IACvD,MAAM,EACJC,YAAa,SAAQ,EACrBC,SAAQ,EACRC,QAAO,EACPC,WAAY,KAAK,CAAA,EACjBC,aAAc,QAAO,EACrBC,gBAAe,EACfC,aAAY,EACZC,WAAY,IAAG,EACfC,WAAY,IAAG,EACfC,UAAS,EACV,GAAGvB;IACJ,MAAM,CAACwB,SAASC,mBAAmB,GAAGC,IAAAA,oCAAoB,EAAC;QACzDC,OAAO3B,MAAMwB,OAAO;QACpBI,cAAc,KAAK;IACrB;IACA,MAAMC,aAAaC,OAAMC,WAAW,CAAC,CAACC,YAAYC,KAAO;QACvDrB;QACAa,mBAAmBS,CAAAA,aAAc;YAC/B,IAAIF,eAAeE,YAAY;gBAC7Bf,oBAAoB,IAAI,IAAIA,oBAAoB,KAAK,IAAI,KAAK,IAAIA,gBAAgBc,IAAI;oBACpFT,SAASQ;gBACX,EAAE;YACJ,CAAC;YACD,OAAOA;QACT;IACF,GAAG;QAACpB;QAAmBa;QAAoBN;KAAgB;IAC3D,MAAMQ,QAAQ;QACZV;QACAC;QACAG;QACAC;QACAF;QACAI;QACAW,qBAAqBX;QACrBV;QACAS;QACA,QAAQ;QACRa,YAAY;YACVpB,SAAS;QACX;QACAA,SAASqB,IAAAA,gCAAg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