@charlesgomes/leafcode-shared-lib-react 1.0.50 → 1.0.51
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 +20 -16
- package/dist/index.mjs +21 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -863,17 +863,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
863
863
|
globalFilterFields
|
|
864
864
|
)
|
|
865
865
|
});
|
|
866
|
-
const
|
|
867
|
-
(0, import_react6.useEffect)(() => {
|
|
868
|
-
if (didInitRef.current) return;
|
|
869
|
-
didInitRef.current = true;
|
|
870
|
-
window.history.replaceState(
|
|
871
|
-
null,
|
|
872
|
-
"",
|
|
873
|
-
window.location.href
|
|
874
|
-
);
|
|
875
|
-
}, []);
|
|
876
|
-
const updateUrlParams = (params, options = { replace: true }) => {
|
|
866
|
+
const updateUrlParams = (params, mode = "push") => {
|
|
877
867
|
if (typeof window === "undefined" || !replaceUrl) return;
|
|
878
868
|
const urlParams = new URLSearchParams(window.location.search);
|
|
879
869
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -887,7 +877,11 @@ function DataTableAdvancedFilterWrapper({
|
|
|
887
877
|
}
|
|
888
878
|
});
|
|
889
879
|
const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
|
|
890
|
-
|
|
880
|
+
if (mode === "replace") {
|
|
881
|
+
window.history.replaceState(null, "", newUrl);
|
|
882
|
+
} else {
|
|
883
|
+
window.history.pushState(null, "", newUrl);
|
|
884
|
+
}
|
|
891
885
|
};
|
|
892
886
|
const hydrateFromUrl = () => {
|
|
893
887
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -921,10 +915,14 @@ function DataTableAdvancedFilterWrapper({
|
|
|
921
915
|
};
|
|
922
916
|
}, []);
|
|
923
917
|
const onPage = (event) => {
|
|
918
|
+
const newPage = event.page + 1;
|
|
924
919
|
setFirst(event.first);
|
|
925
920
|
setRows(event.rows);
|
|
926
|
-
setPage(
|
|
927
|
-
updateUrlParams(
|
|
921
|
+
setPage(newPage);
|
|
922
|
+
updateUrlParams(
|
|
923
|
+
{ page: newPage, rows: event.rows },
|
|
924
|
+
"push"
|
|
925
|
+
);
|
|
928
926
|
};
|
|
929
927
|
const onGlobalFilterChange = (e) => {
|
|
930
928
|
const value = e.target.value;
|
|
@@ -940,10 +938,16 @@ function DataTableAdvancedFilterWrapper({
|
|
|
940
938
|
const onSort = (e) => {
|
|
941
939
|
setSortField(e.sortField);
|
|
942
940
|
setSortOrder(e.sortOrder);
|
|
943
|
-
updateUrlParams(
|
|
941
|
+
updateUrlParams(
|
|
942
|
+
{ sortField: e.sortField, sortOrder: e.sortOrder },
|
|
943
|
+
"push"
|
|
944
|
+
);
|
|
944
945
|
};
|
|
945
946
|
(0, import_react6.useEffect)(() => {
|
|
946
|
-
updateUrlParams(
|
|
947
|
+
updateUrlParams(
|
|
948
|
+
{ page: 1, filter: debouncedSearch },
|
|
949
|
+
"replace"
|
|
950
|
+
);
|
|
947
951
|
}, [debouncedSearch]);
|
|
948
952
|
(0, import_react6.useEffect)(() => {
|
|
949
953
|
if (customers?.items && selectedRowsData.length > 0) {
|
package/dist/index.mjs
CHANGED
|
@@ -129,7 +129,7 @@ function ModalBase({
|
|
|
129
129
|
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
130
130
|
|
|
131
131
|
// src/components/DataTableAdvancedFilter/DataTableAdvancedFilterWrapper.tsx
|
|
132
|
-
import { useEffect as useEffect3, useMemo,
|
|
132
|
+
import { useEffect as useEffect3, useMemo, useState as useState2 } from "react";
|
|
133
133
|
import { useQuery } from "@tanstack/react-query";
|
|
134
134
|
|
|
135
135
|
// src/primereact-compat.ts
|
|
@@ -808,17 +808,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
808
808
|
globalFilterFields
|
|
809
809
|
)
|
|
810
810
|
});
|
|
811
|
-
const
|
|
812
|
-
useEffect3(() => {
|
|
813
|
-
if (didInitRef.current) return;
|
|
814
|
-
didInitRef.current = true;
|
|
815
|
-
window.history.replaceState(
|
|
816
|
-
null,
|
|
817
|
-
"",
|
|
818
|
-
window.location.href
|
|
819
|
-
);
|
|
820
|
-
}, []);
|
|
821
|
-
const updateUrlParams = (params, options = { replace: true }) => {
|
|
811
|
+
const updateUrlParams = (params, mode = "push") => {
|
|
822
812
|
if (typeof window === "undefined" || !replaceUrl) return;
|
|
823
813
|
const urlParams = new URLSearchParams(window.location.search);
|
|
824
814
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -832,7 +822,11 @@ function DataTableAdvancedFilterWrapper({
|
|
|
832
822
|
}
|
|
833
823
|
});
|
|
834
824
|
const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
|
|
835
|
-
|
|
825
|
+
if (mode === "replace") {
|
|
826
|
+
window.history.replaceState(null, "", newUrl);
|
|
827
|
+
} else {
|
|
828
|
+
window.history.pushState(null, "", newUrl);
|
|
829
|
+
}
|
|
836
830
|
};
|
|
837
831
|
const hydrateFromUrl = () => {
|
|
838
832
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -866,10 +860,14 @@ function DataTableAdvancedFilterWrapper({
|
|
|
866
860
|
};
|
|
867
861
|
}, []);
|
|
868
862
|
const onPage = (event) => {
|
|
863
|
+
const newPage = event.page + 1;
|
|
869
864
|
setFirst(event.first);
|
|
870
865
|
setRows(event.rows);
|
|
871
|
-
setPage(
|
|
872
|
-
updateUrlParams(
|
|
866
|
+
setPage(newPage);
|
|
867
|
+
updateUrlParams(
|
|
868
|
+
{ page: newPage, rows: event.rows },
|
|
869
|
+
"push"
|
|
870
|
+
);
|
|
873
871
|
};
|
|
874
872
|
const onGlobalFilterChange = (e) => {
|
|
875
873
|
const value = e.target.value;
|
|
@@ -885,10 +883,16 @@ function DataTableAdvancedFilterWrapper({
|
|
|
885
883
|
const onSort = (e) => {
|
|
886
884
|
setSortField(e.sortField);
|
|
887
885
|
setSortOrder(e.sortOrder);
|
|
888
|
-
updateUrlParams(
|
|
886
|
+
updateUrlParams(
|
|
887
|
+
{ sortField: e.sortField, sortOrder: e.sortOrder },
|
|
888
|
+
"push"
|
|
889
|
+
);
|
|
889
890
|
};
|
|
890
891
|
useEffect3(() => {
|
|
891
|
-
updateUrlParams(
|
|
892
|
+
updateUrlParams(
|
|
893
|
+
{ page: 1, filter: debouncedSearch },
|
|
894
|
+
"replace"
|
|
895
|
+
);
|
|
892
896
|
}, [debouncedSearch]);
|
|
893
897
|
useEffect3(() => {
|
|
894
898
|
if (customers?.items && selectedRowsData.length > 0) {
|