@dynatrace/strato-geo 1.3.4 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/esm/map/MapView.js +31 -24
  2. package/esm/map/MapView.js.map +2 -2
  3. package/esm/map/components/MapContent.js +43 -4
  4. package/esm/map/components/MapContent.js.map +2 -2
  5. package/esm/map/components/toolbar/buttons/MapResetButton.js +6 -1
  6. package/esm/map/components/toolbar/buttons/MapResetButton.js.map +2 -2
  7. package/esm/map/components/toolbar/buttons/MapZoomInOutButtons.js +4 -4
  8. package/esm/map/components/toolbar/buttons/MapZoomInOutButtons.js.map +2 -2
  9. package/esm/map/components/toolbar/buttons/MapZoomToFitButton.js +6 -1
  10. package/esm/map/components/toolbar/buttons/MapZoomToFitButton.js.map +2 -2
  11. package/esm/map/components/toolbar/utils/zoom-state-utils.js +36 -0
  12. package/esm/map/components/toolbar/utils/zoom-state-utils.js.map +7 -0
  13. package/esm/map/constants.js +6 -0
  14. package/esm/map/constants.js.map +2 -2
  15. package/esm/map/contexts/map-data-bounding-box.context.js +3 -1
  16. package/esm/map/contexts/map-data-bounding-box.context.js.map +2 -2
  17. package/esm/map/hooks/use-active-interaction.js +16 -12
  18. package/esm/map/hooks/use-active-interaction.js.map +2 -2
  19. package/esm/map/hooks/use-resolve-color.js +5 -2
  20. package/esm/map/hooks/use-resolve-color.js.map +2 -2
  21. package/esm/map/providers/color-scale.provider.js +2 -1
  22. package/esm/map/providers/color-scale.provider.js.map +2 -2
  23. package/esm/map/providers/imperative-handler.provider.js +7 -1
  24. package/esm/map/providers/imperative-handler.provider.js.map +2 -2
  25. package/esm/map/store/map-store.context.js +7 -1
  26. package/esm/map/store/map-store.context.js.map +2 -2
  27. package/esm/map/store/selectors.js +2 -0
  28. package/esm/map/store/selectors.js.map +2 -2
  29. package/esm/map/store/store.js +13 -0
  30. package/esm/map/store/store.js.map +2 -2
  31. package/esm/map/utils/build-scale-from-legend-config.js +4 -2
  32. package/esm/map/utils/build-scale-from-legend-config.js.map +2 -2
  33. package/esm/map/utils/extract-layers-data.js +4 -4
  34. package/esm/map/utils/extract-layers-data.js.map +2 -2
  35. package/esm/map/utils/get-data-layers-bounding-box.js +1 -1
  36. package/esm/map/utils/get-data-layers-bounding-box.js.map +2 -2
  37. package/esm/map/utils/iterate-config-slots.js +7 -1
  38. package/esm/map/utils/iterate-config-slots.js.map +2 -2
  39. package/esm/map/utils/replace-infinite-values-in-ranges.js +30 -0
  40. package/esm/map/utils/replace-infinite-values-in-ranges.js.map +7 -0
  41. package/esm/map/utils/to-mapbox-initial-view-state.js.map +2 -2
  42. package/index.js +3 -3
  43. package/map/MapView.js +31 -24
  44. package/map/components/MapContent.js +36 -2
  45. package/map/components/toolbar/buttons/MapResetButton.js +6 -1
  46. package/map/components/toolbar/buttons/MapZoomInOutButtons.js +4 -4
  47. package/map/components/toolbar/buttons/MapZoomToFitButton.js +6 -1
  48. package/map/components/toolbar/utils/zoom-state-utils.d.ts +4 -0
  49. package/map/components/toolbar/utils/zoom-state-utils.js +47 -0
  50. package/map/constants.d.ts +5 -1
  51. package/map/constants.js +6 -0
  52. package/map/contexts/map-data-bounding-box.context.d.ts +2 -1
  53. package/map/contexts/map-data-bounding-box.context.js +3 -1
  54. package/map/hooks/use-active-interaction.js +16 -12
  55. package/map/hooks/use-data-bounding-box.d.ts +1 -1
  56. package/map/hooks/use-resolve-color.js +1 -1
  57. package/map/providers/color-scale.provider.d.ts +3 -1
  58. package/map/providers/color-scale.provider.js +2 -1
  59. package/map/providers/imperative-handler.provider.js +7 -1
  60. package/map/store/map-store.context.d.ts +6 -0
  61. package/map/store/map-store.context.js +7 -1
  62. package/map/store/selectors.d.ts +1 -0
  63. package/map/store/selectors.js +2 -0
  64. package/map/store/store.d.ts +2 -1
  65. package/map/store/store.js +13 -0
  66. package/map/types/map-view.d.ts +2 -0
  67. package/map/types/state.d.ts +8 -0
  68. package/map/utils/build-scale-from-legend-config.d.ts +1 -1
  69. package/map/utils/build-scale-from-legend-config.js +4 -2
  70. package/map/utils/extract-layers-data.js +4 -4
  71. package/map/utils/get-data-layers-bounding-box.d.ts +2 -1
  72. package/map/utils/get-data-layers-bounding-box.js +1 -1
  73. package/map/utils/iterate-config-slots.js +7 -1
  74. package/map/utils/replace-infinite-values-in-ranges.d.ts +6 -0
  75. package/map/{components/legend/utils/resolve-color.js → utils/replace-infinite-values-in-ranges.js} +27 -18
  76. package/map/utils/to-mapbox-initial-view-state.d.ts +6 -4
  77. package/package.json +4 -4
  78. package/esm/map/components/legend/utils/resolve-color.js +0 -21
  79. package/esm/map/components/legend/utils/resolve-color.js.map +0 -7
  80. package/map/components/legend/utils/resolve-color.d.ts +0 -8
@@ -27,24 +27,28 @@ const useActiveInteraction = () => {
27
27
  { source: sourceId, id: featureId },
28
28
  { active: !activeState }
29
29
  );
30
- allFeatures.map(
31
- (feature) => map.setFeatureState(
32
- { source: feature.layer.source, id: feature.id },
33
- { isAnyActive: !activeState }
34
- )
35
- );
30
+ allFeatures.forEach((feature) => {
31
+ if (feature.id !== void 0 && feature.layer.source !== void 0) {
32
+ map.setFeatureState(
33
+ { source: feature.layer.source, id: feature.id },
34
+ { isAnyActive: !activeState }
35
+ );
36
+ }
37
+ });
36
38
  } else {
37
39
  if (!isUndefined(featureId) && !isUndefined(sourceId)) {
38
40
  map.setFeatureState(
39
41
  { source: sourceId, id: featureId },
40
42
  { active: false }
41
43
  );
42
- allFeatures.map(
43
- (feature) => map.setFeatureState(
44
- { source: feature.layer.source, id: feature.id },
45
- { isAnyActive: false }
46
- )
47
- );
44
+ allFeatures.forEach((feature) => {
45
+ if (feature.id !== void 0 && feature.layer.source !== void 0) {
46
+ map.setFeatureState(
47
+ { source: feature.layer.source, id: feature.id },
48
+ { isAnyActive: false }
49
+ );
50
+ }
51
+ });
48
52
  }
49
53
  }
50
54
  },
@@ -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';\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 featureId = features[0].id;\n sourceId = features[0].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.map((feature) =>\n map.setFeatureState(\n { source: feature.layer.source, id: feature.id },\n { isAnyActive: !activeState },\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.map((feature) =>\n map.setFeatureState(\n { source: feature.layer.source, id: feature.id },\n { isAnyActive: false },\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;AAExB,MAAM,uBAA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AE,aAAa,MAAM;AAAA,YACvB;AAAA,UACF;AAAA,QACF;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';\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 featureId = features[0].id;\n sourceId = features[0].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;AAExB,MAAM,uBAAuB,MAAM;AACxC,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,oBAAY,SAAS,CAAC,EAAE;AACxB,mBAAW,SAAS,CAAC,EAAE,MAAM;AAC7B,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
  }
@@ -6,14 +6,17 @@ import { useMapConfig } from "./use-map-config.js";
6
6
  import {
7
7
  isLegendColoring
8
8
  } from "../types/coloring.js";
9
- import { isSequentialLegend } from "../utils/build-scale-from-legend-config.js";
9
+ import {
10
+ isSequentialLegend,
11
+ isThresholdLegend
12
+ } from "../utils/build-scale-from-legend-config.js";
10
13
  const useResolveColor = (defaultColor, props, colorParser) => {
11
14
  const legendColoring = useColorScale();
12
15
  const { legend } = useMapConfig();
13
16
  if (!isLegendColoring(props)) {
14
17
  return props.color ?? defaultColor;
15
18
  }
16
- const fallbackColor = !isUndefined(legend) && isSequentialLegend(legend) ? DEFAULT_RANGE_COLOR : defaultColor;
19
+ const fallbackColor = !isUndefined(legend) && (isSequentialLegend(legend) || isThresholdLegend(legend)) ? DEFAULT_RANGE_COLOR : defaultColor;
17
20
  let colorLegend = fallbackColor;
18
21
  if (!isUndefined(legendColoring) && !isUndefined(colorParser)) {
19
22
  colorLegend = (item) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/hooks/use-resolve-color.ts"],
4
- "sourcesContent": ["import { isUndefined } from 'lodash-es';\n\nimport { _accessValue as accessValue } from '@dynatrace/strato-components-preview/core';\n\nimport { useColorScale } from './use-color-scale.js';\nimport { DEFAULT_RANGE_COLOR } from '../constants.js';\nimport { useMapConfig } from './use-map-config.js';\nimport {\n ChoroplethCustomColorProps,\n ColorParser,\n ConnectionColorProps,\n isLegendColoring,\n LegendColorLayerProps,\n LocationColorProps,\n} from '../types/coloring.js';\nimport { Connection } from '../types/connection-layer.js';\nimport { Location } from '../types/location.js';\nimport { isSequentialLegend } from '../utils/build-scale-from-legend-config.js';\n\nexport const useResolveColor = (\n defaultColor: string,\n props:\n | LocationColorProps<never>\n | ConnectionColorProps<never>\n | ChoroplethCustomColorProps<never>\n | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n const legendColoring = useColorScale();\n\n const { legend } = useMapConfig();\n\n if (!isLegendColoring(props)) {\n return props.color ?? defaultColor;\n }\n\n const fallbackColor =\n !isUndefined(legend) && isSequentialLegend(legend)\n ? DEFAULT_RANGE_COLOR\n : defaultColor;\n\n let colorLegend: ((item: Record<string, unknown>) => string) | string =\n fallbackColor;\n\n if (!isUndefined(legendColoring) && !isUndefined(colorParser)) {\n colorLegend = (item: Record<string, unknown>): string => {\n const value = accessValue<number | string>(item, props.valueAccessor);\n if (isUndefined(value)) {\n return fallbackColor;\n }\n\n return colorParser(value) ?? fallbackColor;\n };\n }\n\n return colorLegend;\n};\n\nexport const useResolveLocationColor = <T extends Location>(\n defaultColor: string,\n props: LocationColorProps<T> | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n return useResolveColor(defaultColor, props, colorParser) as\n | string\n | ((item: T) => string);\n};\n\nexport const useResolveConnectionColor = <T extends Connection>(\n defaultColor: string,\n props: ConnectionColorProps<T> | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n return useResolveColor(defaultColor, props, colorParser) as\n | string\n | ((item: T) => string);\n};\n\nexport const useResolveChoroplethColor = <T extends Record<string, unknown>>(\n defaultColor: string,\n props: ChoroplethCustomColorProps<T> | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n return useResolveColor(defaultColor, props, colorParser) as\n | string\n | ((item: T) => string);\n};\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB,mBAAmB;AAE5C,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B;AAAA,EAIE;AAAA,OAGK;AAGP,SAAS,0BAA0B;AAE5B,MAAM,kBAAkB,CAC7B,cACA,OAKA,gBACG;AACH,QAAM,iBAAiB,cAAc;AAErC,QAAM,EAAE,OAAO,IAAI,aAAa;AAEhC,MAAI,CAAC,iBAAiB,KAAK,GAAG;AAC5B,WAAO,MAAM,SAAS;AAAA,EACxB;AAEA,QAAM,gBACJ,CAAC,YAAY,MAAM,KAAK,mBAAmB,MAAM,IAC7C,sBACA;AAEN,MAAI,cACF;AAEF,MAAI,CAAC,YAAY,cAAc,KAAK,CAAC,YAAY,WAAW,GAAG;AAC7D,kBAAc,CAAC,SAA0C;AACvD,YAAM,QAAQ,YAA6B,MAAM,MAAM,aAAa;AACpE,UAAI,YAAY,KAAK,GAAG;AACtB,eAAO;AAAA,MACT;AAEA,aAAO,YAAY,KAAK,KAAK;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,0BAA0B,CACrC,cACA,OACA,gBACG;AACH,SAAO,gBAAgB,cAAc,OAAO,WAAW;AAGzD;AAEO,MAAM,4BAA4B,CACvC,cACA,OACA,gBACG;AACH,SAAO,gBAAgB,cAAc,OAAO,WAAW;AAGzD;AAEO,MAAM,4BAA4B,CACvC,cACA,OACA,gBACG;AACH,SAAO,gBAAgB,cAAc,OAAO,WAAW;AAGzD;",
4
+ "sourcesContent": ["import { isUndefined } from 'lodash-es';\n\nimport { _accessValue as accessValue } from '@dynatrace/strato-components-preview/core';\n\nimport { useColorScale } from './use-color-scale.js';\nimport { DEFAULT_RANGE_COLOR } from '../constants.js';\nimport { useMapConfig } from './use-map-config.js';\nimport {\n ChoroplethCustomColorProps,\n ColorParser,\n ConnectionColorProps,\n isLegendColoring,\n LegendColorLayerProps,\n LocationColorProps,\n} from '../types/coloring.js';\nimport { Connection } from '../types/connection-layer.js';\nimport { Location } from '../types/location.js';\nimport {\n isSequentialLegend,\n isThresholdLegend,\n} from '../utils/build-scale-from-legend-config.js';\n\nexport const useResolveColor = (\n defaultColor: string,\n props:\n | LocationColorProps<never>\n | ConnectionColorProps<never>\n | ChoroplethCustomColorProps<never>\n | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n const legendColoring = useColorScale();\n\n const { legend } = useMapConfig();\n\n if (!isLegendColoring(props)) {\n return props.color ?? defaultColor;\n }\n\n const fallbackColor =\n !isUndefined(legend) &&\n (isSequentialLegend(legend) || isThresholdLegend(legend))\n ? DEFAULT_RANGE_COLOR\n : defaultColor;\n\n let colorLegend: ((item: Record<string, unknown>) => string) | string =\n fallbackColor;\n\n if (!isUndefined(legendColoring) && !isUndefined(colorParser)) {\n colorLegend = (item: Record<string, unknown>): string => {\n const value = accessValue<number | string>(item, props.valueAccessor);\n if (isUndefined(value)) {\n return fallbackColor;\n }\n\n return colorParser(value) ?? fallbackColor;\n };\n }\n\n return colorLegend;\n};\n\nexport const useResolveLocationColor = <T extends Location>(\n defaultColor: string,\n props: LocationColorProps<T> | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n return useResolveColor(defaultColor, props, colorParser) as\n | string\n | ((item: T) => string);\n};\n\nexport const useResolveConnectionColor = <T extends Connection>(\n defaultColor: string,\n props: ConnectionColorProps<T> | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n return useResolveColor(defaultColor, props, colorParser) as\n | string\n | ((item: T) => string);\n};\n\nexport const useResolveChoroplethColor = <T extends Record<string, unknown>>(\n defaultColor: string,\n props: ChoroplethCustomColorProps<T> | LegendColorLayerProps,\n colorParser?: ColorParser,\n) => {\n return useResolveColor(defaultColor, props, colorParser) as\n | string\n | ((item: T) => string);\n};\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB,mBAAmB;AAE5C,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B;AAAA,EAIE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEA,MAAM,kBAAkB,CAC7B,cACA,OAKA,gBACG;AACH,QAAM,iBAAiB,cAAc;AAErC,QAAM,EAAE,OAAO,IAAI,aAAa;AAEhC,MAAI,CAAC,iBAAiB,KAAK,GAAG;AAC5B,WAAO,MAAM,SAAS;AAAA,EACxB;AAEA,QAAM,gBACJ,CAAC,YAAY,MAAM,MAClB,mBAAmB,MAAM,KAAK,kBAAkB,MAAM,KACnD,sBACA;AAEN,MAAI,cACF;AAEF,MAAI,CAAC,YAAY,cAAc,KAAK,CAAC,YAAY,WAAW,GAAG;AAC7D,kBAAc,CAAC,SAA0C;AACvD,YAAM,QAAQ,YAA6B,MAAM,MAAM,aAAa;AACpE,UAAI,YAAY,KAAK,GAAG;AACtB,eAAO;AAAA,MACT;AAEA,aAAO,YAAY,KAAK,KAAK;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,0BAA0B,CACrC,cACA,OACA,gBACG;AACH,SAAO,gBAAgB,cAAc,OAAO,WAAW;AAGzD;AAEO,MAAM,4BAA4B,CACvC,cACA,OACA,gBACG;AACH,SAAO,gBAAgB,cAAc,OAAO,WAAW;AAGzD;AAEO,MAAM,4BAA4B,CACvC,cACA,OACA,gBACG;AACH,SAAO,gBAAgB,cAAc,OAAO,WAAW;AAGzD;",
6
6
  "names": []
7
7
  }
@@ -5,6 +5,7 @@ import { useMapConfig } from "../hooks/use-map-config.js";
5
5
  import { buildScaleFromLegendConfig } from "../utils/build-scale-from-legend-config.js";
6
6
  const ColorScaleProvider = ({
7
7
  categories,
8
+ dataMax,
8
9
  children
9
10
  }) => {
10
11
  const { legend } = useMapConfig();
@@ -12,7 +13,7 @@ const ColorScaleProvider = ({
12
13
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
13
14
  }
14
15
  const categoriesArray = "categories" in legend && legend.categories ? legend.categories : categories;
15
- const scale = buildScaleFromLegendConfig(legend, categoriesArray);
16
+ const scale = buildScaleFromLegendConfig(legend, categoriesArray, dataMax);
16
17
  return /* @__PURE__ */ React.createElement(ColorScaleContext.Provider, { value: scale }, children);
17
18
  };
18
19
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/providers/color-scale.provider.tsx"],
4
- "sourcesContent": ["import { isEmpty } from 'lodash-es';\nimport React, { type PropsWithChildren } from 'react';\n\nimport { ColorScaleContext } from '../contexts/color-scale.context.js';\nimport { useMapConfig } from '../hooks/use-map-config.js';\nimport { buildScaleFromLegendConfig } from '../utils/build-scale-from-legend-config.js';\n\n/**\n * This provider will hold the scale used to map from a value of the domain\n * to a color in the color palette (range) or undefined in case is out of the\n * domain. This is valid if the consumer set a layer to be colored by the\n * legend, else this provider will be undefined.\n * As we use different scales, the consumer (of this provider) will need to\n * set some type guards to ensure ts compliance.\n * Because of that and to ease the consumption of this provider, we created\n * another one that make use of this scale.\n * @see {@link LayerColorStrategyProvider}\n * @example to build a legend the raw scale could be needed\n * @param categories - Available categories to be shown in the legend\n * @param children -\n */\nexport const ColorScaleProvider = ({\n categories,\n children,\n}: PropsWithChildren<{\n categories: string[];\n}>) => {\n const { legend } = useMapConfig();\n\n if (isEmpty(legend)) {\n return <>{children}</>;\n }\n\n /**\n * prop categories will be deprecated, details:\n * https://dt-rnd.atlassian.net/browse/APPDEV-11805\n * Remove categoriesArray after this, and use category prop\n */\n const categoriesArray =\n 'categories' in legend && legend.categories\n ? legend.categories\n : categories;\n\n const scale = buildScaleFromLegendConfig(legend, categoriesArray);\n\n return (\n <ColorScaleContext.Provider value={scale}>\n {children}\n </ColorScaleContext.Provider>\n );\n};\n"],
5
- "mappings": "AAAA,SAAS,eAAe;AACxB,OAAO,WAAuC;AAE9C,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,kCAAkC;AAgBpC,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AACF,MAEO;AACL,QAAM,EAAE,OAAO,IAAI,aAAa;AAEhC,MAAI,QAAQ,MAAM,GAAG;AACnB,WAAO,0DAAG,QAAS;AAAA,EACrB;AAOA,QAAM,kBACJ,gBAAgB,UAAU,OAAO,aAC7B,OAAO,aACP;AAEN,QAAM,QAAQ,2BAA2B,QAAQ,eAAe;AAEhE,SACE,oCAAC,kBAAkB,UAAlB,EAA2B,OAAO,SAChC,QACH;AAEJ;",
4
+ "sourcesContent": ["import { isEmpty } from 'lodash-es';\nimport React, { type PropsWithChildren } from 'react';\n\nimport { ColorScaleContext } from '../contexts/color-scale.context.js';\nimport { useMapConfig } from '../hooks/use-map-config.js';\nimport { buildScaleFromLegendConfig } from '../utils/build-scale-from-legend-config.js';\n\n/**\n * This provider will hold the scale used to map from a value of the domain\n * to a color in the color palette (range) or undefined in case is out of the\n * domain. This is valid if the consumer set a layer to be colored by the\n * legend, else this provider will be undefined.\n * As we use different scales, the consumer (of this provider) will need to\n * set some type guards to ensure ts compliance.\n * Because of that and to ease the consumption of this provider, we created\n * another one that make use of this scale.\n * @see {@link LayerColorStrategyProvider}\n * @example to build a legend the raw scale could be needed\n * @param categories - Available categories to be shown in the legend\n * @param dataMax - Maximum value present in the data\n * @param children -\n */\nexport const ColorScaleProvider = ({\n categories,\n dataMax,\n children,\n}: PropsWithChildren<{\n categories: string[];\n dataMax: number;\n}>) => {\n const { legend } = useMapConfig();\n\n if (isEmpty(legend)) {\n return <>{children}</>;\n }\n\n /**\n * prop categories will be deprecated, details:\n * https://dt-rnd.atlassian.net/browse/APPDEV-11805\n * Remove categoriesArray after this, and use category prop\n */\n const categoriesArray =\n 'categories' in legend && legend.categories\n ? legend.categories\n : categories;\n\n const scale = buildScaleFromLegendConfig(legend, categoriesArray, dataMax);\n\n return (\n <ColorScaleContext.Provider value={scale}>\n {children}\n </ColorScaleContext.Provider>\n );\n};\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;AACxB,OAAO,WAAuC;AAE9C,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,kCAAkC;AAiBpC,MAAM,qBAAqB,CAAC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACF,MAGO;AACL,QAAM,EAAE,OAAO,IAAI,aAAa;AAEhC,MAAI,QAAQ,MAAM,GAAG;AACnB,WAAO,0DAAG,QAAS;AAAA,EACrB;AAOA,QAAM,kBACJ,gBAAgB,UAAU,OAAO,aAC7B,OAAO,aACP;AAEN,QAAM,QAAQ,2BAA2B,QAAQ,iBAAiB,OAAO;AAEzE,SACE,oCAAC,kBAAkB,UAAlB,EAA2B,OAAO,SAChC,QACH;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -4,6 +4,7 @@ import { FIT_BOUNDS_OPTIONS } from "../constants.js";
4
4
  import { useDataBoundingBox } from "../hooks/use-data-bounding-box.js";
5
5
  import { useInitialViewContext } from "../hooks/use-initial-view-context.js";
6
6
  import { useMapRawData } from "../hooks/use-map-raw-data.js";
7
+ import { useSetStateZoom } from "../store/store.js";
7
8
  import { buildAndDownloadCsv } from "../utils/build-and-download-csv.js";
8
9
  const MapViewImperativeHandler = ({
9
10
  forwardedRef,
@@ -14,8 +15,13 @@ const MapViewImperativeHandler = ({
14
15
  const { current: map } = useMap();
15
16
  const { longitude = 0, latitude = 0, zoom = 0 } = useInitialViewContext();
16
17
  const boundingBox = useDataBoundingBox();
18
+ const setZoomState = useSetStateZoom();
17
19
  const zoomOutEnabled = map && map?.getMinZoom() !== map?.getZoom();
18
20
  const zoomInEnabled = map && map?.getMaxZoom() !== map?.getZoom();
21
+ const handleZoomToFit = () => {
22
+ map?.fitBounds(boundingBox, FIT_BOUNDS_OPTIONS);
23
+ setZoomState({ zoomToFitEnabled: false, zoomToFitInProgress: true });
24
+ };
19
25
  useImperativeHandle(forwardedRef, () => ({
20
26
  element: containerRef.current,
21
27
  downloadData: () => {
@@ -23,7 +29,7 @@ const MapViewImperativeHandler = ({
23
29
  },
24
30
  zoomIn: () => zoomInEnabled && map?.zoomIn(),
25
31
  zoomOut: () => zoomOutEnabled && map?.zoomOut(),
26
- zoomToFit: () => map?.fitBounds(boundingBox, FIT_BOUNDS_OPTIONS),
32
+ zoomToFit: () => handleZoomToFit(),
27
33
  reset: () => map?.flyTo({ center: [longitude, latitude], zoom })
28
34
  }));
29
35
  return children;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/providers/imperative-handler.provider.ts"],
4
- "sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { PropsWithChildren, useImperativeHandle } from 'react';\n\nimport { FIT_BOUNDS_OPTIONS } from '../constants.js';\nimport { useDataBoundingBox } from '../hooks/use-data-bounding-box.js';\nimport { useInitialViewContext } from '../hooks/use-initial-view-context.js';\nimport { useMapRawData } from '../hooks/use-map-raw-data.js';\nimport type { MapViewRef } from '../types/map-view.js';\nimport { buildAndDownloadCsv } from '../utils/build-and-download-csv.js';\n\nexport interface MapViewImperativeHandlerProps {\n forwardedRef: React.Ref<MapViewRef>;\n containerRef: React.RefObject<HTMLDivElement>;\n}\n\nexport const MapViewImperativeHandler = ({\n forwardedRef,\n containerRef,\n children,\n}: PropsWithChildren<MapViewImperativeHandlerProps>) => {\n const layersData = useMapRawData();\n const { current: map } = useMap();\n const { longitude = 0, latitude = 0, zoom = 0 } = useInitialViewContext();\n const boundingBox = useDataBoundingBox();\n const zoomOutEnabled = map && map?.getMinZoom() !== map?.getZoom();\n const zoomInEnabled = map && map?.getMaxZoom() !== map?.getZoom();\n\n useImperativeHandle(forwardedRef, () => ({\n element: containerRef.current,\n downloadData: () => {\n buildAndDownloadCsv(layersData);\n },\n zoomIn: () => zoomInEnabled && map?.zoomIn(),\n zoomOut: () => zoomOutEnabled && map?.zoomOut(),\n zoomToFit: () => map?.fitBounds(boundingBox, FIT_BOUNDS_OPTIONS),\n reset: () => map?.flyTo({ center: [longitude, latitude], zoom: zoom }),\n }));\n\n return children;\n};\n"],
5
- "mappings": "AAAA,SAAS,cAAc;AACvB,SAA4B,2BAA2B;AAEvD,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAE9B,SAAS,2BAA2B;AAO7B,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,MAAwD;AACtD,QAAM,aAAa,cAAc;AACjC,QAAM,EAAE,SAAS,IAAI,IAAI,OAAO;AAChC,QAAM,EAAE,YAAY,GAAG,WAAW,GAAG,OAAO,EAAE,IAAI,sBAAsB;AACxE,QAAM,cAAc,mBAAmB;AACvC,QAAM,iBAAiB,OAAO,KAAK,WAAW,MAAM,KAAK,QAAQ;AACjE,QAAM,gBAAgB,OAAO,KAAK,WAAW,MAAM,KAAK,QAAQ;AAEhE,sBAAoB,cAAc,OAAO;AAAA,IACvC,SAAS,aAAa;AAAA,IACtB,cAAc,MAAM;AAClB,0BAAoB,UAAU;AAAA,IAChC;AAAA,IACA,QAAQ,MAAM,iBAAiB,KAAK,OAAO;AAAA,IAC3C,SAAS,MAAM,kBAAkB,KAAK,QAAQ;AAAA,IAC9C,WAAW,MAAM,KAAK,UAAU,aAAa,kBAAkB;AAAA,IAC/D,OAAO,MAAM,KAAK,MAAM,EAAE,QAAQ,CAAC,WAAW,QAAQ,GAAG,KAAW,CAAC;AAAA,EACvE,EAAE;AAEF,SAAO;AACT;",
4
+ "sourcesContent": ["import { useMap } from '@vis.gl/react-maplibre';\nimport { PropsWithChildren, useImperativeHandle } from 'react';\n\nimport { FIT_BOUNDS_OPTIONS } from '../constants.js';\nimport { useDataBoundingBox } from '../hooks/use-data-bounding-box.js';\nimport { useInitialViewContext } from '../hooks/use-initial-view-context.js';\nimport { useMapRawData } from '../hooks/use-map-raw-data.js';\nimport { useSetStateZoom } from '../store/store.js';\nimport type { MapViewRef } from '../types/map-view.js';\nimport { buildAndDownloadCsv } from '../utils/build-and-download-csv.js';\n\nexport interface MapViewImperativeHandlerProps {\n forwardedRef: React.Ref<MapViewRef>;\n containerRef: React.RefObject<HTMLDivElement>;\n}\n\nexport const MapViewImperativeHandler = ({\n forwardedRef,\n containerRef,\n children,\n}: PropsWithChildren<MapViewImperativeHandlerProps>) => {\n const layersData = useMapRawData();\n const { current: map } = useMap();\n const { longitude = 0, latitude = 0, zoom = 0 } = useInitialViewContext();\n const boundingBox = useDataBoundingBox();\n const setZoomState = useSetStateZoom();\n const zoomOutEnabled = map && map?.getMinZoom() !== map?.getZoom();\n const zoomInEnabled = map && map?.getMaxZoom() !== map?.getZoom();\n\n const handleZoomToFit = () => {\n map?.fitBounds(boundingBox, FIT_BOUNDS_OPTIONS);\n setZoomState({ zoomToFitEnabled: false, zoomToFitInProgress: true });\n };\n\n useImperativeHandle(forwardedRef, () => ({\n element: containerRef.current,\n downloadData: () => {\n buildAndDownloadCsv(layersData);\n },\n zoomIn: () => zoomInEnabled && map?.zoomIn(),\n zoomOut: () => zoomOutEnabled && map?.zoomOut(),\n zoomToFit: () => handleZoomToFit(),\n reset: () => map?.flyTo({ center: [longitude, latitude], zoom: zoom }),\n }));\n\n return children;\n};\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AACvB,SAA4B,2BAA2B;AAEvD,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAEhC,SAAS,2BAA2B;AAO7B,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,MAAwD;AACtD,QAAM,aAAa,cAAc;AACjC,QAAM,EAAE,SAAS,IAAI,IAAI,OAAO;AAChC,QAAM,EAAE,YAAY,GAAG,WAAW,GAAG,OAAO,EAAE,IAAI,sBAAsB;AACxE,QAAM,cAAc,mBAAmB;AACvC,QAAM,eAAe,gBAAgB;AACrC,QAAM,iBAAiB,OAAO,KAAK,WAAW,MAAM,KAAK,QAAQ;AACjE,QAAM,gBAAgB,OAAO,KAAK,WAAW,MAAM,KAAK,QAAQ;AAEhE,QAAM,kBAAkB,MAAM;AAC5B,SAAK,UAAU,aAAa,kBAAkB;AAC9C,iBAAa,EAAE,kBAAkB,OAAO,qBAAqB,KAAK,CAAC;AAAA,EACrE;AAEA,sBAAoB,cAAc,OAAO;AAAA,IACvC,SAAS,aAAa;AAAA,IACtB,cAAc,MAAM;AAClB,0BAAoB,UAAU;AAAA,IAChC;AAAA,IACA,QAAQ,MAAM,iBAAiB,KAAK,OAAO;AAAA,IAC3C,SAAS,MAAM,kBAAkB,KAAK,QAAQ;AAAA,IAC9C,WAAW,MAAM,gBAAgB;AAAA,IACjC,OAAO,MAAM,KAAK,MAAM,EAAE,QAAQ,CAAC,WAAW,QAAQ,GAAG,KAAW,CAAC;AAAA,EACvE,EAAE;AAEF,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -15,7 +15,13 @@ const initialState = {
15
15
  overlay: {
16
16
  mouseInBounds: false
17
17
  },
18
- selection: initialSelection
18
+ selection: initialSelection,
19
+ zoom: {
20
+ zoomInEnabled: true,
21
+ zoomOutEnabled: true,
22
+ zoomToFitEnabled: true,
23
+ resetEnabled: false
24
+ }
19
25
  };
20
26
  const MapStore = React.createContext(
21
27
  createStore(initialState)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/store/map-store.context.ts"],
4
- "sourcesContent": ["import React from 'react';\n\nimport {\n createStore,\n type Store,\n} from '@dynatrace/strato-components-preview/core';\n\nimport type { MapState } from '../types/state.js';\n\nconst initialSelection = { highlightedSeries: undefined, visible: undefined };\n\nexport const initialState = {\n tooltip: {\n pinned: false,\n visible: false,\n enabled: true,\n hoveredLayerId: undefined,\n data: undefined,\n position: undefined,\n },\n overlay: {\n mouseInBounds: false,\n },\n selection: initialSelection,\n};\n\nexport const MapStore = React.createContext<Store<MapState>>(\n createStore<MapState>(initialState),\n);\n\nMapStore['displayName'] = 'MapStore';\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAElB;AAAA,EACE;AAAA,OAEK;AAIP,MAAM,mBAAmB,EAAE,mBAAmB,QAAW,SAAS,OAAU;AAErE,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,SAAS;AAAA,IACP,eAAe;AAAA,EACjB;AAAA,EACA,WAAW;AACb;AAEO,MAAM,WAAW,MAAM;AAAA,EAC5B,YAAsB,YAAY;AACpC;AAEA,SAAS,aAAa,IAAI;",
4
+ "sourcesContent": ["import React from 'react';\n\nimport {\n createStore,\n type Store,\n} from '@dynatrace/strato-components-preview/core';\n\nimport type { MapState } from '../types/state.js';\n\nconst initialSelection = { highlightedSeries: undefined, visible: undefined };\n\nexport const initialState = {\n tooltip: {\n pinned: false,\n visible: false,\n enabled: true,\n hoveredLayerId: undefined,\n data: undefined,\n position: undefined,\n },\n overlay: {\n mouseInBounds: false,\n },\n selection: initialSelection,\n zoom: {\n zoomInEnabled: true,\n zoomOutEnabled: true,\n zoomToFitEnabled: true,\n resetEnabled: false,\n },\n};\n\nexport const MapStore = React.createContext<Store<MapState>>(\n createStore<MapState>(initialState),\n);\n\nMapStore['displayName'] = 'MapStore';\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAElB;AAAA,EACE;AAAA,OAEK;AAIP,MAAM,mBAAmB,EAAE,mBAAmB,QAAW,SAAS,OAAU;AAErE,MAAM,eAAe;AAAA,EAC1B,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AAAA,EACA,SAAS;AAAA,IACP,eAAe;AAAA,EACjB;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,cAAc;AAAA,EAChB;AACF;AAEO,MAAM,WAAW,MAAM;AAAA,EAC5B,YAAsB,YAAY;AACpC;AAEA,SAAS,aAAa,IAAI;",
6
6
  "names": []
7
7
  }
@@ -14,11 +14,13 @@ const useMapTooltipPinnedState = () => useSelector(({ tooltip }) => {
14
14
  return pinned;
15
15
  });
16
16
  const useMapOverlayState = () => useSelector(({ overlay }) => overlay);
17
+ const useMapZoomState = () => useSelector(({ zoom }) => zoom);
17
18
  export {
18
19
  useMapOverlayState,
19
20
  useMapSelectionState,
20
21
  useMapTooltipPinnedState,
21
22
  useMapTooltipState,
23
+ useMapZoomState,
22
24
  useSelector
23
25
  };
24
26
  //# sourceMappingURL=selectors.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/store/selectors.ts"],
4
- "sourcesContent": ["import { isEqual } from 'lodash-es';\nimport { Context } from 'react';\n\nimport {\n Store,\n useStoreSelector,\n} from '@dynatrace/strato-components-preview/core';\n\nimport { MapStore } from './map-store.context.js';\nimport type { MapState } from '../types/state.js';\n\nexport const useSelector = <T, O>(selector: (state: MapState<T>) => O): O =>\n useStoreSelector(MapStore as Context<Store<MapState<T>>>, selector, isEqual);\n\nexport const useMapSelectionState = <T>() =>\n useSelector(({ selection }: MapState<T>) => selection);\n\nexport const useMapTooltipState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned, ...tooltipState } = tooltip;\n\n return tooltipState;\n });\n\nexport const useMapTooltipPinnedState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned } = tooltip;\n\n return pinned;\n });\n\nexport const useMapOverlayState = <T>() =>\n useSelector(({ overlay }: MapState<T>) => overlay);\n"],
5
- "mappings": "AAAA,SAAS,eAAe;AAGxB;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,gBAAgB;AAGlB,MAAM,cAAc,CAAO,aAChC,iBAAiB,UAAyC,UAAU,OAAO;AAEtE,MAAM,uBAAuB,MAClC,YAAY,CAAC,EAAE,UAAU,MAAmB,SAAS;AAEhD,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,QAAQ,GAAG,aAAa,IAAI;AAEpC,SAAO;AACT,CAAC;AAEI,MAAM,2BAA2B,MACtC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,OAAO,IAAI;AAEnB,SAAO;AACT,CAAC;AAEI,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB,OAAO;",
4
+ "sourcesContent": ["import { isEqual } from 'lodash-es';\nimport { Context } from 'react';\n\nimport {\n Store,\n useStoreSelector,\n} from '@dynatrace/strato-components-preview/core';\n\nimport { MapStore } from './map-store.context.js';\nimport type { MapState } from '../types/state.js';\n\nexport const useSelector = <T, O>(selector: (state: MapState<T>) => O): O =>\n useStoreSelector(MapStore as Context<Store<MapState<T>>>, selector, isEqual);\n\nexport const useMapSelectionState = <T>() =>\n useSelector(({ selection }: MapState<T>) => selection);\n\nexport const useMapTooltipState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned, ...tooltipState } = tooltip;\n\n return tooltipState;\n });\n\nexport const useMapTooltipPinnedState = <T>() =>\n useSelector(({ tooltip }: MapState<T>) => {\n const { pinned } = tooltip;\n\n return pinned;\n });\n\nexport const useMapOverlayState = <T>() =>\n useSelector(({ overlay }: MapState<T>) => overlay);\n\nexport const useMapZoomState = <T>() =>\n useSelector(({ zoom }: MapState<T>) => zoom);\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;AAGxB;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,gBAAgB;AAGlB,MAAM,cAAc,CAAO,aAChC,iBAAiB,UAAyC,UAAU,OAAO;AAEtE,MAAM,uBAAuB,MAClC,YAAY,CAAC,EAAE,UAAU,MAAmB,SAAS;AAEhD,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,QAAQ,GAAG,aAAa,IAAI;AAEpC,SAAO;AACT,CAAC;AAEI,MAAM,2BAA2B,MACtC,YAAY,CAAC,EAAE,QAAQ,MAAmB;AACxC,QAAM,EAAE,OAAO,IAAI;AAEnB,SAAO;AACT,CAAC;AAEI,MAAM,qBAAqB,MAChC,YAAY,CAAC,EAAE,QAAQ,MAAmB,OAAO;AAE5C,MAAM,kBAAkB,MAC7B,YAAY,CAAC,EAAE,KAAK,MAAmB,IAAI;",
6
6
  "names": []
7
7
  }
@@ -58,11 +58,24 @@ const useToggleStatePinnedTooltip = () => {
58
58
  });
59
59
  };
60
60
  };
61
+ const useSetStateZoom = () => {
62
+ const setState = useSetState();
63
+ return (newZoomState) => {
64
+ setState((prev) => ({
65
+ ...prev,
66
+ zoom: {
67
+ ...prev.zoom,
68
+ ...newZoomState
69
+ }
70
+ }));
71
+ };
72
+ };
61
73
  export {
62
74
  useSetState,
63
75
  useSetStateOverlay,
64
76
  useSetStateSelection,
65
77
  useSetStateTooltip,
78
+ useSetStateZoom,
66
79
  useToggleStatePinnedTooltip
67
80
  };
68
81
  //# sourceMappingURL=store.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/store/store.ts"],
4
- "sourcesContent": ["import { useContext } from 'react';\n\nimport { MapStore } from './map-store.context.js';\nimport type {\n MapOverlayState,\n MapSelectionState,\n MapTooltipState,\n} from '../types/state.js';\n\nexport const useSetState = () => {\n const { setState } = useContext(MapStore);\n\n return setState;\n};\n\nexport * from './selectors.js';\n\nexport const useSetStateSelection = () => {\n const setState = useSetState();\n\n return (newSelectionState: Partial<MapSelectionState>) => {\n setState((prev) => ({\n ...prev,\n selection: {\n ...prev.selection,\n ...newSelectionState,\n },\n }));\n };\n};\n\nexport const useSetStateTooltip = <T>() => {\n const setState = useSetState();\n\n return (newTooltipState: Partial<MapTooltipState<T>>) => {\n setState((prev) => ({\n ...prev,\n tooltip: {\n ...prev.tooltip,\n ...newTooltipState,\n },\n }));\n };\n};\n\nexport const useSetStateOverlay = () => {\n const setState = useSetState();\n\n return (newOverlayState: Partial<MapOverlayState>) => {\n setState((prev) => ({\n ...prev,\n overlay: {\n ...prev.overlay,\n ...newOverlayState,\n },\n }));\n };\n};\n\nexport const useToggleStatePinnedTooltip = () => {\n const setState = useSetState();\n\n return () => {\n setState((prev) => {\n if (prev.tooltip.visible || prev.tooltip.pinned) {\n return {\n ...prev,\n tooltip: {\n ...prev.tooltip,\n pinned: !prev.tooltip.pinned,\n },\n };\n }\n return { ...prev };\n });\n };\n};\n"],
5
- "mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AAOlB,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,SAAS,IAAI,WAAW,QAAQ;AAExC,SAAO;AACT;AAEA,cAAc;AAEP,MAAM,uBAAuB,MAAM;AACxC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,sBAAkD;AACxD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,WAAW;AAAA,QACT,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,qBAAqB,MAAS;AACzC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,oBAAiD;AACvD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,qBAAqB,MAAM;AACtC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,oBAA8C;AACpD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,8BAA8B,MAAM;AAC/C,QAAM,WAAW,YAAY;AAE7B,SAAO,MAAM;AACX,aAAS,CAAC,SAAS;AACjB,UAAI,KAAK,QAAQ,WAAW,KAAK,QAAQ,QAAQ;AAC/C,eAAO;AAAA,UACL,GAAG;AAAA,UACH,SAAS;AAAA,YACP,GAAG,KAAK;AAAA,YACR,QAAQ,CAAC,KAAK,QAAQ;AAAA,UACxB;AAAA,QACF;AAAA,MACF;AACA,aAAO,EAAE,GAAG,KAAK;AAAA,IACnB,CAAC;AAAA,EACH;AACF;",
4
+ "sourcesContent": ["import { useContext } from 'react';\n\nimport { MapStore } from './map-store.context.js';\nimport type {\n MapOverlayState,\n MapSelectionState,\n MapTooltipState,\n ZoomState,\n} from '../types/state.js';\n\nexport const useSetState = () => {\n const { setState } = useContext(MapStore);\n\n return setState;\n};\n\nexport * from './selectors.js';\n\nexport const useSetStateSelection = () => {\n const setState = useSetState();\n\n return (newSelectionState: Partial<MapSelectionState>) => {\n setState((prev) => ({\n ...prev,\n selection: {\n ...prev.selection,\n ...newSelectionState,\n },\n }));\n };\n};\n\nexport const useSetStateTooltip = <T>() => {\n const setState = useSetState();\n\n return (newTooltipState: Partial<MapTooltipState<T>>) => {\n setState((prev) => ({\n ...prev,\n tooltip: {\n ...prev.tooltip,\n ...newTooltipState,\n },\n }));\n };\n};\n\nexport const useSetStateOverlay = () => {\n const setState = useSetState();\n\n return (newOverlayState: Partial<MapOverlayState>) => {\n setState((prev) => ({\n ...prev,\n overlay: {\n ...prev.overlay,\n ...newOverlayState,\n },\n }));\n };\n};\n\nexport const useToggleStatePinnedTooltip = () => {\n const setState = useSetState();\n\n return () => {\n setState((prev) => {\n if (prev.tooltip.visible || prev.tooltip.pinned) {\n return {\n ...prev,\n tooltip: {\n ...prev.tooltip,\n pinned: !prev.tooltip.pinned,\n },\n };\n }\n return { ...prev };\n });\n };\n};\n\nexport const useSetStateZoom = () => {\n const setState = useSetState();\n\n return (newZoomState: Partial<ZoomState>) => {\n setState((prev) => ({\n ...prev,\n zoom: {\n ...prev.zoom,\n ...newZoomState,\n },\n }));\n };\n};\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AAQlB,MAAM,cAAc,MAAM;AAC/B,QAAM,EAAE,SAAS,IAAI,WAAW,QAAQ;AAExC,SAAO;AACT;AAEA,cAAc;AAEP,MAAM,uBAAuB,MAAM;AACxC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,sBAAkD;AACxD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,WAAW;AAAA,QACT,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,qBAAqB,MAAS;AACzC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,oBAAiD;AACvD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,qBAAqB,MAAM;AACtC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,oBAA8C;AACpD,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,SAAS;AAAA,QACP,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;AAEO,MAAM,8BAA8B,MAAM;AAC/C,QAAM,WAAW,YAAY;AAE7B,SAAO,MAAM;AACX,aAAS,CAAC,SAAS;AACjB,UAAI,KAAK,QAAQ,WAAW,KAAK,QAAQ,QAAQ;AAC/C,eAAO;AAAA,UACL,GAAG;AAAA,UACH,SAAS;AAAA,YACP,GAAG,KAAK;AAAA,YACR,QAAQ,CAAC,KAAK,QAAQ;AAAA,UACxB;AAAA,QACF;AAAA,MACF;AACA,aAAO,EAAE,GAAG,KAAK;AAAA,IACnB,CAAC;AAAA,EACH;AACF;AAEO,MAAM,kBAAkB,MAAM;AACnC,QAAM,WAAW,YAAY;AAE7B,SAAO,CAAC,iBAAqC;AAC3C,aAAS,CAAC,UAAU;AAAA,MAClB,GAAG;AAAA,MACH,MAAM;AAAA,QACJ,GAAG,KAAK;AAAA,QACR,GAAG;AAAA,MACL;AAAA,IACF,EAAE;AAAA,EACJ;AACF;",
6
6
  "names": []
7
7
  }
@@ -10,13 +10,15 @@ import { createCategoricalColorSchemeFromLegendProps } from "./create-categorica
10
10
  const isThresholdLegend = (legendConfig) => legendConfig.type === "threshold";
11
11
  const isSequentialLegend = (legendConfig) => legendConfig.type === "sequential";
12
12
  const isCategoricalLegend = (legendConfig) => legendConfig.type === "categorical";
13
- const buildScaleFromLegendConfig = (mapLegendConfig, categories) => {
13
+ const buildScaleFromLegendConfig = (mapLegendConfig, categories, dataMax) => {
14
14
  if (isSequentialLegend(mapLegendConfig)) {
15
15
  const { min, max, colorPalette } = mapLegendConfig;
16
16
  return buildQuantizeScaleFromColorPalette(min, max, colorPalette);
17
17
  } else if (isThresholdLegend(mapLegendConfig)) {
18
18
  const { ranges } = mapLegendConfig;
19
- return buildThresholdScaleFromRanges(ranges, DEFAULT_RANGE_COLOR);
19
+ return buildThresholdScaleFromRanges(ranges, DEFAULT_RANGE_COLOR, {
20
+ max: dataMax
21
+ });
20
22
  } else if (isCategoricalLegend(mapLegendConfig)) {
21
23
  const isArrayOfColors = Array.isArray(mapLegendConfig.colorPalette);
22
24
  const isDefaultColorPalette = colorPaletteOptions.includes(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/build-scale-from-legend-config.ts"],
4
- "sourcesContent": ["import {\n _buildQuantizeScaleFromColorPalette as buildQuantizeScaleFromColorPalette,\n _buildThresholdScaleFromRanges as buildThresholdScaleFromRanges,\n type ColorPalette,\n colorPaletteOptions,\n} from '@dynatrace/strato-components-preview/charts';\n\nimport { buildCategoricalScale } from './build-categorical-scale.js';\nimport { DEFAULT_RANGE_COLOR } from '../constants.js';\nimport { createCategoricalColorSchemeFromCustomColorObject } from './create-categorical-color-scheme-from-custom-color-object.js';\nimport { createCategoricalColorSchemeFromLegendProps } from './create-categorical-color-scheme-from-legend-props.js';\nimport type {\n CategoricalLegendConfig,\n MapLegendConfig,\n SequentialLegendConfig,\n ThresholdLegendConfig,\n} from '../types/legend.js';\n\nexport const isThresholdLegend = (\n legendConfig: MapLegendConfig,\n): legendConfig is ThresholdLegendConfig => legendConfig.type === 'threshold';\n\nexport const isSequentialLegend = (\n legendConfig: MapLegendConfig,\n): legendConfig is SequentialLegendConfig => legendConfig.type === 'sequential';\n\nexport const isCategoricalLegend = (\n legendConfig: MapLegendConfig,\n): legendConfig is CategoricalLegendConfig =>\n legendConfig.type === 'categorical';\n\n/**\n * Builds a scale for the corresponding map legend configuration\n */\nexport const buildScaleFromLegendConfig = (\n mapLegendConfig: MapLegendConfig,\n categories?: string[],\n) => {\n if (isSequentialLegend(mapLegendConfig)) {\n const { min, max, colorPalette } = mapLegendConfig;\n return buildQuantizeScaleFromColorPalette(min, max, colorPalette);\n } else if (isThresholdLegend(mapLegendConfig)) {\n const { ranges } = mapLegendConfig;\n return buildThresholdScaleFromRanges(ranges, DEFAULT_RANGE_COLOR);\n } else if (isCategoricalLegend(mapLegendConfig)) {\n const isArrayOfColors = Array.isArray(mapLegendConfig.colorPalette);\n const isDefaultColorPalette = colorPaletteOptions.includes(\n mapLegendConfig.colorPalette as (typeof colorPaletteOptions)[number],\n );\n const isCustomColorObject = !(isDefaultColorPalette || isArrayOfColors);\n const colorPaletteObject = isCustomColorObject\n ? createCategoricalColorSchemeFromCustomColorObject(\n mapLegendConfig.colorPalette as {\n [key: string]: string;\n },\n categories ?? [],\n )\n : createCategoricalColorSchemeFromLegendProps(\n mapLegendConfig.colorPalette as string[] | ColorPalette,\n categories ?? [],\n );\n\n return buildCategoricalScale(colorPaletteObject);\n }\n};\n"],
5
- "mappings": "AAAA;AAAA,EACE,uCAAuC;AAAA,EACvC,kCAAkC;AAAA,EAElC;AAAA,OACK;AAEP,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,yDAAyD;AAClE,SAAS,mDAAmD;AAQrD,MAAM,oBAAoB,CAC/B,iBAC0C,aAAa,SAAS;AAE3D,MAAM,qBAAqB,CAChC,iBAC2C,aAAa,SAAS;AAE5D,MAAM,sBAAsB,CACjC,iBAEA,aAAa,SAAS;AAKjB,MAAM,6BAA6B,CACxC,iBACA,eACG;AACH,MAAI,mBAAmB,eAAe,GAAG;AACvC,UAAM,EAAE,KAAK,KAAK,aAAa,IAAI;AACnC,WAAO,mCAAmC,KAAK,KAAK,YAAY;AAAA,EAClE,WAAW,kBAAkB,eAAe,GAAG;AAC7C,UAAM,EAAE,OAAO,IAAI;AACnB,WAAO,8BAA8B,QAAQ,mBAAmB;AAAA,EAClE,WAAW,oBAAoB,eAAe,GAAG;AAC/C,UAAM,kBAAkB,MAAM,QAAQ,gBAAgB,YAAY;AAClE,UAAM,wBAAwB,oBAAoB;AAAA,MAChD,gBAAgB;AAAA,IAClB;AACA,UAAM,sBAAsB,EAAE,yBAAyB;AACvD,UAAM,qBAAqB,sBACvB;AAAA,MACE,gBAAgB;AAAA,MAGhB,cAAc,CAAC;AAAA,IACjB,IACA;AAAA,MACE,gBAAgB;AAAA,MAChB,cAAc,CAAC;AAAA,IACjB;AAEJ,WAAO,sBAAsB,kBAAkB;AAAA,EACjD;AACF;",
4
+ "sourcesContent": ["import {\n _buildQuantizeScaleFromColorPalette as buildQuantizeScaleFromColorPalette,\n _buildThresholdScaleFromRanges as buildThresholdScaleFromRanges,\n type ColorPalette,\n colorPaletteOptions,\n} from '@dynatrace/strato-components-preview/charts';\n\nimport { buildCategoricalScale } from './build-categorical-scale.js';\nimport { DEFAULT_RANGE_COLOR } from '../constants.js';\nimport { createCategoricalColorSchemeFromCustomColorObject } from './create-categorical-color-scheme-from-custom-color-object.js';\nimport { createCategoricalColorSchemeFromLegendProps } from './create-categorical-color-scheme-from-legend-props.js';\nimport type {\n CategoricalLegendConfig,\n MapLegendConfig,\n SequentialLegendConfig,\n ThresholdLegendConfig,\n} from '../types/legend.js';\n\nexport const isThresholdLegend = (\n legendConfig: MapLegendConfig,\n): legendConfig is ThresholdLegendConfig => legendConfig.type === 'threshold';\n\nexport const isSequentialLegend = (\n legendConfig: MapLegendConfig,\n): legendConfig is SequentialLegendConfig => legendConfig.type === 'sequential';\n\nexport const isCategoricalLegend = (\n legendConfig: MapLegendConfig,\n): legendConfig is CategoricalLegendConfig =>\n legendConfig.type === 'categorical';\n\n/**\n * Builds a scale for the corresponding map legend configuration\n */\nexport const buildScaleFromLegendConfig = (\n mapLegendConfig: MapLegendConfig,\n categories?: string[],\n dataMax?: number,\n) => {\n if (isSequentialLegend(mapLegendConfig)) {\n const { min, max, colorPalette } = mapLegendConfig;\n return buildQuantizeScaleFromColorPalette(min, max, colorPalette);\n } else if (isThresholdLegend(mapLegendConfig)) {\n const { ranges } = mapLegendConfig;\n return buildThresholdScaleFromRanges(ranges, DEFAULT_RANGE_COLOR, {\n max: dataMax,\n });\n } else if (isCategoricalLegend(mapLegendConfig)) {\n const isArrayOfColors = Array.isArray(mapLegendConfig.colorPalette);\n const isDefaultColorPalette = colorPaletteOptions.includes(\n mapLegendConfig.colorPalette as (typeof colorPaletteOptions)[number],\n );\n const isCustomColorObject = !(isDefaultColorPalette || isArrayOfColors);\n const colorPaletteObject = isCustomColorObject\n ? createCategoricalColorSchemeFromCustomColorObject(\n mapLegendConfig.colorPalette as {\n [key: string]: string;\n },\n categories ?? [],\n )\n : createCategoricalColorSchemeFromLegendProps(\n mapLegendConfig.colorPalette as string[] | ColorPalette,\n categories ?? [],\n );\n\n return buildCategoricalScale(colorPaletteObject);\n }\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE,uCAAuC;AAAA,EACvC,kCAAkC;AAAA,EAElC;AAAA,OACK;AAEP,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,yDAAyD;AAClE,SAAS,mDAAmD;AAQrD,MAAM,oBAAoB,CAC/B,iBAC0C,aAAa,SAAS;AAE3D,MAAM,qBAAqB,CAChC,iBAC2C,aAAa,SAAS;AAE5D,MAAM,sBAAsB,CACjC,iBAEA,aAAa,SAAS;AAKjB,MAAM,6BAA6B,CACxC,iBACA,YACA,YACG;AACH,MAAI,mBAAmB,eAAe,GAAG;AACvC,UAAM,EAAE,KAAK,KAAK,aAAa,IAAI;AACnC,WAAO,mCAAmC,KAAK,KAAK,YAAY;AAAA,EAClE,WAAW,kBAAkB,eAAe,GAAG;AAC7C,UAAM,EAAE,OAAO,IAAI;AACnB,WAAO,8BAA8B,QAAQ,qBAAqB;AAAA,MAChE,KAAK;AAAA,IACP,CAAC;AAAA,EACH,WAAW,oBAAoB,eAAe,GAAG;AAC/C,UAAM,kBAAkB,MAAM,QAAQ,gBAAgB,YAAY;AAClE,UAAM,wBAAwB,oBAAoB;AAAA,MAChD,gBAAgB;AAAA,IAClB;AACA,UAAM,sBAAsB,EAAE,yBAAyB;AACvD,UAAM,qBAAqB,sBACvB;AAAA,MACE,gBAAgB;AAAA,MAGhB,cAAc,CAAC;AAAA,IACjB,IACA;AAAA,MACE,gBAAgB;AAAA,MAChB,cAAc,CAAC;AAAA,IACjB;AAEJ,WAAO,sBAAsB,kBAAkB;AAAA,EACjD;AACF;",
6
6
  "names": []
7
7
  }
@@ -11,14 +11,14 @@ const addCategory = (extendedDataPoint, valueAccessor) => {
11
11
  }
12
12
  };
13
13
  const updateDomain = (domain, value) => {
14
- const [min, max] = domain;
14
+ let [min, max] = domain;
15
15
  if (value < min) {
16
- return [value, max];
16
+ min = value;
17
17
  }
18
18
  if (value > max) {
19
- return [min, value];
19
+ max = value;
20
20
  }
21
- return domain;
21
+ return [min, max];
22
22
  };
23
23
  const extractLayersData = (children, valueAccessors) => {
24
24
  let flattenData = [];
@@ -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 React 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 const [min, max] = domain;\n if (value < min) {\n return [value, max];\n }\n if (value > max) {\n return [min, value];\n }\n return domain;\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: React.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 React.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,OAAO,WAAW;AAElB,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,eA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AC3C,kBAAM,aAAa;AAAA,cACjB,GAAG;AAAA,cACH,mBAAmB,cAAc,kBAAkB,CAAC;AAAA,cACpD,yBAAyB;AAAA,cACzB,cAAc,MAAM,MAAM;AAAA,YAC5B;AAEA,wBAAY,KAAK,UAAU;AAAA,UAC7B,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH,WAAW,YAAY,OAAO,eAAe,GAAG;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;",
4
+ "sourcesContent": ["import { isString } from 'lodash-es';\nimport React 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: React.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 React.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,OAAO,WAAW;AAElB,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,QAAM,SAAS,QAAQ,UAAU,CAAC,UAAU;AAC1C,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,oBAAY,cAAc,IAAI,QAAkB;AAEhD,YAAI,OAAO,aAAa,UAAU;AAChC,yBAAe,aAAa,cAAc,QAAQ;AAAA,QACpD;AAEA,sBAAc,YA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AG,aAAa;AAAA,IAC7B;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { _accessValue as accessValue } from "@dynatrace/strato-components-preview/core";
3
+ import { isComponent } from "./is-component.js";
3
4
  import { BubbleLayer } from "../components/BubbleLayer/BubbleLayer.js";
4
5
  import { ChoroplethLayer } from "../components/ChoroplethLayer/ChoroplethLayer.js";
5
6
  import { ConnectionLayer } from "../components/ConnectionLayer/ConnectionLayer.js";
@@ -10,7 +11,6 @@ import {
10
11
  MIN_LATITUDE,
11
12
  MIN_LONGITUDE
12
13
  } from "../constants.js";
13
- import { isComponent } from "./is-component.js";
14
14
  const narrowDownLocationBounds = (coordinates, initialBounds) => {
15
15
  const bounds = [...initialBounds];
16
16
  coordinates.forEach(({ latitude, longitude }) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/get-data-layers-bounding-box.ts"],
4
- "sourcesContent": ["import { Feature } from 'geojson';\nimport React from 'react';\n\nimport { _accessValue as accessValue } from '@dynatrace/strato-components-preview/core';\n\nimport { BubbleLayer } from '../components/BubbleLayer/BubbleLayer.js';\nimport { ChoroplethLayer } from '../components/ChoroplethLayer/ChoroplethLayer.js';\nimport { ConnectionLayer } from '../components/ConnectionLayer/ConnectionLayer.js';\nimport { DotLayer } from '../components/DotLayer/DotLayer.js';\nimport {\n MAX_LATITUDE,\n MAX_LONGITUDE,\n MIN_LATITUDE,\n MIN_LONGITUDE,\n} from '../constants.js';\nimport { isComponent } from './is-component.js';\nimport { InternalChoroplethLayerProps } from '../types/choropleth-layer.js';\nimport type { Location } from '../types/location.js';\n\nconst narrowDownLocationBounds = (\n coordinates: Location[],\n initialBounds: [number, number, number, number],\n) => {\n const bounds: [number, number, number, number] = [...initialBounds];\n coordinates.forEach(({ latitude, longitude }) => {\n bounds[0] = Math.min(bounds[0], longitude);\n bounds[1] = Math.min(bounds[1], latitude);\n bounds[2] = Math.max(bounds[2], longitude);\n bounds[3] = Math.max(bounds[3], latitude);\n });\n\n return bounds;\n};\n\nconst updateChoroplethBounds = (\n locationBounds: [number, number, number, number],\n initialBounds: [number, number, number, number],\n) => {\n const bounds: [number, number, number, number] = [...initialBounds];\n bounds[0] = Math.min(bounds[0], locationBounds[0]);\n bounds[1] = Math.min(bounds[1], locationBounds[1]);\n bounds[2] = Math.max(bounds[2], locationBounds[2]);\n bounds[3] = Math.max(bounds[3], locationBounds[3]);\n\n return bounds;\n};\n\nconst narrowDownChoroplethBounds = (\n props: InternalChoroplethLayerProps<Record<string, unknown>>,\n featureCollection: Feature[],\n bounds: [number, number, number, number],\n) => {\n const locations = props.data.map((feat) => {\n const accessor = props.regionAccessor;\n if (typeof accessor === 'string') {\n return accessValue<string>(feat, accessor);\n } else {\n return accessor(feat);\n }\n });\n\n let foundLocations = 0;\n for (const feature of featureCollection) {\n if (locations.includes(feature.id as string)) {\n if (feature.properties?.bbox) {\n bounds = updateChoroplethBounds(feature.properties.bbox, bounds);\n foundLocations++;\n }\n }\n if (foundLocations === locations.length) {\n break;\n }\n }\n\n return bounds;\n};\n\nexport const getDataLayersBoundingBox = (\n children: React.ReactNode,\n featureCollection?: Feature[],\n): [number, number, number, number] => {\n let bounds: [number, number, number, number] = [\n MAX_LONGITUDE,\n MAX_LATITUDE,\n MIN_LONGITUDE,\n MIN_LATITUDE,\n ];\n\n React.Children.forEach(children, (child) => {\n if (isComponent(child, BubbleLayer) || isComponent(child, DotLayer)) {\n const data = child.props.data;\n\n bounds = narrowDownLocationBounds(data, bounds);\n } else if (isComponent(child, ConnectionLayer)) {\n const connectionsProps = child.props;\n connectionsProps.data.forEach(({ path }) => {\n bounds = narrowDownLocationBounds(path, bounds);\n });\n } else if (isComponent(child, ChoroplethLayer)) {\n if (featureCollection !== undefined) {\n bounds = narrowDownChoroplethBounds(\n child.props,\n featureCollection,\n bounds,\n );\n }\n }\n });\n\n return bounds;\n};\n"],
5
- "mappings": "AACA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,CAAC;AAED,MAAI,iBAAiB;AACrB,aAAW,WAAW,mBAAmB;AACvC,QAAI,UAAU,SAAS,QAAQ,EAAY,GAAG;AAC5C,UAAI,QAAQ,YAAY,MAAM;AAC5B,iBAAS,uBAAuB,QAAQ,WAAW,MAAM,MAAM;AAC/D;AAAA,MACF;AAAA,IACF;AACA,QAAI,mBAAmB,UAAU,QAAQ;AACvC;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,MAAM,2BAA2B,CACtC,UACA,sBACqC;AACrC,MAAI,SAA2C;AAAA,IAC7C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,SAAS,QAAQ,UAAU,CAAC,UAAU;AAC1C,QAAI,YAAY,OAAO,WAAW,KAAK,YAAY,OAAO,QAAQ,GAAG;AACnE,YAAM,OAAO,MAAM,MAAM;AAEzB,eAAS,yBAAyB,MAAM,MAAM;AAAA,IAChD,WAAW,YAAY,OAAO,eAAe,GAAG;AAC9C,YAAM,mBAAmB,MAAM;AAC/B,uBAAiB,KAAK,QAAQ,CAAC,EAAE,KAAK,MAAM;AAC1C,iBAAS,yBAAyB,MAAM,MAAM;AAAA,MAChD,CAAC;AAAA,IACH,WAAW,YAAY,OAAO,eAAe,GAAG;AAC9C,UAAI,sBAAsB,QAAW;AACnC,iBAAS;AAAA,UACP,MAAM;AAAA,UACN;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
4
+ "sourcesContent": ["import { Feature } from 'geojson';\nimport React from 'react';\n\nimport { _accessValue as accessValue } from '@dynatrace/strato-components-preview/core';\n\nimport { isComponent } from './is-component.js';\nimport { BubbleLayer } from '../components/BubbleLayer/BubbleLayer.js';\nimport { ChoroplethLayer } from '../components/ChoroplethLayer/ChoroplethLayer.js';\nimport { ConnectionLayer } from '../components/ConnectionLayer/ConnectionLayer.js';\nimport { DotLayer } from '../components/DotLayer/DotLayer.js';\nimport {\n MAX_LATITUDE,\n MAX_LONGITUDE,\n MIN_LATITUDE,\n MIN_LONGITUDE,\n} from '../constants.js';\nimport { InternalChoroplethLayerProps } from '../types/choropleth-layer.js';\nimport type { Location } from '../types/location.js';\nimport type { BoundingBoxCoords } from '../types/map-view.js';\n\nconst narrowDownLocationBounds = (\n coordinates: Location[],\n initialBounds: BoundingBoxCoords,\n) => {\n const bounds: BoundingBoxCoords = [...initialBounds];\n coordinates.forEach(({ latitude, longitude }) => {\n bounds[0] = Math.min(bounds[0], longitude);\n bounds[1] = Math.min(bounds[1], latitude);\n bounds[2] = Math.max(bounds[2], longitude);\n bounds[3] = Math.max(bounds[3], latitude);\n });\n\n return bounds;\n};\n\nconst updateChoroplethBounds = (\n locationBounds: BoundingBoxCoords,\n initialBounds: BoundingBoxCoords,\n) => {\n const bounds: BoundingBoxCoords = [...initialBounds];\n bounds[0] = Math.min(bounds[0], locationBounds[0]);\n bounds[1] = Math.min(bounds[1], locationBounds[1]);\n bounds[2] = Math.max(bounds[2], locationBounds[2]);\n bounds[3] = Math.max(bounds[3], locationBounds[3]);\n\n return bounds;\n};\n\nconst narrowDownChoroplethBounds = (\n props: InternalChoroplethLayerProps<Record<string, unknown>>,\n featureCollection: Feature[],\n bounds: BoundingBoxCoords,\n) => {\n const locations = props.data.map((feat) => {\n const accessor = props.regionAccessor;\n if (typeof accessor === 'string') {\n return accessValue<string>(feat, accessor);\n } else {\n return accessor(feat);\n }\n });\n\n let foundLocations = 0;\n for (const feature of featureCollection) {\n if (locations.includes(feature.id as string)) {\n if (feature.properties?.bbox) {\n bounds = updateChoroplethBounds(feature.properties.bbox, bounds);\n foundLocations++;\n }\n }\n if (foundLocations === locations.length) {\n break;\n }\n }\n\n return bounds;\n};\n\nexport const getDataLayersBoundingBox = (\n children: React.ReactNode,\n featureCollection?: Feature[],\n): BoundingBoxCoords => {\n let bounds: BoundingBoxCoords = [\n MAX_LONGITUDE,\n MAX_LATITUDE,\n MIN_LONGITUDE,\n MIN_LATITUDE,\n ];\n\n React.Children.forEach(children, (child) => {\n if (isComponent(child, BubbleLayer) || isComponent(child, DotLayer)) {\n const data = child.props.data;\n\n bounds = narrowDownLocationBounds(data, bounds);\n } else if (isComponent(child, ConnectionLayer)) {\n const connectionsProps = child.props;\n connectionsProps.data.forEach(({ path }) => {\n bounds = narrowDownLocationBounds(path, bounds);\n });\n } else if (isComponent(child, ChoroplethLayer)) {\n if (featureCollection !== undefined) {\n bounds = narrowDownChoroplethBounds(\n child.props,\n featureCollection,\n bounds,\n );\n }\n }\n });\n\n return bounds;\n};\n"],
5
+ "mappings": "AACA,OAAO,WAAW;AAElB,SAAS,gBAAgB,mBAAmB;AAE5C,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,MAAM,2BAA2B,CAC/B,aACA,kBACG;AACH,QAAM,SAA4B,CAAC,GAAG,aAAa;AACnD,cAAY,QAAQ,CAAC,EAAE,UAAU,UAAU,MAAM;AAC/C,WAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,SAAS;AACzC,WAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,QAAQ;AACxC,WAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,SAAS;AACzC,WAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,QAAQ;AAAA,EAC1C,CAAC;AAED,SAAO;AACT;AAEA,MAAM,yBAAyB,CAC7B,gBACA,kBACG;AACH,QAAM,SAA4B,CAAC,GAAG,aAAa;AACnD,SAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC;AACjD,SAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC;AACjD,SAAO,CAAC,IAAI,KAAK,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A;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -7,6 +7,7 @@ import {
7
7
  DEFAULT_MAP_POSITION,
8
8
  DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE
9
9
  } from "../constants.js";
10
+ import { replaceInfiniteValuesInRanges } from "./replace-infinite-values-in-ranges.js";
10
11
  import { BaseLayer } from "../slots/BaseLayer.js";
11
12
  import { CategoricalLegend } from "../slots/CategoricalLegend.js";
12
13
  import { ChartInteractions } from "../slots/ChartInteractions.js";
@@ -76,13 +77,18 @@ const iterateConfigSlots = (children, legendDomain) => {
76
77
  }
77
78
  case ThresholdLegend: {
78
79
  const { children: children2, ...legend } = child.props;
80
+ const ranges = replaceInfiniteValuesInRanges(
81
+ legend.ranges,
82
+ legendDomain
83
+ );
79
84
  slots = {
80
85
  ...slots,
81
86
  legend: {
82
87
  type: "threshold",
83
88
  position: DEFAULT_MAP_POSITION,
84
89
  ratio: DEFAULT_MAP_LEGEND_RATIO,
85
- ...legend
90
+ ...legend,
91
+ ranges
86
92
  }
87
93
  };
88
94
  break;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/iterate-config-slots.ts"],
4
- "sourcesContent": ["import React from 'react';\nimport { isElement } from 'react-is';\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 { 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: React.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 React.Children.forEach(children, (child) => {\n if (isElement(child)) {\n switch (child.type) {\n case 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 break;\n }\n\n case 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 break;\n }\n\n case SequentialLegend: {\n const { children, ...legend } = child.props;\n\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 ...legend,\n min: legend.min ?? legendDomain[0],\n max: legend.max ?? legendDomain[1],\n },\n };\n\n break;\n }\n\n case CategoricalLegend: {\n const { children, ...legend } = child.props;\n\n slots = {\n ...slots,\n legend: {\n type: 'categorical',\n position: DEFAULT_MAP_POSITION,\n ...legend,\n },\n };\n break;\n }\n\n case ThresholdLegend: {\n const { children, ...legend } = child.props;\n\n slots = {\n ...slots,\n legend: {\n type: 'threshold',\n position: DEFAULT_MAP_POSITION,\n ratio: DEFAULT_MAP_LEGEND_RATIO,\n ...legend,\n },\n };\n break;\n }\n\n case BaseLayer: {\n slots = {\n ...slots,\n baseLayer: {\n ...slots.baseLayer,\n ...child.props,\n },\n };\n break;\n }\n }\n }\n });\n\n return slots;\n};\n\nconst iterateChartInteractionsSlots = (children: React.ReactElement[]) => {\n let interactions: ChartInteractionsConfig = {};\n\n React.Children.forEach(children, (childInteractions) => {\n if (isElement(childInteractions)) {\n switch (childInteractions.type) {\n case ChartInteractions.Zoom:\n interactions = { ...interactions, zoom: { enabled: true } };\n break;\n case ChartInteractions.ZoomToFit:\n interactions = { ...interactions, zoomToFit: { enabled: true } };\n break;\n }\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: React.ReactElement[]) => {\n let toolbar = {};\n\n React.Children.forEach(children, (childToolbar) => {\n if (\n isElement(childToolbar) &&\n childToolbar.type === ChartToolbar.DownloadData\n ) {\n toolbar = {\n ...toolbar,\n downloadData: { enabled: true },\n };\n }\n });\n\n return toolbar;\n};\n"],
5
- "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAE1B,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,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,QAAM,SAAS,QAAQ,UAAU,CAAC,UAAU;AAC1C,QAAI,UAAU,KAAK,GAAG;AACpB,cAAQ,MAAM,MAAM;AAAA,QAClB,KAAK,mBAAmB;AACtB,gBAAM,EAAE,UAAAA,WAAU,GAAG,qBAAqB,IAAI,MAAM;AAEpD,gBAAM,eAAe,8BAA8BA,SAAQ;AAE3D,kBAAQ;AAAA,YACN,GAAG;AAAA,YACH,cAAc;AAAA,cACZ,GAAG;AAAA,cACH,GAAG;AAAA,YACL;AAAA,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IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,MAAM,gCAAgC,CAAC,aAAmC;AACxE,MAAI,eAAwC,CAAC;AAE7C,QAAM,SAAS,QAAQ,UAAU,CAAC,sBAAsB;AACtD,QAAI,UAAU,iBAAiB,GAAG;AAChC,cAAQ,kBAAkB,MAAM;AAAA,QAC9B,KAAK,kBAAkB;AACrB,yBAAe,EAAE,GAAG,cAAc,MAAM,EAAE,SAAS,KAAK,EAAE;AAC1D;AAAA,QACF,KAAK,kBAAkB;AACrB,yBAAe,EAAE,GAAG,cAAc,WAAW,EAAE,SAAS,KAAK,EAAE;AAC/D;AAAA,MACJ;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAOA,MAAM,2BAA2B,CAAC,aAAmC;AACnE,MAAI,UAAU,CAAC;AAEf,QAAM,SAAS,QAAQ,UAAU,CAAC,iBAAiB;AACjD,QACE,UAAU,YAAY,KACtB,aAAa,SAAS,aAAa,cACnC;AACA,gBAAU;AAAA,QACR,GAAG;AAAA,QACH,cAAc,EAAE,SAAS,KAAK;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
4
+ "sourcesContent": ["import React from 'react';\nimport { isElement } from 'react-is';\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 { 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: React.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 React.Children.forEach(children, (child) => {\n if (isElement(child)) {\n switch (child.type) {\n case 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 break;\n }\n\n case 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 break;\n }\n\n case SequentialLegend: {\n const { children, ...legend } = child.props;\n\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 ...legend,\n min: legend.min ?? legendDomain[0],\n max: legend.max ?? legendDomain[1],\n },\n };\n\n break;\n }\n\n case CategoricalLegend: {\n const { children, ...legend } = child.props;\n\n slots = {\n ...slots,\n legend: {\n type: 'categorical',\n position: DEFAULT_MAP_POSITION,\n ...legend,\n },\n };\n break;\n }\n\n case ThresholdLegend: {\n const { children, ...legend } = child.props;\n\n const ranges = replaceInfiniteValuesInRanges(\n legend.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 ...legend,\n ranges,\n },\n };\n break;\n }\n\n case BaseLayer: {\n slots = {\n ...slots,\n baseLayer: {\n ...slots.baseLayer,\n ...child.props,\n },\n };\n break;\n }\n }\n }\n });\n\n return slots;\n};\n\nconst iterateChartInteractionsSlots = (children: React.ReactElement[]) => {\n let interactions: ChartInteractionsConfig = {};\n\n React.Children.forEach(children, (childInteractions) => {\n if (isElement(childInteractions)) {\n switch (childInteractions.type) {\n case ChartInteractions.Zoom:\n interactions = { ...interactions, zoom: { enabled: true } };\n break;\n case ChartInteractions.ZoomToFit:\n interactions = { ...interactions, zoomToFit: { enabled: true } };\n break;\n }\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: React.ReactElement[]) => {\n let toolbar = {};\n\n React.Children.forEach(children, (childToolbar) => {\n if (\n isElement(childToolbar) &&\n childToolbar.type === ChartToolbar.DownloadData\n ) {\n toolbar = {\n ...toolbar,\n downloadData: { enabled: true },\n };\n }\n });\n\n return toolbar;\n};\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,iBAAiB;AAE1B,SAAS,oBAAoB;AAE7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,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,QAAM,SAAS,QAAQ,UAAU,CAAC,UAAU;AAC1C,QAAI,UAAU,KAAK,GAAG;AACpB,cAAQ,MAAM,MAAM;AAAA,QAClB,KAAK,mBAAmB;AACtB,gBAAM,EAAE,UAAAA,WAAU,GAAG,qBAAqB,IAAI,MAAM;AAEpD,gBAAM,eAAe,8BAA8BA,SAAQ;AAE3D,kBAAQ;AAAA,YACN,GAAG;AAAA,YACH,c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N,GAAG;AAAA,YACH,WAAW;AAAA,cACT,GAAG,MAAM;AAAA,cACT,GAAG,MAAM;AAAA,YACX;AAAA,UACF;AACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEA,MAAM,gCAAgC,CAAC,aAAmC;AACxE,MAAI,eAAwC,CAAC;AAE7C,QAAM,SAAS,QAAQ,UAAU,CAAC,sBAAsB;AACtD,QAAI,UAAU,iBAAiB,GAAG;AAChC,cAAQ,kBAAkB,MAAM;AAAA,QAC9B,KAAK,kBAAkB;AACrB,yBAAe,EAAE,GAAG,cAAc,MAAM,EAAE,SAAS,KAAK,EAAE;AAC1D;AAAA,QACF,KAAK,kBAAkB;AACrB,yBAAe,EAAE,GAAG,cAAc,WAAW,EAAE,SAAS,KAAK,EAAE;AAC/D;AAAA,MACJ;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAOA,MAAM,2BAA2B,CAAC,aAAmC;AACnE,MAAI,UAAU,CAAC;AAEf,QAAM,SAAS,QAAQ,UAAU,CAAC,iBAAiB;AACjD,QACE,UAAU,YAAY,KACtB,aAAa,SAAS,aAAa,cACnC;AACA,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
  }
@@ -0,0 +1,30 @@
1
+ const replaceInfiniteValuesInRanges = (ranges, domain) => {
2
+ const replaceInfiniteValues = (value) => {
3
+ if (value === -Infinity) {
4
+ if (domain[0] >= 0) {
5
+ return 0;
6
+ } else {
7
+ return domain[0];
8
+ }
9
+ }
10
+ if (value === Infinity) {
11
+ if (domain[1] <= 0) {
12
+ return 0;
13
+ } else {
14
+ return domain[1];
15
+ }
16
+ }
17
+ return value;
18
+ };
19
+ return ranges.map((range) => {
20
+ return {
21
+ ...range,
22
+ from: replaceInfiniteValues(range.from),
23
+ to: replaceInfiniteValues(range.to)
24
+ };
25
+ });
26
+ };
27
+ export {
28
+ replaceInfiniteValuesInRanges
29
+ };
30
+ //# sourceMappingURL=replace-infinite-values-in-ranges.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/map/utils/replace-infinite-values-in-ranges.ts"],
4
+ "sourcesContent": ["import { ColoredRange } from '@dynatrace/strato-components-preview/charts';\n\nexport const replaceInfiniteValuesInRanges = (\n ranges: ColoredRange[],\n domain: [number, number],\n) => {\n const replaceInfiniteValues = (value: number) => {\n if (value === -Infinity) {\n if (domain[0] >= 0) {\n return 0;\n } else {\n return domain[0];\n }\n }\n if (value === Infinity) {\n if (domain[1] <= 0) {\n return 0;\n } else {\n return domain[1];\n }\n }\n return value;\n };\n\n return ranges.map((range: ColoredRange) => {\n return {\n ...range,\n from: replaceInfiniteValues(range.from),\n to: replaceInfiniteValues(range.to),\n };\n });\n};\n"],
5
+ "mappings": "AAEO,MAAM,gCAAgC,CAC3C,QACA,WACG;AACH,QAAM,wBAAwB,CAAC,UAAkB;AAC/C,QAAI,UAAU,WAAW;AACvB,UAAI,OAAO,CAAC,KAAK,GAAG;AAClB,eAAO;AAAA,MACT,OAAO;AACL,eAAO,OAAO,CAAC;AAAA,MACjB;AAAA,IACF;AACA,QAAI,UAAU,UAAU;AACtB,UAAI,OAAO,CAAC,KAAK,GAAG;AAClB,eAAO;AAAA,MACT,OAAO;AACL,eAAO,OAAO,CAAC;AAAA,MACjB;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,IAAI,CAAC,UAAwB;AACzC,WAAO;AAAA,MACL,GAAG;AAAA,MACH,MAAM,sBAAsB,MAAM,IAAI;AAAA,MACtC,IAAI,sBAAsB,MAAM,EAAE;AAAA,IACpC;AAAA,EACF,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/map/utils/to-mapbox-initial-view-state.ts"],
4
- "sourcesContent": ["import { isArray } from 'lodash-es';\n\nimport { FIT_BOUNDS_OPTIONS } from '../constants.js';\nimport { ViewState } from '../types/map-view.js';\n\nexport const toMapBoxInitialViewState = (\n initialViewState: ViewState | [number, number, number, number],\n) =>\n isArray(initialViewState)\n ? { bounds: initialViewState, fitBoundsOptions: FIT_BOUNDS_OPTIONS }\n : initialViewState;\n"],
5
- "mappings": "AAAA,SAAS,eAAe;AAExB,SAAS,0BAA0B;AAG5B,MAAM,2BAA2B,CACtC,qBAEA,QAAQ,gBAAgB,IACpB,EAAE,QAAQ,kBAAkB,kBAAkB,mBAAmB,IACjE;",
4
+ "sourcesContent": ["import { isArray } from 'lodash-es';\nimport type { PaddingOptions } from 'maplibre-gl';\n\nimport { FIT_BOUNDS_OPTIONS } from '../constants.js';\nimport type { BoundingBoxCoords, ViewState } from '../types/map-view.js';\n\nexport type InitialBounds = {\n bounds: BoundingBoxCoords;\n fitBoundsOptions: {\n padding: number | PaddingOptions;\n };\n};\n\nexport const toMapBoxInitialViewState = (\n initialViewState: ViewState | BoundingBoxCoords,\n): ViewState | InitialBounds =>\n isArray(initialViewState)\n ? { bounds: initialViewState, fitBoundsOptions: FIT_BOUNDS_OPTIONS }\n : initialViewState;\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;AAGxB,SAAS,0BAA0B;AAU5B,MAAM,2BAA2B,CACtC,qBAEA,QAAQ,gBAAgB,IACpB,EAAE,QAAQ,kBAAkB,kBAAkB,mBAAmB,IACjE;",
6
6
  "names": []
7
7
  }