import { ListboxClassNameContract } from "@microsoft/fast-components-class-name-contracts-base"; import Foundation, { HandledProps } from "@microsoft/fast-components-foundation-react"; import React from "react"; import { ListboxItemProps } from "../listbox-item"; import { ListboxContext, ListboxContextType } from "./listbox-context"; import { ListboxHandledProps, ListboxProps, ListboxUnhandledProps } from "./listbox.props"; export interface ListboxState { /** * The index of the focusable child */ focusIndex: number; focussedItemId: string; selectedItems: ListboxItemProps[]; } declare class Listbox extends Foundation { static displayName: string; static defaultProps: Partial; /** * converts an array of item id's to an array of ListboxItemProps objects populated by data * extracted from the provided children based on id match */ static getListboxItemDataFromIds(selectedIds: Array, children: React.ReactNode): ListboxItemProps[]; /** * returns the first selectable item in the provided array of children */ static getFirstValidOptionInRange: (startIndex: number, endIndex: number, childrenAsArray: React.ReactNode[], increment: number) => React.ReactNode; /** * returns all the selectable items in the provided array of children */ static getValidOptions: (childrenAsArray: React.ReactNode[]) => React.ReactNode[]; /** * Gets the index of an item from it's id by examining children props */ static getItemIndexById(itemId: string, children: React.ReactNode): number; private static valuePropertyKey; private static idPropertyKey; private static disabledPropertyKey; /** * tests whether a React.ReactElement is a valid item to select * (ie. such an option id exists and the option is not disabled), * the values of the returned data objects are updated to reflect values of child object * with matching id. */ private static isValidSelectedItem; /** * Gets a child node from it's id by examining provided children */ private static getNodeById; /** * Gets the listItemData of an item from it's id by examining children props */ private static getItemPropsById; /** * validates selected options against child props and returns only the valid ones * (ie. such an option id exists and the option is not disabled), * the values of the returned data objects are updated to reflect values of child object * with matching id. */ private static validateSelection; protected handledProps: HandledProps; private rootElement; private typeAheadString; private typeAheadTimer; private shiftRangeSelectStartIndex; constructor(props: ListboxProps); /** * Renders the component */ render(): React.ReactElement; componentDidUpdate(prevProps: ListboxProps): void; componentDidMount(): void; componentWillUnmount(): void; /** * Create class names */ protected generateClassNames(): string; /** * Render all child elements */ private renderChildren; /** * Render a single child */ private renderChild; /** * Determines if a given element should be focusable by the menu */ private isFocusableElement; /** * Determines if a given element is disabled */ private isDisabledElement; /** * Return an array of all focusabled elements that are children * of the context menu */ private domChildren; /** * Sets focus to the nearest focusable element to the supplied focusIndex. * The adjustment controls how the function searches for other focusable elements * if the element at the focusIndex is not focusable. A positive number will search * towards the end of the children array, whereas a negative number will search towards * the beginning of the children array. Returns the focussed item id or an empty string * if none found */ private setFocus; /** * sets focus state and selection when component is initially mounted * or children have changed and invalidated focus */ private setInitialFocus; /** * gets the initial selection state based on props */ private getInitialSelection; /** * Function called by child select options when they have been focused */ private listboxItemfocused; /** * Handle the keydown event of the root menu */ private handleMenuKeyDown; /** * Sets focus based on characters typed */ private processTypeAhead; /** * clears the type ahead buffer after specified time of no typing */ private typeAheadTimerExpired; /** * Function called by child items when they have been invoked */ private listboxItemInvoked; /** * Toggle the selection state of the item */ private toggleItem; /** * Select a range of items */ private selectRange; /** * Updates selection state (should be the only place this is done outside of initialization) */ private updateSelection; } export default Listbox; export * from "./listbox.props"; export { ListboxClassNameContract, ListboxContext, ListboxContextType };