carbon-react 112.0.4 → 113.0.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.
Files changed (25) hide show
  1. package/esm/__internal__/focus-trap/focus-trap-utils.d.ts +1 -1
  2. package/esm/__internal__/focus-trap/focus-trap-utils.js +1 -1
  3. package/esm/__internal__/focus-trap/focus-trap.component.js +25 -26
  4. package/esm/__internal__/input/input-presentation.style.d.ts +1 -1
  5. package/esm/__internal__/tooltip-provider/index.d.ts +1 -1
  6. package/esm/components/tooltip/tooltip-pointer.style.d.ts +2 -10
  7. package/esm/components/tooltip/tooltip-pointer.style.js +6 -45
  8. package/esm/components/tooltip/tooltip.component.d.ts +1 -1
  9. package/esm/components/tooltip/tooltip.component.js +163 -58
  10. package/esm/components/tooltip/tooltip.style.d.ts +1 -5
  11. package/esm/components/tooltip/tooltip.style.js +2 -39
  12. package/esm/hooks/__internal__/useFloating/useFloating.d.ts +2 -2
  13. package/lib/__internal__/focus-trap/focus-trap-utils.d.ts +1 -1
  14. package/lib/__internal__/focus-trap/focus-trap-utils.js +1 -1
  15. package/lib/__internal__/focus-trap/focus-trap.component.js +25 -26
  16. package/lib/__internal__/input/input-presentation.style.d.ts +1 -1
  17. package/lib/__internal__/tooltip-provider/index.d.ts +1 -1
  18. package/lib/components/tooltip/tooltip-pointer.style.d.ts +2 -10
  19. package/lib/components/tooltip/tooltip-pointer.style.js +6 -45
  20. package/lib/components/tooltip/tooltip.component.d.ts +1 -1
  21. package/lib/components/tooltip/tooltip.component.js +167 -60
  22. package/lib/components/tooltip/tooltip.style.d.ts +1 -5
  23. package/lib/components/tooltip/tooltip.style.js +2 -39
  24. package/lib/hooks/__internal__/useFloating/useFloating.d.ts +2 -2
  25. package/package.json +4 -3
@@ -1,4 +1,4 @@
1
1
  declare const defaultFocusableSelectors = "button:not([disabled]), [href], input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
2
2
  declare const setElementFocus: (element: HTMLElement) => void;
3
- declare const getNextElement: (element: HTMLElement, focusableElements: HTMLElement[], shiftKey: boolean) => HTMLElement;
3
+ declare const getNextElement: (element: HTMLElement, focusableElements: HTMLElement[], shiftKey: boolean) => HTMLElement | undefined;
4
4
  export { defaultFocusableSelectors, getNextElement, setElementFocus };
@@ -51,7 +51,7 @@ const getNextElement = (element, focusableElements, shiftKey) => {
51
51
  return focusableElements[0];
52
52
  }
53
53
 
54
- return element;
54
+ return undefined;
55
55
  }
56
56
 
57
57
  const increment = shiftKey ? -1 : 1;
@@ -78,33 +78,22 @@ const FocusTrap = ({
78
78
  return;
79
79
  }
80
80
 
81
+ if (ev.key !== "Tab") return;
82
+
83
+ if (!(focusableElements !== null && focusableElements !== void 0 && focusableElements.length)) {
84
+ /* Block the trap */
85
+ ev.preventDefault();
86
+ return;
87
+ }
88
+
81
89
  const activeElement = document.activeElement;
90
+ const isWrapperFocused = activeElement === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
91
+ const elementWhenWrapperFocused = ev.shiftKey ? firstElement : lastElement;
92
+ const elementToFocus = getNextElement(isWrapperFocused ? elementWhenWrapperFocused : activeElement, focusableElements, ev.shiftKey);
82
93
 
83
- if (ev.key === "Tab") {
84
- if (!(focusableElements !== null && focusableElements !== void 0 && focusableElements.length)) {
85
- /* Block the trap */
86
- ev.preventDefault();
87
- } else if (ev.shiftKey) {
88
- /* shift + tab */
89
- let elementToFocus;
90
-
91
- if (activeElement === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
92
- elementToFocus = getNextElement(firstElement, focusableElements, ev.shiftKey);
93
- } else {
94
- elementToFocus = getNextElement(activeElement, focusableElements, ev.shiftKey);
95
- }
96
-
97
- setElementFocus(elementToFocus);
98
- ev.preventDefault();
99
- } else if (activeElement === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
100
- const elementToFocus = getNextElement(lastElement, focusableElements, ev.shiftKey);
101
- setElementFocus(elementToFocus);
102
- ev.preventDefault();
103
- } else {
104
- const elementToFocus = getNextElement(activeElement, focusableElements, ev.shiftKey);
105
- setElementFocus(elementToFocus);
106
- ev.preventDefault();
107
- }
94
+ if (elementToFocus) {
95
+ setElementFocus(elementToFocus);
96
+ ev.preventDefault();
108
97
  }
109
98
  };
110
99
 
@@ -169,7 +158,17 @@ const FocusTrap = ({
169
158
  });
170
159
  return /*#__PURE__*/React.createElement("div", {
171
160
  ref: trapRef
172
- }, clonedChildren);
161
+ }, /*#__PURE__*/React.createElement("div", {
162
+ "data-element": "tab-guard-top" // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
163
+ ,
164
+ tabIndex: 0,
165
+ onFocus: () => setElementFocus(lastElement)
166
+ }), clonedChildren, /*#__PURE__*/React.createElement("div", {
167
+ "data-element": "tab-guard-bottom" // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
168
+ ,
169
+ tabIndex: 0,
170
+ onFocus: () => setElementFocus(firstElement)
171
+ }));
173
172
  };
174
173
 
175
174
  FocusTrap.propTypes = {
@@ -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?: {
@@ -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 = {
@@ -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,4 +1,4 @@
1
1
  declare const defaultFocusableSelectors = "button:not([disabled]), [href], input:not([type=\"hidden\"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
2
2
  declare const setElementFocus: (element: HTMLElement) => void;
3
- declare const getNextElement: (element: HTMLElement, focusableElements: HTMLElement[], shiftKey: boolean) => HTMLElement;
3
+ declare const getNextElement: (element: HTMLElement, focusableElements: HTMLElement[], shiftKey: boolean) => HTMLElement | undefined;
4
4
  export { defaultFocusableSelectors, getNextElement, setElementFocus };
@@ -60,7 +60,7 @@ const getNextElement = (element, focusableElements, shiftKey) => {
60
60
  return focusableElements[0];
61
61
  }
62
62
 
63
- return element;
63
+ return undefined;
64
64
  }
65
65
 
66
66
  const increment = shiftKey ? -1 : 1;
@@ -95,33 +95,22 @@ const FocusTrap = ({
95
95
  return;
96
96
  }
97
97
 
98
+ if (ev.key !== "Tab") return;
99
+
100
+ if (!(focusableElements !== null && focusableElements !== void 0 && focusableElements.length)) {
101
+ /* Block the trap */
102
+ ev.preventDefault();
103
+ return;
104
+ }
105
+
98
106
  const activeElement = document.activeElement;
107
+ const isWrapperFocused = activeElement === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
108
+ const elementWhenWrapperFocused = ev.shiftKey ? firstElement : lastElement;
109
+ const elementToFocus = (0, _focusTrapUtils.getNextElement)(isWrapperFocused ? elementWhenWrapperFocused : activeElement, focusableElements, ev.shiftKey);
99
110
 
100
- if (ev.key === "Tab") {
101
- if (!(focusableElements !== null && focusableElements !== void 0 && focusableElements.length)) {
102
- /* Block the trap */
103
- ev.preventDefault();
104
- } else if (ev.shiftKey) {
105
- /* shift + tab */
106
- let elementToFocus;
107
-
108
- if (activeElement === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
109
- elementToFocus = (0, _focusTrapUtils.getNextElement)(firstElement, focusableElements, ev.shiftKey);
110
- } else {
111
- elementToFocus = (0, _focusTrapUtils.getNextElement)(activeElement, focusableElements, ev.shiftKey);
112
- }
113
-
114
- (0, _focusTrapUtils.setElementFocus)(elementToFocus);
115
- ev.preventDefault();
116
- } else if (activeElement === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
117
- const elementToFocus = (0, _focusTrapUtils.getNextElement)(lastElement, focusableElements, ev.shiftKey);
118
- (0, _focusTrapUtils.setElementFocus)(elementToFocus);
119
- ev.preventDefault();
120
- } else {
121
- const elementToFocus = (0, _focusTrapUtils.getNextElement)(activeElement, focusableElements, ev.shiftKey);
122
- (0, _focusTrapUtils.setElementFocus)(elementToFocus);
123
- ev.preventDefault();
124
- }
111
+ if (elementToFocus) {
112
+ (0, _focusTrapUtils.setElementFocus)(elementToFocus);
113
+ ev.preventDefault();
125
114
  }
126
115
  };
127
116
 
@@ -187,7 +176,17 @@ const FocusTrap = ({
187
176
 
188
177
  return /*#__PURE__*/_react.default.createElement("div", {
189
178
  ref: trapRef
190
- }, clonedChildren);
179
+ }, /*#__PURE__*/_react.default.createElement("div", {
180
+ "data-element": "tab-guard-top" // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
181
+ ,
182
+ tabIndex: 0,
183
+ onFocus: () => (0, _focusTrapUtils.setElementFocus)(lastElement)
184
+ }), clonedChildren, /*#__PURE__*/_react.default.createElement("div", {
185
+ "data-element": "tab-guard-bottom" // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
186
+ ,
187
+ tabIndex: 0,
188
+ onFocus: () => (0, _focusTrapUtils.setElementFocus)(firstElement)
189
+ }));
191
190
  };
192
191
 
193
192
  FocusTrap.propTypes = {
@@ -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?: {
@@ -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;
@@ -32,55 +32,19 @@ const tooltipColor = (theme, bgColor, type) => {
32
32
  return type === "error" ? "var(--colorsSemanticNegative500)" : "var(--colorsSemanticNeutral500)";
33
33
  };
34
34
 
35
- const tooltipOffset = (position, inputSize, isPartOfInput) => {
36
- if (!isPartOfInput) {
37
- return {
38
- [position]: "1px"
39
- };
40
- }
41
-
42
- switch (inputSize) {
43
- case "small":
44
- return `
45
- ${position}: 5px;
46
- @-moz-document url-prefix() {
47
- ${position}: ${["top", "bottom"].includes(position) ? "7px" : "6px"};
48
- }
49
- `;
50
-
51
- case "large":
52
- return `
53
- ${position}: ${["top", "bottom"].includes(position) ? "0px" : "-2px"};
54
- @-moz-document url-prefix() {
55
- ${position}: -1px;
56
- }
57
- `;
58
-
59
- default:
60
- return `
61
- ${position}: ${["top", "bottom"].includes(position) ? "4px" : "2px"};
62
- @-moz-document url-prefix() {
63
- ${position}: 4px;
64
- }
65
- `;
66
- }
67
- };
68
-
69
35
  const StyledTooltip = _styledComponents.default.div`
70
36
  ${({
71
- position,
72
37
  size,
73
38
  theme,
74
39
  type,
75
- isPartOfInput,
76
- inputSize = "medium",
77
40
  bgColor,
78
41
  fontColor
79
42
  }) => (0, _styledComponents.css)`
80
43
  bottom: auto;
81
44
  right: auto;
82
45
  max-width: 300px;
83
- position: relative;
46
+ width: max-content;
47
+ position: absolute;
84
48
  animation: ${fadeIn} 0.2s linear;
85
49
  z-index: ${theme.zIndex.popover}; // TODO (tokens): implement elevation tokens - FE-4437
86
50
  text-align: left;
@@ -93,7 +57,6 @@ const StyledTooltip = _styledComponents.default.div`
93
57
  line-height: 1.5rem;
94
58
  font-weight: 400;
95
59
  background-color: ${tooltipColor(theme, bgColor, type)};
96
- ${tooltipOffset(position, inputSize, isPartOfInput)};
97
60
  `}
98
61
  `;
99
62
  StyledTooltip.defaultProps = {
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "112.0.4",
3
+ "version": "113.0.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -82,6 +82,7 @@
82
82
  "@storybook/theming": "^6.4.18",
83
83
  "@testing-library/jest-dom": "^5.16.2",
84
84
  "@testing-library/react": "^12.1.3",
85
+ "@testing-library/user-event": "^14.4.3",
85
86
  "@types/crypto-js": "^4.1.1",
86
87
  "@types/draft-js": "^0.11.7",
87
88
  "@types/enzyme": "^3.10.3",
@@ -164,10 +165,10 @@
164
165
  "webpack-dev-server": "^4.0.0"
165
166
  },
166
167
  "dependencies": {
167
- "@floating-ui/dom": "^1.0.2",
168
+ "@floating-ui/dom": "^1.0.7",
169
+ "@floating-ui/react-dom": "^1.0.1",
168
170
  "@octokit/rest": "^18.12.0",
169
171
  "@styled-system/prop-types": "^5.1.5",
170
- "@tippyjs/react": "^4.2.5",
171
172
  "@types/styled-system": "^5.1.11",
172
173
  "chalk": "^4.1.1",
173
174
  "ci-info": "^3.3.2",