@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.
@@ -7,7 +7,7 @@
7
7
  const rotated = "_rotated_nq9z3_6";
8
8
  const path$4 = "_path_nq9z3_10";
9
9
  const active = "_active_nq9z3_14";
10
- const defaultStyles$r = {
10
+ const defaultStyles$s = {
11
11
  group,
12
12
  rotated,
13
13
  path: path$4,
@@ -46,13 +46,13 @@
46
46
  styles: styles2
47
47
  }) {
48
48
  const defaultStylesCopy = {
49
- ...defaultStyles$r
49
+ ...defaultStyles$s
50
50
  };
51
51
  if (active2) {
52
- defaultStylesCopy.path = mergeStyles(defaultStyles$r.path, defaultStyles$r.active);
52
+ defaultStylesCopy.path = mergeStyles(defaultStyles$s.path, defaultStyles$s.active);
53
53
  }
54
54
  if (direction === DIRECTION.up) {
55
- defaultStylesCopy.group = mergeStyles(defaultStyles$r.group, defaultStyles$r.rotated);
55
+ defaultStylesCopy.group = mergeStyles(defaultStyles$s.group, defaultStyles$s.rotated);
56
56
  }
57
57
  styles2 = mergeStyles(defaultStylesCopy, styles2);
58
58
  return jsxRuntime.jsx("svg", {
@@ -77,7 +77,7 @@
77
77
  const dot = "_dot_jzalm_6";
78
78
  const circle$2 = "_circle_jzalm_13";
79
79
  const text$4 = "_text_jzalm_17";
80
- const defaultStyles$q = {
80
+ const defaultStyles$r = {
81
81
  container: container$4,
82
82
  dot,
83
83
  circle: circle$2,
@@ -94,10 +94,10 @@
94
94
  abbreviation
95
95
  }) => {
96
96
  const defaultStylesCopy = {
97
- ...defaultStyles$q
97
+ ...defaultStyles$r
98
98
  };
99
99
  if (dotType === DOT_TYPE.round) {
100
- defaultStylesCopy.dot = mergeStyles(defaultStyles$q.dot, defaultStyles$q.circle);
100
+ defaultStylesCopy.dot = mergeStyles(defaultStyles$r.dot, defaultStyles$r.circle);
101
101
  }
102
102
  styles2 = mergeStyles(defaultStylesCopy, styles2);
103
103
  return jsxRuntime.jsxs("div", {
@@ -132,7 +132,7 @@
132
132
  const bar$2 = "_bar_wmb0k_1";
133
133
  const label$1 = "_label_wmb0k_5";
134
134
  const backgroundRect = "_backgroundRect_wmb0k_11";
135
- const defaultStyles$p = {
135
+ const defaultStyles$q = {
136
136
  bar: bar$2,
137
137
  label: label$1,
138
138
  backgroundRect
@@ -166,7 +166,7 @@
166
166
  setHideLabels(false);
167
167
  }, [stack, width, height]);
168
168
  styles2 = mergeStyles({
169
- ...defaultStyles$p
169
+ ...defaultStyles$q
170
170
  }, styles2);
171
171
  let totalWidth = 0;
172
172
  const content2 = stack.map((d2, index2) => {
@@ -279,7 +279,7 @@
279
279
  const svg$8 = "_svg_1cajk_6";
280
280
  const previous = "_previous_1cajk_12";
281
281
  const next = "_next_1cajk_16";
282
- const defaultStyles$o = {
282
+ const defaultStyles$p = {
283
283
  svg: svg$8,
284
284
  previous,
285
285
  next
@@ -290,7 +290,7 @@
290
290
  next: next2,
291
291
  styles: styles2
292
292
  } = props;
293
- styles2 = mergeStyles(defaultStyles$o, styles2);
293
+ styles2 = mergeStyles(defaultStyles$p, styles2);
294
294
  const gradientId = `gv-gradient-def-${previous2}-${next2}`;
295
295
  const gradients = useGradients();
296
296
  hooks.useEffect(() => {
@@ -359,7 +359,7 @@
359
359
  }
360
360
  const button$4 = "_button_kpmyt_1";
361
361
  const svg$7 = "_svg_kpmyt_14";
362
- const defaultStyles$n = {
362
+ const defaultStyles$o = {
363
363
  button: button$4,
364
364
  svg: svg$7
365
365
  };
@@ -368,7 +368,7 @@
368
368
  styles: styles2
369
369
  }) => {
370
370
  styles2 = mergeStyles({
371
- ...defaultStyles$n
371
+ ...defaultStyles$o
372
372
  }, styles2);
373
373
  return jsxRuntime.jsx("button", {
374
374
  class: styles2.button,
@@ -386,7 +386,7 @@
386
386
  const svg$6 = "_svg_1v49v_1";
387
387
  const circle$1 = "_circle_1v49v_5";
388
388
  const pulse = "_pulse_1v49v_9";
389
- const defaultStyles$m = {
389
+ const defaultStyles$n = {
390
390
  svg: svg$6,
391
391
  circle: circle$1,
392
392
  pulse
@@ -396,7 +396,7 @@
396
396
  pulse: pulse2 = false,
397
397
  styles: styles2
398
398
  }) => {
399
- styles2 = mergeStyles(defaultStyles$m, styles2);
399
+ styles2 = mergeStyles(defaultStyles$n, styles2);
400
400
  return jsxRuntime.jsx("svg", {
401
401
  style: styles2.svg,
402
402
  fill: "none",
@@ -416,7 +416,7 @@
416
416
  });
417
417
  };
418
418
  const text$3 = "_text_1okyv_1";
419
- const defaultStyles$l = {
419
+ const defaultStyles$m = {
420
420
  text: text$3
421
421
  };
422
422
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -766,7 +766,7 @@
766
766
  styles: styles2
767
767
  }) => {
768
768
  styles2 = mergeStyles({
769
- ...defaultStyles$l
769
+ ...defaultStyles$m
770
770
  }, styles2);
771
771
  let timeSince = dayjs(timeStamp).fromNow();
772
772
  return jsxRuntime.jsx("span", {
@@ -776,7 +776,7 @@
776
776
  };
777
777
  const pageContainer = "_pageContainer_1s0yq_9";
778
778
  const sideBorders = "_sideBorders_1s0yq_42";
779
- const defaultStyles$k = {
779
+ const defaultStyles$l = {
780
780
  pageContainer,
781
781
  sideBorders
782
782
  };
@@ -788,14 +788,14 @@
788
788
  const {
789
789
  pageContainer: pageContainer2,
790
790
  sideBorders: sideBordersStyle
791
- } = mergeStyles(defaultStyles$k, styles2);
791
+ } = mergeStyles(defaultStyles$l, styles2);
792
792
  return jsxRuntime.jsx("div", {
793
793
  className: [pageContainer2, sideBorders2 && sideBordersStyle].join(" "),
794
794
  children
795
795
  });
796
796
  }
797
797
  const bar$1 = "_bar_17pyf_9";
798
- const defaultStyles$j = {
798
+ const defaultStyles$k = {
799
799
  bar: bar$1
800
800
  };
801
801
  function ChangeBar({
@@ -813,7 +813,7 @@
813
813
  let thisStyles = ` height: ${height}; width: ${barwidth}px; ${positive ? `left: ${posleft}` : `left: ${negleft}`}`;
814
814
  let thisColor = ` bg-color--${party}`;
815
815
  styles2 = mergeStyles({
816
- ...defaultStyles$j
816
+ ...defaultStyles$k
817
817
  }, styles2);
818
818
  return jsxRuntime.jsx("div", {
819
819
  className: styles2.wrapper,
@@ -828,7 +828,7 @@
828
828
  const dividingLineColor = "_dividingLineColor_886i1_16";
829
829
  const square = "_square_886i1_20";
830
830
  const corner = "_corner_886i1_24";
831
- const defaultStyles$i = {
831
+ const defaultStyles$j = {
832
832
  svg: svg$5,
833
833
  dividingLineColor,
834
834
  square,
@@ -841,7 +841,7 @@
841
841
  styles: styles2
842
842
  }) => {
843
843
  styles2 = mergeStyles({
844
- ...defaultStyles$i
844
+ ...defaultStyles$j
845
845
  }, styles2);
846
846
  let cornerSize = squareSize * 0.625;
847
847
  let cornerMargin = squareSize < 100 ? squareSize / 6 : 10;
@@ -879,7 +879,7 @@
879
879
  const stackedGridRotateItems90 = "_stackedGridRotateItems90_1e05o_19";
880
880
  const stackedGridRotateItems180 = "_stackedGridRotateItems180_1e05o_25";
881
881
  const stackedGridRotateItems270 = "_stackedGridRotateItems270_1e05o_31";
882
- const defaultStyles$h = {
882
+ const defaultStyles$i = {
883
883
  stackedGridContainer,
884
884
  stackedGridRotateItems0,
885
885
  stackedGridRotateItems90,
@@ -918,7 +918,7 @@
918
918
  width: containerWidth,
919
919
  transform: containerFlip
920
920
  };
921
- styles2 = mergeStyles(defaultStyles$h, styles2);
921
+ styles2 = mergeStyles(defaultStyles$i, styles2);
922
922
  return jsxRuntime.jsx("div", {
923
923
  style: flexStyles,
924
924
  className: `${styles2.stackedGridContainer} ${styles2[itemRotateClass]}`,
@@ -927,7 +927,7 @@
927
927
  };
928
928
  const svg$4 = "_svg_l2fsl_9";
929
929
  const squareFill = "_squareFill_l2fsl_16";
930
- const defaultStyles$g = {
930
+ const defaultStyles$h = {
931
931
  svg: svg$4,
932
932
  squareFill
933
933
  };
@@ -937,7 +937,7 @@
937
937
  styles: styles2
938
938
  }) => {
939
939
  styles2 = mergeStyles({
940
- ...defaultStyles$g
940
+ ...defaultStyles$h
941
941
  }, styles2);
942
942
  return jsxRuntime.jsx("svg", {
943
943
  width: size,
@@ -955,7 +955,7 @@
955
955
  };
956
956
  const button$3 = "_button_1fees_1";
957
957
  const icon = "_icon_1fees_6";
958
- const defaultStyles$f = {
958
+ const defaultStyles$g = {
959
959
  button: button$3,
960
960
  icon
961
961
  };
@@ -965,7 +965,7 @@
965
965
  styles: styles2,
966
966
  onClick
967
967
  }) {
968
- styles2 = mergeStyles(defaultStyles$f, styles2);
968
+ styles2 = mergeStyles(defaultStyles$g, styles2);
969
969
  return jsxRuntime.jsx("button", {
970
970
  className: styles2.button,
971
971
  disabled,
@@ -991,7 +991,7 @@
991
991
  }
992
992
  const button$2 = "_button_19t7j_1";
993
993
  const buttonInner$1 = "_buttonInner_19t7j_6";
994
- const defaultStyles$e = {
994
+ const defaultStyles$f = {
995
995
  button: button$2,
996
996
  buttonInner: buttonInner$1
997
997
  };
@@ -1001,7 +1001,7 @@
1001
1001
  styles: styles2,
1002
1002
  children
1003
1003
  }) {
1004
- styles2 = mergeStyles(defaultStyles$e, styles2);
1004
+ styles2 = mergeStyles(defaultStyles$f, styles2);
1005
1005
  return jsxRuntime.jsx("button", {
1006
1006
  className: styles2.button,
1007
1007
  "data-type": type,
@@ -1016,7 +1016,7 @@
1016
1016
  const buttonBorder = "_buttonBorder_6w12u_10";
1017
1017
  const svg$3 = "_svg_6w12u_18";
1018
1018
  const path$3 = "_path_6w12u_24";
1019
- const defaultStyles$d = {
1019
+ const defaultStyles$e = {
1020
1020
  button: button$1,
1021
1021
  buttonBorder,
1022
1022
  svg: svg$3,
@@ -1027,7 +1027,7 @@
1027
1027
  onClick,
1028
1028
  styles: styles2
1029
1029
  }) {
1030
- styles2 = mergeStyles(defaultStyles$d, styles2);
1030
+ styles2 = mergeStyles(defaultStyles$e, styles2);
1031
1031
  return jsxRuntime.jsx("button", {
1032
1032
  className: [styles2.button, border && styles2.buttonBorder].join(" "),
1033
1033
  onClick,
@@ -1170,7 +1170,7 @@
1170
1170
  const headerCellButton = "_headerCellButton_1b75c_39";
1171
1171
  const bodyRow = "_bodyRow_1b75c_48";
1172
1172
  const bodyCell = "_bodyCell_1b75c_53";
1173
- const defaultStyles$c = {
1173
+ const defaultStyles$d = {
1174
1174
  table,
1175
1175
  hideHeader,
1176
1176
  hideHeaderNoBorder,
@@ -1211,7 +1211,7 @@
1211
1211
  };
1212
1212
  });
1213
1213
  };
1214
- styles2 = mergeStyles(defaultStyles$c, styles2);
1214
+ styles2 = mergeStyles(defaultStyles$d, styles2);
1215
1215
  return jsxRuntime.jsxs("table", {
1216
1216
  className: styles2.table,
1217
1217
  children: [jsxRuntime.jsx("thead", {
@@ -1344,7 +1344,7 @@
1344
1344
  const y2Label = "_y2Label_gj7pr_28";
1345
1345
  const axis$1 = "_axis_gj7pr_32";
1346
1346
  const axisLabel = "_axisLabel_gj7pr_37";
1347
- const defaultStyles$b = {
1347
+ const defaultStyles$c = {
1348
1348
  slopeChartContainer,
1349
1349
  svg: svg$2,
1350
1350
  line,
@@ -1396,7 +1396,7 @@
1396
1396
  return positionLabels(labels);
1397
1397
  }, [lines, y2Label2, yScale]);
1398
1398
  styles2 = mergeStyles({
1399
- ...defaultStyles$b
1399
+ ...defaultStyles$c
1400
1400
  }, styles2);
1401
1401
  const chart = jsxRuntime.jsx("svg", {
1402
1402
  class: styles2.svg,
@@ -1489,6 +1489,7 @@
1489
1489
  const x = clientX - rect.left;
1490
1490
  const y = clientY - rect.top;
1491
1491
  requestAnimationFrame(() => {
1492
+ setTargetRect(rect);
1492
1493
  setPosition({
1493
1494
  x,
1494
1495
  y
@@ -1619,7 +1620,7 @@
1619
1620
  });
1620
1621
  }
1621
1622
  const tooltip = "_tooltip_11t5d_1";
1622
- const defaultStyles$a = {
1623
+ const defaultStyles$b = {
1623
1624
  tooltip
1624
1625
  };
1625
1626
  const TooltipType = {
@@ -1647,7 +1648,7 @@
1647
1648
  hoverActive
1648
1649
  } = useTooltipTarget(targetElement, trackPosition);
1649
1650
  const tooltipRef = hooks.useRef(null);
1650
- styles2 = mergeStyles(defaultStyles$a, styles2);
1651
+ styles2 = mergeStyles(defaultStyles$b, styles2);
1651
1652
  hooks.useEffect(() => {
1652
1653
  let element = null;
1653
1654
  if (typeof refOrSelector === "string") {
@@ -1701,17 +1702,18 @@
1701
1702
  }) : tooltip2, displayElement);
1702
1703
  }
1703
1704
  function tooltipPositionForPoint({
1705
+ targetRect,
1704
1706
  positionInTarget,
1705
1707
  tooltip: tooltip2,
1706
1708
  displayElement
1707
1709
  }) {
1708
- const displayElementRect = displayElement.getBoundingClientRect();
1709
1710
  const newPosition = {
1710
- x: positionInTarget.x + displayElementRect.x,
1711
- y: positionInTarget.y + displayElementRect.y
1711
+ x: positionInTarget.x + targetRect.x,
1712
+ y: positionInTarget.y + targetRect.y
1712
1713
  };
1713
1714
  const tooltipWidth = tooltip2.offsetWidth;
1714
1715
  const tooltipHeight = tooltip2.offsetHeight;
1716
+ const displayElementRect = displayElement.getBoundingClientRect();
1715
1717
  if (newPosition.x + tooltipWidth > displayElementRect.right) {
1716
1718
  newPosition.x -= tooltipWidth;
1717
1719
  }
@@ -1742,7 +1744,7 @@
1742
1744
  }
1743
1745
  const text$2 = "_text_1b8t2_1";
1744
1746
  const container$3 = "_container_1b8t2_10";
1745
- const defaultStyles$9 = {
1747
+ const defaultStyles$a = {
1746
1748
  text: text$2,
1747
1749
  container: container$3
1748
1750
  };
@@ -1753,7 +1755,7 @@
1753
1755
  styles: styles2
1754
1756
  }) => {
1755
1757
  styles2 = mergeStyles({
1756
- ...defaultStyles$9
1758
+ ...defaultStyles$a
1757
1759
  }, styles2);
1758
1760
  let hasChanged = next2 !== previous2;
1759
1761
  return jsxRuntime.jsx("div", {
@@ -1787,7 +1789,7 @@
1787
1789
  const displayRow = "_displayRow_w8o28_65";
1788
1790
  const displayColumn = "_displayColumn_w8o28_71";
1789
1791
  const topRow = "_topRow_w8o28_75";
1790
- const defaultStyles$8 = {
1792
+ const defaultStyles$9 = {
1791
1793
  toplineResult,
1792
1794
  primaryname,
1793
1795
  secondaryname,
@@ -1812,7 +1814,7 @@
1812
1814
  showInfoButton = false
1813
1815
  }) => {
1814
1816
  styles2 = mergeStyles({
1815
- ...defaultStyles$8
1817
+ ...defaultStyles$9
1816
1818
  }, styles2);
1817
1819
  const displayStyle = displayRow2 ? styles2.displayRow : styles2.displayColumn;
1818
1820
  return !secondaryName ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -1879,7 +1881,7 @@
1879
1881
  const borderTop = "_borderTop_12aiu_52";
1880
1882
  const header = "_header_12aiu_56";
1881
1883
  const content = "_content_12aiu_76";
1882
- const defaultStyles$7 = {
1884
+ const defaultStyles$8 = {
1883
1885
  section,
1884
1886
  borderTop,
1885
1887
  header,
@@ -1892,7 +1894,7 @@
1892
1894
  backgroundColor = "transparent"
1893
1895
  }, ref) => {
1894
1896
  styles2 = mergeStyles({
1895
- ...defaultStyles$7
1897
+ ...defaultStyles$8
1896
1898
  }, styles2);
1897
1899
  return jsxRuntime.jsxs("section", {
1898
1900
  ref,
@@ -1912,7 +1914,7 @@
1912
1914
  const text$1 = "_text_lo5h3_1";
1913
1915
  const axis = "_axis_lo5h3_6";
1914
1916
  const bar = "_bar_lo5h3_10";
1915
- const defaultStyles$6 = {
1917
+ const defaultStyles$7 = {
1916
1918
  text: text$1,
1917
1919
  axis,
1918
1920
  bar
@@ -1927,12 +1929,13 @@
1927
1929
  columnPadding,
1928
1930
  styles: styles2
1929
1931
  }) => {
1930
- styles2 = mergeStyles(defaultStyles$6, styles2);
1932
+ styles2 = mergeStyles(defaultStyles$7, styles2);
1931
1933
  const yScale = d3Scale.scaleLinear([maxValue, minValue], [0, chartHeight]);
1932
1934
  const totalColumnWidth = Number(columnWidth) + Number(columnPadding.left) + Number(columnPadding.right);
1935
+ let marginBottom = minValue < 0 ? 0 : 40;
1933
1936
  return jsxRuntime.jsxs("svg", {
1934
1937
  width: chartWidth,
1935
- height: chartHeight,
1938
+ height: chartHeight + marginBottom,
1936
1939
  children: [columns.map((column, index2) => {
1937
1940
  const getHeight = (input2) => {
1938
1941
  return yScale(0) - yScale(input2);
@@ -1970,7 +1973,7 @@
1970
1973
  const leftCell = "_leftCell_vd5ly_55";
1971
1974
  const rightCell = "_rightCell_vd5ly_55";
1972
1975
  const mugshot = "_mugshot_vd5ly_71";
1973
- const defaultStyles$5 = {
1976
+ const defaultStyles$6 = {
1974
1977
  text,
1975
1978
  container: container$2,
1976
1979
  title: title$1,
@@ -1989,7 +1992,7 @@
1989
1992
  abbreviation
1990
1993
  }) => {
1991
1994
  styles2 = mergeStyles({
1992
- ...defaultStyles$5
1995
+ ...defaultStyles$6
1993
1996
  }, styles2);
1994
1997
  return jsxRuntime.jsx("div", {
1995
1998
  class: styles2.container,
@@ -2257,6 +2260,33 @@
2257
2260
  return feature;
2258
2261
  }
2259
2262
  const MapContext = preact.createContext();
2263
+ function calculateScale(mapBounds, mapWidthPixels, mapHeightPixels) {
2264
+ const south = mapBounds[0][1];
2265
+ const west = mapBounds[0][0];
2266
+ const north = mapBounds[1][1];
2267
+ const east = mapBounds[1][0];
2268
+ const widthKilometers = distanceInKmBetweenEarthCoordinates([west, south], [east, south]);
2269
+ const heightKilometers = distanceInKmBetweenEarthCoordinates([west, south], [west, north]);
2270
+ const scaleX = mapWidthPixels / widthKilometers;
2271
+ const scaleY = mapHeightPixels / heightKilometers;
2272
+ const scale = (scaleX + scaleY) / 2;
2273
+ return scale;
2274
+ }
2275
+ function distanceInKmBetweenEarthCoordinates(point1, point2) {
2276
+ let [lon1, lat1] = point1;
2277
+ let [lon2, lat2] = point2;
2278
+ const earthRadiusKm = 6371;
2279
+ const dLat = degreesToRadians(lat2 - lat1);
2280
+ const dLon = degreesToRadians(lon2 - lon1);
2281
+ lat1 = degreesToRadians(lat1);
2282
+ lat2 = degreesToRadians(lat2);
2283
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(lat1) * Math.cos(lat2);
2284
+ const c2 = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
2285
+ return earthRadiusKm * c2;
2286
+ }
2287
+ function degreesToRadians(degrees) {
2288
+ return degrees * Math.PI / 180;
2289
+ }
2260
2290
  function SVGMapProvider({
2261
2291
  id,
2262
2292
  mapRef,
@@ -2276,9 +2306,47 @@
2276
2306
  return config.projection.fitSize([contentSize.width, contentSize.height], bboxFeature(config.bounds));
2277
2307
  }, [contentSize, config]);
2278
2308
  const path2 = d3Geo.geoPath().projection(projection);
2309
+ const layerSet = hooks.useRef(/* @__PURE__ */ new Set());
2310
+ const layers = hooks.useRef([]);
2311
+ const updateLayers = hooks.useCallback((layerSet2) => {
2312
+ const _layers = Array.from(layerSet2.current);
2313
+ _layers.sort((a, b) => {
2314
+ return b.zIndex - a.zIndex;
2315
+ });
2316
+ layers.current = _layers;
2317
+ }, []);
2318
+ const registerLayer = hooks.useCallback((layer) => {
2319
+ layerSet.current.add(layer);
2320
+ updateLayers(layerSet);
2321
+ }, [updateLayers]);
2322
+ const unregisterLayer = hooks.useCallback((layer) => {
2323
+ layerSet.current.delete(layer);
2324
+ updateLayers(layerSet);
2325
+ }, [updateLayers]);
2326
+ const findFeatureAtPoint = hooks.useCallback(({
2327
+ x,
2328
+ y
2329
+ }) => {
2330
+ const adjustedPoint = [x - padding.left, y - padding.top];
2331
+ for (const layer of layers.current) {
2332
+ if (typeof layer.findFeatureAtPoint === "function") {
2333
+ const feature = layer.findFeatureAtPoint(adjustedPoint);
2334
+ if (feature)
2335
+ return feature;
2336
+ }
2337
+ }
2338
+ return null;
2339
+ }, [padding]);
2340
+ const getVisibleBounds = hooks.useCallback(() => {
2341
+ const projectedSW = projection.invert([padding.left, contentSize.height]);
2342
+ const projectedNE = projection.invert([padding.left + contentSize.width, padding.top]);
2343
+ return [projectedSW, projectedNE];
2344
+ }, [projection, contentSize, padding]);
2345
+ const getZoomScale = hooks.useCallback(() => {
2346
+ return calculateScale(getVisibleBounds(), contentSize.width, contentSize.height);
2347
+ }, [getVisibleBounds, contentSize]);
2279
2348
  const context = {
2280
2349
  id,
2281
- mapRef,
2282
2350
  projection,
2283
2351
  config,
2284
2352
  path: path2,
@@ -2290,15 +2358,20 @@
2290
2358
  padding,
2291
2359
  zoom,
2292
2360
  extent: [[0, 0], [width, height]],
2293
- selectedFeature
2361
+ selectedFeature,
2362
+ getZoomScale,
2363
+ registerLayer,
2364
+ unregisterLayer,
2365
+ findFeatureAtPoint
2294
2366
  };
2367
+ mapRef.current = context;
2295
2368
  return jsxRuntime.jsx(MapContext.Provider, {
2296
2369
  value: context,
2297
2370
  children
2298
2371
  });
2299
2372
  }
2300
2373
  const path$1 = "_path_1cwd5_9";
2301
- const defaultStyles$4 = {
2374
+ const defaultStyles$5 = {
2302
2375
  path: path$1
2303
2376
  };
2304
2377
  function CompositionBorders({
@@ -2307,7 +2380,7 @@
2307
2380
  const {
2308
2381
  projection
2309
2382
  } = hooks.useContext(MapContext);
2310
- styles2 = mergeStyles(defaultStyles$4, styles2);
2383
+ styles2 = mergeStyles(defaultStyles$5, styles2);
2311
2384
  return jsxRuntime.jsx("path", {
2312
2385
  className: styles2.path,
2313
2386
  d: projection.getCompositionBorders()
@@ -2318,7 +2391,6 @@
2318
2391
  }) {
2319
2392
  const {
2320
2393
  id,
2321
- mapRef,
2322
2394
  config,
2323
2395
  size,
2324
2396
  selectedFeature,
@@ -2326,7 +2398,6 @@
2326
2398
  } = hooks.useContext(MapContext);
2327
2399
  return jsxRuntime.jsx("svg", {
2328
2400
  id,
2329
- ref: mapRef,
2330
2401
  width: size.width,
2331
2402
  height: size.height,
2332
2403
  viewBox: `0 0 ${size.width} ${size.height}`,
@@ -2376,9 +2447,22 @@
2376
2447
  fill = null,
2377
2448
  stroke = null,
2378
2449
  strokeWidth = 1,
2450
+ zIndex = 0,
2379
2451
  styles: styles2
2380
2452
  }) {
2381
2453
  const context = hooks.useContext(MapContext);
2454
+ hooks.useEffect(() => {
2455
+ function findFeatureAtPoint(point) {
2456
+ }
2457
+ const layer = {
2458
+ zIndex,
2459
+ findFeatureAtPoint
2460
+ };
2461
+ context.registerLayer(layer);
2462
+ return () => {
2463
+ context.unregisterLayer(layer);
2464
+ };
2465
+ }, [context, zIndex]);
2382
2466
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
2383
2467
  children: features.map((d2, index2) => {
2384
2468
  return jsxRuntime.jsx("path", {
@@ -2459,9 +2543,34 @@
2459
2543
  fill = null,
2460
2544
  stroke = null,
2461
2545
  strokeWidth = 1,
2546
+ zIndex = 0,
2462
2547
  styles: styles2
2463
2548
  }) {
2464
2549
  const context = hooks.useContext(MapContext);
2550
+ hooks.useEffect(() => {
2551
+ function findFeatureAtPoint(point) {
2552
+ for (const [index2, feature] of features.entries()) {
2553
+ const resolvedRadius = dynamicPropValue(radius, feature, index2);
2554
+ if (isNaN(resolvedRadius))
2555
+ return;
2556
+ const [cx, cy] = context.projection(feature.geometry.coordinates);
2557
+ const distanceSquared = (point[0] - cx) ** 2 + (point[1] - cy) ** 2;
2558
+ const radiusSquared = resolvedRadius ** 2;
2559
+ if (distanceSquared <= radiusSquared) {
2560
+ return feature;
2561
+ }
2562
+ }
2563
+ return null;
2564
+ }
2565
+ const layer = {
2566
+ zIndex,
2567
+ findFeatureAtPoint
2568
+ };
2569
+ context.registerLayer(layer);
2570
+ return () => {
2571
+ context.unregisterLayer(layer);
2572
+ };
2573
+ }, [context, features, radius, zIndex]);
2465
2574
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
2466
2575
  children: features.map((d2, index2) => {
2467
2576
  const [cx, cy] = context.projection(d2.geometry.coordinates);
@@ -2546,34 +2655,12 @@
2546
2655
  setIsReady(true);
2547
2656
  }
2548
2657
  }, [isReady]);
2549
- hooks.useImperativeHandle(
2550
- ref,
2551
- () => ({
2552
- isReady,
2553
- getContainer: () => containerRef.current,
2554
- findFeatureAtPoint
2555
- }),
2556
- // eslint-disable-next-line react-hooks/exhaustive-deps
2557
- [isReady]
2558
- );
2559
- function findFeatureAtPoint({
2560
- x,
2561
- y
2562
- }) {
2563
- const adjustedPoint = [x - padding.left, y - padding.top];
2564
- const coordinates = config.projection.invert(adjustedPoint);
2565
- for (const child of preact.toChildArray(children)) {
2566
- if (Object.prototype.hasOwnProperty.call(child.props, "features")) {
2567
- const features = child.props.features;
2568
- for (const feature of features) {
2569
- if (d3Geo.geoContains(feature, coordinates)) {
2570
- return feature;
2571
- }
2572
- }
2573
- }
2574
- }
2575
- return null;
2576
- }
2658
+ const mapRef = hooks.useRef();
2659
+ hooks.useImperativeHandle(ref, () => ({
2660
+ isReady,
2661
+ getContainer: () => containerRef.current,
2662
+ getContext: () => mapRef.current
2663
+ }), [isReady]);
2577
2664
  const containerSize = useContainerSize(containerRef);
2578
2665
  const containerStyle = hooks.useMemo(() => {
2579
2666
  const style = {};
@@ -2583,7 +2670,6 @@
2583
2670
  style["height"] = height;
2584
2671
  return style;
2585
2672
  }, [width, height]);
2586
- const mapRef = hooks.useRef();
2587
2673
  const renderSVG = containerSize && !config.drawToCanvas;
2588
2674
  return jsxRuntime.jsx("div", {
2589
2675
  ref: containerRef,
@@ -2599,14 +2685,16 @@
2599
2685
  selectedFeature,
2600
2686
  zoom,
2601
2687
  children: jsxRuntime.jsx(SVGRenderer, {
2602
- children
2688
+ children: preact.toChildArray(children).map((child, index2) => preact.cloneElement(child, {
2689
+ zIndex: index2
2690
+ }))
2603
2691
  })
2604
2692
  })
2605
2693
  });
2606
2694
  });
2607
2695
  const container = "_container_azu4a_1";
2608
2696
  const paragraph = "_paragraph_azu4a_12";
2609
- const defaultStyles$3 = {
2697
+ const defaultStyles$4 = {
2610
2698
  container,
2611
2699
  paragraph
2612
2700
  };
@@ -2619,7 +2707,7 @@
2619
2707
  styles: styles2
2620
2708
  }) {
2621
2709
  styles2 = mergeStyles({
2622
- ...defaultStyles$3
2710
+ ...defaultStyles$4
2623
2711
  }, styles2);
2624
2712
  return jsxRuntime.jsxs("div", {
2625
2713
  class: styles2.container,
@@ -2662,7 +2750,7 @@
2662
2750
  const suggestion = "_suggestion_g5w44_36";
2663
2751
  const selected = "_selected_g5w44_59";
2664
2752
  const highlighted = "_highlighted_g5w44_63";
2665
- const defaultStyles$2 = {
2753
+ const defaultStyles$3 = {
2666
2754
  searchContainer,
2667
2755
  input,
2668
2756
  searchIcon,
@@ -2683,7 +2771,7 @@
2683
2771
  styles: styles2
2684
2772
  }) {
2685
2773
  var _a, _b, _c;
2686
- styles2 = mergeStyles(defaultStyles$2, styles2);
2774
+ styles2 = mergeStyles(defaultStyles$3, styles2);
2687
2775
  const inputRef = hooks.useRef(null);
2688
2776
  const [selectedIndex, setSelectedIndex] = hooks.useState(-1);
2689
2777
  const [suggestions2, setSuggestions] = hooks.useState();
@@ -2795,7 +2883,7 @@
2795
2883
  const refreshIndicator = "_refreshIndicator_u6lji_1";
2796
2884
  const liveText = "_liveText_u6lji_8";
2797
2885
  const refreshText = "_refreshText_u6lji_9";
2798
- const defaultStyles$1 = {
2886
+ const defaultStyles$2 = {
2799
2887
  refreshIndicator,
2800
2888
  liveText,
2801
2889
  refreshText
@@ -2804,7 +2892,7 @@
2804
2892
  text: text2,
2805
2893
  styles: styles2
2806
2894
  }) {
2807
- styles2 = mergeStyles(defaultStyles$1, styles2);
2895
+ styles2 = mergeStyles(defaultStyles$2, styles2);
2808
2896
  return jsxRuntime.jsxs("div", {
2809
2897
  className: styles2.refreshIndicator,
2810
2898
  children: [jsxRuntime.jsx(CircleIcon, {
@@ -2818,6 +2906,34 @@
2818
2906
  })]
2819
2907
  });
2820
2908
  }
2909
+ const grid = "_grid_xps7m_9";
2910
+ const defaultStyles$1 = {
2911
+ grid
2912
+ };
2913
+ const GridType = {
2914
+ small: "small",
2915
+ medium: "medium",
2916
+ large: "large"
2917
+ };
2918
+ function ResponsiveGrid({
2919
+ type = GridType.medium,
2920
+ children,
2921
+ styles: styles2
2922
+ }) {
2923
+ styles2 = mergeStyles({
2924
+ ...defaultStyles$1
2925
+ }, styles2);
2926
+ return jsxRuntime.jsx("div", {
2927
+ className: styles2.grid,
2928
+ "data-grid-type": type,
2929
+ children: preact.toChildArray(children).map((child, index2) => {
2930
+ return jsxRuntime.jsx("div", {
2931
+ className: styles2.gridItem,
2932
+ children: child
2933
+ }, index2);
2934
+ })
2935
+ });
2936
+ }
2821
2937
  const coalitionsWrapper = "_coalitionsWrapper_1ahqy_9";
2822
2938
  const coalitionsContainer = "_coalitionsContainer_1ahqy_14";
2823
2939
  const coalition = "_coalition_1ahqy_9";
@@ -3112,6 +3228,7 @@
3112
3228
  exports2.Container = Container;
3113
3229
  exports2.ControlChange = ControlChange;
3114
3230
  exports2.GradientIcon = GradientIcon;
3231
+ exports2.GridType = GridType;
3115
3232
  exports2.InfoButton = InfoButton;
3116
3233
  exports2.LegendItem = LegendItem;
3117
3234
  exports2.Map = Map$1;
@@ -3122,6 +3239,7 @@
3122
3239
  exports2.Projection = Projection;
3123
3240
  exports2.RefreshIndicator = RefreshIndicator;
3124
3241
  exports2.RelativeTimeSentence = RelativeTimeSentence;
3242
+ exports2.ResponsiveGrid = ResponsiveGrid;
3125
3243
  exports2.ResultSummary = ResultSummary;
3126
3244
  exports2.SearchInput = SearchInput;
3127
3245
  exports2.SlopeChart = SlopeChart;