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.
@@ -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?: {
@@ -237,136 +237,140 @@ const StyledTabTitle = styled.button`
237
237
  isInSidebar
238
238
  }) => css`
239
239
  height: ${size === "large" ? "var(--sizing600)" : "var(--sizing500)"};
240
-
240
+
241
241
  ${position === "top" && css`
242
- ${borders && !(noRightBorder || noLeftBorder) && css`
243
- &:nth-of-type(n + 1) {
244
- margin-left: -1px;
245
- }
246
- &:first-child {
247
- margin-left: 0;
248
- }
249
- `}
242
+ ${borders && !(noRightBorder || noLeftBorder) && css`
243
+ &:nth-of-type(n + 1) {
244
+ margin-left: -1px;
245
+ }
246
+ &:first-child {
247
+ margin-left: 0;
248
+ }
250
249
  `}
250
+ `}
251
251
  ${position === "left" && css`
252
- ${borders && css`
253
- &:nth-of-type(n + 1) {
254
- margin-top: -1px;
255
- }
256
- &:first-child {
257
- margin-top: 0;
258
- }
259
- `}
252
+ ${borders && css`
253
+ &:nth-of-type(n + 1) {
254
+ margin-top: -1px;
255
+ }
256
+ &:first-child {
257
+ margin-top: 0;
258
+ }
260
259
  `}
260
+ `}
261
261
 
262
262
  ${!isTabSelected && css`
263
- color: var(--colorsActionMinorYin090);
263
+ color: var(--colorsActionMinorYin090);
264
264
 
265
- &:hover {
266
- background: var(--colorsActionMinor100);
267
- color: var(--colorsActionMinorYin090);
268
- outline: none;
269
- }
270
- &:focus {
271
- color: var(--colorsActionMinorYin090);
272
- outline: none;
273
- }
274
- `}
265
+ &:hover {
266
+ background: var(--colorsActionMinor100);
267
+ color: var(--colorsActionMinorYin090);
268
+ outline: none;
269
+ }
270
+ &:focus {
271
+ color: var(--colorsActionMinorYin090);
272
+ outline: none;
273
+ }
274
+ `}
275
275
 
276
276
  ${isTabSelected && css`
277
- color: var(--colorsActionMajorYin090);
278
- background-color: var(--colorsActionMajorYang100);
279
-
280
- ${(error || warning || info) && css`
281
- padding-bottom: 0px;
282
- `}
277
+ color: var(--colorsActionMajorYin090);
278
+ background-color: var(--colorsActionMajorYang100);
283
279
 
284
- &:hover {
285
- background-color: var(--colorsActionMajorYang100);
286
- border-bottom-color: ${alternateStyling ? "var(--colorsActionMinor100)" : "var(--colorsActionMajor500)"};
287
- color: var(--colorsActionMajorYin090);
288
- cursor: default;
289
- }
280
+ ${(error || warning || info) && css`
281
+ padding-bottom: 0px;
290
282
  `}
291
283
 
284
+ &:hover {
285
+ background-color: var(--colorsActionMajorYang100);
286
+ border-bottom-color: ${alternateStyling ? "var(--colorsActionMinor100)" : "var(--colorsActionMajor500)"};
287
+ color: var(--colorsActionMajorYin090);
288
+ cursor: default;
289
+ }
290
+ `}
291
+
292
292
  &:focus {
293
- outline: ${isInSidebar ? "none;" : "var(--borderWidth300) solid var(--colorsSemanticFocus500);"}
293
+ outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
294
294
  z-index: 2;
295
+
296
+ ${isInSidebar && css`
297
+ outline-offset: -3px;
298
+ `}
295
299
  }
296
300
 
297
301
  ${position === "left" && css`
298
- background-color: transparent;
299
- border-bottom: 0px;
302
+ background-color: transparent;
303
+ border-bottom: 0px;
300
304
 
301
- ${!isInSidebar && !error && css`
302
- border-right: ${alternateStyling ? "1px" : "2px"} solid
303
- var(--colorsActionMinor100);
304
- `}
305
+ ${!isInSidebar && !error && css`
306
+ border-right: ${alternateStyling ? "1px" : "2px"} solid
307
+ var(--colorsActionMinor100);
308
+ `}
305
309
 
306
- ${!borders && css`
307
- ${StyledTitleContent} {
308
- border-bottom: none;
309
- }
310
- `}
310
+ ${!borders && css`
311
+ ${StyledTitleContent} {
312
+ border-bottom: none;
313
+ }
314
+ `}
311
315
 
312
316
  display: flex;
313
- height: auto;
314
- margin-left: 0px;
317
+ height: auto;
318
+ margin-left: 0px;
315
319
 
316
- &:first-child {
317
- margin-top: 0;
318
- }
320
+ &:first-child {
321
+ margin-top: 0;
322
+ }
319
323
 
320
- &:hover {
321
- ${alternateStyling && "border-right-color: var(--colorsActionMinor100)"}
322
- }
324
+ &:hover {
325
+ ${alternateStyling && "border-right-color: var(--colorsActionMinor100)"}
326
+ }
323
327
 
324
- ${(warning || info) && css`
325
- border-right: none;
328
+ ${(warning || info) && css`
329
+ border-right: none;
330
+ `}
331
+
332
+ ${isTabSelected && css`
333
+ ${alternateStyling && css`
334
+ border-right-color: var(--colorsActionMinor100);
326
335
  `}
327
336
 
328
- ${isTabSelected && css`
329
- ${alternateStyling && css`
330
- border-right-color: var(--colorsActionMinor100);
331
- `}
337
+ ${!alternateStyling && css`
338
+ border-right: none;
339
+ padding-bottom: 0px;
332
340
 
333
- ${!alternateStyling && css`
341
+ ${StyledTitleContent} {
342
+ ${!(error || warning || info) && "margin-right: 2px;"}
334
343
  border-right: none;
335
- padding-bottom: 0px;
336
-
337
- ${StyledTitleContent} {
338
- ${!(error || warning || info) && "margin-right: 2px;"}
339
- border-right: none;
340
- }
341
- `}
344
+ }
345
+ `}
342
346
 
343
347
  background-color: var(--colorsActionMajorYang100);
344
348
 
345
- &:hover {
346
- ${alternateStyling && "border-right-color: var(--colorsActionMinor100);"}
347
- background-color: var(--colorsActionMajorYang100);
348
- ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
349
- }
349
+ &:hover {
350
+ ${alternateStyling && "border-right-color: var(--colorsActionMinor100);"}
351
+ background-color: var(--colorsActionMajorYang100);
352
+ ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
353
+ }
350
354
 
351
- &:focus {
352
- ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
353
- }
354
- `}
355
+ &:focus {
356
+ ${(error || warning || info) && "border-right-color: var(--colorsSemanticNegative500);"}
357
+ }
355
358
  `}
359
+ `}
356
360
 
357
361
  ${alternateStyling && css`
358
- &:focus {
359
- background-color: var(--colorsActionMinor200);
360
- }
362
+ &:focus {
363
+ background-color: var(--colorsActionMinor200);
364
+ }
361
365
 
362
- &:hover {
363
- background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
364
- }
366
+ &:hover {
367
+ background-color: ${isTabSelected ? "var(--colorsActionMinor200)" : "var(--colorsActionMinor250)"};
368
+ }
365
369
 
366
- ${isTabSelected && css`
367
- background-color: var(--colorsActionMinor200);
368
- `}
370
+ ${isTabSelected && css`
371
+ background-color: var(--colorsActionMinor200);
369
372
  `}
373
+ `}
370
374
  `}
371
375
  `;
372
376
  const StyledLayoutWrapper = styled.div`
@@ -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;
@@ -9,58 +9,19 @@ const pointerColor = (theme, bgColor, type) => {
9
9
 
10
10
  const StyledTooltipPointer = styled.div`
11
11
  ${({
12
- position,
13
12
  theme,
14
13
  type,
15
14
  bgColor
16
15
  }) => css`
16
+ z-index: ${theme.zIndex.popover}; // TODO (tokens): implement elevation tokens - FE-4437
17
+ background: ${pointerColor(theme, bgColor, type)};
17
18
  position: absolute;
18
- width: 0;
19
- height: 0;
20
-
21
- ${position === "top" && css`
22
- border-left: 8px solid transparent;
23
- border-right: 8px solid transparent;
24
- border-top: 8px solid ${pointerColor(theme, bgColor, type)};
25
- bottom: calc(-1 * var(--spacing100));
26
- @-moz-document url-prefix() {
27
- bottom: -7px;
28
- }
29
- `}
30
-
31
- ${position === "bottom" && css`
32
- border-left: 8px solid transparent;
33
- border-right: 8px solid transparent;
34
- border-bottom: 8px solid ${pointerColor(theme, bgColor, type)};
35
- top: calc(-1 * var(--spacing100));
36
- @-moz-document url-prefix() {
37
- top: -7px;
38
- }
39
- `}
40
-
41
- ${position === "right" && css`
42
- border-top: 8px solid transparent;
43
- border-bottom: 8px solid transparent;
44
- border-right: 8px solid ${pointerColor(theme, bgColor, type)};
45
- left: calc(-1 * var(--spacing100));
46
- @-moz-document url-prefix() {
47
- left: -7px;
48
- }
49
- `}
50
-
51
- ${position === "left" && css`
52
- border-top: 8px solid transparent;
53
- border-bottom: 8px solid transparent;
54
- border-left: 8px solid ${pointerColor(theme, bgColor, type)};
55
- right: calc(-1 * var(--spacing100));
56
- @-moz-document url-prefix() {
57
- right: -7px;
58
- }
59
- `}
19
+ width: 12px;
20
+ height: 12px;
21
+ transform: rotate(45deg);
60
22
  `}
61
23
  `;
62
24
  StyledTooltipPointer.defaultProps = {
63
- theme: baseTheme,
64
- position: "top"
25
+ theme: baseTheme
65
26
  };
66
27
  export default StyledTooltipPointer;
@@ -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 */
@@ -1,17 +1,28 @@
1
1
  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); }
2
2
 
3
- import React from "react";
3
+ import React, { useRef, useMemo, useCallback, useState, useEffect } from "react";
4
4
  import PropTypes from "prop-types";
5
- import Tippy from "@tippyjs/react/headless";
6
- import { sticky } from "tippy.js";
7
5
  import invariant from "invariant";
6
+ import { offset, flip, shift, arrow, limitShift, autoUpdate, useFloating } from "@floating-ui/react-dom";
8
7
  import StyledTooltip from "./tooltip.style";
9
8
  import StyledPointer from "./tooltip-pointer.style";
10
9
  import { TOOLTIP_POSITIONS } from "./tooltip.config";
11
10
  import tagComponent from "../../__internal__/utils/helpers/tags/tags";
12
- import CarbonScopedTokensProvider from "../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component";
11
+ import Portal from "../portal";
12
+
13
+ function preserveRef(ref, node) {
14
+ if (!ref) return;
15
+
16
+ if (typeof ref === "function") {
17
+ ref(node);
18
+ }
19
+
20
+ if (typeof ref === "object" && "current" in ref) {
21
+ ref.current = node;
22
+ }
23
+ }
24
+
13
25
  const TOOLTIP_DELAY = 100;
14
- const tippyPlugins = [sticky];
15
26
  const Tooltip = /*#__PURE__*/React.forwardRef(({
16
27
  children,
17
28
  isVisible,
@@ -20,7 +31,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
20
31
  type,
21
32
  size = "medium",
22
33
  isPartOfInput,
23
- inputSize,
34
+ inputSize = "medium",
24
35
  id,
25
36
  bgColor,
26
37
  fontColor,
@@ -28,61 +39,155 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
28
39
  target,
29
40
  ...rest
30
41
  }, ref) => {
31
- const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => TOOLTIP_POSITIONS.includes(placement));
32
- !isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? invariant(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
42
+ const targetInternalRef = useRef(null);
43
+ const isControlled = isVisible !== undefined;
44
+ const [isOpen, setIsOpen] = useState(false);
45
+ let showTooltip = isOpen;
33
46
 
34
- const tooltip = (attrs, content) => {
35
- const currentPosition = attrs["data-placement"] || position;
36
- return /*#__PURE__*/React.createElement(CarbonScopedTokensProvider, null, /*#__PURE__*/React.createElement(StyledTooltip, _extends({
37
- "data-element": "tooltip",
38
- role: "tooltip",
39
- tabIndex: -1,
40
- type: type,
41
- size: size,
42
- id: id
43
- }, tagComponent("tooltip", rest), {
44
- isPartOfInput: isPartOfInput,
45
- inputSize: inputSize
46
- }, attrs, {
47
- position: currentPosition,
48
- ref: ref,
49
- bgColor: bgColor,
50
- fontColor: fontColor
51
- }), /*#__PURE__*/React.createElement(StyledPointer, _extends({
52
- key: "pointer",
53
- type: type
54
- }, attrs, {
55
- position: currentPosition,
56
- "data-popper-arrow": "",
57
- "data-element": "tooltip-pointer",
58
- bgColor: bgColor
59
- })), content));
60
- };
47
+ if (isControlled) {
48
+ showTooltip = isVisible;
49
+ }
61
50
 
62
- return /*#__PURE__*/React.createElement(Tippy, _extends({
63
- placement: position,
64
- delay: TOOLTIP_DELAY
65
- }, isVisible !== undefined && {
66
- visible: isVisible
67
- }, {
68
- plugins: tippyPlugins,
69
- sticky: true,
70
- render: attrs => tooltip(attrs, message),
71
- reference: target,
72
- popperOptions: {
73
- modifiers: [...(flipOverrides ? [{
74
- name: "flip",
75
- options: {
76
- fallbackPlacements: flipOverrides
77
- }
78
- }] : []), {
79
- name: "computeStyles",
80
- options: {
81
- gpuAcceleration: false
82
- }
83
- }]
51
+ const showDelayedTimeout = useRef(undefined);
52
+ const hideDelayedTimeout = useRef(undefined);
53
+ useEffect(() => {
54
+ return () => {
55
+ clearTimeout(showDelayedTimeout.current);
56
+ clearTimeout(hideDelayedTimeout.current);
57
+ };
58
+ }, []);
59
+ const show = useCallback(() => setIsOpen(true), []);
60
+ const hide = useCallback(() => setIsOpen(false), []);
61
+ const showDelayed = useCallback(() => {
62
+ showDelayedTimeout.current = window.setTimeout(show, TOOLTIP_DELAY);
63
+ }, [show]);
64
+ const hideDelayed = useCallback(() => {
65
+ hideDelayedTimeout.current = window.setTimeout(hide, TOOLTIP_DELAY);
66
+ }, [hide]);
67
+ useEffect(() => {
68
+ const events = {
69
+ mouseenter: showDelayed,
70
+ mouseleave: hideDelayed,
71
+ focus: show,
72
+ blur: hide
73
+ };
74
+ const targetElement = target || targetInternalRef.current;
75
+
76
+ if (!isControlled) {
77
+ Object.entries(events).forEach(([event, handler]) => {
78
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener(event, handler);
79
+ });
84
80
  }
85
- }), children);
81
+
82
+ return () => {
83
+ if (!isControlled) {
84
+ Object.entries(events).forEach(([event, handler]) => {
85
+ targetElement === null || targetElement === void 0 ? void 0 : targetElement.removeEventListener(event, handler);
86
+ });
87
+ }
88
+ };
89
+ }, [children, show, showDelayed, hide, hideDelayed, isControlled, target]);
90
+ const flipOverridesRef = useRef(flipOverrides);
91
+ flipOverridesRef.current = flipOverrides;
92
+ const arrowReference = useRef(null);
93
+ const calculateOffset = useCallback(placement => {
94
+ let mainAxisOffset = 9;
95
+
96
+ if (isPartOfInput) {
97
+ const offsets = {
98
+ small: 5,
99
+ medium: ["top", "bottom"].includes(placement) ? 6 : 8,
100
+ large: ["top", "bottom"].includes(placement) ? 10 : 12
101
+ };
102
+ mainAxisOffset = offsets[inputSize];
103
+ }
104
+
105
+ return mainAxisOffset;
106
+ }, [inputSize, isPartOfInput]);
107
+ const defaultMiddleware = useMemo(() => [offset(({
108
+ placement
109
+ }) => ({
110
+ mainAxis: calculateOffset(placement)
111
+ })), flip({
112
+ fallbackPlacements: flipOverridesRef.current
113
+ }), shift({
114
+ padding: 5,
115
+ limiter: limitShift({
116
+ offset: ({
117
+ rects
118
+ }) => ({
119
+ mainAxis: rects.reference.height
120
+ })
121
+ })
122
+ }), arrow({
123
+ element: arrowReference
124
+ })], [calculateOffset, arrowReference]);
125
+ const {
126
+ x,
127
+ y,
128
+ reference,
129
+ floating,
130
+ strategy,
131
+ placement: currentPlacement,
132
+ middlewareData
133
+ } = useFloating({
134
+ placement: position,
135
+ middleware: defaultMiddleware,
136
+ whileElementsMounted: autoUpdate
137
+ });
138
+ const tooltipStyle = {
139
+ position: strategy,
140
+ top: y ?? 0,
141
+ left: x ?? 0
142
+ };
143
+ const handleTargetRef = useCallback(node => {
144
+ reference(target || node);
145
+ targetInternalRef.current = node;
146
+ preserveRef(children.ref, node);
147
+ }, [reference, children, target]);
148
+ const handleFloatingRef = useCallback(node => {
149
+ floating(node);
150
+ preserveRef(ref, node);
151
+ }, [floating, ref]);
152
+ const staticSide = {
153
+ top: "bottom",
154
+ right: "left",
155
+ bottom: "top",
156
+ left: "right"
157
+ }[currentPlacement.split("-")[0]];
158
+ const {
159
+ x: arrowX,
160
+ y: arrowY
161
+ } = middlewareData.arrow || {};
162
+ const arrowStyle = {
163
+ left: arrowX,
164
+ top: arrowY,
165
+ [staticSide]: "-6px"
166
+ };
167
+ const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => TOOLTIP_POSITIONS.includes(placement));
168
+ !isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? invariant(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
169
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.cloneElement(children, {
170
+ ref: handleTargetRef
171
+ }), showTooltip ? /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledTooltip, _extends({
172
+ "data-element": "tooltip",
173
+ role: "tooltip",
174
+ tabIndex: -1,
175
+ type: type,
176
+ size: size,
177
+ id: id
178
+ }, tagComponent("tooltip", rest), {
179
+ ref: handleFloatingRef,
180
+ bgColor: bgColor,
181
+ fontColor: fontColor,
182
+ style: tooltipStyle,
183
+ "data-placement": currentPlacement
184
+ }), /*#__PURE__*/React.createElement(StyledPointer, {
185
+ type: type,
186
+ ref: arrowReference,
187
+ "data-element": "tooltip-pointer",
188
+ bgColor: bgColor,
189
+ style: arrowStyle
190
+ }), message)) : null);
86
191
  });
87
192
  Tooltip.propTypes = {
88
193
  "bgColor": PropTypes.string,
@@ -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;
@@ -16,55 +16,19 @@ const tooltipColor = (theme, bgColor, type) => {
16
16
  return type === "error" ? "var(--colorsSemanticNegative500)" : "var(--colorsSemanticNeutral500)";
17
17
  };
18
18
 
19
- const tooltipOffset = (position, inputSize, isPartOfInput) => {
20
- if (!isPartOfInput) {
21
- return {
22
- [position]: "1px"
23
- };
24
- }
25
-
26
- switch (inputSize) {
27
- case "small":
28
- return `
29
- ${position}: 5px;
30
- @-moz-document url-prefix() {
31
- ${position}: ${["top", "bottom"].includes(position) ? "7px" : "6px"};
32
- }
33
- `;
34
-
35
- case "large":
36
- return `
37
- ${position}: ${["top", "bottom"].includes(position) ? "0px" : "-2px"};
38
- @-moz-document url-prefix() {
39
- ${position}: -1px;
40
- }
41
- `;
42
-
43
- default:
44
- return `
45
- ${position}: ${["top", "bottom"].includes(position) ? "4px" : "2px"};
46
- @-moz-document url-prefix() {
47
- ${position}: 4px;
48
- }
49
- `;
50
- }
51
- };
52
-
53
19
  const StyledTooltip = styled.div`
54
20
  ${({
55
- position,
56
21
  size,
57
22
  theme,
58
23
  type,
59
- isPartOfInput,
60
- inputSize = "medium",
61
24
  bgColor,
62
25
  fontColor
63
26
  }) => css`
64
27
  bottom: auto;
65
28
  right: auto;
66
29
  max-width: 300px;
67
- position: relative;
30
+ width: max-content;
31
+ position: absolute;
68
32
  animation: ${fadeIn} 0.2s linear;
69
33
  z-index: ${theme.zIndex.popover}; // TODO (tokens): implement elevation tokens - FE-4437
70
34
  text-align: left;
@@ -77,7 +41,6 @@ const StyledTooltip = styled.div`
77
41
  line-height: 1.5rem;
78
42
  font-weight: 400;
79
43
  background-color: ${tooltipColor(theme, bgColor, type)};
80
- ${tooltipOffset(position, inputSize, isPartOfInput)};
81
44
  `}
82
45
  `;
83
46
  StyledTooltip.defaultProps = {