@moda/om 21.6.1 → 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.
- package/dist/index.cjs.js +14 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +14 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Select/Select.d.ts +1 -0
- package/dist/src/components/Select/SelectOptions.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Select/Select.tsx +2 -0
- package/src/components/Select/SelectOptions.tsx +8 -1
|
@@ -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
|
@@ -15,6 +15,7 @@ export type SelectExtraOption = {
|
|
|
15
15
|
callback: (event?: React.MouseEvent<HTMLButtonElement>) => void;
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
label: string;
|
|
18
|
+
closeOnClick?: boolean;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export type SelectableOption = {
|
|
@@ -181,6 +182,7 @@ export const Select: React.FC<SelectProps> = ({
|
|
|
181
182
|
onFocus={handleFocus}
|
|
182
183
|
selectedOption={selected}
|
|
183
184
|
extraOption={extraOption}
|
|
185
|
+
onCloseDropdown={() => dispatch({ type: 'CLOSE' })}
|
|
184
186
|
/>
|
|
185
187
|
)}
|
|
186
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={
|
|
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>
|