@fluentui/react-tooltip 9.0.0-rc.1 → 9.0.0-rc.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/CHANGELOG.json +401 -1
  2. package/CHANGELOG.md +215 -101
  3. package/MIGRATION.md +51 -43
  4. package/Spec.md +201 -337
  5. package/dist/{react-tooltip.d.ts → index.d.ts} +46 -34
  6. package/{lib → dist}/tsdoc-metadata.json +0 -0
  7. package/lib/Tooltip.js.map +1 -1
  8. package/lib/components/Tooltip/Tooltip.js.map +1 -1
  9. package/lib/components/Tooltip/Tooltip.types.js.map +1 -1
  10. package/lib/components/Tooltip/index.js.map +1 -1
  11. package/lib/components/Tooltip/private/constants.js.map +1 -1
  12. package/lib/components/Tooltip/renderTooltip.js +3 -1
  13. package/lib/components/Tooltip/renderTooltip.js.map +1 -1
  14. package/lib/components/Tooltip/useTooltip.js +27 -34
  15. package/lib/components/Tooltip/useTooltip.js.map +1 -1
  16. package/lib/components/Tooltip/useTooltipStyles.js +10 -1
  17. package/lib/components/Tooltip/useTooltipStyles.js.map +1 -1
  18. package/lib/index.js +2 -1
  19. package/lib/index.js.map +1 -1
  20. package/lib-commonjs/Tooltip.js.map +1 -1
  21. package/lib-commonjs/components/Tooltip/Tooltip.js.map +1 -1
  22. package/lib-commonjs/components/Tooltip/Tooltip.types.js.map +1 -1
  23. package/lib-commonjs/components/Tooltip/index.js.map +1 -1
  24. package/lib-commonjs/components/Tooltip/private/constants.js.map +1 -1
  25. package/lib-commonjs/components/Tooltip/renderTooltip.js +3 -1
  26. package/lib-commonjs/components/Tooltip/renderTooltip.js.map +1 -1
  27. package/lib-commonjs/components/Tooltip/useTooltip.js +27 -34
  28. package/lib-commonjs/components/Tooltip/useTooltip.js.map +1 -1
  29. package/lib-commonjs/components/Tooltip/useTooltipStyles.js +11 -2
  30. package/lib-commonjs/components/Tooltip/useTooltipStyles.js.map +1 -1
  31. package/lib-commonjs/index.js +39 -2
  32. package/lib-commonjs/index.js.map +1 -1
  33. package/package.json +19 -22
  34. package/lib/Tooltip.d.ts +0 -1
  35. package/lib/components/Tooltip/Tooltip.d.ts +0 -7
  36. package/lib/components/Tooltip/Tooltip.types.d.ts +0 -108
  37. package/lib/components/Tooltip/index.d.ts +0 -5
  38. package/lib/components/Tooltip/private/constants.d.ts +0 -12
  39. package/lib/components/Tooltip/renderTooltip.d.ts +0 -5
  40. package/lib/components/Tooltip/useTooltip.d.ts +0 -10
  41. package/lib/components/Tooltip/useTooltipStyles.d.ts +0 -6
  42. package/lib/index.d.ts +0 -1
  43. package/lib-commonjs/Tooltip.d.ts +0 -1
  44. package/lib-commonjs/components/Tooltip/Tooltip.d.ts +0 -7
  45. package/lib-commonjs/components/Tooltip/Tooltip.types.d.ts +0 -108
  46. package/lib-commonjs/components/Tooltip/index.d.ts +0 -5
  47. package/lib-commonjs/components/Tooltip/private/constants.d.ts +0 -12
  48. package/lib-commonjs/components/Tooltip/renderTooltip.d.ts +0 -5
  49. package/lib-commonjs/components/Tooltip/useTooltip.d.ts +0 -10
  50. package/lib-commonjs/components/Tooltip/useTooltipStyles.d.ts +0 -6
  51. package/lib-commonjs/index.d.ts +0 -1
@@ -1,9 +1,11 @@
1
1
  import type { ComponentProps } from '@fluentui/react-utilities';
2
2
  import type { ComponentState } from '@fluentui/react-utilities';
3
3
  import type { FluentTriggerComponent } from '@fluentui/react-utilities';
4
+ import type { PortalProps } from '@fluentui/react-portal';
4
5
  import type { PositioningShorthand } from '@fluentui/react-positioning';
5
6
  import * as React_2 from 'react';
6
7
  import type { Slot } from '@fluentui/react-utilities';
8
+ import type { SlotClassNames } from '@fluentui/react-utilities';
7
9
 
8
10
  /**
9
11
  * Data for the Tooltip's onVisibleChange event.
@@ -22,45 +24,50 @@ export declare const renderTooltip_unstable: (state: TooltipState) => JSX.Elemen
22
24
  */
23
25
  export declare const Tooltip: React_2.FC<TooltipProps> & FluentTriggerComponent;
24
26
 
27
+ /**
28
+ * @deprecated Use `tooltipClassNames.root` instead.
29
+ */
25
30
  export declare const tooltipClassName = "fui-Tooltip";
26
31
 
32
+ export declare const tooltipClassNames: SlotClassNames<TooltipSlots>;
33
+
27
34
  /**
28
- * Properties and state for Tooltip
35
+ * Properties for Tooltip
29
36
  */
30
- declare type TooltipCommons = {
37
+ export declare type TooltipProps = ComponentProps<TooltipSlots> & Pick<PortalProps, 'mountNode'> & {
31
38
  /**
32
39
  * The tooltip's visual appearance.
33
40
  * * `normal` - Uses the theme's background and text colors.
34
41
  * * `inverted` - Higher contrast variant that uses the theme's inverted colors.
35
42
  *
36
- * @defaultvalue normal
43
+ * @default normal
37
44
  */
38
45
  appearance?: 'normal' | 'inverted';
39
46
  /**
40
- * Render an arrow pointing to the target element
47
+ * The tooltip can have a single JSX child, or a render function that accepts TooltipTriggerProps.
41
48
  *
42
- * @defaultvalue false
49
+ * If no child is provided, the tooltip's target must be set with the `positioning` prop, and its
50
+ * visibility must be controlled with the `visible` prop.
43
51
  */
44
- withArrow?: boolean;
45
- /**
46
- * Configure the positioning of the tooltip
47
- *
48
- * @defaultvalue above
49
- */
50
- positioning?: PositioningShorthand;
52
+ children?: (React_2.ReactElement & {
53
+ ref?: React_2.Ref<unknown>;
54
+ }) | ((props: TooltipTriggerProps) => React_2.ReactElement | null) | null;
51
55
  /**
52
- * Control the tooltip's visibility programatically.
53
- *
54
- * This can be used in conjunction with onVisibleChange to modify the tooltip's show and hide behavior.
56
+ * Delay before the tooltip is hidden, in milliseconds.
55
57
  *
56
- * If not provided, the visibility will be controlled by the tooltip itself, based on hover and focus events on the
57
- * trigger (child) element.
58
+ * @default 250
58
59
  */
59
- visible?: boolean;
60
+ hideDelay?: number;
60
61
  /**
61
62
  * Notification when the visibility of the tooltip is changing
62
63
  */
63
64
  onVisibleChange?: (event: React_2.PointerEvent<HTMLElement> | React_2.FocusEvent<HTMLElement> | undefined, data: OnVisibleChangeData) => void;
65
+ /**
66
+ * Configure the positioning of the tooltip
67
+ *
68
+ * @default above
69
+ */
70
+ positioning?: PositioningShorthand;
64
71
  /**
65
72
  * (Required) Specifies whether this tooltip is acting as the description or label of its trigger element.
66
73
  *
@@ -74,37 +81,42 @@ declare type TooltipCommons = {
74
81
  /**
75
82
  * Delay before the tooltip is shown, in milliseconds.
76
83
  *
77
- * @defaultvalue 250
84
+ * @default 250
78
85
  */
79
- showDelay: number;
86
+ showDelay?: number;
80
87
  /**
81
- * Delay before the tooltip is hidden, in milliseconds.
88
+ * Control the tooltip's visibility programatically.
89
+ *
90
+ * This can be used in conjunction with onVisibleChange to modify the tooltip's show and hide behavior.
91
+ *
92
+ * If not provided, the visibility will be controlled by the tooltip itself, based on hover and focus events on the
93
+ * trigger (child) element.
82
94
  *
83
- * @defaultvalue 250
95
+ * @default false
84
96
  */
85
- hideDelay: number;
86
- };
87
-
88
- /**
89
- * Properties for Tooltip
90
- */
91
- export declare type TooltipProps = ComponentProps<TooltipSlots> & Partial<Omit<TooltipCommons, 'relationship'>> & Pick<TooltipCommons, 'relationship'> & {
92
- children?: (React_2.ReactElement & {
93
- ref?: React_2.Ref<unknown>;
94
- }) | ((props: TooltipTriggerProps) => React_2.ReactElement | null) | null;
97
+ visible?: boolean;
98
+ /**
99
+ * Render an arrow pointing to the target element
100
+ *
101
+ * @default false
102
+ */
103
+ withArrow?: boolean;
95
104
  };
96
105
 
97
106
  /**
98
107
  * Slot properties for Tooltip
99
108
  */
100
109
  export declare type TooltipSlots = {
110
+ /**
111
+ * The text or JSX content of the tooltip.
112
+ */
101
113
  content: NonNullable<Slot<'div'>>;
102
114
  };
103
115
 
104
116
  /**
105
117
  * State used in rendering Tooltip
106
118
  */
107
- export declare type TooltipState = ComponentState<TooltipSlots> & TooltipCommons & {
119
+ export declare type TooltipState = ComponentState<TooltipSlots> & Pick<TooltipProps, 'mountNode' | 'relationship'> & Required<Pick<TooltipProps, 'appearance' | 'hideDelay' | 'positioning' | 'showDelay' | 'visible' | 'withArrow'>> & {
108
120
  children?: React_2.ReactElement | null;
109
121
  /**
110
122
  * Whether the tooltip should be rendered to the DOM.
@@ -125,7 +137,7 @@ export declare type TooltipState = ComponentState<TooltipSlots> & TooltipCommons
125
137
  */
126
138
  export declare type TooltipTriggerProps = {
127
139
  ref?: React_2.Ref<never>;
128
- } & Pick<React_2.HTMLAttributes<HTMLElement>, 'onPointerEnter' | 'onPointerLeave' | 'onFocus' | 'onBlur' | 'aria-describedby' | 'aria-labelledby' | 'aria-label'>;
140
+ } & Pick<React_2.HTMLAttributes<HTMLElement>, 'aria-describedby' | 'aria-label' | 'aria-labelledby' | 'onBlur' | 'onFocus' | 'onPointerEnter' | 'onPointerLeave'>;
129
141
 
130
142
  /**
131
143
  * Create the state required to render Tooltip.
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../src/Tooltip.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"../src/","sources":["Tooltip.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from './components/Tooltip/index';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,SAAS,mBAAT,QAAoC,cAApC;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AACA,SAAS,yBAAT,QAA0C,oBAA1C;AAIA;;AAEG;;AACH,OAAO,MAAM,OAAO,GAAoD,KAAK,IAAG;AAC9E,QAAM,KAAK,GAAG,mBAAmB,CAAC,KAAD,CAAjC;AAEA,EAAA,yBAAyB,CAAC,KAAD,CAAzB;AACA,SAAO,sBAAsB,CAAC,KAAD,CAA7B;AACD,CALM;AAOP,OAAO,CAAC,WAAR,GAAsB,SAAtB;AACA,OAAO,CAAC,wBAAR,GAAmC,IAAnC","sourceRoot":""}
1
+ {"version":3,"sources":["components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AACA,SAAS,mBAAT,QAAoC,cAApC;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AACA,SAAS,yBAAT,QAA0C,oBAA1C;AAIA;;AAEG;;AACH,OAAO,MAAM,OAAO,GAAoD,KAAK,IAAG;AAC9E,QAAM,KAAK,GAAG,mBAAmB,CAAC,KAAD,CAAjC;AAEA,EAAA,yBAAyB,CAAC,KAAD,CAAzB;AACA,SAAO,sBAAsB,CAAC,KAAD,CAA7B;AACD,CALM;AAOP,OAAO,CAAC,WAAR,GAAsB,SAAtB;AACA,OAAO,CAAC,wBAAR,GAAmC,IAAnC","sourcesContent":["import * as React from 'react';\nimport { useTooltip_unstable } from './useTooltip';\nimport { renderTooltip_unstable } from './renderTooltip';\nimport { useTooltipStyles_unstable } from './useTooltipStyles';\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> & FluentTriggerComponent = props => {\n const state = useTooltip_unstable(props);\n\n useTooltipStyles_unstable(state);\n return renderTooltip_unstable(state);\n};\n\nTooltip.displayName = 'Tooltip';\nTooltip.isFluentTriggerComponent = true;\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.types.js","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"Tooltip.types.js","sourceRoot":"../src/","sources":["components/Tooltip/Tooltip.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { PositioningShorthand } from '@fluentui/react-positioning';\nimport type { ComponentProps, ComponentState, Slot } 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 trigger of the Tooltip\n */\nexport type TooltipTriggerProps = {\n ref?: React.Ref<never>;\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 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 /**\n * The tooltip can have a single JSX child, or a render function that accepts TooltipTriggerProps.\n *\n * If no child is provided, the tooltip's target must be set with the `positioning` prop, and its\n * visibility must be controlled with the `visible` prop.\n */\n children?:\n | (React.ReactElement & { ref?: React.Ref<unknown> })\n | ((props: TooltipTriggerProps) => React.ReactElement | null)\n | null;\n\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Tooltip/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Tooltip/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './Tooltip';\nexport * from './Tooltip.types';\nexport * from './renderTooltip';\nexport * from './useTooltip';\nexport * from './useTooltipStyles';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Tooltip/private/constants.ts"],"names":[],"mappings":"AAAA;;AAEG;AACH,OAAO,MAAM,WAAW,GAAG,CAApB;AAEP;;;;;;AAMG;;AACH,OAAO,MAAM,mBAAmB,GAAG,CAA5B","sourceRoot":""}
1
+ {"version":3,"sources":["components/Tooltip/private/constants.ts"],"names":[],"mappings":"AAAA;;AAEG;AACH,OAAO,MAAM,WAAW,GAAG,CAApB;AAEP;;;;;;AAMG;;AACH,OAAO,MAAM,mBAAmB,GAAG,CAA5B","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"],"sourceRoot":"../src/"}
@@ -10,7 +10,9 @@ export const renderTooltip_unstable = state => {
10
10
  slots,
11
11
  slotProps
12
12
  } = getSlots(state);
13
- return /*#__PURE__*/React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(slots.content, { ...slotProps.content
13
+ return /*#__PURE__*/React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && /*#__PURE__*/React.createElement(Portal, {
14
+ mountNode: state.mountNode
15
+ }, /*#__PURE__*/React.createElement(slots.content, { ...slotProps.content
14
16
  }, state.withArrow && /*#__PURE__*/React.createElement("div", {
15
17
  ref: state.arrowRef,
16
18
  className: state.arrowClassName
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tooltip/renderTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,MAAT,QAAuB,wBAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,sBAAsB,GAAI,KAAD,IAAwB;AAC5D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAe,KAAf,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EACG,KAAK,CAAC,QADT,EAEG,KAAK,CAAC,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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"],"sourceRoot":"../src/"}
@@ -22,15 +22,16 @@ export const useTooltip_unstable = props => {
22
22
  } = useFluent();
23
23
  const [setDelayTimeout, clearDelayTimeout] = useTimeout();
24
24
  const {
25
- appearance,
25
+ appearance = 'normal',
26
26
  children,
27
27
  content,
28
- withArrow,
29
- positioning,
28
+ withArrow = false,
29
+ positioning = 'above',
30
30
  onVisibleChange,
31
31
  relationship,
32
32
  showDelay = 250,
33
- hideDelay = 250
33
+ hideDelay = 250,
34
+ mountNode
34
35
  } = props;
35
36
  const [visible, setVisibleInternal] = useControllableState({
36
37
  state: props.visible,
@@ -57,6 +58,7 @@ export const useTooltip_unstable = props => {
57
58
  visible,
58
59
  shouldRenderTooltip: visible,
59
60
  appearance,
61
+ mountNode,
60
62
  // Slots
61
63
  components: {
62
64
  content: 'div'
@@ -157,46 +159,37 @@ export const useTooltip_unstable = props => {
157
159
 
158
160
  state.content.onPointerEnter = useMergedEventCallbacks(state.content.onPointerEnter, clearDelayTimeout);
159
161
  state.content.onPointerLeave = useMergedEventCallbacks(state.content.onPointerLeave, onLeaveTrigger);
160
- const child = /*#__PURE__*/React.isValidElement(children) ? getTriggerChild(children) : undefined; // The props to add to the trigger element (child)
161
-
162
- const triggerProps = {
163
- onPointerEnter: useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onPointerEnter, onEnterTrigger),
164
- onPointerLeave: useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onPointerLeave, onLeaveTrigger),
165
- onFocus: useMergedEventCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onFocus, onEnterTrigger),
166
- onBlur: useMergedEventCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onBlur, onLeaveTrigger)
167
- }; // If the target prop is not provided, attach targetRef to the trigger element's ref prop
168
-
169
- const childTargetRef = useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);
170
-
171
- if (popperOptions.target === undefined) {
172
- triggerProps.ref = childTargetRef;
173
- }
162
+ const child = /*#__PURE__*/React.isValidElement(children) ? getTriggerChild(children) : undefined;
163
+ const triggerAriaProps = {};
174
164
 
175
165
  if (relationship === 'label') {
176
- const hasLabel = (child === null || child === void 0 ? void 0 : child.props) && ('aria-label' in child.props || 'aria-labelledby' in child.props);
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 if (!isServerSideRender) {
170
+ triggerAriaProps['aria-labelledby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
177
171
 
178
- if (!hasLabel) {
179
- // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
180
- if (typeof state.content.children === 'string') {
181
- triggerProps['aria-label'] = state.content.children;
182
- } else if (!isServerSideRender) {
183
- triggerProps['aria-labelledby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
184
-
185
- state.shouldRenderTooltip = true;
186
- }
172
+ state.shouldRenderTooltip = true;
187
173
  }
188
174
  } else if (relationship === 'description') {
189
- const hasDescription = (child === null || child === void 0 ? void 0 : child.props) && ('aria-description' in child.props || 'aria-describedby' in child.props);
190
-
191
- if (!hasDescription && !isServerSideRender) {
192
- triggerProps['aria-describedby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
175
+ if (!isServerSideRender) {
176
+ triggerAriaProps['aria-describedby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
193
177
 
194
178
  state.shouldRenderTooltip = true;
195
179
  }
196
- } // Apply the trigger props to the child, either by calling the render function, or cloning with the new props
180
+ }
197
181
 
182
+ const childTargetRef = useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef); // Apply the trigger props to the child, either by calling the render function, or cloning with the new props
198
183
 
199
- state.children = applyTriggerPropsToChildren(children, triggerProps);
184
+ state.children = applyTriggerPropsToChildren(children, { ...triggerAriaProps,
185
+ ...(child === null || child === void 0 ? void 0 : child.props),
186
+ // If the target prop is not provided, attach targetRef to the trigger element's ref prop
187
+ ref: popperOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
188
+ onPointerEnter: useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onPointerEnter, onEnterTrigger),
189
+ onPointerLeave: useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onPointerLeave, onLeaveTrigger),
190
+ onFocus: useMergedEventCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onFocus, onEnterTrigger),
191
+ onBlur: useMergedEventCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onBlur, onLeaveTrigger)
192
+ });
200
193
  return state;
201
194
  };
202
195
  //# sourceMappingURL=useTooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tooltip/useTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,EAA2B,2BAA3B,EAAwD,SAAxD,QAAyE,6BAAzE;AACA,SAAS,cAAT,EAAy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P,MAAY,IAAZ,IAAY,EAAA,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAY,EAAA,CAAE,cAAf,EAA+B,cAA/B,CANmC;AAO1E,IAAA,OAAO,EAAE,uBAAuB,CAAC,CAAA,EAAA,GAAA,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,KAAP,MAAY,IAAZ,IAAY,EAAA,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAY,EAAA,CAAE,OAAf,EAAwB,cAAxB,CAP0C;AAQ1E,IAAA,MAAM,EAAE,uBAAuB,CAAC,CAAA,EAAA,GAAA,KAAK,KAAA,IAAL,IAAA,KAAK,KAAA,KAAA,CAAL,GAAK,KAAA,CAAL,GAAA,KAAK,CAAE,KAAP,MAAY,IAAZ,IAAY,EAAA,KAAA,KAAA,CAAZ,GAAY,KAAA,CAAZ,GAAY,EAAA,CAAE,MAAf,EAAuB,cAAvB;AAR2C,GAAhC,CAA5C;AAWA,SAAO,KAAP;AACD,CAxMM","sourcesContent":["import * as React from 'react';\nimport { mergeArrowOffset, resolvePositioningShorthand, usePopper } from '@fluentui/react-positioning';\nimport { TooltipContext, useFluent } from '@fluentui/react-shared-contexts';\nimport {\n applyTriggerPropsToChildren,\n resolveShorthand,\n useControllableState,\n useMergedEventCallbacks,\n useId,\n useIsomorphicLayoutEffect,\n useIsSSR,\n useMergedRefs,\n useTimeout,\n getTriggerChild,\n} from '@fluentui/react-utilities';\nimport type { TooltipProps, TooltipState, TooltipTriggerProps } from './Tooltip.types';\nimport { arrowHeight, tooltipBorderRadius } from './private/constants';\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 = React.useContext(TooltipContext);\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 popperOptions = {\n enabled: state.visible,\n arrowPadding: 2 * tooltipBorderRadius,\n position: 'above' as const,\n align: 'center' as const,\n offset: [0, 4] as [number, number],\n ...resolvePositioningShorthand(state.positioning),\n };\n\n if (state.withArrow) {\n popperOptions.offset = mergeArrowOffset(popperOptions.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 } = usePopper(popperOptions);\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' || ev.key === 'Esc') {\n thisTooltip.hide();\n }\n };\n\n targetDocument?.addEventListener('keydown', onDocumentKeyDown);\n\n return () => {\n if (context.visibleTooltip === thisTooltip) {\n context.visibleTooltip = undefined;\n }\n\n targetDocument?.removeEventListener('keydown', onDocumentKeyDown);\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 pointer enters the tooltip, and restart it when the mouse leaves.\n // This keeps the tooltip visible when the pointer is moved over it.\n state.content.onPointerEnter = useMergedEventCallbacks(state.content.onPointerEnter, clearDelayTimeout);\n state.content.onPointerLeave = useMergedEventCallbacks(state.content.onPointerLeave, onLeaveTrigger);\n\n const child = React.isValidElement(children) ? getTriggerChild(children) : undefined;\n\n const triggerAriaProps: Pick<TooltipTriggerProps, '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 if (!isServerSideRender) {\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 if (!isServerSideRender) {\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\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<TooltipTriggerProps>(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: popperOptions.target === undefined ? childTargetRef : child?.ref,\n onPointerEnter: useMergedEventCallbacks(child?.props?.onPointerEnter, onEnterTrigger),\n onPointerLeave: useMergedEventCallbacks(child?.props?.onPointerLeave, onLeaveTrigger),\n onFocus: useMergedEventCallbacks(child?.props?.onFocus, onEnterTrigger),\n onBlur: useMergedEventCallbacks(child?.props?.onBlur, onLeaveTrigger),\n });\n\n return state;\n};\n"],"sourceRoot":"../src/"}
@@ -2,7 +2,14 @@ import { shorthands, __styles, mergeClasses } from '@griffel/react';
2
2
  import { createArrowStyles } from '@fluentui/react-positioning';
3
3
  import { tokens } from '@fluentui/react-theme';
4
4
  import { arrowHeight } from './private/constants';
5
+ /**
6
+ * @deprecated Use `tooltipClassNames.root` instead.
7
+ */
8
+
5
9
  export const tooltipClassName = 'fui-Tooltip';
10
+ export const tooltipClassNames = {
11
+ content: 'fui-Tooltip__content'
12
+ };
6
13
  /**
7
14
  * Styles for the tooltip
8
15
  */
@@ -88,7 +95,9 @@ const useStyles = /*#__PURE__*/__styles({
88
95
 
89
96
  export const useTooltipStyles_unstable = state => {
90
97
  const styles = useStyles();
91
- state.content.className = mergeClasses(tooltipClassName, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
98
+ state.content.className = mergeClasses(
99
+ /* eslint-disable-next-line deprecation/deprecation */
100
+ tooltipClassName, tooltipClassNames.content, styles.root, state.appearance === 'inverted' && styles.inverted, state.visible && styles.visible, state.content.className);
92
101
  state.arrowClassName = styles.arrow;
93
102
  return state;
94
103
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tooltip/useTooltipStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,YAAiC,YAAjC,QAAqD,gBAArD;AACA,SAAS,iBAAT,QAAkC,6BAAlC;AACA,SAAS,MAAT,QAAuB,uBAAvB;AACA,SAAS,WAAT,QAA4B,qBAA5B;AAGA,OAAO,MAAM,gBAAgB,GAAG,aAAzB;AAEP;;AAEG;;AACH,MAAM,SAAS,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAlB;AAkCA;;AAEG;;;AACH,OAAO,MAAM,yBAAyB,GAAI,KAAD,IAAsC;AAC7E,QAAM,MAAM,GAAG,SAAS,EAAxB;AAEA,EAAA,KAAK,CAAC,OAAN,CAAc,SAAd,GAA0B,YAAY;AACpC;AACA,EAAA,gBAFoC,EAGpC,iBAAiB,CAAC,OAHkB,EAIpC,MAAM,CAAC,IAJ6B,EAKpC,KAAK,CAAC,UAAN,KAAqB,UAArB,IAAmC,MAAM,CAAC,QALN,EAMpC,KAAK,CAAC,OAAN,IAAiB,MAAM,CAAC,OANY,EAOpC,KAAK,CAAC,OAAN,CAAc,SAPsB,CAAtC;AAUA,EAAA,KAAK,CAAC,cAAN,GAAuB,MAAM,CAAC,KAA9B;AAEA,SAAO,KAAP;AACD,CAhBM","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';\nimport type { TooltipSlots, TooltipState } from './Tooltip.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\n/**\n * @deprecated Use `tooltipClassNames.root` instead.\n */\nexport const tooltipClassName = 'fui-Tooltip';\nexport const tooltipClassNames: SlotClassNames<TooltipSlots> = {\n content: 'fui-Tooltip__content',\n};\n\n/**\n * Styles for the tooltip\n */\nconst useStyles = makeStyles({\n root: {\n display: 'none',\n boxSizing: 'border-box',\n maxWidth: '240px',\n cursor: 'default',\n fontFamily: tokens.fontFamilyBase,\n fontSize: tokens.fontSizeBase200,\n lineHeight: tokens.lineHeightBase200,\n\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStroke),\n ...shorthands.padding('4px', '11px', '6px', '11px'), // '5px 12px 7px 12px' minus the border width '1px'\n backgroundColor: tokens.colorNeutralBackground1,\n color: tokens.colorNeutralForeground1,\n\n // TODO need to add versions of tokens.alias.shadow.shadow8, etc. that work with filter\n filter:\n `drop-shadow(0 0 2px ${tokens.colorNeutralShadowAmbient}) ` +\n `drop-shadow(0 4px 8px ${tokens.colorNeutralShadowKey})`,\n },\n\n visible: {\n display: 'block',\n },\n\n inverted: {\n backgroundColor: tokens.colorNeutralBackgroundInverted,\n color: tokens.colorNeutralForegroundInverted,\n },\n\n arrow: createArrowStyles({ arrowHeight }),\n});\n\n/**\n * Apply styling to the Tooltip slots based on the state\n */\nexport const useTooltipStyles_unstable = (state: TooltipState): TooltipState => {\n const styles = useStyles();\n\n state.content.className = mergeClasses(\n /* eslint-disable-next-line deprecation/deprecation */\n tooltipClassName,\n tooltipClassNames.content,\n styles.root,\n state.appearance === 'inverted' && styles.inverted,\n state.visible && styles.visible,\n state.content.className,\n );\n\n state.arrowClassName = styles.arrow;\n\n return state;\n};\n"],"sourceRoot":"../src/"}
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export * from './Tooltip';
1
+ export { Tooltip, renderTooltip_unstable, // eslint-disable-next-line deprecation/deprecation
2
+ tooltipClassName, tooltipClassNames, useTooltipStyles_unstable, useTooltip_unstable } from './Tooltip';
2
3
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,SACE,OADF,EAEE,sBAFF,EAGE;AACA,gBAJF,EAKE,iBALF,EAME,yBANF,EAOE,mBAPF,QAQO,WARP","sourcesContent":["export {\n Tooltip,\n renderTooltip_unstable,\n // eslint-disable-next-line deprecation/deprecation\n tooltipClassName,\n tooltipClassNames,\n useTooltipStyles_unstable,\n useTooltip_unstable,\n} from './Tooltip';\nexport type { OnVisibleChangeData, TooltipProps, TooltipSlots, TooltipState, TooltipTriggerProps } from './Tooltip';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/Tooltip.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA","sourceRoot":""}
1
+ {"version":3,"sources":["Tooltip.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Tooltip/index';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,iBAAA,CAAA;;AACA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAIA;;AAEG;;;AACI,MAAM,OAAO,GAAoD,KAAK,IAAG;AAC9E,QAAM,KAAK,GAAG,YAAA,CAAA,mBAAA,CAAoB,KAApB,CAAd;AAEA,EAAA,kBAAA,CAAA,yBAAA,CAA0B,KAA1B;AACA,SAAO,eAAA,CAAA,sBAAA,CAAuB,KAAvB,CAAP;AACD,CALM;;AAAM,OAAA,CAAA,OAAA,GAAO,OAAP;AAOb,OAAA,CAAA,OAAA,CAAQ,WAAR,GAAsB,SAAtB;AACA,OAAA,CAAA,OAAA,CAAQ,wBAAR,GAAmC,IAAnC","sourceRoot":""}
1
+ {"version":3,"sources":["components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,iBAAA,CAAA;;AACA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAIA;;AAEG;;;AACI,MAAM,OAAO,GAAoD,KAAK,IAAG;AAC9E,QAAM,KAAK,GAAG,YAAA,CAAA,mBAAA,CAAoB,KAApB,CAAd;AAEA,EAAA,kBAAA,CAAA,yBAAA,CAA0B,KAA1B;AACA,SAAO,eAAA,CAAA,sBAAA,CAAuB,KAAvB,CAAP;AACD,CALM;;AAAM,OAAA,CAAA,OAAA,GAAO,OAAP;AAOb,OAAA,CAAA,OAAA,CAAQ,WAAR,GAAsB,SAAtB;AACA,OAAA,CAAA,OAAA,CAAQ,wBAAR,GAAmC,IAAnC","sourcesContent":["import * as React from 'react';\nimport { useTooltip_unstable } from './useTooltip';\nimport { renderTooltip_unstable } from './renderTooltip';\nimport { useTooltipStyles_unstable } from './useTooltipStyles';\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> & FluentTriggerComponent = props => {\n const state = useTooltip_unstable(props);\n\n useTooltipStyles_unstable(state);\n return renderTooltip_unstable(state);\n};\n\nTooltip.displayName = 'Tooltip';\nTooltip.isFluentTriggerComponent = true;\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tooltip/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,WAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA","sourceRoot":""}
1
+ {"version":3,"sources":["components/Tooltip/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,WAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Tooltip';\nexport * from './Tooltip.types';\nexport * from './renderTooltip';\nexport * from './useTooltip';\nexport * from './useTooltipStyles';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Tooltip/private/constants.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACU,OAAA,CAAA,WAAA,GAAc,CAAd;AAEb;;;;;;AAMG;;AACU,OAAA,CAAA,mBAAA,GAAsB,CAAtB","sourceRoot":""}
1
+ {"version":3,"sources":["components/Tooltip/private/constants.ts"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACU,OAAA,CAAA,WAAA,GAAc,CAAd;AAEb;;;;;;AAMG;;AACU,OAAA,CAAA,mBAAA,GAAsB,CAAtB","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"],"sourceRoot":"../src/"}
@@ -20,7 +20,9 @@ const renderTooltip_unstable = state => {
20
20
  slots,
21
21
  slotProps
22
22
  } = react_utilities_1.getSlots(state);
23
- return React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && React.createElement(react_portal_1.Portal, null, React.createElement(slots.content, { ...slotProps.content
23
+ return React.createElement(React.Fragment, null, state.children, state.shouldRenderTooltip && React.createElement(react_portal_1.Portal, {
24
+ mountNode: state.mountNode
25
+ }, React.createElement(slots.content, { ...slotProps.content
24
26
  }, state.withArrow && React.createElement("div", {
25
27
  ref: state.arrowRef,
26
28
  className: state.arrowClassName
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Tooltip/renderTooltip.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,sBAAsB,GAAI,KAAD,IAAwB;AAC5D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,iBAAA,CAAA,QAAA,CAAuB,KAAvB,CAA7B;AAEA,SACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EACG,KAAK,CAAC,QADT,EAEG,KAAK,CAAC,mBAAN,IACC,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO,IAAP,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;AAAf,GAAd,EACG,KAAK,CAAC,SAAN,IAAmB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAK,IAAA,GAAG,EAAE,KAAK,CAAC,QAAhB;AAA0B,IAAA,SAAS,EAAE,KAAK,CAAC;AAA3C,GAAA,CADtB,EAEG,KAAK,CAAC,OAAN,CAAc,QAFjB,CADF,CAHJ,CADF;AAaD,CAhBM;;AAAM,OAAA,CAAA,sBAAA,GAAsB,sBAAtB","sourceRoot":""}
1
+ {"version":3,"sources":["components/Tooltip/renderTooltip.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,sBAAsB,GAAI,KAAD,IAAwB;AAC5D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,iBAAA,CAAA,QAAA,CAAuB,KAAvB,CAA7B;AAEA,SACE,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EACG,KAAK,CAAC,QADT,EAEG,KAAK,CAAC,mBAAN,IACC,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO;AAAC,IAAA,SAAS,EAAE,KAAK,CAAC;AAAlB,GAAP,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;AAAf,GAAd,EACG,KAAK,CAAC,SAAN,IAAmB,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA;AAAK,IAAA,GAAG,EAAE,KAAK,CAAC,QAAhB;AAA0B,IAAA,SAAS,EAAE,KAAK,CAAC;AAA3C,GAAA,CADtB,EAEG,KAAK,CAAC,OAAN,CAAc,QAFjB,CADF,CAHJ,CADF;AAaD,CAhBM;;AAAM,OAAA,CAAA,sBAAA,GAAsB,sBAAtB","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"],"sourceRoot":"../src/"}
@@ -34,15 +34,16 @@ const useTooltip_unstable = props => {
34
34
  } = react_shared_contexts_1.useFluent();
35
35
  const [setDelayTimeout, clearDelayTimeout] = react_utilities_1.useTimeout();
36
36
  const {
37
- appearance,
37
+ appearance = 'normal',
38
38
  children,
39
39
  content,
40
- withArrow,
41
- positioning,
40
+ withArrow = false,
41
+ positioning = 'above',
42
42
  onVisibleChange,
43
43
  relationship,
44
44
  showDelay = 250,
45
- hideDelay = 250
45
+ hideDelay = 250,
46
+ mountNode
46
47
  } = props;
47
48
  const [visible, setVisibleInternal] = react_utilities_1.useControllableState({
48
49
  state: props.visible,
@@ -69,6 +70,7 @@ const useTooltip_unstable = props => {
69
70
  visible,
70
71
  shouldRenderTooltip: visible,
71
72
  appearance,
73
+ mountNode,
72
74
  // Slots
73
75
  components: {
74
76
  content: 'div'
@@ -169,46 +171,37 @@ const useTooltip_unstable = props => {
169
171
 
170
172
  state.content.onPointerEnter = react_utilities_1.useMergedEventCallbacks(state.content.onPointerEnter, clearDelayTimeout);
171
173
  state.content.onPointerLeave = react_utilities_1.useMergedEventCallbacks(state.content.onPointerLeave, onLeaveTrigger);
172
- const child = React.isValidElement(children) ? react_utilities_1.getTriggerChild(children) : undefined; // The props to add to the trigger element (child)
173
-
174
- const triggerProps = {
175
- onPointerEnter: react_utilities_1.useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onPointerEnter, onEnterTrigger),
176
- onPointerLeave: react_utilities_1.useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onPointerLeave, onLeaveTrigger),
177
- onFocus: react_utilities_1.useMergedEventCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onFocus, onEnterTrigger),
178
- onBlur: react_utilities_1.useMergedEventCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onBlur, onLeaveTrigger)
179
- }; // If the target prop is not provided, attach targetRef to the trigger element's ref prop
180
-
181
- const childTargetRef = react_utilities_1.useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef);
182
-
183
- if (popperOptions.target === undefined) {
184
- triggerProps.ref = childTargetRef;
185
- }
174
+ const child = React.isValidElement(children) ? react_utilities_1.getTriggerChild(children) : undefined;
175
+ const triggerAriaProps = {};
186
176
 
187
177
  if (relationship === 'label') {
188
- const hasLabel = (child === null || child === void 0 ? void 0 : child.props) && ('aria-label' in child.props || 'aria-labelledby' in child.props);
178
+ // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
179
+ if (typeof state.content.children === 'string') {
180
+ triggerAriaProps['aria-label'] = state.content.children;
181
+ } else if (!isServerSideRender) {
182
+ triggerAriaProps['aria-labelledby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
189
183
 
190
- if (!hasLabel) {
191
- // aria-label only works if the content is a string. Otherwise, need to use aria-labelledby.
192
- if (typeof state.content.children === 'string') {
193
- triggerProps['aria-label'] = state.content.children;
194
- } else if (!isServerSideRender) {
195
- triggerProps['aria-labelledby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-labelledby refers to a valid element
196
-
197
- state.shouldRenderTooltip = true;
198
- }
184
+ state.shouldRenderTooltip = true;
199
185
  }
200
186
  } else if (relationship === 'description') {
201
- const hasDescription = (child === null || child === void 0 ? void 0 : child.props) && ('aria-description' in child.props || 'aria-describedby' in child.props);
202
-
203
- if (!hasDescription && !isServerSideRender) {
204
- triggerProps['aria-describedby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
187
+ if (!isServerSideRender) {
188
+ triggerAriaProps['aria-describedby'] = state.content.id; // Always render the tooltip even if hidden, so that aria-describedby refers to a valid element
205
189
 
206
190
  state.shouldRenderTooltip = true;
207
191
  }
208
- } // Apply the trigger props to the child, either by calling the render function, or cloning with the new props
192
+ }
209
193
 
194
+ const childTargetRef = react_utilities_1.useMergedRefs(child === null || child === void 0 ? void 0 : child.ref, targetRef); // Apply the trigger props to the child, either by calling the render function, or cloning with the new props
210
195
 
211
- state.children = react_utilities_1.applyTriggerPropsToChildren(children, triggerProps);
196
+ state.children = react_utilities_1.applyTriggerPropsToChildren(children, { ...triggerAriaProps,
197
+ ...(child === null || child === void 0 ? void 0 : child.props),
198
+ // If the target prop is not provided, attach targetRef to the trigger element's ref prop
199
+ ref: popperOptions.target === undefined ? childTargetRef : child === null || child === void 0 ? void 0 : child.ref,
200
+ onPointerEnter: react_utilities_1.useMergedEventCallbacks((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.onPointerEnter, onEnterTrigger),
201
+ onPointerLeave: react_utilities_1.useMergedEventCallbacks((_b = child === null || child === void 0 ? void 0 : child.props) === null || _b === void 0 ? void 0 : _b.onPointerLeave, onLeaveTrigger),
202
+ onFocus: react_utilities_1.useMergedEventCallbacks((_c = child === null || child === void 0 ? void 0 : child.props) === null || _c === void 0 ? void 0 : _c.onFocus, onEnterTrigger),
203
+ onBlur: react_utilities_1.useMergedEventCallbacks((_d = child === null || child === void 0 ? void 0 : child.props) === null || _d === void 0 ? void 0 : _d.onBlur, onLeaveTrigger)
204
+ });
212
205
  return state;
213
206
  };
214
207