@etsoo/react 1.8.3 → 1.8.4
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.
|
@@ -76,7 +76,7 @@ export interface GridLoader<T extends object> {
|
|
|
76
76
|
/**
|
|
77
77
|
* Load data
|
|
78
78
|
*/
|
|
79
|
-
loadData: (props: GridLoadDataProps) => PromiseLike<T[] | null | undefined>;
|
|
79
|
+
loadData: (props: GridLoadDataProps, lastItem?: T) => PromiseLike<T[] | null | undefined>;
|
|
80
80
|
/**
|
|
81
81
|
* Handler for init load
|
|
82
82
|
* @param ref Ref
|
|
@@ -100,6 +100,10 @@ type GridLoaderProps<T> = {
|
|
|
100
100
|
* @default true
|
|
101
101
|
*/
|
|
102
102
|
autoLoad: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Last loaded item
|
|
105
|
+
*/
|
|
106
|
+
lastItem?: T;
|
|
103
107
|
/**
|
|
104
108
|
* Last loaded items
|
|
105
109
|
*/
|
|
@@ -45,13 +45,14 @@ export const ScrollerGrid = (props) => {
|
|
|
45
45
|
queryPaging,
|
|
46
46
|
data
|
|
47
47
|
};
|
|
48
|
-
loadData(loadProps).then((result) => {
|
|
48
|
+
loadData(loadProps, refs.current.lastItem).then((result) => {
|
|
49
49
|
if (result == null || refs.current.isMounted === false) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
refs.current.isMounted = true;
|
|
53
53
|
const newItems = result.length;
|
|
54
54
|
refs.current.lastLoadedItems = newItems;
|
|
55
|
+
refs.current.lastItem = result.at(-1);
|
|
55
56
|
refs.current.isNextPageLoading = false;
|
|
56
57
|
refs.current.hasNextPage = newItems >= refs.current.queryPaging.batchSize;
|
|
57
58
|
if (pageAdd === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.4",
|
|
4
4
|
"description": "TypeScript ReactJs UI Independent Framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@emotion/css": "^11.13.5",
|
|
49
49
|
"@emotion/react": "^11.13.5",
|
|
50
50
|
"@emotion/styled": "^11.13.5",
|
|
51
|
-
"@etsoo/appscript": "^1.5.
|
|
51
|
+
"@etsoo/appscript": "^1.5.76",
|
|
52
52
|
"@etsoo/notificationbase": "^1.1.54",
|
|
53
53
|
"@etsoo/shared": "^1.2.55",
|
|
54
54
|
"react": "^18.3.1",
|
|
@@ -116,7 +116,10 @@ export interface GridLoader<T extends object> {
|
|
|
116
116
|
/**
|
|
117
117
|
* Load data
|
|
118
118
|
*/
|
|
119
|
-
loadData: (
|
|
119
|
+
loadData: (
|
|
120
|
+
props: GridLoadDataProps,
|
|
121
|
+
lastItem?: T
|
|
122
|
+
) => PromiseLike<T[] | null | undefined>;
|
|
120
123
|
|
|
121
124
|
/**
|
|
122
125
|
* Handler for init load
|
|
@@ -147,6 +150,11 @@ type GridLoaderProps<T> = {
|
|
|
147
150
|
*/
|
|
148
151
|
autoLoad: boolean;
|
|
149
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Last loaded item
|
|
155
|
+
*/
|
|
156
|
+
lastItem?: T;
|
|
157
|
+
|
|
150
158
|
/**
|
|
151
159
|
* Last loaded items
|
|
152
160
|
*/
|
|
@@ -211,7 +211,7 @@ export const ScrollerGrid = <T extends object>(props: ScrollerGridProps<T>) => {
|
|
|
211
211
|
data
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
loadData(loadProps).then((result) => {
|
|
214
|
+
loadData(loadProps, refs.current.lastItem).then((result) => {
|
|
215
215
|
if (result == null || refs.current.isMounted === false) {
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
@@ -219,6 +219,7 @@ export const ScrollerGrid = <T extends object>(props: ScrollerGridProps<T>) => {
|
|
|
219
219
|
|
|
220
220
|
const newItems = result.length;
|
|
221
221
|
refs.current.lastLoadedItems = newItems;
|
|
222
|
+
refs.current.lastItem = result.at(-1);
|
|
222
223
|
refs.current.isNextPageLoading = false;
|
|
223
224
|
refs.current.hasNextPage = newItems >= refs.current.queryPaging.batchSize;
|
|
224
225
|
|