@guardian/interactive-component-library 0.1.0-alpha.32 → 0.1.0-alpha.34
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.
|
@@ -485,7 +485,10 @@ const Waffle = ({
|
|
|
485
485
|
numberOfRows,
|
|
486
486
|
type = WaffleType.circle,
|
|
487
487
|
idAccessor,
|
|
488
|
-
onMouseOver
|
|
488
|
+
onMouseOver = () => {
|
|
489
|
+
},
|
|
490
|
+
onClick = () => {
|
|
491
|
+
},
|
|
489
492
|
styles: styles2
|
|
490
493
|
}) => {
|
|
491
494
|
const containerRef = useRef();
|
|
@@ -510,6 +513,7 @@ const Waffle = ({
|
|
|
510
513
|
attributes = {
|
|
511
514
|
id: unit2[idAccessor] || `w-${j}`,
|
|
512
515
|
onMouseOver: (e) => onMouseOver(unit2, e),
|
|
516
|
+
onClick: (e) => onClick(unit2, e),
|
|
513
517
|
class: `${styles2.unit} ${unit2.class}`,
|
|
514
518
|
height: unitHeight,
|
|
515
519
|
width: unitWidth,
|
|
@@ -520,6 +524,7 @@ const Waffle = ({
|
|
|
520
524
|
attributes = {
|
|
521
525
|
id: unit2[idAccessor] || `w-${j}`,
|
|
522
526
|
onMouseOver: (e) => onMouseOver(unit2, e),
|
|
527
|
+
onClick: (e) => onClick(unit2, e),
|
|
523
528
|
class: `${styles2.unit} ${unit2.class}`,
|
|
524
529
|
r: unitWidth / 2,
|
|
525
530
|
transform: `translate(${unitWidth * Math.floor(j / numberOfRows) + unitWidth / 2}, ${unitHeight * (j % numberOfRows) + unitHeight / 2})`
|
|
@@ -1943,11 +1948,11 @@ const ToplineResult = forwardRef(({
|
|
|
1943
1948
|
})]
|
|
1944
1949
|
});
|
|
1945
1950
|
});
|
|
1946
|
-
const borderTop = "
|
|
1947
|
-
const section = "
|
|
1948
|
-
const fullWidth = "
|
|
1949
|
-
const header = "
|
|
1950
|
-
const content = "
|
|
1951
|
+
const borderTop = "_borderTop_1yz7f_9";
|
|
1952
|
+
const section = "_section_1yz7f_14";
|
|
1953
|
+
const fullWidth = "_fullWidth_1yz7f_57";
|
|
1954
|
+
const header = "_header_1yz7f_96";
|
|
1955
|
+
const content = "_content_1yz7f_133";
|
|
1951
1956
|
const defaultStyles$9 = {
|
|
1952
1957
|
borderTop,
|
|
1953
1958
|
section,
|
|
@@ -2414,14 +2419,16 @@ var d = (E) => {
|
|
|
2414
2419
|
return cloneElement(t, { className: i });
|
|
2415
2420
|
});
|
|
2416
2421
|
};
|
|
2417
|
-
const transitionContainer = "
|
|
2418
|
-
const
|
|
2419
|
-
const
|
|
2420
|
-
const
|
|
2421
|
-
const
|
|
2422
|
-
const
|
|
2422
|
+
const transitionContainer = "_transitionContainer_15ioc_1";
|
|
2423
|
+
const blur = "_blur_15ioc_12";
|
|
2424
|
+
const modalBox = "_modalBox_15ioc_17";
|
|
2425
|
+
const enter = "_enter_15ioc_26";
|
|
2426
|
+
const exitDone = "_exitDone_15ioc_27";
|
|
2427
|
+
const enterActive = "_enterActive_15ioc_38";
|
|
2428
|
+
const exit = "_exit_15ioc_27";
|
|
2423
2429
|
const styles$6 = {
|
|
2424
2430
|
transitionContainer,
|
|
2431
|
+
blur,
|
|
2425
2432
|
modalBox,
|
|
2426
2433
|
enter,
|
|
2427
2434
|
exitDone,
|
|
@@ -2430,6 +2437,7 @@ const styles$6 = {
|
|
|
2430
2437
|
};
|
|
2431
2438
|
function Modal({
|
|
2432
2439
|
visible = false,
|
|
2440
|
+
blurBackground = true,
|
|
2433
2441
|
children,
|
|
2434
2442
|
onClickOutside
|
|
2435
2443
|
}) {
|
|
@@ -2459,11 +2467,8 @@ function Modal({
|
|
|
2459
2467
|
duration: 300,
|
|
2460
2468
|
classNames: styles$6,
|
|
2461
2469
|
children: jsx("div", {
|
|
2462
|
-
|
|
2470
|
+
className: [styles$6.transitionContainer, blurBackground && styles$6.blur, visible && styles$6.visible].join(" "),
|
|
2463
2471
|
onClick,
|
|
2464
|
-
style: {
|
|
2465
|
-
pointerEvents: visible ? "auto" : "none"
|
|
2466
|
-
},
|
|
2467
2472
|
children: jsx("div", {
|
|
2468
2473
|
ref: modalBoxRef,
|
|
2469
2474
|
class: styles$6.modalBox,
|
|
@@ -4443,7 +4448,7 @@ class MapRenderer {
|
|
|
4443
4448
|
constructor(map) {
|
|
4444
4449
|
this.map = map;
|
|
4445
4450
|
this._element = document.createElement("div");
|
|
4446
|
-
this._element.className = "gv-
|
|
4451
|
+
this._element.className = "gv-layer-container";
|
|
4447
4452
|
const style2 = this._element.style;
|
|
4448
4453
|
style2.position = "absolute";
|
|
4449
4454
|
style2.width = "100%";
|
|
@@ -5949,6 +5954,7 @@ let Map$2 = class Map2 {
|
|
|
5949
5954
|
this.layers = [];
|
|
5950
5955
|
this.dispatcher = new Dispatcher(this);
|
|
5951
5956
|
this._viewport = document.createElement("div");
|
|
5957
|
+
this._viewport.className = "gv-map";
|
|
5952
5958
|
this._viewport.style.position = "relative";
|
|
5953
5959
|
this._viewport.style.overflow = "hidden";
|
|
5954
5960
|
this._viewport.style.top = 0;
|
|
@@ -5962,13 +5968,19 @@ let Map$2 = class Map2 {
|
|
|
5962
5968
|
this.view.transform = zoomIdentity;
|
|
5963
5969
|
this._zoomBypassKey = navigator.userAgent.indexOf("Mac") !== -1 ? "metaKey" : "ctrlKey";
|
|
5964
5970
|
this._zoomBehaviour = zoom().scaleExtent(this.view.scaleExtent).filter((event) => {
|
|
5971
|
+
const filterEvent = (filter) => {
|
|
5972
|
+
this._filterEventCallback(filter);
|
|
5973
|
+
return !filter;
|
|
5974
|
+
};
|
|
5965
5975
|
if (event.type === "wheel" && !event[this._zoomBypassKey]) {
|
|
5966
|
-
|
|
5967
|
-
return false;
|
|
5976
|
+
return filterEvent(true);
|
|
5968
5977
|
}
|
|
5969
|
-
if ("targetTouches" in event
|
|
5970
|
-
|
|
5971
|
-
|
|
5978
|
+
if ("targetTouches" in event) {
|
|
5979
|
+
if (event.targetTouches.length < 2) {
|
|
5980
|
+
return false;
|
|
5981
|
+
}
|
|
5982
|
+
event.preventDefault();
|
|
5983
|
+
return filterEvent(false);
|
|
5972
5984
|
}
|
|
5973
5985
|
return (!event.ctrlKey || event.type === "wheel") && !event.button;
|
|
5974
5986
|
}).on("zoom", (event) => {
|
|
@@ -5979,6 +5991,15 @@ let Map$2 = class Map2 {
|
|
|
5979
5991
|
});
|
|
5980
5992
|
});
|
|
5981
5993
|
select(this._viewport).call(this._zoomBehaviour);
|
|
5994
|
+
this._viewport.addEventListener("touchmove", (event) => {
|
|
5995
|
+
if (event.targetTouches.length < 2) {
|
|
5996
|
+
this._filterEventCallback(true);
|
|
5997
|
+
}
|
|
5998
|
+
});
|
|
5999
|
+
}
|
|
6000
|
+
destroy() {
|
|
6001
|
+
this._resizeObserver.disconnect();
|
|
6002
|
+
this._viewport.remove();
|
|
5982
6003
|
}
|
|
5983
6004
|
/** PUBLIC GETTERS */
|
|
5984
6005
|
get size() {
|
|
@@ -5994,9 +6015,6 @@ let Map$2 = class Map2 {
|
|
|
5994
6015
|
onFilterEvent(callback) {
|
|
5995
6016
|
this._filterEventCallback = callback;
|
|
5996
6017
|
}
|
|
5997
|
-
onZoomEvent(callback) {
|
|
5998
|
-
this._onZoomEventCallback = callback;
|
|
5999
|
-
}
|
|
6000
6018
|
fitObject(geoJSON) {
|
|
6001
6019
|
this.view.fitObject(geoJSON);
|
|
6002
6020
|
this._requestRender();
|
|
@@ -6017,7 +6035,7 @@ let Map$2 = class Map2 {
|
|
|
6017
6035
|
if (layers === this.layers) {
|
|
6018
6036
|
return;
|
|
6019
6037
|
}
|
|
6020
|
-
|
|
6038
|
+
new Array(...this.layers).forEach((layer) => {
|
|
6021
6039
|
if (!layers.includes(layer)) {
|
|
6022
6040
|
this.removeLayer(layer);
|
|
6023
6041
|
}
|
|
@@ -6043,11 +6061,32 @@ let Map$2 = class Map2 {
|
|
|
6043
6061
|
}) {
|
|
6044
6062
|
return select(this._viewport).transition().duration(options.duration).call(this._zoomBehaviour.scaleTo, zoomLevel).end();
|
|
6045
6063
|
}
|
|
6046
|
-
zoomToFeature(feature, focalPoint
|
|
6064
|
+
zoomToFeature(feature, focalPoint, padding = {
|
|
6065
|
+
top: 40,
|
|
6066
|
+
right: 40,
|
|
6067
|
+
bottom: 40,
|
|
6068
|
+
left: 40
|
|
6069
|
+
}) {
|
|
6047
6070
|
const extent = feature.getExtent();
|
|
6048
|
-
const [[
|
|
6049
|
-
const
|
|
6050
|
-
const
|
|
6071
|
+
const [[featureX, featureY], [featureWidth, featureHeight]] = this.view.boundsForExtent(extent);
|
|
6072
|
+
const [viewPortWidth, viewPortHeight] = this.view.viewPortSize;
|
|
6073
|
+
const paddedViewPortWidth = viewPortWidth - padding.left - padding.right;
|
|
6074
|
+
const paddedViewPortHeight = viewPortHeight - padding.top - padding.bottom;
|
|
6075
|
+
const featureScale = Math.min(paddedViewPortWidth / featureWidth, paddedViewPortHeight / featureHeight);
|
|
6076
|
+
const zoomScale = Math.min(this.view.maxZoom, featureScale);
|
|
6077
|
+
const scaledPadding = {
|
|
6078
|
+
top: padding.top / zoomScale,
|
|
6079
|
+
right: padding.right / zoomScale,
|
|
6080
|
+
bottom: padding.bottom / zoomScale,
|
|
6081
|
+
left: padding.left / zoomScale
|
|
6082
|
+
};
|
|
6083
|
+
const paddedFeatureBounds = {
|
|
6084
|
+
x: featureX - scaledPadding.left,
|
|
6085
|
+
y: featureY - scaledPadding.top,
|
|
6086
|
+
width: featureWidth + scaledPadding.left + scaledPadding.right,
|
|
6087
|
+
height: featureHeight + scaledPadding.top + scaledPadding.bottom
|
|
6088
|
+
};
|
|
6089
|
+
const newTransform = zoomIdentity.translate(viewPortWidth / 2, viewPortHeight / 2).scale(zoomScale).translate(-(paddedFeatureBounds.x + paddedFeatureBounds.width / 2), -(paddedFeatureBounds.y + paddedFeatureBounds.height / 2));
|
|
6051
6090
|
select(this._viewport).transition().duration(500).call(this._zoomBehaviour.transform, newTransform, focalPoint);
|
|
6052
6091
|
}
|
|
6053
6092
|
async resetZoom(options) {
|
|
@@ -6273,16 +6312,19 @@ class View {
|
|
|
6273
6312
|
};
|
|
6274
6313
|
}
|
|
6275
6314
|
}
|
|
6276
|
-
const mapContainer = "
|
|
6277
|
-
const helpTextContainer = "
|
|
6278
|
-
const helpText = "
|
|
6279
|
-
const
|
|
6315
|
+
const mapContainer = "_mapContainer_qlxau_9";
|
|
6316
|
+
const helpTextContainer = "_helpTextContainer_qlxau_15";
|
|
6317
|
+
const helpText = "_helpText_qlxau_15";
|
|
6318
|
+
const desktopHelpText = "_desktopHelpText_qlxau_40";
|
|
6319
|
+
const mobileHelpText$1 = "_mobileHelpText_qlxau_48";
|
|
6280
6320
|
const styles$3 = {
|
|
6281
6321
|
mapContainer,
|
|
6282
6322
|
helpTextContainer,
|
|
6283
6323
|
helpText,
|
|
6284
|
-
|
|
6324
|
+
desktopHelpText,
|
|
6325
|
+
mobileHelpText: mobileHelpText$1
|
|
6285
6326
|
};
|
|
6327
|
+
const mobileHelpText = "Use two fingers to zoom";
|
|
6286
6328
|
const Map$1 = forwardRef(({
|
|
6287
6329
|
config,
|
|
6288
6330
|
onLoad,
|
|
@@ -6291,10 +6333,10 @@ const Map$1 = forwardRef(({
|
|
|
6291
6333
|
const {
|
|
6292
6334
|
layers
|
|
6293
6335
|
} = children;
|
|
6336
|
+
const targetRef = useRef();
|
|
6294
6337
|
const [map, setMap] = useState();
|
|
6295
|
-
const [hideDefaultHelpText, setHideDefaultHelpText] = useState(false);
|
|
6296
6338
|
const [zoomHelpText, setZoomHelpText] = useState("");
|
|
6297
|
-
const [
|
|
6339
|
+
const [showHelpText, setShowHelpText] = useState(false);
|
|
6298
6340
|
useEffect(() => {
|
|
6299
6341
|
const map2 = new Map$2({
|
|
6300
6342
|
view: new View(config.view),
|
|
@@ -6308,6 +6350,7 @@ const Map$1 = forwardRef(({
|
|
|
6308
6350
|
const zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
|
|
6309
6351
|
setZoomHelpText(zoomHelpText2);
|
|
6310
6352
|
return () => {
|
|
6353
|
+
map2.destroy();
|
|
6311
6354
|
if (ref)
|
|
6312
6355
|
ref.current = null;
|
|
6313
6356
|
setMap(null);
|
|
@@ -6317,16 +6360,15 @@ const Map$1 = forwardRef(({
|
|
|
6317
6360
|
if (!map)
|
|
6318
6361
|
return;
|
|
6319
6362
|
let timeoutID;
|
|
6320
|
-
map.onFilterEvent(() => {
|
|
6363
|
+
map.onFilterEvent((showHelpText2) => {
|
|
6321
6364
|
if (timeoutID)
|
|
6322
6365
|
clearTimeout(timeoutID);
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
setHideDefaultHelpText(zoomLevel > 1);
|
|
6366
|
+
setShowHelpText(showHelpText2);
|
|
6367
|
+
if (showHelpText2) {
|
|
6368
|
+
timeoutID = setTimeout(() => {
|
|
6369
|
+
setShowHelpText(false);
|
|
6370
|
+
}, 1e3);
|
|
6371
|
+
}
|
|
6330
6372
|
});
|
|
6331
6373
|
return () => {
|
|
6332
6374
|
if (timeoutID)
|
|
@@ -6338,22 +6380,22 @@ const Map$1 = forwardRef(({
|
|
|
6338
6380
|
map.setLayers(layers);
|
|
6339
6381
|
}
|
|
6340
6382
|
}, [map, layers]);
|
|
6341
|
-
const targetRef = useRef();
|
|
6342
|
-
const hideHelpText = hideDefaultHelpText && !highlightHelpText;
|
|
6343
|
-
const helpText2 = highlightHelpText ? zoomHelpText : config.defaultHelpText;
|
|
6344
6383
|
return jsx("div", {
|
|
6345
6384
|
ref: targetRef,
|
|
6346
6385
|
className: styles$3.mapContainer,
|
|
6347
|
-
children:
|
|
6386
|
+
children: jsxs("div", {
|
|
6348
6387
|
className: styles$3.helpTextContainer,
|
|
6349
6388
|
style: {
|
|
6350
|
-
opacity:
|
|
6389
|
+
opacity: showHelpText ? 1 : 0
|
|
6351
6390
|
},
|
|
6352
6391
|
"aria-hidden": true,
|
|
6353
|
-
children: jsx("p", {
|
|
6354
|
-
className: [styles$3.helpText,
|
|
6355
|
-
children:
|
|
6356
|
-
})
|
|
6392
|
+
children: [jsx("p", {
|
|
6393
|
+
className: [styles$3.helpText, styles$3.desktopHelpText].join(" "),
|
|
6394
|
+
children: zoomHelpText
|
|
6395
|
+
}), jsx("p", {
|
|
6396
|
+
className: [styles$3.helpText, styles$3.mobileHelpText].join(" "),
|
|
6397
|
+
children: mobileHelpText
|
|
6398
|
+
})]
|
|
6357
6399
|
})
|
|
6358
6400
|
});
|
|
6359
6401
|
});
|
|
@@ -6463,7 +6505,8 @@ class FeatureRenderer {
|
|
|
6463
6505
|
render(frameState, feature, context) {
|
|
6464
6506
|
const {
|
|
6465
6507
|
projection,
|
|
6466
|
-
transform
|
|
6508
|
+
transform,
|
|
6509
|
+
pixelRatio
|
|
6467
6510
|
} = frameState.viewState;
|
|
6468
6511
|
this.drawingFunction.context(context);
|
|
6469
6512
|
context.beginPath();
|
|
@@ -6476,7 +6519,7 @@ class FeatureRenderer {
|
|
|
6476
6519
|
fill
|
|
6477
6520
|
} = this.style;
|
|
6478
6521
|
if (stroke) {
|
|
6479
|
-
context.lineWidth = stroke.width / transform.k;
|
|
6522
|
+
context.lineWidth = stroke.width * pixelRatio / transform.k;
|
|
6480
6523
|
context.strokeStyle = stroke.color;
|
|
6481
6524
|
context.stroke();
|
|
6482
6525
|
}
|
|
@@ -6867,6 +6910,8 @@ class VectorLayerRenderer {
|
|
|
6867
6910
|
this.featureRenderer = new FeatureRenderer();
|
|
6868
6911
|
}
|
|
6869
6912
|
renderFrame(frameState, targetElement) {
|
|
6913
|
+
if (this.layer.opacity === 0)
|
|
6914
|
+
return targetElement;
|
|
6870
6915
|
const {
|
|
6871
6916
|
projection,
|
|
6872
6917
|
sizeInPixels,
|
|
@@ -6884,14 +6929,14 @@ class VectorLayerRenderer {
|
|
|
6884
6929
|
const source = this.layer.source;
|
|
6885
6930
|
const features = source.getFeaturesInExtent(visibleExtent);
|
|
6886
6931
|
for (const feature of features) {
|
|
6887
|
-
context.save();
|
|
6888
6932
|
const styleFunction2 = feature.getStyleFunction() || this.layer.getStyleFunction();
|
|
6889
6933
|
const featureStyle = styleFunction2(feature);
|
|
6890
|
-
if (
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6934
|
+
if ((featureStyle == null ? void 0 : featureStyle.stroke) || (featureStyle == null ? void 0 : featureStyle.fill)) {
|
|
6935
|
+
context.save();
|
|
6936
|
+
this.featureRenderer.setStyle(featureStyle);
|
|
6937
|
+
this.featureRenderer.render(frameState, feature, context);
|
|
6938
|
+
context.restore();
|
|
6939
|
+
}
|
|
6895
6940
|
}
|
|
6896
6941
|
if (Object.prototype.hasOwnProperty.call(projection, "getCompositionBorders")) {
|
|
6897
6942
|
context.beginPath();
|
|
@@ -7419,7 +7464,7 @@ function useWindowSize() {
|
|
|
7419
7464
|
height: window.innerHeight
|
|
7420
7465
|
};
|
|
7421
7466
|
});
|
|
7422
|
-
|
|
7467
|
+
useLayoutEffect(() => {
|
|
7423
7468
|
if (typeof window === "undefined")
|
|
7424
7469
|
return;
|
|
7425
7470
|
function handleResize() {
|
|
@@ -7525,7 +7570,8 @@ function CoalitionsTracker({
|
|
|
7525
7570
|
stack: list.stack,
|
|
7526
7571
|
width: list.width,
|
|
7527
7572
|
height: barChartHeight,
|
|
7528
|
-
createSVG: true
|
|
7573
|
+
createSVG: true,
|
|
7574
|
+
styles: styles2
|
|
7529
7575
|
})]
|
|
7530
7576
|
}, index);
|
|
7531
7577
|
};
|