@dynatrace/strato-geo 1.7.2 → 1.8.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.
@@ -26,6 +26,7 @@ import { ColorScaleProvider } from "./providers/color-scale.provider.js";
26
26
  import { LayerColorStrategyProvider } from "./providers/layer-color-strategy.provider.js";
27
27
  import { ErrorStateSlot } from "./slots/states/ErrorStateSlot.js";
28
28
  import { MapStoreProvider } from "./store/map-store.provider.js";
29
+ import { isThresholdLegend } from "./utils/build-scale-from-legend-config.js";
29
30
  import { extractLayersData } from "./utils/extract-layers-data.js";
30
31
  import { getMapStatesTemplates } from "./utils/get-map-states-template.js";
31
32
  import { iterateConfigSlots } from "./utils/iterate-config-slots.js";
@@ -49,6 +50,13 @@ const _MapView = forwardRef(
49
50
  legendDomain
50
51
  } = extractLayersData(parsedChildren, valueAccessors);
51
52
  const config = iterateConfigSlots(children, legendDomain);
53
+ const getMaxRange = () => {
54
+ if (config.legend && isThresholdLegend(config.legend)) {
55
+ return config.legend.ranges.at(-1)?.to ?? legendDomain[1];
56
+ }
57
+ return legendDomain[1];
58
+ };
59
+ const dataMax = getMaxRange();
52
60
  const isLegendHidden = !config.legend || !!config.legend.hidden;
53
61
  const legendPosition = config.legend?.position;
54
62
  const legendRatio = config.legend?.ratio;
@@ -90,7 +98,7 @@ const _MapView = forwardRef(
90
98
  ColorScaleProvider,
91
99
  {
92
100
  categories,
93
- dataMax: legendDomain[1],
101
+ dataMax,
94
102
  children: /* @__PURE__ */ jsx(LayerColorStrategyProvider, { children: /* @__PURE__ */ jsxs(
95
103
  ChartLayout,
96
104
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/map/MapView.tsx"],
4
- "sourcesContent": ["import { forwardRef, type PropsWithChildren, useState } 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 {\n DEFAULT_LEGEND_SIZES,\n DEFAULT_MAP_HEIGHT,\n DEFAULT_TRUNCATION_MODE,\n MAP_VIEW_ARIA_LABEL,\n} from './constants.js';\nimport { FormatterContext } from './contexts/formatter.context.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 { MapLoadingContext } from './contexts/map-loading.context.js';\nimport { MapRawDataContext } from './contexts/map-raw-data.context.js';\nimport { MapTruncationModeContext } from './contexts/map-truncation-mode.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 { 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\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 formatter,\n truncationMode,\n ...remaining\n } = props;\n const { layerIds, parsedChildren, valueAccessors } = setLayersId(children);\n\n const {\n flattenData: layersData,\n categories,\n legendDomain,\n } = extractLayersData(parsedChildren, valueAccessors);\n\n const config = iterateConfigSlots(children, legendDomain);\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, isFetchingFeatures, baseFeatureCollection, error } =\n useLoadMapBaseLayer(config.baseLayer);\n\n const [isMapLoaded, setIsMapLoaded] = useState<boolean>(false);\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 = (!isFetchingFeatures && !isMapEnabled) || error;\n\n const isLoading = isFetchingFeatures || !isMapLoaded;\n\n return (\n <div\n style={containerStyles}\n className={customerClassNames}\n data-testid=\"mapview-container\"\n role=\"img\"\n aria-label={MAP_VIEW_ARIA_LABEL}\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 isFetchingFeatures={isFetchingFeatures}\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 <MapTruncationModeContext.Provider\n value={truncationMode ?? DEFAULT_TRUNCATION_MODE}\n >\n <FormatterContext.Provider value={formatter}>\n <MapRawDataContext.Provider value={layersData}>\n <MapStoreProvider>\n <ColorScaleProvider\n categories={categories}\n dataMax={legendDomain[1]}\n >\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 onMapLoad={() => setIsMapLoaded(true)}\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 </MapRawDataContext.Provider>\n </FormatterContext.Provider>\n </MapTruncationModeContext.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 * @public\n */\nexport const MapView = Object.assign(_MapView, {\n ErrorState: ErrorStateSlot,\n});\n"],
5
- "mappings": "AA6FY,cAwBoB,YAxBpB;AA7FZ,SAAS,YAAoC,gBAAgB;AAE7D;AAAA,EACE,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,yBAAyB;AAAA,OACpB;AAEP,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,mCAAmC;AAC5C,SAAS,+BAA+B;AACxC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AAEjC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAG5B,OAAO;AAKP,MAAM,WAAW;AAAA,EACf,CAAC,OAAO,iBAAiB;AACvB,UAAM;AAAA,MACJ;A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,gBAAgB,UAAhB,EAAyB,OAAO,UAC/B;AAAA,cAAC,yBAAyB;AAAA,cAAzB;AAAA,gBACC,OAAO,kBAAkB;AAAA,gBAEzB,8BAAC,iBAAiB,UAAjB,EAA0B,OAAO,WAChC,8BAAC,kBAAkB,UAAlB,EAA2B,OAAO,YACjC,8BAAC,oBACC;AAAA,kBAAC;AAAA;AAAA,oBACC;AAAA,oBACA,SAAS,aAAa,CAAC;AAAA,oBAEvB,8BAAC,8BACC;AAAA,sBAAC;AAAA;AAAA,wBACC,KAAK;AAAA,wBACL;AAAA,wBACA;AAAA,wBACA,YAAY,WAAW;AAAA,wBAEvB;AAAA,8CAAC,YAAY,OAAZ,EACE,mCACC;AAAA,4BAAC;AAAA;AAAA,8BACC,KAAK;AAAA,8BACL,WAAW,MAAM,eAAe,IAAI;AAAA,8BACnC,GAAG;AAAA,8BAEH;AAAA;AAAA,0BACH,GAEJ;AAAA,0BACC,CAAC,kBACA;AAAA,4BAAC,YAAY;AAAA,4BAAZ;AAAA,8BACC,UAAU;AAAA,8BACV,OAAO;AAAA,8BACP,iBAAiB;AAAA,8BACjB,UAAU;AAAA,8BAEV,8BAAC,qBAAkB;AAAA;AAAA,0BACrB;AAAA;AAAA;AAAA,oBAEJ,GACF;AAAA;AAAA,gBACF,GACF,GACF,GACF;AAAA;AAAA,YACF,GACF,GACF;AAAA;AAAA,QACF,GACF;AAAA;AAAA,IAGN;AAAA,EAEJ;AACF;AAEC,SAAuD,aAAa,IACnE;AAMK,MAAM,UAAU,OAAO,OAAO,UAAU;AAAA,EAC7C,YAAY;AACd,CAAC;",
4
+ "sourcesContent": ["import { forwardRef, type PropsWithChildren, useState } 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 {\n DEFAULT_LEGEND_SIZES,\n DEFAULT_MAP_HEIGHT,\n DEFAULT_TRUNCATION_MODE,\n MAP_VIEW_ARIA_LABEL,\n} from './constants.js';\nimport { FormatterContext } from './contexts/formatter.context.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 { MapLoadingContext } from './contexts/map-loading.context.js';\nimport { MapRawDataContext } from './contexts/map-raw-data.context.js';\nimport { MapTruncationModeContext } from './contexts/map-truncation-mode.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 { isThresholdLegend } from './utils/build-scale-from-legend-config.js';\nimport { extractLayersData } from './utils/extract-layers-data.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';\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 formatter,\n truncationMode,\n ...remaining\n } = props;\n const { layerIds, parsedChildren, valueAccessors } = setLayersId(children);\n\n const {\n flattenData: layersData,\n categories,\n legendDomain,\n } = extractLayersData(parsedChildren, valueAccessors);\n\n const config = iterateConfigSlots(children, legendDomain);\n\n const getMaxRange = (): number => {\n if (config.legend && isThresholdLegend(config.legend)) {\n return config.legend.ranges.at(-1)?.to ?? legendDomain[1];\n }\n return legendDomain[1];\n };\n\n const dataMax = getMaxRange();\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, isFetchingFeatures, baseFeatureCollection, error } =\n useLoadMapBaseLayer(config.baseLayer);\n\n const [isMapLoaded, setIsMapLoaded] = useState<boolean>(false);\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 = (!isFetchingFeatures && !isMapEnabled) || error;\n\n const isLoading = isFetchingFeatures || !isMapLoaded;\n\n return (\n <div\n style={containerStyles}\n className={customerClassNames}\n data-testid=\"mapview-container\"\n role=\"img\"\n aria-label={MAP_VIEW_ARIA_LABEL}\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 isFetchingFeatures={isFetchingFeatures}\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 <MapTruncationModeContext.Provider\n value={truncationMode ?? DEFAULT_TRUNCATION_MODE}\n >\n <FormatterContext.Provider value={formatter}>\n <MapRawDataContext.Provider value={layersData}>\n <MapStoreProvider>\n <ColorScaleProvider\n categories={categories}\n dataMax={dataMax}\n >\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 onMapLoad={() => setIsMapLoaded(true)}\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 </MapRawDataContext.Provider>\n </FormatterContext.Provider>\n </MapTruncationModeContext.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 * @public\n */\nexport const MapView = Object.assign(_MapView, {\n ErrorState: ErrorStateSlot,\n});\n"],
5
+ "mappings": "AAqGY,cAwBoB,YAxBpB;AArGZ,SAAS,YAAoC,gBAAgB;AAE7D;AAAA,EACE,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,yBAAyB;AAAA,OACpB;AAEP,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,mCAAmC;AAC5C,SAAS,+BAA+B;AACxC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AAEjC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAC5B,OAAO;AAKP,MAAM,WAAW;A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CAAC;",
6
6
  "names": []
7
7
  }
@@ -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 type { _TruncationMode as TruncationMode } from '@dynatrace/strato-components/typography';\nimport Colors from '@dynatrace/strato-design-tokens/colors';\n\nimport type { BaseLayerRules } from './types/base-layer.js';\nimport type { BoundingBoxCoords } from './types/map-view.js';\n\n//region GENERAL\nexport const DEFAULT_COUNTRIES_FILL_COLOR =\n Colors.Background.Container.Neutral.Default;\nexport const DEFAULT_BOUNDARIES_BORDER_COLOR = Colors.Border.Neutral.Default;\nexport const COUNTRY_BORDER_WIDTH = 1;\nexport const REGION_BORDER_WIDTH = 0.4;\nexport const TRANSPARENT_BORDER_COLOR = '#00000000';\n\n// region Map max bounds:\n// These bounds hide the space used by Antarctica and some portion of the North Pole\nexport const MAX_LATITUDE = 85;\nexport const MIN_LATITUDE = -60;\nexport const MAX_LONGITUDE = 179.99;\nexport const MIN_LONGITUDE = -179.99;\n// endregion\n\nexport const WORLD_VIEW_MAX_BOUNDARIES: BoundingBoxCoords = [\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 = 'auto';\nexport const DEFAULT_MAP_POSITION = 'auto';\nexport const DEFAULT_INPUT_ICON_SIZE = 20;\nexport const ACTIVE_COLOR = Colors.Border.Neutral.Accent;\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_DEFAULT = 1;\nexport const SHAPE_OPACITY_DIMMED = 0.2;\n\nexport const DEFAULT_SYMBOL_SIZE = 32;\nexport const FALLBACK_SYMBOL_SIZE = 1;\nexport const DEFAULT_TRUNCATION_MODE = 'middle' as TruncationMode;\n\nexport const CDN_BASE_PATH =\n 'https://dt-cdn.net/scripts/data/worldmap/maps/v004/' 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 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\nexport const ACTIVE_BORDER_WIDTH_OUTER = 3;\nexport const ACTIVE_BORDER_WIDTH_INNER = 1;\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\n//region Zoom state comparison precision\nexport const BOUNDING_BOX_PRECISION = 6;\nexport const VIEW_STATE_PRECISION = 4;\nexport const MAX_BOUNDS_PRECISION = 2;\n//endregion\n\nexport const MAP_VIEW_ARIA_LABEL = 'Map View';\n"],
4
+ "sourcesContent": ["import type { ExpressionSpecification } from '@maplibre/maplibre-gl-style-spec';\nimport { defineMessages } from 'react-intl';\n\nimport type { TruncationMode } from '@dynatrace/strato-components/typography';\nimport Colors from '@dynatrace/strato-design-tokens/colors';\n\nimport type { BaseLayerRules } from './types/base-layer.js';\nimport type { BoundingBoxCoords } from './types/map-view.js';\n\n//region GENERAL\nexport const DEFAULT_COUNTRIES_FILL_COLOR =\n Colors.Background.Container.Neutral.Default;\nexport const DEFAULT_BOUNDARIES_BORDER_COLOR = Colors.Border.Neutral.Default;\nexport const COUNTRY_BORDER_WIDTH = 1;\nexport const REGION_BORDER_WIDTH = 0.4;\nexport const TRANSPARENT_BORDER_COLOR = '#00000000';\n\n// region Map max bounds:\n// These bounds hide the space used by Antarctica and some portion of the North Pole\nexport const MAX_LATITUDE = 85;\nexport const MIN_LATITUDE = -60;\nexport const MAX_LONGITUDE = 179.99;\nexport const MIN_LONGITUDE = -179.99;\n// endregion\n\nexport const WORLD_VIEW_MAX_BOUNDARIES: BoundingBoxCoords = [\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 = 'auto';\nexport const DEFAULT_MAP_POSITION = 'auto';\nexport const DEFAULT_INPUT_ICON_SIZE = 20;\nexport const ACTIVE_COLOR = Colors.Border.Neutral.Accent;\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_DEFAULT = 1;\nexport const SHAPE_OPACITY_DIMMED = 0.2;\n\nexport const DEFAULT_SYMBOL_SIZE = 32;\nexport const FALLBACK_SYMBOL_SIZE = 1;\nexport const DEFAULT_TRUNCATION_MODE = 'middle' as TruncationMode;\n\nexport const CDN_BASE_PATH =\n 'https://dt-cdn.net/scripts/data/worldmap/maps/v004/' 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 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\nexport const ACTIVE_BORDER_WIDTH_OUTER = 3;\nexport const ACTIVE_BORDER_WIDTH_INNER = 1;\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\n//region Zoom state comparison precision\nexport const BOUNDING_BOX_PRECISION = 6;\nexport const VIEW_STATE_PRECISION = 4;\nexport const MAX_BOUNDS_PRECISION = 2;\n//endregion\n\nexport const MAP_VIEW_ARIA_LABEL = 'Map View';\n"],
5
5
  "mappings": "AACA,SAAS,sBAAsB;AAG/B,OAAO,YAAY;AAMZ,MAAM,+BACX,OAAO,WAAW,UAAU,QAAQ;AAC/B,MAAM,kCAAkC,OAAO,OAAO,QAAQ;AAC9D,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;AAC5B,MAAM,2BAA2B;AAIjC,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,gBAAgB;AAGtB,MAAM,4BAA+C;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACO,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB,EAAE,SAAS,GAAG;AACzC,MAAM,qBAA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AAIxC,MAAM,4BAA4B;AAClC,MAAM,4BAA4B;AAElC,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;AAKO,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAG7B,MAAM,sBAAsB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/contexts/map-truncation-mode.context.ts"],
4
- "sourcesContent": ["import { createContext } from 'react';\n\nimport type { _TruncationMode as TruncationMode } from '@dynatrace/strato-components/typography';\n\nimport { DEFAULT_TRUNCATION_MODE } from '../constants.js';\n\nexport const MapTruncationModeContext = createContext<TruncationMode>(\n DEFAULT_TRUNCATION_MODE,\n);\n"],
4
+ "sourcesContent": ["import { createContext } from 'react';\n\nimport type { TruncationMode } from '@dynatrace/strato-components/typography';\n\nimport { DEFAULT_TRUNCATION_MODE } from '../constants.js';\n\nexport const MapTruncationModeContext = createContext<TruncationMode>(\n DEFAULT_TRUNCATION_MODE,\n);\n"],
5
5
  "mappings": "AAAA,SAAS,qBAAqB;AAI9B,SAAS,+BAA+B;AAEjC,MAAM,2BAA2B;AAAA,EACtC;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/hooks/use-active-interaction.ts"],
4
- "sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { isNil, isUndefined } from 'lodash-es';\nimport type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useCallback, useEffect } from 'react';\n\nimport { BASE_LAYER_IDS } from '../constants.js';\nimport { getMinValueFeature } from '../utils/get-min-value-feature.js';\n\nexport const useActiveInteraction = () => {\n const map = useMap().current!;\n\n let featureId: string | number | undefined;\n let sourceId: string | undefined;\n const handleClick = useCallback(\n ({ point }: MapLayerMouseEvent) => {\n const features = map.queryRenderedFeatures(point);\n const allFeatures = map.queryRenderedFeatures();\n\n const layerId = features?.[0]?.layer?.id;\n\n const hasHoveredFeatures =\n !isNil(features) && features.length > 0 && !isUndefined(layerId);\n const isBaseLayer = BASE_LAYER_IDS.includes(layerId);\n\n if (hasHoveredFeatures && !isBaseLayer) {\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // if there's already an active feature, remove the active state\n map.setFeatureState(\n { source: sourceId, id: featureId },\n { active: false },\n );\n }\n\n const minFeature = getMinValueFeature(features);\n\n featureId = minFeature.id;\n sourceId = minFeature.layer.source;\n const activeState = features[0].state.active;\n\n // add the active state to the closest feature\n map.setFeatureState(\n { source: sourceId, id: featureId },\n { active: !activeState },\n );\n allFeatures.forEach((feature) => {\n if (feature.id !== undefined && feature.layer.source !== undefined) {\n map.setFeatureState(\n { source: feature.layer.source, id: feature.id },\n { isAnyActive: !activeState },\n );\n }\n }); //TODO: change to inactive\n } else {\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // remove the active state from the last active feature\n map.setFeatureState(\n { source: sourceId, id: featureId },\n { active: false },\n );\n allFeatures.forEach((feature) => {\n if (\n feature.id !== undefined &&\n feature.layer.source !== undefined\n ) {\n map.setFeatureState(\n { source: feature.layer.source, id: feature.id },\n { isAnyActive: false },\n );\n }\n });\n }\n }\n },\n [featureId, sourceId, map],\n );\n\n useEffect(() => {\n map.on('click', handleClick);\n return () => {\n map.off('click', handleClick);\n };\n }, []);\n};\n"],
5
- "mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,OAAO,mBAAmB;AAEnC,SAAS,aAAa,iBAAiB;AAEvC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAE5B,MAAM,uBAAuB,MAAM;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ACE,QAAQ,OAAO,UACf,QAAQ,MAAM,WAAW,QACzB;AACA,kBAAI;AAAA,gBACF,EAAE,QAAQ,QAAQ,MAAM,QAAQ,IAAI,QAAQ,GAAG;AAAA,gBAC/C,EAAE,aAAa,MAAM;AAAA,cACvB;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,UAAU,GAAG;AAAA,EAC3B;AAEA,YAAU,MAAM;AACd,QAAI,GAAG,SAAS,WAAW;AAC3B,WAAO,MAAM;AACX,UAAI,IAAI,SAAS,WAAW;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,CAAC;AACP;",
4
+ "sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { isNil, isUndefined } from 'lodash-es';\nimport type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useCallback, useEffect } from 'react';\n\nimport { BASE_LAYER_IDS } from '../constants.js';\nimport { getMinValueFeature } from '../utils/get-min-value-feature.js';\n\nexport const useActiveInteraction = () => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const map = useMap().current!;\n\n let featureId: string | number | undefined;\n let sourceId: string | undefined;\n const handleClick = useCallback(\n ({ point }: MapLayerMouseEvent) => {\n const features = map.queryRenderedFeatures(point);\n const allFeatures = map.queryRenderedFeatures();\n\n const layerId = features?.[0]?.layer?.id;\n\n const hasHoveredFeatures =\n !isNil(features) && features.length > 0 && !isUndefined(layerId);\n const isBaseLayer = BASE_LAYER_IDS.includes(layerId);\n\n if (hasHoveredFeatures && !isBaseLayer) {\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // if there's already an active feature, remove the active state\n map.setFeatureState(\n { source: sourceId, id: featureId },\n { active: false },\n );\n }\n\n const minFeature = getMinValueFeature(features);\n\n featureId = minFeature.id;\n sourceId = minFeature.layer.source;\n const activeState = features[0].state.active;\n\n // add the active state to the closest feature\n map.setFeatureState(\n { source: sourceId, id: featureId },\n { active: !activeState },\n );\n allFeatures.forEach((feature) => {\n if (feature.id !== undefined && feature.layer.source !== undefined) {\n map.setFeatureState(\n { source: feature.layer.source, id: feature.id },\n { isAnyActive: !activeState },\n );\n }\n }); //TODO: change to inactive\n } else {\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // remove the active state from the last active feature\n map.setFeatureState(\n { source: sourceId, id: featureId },\n { active: false },\n );\n allFeatures.forEach((feature) => {\n if (\n feature.id !== undefined &&\n feature.layer.source !== undefined\n ) {\n map.setFeatureState(\n { source: feature.layer.source, id: feature.id },\n { isAnyActive: false },\n );\n }\n });\n }\n }\n },\n [featureId, sourceId, map],\n );\n\n useEffect(() => {\n map.on('click', handleClick);\n return () => {\n map.off('click', handleClick);\n };\n }, []);\n};\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,OAAO,mBAAmB;AAEnC,SAAS,aAAa,iBAAiB;AAEvC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAE5B,MAAM,uBAAuB,MAAM;AAExC,QAAM,MAAM,OAAO,EAAE;AAErB,MAAI;AACJ,MAAI;AACJ,QAAM,cAAc;AAAA,IAClB,CAAC,EAAE,MAAM,MAA0B;AACjC,YAAM,WAAW,IAAI,sBAAsB,KAAK;AAChD,YAAM,cAAc,IAAI,sBAAsB;AAE9C,YAAM,UAAU,WAAW,CAAC,GAAG,OAAO;AAEtC,YAAM,qBACJ,CAAC,MAAM,QAAQ,KAAK,SAAS,SAAS,KAAK,CAAC,YAAY,OAAO;AACjE,YAAM,cAAc,eAAe,SAAS,OAAO;AAEnD,UAAI,sBAAsB,CAAC,aAAa;AACtC,YAAI,CAAC,YAAY,SAAS,KAAK,CAAC,YAAY,QAAQ,GAAG;AAErD,cAAI;AAAA,YACF,EAAE,QAAQ,UAAU,IAAI,UAAU;AAAA,YAClC,EAAE,QAAQ,MAAM;AAAA,UAClB;AAAA,QACF;AAEA,cAAM,aAAa,mBAAmB,QAAQ;AAE9C,oBAAY,WAAW;AACvB,mBAAW,WAAW,MAAM;AAC5B,cAAM,cAAc,SAAS,CAAC,EAAE,MAAM;AAGtC,YAAI;AAAA,UACF,EAAE,QAAQ,UAAU,IAAI,UAAU;AAAA,UAClC,EAAE,QAAQ,CAAC,YAAY;AAAA,QACzB;AACA,oBAAY,QAAQ,CAAC,YAAY;AAC/B,cAAI,QAAQ,OAAO,UAAa,QAAQ,MAAM,WAAW,QAAW;AAClE,gBAAI;AAAA,cACF,EAAE,QAAQ,QAAQ,MAAM,QAAQ,IAAI,QAAQ,GAAG;AAAA,cAC/C,EAAE,aAAa,CAAC,YAAY;AAAA,YAC9B;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,OAAO;AACL,YAAI,CAAC,YAAY,SAAS,KAAK,CAAC,YAAY,QAAQ,GAAG;AAErD,cAAI;AAAA,YACF,EAAE,QAAQ,UAAU,IAAI,UAAU;AAAA,YAClC,EAAE,QAAQ,MAAM;AAAA,UAClB;AACA,sBAAY,QAAQ,CAAC,YAAY;AAC/B,gBACE,QAAQ,OAAO,UACf,QAAQ,MAAM,WAAW,QACzB;AACA,kBAAI;AAAA,gBACF,EAAE,QAAQ,QAAQ,MAAM,QAAQ,IAAI,QAAQ,GAAG;AAAA,gBAC/C,EAAE,aAAa,MAAM;AAAA,cACvB;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,UAAU,GAAG;AAAA,EAC3B;AAEA,YAAU,MAAM;AACd,QAAI,GAAG,SAAS,WAAW;AAC3B,WAAO,MAAM;AACX,UAAI,IAAI,SAAS,WAAW;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,CAAC;AACP;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/hooks/use-attach-image-from-icon.ts"],
4
- "sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { isString } from 'lodash-es';\nimport { createElement, type ReactNode, useLayoutEffect } from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { useSafeSvgParser } from './use-safe-svg-parser.js';\nimport { DEFAULT_INPUT_ICON_SIZE } from '../constants.js';\nimport type { MapShape } from '../types/shapes.js';\nimport { attachImageToMap } from '../utils/attach-image-to-map.js';\nimport { createBitmapConfigOptions } from '../utils/create-bitmap-config-options.js';\nimport { getDataUri } from '../utils/get-data-uri.js';\nimport { getScaledSymbolSize } from '../utils/get-scaled-symbol-size.js';\n\nexport const useAttachImageFromIcon = (\n icon: string | MapShape | ReactNode,\n suffix: string,\n outputSize?: number,\n) => {\n const { elementAsString, ref } = useSafeSvgParser();\n const defaultScaledIconSize = getScaledSymbolSize();\n const { current: map } = useMap()!;\n const img = new Image(defaultScaledIconSize, defaultScaledIconSize);\n\n /*\n * As we can only create a reference in a React Node, but we need a virtual\n * 'root' element in the DOM to attach it, we create a 'div'\n * container that lately will hold the React Node. This is done to ensure\n * everything is cached prior any manipulation.\n */\n // Create a div element that acts as a container node in the DOM\n const fakeDomContainer = document.createElement('div');\n useLayoutEffect(() => {\n if (isString(icon)) {\n return;\n }\n // Create a React Node that will have a ref callback to be run when loaded and\n // the input icon as a children\n const reactNodeRefContainer = createElement('div', { ref }, icon);\n // Attach React Node with the ref callback into DOM Node\n const root = createRoot(fakeDomContainer);\n root.render(reactNodeRefContainer);\n }, [icon]);\n\n // Remove cached element to free resources\n fakeDomContainer.remove();\n\n const stringUrl = getDataUri(elementAsString);\n\n img.addEventListener('load', () => {\n createImageBitmap(\n img,\n 0,\n 0,\n DEFAULT_INPUT_ICON_SIZE,\n DEFAULT_INPUT_ICON_SIZE,\n createBitmapConfigOptions(outputSize),\n ).then((bitmap) => {\n if (!map) {\n return;\n }\n const iconName = `custom-icon-${suffix}`;\n attachImageToMap(map, bitmap, iconName);\n });\n });\n img.src = stringUrl;\n\n return !isString(icon);\n};\n"],
5
- "mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,eAA+B,uBAAuB;AAC/D,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AAExC,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAE7B,MAAM,yBAAyB,CACpC,MACA,QACA,eACG;AACH,QAAM,EAAE,iBAAiB,IAAI,IAAI,iBAAiB;AAClD,QAAM,wBAAwB,oBAAoB;AAClD,QAAM,EAAE,SAAS,IAAI,IAAI,OAAO;AAChC,QAAM,MAAM,IAAI,MAAM,uBAAuB,qBAAqB;AASlE,QAAM,mBAAmB,SAAS,cAAc,KAAK;AACrD,kBAAgB,MAAM;AACpB,QAAI,SAAS,IAAI,GAAG;AAClB;AAAA,IACF;AAGA,UAAM,wBAAwB,cAAc,OAAO,EAAE,IAAI,GAAG,IAAI;AAEhE,UAAM,OAAO,WAAW,gBAAgB;AACxC,SAAK,OAAO,qBAAqB;AAAA,EACnC,GAAG,CAAC,IAAI,CAAC;AAGT,mBAAiB,OAAO;AAExB,QAAM,YAAY,WAAW,eAAe;AAE5C,MAAI,iBAAiB,QAAQ,MAAM;AACjC;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,0BAA0B,UAAU;AAAA,IACtC,EAAE,KAAK,CAAC,WAAW;AACjB,UAAI,CAAC,KAAK;AACR;AAAA,MACF;AACA,YAAM,WAAW,eAAe,MAAM;AACtC,uBAAiB,KAAK,QAAQ,QAAQ;AAAA,IACxC,CAAC;AAAA,EACH,CAAC;AACD,MAAI,MAAM;AAEV,SAAO,CAAC,SAAS,IAAI;AACvB;",
4
+ "sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { isString } from 'lodash-es';\nimport { createElement, type ReactNode, useLayoutEffect } from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { useSafeSvgParser } from './use-safe-svg-parser.js';\nimport { DEFAULT_INPUT_ICON_SIZE } from '../constants.js';\nimport type { MapShape } from '../types/shapes.js';\nimport { attachImageToMap } from '../utils/attach-image-to-map.js';\nimport { createBitmapConfigOptions } from '../utils/create-bitmap-config-options.js';\nimport { getDataUri } from '../utils/get-data-uri.js';\nimport { getScaledSymbolSize } from '../utils/get-scaled-symbol-size.js';\n\nexport const useAttachImageFromIcon = (\n icon: string | MapShape | ReactNode,\n suffix: string,\n outputSize?: number,\n) => {\n const { elementAsString, ref } = useSafeSvgParser();\n const defaultScaledIconSize = getScaledSymbolSize();\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const { current: map } = useMap()!;\n const img = new Image(defaultScaledIconSize, defaultScaledIconSize);\n\n /*\n * As we can only create a reference in a React Node, but we need a virtual\n * 'root' element in the DOM to attach it, we create a 'div'\n * container that lately will hold the React Node. This is done to ensure\n * everything is cached prior any manipulation.\n */\n // Create a div element that acts as a container node in the DOM\n const fakeDomContainer = document.createElement('div');\n useLayoutEffect(() => {\n if (isString(icon)) {\n return;\n }\n // Create a React Node that will have a ref callback to be run when loaded and\n // the input icon as a children\n const reactNodeRefContainer = createElement('div', { ref }, icon);\n // Attach React Node with the ref callback into DOM Node\n const root = createRoot(fakeDomContainer);\n root.render(reactNodeRefContainer);\n }, [icon]);\n\n // Remove cached element to free resources\n fakeDomContainer.remove();\n\n const stringUrl = getDataUri(elementAsString);\n\n img.addEventListener('load', () => {\n createImageBitmap(\n img,\n 0,\n 0,\n DEFAULT_INPUT_ICON_SIZE,\n DEFAULT_INPUT_ICON_SIZE,\n createBitmapConfigOptions(outputSize),\n ).then((bitmap) => {\n if (!map) {\n return;\n }\n const iconName = `custom-icon-${suffix}`;\n attachImageToMap(map, bitmap, iconName);\n });\n });\n img.src = stringUrl;\n\n return !isString(icon);\n};\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,eAA+B,uBAAuB;AAC/D,SAAS,kBAAkB;AAE3B,SAAS,wBAAwB;AACjC,SAAS,+BAA+B;AAExC,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAC1C,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAE7B,MAAM,yBAAyB,CACpC,MACA,QACA,eACG;AACH,QAAM,EAAE,iBAAiB,IAAI,IAAI,iBAAiB;AAClD,QAAM,wBAAwB,oBAAoB;AAGlD,QAAM,EAAE,SAAS,IAAI,IAAI,OAAO;AAChC,QAAM,MAAM,IAAI,MAAM,uBAAuB,qBAAqB;AASlE,QAAM,mBAAmB,SAAS,cAAc,KAAK;AACrD,kBAAgB,MAAM;AACpB,QAAI,SAAS,IAAI,GAAG;AAClB;AAAA,IACF;AAGA,UAAM,wBAAwB,cAAc,OAAO,EAAE,IAAI,GAAG,IAAI;AAEhE,UAAM,OAAO,WAAW,gBAAgB;AACxC,SAAK,OAAO,qBAAqB;AAAA,EACnC,GAAG,CAAC,IAAI,CAAC;AAGT,mBAAiB,OAAO;AAExB,QAAM,YAAY,WAAW,eAAe;AAE5C,MAAI,iBAAiB,QAAQ,MAAM;AACjC;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,0BAA0B,UAAU;AAAA,IACtC,EAAE,KAAK,CAAC,WAAW;AACjB,UAAI,CAAC,KAAK;AACR;AAAA,MACF;AACA,YAAM,WAAW,eAAe,MAAM;AACtC,uBAAiB,KAAK,QAAQ,QAAQ;AAAA,IACxC,CAAC;AAAA,EACH,CAAC;AACD,MAAI,MAAM;AAEV,SAAO,CAAC,SAAS,IAAI;AACvB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/hooks/use-hover-interaction.ts"],
4
- "sourcesContent": ["import type { MapRef } from '@vis.gl/react-maplibre';\nimport { useMap } from '@vis.gl/react-maplibre';\nimport { isNil, isString, isUndefined } from 'lodash-es';\nimport type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useCallback, useEffect } from 'react';\n\nimport { BASE_LAYER_IDS } from '../constants.js';\nimport {\n getAssociatedFeatures,\n hasAssociatedFeatures,\n isAssociatedFeature,\n} from '../utils/associated-features.js';\nimport { getMinValueFeature } from '../utils/get-min-value-feature.js';\n\n/**\n * Checks whether a feature exists from a given source\n *\n * @param map -\n * @param source -\n * @param id -\n */\nconst featureExists = (\n map: MapRef,\n source: string,\n id: string | number,\n): boolean => {\n const isSourcePresent = map.getSource(source) !== undefined;\n\n return (\n isSourcePresent &&\n map.getFeatureState({\n source,\n id,\n }) !== undefined\n );\n};\n\n/**\n * Removes hovered state from a feature and its associated features from a given source\n * @param map -\n * @param source -\n * @param id -\n */\nconst blurFeature = (map: MapRef, source: string, id: string | number) => {\n map.setFeatureState({ source, id }, { hover: false });\n\n if (isString(id) && hasAssociatedFeatures(id)) {\n for (const associatedFeature of getAssociatedFeatures('connection')) {\n const associatedSource = `${source}-direction`;\n const associatedId = `${id}-${associatedFeature}`;\n\n if (featureExists(map, associatedSource, associatedId)) {\n map.setFeatureState(\n { source: associatedSource, id: associatedId },\n {\n hover: false,\n },\n );\n }\n }\n }\n};\n\n/**\n * Sets hovered state to a feature and its associated features from a given source\n * @param map -\n * @param source -\n * @param id -\n */\nconst hoverFeature = (map: MapRef, source: string, id: string | number) => {\n map.setFeatureState({ source, id }, { hover: true });\n\n if (isString(id) && hasAssociatedFeatures(id)) {\n for (const associatedFeature of getAssociatedFeatures('connection')) {\n const associatedSource = `${source}-direction`;\n const associatedId = `${id}-${associatedFeature}`;\n\n if (featureExists(map, associatedSource, associatedId)) {\n map.setFeatureState(\n { source: `${source}-direction`, id: `${id}-${associatedFeature}` },\n {\n hover: true,\n },\n );\n }\n }\n }\n};\n\n/**\n * Sets and removes hovered state to the features depending on mouse position\n */\nexport const useHoverInteraction = () => {\n const map = useMap().current;\n\n let featureId: string | number | undefined;\n let sourceId: string | undefined;\n\n const handleMouseOut = useCallback(\n ({ point }: MapLayerMouseEvent) => {\n if (!isNil(map) && !isUndefined(featureId) && !isUndefined(sourceId)) {\n blurFeature(map, sourceId, featureId);\n }\n },\n [featureId, sourceId, map],\n );\n\n const handleMouseMove = useCallback(\n ({ point }: MapLayerMouseEvent) => {\n if (!isNil(map)) {\n const features = map\n .queryRenderedFeatures(point)\n .filter((feature) => !isAssociatedFeature(feature.properties.id)); // associated features should only have hover state when the main feature is hovered\n\n map.getCanvas().style.cursor = 'grab';\n const layerId = features?.[0]?.layer?.id;\n\n const hasHoveredFeatures =\n !isNil(features) && features.length > 0 && !isUndefined(layerId);\n const isBaseLayer = BASE_LAYER_IDS.includes(layerId);\n\n if (hasHoveredFeatures && !isBaseLayer) {\n map.getCanvas().style.cursor = 'pointer';\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // if there's already a hovered feature, remove the hover state\n blurFeature(map, sourceId, featureId);\n }\n\n const minFeature = getMinValueFeature(features);\n\n featureId = minFeature!.id;\n sourceId = minFeature!.layer.source;\n\n // add the hover state to the closest feature\n if (!isUndefined(featureId)) {\n hoverFeature(map, sourceId, featureId);\n }\n } else {\n map.getCanvas().style.cursor = 'grab';\n\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // remove the active state from the last hovered feature\n blurFeature(map, sourceId, featureId);\n }\n }\n }\n },\n [featureId, sourceId, map],\n );\n\n useEffect(() => {\n map?.on('mousemove', handleMouseMove);\n map?.on('mouseout', handleMouseOut);\n return () => {\n map?.off('mousemove', handleMouseMove);\n map?.off('mouseout', handleMouseOut);\n };\n }, []);\n};\n"],
5
- "mappings": "AACA,SAAS,cAAc;AACvB,SAAS,OAAO,UAAU,mBAAmB;AAE7C,SAAS,aAAa,iBAAiB;AAEvC,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AASnC,MAAM,gBAAgB,CACpB,KACA,QACA,OACY;AACZ,QAAM,kBAAkB,IAAI,UAAU,MAAM,MAAM;AAElD,SACE,mBACA,IAAI,gBAAgB;AAAA,IAClB;AAAA,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,cAAc;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,CAAC;AACP;",
4
+ "sourcesContent": ["import type { MapRef } from '@vis.gl/react-maplibre';\nimport { useMap } from '@vis.gl/react-maplibre';\nimport { isNil, isString, isUndefined } from 'lodash-es';\nimport type { MapLayerMouseEvent } from 'maplibre-gl';\nimport { useCallback, useEffect } from 'react';\n\nimport { BASE_LAYER_IDS } from '../constants.js';\nimport {\n getAssociatedFeatures,\n hasAssociatedFeatures,\n isAssociatedFeature,\n} from '../utils/associated-features.js';\nimport { getMinValueFeature } from '../utils/get-min-value-feature.js';\n\n/**\n * Checks whether a feature exists from a given source\n *\n * @param map -\n * @param source -\n * @param id -\n */\nconst featureExists = (\n map: MapRef,\n source: string,\n id: string | number,\n): boolean => {\n const isSourcePresent = map.getSource(source) !== undefined;\n\n return (\n isSourcePresent &&\n map.getFeatureState({\n source,\n id,\n }) !== undefined\n );\n};\n\n/**\n * Removes hovered state from a feature and its associated features from a given source\n * @param map -\n * @param source -\n * @param id -\n */\nconst blurFeature = (map: MapRef, source: string, id: string | number) => {\n map.setFeatureState({ source, id }, { hover: false });\n\n if (isString(id) && hasAssociatedFeatures(id)) {\n for (const associatedFeature of getAssociatedFeatures('connection')) {\n const associatedSource = `${source}-direction`;\n const associatedId = `${id}-${associatedFeature}`;\n\n if (featureExists(map, associatedSource, associatedId)) {\n map.setFeatureState(\n { source: associatedSource, id: associatedId },\n {\n hover: false,\n },\n );\n }\n }\n }\n};\n\n/**\n * Sets hovered state to a feature and its associated features from a given source\n * @param map -\n * @param source -\n * @param id -\n */\nconst hoverFeature = (map: MapRef, source: string, id: string | number) => {\n map.setFeatureState({ source, id }, { hover: true });\n\n if (isString(id) && hasAssociatedFeatures(id)) {\n for (const associatedFeature of getAssociatedFeatures('connection')) {\n const associatedSource = `${source}-direction`;\n const associatedId = `${id}-${associatedFeature}`;\n\n if (featureExists(map, associatedSource, associatedId)) {\n map.setFeatureState(\n { source: `${source}-direction`, id: `${id}-${associatedFeature}` },\n {\n hover: true,\n },\n );\n }\n }\n }\n};\n\n/**\n * Sets and removes hovered state to the features depending on mouse position\n */\nexport const useHoverInteraction = () => {\n const map = useMap().current;\n\n let featureId: string | number | undefined;\n let sourceId: string | undefined;\n\n const handleMouseOut = useCallback(\n ({ point }: MapLayerMouseEvent) => {\n if (!isNil(map) && !isUndefined(featureId) && !isUndefined(sourceId)) {\n blurFeature(map, sourceId, featureId);\n }\n },\n [featureId, sourceId, map],\n );\n\n const handleMouseMove = useCallback(\n ({ point }: MapLayerMouseEvent) => {\n if (!isNil(map)) {\n const features = map\n .queryRenderedFeatures(point)\n .filter((feature) => !isAssociatedFeature(feature.properties.id)); // associated features should only have hover state when the main feature is hovered\n\n map.getCanvas().style.cursor = 'grab';\n const layerId = features?.[0]?.layer?.id;\n\n const hasHoveredFeatures =\n !isNil(features) && features.length > 0 && !isUndefined(layerId);\n const isBaseLayer = BASE_LAYER_IDS.includes(layerId);\n\n if (hasHoveredFeatures && !isBaseLayer) {\n map.getCanvas().style.cursor = 'pointer';\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // if there's already a hovered feature, remove the hover state\n blurFeature(map, sourceId, featureId);\n }\n\n const minFeature = getMinValueFeature(features);\n\n featureId = minFeature.id;\n sourceId = minFeature.layer.source;\n\n // add the hover state to the closest feature\n if (!isUndefined(featureId)) {\n hoverFeature(map, sourceId, featureId);\n }\n } else {\n map.getCanvas().style.cursor = 'grab';\n\n if (!isUndefined(featureId) && !isUndefined(sourceId)) {\n // remove the active state from the last hovered feature\n blurFeature(map, sourceId, featureId);\n }\n }\n }\n },\n [featureId, sourceId, map],\n );\n\n useEffect(() => {\n map?.on('mousemove', handleMouseMove);\n map?.on('mouseout', handleMouseOut);\n return () => {\n map?.off('mousemove', handleMouseMove);\n map?.off('mouseout', handleMouseOut);\n };\n }, []);\n};\n"],
5
+ "mappings": "AACA,SAAS,cAAc;AACvB,SAAS,OAAO,UAAU,mBAAmB;AAE7C,SAAS,aAAa,iB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ACtC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,WAAW,UAAU,GAAG;AAAA,EAC3B;AAEA,YAAU,MAAM;AACd,SAAK,GAAG,aAAa,eAAe;AACpC,SAAK,GAAG,YAAY,cAAc;AAClC,WAAO,MAAM;AACX,WAAK,IAAI,aAAa,eAAe;AACrC,WAAK,IAAI,YAAY,cAAc;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,CAAC;AACP;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/hooks/use-truncation-mode.ts"],
4
- "sourcesContent": ["import { useContext } from 'react';\n\nimport type { _TruncationMode as TruncationMode } from '@dynatrace/strato-components/typography';\n\nimport { MapTruncationModeContext } from '../contexts/map-truncation-mode.context.js';\n\nexport const useTruncationMode = () =>\n useContext<TruncationMode>(MapTruncationModeContext);\n"],
4
+ "sourcesContent": ["import { useContext } from 'react';\n\nimport type { TruncationMode } from '@dynatrace/strato-components/typography';\n\nimport { MapTruncationModeContext } from '../contexts/map-truncation-mode.context.js';\n\nexport const useTruncationMode = () =>\n useContext<TruncationMode>(MapTruncationModeContext);\n"],
5
5
  "mappings": "AAAA,SAAS,kBAAkB;AAI3B,SAAS,gCAAgC;AAElC,MAAM,oBAAoB,MAC/B,WAA2B,wBAAwB;",
6
6
  "names": []
7
7
  }
@@ -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 { type ReactNode, Children } 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': child.props.layerId,\n };\n\n const category = addCategory(\n extendedDataPoint,\n valueAccessors.get(child.props.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 } else if (isComponent(child, ConnectionLayer)) {\n const { data } = child.props;\n\n data.forEach((connection, connectionIndex) => {\n if (connection.path.length >= 2) {\n const category = addCategory(\n connection,\n valueAccessors.get(child.props.layerId),\n );\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': child.props.layerId,\n };\n\n flattenData.push(parsedPath);\n });\n }\n });\n } else if (isComponent(child, ChoroplethLayer)) {\n const { data, regionAccessor } = child.props;\n\n data.forEach((dataEntry) => {\n const region = isString(regionAccessor)\n ? dataEntry[regionAccessor]\n : regionAccessor(dataEntry);\n\n const choroplethLayerData = {\n ...dataEntry,\n region,\n 'layer-name': child.props.layerId,\n };\n\n const category = addCategory(\n choroplethLayerData,\n valueAccessors.get(child.props.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 });\n\n return {\n flattenData,\n categories: [...categoriesSet],\n legendDomain,\n };\n};\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAyB,gBAAgB;AAEzC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAEzB,MAAM,cAAc,CAClB,mBACA,kBACG;AACH,MAAI,iBAAiB,kBAAkB,aAAa,GAAG;AACrD,WAAO,kBAAkB,aAAa;AAAA,EACxC;AACF;AAEA,MAAM,eAAe,CACnB,QACA,UACqB;AACrB,MAAI,CAAC,KAAK,GAAG,IAAI;AACjB,MAAI,QAAQ,KAAK;AACf,UAAM;AAAA,EACR;AACA,MAAI,QAAQ,KAAK;AACf,UAAM;AAAA,EACR;AACA,SAAO,CAAC,KAAK,GAAG;AAClB;AAQO,MAAM,oBAAoB,CAC/B,UACA,mBACG;AACH,MAAI,cAAyC,CAAC;AAC9C,QAAM,gBAAgB,oBAAI,IAAY;AACtC,MAAI,eAAiC,CAAC,UAAU,SAAS;AAEzD,WAAS,QAAQ,UAAU,CAAC,UAAU;AACpC,QAAI,YAAY,OAAO,WAAW,KAAK,YAAY,OAAO,QAAQ,GAAG;AACnE,YAAM,EAAE,KAAK,IAAI,MAAM;AAEvB,WAAK,QAAQ,CAAC,cAAc;AAC1B,cAAM,oBAAoB;AAAA,UACxB,GAAG;AAAA,UACH,cAAc,MAAM,MAAM;AAAA,QAC5B;AAEA,cAAM,WAAW;AAAA,UACf;AAAA,UACA,eAAe,IAAI,MAAM,MAAM,OAAO;AAAA,QACxC;AAEA,oBAA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BAAY,KAAK,mBAAmB;AAAA,MACtC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,YAAY,CAAC,GAAG,aAAa;AAAA,IAC7B;AAAA,EACF;AACF;",
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': child.props.layerId,\n };\n\n const category = addCategory(\n extendedDataPoint,\n valueAccessors.get(child.props.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 } else if (isComponent(child, ConnectionLayer)) {\n const { data } = child.props;\n\n data.forEach((connection, connectionIndex) => {\n if (connection.path.length >= 2) {\n const category = addCategory(\n connection,\n valueAccessors.get(child.props.layerId),\n );\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': child.props.layerId,\n };\n\n flattenData.push(parsedPath);\n });\n }\n });\n } else if (isComponent(child, ChoroplethLayer)) {\n const { data, regionAccessor } = child.props;\n\n data.forEach((dataEntry) => {\n const region = isString(regionAccessor)\n ? dataEntry[regionAccessor]\n : regionAccessor(dataEntry);\n\n const choroplethLayerData = {\n ...dataEntry,\n region,\n 'layer-name': child.props.layerId,\n };\n\n const category = addCategory(\n choroplethLayerData,\n valueAccessors.get(child.props.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 });\n\n return {\n flattenData,\n categories: [...categoriesSet],\n legendDomain,\n };\n};\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,gBAAgC;AAEzC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAEzB,MAAM,cAAc,CAClB,mBACA,kBACG;AACH,MAAI,iBAAiB,kBAAkB,aAAa,GAAG;AACrD,WAAO,kBAAkB,aAAa;AAAA,EACxC;AACF;AAEA,MAAM,eAAe,CACnB,QACA,UACqB;AACrB,MAAI,CAAC,KAAK,GAAG,IAAI;AACjB,MAAI,QAAQ,KAAK;AACf,UAAM;AAAA,EACR;AACA,MAAI,QAAQ,KAAK;AACf,UAAM;AAAA,EACR;AACA,SAAO,CAAC,KAAK,GAAG;AAClB;AAQO,MAAM,oBAAoB,CAC/B,UACA,mBACG;AACH,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AAC9C,YAAM,EAAE,MAAM,eAAe,IAAI,MAAM;AAEvC,WAAK,QAAQ,CAAC,cAAc;AAC1B,cAAM,SAAS,SAAS,cAAc,IAClC,UAAU,cAAc,IACxB,eAAe,SAAS;AAE5B,cAAM,sBAAsB;AAAA,UAC1B,GAAG;AAAA,UACH;AAAA,UACA,cAAc,MAAM,MAAM;AAAA,QAC5B;AAEA,cAAM,WAAW;AAAA,UACf;AAAA,UACA,eAAe,IAAI,MAAM,MAAM,OAAO;AAAA,QACxC;AAEA,oBAAY,cAAc,IAAI,QAAkB;AAEhD,YAAI,OAAO,aAAa,UAAU;AAChC,yBAAe,aAAa,cAAc,QAAQ;AAAA,QACpD;AAEA,oBAAY,KAAK,mBAAmB;AAAA,MACtC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,YAAY,CAAC,GAAG,aAAa;AAAA,IAC7B;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -64,10 +64,11 @@ const iterateConfigSlots = (children, legendDomain) => {
64
64
  }
65
65
  };
66
66
  } else if (isSlot(child, ThresholdLegend)) {
67
- const ranges = replaceInfiniteValuesInRanges(
68
- child.props.ranges,
69
- legendDomain
70
- );
67
+ const getDomainValue = (index, legendDomainValue) => Number.isFinite(legendDomainValue) ? legendDomainValue : child.props.ranges?.at(index)?.to ?? legendDomainValue;
68
+ const ranges = replaceInfiniteValuesInRanges(child.props.ranges, [
69
+ getDomainValue(0, legendDomain[0]),
70
+ getDomainValue(-1, legendDomain[1])
71
+ ]);
71
72
  slots = {
72
73
  ...slots,
73
74
  legend: {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/iterate-config-slots.ts"],
4
- "sourcesContent": ["import { Children, type ReactNode } from 'react';\n\nimport { ChartToolbar } from '@dynatrace/strato-components-preview/charts';\n\nimport {\n DEFAULT_BASE_LAYER_RULES,\n DEFAULT_MAP_LEGEND_RATIO,\n DEFAULT_MAP_POSITION,\n DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n} from '../constants.js';\nimport { isSlot } from './is-slot.js';\nimport { replaceInfiniteValuesInRanges } from './replace-infinite-values-in-ranges.js';\nimport { BaseLayer } from '../slots/BaseLayer.js';\nimport { CategoricalLegend } from '../slots/CategoricalLegend.js';\nimport { ChartInteractions } from '../slots/ChartInteractions.js';\nimport { SequentialLegend } from '../slots/SequentialLegend.js';\nimport { ThresholdLegend } from '../slots/ThresholdLegend.js';\nimport type { MapConfig } from '../types/configuration.js';\nimport type { ChartInteractionsConfig } from '../types/toolbar.js';\n\n/**\n * Generate map config based on slots\n * @param children - Map children\n * @param legendDomain - Domain containing min and max value relevant for legend\n * @returns Map slot config\n */\nexport const iterateConfigSlots = (\n children: ReactNode,\n legendDomain: [number, number],\n) => {\n let slots: MapConfig = {\n toolbar: undefined,\n interactions: undefined,\n legend: undefined,\n baseLayer: DEFAULT_BASE_LAYER_RULES,\n };\n\n Children.forEach(children, (child) => {\n if (isSlot(child, ChartInteractions)) {\n const { children, ...previousInteractions } = child.props;\n\n const interactions = iterateChartInteractionsSlots(children);\n\n slots = {\n ...slots,\n interactions: {\n ...previousInteractions,\n ...interactions,\n },\n };\n } else if (isSlot(child, ChartToolbar)) {\n const { children, ...toolbar } = child.props;\n const childrenToolbar = iterateChartToolbarSlots(children);\n\n slots = {\n ...slots,\n toolbar: {\n ...toolbar,\n ...childrenToolbar,\n },\n };\n } else if (isSlot(child, SequentialLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'sequential',\n colorPalette: DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n min: child.props.min ?? legendDomain[0],\n max: child.props.max ?? legendDomain[1],\n },\n };\n } else if (isSlot(child, CategoricalLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'categorical',\n position: DEFAULT_MAP_POSITION,\n ...child.props,\n },\n };\n } else if (isSlot(child, ThresholdLegend)) {\n const ranges = replaceInfiniteValuesInRanges(\n child.props.ranges,\n legendDomain,\n );\n\n slots = {\n ...slots,\n legend: {\n type: 'threshold',\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n ranges,\n },\n };\n } else if (isSlot(child, BaseLayer)) {\n slots = {\n ...slots,\n baseLayer: {\n ...slots.baseLayer,\n ...child.props,\n },\n };\n }\n });\n\n return slots;\n};\n\nconst iterateChartInteractionsSlots = (children: ReactNode) => {\n let interactions: ChartInteractionsConfig = {};\n\n Children.forEach(children, (childInteractions) => {\n if (isSlot(childInteractions, ChartInteractions.Zoom)) {\n interactions = { ...interactions, zoom: { enabled: true } };\n } else if (isSlot(childInteractions, ChartInteractions.ZoomToFit)) {\n interactions = { ...interactions, zoomToFit: { enabled: true } };\n }\n });\n\n return interactions;\n};\n\n/**\n * Generates chart config based on slots\n * @param children - CharInteraction children\n * @returns ChartInteraction slot config\n */\nconst iterateChartToolbarSlots = (children: ReactNode) => {\n let toolbar = {};\n\n Children.forEach(children, (childToolbar) => {\n if (isSlot(childToolbar, ChartToolbar.DownloadData)) {\n toolbar = {\n ...toolbar,\n downloadData: { enabled: true },\n };\n }\n });\n\n return toolbar;\n};\n"],
5
- "mappings": "AAAA,SAAS,gBAAgC;AAEzC,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,qCAAqC;AAC9C,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAUzB,MAAM,qBAAqB,CAChC,UACA,iBACG;AACH,MAAI,QAAmB;AAAA,IACrB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAEA,WAAS,QAA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,IACF,WAAW,OAAO,OAAO,SAAS,GAAG;AACnC,cAAQ;AAAA,QACN,GAAG;AAAA,QACH,WAAW;AAAA,UACT,GAAG,MAAM;AAAA,UACT,GAAG,MAAM;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,MAAM,gCAAgC,CAAC,aAAwB;AAC7D,MAAI,eAAwC,CAAC;AAE7C,WAAS,QAAQ,UAAU,CAAC,sBAAsB;AAChD,QAAI,OAAO,mBAAmB,kBAAkB,IAAI,GAAG;AACrD,qBAAe,EAAE,GAAG,cAAc,MAAM,EAAE,SAAS,KAAK,EAAE;AAAA,IAC5D,WAAW,OAAO,mBAAmB,kBAAkB,SAAS,GAAG;AACjE,qBAAe,EAAE,GAAG,cAAc,WAAW,EAAE,SAAS,KAAK,EAAE;AAAA,IACjE;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAOA,MAAM,2BAA2B,CAAC,aAAwB;AACxD,MAAI,UAAU,CAAC;AAEf,WAAS,QAAQ,UAAU,CAAC,iBAAiB;AAC3C,QAAI,OAAO,cAAc,aAAa,YAAY,GAAG;AACnD,gBAAU;AAAA,QACR,GAAG;AAAA,QACH,cAAc,EAAE,SAAS,KAAK;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
4
+ "sourcesContent": ["import { Children, type ReactNode } from 'react';\n\nimport { ChartToolbar } from '@dynatrace/strato-components-preview/charts';\n\nimport {\n DEFAULT_BASE_LAYER_RULES,\n DEFAULT_MAP_LEGEND_RATIO,\n DEFAULT_MAP_POSITION,\n DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n} from '../constants.js';\nimport { isSlot } from './is-slot.js';\nimport { replaceInfiniteValuesInRanges } from './replace-infinite-values-in-ranges.js';\nimport { BaseLayer } from '../slots/BaseLayer.js';\nimport { CategoricalLegend } from '../slots/CategoricalLegend.js';\nimport { ChartInteractions } from '../slots/ChartInteractions.js';\nimport { SequentialLegend } from '../slots/SequentialLegend.js';\nimport { ThresholdLegend } from '../slots/ThresholdLegend.js';\nimport type { MapConfig } from '../types/configuration.js';\nimport type { ChartInteractionsConfig } from '../types/toolbar.js';\n\n/**\n * Generate map config based on slots\n * @param children - Map children\n * @param legendDomain - Domain containing min and max value relevant for legend\n * @returns Map slot config\n */\nexport const iterateConfigSlots = (\n children: ReactNode,\n legendDomain: [number, number],\n) => {\n let slots: MapConfig = {\n toolbar: undefined,\n interactions: undefined,\n legend: undefined,\n baseLayer: DEFAULT_BASE_LAYER_RULES,\n };\n\n Children.forEach(children, (child) => {\n if (isSlot(child, ChartInteractions)) {\n const { children, ...previousInteractions } = child.props;\n\n const interactions = iterateChartInteractionsSlots(children);\n\n slots = {\n ...slots,\n interactions: {\n ...previousInteractions,\n ...interactions,\n },\n };\n } else if (isSlot(child, ChartToolbar)) {\n const { children, ...toolbar } = child.props;\n const childrenToolbar = iterateChartToolbarSlots(children);\n\n slots = {\n ...slots,\n toolbar: {\n ...toolbar,\n ...childrenToolbar,\n },\n };\n } else if (isSlot(child, SequentialLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'sequential',\n colorPalette: DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n min: child.props.min ?? legendDomain[0],\n max: child.props.max ?? legendDomain[1],\n },\n };\n } else if (isSlot(child, CategoricalLegend)) {\n slots = {\n ...slots,\n legend: {\n type: 'categorical',\n position: DEFAULT_MAP_POSITION,\n ...child.props,\n },\n };\n } else if (isSlot(child, ThresholdLegend)) {\n const getDomainValue = (index: number, legendDomainValue: number) =>\n Number.isFinite(legendDomainValue)\n ? legendDomainValue\n : child.props.ranges?.at(index)?.to ?? legendDomainValue;\n\n const ranges = replaceInfiniteValuesInRanges(child.props.ranges, [\n getDomainValue(0, legendDomain[0]),\n getDomainValue(-1, legendDomain[1]),\n ]);\n\n slots = {\n ...slots,\n legend: {\n type: 'threshold',\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...child.props,\n ranges,\n },\n };\n } else if (isSlot(child, BaseLayer)) {\n slots = {\n ...slots,\n baseLayer: {\n ...slots.baseLayer,\n ...child.props,\n },\n };\n }\n });\n\n return slots;\n};\n\nconst iterateChartInteractionsSlots = (children: ReactNode) => {\n let interactions: ChartInteractionsConfig = {};\n\n Children.forEach(children, (childInteractions) => {\n if (isSlot(childInteractions, ChartInteractions.Zoom)) {\n interactions = { ...interactions, zoom: { enabled: true } };\n } else if (isSlot(childInteractions, ChartInteractions.ZoomToFit)) {\n interactions = { ...interactions, zoomToFit: { enabled: true } };\n }\n });\n\n return interactions;\n};\n\n/**\n * Generates chart config based on slots\n * @param children - CharInteraction children\n * @returns ChartInteraction slot config\n */\nconst iterateChartToolbarSlots = (children: ReactNode) => {\n let toolbar = {};\n\n Children.forEach(children, (childToolbar) => {\n if (isSlot(childToolbar, ChartToolbar.DownloadData)) {\n toolbar = {\n ...toolbar,\n downloadData: { enabled: true },\n };\n }\n });\n\n return toolbar;\n};\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgC;AAEzC,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,qCAAqC;AAC9C,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAUzB,MAAM,qBAAqB,CAChC,UACA,iBACG;AACH,MAAI,QAAmB;AAAA,IACrB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAEA,WAAS,QAAQ,UAAU,CAAC,UAAU;AACpC,QAAI,OAAO,OAAO,iBAAiB,GAAG;AACpC,YAAM,EAAE,UAAAA,WAAU,GAAG,qBAAqB,IAAI,MAA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ACN,UAAU;AAAA,UACV,OAAO;AAAA,UACP,GAAG,MAAM;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF,WAAW,OAAO,OAAO,SAAS,GAAG;AACnC,cAAQ;AAAA,QACN,GAAG;AAAA,QACH,WAAW;AAAA,UACT,GAAG,MAAM;AAAA,UACT,GAAG,MAAM;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,MAAM,gCAAgC,CAAC,aAAwB;AAC7D,MAAI,eAAwC,CAAC;AAE7C,WAAS,QAAQ,UAAU,CAAC,sBAAsB;AAChD,QAAI,OAAO,mBAAmB,kBAAkB,IAAI,GAAG;AACrD,qBAAe,EAAE,GAAG,cAAc,MAAM,EAAE,SAAS,KAAK,EAAE;AAAA,IAC5D,WAAW,OAAO,mBAAmB,kBAAkB,SAAS,GAAG;AACjE,qBAAe,EAAE,GAAG,cAAc,WAAW,EAAE,SAAS,KAAK,EAAE;AAAA,IACjE;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAOA,MAAM,2BAA2B,CAAC,aAAwB;AACxD,MAAI,UAAU,CAAC;AAEf,WAAS,QAAQ,UAAU,CAAC,iBAAiB;AAC3C,QAAI,OAAO,cAAc,aAAa,YAAY,GAAG;AACnD,gBAAU;AAAA,QACR,GAAG;AAAA,QACH,cAAc,EAAE,SAAS,KAAK;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
6
  "names": ["children"]
7
7
  }
@@ -26,47 +26,48 @@ const layers = new WeakMap([
26
26
  [ChoroplethLayer, { prefix: "choropleth" }],
27
27
  [ConnectionLayer, { prefix: "connection" }]
28
28
  ]);
29
+ const isValidLayer = (child) => {
30
+ if (!isElement(child) || typeof child.type === "string") {
31
+ return false;
32
+ }
33
+ const componentType = child.type;
34
+ return layers.get(componentType) !== void 0 && (isSlot(child, BubbleLayer) || isSlot(child, ConnectionLayer) || isSlot(child, ChoroplethLayer) || isSlot(child, DotLayer));
35
+ };
36
+ const createLayer = (child, data, layerId) => {
37
+ if (isSlot(child, BubbleLayer)) {
38
+ return /* @__PURE__ */ jsx(MapBubbleLayer, { ...child.props, data, layerId });
39
+ }
40
+ if (isSlot(child, ConnectionLayer)) {
41
+ return /* @__PURE__ */ jsx(MapConnectionLayer, { ...child.props, data, layerId });
42
+ }
43
+ if (isSlot(child, DotLayer)) {
44
+ return /* @__PURE__ */ jsx(MapDotLayer, { ...child.props, data, layerId });
45
+ }
46
+ if (isSlot(child, ChoroplethLayer)) {
47
+ return /* @__PURE__ */ jsx(MapChoroplethLayer, { ...child.props, data, layerId });
48
+ }
49
+ return child;
50
+ };
29
51
  const setLayersId = (children) => {
30
52
  const layerIds = [];
31
53
  let index = 0;
32
54
  const valueAccessors = /* @__PURE__ */ new Map();
33
55
  const parsedChildren = Children.map(children, (child) => {
34
- if (isElement(child) && typeof child.type !== "string") {
35
- const layer = layers.get(child.type);
36
- if (layer !== void 0 && (isSlot(child, BubbleLayer) || isSlot(child, ConnectionLayer) || isSlot(child, ChoroplethLayer) || isSlot(child, DotLayer))) {
37
- const layerId = `${layer?.prefix}-${index}`;
38
- if (isValidElement(child) && child.props.color === "legend" && child.props.valueAccessor) {
39
- valueAccessors.set(layerId, child.props.valueAccessor);
40
- }
41
- index += 1;
42
- layerIds.push(layerId);
43
- const data = valueAccessors.get(layerId) ? sanitizeData(child, valueAccessors.get(layerId)) : child.props.data;
44
- if (isSlot(child, BubbleLayer)) {
45
- return /* @__PURE__ */ jsx(MapBubbleLayer, { ...child.props, data, layerId });
46
- } else if (isSlot(child, ConnectionLayer)) {
47
- return /* @__PURE__ */ jsx(
48
- MapConnectionLayer,
49
- {
50
- ...child.props,
51
- data,
52
- layerId
53
- }
54
- );
55
- } else if (isSlot(child, DotLayer)) {
56
- return /* @__PURE__ */ jsx(MapDotLayer, { ...child.props, data, layerId });
57
- } else if (isSlot(child, ChoroplethLayer)) {
58
- return /* @__PURE__ */ jsx(
59
- MapChoroplethLayer,
60
- {
61
- ...child.props,
62
- data,
63
- layerId
64
- }
65
- );
66
- }
67
- }
56
+ if (!isValidLayer(child)) {
57
+ return child;
58
+ }
59
+ const validChild = child;
60
+ const componentType = validChild.type;
61
+ const layer = layers.get(componentType);
62
+ const layerId = `${layer?.prefix}-${index}`;
63
+ if (isValidElement(validChild) && validChild.props.color === "legend" && validChild.props.valueAccessor) {
64
+ valueAccessors.set(layerId, validChild.props.valueAccessor);
68
65
  }
69
- return child;
66
+ index += 1;
67
+ layerIds.push(layerId);
68
+ const layerIdValueAccessor = valueAccessors.get(layerId);
69
+ const data = layerIdValueAccessor ? sanitizeData(validChild, layerIdValueAccessor) : validChild.props.data;
70
+ return createLayer(validChild, data, layerId);
70
71
  });
71
72
  return { layerIds, parsedChildren, valueAccessors };
72
73
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/set-layers-id.tsx"],
4
- "sourcesContent": ["import { isUndefined } from 'lodash-es';\nimport {\n Children,\n isValidElement,\n type JSXElementConstructor,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { isElement } from 'react-is';\n\nimport { isSlot } from './is-slot.js';\nimport { BubbleLayer as MapBubbleLayer } from '../components/BubbleLayer/BubbleLayer.js';\nimport { ChoroplethLayer as MapChoroplethLayer } from '../components/ChoroplethLayer/ChoroplethLayer.js';\nimport { ConnectionLayer as MapConnectionLayer } from '../components/ConnectionLayer/ConnectionLayer.js';\nimport { DotLayer as MapDotLayer } from '../components/DotLayer/DotLayer.js';\nimport { BubbleLayer } from '../slots/BubbleLayer.js';\nimport { ChoroplethLayer } from '../slots/ChoroplethLayer.js';\nimport { ConnectionLayer } from '../slots/ConnectionLayer.js';\nimport { DotLayer } from '../slots/DotLayer.js';\nimport type { LegendColorLayerProps } from '../types/coloring.js';\nimport type { Location } from '../types/location.js';\n\n// TODO: React 19 update\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst sanitizeData = (child: ReactElement<any>, key: string) => {\n return child.props.data.filter((datapoint: Location) => {\n const value = datapoint[key as keyof Location];\n return !(value === null || isUndefined(value));\n });\n};\n\nconst layers = new WeakMap<JSXElementConstructor<never>, { prefix: string }>([\n [BubbleLayer, { prefix: 'bubble' }],\n [DotLayer, { prefix: 'dot' }],\n [ChoroplethLayer, { prefix: 'choropleth' }],\n [ConnectionLayer, { prefix: 'connection' }],\n]);\n\n/**\n * Set layers id to layer slots provided by the consumer.\n * @param children - MapView children\n * @returns An array with all the layers IDs and the children using the layer component\n */\nexport const setLayersId = (\n children: ReactNode,\n): {\n layerIds: string[];\n parsedChildren: ReactNode;\n valueAccessors: Map<string, string>;\n} => {\n const layerIds: string[] = [];\n let index = 0;\n const valueAccessors = new Map<string, string>();\n\n const parsedChildren = Children.map(children, (child) => {\n if (isElement(child) && typeof child.type !== 'string') {\n const layer = layers.get(child.type);\n\n if (\n layer !== undefined &&\n (isSlot(child, BubbleLayer) ||\n isSlot(child, ConnectionLayer) ||\n isSlot(child, ChoroplethLayer) ||\n isSlot(child, DotLayer))\n ) {\n const layerId = `${layer?.prefix}-${index}`;\n\n if (\n isValidElement<LegendColorLayerProps>(child) &&\n child.props.color === 'legend' &&\n child.props.valueAccessor\n ) {\n valueAccessors.set(layerId, child.props.valueAccessor);\n }\n\n index += 1;\n\n layerIds.push(layerId);\n\n const data = valueAccessors.get(layerId)\n ? sanitizeData(child, valueAccessors.get(layerId)!)\n : child.props.data;\n\n if (isSlot(child, BubbleLayer)) {\n return (\n <MapBubbleLayer {...child.props} data={data} layerId={layerId} />\n );\n } else if (isSlot(child, ConnectionLayer)) {\n return (\n <MapConnectionLayer\n {...child.props}\n data={data}\n layerId={layerId}\n />\n );\n } else if (isSlot(child, DotLayer)) {\n return <MapDotLayer {...child.props} data={data} layerId={layerId} />;\n } else if (isSlot(child, ChoroplethLayer)) {\n return (\n <MapChoroplethLayer\n {...child.props}\n data={data}\n layerId={layerId}\n />\n );\n }\n }\n }\n return child;\n });\n\n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AAsC,KAAK,KAC3C,MAAM,MAAM,UAAU,YACtB,MAAM,MAAM,eACZ;AACA,yBAAe,IAAI,SAAS,MAAM,MAAM,aAAa;AAAA,QACvD;AAEA,iBAAS;AAET,iBAAS,KAAK,OAAO;AAErB,cAAM,OAAO,eAAe,IAAI,OAAO,IACnC,aAAa,OAAO,eAAe,IAAI,OAAO,CAAE,IAChD,MAAM,MAAM;AAEhB,YAAI,OAAO,OAAO,WAAW,GAAG;AAC9B,iBACE,oBAAC,kBAAgB,GAAG,MAAM,OAAO,MAAY,SAAkB;AAAA,QAEnE,WAAW,OAAO,OAAO,eAAe,GAAG;AACzC,iBACE;AAAA,YAAC;AAAA;AAAA,cACE,GAAG,MAAM;AAAA,cACV;AAAA,cACA;AAAA;AAAA,UACF;AAAA,QAEJ,WAAW,OAAO,OAAO,QAAQ,GAAG;AAClC,iBAAO,oBAAC,eAAa,GAAG,MAAM,OAAO,MAAY,SAAkB;AAAA,QACrE,WAAW,OAAO,OAAO,eAAe,GAAG;AACzC,iBACE;AAAA,YAAC;AAAA;AAAA,cACE,GAAG,MAAM;AAAA,cACV;AAAA,cACA;AAAA;AAAA,UACF;AAAA,QAEJ;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT,CAAC;AAED,SAAO,EAAE,UAAU,gBAAgB,eAAe;AACpD;",
4
+ "sourcesContent": ["import { isUndefined } from 'lodash-es';\nimport {\n Children,\n isValidElement,\n type JSXElementConstructor,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { isElement } from 'react-is';\n\nimport { isSlot } from './is-slot.js';\nimport { BubbleLayer as MapBubbleLayer } from '../components/BubbleLayer/BubbleLayer.js';\nimport { ChoroplethLayer as MapChoroplethLayer } from '../components/ChoroplethLayer/ChoroplethLayer.js';\nimport { ConnectionLayer as MapConnectionLayer } from '../components/ConnectionLayer/ConnectionLayer.js';\nimport { DotLayer as MapDotLayer } from '../components/DotLayer/DotLayer.js';\nimport { BubbleLayer } from '../slots/BubbleLayer.js';\nimport { ChoroplethLayer } from '../slots/ChoroplethLayer.js';\nimport { ConnectionLayer } from '../slots/ConnectionLayer.js';\nimport { DotLayer } from '../slots/DotLayer.js';\nimport type { LegendColorLayerProps } from '../types/coloring.js';\nimport type { Location } from '../types/location.js';\n\n// TODO: React 19 update\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst sanitizeData = (child: ReactElement<any>, key: string) => {\n return child.props.data.filter((datapoint: Location) => {\n const value = datapoint[key as keyof Location];\n return !(value === null || isUndefined(value));\n });\n};\n\nconst layers = new WeakMap<JSXElementConstructor<never>, { prefix: string }>([\n [BubbleLayer, { prefix: 'bubble' }],\n [DotLayer, { prefix: 'dot' }],\n [ChoroplethLayer, { prefix: 'choropleth' }],\n [ConnectionLayer, { prefix: 'connection' }],\n]);\n\nconst isValidLayer = (child: ReactNode): boolean => {\n if (!isElement(child) || typeof child.type === 'string') {\n return false;\n }\n const componentType = child.type as JSXElementConstructor<never>;\n return (\n layers.get(componentType) !== undefined &&\n (isSlot(child, BubbleLayer) ||\n isSlot(child, ConnectionLayer) ||\n isSlot(child, ChoroplethLayer) ||\n isSlot(child, DotLayer))\n );\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst createLayer = (child: ReactElement, data: any, layerId: string) => {\n if (isSlot(child, BubbleLayer)) {\n return <MapBubbleLayer {...child.props} data={data} layerId={layerId} />;\n }\n if (isSlot(child, ConnectionLayer)) {\n return (\n <MapConnectionLayer {...child.props} data={data} layerId={layerId} />\n );\n }\n if (isSlot(child, DotLayer)) {\n return <MapDotLayer {...child.props} data={data} layerId={layerId} />;\n }\n if (isSlot(child, ChoroplethLayer)) {\n return (\n <MapChoroplethLayer {...child.props} data={data} layerId={layerId} />\n );\n }\n return child;\n};\n\n/**\n * Set layers id to layer slots provided by the consumer.\n * @param children - MapView children\n * @returns An array with all the layers IDs and the children using the layer component\n */\nexport const setLayersId = (\n children: ReactNode,\n): {\n layerIds: string[];\n parsedChildren: ReactNode;\n valueAccessors: Map<string, string>;\n} => {\n const layerIds: string[] = [];\n let index = 0;\n const valueAccessors = new Map<string, string>();\n\n const parsedChildren = Children.map(children, (child) => {\n if (!isValidLayer(child)) {\n return child;\n }\n\n const validChild = child as ReactElement;\n const componentType = validChild.type as JSXElementConstructor<never>;\n const layer = layers.get(componentType);\n const layerId = `${layer?.prefix}-${index}`;\n\n if (\n isValidElement<LegendColorLayerProps>(validChild) &&\n validChild.props.color === 'legend' &&\n validChild.props.valueAccessor\n ) {\n valueAccessors.set(layerId, validChild.props.valueAccessor);\n }\n\n index += 1;\n layerIds.push(layerId);\n\n const layerIdValueAccessor = valueAccessors.get(layerId);\n const data = layerIdValueAccessor\n ? sanitizeData(validChild, layerIdValueAccessor)\n : validChild.props.data;\n\n return createLayer(validChild, data, layerId);\n });\n\n return { layerIds, parsedChildren, valueAccessors };\n};\n"],
5
+ "mappings": "AAuDW;AAvDX,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,SAAS,iBAAiB;AAE1B,SAAS,cAAc;AACvB,SAAS,eAAe,sBAAsB;AAC9C,SAAS,mBAAmB,0BAA0B;AACtD,SAAS,mBAAmB,0BAA0B;AACtD,SAAS,YAAY,mBAAmB;AACxC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAMzB,MAAM,eAAe,CAAC,OAA0B,QAAgB;AAC9D,SAAO,MAAM,MAAM,KAAK,OAAO,CAAC,cAAwB;AACtD,UAAM,QAAQ,UAAU,GAAqB;AAC7C,WAAO,EAAE,UAAU,QAAQ,YAAY,KAAK;AAAA,EAC9C,CAAC;AACH;AAEA,MAAM,SAAS,IAAI,QAA0D;AAAA,EAC3E,CAAC,aAAa,EAAE,QAAQ,SAAS,CAAC;AAAA,EAClC,CAAC,UAAU,EAAE,QAAQ,MAAM,CAAC;AAAA,EAC5B,CAAC,iBAAiB,EAAE,QAAQ,aAAa,CAAC;AAAA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C3B,WAAW,MAAM,eACjB;AACA,qBAAe,IAAI,SAAS,WAAW,MAAM,aAAa;AAAA,IAC5D;AAEA,aAAS;AACT,aAAS,KAAK,OAAO;AAErB,UAAM,uBAAuB,eAAe,IAAI,OAAO;AACvD,UAAM,OAAO,uBACT,aAAa,YAAY,oBAAoB,IAC7C,WAAW,MAAM;AAErB,WAAO,YAAY,YAAY,MAAM,OAAO;AAAA,EAC9C,CAAC;AAED,SAAO,EAAE,UAAU,gBAAgB,eAAe;AACpD;",
6
6
  "names": []
7
7
  }
package/map/MapView.js CHANGED
@@ -40,6 +40,7 @@ var import_color_scale_provider = require("./providers/color-scale.provider.js")
40
40
  var import_layer_color_strategy_provider = require("./providers/layer-color-strategy.provider.js");
41
41
  var import_ErrorStateSlot = require("./slots/states/ErrorStateSlot.js");
42
42
  var import_map_store_provider = require("./store/map-store.provider.js");
43
+ var import_build_scale_from_legend_config = require("./utils/build-scale-from-legend-config.js");
43
44
  var import_extract_layers_data = require("./utils/extract-layers-data.js");
44
45
  var import_get_map_states_template = require("./utils/get-map-states-template.js");
45
46
  var import_iterate_config_slots = require("./utils/iterate-config-slots.js");
@@ -63,6 +64,13 @@ const _MapView = (0, import_react.forwardRef)(
63
64
  legendDomain
64
65
  } = (0, import_extract_layers_data.extractLayersData)(parsedChildren, valueAccessors);
65
66
  const config = (0, import_iterate_config_slots.iterateConfigSlots)(children, legendDomain);
67
+ const getMaxRange = () => {
68
+ if (config.legend && (0, import_build_scale_from_legend_config.isThresholdLegend)(config.legend)) {
69
+ return config.legend.ranges.at(-1)?.to ?? legendDomain[1];
70
+ }
71
+ return legendDomain[1];
72
+ };
73
+ const dataMax = getMaxRange();
66
74
  const isLegendHidden = !config.legend || !!config.legend.hidden;
67
75
  const legendPosition = config.legend?.position;
68
76
  const legendRatio = config.legend?.ratio;
@@ -104,7 +112,7 @@ const _MapView = (0, import_react.forwardRef)(
104
112
  import_color_scale_provider.ColorScaleProvider,
105
113
  {
106
114
  categories,
107
- dataMax: legendDomain[1],
115
+ dataMax,
108
116
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_layer_color_strategy_provider.LayerColorStrategyProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
109
117
  import_charts._ChartLayout,
110
118
  {
@@ -1,5 +1,5 @@
1
1
  import type { ExpressionSpecification } from '@maplibre/maplibre-gl-style-spec';
2
- import type { _TruncationMode as TruncationMode } from '@dynatrace/strato-components/typography';
2
+ import type { TruncationMode } from '@dynatrace/strato-components/typography';
3
3
  import type { BaseLayerRules } from './types/base-layer.js';
4
4
  import type { BoundingBoxCoords } from './types/map-view.js';
5
5
  export declare const DEFAULT_COUNTRIES_FILL_COLOR: string;
@@ -1,2 +1,2 @@
1
- import type { _TruncationMode as TruncationMode } from '@dynatrace/strato-components/typography';
1
+ import type { TruncationMode } from '@dynatrace/strato-components/typography';
2
2
  export declare const MapTruncationModeContext: import("react").Context<TruncationMode>;
@@ -1,2 +1,2 @@
1
- import type { _TruncationMode as TruncationMode } from '@dynatrace/strato-components/typography';
1
+ import type { TruncationMode } from '@dynatrace/strato-components/typography';
2
2
  export declare const useTruncationMode: () => TruncationMode;
@@ -1,6 +1,6 @@
1
1
  import { StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
2
2
  import { type CSSProperties } from 'react';
3
- import type { _TruncationMode as TruncationMode } from '@dynatrace/strato-components/typography';
3
+ import type { TruncationMode } from '@dynatrace/strato-components/typography';
4
4
  import { Formatter } from '@dynatrace/strato-components-preview/charts';
5
5
  import { ConvertibleUnit, FormatOptions, Unit } from '@dynatrace-sdk/units';
6
6
  /**
@@ -82,10 +82,11 @@ const iterateConfigSlots = (children, legendDomain) => {
82
82
  }
83
83
  };
84
84
  } else if ((0, import_is_slot.isSlot)(child, import_ThresholdLegend.ThresholdLegend)) {
85
- const ranges = (0, import_replace_infinite_values_in_ranges.replaceInfiniteValuesInRanges)(
86
- child.props.ranges,
87
- legendDomain
88
- );
85
+ const getDomainValue = (index, legendDomainValue) => Number.isFinite(legendDomainValue) ? legendDomainValue : child.props.ranges?.at(index)?.to ?? legendDomainValue;
86
+ const ranges = (0, import_replace_infinite_values_in_ranges.replaceInfiniteValuesInRanges)(child.props.ranges, [
87
+ getDomainValue(0, legendDomain[0]),
88
+ getDomainValue(-1, legendDomain[1])
89
+ ]);
89
90
  slots = {
90
91
  ...slots,
91
92
  legend: {
@@ -46,47 +46,48 @@ const layers = new WeakMap([
46
46
  [import_ChoroplethLayer2.ChoroplethLayer, { prefix: "choropleth" }],
47
47
  [import_ConnectionLayer2.ConnectionLayer, { prefix: "connection" }]
48
48
  ]);
49
+ const isValidLayer = (child) => {
50
+ if (!(0, import_react_is.isElement)(child) || typeof child.type === "string") {
51
+ return false;
52
+ }
53
+ const componentType = child.type;
54
+ return layers.get(componentType) !== void 0 && ((0, import_is_slot.isSlot)(child, import_BubbleLayer2.BubbleLayer) || (0, import_is_slot.isSlot)(child, import_ConnectionLayer2.ConnectionLayer) || (0, import_is_slot.isSlot)(child, import_ChoroplethLayer2.ChoroplethLayer) || (0, import_is_slot.isSlot)(child, import_DotLayer2.DotLayer));
55
+ };
56
+ const createLayer = (child, data, layerId) => {
57
+ if ((0, import_is_slot.isSlot)(child, import_BubbleLayer2.BubbleLayer)) {
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_BubbleLayer.BubbleLayer, { ...child.props, data, layerId });
59
+ }
60
+ if ((0, import_is_slot.isSlot)(child, import_ConnectionLayer2.ConnectionLayer)) {
61
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ConnectionLayer.ConnectionLayer, { ...child.props, data, layerId });
62
+ }
63
+ if ((0, import_is_slot.isSlot)(child, import_DotLayer2.DotLayer)) {
64
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DotLayer.DotLayer, { ...child.props, data, layerId });
65
+ }
66
+ if ((0, import_is_slot.isSlot)(child, import_ChoroplethLayer2.ChoroplethLayer)) {
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ChoroplethLayer.ChoroplethLayer, { ...child.props, data, layerId });
68
+ }
69
+ return child;
70
+ };
49
71
  const setLayersId = (children) => {
50
72
  const layerIds = [];
51
73
  let index = 0;
52
74
  const valueAccessors = /* @__PURE__ */ new Map();
53
75
  const parsedChildren = import_react.Children.map(children, (child) => {
54
- if ((0, import_react_is.isElement)(child) && typeof child.type !== "string") {
55
- const layer = layers.get(child.type);
56
- if (layer !== void 0 && ((0, import_is_slot.isSlot)(child, import_BubbleLayer2.BubbleLayer) || (0, import_is_slot.isSlot)(child, import_ConnectionLayer2.ConnectionLayer) || (0, import_is_slot.isSlot)(child, import_ChoroplethLayer2.ChoroplethLayer) || (0, import_is_slot.isSlot)(child, import_DotLayer2.DotLayer))) {
57
- const layerId = `${layer?.prefix}-${index}`;
58
- if ((0, import_react.isValidElement)(child) && child.props.color === "legend" && child.props.valueAccessor) {
59
- valueAccessors.set(layerId, child.props.valueAccessor);
60
- }
61
- index += 1;
62
- layerIds.push(layerId);
63
- const data = valueAccessors.get(layerId) ? sanitizeData(child, valueAccessors.get(layerId)) : child.props.data;
64
- if ((0, import_is_slot.isSlot)(child, import_BubbleLayer2.BubbleLayer)) {
65
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_BubbleLayer.BubbleLayer, { ...child.props, data, layerId });
66
- } else if ((0, import_is_slot.isSlot)(child, import_ConnectionLayer2.ConnectionLayer)) {
67
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
- import_ConnectionLayer.ConnectionLayer,
69
- {
70
- ...child.props,
71
- data,
72
- layerId
73
- }
74
- );
75
- } else if ((0, import_is_slot.isSlot)(child, import_DotLayer2.DotLayer)) {
76
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DotLayer.DotLayer, { ...child.props, data, layerId });
77
- } else if ((0, import_is_slot.isSlot)(child, import_ChoroplethLayer2.ChoroplethLayer)) {
78
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
- import_ChoroplethLayer.ChoroplethLayer,
80
- {
81
- ...child.props,
82
- data,
83
- layerId
84
- }
85
- );
86
- }
87
- }
76
+ if (!isValidLayer(child)) {
77
+ return child;
78
+ }
79
+ const validChild = child;
80
+ const componentType = validChild.type;
81
+ const layer = layers.get(componentType);
82
+ const layerId = `${layer?.prefix}-${index}`;
83
+ if ((0, import_react.isValidElement)(validChild) && validChild.props.color === "legend" && validChild.props.valueAccessor) {
84
+ valueAccessors.set(layerId, validChild.props.valueAccessor);
88
85
  }
89
- return child;
86
+ index += 1;
87
+ layerIds.push(layerId);
88
+ const layerIdValueAccessor = valueAccessors.get(layerId);
89
+ const data = layerIdValueAccessor ? sanitizeData(validChild, layerIdValueAccessor) : validChild.props.data;
90
+ return createLayer(validChild, data, layerId);
90
91
  });
91
92
  return { layerIds, parsedChildren, valueAccessors };
92
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynatrace/strato-geo",
3
- "version": "1.7.2",
3
+ "version": "1.8.2",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "lang": "lang/uncompiled",
@@ -47,10 +47,10 @@
47
47
  "react-dom": "^18.0.0",
48
48
  "react-intl": "^6.0.8 || ^7.0.0",
49
49
  "react-is": "^18.0.0",
50
- "@dynatrace/strato-components": "^1.6.2",
51
- "@dynatrace/strato-components-preview": "^1.7.2",
50
+ "@dynatrace/strato-components": "^1.7.2",
52
51
  "@dynatrace/strato-design-tokens": "^1.0.1",
53
- "@dynatrace/strato-icons": "^1.5.0"
52
+ "@dynatrace/strato-components-preview": "^1.8.2",
53
+ "@dynatrace/strato-icons": "^1.5.1"
54
54
  },
55
55
  "sideEffects": [
56
56
  "./map/styles/react-mapgl-styles.css",