@mailstep/design-system 0.9.3 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -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
- if (typeof onChange === "function") onChange?.(emptyOptions);
62
- }, [onChange]);
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);
@@ -3,7 +3,9 @@ type Props = {
3
3
  onCustomSelectAll: ({ options }: {
4
4
  options?: Option[];
5
5
  }) => void;
6
- onCustomDeselectAll: () => void;
6
+ onCustomDeselectAll: ({ options }: {
7
+ options?: Option[];
8
+ }) => void;
7
9
  value: SelectProps['value'];
8
10
  options: SelectProps['options'];
9
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,