jclib-ui 1.0.30 → 1.0.32
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/jclib-ui.es.js +36 -48
- package/dist/jclib-ui.es.js.map +1 -1
- package/dist/jclib-ui.umd.js +3 -3
- package/dist/jclib-ui.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/jclib-ui.es.js
CHANGED
|
@@ -8646,21 +8646,18 @@ function useApi(initialConfig) {
|
|
|
8646
8646
|
if (globalApiConfig.getToken) {
|
|
8647
8647
|
let token = globalApiConfig.getToken();
|
|
8648
8648
|
if (token) {
|
|
8649
|
-
if (globalApiConfig.auth.prefix)
|
|
8649
|
+
if (globalApiConfig.auth.prefix)
|
|
8650
8650
|
token = `${globalApiConfig.auth.prefix} ${token}`;
|
|
8651
|
-
}
|
|
8652
8651
|
initialConfig.headers[globalApiConfig.auth.header] = token;
|
|
8653
8652
|
}
|
|
8654
8653
|
}
|
|
8655
|
-
if (globalApiConfig.ident)
|
|
8654
|
+
if (globalApiConfig.ident)
|
|
8656
8655
|
initialConfig.headers["x-identify"] = globalApiConfig.ident;
|
|
8657
|
-
}
|
|
8658
8656
|
initialConfig.cache = Boolean(
|
|
8659
8657
|
globalApiConfig.isProductionMode && (!initialConfig.method || initialConfig.method == "get")
|
|
8660
8658
|
);
|
|
8661
|
-
if (initialConfig == null ? void 0 : initialConfig.cache)
|
|
8659
|
+
if (initialConfig == null ? void 0 : initialConfig.cache)
|
|
8662
8660
|
await cache.init(initialConfig);
|
|
8663
|
-
}
|
|
8664
8661
|
let finalConfig = {
|
|
8665
8662
|
baseURL: globalApiConfig.baseURL,
|
|
8666
8663
|
timeout: globalApiConfig.timeout,
|
|
@@ -8669,25 +8666,15 @@ function useApi(initialConfig) {
|
|
|
8669
8666
|
...initialConfig,
|
|
8670
8667
|
...localConfig
|
|
8671
8668
|
};
|
|
8672
|
-
if (finalConfig.report)
|
|
8673
|
-
finalConfig = {
|
|
8674
|
-
...finalConfig,
|
|
8675
|
-
responseType: "blob",
|
|
8676
|
-
timeout: 0
|
|
8677
|
-
};
|
|
8678
|
-
}
|
|
8669
|
+
if (finalConfig.report)
|
|
8670
|
+
finalConfig = { ...finalConfig, responseType: "blob", timeout: 0 };
|
|
8679
8671
|
setRequestInfo({ ...initialRequestInfo, loading: true });
|
|
8680
|
-
if (finalConfig.onBefore)
|
|
8672
|
+
if (finalConfig.onBefore)
|
|
8681
8673
|
finalConfig.onBefore(finalConfig);
|
|
8682
|
-
}
|
|
8683
8674
|
try {
|
|
8684
|
-
const res = await axios({
|
|
8685
|
-
|
|
8686
|
-
signal: controller.signal
|
|
8687
|
-
});
|
|
8688
|
-
if (globalApiConfig.afterRequest) {
|
|
8675
|
+
const res = await axios({ ...finalConfig, signal: controller.signal });
|
|
8676
|
+
if (globalApiConfig.afterRequest)
|
|
8689
8677
|
globalApiConfig.afterRequest(res);
|
|
8690
|
-
}
|
|
8691
8678
|
response = {
|
|
8692
8679
|
...initialRequestInfo,
|
|
8693
8680
|
data: res.data,
|
|
@@ -8696,7 +8683,7 @@ function useApi(initialConfig) {
|
|
|
8696
8683
|
headers: res.headers
|
|
8697
8684
|
};
|
|
8698
8685
|
} catch (err) {
|
|
8699
|
-
if ((err == null ? void 0 : err.code)
|
|
8686
|
+
if ((err == null ? void 0 : err.code) == "ERR_NETWORK") {
|
|
8700
8687
|
response = {
|
|
8701
8688
|
...initialRequestInfo,
|
|
8702
8689
|
isError: true,
|
|
@@ -8713,7 +8700,7 @@ function useApi(initialConfig) {
|
|
|
8713
8700
|
};
|
|
8714
8701
|
switch (err.response.status) {
|
|
8715
8702
|
case 400: {
|
|
8716
|
-
if ((finalConfig == null ? void 0 : finalConfig.responseType)
|
|
8703
|
+
if ((finalConfig == null ? void 0 : finalConfig.responseType) == "blob") {
|
|
8717
8704
|
let data = await err.response.data.text();
|
|
8718
8705
|
data = JSON.parse(data);
|
|
8719
8706
|
response.message = data.error || "Ocorreu um erro ao consultar o servidor!";
|
|
@@ -8743,22 +8730,19 @@ function useApi(initialConfig) {
|
|
|
8743
8730
|
};
|
|
8744
8731
|
}
|
|
8745
8732
|
const vmens = `timeout of ${globalApiConfig.timeout}ms exceeded`;
|
|
8746
|
-
if (response.message
|
|
8733
|
+
if (response.message == vmens || response.message == "Network Error")
|
|
8747
8734
|
response.message = "Sem conexão com o servidor!";
|
|
8748
|
-
}
|
|
8749
8735
|
if (response.isError) {
|
|
8750
8736
|
response.error = response.message;
|
|
8751
8737
|
} else {
|
|
8752
8738
|
response.error = null;
|
|
8753
8739
|
}
|
|
8754
|
-
if (initialConfig == null ? void 0 : initialConfig.cache)
|
|
8740
|
+
if (initialConfig == null ? void 0 : initialConfig.cache)
|
|
8755
8741
|
await cache.save(response, initialConfig);
|
|
8756
|
-
}
|
|
8757
8742
|
response = { ...response, loading: false };
|
|
8758
8743
|
setRequestInfo(response);
|
|
8759
|
-
if (initialConfig == null ? void 0 : initialConfig.onTerminated)
|
|
8744
|
+
if (initialConfig == null ? void 0 : initialConfig.onTerminated)
|
|
8760
8745
|
initialConfig.onTerminated(response);
|
|
8761
|
-
}
|
|
8762
8746
|
return response;
|
|
8763
8747
|
}
|
|
8764
8748
|
return [callRequest, requestInfo, callCancel];
|
|
@@ -21531,7 +21515,7 @@ function PrintButtons({ onClose, showTypes = true }) {
|
|
|
21531
21515
|
const { reportType, setReportType } = useLibContext();
|
|
21532
21516
|
const arrTypes = ["PDF", "Excel", "Word", "Texto"];
|
|
21533
21517
|
const { globalApiConfig } = useLibContext();
|
|
21534
|
-
const
|
|
21518
|
+
const reportTypeItems = createDropdownItems([
|
|
21535
21519
|
{
|
|
21536
21520
|
title: "PDF",
|
|
21537
21521
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fa-solid fa-file-pdf" }),
|
|
@@ -21561,17 +21545,22 @@ function PrintButtons({ onClose, showTypes = true }) {
|
|
|
21561
21545
|
}
|
|
21562
21546
|
}
|
|
21563
21547
|
]);
|
|
21564
|
-
if (!showTypes) {
|
|
21548
|
+
if (!showTypes || !globalApiConfig.showReportTypesButton) {
|
|
21565
21549
|
setReportType(0);
|
|
21566
21550
|
}
|
|
21567
21551
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "print-btn--container", children: [
|
|
21568
|
-
showTypes && globalApiConfig.showReportTypesButton && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
21569
|
-
|
|
21570
|
-
|
|
21571
|
-
|
|
21572
|
-
|
|
21573
|
-
|
|
21574
|
-
|
|
21552
|
+
showTypes && globalApiConfig.showReportTypesButton && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
21553
|
+
DropDownButton,
|
|
21554
|
+
{
|
|
21555
|
+
items: reportTypeItems,
|
|
21556
|
+
title: "Formato do relatório",
|
|
21557
|
+
direction: "down",
|
|
21558
|
+
children: [
|
|
21559
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "d-inline-block d-sm-none me-2", children: "Formato do relatório:" }),
|
|
21560
|
+
arrTypes[reportType]
|
|
21561
|
+
]
|
|
21562
|
+
}
|
|
21563
|
+
),
|
|
21575
21564
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "print-btn--buttons", children: [
|
|
21576
21565
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "btn btn-primary", type: "submit", children: [
|
|
21577
21566
|
/* @__PURE__ */ jsxRuntimeExports.jsx("i", { className: "fas fa-print" }),
|
|
@@ -21585,7 +21574,6 @@ function PrintButtons({ onClose, showTypes = true }) {
|
|
|
21585
21574
|
] });
|
|
21586
21575
|
}
|
|
21587
21576
|
const report = localforageExports.createInstance({
|
|
21588
|
-
// name: process.env.REACT_APP_DB || 'report',
|
|
21589
21577
|
name: "report",
|
|
21590
21578
|
storeName: "report"
|
|
21591
21579
|
});
|
|
@@ -21612,9 +21600,10 @@ function useLocalForage(key, initialValue, versao = 1) {
|
|
|
21612
21600
|
}
|
|
21613
21601
|
function useParamId() {
|
|
21614
21602
|
let result = 0;
|
|
21615
|
-
|
|
21616
|
-
if (params && params.id)
|
|
21603
|
+
let params = useParams();
|
|
21604
|
+
if (params && params.id) {
|
|
21617
21605
|
result = parseInt(params.id);
|
|
21606
|
+
}
|
|
21618
21607
|
return result;
|
|
21619
21608
|
}
|
|
21620
21609
|
function useQuery() {
|
|
@@ -21624,22 +21613,21 @@ function useQuery() {
|
|
|
21624
21613
|
function useLocalStorage(key, initialValue) {
|
|
21625
21614
|
const [storedValue, setStoredValue] = useState(() => {
|
|
21626
21615
|
const item = localStorage.getItem(key);
|
|
21627
|
-
if (item && item !== "undefined" && item !== "null" && item !== "")
|
|
21616
|
+
if (item && item !== "undefined" && item !== "null" && item !== "")
|
|
21628
21617
|
return JSON.parse(item);
|
|
21629
|
-
}
|
|
21630
21618
|
return initialValue;
|
|
21631
21619
|
});
|
|
21632
|
-
useEffect(
|
|
21633
|
-
localStorage.setItem(key, JSON.stringify(storedValue))
|
|
21634
|
-
|
|
21620
|
+
useEffect(
|
|
21621
|
+
() => localStorage.setItem(key, JSON.stringify(storedValue)),
|
|
21622
|
+
[storedValue]
|
|
21623
|
+
);
|
|
21635
21624
|
return [storedValue, setStoredValue];
|
|
21636
21625
|
}
|
|
21637
21626
|
function useSessionStorage(key, initialValue) {
|
|
21638
21627
|
const [storedValue, setStoredValue] = useState(() => {
|
|
21639
21628
|
const item = sessionStorage.getItem(key);
|
|
21640
|
-
if (item && item !== "undefined" && item !== "null" && item !== "")
|
|
21629
|
+
if (item && item !== "undefined" && item !== "null" && item !== "")
|
|
21641
21630
|
return JSON.parse(item);
|
|
21642
|
-
}
|
|
21643
21631
|
return initialValue;
|
|
21644
21632
|
});
|
|
21645
21633
|
useEffect(() => {
|