downshift
Version:
🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
59 lines (58 loc) • 2.81 kB
TypeScript
export let useControlPropsValidator: typeof noop;
export function useScrollIntoView({ highlightedIndex, isOpen, itemRefs, getItemNodeFromIndex, menuElement, scrollIntoView: scrollIntoViewProp, }: {
highlightedIndex: any;
isOpen: any;
itemRefs: any;
getItemNodeFromIndex: any;
menuElement: any;
scrollIntoView: any;
}): React.MutableRefObject<boolean>;
export function useGetterPropsCalledChecker(): typeof noop;
/**
* Tracks mouse and touch events, such as mouseDown, touchMove and touchEnd.
*
* @param {Window} environment The environment to add the event listeners to, for instance window.
* @param {() => void} handleBlur The function that is called if mouseDown or touchEnd occured outside the downshiftElements.
* @param {Array<{current: HTMLElement}>} downshiftElementsRefs The refs for the elements that should not trigger a blur action from mouseDown or touchEnd.
* @returns {{isMouseDown: boolean, isTouchMove: boolean, isTouchEnd: boolean}} The mouse and touch events information, if any of are happening.
*/
export function useMouseAndTouchTracker(environment: Window, handleBlur: () => void, downshiftRefs: any): {
isMouseDown: boolean;
isTouchMove: boolean;
isTouchEnd: boolean;
};
export function getHighlightedIndexOnOpen(props: any, state: any, offset: any): any;
export function isAcceptedCharacterKey(key: any): boolean;
/**
* Handles selection on Enter / Alt + ArrowUp. Closes the menu and resets the highlighted index, unless there is a highlighted.
* In that case, selects the item and resets to defaults for open state and highlighted idex.
* @param {Object} props The useCombobox props.
* @param {number} highlightedIndex The index from the state.
* @param {boolean} inputValue Also return the input value for state.
* @returns The changes for the state.
*/
export function getChangesOnSelection(props: Object, highlightedIndex: number, inputValue?: boolean): any;
/**
* Check if a state is equal for dropdowns, by comparing isOpen, inputValue, highlightedIndex and selected item.
* Used by useSelect and useCombobox.
*
* @param {Object} prevState
* @param {Object} newState
* @returns {boolean} Wheather the states are deeply equal.
*/
export function isDropdownsStateEqual(prevState: Object, newState: Object): boolean;
/**
* Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
*
* @param {Object} props Props from useCombobox or useSelect.
* @returns {number} The highlighted index.
*/
export function getDefaultHighlightedIndex(props: Object): number;
export function getInitialState(props: any): {
highlightedIndex: any;
isOpen: unknown;
selectedItem: unknown;
inputValue: unknown;
};
import { noop } from "../utils-ts";
import * as React from "react";