@@ -19,6 +19,8 @@ import { ComponentSizeType } from '@Shared/constants'
19
19
import { MutableRefObject , ReactElement , ReactNode } from 'react'
20
20
import { GroupBase , GroupHeadingProps , Props as ReactSelectProps , SelectInstance } from 'react-select'
21
21
import { CreatableProps } from 'react-select/creatable'
22
+ // This import allows to extend the base interface in react-select module via module augmentation
23
+ import type { } from 'react-select/base'
22
24
23
25
export interface SelectPickerOptionType < OptionValue = string | number > extends OptionType < OptionValue , ReactNode > {
24
26
/**
@@ -35,17 +37,41 @@ export interface SelectPickerOptionType<OptionValue = string | number> extends O
35
37
endIcon ?: ReactElement
36
38
}
37
39
38
- export enum SelectPickerVariantType {
39
- DEFAULT = 'default' ,
40
- BORDER_LESS = 'border-less' ,
41
- }
42
-
43
40
type SelectProps < OptionValue , IsMulti extends boolean > = ReactSelectProps <
44
41
SelectPickerOptionType < OptionValue > ,
45
42
IsMulti ,
46
43
GroupBase < SelectPickerOptionType < OptionValue > >
47
44
>
48
45
46
+ declare module 'react-select/base' {
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
+ export interface Props < Option , IsMulti extends boolean , Group extends GroupBase < Option > > {
49
+ /**
50
+ * Render function for the footer at the bottom of menu list. It is sticky by default
51
+ */
52
+ renderMenuListFooter ?: ( selectedOptions : SelectProps < string | number , IsMulti > [ 'value' ] ) => ReactNode
53
+ /**
54
+ * If true, custom options are rendered in the menuList component of react select
55
+ *
56
+ * Note: renderCustomOptions is required to be passed; renderMenuListFooter is also not called
57
+ *
58
+ * @default false
59
+ */
60
+ shouldRenderCustomOptions ?: boolean
61
+ /**
62
+ * Callback handler for custom options
63
+ *
64
+ * Imp Note: The menu open/close needs to handled by the consumer in this case
65
+ */
66
+ renderCustomOptions ?: ( ) => ReactElement
67
+ }
68
+ }
69
+
70
+ export enum SelectPickerVariantType {
71
+ DEFAULT = 'default' ,
72
+ BORDER_LESS = 'border-less' ,
73
+ }
74
+
49
75
export type SelectPickerProps < OptionValue = number | string , IsMulti extends boolean = false > = Pick <
50
76
SelectProps < OptionValue , IsMulti > ,
51
77
| 'name'
@@ -72,6 +98,9 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
72
98
| 'onMenuClose'
73
99
| 'autoFocus'
74
100
| 'onBlur'
101
+ | 'renderMenuListFooter'
102
+ | 'shouldRenderCustomOptions'
103
+ | 'renderCustomOptions'
75
104
> &
76
105
Required < Pick < SelectProps < OptionValue , IsMulti > , 'inputId' > > & {
77
106
/**
@@ -82,10 +111,6 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
82
111
* Error message for the select
83
112
*/
84
113
error ?: ReactNode
85
- /**
86
- * Render function for the footer at the bottom of menu list. It is sticky by default
87
- */
88
- renderMenuListFooter ?: ( selectedOptions : SelectProps < OptionValue , IsMulti > [ 'value' ] ) => ReactNode
89
114
/**
90
115
* Info text for the select, if any
91
116
*/
@@ -195,29 +220,7 @@ export type SelectPickerProps<OptionValue = number | string, IsMulti extends boo
195
220
: {
196
221
isMulti ?: never
197
222
multiSelectProps ?: never
198
- } ) &
199
- (
200
- | {
201
- /**
202
- * If true, custom options are rendered in the menuList component of react select
203
- *
204
- * Note: renderCustomOptions is required to be passed; renderMenuListFooter is also not called
205
- *
206
- * @default false
207
- */
208
- shouldRenderCustomOptions : boolean
209
- /**
210
- * Callback handler for custom options
211
- *
212
- * Imp Note: The menu open/close needs to handled by the consumer in this case
213
- */
214
- renderCustomOptions : ( ) => ReactElement
215
- }
216
- | {
217
- shouldRenderCustomOptions ?: never
218
- renderCustomOptions ?: never
219
- }
220
- )
223
+ } )
221
224
222
225
// Doing like this, because of global export error GroupHeadingPropsDefinedProps
223
226
export type SelectPickerGroupHeadingProps < OptionValue > = GroupHeadingProps < SelectPickerOptionType < OptionValue > > & {
0 commit comments