1
- import ReactSelect , { ControlProps , Props as ReactSelectProps } from 'react-select'
2
- import { ReactNode , useCallback , useMemo } from 'react'
1
+ import ReactSelect , { ControlProps , MenuProps , Props as ReactSelectProps } from 'react-select'
2
+ import { ReactElement , ReactNode , useCallback , useMemo } from 'react'
3
3
import { ReactComponent as ErrorIcon } from '@Icons/ic-warning.svg'
4
4
import { getCommonSelectStyle } from './utils'
5
- import { ControlWithIcon , DropdownIndicator , SingleSelectOption , LoadingIndicator } from './common'
5
+ import {
6
+ SelectPickerControl ,
7
+ SelectPickerDropdownIndicator ,
8
+ SelectPickerMenu ,
9
+ SelectPickerOption ,
10
+ SelectPickerLoadingIndicator ,
11
+ } from './common'
6
12
import { SelectPickerOptionType } from './type'
7
13
8
14
export interface SelectPickerProps
@@ -22,13 +28,20 @@ export interface SelectPickerProps
22
28
| 'isLoading'
23
29
| 'inputId'
24
30
> {
25
- icon ?: ReactNode
31
+ icon ?: ReactElement
26
32
error ?: ReactNode
27
33
options : SelectPickerOptionType [ ]
28
34
value ?: SelectPickerOptionType
35
+ renderMenuListFooter : ( ) => ReactNode
29
36
}
30
37
31
- const SelectPicker = ( { error, icon, placeholder = 'Select a option' , ...props } : SelectPickerProps ) => {
38
+ const SelectPicker = ( {
39
+ error,
40
+ icon,
41
+ renderMenuListFooter,
42
+ placeholder = 'Select a option' ,
43
+ ...props
44
+ } : SelectPickerProps ) => {
32
45
const selectStyles = useMemo (
33
46
( ) =>
34
47
getCommonSelectStyle ( {
@@ -38,24 +51,30 @@ const SelectPicker = ({ error, icon, placeholder = 'Select a option', ...props }
38
51
)
39
52
40
53
const renderControl = useCallback (
41
- ( controlProps : ControlProps ) => < ControlWithIcon { ...controlProps } icon = { icon } /> ,
54
+ ( controlProps : ControlProps ) => < SelectPickerControl { ...controlProps } icon = { icon } /> ,
42
55
[ icon ] ,
43
56
)
44
57
58
+ const renderMenu = useCallback (
59
+ ( menuProps : MenuProps ) => < SelectPickerMenu { ...menuProps } renderMenuListFooter = { renderMenuListFooter } /> ,
60
+ [ ] ,
61
+ )
62
+
45
63
return (
46
64
< div >
47
65
< ReactSelect < SelectPickerOptionType , boolean >
48
66
{ ...props }
49
67
placeholder = { placeholder }
50
68
components = { {
51
69
IndicatorSeparator : null ,
52
- LoadingIndicator,
53
- DropdownIndicator,
70
+ LoadingIndicator : SelectPickerLoadingIndicator ,
71
+ DropdownIndicator : SelectPickerDropdownIndicator ,
54
72
Control : renderControl ,
55
- Option : SingleSelectOption ,
56
- // ValueContainer ,
73
+ Option : SelectPickerOption ,
74
+ Menu : renderMenu ,
57
75
} }
58
76
styles = { selectStyles }
77
+ menuIsOpen
59
78
/>
60
79
{ error && (
61
80
< div className = "flex left dc__gap-4 cr-5 fs-11 lh-16 fw-4" >
0 commit comments