@deskpro/deskpro-ui 6.10.4 → 7.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.
- package/dist/cjs/components/Avatar/Avatar.js +11 -2
- package/dist/cjs/components/Avatar/Avatar.js.map +1 -1
- package/dist/cjs/components/Avatar/AvatarGroup.js +4 -1
- package/dist/cjs/components/Avatar/AvatarGroup.js.map +1 -1
- package/dist/cjs/components/LabelTag/Tag.js +2 -2
- package/dist/cjs/components/LabelTag/Tag.js.map +1 -1
- package/dist/cjs/components/LabelTag/TagCircle.js +11 -2
- package/dist/cjs/components/LabelTag/TagCircle.js.map +1 -1
- package/dist/cjs/components/TabBar/TabBar.js +4 -7
- package/dist/cjs/components/TabBar/TabBar.js.map +1 -1
- package/dist/cjs/components/TextArea/TextArea.js +33 -31
- package/dist/cjs/components/TextArea/TextArea.js.map +1 -1
- package/dist/cjs/components/TippyTooltip/EllipsesTippyTooltip.js +18 -0
- package/dist/cjs/components/TippyTooltip/EllipsesTippyTooltip.js.map +1 -0
- package/dist/cjs/components/TippyTooltip/TippyTooltip.js +121 -0
- package/dist/cjs/components/TippyTooltip/TippyTooltip.js.map +1 -0
- package/dist/cjs/components/TippyTooltip/index.js +9 -0
- package/dist/cjs/components/TippyTooltip/index.js.map +1 -0
- package/dist/cjs/components/TippyTooltip/mergePlugins.js.map +1 -0
- package/dist/cjs/components/TippyTooltip/plugIns/disableForTouchDevicesPlugin.js.map +1 -0
- package/dist/cjs/components/TippyTooltip/plugIns/dpNamePlugin.js.map +1 -0
- package/dist/cjs/components/TippyTooltip/plugIns/escPlugin.js.map +1 -0
- package/dist/cjs/components/TippyTooltip/plugIns/index.js.map +1 -0
- package/dist/cjs/components/Tooltip/EllipsesTooltip.js +2 -3
- package/dist/cjs/components/Tooltip/EllipsesTooltip.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.js +137 -101
- package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/components/Tooltip/index.js.map +1 -1
- package/dist/cjs/components/Tooltip/styles.js +201 -0
- package/dist/cjs/components/Tooltip/styles.js.map +1 -0
- package/dist/cjs/components/Tooltip/types.js +3 -0
- package/dist/cjs/components/Tooltip/types.js.map +1 -0
- package/dist/cjs/components/Tooltip/utils.js +193 -0
- package/dist/cjs/components/Tooltip/utils.js.map +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/hooks/useOnClickOutside.js +27 -0
- package/dist/cjs/hooks/useOnClickOutside.js.map +1 -0
- package/dist/deskpro-ui.d.ts +79 -10
- package/dist/esm/components/Avatar/Avatar.js +11 -2
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/Avatar/AvatarGroup.js +4 -1
- package/dist/esm/components/Avatar/AvatarGroup.js.map +1 -1
- package/dist/esm/components/LabelTag/Tag.js +3 -3
- package/dist/esm/components/LabelTag/Tag.js.map +1 -1
- package/dist/esm/components/LabelTag/TagCircle.js +11 -2
- package/dist/esm/components/LabelTag/TagCircle.js.map +1 -1
- package/dist/esm/components/TabBar/TabBar.js +4 -7
- package/dist/esm/components/TabBar/TabBar.js.map +1 -1
- package/dist/esm/components/TextArea/TextArea.js +33 -31
- package/dist/esm/components/TextArea/TextArea.js.map +1 -1
- package/dist/esm/components/TippyTooltip/EllipsesTippyTooltip.js +16 -0
- package/dist/esm/components/TippyTooltip/EllipsesTippyTooltip.js.map +1 -0
- package/dist/esm/components/TippyTooltip/TippyTooltip.js +117 -0
- package/dist/esm/components/TippyTooltip/TippyTooltip.js.map +1 -0
- package/dist/esm/components/TippyTooltip/index.js +3 -0
- package/dist/esm/components/TippyTooltip/index.js.map +1 -0
- package/dist/esm/components/TippyTooltip/mergePlugins.js.map +1 -0
- package/dist/esm/components/TippyTooltip/plugIns/disableForTouchDevicesPlugin.js.map +1 -0
- package/dist/esm/components/TippyTooltip/plugIns/dpNamePlugin.js.map +1 -0
- package/dist/esm/components/TippyTooltip/plugIns/escPlugin.js.map +1 -0
- package/dist/esm/components/TippyTooltip/plugIns/index.js.map +1 -0
- package/dist/esm/components/Tooltip/EllipsesTooltip.js +2 -3
- package/dist/esm/components/Tooltip/EllipsesTooltip.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +136 -101
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Tooltip/index.js.map +1 -1
- package/dist/esm/components/Tooltip/styles.js +197 -0
- package/dist/esm/components/Tooltip/styles.js.map +1 -0
- package/dist/esm/components/Tooltip/types.js +2 -0
- package/dist/esm/components/Tooltip/types.js.map +1 -0
- package/dist/esm/components/Tooltip/utils.js +187 -0
- package/dist/esm/components/Tooltip/utils.js.map +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/hooks/useOnClickOutside.js +23 -0
- package/dist/esm/hooks/useOnClickOutside.js.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/components/Tooltip/mergePlugins.js.map +0 -1
- package/dist/cjs/components/Tooltip/plugIns/disableForTouchDevicesPlugin.js.map +0 -1
- package/dist/cjs/components/Tooltip/plugIns/dpNamePlugin.js.map +0 -1
- package/dist/cjs/components/Tooltip/plugIns/escPlugin.js.map +0 -1
- package/dist/cjs/components/Tooltip/plugIns/index.js.map +0 -1
- package/dist/esm/components/Tooltip/mergePlugins.js.map +0 -1
- package/dist/esm/components/Tooltip/plugIns/disableForTouchDevicesPlugin.js.map +0 -1
- package/dist/esm/components/Tooltip/plugIns/dpNamePlugin.js.map +0 -1
- package/dist/esm/components/Tooltip/plugIns/escPlugin.js.map +0 -1
- package/dist/esm/components/Tooltip/plugIns/index.js.map +0 -1
- /package/dist/cjs/components/{Tooltip → TippyTooltip}/mergePlugins.js +0 -0
- /package/dist/cjs/components/{Tooltip → TippyTooltip}/plugIns/disableForTouchDevicesPlugin.js +0 -0
- /package/dist/cjs/components/{Tooltip → TippyTooltip}/plugIns/dpNamePlugin.js +0 -0
- /package/dist/cjs/components/{Tooltip → TippyTooltip}/plugIns/escPlugin.js +0 -0
- /package/dist/cjs/components/{Tooltip → TippyTooltip}/plugIns/index.js +0 -0
- /package/dist/esm/components/{Tooltip → TippyTooltip}/mergePlugins.js +0 -0
- /package/dist/esm/components/{Tooltip → TippyTooltip}/plugIns/disableForTouchDevicesPlugin.js +0 -0
- /package/dist/esm/components/{Tooltip → TippyTooltip}/plugIns/dpNamePlugin.js +0 -0
- /package/dist/esm/components/{Tooltip → TippyTooltip}/plugIns/escPlugin.js +0 -0
- /package/dist/esm/components/{Tooltip → TippyTooltip}/plugIns/index.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsesTooltip.js","sourceRoot":"","sources":["../../../../src/components/Tooltip/EllipsesTooltip.tsx"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,uCAAoC;
|
|
1
|
+
{"version":3,"file":"EllipsesTooltip.js","sourceRoot":"","sources":["../../../../src/components/Tooltip/EllipsesTooltip.tsx"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,uCAAoC;AAGpC;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAgB,EAAE,EAAE;;IAC/D,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,MAAA,GAAG,CAAC,OAAO,0CAAE,iBAAiB,CAAC;IAC7C,MAAM,UAAU,GAAG,KAAK,IAAI,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;IAClE,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;QAC3C,oBAAC,iBAAO,OAAK,KAAK,EAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC,UAAU,IAClD,KAAK,CAAC,QAAQ,CACP,CACN,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -2,118 +2,154 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TooltipCommonIcon = exports.Tooltip = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const
|
|
6
|
-
const react_1 = require("@tippyjs/react");
|
|
7
|
-
const layout_1 = require("../../layout");
|
|
5
|
+
const react_1 = require("react");
|
|
8
6
|
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
|
9
7
|
const Icon_1 = require("../Icon");
|
|
10
8
|
const dpName_1 = require("../../utils/dpName");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
color: theme.colors.grey_black100,
|
|
19
|
-
border: `1px solid ${theme.colors.systemShade30}`,
|
|
20
|
-
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
21
|
-
},
|
|
22
|
-
lightBox: {
|
|
23
|
-
backgroundColor: theme.colors.white,
|
|
24
|
-
color: theme.colors.grey100,
|
|
25
|
-
border: `1px solid ${theme.colors.grey20}`,
|
|
26
|
-
borderColor: theme.colors.grey20,
|
|
27
|
-
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
28
|
-
},
|
|
29
|
-
// this type is based of the same styling as the modal component
|
|
30
|
-
lightBoxModal: {
|
|
31
|
-
backgroundColor: theme.colors.white,
|
|
32
|
-
color: theme.colors.grey100,
|
|
33
|
-
border: `1px solid ${theme.colors.grey20}`,
|
|
34
|
-
borderColor: theme.colors.grey20,
|
|
35
|
-
boxShadow: "0px 4px 16px rgba(0, 0, 0, 0.3)",
|
|
36
|
-
},
|
|
37
|
-
dark: {
|
|
38
|
-
backgroundColor: theme.colors.grey_black100,
|
|
39
|
-
color: theme.colors.white,
|
|
40
|
-
border: "none",
|
|
41
|
-
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
42
|
-
},
|
|
43
|
-
extraDark: {
|
|
44
|
-
backgroundColor: theme.colors.grey100,
|
|
45
|
-
color: theme.colors.white,
|
|
46
|
-
border: "none",
|
|
47
|
-
borderColor: theme.colors.grey100,
|
|
48
|
-
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
52
|
-
return styles[styleType] || styles.dark;
|
|
53
|
-
};
|
|
9
|
+
const Portal_1 = require("../Portal");
|
|
10
|
+
const styles_1 = require("./styles");
|
|
11
|
+
const useOnClickOutside_1 = require("../../hooks/useOnClickOutside");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
const utils_2 = require("./utils");
|
|
14
|
+
const lodash_1 = require("lodash");
|
|
15
|
+
const react_resize_observer_1 = require("react-resize-observer");
|
|
54
16
|
/**
|
|
55
17
|
* @public
|
|
56
18
|
*/
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
19
|
+
const Tooltip = ({ styleType, width, maxWidth = 350, offsetTop, offsetLeft, offset, visible, interactive, styledCss, customComponent, borderRadius, onPressEsc, enableOnTouchDevices, placement = "top", disabled, content, className, delay = [200, 0], hideOnClick, onClickOutside, onShow, onHide, duration, arrow, arrowColor, children, }) => {
|
|
20
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(!!visible);
|
|
21
|
+
const [position, setPosition] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
22
|
+
const [arrowPosition, setArrowPosition] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
23
|
+
const [calculatedPlacement, setCalculatedPlacement] = (0, react_1.useState)(placement);
|
|
24
|
+
const triggerRef = (0, react_1.useRef)(null);
|
|
25
|
+
const tooltipRef = (0, react_1.useRef)(null);
|
|
26
|
+
const delayOpenRef = (0, react_1.useRef)();
|
|
27
|
+
const delayCloseRef = (0, react_1.useRef)();
|
|
28
|
+
const openDelay = typeof delay === "number" ? delay : delay && delay.length ? delay[0] : 0;
|
|
29
|
+
const closeDelay = typeof delay === "number" ? delay : delay && delay.length ? delay[1] : 0;
|
|
30
|
+
const calculatedOffset = offset || [offsetLeft !== null && offsetLeft !== void 0 ? offsetLeft : 0, offsetTop !== null && offsetTop !== void 0 ? offsetTop : 0];
|
|
31
|
+
const isDisabled = disabled || ((0, utils_1.isTouch)() && !enableOnTouchDevices);
|
|
32
|
+
const handleOpen = (0, react_1.useCallback)(() => {
|
|
33
|
+
setIsOpen(true);
|
|
34
|
+
onShow === null || onShow === void 0 ? void 0 : onShow();
|
|
35
|
+
}, [onShow]);
|
|
36
|
+
const handleClose = (0, react_1.useCallback)(() => {
|
|
37
|
+
setIsOpen(false);
|
|
38
|
+
onHide === null || onHide === void 0 ? void 0 : onHide();
|
|
39
|
+
}, [onHide]);
|
|
40
|
+
const onClickOutsideHandler = (0, react_1.useCallback)(() => {
|
|
41
|
+
if (hideOnClick) {
|
|
42
|
+
handleClose();
|
|
43
|
+
}
|
|
44
|
+
onClickOutside === null || onClickOutside === void 0 ? void 0 : onClickOutside();
|
|
45
|
+
}, [handleClose, hideOnClick, onClickOutside]);
|
|
46
|
+
(0, useOnClickOutside_1.useOnClickOutside)(tooltipRef, isOpen ? onClickOutsideHandler : undefined);
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
if (!isDisabled && visible !== undefined) {
|
|
49
|
+
visible ? handleOpen() : handleClose();
|
|
50
|
+
}
|
|
51
|
+
}, [handleClose, handleOpen, isDisabled, visible]);
|
|
52
|
+
(0, react_1.useEffect)(() => {
|
|
53
|
+
const handleEsc = (event) => {
|
|
54
|
+
if (event.key === "Escape") {
|
|
55
|
+
onPressEsc === null || onPressEsc === void 0 ? void 0 : onPressEsc();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
if (isOpen) {
|
|
59
|
+
window.addEventListener("keydown", handleEsc);
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
window.removeEventListener("keydown", handleEsc);
|
|
63
|
+
};
|
|
64
|
+
}, [isOpen, onPressEsc]);
|
|
65
|
+
(0, react_1.useEffect)(() => {
|
|
66
|
+
return () => {
|
|
67
|
+
delayOpenRef.current && clearTimeout(delayOpenRef.current);
|
|
68
|
+
delayCloseRef.current && clearTimeout(delayCloseRef.current);
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
const positionTooltip = (0, react_1.useCallback)(() => {
|
|
72
|
+
var _a, _b, _c;
|
|
73
|
+
if (isOpen && !isDisabled) {
|
|
74
|
+
const triggerRect = (_b = (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.firstElementChild) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
75
|
+
const tooltipRect = (_c = tooltipRef.current) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
|
|
76
|
+
if (triggerRect && tooltipRect) {
|
|
77
|
+
const { position, calculatedPlacement } = (0, utils_2.getPositionAndPlacement)(utils_2.placementMap[placement], triggerRect, tooltipRect);
|
|
78
|
+
setPosition(position);
|
|
79
|
+
setCalculatedPlacement(calculatedPlacement);
|
|
80
|
+
if (arrow) {
|
|
81
|
+
const arrowPosition = (0, utils_2.getArrowPosition)(calculatedPlacement, triggerRect, {
|
|
82
|
+
x: position.x,
|
|
83
|
+
y: position.y,
|
|
84
|
+
width: tooltipRect.width,
|
|
85
|
+
height: tooltipRect.height,
|
|
86
|
+
});
|
|
87
|
+
setArrowPosition(arrowPosition);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, [arrow, isDisabled, isOpen, placement]);
|
|
92
|
+
const throttledPositionTooltip = (0, react_1.useMemo)(() => (0, lodash_1.throttle)(positionTooltip, 100), [positionTooltip]);
|
|
93
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
94
|
+
positionTooltip();
|
|
95
|
+
}, [positionTooltip]);
|
|
96
|
+
const onMouseEnterTrigger = (0, react_1.useCallback)(() => {
|
|
97
|
+
if (visible === undefined) {
|
|
98
|
+
delayOpenRef.current = setTimeout(() => {
|
|
99
|
+
handleOpen();
|
|
100
|
+
}, openDelay);
|
|
107
101
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
}, [handleOpen, openDelay, visible]);
|
|
103
|
+
const onMouseLeaveTrigger = (0, react_1.useCallback)(() => {
|
|
104
|
+
delayOpenRef.current && clearTimeout(delayOpenRef.current);
|
|
105
|
+
delayOpenRef.current = undefined;
|
|
106
|
+
if (visible === undefined) {
|
|
107
|
+
delayCloseRef.current = setTimeout(() => {
|
|
108
|
+
handleClose();
|
|
109
|
+
}, closeDelay);
|
|
110
|
+
}
|
|
111
|
+
}, [closeDelay, handleClose, visible]);
|
|
112
|
+
const onMouseEnterTooltip = (0, react_1.useCallback)(() => {
|
|
113
|
+
if (interactive) {
|
|
114
|
+
delayCloseRef.current && clearTimeout(delayCloseRef.current);
|
|
115
|
+
delayCloseRef.current = undefined;
|
|
116
|
+
handleOpen();
|
|
117
|
+
}
|
|
118
|
+
}, [handleOpen, interactive]);
|
|
119
|
+
const onMouseLeaveTooltip = (0, react_1.useCallback)(() => {
|
|
120
|
+
if (visible === undefined) {
|
|
121
|
+
delayOpenRef.current && clearTimeout(delayOpenRef.current);
|
|
122
|
+
delayCloseRef.current = setTimeout(() => {
|
|
123
|
+
handleClose();
|
|
124
|
+
}, closeDelay);
|
|
125
|
+
}
|
|
126
|
+
}, [closeDelay, handleClose, visible]);
|
|
127
|
+
(0, react_1.useEffect)(() => {
|
|
128
|
+
window.addEventListener("resize", throttledPositionTooltip);
|
|
129
|
+
return () => window.removeEventListener("resize", throttledPositionTooltip);
|
|
130
|
+
}, [throttledPositionTooltip]);
|
|
131
|
+
if (isDisabled) {
|
|
132
|
+
return React.createElement(React.Fragment, null, children);
|
|
133
|
+
}
|
|
134
|
+
return (React.createElement(React.Fragment, null,
|
|
135
|
+
isOpen ? (React.createElement(Portal_1.Portal, null,
|
|
136
|
+
React.createElement(styles_1.Wrapper, { isOpen: isOpen, position: position, isVisible: true, className: "tooltip-wrapper" },
|
|
137
|
+
React.createElement(styles_1.Root, { ref: tooltipRef, width: width, maxWidth: maxWidth, placement: calculatedPlacement, className: `tooltip-root ${className !== null && className !== void 0 ? className : ""}`, onMouseEnter: onMouseEnterTooltip, onMouseLeave: onMouseLeaveTooltip, styledCss: styledCss },
|
|
138
|
+
React.createElement(react_resize_observer_1.default, { onResize: () => {
|
|
139
|
+
positionTooltip();
|
|
140
|
+
} }),
|
|
141
|
+
React.createElement(styles_1.Box, { padding: customComponent ? "0" : undefined, styleType: styleType, borderRadius: borderRadius, offset: calculatedOffset, className: "tooltip-box", duration: duration },
|
|
142
|
+
React.createElement(styles_1.Content, { className: "tooltip-content" }, content),
|
|
143
|
+
arrow ? (React.createElement(styles_1.Arrow, { placement: calculatedPlacement, position: arrowPosition, arrowColor: arrowColor, styleType: styleType, className: "tooltip-arrow" })) : null))))) : null,
|
|
144
|
+
React.createElement(styles_1.Trigger, { ref: triggerRef, onMouseEnter: onMouseEnterTrigger, onMouseLeave: onMouseLeaveTrigger }, children)));
|
|
145
|
+
};
|
|
146
|
+
exports.Tooltip = Tooltip;
|
|
111
147
|
/**
|
|
112
148
|
* @public
|
|
113
149
|
*/
|
|
114
150
|
function TooltipCommonIcon({ content, styleType = "light", placement = "top", iconSize = 10, }) {
|
|
115
|
-
return (React.createElement(exports.Tooltip, { ...(0, dpName_1.dpNameProp)("Tooltip"), content: content,
|
|
116
|
-
React.createElement(
|
|
151
|
+
return (React.createElement(exports.Tooltip, { ...(0, dpName_1.dpNameProp)("Tooltip"), content: content, placement: placement, styleType: styleType },
|
|
152
|
+
React.createElement("span", null,
|
|
117
153
|
React.createElement(Icon_1.Icon, { icon: free_solid_svg_icons_1.faQuestionCircle, themeColor: "grey40", size: iconSize }))));
|
|
118
154
|
}
|
|
119
155
|
exports.TooltipCommonIcon = TooltipCommonIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,iCAA2F;AAC3F,4EAAqE;AACrE,kCAA+B;AAC/B,+CAAgD;AAChD,sCAAmC;AACnC,qCAAuE;AAEvE,qEAAkE;AAClE,uCAAsC;AACtC,mCAAkF;AAGlF,mCAAkC;AAClC,iEAAmD;AAmCnD;;GAEG;AACI,MAAM,OAAO,GAAG,CAAC,EACtB,SAAS,EACT,KAAK,EACL,QAAQ,GAAG,GAAG,EACd,SA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AC;AACJ,CAAC,CAAC;AA1NW,QAAA,OAAO,WA0NlB;AAYF;;GAEG;AACH,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,SAAS,GAAG,OAAO,EACnB,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,EAAE,GACU;IACvB,OAAO,CACL,oBAAC,eAAO,OACF,IAAA,mBAAU,EAAC,SAAS,CAAC,EACzB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS;QAEpB;YACE,oBAAC,WAAI,IAAC,IAAI,EAAE,uCAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,GAAI,CACjE,CACC,CACX,CAAC;AACJ,CAAC;AAlBD,8CAkBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Tooltip/index.ts"],"names":[],"mappings":";;;AAAA,qCAAuD;AAA9C,kGAAA,OAAO,OAAA;AAAE,4GAAA,iBAAiB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Tooltip/index.ts"],"names":[],"mappings":";;;AAAA,qCAAuD;AAA9C,kGAAA,OAAO,OAAA;AAAE,4GAAA,iBAAiB,OAAA;AAGnC,qDAA+D;AAAtD,kHAAA,OAAO,OAAmB"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStyle = exports.Arrow = exports.Trigger = exports.Content = exports.Box = exports.Root = exports.Wrapper = void 0;
|
|
4
|
+
const styled_components_1 = require("styled-components");
|
|
5
|
+
const styled_components_2 = require("styled-components");
|
|
6
|
+
const ts_pattern_1 = require("ts-pattern");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const DEFAULT_OFFSET = 8;
|
|
9
|
+
exports.Wrapper = styled_components_2.default.div `
|
|
10
|
+
z-index: 9999;
|
|
11
|
+
display: ${({ isOpen }) => (isOpen ? "block" : "none")};
|
|
12
|
+
visibility: ${({ isVisible }) => (isVisible ? "visible" : "hidden")};
|
|
13
|
+
position: absolute;
|
|
14
|
+
inset: 0px 0px auto auto;
|
|
15
|
+
margin: 0px;
|
|
16
|
+
top: 0;
|
|
17
|
+
left: 0;
|
|
18
|
+
transform: ${({ position }) => `translate(${position.x}px, ${position.y}px)`};
|
|
19
|
+
width: fit-content;
|
|
20
|
+
`;
|
|
21
|
+
exports.Root = styled_components_2.default.div `
|
|
22
|
+
padding: ${({ placement }) => getPositionPadding(placement)};
|
|
23
|
+
max-width: ${({ maxWidth }) => maxWidth
|
|
24
|
+
? typeof maxWidth === "string"
|
|
25
|
+
? `${maxWidth} !important`
|
|
26
|
+
: `${maxWidth}px !important`
|
|
27
|
+
: undefined};
|
|
28
|
+
width: ${({ width }) => width};
|
|
29
|
+
${({ styledCss }) => styledCss}
|
|
30
|
+
`;
|
|
31
|
+
const getPositionPadding = (placement) => placement.includes("top")
|
|
32
|
+
? `0 0 ${DEFAULT_OFFSET}px 0`
|
|
33
|
+
: placement.includes("bottom")
|
|
34
|
+
? `${DEFAULT_OFFSET}px 0 0 0`
|
|
35
|
+
: placement.includes("left")
|
|
36
|
+
? `0 ${DEFAULT_OFFSET}px 0 0`
|
|
37
|
+
: `0 0 0 ${DEFAULT_OFFSET}px`;
|
|
38
|
+
exports.Box = styled_components_2.default.div `
|
|
39
|
+
position: relative;
|
|
40
|
+
padding: ${({ padding }) => padding !== null && padding !== void 0 ? padding : "5px 9px"};
|
|
41
|
+
z-index: 1;
|
|
42
|
+
|
|
43
|
+
background-color: ${({ theme, styleType = "light" }) => (0, exports.getStyle)(styleType, theme).backgroundColor};
|
|
44
|
+
color: ${({ theme, styleType = "light" }) => (0, exports.getStyle)(styleType, theme).color};
|
|
45
|
+
box-shadow: ${({ theme, styleType = "light" }) => (0, exports.getStyle)(styleType, theme).boxShadow};
|
|
46
|
+
border: ${({ theme, styleType = "light" }) => (0, exports.getStyle)(styleType, theme).border};
|
|
47
|
+
border-radius: ${({ borderRadius }) => (borderRadius ? borderRadius : 3)}px;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
font-family: ${(props) => props.theme.fonts.primary};
|
|
52
|
+
font-style: normal;
|
|
53
|
+
font-weight: normal;
|
|
54
|
+
font-size: 11px;
|
|
55
|
+
line-height: 150%;
|
|
56
|
+
word-break: break-word;
|
|
57
|
+
${({ offset: [, offsetTop] }) => offsetTop && `top: ${offsetTop}px !important`};
|
|
58
|
+
${({ offset: [offsetLeft] }) => offsetLeft && `left: ${offsetLeft}px !important`};
|
|
59
|
+
transition-property: transform, visibility, opacity;
|
|
60
|
+
transition-duration: ${({ duration = 250 }) => duration}ms;
|
|
61
|
+
`;
|
|
62
|
+
exports.Content = styled_components_2.default.div ``;
|
|
63
|
+
exports.Trigger = styled_components_2.default.div `
|
|
64
|
+
display: contents;
|
|
65
|
+
`;
|
|
66
|
+
exports.Arrow = styled_components_2.default.div `
|
|
67
|
+
position: absolute;
|
|
68
|
+
width: ${utils_1.ARROW_WIDTH}px;
|
|
69
|
+
height: ${utils_1.ARROW_WIDTH}px;
|
|
70
|
+
transform: ${({ position }) => `translate(${position.x}px, ${position.y}px)`};
|
|
71
|
+
${({ placement, arrowColor, theme, styleType }) => getArrowCss(placement, arrowColor, theme, styleType)}
|
|
72
|
+
|
|
73
|
+
&::before {
|
|
74
|
+
content: "";
|
|
75
|
+
position: absolute;
|
|
76
|
+
${({ placement, arrowColor, theme, styleType }) => getArrowPseudoCss("before", placement, arrowColor, theme, styleType)}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&::after {
|
|
80
|
+
content: "";
|
|
81
|
+
z-index: -1;
|
|
82
|
+
position: absolute;
|
|
83
|
+
${({ placement, arrowColor, theme, styleType }) => getArrowPseudoCss("after", placement, arrowColor, theme, styleType)}
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
const getArrowCss = (placement, arrowColor, theme, styleType = "light") => {
|
|
87
|
+
const color = arrowColor ? theme.colors[arrowColor] : (0, exports.getStyle)(styleType, theme).backgroundColor;
|
|
88
|
+
return (0, ts_pattern_1.match)(placement)
|
|
89
|
+
.when((placement) => placement.includes("bottom"), () => (0, styled_components_1.css) `
|
|
90
|
+
top: 0;
|
|
91
|
+
left: 0;
|
|
92
|
+
color: ${color};
|
|
93
|
+
border-top-color: ${color};
|
|
94
|
+
`)
|
|
95
|
+
.when((placement) => placement.includes("top"), () => (0, styled_components_1.css) `
|
|
96
|
+
bottom: 0;
|
|
97
|
+
left: 0;
|
|
98
|
+
color: ${color};
|
|
99
|
+
border-bottom-color: ${color};
|
|
100
|
+
`)
|
|
101
|
+
.when((placement) => placement.includes("left"), () => (0, styled_components_1.css) `
|
|
102
|
+
right: 0;
|
|
103
|
+
top: 0;
|
|
104
|
+
color: ${color};
|
|
105
|
+
border-left-color: ${color};
|
|
106
|
+
`)
|
|
107
|
+
.when((placement) => placement.includes("right"), () => (0, styled_components_1.css) `
|
|
108
|
+
left: 0;
|
|
109
|
+
top: 0;
|
|
110
|
+
color: ${color};
|
|
111
|
+
border-right-color: ${color};
|
|
112
|
+
`)
|
|
113
|
+
.otherwise(() => undefined);
|
|
114
|
+
};
|
|
115
|
+
const getArrowPseudoCss = (type, placement, arrowColor, theme, styleType = "light") => {
|
|
116
|
+
const borderColor = type === "before"
|
|
117
|
+
? "initial"
|
|
118
|
+
: arrowColor
|
|
119
|
+
? theme.colors[arrowColor]
|
|
120
|
+
: (0, exports.getStyle)(styleType, theme).borderColor;
|
|
121
|
+
const offset = type === "before" ? "-7px" : "-8px";
|
|
122
|
+
const halfArrowWidth = `${utils_1.ARROW_WIDTH / 2}px`;
|
|
123
|
+
return (0, ts_pattern_1.match)(placement)
|
|
124
|
+
.when((placement) => placement.includes("bottom"), () => (0, styled_components_1.css) `
|
|
125
|
+
left: 0;
|
|
126
|
+
top: ${offset};
|
|
127
|
+
border-color: transparent;
|
|
128
|
+
border-bottom-color: ${borderColor};
|
|
129
|
+
border-width: 0 ${halfArrowWidth} ${halfArrowWidth};
|
|
130
|
+
border-style: solid;
|
|
131
|
+
`)
|
|
132
|
+
.when((placement) => placement.includes("top"), () => (0, styled_components_1.css) `
|
|
133
|
+
left: 0;
|
|
134
|
+
bottom: ${offset};
|
|
135
|
+
border-color: transparent;
|
|
136
|
+
border-top-color: ${borderColor};
|
|
137
|
+
border-width: ${halfArrowWidth} ${halfArrowWidth} 0;
|
|
138
|
+
border-style: solid;
|
|
139
|
+
`)
|
|
140
|
+
.when((placement) => placement.includes("left"), () => (0, styled_components_1.css) `
|
|
141
|
+
top: 0;
|
|
142
|
+
right: ${offset};
|
|
143
|
+
border-color: transparent;
|
|
144
|
+
border-left-color: ${borderColor};
|
|
145
|
+
border-width: ${halfArrowWidth} 0 ${halfArrowWidth} ${halfArrowWidth};
|
|
146
|
+
border-style: solid;
|
|
147
|
+
`)
|
|
148
|
+
.when((placement) => placement.includes("right"), () => (0, styled_components_1.css) `
|
|
149
|
+
top: 0;
|
|
150
|
+
left: ${offset};
|
|
151
|
+
border-color: transparent;
|
|
152
|
+
border-right-color: ${borderColor};
|
|
153
|
+
border-width: ${halfArrowWidth} ${halfArrowWidth} ${halfArrowWidth} 0;
|
|
154
|
+
border-style: solid;
|
|
155
|
+
`)
|
|
156
|
+
.otherwise(() => undefined);
|
|
157
|
+
};
|
|
158
|
+
const getStyle = (styleType, theme) => {
|
|
159
|
+
const styles = {
|
|
160
|
+
light: {
|
|
161
|
+
backgroundColor: theme.colors.grey3,
|
|
162
|
+
color: theme.colors.grey_black100,
|
|
163
|
+
border: `1px solid ${theme.colors.systemShade30}`,
|
|
164
|
+
borderColor: theme.colors.systemShade30,
|
|
165
|
+
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
166
|
+
},
|
|
167
|
+
lightBox: {
|
|
168
|
+
backgroundColor: theme.colors.white,
|
|
169
|
+
color: theme.colors.grey100,
|
|
170
|
+
border: `1px solid ${theme.colors.grey20}`,
|
|
171
|
+
borderColor: theme.colors.grey20,
|
|
172
|
+
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
173
|
+
},
|
|
174
|
+
// this type is based of the same styling as the modal component
|
|
175
|
+
lightBoxModal: {
|
|
176
|
+
backgroundColor: theme.colors.white,
|
|
177
|
+
color: theme.colors.grey100,
|
|
178
|
+
border: `1px solid ${theme.colors.grey20}`,
|
|
179
|
+
borderColor: theme.colors.grey20,
|
|
180
|
+
boxShadow: "0px 4px 16px rgba(0, 0, 0, 0.3)",
|
|
181
|
+
},
|
|
182
|
+
dark: {
|
|
183
|
+
backgroundColor: theme.colors.grey_black100,
|
|
184
|
+
color: theme.colors.white,
|
|
185
|
+
border: `1px solid ${theme.colors.grey_black100}`,
|
|
186
|
+
borderColor: theme.colors.grey_black100,
|
|
187
|
+
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
188
|
+
},
|
|
189
|
+
extraDark: {
|
|
190
|
+
backgroundColor: theme.colors.grey100,
|
|
191
|
+
color: theme.colors.white,
|
|
192
|
+
border: `1px solid ${theme.colors.grey100}`,
|
|
193
|
+
borderColor: theme.colors.grey100,
|
|
194
|
+
boxShadow: "0px 4px 6px -1px rgba(0, 0, 0, 0.1), 0px 2px 4px -1px rgba(0, 0, 0, 0.06);",
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
198
|
+
return styles[styleType] || styles.dark;
|
|
199
|
+
};
|
|
200
|
+
exports.getStyle = getStyle;
|
|
201
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js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