@guardian/interactive-component-library 0.1.0-alpha.20 → 0.1.0-alpha.21

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.
@@ -18,6 +18,8 @@ const defaultStyles$t = {
18
18
  active
19
19
  };
20
20
  function mergeStyles(firstStyle, secondStyle) {
21
+ if (!firstStyle)
22
+ return secondStyle;
21
23
  if (!secondStyle)
22
24
  return firstStyle;
23
25
  if (typeof firstStyle === "string") {
@@ -28,14 +30,7 @@ function mergeStyles(firstStyle, secondStyle) {
28
30
  }
29
31
  const allKeys = /* @__PURE__ */ new Set([...Object.keys(firstStyle), ...Object.keys(secondStyle)]);
30
32
  const merged = Array.from(allKeys).reduce((result, key) => {
31
- const classNames = [];
32
- if (firstStyle && key in firstStyle) {
33
- classNames.push(firstStyle[key]);
34
- }
35
- if (secondStyle && key in secondStyle) {
36
- classNames.push(secondStyle[key]);
37
- }
38
- result[key] = classNames.join(" ");
33
+ result[key] = mergeStyles(firstStyle[key], secondStyle[key]);
39
34
  return result;
40
35
  }, {});
41
36
  return merged;
@@ -44,9 +39,14 @@ const DIRECTION = {
44
39
  up: "up",
45
40
  down: "down"
46
41
  };
42
+ const SIZE = {
43
+ small: "small",
44
+ large: "large"
45
+ };
47
46
  function Chevron({
48
47
  active: active2 = false,
49
48
  direction = DIRECTION.down,
49
+ size = SIZE.small,
50
50
  styles: styles2
51
51
  }) {
52
52
  const defaultStylesCopy = {
@@ -59,6 +59,15 @@ function Chevron({
59
59
  defaultStylesCopy.group = mergeStyles(defaultStyles$t.group, defaultStyles$t.rotated);
60
60
  }
61
61
  styles2 = mergeStyles(defaultStylesCopy, styles2);
62
+ return size === SIZE.small ? jsx(SmallChevron, {
63
+ styles: styles2
64
+ }) : jsx(LargeChevron, {
65
+ styles: styles2
66
+ });
67
+ }
68
+ function SmallChevron({
69
+ styles: styles2
70
+ }) {
62
71
  return jsx("svg", {
63
72
  width: "16",
64
73
  height: "24",
@@ -78,15 +87,34 @@ function Chevron({
78
87
  })
79
88
  });
80
89
  }
90
+ function LargeChevron({
91
+ styles: styles2
92
+ }) {
93
+ return jsx("svg", {
94
+ width: "15",
95
+ height: "19",
96
+ className: styles2.svg,
97
+ viewBox: "0 0 15 19",
98
+ fill: "none",
99
+ xmlns: "http://www.w3.org/2000/svg",
100
+ children: jsx("g", {
101
+ className: styles2.group,
102
+ children: jsx("path", {
103
+ d: "M0.667809 7.5L6.81507 12.1053L8.18493 12.1053L14.3322 7.5L15 8.09868L7.84247 14.5L7.15753 14.5L-2.61693e-08 8.09868L0.667809 7.5Z",
104
+ className: styles2.path
105
+ })
106
+ })
107
+ });
108
+ }
81
109
  const container$5 = "_container_jzalm_1";
82
110
  const dot = "_dot_jzalm_6";
83
111
  const circle$2 = "_circle_jzalm_13";
84
- const text$4 = "_text_jzalm_17";
112
+ const text$3 = "_text_jzalm_17";
85
113
  const defaultStyles$s = {
86
114
  container: container$5,
87
115
  dot,
88
116
  circle: circle$2,
89
- text: text$4
117
+ text: text$3
90
118
  };
91
119
  const DOT_TYPE = {
92
120
  round: "round",
@@ -187,7 +215,7 @@ function StackedBar({
187
215
  x: config.x,
188
216
  y: config.y,
189
217
  textAnchor: config.textAnchor,
190
- alignmentBaseline: config.alignmentBaseline,
218
+ dominantBaseline: config.dominantBaseline,
191
219
  children: config.value
192
220
  }, `label-${i}`);
193
221
  let totalWidth = 0;
@@ -198,7 +226,7 @@ function StackedBar({
198
226
  x: itemWidth - 4,
199
227
  y: height / 2,
200
228
  textAnchor: "end",
201
- alignmentBaseline: "central"
229
+ dominantBaseline: "middle"
202
230
  };
203
231
  const value = jsxs("g", {
204
232
  transform: `translate(${totalWidth}, 0)`,
@@ -225,7 +253,7 @@ function StackedBar({
225
253
  y: height + 4,
226
254
  value: d2.label,
227
255
  textAnchor: "end",
228
- alignmentBaseline: "hanging"
256
+ dominantBaseline: "hanging"
229
257
  };
230
258
  totalW += itemWidth;
231
259
  return labelConfig;
@@ -285,7 +313,7 @@ function createStore(initialStore) {
285
313
  return () => {
286
314
  listeners.delete(listener);
287
315
  };
288
- }, []);
316
+ }, [selectorFn]);
289
317
  const syncedStore = useSyncExternalStore(subscribe, getStore, getServerStore);
290
318
  return selectorFn(syncedStore);
291
319
  }
@@ -392,10 +420,10 @@ function GradientDefs({
392
420
  })
393
421
  });
394
422
  }
395
- const button$4 = "_button_oqopj_1";
423
+ const button$5 = "_button_oqopj_1";
396
424
  const svg$7 = "_svg_oqopj_15";
397
425
  const defaultStyles$p = {
398
- button: button$4,
426
+ button: button$5,
399
427
  svg: svg$7
400
428
  };
401
429
  const InfoButton = ({
@@ -450,9 +478,9 @@ const CircleIcon = ({
450
478
  })
451
479
  });
452
480
  };
453
- const text$3 = "_text_1okyv_1";
481
+ const text$2 = "_text_1okyv_1";
454
482
  const defaultStyles$n = {
455
- text: text$3
483
+ text: text$2
456
484
  };
457
485
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
458
486
  function getDefaultExportFromCjs(x) {
@@ -990,11 +1018,11 @@ const SquareIcon = ({
990
1018
  })
991
1019
  });
992
1020
  };
993
- const button$3 = "_button_1fees_1";
994
- const icon = "_icon_1fees_6";
1021
+ const button$4 = "_button_1fees_1";
1022
+ const icon$2 = "_icon_1fees_6";
995
1023
  const defaultStyles$h = {
996
- button: button$3,
997
- icon
1024
+ button: button$4,
1025
+ icon: icon$2
998
1026
  };
999
1027
  function ArrowButton({
1000
1028
  direction = "right",
@@ -1026,10 +1054,10 @@ function ArrowButton({
1026
1054
  })
1027
1055
  });
1028
1056
  }
1029
- const button$2 = "_button_3521c_1";
1057
+ const button$3 = "_button_3521c_1";
1030
1058
  const buttonInner$1 = "_buttonInner_3521c_6";
1031
1059
  const defaultStyles$g = {
1032
- button: button$2,
1060
+ button: button$3,
1033
1061
  buttonInner: buttonInner$1
1034
1062
  };
1035
1063
  function Button({
@@ -1049,12 +1077,12 @@ function Button({
1049
1077
  })
1050
1078
  });
1051
1079
  }
1052
- const button$1 = "_button_125im_1";
1080
+ const button$2 = "_button_125im_1";
1053
1081
  const buttonBorder = "_buttonBorder_125im_11";
1054
1082
  const svg$3 = "_svg_125im_19";
1055
1083
  const path$3 = "_path_125im_25";
1056
1084
  const defaultStyles$f = {
1057
- button: button$1,
1085
+ button: button$2,
1058
1086
  buttonBorder,
1059
1087
  svg: svg$3,
1060
1088
  path: path$3
@@ -1629,7 +1657,7 @@ const enter$1 = "_enter_1gzlr_21";
1629
1657
  const exitDone$1 = "_exitDone_1gzlr_22";
1630
1658
  const enterActive$1 = "_enterActive_1gzlr_31";
1631
1659
  const exit$1 = "_exit_1gzlr_22";
1632
- const styles$5 = {
1660
+ const styles$6 = {
1633
1661
  transitionContainer: transitionContainer$1,
1634
1662
  modalBox: modalBox$1,
1635
1663
  enter: enter$1,
@@ -1644,12 +1672,12 @@ function Modal$1({
1644
1672
  return jsx(d, {
1645
1673
  in: visible,
1646
1674
  duration: 300,
1647
- classNames: styles$5,
1675
+ classNames: styles$6,
1648
1676
  alwaysMounted: true,
1649
1677
  children: jsx("div", {
1650
- class: styles$5.transitionContainer,
1678
+ class: styles$6.transitionContainer,
1651
1679
  children: jsx("div", {
1652
- class: styles$5.modalBox,
1680
+ class: styles$6.modalBox,
1653
1681
  children
1654
1682
  })
1655
1683
  })
@@ -1778,10 +1806,10 @@ function tooltipPositionForRect({
1778
1806
  }
1779
1807
  return newPosition;
1780
1808
  }
1781
- const text$2 = "_text_1b8t2_1";
1809
+ const text$1 = "_text_1b8t2_1";
1782
1810
  const container$3 = "_container_1b8t2_10";
1783
1811
  const defaultStyles$a = {
1784
- text: text$2,
1812
+ text: text$1,
1785
1813
  container: container$3
1786
1814
  };
1787
1815
  const ControlChange = ({
@@ -1952,11 +1980,11 @@ const PageSection = forwardRef(({
1952
1980
  })]
1953
1981
  });
1954
1982
  });
1955
- const text$1 = "_text_lo5h3_1";
1983
+ const text = "_text_lo5h3_1";
1956
1984
  const axis = "_axis_lo5h3_6";
1957
1985
  const bar = "_bar_lo5h3_10";
1958
1986
  const defaultStyles$7 = {
1959
- text: text$1,
1987
+ text,
1960
1988
  axis,
1961
1989
  bar
1962
1990
  };
@@ -2006,58 +2034,56 @@ const ColumnChart = ({
2006
2034
  })]
2007
2035
  });
2008
2036
  };
2009
- const text = "_text_vd5ly_1";
2010
- const container$2 = "_container_vd5ly_9";
2011
- const title$1 = "_title_vd5ly_16";
2012
- const subtitle = "_subtitle_vd5ly_33";
2013
- const blurb = "_blurb_vd5ly_44";
2014
- const leftCell = "_leftCell_vd5ly_55";
2015
- const rightCell = "_rightCell_vd5ly_55";
2016
- const mugshot = "_mugshot_vd5ly_71";
2037
+ const container$2 = "_container_1snyq_1";
2038
+ const img = "_img_1snyq_7";
2039
+ const title$2 = "_title_1snyq_15";
2040
+ const subtitle = "_subtitle_1snyq_31";
2041
+ const small = "_small_1snyq_41";
2042
+ const blurb = "_blurb_1snyq_51";
2043
+ const footnote = "_footnote_1snyq_59";
2017
2044
  const defaultStyles$6 = {
2018
- text,
2019
2045
  container: container$2,
2020
- title: title$1,
2046
+ img,
2047
+ title: title$2,
2021
2048
  subtitle,
2049
+ small,
2022
2050
  blurb,
2023
- leftCell,
2024
- rightCell,
2025
- mugshot
2051
+ footnote
2052
+ };
2053
+ const SubtitleStyle = {
2054
+ small: "small",
2055
+ large: "large"
2026
2056
  };
2027
2057
  const PartyProfile = ({
2028
- styles: styles2,
2029
2058
  title: title2,
2030
2059
  subtitle: subtitle2,
2060
+ subtitleStyle = SubtitleStyle.large,
2031
2061
  blurb: blurb2,
2062
+ footnote: footnote2,
2032
2063
  imgSrc,
2033
- abbreviation
2064
+ styles: styles2
2034
2065
  }) => {
2035
2066
  styles2 = mergeStyles({
2036
2067
  ...defaultStyles$6
2037
2068
  }, styles2);
2038
- return jsx("div", {
2069
+ return jsxs("div", {
2039
2070
  class: styles2.container,
2040
- children: jsxs(Fragment, {
2041
- children: [jsxs("div", {
2042
- className: styles2.leftCell,
2043
- children: [jsx("h3", {
2044
- className: `${styles2.title}`,
2045
- children: title2
2046
- }), jsx("div", {
2047
- className: styles2.subtitle,
2048
- children: subtitle2
2049
- }), jsx("div", {
2050
- className: styles2.blurb,
2051
- children: blurb2
2052
- })]
2053
- }), jsx("div", {
2054
- className: styles2.rightCell,
2055
- children: jsx("img", {
2056
- src: imgSrc,
2057
- className: `${styles2.mugshot} bg-color--${abbreviation}`
2058
- })
2059
- })]
2060
- })
2071
+ children: [jsx("img", {
2072
+ src: imgSrc,
2073
+ className: styles2.img
2074
+ }), jsx("h3", {
2075
+ className: styles2.title,
2076
+ children: title2
2077
+ }), jsx("div", {
2078
+ className: [styles2.subtitle, styles2[subtitleStyle]].join(" "),
2079
+ children: subtitle2
2080
+ }), jsx("div", {
2081
+ className: styles2.blurb,
2082
+ children: blurb2
2083
+ }), jsx("div", {
2084
+ className: styles2.footnote,
2085
+ children: footnote2
2086
+ })]
2061
2087
  });
2062
2088
  };
2063
2089
  var epsilon$1 = 1e-6;
@@ -2472,7 +2498,7 @@ function useContainerSize(containerRef) {
2472
2498
  }
2473
2499
  const container$1 = "_container_cyrny_1";
2474
2500
  const svg$1 = "_svg_cyrny_6";
2475
- const styles$4 = {
2501
+ const styles$5 = {
2476
2502
  container: container$1,
2477
2503
  svg: svg$1
2478
2504
  };
@@ -2720,7 +2746,7 @@ const Map$1 = forwardRef(({
2720
2746
  const renderSVG = containerSize && !config.drawToCanvas;
2721
2747
  return jsx("div", {
2722
2748
  ref: containerRef,
2723
- className: styles$4.container,
2749
+ className: styles$5.container,
2724
2750
  style: containerStyle,
2725
2751
  children: renderSVG && jsx(SVGMapProvider, {
2726
2752
  id,
@@ -2772,7 +2798,7 @@ function ResultSummary({
2772
2798
  }
2773
2799
  const svg = "_svg_1dms8_1";
2774
2800
  const path = "_path_1dms8_8";
2775
- const styles$3 = {
2801
+ const styles$4 = {
2776
2802
  svg,
2777
2803
  path
2778
2804
  };
@@ -2780,9 +2806,9 @@ function SearchIcon() {
2780
2806
  return jsx("svg", {
2781
2807
  viewBox: "0 0 20 20",
2782
2808
  xmlns: "http://www.w3.org/2000/svg",
2783
- className: styles$3.svg,
2809
+ className: styles$4.svg,
2784
2810
  children: jsx("path", {
2785
- className: styles$3.path,
2811
+ className: styles$4.path,
2786
2812
  "fill-rule": "evenodd",
2787
2813
  "clip-rule": "evenodd",
2788
2814
  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"
@@ -2927,11 +2953,13 @@ function SuggestionList({
2927
2953
  })
2928
2954
  });
2929
2955
  }
2930
- const refreshIndicator = "_refreshIndicator_u6lji_1";
2931
- const liveText = "_liveText_u6lji_8";
2932
- const refreshText = "_refreshText_u6lji_9";
2956
+ const refreshIndicator = "_refreshIndicator_3z0ji_9";
2957
+ const icon$1 = "_icon_3z0ji_17";
2958
+ const liveText = "_liveText_3z0ji_26";
2959
+ const refreshText = "_refreshText_3z0ji_27";
2933
2960
  const defaultStyles$2 = {
2934
2961
  refreshIndicator,
2962
+ icon: icon$1,
2935
2963
  liveText,
2936
2964
  refreshText
2937
2965
  };
@@ -2942,8 +2970,11 @@ function RefreshIndicator({
2942
2970
  styles2 = mergeStyles(defaultStyles$2, styles2);
2943
2971
  return jsxs("div", {
2944
2972
  className: styles2.refreshIndicator,
2945
- children: [jsx(CircleIcon, {
2946
- pulse: true
2973
+ children: [jsx("span", {
2974
+ className: styles2.icon,
2975
+ children: jsx(CircleIcon, {
2976
+ pulse: true
2977
+ })
2947
2978
  }), jsx("span", {
2948
2979
  className: styles2.liveText,
2949
2980
  children: "LIVE"
@@ -2987,7 +3018,7 @@ const enter = "_enter_wws3j_21";
2987
3018
  const exitDone = "_exitDone_wws3j_22";
2988
3019
  const enterActive = "_enterActive_wws3j_31";
2989
3020
  const exit = "_exit_wws3j_22";
2990
- const styles$2 = {
3021
+ const styles$3 = {
2991
3022
  transitionContainer,
2992
3023
  modalBox,
2993
3024
  enter,
@@ -3010,21 +3041,123 @@ function Modal({
3010
3041
  return createPortal(jsx(d, {
3011
3042
  in: visible,
3012
3043
  duration: 300,
3013
- classNames: styles$2,
3044
+ classNames: styles$3,
3014
3045
  children: jsx("div", {
3015
- class: styles$2.transitionContainer,
3046
+ class: styles$3.transitionContainer,
3016
3047
  onClick,
3017
3048
  style: {
3018
3049
  pointerEvents: visible ? "auto" : "none"
3019
3050
  },
3020
3051
  children: jsx("div", {
3021
3052
  ref: modalBoxRef,
3022
- class: styles$2.modalBox,
3053
+ class: styles$3.modalBox,
3023
3054
  children
3024
3055
  })
3025
3056
  })
3026
3057
  }), document.body);
3027
3058
  }
3059
+ const button$1 = "_button_xeyqm_1";
3060
+ const icon = "_icon_xeyqm_17";
3061
+ const title$1 = "_title_xeyqm_22";
3062
+ const popout = "_popout_xeyqm_29";
3063
+ const hint = "_hint_xeyqm_44";
3064
+ const option = "_option_xeyqm_51";
3065
+ const optionIcon = "_optionIcon_xeyqm_71";
3066
+ const optionTitle = "_optionTitle_xeyqm_76";
3067
+ const optionDescription = "_optionDescription_xeyqm_84";
3068
+ const checkmark = "_checkmark_xeyqm_91";
3069
+ const checkmarkPath = "_checkmarkPath_xeyqm_97";
3070
+ const styles$2 = {
3071
+ button: button$1,
3072
+ icon,
3073
+ title: title$1,
3074
+ popout,
3075
+ hint,
3076
+ option,
3077
+ optionIcon,
3078
+ optionTitle,
3079
+ optionDescription,
3080
+ checkmark,
3081
+ checkmarkPath
3082
+ };
3083
+ function Dropdown({
3084
+ title: title2,
3085
+ hint: hint2,
3086
+ options,
3087
+ onSelect
3088
+ }) {
3089
+ const [expanded, setExpanded] = useState(true);
3090
+ const [selectedIndex, setSelectedIndex] = useState(0);
3091
+ const onOptionClick = useCallback((option2, index2) => {
3092
+ setSelectedIndex(index2);
3093
+ if (onSelect)
3094
+ onSelect(option2, index2);
3095
+ }, [onSelect]);
3096
+ const iconForSelectedOption = useMemo(() => {
3097
+ const selectedOption = options[selectedIndex];
3098
+ return selectedOption.icon;
3099
+ }, [options, selectedIndex]);
3100
+ return jsxs("div", {
3101
+ children: [jsxs("button", {
3102
+ className: styles$2.button,
3103
+ onClick: () => setExpanded((current) => !current),
3104
+ children: [jsx("img", {
3105
+ src: iconForSelectedOption,
3106
+ className: styles$2.icon
3107
+ }), jsx("span", {
3108
+ className: styles$2.title,
3109
+ children: title2
3110
+ }), jsx(Chevron, {
3111
+ active: true,
3112
+ size: "large",
3113
+ direction: expanded ? "up" : "down"
3114
+ })]
3115
+ }), jsxs("div", {
3116
+ className: styles$2.popout,
3117
+ style: {
3118
+ visibility: expanded ? "visible" : "hidden"
3119
+ },
3120
+ children: [hint2 && jsx("p", {
3121
+ className: styles$2.hint,
3122
+ children: hint2
3123
+ }), options.map((option2, index2) => jsxs("button", {
3124
+ className: styles$2.option,
3125
+ onClick: () => onOptionClick(option2, index2),
3126
+ children: [jsx("img", {
3127
+ src: option2.icon,
3128
+ className: styles$2.optionIcon
3129
+ }), jsxs("div", {
3130
+ className: styles$2.optionText,
3131
+ children: [jsx("h4", {
3132
+ className: styles$2.optionTitle,
3133
+ children: option2.title
3134
+ }), jsx("p", {
3135
+ className: styles$2.optionDescription,
3136
+ children: option2.description
3137
+ })]
3138
+ }), index2 === selectedIndex && jsx("div", {
3139
+ className: styles$2.checkmark,
3140
+ children: jsx(Checkmark, {})
3141
+ })]
3142
+ }, option2.title))]
3143
+ })]
3144
+ });
3145
+ }
3146
+ function Checkmark() {
3147
+ return jsx("svg", {
3148
+ width: "11",
3149
+ height: "9",
3150
+ viewBox: "0 0 11 9",
3151
+ fill: "none",
3152
+ xmlns: "http://www.w3.org/2000/svg",
3153
+ children: jsx("path", {
3154
+ "fill-rule": "evenodd",
3155
+ "clip-rule": "evenodd",
3156
+ d: "M0.631814 4.43687L0.0839844 4.9847L2.82313 8.8195H3.08335L10.9173 0.711624L10.3695 0.17749L3.08335 6.77884L0.631814 4.43687Z",
3157
+ className: styles$2.checkmarkPath
3158
+ })
3159
+ });
3160
+ }
3028
3161
  const coalitionsWrapper = "_coalitionsWrapper_1ahqy_9";
3029
3162
  const coalitionsContainer = "_coalitionsContainer_1ahqy_14";
3030
3163
  const coalition = "_coalition_1ahqy_9";
@@ -3319,6 +3452,7 @@ export {
3319
3452
  ColumnChart,
3320
3453
  Container,
3321
3454
  ControlChange,
3455
+ Dropdown,
3322
3456
  GradientIcon,
3323
3457
  GridType,
3324
3458
  InfoButton,