14
14
* limitations under the License.
15
15
*/
16
16
17
+ import Tippy , { TippyProps } from '@tippyjs/react'
17
18
import {
18
19
components ,
19
20
DropdownIndicatorProps ,
@@ -31,14 +32,20 @@ import { ReactComponent as ICCaretDown } from '@Icons/ic-caret-down.svg'
31
32
import { ReactComponent as ICClose } from '@Icons/ic-close.svg'
32
33
import { ReactComponent as ICErrorExclamation } from '@Icons/ic-error-exclamation.svg'
33
34
import { ChangeEvent } from 'react'
34
- import { noop } from '@Common/Helper'
35
+ import { ConditionalWrap , noop } from '@Common/Helper'
35
36
import { CHECKBOX_VALUE } from '@Common/Types'
36
37
import { Checkbox } from '@Common/Checkbox'
37
38
import { ReactSelectInputAction } from '@Common/Constants'
38
39
import { isNullOrUndefined } from '@Shared/Helpers'
39
40
import { SelectPickerGroupHeadingProps , SelectPickerOptionType , SelectPickerProps } from './type'
40
41
import { getGroupCheckboxValue } from './utils'
41
42
43
+ const renderWithTippy = ( tippyProps : TippyProps ) => ( children : React . ReactElement ) => (
44
+ < Tippy { ...tippyProps } className = { `default-tt ${ tippyProps ?. className || '' } ` } >
45
+ { children }
46
+ </ Tippy >
47
+ )
48
+
42
49
export const SelectPickerDropdownIndicator = < OptionValue , > (
43
50
props : DropdownIndicatorProps < SelectPickerOptionType < OptionValue > > ,
44
51
) => {
@@ -124,7 +131,7 @@ export const SelectPickerOption = <OptionValue, IsMulti extends boolean>({
124
131
isDisabled,
125
132
isSelected,
126
133
} = props
127
- const { description, startIcon, endIcon } = data ?? { }
134
+ const { description, startIcon, endIcon, tooltipProps } = data ?? { }
128
135
const showDescription = ! ! description
129
136
// __isNew__ denotes the new option to be created
130
137
const isCreatableOption = '__isNew__' in data && data . __isNew__
@@ -137,39 +144,41 @@ export const SelectPickerOption = <OptionValue, IsMulti extends boolean>({
137
144
138
145
return (
139
146
< components . Option { ...props } >
140
- < div className = "flexbox dc__align-items-center dc__gap-8" >
141
- { isMulti && ! isCreatableOption && (
142
- < Checkbox
143
- onChange = { noop }
144
- onClick = { handleChange }
145
- isChecked = { isSelected || false }
146
- value = { CHECKBOX_VALUE . CHECKED }
147
- rootClassName = "mb-0 w-20 p-2 dc__align-self-start dc__no-shrink"
148
- disabled = { isDisabled }
149
- />
150
- ) }
151
- < div className = { `flex left ${ showDescription ? 'top' : '' } dc__gap-8` } >
152
- { startIcon && (
153
- < div className = "dc__no-shrink icon-dim-20 flex dc__fill-available-space" > { startIcon } </ div >
147
+ < ConditionalWrap condition = { ! ! tooltipProps ?. content } wrap = { renderWithTippy ( tooltipProps ) } >
148
+ < div className = "flexbox dc__align-items-center dc__gap-8" >
149
+ { isMulti && ! isCreatableOption && (
150
+ < Checkbox
151
+ onChange = { noop }
152
+ onClick = { handleChange }
153
+ isChecked = { isSelected || false }
154
+ value = { CHECKBOX_VALUE . CHECKED }
155
+ rootClassName = "mb-0 w-20 p-2 dc__align-self-start dc__no-shrink"
156
+ disabled = { isDisabled }
157
+ />
154
158
) }
155
- < div className = "flex-grow-1" >
156
- < h4 className = { `m-0 fs-13 ${ isCreatableOption ? 'cb-5' : 'cn-9' } fw-4 lh-20 dc__truncate` } >
157
- { label }
158
- </ h4 >
159
- { /* Add support for custom ellipsis if required */ }
160
- { showDescription && (
161
- < p
162
- className = { `m-0 fs-12 fw-4 lh-18 cn-7 ${ ! disableDescriptionEllipsis ? 'dc__ellipsis-right__2nd-line' : '' } ` }
163
- >
164
- { description }
165
- </ p >
159
+ < div className = { `flex left ${ showDescription ? 'top' : '' } dc__gap-8` } >
160
+ { startIcon && (
161
+ < div className = "dc__no-shrink icon-dim-20 flex dc__fill-available-space" > { startIcon } </ div >
162
+ ) }
163
+ < div className = "flex-grow-1" >
164
+ < h4 className = { `m-0 fs-13 ${ isCreatableOption ? 'cb-5' : 'cn-9' } fw-4 lh-20 dc__truncate` } >
165
+ { label }
166
+ </ h4 >
167
+ { /* Add support for custom ellipsis if required */ }
168
+ { showDescription && (
169
+ < p
170
+ className = { `m-0 fs-12 fw-4 lh-18 cn-7 ${ ! disableDescriptionEllipsis ? 'dc__ellipsis-right__2nd-line' : '' } ` }
171
+ >
172
+ { description }
173
+ </ p >
174
+ ) }
175
+ </ div >
176
+ { endIcon && (
177
+ < div className = "dc__no-shrink icon-dim-20 flex dc__fill-available-space" > { endIcon } </ div >
166
178
) }
167
179
</ div >
168
- { endIcon && (
169
- < div className = "dc__no-shrink icon-dim-20 flex dc__fill-available-space" > { endIcon } </ div >
170
- ) }
171
180
</ div >
172
- </ div >
181
+ </ ConditionalWrap >
173
182
</ components . Option >
174
183
)
175
184
}
0 commit comments