gbs-add-block 1.0.30 → 1.0.31
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/package.json
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useSearch,
|
|
8
8
|
useFiltering,
|
|
9
9
|
useRowSelection,
|
|
10
|
-
usePageStatus,
|
|
11
10
|
} from "../hooks";
|
|
12
11
|
|
|
13
12
|
const GridContext = createContext<GridContextType | undefined>(undefined);
|
|
@@ -70,7 +69,13 @@ export const GridProvider: React.FC<{
|
|
|
70
69
|
goToFirstPage,
|
|
71
70
|
goToPage,
|
|
72
71
|
resetPage,
|
|
73
|
-
} = usePagination(
|
|
72
|
+
} = usePagination(
|
|
73
|
+
totalPages,
|
|
74
|
+
lazy,
|
|
75
|
+
workingDataSource,
|
|
76
|
+
pageSettings,
|
|
77
|
+
pageStatus
|
|
78
|
+
);
|
|
74
79
|
|
|
75
80
|
// Search functionality
|
|
76
81
|
const { searchParam, handleSearchInput, handleSearch } = useSearch({
|
|
@@ -110,9 +115,6 @@ export const GridProvider: React.FC<{
|
|
|
110
115
|
const { selectedRows, handleSelectAll, handleSelect, isRowSelected } =
|
|
111
116
|
useRowSelection(workingDataSource, onSelectRow);
|
|
112
117
|
|
|
113
|
-
// Page status reporting - Bug Report - causes re-rendering when currentPage or totalPages change
|
|
114
|
-
// usePageStatus(currentPage, totalPages, pageStatus);
|
|
115
|
-
|
|
116
118
|
// Context value
|
|
117
119
|
const contextValue: GridContextType = {
|
|
118
120
|
// State
|
|
@@ -4,13 +4,15 @@ export const usePagination = (
|
|
|
4
4
|
totalPages: number,
|
|
5
5
|
lazy: boolean,
|
|
6
6
|
dataSource?: any[],
|
|
7
|
-
pageSettings?: { pageNumber: number }
|
|
7
|
+
pageSettings?: { pageNumber: number },
|
|
8
|
+
pageStatus?: ({ currentPage }: { currentPage: number }) => void
|
|
8
9
|
) => {
|
|
9
10
|
const [currentPage, setCurrentPage] = useState(0);
|
|
10
11
|
const [pageStart, setPageStart] = useState(0);
|
|
11
12
|
const [pageEnd, setPageEnd] = useState(10);
|
|
12
13
|
const [prevDataLength, setPrevDataLength] = useState(0);
|
|
13
14
|
|
|
15
|
+
// Update page range based on current page
|
|
14
16
|
const updatePageRange = useCallback(
|
|
15
17
|
(page: number) => {
|
|
16
18
|
const start = Math.floor(page / 10) * 10;
|
|
@@ -20,6 +22,7 @@ export const usePagination = (
|
|
|
20
22
|
[totalPages]
|
|
21
23
|
);
|
|
22
24
|
|
|
25
|
+
// Initialize page range based on total pages
|
|
23
26
|
useEffect(() => {
|
|
24
27
|
if (!lazy) {
|
|
25
28
|
setPageEnd(Math.min(10, totalPages));
|
|
@@ -28,6 +31,13 @@ export const usePagination = (
|
|
|
28
31
|
}
|
|
29
32
|
}, [totalPages, lazy, pageStart]);
|
|
30
33
|
|
|
34
|
+
// Update page status if provided
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (pageStatus) {
|
|
37
|
+
pageStatus({ currentPage });
|
|
38
|
+
}
|
|
39
|
+
}, [currentPage, pageStatus]);
|
|
40
|
+
|
|
31
41
|
// This will handle the case when dataSource changes
|
|
32
42
|
// and adjust the current page accordingly in managed workflow
|
|
33
43
|
useEffect(() => {
|
|
@@ -35,7 +35,7 @@ export type GridProps = {
|
|
|
35
35
|
gridColumnStyleSelectAll?: string;
|
|
36
36
|
gridColumnStyle?: string;
|
|
37
37
|
rowChange?: any;
|
|
38
|
-
pageStatus?:
|
|
38
|
+
pageStatus?: ({ currentPage }: { currentPage: number }) => void;
|
|
39
39
|
activeFilterArrayValue?: ActiveFilterArrayValue[] | any;
|
|
40
40
|
searchParamValue?: (value: string) => void;
|
|
41
41
|
showTotalPages?: boolean;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
export const usePageStatus = (
|
|
4
|
-
currentPage: number,
|
|
5
|
-
totalPages: number,
|
|
6
|
-
pageStatus?: (status: any) => void
|
|
7
|
-
) => {
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (pageStatus) {
|
|
10
|
-
pageStatus({ currentPage, totalPages });
|
|
11
|
-
}
|
|
12
|
-
}, [pageStatus, currentPage, totalPages]);
|
|
13
|
-
};
|