@dynatrace/strato-geo 3.6.0 → 3.7.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.
- package/esm/map/MapView.js +42 -34
- package/esm/map/MapView.js.map +2 -2
- package/esm/map/components/BubbleLayer/BubbleCircleLayer.js +2 -0
- package/esm/map/components/BubbleLayer/BubbleCircleLayer.js.map +2 -2
- package/esm/map/components/BubbleLayer/BubbleLayer.js +4 -1
- package/esm/map/components/BubbleLayer/BubbleLayer.js.map +2 -2
- package/esm/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.js +5 -5
- package/esm/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js +5 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayerTooltip.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +3 -1
- package/esm/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.js +6 -5
- package/esm/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayer.js +1 -1
- package/esm/map/components/ConnectionLayer/ConnectionLayer.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js +3 -0
- package/esm/map/components/ConnectionLayer/ConnectionLayerLine.js.map +2 -2
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js +7 -9
- package/esm/map/components/ConnectionLayer/ConnectionLayerTooltip.js.map +2 -2
- package/esm/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.js +20 -18
- package/esm/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.js.map +2 -2
- package/esm/map/components/DotLayer/DotLayer.js +4 -1
- package/esm/map/components/DotLayer/DotLayer.js.map +2 -2
- package/esm/map/components/DotLayer/DotLayerTooltip.js.map +2 -2
- package/esm/map/components/DotLayer/utils/parse-dot-data-to-geo-json.js +5 -5
- package/esm/map/components/DotLayer/utils/parse-dot-data-to-geo-json.js.map +2 -2
- package/esm/map/components/MapContent.js +22 -12
- package/esm/map/components/MapContent.js.map +2 -2
- package/esm/map/contexts/geo-data-lookup.context.js +8 -0
- package/esm/map/contexts/geo-data-lookup.context.js.map +7 -0
- package/esm/map/hooks/use-active-interaction.js +59 -43
- package/esm/map/hooks/use-active-interaction.js.map +2 -2
- package/esm/map/hooks/use-attach-image-from-icon.js +4 -2
- package/esm/map/hooks/use-attach-image-from-icon.js.map +2 -2
- package/esm/map/hooks/use-hover-interaction.js +59 -41
- package/esm/map/hooks/use-hover-interaction.js.map +2 -2
- package/esm/map/hooks/use-layer-before-id.js +24 -0
- package/esm/map/hooks/use-layer-before-id.js.map +7 -0
- package/esm/map/hooks/use-map-runtime-error.js +93 -0
- package/esm/map/hooks/use-map-runtime-error.js.map +7 -0
- package/esm/map/hooks/use-overlay-events.js +11 -2
- package/esm/map/hooks/use-overlay-events.js.map +2 -2
- package/esm/map/hooks/use-webgl-context-error.js +2 -1
- package/esm/map/hooks/use-webgl-context-error.js.map +2 -2
- package/esm/map/index.js.map +1 -1
- package/esm/map/slots/Tooltip.js.map +2 -2
- package/esm/map/utils/attach-image-from-shape.js +4 -2
- package/esm/map/utils/attach-image-from-shape.js.map +2 -2
- package/esm/map/utils/extract-layers-data.js +24 -15
- package/esm/map/utils/extract-layers-data.js.map +2 -2
- package/esm/map/utils/is-browser-firefox.js +7 -0
- package/esm/map/utils/is-browser-firefox.js.map +7 -0
- package/esm/map/utils/parse-tooltip-data.js +22 -7
- package/esm/map/utils/parse-tooltip-data.js.map +2 -2
- package/map/MapView.js +42 -34
- package/map/components/BubbleLayer/BubbleCircleLayer.d.ts +2 -1
- package/map/components/BubbleLayer/BubbleCircleLayer.js +2 -0
- package/map/components/BubbleLayer/BubbleLayer.js +4 -1
- package/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.d.ts +3 -1
- package/map/components/BubbleLayer/utils/parse-bubble-data-to-geo-json.js +5 -5
- package/map/components/ChoroplethLayer/ChoroplethLayer.js +5 -2
- package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.d.ts +1 -0
- package/map/components/ChoroplethLayer/ChoroplethOutlineLayer.js +3 -1
- package/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.d.ts +3 -1
- package/map/components/ChoroplethLayer/utils/parse-region-data-to-geo-json.js +6 -5
- package/map/components/ConnectionLayer/ConnectionLayer.js +1 -1
- package/map/components/ConnectionLayer/ConnectionLayerLine.js +3 -0
- package/map/components/ConnectionLayer/ConnectionLayerTooltip.js +7 -9
- package/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.d.ts +3 -1
- package/map/components/ConnectionLayer/utils/parse-connection-data-to-geo-json.js +20 -18
- package/map/components/DotLayer/DotLayer.js +4 -1
- package/map/components/DotLayer/utils/parse-dot-data-to-geo-json.d.ts +3 -1
- package/map/components/DotLayer/utils/parse-dot-data-to-geo-json.js +5 -5
- package/map/components/MapContent.js +21 -12
- package/map/contexts/geo-data-lookup.context.d.ts +9 -0
- package/map/{components/ConnectionLayer/utils/restore-null-props.js → contexts/geo-data-lookup.context.js} +8 -9
- package/map/hooks/use-active-interaction.d.ts +8 -1
- package/map/hooks/use-active-interaction.js +58 -42
- package/map/hooks/use-attach-image-from-icon.js +4 -2
- package/map/hooks/use-hover-interaction.d.ts +6 -2
- package/map/hooks/use-hover-interaction.js +52 -39
- package/map/hooks/use-layer-before-id.d.ts +13 -0
- package/map/hooks/{use-map-mouse-move.js → use-layer-before-id.js} +20 -15
- package/map/hooks/use-map-runtime-error.d.ts +34 -0
- package/map/hooks/use-map-runtime-error.js +112 -0
- package/map/hooks/use-overlay-events.js +11 -2
- package/map/hooks/use-webgl-context-error.js +2 -1
- package/map/slots/Tooltip.d.ts +2 -0
- package/map/types/connection-layer.d.ts +1 -8
- package/map/types/tooltip.d.ts +1 -0
- package/map/utils/attach-image-from-shape.js +4 -2
- package/map/utils/extract-layers-data.d.ts +2 -0
- package/map/utils/extract-layers-data.js +24 -15
- package/map/utils/is-browser-firefox.d.ts +5 -0
- package/map/utils/is-browser-firefox.js +26 -0
- package/map/utils/parse-tooltip-data.d.ts +11 -3
- package/map/utils/parse-tooltip-data.js +22 -7
- package/package.json +2 -2
- package/esm/map/components/ConnectionLayer/utils/restore-null-props.js +0 -9
- package/esm/map/components/ConnectionLayer/utils/restore-null-props.js.map +0 -7
- package/esm/map/hooks/use-map-mouse-move.js +0 -19
- package/esm/map/hooks/use-map-mouse-move.js.map +0 -7
- package/map/components/ConnectionLayer/utils/restore-null-props.d.ts +0 -2
- package/map/hooks/use-map-mouse-move.d.ts +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/hooks/use-overlay-events.ts"],
|
|
4
|
-
"sourcesContent": ["import type { MapLayerMouseEvent } from 'maplibre-gl';\n\nimport {\n _useOverlayTooltipReducer as useTooltipReducer,\n _useOverlayTooltipStore as useOverlayTooltipStore,\n _useOverlayChart as useOverlayChart,\n type _OverlayTooltipGeometryTypes as GeometryTypes,\n} from '@dynatrace/strato-components/charts';\n\nimport { useSetStateOverlay, useSetState } from '../store/store.js';\nimport { buildGeoTooltipState } from '../utils/build-geo-tooltip-state.js';\nimport { extractDataFromEvent } from '../utils/parse-tooltip-data.js';\n\nconst layerIdToGeometry = (layerId: string | undefined): GeometryTypes => {\n if (layerId?.includes('bubble')) {\n return 'geoBubble';\n }\n if (layerId?.includes('choropleth')) {\n return 'geoChoropleth';\n }\n if (layerId?.includes('connection')) {\n return 'geoConnection';\n }\n return 'geoDot';\n};\n\nexport const useOverlayEvents = () => {\n const setOverlayState = useSetStateOverlay();\n const setState = useSetState();\n const dispatch = useTooltipReducer();\n const store = useOverlayTooltipStore();\n const overlay = useOverlayChart();\n\n const getAbsolutePosition = (event: MapLayerMouseEvent) => {\n return {\n x: Math.round(event.originalEvent.clientX),\n y: Math.round(event.originalEvent.clientY),\n };\n };\n\n const setTooltipMarker = (\n hoveredLayerId: string | undefined,\n location: { lng: number; lat: number } | undefined,\n ) => {\n setState((prev) => ({\n ...prev,\n tooltip: {\n ...prev.tooltip,\n hoveredLayerId,\n location: location as typeof prev.tooltip.location,\n },\n }));\n };\n\n const hideTooltip = () => {\n dispatch({ type: 'RESET_TOOLTIP' })();\n setTooltipMarker(undefined, undefined);\n };\n\n const handleMouseEnter = () => {\n setOverlayState({ mouseInBounds: true });\n };\n\n const handleMouseMove = (event: MapLayerMouseEvent) => {\n if (event.features?.length) {\n const currentState = store.getState();\n\n if (currentState.pinned) {\n return;\n }\n\n const { data, hoveredLayerId } = extractDataFromEvent(event);\n\n overlay.clear();\n\n setTooltipMarker(hoveredLayerId, event.lngLat);\n\n const pos = getAbsolutePosition(event);\n store.setState(\n buildGeoTooltipState({\n absoluteX: pos.x,\n absoluteY: pos.y,\n relativeX: Math.round(event.point.x),\n relativeY: Math.round(event.point.y),\n pinned: false,\n geometry: layerIdToGeometry(hoveredLayerId),\n metadata: data,\n }),\n );\n } else {\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n }\n };\n\n const handleMouseLeave = () => {\n setOverlayState({ mouseInBounds: false });\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n };\n\n const handleMouseClick = (event: MapLayerMouseEvent) => {\n const { data, featureId, hoveredLayerId } = extractDataFromEvent(event);\n\n if (!featureId) {\n hideTooltip();\n return;\n }\n\n if (!hoveredLayerId) {\n hideTooltip();\n return;\n }\n\n overlay.clear();\n\n setTooltipMarker(hoveredLayerId, event.lngLat);\n\n const pos = getAbsolutePosition(event);\n store.setState(\n buildGeoTooltipState({\n absoluteX: pos.x,\n absoluteY: pos.y,\n relativeX: Math.round(event.point.x),\n relativeY: Math.round(event.point.y),\n pinned: true,\n geometry: layerIdToGeometry(hoveredLayerId),\n metadata: data,\n }),\n );\n };\n\n const hideTooltipIfNotPinned = () => {\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n };\n\n return {\n handleMouseEnter,\n handleMouseMove,\n handleMouseLeave,\n handleMouseClick,\n handleZoom: hideTooltipIfNotPinned,\n handleDrag: hideTooltipIfNotPinned,\n };\n};\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useContext } from 'react';\n\nimport {\n _useOverlayTooltipReducer as useTooltipReducer,\n _useOverlayTooltipStore as useOverlayTooltipStore,\n _useOverlayChart as useOverlayChart,\n type _OverlayTooltipGeometryTypes as GeometryTypes,\n} from '@dynatrace/strato-components/charts';\n\nimport { GeoDataLookupContext } from '../contexts/geo-data-lookup.context.js';\nimport { useSetStateOverlay, useSetState } from '../store/store.js';\nimport { buildGeoTooltipState } from '../utils/build-geo-tooltip-state.js';\nimport { extractDataFromEvent } from '../utils/parse-tooltip-data.js';\n\nconst layerIdToGeometry = (layerId: string | undefined): GeometryTypes => {\n if (layerId?.includes('bubble')) {\n return 'geoBubble';\n }\n if (layerId?.includes('choropleth')) {\n return 'geoChoropleth';\n }\n if (layerId?.includes('connection')) {\n return 'geoConnection';\n }\n return 'geoDot';\n};\n\nexport const useOverlayEvents = () => {\n const dataLookupRegistry = useContext(GeoDataLookupContext);\n const setOverlayState = useSetStateOverlay();\n const setState = useSetState();\n const dispatch = useTooltipReducer();\n const store = useOverlayTooltipStore();\n const overlay = useOverlayChart();\n\n const getAbsolutePosition = (event: MapLayerMouseEvent) => {\n return {\n x: Math.round(event.originalEvent.clientX),\n y: Math.round(event.originalEvent.clientY),\n };\n };\n\n const setTooltipMarker = (\n hoveredLayerId: string | undefined,\n location: { lng: number; lat: number } | undefined,\n ) => {\n setState((prev) => ({\n ...prev,\n tooltip: {\n ...prev.tooltip,\n hoveredLayerId,\n location: location as typeof prev.tooltip.location,\n },\n }));\n };\n\n const hideTooltip = () => {\n dispatch({ type: 'RESET_TOOLTIP' })();\n setTooltipMarker(undefined, undefined);\n };\n\n const handleMouseEnter = () => {\n setOverlayState({ mouseInBounds: true });\n };\n\n const handleMouseMove = (event: MapLayerMouseEvent) => {\n if (event.features?.length) {\n const currentState = store.getState();\n\n if (currentState.pinned) {\n return;\n }\n\n const { data, hoveredLayerId } = extractDataFromEvent(\n event,\n dataLookupRegistry,\n );\n\n overlay.clear();\n\n setTooltipMarker(hoveredLayerId, event.lngLat);\n\n const pos = getAbsolutePosition(event);\n store.setState(\n buildGeoTooltipState({\n absoluteX: pos.x,\n absoluteY: pos.y,\n relativeX: Math.round(event.point.x),\n relativeY: Math.round(event.point.y),\n pinned: false,\n geometry: layerIdToGeometry(hoveredLayerId),\n metadata: data,\n }),\n );\n } else {\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n }\n };\n\n const handleMouseLeave = () => {\n setOverlayState({ mouseInBounds: false });\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n };\n\n const handleMouseClick = (event: MapLayerMouseEvent) => {\n const { data, featureId, hoveredLayerId } = extractDataFromEvent(\n event,\n dataLookupRegistry,\n );\n\n if (!featureId) {\n hideTooltip();\n return;\n }\n\n if (!hoveredLayerId) {\n hideTooltip();\n return;\n }\n\n overlay.clear();\n\n setTooltipMarker(hoveredLayerId, event.lngLat);\n\n const pos = getAbsolutePosition(event);\n store.setState(\n buildGeoTooltipState({\n absoluteX: pos.x,\n absoluteY: pos.y,\n relativeX: Math.round(event.point.x),\n relativeY: Math.round(event.point.y),\n pinned: true,\n geometry: layerIdToGeometry(hoveredLayerId),\n metadata: data,\n }),\n );\n };\n\n const hideTooltipIfNotPinned = () => {\n const currentState = store.getState();\n if (!currentState.pinned) {\n hideTooltip();\n }\n };\n\n return {\n handleMouseEnter,\n handleMouseMove,\n handleMouseLeave,\n handleMouseClick,\n handleZoom: hideTooltipIfNotPinned,\n handleDrag: hideTooltipIfNotPinned,\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,8 @@ const useWebGLContextError = (onContextLost) => {
|
|
|
7
7
|
if (!canvas) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
const handleContextLost = () => {
|
|
10
|
+
const handleContextLost = (event) => {
|
|
11
|
+
event.preventDefault();
|
|
11
12
|
onContextLost?.();
|
|
12
13
|
};
|
|
13
14
|
canvas.addEventListener("webglcontextlost", handleContextLost);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/hooks/use-webgl-context-error.ts"],
|
|
4
|
-
"sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { useEffect } from 'react';\n\n/**\n * Hook to detect WebGL context loss events.\n * Browsers have a limit of active WebGL canvas contexts.\n */\nexport const useWebGLContextError = (onContextLost?: () => void) => {\n const { current: mapRef } = useMap();\n\n useEffect(() => {\n const canvas = mapRef?.getMap()?.getCanvas();\n if (!canvas) {\n return;\n }\n\n const handleContextLost = () => {\n onContextLost?.();\n };\n\n canvas.addEventListener('webglcontextlost', handleContextLost);\n\n return () => {\n canvas.removeEventListener('webglcontextlost', handleContextLost);\n };\n }, [mapRef, onContextLost]);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAMnB,MAAM,uBAAuB,CAAC,kBAA+B;AAClE,QAAM,EAAE,SAAS,OAAO,IAAI,OAAO;AAEnC,YAAU,MAAM;AACd,UAAM,SAAS,QAAQ,OAAO,GAAG,UAAU;AAC3C,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,UAAM,oBAAoB,
|
|
4
|
+
"sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { useEffect } from 'react';\n\n/**\n * Hook to detect WebGL context loss events.\n * Browsers have a limit of active WebGL canvas contexts.\n */\nexport const useWebGLContextError = (onContextLost?: () => void) => {\n const { current: mapRef } = useMap();\n\n useEffect(() => {\n const canvas = mapRef?.getMap()?.getCanvas();\n if (!canvas) {\n return;\n }\n\n const handleContextLost = (event: Event) => {\n // Prevent the browser default so it will attempt to restore the context\n // via a subsequent `webglcontextrestored` event.\n event.preventDefault();\n onContextLost?.();\n };\n\n canvas.addEventListener('webglcontextlost', handleContextLost);\n\n return () => {\n canvas.removeEventListener('webglcontextlost', handleContextLost);\n };\n }, [mapRef, onContextLost]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAMnB,MAAM,uBAAuB,CAAC,kBAA+B;AAClE,QAAM,EAAE,SAAS,OAAO,IAAI,OAAO;AAEnC,YAAU,MAAM;AACd,UAAM,SAAS,QAAQ,OAAO,GAAG,UAAU;AAC3C,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,UAAM,oBAAoB,CAAC,UAAiB;AAG1C,YAAM,eAAe;AACrB,sBAAgB;AAAA,IAClB;AAEA,WAAO,iBAAiB,oBAAoB,iBAAiB;AAE7D,WAAO,MAAM;AACX,aAAO,oBAAoB,oBAAoB,iBAAiB;AAAA,IAClE;AAAA,EACF,GAAG,CAAC,QAAQ,aAAa,CAAC;AAC5B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/esm/map/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/map/index.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-deprecated -- DEPRECATION: [APPDEV-17834] Re-exports of legacy geo Tooltip API. BREAKING-CHANGE: migrate to ChartTooltip before next major. */\nexport { ChartInteractions } from './slots/ChartInteractions.js';\nexport { MapView } from './MapView.js';\nexport { ConnectionLayer } from './slots/ConnectionLayer.js';\nexport { DotLayer } from './slots/DotLayer.js';\nexport { BubbleLayer } from './slots/BubbleLayer.js';\nexport { BaseLayer } from './slots/BaseLayer.js';\nexport { ChoroplethLayer } from './slots/ChoroplethLayer.js';\nexport { Tooltip, TooltipAtoms } from './slots/Tooltip.js';\nexport { DownloadCSV } from './slots/DownloadCSV.js';\n\nexport type {\n MapViewProps,\n MapViewBaseProps,\n MapViewUncontrolledProps,\n MapViewControlledProps,\n DisallowAll,\n ViewState,\n MapViewRef,\n} from './types/map-view.js';\n\nexport type { BaseLayerProps } from './types/base-layer.js';\n\nexport type { MapViewZoomSlotProps } from './slots/Zoom.js';\n\nexport type {\n Connection,\n ConnectionColorProps,\n ConnectionLayerBaseProps,\n ConnectionLayerProps,\n CurvedLine,\n} from './types/connection-layer.js';\n\nexport type { DotLayerBaseProps, DotLayerProps } from './types/dot-layer.js';\n\nexport type {\n BubbleLayerBaseProps,\n BubbleLayerProps,\n ScaleNoneProps,\n ScaleRadiusProps,\n} from './types/bubble-layer.js';\n\nexport type {\n ChoroplethLayerBaseProps,\n ChoroplethLayerProps,\n} from './types/choropleth-layer.js';\n\nexport type { Location } from './types/location.js';\nexport type { MapShape } from './types/shapes.js';\nexport type {\n ChartInteractionsProps,\n MapToolbarSlotProps,\n} from './types/toolbar.js';\nexport type { ErrorStateSlotProps } from './slots/states/ErrorStateSlot.js';\n\nexport type {\n BaseLegendProps,\n CategoricalLegendProps,\n SequentialLegendProps,\n ThresholdLegendProps,\n} from './types/legend.js';\n\nexport type {\n LocationColorProps,\n LegendColorLayerProps,\n ChoroplethCustomColorProps,\n} from './types/coloring.js';\n\nexport { SequentialLegend } from './slots/SequentialLegend.js';\nexport { ThresholdLegend } from './slots/ThresholdLegend.js';\nexport { CategoricalLegend } from './slots/CategoricalLegend.js';\n\nexport type {\n BubbleLayerTooltipHandler,\n BubbleLayerTooltipHandlerProps,\n DotLayerTooltipHandler,\n DotLayerTooltipHandlerProps,\n ConnectionLayerTooltipHandler,\n ConnectionLayerTooltipHandlerProps,\n ChoroplethLayerTooltipHandlerProps,\n ChoroplethLayerTooltipHandler,\n ChartTooltip,\n DotLayerTooltipData,\n BubbleLayerTooltipData,\n ConnectionLayerTooltipData,\n ChoroplethLayerTooltipData,\n} from './types/tooltip.js';\n\nexport { getAllCountries } from './utils/get-all-countries.js';\n\nexport { MapViewProvider } from './providers/map-view.provider.js';\nexport type { MapViewProviderProps } from './types/map-view-provider.js';\n"],
|
|
5
5
|
"mappings": "AACA,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,SAAS,oBAAoB;AACtC,SAAS,mBAAmB;AA2D5B,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAkBlC,SAAS,uBAAuB;AAEhC,SAAS,uBAAuB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/slots/Tooltip.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-deprecated -- DEPRECATION: [APPDEV-17834] Legacy geo Tooltip slot. BREAKING-CHANGE: migrate to ChartTooltip before next major. */\nimport type { _ChartTooltipAtomsType as ChartTooltipAtomsType } from '@dynatrace/strato-components/charts';\nimport {\n _ChartTooltipSlots as ChartTooltipSlots,\n _ChartTooltipAtoms as ChartTooltipAtoms,\n _ChartTooltipTemplate as ChartTooltipTemplate,\n} from '@dynatrace/strato-components/charts';\n\nimport type { ChartTooltip } from '../types/tooltip.js';\n\n/**\n * Tooltip is responsible for exposing the\n * ChartTooltip props, such as, sections, to the consumer\n * @public\n * @deprecated Use `ChartTooltip` from `@dynatrace/strato-components/charts` instead. Removal: APPDEV-17834\n */\nexport const Tooltip: ChartTooltip = {\n ...ChartTooltipSlots,\n ...ChartTooltipTemplate,\n};\n\n/**\n * TooltipAtoms is responsible for exposing the\n * ChartTooltip atoms.\n * @public\n * @deprecated Use `ChartTooltip` from `@dynatrace/strato-components/charts` instead. Removal: APPDEV-17834\n */\nexport const TooltipAtoms: ChartTooltipAtomsType = { ...ChartTooltipAtoms };\n"],
|
|
5
|
+
"mappings": "AAEA;AAAA,EACE,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,OACpB;AAUA,MAAM,UAAwB;AAAA,EACnC,GAAG;AAAA,EACH,GAAG;AACL;AAQO,MAAM,eAAsC,EAAE,GAAG,kBAAkB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,20 +2,22 @@ import { attachImageToMap } from "./attach-image-to-map.js";
|
|
|
2
2
|
import { createBitmapConfigOptions } from "./create-bitmap-config-options.js";
|
|
3
3
|
import { getDataUri } from "./get-data-uri.js";
|
|
4
4
|
import { DEFAULT_INPUT_ICON_SIZE } from "../constants.js";
|
|
5
|
+
import { isFirefox } from "./is-browser-firefox.js";
|
|
5
6
|
import { getShape } from "../shapes/shape-picker.js";
|
|
6
7
|
const attachImageFromShape = (map, shape, name, outputSize) => {
|
|
7
8
|
const pickedShape = getShape(shape);
|
|
8
9
|
const stringUrl = getDataUri(encodeURIComponent(pickedShape));
|
|
9
10
|
const img = new Image(DEFAULT_INPUT_ICON_SIZE, DEFAULT_INPUT_ICON_SIZE);
|
|
10
11
|
img.addEventListener("load", () => {
|
|
11
|
-
createImageBitmap(
|
|
12
|
+
const bitmapPromise = isFirefox() ? createImageBitmap(img, createBitmapConfigOptions(outputSize)) : createImageBitmap(
|
|
12
13
|
img,
|
|
13
14
|
0,
|
|
14
15
|
0,
|
|
15
16
|
DEFAULT_INPUT_ICON_SIZE,
|
|
16
17
|
DEFAULT_INPUT_ICON_SIZE,
|
|
17
18
|
createBitmapConfigOptions(outputSize)
|
|
18
|
-
)
|
|
19
|
+
);
|
|
20
|
+
bitmapPromise.then((bitmap) => {
|
|
19
21
|
if (!map) {
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/utils/attach-image-from-shape.ts"],
|
|
4
|
-
"sourcesContent": ["import type { MapRef } from '@vis.gl/react-maplibre';\n\nimport { attachImageToMap } from './attach-image-to-map.js';\nimport { createBitmapConfigOptions } from './create-bitmap-config-options.js';\nimport { getDataUri } from './get-data-uri.js';\nimport { DEFAULT_INPUT_ICON_SIZE } from '../constants.js';\nimport { getShape } from '../shapes/shape-picker.js';\nimport type { MapShape } from '../types/shapes.js';\n\nexport const attachImageFromShape = (\n map: MapRef,\n shape: MapShape,\n name: string,\n outputSize?: number,\n) => {\n const pickedShape = getShape(shape);\n const stringUrl = getDataUri(encodeURIComponent(pickedShape));\n const img = new Image(DEFAULT_INPUT_ICON_SIZE, DEFAULT_INPUT_ICON_SIZE);\n img.addEventListener('load', () => {\n createImageBitmap(\n img,\n
|
|
5
|
-
"mappings": "AAEA,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,SAAS,+BAA+B;AACxC,SAAS,gBAAgB;AAGlB,MAAM,uBAAuB,CAClC,KACA,OACA,MACA,eACG;AACH,QAAM,cAAc,SAAS,KAAK;AAClC,QAAM,YAAY,WAAW,mBAAmB,WAAW,CAAC;AAC5D,QAAM,MAAM,IAAI,MAAM,yBAAyB,uBAAuB;AACtE,MAAI,iBAAiB,QAAQ,MAAM;
|
|
4
|
+
"sourcesContent": ["import type { MapRef } from '@vis.gl/react-maplibre';\n\nimport { attachImageToMap } from './attach-image-to-map.js';\nimport { createBitmapConfigOptions } from './create-bitmap-config-options.js';\nimport { getDataUri } from './get-data-uri.js';\nimport { DEFAULT_INPUT_ICON_SIZE } from '../constants.js';\nimport { isFirefox } from './is-browser-firefox.js';\nimport { getShape } from '../shapes/shape-picker.js';\nimport type { MapShape } from '../types/shapes.js';\n\nexport const attachImageFromShape = (\n map: MapRef,\n shape: MapShape,\n name: string,\n outputSize?: number,\n) => {\n const pickedShape = getShape(shape);\n const stringUrl = getDataUri(encodeURIComponent(pickedShape));\n const img = new Image(DEFAULT_INPUT_ICON_SIZE, DEFAULT_INPUT_ICON_SIZE);\n img.addEventListener('load', () => {\n // passing an explicit source rect to createImageBitmap\n // clips SVG icons on Firefox. Drop the rect on Firefox only \u2014 other\n // browsers keep the original path.\n const bitmapPromise = isFirefox()\n ? createImageBitmap(img, createBitmapConfigOptions(outputSize))\n : createImageBitmap(\n img,\n 0,\n 0,\n DEFAULT_INPUT_ICON_SIZE,\n DEFAULT_INPUT_ICON_SIZE,\n createBitmapConfigOptions(outputSize),\n );\n bitmapPromise.then((bitmap) => {\n if (!map) {\n return;\n }\n attachImageToMap(map, bitmap, name);\n });\n });\n img.src = stringUrl;\n};\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,SAAS,+BAA+B;AACxC,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAGlB,MAAM,uBAAuB,CAClC,KACA,OACA,MACA,eACG;AACH,QAAM,cAAc,SAAS,KAAK;AAClC,QAAM,YAAY,WAAW,mBAAmB,WAAW,CAAC;AAC5D,QAAM,MAAM,IAAI,MAAM,yBAAyB,uBAAuB;AACtE,MAAI,iBAAiB,QAAQ,MAAM;AAIjC,UAAM,gBAAgB,UAAU,IAC5B,kBAAkB,KAAK,0BAA0B,UAAU,CAAC,IAC5D;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,0BAA0B,UAAU;AAAA,IACtC;AACJ,kBAAc,KAAK,CAAC,WAAW;AAC7B,UAAI,CAAC,KAAK;AACR;AAAA,MACF;AACA,uBAAiB,KAAK,QAAQ,IAAI;AAAA,IACpC,CAAC;AAAA,EACH,CAAC;AACD,MAAI,MAAM;AACZ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,17 +24,20 @@ const extractLayersData = (children, valueAccessors) => {
|
|
|
24
24
|
let flattenData = [];
|
|
25
25
|
const categoriesSet = /* @__PURE__ */ new Set();
|
|
26
26
|
let legendDomain = [Infinity, -Infinity];
|
|
27
|
+
const dataLookupRegistry = /* @__PURE__ */ new Map();
|
|
27
28
|
Children.forEach(children, (child) => {
|
|
28
29
|
if (isComponent(child, BubbleLayer) || isComponent(child, DotLayer)) {
|
|
29
|
-
const { data } = child.props;
|
|
30
|
-
|
|
30
|
+
const { data, layerId } = child.props;
|
|
31
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
32
|
+
data.forEach((dataPoint, index) => {
|
|
33
|
+
lookup.set(index, dataPoint);
|
|
31
34
|
const extendedDataPoint = {
|
|
32
35
|
...dataPoint,
|
|
33
|
-
"layer-name":
|
|
36
|
+
"layer-name": layerId
|
|
34
37
|
};
|
|
35
38
|
const category = addCategory(
|
|
36
39
|
extendedDataPoint,
|
|
37
|
-
valueAccessors.get(
|
|
40
|
+
valueAccessors.get(layerId)
|
|
38
41
|
);
|
|
39
42
|
category && categoriesSet.add(category);
|
|
40
43
|
if (typeof category === "number") {
|
|
@@ -42,14 +45,14 @@ const extractLayersData = (children, valueAccessors) => {
|
|
|
42
45
|
}
|
|
43
46
|
flattenData = flattenData.concat(extendedDataPoint);
|
|
44
47
|
});
|
|
48
|
+
dataLookupRegistry.set(`source-${layerId}`, lookup);
|
|
45
49
|
} else if (isComponent(child, ConnectionLayer)) {
|
|
46
|
-
const { data } = child.props;
|
|
50
|
+
const { data, layerId } = child.props;
|
|
51
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
47
52
|
data.forEach((connection, connectionIndex) => {
|
|
53
|
+
lookup.set(connectionIndex, connection);
|
|
48
54
|
if (connection.path.length >= 2) {
|
|
49
|
-
const category = addCategory(
|
|
50
|
-
connection,
|
|
51
|
-
valueAccessors.get(child.props.layerId)
|
|
52
|
-
);
|
|
55
|
+
const category = addCategory(connection, valueAccessors.get(layerId));
|
|
53
56
|
category && categoriesSet.add(category);
|
|
54
57
|
if (typeof category === "number") {
|
|
55
58
|
legendDomain = updateDomain(legendDomain, category);
|
|
@@ -59,24 +62,28 @@ const extractLayersData = (children, valueAccessors) => {
|
|
|
59
62
|
...path,
|
|
60
63
|
"connection-name": `connection-${connectionIndex + 1}`,
|
|
61
64
|
"connection-item-index": pathIndex,
|
|
62
|
-
"layer-name":
|
|
65
|
+
"layer-name": layerId
|
|
63
66
|
};
|
|
64
67
|
flattenData.push(parsedPath);
|
|
65
68
|
});
|
|
66
69
|
}
|
|
67
70
|
});
|
|
71
|
+
dataLookupRegistry.set(`source-${layerId}`, lookup);
|
|
68
72
|
} else if (isComponent(child, ChoroplethLayer)) {
|
|
69
|
-
const { data, regionAccessor } = child.props;
|
|
70
|
-
|
|
73
|
+
const { data, regionAccessor, layerId } = child.props;
|
|
74
|
+
const sourceId = layerId.replace("layer", "source");
|
|
75
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
76
|
+
data.forEach((dataEntry, index) => {
|
|
77
|
+
lookup.set(index, dataEntry);
|
|
71
78
|
const region = isString(regionAccessor) ? dataEntry[regionAccessor] : regionAccessor(dataEntry);
|
|
72
79
|
const choroplethLayerData = {
|
|
73
80
|
...dataEntry,
|
|
74
81
|
region,
|
|
75
|
-
"layer-name":
|
|
82
|
+
"layer-name": layerId
|
|
76
83
|
};
|
|
77
84
|
const category = addCategory(
|
|
78
85
|
choroplethLayerData,
|
|
79
|
-
valueAccessors.get(
|
|
86
|
+
valueAccessors.get(layerId)
|
|
80
87
|
);
|
|
81
88
|
category && categoriesSet.add(category);
|
|
82
89
|
if (typeof category === "number") {
|
|
@@ -84,12 +91,14 @@ const extractLayersData = (children, valueAccessors) => {
|
|
|
84
91
|
}
|
|
85
92
|
flattenData.push(choroplethLayerData);
|
|
86
93
|
});
|
|
94
|
+
dataLookupRegistry.set(sourceId, lookup);
|
|
87
95
|
}
|
|
88
96
|
});
|
|
89
97
|
return {
|
|
90
98
|
flattenData,
|
|
91
99
|
categories: [...categoriesSet],
|
|
92
|
-
legendDomain
|
|
100
|
+
legendDomain,
|
|
101
|
+
dataLookupRegistry
|
|
93
102
|
};
|
|
94
103
|
};
|
|
95
104
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/utils/extract-layers-data.ts"],
|
|
4
|
-
"sourcesContent": ["import { isString } from 'lodash-es';\nimport { Children, type ReactNode } from 'react';\n\nimport { isComponent } from './is-component.js';\nimport { BubbleLayer } from '../components/BubbleLayer/BubbleLayer.js';\nimport { ChoroplethLayer } from '../components/ChoroplethLayer/ChoroplethLayer.js';\nimport { ConnectionLayer } from '../components/ConnectionLayer/ConnectionLayer.js';\nimport { DotLayer } from '../components/DotLayer/DotLayer.js';\n\nconst addCategory = (\n extendedDataPoint: Record<string, unknown>,\n valueAccessor?: string,\n) => {\n if (valueAccessor && extendedDataPoint[valueAccessor]) {\n return extendedDataPoint[valueAccessor];\n }\n};\n\nconst updateDomain = (\n domain: [number, number],\n value: number,\n): [number, number] => {\n let [min, max] = domain;\n if (value < min) {\n min = value;\n }\n if (value > max) {\n max = value;\n }\n return [min, max];\n};\n\n/**\n * Extract layers data\n * @param children - MapView children\n * @param valueAccessors - MapView Layer valueAccessor\n * @returns flattened data array\n */\nexport const extractLayersData = (\n children: ReactNode,\n valueAccessors: Map<string, string>,\n) => {\n let flattenData: Record<string, unknown>[] = [];\n const categoriesSet = new Set<string>();\n let legendDomain: [number, number] = [Infinity, -Infinity];\n\n Children.forEach(children, (child) => {\n if (isComponent(child, BubbleLayer) || isComponent(child, DotLayer)) {\n const { data } = child.props;\n\n data.forEach((dataPoint) => {\n const extendedDataPoint = {\n ...dataPoint,\n 'layer-name':
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,gBAAgC;AAEzC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import { isString } from 'lodash-es';\nimport { Children, type ReactNode } from 'react';\n\nimport { isComponent } from './is-component.js';\nimport { BubbleLayer } from '../components/BubbleLayer/BubbleLayer.js';\nimport { ChoroplethLayer } from '../components/ChoroplethLayer/ChoroplethLayer.js';\nimport { ConnectionLayer } from '../components/ConnectionLayer/ConnectionLayer.js';\nimport { DotLayer } from '../components/DotLayer/DotLayer.js';\nimport type {\n GeoDataLookup,\n GeoDataLookupRegistry,\n} from '../contexts/geo-data-lookup.context.js';\n\nconst addCategory = (\n extendedDataPoint: Record<string, unknown>,\n valueAccessor?: string,\n) => {\n if (valueAccessor && extendedDataPoint[valueAccessor]) {\n return extendedDataPoint[valueAccessor];\n }\n};\n\nconst updateDomain = (\n domain: [number, number],\n value: number,\n): [number, number] => {\n let [min, max] = domain;\n if (value < min) {\n min = value;\n }\n if (value > max) {\n max = value;\n }\n return [min, max];\n};\n\n/**\n * Extract layers data\n * @param children - MapView children\n * @param valueAccessors - MapView Layer valueAccessor\n * @returns flattened data array\n */\nexport const extractLayersData = (\n children: ReactNode,\n valueAccessors: Map<string, string>,\n) => {\n let flattenData: Record<string, unknown>[] = [];\n const categoriesSet = new Set<string>();\n let legendDomain: [number, number] = [Infinity, -Infinity];\n const dataLookupRegistry: GeoDataLookupRegistry = new Map();\n\n Children.forEach(children, (child) => {\n if (isComponent(child, BubbleLayer) || isComponent(child, DotLayer)) {\n const { data, layerId } = child.props;\n const lookup: GeoDataLookup = new Map();\n\n data.forEach((dataPoint, index) => {\n lookup.set(index, dataPoint);\n\n const extendedDataPoint = {\n ...dataPoint,\n 'layer-name': layerId,\n };\n\n const category = addCategory(\n extendedDataPoint,\n valueAccessors.get(layerId),\n );\n\n category && categoriesSet.add(category as string);\n\n if (typeof category === 'number') {\n legendDomain = updateDomain(legendDomain, category);\n }\n\n flattenData = flattenData.concat(extendedDataPoint);\n });\n\n dataLookupRegistry.set(`source-${layerId}`, lookup);\n } else if (isComponent(child, ConnectionLayer)) {\n const { data, layerId } = child.props;\n const lookup: GeoDataLookup = new Map();\n\n data.forEach((connection, connectionIndex) => {\n lookup.set(connectionIndex, connection);\n if (connection.path.length >= 2) {\n const category = addCategory(connection, valueAccessors.get(layerId));\n\n category && categoriesSet.add(category as string);\n\n if (typeof category === 'number') {\n legendDomain = updateDomain(legendDomain, category);\n }\n\n connection.path.forEach((path, pathIndex) => {\n const parsedPath = {\n ...path,\n 'connection-name': `connection-${connectionIndex + 1}`,\n 'connection-item-index': pathIndex,\n 'layer-name': layerId,\n };\n\n flattenData.push(parsedPath);\n });\n }\n });\n\n dataLookupRegistry.set(`source-${layerId}`, lookup);\n } else if (isComponent(child, ChoroplethLayer)) {\n const { data, regionAccessor, layerId } = child.props;\n const sourceId = layerId.replace('layer', 'source');\n const lookup: GeoDataLookup = new Map();\n\n data.forEach((dataEntry, index) => {\n lookup.set(index, dataEntry);\n const region = isString(regionAccessor)\n ? dataEntry[regionAccessor]\n : regionAccessor(dataEntry);\n\n const choroplethLayerData = {\n ...dataEntry,\n region,\n 'layer-name': layerId,\n };\n\n const category = addCategory(\n choroplethLayerData,\n valueAccessors.get(layerId),\n );\n\n category && categoriesSet.add(category as string);\n\n if (typeof category === 'number') {\n legendDomain = updateDomain(legendDomain, category);\n }\n\n flattenData.push(choroplethLayerData);\n });\n\n dataLookupRegistry.set(sourceId, lookup);\n }\n });\n\n return {\n flattenData,\n categories: [...categoriesSet],\n legendDomain,\n dataLookupRegistry,\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/map/utils/is-browser-firefox.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @returns true if is firefox browser, false otherwise\n * @internal\n */\nexport function isFirefox() {\n return (\n typeof navigator !== 'undefined' &&\n navigator.userAgent.toLowerCase().includes('firefox')\n );\n}\n"],
|
|
5
|
+
"mappings": "AAIO,SAAS,YAAY;AAC1B,SACE,OAAO,cAAc,eACrB,UAAU,UAAU,YAAY,EAAE,SAAS,SAAS;AAExD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -16,20 +16,35 @@ const parseFeatureProperties = (featureProperties) => {
|
|
|
16
16
|
}
|
|
17
17
|
return properties;
|
|
18
18
|
};
|
|
19
|
-
const
|
|
19
|
+
const resolveSourceId = (feature) => feature.source ?? feature.layer?.source;
|
|
20
|
+
const restoreDataFromLookup = (sourceId, dataIndex, registry) => {
|
|
21
|
+
if (registry === void 0 || sourceId === void 0 || dataIndex === void 0) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
const lookup = registry.get(sourceId);
|
|
25
|
+
return lookup?.get(dataIndex);
|
|
26
|
+
};
|
|
27
|
+
const parseTooltipData = (features, registry) => {
|
|
20
28
|
const data = [];
|
|
21
29
|
for (const feature of features) {
|
|
22
30
|
const properties = parseFeatureProperties(feature.properties);
|
|
23
|
-
const
|
|
31
|
+
const sourceId = resolveSourceId(feature);
|
|
32
|
+
const { __dataIndex, ...visibleProperties } = properties;
|
|
33
|
+
const dataIndex = typeof __dataIndex === "number" ? __dataIndex : void 0;
|
|
34
|
+
const originalData = restoreDataFromLookup(sourceId, dataIndex, registry);
|
|
35
|
+
const coordinates = feature.geometry.type === "Point" ? {
|
|
36
|
+
longitude: feature.geometry.coordinates[0],
|
|
37
|
+
latitude: feature.geometry.coordinates[1]
|
|
38
|
+
} : {};
|
|
24
39
|
data.push({
|
|
25
|
-
...
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
...visibleProperties,
|
|
41
|
+
...originalData !== void 0 ? { data: originalData } : {},
|
|
42
|
+
...coordinates
|
|
28
43
|
});
|
|
29
44
|
}
|
|
30
45
|
return data;
|
|
31
46
|
};
|
|
32
|
-
const extractDataFromEvent = (event) => {
|
|
47
|
+
const extractDataFromEvent = (event, registry) => {
|
|
33
48
|
if (!event.features?.length) {
|
|
34
49
|
return {};
|
|
35
50
|
}
|
|
@@ -38,7 +53,7 @@ const extractDataFromEvent = (event) => {
|
|
|
38
53
|
const hoveredFeatures = event.features.filter(
|
|
39
54
|
(feature2) => feature2.layer.id === hoveredLayerId
|
|
40
55
|
);
|
|
41
|
-
const data = parseTooltipData(hoveredFeatures);
|
|
56
|
+
const data = parseTooltipData(hoveredFeatures, registry);
|
|
42
57
|
return {
|
|
43
58
|
featureId: `${hoveredLayerId}-${feature.id}`,
|
|
44
59
|
hoveredLayerId,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/utils/parse-tooltip-data.ts"],
|
|
4
|
-
"sourcesContent": ["import type
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { MapGeoJSONFeature, MapLayerMouseEvent } from 'maplibre-gl';\n\nimport type { GeoDataLookupRegistry } from '../contexts/geo-data-lookup.context.js';\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 * Resolves the source ID from a feature, looking at either the\n * `source` property or the `layer.source` property.\n */\nconst resolveSourceId = (feature: MapGeoJSONFeature): string | undefined =>\n feature.source ?? feature.layer?.source;\n\n/**\n * Restores full user data from the data lookup registry using the\n * `__dataIndex` stored in the feature's properties.\n *\n * Returns the original data object if found, or undefined if not.\n */\nconst restoreDataFromLookup = (\n sourceId: string | undefined,\n dataIndex: number | undefined,\n registry: GeoDataLookupRegistry | undefined,\n): unknown => {\n if (\n registry === undefined ||\n sourceId === undefined ||\n dataIndex === undefined\n ) {\n return undefined;\n }\n\n const lookup = registry.get(sourceId);\n return lookup?.get(dataIndex);\n};\n\n/**\n * Extracts useful map features data for the tooltip.\n *\n * When a data lookup registry is provided, the full original data\n * is restored from the `__dataIndex` stored in GeoJSON properties.\n * This allows GeoJSON features to carry only rendering-relevant\n * fields while still providing full data for tooltips.\n *\n * @param features - map features\n * @param registry - optional data lookup registry for restoring full data\n */\nexport const parseTooltipData = (\n features: MapGeoJSONFeature[],\n registry?: GeoDataLookupRegistry,\n) => {\n const data: unknown[] = [];\n\n for (const feature of features) {\n const properties = parseFeatureProperties(feature.properties);\n\n const sourceId = resolveSourceId(feature);\n const { __dataIndex, ...visibleProperties } = properties;\n const dataIndex = typeof __dataIndex === 'number' ? __dataIndex : undefined;\n const originalData = restoreDataFromLookup(sourceId, dataIndex, registry);\n\n const coordinates =\n feature.geometry.type === 'Point'\n ? {\n longitude: feature.geometry.coordinates[0],\n latitude: feature.geometry.coordinates[1],\n }\n : {};\n\n data.push({\n ...visibleProperties,\n ...(originalData !== undefined ? { data: originalData } : {}),\n ...coordinates,\n });\n }\n\n return data;\n};\n\nexport const extractDataFromEvent = (\n event: MapLayerMouseEvent,\n registry?: GeoDataLookupRegistry,\n) => {\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, registry);\n\n return {\n featureId: `${hoveredLayerId}-${feature.id}`,\n hoveredLayerId,\n data,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAQA,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;AAMA,MAAM,kBAAkB,CAAC,YACvB,QAAQ,UAAU,QAAQ,OAAO;AAQnC,MAAM,wBAAwB,CAC5B,UACA,WACA,aACY;AACZ,MACE,aAAa,UACb,aAAa,UACb,cAAc,QACd;AACA,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,SAAS,IAAI,QAAQ;AACpC,SAAO,QAAQ,IAAI,SAAS;AAC9B;AAaO,MAAM,mBAAmB,CAC9B,UACA,aACG;AACH,QAAM,OAAkB,CAAC;AAEzB,aAAW,WAAW,UAAU;AAC9B,UAAM,aAAa,uBAAuB,QAAQ,UAAU;AAE5D,UAAM,WAAW,gBAAgB,OAAO;AACxC,UAAM,EAAE,aAAa,GAAG,kBAAkB,IAAI;AAC9C,UAAM,YAAY,OAAO,gBAAgB,WAAW,cAAc;AAClE,UAAM,eAAe,sBAAsB,UAAU,WAAW,QAAQ;AAExE,UAAM,cACJ,QAAQ,SAAS,SAAS,UACtB;AAAA,MACE,WAAW,QAAQ,SAAS,YAAY,CAAC;AAAA,MACzC,UAAU,QAAQ,SAAS,YAAY,CAAC;AAAA,IAC1C,IACA,CAAC;AAEP,SAAK,KAAK;AAAA,MACR,GAAG;AAAA,MACH,GAAI,iBAAiB,SAAY,EAAE,MAAM,aAAa,IAAI,CAAC;AAAA,MAC3D,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEO,MAAM,uBAAuB,CAClC,OACA,aACG;AACH,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,iBAAiB,QAAQ;AAEvD,SAAO;AAAA,IACL,WAAW,GAAG,cAAc,IAAI,QAAQ,EAAE;AAAA,IAC1C;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["feature"]
|
|
7
7
|
}
|
package/map/MapView.js
CHANGED
|
@@ -30,6 +30,7 @@ var import_MapContent = require("./components/MapContent.js");
|
|
|
30
30
|
var import_MapUnavailable = require("./components/MapUnavailable.js");
|
|
31
31
|
var import_constants = require("./constants.js");
|
|
32
32
|
var import_formatter_context = require("./contexts/formatter.context.js");
|
|
33
|
+
var import_geo_data_lookup_context = require("./contexts/geo-data-lookup.context.js");
|
|
33
34
|
var import_layer_ids_context = require("./contexts/layer-ids.context.js");
|
|
34
35
|
var import_map_base_layer_context = require("./contexts/map-base-layer.context.js");
|
|
35
36
|
var import_map_configuration_context = require("./contexts/map-configuration.context.js");
|
|
@@ -69,7 +70,8 @@ const _MapView = (0, import_react.forwardRef)(
|
|
|
69
70
|
const {
|
|
70
71
|
flattenData: layersData,
|
|
71
72
|
categories,
|
|
72
|
-
legendDomain
|
|
73
|
+
legendDomain,
|
|
74
|
+
dataLookupRegistry
|
|
73
75
|
} = (0, import_extract_layers_data.extractLayersData)(parsedChildren, valueAccessors);
|
|
74
76
|
const config = (0, import_iterate_config_slots.iterateConfigSlots)(children, legendDomain);
|
|
75
77
|
const getMaxRange = () => {
|
|
@@ -119,43 +121,49 @@ const _MapView = (0, import_react.forwardRef)(
|
|
|
119
121
|
import_map_truncation_mode_context.MapTruncationModeContext.Provider,
|
|
120
122
|
{
|
|
121
123
|
value: truncationMode ?? import_constants.DEFAULT_TRUNCATION_MODE,
|
|
122
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_formatter_context.FormatterContext.Provider, { value: formatter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_map_raw_data_context.MapRawDataContext.Provider, { value: layersData, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
123
|
-
|
|
124
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_formatter_context.FormatterContext.Provider, { value: formatter, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_map_raw_data_context.MapRawDataContext.Provider, { value: layersData, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
import_geo_data_lookup_context.GeoDataLookupContext.Provider,
|
|
124
126
|
{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
import_charts._ChartLayout,
|
|
127
|
+
value: dataLookupRegistry,
|
|
128
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_charts._OverlayProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_charts._OverlayTooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_map_store_provider.MapStoreProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
129
|
+
import_color_scale_provider.ColorScaleProvider,
|
|
129
130
|
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
131
|
+
categories,
|
|
132
|
+
dataMax,
|
|
133
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_layer_color_strategy_provider.LayerColorStrategyProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
134
|
+
import_charts._ChartLayout,
|
|
135
|
+
{
|
|
136
|
+
ref: chartLayoutRef,
|
|
137
|
+
chartHeight,
|
|
138
|
+
errorState,
|
|
139
|
+
showLoader: loading || isLoading,
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_charts._ChartLayout.Graph, { children: baseFeatureCollection && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
+
import_MapContent.MapContent,
|
|
143
|
+
{
|
|
144
|
+
ref: forwardedRef,
|
|
145
|
+
onMapLoad: () => setIsMapLoaded(true),
|
|
146
|
+
...remaining,
|
|
147
|
+
children: parsedChildren
|
|
148
|
+
}
|
|
149
|
+
) }),
|
|
150
|
+
!isLegendHidden && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
|
+
import_charts._ChartLayout.Legend,
|
|
152
|
+
{
|
|
153
|
+
position: legendPosition,
|
|
154
|
+
ratio: legendRatio,
|
|
155
|
+
ratioBoundaries: import_constants.DEFAULT_LEGEND_SIZES,
|
|
156
|
+
onResize: legendOnRatioChange,
|
|
157
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MapLegendRenderer.MapLegendRenderer, {})
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
) })
|
|
155
163
|
}
|
|
156
|
-
) })
|
|
164
|
+
) }) }) })
|
|
157
165
|
}
|
|
158
|
-
) }) })
|
|
166
|
+
) }) })
|
|
159
167
|
}
|
|
160
168
|
) }) })
|
|
161
169
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BehaviorTrackingProps } from '@dynatrace/strato-components/core';
|
|
2
|
-
export declare const BubbleCircleLayer: ({ id, source, ...behavioralTrackingProps }: {
|
|
2
|
+
export declare const BubbleCircleLayer: ({ id, source, beforeId, ...behavioralTrackingProps }: {
|
|
3
3
|
id: string;
|
|
4
4
|
source: string;
|
|
5
|
+
beforeId?: string;
|
|
5
6
|
} & BehaviorTrackingProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -29,6 +29,7 @@ var import_constants = require("../../constants.js");
|
|
|
29
29
|
const BubbleCircleLayer = ({
|
|
30
30
|
id,
|
|
31
31
|
source,
|
|
32
|
+
beforeId,
|
|
32
33
|
...behavioralTrackingProps
|
|
33
34
|
}) => {
|
|
34
35
|
const sizeInterpolation = (0, import_use_size_interpolation.useSizeInterpolation)();
|
|
@@ -39,6 +40,7 @@ const BubbleCircleLayer = ({
|
|
|
39
40
|
type: "circle",
|
|
40
41
|
id,
|
|
41
42
|
source,
|
|
43
|
+
beforeId,
|
|
42
44
|
paint: {
|
|
43
45
|
"circle-color": [
|
|
44
46
|
"case",
|
|
@@ -31,6 +31,7 @@ var import_size_interpolation_context = require("./contexts/size-interpolation.c
|
|
|
31
31
|
var import_build_radius_scale = require("./utils/build-radius-scale.js");
|
|
32
32
|
var import_parse_bubble_data_to_geo_json = require("./utils/parse-bubble-data-to-geo-json.js");
|
|
33
33
|
var import_constants = require("../../constants.js");
|
|
34
|
+
var import_use_layer_before_id = require("../../hooks/use-layer-before-id.js");
|
|
34
35
|
var import_use_layer_coloring_strategy = require("../../hooks/use-layer-coloring-strategy.js");
|
|
35
36
|
var import_use_legend_interaction_highlighting = require("../../hooks/use-legend-interaction-highlighting.js");
|
|
36
37
|
var import_use_legend_interaction_visibility = require("../../hooks/use-legend-interaction-visibility.js");
|
|
@@ -58,12 +59,13 @@ const BubbleLayer = (props) => {
|
|
|
58
59
|
const sourceId = `source-${layerId}`;
|
|
59
60
|
(0, import_use_legend_interaction_highlighting.useLegendInteractionHighlighting)(props, sourceId);
|
|
60
61
|
(0, import_use_legend_interaction_visibility.useLegendInteractionVisibility)(props, layerId);
|
|
62
|
+
const beforeId = (0, import_use_layer_before_id.useLayerBeforeId)(layerId);
|
|
61
63
|
let radiusScale = (value) => value;
|
|
62
64
|
if ((0, import_bubble_layer.isScaleRadius)(props)) {
|
|
63
65
|
const { radiusRange = [10, 100], radius: radius2, scale = "linear" } = props;
|
|
64
66
|
radiusScale = (0, import_build_radius_scale.buildRadiusScale)(data, radius2, scale, radiusRange);
|
|
65
67
|
}
|
|
66
|
-
const dataGeoJson = (0, import_parse_bubble_data_to_geo_json.parseBubbleDataToGeoJSON)(
|
|
68
|
+
const { geoJson: dataGeoJson } = (0, import_parse_bubble_data_to_geo_json.parseBubbleDataToGeoJSON)(
|
|
67
69
|
data,
|
|
68
70
|
bubbleColor,
|
|
69
71
|
radius,
|
|
@@ -82,6 +84,7 @@ const BubbleLayer = (props) => {
|
|
|
82
84
|
{
|
|
83
85
|
id: layerId,
|
|
84
86
|
source: sourceId,
|
|
87
|
+
beforeId,
|
|
85
88
|
...behavioralTrackingProps
|
|
86
89
|
}
|
|
87
90
|
),
|
|
@@ -2,5 +2,7 @@ import type { ScaleLinear, ScaleLogarithmic } from 'd3-scale';
|
|
|
2
2
|
import type GeoJSON from 'geojson';
|
|
3
3
|
import type { Location } from '../../../types/location.js';
|
|
4
4
|
type RadiusScale = ScaleLinear<number, number> | ScaleLogarithmic<number, number> | ((value: number) => number);
|
|
5
|
-
export declare const parseBubbleDataToGeoJSON: <T extends Location>(data: T[], color: string | ((item: T) => string), radius: number | ((item: T) => number), scale: RadiusScale) =>
|
|
5
|
+
export declare const parseBubbleDataToGeoJSON: <T extends Location>(data: T[], color: string | ((item: T) => string), radius: number | ((item: T) => number), scale: RadiusScale) => {
|
|
6
|
+
geoJson: GeoJSON.FeatureCollection;
|
|
7
|
+
};
|
|
6
8
|
export {};
|
|
@@ -26,18 +26,17 @@ var import_define_radius = require("./define-radius.js");
|
|
|
26
26
|
var import_calculate_hovered_color = require("../../../utils/calculate-hovered-color.js");
|
|
27
27
|
var import_define_color = require("../../../utils/define-color.js");
|
|
28
28
|
const parseBubbleDataToGeoJSON = (data, color, radius, scale) => {
|
|
29
|
-
|
|
29
|
+
const geoJson = {
|
|
30
30
|
type: "FeatureCollection",
|
|
31
|
-
features: data.map((feature) => {
|
|
32
|
-
const { longitude, latitude
|
|
31
|
+
features: data.map((feature, index) => {
|
|
32
|
+
const { longitude, latitude } = feature;
|
|
33
33
|
const canvasColor = (0, import_charts._getCanvasColor)((0, import_define_color.defineColor)(color, feature));
|
|
34
34
|
const hoveredColor = (0, import_calculate_hovered_color.calculateHoveredColor)(canvasColor);
|
|
35
35
|
const scaledRadius = scale((0, import_define_radius.defineRadius)(radius, feature));
|
|
36
36
|
return {
|
|
37
37
|
type: "Feature",
|
|
38
38
|
properties: {
|
|
39
|
-
|
|
40
|
-
...properties,
|
|
39
|
+
__dataIndex: index,
|
|
41
40
|
__color: canvasColor,
|
|
42
41
|
__hoveredColor: hoveredColor,
|
|
43
42
|
__radius: scaledRadius,
|
|
@@ -47,4 +46,5 @@ const parseBubbleDataToGeoJSON = (data, color, radius, scale) => {
|
|
|
47
46
|
};
|
|
48
47
|
})
|
|
49
48
|
};
|
|
49
|
+
return { geoJson };
|
|
50
50
|
};
|