@guardian/interactive-component-library 0.1.0-alpha.34 → 0.1.0-alpha.36

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.
@@ -1,6 +1,6 @@
1
1
  (function(global2, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("preact/jsx-runtime"), require("preact/hooks"), require("preact"), require("preact/compat"), require("d3-scale"), require("d3-geo"), require("d3-zoom"), require("d3-selection")) : typeof define === "function" && define.amd ? define(["exports", "preact/jsx-runtime", "preact/hooks", "preact", "preact/compat", "d3-scale", "d3-geo", "d3-zoom", "d3-selection"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["interactive-component-library"] = {}, global2["preact/jsx-runtime"], global2["preact/hooks"], global2.preact, global2["preact/compat"], global2["d3-scale"], global2["d3-geo"], global2["d3-zoom"], global2["d3-selection"]));
3
- })(this, function(exports2, jsxRuntime, hooks, preact, compat, d3Scale, d3Geo, d3Zoom, d3Selection) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("preact/jsx-runtime"), require("preact/hooks"), require("preact/compat"), require("d3-scale"), require("preact"), require("d3-geo"), require("d3-zoom"), require("d3-selection")) : typeof define === "function" && define.amd ? define(["exports", "preact/jsx-runtime", "preact/hooks", "preact/compat", "d3-scale", "preact", "d3-geo", "d3-zoom", "d3-selection"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["interactive-component-library"] = {}, global2["preact/jsx-runtime"], global2["preact/hooks"], global2["preact/compat"], global2["d3-scale"], global2.preact, global2["d3-geo"], global2["d3-zoom"], global2["d3-selection"]));
3
+ })(this, function(exports2, jsxRuntime, hooks, compat, d3Scale, preact, d3Geo, d3Zoom, d3Selection) {
4
4
  "use strict";
5
5
  const main = "";
6
6
  const svg$9 = "_svg_b5io0_1";
@@ -302,60 +302,6 @@
302
302
  children: [content2, labelType === LabelType.hanging && !hideLabels && hangingLabelConfig.map((config, i) => renderLabel(config, i))]
303
303
  });
304
304
  }
305
- function shouldUpdate(oldState, newState) {
306
- if (oldState === newState)
307
- return false;
308
- if (isObj(oldState) && isObj(newState)) {
309
- for (let key in newState) {
310
- if (oldState[key] !== newState[key])
311
- return true;
312
- }
313
- return false;
314
- }
315
- return true;
316
- }
317
- function isObj(obj) {
318
- return typeof obj === "object" && !Array.isArray(obj) && obj !== null;
319
- }
320
- function createStore(initialStore) {
321
- let store = initialStore;
322
- const listeners = /* @__PURE__ */ new Set();
323
- function useStore(selectorFn = (store2) => store2) {
324
- const subscribe = hooks.useCallback((updater) => {
325
- const listener = {
326
- updater,
327
- selectorFn
328
- };
329
- listeners.add(listener);
330
- return () => {
331
- listeners.delete(listener);
332
- };
333
- }, [selectorFn]);
334
- const syncedStore = compat.useSyncExternalStore(subscribe, getStore, getServerStore);
335
- return selectorFn(syncedStore);
336
- }
337
- function setStore(action) {
338
- const oldStore = store;
339
- store = action instanceof Function ? action(store) : action;
340
- listeners.forEach(({
341
- selectorFn,
342
- updater
343
- }) => {
344
- const oldState = selectorFn(oldStore);
345
- const newState = selectorFn(store);
346
- if (shouldUpdate(oldState, newState))
347
- updater(() => newState);
348
- });
349
- }
350
- function getStore() {
351
- return store;
352
- }
353
- function getServerStore() {
354
- return initialStore;
355
- }
356
- return [useStore, setStore, getStore];
357
- }
358
- const [useGradients, setGradients, getGradients] = createStore({});
359
305
  const svg$8 = "_svg_1cajk_6";
360
306
  const previous = "_previous_1cajk_12";
361
307
  const next = "_next_1cajk_16";
@@ -371,72 +317,34 @@
371
317
  styles: styles2
372
318
  } = props;
373
319
  styles2 = mergeStyles(defaultStyles$t, styles2);
374
- const gradientId = `gv-gradient-def-${previous2}-${next2}`;
375
- const gradients = useGradients();
376
- hooks.useEffect(() => {
377
- setGradients((current) => {
378
- current[gradientId] = {
379
- id: gradientId,
380
- ...props
381
- };
382
- return current;
383
- });
384
- }, [gradientId, props]);
385
- hooks.useEffect(() => {
386
- let container2 = document.getElementById("gv-gradient-defs");
387
- if (!container2) {
388
- container2 = document.createElement("div");
389
- container2.id = "gv-gradient-defs";
390
- document.body.prepend(container2);
391
- }
392
- preact.render(jsxRuntime.jsx(GradientDefs, {
393
- gradients: Object.values(gradients)
394
- }), container2);
395
- }, [gradients]);
396
- return jsxRuntime.jsx("svg", {
320
+ const gradientId = hooks.useId();
321
+ return jsxRuntime.jsxs("svg", {
397
322
  class: styles2.svg,
398
323
  width: "24",
399
324
  height: "11",
400
325
  viewBox: "0 0 24 11",
401
326
  xmlns: "http://www.w3.org/2000/svg",
402
- children: jsxRuntime.jsx("path", {
327
+ children: [jsxRuntime.jsx("defs", {
328
+ children: jsxRuntime.jsxs("linearGradient", {
329
+ id: gradientId,
330
+ x1: "5.5",
331
+ y1: "5.5",
332
+ x2: "12",
333
+ y2: "5.5",
334
+ gradientUnits: "userSpaceOnUse",
335
+ children: [jsxRuntime.jsx("stop", {
336
+ class: `${styles2 == null ? void 0 : styles2.previous} stop-color--${previous2}`
337
+ }), jsxRuntime.jsx("stop", {
338
+ class: `${styles2 == null ? void 0 : styles2.next} stop-color--${next2}`,
339
+ offset: "1"
340
+ })]
341
+ })
342
+ }), jsxRuntime.jsx("path", {
403
343
  d: "M0 5.434C0 2.43288 2.43288 0 5.434 0H5.69626C6.85818 0 7.9797 0.426401 8.84813 1.19834C10.6456 2.79612 13.3544 2.79612 15.1519 1.19834C16.0203 0.426401 17.1418 0 18.3037 0L18.566 0C21.5671 0 24 2.43288 24 5.434V5.566C24 8.56712 21.5671 11 18.566 11H18.3037C17.1418 11 16.0203 10.5736 15.1519 9.80166C13.3544 8.20388 10.6456 8.20388 8.84813 9.80166C7.9797 10.5736 6.85818 11 5.69626 11H5.434C2.43288 11 0 8.56712 0 5.566V5.434Z",
404
344
  fill: `url(#${gradientId})`
405
- })
345
+ })]
406
346
  });
407
347
  };
408
- function GradientDefs({
409
- gradients
410
- }) {
411
- return jsxRuntime.jsx("svg", {
412
- width: "24",
413
- height: "11",
414
- viewBox: "0 0 24 11",
415
- children: jsxRuntime.jsx("defs", {
416
- children: gradients.map(({
417
- id: id2,
418
- previous: previous2,
419
- next: next2,
420
- styles: styles2
421
- }) => {
422
- return jsxRuntime.jsxs("linearGradient", {
423
- id: id2,
424
- x1: "5.5",
425
- y1: "5.5",
426
- x2: "12",
427
- y2: "5.5",
428
- gradientUnits: "userSpaceOnUse",
429
- children: [jsxRuntime.jsx("stop", {
430
- class: `${styles2 == null ? void 0 : styles2.previous} stop-color--${previous2}`
431
- }), jsxRuntime.jsx("stop", {
432
- class: `${styles2 == null ? void 0 : styles2.next} stop-color--${next2}`,
433
- offset: "1"
434
- })]
435
- }, id2);
436
- })
437
- })
438
- });
439
- }
440
348
  const unit = "_unit_mo5d9_1";
441
349
  const container$6 = "_container_mo5d9_6";
442
350
  const defaultStyles$s = {
@@ -485,7 +393,8 @@
485
393
  },
486
394
  onClick = () => {
487
395
  },
488
- styles: styles2
396
+ styles: styles2,
397
+ svgId
489
398
  }) => {
490
399
  const containerRef = hooks.useRef();
491
400
  const containerSize = useContainerSize(containerRef);
@@ -502,6 +411,7 @@
502
411
  children: containerSize && jsxRuntime.jsx("svg", {
503
412
  viewBox: `0 0 ${width} ${height}`,
504
413
  class: styles2.svg,
414
+ id: svgId,
505
415
  children: jsxRuntime.jsx("g", {
506
416
  children: units.map((unit2, j) => {
507
417
  let attributes;
@@ -1219,10 +1129,10 @@
1219
1129
  })
1220
1130
  });
1221
1131
  }
1222
- const button$4 = "_button_nr8bh_1";
1223
- const buttonBorder = "_buttonBorder_nr8bh_11";
1224
- const svg$3 = "_svg_nr8bh_19";
1225
- const path$3 = "_path_nr8bh_25";
1132
+ const button$4 = "_button_1bibm_1";
1133
+ const buttonBorder = "_buttonBorder_1bibm_14";
1134
+ const svg$3 = "_svg_1bibm_22";
1135
+ const path$3 = "_path_1bibm_29";
1226
1136
  const defaultStyles$h = {
1227
1137
  button: button$4,
1228
1138
  buttonBorder,
@@ -1242,11 +1152,12 @@
1242
1152
  className: styles2.svg,
1243
1153
  viewBox: "0 0 17 17",
1244
1154
  fill: "none",
1155
+ preserveAspectRatio: "xMidYMid meet",
1245
1156
  xmlns: "http://www.w3.org/2000/svg",
1246
1157
  children: jsxRuntime.jsx("path", {
1247
1158
  className: styles2.path,
1248
- "fill-rule": "evenodd",
1249
- "clip-rule": "evenodd",
1159
+ fillRule: "evenodd",
1160
+ clipRule: "evenodd",
1250
1161
  d: "M8.32497 10.025L15.5499 16.6499L16.6249 15.5749L10.025 8.32497L16.6249 1.075L15.5499 0L8.32497 6.62498L1.075 0.0249999L0 1.1L6.62498 8.32497L0 15.5499L1.075 16.6249L8.32497 10.025Z"
1251
1162
  })
1252
1163
  })
@@ -1464,6 +1375,7 @@
1464
1375
  children: table2.columns.map((column, index) => {
1465
1376
  var _a;
1466
1377
  return jsxRuntime.jsx("th", {
1378
+ scope: "col",
1467
1379
  className: mergeStyles(styles2.headerCell, (_a = column.styles) == null ? void 0 : _a.headerCell),
1468
1380
  children: jsxRuntime.jsx(HeaderCell, {
1469
1381
  styles: mergeStyles(styles2, column.styles),
@@ -1549,7 +1461,8 @@
1549
1461
  right: 24,
1550
1462
  top: 20,
1551
1463
  bottom: 20
1552
- }
1464
+ },
1465
+ svgId
1553
1466
  }) => {
1554
1467
  const wrapperRef = hooks.useRef(null);
1555
1468
  const containerSize = useContainerSize(wrapperRef);
@@ -1580,6 +1493,7 @@
1580
1493
  class: styles2.svg,
1581
1494
  width,
1582
1495
  height,
1496
+ id: svgId,
1583
1497
  children: jsxRuntime.jsxs("g", {
1584
1498
  transform: `translate(${padding.left} ${padding.top})`,
1585
1499
  children: [jsxRuntime.jsxs("g", {
@@ -1816,25 +1730,23 @@
1816
1730
  ...defaultStyles$c
1817
1731
  }, styles2);
1818
1732
  let hasChanged = next2 !== previous2;
1819
- return jsxRuntime.jsx("div", {
1733
+ return jsxRuntime.jsxs("div", {
1820
1734
  class: styles2.container,
1821
- children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
1822
- children: [hasChanged ? jsxRuntime.jsx(GradientIcon, {
1823
- previous: previous2,
1824
- next: next2,
1825
- styles: {
1826
- previous: styles2.previous,
1827
- next: styles2.next
1828
- }
1829
- }) : jsxRuntime.jsx(CircleIcon, {
1830
- styles: {
1831
- circle: `fill-color--${next2}`
1832
- }
1833
- }), jsxRuntime.jsx("strong", {
1834
- className: styles2.text,
1835
- children: text2
1836
- })]
1837
- })
1735
+ children: [hasChanged ? jsxRuntime.jsx(GradientIcon, {
1736
+ previous: previous2,
1737
+ next: next2,
1738
+ styles: {
1739
+ previous: styles2.previous,
1740
+ next: styles2.next
1741
+ }
1742
+ }) : jsxRuntime.jsx(CircleIcon, {
1743
+ styles: {
1744
+ circle: `fill-color--${next2}`
1745
+ }
1746
+ }), jsxRuntime.jsx("strong", {
1747
+ className: styles2.text,
1748
+ children: text2
1749
+ })]
1838
1750
  });
1839
1751
  };
1840
1752
  const wrapper = "_wrapper_8vo05_1";
@@ -2151,14 +2063,14 @@
2151
2063
  })
2152
2064
  });
2153
2065
  }
2154
- const searchContainer = "_searchContainer_116es_1";
2155
- const input = "_input_116es_5";
2156
- const searchIcon = "_searchIcon_116es_27";
2157
- const clearButton = "_clearButton_116es_36";
2158
- const suggestions = "_suggestions_116es_42";
2159
- const suggestion = "_suggestion_116es_42";
2160
- const selected$1 = "_selected_116es_68";
2161
- const highlighted = "_highlighted_116es_72";
2066
+ const searchContainer = "_searchContainer_1px2g_1";
2067
+ const input = "_input_1px2g_5";
2068
+ const searchIcon = "_searchIcon_1px2g_27";
2069
+ const clearButton = "_clearButton_1px2g_36";
2070
+ const suggestions = "_suggestions_1px2g_42";
2071
+ const suggestion = "_suggestion_1px2g_42";
2072
+ const selected$1 = "_selected_1px2g_68";
2073
+ const highlighted = "_highlighted_1px2g_72";
2162
2074
  const defaultStyles$5 = {
2163
2075
  searchContainer,
2164
2076
  input,
@@ -2415,13 +2327,13 @@
2415
2327
  return preact.cloneElement(t, { className: i });
2416
2328
  });
2417
2329
  };
2418
- const transitionContainer = "_transitionContainer_15ioc_1";
2419
- const blur = "_blur_15ioc_12";
2420
- const modalBox = "_modalBox_15ioc_17";
2421
- const enter = "_enter_15ioc_26";
2422
- const exitDone = "_exitDone_15ioc_27";
2423
- const enterActive = "_enterActive_15ioc_38";
2424
- const exit = "_exit_15ioc_27";
2330
+ const transitionContainer = "_transitionContainer_1syip_1";
2331
+ const blur = "_blur_1syip_12";
2332
+ const modalBox = "_modalBox_1syip_17";
2333
+ const enter = "_enter_1syip_26";
2334
+ const exitDone = "_exitDone_1syip_27";
2335
+ const enterActive = "_enterActive_1syip_38";
2336
+ const exitActive = "_exitActive_1syip_49";
2425
2337
  const styles$6 = {
2426
2338
  transitionContainer,
2427
2339
  blur,
@@ -2429,7 +2341,7 @@
2429
2341
  enter,
2430
2342
  exitDone,
2431
2343
  enterActive,
2432
- exit
2344
+ exitActive
2433
2345
  };
2434
2346
  function Modal({
2435
2347
  visible = false,
@@ -3867,7 +3779,7 @@
3867
3779
  const renderSVG = containerSize && !config.drawToCanvas;
3868
3780
  const zoomControl2 = organisedChildren.controls["ZoomControl"];
3869
3781
  const renderZoomControl = zoomControl2 && zoom.enabled;
3870
- return jsxRuntime.jsxs("div", {
3782
+ return jsxRuntime.jsxs("figure", {
3871
3783
  ref: containerRef,
3872
3784
  className: styles$4.container,
3873
3785
  style: containerStyle,
@@ -6376,7 +6288,7 @@
6376
6288
  map.setLayers(layers);
6377
6289
  }
6378
6290
  }, [map, layers]);
6379
- return jsxRuntime.jsx("div", {
6291
+ return jsxRuntime.jsx("figure", {
6380
6292
  ref: targetRef,
6381
6293
  className: styles$3.mapContainer,
6382
6294
  children: jsxRuntime.jsxs("div", {
@@ -6403,10 +6315,10 @@
6403
6315
  fill: "none",
6404
6316
  xmlns: "http://www.w3.org/2000/svg",
6405
6317
  children: jsxRuntime.jsx("path", {
6406
- "fill-rule": "evenodd",
6407
- "clip-rule": "evenodd",
6318
+ fillRule: "evenodd",
6319
+ clipRule: "evenodd",
6408
6320
  d: "M0 0.75V3.24999H21.9999V0.75H0Z",
6409
- fill: "#121212"
6321
+ fill: "var(--news-grey-01)"
6410
6322
  })
6411
6323
  });
6412
6324
  }
@@ -6418,10 +6330,10 @@
6418
6330
  fill: "none",
6419
6331
  xmlns: "http://www.w3.org/2000/svg",
6420
6332
  children: jsxRuntime.jsx("path", {
6421
- "fill-rule": "evenodd",
6422
- "clip-rule": "evenodd",
6333
+ fillRule: "evenodd",
6334
+ clipRule: "evenodd",
6423
6335
  d: "M9.79997 12.2L10.225 21.9999H11.75L12.2 12.2L21.9999 11.75V10.225L12.2 9.79997L11.75 0H10.225L9.79997 9.79997L0 10.225V11.75L9.79997 12.2Z",
6424
- fill: "#121212"
6336
+ fill: "var(--news-grey-01)"
6425
6337
  })
6426
6338
  });
6427
6339
  }
@@ -6435,8 +6347,8 @@
6435
6347
  fill: "none",
6436
6348
  xmlns: "http://www.w3.org/2000/svg",
6437
6349
  children: jsxRuntime.jsx("path", {
6438
- "fill-rule": "evenodd",
6439
- "clip-rule": "evenodd",
6350
+ fillRule: "evenodd",
6351
+ clipRule: "evenodd",
6440
6352
  d: "M32.107 33.107L26.5535 27.5535C24.7984 29.0775 22.5069 30 20 30L19.9916 30L19.9811 30C17.4476 30 15.1269 29.0482 13.3721 27.4882C11.3038 25.6561 10 22.9803 10 20H11.8C11.8 24.5287 15.4713 28.2 20 28.2C20.0567 28.2 20.1134 28.1994 20.1698 28.1983C24.5716 28.0965 28.1587 24.4465 28.1587 19.9772C28.1587 15.467 24.4685 11.7995 19.9811 11.7995C17.407 11.7995 15.1975 12.9385 13.6713 14.7608L16.9742 15.3075V16.4465L11.1428 16.4465L10.71 16.0137V10H11.8262L12.3956 13.4396C14.218 11.3212 16.9059 10 19.9811 10C25.5164 10 30.0039 14.4647 30.0039 19.9772C30.0039 21.8429 29.4982 23.5854 28.6171 25.0771C28.4764 25.3155 28.326 25.5474 28.1666 25.7725L33.8221 31.428C33.2844 32.0212 32.7116 32.5819 32.107 33.107Z",
6441
6353
  fill
6442
6354
  })
@@ -6481,7 +6393,7 @@
6481
6393
  onClick: _onReset,
6482
6394
  disabled: !resetEnabled,
6483
6395
  children: jsxRuntime.jsx(IconReset, {
6484
- fill: resetEnabled ? "var(--primary-text-color)" : "var(--news-grey-02)"
6396
+ fill: resetEnabled ? "var(--primary-text-color)" : "var(--news-grey-03)"
6485
6397
  })
6486
6398
  })]
6487
6399
  });
@@ -7551,7 +7463,7 @@
7551
7463
  position: "relative",
7552
7464
  zIndex: 2
7553
7465
  },
7554
- children: [jsxRuntime.jsx("h4", {
7466
+ children: [jsxRuntime.jsx("h3", {
7555
7467
  className: styles2.title,
7556
7468
  children: list.title
7557
7469
  }), jsxRuntime.jsx("p", {