ag-common 0.0.669 → 0.0.670
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.
|
@@ -55,17 +55,21 @@ const Comp = ({ pos, children, }) => {
|
|
|
55
55
|
let right;
|
|
56
56
|
let top;
|
|
57
57
|
let bottom;
|
|
58
|
+
const gap = 5;
|
|
58
59
|
if (size === null || size === void 0 ? void 0 : size.p) {
|
|
59
|
-
left = pos.x +
|
|
60
|
-
if (pos.x + size.p.tooltipWidth > pos.parentWidth) {
|
|
60
|
+
left = pos.x + gap;
|
|
61
|
+
if (pos.x + gap + size.p.tooltipWidth > pos.parentWidth) {
|
|
61
62
|
left = undefined;
|
|
62
|
-
right = pos.parentWidth - pos.x +
|
|
63
|
+
right = pos.parentWidth - pos.x + gap;
|
|
63
64
|
}
|
|
64
65
|
//
|
|
65
|
-
top = pos.y +
|
|
66
|
+
top = pos.y + gap;
|
|
66
67
|
if (top + size.p.tooltipHeight > pos.parentHeight) {
|
|
67
68
|
top = undefined;
|
|
68
69
|
bottom = pos.parentHeight - pos.y;
|
|
70
|
+
if (bottom + size.p.tooltipHeight > pos.parentHeight) {
|
|
71
|
+
bottom = pos.parentHeight - size.p.tooltipHeight;
|
|
72
|
+
}
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
return (react_1.default.createElement(Base, { ref: ref, style: Object.assign({ left,
|
|
@@ -74,11 +78,11 @@ const Comp = ({ pos, children, }) => {
|
|
|
74
78
|
bottom }, (!(size === null || size === void 0 ? void 0 : size.p) && { zIndex: -1 })) }, children(pos.data)));
|
|
75
79
|
};
|
|
76
80
|
const useTooltip = () => {
|
|
77
|
-
const pos = (0, react_1.useState)();
|
|
81
|
+
const [pos, setPosRaw] = (0, react_1.useState)();
|
|
78
82
|
const setPos = (p) => {
|
|
79
83
|
var _a, _b;
|
|
80
84
|
if (!p) {
|
|
81
|
-
|
|
85
|
+
setPosRaw(undefined);
|
|
82
86
|
return;
|
|
83
87
|
}
|
|
84
88
|
const { top: parentTop, left: parentLeft, width: parentWidth, height: parentHeight, } = (_b = (_a = p.parent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : { width: 0, height: 0 };
|
|
@@ -92,12 +96,12 @@ const useTooltip = () => {
|
|
|
92
96
|
x,
|
|
93
97
|
y,
|
|
94
98
|
};
|
|
95
|
-
|
|
99
|
+
setPosRaw(p2);
|
|
96
100
|
};
|
|
97
101
|
return {
|
|
98
102
|
Comp,
|
|
99
103
|
setPos,
|
|
100
|
-
pos
|
|
104
|
+
pos,
|
|
101
105
|
};
|
|
102
106
|
};
|
|
103
107
|
exports.useTooltip = useTooltip;
|
package/package.json
CHANGED