@bluemarble/bm-components 1.9.1 → 1.9.3
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.js +45 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4209,44 +4209,50 @@ function useFormHelper() {
|
|
|
4209
4209
|
const { createAlert } = alertProps;
|
|
4210
4210
|
const { setLoading } = loadingProps;
|
|
4211
4211
|
const sourceRef = useRef3(new AbortController());
|
|
4212
|
-
const onSubmitWrapper = (
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4212
|
+
const onSubmitWrapper = useCallback3(
|
|
4213
|
+
(fn, { name }) => {
|
|
4214
|
+
return (fields, methods) => __async(this, null, function* () {
|
|
4215
|
+
const LOADING_NAME = name;
|
|
4216
|
+
setLoading(LOADING_NAME);
|
|
4217
|
+
try {
|
|
4218
|
+
yield fn(fields, methods);
|
|
4219
|
+
} catch (error) {
|
|
4220
|
+
errorHandler(error, methods.setErrors);
|
|
4221
|
+
} finally {
|
|
4222
|
+
setLoading(LOADING_NAME, true);
|
|
4223
|
+
}
|
|
4224
|
+
});
|
|
4225
|
+
},
|
|
4226
|
+
[setLoading]
|
|
4227
|
+
);
|
|
4228
|
+
const onRequestWrapper = useCallback3(
|
|
4229
|
+
(fn, { name }) => {
|
|
4230
|
+
return (...params) => __async(this, null, function* () {
|
|
4231
|
+
const LOADING_NAME = name;
|
|
4232
|
+
setLoading(LOADING_NAME);
|
|
4233
|
+
api.interceptors.request.use(
|
|
4234
|
+
(config) => {
|
|
4235
|
+
if (!config.signal && sourceRef.current && config.method === "get") {
|
|
4236
|
+
config.signal = sourceRef.current.signal;
|
|
4237
|
+
}
|
|
4238
|
+
return config;
|
|
4239
|
+
},
|
|
4240
|
+
(error) => {
|
|
4241
|
+
return Promise.reject(error);
|
|
4233
4242
|
}
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
return
|
|
4243
|
+
);
|
|
4244
|
+
try {
|
|
4245
|
+
const response = yield fn(...params);
|
|
4246
|
+
return response;
|
|
4247
|
+
} catch (error) {
|
|
4248
|
+
errorHandler(error);
|
|
4249
|
+
} finally {
|
|
4250
|
+
setLoading(LOADING_NAME, true);
|
|
4238
4251
|
}
|
|
4239
|
-
);
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
} catch (error) {
|
|
4244
|
-
errorHandler(error);
|
|
4245
|
-
} finally {
|
|
4246
|
-
setLoading(LOADING_NAME, true);
|
|
4247
|
-
}
|
|
4248
|
-
});
|
|
4249
|
-
};
|
|
4252
|
+
});
|
|
4253
|
+
},
|
|
4254
|
+
[setLoading, api]
|
|
4255
|
+
);
|
|
4250
4256
|
const errorHandler = useCallback3(
|
|
4251
4257
|
(error, callback) => {
|
|
4252
4258
|
if ((error == null ? void 0 : error.message) === "cancel.navigation")
|
|
@@ -4592,7 +4598,7 @@ var AuthHelper = class {
|
|
|
4592
4598
|
};
|
|
4593
4599
|
|
|
4594
4600
|
// src/hooks/useGrid.ts
|
|
4595
|
-
import { useCallback as useCallback5, useMemo as useMemo3, useState as useState6 } from "react";
|
|
4601
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useMemo as useMemo3, useState as useState6 } from "react";
|
|
4596
4602
|
|
|
4597
4603
|
// src/hooks/useFilter.ts
|
|
4598
4604
|
import moment2 from "moment";
|
|
@@ -4797,6 +4803,9 @@ function useGrid({
|
|
|
4797
4803
|
return sortedData.slice(startPage, endPage);
|
|
4798
4804
|
}, [filteredData, currentPage, rowsPerPage, sortData]);
|
|
4799
4805
|
const totalNumberOfPages = Math.ceil(filteredData.length / rowsPerPage) - 1;
|
|
4806
|
+
useEffect5(() => {
|
|
4807
|
+
setDefaultData(externalDefaultData);
|
|
4808
|
+
}, [externalDefaultData]);
|
|
4800
4809
|
return {
|
|
4801
4810
|
data: displayData,
|
|
4802
4811
|
updatedTimes,
|
|
@@ -4850,7 +4859,7 @@ function createSearch(options) {
|
|
|
4850
4859
|
}
|
|
4851
4860
|
|
|
4852
4861
|
// src/hooks/useAsyncGrid.ts
|
|
4853
|
-
import { useCallback as useCallback6, useEffect as
|
|
4862
|
+
import { useCallback as useCallback6, useEffect as useEffect6, useState as useState7 } from "react";
|
|
4854
4863
|
function useAsyncGrid({
|
|
4855
4864
|
columns,
|
|
4856
4865
|
filters = [],
|
|
@@ -5001,7 +5010,7 @@ function useAsyncGrid({
|
|
|
5001
5010
|
[updateGridContent, totalNumberOfItems, sortedBy, currentPage]
|
|
5002
5011
|
);
|
|
5003
5012
|
const displayData = defaultData;
|
|
5004
|
-
|
|
5013
|
+
useEffect6(() => {
|
|
5005
5014
|
updateGridContent({ page: 0, sortedBy: [], rowsPerPage });
|
|
5006
5015
|
}, [updateGridContent, rowsPerPage]);
|
|
5007
5016
|
return {
|
|
@@ -5024,9 +5033,9 @@ function useAsyncGrid({
|
|
|
5024
5033
|
}
|
|
5025
5034
|
|
|
5026
5035
|
// src/hooks/useEvent.ts
|
|
5027
|
-
import { useEffect as
|
|
5036
|
+
import { useEffect as useEffect7 } from "react";
|
|
5028
5037
|
function useEvent(event, handler, passive = false) {
|
|
5029
|
-
|
|
5038
|
+
useEffect7(() => {
|
|
5030
5039
|
window.addEventListener(event, handler, passive);
|
|
5031
5040
|
return function cleanup() {
|
|
5032
5041
|
window.removeEventListener(event, handler);
|
|
@@ -5038,7 +5047,7 @@ function useEvent(event, handler, passive = false) {
|
|
|
5038
5047
|
import React27, { useCallback as useCallback7 } from "react";
|
|
5039
5048
|
import {
|
|
5040
5049
|
createContext as createContext3,
|
|
5041
|
-
useEffect as
|
|
5050
|
+
useEffect as useEffect8,
|
|
5042
5051
|
useState as useState8
|
|
5043
5052
|
} from "react";
|
|
5044
5053
|
import { parseCookies as parseCookies2 } from "nookies";
|
|
@@ -5080,7 +5089,7 @@ function CreateAuthProvider({
|
|
|
5080
5089
|
yield api.get("/auth/logout");
|
|
5081
5090
|
setUser(void 0);
|
|
5082
5091
|
}), [api]);
|
|
5083
|
-
|
|
5092
|
+
useEffect8(() => {
|
|
5084
5093
|
const token = parseCookies2()[sessionTokenName];
|
|
5085
5094
|
if (token) {
|
|
5086
5095
|
setStatus("loading");
|