|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
import { css, cx } from '@emotion/css'; |
|
|
|
|
import React from 'react'; |
|
|
|
|
import { components, GroupBase, SingleValueProps } from 'react-select'; |
|
|
|
|
import tinycolor from 'tinycolor2'; |
|
|
|
|
|
|
|
|
|
import { GrafanaTheme2, SelectableValue } from '@grafana/data'; |
|
|
|
|
|
|
|
|
@ -22,6 +21,7 @@ const getStyles = (theme: GrafanaTheme2) => { |
|
|
|
|
max-width: 100%; |
|
|
|
|
grid-area: 1 / 1 / 2 / 3; |
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const spinnerWrapper = css` |
|
|
|
|
width: 16px; |
|
|
|
|
height: 16px; |
|
|
|
@ -39,10 +39,14 @@ const getStyles = (theme: GrafanaTheme2) => { |
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const disabled = css` |
|
|
|
|
color: ${tinycolor(theme.colors.text.disabled).setAlpha(0.64).toString()}; |
|
|
|
|
color: ${theme.colors.text.disabled}; |
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const isOpen = css` |
|
|
|
|
color: ${theme.colors.text.disabled}; |
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
return { singleValue, spinnerWrapper, spinnerIcon, disabled }; |
|
|
|
|
return { singleValue, spinnerWrapper, spinnerIcon, disabled, isOpen }; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
type StylesType = ReturnType<typeof getStyles>; |
|
|
|
@ -55,7 +59,10 @@ export const SingleValue = <T extends unknown>(props: Props<T>) => { |
|
|
|
|
const loading = useDelayedSwitch(data.loading || false, { delay: 250, duration: 750 }); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<components.SingleValue {...props} className={cx(styles.singleValue, isDisabled && styles.disabled)}> |
|
|
|
|
<components.SingleValue |
|
|
|
|
{...props} |
|
|
|
|
className={cx(styles.singleValue, isDisabled && styles.disabled, props.selectProps.menuIsOpen && styles.isOpen)} |
|
|
|
|
> |
|
|
|
|
{data.imgUrl ? ( |
|
|
|
|
<FadeWithImage |
|
|
|
|
loading={loading} |
|
|
|
|