@guardian/interactive-component-library 0.1.0-alpha.33 → 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.
|
@@ -1948,11 +1948,11 @@ const ToplineResult = forwardRef(({
|
|
|
1948
1948
|
})]
|
|
1949
1949
|
});
|
|
1950
1950
|
});
|
|
1951
|
-
const borderTop = "
|
|
1952
|
-
const section = "
|
|
1953
|
-
const fullWidth = "
|
|
1954
|
-
const header = "
|
|
1955
|
-
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";
|
|
1956
1956
|
const defaultStyles$9 = {
|
|
1957
1957
|
borderTop,
|
|
1958
1958
|
section,
|
|
@@ -2419,14 +2419,16 @@ var d = (E) => {
|
|
|
2419
2419
|
return cloneElement(t, { className: i });
|
|
2420
2420
|
});
|
|
2421
2421
|
};
|
|
2422
|
-
const transitionContainer = "
|
|
2423
|
-
const
|
|
2424
|
-
const
|
|
2425
|
-
const
|
|
2426
|
-
const
|
|
2427
|
-
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";
|
|
2428
2429
|
const styles$6 = {
|
|
2429
2430
|
transitionContainer,
|
|
2431
|
+
blur,
|
|
2430
2432
|
modalBox,
|
|
2431
2433
|
enter,
|
|
2432
2434
|
exitDone,
|
|
@@ -2435,6 +2437,7 @@ const styles$6 = {
|
|
|
2435
2437
|
};
|
|
2436
2438
|
function Modal({
|
|
2437
2439
|
visible = false,
|
|
2440
|
+
blurBackground = true,
|
|
2438
2441
|
children,
|
|
2439
2442
|
onClickOutside
|
|
2440
2443
|
}) {
|
|
@@ -2464,11 +2467,8 @@ function Modal({
|
|
|
2464
2467
|
duration: 300,
|
|
2465
2468
|
classNames: styles$6,
|
|
2466
2469
|
children: jsx("div", {
|
|
2467
|
-
|
|
2470
|
+
className: [styles$6.transitionContainer, blurBackground && styles$6.blur, visible && styles$6.visible].join(" "),
|
|
2468
2471
|
onClick,
|
|
2469
|
-
style: {
|
|
2470
|
-
pointerEvents: visible ? "auto" : "none"
|
|
2471
|
-
},
|
|
2472
2472
|
children: jsx("div", {
|
|
2473
2473
|
ref: modalBoxRef,
|
|
2474
2474
|
class: styles$6.modalBox,
|
|
@@ -4448,7 +4448,7 @@ class MapRenderer {
|
|
|
4448
4448
|
constructor(map) {
|
|
4449
4449
|
this.map = map;
|
|
4450
4450
|
this._element = document.createElement("div");
|
|
4451
|
-
this._element.className = "gv-
|
|
4451
|
+
this._element.className = "gv-layer-container";
|
|
4452
4452
|
const style2 = this._element.style;
|
|
4453
4453
|
style2.position = "absolute";
|
|
4454
4454
|
style2.width = "100%";
|
|
@@ -5954,6 +5954,7 @@ let Map$2 = class Map2 {
|
|
|
5954
5954
|
this.layers = [];
|
|
5955
5955
|
this.dispatcher = new Dispatcher(this);
|
|
5956
5956
|
this._viewport = document.createElement("div");
|
|
5957
|
+
this._viewport.className = "gv-map";
|
|
5957
5958
|
this._viewport.style.position = "relative";
|
|
5958
5959
|
this._viewport.style.overflow = "hidden";
|
|
5959
5960
|
this._viewport.style.top = 0;
|
|
@@ -5967,13 +5968,19 @@ let Map$2 = class Map2 {
|
|
|
5967
5968
|
this.view.transform = zoomIdentity;
|
|
5968
5969
|
this._zoomBypassKey = navigator.userAgent.indexOf("Mac") !== -1 ? "metaKey" : "ctrlKey";
|
|
5969
5970
|
this._zoomBehaviour = zoom().scaleExtent(this.view.scaleExtent).filter((event) => {
|
|
5971
|
+
const filterEvent = (filter) => {
|
|
5972
|
+
this._filterEventCallback(filter);
|
|
5973
|
+
return !filter;
|
|
5974
|
+
};
|
|
5970
5975
|
if (event.type === "wheel" && !event[this._zoomBypassKey]) {
|
|
5971
|
-
|
|
5972
|
-
return false;
|
|
5976
|
+
return filterEvent(true);
|
|
5973
5977
|
}
|
|
5974
|
-
if ("targetTouches" in event
|
|
5975
|
-
|
|
5976
|
-
|
|
5978
|
+
if ("targetTouches" in event) {
|
|
5979
|
+
if (event.targetTouches.length < 2) {
|
|
5980
|
+
return false;
|
|
5981
|
+
}
|
|
5982
|
+
event.preventDefault();
|
|
5983
|
+
return filterEvent(false);
|
|
5977
5984
|
}
|
|
5978
5985
|
return (!event.ctrlKey || event.type === "wheel") && !event.button;
|
|
5979
5986
|
}).on("zoom", (event) => {
|
|
@@ -5984,6 +5991,15 @@ let Map$2 = class Map2 {
|
|
|
5984
5991
|
});
|
|
5985
5992
|
});
|
|
5986
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();
|
|
5987
6003
|
}
|
|
5988
6004
|
/** PUBLIC GETTERS */
|
|
5989
6005
|
get size() {
|
|
@@ -5999,9 +6015,6 @@ let Map$2 = class Map2 {
|
|
|
5999
6015
|
onFilterEvent(callback) {
|
|
6000
6016
|
this._filterEventCallback = callback;
|
|
6001
6017
|
}
|
|
6002
|
-
onZoomEvent(callback) {
|
|
6003
|
-
this._onZoomEventCallback = callback;
|
|
6004
|
-
}
|
|
6005
6018
|
fitObject(geoJSON) {
|
|
6006
6019
|
this.view.fitObject(geoJSON);
|
|
6007
6020
|
this._requestRender();
|
|
@@ -6022,7 +6035,7 @@ let Map$2 = class Map2 {
|
|
|
6022
6035
|
if (layers === this.layers) {
|
|
6023
6036
|
return;
|
|
6024
6037
|
}
|
|
6025
|
-
|
|
6038
|
+
new Array(...this.layers).forEach((layer) => {
|
|
6026
6039
|
if (!layers.includes(layer)) {
|
|
6027
6040
|
this.removeLayer(layer);
|
|
6028
6041
|
}
|
|
@@ -6048,11 +6061,32 @@ let Map$2 = class Map2 {
|
|
|
6048
6061
|
}) {
|
|
6049
6062
|
return select(this._viewport).transition().duration(options.duration).call(this._zoomBehaviour.scaleTo, zoomLevel).end();
|
|
6050
6063
|
}
|
|
6051
|
-
zoomToFeature(feature, focalPoint
|
|
6064
|
+
zoomToFeature(feature, focalPoint, padding = {
|
|
6065
|
+
top: 40,
|
|
6066
|
+
right: 40,
|
|
6067
|
+
bottom: 40,
|
|
6068
|
+
left: 40
|
|
6069
|
+
}) {
|
|
6052
6070
|
const extent = feature.getExtent();
|
|
6053
|
-
const [[
|
|
6054
|
-
const
|
|
6055
|
-
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));
|
|
6056
6090
|
select(this._viewport).transition().duration(500).call(this._zoomBehaviour.transform, newTransform, focalPoint);
|
|
6057
6091
|
}
|
|
6058
6092
|
async resetZoom(options) {
|
|
@@ -6278,16 +6312,19 @@ class View {
|
|
|
6278
6312
|
};
|
|
6279
6313
|
}
|
|
6280
6314
|
}
|
|
6281
|
-
const mapContainer = "
|
|
6282
|
-
const helpTextContainer = "
|
|
6283
|
-
const helpText = "
|
|
6284
|
-
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";
|
|
6285
6320
|
const styles$3 = {
|
|
6286
6321
|
mapContainer,
|
|
6287
6322
|
helpTextContainer,
|
|
6288
6323
|
helpText,
|
|
6289
|
-
|
|
6324
|
+
desktopHelpText,
|
|
6325
|
+
mobileHelpText: mobileHelpText$1
|
|
6290
6326
|
};
|
|
6327
|
+
const mobileHelpText = "Use two fingers to zoom";
|
|
6291
6328
|
const Map$1 = forwardRef(({
|
|
6292
6329
|
config,
|
|
6293
6330
|
onLoad,
|
|
@@ -6296,10 +6333,10 @@ const Map$1 = forwardRef(({
|
|
|
6296
6333
|
const {
|
|
6297
6334
|
layers
|
|
6298
6335
|
} = children;
|
|
6336
|
+
const targetRef = useRef();
|
|
6299
6337
|
const [map, setMap] = useState();
|
|
6300
|
-
const [hideDefaultHelpText, setHideDefaultHelpText] = useState(false);
|
|
6301
6338
|
const [zoomHelpText, setZoomHelpText] = useState("");
|
|
6302
|
-
const [
|
|
6339
|
+
const [showHelpText, setShowHelpText] = useState(false);
|
|
6303
6340
|
useEffect(() => {
|
|
6304
6341
|
const map2 = new Map$2({
|
|
6305
6342
|
view: new View(config.view),
|
|
@@ -6313,6 +6350,7 @@ const Map$1 = forwardRef(({
|
|
|
6313
6350
|
const zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
|
|
6314
6351
|
setZoomHelpText(zoomHelpText2);
|
|
6315
6352
|
return () => {
|
|
6353
|
+
map2.destroy();
|
|
6316
6354
|
if (ref)
|
|
6317
6355
|
ref.current = null;
|
|
6318
6356
|
setMap(null);
|
|
@@ -6322,16 +6360,15 @@ const Map$1 = forwardRef(({
|
|
|
6322
6360
|
if (!map)
|
|
6323
6361
|
return;
|
|
6324
6362
|
let timeoutID;
|
|
6325
|
-
map.onFilterEvent(() => {
|
|
6363
|
+
map.onFilterEvent((showHelpText2) => {
|
|
6326
6364
|
if (timeoutID)
|
|
6327
6365
|
clearTimeout(timeoutID);
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
setHideDefaultHelpText(zoomLevel > 1);
|
|
6366
|
+
setShowHelpText(showHelpText2);
|
|
6367
|
+
if (showHelpText2) {
|
|
6368
|
+
timeoutID = setTimeout(() => {
|
|
6369
|
+
setShowHelpText(false);
|
|
6370
|
+
}, 1e3);
|
|
6371
|
+
}
|
|
6335
6372
|
});
|
|
6336
6373
|
return () => {
|
|
6337
6374
|
if (timeoutID)
|
|
@@ -6343,22 +6380,22 @@ const Map$1 = forwardRef(({
|
|
|
6343
6380
|
map.setLayers(layers);
|
|
6344
6381
|
}
|
|
6345
6382
|
}, [map, layers]);
|
|
6346
|
-
const targetRef = useRef();
|
|
6347
|
-
const hideHelpText = hideDefaultHelpText && !highlightHelpText;
|
|
6348
|
-
const helpText2 = highlightHelpText ? zoomHelpText : config.defaultHelpText;
|
|
6349
6383
|
return jsx("div", {
|
|
6350
6384
|
ref: targetRef,
|
|
6351
6385
|
className: styles$3.mapContainer,
|
|
6352
|
-
children:
|
|
6386
|
+
children: jsxs("div", {
|
|
6353
6387
|
className: styles$3.helpTextContainer,
|
|
6354
6388
|
style: {
|
|
6355
|
-
opacity:
|
|
6389
|
+
opacity: showHelpText ? 1 : 0
|
|
6356
6390
|
},
|
|
6357
6391
|
"aria-hidden": true,
|
|
6358
|
-
children: jsx("p", {
|
|
6359
|
-
className: [styles$3.helpText,
|
|
6360
|
-
children:
|
|
6361
|
-
})
|
|
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
|
+
})]
|
|
6362
6399
|
})
|
|
6363
6400
|
});
|
|
6364
6401
|
});
|
|
@@ -6468,7 +6505,8 @@ class FeatureRenderer {
|
|
|
6468
6505
|
render(frameState, feature, context) {
|
|
6469
6506
|
const {
|
|
6470
6507
|
projection,
|
|
6471
|
-
transform
|
|
6508
|
+
transform,
|
|
6509
|
+
pixelRatio
|
|
6472
6510
|
} = frameState.viewState;
|
|
6473
6511
|
this.drawingFunction.context(context);
|
|
6474
6512
|
context.beginPath();
|
|
@@ -6481,7 +6519,7 @@ class FeatureRenderer {
|
|
|
6481
6519
|
fill
|
|
6482
6520
|
} = this.style;
|
|
6483
6521
|
if (stroke) {
|
|
6484
|
-
context.lineWidth = stroke.width / transform.k;
|
|
6522
|
+
context.lineWidth = stroke.width * pixelRatio / transform.k;
|
|
6485
6523
|
context.strokeStyle = stroke.color;
|
|
6486
6524
|
context.stroke();
|
|
6487
6525
|
}
|
|
@@ -6872,6 +6910,8 @@ class VectorLayerRenderer {
|
|
|
6872
6910
|
this.featureRenderer = new FeatureRenderer();
|
|
6873
6911
|
}
|
|
6874
6912
|
renderFrame(frameState, targetElement) {
|
|
6913
|
+
if (this.layer.opacity === 0)
|
|
6914
|
+
return targetElement;
|
|
6875
6915
|
const {
|
|
6876
6916
|
projection,
|
|
6877
6917
|
sizeInPixels,
|
|
@@ -6889,14 +6929,14 @@ class VectorLayerRenderer {
|
|
|
6889
6929
|
const source = this.layer.source;
|
|
6890
6930
|
const features = source.getFeaturesInExtent(visibleExtent);
|
|
6891
6931
|
for (const feature of features) {
|
|
6892
|
-
context.save();
|
|
6893
6932
|
const styleFunction2 = feature.getStyleFunction() || this.layer.getStyleFunction();
|
|
6894
6933
|
const featureStyle = styleFunction2(feature);
|
|
6895
|
-
if (
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
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
|
+
}
|
|
6900
6940
|
}
|
|
6901
6941
|
if (Object.prototype.hasOwnProperty.call(projection, "getCompositionBorders")) {
|
|
6902
6942
|
context.beginPath();
|
|
@@ -7424,7 +7464,7 @@ function useWindowSize() {
|
|
|
7424
7464
|
height: window.innerHeight
|
|
7425
7465
|
};
|
|
7426
7466
|
});
|
|
7427
|
-
|
|
7467
|
+
useLayoutEffect(() => {
|
|
7428
7468
|
if (typeof window === "undefined")
|
|
7429
7469
|
return;
|
|
7430
7470
|
function handleResize() {
|