-
Notifications
You must be signed in to change notification settings - Fork 521
/
index.d.ts
263 lines (211 loc) · 5.85 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
import * as React from "react";
export type BatteryManager = {
supported: boolean;
loading: boolean;
level: number | null;
charging: boolean | null;
chargingTime: number | null;
dischargingTime: number | null;
};
export type GeolocationState = {
loading: boolean;
accuracy: number | null;
altitude: number | null;
altitudeAccuracy: number | null;
heading: number | null;
latitude: number | null;
longitude: number | null;
speed: number | null;
timestamp: number | null;
error: GeolocationPositionError | null;
};
export type HistoryState<T> = {
state: T;
set: (newPresent: T) => void;
undo: () => void;
redo: () => void;
clear: () => void;
canUndo: boolean;
canRedo: boolean;
};
export type LongPressOptions = {
threshold?: number;
onStart?: (e: Event) => void;
onFinish?: (e: Event) => void;
onCancel?: (e: Event) => void;
};
export type LongPressFns = {
onMouseDown: (e: React.MouseEvent) => void;
onMouseUp: (e: React.MouseEvent) => void;
onMouseLeave: (e: React.MouseEvent) => void;
onTouchStart: (e: React.TouchEvent) => void;
onTouchEnd: (e: React.TouchEvent) => void;
};
export type MousePosition = {
x: number;
y: number;
elementX: number;
elementY: number;
elementPositionX: number;
elementPositionY: number;
};
export type NetworkState = {
online: boolean;
downlink: number | null;
downlinkMax: number | null;
effectiveType: string | null;
rtt: number | null;
saveData: boolean | null;
type: string | null;
};
export type CustomList<T> = {
set: (l: T[]) => void;
push: (element: T) => void;
removeAt: (index: number) => void;
insertAt: (index: number, element: T) => void;
updateAt: (index: number, element: T) => void;
clear: () => void;
};
export type CustomQueue<T> = {
add: (element: T) => void;
remove: () => T | undefined;
clear: () => void;
first: T | undefined;
last: T | undefined;
size: number;
queue: T[];
};
export type RenderInfo = {
name: string;
renders: number;
sinceLastRender: number;
timestamp: number;
};
export type SpeechOptions = {
lang?: string;
voice?: {
lang?: string;
name?: string;
};
rate?: number;
pitch?: number;
volume?: number;
};
export type SpeechState = {
isPlaying: boolean;
status: "init" | "play" | "pause" | "stop";
lang: string;
voiceInfo: {
lang: string;
name: string;
};
rate: number;
pitch: number;
volume: number;
};
declare module "@uidotdev/usehooks" {
export function useBattery(): BatteryManager;
export function useClickAway<T extends Element>(
cb: (e: Event) => void
): React.MutableRefObject<T>;
export function useCopyToClipboard(): [
string | null,
(value: string) => Promise<void>
];
export function useCounter(
startingValue?: number,
options?: {
min?: number;
max?: number;
}
): [
number,
{
increment: () => void;
decrement: () => void;
set: (nextCount: number) => void;
reset: () => void;
}
];
export function useDebounce<T>(value: T, delay: number): T;
export function useDefault<T>(
initialValue: T,
defaultValue: T
): [T, React.Dispatch<React.SetStateAction<T>>];
export function useDocumentTitle(title: string): void;
export function useFavicon(url: string): void;
export function useGeolocation(options?: PositionOptions): GeolocationState;
export function useHistoryState<T>(initialPresent?: T): HistoryState<T>;
export function useHover<T extends Element>(): [
React.RefCallback<T>,
boolean
];
export function useIdle(ms?: number): boolean;
export function useIntersectionObserver<T extends Element>(
options?: IntersectionObserverInit
): [React.RefCallback<T>, IntersectionObserverEntry | null];
export function useIsClient(): boolean;
export function useIsFirstRender(): boolean;
export function useList<T>(defaultList?: T[]): [T[], CustomList<T>];
export function useLocalStorage<T>(
key: string,
initialValue?: T
): [T, React.Dispatch<React.SetStateAction<T>>];
export function useLockBodyScroll(): void;
export function useLongPress(
callback: (e: Event) => void,
options?: LongPressOptions
): LongPressFns;
export function useMap<T>(initialState?: T): Map<T, any>;
export function useMeasure<T extends Element>(): [
React.RefCallback<T>,
{
width: number | null;
height: number | null;
}
];
export function useMediaQuery(query: string): boolean;
export function useMouse<T extends Element>(): [
MousePosition,
React.MutableRefObject<T>
];
export function useNetworkState(): NetworkState;
export function useObjectState<T>(initialValue: T): [T, (arg: T) => void];
export function useOrientation(): {
angle: number;
type: string;
};
export function usePreferredLanguage(): string;
export function usePrevious<T>(newValue: T): T;
export function useQueue<T>(initialValue?: T[]): CustomQueue<T>;
export function useRenderCount(): number;
export function useRenderInfo(name?: string): RenderInfo | undefined;
export function useScript(
src: string,
options?: {
removeOnUnmount?: boolean;
}
): "unknown" | "loading" | "ready" | "error";
export function useSessionStorage<T>(
key: string,
initialValue: T
): [T, React.Dispatch<React.SetStateAction<T>>];
export function useSet<T>(values?: T[]): Set<T>;
export function useSpeech(text: string, options?: SpeechOptions): SpeechState;
export function useThrottle<T>(value: T, delay: number): T;
export function useToggle(
initialValue?: boolean
): [boolean, (newValue?: boolean) => void];
export function useVisibilityChange(): boolean;
export function useWindowScroll(): [
{
x: number | null;
y: number | null;
},
(args: unknown) => void
];
export function useWindowSize(): {
width: number | null;
height: number | null;
};
}