react-hook-toolkit 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +582 -15
- package/dist/index.js +209 -17
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +209 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -29
- package/LICENSE +0 -35
- package/dist/chunk1213/chunk158261.d.ts +0 -16
- package/dist/chunk1213/chunk158261.js +0 -41
- package/dist/chunk1415/chunk143.d.ts +0 -20
- package/dist/chunk1415/chunk143.js +0 -58
- package/dist/chunk1516/chunk0021.d.ts +0 -109
- package/dist/chunk1516/chunk0021.js +0 -700
- package/dist/chunk1516/chunk0022.d.ts +0 -2
- package/dist/chunk1516/chunk0022.js +0 -381
- package/dist/chunk1516/chunk613852.d.ts +0 -10
- package/dist/chunk1516/chunk613852.js +0 -299
- package/dist/chunk1516/chunk726433.d.ts +0 -58
- package/dist/chunk1516/chunk726433.js +0 -621
- package/dist/chunk1516/chunk940514.d.ts +0 -93
- package/dist/chunk1516/chunk940514.js +0 -817
- package/dist/chunk1617/chunk613555.d.ts +0 -23
- package/dist/chunk1617/chunk613555.js +0 -115
- package/dist/chunk1617/chunk613556.d.ts +0 -4
- package/dist/chunk1617/chunk613556.js +0 -145
- package/dist/chunk1617/chunk613557.d.ts +0 -3
- package/dist/chunk1617/chunk613557.js +0 -7
- package/dist/type.d.ts +0 -301
- package/dist/type.js +0 -7
- package/dist/utils.d.ts +0 -21
- package/dist/utils.js +0 -104
package/package.json
CHANGED
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hook-toolkit",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "A collection of reusable React hooks for modern applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
8
|
"scripts": {
|
|
12
|
-
"build": "
|
|
9
|
+
"build": "rollup -c --bundleConfigAsCjs",
|
|
10
|
+
"prepare": "npm run build",
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
12
|
},
|
|
14
|
-
"
|
|
15
|
-
"custom hooks",
|
|
16
|
-
"react utilities",
|
|
17
|
-
"react hooks",
|
|
18
|
-
"react lifecycle",
|
|
19
|
-
"browser events",
|
|
20
|
-
"dom interactions",
|
|
21
|
-
"reusable logic",
|
|
22
|
-
"state management",
|
|
23
|
-
"responsive design",
|
|
24
|
-
"accessibility features",
|
|
25
|
-
"event handling",
|
|
26
|
-
"window events",
|
|
27
|
-
"component cleanup",
|
|
28
|
-
"UI optimization",
|
|
29
|
-
"effect management",
|
|
30
|
-
"cross-browser support",
|
|
31
|
-
"react development"
|
|
32
|
-
],
|
|
13
|
+
"author": "Shivaji & Shyamal",
|
|
33
14
|
"license": "MIT",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
17
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
18
|
+
},
|
|
34
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
|
+
"axios": "^1.7.7",
|
|
27
|
+
"postcss": "^8.5.3",
|
|
28
|
+
"rollup": "^4.18.1",
|
|
29
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
30
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
31
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
35
32
|
"@types/draft-js": "^0.11.18",
|
|
36
33
|
"@types/draftjs-to-html": "^0.8.4",
|
|
37
34
|
"@types/html-to-draftjs": "^1.5.0",
|
|
@@ -45,8 +42,8 @@
|
|
|
45
42
|
"dependencies": {
|
|
46
43
|
"@emotion/react": "^11.14.0",
|
|
47
44
|
"@emotion/styled": "^11.14.0",
|
|
48
|
-
"@mui/
|
|
49
|
-
"@mui/material": "^5.
|
|
45
|
+
"@mui/material": "^5.17.1",
|
|
46
|
+
"@mui/icons-material": "^5.17.1",
|
|
50
47
|
"animate.css": "^4.1.1",
|
|
51
48
|
"axios": "^1.7.8",
|
|
52
49
|
"draft-js": "^0.11.7",
|
|
@@ -56,5 +53,15 @@
|
|
|
56
53
|
"react": "^18.2.0",
|
|
57
54
|
"react-draft-wysiwyg": "^1.15.0",
|
|
58
55
|
"react-error-boundary": "^4.0.13"
|
|
59
|
-
}
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"react",
|
|
59
|
+
"react-hooks",
|
|
60
|
+
"custom-hooks",
|
|
61
|
+
"hooks",
|
|
62
|
+
"utilities"
|
|
63
|
+
],
|
|
64
|
+
"files": [
|
|
65
|
+
"dist"
|
|
66
|
+
]
|
|
60
67
|
}
|
package/LICENSE
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright © 2025 Shivaji Surwase. All rights reserved.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
|
|
7
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
|
|
11
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
|
|
13
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
-
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
|
|
20
|
-
copies or substantial portions of the Software.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
|
|
25
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
|
|
27
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
-
|
|
29
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
-
|
|
31
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
-
|
|
33
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
34
|
-
|
|
35
|
-
SOFTWARE.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FC, ReactNode } from 'react';
|
|
2
|
-
export interface DrawerContextValue {
|
|
3
|
-
drawerOpen: boolean;
|
|
4
|
-
openDrawer: () => void;
|
|
5
|
-
closeDrawer: () => void;
|
|
6
|
-
openDrawerInButton: () => void;
|
|
7
|
-
closeDrawerInButton: () => void;
|
|
8
|
-
currentMainMenu?: string;
|
|
9
|
-
setCurrentMainMenu?: (value: string) => void;
|
|
10
|
-
}
|
|
11
|
-
interface DrawerProviderProps {
|
|
12
|
-
children?: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
declare const DrawerContext: import("react").Context<DrawerContextValue>;
|
|
15
|
-
export declare const DrawerProvider: FC<DrawerProviderProps>;
|
|
16
|
-
export default DrawerContext;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useState } from 'react';
|
|
3
|
-
var DrawerContext = createContext({
|
|
4
|
-
drawerOpen: false,
|
|
5
|
-
openDrawer: function () { },
|
|
6
|
-
closeDrawer: function () { },
|
|
7
|
-
openDrawerInButton: function () { },
|
|
8
|
-
closeDrawerInButton: function () { },
|
|
9
|
-
currentMainMenu: '',
|
|
10
|
-
setCurrentMainMenu: function () { },
|
|
11
|
-
});
|
|
12
|
-
export var DrawerProvider = function (props) {
|
|
13
|
-
var children = props.children;
|
|
14
|
-
var _a = useState(true), drawerOpen = _a[0], setDrawer = _a[1];
|
|
15
|
-
var _b = useState(''), currentMainMenu = _b[0], setCurrOpenMenu = _b[1];
|
|
16
|
-
var openDrawer = function () {
|
|
17
|
-
setDrawer(true);
|
|
18
|
-
};
|
|
19
|
-
var closeDrawer = function () {
|
|
20
|
-
setDrawer(false);
|
|
21
|
-
};
|
|
22
|
-
var openDrawerInButton = function () {
|
|
23
|
-
setDrawer(false);
|
|
24
|
-
};
|
|
25
|
-
var closeDrawerInButton = function () {
|
|
26
|
-
setDrawer(true);
|
|
27
|
-
};
|
|
28
|
-
var setCurrentMainMenu = function (value) {
|
|
29
|
-
setCurrOpenMenu(value);
|
|
30
|
-
};
|
|
31
|
-
return (_jsx(DrawerContext.Provider, { value: {
|
|
32
|
-
drawerOpen: drawerOpen,
|
|
33
|
-
openDrawer: openDrawer,
|
|
34
|
-
closeDrawer: closeDrawer,
|
|
35
|
-
openDrawerInButton: openDrawerInButton,
|
|
36
|
-
closeDrawerInButton: closeDrawerInButton,
|
|
37
|
-
currentMainMenu: currentMainMenu,
|
|
38
|
-
setCurrentMainMenu: setCurrentMainMenu,
|
|
39
|
-
}, children: children }));
|
|
40
|
-
};
|
|
41
|
-
export default DrawerContext;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license HEXE
|
|
3
|
-
* Copyright (c) 2020-2024 Shivaji & Collaborators
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import React from 'react';
|
|
8
|
-
type HookFunction = () => any;
|
|
9
|
-
declare class HEXE {
|
|
10
|
-
private hs;
|
|
11
|
-
private ss;
|
|
12
|
-
constructor();
|
|
13
|
-
setHook(name: string, hookFunction: HookFunction): this;
|
|
14
|
-
private putHooks;
|
|
15
|
-
component(): React.FC;
|
|
16
|
-
getHook(name: string): any;
|
|
17
|
-
}
|
|
18
|
-
declare const ReactHooksWrapper: React.FC<{}>;
|
|
19
|
-
declare const getHook: (name: string) => any, setHook: (name: string, hookFunction: HookFunction) => HEXE;
|
|
20
|
-
export { ReactHooksWrapper, getHook, setHook };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license HEXE
|
|
3
|
-
* Copyright (c) 2020-2024 Shivaji & Collaborators
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import React from 'react';
|
|
8
|
-
var HEXE = /** @class */ (function () {
|
|
9
|
-
function HEXE() {
|
|
10
|
-
this.hs = {};
|
|
11
|
-
this.ss = {};
|
|
12
|
-
this.setHook = this.setHook.bind(this);
|
|
13
|
-
this.getHook = this.getHook.bind(this);
|
|
14
|
-
this.putHooks = this.putHooks.bind(this);
|
|
15
|
-
}
|
|
16
|
-
HEXE.prototype.setHook = function (name, hookFunction) {
|
|
17
|
-
[
|
|
18
|
-
{ value: name, id: 'name', type: 'string' },
|
|
19
|
-
{ value: hookFunction, id: 'hook', type: 'function' },
|
|
20
|
-
].forEach(function (_a) {
|
|
21
|
-
var value = _a.value, id = _a.id, type = _a.type;
|
|
22
|
-
if (type === 'string' && typeof value !== 'string') {
|
|
23
|
-
throw new TypeError("\"".concat(id, "\" expected to be of type ").concat(type));
|
|
24
|
-
}
|
|
25
|
-
if (type === 'function' && typeof value !== 'function') {
|
|
26
|
-
throw new TypeError("\"".concat(id, "\" expected to be of type ").concat(type));
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
this.hs[name] = {
|
|
30
|
-
name: name,
|
|
31
|
-
hook: hookFunction,
|
|
32
|
-
};
|
|
33
|
-
return this;
|
|
34
|
-
};
|
|
35
|
-
HEXE.prototype.putHooks = function (name, value) {
|
|
36
|
-
this.ss[name] = value;
|
|
37
|
-
};
|
|
38
|
-
HEXE.prototype.component = function () {
|
|
39
|
-
var _this = this;
|
|
40
|
-
/* Author: Shivaji & Shyamal */
|
|
41
|
-
var Component = function () {
|
|
42
|
-
Object.values(_this.hs).forEach(function (_a) {
|
|
43
|
-
var name = _a.name, hook = _a.hook;
|
|
44
|
-
_this.putHooks(name, hook());
|
|
45
|
-
});
|
|
46
|
-
return /*#__PURE__*/ React.createElement(React.Fragment, null);
|
|
47
|
-
};
|
|
48
|
-
return Component;
|
|
49
|
-
};
|
|
50
|
-
HEXE.prototype.getHook = function (name) {
|
|
51
|
-
return this.ss[name];
|
|
52
|
-
};
|
|
53
|
-
return HEXE;
|
|
54
|
-
}());
|
|
55
|
-
var o = new HEXE();
|
|
56
|
-
var ReactHooksWrapper = o.component();
|
|
57
|
-
var getHook = o.getHook, setHook = o.setHook;
|
|
58
|
-
export { ReactHooksWrapper, getHook, setHook };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { BatteryState, UseHistory, UseSessionStorage, UseSound, UseTouch } from '../type';
|
|
2
|
-
export declare function useGeoLocation(): {
|
|
3
|
-
position: GeolocationPosition | null;
|
|
4
|
-
error: Error | null;
|
|
5
|
-
};
|
|
6
|
-
export declare function useTimer(initialTime: number): {
|
|
7
|
-
time: number;
|
|
8
|
-
error: Error | null;
|
|
9
|
-
};
|
|
10
|
-
export declare function useIsMounted(): boolean;
|
|
11
|
-
export declare function useCss(css: string): {
|
|
12
|
-
error: Error | null;
|
|
13
|
-
};
|
|
14
|
-
export declare function useSpeak(text: string): {
|
|
15
|
-
speak: () => void;
|
|
16
|
-
error: Error | null;
|
|
17
|
-
};
|
|
18
|
-
export declare function useCountUp(target: number, duration: number): {
|
|
19
|
-
count: number;
|
|
20
|
-
error: Error | null;
|
|
21
|
-
};
|
|
22
|
-
export declare function useCountDown(start: number): {
|
|
23
|
-
count: number;
|
|
24
|
-
error: Error | null;
|
|
25
|
-
};
|
|
26
|
-
export declare const useBattery: () => BatteryState;
|
|
27
|
-
export declare const useEventListener: (eventName: string, handler: (event: Event) => void, elementRef?: React.RefObject<HTMLElement>, options?: boolean | AddEventListenerOptions) => void;
|
|
28
|
-
export declare const useHistory: () => UseHistory;
|
|
29
|
-
interface UsePreferredLanguage {
|
|
30
|
-
language: string;
|
|
31
|
-
languages: Array<string>;
|
|
32
|
-
isSupported: boolean;
|
|
33
|
-
}
|
|
34
|
-
export declare const usePreferredLanguage: () => UsePreferredLanguage;
|
|
35
|
-
export declare const useSessionStorage: UseSessionStorage<any>;
|
|
36
|
-
export declare const useSound: (url: string) => UseSound;
|
|
37
|
-
export declare const useTouch: UseTouch;
|
|
38
|
-
export declare const useUpdateEffect: (effect: React.EffectCallback, deps: React.DependencyList) => void;
|
|
39
|
-
export declare const usePersistedForm: <T>(key: string, initialValue: T) => [T, (value: T) => void];
|
|
40
|
-
export declare const useCrossFieldValidation: <T extends Record<string, any>>(validate: (values: T) => Record<keyof T, string | null>) => {
|
|
41
|
-
errors: Record<keyof T, string | null>;
|
|
42
|
-
validateFields: (values: T) => boolean;
|
|
43
|
-
};
|
|
44
|
-
export declare const useFieldArray: <T>(initialValue: T[]) => {
|
|
45
|
-
fields: T[];
|
|
46
|
-
append: (item: T) => void;
|
|
47
|
-
remove: (index: number) => void;
|
|
48
|
-
update: (index: number, item: T) => void;
|
|
49
|
-
};
|
|
50
|
-
type SubmitHandler<T> = (data: T) => Promise<void>;
|
|
51
|
-
export declare const useFormSubmit: <T>(handler: SubmitHandler<T>) => {
|
|
52
|
-
handleSubmit: (data: T) => Promise<void>;
|
|
53
|
-
isSubmitting: boolean;
|
|
54
|
-
submitError: string | null;
|
|
55
|
-
};
|
|
56
|
-
export declare const useSmartForm: <T extends Record<string, any>>(initialValues: T, storageKey?: string) => {
|
|
57
|
-
values: T;
|
|
58
|
-
handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
59
|
-
setValues: import("react").Dispatch<import("react").SetStateAction<T>>;
|
|
60
|
-
dirty: boolean;
|
|
61
|
-
};
|
|
62
|
-
export declare const useUndo: <T>(initialState: T) => {
|
|
63
|
-
state: T;
|
|
64
|
-
setState: (newState: T) => void;
|
|
65
|
-
undo: () => false | void;
|
|
66
|
-
redo: () => false | void;
|
|
67
|
-
canUndo: boolean;
|
|
68
|
-
canRedo: boolean;
|
|
69
|
-
};
|
|
70
|
-
export declare const useFormWizard: <T extends Record<string, any>>(steps: {
|
|
71
|
-
validate?: (values: T) => Record<string, string>;
|
|
72
|
-
component: React.FC<{
|
|
73
|
-
values: T;
|
|
74
|
-
setValues: (v: T) => void;
|
|
75
|
-
}>;
|
|
76
|
-
}[], initialValues: T) => {
|
|
77
|
-
currentStep: number;
|
|
78
|
-
CurrentStep: import("react").FC<{
|
|
79
|
-
values: T;
|
|
80
|
-
setValues: (v: T) => void;
|
|
81
|
-
}>;
|
|
82
|
-
values: T;
|
|
83
|
-
setValues: import("react").Dispatch<import("react").SetStateAction<T>>;
|
|
84
|
-
next: () => void;
|
|
85
|
-
prev: () => void;
|
|
86
|
-
errors: Record<string, string>;
|
|
87
|
-
isFirstStep: boolean;
|
|
88
|
-
isLastStep: boolean;
|
|
89
|
-
};
|
|
90
|
-
export declare const createOptimizedContext: <T>() => readonly [import("react").Provider<T | undefined>, <U>(selector: (value: T) => U) => U];
|
|
91
|
-
export declare const useWebSocket: <T>(url: string, onMessage?: (data: T) => void) => {
|
|
92
|
-
data: T | null;
|
|
93
|
-
send: (message: any) => void;
|
|
94
|
-
isConnected: boolean;
|
|
95
|
-
};
|
|
96
|
-
export declare const useDragReorder: <T>(initialItems: T[]) => {
|
|
97
|
-
items: T[];
|
|
98
|
-
handleDragStart: (index: number) => void;
|
|
99
|
-
handleDragEnter: (index: number) => void;
|
|
100
|
-
handleDrop: () => void;
|
|
101
|
-
};
|
|
102
|
-
export declare const useInfiniteScroll: <T>(fetchData: (page: number) => Promise<T[]>, initialData?: T[]) => {
|
|
103
|
-
data: T[];
|
|
104
|
-
loading: boolean;
|
|
105
|
-
hasMore: boolean;
|
|
106
|
-
lastElementRef: (node: HTMLElement | null) => void;
|
|
107
|
-
};
|
|
108
|
-
export declare const useEventListeners: (eventType: string, handler: (event: Event) => void, element?: HTMLElement | Window, options?: AddEventListenerOptions) => void;
|
|
109
|
-
export {};
|