import { default as React } from 'react'; import { default as FormLabel } from '../../FormLabel/FormLabel'; import { SelectGroupType, SelectGroupWithNested, SelectOption } from './SelectHelpers'; import { SearchBarProps } from '../../SearchBar/SearchBar'; export type SelectProps = { /** Options to display in the dropdown menu. Can include nested options for flyout behavior. */ options: OptionType[] | SelectGroupType[] | SelectOption[] | SelectGroupWithNested[]; /** Key that will determine the value of the selected option */ optionKeyName: keyof OptionType; /** Key that will determine what to display as an option */ labelKeyName: keyof OptionType; /** The currently selected option state */ selectedItem: OptionType; /** Function to call when the selected option changes */ onChange: (option: OptionType) => void; /** Optional function to call when removing focus (onBlur) */ onBlur?: (option: OptionType) => void; /** Optional function to call when opening the dropdown menu */ onFocus?: () => void; /** Optional props to pass to the FormLabel component */ labelProps?: Pick, 'label' | 'rightLabel' | 'tooltip' | 'id'>; /** Overrides message displayed in dropdown when there are no options */ noOptionsMessage?: string; /** Turns the select red if in an error state */ error?: boolean; /** Turns the select gray and prevents interaction */ disabled?: boolean; /** Optional prop to display loading state */ loading?: boolean; /** Adds an asterisk to the label to indicate the field is required */ required?: boolean; /** Optionally removes the border around the Select */ noBorder?: boolean; /** Optionally add more configuration for the SearchBar */ searchBarProps?: Omit & { /** Optionally show the SearchBar at all times instead of the current conditional rendering */ showSearchBar?: boolean; /** Optional function that will make a callout with the search `value` passed back */ onChange?: (value: string) => void; }; /** Opt out of using the portal for the menu. This is needed whenever the Select needs to be used in a Popover. */ noMenuPortal?: boolean; /** Optional placeholder when there is no selected option */ placeholder?: string; /** Optional prop to allow a Button in the footer */ footerButtonProps?: { /** Function to call when creating a new option */ callout: () => void; /** Text to display on the button */ text: string; }; /** Optionally override the width of the Select menu */ menuWidth?: number; /** Optionally add configuration for infinite scroll */ scrollProps?: { /** Flag to determine if the select has more data that needs to be called */ hasMore: boolean; /** With pagination, new data needs to get called every time we reach the scrolling threshold. This is the function to get the next set of data. */ getData: () => void; }; /** Optional prop to add a test id to the Select for QA testing */ qaTestId?: string; /** Optional prop to add a test id to the Select menu for QA testing */ menuQaTestId?: string; /** Optional key name for nested options. Defaults to 'nestedOptions' */ nestedOptionsKeyName?: string; /** * Optionally show selected option's `secondaryContent` before the dropdown caret. * Can be a boolean value or a callback function that decides visibility based on selected option. */ showSecondaryContent?: boolean | ((option: OptionType) => boolean); }; declare const Select: ({ options, labelProps, selectedItem, onChange, onBlur, onFocus, error, disabled, required, optionKeyName, labelKeyName, loading, noBorder, noOptionsMessage, searchBarProps, noMenuPortal, placeholder, footerButtonProps, menuWidth, scrollProps, qaTestId, nestedOptionsKeyName, menuQaTestId, showSecondaryContent, }: SelectProps) => React.JSX.Element; export default Select;