import React, { useState } from 'react'; import { IconName } from '../../types'; import { SelectableValue } from '@grafana/data'; import { Button, ButtonVariant } from '../Button'; import { Select } from '../Select/Select'; import { FullWidthButtonContainer } from '../Button/FullWidthButtonContainer'; import { ComponentSize } from '../../types/size'; import { selectors } from '@grafana/e2e-selectors'; interface ValuePickerProps { /** Label to display on the picker button */ label: string; /** Icon to display on the picker button */ icon?: IconName; /** ValuePicker options */ options: Array>; /** Callback to handle selected option */ onChange: (value: SelectableValue) => void; /** Which ButtonVariant to render */ variant?: ButtonVariant; /** Size of button */ size?: ComponentSize; /** Should the picker cover the full width of its parent */ isFullWidth?: boolean; /** Control where the menu is rendered */ menuPlacement?: 'auto' | 'bottom' | 'top'; } export function ValuePicker({ label, icon, options, onChange, variant, size = 'sm', isFullWidth = true, menuPlacement, }: ValuePickerProps) { const [isPicking, setIsPicking] = useState(false); const buttonEl = ( ); return ( <> {!isPicking && (isFullWidth ? {buttonEl} : buttonEl)} {isPicking && (