@guardian/interactive-component-library 0.1.0-alpha.14 → 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,7 +1929,7 @@
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);
1933
1935
  let marginBottom = minValue < 0 ? 0 : 40;
@@ -1971,7 +1973,7 @@
1971
1973
  const leftCell = "_leftCell_vd5ly_55";
1972
1974
  const rightCell = "_rightCell_vd5ly_55";
1973
1975
  const mugshot = "_mugshot_vd5ly_71";
1974
- const defaultStyles$5 = {
1976
+ const defaultStyles$6 = {
1975
1977
  text,
1976
1978
  container: container$2,
1977
1979
  title: title$1,
@@ -1990,7 +1992,7 @@
1990
1992
  abbreviation
1991
1993
  }) => {
1992
1994
  styles2 = mergeStyles({
1993
- ...defaultStyles$5
1995
+ ...defaultStyles$6
1994
1996
  }, styles2);
1995
1997
  return jsxRuntime.jsx("div", {
1996
1998
  class: styles2.container,
@@ -2258,6 +2260,33 @@
2258
2260
  return feature;
2259
2261
  }
2260
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
+ }
2261
2290
  function SVGMapProvider({
2262
2291
  id,
2263
2292
  mapRef,
@@ -2277,9 +2306,47 @@
2277
2306
  return config.projection.fitSize([contentSize.width, contentSize.height], bboxFeature(config.bounds));
2278
2307
  }, [contentSize, config]);
2279
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]);
2280
2348
  const context = {
2281
2349
  id,
2282
- mapRef,
2283
2350
  projection,
2284
2351
  config,
2285
2352
  path: path2,
@@ -2291,15 +2358,20 @@
2291
2358
  padding,
2292
2359
  zoom,
2293
2360
  extent: [[0, 0], [width, height]],
2294
- selectedFeature
2361
+ selectedFeature,
2362
+ getZoomScale,
2363
+ registerLayer,
2364
+ unregisterLayer,
2365
+ findFeatureAtPoint
2295
2366
  };
2367
+ mapRef.current = context;
2296
2368
  return jsxRuntime.jsx(MapContext.Provider, {
2297
2369
  value: context,
2298
2370
  children
2299
2371
  });
2300
2372
  }
2301
2373
  const path$1 = "_path_1cwd5_9";
2302
- const defaultStyles$4 = {
2374
+ const defaultStyles$5 = {
2303
2375
  path: path$1
2304
2376
  };
2305
2377
  function CompositionBorders({
@@ -2308,7 +2380,7 @@
2308
2380
  const {
2309
2381
  projection
2310
2382
  } = hooks.useContext(MapContext);
2311
- styles2 = mergeStyles(defaultStyles$4, styles2);
2383
+ styles2 = mergeStyles(defaultStyles$5, styles2);
2312
2384
  return jsxRuntime.jsx("path", {
2313
2385
  className: styles2.path,
2314
2386
  d: projection.getCompositionBorders()
@@ -2319,7 +2391,6 @@
2319
2391
  }) {
2320
2392
  const {
2321
2393
  id,
2322
- mapRef,
2323
2394
  config,
2324
2395
  size,
2325
2396
  selectedFeature,
@@ -2327,7 +2398,6 @@
2327
2398
  } = hooks.useContext(MapContext);
2328
2399
  return jsxRuntime.jsx("svg", {
2329
2400
  id,
2330
- ref: mapRef,
2331
2401
  width: size.width,
2332
2402
  height: size.height,
2333
2403
  viewBox: `0 0 ${size.width} ${size.height}`,
@@ -2377,9 +2447,22 @@
2377
2447
  fill = null,
2378
2448
  stroke = null,
2379
2449
  strokeWidth = 1,
2450
+ zIndex = 0,
2380
2451
  styles: styles2
2381
2452
  }) {
2382
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]);
2383
2466
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
2384
2467
  children: features.map((d2, index2) => {
2385
2468
  return jsxRuntime.jsx("path", {
@@ -2460,9 +2543,34 @@
2460
2543
  fill = null,
2461
2544
  stroke = null,
2462
2545
  strokeWidth = 1,
2546
+ zIndex = 0,
2463
2547
  styles: styles2
2464
2548
  }) {
2465
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]);
2466
2574
  return jsxRuntime.jsx(jsxRuntime.Fragment, {
2467
2575
  children: features.map((d2, index2) => {
2468
2576
  const [cx, cy] = context.projection(d2.geometry.coordinates);
@@ -2547,34 +2655,12 @@
2547
2655
  setIsReady(true);
2548
2656
  }
2549
2657
  }, [isReady]);
2550
- hooks.useImperativeHandle(
2551
- ref,
2552
- () => ({
2553
- isReady,
2554
- getContainer: () => containerRef.current,
2555
- findFeatureAtPoint
2556
- }),
2557
- // eslint-disable-next-line react-hooks/exhaustive-deps
2558
- [isReady]
2559
- );
2560
- function findFeatureAtPoint({
2561
- x,
2562
- y
2563
- }) {
2564
- const adjustedPoint = [x - padding.left, y - padding.top];
2565
- const coordinates = config.projection.invert(adjustedPoint);
2566
- for (const child of preact.toChildArray(children)) {
2567
- if (Object.prototype.hasOwnProperty.call(child.props, "features")) {
2568
- const features = child.props.features;
2569
- for (const feature of features) {
2570
- if (d3Geo.geoContains(feature, coordinates)) {
2571
- return feature;
2572
- }
2573
- }
2574
- }
2575
- }
2576
- return null;
2577
- }
2658
+ const mapRef = hooks.useRef();
2659
+ hooks.useImperativeHandle(ref, () => ({
2660
+ isReady,
2661
+ getContainer: () => containerRef.current,
2662
+ getContext: () => mapRef.current
2663
+ }), [isReady]);
2578
2664
  const containerSize = useContainerSize(containerRef);
2579
2665
  const containerStyle = hooks.useMemo(() => {
2580
2666
  const style = {};
@@ -2584,7 +2670,6 @@
2584
2670
  style["height"] = height;
2585
2671
  return style;
2586
2672
  }, [width, height]);
2587
- const mapRef = hooks.useRef();
2588
2673
  const renderSVG = containerSize && !config.drawToCanvas;
2589
2674
  return jsxRuntime.jsx("div", {
2590
2675
  ref: containerRef,
@@ -2600,14 +2685,16 @@
2600
2685
  selectedFeature,
2601
2686
  zoom,
2602
2687
  children: jsxRuntime.jsx(SVGRenderer, {
2603
- children
2688
+ children: preact.toChildArray(children).map((child, index2) => preact.cloneElement(child, {
2689
+ zIndex: index2
2690
+ }))
2604
2691
  })
2605
2692
  })
2606
2693
  });
2607
2694
  });
2608
2695
  const container = "_container_azu4a_1";
2609
2696
  const paragraph = "_paragraph_azu4a_12";
2610
- const defaultStyles$3 = {
2697
+ const defaultStyles$4 = {
2611
2698
  container,
2612
2699
  paragraph
2613
2700
  };
@@ -2620,7 +2707,7 @@
2620
2707
  styles: styles2
2621
2708
  }) {
2622
2709
  styles2 = mergeStyles({
2623
- ...defaultStyles$3
2710
+ ...defaultStyles$4
2624
2711
  }, styles2);
2625
2712
  return jsxRuntime.jsxs("div", {
2626
2713
  class: styles2.container,
@@ -2663,7 +2750,7 @@
2663
2750
  const suggestion = "_suggestion_g5w44_36";
2664
2751
  const selected = "_selected_g5w44_59";
2665
2752
  const highlighted = "_highlighted_g5w44_63";
2666
- const defaultStyles$2 = {
2753
+ const defaultStyles$3 = {
2667
2754
  searchContainer,
2668
2755
  input,
2669
2756
  searchIcon,
@@ -2684,7 +2771,7 @@
2684
2771
  styles: styles2
2685
2772
  }) {
2686
2773
  var _a, _b, _c;
2687
- styles2 = mergeStyles(defaultStyles$2, styles2);
2774
+ styles2 = mergeStyles(defaultStyles$3, styles2);
2688
2775
  const inputRef = hooks.useRef(null);
2689
2776
  const [selectedIndex, setSelectedIndex] = hooks.useState(-1);
2690
2777
  const [suggestions2, setSuggestions] = hooks.useState();
@@ -2796,7 +2883,7 @@
2796
2883
  const refreshIndicator = "_refreshIndicator_u6lji_1";
2797
2884
  const liveText = "_liveText_u6lji_8";
2798
2885
  const refreshText = "_refreshText_u6lji_9";
2799
- const defaultStyles$1 = {
2886
+ const defaultStyles$2 = {
2800
2887
  refreshIndicator,
2801
2888
  liveText,
2802
2889
  refreshText
@@ -2805,7 +2892,7 @@
2805
2892
  text: text2,
2806
2893
  styles: styles2
2807
2894
  }) {
2808
- styles2 = mergeStyles(defaultStyles$1, styles2);
2895
+ styles2 = mergeStyles(defaultStyles$2, styles2);
2809
2896
  return jsxRuntime.jsxs("div", {
2810
2897
  className: styles2.refreshIndicator,
2811
2898
  children: [jsxRuntime.jsx(CircleIcon, {
@@ -2819,6 +2906,34 @@
2819
2906
  })]
2820
2907
  });
2821
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
+ }
2822
2937
  const coalitionsWrapper = "_coalitionsWrapper_1ahqy_9";
2823
2938
  const coalitionsContainer = "_coalitionsContainer_1ahqy_14";
2824
2939
  const coalition = "_coalition_1ahqy_9";
@@ -3113,6 +3228,7 @@
3113
3228
  exports2.Container = Container;
3114
3229
  exports2.ControlChange = ControlChange;
3115
3230
  exports2.GradientIcon = GradientIcon;
3231
+ exports2.GridType = GridType;
3116
3232
  exports2.InfoButton = InfoButton;
3117
3233
  exports2.LegendItem = LegendItem;
3118
3234
  exports2.Map = Map$1;
@@ -3123,6 +3239,7 @@
3123
3239
  exports2.Projection = Projection;
3124
3240
  exports2.RefreshIndicator = RefreshIndicator;
3125
3241
  exports2.RelativeTimeSentence = RelativeTimeSentence;
3242
+ exports2.ResponsiveGrid = ResponsiveGrid;
3126
3243
  exports2.ResultSummary = ResultSummary;
3127
3244
  exports2.SearchInput = SearchInput;
3128
3245
  exports2.SlopeChart = SlopeChart;