@trail-ui/react
Version:
103 lines (100 loc) • 2.82 kB
TypeScript
import { SelectVariantProps, SlotsToClasses, SelectSlots } from '@trail-ui/theme';
import { ReactNode, ForwardedRef, ReactElement } from 'react';
import { Placement } from 'react-aria';
import { SelectProps as SelectProps$1, PopoverProps } from 'react-aria-components';
import { ListBoxProps } from '../listbox/listbox.js';
import { SpinnerProps } from '../spinner/spinner.js';
import 'react/jsx-runtime';
import '../listbox/listbox-item.js';
interface SelectProps<T extends object> extends Omit<SelectProps$1<T>, 'children'>, SelectVariantProps {
/**
* The label of the select.
*/
label?: ReactNode;
/**
* The id of the label of the select.
*/
labelId?: string;
/**
* The id of the selected option.
*/
optionId?: string;
/**
* The description of the select.
*/
description?: ReactNode;
/**
* The id of the error message of the select.
*/
errorId?: string;
/**
* The error icon of the select.
*/
errorIcon?: ReactNode;
/**
* The error message of the select.
*/
errorMessage?: ReactNode;
/**
* The placement of the popover.
*/
placement?: Placement;
/**
* The items of the select.
*/
items?: Iterable<T>;
/**
* The children of the select.
*/
children: React.ReactNode | ((item: T) => React.ReactNode);
/**
* The icon that represents the select open state. Usually a chevron icon.
*/
selectorIcon?: ReactNode;
/**
* Element to be rendered in the left side of the select.
*/
startContent?: React.ReactNode;
/**
* Element to be rendered in the right side of the select.
*/
endContent?: ReactNode;
/**
* Whether the select is loading.
*/
isLoading?: boolean;
/**
* Props to be passed to the spinner component.
*
* @default { size: "sm" , color: "current" }
*/
spinnerProps?: Partial<SpinnerProps>;
/**
* Props to be passed to the popover component.
*
* @default { placement: "bottom", triggerScaleOnOpen: false, offset: 5 }
*/
popoverProps?: Partial<PopoverProps>;
/**
* Props to be passed to the listbox component.
*
* @default { disableAnimation: false }
*/
listBoxProps?: Partial<ListBoxProps<T>>;
/**
* Classes object to style the select and its children.
*/
classNames?: SlotsToClasses<SelectSlots>;
/**
* The current selected value
*/
selectedItem?: string;
/**
* The current item that has focus in the dropdown options
*/
currentFocusedItem?: string;
}
declare const _Select: <T extends object>(props: SelectProps<T> & {
ref?: ForwardedRef<HTMLDivElement>;
}) => ReactElement;
export { _Select as Select, SelectProps };