oolib 3.3.0 → 3.3.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.
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TooltipProps } from './types';
|
|
3
|
-
export default function Tooltip({ text, heading, primaryContent, secondaryContent, progressiveDelay, progressiveGap, children, placement, showPointer, showDelay, hideDelay, animation, followCursor, cursorOffset, invert, wrapperDisplay, wrapperStyle, trigger, style, }: TooltipProps): React.JSX.Element;
|
|
3
|
+
export default function Tooltip({ text, heading, primaryContent, secondaryContent, progressiveDelay, progressiveGap, children, placement, showPointer, showDelay, hideDelay, animation, followCursor, cursorOffset, invert, wrapperDisplay, wrapperStyle, trigger, pinOnClick, style, }: TooltipProps): React.JSX.Element;
|
|
@@ -53,15 +53,15 @@ var utils_1 = require("./utils");
|
|
|
53
53
|
var styled_1 = require("./styled");
|
|
54
54
|
var CURSOR_HEIGHT = 20;
|
|
55
55
|
function Tooltip(_a) {
|
|
56
|
-
var text = _a.text, heading = _a.heading, primaryContent = _a.primaryContent, secondaryContent = _a.secondaryContent, _b = _a.progressiveDelay, progressiveDelay = _b === void 0 ? 600 : _b, _c = _a.progressiveGap, progressiveGap = _c === void 0 ? 8 : _c, children = _a.children, _d = _a.placement, placement = _d === void 0 ? 'top' : _d, _e = _a.showPointer, showPointer = _e === void 0 ? true : _e, _f = _a.showDelay, showDelay = _f === void 0 ? 600 : _f, _g = _a.hideDelay, hideDelay = _g === void 0 ? 0 : _g, _h = _a.animation, animation = _h === void 0 ? 'fade' : _h, _j = _a.followCursor, followCursor = _j === void 0 ? false : _j, _k = _a.cursorOffset, cursorOffset = _k === void 0 ? 10 : _k, _l = _a.invert, invert = _l === void 0 ? false : _l, wrapperDisplay = _a.wrapperDisplay, wrapperStyle = _a.wrapperStyle, _m = _a.trigger, trigger = _m === void 0 ? 'hover' : _m, style = _a.style;
|
|
56
|
+
var text = _a.text, heading = _a.heading, primaryContent = _a.primaryContent, secondaryContent = _a.secondaryContent, _b = _a.progressiveDelay, progressiveDelay = _b === void 0 ? 600 : _b, _c = _a.progressiveGap, progressiveGap = _c === void 0 ? 8 : _c, children = _a.children, _d = _a.placement, placement = _d === void 0 ? 'top' : _d, _e = _a.showPointer, showPointer = _e === void 0 ? true : _e, _f = _a.showDelay, showDelay = _f === void 0 ? 600 : _f, _g = _a.hideDelay, hideDelay = _g === void 0 ? 0 : _g, _h = _a.animation, animation = _h === void 0 ? 'fade' : _h, _j = _a.followCursor, followCursor = _j === void 0 ? false : _j, _k = _a.cursorOffset, cursorOffset = _k === void 0 ? 10 : _k, _l = _a.invert, invert = _l === void 0 ? false : _l, wrapperDisplay = _a.wrapperDisplay, wrapperStyle = _a.wrapperStyle, _m = _a.trigger, trigger = _m === void 0 ? 'hover' : _m, _o = _a.pinOnClick, pinOnClick = _o === void 0 ? true : _o, style = _a.style;
|
|
57
57
|
var bgColor = invert ? __1.colors2.white : __1.colors2.black;
|
|
58
58
|
var textColor = invert ? __1.colors2.black : __1.colors2.white;
|
|
59
59
|
var resolvedPrimaryContent = (0, utils_1.resolvePrimaryContent)(text, heading, primaryContent);
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
var
|
|
64
|
-
var
|
|
60
|
+
var _p = (0, react_1.useState)(false), isOpen = _p[0], setIsOpen = _p[1];
|
|
61
|
+
var _q = (0, react_1.useState)(false), showSecondary = _q[0], setShowSecondary = _q[1];
|
|
62
|
+
var _r = (0, react_1.useState)(false), isPinned = _r[0], setIsPinned = _r[1];
|
|
63
|
+
var _s = (0, react_1.useState)({ x: 0, y: 0 }), mousePos = _s[0], setMousePos = _s[1];
|
|
64
|
+
var _t = (0, react_1.useState)({}), cursorTooltipStyle = _t[0], setCursorTooltipStyle = _t[1];
|
|
65
65
|
var progressiveTimerRef = (0, react_1.useRef)(null);
|
|
66
66
|
var containerRef = (0, react_1.useRef)(null);
|
|
67
67
|
var arrowRef = (0, react_1.useRef)(null);
|
|
@@ -89,7 +89,7 @@ function Tooltip(_a) {
|
|
|
89
89
|
close: { opacity: 0 },
|
|
90
90
|
} : undefined;
|
|
91
91
|
var isClickTrigger = trigger === 'click';
|
|
92
|
-
var
|
|
92
|
+
var _u = (0, useFloatingPosition_1.useFloatingPosition)({
|
|
93
93
|
open: isOpen,
|
|
94
94
|
onOpenChange: function (open) {
|
|
95
95
|
if (followCursor)
|
|
@@ -129,7 +129,7 @@ function Tooltip(_a) {
|
|
|
129
129
|
shift: { enabled: true, config: { padding: 8 } },
|
|
130
130
|
flip: { enabled: true, config: followCursor ? { fallbackPlacements: ['top-start'] } : { fallbackAxisSideDirection: 'start' } },
|
|
131
131
|
},
|
|
132
|
-
}), refs =
|
|
132
|
+
}), refs = _u.refs, floatingStyles = _u.floatingStyles, context = _u.context, getReferenceProps = _u.getReferenceProps, getFloatingProps = _u.getFloatingProps, isMounted = _u.isMounted, transitionStyles = _u.transitionStyles;
|
|
133
133
|
var handleMouseMove = (0, react_1.useCallback)(function (e) {
|
|
134
134
|
if (followCursor) {
|
|
135
135
|
setMousePos({ x: e.clientX, y: e.clientY });
|
|
@@ -149,6 +149,8 @@ function Tooltip(_a) {
|
|
|
149
149
|
var handleClick = function (e) {
|
|
150
150
|
if (followCursor || isClickTrigger)
|
|
151
151
|
return; //useClick
|
|
152
|
+
if (!pinOnClick)
|
|
153
|
+
return; // clickable child owns the click — don't swallow or pin
|
|
152
154
|
e.stopPropagation();
|
|
153
155
|
if (isOpen) {
|
|
154
156
|
setIsPinned(false);
|
|
@@ -61,6 +61,15 @@ export interface TooltipProps {
|
|
|
61
61
|
*/
|
|
62
62
|
wrapperStyle?: React.CSSProperties;
|
|
63
63
|
trigger?: 'hover' | 'click';
|
|
64
|
+
/**
|
|
65
|
+
* Hover-trigger only. By default, clicking the wrapped child pins the
|
|
66
|
+
* tooltip open AND stops the click from propagating — which silently
|
|
67
|
+
* swallows clicks meant for an interactive child (or an ancestor click
|
|
68
|
+
* handler, e.g. a popover trigger wrapping this tooltip). Set false when
|
|
69
|
+
* `children` is clickable: the click passes through untouched and the
|
|
70
|
+
* tooltip never pins.
|
|
71
|
+
*/
|
|
72
|
+
pinOnClick?: boolean;
|
|
64
73
|
style?: React.CSSProperties;
|
|
65
74
|
}
|
|
66
75
|
export interface GetBorderRadiusOptions {
|