@zendeskgarden/react-tooltips 9.6.0 → 9.7.0

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.
@@ -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,
@@ -57,7 +58,7 @@ const TooltipComponent = _ref => {
57
58
  isVisible: isInitialVisible
58
59
  });
59
60
  const controlledIsVisible = getControlledValue(externalIsVisible, isVisible);
60
- const [floatingPlacement] = getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement);
61
+ const [floatingPlacement, fallbackPlacements] = getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement, _fallbackPlacements);
61
62
  const {
62
63
  refs,
63
64
  placement,
@@ -75,7 +76,9 @@ const TooltipComponent = _ref => {
75
76
  floating: floatingRef?.current
76
77
  },
77
78
  placement: floatingPlacement,
78
- middleware: _placement === 'auto' ? [autoPlacement()] : undefined
79
+ middleware: _placement === 'auto' ? [autoPlacement()] : [flip({
80
+ fallbackPlacements
81
+ })]
79
82
  });
80
83
  useEffect(() => {
81
84
  let cleanup;
@@ -117,6 +120,7 @@ TooltipComponent.propTypes = {
117
120
  id: PropTypes.string,
118
121
  content: PropTypes.node.isRequired,
119
122
  placement: PropTypes.oneOf(PLACEMENT),
123
+ fallbackPlacements: PropTypes.arrayOf(PropTypes.oneOf(PLACEMENT.filter(placement => placement !== 'auto'))),
120
124
  size: PropTypes.oneOf(SIZE),
121
125
  type: PropTypes.oneOf(TYPE),
122
126
  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.6.0'
13
+ 'data-garden-version': '9.7.0'
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.6.0'
13
+ 'data-garden-version': '9.7.0'
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.6.0'
137
+ 'data-garden-version': '9.7.0'
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.6.0'
28
+ 'data-garden-version': '9.7.0'
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.6.0'
37
+ 'data-garden-version': '9.7.0'
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.6.0'
168
+ 'data-garden-version': '9.7.0'
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,
@@ -233,7 +234,7 @@ const TooltipComponent = _ref => {
233
234
  isVisible: isInitialVisible
234
235
  });
235
236
  const controlledIsVisible = containerUtilities.getControlledValue(externalIsVisible, isVisible);
236
- const [floatingPlacement] = reactTheming.getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement);
237
+ const [floatingPlacement, fallbackPlacements] = reactTheming.getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement, _fallbackPlacements);
237
238
  const {
238
239
  refs,
239
240
  placement,
@@ -251,7 +252,9 @@ const TooltipComponent = _ref => {
251
252
  floating: floatingRef?.current
252
253
  },
253
254
  placement: floatingPlacement,
254
- middleware: _placement === 'auto' ? [reactDom.autoPlacement()] : undefined
255
+ middleware: _placement === 'auto' ? [reactDom.autoPlacement()] : [reactDom.flip({
256
+ fallbackPlacements
257
+ })]
255
258
  });
256
259
  React.useEffect(() => {
257
260
  let cleanup;
@@ -293,6 +296,7 @@ TooltipComponent.propTypes = {
293
296
  id: PropTypes__default.default.string,
294
297
  content: PropTypes__default.default.node.isRequired,
295
298
  placement: PropTypes__default.default.oneOf(PLACEMENT),
299
+ fallbackPlacements: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOf(PLACEMENT.filter(placement => placement !== 'auto'))),
296
300
  size: PropTypes__default.default.oneOf(SIZE),
297
301
  type: PropTypes__default.default.oneOf(TYPE),
298
302
  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>>;
@@ -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.6.0",
3
+ "version": "9.7.0",
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>",
@@ -35,7 +35,7 @@
35
35
  "styled-components": "^5.3.1 || ^6.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@zendeskgarden/react-theming": "^9.6.0"
38
+ "@zendeskgarden/react-theming": "^9.7.0"
39
39
  },
40
40
  "keywords": [
41
41
  "components",
@@ -47,5 +47,5 @@
47
47
  "access": "public"
48
48
  },
49
49
  "zendeskgarden:src": "src/index.ts",
50
- "gitHead": "33fcfeab6a350bd9e73c0aebbc1652be5d8043bc"
50
+ "gitHead": "565d21114d465d64f323a1960d8731f3bbcdefe5"
51
51
  }