@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 = "
|
|
1499
|
-
const svg$2 = "
|
|
1500
|
-
const line$1 = "
|
|
1501
|
-
const
|
|
1502
|
-
const
|
|
1503
|
-
const
|
|
1504
|
-
const
|
|
1505
|
-
const
|
|
1506
|
-
const
|
|
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 = "
|
|
1952
|
-
const borderTop = "
|
|
1953
|
-
const header = "
|
|
1954
|
-
const content = "
|
|
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 = "
|
|
2048
|
-
const img = "
|
|
2049
|
-
const title$2 = "
|
|
2050
|
-
const subtitle = "
|
|
2051
|
-
const small = "
|
|
2052
|
-
const blurb = "
|
|
2053
|
-
const footnote = "
|
|
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 = "
|
|
3134
|
-
const button$1 = "
|
|
3135
|
-
const icon = "
|
|
3136
|
-
const title$1 = "
|
|
3137
|
-
const popout = "
|
|
3138
|
-
const hint = "
|
|
3139
|
-
const
|
|
3140
|
-
const
|
|
3141
|
-
const
|
|
3142
|
-
const
|
|
3143
|
-
const
|
|
3144
|
-
const
|
|
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 =
|
|
3208
|
+
const selectedOption = flatOptions[selectedIndex];
|
|
3178
3209
|
return selectedOption.icon;
|
|
3179
|
-
}, [
|
|
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
|
-
}),
|
|
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,
|
|
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
|
-
}),
|
|
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
|
}
|