UNPKG

2.86 kBTypeScriptView Raw
1import * as React from 'react';
2import { ClassNamesState, InputActionMeta, OptionsType, OptionTypeBase, ValueType } from './types';
3
4// ==============================
5// NO OP
6// ==============================
7
8export function noop(): void;
9export function emptyString(): string;
10
11// ==============================
12// Class Name Prefixer
13// ==============================
14
15export function classNames(
16 prefix?: string | null,
17 cssKey?: string | null,
18 state?: ClassNamesState,
19 className?: string,
20): string;
21
22// ==============================
23// Clean Value
24// ==============================
25
26export function cleanValue<OptionType extends OptionTypeBase>(
27 value: ValueType<OptionType, boolean>,
28): OptionsType<OptionType>;
29
30// ==============================
31// Handle Input Change
32// ==============================
33
34export function handleInputChange(
35 inputValue: string,
36 actionMeta: InputActionMeta,
37 onInputChange?: (inputValue: string, actionMeta: InputActionMeta) => string | void,
38): string;
39
40// ==============================
41// Scroll Helpers
42// ==============================
43
44export function isDocumentElement(el: Element): boolean;
45
46// Normalized Scroll Top
47// ------------------------------
48
49export function normalizedHeight(el: Element): number;
50
51// Normalized scrollTo & scrollTop
52// ------------------------------
53
54export function getScrollTop(el: Element): number;
55
56export function scrollTo(el: Element, top: number): void;
57
58// Get Scroll Parent
59// ------------------------------
60
61export function getScrollParent(element: React.Ref<any>): Element;
62
63// Animated Scroll To
64// ------------------------------
65
66export function animatedScrollTo(
67 element: HTMLElement | typeof window,
68 to: number,
69 duration?: number,
70 callback?: (element: HTMLElement | typeof window) => void,
71): void;
72
73// Scroll Into View
74// ------------------------------
75
76export function scrollIntoView(menuEl: HTMLElement, focusedEl: HTMLElement): void;
77
78// ==============================
79// Get bounding client object
80// ==============================
81
82// cannot get keys using array notation with DOMRect
83export function getBoundingClientObj(
84 element: HTMLElement,
85): {
86 bottom: number;
87 height: number;
88 left: number;
89 right: number;
90 top: number;
91 width: number;
92};
93export interface RectType {
94 left: number;
95 right: number;
96 bottom: number;
97 height: number;
98 width: number;
99}
100
101// ==============================
102// String to Key (kebabify)
103// ==============================
104
105export function toKey(str: string): string;
106
107// ==============================
108// Touch Capability Detector
109// ==============================
110
111export function isTouchCapable(): boolean;
112
113// ==============================
114// Mobile Device Detector
115// ==============================
116
117export function isMobileDevice(): boolean;