@mailstep/design-system 0.9.2 → 0.9.4
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.
package/package.json
CHANGED
|
@@ -91,7 +91,7 @@ const StyledButton = styled$1.button`
|
|
|
91
91
|
&[data-variant='outline'] {
|
|
92
92
|
background-color: white;
|
|
93
93
|
border: slim;
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
&[data-appearance='primary'] {
|
|
96
96
|
color: typoPrimary;
|
|
97
97
|
border-color: typoPrimary;
|
|
@@ -114,7 +114,7 @@ const StyledButton = styled$1.button`
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
&[data-appearance='tertiary'] {
|
|
118
118
|
color: dangerColor;
|
|
119
119
|
border-color: dangerColor;
|
|
120
120
|
|
|
@@ -57,9 +57,15 @@ const Select = ({ label, name, value = "", options = emptyOptions, defaultOption
|
|
|
57
57
|
localGetOptionValue,
|
|
58
58
|
resolveOption
|
|
59
59
|
]);
|
|
60
|
-
const unsetAllOptions = useCallback(() => {
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const unsetAllOptions = useCallback(({ options: optionsToRemove }) => {
|
|
61
|
+
const current = Array.isArray(selectedOption) ? selectedOption : selectedOption ? [selectedOption] : [];
|
|
62
|
+
const removeValues = new Set((optionsToRemove || []).map((option) => localGetOptionValue(option)));
|
|
63
|
+
handleChange(current.filter((selected) => !removeValues.has(localGetOptionValue(selected))));
|
|
64
|
+
}, [
|
|
65
|
+
handleChange,
|
|
66
|
+
selectedOption,
|
|
67
|
+
localGetOptionValue
|
|
68
|
+
]);
|
|
63
69
|
const icon = containerVariant === "search" && !placeholderIcon && placeholderIcon !== null ? "search" : placeholderIcon || void 0;
|
|
64
70
|
const modifiedMaxMenuHeight = showSelectAllButton && maxMenuHeight ? maxMenuHeight - 30 : maxMenuHeight;
|
|
65
71
|
const [customComponents, customTheme, customStyles] = useStylesAndComponents(style, optionVariant, multiLabelVariant, containerVariant, useSimplifiedOptions, showSelectAllButton);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { SelectProps, CustomTheme } from '../types';
|
|
2
|
-
import { Option } from '../types';
|
|
1
|
+
import { type SelectProps, type CustomTheme, type Option } from '../types';
|
|
3
2
|
type Props = {
|
|
4
3
|
onCustomSelectAll: ({ options }: {
|
|
5
4
|
options?: Option[];
|
|
6
5
|
}) => void;
|
|
7
|
-
onCustomDeselectAll: (
|
|
6
|
+
onCustomDeselectAll: ({ options }: {
|
|
7
|
+
options?: Option[];
|
|
8
|
+
}) => void;
|
|
8
9
|
value: SelectProps['value'];
|
|
9
10
|
options: SelectProps['options'];
|
|
10
11
|
maxMenuHeight: number;
|
|
@@ -33,7 +33,7 @@ const SelectAll = ({ onCustomSelectAll, onCustomDeselectAll, value, options, max
|
|
|
33
33
|
onCustomSelectAll({ options });
|
|
34
34
|
} else if (isSelected) {
|
|
35
35
|
setIsSelected(false);
|
|
36
|
-
onCustomDeselectAll();
|
|
36
|
+
onCustomDeselectAll({ options });
|
|
37
37
|
}
|
|
38
38
|
}, [
|
|
39
39
|
isSelected,
|
|
@@ -50,13 +50,11 @@ const SelectAll = ({ onCustomSelectAll, onCustomDeselectAll, value, options, max
|
|
|
50
50
|
value
|
|
51
51
|
]);
|
|
52
52
|
useEffect(() => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
options?.length !== value.length && setIsSelected(false);
|
|
56
|
-
}
|
|
53
|
+
const selectedValues = Array.isArray(value) ? value.map((option) => option && typeof option === "object" ? option.value : option) : [];
|
|
54
|
+
setIsSelected(!!options?.length && options.every((option) => selectedValues.includes(option.value)));
|
|
57
55
|
}, [
|
|
58
56
|
maxMenuHeight,
|
|
59
|
-
options
|
|
57
|
+
options,
|
|
60
58
|
value
|
|
61
59
|
]);
|
|
62
60
|
if (!options?.length) return null;
|