sag_components 1.0.1069 → 1.0.1070

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.
@@ -93,24 +93,24 @@ const Heatmap = props => {
93
93
  duration: 0.4
94
94
  },
95
95
  onMouseEnter: e => {
96
- var _barRefs$current$inde;
96
+ var _barRefs$current$inde, _barsContainerRef$cur;
97
97
  const barRect = (_barRefs$current$inde = barRefs.current[index]) === null || _barRefs$current$inde === void 0 ? void 0 : _barRefs$current$inde.getBoundingClientRect();
98
+ const parentRect = (_barsContainerRef$cur = barsContainerRef.current) === null || _barsContainerRef$cur === void 0 ? void 0 : _barsContainerRef$cur.getBoundingClientRect();
98
99
  if (barRect && e.clientX > barRect.x && e.clientX < barRect.x + barRect.width && e.clientY > barRect.y && e.clientY < barRect.y + barRect.height) {
99
- var _e$nativeEvent, _e$nativeEvent2;
100
100
  setTooltip({
101
101
  label: `${item.label} - ${Math.round(item.value / totalValue * 100)}%`
102
102
  });
103
- // Prevent setting tooltip position if mouse is over the tooltip element
104
- if (e.target.classList.contains('TooltipContainer')) {
105
- return; // Exit early if mouse is over the tooltip
106
- }
107
- if ((_e$nativeEvent = e.nativeEvent) !== null && _e$nativeEvent !== void 0 && _e$nativeEvent.layerX && (_e$nativeEvent2 = e.nativeEvent) !== null && _e$nativeEvent2 !== void 0 && _e$nativeEvent2.layerY) {
108
- var _e$nativeEvent3, _e$nativeEvent4;
103
+ if (parentRect) {
104
+ let tooltipX = e.clientX + 10; // Default: Position to the right of the cursor
105
+ const tooltipWidth = 150; // Estimate tooltip width (adjust as needed)
106
+
107
+ // If tooltip would overflow, move it to the left of the cursor
108
+ if (tooltipX + tooltipWidth > parentRect.right) {
109
+ tooltipX = e.clientX - tooltipWidth - 10;
110
+ }
109
111
  setTooltipPosition({
110
- // eslint-disable-next-line no-unsafe-optional-chaining
111
- x: ((_e$nativeEvent3 = e.nativeEvent) === null || _e$nativeEvent3 === void 0 ? void 0 : _e$nativeEvent3.layerX) + 10,
112
- // eslint-disable-next-line no-unsafe-optional-chaining
113
- y: ((_e$nativeEvent4 = e.nativeEvent) === null || _e$nativeEvent4 === void 0 ? void 0 : _e$nativeEvent4.layerY) + 20
112
+ x: tooltipX,
113
+ y: e.clientY - 30
114
114
  });
115
115
  }
116
116
  }
@@ -123,21 +123,19 @@ const Heatmap = props => {
123
123
  }
124
124
  },
125
125
  onMouseMove: e => {
126
- var _barRefs$current$inde3;
126
+ var _barRefs$current$inde3, _barsContainerRef$cur2;
127
127
  const barRect = (_barRefs$current$inde3 = barRefs.current[index]) === null || _barRefs$current$inde3 === void 0 ? void 0 : _barRefs$current$inde3.getBoundingClientRect();
128
+ const parentRect = (_barsContainerRef$cur2 = barsContainerRef.current) === null || _barsContainerRef$cur2 === void 0 ? void 0 : _barsContainerRef$cur2.getBoundingClientRect();
128
129
  if (barRect && e.clientX > barRect.x && e.clientX < barRect.x + barRect.width && e.clientY > barRect.y && e.clientY < barRect.y + barRect.height) {
129
- var _e$nativeEvent5, _e$nativeEvent6;
130
- // Prevent setting tooltip position if mouse is over the tooltip element
131
- if (e.target.classList.contains('TooltipContainer')) {
132
- return; // Exit early if mouse is over the tooltip
133
- }
134
- if ((_e$nativeEvent5 = e.nativeEvent) !== null && _e$nativeEvent5 !== void 0 && _e$nativeEvent5.layerX && (_e$nativeEvent6 = e.nativeEvent) !== null && _e$nativeEvent6 !== void 0 && _e$nativeEvent6.layerY) {
135
- var _e$nativeEvent7, _e$nativeEvent8;
130
+ if (parentRect) {
131
+ let tooltipX = e.clientX + 10;
132
+ const tooltipWidth = 150;
133
+ if (tooltipX + tooltipWidth > parentRect.right) {
134
+ tooltipX = e.clientX - tooltipWidth - 10;
135
+ }
136
136
  setTooltipPosition({
137
- // eslint-disable-next-line no-unsafe-optional-chaining
138
- x: ((_e$nativeEvent7 = e.nativeEvent) === null || _e$nativeEvent7 === void 0 ? void 0 : _e$nativeEvent7.layerX) + 10,
139
- // eslint-disable-next-line no-unsafe-optional-chaining
140
- y: ((_e$nativeEvent8 = e.nativeEvent) === null || _e$nativeEvent8 === void 0 ? void 0 : _e$nativeEvent8.layerY) + 20
137
+ x: tooltipX,
138
+ y: e.clientY - 30
141
139
  });
142
140
  }
143
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sag_components",
3
- "version": "1.0.1069",
3
+ "version": "1.0.1070",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {