react-hook-toolkit 1.1.9 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/type.d.ts ADDED
@@ -0,0 +1,286 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import { ReactNode } from 'react';
3
+ export interface DrawerContextValue {
4
+ drawerOpen: boolean;
5
+ openDrawer: () => void;
6
+ closeDrawer: () => void;
7
+ openDrawerInButton: () => void;
8
+ closeDrawerInButton: () => void;
9
+ currentMainMenu?: string;
10
+ setCurrentMainMenu?: (value: string) => void;
11
+ }
12
+ export interface DrawerProviderProps {
13
+ children: ReactNode;
14
+ }
15
+ export interface FileComponentProps {
16
+ primaryKey: string | number;
17
+ filename: string;
18
+ size: string | number;
19
+ onDownload?: any;
20
+ width?: number;
21
+ borderColor?: string;
22
+ fileColor?: 'inherit' | 'primary' | 'secondary' | 'error' | 'disabled' | 'action';
23
+ isDownloading: boolean;
24
+ }
25
+ export interface AlertPropsType {
26
+ type: string;
27
+ msg: string;
28
+ duration?: number;
29
+ }
30
+ export interface DetailsCardProps {
31
+ isLoading?: boolean;
32
+ title: string;
33
+ details: any[];
34
+ spacing?: number;
35
+ boxShadow?: string;
36
+ background?: string;
37
+ loaderType?: 'skeleton' | 'circular';
38
+ displayType?: 'flex' | 'block';
39
+ }
40
+ export interface UploadButtonProps {
41
+ isUpload?: boolean;
42
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
43
+ state?: {
44
+ isUploaded?: boolean;
45
+ isUploadError?: boolean;
46
+ isLoadingUpload?: boolean;
47
+ };
48
+ onFileSelect: (file: File) => void;
49
+ }
50
+ export interface DownloadButtonState {
51
+ isDownloaded?: boolean;
52
+ isDownloadError?: boolean;
53
+ isLoadingDownload?: boolean;
54
+ }
55
+ export interface DownloadFileProps {
56
+ isDownload?: boolean;
57
+ color?: 'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning';
58
+ state?: DownloadButtonState;
59
+ onDownload: () => void;
60
+ }
61
+ type MenuPosition = 'auto' | 'fixed';
62
+ type ThemeMode = 'light' | 'dark';
63
+ export interface ContextMenuProps {
64
+ options: any;
65
+ children: React.ReactNode;
66
+ disabled?: boolean;
67
+ className?: string;
68
+ menuClassName?: string;
69
+ position?: MenuPosition;
70
+ onShow?: () => void;
71
+ onHide?: () => void;
72
+ currentInstance?: any;
73
+ theme?: ThemeMode;
74
+ }
75
+ export interface UndoableHistoryState<T> {
76
+ past: T[];
77
+ present: T;
78
+ future: T[];
79
+ }
80
+ export type HistoryAction<T> = {
81
+ type: 'UNDO';
82
+ } | {
83
+ type: 'REDO';
84
+ } | {
85
+ type: 'CLEAR';
86
+ } | {
87
+ type: 'SET';
88
+ newPresent: T;
89
+ } | {
90
+ type: 'RESET';
91
+ newPresent: T;
92
+ };
93
+ export type UseRecentSearchOptions = {
94
+ key?: string;
95
+ limit?: number;
96
+ uniqueKey?: string;
97
+ excludeEmpty?: boolean;
98
+ };
99
+ export interface UseAxiosResponse<T> {
100
+ data: T | null;
101
+ loading: boolean;
102
+ error: string | null;
103
+ makeRequest: (url: string, method?: string, requestData?: any) => void;
104
+ cancelRequest: () => void;
105
+ }
106
+ export interface UseAxiosConfig extends AxiosRequestConfig {
107
+ baseURL?: string;
108
+ headers?: {
109
+ [key: string]: string;
110
+ };
111
+ }
112
+ export interface FetchState<T> {
113
+ data: T | null;
114
+ loading: boolean;
115
+ error: string | null;
116
+ }
117
+ export interface WindowSize {
118
+ width: number;
119
+ height: number;
120
+ }
121
+ export interface ScrollPosition {
122
+ x: number;
123
+ y: number;
124
+ }
125
+ export interface MousePosition {
126
+ x: number;
127
+ y: number;
128
+ }
129
+ export type IdleStatus = 'idle' | 'pending' | 'success' | 'error';
130
+ export type AsyncFunction<T> = () => Promise<T>;
131
+ export interface UseAsyncReturn<T> {
132
+ execute: () => void;
133
+ status: IdleStatus;
134
+ value: T | null;
135
+ error: Error | null;
136
+ }
137
+ export interface BatteryManager {
138
+ level: number;
139
+ charging: boolean;
140
+ chargingTime: number;
141
+ dischargingTime: number;
142
+ addEventListener(type: string, listener: EventListener | EventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
143
+ removeEventListener(type: string, listener: EventListener | EventListenerObject | null, options?: boolean | EventListenerOptions): void;
144
+ }
145
+ export interface BatteryState {
146
+ supported: boolean;
147
+ loading: boolean;
148
+ level: number | null;
149
+ charging: boolean | null;
150
+ chargingTime: number | null;
151
+ dischargingTime: number | null;
152
+ }
153
+ export interface NavigatorWithBattery extends Navigator {
154
+ getBattery: () => Promise<BatteryManager>;
155
+ }
156
+ export interface HistoryState {
157
+ [key: string]: any;
158
+ }
159
+ export interface UseHistory {
160
+ history: History;
161
+ state: HistoryState | null;
162
+ push: (path: string, state?: HistoryState) => void;
163
+ replace: (path: string, state?: HistoryState) => void;
164
+ goBack: () => void;
165
+ goForward: () => void;
166
+ }
167
+ export interface UseSessionStorage<T> {
168
+ (key: string, initialValue: T): [T, (value: T) => void];
169
+ }
170
+ export interface UseSound {
171
+ play: () => void;
172
+ pause: () => void;
173
+ stop: () => void;
174
+ setVolume: (volume: number) => void;
175
+ isPlaying: boolean;
176
+ error: Error | null;
177
+ }
178
+ export interface TouchPosition {
179
+ x: number | null;
180
+ y: number | null;
181
+ }
182
+ export interface UseTouch {
183
+ (elementRef: React.RefObject<HTMLElement>): {
184
+ touchStart: TouchPosition;
185
+ touchMove: TouchPosition;
186
+ touchEnd: TouchPosition;
187
+ };
188
+ }
189
+ export interface MotionSensorState {
190
+ acceleration: {
191
+ x: number | null;
192
+ y: number | null;
193
+ z: number | null;
194
+ };
195
+ accelerationIncludingGravity: {
196
+ x: number | null;
197
+ y: number | null;
198
+ z: number | null;
199
+ };
200
+ rotationRate: {
201
+ alpha: number | null;
202
+ beta: number | null;
203
+ gamma: number | null;
204
+ };
205
+ interval: number | null;
206
+ }
207
+ export type SpeechOptions = {
208
+ lang: string;
209
+ voice?: SpeechSynthesisVoice;
210
+ rate: number;
211
+ pitch: number;
212
+ volume: number;
213
+ };
214
+ export type IState = PermissionState | '';
215
+ export type IPermissionDescriptor = PermissionDescriptor | (PermissionDescriptor & {
216
+ deviceId?: string;
217
+ }) | (PermissionDescriptor & {
218
+ sysex?: boolean;
219
+ }) | (PermissionDescriptor & {
220
+ userVisibleOnly?: boolean;
221
+ });
222
+ export type ISpeechOptions = Partial<SpeechOptions>;
223
+ export type VoiceInfo = Pick<SpeechSynthesisVoice, 'lang' | 'name'>;
224
+ export type ISpeechState = SpeechOptions & {
225
+ isPlaying: boolean;
226
+ status: string;
227
+ voiceInfo: VoiceInfo;
228
+ };
229
+ export declare enum VoiceStatus {
230
+ init = 0,
231
+ play = 1,
232
+ pause = 2,
233
+ end = 3
234
+ }
235
+ export interface BrowserHistoryState {
236
+ canGoBack: boolean;
237
+ canGoForward: boolean;
238
+ historyLength: number;
239
+ }
240
+ export interface BrowserSettings {
241
+ clearCache: boolean;
242
+ clearCookies: boolean;
243
+ clearLocalStorage: boolean;
244
+ clearSessionStorage: boolean;
245
+ }
246
+ export interface UseBrowserControlsReturn {
247
+ currentUrl: URL;
248
+ currentPath: string;
249
+ currentHash: string;
250
+ currentSearchParams: URLSearchParams;
251
+ goBack: () => void;
252
+ goForward: () => void;
253
+ reload: (hardReload?: boolean, scrollToTop?: boolean) => void;
254
+ navigateTo: (url: string | URL, replace?: boolean) => void;
255
+ clearBrowserData: (settings: Partial<BrowserSettings>) => Promise<void>;
256
+ historyState: BrowserHistoryState;
257
+ isOnline: boolean;
258
+ copyCurrentUrl: () => Promise<void>;
259
+ openNewTab: (url?: string) => void;
260
+ getFaviconUrl: (size?: number) => string;
261
+ getPageTitle: () => string;
262
+ setPageTitle: (title: string) => void;
263
+ isSecureContext: boolean;
264
+ viewportSize: {
265
+ width: number;
266
+ height: number;
267
+ };
268
+ screenSize: {
269
+ width: number;
270
+ height: number;
271
+ };
272
+ enableFullscreen: () => Promise<void>;
273
+ disableFullscreen: () => Promise<void>;
274
+ isFullscreen: boolean;
275
+ printPage: () => void;
276
+ getUserAgent: () => string;
277
+ shareContent: (data: ShareData) => Promise<void>;
278
+ isShareSupported: boolean;
279
+ closeCurrentTab: () => void;
280
+ }
281
+ export interface AnimatedWrapperProps {
282
+ animationClass?: string;
283
+ delay?: any;
284
+ children: React.ReactNode;
285
+ }
286
+ export {};
@@ -0,0 +1,21 @@
1
+ export declare const promise: (time: number) => Promise<unknown>;
2
+ export declare function throttle<T extends (...args: any[]) => void>(func: T, limit: number): T;
3
+ export declare const debounceUtils: <T extends (...args: any[]) => void>(func: T, delay: number) => (...args: Parameters<T>) => void;
4
+ export declare const isBrowser: boolean;
5
+ export declare const isDev: boolean;
6
+ export declare const isObject: (value: unknown) => value is Record<any, any>;
7
+ export declare const isFunction: (value: unknown) => value is (...args: any) => any;
8
+ export declare const isString: (value: unknown) => value is string;
9
+ export declare const isBoolean: (value: unknown) => value is boolean;
10
+ export declare const isNumber: (value: unknown) => value is number;
11
+ export declare const isUndef: (value: unknown) => value is undefined;
12
+ export declare const isAppleDevice: boolean;
13
+ export declare const isNavigator: boolean;
14
+ export declare const getScrollTop: (el: Document | Element) => number;
15
+ export declare const getScrollHeight: (el: Document | Element) => number;
16
+ export declare const getClientHeight: (el: Document | Element) => number;
17
+ export declare function sleep(time: number): Promise<void>;
18
+ export declare function request(req: any): Promise<unknown>;
19
+ export declare const noop: () => void;
20
+ export declare function on<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['addEventListener']> | [string, Function | null, ...any]): void;
21
+ export declare function off<T extends Window | Document | HTMLElement | EventTarget>(obj: T | null, ...args: Parameters<T['removeEventListener']> | [string, Function | null, ...any]): void;
package/package.json CHANGED
@@ -1,61 +1,60 @@
1
- {
2
- "name": "react-hook-toolkit",
3
- "version": "1.1.9",
4
- "description": "A collection of reusable React hooks for modern applications.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "scripts": {
9
- "build": "rollup -c --bundleConfigAsCjs",
10
- "prepare": "npm run build",
11
- "test": "echo \"Error: no test specified\" && exit 1"
12
- },
13
- "license": "MIT",
14
- "engines": {
15
- "node": ">=16.0.0"
16
- },
17
- "peerDependencies": {
18
- "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
19
- "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
20
- },
21
- "devDependencies": {
22
- "@rollup/plugin-commonjs": "^26.0.1",
23
- "@rollup/plugin-json": "^6.1.0",
24
- "@rollup/plugin-node-resolve": "^15.2.3",
25
- "@rollup/plugin-terser": "^0.4.4",
26
- "@rollup/plugin-typescript": "^11.1.6",
27
- "@types/crypto-js": "^4.2.2",
28
- "@types/node": "^22.15.19",
29
- "@types/react": "^18.2.0",
30
- "@types/react-dom": "^18.2.0",
31
- "postcss": "^8.5.3",
32
- "react": "^18.2.0",
33
- "react-dom": "^18.2.0",
34
- "rollup": "^4.18.1",
35
- "rollup-plugin-dts": "^6.1.1",
36
- "rollup-plugin-peer-deps-external": "^2.2.4",
37
- "rollup-plugin-postcss": "^4.0.2",
38
- "tslib": "^2.6.3",
39
- "typescript": "^5.5.3"
40
- },
41
- "dependencies": {
42
- "@emotion/react": "^11.14.0",
43
- "@emotion/styled": "^11.14.0",
44
- "@mui/icons-material": "^5.17.1",
45
- "@mui/material": "^5.17.1",
46
- "animate.css": "^4.1.1",
47
- "axios": "^1.7.8",
48
- "nprogress": "^0.2.0",
49
- "react-error-boundary": "^4.0.13"
50
- },
51
- "keywords": [
52
- "react",
53
- "react-hooks",
54
- "custom-hooks",
55
- "hooks",
56
- "utilities"
57
- ],
58
- "files": [
59
- "dist"
60
- ]
61
- }
1
+ {
2
+ "name": "react-hook-toolkit",
3
+ "version": "1.2.1",
4
+ "description": "A collection of reusable React hooks for modern applications.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "rollup -c --bundleConfigAsCjs",
10
+ "prepare": "npm run build",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "author": "Shivaji & Shyamal",
14
+ "license": "MIT",
15
+ "peerDependencies": {
16
+ "react": ">=16.8.0",
17
+ "react-dom": ">=16.8.0"
18
+ },
19
+ "devDependencies": {
20
+ "@rollup/plugin-commonjs": "^26.0.1",
21
+ "@rollup/plugin-json": "^6.1.0",
22
+ "@rollup/plugin-node-resolve": "^15.2.3",
23
+ "@rollup/plugin-terser": "^0.4.4",
24
+ "@rollup/plugin-typescript": "^11.1.6",
25
+ "@types/crypto-js": "^4.2.2",
26
+ "postcss": "^8.5.3",
27
+ "@types/react": "18.2.20",
28
+ "@types/react-dom": "18.2.7",
29
+ "rollup": "^4.18.1",
30
+ "rollup-plugin-dts": "^6.1.1",
31
+ "rollup-plugin-postcss": "^4.0.2",
32
+ "rollup-plugin-peer-deps-external": "^2.2.4",
33
+ "@types/node": "^22.13.10",
34
+ "@types/nprogress": "^0.2.3",
35
+ "tslib": "^2.6.3",
36
+ "typescript": "^5.2.2"
37
+ },
38
+ "dependencies": {
39
+ "@emotion/react": "^11.14.0",
40
+ "@emotion/styled": "^11.14.0",
41
+ "@mui/icons-material": "5.14.0",
42
+ "@mui/material": "^5.14.0",
43
+ "animate.css": "^4.1.1",
44
+ "axios": "^1.7.8",
45
+ "nprogress": "^0.2.0",
46
+ "react": "^18.2.0",
47
+ "react-dom": "^18.2.0",
48
+ "react-error-boundary": "^4.0.13"
49
+ },
50
+ "keywords": [
51
+ "react",
52
+ "react-hooks",
53
+ "custom-hooks",
54
+ "hooks",
55
+ "utilities"
56
+ ],
57
+ "files": [
58
+ "dist"
59
+ ]
60
+ }