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