@dynatrace/strato-geo 2.10.2 → 2.12.2
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/esm/map/MapView.js +7 -1
- package/esm/map/MapView.js.map +2 -2
- package/esm/map/components/BubbleLayer/BubbleLayer.js +8 -10
- package/esm/map/components/BubbleLayer/BubbleLayer.js.map +2 -2
- package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js +12 -5
- package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js +32 -85
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +12 -5
- package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +71 -0
- package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js.map +7 -0
- package/esm/map/components/ConnectionLayer/ConnectionLayer.js +8 -8
- package/esm/map/components/ConnectionLayer/ConnectionLayer.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js +30 -27
- package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js +11 -6
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js.map +2 -2
- package/esm/map/components/ConnectionLayer/utils/restore-null-props.js +1 -1
- package/esm/map/components/ConnectionLayer/utils/restore-null-props.js.map +2 -2
- package/esm/map/components/DefaultTooltip/DefaultTooltip.js +1 -4
- package/esm/map/components/DefaultTooltip/DefaultTooltip.js.map +2 -2
- package/esm/map/components/DefaultTooltip/utils/get-default-actions.js +12 -4
- package/esm/map/components/DefaultTooltip/utils/get-default-actions.js.map +2 -2
- package/esm/map/components/DotLayer/DotLayer.js +50 -52
- package/esm/map/components/DotLayer/DotLayer.js.map +2 -2
- package/esm/map/components/DotLayer/DotLayerTooltip.js +12 -5
- package/esm/map/components/DotLayer/DotLayerTooltip.js.map +2 -2
- package/esm/map/components/MapContent.js +6 -6
- package/esm/map/components/MapContent.js.map +2 -2
- package/esm/map/components/TooltipWrapper.js +26 -0
- package/esm/map/components/TooltipWrapper.js.map +7 -0
- package/esm/map/components/toolbar/MapToolbar.js +14 -4
- package/esm/map/components/toolbar/MapToolbar.js.map +2 -2
- package/esm/map/contexts/formatter.context.js.map +2 -2
- package/esm/map/contexts/tooltip.context.js +8 -0
- package/esm/map/contexts/tooltip.context.js.map +7 -0
- package/esm/map/hooks/use-active-interaction.js +24 -0
- package/esm/map/hooks/use-active-interaction.js.map +2 -2
- package/esm/map/hooks/use-formatter-context.js.map +2 -2
- package/esm/map/hooks/use-get-position.js +56 -0
- package/esm/map/hooks/use-get-position.js.map +7 -0
- package/esm/map/hooks/use-overlay-events.js +10 -20
- package/esm/map/hooks/use-overlay-events.js.map +2 -2
- package/esm/map/hooks/use-tooltip-event-listeners.js +6 -22
- package/esm/map/hooks/use-tooltip-event-listeners.js.map +2 -2
- package/esm/map/index.js +2 -0
- package/esm/map/index.js.map +2 -2
- package/esm/map/slots/DownloadCSV.js +6 -0
- package/esm/map/slots/DownloadCSV.js.map +7 -0
- package/esm/map/slots/Toolbar.js +6 -0
- package/esm/map/slots/Toolbar.js.map +7 -0
- package/esm/map/store/map-store.context.js +3 -2
- package/esm/map/store/map-store.context.js.map +2 -2
- package/esm/map/store/map-store.provider.js +1 -1
- package/esm/map/store/map-store.provider.js.map +2 -2
- package/esm/map/store/selectors.js +4 -0
- package/esm/map/store/selectors.js.map +2 -2
- package/esm/map/store/store.js +59 -24
- package/esm/map/store/store.js.map +2 -2
- package/esm/map/utils/iterate-config-slots.js +21 -1
- package/esm/map/utils/iterate-config-slots.js.map +2 -2
- package/esm/map/utils/parse-tooltip-data.js +17 -0
- package/esm/map/utils/parse-tooltip-data.js.map +3 -3
- package/map/MapView.d.ts +12 -0
- package/map/MapView.js +7 -1
- package/map/components/BubbleLayer/BubbleLayer.js +7 -9
- package/map/components/BubbleLayer/BubbleLayerTooltip.d.ts +0 -1
- package/map/components/BubbleLayer/BubbleLayerTooltip.js +12 -5
- package/map/components/ChoroplethLayer/ChoroplethLayer.js +30 -76
- package/map/components/ChoroplethLayer/ChoroplethLayerTooltip.d.ts +0 -1
- package/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +12 -5
- package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.d.ts +3 -0
- package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +82 -0
- package/map/components/ConnectionLayer/ConnectionLayer.js +8 -8
- package/map/components/ConnectionLayer/ConnectionLayerLine.d.ts +2 -1
- package/map/components/ConnectionLayer/ConnectionLayerLine.js +29 -26
- package/map/components/ConnectionLayer/ConnectionLayerTooltip.d.ts +1 -2
- package/map/components/ConnectionLayer/ConnectionLayerTooltip.js +11 -6
- package/map/components/ConnectionLayer/utils/restore-null-props.js +1 -1
- package/map/components/DefaultTooltip/DefaultTooltip.js +1 -4
- package/map/components/DefaultTooltip/utils/get-default-actions.d.ts +2 -2
- package/map/components/DefaultTooltip/utils/get-default-actions.js +12 -4
- package/map/components/DotLayer/DotLayer.js +49 -51
- package/map/components/DotLayer/DotLayerTooltip.d.ts +0 -1
- package/map/components/DotLayer/DotLayerTooltip.js +12 -5
- package/map/components/MapContent.js +1 -1
- package/map/components/TooltipWrapper.d.ts +4 -0
- package/map/components/TooltipWrapper.js +42 -0
- package/map/components/toolbar/MapToolbar.js +14 -4
- package/map/contexts/formatter.context.d.ts +2 -2
- package/map/contexts/tooltip.context.d.ts +3 -0
- package/map/contexts/tooltip.context.js +27 -0
- package/map/hooks/use-active-interaction.js +24 -0
- package/map/hooks/use-formatter-context.d.ts +3 -1
- package/map/hooks/use-get-position.d.ts +4 -0
- package/map/hooks/use-get-position.js +75 -0
- package/map/hooks/use-overlay-events.js +7 -17
- package/map/hooks/use-tooltip-event-listeners.js +5 -18
- package/map/index.d.ts +2 -1
- package/map/index.js +2 -0
- package/map/slots/DownloadCSV.d.ts +8 -0
- package/map/slots/DownloadCSV.js +25 -0
- package/map/slots/Toolbar.d.ts +9 -0
- package/map/slots/Toolbar.js +25 -0
- package/map/store/map-store.context.d.ts +1 -23
- package/map/store/map-store.context.js +3 -2
- package/map/store/map-store.provider.js +1 -1
- package/map/store/selectors.d.ts +4 -4
- package/map/store/selectors.js +4 -0
- package/map/store/store.d.ts +5 -3
- package/map/store/store.js +59 -24
- package/map/types/state.d.ts +3 -4
- package/map/types/toolbar.d.ts +14 -11
- package/map/utils/iterate-config-slots.js +21 -1
- package/map/utils/parse-tooltip-data.d.ts +10 -1
- package/map/utils/parse-tooltip-data.js +17 -0
- package/package.json +5 -5
|
@@ -29,18 +29,23 @@ var import_MapZoomInOutButtons = require("./buttons/MapZoomInOutButtons.js");
|
|
|
29
29
|
var import_MapZoomToFitButton = require("./buttons/MapZoomToFitButton.js");
|
|
30
30
|
var import_constants = require("./constants.js");
|
|
31
31
|
var import_use_map_config = require("../../hooks/use-map-config.js");
|
|
32
|
+
var import_use_map_raw_data = require("../../hooks/use-map-raw-data.js");
|
|
32
33
|
var import_map_initial_view_provider = require("../../providers/map-initial-view.provider.js");
|
|
33
34
|
var import_selectors = require("../../store/selectors.js");
|
|
34
35
|
var import_store = require("../../store/store.js");
|
|
36
|
+
var import_build_and_download_csv = require("../../utils/build-and-download-csv.js");
|
|
35
37
|
const defaultToolbarPlacement = "top-right";
|
|
36
38
|
const MapToolbar = () => {
|
|
37
39
|
const { toolbar: toolbarConfig, interactions: interactionsConfig } = (0, import_use_map_config.useMapConfig)();
|
|
40
|
+
const data = (0, import_use_map_raw_data.useMapRawData)();
|
|
38
41
|
const { mouseInBounds } = (0, import_selectors.useMapOverlayState)();
|
|
39
42
|
const setTooltipState = (0, import_store.useSetStateTooltip)();
|
|
40
|
-
const isZoomEnabled = interactionsConfig?.zoom?.enabled ?? false;
|
|
41
|
-
const isZoomToFitEnabled = interactionsConfig?.zoomToFit?.enabled ?? false;
|
|
42
|
-
const isDownloadDataEnabled = toolbarConfig?.
|
|
43
|
-
const
|
|
43
|
+
const isZoomEnabled = toolbarConfig?.zoom?.enabled ?? interactionsConfig?.zoom?.enabled ?? false;
|
|
44
|
+
const isZoomToFitEnabled = toolbarConfig?.zoom?.enabled ?? interactionsConfig?.zoomToFit?.enabled ?? false;
|
|
45
|
+
const isDownloadDataEnabled = toolbarConfig?.downloadCSV?.enabled ?? false;
|
|
46
|
+
const hasZoomControls = isZoomEnabled || isZoomToFitEnabled;
|
|
47
|
+
const hasControls = hasZoomControls || isDownloadDataEnabled;
|
|
48
|
+
const hasOnlyDownloadCSV = isDownloadDataEnabled && !hasZoomControls;
|
|
44
49
|
const handleMouseEnter = () => {
|
|
45
50
|
setTooltipState({
|
|
46
51
|
enabled: false
|
|
@@ -51,6 +56,9 @@ const MapToolbar = () => {
|
|
|
51
56
|
enabled: true
|
|
52
57
|
});
|
|
53
58
|
};
|
|
59
|
+
const handleDownloadDataToolbar = () => {
|
|
60
|
+
(0, import_build_and_download_csv.buildAndDownloadCsv)(data);
|
|
61
|
+
};
|
|
54
62
|
return hasControls ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_map_initial_view_provider.MapInitialViewProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
55
63
|
import_charts._ChartToolbarRenderer,
|
|
56
64
|
{
|
|
@@ -58,6 +66,8 @@ const MapToolbar = () => {
|
|
|
58
66
|
collapsed: toolbarConfig?.collapsed,
|
|
59
67
|
draggable: toolbarConfig?.draggable,
|
|
60
68
|
placement: toolbarConfig?.placement ?? defaultToolbarPlacement,
|
|
69
|
+
handleDownloadDataToolbar,
|
|
70
|
+
isDownloadEnabled: !hasOnlyDownloadCSV && isDownloadDataEnabled,
|
|
61
71
|
initialA11yState: import_constants.initialA11yToolbarTabIndexContext,
|
|
62
72
|
onMouseEnter: handleMouseEnter,
|
|
63
73
|
onMouseLeave: handleMouseLeave,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Formatter } from '@dynatrace/strato-components-preview/charts';
|
|
2
|
-
import { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units';
|
|
1
|
+
import type { Formatter } from '@dynatrace/strato-components-preview/charts';
|
|
2
|
+
import type { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units';
|
|
3
3
|
export declare const FormatterContext: import("react").Context<Formatter | FormatOptions<Unit, ConvertibleUnit> | undefined>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tooltip_context_exports = {};
|
|
20
|
+
__export(tooltip_context_exports, {
|
|
21
|
+
TooltipContext: () => TooltipContext
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tooltip_context_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
const TooltipContext = (0, import_react.createContext)({
|
|
26
|
+
markerRef: { current: void 0 }
|
|
27
|
+
});
|
|
@@ -79,10 +79,34 @@ const useActiveInteraction = () => {
|
|
|
79
79
|
},
|
|
80
80
|
[featureId, sourceId, map]
|
|
81
81
|
);
|
|
82
|
+
const onEscapeKeyPressedHandler = (0, import_react.useCallback)(
|
|
83
|
+
(event) => {
|
|
84
|
+
if (event.key === "Escape") {
|
|
85
|
+
if (!(0, import_lodash_es.isUndefined)(featureId) && !(0, import_lodash_es.isUndefined)(sourceId)) {
|
|
86
|
+
map.setFeatureState(
|
|
87
|
+
{ source: sourceId, id: featureId },
|
|
88
|
+
{ active: false }
|
|
89
|
+
);
|
|
90
|
+
const allFeatures = map.queryRenderedFeatures();
|
|
91
|
+
allFeatures.forEach((feature) => {
|
|
92
|
+
if (feature.id !== void 0 && feature.layer.source !== void 0) {
|
|
93
|
+
map.setFeatureState(
|
|
94
|
+
{ source: feature.layer.source, id: feature.id },
|
|
95
|
+
{ isAnyActive: false }
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
[featureId, sourceId, map]
|
|
103
|
+
);
|
|
82
104
|
(0, import_react.useEffect)(() => {
|
|
83
105
|
map.on("click", handleClick);
|
|
106
|
+
window.addEventListener("keyup", onEscapeKeyPressedHandler);
|
|
84
107
|
return () => {
|
|
85
108
|
map.off("click", handleClick);
|
|
109
|
+
window.removeEventListener("keyup", onEscapeKeyPressedHandler);
|
|
86
110
|
};
|
|
87
111
|
}, []);
|
|
88
112
|
};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Formatter } from '@dynatrace/strato-components-preview/charts';
|
|
2
|
+
import type { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units';
|
|
3
|
+
export declare const useFormatterContext: () => Formatter | FormatOptions<Unit, ConvertibleUnit> | undefined;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var use_get_position_exports = {};
|
|
20
|
+
__export(use_get_position_exports, {
|
|
21
|
+
useGetPosition: () => useGetPosition
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(use_get_position_exports);
|
|
24
|
+
var import_react_maplibre = require("@vis.gl/react-maplibre");
|
|
25
|
+
var import_lodash_es = require("lodash");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_tooltip_context = require("../contexts/tooltip.context.js");
|
|
28
|
+
const useGetPosition = (pinned, visible) => {
|
|
29
|
+
const mapRef = (0, import_react_maplibre.useMap)();
|
|
30
|
+
const { markerRef } = (0, import_react.useContext)(import_tooltip_context.TooltipContext);
|
|
31
|
+
const getBounds = () => mapRef.current?.getContainer().getBoundingClientRect();
|
|
32
|
+
const [mapBounds, setMapBounds] = (0, import_react.useState)(visible ? getBounds : null);
|
|
33
|
+
const updateBounds = (0, import_react.useCallback)(
|
|
34
|
+
(0, import_lodash_es.throttle)(
|
|
35
|
+
() => {
|
|
36
|
+
setMapBounds(getBounds);
|
|
37
|
+
},
|
|
38
|
+
10,
|
|
39
|
+
{ trailing: true, leading: true }
|
|
40
|
+
),
|
|
41
|
+
[]
|
|
42
|
+
);
|
|
43
|
+
(0, import_react.useEffect)(() => {
|
|
44
|
+
if (visible) {
|
|
45
|
+
updateBounds();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setMapBounds(null);
|
|
49
|
+
}, [visible]);
|
|
50
|
+
(0, import_react.useEffect)(() => {
|
|
51
|
+
if (pinned) {
|
|
52
|
+
const observers = [
|
|
53
|
+
mapRef.current?.on("drag", updateBounds),
|
|
54
|
+
mapRef.current?.on("zoom", updateBounds),
|
|
55
|
+
mapRef.current?.on("resize", updateBounds)
|
|
56
|
+
];
|
|
57
|
+
document.body.addEventListener("scroll", updateBounds, true);
|
|
58
|
+
return () => {
|
|
59
|
+
observers.forEach((o) => o && o.unsubscribe());
|
|
60
|
+
document.body.removeEventListener("scroll", updateBounds, true);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}, [pinned]);
|
|
64
|
+
if (!mapBounds || !markerRef.current?._pos) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const position = {
|
|
68
|
+
x: mapBounds.x + markerRef.current?._pos.x,
|
|
69
|
+
y: mapBounds.y + markerRef.current?._pos.y
|
|
70
|
+
};
|
|
71
|
+
if (!(0, import_lodash_es.inRange)(position.x, mapBounds.left, mapBounds.right) || !(0, import_lodash_es.inRange)(position.y, mapBounds.top, mapBounds.bottom)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return position;
|
|
75
|
+
};
|
|
@@ -26,7 +26,7 @@ var import_parse_tooltip_data = require("../utils/parse-tooltip-data.js");
|
|
|
26
26
|
const useOverlayEvents = () => {
|
|
27
27
|
const setOverlayState = (0, import_store.useSetStateOverlay)();
|
|
28
28
|
const setTooltipState = (0, import_store.useSetStateTooltip)();
|
|
29
|
-
const
|
|
29
|
+
const setTooltipPinnedState = (0, import_store.useTooltipPinnedState)();
|
|
30
30
|
const hideTooltip = () => {
|
|
31
31
|
setTooltipState({ visible: false });
|
|
32
32
|
};
|
|
@@ -36,22 +36,13 @@ const useOverlayEvents = () => {
|
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
const handleMouseMove = (event) => {
|
|
39
|
-
if (event.features
|
|
40
|
-
const {
|
|
41
|
-
const position = {
|
|
42
|
-
x: clientX,
|
|
43
|
-
y: clientY
|
|
44
|
-
};
|
|
45
|
-
const hoveredLayerId = event.features[0].layer.id;
|
|
46
|
-
const hoveredFeatures = event.features.filter(
|
|
47
|
-
(feature) => feature.layer.id === hoveredLayerId
|
|
48
|
-
);
|
|
49
|
-
const data = (0, import_parse_tooltip_data.parseTooltipData)(hoveredFeatures);
|
|
39
|
+
if (event.features?.length) {
|
|
40
|
+
const { data, hoveredLayerId } = (0, import_parse_tooltip_data.extractDataFromEvent)(event);
|
|
50
41
|
setTooltipState({
|
|
51
|
-
visible: true,
|
|
52
|
-
hoveredLayerId,
|
|
53
42
|
data,
|
|
54
|
-
|
|
43
|
+
hoveredLayerId,
|
|
44
|
+
visible: true,
|
|
45
|
+
location: event.lngLat
|
|
55
46
|
});
|
|
56
47
|
} else {
|
|
57
48
|
hideTooltip();
|
|
@@ -64,8 +55,7 @@ const useOverlayEvents = () => {
|
|
|
64
55
|
hideTooltip();
|
|
65
56
|
};
|
|
66
57
|
const handleMouseClick = (event) => {
|
|
67
|
-
event
|
|
68
|
-
toggleTooltipPinnedState();
|
|
58
|
+
setTooltipPinnedState(event);
|
|
69
59
|
};
|
|
70
60
|
const handleDrag = () => {
|
|
71
61
|
hideTooltip();
|
|
@@ -24,33 +24,20 @@ module.exports = __toCommonJS(use_tooltip_event_listeners_exports);
|
|
|
24
24
|
var import_react = require("react");
|
|
25
25
|
var import_store = require("../store/store.js");
|
|
26
26
|
const useTooltipEventListeners = () => {
|
|
27
|
-
const
|
|
27
|
+
const setClearTooltip = (0, import_store.useClearTooltip)();
|
|
28
28
|
const pinned = (0, import_store.useMapTooltipPinnedState)();
|
|
29
|
-
const unpinTooltip = (0, import_react.useCallback)(() => {
|
|
30
|
-
if (pinned) {
|
|
31
|
-
setTooltipState({ pinned: false });
|
|
32
|
-
}
|
|
33
|
-
}, [pinned]);
|
|
34
29
|
const onEscapeKeyPressedHandler = (0, import_react.useCallback)(
|
|
35
30
|
(event) => {
|
|
36
|
-
if (event.key === "Escape") {
|
|
37
|
-
|
|
31
|
+
if (pinned && event.key === "Escape") {
|
|
32
|
+
setClearTooltip();
|
|
38
33
|
}
|
|
39
34
|
},
|
|
40
|
-
[
|
|
41
|
-
);
|
|
42
|
-
const onClick = (0, import_react.useCallback)(
|
|
43
|
-
(event) => {
|
|
44
|
-
unpinTooltip();
|
|
45
|
-
},
|
|
46
|
-
[unpinTooltip]
|
|
35
|
+
[pinned]
|
|
47
36
|
);
|
|
48
37
|
(0, import_react.useEffect)(() => {
|
|
49
|
-
window.addEventListener("click", onClick);
|
|
50
38
|
window.addEventListener("keyup", onEscapeKeyPressedHandler);
|
|
51
39
|
return () => {
|
|
52
|
-
window.removeEventListener("click", onClick);
|
|
53
40
|
window.removeEventListener("keyup", onEscapeKeyPressedHandler);
|
|
54
41
|
};
|
|
55
|
-
}, [
|
|
42
|
+
}, [onEscapeKeyPressedHandler]);
|
|
56
43
|
};
|
package/map/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { BubbleLayer } from './slots/BubbleLayer.js';
|
|
|
6
6
|
export { BaseLayer } from './slots/BaseLayer.js';
|
|
7
7
|
export { ChoroplethLayer } from './slots/ChoroplethLayer.js';
|
|
8
8
|
export { Tooltip, TooltipAtoms } from './slots/Tooltip.js';
|
|
9
|
+
export { DownloadCSV } from './slots/DownloadCSV.js';
|
|
9
10
|
export type { MapViewProps, MapViewBaseProps, MapViewUncontrolledProps, MapViewControlledProps, DisallowAll, ViewState, MapViewRef, } from './types/map-view.js';
|
|
10
11
|
export type { BaseLayerProps } from './types/base-layer.js';
|
|
11
12
|
export type { Connection, ConnectionLayerBaseProps, ConnectionLayerProps, CurvedLine, } from './types/connection-layer.js';
|
|
@@ -14,7 +15,7 @@ export type { BubbleLayerBaseProps, BubbleLayerProps, ScaleNoneProps, ScaleRadiu
|
|
|
14
15
|
export type { ChoroplethLayerBaseProps, ChoroplethLayerProps, } from './types/choropleth-layer.js';
|
|
15
16
|
export type { Location } from './types/location.js';
|
|
16
17
|
export type { MapShape } from './types/shapes.js';
|
|
17
|
-
export type { ChartInteractionsProps } from './types/toolbar.js';
|
|
18
|
+
export type { ChartInteractionsProps, MapToolbarSlotProps, } from './types/toolbar.js';
|
|
18
19
|
export type { ErrorStateSlotProps } from './slots/states/ErrorStateSlot.js';
|
|
19
20
|
export type { BaseLegendProps, CategoricalLegendProps, SequentialLegendProps, ThresholdLegendProps, } from './types/legend.js';
|
|
20
21
|
export type { LocationColorProps, LegendColorLayerProps, ChoroplethCustomColorProps, ConnectionColorProps, } from './types/coloring.js';
|
package/map/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(map_exports, {
|
|
|
25
25
|
ChoroplethLayer: () => import_ChoroplethLayer.ChoroplethLayer,
|
|
26
26
|
ConnectionLayer: () => import_ConnectionLayer.ConnectionLayer,
|
|
27
27
|
DotLayer: () => import_DotLayer.DotLayer,
|
|
28
|
+
DownloadCSV: () => import_DownloadCSV.DownloadCSV,
|
|
28
29
|
MapView: () => import_MapView.MapView,
|
|
29
30
|
SequentialLegend: () => import_SequentialLegend.SequentialLegend,
|
|
30
31
|
ThresholdLegend: () => import_ThresholdLegend.ThresholdLegend,
|
|
@@ -41,6 +42,7 @@ var import_BubbleLayer = require("./slots/BubbleLayer.js");
|
|
|
41
42
|
var import_BaseLayer = require("./slots/BaseLayer.js");
|
|
42
43
|
var import_ChoroplethLayer = require("./slots/ChoroplethLayer.js");
|
|
43
44
|
var import_Tooltip = require("./slots/Tooltip.js");
|
|
45
|
+
var import_DownloadCSV = require("./slots/DownloadCSV.js");
|
|
44
46
|
var import_SequentialLegend = require("./slots/SequentialLegend.js");
|
|
45
47
|
var import_ThresholdLegend = require("./slots/ThresholdLegend.js");
|
|
46
48
|
var import_CategoricalLegend = require("./slots/CategoricalLegend.js");
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var DownloadCSV_exports = {};
|
|
20
|
+
__export(DownloadCSV_exports, {
|
|
21
|
+
DownloadCSV: () => DownloadCSV
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(DownloadCSV_exports);
|
|
24
|
+
const DownloadCSV = () => null;
|
|
25
|
+
DownloadCSV["displayName"] = "MapView.DownloadCSV";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Toolbar_exports = {};
|
|
20
|
+
__export(Toolbar_exports, {
|
|
21
|
+
Toolbar: () => Toolbar
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Toolbar_exports);
|
|
24
|
+
const Toolbar = (props) => null;
|
|
25
|
+
Toolbar.displayName = "MapToolbar";
|
|
@@ -1,26 +1,4 @@
|
|
|
1
1
|
import { type Store } from '@dynatrace/strato-components-preview/core';
|
|
2
2
|
import type { MapState } from '../types/state.js';
|
|
3
|
-
export declare const initialState:
|
|
4
|
-
tooltip: {
|
|
5
|
-
pinned: boolean;
|
|
6
|
-
visible: boolean;
|
|
7
|
-
enabled: boolean;
|
|
8
|
-
hoveredLayerId: undefined;
|
|
9
|
-
data: undefined;
|
|
10
|
-
position: undefined;
|
|
11
|
-
};
|
|
12
|
-
overlay: {
|
|
13
|
-
mouseInBounds: boolean;
|
|
14
|
-
};
|
|
15
|
-
selection: {
|
|
16
|
-
highlightedSeries: undefined;
|
|
17
|
-
visible: undefined;
|
|
18
|
-
};
|
|
19
|
-
zoom: {
|
|
20
|
-
zoomInEnabled: boolean;
|
|
21
|
-
zoomOutEnabled: boolean;
|
|
22
|
-
zoomToFitEnabled: boolean;
|
|
23
|
-
resetEnabled: boolean;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
3
|
+
export declare const initialState: MapState;
|
|
26
4
|
export declare const MapStore: import("react").Context<Store<MapState<unknown>>>;
|
|
@@ -27,6 +27,6 @@ var import_core = require("@dynatrace/strato-components-preview/core");
|
|
|
27
27
|
var import_map_store_context = require("./map-store.context.js");
|
|
28
28
|
const MapStoreProvider = ({ children }) => {
|
|
29
29
|
const storeRef = (0, import_react.useRef)(null);
|
|
30
|
-
storeRef.current
|
|
30
|
+
storeRef.current ||= (0, import_core.createStore)(import_map_store_context.initialState);
|
|
31
31
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_map_store_context.MapStore.Provider, { value: storeRef.current, children });
|
|
32
32
|
};
|
package/map/store/selectors.d.ts
CHANGED
|
@@ -6,11 +6,11 @@ export declare const useMapTooltipState: <T>() => {
|
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
hoveredLayerId: string | undefined;
|
|
8
8
|
data: T[] | undefined;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
y: number;
|
|
12
|
-
} | undefined;
|
|
9
|
+
pinnedId: string | undefined;
|
|
10
|
+
location: import("maplibre-gl").LngLat | undefined;
|
|
13
11
|
};
|
|
12
|
+
export declare const useMapTooltipLocationState: <T>() => import("maplibre-gl").LngLat | undefined;
|
|
13
|
+
export declare const useMapTooltipHoveredLayerIdState: <T>() => string | undefined;
|
|
14
14
|
export declare const useMapTooltipPinnedState: <T>() => boolean;
|
|
15
15
|
export declare const useMapOverlayState: <T>() => import("../types/state.js").MapOverlayState;
|
|
16
16
|
export declare const useMapZoomState: <T>() => import("../types/state.js").ZoomState;
|
package/map/store/selectors.js
CHANGED
|
@@ -20,6 +20,8 @@ var selectors_exports = {};
|
|
|
20
20
|
__export(selectors_exports, {
|
|
21
21
|
useMapOverlayState: () => useMapOverlayState,
|
|
22
22
|
useMapSelectionState: () => useMapSelectionState,
|
|
23
|
+
useMapTooltipHoveredLayerIdState: () => useMapTooltipHoveredLayerIdState,
|
|
24
|
+
useMapTooltipLocationState: () => useMapTooltipLocationState,
|
|
23
25
|
useMapTooltipPinnedState: () => useMapTooltipPinnedState,
|
|
24
26
|
useMapTooltipState: () => useMapTooltipState,
|
|
25
27
|
useMapZoomState: () => useMapZoomState,
|
|
@@ -35,6 +37,8 @@ const useMapTooltipState = () => useSelector(({ tooltip }) => {
|
|
|
35
37
|
const { pinned, ...tooltipState } = tooltip;
|
|
36
38
|
return tooltipState;
|
|
37
39
|
});
|
|
40
|
+
const useMapTooltipLocationState = () => useSelector(({ tooltip }) => tooltip.location);
|
|
41
|
+
const useMapTooltipHoveredLayerIdState = () => useSelector(({ tooltip }) => tooltip.hoveredLayerId);
|
|
38
42
|
const useMapTooltipPinnedState = () => useSelector(({ tooltip }) => {
|
|
39
43
|
const { pinned } = tooltip;
|
|
40
44
|
return pinned;
|
package/map/store/store.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { MapLayerMouseEvent } from 'maplibre-gl';
|
|
2
|
+
import type { MapOverlayState, MapSelectionState, MapState, MapTooltipState, ZoomState } from '../types/state.js';
|
|
3
|
+
export declare const useSetState: () => (action: MapState<unknown> | ((prev: MapState<unknown>) => MapState<unknown>)) => void;
|
|
3
4
|
export * from './selectors.js';
|
|
4
5
|
export declare const useSetStateSelection: () => (newSelectionState: Partial<MapSelectionState>) => void;
|
|
5
6
|
export declare const useSetStateTooltip: <T>() => (newTooltipState: Partial<MapTooltipState<T>>) => void;
|
|
7
|
+
export declare const useClearTooltip: () => () => void;
|
|
8
|
+
export declare const useTooltipPinnedState: () => (event: MapLayerMouseEvent) => void;
|
|
6
9
|
export declare const useSetStateOverlay: () => (newOverlayState: Partial<MapOverlayState>) => void;
|
|
7
|
-
export declare const useToggleStatePinnedTooltip: () => () => void;
|
|
8
10
|
export declare const useSetStateZoom: () => (newZoomState: Partial<ZoomState>) => void;
|
package/map/store/store.js
CHANGED
|
@@ -19,16 +19,18 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var store_exports = {};
|
|
21
21
|
__export(store_exports, {
|
|
22
|
+
useClearTooltip: () => useClearTooltip,
|
|
22
23
|
useSetState: () => useSetState,
|
|
23
24
|
useSetStateOverlay: () => useSetStateOverlay,
|
|
24
25
|
useSetStateSelection: () => useSetStateSelection,
|
|
25
26
|
useSetStateTooltip: () => useSetStateTooltip,
|
|
26
27
|
useSetStateZoom: () => useSetStateZoom,
|
|
27
|
-
|
|
28
|
+
useTooltipPinnedState: () => useTooltipPinnedState
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(store_exports);
|
|
30
31
|
var import_react = require("react");
|
|
31
32
|
var import_map_store_context = require("./map-store.context.js");
|
|
33
|
+
var import_parse_tooltip_data = require("../utils/parse-tooltip-data.js");
|
|
32
34
|
__reExport(store_exports, require("./selectors.js"), module.exports);
|
|
33
35
|
const useSetState = () => {
|
|
34
36
|
const { setState } = (0, import_react.useContext)(import_map_store_context.MapStore);
|
|
@@ -49,13 +51,63 @@ const useSetStateSelection = () => {
|
|
|
49
51
|
const useSetStateTooltip = () => {
|
|
50
52
|
const setState = useSetState();
|
|
51
53
|
return (newTooltipState) => {
|
|
52
|
-
setState((prev) =>
|
|
53
|
-
...
|
|
54
|
-
|
|
55
|
-
...prev
|
|
56
|
-
|
|
54
|
+
setState((prev) => {
|
|
55
|
+
const { location, data, hoveredLayerId, ...tooltipState } = newTooltipState;
|
|
56
|
+
return {
|
|
57
|
+
...prev,
|
|
58
|
+
tooltip: {
|
|
59
|
+
...prev.tooltip,
|
|
60
|
+
...tooltipState,
|
|
61
|
+
hoveredLayerId: prev.tooltip.pinned ? prev.tooltip.hoveredLayerId : hoveredLayerId,
|
|
62
|
+
data: prev.tooltip.pinned ? prev.tooltip.data : data,
|
|
63
|
+
location: prev.tooltip.pinned ? prev.tooltip.location : location
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
const clearTooltip = (prev) => {
|
|
70
|
+
return {
|
|
71
|
+
...prev,
|
|
72
|
+
tooltip: {
|
|
73
|
+
...prev.tooltip,
|
|
74
|
+
pinned: false,
|
|
75
|
+
data: void 0,
|
|
76
|
+
pinnedId: void 0,
|
|
77
|
+
hoveredLayerId: void 0,
|
|
78
|
+
visible: false,
|
|
79
|
+
location: void 0
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const useClearTooltip = () => {
|
|
84
|
+
const setState = useSetState();
|
|
85
|
+
return () => {
|
|
86
|
+
setState(clearTooltip);
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
const useTooltipPinnedState = () => {
|
|
90
|
+
const setState = useSetState();
|
|
91
|
+
return (event) => {
|
|
92
|
+
setState((prev) => {
|
|
93
|
+
const { data, featureId, hoveredLayerId } = (0, import_parse_tooltip_data.extractDataFromEvent)(event);
|
|
94
|
+
if (!featureId) {
|
|
95
|
+
return clearTooltip(prev);
|
|
57
96
|
}
|
|
58
|
-
|
|
97
|
+
const isPinned = prev.tooltip.pinnedId !== featureId;
|
|
98
|
+
return {
|
|
99
|
+
...prev,
|
|
100
|
+
tooltip: {
|
|
101
|
+
...prev.tooltip,
|
|
102
|
+
data,
|
|
103
|
+
hoveredLayerId,
|
|
104
|
+
visible: true,
|
|
105
|
+
location: event.lngLat,
|
|
106
|
+
pinned: isPinned,
|
|
107
|
+
pinnedId: isPinned ? featureId : void 0
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
});
|
|
59
111
|
};
|
|
60
112
|
};
|
|
61
113
|
const useSetStateOverlay = () => {
|
|
@@ -70,23 +122,6 @@ const useSetStateOverlay = () => {
|
|
|
70
122
|
}));
|
|
71
123
|
};
|
|
72
124
|
};
|
|
73
|
-
const useToggleStatePinnedTooltip = () => {
|
|
74
|
-
const setState = useSetState();
|
|
75
|
-
return () => {
|
|
76
|
-
setState((prev) => {
|
|
77
|
-
if (prev.tooltip.visible || prev.tooltip.pinned) {
|
|
78
|
-
return {
|
|
79
|
-
...prev,
|
|
80
|
-
tooltip: {
|
|
81
|
-
...prev.tooltip,
|
|
82
|
-
pinned: !prev.tooltip.pinned
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
return { ...prev };
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
125
|
const useSetStateZoom = () => {
|
|
91
126
|
const setState = useSetState();
|
|
92
127
|
return (newZoomState) => {
|
package/map/types/state.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LngLat } from 'maplibre-gl';
|
|
1
2
|
import type { _LegendItem as LegendItem } from '@dynatrace/strato-components-preview/charts';
|
|
2
3
|
export interface MapSelectionState {
|
|
3
4
|
highlightedSeries: LegendItem[] | undefined;
|
|
@@ -9,10 +10,8 @@ export interface MapTooltipState<T> {
|
|
|
9
10
|
enabled: boolean;
|
|
10
11
|
hoveredLayerId: string | undefined;
|
|
11
12
|
data: T[] | undefined;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
y: number;
|
|
15
|
-
} | undefined;
|
|
13
|
+
pinnedId: string | undefined;
|
|
14
|
+
location: LngLat | undefined;
|
|
16
15
|
}
|
|
17
16
|
export interface MapOverlayState {
|
|
18
17
|
mouseInBounds: boolean;
|