downshift 9.3.2 → 9.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/downshift.cjs.cjs +617 -698
- package/dist/downshift.d.ts +49 -55
- package/dist/downshift.esm.mjs +618 -699
- package/dist/downshift.native.cjs.cjs +575 -653
- package/dist/downshift.nativeweb.cjs.cjs +615 -693
- package/dist/downshift.types.d.ts +205 -0
- package/dist/downshift.umd.js +621 -702
- package/dist/downshift.umd.js.map +1 -1
- package/dist/downshift.umd.min.js +1 -1
- package/dist/downshift.umd.min.js.map +1 -1
- package/dist/hooks/testUtils/MemoizedItem.d.ts +10 -0
- package/dist/hooks/testUtils/fixtures.d.ts +16 -0
- package/dist/hooks/testUtils/index.d.ts +4 -0
- package/dist/hooks/testUtils/interactions.d.ts +16 -0
- package/dist/hooks/testUtils/testCases.d.ts +2 -0
- package/dist/hooks/useCombobox/__tests__/utils/index.d.ts +5 -0
- package/dist/hooks/useCombobox/__tests__/utils/interactions.d.ts +6 -0
- package/dist/hooks/useCombobox/__tests__/utils/renderCombobox.d.ts +72 -0
- package/dist/hooks/useCombobox/__tests__/utils/renderUseCombobox.d.ts +2 -0
- package/dist/hooks/useCombobox/index.d.ts +4 -94
- package/dist/hooks/useCombobox/index.types.d.ts +302 -0
- package/dist/hooks/useCombobox/reducer.d.ts +4 -1
- package/dist/hooks/useCombobox/stateChangeTypes.d.ts +24 -23
- package/dist/hooks/useCombobox/utils/getInitialState.d.ts +10 -0
- package/dist/hooks/useCombobox/utils/index.d.ts +3 -0
- package/dist/hooks/useCombobox/{utils.d.ts → utils/propTypes.d.ts} +2 -30
- package/dist/hooks/useCombobox/utils/useControlledReducer.d.ts +16 -0
- package/dist/hooks/useMultipleSelection/index.d.ts +25 -13
- package/dist/hooks/useMultipleSelection/index.types.d.ts +117 -0
- package/dist/hooks/useMultipleSelection/reducer.d.ts +1 -1
- package/dist/hooks/useMultipleSelection/utils.d.ts +14 -15
- package/dist/hooks/useSelect/__tests__/utils/getItemIndexByCharacter.d.ts +7 -0
- package/dist/hooks/useSelect/__tests__/utils/index.d.ts +6 -0
- package/dist/hooks/useSelect/__tests__/utils/renderSelect.d.ts +71 -0
- package/dist/hooks/useSelect/__tests__/utils/renderUseSelect.d.ts +2 -0
- package/dist/hooks/useSelect/__tests__/utils/stateChangeTestCases.d.ts +182 -0
- package/dist/hooks/useSelect/index.d.ts +4 -71
- package/dist/hooks/useSelect/index.types.d.ts +266 -0
- package/dist/hooks/useSelect/reducer.d.ts +4 -1
- package/dist/hooks/useSelect/stateChangeTypes.d.ts +23 -22
- package/dist/hooks/useSelect/utils/index.d.ts +0 -1
- package/dist/hooks/useTagGroup/__tests__/utils/renderTagGroup.d.ts +1 -1
- package/dist/hooks/useTagGroup/index.types.d.ts +10 -13
- package/dist/hooks/useTagGroup/reducer.d.ts +4 -2
- package/dist/hooks/useTagGroup/utils/index.d.ts +3 -1
- package/dist/hooks/utils/__tests__/dropdownDefaultProps.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/getChangesOnSelection.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/getDefaultHighlightedIndex.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/getDefaultValue.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/getHighlightedIndexOnOpen.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/getInitialValue.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/getItemAndIndex.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/isDropdownStateEqual.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useA11yMessageStatus.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useControlPropsValidator.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useControlledReducer.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useElementIds.legacy.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useElementIds.r18.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useEnhancedReducer.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useGetterPropsCalledChecker.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useIsInitialMount.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useMouseAndTouchTracker.test.d.ts +1 -0
- package/dist/hooks/utils/__tests__/useScrollIntoView.test.d.ts +1 -0
- package/dist/hooks/utils/callOnChangeProps.d.ts +4 -0
- package/dist/hooks/utils/dropdownDefaultProps.d.ts +13 -0
- package/dist/hooks/{utils.dropdown/defaultStateValues.d.ts → utils/dropdownDefaultStateValues.d.ts} +2 -2
- package/dist/hooks/{utils.dropdown/propTypes.d.ts → utils/dropdownPropTypes.d.ts} +1 -1
- package/dist/hooks/utils/getChangesOnSelection.d.ts +17 -0
- package/dist/hooks/utils/getDefaultHighlightedIndex.d.ts +7 -0
- package/dist/hooks/utils/getDefaultValue.d.ts +8 -0
- package/dist/hooks/utils/getHighlightedIndexOnOpen.d.ts +16 -0
- package/dist/hooks/utils/getInitialState.d.ts +23 -0
- package/dist/hooks/utils/getInitialValue.d.ts +14 -0
- package/dist/hooks/utils/index.d.ts +24 -0
- package/dist/hooks/utils/index.types.d.ts +26 -0
- package/dist/hooks/utils/isDropdownStateEqual.d.ts +16 -0
- package/dist/hooks/utils/reducer.d.ts +27 -0
- package/dist/hooks/utils/useControlPropsValidator.d.ts +6 -0
- package/dist/hooks/utils/useControlledReducer.d.ts +13 -0
- package/dist/hooks/utils/useEnhancedReducer.d.ts +15 -0
- package/dist/hooks/utils/useGetterPropsCalledChecker.d.ts +2 -0
- package/dist/hooks/utils/useMouseAndTouchTracker.d.ts +15 -0
- package/dist/hooks/utils/useScrollIntoView.d.ts +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/utils/__tests__/callAllEventHandlers.test.d.ts +1 -0
- package/dist/utils/__tests__/debounce.test.d.ts +1 -0
- package/dist/utils/__tests__/generateId.r18.test.d.ts +1 -0
- package/dist/utils/__tests__/generateId.test.d.ts +1 -0
- package/dist/utils/__tests__/getHighlightedIndex.test.d.ts +1 -0
- package/dist/utils/__tests__/getNonDisabledIndex.test.d.ts +1 -0
- package/dist/utils/__tests__/getState.test.d.ts +1 -0
- package/dist/utils/__tests__/handleRefs.test.d.ts +1 -0
- package/dist/utils/__tests__/normalizeArrowKey.test.d.ts +1 -0
- package/dist/utils/__tests__/scrollIntoView.test.d.ts +1 -0
- package/dist/utils/__tests__/setA11yStatus.test.d.ts +1 -0
- package/dist/utils/__tests__/targetWithinDownshift.test.d.ts +1 -0
- package/dist/utils/__tests__/useLatestRef.test.d.ts +1 -0
- package/dist/utils/__tests__/validateControlledUnchanged.test.d.ts +1 -0
- package/dist/utils/__tests__/validatePropTypes.test.d.ts +1 -0
- package/dist/utils/getHighlightedIndex.d.ts +11 -0
- package/dist/utils/getNonDisabledIndex.d.ts +11 -0
- package/dist/utils/getState.d.ts +12 -0
- package/dist/utils/handleRefs.d.ts +2 -0
- package/dist/{utils-ts → utils}/index.d.ts +5 -1
- package/dist/utils/normalizeArrowKey.d.ts +6 -0
- package/dist/utils/targetWithinDownshift.d.ts +12 -0
- package/dist/utils/validateControlledUnchanged.d.ts +1 -0
- package/dist/utils/validatePropTypes.d.ts +2 -0
- package/dist/utils.legacy.d.ts +54 -0
- package/flow-typed/npm/downshift_v2.x.x.js.flow +87 -62
- package/package.json +2 -4
- package/preact/dist/downshift.cjs.cjs +617 -698
- package/preact/dist/downshift.cjs.js +4265 -0
- package/preact/dist/downshift.esm.js +4238 -0
- package/preact/dist/downshift.esm.mjs +618 -699
- package/preact/dist/downshift.umd.js +617 -698
- package/preact/dist/downshift.umd.js.map +1 -1
- package/preact/dist/downshift.umd.min.js +1 -1
- package/preact/dist/downshift.umd.min.js.map +1 -1
- package/typings/index.d.ts +13 -21
- package/dist/hooks/reducer.d.ts +0 -1
- package/dist/hooks/useSelect/utils/defaultProps.d.ts +0 -8
- package/dist/hooks/utils-ts/callOnChangeProps.d.ts +0 -2
- package/dist/hooks/utils-ts/getDefaultValue.d.ts +0 -2
- package/dist/hooks/utils-ts/getInitialValue.d.ts +0 -2
- package/dist/hooks/utils-ts/index.d.ts +0 -11
- package/dist/hooks/utils-ts/stateReducer.d.ts +0 -6
- package/dist/hooks/utils-ts/useControlledReducer.d.ts +0 -12
- package/dist/hooks/utils-ts/useEnhancedReducer.d.ts +0 -13
- package/dist/hooks/utils.d.ts +0 -58
- package/dist/hooks/utils.dropdown/defaultProps.d.ts +0 -9
- package/dist/hooks/utils.dropdown/index.d.ts +0 -3
- package/dist/utils-ts/getState.d.ts +0 -22
- package/dist/utils-ts/handleRefs.d.ts +0 -2
- package/dist/utils-ts/validatePropTypes.d.ts +0 -2
- package/dist/utils.d.ts +0 -123
- package/typings/index.legacy.d.ts +0 -888
- /package/dist/hooks/{utils-ts/__tests__/getItemAndIndex.test.d.ts → useCombobox/utils/__tests__/getInitialState.test.d.ts} +0 -0
- /package/dist/hooks/{utils.dropdown/__tests__/useElementIds.legacy.test.d.ts → useCombobox/utils/__tests__/useControlledReducer.test.d.ts} +0 -0
- /package/dist/hooks/{utils.dropdown/__tests__/useElementIds.r18.test.d.ts → useSelect/utils/__tests__/getItemIndexByCharacterKey.test.d.ts} +0 -0
- /package/dist/{utils-ts/__tests__/getState.test.d.ts → hooks/utils/__tests__/callOnChangeProps.test.d.ts} +0 -0
- /package/dist/{utils-ts/__tests__/handleRefs.test.d.ts → hooks/utils/__tests__/capitalizeString.test.d.ts} +0 -0
- /package/dist/hooks/{utils-ts → utils}/capitalizeString.d.ts +0 -0
- /package/dist/hooks/{utils-ts → utils}/getItemAndIndex.d.ts +0 -0
- /package/dist/hooks/{utils-ts → utils}/propTypes.d.ts +0 -0
- /package/dist/hooks/{utils-ts → utils}/useA11yMessageStatus.d.ts +0 -0
- /package/dist/hooks/{utils.dropdown → utils}/useElementIds.d.ts +0 -0
- /package/dist/hooks/{utils-ts → utils}/useIsInitialMount.d.ts +0 -0
- /package/dist/{utils-ts → utils}/callAllEventHandlers.d.ts +0 -0
- /package/dist/{utils-ts → utils}/debounce.d.ts +0 -0
- /package/dist/{utils-ts → utils}/generateId.d.ts +0 -0
- /package/dist/{utils-ts → utils}/noop.d.ts +0 -0
- /package/dist/{utils-ts → utils}/scrollIntoView.d.ts +0 -0
- /package/dist/{utils-ts → utils}/setA11yStatus.d.ts +0 -0
- /package/dist/{utils-ts → utils}/useLatestRef.d.ts +0 -0
package/typings/index.d.ts
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default
|
|
1
|
+
// Downshift (legacy class component)
|
|
2
|
+
export * from '../src/downshift.types'
|
|
3
|
+
export {default} from '../src/downshift.types'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
UseTagGroupProps,
|
|
8
|
-
UseTagGroupReturnValue,
|
|
9
|
-
GetTagGroupProps,
|
|
10
|
-
GetTagGroupPropsOptions,
|
|
11
|
-
GetTagGroupPropsReturnValue,
|
|
12
|
-
GetTagProps,
|
|
13
|
-
GetTagPropsOptions,
|
|
14
|
-
GetTagPropsReturnValue,
|
|
15
|
-
GetTagRemoveProps,
|
|
16
|
-
GetTagRemovePropsOptions,
|
|
17
|
-
GetTagRemovePropsReturnValue,
|
|
18
|
-
UseTagGroupStateChangeTypes,
|
|
19
|
-
} from '../dist/hooks/useTagGroup/index.types'
|
|
5
|
+
// useSelect
|
|
6
|
+
export * from '../src/hooks/useSelect/index.types'
|
|
20
7
|
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
8
|
+
// useCombobox
|
|
9
|
+
export * from '../src/hooks/useCombobox/index.types'
|
|
10
|
+
|
|
11
|
+
// useMultipleSelection
|
|
12
|
+
export * from '../src/hooks/useMultipleSelection/index.types'
|
|
13
|
+
|
|
14
|
+
// useTagGroup
|
|
15
|
+
export * from '../src/hooks/useTagGroup/index.types'
|
package/dist/hooks/reducer.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function downshiftCommonReducer(state: any, props: any, action: any, stateChangeTypes: any): any;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const defaultProps: {
|
|
2
|
-
isItemDisabled(): boolean;
|
|
3
|
-
itemToString(item: unknown): string;
|
|
4
|
-
itemToKey(item: unknown): unknown;
|
|
5
|
-
stateReducer: typeof import("../../utils-ts").stateReducer;
|
|
6
|
-
scrollIntoView: typeof import("../../../utils-ts").scrollIntoView;
|
|
7
|
-
environment: (Window & typeof globalThis) | undefined;
|
|
8
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { useControlledReducer } from './useControlledReducer';
|
|
2
|
-
export { useEnhancedReducer } from './useEnhancedReducer';
|
|
3
|
-
export { callOnChangeProps } from './callOnChangeProps';
|
|
4
|
-
export { getItemAndIndex } from './getItemAndIndex';
|
|
5
|
-
export { useIsInitialMount } from './useIsInitialMount';
|
|
6
|
-
export { stateReducer } from './stateReducer';
|
|
7
|
-
export { propTypes as commonPropTypes } from './propTypes';
|
|
8
|
-
export { capitalizeString } from './capitalizeString';
|
|
9
|
-
export { getDefaultValue } from './getDefaultValue';
|
|
10
|
-
export { getInitialValue } from './getInitialValue';
|
|
11
|
-
export { useA11yMessageStatus } from './useA11yMessageStatus';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Action, type State, type Props } from '../../utils-ts';
|
|
2
|
-
/**
|
|
3
|
-
* Wraps the useEnhancedReducer and applies the controlled prop values before
|
|
4
|
-
* returning the new state.
|
|
5
|
-
*
|
|
6
|
-
* @param {Function} reducer Reducer function from downshift.
|
|
7
|
-
* @param {Object} props The hook props, also passed to createInitialState.
|
|
8
|
-
* @param {Function} createInitialState Function that returns the initial state.
|
|
9
|
-
* @param {Function} isStateEqual Function that checks if a previous state is equal to the next.
|
|
10
|
-
* @returns {Array} An array with the state and an action dispatcher.
|
|
11
|
-
*/
|
|
12
|
-
export declare function useControlledReducer<S extends State, P extends Partial<S> & Props<S, T>, T, A extends Action<T>>(reducer: (state: S, props: P, action: A) => S, props: P, createInitialState: (props: P) => S, isStateEqual: (prevState: S, newState: S) => boolean): [S, (action: A) => void];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Action, type Props, type State } from '../../utils-ts';
|
|
2
|
-
/**
|
|
3
|
-
* Computes the controlled state using a the previous state, props,
|
|
4
|
-
* two reducers, one from downshift and an optional one from the user.
|
|
5
|
-
* Also calls the onChange handlers for state values that have changed.
|
|
6
|
-
*
|
|
7
|
-
* @param {Function} reducer Reducer function from downshift.
|
|
8
|
-
* @param {Object} props The hook props, also passed to createInitialState.
|
|
9
|
-
* @param {Function} createInitialState Function that returns the initial state.
|
|
10
|
-
* @param {Function} isStateEqual Function that checks if a previous state is equal to the next.
|
|
11
|
-
* @returns {Array} An array with the state and an action dispatcher.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useEnhancedReducer<S extends State, P extends Partial<S> & Props<S, T>, T, A extends Action<T>>(reducer: (state: S, props: P, action: A) => S, props: P, createInitialState: (props: P) => S, isStateEqual: (prevState: S, newState: S) => boolean): [S, (action: A) => void];
|
package/dist/hooks/utils.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export let useControlPropsValidator: typeof noop;
|
|
2
|
-
export function useScrollIntoView({ highlightedIndex, isOpen, itemRefs, getItemNodeFromIndex, menuElement, scrollIntoView: scrollIntoViewProp, }: {
|
|
3
|
-
highlightedIndex: any;
|
|
4
|
-
isOpen: any;
|
|
5
|
-
itemRefs: any;
|
|
6
|
-
getItemNodeFromIndex: any;
|
|
7
|
-
menuElement: any;
|
|
8
|
-
scrollIntoView: any;
|
|
9
|
-
}): React.MutableRefObject<boolean>;
|
|
10
|
-
export function useGetterPropsCalledChecker(): typeof noop;
|
|
11
|
-
/**
|
|
12
|
-
* Tracks mouse and touch events, such as mouseDown, touchMove and touchEnd.
|
|
13
|
-
*
|
|
14
|
-
* @param {Window} environment The environment to add the event listeners to, for instance window.
|
|
15
|
-
* @param {() => void} handleBlur The function that is called if mouseDown or touchEnd occured outside the downshiftElements.
|
|
16
|
-
* @param {Array<{current: HTMLElement}>} downshiftElementsRefs The refs for the elements that should not trigger a blur action from mouseDown or touchEnd.
|
|
17
|
-
* @returns {{isMouseDown: boolean, isTouchMove: boolean, isTouchEnd: boolean}} The mouse and touch events information, if any of are happening.
|
|
18
|
-
*/
|
|
19
|
-
export function useMouseAndTouchTracker(environment: Window, handleBlur: () => void, downshiftRefs: any): {
|
|
20
|
-
isMouseDown: boolean;
|
|
21
|
-
isTouchMove: boolean;
|
|
22
|
-
isTouchEnd: boolean;
|
|
23
|
-
};
|
|
24
|
-
export function getHighlightedIndexOnOpen(props: any, state: any, offset: any): any;
|
|
25
|
-
export function isAcceptedCharacterKey(key: any): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Handles selection on Enter / Alt + ArrowUp. Closes the menu and resets the highlighted index, unless there is a highlighted.
|
|
28
|
-
* In that case, selects the item and resets to defaults for open state and highlighted idex.
|
|
29
|
-
* @param {Object} props The useCombobox props.
|
|
30
|
-
* @param {number} highlightedIndex The index from the state.
|
|
31
|
-
* @param {boolean} inputValue Also return the input value for state.
|
|
32
|
-
* @returns The changes for the state.
|
|
33
|
-
*/
|
|
34
|
-
export function getChangesOnSelection(props: Object, highlightedIndex: number, inputValue?: boolean): any;
|
|
35
|
-
/**
|
|
36
|
-
* Check if a state is equal for dropdowns, by comparing isOpen, inputValue, highlightedIndex and selected item.
|
|
37
|
-
* Used by useSelect and useCombobox.
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} prevState
|
|
40
|
-
* @param {Object} newState
|
|
41
|
-
* @returns {boolean} Wheather the states are deeply equal.
|
|
42
|
-
*/
|
|
43
|
-
export function isDropdownsStateEqual(prevState: Object, newState: Object): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Returns the new highlightedIndex based on the defaultHighlightedIndex prop, if it's not disabled.
|
|
46
|
-
*
|
|
47
|
-
* @param {Object} props Props from useCombobox or useSelect.
|
|
48
|
-
* @returns {number} The highlighted index.
|
|
49
|
-
*/
|
|
50
|
-
export function getDefaultHighlightedIndex(props: Object): number;
|
|
51
|
-
export function getInitialState(props: any): {
|
|
52
|
-
highlightedIndex: any;
|
|
53
|
-
isOpen: unknown;
|
|
54
|
-
selectedItem: unknown;
|
|
55
|
-
inputValue: unknown;
|
|
56
|
-
};
|
|
57
|
-
import { noop } from "../utils-ts";
|
|
58
|
-
import * as React from "react";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { scrollIntoView } from '../../utils-ts';
|
|
2
|
-
import { stateReducer } from '../utils-ts';
|
|
3
|
-
export declare const defaultProps: {
|
|
4
|
-
itemToString(item: unknown): string;
|
|
5
|
-
itemToKey(item: unknown): unknown;
|
|
6
|
-
stateReducer: typeof stateReducer;
|
|
7
|
-
scrollIntoView: typeof scrollIntoView;
|
|
8
|
-
environment: (Window & typeof globalThis) | undefined;
|
|
9
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface Action<T> extends Record<string, unknown> {
|
|
2
|
-
type: T;
|
|
3
|
-
}
|
|
4
|
-
export type State = Record<string, unknown>;
|
|
5
|
-
export interface Props<S, T> {
|
|
6
|
-
onStateChange?(typeAndChanges: unknown): void;
|
|
7
|
-
stateReducer(state: S, actionAndChanges: Action<T> & {
|
|
8
|
-
changes: Partial<S>;
|
|
9
|
-
}): Partial<S>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* This will perform a shallow merge of the given state object
|
|
13
|
-
* with the state coming from props
|
|
14
|
-
* (for the controlled component scenario)
|
|
15
|
-
* This is used in state updater functions so they're referencing
|
|
16
|
-
* the right state regardless of where it comes from.
|
|
17
|
-
*
|
|
18
|
-
* @param state The state of the component/hook.
|
|
19
|
-
* @param props The props that may contain controlled values.
|
|
20
|
-
* @returns The merged controlled state.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getState<S extends State, P extends Partial<S> & Props<S, T>, T>(state: S, props?: P): S;
|
package/dist/utils.d.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accepts a parameter and returns it if it's a function
|
|
3
|
-
* or a noop function if it's not. This allows us to
|
|
4
|
-
* accept a callback, but not worry about it if it's not
|
|
5
|
-
* passed.
|
|
6
|
-
* @param {Function} cb the callback
|
|
7
|
-
* @return {Function} a function
|
|
8
|
-
*/
|
|
9
|
-
export function cbToCb(cb: Function): Function;
|
|
10
|
-
/**
|
|
11
|
-
* This is intended to be used to compose event handlers.
|
|
12
|
-
* They are executed in order until one of them sets
|
|
13
|
-
* `event.preventDownshiftDefault = true`.
|
|
14
|
-
* @param {...Function} fns the event handler functions
|
|
15
|
-
* @return {Function} the event handler to add to an element
|
|
16
|
-
*/
|
|
17
|
-
export function callAllEventHandlers(...fns: Function[]): Function;
|
|
18
|
-
export function handleRefs(...refs: any[]): (node: any) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Simple debounce implementation. Will call the given
|
|
21
|
-
* function once after the time given has passed since
|
|
22
|
-
* it was last called.
|
|
23
|
-
* @param {Function} fn the function to call after the time
|
|
24
|
-
* @param {Number} time the time to wait
|
|
25
|
-
* @return {Function} the debounced function
|
|
26
|
-
*/
|
|
27
|
-
export function debounce(fn: Function, time: number): Function;
|
|
28
|
-
/**
|
|
29
|
-
* Default implementation for status message. Only added when menu is open.
|
|
30
|
-
* Will specify if there are results in the list, and if so, how many,
|
|
31
|
-
* and what keys are relevant.
|
|
32
|
-
*
|
|
33
|
-
* @param {Object} param the downshift state and other relevant properties
|
|
34
|
-
* @return {String} the a11y status message
|
|
35
|
-
*/
|
|
36
|
-
export function getA11yStatusMessage({ isOpen, resultCount, previousResultCount }: Object): string;
|
|
37
|
-
/**
|
|
38
|
-
* Takes an argument and if it's an array, returns the first item in the array
|
|
39
|
-
* otherwise returns the argument
|
|
40
|
-
* @param {*} arg the maybe-array
|
|
41
|
-
* @param {*} defaultValue the value if arg is falsey not defined
|
|
42
|
-
* @return {*} the arg or it's first item
|
|
43
|
-
*/
|
|
44
|
-
export function unwrapArray(arg: any, defaultValue: any): any;
|
|
45
|
-
/**
|
|
46
|
-
* @param {Object} element (P)react element
|
|
47
|
-
* @return {Boolean} whether it's a DOM element
|
|
48
|
-
*/
|
|
49
|
-
export function isDOMElement(element: Object): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* @param {Object} element (P)react element
|
|
52
|
-
* @return {Object} the props
|
|
53
|
-
*/
|
|
54
|
-
export function getElementProps(element: Object): Object;
|
|
55
|
-
/**
|
|
56
|
-
* Throws a helpful error message for required properties. Useful
|
|
57
|
-
* to be used as a default in destructuring or object params.
|
|
58
|
-
* @param {String} fnName the function name
|
|
59
|
-
* @param {String} propName the prop name
|
|
60
|
-
*/
|
|
61
|
-
export function requiredProp(fnName: string, propName: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* @param {Object} state the state object
|
|
64
|
-
* @return {Object} state that is relevant to downshift
|
|
65
|
-
*/
|
|
66
|
-
export function pickState(state?: Object): Object;
|
|
67
|
-
/**
|
|
68
|
-
* Simple check if the value passed is object literal
|
|
69
|
-
* @param {*} obj any things
|
|
70
|
-
* @return {Boolean} whether it's object literal
|
|
71
|
-
*/
|
|
72
|
-
export function isPlainObject(obj: any): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Normalizes the 'key' property of a KeyboardEvent in IE/Edge
|
|
75
|
-
* @param {Object} event a keyboardEvent object
|
|
76
|
-
* @return {String} keyboard key
|
|
77
|
-
*/
|
|
78
|
-
export function normalizeArrowKey(event: Object): string;
|
|
79
|
-
/**
|
|
80
|
-
* Checks if event target is within the downshift elements.
|
|
81
|
-
*
|
|
82
|
-
* @param {EventTarget} target Target to check.
|
|
83
|
-
* @param {HTMLElement[]} downshiftElements The elements that form downshift (list, toggle button etc).
|
|
84
|
-
* @param {Window} environment The window context where downshift renders.
|
|
85
|
-
* @param {boolean} checkActiveElement Whether to also check activeElement.
|
|
86
|
-
*
|
|
87
|
-
* @returns {boolean} Whether or not the target is within downshift elements.
|
|
88
|
-
*/
|
|
89
|
-
export function targetWithinDownshift(target: EventTarget, downshiftElements: HTMLElement[], environment: Window, checkActiveElement?: boolean): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* This determines whether a prop is a "controlled prop" meaning it is
|
|
92
|
-
* state which is controlled by the outside of this component rather
|
|
93
|
-
* than within this component.
|
|
94
|
-
*
|
|
95
|
-
* @param {Object} props The props that may contain controlled values.
|
|
96
|
-
* @param {String} key the key to check
|
|
97
|
-
* @return {Boolean} whether it is a controlled controlled prop
|
|
98
|
-
*/
|
|
99
|
-
export function isControlledProp(props: Object, key: string): boolean;
|
|
100
|
-
export let validateControlledUnchanged: typeof noop;
|
|
101
|
-
/**
|
|
102
|
-
* Returns the next non-disabled highlightedIndex value.
|
|
103
|
-
*
|
|
104
|
-
* @param {number} start The current highlightedIndex.
|
|
105
|
-
* @param {number} offset The offset from the current highlightedIndex to start searching.
|
|
106
|
-
* @param {unknown[]} items The items array.
|
|
107
|
-
* @param {(item: unknown, index: number) => boolean} isItemDisabled Function that tells if an item is disabled or not.
|
|
108
|
-
* @param {boolean?} circular If the search reaches the end, if it can search again starting from the other end.
|
|
109
|
-
* @returns {number} The next highlightedIndex.
|
|
110
|
-
*/
|
|
111
|
-
export function getHighlightedIndex(start: number, offset: number, items: unknown[], isItemDisabled: (item: unknown, index: number) => boolean, circular?: boolean | null): number;
|
|
112
|
-
/**
|
|
113
|
-
* Returns the next non-disabled highlightedIndex value.
|
|
114
|
-
*
|
|
115
|
-
* @param {number} start The current highlightedIndex.
|
|
116
|
-
* @param {boolean} backwards If true, it will search backwards from the start.
|
|
117
|
-
* @param {unknown[]} items The items array.
|
|
118
|
-
* @param {(item: unknown, index: number) => boolean} isItemDisabled Function that tells if an item is disabled or not.
|
|
119
|
-
* @param {boolean} circular If the search reaches the end, if it can search again starting from the other end.
|
|
120
|
-
* @returns {number} The next non-disabled index.
|
|
121
|
-
*/
|
|
122
|
-
export function getNonDisabledIndex(start: number, backwards: boolean, items: unknown[], isItemDisabled: (item: unknown, index: number) => boolean, circular?: boolean): number;
|
|
123
|
-
import { noop } from "./utils-ts";
|