@guardian/interactive-component-library 0.1.0-alpha.25 → 0.1.0-alpha.27

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.
@@ -1495,19 +1495,21 @@
1495
1495
  })]
1496
1496
  });
1497
1497
  }
1498
- const slopeChartContainer = "_slopeChartContainer_gj7pr_1";
1499
- const svg$2 = "_svg_gj7pr_5";
1500
- const line$1 = "_line_gj7pr_9";
1501
- const circle = "_circle_gj7pr_14";
1502
- const label = "_label_gj7pr_18";
1503
- const y1Label = "_y1Label_gj7pr_24";
1504
- const y2Label = "_y2Label_gj7pr_28";
1505
- const axis$1 = "_axis_gj7pr_32";
1506
- const axisLabel = "_axisLabel_gj7pr_37";
1498
+ const slopeChartContainer = "_slopeChartContainer_nmjjj_1";
1499
+ const svg$2 = "_svg_nmjjj_5";
1500
+ const line$1 = "_line_nmjjj_9";
1501
+ const lineWhite = "_lineWhite_nmjjj_14";
1502
+ const circle = "_circle_nmjjj_19";
1503
+ const label = "_label_nmjjj_23";
1504
+ const y1Label = "_y1Label_nmjjj_29";
1505
+ const y2Label = "_y2Label_nmjjj_33";
1506
+ const axis$1 = "_axis_nmjjj_37";
1507
+ const axisLabel = "_axisLabel_nmjjj_42";
1507
1508
  const defaultStyles$d = {
1508
1509
  slopeChartContainer,
1509
1510
  svg: svg$2,
1510
1511
  line: line$1,
1512
+ lineWhite,
1511
1513
  circle,
1512
1514
  label,
1513
1515
  y1Label,
@@ -1588,6 +1590,12 @@
1588
1590
  }, line2.styles);
1589
1591
  return jsxRuntime.jsxs("g", {
1590
1592
  children: [jsxRuntime.jsx("line", {
1593
+ x1: 0,
1594
+ y1: yScale(line2.y1),
1595
+ x2: contentWidth,
1596
+ y2: yScale(line2.y2),
1597
+ className: `${itemStyles.lineWhite}`
1598
+ }), jsxRuntime.jsx("line", {
1591
1599
  x1: 0,
1592
1600
  y1: yScale(line2.y1),
1593
1601
  x2: contentWidth,
@@ -1948,10 +1956,10 @@
1948
1956
  })]
1949
1957
  });
1950
1958
  });
1951
- const section = "_section_12aiu_9";
1952
- const borderTop = "_borderTop_12aiu_52";
1953
- const header = "_header_12aiu_56";
1954
- const content = "_content_12aiu_76";
1959
+ const section = "_section_4s2t4_9";
1960
+ const borderTop = "_borderTop_4s2t4_52";
1961
+ const header = "_header_4s2t4_56";
1962
+ const content = "_content_4s2t4_77";
1955
1963
  const defaultStyles$8 = {
1956
1964
  section,
1957
1965
  borderTop,
@@ -2044,13 +2052,13 @@
2044
2052
  })]
2045
2053
  });
2046
2054
  };
2047
- const container$3 = "_container_1snyq_1";
2048
- const img = "_img_1snyq_7";
2049
- const title$2 = "_title_1snyq_15";
2050
- const subtitle = "_subtitle_1snyq_31";
2051
- const small = "_small_1snyq_41";
2052
- const blurb = "_blurb_1snyq_51";
2053
- const footnote = "_footnote_1snyq_59";
2055
+ const container$3 = "_container_hbk39_1";
2056
+ const img = "_img_hbk39_5";
2057
+ const title$2 = "_title_hbk39_13";
2058
+ const subtitle = "_subtitle_hbk39_29";
2059
+ const small = "_small_hbk39_39";
2060
+ const blurb = "_blurb_hbk39_49";
2061
+ const footnote = "_footnote_hbk39_57";
2054
2062
  const defaultStyles$6 = {
2055
2063
  container: container$3,
2056
2064
  img,
@@ -2071,6 +2079,7 @@
2071
2079
  blurb: blurb2,
2072
2080
  footnote: footnote2,
2073
2081
  imgSrc,
2082
+ imgAltText,
2074
2083
  styles: styles2
2075
2084
  }) => {
2076
2085
  styles2 = mergeStyles({
@@ -2080,7 +2089,8 @@
2080
2089
  class: styles2.container,
2081
2090
  children: [jsxRuntime.jsx("img", {
2082
2091
  src: imgSrc,
2083
- className: styles2.img
2092
+ className: styles2.img,
2093
+ alt: imgAltText
2084
2094
  }), jsxRuntime.jsx("h3", {
2085
2095
  className: styles2.title,
2086
2096
  children: title2
@@ -3130,18 +3140,19 @@
3130
3140
  })
3131
3141
  }), document.body);
3132
3142
  }
3133
- const container = "_container_iozsb_1";
3134
- const button$1 = "_button_iozsb_6";
3135
- const icon = "_icon_iozsb_22";
3136
- const title$1 = "_title_iozsb_27";
3137
- const popout = "_popout_iozsb_34";
3138
- const hint = "_hint_iozsb_51";
3139
- const option = "_option_iozsb_58";
3140
- const optionIcon = "_optionIcon_iozsb_79";
3141
- const optionTitle = "_optionTitle_iozsb_84";
3142
- const optionDescription = "_optionDescription_iozsb_92";
3143
- const checkmark = "_checkmark_iozsb_99";
3144
- const checkmarkPath = "_checkmarkPath_iozsb_105";
3143
+ const container = "_container_1enis_1";
3144
+ const button$1 = "_button_1enis_6";
3145
+ const icon = "_icon_1enis_22";
3146
+ const title$1 = "_title_1enis_27";
3147
+ const popout = "_popout_1enis_34";
3148
+ const hint = "_hint_1enis_51";
3149
+ const groupHeader = "_groupHeader_1enis_58";
3150
+ const option = "_option_1enis_65";
3151
+ const optionIcon = "_optionIcon_1enis_86";
3152
+ const optionTitle = "_optionTitle_1enis_91";
3153
+ const optionDescription = "_optionDescription_1enis_99";
3154
+ const checkmark = "_checkmark_1enis_106";
3155
+ const checkmarkPath = "_checkmarkPath_1enis_112";
3145
3156
  const styles$2 = {
3146
3157
  container,
3147
3158
  button: button$1,
@@ -3149,6 +3160,7 @@
3149
3160
  title: title$1,
3150
3161
  popout,
3151
3162
  hint,
3163
+ groupHeader,
3152
3164
  option,
3153
3165
  optionIcon,
3154
3166
  optionTitle,
@@ -3173,10 +3185,29 @@
3173
3185
  if (collapseOnSelect)
3174
3186
  setExpanded(false);
3175
3187
  }, [onSelect]);
3188
+ const optionGroups = hooks.useMemo(() => {
3189
+ const containsOptionGroups = "options" in options[0];
3190
+ if (!containsOptionGroups) {
3191
+ return [{
3192
+ options
3193
+ }];
3194
+ }
3195
+ let optionIndex = 0;
3196
+ for (const group2 of options) {
3197
+ for (const option2 of group2.options) {
3198
+ option2.index = optionIndex;
3199
+ optionIndex++;
3200
+ }
3201
+ }
3202
+ return options;
3203
+ }, options);
3204
+ const flatOptions = hooks.useMemo(() => {
3205
+ return optionGroups.map((group2) => group2.options).flat();
3206
+ }, [optionGroups]);
3176
3207
  const iconForSelectedOption = hooks.useMemo(() => {
3177
- const selectedOption = options[selectedIndex];
3208
+ const selectedOption = flatOptions[selectedIndex];
3178
3209
  return selectedOption.icon;
3179
- }, [options, selectedIndex]);
3210
+ }, [flatOptions, selectedIndex]);
3180
3211
  return jsxRuntime.jsxs("div", {
3181
3212
  className: styles$2.container,
3182
3213
  children: [jsxRuntime.jsxs("button", {
@@ -3201,9 +3232,28 @@
3201
3232
  children: [hint2 && jsxRuntime.jsx("p", {
3202
3233
  className: styles$2.hint,
3203
3234
  children: hint2
3204
- }), options.map((option2, index2) => jsxRuntime.jsxs("button", {
3235
+ }), optionGroups.map((group2) => jsxRuntime.jsx(OptionGroup, {
3236
+ ...group2,
3237
+ selectedIndex,
3238
+ onOptionClick
3239
+ }))]
3240
+ })]
3241
+ });
3242
+ }
3243
+ function OptionGroup({
3244
+ title: title2,
3245
+ options,
3246
+ selectedIndex,
3247
+ onOptionClick
3248
+ }) {
3249
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
3250
+ children: [title2 && jsxRuntime.jsx("span", {
3251
+ className: styles$2.groupHeader,
3252
+ children: title2
3253
+ }), options.map((option2) => {
3254
+ return jsxRuntime.jsxs("button", {
3205
3255
  className: styles$2.option,
3206
- onClick: () => onOptionClick(option2, index2),
3256
+ onClick: () => onOptionClick(option2, option2.index),
3207
3257
  children: [jsxRuntime.jsx("img", {
3208
3258
  src: option2.icon,
3209
3259
  className: styles$2.optionIcon
@@ -3216,11 +3266,11 @@
3216
3266
  className: styles$2.optionDescription,
3217
3267
  children: option2.description
3218
3268
  })]
3219
- }), index2 === selectedIndex && jsxRuntime.jsx("div", {
3269
+ }), option2.index === selectedIndex && jsxRuntime.jsx("div", {
3220
3270
  className: styles$2.checkmark,
3221
3271
  children: jsxRuntime.jsx(Checkmark, {})
3222
3272
  })]
3223
- }, option2.title))]
3273
+ }, option2.title);
3224
3274
  })]
3225
3275
  });
3226
3276
  }