@patreon/studio
Version:
Patreon Studio Design System
62 lines (61 loc) • 1.94 kB
TypeScript
import React from 'react';
import type { ItemProps, ItemRenderer, SelectItemHandler } from './types';
export interface DropdownListProps<T extends ItemProps = ItemProps> {
/**
* What to show as an empty state if there are no items
*/
emptyState?: React.ReactNode;
/**
* Whether to not render lines delineating items in the list. Default is to render lines
* @deprecated hideLine is no longer supported
*/
hideLines?: boolean;
/**
* Items can be an array of any object, but it must extend ItemProps
*/
items: T[];
/**
* Custom item renderer. Used by DropdownListItem
*/
itemRenderer?: ItemRenderer<T>;
/**
* Whether to enable keyboard navigation
* passed right on thru to `InteractiveList`
*/
keyboardNav?: boolean;
/**
* Number of units or % value of describing max height of the list.
* Overflow-y kicks in if there are more items than the view port.
* @todo figure out a better, more automatic way to do this.
*/
maxHeight?: number | string;
/**
* Callback for when an item is selected.
* @param object Item object as in props.items
*/
onSelectItem?: SelectItemHandler<T>;
/**
* Index of currently selected item
* Alternately, can pass a 'isSelected' prop to item objects
* for the same effect
*/
selectedIndex?: number;
/**
* Whether to not wrap dropdown lists
*/
noWrap?: boolean;
}
/** @deprecated use `OverlayTriggerMenu` instead. */
export declare class DropdownList<T extends ItemProps = ItemProps> extends React.Component<DropdownListProps<T>> {
static defaultProps: {
keyboardNav: boolean;
};
state: {
currentIndex: number;
};
get items(): T[];
componentDidMount(): void;
componentWillUnmount(): void;
handleKeyDown: (e: KeyboardEvent) => void;
render(): React.JSX.Element;
}