@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,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
|
|
2
|
-
import { useRef, useMemo,
|
|
3
|
-
import {
|
|
4
|
-
import { useSyncExternalStore, forwardRef, createPortal } from "preact/compat";
|
|
2
|
+
import { useRef, useMemo, useId, useState, useLayoutEffect, useEffect, useCallback, useContext, useImperativeHandle } from "preact/hooks";
|
|
3
|
+
import { forwardRef, createPortal } from "preact/compat";
|
|
5
4
|
import { scaleLinear as scaleLinear$1 } from "d3-scale";
|
|
5
|
+
import { toChildArray, createElement, cloneElement, createContext } from "preact";
|
|
6
6
|
import { geoStream, geoAlbers, geoPath, geoContains, geoMercator } from "d3-geo";
|
|
7
7
|
import { zoomIdentity, zoom, ZoomTransform } from "d3-zoom";
|
|
8
8
|
import { namespace, matcher, selector, selectorAll, selection, style, select } from "d3-selection";
|
|
@@ -306,60 +306,6 @@ function StackedBar({
|
|
|
306
306
|
children: [content2, labelType === LabelType.hanging && !hideLabels && hangingLabelConfig.map((config, i) => renderLabel(config, i))]
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
|
-
function shouldUpdate(oldState, newState) {
|
|
310
|
-
if (oldState === newState)
|
|
311
|
-
return false;
|
|
312
|
-
if (isObj(oldState) && isObj(newState)) {
|
|
313
|
-
for (let key in newState) {
|
|
314
|
-
if (oldState[key] !== newState[key])
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
return true;
|
|
320
|
-
}
|
|
321
|
-
function isObj(obj) {
|
|
322
|
-
return typeof obj === "object" && !Array.isArray(obj) && obj !== null;
|
|
323
|
-
}
|
|
324
|
-
function createStore(initialStore) {
|
|
325
|
-
let store = initialStore;
|
|
326
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
327
|
-
function useStore(selectorFn = (store2) => store2) {
|
|
328
|
-
const subscribe = useCallback((updater) => {
|
|
329
|
-
const listener = {
|
|
330
|
-
updater,
|
|
331
|
-
selectorFn
|
|
332
|
-
};
|
|
333
|
-
listeners.add(listener);
|
|
334
|
-
return () => {
|
|
335
|
-
listeners.delete(listener);
|
|
336
|
-
};
|
|
337
|
-
}, [selectorFn]);
|
|
338
|
-
const syncedStore = useSyncExternalStore(subscribe, getStore, getServerStore);
|
|
339
|
-
return selectorFn(syncedStore);
|
|
340
|
-
}
|
|
341
|
-
function setStore(action) {
|
|
342
|
-
const oldStore = store;
|
|
343
|
-
store = action instanceof Function ? action(store) : action;
|
|
344
|
-
listeners.forEach(({
|
|
345
|
-
selectorFn,
|
|
346
|
-
updater
|
|
347
|
-
}) => {
|
|
348
|
-
const oldState = selectorFn(oldStore);
|
|
349
|
-
const newState = selectorFn(store);
|
|
350
|
-
if (shouldUpdate(oldState, newState))
|
|
351
|
-
updater(() => newState);
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
function getStore() {
|
|
355
|
-
return store;
|
|
356
|
-
}
|
|
357
|
-
function getServerStore() {
|
|
358
|
-
return initialStore;
|
|
359
|
-
}
|
|
360
|
-
return [useStore, setStore, getStore];
|
|
361
|
-
}
|
|
362
|
-
const [useGradients, setGradients, getGradients] = createStore({});
|
|
363
309
|
const svg$8 = "_svg_1cajk_6";
|
|
364
310
|
const previous = "_previous_1cajk_12";
|
|
365
311
|
const next = "_next_1cajk_16";
|
|
@@ -375,72 +321,34 @@ const GradientIcon = (props) => {
|
|
|
375
321
|
styles: styles2
|
|
376
322
|
} = props;
|
|
377
323
|
styles2 = mergeStyles(defaultStyles$t, styles2);
|
|
378
|
-
const gradientId =
|
|
379
|
-
|
|
380
|
-
useEffect(() => {
|
|
381
|
-
setGradients((current) => {
|
|
382
|
-
current[gradientId] = {
|
|
383
|
-
id: gradientId,
|
|
384
|
-
...props
|
|
385
|
-
};
|
|
386
|
-
return current;
|
|
387
|
-
});
|
|
388
|
-
}, [gradientId, props]);
|
|
389
|
-
useEffect(() => {
|
|
390
|
-
let container2 = document.getElementById("gv-gradient-defs");
|
|
391
|
-
if (!container2) {
|
|
392
|
-
container2 = document.createElement("div");
|
|
393
|
-
container2.id = "gv-gradient-defs";
|
|
394
|
-
document.body.prepend(container2);
|
|
395
|
-
}
|
|
396
|
-
render(jsx(GradientDefs, {
|
|
397
|
-
gradients: Object.values(gradients)
|
|
398
|
-
}), container2);
|
|
399
|
-
}, [gradients]);
|
|
400
|
-
return jsx("svg", {
|
|
324
|
+
const gradientId = useId();
|
|
325
|
+
return jsxs("svg", {
|
|
401
326
|
class: styles2.svg,
|
|
402
327
|
width: "24",
|
|
403
328
|
height: "11",
|
|
404
329
|
viewBox: "0 0 24 11",
|
|
405
330
|
xmlns: "http://www.w3.org/2000/svg",
|
|
406
|
-
children: jsx("
|
|
331
|
+
children: [jsx("defs", {
|
|
332
|
+
children: jsxs("linearGradient", {
|
|
333
|
+
id: gradientId,
|
|
334
|
+
x1: "5.5",
|
|
335
|
+
y1: "5.5",
|
|
336
|
+
x2: "12",
|
|
337
|
+
y2: "5.5",
|
|
338
|
+
gradientUnits: "userSpaceOnUse",
|
|
339
|
+
children: [jsx("stop", {
|
|
340
|
+
class: `${styles2 == null ? void 0 : styles2.previous} stop-color--${previous2}`
|
|
341
|
+
}), jsx("stop", {
|
|
342
|
+
class: `${styles2 == null ? void 0 : styles2.next} stop-color--${next2}`,
|
|
343
|
+
offset: "1"
|
|
344
|
+
})]
|
|
345
|
+
})
|
|
346
|
+
}), jsx("path", {
|
|
407
347
|
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",
|
|
408
348
|
fill: `url(#${gradientId})`
|
|
409
|
-
})
|
|
349
|
+
})]
|
|
410
350
|
});
|
|
411
351
|
};
|
|
412
|
-
function GradientDefs({
|
|
413
|
-
gradients
|
|
414
|
-
}) {
|
|
415
|
-
return jsx("svg", {
|
|
416
|
-
width: "24",
|
|
417
|
-
height: "11",
|
|
418
|
-
viewBox: "0 0 24 11",
|
|
419
|
-
children: jsx("defs", {
|
|
420
|
-
children: gradients.map(({
|
|
421
|
-
id: id2,
|
|
422
|
-
previous: previous2,
|
|
423
|
-
next: next2,
|
|
424
|
-
styles: styles2
|
|
425
|
-
}) => {
|
|
426
|
-
return jsxs("linearGradient", {
|
|
427
|
-
id: id2,
|
|
428
|
-
x1: "5.5",
|
|
429
|
-
y1: "5.5",
|
|
430
|
-
x2: "12",
|
|
431
|
-
y2: "5.5",
|
|
432
|
-
gradientUnits: "userSpaceOnUse",
|
|
433
|
-
children: [jsx("stop", {
|
|
434
|
-
class: `${styles2 == null ? void 0 : styles2.previous} stop-color--${previous2}`
|
|
435
|
-
}), jsx("stop", {
|
|
436
|
-
class: `${styles2 == null ? void 0 : styles2.next} stop-color--${next2}`,
|
|
437
|
-
offset: "1"
|
|
438
|
-
})]
|
|
439
|
-
}, id2);
|
|
440
|
-
})
|
|
441
|
-
})
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
352
|
const unit = "_unit_mo5d9_1";
|
|
445
353
|
const container$6 = "_container_mo5d9_6";
|
|
446
354
|
const defaultStyles$s = {
|
|
@@ -489,7 +397,8 @@ const Waffle = ({
|
|
|
489
397
|
},
|
|
490
398
|
onClick = () => {
|
|
491
399
|
},
|
|
492
|
-
styles: styles2
|
|
400
|
+
styles: styles2,
|
|
401
|
+
svgId
|
|
493
402
|
}) => {
|
|
494
403
|
const containerRef = useRef();
|
|
495
404
|
const containerSize = useContainerSize(containerRef);
|
|
@@ -506,6 +415,7 @@ const Waffle = ({
|
|
|
506
415
|
children: containerSize && jsx("svg", {
|
|
507
416
|
viewBox: `0 0 ${width} ${height}`,
|
|
508
417
|
class: styles2.svg,
|
|
418
|
+
id: svgId,
|
|
509
419
|
children: jsx("g", {
|
|
510
420
|
children: units.map((unit2, j) => {
|
|
511
421
|
let attributes;
|
|
@@ -1223,10 +1133,10 @@ function Button({
|
|
|
1223
1133
|
})
|
|
1224
1134
|
});
|
|
1225
1135
|
}
|
|
1226
|
-
const button$4 = "
|
|
1227
|
-
const buttonBorder = "
|
|
1228
|
-
const svg$3 = "
|
|
1229
|
-
const path$3 = "
|
|
1136
|
+
const button$4 = "_button_1bibm_1";
|
|
1137
|
+
const buttonBorder = "_buttonBorder_1bibm_14";
|
|
1138
|
+
const svg$3 = "_svg_1bibm_22";
|
|
1139
|
+
const path$3 = "_path_1bibm_29";
|
|
1230
1140
|
const defaultStyles$h = {
|
|
1231
1141
|
button: button$4,
|
|
1232
1142
|
buttonBorder,
|
|
@@ -1246,11 +1156,12 @@ function CloseButton({
|
|
|
1246
1156
|
className: styles2.svg,
|
|
1247
1157
|
viewBox: "0 0 17 17",
|
|
1248
1158
|
fill: "none",
|
|
1159
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
1249
1160
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1250
1161
|
children: jsx("path", {
|
|
1251
1162
|
className: styles2.path,
|
|
1252
|
-
|
|
1253
|
-
|
|
1163
|
+
fillRule: "evenodd",
|
|
1164
|
+
clipRule: "evenodd",
|
|
1254
1165
|
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"
|
|
1255
1166
|
})
|
|
1256
1167
|
})
|
|
@@ -1468,6 +1379,7 @@ function Table({
|
|
|
1468
1379
|
children: table2.columns.map((column, index) => {
|
|
1469
1380
|
var _a;
|
|
1470
1381
|
return jsx("th", {
|
|
1382
|
+
scope: "col",
|
|
1471
1383
|
className: mergeStyles(styles2.headerCell, (_a = column.styles) == null ? void 0 : _a.headerCell),
|
|
1472
1384
|
children: jsx(HeaderCell, {
|
|
1473
1385
|
styles: mergeStyles(styles2, column.styles),
|
|
@@ -1553,7 +1465,8 @@ const SlopeChart = ({
|
|
|
1553
1465
|
right: 24,
|
|
1554
1466
|
top: 20,
|
|
1555
1467
|
bottom: 20
|
|
1556
|
-
}
|
|
1468
|
+
},
|
|
1469
|
+
svgId
|
|
1557
1470
|
}) => {
|
|
1558
1471
|
const wrapperRef = useRef(null);
|
|
1559
1472
|
const containerSize = useContainerSize(wrapperRef);
|
|
@@ -1584,6 +1497,7 @@ const SlopeChart = ({
|
|
|
1584
1497
|
class: styles2.svg,
|
|
1585
1498
|
width,
|
|
1586
1499
|
height,
|
|
1500
|
+
id: svgId,
|
|
1587
1501
|
children: jsxs("g", {
|
|
1588
1502
|
transform: `translate(${padding.left} ${padding.top})`,
|
|
1589
1503
|
children: [jsxs("g", {
|
|
@@ -1820,25 +1734,23 @@ const ControlChange = ({
|
|
|
1820
1734
|
...defaultStyles$c
|
|
1821
1735
|
}, styles2);
|
|
1822
1736
|
let hasChanged = next2 !== previous2;
|
|
1823
|
-
return
|
|
1737
|
+
return jsxs("div", {
|
|
1824
1738
|
class: styles2.container,
|
|
1825
|
-
children:
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
})]
|
|
1841
|
-
})
|
|
1739
|
+
children: [hasChanged ? jsx(GradientIcon, {
|
|
1740
|
+
previous: previous2,
|
|
1741
|
+
next: next2,
|
|
1742
|
+
styles: {
|
|
1743
|
+
previous: styles2.previous,
|
|
1744
|
+
next: styles2.next
|
|
1745
|
+
}
|
|
1746
|
+
}) : jsx(CircleIcon, {
|
|
1747
|
+
styles: {
|
|
1748
|
+
circle: `fill-color--${next2}`
|
|
1749
|
+
}
|
|
1750
|
+
}), jsx("strong", {
|
|
1751
|
+
className: styles2.text,
|
|
1752
|
+
children: text2
|
|
1753
|
+
})]
|
|
1842
1754
|
});
|
|
1843
1755
|
};
|
|
1844
1756
|
const wrapper = "_wrapper_8vo05_1";
|
|
@@ -2155,14 +2067,14 @@ function SearchIcon() {
|
|
|
2155
2067
|
})
|
|
2156
2068
|
});
|
|
2157
2069
|
}
|
|
2158
|
-
const searchContainer = "
|
|
2159
|
-
const input = "
|
|
2160
|
-
const searchIcon = "
|
|
2161
|
-
const clearButton = "
|
|
2162
|
-
const suggestions = "
|
|
2163
|
-
const suggestion = "
|
|
2164
|
-
const selected$1 = "
|
|
2165
|
-
const highlighted = "
|
|
2070
|
+
const searchContainer = "_searchContainer_1px2g_1";
|
|
2071
|
+
const input = "_input_1px2g_5";
|
|
2072
|
+
const searchIcon = "_searchIcon_1px2g_27";
|
|
2073
|
+
const clearButton = "_clearButton_1px2g_36";
|
|
2074
|
+
const suggestions = "_suggestions_1px2g_42";
|
|
2075
|
+
const suggestion = "_suggestion_1px2g_42";
|
|
2076
|
+
const selected$1 = "_selected_1px2g_68";
|
|
2077
|
+
const highlighted = "_highlighted_1px2g_72";
|
|
2166
2078
|
const defaultStyles$5 = {
|
|
2167
2079
|
searchContainer,
|
|
2168
2080
|
input,
|
|
@@ -2419,13 +2331,13 @@ var d = (E) => {
|
|
|
2419
2331
|
return cloneElement(t, { className: i });
|
|
2420
2332
|
});
|
|
2421
2333
|
};
|
|
2422
|
-
const transitionContainer = "
|
|
2423
|
-
const blur = "
|
|
2424
|
-
const modalBox = "
|
|
2425
|
-
const enter = "
|
|
2426
|
-
const exitDone = "
|
|
2427
|
-
const enterActive = "
|
|
2428
|
-
const
|
|
2334
|
+
const transitionContainer = "_transitionContainer_1syip_1";
|
|
2335
|
+
const blur = "_blur_1syip_12";
|
|
2336
|
+
const modalBox = "_modalBox_1syip_17";
|
|
2337
|
+
const enter = "_enter_1syip_26";
|
|
2338
|
+
const exitDone = "_exitDone_1syip_27";
|
|
2339
|
+
const enterActive = "_enterActive_1syip_38";
|
|
2340
|
+
const exitActive = "_exitActive_1syip_49";
|
|
2429
2341
|
const styles$6 = {
|
|
2430
2342
|
transitionContainer,
|
|
2431
2343
|
blur,
|
|
@@ -2433,7 +2345,7 @@ const styles$6 = {
|
|
|
2433
2345
|
enter,
|
|
2434
2346
|
exitDone,
|
|
2435
2347
|
enterActive,
|
|
2436
|
-
|
|
2348
|
+
exitActive
|
|
2437
2349
|
};
|
|
2438
2350
|
function Modal({
|
|
2439
2351
|
visible = false,
|
|
@@ -3871,7 +3783,7 @@ const SVGMap = forwardRef(({
|
|
|
3871
3783
|
const renderSVG = containerSize && !config.drawToCanvas;
|
|
3872
3784
|
const zoomControl2 = organisedChildren.controls["ZoomControl"];
|
|
3873
3785
|
const renderZoomControl = zoomControl2 && zoom2.enabled;
|
|
3874
|
-
return jsxs("
|
|
3786
|
+
return jsxs("figure", {
|
|
3875
3787
|
ref: containerRef,
|
|
3876
3788
|
className: styles$4.container,
|
|
3877
3789
|
style: containerStyle,
|
|
@@ -6380,7 +6292,7 @@ const Map$1 = forwardRef(({
|
|
|
6380
6292
|
map.setLayers(layers);
|
|
6381
6293
|
}
|
|
6382
6294
|
}, [map, layers]);
|
|
6383
|
-
return jsx("
|
|
6295
|
+
return jsx("figure", {
|
|
6384
6296
|
ref: targetRef,
|
|
6385
6297
|
className: styles$3.mapContainer,
|
|
6386
6298
|
children: jsxs("div", {
|
|
@@ -6407,10 +6319,10 @@ function IconMinus() {
|
|
|
6407
6319
|
fill: "none",
|
|
6408
6320
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6409
6321
|
children: jsx("path", {
|
|
6410
|
-
|
|
6411
|
-
|
|
6322
|
+
fillRule: "evenodd",
|
|
6323
|
+
clipRule: "evenodd",
|
|
6412
6324
|
d: "M0 0.75V3.24999H21.9999V0.75H0Z",
|
|
6413
|
-
fill: "
|
|
6325
|
+
fill: "var(--news-grey-01)"
|
|
6414
6326
|
})
|
|
6415
6327
|
});
|
|
6416
6328
|
}
|
|
@@ -6422,10 +6334,10 @@ function IconPlus() {
|
|
|
6422
6334
|
fill: "none",
|
|
6423
6335
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6424
6336
|
children: jsx("path", {
|
|
6425
|
-
|
|
6426
|
-
|
|
6337
|
+
fillRule: "evenodd",
|
|
6338
|
+
clipRule: "evenodd",
|
|
6427
6339
|
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",
|
|
6428
|
-
fill: "
|
|
6340
|
+
fill: "var(--news-grey-01)"
|
|
6429
6341
|
})
|
|
6430
6342
|
});
|
|
6431
6343
|
}
|
|
@@ -6439,8 +6351,8 @@ function IconReset({
|
|
|
6439
6351
|
fill: "none",
|
|
6440
6352
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6441
6353
|
children: jsx("path", {
|
|
6442
|
-
|
|
6443
|
-
|
|
6354
|
+
fillRule: "evenodd",
|
|
6355
|
+
clipRule: "evenodd",
|
|
6444
6356
|
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",
|
|
6445
6357
|
fill
|
|
6446
6358
|
})
|
|
@@ -6485,7 +6397,7 @@ function ZoomControl({
|
|
|
6485
6397
|
onClick: _onReset,
|
|
6486
6398
|
disabled: !resetEnabled,
|
|
6487
6399
|
children: jsx(IconReset, {
|
|
6488
|
-
fill: resetEnabled ? "var(--primary-text-color)" : "var(--news-grey-
|
|
6400
|
+
fill: resetEnabled ? "var(--primary-text-color)" : "var(--news-grey-03)"
|
|
6489
6401
|
})
|
|
6490
6402
|
})]
|
|
6491
6403
|
});
|
|
@@ -7555,7 +7467,7 @@ function CoalitionsTracker({
|
|
|
7555
7467
|
position: "relative",
|
|
7556
7468
|
zIndex: 2
|
|
7557
7469
|
},
|
|
7558
|
-
children: [jsx("
|
|
7470
|
+
children: [jsx("h3", {
|
|
7559
7471
|
className: styles2.title,
|
|
7560
7472
|
children: list.title
|
|
7561
7473
|
}), jsx("p", {
|