@dynatrace/strato-geo 0.10.72 → 0.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.
- package/esm/map/MapView.js +37 -34
- package/esm/map/MapView.js.map +2 -2
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js +1 -6
- package/esm/map/components/ChoroplethLayer/ChoroplethLayer.js.map +2 -2
- package/esm/map/components/MapContent.js +16 -4
- package/esm/map/components/MapContent.js.map +2 -2
- package/esm/map/components/legend/SequentialLegendRenderer.js +8 -3
- package/esm/map/components/legend/SequentialLegendRenderer.js.map +2 -2
- package/esm/map/components/legend/ThresholdLegendRenderer.js +1 -1
- package/esm/map/components/legend/ThresholdLegendRenderer.js.map +2 -2
- package/esm/map/constants.js +5 -0
- package/esm/map/constants.js.map +2 -2
- package/esm/map/contexts/map-configuration.context.js +2 -1
- package/esm/map/contexts/map-configuration.context.js.map +2 -2
- package/esm/map/contexts/map-loading.context.js +6 -0
- package/esm/map/contexts/map-loading.context.js.map +7 -0
- package/esm/map/hooks/use-load-map-base-layer.js +7 -13
- package/esm/map/hooks/use-load-map-base-layer.js.map +2 -2
- package/esm/map/hooks/use-map-loading.js +7 -0
- package/esm/map/hooks/use-map-loading.js.map +7 -0
- package/esm/map/providers/imperative-handler.provider.js +34 -0
- package/esm/map/providers/imperative-handler.provider.js.map +7 -0
- package/esm/map/utils/get-client-settings.js.map +2 -2
- package/esm/map/utils/get-tenant-country-code.js +2 -2
- package/esm/map/utils/get-tenant-country-code.js.map +2 -2
- package/esm/map/utils/iterate-config-slots.js +4 -4
- package/esm/map/utils/iterate-config-slots.js.map +2 -2
- package/map/MapView.js +36 -29
- package/map/components/ChoroplethLayer/ChoroplethLayer.js +1 -6
- package/map/components/MapContent.d.ts +2 -2
- package/map/components/MapContent.js +16 -4
- package/map/components/legend/SequentialLegendRenderer.js +7 -3
- package/map/components/legend/ThresholdLegendRenderer.js +1 -1
- package/map/constants.d.ts +2 -0
- package/map/constants.js +5 -0
- package/map/contexts/map-configuration.context.js +2 -1
- package/map/contexts/map-loading.context.d.ts +1 -0
- package/map/contexts/map-loading.context.js +24 -0
- package/map/hooks/use-load-map-base-layer.d.ts +1 -1
- package/map/hooks/use-load-map-base-layer.js +6 -12
- package/map/hooks/use-map-loading.d.ts +1 -0
- package/map/hooks/use-map-loading.js +25 -0
- package/map/providers/imperative-handler.provider.d.ts +7 -0
- package/map/providers/imperative-handler.provider.js +52 -0
- package/map/types/configuration.d.ts +4 -4
- package/map/types/map-view.d.ts +8 -0
- package/map/utils/get-tenant-country-code.js +1 -1
- package/map/utils/iterate-config-slots.js +3 -4
- package/package.json +5 -5
package/esm/map/MapView.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
forwardRef,
|
|
3
|
-
useImperativeHandle,
|
|
4
|
-
useRef
|
|
5
|
-
} from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
6
2
|
import {
|
|
7
3
|
_ChartLayout as ChartLayout,
|
|
8
4
|
_coerceSizeValue as coerceSizeValue,
|
|
9
5
|
_useAutoLegendRefresh as useAutoLegendRefresh
|
|
10
6
|
} from "@dynatrace/strato-components-preview/charts";
|
|
11
|
-
import { useMergeRefs } from "@dynatrace/strato-components-preview/core";
|
|
12
7
|
import { MapLegendRenderer } from "./components/legend/MapLegendRenderer.js";
|
|
13
8
|
import { MapContent } from "./components/MapContent.js";
|
|
14
9
|
import { MapUnavailable } from "./components/MapUnavailable.js";
|
|
@@ -17,13 +12,13 @@ import { LayerIdsContext } from "./contexts/layer-ids.context.js";
|
|
|
17
12
|
import { MapBaseLayerFeaturesContext } from "./contexts/map-base-layer.context.js";
|
|
18
13
|
import { MapConfigurationContext } from "./contexts/map-configuration.context.js";
|
|
19
14
|
import { MapDataBoundingBoxContext } from "./contexts/map-data-bounding-box.context.js";
|
|
15
|
+
import { MapLoadingContext } from "./contexts/map-loading.context.js";
|
|
20
16
|
import { MapRawDataContext } from "./contexts/map-raw-data.context.js";
|
|
21
17
|
import { useLoadMapBaseLayer } from "./hooks/use-load-map-base-layer.js";
|
|
22
18
|
import { ColorScaleProvider } from "./providers/color-scale.provider.js";
|
|
23
19
|
import { LayerColorStrategyProvider } from "./providers/layer-color-strategy.provider.js";
|
|
24
20
|
import { ErrorStateSlot } from "./slots/states/ErrorStateSlot.js";
|
|
25
21
|
import { MapStoreProvider } from "./store/map-store.provider.js";
|
|
26
|
-
import { buildAndDownloadCsv } from "./utils/build-and-download-csv.js";
|
|
27
22
|
import { extractLayersData } from "./utils/extract-layers-data.js";
|
|
28
23
|
import { getDataLayersBoundingBox } from "./utils/get-data-layers-bounding-box.js";
|
|
29
24
|
import { getMapStatesTemplates } from "./utils/get-map-states-template.js";
|
|
@@ -42,17 +37,6 @@ const _MapView = forwardRef(
|
|
|
42
37
|
const { layerIds, parsedChildren } = setLayersId(children);
|
|
43
38
|
const layersData = extractLayersData(parsedChildren);
|
|
44
39
|
const dataLayersBBox = getDataLayersBoundingBox(children);
|
|
45
|
-
const containerRef = useRef(null);
|
|
46
|
-
const rootRef = useMergeRefs([
|
|
47
|
-
forwardedRef,
|
|
48
|
-
containerRef
|
|
49
|
-
]);
|
|
50
|
-
useImperativeHandle(forwardedRef, () => ({
|
|
51
|
-
element: containerRef.current,
|
|
52
|
-
downloadData: () => {
|
|
53
|
-
buildAndDownloadCsv(layersData);
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
40
|
const config = iterateConfigSlots(children);
|
|
57
41
|
const isLegendHidden = !config.legend || !!config.legend.hidden;
|
|
58
42
|
const legendPosition = config.legend?.position;
|
|
@@ -80,26 +64,45 @@ const _MapView = forwardRef(
|
|
|
80
64
|
chartHeight,
|
|
81
65
|
error
|
|
82
66
|
}
|
|
83
|
-
) : /* @__PURE__ */ React.createElement(
|
|
84
|
-
|
|
67
|
+
) : /* @__PURE__ */ React.createElement(MapLoadingContext.Provider, { value: loading }, /* @__PURE__ */ React.createElement(
|
|
68
|
+
MapBaseLayerFeaturesContext.Provider,
|
|
85
69
|
{
|
|
86
|
-
|
|
87
|
-
chartHeight,
|
|
88
|
-
errorState,
|
|
89
|
-
showLoader: loading || isLoading
|
|
70
|
+
value: baseFeatureCollection
|
|
90
71
|
},
|
|
91
|
-
/* @__PURE__ */ React.createElement(
|
|
92
|
-
|
|
93
|
-
ChartLayout.Legend,
|
|
72
|
+
/* @__PURE__ */ React.createElement(MapConfigurationContext.Provider, { value: config }, /* @__PURE__ */ React.createElement(LayerIdsContext.Provider, { value: layerIds }, /* @__PURE__ */ React.createElement(MapRawDataContext.Provider, { value: layersData }, /* @__PURE__ */ React.createElement(
|
|
73
|
+
MapDataBoundingBoxContext.Provider,
|
|
94
74
|
{
|
|
95
|
-
|
|
96
|
-
ratio: legendRatio,
|
|
97
|
-
ratioBoundaries: DEFAULT_LEGEND_SIZES,
|
|
98
|
-
onResize: legendOnRatioChange
|
|
75
|
+
value: dataLayersBBox
|
|
99
76
|
},
|
|
100
|
-
/* @__PURE__ */ React.createElement(
|
|
101
|
-
|
|
102
|
-
|
|
77
|
+
/* @__PURE__ */ React.createElement(MapStoreProvider, null, /* @__PURE__ */ React.createElement(ColorScaleProvider, null, /* @__PURE__ */ React.createElement(LayerColorStrategyProvider, null, /* @__PURE__ */ React.createElement(
|
|
78
|
+
ChartLayout,
|
|
79
|
+
{
|
|
80
|
+
ref: chartLayoutRef,
|
|
81
|
+
chartHeight,
|
|
82
|
+
errorState,
|
|
83
|
+
showLoader: loading || isLoading
|
|
84
|
+
},
|
|
85
|
+
/* @__PURE__ */ React.createElement(ChartLayout.Graph, null, baseFeatureCollection && /* @__PURE__ */ React.createElement(
|
|
86
|
+
MapContent,
|
|
87
|
+
{
|
|
88
|
+
ref: forwardedRef,
|
|
89
|
+
...remaining
|
|
90
|
+
},
|
|
91
|
+
parsedChildren
|
|
92
|
+
)),
|
|
93
|
+
!isLegendHidden && /* @__PURE__ */ React.createElement(
|
|
94
|
+
ChartLayout.Legend,
|
|
95
|
+
{
|
|
96
|
+
position: legendPosition,
|
|
97
|
+
ratio: legendRatio,
|
|
98
|
+
ratioBoundaries: DEFAULT_LEGEND_SIZES,
|
|
99
|
+
onResize: legendOnRatioChange
|
|
100
|
+
},
|
|
101
|
+
/* @__PURE__ */ React.createElement(MapLegendRenderer, null)
|
|
102
|
+
)
|
|
103
|
+
))))
|
|
104
|
+
))))
|
|
105
|
+
))
|
|
103
106
|
);
|
|
104
107
|
}
|
|
105
108
|
);
|
package/esm/map/MapView.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/map/MapView.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, {
|
|
5
|
-
"mappings": "AAAA,OAAO
|
|
4
|
+
"sourcesContent": ["import React, { forwardRef, type PropsWithChildren } from 'react';\n\nimport {\n _ChartLayout as ChartLayout,\n _coerceSizeValue as coerceSizeValue,\n _useAutoLegendRefresh as useAutoLegendRefresh,\n} from '@dynatrace/strato-components-preview/charts';\n\nimport { MapLegendRenderer } from './components/legend/MapLegendRenderer.js';\nimport { MapContent } from './components/MapContent.js';\nimport { MapUnavailable } from './components/MapUnavailable.js';\nimport { DEFAULT_LEGEND_SIZES, DEFAULT_MAP_HEIGHT } from './constants.js';\nimport { LayerIdsContext } from './contexts/layer-ids.context.js';\nimport { MapBaseLayerFeaturesContext } from './contexts/map-base-layer.context.js';\nimport { MapConfigurationContext } from './contexts/map-configuration.context.js';\nimport { MapDataBoundingBoxContext } from './contexts/map-data-bounding-box.context.js';\nimport { MapLoadingContext } from './contexts/map-loading.context.js';\nimport { MapRawDataContext } from './contexts/map-raw-data.context.js';\nimport { useLoadMapBaseLayer } from './hooks/use-load-map-base-layer.js';\nimport { ColorScaleProvider } from './providers/color-scale.provider.js';\nimport { LayerColorStrategyProvider } from './providers/layer-color-strategy.provider.js';\nimport { ErrorStateSlot } from './slots/states/ErrorStateSlot.js';\nimport { MapStoreProvider } from './store/map-store.provider.js';\nimport type { MapViewProps, MapViewRef } from './types/map-view.js';\nimport { extractLayersData } from './utils/extract-layers-data.js';\nimport { getDataLayersBoundingBox } from './utils/get-data-layers-bounding-box.js';\nimport { getMapStatesTemplates } from './utils/get-map-states-template.js';\nimport { iterateConfigSlots } from './utils/iterate-config-slots.js';\nimport { setLayersId } from './utils/set-layers-id.js';\n// eslint-disable-next-line no-restricted-imports\nimport './styles/react-mapgl-styles.css';\n\n/**\n * MapView Component\n */\nconst _MapView = forwardRef<MapViewRef, PropsWithChildren<MapViewProps>>(\n (props, forwardedRef) => {\n const {\n children,\n loading = false,\n style: costumerStyle,\n className: customerClassNames,\n ...remaining\n } = props;\n const { layerIds, parsedChildren } = setLayersId(children);\n\n const layersData = extractLayersData(parsedChildren);\n const dataLayersBBox = getDataLayersBoundingBox(children);\n\n const config = iterateConfigSlots(children);\n\n const isLegendHidden = !config.legend || !!config.legend.hidden;\n const legendPosition = config.legend?.position;\n const legendRatio = config.legend?.ratio;\n const legendOnRatioChange = config.legend?.onRatioChange;\n\n const { isMapEnabled, isLoading, baseFeatureCollection, error } =\n useLoadMapBaseLayer(config.baseLayer);\n\n const { errorState } = getMapStatesTemplates(children);\n\n const chartHeight = coerceSizeValue(props.height) || DEFAULT_MAP_HEIGHT;\n\n const containerStyles = { width: '100%', ...costumerStyle };\n\n const chartLayoutRef = useAutoLegendRefresh(layersData);\n const mapUnavailable = (!isLoading && !isMapEnabled) || error;\n\n return (\n <div\n style={containerStyles}\n className={customerClassNames}\n data-testid=\"mapview-container\"\n >\n {\n // TODO: Error boundaries global fix needed - this error state only purpose is to make map not rendering when there error in response\n mapUnavailable ? (\n <MapUnavailable\n isLoading={isLoading}\n isDisabled={!isMapEnabled}\n chartHeight={chartHeight}\n error={error}\n />\n ) : (\n <MapLoadingContext.Provider value={loading}>\n <MapBaseLayerFeaturesContext.Provider\n value={baseFeatureCollection}\n >\n <MapConfigurationContext.Provider value={config}>\n <LayerIdsContext.Provider value={layerIds}>\n <MapRawDataContext.Provider value={layersData}>\n <MapDataBoundingBoxContext.Provider\n value={dataLayersBBox}\n >\n <MapStoreProvider>\n <ColorScaleProvider>\n <LayerColorStrategyProvider>\n <ChartLayout\n ref={chartLayoutRef}\n chartHeight={chartHeight}\n errorState={errorState}\n showLoader={loading || isLoading}\n >\n <ChartLayout.Graph>\n {baseFeatureCollection && (\n <MapContent\n ref={forwardedRef}\n {...remaining}\n >\n {parsedChildren}\n </MapContent>\n )}\n </ChartLayout.Graph>\n {!isLegendHidden && (\n <ChartLayout.Legend\n position={legendPosition}\n ratio={legendRatio}\n ratioBoundaries={DEFAULT_LEGEND_SIZES}\n onResize={legendOnRatioChange}\n >\n <MapLegendRenderer />\n </ChartLayout.Legend>\n )}\n </ChartLayout>\n </LayerColorStrategyProvider>\n </ColorScaleProvider>\n </MapStoreProvider>\n </MapDataBoundingBoxContext.Provider>\n </MapRawDataContext.Provider>\n </LayerIdsContext.Provider>\n </MapConfigurationContext.Provider>\n </MapBaseLayerFeaturesContext.Provider>\n </MapLoadingContext.Provider>\n )\n }\n </div>\n );\n },\n);\n\n(_MapView as typeof _MapView & { displayName: string })['displayName'] =\n 'MapView';\n\n/**\n * The `MapView` is a component that renders a map with various geospatial data layers.\n * @beta\n */\nexport const MapView = Object.assign(_MapView, {\n ErrorState: ErrorStateSlot,\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,kBAA0C;AAE1D;AAAA,EACE,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,yBAAyB;AAAA,OACpB;AAEP,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB,0BAA0B;AACzD,SAAS,uBAAuB;AAChC,SAAS,mCAAmC;AAC5C,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AAC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AAAA,UACC,OAAO;AAAA;AAAA,QAEP,oCAAC,wBAAwB,UAAxB,EAAiC,OAAO,UACvC,oCAAC,gBAAgB,UAAhB,EAAyB,OAAO,YAC/B,oCAAC,kBAAkB,UAAlB,EAA2B,OAAO,cACjC;AAAA,UAAC,0BAA0B;AAAA,UAA1B;AAAA,YACC,OAAO;AAAA;AAAA,UAEP,oCAAC,wBACC,oCAAC,0BACC,oCAAC,kCACC;AAAA,YAAC;AAAA;AAAA,cACC,KAAK;AAAA,cACL;AAAA,cACA;AAAA,cACA,YAAY,WAAW;AAAA;AAAA,YAEvB,oCAAC,YAAY,OAAZ,MACE,yBACC;AAAA,cAAC;AAAA;AAAA,gBACC,KAAK;AAAA,gBACJ,GAAG;AAAA;AAAA,cAEH;AAAA,YACH,CAEJ;AAAA,YACC,CAAC,kBACA;AAAA,cAAC,YAAY;AAAA,cAAZ;AAAA,gBACC,UAAU;AAAA,gBACV,OAAO;AAAA,gBACP,iBAAiB;AAAA,gBACjB,UAAU;AAAA;AAAA,cAEV,oCAAC,uBAAkB;AAAA,YACrB;AAAA,UAEJ,CACF,CACF,CACF;AAAA,QACF,CACF,CACF,CACF;AAAA,MACF,CACF;AAAA,IAGN;AAAA,EAEJ;AACF;AAEC,SAAuD,aAAa,IACnE;AAMK,MAAM,UAAU,OAAO,OAAO,UAAU;AAAA,EAC7C,YAAY;AACd,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,12 +32,7 @@ const ChoroplethLayer = (props) => {
|
|
|
32
32
|
const sourceId = layerId.replace("layer", "source");
|
|
33
33
|
useLegendInteractionHighlighting(props, sourceId);
|
|
34
34
|
useLegendInteractionVisibility(props, layerId);
|
|
35
|
-
const dataGeoJSON = parseRegionDataToGeoJSON(
|
|
36
|
-
mapSource,
|
|
37
|
-
data,
|
|
38
|
-
regionAccessor,
|
|
39
|
-
choroplethColor
|
|
40
|
-
);
|
|
35
|
+
const dataGeoJSON = mapSource && parseRegionDataToGeoJSON(mapSource, data, regionAccessor, choroplethColor);
|
|
41
36
|
const tooltipTemplate = useTooltipTemplate(
|
|
42
37
|
children,
|
|
43
38
|
ChoroplethLayerTooltipSlot
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/map/components/ChoroplethLayer/ChoroplethLayer.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { type PropsWithChildren } from 'react';\nimport { Layer, Source } from 'react-map-gl/maplibre';\n\nimport { _getCanvasColor as getCanvasColor } from '@dynatrace/strato-components-preview/charts';\n\nimport { ChoroplethLayerTooltip } from './ChoroplethLayerTooltip.js';\nimport { parseRegionDataToGeoJSON } from './utils/parse-region-data-to-geo-json.js';\nimport {\n ACTIVE_COLOR,\n ACTIVE_STATE_BORDERS_WIDTH,\n DEFAULT_CHOROPLETH_COLOR,\n DEFAULT_COUNTRIES_BORDER_COLOR,\n LEGEND_DIM_OPACITY,\n SHAPE_OPACITY,\n TRANSPARENT_BORDER_COLOR,\n} from '../../constants.js';\nimport { useLayerColoringStrategy } from '../../hooks/use-layer-coloring-strategy.js';\nimport { useLegendInteractionHighlighting } from '../../hooks/use-legend-interaction-highlighting.js';\nimport { useLegendInteractionVisibility } from '../../hooks/use-legend-interaction-visibility.js';\nimport { useMapBaseLayerFeatures } from '../../hooks/use-map-base-layer-features.js';\nimport { useResolveChoroplethColor } from '../../hooks/use-resolve-color.js';\nimport { useTooltipTemplate } from '../../hooks/use-tooltip-template.js';\nimport { ChoroplethLayerTooltip as ChoroplethLayerTooltipSlot } from '../../slots/ChoroplethLayerTooltip.js';\nimport type { InternalChoroplethLayerProps } from '../../types/choropleth-layer.js';\nimport { isChoroplethTooltipTemplate } from '../../utils/tooltip-type-guards.js';\n\nexport const ChoroplethLayer = <T extends Record<string, unknown>>(\n props: PropsWithChildren<InternalChoroplethLayerProps<T>>,\n) => {\n const { layerId, data, regionAccessor, children } = props;\n\n const mapSource = useMapBaseLayerFeatures();\n\n const colorParser = useLayerColoringStrategy();\n const choroplethColor = useResolveChoroplethColor(\n DEFAULT_CHOROPLETH_COLOR,\n props,\n colorParser,\n );\n const sourceId = layerId.replace('layer', 'source');\n useLegendInteractionHighlighting(props, sourceId);\n useLegendInteractionVisibility(props, layerId);\n\n const dataGeoJSON
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAuC;AAC9C,SAAS,OAAO,cAAc;AAE9B,SAAS,mBAAmB,sBAAsB;AAElD,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAAS,sCAAsC;AAC/C,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,0BAA0B;AACnC,SAAS,0BAA0B,kCAAkC;AAErE,SAAS,mCAAmC;AAErC,MAAM,kBAAkB,CAC7B,UACG;AACH,QAAM,EAAE,SAAS,MAAM,gBAAgB,SAAS,IAAI;AAEpD,QAAM,YAAY,wBAAwB;AAE1C,QAAM,cAAc,yBAAyB;AAC7C,QAAM,kBAAkB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,WAAW,QAAQ,QAAQ,SAAS,QAAQ;AAClD,mCAAiC,OAAO,QAAQ;AAChD,iCAA+B,OAAO,OAAO;AAE7C,QAAM,
|
|
4
|
+
"sourcesContent": ["import React, { type PropsWithChildren } from 'react';\nimport { Layer, Source } from 'react-map-gl/maplibre';\n\nimport { _getCanvasColor as getCanvasColor } from '@dynatrace/strato-components-preview/charts';\n\nimport { ChoroplethLayerTooltip } from './ChoroplethLayerTooltip.js';\nimport { parseRegionDataToGeoJSON } from './utils/parse-region-data-to-geo-json.js';\nimport {\n ACTIVE_COLOR,\n ACTIVE_STATE_BORDERS_WIDTH,\n DEFAULT_CHOROPLETH_COLOR,\n DEFAULT_COUNTRIES_BORDER_COLOR,\n LEGEND_DIM_OPACITY,\n SHAPE_OPACITY,\n TRANSPARENT_BORDER_COLOR,\n} from '../../constants.js';\nimport { useLayerColoringStrategy } from '../../hooks/use-layer-coloring-strategy.js';\nimport { useLegendInteractionHighlighting } from '../../hooks/use-legend-interaction-highlighting.js';\nimport { useLegendInteractionVisibility } from '../../hooks/use-legend-interaction-visibility.js';\nimport { useMapBaseLayerFeatures } from '../../hooks/use-map-base-layer-features.js';\nimport { useResolveChoroplethColor } from '../../hooks/use-resolve-color.js';\nimport { useTooltipTemplate } from '../../hooks/use-tooltip-template.js';\nimport { ChoroplethLayerTooltip as ChoroplethLayerTooltipSlot } from '../../slots/ChoroplethLayerTooltip.js';\nimport type { InternalChoroplethLayerProps } from '../../types/choropleth-layer.js';\nimport { isChoroplethTooltipTemplate } from '../../utils/tooltip-type-guards.js';\n\nexport const ChoroplethLayer = <T extends Record<string, unknown>>(\n props: PropsWithChildren<InternalChoroplethLayerProps<T>>,\n) => {\n const { layerId, data, regionAccessor, children } = props;\n\n const mapSource = useMapBaseLayerFeatures();\n\n const colorParser = useLayerColoringStrategy();\n const choroplethColor = useResolveChoroplethColor(\n DEFAULT_CHOROPLETH_COLOR,\n props,\n colorParser,\n );\n const sourceId = layerId.replace('layer', 'source');\n useLegendInteractionHighlighting(props, sourceId);\n useLegendInteractionVisibility(props, layerId);\n\n const dataGeoJSON =\n mapSource &&\n parseRegionDataToGeoJSON(mapSource, data, regionAccessor, choroplethColor);\n\n const tooltipTemplate = useTooltipTemplate(\n children,\n ChoroplethLayerTooltipSlot,\n );\n\n return (\n <>\n <Source id={sourceId} type=\"geojson\" data={dataGeoJSON} generateId>\n <Layer\n id={layerId}\n type=\"fill\"\n source={sourceId}\n paint={{\n 'fill-color': [\n 'case',\n ['boolean', ['feature-state', 'active'], false],\n ['get', '__color'],\n ['boolean', ['feature-state', 'hover'], false],\n ['get', '__hoveredColor'],\n ['get', '__color'],\n ],\n 'fill-opacity': [\n 'case',\n ['boolean', ['feature-state', 'legendHover'], true],\n SHAPE_OPACITY,\n LEGEND_DIM_OPACITY,\n ],\n }}\n />\n <Layer\n type=\"line\"\n source={sourceId}\n paint={{\n 'line-color': getCanvasColor(DEFAULT_COUNTRIES_BORDER_COLOR),\n }}\n />\n <Layer\n type=\"line\"\n source={sourceId}\n paint={{\n 'line-color': [\n 'case',\n ['boolean', ['feature-state', 'active'], false],\n getCanvasColor(ACTIVE_COLOR),\n getCanvasColor(TRANSPARENT_BORDER_COLOR),\n ],\n 'line-width': ACTIVE_STATE_BORDERS_WIDTH,\n }}\n />\n </Source>\n\n <ChoroplethLayerTooltip\n layerId={layerId}\n tooltipTemplate={\n isChoroplethTooltipTemplate(tooltipTemplate)\n ? tooltipTemplate\n : undefined\n }\n />\n </>\n );\n};\n\nChoroplethLayer['displayName'] = 'ChoroplethLayer';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAuC;AAC9C,SAAS,OAAO,cAAc;AAE9B,SAAS,mBAAmB,sBAAsB;AAElD,SAAS,8BAA8B;AACvC,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAAS,sCAAsC;AAC/C,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,0BAA0B;AACnC,SAAS,0BAA0B,kCAAkC;AAErE,SAAS,mCAAmC;AAErC,MAAM,kBAAkB,CAC7B,UACG;AACH,QAAM,EAAE,SAAS,MAAM,gBAAgB,SAAS,IAAI;AAEpD,QAAM,YAAY,wBAAwB;AAE1C,QAAM,cAAc,yBAAyB;AAC7C,QAAM,kBAAkB;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,WAAW,QAAQ,QAAQ,SAAS,QAAQ;AAClD,mCAAiC,OAAO,QAAQ;AAChD,iCAA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AAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -20,10 +20,12 @@ import { useHoverInteraction } from "../hooks/use-hover-interaction.js";
|
|
|
20
20
|
import { useInitialViewState } from "../hooks/use-initial-view-state.js";
|
|
21
21
|
import { useMapBaseLayerFeatures } from "../hooks/use-map-base-layer-features.js";
|
|
22
22
|
import { useMapConfig } from "../hooks/use-map-config.js";
|
|
23
|
+
import { useMapLoading } from "../hooks/use-map-loading.js";
|
|
23
24
|
import { useMapPerformance } from "../hooks/use-map-performance.js";
|
|
24
25
|
import { useOverlayEvents } from "../hooks/use-overlay-events.js";
|
|
25
26
|
import { useTooltipEventListeners } from "../hooks/use-tooltip-event-listeners.js";
|
|
26
27
|
import { defaultStyle } from "../map-styles/default-style.js";
|
|
28
|
+
import { MapViewImperativeHandler } from "../providers/imperative-handler.provider.js";
|
|
27
29
|
import { getColorFromToken } from "../utils/get-color-from-token.js";
|
|
28
30
|
import { toMapBoxInitialViewState } from "../utils/to-mapbox-initial-view-state.js";
|
|
29
31
|
import { useSetMapInitialConfiguration } from "../utils/use-set-map-initial-configuration.js";
|
|
@@ -69,8 +71,12 @@ const MapContent = forwardRef((props, forwardedRef) => {
|
|
|
69
71
|
onViewStateChange,
|
|
70
72
|
...remaining
|
|
71
73
|
} = props;
|
|
74
|
+
const loading = useMapLoading();
|
|
72
75
|
const mapContainerRef = useRef(null);
|
|
73
|
-
const mergedRefs = useMergeRefs([
|
|
76
|
+
const mergedRefs = useMergeRefs([
|
|
77
|
+
mapContainerRef,
|
|
78
|
+
forwardedRef
|
|
79
|
+
]);
|
|
74
80
|
useTooltipEventListeners();
|
|
75
81
|
const { toolbar: toolbarConfig, interactions: interactionsConfig } = useMapConfig();
|
|
76
82
|
const layerIds = useContext(LayerIdsContext);
|
|
@@ -122,9 +128,15 @@ const MapContent = forwardRef((props, forwardedRef) => {
|
|
|
122
128
|
interactive: true,
|
|
123
129
|
...remaining
|
|
124
130
|
},
|
|
125
|
-
/* @__PURE__ */ React.createElement(
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
/* @__PURE__ */ React.createElement(
|
|
132
|
+
MapViewImperativeHandler,
|
|
133
|
+
{
|
|
134
|
+
forwardedRef,
|
|
135
|
+
containerRef: mapContainerRef
|
|
136
|
+
},
|
|
137
|
+
/* @__PURE__ */ React.createElement(MapSource, null),
|
|
138
|
+
loading ? null : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(MapInteractions, null, children), shouldRenderToolbar ? /* @__PURE__ */ React.createElement(MapToolbar, null) : null)
|
|
139
|
+
)
|
|
128
140
|
)
|
|
129
141
|
);
|
|
130
142
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/components/MapContent.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isUndefined } from 'lodash-es';\nimport type { MapLayerMouseEvent } from 'maplibre-gl';\nimport React, {\n forwardRef,\n type PropsWithChildren,\n useContext,\n useRef,\n} from 'react';\nimport { Layer, type LayerProps, Map, Source } from 'react-map-gl/maplibre';\n\nimport { _useGraphSize as useGraphSize } from '@dynatrace/strato-components-preview/charts';\nimport { useMergeRefs } from '@dynatrace/strato-components-preview/core';\n\nimport {\n BASE_LAYER_FILL_ID,\n BASE_LAYER_LINE_ID,\n DEFAULT_COUNTRIES_BORDER_COLOR,\n DEFAULT_COUNTRIES_FILL_COLOR,\n} from '../constants.js';\nimport { MapToolbar } from './toolbar/MapToolbar.js';\nimport { LayerIdsContext } from '../contexts/layer-ids.context.js';\nimport { useActiveInteraction } from '../hooks/use-active-interaction.js';\nimport { useHoverInteraction } from '../hooks/use-hover-interaction.js';\nimport { useInitialViewState } from '../hooks/use-initial-view-state.js';\nimport { useMapBaseLayerFeatures } from '../hooks/use-map-base-layer-features.js';\nimport { useMapConfig } from '../hooks/use-map-config.js';\nimport { useMapPerformance } from '../hooks/use-map-performance.js';\nimport { useOverlayEvents } from '../hooks/use-overlay-events.js';\nimport { useTooltipEventListeners } from '../hooks/use-tooltip-event-listeners.js';\nimport { defaultStyle } from '../map-styles/default-style.js';\nimport type { MapViewProps } from '../types/map-view.js';\nimport { getColorFromToken } from '../utils/get-color-from-token.js';\nimport { toMapBoxInitialViewState } from '../utils/to-mapbox-initial-view-state.js';\nimport { useSetMapInitialConfiguration } from '../utils/use-set-map-initial-configuration.js';\n\nconst lineLayer: LayerProps = {\n id: BASE_LAYER_LINE_ID,\n type: 'line',\n};\n\nconst fillLayer: LayerProps = {\n id: BASE_LAYER_FILL_ID,\n type: 'fill',\n};\n\nconst MapSource = () => {\n const baseLayerFeatures = useMapBaseLayerFeatures();\n return (\n <Source id=\"data\" type=\"geojson\" data={baseLayerFeatures}>\n <Layer\n {...fillLayer}\n paint={{\n 'fill-color': getColorFromToken(DEFAULT_COUNTRIES_FILL_COLOR),\n }}\n ></Layer>\n <Layer\n {...lineLayer}\n paint={{\n 'line-color': getColorFromToken(DEFAULT_COUNTRIES_BORDER_COLOR),\n }}\n ></Layer>\n </Source>\n );\n};\n\nconst MapInteractions = ({ children }: PropsWithChildren) => {\n useHoverInteraction();\n useActiveInteraction();\n\n return children;\n};\n\nexport const MapContent = forwardRef<\n
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB;AAE5B,OAAO;AAAA,EACL;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,OAAwB,KAAK,cAAc;AAEpD,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AACxC,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AACzC,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import { isUndefined } from 'lodash-es';\nimport type { MapLayerMouseEvent } from 'maplibre-gl';\nimport React, {\n forwardRef,\n type PropsWithChildren,\n useContext,\n useRef,\n} from 'react';\nimport { Layer, type LayerProps, Map, Source } from 'react-map-gl/maplibre';\n\nimport { _useGraphSize as useGraphSize } from '@dynatrace/strato-components-preview/charts';\nimport { useMergeRefs } from '@dynatrace/strato-components-preview/core';\n\nimport {\n BASE_LAYER_FILL_ID,\n BASE_LAYER_LINE_ID,\n DEFAULT_COUNTRIES_BORDER_COLOR,\n DEFAULT_COUNTRIES_FILL_COLOR,\n} from '../constants.js';\nimport { MapToolbar } from './toolbar/MapToolbar.js';\nimport { LayerIdsContext } from '../contexts/layer-ids.context.js';\nimport { useActiveInteraction } from '../hooks/use-active-interaction.js';\nimport { useHoverInteraction } from '../hooks/use-hover-interaction.js';\nimport { useInitialViewState } from '../hooks/use-initial-view-state.js';\nimport { useMapBaseLayerFeatures } from '../hooks/use-map-base-layer-features.js';\nimport { useMapConfig } from '../hooks/use-map-config.js';\nimport { useMapLoading } from '../hooks/use-map-loading.js';\nimport { useMapPerformance } from '../hooks/use-map-performance.js';\nimport { useOverlayEvents } from '../hooks/use-overlay-events.js';\nimport { useTooltipEventListeners } from '../hooks/use-tooltip-event-listeners.js';\nimport { defaultStyle } from '../map-styles/default-style.js';\nimport { MapViewImperativeHandler } from '../providers/imperative-handler.provider.js';\nimport type { MapViewProps, MapViewRef } from '../types/map-view.js';\nimport { getColorFromToken } from '../utils/get-color-from-token.js';\nimport { toMapBoxInitialViewState } from '../utils/to-mapbox-initial-view-state.js';\nimport { useSetMapInitialConfiguration } from '../utils/use-set-map-initial-configuration.js';\n\nconst lineLayer: LayerProps = {\n id: BASE_LAYER_LINE_ID,\n type: 'line',\n};\n\nconst fillLayer: LayerProps = {\n id: BASE_LAYER_FILL_ID,\n type: 'fill',\n};\n\nconst MapSource = () => {\n const baseLayerFeatures = useMapBaseLayerFeatures();\n return (\n <Source id=\"data\" type=\"geojson\" data={baseLayerFeatures}>\n <Layer\n {...fillLayer}\n paint={{\n 'fill-color': getColorFromToken(DEFAULT_COUNTRIES_FILL_COLOR),\n }}\n ></Layer>\n <Layer\n {...lineLayer}\n paint={{\n 'line-color': getColorFromToken(DEFAULT_COUNTRIES_BORDER_COLOR),\n }}\n ></Layer>\n </Source>\n );\n};\n\nconst MapInteractions = ({ children }: PropsWithChildren) => {\n useHoverInteraction();\n useActiveInteraction();\n\n return children;\n};\n\nexport const MapContent = forwardRef<\n MapViewRef,\n PropsWithChildren<MapViewProps>\n>((props, forwardedRef) => {\n const {\n initialViewState: initialViewStateProp,\n children,\n style,\n mapStyle = defaultStyle,\n onViewStateChange,\n ...remaining\n } = props;\n\n const loading = useMapLoading();\n\n const mapContainerRef = useRef<HTMLDivElement>(null);\n const mergedRefs = useMergeRefs<MapViewRef | HTMLDivElement>([\n mapContainerRef,\n forwardedRef,\n ]);\n\n useTooltipEventListeners();\n\n const { toolbar: toolbarConfig, interactions: interactionsConfig } =\n useMapConfig();\n const layerIds = useContext(LayerIdsContext);\n const shouldRenderToolbar =\n !isUndefined(toolbarConfig) || !isUndefined(interactionsConfig);\n\n const { height: graphHeight, width: graphWidth } = useGraphSize();\n\n const {\n handleMouseEnter,\n handleMouseMove,\n handleMouseLeave,\n handleMouseClick,\n handleZoom,\n handleDrag,\n } = useOverlayEvents();\n\n const initialViewState = useInitialViewState(initialViewStateProp);\n\n const { onLoadHandler, onRenderHandler } = useMapPerformance(mapContainerRef);\n\n return (\n <div\n data-testid=\"map-container\"\n ref={mergedRefs}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <Map\n onMove={(evt) => {\n onViewStateChange?.(evt.viewState);\n }}\n initialViewState={toMapBoxInitialViewState(initialViewState)}\n style={{\n width: graphWidth,\n height: `${graphHeight}px`,\n ...style,\n }}\n mapStyle={mapStyle}\n dragRotate={false}\n fadeDuration={0}\n RTLTextPlugin={false}\n renderWorldCopies={false}\n interactiveLayerIds={layerIds}\n onMouseMove={(e) => handleMouseMove(e as MapLayerMouseEvent)}\n onClick={(e) => handleMouseClick(e as MapLayerMouseEvent)}\n onZoom={handleZoom}\n onDrag={handleDrag}\n onRender={() => onRenderHandler && onRenderHandler()}\n onLoad={() => onLoadHandler && onLoadHandler()}\n ref={useSetMapInitialConfiguration()}\n interactive\n {...remaining}\n >\n <MapViewImperativeHandler\n forwardedRef={forwardedRef}\n containerRef={mapContainerRef}\n >\n <MapSource />\n {loading ? null : (\n <>\n <MapInteractions>{children}</MapInteractions>\n {shouldRenderToolbar ? <MapToolbar /> : null}\n </>\n )}\n </MapViewImperativeHandler>\n </Map>\n </div>\n );\n});\n\n(MapContent as typeof MapContent & { displayName: string }).displayName =\n 'MapContent';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAE5B,OAAO;AAAA,EACL;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,OAAwB,KAAK,cAAc;AAEpD,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AACxC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AACzC,SAAS,oBAAoB;AAC7B,SAAS,gCAAgC;AAEzC,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,SAAS,qCAAqC;AAE9C,MAAM,YAAwB;AAAA,EAC5B,IAAI;AAAA,EACJ,MAAM;AACR;AAEA,MAAM,YAAwB;AAAA,EAC5B,IAAI;AAAA,EACJ,MAAM;AACR;AAEA,MAAM,YAAY,MAAM;AACtB,QAAM,oB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AA,IAEd;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,CAAC,QAAQ;AACf,8BAAoB,IAAI,SAAS;AAAA,QACnC;AAAA,QACA,kBAAkB,yBAAyB,gBAAgB;AAAA,QAC3D,OAAO;AAAA,UACL,OAAO;AAAA,UACP,QAAQ,GAAG,WAAW;AAAA,UACtB,GAAG;AAAA,QACL;AAAA,QACA;AAAA,QACA,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,eAAe;AAAA,QACf,mBAAmB;AAAA,QACnB,qBAAqB;AAAA,QACrB,aAAa,CAAC,MAAM,gBAAgB,CAAuB;AAAA,QAC3D,SAAS,CAAC,MAAM,iBAAiB,CAAuB;AAAA,QACxD,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,UAAU,MAAM,mBAAmB,gBAAgB;AAAA,QACnD,QAAQ,MAAM,iBAAiB,cAAc;AAAA,QAC7C,KAAK,8BAA8B;AAAA,QACnC,aAAW;AAAA,QACV,GAAG;AAAA;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,cAAc;AAAA;AAAA,QAEd,oCAAC,eAAU;AAAA,QACV,UAAU,OACT,0DACE,oCAAC,uBAAiB,QAAS,GAC1B,sBAAsB,oCAAC,gBAAW,IAAK,IAC1C;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAEJ,CAAC;AAEA,WAA2D,cAC1D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { isUndefined } from "lodash-es";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import {
|
|
4
|
+
__RangeLegend as RangeLegend,
|
|
4
5
|
_buildQuantizedRangeItems as buildQuantizedRangeItems,
|
|
5
6
|
_getLegendOrientation as getLegendOrientation,
|
|
6
|
-
|
|
7
|
+
_getTickFormatterMethod as getTickFormatterMethod,
|
|
7
8
|
_useChartLayoutOrientation as useChartLayoutOrientation
|
|
8
9
|
} from "@dynatrace/strato-components-preview/charts";
|
|
9
|
-
import { DEFAULT_FORMATTER } from "../../constants.js";
|
|
10
10
|
import { useColorScale } from "../../hooks/use-color-scale.js";
|
|
11
|
+
const buildLegendTicks = (scale) => [
|
|
12
|
+
...scale.domain(),
|
|
13
|
+
...scale.thresholds()
|
|
14
|
+
];
|
|
11
15
|
const SequentialLegendRenderer = () => {
|
|
12
16
|
const { orientation: layoutOrientation } = useChartLayoutOrientation();
|
|
13
17
|
const scale = useColorScale();
|
|
@@ -17,12 +21,13 @@ const SequentialLegendRenderer = () => {
|
|
|
17
21
|
const orientation = getLegendOrientation(layoutOrientation);
|
|
18
22
|
const invertItems = orientation === "vertical";
|
|
19
23
|
const items = buildQuantizedRangeItems(scale, invertItems);
|
|
24
|
+
const domain = buildLegendTicks(scale);
|
|
20
25
|
return /* @__PURE__ */ React.createElement(
|
|
21
26
|
RangeLegend,
|
|
22
27
|
{
|
|
23
28
|
items,
|
|
24
29
|
orientation,
|
|
25
|
-
formatter:
|
|
30
|
+
formatter: getTickFormatterMethod(domain)
|
|
26
31
|
}
|
|
27
32
|
);
|
|
28
33
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/map/components/legend/SequentialLegendRenderer.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { ScaleQuantize } from 'd3-scale';\nimport { isUndefined } from 'lodash-es';\nimport React from 'react';\n\nimport {\n _buildQuantizedRangeItems as buildQuantizedRangeItems,\n _getLegendOrientation as getLegendOrientation,\n
|
|
5
|
-
"mappings": "AACA,SAAS,mBAAmB;AAC5B,OAAO,WAAW;AAElB;AAAA,EACE,6BAA6B;AAAA,EAC7B,yBAAyB;AAAA,EACzB,
|
|
4
|
+
"sourcesContent": ["import type { ScaleQuantize } from 'd3-scale';\nimport { isUndefined } from 'lodash-es';\nimport React from 'react';\n\nimport {\n __RangeLegend as RangeLegend,\n _buildQuantizedRangeItems as buildQuantizedRangeItems,\n _getLegendOrientation as getLegendOrientation,\n _getTickFormatterMethod as getTickFormatterMethod,\n _useChartLayoutOrientation as useChartLayoutOrientation,\n} from '@dynatrace/strato-components-preview/charts';\n\nimport { useColorScale } from '../../hooks/use-color-scale.js';\n\nconst buildLegendTicks = (scale: ScaleQuantize<string>) => [\n ...scale.domain(),\n ...scale.thresholds(),\n];\n\nexport const SequentialLegendRenderer = () => {\n const { orientation: layoutOrientation } = useChartLayoutOrientation();\n const scale = useColorScale() as ScaleQuantize<string>;\n\n if (isUndefined(scale)) {\n return null;\n }\n\n const orientation = getLegendOrientation(layoutOrientation);\n const invertItems = orientation === 'vertical';\n const items = buildQuantizedRangeItems(scale, invertItems);\n\n const domain = buildLegendTicks(scale);\n\n return (\n <RangeLegend\n items={items}\n orientation={orientation}\n formatter={getTickFormatterMethod(domain)}\n />\n );\n};\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,mBAAmB;AAC5B,OAAO,WAAW;AAElB;AAAA,EACE,iBAAiB;AAAA,EACjB,6BAA6B;AAAA,EAC7B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,8BAA8B;AAAA,OACzB;AAEP,SAAS,qBAAqB;AAE9B,MAAM,mBAAmB,CAAC,UAAiC;AAAA,EACzD,GAAG,MAAM,OAAO;AAAA,EAChB,GAAG,MAAM,WAAW;AACtB;AAEO,MAAM,2BAA2B,MAAM;AAC5C,QAAM,EAAE,aAAa,kBAAkB,IAAI,0BAA0B;AACrE,QAAM,QAAQ,cAAc;AAE5B,MAAI,YAAY,KAAK,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,qBAAqB,iBAAiB;AAC1D,QAAM,cAAc,gBAAgB;AACpC,QAAM,QAAQ,yBAAyB,OAAO,WAAW;AAEzD,QAAM,SAAS,iBAAiB,KAAK;AAErC,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,WAAW,uBAAuB,MAAM;AAAA;AAAA,EAC1C;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
_buildLegendItemsFromRange as buildLegendItemsFromRange,
|
|
4
4
|
_getLegendOrientation as getLegendOrientation,
|
|
5
|
-
|
|
5
|
+
__RangeLegend as RangeLegend,
|
|
6
6
|
_useChartLayoutOrientation as useChartLayoutOrientation
|
|
7
7
|
} from "@dynatrace/strato-components-preview/charts";
|
|
8
8
|
import { DEFAULT_FORMATTER } from "../../constants.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/map/components/legend/ThresholdLegendRenderer.tsx"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\n\nimport {\n _buildLegendItemsFromRange as buildLegendItemsFromRange,\n _getLegendOrientation as getLegendOrientation,\n
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;AAElB;AAAA,EACE,8BAA8B;AAAA,EAC9B,yBAAyB;AAAA,EACzB,
|
|
4
|
+
"sourcesContent": ["import React from 'react';\n\nimport {\n _buildLegendItemsFromRange as buildLegendItemsFromRange,\n _getLegendOrientation as getLegendOrientation,\n __RangeLegend as RangeLegend,\n _useChartLayoutOrientation as useChartLayoutOrientation,\n} from '@dynatrace/strato-components-preview/charts';\n\nimport { DEFAULT_FORMATTER } from '../../constants.js';\nimport { useMapConfig } from '../../hooks/use-map-config.js';\nimport type { ThresholdLegendConfig } from '../../types/legend.js';\n\nexport const ThresholdLegendRenderer = () => {\n const { orientation: layoutOrientation } = useChartLayoutOrientation();\n\n const { legend } = useMapConfig();\n\n const { ranges } = legend as ThresholdLegendConfig;\n\n const orientation = getLegendOrientation(layoutOrientation);\n const invertItems = orientation === 'vertical';\n const items = buildLegendItemsFromRange(ranges);\n invertItems && items.reverse();\n\n return (\n <RangeLegend\n items={items}\n orientation={orientation}\n formatter={DEFAULT_FORMATTER}\n />\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAElB;AAAA,EACE,8BAA8B;AAAA,EAC9B,yBAAyB;AAAA,EACzB,iBAAiB;AAAA,EACjB,8BAA8B;AAAA,OACzB;AAEP,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAGtB,MAAM,0BAA0B,MAAM;AAC3C,QAAM,EAAE,aAAa,kBAAkB,IAAI,0BAA0B;AAErE,QAAM,EAAE,OAAO,IAAI,aAAa;AAEhC,QAAM,EAAE,OAAO,IAAI;AAEnB,QAAM,cAAc,qBAAqB,iBAAiB;AAC1D,QAAM,cAAc,gBAAgB;AACpC,QAAM,QAAQ,0BAA0B,MAAM;AAC9C,iBAAe,MAAM,QAAQ;AAE7B,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA,WAAW;AAAA;AAAA,EACb;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/esm/map/constants.js
CHANGED
|
@@ -77,6 +77,10 @@ const COPY_TO_CLIPBOARD_MESSAGES = defineMessages({
|
|
|
77
77
|
description: "Text in a tooltip shown when hovering a tooltip item and hovering the copy button next to its coordinates"
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
+
const DEFAULT_BASE_LAYER_RULES = {
|
|
81
|
+
include: [INCLUDE_ALL_WILDCARD_RULE],
|
|
82
|
+
exclude: []
|
|
83
|
+
};
|
|
80
84
|
export {
|
|
81
85
|
ACTIVE_COLOR,
|
|
82
86
|
ACTIVE_STATE_BORDERS_WIDTH,
|
|
@@ -88,6 +92,7 @@ export {
|
|
|
88
92
|
BUBBLE_STROKE,
|
|
89
93
|
CDN_BASE_PATH,
|
|
90
94
|
COPY_TO_CLIPBOARD_MESSAGES,
|
|
95
|
+
DEFAULT_BASE_LAYER_RULES,
|
|
91
96
|
DEFAULT_BASIC_SHAPE_COLOR_TOKEN,
|
|
92
97
|
DEFAULT_BUBBLE_COLOR,
|
|
93
98
|
DEFAULT_CHOROPLETH_COLOR,
|
package/esm/map/constants.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/map/constants.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ExpressionSpecification } from '@maplibre/maplibre-gl-style-spec';\nimport { defineMessages } from 'react-intl';\n\nimport Colors from '@dynatrace/strato-design-tokens/colors';\n\n//region GENERAL\nexport const DEFAULT_COUNTRIES_FILL_COLOR = Colors.Theme.Neutral['50'];\nexport const DEFAULT_COUNTRIES_BORDER_COLOR = Colors.Background.Surface.Default;\nexport const TRANSPARENT_BORDER_COLOR = '#00000000';\nexport const MAX_LATITUDE = 90;\nexport const MIN_LATITUDE = -90;\nexport const MAX_LONGITUDE = 180;\nexport const MIN_LONGITUDE = -180;\nexport const WHOLE_WORLD_VIEW_BOUNDARIES: [number, number, number, number] = [\n MAX_LONGITUDE,\n MAX_LATITUDE,\n MIN_LONGITUDE,\n MIN_LATITUDE,\n];\nexport const DEFAULT_COUNTRY_CODE = 'default';\nexport const FIT_BOUNDS_OPTIONS = { padding: 20 };\nexport const DEFAULT_MAP_HEIGHT = 400;\nexport const DEFAULT_MAP_LEGEND_RATIO = 12;\nexport const DEFAULT_MAP_POSITION = 'auto';\nexport const DEFAULT_INPUT_ICON_SIZE = 20;\nexport const ACTIVE_COLOR = Colors.Border.Neutral.AccentActive;\n\nexport const BASE_LAYER_FILL_ID = 'geojson-fill';\nexport const BASE_LAYER_LINE_ID = 'geojson-line';\nexport const BASE_LAYER_IDS = [BASE_LAYER_LINE_ID, BASE_LAYER_FILL_ID];\nexport const SHAPE_OPACITY = 1;\nexport const DEFAULT_SYMBOL_SIZE = 32;\n\nexport const CDN_BASE_PATH =\n 'https://dt-cdn.net/scripts/data/worldmap/maps/v002/' as const;\nexport const INCLUDE_ALL_WILDCARD_RULE = '*' as const;\n//endregion\n\n//region LEGEND\nexport const DEFAULT_BASIC_SHAPE_COLOR_TOKEN =\n Colors.Charts.CategoricalThemed.PurpleRain.Color01;\nexport const DEFAULT_LEGEND_SIZES = {\n // Minimum size in which the legend can be resized (vertical layout)\n minWidth: 0.1,\n // Minimum size in which the legend can be resized (horizontal layout)\n minHeight: 0.1,\n // Maximum size in which the legend can be resized (vertical layout). 80% represent 4 / 5ths of the container.\n maxWidth: 0.8,\n // Maximum size in which the legend can be resized (horizontal layout). 80% represent 4 / 5ths of the container.\n maxHeight: 0.8,\n};\nexport const DEFAULT_FORMATTER = {\n maximumFractionDigits: 1,\n};\nexport const DEFAULT_RANGE_COLOR = Colors.Background.Container.Neutral.Accent;\nexport const LEGEND_DIM_OPACITY = 0.2;\nexport const DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE = 'blue';\n//endregion\n\n//region DOT LAYER\nexport const ICON_BACKGROUND_OPACITY = 0.7;\nexport const ICON_BACKGROUND_RADIUS = 16;\nexport const DEFAULT_ICON_BACKGROUND_COLOR =\n Colors.Background.Container.Neutral.Subdued;\nexport const DEFAULT_ICON_SIZE_RATIO = 0.6;\nexport const DEFAULT_SHAPE_COLOR = Colors.Charts.Categorical.Color15.Default;\nexport const DEFAULT_ICON_COLOR = Colors.Icon.Neutral.Default;\n//endregion\n\n//region BUBBLE LAYER\nexport const DEFAULT_BUBBLE_COLOR = Colors.Charts.Categorical.Color07.Default;\nexport const DEFAULT_RADIUS = 12;\nexport const BUBBLE_DEFAULT_OPACITY = 0.4;\nexport const BUBBLE_STROKE = 1;\nexport const BUBBLE_OUTLINE_STROKE = 1;\nexport const DEFAULT_RADIUS_EXPRESSION: ExpressionSpecification = [\n 'get',\n '__radius',\n];\n//endregion\n\n//region CONNECTION LAYER\nexport const DEFAULT_LINE_JOIN: 'bevel' | 'round' | 'miter' = 'miter';\nexport const DEFAULT_LINE_CAP: 'butt' | 'round' | 'square' = 'butt';\nexport const DEFAULT_LINE_THICKNESS = 2;\nexport const DEFAULT_LINE_COLOR = Colors.Charts.Categorical.Color03.Default;\nexport const DEFAULT_LINE_DASH_ARRAY = [5, 2.5];\nexport const MIN_LINE_THICKNESS = 1;\nexport const MAX_LINE_THICKNESS = 64;\nexport const DIRECTION_ICON_OUTPUT_SIZE = 128;\nexport const DIRECTION_ICON_SHRINK_RATIO = 1 / 15;\n//endregion\n\n//region CHOROPLETH LAYER\n\nexport const ACTIVE_STATE_BORDERS_WIDTH = 1.8;\n\nexport const DEFAULT_CHOROPLETH_COLOR =\n Colors.Charts.Sequential.Blue.Color05.Default;\n\nexport const COPY_TO_CLIPBOARD_MESSAGES = defineMessages({\n copyActionCoords: {\n id: 'g2qESM+ibB5sUyjf',\n defaultMessage: 'Copy coordinates',\n description:\n 'Text in a tooltip shown when hovering a tooltip item and hovering the copy button next to its coordinates',\n },\n});\n//endregion\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,sBAAsB;AAE/B,OAAO,YAAY;
|
|
4
|
+
"sourcesContent": ["import type { ExpressionSpecification } from '@maplibre/maplibre-gl-style-spec';\nimport { defineMessages } from 'react-intl';\n\nimport Colors from '@dynatrace/strato-design-tokens/colors';\n\nimport type { BaseLayerRules } from './types/base-layer.js';\n\n//region GENERAL\nexport const DEFAULT_COUNTRIES_FILL_COLOR = Colors.Theme.Neutral['50'];\nexport const DEFAULT_COUNTRIES_BORDER_COLOR = Colors.Background.Surface.Default;\nexport const TRANSPARENT_BORDER_COLOR = '#00000000';\nexport const MAX_LATITUDE = 90;\nexport const MIN_LATITUDE = -90;\nexport const MAX_LONGITUDE = 180;\nexport const MIN_LONGITUDE = -180;\nexport const WHOLE_WORLD_VIEW_BOUNDARIES: [number, number, number, number] = [\n MAX_LONGITUDE,\n MAX_LATITUDE,\n MIN_LONGITUDE,\n MIN_LATITUDE,\n];\nexport const DEFAULT_COUNTRY_CODE = 'default';\nexport const FIT_BOUNDS_OPTIONS = { padding: 20 };\nexport const DEFAULT_MAP_HEIGHT = 400;\nexport const DEFAULT_MAP_LEGEND_RATIO = 12;\nexport const DEFAULT_MAP_POSITION = 'auto';\nexport const DEFAULT_INPUT_ICON_SIZE = 20;\nexport const ACTIVE_COLOR = Colors.Border.Neutral.AccentActive;\n\nexport const BASE_LAYER_FILL_ID = 'geojson-fill';\nexport const BASE_LAYER_LINE_ID = 'geojson-line';\nexport const BASE_LAYER_IDS = [BASE_LAYER_LINE_ID, BASE_LAYER_FILL_ID];\nexport const SHAPE_OPACITY = 1;\nexport const DEFAULT_SYMBOL_SIZE = 32;\n\nexport const CDN_BASE_PATH =\n 'https://dt-cdn.net/scripts/data/worldmap/maps/v002/' as const;\nexport const INCLUDE_ALL_WILDCARD_RULE = '*' as const;\n//endregion\n\n//region LEGEND\nexport const DEFAULT_BASIC_SHAPE_COLOR_TOKEN =\n Colors.Charts.CategoricalThemed.PurpleRain.Color01;\nexport const DEFAULT_LEGEND_SIZES = {\n // Minimum size in which the legend can be resized (vertical layout)\n minWidth: 0.1,\n // Minimum size in which the legend can be resized (horizontal layout)\n minHeight: 0.1,\n // Maximum size in which the legend can be resized (vertical layout). 80% represent 4 / 5ths of the container.\n maxWidth: 0.8,\n // Maximum size in which the legend can be resized (horizontal layout). 80% represent 4 / 5ths of the container.\n maxHeight: 0.8,\n};\nexport const DEFAULT_FORMATTER = {\n maximumFractionDigits: 1,\n};\nexport const DEFAULT_RANGE_COLOR = Colors.Background.Container.Neutral.Accent;\nexport const LEGEND_DIM_OPACITY = 0.2;\nexport const DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE = 'blue';\n//endregion\n\n//region DOT LAYER\nexport const ICON_BACKGROUND_OPACITY = 0.7;\nexport const ICON_BACKGROUND_RADIUS = 16;\nexport const DEFAULT_ICON_BACKGROUND_COLOR =\n Colors.Background.Container.Neutral.Subdued;\nexport const DEFAULT_ICON_SIZE_RATIO = 0.6;\nexport const DEFAULT_SHAPE_COLOR = Colors.Charts.Categorical.Color15.Default;\nexport const DEFAULT_ICON_COLOR = Colors.Icon.Neutral.Default;\n//endregion\n\n//region BUBBLE LAYER\nexport const DEFAULT_BUBBLE_COLOR = Colors.Charts.Categorical.Color07.Default;\nexport const DEFAULT_RADIUS = 12;\nexport const BUBBLE_DEFAULT_OPACITY = 0.4;\nexport const BUBBLE_STROKE = 1;\nexport const BUBBLE_OUTLINE_STROKE = 1;\nexport const DEFAULT_RADIUS_EXPRESSION: ExpressionSpecification = [\n 'get',\n '__radius',\n];\n//endregion\n\n//region CONNECTION LAYER\nexport const DEFAULT_LINE_JOIN: 'bevel' | 'round' | 'miter' = 'miter';\nexport const DEFAULT_LINE_CAP: 'butt' | 'round' | 'square' = 'butt';\nexport const DEFAULT_LINE_THICKNESS = 2;\nexport const DEFAULT_LINE_COLOR = Colors.Charts.Categorical.Color03.Default;\nexport const DEFAULT_LINE_DASH_ARRAY = [5, 2.5];\nexport const MIN_LINE_THICKNESS = 1;\nexport const MAX_LINE_THICKNESS = 64;\nexport const DIRECTION_ICON_OUTPUT_SIZE = 128;\nexport const DIRECTION_ICON_SHRINK_RATIO = 1 / 15;\n//endregion\n\n//region CHOROPLETH LAYER\n\nexport const ACTIVE_STATE_BORDERS_WIDTH = 1.8;\n\nexport const DEFAULT_CHOROPLETH_COLOR =\n Colors.Charts.Sequential.Blue.Color05.Default;\n\nexport const COPY_TO_CLIPBOARD_MESSAGES = defineMessages({\n copyActionCoords: {\n id: 'g2qESM+ibB5sUyjf',\n defaultMessage: 'Copy coordinates',\n description:\n 'Text in a tooltip shown when hovering a tooltip item and hovering the copy button next to its coordinates',\n },\n});\n//endregion\n\n//region BASE LAYER RULES\nexport const DEFAULT_BASE_LAYER_RULES = {\n include: [INCLUDE_ALL_WILDCARD_RULE],\n exclude: [],\n} as const as BaseLayerRules;\n\n//endregion\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,sBAAsB;AAE/B,OAAO,YAAY;AAKZ,MAAM,+BAA+B,OAAO,MAAM,QAAQ,IAAI;AAC9D,MAAM,iCAAiC,OAAO,WAAW,QAAQ;AACjE,MAAM,2BAA2B;AACjC,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,gBA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C7D,MAAM,0BAA0B,CAAC,GAAG,GAAG;AACvC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,6BAA6B;AACnC,MAAM,8BAA8B,IAAI;AAKxC,MAAM,6BAA6B;AAEnC,MAAM,2BACX,OAAO,OAAO,WAAW,KAAK,QAAQ;AAEjC,MAAM,6BAA6B,eAAe;AAAA,EACvD,kBAAkB;AAAA,IAChB,IAAI;AAAA,IACJ,gBAAgB;AAAA,IAChB,aACE;AAAA,EACJ;AACF,CAAC;AAIM,MAAM,2BAA2B;AAAA,EACtC,SAAS,CAAC,yBAAyB;AAAA,EACnC,SAAS,CAAC;AACZ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { DEFAULT_BASE_LAYER_RULES } from "../constants.js";
|
|
2
3
|
const MapConfigurationContext = React.createContext({
|
|
3
4
|
toolbar: void 0,
|
|
4
5
|
interactions: void 0,
|
|
5
6
|
legend: void 0,
|
|
6
|
-
baseLayer:
|
|
7
|
+
baseLayer: DEFAULT_BASE_LAYER_RULES
|
|
7
8
|
});
|
|
8
9
|
export {
|
|
9
10
|
MapConfigurationContext
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/contexts/map-configuration.context.ts"],
|
|
4
|
-
"sourcesContent": ["import React from 'react';\n\nimport type { MapConfig } from '../types/configuration.js';\n\nexport const MapConfigurationContext = React.createContext<MapConfig>({\n toolbar: undefined,\n interactions: undefined,\n legend: undefined,\n baseLayer:
|
|
5
|
-
"mappings": "AAAA,OAAO,WAAW;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\n\nimport { DEFAULT_BASE_LAYER_RULES } from '../constants.js';\nimport type { MapConfig } from '../types/configuration.js';\n\nexport const MapConfigurationContext = React.createContext<MapConfig>({\n toolbar: undefined,\n interactions: undefined,\n legend: undefined,\n baseLayer: DEFAULT_BASE_LAYER_RULES,\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAElB,SAAS,gCAAgC;AAGlC,MAAM,0BAA0B,MAAM,cAAyB;AAAA,EACpE,SAAS;AAAA,EACT,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,WAAW;AACb,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/map/contexts/map-loading.context.ts"],
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react';\n\nexport const MapLoadingContext = createContext<boolean | undefined>(undefined);\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAEvB,MAAM,oBAAoB,cAAmC,MAAS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { INCLUDE_ALL_WILDCARD_RULE } from "../constants.js";
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
2
|
import { applyFeatureFilterRules } from "../utils/apply-feature-filter-rules.js";
|
|
4
3
|
import {
|
|
5
4
|
getCountryRegionsRules,
|
|
@@ -14,33 +13,28 @@ import { getBaseLayerShapesRequestConfig } from "../utils/get-base-layer-shapes-
|
|
|
14
13
|
import { getClientSettings } from "../utils/get-client-settings.js";
|
|
15
14
|
import { getTenantCountryCode } from "../utils/get-tenant-country-code.js";
|
|
16
15
|
import { mergeFeatureCollections } from "../utils/merge-feature-collections.js";
|
|
17
|
-
const DEFAULT_BASE_LAYER_RULES = {
|
|
18
|
-
include: [INCLUDE_ALL_WILDCARD_RULE],
|
|
19
|
-
exclude: []
|
|
20
|
-
};
|
|
21
16
|
const useLoadMapBaseLayer = (baseLayerConfig) => {
|
|
22
17
|
const [isLoading, setIsLoading] = useState(true);
|
|
23
18
|
const [isMapEnabled, setIsMapEnabled] = useState(false);
|
|
24
19
|
const [baseFeatureCollection, setBaseFeatureCollection] = useState(void 0);
|
|
25
|
-
const baseLayerRules = baseLayerConfig ?? DEFAULT_BASE_LAYER_RULES;
|
|
26
20
|
const [error, setError] = useState(false);
|
|
27
|
-
const getData = async () => {
|
|
21
|
+
const getData = useCallback(async () => {
|
|
28
22
|
setIsLoading(true);
|
|
29
23
|
const isMapEnabledResponse = await getClientSettings();
|
|
30
24
|
if (isMapEnabledResponse) {
|
|
31
25
|
setIsMapEnabled(isMapEnabledResponse);
|
|
32
26
|
getTenantCountryCode().then((tenantCountryCode) => {
|
|
33
|
-
const { includeWorldView, countryRegions } = getBaseLayerShapesRequestConfig(
|
|
27
|
+
const { includeWorldView, countryRegions } = getBaseLayerShapesRequestConfig(baseLayerConfig.include);
|
|
34
28
|
const featuresRequests = [];
|
|
35
29
|
if (includeWorldView) {
|
|
36
|
-
const worldViewRules = getWorldViewRules(
|
|
30
|
+
const worldViewRules = getWorldViewRules(baseLayerConfig);
|
|
37
31
|
const worldViewRequest = fetchWorldViewFeatures(
|
|
38
32
|
tenantCountryCode
|
|
39
33
|
).then(applyFeatureFilterRules(worldViewRules));
|
|
40
34
|
featuresRequests.push(worldViewRequest);
|
|
41
35
|
}
|
|
42
36
|
if (countryRegions.length > 0) {
|
|
43
|
-
const regionsRules = getRegionsRules(
|
|
37
|
+
const regionsRules = getRegionsRules(baseLayerConfig);
|
|
44
38
|
countryRegions.forEach((countryCode) => {
|
|
45
39
|
const countryRules = getCountryRegionsRules(
|
|
46
40
|
regionsRules,
|
|
@@ -62,10 +56,10 @@ const useLoadMapBaseLayer = (baseLayerConfig) => {
|
|
|
62
56
|
}).finally(() => setIsLoading(false));
|
|
63
57
|
});
|
|
64
58
|
}
|
|
65
|
-
};
|
|
59
|
+
}, [baseLayerConfig.include, baseLayerConfig.exclude]);
|
|
66
60
|
useEffect(() => {
|
|
67
61
|
getData();
|
|
68
|
-
}, []);
|
|
62
|
+
}, [getData]);
|
|
69
63
|
return { isLoading, baseFeatureCollection, isMapEnabled, error };
|
|
70
64
|
};
|
|
71
65
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/map/hooks/use-load-map-base-layer.ts"],
|
|
4
|
-
"sourcesContent": ["import { FeatureCollection } from 'geojson';\nimport { useEffect, useState } from 'react';\n\nimport
|
|
5
|
-
"mappings": "AACA,SAAS,WAAW,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import { FeatureCollection } from 'geojson';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport type { BaseLayerRules } from '../types/base-layer.js';\nimport { applyFeatureFilterRules } from '../utils/apply-feature-filter-rules.js';\nimport {\n getCountryRegionsRules,\n getRegionsRules,\n getWorldViewRules,\n} from '../utils/base-layer-rules.js';\nimport {\n fetchCountryFeatures,\n fetchWorldViewFeatures,\n} from '../utils/fetch-base-layer-features.js';\nimport { getBaseLayerShapesRequestConfig } from '../utils/get-base-layer-shapes-request-config.js';\nimport { getClientSettings } from '../utils/get-client-settings.js';\nimport { getTenantCountryCode } from '../utils/get-tenant-country-code.js';\nimport { mergeFeatureCollections } from '../utils/merge-feature-collections.js';\n\nexport const useLoadMapBaseLayer = (baseLayerConfig: BaseLayerRules) => {\n const [isLoading, setIsLoading] = useState(true);\n const [isMapEnabled, setIsMapEnabled] = useState(false);\n const [baseFeatureCollection, setBaseFeatureCollection] = useState<\n FeatureCollection | undefined\n >(undefined);\n const [error, setError] = useState<boolean>(false);\n\n const getData = useCallback(async () => {\n setIsLoading(true);\n const isMapEnabledResponse = await getClientSettings();\n\n if (isMapEnabledResponse) {\n setIsMapEnabled(isMapEnabledResponse);\n getTenantCountryCode().then((tenantCountryCode: string) => {\n const { includeWorldView, countryRegions } =\n getBaseLayerShapesRequestConfig(baseLayerConfig.include);\n const featuresRequests: Promise<FeatureCollection>[] = [];\n\n if (includeWorldView) {\n const worldViewRules = getWorldViewRules(baseLayerConfig);\n const worldViewRequest = fetchWorldViewFeatures(\n tenantCountryCode,\n ).then(applyFeatureFilterRules(worldViewRules));\n featuresRequests.push(worldViewRequest);\n }\n\n if (countryRegions.length > 0) {\n const regionsRules = getRegionsRules(baseLayerConfig);\n countryRegions.forEach((countryCode: string) => {\n const countryRules = getCountryRegionsRules(\n regionsRules,\n countryCode,\n );\n const countryRequest = fetchCountryFeatures(\n tenantCountryCode,\n countryCode,\n ).then(applyFeatureFilterRules(countryRules, countryCode));\n featuresRequests.push(countryRequest);\n });\n }\n\n Promise.all(featuresRequests)\n .then((featureCollections) => {\n setBaseFeatureCollection(\n mergeFeatureCollections(featureCollections),\n );\n })\n .catch(() => {\n setError(true);\n })\n .finally(() => setIsLoading(false));\n });\n }\n }, [baseLayerConfig.include, baseLayerConfig.exclude]);\n\n useEffect(() => {\n getData();\n }, [getData]);\n return { isLoading, baseFeatureCollection, isMapEnabled, error };\n};\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,aAAa,WAAW,gBAAgB;AAGjD,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,uCAAuC;AAChD,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AAEjC,MAAM,sBAAsB,CAAC,oBAAoC;AACtE,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AACtD,QAAM,CAAC,uBAAuB,wBAAwB,IAAI,SAExD,MAAS;AACX,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkB,KAAK;AAEjD,QAAM,UAAU,YAAY,YAAY;AACtC,iBAAa,IAAI;AACjB,UAAM,uBAAuB,MAAM,kBAAkB;AAErD,QAAI,sBAAsB;AACxB,sBAAgB,oBAAoB;AACpC,2BAAqB,EAAE,KAAK,CAAC,sBAA8B;AACzD,cAAM,EAAE,kBAAkB,eAAe,IACvC,gCAAgC,gBAAgB,OAAO;AACzD,cAAM,mBAAiD,CAAC;AAExD,YAAI,kBAAkB;AACpB,gBAAM,iBAAiB,kBAAkB,eAAe;AACxD,gBAAM,mBAAmB;AAAA,YACvB;AAAA,UACF,EAAE,KAAK,wBAAwB,cAAc,CAAC;AAC9C,2BAAiB,KAAK,gBAAgB;AAAA,QACxC;AAEA,YAAI,eAAe,SAAS,GAAG;AAC7B,gBAAM,eAAe,gBAAgB,eAAe;AACpD,yBAAe,QAAQ,CAAC,gBAAwB;AAC9C,kBAAM,eAAe;AAAA,cACnB;AAAA,cACA;AAAA,YACF;AACA,kBAAM,iBAAiB;AAAA,cACrB;AAAA,cACA;AAAA,YACF,EAAE,KAAK,wBAAwB,cAAc,WAAW,CAAC;AACzD,6BAAiB,KAAK,cAAc;AAAA,UACtC,CAAC;AAAA,QACH;AAEA,gBAAQ,IAAI,gBAAgB,EACzB,KAAK,CAAC,uBAAuB;AAC5B;AAAA,YACE,wBAAwB,kBAAkB;AAAA,UAC5C;AAAA,QACF,CAAC,EACA,MAAM,MAAM;AACX,mBAAS,IAAI;AAAA,QACf,CAAC,EACA,QAAQ,MAAM,aAAa,KAAK,CAAC;AAAA,MACtC,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,gBAAgB,SAAS,gBAAgB,OAAO,CAAC;AAErD,YAAU,MAAM;AACd,YAAQ;AAAA,EACV,GAAG,CAAC,OAAO,CAAC;AACZ,SAAO,EAAE,WAAW,uBAAuB,cAAc,MAAM;AACjE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/map/hooks/use-map-loading.ts"],
|
|
4
|
+
"sourcesContent": ["import { useContext } from 'react';\n\nimport { MapLoadingContext } from '../contexts/map-loading.context.js';\n\nexport const useMapLoading = () => useContext(MapLoadingContext);\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,yBAAyB;AAE3B,MAAM,gBAAgB,MAAM,WAAW,iBAAiB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|