react-hook-toolkit 1.2.0 → 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/package.json CHANGED
@@ -1,52 +1,60 @@
1
- {
2
- "name": "react-hook-toolkit",
3
- "version": "1.2.0",
4
- "description": "Ultimate package for React developers, offering a powerful collection of hooks and components to enhance their development experience.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
- "scripts": {
12
- "build": "tsc"
13
- },
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
- ],
33
- "license": "MIT",
34
- "devDependencies": {
35
- "@types/node": "^22.13.10",
36
- "@types/nprogress": "^0.2.3",
37
- "@types/react": "^18.2.14",
38
- "tslib": "^2.6.3",
39
- "typescript": "^5.2.2"
40
- },
41
- "dependencies": {
42
- "@emotion/react": "^11.14.0",
43
- "@emotion/styled": "^11.14.0",
44
- "@mui/icons-material": "^7.0.1",
45
- "@mui/material": "^5.14.0",
46
- "animate.css": "^4.1.1",
47
- "axios": "^1.7.8",
48
- "nprogress": "^0.2.0",
49
- "react": "^18.2.0",
50
- "react-error-boundary": "^4.0.13"
51
- }
52
- }
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
+ }
@@ -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,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,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 };