@exyconn/common 2.1.0 → 2.3.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/README.md +969 -261
- package/dist/client/hooks/index.d.mts +1042 -0
- package/dist/client/hooks/index.d.ts +1042 -0
- package/dist/client/hooks/index.js +2276 -0
- package/dist/client/hooks/index.js.map +1 -0
- package/dist/client/hooks/index.mjs +2217 -0
- package/dist/client/hooks/index.mjs.map +1 -0
- package/dist/client/http/index.d.mts +217 -49
- package/dist/client/http/index.d.ts +217 -49
- package/dist/client/http/index.js +473 -94
- package/dist/client/http/index.js.map +1 -1
- package/dist/client/http/index.mjs +441 -84
- package/dist/client/http/index.mjs.map +1 -1
- package/dist/client/index.d.mts +6 -4
- package/dist/client/index.d.ts +6 -4
- package/dist/client/index.js +481 -319
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +449 -290
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/utils/index.d.mts +3 -279
- package/dist/client/utils/index.d.ts +3 -279
- package/dist/client/web/index.d.mts +1461 -0
- package/dist/client/web/index.d.ts +1461 -0
- package/dist/client/web/index.js +2681 -0
- package/dist/client/web/index.js.map +1 -0
- package/dist/client/web/index.mjs +2618 -0
- package/dist/client/web/index.mjs.map +1 -0
- package/dist/data/brand-identity.d.mts +149 -0
- package/dist/data/brand-identity.d.ts +149 -0
- package/dist/data/brand-identity.js +235 -0
- package/dist/data/brand-identity.js.map +1 -0
- package/dist/data/brand-identity.mjs +220 -0
- package/dist/data/brand-identity.mjs.map +1 -0
- package/dist/data/countries.d.mts +61 -0
- package/dist/data/countries.d.ts +61 -0
- package/dist/data/countries.js +987 -0
- package/dist/data/countries.js.map +1 -0
- package/dist/data/countries.mjs +971 -0
- package/dist/data/countries.mjs.map +1 -0
- package/dist/data/currencies.d.mts +19 -0
- package/dist/data/currencies.d.ts +19 -0
- package/dist/data/currencies.js +162 -0
- package/dist/data/currencies.js.map +1 -0
- package/dist/data/currencies.mjs +153 -0
- package/dist/data/currencies.mjs.map +1 -0
- package/dist/data/index.d.mts +7 -0
- package/dist/data/index.d.ts +7 -0
- package/dist/data/index.js +2087 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/index.mjs +1948 -0
- package/dist/data/index.mjs.map +1 -0
- package/dist/data/phone-codes.d.mts +15 -0
- package/dist/data/phone-codes.d.ts +15 -0
- package/dist/data/phone-codes.js +219 -0
- package/dist/data/phone-codes.js.map +1 -0
- package/dist/data/phone-codes.mjs +211 -0
- package/dist/data/phone-codes.mjs.map +1 -0
- package/dist/data/regex.d.mts +287 -0
- package/dist/data/regex.d.ts +287 -0
- package/dist/data/regex.js +306 -0
- package/dist/data/regex.js.map +1 -0
- package/dist/data/regex.mjs +208 -0
- package/dist/data/regex.mjs.map +1 -0
- package/dist/data/timezones.d.mts +16 -0
- package/dist/data/timezones.d.ts +16 -0
- package/dist/data/timezones.js +98 -0
- package/dist/data/timezones.js.map +1 -0
- package/dist/data/timezones.mjs +89 -0
- package/dist/data/timezones.mjs.map +1 -0
- package/dist/index-BZf42T3R.d.mts +305 -0
- package/dist/index-CF0D8PGE.d.ts +305 -0
- package/dist/index-Ckhm_HaX.d.mts +138 -0
- package/dist/index-DKn4raO7.d.ts +222 -0
- package/dist/index-NS8dS0p9.d.mts +222 -0
- package/dist/index-Nqm5_lwT.d.ts +188 -0
- package/dist/index-br6POSyA.d.ts +138 -0
- package/dist/index-jBi3V6e5.d.mts +188 -0
- package/dist/index.d.mts +21 -580
- package/dist/index.d.ts +21 -580
- package/dist/index.js +1839 -347
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1850 -359
- package/dist/index.mjs.map +1 -1
- package/dist/packageCheck-B_qfsD6R.d.ts +280 -0
- package/dist/packageCheck-C2_FT_Rl.d.mts +280 -0
- package/dist/server/configs/index.d.mts +602 -0
- package/dist/server/configs/index.d.ts +602 -0
- package/dist/server/configs/index.js +707 -0
- package/dist/server/configs/index.js.map +1 -0
- package/dist/server/configs/index.mjs +665 -0
- package/dist/server/configs/index.mjs.map +1 -0
- package/dist/server/index.d.mts +4 -1
- package/dist/server/index.d.ts +4 -1
- package/dist/server/index.js +1330 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1286 -2
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/middleware/index.d.mts +283 -2
- package/dist/server/middleware/index.d.ts +283 -2
- package/dist/server/middleware/index.js +761 -0
- package/dist/server/middleware/index.js.map +1 -1
- package/dist/server/middleware/index.mjs +751 -1
- package/dist/server/middleware/index.mjs.map +1 -1
- package/dist/shared/config/index.d.mts +40 -0
- package/dist/shared/config/index.d.ts +40 -0
- package/dist/shared/config/index.js +58 -0
- package/dist/shared/config/index.js.map +1 -0
- package/dist/shared/config/index.mjs +51 -0
- package/dist/shared/config/index.mjs.map +1 -0
- package/dist/shared/constants/index.d.mts +593 -0
- package/dist/shared/constants/index.d.ts +593 -0
- package/dist/shared/constants/index.js +391 -0
- package/dist/shared/constants/index.js.map +1 -0
- package/dist/shared/constants/index.mjs +360 -0
- package/dist/shared/constants/index.mjs.map +1 -0
- package/dist/shared/index.d.mts +5 -1
- package/dist/shared/index.d.ts +5 -1
- package/dist/shared/types/index.d.mts +140 -0
- package/dist/shared/types/index.d.ts +140 -0
- package/dist/shared/types/index.js +4 -0
- package/dist/shared/types/index.js.map +1 -0
- package/dist/shared/types/index.mjs +3 -0
- package/dist/shared/types/index.mjs.map +1 -0
- package/dist/shared/utils/index.d.mts +255 -0
- package/dist/shared/utils/index.d.ts +255 -0
- package/dist/shared/utils/index.js +623 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/index.mjs +324 -0
- package/dist/shared/utils/index.mjs.map +1 -0
- package/dist/shared/validation/index.d.mts +258 -0
- package/dist/shared/validation/index.d.ts +258 -0
- package/dist/shared/validation/index.js +185 -0
- package/dist/shared/validation/index.js.map +1 -0
- package/dist/shared/validation/index.mjs +172 -0
- package/dist/shared/validation/index.mjs.map +1 -0
- package/package.json +127 -62
- package/dist/index-BcxL4_V4.d.ts +0 -2946
- package/dist/index-DEzgM15j.d.ts +0 -67
- package/dist/index-DNFVgQx8.d.ts +0 -1375
- package/dist/index-DbV04Dx8.d.mts +0 -67
- package/dist/index-DfqEP6Oe.d.mts +0 -1375
- package/dist/index-bvvCev9Q.d.mts +0 -2946
|
@@ -0,0 +1,1042 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
interface UseToggleReturn {
|
|
4
|
+
/** Current boolean value */
|
|
5
|
+
value: boolean;
|
|
6
|
+
/** Toggle the value */
|
|
7
|
+
toggle: () => void;
|
|
8
|
+
/** Set to true */
|
|
9
|
+
setTrue: () => void;
|
|
10
|
+
/** Set to false */
|
|
11
|
+
setFalse: () => void;
|
|
12
|
+
/** Set to specific value */
|
|
13
|
+
setValue: (value: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Hook to manage boolean state with toggle functionality
|
|
17
|
+
* @param initialValue - Initial boolean value (default: false)
|
|
18
|
+
*/
|
|
19
|
+
declare function useToggle(initialValue?: boolean): UseToggleReturn;
|
|
20
|
+
|
|
21
|
+
interface UseCounterOptions {
|
|
22
|
+
/** Minimum value */
|
|
23
|
+
min?: number;
|
|
24
|
+
/** Maximum value */
|
|
25
|
+
max?: number;
|
|
26
|
+
/** Step value for increment/decrement */
|
|
27
|
+
step?: number;
|
|
28
|
+
}
|
|
29
|
+
interface UseCounterReturn {
|
|
30
|
+
/** Current count value */
|
|
31
|
+
count: number;
|
|
32
|
+
/** Increment by step */
|
|
33
|
+
increment: () => void;
|
|
34
|
+
/** Decrement by step */
|
|
35
|
+
decrement: () => void;
|
|
36
|
+
/** Set to specific value */
|
|
37
|
+
set: (value: number) => void;
|
|
38
|
+
/** Reset to initial value */
|
|
39
|
+
reset: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hook to manage numeric counter with min/max bounds
|
|
43
|
+
* @param initialValue - Initial counter value (default: 0)
|
|
44
|
+
* @param options - Configuration options
|
|
45
|
+
*/
|
|
46
|
+
declare function useCounter(initialValue?: number, options?: UseCounterOptions): UseCounterReturn;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Hook that returns a default value when state is null or undefined
|
|
50
|
+
* @param initialValue - Initial value (can be null/undefined)
|
|
51
|
+
* @param defaultValue - Default value to use when state is null/undefined
|
|
52
|
+
*/
|
|
53
|
+
declare function useDefault<T>(initialValue: T | null | undefined, defaultValue: T): [T, (value: T | null | undefined) => void];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Hook to get the previous value of a state or prop
|
|
57
|
+
* @param value - Current value to track
|
|
58
|
+
* @param initialValue - Optional initial previous value
|
|
59
|
+
*/
|
|
60
|
+
declare function usePrevious<T>(value: T, initialValue?: T): T | undefined;
|
|
61
|
+
|
|
62
|
+
type ObjectStateUpdate<T> = Partial<T> | ((prevState: T) => Partial<T>);
|
|
63
|
+
interface UseObjectStateReturn<T extends object> {
|
|
64
|
+
/** Current state object */
|
|
65
|
+
state: T;
|
|
66
|
+
/** Update state with partial object (merges with existing) */
|
|
67
|
+
setState: (update: ObjectStateUpdate<T>) => void;
|
|
68
|
+
/** Reset to initial state */
|
|
69
|
+
resetState: () => void;
|
|
70
|
+
/** Set a single property */
|
|
71
|
+
setProperty: <K extends keyof T>(key: K, value: T[K]) => void;
|
|
72
|
+
/** Remove a property (sets to undefined) */
|
|
73
|
+
removeProperty: <K extends keyof T>(key: K) => void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Hook to manage object state with partial updates
|
|
77
|
+
* @param initialState - Initial state object
|
|
78
|
+
*/
|
|
79
|
+
declare function useObjectState<T extends object>(initialState: T): UseObjectStateReturn<T>;
|
|
80
|
+
|
|
81
|
+
interface UseHistoryStateReturn<T> {
|
|
82
|
+
/** Current state value */
|
|
83
|
+
state: T;
|
|
84
|
+
/** Set new state (adds to history) */
|
|
85
|
+
setState: (value: T | ((prev: T) => T)) => void;
|
|
86
|
+
/** Undo to previous state */
|
|
87
|
+
undo: () => void;
|
|
88
|
+
/** Redo to next state */
|
|
89
|
+
redo: () => void;
|
|
90
|
+
/** Clear all history and reset to current or initial */
|
|
91
|
+
clear: (value?: T) => void;
|
|
92
|
+
/** Can undo? */
|
|
93
|
+
canUndo: boolean;
|
|
94
|
+
/** Can redo? */
|
|
95
|
+
canRedo: boolean;
|
|
96
|
+
/** Full history array */
|
|
97
|
+
history: T[];
|
|
98
|
+
/** Current position in history */
|
|
99
|
+
pointer: number;
|
|
100
|
+
/** Go to specific position in history */
|
|
101
|
+
go: (index: number) => void;
|
|
102
|
+
}
|
|
103
|
+
interface UseHistoryStateOptions {
|
|
104
|
+
/** Maximum history length (default: 100) */
|
|
105
|
+
maxLength?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Hook to manage state with undo/redo functionality
|
|
109
|
+
* @param initialValue - Initial state value
|
|
110
|
+
* @param options - Configuration options
|
|
111
|
+
*/
|
|
112
|
+
declare function useHistoryState<T>(initialValue: T, options?: UseHistoryStateOptions): UseHistoryStateReturn<T>;
|
|
113
|
+
|
|
114
|
+
interface UseQueueReturn<T> {
|
|
115
|
+
/** Current queue items */
|
|
116
|
+
queue: T[];
|
|
117
|
+
/** Add item to end of queue */
|
|
118
|
+
enqueue: (item: T) => void;
|
|
119
|
+
/** Add multiple items to end of queue */
|
|
120
|
+
enqueueAll: (items: T[]) => void;
|
|
121
|
+
/** Remove and return first item */
|
|
122
|
+
dequeue: () => T | undefined;
|
|
123
|
+
/** Peek at first item without removing */
|
|
124
|
+
peek: () => T | undefined;
|
|
125
|
+
/** Clear the queue */
|
|
126
|
+
clear: () => void;
|
|
127
|
+
/** Queue size */
|
|
128
|
+
size: number;
|
|
129
|
+
/** Is queue empty? */
|
|
130
|
+
isEmpty: boolean;
|
|
131
|
+
/** First item in queue */
|
|
132
|
+
first: T | undefined;
|
|
133
|
+
/** Last item in queue */
|
|
134
|
+
last: T | undefined;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Hook to manage a FIFO queue
|
|
138
|
+
* @param initialValue - Initial queue items (default: [])
|
|
139
|
+
*/
|
|
140
|
+
declare function useQueue<T>(initialValue?: T[]): UseQueueReturn<T>;
|
|
141
|
+
|
|
142
|
+
interface UseListReturn<T> {
|
|
143
|
+
/** Current list items */
|
|
144
|
+
list: T[];
|
|
145
|
+
/** Set entire list */
|
|
146
|
+
set: (newList: T[]) => void;
|
|
147
|
+
/** Add item to end */
|
|
148
|
+
push: (item: T) => void;
|
|
149
|
+
/** Add item to beginning */
|
|
150
|
+
unshift: (item: T) => void;
|
|
151
|
+
/** Remove item at index */
|
|
152
|
+
removeAt: (index: number) => void;
|
|
153
|
+
/** Remove first matching item */
|
|
154
|
+
remove: (item: T) => void;
|
|
155
|
+
/** Remove items matching predicate */
|
|
156
|
+
removeWhere: (predicate: (item: T) => boolean) => void;
|
|
157
|
+
/** Update item at index */
|
|
158
|
+
updateAt: (index: number, item: T) => void;
|
|
159
|
+
/** Update item at index with function */
|
|
160
|
+
updateWhere: (predicate: (item: T) => boolean, updater: (item: T) => T) => void;
|
|
161
|
+
/** Insert item at index */
|
|
162
|
+
insertAt: (index: number, item: T) => void;
|
|
163
|
+
/** Move item from one index to another */
|
|
164
|
+
move: (fromIndex: number, toIndex: number) => void;
|
|
165
|
+
/** Clear the list */
|
|
166
|
+
clear: () => void;
|
|
167
|
+
/** Reset to initial value */
|
|
168
|
+
reset: () => void;
|
|
169
|
+
/** Filter items */
|
|
170
|
+
filter: (predicate: (item: T) => boolean) => void;
|
|
171
|
+
/** Sort items */
|
|
172
|
+
sort: (compareFn?: (a: T, b: T) => number) => void;
|
|
173
|
+
/** Reverse items */
|
|
174
|
+
reverse: () => void;
|
|
175
|
+
/** List size */
|
|
176
|
+
size: number;
|
|
177
|
+
/** Is list empty? */
|
|
178
|
+
isEmpty: boolean;
|
|
179
|
+
/** First item */
|
|
180
|
+
first: T | undefined;
|
|
181
|
+
/** Last item */
|
|
182
|
+
last: T | undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Hook to manage array/list with utility methods
|
|
186
|
+
* @param initialValue - Initial list items (default: [])
|
|
187
|
+
*/
|
|
188
|
+
declare function useList<T>(initialValue?: T[]): UseListReturn<T>;
|
|
189
|
+
|
|
190
|
+
interface UseMapReturn<K, V> {
|
|
191
|
+
/** Current map */
|
|
192
|
+
map: Map<K, V>;
|
|
193
|
+
/** Get value by key */
|
|
194
|
+
get: (key: K) => V | undefined;
|
|
195
|
+
/** Set key-value pair */
|
|
196
|
+
set: (key: K, value: V) => void;
|
|
197
|
+
/** Set multiple entries */
|
|
198
|
+
setAll: (entries: Iterable<[K, V]>) => void;
|
|
199
|
+
/** Check if key exists */
|
|
200
|
+
has: (key: K) => boolean;
|
|
201
|
+
/** Delete by key */
|
|
202
|
+
remove: (key: K) => void;
|
|
203
|
+
/** Delete multiple keys */
|
|
204
|
+
removeAll: (keys: K[]) => void;
|
|
205
|
+
/** Clear the map */
|
|
206
|
+
clear: () => void;
|
|
207
|
+
/** Reset to initial value */
|
|
208
|
+
reset: () => void;
|
|
209
|
+
/** Map size */
|
|
210
|
+
size: number;
|
|
211
|
+
/** All keys */
|
|
212
|
+
keys: K[];
|
|
213
|
+
/** All values */
|
|
214
|
+
values: V[];
|
|
215
|
+
/** All entries */
|
|
216
|
+
entries: [K, V][];
|
|
217
|
+
/** Is map empty? */
|
|
218
|
+
isEmpty: boolean;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Hook to manage Map state with utility methods
|
|
222
|
+
* @param initialValue - Initial entries (default: [])
|
|
223
|
+
*/
|
|
224
|
+
declare function useMap<K, V>(initialValue?: Iterable<[K, V]>): UseMapReturn<K, V>;
|
|
225
|
+
|
|
226
|
+
interface UseSetReturn<T> {
|
|
227
|
+
/** Current set */
|
|
228
|
+
set: Set<T>;
|
|
229
|
+
/** Add item to set */
|
|
230
|
+
add: (item: T) => void;
|
|
231
|
+
/** Add multiple items */
|
|
232
|
+
addAll: (items: Iterable<T>) => void;
|
|
233
|
+
/** Check if item exists */
|
|
234
|
+
has: (item: T) => boolean;
|
|
235
|
+
/** Remove item from set */
|
|
236
|
+
remove: (item: T) => void;
|
|
237
|
+
/** Remove multiple items */
|
|
238
|
+
removeAll: (items: Iterable<T>) => void;
|
|
239
|
+
/** Toggle item (add if not exists, remove if exists) */
|
|
240
|
+
toggle: (item: T) => void;
|
|
241
|
+
/** Clear the set */
|
|
242
|
+
clear: () => void;
|
|
243
|
+
/** Reset to initial value */
|
|
244
|
+
reset: () => void;
|
|
245
|
+
/** Set size */
|
|
246
|
+
size: number;
|
|
247
|
+
/** All values as array */
|
|
248
|
+
values: T[];
|
|
249
|
+
/** Is set empty? */
|
|
250
|
+
isEmpty: boolean;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Hook to manage Set state with utility methods
|
|
254
|
+
* @param initialValue - Initial items (default: [])
|
|
255
|
+
*/
|
|
256
|
+
declare function useSet<T>(initialValue?: Iterable<T>): UseSetReturn<T>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Debounce a value with configurable delay
|
|
260
|
+
* @param value - Value to debounce
|
|
261
|
+
* @param delay - Delay in milliseconds (default: 500)
|
|
262
|
+
*/
|
|
263
|
+
declare function useDebounce<T>(value: T, delay?: number): T;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Throttle a value with configurable interval
|
|
267
|
+
* @param value - Value to throttle
|
|
268
|
+
* @param interval - Minimum interval between updates in milliseconds (default: 500)
|
|
269
|
+
*/
|
|
270
|
+
declare function useThrottle<T>(value: T, interval?: number): T;
|
|
271
|
+
|
|
272
|
+
interface UseTimeoutReturn {
|
|
273
|
+
/** Reset the timeout */
|
|
274
|
+
reset: () => void;
|
|
275
|
+
/** Clear/cancel the timeout */
|
|
276
|
+
clear: () => void;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Hook to manage setTimeout declaratively
|
|
280
|
+
* @param callback - Function to call after timeout
|
|
281
|
+
* @param delay - Delay in milliseconds (null to disable)
|
|
282
|
+
*/
|
|
283
|
+
declare function useTimeout(callback: () => void, delay: number | null): UseTimeoutReturn;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Run a callback on an interval
|
|
287
|
+
* @param callback - Function to call on each interval
|
|
288
|
+
* @param delay - Interval delay in ms (null to pause)
|
|
289
|
+
*/
|
|
290
|
+
declare function useInterval(callback: () => void, delay: number | null): void;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Hook to run interval conditionally
|
|
294
|
+
* @param callback - Function to call on each interval
|
|
295
|
+
* @param delay - Interval delay in milliseconds
|
|
296
|
+
* @param when - Condition to run the interval
|
|
297
|
+
* @param immediate - Run callback immediately when condition becomes true
|
|
298
|
+
*/
|
|
299
|
+
declare function useIntervalWhen(callback: () => void, delay: number, when: boolean, immediate?: boolean): void;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Hook to run callback at random intervals
|
|
303
|
+
* @param callback - Function to call on each interval
|
|
304
|
+
* @param minDelay - Minimum delay in milliseconds
|
|
305
|
+
* @param maxDelay - Maximum delay in milliseconds
|
|
306
|
+
* @param enabled - Whether the interval is enabled (default: true)
|
|
307
|
+
*/
|
|
308
|
+
declare function useRandomInterval(callback: () => void, minDelay: number, maxDelay: number, enabled?: boolean): void;
|
|
309
|
+
|
|
310
|
+
interface UseCountdownOptions {
|
|
311
|
+
/** Interval in milliseconds (default: 1000) */
|
|
312
|
+
interval?: number;
|
|
313
|
+
/** Callback when countdown reaches zero */
|
|
314
|
+
onComplete?: () => void;
|
|
315
|
+
/** Auto-start the countdown (default: false) */
|
|
316
|
+
autoStart?: boolean;
|
|
317
|
+
}
|
|
318
|
+
interface UseCountdownReturn {
|
|
319
|
+
/** Current countdown value in milliseconds */
|
|
320
|
+
count: number;
|
|
321
|
+
/** Start the countdown */
|
|
322
|
+
start: () => void;
|
|
323
|
+
/** Pause the countdown */
|
|
324
|
+
pause: () => void;
|
|
325
|
+
/** Resume the countdown */
|
|
326
|
+
resume: () => void;
|
|
327
|
+
/** Reset to initial value */
|
|
328
|
+
reset: (newCount?: number) => void;
|
|
329
|
+
/** Is countdown running? */
|
|
330
|
+
isRunning: boolean;
|
|
331
|
+
/** Is countdown complete? */
|
|
332
|
+
isComplete: boolean;
|
|
333
|
+
/** Formatted time { days, hours, minutes, seconds } */
|
|
334
|
+
formatted: {
|
|
335
|
+
days: number;
|
|
336
|
+
hours: number;
|
|
337
|
+
minutes: number;
|
|
338
|
+
seconds: number;
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Hook to manage countdown timer
|
|
343
|
+
* @param initialCount - Initial countdown value in milliseconds
|
|
344
|
+
* @param options - Configuration options
|
|
345
|
+
*/
|
|
346
|
+
declare function useCountdown(initialCount: number, options?: UseCountdownOptions): UseCountdownReturn;
|
|
347
|
+
|
|
348
|
+
interface UseContinuousRetryOptions {
|
|
349
|
+
/** Maximum number of retry attempts (default: Infinity) */
|
|
350
|
+
maxAttempts?: number;
|
|
351
|
+
/** Delay between retries in milliseconds (default: 1000) */
|
|
352
|
+
delay?: number;
|
|
353
|
+
/** Whether to use exponential backoff (default: false) */
|
|
354
|
+
exponentialBackoff?: boolean;
|
|
355
|
+
/** Maximum delay when using exponential backoff (default: 30000) */
|
|
356
|
+
maxDelay?: number;
|
|
357
|
+
/** Auto-start retrying (default: true) */
|
|
358
|
+
autoStart?: boolean;
|
|
359
|
+
}
|
|
360
|
+
interface UseContinuousRetryReturn {
|
|
361
|
+
/** Number of attempts made */
|
|
362
|
+
attempts: number;
|
|
363
|
+
/** Last error encountered */
|
|
364
|
+
error: Error | null;
|
|
365
|
+
/** Is currently retrying? */
|
|
366
|
+
isRetrying: boolean;
|
|
367
|
+
/** Has succeeded? */
|
|
368
|
+
isSuccess: boolean;
|
|
369
|
+
/** Has reached max attempts? */
|
|
370
|
+
isMaxAttempts: boolean;
|
|
371
|
+
/** Start/restart retrying */
|
|
372
|
+
start: () => void;
|
|
373
|
+
/** Stop retrying */
|
|
374
|
+
stop: () => void;
|
|
375
|
+
/** Reset state */
|
|
376
|
+
reset: () => void;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Hook to continuously retry a function until success
|
|
380
|
+
* @param callback - Async function to retry (return true for success, false for retry)
|
|
381
|
+
* @param options - Configuration options
|
|
382
|
+
*/
|
|
383
|
+
declare function useContinuousRetry(callback: () => Promise<boolean> | boolean, options?: UseContinuousRetryOptions): UseContinuousRetryReturn;
|
|
384
|
+
|
|
385
|
+
interface WindowSize {
|
|
386
|
+
width: number;
|
|
387
|
+
height: number;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Track window dimensions with resize updates
|
|
391
|
+
* @param debounceMs - Debounce resize events (default: 100ms)
|
|
392
|
+
*/
|
|
393
|
+
declare function useWindowSize(debounceMs?: number): WindowSize;
|
|
394
|
+
|
|
395
|
+
interface WindowScrollPosition {
|
|
396
|
+
/** Horizontal scroll position */
|
|
397
|
+
x: number;
|
|
398
|
+
/** Vertical scroll position */
|
|
399
|
+
y: number;
|
|
400
|
+
/** Scroll direction (up, down, left, right, or null) */
|
|
401
|
+
direction: 'up' | 'down' | 'left' | 'right' | null;
|
|
402
|
+
/** Is scrolling? */
|
|
403
|
+
isScrolling: boolean;
|
|
404
|
+
}
|
|
405
|
+
interface UseWindowScrollReturn extends WindowScrollPosition {
|
|
406
|
+
/** Scroll to position */
|
|
407
|
+
scrollTo: (options: ScrollToOptions) => void;
|
|
408
|
+
/** Scroll to top */
|
|
409
|
+
scrollToTop: (behavior?: ScrollBehavior) => void;
|
|
410
|
+
/** Scroll to bottom */
|
|
411
|
+
scrollToBottom: (behavior?: ScrollBehavior) => void;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Hook to track and control window scroll position
|
|
415
|
+
*/
|
|
416
|
+
declare function useWindowScroll(): UseWindowScrollReturn;
|
|
417
|
+
|
|
418
|
+
interface UseDocumentTitleOptions {
|
|
419
|
+
/** Restore previous title on unmount (default: true) */
|
|
420
|
+
restoreOnUnmount?: boolean;
|
|
421
|
+
/** Title template, use %s for title placeholder */
|
|
422
|
+
template?: string;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Hook to set document title
|
|
426
|
+
* @param title - Document title
|
|
427
|
+
* @param options - Configuration options
|
|
428
|
+
*/
|
|
429
|
+
declare function useDocumentTitle(title: string, options?: UseDocumentTitleOptions): void;
|
|
430
|
+
|
|
431
|
+
interface UsePageTitleOptions {
|
|
432
|
+
/** Suffix to append to the title (e.g., organization name) */
|
|
433
|
+
suffix?: string;
|
|
434
|
+
/** Separator between title and suffix (default: ' | ') */
|
|
435
|
+
separator?: string;
|
|
436
|
+
/** Whether to restore original title on unmount (default: true) */
|
|
437
|
+
restoreOnUnmount?: boolean;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Set the document title with optional suffix
|
|
441
|
+
* @param title - Page title
|
|
442
|
+
* @param options - Configuration options
|
|
443
|
+
*/
|
|
444
|
+
declare function usePageTitle(title: string, options?: UsePageTitleOptions): void;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Hook to dynamically change favicon
|
|
448
|
+
* @param href - URL of the favicon image
|
|
449
|
+
* @param restoreOnUnmount - Whether to restore original favicon on unmount (default: true)
|
|
450
|
+
*/
|
|
451
|
+
declare function useFavicon(href: string, restoreOnUnmount?: boolean): void;
|
|
452
|
+
|
|
453
|
+
interface UseVisibilityChangeReturn {
|
|
454
|
+
/** Is document visible? */
|
|
455
|
+
isVisible: boolean;
|
|
456
|
+
/** Visibility state ('visible', 'hidden', 'prerender') */
|
|
457
|
+
visibilityState: DocumentVisibilityState;
|
|
458
|
+
/** Time when visibility last changed */
|
|
459
|
+
lastChanged: Date | null;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Hook to track document visibility state
|
|
463
|
+
* @param onVisibilityChange - Optional callback when visibility changes
|
|
464
|
+
*/
|
|
465
|
+
declare function useVisibilityChange(onVisibilityChange?: (isVisible: boolean) => void): UseVisibilityChangeReturn;
|
|
466
|
+
|
|
467
|
+
interface UsePageLeaveOptions {
|
|
468
|
+
/** Show confirmation dialog on page leave (default: false) */
|
|
469
|
+
showConfirmation?: boolean;
|
|
470
|
+
/** Custom confirmation message (browser may override) */
|
|
471
|
+
confirmationMessage?: string;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Hook to detect when user is leaving the page
|
|
475
|
+
* @param onLeave - Callback when user attempts to leave
|
|
476
|
+
* @param options - Configuration options
|
|
477
|
+
*/
|
|
478
|
+
declare function usePageLeave(onLeave?: () => void, options?: UsePageLeaveOptions): void;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Hook to lock body scroll
|
|
482
|
+
* @param locked - Whether scroll should be locked (default: true)
|
|
483
|
+
*/
|
|
484
|
+
declare function useLockBodyScroll(locked?: boolean): void;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Hook to check if rendering on client side
|
|
488
|
+
* Useful for SSR/SSG environments
|
|
489
|
+
*/
|
|
490
|
+
declare function useIsClient(): boolean;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Hook to check if it's the first render
|
|
494
|
+
*/
|
|
495
|
+
declare function useIsFirstRender(): boolean;
|
|
496
|
+
|
|
497
|
+
type EventMap = WindowEventMap & DocumentEventMap & HTMLElementEventMap;
|
|
498
|
+
/**
|
|
499
|
+
* Hook to attach event listeners declaratively
|
|
500
|
+
* @param eventName - Name of the event to listen for
|
|
501
|
+
* @param handler - Event handler function
|
|
502
|
+
* @param element - Target element (default: window)
|
|
503
|
+
* @param options - AddEventListener options
|
|
504
|
+
*/
|
|
505
|
+
declare function useEventListener<K extends keyof EventMap>(eventName: K, handler: (event: EventMap[K]) => void, element?: HTMLElement | Window | Document | null, options?: boolean | AddEventListenerOptions): void;
|
|
506
|
+
|
|
507
|
+
interface UseKeyPressOptions {
|
|
508
|
+
/** Target element (default: document) */
|
|
509
|
+
target?: HTMLElement | Document | Window | null;
|
|
510
|
+
/** Event type: 'keydown' | 'keyup' | 'keypress' */
|
|
511
|
+
event?: 'keydown' | 'keyup' | 'keypress';
|
|
512
|
+
/** Prevent default behavior */
|
|
513
|
+
preventDefault?: boolean;
|
|
514
|
+
/** Stop event propagation */
|
|
515
|
+
stopPropagation?: boolean;
|
|
516
|
+
}
|
|
517
|
+
interface UseKeyPressReturn {
|
|
518
|
+
/** Is the key currently pressed? */
|
|
519
|
+
pressed: boolean;
|
|
520
|
+
/** Event object from last press */
|
|
521
|
+
event: KeyboardEvent | null;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Hook to detect key press
|
|
525
|
+
* @param targetKey - Key to detect (e.g., 'Enter', 'Escape', 'a')
|
|
526
|
+
* @param callback - Optional callback when key is pressed
|
|
527
|
+
* @param options - Configuration options
|
|
528
|
+
*/
|
|
529
|
+
declare function useKeyPress(targetKey: string | string[], callback?: (event: KeyboardEvent) => void, options?: UseKeyPressOptions): UseKeyPressReturn;
|
|
530
|
+
|
|
531
|
+
interface UseHoverReturn<T extends HTMLElement = HTMLElement> {
|
|
532
|
+
/** Ref to attach to the target element */
|
|
533
|
+
ref: React.RefObject<T | null>;
|
|
534
|
+
/** Is element being hovered? */
|
|
535
|
+
isHovered: boolean;
|
|
536
|
+
/** Bind props to spread on element */
|
|
537
|
+
bind: {
|
|
538
|
+
onMouseEnter: () => void;
|
|
539
|
+
onMouseLeave: () => void;
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Hook to detect hover state
|
|
544
|
+
* @param onHoverChange - Optional callback when hover state changes
|
|
545
|
+
*/
|
|
546
|
+
declare function useHover<T extends HTMLElement = HTMLElement>(onHoverChange?: (isHovered: boolean) => void): UseHoverReturn<T>;
|
|
547
|
+
|
|
548
|
+
type EventType = 'mousedown' | 'mouseup' | 'touchstart' | 'touchend';
|
|
549
|
+
/**
|
|
550
|
+
* Hook to detect clicks outside of an element
|
|
551
|
+
* @param callback - Function to call when click outside occurs
|
|
552
|
+
* @param events - Event types to listen for (default: ['mousedown', 'touchstart'])
|
|
553
|
+
*/
|
|
554
|
+
declare function useClickAway<T extends HTMLElement = HTMLElement>(callback: (event: MouseEvent | TouchEvent) => void, events?: EventType[]): React.RefObject<T | null>;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* useOnClickOutside Hook
|
|
558
|
+
* Detect clicks outside of a referenced element
|
|
559
|
+
*/
|
|
560
|
+
|
|
561
|
+
type Handler = (event: MouseEvent | TouchEvent) => void;
|
|
562
|
+
/**
|
|
563
|
+
* Detect clicks outside of a referenced element
|
|
564
|
+
* @param ref - React ref to the element
|
|
565
|
+
* @param handler - Callback when click outside occurs
|
|
566
|
+
* @param enabled - Whether the hook is enabled (default: true)
|
|
567
|
+
*/
|
|
568
|
+
declare function useOnClickOutside<T extends HTMLElement = HTMLElement>(ref: RefObject<T>, handler: Handler, enabled?: boolean): void;
|
|
569
|
+
|
|
570
|
+
interface UseLongPressOptions {
|
|
571
|
+
/** Threshold in milliseconds (default: 400) */
|
|
572
|
+
threshold?: number;
|
|
573
|
+
/** Callback on long press */
|
|
574
|
+
onLongPress?: (event: React.MouseEvent | React.TouchEvent) => void;
|
|
575
|
+
/** Callback on regular click */
|
|
576
|
+
onClick?: (event: React.MouseEvent | React.TouchEvent) => void;
|
|
577
|
+
/** Callback when press starts */
|
|
578
|
+
onStart?: (event: React.MouseEvent | React.TouchEvent) => void;
|
|
579
|
+
/** Callback when press ends */
|
|
580
|
+
onFinish?: (event: React.MouseEvent | React.TouchEvent) => void;
|
|
581
|
+
/** Callback when press is cancelled */
|
|
582
|
+
onCancel?: (event: React.MouseEvent | React.TouchEvent) => void;
|
|
583
|
+
}
|
|
584
|
+
interface UseLongPressReturn {
|
|
585
|
+
/** Is currently pressing? */
|
|
586
|
+
isPressed: boolean;
|
|
587
|
+
/** Is long press achieved? */
|
|
588
|
+
isLongPress: boolean;
|
|
589
|
+
/** Bind props to spread on element */
|
|
590
|
+
bind: {
|
|
591
|
+
onMouseDown: (e: React.MouseEvent) => void;
|
|
592
|
+
onMouseUp: (e: React.MouseEvent) => void;
|
|
593
|
+
onMouseLeave: (e: React.MouseEvent) => void;
|
|
594
|
+
onTouchStart: (e: React.TouchEvent) => void;
|
|
595
|
+
onTouchEnd: (e: React.TouchEvent) => void;
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Hook to detect long press gesture
|
|
600
|
+
* @param options - Configuration options
|
|
601
|
+
*/
|
|
602
|
+
declare function useLongPress(options?: UseLongPressOptions): UseLongPressReturn;
|
|
603
|
+
|
|
604
|
+
interface MousePosition {
|
|
605
|
+
/** X position relative to viewport */
|
|
606
|
+
x: number;
|
|
607
|
+
/** Y position relative to viewport */
|
|
608
|
+
y: number;
|
|
609
|
+
/** X position relative to page */
|
|
610
|
+
pageX: number;
|
|
611
|
+
/** Y position relative to page */
|
|
612
|
+
pageY: number;
|
|
613
|
+
/** X position relative to element (if ref provided) */
|
|
614
|
+
elementX: number;
|
|
615
|
+
/** Y position relative to element (if ref provided) */
|
|
616
|
+
elementY: number;
|
|
617
|
+
/** Is mouse within element bounds? */
|
|
618
|
+
isInElement: boolean;
|
|
619
|
+
}
|
|
620
|
+
interface UseMouseOptions {
|
|
621
|
+
/** Whether to track (default: true) */
|
|
622
|
+
enabled?: boolean;
|
|
623
|
+
}
|
|
624
|
+
interface UseMouseReturn<T extends HTMLElement = HTMLElement> extends MousePosition {
|
|
625
|
+
/** Ref to attach to element for relative positioning */
|
|
626
|
+
ref: React.RefObject<T | null>;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Hook to track mouse position
|
|
630
|
+
* @param options - Configuration options
|
|
631
|
+
*/
|
|
632
|
+
declare function useMouse<T extends HTMLElement = HTMLElement>(options?: UseMouseOptions): UseMouseReturn<T>;
|
|
633
|
+
|
|
634
|
+
interface UseCopyToClipboardReturn {
|
|
635
|
+
/** Copy text to clipboard */
|
|
636
|
+
copy: (text: string) => Promise<boolean>;
|
|
637
|
+
/** Whether copy was successful (resets after timeout) */
|
|
638
|
+
copied: boolean;
|
|
639
|
+
/** Error message if copy failed */
|
|
640
|
+
error: string | null;
|
|
641
|
+
/** Reset state */
|
|
642
|
+
reset: () => void;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Copy text to clipboard with feedback
|
|
646
|
+
* @param resetDelay - Time in ms before copied state resets (default: 2000)
|
|
647
|
+
*/
|
|
648
|
+
declare function useCopyToClipboard(resetDelay?: number): UseCopyToClipboardReturn;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Track a media query match
|
|
652
|
+
* @param query - CSS media query string (e.g., '(min-width: 768px)')
|
|
653
|
+
*/
|
|
654
|
+
declare function useMediaQuery(query: string): boolean;
|
|
655
|
+
declare const useIsMobile: () => boolean;
|
|
656
|
+
declare const useIsTablet: () => boolean;
|
|
657
|
+
declare const useIsDesktop: () => boolean;
|
|
658
|
+
declare const useIsMobileOrTablet: () => boolean;
|
|
659
|
+
|
|
660
|
+
interface OrientationState {
|
|
661
|
+
/** Device orientation angle */
|
|
662
|
+
angle: number;
|
|
663
|
+
/** Orientation type */
|
|
664
|
+
type: OrientationType;
|
|
665
|
+
/** Is portrait? */
|
|
666
|
+
isPortrait: boolean;
|
|
667
|
+
/** Is landscape? */
|
|
668
|
+
isLandscape: boolean;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Hook to track device/screen orientation
|
|
672
|
+
*/
|
|
673
|
+
declare function useOrientation(): OrientationState;
|
|
674
|
+
|
|
675
|
+
interface BatteryState {
|
|
676
|
+
/** Is battery API supported? */
|
|
677
|
+
isSupported: boolean;
|
|
678
|
+
/** Is device charging? */
|
|
679
|
+
charging: boolean;
|
|
680
|
+
/** Time until fully charged (seconds), Infinity if not charging */
|
|
681
|
+
chargingTime: number;
|
|
682
|
+
/** Time until discharged (seconds), Infinity if charging */
|
|
683
|
+
dischargingTime: number;
|
|
684
|
+
/** Battery level (0 to 1) */
|
|
685
|
+
level: number;
|
|
686
|
+
/** Battery percentage (0 to 100) */
|
|
687
|
+
percentage: number;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Hook to track battery status
|
|
691
|
+
*/
|
|
692
|
+
declare function useBattery(): BatteryState;
|
|
693
|
+
|
|
694
|
+
interface NetworkState {
|
|
695
|
+
/** Is online? */
|
|
696
|
+
online: boolean;
|
|
697
|
+
/** Is offline? */
|
|
698
|
+
offline: boolean;
|
|
699
|
+
/** Connection downlink speed (Mbps) */
|
|
700
|
+
downlink?: number;
|
|
701
|
+
/** Effective connection type */
|
|
702
|
+
effectiveType?: 'slow-2g' | '2g' | '3g' | '4g';
|
|
703
|
+
/** Round-trip time (ms) */
|
|
704
|
+
rtt?: number;
|
|
705
|
+
/** Is data saver enabled? */
|
|
706
|
+
saveData?: boolean;
|
|
707
|
+
/** Connection type */
|
|
708
|
+
type?: string;
|
|
709
|
+
/** Time when status last changed */
|
|
710
|
+
since?: Date;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Hook to track network status
|
|
714
|
+
*/
|
|
715
|
+
declare function useNetworkState(): NetworkState;
|
|
716
|
+
|
|
717
|
+
interface UseIdleOptions {
|
|
718
|
+
/** Idle timeout in milliseconds (default: 60000 = 1 minute) */
|
|
719
|
+
timeout?: number;
|
|
720
|
+
/** Events to consider as activity */
|
|
721
|
+
events?: string[];
|
|
722
|
+
/** Initial idle state */
|
|
723
|
+
initialState?: boolean;
|
|
724
|
+
/** Callback when user becomes idle */
|
|
725
|
+
onIdle?: () => void;
|
|
726
|
+
/** Callback when user becomes active */
|
|
727
|
+
onActive?: () => void;
|
|
728
|
+
}
|
|
729
|
+
interface UseIdleReturn {
|
|
730
|
+
/** Is user idle? */
|
|
731
|
+
isIdle: boolean;
|
|
732
|
+
/** Last active timestamp */
|
|
733
|
+
lastActive: Date;
|
|
734
|
+
/** Reset idle timer */
|
|
735
|
+
reset: () => void;
|
|
736
|
+
/** Start tracking */
|
|
737
|
+
start: () => void;
|
|
738
|
+
/** Stop tracking */
|
|
739
|
+
stop: () => void;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Hook to detect user idle state
|
|
743
|
+
* @param options - Configuration options
|
|
744
|
+
*/
|
|
745
|
+
declare function useIdle(options?: UseIdleOptions): UseIdleReturn;
|
|
746
|
+
|
|
747
|
+
interface GeolocationState {
|
|
748
|
+
/** Is loading? */
|
|
749
|
+
loading: boolean;
|
|
750
|
+
/** Error message */
|
|
751
|
+
error: string | null;
|
|
752
|
+
/** Latitude */
|
|
753
|
+
latitude: number | null;
|
|
754
|
+
/** Longitude */
|
|
755
|
+
longitude: number | null;
|
|
756
|
+
/** Accuracy in meters */
|
|
757
|
+
accuracy: number | null;
|
|
758
|
+
/** Altitude in meters */
|
|
759
|
+
altitude: number | null;
|
|
760
|
+
/** Altitude accuracy in meters */
|
|
761
|
+
altitudeAccuracy: number | null;
|
|
762
|
+
/** Heading in degrees */
|
|
763
|
+
heading: number | null;
|
|
764
|
+
/** Speed in m/s */
|
|
765
|
+
speed: number | null;
|
|
766
|
+
/** Timestamp */
|
|
767
|
+
timestamp: number | null;
|
|
768
|
+
}
|
|
769
|
+
interface UseGeolocationOptions {
|
|
770
|
+
/** Enable high accuracy mode */
|
|
771
|
+
enableHighAccuracy?: boolean;
|
|
772
|
+
/** Maximum age of cached position (ms) */
|
|
773
|
+
maximumAge?: number;
|
|
774
|
+
/** Timeout for getting position (ms) */
|
|
775
|
+
timeout?: number;
|
|
776
|
+
/** Watch position continuously */
|
|
777
|
+
watch?: boolean;
|
|
778
|
+
}
|
|
779
|
+
interface UseGeolocationReturn extends GeolocationState {
|
|
780
|
+
/** Refresh position */
|
|
781
|
+
refresh: () => void;
|
|
782
|
+
/** Is geolocation supported? */
|
|
783
|
+
isSupported: boolean;
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Hook to track geolocation
|
|
787
|
+
* @param options - Configuration options
|
|
788
|
+
*/
|
|
789
|
+
declare function useGeolocation(options?: UseGeolocationOptions): UseGeolocationReturn;
|
|
790
|
+
|
|
791
|
+
interface UsePreferredLanguageReturn {
|
|
792
|
+
/** Primary preferred language */
|
|
793
|
+
language: string;
|
|
794
|
+
/** All preferred languages */
|
|
795
|
+
languages: readonly string[];
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Hook to get user's preferred language
|
|
799
|
+
*/
|
|
800
|
+
declare function usePreferredLanguage(): UsePreferredLanguageReturn;
|
|
801
|
+
|
|
802
|
+
type ThemeMode = 'light' | 'dark';
|
|
803
|
+
/**
|
|
804
|
+
* Detect and track system color scheme preference
|
|
805
|
+
* @returns Current theme mode based on system preference
|
|
806
|
+
*/
|
|
807
|
+
declare function useThemeDetector(): ThemeMode;
|
|
808
|
+
|
|
809
|
+
type SetValue<T> = T | ((prevValue: T) => T);
|
|
810
|
+
interface UseLocalStorageOptions<T> {
|
|
811
|
+
/** Serialize function (default: JSON.stringify) */
|
|
812
|
+
serializer?: (value: T) => string;
|
|
813
|
+
/** Deserialize function (default: JSON.parse) */
|
|
814
|
+
deserializer?: (value: string) => T;
|
|
815
|
+
/** Enable cross-tab synchronization (default: true) */
|
|
816
|
+
syncTabs?: boolean;
|
|
817
|
+
/** Enable logging (default: false) */
|
|
818
|
+
debug?: boolean;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Hook to persist state in localStorage with cross-tab sync
|
|
822
|
+
* @param key - localStorage key
|
|
823
|
+
* @param initialValue - initial/fallback value
|
|
824
|
+
* @param options - configuration options
|
|
825
|
+
*/
|
|
826
|
+
declare function useLocalStorage<T>(key: string, initialValue: T, options?: UseLocalStorageOptions<T>): [T, (value: SetValue<T>) => void, () => void];
|
|
827
|
+
|
|
828
|
+
interface UseSessionStorageOptions<T> {
|
|
829
|
+
/** Serialize function (default: JSON.stringify) */
|
|
830
|
+
serializer?: (value: T) => string;
|
|
831
|
+
/** Deserialize function (default: JSON.parse) */
|
|
832
|
+
deserializer?: (value: string) => T;
|
|
833
|
+
/** Enable logging (default: false) */
|
|
834
|
+
debug?: boolean;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Hook to persist state in sessionStorage
|
|
838
|
+
* @param key - sessionStorage key
|
|
839
|
+
* @param initialValue - initial/fallback value
|
|
840
|
+
* @param options - configuration options
|
|
841
|
+
*/
|
|
842
|
+
declare function useSessionStorage<T>(key: string, initialValue: T, options?: UseSessionStorageOptions<T>): [T, (value: SetValue<T>) => void, () => void];
|
|
843
|
+
|
|
844
|
+
interface UseFetchOptions<T> extends Omit<RequestInit, 'body'> {
|
|
845
|
+
/** Request body (will be JSON.stringify'd if object) */
|
|
846
|
+
body?: BodyInit | object | null;
|
|
847
|
+
/** Skip initial fetch */
|
|
848
|
+
skip?: boolean;
|
|
849
|
+
/** Transform response data */
|
|
850
|
+
transform?: (data: unknown) => T;
|
|
851
|
+
/** Retry count on failure */
|
|
852
|
+
retries?: number;
|
|
853
|
+
/** Retry delay in ms */
|
|
854
|
+
retryDelay?: number;
|
|
855
|
+
/** Cache key (default: url) */
|
|
856
|
+
cacheKey?: string;
|
|
857
|
+
/** Cache time in ms */
|
|
858
|
+
cacheTime?: number;
|
|
859
|
+
/** Callback on success */
|
|
860
|
+
onSuccess?: (data: T) => void;
|
|
861
|
+
/** Callback on error */
|
|
862
|
+
onError?: (error: Error) => void;
|
|
863
|
+
}
|
|
864
|
+
interface UseFetchReturn<T> {
|
|
865
|
+
/** Response data */
|
|
866
|
+
data: T | null;
|
|
867
|
+
/** Is loading? */
|
|
868
|
+
loading: boolean;
|
|
869
|
+
/** Error */
|
|
870
|
+
error: Error | null;
|
|
871
|
+
/** Refetch data */
|
|
872
|
+
refetch: () => Promise<T | null>;
|
|
873
|
+
/** Abort current request */
|
|
874
|
+
abort: () => void;
|
|
875
|
+
/** Is fetching? (includes refetch) */
|
|
876
|
+
isFetching: boolean;
|
|
877
|
+
/** HTTP status code */
|
|
878
|
+
status: number | null;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Hook for data fetching with caching and retry support
|
|
882
|
+
* @param url - URL to fetch
|
|
883
|
+
* @param options - Fetch options
|
|
884
|
+
*/
|
|
885
|
+
declare function useFetch<T = unknown>(url: string | null, options?: UseFetchOptions<T>): UseFetchReturn<T>;
|
|
886
|
+
|
|
887
|
+
type ScriptStatus = 'idle' | 'loading' | 'ready' | 'error';
|
|
888
|
+
interface UseScriptOptions {
|
|
889
|
+
/** Should load script immediately (default: true) */
|
|
890
|
+
shouldLoad?: boolean;
|
|
891
|
+
/** Remove script on unmount (default: false) */
|
|
892
|
+
removeOnUnmount?: boolean;
|
|
893
|
+
/** Script attributes */
|
|
894
|
+
attributes?: Record<string, string>;
|
|
895
|
+
}
|
|
896
|
+
interface UseScriptReturn {
|
|
897
|
+
/** Script loading status */
|
|
898
|
+
status: ScriptStatus;
|
|
899
|
+
/** Is script ready? */
|
|
900
|
+
ready: boolean;
|
|
901
|
+
/** Is loading? */
|
|
902
|
+
loading: boolean;
|
|
903
|
+
/** Has error? */
|
|
904
|
+
error: boolean;
|
|
905
|
+
/** Load script manually */
|
|
906
|
+
load: () => void;
|
|
907
|
+
/** Remove script */
|
|
908
|
+
remove: () => void;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Hook to dynamically load external scripts
|
|
912
|
+
* @param src - Script source URL
|
|
913
|
+
* @param options - Configuration options
|
|
914
|
+
*/
|
|
915
|
+
declare function useScript(src: string, options?: UseScriptOptions): UseScriptReturn;
|
|
916
|
+
|
|
917
|
+
interface RenderInfo {
|
|
918
|
+
/** Component name (if provided) */
|
|
919
|
+
name: string;
|
|
920
|
+
/** Total render count */
|
|
921
|
+
renders: number;
|
|
922
|
+
/** Time since last render (ms) */
|
|
923
|
+
sinceLastRender: number;
|
|
924
|
+
/** Timestamp of last render */
|
|
925
|
+
timestamp: number;
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Hook to track render information for debugging
|
|
929
|
+
* @param componentName - Optional component name for identification
|
|
930
|
+
*/
|
|
931
|
+
declare function useRenderInfo(componentName?: string): RenderInfo;
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* Hook to count component renders
|
|
935
|
+
*/
|
|
936
|
+
declare function useRenderCount(): number;
|
|
937
|
+
|
|
938
|
+
interface UseLoggerOptions {
|
|
939
|
+
/** Log props changes */
|
|
940
|
+
logProps?: boolean;
|
|
941
|
+
/** Log lifecycle events */
|
|
942
|
+
logLifecycle?: boolean;
|
|
943
|
+
/** Custom logger function */
|
|
944
|
+
logger?: (...args: unknown[]) => void;
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Hook to log component lifecycle and changes
|
|
948
|
+
* @param componentName - Name of the component
|
|
949
|
+
* @param props - Props to track changes
|
|
950
|
+
* @param options - Configuration options
|
|
951
|
+
*/
|
|
952
|
+
declare function useLogger(componentName: string, props?: Record<string, unknown>, options?: UseLoggerOptions): void;
|
|
953
|
+
|
|
954
|
+
interface Dimensions {
|
|
955
|
+
/** Element width */
|
|
956
|
+
width: number;
|
|
957
|
+
/** Element height */
|
|
958
|
+
height: number;
|
|
959
|
+
/** Top position relative to viewport */
|
|
960
|
+
top: number;
|
|
961
|
+
/** Left position relative to viewport */
|
|
962
|
+
left: number;
|
|
963
|
+
/** Bottom position relative to viewport */
|
|
964
|
+
bottom: number;
|
|
965
|
+
/** Right position relative to viewport */
|
|
966
|
+
right: number;
|
|
967
|
+
/** X position (same as left) */
|
|
968
|
+
x: number;
|
|
969
|
+
/** Y position (same as top) */
|
|
970
|
+
y: number;
|
|
971
|
+
}
|
|
972
|
+
interface UseMeasureReturn<T extends HTMLElement = HTMLElement> {
|
|
973
|
+
/** Ref to attach to element */
|
|
974
|
+
ref: React.RefCallback<T>;
|
|
975
|
+
/** Element dimensions */
|
|
976
|
+
dimensions: Dimensions;
|
|
977
|
+
/** Manually trigger measurement */
|
|
978
|
+
measure: () => void;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Hook to measure element dimensions
|
|
982
|
+
*/
|
|
983
|
+
declare function useMeasure<T extends HTMLElement = HTMLElement>(): UseMeasureReturn<T>;
|
|
984
|
+
|
|
985
|
+
interface UseIntersectionObserverOptions {
|
|
986
|
+
/** Root element (default: viewport) */
|
|
987
|
+
root?: Element | null;
|
|
988
|
+
/** Root margin (default: '0px') */
|
|
989
|
+
rootMargin?: string;
|
|
990
|
+
/** Intersection threshold(s) (default: 0) */
|
|
991
|
+
threshold?: number | number[];
|
|
992
|
+
/** Freeze after first intersection */
|
|
993
|
+
freezeOnceVisible?: boolean;
|
|
994
|
+
/** Initial visibility state */
|
|
995
|
+
initialIsIntersecting?: boolean;
|
|
996
|
+
/** Callback when intersection changes */
|
|
997
|
+
onChange?: (isIntersecting: boolean, entry: IntersectionObserverEntry) => void;
|
|
998
|
+
}
|
|
999
|
+
interface UseIntersectionObserverReturn<T extends Element = Element> {
|
|
1000
|
+
/** Ref to attach to element */
|
|
1001
|
+
ref: React.RefCallback<T>;
|
|
1002
|
+
/** Is element intersecting? */
|
|
1003
|
+
isIntersecting: boolean;
|
|
1004
|
+
/** Full intersection entry */
|
|
1005
|
+
entry: IntersectionObserverEntry | null;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Hook to observe element intersection with viewport
|
|
1009
|
+
* @param options - IntersectionObserver options
|
|
1010
|
+
*/
|
|
1011
|
+
declare function useIntersectionObserver<T extends Element = Element>(options?: UseIntersectionObserverOptions): UseIntersectionObserverReturn<T>;
|
|
1012
|
+
|
|
1013
|
+
type SnackbarSeverity = 'success' | 'error' | 'warning' | 'info';
|
|
1014
|
+
interface SnackbarState {
|
|
1015
|
+
open: boolean;
|
|
1016
|
+
message: string;
|
|
1017
|
+
severity: SnackbarSeverity;
|
|
1018
|
+
autoHideDuration?: number;
|
|
1019
|
+
}
|
|
1020
|
+
interface UseSnackbarReturn {
|
|
1021
|
+
/** Current snackbar state */
|
|
1022
|
+
state: SnackbarState;
|
|
1023
|
+
/** Show snackbar with message */
|
|
1024
|
+
show: (message: string, severity?: SnackbarSeverity, duration?: number) => void;
|
|
1025
|
+
/** Show success snackbar */
|
|
1026
|
+
success: (message: string, duration?: number) => void;
|
|
1027
|
+
/** Show error snackbar */
|
|
1028
|
+
error: (message: string, duration?: number) => void;
|
|
1029
|
+
/** Show warning snackbar */
|
|
1030
|
+
warning: (message: string, duration?: number) => void;
|
|
1031
|
+
/** Show info snackbar */
|
|
1032
|
+
info: (message: string, duration?: number) => void;
|
|
1033
|
+
/** Close snackbar */
|
|
1034
|
+
close: () => void;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Manage snackbar/toast notification state
|
|
1038
|
+
* @param defaultDuration - Default auto-hide duration in ms
|
|
1039
|
+
*/
|
|
1040
|
+
declare function useSnackbar(defaultDuration?: number): UseSnackbarReturn;
|
|
1041
|
+
|
|
1042
|
+
export { type BatteryState, type Dimensions, type GeolocationState, type MousePosition, type NetworkState, type ObjectStateUpdate, type OrientationState, type RenderInfo, type ScriptStatus, type SetValue, type SnackbarSeverity, type SnackbarState, type ThemeMode, type UseContinuousRetryOptions, type UseContinuousRetryReturn, type UseCopyToClipboardReturn, type UseCountdownOptions, type UseCountdownReturn, type UseCounterOptions, type UseCounterReturn, type UseDocumentTitleOptions, type UseFetchOptions, type UseFetchReturn, type UseGeolocationOptions, type UseGeolocationReturn, type UseHistoryStateOptions, type UseHistoryStateReturn, type UseHoverReturn, type UseIdleOptions, type UseIdleReturn, type UseIntersectionObserverOptions, type UseIntersectionObserverReturn, type UseKeyPressOptions, type UseKeyPressReturn, type UseListReturn, type UseLocalStorageOptions, type UseLoggerOptions, type UseLongPressOptions, type UseLongPressReturn, type UseMapReturn, type UseMeasureReturn, type UseMouseOptions, type UseMouseReturn, type UseObjectStateReturn, type UsePageLeaveOptions, type UsePageTitleOptions, type UsePreferredLanguageReturn, type UseQueueReturn, type UseScriptOptions, type UseScriptReturn, type UseSessionStorageOptions, type UseSetReturn, type UseSnackbarReturn, type UseTimeoutReturn, type UseToggleReturn, type UseVisibilityChangeReturn, type UseWindowScrollReturn, type WindowScrollPosition, type WindowSize, useBattery, useClickAway, useContinuousRetry, useCopyToClipboard, useCountdown, useCounter, useDebounce, useDefault, useDocumentTitle, useEventListener, useFavicon, useFetch, useGeolocation, useHistoryState, useHover, useIdle, useIntersectionObserver, useInterval, useIntervalWhen, useIsClient, useIsDesktop, useIsFirstRender, useIsMobile, useIsMobileOrTablet, useIsTablet, useKeyPress, useList, useLocalStorage, useLockBodyScroll, useLogger, useLongPress, useMap, useMeasure, useMediaQuery, useMouse, useNetworkState, useObjectState, useOnClickOutside, useOrientation, usePageLeave, usePageTitle, usePreferredLanguage, usePrevious, useQueue, useRandomInterval, useRenderCount, useRenderInfo, useScript, useSessionStorage, useSet, useSnackbar, useThemeDetector, useThrottle, useTimeout, useToggle, useVisibilityChange, useWindowScroll, useWindowSize };
|