react-js-plugins 3.8.0 → 3.10.0
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
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
**react-js-plugins** package is a lightweight and powerful toolkit for developers, providing reusable solutions for various application requirements. react-js-plugins offers a comprehensive collection of utility functions designed to simplify common development tasks. Key functionalities include form validation, date formatting, array/object manipulation, and exporting data to Excel. Additional features include browser/device detection, storage management, reducers, performance optimization utilities, and string/number formatting tools.
|
|
3
3
|
|
|
4
|
+
## ⚠️ Deprecated Notice
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**❌ Deprecated:** `createPublicInstance and createPrivateInstance` (above version 3)
|
|
7
|
+
**✔️ New Method:** `createAxiosInstance`
|
|
8
|
+
|
|
9
|
+
<!-- **Note: This lightweight and type-safe package is written in TypeScript and offers full support for all utilities across all modern browsers.** -->
|
|
6
10
|
|
|
7
11
|
### **Installation**
|
|
8
12
|
|
|
@@ -32,7 +32,10 @@ interface AxiosConfigProps {
|
|
|
32
32
|
}) => any;
|
|
33
33
|
defaultHeaders?: Record<string, string>;
|
|
34
34
|
onError?: (error: AxiosError) => void;
|
|
35
|
-
onLoaderChange?: (
|
|
35
|
+
onLoaderChange?: (params: {
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
config?: AxiosRequestConfig;
|
|
38
|
+
}) => void;
|
|
36
39
|
}
|
|
37
40
|
export declare const createAxiosInstance: ({ baseURL, timeout, withCredentials, enableDateTransform, enablePrivateMode, enableLoader, getToken, handleAuthError, transformRequest, transformResponse, defaultHeaders, onError, onLoaderChange, }: AxiosConfigProps) => AxiosInstance;
|
|
38
41
|
export {};
|
|
@@ -98,7 +98,7 @@ export var createAxiosInstance = function (_a) {
|
|
|
98
98
|
_d.trys.push([0, 5, , 6]);
|
|
99
99
|
isLoaderEnabled = config.enableLoader !== undefined ? config.enableLoader : enableLoader;
|
|
100
100
|
if (isLoaderEnabled && typeof onLoaderChange === 'function') {
|
|
101
|
-
onLoaderChange(true, config);
|
|
101
|
+
onLoaderChange({ isLoading: true, config: config });
|
|
102
102
|
}
|
|
103
103
|
if ((_b = config.enablePrivateMode) !== null && _b !== void 0 ? _b : enablePrivateMode) {
|
|
104
104
|
token = getToken === null || getToken === void 0 ? void 0 : getToken();
|
|
@@ -128,7 +128,7 @@ export var createAxiosInstance = function (_a) {
|
|
|
128
128
|
error_1 = _d.sent();
|
|
129
129
|
console.error('❌ Request Interceptor Error:', error_1);
|
|
130
130
|
if (typeof onLoaderChange === 'function') {
|
|
131
|
-
onLoaderChange(false, config);
|
|
131
|
+
onLoaderChange({ isLoading: false, config: config });
|
|
132
132
|
}
|
|
133
133
|
return [2 /*return*/, Promise.reject(error_1)];
|
|
134
134
|
case 6: return [2 /*return*/];
|
|
@@ -149,7 +149,7 @@ export var createAxiosInstance = function (_a) {
|
|
|
149
149
|
? response.config.enableLoader
|
|
150
150
|
: enableLoader;
|
|
151
151
|
if (isLoaderEnabled && typeof onLoaderChange === 'function') {
|
|
152
|
-
onLoaderChange(false, response.config);
|
|
152
|
+
onLoaderChange({ isLoading: false, config: response.config });
|
|
153
153
|
}
|
|
154
154
|
if (!(typeof transformResponse === 'function')) return [3 /*break*/, 4];
|
|
155
155
|
result = transformResponse({
|
|
@@ -176,7 +176,7 @@ export var createAxiosInstance = function (_a) {
|
|
|
176
176
|
console.error('❌ Response Transform Error:', error_2);
|
|
177
177
|
isLoaderEnabled = ((_c = response === null || response === void 0 ? void 0 : response.config) === null || _c === void 0 ? void 0 : _c.enableLoader) !== undefined ? response.config.enableLoader : enableLoader;
|
|
178
178
|
if (isLoaderEnabled && typeof onLoaderChange === 'function') {
|
|
179
|
-
onLoaderChange(false, response.config);
|
|
179
|
+
onLoaderChange({ isLoading: false, config: response.config });
|
|
180
180
|
}
|
|
181
181
|
return [2 /*return*/, Promise.reject(error_2)];
|
|
182
182
|
case 6: return [2 /*return*/];
|
|
@@ -191,7 +191,7 @@ export var createAxiosInstance = function (_a) {
|
|
|
191
191
|
config = err.config;
|
|
192
192
|
isLoaderEnabled = (config === null || config === void 0 ? void 0 : config.enableLoader) !== undefined ? config.enableLoader : enableLoader;
|
|
193
193
|
if (isLoaderEnabled && typeof onLoaderChange === 'function') {
|
|
194
|
-
onLoaderChange(false, config);
|
|
194
|
+
onLoaderChange({ isLoading: false, config: config });
|
|
195
195
|
}
|
|
196
196
|
if (typeof onError === 'function') {
|
|
197
197
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-js-plugins",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "A powerful and efficient React utility library designed to enhance application performance by streamlining and simplifying the management of complex asynchronous operations.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|