@guardian/interactive-component-library 0.1.0-alpha.15 → 0.1.0-alpha.17
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.
|
@@ -3,7 +3,7 @@ import { useRef, useState, useLayoutEffect, useCallback, useEffect, useMemo, use
|
|
|
3
3
|
import { render, createElement, cloneElement, createContext, toChildArray } from "preact";
|
|
4
4
|
import { useSyncExternalStore, createPortal, forwardRef } from "preact/compat";
|
|
5
5
|
import { scaleLinear as scaleLinear$1 } from "d3-scale";
|
|
6
|
-
import { geoStream, geoAlbers, geoPath, geoMercator } from "d3-geo";
|
|
6
|
+
import { geoStream, geoAlbers, geoPath, geoContains, geoMercator } from "d3-geo";
|
|
7
7
|
const main = "";
|
|
8
8
|
const group = "_group_nq9z3_1";
|
|
9
9
|
const rotated = "_rotated_nq9z3_6";
|
|
@@ -1589,33 +1589,33 @@ var d = (E) => {
|
|
|
1589
1589
|
return cloneElement(t, { className: i });
|
|
1590
1590
|
});
|
|
1591
1591
|
};
|
|
1592
|
-
const transitionContainer = "_transitionContainer_1gzlr_1";
|
|
1593
|
-
const modalBox = "_modalBox_1gzlr_13";
|
|
1594
|
-
const enter = "_enter_1gzlr_21";
|
|
1595
|
-
const exitDone = "_exitDone_1gzlr_22";
|
|
1596
|
-
const enterActive = "_enterActive_1gzlr_31";
|
|
1597
|
-
const exit = "_exit_1gzlr_22";
|
|
1598
|
-
const styles$
|
|
1599
|
-
transitionContainer,
|
|
1600
|
-
modalBox,
|
|
1601
|
-
enter,
|
|
1602
|
-
exitDone,
|
|
1603
|
-
enterActive,
|
|
1604
|
-
exit
|
|
1605
|
-
};
|
|
1606
|
-
function Modal({
|
|
1592
|
+
const transitionContainer$1 = "_transitionContainer_1gzlr_1";
|
|
1593
|
+
const modalBox$1 = "_modalBox_1gzlr_13";
|
|
1594
|
+
const enter$1 = "_enter_1gzlr_21";
|
|
1595
|
+
const exitDone$1 = "_exitDone_1gzlr_22";
|
|
1596
|
+
const enterActive$1 = "_enterActive_1gzlr_31";
|
|
1597
|
+
const exit$1 = "_exit_1gzlr_22";
|
|
1598
|
+
const styles$5 = {
|
|
1599
|
+
transitionContainer: transitionContainer$1,
|
|
1600
|
+
modalBox: modalBox$1,
|
|
1601
|
+
enter: enter$1,
|
|
1602
|
+
exitDone: exitDone$1,
|
|
1603
|
+
enterActive: enterActive$1,
|
|
1604
|
+
exit: exit$1
|
|
1605
|
+
};
|
|
1606
|
+
function Modal$1({
|
|
1607
1607
|
visible = false,
|
|
1608
1608
|
children
|
|
1609
1609
|
}) {
|
|
1610
1610
|
return jsx(d, {
|
|
1611
1611
|
in: visible,
|
|
1612
1612
|
duration: 300,
|
|
1613
|
-
classNames: styles$
|
|
1613
|
+
classNames: styles$5,
|
|
1614
1614
|
alwaysMounted: true,
|
|
1615
1615
|
children: jsx("div", {
|
|
1616
|
-
class: styles$
|
|
1616
|
+
class: styles$5.transitionContainer,
|
|
1617
1617
|
children: jsx("div", {
|
|
1618
|
-
class: styles$
|
|
1618
|
+
class: styles$5.modalBox,
|
|
1619
1619
|
children
|
|
1620
1620
|
})
|
|
1621
1621
|
})
|
|
@@ -1698,7 +1698,7 @@ function Tooltip({
|
|
|
1698
1698
|
style: fixedStyle,
|
|
1699
1699
|
children: [positionInTarget && children(positionInTarget), !trackPosition && children]
|
|
1700
1700
|
});
|
|
1701
|
-
return createPortal(type === TooltipType.modal ? jsx(Modal, {
|
|
1701
|
+
return createPortal(type === TooltipType.modal ? jsx(Modal$1, {
|
|
1702
1702
|
visible: hoverActive,
|
|
1703
1703
|
children: tooltip2
|
|
1704
1704
|
}) : tooltip2, displayElement);
|
|
@@ -2433,7 +2433,7 @@ function useContainerSize(containerRef) {
|
|
|
2433
2433
|
}
|
|
2434
2434
|
const container$1 = "_container_cyrny_1";
|
|
2435
2435
|
const svg$1 = "_svg_cyrny_6";
|
|
2436
|
-
const styles$
|
|
2436
|
+
const styles$4 = {
|
|
2437
2437
|
container: container$1,
|
|
2438
2438
|
svg: svg$1
|
|
2439
2439
|
};
|
|
@@ -2455,6 +2455,12 @@ function Polygon({
|
|
|
2455
2455
|
const context = useContext(MapContext);
|
|
2456
2456
|
useEffect(() => {
|
|
2457
2457
|
function findFeatureAtPoint(point) {
|
|
2458
|
+
const projectedPoint = context.projection.invert(point);
|
|
2459
|
+
for (const feature of features) {
|
|
2460
|
+
if (geoContains(feature, projectedPoint)) {
|
|
2461
|
+
return feature;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2458
2464
|
}
|
|
2459
2465
|
const layer = {
|
|
2460
2466
|
zIndex,
|
|
@@ -2464,7 +2470,7 @@ function Polygon({
|
|
|
2464
2470
|
return () => {
|
|
2465
2471
|
context.unregisterLayer(layer);
|
|
2466
2472
|
};
|
|
2467
|
-
}, [context, zIndex]);
|
|
2473
|
+
}, [context, zIndex, features]);
|
|
2468
2474
|
return jsx(Fragment, {
|
|
2469
2475
|
children: features.map((d2, index2) => {
|
|
2470
2476
|
return jsx("path", {
|
|
@@ -2675,7 +2681,7 @@ const Map$1 = forwardRef(({
|
|
|
2675
2681
|
const renderSVG = containerSize && !config.drawToCanvas;
|
|
2676
2682
|
return jsx("div", {
|
|
2677
2683
|
ref: containerRef,
|
|
2678
|
-
className: styles$
|
|
2684
|
+
className: styles$4.container,
|
|
2679
2685
|
style: containerStyle,
|
|
2680
2686
|
children: renderSVG && jsx(SVGMapProvider, {
|
|
2681
2687
|
id,
|
|
@@ -2727,7 +2733,7 @@ function ResultSummary({
|
|
|
2727
2733
|
}
|
|
2728
2734
|
const svg = "_svg_1dms8_1";
|
|
2729
2735
|
const path = "_path_1dms8_8";
|
|
2730
|
-
const styles$
|
|
2736
|
+
const styles$3 = {
|
|
2731
2737
|
svg,
|
|
2732
2738
|
path
|
|
2733
2739
|
};
|
|
@@ -2735,9 +2741,9 @@ function SearchIcon() {
|
|
|
2735
2741
|
return jsx("svg", {
|
|
2736
2742
|
viewBox: "0 0 20 20",
|
|
2737
2743
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2738
|
-
className: styles$
|
|
2744
|
+
className: styles$3.svg,
|
|
2739
2745
|
children: jsx("path", {
|
|
2740
|
-
className: styles$
|
|
2746
|
+
className: styles$3.path,
|
|
2741
2747
|
"fill-rule": "evenodd",
|
|
2742
2748
|
"clip-rule": "evenodd",
|
|
2743
2749
|
d: "M7.273 0c4.022 0 7.25 3.295 7.25 7.273a7.226 7.226 0 01-7.25 7.25C3.25 14.523 0 11.295 0 7.273 0 3.295 3.25 0 7.273 0zm0 1.84A5.403 5.403 0 001.84 7.274c0 3 2.409 5.454 5.432 5.454 3 0 5.454-2.454 5.454-5.454 0-3.023-2.454-5.432-5.454-5.432zM20 18.16l-5.432-5.432h-.932l-.909.91v.931L18.16 20 20 18.159z"
|
|
@@ -2936,6 +2942,50 @@ function ResponsiveGrid({
|
|
|
2936
2942
|
})
|
|
2937
2943
|
});
|
|
2938
2944
|
}
|
|
2945
|
+
const transitionContainer = "_transitionContainer_wws3j_1";
|
|
2946
|
+
const modalBox = "_modalBox_wws3j_13";
|
|
2947
|
+
const enter = "_enter_wws3j_21";
|
|
2948
|
+
const exitDone = "_exitDone_wws3j_22";
|
|
2949
|
+
const enterActive = "_enterActive_wws3j_31";
|
|
2950
|
+
const exit = "_exit_wws3j_22";
|
|
2951
|
+
const styles$2 = {
|
|
2952
|
+
transitionContainer,
|
|
2953
|
+
modalBox,
|
|
2954
|
+
enter,
|
|
2955
|
+
exitDone,
|
|
2956
|
+
enterActive,
|
|
2957
|
+
exit
|
|
2958
|
+
};
|
|
2959
|
+
function Modal({
|
|
2960
|
+
visible = false,
|
|
2961
|
+
children,
|
|
2962
|
+
onClickOutside
|
|
2963
|
+
}) {
|
|
2964
|
+
const modalBoxRef = useRef();
|
|
2965
|
+
const onClick = useCallback((event) => {
|
|
2966
|
+
if (!modalBoxRef.current.contains(event.target)) {
|
|
2967
|
+
if (onClickOutside && visible)
|
|
2968
|
+
onClickOutside(event);
|
|
2969
|
+
}
|
|
2970
|
+
}, [onClickOutside, visible]);
|
|
2971
|
+
return createPortal(jsx(d, {
|
|
2972
|
+
in: visible,
|
|
2973
|
+
duration: 300,
|
|
2974
|
+
classNames: styles$2,
|
|
2975
|
+
children: jsx("div", {
|
|
2976
|
+
class: styles$2.transitionContainer,
|
|
2977
|
+
onClick,
|
|
2978
|
+
style: {
|
|
2979
|
+
pointerEvents: visible ? "auto" : "none"
|
|
2980
|
+
},
|
|
2981
|
+
children: jsx("div", {
|
|
2982
|
+
ref: modalBoxRef,
|
|
2983
|
+
class: styles$2.modalBox,
|
|
2984
|
+
children
|
|
2985
|
+
})
|
|
2986
|
+
})
|
|
2987
|
+
}), document.body);
|
|
2988
|
+
}
|
|
2939
2989
|
const coalitionsWrapper = "_coalitionsWrapper_1ahqy_9";
|
|
2940
2990
|
const coalitionsContainer = "_coalitionsContainer_1ahqy_14";
|
|
2941
2991
|
const coalition = "_coalition_1ahqy_9";
|
|
@@ -3108,17 +3158,19 @@ function Gradient() {
|
|
|
3108
3158
|
})]
|
|
3109
3159
|
});
|
|
3110
3160
|
}
|
|
3111
|
-
const ticker = "
|
|
3112
|
-
const tickerItems = "
|
|
3113
|
-
const
|
|
3114
|
-
const
|
|
3115
|
-
const
|
|
3116
|
-
const
|
|
3117
|
-
const
|
|
3118
|
-
const
|
|
3161
|
+
const ticker = "_ticker_fyd8z_9";
|
|
3162
|
+
const tickerItems = "_tickerItems_fyd8z_19";
|
|
3163
|
+
const tickerScroll = "_tickerScroll_fyd8z_24";
|
|
3164
|
+
const tickerItem = "_tickerItem_fyd8z_19";
|
|
3165
|
+
const controls = "_controls_fyd8z_46";
|
|
3166
|
+
const gradient = "_gradient_fyd8z_61";
|
|
3167
|
+
const buttons = "_buttons_fyd8z_75";
|
|
3168
|
+
const button = "_button_fyd8z_75";
|
|
3169
|
+
const buttonInner = "_buttonInner_fyd8z_101";
|
|
3119
3170
|
const styles = {
|
|
3120
3171
|
ticker,
|
|
3121
3172
|
tickerItems,
|
|
3173
|
+
tickerScroll,
|
|
3122
3174
|
tickerItem,
|
|
3123
3175
|
controls,
|
|
3124
3176
|
gradient,
|
|
@@ -3126,45 +3178,37 @@ const styles = {
|
|
|
3126
3178
|
button,
|
|
3127
3179
|
buttonInner
|
|
3128
3180
|
};
|
|
3129
|
-
function totalSizeForElements(elements) {
|
|
3130
|
-
return Array.from(elements).reduce((totalSize, element) => {
|
|
3131
|
-
totalSize.width += element.clientWidth;
|
|
3132
|
-
totalSize.height += element.clientHeight;
|
|
3133
|
-
return totalSize;
|
|
3134
|
-
}, {
|
|
3135
|
-
width: 0,
|
|
3136
|
-
height: 0
|
|
3137
|
-
});
|
|
3138
|
-
}
|
|
3139
3181
|
function Ticker({
|
|
3140
3182
|
maxItems = 20,
|
|
3141
3183
|
onStateChange,
|
|
3142
3184
|
children
|
|
3143
3185
|
}) {
|
|
3144
|
-
const [
|
|
3186
|
+
const [pageIndex, setPageIndex] = useState(0);
|
|
3187
|
+
const [pageWidth, setPageWidth] = useState(0);
|
|
3188
|
+
const [numberOfPages, setNumberOfPages] = useState(0);
|
|
3189
|
+
const offsetWidth = useMemo(() => {
|
|
3190
|
+
return -pageIndex * (pageWidth || 0);
|
|
3191
|
+
}, [pageIndex, pageWidth]);
|
|
3145
3192
|
const windowSize = useWindowSize();
|
|
3146
3193
|
const tickerRef = useRef();
|
|
3147
3194
|
const tickerItemsRef = useRef();
|
|
3195
|
+
const tickerScrollRef = useRef();
|
|
3196
|
+
const controlsRef = useRef();
|
|
3148
3197
|
const [hideButtons, setHideButtons] = useState(false);
|
|
3149
|
-
const [nextButtonDisabled, setNextButtonDisabled] = useState(false);
|
|
3150
3198
|
const [expanded, setExpanded] = useState(false);
|
|
3151
3199
|
const childArray = toChildArray(children);
|
|
3152
3200
|
useLayoutEffect(() => {
|
|
3153
3201
|
const tickerItemsContainer = tickerItemsRef.current;
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
setNextButtonDisabled(nextButtonDisabled2);
|
|
3165
|
-
}
|
|
3166
|
-
}
|
|
3167
|
-
}, [offset, windowSize, childArray, setHideButtons, setNextButtonDisabled]);
|
|
3202
|
+
const pageWidth2 = tickerItemsContainer.clientWidth * 0.75;
|
|
3203
|
+
setPageWidth(pageWidth2);
|
|
3204
|
+
const numberOfPages2 = Math.ceil(tickerScrollRef.current.scrollWidth / pageWidth2);
|
|
3205
|
+
setNumberOfPages(numberOfPages2);
|
|
3206
|
+
}, []);
|
|
3207
|
+
useLayoutEffect(() => {
|
|
3208
|
+
const tickerItemsContainer = tickerItemsRef.current;
|
|
3209
|
+
const hideButtons2 = windowSize.width >= 480 ? tickerScrollRef.current.scrollWidth <= tickerItemsContainer.clientWidth : tickerScrollRef.current.scrollHeight <= tickerItemsContainer.clientHeight;
|
|
3210
|
+
setHideButtons(hideButtons2);
|
|
3211
|
+
}, [windowSize, setHideButtons]);
|
|
3168
3212
|
function toggleExpandedState() {
|
|
3169
3213
|
setExpanded((expanded2) => {
|
|
3170
3214
|
const newState = !expanded2;
|
|
@@ -3178,32 +3222,37 @@ function Ticker({
|
|
|
3178
3222
|
return jsxs("div", {
|
|
3179
3223
|
ref: tickerRef,
|
|
3180
3224
|
className: styles.ticker,
|
|
3181
|
-
style: `--ticker-offset: ${
|
|
3225
|
+
style: `--ticker-offset: ${offsetWidth}px;`,
|
|
3182
3226
|
"data-expanded": expanded,
|
|
3183
3227
|
children: [jsx("div", {
|
|
3184
3228
|
ref: tickerItemsRef,
|
|
3185
3229
|
className: styles.tickerItems,
|
|
3186
|
-
children:
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3230
|
+
children: jsx("div", {
|
|
3231
|
+
ref: tickerScrollRef,
|
|
3232
|
+
className: styles.tickerScroll,
|
|
3233
|
+
children: childArray.map((child, index2) => jsx("div", {
|
|
3234
|
+
className: styles.tickerItem,
|
|
3235
|
+
children: child
|
|
3236
|
+
}, index2))
|
|
3237
|
+
})
|
|
3190
3238
|
}), jsxs("div", {
|
|
3239
|
+
ref: controlsRef,
|
|
3191
3240
|
className: styles.controls,
|
|
3192
3241
|
style: hideButtons && {
|
|
3193
3242
|
display: "none"
|
|
3194
3243
|
},
|
|
3195
3244
|
children: [jsx("div", {
|
|
3196
3245
|
className: styles.gradient,
|
|
3197
|
-
children: jsx(Gradient, {})
|
|
3246
|
+
children: !expanded && jsx(Gradient, {})
|
|
3198
3247
|
}), jsxs("div", {
|
|
3199
3248
|
className: styles.buttons,
|
|
3200
3249
|
children: [jsx(ArrowButton, {
|
|
3201
|
-
onClick: () =>
|
|
3202
|
-
disabled:
|
|
3250
|
+
onClick: () => setPageIndex((d2) => d2 + 1),
|
|
3251
|
+
disabled: pageIndex >= numberOfPages - 1
|
|
3203
3252
|
}), jsx(ArrowButton, {
|
|
3204
3253
|
direction: "left",
|
|
3205
|
-
onClick: () =>
|
|
3206
|
-
disabled:
|
|
3254
|
+
onClick: () => setPageIndex((d2) => d2 - 1),
|
|
3255
|
+
disabled: pageIndex <= 0
|
|
3207
3256
|
})]
|
|
3208
3257
|
}), jsx("div", {
|
|
3209
3258
|
className: styles.button,
|
|
@@ -3237,6 +3286,7 @@ export {
|
|
|
3237
3286
|
Map$1 as Map,
|
|
3238
3287
|
MapConfiguration,
|
|
3239
3288
|
index as MapLayers,
|
|
3289
|
+
Modal,
|
|
3240
3290
|
PageSection,
|
|
3241
3291
|
PartyProfile,
|
|
3242
3292
|
Projection,
|