@reactuses/core 4.0.11 → 5.0.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/index.cjs +2963 -5911
- package/dist/index.d.cts +2902 -0
- package/dist/index.d.mts +2902 -0
- package/dist/index.d.ts +2680 -664
- package/dist/index.mjs +2958 -5903
- package/package.json +22 -13
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2902 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { DependencyList, RefObject, MutableRefObject, EffectCallback, useEffect, Dispatch, SetStateAction, useLayoutEffect } from 'react';
|
|
3
|
+
import Cookies from 'js-cookie';
|
|
4
|
+
import { DebounceSettings, ThrottleSettings, DebouncedFunc as DebouncedFunc$1 } from 'lodash-es';
|
|
5
|
+
import * as lodash from 'lodash';
|
|
6
|
+
import { DebounceSettings as DebounceSettings$1, DebouncedFunc, ThrottleSettings as ThrottleSettings$1 } from 'lodash';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title useActiveElement
|
|
10
|
+
* @returns_en Returns an instance of the type parameter `T` or `null`.
|
|
11
|
+
* @returns 返回类型参数 `T` 或 `null` 的实例
|
|
12
|
+
*/
|
|
13
|
+
type UseActiveElement = <T extends Element>() => T | null;
|
|
14
|
+
|
|
15
|
+
declare const useActiveElement: UseActiveElement;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @title useAsyncEffect
|
|
20
|
+
*/
|
|
21
|
+
type UseAsyncEffect = <T>(
|
|
22
|
+
/**
|
|
23
|
+
* @zh 支持promise的副作用函数
|
|
24
|
+
* @en effect that support promise
|
|
25
|
+
*/
|
|
26
|
+
effect: () => Promise<T> | T,
|
|
27
|
+
/**
|
|
28
|
+
* @zh 清理函数
|
|
29
|
+
* @en cleanup function
|
|
30
|
+
* @defaultValue () => {}
|
|
31
|
+
*/
|
|
32
|
+
cleanup?: typeof effect,
|
|
33
|
+
/**
|
|
34
|
+
* @zh 依赖列表
|
|
35
|
+
* @en dependency list
|
|
36
|
+
*/
|
|
37
|
+
deps?: DependencyList) => void;
|
|
38
|
+
|
|
39
|
+
declare const useAsyncEffect: UseAsyncEffect;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @title useClickOutside
|
|
43
|
+
*/
|
|
44
|
+
type UseClickOutside = (
|
|
45
|
+
/**
|
|
46
|
+
* @zh dom对象
|
|
47
|
+
* @en dom element
|
|
48
|
+
*/
|
|
49
|
+
target: RefObject<Element>,
|
|
50
|
+
/**
|
|
51
|
+
* @zh 监听函数
|
|
52
|
+
* @en listener fucntion
|
|
53
|
+
*/
|
|
54
|
+
handler: (evt: EventType) => void) => void;
|
|
55
|
+
type EventType = MouseEvent | TouchEvent;
|
|
56
|
+
|
|
57
|
+
declare const useClickOutside: UseClickOutside;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @title useCookie
|
|
61
|
+
* @returns 包含以下元素的元组:
|
|
62
|
+
* - cookie 的当前值。
|
|
63
|
+
* - 更新 cookie 值的函数。
|
|
64
|
+
* - 刷新 cookie 值的函数,以防其他事件更改它。
|
|
65
|
+
* @returns_en A tuple with the following elements:
|
|
66
|
+
* - The current value of the cookie.
|
|
67
|
+
* - A function to update the value of the cookie.
|
|
68
|
+
* - A function to refresh the value of the cookie, incase other events change it.
|
|
69
|
+
*/
|
|
70
|
+
type UseCookie = (
|
|
71
|
+
/**
|
|
72
|
+
* @zh 键值
|
|
73
|
+
* @en key
|
|
74
|
+
*/
|
|
75
|
+
key: string,
|
|
76
|
+
/**
|
|
77
|
+
* @zh 透传给 `js-cookie` 的参数
|
|
78
|
+
* @en option pass to `js-cookie`
|
|
79
|
+
*/
|
|
80
|
+
options?: Cookies.CookieAttributes,
|
|
81
|
+
/**
|
|
82
|
+
* @zh 默认值,ssr必须传递
|
|
83
|
+
* @en defaultValue, must be required in ssr
|
|
84
|
+
*/
|
|
85
|
+
defaultValue?: string) => readonly [
|
|
86
|
+
UseCookieState,
|
|
87
|
+
(newValue: UseCookieState | ((prevState: UseCookieState) => UseCookieState)) => void,
|
|
88
|
+
() => void
|
|
89
|
+
];
|
|
90
|
+
/**
|
|
91
|
+
* @title useCookieState
|
|
92
|
+
*/
|
|
93
|
+
type UseCookieState = string | undefined;
|
|
94
|
+
|
|
95
|
+
declare const useCookie: UseCookie;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @title useCountdown
|
|
99
|
+
* @returns_en A tuple with the following elements:
|
|
100
|
+
* - hour
|
|
101
|
+
* - minute.
|
|
102
|
+
* - second.
|
|
103
|
+
* @returns 包含以下元素的元组:
|
|
104
|
+
* - 小时。
|
|
105
|
+
* - 分钟。
|
|
106
|
+
* - 秒数。
|
|
107
|
+
*/
|
|
108
|
+
type UseCountDown = (
|
|
109
|
+
/**
|
|
110
|
+
* @zh 时间差
|
|
111
|
+
* @en time differ
|
|
112
|
+
*/
|
|
113
|
+
time: number,
|
|
114
|
+
/**
|
|
115
|
+
* @zh 时间格式化函数
|
|
116
|
+
* @en time format function
|
|
117
|
+
* @defaultValue HH MM SS
|
|
118
|
+
*/
|
|
119
|
+
format?: (num: number) => [string, string, string],
|
|
120
|
+
/**
|
|
121
|
+
* @zh 倒计时结束的回调函数
|
|
122
|
+
* @en callback function for end of countdown
|
|
123
|
+
*/
|
|
124
|
+
callback?: () => void) => readonly [string, string, string];
|
|
125
|
+
|
|
126
|
+
declare const useCountDown: UseCountDown;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @title useCounter
|
|
130
|
+
* @returns_en A tuple with the following elements:
|
|
131
|
+
* - The current value of the counter.
|
|
132
|
+
* - A function to set the state of the counter. It can accept a number or a function that returns a number.
|
|
133
|
+
* - A function to increment the counter. It optionally accepts a number to increment the counter by, defaulting to 1.
|
|
134
|
+
* - A function to decrement the counter. It optionally accepts a number to decrement the counter by, defaulting to 1.
|
|
135
|
+
* - A function to reset the counter to its initial value.
|
|
136
|
+
* @returns 包含以下元素的元组:
|
|
137
|
+
* - 计数器的当前值。
|
|
138
|
+
* - 设置计数器状态的函数。 它可以接受数字或返回数字的函数。
|
|
139
|
+
* - 递增计数器的函数。 它可以选择接受一个数字来增加计数器,默认为 1。
|
|
140
|
+
* - 递减计数器的函数。 它可以选择接受一个数字来减少计数器,默认为 1。
|
|
141
|
+
* - 将计数器重置为其初始值的函数。
|
|
142
|
+
*/
|
|
143
|
+
type UseCounter = (
|
|
144
|
+
/**
|
|
145
|
+
* @zh 初始值,可以为数字或者一个初始化的函数
|
|
146
|
+
* @en The initial value of the counter. It can be a number or a function that returns a number. If not provided, the counter will start from 0.
|
|
147
|
+
* @defaultValue 0
|
|
148
|
+
*/
|
|
149
|
+
initialValue?: number | (() => number),
|
|
150
|
+
/**
|
|
151
|
+
* @zh 最大值。不提供则无上限
|
|
152
|
+
* @en The maximum value that the counter can reach. If not provided or null, there is no upper limit.
|
|
153
|
+
*/
|
|
154
|
+
max?: number | null,
|
|
155
|
+
/**
|
|
156
|
+
* @zh 最小值。不提供则无下限
|
|
157
|
+
* @en The minimum value that the counter can reach. If not provided or null, there is no lower limit.
|
|
158
|
+
*/
|
|
159
|
+
min?: number | null) => readonly [
|
|
160
|
+
number,
|
|
161
|
+
(newState: number | ((prev: number) => number) | (() => number)) => void,
|
|
162
|
+
(delta?: number) => void,
|
|
163
|
+
(delta?: number) => void,
|
|
164
|
+
() => void
|
|
165
|
+
];
|
|
166
|
+
|
|
167
|
+
declare const useCounter: UseCounter;
|
|
168
|
+
|
|
169
|
+
type TargetValue<T> = T | undefined | null;
|
|
170
|
+
type TargetType = HTMLElement | Element | Window | Document | EventTarget;
|
|
171
|
+
type BasicTarget<T extends TargetType = Element> = (() => TargetValue<T>) | TargetValue<T> | MutableRefObject<TargetValue<T>>;
|
|
172
|
+
|
|
173
|
+
declare const defaultOptions: UseCssVarOptions;
|
|
174
|
+
/**
|
|
175
|
+
* @title useCssVar
|
|
176
|
+
* @returns_en A tuple with the following elements:
|
|
177
|
+
* - The current value of the css var.
|
|
178
|
+
* - A function to update the value of the css var.
|
|
179
|
+
* @returns 包含以下元素的元组:
|
|
180
|
+
* - css 变量值
|
|
181
|
+
* - 更新 css 变量值的函数
|
|
182
|
+
*/
|
|
183
|
+
type UseCssVar = <T extends HTMLElement = HTMLElement>(
|
|
184
|
+
/**
|
|
185
|
+
* @zh 属性值,比如 --color
|
|
186
|
+
* @en prop, eg: --color
|
|
187
|
+
*/
|
|
188
|
+
prop: string,
|
|
189
|
+
/**
|
|
190
|
+
* @zh dom元素
|
|
191
|
+
* @en dom element
|
|
192
|
+
*/
|
|
193
|
+
target: BasicTarget<T>,
|
|
194
|
+
/**
|
|
195
|
+
* @zh 默认值
|
|
196
|
+
* @en default value
|
|
197
|
+
*/
|
|
198
|
+
defaultValue?: string,
|
|
199
|
+
/**
|
|
200
|
+
* @zh 可选项
|
|
201
|
+
* @en options
|
|
202
|
+
*/
|
|
203
|
+
options?: UseCssVarOptions) => readonly [string, (v: string) => void];
|
|
204
|
+
/**
|
|
205
|
+
* @title UseCssVarOptions
|
|
206
|
+
*/
|
|
207
|
+
interface UseCssVarOptions {
|
|
208
|
+
/**
|
|
209
|
+
* @en Use MutationObserver to monitor variable changes
|
|
210
|
+
* @zh 使用 MutationObserver 来监听变量变更
|
|
211
|
+
* @defaultValue false
|
|
212
|
+
*/
|
|
213
|
+
observe?: boolean;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare const useCssVar: UseCssVar;
|
|
217
|
+
|
|
218
|
+
type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
|
|
219
|
+
/**
|
|
220
|
+
* @title useCustomCompareEffect
|
|
221
|
+
*/
|
|
222
|
+
type UseCustomCompareEffect = <TDeps extends DependencyList>(
|
|
223
|
+
/**
|
|
224
|
+
* @zh 副作用函数
|
|
225
|
+
* @en effect callback
|
|
226
|
+
*/
|
|
227
|
+
effect: EffectCallback,
|
|
228
|
+
/**
|
|
229
|
+
* @zh 依赖列表
|
|
230
|
+
* @en deps
|
|
231
|
+
*/
|
|
232
|
+
deps: TDeps,
|
|
233
|
+
/**
|
|
234
|
+
* @zh 依赖比较函数
|
|
235
|
+
* @en deps compare function
|
|
236
|
+
*/
|
|
237
|
+
depsEqual: DepsEqualFnType<TDeps>) => void;
|
|
238
|
+
|
|
239
|
+
declare const useCustomCompareEffect: UseCustomCompareEffect;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @title useCycleList
|
|
243
|
+
* @returns_en A tuple with the following elements:
|
|
244
|
+
* - The current index value of the list.
|
|
245
|
+
* - A function to set index to prev.
|
|
246
|
+
* - A function to set index to next.
|
|
247
|
+
* @returns 包含以下元素的元组:
|
|
248
|
+
* - 数组中当前的索引对象值
|
|
249
|
+
* - 设置索引为前一个的函数
|
|
250
|
+
* - 设置索引为后一个的函数
|
|
251
|
+
*/
|
|
252
|
+
type UseCycleList = <T>(
|
|
253
|
+
/**
|
|
254
|
+
* @zh 循环数组
|
|
255
|
+
* @en cycle array
|
|
256
|
+
*/
|
|
257
|
+
list: T[],
|
|
258
|
+
/**
|
|
259
|
+
* @zh 数组索引
|
|
260
|
+
* @en array index
|
|
261
|
+
*/
|
|
262
|
+
i?: number) => readonly [T, (i?: number) => void, (i?: number) => void];
|
|
263
|
+
|
|
264
|
+
declare const useCycleList: UseCycleList;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @title UseDarkOptions
|
|
268
|
+
*/
|
|
269
|
+
interface UseDarkOptions {
|
|
270
|
+
/**
|
|
271
|
+
* @en CSS Selector for the target element applying to
|
|
272
|
+
* @zh 适用于目标元素的 CSS 选择器
|
|
273
|
+
* @defaultValue 'html'
|
|
274
|
+
*/
|
|
275
|
+
selector?: string;
|
|
276
|
+
/**
|
|
277
|
+
* @en HTML attribute applying the target element
|
|
278
|
+
* @zh 应用到目标元素的 html 属性
|
|
279
|
+
* @defaultValue 'class'
|
|
280
|
+
*/
|
|
281
|
+
attribute?: string;
|
|
282
|
+
/**
|
|
283
|
+
* @en default value
|
|
284
|
+
* @zh 默认值
|
|
285
|
+
* @defaultValue false
|
|
286
|
+
*/
|
|
287
|
+
defaultValue?: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* @en Key to persist the data into localStorage/sessionStorage.
|
|
290
|
+
* @zh 将数据持久保存到 localStorage/sessionStorage 的键值
|
|
291
|
+
* @defaultValue 'reactuses-color-scheme'
|
|
292
|
+
*/
|
|
293
|
+
storageKey?: string;
|
|
294
|
+
/**
|
|
295
|
+
* @en Storage object, can be localStorage or sessionStorage
|
|
296
|
+
* @zh 存储对象,可以是localStorage或sessionStorage
|
|
297
|
+
* @defaultValue `localStorage`
|
|
298
|
+
*/
|
|
299
|
+
storage?: () => Storage;
|
|
300
|
+
/**
|
|
301
|
+
* @en name dark apply to element
|
|
302
|
+
* @zh 应用到目标元素上黑色类名称
|
|
303
|
+
*/
|
|
304
|
+
classNameDark: string;
|
|
305
|
+
/**
|
|
306
|
+
* @en name light apply to element
|
|
307
|
+
* @zh 应用到目标元素上的亮色类名称
|
|
308
|
+
*/
|
|
309
|
+
classNameLight: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* @title useDarkMode
|
|
313
|
+
* @returns_en A tuple with the following elements:
|
|
314
|
+
* - The current value of the dark state.
|
|
315
|
+
* - A function to toggle the dark state.
|
|
316
|
+
* - A function to update the dark state.
|
|
317
|
+
* @returns 包含以下元素的元组:
|
|
318
|
+
* - 黑暗状态的当前值。
|
|
319
|
+
* - 切换黑暗状态的功能。
|
|
320
|
+
* - 更新黑暗状态的功能。
|
|
321
|
+
*/
|
|
322
|
+
type UseDarkMode = (options: UseDarkOptions) => readonly [
|
|
323
|
+
boolean | null,
|
|
324
|
+
() => void,
|
|
325
|
+
React.Dispatch<React.SetStateAction<boolean | null>>
|
|
326
|
+
];
|
|
327
|
+
|
|
328
|
+
declare const useDarkMode: UseDarkMode;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @title useDebounce
|
|
332
|
+
*/
|
|
333
|
+
type UseDebounce = <T>(
|
|
334
|
+
/**
|
|
335
|
+
* @zh 要防抖的值
|
|
336
|
+
* @en the value need to debounce
|
|
337
|
+
*/
|
|
338
|
+
value: T,
|
|
339
|
+
/**
|
|
340
|
+
* @zh 间隔时间
|
|
341
|
+
* @en wait time
|
|
342
|
+
*/
|
|
343
|
+
wait?: number,
|
|
344
|
+
/**
|
|
345
|
+
* @zh 传递给 `lodash.debounce` 的选项
|
|
346
|
+
* @en options passed to `lodash.debounce`
|
|
347
|
+
*/
|
|
348
|
+
options?: DebounceSettings) => T;
|
|
349
|
+
|
|
350
|
+
declare const useDebounce: UseDebounce;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* @title useDebounceFn
|
|
354
|
+
* @returns_en A object with the following elements:
|
|
355
|
+
* - run: exec function.
|
|
356
|
+
* - cancel: cancel exec function.
|
|
357
|
+
* - flush: immediately exec function
|
|
358
|
+
* @returns 具有以下元素的对象:
|
|
359
|
+
* - run:执行函数。
|
|
360
|
+
* - cancel:取消执行函数。
|
|
361
|
+
* - flush: 立即执行函数
|
|
362
|
+
*/
|
|
363
|
+
type UseDebounceFn = <T extends (...args: any) => any>(
|
|
364
|
+
/**
|
|
365
|
+
* @zh 要防抖的函数
|
|
366
|
+
* @en debounce function
|
|
367
|
+
*/
|
|
368
|
+
fn: T,
|
|
369
|
+
/**
|
|
370
|
+
* @zh 间隔时间
|
|
371
|
+
* @en wait time
|
|
372
|
+
*/
|
|
373
|
+
wait?: number,
|
|
374
|
+
/**
|
|
375
|
+
* @zh 传递给 `lodash.debounce` 的属性
|
|
376
|
+
* @en options passed to `lodash.debounce`
|
|
377
|
+
*/
|
|
378
|
+
options?: DebounceSettings$1) => {
|
|
379
|
+
run: DebouncedFunc<(...args_0: Parameters<T>) => ReturnType<T>>;
|
|
380
|
+
cancel: () => void;
|
|
381
|
+
flush: any;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
declare const useDebounceFn: UseDebounceFn;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @title useDeepCompareEffect
|
|
388
|
+
*/
|
|
389
|
+
type UseDeepCompareEffect = (
|
|
390
|
+
/**
|
|
391
|
+
* @zh 副作用函数
|
|
392
|
+
* @en effect function
|
|
393
|
+
*/
|
|
394
|
+
effect: EffectCallback,
|
|
395
|
+
/**
|
|
396
|
+
* @zh 依赖列表
|
|
397
|
+
* @en dep list
|
|
398
|
+
*/
|
|
399
|
+
deps: DependencyList) => void;
|
|
400
|
+
|
|
401
|
+
declare const useDeepCompareEffect: UseDeepCompareEffect;
|
|
402
|
+
|
|
403
|
+
declare const useDocumentVisibility: (defaultValue?: DocumentVisibilityState) => DocumentVisibilityState;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* @title useDoubleClick
|
|
407
|
+
*/
|
|
408
|
+
type UseDoubleClick = (props: UseDoubleClickProps) => void;
|
|
409
|
+
/**
|
|
410
|
+
* @title UseDoubleClickProps
|
|
411
|
+
*/
|
|
412
|
+
interface UseDoubleClickProps {
|
|
413
|
+
/**
|
|
414
|
+
* @zh dom对象
|
|
415
|
+
* @en dom element
|
|
416
|
+
*/
|
|
417
|
+
target: RefObject<Element>;
|
|
418
|
+
/**
|
|
419
|
+
* @zh 延迟时间(毫秒)
|
|
420
|
+
* @en latency time (milliseconds)
|
|
421
|
+
*/
|
|
422
|
+
latency?: number | undefined;
|
|
423
|
+
/**
|
|
424
|
+
* @zh 单击事件处理函数
|
|
425
|
+
* @en single click event handler
|
|
426
|
+
*/
|
|
427
|
+
onSingleClick?: ((e?: MouseEvent | TouchEvent) => void) | undefined;
|
|
428
|
+
/**
|
|
429
|
+
* @zh 双击事件处理函数
|
|
430
|
+
* @en double click event handler
|
|
431
|
+
*/
|
|
432
|
+
onDoubleClick?: ((e?: MouseEvent | TouchEvent) => void) | undefined;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
declare const useDoubleClick: UseDoubleClick;
|
|
436
|
+
|
|
437
|
+
type Fn = (this: any, ...args: any[]) => any;
|
|
438
|
+
type Stoppable = [boolean, Fn, Fn];
|
|
439
|
+
type PointerType = "mouse" | "touch" | "pen";
|
|
440
|
+
interface Position {
|
|
441
|
+
x: number;
|
|
442
|
+
y: number;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @title useDraggable
|
|
447
|
+
* @returns 包含以下元素的元组:
|
|
448
|
+
* - x
|
|
449
|
+
* - y
|
|
450
|
+
* - 元素是否在拖动中
|
|
451
|
+
* @returns_en A tuple with the following elements:
|
|
452
|
+
* - x
|
|
453
|
+
* - y
|
|
454
|
+
* - Whether the element is being dragged
|
|
455
|
+
*/
|
|
456
|
+
type UseDraggable = (
|
|
457
|
+
/**
|
|
458
|
+
* @zh dom对象
|
|
459
|
+
* @en dom element
|
|
460
|
+
*/
|
|
461
|
+
target: RefObject<HTMLElement | SVGElement>,
|
|
462
|
+
/**
|
|
463
|
+
* @zh 可选参数
|
|
464
|
+
* @en optional params
|
|
465
|
+
*/
|
|
466
|
+
options?: UseDraggableOptions) => readonly [number, number, boolean];
|
|
467
|
+
/**
|
|
468
|
+
* @title UseDraggableOptions
|
|
469
|
+
*/
|
|
470
|
+
interface UseDraggableOptions {
|
|
471
|
+
/**
|
|
472
|
+
* @en Only start the dragging when click on the element directly
|
|
473
|
+
* @zh 仅当直接单击元素时才开始拖动
|
|
474
|
+
* @defaultValue false
|
|
475
|
+
*/
|
|
476
|
+
exact?: boolean;
|
|
477
|
+
/**
|
|
478
|
+
* @en Prevent events defaults
|
|
479
|
+
* @zh 阻止默认事件
|
|
480
|
+
* @defaultValue false
|
|
481
|
+
*/
|
|
482
|
+
preventDefault?: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* @en Prevent events propagation
|
|
485
|
+
* @zh 阻止事件冒泡
|
|
486
|
+
* @defaultValue false
|
|
487
|
+
*/
|
|
488
|
+
stopPropagation?: boolean;
|
|
489
|
+
/**
|
|
490
|
+
* @en Element to attach `pointermove` and `pointerup` events to.
|
|
491
|
+
* @zh 将“pointermove”和“pointerup”事件附加到的dom元素
|
|
492
|
+
* @defaultValue window
|
|
493
|
+
*/
|
|
494
|
+
draggingElement?: RefObject<HTMLElement | SVGElement | Window | Document>;
|
|
495
|
+
/**
|
|
496
|
+
* @en Handle that triggers the drag event
|
|
497
|
+
* @zh 触发拖动事件的dom元素
|
|
498
|
+
* @defaultValue target
|
|
499
|
+
*/
|
|
500
|
+
handle?: RefObject<HTMLElement | SVGElement>;
|
|
501
|
+
/**
|
|
502
|
+
* @en Pointer types that listen to.
|
|
503
|
+
* @zh 监听的事件类型
|
|
504
|
+
* @defaultValue ['mouse', 'touch', 'pen']
|
|
505
|
+
*/
|
|
506
|
+
pointerTypes?: PointerType[];
|
|
507
|
+
/**
|
|
508
|
+
* @en Initial position of the element.
|
|
509
|
+
* @zh 初始的元素位置
|
|
510
|
+
* @defaultValue { x: 0, y: 0 }
|
|
511
|
+
*/
|
|
512
|
+
initialValue?: Position;
|
|
513
|
+
/**
|
|
514
|
+
* @en Callback when the dragging starts. Return `false` to prevent dragging.
|
|
515
|
+
* @zh 拖动开始时的回调。 返回“false”以防止拖动
|
|
516
|
+
*/
|
|
517
|
+
onStart?: (position: Position, event: PointerEvent) => void | false;
|
|
518
|
+
/**
|
|
519
|
+
* @en Callback during dragging.
|
|
520
|
+
* @zh 拖动时候的回调
|
|
521
|
+
*/
|
|
522
|
+
onMove?: (position: Position, event: PointerEvent) => void;
|
|
523
|
+
/**
|
|
524
|
+
* @en Callback when dragging end.
|
|
525
|
+
* @zh 拖动结束的回调
|
|
526
|
+
*/
|
|
527
|
+
onEnd?: (position: Position, event: PointerEvent) => void;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
declare const useDraggable: UseDraggable;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* @title useDropZone
|
|
534
|
+
* @returns 文件是否在区域上
|
|
535
|
+
* @returns_en Whether the file is on the zone
|
|
536
|
+
*/
|
|
537
|
+
type UseDropZone = (
|
|
538
|
+
/**
|
|
539
|
+
* @zh 目标元素
|
|
540
|
+
* @en target element
|
|
541
|
+
*/
|
|
542
|
+
target: RefObject<EventTarget>,
|
|
543
|
+
/**
|
|
544
|
+
* @zh 拖拽释放时候的回调
|
|
545
|
+
* @en drop callback
|
|
546
|
+
*/
|
|
547
|
+
onDrop?: ((files: File[] | null) => void) | undefined) => boolean;
|
|
548
|
+
|
|
549
|
+
declare const useDropZone: UseDropZone;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* @title useElementBounding
|
|
553
|
+
*/
|
|
554
|
+
type UseElementBounding = (
|
|
555
|
+
/**
|
|
556
|
+
* @zh 目标元素
|
|
557
|
+
* @en target element
|
|
558
|
+
*/
|
|
559
|
+
target: RefObject<Element>,
|
|
560
|
+
/**
|
|
561
|
+
* @zh 可选参数
|
|
562
|
+
* @en optional params
|
|
563
|
+
*/
|
|
564
|
+
options?: UseElementBoundingOptions) => UseElementBoundingReturn;
|
|
565
|
+
/**
|
|
566
|
+
* @title UseElementBoundingOptions
|
|
567
|
+
*/
|
|
568
|
+
interface UseElementBoundingOptions {
|
|
569
|
+
/**
|
|
570
|
+
* @en Reset values to 0 on component unmounted
|
|
571
|
+
* @zh 将数值重置为0
|
|
572
|
+
* @defaultValue true
|
|
573
|
+
*/
|
|
574
|
+
reset?: boolean;
|
|
575
|
+
/**
|
|
576
|
+
* @en Listen to window resize event
|
|
577
|
+
* @zh 是否监听 resize 事件
|
|
578
|
+
* @defaultValue true
|
|
579
|
+
*/
|
|
580
|
+
windowResize?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* @en Listen to window scroll event
|
|
583
|
+
* @zh 是否监听 scroll 事件
|
|
584
|
+
* @defaultValue true
|
|
585
|
+
*/
|
|
586
|
+
windowScroll?: boolean;
|
|
587
|
+
/**
|
|
588
|
+
* @en Immediately call update on component mounted
|
|
589
|
+
* @zh 立即更新
|
|
590
|
+
* @default true
|
|
591
|
+
*/
|
|
592
|
+
immediate?: boolean;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* @title UseElementBoundingReturn
|
|
596
|
+
*/
|
|
597
|
+
interface UseElementBoundingReturn {
|
|
598
|
+
/**
|
|
599
|
+
* @en Height of the element
|
|
600
|
+
* @zh 元素的高度
|
|
601
|
+
*/
|
|
602
|
+
readonly height: number;
|
|
603
|
+
/**
|
|
604
|
+
* @en Bottom position of the element
|
|
605
|
+
* @zh 元素的底部位置
|
|
606
|
+
*/
|
|
607
|
+
readonly bottom: number;
|
|
608
|
+
/**
|
|
609
|
+
* @en Left position of the element
|
|
610
|
+
* @zh 元素的左侧位置
|
|
611
|
+
*/
|
|
612
|
+
readonly left: number;
|
|
613
|
+
/**
|
|
614
|
+
* @en Right position of the element
|
|
615
|
+
* @zh 元素的右侧位置
|
|
616
|
+
*/
|
|
617
|
+
readonly right: number;
|
|
618
|
+
/**
|
|
619
|
+
* @en Top position of the element
|
|
620
|
+
* @zh 元素的顶部位置
|
|
621
|
+
*/
|
|
622
|
+
readonly top: number;
|
|
623
|
+
/**
|
|
624
|
+
* @en Width of the element
|
|
625
|
+
* @zh 元素的宽度
|
|
626
|
+
*/
|
|
627
|
+
readonly width: number;
|
|
628
|
+
/**
|
|
629
|
+
* @en X position of the element
|
|
630
|
+
* @zh 元素的 X 位置
|
|
631
|
+
*/
|
|
632
|
+
readonly x: number;
|
|
633
|
+
/**
|
|
634
|
+
* @en Y position of the element
|
|
635
|
+
* @zh 元素的 Y 位置
|
|
636
|
+
*/
|
|
637
|
+
readonly y: number;
|
|
638
|
+
/**
|
|
639
|
+
* @en Manual update
|
|
640
|
+
* @zh 手动更新
|
|
641
|
+
*/
|
|
642
|
+
readonly update: () => void;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
declare const useElementBounding: UseElementBounding;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @title useElementSize
|
|
649
|
+
* @returns_en A tuple with the following elements:
|
|
650
|
+
* - width
|
|
651
|
+
* - height
|
|
652
|
+
* @returns 包含以下元素的元组:
|
|
653
|
+
* - 元素宽度。
|
|
654
|
+
* - 元素高度。
|
|
655
|
+
*/
|
|
656
|
+
type UseElementSize = (
|
|
657
|
+
/**
|
|
658
|
+
* @zh dom对象
|
|
659
|
+
* @en dom element
|
|
660
|
+
*/
|
|
661
|
+
target: RefObject<Element>,
|
|
662
|
+
/**
|
|
663
|
+
* @zh `resizeObserver` 参数
|
|
664
|
+
* @en options passed to `resizeObserver`
|
|
665
|
+
*/
|
|
666
|
+
options?: ResizeObserverOptions) => readonly [number, number];
|
|
667
|
+
|
|
668
|
+
declare const useElementSize: UseElementSize;
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* @title useElementVisibility
|
|
672
|
+
* @returns 包含以下元素的元组:
|
|
673
|
+
* - 当前元素是否可见。
|
|
674
|
+
* - 停止监听函数。
|
|
675
|
+
* @returns_en A tuple with the following elements:
|
|
676
|
+
* - is the current element visible.
|
|
677
|
+
* - stop observer listening function.
|
|
678
|
+
*/
|
|
679
|
+
type UseElementVisibility = (
|
|
680
|
+
/**
|
|
681
|
+
* @zh dom对象
|
|
682
|
+
* @en dom element
|
|
683
|
+
*/
|
|
684
|
+
target: RefObject<HTMLElement | SVGElement>,
|
|
685
|
+
/**
|
|
686
|
+
* @zh 传递给 `intersectionObserver` 的选项
|
|
687
|
+
* @en options passed to `intersectionObserver`
|
|
688
|
+
*/
|
|
689
|
+
options?: IntersectionObserverInit) => readonly [boolean, () => void];
|
|
690
|
+
|
|
691
|
+
declare const useElementVisibility: UseElementVisibility;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* @title useEvent
|
|
695
|
+
*/
|
|
696
|
+
type UseEvent = <T extends Fn>(
|
|
697
|
+
/**
|
|
698
|
+
* @zh 函数
|
|
699
|
+
* @en function
|
|
700
|
+
*/
|
|
701
|
+
fn: T) => T;
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* keep function reference immutable
|
|
705
|
+
*/
|
|
706
|
+
declare const useEvent: UseEvent;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* @title useEventEmitter
|
|
710
|
+
* @returns 包含以下元素的元组:
|
|
711
|
+
* - 添加监听器的函数。
|
|
712
|
+
* - 触发函数。
|
|
713
|
+
* - 停止函数。
|
|
714
|
+
* @returns_en A tuple with the following elements:
|
|
715
|
+
* - a function to add lisenter.
|
|
716
|
+
* - fire functiion.
|
|
717
|
+
* stop functiion
|
|
718
|
+
*/
|
|
719
|
+
type UseEventEmitter = <T, U = void>() => readonly [
|
|
720
|
+
UseEventEmitterEvent<T, U>,
|
|
721
|
+
(arg1: T, arg2: U) => void,
|
|
722
|
+
() => void
|
|
723
|
+
];
|
|
724
|
+
interface UseEventEmitterListener<T, U = void> {
|
|
725
|
+
(arg1: T, arg2: U): void;
|
|
726
|
+
}
|
|
727
|
+
interface UseEventEmitterDisposable {
|
|
728
|
+
dispose(): void;
|
|
729
|
+
}
|
|
730
|
+
interface UseEventEmitterEvent<T, U = void> {
|
|
731
|
+
(listener: (arg1: T, arg2: U) => any): UseEventEmitterDisposable;
|
|
732
|
+
}
|
|
733
|
+
interface UseEventEmitterEventOnce<T, U = void> {
|
|
734
|
+
(listener: (arg1: T, arg2: U) => any): void;
|
|
735
|
+
}
|
|
736
|
+
interface UseEventEmitterReturn<T, U = void> {
|
|
737
|
+
/**
|
|
738
|
+
* Subscribe to an event. When calling emit, the listeners will execute.
|
|
739
|
+
* @param listener watch listener.
|
|
740
|
+
* @returns a stop function to remove the current callback.
|
|
741
|
+
*/
|
|
742
|
+
event: UseEventEmitterEvent<T, U>;
|
|
743
|
+
/**
|
|
744
|
+
* fire an event, the corresponding event listeners will execute.
|
|
745
|
+
* @param event data sent.
|
|
746
|
+
*/
|
|
747
|
+
fire: (arg1: T, arg2: U) => void;
|
|
748
|
+
/**
|
|
749
|
+
* Remove all corresponding listener.
|
|
750
|
+
*/
|
|
751
|
+
dispose: () => void;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
declare const useEventEmitter: <T, U = void>() => readonly [UseEventEmitterEvent<T, U>, (arg1: T, arg2: U) => void, () => void];
|
|
755
|
+
|
|
756
|
+
type Target = BasicTarget<HTMLElement | Element | Window | Document | EventTarget>;
|
|
757
|
+
declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: Window, options?: boolean | AddEventListenerOptions): void;
|
|
758
|
+
declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: Document, options?: boolean | AddEventListenerOptions): void;
|
|
759
|
+
declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: T, options?: boolean | AddEventListenerOptions): void;
|
|
760
|
+
declare function useEventListener<K extends keyof ElementEventMap>(eventName: K, handler: (event: ElementEventMap[K]) => void, element: Element, options?: boolean | AddEventListenerOptions): void;
|
|
761
|
+
declare function useEventListener<K = Event>(eventName: string, handler: (event: K) => void, element: EventTarget | null | undefined, options?: boolean | AddEventListenerOptions): void;
|
|
762
|
+
declare function useEventListener(eventName: string, handler: (...p: any) => void, element?: Target, options?: boolean | AddEventListenerOptions): void;
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* @title useEyeDropper
|
|
766
|
+
* @returns 包含以下元素的元组:
|
|
767
|
+
* - 浏览器是否支持该特性。
|
|
768
|
+
* - 打开颜色选择器的函数。
|
|
769
|
+
* @returns_en A tuple with the following elements:
|
|
770
|
+
* - Whether the browser supports this feature.
|
|
771
|
+
* - A function to open eye dropper.
|
|
772
|
+
*/
|
|
773
|
+
type UseEyeDropper = () => readonly [
|
|
774
|
+
boolean,
|
|
775
|
+
(options?: UseEyeDropperOpenOptions) => Promise<UseEyeDropperOpenReturnType>
|
|
776
|
+
];
|
|
777
|
+
/**
|
|
778
|
+
* @title UseEyeDropperOpenOptions
|
|
779
|
+
*/
|
|
780
|
+
interface UseEyeDropperOpenOptions {
|
|
781
|
+
/**
|
|
782
|
+
* @zh 终止信号
|
|
783
|
+
* @en abort signal
|
|
784
|
+
*/
|
|
785
|
+
signal?: AbortSignal;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* @title UseEyeDropperOpenReturnType
|
|
789
|
+
*/
|
|
790
|
+
interface UseEyeDropperOpenReturnType {
|
|
791
|
+
/**
|
|
792
|
+
* @zh rgb 颜色值
|
|
793
|
+
* @en rgb color value
|
|
794
|
+
*/
|
|
795
|
+
sRGBHex: string;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
declare const useEyeDropper: UseEyeDropper;
|
|
799
|
+
|
|
800
|
+
declare const useFavicon: (href: string, baseUrl?: string, rel?: string) => void;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* @title useFileDialog
|
|
804
|
+
* @returns 包含以下元素的元组:
|
|
805
|
+
* - 文件数组。
|
|
806
|
+
* - 打开文件选择器函数。
|
|
807
|
+
* - 重置函数。
|
|
808
|
+
* @returns_en A tuple with the following elements:
|
|
809
|
+
* - file array.
|
|
810
|
+
* - A function to open file dialog.
|
|
811
|
+
* - A function to reset files
|
|
812
|
+
*/
|
|
813
|
+
type UseFileDialog = (options?: UseFileDialogOptions) => readonly [
|
|
814
|
+
FileList | null,
|
|
815
|
+
(localOptions?: Partial<UseFileDialogOptions>) => void,
|
|
816
|
+
() => void
|
|
817
|
+
];
|
|
818
|
+
/**
|
|
819
|
+
* @title UseFileDialogOptions
|
|
820
|
+
*/
|
|
821
|
+
interface UseFileDialogOptions {
|
|
822
|
+
/**
|
|
823
|
+
* @zh 选择多个文件
|
|
824
|
+
* @en choose multiple file
|
|
825
|
+
* @defaultValue true
|
|
826
|
+
*/
|
|
827
|
+
multiple?: boolean;
|
|
828
|
+
/**
|
|
829
|
+
* @zh 可以接受的文件类型
|
|
830
|
+
* @en accept file type
|
|
831
|
+
* @defaultValue '*'
|
|
832
|
+
*/
|
|
833
|
+
accept?: string;
|
|
834
|
+
/**
|
|
835
|
+
* @zh [指定设备,可以从麦克风或者摄像头中获取文件](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
|
836
|
+
* @en [Specify the device to obtain files from the microphone or camera](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
|
837
|
+
* @see [HTMLInputElement Capture](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
|
838
|
+
*/
|
|
839
|
+
capture?: string;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
declare const useFileDialog: UseFileDialog;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* @title useFirstMountState
|
|
846
|
+
*/
|
|
847
|
+
type UseFirstMountState = () => boolean;
|
|
848
|
+
|
|
849
|
+
declare const useFirstMountState: UseFirstMountState;
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* @title useFocus
|
|
853
|
+
* @returns 包含以下元素的元组:
|
|
854
|
+
* - 元素是否聚焦。
|
|
855
|
+
* - 更新聚焦状态。
|
|
856
|
+
* @returns_en A tuple with the following elements:
|
|
857
|
+
* - whether the element focus.
|
|
858
|
+
* - A function to update focus state.
|
|
859
|
+
*/
|
|
860
|
+
type UseFocus = (
|
|
861
|
+
/**
|
|
862
|
+
* @zh dom对象
|
|
863
|
+
* @en dom element
|
|
864
|
+
*/
|
|
865
|
+
target: RefObject<HTMLElement | SVGElement>,
|
|
866
|
+
/**
|
|
867
|
+
* @zh 默认值
|
|
868
|
+
* @en defaultValue
|
|
869
|
+
* @defaultValue false
|
|
870
|
+
*/
|
|
871
|
+
initialValue?: boolean) => readonly [boolean, (value: boolean) => void];
|
|
872
|
+
|
|
873
|
+
declare const useFocus: UseFocus;
|
|
874
|
+
|
|
875
|
+
/**
|
|
876
|
+
* @title useFps
|
|
877
|
+
* @returns 每秒帧数
|
|
878
|
+
* @returns_en frames per second
|
|
879
|
+
*/
|
|
880
|
+
type UseFps = (options?: UseFpsOptions) => number;
|
|
881
|
+
/**
|
|
882
|
+
* @title UseFpsOptions
|
|
883
|
+
*/
|
|
884
|
+
interface UseFpsOptions {
|
|
885
|
+
/**
|
|
886
|
+
* @en Calculate the FPS on every x frames.
|
|
887
|
+
* @zh 每过 x 帧计算一次
|
|
888
|
+
* @defaultValue 10
|
|
889
|
+
*/
|
|
890
|
+
every?: number;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
declare const useFps: (options?: UseFpsOptions) => number;
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* @title useFullScreen
|
|
897
|
+
* @returns 包含以下元素的元组:
|
|
898
|
+
* - 当前是否处于全屏。
|
|
899
|
+
* - 一个操作对象:
|
|
900
|
+
* - enterFullscreen: 进入全屏。
|
|
901
|
+
* - exitFullscreen: 退出全屏。
|
|
902
|
+
* - toggleFullscreen: 切换全屏。
|
|
903
|
+
* - isEnabled: 当前浏览器是否支持全屏。
|
|
904
|
+
* @returns_en A tuple with the following elements:
|
|
905
|
+
* - whether the browser is in fullscreen.
|
|
906
|
+
* - a object:
|
|
907
|
+
* - enterFullscreen
|
|
908
|
+
* - exitFullscreen
|
|
909
|
+
* - toggleFullscreen
|
|
910
|
+
* - isEnabled: whether the browser support fullscreen
|
|
911
|
+
*/
|
|
912
|
+
type UseFullscreen = (
|
|
913
|
+
/**
|
|
914
|
+
* @zh dom元素
|
|
915
|
+
* @en dom element
|
|
916
|
+
*/
|
|
917
|
+
target: RefObject<Element>,
|
|
918
|
+
/**
|
|
919
|
+
* @zh 可选参数
|
|
920
|
+
* @en optional params
|
|
921
|
+
*/
|
|
922
|
+
options?: UseFullScreenOptions) => readonly [
|
|
923
|
+
/**
|
|
924
|
+
* @zh 当前是否处于全屏
|
|
925
|
+
* @en whether is in fullscreen
|
|
926
|
+
*/
|
|
927
|
+
boolean,
|
|
928
|
+
{
|
|
929
|
+
/**
|
|
930
|
+
* @zh 进入全屏
|
|
931
|
+
* @en enter fullscreen
|
|
932
|
+
*/
|
|
933
|
+
readonly enterFullscreen: () => void;
|
|
934
|
+
/**
|
|
935
|
+
* @zh 退出全屏
|
|
936
|
+
* @en exit fullscreen
|
|
937
|
+
*/
|
|
938
|
+
readonly exitFullscreen: () => void;
|
|
939
|
+
/**
|
|
940
|
+
* @zh 切换全屏
|
|
941
|
+
* @en toggle fullscreen
|
|
942
|
+
*/
|
|
943
|
+
readonly toggleFullscreen: () => void;
|
|
944
|
+
/**
|
|
945
|
+
* @zh 浏览器是否支持
|
|
946
|
+
* @en whether the browser support fullscreen
|
|
947
|
+
*/
|
|
948
|
+
readonly isEnabled: boolean;
|
|
949
|
+
}
|
|
950
|
+
];
|
|
951
|
+
/**
|
|
952
|
+
* @title UseFullScreenOptions
|
|
953
|
+
*/
|
|
954
|
+
interface UseFullScreenOptions {
|
|
955
|
+
/**
|
|
956
|
+
* @zh 退出时候的回调
|
|
957
|
+
* @en exit callback
|
|
958
|
+
*/
|
|
959
|
+
onExit?: () => void;
|
|
960
|
+
/**
|
|
961
|
+
* @zh 进入时候的回调
|
|
962
|
+
* @en enter callback
|
|
963
|
+
*/
|
|
964
|
+
onEnter?: () => void;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
declare const useFullscreen: UseFullscreen;
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* @title useGeoLocation
|
|
971
|
+
* @returns 包含以下元素的元组:
|
|
972
|
+
* - 坐标。
|
|
973
|
+
* - 获取坐标的时间戳。
|
|
974
|
+
* - 错误。
|
|
975
|
+
* @returns_en A tuple with the following elements:
|
|
976
|
+
* - coordinates.
|
|
977
|
+
* - timestamp when get coordinates.
|
|
978
|
+
* - errors.
|
|
979
|
+
*/
|
|
980
|
+
type UseGeolocation = (
|
|
981
|
+
/**
|
|
982
|
+
* @zh 可选 `PositionOptions` 参数
|
|
983
|
+
* @en optional `PositionOptions` params
|
|
984
|
+
*/
|
|
985
|
+
options?: Partial<PositionOptions>) => {
|
|
986
|
+
readonly coordinates: GeolocationCoordinates;
|
|
987
|
+
readonly locatedAt: number | null;
|
|
988
|
+
readonly error: GeolocationPositionError | null;
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
declare const useGeolocation: UseGeolocation;
|
|
992
|
+
|
|
993
|
+
declare const useHover: <T extends Element = HTMLDivElement>(target: RefObject<T>) => boolean;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* @title UseIdle
|
|
997
|
+
* @returns 是否处于空闲
|
|
998
|
+
* @returns_en whether user is idle
|
|
999
|
+
*/
|
|
1000
|
+
type UseIdle = (
|
|
1001
|
+
/**
|
|
1002
|
+
* @zh 检测时间
|
|
1003
|
+
* @en detection time
|
|
1004
|
+
* @defaultValue 60e3
|
|
1005
|
+
*/
|
|
1006
|
+
ms?: number,
|
|
1007
|
+
/**
|
|
1008
|
+
* @zh 初始值
|
|
1009
|
+
* @en initial value
|
|
1010
|
+
* @defaultValue false
|
|
1011
|
+
*/
|
|
1012
|
+
initialState?: boolean,
|
|
1013
|
+
/**
|
|
1014
|
+
* @zh 监听的事件
|
|
1015
|
+
* @en listener events
|
|
1016
|
+
* @defaultValue ["mousemove","mousedown","resize","keydown","touchstart","wheel"]
|
|
1017
|
+
*/
|
|
1018
|
+
events?: (keyof WindowEventMap)[]) => boolean;
|
|
1019
|
+
|
|
1020
|
+
declare const useIdle: UseIdle;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* @title useScroll
|
|
1024
|
+
* @returns 包含以下元素的元组:
|
|
1025
|
+
* - x 值。
|
|
1026
|
+
* - y 值。
|
|
1027
|
+
* - 是否在滚动。
|
|
1028
|
+
* - 到达边界状态。
|
|
1029
|
+
* - 滚动方向
|
|
1030
|
+
* @returns_en A tuple with the following elements:
|
|
1031
|
+
* - The x value.
|
|
1032
|
+
* - The y value.
|
|
1033
|
+
* - Whether it is scrolling.
|
|
1034
|
+
* - Boundary arrival status.
|
|
1035
|
+
* - Scroll direction.
|
|
1036
|
+
*/
|
|
1037
|
+
type UseScroll = (
|
|
1038
|
+
/**
|
|
1039
|
+
* @zh dom元素
|
|
1040
|
+
* @en dom elment
|
|
1041
|
+
*/
|
|
1042
|
+
target: RefObject<Element> | Window | Document,
|
|
1043
|
+
/**
|
|
1044
|
+
* @zh 可选参数
|
|
1045
|
+
* @en optional params
|
|
1046
|
+
*/
|
|
1047
|
+
options?: UseScrollOptions) => readonly [
|
|
1048
|
+
number,
|
|
1049
|
+
number,
|
|
1050
|
+
boolean,
|
|
1051
|
+
UseScrollArrivedState,
|
|
1052
|
+
UseScrollDirection
|
|
1053
|
+
];
|
|
1054
|
+
/**
|
|
1055
|
+
* @title UseScrollOptions
|
|
1056
|
+
*/
|
|
1057
|
+
interface UseScrollOptions {
|
|
1058
|
+
/**
|
|
1059
|
+
* @en Throttle time for scroll event, it’s disabled by default.
|
|
1060
|
+
* @zh 滚动事件的节流时间,默认关闭。
|
|
1061
|
+
* @defaultValue 0
|
|
1062
|
+
*/
|
|
1063
|
+
throttle?: number;
|
|
1064
|
+
/**
|
|
1065
|
+
* @en The check time when scrolling ends.
|
|
1066
|
+
* This configuration will be setting to (throttle + idle) when the `throttle` is configured.
|
|
1067
|
+
* @zh 滚动结束时的检查时间。
|
|
1068
|
+
* 当配置 `throttle` 时,此配置将设置为 (throttle +idle)。
|
|
1069
|
+
* @default 200
|
|
1070
|
+
*/
|
|
1071
|
+
idle?: number;
|
|
1072
|
+
/**
|
|
1073
|
+
* @en Offset arrived states by x pixels
|
|
1074
|
+
* @zh 将到达状态偏移 x 像素
|
|
1075
|
+
*/
|
|
1076
|
+
offset?: UseScrollOffset;
|
|
1077
|
+
/**
|
|
1078
|
+
* @en Trigger it when scrolling.
|
|
1079
|
+
* @zh 滚动的回调
|
|
1080
|
+
*/
|
|
1081
|
+
onScroll?: (e: Event) => void;
|
|
1082
|
+
/**
|
|
1083
|
+
* @en Trigger it when scrolling ends.
|
|
1084
|
+
* @zh 滚动结束的回调
|
|
1085
|
+
*/
|
|
1086
|
+
onStop?: (e: Event) => void;
|
|
1087
|
+
/**
|
|
1088
|
+
* @en Listener options for scroll event.
|
|
1089
|
+
* @zh 滚动事件参数
|
|
1090
|
+
* @defaultValue {capture: false, passive: true}
|
|
1091
|
+
*/
|
|
1092
|
+
eventListenerOptions?: boolean | AddEventListenerOptions;
|
|
1093
|
+
}
|
|
1094
|
+
interface UseScrollOffset {
|
|
1095
|
+
left?: number;
|
|
1096
|
+
right?: number;
|
|
1097
|
+
top?: number;
|
|
1098
|
+
bottom?: number;
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* @title UseScrollArrivedState
|
|
1102
|
+
*/
|
|
1103
|
+
interface UseScrollArrivedState {
|
|
1104
|
+
/**
|
|
1105
|
+
* @en arrived left
|
|
1106
|
+
* @zh 到达左边
|
|
1107
|
+
*/
|
|
1108
|
+
left: boolean;
|
|
1109
|
+
/**
|
|
1110
|
+
* @en arrived right
|
|
1111
|
+
* @zh 到达右边
|
|
1112
|
+
*/
|
|
1113
|
+
right: boolean;
|
|
1114
|
+
/**
|
|
1115
|
+
* @en arrived top
|
|
1116
|
+
* @zh 到达顶部
|
|
1117
|
+
*/
|
|
1118
|
+
top: boolean;
|
|
1119
|
+
/**
|
|
1120
|
+
* @en arrived bottom
|
|
1121
|
+
* @zh 到达底部
|
|
1122
|
+
*/
|
|
1123
|
+
bottom: boolean;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* @title UseScrollDirection
|
|
1127
|
+
*/
|
|
1128
|
+
interface UseScrollDirection {
|
|
1129
|
+
/**
|
|
1130
|
+
* @en scroll left
|
|
1131
|
+
* @zh 向左滚动
|
|
1132
|
+
*/
|
|
1133
|
+
left: boolean;
|
|
1134
|
+
/**
|
|
1135
|
+
* @en scroll right
|
|
1136
|
+
* @zh 向右滚动
|
|
1137
|
+
*/
|
|
1138
|
+
right: boolean;
|
|
1139
|
+
/**
|
|
1140
|
+
* @en scroll top
|
|
1141
|
+
* @zh 向上滚动
|
|
1142
|
+
*/
|
|
1143
|
+
top: boolean;
|
|
1144
|
+
/**
|
|
1145
|
+
* @en scroll bottom
|
|
1146
|
+
* @zh 向下滚动
|
|
1147
|
+
*/
|
|
1148
|
+
bottom: boolean;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* @title useInfiniteScroll
|
|
1153
|
+
*/
|
|
1154
|
+
type UseInfiniteScroll = (
|
|
1155
|
+
/**
|
|
1156
|
+
* @zh dom元素
|
|
1157
|
+
* @en dom element
|
|
1158
|
+
*/
|
|
1159
|
+
target: RefObject<Element>,
|
|
1160
|
+
/**
|
|
1161
|
+
* @zh 加载更多函数
|
|
1162
|
+
* @en load more function
|
|
1163
|
+
*/
|
|
1164
|
+
onLoadMore: UseInfiniteScrollLoadMore,
|
|
1165
|
+
/**
|
|
1166
|
+
* @zh 可选参数
|
|
1167
|
+
* @en optional params
|
|
1168
|
+
*/
|
|
1169
|
+
options?: UseInfiniteScrollOptions) => void;
|
|
1170
|
+
/**
|
|
1171
|
+
* @title UseInfiniteScrollLoadMore
|
|
1172
|
+
*/
|
|
1173
|
+
type UseInfiniteScrollLoadMore = (
|
|
1174
|
+
/**
|
|
1175
|
+
* @zh `useScroll` 返回的状态
|
|
1176
|
+
* @en the return state of `useScroll`
|
|
1177
|
+
*/
|
|
1178
|
+
state: readonly [
|
|
1179
|
+
number,
|
|
1180
|
+
number,
|
|
1181
|
+
boolean,
|
|
1182
|
+
UseInfiniteScrollArrivedState,
|
|
1183
|
+
UseInfiniteScrollDirection
|
|
1184
|
+
]) => void | Promise<void>;
|
|
1185
|
+
/**
|
|
1186
|
+
* @title UseInfiniteScrollOptions
|
|
1187
|
+
*/
|
|
1188
|
+
interface UseInfiniteScrollOptions extends UseScrollOptions {
|
|
1189
|
+
/**
|
|
1190
|
+
* @en The minimum distance between the bottom of the element and the bottom of the viewport
|
|
1191
|
+
* @zh 元素底部与视口底部之间的最小距离
|
|
1192
|
+
* @defaultValue 0
|
|
1193
|
+
*/
|
|
1194
|
+
distance?: number;
|
|
1195
|
+
/**
|
|
1196
|
+
* @en The direction in which to listen the scroll.
|
|
1197
|
+
* @zh 滚动方向
|
|
1198
|
+
* @defaultValue 'bottom'
|
|
1199
|
+
*/
|
|
1200
|
+
direction?: "top" | "bottom" | "left" | "right";
|
|
1201
|
+
/**
|
|
1202
|
+
* @en Whether to preserve the current scroll position when loading more items.
|
|
1203
|
+
* @zh 加载更多项目时是否保留当前滚动位置
|
|
1204
|
+
* @defaultValueValue false
|
|
1205
|
+
*/
|
|
1206
|
+
preserveScrollPosition?: boolean;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* @title UseInfiniteScrollArrivedState
|
|
1210
|
+
*/
|
|
1211
|
+
interface UseInfiniteScrollArrivedState {
|
|
1212
|
+
/**
|
|
1213
|
+
* @en arrived left
|
|
1214
|
+
* @zh 到达左边
|
|
1215
|
+
*/
|
|
1216
|
+
left: boolean;
|
|
1217
|
+
/**
|
|
1218
|
+
* @en arrived right
|
|
1219
|
+
* @zh 到达右边
|
|
1220
|
+
*/
|
|
1221
|
+
right: boolean;
|
|
1222
|
+
/**
|
|
1223
|
+
* @en arrived top
|
|
1224
|
+
* @zh 到达顶部
|
|
1225
|
+
*/
|
|
1226
|
+
top: boolean;
|
|
1227
|
+
/**
|
|
1228
|
+
* @en arrived bottom
|
|
1229
|
+
* @zh 到达底部
|
|
1230
|
+
*/
|
|
1231
|
+
bottom: boolean;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* @title UseInfiniteScrollDirection
|
|
1235
|
+
*/
|
|
1236
|
+
interface UseInfiniteScrollDirection {
|
|
1237
|
+
/**
|
|
1238
|
+
* @en scroll left
|
|
1239
|
+
* @zh 向左滚动
|
|
1240
|
+
*/
|
|
1241
|
+
left: boolean;
|
|
1242
|
+
/**
|
|
1243
|
+
* @en scroll right
|
|
1244
|
+
* @zh 向右滚动
|
|
1245
|
+
*/
|
|
1246
|
+
right: boolean;
|
|
1247
|
+
/**
|
|
1248
|
+
* @en scroll top
|
|
1249
|
+
* @zh 向上滚动
|
|
1250
|
+
*/
|
|
1251
|
+
top: boolean;
|
|
1252
|
+
/**
|
|
1253
|
+
* @en scroll bottom
|
|
1254
|
+
* @zh 向下滚动
|
|
1255
|
+
*/
|
|
1256
|
+
bottom: boolean;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
declare const useInfiniteScroll: UseInfiniteScroll;
|
|
1260
|
+
|
|
1261
|
+
declare const useIntersectionObserver: (target: RefObject<Element>, callback: IntersectionObserverCallback, options?: IntersectionObserverInit) => () => void;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* @title useInterval
|
|
1265
|
+
*/
|
|
1266
|
+
type UseInterval = (
|
|
1267
|
+
/**
|
|
1268
|
+
* @zh 回调
|
|
1269
|
+
* @en callback
|
|
1270
|
+
*/
|
|
1271
|
+
callback: () => void,
|
|
1272
|
+
/**
|
|
1273
|
+
* @zh 时间,如果为 `null` 的话则停止计时器
|
|
1274
|
+
* @en Time, if `null` then stop the timer
|
|
1275
|
+
*/
|
|
1276
|
+
delay?: number | null,
|
|
1277
|
+
/**
|
|
1278
|
+
* @zh 可选参数
|
|
1279
|
+
* @en optional params
|
|
1280
|
+
*/
|
|
1281
|
+
options?: UseIntervalOptions) => void;
|
|
1282
|
+
/**
|
|
1283
|
+
* @title UseIntervalOptions
|
|
1284
|
+
*/
|
|
1285
|
+
interface UseIntervalOptions {
|
|
1286
|
+
/**
|
|
1287
|
+
* @zh 是否立即执行。
|
|
1288
|
+
* @en Whether to execute immediately.
|
|
1289
|
+
*/
|
|
1290
|
+
immediate?: boolean;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
declare const useInterval: UseInterval;
|
|
1294
|
+
|
|
1295
|
+
declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* @title useKeyModifier
|
|
1299
|
+
* @returns 按键是否被按下
|
|
1300
|
+
* @returns_en Whether the key is pressed
|
|
1301
|
+
*/
|
|
1302
|
+
type UseKeyModifier = (
|
|
1303
|
+
/**
|
|
1304
|
+
* @zh 键位
|
|
1305
|
+
* @en key modifier
|
|
1306
|
+
*/
|
|
1307
|
+
modifier: KeyModifier,
|
|
1308
|
+
/**
|
|
1309
|
+
* @zh 可选参数
|
|
1310
|
+
* @en optional params
|
|
1311
|
+
*/
|
|
1312
|
+
options?: UseModifierOptions) => boolean;
|
|
1313
|
+
type KeyModifier = "Alt" | "AltGraph" | "CapsLock" | "Control" | "Fn" | "FnLock" | "Meta" | "NumLock" | "ScrollLock" | "Shift" | "Symbol" | "SymbolLock";
|
|
1314
|
+
/**
|
|
1315
|
+
* @title UseModifierOptions
|
|
1316
|
+
*/
|
|
1317
|
+
interface UseModifierOptions {
|
|
1318
|
+
/**
|
|
1319
|
+
* @en Event names that will prompt update to modifier states
|
|
1320
|
+
* @zh 更新按键状态的事件
|
|
1321
|
+
* @defaultValue ['mousedown', 'mouseup', 'keydown', 'keyup']
|
|
1322
|
+
*/
|
|
1323
|
+
events?: (keyof WindowEventMap)[];
|
|
1324
|
+
/**
|
|
1325
|
+
* @en Initial value of the returned ref
|
|
1326
|
+
* @zh 初始值
|
|
1327
|
+
* @defaultValue false
|
|
1328
|
+
*/
|
|
1329
|
+
initial?: boolean;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
declare const useKeyModifier: UseKeyModifier;
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* @title useLatest
|
|
1336
|
+
* @returns ref 对象
|
|
1337
|
+
* @returns_en ref object
|
|
1338
|
+
*/
|
|
1339
|
+
type UseLatest = <T>(
|
|
1340
|
+
/**
|
|
1341
|
+
* @zh 追踪值
|
|
1342
|
+
* @en tracked value
|
|
1343
|
+
*/
|
|
1344
|
+
value: T) => MutableRefObject<T>;
|
|
1345
|
+
|
|
1346
|
+
declare const useLatest: UseLatest;
|
|
1347
|
+
|
|
1348
|
+
interface Serializer<T> {
|
|
1349
|
+
read(raw: string): T;
|
|
1350
|
+
write(value: T): string;
|
|
1351
|
+
}
|
|
1352
|
+
interface UseStorageOptions<T> {
|
|
1353
|
+
/**
|
|
1354
|
+
* Custom data serialization
|
|
1355
|
+
*/
|
|
1356
|
+
serializer?: Serializer<T>;
|
|
1357
|
+
/**
|
|
1358
|
+
* On error callback
|
|
1359
|
+
*
|
|
1360
|
+
* Default log error to `console.error`
|
|
1361
|
+
*/
|
|
1362
|
+
onError?: (error: unknown) => void;
|
|
1363
|
+
/**
|
|
1364
|
+
* set to storage when nodata in effect, fallback to defaults
|
|
1365
|
+
*/
|
|
1366
|
+
effectStorageValue?: T | (() => T);
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
declare function useLocalStorage(key: string, defaults: string, options?: UseStorageOptions<string>): readonly [string | null, Dispatch<SetStateAction<string | null>>];
|
|
1370
|
+
declare function useLocalStorage(key: string, defaults: number, options?: UseStorageOptions<number>): readonly [number | null, Dispatch<SetStateAction<number | null>>];
|
|
1371
|
+
declare function useLocalStorage(key: string, defaults: boolean, options?: UseStorageOptions<boolean>): readonly [boolean | null, Dispatch<SetStateAction<boolean | null>>];
|
|
1372
|
+
declare function useLocalStorage<T>(key: string, defaults: T, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
1373
|
+
declare function useLocalStorage<T = unknown>(key: string, defaults: null, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* @title useLocationSelector
|
|
1377
|
+
*/
|
|
1378
|
+
type UseLocationSelector = <R>(
|
|
1379
|
+
/**
|
|
1380
|
+
* @zh 选择器
|
|
1381
|
+
* @en selector function
|
|
1382
|
+
*/
|
|
1383
|
+
selector: (location: Location) => R,
|
|
1384
|
+
/**
|
|
1385
|
+
* @zh 默认值
|
|
1386
|
+
* @en default value
|
|
1387
|
+
*/
|
|
1388
|
+
fallback?: R | undefined) => R | undefined;
|
|
1389
|
+
|
|
1390
|
+
declare const useLocationSelector: UseLocationSelector;
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* @title useLongPress
|
|
1394
|
+
* @returns 包含以下元素的对象:
|
|
1395
|
+
* - onMouseDown 鼠标按下事件。
|
|
1396
|
+
* - onTouchStart 手指按下事件。
|
|
1397
|
+
* - onMouseUp 鼠标松开事件。
|
|
1398
|
+
* - onMouseLeave 鼠标离开事件
|
|
1399
|
+
* - onTouchEnd 手指松开事件
|
|
1400
|
+
* @returns_en A object with the following elements:
|
|
1401
|
+
* - onMouseDown: Mouse down event.
|
|
1402
|
+
* - onTouchStart: Finger touch start event.
|
|
1403
|
+
* - onMouseUp: Mouse up event.
|
|
1404
|
+
* - onMouseLeave: Mouse leave event.
|
|
1405
|
+
* - onTouchEnd: Finger touch end event.
|
|
1406
|
+
*/
|
|
1407
|
+
type UseLongPress = (
|
|
1408
|
+
/**
|
|
1409
|
+
* @zh 回调
|
|
1410
|
+
* @en callback
|
|
1411
|
+
*/
|
|
1412
|
+
callback: (e: TouchEvent | MouseEvent) => void,
|
|
1413
|
+
/**
|
|
1414
|
+
* @zh 可选参数
|
|
1415
|
+
* @en optional params
|
|
1416
|
+
*/
|
|
1417
|
+
options?: UseLongPressOptions) => {
|
|
1418
|
+
readonly onMouseDown: (e: any) => void;
|
|
1419
|
+
readonly onTouchStart: (e: any) => void;
|
|
1420
|
+
readonly onMouseUp: () => void;
|
|
1421
|
+
readonly onMouseLeave: () => void;
|
|
1422
|
+
readonly onTouchEnd: () => void;
|
|
1423
|
+
};
|
|
1424
|
+
/**
|
|
1425
|
+
* @title UseLongPressOptions
|
|
1426
|
+
*/
|
|
1427
|
+
interface UseLongPressOptions {
|
|
1428
|
+
/**
|
|
1429
|
+
* @zh 阻止默认事件
|
|
1430
|
+
* @en whether prevent default event
|
|
1431
|
+
* @defaultValue true
|
|
1432
|
+
*/
|
|
1433
|
+
isPreventDefault?: boolean;
|
|
1434
|
+
/**
|
|
1435
|
+
* @zh 延迟
|
|
1436
|
+
* @en delay time
|
|
1437
|
+
* @defaultValue 300
|
|
1438
|
+
*/
|
|
1439
|
+
delay?: number;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
declare const useLongPress: UseLongPress;
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* @title useMeasure
|
|
1446
|
+
* @returns [DOMRect值,停止监听函数]
|
|
1447
|
+
* @returns_en [DOMRect, stop listening function]
|
|
1448
|
+
*/
|
|
1449
|
+
type UseMeasure = (
|
|
1450
|
+
/**
|
|
1451
|
+
* @zh dom对象
|
|
1452
|
+
* @en dom element
|
|
1453
|
+
*/
|
|
1454
|
+
target: RefObject<Element>,
|
|
1455
|
+
/**
|
|
1456
|
+
* @zh 可选参数
|
|
1457
|
+
* @en optional params
|
|
1458
|
+
*/
|
|
1459
|
+
options?: ResizeObserverOptions) => readonly [UseMeasureRect, () => void];
|
|
1460
|
+
/**
|
|
1461
|
+
* @title UseMeasureRect
|
|
1462
|
+
*/
|
|
1463
|
+
type UseMeasureRect = Omit<DOMRectReadOnly, "toJSON">;
|
|
1464
|
+
|
|
1465
|
+
declare const useMeasure: UseMeasure;
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* @title useMediaDevices
|
|
1469
|
+
* @returns 包含以下元素的元组:
|
|
1470
|
+
* - 媒体设备信息。
|
|
1471
|
+
* - 请求媒体设备权限。
|
|
1472
|
+
* @returns_en A tuple with the following elements:
|
|
1473
|
+
* - The media devices info.
|
|
1474
|
+
* - A function to request media devices permission.
|
|
1475
|
+
*/
|
|
1476
|
+
type UseMediaDevices = (
|
|
1477
|
+
/**
|
|
1478
|
+
* @zh 可选参数
|
|
1479
|
+
* @en optional params
|
|
1480
|
+
*/
|
|
1481
|
+
options?: UseMediaDeviceOptions) => readonly [
|
|
1482
|
+
{
|
|
1483
|
+
devices: {
|
|
1484
|
+
deviceId: string;
|
|
1485
|
+
groupId: string;
|
|
1486
|
+
kind: MediaDeviceKind;
|
|
1487
|
+
label: string;
|
|
1488
|
+
}[];
|
|
1489
|
+
},
|
|
1490
|
+
() => Promise<boolean>
|
|
1491
|
+
];
|
|
1492
|
+
/**
|
|
1493
|
+
* @title UseMediaDeviceOptions
|
|
1494
|
+
*/
|
|
1495
|
+
interface UseMediaDeviceOptions {
|
|
1496
|
+
/**
|
|
1497
|
+
* @en Request for permissions immediately if it's not granted,
|
|
1498
|
+
* otherwise label and deviceIds could be empty
|
|
1499
|
+
* @zh 自动请求权限
|
|
1500
|
+
* @defaultValue false
|
|
1501
|
+
*/
|
|
1502
|
+
requestPermissions?: boolean;
|
|
1503
|
+
/**
|
|
1504
|
+
* @en Request for types of media permissions
|
|
1505
|
+
* @zh 请求媒体权限类型
|
|
1506
|
+
* @defaultValue { audio: true, video: true }
|
|
1507
|
+
*/
|
|
1508
|
+
constraints?: MediaStreamConstraints;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
declare const useMediaDevices: UseMediaDevices;
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* @title useMediaQuery
|
|
1515
|
+
* @returns 是否符合媒体查询
|
|
1516
|
+
* @returns_en whether comply with media inquiries
|
|
1517
|
+
*/
|
|
1518
|
+
type UseMediaQuery = (
|
|
1519
|
+
/**
|
|
1520
|
+
* @zh 媒体查询字符串
|
|
1521
|
+
* @en media query string
|
|
1522
|
+
*/
|
|
1523
|
+
query: string,
|
|
1524
|
+
/**
|
|
1525
|
+
* @zh 默认值
|
|
1526
|
+
* @en default value
|
|
1527
|
+
*/
|
|
1528
|
+
defaultState?: boolean) => boolean;
|
|
1529
|
+
|
|
1530
|
+
declare const useMediaQuery: UseMediaQuery;
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* @title useMount
|
|
1534
|
+
*/
|
|
1535
|
+
type UseMount = (
|
|
1536
|
+
/**
|
|
1537
|
+
* @zh 副作用函数
|
|
1538
|
+
* @en effect function
|
|
1539
|
+
*/
|
|
1540
|
+
effect: () => void) => void;
|
|
1541
|
+
|
|
1542
|
+
declare const useMount: UseMount;
|
|
1543
|
+
|
|
1544
|
+
declare const useMountedState: () => () => boolean;
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* @title useMouse
|
|
1548
|
+
* @returns 鼠标位置
|
|
1549
|
+
* @returns_en Mouse Position
|
|
1550
|
+
*/
|
|
1551
|
+
type UseMouse = (
|
|
1552
|
+
/**
|
|
1553
|
+
* @zh dom元素
|
|
1554
|
+
* @en dom element
|
|
1555
|
+
*/
|
|
1556
|
+
target?: BasicTarget) => UseMouseCursorState;
|
|
1557
|
+
/**
|
|
1558
|
+
* @title UseMouseCursorState
|
|
1559
|
+
*/
|
|
1560
|
+
interface UseMouseCursorState {
|
|
1561
|
+
screenX: number;
|
|
1562
|
+
screenY: number;
|
|
1563
|
+
clientX: number;
|
|
1564
|
+
clientY: number;
|
|
1565
|
+
pageX: number;
|
|
1566
|
+
pageY: number;
|
|
1567
|
+
elementX: number;
|
|
1568
|
+
elementY: number;
|
|
1569
|
+
elementH: number;
|
|
1570
|
+
elementW: number;
|
|
1571
|
+
elementPosX: number;
|
|
1572
|
+
elementPosY: number;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
declare const useMouse: UseMouse;
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* @title useMousePressed
|
|
1579
|
+
* @returns 包含以下元素的元组:
|
|
1580
|
+
* - 鼠标是否按下。
|
|
1581
|
+
* - 按下的事件来源。
|
|
1582
|
+
* @returns_en A tuple with the following elements:
|
|
1583
|
+
* - whether the mouse is pressed.
|
|
1584
|
+
* - the pressed source type
|
|
1585
|
+
*/
|
|
1586
|
+
type UseMousePressed = (
|
|
1587
|
+
/**
|
|
1588
|
+
* @zh dom对象
|
|
1589
|
+
* @en dom element
|
|
1590
|
+
*/
|
|
1591
|
+
target?: RefObject<Element>,
|
|
1592
|
+
/**
|
|
1593
|
+
* @zh 可选参数
|
|
1594
|
+
* @en optional params
|
|
1595
|
+
*/
|
|
1596
|
+
options?: UseMousePressedOptions) => readonly [boolean, UseMousePressedSourceType];
|
|
1597
|
+
/**
|
|
1598
|
+
* @title UseMousePressedOptions
|
|
1599
|
+
*/
|
|
1600
|
+
interface UseMousePressedOptions {
|
|
1601
|
+
/**
|
|
1602
|
+
* @en Listen to `touchstart` `touchend` events
|
|
1603
|
+
* @zh 监听 `touchstart` 事件
|
|
1604
|
+
* @defaultValue true
|
|
1605
|
+
*/
|
|
1606
|
+
touch?: boolean;
|
|
1607
|
+
/**
|
|
1608
|
+
* @en Listen to `dragstart` `drop` and `dragend` events
|
|
1609
|
+
* @zh 监听 `dragStart` 事件
|
|
1610
|
+
* @defaultValue true
|
|
1611
|
+
*/
|
|
1612
|
+
drag?: boolean;
|
|
1613
|
+
/**
|
|
1614
|
+
* @en Initial values
|
|
1615
|
+
* @zh 初始值
|
|
1616
|
+
* @defaultValue false
|
|
1617
|
+
*/
|
|
1618
|
+
initialValue?: boolean | (() => boolean);
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* @title UseMousePressedSourceType
|
|
1622
|
+
*/
|
|
1623
|
+
type UseMousePressedSourceType = "mouse" | "touch" | null;
|
|
1624
|
+
|
|
1625
|
+
declare const useMousePressed: (target?: RefObject<Element>, options?: UseMousePressedOptions) => readonly [boolean, UseMousePressedSourceType];
|
|
1626
|
+
|
|
1627
|
+
/**
|
|
1628
|
+
* @title UseMutationObserver
|
|
1629
|
+
* @returns 停止函数
|
|
1630
|
+
* @returns_en stop listenering function
|
|
1631
|
+
*/
|
|
1632
|
+
type UseMutationObserver = (
|
|
1633
|
+
/**
|
|
1634
|
+
* @zh 回调
|
|
1635
|
+
* @en callback
|
|
1636
|
+
*/
|
|
1637
|
+
callback: MutationCallback,
|
|
1638
|
+
/**
|
|
1639
|
+
* @zh dom元素
|
|
1640
|
+
* @en dom对象
|
|
1641
|
+
*/
|
|
1642
|
+
target: BasicTarget,
|
|
1643
|
+
/**
|
|
1644
|
+
* @zh 传递给 `MutationObserver` 的参数
|
|
1645
|
+
* @en options passed to `MutationObserver`
|
|
1646
|
+
*/
|
|
1647
|
+
options?: MutationObserverInit) => () => void;
|
|
1648
|
+
|
|
1649
|
+
declare const useMutationObserver: UseMutationObserver;
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* @title useNetwork
|
|
1653
|
+
*/
|
|
1654
|
+
type UseNetwork = () => IUseNetworkState;
|
|
1655
|
+
/**
|
|
1656
|
+
* @title IUseNetworkState
|
|
1657
|
+
*/
|
|
1658
|
+
interface IUseNetworkState {
|
|
1659
|
+
/**
|
|
1660
|
+
* @en Whether browser connected to the network or not.
|
|
1661
|
+
* @zh 浏览器是否连接网络
|
|
1662
|
+
*/
|
|
1663
|
+
online: boolean | undefined;
|
|
1664
|
+
/**
|
|
1665
|
+
* @en Previous value of `online` property. Helps to identify if browser
|
|
1666
|
+
* just connected or lost connection.
|
|
1667
|
+
* @zh `online` 属性的先前值。 帮助识别浏览器是否
|
|
1668
|
+
* 刚刚连接或失去连接。
|
|
1669
|
+
*/
|
|
1670
|
+
previous: boolean | undefined;
|
|
1671
|
+
/**
|
|
1672
|
+
* @en The {Date} object pointing to the moment when state change occurred.
|
|
1673
|
+
* @zh {Date} 对象指向状态更改发生的时刻。
|
|
1674
|
+
*/
|
|
1675
|
+
since: Date | undefined;
|
|
1676
|
+
/**
|
|
1677
|
+
* @en Effective bandwidth estimate in megabits per second, rounded to the
|
|
1678
|
+
* nearest multiple of 25 kilobits per seconds.
|
|
1679
|
+
* @zh 有效带宽估计(以兆位每秒为单位),四舍五入到
|
|
1680
|
+
* 25 kbps 的最接近倍数。
|
|
1681
|
+
*/
|
|
1682
|
+
downlink: INetworkInformation["downlink"] | undefined;
|
|
1683
|
+
/**
|
|
1684
|
+
* @en Maximum downlink speed, in megabits per second (Mbps), for the
|
|
1685
|
+
* underlying connection technology
|
|
1686
|
+
* @zh 最大下行链路速度,以兆比特每秒 (Mbps) 为单位
|
|
1687
|
+
*/
|
|
1688
|
+
downlinkMax: INetworkInformation["downlinkMax"] | undefined;
|
|
1689
|
+
/**
|
|
1690
|
+
* @en Effective type of the connection meaning one of 'slow-2g', '2g', '3g', or '4g'.
|
|
1691
|
+
* This value is determined using a combination of recently observed round-trip time
|
|
1692
|
+
* and downlink values.
|
|
1693
|
+
* @zh 连接的有效类型,表示“slow-2g”、“2g”、“3g”或“4g”之一。
|
|
1694
|
+
* 该值是根据最近观察到的往返时间和和下行链路值的组合确定的
|
|
1695
|
+
*/
|
|
1696
|
+
effectiveType: INetworkInformation["effectiveType"] | undefined;
|
|
1697
|
+
/**
|
|
1698
|
+
* @en Estimated effective round-trip time of the current connection, rounded
|
|
1699
|
+
* to the nearest multiple of 25 milliseconds
|
|
1700
|
+
* @zh 当前连接的估计有效往返时间,四舍五入
|
|
1701
|
+
* 精确到 25 毫秒的最接近倍数
|
|
1702
|
+
*/
|
|
1703
|
+
rtt: INetworkInformation["rtt"] | undefined;
|
|
1704
|
+
/**
|
|
1705
|
+
* @en {true} if the user has set a reduced data usage option on the user agent.
|
|
1706
|
+
* @zh 如果用户在用户代理上设置了减少数据使用选项,则为 {true}。
|
|
1707
|
+
*/
|
|
1708
|
+
saveData: INetworkInformation["saveData"] | undefined;
|
|
1709
|
+
/**
|
|
1710
|
+
* @en The type of connection a device is using to communicate with the network.
|
|
1711
|
+
* It will be one of the following values:
|
|
1712
|
+
* - bluetooth
|
|
1713
|
+
* - cellular
|
|
1714
|
+
* - ethernet
|
|
1715
|
+
* - none
|
|
1716
|
+
* - wifi
|
|
1717
|
+
* - wimax
|
|
1718
|
+
* - other
|
|
1719
|
+
* - unknown
|
|
1720
|
+
* @zh 设备用于与网络通信的连接类型。
|
|
1721
|
+
* 它将是以下值之一:
|
|
1722
|
+
* - 蓝牙
|
|
1723
|
+
* - 蜂窝网络
|
|
1724
|
+
* - 以太网
|
|
1725
|
+
* - 没有任何
|
|
1726
|
+
* - 无线上网
|
|
1727
|
+
* - 无线麦克斯
|
|
1728
|
+
* - 其他
|
|
1729
|
+
* - 未知
|
|
1730
|
+
*/
|
|
1731
|
+
type: INetworkInformation["type"] | undefined;
|
|
1732
|
+
}
|
|
1733
|
+
interface INetworkInformation extends EventTarget {
|
|
1734
|
+
readonly downlink: number;
|
|
1735
|
+
readonly downlinkMax: number;
|
|
1736
|
+
readonly effectiveType: "slow-2g" | "2g" | "3g" | "4g";
|
|
1737
|
+
readonly rtt: number;
|
|
1738
|
+
readonly saveData: boolean;
|
|
1739
|
+
readonly type: "bluetooth" | "cellular" | "ethernet" | "none" | "wifi" | "wimax" | "other" | "unknown";
|
|
1740
|
+
onChange: (event: Event) => void;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
declare const useNetwork: UseNetwork;
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* @title useObjectUrl
|
|
1747
|
+
* @returns 返回一个由 Blob 或 MediaSource 对象生成的 URL(如果存在),否则返回 undefined
|
|
1748
|
+
* @returns_en Returns a URL created from the Blob or MediaSource object, or undefined if none exists
|
|
1749
|
+
*/
|
|
1750
|
+
type UseObjectUrl = (
|
|
1751
|
+
/**
|
|
1752
|
+
* @zh 文件或者媒体对象
|
|
1753
|
+
* @en file or media source
|
|
1754
|
+
*/
|
|
1755
|
+
object: Blob | MediaSource) => string | undefined;
|
|
1756
|
+
|
|
1757
|
+
declare const useObjectUrl: UseObjectUrl;
|
|
1758
|
+
|
|
1759
|
+
declare const useOnceEffect: typeof useEffect | typeof react.useLayoutEffect;
|
|
1760
|
+
|
|
1761
|
+
declare const useOnceLayoutEffect: typeof react.useEffect | typeof useLayoutEffect;
|
|
1762
|
+
|
|
1763
|
+
/**
|
|
1764
|
+
* @title useOnline
|
|
1765
|
+
* @returns 网络是否在线
|
|
1766
|
+
* @returns_en whether netwotk is online
|
|
1767
|
+
*/
|
|
1768
|
+
type UseOnline = () => boolean | undefined;
|
|
1769
|
+
|
|
1770
|
+
declare const useOnline: UseOnline;
|
|
1771
|
+
|
|
1772
|
+
/**
|
|
1773
|
+
* @title useOrientation
|
|
1774
|
+
* @returns 包含以下元素的元组:
|
|
1775
|
+
* - 方向状态。
|
|
1776
|
+
* - 锁定方向。
|
|
1777
|
+
* - 解锁方向。
|
|
1778
|
+
* @returns_en A tuple with the following elements:
|
|
1779
|
+
* - orientation type.
|
|
1780
|
+
* - lock orientation.
|
|
1781
|
+
* - unlock orientation.
|
|
1782
|
+
*/
|
|
1783
|
+
type UseOrientation = (
|
|
1784
|
+
/**
|
|
1785
|
+
* @zh 初始值
|
|
1786
|
+
* @en initial value
|
|
1787
|
+
*/
|
|
1788
|
+
initialState?: UseOrientationState) => readonly [
|
|
1789
|
+
UseOrientationState,
|
|
1790
|
+
(type: UseOrientationLockType) => any,
|
|
1791
|
+
() => void
|
|
1792
|
+
];
|
|
1793
|
+
/**
|
|
1794
|
+
* @title UseOrientationState
|
|
1795
|
+
*/
|
|
1796
|
+
interface UseOrientationState {
|
|
1797
|
+
/**
|
|
1798
|
+
* @zh 角度
|
|
1799
|
+
* @en document angle
|
|
1800
|
+
*/
|
|
1801
|
+
angle: number;
|
|
1802
|
+
/**
|
|
1803
|
+
* @zh 方向类型
|
|
1804
|
+
* @en orientation type
|
|
1805
|
+
*/
|
|
1806
|
+
type: UseOrientationType | undefined;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* @title UseOrientationType
|
|
1810
|
+
*/
|
|
1811
|
+
type UseOrientationType = "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
|
|
1812
|
+
/**
|
|
1813
|
+
* @title UseOrientationLockType
|
|
1814
|
+
*/
|
|
1815
|
+
type UseOrientationLockType = "any" | "natural" | "landscape" | "portrait" | "portrait-primary" | "portrait-secondary" | "landscape-primary" | "landscape-secondary";
|
|
1816
|
+
|
|
1817
|
+
declare const useOrientation: UseOrientation;
|
|
1818
|
+
|
|
1819
|
+
declare const usePageLeave: () => boolean;
|
|
1820
|
+
|
|
1821
|
+
/**
|
|
1822
|
+
* @title usePermission
|
|
1823
|
+
* @returns 权限状态
|
|
1824
|
+
* @returns_en permission state
|
|
1825
|
+
*/
|
|
1826
|
+
type UsePermission = (
|
|
1827
|
+
/**
|
|
1828
|
+
* @zh 权限描述符
|
|
1829
|
+
* @en permission desc
|
|
1830
|
+
*/
|
|
1831
|
+
permissionDesc: UsePermissionGeneralPermissionDescriptor | UsePermissionGeneralPermissionDescriptor["name"]) => UsePermissionState;
|
|
1832
|
+
/**
|
|
1833
|
+
* @title UsePermissionState
|
|
1834
|
+
*/
|
|
1835
|
+
type UsePermissionState = PermissionState | "";
|
|
1836
|
+
/**
|
|
1837
|
+
* @title UsePermissionGeneralPermissionDescriptor
|
|
1838
|
+
*/
|
|
1839
|
+
type UsePermissionGeneralPermissionDescriptor = PermissionDescriptor | {
|
|
1840
|
+
name: UsePermissionDescriptorNamePolyfill;
|
|
1841
|
+
};
|
|
1842
|
+
/**
|
|
1843
|
+
* @title UsePermissionDescriptorNamePolyfill
|
|
1844
|
+
*/
|
|
1845
|
+
type UsePermissionDescriptorNamePolyfill = "accelerometer" | "accessibility-events" | "ambient-light-sensor" | "background-sync" | "camera" | "clipboard-read" | "clipboard-write" | "gyroscope" | "magnetometer" | "microphone" | "notifications" | "payment-handler" | "persistent-storage" | "push" | "speaker";
|
|
1846
|
+
|
|
1847
|
+
declare const usePermission: UsePermission;
|
|
1848
|
+
|
|
1849
|
+
/**
|
|
1850
|
+
* @title usePreferredColorScheme
|
|
1851
|
+
* @returns prefers-color-scheme的媒体查询值
|
|
1852
|
+
* @returns_en value of prefers-color-scheme media query
|
|
1853
|
+
*/
|
|
1854
|
+
type UsePreferredColorScheme = (
|
|
1855
|
+
/**
|
|
1856
|
+
* @zh 默认值
|
|
1857
|
+
* @en default value
|
|
1858
|
+
* @defaultValue no-preference
|
|
1859
|
+
*/
|
|
1860
|
+
defaultState?: ColorScheme) => ColorScheme;
|
|
1861
|
+
/**
|
|
1862
|
+
* @title ColorScheme
|
|
1863
|
+
*/
|
|
1864
|
+
type ColorScheme = "dark" | "light" | "no-preference";
|
|
1865
|
+
|
|
1866
|
+
declare const usePreferredColorScheme: UsePreferredColorScheme;
|
|
1867
|
+
|
|
1868
|
+
/**
|
|
1869
|
+
* @title usePreferredContrast
|
|
1870
|
+
*/
|
|
1871
|
+
type UsePreferredContrast = (
|
|
1872
|
+
/**
|
|
1873
|
+
* @zh 默认值
|
|
1874
|
+
* @en default value
|
|
1875
|
+
* @defaultValue no-preference
|
|
1876
|
+
*/
|
|
1877
|
+
defaultState?: Contrast) => Contrast;
|
|
1878
|
+
/**
|
|
1879
|
+
* @title Contrast
|
|
1880
|
+
*/
|
|
1881
|
+
type Contrast = "more" | "less" | "custom" | "no-preference";
|
|
1882
|
+
|
|
1883
|
+
declare const usePreferredContrast: UsePreferredContrast;
|
|
1884
|
+
|
|
1885
|
+
declare const usePreferredDark: (defaultState?: boolean) => boolean;
|
|
1886
|
+
|
|
1887
|
+
declare const usePrevious: <T>(state: T) => T | undefined;
|
|
1888
|
+
|
|
1889
|
+
/**
|
|
1890
|
+
* @title useRafFn
|
|
1891
|
+
* @returns 包含以下元素的元组:
|
|
1892
|
+
* - 停止函数。
|
|
1893
|
+
* - 开始函数。
|
|
1894
|
+
* - 函数是否在执行中。
|
|
1895
|
+
* @returns_en A tuple with the following elements:
|
|
1896
|
+
* - stop function
|
|
1897
|
+
* - start function
|
|
1898
|
+
* whether function is running
|
|
1899
|
+
*/
|
|
1900
|
+
type UseRafFn = (
|
|
1901
|
+
/**
|
|
1902
|
+
* @zh 回调
|
|
1903
|
+
* @en callback
|
|
1904
|
+
*/
|
|
1905
|
+
callback: FrameRequestCallback,
|
|
1906
|
+
/**
|
|
1907
|
+
* @zh 立即执行
|
|
1908
|
+
* @en immediatly start
|
|
1909
|
+
*/
|
|
1910
|
+
initiallyActive?: boolean) => readonly [() => void, () => void, () => boolean];
|
|
1911
|
+
|
|
1912
|
+
declare const useRafFn: UseRafFn;
|
|
1913
|
+
|
|
1914
|
+
declare const useRafState: <S>(initialState: S | (() => S)) => readonly [S, Dispatch<SetStateAction<S>>];
|
|
1915
|
+
|
|
1916
|
+
declare const useReducedMotion: (defaultState?: boolean) => boolean;
|
|
1917
|
+
|
|
1918
|
+
declare const useResizeObserver: (target: RefObject<Element>, callback: ResizeObserverCallback, options?: ResizeObserverOptions) => () => void;
|
|
1919
|
+
|
|
1920
|
+
declare const useScreenSafeArea: () => readonly [string, string, string, string, lodash.DebouncedFunc<() => void>];
|
|
1921
|
+
|
|
1922
|
+
/**
|
|
1923
|
+
* @title useScriptTag
|
|
1924
|
+
* @returns 包含以下元素的元组:
|
|
1925
|
+
* - 用来加载资源的 html 元素。
|
|
1926
|
+
* - 资源加载状态。
|
|
1927
|
+
* - 资源加载函数。
|
|
1928
|
+
* - 资源卸载函数
|
|
1929
|
+
* @returns_en A tuple with the following elements:
|
|
1930
|
+
* - html element used to load resources.
|
|
1931
|
+
* - Resource loading status.
|
|
1932
|
+
* - Resource loading function.
|
|
1933
|
+
* - Resource unloading function
|
|
1934
|
+
*/
|
|
1935
|
+
type UseScriptTag = (
|
|
1936
|
+
/**
|
|
1937
|
+
* @zh 资源地址
|
|
1938
|
+
* @en source
|
|
1939
|
+
*/
|
|
1940
|
+
src: string,
|
|
1941
|
+
/**
|
|
1942
|
+
* @zh 资源加载完成的回调
|
|
1943
|
+
* @en source loaded callback
|
|
1944
|
+
*/
|
|
1945
|
+
onLoaded?: (el: HTMLScriptElement) => void,
|
|
1946
|
+
/**
|
|
1947
|
+
* @zh 可选参数
|
|
1948
|
+
* @en optional params
|
|
1949
|
+
*/
|
|
1950
|
+
options?: UseScriptTagOptions) => readonly [
|
|
1951
|
+
HTMLScriptElement | null,
|
|
1952
|
+
UseScriptTagStatus,
|
|
1953
|
+
(waitForScriptLoad?: boolean) => Promise<HTMLScriptElement | boolean>,
|
|
1954
|
+
() => void
|
|
1955
|
+
];
|
|
1956
|
+
/**
|
|
1957
|
+
* @title UseScriptTagOptions
|
|
1958
|
+
*/
|
|
1959
|
+
interface UseScriptTagOptions {
|
|
1960
|
+
/**
|
|
1961
|
+
* @en Load the script immediately
|
|
1962
|
+
* @zh 立即加载资源
|
|
1963
|
+
* @defaultValue true
|
|
1964
|
+
*/
|
|
1965
|
+
immediate?: boolean;
|
|
1966
|
+
/**
|
|
1967
|
+
* @en Add `async` attribute to the script tag
|
|
1968
|
+
* @zh 在 `script` 标签上加上 `async`
|
|
1969
|
+
* @defaultValue true
|
|
1970
|
+
*/
|
|
1971
|
+
async?: boolean;
|
|
1972
|
+
/**
|
|
1973
|
+
* @en Script type
|
|
1974
|
+
* @zh 脚本类型
|
|
1975
|
+
* @defaultValue 'text/javascript'
|
|
1976
|
+
*/
|
|
1977
|
+
type?: string;
|
|
1978
|
+
/**
|
|
1979
|
+
* @en Manual controls the timing of loading and unloading
|
|
1980
|
+
* @zh 手动控制加载和卸载时机
|
|
1981
|
+
* @defaultValue false
|
|
1982
|
+
*/
|
|
1983
|
+
manual?: boolean;
|
|
1984
|
+
/**
|
|
1985
|
+
* @zh 跨域属性
|
|
1986
|
+
* @en cross origin
|
|
1987
|
+
*/
|
|
1988
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
1989
|
+
/**
|
|
1990
|
+
* @en referrer policy
|
|
1991
|
+
* @zh 来源属性
|
|
1992
|
+
*/
|
|
1993
|
+
referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
1994
|
+
/**
|
|
1995
|
+
* @en Add `noModule` attribute to the script tag
|
|
1996
|
+
* @zh 在 `script` 标签上加上 `noModule`
|
|
1997
|
+
*/
|
|
1998
|
+
noModule?: boolean;
|
|
1999
|
+
/**
|
|
2000
|
+
* @en Add `defer` attribute to the script tag
|
|
2001
|
+
* @zh 在 `script` 标签上加上 `defer`
|
|
2002
|
+
*/
|
|
2003
|
+
defer?: boolean;
|
|
2004
|
+
/**
|
|
2005
|
+
* @en Add custom attribute to the script tag
|
|
2006
|
+
* @zh 在 script 标签上添加自定义属性
|
|
2007
|
+
*/
|
|
2008
|
+
attrs?: Record<string, string>;
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* @title UseScriptTagStatus
|
|
2012
|
+
*/
|
|
2013
|
+
type UseScriptTagStatus = "idle" | "loading" | "ready" | "error";
|
|
2014
|
+
|
|
2015
|
+
declare const useScriptTag: UseScriptTag;
|
|
2016
|
+
|
|
2017
|
+
declare const useScroll: UseScroll;
|
|
2018
|
+
|
|
2019
|
+
/**
|
|
2020
|
+
* @title useScrollIntoView
|
|
2021
|
+
* @returns 包含以下元素的对象:
|
|
2022
|
+
* - scrollIntoView:滚动进入视口函数。
|
|
2023
|
+
* - cancel: 取消滚动函数。
|
|
2024
|
+
* @returns_en A object with the following elements:
|
|
2025
|
+
* - scrollIntoView: scroll target element into viewport
|
|
2026
|
+
* - cancel: cancel scroll function
|
|
2027
|
+
*/
|
|
2028
|
+
type UseScrollIntoView = (
|
|
2029
|
+
/**
|
|
2030
|
+
* @zh dom对象
|
|
2031
|
+
* @en dom element
|
|
2032
|
+
*/
|
|
2033
|
+
targetElement: BasicTarget<HTMLElement>,
|
|
2034
|
+
/**
|
|
2035
|
+
* @zh 可选参数
|
|
2036
|
+
* @en optional params
|
|
2037
|
+
*/ params?: UseScrollIntoViewParams,
|
|
2038
|
+
/**
|
|
2039
|
+
* @zh 滚动容器
|
|
2040
|
+
* @en scroll container
|
|
2041
|
+
*/
|
|
2042
|
+
scrollElement?: BasicTarget<HTMLElement>) => {
|
|
2043
|
+
scrollIntoView: (animation?: UseScrollIntoViewAnimation) => void;
|
|
2044
|
+
cancel: () => void;
|
|
2045
|
+
};
|
|
2046
|
+
/**
|
|
2047
|
+
* @title UseScrollIntoViewAnimation
|
|
2048
|
+
*/
|
|
2049
|
+
interface UseScrollIntoViewAnimation {
|
|
2050
|
+
/**
|
|
2051
|
+
* @en target element alignment relatively to parent based on current axis
|
|
2052
|
+
* @zh 基于当前轴的目标元素相对于父元素的对齐方式
|
|
2053
|
+
*/
|
|
2054
|
+
alignment?: "start" | "end" | "center";
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* @title UseScrollIntoViewParams
|
|
2058
|
+
*/
|
|
2059
|
+
interface UseScrollIntoViewParams {
|
|
2060
|
+
/**
|
|
2061
|
+
* @en callback fired after scroll
|
|
2062
|
+
* @zh 滚动完成回调
|
|
2063
|
+
*/
|
|
2064
|
+
onScrollFinish?: () => void;
|
|
2065
|
+
/**
|
|
2066
|
+
* @en duration of scroll in milliseconds
|
|
2067
|
+
* @zh 滚动时间
|
|
2068
|
+
* @defaultValue 1250
|
|
2069
|
+
*/
|
|
2070
|
+
duration?: number;
|
|
2071
|
+
/**
|
|
2072
|
+
* @en axis of scroll
|
|
2073
|
+
* @zh 滚动方向
|
|
2074
|
+
* @defaultValue y
|
|
2075
|
+
*/
|
|
2076
|
+
axis?: "x" | "y";
|
|
2077
|
+
/**
|
|
2078
|
+
* @en custom mathematical easing function
|
|
2079
|
+
* @zh 自定义缓和数学函数
|
|
2080
|
+
* @defaultValue (t: number) => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t
|
|
2081
|
+
*/
|
|
2082
|
+
easing?: (t: number) => number;
|
|
2083
|
+
/**
|
|
2084
|
+
* @en additional distance between nearest edge and element
|
|
2085
|
+
* @zh 最近的边缘和元素之间的附加距离
|
|
2086
|
+
* @defaultValue 0
|
|
2087
|
+
*/
|
|
2088
|
+
offset?: number;
|
|
2089
|
+
/**
|
|
2090
|
+
* @en indicator if animation may be interrupted by user scrolling
|
|
2091
|
+
* @zh 指示动画是否可能因用户滚动而中断
|
|
2092
|
+
* @defaultValue true
|
|
2093
|
+
*/
|
|
2094
|
+
cancelable?: boolean;
|
|
2095
|
+
/**
|
|
2096
|
+
* @en prevents content jumping in scrolling lists with multiple targets
|
|
2097
|
+
* @zh 防止内容在具有多个目标的滚动列表中跳跃
|
|
2098
|
+
*/
|
|
2099
|
+
isList?: boolean;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
declare const useScrollIntoView: UseScrollIntoView;
|
|
2103
|
+
|
|
2104
|
+
/**
|
|
2105
|
+
* @title useScrollLock
|
|
2106
|
+
* @returns 包含以下元素的元组:
|
|
2107
|
+
* - 是否锁定。
|
|
2108
|
+
* - 更新锁定值的函数。
|
|
2109
|
+
* @returns_en A tuple with the following elements:
|
|
2110
|
+
* - whether scroll is locked.
|
|
2111
|
+
* - A function to update the value of lock state.
|
|
2112
|
+
*/
|
|
2113
|
+
type UseScrollLock = (
|
|
2114
|
+
/**
|
|
2115
|
+
* @zh dom元素
|
|
2116
|
+
* @en dom element
|
|
2117
|
+
*/
|
|
2118
|
+
target: BasicTarget<HTMLElement>,
|
|
2119
|
+
/**
|
|
2120
|
+
* @zh 默认值
|
|
2121
|
+
* @en default value
|
|
2122
|
+
* @defaultValue false
|
|
2123
|
+
*/
|
|
2124
|
+
initialState?: boolean) => readonly [boolean, (flag: boolean) => void];
|
|
2125
|
+
|
|
2126
|
+
declare const useScrollLock: UseScrollLock;
|
|
2127
|
+
|
|
2128
|
+
declare function useSessionStorage(key: string, defaults: string, options?: UseStorageOptions<string>): readonly [string | null, Dispatch<SetStateAction<string | null>>];
|
|
2129
|
+
declare function useSessionStorage(key: string, defaults: number, options?: UseStorageOptions<number>): readonly [number | null, Dispatch<SetStateAction<number | null>>];
|
|
2130
|
+
declare function useSessionStorage(key: string, defaults: boolean, options?: UseStorageOptions<boolean>): readonly [boolean | null, Dispatch<SetStateAction<boolean | null>>];
|
|
2131
|
+
declare function useSessionStorage<T>(key: string, defaults: T, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
2132
|
+
declare function useSessionStorage<T = unknown>(key: string, defaults: null, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
2133
|
+
|
|
2134
|
+
/**
|
|
2135
|
+
* @title useSetState
|
|
2136
|
+
* @returns 包含以下元素的元组:
|
|
2137
|
+
* - state 的当前值。
|
|
2138
|
+
* - 更新 state 值的函数。
|
|
2139
|
+
* @returns_en A tuple with the following elements:
|
|
2140
|
+
* - The current value of the state.
|
|
2141
|
+
* - A function to update the value of the state.
|
|
2142
|
+
*/
|
|
2143
|
+
type UseSetState = <T extends Record<string, any>>(
|
|
2144
|
+
/**
|
|
2145
|
+
* @zh 初始值
|
|
2146
|
+
* @en initial value
|
|
2147
|
+
*/
|
|
2148
|
+
initialState: T) => readonly [
|
|
2149
|
+
T,
|
|
2150
|
+
(statePartial: Partial<T> | ((currentState: T) => Partial<T>)) => void
|
|
2151
|
+
];
|
|
2152
|
+
|
|
2153
|
+
declare const useSetState: UseSetState;
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* @title useSticky
|
|
2157
|
+
* @returns 包含以下元素的元组:
|
|
2158
|
+
* - 当前是否粘滞。
|
|
2159
|
+
* - 更新粘滞值的函数。
|
|
2160
|
+
* @returns_en A tuple with the following elements:
|
|
2161
|
+
* - The current state of sticky.
|
|
2162
|
+
* - A function to update the value of sticky.
|
|
2163
|
+
*/
|
|
2164
|
+
type UseSticky = (
|
|
2165
|
+
/**
|
|
2166
|
+
* @zh dom元素
|
|
2167
|
+
* @en dom element
|
|
2168
|
+
*/
|
|
2169
|
+
targetElement: BasicTarget<HTMLElement>,
|
|
2170
|
+
/**
|
|
2171
|
+
* @zh 可选参数
|
|
2172
|
+
* @en optional params
|
|
2173
|
+
*/
|
|
2174
|
+
params: UseStickyParams,
|
|
2175
|
+
/**
|
|
2176
|
+
* @zh 滚动容器
|
|
2177
|
+
* @en scroll container
|
|
2178
|
+
*/
|
|
2179
|
+
scrollElement?: BasicTarget<HTMLElement>) => [boolean, React.Dispatch<React.SetStateAction<boolean>>];
|
|
2180
|
+
/**
|
|
2181
|
+
* @title UseStickyParams
|
|
2182
|
+
*/
|
|
2183
|
+
interface UseStickyParams {
|
|
2184
|
+
/**
|
|
2185
|
+
* @en axis of scroll
|
|
2186
|
+
* @zh 滚动方向
|
|
2187
|
+
* @defaultValue y
|
|
2188
|
+
*/
|
|
2189
|
+
axis?: "x" | "y";
|
|
2190
|
+
/**
|
|
2191
|
+
* @en cover height or width
|
|
2192
|
+
* @zh 沉浸式高度/宽度
|
|
2193
|
+
* @defaultValue 0
|
|
2194
|
+
*/
|
|
2195
|
+
nav: number;
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
declare const useSticky: (targetElement: BasicTarget<HTMLElement>, { axis, nav }: UseStickyParams, scrollElement?: BasicTarget<HTMLElement>) => [boolean, react__default.Dispatch<react__default.SetStateAction<boolean>>];
|
|
2199
|
+
|
|
2200
|
+
declare const useSupported: (callback: () => unknown, sync?: boolean) => boolean;
|
|
2201
|
+
|
|
2202
|
+
/**
|
|
2203
|
+
* @title useTextDirection
|
|
2204
|
+
* @returns 包含以下元素的元组:
|
|
2205
|
+
* - 文字方向。
|
|
2206
|
+
* - 更新文字方向值的函数。
|
|
2207
|
+
* @returns_en A tuple with the following elements:
|
|
2208
|
+
* - The current value of the text direction.
|
|
2209
|
+
* - A function to update the value of the text direction.
|
|
2210
|
+
*/
|
|
2211
|
+
type UseTextDirection = (
|
|
2212
|
+
/**
|
|
2213
|
+
* @zh 可选参数
|
|
2214
|
+
* @en optional params
|
|
2215
|
+
*/
|
|
2216
|
+
options?: UseTextDirectionOptions) => readonly [UseTextDirectionValue, (value: UseTextDirectionValue) => void];
|
|
2217
|
+
/**
|
|
2218
|
+
* @title UseTextDirectionOptions
|
|
2219
|
+
*/
|
|
2220
|
+
interface UseTextDirectionOptions {
|
|
2221
|
+
/**
|
|
2222
|
+
* @en CSS Selector for the target element applying to
|
|
2223
|
+
* @zh 适用于目标元素的 CSS 选择器
|
|
2224
|
+
* @defaultValue 'html'
|
|
2225
|
+
*/
|
|
2226
|
+
selector?: string;
|
|
2227
|
+
/**
|
|
2228
|
+
* @en Initial value
|
|
2229
|
+
* @zh 初始值
|
|
2230
|
+
* @defaultValue 'ltr'
|
|
2231
|
+
*/
|
|
2232
|
+
initialValue?: UseTextDirectionValue;
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* @title UseTextDirectionValue
|
|
2236
|
+
*/
|
|
2237
|
+
type UseTextDirectionValue = "ltr" | "rtl" | "auto";
|
|
2238
|
+
|
|
2239
|
+
declare const useTextDirection: UseTextDirection;
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* @title useTextSelection
|
|
2243
|
+
* @returns 选择的文本对象
|
|
2244
|
+
* @returns_en selected text object
|
|
2245
|
+
*/
|
|
2246
|
+
type UseTextSelection = () => Selection | null;
|
|
2247
|
+
|
|
2248
|
+
declare const useTextSelection: UseTextSelection;
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* @title useThrottle
|
|
2252
|
+
*/
|
|
2253
|
+
type UseThrottle = <T>(
|
|
2254
|
+
/**
|
|
2255
|
+
* @zh 要节流的值
|
|
2256
|
+
* @en the value need to throttle
|
|
2257
|
+
*/
|
|
2258
|
+
value: T,
|
|
2259
|
+
/**
|
|
2260
|
+
* @zh 间隔时间
|
|
2261
|
+
* @en wait time
|
|
2262
|
+
*/
|
|
2263
|
+
wait?: number,
|
|
2264
|
+
/**
|
|
2265
|
+
* @zh 传递给 `lodash.throttle` 的选项
|
|
2266
|
+
* @en options passed to `lodash.throttle`
|
|
2267
|
+
*/
|
|
2268
|
+
options?: ThrottleSettings) => T;
|
|
2269
|
+
|
|
2270
|
+
declare const useThrottle: UseThrottle;
|
|
2271
|
+
|
|
2272
|
+
declare const useThrottleFn: <T extends (...args: any) => any>(fn: T, wait?: number, options?: ThrottleSettings) => {
|
|
2273
|
+
run: lodash.DebouncedFunc<(...args_0: Parameters<T>) => ReturnType<T>>;
|
|
2274
|
+
cancel: () => void;
|
|
2275
|
+
flush: () => ReturnType<T> | undefined;
|
|
2276
|
+
};
|
|
2277
|
+
|
|
2278
|
+
/**
|
|
2279
|
+
* @title useTimeout
|
|
2280
|
+
* @returns 包含以下元素的元组:
|
|
2281
|
+
* - 是否等待定时器执行。
|
|
2282
|
+
* - 设置定时器。
|
|
2283
|
+
* - 取消定时器。
|
|
2284
|
+
* @returns_en A tuple with the following elements:
|
|
2285
|
+
* - Whether to wait for the timer to execute.
|
|
2286
|
+
* - Set timer.
|
|
2287
|
+
* - Cancel timer.
|
|
2288
|
+
*/
|
|
2289
|
+
type UseTimeout = (
|
|
2290
|
+
/**
|
|
2291
|
+
* @zh 间隔时间
|
|
2292
|
+
* @en wait time
|
|
2293
|
+
*/
|
|
2294
|
+
ms?: number
|
|
2295
|
+
/**
|
|
2296
|
+
* @zh 可选参数
|
|
2297
|
+
* @en optional param
|
|
2298
|
+
*/ , options?: UseTimeoutOptions) => Stoppable;
|
|
2299
|
+
/**
|
|
2300
|
+
* @title UseTimeoutOptions
|
|
2301
|
+
*/
|
|
2302
|
+
interface UseTimeoutOptions {
|
|
2303
|
+
/**
|
|
2304
|
+
* @en Start the timer immediate after calling this function
|
|
2305
|
+
* @zh 立即设置定时器
|
|
2306
|
+
* @defaultValue false
|
|
2307
|
+
*/
|
|
2308
|
+
immediate?: boolean;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
declare const useTimeout: UseTimeout;
|
|
2312
|
+
|
|
2313
|
+
/**
|
|
2314
|
+
* @title useTimeoutFn
|
|
2315
|
+
* @returns 包含以下元素的元组:
|
|
2316
|
+
* - 是否等待定时器执行。
|
|
2317
|
+
* - 设置定时器。
|
|
2318
|
+
* - 取消定时器。
|
|
2319
|
+
* @returns_en A tuple with the following elements:
|
|
2320
|
+
* - Whether to wait for the timer to execute.
|
|
2321
|
+
* - Set timer.
|
|
2322
|
+
* - Cancel timer.
|
|
2323
|
+
*/
|
|
2324
|
+
type UseTimeoutFn = (
|
|
2325
|
+
/**
|
|
2326
|
+
* @zh 回调
|
|
2327
|
+
* @en callback
|
|
2328
|
+
*/
|
|
2329
|
+
cb: (...args: unknown[]) => any,
|
|
2330
|
+
/**
|
|
2331
|
+
* @zh 间隔时间
|
|
2332
|
+
* @en wait time
|
|
2333
|
+
*/
|
|
2334
|
+
interval: number,
|
|
2335
|
+
/**
|
|
2336
|
+
* @zh 可选参数
|
|
2337
|
+
* @en optional param
|
|
2338
|
+
*/
|
|
2339
|
+
options?: UseTimeoutFnOptions) => Stoppable;
|
|
2340
|
+
/**
|
|
2341
|
+
* @title UseTimeoutFnOptions
|
|
2342
|
+
*/
|
|
2343
|
+
interface UseTimeoutFnOptions {
|
|
2344
|
+
/**
|
|
2345
|
+
* @en Start the timer immediate after calling this function
|
|
2346
|
+
* @zh 立即设置定时器
|
|
2347
|
+
* @defaultValue false
|
|
2348
|
+
*/
|
|
2349
|
+
immediate?: boolean;
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
/**
|
|
2353
|
+
* Wrapper for `setTimeout` with controls.
|
|
2354
|
+
*
|
|
2355
|
+
* @param cb
|
|
2356
|
+
* @param interval
|
|
2357
|
+
* @param options
|
|
2358
|
+
*/
|
|
2359
|
+
declare const useTimeoutFn: UseTimeoutFn;
|
|
2360
|
+
|
|
2361
|
+
/**
|
|
2362
|
+
* @title useTitle
|
|
2363
|
+
*/
|
|
2364
|
+
type UseTitle = (
|
|
2365
|
+
/**
|
|
2366
|
+
* @zh 标题
|
|
2367
|
+
* @en title
|
|
2368
|
+
*/
|
|
2369
|
+
title: string) => void;
|
|
2370
|
+
|
|
2371
|
+
declare const useTitle: UseTitle;
|
|
2372
|
+
|
|
2373
|
+
/**
|
|
2374
|
+
* @title useToggle
|
|
2375
|
+
* @returns 包含以下元素的元组:
|
|
2376
|
+
* - 布尔状态的当前值。
|
|
2377
|
+
* - 切换布尔状态值的函数。
|
|
2378
|
+
* @returns_en A tuple with the following elements:
|
|
2379
|
+
* - The current value of the bool state.
|
|
2380
|
+
* - A function to update the value of the bool state.
|
|
2381
|
+
*/
|
|
2382
|
+
type UseToggle = (
|
|
2383
|
+
/**
|
|
2384
|
+
* @zh 初始值
|
|
2385
|
+
* @en initialValue
|
|
2386
|
+
*/
|
|
2387
|
+
initialValue: boolean) => [boolean, (nextValue?: any) => void];
|
|
2388
|
+
|
|
2389
|
+
declare const useToggle: UseToggle;
|
|
2390
|
+
|
|
2391
|
+
declare const useUnmount: (fn: () => void) => void;
|
|
2392
|
+
|
|
2393
|
+
declare const useUpdate: () => () => void;
|
|
2394
|
+
|
|
2395
|
+
declare const useUpdateEffect: typeof useEffect | typeof react.useLayoutEffect;
|
|
2396
|
+
|
|
2397
|
+
declare const useUpdateLayoutEffect: typeof react.useEffect | typeof useLayoutEffect;
|
|
2398
|
+
|
|
2399
|
+
/**
|
|
2400
|
+
* @title useWebNotification
|
|
2401
|
+
*/
|
|
2402
|
+
type UseWebNotification = (
|
|
2403
|
+
/**
|
|
2404
|
+
* @zh 自动请求权限
|
|
2405
|
+
* @en auto request permission
|
|
2406
|
+
*/
|
|
2407
|
+
requestPermissions?: boolean) => UseWebNotificationReturn;
|
|
2408
|
+
/**
|
|
2409
|
+
* @title UseWebNotificationReturn
|
|
2410
|
+
*/
|
|
2411
|
+
interface UseWebNotificationReturn {
|
|
2412
|
+
/**
|
|
2413
|
+
* @zh 浏览器是否支持
|
|
2414
|
+
* @en whether browser support
|
|
2415
|
+
*/
|
|
2416
|
+
readonly isSupported: boolean;
|
|
2417
|
+
/**
|
|
2418
|
+
* @zh 展示函数
|
|
2419
|
+
* @en show function
|
|
2420
|
+
*/
|
|
2421
|
+
readonly show: UseWebNotificationShow;
|
|
2422
|
+
/**
|
|
2423
|
+
* @zh 关闭函数
|
|
2424
|
+
* @en close function
|
|
2425
|
+
*/
|
|
2426
|
+
readonly close: () => void;
|
|
2427
|
+
/**
|
|
2428
|
+
* @zh 请求权限函数
|
|
2429
|
+
* @en request permissions function
|
|
2430
|
+
*/
|
|
2431
|
+
readonly ensurePermissions: () => Promise<boolean | undefined>;
|
|
2432
|
+
/**
|
|
2433
|
+
* @zh 权限状态
|
|
2434
|
+
* @en permission status
|
|
2435
|
+
*/
|
|
2436
|
+
readonly permissionGranted: React.MutableRefObject<boolean>;
|
|
2437
|
+
}
|
|
2438
|
+
/**
|
|
2439
|
+
* @title UseWebNotificationShow
|
|
2440
|
+
*/
|
|
2441
|
+
type UseWebNotificationShow = (
|
|
2442
|
+
/**
|
|
2443
|
+
* @zh 通知标题
|
|
2444
|
+
* @en notification title
|
|
2445
|
+
*/
|
|
2446
|
+
title: string,
|
|
2447
|
+
/**
|
|
2448
|
+
* @zh 通知选项
|
|
2449
|
+
* @en options passed to `NotificationOptions`
|
|
2450
|
+
*/
|
|
2451
|
+
options?: NotificationOptions) => Notification | undefined;
|
|
2452
|
+
|
|
2453
|
+
declare const useWebNotification: UseWebNotification;
|
|
2454
|
+
|
|
2455
|
+
declare const useWindowsFocus: (defauleValue?: boolean) => boolean;
|
|
2456
|
+
|
|
2457
|
+
/**
|
|
2458
|
+
* @title useWindowScroll
|
|
2459
|
+
* @returns {UseWindowScrollState}
|
|
2460
|
+
*/
|
|
2461
|
+
type UseWindowScroll = () => UseWindowScrollState;
|
|
2462
|
+
/**
|
|
2463
|
+
* @title useWindowScrollState
|
|
2464
|
+
*/
|
|
2465
|
+
interface UseWindowScrollState {
|
|
2466
|
+
/**
|
|
2467
|
+
* @zh 水平滚动的像素值
|
|
2468
|
+
* @en pixel value of horizontal scrolling
|
|
2469
|
+
*/
|
|
2470
|
+
x: number;
|
|
2471
|
+
/**
|
|
2472
|
+
* @zh 垂直滚动的像素值
|
|
2473
|
+
* @en pixel value of vertical scrolling
|
|
2474
|
+
*/
|
|
2475
|
+
y: number;
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
declare const useWindowScroll: () => UseWindowScrollState;
|
|
2479
|
+
|
|
2480
|
+
/**
|
|
2481
|
+
* @title useWindowSize
|
|
2482
|
+
* @returns_en A object with the following elements:
|
|
2483
|
+
* - width: The current window width.
|
|
2484
|
+
* - height: The current window height.
|
|
2485
|
+
* @returns 包含以下元素的对象:
|
|
2486
|
+
* - width:当前视窗宽度。
|
|
2487
|
+
* - height: 当前视窗高度。
|
|
2488
|
+
*/
|
|
2489
|
+
type UseWindowSize = () => {
|
|
2490
|
+
readonly width: number;
|
|
2491
|
+
readonly height: number;
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
declare const useWindowSize: UseWindowSize;
|
|
2495
|
+
|
|
2496
|
+
/**
|
|
2497
|
+
* @title useClipBoard
|
|
2498
|
+
* @returns_en Returns a readonly tuple.
|
|
2499
|
+
* @returns 返回只读元组.
|
|
2500
|
+
*/
|
|
2501
|
+
type UseClipboard = () => readonly [string, (txt: string) => Promise<void>];
|
|
2502
|
+
|
|
2503
|
+
declare const useClipboard: UseClipboard;
|
|
2504
|
+
|
|
2505
|
+
/**
|
|
2506
|
+
* @title useDocumentVisiblity
|
|
2507
|
+
* @returns_en document visibility
|
|
2508
|
+
* @returns 文档可见性
|
|
2509
|
+
*/
|
|
2510
|
+
type UseDocumentVisibility = (
|
|
2511
|
+
/**
|
|
2512
|
+
* @zh 默认值
|
|
2513
|
+
* @en default value
|
|
2514
|
+
*/
|
|
2515
|
+
defaultValue?: DocumentVisibilityState) => DocumentVisibilityState;
|
|
2516
|
+
|
|
2517
|
+
/**
|
|
2518
|
+
* @title useEventListener
|
|
2519
|
+
*/
|
|
2520
|
+
type UseEventListener = (
|
|
2521
|
+
/**
|
|
2522
|
+
* @zh 事件名称
|
|
2523
|
+
* @en event name
|
|
2524
|
+
*/
|
|
2525
|
+
eventName: string,
|
|
2526
|
+
/**
|
|
2527
|
+
* @zh 事件处理器
|
|
2528
|
+
* @en event handler
|
|
2529
|
+
*/
|
|
2530
|
+
handler: (event: any) => void,
|
|
2531
|
+
/**
|
|
2532
|
+
* @zh dom元素
|
|
2533
|
+
* @en dom element
|
|
2534
|
+
* @defaultValue `window`
|
|
2535
|
+
*/
|
|
2536
|
+
element?: HTMLElement | Element | Window | Document | EventTarget | null | undefined,
|
|
2537
|
+
/**
|
|
2538
|
+
* @zh 监听选项
|
|
2539
|
+
* @en listener options
|
|
2540
|
+
*/
|
|
2541
|
+
options?: boolean | AddEventListenerOptions | undefined) => void;
|
|
2542
|
+
|
|
2543
|
+
/**
|
|
2544
|
+
* @title useFavicon
|
|
2545
|
+
*/
|
|
2546
|
+
type UseFavicon = (
|
|
2547
|
+
/**
|
|
2548
|
+
* @zh 图标路径
|
|
2549
|
+
* @en icon href
|
|
2550
|
+
*/
|
|
2551
|
+
href: string,
|
|
2552
|
+
/**
|
|
2553
|
+
* @zh 基础 url
|
|
2554
|
+
* @en base url
|
|
2555
|
+
*/
|
|
2556
|
+
baseUrl?: string,
|
|
2557
|
+
/**
|
|
2558
|
+
* @zh 设置 link 标签的 rel 属性
|
|
2559
|
+
* @en set rel attribute to link element
|
|
2560
|
+
* @defaultValue icon
|
|
2561
|
+
*/
|
|
2562
|
+
rel?: string) => void;
|
|
2563
|
+
|
|
2564
|
+
/**
|
|
2565
|
+
* @title useHover
|
|
2566
|
+
*/
|
|
2567
|
+
type UseHover = <T extends Element = HTMLDivElement>(
|
|
2568
|
+
/**
|
|
2569
|
+
* @zh dom对象
|
|
2570
|
+
* @en dom element
|
|
2571
|
+
*/
|
|
2572
|
+
target: RefObject<T>) => boolean;
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* @title useIntersectionObserver
|
|
2576
|
+
* @returns 停止监听函数
|
|
2577
|
+
* @returns_en stop listening function
|
|
2578
|
+
*/
|
|
2579
|
+
type UseIntersectionObserver = (
|
|
2580
|
+
/**
|
|
2581
|
+
* @zh dom元素
|
|
2582
|
+
* @en dom element
|
|
2583
|
+
*/
|
|
2584
|
+
target: RefObject<Element>,
|
|
2585
|
+
/**
|
|
2586
|
+
* @zh 回调
|
|
2587
|
+
* @en callback
|
|
2588
|
+
*/
|
|
2589
|
+
callback: IntersectionObserverCallback,
|
|
2590
|
+
/**
|
|
2591
|
+
* @zh 传递给 `IntersectionObserver` 的参数
|
|
2592
|
+
* @en options passed to `IntersectionObserver`
|
|
2593
|
+
*/
|
|
2594
|
+
options?: IntersectionObserverInit) => () => void;
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* @title useLocalStorage
|
|
2598
|
+
* @returns 包含以下元素的元组:
|
|
2599
|
+
* - localStorage 的当前值。
|
|
2600
|
+
* - 更新 localStorage 值的函数。
|
|
2601
|
+
* @returns_en A tuple with the following elements:
|
|
2602
|
+
* - The current value of the localStorage.
|
|
2603
|
+
* - A function to update the value of the localStorage.
|
|
2604
|
+
*/
|
|
2605
|
+
type UseLocalStorage = <T extends string | number | boolean | object | null>(
|
|
2606
|
+
/**
|
|
2607
|
+
* @zh 键值
|
|
2608
|
+
* @en key
|
|
2609
|
+
*/
|
|
2610
|
+
key: string,
|
|
2611
|
+
/**
|
|
2612
|
+
* @zh 默认值
|
|
2613
|
+
* @en default value
|
|
2614
|
+
*/
|
|
2615
|
+
defaultValue?: T,
|
|
2616
|
+
/**
|
|
2617
|
+
* @zh 可选参数
|
|
2618
|
+
* @en optional params
|
|
2619
|
+
*/
|
|
2620
|
+
options?: UseLocalStorageOptions<T>) => readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
2621
|
+
/**
|
|
2622
|
+
* @title UseLocalStorageOptions
|
|
2623
|
+
*/
|
|
2624
|
+
interface UseLocalStorageOptions<T> {
|
|
2625
|
+
/**
|
|
2626
|
+
* @en Custom data serialization
|
|
2627
|
+
* @zh 自定义数据序列化
|
|
2628
|
+
*/
|
|
2629
|
+
serializer?: UseLocalStorageSerializer<T>;
|
|
2630
|
+
/**
|
|
2631
|
+
* @en On error callback
|
|
2632
|
+
* @zh 错误回调
|
|
2633
|
+
* @defaultValue `console.error`
|
|
2634
|
+
*/
|
|
2635
|
+
onError?: (error: unknown) => void;
|
|
2636
|
+
/**
|
|
2637
|
+
* @en set to storage when storage doesn't has data in effect, fallback to `defaultValue`
|
|
2638
|
+
* @zh 当副作用执行的时候没有在 storage 中获取到数据时设置,默认会设置 `defaultValue`
|
|
2639
|
+
*/
|
|
2640
|
+
effectStorageValue?: T | (() => T);
|
|
2641
|
+
}
|
|
2642
|
+
/**
|
|
2643
|
+
* @title UseLocalStorageSerializer
|
|
2644
|
+
*/
|
|
2645
|
+
interface UseLocalStorageSerializer<T> {
|
|
2646
|
+
/**
|
|
2647
|
+
* @en Custom data read
|
|
2648
|
+
* @zh 自定义数据读取
|
|
2649
|
+
*/
|
|
2650
|
+
read: (raw: string) => T;
|
|
2651
|
+
/**
|
|
2652
|
+
* @en Custom data write
|
|
2653
|
+
* @zh 自定义数据写入
|
|
2654
|
+
*/
|
|
2655
|
+
write: (value: T) => string;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
/**
|
|
2659
|
+
* @title useMountedState
|
|
2660
|
+
* @returns 组件的挂载状态
|
|
2661
|
+
* @returns_en component mounted state
|
|
2662
|
+
*/
|
|
2663
|
+
type UseMountedState = () => () => boolean;
|
|
2664
|
+
|
|
2665
|
+
/**
|
|
2666
|
+
* @title usePageLeave
|
|
2667
|
+
* @returns 鼠标是否离开页面
|
|
2668
|
+
* @returns_en whether the mouse leave page
|
|
2669
|
+
*/
|
|
2670
|
+
type UsePageLeave = () => boolean;
|
|
2671
|
+
|
|
2672
|
+
/**
|
|
2673
|
+
* @title usePreferredDark
|
|
2674
|
+
* @returns 是否偏好黑色
|
|
2675
|
+
* @returns_en whether prefer dark
|
|
2676
|
+
*/
|
|
2677
|
+
type UsePreferredDark = (
|
|
2678
|
+
/**
|
|
2679
|
+
* @zh 默认值
|
|
2680
|
+
* @en defaule value
|
|
2681
|
+
*/
|
|
2682
|
+
defaultState?: boolean) => boolean;
|
|
2683
|
+
|
|
2684
|
+
/**
|
|
2685
|
+
* @title usePrevious
|
|
2686
|
+
* @returns 更新前的值
|
|
2687
|
+
* @returns_en previous value
|
|
2688
|
+
*/
|
|
2689
|
+
type UsePrevious = <T>(
|
|
2690
|
+
/**
|
|
2691
|
+
* @zh 状态值
|
|
2692
|
+
* @en state value
|
|
2693
|
+
*/
|
|
2694
|
+
state: T) => T | undefined;
|
|
2695
|
+
|
|
2696
|
+
/**
|
|
2697
|
+
* @title useRafState
|
|
2698
|
+
* @returns 包含以下元素的元组:
|
|
2699
|
+
* - state 的当前值。
|
|
2700
|
+
* - 在 `requestAnimationFrame` 中更新 state 值的函数。
|
|
2701
|
+
* @returns_en A tuple with the following elements:
|
|
2702
|
+
* - the state value
|
|
2703
|
+
* - a function to update state in `requestAnimationFrame`
|
|
2704
|
+
*/
|
|
2705
|
+
type UseRafState = <S>(
|
|
2706
|
+
/**
|
|
2707
|
+
* @zh 状态值
|
|
2708
|
+
* @en state value
|
|
2709
|
+
*/
|
|
2710
|
+
initialState: S | (() => S)) => readonly [S, Dispatch<SetStateAction<S>>];
|
|
2711
|
+
|
|
2712
|
+
/**
|
|
2713
|
+
* @title useReducedMotion
|
|
2714
|
+
* @returns 是否偏好减少动画
|
|
2715
|
+
* @returns_en whether prefer reduced motion
|
|
2716
|
+
*/
|
|
2717
|
+
type UseReducedMotion = (
|
|
2718
|
+
/**
|
|
2719
|
+
* @zh 默认值
|
|
2720
|
+
* @en default value
|
|
2721
|
+
*/
|
|
2722
|
+
defaultState?: boolean) => boolean;
|
|
2723
|
+
|
|
2724
|
+
/**
|
|
2725
|
+
* @title useResizeObserver
|
|
2726
|
+
*/
|
|
2727
|
+
type UseResizeObserver = (
|
|
2728
|
+
/**
|
|
2729
|
+
* @zh dom元素
|
|
2730
|
+
* @en dom element
|
|
2731
|
+
*/
|
|
2732
|
+
target: RefObject<Element>,
|
|
2733
|
+
/**
|
|
2734
|
+
* @zh 回调
|
|
2735
|
+
* @en callback
|
|
2736
|
+
*/
|
|
2737
|
+
callback: ResizeObserverCallback,
|
|
2738
|
+
/**
|
|
2739
|
+
* @zh `resizeObserver` 参数
|
|
2740
|
+
* @en options passed to `resizeObserver`
|
|
2741
|
+
*/
|
|
2742
|
+
options?: ResizeObserverOptions) => () => void;
|
|
2743
|
+
|
|
2744
|
+
/**
|
|
2745
|
+
* @title useScreenSafeArea
|
|
2746
|
+
* @returns 包含以下元素的元组:
|
|
2747
|
+
* - 顶部安全距离。
|
|
2748
|
+
* - 右边安全距离。
|
|
2749
|
+
* - 底部安全距离。
|
|
2750
|
+
* - 左边安全距离,
|
|
2751
|
+
* - 手动更新函数
|
|
2752
|
+
* @returns_en A tuple with the following elements:
|
|
2753
|
+
* - top safe distance
|
|
2754
|
+
* - right safe distance
|
|
2755
|
+
* - bottom safe distance
|
|
2756
|
+
* - left safe distance
|
|
2757
|
+
* - munual update function
|
|
2758
|
+
*/
|
|
2759
|
+
type UseScreenSafeArea = () => readonly [string, string, string, string, DebouncedFunc$1<() => void>];
|
|
2760
|
+
|
|
2761
|
+
/**
|
|
2762
|
+
* @title useSessionStorage
|
|
2763
|
+
* @returns 包含以下元素的元组:
|
|
2764
|
+
* - sessionStorage 的当前值。
|
|
2765
|
+
* - 更新 sessionStorage 值的函数。
|
|
2766
|
+
* @returns_en A tuple with the following elements:
|
|
2767
|
+
* - The current value of the sessionStorage.
|
|
2768
|
+
* - A function to update the value of the sessionStorage.
|
|
2769
|
+
*/
|
|
2770
|
+
type UseSessionStorage = <T extends string | number | boolean | object | null>(
|
|
2771
|
+
/**
|
|
2772
|
+
* @zh 键值
|
|
2773
|
+
* @en key
|
|
2774
|
+
*/
|
|
2775
|
+
key: string,
|
|
2776
|
+
/**
|
|
2777
|
+
* @zh 默认值
|
|
2778
|
+
* @en default value
|
|
2779
|
+
*/
|
|
2780
|
+
defaultValue?: T,
|
|
2781
|
+
/**
|
|
2782
|
+
* @zh 可选参数
|
|
2783
|
+
* @en optional params
|
|
2784
|
+
*/
|
|
2785
|
+
options?: UseSessionStorageOptions<T>) => readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
2786
|
+
/**
|
|
2787
|
+
* @title UseSessionStorageOptions
|
|
2788
|
+
*/
|
|
2789
|
+
interface UseSessionStorageOptions<T> {
|
|
2790
|
+
/**
|
|
2791
|
+
* @en Custom data serialization
|
|
2792
|
+
* @zh 自定义数据序列化
|
|
2793
|
+
*/
|
|
2794
|
+
serializer?: UseSessionStorageSerializer<T>;
|
|
2795
|
+
/**
|
|
2796
|
+
* @en On error callback
|
|
2797
|
+
* @zh 错误回调
|
|
2798
|
+
* @defaultValue `console.error`
|
|
2799
|
+
*/
|
|
2800
|
+
onError?: (error: unknown) => void;
|
|
2801
|
+
/**
|
|
2802
|
+
* @en set to storage when storage doesn't has data in effect, fallback to `defaultValue`
|
|
2803
|
+
* @zh 当副作用执行的时候没有在 storage 中获取到数据时设置,默认会设置 `defaultValue`
|
|
2804
|
+
*/
|
|
2805
|
+
effectStorageValue?: T | (() => T);
|
|
2806
|
+
}
|
|
2807
|
+
/**
|
|
2808
|
+
* @title UseSessionStorageSerializer
|
|
2809
|
+
*/
|
|
2810
|
+
interface UseSessionStorageSerializer<T> {
|
|
2811
|
+
/**
|
|
2812
|
+
* @en Custom data read
|
|
2813
|
+
* @zh 自定义数据读取
|
|
2814
|
+
*/
|
|
2815
|
+
read: (raw: string) => T;
|
|
2816
|
+
/**
|
|
2817
|
+
* @en Custom data write
|
|
2818
|
+
* @zh 自定义数据写入
|
|
2819
|
+
*/
|
|
2820
|
+
write: (value: T) => string;
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
/**
|
|
2824
|
+
* @title useSupported
|
|
2825
|
+
* @returns 浏览器是否支持
|
|
2826
|
+
* @returns_en whether the browser support
|
|
2827
|
+
*/
|
|
2828
|
+
type UseSupported = (
|
|
2829
|
+
/**
|
|
2830
|
+
* @zh 测试回调
|
|
2831
|
+
* @en test callback
|
|
2832
|
+
*/
|
|
2833
|
+
callback: () => unknown,
|
|
2834
|
+
/**
|
|
2835
|
+
* @zh 使用 useLayoutEffect来进行测试
|
|
2836
|
+
* @en use useLayoutEffect to test
|
|
2837
|
+
* @defaultValue false
|
|
2838
|
+
*/
|
|
2839
|
+
sync?: boolean) => boolean;
|
|
2840
|
+
|
|
2841
|
+
/**
|
|
2842
|
+
* @title useThrottleFn
|
|
2843
|
+
* @returns_en A object with the following elements:
|
|
2844
|
+
* - run: exec function.
|
|
2845
|
+
* - cancel: cancel exec function.
|
|
2846
|
+
* - flush: immediately exec function
|
|
2847
|
+
* @returns 具有以下元素的对象:
|
|
2848
|
+
* - run:执行函数。
|
|
2849
|
+
* - cancel:取消执行函数。
|
|
2850
|
+
* - flush: 立即执行函数
|
|
2851
|
+
*/
|
|
2852
|
+
type UseThrottleFn = <T extends (...args: any) => any>(
|
|
2853
|
+
/**
|
|
2854
|
+
* @zh 要节流的函数
|
|
2855
|
+
* @en Throttle function
|
|
2856
|
+
*/
|
|
2857
|
+
fn: T,
|
|
2858
|
+
/**
|
|
2859
|
+
* @zh 间隔时间
|
|
2860
|
+
* @en wait time
|
|
2861
|
+
*/
|
|
2862
|
+
wait?: number,
|
|
2863
|
+
/**
|
|
2864
|
+
* @zh 传递给 `lodash.throttle` 的属性
|
|
2865
|
+
* @en options passed to `lodash.throttle`
|
|
2866
|
+
*/
|
|
2867
|
+
options?: ThrottleSettings$1) => {
|
|
2868
|
+
run: DebouncedFunc<(...args_0: Parameters<T>) => ReturnType<T>>;
|
|
2869
|
+
cancel: () => void;
|
|
2870
|
+
flush: any;
|
|
2871
|
+
};
|
|
2872
|
+
|
|
2873
|
+
/**
|
|
2874
|
+
* @title useUnmount
|
|
2875
|
+
*/
|
|
2876
|
+
type UseUnmount = (
|
|
2877
|
+
/**
|
|
2878
|
+
* @zh 清理函数
|
|
2879
|
+
* @en clear function
|
|
2880
|
+
*/
|
|
2881
|
+
fn: () => void) => void;
|
|
2882
|
+
|
|
2883
|
+
/**
|
|
2884
|
+
* @title useUpdate
|
|
2885
|
+
* @returns 强制更新函数
|
|
2886
|
+
* @returns_en rerender trigger function
|
|
2887
|
+
*/
|
|
2888
|
+
type UseUpdate = () => () => void;
|
|
2889
|
+
|
|
2890
|
+
/**
|
|
2891
|
+
* @title useWindowsFocus
|
|
2892
|
+
* @returns 窗口是否聚焦
|
|
2893
|
+
* @returns_en whether window focus
|
|
2894
|
+
*/
|
|
2895
|
+
type UseWindowsFocus = (
|
|
2896
|
+
/**
|
|
2897
|
+
* @zh 默认值
|
|
2898
|
+
* @en defauleValue
|
|
2899
|
+
*/
|
|
2900
|
+
defauleValue?: boolean) => boolean;
|
|
2901
|
+
|
|
2902
|
+
export { type ColorScheme, type Contrast, type DepsEqualFnType, type EventType, type INetworkInformation, type IUseNetworkState, type KeyModifier, type UseActiveElement, type UseAsyncEffect, type UseClickOutside, type UseClipboard, type UseCookie, type UseCookieState, type UseCountDown, type UseCounter, type UseCssVar, type UseCssVarOptions, type UseCustomCompareEffect, type UseCycleList, type UseDarkMode, type UseDarkOptions, type UseDebounce, type UseDebounceFn, type UseDeepCompareEffect, type UseDocumentVisibility, type UseDoubleClick, type UseDoubleClickProps, type UseDraggable, type UseDraggableOptions, type UseDropZone, type UseElementBounding, type UseElementBoundingOptions, type UseElementBoundingReturn, type UseElementSize, type UseElementVisibility, type UseEvent, type UseEventEmitter, type UseEventEmitterDisposable, type UseEventEmitterEvent, type UseEventEmitterEventOnce, type UseEventEmitterListener, type UseEventEmitterReturn, type UseEventListener, type UseEyeDropper, type UseEyeDropperOpenOptions, type UseEyeDropperOpenReturnType, type UseFavicon, type UseFileDialog, type UseFileDialogOptions, type UseFirstMountState, type UseFocus, type UseFps, type UseFpsOptions, type UseFullScreenOptions, type UseFullscreen, type UseGeolocation, type UseHover, type UseIdle, type UseInfiniteScroll, type UseInfiniteScrollArrivedState, type UseInfiniteScrollDirection, type UseInfiniteScrollLoadMore, type UseInfiniteScrollOptions, type UseIntersectionObserver, type UseInterval, type UseIntervalOptions, type UseKeyModifier, type UseLatest, type UseLocalStorage, type UseLocalStorageOptions, type UseLocalStorageSerializer, type UseLocationSelector, type UseLongPress, type UseLongPressOptions, type UseMeasure, type UseMeasureRect, type UseMediaDeviceOptions, type UseMediaDevices, type UseMediaQuery, type UseModifierOptions, type UseMount, type UseMountedState, type UseMouse, type UseMouseCursorState, type UseMousePressed, type UseMousePressedOptions, type UseMousePressedSourceType, type UseMutationObserver, type UseNetwork, type UseObjectUrl, type UseOnline, type UseOrientation, type UseOrientationLockType, type UseOrientationState, type UseOrientationType, type UsePageLeave, type UsePermission, type UsePermissionDescriptorNamePolyfill, type UsePermissionGeneralPermissionDescriptor, type UsePermissionState, type UsePreferredColorScheme, type UsePreferredContrast, type UsePreferredDark, type UsePrevious, type UseRafFn, type UseRafState, type UseReducedMotion, type UseResizeObserver, type UseScreenSafeArea, type UseScriptTag, type UseScriptTagOptions, type UseScriptTagStatus, type UseScroll, type UseScrollArrivedState, type UseScrollDirection, type UseScrollIntoView, type UseScrollIntoViewAnimation, type UseScrollIntoViewParams, type UseScrollLock, type UseScrollOffset, type UseScrollOptions, type UseSessionStorage, type UseSessionStorageOptions, type UseSessionStorageSerializer, type UseSetState, type UseSticky, type UseStickyParams, type UseSupported, type UseTextDirection, type UseTextDirectionOptions, type UseTextDirectionValue, type UseTextSelection, type UseThrottle, type UseThrottleFn, type UseTimeout, type UseTimeoutFn, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseTitle, type UseToggle, type UseUnmount, type UseUpdate, type UseWebNotification, type UseWebNotificationReturn, type UseWebNotificationShow, type UseWindowScroll, type UseWindowScrollState, type UseWindowSize, type UseWindowsFocus, defaultOptions, useActiveElement, useAsyncEffect, useClickOutside, useClipboard, useCookie, useCountDown, useCounter, useCssVar, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, useFps, useFullscreen, useGeolocation, useHover, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLocationSelector, useLongPress, useMeasure, useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnceEffect, useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScreenSafeArea, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, useUpdateLayoutEffect, useWebNotification, useWindowScroll, useWindowSize, useWindowsFocus };
|