@dynatrace/strato-geo 2.10.2 → 2.11.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.
Files changed (114) hide show
  1. package/esm/map/MapView.js +7 -1
  2. package/esm/map/MapView.js.map +2 -2
  3. package/esm/map/components/BubbleLayer/BubbleLayer.js +8 -10
  4. package/esm/map/components/BubbleLayer/BubbleLayer.js.map +2 -2
  5. package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js +12 -5
  6. package/esm/map/components/BubbleLayer/BubbleLayerTooltip.js.map +2 -2
  7. package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js +32 -85
  8. package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js.map +2 -2
  9. package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +12 -5
  10. package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js.map +2 -2
  11. package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +71 -0
  12. package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js.map +7 -0
  13. package/esm/map/components/ConnectionLayer/ConnectionLayer.js +8 -8
  14. package/esm/map/components/ConnectionLayer/ConnectionLayer.js.map +2 -2
  15. package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js +30 -27
  16. package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js.map +2 -2
  17. package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js +11 -6
  18. package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js.map +2 -2
  19. package/esm/map/components/ConnectionLayer/utils/restore-null-props.js +1 -1
  20. package/esm/map/components/ConnectionLayer/utils/restore-null-props.js.map +2 -2
  21. package/esm/map/components/DefaultTooltip/DefaultTooltip.js +1 -4
  22. package/esm/map/components/DefaultTooltip/DefaultTooltip.js.map +2 -2
  23. package/esm/map/components/DefaultTooltip/utils/get-default-actions.js +12 -4
  24. package/esm/map/components/DefaultTooltip/utils/get-default-actions.js.map +2 -2
  25. package/esm/map/components/DotLayer/DotLayer.js +50 -52
  26. package/esm/map/components/DotLayer/DotLayer.js.map +2 -2
  27. package/esm/map/components/DotLayer/DotLayerTooltip.js +12 -5
  28. package/esm/map/components/DotLayer/DotLayerTooltip.js.map +2 -2
  29. package/esm/map/components/MapContent.js +6 -6
  30. package/esm/map/components/MapContent.js.map +2 -2
  31. package/esm/map/components/TooltipWrapper.js +26 -0
  32. package/esm/map/components/TooltipWrapper.js.map +7 -0
  33. package/esm/map/components/toolbar/MapToolbar.js +11 -3
  34. package/esm/map/components/toolbar/MapToolbar.js.map +2 -2
  35. package/esm/map/contexts/tooltip.context.js +8 -0
  36. package/esm/map/contexts/tooltip.context.js.map +7 -0
  37. package/esm/map/hooks/use-active-interaction.js +24 -0
  38. package/esm/map/hooks/use-active-interaction.js.map +2 -2
  39. package/esm/map/hooks/use-get-position.js +56 -0
  40. package/esm/map/hooks/use-get-position.js.map +7 -0
  41. package/esm/map/hooks/use-overlay-events.js +10 -20
  42. package/esm/map/hooks/use-overlay-events.js.map +2 -2
  43. package/esm/map/hooks/use-tooltip-event-listeners.js +6 -22
  44. package/esm/map/hooks/use-tooltip-event-listeners.js.map +2 -2
  45. package/esm/map/index.js +2 -0
  46. package/esm/map/index.js.map +2 -2
  47. package/esm/map/slots/DownloadCSV.js +6 -0
  48. package/esm/map/slots/DownloadCSV.js.map +7 -0
  49. package/esm/map/slots/Toolbar.js +6 -0
  50. package/esm/map/slots/Toolbar.js.map +7 -0
  51. package/esm/map/store/map-store.context.js +3 -2
  52. package/esm/map/store/map-store.context.js.map +2 -2
  53. package/esm/map/store/map-store.provider.js +1 -1
  54. package/esm/map/store/map-store.provider.js.map +2 -2
  55. package/esm/map/store/selectors.js +4 -0
  56. package/esm/map/store/selectors.js.map +2 -2
  57. package/esm/map/store/store.js +59 -24
  58. package/esm/map/store/store.js.map +2 -2
  59. package/esm/map/utils/iterate-config-slots.js +21 -1
  60. package/esm/map/utils/iterate-config-slots.js.map +2 -2
  61. package/esm/map/utils/parse-tooltip-data.js +17 -0
  62. package/esm/map/utils/parse-tooltip-data.js.map +3 -3
  63. package/map/MapView.d.ts +12 -0
  64. package/map/MapView.js +7 -1
  65. package/map/components/BubbleLayer/BubbleLayer.js +7 -9
  66. package/map/components/BubbleLayer/BubbleLayerTooltip.d.ts +0 -1
  67. package/map/components/BubbleLayer/BubbleLayerTooltip.js +12 -5
  68. package/map/components/ChoroplethLayer/ChoroplethLayer.js +30 -76
  69. package/map/components/ChoroplethLayer/ChoroplethLayerTooltip.d.ts +0 -1
  70. package/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js +12 -5
  71. package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.d.ts +3 -0
  72. package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +82 -0
  73. package/map/components/ConnectionLayer/ConnectionLayer.js +8 -8
  74. package/map/components/ConnectionLayer/ConnectionLayerLine.d.ts +2 -1
  75. package/map/components/ConnectionLayer/ConnectionLayerLine.js +29 -26
  76. package/map/components/ConnectionLayer/ConnectionLayerTooltip.d.ts +1 -2
  77. package/map/components/ConnectionLayer/ConnectionLayerTooltip.js +11 -6
  78. package/map/components/ConnectionLayer/utils/restore-null-props.js +1 -1
  79. package/map/components/DefaultTooltip/DefaultTooltip.js +1 -4
  80. package/map/components/DefaultTooltip/utils/get-default-actions.d.ts +2 -2
  81. package/map/components/DefaultTooltip/utils/get-default-actions.js +12 -4
  82. package/map/components/DotLayer/DotLayer.js +49 -51
  83. package/map/components/DotLayer/DotLayerTooltip.d.ts +0 -1
  84. package/map/components/DotLayer/DotLayerTooltip.js +12 -5
  85. package/map/components/MapContent.js +1 -1
  86. package/map/components/TooltipWrapper.d.ts +4 -0
  87. package/map/components/TooltipWrapper.js +42 -0
  88. package/map/components/toolbar/MapToolbar.js +11 -3
  89. package/map/contexts/tooltip.context.d.ts +3 -0
  90. package/map/contexts/tooltip.context.js +27 -0
  91. package/map/hooks/use-active-interaction.js +24 -0
  92. package/map/hooks/use-get-position.d.ts +4 -0
  93. package/map/hooks/use-get-position.js +75 -0
  94. package/map/hooks/use-overlay-events.js +7 -17
  95. package/map/hooks/use-tooltip-event-listeners.js +5 -18
  96. package/map/index.d.ts +2 -1
  97. package/map/index.js +2 -0
  98. package/map/slots/DownloadCSV.d.ts +8 -0
  99. package/map/slots/DownloadCSV.js +25 -0
  100. package/map/slots/Toolbar.d.ts +9 -0
  101. package/map/slots/Toolbar.js +25 -0
  102. package/map/store/map-store.context.d.ts +1 -23
  103. package/map/store/map-store.context.js +3 -2
  104. package/map/store/map-store.provider.js +1 -1
  105. package/map/store/selectors.d.ts +4 -4
  106. package/map/store/selectors.js +4 -0
  107. package/map/store/store.d.ts +5 -3
  108. package/map/store/store.js +59 -24
  109. package/map/types/state.d.ts +3 -4
  110. package/map/types/toolbar.d.ts +14 -11
  111. package/map/utils/iterate-config-slots.js +21 -1
  112. package/map/utils/parse-tooltip-data.d.ts +10 -1
  113. package/map/utils/parse-tooltip-data.js +17 -0
  114. package/package.json +4 -4
@@ -9,6 +9,8 @@ const useMapTooltipState = () => useSelector(({ tooltip }) => {
9
9
  const { pinned, ...tooltipState } = tooltip;
10
10
  return tooltipState;
11
11
  });
12
+ const useMapTooltipLocationState = () => useSelector(({ tooltip }) => tooltip.location);
13
+ const useMapTooltipHoveredLayerIdState = () => useSelector(({ tooltip }) => tooltip.hoveredLayerId);
12
14
  const useMapTooltipPinnedState = () => useSelector(({ tooltip }) => {
13
15
  const { pinned } = tooltip;
14
16
  return pinned;
@@ -18,6 +20,8 @@ const useMapZoomState = () => useSelector(({ zoom }) => zoom);
18
20
  export {
19
21
  useMapOverlayState,
20
22
  useMapSelectionState,
23
+ useMapTooltipHoveredLayerIdState,
24
+ useMapTooltipLocationState,
21
25
  useMapTooltipPinnedState,
22
26
  useMapTooltipState,
23
27
  useMapZoomState,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/store/selectors.ts"],
4
- "sourcesContent": ["import { isEqual } from 'lodash-es';\nimport { type Context } from 'react';\n\nimport {\n Store,\n useStoreSelector,\n} from '@dynatrace/strato-components-preview/core';\n\nimport { MapStore } from './map-store.context.js';\nimport type { MapState } from '../types/state.js';\n\nexport const useSelector = <T, O>(selector: (state: MapState<T>) => O): O =>\n useStoreSelector(MapStore as Context<Store<MapState<T>>>, selector, isEqual);\n\nexport const useMapSelectionState = <T>() =>\n useSelector(({ selection }: MapState<T>) => selection);\n\nexport const useMapTooltipState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned, ...tooltipState } = tooltip;\n\n return tooltipState;\n });\n\nexport const useMapTooltipPinnedState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned } = tooltip;\n\n return pinned;\n });\n\nexport const useMapOverlayState = <T>() =>\n useSelector(({ overlay }: MapState<T>) => overlay);\n\nexport const useMapZoomState = <T>() =>\n useSelector(({ zoom }: MapState<T>) => zoom);\n"],
5
- "mappings": "AAAA,SAAS,eAAe;AAGxB;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,gBAAgB;AAGlB,MAAM,cAAc,CAAO,aAChC,iBAAiB,UAAyC,UAAU,OAAO;AAEtE,MAAM,uBAAuB,MAClC,YAAY,CAAC,EAAE,UAAU,MAAmB,SAAS;AAEhD,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,QAAQ,GAAG,aAAa,IAAI;AAEpC,SAAO;AACT,CAAC;AAEI,MAAM,2BAA2B,MACtC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,OAAO,IAAI;AAEnB,SAAO;AACT,CAAC;AAEI,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB,OAAO;AAE5C,MAAM,kBAAkB,MAC7B,YAAY,CAAC,EAAE,KAAK,MAAmB,IAAI;",
4
+ "sourcesContent": ["import { isEqual } from 'lodash-es';\nimport { type Context } from 'react';\n\nimport {\n Store,\n useStoreSelector,\n} from '@dynatrace/strato-components-preview/core';\n\nimport { MapStore } from './map-store.context.js';\nimport type { MapState } from '../types/state.js';\n\nexport const useSelector = <T, O>(selector: (state: MapState<T>) => O): O =>\n useStoreSelector(MapStore as Context<Store<MapState<T>>>, selector, isEqual);\n\nexport const useMapSelectionState = <T>() =>\n useSelector(({ selection }: MapState<T>) => selection);\n\nexport const useMapTooltipState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned, ...tooltipState } = tooltip;\n\n return tooltipState;\n });\n\nexport const useMapTooltipLocationState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => tooltip.location);\n\nexport const useMapTooltipHoveredLayerIdState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => tooltip.hoveredLayerId);\n\nexport const useMapTooltipPinnedState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned } = tooltip;\n\n return pinned;\n });\n\nexport const useMapOverlayState = <T>() =>\n useSelector(({ overlay }: MapState<T>) => overlay);\n\nexport const useMapZoomState = <T>() =>\n useSelector(({ zoom }: MapState<T>) => zoom);\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;AAGxB;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,gBAAgB;AAGlB,MAAM,cAAc,CAAO,aAChC,iBAAiB,UAAyC,UAAU,OAAO;AAEtE,MAAM,uBAAuB,MAClC,YAAY,CAAC,EAAE,UAAU,MAAmB,SAAS;AAEhD,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,QAAQ,GAAG,aAAa,IAAI;AAEpC,SAAO;AACT,CAAC;AAEI,MAAM,6BAA6B,MACxC,YAAY,CAAC,EAAE,QAAQ,MAAmB,QAAQ,QAAQ;AAErD,MAAM,mCAAmC,MAC9C,YAAY,CAAC,EAAE,QAAQ,MAAmB,QAAQ,cAAc;AAE3D,MAAM,2BAA2B,MACtC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,OAAO,IAAI;AAEnB,SAAO;AACT,CAAC;AAEI,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB,OAAO;AAE5C,MAAM,kBAAkB,MAC7B,YAAY,CAAC,EAAE,KAAK,MAAmB,IAAI;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,6 @@
1
1
  import { useContext } from "react";
2
2
  import { MapStore } from "./map-store.context.js";
3
+ import { extractDataFromEvent } from "../utils/parse-tooltip-data.js";
3
4
  const useSetState = () => {
4
5
  const { setState } = useContext(MapStore);
5
6
  return setState;
@@ -20,13 +21,63 @@ const useSetStateSelection = () => {
20
21
  const useSetStateTooltip = () => {
21
22
  const setState = useSetState();
22
23
  return (newTooltipState) => {
23
- setState((prev) => ({
24
- ...prev,
25
- tooltip: {
26
- ...prev.tooltip,
27
- ...newTooltipState
24
+ setState((prev) => {
25
+ const { location, data, hoveredLayerId, ...tooltipState } = newTooltipState;
26
+ return {
27
+ ...prev,
28
+ tooltip: {
29
+ ...prev.tooltip,
30
+ ...tooltipState,
31
+ hoveredLayerId: prev.tooltip.pinned ? prev.tooltip.hoveredLayerId : hoveredLayerId,
32
+ data: prev.tooltip.pinned ? prev.tooltip.data : data,
33
+ location: prev.tooltip.pinned ? prev.tooltip.location : location
34
+ }
35
+ };
36
+ });
37
+ };
38
+ };
39
+ const clearTooltip = (prev) => {
40
+ return {
41
+ ...prev,
42
+ tooltip: {
43
+ ...prev.tooltip,
44
+ pinned: false,
45
+ data: void 0,
46
+ pinnedId: void 0,
47
+ hoveredLayerId: void 0,
48
+ visible: false,
49
+ location: void 0
50
+ }
51
+ };
52
+ };
53
+ const useClearTooltip = () => {
54
+ const setState = useSetState();
55
+ return () => {
56
+ setState(clearTooltip);
57
+ };
58
+ };
59
+ const useTooltipPinnedState = () => {
60
+ const setState = useSetState();
61
+ return (event) => {
62
+ setState((prev) => {
63
+ const { data, featureId, hoveredLayerId } = extractDataFromEvent(event);
64
+ if (!featureId) {
65
+ return clearTooltip(prev);
28
66
  }
29
- }));
67
+ const isPinned = prev.tooltip.pinnedId !== featureId;
68
+ return {
69
+ ...prev,
70
+ tooltip: {
71
+ ...prev.tooltip,
72
+ data,
73
+ hoveredLayerId,
74
+ visible: true,
75
+ location: event.lngLat,
76
+ pinned: isPinned,
77
+ pinnedId: isPinned ? featureId : void 0
78
+ }
79
+ };
80
+ });
30
81
  };
31
82
  };
32
83
  const useSetStateOverlay = () => {
@@ -41,23 +92,6 @@ const useSetStateOverlay = () => {
41
92
  }));
42
93
  };
43
94
  };
44
- const useToggleStatePinnedTooltip = () => {
45
- const setState = useSetState();
46
- return () => {
47
- setState((prev) => {
48
- if (prev.tooltip.visible || prev.tooltip.pinned) {
49
- return {
50
- ...prev,
51
- tooltip: {
52
- ...prev.tooltip,
53
- pinned: !prev.tooltip.pinned
54
- }
55
- };
56
- }
57
- return { ...prev };
58
- });
59
- };
60
- };
61
95
  const useSetStateZoom = () => {
62
96
  const setState = useSetState();
63
97
  return (newZoomState) => {
@@ -71,11 +105,12 @@ const useSetStateZoom = () => {
71
105
  };
72
106
  };
73
107
  export {
108
+ useClearTooltip,
74
109
  useSetState,
75
110
  useSetStateOverlay,
76
111
  useSetStateSelection,
77
112
  useSetStateTooltip,
78
113
  useSetStateZoom,
79
- useToggleStatePinnedTooltip
114
+ useTooltipPinnedState
80
115
  };
81
116
  //# sourceMappingURL=store.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/store/store.ts"],
4
- "sourcesContent": ["import { useContext } from 'react';\n\nimport { MapStore } from './map-store.context.js';\nimport type {\n MapOverlayState,\n MapSelectionState,\n MapTooltipState,\n ZoomState,\n} from '../types/state.js';\n\nexport const useSetState = () => {\n const { setState } = useContext(MapStore);\n\n return setState;\n};\n\nexport * from './selectors.js';\n\nexport const useSetStateSelection = () => {\n const setState = useSetState();\n\n return (newSelectionState: Partial<MapSelectionState>) => {\n setState((prev) => ({\n ...prev,\n selection: {\n ...prev.selection,\n ...newSelectionState,\n },\n }));\n };\n};\n\nexport const useSetStateTooltip = <T>() => {\n const setState = useSetState();\n\n return (newTooltipState: Partial<MapTooltipState<T>>) => {\n setState((prev) => ({\n ...prev,\n tooltip: {\n ...prev.tooltip,\n ...newTooltipState,\n },\n }));\n };\n};\n\nexport const useSetStateOverlay = () => {\n const setState = useSetState();\n\n return (newOverlayState: Partial<MapOverlayState>) => {\n setState((prev) => ({\n ...prev,\n overlay: {\n ...prev.overlay,\n ...newOverlayState,\n },\n }));\n };\n};\n\nexport const useToggleStatePinnedTooltip = () => {\n const setState = useSetState();\n\n return () => {\n setState((prev) => {\n if (prev.tooltip.visible || prev.tooltip.pinned) {\n return {\n ...prev,\n tooltip: {\n ...prev.tooltip,\n pinned: !prev.tooltip.pinned,\n },\n };\n }\n return { ...prev };\n });\n };\n};\n\nexport const useSetStateZoom = () => {\n const setState = useSetState();\n\n return (newZoomState: Partial<ZoomState>) => {\n setState((prev) => ({\n ...prev,\n zoom: {\n ...prev.zoom,\n ...newZoomState,\n },\n }));\n };\n};\n"],
5
- "mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AAQlB,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,SAAS,IAAI,WAAW,QAAQ;AAExC,SAAO;AACT;AAEA,cAAc;AAEP,MAAM,uBAAuB,MAAM;AACxC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,sBAAkD;AACxD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,WAAW;AAAA,QACT,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,qBAAqB,MAAS;AACzC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,oBAAiD;AACvD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,qBAAqB,MAAM;AACtC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,oBAA8C;AACpD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,8BAA8B,MAAM;AAC/C,QAAM,WAAW,YAAY;AAE7B,SAAO,MAAM;AACX,aAAS,CAAC,SAAS;AACjB,UAAI,KAAK,QAAQ,WAAW,KAAK,QAAQ,QAAQ;AAC/C,eAAO;AAAA,UACL,GAAG;AAAA,UACH,SAAS;AAAA,YACP,GAAG,KAAK;AAAA,YACR,QAAQ,CAAC,KAAK,QAAQ;AAAA,UACxB;AAAA,QACF;AAAA,MACF;AACA,aAAO,EAAE,GAAG,KAAK;AAAA,IACnB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,kBAAkB,MAAM;AACnC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,iBAAqC;AAC3C,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,MAAM;AAAA,QACJ,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;",
4
+ "sourcesContent": ["import type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useContext } from 'react';\n\nimport { MapStore } from './map-store.context.js';\nimport type {\n MapOverlayState,\n MapSelectionState,\n MapState,\n MapTooltipState,\n ZoomState,\n} from '../types/state.js';\nimport { extractDataFromEvent } from '../utils/parse-tooltip-data.js';\n\nexport const useSetState = () => {\n const { setState } = useContext(MapStore);\n\n return setState;\n};\n\nexport * from './selectors.js';\n\nexport const useSetStateSelection = () => {\n const setState = useSetState();\n\n return (newSelectionState: Partial<MapSelectionState>) => {\n setState((prev) => ({\n ...prev,\n selection: {\n ...prev.selection,\n ...newSelectionState,\n },\n }));\n };\n};\n\nexport const useSetStateTooltip = <T>() => {\n const setState = useSetState();\n\n return (newTooltipState: Partial<MapTooltipState<T>>) => {\n setState((prev) => {\n const { location, data, hoveredLayerId, ...tooltipState } =\n newTooltipState;\n return {\n ...prev,\n tooltip: {\n ...prev.tooltip,\n ...tooltipState,\n hoveredLayerId: prev.tooltip.pinned\n ? prev.tooltip.hoveredLayerId\n : hoveredLayerId,\n data: prev.tooltip.pinned ? prev.tooltip.data : data,\n location: prev.tooltip.pinned ? prev.tooltip.location : location,\n },\n };\n });\n };\n};\nconst clearTooltip = (prev: MapState<unknown>) => {\n return {\n ...prev,\n tooltip: {\n ...prev.tooltip,\n pinned: false,\n data: undefined,\n pinnedId: undefined,\n hoveredLayerId: undefined,\n visible: false,\n location: undefined,\n },\n };\n};\nexport const useClearTooltip = () => {\n const setState = useSetState();\n\n return () => {\n setState(clearTooltip);\n };\n};\n\nexport const useTooltipPinnedState = () => {\n const setState = useSetState();\n\n return (event: MapLayerMouseEvent) => {\n setState((prev) => {\n const { data, featureId, hoveredLayerId } = extractDataFromEvent(event);\n if (!featureId) {\n return clearTooltip(prev);\n }\n\n const isPinned = prev.tooltip.pinnedId !== featureId;\n return {\n ...prev,\n tooltip: {\n ...prev.tooltip,\n data,\n hoveredLayerId,\n visible: true,\n location: event.lngLat,\n pinned: isPinned,\n pinnedId: isPinned ? featureId : undefined,\n },\n };\n });\n };\n};\n\nexport const useSetStateOverlay = () => {\n const setState = useSetState();\n\n return (newOverlayState: Partial<MapOverlayState>) => {\n setState((prev) => ({\n ...prev,\n overlay: {\n ...prev.overlay,\n ...newOverlayState,\n },\n }));\n };\n};\n\nexport const useSetStateZoom = () => {\n const setState = useSetState();\n\n return (newZoomState: Partial<ZoomState>) => {\n setState((prev) => ({\n ...prev,\n zoom: {\n ...prev.zoom,\n ...newZoomState,\n },\n }));\n };\n};\n"],
5
+ "mappings": "AACA,SAAS,kBAAkB;AA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AC,UAA8B;AACpC,aAAS,CAAC,SAAS;AACjB,YAAM,EAAE,MAAM,WAAW,eAAe,IAAI,qBAAqB,KAAK;AACtE,UAAI,CAAC,WAAW;AACd,eAAO,aAAa,IAAI;AAAA,MAC1B;AAEA,YAAM,WAAW,KAAK,QAAQ,aAAa;AAC3C,aAAO;AAAA,QACL,GAAG;AAAA,QACH,SAAS;AAAA,UACP,GAAG,KAAK;AAAA,UACR;AAAA,UACA;AAAA,UACA,SAAS;AAAA,UACT,UAAU,MAAM;AAAA,UAChB,QAAQ;AAAA,UACR,UAAU,WAAW,YAAY;AAAA,QACnC;AAAA,MACF;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEO,MAAM,qBAAqB,MAAM;AACtC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,oBAA8C;AACpD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,kBAAkB,MAAM;AACnC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,iBAAqC;AAC3C,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,MAAM;AAAA,QACJ,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ import { isEmpty } from "lodash-es";
1
2
  import { Children } from "react";
2
3
  import { ChartToolbar } from "@dynatrace/strato-components-preview/charts";
3
4
  import {
@@ -11,8 +12,11 @@ import { replaceInfiniteValuesInRanges } from "./replace-infinite-values-in-rang
11
12
  import { BaseLayer } from "../slots/BaseLayer.js";
12
13
  import { CategoricalLegend } from "../slots/CategoricalLegend.js";
13
14
  import { ChartInteractions } from "../slots/ChartInteractions.js";
15
+ import { DownloadCSV } from "../slots/DownloadCSV.js";
14
16
  import { SequentialLegend } from "../slots/SequentialLegend.js";
15
17
  import { ThresholdLegend } from "../slots/ThresholdLegend.js";
18
+ import { Toolbar } from "../slots/Toolbar.js";
19
+ import { Zoom } from "../slots/Zoom.js";
16
20
  const iterateConfigSlots = (children, legendDomain) => {
17
21
  let slots = {
18
22
  toolbar: void 0,
@@ -20,6 +24,7 @@ const iterateConfigSlots = (children, legendDomain) => {
20
24
  legend: void 0,
21
25
  baseLayer: DEFAULT_BASE_LAYER_RULES
22
26
  };
27
+ let slotMapToolbarConfig = {};
23
28
  Children.forEach(children, (child) => {
24
29
  if (isSlot(child, ChartInteractions)) {
25
30
  const { children: children2, ...previousInteractions } = child.props;
@@ -79,6 +84,18 @@ const iterateConfigSlots = (children, legendDomain) => {
79
84
  ranges
80
85
  }
81
86
  };
87
+ } else if (isSlot(child, Toolbar)) {
88
+ slotMapToolbarConfig = { ...slotMapToolbarConfig, ...child.props };
89
+ } else if (isSlot(child, DownloadCSV)) {
90
+ slotMapToolbarConfig = {
91
+ ...slotMapToolbarConfig,
92
+ downloadCSV: { enabled: true }
93
+ };
94
+ } else if (isSlot(child, Zoom)) {
95
+ slotMapToolbarConfig = {
96
+ ...slotMapToolbarConfig,
97
+ zoom: { enabled: true }
98
+ };
82
99
  } else if (isSlot(child, BaseLayer)) {
83
100
  slots = {
84
101
  ...slots,
@@ -89,6 +106,9 @@ const iterateConfigSlots = (children, legendDomain) => {
89
106
  };
90
107
  }
91
108
  });
109
+ if (!isEmpty(slotMapToolbarConfig)) {
110
+ slots.toolbar = { ...slots.toolbar, ...slotMapToolbarConfig };
111
+ }
92
112
  return slots;
93
113
  };
94
114
  const iterateChartInteractionsSlots = (children) => {
@@ -108,7 +128,7 @@ const iterateChartToolbarSlots = (children) => {
108
128
  if (isSlot(childToolbar, ChartToolbar.DownloadData)) {
109
129
  toolbar = {
110
130
  ...toolbar,
111
- downloadData: { enabled: true }
131
+ downloadCSV: { enabled: true }
112
132
  };
113
133
  }
114
134
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/iterate-config-slots.ts"],
4
- "sourcesContent": ["import { Children, type ReactNode } from 'react';\n\nimport { ChartToolbar } from '@dynatrace/strato-components-preview/charts';\n\nimport {\n DEFAULT_BASE_LAYER_RULES,\n DEFAULT_MAP_LEGEND_RATIO,\n DEFAULT_MAP_POSITION,\n DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n} from '../constants.js';\nimport { isSlot } from './is-slot.js';\nimport { replaceInfiniteValuesInRanges } from './replace-infinite-values-in-ranges.js';\nimport { BaseLayer } from '../slots/BaseLayer.js';\nimport { CategoricalLegend } from '../slots/CategoricalLegend.js';\nimport { ChartInteractions } from '../slots/ChartInteractions.js';\nimport { SequentialLegend } from '../slots/SequentialLegend.js';\nimport { ThresholdLegend } from '../slots/ThresholdLegend.js';\nimport type { MapConfig } from '../types/configuration.js';\nimport type { ChartInteractionsConfig } from '../types/toolbar.js';\n\n/**\n * Generate map config based on slots\n * @param children - Map children\n * @param legendDomain - Domain containing min and max value relevant for legend\n * @returns Map slot config\n */\nexport const iterateConfigSlots = (\n children: ReactNode,\n legendDomain: [number, number],\n) => {\n let slots: MapConfig = {\n toolbar: undefined,\n interactions: undefined,\n legend: undefined,\n baseLayer: DEFAULT_BASE_LAYER_RULES,\n };\n\n Children.forEach(children, (child) => {\n if (isSlot(child, ChartInteractions)) {\n const { children, ...previousInteractions } = child.props;\n\n const interactions = iterateChartInteractionsSlots(children);\n\n slots = {\n ...slots,\n interactions: {\n ...previousInteractions,\n ...interactions,\n },\n };\n } else if (isSlot(child, ChartToolbar)) {\n const { children, ...toolbar } = child.props;\n const childrenToolbar = iterateChartToolbarSlots(children);\n\n slots = {\n ...slots,\n toolbar: {\n ...toolbar,\n ...childrenToolbar,\n },\n };\n } else if (isSlot(child, SequentialLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'sequential',\n colorPalette: DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n min: child.props.min ?? legendDomain[0],\n max: child.props.max ?? legendDomain[1],\n },\n };\n } else if (isSlot(child, CategoricalLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'categorical',\n position: DEFAULT_MAP_POSITION,\n ...child.props,\n },\n };\n } else if (isSlot(child, ThresholdLegend)) {\n const getDomainValue = (index: number, legendDomainValue: number) =>\n Number.isFinite(legendDomainValue)\n ? legendDomainValue\n : child.props.ranges?.at(index)?.to ?? legendDomainValue;\n\n const ranges = replaceInfiniteValuesInRanges(child.props.ranges, [\n getDomainValue(0, legendDomain[0]),\n getDomainValue(-1, legendDomain[1]),\n ]);\n\n slots = {\n ...slots,\n legend: {\n type: 'threshold',\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n ranges,\n },\n };\n } else if (isSlot(child, BaseLayer)) {\n slots = {\n ...slots,\n baseLayer: {\n ...slots.baseLayer,\n ...child.props,\n },\n };\n }\n });\n\n return slots;\n};\n\nconst iterateChartInteractionsSlots = (children: ReactNode) => {\n let interactions: ChartInteractionsConfig = {};\n\n Children.forEach(children, (childInteractions) => {\n if (isSlot(childInteractions, ChartInteractions.Zoom)) {\n interactions = { ...interactions, zoom: { enabled: true } };\n } else if (isSlot(childInteractions, ChartInteractions.ZoomToFit)) {\n interactions = { ...interactions, zoomToFit: { enabled: true } };\n }\n });\n\n return interactions;\n};\n\n/**\n * Generates chart config based on slots\n * @param children - CharInteraction children\n * @returns ChartInteraction slot config\n */\nconst iterateChartToolbarSlots = (children: ReactNode) => {\n let toolbar = {};\n\n Children.forEach(children, (childToolbar) => {\n if (isSlot(childToolbar, ChartToolbar.DownloadData)) {\n toolbar = {\n ...toolbar,\n downloadData: { enabled: true },\n };\n }\n });\n\n return toolbar;\n};\n"],
5
- "mappings": "AAAA,SAAS,gBAAgC;AAEzC,SAAS,oBAA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AI,OAAO,cAAc,aAAa,YAAY,GAAG;AACnD,gBAAU;AAAA,QACR,GAAG;AAAA,QACH,cAAc,EAAE,SAAS,KAAK;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
4
+ "sourcesContent": ["import { isEmpty } from 'lodash-es';\nimport { Children, type ReactNode } from 'react';\n\nimport { ChartToolbar } from '@dynatrace/strato-components-preview/charts';\n\nimport {\n DEFAULT_BASE_LAYER_RULES,\n DEFAULT_MAP_LEGEND_RATIO,\n DEFAULT_MAP_POSITION,\n DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n} from '../constants.js';\nimport { isSlot } from './is-slot.js';\nimport { replaceInfiniteValuesInRanges } from './replace-infinite-values-in-ranges.js';\nimport { BaseLayer } from '../slots/BaseLayer.js';\nimport { CategoricalLegend } from '../slots/CategoricalLegend.js';\nimport { ChartInteractions } from '../slots/ChartInteractions.js';\nimport { DownloadCSV } from '../slots/DownloadCSV.js';\nimport { SequentialLegend } from '../slots/SequentialLegend.js';\nimport { ThresholdLegend } from '../slots/ThresholdLegend.js';\nimport { Toolbar } from '../slots/Toolbar.js';\nimport { Zoom } from '../slots/Zoom.js';\nimport type { MapConfig } from '../types/configuration.js';\nimport type {\n ChartInteractionsConfig,\n MapToolbarConfig,\n} from '../types/toolbar.js';\n\n/**\n * Generate map config based on slots\n * @param children - Map children\n * @param legendDomain - Domain containing min and max value relevant for legend\n * @returns Map slot config\n */\nexport const iterateConfigSlots = (\n children: ReactNode,\n legendDomain: [number, number],\n) => {\n let slots: MapConfig = {\n toolbar: undefined,\n interactions: undefined,\n legend: undefined,\n baseLayer: DEFAULT_BASE_LAYER_RULES,\n };\n\n let slotMapToolbarConfig: MapToolbarConfig = {};\n\n Children.forEach(children, (child) => {\n if (isSlot(child, ChartInteractions)) {\n const { children, ...previousInteractions } = child.props;\n\n const interactions = iterateChartInteractionsSlots(children);\n\n slots = {\n ...slots,\n interactions: {\n ...previousInteractions,\n ...interactions,\n },\n };\n } else if (isSlot(child, ChartToolbar)) {\n const { children, ...toolbar } = child.props;\n const childrenToolbar = iterateChartToolbarSlots(children);\n\n slots = {\n ...slots,\n toolbar: {\n ...toolbar,\n ...childrenToolbar,\n },\n };\n } else if (isSlot(child, SequentialLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'sequential',\n colorPalette: DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n min: child.props.min ?? legendDomain[0],\n max: child.props.max ?? legendDomain[1],\n },\n };\n } else if (isSlot(child, CategoricalLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'categorical',\n position: DEFAULT_MAP_POSITION,\n ...child.props,\n },\n };\n } else if (isSlot(child, ThresholdLegend)) {\n const getDomainValue = (index: number, legendDomainValue: number) =>\n Number.isFinite(legendDomainValue)\n ? legendDomainValue\n : child.props.ranges?.at(index)?.to ?? legendDomainValue;\n\n const ranges = replaceInfiniteValuesInRanges(child.props.ranges, [\n getDomainValue(0, legendDomain[0]),\n getDomainValue(-1, legendDomain[1]),\n ]);\n\n slots = {\n ...slots,\n legend: {\n type: 'threshold',\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n ranges,\n },\n };\n } else if (isSlot(child, Toolbar)) {\n slotMapToolbarConfig = { ...slotMapToolbarConfig, ...child.props };\n } else if (isSlot(child, DownloadCSV)) {\n slotMapToolbarConfig = {\n ...slotMapToolbarConfig,\n downloadCSV: { enabled: true },\n };\n } else if (isSlot(child, Zoom)) {\n slotMapToolbarConfig = {\n ...slotMapToolbarConfig,\n zoom: { enabled: true },\n };\n } else if (isSlot(child, BaseLayer)) {\n slots = {\n ...slots,\n baseLayer: {\n ...slots.baseLayer,\n ...child.props,\n },\n };\n }\n });\n if (!isEmpty(slotMapToolbarConfig)) {\n slots.toolbar = { ...slots.toolbar, ...slotMapToolbarConfig };\n }\n\n return slots;\n};\n\nconst iterateChartInteractionsSlots = (children: ReactNode) => {\n let interactions: ChartInteractionsConfig = {};\n\n Children.forEach(children, (childInteractions) => {\n if (isSlot(childInteractions, ChartInteractions.Zoom)) {\n interactions = { ...interactions, zoom: { enabled: true } };\n } else if (isSlot(childInteractions, ChartInteractions.ZoomToFit)) {\n interactions = { ...interactions, zoomToFit: { enabled: true } };\n }\n });\n\n return interactions;\n};\n\n/**\n * Generates chart config based on slots\n * @param children - CharInteraction children\n * @returns ChartInteraction slot config\n */\nconst iterateChartToolbarSlots = (children: ReactNode) => {\n let toolbar = {};\n\n Children.forEach(children, (childToolbar) => {\n if (isSlot(childToolbar, ChartToolbar.DownloadData)) {\n toolbar = {\n ...toolbar,\n downloadCSV: { enabled: true },\n };\n }\n });\n\n return toolbar;\n};\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;AACxB,SAAS,gBAAgC;AAEzC,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,qCAAqC;AAC9C,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,eAAe;AACxB,SAAS,YAAY;AAad,MAAM,qBAAqB,CAChC,UACA,iBACG;AACH,MAAI,QAAmB;AAAA,IACrB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAEA,MAAI,uBAAyC,CAAC;AAE9C,WAAS,QAAQ,UAAU,CAAC,UAAU;AACpC,QAAI,OAAO,OAAO,iBAAiB,GAAG;AACpC,YAAM,EAAE,UAAAA,WAAU,GAAG,qBAAqB,IAAI,MAAM;AAEpD,YAAM,eAAe,8BAA8BA,SAAQ;AAE3D,cAAQ;AAAA,QACN,GAAG;AAAA,QACH,cA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;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
6
  "names": ["children"]
7
7
  }
@@ -29,7 +29,24 @@ const parseTooltipData = (features) => {
29
29
  }
30
30
  return data;
31
31
  };
32
+ const extractDataFromEvent = (event) => {
33
+ if (!event.features?.length) {
34
+ return {};
35
+ }
36
+ const feature = event.features[0];
37
+ const hoveredLayerId = feature.layer.id;
38
+ const hoveredFeatures = event.features.filter(
39
+ (feature2) => feature2.layer.id === hoveredLayerId
40
+ );
41
+ const data = parseTooltipData(hoveredFeatures);
42
+ return {
43
+ featureId: `${hoveredLayerId}-${feature.id}`,
44
+ hoveredLayerId,
45
+ data
46
+ };
47
+ };
32
48
  export {
49
+ extractDataFromEvent,
33
50
  parseTooltipData
34
51
  };
35
52
  //# sourceMappingURL=parse-tooltip-data.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/parse-tooltip-data.ts"],
4
- "sourcesContent": ["import type GeoJSON from 'geojson';\nimport type { MapGeoJSONFeature } from 'maplibre-gl';\n\n/**\n * Tries to deserialize an object, if serialized\n * @param serializedObject - string\n */\nconst deserializeObject = (\n serializedObject: string,\n): string | Record<string, unknown> => {\n try {\n return JSON.parse(serializedObject);\n } catch {\n return serializedObject;\n }\n};\n\n/**\n * Deserializes map feature properties that are serialized\n *\n * @param featureProperties - map feature properties\n */\nconst parseFeatureProperties = (featureProperties: Record<string, unknown>) => {\n const properties: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(featureProperties)) {\n if (typeof value === 'string') {\n properties[key] = deserializeObject(value);\n } else {\n properties[key] = value;\n }\n }\n\n return properties;\n};\n\n/**\n * Extracts useful map features data for the tooltip\n * @param features - map features\n */\nexport const parseTooltipData = (features: MapGeoJSONFeature[]) => {\n const data: unknown[] = [];\n\n for (const feature of features) {\n const properties = parseFeatureProperties(feature.properties);\n const [latitude, longitude] = (feature.geometry as GeoJSON.Point)\n .coordinates;\n\n data.push({\n ...properties,\n latitude,\n longitude,\n });\n }\n\n return data;\n};\n"],
5
- "mappings": "AAOA,MAAM,oBAAoB,CACxB,qBACqC;AACrC,MAAI;AACF,WAAO,KAAK,MAAM,gBAAgB;AAAA,EACpC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOA,MAAM,yBAAyB,CAAC,sBAA+C;AAC7E,QAAM,aAAsC,CAAC;AAE7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,iBAAiB,GAAG;AAC5D,QAAI,OAAO,UAAU,UAAU;AAC7B,iBAAW,GAAG,IAAI,kBAAkB,KAAK;AAAA,IAC3C,OAAO;AACL,iBAAW,GAAG,IAAI;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;AAMO,MAAM,mBAAmB,CAAC,aAAkC;AACjE,QAAM,OAAkB,CAAC;AAEzB,aAAW,WAAW,UAAU;AAC9B,UAAM,aAAa,uBAAuB,QAAQ,UAAU;AAC5D,UAAM,CAAC,UAAU,SAAS,IAAK,QAAQ,SACpC;AAEH,SAAK,KAAK;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;",
6
- "names": []
4
+ "sourcesContent": ["import type GeoJSON from 'geojson';\nimport type { MapGeoJSONFeature, MapLayerMouseEvent } from 'maplibre-gl';\n\n/**\n * Tries to deserialize an object, if serialized\n * @param serializedObject - string\n */\nconst deserializeObject = (\n serializedObject: string,\n): string | Record<string, unknown> => {\n try {\n return JSON.parse(serializedObject);\n } catch {\n return serializedObject;\n }\n};\n\n/**\n * Deserializes map feature properties that are serialized\n *\n * @param featureProperties - map feature properties\n */\nconst parseFeatureProperties = (featureProperties: Record<string, unknown>) => {\n const properties: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(featureProperties)) {\n if (typeof value === 'string') {\n properties[key] = deserializeObject(value);\n } else {\n properties[key] = value;\n }\n }\n\n return properties;\n};\n\n/**\n * Extracts useful map features data for the tooltip\n * @param features - map features\n */\nexport const parseTooltipData = (features: MapGeoJSONFeature[]) => {\n const data: unknown[] = [];\n\n for (const feature of features) {\n const properties = parseFeatureProperties(feature.properties);\n const [latitude, longitude] = (feature.geometry as GeoJSON.Point)\n .coordinates;\n\n data.push({\n ...properties,\n latitude,\n longitude,\n });\n }\n\n return data;\n};\n\nexport const extractDataFromEvent = (event: MapLayerMouseEvent) => {\n if (!event.features?.length) {\n return {};\n }\n const feature = event.features[0];\n const hoveredLayerId = feature.layer.id;\n const hoveredFeatures = event.features.filter(\n (feature) => feature.layer.id === hoveredLayerId,\n );\n\n const data = parseTooltipData(hoveredFeatures);\n\n return {\n featureId: `${hoveredLayerId}-${feature.id}`,\n hoveredLayerId,\n data,\n };\n};\n"],
5
+ "mappings": "AAOA,MAAM,oBAAoB,CACxB,qBACqC;AACrC,MAAI;AACF,WAAO,KAAK,MAAM,gBAAgB;AAAA,EACpC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOA,MAAM,yBAAyB,CAAC,sBAA+C;AAC7E,QAAM,aAAsC,CAAC;AAE7C,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,iBAAiB,GAAG;AAC5D,QAAI,OAAO,UAAU,UAAU;AAC7B,iBAAW,GAAG,IAAI,kBAAkB,KAAK;AAAA,IAC3C,OAAO;AACL,iBAAW,GAAG,IAAI;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;AAMO,MAAM,mBAAmB,CAAC,aAAkC;AACjE,QAAM,OAAkB,CAAC;AAEzB,aAAW,WAAW,UAAU;AAC9B,UAAM,aAAa,uBAAuB,QAAQ,UAAU;AAC5D,UAAM,CAAC,UAAU,SAAS,IAAK,QAAQ,SACpC;AAEH,SAAK,KAAK;AAAA,MACR,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAAC,UAA8B;AACjE,MAAI,CAAC,MAAM,UAAU,QAAQ;AAC3B,WAAO,CAAC;AAAA,EACV;AACA,QAAM,UAAU,MAAM,SAAS,CAAC;AAChC,QAAM,iBAAiB,QAAQ,MAAM;AACrC,QAAM,kBAAkB,MAAM,SAAS;AAAA,IACrC,CAACA,aAAYA,SAAQ,MAAM,OAAO;AAAA,EACpC;AAEA,QAAM,OAAO,iBAAiB,eAAe;AAE7C,SAAO;AAAA,IACL,WAAW,GAAG,cAAc,IAAI,QAAQ,EAAE;AAAA,IAC1C;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": ["feature"]
7
7
  }
package/map/MapView.d.ts CHANGED
@@ -7,4 +7,16 @@ import './styles/react-mapgl-styles.css';
7
7
  */
8
8
  export declare const MapView: ((props: PropsWithChildren<MapViewProps> & import("react").RefAttributes<MapViewRef>) => React.ReactElement | null) & {
9
9
  ErrorState: (props: import("./slots/states/ErrorStateSlot.js").ErrorStateSlotProps) => null;
10
+ Toolbar: {
11
+ (props: import("./index.js").MapToolbarSlotProps): null;
12
+ displayName: string;
13
+ };
14
+ DownloadCSV: {
15
+ (): null;
16
+ displayName: string;
17
+ };
18
+ Zoom: {
19
+ (): null;
20
+ displayName: string;
21
+ };
10
22
  };
package/map/MapView.js CHANGED
@@ -38,7 +38,10 @@ var import_map_truncation_mode_context = require("./contexts/map-truncation-mode
38
38
  var import_use_load_map_base_layer = require("./hooks/use-load-map-base-layer.js");
39
39
  var import_color_scale_provider = require("./providers/color-scale.provider.js");
40
40
  var import_layer_color_strategy_provider = require("./providers/layer-color-strategy.provider.js");
41
+ var import_DownloadCSV = require("./slots/DownloadCSV.js");
41
42
  var import_ErrorStateSlot = require("./slots/states/ErrorStateSlot.js");
43
+ var import_Toolbar = require("./slots/Toolbar.js");
44
+ var import_Zoom = require("./slots/Zoom.js");
42
45
  var import_map_store_provider = require("./store/map-store.provider.js");
43
46
  var import_build_scale_from_legend_config = require("./utils/build-scale-from-legend-config.js");
44
47
  var import_extract_layers_data = require("./utils/extract-layers-data.js");
@@ -160,5 +163,8 @@ const _MapView = (0, import_react.forwardRef)(
160
163
  );
161
164
  _MapView["displayName"] = "MapView";
162
165
  const MapView = Object.assign(_MapView, {
163
- ErrorState: import_ErrorStateSlot.ErrorStateSlot
166
+ ErrorState: import_ErrorStateSlot.ErrorStateSlot,
167
+ Toolbar: import_Toolbar.Toolbar,
168
+ DownloadCSV: import_DownloadCSV.DownloadCSV,
169
+ Zoom: import_Zoom.Zoom
164
170
  });
@@ -38,6 +38,7 @@ var import_use_tooltip_template = require("../../hooks/use-tooltip-template.js")
38
38
  var import_BubbleLayerTooltip2 = require("../../slots/BubbleLayerTooltip.js");
39
39
  var import_bubble_layer = require("../../types/bubble-layer.js");
40
40
  var import_tooltip_type_guards = require("../../utils/tooltip-type-guards.js");
41
+ var import_TooltipWrapper = require("../TooltipWrapper.js");
41
42
  const BubbleLayer = (props) => {
42
43
  const {
43
44
  data,
@@ -67,18 +68,15 @@ const BubbleLayer = (props) => {
67
68
  radiusScale
68
69
  );
69
70
  const tooltipTemplate = (0, import_use_tooltip_template.useTooltipTemplate)(children, import_BubbleLayerTooltip2.BubbleLayerTooltip);
70
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
71
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_size_interpolation_context.SizeInterpolationContext.Provider, { value: sizeInterpolation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_maplibre.Source, { id: sourceId, type: "geojson", data: dataGeoJson, generateId: true, children: [
72
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_BubbleCircleLayer.BubbleCircleLayer, { id: layerId, source: sourceId }),
73
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_BubbleOutlineLayer.BubbleOutlineLayer, { beforeId: layerId, source: sourceId })
74
- ] }) }),
75
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
71
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_size_interpolation_context.SizeInterpolationContext.Provider, { value: sizeInterpolation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_maplibre.Source, { id: sourceId, type: "geojson", data: dataGeoJson, generateId: true, children: [
72
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_BubbleCircleLayer.BubbleCircleLayer, { id: layerId, source: sourceId }),
73
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_BubbleOutlineLayer.BubbleOutlineLayer, { beforeId: layerId, source: sourceId }),
74
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TooltipWrapper.TooltipWrapper, { layerId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
75
  import_BubbleLayerTooltip.BubbleLayerTooltip,
77
76
  {
78
- layerId,
79
77
  tooltipTemplate: (0, import_tooltip_type_guards.isBubbleTooltipTemplate)(tooltipTemplate) ? tooltipTemplate : void 0
80
78
  }
81
- )
82
- ] });
79
+ ) })
80
+ ] }) });
83
81
  };
84
82
  BubbleLayer["displayName"] = "BubbleLayer";
@@ -1,6 +1,5 @@
1
1
  import type { BubbleLayerTooltipHandler } from '../../types/tooltip.js';
2
2
  export interface BubbleLayerTooltipProps {
3
- layerId: string;
4
3
  tooltipTemplate?: BubbleLayerTooltipHandler;
5
4
  }
6
5
  export declare const BubbleLayerTooltip: {
@@ -25,9 +25,10 @@ var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_lodash_es = require("lodash");
26
26
  var import_react = require("react");
27
27
  var import_charts = require("@dynatrace/strato-components-preview/charts");
28
+ var import_use_get_position = require("../../hooks/use-get-position.js");
28
29
  var import_selectors = require("../../store/selectors.js");
29
30
  const BubbleLayerTooltip = (props) => {
30
- const { layerId, tooltipTemplate } = props;
31
+ const { tooltipTemplate } = props;
31
32
  const {
32
33
  selectedItem: selectedItemId,
33
34
  actionsMenuRef,
@@ -35,15 +36,16 @@ const BubbleLayerTooltip = (props) => {
35
36
  onLeave
36
37
  } = (0, import_charts._useChartActionsMenu)();
37
38
  const tooltipRef = (0, import_react.useRef)(null);
38
- const { hoveredLayerId, data, position, visible, enabled } = (0, import_selectors.useMapTooltipState)();
39
+ const { data, visible, enabled } = (0, import_selectors.useMapTooltipState)();
39
40
  const pinned = (0, import_selectors.useMapTooltipPinnedState)();
40
41
  const closestPoint = (0, import_react.useRef)(null);
41
42
  const remainingPoints = (0, import_react.useRef)([]);
42
- const forceHideTooltip = !pinned && (hoveredLayerId !== layerId || !visible || !enabled);
43
+ const forceHideTooltip = !pinned && (!visible || !enabled);
44
+ const position = (0, import_use_get_position.useGetPosition)(pinned, !forceHideTooltip);
43
45
  if (!tooltipTemplate || forceHideTooltip || !position) {
44
46
  return null;
45
47
  }
46
- if (!pinned && data?.[0]) {
48
+ if (data?.[0]) {
47
49
  const sanitizedData = data.map((bubbleProps) => {
48
50
  const {
49
51
  __color: color,
@@ -60,9 +62,14 @@ const BubbleLayerTooltip = (props) => {
60
62
  closestPoint.current = sortedBubbles[0];
61
63
  remainingPoints.current = sortedBubbles.slice(1);
62
64
  }
65
+ const template = closestPoint.current ? tooltipTemplate(closestPoint.current, remainingPoints.current) : null;
66
+ if (!template) {
67
+ return null;
68
+ }
63
69
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
64
70
  import_charts._ChartTooltip,
65
71
  {
72
+ updatePositionWhenPinned: true,
66
73
  position,
67
74
  pinned,
68
75
  ref: tooltipRef,
@@ -72,7 +79,7 @@ const BubbleLayerTooltip = (props) => {
72
79
  actionsMenuRef,
73
80
  updateSelectedItem
74
81
  },
75
- children: closestPoint.current ? tooltipTemplate(closestPoint.current, remainingPoints.current) : null
82
+ children: template
76
83
  }
77
84
  );
78
85
  };
@@ -23,8 +23,8 @@ __export(ChoroplethLayer_exports, {
23
23
  module.exports = __toCommonJS(ChoroplethLayer_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_react_maplibre = require("@vis.gl/react-maplibre");
26
- var import_charts = require("@dynatrace/strato-components-preview/charts");
27
26
  var import_ChoroplethLayerTooltip = require("./ChoroplethLayerTooltip.js");
27
+ var import_ChoroplethOutlineLayer = require("./ChoroplethOutlineLayer.js");
28
28
  var import_parse_region_data_to_geo_json = require("./utils/parse-region-data-to-geo-json.js");
29
29
  var import_constants = require("../../constants.js");
30
30
  var import_use_layer_coloring_strategy = require("../../hooks/use-layer-coloring-strategy.js");
@@ -35,6 +35,7 @@ var import_use_resolve_color = require("../../hooks/use-resolve-color.js");
35
35
  var import_use_tooltip_template = require("../../hooks/use-tooltip-template.js");
36
36
  var import_ChoroplethLayerTooltip2 = require("../../slots/ChoroplethLayerTooltip.js");
37
37
  var import_tooltip_type_guards = require("../../utils/tooltip-type-guards.js");
38
+ var import_TooltipWrapper = require("../TooltipWrapper.js");
38
39
  const ChoroplethLayer = (props) => {
39
40
  const { layerId, data, regionAccessor, children } = props;
40
41
  const mapSource = (0, import_use_map_base_layer_features.useMapBaseLayerFeatures)();
@@ -52,86 +53,39 @@ const ChoroplethLayer = (props) => {
52
53
  children,
53
54
  import_ChoroplethLayerTooltip2.ChoroplethLayerTooltip
54
55
  );
55
- return dataGeoJSON && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
56
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_maplibre.Source, { id: sourceId, type: "geojson", data: dataGeoJSON, generateId: true, children: [
57
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
- import_react_maplibre.Layer,
59
- {
60
- id: layerId,
61
- source: sourceId,
62
- type: "fill",
63
- paint: {
64
- "fill-color": ["get", "__color"],
65
- "fill-opacity": [
66
- "case",
67
- ["==", ["feature-state", "legendHover"], false],
68
- import_constants.SHAPE_OPACITY_DIMMED,
69
- ["==", ["feature-state", "active"], true],
70
- import_constants.SHAPE_OPACITY_DEFAULT,
71
- ["==", ["feature-state", "hover"], true],
72
- import_constants.SHAPE_OPACITY_DEFAULT,
73
- ["==", ["feature-state", "legendHover"], true],
74
- import_constants.SHAPE_OPACITY_DEFAULT,
75
- ["==", ["feature-state", "isAnyActive"], true],
76
- import_constants.SHAPE_OPACITY_DIMMED,
77
- import_constants.SHAPE_OPACITY_DEFAULT
78
- ]
79
- }
80
- }
81
- ),
82
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
- import_react_maplibre.Layer,
84
- {
85
- source: sourceId,
86
- type: "line",
87
- paint: {
88
- "line-color": [
89
- "case",
90
- ["==", ["feature-state", "active"], true],
91
- (0, import_charts._getCanvasColor)(import_constants.DEFAULT_BOUNDARIES_BORDER_COLOR),
92
- ["==", ["feature-state", "hover"], true],
93
- (0, import_charts._getCanvasColor)(import_constants.DEFAULT_BOUNDARIES_BORDER_COLOR),
94
- (0, import_charts._getCanvasColor)(import_constants.DEFAULT_BOUNDARIES_BORDER_COLOR)
95
- ],
96
- "line-width": [
97
- "case",
98
- ["==", ["feature-state", "active"], true],
99
- import_constants.ACTIVE_BORDER_WIDTH_OUTER,
100
- ["==", ["feature-state", "hover"], true],
101
- import_constants.ACTIVE_BORDER_WIDTH_OUTER,
102
- ["==", ["get", "region_type"], "REGION"],
103
- import_constants.REGION_BORDER_WIDTH,
104
- import_constants.COUNTRY_BORDER_WIDTH
105
- ]
106
- }
107
- }
108
- ),
109
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
110
- import_react_maplibre.Layer,
111
- {
112
- source: sourceId,
113
- type: "line",
114
- paint: {
115
- "line-color": [
116
- "case",
117
- ["==", ["feature-state", "active"], true],
118
- (0, import_charts._getCanvasColor)(import_constants.ACTIVE_COLOR),
119
- ["==", ["feature-state", "hover"], true],
120
- (0, import_charts._getCanvasColor)(import_constants.ACTIVE_COLOR),
121
- (0, import_charts._getCanvasColor)(import_constants.TRANSPARENT_BORDER_COLOR)
122
- ],
123
- "line-width": import_constants.ACTIVE_BORDER_WIDTH_INNER
124
- }
125
- }
126
- )
127
- ] }),
56
+ return dataGeoJSON && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_maplibre.Source, { id: sourceId, type: "geojson", data: dataGeoJSON, generateId: true, children: [
128
57
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
+ import_react_maplibre.Layer,
59
+ {
60
+ id: layerId,
61
+ source: sourceId,
62
+ type: "fill",
63
+ paint: {
64
+ "fill-color": ["get", "__color"],
65
+ "fill-opacity": [
66
+ "case",
67
+ ["==", ["feature-state", "legendHover"], false],
68
+ import_constants.SHAPE_OPACITY_DIMMED,
69
+ ["==", ["feature-state", "active"], true],
70
+ import_constants.SHAPE_OPACITY_DEFAULT,
71
+ ["==", ["feature-state", "hover"], true],
72
+ import_constants.SHAPE_OPACITY_DEFAULT,
73
+ ["==", ["feature-state", "legendHover"], true],
74
+ import_constants.SHAPE_OPACITY_DEFAULT,
75
+ ["==", ["feature-state", "isAnyActive"], true],
76
+ import_constants.SHAPE_OPACITY_DIMMED,
77
+ import_constants.SHAPE_OPACITY_DEFAULT
78
+ ]
79
+ }
80
+ }
81
+ ),
82
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChoroplethOutlineLayer.ChoroplethOutlineLayer, { sourceId }),
83
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TooltipWrapper.TooltipWrapper, { layerId, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
129
84
  import_ChoroplethLayerTooltip.ChoroplethLayerTooltip,
130
85
  {
131
- layerId,
132
86
  tooltipTemplate: (0, import_tooltip_type_guards.isChoroplethTooltipTemplate)(tooltipTemplate) ? tooltipTemplate : void 0
133
87
  }
134
- )
88
+ ) })
135
89
  ] });
136
90
  };
137
91
  ChoroplethLayer["displayName"] = "ChoroplethLayer";
@@ -1,6 +1,5 @@
1
1
  import type { ChoroplethLayerTooltipHandler } from '../../types/tooltip.js';
2
2
  export interface ChoroplethLayerTooltipProps {
3
- layerId: string;
4
3
  tooltipTemplate?: ChoroplethLayerTooltipHandler;
5
4
  }
6
5
  export declare const ChoroplethLayerTooltip: {