@codacy/ui-components 0.66.23 → 0.66.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Tooltip/Tooltip.js +11 -8
- package/lib/Tooltip/types.d.ts +7 -0
- package/package.json +1 -1
package/lib/Tooltip/Tooltip.js
CHANGED
|
@@ -35,7 +35,8 @@ var Tooltip = exports.Tooltip = function Tooltip(_ref) {
|
|
|
35
35
|
_ref$hoverAnimation = _ref.hoverAnimation,
|
|
36
36
|
hoverAnimation = _ref$hoverAnimation === void 0 ? true : _ref$hoverAnimation,
|
|
37
37
|
_ref$maxWidth = _ref.maxWidth,
|
|
38
|
-
maxWidth = _ref$maxWidth === void 0 ? '12rem' : _ref$maxWidth
|
|
38
|
+
maxWidth = _ref$maxWidth === void 0 ? '12rem' : _ref$maxWidth,
|
|
39
|
+
clickableTooltip = _ref.clickableTooltip;
|
|
39
40
|
var _useState = (0, _react.useState)(false),
|
|
40
41
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
41
42
|
visible = _useState2[0],
|
|
@@ -144,9 +145,9 @@ var Tooltip = exports.Tooltip = function Tooltip(_ref) {
|
|
|
144
145
|
}, attributes.popper), {}, {
|
|
145
146
|
textAlignment: textAlignment,
|
|
146
147
|
"data-enter": visible || undefined,
|
|
147
|
-
onMouseEnter: handleEnter,
|
|
148
|
-
onMouseOver: handleOver,
|
|
149
|
-
onMouseLeave: handleLeave,
|
|
148
|
+
onMouseEnter: clickableTooltip ? undefined : handleEnter,
|
|
149
|
+
onMouseOver: clickableTooltip ? undefined : handleOver,
|
|
150
|
+
onMouseLeave: clickableTooltip ? undefined : handleLeave,
|
|
150
151
|
backgroundColor: backgroundColor,
|
|
151
152
|
maxWidth: maxWidth,
|
|
152
153
|
children: [withArrow && /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.TooltipArrow, {
|
|
@@ -156,14 +157,16 @@ var Tooltip = exports.Tooltip = function Tooltip(_ref) {
|
|
|
156
157
|
}), content]
|
|
157
158
|
}));
|
|
158
159
|
var containerElement = portal && document.querySelector('body');
|
|
160
|
+
var isVisible = clickableTooltip ? clickableTooltip.visible : visible;
|
|
159
161
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
160
162
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.TooltipTrigger, {
|
|
161
163
|
ref: setTriggerRef,
|
|
162
|
-
onMouseEnter: handleEnter,
|
|
163
|
-
onMouseOver: handleOver,
|
|
164
|
-
onMouseLeave: handleLeave,
|
|
164
|
+
onMouseEnter: clickableTooltip ? undefined : handleEnter,
|
|
165
|
+
onMouseOver: clickableTooltip ? undefined : handleOver,
|
|
166
|
+
onMouseLeave: clickableTooltip ? undefined : handleLeave,
|
|
165
167
|
hoverAnimation: hoverAnimation,
|
|
168
|
+
onClick: clickableTooltip ? clickableTooltip.onClick : undefined,
|
|
166
169
|
children: children
|
|
167
|
-
}),
|
|
170
|
+
}), isVisible && (containerElement ? /*#__PURE__*/_reactDom["default"].createPortal(tooltipCard, containerElement) : tooltipCard)]
|
|
168
171
|
});
|
|
169
172
|
};
|
package/lib/Tooltip/types.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ export declare type TooltipProps = TooltipContentProps & TooltipPositionProps &
|
|
|
17
17
|
hoverAnimation?: boolean;
|
|
18
18
|
/** Tooltip's max width ? */
|
|
19
19
|
maxWidth?: string;
|
|
20
|
+
/** Fixed tooltip that will be shown regardless of the trigger's hover state. Useful for tooltips that should be shown on page load. */
|
|
21
|
+
clickableTooltip?: {
|
|
22
|
+
/** Whether the tooltip should be visible */
|
|
23
|
+
visible?: boolean;
|
|
24
|
+
/** Callback for when the tooltip trigger is clicked */
|
|
25
|
+
onClick?: () => void;
|
|
26
|
+
};
|
|
20
27
|
};
|
|
21
28
|
export interface TooltipContentProps {
|
|
22
29
|
/** The element that triggers the tooltip */
|