carbon-react 112.0.3 → 113.0.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.
@@ -2,8 +2,8 @@
2
2
  import { Strategy, Middleware, Placement } from "@floating-ui/dom";
3
3
  export interface UseFloatingProps {
4
4
  isOpen?: boolean;
5
- reference: React.RefObject<HTMLElement>;
6
- floating: React.RefObject<HTMLElement>;
5
+ reference: React.RefObject<HTMLElement | null>;
6
+ floating: React.RefObject<HTMLElement | null>;
7
7
  strategy?: Strategy;
8
8
  middleware?: Middleware[];
9
9
  placement?: Placement;
@@ -1,6 +1,6 @@
1
1
  import { CommonInputPresentationProps } from "./input-presentation.component";
2
2
  import { InputContextProps } from "../input-behaviour";
3
3
  import { CarbonProviderProps } from "../../components/carbon-provider";
4
- export declare const StyledInputPresentationContainer: import("styled-components").StyledComponent<"div", any, Pick<CommonInputPresentationProps, "maxWidth" | "inputWidth">, never>;
4
+ export declare const StyledInputPresentationContainer: import("styled-components").StyledComponent<"div", any, Pick<CommonInputPresentationProps, "inputWidth" | "maxWidth">, never>;
5
5
  declare const InputPresentationStyle: import("styled-components").StyledComponent<"div", any, Pick<InputContextProps, "hasFocus"> & Pick<CommonInputPresentationProps, "disabled" | "error" | "info" | "warning" | "align" | "readOnly" | "size" | "hasIcon"> & Pick<CarbonProviderProps, "validationRedesignOptIn">, never>;
6
6
  export default InputPresentationStyle;
@@ -9,7 +9,7 @@ interface TooltipProviderProps {
9
9
  focusable?: boolean;
10
10
  tooltipVisible?: boolean;
11
11
  disabled?: boolean;
12
- target?: Element;
12
+ target?: HTMLElement;
13
13
  }
14
14
  interface ToolbarContextProps extends Omit<TooltipProviderProps, "children"> {
15
15
  tooltipId?: {
@@ -255,136 +255,140 @@ const StyledTabTitle = _styledComponents.default.button`
255
255
  isInSidebar
256
256
  }) => (0, _styledComponents.css)`
257
257
  height: ${size === "large" ? "var(--sizing600)" : "var(--sizing500)"};
258
-
258
+
259
259
  ${position === "top" && (0, _styledComponents.css)`
260
- ${borders && !(noRightBorder || noLeftBorder) && (0, _styledComponents.css)`
261
- &:nth-of-type(n + 1) {
262
- margin-left: -1px;
263
- }
264
- &:first-child {
265
- margin-left: 0;
266
- }
267
- `}
260
+ ${borders && !(noRightBorder || noLeftBorder) && (0, _styledComponents.css)`
261
+ &:nth-of-type(n + 1) {
262
+ margin-left: -1px;
263
+ }
264
+ &:first-child {
265
+ margin-left: 0;
266
+ }
268
267
  `}
268
+ `}
269
269
  ${position === "left" && (0, _styledComponents.css)`
270
- ${borders && (0, _styledComponents.css)`
271
- &:nth-of-type(n + 1) {
272
- margin-top: -1px;
273
- }
274
- &:first-child {
275
- margin-top: 0;
276
- }
277
- `}
270
+ ${borders && (0, _styledComponents.css)`
271
+ &:nth-of-type(n + 1) {
272
+ margin-top: -1px;
273
+ }
274
+ &:first-child {
275
+ margin-top: 0;
276
+ }
278
277
  `}
278
+ `}
279
279
 
280
280
  ${!isTabSelected && (0, _styledComponents.css)`
281
- color: var(--colorsActionMinorYin090);
281
+ color: var(--colorsActionMinorYin090);
282
282
 
283
- &:hover {
284
- background: var(--colorsActionMinor100);
285
- color: var(--colorsActionMinorYin090);
286
- outline: none;
287
- }
288
- &:focus {
289
- color: var(--colorsActionMinorYin090);
290
- outline: none;
291
- }
292
- `}
283
+ &:hover {
284
+ background: var(--colorsActionMinor100);
285
+ color: var(--colorsActionMinorYin090);
286
+ outline: none;
287
+ }
288
+ &:focus {
289
+ color: var(--colorsActionMinorYin090);
290
+ outline: none;
291
+ }
292
+ `}
293
293
 
294
294
  ${isTabSelected && (0, _styledComponents.css)`
295
- color: var(--colorsActionMajorYin090);
296
- background-color: var(--colorsActionMajorYang100);
297
-
298
- ${(error || warning || info) && (0, _styledComponents.css)`
299
- padding-bottom: 0px;
300
- `}
295
+ color: var(--colorsActionMajorYin090);
296
+ background-color: var(--colorsActionMajorYang100);
301
297
 
302
- &:hover {
303
- background-color: var(--colorsActionMajorYang100);
304
- border-bottom-color: ${alternateStyling ? "var(--colorsActionMinor100)" : "var(--colorsActionMajor500)"};
305
- color: var(--colorsActionMajorYin090);
306
- cursor: default;
307
- }
298
+ ${(error || warning || info) && (0, _styledComponents.css)`
299
+ padding-bottom: 0px;
308
300
  `}
309
301
 
302
+ &:hover {
303
+ background-color: var(--colorsActionMajorYang100);
304
+ border-bottom-color: ${alternateStyling ? "var(--colorsActionMinor100)" : "var(--colorsActionMajor500)"};
305
+ color: var(--colorsActionMajorYin090);
306
+ cursor: default;
307
+ }
308
+ `}
309
+
310
310
  &:focus {
311
- outline: ${isInSidebar ? "none;" : "var(--borderWidth300) solid var(--colorsSemanticFocus500);"}
311
+ outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
312
312
  z-index: 2;
313
+
314
+ ${isInSidebar && (0, _styledComponents.css)`
315
+ outline-offset: -3px;
316
+ `}
313
317
  }
314
318
 
315
319
  ${position === "left" && (0, _styledComponents.css)`
316
- background-color: transparent;
317
- border-bottom: 0px;
320
+ background-color: transparent;
321
+ border-bottom: 0px;
318
322
 
319
- ${!isInSidebar && !error && (0, _styledComponents.css)`
320
- border-right: ${alternateStyling ? "1px" : "2px"} solid
321
- var(--colorsActionMinor100);
322
- `}
323
+ ${!isInSidebar && !error && (0, _styledComponents.css)`
324
+ border-right: ${alternateStyling ? "1px" : "2px"} solid
325
+ var(--colorsActionMinor100);
326
+ `}
323
327
 
324
- ${!borders && (0, _styledComponents.css)`
325
- ${StyledTitleContent} {
326
- border-bottom: none;
327
- }
328
- `}
328
+ ${!borders && (0, _styledComponents.css)`
329
+ ${StyledTitleContent} {
330
+ border-bottom: none;
331
+ }
332
+ `}
329
333
 
330
334
  display: flex;
331
- height: auto;
332
- margin-left: 0px;
335
+ height: auto;
336
+ margin-left: 0px;
333
337
 
334
- &:first-child {
335
- margin-top: 0;
336
- }
338
+ &:first-child {
339
+ margin-top: 0;
340
+ }
337
341
 
338
- &:hover {
339
- ${alternateStyling && "border-right-color: var(--colorsActionMinor100)"}
340
- }
342
+ &:hover {
343
+ ${alternateStyling && "border-right-color: var(--colorsActionMinor100)"}
344
+ }
341
345
 
342
- ${(warning || info) && (0, _styledComponents.css)`
343
- border-right: none;
346
+ ${(warning || info) && (0, _styledComponents.css)`
347
+ border-right: none;
348
+ `}
349
+
350
+ ${isTabSelected && (0, _styledComponents.css)`
351
+ ${alternateStyling && (0, _styledComponents.css)`
352
+ border-right-color: var(--colorsActionMinor100);
344
353
  `}
345
354
 
346
- ${isTabSelected && (0, _styledComponents.css)`
347
- ${alternateStyling && (0, _styledComponents.css)`
348
- border-right-color: var(--colorsActionMinor100);
349
- `}
355
+ ${!alternateStyling && (0, _styledComponents.css)`
356
+ border-right: none;
357
+ padding-bottom: 0px;
350
358
 
351
- ${!alternateStyling && (0, _styledComponents.css)`
359
+ ${StyledTitleContent} {
360
+ ${!(error || warning || info) && "margin-right: 2px;"}
352
361
  border-right: none;
353
- padding-bottom: 0px;
354
-
355
- ${StyledTitleContent} {
356
- ${!(error || warning || info) && "margin-right: 2px;"}
357
- border-right: none;
358
- }
359
- `}
362
+ }
363
+ `}
360
364
 
361
365
  background-color: var(--colorsActionMajorYang100);
362
366
 
363
- &:hover {
364
- ${alternateStyling && "border-right-color: var(--colorsActionMinor100);"}
365
- background-color: var(--colorsActionMajorYang100);
366
- ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
367
- }
367
+ &:hover {
368
+ ${alternateStyling && "border-right-color: var(--colorsActionMinor100);"}
369
+ background-color: var(--colorsActionMajorYang100);
370
+ ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
371
+ }
368
372
 
369
- &:focus {
370
- ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
371
- }
372
- `}
373
+ &:focus {
374
+ ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
375
+ }
373
376
  `}
377
+ `}
374
378
 
375
379
  ${alternateStyling && (0, _styledComponents.css)`
376
- &:focus {
377
- background-color: var(--colorsActionMinor200);
378
- }
380
+ &:focus {
381
+ background-color: var(--colorsActionMinor200);
382
+ }
379
383
 
380
- &:hover {
381
- background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
382
- }
384
+ &:hover {
385
+ background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
386
+ }
383
387
 
384
- ${isTabSelected && (0, _styledComponents.css)`
385
- background-color: var(--colorsActionMinor200);
386
- `}
388
+ ${isTabSelected && (0, _styledComponents.css)`
389
+ background-color: var(--colorsActionMinor200);
387
390
  `}
391
+ `}
388
392
  `}
389
393
  `;
390
394
  exports.StyledTabTitle = StyledTabTitle;
@@ -1,11 +1,3 @@
1
- import { Placement } from "tippy.js";
2
- interface StyledTooltipPointer {
3
- /** Sets position of the tooltip */
4
- position?: Placement;
5
- /** Defines the message type */
6
- type?: string;
7
- /** Override background color of the Tooltip, provide any color from palette or any valid css color value. */
8
- bgColor?: string;
9
- }
10
- declare const StyledTooltipPointer: import("styled-components").StyledComponent<"div", any, StyledTooltipPointer, never>;
1
+ import { TooltipProps } from "./tooltip.component";
2
+ declare const StyledTooltipPointer: import("styled-components").StyledComponent<"div", any, Pick<TooltipProps, "type" | "bgColor">, never>;
11
3
  export default StyledTooltipPointer;
@@ -24,59 +24,20 @@ const pointerColor = (theme, bgColor, type) => {
24
24
 
25
25
  const StyledTooltipPointer = _styledComponents.default.div`
26
26
  ${({
27
- position,
28
27
  theme,
29
28
  type,
30
29
  bgColor
31
30
  }) => (0, _styledComponents.css)`
31
+ z-index: ${theme.zIndex.popover}; // TODO (tokens): implement elevation tokens - FE-4437
32
+ background: ${pointerColor(theme, bgColor, type)};
32
33
  position: absolute;
33
- width: 0;
34
- height: 0;
35
-
36
- ${position === "top" && (0, _styledComponents.css)`
37
- border-left: 8px solid transparent;
38
- border-right: 8px solid transparent;
39
- border-top: 8px solid ${pointerColor(theme, bgColor, type)};
40
- bottom: calc(-1 * var(--spacing100));
41
- @-moz-document url-prefix() {
42
- bottom: -7px;
43
- }
44
- `}
45
-
46
- ${position === "bottom" && (0, _styledComponents.css)`
47
- border-left: 8px solid transparent;
48
- border-right: 8px solid transparent;
49
- border-bottom: 8px solid ${pointerColor(theme, bgColor, type)};
50
- top: calc(-1 * var(--spacing100));
51
- @-moz-document url-prefix() {
52
- top: -7px;
53
- }
54
- `}
55
-
56
- ${position === "right" && (0, _styledComponents.css)`
57
- border-top: 8px solid transparent;
58
- border-bottom: 8px solid transparent;
59
- border-right: 8px solid ${pointerColor(theme, bgColor, type)};
60
- left: calc(-1 * var(--spacing100));
61
- @-moz-document url-prefix() {
62
- left: -7px;
63
- }
64
- `}
65
-
66
- ${position === "left" && (0, _styledComponents.css)`
67
- border-top: 8px solid transparent;
68
- border-bottom: 8px solid transparent;
69
- border-left: 8px solid ${pointerColor(theme, bgColor, type)};
70
- right: calc(-1 * var(--spacing100));
71
- @-moz-document url-prefix() {
72
- right: -7px;
73
- }
74
- `}
34
+ width: 12px;
35
+ height: 12px;
36
+ transform: rotate(45deg);
75
37
  `}
76
38
  `;
77
39
  StyledTooltipPointer.defaultProps = {
78
- theme: _base.default,
79
- position: "top"
40
+ theme: _base.default
80
41
  };
81
42
  var _default = StyledTooltipPointer;
82
43
  exports.default = _default;
@@ -27,7 +27,7 @@ export interface TooltipProps {
27
27
  */
28
28
  flipOverrides?: TooltipPositions[];
29
29
  /** @ignore @private */
30
- target?: Element;
30
+ target?: HTMLElement;
31
31
  /** @ignore @private */
32
32
  isPartOfInput?: boolean;
33
33
  /** @ignore @private */
@@ -5,16 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = exports.Tooltip = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
- var _headless = _interopRequireDefault(require("@tippyjs/react/headless"));
13
-
14
- var _tippy = require("tippy.js");
15
-
16
12
  var _invariant = _interopRequireDefault(require("invariant"));
17
13
 
14
+ var _reactDom = require("@floating-ui/react-dom");
15
+
18
16
  var _tooltip = _interopRequireDefault(require("./tooltip.style"));
19
17
 
20
18
  var _tooltipPointer = _interopRequireDefault(require("./tooltip-pointer.style"));
@@ -23,14 +21,29 @@ var _tooltip2 = require("./tooltip.config");
23
21
 
24
22
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
25
23
 
26
- var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
24
+ var _portal = _interopRequireDefault(require("../portal"));
27
25
 
28
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
27
 
28
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
29
+
30
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
30
32
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
33
 
34
+ function preserveRef(ref, node) {
35
+ if (!ref) return;
36
+
37
+ if (typeof ref === "function") {
38
+ ref(node);
39
+ }
40
+
41
+ if (typeof ref === "object" && "current" in ref) {
42
+ ref.current = node;
43
+ }
44
+ }
45
+
32
46
  const TOOLTIP_DELAY = 100;
33
- const tippyPlugins = [_tippy.sticky];
34
47
 
35
48
  const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
36
49
  children,
@@ -40,7 +53,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
40
53
  type,
41
54
  size = "medium",
42
55
  isPartOfInput,
43
- inputSize,
56
+ inputSize = "medium",
44
57
  id,
45
58
  bgColor,
46
59
  fontColor,
@@ -48,61 +61,155 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
48
61
  target,
49
62
  ...rest
50
63
  }, ref) => {
51
- const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => _tooltip2.TOOLTIP_POSITIONS.includes(placement));
52
- !isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
64
+ const targetInternalRef = (0, _react.useRef)(null);
65
+ const isControlled = isVisible !== undefined;
66
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
67
+ let showTooltip = isOpen;
68
+
69
+ if (isControlled) {
70
+ showTooltip = isVisible;
71
+ }
72
+
73
+ const showDelayedTimeout = (0, _react.useRef)(undefined);
74
+ const hideDelayedTimeout = (0, _react.useRef)(undefined);
75
+ (0, _react.useEffect)(() => {
76
+ return () => {
77
+ clearTimeout(showDelayedTimeout.current);
78
+ clearTimeout(hideDelayedTimeout.current);
79
+ };
80
+ }, []);
81
+ const show = (0, _react.useCallback)(() => setIsOpen(true), []);
82
+ const hide = (0, _react.useCallback)(() => setIsOpen(false), []);
83
+ const showDelayed = (0, _react.useCallback)(() => {
84
+ showDelayedTimeout.current = window.setTimeout(show, TOOLTIP_DELAY);
85
+ }, [show]);
86
+ const hideDelayed = (0, _react.useCallback)(() => {
87
+ hideDelayedTimeout.current = window.setTimeout(hide, TOOLTIP_DELAY);
88
+ }, [hide]);
89
+ (0, _react.useEffect)(() => {
90
+ const events = {
91
+ mouseenter: showDelayed,
92
+ mouseleave: hideDelayed,
93
+ focus: show,
94
+ blur: hide
95
+ };
96
+ const targetElement = target || targetInternalRef.current;
97
+
98
+ if (!isControlled) {
99
+ Object.entries(events).forEach(([event, handler]) => {
100
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener(event, handler);
101
+ });
102
+ }
53
103
 
54
- const tooltip = (attrs, content) => {
55
- const currentPosition = attrs["data-placement"] || position;
56
- return /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, /*#__PURE__*/_react.default.createElement(_tooltip.default, _extends({
57
- "data-element": "tooltip",
58
- role: "tooltip",
59
- tabIndex: -1,
60
- type: type,
61
- size: size,
62
- id: id
63
- }, (0, _tags.default)("tooltip", rest), {
64
- isPartOfInput: isPartOfInput,
65
- inputSize: inputSize
66
- }, attrs, {
67
- position: currentPosition,
68
- ref: ref,
69
- bgColor: bgColor,
70
- fontColor: fontColor
71
- }), /*#__PURE__*/_react.default.createElement(_tooltipPointer.default, _extends({
72
- key: "pointer",
73
- type: type
74
- }, attrs, {
75
- position: currentPosition,
76
- "data-popper-arrow": "",
77
- "data-element": "tooltip-pointer",
78
- bgColor: bgColor
79
- })), content));
80
- };
104
+ return () => {
105
+ if (!isControlled) {
106
+ Object.entries(events).forEach(([event, handler]) => {
107
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener(event, handler);
108
+ });
109
+ }
110
+ };
111
+ }, [children, show, showDelayed, hide, hideDelayed, isControlled, target]);
112
+ const flipOverridesRef = (0, _react.useRef)(flipOverrides);
113
+ flipOverridesRef.current = flipOverrides;
114
+ const arrowReference = (0, _react.useRef)(null);
115
+ const calculateOffset = (0, _react.useCallback)(placement => {
116
+ let mainAxisOffset = 9;
117
+
118
+ if (isPartOfInput) {
119
+ const offsets = {
120
+ small: 5,
121
+ medium: ["top", "bottom"].includes(placement) ? 6 : 8,
122
+ large: ["top", "bottom"].includes(placement) ? 10 : 12
123
+ };
124
+ mainAxisOffset = offsets[inputSize];
125
+ }
81
126
 
82
- return /*#__PURE__*/_react.default.createElement(_headless.default, _extends({
127
+ return mainAxisOffset;
128
+ }, [inputSize, isPartOfInput]);
129
+ const defaultMiddleware = (0, _react.useMemo)(() => [(0, _reactDom.offset)(({
130
+ placement
131
+ }) => ({
132
+ mainAxis: calculateOffset(placement)
133
+ })), (0, _reactDom.flip)({
134
+ fallbackPlacements: flipOverridesRef.current
135
+ }), (0, _reactDom.shift)({
136
+ padding: 5,
137
+ limiter: (0, _reactDom.limitShift)({
138
+ offset: ({
139
+ rects
140
+ }) => ({
141
+ mainAxis: rects.reference.height
142
+ })
143
+ })
144
+ }), (0, _reactDom.arrow)({
145
+ element: arrowReference
146
+ })], [calculateOffset, arrowReference]);
147
+ const {
148
+ x,
149
+ y,
150
+ reference,
151
+ floating,
152
+ strategy,
153
+ placement: currentPlacement,
154
+ middlewareData
155
+ } = (0, _reactDom.useFloating)({
83
156
  placement: position,
84
- delay: TOOLTIP_DELAY
85
- }, isVisible !== undefined && {
86
- visible: isVisible
87
- }, {
88
- plugins: tippyPlugins,
89
- sticky: true,
90
- render: attrs => tooltip(attrs, message),
91
- reference: target,
92
- popperOptions: {
93
- modifiers: [...(flipOverrides ? [{
94
- name: "flip",
95
- options: {
96
- fallbackPlacements: flipOverrides
97
- }
98
- }] : []), {
99
- name: "computeStyles",
100
- options: {
101
- gpuAcceleration: false
102
- }
103
- }]
104
- }
105
- }), children);
157
+ middleware: defaultMiddleware,
158
+ whileElementsMounted: _reactDom.autoUpdate
159
+ });
160
+ const tooltipStyle = {
161
+ position: strategy,
162
+ top: y ?? 0,
163
+ left: x ?? 0
164
+ };
165
+ const handleTargetRef = (0, _react.useCallback)(node => {
166
+ reference(target || node);
167
+ targetInternalRef.current = node;
168
+ preserveRef(children.ref, node);
169
+ }, [reference, children, target]);
170
+ const handleFloatingRef = (0, _react.useCallback)(node => {
171
+ floating(node);
172
+ preserveRef(ref, node);
173
+ }, [floating, ref]);
174
+ const staticSide = {
175
+ top: "bottom",
176
+ right: "left",
177
+ bottom: "top",
178
+ left: "right"
179
+ }[currentPlacement.split("-")[0]];
180
+ const {
181
+ x: arrowX,
182
+ y: arrowY
183
+ } = middlewareData.arrow || {};
184
+ const arrowStyle = {
185
+ left: arrowX,
186
+ top: arrowY,
187
+ [staticSide]: "-6px"
188
+ };
189
+ const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => _tooltip2.TOOLTIP_POSITIONS.includes(placement));
190
+ !isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
191
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.cloneElement(children, {
192
+ ref: handleTargetRef
193
+ }), showTooltip ? /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_tooltip.default, _extends({
194
+ "data-element": "tooltip",
195
+ role: "tooltip",
196
+ tabIndex: -1,
197
+ type: type,
198
+ size: size,
199
+ id: id
200
+ }, (0, _tags.default)("tooltip", rest), {
201
+ ref: handleFloatingRef,
202
+ bgColor: bgColor,
203
+ fontColor: fontColor,
204
+ style: tooltipStyle,
205
+ "data-placement": currentPlacement
206
+ }), /*#__PURE__*/_react.default.createElement(_tooltipPointer.default, {
207
+ type: type,
208
+ ref: arrowReference,
209
+ "data-element": "tooltip-pointer",
210
+ bgColor: bgColor,
211
+ style: arrowStyle
212
+ }), message)) : null);
106
213
  });
107
214
 
108
215
  exports.Tooltip = Tooltip;
@@ -1,7 +1,3 @@
1
- import { Placement } from "tippy.js";
2
1
  import { TooltipProps } from "./tooltip.component";
3
- interface StyledTooltipProps extends Omit<TooltipProps, "children" | "message" | "position"> {
4
- position: Placement;
5
- }
6
- declare const StyledTooltip: import("styled-components").StyledComponent<"div", any, StyledTooltipProps, never>;
2
+ declare const StyledTooltip: import("styled-components").StyledComponent<"div", any, Pick<TooltipProps, "type" | "size" | "bgColor" | "fontColor">, never>;
7
3
  export default StyledTooltip;