@octopusdeploy/design-system-components
Version:
The design systems component library.
69 lines (68 loc) • 2.81 kB
TypeScript
import type { ReactElement } from "react";
import type { DropdownButtonState } from "../../Dropdown/useDropdownButton";
import type { AsyncList } from "./AsyncList";
import type { SelectedOption } from "./SelectBase";
import type { SelectOption } from "./SelectOption";
export interface SelectOptionListProps<T> {
/**
* The items to display in the list.
*/
items: T[] | AsyncList<T>;
/**
* A function that returns a SelectOption for an item.
*/
getOption: (item: T) => SelectOption;
/**
* Controls whether items are sorted before displaying. Has no effect on AsyncList items.
* @default false
*/
sortItems?: boolean;
/**
* The currently selected value(s).
*/
value: string | string[] | undefined;
/**
* Whether multiple options can be selected (renders checkboxes and a select/deselect-all control).
*/
isMultiSelectable: boolean;
/**
* Whether to show a search/filter input above the list.
*/
allowFilter: boolean;
/**
* The accessible label used for the filter input and listbox.
*/
label: string;
/**
* Renders a single option row.
*/
renderOption: (option: SelectOption, selected: boolean) => ReactElement;
/**
* The action to perform when one or more options are selected.
*/
onOptionsSelected: (options: SelectedOption[]) => void;
/**
* Closes the containing dropdown (used to close after a single-select selection).
*/
closeDropdown: DropdownButtonState["closeDropdown"];
/**
* Reports the active option's html id, e.g. so a parent combobox can mirror it in
* `aria-activedescendant`.
*/
onActiveDescendantChange?: (activeDescendantId: string | undefined) => void;
/**
* Used for the error footer's retry on refresh-backed lists, instead of calling the list's
* `refresh` directly. `SelectBase` passes its own refresh handler here so a retry shares the
* field's refresh lifecycle (spin, re-entry guard, and aria-live outcome announcements).
*/
onRefresh?: () => void;
}
/**
* The dropdown body of a `Select` / `MultiSelect`: an optional filter input, an optional
* select/deselect-all control, and the scrollable listbox of options.
*
* This owns its own filter state and listbox wiring, so it can be rendered standalone
* (e.g. inside a popover) as well as inside `SelectBase`. It does not render the trigger
* field, label, or positioning container.
*/
export declare function SelectOptionList<T>({ items: itemsArrayOrAsyncList, getOption, sortItems, value, isMultiSelectable, allowFilter, label, renderOption, onOptionsSelected, closeDropdown, onActiveDescendantChange, onRefresh, }: SelectOptionListProps<T>): import("react/jsx-runtime").JSX.Element;