@reactuses/core 1.0.2 → 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 +76 -0
- package/index.d.ts +543 -505
- package/index.mjs +76 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -14,82 +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];
|
|
48
|
-
declare type PointerType = "mouse" | "touch" | "pen";
|
|
49
|
-
interface Position {
|
|
50
|
-
x: number;
|
|
51
|
-
y: number;
|
|
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
52
|
}
|
|
53
53
|
|
|
54
54
|
declare function useEvent<T extends Fn>(fn: T): T;
|
|
55
55
|
|
|
56
56
|
declare function useToggle(initialValue: boolean): [boolean, (nextValue?: any) => void];
|
|
57
57
|
|
|
58
|
-
declare function useInterval(callback: () => void, delay?: number | null, options?: {
|
|
59
|
-
immediate?: boolean;
|
|
58
|
+
declare function useInterval(callback: () => void, delay?: number | null, options?: {
|
|
59
|
+
immediate?: boolean;
|
|
60
60
|
}): void;
|
|
61
61
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
93
93
|
declare function useDarkMode<T extends string | "light" | "dark">(options?: UseDarkOptions<T>): readonly [T | null, react.Dispatch<react.SetStateAction<T | null>>];
|
|
94
94
|
|
|
95
95
|
declare function useMediaQuery(query: string, defaultState?: boolean): boolean;
|
|
@@ -102,148 +102,148 @@ declare function useMount(fn: () => void): void;
|
|
|
102
102
|
|
|
103
103
|
declare function useUnmount(fn: () => void): void;
|
|
104
104
|
|
|
105
|
-
interface ThrottleSettings {
|
|
106
|
-
leading?: boolean | undefined;
|
|
107
|
-
trailing?: boolean | undefined;
|
|
108
|
-
}
|
|
109
|
-
interface DebounceSettings {
|
|
110
|
-
leading?: boolean;
|
|
111
|
-
trailing?: boolean;
|
|
112
|
-
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;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
declare function useThrottle<T>(value: T, wait?: number, options?: ThrottleSettings): T;
|
|
116
116
|
|
|
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;
|
|
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;
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
declare function useDebounce<T>(value: T, wait?: number, options?: DebounceSettings): T;
|
|
124
124
|
|
|
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;
|
|
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;
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
declare function useRafState<S>(initialState: S | (() => S)): readonly [S, Dispatch<SetStateAction<S>>];
|
|
132
132
|
|
|
133
133
|
declare function useUpdate(): () => void;
|
|
134
134
|
|
|
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
|
-
*/
|
|
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
|
+
*/
|
|
150
150
|
declare function useTimeoutFn(cb: (...args: unknown[]) => any, interval: number, options?: UseTimeoutFnOptions): Stoppable;
|
|
151
151
|
|
|
152
152
|
declare function useTimeout(ms?: number, options?: UseTimeoutFnOptions): Stoppable;
|
|
153
153
|
|
|
154
154
|
declare function useMountedState(): () => boolean;
|
|
155
155
|
|
|
156
|
-
declare type TargetValue<T> = T | undefined | null;
|
|
157
|
-
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;
|
|
158
158
|
declare type BasicTarget<T extends TargetType = Element> = (() => TargetValue<T>) | TargetValue<T> | MutableRefObject<TargetValue<T>>;
|
|
159
159
|
|
|
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;
|
|
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;
|
|
166
166
|
declare function useEventListener(eventName: string, handler: (...p: any) => void, element?: Target, options?: boolean | AddEventListenerOptions): void;
|
|
167
167
|
|
|
168
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];
|
|
169
169
|
|
|
170
|
-
declare type RafLoopReturns = readonly [() => void, () => void, () => boolean];
|
|
170
|
+
declare type RafLoopReturns = readonly [() => void, () => void, () => boolean];
|
|
171
171
|
declare function useRafFn(callback: FrameRequestCallback, initiallyActive?: boolean): RafLoopReturns;
|
|
172
172
|
|
|
173
|
-
interface IDisposable {
|
|
174
|
-
dispose(): void;
|
|
175
|
-
}
|
|
176
|
-
interface IEvent<T, U = void> {
|
|
177
|
-
(listener: (arg1: T, arg2: U) => any): IDisposable;
|
|
178
|
-
}
|
|
173
|
+
interface IDisposable {
|
|
174
|
+
dispose(): void;
|
|
175
|
+
}
|
|
176
|
+
interface IEvent<T, U = void> {
|
|
177
|
+
(listener: (arg1: T, arg2: U) => any): IDisposable;
|
|
178
|
+
}
|
|
179
179
|
declare function useEventEmitter<T, U = void>(): readonly [IEvent<T, U>, (arg1: T, arg2: U) => void, () => void];
|
|
180
180
|
|
|
181
181
|
declare function useFavicon(href: string, baseUrl?: string, rel?: string): void;
|
|
182
182
|
|
|
183
183
|
declare function useMutationObserver(callback: MutationCallback, target: BasicTarget, options?: MutationObserverInit): () => void;
|
|
184
184
|
|
|
185
|
-
declare type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
|
|
185
|
+
declare type DepsEqualFnType<TDeps extends DependencyList> = (prevDeps: TDeps, nextDeps: TDeps) => boolean;
|
|
186
186
|
declare function useCustomCompareEffect<TDeps extends DependencyList>(effect: EffectCallback, deps: TDeps, depsEqual: DepsEqualFnType<TDeps>): void;
|
|
187
187
|
|
|
188
188
|
declare function useDeepCompareEffect(effect: EffectCallback, deps: DependencyList): void;
|
|
189
189
|
|
|
190
190
|
declare function useTitle(title: string): void;
|
|
191
191
|
|
|
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";
|
|
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";
|
|
228
228
|
declare function useScriptTag(src: string, onLoaded?: (el: HTMLScriptElement) => void, options?: UseScriptTagOptions): readonly [HTMLScriptElement | null, Status, (waitForScriptLoad?: boolean) => Promise<HTMLScriptElement | boolean>, () => void];
|
|
229
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
|
+
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
|
+
};
|
|
235
235
|
declare function usePermission(permissionDesc: GeneralPermissionDescriptor | GeneralPermissionDescriptor["name"]): IState;
|
|
236
236
|
|
|
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;
|
|
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;
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
declare function useObjectUrl(object: Blob | MediaSource | undefined): string | undefined;
|
|
@@ -252,135 +252,135 @@ declare function useIdle(ms?: number, initialState?: boolean, events?: (keyof Wi
|
|
|
252
252
|
|
|
253
253
|
declare const _default$1: () => {};
|
|
254
254
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
270
270
|
declare function useTextDirection(options?: UseTextDirectionOptions): readonly [UseTextDirectionValue, (value: UseTextDirectionValue) => void];
|
|
271
271
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
286
286
|
declare function useMouse(target?: BasicTarget): CursorState;
|
|
287
287
|
|
|
288
|
-
interface UseFpsOptions {
|
|
289
|
-
/**
|
|
290
|
-
* Calculate the FPS on every x frames.
|
|
291
|
-
* @default 10
|
|
292
|
-
*/
|
|
293
|
-
every?: number;
|
|
294
|
-
}
|
|
288
|
+
interface UseFpsOptions {
|
|
289
|
+
/**
|
|
290
|
+
* Calculate the FPS on every x frames.
|
|
291
|
+
* @default 10
|
|
292
|
+
*/
|
|
293
|
+
every?: number;
|
|
294
|
+
}
|
|
295
295
|
declare const _default: (options?: UseFpsOptions | undefined) => number;
|
|
296
296
|
|
|
297
|
-
declare function useGeolocation(options?: Partial<PositionOptions>): {
|
|
298
|
-
readonly coordinates: GeolocationCoordinates;
|
|
299
|
-
readonly locatedAt: number | null;
|
|
300
|
-
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;
|
|
301
301
|
};
|
|
302
302
|
|
|
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;
|
|
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;
|
|
312
312
|
}];
|
|
313
313
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
376
376
|
declare function useNetwork(): IUseNetworkState;
|
|
377
377
|
|
|
378
378
|
declare function useOnline(): boolean | undefined;
|
|
379
379
|
|
|
380
|
-
interface OrientationState {
|
|
381
|
-
angle: number;
|
|
382
|
-
type: string;
|
|
383
|
-
}
|
|
380
|
+
interface OrientationState {
|
|
381
|
+
angle: number;
|
|
382
|
+
type: string;
|
|
383
|
+
}
|
|
384
384
|
declare function useOrientation(initialState?: OrientationState): readonly [OrientationState, (type: OrientationLockType) => Promise<void> | undefined, () => void];
|
|
385
385
|
|
|
386
386
|
declare function useIntersectionObserver(target: BasicTarget, callback: IntersectionObserverCallback, options?: IntersectionObserverInit): () => void;
|
|
@@ -393,259 +393,297 @@ declare function useResizeObserver(target: BasicTarget, callback: ResizeObserver
|
|
|
393
393
|
|
|
394
394
|
declare function useDropZone(target: BasicTarget<HTMLElement>, onDrop?: (files: File[] | null) => void): boolean;
|
|
395
395
|
|
|
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
|
|
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
|
|
415
415
|
];
|
|
416
416
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
474
474
|
];
|
|
475
475
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
496
496
|
declare function useInfiniteScroll(target: BasicTarget<HTMLElement | SVGElement | Window | Document>, onLoadMore: (state: ReturnType<typeof useScroll>) => void | Promise<void>, options?: UseInfiniteScrollOptions): void;
|
|
497
497
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
513
513
|
declare function useKeyModifier(modifier: KeyModifier, options?: UseModifierOptions): boolean;
|
|
514
514
|
|
|
515
|
-
declare type IHookStateInitialSetter<S> = () => S;
|
|
515
|
+
declare type IHookStateInitialSetter<S> = () => S;
|
|
516
516
|
declare type IHookStateInitAction<S> = S | IHookStateInitialSetter<S>;
|
|
517
517
|
|
|
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;
|
|
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;
|
|
539
539
|
declare function useMousePressed(target?: BasicTarget, options?: MousePressedOptions): readonly [boolean, MouseSourceType];
|
|
540
540
|
|
|
541
541
|
declare function useScrollLock(target: BasicTarget<HTMLElement | SVGElement | Window | Document>, initialState?: boolean): readonly [boolean, (flag: boolean) => void];
|
|
542
542
|
|
|
543
543
|
declare function useElementSize(target: BasicTarget, options?: ResizeObserverOptions): readonly [number, number];
|
|
544
544
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
583
583
|
declare function useVirtualList<T = any>(list: T[] | undefined, options: UseVirtualListOptions): UseVirtualListReturn<T>;
|
|
584
584
|
|
|
585
|
-
declare type ColorScheme = "dark" | "light" | "no-preference";
|
|
585
|
+
declare type ColorScheme = "dark" | "light" | "no-preference";
|
|
586
586
|
declare function usePreferredColorScheme(defaultState?: ColorScheme): ColorScheme;
|
|
587
587
|
|
|
588
|
-
declare type Contrast = "more" | "less" | "custom" | "no-preference";
|
|
588
|
+
declare type Contrast = "more" | "less" | "custom" | "no-preference";
|
|
589
589
|
declare function usePreferredContrast(defaultState?: Contrast): Contrast;
|
|
590
590
|
|
|
591
591
|
declare function useActiveElement<T extends Element>(): T | null;
|
|
592
592
|
|
|
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
|
-
}
|
|
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
649
|
declare function useDraggable(target: BasicTarget<HTMLElement | SVGElement>, options?: UseDraggableOptions): readonly [number, number, boolean];
|
|
650
650
|
|
|
651
|
-
|
|
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 };
|