@guardian/interactive-component-library 0.1.0-alpha.23 → 0.1.0-alpha.24
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.
|
@@ -1133,8 +1133,8 @@ const SquareIcon = ({
|
|
|
1133
1133
|
})
|
|
1134
1134
|
});
|
|
1135
1135
|
};
|
|
1136
|
-
const button$4 = "
|
|
1137
|
-
const icon$2 = "
|
|
1136
|
+
const button$4 = "_button_1kqfn_1";
|
|
1137
|
+
const icon$2 = "_icon_1kqfn_6";
|
|
1138
1138
|
const defaultStyles$i = {
|
|
1139
1139
|
button: button$4,
|
|
1140
1140
|
icon: icon$2
|
|
@@ -1169,8 +1169,8 @@ function ArrowButton({
|
|
|
1169
1169
|
})
|
|
1170
1170
|
});
|
|
1171
1171
|
}
|
|
1172
|
-
const button$3 = "
|
|
1173
|
-
const buttonInner$1 = "
|
|
1172
|
+
const button$3 = "_button_s6ell_1";
|
|
1173
|
+
const buttonInner$1 = "_buttonInner_s6ell_6";
|
|
1174
1174
|
const defaultStyles$h = {
|
|
1175
1175
|
button: button$3,
|
|
1176
1176
|
buttonInner: buttonInner$1
|
|
@@ -1192,10 +1192,10 @@ function Button({
|
|
|
1192
1192
|
})
|
|
1193
1193
|
});
|
|
1194
1194
|
}
|
|
1195
|
-
const button$2 = "
|
|
1196
|
-
const buttonBorder = "
|
|
1197
|
-
const svg$3 = "
|
|
1198
|
-
const path$3 = "
|
|
1195
|
+
const button$2 = "_button_nr8bh_1";
|
|
1196
|
+
const buttonBorder = "_buttonBorder_nr8bh_11";
|
|
1197
|
+
const svg$3 = "_svg_nr8bh_19";
|
|
1198
|
+
const path$3 = "_path_nr8bh_25";
|
|
1199
1199
|
const defaultStyles$g = {
|
|
1200
1200
|
button: button$2,
|
|
1201
1201
|
buttonBorder,
|
|
@@ -3091,6 +3091,18 @@ function Modal({
|
|
|
3091
3091
|
onClickOutside(event);
|
|
3092
3092
|
}
|
|
3093
3093
|
}, [onClickOutside, visible]);
|
|
3094
|
+
useEffect(() => {
|
|
3095
|
+
if (visible) {
|
|
3096
|
+
window.addEventListener("scroll", onClick, {
|
|
3097
|
+
once: true
|
|
3098
|
+
});
|
|
3099
|
+
}
|
|
3100
|
+
return () => {
|
|
3101
|
+
if (visible) {
|
|
3102
|
+
window.removeEventListener("scroll", onClick);
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
}, [onClick, visible]);
|
|
3094
3106
|
return createPortal(jsx(d, {
|
|
3095
3107
|
in: visible,
|
|
3096
3108
|
duration: 300,
|
|
@@ -3139,14 +3151,18 @@ function Dropdown({
|
|
|
3139
3151
|
title: title2,
|
|
3140
3152
|
hint: hint2,
|
|
3141
3153
|
options,
|
|
3142
|
-
onSelect
|
|
3154
|
+
onSelect,
|
|
3155
|
+
collapseOnSelect = false,
|
|
3156
|
+
expandByDefault = true
|
|
3143
3157
|
}) {
|
|
3144
|
-
const [expanded, setExpanded] = useState(
|
|
3158
|
+
const [expanded, setExpanded] = useState(expandByDefault);
|
|
3145
3159
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
3146
3160
|
const onOptionClick = useCallback((option2, index2) => {
|
|
3147
3161
|
setSelectedIndex(index2);
|
|
3148
3162
|
if (onSelect)
|
|
3149
3163
|
onSelect(option2, index2);
|
|
3164
|
+
if (collapseOnSelect)
|
|
3165
|
+
setExpanded(false);
|
|
3150
3166
|
}, [onSelect]);
|
|
3151
3167
|
const iconForSelectedOption = useMemo(() => {
|
|
3152
3168
|
const selectedOption = options[selectedIndex];
|