/
utils.ts
41 lines (40 loc) · 1.06 KB
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import type { CommonPropsAndClassName, GroupBase } from "react-select";
/**
* Clean Common Props
*
* Borrowed from the original `react-select` package
*
* @see {@link https://github.com/JedWatson/react-select/blob/5d960cc31670dcd9c8f17341f9111349ec66aa21/packages/react-select/src/utils.ts#L75}
*/
export const cleanCommonProps = <
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>,
AdditionalProps
>(
props: Partial<CommonPropsAndClassName<Option, IsMulti, Group>> &
AdditionalProps
): Omit<
AdditionalProps,
keyof CommonPropsAndClassName<Option, IsMulti, Group>
> => {
// className
const {
className, // not listed in commonProps documentation, needs to be removed to allow Emotion to generate classNames
clearValue,
cx,
getStyles,
getClassNames,
getValue,
hasValue,
isMulti,
isRtl,
options, // not listed in commonProps documentation
selectOption,
selectProps,
setValue,
theme, // not listed in commonProps documentation
...innerProps
} = props;
return { ...innerProps };
};