@@ -24,7 +24,6 @@ import {
24
24
MenuListProps ,
25
25
MultiValueRemoveProps ,
26
26
MultiValueProps ,
27
- GroupHeadingProps ,
28
27
MultiValue ,
29
28
} from 'react-select'
30
29
import { Progressing } from '@Common/Progressing'
@@ -36,10 +35,12 @@ import { noop } from '@Common/Helper'
36
35
import { CHECKBOX_VALUE } from '@Common/Types'
37
36
import { Checkbox } from '@Common/Checkbox'
38
37
import { ReactSelectInputAction } from '@Common/Constants'
39
- import { SelectPickerOptionType , SelectPickerProps } from './type'
38
+ import { SelectPickerGroupHeadingProps , SelectPickerOptionType , SelectPickerProps } from './type'
40
39
import { getGroupCheckboxValue } from './utils'
41
40
42
- export const SelectPickerDropdownIndicator = ( props : DropdownIndicatorProps < SelectPickerOptionType > ) => {
41
+ export const SelectPickerDropdownIndicator = < OptionValue , > (
42
+ props : DropdownIndicatorProps < SelectPickerOptionType < OptionValue > > ,
43
+ ) => {
43
44
const { isDisabled } = props
44
45
45
46
return (
@@ -49,21 +50,24 @@ export const SelectPickerDropdownIndicator = (props: DropdownIndicatorProps<Sele
49
50
)
50
51
}
51
52
52
- export const SelectPickerClearIndicator = ( props : ClearIndicatorProps < SelectPickerOptionType > ) => (
53
+ export const SelectPickerClearIndicator = < OptionValue , > (
54
+ props : ClearIndicatorProps < SelectPickerOptionType < OptionValue > > ,
55
+ ) => (
53
56
< components . ClearIndicator { ...props } >
54
57
< ICClose className = "icon-dim-16 icon-use-fill-n6 dc__no-shrink" />
55
58
</ components . ClearIndicator >
56
59
)
57
60
58
- export const SelectPickerControl = ( {
61
+ export const SelectPickerControl = < OptionValue , IsMulti extends boolean > ( {
59
62
icon,
60
63
showSelectedOptionIcon,
61
64
...props
62
- } : ControlProps < SelectPickerOptionType > & Pick < SelectPickerProps , 'icon' | 'showSelectedOptionIcon' > ) => {
65
+ } : ControlProps < SelectPickerOptionType < OptionValue > > &
66
+ Pick < SelectPickerProps < OptionValue , IsMulti > , 'icon' | 'showSelectedOptionIcon' > ) => {
63
67
const { children, getValue } = props
64
68
const { startIcon, endIcon } = getValue ( ) ?. [ 0 ] ?? { }
65
69
66
- let iconToDisplay = icon
70
+ let iconToDisplay : SelectPickerOptionType < OptionValue > [ 'startIcon' ] = icon
67
71
68
72
if ( showSelectedOptionIcon && ( startIcon || endIcon ) ) {
69
73
iconToDisplay = startIcon || endIcon
@@ -79,10 +83,11 @@ export const SelectPickerControl = ({
79
83
)
80
84
}
81
85
82
- export const SelectPickerValueContainer = ( {
86
+ export const SelectPickerValueContainer = < OptionValue , IsMulti extends boolean > ( {
83
87
showSelectedOptionsCount,
84
88
...props
85
- } : ValueContainerProps < SelectPickerOptionType > & Pick < SelectPickerProps , 'showSelectedOptionsCount' > ) => {
89
+ } : ValueContainerProps < SelectPickerOptionType < OptionValue > > &
90
+ Pick < SelectPickerProps < OptionValue , IsMulti > , 'showSelectedOptionsCount' > ) => {
86
91
const { getValue } = props
87
92
const selectedOptionsLength = ( getValue ( ) ?? [ ] ) . length
88
93
@@ -102,10 +107,11 @@ export const SelectPickerValueContainer = ({
102
107
103
108
export const SelectPickerLoadingIndicator = ( ) => < Progressing />
104
109
105
- export const SelectPickerOption = ( {
110
+ export const SelectPickerOption = < OptionValue , IsMulti extends boolean > ( {
106
111
disableDescriptionEllipsis,
107
112
...props
108
- } : OptionProps < SelectPickerOptionType > & Pick < SelectPickerProps , 'disableDescriptionEllipsis' > ) => {
113
+ } : OptionProps < SelectPickerOptionType < OptionValue > > &
114
+ Pick < SelectPickerProps < OptionValue , IsMulti > , 'disableDescriptionEllipsis' > ) => {
109
115
const {
110
116
label,
111
117
data,
@@ -161,13 +167,16 @@ export const SelectPickerOption = ({
161
167
)
162
168
}
163
169
164
- export const SelectPickerMenuList = ( {
170
+ export const SelectPickerMenuList = < OptionValue , IsMulti extends boolean > ( {
165
171
renderMenuListFooter,
166
172
shouldRenderCustomOptions,
167
173
renderCustomOptions,
168
174
...props
169
- } : MenuListProps < SelectPickerOptionType > &
170
- Pick < SelectPickerProps , 'renderMenuListFooter' | 'shouldRenderCustomOptions' | 'renderCustomOptions' > ) => {
175
+ } : MenuListProps < SelectPickerOptionType < OptionValue > > &
176
+ Pick <
177
+ SelectPickerProps < OptionValue , IsMulti > ,
178
+ 'renderMenuListFooter' | 'shouldRenderCustomOptions' | 'renderCustomOptions'
179
+ > ) => {
171
180
const { children } = props
172
181
173
182
return (
@@ -183,10 +192,11 @@ export const SelectPickerMenuList = ({
183
192
)
184
193
}
185
194
186
- export const SelectPickerMultiValueLabel = ( {
195
+ export const SelectPickerMultiValueLabel = < OptionValue , IsMulti extends boolean > ( {
187
196
getIsOptionValid,
188
197
...props
189
- } : MultiValueProps < SelectPickerOptionType , true > & Pick < SelectPickerProps [ 'multiSelectProps' ] , 'getIsOptionValid' > ) => {
198
+ } : MultiValueProps < SelectPickerOptionType < OptionValue > , true > &
199
+ Pick < SelectPickerProps < OptionValue , IsMulti > [ 'multiSelectProps' ] , 'getIsOptionValid' > ) => {
190
200
const { data, selectProps } = props
191
201
const isOptionValid = getIsOptionValid ( data )
192
202
const iconToDisplay = isOptionValid ? data . startIcon || data . endIcon : < ICErrorExclamation />
@@ -213,11 +223,10 @@ export const SelectPickerMultiValueRemove = (props: MultiValueRemoveProps) => (
213
223
</ components . MultiValueLabel >
214
224
)
215
225
216
- export const SelectPickerGroupHeading = ( {
226
+ export const SelectPickerGroupHeading = < OptionValue , > ( {
217
227
isGroupHeadingSelectable,
218
228
...props
219
- } : GroupHeadingProps < SelectPickerOptionType > &
220
- Pick < SelectPickerProps [ 'multiSelectProps' ] , 'isGroupHeadingSelectable' > ) => {
229
+ } : SelectPickerGroupHeadingProps < OptionValue > ) => {
221
230
const { data, selectProps } = props
222
231
223
232
if ( ! data . label ) {
@@ -228,7 +237,7 @@ export const SelectPickerGroupHeading = ({
228
237
return < components . GroupHeading { ...props } />
229
238
}
230
239
231
- const selectedOptions = ( selectProps . value as MultiValue < SelectPickerOptionType > ) ?? [ ]
240
+ const selectedOptions = ( selectProps . value as MultiValue < SelectPickerOptionType < OptionValue > > ) ?? [ ]
232
241
const groupHeadingOptions = data . options ?? [ ]
233
242
234
243
const checkboxValue = getGroupCheckboxValue ( groupHeadingOptions , selectedOptions , selectProps . getOptionValue )
0 commit comments