@wireapp/react-ui-kit 9.15.2 → 9.15.4
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/Form/Tooltip.d.ts.map +1 -1
- package/lib/Form/Tooltip.js +26 -19
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Form/Tooltip.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAA0B,SAAS,EAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../src/Form/Tooltip.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAA0B,SAAS,EAAmB,MAAM,OAAO,CAAC;AAsHrF,UAAU,YAAY,CAAC,CAAC,GAAG,cAAc,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC7D,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAID,eAAO,MAAM,OAAO,2BAA0B,YAAY,qDAiCzD,CAAC"}
|
package/lib/Form/Tooltip.js
CHANGED
|
@@ -34,36 +34,43 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
34
34
|
const react_1 = require("react");
|
|
35
35
|
const react_dom_1 = require("react-dom");
|
|
36
36
|
const util_1 = require("../util");
|
|
37
|
-
const
|
|
37
|
+
const paddingDistance = 8;
|
|
38
38
|
const tooltipStyle = theme => ({
|
|
39
|
-
position: '
|
|
39
|
+
position: 'fixed',
|
|
40
40
|
zIndex: '99999',
|
|
41
41
|
maxWidth: '300px',
|
|
42
42
|
filter: 'drop-shadow(1px 2px 6px rgba(0, 0, 0, 0.3))',
|
|
43
43
|
borderRadius: '4px',
|
|
44
|
+
"&[data-position='top']": {
|
|
45
|
+
paddingBottom: `${paddingDistance}px`,
|
|
46
|
+
'.tooltip-arrow': {
|
|
47
|
+
borderTop: `10px solid ${theme.Tooltip.backgroundColor}`,
|
|
48
|
+
bottom: 0,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
"&[data-position='bottom']": {
|
|
52
|
+
paddingTop: `${paddingDistance}px`,
|
|
53
|
+
'.tooltip-arrow': {
|
|
54
|
+
borderBottom: `10px solid ${theme.Tooltip.backgroundColor}`,
|
|
55
|
+
top: 0,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
44
58
|
'.tooltip-content': {
|
|
45
59
|
color: theme.Tooltip.color,
|
|
46
60
|
backgroundColor: theme.Tooltip.backgroundColor,
|
|
61
|
+
borderRadius: '4px',
|
|
47
62
|
fontSize: '12px',
|
|
48
63
|
lineHeight: '14px',
|
|
49
64
|
fontWeight: 400,
|
|
50
|
-
padding: `${
|
|
65
|
+
padding: `${paddingDistance}px 8px`,
|
|
51
66
|
textAlign: 'center',
|
|
52
67
|
},
|
|
53
68
|
'.tooltip-arrow': {
|
|
54
69
|
width: 0,
|
|
55
70
|
height: 0,
|
|
56
|
-
borderLeft: '
|
|
57
|
-
borderRight: '
|
|
71
|
+
borderLeft: '8px solid transparent',
|
|
72
|
+
borderRight: '8px solid transparent',
|
|
58
73
|
position: 'absolute',
|
|
59
|
-
"&[data-position='top']": {
|
|
60
|
-
borderTop: `10px solid ${theme.Tooltip.backgroundColor}`,
|
|
61
|
-
bottom: '-6px',
|
|
62
|
-
},
|
|
63
|
-
"&[data-position='bottom']": {
|
|
64
|
-
borderBottom: `10px solid ${theme.Tooltip.backgroundColor}`,
|
|
65
|
-
top: '-6px',
|
|
66
|
-
},
|
|
67
74
|
},
|
|
68
75
|
});
|
|
69
76
|
const PortalComponent = ({ children, bounding, selector = '#wire-app' }) => {
|
|
@@ -76,15 +83,15 @@ const PortalComponent = ({ children, bounding, selector = '#wire-app' }) => {
|
|
|
76
83
|
if (!bounding || !element) {
|
|
77
84
|
return;
|
|
78
85
|
}
|
|
79
|
-
const isTouchingTopEdge = bounding.y <= element.clientHeight +
|
|
86
|
+
const isTouchingTopEdge = bounding.y <= element.clientHeight + paddingDistance * 2;
|
|
80
87
|
setIsTouchingTop(isTouchingTopEdge);
|
|
81
88
|
const elementWidth = (element.scrollWidth - bounding.width) / 2;
|
|
82
89
|
element.style.left = `${bounding.x - elementWidth}px`;
|
|
83
90
|
if (isTouchingTopEdge) {
|
|
84
|
-
element.style.top = `${bounding.y + bounding.height
|
|
91
|
+
element.style.top = `${bounding.y + bounding.height}px`;
|
|
85
92
|
}
|
|
86
93
|
else {
|
|
87
|
-
element.style.top = `${bounding.y - element.clientHeight
|
|
94
|
+
element.style.top = `${bounding.y - element.clientHeight}px`;
|
|
88
95
|
}
|
|
89
96
|
};
|
|
90
97
|
const tooltipArrowRef = (element) => {
|
|
@@ -96,9 +103,9 @@ const PortalComponent = ({ children, bounding, selector = '#wire-app' }) => {
|
|
|
96
103
|
return;
|
|
97
104
|
}
|
|
98
105
|
const parentElementRect = parentElement.getBoundingClientRect();
|
|
99
|
-
element.style.left = `${parentElementRect.width / 2 -
|
|
106
|
+
element.style.left = `${parentElementRect.width / 2 - paddingDistance}px`;
|
|
100
107
|
};
|
|
101
|
-
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { ref: tooltipRef, className: "tooltip", css: (theme) => tooltipStyle(theme), children: [(0, jsx_runtime_1.jsx)("div", { ref: tooltipArrowRef, className: "tooltip-arrow"
|
|
108
|
+
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsxs)("div", { ref: tooltipRef, className: "tooltip", css: (theme) => tooltipStyle(theme), "data-position": isTouchingTop ? 'bottom' : 'top', children: [(0, jsx_runtime_1.jsx)("div", { ref: tooltipArrowRef, className: "tooltip-arrow" }), (0, jsx_runtime_1.jsx)("div", { className: "tooltip-content", "data-testid": "tooltip-content", children: children })] }), targetElement);
|
|
102
109
|
};
|
|
103
110
|
const filterTooltipProps = (props) => (0, util_1.filterProps)(props, ['body']);
|
|
104
111
|
const Tooltip = (_a) => {
|
|
@@ -108,7 +115,7 @@ const Tooltip = (_a) => {
|
|
|
108
115
|
const filteredProps = filterTooltipProps(props);
|
|
109
116
|
const { body, selector = '#wire-app' } = props;
|
|
110
117
|
const onElementEnter = (event) => {
|
|
111
|
-
const boundingRect = event.
|
|
118
|
+
const boundingRect = event.currentTarget.getBoundingClientRect();
|
|
112
119
|
setIsHovered(true);
|
|
113
120
|
boundingRectRef.current = boundingRect;
|
|
114
121
|
};
|
package/package.json
CHANGED
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"webpack": "^5.74.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@emotion/react": "11
|
|
53
|
-
"@types/react": "^18
|
|
54
|
-
"react": "^18
|
|
55
|
-
"react-dom": "^18
|
|
52
|
+
"@emotion/react": "^11",
|
|
53
|
+
"@types/react": "^18",
|
|
54
|
+
"react": "^18",
|
|
55
|
+
"react-dom": "^18"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@types/react": {
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
"test:watch": "jest --watch",
|
|
71
71
|
"test:update": "jest --updateSnapshot"
|
|
72
72
|
},
|
|
73
|
-
"version": "9.15.
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"version": "9.15.4",
|
|
74
|
+
"gitHead": "6d6565a9ca1963c15568e9c557bcb8d95755fce7"
|
|
75
75
|
}
|