@blueprintjs/select
Version:
Components related to selecting items from a list
94 lines (93 loc) • 3.35 kB
TypeScript
import * as React from "react";
import { AbstractPureComponent, type InputGroupProps } from "@blueprintjs/core";
import { type ListItemsProps, type SelectPopoverProps } from "../../common";
export interface SelectProps<T> extends ListItemsProps<T>, SelectPopoverProps {
/**
* Element which triggers the select popover. In most cases, you should display
* the name or label of the curently selected item here.
*/
children?: React.ReactNode;
/**
* Whether the component is non-interactive.
* If true, the list's item renderer will not be called.
* Note that you'll also need to disable the component's children, if appropriate.
*
* @default false
*/
disabled?: boolean;
/**
* Whether the component should take up the full width of its container.
* You also have to ensure that the child component has `fill` set to `true` or is styled appropriately.
*/
fill?: boolean;
/**
* Whether the dropdown list can be filtered.
* Disabling this option will remove the `InputGroup` and ignore `inputProps`.
*
* @default true
*/
filterable?: boolean;
/**
* Props to pass to the query [InputGroup component](#core/components/input-group).
*
* Some properties are unavailable:
* - `inputProps.value`: use `query` instead
* - `inputProps.onChange`: use `onQueryChange` instead
*/
inputProps?: Partial<Omit<InputGroupProps, "value" | "onChange">>;
/**
* HTML attributes to add to the `Menu` listbox containing the selectable options.
*/
menuProps?: React.HTMLAttributes<HTMLUListElement>;
/**
* A placeholder string passed to the filter text input.
* Applicable only when `filterable` is `true`.
*
* @default "Filter..."
*/
placeholder?: string;
/**
* Whether the active item should be reset to the first matching item _when
* the popover closes_. The query will also be reset to the empty string.
*
* @default false
*/
resetOnClose?: boolean;
}
/** Exported for testing, not part of public API */
export interface SelectState {
isOpen: boolean;
}
/**
* Select component.
*
* @see https://blueprintjs.com/docs/#select/select
*/
export declare class Select<T> extends AbstractPureComponent<SelectProps<T>, SelectState> {
static displayName: string;
/** @deprecated no longer necessary now that the TypeScript parser supports type arguments on JSX element tags */
static ofType<U>(): new (props: SelectProps<U>) => Select<U>;
state: SelectState;
inputElement: HTMLInputElement | null;
private queryList;
private previousFocusedElement;
private handleInputRef;
private handleQueryListRef;
private listboxId;
render(): React.JSX.Element;
componentDidUpdate(prevProps: SelectProps<T>, prevState: SelectState): void;
private renderQueryList;
private getPopoverTargetRenderer;
private maybeRenderClearButton;
private withPopoverTargetPropsHandler;
/**
* Target wrapper element "keydown" handler while the popover is closed.
*/
private handleTargetKeyDown;
private handleItemSelect;
private handlePopoverInteraction;
private handlePopoverOpening;
private handlePopoverOpened;
private handlePopoverClosing;
private resetQuery;
}