@zendeskgarden/react-tooltips 9.6.0 → 9.7.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.
- package/dist/esm/elements/Tooltip.js +14 -8
- package/dist/esm/styled/StyledParagraph.js +1 -1
- package/dist/esm/styled/StyledTitle.js +1 -1
- package/dist/esm/styled/StyledTooltip.js +1 -1
- package/dist/index.cjs.js +16 -10
- package/dist/typings/elements/Tooltip.d.ts +2 -1
- package/dist/typings/styled/StyledTooltip.d.ts +1 -1
- package/dist/typings/types/index.d.ts +2 -0
- package/package.json +7 -4
|
@@ -16,7 +16,7 @@ import '../styled/StyledTitle.js';
|
|
|
16
16
|
import { StyledTooltip } from '../styled/StyledTooltip.js';
|
|
17
17
|
import { StyledTooltipWrapper } from '../styled/StyledTooltipWrapper.js';
|
|
18
18
|
import { PLACEMENT, SIZE, TYPE } from '../types/index.js';
|
|
19
|
-
import { useFloating, platform, autoPlacement, autoUpdate } from '@floating-ui/react-dom';
|
|
19
|
+
import { useFloating, platform, autoPlacement, flip, autoUpdate } from '@floating-ui/react-dom';
|
|
20
20
|
import { DEFAULT_THEME, getFloatingPlacements } from '@zendeskgarden/react-theming';
|
|
21
21
|
import { toSize } from './utils.js';
|
|
22
22
|
import { Paragraph } from './Paragraph.js';
|
|
@@ -31,6 +31,7 @@ const TooltipComponent = _ref => {
|
|
|
31
31
|
content,
|
|
32
32
|
refKey,
|
|
33
33
|
placement: _placement,
|
|
34
|
+
fallbackPlacements: _fallbackPlacements,
|
|
34
35
|
children,
|
|
35
36
|
hasArrow,
|
|
36
37
|
size,
|
|
@@ -54,10 +55,11 @@ const TooltipComponent = _ref => {
|
|
|
54
55
|
} = useTooltip({
|
|
55
56
|
id,
|
|
56
57
|
delayMilliseconds: delayMS,
|
|
57
|
-
isVisible: isInitialVisible
|
|
58
|
+
isVisible: isInitialVisible,
|
|
59
|
+
triggerRef
|
|
58
60
|
});
|
|
59
61
|
const controlledIsVisible = getControlledValue(externalIsVisible, isVisible);
|
|
60
|
-
const [floatingPlacement] = getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement);
|
|
62
|
+
const [floatingPlacement, fallbackPlacements] = getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement, _fallbackPlacements);
|
|
61
63
|
const {
|
|
62
64
|
refs,
|
|
63
65
|
placement,
|
|
@@ -75,7 +77,9 @@ const TooltipComponent = _ref => {
|
|
|
75
77
|
floating: floatingRef?.current
|
|
76
78
|
},
|
|
77
79
|
placement: floatingPlacement,
|
|
78
|
-
middleware: _placement === 'auto' ? [autoPlacement()] :
|
|
80
|
+
middleware: _placement === 'auto' ? [autoPlacement()] : [flip({
|
|
81
|
+
fallbackPlacements
|
|
82
|
+
})]
|
|
79
83
|
});
|
|
80
84
|
useEffect(() => {
|
|
81
85
|
let cleanup;
|
|
@@ -94,16 +98,17 @@ const TooltipComponent = _ref => {
|
|
|
94
98
|
},
|
|
95
99
|
$zIndex: zIndex,
|
|
96
100
|
"aria-hidden": !controlledIsVisible
|
|
97
|
-
}, React.createElement(StyledTooltip,
|
|
98
|
-
'aria-hidden': !controlledIsVisible,
|
|
101
|
+
}, React.createElement(StyledTooltip, Object.assign({
|
|
99
102
|
$hasArrow: hasArrow,
|
|
100
103
|
$placement: placement,
|
|
101
104
|
$size: toSize(size, type),
|
|
102
|
-
$type: type
|
|
105
|
+
$type: type
|
|
106
|
+
}, getTooltipProps({
|
|
107
|
+
'aria-hidden': !controlledIsVisible,
|
|
103
108
|
onBlur: composeEventHandlers(onBlur, () => closeTooltip(0)),
|
|
104
109
|
onFocus: composeEventHandlers(onFocus, openTooltip),
|
|
105
110
|
...props
|
|
106
|
-
}), content));
|
|
111
|
+
})), content));
|
|
107
112
|
return React.createElement(React.Fragment, null, cloneElement(Child, getTriggerProps({
|
|
108
113
|
...Child.props,
|
|
109
114
|
[refKey]: mergeRefs([triggerRef, Child.ref ? Child.ref : null])
|
|
@@ -117,6 +122,7 @@ TooltipComponent.propTypes = {
|
|
|
117
122
|
id: PropTypes.string,
|
|
118
123
|
content: PropTypes.node.isRequired,
|
|
119
124
|
placement: PropTypes.oneOf(PLACEMENT),
|
|
125
|
+
fallbackPlacements: PropTypes.arrayOf(PropTypes.oneOf(PLACEMENT.filter(placement => placement !== 'auto'))),
|
|
120
126
|
size: PropTypes.oneOf(SIZE),
|
|
121
127
|
type: PropTypes.oneOf(TYPE),
|
|
122
128
|
zIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -10,7 +10,7 @@ import { componentStyles } from '@zendeskgarden/react-theming';
|
|
|
10
10
|
const COMPONENT_ID = 'tooltip.paragraph';
|
|
11
11
|
const StyledParagraph = styled.p.attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID,
|
|
13
|
-
'data-garden-version': '9.
|
|
13
|
+
'data-garden-version': '9.7.1'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledParagraph",
|
|
16
16
|
componentId: "sc-wuqkfc-0"
|
|
@@ -10,7 +10,7 @@ import { componentStyles } from '@zendeskgarden/react-theming';
|
|
|
10
10
|
const COMPONENT_ID = 'tooltip.title';
|
|
11
11
|
const StyledTitle = styled.strong.attrs({
|
|
12
12
|
'data-garden-id': COMPONENT_ID,
|
|
13
|
-
'data-garden-version': '9.
|
|
13
|
+
'data-garden-version': '9.7.1'
|
|
14
14
|
}).withConfig({
|
|
15
15
|
displayName: "StyledTitle",
|
|
16
16
|
componentId: "sc-vnjcvz-0"
|
|
@@ -134,7 +134,7 @@ const colorStyles = _ref2 => {
|
|
|
134
134
|
};
|
|
135
135
|
const StyledTooltip = styled.div.attrs({
|
|
136
136
|
'data-garden-id': COMPONENT_ID,
|
|
137
|
-
'data-garden-version': '9.
|
|
137
|
+
'data-garden-version': '9.7.1'
|
|
138
138
|
}).withConfig({
|
|
139
139
|
displayName: "StyledTooltip",
|
|
140
140
|
componentId: "sc-gzzjq4-0"
|
package/dist/index.cjs.js
CHANGED
|
@@ -25,7 +25,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
|
25
25
|
const COMPONENT_ID$2 = 'tooltip.paragraph';
|
|
26
26
|
const StyledParagraph = styled__default.default.p.attrs({
|
|
27
27
|
'data-garden-id': COMPONENT_ID$2,
|
|
28
|
-
'data-garden-version': '9.
|
|
28
|
+
'data-garden-version': '9.7.1'
|
|
29
29
|
}).withConfig({
|
|
30
30
|
displayName: "StyledParagraph",
|
|
31
31
|
componentId: "sc-wuqkfc-0"
|
|
@@ -34,7 +34,7 @@ const StyledParagraph = styled__default.default.p.attrs({
|
|
|
34
34
|
const COMPONENT_ID$1 = 'tooltip.title';
|
|
35
35
|
const StyledTitle = styled__default.default.strong.attrs({
|
|
36
36
|
'data-garden-id': COMPONENT_ID$1,
|
|
37
|
-
'data-garden-version': '9.
|
|
37
|
+
'data-garden-version': '9.7.1'
|
|
38
38
|
}).withConfig({
|
|
39
39
|
displayName: "StyledTitle",
|
|
40
40
|
componentId: "sc-vnjcvz-0"
|
|
@@ -165,7 +165,7 @@ const colorStyles = _ref2 => {
|
|
|
165
165
|
};
|
|
166
166
|
const StyledTooltip = styled__default.default.div.attrs({
|
|
167
167
|
'data-garden-id': COMPONENT_ID,
|
|
168
|
-
'data-garden-version': '9.
|
|
168
|
+
'data-garden-version': '9.7.1'
|
|
169
169
|
}).withConfig({
|
|
170
170
|
displayName: "StyledTooltip",
|
|
171
171
|
componentId: "sc-gzzjq4-0"
|
|
@@ -207,6 +207,7 @@ const TooltipComponent = _ref => {
|
|
|
207
207
|
content,
|
|
208
208
|
refKey,
|
|
209
209
|
placement: _placement,
|
|
210
|
+
fallbackPlacements: _fallbackPlacements,
|
|
210
211
|
children,
|
|
211
212
|
hasArrow,
|
|
212
213
|
size,
|
|
@@ -230,10 +231,11 @@ const TooltipComponent = _ref => {
|
|
|
230
231
|
} = containerTooltip.useTooltip({
|
|
231
232
|
id,
|
|
232
233
|
delayMilliseconds: delayMS,
|
|
233
|
-
isVisible: isInitialVisible
|
|
234
|
+
isVisible: isInitialVisible,
|
|
235
|
+
triggerRef
|
|
234
236
|
});
|
|
235
237
|
const controlledIsVisible = containerUtilities.getControlledValue(externalIsVisible, isVisible);
|
|
236
|
-
const [floatingPlacement] = reactTheming.getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement);
|
|
238
|
+
const [floatingPlacement, fallbackPlacements] = reactTheming.getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement, _fallbackPlacements);
|
|
237
239
|
const {
|
|
238
240
|
refs,
|
|
239
241
|
placement,
|
|
@@ -251,7 +253,9 @@ const TooltipComponent = _ref => {
|
|
|
251
253
|
floating: floatingRef?.current
|
|
252
254
|
},
|
|
253
255
|
placement: floatingPlacement,
|
|
254
|
-
middleware: _placement === 'auto' ? [reactDom.autoPlacement()] :
|
|
256
|
+
middleware: _placement === 'auto' ? [reactDom.autoPlacement()] : [reactDom.flip({
|
|
257
|
+
fallbackPlacements
|
|
258
|
+
})]
|
|
255
259
|
});
|
|
256
260
|
React.useEffect(() => {
|
|
257
261
|
let cleanup;
|
|
@@ -270,16 +274,17 @@ const TooltipComponent = _ref => {
|
|
|
270
274
|
},
|
|
271
275
|
$zIndex: zIndex,
|
|
272
276
|
"aria-hidden": !controlledIsVisible
|
|
273
|
-
}, React__default.default.createElement(StyledTooltip,
|
|
274
|
-
'aria-hidden': !controlledIsVisible,
|
|
277
|
+
}, React__default.default.createElement(StyledTooltip, Object.assign({
|
|
275
278
|
$hasArrow: hasArrow,
|
|
276
279
|
$placement: placement,
|
|
277
280
|
$size: toSize(size, type),
|
|
278
|
-
$type: type
|
|
281
|
+
$type: type
|
|
282
|
+
}, getTooltipProps({
|
|
283
|
+
'aria-hidden': !controlledIsVisible,
|
|
279
284
|
onBlur: containerUtilities.composeEventHandlers(onBlur, () => closeTooltip(0)),
|
|
280
285
|
onFocus: containerUtilities.composeEventHandlers(onFocus, openTooltip),
|
|
281
286
|
...props
|
|
282
|
-
}), content));
|
|
287
|
+
})), content));
|
|
283
288
|
return React__default.default.createElement(React__default.default.Fragment, null, React.cloneElement(Child, getTriggerProps({
|
|
284
289
|
...Child.props,
|
|
285
290
|
[refKey]: reactMergeRefs.mergeRefs([triggerRef, Child.ref ? Child.ref : null])
|
|
@@ -293,6 +298,7 @@ TooltipComponent.propTypes = {
|
|
|
293
298
|
id: PropTypes__default.default.string,
|
|
294
299
|
content: PropTypes__default.default.node.isRequired,
|
|
295
300
|
placement: PropTypes__default.default.oneOf(PLACEMENT),
|
|
301
|
+
fallbackPlacements: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOf(PLACEMENT.filter(placement => placement !== 'auto'))),
|
|
296
302
|
size: PropTypes__default.default.oneOf(SIZE),
|
|
297
303
|
type: PropTypes__default.default.oneOf(TYPE),
|
|
298
304
|
zIndex: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
@@ -11,7 +11,7 @@ import { Paragraph } from './Paragraph';
|
|
|
11
11
|
import { Title } from './Title';
|
|
12
12
|
export declare const PLACEMENT_DEFAULT = "top";
|
|
13
13
|
export declare const TooltipComponent: {
|
|
14
|
-
({ id, delayMS, isInitialVisible, content, refKey, placement: _placement, children, hasArrow, size, type, appendToNode, zIndex, isVisible: externalIsVisible, onFocus, onBlur, ...props }: ITooltipProps): React.JSX.Element;
|
|
14
|
+
({ id, delayMS, isInitialVisible, content, refKey, placement: _placement, fallbackPlacements: _fallbackPlacements, children, hasArrow, size, type, appendToNode, zIndex, isVisible: externalIsVisible, onFocus, onBlur, ...props }: ITooltipProps): React.JSX.Element;
|
|
15
15
|
displayName: string;
|
|
16
16
|
propTypes: {
|
|
17
17
|
appendToNode: PropTypes.Requireable<any>;
|
|
@@ -20,6 +20,7 @@ export declare const TooltipComponent: {
|
|
|
20
20
|
id: PropTypes.Requireable<string>;
|
|
21
21
|
content: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
22
22
|
placement: PropTypes.Requireable<"top" | "auto" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "end" | "end-top" | "end-bottom" | "start" | "start-top" | "start-bottom">;
|
|
23
|
+
fallbackPlacements: PropTypes.Requireable<("top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "end" | "end-top" | "end-bottom" | "start" | "start-top" | "start-bottom" | null | undefined)[]>;
|
|
23
24
|
size: PropTypes.Requireable<"small" | "medium" | "large" | "extra-large">;
|
|
24
25
|
type: PropTypes.Requireable<"light" | "dark">;
|
|
25
26
|
zIndex: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
@@ -10,7 +10,7 @@ interface IStyledTooltipProps {
|
|
|
10
10
|
$hasArrow: ITooltipProps['hasArrow'];
|
|
11
11
|
$placement: Placement;
|
|
12
12
|
$size: NonNullable<ITooltipProps['size']>;
|
|
13
|
-
$type:
|
|
13
|
+
$type: ITooltipProps['type'];
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Accepts all `<div>` props
|
|
@@ -18,6 +18,8 @@ export interface ITooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'con
|
|
|
18
18
|
delayMS?: number;
|
|
19
19
|
/** Defines the content of the tooltip */
|
|
20
20
|
content: ReactNode;
|
|
21
|
+
/** Provides a list of acceptable fallback placements */
|
|
22
|
+
fallbackPlacements?: Exclude<GardenPlacement, 'auto'>[];
|
|
21
23
|
/** Adjusts the placement of the tooltip */
|
|
22
24
|
placement?: GardenPlacement;
|
|
23
25
|
/** Adjusts the padding and font size */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-tooltips",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.1",
|
|
4
4
|
"description": "Collection of components and render prop containers relating to Tooltips in the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"types": "dist/typings/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@floating-ui/react-dom": "^2.0.0",
|
|
25
|
-
"@zendeskgarden/container-tooltip": "^
|
|
25
|
+
"@zendeskgarden/container-tooltip": "^2.0.0",
|
|
26
26
|
"@zendeskgarden/container-utilities": "^2.0.0",
|
|
27
27
|
"polished": "^4.3.1",
|
|
28
28
|
"prop-types": "^15.5.7",
|
|
@@ -35,7 +35,10 @@
|
|
|
35
35
|
"styled-components": "^5.3.1 || ^6.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@zendeskgarden/react-
|
|
38
|
+
"@zendeskgarden/react-buttons": "^9.7.1",
|
|
39
|
+
"@zendeskgarden/react-dropdowns": "^9.7.1",
|
|
40
|
+
"@zendeskgarden/react-grid": "^9.7.1",
|
|
41
|
+
"@zendeskgarden/react-theming": "^9.7.1"
|
|
39
42
|
},
|
|
40
43
|
"keywords": [
|
|
41
44
|
"components",
|
|
@@ -47,5 +50,5 @@
|
|
|
47
50
|
"access": "public"
|
|
48
51
|
},
|
|
49
52
|
"zendeskgarden:src": "src/index.ts",
|
|
50
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "df6d9dc7ac384673ecbf8fd5adb954fab8681974"
|
|
51
54
|
}
|