@guardian/interactive-component-library 0.1.0-alpha.30 → 0.1.0-alpha.32
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) {
|
|
@@ -219,13 +221,11 @@ function StackedBar({
|
|
|
219
221
|
...defaultStyles$u
|
|
220
222
|
}, styles2);
|
|
221
223
|
const svgHeight = labelType === LabelType.hanging && !hideLabels ? height + 20 : height;
|
|
222
|
-
const cleanBorderAbbr = (abbrText) =>
|
|
223
|
-
return abbrText.split("-")[0];
|
|
224
|
-
};
|
|
224
|
+
const cleanBorderAbbr = (abbrText) => abbrText.split("-")[0];
|
|
225
225
|
const renderLabel = (config, i) => jsx("text", {
|
|
226
226
|
ref: (element) => textElements.current[i] = element,
|
|
227
227
|
"text-rendering": "optimizeLegibility",
|
|
228
|
-
className: styles2.label
|
|
228
|
+
className: `${styles2.label} ${config.hasStroke ? styles2.labelStroke : ""}`,
|
|
229
229
|
style: {
|
|
230
230
|
display: "visible"
|
|
231
231
|
},
|
|
@@ -256,7 +256,6 @@ function StackedBar({
|
|
|
256
256
|
fill: d2.fill
|
|
257
257
|
},
|
|
258
258
|
"shape-rendering": "crispEdges"
|
|
259
|
-
// stroke={border && var()}
|
|
260
259
|
}), labelType === LabelType.inline && !hideLabels && renderLabel(labelConfig, index)]
|
|
261
260
|
}, index);
|
|
262
261
|
totalWidth += itemWidth;
|
|
@@ -278,6 +277,10 @@ function StackedBar({
|
|
|
278
277
|
});
|
|
279
278
|
return preventOverlap(labels, 0, labelOverlapConfig.labelSize, "x", labelOverlapConfig.moveBothLabels);
|
|
280
279
|
}, [stack, height, width]);
|
|
280
|
+
const strokedHangingLabelConfig = useMemo(() => [...hangingLabelConfig].map((l) => ({
|
|
281
|
+
...l,
|
|
282
|
+
hasStroke: true
|
|
283
|
+
})), [hangingLabelConfig]);
|
|
281
284
|
const backgroundRect2 = jsx("g", {
|
|
282
285
|
children: jsx("rect", {
|
|
283
286
|
x: "0",
|
|
@@ -295,7 +298,7 @@ function StackedBar({
|
|
|
295
298
|
viewBox: `0 0 ${width} ${svgHeight}`,
|
|
296
299
|
xmlns: "http://www.w3.org/2000/svg",
|
|
297
300
|
children: [showBackgroundRect && backgroundRect2, jsxs("g", {
|
|
298
|
-
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))]
|
|
299
302
|
})]
|
|
300
303
|
});
|
|
301
304
|
}
|
|
@@ -1312,9 +1315,11 @@ function useTable({
|
|
|
1312
1315
|
if (sortState.columnIndex < 0) {
|
|
1313
1316
|
return data;
|
|
1314
1317
|
}
|
|
1318
|
+
const dataCopy = new Array(...data);
|
|
1315
1319
|
const column = columns[sortState.columnIndex];
|
|
1316
1320
|
const sortFunction = sortState.ascending ? sortAscending(column.accessor) : sortDescending(column.accessor);
|
|
1317
|
-
|
|
1321
|
+
dataCopy.sort(sortFunction);
|
|
1322
|
+
return dataCopy;
|
|
1318
1323
|
}, [columns, data, sortState]);
|
|
1319
1324
|
const columnModels = useMemo(() => {
|
|
1320
1325
|
return columns.map((column, columnIndex) => {
|
|
@@ -1938,11 +1943,11 @@ const ToplineResult = forwardRef(({
|
|
|
1938
1943
|
})]
|
|
1939
1944
|
});
|
|
1940
1945
|
});
|
|
1941
|
-
const borderTop = "
|
|
1942
|
-
const section = "
|
|
1943
|
-
const fullWidth = "
|
|
1944
|
-
const header = "
|
|
1945
|
-
const content = "
|
|
1946
|
+
const borderTop = "_borderTop_1b1s0_9";
|
|
1947
|
+
const section = "_section_1b1s0_13";
|
|
1948
|
+
const fullWidth = "_fullWidth_1b1s0_56";
|
|
1949
|
+
const header = "_header_1b1s0_95";
|
|
1950
|
+
const content = "_content_1b1s0_132";
|
|
1946
1951
|
const defaultStyles$9 = {
|
|
1947
1952
|
borderTop,
|
|
1948
1953
|
section,
|
|
@@ -2145,14 +2150,14 @@ function SearchIcon() {
|
|
|
2145
2150
|
})
|
|
2146
2151
|
});
|
|
2147
2152
|
}
|
|
2148
|
-
const searchContainer = "
|
|
2149
|
-
const input = "
|
|
2150
|
-
const searchIcon = "
|
|
2151
|
-
const clearButton = "
|
|
2152
|
-
const suggestions = "
|
|
2153
|
-
const suggestion = "
|
|
2154
|
-
const selected$1 = "
|
|
2155
|
-
const highlighted = "
|
|
2153
|
+
const searchContainer = "_searchContainer_116es_1";
|
|
2154
|
+
const input = "_input_116es_5";
|
|
2155
|
+
const searchIcon = "_searchIcon_116es_27";
|
|
2156
|
+
const clearButton = "_clearButton_116es_36";
|
|
2157
|
+
const suggestions = "_suggestions_116es_42";
|
|
2158
|
+
const suggestion = "_suggestion_116es_42";
|
|
2159
|
+
const selected$1 = "_selected_116es_68";
|
|
2160
|
+
const highlighted = "_highlighted_116es_72";
|
|
2156
2161
|
const defaultStyles$5 = {
|
|
2157
2162
|
searchContainer,
|
|
2158
2163
|
input,
|
|
@@ -2191,6 +2196,7 @@ function SearchInput({
|
|
|
2191
2196
|
onSelectSuggestion(suggestions2[selectedIndex]);
|
|
2192
2197
|
} else if (event.key === "Enter") {
|
|
2193
2198
|
onSubmit(inputRef.current.value);
|
|
2199
|
+
inputRef.current.blur();
|
|
2194
2200
|
}
|
|
2195
2201
|
}
|
|
2196
2202
|
async function inputChanged(input2) {
|
|
@@ -2206,7 +2212,7 @@ function SearchInput({
|
|
|
2206
2212
|
inputRef.current.value = suggestion2.text;
|
|
2207
2213
|
inputRef.current.blur();
|
|
2208
2214
|
}
|
|
2209
|
-
const showClearButton = ((_a = inputRef.current) == null ? void 0 : _a.value) && ((_b = inputRef.current) == null ? void 0 : _b.value) !== "";
|
|
2215
|
+
const showClearButton = ((_a = inputRef.current) == null ? void 0 : _a.value) && ((_b = inputRef.current) == null ? void 0 : _b.value) !== "" || inputValue && inputValue !== "";
|
|
2210
2216
|
return jsxs("div", {
|
|
2211
2217
|
className: styles2.searchContainer,
|
|
2212
2218
|
children: [jsx("input", {
|
|
@@ -2446,6 +2452,8 @@ function Modal({
|
|
|
2446
2452
|
}
|
|
2447
2453
|
};
|
|
2448
2454
|
}, [onClick, visible]);
|
|
2455
|
+
if (typeof document === "undefined")
|
|
2456
|
+
return;
|
|
2449
2457
|
return createPortal(jsx(d, {
|
|
2450
2458
|
in: visible,
|
|
2451
2459
|
duration: 300,
|
|
@@ -3716,10 +3724,10 @@ function IconPlus$1() {
|
|
|
3716
3724
|
})
|
|
3717
3725
|
});
|
|
3718
3726
|
}
|
|
3719
|
-
const zoomControl$
|
|
3727
|
+
const zoomControl$2 = "_zoomControl_1qhlz_1";
|
|
3720
3728
|
const button$2 = "_button_1qhlz_7";
|
|
3721
3729
|
const styles$5 = {
|
|
3722
|
-
zoomControl: zoomControl$
|
|
3730
|
+
zoomControl: zoomControl$2,
|
|
3723
3731
|
button: button$2
|
|
3724
3732
|
};
|
|
3725
3733
|
function ZoomControl$1({
|
|
@@ -3763,15 +3771,15 @@ function useOrganisedChildren(children) {
|
|
|
3763
3771
|
}, [children]);
|
|
3764
3772
|
return organisedChildren;
|
|
3765
3773
|
}
|
|
3766
|
-
const container = "
|
|
3767
|
-
const svg = "
|
|
3768
|
-
const controls$1 = "
|
|
3769
|
-
const zoomControl$
|
|
3774
|
+
const container = "_container_1ta61_1";
|
|
3775
|
+
const svg = "_svg_1ta61_7";
|
|
3776
|
+
const controls$1 = "_controls_1ta61_13";
|
|
3777
|
+
const zoomControl$1 = "_zoomControl_1ta61_21";
|
|
3770
3778
|
const styles$4 = {
|
|
3771
3779
|
container,
|
|
3772
3780
|
svg,
|
|
3773
3781
|
controls: controls$1,
|
|
3774
|
-
zoomControl: zoomControl$
|
|
3782
|
+
zoomControl: zoomControl$1
|
|
3775
3783
|
};
|
|
3776
3784
|
const _Projection = {
|
|
3777
3785
|
geoAlbersUKComposite: geoAlbersUk(),
|
|
@@ -3892,10 +3900,11 @@ function hasArea(size) {
|
|
|
3892
3900
|
return size[0] > 0 && size[1] > 0;
|
|
3893
3901
|
}
|
|
3894
3902
|
function sizeMinusPadding(size, padding) {
|
|
3903
|
+
let newSize = [...size];
|
|
3895
3904
|
if (padding) {
|
|
3896
|
-
|
|
3905
|
+
newSize = [size[0] - padding.left - padding.right, size[1] - padding.top - padding.bottom];
|
|
3897
3906
|
}
|
|
3898
|
-
return
|
|
3907
|
+
return newSize;
|
|
3899
3908
|
}
|
|
3900
3909
|
function scaleSize(size, ratio, dest) {
|
|
3901
3910
|
if (dest === void 0) {
|
|
@@ -3908,8 +3917,8 @@ function scaleSize(size, ratio, dest) {
|
|
|
3908
3917
|
function scalePadding(padding, ratio) {
|
|
3909
3918
|
const scaled = {
|
|
3910
3919
|
top: Math.round(padding.top * ratio),
|
|
3911
|
-
right: Math.round(padding.
|
|
3912
|
-
bottom: Math.round(padding.
|
|
3920
|
+
right: Math.round(padding.right * ratio),
|
|
3921
|
+
bottom: Math.round(padding.bottom * ratio),
|
|
3913
3922
|
left: Math.round(padding.left * ratio)
|
|
3914
3923
|
};
|
|
3915
3924
|
return scaled;
|
|
@@ -4621,17 +4630,18 @@ class Dispatcher {
|
|
|
4621
4630
|
return;
|
|
4622
4631
|
listenersForEvent.delete(listenerKey);
|
|
4623
4632
|
}
|
|
4624
|
-
dispatch(eventType) {
|
|
4633
|
+
dispatch(eventType, payload) {
|
|
4625
4634
|
const listenersForEvent = this._listenersByEvent.get(eventType);
|
|
4626
4635
|
if (!listenersForEvent)
|
|
4627
4636
|
return;
|
|
4628
4637
|
listenersForEvent.forEach((callback) => {
|
|
4629
|
-
callback(this.target);
|
|
4638
|
+
callback(this.target, payload);
|
|
4630
4639
|
});
|
|
4631
4640
|
}
|
|
4632
4641
|
}
|
|
4633
|
-
const
|
|
4634
|
-
CHANGE: "change"
|
|
4642
|
+
const MapEvent = {
|
|
4643
|
+
CHANGE: "change",
|
|
4644
|
+
ZOOM: "zoom"
|
|
4635
4645
|
};
|
|
4636
4646
|
var noop = { value: () => {
|
|
4637
4647
|
} };
|
|
@@ -5937,6 +5947,7 @@ let Map$2 = class Map2 {
|
|
|
5937
5947
|
this.view = options.view;
|
|
5938
5948
|
this.target = options.target;
|
|
5939
5949
|
this.layers = [];
|
|
5950
|
+
this.dispatcher = new Dispatcher(this);
|
|
5940
5951
|
this._viewport = document.createElement("div");
|
|
5941
5952
|
this._viewport.style.position = "relative";
|
|
5942
5953
|
this._viewport.style.overflow = "hidden";
|
|
@@ -5963,9 +5974,9 @@ let Map$2 = class Map2 {
|
|
|
5963
5974
|
}).on("zoom", (event) => {
|
|
5964
5975
|
this.view.transform = event.transform;
|
|
5965
5976
|
this._requestRender();
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
}
|
|
5977
|
+
this.dispatcher.dispatch(MapEvent.ZOOM, {
|
|
5978
|
+
currentZoomLevel: event.transform.k
|
|
5979
|
+
});
|
|
5969
5980
|
});
|
|
5970
5981
|
select(this._viewport).call(this._zoomBehaviour);
|
|
5971
5982
|
}
|
|
@@ -5996,7 +6007,7 @@ let Map$2 = class Map2 {
|
|
|
5996
6007
|
addLayers(layers) {
|
|
5997
6008
|
this.layers = this.layers.concat(layers);
|
|
5998
6009
|
layers.forEach((layer) => {
|
|
5999
|
-
layer.on(
|
|
6010
|
+
layer.on(MapEvent.CHANGE, () => {
|
|
6000
6011
|
this._requestRender();
|
|
6001
6012
|
});
|
|
6002
6013
|
});
|
|
@@ -6171,12 +6182,12 @@ class View {
|
|
|
6171
6182
|
}
|
|
6172
6183
|
// map size in pixels (i.e. scaled by device pixel ratio)
|
|
6173
6184
|
get mapSize() {
|
|
6174
|
-
return
|
|
6185
|
+
return scaleSize(this.viewPortSize, this.pixelRatio);
|
|
6175
6186
|
}
|
|
6176
|
-
// padding in pixels (i.e. scaled by device pixel ratio)
|
|
6177
6187
|
get padding() {
|
|
6178
6188
|
return this._padding;
|
|
6179
6189
|
}
|
|
6190
|
+
// padding in pixels (i.e. scaled by device pixel ratio)
|
|
6180
6191
|
get scaledPadding() {
|
|
6181
6192
|
const scaledPadding = {
|
|
6182
6193
|
...this._padding
|
|
@@ -6233,12 +6244,13 @@ class View {
|
|
|
6233
6244
|
}
|
|
6234
6245
|
// get extent for drawn map
|
|
6235
6246
|
getMapExtent() {
|
|
6236
|
-
const
|
|
6237
|
-
const
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6247
|
+
const mapSizeInPixels = this.mapSize;
|
|
6248
|
+
const paddingInPixels = this.scaledPadding;
|
|
6249
|
+
return [[paddingInPixels.left, paddingInPixels.top], sizeMinusPadding(mapSizeInPixels, {
|
|
6250
|
+
...paddingInPixels,
|
|
6251
|
+
left: 0,
|
|
6252
|
+
top: 0
|
|
6253
|
+
})];
|
|
6242
6254
|
}
|
|
6243
6255
|
// visible extent in map coordinates
|
|
6244
6256
|
getVisibleExtent(transform, projection) {
|
|
@@ -6261,6 +6273,90 @@ class View {
|
|
|
6261
6273
|
};
|
|
6262
6274
|
}
|
|
6263
6275
|
}
|
|
6276
|
+
const mapContainer = "_mapContainer_y5eeh_9";
|
|
6277
|
+
const helpTextContainer = "_helpTextContainer_y5eeh_15";
|
|
6278
|
+
const helpText = "_helpText_y5eeh_15";
|
|
6279
|
+
const highlight = "_highlight_y5eeh_40";
|
|
6280
|
+
const styles$3 = {
|
|
6281
|
+
mapContainer,
|
|
6282
|
+
helpTextContainer,
|
|
6283
|
+
helpText,
|
|
6284
|
+
highlight
|
|
6285
|
+
};
|
|
6286
|
+
const Map$1 = forwardRef(({
|
|
6287
|
+
config,
|
|
6288
|
+
onLoad,
|
|
6289
|
+
children
|
|
6290
|
+
}, ref) => {
|
|
6291
|
+
const {
|
|
6292
|
+
layers
|
|
6293
|
+
} = children;
|
|
6294
|
+
const [map, setMap] = useState();
|
|
6295
|
+
const [hideDefaultHelpText, setHideDefaultHelpText] = useState(false);
|
|
6296
|
+
const [zoomHelpText, setZoomHelpText] = useState("");
|
|
6297
|
+
const [highlightHelpText, setHighlightHelpText] = useState(false);
|
|
6298
|
+
useEffect(() => {
|
|
6299
|
+
const map2 = new Map$2({
|
|
6300
|
+
view: new View(config.view),
|
|
6301
|
+
target: targetRef.current
|
|
6302
|
+
});
|
|
6303
|
+
map2.addLayers(layers);
|
|
6304
|
+
setMap(map2);
|
|
6305
|
+
if (ref)
|
|
6306
|
+
ref.current = map2;
|
|
6307
|
+
onLoad && onLoad(map2);
|
|
6308
|
+
const zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
|
|
6309
|
+
setZoomHelpText(zoomHelpText2);
|
|
6310
|
+
return () => {
|
|
6311
|
+
if (ref)
|
|
6312
|
+
ref.current = null;
|
|
6313
|
+
setMap(null);
|
|
6314
|
+
};
|
|
6315
|
+
}, []);
|
|
6316
|
+
useEffect(() => {
|
|
6317
|
+
if (!map)
|
|
6318
|
+
return;
|
|
6319
|
+
let timeoutID;
|
|
6320
|
+
map.onFilterEvent(() => {
|
|
6321
|
+
if (timeoutID)
|
|
6322
|
+
clearTimeout(timeoutID);
|
|
6323
|
+
setHighlightHelpText(true);
|
|
6324
|
+
timeoutID = setTimeout(() => {
|
|
6325
|
+
setHighlightHelpText();
|
|
6326
|
+
}, 1e3);
|
|
6327
|
+
});
|
|
6328
|
+
map.onZoomEvent((zoomLevel) => {
|
|
6329
|
+
setHideDefaultHelpText(zoomLevel > 1);
|
|
6330
|
+
});
|
|
6331
|
+
return () => {
|
|
6332
|
+
if (timeoutID)
|
|
6333
|
+
clearTimeout(timeoutID);
|
|
6334
|
+
};
|
|
6335
|
+
}, [map]);
|
|
6336
|
+
useEffect(() => {
|
|
6337
|
+
if (map && layers !== map.layers) {
|
|
6338
|
+
map.setLayers(layers);
|
|
6339
|
+
}
|
|
6340
|
+
}, [map, layers]);
|
|
6341
|
+
const targetRef = useRef();
|
|
6342
|
+
const hideHelpText = hideDefaultHelpText && !highlightHelpText;
|
|
6343
|
+
const helpText2 = highlightHelpText ? zoomHelpText : config.defaultHelpText;
|
|
6344
|
+
return jsx("div", {
|
|
6345
|
+
ref: targetRef,
|
|
6346
|
+
className: styles$3.mapContainer,
|
|
6347
|
+
children: jsx("div", {
|
|
6348
|
+
className: styles$3.helpTextContainer,
|
|
6349
|
+
style: {
|
|
6350
|
+
opacity: hideHelpText ? 0 : 1
|
|
6351
|
+
},
|
|
6352
|
+
"aria-hidden": true,
|
|
6353
|
+
children: jsx("p", {
|
|
6354
|
+
className: [styles$3.helpText, highlightHelpText && styles$3.highlight].join(" "),
|
|
6355
|
+
children: helpText2
|
|
6356
|
+
})
|
|
6357
|
+
})
|
|
6358
|
+
});
|
|
6359
|
+
});
|
|
6264
6360
|
function IconMinus() {
|
|
6265
6361
|
return jsx("svg", {
|
|
6266
6362
|
width: "22",
|
|
@@ -6308,10 +6404,10 @@ function IconReset({
|
|
|
6308
6404
|
})
|
|
6309
6405
|
});
|
|
6310
6406
|
}
|
|
6311
|
-
const zoomControl
|
|
6407
|
+
const zoomControl = "_zoomControl_13wd1_1";
|
|
6312
6408
|
const button$1 = "_button_13wd1_7";
|
|
6313
|
-
const styles$
|
|
6314
|
-
zoomControl
|
|
6409
|
+
const styles$2 = {
|
|
6410
|
+
zoomControl,
|
|
6315
6411
|
button: button$1
|
|
6316
6412
|
};
|
|
6317
6413
|
function ZoomControl({
|
|
@@ -6333,17 +6429,17 @@ function ZoomControl({
|
|
|
6333
6429
|
onReset(event);
|
|
6334
6430
|
};
|
|
6335
6431
|
return jsxs("div", {
|
|
6336
|
-
className: styles$
|
|
6432
|
+
className: styles$2.zoomControl,
|
|
6337
6433
|
children: [jsx("button", {
|
|
6338
|
-
className: styles$
|
|
6434
|
+
className: styles$2.button,
|
|
6339
6435
|
onClick: _onZoomIn,
|
|
6340
6436
|
children: jsx(IconPlus, {})
|
|
6341
6437
|
}), jsx("button", {
|
|
6342
|
-
className: styles$
|
|
6438
|
+
className: styles$2.button,
|
|
6343
6439
|
onClick: _onZoomOut,
|
|
6344
6440
|
children: jsx(IconMinus, {})
|
|
6345
6441
|
}), jsx("button", {
|
|
6346
|
-
className: styles$
|
|
6442
|
+
className: styles$2.button,
|
|
6347
6443
|
onClick: _onReset,
|
|
6348
6444
|
disabled: !resetEnabled,
|
|
6349
6445
|
children: jsx(IconReset, {
|
|
@@ -6352,101 +6448,6 @@ function ZoomControl({
|
|
|
6352
6448
|
})]
|
|
6353
6449
|
});
|
|
6354
6450
|
}
|
|
6355
|
-
const mapContainer = "_mapContainer_aknz0_9";
|
|
6356
|
-
const helpTextContainer = "_helpTextContainer_aknz0_15";
|
|
6357
|
-
const helpText = "_helpText_aknz0_15";
|
|
6358
|
-
const highlight = "_highlight_aknz0_40";
|
|
6359
|
-
const zoomControl = "_zoomControl_aknz0_45";
|
|
6360
|
-
const styles$2 = {
|
|
6361
|
-
mapContainer,
|
|
6362
|
-
helpTextContainer,
|
|
6363
|
-
helpText,
|
|
6364
|
-
highlight,
|
|
6365
|
-
zoomControl
|
|
6366
|
-
};
|
|
6367
|
-
const Map$1 = forwardRef(({
|
|
6368
|
-
config,
|
|
6369
|
-
children
|
|
6370
|
-
}, ref) => {
|
|
6371
|
-
const {
|
|
6372
|
-
controls: controls2,
|
|
6373
|
-
layers
|
|
6374
|
-
} = children;
|
|
6375
|
-
const [map, setMap] = useState();
|
|
6376
|
-
const [currentZoomLevel, setCurrentZoomLevel] = useState(1);
|
|
6377
|
-
const [hideDefaultHelpText, setHideDefaultHelpText] = useState(false);
|
|
6378
|
-
const [zoomHelpText, setZoomHelpText] = useState("");
|
|
6379
|
-
const [highlightHelpText, setHighlightHelpText] = useState(false);
|
|
6380
|
-
useEffect(() => {
|
|
6381
|
-
const map2 = new Map$2({
|
|
6382
|
-
view: new View(config.view),
|
|
6383
|
-
target: targetRef.current
|
|
6384
|
-
});
|
|
6385
|
-
map2.addLayers(layers);
|
|
6386
|
-
setMap(map2);
|
|
6387
|
-
if (ref)
|
|
6388
|
-
ref.current = map2;
|
|
6389
|
-
const zoomHelpText2 = navigator.userAgent.indexOf("Mac") !== -1 ? "Use ⌘ + scroll to zoom" : "Use Ctrl + scroll to zoom";
|
|
6390
|
-
setZoomHelpText(zoomHelpText2);
|
|
6391
|
-
return () => {
|
|
6392
|
-
if (ref)
|
|
6393
|
-
ref.current = null;
|
|
6394
|
-
setMap(null);
|
|
6395
|
-
};
|
|
6396
|
-
}, []);
|
|
6397
|
-
useEffect(() => {
|
|
6398
|
-
if (!map)
|
|
6399
|
-
return;
|
|
6400
|
-
let timeoutID;
|
|
6401
|
-
map.onFilterEvent(() => {
|
|
6402
|
-
if (timeoutID)
|
|
6403
|
-
clearTimeout(timeoutID);
|
|
6404
|
-
setHighlightHelpText(true);
|
|
6405
|
-
timeoutID = setTimeout(() => {
|
|
6406
|
-
setHighlightHelpText();
|
|
6407
|
-
}, 1e3);
|
|
6408
|
-
});
|
|
6409
|
-
map.onZoomEvent((zoomLevel) => {
|
|
6410
|
-
setCurrentZoomLevel(zoomLevel);
|
|
6411
|
-
setHideDefaultHelpText(zoomLevel > 1);
|
|
6412
|
-
});
|
|
6413
|
-
return () => {
|
|
6414
|
-
if (timeoutID)
|
|
6415
|
-
clearTimeout(timeoutID);
|
|
6416
|
-
};
|
|
6417
|
-
}, [map]);
|
|
6418
|
-
useEffect(() => {
|
|
6419
|
-
if (map && layers !== map.layers) {
|
|
6420
|
-
map.setLayers(layers);
|
|
6421
|
-
}
|
|
6422
|
-
}, [map, layers]);
|
|
6423
|
-
const targetRef = useRef();
|
|
6424
|
-
const hideHelpText = hideDefaultHelpText && !highlightHelpText;
|
|
6425
|
-
const helpText2 = highlightHelpText ? zoomHelpText : config.defaultHelpText;
|
|
6426
|
-
return jsxs("div", {
|
|
6427
|
-
ref: targetRef,
|
|
6428
|
-
className: styles$2.mapContainer,
|
|
6429
|
-
children: [jsx("div", {
|
|
6430
|
-
className: styles$2.helpTextContainer,
|
|
6431
|
-
style: {
|
|
6432
|
-
opacity: hideHelpText ? 0 : 1
|
|
6433
|
-
},
|
|
6434
|
-
"aria-hidden": true,
|
|
6435
|
-
children: jsx("p", {
|
|
6436
|
-
className: [styles$2.helpText, highlightHelpText && styles$2.highlight].join(" "),
|
|
6437
|
-
children: helpText2
|
|
6438
|
-
})
|
|
6439
|
-
}), jsx("div", {
|
|
6440
|
-
className: styles$2.zoomControl,
|
|
6441
|
-
children: jsx(ZoomControl, {
|
|
6442
|
-
resetEnabled: currentZoomLevel > 1,
|
|
6443
|
-
onZoomIn: () => map.zoomIn(),
|
|
6444
|
-
onZoomOut: () => map.zoomOut(),
|
|
6445
|
-
onReset: () => map.zoomTo(1)
|
|
6446
|
-
})
|
|
6447
|
-
})]
|
|
6448
|
-
});
|
|
6449
|
-
});
|
|
6450
6451
|
const Projection = {
|
|
6451
6452
|
geoAlbersUKComposite: geoAlbersUk(),
|
|
6452
6453
|
geoAlbersEngland: geoAlbers().center([0, 52.7]).rotate([1.1743, 0]).parallels([50, 54]),
|
|
@@ -6790,7 +6791,7 @@ class VectorSource {
|
|
|
6790
6791
|
});
|
|
6791
6792
|
}
|
|
6792
6793
|
this._features = features;
|
|
6793
|
-
this.dispatcher.dispatch(
|
|
6794
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6794
6795
|
}
|
|
6795
6796
|
}
|
|
6796
6797
|
class TextLayer {
|
|
@@ -6833,7 +6834,7 @@ class TextLayer {
|
|
|
6833
6834
|
}
|
|
6834
6835
|
set style(style2) {
|
|
6835
6836
|
this._style = style2;
|
|
6836
|
-
this.dispatcher.dispatch(
|
|
6837
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6837
6838
|
}
|
|
6838
6839
|
getExtent() {
|
|
6839
6840
|
if (this._extent)
|
|
@@ -6971,9 +6972,9 @@ class VectorLayer {
|
|
|
6971
6972
|
this._source.tearDown();
|
|
6972
6973
|
}
|
|
6973
6974
|
this._source = source;
|
|
6974
|
-
source.on(
|
|
6975
|
+
source.on(MapEvent.CHANGE, () => {
|
|
6975
6976
|
this._extent = null;
|
|
6976
|
-
this.dispatcher.dispatch(
|
|
6977
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6977
6978
|
});
|
|
6978
6979
|
}
|
|
6979
6980
|
setRawProjection(projection) {
|
|
@@ -6992,7 +6993,7 @@ class VectorLayer {
|
|
|
6992
6993
|
}
|
|
6993
6994
|
set style(style2) {
|
|
6994
6995
|
this._style = style2;
|
|
6995
|
-
this.dispatcher.dispatch(
|
|
6996
|
+
this.dispatcher.dispatch(MapEvent.CHANGE);
|
|
6996
6997
|
}
|
|
6997
6998
|
getStyleFunction() {
|
|
6998
6999
|
const style2 = this.style;
|
|
@@ -7657,7 +7658,7 @@ function Ticker({
|
|
|
7657
7658
|
}, []);
|
|
7658
7659
|
useLayoutEffect(() => {
|
|
7659
7660
|
const tickerItemsContainer = tickerItemsRef.current;
|
|
7660
|
-
const hideButtons2 = windowSize.width >= 480 ? tickerScrollRef.current.scrollWidth <= tickerItemsContainer.clientWidth :
|
|
7661
|
+
const hideButtons2 = windowSize.width >= 480 ? tickerScrollRef.current.scrollWidth <= tickerItemsContainer.clientWidth : childArray.length < 3;
|
|
7661
7662
|
setHideButtons(hideButtons2);
|
|
7662
7663
|
}, [windowSize, setHideButtons]);
|
|
7663
7664
|
function toggleExpandedState() {
|
|
@@ -7848,6 +7849,7 @@ export {
|
|
|
7848
7849
|
Container,
|
|
7849
7850
|
ControlChange,
|
|
7850
7851
|
Controls,
|
|
7852
|
+
Dispatcher,
|
|
7851
7853
|
Dropdown,
|
|
7852
7854
|
Fill,
|
|
7853
7855
|
FirstPastThePostWaffle,
|
|
@@ -7860,6 +7862,7 @@ export {
|
|
|
7860
7862
|
LegendItem,
|
|
7861
7863
|
Map$1 as Map,
|
|
7862
7864
|
MapConfiguration,
|
|
7865
|
+
MapEvent,
|
|
7863
7866
|
MapLayers,
|
|
7864
7867
|
Modal,
|
|
7865
7868
|
PageSection,
|
|
@@ -7889,6 +7892,7 @@ export {
|
|
|
7889
7892
|
VectorSource,
|
|
7890
7893
|
Waffle,
|
|
7891
7894
|
WaffleType,
|
|
7895
|
+
ZoomControl,
|
|
7892
7896
|
_Projection,
|
|
7893
7897
|
bboxFeature,
|
|
7894
7898
|
interpolateFeatures,
|