react-hook-toolkit 1.1.5 → 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/package.json CHANGED
@@ -1,37 +1,34 @@
1
1
  {
2
2
  "name": "react-hook-toolkit",
3
- "version": "1.1.5",
4
- "description": "Ultimate package for React developers, offering a powerful collection of hooks and components to enhance their development experience.",
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.js",
6
+ "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
8
  "scripts": {
12
- "build": "tsc"
9
+ "build": "rollup -c --bundleConfigAsCjs",
10
+ "prepare": "npm run build",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
13
12
  },
14
- "keywords": [
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/icons-material": "^7.0.1",
49
- "@mui/material": "^5.14.0",
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,17 +0,0 @@
1
- import { AxiosInstance, AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
2
- interface AxiosConfigProps {
3
- baseURL: string;
4
- handleAuthError?: (axiosInstance: AxiosInstance, originalRequest: AxiosRequestConfig, err: AxiosError) => Promise<AxiosResponse>;
5
- timeout: number;
6
- }
7
- export declare const privateAxios: ({ baseURL, handleAuthError, timeout }: AxiosConfigProps) => AxiosInstance;
8
- interface AxiosNoAuthConfigProps {
9
- baseURL: string;
10
- timeout: number;
11
- }
12
- export declare const publicAxios: ({ baseURL, timeout }: AxiosNoAuthConfigProps) => AxiosInstance;
13
- declare const _default: {
14
- privateAxios: ({ baseURL, handleAuthError, timeout }: AxiosConfigProps) => AxiosInstance;
15
- publicAxios: ({ baseURL, timeout }: AxiosNoAuthConfigProps) => AxiosInstance;
16
- };
17
- export default _default;
@@ -1,121 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
38
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
39
- if (ar || !(i in from)) {
40
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
41
- ar[i] = from[i];
42
- }
43
- }
44
- return to.concat(ar || Array.prototype.slice.call(from));
45
- };
46
- import axios from 'axios';
47
- function formatDateWithTimezoneOffset(date) {
48
- if (!(date instanceof Date))
49
- return null;
50
- var pad = function (n) { return String(n).padStart(2, '0'); };
51
- var year = date.getFullYear();
52
- var month = pad(date.getMonth() + 1);
53
- var day = pad(date.getDate());
54
- var hours = pad(date.getHours());
55
- var minutes = pad(date.getMinutes());
56
- var seconds = pad(date.getSeconds());
57
- var timezoneOffset = -date.getTimezoneOffset(); // in minutes
58
- var offsetSign = timezoneOffset >= 0 ? '+' : '-';
59
- var offsetHours = pad(Math.floor(Math.abs(timezoneOffset) / 60));
60
- var offsetMinutes = pad(Math.abs(timezoneOffset) % 60);
61
- return "".concat(year, "-").concat(month, "-").concat(day, "T").concat(hours, ":").concat(minutes, ":").concat(seconds).concat(offsetSign).concat(offsetHours, ":").concat(offsetMinutes);
62
- }
63
- var dateTransformer = function (data) {
64
- if (data instanceof Date) {
65
- return formatDateWithTimezoneOffset(data);
66
- }
67
- if (Array.isArray(data)) {
68
- return data.map(dateTransformer);
69
- }
70
- if (typeof data === 'object' && data !== null) {
71
- return Object.fromEntries(Object.entries(data).map(function (_a) {
72
- var key = _a[0], value = _a[1];
73
- return [key, dateTransformer(value)];
74
- }));
75
- }
76
- return data;
77
- };
78
- export var privateAxios = function (_a) {
79
- var baseURL = _a.baseURL, handleAuthError = _a.handleAuthError, timeout = _a.timeout;
80
- var axiosInstance = axios.create({
81
- baseURL: baseURL,
82
- timeout: timeout,
83
- transformRequest: __spreadArray([dateTransformer], axios.defaults.transformRequest, true),
84
- });
85
- axiosInstance.interceptors.response.use(function (res) { return res; }, function (err) { return __awaiter(void 0, void 0, void 0, function () {
86
- var originalRequest;
87
- var _a, _b, _c, _d;
88
- return __generator(this, function (_e) {
89
- switch (_e.label) {
90
- case 0:
91
- if (err.message === 'Network Error') {
92
- return [2 /*return*/, Promise.reject({ title: 'Network Error: Please check your connection.' })];
93
- }
94
- originalRequest = err.config;
95
- if (!(err.response && err.response.status === 401 && !originalRequest._retry)) return [3 /*break*/, 2];
96
- originalRequest._retry = true;
97
- if (!(typeof handleAuthError === 'function')) return [3 /*break*/, 2];
98
- return [4 /*yield*/, handleAuthError(axiosInstance, originalRequest, err)];
99
- case 1: return [2 /*return*/, _e.sent()];
100
- case 2:
101
- if (((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) === 500) {
102
- return [2 /*return*/, Promise.reject((_b = err.response.data) !== null && _b !== void 0 ? _b : { title: 'Internal Server Error' })];
103
- }
104
- return [2 /*return*/, Promise.reject((_d = (_c = err.response) === null || _c === void 0 ? void 0 : _c.data) !== null && _d !== void 0 ? _d : { title: 'Something went wrong' })];
105
- }
106
- });
107
- }); });
108
- return axiosInstance;
109
- };
110
- export var publicAxios = function (_a) {
111
- var baseURL = _a.baseURL, timeout = _a.timeout;
112
- var axiosNoAuthInstance = axios.create({
113
- baseURL: baseURL,
114
- timeout: timeout,
115
- });
116
- axiosNoAuthInstance.interceptors.response.use(function (response) { return response; }, function (error) {
117
- return Promise.reject((error.response && error.response.data) || { title: 'Something went wrong' });
118
- });
119
- return axiosNoAuthInstance;
120
- };
121
- export default { privateAxios: privateAxios, publicAxios: publicAxios };
@@ -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 {};