@reactuses/core 1.0.1 → 1.0.3
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/LICENSE +24 -24
- package/README.md +81 -73
- package/index.cjs +152 -0
- package/index.d.ts +546 -445
- package/index.mjs +151 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -14,77 +14,82 @@ declare const _default$3: typeof useEffect | typeof react.useLayoutEffect;
|
|
|
14
14
|
|
|
15
15
|
declare const _default$2: typeof react.useEffect | typeof useLayoutEffect;
|
|
16
16
|
|
|
17
|
-
interface Serializer<T> {
|
|
18
|
-
read(raw: string): T;
|
|
19
|
-
write(value: T): string;
|
|
20
|
-
}
|
|
21
|
-
interface UseStorageOptions<T> {
|
|
22
|
-
/**
|
|
23
|
-
* Custom data serialization
|
|
24
|
-
*/
|
|
25
|
-
serializer?: Serializer<T>;
|
|
26
|
-
/**
|
|
27
|
-
* On error callback
|
|
28
|
-
*
|
|
29
|
-
* Default log error to `console.error`
|
|
30
|
-
*/
|
|
31
|
-
onError?: (error: unknown) => void;
|
|
17
|
+
interface Serializer<T> {
|
|
18
|
+
read(raw: string): T;
|
|
19
|
+
write(value: T): string;
|
|
20
|
+
}
|
|
21
|
+
interface UseStorageOptions<T> {
|
|
22
|
+
/**
|
|
23
|
+
* Custom data serialization
|
|
24
|
+
*/
|
|
25
|
+
serializer?: Serializer<T>;
|
|
26
|
+
/**
|
|
27
|
+
* On error callback
|
|
28
|
+
*
|
|
29
|
+
* Default log error to `console.error`
|
|
30
|
+
*/
|
|
31
|
+
onError?: (error: unknown) => void;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
declare function useLocalStorage(key: string, defaults: string, options?: UseStorageOptions<string>): readonly [string | null, Dispatch<SetStateAction<string | null>>];
|
|
35
|
-
declare function useLocalStorage(key: string, defaults: number, options?: UseStorageOptions<number>): readonly [number | null, Dispatch<SetStateAction<number | null>>];
|
|
36
|
-
declare function useLocalStorage(key: string, defaults: boolean, options?: UseStorageOptions<boolean>): readonly [boolean | null, Dispatch<SetStateAction<boolean | null>>];
|
|
37
|
-
declare function useLocalStorage<T>(key: string, defaults: T, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
34
|
+
declare function useLocalStorage(key: string, defaults: string, options?: UseStorageOptions<string>): readonly [string | null, Dispatch<SetStateAction<string | null>>];
|
|
35
|
+
declare function useLocalStorage(key: string, defaults: number, options?: UseStorageOptions<number>): readonly [number | null, Dispatch<SetStateAction<number | null>>];
|
|
36
|
+
declare function useLocalStorage(key: string, defaults: boolean, options?: UseStorageOptions<boolean>): readonly [boolean | null, Dispatch<SetStateAction<boolean | null>>];
|
|
37
|
+
declare function useLocalStorage<T>(key: string, defaults: T, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
38
38
|
declare function useLocalStorage<T = unknown>(key: string, defaults: null, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
39
39
|
|
|
40
|
-
declare function useSessionStorage(key: string, defaults: string, options?: UseStorageOptions<string>): readonly [string | null, Dispatch<SetStateAction<string | null>>];
|
|
41
|
-
declare function useSessionStorage(key: string, defaults: number, options?: UseStorageOptions<number>): readonly [number | null, Dispatch<SetStateAction<number | null>>];
|
|
42
|
-
declare function useSessionStorage(key: string, defaults: boolean, options?: UseStorageOptions<boolean>): readonly [boolean | null, Dispatch<SetStateAction<boolean | null>>];
|
|
43
|
-
declare function useSessionStorage<T>(key: string, defaults: T, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
40
|
+
declare function useSessionStorage(key: string, defaults: string, options?: UseStorageOptions<string>): readonly [string | null, Dispatch<SetStateAction<string | null>>];
|
|
41
|
+
declare function useSessionStorage(key: string, defaults: number, options?: UseStorageOptions<number>): readonly [number | null, Dispatch<SetStateAction<number | null>>];
|
|
42
|
+
declare function useSessionStorage(key: string, defaults: boolean, options?: UseStorageOptions<boolean>): readonly [boolean | null, Dispatch<SetStateAction<boolean | null>>];
|
|
43
|
+
declare function useSessionStorage<T>(key: string, defaults: T, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
44
44
|
declare function useSessionStorage<T = unknown>(key: string, defaults: null, options?: UseStorageOptions<T>): readonly [T | null, Dispatch<SetStateAction<T | null>>];
|
|
45
45
|
|
|
46
|
-
declare type Fn = (this: any, ...args: any[]) => any;
|
|
47
|
-
declare type Stoppable = [boolean, Fn, Fn];
|
|
46
|
+
declare type Fn = (this: any, ...args: any[]) => any;
|
|
47
|
+
declare type Stoppable = [boolean, Fn, Fn];
|
|
48
|
+
declare type PointerType = "mouse" | "touch" | "pen";
|
|
49
|
+
interface Position {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
}
|
|
48
53
|
|
|
49
54
|
declare function useEvent<T extends Fn>(fn: T): T;
|
|
50
55
|
|
|
51
56
|
declare function useToggle(initialValue: boolean): [boolean, (nextValue?: any) => void];
|
|
52
57
|
|
|
53
|
-
declare function useInterval(callback: () => void, delay?: number | null, options?: {
|
|
54
|
-
immediate?: boolean;
|
|
58
|
+
declare function useInterval(callback: () => void, delay?: number | null, options?: {
|
|
59
|
+
immediate?: boolean;
|
|
55
60
|
}): void;
|
|
56
61
|
|
|
57
|
-
interface UseDarkOptions<T> {
|
|
58
|
-
/**
|
|
59
|
-
* CSS Selector for the target element applying to
|
|
60
|
-
*
|
|
61
|
-
* @default 'html'
|
|
62
|
-
*/
|
|
63
|
-
selector?: string;
|
|
64
|
-
/**
|
|
65
|
-
* HTML attribute applying the target element
|
|
66
|
-
*
|
|
67
|
-
* @default 'class'
|
|
68
|
-
*/
|
|
69
|
-
attribute?: string;
|
|
70
|
-
/**
|
|
71
|
-
* The initial value write the target element
|
|
72
|
-
* @default 'light | dark'
|
|
73
|
-
*/
|
|
74
|
-
initialValue?: T;
|
|
75
|
-
/**
|
|
76
|
-
* Key to persist the data into localStorage/sessionStorage.
|
|
77
|
-
*
|
|
78
|
-
* @default 'reactuses-color-scheme'
|
|
79
|
-
*/
|
|
80
|
-
storageKey?: string;
|
|
81
|
-
/**
|
|
82
|
-
* Storage object, can be localStorage or sessionStorage
|
|
83
|
-
*
|
|
84
|
-
* @default localStorage
|
|
85
|
-
*/
|
|
86
|
-
storage?: () => Storage;
|
|
87
|
-
}
|
|
62
|
+
interface UseDarkOptions<T> {
|
|
63
|
+
/**
|
|
64
|
+
* CSS Selector for the target element applying to
|
|
65
|
+
*
|
|
66
|
+
* @default 'html'
|
|
67
|
+
*/
|
|
68
|
+
selector?: string;
|
|
69
|
+
/**
|
|
70
|
+
* HTML attribute applying the target element
|
|
71
|
+
*
|
|
72
|
+
* @default 'class'
|
|
73
|
+
*/
|
|
74
|
+
attribute?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The initial value write the target element
|
|
77
|
+
* @default 'light | dark'
|
|
78
|
+
*/
|
|
79
|
+
initialValue?: T;
|
|
80
|
+
/**
|
|
81
|
+
* Key to persist the data into localStorage/sessionStorage.
|
|
82
|
+
*
|
|
83
|
+
* @default 'reactuses-color-scheme'
|
|
84
|
+
*/
|
|
85
|
+
storageKey?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Storage object, can be localStorage or sessionStorage
|
|
88
|
+
*
|
|
89
|
+
* @default localStorage
|
|
90
|
+
*/
|
|
91
|
+
storage?: () => Storage;
|
|
92
|
+
}
|
|
88
93
|
declare function useDarkMode<T extends string | "light" | "dark">(options?: UseDarkOptions<T>): readonly [T | null, react.Dispatch<react.SetStateAction<T | null>>];
|
|
89
94
|
|
|
90
95
|
declare function useMediaQuery(query: string, defaultState?: boolean): boolean;
|
|
@@ -97,148 +102,148 @@ declare function useMount(fn: () => void): void;
|
|
|
97
102
|
|
|
98
103
|
declare function useUnmount(fn: () => void): void;
|
|
99
104
|
|
|
100
|
-
interface ThrottleSettings {
|
|
101
|
-
leading?: boolean | undefined;
|
|
102
|
-
trailing?: boolean | undefined;
|
|
103
|
-
}
|
|
104
|
-
interface DebounceSettings {
|
|
105
|
-
leading?: boolean;
|
|
106
|
-
trailing?: boolean;
|
|
107
|
-
maxWait?: number;
|
|
105
|
+
interface ThrottleSettings {
|
|
106
|
+
leading?: boolean | undefined;
|
|
107
|
+
trailing?: boolean | undefined;
|
|
108
|
+
}
|
|
109
|
+
interface DebounceSettings {
|
|
110
|
+
leading?: boolean;
|
|
111
|
+
trailing?: boolean;
|
|
112
|
+
maxWait?: number;
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
declare function useThrottle<T>(value: T, wait?: number, options?: ThrottleSettings): T;
|
|
111
116
|
|
|
112
|
-
declare function useThrottleFn<T extends (...args: any) => any>(fn: T, wait?: number, options?: ThrottleSettings): {
|
|
113
|
-
run: lodash.DebouncedFunc<(...args_0: Parameters<T>) => ReturnType<T>>;
|
|
114
|
-
cancel: () => void;
|
|
115
|
-
flush: () => ReturnType<T> | undefined;
|
|
117
|
+
declare function useThrottleFn<T extends (...args: any) => any>(fn: T, wait?: number, options?: ThrottleSettings): {
|
|
118
|
+
run: lodash.DebouncedFunc<(...args_0: Parameters<T>) => ReturnType<T>>;
|
|
119
|
+
cancel: () => void;
|
|
120
|
+
flush: () => ReturnType<T> | undefined;
|
|
116
121
|
};
|
|
117
122
|
|
|
118
123
|
declare function useDebounce<T>(value: T, wait?: number, options?: DebounceSettings): T;
|
|
119
124
|
|
|
120
|
-
declare function useDebounceFn<T extends (...args: any) => any>(fn: T, wait?: number, options?: DebounceSettings): {
|
|
121
|
-
run: lodash.DebouncedFunc<(...args_0: Parameters<T>) => ReturnType<T>>;
|
|
122
|
-
cancel: () => void;
|
|
123
|
-
flush: () => ReturnType<T> | undefined;
|
|
125
|
+
declare function useDebounceFn<T extends (...args: any) => any>(fn: T, wait?: number, options?: DebounceSettings): {
|
|
126
|
+
run: lodash.DebouncedFunc<(...args_0: Parameters<T>) => ReturnType<T>>;
|
|
127
|
+
cancel: () => void;
|
|
128
|
+
flush: () => ReturnType<T> | undefined;
|
|
124
129
|
};
|
|
125
130
|
|
|
126
131
|
declare function useRafState<S>(initialState: S | (() => S)): readonly [S, Dispatch<SetStateAction<S>>];
|
|
127
132
|
|
|
128
133
|
declare function useUpdate(): () => void;
|
|
129
134
|
|
|
130
|
-
interface UseTimeoutFnOptions {
|
|
131
|
-
/**
|
|
132
|
-
* Start the timer immediate after calling this function
|
|
133
|
-
*
|
|
134
|
-
* @default false
|
|
135
|
-
*/
|
|
136
|
-
immediate?: boolean;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Wrapper for `setTimeout` with controls.
|
|
140
|
-
*
|
|
141
|
-
* @param cb
|
|
142
|
-
* @param interval
|
|
143
|
-
* @param options
|
|
144
|
-
*/
|
|
135
|
+
interface UseTimeoutFnOptions {
|
|
136
|
+
/**
|
|
137
|
+
* Start the timer immediate after calling this function
|
|
138
|
+
*
|
|
139
|
+
* @default false
|
|
140
|
+
*/
|
|
141
|
+
immediate?: boolean;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Wrapper for `setTimeout` with controls.
|
|
145
|
+
*
|
|
146
|
+
* @param cb
|
|
147
|
+
* @param interval
|
|
148
|
+
* @param options
|
|
149
|
+
*/
|
|
145
150
|
declare function useTimeoutFn(cb: (...args: unknown[]) => any, interval: number, options?: UseTimeoutFnOptions): Stoppable;
|
|
146
151
|
|
|
147
152
|
declare function useTimeout(ms?: number, options?: UseTimeoutFnOptions): Stoppable;
|
|
148
153
|
|
|
149
154
|
declare function useMountedState(): () => boolean;
|
|
150
155
|
|
|
151
|
-
declare type TargetValue<T> = T | undefined | null;
|
|
152
|
-
declare type TargetType = HTMLElement | Element | Window | Document | EventTarget;
|
|
156
|
+
declare type TargetValue<T> = T | undefined | null;
|
|
157
|
+
declare type TargetType = HTMLElement | Element | Window | Document | EventTarget;
|
|
153
158
|
declare type BasicTarget<T extends TargetType = Element> = (() => TargetValue<T>) | TargetValue<T> | MutableRefObject<TargetValue<T>>;
|
|
154
159
|
|
|
155
|
-
declare type Target = BasicTarget<HTMLElement | Element | Window | Document | EventTarget>;
|
|
156
|
-
declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: Window, options?: boolean | AddEventListenerOptions): void;
|
|
157
|
-
declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: Document, options?: boolean | AddEventListenerOptions): void;
|
|
158
|
-
declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: T, options?: boolean | AddEventListenerOptions): void;
|
|
159
|
-
declare function useEventListener<K extends keyof ElementEventMap>(eventName: K, handler: (event: ElementEventMap[K]) => void, element: Element, options?: boolean | AddEventListenerOptions): void;
|
|
160
|
-
declare function useEventListener<K = Event>(eventName: string, handler: (event: K) => void, element: EventTarget | null | undefined, options?: boolean | AddEventListenerOptions): void;
|
|
160
|
+
declare type Target = BasicTarget<HTMLElement | Element | Window | Document | EventTarget>;
|
|
161
|
+
declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: Window, options?: boolean | AddEventListenerOptions): void;
|
|
162
|
+
declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: Document, options?: boolean | AddEventListenerOptions): void;
|
|
163
|
+
declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: T, options?: boolean | AddEventListenerOptions): void;
|
|
164
|
+
declare function useEventListener<K extends keyof ElementEventMap>(eventName: K, handler: (event: ElementEventMap[K]) => void, element: Element, options?: boolean | AddEventListenerOptions): void;
|
|
165
|
+
declare function useEventListener<K = Event>(eventName: string, handler: (event: K) => void, element: EventTarget | null | undefined, options?: boolean | AddEventListenerOptions): void;
|
|
161
166
|
declare function useEventListener(eventName: string, handler: (...p: any) => void, element?: Target, options?: boolean | AddEventListenerOptions): void;
|
|
162
167
|
|
|
163
168
|
declare function useCounter(initialValue?: number | (() => number), max?: number | null, min?: number | null): readonly [number, (newState: number | ((prev: number) => number) | (() => number)) => void, (delta?: number) => void, (delta?: number) => void, () => void];
|
|
164
169
|
|
|
165
|
-
declare type RafLoopReturns = readonly [() => void, () => void, () => boolean];
|
|
170
|
+
declare type RafLoopReturns = readonly [() => void, () => void, () => boolean];
|
|
166
171
|
declare function useRafFn(callback: FrameRequestCallback, initiallyActive?: boolean): RafLoopReturns;
|
|
167
172
|
|
|
168
|
-
interface IDisposable {
|
|
169
|
-
dispose(): void;
|
|
170
|
-
}
|
|
171
|
-
interface IEvent<T, U = void> {
|
|
172
|
-
(listener: (arg1: T, arg2: U) => any): IDisposable;
|
|
173
|
-
}
|
|
173
|
+
interface IDisposable {
|
|
174
|
+
dispose(): void;
|
|
175
|
+
}
|
|
176
|
+
interface IEvent<T, U = void> {
|
|
177
|
+
(listener: (arg1: T, arg2: U) => any): IDisposable;
|
|
178
|
+
}
|
|
174
179
|
declare function useEventEmitter<T, U = void>(): readonly [IEvent<T, U>, (arg1: T, arg2: U) => void, () => void];
|
|
175
180
|
|
|
176
181
|
declare function useFavicon(href: string, baseUrl?: string, rel?: string): void;
|
|
177
182
|
|
|
178
183
|
declare function useMutationObserver(callback: MutationCallback, target: BasicTarget, options?: MutationObserverInit): () => void;
|
|
179
184
|
|
|
180
|
-
declare type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
|
|
185
|
+
declare type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
|
|
181
186
|
declare function useCustomCompareEffect<TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>): void;
|
|
182
187
|
|
|
183
188
|
declare function useDeepCompareEffect(effect: EffectCallback, deps: DependencyList): void;
|
|
184
189
|
|
|
185
190
|
declare function useTitle(title: string): void;
|
|
186
191
|
|
|
187
|
-
interface UseScriptTagOptions {
|
|
188
|
-
/**
|
|
189
|
-
* Load the script immediately
|
|
190
|
-
*
|
|
191
|
-
* @default true
|
|
192
|
-
*/
|
|
193
|
-
immediate?: boolean;
|
|
194
|
-
/**
|
|
195
|
-
* Add `async` attribute to the script tag
|
|
196
|
-
*
|
|
197
|
-
* @default true
|
|
198
|
-
*/
|
|
199
|
-
async?: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* Script type
|
|
202
|
-
*
|
|
203
|
-
* @default 'text/javascript'
|
|
204
|
-
*/
|
|
205
|
-
type?: string;
|
|
206
|
-
/**
|
|
207
|
-
* Manual controls the timing of loading and unloading
|
|
208
|
-
*
|
|
209
|
-
* @default false
|
|
210
|
-
*/
|
|
211
|
-
manual?: boolean;
|
|
212
|
-
crossOrigin?: "anonymous" | "use-credentials";
|
|
213
|
-
referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
214
|
-
noModule?: boolean;
|
|
215
|
-
defer?: boolean;
|
|
216
|
-
/**
|
|
217
|
-
* Add custom attribute to the script tag
|
|
218
|
-
*
|
|
219
|
-
*/
|
|
220
|
-
attrs?: Record<string, string>;
|
|
221
|
-
}
|
|
222
|
-
declare type Status = "idle" | "loading" | "ready" | "error";
|
|
192
|
+
interface UseScriptTagOptions {
|
|
193
|
+
/**
|
|
194
|
+
* Load the script immediately
|
|
195
|
+
*
|
|
196
|
+
* @default true
|
|
197
|
+
*/
|
|
198
|
+
immediate?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Add `async` attribute to the script tag
|
|
201
|
+
*
|
|
202
|
+
* @default true
|
|
203
|
+
*/
|
|
204
|
+
async?: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Script type
|
|
207
|
+
*
|
|
208
|
+
* @default 'text/javascript'
|
|
209
|
+
*/
|
|
210
|
+
type?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Manual controls the timing of loading and unloading
|
|
213
|
+
*
|
|
214
|
+
* @default false
|
|
215
|
+
*/
|
|
216
|
+
manual?: boolean;
|
|
217
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
218
|
+
referrerPolicy?: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
219
|
+
noModule?: boolean;
|
|
220
|
+
defer?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Add custom attribute to the script tag
|
|
223
|
+
*
|
|
224
|
+
*/
|
|
225
|
+
attrs?: Record<string, string>;
|
|
226
|
+
}
|
|
227
|
+
declare type Status = "idle" | "loading" | "ready" | "error";
|
|
223
228
|
declare function useScriptTag(src: string, onLoaded?: (el: HTMLScriptElement) => void, options?: UseScriptTagOptions): readonly [HTMLScriptElement | null, Status, (waitForScriptLoad?: boolean) => Promise<HTMLScriptElement | boolean>, () => void];
|
|
224
229
|
|
|
225
|
-
declare type IState = PermissionState | "";
|
|
226
|
-
declare type DescriptorNamePolyfill = "accelerometer" | "accessibility-events" | "ambient-light-sensor" | "background-sync" | "camera" | "clipboard-read" | "clipboard-write" | "gyroscope" | "magnetometer" | "microphone" | "notifications" | "payment-handler" | "persistent-storage" | "push" | "speaker";
|
|
227
|
-
declare type GeneralPermissionDescriptor = PermissionDescriptor | {
|
|
228
|
-
name: DescriptorNamePolyfill;
|
|
229
|
-
};
|
|
230
|
+
declare type IState = PermissionState | "";
|
|
231
|
+
declare type DescriptorNamePolyfill = "accelerometer" | "accessibility-events" | "ambient-light-sensor" | "background-sync" | "camera" | "clipboard-read" | "clipboard-write" | "gyroscope" | "magnetometer" | "microphone" | "notifications" | "payment-handler" | "persistent-storage" | "push" | "speaker";
|
|
232
|
+
declare type GeneralPermissionDescriptor = PermissionDescriptor | {
|
|
233
|
+
name: DescriptorNamePolyfill;
|
|
234
|
+
};
|
|
230
235
|
declare function usePermission(permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor["name"]): IState;
|
|
231
236
|
|
|
232
|
-
interface Options$1 {
|
|
233
|
-
isPreventDefault?: boolean;
|
|
234
|
-
delay?: number;
|
|
235
|
-
}
|
|
236
|
-
declare function useLongPress(callback: (e: TouchEvent | MouseEvent) => void, { isPreventDefault, delay }?: Options$1): {
|
|
237
|
-
readonly onMouseDown: (e: any) => void;
|
|
238
|
-
readonly onTouchStart: (e: any) => void;
|
|
239
|
-
readonly onMouseUp: () => void;
|
|
240
|
-
readonly onMouseLeave: () => void;
|
|
241
|
-
readonly onTouchEnd: () => void;
|
|
237
|
+
interface Options$1 {
|
|
238
|
+
isPreventDefault?: boolean;
|
|
239
|
+
delay?: number;
|
|
240
|
+
}
|
|
241
|
+
declare function useLongPress(callback: (e: TouchEvent | MouseEvent) => void, { isPreventDefault, delay }?: Options$1): {
|
|
242
|
+
readonly onMouseDown: (e: any) => void;
|
|
243
|
+
readonly onTouchStart: (e: any) => void;
|
|
244
|
+
readonly onMouseUp: () => void;
|
|
245
|
+
readonly onMouseLeave: () => void;
|
|
246
|
+
readonly onTouchEnd: () => void;
|
|
242
247
|
};
|
|
243
248
|
|
|
244
249
|
declare function useObjectUrl(object: Blob | MediaSource | undefined): string | undefined;
|
|
@@ -247,135 +252,135 @@ declare function useIdle(ms?: number, initialState?: boolean, events?: (keyof Wi
|
|
|
247
252
|
|
|
248
253
|
declare const _default$1: () => {};
|
|
249
254
|
|
|
250
|
-
declare type UseTextDirectionValue = "ltr" | "rtl" | "auto";
|
|
251
|
-
interface UseTextDirectionOptions {
|
|
252
|
-
/**
|
|
253
|
-
* CSS Selector for the target element applying to
|
|
254
|
-
*
|
|
255
|
-
* @default 'html'
|
|
256
|
-
*/
|
|
257
|
-
selector?: string;
|
|
258
|
-
/**
|
|
259
|
-
* Initial value
|
|
260
|
-
*
|
|
261
|
-
* @default 'ltr'
|
|
262
|
-
*/
|
|
263
|
-
initialValue?: UseTextDirectionValue;
|
|
264
|
-
}
|
|
255
|
+
declare type UseTextDirectionValue = "ltr" | "rtl" | "auto";
|
|
256
|
+
interface UseTextDirectionOptions {
|
|
257
|
+
/**
|
|
258
|
+
* CSS Selector for the target element applying to
|
|
259
|
+
*
|
|
260
|
+
* @default 'html'
|
|
261
|
+
*/
|
|
262
|
+
selector?: string;
|
|
263
|
+
/**
|
|
264
|
+
* Initial value
|
|
265
|
+
*
|
|
266
|
+
* @default 'ltr'
|
|
267
|
+
*/
|
|
268
|
+
initialValue?: UseTextDirectionValue;
|
|
269
|
+
}
|
|
265
270
|
declare function useTextDirection(options?: UseTextDirectionOptions): readonly [UseTextDirectionValue, (value: UseTextDirectionValue) => void];
|
|
266
271
|
|
|
267
|
-
interface CursorState {
|
|
268
|
-
screenX: number;
|
|
269
|
-
screenY: number;
|
|
270
|
-
clientX: number;
|
|
271
|
-
clientY: number;
|
|
272
|
-
pageX: number;
|
|
273
|
-
pageY: number;
|
|
274
|
-
elementX: number;
|
|
275
|
-
elementY: number;
|
|
276
|
-
elementH: number;
|
|
277
|
-
elementW: number;
|
|
278
|
-
elementPosX: number;
|
|
279
|
-
elementPosY: number;
|
|
280
|
-
}
|
|
272
|
+
interface CursorState {
|
|
273
|
+
screenX: number;
|
|
274
|
+
screenY: number;
|
|
275
|
+
clientX: number;
|
|
276
|
+
clientY: number;
|
|
277
|
+
pageX: number;
|
|
278
|
+
pageY: number;
|
|
279
|
+
elementX: number;
|
|
280
|
+
elementY: number;
|
|
281
|
+
elementH: number;
|
|
282
|
+
elementW: number;
|
|
283
|
+
elementPosX: number;
|
|
284
|
+
elementPosY: number;
|
|
285
|
+
}
|
|
281
286
|
declare function useMouse(target?: BasicTarget): CursorState;
|
|
282
287
|
|
|
283
|
-
interface UseFpsOptions {
|
|
284
|
-
/**
|
|
285
|
-
* Calculate the FPS on every x frames.
|
|
286
|
-
* @default 10
|
|
287
|
-
*/
|
|
288
|
-
every?: number;
|
|
289
|
-
}
|
|
288
|
+
interface UseFpsOptions {
|
|
289
|
+
/**
|
|
290
|
+
* Calculate the FPS on every x frames.
|
|
291
|
+
* @default 10
|
|
292
|
+
*/
|
|
293
|
+
every?: number;
|
|
294
|
+
}
|
|
290
295
|
declare const _default: (options?: UseFpsOptions | undefined) => number;
|
|
291
296
|
|
|
292
|
-
declare function useGeolocation(options?: Partial<PositionOptions>): {
|
|
293
|
-
readonly coordinates: GeolocationCoordinates;
|
|
294
|
-
readonly locatedAt: number | null;
|
|
295
|
-
readonly error: GeolocationPositionError | null;
|
|
297
|
+
declare function useGeolocation(options?: Partial<PositionOptions>): {
|
|
298
|
+
readonly coordinates: GeolocationCoordinates;
|
|
299
|
+
readonly locatedAt: number | null;
|
|
300
|
+
readonly error: GeolocationPositionError | null;
|
|
296
301
|
};
|
|
297
302
|
|
|
298
|
-
interface Options {
|
|
299
|
-
onExit?: () => void;
|
|
300
|
-
onEnter?: () => void;
|
|
301
|
-
}
|
|
302
|
-
declare function useFullscreen(target: BasicTarget, options?: Options): readonly [boolean, {
|
|
303
|
-
readonly enterFullscreen: () => void;
|
|
304
|
-
readonly exitFullscreen: () => void;
|
|
305
|
-
readonly toggleFullscreen: () => void;
|
|
306
|
-
readonly isEnabled: true;
|
|
303
|
+
interface Options {
|
|
304
|
+
onExit?: () => void;
|
|
305
|
+
onEnter?: () => void;
|
|
306
|
+
}
|
|
307
|
+
declare function useFullscreen(target: BasicTarget, options?: Options): readonly [boolean, {
|
|
308
|
+
readonly enterFullscreen: () => void;
|
|
309
|
+
readonly exitFullscreen: () => void;
|
|
310
|
+
readonly toggleFullscreen: () => void;
|
|
311
|
+
readonly isEnabled: true;
|
|
307
312
|
}];
|
|
308
313
|
|
|
309
|
-
interface INetworkInformation extends EventTarget {
|
|
310
|
-
readonly downlink: number;
|
|
311
|
-
readonly downlinkMax: number;
|
|
312
|
-
readonly effectiveType: "slow-2g" | "2g" | "3g" | "4g";
|
|
313
|
-
readonly rtt: number;
|
|
314
|
-
readonly saveData: boolean;
|
|
315
|
-
readonly type: "bluetooth" | "cellular" | "ethernet" | "none" | "wifi" | "wimax" | "other" | "unknown";
|
|
316
|
-
onChange: (event: Event) => void;
|
|
317
|
-
}
|
|
318
|
-
interface IUseNetworkState {
|
|
319
|
-
/**
|
|
320
|
-
* @desc Whether browser connected to the network or not.
|
|
321
|
-
*/
|
|
322
|
-
online: boolean | undefined;
|
|
323
|
-
/**
|
|
324
|
-
* @desc Previous value of `online` property. Helps to identify if browser
|
|
325
|
-
* just connected or lost connection.
|
|
326
|
-
*/
|
|
327
|
-
previous: boolean | undefined;
|
|
328
|
-
/**
|
|
329
|
-
* @desc The {Date} object pointing to the moment when state change occurred.
|
|
330
|
-
*/
|
|
331
|
-
since: Date | undefined;
|
|
332
|
-
/**
|
|
333
|
-
* @desc Effective bandwidth estimate in megabits per second, rounded to the
|
|
334
|
-
* nearest multiple of 25 kilobits per seconds.
|
|
335
|
-
*/
|
|
336
|
-
downlink: INetworkInformation["downlink"] | undefined;
|
|
337
|
-
/**
|
|
338
|
-
* @desc Maximum downlink speed, in megabits per second (Mbps), for the
|
|
339
|
-
* underlying connection technology
|
|
340
|
-
*/
|
|
341
|
-
downlinkMax: INetworkInformation["downlinkMax"] | undefined;
|
|
342
|
-
/**
|
|
343
|
-
* @desc Effective type of the connection meaning one of 'slow-2g', '2g', '3g', or '4g'.
|
|
344
|
-
* This value is determined using a combination of recently observed round-trip time
|
|
345
|
-
* and downlink values.
|
|
346
|
-
*/
|
|
347
|
-
effectiveType: INetworkInformation["effectiveType"] | undefined;
|
|
348
|
-
/**
|
|
349
|
-
* @desc Estimated effective round-trip time of the current connection, rounded
|
|
350
|
-
* to the nearest multiple of 25 milliseconds
|
|
351
|
-
*/
|
|
352
|
-
rtt: INetworkInformation["rtt"] | undefined;
|
|
353
|
-
/**
|
|
354
|
-
* @desc {true} if the user has set a reduced data usage option on the user agent.
|
|
355
|
-
*/
|
|
356
|
-
saveData: INetworkInformation["saveData"] | undefined;
|
|
357
|
-
/**
|
|
358
|
-
* @desc The type of connection a device is using to communicate with the network.
|
|
359
|
-
* It will be one of the following values:
|
|
360
|
-
* - bluetooth
|
|
361
|
-
* - cellular
|
|
362
|
-
* - ethernet
|
|
363
|
-
* - none
|
|
364
|
-
* - wifi
|
|
365
|
-
* - wimax
|
|
366
|
-
* - other
|
|
367
|
-
* - unknown
|
|
368
|
-
*/
|
|
369
|
-
type: INetworkInformation["type"] | undefined;
|
|
370
|
-
}
|
|
314
|
+
interface INetworkInformation extends EventTarget {
|
|
315
|
+
readonly downlink: number;
|
|
316
|
+
readonly downlinkMax: number;
|
|
317
|
+
readonly effectiveType: "slow-2g" | "2g" | "3g" | "4g";
|
|
318
|
+
readonly rtt: number;
|
|
319
|
+
readonly saveData: boolean;
|
|
320
|
+
readonly type: "bluetooth" | "cellular" | "ethernet" | "none" | "wifi" | "wimax" | "other" | "unknown";
|
|
321
|
+
onChange: (event: Event) => void;
|
|
322
|
+
}
|
|
323
|
+
interface IUseNetworkState {
|
|
324
|
+
/**
|
|
325
|
+
* @desc Whether browser connected to the network or not.
|
|
326
|
+
*/
|
|
327
|
+
online: boolean | undefined;
|
|
328
|
+
/**
|
|
329
|
+
* @desc Previous value of `online` property. Helps to identify if browser
|
|
330
|
+
* just connected or lost connection.
|
|
331
|
+
*/
|
|
332
|
+
previous: boolean | undefined;
|
|
333
|
+
/**
|
|
334
|
+
* @desc The {Date} object pointing to the moment when state change occurred.
|
|
335
|
+
*/
|
|
336
|
+
since: Date | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* @desc Effective bandwidth estimate in megabits per second, rounded to the
|
|
339
|
+
* nearest multiple of 25 kilobits per seconds.
|
|
340
|
+
*/
|
|
341
|
+
downlink: INetworkInformation["downlink"] | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* @desc Maximum downlink speed, in megabits per second (Mbps), for the
|
|
344
|
+
* underlying connection technology
|
|
345
|
+
*/
|
|
346
|
+
downlinkMax: INetworkInformation["downlinkMax"] | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* @desc Effective type of the connection meaning one of 'slow-2g', '2g', '3g', or '4g'.
|
|
349
|
+
* This value is determined using a combination of recently observed round-trip time
|
|
350
|
+
* and downlink values.
|
|
351
|
+
*/
|
|
352
|
+
effectiveType: INetworkInformation["effectiveType"] | undefined;
|
|
353
|
+
/**
|
|
354
|
+
* @desc Estimated effective round-trip time of the current connection, rounded
|
|
355
|
+
* to the nearest multiple of 25 milliseconds
|
|
356
|
+
*/
|
|
357
|
+
rtt: INetworkInformation["rtt"] | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* @desc {true} if the user has set a reduced data usage option on the user agent.
|
|
360
|
+
*/
|
|
361
|
+
saveData: INetworkInformation["saveData"] | undefined;
|
|
362
|
+
/**
|
|
363
|
+
* @desc The type of connection a device is using to communicate with the network.
|
|
364
|
+
* It will be one of the following values:
|
|
365
|
+
* - bluetooth
|
|
366
|
+
* - cellular
|
|
367
|
+
* - ethernet
|
|
368
|
+
* - none
|
|
369
|
+
* - wifi
|
|
370
|
+
* - wimax
|
|
371
|
+
* - other
|
|
372
|
+
* - unknown
|
|
373
|
+
*/
|
|
374
|
+
type: INetworkInformation["type"] | undefined;
|
|
375
|
+
}
|
|
371
376
|
declare function useNetwork(): IUseNetworkState;
|
|
372
377
|
|
|
373
378
|
declare function useOnline(): boolean | undefined;
|
|
374
379
|
|
|
375
|
-
interface OrientationState {
|
|
376
|
-
angle: number;
|
|
377
|
-
type: string;
|
|
378
|
-
}
|
|
380
|
+
interface OrientationState {
|
|
381
|
+
angle: number;
|
|
382
|
+
type: string;
|
|
383
|
+
}
|
|
379
384
|
declare function useOrientation(initialState?: OrientationState): readonly [OrientationState, (type: OrientationLockType) => Promise<void> | undefined, () => void];
|
|
380
385
|
|
|
381
386
|
declare function useIntersectionObserver(target: BasicTarget, callback: IntersectionObserverCallback, options?: IntersectionObserverInit): () => void;
|
|
@@ -388,201 +393,297 @@ declare function useResizeObserver(target: BasicTarget, callback: ResizeObserver
|
|
|
388
393
|
|
|
389
394
|
declare function useDropZone(target: BasicTarget<HTMLElement>, onDrop?: (files: File[] | null) => void): boolean;
|
|
390
395
|
|
|
391
|
-
interface UseFileDialogOptions {
|
|
392
|
-
/**
|
|
393
|
-
* @default true
|
|
394
|
-
*/
|
|
395
|
-
multiple?: boolean;
|
|
396
|
-
/**
|
|
397
|
-
* @default '*'
|
|
398
|
-
*/
|
|
399
|
-
accept?: string;
|
|
400
|
-
/**
|
|
401
|
-
* Select the input source for the capture file.
|
|
402
|
-
* @see [HTMLInputElement Capture](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
|
403
|
-
*/
|
|
404
|
-
capture?: string;
|
|
405
|
-
}
|
|
406
|
-
declare function useFileDialog(options?: UseFileDialogOptions): readonly [
|
|
407
|
-
FileList | null,
|
|
408
|
-
(localOptions?: Partial<UseFileDialogOptions>) => void,
|
|
409
|
-
() => void
|
|
396
|
+
interface UseFileDialogOptions {
|
|
397
|
+
/**
|
|
398
|
+
* @default true
|
|
399
|
+
*/
|
|
400
|
+
multiple?: boolean;
|
|
401
|
+
/**
|
|
402
|
+
* @default '*'
|
|
403
|
+
*/
|
|
404
|
+
accept?: string;
|
|
405
|
+
/**
|
|
406
|
+
* Select the input source for the capture file.
|
|
407
|
+
* @see [HTMLInputElement Capture](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
|
408
|
+
*/
|
|
409
|
+
capture?: string;
|
|
410
|
+
}
|
|
411
|
+
declare function useFileDialog(options?: UseFileDialogOptions): readonly [
|
|
412
|
+
FileList | null,
|
|
413
|
+
(localOptions?: Partial<UseFileDialogOptions>) => void,
|
|
414
|
+
() => void
|
|
410
415
|
];
|
|
411
416
|
|
|
412
|
-
interface UseScrollOptions {
|
|
413
|
-
/**
|
|
414
|
-
* Throttle time for scroll event, it’s disabled by default.
|
|
415
|
-
*
|
|
416
|
-
* @default 0
|
|
417
|
-
*/
|
|
418
|
-
throttle?: number;
|
|
419
|
-
/**
|
|
420
|
-
* The check time when scrolling ends.
|
|
421
|
-
* This configuration will be setting to (throttle + idle) when the `throttle` is configured.
|
|
422
|
-
*
|
|
423
|
-
* @default 200
|
|
424
|
-
*/
|
|
425
|
-
idle?: number;
|
|
426
|
-
/**
|
|
427
|
-
* Offset arrived states by x pixels
|
|
428
|
-
*
|
|
429
|
-
*/
|
|
430
|
-
offset?: {
|
|
431
|
-
left?: number;
|
|
432
|
-
right?: number;
|
|
433
|
-
top?: number;
|
|
434
|
-
bottom?: number;
|
|
435
|
-
};
|
|
436
|
-
/**
|
|
437
|
-
* Trigger it when scrolling.
|
|
438
|
-
*
|
|
439
|
-
*/
|
|
440
|
-
onScroll?: (e: Event) => void;
|
|
441
|
-
/**
|
|
442
|
-
* Trigger it when scrolling ends.
|
|
443
|
-
*
|
|
444
|
-
*/
|
|
445
|
-
onStop?: (e: Event) => void;
|
|
446
|
-
/**
|
|
447
|
-
* Listener options for scroll event.
|
|
448
|
-
*
|
|
449
|
-
* @default {capture: false, passive: true}
|
|
450
|
-
*/
|
|
451
|
-
eventListenerOptions?: boolean | AddEventListenerOptions;
|
|
452
|
-
}
|
|
453
|
-
declare function useScroll(target: BasicTarget<HTMLElement | SVGElement | Window | Document>, options?: UseScrollOptions): readonly [
|
|
454
|
-
number,
|
|
455
|
-
number,
|
|
456
|
-
boolean,
|
|
457
|
-
{
|
|
458
|
-
left: boolean;
|
|
459
|
-
right: boolean;
|
|
460
|
-
top: boolean;
|
|
461
|
-
bottom: boolean;
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
left: boolean;
|
|
465
|
-
right: boolean;
|
|
466
|
-
top: boolean;
|
|
467
|
-
bottom: boolean;
|
|
468
|
-
}
|
|
417
|
+
interface UseScrollOptions {
|
|
418
|
+
/**
|
|
419
|
+
* Throttle time for scroll event, it’s disabled by default.
|
|
420
|
+
*
|
|
421
|
+
* @default 0
|
|
422
|
+
*/
|
|
423
|
+
throttle?: number;
|
|
424
|
+
/**
|
|
425
|
+
* The check time when scrolling ends.
|
|
426
|
+
* This configuration will be setting to (throttle + idle) when the `throttle` is configured.
|
|
427
|
+
*
|
|
428
|
+
* @default 200
|
|
429
|
+
*/
|
|
430
|
+
idle?: number;
|
|
431
|
+
/**
|
|
432
|
+
* Offset arrived states by x pixels
|
|
433
|
+
*
|
|
434
|
+
*/
|
|
435
|
+
offset?: {
|
|
436
|
+
left?: number;
|
|
437
|
+
right?: number;
|
|
438
|
+
top?: number;
|
|
439
|
+
bottom?: number;
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Trigger it when scrolling.
|
|
443
|
+
*
|
|
444
|
+
*/
|
|
445
|
+
onScroll?: (e: Event) => void;
|
|
446
|
+
/**
|
|
447
|
+
* Trigger it when scrolling ends.
|
|
448
|
+
*
|
|
449
|
+
*/
|
|
450
|
+
onStop?: (e: Event) => void;
|
|
451
|
+
/**
|
|
452
|
+
* Listener options for scroll event.
|
|
453
|
+
*
|
|
454
|
+
* @default {capture: false, passive: true}
|
|
455
|
+
*/
|
|
456
|
+
eventListenerOptions?: boolean | AddEventListenerOptions;
|
|
457
|
+
}
|
|
458
|
+
declare function useScroll(target: BasicTarget<HTMLElement | SVGElement | Window | Document>, options?: UseScrollOptions): readonly [
|
|
459
|
+
number,
|
|
460
|
+
number,
|
|
461
|
+
boolean,
|
|
462
|
+
{
|
|
463
|
+
left: boolean;
|
|
464
|
+
right: boolean;
|
|
465
|
+
top: boolean;
|
|
466
|
+
bottom: boolean;
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
left: boolean;
|
|
470
|
+
right: boolean;
|
|
471
|
+
top: boolean;
|
|
472
|
+
bottom: boolean;
|
|
473
|
+
}
|
|
469
474
|
];
|
|
470
475
|
|
|
471
|
-
interface UseInfiniteScrollOptions extends UseScrollOptions {
|
|
472
|
-
/**
|
|
473
|
-
* The minimum distance between the bottom of the element and the bottom of the viewport
|
|
474
|
-
*
|
|
475
|
-
* @default 0
|
|
476
|
-
*/
|
|
477
|
-
distance?: number;
|
|
478
|
-
/**
|
|
479
|
-
* The direction in which to listen the scroll.
|
|
480
|
-
*
|
|
481
|
-
* @default 'bottom'
|
|
482
|
-
*/
|
|
483
|
-
direction?: "top" | "bottom" | "left" | "right";
|
|
484
|
-
/**
|
|
485
|
-
* Whether to preserve the current scroll position when loading more items.
|
|
486
|
-
*
|
|
487
|
-
* @default false
|
|
488
|
-
*/
|
|
489
|
-
preserveScrollPosition?: boolean;
|
|
490
|
-
}
|
|
476
|
+
interface UseInfiniteScrollOptions extends UseScrollOptions {
|
|
477
|
+
/**
|
|
478
|
+
* The minimum distance between the bottom of the element and the bottom of the viewport
|
|
479
|
+
*
|
|
480
|
+
* @default 0
|
|
481
|
+
*/
|
|
482
|
+
distance?: number;
|
|
483
|
+
/**
|
|
484
|
+
* The direction in which to listen the scroll.
|
|
485
|
+
*
|
|
486
|
+
* @default 'bottom'
|
|
487
|
+
*/
|
|
488
|
+
direction?: "top" | "bottom" | "left" | "right";
|
|
489
|
+
/**
|
|
490
|
+
* Whether to preserve the current scroll position when loading more items.
|
|
491
|
+
*
|
|
492
|
+
* @default false
|
|
493
|
+
*/
|
|
494
|
+
preserveScrollPosition?: boolean;
|
|
495
|
+
}
|
|
491
496
|
declare function useInfiniteScroll(target: BasicTarget<HTMLElement | SVGElement | Window | Document>, onLoadMore: (state: ReturnType<typeof useScroll>) => void | Promise<void>, options?: UseInfiniteScrollOptions): void;
|
|
492
497
|
|
|
493
|
-
declare type KeyModifier = "Alt" | "AltGraph" | "CapsLock" | "Control" | "Fn" | "FnLock" | "Meta" | "NumLock" | "ScrollLock" | "Shift" | "Symbol" | "SymbolLock";
|
|
494
|
-
interface UseModifierOptions {
|
|
495
|
-
/**
|
|
496
|
-
* Event names that will prompt update to modifier states
|
|
497
|
-
*
|
|
498
|
-
* @default ['mousedown', 'mouseup', 'keydown', 'keyup']
|
|
499
|
-
*/
|
|
500
|
-
events?: (keyof WindowEventMap)[];
|
|
501
|
-
/**
|
|
502
|
-
* Initial value of the returned ref
|
|
503
|
-
*
|
|
504
|
-
* @default false
|
|
505
|
-
*/
|
|
506
|
-
initial?: boolean;
|
|
507
|
-
}
|
|
498
|
+
declare type KeyModifier = "Alt" | "AltGraph" | "CapsLock" | "Control" | "Fn" | "FnLock" | "Meta" | "NumLock" | "ScrollLock" | "Shift" | "Symbol" | "SymbolLock";
|
|
499
|
+
interface UseModifierOptions {
|
|
500
|
+
/**
|
|
501
|
+
* Event names that will prompt update to modifier states
|
|
502
|
+
*
|
|
503
|
+
* @default ['mousedown', 'mouseup', 'keydown', 'keyup']
|
|
504
|
+
*/
|
|
505
|
+
events?: (keyof WindowEventMap)[];
|
|
506
|
+
/**
|
|
507
|
+
* Initial value of the returned ref
|
|
508
|
+
*
|
|
509
|
+
* @default false
|
|
510
|
+
*/
|
|
511
|
+
initial?: boolean;
|
|
512
|
+
}
|
|
508
513
|
declare function useKeyModifier(modifier: KeyModifier, options?: UseModifierOptions): boolean;
|
|
509
514
|
|
|
510
|
-
declare type IHookStateInitialSetter<S> = () => S;
|
|
515
|
+
declare type IHookStateInitialSetter<S> = () => S;
|
|
511
516
|
declare type IHookStateInitAction<S> = S | IHookStateInitialSetter<S>;
|
|
512
517
|
|
|
513
|
-
interface MousePressedOptions {
|
|
514
|
-
/**
|
|
515
|
-
* Listen to `touchstart` `touchend` events
|
|
516
|
-
*
|
|
517
|
-
* @default true
|
|
518
|
-
*/
|
|
519
|
-
touch?: boolean;
|
|
520
|
-
/**
|
|
521
|
-
* Listen to `dragstart` `drop` and `dragend` events
|
|
522
|
-
*
|
|
523
|
-
* @default true
|
|
524
|
-
*/
|
|
525
|
-
drag?: boolean;
|
|
526
|
-
/**
|
|
527
|
-
* Initial values
|
|
528
|
-
*
|
|
529
|
-
* @default false
|
|
530
|
-
*/
|
|
531
|
-
initialValue?: IHookStateInitAction<boolean>;
|
|
532
|
-
}
|
|
533
|
-
declare type MouseSourceType = "mouse" | "touch" | null;
|
|
518
|
+
interface MousePressedOptions {
|
|
519
|
+
/**
|
|
520
|
+
* Listen to `touchstart` `touchend` events
|
|
521
|
+
*
|
|
522
|
+
* @default true
|
|
523
|
+
*/
|
|
524
|
+
touch?: boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Listen to `dragstart` `drop` and `dragend` events
|
|
527
|
+
*
|
|
528
|
+
* @default true
|
|
529
|
+
*/
|
|
530
|
+
drag?: boolean;
|
|
531
|
+
/**
|
|
532
|
+
* Initial values
|
|
533
|
+
*
|
|
534
|
+
* @default false
|
|
535
|
+
*/
|
|
536
|
+
initialValue?: IHookStateInitAction<boolean>;
|
|
537
|
+
}
|
|
538
|
+
declare type MouseSourceType = "mouse" | "touch" | null;
|
|
534
539
|
declare function useMousePressed(target?: BasicTarget, options?: MousePressedOptions): readonly [boolean, MouseSourceType];
|
|
535
540
|
|
|
536
541
|
declare function useScrollLock(target: BasicTarget<HTMLElement | SVGElement | Window | Document>, initialState?: boolean): readonly [boolean, (flag: boolean) => void];
|
|
537
542
|
|
|
538
543
|
declare function useElementSize(target: BasicTarget, options?: ResizeObserverOptions): readonly [number, number];
|
|
539
544
|
|
|
540
|
-
interface UseVirtualListOptions {
|
|
541
|
-
/**
|
|
542
|
-
* container default height
|
|
543
|
-
*
|
|
544
|
-
* @default 300
|
|
545
|
-
*/
|
|
546
|
-
containerHeight?: number;
|
|
547
|
-
/**
|
|
548
|
-
* item height, accept a pixel value or a function that returns the height
|
|
549
|
-
*/
|
|
550
|
-
itemHeight: number | ((index: number) => number);
|
|
551
|
-
/**
|
|
552
|
-
* the extra buffer items outside of the view area
|
|
553
|
-
*
|
|
554
|
-
* @default 5
|
|
555
|
-
*/
|
|
556
|
-
overscan?: number;
|
|
557
|
-
}
|
|
558
|
-
interface UseVirtualListItem<T> {
|
|
559
|
-
data: T;
|
|
560
|
-
index: number;
|
|
561
|
-
}
|
|
562
|
-
interface UseVirtualListReturn<T> {
|
|
563
|
-
list: UseVirtualListItem<T>[];
|
|
564
|
-
scrollTo: (index: number) => void;
|
|
565
|
-
containerProps: {
|
|
566
|
-
ref: RefObject<any>;
|
|
567
|
-
onScroll: () => void;
|
|
568
|
-
style: Partial<CSSProperties>;
|
|
569
|
-
};
|
|
570
|
-
wrapperProps: {
|
|
571
|
-
style: {
|
|
572
|
-
width: string;
|
|
573
|
-
height: string;
|
|
574
|
-
marginTop: string;
|
|
575
|
-
};
|
|
576
|
-
};
|
|
577
|
-
}
|
|
545
|
+
interface UseVirtualListOptions {
|
|
546
|
+
/**
|
|
547
|
+
* container default height
|
|
548
|
+
*
|
|
549
|
+
* @default 300
|
|
550
|
+
*/
|
|
551
|
+
containerHeight?: number;
|
|
552
|
+
/**
|
|
553
|
+
* item height, accept a pixel value or a function that returns the height
|
|
554
|
+
*/
|
|
555
|
+
itemHeight: number | ((index: number) => number);
|
|
556
|
+
/**
|
|
557
|
+
* the extra buffer items outside of the view area
|
|
558
|
+
*
|
|
559
|
+
* @default 5
|
|
560
|
+
*/
|
|
561
|
+
overscan?: number;
|
|
562
|
+
}
|
|
563
|
+
interface UseVirtualListItem<T> {
|
|
564
|
+
data: T;
|
|
565
|
+
index: number;
|
|
566
|
+
}
|
|
567
|
+
interface UseVirtualListReturn<T> {
|
|
568
|
+
list: UseVirtualListItem<T>[];
|
|
569
|
+
scrollTo: (index: number) => void;
|
|
570
|
+
containerProps: {
|
|
571
|
+
ref: RefObject<any>;
|
|
572
|
+
onScroll: () => void;
|
|
573
|
+
style: Partial<CSSProperties>;
|
|
574
|
+
};
|
|
575
|
+
wrapperProps: {
|
|
576
|
+
style: {
|
|
577
|
+
width: string;
|
|
578
|
+
height: string;
|
|
579
|
+
marginTop: string;
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
}
|
|
578
583
|
declare function useVirtualList<T = any>(list: T[] | undefined, options: UseVirtualListOptions): UseVirtualListReturn<T>;
|
|
579
584
|
|
|
580
|
-
declare type ColorScheme = "dark" | "light" | "no-preference";
|
|
585
|
+
declare type ColorScheme = "dark" | "light" | "no-preference";
|
|
581
586
|
declare function usePreferredColorScheme(defaultState?: ColorScheme): ColorScheme;
|
|
582
587
|
|
|
583
|
-
declare type Contrast = "more" | "less" | "custom" | "no-preference";
|
|
588
|
+
declare type Contrast = "more" | "less" | "custom" | "no-preference";
|
|
584
589
|
declare function usePreferredContrast(defaultState?: Contrast): Contrast;
|
|
585
590
|
|
|
586
591
|
declare function useActiveElement<T extends Element>(): T | null;
|
|
587
592
|
|
|
588
|
-
|
|
593
|
+
interface UseDraggableOptions {
|
|
594
|
+
/**
|
|
595
|
+
* Only start the dragging when click on the element directly
|
|
596
|
+
*
|
|
597
|
+
* @default false
|
|
598
|
+
*/
|
|
599
|
+
exact?: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* Prevent events defaults
|
|
602
|
+
*
|
|
603
|
+
* @default false
|
|
604
|
+
*/
|
|
605
|
+
preventDefault?: boolean;
|
|
606
|
+
/**
|
|
607
|
+
* Prevent events propagation
|
|
608
|
+
*
|
|
609
|
+
* @default false
|
|
610
|
+
*/
|
|
611
|
+
stopPropagation?: boolean;
|
|
612
|
+
/**
|
|
613
|
+
* Element to attach `pointermove` and `pointerup` events to.
|
|
614
|
+
*
|
|
615
|
+
* @default window
|
|
616
|
+
*/
|
|
617
|
+
draggingElement?: BasicTarget<HTMLElement | SVGElement | Window | Document>;
|
|
618
|
+
/**
|
|
619
|
+
* Handle that triggers the drag event
|
|
620
|
+
*
|
|
621
|
+
* @default target
|
|
622
|
+
*/
|
|
623
|
+
handle?: BasicTarget<HTMLElement | SVGElement>;
|
|
624
|
+
/**
|
|
625
|
+
* Pointer types that listen to.
|
|
626
|
+
*
|
|
627
|
+
* @default ['mouse', 'touch', 'pen']
|
|
628
|
+
*/
|
|
629
|
+
pointerTypes?: PointerType[];
|
|
630
|
+
/**
|
|
631
|
+
* Initial position of the element.
|
|
632
|
+
*
|
|
633
|
+
* @default { x: 0, y: 0 }
|
|
634
|
+
*/
|
|
635
|
+
initialValue?: Position;
|
|
636
|
+
/**
|
|
637
|
+
* Callback when the dragging starts. Return `false` to prevent dragging.
|
|
638
|
+
*/
|
|
639
|
+
onStart?: (position: Position, event: PointerEvent) => void | false;
|
|
640
|
+
/**
|
|
641
|
+
* Callback during dragging.
|
|
642
|
+
*/
|
|
643
|
+
onMove?: (position: Position, event: PointerEvent) => void;
|
|
644
|
+
/**
|
|
645
|
+
* Callback when dragging end.
|
|
646
|
+
*/
|
|
647
|
+
onEnd?: (position: Position, event: PointerEvent) => void;
|
|
648
|
+
}
|
|
649
|
+
declare function useDraggable(target: BasicTarget<HTMLElement | SVGElement>, options?: UseDraggableOptions): readonly [number, number, boolean];
|
|
650
|
+
|
|
651
|
+
interface UseElementBoundingOptions {
|
|
652
|
+
/**
|
|
653
|
+
* Reset values to 0 on component unmounted
|
|
654
|
+
*
|
|
655
|
+
* @default true
|
|
656
|
+
*/
|
|
657
|
+
reset?: boolean;
|
|
658
|
+
/**
|
|
659
|
+
* Listen to window resize event
|
|
660
|
+
*
|
|
661
|
+
* @default true
|
|
662
|
+
*/
|
|
663
|
+
windowResize?: boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Listen to window scroll event
|
|
666
|
+
*
|
|
667
|
+
* @default true
|
|
668
|
+
*/
|
|
669
|
+
windowScroll?: boolean;
|
|
670
|
+
/**
|
|
671
|
+
* Immediately call update on component mounted
|
|
672
|
+
*
|
|
673
|
+
* @default true
|
|
674
|
+
*/
|
|
675
|
+
immediate?: boolean;
|
|
676
|
+
}
|
|
677
|
+
declare function useElementBounding(target: BasicTarget, options?: UseElementBoundingOptions): {
|
|
678
|
+
readonly height: number;
|
|
679
|
+
readonly bottom: number;
|
|
680
|
+
readonly left: number;
|
|
681
|
+
readonly right: number;
|
|
682
|
+
readonly top: number;
|
|
683
|
+
readonly width: number;
|
|
684
|
+
readonly x: number;
|
|
685
|
+
readonly y: number;
|
|
686
|
+
readonly update: () => void;
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
export { useActiveElement, useCounter, useCustomCompareEffect, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementSize, useEvent, useEventEmitter, useEventListener, useFavicon, useFileDialog, useFirstMountState, _default as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMarkdown, _default$1 as useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useResizeObserver, useScriptTag, useScroll, useScrollLock, useSessionStorage, useTextDirection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, _default$3 as useUpdateEffect, _default$2 as useUpdateLayoutEffect, useVirtualList };
|