@guardian/interactive-component-library 0.1.0-alpha.35 → 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 = {
|
|
@@ -1225,10 +1133,10 @@ function Button({
|
|
|
1225
1133
|
})
|
|
1226
1134
|
});
|
|
1227
1135
|
}
|
|
1228
|
-
const button$4 = "
|
|
1229
|
-
const buttonBorder = "
|
|
1230
|
-
const svg$3 = "
|
|
1231
|
-
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";
|
|
1232
1140
|
const defaultStyles$h = {
|
|
1233
1141
|
button: button$4,
|
|
1234
1142
|
buttonBorder,
|
|
@@ -1248,11 +1156,12 @@ function CloseButton({
|
|
|
1248
1156
|
className: styles2.svg,
|
|
1249
1157
|
viewBox: "0 0 17 17",
|
|
1250
1158
|
fill: "none",
|
|
1159
|
+
preserveAspectRatio: "xMidYMid meet",
|
|
1251
1160
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1252
1161
|
children: jsx("path", {
|
|
1253
1162
|
className: styles2.path,
|
|
1254
|
-
|
|
1255
|
-
|
|
1163
|
+
fillRule: "evenodd",
|
|
1164
|
+
clipRule: "evenodd",
|
|
1256
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"
|
|
1257
1166
|
})
|
|
1258
1167
|
})
|
|
@@ -1825,25 +1734,23 @@ const ControlChange = ({
|
|
|
1825
1734
|
...defaultStyles$c
|
|
1826
1735
|
}, styles2);
|
|
1827
1736
|
let hasChanged = next2 !== previous2;
|
|
1828
|
-
return
|
|
1737
|
+
return jsxs("div", {
|
|
1829
1738
|
class: styles2.container,
|
|
1830
|
-
children:
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
})]
|
|
1846
|
-
})
|
|
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
|
+
})]
|
|
1847
1754
|
});
|
|
1848
1755
|
};
|
|
1849
1756
|
const wrapper = "_wrapper_8vo05_1";
|
|
@@ -2160,14 +2067,14 @@ function SearchIcon() {
|
|
|
2160
2067
|
})
|
|
2161
2068
|
});
|
|
2162
2069
|
}
|
|
2163
|
-
const searchContainer = "
|
|
2164
|
-
const input = "
|
|
2165
|
-
const searchIcon = "
|
|
2166
|
-
const clearButton = "
|
|
2167
|
-
const suggestions = "
|
|
2168
|
-
const suggestion = "
|
|
2169
|
-
const selected$1 = "
|
|
2170
|
-
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";
|
|
2171
2078
|
const defaultStyles$5 = {
|
|
2172
2079
|
searchContainer,
|
|
2173
2080
|
input,
|
|
@@ -6412,10 +6319,10 @@ function IconMinus() {
|
|
|
6412
6319
|
fill: "none",
|
|
6413
6320
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6414
6321
|
children: jsx("path", {
|
|
6415
|
-
|
|
6416
|
-
|
|
6322
|
+
fillRule: "evenodd",
|
|
6323
|
+
clipRule: "evenodd",
|
|
6417
6324
|
d: "M0 0.75V3.24999H21.9999V0.75H0Z",
|
|
6418
|
-
fill: "
|
|
6325
|
+
fill: "var(--news-grey-01)"
|
|
6419
6326
|
})
|
|
6420
6327
|
});
|
|
6421
6328
|
}
|
|
@@ -6427,10 +6334,10 @@ function IconPlus() {
|
|
|
6427
6334
|
fill: "none",
|
|
6428
6335
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6429
6336
|
children: jsx("path", {
|
|
6430
|
-
|
|
6431
|
-
|
|
6337
|
+
fillRule: "evenodd",
|
|
6338
|
+
clipRule: "evenodd",
|
|
6432
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",
|
|
6433
|
-
fill: "
|
|
6340
|
+
fill: "var(--news-grey-01)"
|
|
6434
6341
|
})
|
|
6435
6342
|
});
|
|
6436
6343
|
}
|
|
@@ -6444,8 +6351,8 @@ function IconReset({
|
|
|
6444
6351
|
fill: "none",
|
|
6445
6352
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6446
6353
|
children: jsx("path", {
|
|
6447
|
-
|
|
6448
|
-
|
|
6354
|
+
fillRule: "evenodd",
|
|
6355
|
+
clipRule: "evenodd",
|
|
6449
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",
|
|
6450
6357
|
fill
|
|
6451
6358
|
})
|
|
@@ -6490,7 +6397,7 @@ function ZoomControl({
|
|
|
6490
6397
|
onClick: _onReset,
|
|
6491
6398
|
disabled: !resetEnabled,
|
|
6492
6399
|
children: jsx(IconReset, {
|
|
6493
|
-
fill: resetEnabled ? "var(--primary-text-color)" : "var(--news-grey-
|
|
6400
|
+
fill: resetEnabled ? "var(--primary-text-color)" : "var(--news-grey-03)"
|
|
6494
6401
|
})
|
|
6495
6402
|
})]
|
|
6496
6403
|
});
|