@charlesgomes/leafcode-shared-lib-react 1.0.49 → 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 -6
- package/dist/index.mjs +20 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -863,7 +863,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
863
863
|
globalFilterFields
|
|
864
864
|
)
|
|
865
865
|
});
|
|
866
|
-
const updateUrlParams = (params,
|
|
866
|
+
const updateUrlParams = (params, mode = "push") => {
|
|
867
867
|
if (typeof window === "undefined" || !replaceUrl) return;
|
|
868
868
|
const urlParams = new URLSearchParams(window.location.search);
|
|
869
869
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -877,7 +877,11 @@ function DataTableAdvancedFilterWrapper({
|
|
|
877
877
|
}
|
|
878
878
|
});
|
|
879
879
|
const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
|
|
880
|
-
|
|
880
|
+
if (mode === "replace") {
|
|
881
|
+
window.history.replaceState(null, "", newUrl);
|
|
882
|
+
} else {
|
|
883
|
+
window.history.pushState(null, "", newUrl);
|
|
884
|
+
}
|
|
881
885
|
};
|
|
882
886
|
const hydrateFromUrl = () => {
|
|
883
887
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -911,10 +915,14 @@ function DataTableAdvancedFilterWrapper({
|
|
|
911
915
|
};
|
|
912
916
|
}, []);
|
|
913
917
|
const onPage = (event) => {
|
|
918
|
+
const newPage = event.page + 1;
|
|
914
919
|
setFirst(event.first);
|
|
915
920
|
setRows(event.rows);
|
|
916
|
-
setPage(
|
|
917
|
-
updateUrlParams(
|
|
921
|
+
setPage(newPage);
|
|
922
|
+
updateUrlParams(
|
|
923
|
+
{ page: newPage, rows: event.rows },
|
|
924
|
+
"push"
|
|
925
|
+
);
|
|
918
926
|
};
|
|
919
927
|
const onGlobalFilterChange = (e) => {
|
|
920
928
|
const value = e.target.value;
|
|
@@ -930,10 +938,16 @@ function DataTableAdvancedFilterWrapper({
|
|
|
930
938
|
const onSort = (e) => {
|
|
931
939
|
setSortField(e.sortField);
|
|
932
940
|
setSortOrder(e.sortOrder);
|
|
933
|
-
updateUrlParams(
|
|
941
|
+
updateUrlParams(
|
|
942
|
+
{ sortField: e.sortField, sortOrder: e.sortOrder },
|
|
943
|
+
"push"
|
|
944
|
+
);
|
|
934
945
|
};
|
|
935
946
|
(0, import_react6.useEffect)(() => {
|
|
936
|
-
updateUrlParams(
|
|
947
|
+
updateUrlParams(
|
|
948
|
+
{ page: 1, filter: debouncedSearch },
|
|
949
|
+
"replace"
|
|
950
|
+
);
|
|
937
951
|
}, [debouncedSearch]);
|
|
938
952
|
(0, import_react6.useEffect)(() => {
|
|
939
953
|
if (customers?.items && selectedRowsData.length > 0) {
|
package/dist/index.mjs
CHANGED
|
@@ -808,7 +808,7 @@ function DataTableAdvancedFilterWrapper({
|
|
|
808
808
|
globalFilterFields
|
|
809
809
|
)
|
|
810
810
|
});
|
|
811
|
-
const updateUrlParams = (params,
|
|
811
|
+
const updateUrlParams = (params, mode = "push") => {
|
|
812
812
|
if (typeof window === "undefined" || !replaceUrl) return;
|
|
813
813
|
const urlParams = new URLSearchParams(window.location.search);
|
|
814
814
|
Object.entries(params).forEach(([key, value]) => {
|
|
@@ -822,7 +822,11 @@ function DataTableAdvancedFilterWrapper({
|
|
|
822
822
|
}
|
|
823
823
|
});
|
|
824
824
|
const newUrl = `${window.location.pathname}?${urlParams.toString()}`;
|
|
825
|
-
|
|
825
|
+
if (mode === "replace") {
|
|
826
|
+
window.history.replaceState(null, "", newUrl);
|
|
827
|
+
} else {
|
|
828
|
+
window.history.pushState(null, "", newUrl);
|
|
829
|
+
}
|
|
826
830
|
};
|
|
827
831
|
const hydrateFromUrl = () => {
|
|
828
832
|
const params = new URLSearchParams(window.location.search);
|
|
@@ -856,10 +860,14 @@ function DataTableAdvancedFilterWrapper({
|
|
|
856
860
|
};
|
|
857
861
|
}, []);
|
|
858
862
|
const onPage = (event) => {
|
|
863
|
+
const newPage = event.page + 1;
|
|
859
864
|
setFirst(event.first);
|
|
860
865
|
setRows(event.rows);
|
|
861
|
-
setPage(
|
|
862
|
-
updateUrlParams(
|
|
866
|
+
setPage(newPage);
|
|
867
|
+
updateUrlParams(
|
|
868
|
+
{ page: newPage, rows: event.rows },
|
|
869
|
+
"push"
|
|
870
|
+
);
|
|
863
871
|
};
|
|
864
872
|
const onGlobalFilterChange = (e) => {
|
|
865
873
|
const value = e.target.value;
|
|
@@ -875,10 +883,16 @@ function DataTableAdvancedFilterWrapper({
|
|
|
875
883
|
const onSort = (e) => {
|
|
876
884
|
setSortField(e.sortField);
|
|
877
885
|
setSortOrder(e.sortOrder);
|
|
878
|
-
updateUrlParams(
|
|
886
|
+
updateUrlParams(
|
|
887
|
+
{ sortField: e.sortField, sortOrder: e.sortOrder },
|
|
888
|
+
"push"
|
|
889
|
+
);
|
|
879
890
|
};
|
|
880
891
|
useEffect3(() => {
|
|
881
|
-
updateUrlParams(
|
|
892
|
+
updateUrlParams(
|
|
893
|
+
{ page: 1, filter: debouncedSearch },
|
|
894
|
+
"replace"
|
|
895
|
+
);
|
|
882
896
|
}, [debouncedSearch]);
|
|
883
897
|
useEffect3(() => {
|
|
884
898
|
if (customers?.items && selectedRowsData.length > 0) {
|