@guardian/interactive-component-library 0.1.0-alpha.13 → 0.1.0-alpha.15

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.
@@ -3,13 +3,13 @@ import { useRef, useState, useLayoutEffect, useCallback, useEffect, useMemo, use
3
3
  import { render, createElement, cloneElement, createContext, toChildArray } from "preact";
4
4
  import { useSyncExternalStore, createPortal, forwardRef } from "preact/compat";
5
5
  import { scaleLinear as scaleLinear$1 } from "d3-scale";
6
- import { geoStream, geoAlbers, geoPath, geoMercator, geoContains } from "d3-geo";
6
+ import { geoStream, geoAlbers, geoPath, geoMercator } from "d3-geo";
7
7
  const main = "";
8
8
  const group = "_group_nq9z3_1";
9
9
  const rotated = "_rotated_nq9z3_6";
10
10
  const path$4 = "_path_nq9z3_10";
11
11
  const active = "_active_nq9z3_14";
12
- const defaultStyles$r = {
12
+ const defaultStyles$s = {
13
13
  group,
14
14
  rotated,
15
15
  path: path$4,
@@ -48,13 +48,13 @@ function Chevron({
48
48
  styles: styles2
49
49
  }) {
50
50
  const defaultStylesCopy = {
51
- ...defaultStyles$r
51
+ ...defaultStyles$s
52
52
  };
53
53
  if (active2) {
54
- defaultStylesCopy.path = mergeStyles(defaultStyles$r.path, defaultStyles$r.active);
54
+ defaultStylesCopy.path = mergeStyles(defaultStyles$s.path, defaultStyles$s.active);
55
55
  }
56
56
  if (direction === DIRECTION.up) {
57
- defaultStylesCopy.group = mergeStyles(defaultStyles$r.group, defaultStyles$r.rotated);
57
+ defaultStylesCopy.group = mergeStyles(defaultStyles$s.group, defaultStyles$s.rotated);
58
58
  }
59
59
  styles2 = mergeStyles(defaultStylesCopy, styles2);
60
60
  return jsx("svg", {
@@ -79,7 +79,7 @@ const container$4 = "_container_jzalm_1";
79
79
  const dot = "_dot_jzalm_6";
80
80
  const circle$2 = "_circle_jzalm_13";
81
81
  const text$4 = "_text_jzalm_17";
82
- const defaultStyles$q = {
82
+ const defaultStyles$r = {
83
83
  container: container$4,
84
84
  dot,
85
85
  circle: circle$2,
@@ -96,10 +96,10 @@ const LegendItem = ({
96
96
  abbreviation
97
97
  }) => {
98
98
  const defaultStylesCopy = {
99
- ...defaultStyles$q
99
+ ...defaultStyles$r
100
100
  };
101
101
  if (dotType === DOT_TYPE.round) {
102
- defaultStylesCopy.dot = mergeStyles(defaultStyles$q.dot, defaultStyles$q.circle);
102
+ defaultStylesCopy.dot = mergeStyles(defaultStyles$r.dot, defaultStyles$r.circle);
103
103
  }
104
104
  styles2 = mergeStyles(defaultStylesCopy, styles2);
105
105
  return jsxs("div", {
@@ -134,7 +134,7 @@ function isDarkColor(color) {
134
134
  const bar$2 = "_bar_wmb0k_1";
135
135
  const label$1 = "_label_wmb0k_5";
136
136
  const backgroundRect = "_backgroundRect_wmb0k_11";
137
- const defaultStyles$p = {
137
+ const defaultStyles$q = {
138
138
  bar: bar$2,
139
139
  label: label$1,
140
140
  backgroundRect
@@ -168,7 +168,7 @@ function StackedBar({
168
168
  setHideLabels(false);
169
169
  }, [stack, width, height]);
170
170
  styles2 = mergeStyles({
171
- ...defaultStyles$p
171
+ ...defaultStyles$q
172
172
  }, styles2);
173
173
  let totalWidth = 0;
174
174
  const content2 = stack.map((d2, index2) => {
@@ -281,7 +281,7 @@ const [useGradients, setGradients, getGradients] = createStore({});
281
281
  const svg$8 = "_svg_1cajk_6";
282
282
  const previous = "_previous_1cajk_12";
283
283
  const next = "_next_1cajk_16";
284
- const defaultStyles$o = {
284
+ const defaultStyles$p = {
285
285
  svg: svg$8,
286
286
  previous,
287
287
  next
@@ -292,7 +292,7 @@ const GradientIcon = (props) => {
292
292
  next: next2,
293
293
  styles: styles2
294
294
  } = props;
295
- styles2 = mergeStyles(defaultStyles$o, styles2);
295
+ styles2 = mergeStyles(defaultStyles$p, styles2);
296
296
  const gradientId = `gv-gradient-def-${previous2}-${next2}`;
297
297
  const gradients = useGradients();
298
298
  useEffect(() => {
@@ -361,7 +361,7 @@ function GradientDefs({
361
361
  }
362
362
  const button$4 = "_button_kpmyt_1";
363
363
  const svg$7 = "_svg_kpmyt_14";
364
- const defaultStyles$n = {
364
+ const defaultStyles$o = {
365
365
  button: button$4,
366
366
  svg: svg$7
367
367
  };
@@ -370,7 +370,7 @@ const InfoButton = ({
370
370
  styles: styles2
371
371
  }) => {
372
372
  styles2 = mergeStyles({
373
- ...defaultStyles$n
373
+ ...defaultStyles$o
374
374
  }, styles2);
375
375
  return jsx("button", {
376
376
  class: styles2.button,
@@ -388,7 +388,7 @@ const InfoButton = ({
388
388
  const svg$6 = "_svg_1v49v_1";
389
389
  const circle$1 = "_circle_1v49v_5";
390
390
  const pulse = "_pulse_1v49v_9";
391
- const defaultStyles$m = {
391
+ const defaultStyles$n = {
392
392
  svg: svg$6,
393
393
  circle: circle$1,
394
394
  pulse
@@ -398,7 +398,7 @@ const CircleIcon = ({
398
398
  pulse: pulse2 = false,
399
399
  styles: styles2
400
400
  }) => {
401
- styles2 = mergeStyles(defaultStyles$m, styles2);
401
+ styles2 = mergeStyles(defaultStyles$n, styles2);
402
402
  return jsx("svg", {
403
403
  style: styles2.svg,
404
404
  fill: "none",
@@ -418,7 +418,7 @@ const CircleIcon = ({
418
418
  });
419
419
  };
420
420
  const text$3 = "_text_1okyv_1";
421
- const defaultStyles$l = {
421
+ const defaultStyles$m = {
422
422
  text: text$3
423
423
  };
424
424
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -768,7 +768,7 @@ const RelativeTimeSentence = ({
768
768
  styles: styles2
769
769
  }) => {
770
770
  styles2 = mergeStyles({
771
- ...defaultStyles$l
771
+ ...defaultStyles$m
772
772
  }, styles2);
773
773
  let timeSince = dayjs(timeStamp).fromNow();
774
774
  return jsx("span", {
@@ -778,7 +778,7 @@ const RelativeTimeSentence = ({
778
778
  };
779
779
  const pageContainer = "_pageContainer_1s0yq_9";
780
780
  const sideBorders = "_sideBorders_1s0yq_42";
781
- const defaultStyles$k = {
781
+ const defaultStyles$l = {
782
782
  pageContainer,
783
783
  sideBorders
784
784
  };
@@ -790,14 +790,14 @@ function Container({
790
790
  const {
791
791
  pageContainer: pageContainer2,
792
792
  sideBorders: sideBordersStyle
793
- } = mergeStyles(defaultStyles$k, styles2);
793
+ } = mergeStyles(defaultStyles$l, styles2);
794
794
  return jsx("div", {
795
795
  className: [pageContainer2, sideBorders2 && sideBordersStyle].join(" "),
796
796
  children
797
797
  });
798
798
  }
799
799
  const bar$1 = "_bar_17pyf_9";
800
- const defaultStyles$j = {
800
+ const defaultStyles$k = {
801
801
  bar: bar$1
802
802
  };
803
803
  function ChangeBar({
@@ -815,7 +815,7 @@ function ChangeBar({
815
815
  let thisStyles = ` height: ${height}; width: ${barwidth}px; ${positive ? `left: ${posleft}` : `left: ${negleft}`}`;
816
816
  let thisColor = ` bg-color--${party}`;
817
817
  styles2 = mergeStyles({
818
- ...defaultStyles$j
818
+ ...defaultStyles$k
819
819
  }, styles2);
820
820
  return jsx("div", {
821
821
  className: styles2.wrapper,
@@ -830,7 +830,7 @@ const svg$5 = "_svg_886i1_9";
830
830
  const dividingLineColor = "_dividingLineColor_886i1_16";
831
831
  const square = "_square_886i1_20";
832
832
  const corner = "_corner_886i1_24";
833
- const defaultStyles$i = {
833
+ const defaultStyles$j = {
834
834
  svg: svg$5,
835
835
  dividingLineColor,
836
836
  square,
@@ -843,7 +843,7 @@ const SquareCutCornerIcon = ({
843
843
  styles: styles2
844
844
  }) => {
845
845
  styles2 = mergeStyles({
846
- ...defaultStyles$i
846
+ ...defaultStyles$j
847
847
  }, styles2);
848
848
  let cornerSize = squareSize * 0.625;
849
849
  let cornerMargin = squareSize < 100 ? squareSize / 6 : 10;
@@ -881,7 +881,7 @@ const stackedGridRotateItems0 = "_stackedGridRotateItems0_1e05o_13";
881
881
  const stackedGridRotateItems90 = "_stackedGridRotateItems90_1e05o_19";
882
882
  const stackedGridRotateItems180 = "_stackedGridRotateItems180_1e05o_25";
883
883
  const stackedGridRotateItems270 = "_stackedGridRotateItems270_1e05o_31";
884
- const defaultStyles$h = {
884
+ const defaultStyles$i = {
885
885
  stackedGridContainer,
886
886
  stackedGridRotateItems0,
887
887
  stackedGridRotateItems90,
@@ -920,7 +920,7 @@ const StackedGrid = ({
920
920
  width: containerWidth,
921
921
  transform: containerFlip
922
922
  };
923
- styles2 = mergeStyles(defaultStyles$h, styles2);
923
+ styles2 = mergeStyles(defaultStyles$i, styles2);
924
924
  return jsx("div", {
925
925
  style: flexStyles,
926
926
  className: `${styles2.stackedGridContainer} ${styles2[itemRotateClass]}`,
@@ -929,7 +929,7 @@ const StackedGrid = ({
929
929
  };
930
930
  const svg$4 = "_svg_l2fsl_9";
931
931
  const squareFill = "_squareFill_l2fsl_16";
932
- const defaultStyles$g = {
932
+ const defaultStyles$h = {
933
933
  svg: svg$4,
934
934
  squareFill
935
935
  };
@@ -939,7 +939,7 @@ const SquareIcon = ({
939
939
  styles: styles2
940
940
  }) => {
941
941
  styles2 = mergeStyles({
942
- ...defaultStyles$g
942
+ ...defaultStyles$h
943
943
  }, styles2);
944
944
  return jsx("svg", {
945
945
  width: size,
@@ -957,7 +957,7 @@ const SquareIcon = ({
957
957
  };
958
958
  const button$3 = "_button_1fees_1";
959
959
  const icon = "_icon_1fees_6";
960
- const defaultStyles$f = {
960
+ const defaultStyles$g = {
961
961
  button: button$3,
962
962
  icon
963
963
  };
@@ -967,7 +967,7 @@ function ArrowButton({
967
967
  styles: styles2,
968
968
  onClick
969
969
  }) {
970
- styles2 = mergeStyles(defaultStyles$f, styles2);
970
+ styles2 = mergeStyles(defaultStyles$g, styles2);
971
971
  return jsx("button", {
972
972
  className: styles2.button,
973
973
  disabled,
@@ -993,7 +993,7 @@ function ArrowButton({
993
993
  }
994
994
  const button$2 = "_button_19t7j_1";
995
995
  const buttonInner$1 = "_buttonInner_19t7j_6";
996
- const defaultStyles$e = {
996
+ const defaultStyles$f = {
997
997
  button: button$2,
998
998
  buttonInner: buttonInner$1
999
999
  };
@@ -1003,7 +1003,7 @@ function Button({
1003
1003
  styles: styles2,
1004
1004
  children
1005
1005
  }) {
1006
- styles2 = mergeStyles(defaultStyles$e, styles2);
1006
+ styles2 = mergeStyles(defaultStyles$f, styles2);
1007
1007
  return jsx("button", {
1008
1008
  className: styles2.button,
1009
1009
  "data-type": type,
@@ -1018,7 +1018,7 @@ const button$1 = "_button_6w12u_1";
1018
1018
  const buttonBorder = "_buttonBorder_6w12u_10";
1019
1019
  const svg$3 = "_svg_6w12u_18";
1020
1020
  const path$3 = "_path_6w12u_24";
1021
- const defaultStyles$d = {
1021
+ const defaultStyles$e = {
1022
1022
  button: button$1,
1023
1023
  buttonBorder,
1024
1024
  svg: svg$3,
@@ -1029,7 +1029,7 @@ function CloseButton({
1029
1029
  onClick,
1030
1030
  styles: styles2
1031
1031
  }) {
1032
- styles2 = mergeStyles(defaultStyles$d, styles2);
1032
+ styles2 = mergeStyles(defaultStyles$e, styles2);
1033
1033
  return jsx("button", {
1034
1034
  className: [styles2.button, border && styles2.buttonBorder].join(" "),
1035
1035
  onClick,
@@ -1172,7 +1172,7 @@ const headerCell = "_headerCell_1b75c_31";
1172
1172
  const headerCellButton = "_headerCellButton_1b75c_39";
1173
1173
  const bodyRow = "_bodyRow_1b75c_48";
1174
1174
  const bodyCell = "_bodyCell_1b75c_53";
1175
- const defaultStyles$c = {
1175
+ const defaultStyles$d = {
1176
1176
  table,
1177
1177
  hideHeader,
1178
1178
  hideHeaderNoBorder,
@@ -1213,7 +1213,7 @@ function Table({
1213
1213
  };
1214
1214
  });
1215
1215
  };
1216
- styles2 = mergeStyles(defaultStyles$c, styles2);
1216
+ styles2 = mergeStyles(defaultStyles$d, styles2);
1217
1217
  return jsxs("table", {
1218
1218
  className: styles2.table,
1219
1219
  children: [jsx("thead", {
@@ -1346,7 +1346,7 @@ const y1Label = "_y1Label_gj7pr_24";
1346
1346
  const y2Label = "_y2Label_gj7pr_28";
1347
1347
  const axis$1 = "_axis_gj7pr_32";
1348
1348
  const axisLabel = "_axisLabel_gj7pr_37";
1349
- const defaultStyles$b = {
1349
+ const defaultStyles$c = {
1350
1350
  slopeChartContainer,
1351
1351
  svg: svg$2,
1352
1352
  line,
@@ -1398,7 +1398,7 @@ const SlopeChart = ({
1398
1398
  return positionLabels(labels);
1399
1399
  }, [lines, y2Label2, yScale]);
1400
1400
  styles2 = mergeStyles({
1401
- ...defaultStyles$b
1401
+ ...defaultStyles$c
1402
1402
  }, styles2);
1403
1403
  const chart = jsx("svg", {
1404
1404
  class: styles2.svg,
@@ -1491,6 +1491,7 @@ const useTooltipTarget = (targetElement, trackPosition) => {
1491
1491
  const x = clientX - rect.left;
1492
1492
  const y = clientY - rect.top;
1493
1493
  requestAnimationFrame(() => {
1494
+ setTargetRect(rect);
1494
1495
  setPosition({
1495
1496
  x,
1496
1497
  y
@@ -1621,7 +1622,7 @@ function Modal({
1621
1622
  });
1622
1623
  }
1623
1624
  const tooltip = "_tooltip_11t5d_1";
1624
- const defaultStyles$a = {
1625
+ const defaultStyles$b = {
1625
1626
  tooltip
1626
1627
  };
1627
1628
  const TooltipType = {
@@ -1649,7 +1650,7 @@ function Tooltip({
1649
1650
  hoverActive
1650
1651
  } = useTooltipTarget(targetElement, trackPosition);
1651
1652
  const tooltipRef = useRef(null);
1652
- styles2 = mergeStyles(defaultStyles$a, styles2);
1653
+ styles2 = mergeStyles(defaultStyles$b, styles2);
1653
1654
  useEffect(() => {
1654
1655
  let element = null;
1655
1656
  if (typeof refOrSelector === "string") {
@@ -1703,17 +1704,18 @@ function Tooltip({
1703
1704
  }) : tooltip2, displayElement);
1704
1705
  }
1705
1706
  function tooltipPositionForPoint({
1707
+ targetRect,
1706
1708
  positionInTarget,
1707
1709
  tooltip: tooltip2,
1708
1710
  displayElement
1709
1711
  }) {
1710
- const displayElementRect = displayElement.getBoundingClientRect();
1711
1712
  const newPosition = {
1712
- x: positionInTarget.x + displayElementRect.x,
1713
- y: positionInTarget.y + displayElementRect.y
1713
+ x: positionInTarget.x + targetRect.x,
1714
+ y: positionInTarget.y + targetRect.y
1714
1715
  };
1715
1716
  const tooltipWidth = tooltip2.offsetWidth;
1716
1717
  const tooltipHeight = tooltip2.offsetHeight;
1718
+ const displayElementRect = displayElement.getBoundingClientRect();
1717
1719
  if (newPosition.x + tooltipWidth > displayElementRect.right) {
1718
1720
  newPosition.x -= tooltipWidth;
1719
1721
  }
@@ -1744,7 +1746,7 @@ function tooltipPositionForRect({
1744
1746
  }
1745
1747
  const text$2 = "_text_1b8t2_1";
1746
1748
  const container$3 = "_container_1b8t2_10";
1747
- const defaultStyles$9 = {
1749
+ const defaultStyles$a = {
1748
1750
  text: text$2,
1749
1751
  container: container$3
1750
1752
  };
@@ -1755,7 +1757,7 @@ const ControlChange = ({
1755
1757
  styles: styles2
1756
1758
  }) => {
1757
1759
  styles2 = mergeStyles({
1758
- ...defaultStyles$9
1760
+ ...defaultStyles$a
1759
1761
  }, styles2);
1760
1762
  let hasChanged = next2 !== previous2;
1761
1763
  return jsx("div", {
@@ -1789,7 +1791,7 @@ const secondaryNumber = "_secondaryNumber_w8o28_58";
1789
1791
  const displayRow = "_displayRow_w8o28_65";
1790
1792
  const displayColumn = "_displayColumn_w8o28_71";
1791
1793
  const topRow = "_topRow_w8o28_75";
1792
- const defaultStyles$8 = {
1794
+ const defaultStyles$9 = {
1793
1795
  toplineResult,
1794
1796
  primaryname,
1795
1797
  secondaryname,
@@ -1814,7 +1816,7 @@ const ToplineResult = ({
1814
1816
  showInfoButton = false
1815
1817
  }) => {
1816
1818
  styles2 = mergeStyles({
1817
- ...defaultStyles$8
1819
+ ...defaultStyles$9
1818
1820
  }, styles2);
1819
1821
  const displayStyle = displayRow2 ? styles2.displayRow : styles2.displayColumn;
1820
1822
  return !secondaryName ? jsxs(Fragment, {
@@ -1881,7 +1883,7 @@ const section = "_section_12aiu_9";
1881
1883
  const borderTop = "_borderTop_12aiu_52";
1882
1884
  const header = "_header_12aiu_56";
1883
1885
  const content = "_content_12aiu_76";
1884
- const defaultStyles$7 = {
1886
+ const defaultStyles$8 = {
1885
1887
  section,
1886
1888
  borderTop,
1887
1889
  header,
@@ -1894,7 +1896,7 @@ const PageSection = forwardRef(({
1894
1896
  backgroundColor = "transparent"
1895
1897
  }, ref) => {
1896
1898
  styles2 = mergeStyles({
1897
- ...defaultStyles$7
1899
+ ...defaultStyles$8
1898
1900
  }, styles2);
1899
1901
  return jsxs("section", {
1900
1902
  ref,
@@ -1914,7 +1916,7 @@ const PageSection = forwardRef(({
1914
1916
  const text$1 = "_text_lo5h3_1";
1915
1917
  const axis = "_axis_lo5h3_6";
1916
1918
  const bar = "_bar_lo5h3_10";
1917
- const defaultStyles$6 = {
1919
+ const defaultStyles$7 = {
1918
1920
  text: text$1,
1919
1921
  axis,
1920
1922
  bar
@@ -1929,12 +1931,13 @@ const ColumnChart = ({
1929
1931
  columnPadding,
1930
1932
  styles: styles2
1931
1933
  }) => {
1932
- styles2 = mergeStyles(defaultStyles$6, styles2);
1934
+ styles2 = mergeStyles(defaultStyles$7, styles2);
1933
1935
  const yScale = scaleLinear$1([maxValue, minValue], [0, chartHeight]);
1934
1936
  const totalColumnWidth = Number(columnWidth) + Number(columnPadding.left) + Number(columnPadding.right);
1937
+ let marginBottom = minValue < 0 ? 0 : 40;
1935
1938
  return jsxs("svg", {
1936
1939
  width: chartWidth,
1937
- height: chartHeight,
1940
+ height: chartHeight + marginBottom,
1938
1941
  children: [columns.map((column, index2) => {
1939
1942
  const getHeight = (input2) => {
1940
1943
  return yScale(0) - yScale(input2);
@@ -1972,7 +1975,7 @@ const blurb = "_blurb_vd5ly_44";
1972
1975
  const leftCell = "_leftCell_vd5ly_55";
1973
1976
  const rightCell = "_rightCell_vd5ly_55";
1974
1977
  const mugshot = "_mugshot_vd5ly_71";
1975
- const defaultStyles$5 = {
1978
+ const defaultStyles$6 = {
1976
1979
  text,
1977
1980
  container: container$2,
1978
1981
  title: title$1,
@@ -1991,7 +1994,7 @@ const PartyProfile = ({
1991
1994
  abbreviation
1992
1995
  }) => {
1993
1996
  styles2 = mergeStyles({
1994
- ...defaultStyles$5
1997
+ ...defaultStyles$6
1995
1998
  }, styles2);
1996
1999
  return jsx("div", {
1997
2000
  class: styles2.container,
@@ -2259,6 +2262,33 @@ function bboxFeature(bounds) {
2259
2262
  return feature;
2260
2263
  }
2261
2264
  const MapContext = createContext();
2265
+ function calculateScale(mapBounds, mapWidthPixels, mapHeightPixels) {
2266
+ const south = mapBounds[0][1];
2267
+ const west = mapBounds[0][0];
2268
+ const north = mapBounds[1][1];
2269
+ const east = mapBounds[1][0];
2270
+ const widthKilometers = distanceInKmBetweenEarthCoordinates([west, south], [east, south]);
2271
+ const heightKilometers = distanceInKmBetweenEarthCoordinates([west, south], [west, north]);
2272
+ const scaleX = mapWidthPixels / widthKilometers;
2273
+ const scaleY = mapHeightPixels / heightKilometers;
2274
+ const scale = (scaleX + scaleY) / 2;
2275
+ return scale;
2276
+ }
2277
+ function distanceInKmBetweenEarthCoordinates(point1, point2) {
2278
+ let [lon1, lat1] = point1;
2279
+ let [lon2, lat2] = point2;
2280
+ const earthRadiusKm = 6371;
2281
+ const dLat = degreesToRadians(lat2 - lat1);
2282
+ const dLon = degreesToRadians(lon2 - lon1);
2283
+ lat1 = degreesToRadians(lat1);
2284
+ lat2 = degreesToRadians(lat2);
2285
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);
2286
+ const c2 = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
2287
+ return earthRadiusKm * c2;
2288
+ }
2289
+ function degreesToRadians(degrees) {
2290
+ return degrees * Math.PI / 180;
2291
+ }
2262
2292
  function SVGMapProvider({
2263
2293
  id,
2264
2294
  mapRef,
@@ -2278,9 +2308,47 @@ function SVGMapProvider({
2278
2308
  return config.projection.fitSize([contentSize.width, contentSize.height], bboxFeature(config.bounds));
2279
2309
  }, [contentSize, config]);
2280
2310
  const path2 = geoPath().projection(projection);
2311
+ const layerSet = useRef(/* @__PURE__ */ new Set());
2312
+ const layers = useRef([]);
2313
+ const updateLayers = useCallback((layerSet2) => {
2314
+ const _layers = Array.from(layerSet2.current);
2315
+ _layers.sort((a, b) => {
2316
+ return b.zIndex - a.zIndex;
2317
+ });
2318
+ layers.current = _layers;
2319
+ }, []);
2320
+ const registerLayer = useCallback((layer) => {
2321
+ layerSet.current.add(layer);
2322
+ updateLayers(layerSet);
2323
+ }, [updateLayers]);
2324
+ const unregisterLayer = useCallback((layer) => {
2325
+ layerSet.current.delete(layer);
2326
+ updateLayers(layerSet);
2327
+ }, [updateLayers]);
2328
+ const findFeatureAtPoint = useCallback(({
2329
+ x,
2330
+ y
2331
+ }) => {
2332
+ const adjustedPoint = [x - padding.left, y - padding.top];
2333
+ for (const layer of layers.current) {
2334
+ if (typeof layer.findFeatureAtPoint === "function") {
2335
+ const feature = layer.findFeatureAtPoint(adjustedPoint);
2336
+ if (feature)
2337
+ return feature;
2338
+ }
2339
+ }
2340
+ return null;
2341
+ }, [padding]);
2342
+ const getVisibleBounds = useCallback(() => {
2343
+ const projectedSW = projection.invert([padding.left, contentSize.height]);
2344
+ const projectedNE = projection.invert([padding.left + contentSize.width, padding.top]);
2345
+ return [projectedSW, projectedNE];
2346
+ }, [projection, contentSize, padding]);
2347
+ const getZoomScale = useCallback(() => {
2348
+ return calculateScale(getVisibleBounds(), contentSize.width, contentSize.height);
2349
+ }, [getVisibleBounds, contentSize]);
2281
2350
  const context = {
2282
2351
  id,
2283
- mapRef,
2284
2352
  projection,
2285
2353
  config,
2286
2354
  path: path2,
@@ -2292,15 +2360,20 @@ function SVGMapProvider({
2292
2360
  padding,
2293
2361
  zoom,
2294
2362
  extent: [[0, 0], [width, height]],
2295
- selectedFeature
2363
+ selectedFeature,
2364
+ getZoomScale,
2365
+ registerLayer,
2366
+ unregisterLayer,
2367
+ findFeatureAtPoint
2296
2368
  };
2369
+ mapRef.current = context;
2297
2370
  return jsx(MapContext.Provider, {
2298
2371
  value: context,
2299
2372
  children
2300
2373
  });
2301
2374
  }
2302
2375
  const path$1 = "_path_1cwd5_9";
2303
- const defaultStyles$4 = {
2376
+ const defaultStyles$5 = {
2304
2377
  path: path$1
2305
2378
  };
2306
2379
  function CompositionBorders({
@@ -2309,7 +2382,7 @@ function CompositionBorders({
2309
2382
  const {
2310
2383
  projection
2311
2384
  } = useContext(MapContext);
2312
- styles2 = mergeStyles(defaultStyles$4, styles2);
2385
+ styles2 = mergeStyles(defaultStyles$5, styles2);
2313
2386
  return jsx("path", {
2314
2387
  className: styles2.path,
2315
2388
  d: projection.getCompositionBorders()
@@ -2320,7 +2393,6 @@ function SVGRenderer({
2320
2393
  }) {
2321
2394
  const {
2322
2395
  id,
2323
- mapRef,
2324
2396
  config,
2325
2397
  size,
2326
2398
  selectedFeature,
@@ -2328,7 +2400,6 @@ function SVGRenderer({
2328
2400
  } = useContext(MapContext);
2329
2401
  return jsx("svg", {
2330
2402
  id,
2331
- ref: mapRef,
2332
2403
  width: size.width,
2333
2404
  height: size.height,
2334
2405
  viewBox: `0 0 ${size.width} ${size.height}`,
@@ -2378,9 +2449,22 @@ function Polygon({
2378
2449
  fill = null,
2379
2450
  stroke = null,
2380
2451
  strokeWidth = 1,
2452
+ zIndex = 0,
2381
2453
  styles: styles2
2382
2454
  }) {
2383
2455
  const context = useContext(MapContext);
2456
+ useEffect(() => {
2457
+ function findFeatureAtPoint(point) {
2458
+ }
2459
+ const layer = {
2460
+ zIndex,
2461
+ findFeatureAtPoint
2462
+ };
2463
+ context.registerLayer(layer);
2464
+ return () => {
2465
+ context.unregisterLayer(layer);
2466
+ };
2467
+ }, [context, zIndex]);
2384
2468
  return jsx(Fragment, {
2385
2469
  children: features.map((d2, index2) => {
2386
2470
  return jsx("path", {
@@ -2461,9 +2545,34 @@ function Point({
2461
2545
  fill = null,
2462
2546
  stroke = null,
2463
2547
  strokeWidth = 1,
2548
+ zIndex = 0,
2464
2549
  styles: styles2
2465
2550
  }) {
2466
2551
  const context = useContext(MapContext);
2552
+ useEffect(() => {
2553
+ function findFeatureAtPoint(point) {
2554
+ for (const [index2, feature] of features.entries()) {
2555
+ const resolvedRadius = dynamicPropValue(radius, feature, index2);
2556
+ if (isNaN(resolvedRadius))
2557
+ return;
2558
+ const [cx, cy] = context.projection(feature.geometry.coordinates);
2559
+ const distanceSquared = (point[0] - cx) ** 2 + (point[1] - cy) ** 2;
2560
+ const radiusSquared = resolvedRadius ** 2;
2561
+ if (distanceSquared <= radiusSquared) {
2562
+ return feature;
2563
+ }
2564
+ }
2565
+ return null;
2566
+ }
2567
+ const layer = {
2568
+ zIndex,
2569
+ findFeatureAtPoint
2570
+ };
2571
+ context.registerLayer(layer);
2572
+ return () => {
2573
+ context.unregisterLayer(layer);
2574
+ };
2575
+ }, [context, features, radius, zIndex]);
2467
2576
  return jsx(Fragment, {
2468
2577
  children: features.map((d2, index2) => {
2469
2578
  const [cx, cy] = context.projection(d2.geometry.coordinates);
@@ -2548,34 +2657,12 @@ const Map$1 = forwardRef(({
2548
2657
  setIsReady(true);
2549
2658
  }
2550
2659
  }, [isReady]);
2551
- useImperativeHandle(
2552
- ref,
2553
- () => ({
2554
- isReady,
2555
- getContainer: () => containerRef.current,
2556
- findFeatureAtPoint
2557
- }),
2558
- // eslint-disable-next-line react-hooks/exhaustive-deps
2559
- [isReady]
2560
- );
2561
- function findFeatureAtPoint({
2562
- x,
2563
- y
2564
- }) {
2565
- const adjustedPoint = [x - padding.left, y - padding.top];
2566
- const coordinates = config.projection.invert(adjustedPoint);
2567
- for (const child of toChildArray(children)) {
2568
- if (Object.prototype.hasOwnProperty.call(child.props, "features")) {
2569
- const features = child.props.features;
2570
- for (const feature of features) {
2571
- if (geoContains(feature, coordinates)) {
2572
- return feature;
2573
- }
2574
- }
2575
- }
2576
- }
2577
- return null;
2578
- }
2660
+ const mapRef = useRef();
2661
+ useImperativeHandle(ref, () => ({
2662
+ isReady,
2663
+ getContainer: () => containerRef.current,
2664
+ getContext: () => mapRef.current
2665
+ }), [isReady]);
2579
2666
  const containerSize = useContainerSize(containerRef);
2580
2667
  const containerStyle = useMemo(() => {
2581
2668
  const style = {};
@@ -2585,7 +2672,6 @@ const Map$1 = forwardRef(({
2585
2672
  style["height"] = height;
2586
2673
  return style;
2587
2674
  }, [width, height]);
2588
- const mapRef = useRef();
2589
2675
  const renderSVG = containerSize && !config.drawToCanvas;
2590
2676
  return jsx("div", {
2591
2677
  ref: containerRef,
@@ -2601,14 +2687,16 @@ const Map$1 = forwardRef(({
2601
2687
  selectedFeature,
2602
2688
  zoom,
2603
2689
  children: jsx(SVGRenderer, {
2604
- children
2690
+ children: toChildArray(children).map((child, index2) => cloneElement(child, {
2691
+ zIndex: index2
2692
+ }))
2605
2693
  })
2606
2694
  })
2607
2695
  });
2608
2696
  });
2609
2697
  const container = "_container_azu4a_1";
2610
2698
  const paragraph = "_paragraph_azu4a_12";
2611
- const defaultStyles$3 = {
2699
+ const defaultStyles$4 = {
2612
2700
  container,
2613
2701
  paragraph
2614
2702
  };
@@ -2621,7 +2709,7 @@ function ResultSummary({
2621
2709
  styles: styles2
2622
2710
  }) {
2623
2711
  styles2 = mergeStyles({
2624
- ...defaultStyles$3
2712
+ ...defaultStyles$4
2625
2713
  }, styles2);
2626
2714
  return jsxs("div", {
2627
2715
  class: styles2.container,
@@ -2664,7 +2752,7 @@ const suggestions = "_suggestions_g5w44_36";
2664
2752
  const suggestion = "_suggestion_g5w44_36";
2665
2753
  const selected = "_selected_g5w44_59";
2666
2754
  const highlighted = "_highlighted_g5w44_63";
2667
- const defaultStyles$2 = {
2755
+ const defaultStyles$3 = {
2668
2756
  searchContainer,
2669
2757
  input,
2670
2758
  searchIcon,
@@ -2685,7 +2773,7 @@ function SearchInput({
2685
2773
  styles: styles2
2686
2774
  }) {
2687
2775
  var _a, _b, _c;
2688
- styles2 = mergeStyles(defaultStyles$2, styles2);
2776
+ styles2 = mergeStyles(defaultStyles$3, styles2);
2689
2777
  const inputRef = useRef(null);
2690
2778
  const [selectedIndex, setSelectedIndex] = useState(-1);
2691
2779
  const [suggestions2, setSuggestions] = useState();
@@ -2797,7 +2885,7 @@ function SuggestionList({
2797
2885
  const refreshIndicator = "_refreshIndicator_u6lji_1";
2798
2886
  const liveText = "_liveText_u6lji_8";
2799
2887
  const refreshText = "_refreshText_u6lji_9";
2800
- const defaultStyles$1 = {
2888
+ const defaultStyles$2 = {
2801
2889
  refreshIndicator,
2802
2890
  liveText,
2803
2891
  refreshText
@@ -2806,7 +2894,7 @@ function RefreshIndicator({
2806
2894
  text: text2,
2807
2895
  styles: styles2
2808
2896
  }) {
2809
- styles2 = mergeStyles(defaultStyles$1, styles2);
2897
+ styles2 = mergeStyles(defaultStyles$2, styles2);
2810
2898
  return jsxs("div", {
2811
2899
  className: styles2.refreshIndicator,
2812
2900
  children: [jsx(CircleIcon, {
@@ -2820,6 +2908,34 @@ function RefreshIndicator({
2820
2908
  })]
2821
2909
  });
2822
2910
  }
2911
+ const grid = "_grid_xps7m_9";
2912
+ const defaultStyles$1 = {
2913
+ grid
2914
+ };
2915
+ const GridType = {
2916
+ small: "small",
2917
+ medium: "medium",
2918
+ large: "large"
2919
+ };
2920
+ function ResponsiveGrid({
2921
+ type = GridType.medium,
2922
+ children,
2923
+ styles: styles2
2924
+ }) {
2925
+ styles2 = mergeStyles({
2926
+ ...defaultStyles$1
2927
+ }, styles2);
2928
+ return jsx("div", {
2929
+ className: styles2.grid,
2930
+ "data-grid-type": type,
2931
+ children: toChildArray(children).map((child, index2) => {
2932
+ return jsx("div", {
2933
+ className: styles2.gridItem,
2934
+ children: child
2935
+ }, index2);
2936
+ })
2937
+ });
2938
+ }
2823
2939
  const coalitionsWrapper = "_coalitionsWrapper_1ahqy_9";
2824
2940
  const coalitionsContainer = "_coalitionsContainer_1ahqy_14";
2825
2941
  const coalition = "_coalition_1ahqy_9";
@@ -3115,6 +3231,7 @@ export {
3115
3231
  Container,
3116
3232
  ControlChange,
3117
3233
  GradientIcon,
3234
+ GridType,
3118
3235
  InfoButton,
3119
3236
  LegendItem,
3120
3237
  Map$1 as Map,
@@ -3125,6 +3242,7 @@ export {
3125
3242
  Projection,
3126
3243
  RefreshIndicator,
3127
3244
  RelativeTimeSentence,
3245
+ ResponsiveGrid,
3128
3246
  ResultSummary,
3129
3247
  SearchInput,
3130
3248
  SlopeChart,