@guardian/interactive-component-library 0.1.0-alpha.15 → 0.1.0-alpha.16
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";
|
|
@@ -3237,6 +3287,7 @@ export {
|
|
|
3237
3287
|
Map$1 as Map,
|
|
3238
3288
|
MapConfiguration,
|
|
3239
3289
|
index as MapLayers,
|
|
3290
|
+
Modal,
|
|
3240
3291
|
PageSection,
|
|
3241
3292
|
PartyProfile,
|
|
3242
3293
|
Projection,
|