@megha-ui/react 1.2.751 → 1.2.752
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataRow } from "../types/grid";
|
|
2
|
-
export declare const usePagination: (sortedData: DataRow[], defaultRowsPerPage: number
|
|
2
|
+
export declare const usePagination: (sortedData: DataRow[], defaultRowsPerPage: number) => {
|
|
3
3
|
paginatedData: DataRow[];
|
|
4
4
|
currentPage: number;
|
|
5
5
|
handleChangePage: (page: number) => void;
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { useState, useMemo, useEffect } from "react";
|
|
2
|
-
export const usePagination = (sortedData, defaultRowsPerPage
|
|
2
|
+
export const usePagination = (sortedData, defaultRowsPerPage) => {
|
|
3
3
|
const [currentPage, setCurrentPage] = useState(1);
|
|
4
4
|
const [rowsPerPage, setRowsPerPage] = useState(10);
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
if (currentPageProp !== undefined) {
|
|
7
|
-
setCurrentPage(currentPageProp);
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
setCurrentPage(1);
|
|
11
|
-
}
|
|
12
|
-
console.log("Current page prop:", currentPageProp);
|
|
13
|
-
}, [currentPageProp]);
|
|
14
5
|
useEffect(() => {
|
|
15
6
|
setRowsPerPage(defaultRowsPerPage);
|
|
16
7
|
}, [defaultRowsPerPage]);
|
|
@@ -20,7 +11,7 @@ export const usePagination = (sortedData, defaultRowsPerPage, currentPageProp, g
|
|
|
20
11
|
}, [sortedData, currentPage, rowsPerPage]);
|
|
21
12
|
const handleChangePage = (page) => {
|
|
22
13
|
setCurrentPage(page);
|
|
23
|
-
|
|
14
|
+
localStorage.setItem("currentPage", page.toString());
|
|
24
15
|
};
|
|
25
16
|
const handleChangeRowsPerPage = (value) => {
|
|
26
17
|
setRowsPerPage(parseInt(value.toString(), 10));
|
|
@@ -40,9 +40,7 @@ const Grid = ({ columns, wrapperClass, updateGridColumns, data, height, sortable
|
|
|
40
40
|
console.log("Update fixed filter values not implemented", fixedFilterValues);
|
|
41
41
|
}, locale, formatOptions, exportOptions,
|
|
42
42
|
// Card wrapper props
|
|
43
|
-
withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, subHeader, cardFooter
|
|
44
|
-
console.log("Current page:", page);
|
|
45
|
-
}, currentPage: propCurrentPage, }) => {
|
|
43
|
+
withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, subHeader, cardFooter }) => {
|
|
46
44
|
var _a, _b, _c, _d;
|
|
47
45
|
const [searchQueries, setSearchQueries] = useState({});
|
|
48
46
|
const [chips, setChips] = useState([]);
|
|
@@ -533,7 +531,7 @@ withCard = false, cardClassName, cardHeader, title, headerLeft, headerRight, sub
|
|
|
533
531
|
setSummariseDetails(newSummariseDetails);
|
|
534
532
|
};
|
|
535
533
|
const { sortedData, handleSort, sortQueries, setSortQueries } = useSort(filteredData, gridColumns, uniqueSearch, multiSorting, withAscii);
|
|
536
|
-
const { paginatedData, currentPage, handleChangePage, handleChangeRowsPerPage, rowsPerPage, } = usePagination(sortedData, defaultRowsPerPage
|
|
534
|
+
const { paginatedData, currentPage, handleChangePage, handleChangeRowsPerPage, rowsPerPage, } = usePagination(sortedData, defaultRowsPerPage);
|
|
537
535
|
useEffect(() => {
|
|
538
536
|
const keys = Object.keys(summariseKeys);
|
|
539
537
|
if (keys.length > 0 && summariseAvailable) {
|
package/package.json
CHANGED