@guardian/interactive-component-library 0.1.0-alpha.49 → 0.1.0-alpha.51

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.
@@ -2373,13 +2373,13 @@ var d = (E) => {
2373
2373
  return cloneElement(t, { className: i });
2374
2374
  });
2375
2375
  };
2376
- const transitionContainer = "_transitionContainer_48fp9_1";
2377
- const blur = "_blur_48fp9_11";
2378
- const modalBox = "_modalBox_48fp9_16";
2379
- const enter = "_enter_48fp9_25";
2380
- const exitDone = "_exitDone_48fp9_26";
2381
- const enterActive = "_enterActive_48fp9_37";
2382
- const exitActive = "_exitActive_48fp9_48";
2376
+ const transitionContainer = "_transitionContainer_11twd_1";
2377
+ const blur = "_blur_11twd_11";
2378
+ const modalBox = "_modalBox_11twd_16";
2379
+ const enter = "_enter_11twd_25";
2380
+ const exitDone = "_exitDone_11twd_26";
2381
+ const enterActive = "_enterActive_11twd_37";
2382
+ const exit = "_exit_11twd_26";
2383
2383
  const defaultStyles$3 = {
2384
2384
  transitionContainer,
2385
2385
  blur,
@@ -2387,11 +2387,12 @@ const defaultStyles$3 = {
2387
2387
  enter,
2388
2388
  exitDone,
2389
2389
  enterActive,
2390
- exitActive
2390
+ exit
2391
2391
  };
2392
2392
  function Modal({
2393
2393
  visible = false,
2394
2394
  blurBackground = true,
2395
+ alwaysMounted = false,
2395
2396
  styles: styles2,
2396
2397
  children,
2397
2398
  onClickOutside
@@ -2418,10 +2419,11 @@ function Modal({
2418
2419
  }, [onClick, visible]);
2419
2420
  if (typeof document === "undefined")
2420
2421
  return;
2421
- return createPortal(jsx(d, {
2422
+ return jsx(d, {
2422
2423
  in: visible,
2423
2424
  duration: 300,
2424
2425
  classNames: styles2,
2426
+ alwaysMounted,
2425
2427
  children: jsx("div", {
2426
2428
  className: [styles2.transitionContainer, blurBackground && styles2.blur, visible && styles2.visible].join(" "),
2427
2429
  onClick,
@@ -2431,7 +2433,7 @@ function Modal({
2431
2433
  children
2432
2434
  })
2433
2435
  })
2434
- }), document.body);
2436
+ });
2435
2437
  }
2436
2438
  const container$1 = "_container_6u92g_1";
2437
2439
  const button$3 = "_button_6u92g_5";
@@ -3884,6 +3886,21 @@ function scalePadding(padding, ratio) {
3884
3886
  };
3885
3887
  return scaled;
3886
3888
  }
3889
+ function sizeForElement(element) {
3890
+ const computedStyle = getComputedStyle(element);
3891
+ if (!computedStyle)
3892
+ return null;
3893
+ let size;
3894
+ const width = element.offsetWidth - parseFloat(computedStyle["borderLeftWidth"]) - parseFloat(computedStyle["paddingLeft"]) - parseFloat(computedStyle["paddingRight"]) - parseFloat(computedStyle["borderRightWidth"]);
3895
+ const height = element.offsetHeight - parseFloat(computedStyle["borderTopWidth"]) - parseFloat(computedStyle["paddingTop"]) - parseFloat(computedStyle["paddingBottom"]) - parseFloat(computedStyle["borderBottomWidth"]);
3896
+ if (!isNaN(width) && !isNaN(height)) {
3897
+ size = [width, height];
3898
+ if (!hasArea(size) && !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length)) {
3899
+ console.warn("No map visible because the map container's width or height are 0.");
3900
+ }
3901
+ }
3902
+ return size;
3903
+ }
3887
3904
  function arrayEquals(arr1, arr2) {
3888
3905
  const len1 = arr1.length;
3889
3906
  if (len1 !== arr2.length) {
@@ -5921,7 +5938,9 @@ let Map$2 = class Map2 {
5921
5938
  this._viewport.style.height = "100%";
5922
5939
  this.target.appendChild(this._viewport);
5923
5940
  this._renderer = new MapRenderer(this);
5924
- this._resizeObserver = new ResizeObserver(() => this._updateSize());
5941
+ this._resizeObserver = new ResizeObserver(() => {
5942
+ this._updateSize();
5943
+ });
5925
5944
  this._resizeObserver.observe(this.target);
5926
5945
  this._viewport.addEventListener("touchmove", (event) => {
5927
5946
  if (event.targetTouches.length < 2 && this.collaborativeGesturesEnabled) {
@@ -6067,22 +6086,11 @@ let Map$2 = class Map2 {
6067
6086
  /** PRIVATE METHODS */
6068
6087
  _updateSize() {
6069
6088
  const targetElement = this.target;
6070
- let size;
6071
- if (targetElement) {
6072
- const computedStyle = getComputedStyle(targetElement);
6073
- const width = targetElement.offsetWidth - parseFloat(computedStyle["borderLeftWidth"]) - parseFloat(computedStyle["paddingLeft"]) - parseFloat(computedStyle["paddingRight"]) - parseFloat(computedStyle["borderRightWidth"]);
6074
- const height = targetElement.offsetHeight - parseFloat(computedStyle["borderTopWidth"]) - parseFloat(computedStyle["paddingTop"]) - parseFloat(computedStyle["paddingBottom"]) - parseFloat(computedStyle["borderBottomWidth"]);
6075
- if (!isNaN(width) && !isNaN(height)) {
6076
- size = [width, height];
6077
- if (!hasArea(size) && !!(targetElement.offsetWidth || targetElement.offsetHeight || targetElement.getClientRects().length)) {
6078
- console.warn("No map visible because the map container's width or height are 0.");
6079
- }
6080
- }
6081
- }
6089
+ let newSize = sizeForElement(targetElement);
6082
6090
  const oldSize = this.size;
6083
- if (size && (!oldSize || !arrayEquals(size, oldSize))) {
6084
- this._size = size;
6085
- this._updateViewportSize(size);
6091
+ if (newSize && (!oldSize || !arrayEquals(newSize, oldSize))) {
6092
+ this._size = newSize;
6093
+ this._updateViewportSize(newSize);
6086
6094
  }
6087
6095
  }
6088
6096
  _updateViewportSize(size) {
@@ -6317,11 +6325,11 @@ class View {
6317
6325
  };
6318
6326
  }
6319
6327
  }
6320
- const mapContainer = "_mapContainer_qlxau_9";
6321
- const helpTextContainer = "_helpTextContainer_qlxau_15";
6322
- const helpText = "_helpText_qlxau_15";
6323
- const desktopHelpText = "_desktopHelpText_qlxau_40";
6324
- const mobileHelpText$1 = "_mobileHelpText_qlxau_48";
6328
+ const mapContainer = "_mapContainer_1ogf3_9";
6329
+ const helpTextContainer = "_helpTextContainer_1ogf3_15";
6330
+ const helpText = "_helpText_1ogf3_15";
6331
+ const desktopHelpText = "_desktopHelpText_1ogf3_40";
6332
+ const mobileHelpText$1 = "_mobileHelpText_1ogf3_48";
6325
6333
  const styles$3 = {
6326
6334
  mapContainer,
6327
6335
  helpTextContainer,
@@ -6755,7 +6763,7 @@ class Text {
6755
6763
  this.fontWeight = (options == null ? void 0 : options.fontWeight) || "400";
6756
6764
  this.lineHeight = (options == null ? void 0 : options.lineHeight) || 1.3;
6757
6765
  this.color = (options == null ? void 0 : options.color) || "#121212";
6758
- this.textShadow = (options == null ? void 0 : options.textShadow) || "1px 1px 0px white, -1px -1px 0px white, -1px 1px 0px white, 1px -1px white";
6766
+ this.textShadow = (options == null ? void 0 : options.textShadow) || "1px 1px 0px #f6f6f6, -1px -1px 0px #f6f6f6, -1px 1px 0px #f6f6f6, 1px -1px #f6f6f6";
6759
6767
  }
6760
6768
  }
6761
6769
  var rbushKnn = { exports: {} };
@@ -6889,7 +6897,14 @@ class VectorSource {
6889
6897
  }
6890
6898
  getFeaturesAtCoordinate(coordinate) {
6891
6899
  const [lon, lat] = coordinate;
6892
- return knn$1(this._featuresRtree, lon, lat, 1, (d2) => d2.feature.containsCoordinate(coordinate)).map((d2) => d2.feature);
6900
+ const features = knn$1(this._featuresRtree, lon, lat, 10, (d2) => d2.feature.containsCoordinate(coordinate)).map((d2) => {
6901
+ const midX = d2.minX + (d2.minX + d2.maxX) / 2;
6902
+ const midY = d2.minY + (d2.minY + d2.maxY) / 2;
6903
+ d2.distance = Math.hypot(midX - lon, midY - lat);
6904
+ return d2;
6905
+ });
6906
+ features.sort((a, b) => a.distance - b.distance);
6907
+ return features.map((d2) => d2.feature);
6893
6908
  }
6894
6909
  getFeaturesInExtent(extent) {
6895
6910
  const [minX, minY, maxX, maxY] = extent;
@@ -7816,7 +7831,7 @@ function Ticker({
7816
7831
  className: styles.buttons,
7817
7832
  children: [jsx(ArrowButton, {
7818
7833
  onClick: () => setPageIndex((d2) => d2 + 1),
7819
- disabled: pageIndex >= numberOfPages - 1
7834
+ disabled: pageIndex >= numberOfPages - 2
7820
7835
  }), jsx(ArrowButton, {
7821
7836
  direction: "left",
7822
7837
  onClick: () => setPageIndex((d2) => d2 - 1),