oolib 2.225.3 → 2.225.5
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/dist/stories/v2/components/Tooltip.stories.d.ts +81 -0
- package/dist/stories/v2/components/Tooltip.stories.js +981 -5
- package/dist/v2/components/List/comps/ListItem.js +19 -2
- package/dist/v2/components/Tooltip/Layout/TooltipHeading.d.ts +2 -9
- package/dist/v2/components/Tooltip/Layout/TooltipHeading.js +32 -3
- package/dist/v2/components/Tooltip/Layout/TooltipText.d.ts +2 -7
- package/dist/v2/components/Tooltip/Layout/TooltipText.js +10 -2
- package/dist/v2/components/Tooltip/index.d.ts +2 -20
- package/dist/v2/components/Tooltip/index.js +25 -18
- package/dist/v2/components/Tooltip/styled.d.ts +3 -1
- package/dist/v2/components/Tooltip/styled.js +6 -3
- package/dist/v2/components/Tooltip/types.d.ts +65 -0
- package/dist/v2/components/Tooltip/types.js +2 -0
- package/dist/v2/components/Tooltip/utils/index.d.ts +3 -20
- package/dist/v2/components/Tooltip/utils/index.js +7 -1
- package/package.json +1 -1
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
14
|
if (k2 === undefined) k2 = k;
|
|
4
15
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,12 +59,13 @@ var themes_1 = require("../../../themes");
|
|
|
48
59
|
var genColor_1 = require("../../Dropdowns/utils/genColor");
|
|
49
60
|
var RadioAndCheckbox_1 = require("../../RadioAndCheckbox");
|
|
50
61
|
var styled_1 = require("./styled");
|
|
62
|
+
var Tooltip_1 = __importDefault(require("../../Tooltip"));
|
|
51
63
|
var grey40 = themes_1.colors.grey40, grey80 = themes_1.colors.grey80, grey60 = themes_1.colors.grey60;
|
|
52
64
|
var ListItem = function (_a) {
|
|
53
65
|
var id = _a.id, option = _a.option, isSelected = _a.isSelected, isFocussed = _a.isFocussed, scrollFocussedOpIntoView = _a.scrollFocussedOpIntoView, parentOnChange = _a.onChange, setSearchString = _a.setSearchString, optionsClassName = _a.optionsClassName, S = _a.S, observerRef = _a.observerRef, isTagsStyle = _a.isTagsStyle, isMulti = _a.isMulti, value = _a.value, index = _a.index, _b = _a.alignCheckbox, alignCheckbox = _b === void 0 ? "left" : _b, iconAfter = _a.iconAfter;
|
|
54
66
|
var theme = (0, styled_components_1.useTheme)();
|
|
55
67
|
var TypoComp = S ? Typo2_1.UI_BODY_SM_DF : Typo2_1.UI_BODY_SM_DF;
|
|
56
|
-
var image = option.image, display = option.display, icon = option.icon, desc = option.desc, color = option.color, loading = option.loading, disabled = option.disabled;
|
|
68
|
+
var image = option.image, display = option.display, icon = option.icon, desc = option.desc, color = option.color, loading = option.loading, disabled = option.disabled, tooltip = option.tooltip;
|
|
57
69
|
var handleClick = function () {
|
|
58
70
|
if (!loading) {
|
|
59
71
|
parentOnChange(id, option);
|
|
@@ -73,7 +85,7 @@ var ListItem = function (_a) {
|
|
|
73
85
|
}
|
|
74
86
|
return null;
|
|
75
87
|
};
|
|
76
|
-
|
|
88
|
+
var listItemContent = (react_1.default.createElement(styled_1.StyledListItemWrapper, { index: index, isSelected: isSelected, isFocussed: isFocussed, className: "OKE-Dropdown__option", ref: function (el) { return isFocussed && el && scrollFocussedOpIntoView(el); }, onClick: handleClick, S: S, style: { pointerEvents: disabled && "none", cursor: !disabled && "pointer" } },
|
|
77
89
|
react_1.default.createElement(styled_1.StyledWrapper, { ref: observerRef, style: {
|
|
78
90
|
display: "flex",
|
|
79
91
|
alignItems: desc ? "flex-start" : "center",
|
|
@@ -106,5 +118,10 @@ var ListItem = function (_a) {
|
|
|
106
118
|
className: "OKE-Dropdown__optionIcon",
|
|
107
119
|
disabled: disabled
|
|
108
120
|
}))));
|
|
121
|
+
if (tooltip) {
|
|
122
|
+
var tooltipProps = typeof tooltip === 'string' ? { text: tooltip } : tooltip;
|
|
123
|
+
return (react_1.default.createElement(Tooltip_1.default, __assign({ placement: "right", wrapperDisplay: "block" }, tooltipProps), listItemContent));
|
|
124
|
+
}
|
|
125
|
+
return listItemContent;
|
|
109
126
|
};
|
|
110
127
|
exports.ListItem = ListItem;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
text: string;
|
|
5
|
-
containerStyle?: React.CSSProperties;
|
|
6
|
-
headingStyle?: React.CSSProperties;
|
|
7
|
-
textStyle?: React.CSSProperties;
|
|
8
|
-
}
|
|
9
|
-
export default function TooltipHeading({ heading, text, containerStyle, headingStyle, textStyle }: TooltipHeadingProps): React.JSX.Element;
|
|
10
|
-
export {};
|
|
2
|
+
import { TooltipHeadingProps } from '../types';
|
|
3
|
+
export default function TooltipHeading({ heading, text, blocks, containerStyle, headingStyle, textStyle, linkStyle, }: TooltipHeadingProps): React.JSX.Element;
|
|
@@ -17,13 +17,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.default = TooltipHeading;
|
|
18
18
|
var react_1 = __importDefault(require("react"));
|
|
19
19
|
var Typo2_1 = require("../../Typo2");
|
|
20
|
+
var utils_1 = require("../utils");
|
|
20
21
|
var defaultContainerStyle = {
|
|
21
22
|
padding: '0.8rem',
|
|
22
23
|
maxWidth: '30rem',
|
|
23
24
|
};
|
|
25
|
+
var renderBlock = function (block, index, headingStyle, textStyle, linkStyle) {
|
|
26
|
+
var heading = block.heading, text = block.text, link = block.link;
|
|
27
|
+
var linkElement = link ? (0, utils_1.renderLink)(link, linkStyle) : null;
|
|
28
|
+
var position = (link === null || link === void 0 ? void 0 : link.position) || 'end';
|
|
29
|
+
var renderLine = function (content, showLink, TextComponent, style) {
|
|
30
|
+
if (!content && !showLink)
|
|
31
|
+
return null;
|
|
32
|
+
if (!content)
|
|
33
|
+
return react_1.default.createElement(TextComponent, { style: style }, linkElement);
|
|
34
|
+
return (react_1.default.createElement(TextComponent, { style: style },
|
|
35
|
+
position === 'start' && showLink && react_1.default.createElement(react_1.default.Fragment, null,
|
|
36
|
+
linkElement,
|
|
37
|
+
" "),
|
|
38
|
+
content,
|
|
39
|
+
position === 'end' && showLink && linkElement && react_1.default.createElement(react_1.default.Fragment, null,
|
|
40
|
+
" ",
|
|
41
|
+
linkElement)));
|
|
42
|
+
};
|
|
43
|
+
return (react_1.default.createElement("div", { key: index, style: { marginTop: index > 0 ? '0.6rem' : 0 } },
|
|
44
|
+
heading && renderLine(heading, !text, Typo2_1.UI_CAPTION_SEMIBOLD, headingStyle),
|
|
45
|
+
(text || (!heading && link)) && renderLine(text, true, Typo2_1.UI_CAPTION, textStyle)));
|
|
46
|
+
};
|
|
24
47
|
function TooltipHeading(_a) {
|
|
25
|
-
var heading = _a.heading, text = _a.text, containerStyle = _a.containerStyle, headingStyle = _a.headingStyle, textStyle = _a.textStyle;
|
|
48
|
+
var heading = _a.heading, text = _a.text, blocks = _a.blocks, containerStyle = _a.containerStyle, headingStyle = _a.headingStyle, textStyle = _a.textStyle, linkStyle = _a.linkStyle;
|
|
49
|
+
// If blocks are provided, use the new multi-block rendering
|
|
50
|
+
if (blocks && blocks.length > 0) {
|
|
51
|
+
return (react_1.default.createElement("div", { style: __assign(__assign({}, defaultContainerStyle), containerStyle) }, blocks.map(function (block, index) {
|
|
52
|
+
return renderBlock(block, index, headingStyle, textStyle, linkStyle);
|
|
53
|
+
})));
|
|
54
|
+
}
|
|
26
55
|
return (react_1.default.createElement("div", { style: __assign(__assign({}, defaultContainerStyle), containerStyle) },
|
|
27
|
-
react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD, { style: headingStyle }, heading),
|
|
28
|
-
react_1.default.createElement(Typo2_1.UI_CAPTION, { style: textStyle }, text)));
|
|
56
|
+
heading && (react_1.default.createElement(Typo2_1.UI_CAPTION_SEMIBOLD, { style: headingStyle }, heading)),
|
|
57
|
+
text && (react_1.default.createElement(Typo2_1.UI_CAPTION, { style: textStyle }, text))));
|
|
29
58
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
containerStyle?: React.CSSProperties;
|
|
5
|
-
textStyle?: React.CSSProperties;
|
|
6
|
-
}
|
|
7
|
-
export default function TooltipText({ text, containerStyle, textStyle }: TooltipTextProps): React.JSX.Element;
|
|
8
|
-
export {};
|
|
2
|
+
import { TooltipTextProps } from '../types';
|
|
3
|
+
export default function TooltipText({ text, link, containerStyle, textStyle, linkStyle }: TooltipTextProps): React.JSX.Element;
|
|
@@ -17,12 +17,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.default = TooltipText;
|
|
18
18
|
var react_1 = __importDefault(require("react"));
|
|
19
19
|
var Typo2_1 = require("../../Typo2");
|
|
20
|
+
var utils_1 = require("../utils");
|
|
20
21
|
var defaultContainerStyle = {
|
|
21
22
|
padding: '0.8rem',
|
|
22
23
|
maxWidth: '30rem',
|
|
23
24
|
};
|
|
24
25
|
function TooltipText(_a) {
|
|
25
|
-
var text = _a.text, containerStyle = _a.containerStyle, textStyle = _a.textStyle;
|
|
26
|
+
var text = _a.text, link = _a.link, containerStyle = _a.containerStyle, textStyle = _a.textStyle, linkStyle = _a.linkStyle;
|
|
27
|
+
var position = (link === null || link === void 0 ? void 0 : link.position) || 'end';
|
|
28
|
+
var linkElement = link ? (0, utils_1.renderLink)(link, linkStyle) : null;
|
|
26
29
|
return (react_1.default.createElement("div", { style: __assign(__assign({}, defaultContainerStyle), containerStyle) },
|
|
27
|
-
react_1.default.createElement(Typo2_1.UI_CAPTION, { style: textStyle },
|
|
30
|
+
react_1.default.createElement(Typo2_1.UI_CAPTION, { style: textStyle },
|
|
31
|
+
position === 'start' && linkElement,
|
|
32
|
+
position === 'start' && linkElement && text && ' ',
|
|
33
|
+
text,
|
|
34
|
+
position === 'end' && linkElement && text && ' ',
|
|
35
|
+
position === 'end' && linkElement)));
|
|
28
36
|
}
|
|
@@ -1,21 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
text?: string;
|
|
5
|
-
heading?: string;
|
|
6
|
-
primaryContent?: ContentConfig;
|
|
7
|
-
secondaryContent?: ContentConfig;
|
|
8
|
-
progressiveDelay?: number;
|
|
9
|
-
progressiveGap?: number;
|
|
10
|
-
children: React.ReactElement;
|
|
11
|
-
placement?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
12
|
-
showPointer?: boolean;
|
|
13
|
-
showDelay?: number;
|
|
14
|
-
hideDelay?: number;
|
|
15
|
-
animation?: 'fade' | 'none';
|
|
16
|
-
followCursor?: boolean;
|
|
17
|
-
cursorOffset?: number;
|
|
18
|
-
invert?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export default function Tooltip({ text, heading, primaryContent, secondaryContent, progressiveDelay, progressiveGap, children, placement, showPointer, showDelay, hideDelay, animation, followCursor, cursorOffset, invert, }: TooltipProps): React.JSX.Element;
|
|
21
|
-
export {};
|
|
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, trigger, 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 ? 1000 : _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 ? 0 : _f, _g = _a.hideDelay, hideDelay = _g === void 0 ? 0 : _g, _h = _a.animation, animation = _h === void 0 ? 'none' : _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;
|
|
56
|
+
var text = _a.text, heading = _a.heading, primaryContent = _a.primaryContent, secondaryContent = _a.secondaryContent, _b = _a.progressiveDelay, progressiveDelay = _b === void 0 ? 1000 : _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 ? 0 : _f, _g = _a.hideDelay, hideDelay = _g === void 0 ? 0 : _g, _h = _a.animation, animation = _h === void 0 ? 'none' : _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, _m = _a.trigger, trigger = _m === void 0 ? 'hover' : _m, 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 _o = (0, react_1.useState)(false), isOpen = _o[0], setIsOpen = _o[1];
|
|
61
|
+
var _p = (0, react_1.useState)(false), showSecondary = _p[0], setShowSecondary = _p[1];
|
|
62
|
+
var _q = (0, react_1.useState)(false), isPinned = _q[0], setIsPinned = _q[1];
|
|
63
|
+
var _r = (0, react_1.useState)({ x: 0, y: 0 }), mousePos = _r[0], setMousePos = _r[1];
|
|
64
|
+
var _s = (0, react_1.useState)({}), cursorTooltipStyle = _s[0], setCursorTooltipStyle = _s[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);
|
|
@@ -88,11 +88,17 @@ function Tooltip(_a) {
|
|
|
88
88
|
open: { opacity: 1 },
|
|
89
89
|
close: { opacity: 0 },
|
|
90
90
|
} : undefined;
|
|
91
|
-
var
|
|
91
|
+
var isClickTrigger = trigger === 'click';
|
|
92
|
+
var _t = (0, useFloatingPosition_1.useFloatingPosition)({
|
|
92
93
|
open: isOpen,
|
|
93
94
|
onOpenChange: function (open) {
|
|
94
95
|
if (followCursor)
|
|
95
96
|
return;
|
|
97
|
+
if (isClickTrigger) {
|
|
98
|
+
// For click trigger, toggle on click
|
|
99
|
+
setIsOpen(open);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
96
102
|
if (isPinned) {
|
|
97
103
|
if (!open) {
|
|
98
104
|
setIsPinned(false);
|
|
@@ -108,21 +114,22 @@ function Tooltip(_a) {
|
|
|
108
114
|
arrowPadding: utils_1.ARROW_PADDING,
|
|
109
115
|
customMiddleware: followCursor ? undefined : [utils_1.autoSafeFlip],
|
|
110
116
|
disableAutoUpdate: followCursor,
|
|
111
|
-
enableDelayGroups:
|
|
112
|
-
|
|
117
|
+
enableDelayGroups: !isClickTrigger,
|
|
118
|
+
enableTriggerOnClick: isClickTrigger,
|
|
119
|
+
enableHover: !isClickTrigger && !isPinned && !followCursor,
|
|
113
120
|
hoverOptions: {
|
|
114
121
|
delay: { open: showDelay, close: hideDelay },
|
|
115
122
|
},
|
|
116
|
-
focusOptions: { enabled: !followCursor },
|
|
123
|
+
focusOptions: { enabled: !followCursor && !isClickTrigger },
|
|
117
124
|
dismissOptions: { enabled: !followCursor },
|
|
118
125
|
roleOptions: { role: 'tooltip' },
|
|
119
126
|
transitionOptions: transitionOptions,
|
|
120
127
|
middlewareOptions: {
|
|
121
128
|
offset: { config: followCursor ? cursorOffset : 10 },
|
|
122
129
|
shift: { enabled: true, config: { padding: 8 } },
|
|
123
|
-
flip: { enabled:
|
|
130
|
+
flip: { enabled: true, config: followCursor ? { fallbackPlacements: ['top-start'] } : { fallbackAxisSideDirection: 'start' } },
|
|
124
131
|
},
|
|
125
|
-
}), refs =
|
|
132
|
+
}), refs = _t.refs, floatingStyles = _t.floatingStyles, context = _t.context, getReferenceProps = _t.getReferenceProps, getFloatingProps = _t.getFloatingProps, isMounted = _t.isMounted, transitionStyles = _t.transitionStyles;
|
|
126
133
|
var handleMouseMove = (0, react_1.useCallback)(function (e) {
|
|
127
134
|
if (followCursor) {
|
|
128
135
|
setMousePos({ x: e.clientX, y: e.clientY });
|
|
@@ -140,8 +147,8 @@ function Tooltip(_a) {
|
|
|
140
147
|
}
|
|
141
148
|
}, [followCursor]);
|
|
142
149
|
var handleClick = function (e) {
|
|
143
|
-
if (followCursor)
|
|
144
|
-
return;
|
|
150
|
+
if (followCursor || isClickTrigger)
|
|
151
|
+
return; //useClick
|
|
145
152
|
e.stopPropagation();
|
|
146
153
|
if (isOpen) {
|
|
147
154
|
setIsPinned(false);
|
|
@@ -185,18 +192,18 @@ function Tooltip(_a) {
|
|
|
185
192
|
? "0 0 ".concat(utils_1.BORDER_RADIUS, " ").concat(utils_1.BORDER_RADIUS)
|
|
186
193
|
: utils_1.BORDER_RADIUS;
|
|
187
194
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
188
|
-
react_1.default.createElement(styled_1.StyledInlineWrapper, { ref: containerRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseMove: handleMouseMove }, children),
|
|
195
|
+
react_1.default.createElement(styled_1.StyledInlineWrapper, { ref: containerRef, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onMouseMove: handleMouseMove, "$display": wrapperDisplay }, children),
|
|
189
196
|
isOpen && (react_1.default.createElement(react_2.FloatingPortal, null,
|
|
190
|
-
react_1.default.createElement(styled_1.StyledCursorTooltipWrapper, { ref: tooltipRef, style: cursorTooltipStyle, "$gap": progressiveGap },
|
|
197
|
+
react_1.default.createElement(styled_1.StyledCursorTooltipWrapper, { ref: tooltipRef, style: __assign(__assign({}, cursorTooltipStyle), style), "$gap": progressiveGap },
|
|
191
198
|
react_1.default.createElement(styled_1.StyledTooltipContent, { "$bgColor": bgColor, "$textColor": textColor, "$borderRadius": cursorBorderRadius }, resolvedPrimaryContent && (0, utils_1.renderContent)(resolvedPrimaryContent)),
|
|
192
199
|
secondaryContent && showSecondary && (react_1.default.createElement(styled_1.StyledTooltipContent, { "$bgColor": bgColor, "$textColor": textColor, "$borderRadius": cursorSecondaryBorderRadius }, (0, utils_1.renderContent)(secondaryContent))))))));
|
|
193
200
|
}
|
|
194
201
|
var isVertical = placement.startsWith('top') || placement.startsWith('bottom');
|
|
195
202
|
var secondaryFirst = placement.startsWith('top') || placement.startsWith('left');
|
|
196
203
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
197
|
-
react_1.default.
|
|
204
|
+
react_1.default.createElement(styled_1.StyledInlineWrapper, __assign({ ref: refs.setReference }, getReferenceProps({ onClick: handleClick }), { "$display": wrapperDisplay }), children),
|
|
198
205
|
(hasFadeAnimation ? isMounted : isOpen) && (react_1.default.createElement(react_2.FloatingPortal, null,
|
|
199
|
-
react_1.default.createElement(styled_1.StyledTooltipWrapper, __assign({ ref: refs.setFloating, style: __assign(__assign({}, floatingStyles), (hasFadeAnimation ? transitionStyles : {})), "$isVertical": isVertical, "$gap": progressiveGap }, getFloatingProps()),
|
|
206
|
+
react_1.default.createElement(styled_1.StyledTooltipWrapper, __assign({ ref: refs.setFloating, style: __assign(__assign(__assign({}, floatingStyles), (hasFadeAnimation ? transitionStyles : {})), style), "$isVertical": isVertical, "$gap": progressiveGap }, getFloatingProps()),
|
|
200
207
|
react_1.default.createElement(styled_1.StyledTooltipContent, { "$bgColor": bgColor, "$textColor": textColor, "$borderRadius": (0, utils_1.getBorderRadius)({
|
|
201
208
|
isPrimary: true,
|
|
202
209
|
progressiveGap: progressiveGap,
|
|
@@ -21,4 +21,6 @@ export declare const StyledTooltipContent: import("styled-components").StyledCom
|
|
|
21
21
|
$borderRadius?: string;
|
|
22
22
|
$order?: number;
|
|
23
23
|
}, never>;
|
|
24
|
-
export declare const StyledInlineWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
24
|
+
export declare const StyledInlineWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
25
|
+
$display?: "inline-block" | "block" | "contents";
|
|
26
|
+
}, never>;
|
|
@@ -53,14 +53,14 @@ exports.StyledSecondaryContentWrapper = styled_components_1.default.div(template
|
|
|
53
53
|
var $animate = _a.$animate;
|
|
54
54
|
return $animate && exports.slideAnimation;
|
|
55
55
|
});
|
|
56
|
-
exports.StyledTooltipWrapper = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n z-index:
|
|
56
|
+
exports.StyledTooltipWrapper = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n z-index: 1000000000;\n display: flex;\n flex-direction: ", ";\n gap: ", ";\n"], ["\n z-index: 1000000000;\n display: flex;\n flex-direction: ", ";\n gap: ", ";\n"])), function (_a) {
|
|
57
57
|
var $isVertical = _a.$isVertical;
|
|
58
58
|
return ($isVertical ? 'column' : 'row');
|
|
59
59
|
}, function (_a) {
|
|
60
60
|
var _b = _a.$gap, $gap = _b === void 0 ? 0 : _b;
|
|
61
61
|
return "".concat($gap, "px");
|
|
62
62
|
});
|
|
63
|
-
exports.StyledCursorTooltipWrapper = styled_components_1.default.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n z-index:
|
|
63
|
+
exports.StyledCursorTooltipWrapper = styled_components_1.default.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n z-index: 1000000000;\n pointer-events: none;\n display: flex;\n flex-direction: column;\n gap: ", ";\n"], ["\n z-index: 1000000000;\n pointer-events: none;\n display: flex;\n flex-direction: column;\n gap: ", ";\n"])), function (_a) {
|
|
64
64
|
var _b = _a.$gap, $gap = _b === void 0 ? 0 : _b;
|
|
65
65
|
return "".concat($gap, "px");
|
|
66
66
|
});
|
|
@@ -77,5 +77,8 @@ exports.StyledTooltipContent = styled_components_1.default.div(templateObject_9
|
|
|
77
77
|
var $order = _a.$order;
|
|
78
78
|
return $order !== undefined && "order: ".concat($order, ";");
|
|
79
79
|
});
|
|
80
|
-
exports.StyledInlineWrapper = styled_components_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display:
|
|
80
|
+
exports.StyledInlineWrapper = styled_components_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: ", ";\n"], ["\n display: ", ";\n"])), function (_a) {
|
|
81
|
+
var _b = _a.$display, $display = _b === void 0 ? 'inline-block' : _b;
|
|
82
|
+
return $display;
|
|
83
|
+
});
|
|
81
84
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TooltipLink {
|
|
3
|
+
text: string;
|
|
4
|
+
href: string;
|
|
5
|
+
position?: 'start' | 'end';
|
|
6
|
+
newTab?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface TooltipTextProps {
|
|
9
|
+
text?: string;
|
|
10
|
+
link?: TooltipLink;
|
|
11
|
+
containerStyle?: React.CSSProperties;
|
|
12
|
+
textStyle?: React.CSSProperties;
|
|
13
|
+
linkStyle?: React.CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
export interface ContentBlock {
|
|
16
|
+
heading?: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
link?: TooltipLink;
|
|
19
|
+
}
|
|
20
|
+
export interface TooltipHeadingProps {
|
|
21
|
+
heading?: string;
|
|
22
|
+
text?: string;
|
|
23
|
+
blocks?: ContentBlock[];
|
|
24
|
+
containerStyle?: React.CSSProperties;
|
|
25
|
+
headingStyle?: React.CSSProperties;
|
|
26
|
+
textStyle?: React.CSSProperties;
|
|
27
|
+
linkStyle?: React.CSSProperties;
|
|
28
|
+
}
|
|
29
|
+
export type ContentConfig = {
|
|
30
|
+
layout: 'TooltipText';
|
|
31
|
+
props: TooltipTextProps;
|
|
32
|
+
} | {
|
|
33
|
+
layout: 'TooltipHeading';
|
|
34
|
+
props: TooltipHeadingProps;
|
|
35
|
+
} | {
|
|
36
|
+
layout: 'custom';
|
|
37
|
+
render: React.ReactNode;
|
|
38
|
+
};
|
|
39
|
+
export interface TooltipProps {
|
|
40
|
+
text?: string;
|
|
41
|
+
heading?: string;
|
|
42
|
+
primaryContent?: ContentConfig;
|
|
43
|
+
secondaryContent?: ContentConfig;
|
|
44
|
+
progressiveDelay?: number;
|
|
45
|
+
progressiveGap?: number;
|
|
46
|
+
children: React.ReactElement;
|
|
47
|
+
placement?: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
48
|
+
showPointer?: boolean;
|
|
49
|
+
showDelay?: number;
|
|
50
|
+
hideDelay?: number;
|
|
51
|
+
animation?: 'fade' | 'none';
|
|
52
|
+
followCursor?: boolean;
|
|
53
|
+
cursorOffset?: number;
|
|
54
|
+
invert?: boolean;
|
|
55
|
+
wrapperDisplay?: 'inline-block' | 'block' | 'contents';
|
|
56
|
+
trigger?: 'hover' | 'click';
|
|
57
|
+
style?: React.CSSProperties;
|
|
58
|
+
}
|
|
59
|
+
export interface GetBorderRadiusOptions {
|
|
60
|
+
isPrimary: boolean;
|
|
61
|
+
progressiveGap: number;
|
|
62
|
+
secondaryContent: boolean;
|
|
63
|
+
showSecondary: boolean;
|
|
64
|
+
placement: string;
|
|
65
|
+
}
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ContentConfig, GetBorderRadiusOptions, TooltipLink } from '../types';
|
|
3
3
|
export { autoSafeFlip, ARROW_PADDING } from './autoSafeFlip';
|
|
4
|
-
type
|
|
5
|
-
type TooltipHeadingProps = React.ComponentProps<typeof TooltipHeading>;
|
|
6
|
-
export type ContentConfig = {
|
|
7
|
-
layout: 'TooltipText';
|
|
8
|
-
props: TooltipTextProps;
|
|
9
|
-
} | {
|
|
10
|
-
layout: 'TooltipHeading';
|
|
11
|
-
props: TooltipHeadingProps;
|
|
12
|
-
} | {
|
|
13
|
-
layout: 'custom';
|
|
14
|
-
render: React.ReactNode;
|
|
15
|
-
};
|
|
4
|
+
export type { ContentConfig } from '../types';
|
|
16
5
|
export declare const renderContent: (config: ContentConfig) => React.ReactNode;
|
|
17
6
|
export declare const resolvePrimaryContent: (text?: string, heading?: string, primaryContent?: ContentConfig) => ContentConfig | null;
|
|
18
7
|
export declare const BORDER_RADIUS = "0.8rem";
|
|
19
|
-
interface GetBorderRadiusOptions {
|
|
20
|
-
isPrimary: boolean;
|
|
21
|
-
progressiveGap: number;
|
|
22
|
-
secondaryContent: boolean;
|
|
23
|
-
showSecondary: boolean;
|
|
24
|
-
placement: string;
|
|
25
|
-
}
|
|
26
8
|
export declare const getBorderRadius: ({ isPrimary, progressiveGap, secondaryContent, showSecondary, placement, }: GetBorderRadiusOptions) => string;
|
|
9
|
+
export declare const renderLink: (link: TooltipLink, linkStyle?: React.CSSProperties) => React.JSX.Element;
|
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getBorderRadius = exports.BORDER_RADIUS = exports.resolvePrimaryContent = exports.renderContent = exports.ARROW_PADDING = exports.autoSafeFlip = void 0;
|
|
6
|
+
exports.renderLink = exports.getBorderRadius = exports.BORDER_RADIUS = exports.resolvePrimaryContent = exports.renderContent = exports.ARROW_PADDING = exports.autoSafeFlip = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
8
|
var Layout_1 = require("../Layout");
|
|
9
|
+
var OKELink_1 = require("../../OKELink");
|
|
9
10
|
var autoSafeFlip_1 = require("./autoSafeFlip");
|
|
10
11
|
Object.defineProperty(exports, "autoSafeFlip", { enumerable: true, get: function () { return autoSafeFlip_1.autoSafeFlip; } });
|
|
11
12
|
Object.defineProperty(exports, "ARROW_PADDING", { enumerable: true, get: function () { return autoSafeFlip_1.ARROW_PADDING; } });
|
|
@@ -64,3 +65,8 @@ var getBorderRadius = function (_a) {
|
|
|
64
65
|
: "0 ".concat(exports.BORDER_RADIUS, " ").concat(exports.BORDER_RADIUS, " 0");
|
|
65
66
|
};
|
|
66
67
|
exports.getBorderRadius = getBorderRadius;
|
|
68
|
+
var renderLink = function (link, linkStyle) {
|
|
69
|
+
var invertUnderline = (linkStyle === null || linkStyle === void 0 ? void 0 : linkStyle.textDecoration) === 'none';
|
|
70
|
+
return (react_1.default.createElement(OKELink_1.OKELink, { link: link.href, text: link.text, color: "white", invertUnderline: invertUnderline, style: linkStyle }));
|
|
71
|
+
};
|
|
72
|
+
exports.renderLink = renderLink;
|