UNPKG

downshift

Version:

🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.

55 lines (54 loc) 1.97 kB
/** * Accepts a parameter and returns it if it's a function * or a noop function if it's not. This allows us to * accept a callback, but not worry about it if it's not * passed. * @param {Function} cb the callback * @return {Function} a function */ export function cbToCb(cb: Function): Function; /** * Default implementation for status message. Only added when menu is open. * Will specify if there are results in the list, and if so, how many, * and what keys are relevant. * * @param {Object} param the downshift state and other relevant properties * @return {String} the a11y status message */ export function getA11yStatusMessage({ isOpen, resultCount, previousResultCount }: Object): string; /** * Takes an argument and if it's an array, returns the first item in the array * otherwise returns the argument * @param {*} arg the maybe-array * @param {*} defaultValue the value if arg is falsey not defined * @return {*} the arg or it's first item */ export function unwrapArray(arg: any, defaultValue: any): any; /** * @param {Object} element (P)react element * @return {Boolean} whether it's a DOM element */ export function isDOMElement(element: Object): boolean; /** * @param {Object} element (P)react element * @return {Object} the props */ export function getElementProps(element: Object): Object; /** * Throws a helpful error message for required properties. Useful * to be used as a default in destructuring or object params. * @param {String} fnName the function name * @param {String} propName the prop name */ export function requiredProp(fnName: string, propName: string): void; /** * @param {Object} state the state object * @return {Object} state that is relevant to downshift */ export function pickState(state?: Object): Object; /** * Simple check if the value passed is object literal * @param {*} obj any things * @return {Boolean} whether it's object literal */ export function isPlainObject(obj: any): boolean;