import * as React from 'react'; import ILocalContainerProps from '../../../common/structures/ILocalContainerProps'; /** Unformatted option for use in the { [value: string]: ComboboxOption } type for the "options" prop */ export interface ComboboxOption { /** Whether the option is disabled */ disabled?: boolean; /** Whether to show the download icon next to an option */ download?: boolean; /** The icon to show next to the left of the option label - if a string, it will be the src attribute of an tag */ icon?: React.ReactNode; /** The text to show for the option */ label: string; /** Optional metadata - NOTE this is unused and exists for backwards compatability */ metadata?: any; /** * The option group the option belongs to. * * Must match an object key or optionGroup.name field of an option group passed in the "optionGroups" prop */ optionGroup?: string | null; /** Optional secondary text to be displayed to the right of the option label */ secondaryText?: React.ReactNode; /** Classname to be applied to option */ className?: string; } /** * Formatted option that the component will adapt all options in the "options" prop to. * * Essentially this just guarantees a "value" property on every option used internally, and it's necessary because * the "options" prop is quite flexible and allows several different formats. */ export interface ComboboxOptionFormatted extends ComboboxOption { /** A string representing the value of the option */ value: string; } /** An array of formatted options, this is the interface used by state.options internally */ export type ComboboxOptionsFormatted = ComboboxOptionFormatted[]; export type ComboboxOptionsObject = { [value: string]: ComboboxOption; }; /** * The type used by the "options" prop, ComboboxOptions allows users to pass options in a variety of formats. * * When the key of an object is [value: string], that means the key will be converted into that option's "value" property (see ComboboxOptionFormatted). */ export type ComboboxOptions = ComboboxOptionFormatted[] | string[] | ComboboxOptionsObject | { [value: string]: string; }; /** An asynchronous function that loads options, an alternative to passing options via the "options" prop. */ export type ComboboxOptionsLoader = () => Promise; /** A group to separate Combobox options */ export interface ComboboxOptionGroup { /** The label used to display the option group item */ label: string; /** An optional link to display in the option group item */ linkText?: string; /** href for the textButtonExternal optionally rendered by passing linkText */ href?: string; } /** A group to separate Combobox options */ export interface ComboboxOptionGroupFormatted extends ComboboxOptionGroup { /** The name of the option group - this should match the "optionGroup" field of an option */ name: string; } /** * The type used by "optionGroups" to pass in option groups. * * If using the object format, a key must match the "optionGroup" property of a ComboboxOption to be used by that option. */ export type ComboboxOptionGroups = { [optionGroup: string]: ComboboxOptionGroup; } | ComboboxOptionGroupFormatted[] | string[]; /** The type used internally when referencing optionGroups - the "optionGroups" prop will get formatted to this type */ export type ComboboxOptionGroupsFormatted = ComboboxOptionGroupFormatted[]; export interface IComboboxProps extends ILocalContainerProps { /** Whether the entire combobox is disabled */ disabled?: boolean; /** Placeholder value for when no options exist */ emptyPlaceholder?: string; /** Placeholder for when options are being loaded by optionsLoader */ loadingOptionsPlaceholder?: string; /** Callback function called when the selected value changes. Combine with "value" prop to make this a controlled component */ onChange: (value: IComboboxProps['value']) => void; /** Options for Combobox. Will be internally passed through a formatter before being used */ options?: ComboboxOptions; /** Height for the options in the dropdown. 's' = 37px, 'l' = 57px */ optionHeight?: 's' | 'l'; /** Height for the text input. 's' = 37px, 'l' = 57px */ inputHeight?: 's' | 'm' | 'l'; /** Optional async function that returns ComboboxOptions, useful for displaying a loading state while not blocking renders */ optionsLoader?: ComboboxOptionsLoader; /** OptionGroups used to separate Options. Key must match the "optionGroup" field of an option to be used. Groups will be displayed in the order they are passed */ optionGroups?: ComboboxOptionGroups; /** Placeholder for when options exist but none are selected */ placeholder?: string; /** Whether the options should be formatted to have striped backgrounds */ striped?: boolean; /** The selected value. Combine with "onChange" prop to make this a controlled component */ value?: string; /** Required ID field used to make unique keys for rendered lists */ id: string; /** Message to display in the option shown when no results are found with a given filter */ noResultsMessage?: string; /** Whether combobox is in invalid state - adds red border */ invalid?: boolean; /** Message shown below text input when combobox is invalid */ invalidMessage?: string; /** Offset for the max height of the combobox options dropdown. The max height defaults to 75px above the bottom of the window. */ maxHeightOffset?: number; /** Whether to show the options Icon next to the option when in a selected state */ showOptionIconWhenSelected?: boolean; /** Whether we're currently loading options (not using optionsLoader) */ loadingOptions?: boolean; } /** * A combobox component for searching through a list of options in a dropdown. * * This component borrows heavily from FlySelect, with code adapted for a * functional component. */ declare const Combobox: (props: IComboboxProps) => React.JSX.Element; export default Combobox; //# sourceMappingURL=Combobox.d.ts.map