1
1
import ReactSelect , { ControlProps , MenuProps } from 'react-select'
2
- import { useCallback , useMemo } from 'react'
2
+ import { ReactElement , useCallback , useMemo } from 'react'
3
3
import { ReactComponent as ErrorIcon } from '@Icons/ic-warning.svg'
4
4
import { ReactComponent as ICInfoFilledOverride } from '@Icons/ic-info-filled-override.svg'
5
5
import { ComponentSizeType } from '@Shared/constants'
6
+ import { ConditionalWrap } from '@Common/Helper'
7
+ import Tippy from '@tippyjs/react'
6
8
import { getCommonSelectStyle } from './utils'
7
9
import {
8
10
SelectPickerClearIndicator ,
@@ -23,9 +25,10 @@ const SelectPicker = ({
23
25
label,
24
26
showSelectedOptionIcon = true ,
25
27
size = ComponentSizeType . medium ,
28
+ disabledTippyContent,
26
29
...props
27
30
} : SelectPickerProps ) => {
28
- const { inputId, required } = props
31
+ const { inputId, required, isDisabled } = props
29
32
30
33
const selectStyles = useMemo (
31
34
( ) =>
@@ -50,6 +53,12 @@ const SelectPicker = ({
50
53
[ ] ,
51
54
)
52
55
56
+ const renderDisabledTippy = ( children : ReactElement ) => (
57
+ < Tippy content = { disabledTippyContent } placement = "top" className = "default-tt" arrow = { false } >
58
+ { children }
59
+ </ Tippy >
60
+ )
61
+
53
62
return (
54
63
< div className = "flex column left top dc__gap-4" >
55
64
{ /* TODO Eshank: Common out for fields */ }
@@ -70,25 +79,28 @@ const SelectPicker = ({
70
79
) }
71
80
</ label >
72
81
) }
73
- < ReactSelect < SelectPickerOptionType , boolean >
74
- { ...props }
75
- placeholder = { placeholder }
76
- components = { {
77
- IndicatorSeparator : null ,
78
- LoadingIndicator : SelectPickerLoadingIndicator ,
79
- DropdownIndicator : SelectPickerDropdownIndicator ,
80
- Control : renderControl ,
81
- Option : SelectPickerOption ,
82
- Menu : renderMenu ,
83
- ClearIndicator : SelectPickerClearIndicator ,
84
- } }
85
- styles = { selectStyles }
86
- className = "w-100"
87
- menuPlacement = "auto"
88
- menuPosition = "fixed"
89
- menuShouldScrollIntoView
90
- backspaceRemovesValue = { false }
91
- />
82
+ < ConditionalWrap condition = { isDisabled && ! ! disabledTippyContent } wrap = { renderDisabledTippy } >
83
+ < div className = "w-100" >
84
+ < ReactSelect < SelectPickerOptionType , boolean >
85
+ { ...props }
86
+ placeholder = { placeholder }
87
+ components = { {
88
+ IndicatorSeparator : null ,
89
+ LoadingIndicator : SelectPickerLoadingIndicator ,
90
+ DropdownIndicator : SelectPickerDropdownIndicator ,
91
+ Control : renderControl ,
92
+ Option : SelectPickerOption ,
93
+ Menu : renderMenu ,
94
+ ClearIndicator : SelectPickerClearIndicator ,
95
+ } }
96
+ styles = { selectStyles }
97
+ menuPlacement = "auto"
98
+ menuPosition = "fixed"
99
+ menuShouldScrollIntoView
100
+ backspaceRemovesValue = { false }
101
+ />
102
+ </ div >
103
+ </ ConditionalWrap >
92
104
</ div >
93
105
{ error && (
94
106
< div className = "flex left dc__gap-4 cr-5 fs-11 lh-16 fw-4" >
0 commit comments