@guardian/interactive-component-library 0.1.0-alpha.31 → 0.1.0-alpha.33
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.
|
@@ -145,12 +145,14 @@ const LegendItem = ({
|
|
|
145
145
|
})]
|
|
146
146
|
});
|
|
147
147
|
};
|
|
148
|
-
const bar$2 = "
|
|
149
|
-
const label$1 = "
|
|
150
|
-
const
|
|
148
|
+
const bar$2 = "_bar_1jxh9_1";
|
|
149
|
+
const label$1 = "_label_1jxh9_5";
|
|
150
|
+
const labelStroke = "_labelStroke_1jxh9_11";
|
|
151
|
+
const backgroundRect = "_backgroundRect_1jxh9_17";
|
|
151
152
|
const defaultStyles$u = {
|
|
152
153
|
bar: bar$2,
|
|
153
154
|
label: label$1,
|
|
155
|
+
labelStroke,
|
|
154
156
|
backgroundRect
|
|
155
157
|
};
|
|
156
158
|
function preventOverlap(labelPositions, iteration = 0, labelSize = 12, coordinate = "y", moveBothLabels = true) {
|
|
@@ -223,7 +225,7 @@ function StackedBar({
|
|
|
223
225
|
const renderLabel = (config, i) => jsx("text", {
|
|
224
226
|
ref: (element) => textElements.current[i] = element,
|
|
225
227
|
"text-rendering": "optimizeLegibility",
|
|
226
|
-
className: styles2.label
|
|
228
|
+
className: `${styles2.label} ${config.hasStroke ? styles2.labelStroke : ""}`,
|
|
227
229
|
style: {
|
|
228
230
|
display: "visible"
|
|
229
231
|
},
|
|
@@ -275,6 +277,10 @@ function StackedBar({
|
|
|
275
277
|
});
|
|
276
278
|
return preventOverlap(labels, 0, labelOverlapConfig.labelSize, "x", labelOverlapConfig.moveBothLabels);
|
|
277
279
|
}, [stack, height, width]);
|
|
280
|
+
const strokedHangingLabelConfig = useMemo(() => [...hangingLabelConfig].map((l) => ({
|
|
281
|
+
...l,
|
|
282
|
+
hasStroke: true
|
|
283
|
+
})), [hangingLabelConfig]);
|
|
278
284
|
const backgroundRect2 = jsx("g", {
|
|
279
285
|
children: jsx("rect", {
|
|
280
286
|
x: "0",
|
|
@@ -292,7 +298,7 @@ function StackedBar({
|
|
|
292
298
|
viewBox: `0 0 ${width} ${svgHeight}`,
|
|
293
299
|
xmlns: "http://www.w3.org/2000/svg",
|
|
294
300
|
children: [showBackgroundRect && backgroundRect2, jsxs("g", {
|
|
295
|
-
children: [content2, labelType === LabelType.hanging && !hideLabels && hangingLabelConfig.map((config, i) => renderLabel(config, i))]
|
|
301
|
+
children: [content2, labelType === LabelType.hanging && !hideLabels && strokedHangingLabelConfig.map((config, i) => renderLabel(config, i)), labelType === LabelType.hanging && !hideLabels && hangingLabelConfig.map((config, i) => renderLabel(config, i))]
|
|
296
302
|
})]
|
|
297
303
|
});
|
|
298
304
|
}
|
|
@@ -479,7 +485,10 @@ const Waffle = ({
|
|
|
479
485
|
numberOfRows,
|
|
480
486
|
type = WaffleType.circle,
|
|
481
487
|
idAccessor,
|
|
482
|
-
onMouseOver
|
|
488
|
+
onMouseOver = () => {
|
|
489
|
+
},
|
|
490
|
+
onClick = () => {
|
|
491
|
+
},
|
|
483
492
|
styles: styles2
|
|
484
493
|
}) => {
|
|
485
494
|
const containerRef = useRef();
|
|
@@ -504,6 +513,7 @@ const Waffle = ({
|
|
|
504
513
|
attributes = {
|
|
505
514
|
id: unit2[idAccessor] || `w-${j}`,
|
|
506
515
|
onMouseOver: (e) => onMouseOver(unit2, e),
|
|
516
|
+
onClick: (e) => onClick(unit2, e),
|
|
507
517
|
class: `${styles2.unit} ${unit2.class}`,
|
|
508
518
|
height: unitHeight,
|
|
509
519
|
width: unitWidth,
|
|
@@ -514,6 +524,7 @@ const Waffle = ({
|
|
|
514
524
|
attributes = {
|
|
515
525
|
id: unit2[idAccessor] || `w-${j}`,
|
|
516
526
|
onMouseOver: (e) => onMouseOver(unit2, e),
|
|
527
|
+
onClick: (e) => onClick(unit2, e),
|
|
517
528
|
class: `${styles2.unit} ${unit2.class}`,
|
|
518
529
|
r: unitWidth / 2,
|
|
519
530
|
transform: `translate(${unitWidth * Math.floor(j / numberOfRows) + unitWidth / 2}, ${unitHeight * (j % numberOfRows) + unitHeight / 2})`
|
|
@@ -1937,11 +1948,11 @@ const ToplineResult = forwardRef(({
|
|
|
1937
1948
|
})]
|
|
1938
1949
|
});
|
|
1939
1950
|
});
|
|
1940
|
-
const borderTop = "
|
|
1941
|
-
const section = "
|
|
1942
|
-
const fullWidth = "
|
|
1943
|
-
const header = "
|
|
1944
|
-
const content = "
|
|
1951
|
+
const borderTop = "_borderTop_1b1s0_9";
|
|
1952
|
+
const section = "_section_1b1s0_13";
|
|
1953
|
+
const fullWidth = "_fullWidth_1b1s0_56";
|
|
1954
|
+
const header = "_header_1b1s0_95";
|
|
1955
|
+
const content = "_content_1b1s0_132";
|
|
1945
1956
|
const defaultStyles$9 = {
|
|
1946
1957
|
borderTop,
|
|
1947
1958
|
section,
|
|
@@ -2144,14 +2155,14 @@ function SearchIcon() {
|
|
|
2144
2155
|
})
|
|
2145
2156
|
});
|
|
2146
2157
|
}
|
|
2147
|
-
const searchContainer = "
|
|
2148
|
-
const input = "
|
|
2149
|
-
const searchIcon = "
|
|
2150
|
-
const clearButton = "
|
|
2151
|
-
const suggestions = "
|
|
2152
|
-
const suggestion = "
|
|
2153
|
-
const selected$1 = "
|
|
2154
|
-
const highlighted = "
|
|
2158
|
+
const searchContainer = "_searchContainer_116es_1";
|
|
2159
|
+
const input = "_input_116es_5";
|
|
2160
|
+
const searchIcon = "_searchIcon_116es_27";
|
|
2161
|
+
const clearButton = "_clearButton_116es_36";
|
|
2162
|
+
const suggestions = "_suggestions_116es_42";
|
|
2163
|
+
const suggestion = "_suggestion_116es_42";
|
|
2164
|
+
const selected$1 = "_selected_116es_68";
|
|
2165
|
+
const highlighted = "_highlighted_116es_72";
|
|
2155
2166
|
const defaultStyles$5 = {
|
|
2156
2167
|
searchContainer,
|
|
2157
2168
|
input,
|
|
@@ -2190,6 +2201,7 @@ function SearchInput({
|
|
|
2190
2201
|
onSelectSuggestion(suggestions2[selectedIndex]);
|
|
2191
2202
|
} else if (event.key === "Enter") {
|
|
2192
2203
|
onSubmit(inputRef.current.value);
|
|
2204
|
+
inputRef.current.blur();
|
|
2193
2205
|
}
|
|
2194
2206
|
}
|
|
2195
2207
|
async function inputChanged(input2) {
|
|
@@ -2205,7 +2217,7 @@ function SearchInput({
|
|
|
2205
2217
|
inputRef.current.value = suggestion2.text;
|
|
2206
2218
|
inputRef.current.blur();
|
|
2207
2219
|
}
|
|
2208
|
-
const showClearButton = ((_a = inputRef.current) == null ? void 0 : _a.value) && ((_b = inputRef.current) == null ? void 0 : _b.value) !== "";
|
|
2220
|
+
const showClearButton = ((_a = inputRef.current) == null ? void 0 : _a.value) && ((_b = inputRef.current) == null ? void 0 : _b.value) !== "" || inputValue && inputValue !== "";
|
|
2209
2221
|
return jsxs("div", {
|
|
2210
2222
|
className: styles2.searchContainer,
|
|
2211
2223
|
children: [jsx("input", {
|
|
@@ -2445,6 +2457,8 @@ function Modal({
|
|
|
2445
2457
|
}
|
|
2446
2458
|
};
|
|
2447
2459
|
}, [onClick, visible]);
|
|
2460
|
+
if (typeof document === "undefined")
|
|
2461
|
+
return;
|
|
2448
2462
|
return createPortal(jsx(d, {
|
|
2449
2463
|
in: visible,
|
|
2450
2464
|
duration: 300,
|
|
@@ -3715,10 +3729,10 @@ function IconPlus$1() {
|
|
|
3715
3729
|
})
|
|
3716
3730
|
});
|
|
3717
3731
|
}
|
|
3718
|
-
const zoomControl$
|
|
3732
|
+
const zoomControl$2 = "_zoomControl_1qhlz_1";
|
|
3719
3733
|
const button$2 = "_button_1qhlz_7";
|
|
3720
3734
|
const styles$5 = {
|
|
3721
|
-
zoomControl: zoomControl$
|
|
3735
|
+
zoomControl: zoomControl$2,
|
|
3722
3736
|
button: button$2
|
|
3723
3737
|
};
|
|
3724
3738
|
function ZoomControl$1({
|
|
@@ -3762,15 +3776,15 @@ function useOrganisedChildren(children) {
|
|
|
3762
3776
|
}, [children]);
|
|
3763
3777
|
return organisedChildren;
|
|
3764
3778
|
}
|
|
3765
|
-
const container = "
|
|
3766
|
-
const svg = "
|
|
3767
|
-
const controls$1 = "
|
|
3768
|
-
const zoomControl$
|
|
3779
|
+
const container = "_container_1ta61_1";
|
|
3780
|
+
const svg = "_svg_1ta61_7";
|
|
3781
|
+
const controls$1 = "_controls_1ta61_13";
|
|
3782
|
+
const zoomControl$1 = "_zoomControl_1ta61_21";
|
|
3769
3783
|
const styles$4 = {
|
|
3770
3784
|
container,
|
|
3771
3785
|
svg,
|
|
3772
3786
|
controls: controls$1,
|
|
3773
|
-
zoomControl: zoomControl$
|
|
3787
|
+
zoomControl: zoomControl$1
|
|
3774
3788
|
};
|
|
3775
3789
|
const _Projection = {
|
|
3776
3790
|
geoAlbersUKComposite: geoAlbersUk(),
|
|
@@ -3891,10 +3905,11 @@ function hasArea(size) {
|
|
|
3891
3905
|
return size[0] > 0 && size[1] > 0;
|
|
3892
3906
|
}
|
|
3893
3907
|
function sizeMinusPadding(size, padding) {
|
|
3908
|
+
let newSize = [...size];
|
|
3894
3909
|
if (padding) {
|
|
3895
|
-
|
|
3910
|
+
newSize = [size[0] - padding.left - padding.right, size[1] - padding.top - padding.bottom];
|
|
3896
3911
|
}
|
|
3897
|
-
return
|
|
3912
|
+
return newSize;
|
|
3898
3913
|
}
|
|
3899
3914
|
function scaleSize(size, ratio, dest) {
|
|
3900
3915
|
if (dest === void 0) {
|
|
@@ -3907,8 +3922,8 @@ function scaleSize(size, ratio, dest) {
|
|
|
3907
3922
|
function scalePadding(padding, ratio) {
|
|
3908
3923
|
const scaled = {
|
|
3909
3924
|
top: Math.round(padding.top * ratio),
|
|
3910
|
-
right: Math.round(padding.
|
|
3911
|
-
bottom: Math.round(padding.
|
|
3925
|
+
right: Math.round(padding.right * ratio),
|
|
3926
|
+
bottom: Math.round(padding.bottom * ratio),
|
|
3912
3927
|
left: Math.round(padding.left * ratio)
|
|
3913
3928
|
};
|
|
3914
3929
|
return scaled;
|
|
@@ -4620,17 +4635,18 @@ class Dispatcher {
|
|
|
4620
4635
|
return;
|
|
4621
4636
|
listenersForEvent.delete(listenerKey);
|
|
4622
4637
|
}
|
|
4623
|
-
dispatch(eventType) {
|
|
4638
|
+
dispatch(eventType, payload) {
|
|
4624
4639
|
const listenersForEvent = this._listenersByEvent.get(eventType);
|
|
4625
4640
|
if (!listenersForEvent)
|
|
4626
4641
|
return;
|
|
4627
4642
|
listenersForEvent.forEach((callback) => {
|
|
4628
|
-
callback(this.target);
|
|
4643
|
+
callback(this.target, payload);
|
|
4629
4644
|
});
|
|
4630
4645
|
}
|
|
4631
4646
|
}
|
|
4632
|
-
const
|
|
4633
|
-
CHANGE: "change"
|
|
4647
|
+
const MapEvent = {
|
|
4648
|
+
CHANGE: "change",
|
|
4649
|
+
ZOOM: "zoom"
|
|
4634
4650
|
};
|
|
4635
4651
|
var noop = { value: () => {
|
|
4636
4652
|
} };
|
|
@@ -5936,6 +5952,7 @@ let Map$2 = class Map2 {
|
|
|
5936
5952
|
this.view = options.view;
|
|
5937
5953
|
this.target = options.target;
|
|
5938
5954
|
this.layers = [];
|
|
5955
|
+
this.dispatcher = new Dispatcher(this);
|
|
5939
5956
|
this._viewport = document.createElement("div");
|
|
5940
5957
|
this._viewport.style.position = "relative";
|
|
5941
5958
|
this._viewport.style.overflow = "hidden";
|
|
@@ -5962,9 +5979,9 @@ let Map$2 = class Map2 {
|
|
|
5962
5979
|
}).on("zoom", (event) => {
|
|
5963
5980
|
this.view.transform = event.transform;
|
|
5964
5981
|
this._requestRender();
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
}
|
|
5982
|
+
this.dispatcher.dispatch(MapEvent.ZOOM, {
|
|
5983
|
+
currentZoomLevel: event.transform.k
|
|
5984
|
+
});
|
|
5968
5985
|
});
|
|
5969
5986
|
select(this._viewport).call(this._zoomBehaviour);
|
|
5970
5987
|
}
|
|
@@ -5995,7 +6012,7 @@ let Map$2 = class Map2 {
|
|
|
5995
6012
|
addLayers(layers) {
|
|
5996
6013
|
this.layers = this.layers.concat(layers);
|
|
5997
6014
|
layers.forEach((layer) => {
|
|
5998
|
-
layer.on(
|
|
6015
|
+
layer.on(MapEvent.CHANGE, () => {
|
|
5999
6016
|
this._requestRender();
|
|
6000
6017
|
});
|
|
6001
6018
|
});
|
|
@@ -6170,12 +6187,12 @@ class View {
|
|
|
6170
6187
|
}
|
|
6171
6188
|
// map size in pixels (i.e. scaled by device pixel ratio)
|
|
6172
6189
|
get mapSize() {
|
|
6173
|
-
return
|
|
6190
|
+
return scaleSize(this.viewPortSize, this.pixelRatio);
|
|
6174
6191
|
}
|
|
6175
|
-
// padding in pixels (i.e. scaled by device pixel ratio)
|
|
6176
6192
|
get padding() {
|
|
6177
6193
|
return this._padding;
|
|
6178
6194
|
}
|
|
6195
|
+
// padding in pixels (i.e. scaled by device pixel ratio)
|
|
6179
6196
|
get scaledPadding() {
|
|
6180
6197
|
const scaledPadding = {
|
|
6181
6198
|
...this._padding
|
|
@@ -6232,12 +6249,13 @@ class View {
|
|
|
6232
6249
|
}
|
|
6233
6250
|
// get extent for drawn map
|
|
6234
6251
|
getMapExtent() {
|
|
6235
|
-
const
|
|
6236
|
-
const
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6252
|
+
const mapSizeInPixels = this.mapSize;
|
|
6253
|
+
const paddingInPixels = this.scaledPadding;
|
|
6254
|
+
return [[paddingInPixels.left, paddingInPixels.top], sizeMinusPadding(mapSizeInPixels, {
|
|
6255
|
+
...paddingInPixels,
|
|
6256
|
+
left: 0,
|
|
6257
|
+
top: 0
|
|
6258
|
+
})];
|
|
6241
6259
|
}
|
|
6242
6260
|
// visible extent in map coordinates
|
|
6243
6261
|
getVisibleExtent(transform, projection) {
|
|
@@ -6260,6 +6278,90 @@ class View {
|
|
|
6260
6278
|
};
|
|
6261
6279
|
}
|
|
6262
6280
|
}
|
|
6281
|
+
const mapContainer = "_mapContainer_y5eeh_9";
|
|
6282
|
+
const helpTextContainer = "_helpTextContainer_y5eeh_15";
|
|
6283
|
+
const helpText = "_helpText_y5eeh_15";
|
|
6284
|
+
const highlight = "_highlight_y5eeh_40";
|
|
6285
|
+
const styles$3 = {
|
|
6286
|
+
mapContainer,
|
|
6287
|
+
helpTextContainer,
|
|
6288
|
+
helpText,
|
|
6289
|
+
highlight
|
|
6290
|
+
};
|
|
6291
|
+
const Map$1 = forwardRef(({
|
|
6292
|
+
config,
|
|
6293
|
+
onLoad,
|
|
6294
|
+
children
|
|
6295
|
+
}, ref) => {
|
|
6296
|
+
const {
|
|
6297
|
+
layers
|
|
6298
|
+
} = children;
|
|
6299
|
+
const [map, setMap] = useState();
|
|
6300
|
+
const [hideDefaultHelpText, setHideDefaultHelpText] = useState(false);
|
|
6301
|
+
const [zoomHelpText, setZoomHelpText] = useState("");
|
|
6302
|
+
const [highlightHelpText, setHighlightHelpText] = useState(false);
|
|
6303
|
+
useEffect(() => {
|
|
6304
|
+
const map2 = new Map$2({
|
|
6305
|
+
view: new View(config.view),
|
|
6306
|
+
target: targetRef.current
|
|
6307
|
+
});
|
|
6308
|
+
map2.addLayers(layers);
|
|
6309
|
+
setMap(map2);
|
|
6310
|
+
if (ref)
|
|
6311
|
+
ref.current = map2;
|
|
6312
|
+
onLoad && onLoad(map2);
|
|
6313
|
+
const zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
|
|
6314
|
+
setZoomHelpText(zoomHelpText2);
|
|
6315
|
+
return () => {
|
|
6316
|
+
if (ref)
|
|
6317
|
+
ref.current = null;
|
|
6318
|
+
setMap(null);
|
|
6319
|
+
};
|
|
6320
|
+
}, []);
|
|
6321
|
+
useEffect(() => {
|
|
6322
|
+
if (!map)
|
|
6323
|
+
return;
|
|
6324
|
+
let timeoutID;
|
|
6325
|
+
map.onFilterEvent(() => {
|
|
6326
|
+
if (timeoutID)
|
|
6327
|
+
clearTimeout(timeoutID);
|
|
6328
|
+
setHighlightHelpText(true);
|
|
6329
|
+
timeoutID = setTimeout(() => {
|
|
6330
|
+
setHighlightHelpText();
|
|
6331
|
+
}, 1e3);
|
|
6332
|
+
});
|
|
6333
|
+
map.onZoomEvent((zoomLevel) => {
|
|
6334
|
+
setHideDefaultHelpText(zoomLevel > 1);
|
|
6335
|
+
});
|
|
6336
|
+
return () => {
|
|
6337
|
+
if (timeoutID)
|
|
6338
|
+
clearTimeout(timeoutID);
|
|
6339
|
+
};
|
|
6340
|
+
}, [map]);
|
|
6341
|
+
useEffect(() => {
|
|
6342
|
+
if (map && layers !== map.layers) {
|
|
6343
|
+
map.setLayers(layers);
|
|
6344
|
+
}
|
|
6345
|
+
}, [map, layers]);
|
|
6346
|
+
const targetRef = useRef();
|
|
6347
|
+
const hideHelpText = hideDefaultHelpText && !highlightHelpText;
|
|
6348
|
+
const helpText2 = highlightHelpText ? zoomHelpText : config.defaultHelpText;
|
|
6349
|
+
return jsx("div", {
|
|
6350
|
+
ref: targetRef,
|
|
6351
|
+
className: styles$3.mapContainer,
|
|
6352
|
+
children: jsx("div", {
|
|
6353
|
+
className: styles$3.helpTextContainer,
|
|
6354
|
+
style: {
|
|
6355
|
+
opacity: hideHelpText ? 0 : 1
|
|
6356
|
+
},
|
|
6357
|
+
"aria-hidden": true,
|
|
6358
|
+
children: jsx("p", {
|
|
6359
|
+
className: [styles$3.helpText, highlightHelpText && styles$3.highlight].join(" "),
|
|
6360
|
+
children: helpText2
|
|
6361
|
+
})
|
|
6362
|
+
})
|
|
6363
|
+
});
|
|
6364
|
+
});
|
|
6263
6365
|
function IconMinus() {
|
|
6264
6366
|
return jsx("svg", {
|
|
6265
6367
|
width: "22",
|
|
@@ -6307,10 +6409,10 @@ function IconReset({
|
|
|
6307
6409
|
})
|
|
6308
6410
|
});
|
|
6309
6411
|
}
|
|
6310
|
-
const zoomControl
|
|
6412
|
+
const zoomControl = "_zoomControl_13wd1_1";
|
|
6311
6413
|
const button$1 = "_button_13wd1_7";
|
|
6312
|
-
const styles$
|
|
6313
|
-
zoomControl
|
|
6414
|
+
const styles$2 = {
|
|
6415
|
+
zoomControl,
|
|
6314
6416
|
button: button$1
|
|
6315
6417
|
};
|
|
6316
6418
|
function ZoomControl({
|
|
@@ -6332,17 +6434,17 @@ function ZoomControl({
|
|
|
6332
6434
|
onReset(event);
|
|
6333
6435
|
};
|
|
6334
6436
|
return jsxs("div", {
|
|
6335
|
-
className: styles$
|
|
6437
|
+
className: styles$2.zoomControl,
|
|
6336
6438
|
children: [jsx("button", {
|
|
6337
|
-
className: styles$
|
|
6439
|
+
className: styles$2.button,
|
|
6338
6440
|
onClick: _onZoomIn,
|
|
6339
6441
|
children: jsx(IconPlus, {})
|
|
6340
6442
|
}), jsx("button", {
|
|
6341
|
-
className: styles$
|
|
6443
|
+
className: styles$2.button,
|
|
6342
6444
|
onClick: _onZoomOut,
|
|
6343
6445
|
children: jsx(IconMinus, {})
|
|
6344
6446
|
}), jsx("button", {
|
|
6345
|
-
className: styles$
|
|
6447
|
+
className: styles$2.button,
|
|
6346
6448
|
onClick: _onReset,
|
|
6347
6449
|
disabled: !resetEnabled,
|
|
6348
6450
|
children: jsx(IconReset, {
|
|
@@ -6351,101 +6453,6 @@ function ZoomControl({
|
|
|
6351
6453
|
})]
|
|
6352
6454
|
});
|
|
6353
6455
|
}
|
|
6354
|
-
const mapContainer = "_mapContainer_aknz0_9";
|
|
6355
|
-
const helpTextContainer = "_helpTextContainer_aknz0_15";
|
|
6356
|
-
const helpText = "_helpText_aknz0_15";
|
|
6357
|
-
const highlight = "_highlight_aknz0_40";
|
|
6358
|
-
const zoomControl = "_zoomControl_aknz0_45";
|
|
6359
|
-
const styles$2 = {
|
|
6360
|
-
mapContainer,
|
|
6361
|
-
helpTextContainer,
|
|
6362
|
-
helpText,
|
|
6363
|
-
highlight,
|
|
6364
|
-
zoomControl
|
|
6365
|
-
};
|
|
6366
|
-
const Map$1 = forwardRef(({
|
|
6367
|
-
config,
|
|
6368
|
-
children
|
|
6369
|
-
}, ref) => {
|
|
6370
|
-
const {
|
|
6371
|
-
controls: controls2,
|
|
6372
|
-
layers
|
|
6373
|
-
} = children;
|
|
6374
|
-
const [map, setMap] = useState();
|
|
6375
|
-
const [currentZoomLevel, setCurrentZoomLevel] = useState(1);
|
|
6376
|
-
const [hideDefaultHelpText, setHideDefaultHelpText] = useState(false);
|
|
6377
|
-
const [zoomHelpText, setZoomHelpText] = useState("");
|
|
6378
|
-
const [highlightHelpText, setHighlightHelpText] = useState(false);
|
|
6379
|
-
useEffect(() => {
|
|
6380
|
-
const map2 = new Map$2({
|
|
6381
|
-
view: new View(config.view),
|
|
6382
|
-
target: targetRef.current
|
|
6383
|
-
});
|
|
6384
|
-
map2.addLayers(layers);
|
|
6385
|
-
setMap(map2);
|
|
6386
|
-
if (ref)
|
|
6387
|
-
ref.current = map2;
|
|
6388
|
-
const zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
|
|
6389
|
-
setZoomHelpText(zoomHelpText2);
|
|
6390
|
-
return () => {
|
|
6391
|
-
if (ref)
|
|
6392
|
-
ref.current = null;
|
|
6393
|
-
setMap(null);
|
|
6394
|
-
};
|
|
6395
|
-
}, []);
|
|
6396
|
-
useEffect(() => {
|
|
6397
|
-
if (!map)
|
|
6398
|
-
return;
|
|
6399
|
-
let timeoutID;
|
|
6400
|
-
map.onFilterEvent(() => {
|
|
6401
|
-
if (timeoutID)
|
|
6402
|
-
clearTimeout(timeoutID);
|
|
6403
|
-
setHighlightHelpText(true);
|
|
6404
|
-
timeoutID = setTimeout(() => {
|
|
6405
|
-
setHighlightHelpText();
|
|
6406
|
-
}, 1e3);
|
|
6407
|
-
});
|
|
6408
|
-
map.onZoomEvent((zoomLevel) => {
|
|
6409
|
-
setCurrentZoomLevel(zoomLevel);
|
|
6410
|
-
setHideDefaultHelpText(zoomLevel > 1);
|
|
6411
|
-
});
|
|
6412
|
-
return () => {
|
|
6413
|
-
if (timeoutID)
|
|
6414
|
-
clearTimeout(timeoutID);
|
|
6415
|
-
};
|
|
6416
|
-
}, [map]);
|
|
6417
|
-
useEffect(() => {
|
|
6418
|
-
if (map && layers !== map.layers) {
|
|
6419
|
-
map.setLayers(layers);
|
|
6420
|
-
}
|
|
6421
|
-
}, [map, layers]);
|
|
6422
|
-
const targetRef = useRef();
|
|
6423
|
-
const hideHelpText = hideDefaultHelpText && !highlightHelpText;
|
|
6424
|
-
const helpText2 = highlightHelpText ? zoomHelpText : config.defaultHelpText;
|
|
6425
|
-
return jsxs("div", {
|
|
6426
|
-
ref: targetRef,
|
|
6427
|
-
className: styles$2.mapContainer,
|
|
6428
|
-
children: [jsx("div", {
|
|
6429
|
-
className: styles$2.helpTextContainer,
|
|
6430
|
-
style: {
|
|
6431
|
-
opacity: hideHelpText ? 0 : 1
|
|
6432
|
-
},
|
|
6433
|
-
"aria-hidden": true,
|
|
6434
|
-
children: jsx("p", {
|
|
6435
|
-
className: [styles$2.helpText, highlightHelpText && styles$2.highlight].join(" "),
|
|
6436
|
-
children: helpText2
|
|
6437
|
-
})
|
|
6438
|
-
}), jsx("div", {
|
|
6439
|
-
className: styles$2.zoomControl,
|
|
6440
|
-
children: jsx(ZoomControl, {
|
|
6441
|
-
resetEnabled: currentZoomLevel > 1,
|
|
6442
|
-
onZoomIn: () => map.zoomIn(),
|
|
6443
|
-
onZoomOut: () => map.zoomOut(),
|
|
6444
|
-
onReset: () => map.zoomTo(1)
|
|
6445
|
-
})
|
|
6446
|
-
})]
|
|
6447
|
-
});
|
|
6448
|
-
});
|
|
6449
6456
|
const Projection = {
|
|
6450
6457
|
geoAlbersUKComposite: geoAlbersUk(),
|
|
6451
6458
|
geoAlbersEngland: geoAlbers().center([0, 52.7]).rotate([1.1743, 0]).parallels([50, 54]),
|
|
@@ -6789,7 +6796,7 @@ class VectorSource {
|
|
|
6789
6796
|
});
|
|
6790
6797
|
}
|
|
6791
6798
|
this._features = features;
|
|
6792
|
-
this.dispatcher.dispatch(
|
|
6799
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6793
6800
|
}
|
|
6794
6801
|
}
|
|
6795
6802
|
class TextLayer {
|
|
@@ -6832,7 +6839,7 @@ class TextLayer {
|
|
|
6832
6839
|
}
|
|
6833
6840
|
set style(style2) {
|
|
6834
6841
|
this._style = style2;
|
|
6835
|
-
this.dispatcher.dispatch(
|
|
6842
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6836
6843
|
}
|
|
6837
6844
|
getExtent() {
|
|
6838
6845
|
if (this._extent)
|
|
@@ -6970,9 +6977,9 @@ class VectorLayer {
|
|
|
6970
6977
|
this._source.tearDown();
|
|
6971
6978
|
}
|
|
6972
6979
|
this._source = source;
|
|
6973
|
-
source.on(
|
|
6980
|
+
source.on(MapEvent.CHANGE, () => {
|
|
6974
6981
|
this._extent = null;
|
|
6975
|
-
this.dispatcher.dispatch(
|
|
6982
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6976
6983
|
});
|
|
6977
6984
|
}
|
|
6978
6985
|
setRawProjection(projection) {
|
|
@@ -6991,7 +6998,7 @@ class VectorLayer {
|
|
|
6991
6998
|
}
|
|
6992
6999
|
set style(style2) {
|
|
6993
7000
|
this._style = style2;
|
|
6994
|
-
this.dispatcher.dispatch(
|
|
7001
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6995
7002
|
}
|
|
6996
7003
|
getStyleFunction() {
|
|
6997
7004
|
const style2 = this.style;
|
|
@@ -7523,7 +7530,8 @@ function CoalitionsTracker({
|
|
|
7523
7530
|
stack: list.stack,
|
|
7524
7531
|
width: list.width,
|
|
7525
7532
|
height: barChartHeight,
|
|
7526
|
-
createSVG: true
|
|
7533
|
+
createSVG: true,
|
|
7534
|
+
styles: styles2
|
|
7527
7535
|
})]
|
|
7528
7536
|
}, index);
|
|
7529
7537
|
};
|
|
@@ -7656,7 +7664,7 @@ function Ticker({
|
|
|
7656
7664
|
}, []);
|
|
7657
7665
|
useLayoutEffect(() => {
|
|
7658
7666
|
const tickerItemsContainer = tickerItemsRef.current;
|
|
7659
|
-
const hideButtons2 = windowSize.width >= 480 ? tickerScrollRef.current.scrollWidth <= tickerItemsContainer.clientWidth :
|
|
7667
|
+
const hideButtons2 = windowSize.width >= 480 ? tickerScrollRef.current.scrollWidth <= tickerItemsContainer.clientWidth : childArray.length < 3;
|
|
7660
7668
|
setHideButtons(hideButtons2);
|
|
7661
7669
|
}, [windowSize, setHideButtons]);
|
|
7662
7670
|
function toggleExpandedState() {
|
|
@@ -7847,6 +7855,7 @@ export {
|
|
|
7847
7855
|
Container,
|
|
7848
7856
|
ControlChange,
|
|
7849
7857
|
Controls,
|
|
7858
|
+
Dispatcher,
|
|
7850
7859
|
Dropdown,
|
|
7851
7860
|
Fill,
|
|
7852
7861
|
FirstPastThePostWaffle,
|
|
@@ -7859,6 +7868,7 @@ export {
|
|
|
7859
7868
|
LegendItem,
|
|
7860
7869
|
Map$1 as Map,
|
|
7861
7870
|
MapConfiguration,
|
|
7871
|
+
MapEvent,
|
|
7862
7872
|
MapLayers,
|
|
7863
7873
|
Modal,
|
|
7864
7874
|
PageSection,
|
|
@@ -7888,6 +7898,7 @@ export {
|
|
|
7888
7898
|
VectorSource,
|
|
7889
7899
|
Waffle,
|
|
7890
7900
|
WaffleType,
|
|
7901
|
+
ZoomControl,
|
|
7891
7902
|
_Projection,
|
|
7892
7903
|
bboxFeature,
|
|
7893
7904
|
interpolateFeatures,
|