|
3 | 3 | DropdownIndicatorProps,
|
4 | 4 | ControlProps,
|
5 | 5 | OptionProps,
|
6 |
| - MenuProps, |
7 | 6 | ClearIndicatorProps,
|
8 |
| - ValueContainerProps, |
| 7 | + MenuProps, |
9 | 8 | } from 'react-select'
|
10 | 9 | import { Progressing } from '@Common/Progressing'
|
11 | 10 | import { ReactComponent as ICCaretDown } from '@Icons/ic-caret-down.svg'
|
@@ -35,39 +34,23 @@ export const SelectPickerControl = ({
|
35 | 34 | }: ControlProps<SelectPickerOptionType> & Pick<SelectPickerProps, 'icon' | 'showSelectedOptionIcon'>) => {
|
36 | 35 | const { children, getValue } = props
|
37 | 36 | const { startIcon, endIcon } = getValue()?.[0] ?? {}
|
38 |
| - // Show the display icon if either the selected option icon is not to be shown or not available |
39 |
| - const showDisplayIcon = !!(icon && (!showSelectedOptionIcon || !(startIcon || endIcon))) |
| 37 | + |
| 38 | + let iconToDisplay = icon |
| 39 | + |
| 40 | + if (showSelectedOptionIcon && (startIcon || endIcon)) { |
| 41 | + iconToDisplay = startIcon || endIcon |
| 42 | + } |
40 | 43 |
|
41 | 44 | return (
|
42 | 45 | <components.Control {...props}>
|
43 |
| - {showDisplayIcon && <div className="dc__no-shrink icon-dim-20 flex dc__fill-available-space">{icon}</div>} |
| 46 | + {iconToDisplay && ( |
| 47 | + <div className="dc__no-shrink icon-dim-20 flex dc__fill-available-space">{iconToDisplay}</div> |
| 48 | + )} |
44 | 49 | {children}
|
45 | 50 | </components.Control>
|
46 | 51 | )
|
47 | 52 | }
|
48 | 53 |
|
49 |
| -export const SelectPickerValueContainer = ({ |
50 |
| - showSelectedOptionIcon, |
51 |
| - ...props |
52 |
| -}: ValueContainerProps<SelectPickerOptionType> & Pick<SelectPickerProps, 'showSelectedOptionIcon'>) => { |
53 |
| - const { children, getValue, hasValue } = props |
54 |
| - const { startIcon, endIcon } = getValue()?.[0] ?? {} |
55 |
| - const showIcon = !!(showSelectedOptionIcon && hasValue && (startIcon || endIcon)) |
56 |
| - |
57 |
| - return ( |
58 |
| - <components.ValueContainer {...props}> |
59 |
| - <div className="flex left dc__gap-8"> |
60 |
| - {showIcon && ( |
61 |
| - <div className="dc__no-shrink icon-dim-20 flex dc__fill-available-space"> |
62 |
| - {startIcon || endIcon} |
63 |
| - </div> |
64 |
| - )} |
65 |
| - {children} |
66 |
| - </div> |
67 |
| - </components.ValueContainer> |
68 |
| - ) |
69 |
| -} |
70 |
| - |
71 | 54 | export const SelectPickerLoadingIndicator = () => <Progressing />
|
72 | 55 |
|
73 | 56 | export const SelectPickerOption = (props: OptionProps<SelectPickerOptionType>) => {
|
|
0 commit comments