@moda/om 21.6.0 → 21.6.2

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.
@@ -2,9 +2,10 @@ import React from 'react';
2
2
  import { TextColor } from '../Text';
3
3
  import './Select.scss';
4
4
  export type SelectExtraOption = {
5
- callback: () => void;
5
+ callback: (event?: React.MouseEvent<HTMLButtonElement>) => void;
6
6
  disabled?: boolean;
7
7
  label: string;
8
+ closeOnClick?: boolean;
8
9
  };
9
10
  export type SelectableOption = {
10
11
  value: string;
@@ -11,5 +11,6 @@ export type SelectOptionsProps = Omit<React.HTMLAttributes<HTMLUListElement>, 'o
11
11
  onSelect(option: SelectableOption): void;
12
12
  dataTestId?: string;
13
13
  extraOption?: SelectExtraOption;
14
+ onCloseDropdown?: () => void;
14
15
  };
15
16
  export declare const SelectOptions: React.FC<SelectOptionsProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda/om",
3
- "version": "21.6.0",
3
+ "version": "21.6.2",
4
4
  "description": "Moda Operandi design system",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -76,11 +76,11 @@
76
76
  "@eslint/js": "^9.31.0",
77
77
  "@moda/rollup-plugin-postcss": "^4.0.1",
78
78
  "@rollup/plugin-babel": "^6.0.4",
79
- "@rollup/plugin-commonjs": "^28.0.6",
79
+ "@rollup/plugin-commonjs": "^29.0.0",
80
80
  "@rollup/plugin-node-resolve": "^16.0.1",
81
81
  "@storybook/addon-links": "^9.0.17",
82
82
  "@storybook/addon-postcss": "^2.0.0",
83
- "@storybook/addon-webpack5-compiler-babel": "^3.0.6",
83
+ "@storybook/addon-webpack5-compiler-babel": "^4.0.0",
84
84
  "@storybook/addons": "^7.6.17",
85
85
  "@storybook/react": "^9.0.17",
86
86
  "@storybook/react-webpack5": "^9.0.17",
@@ -11,7 +11,12 @@ import { useSelect } from './useSelect';
11
11
 
12
12
  import './Select.scss';
13
13
 
14
- export type SelectExtraOption = { callback: () => void; disabled?: boolean; label: string };
14
+ export type SelectExtraOption = {
15
+ callback: (event?: React.MouseEvent<HTMLButtonElement>) => void;
16
+ disabled?: boolean;
17
+ label: string;
18
+ closeOnClick?: boolean;
19
+ };
15
20
 
16
21
  export type SelectableOption = {
17
22
  value: string;
@@ -177,6 +182,7 @@ export const Select: React.FC<SelectProps> = ({
177
182
  onFocus={handleFocus}
178
183
  selectedOption={selected}
179
184
  extraOption={extraOption}
185
+ onCloseDropdown={() => dispatch({ type: 'CLOSE' })}
180
186
  />
181
187
  )}
182
188
  </div>
@@ -23,6 +23,7 @@ export type SelectOptionsProps = Omit<
23
23
  onSelect(option: SelectableOption): void;
24
24
  dataTestId?: string;
25
25
  extraOption?: SelectExtraOption;
26
+ onCloseDropdown?: () => void;
26
27
  };
27
28
 
28
29
  export const SelectOptions: React.FC<SelectOptionsProps> = ({
@@ -36,6 +37,7 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
36
37
  className,
37
38
  dataTestId,
38
39
  extraOption,
40
+ onCloseDropdown,
39
41
  ...rest
40
42
  }) => {
41
43
  const [searchPhrase, setSearchPhrase] = useState('');
@@ -100,7 +102,12 @@ export const SelectOptions: React.FC<SelectOptionsProps> = ({
100
102
  <ControlLink
101
103
  className='SelectOptions__extra-option'
102
104
  disabled={extraOption.disabled}
103
- onClick={extraOption.callback}
105
+ onClick={(event: React.MouseEvent<HTMLButtonElement>) => {
106
+ extraOption.callback(event);
107
+ if (extraOption.closeOnClick) {
108
+ onCloseDropdown?.();
109
+ }
110
+ }}
104
111
  >
105
112
  {extraOption.label}
106
113
  </ControlLink>