@gpa-gemstone/react-forms 1.1.109 → 1.1.111
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/ToolTip.js +46 -9
- package/package.json +4 -4
package/lib/ToolTip.js
CHANGED
|
@@ -86,6 +86,7 @@ var Tooltip = function (props) {
|
|
|
86
86
|
closeTimer.current = window.setTimeout(function () { return setDelayedShow(false); }, 250);
|
|
87
87
|
}
|
|
88
88
|
}, [props.Show, isTooltipHovered]);
|
|
89
|
+
//Effect to get colors from alert class
|
|
89
90
|
React.useLayoutEffect(function () {
|
|
90
91
|
if (alertRef.current == null)
|
|
91
92
|
return;
|
|
@@ -93,17 +94,49 @@ var Tooltip = function (props) {
|
|
|
93
94
|
setBackgroundColor(style.backgroundColor);
|
|
94
95
|
setColor(style.color);
|
|
95
96
|
});
|
|
97
|
+
//effect to get target element position
|
|
96
98
|
React.useEffect(function () {
|
|
97
|
-
var
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
var updateTargetPosition = function () {
|
|
100
|
+
var target = getTarget(props.Target);
|
|
101
|
+
if (target == null) {
|
|
102
|
+
setTargetElementPosition(defaultTargetPosition);
|
|
103
|
+
setDelayedShow(false);
|
|
104
|
+
setIsTooltipHovered(false);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
var targetLocation = (0, helper_functions_1.GetNodeSize)(target);
|
|
108
|
+
var newPosition = {
|
|
109
|
+
Height: targetLocation.height,
|
|
110
|
+
Top: targetLocation.top,
|
|
111
|
+
Left: targetLocation.left,
|
|
112
|
+
Width: targetLocation.width
|
|
113
|
+
};
|
|
114
|
+
setTargetElementPosition(function (prev) {
|
|
115
|
+
if (!(0, lodash_1.isEqual)(newPosition, prev))
|
|
116
|
+
return newPosition;
|
|
117
|
+
return prev;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
// Initial position calculation
|
|
121
|
+
updateTargetPosition();
|
|
122
|
+
// Only set up observers when tooltip is visible
|
|
123
|
+
if (!shouldShow)
|
|
100
124
|
return;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
125
|
+
var target = getTarget(props.Target);
|
|
126
|
+
if (target == null)
|
|
127
|
+
return;
|
|
128
|
+
window.addEventListener('scroll', updateTargetPosition, true);
|
|
129
|
+
window.addEventListener('resize', updateTargetPosition);
|
|
130
|
+
var resizeObserver = new ResizeObserver(updateTargetPosition);
|
|
131
|
+
resizeObserver.observe(document.body);
|
|
132
|
+
resizeObserver.observe(target);
|
|
133
|
+
return function () {
|
|
134
|
+
window.removeEventListener('scroll', updateTargetPosition, true);
|
|
135
|
+
window.removeEventListener('resize', updateTargetPosition);
|
|
136
|
+
resizeObserver.disconnect();
|
|
137
|
+
};
|
|
138
|
+
}, [shouldShow, props.Target]);
|
|
139
|
+
//Effect to position tooltip
|
|
107
140
|
React.useLayoutEffect(function () {
|
|
108
141
|
var _a = getPosition(toolTip, targetElementPosition, targetPosition), t = _a[0], l = _a[1], arrowLeft = _a[2], actPosition = _a[3];
|
|
109
142
|
setTop(t);
|
|
@@ -185,5 +218,9 @@ var getPosition = function (toolTip, targetPosition, position) {
|
|
|
185
218
|
}
|
|
186
219
|
return [top, left, arrowPositionPercent, effectivePosition];
|
|
187
220
|
};
|
|
221
|
+
var getTarget = function (target) {
|
|
222
|
+
var targets = document.querySelectorAll("[data-tooltip".concat(target === undefined ? '' : "=\"".concat(target, "\""), "]"));
|
|
223
|
+
return targets.length > 0 ? targets[0] : null;
|
|
224
|
+
};
|
|
188
225
|
exports.default = exports.Tooltip;
|
|
189
226
|
var templateObject_1, templateObject_2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpa-gemstone/react-forms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.111",
|
|
4
4
|
"description": "React Form modules for gpa webapps",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"typescript": "5.5.3"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@gpa-gemstone/application-typings": "0.0.
|
|
49
|
-
"@gpa-gemstone/gpa-symbols": "0.0.
|
|
50
|
-
"@gpa-gemstone/helper-functions": "0.0.
|
|
48
|
+
"@gpa-gemstone/application-typings": "0.0.96",
|
|
49
|
+
"@gpa-gemstone/gpa-symbols": "0.0.59",
|
|
50
|
+
"@gpa-gemstone/helper-functions": "0.0.55",
|
|
51
51
|
"@types/react": "^17.0.14",
|
|
52
52
|
"@types/styled-components": "^5.1.11",
|
|
53
53
|
"lodash": "^4.17.21",
|