@dynatrace/strato-geo 3.7.1 → 3.8.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.
@@ -24,6 +24,7 @@ module.exports = __toCommonJS(use_hover_interaction_exports);
24
24
  var import_react_maplibre = require("@vis.gl/react-maplibre");
25
25
  var import_lodash_es = require("lodash");
26
26
  var import_react = require("react");
27
+ var import_use_geo_tooltip_sync = require("./use-geo-tooltip-sync.js");
27
28
  var import_associated_features = require("../utils/associated-features.js");
28
29
  var import_get_min_value_feature = require("../utils/get-min-value-feature.js");
29
30
  const MOUSEMOVE_THROTTLE_MS = 16;
@@ -81,6 +82,10 @@ const useHoverInteraction = (interactiveLayerIds) => {
81
82
  const sourceIdRef = (0, import_react.useRef)(void 0);
82
83
  const interactiveLayerIdsRef = (0, import_react.useRef)(interactiveLayerIds);
83
84
  interactiveLayerIdsRef.current = interactiveLayerIds;
85
+ const inBoundsFromStore = (0, import_use_geo_tooltip_sync.useOverlayTooltipSelector)(
86
+ (state) => state.inBounds
87
+ );
88
+ const prevInBoundsRef = (0, import_react.useRef)(false);
84
89
  const handleMouseOut = (0, import_react.useCallback)(() => {
85
90
  if (!(0, import_lodash_es.isNil)(map)) {
86
91
  blurTrackedFeature(map, featureIdRef, sourceIdRef);
@@ -121,6 +126,13 @@ const useHoverInteraction = (interactiveLayerIds) => {
121
126
  ),
122
127
  [map]
123
128
  );
129
+ (0, import_react.useEffect)(() => {
130
+ const wasJustHidden = prevInBoundsRef.current && !inBoundsFromStore;
131
+ prevInBoundsRef.current = inBoundsFromStore;
132
+ if (wasJustHidden && !(0, import_lodash_es.isNil)(map)) {
133
+ blurTrackedFeature(map, featureIdRef, sourceIdRef);
134
+ }
135
+ }, [inBoundsFromStore, map]);
124
136
  (0, import_react.useEffect)(() => {
125
137
  map?.on("mousemove", throttledMouseMove);
126
138
  map?.on("mouseout", handleMouseOut);
@@ -46,6 +46,7 @@ const useOverlayEvents = () => {
46
46
  const dispatch = (0, import_charts._useOverlayTooltipReducer)();
47
47
  const store = (0, import_charts._useOverlayTooltipStore)();
48
48
  const overlay = (0, import_charts._useOverlayChart)();
49
+ const pinnedFeatureIdRef = (0, import_react.useRef)(void 0);
49
50
  const getAbsolutePosition = (event) => {
50
51
  return {
51
52
  x: Math.round(event.originalEvent.clientX),
@@ -65,6 +66,23 @@ const useOverlayEvents = () => {
65
66
  const hideTooltip = () => {
66
67
  dispatch({ type: "RESET_TOOLTIP" })();
67
68
  setTooltipMarker(void 0, void 0);
69
+ pinnedFeatureIdRef.current = void 0;
70
+ };
71
+ const showHoverTooltip = (event, data, hoveredLayerId) => {
72
+ overlay.clear();
73
+ setTooltipMarker(hoveredLayerId, event.lngLat);
74
+ const pos = getAbsolutePosition(event);
75
+ store.setState(
76
+ (0, import_build_geo_tooltip_state.buildGeoTooltipState)({
77
+ absoluteX: pos.x,
78
+ absoluteY: pos.y,
79
+ relativeX: Math.round(event.point.x),
80
+ relativeY: Math.round(event.point.y),
81
+ pinned: false,
82
+ geometry: layerIdToGeometry(hoveredLayerId),
83
+ metadata: data
84
+ })
85
+ );
68
86
  };
69
87
  const handleMouseEnter = () => {
70
88
  setOverlayState({ mouseInBounds: true });
@@ -79,20 +97,7 @@ const useOverlayEvents = () => {
79
97
  event,
80
98
  dataLookupRegistry
81
99
  );
82
- overlay.clear();
83
- setTooltipMarker(hoveredLayerId, event.lngLat);
84
- const pos = getAbsolutePosition(event);
85
- store.setState(
86
- (0, import_build_geo_tooltip_state.buildGeoTooltipState)({
87
- absoluteX: pos.x,
88
- absoluteY: pos.y,
89
- relativeX: Math.round(event.point.x),
90
- relativeY: Math.round(event.point.y),
91
- pinned: false,
92
- geometry: layerIdToGeometry(hoveredLayerId),
93
- metadata: data
94
- })
95
- );
100
+ showHoverTooltip(event, data ?? [], hoveredLayerId);
96
101
  } else {
97
102
  const currentState = store.getState();
98
103
  if (!currentState.pinned) {
@@ -120,8 +125,15 @@ const useOverlayEvents = () => {
120
125
  hideTooltip();
121
126
  return;
122
127
  }
128
+ const currentState = store.getState();
129
+ if (currentState.pinned && pinnedFeatureIdRef.current === featureId) {
130
+ pinnedFeatureIdRef.current = void 0;
131
+ showHoverTooltip(event, data ?? [], hoveredLayerId);
132
+ return;
133
+ }
123
134
  overlay.clear();
124
135
  setTooltipMarker(hoveredLayerId, event.lngLat);
136
+ pinnedFeatureIdRef.current = featureId;
125
137
  const pos = getAbsolutePosition(event);
126
138
  store.setState(
127
139
  (0, import_build_geo_tooltip_state.buildGeoTooltipState)({
@@ -22,4 +22,4 @@ __export(get_scaled_symbol_size_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(get_scaled_symbol_size_exports);
24
24
  var import_constants = require("../constants.js");
25
- const getScaledSymbolSize = (symbolSize = import_constants.DEFAULT_SYMBOL_SIZE) => symbolSize * devicePixelRatio;
25
+ const getScaledSymbolSize = (symbolSize = import_constants.DEFAULT_SYMBOL_SIZE) => Math.max(1, symbolSize * devicePixelRatio);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynatrace/strato-geo",
3
- "version": "3.7.1",
3
+ "version": "3.8.0",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -54,9 +54,9 @@
54
54
  "@dynatrace-sdk/client-classic-environment-v2": "^5.1.0",
55
55
  "@dynatrace-sdk/client-platform-management-service": "^1.7.0",
56
56
  "@dynatrace-sdk/units": "^1.5.0",
57
- "@dynatrace/strato-components": "^3.7.1",
58
- "@dynatrace/strato-design-tokens": "^1.5.0",
59
- "@dynatrace/strato-icons": "^2.3.0",
57
+ "@dynatrace/strato-components": "^3.8.0",
58
+ "@dynatrace/strato-design-tokens": "^1.5.1",
59
+ "@dynatrace/strato-icons": "^2.3.1",
60
60
  "react": "^18.0.0",
61
61
  "react-dom": "^18.0.0",
62
62
  "react-intl": "^6.0.8 || ^7.0.0",