@etsoo/react 1.7.36 → 1.7.38
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/lib/components/GridLoader.d.ts +23 -4
- package/lib/components/GridMethodRef.d.ts +2 -2
- package/lib/components/ScrollerGrid.js +4 -2
- package/lib/components/ScrollerList.js +4 -2
- package/package.json +3 -3
- package/src/components/GridLoader.ts +27 -4
- package/src/components/GridMethodRef.ts +2 -2
- package/src/components/ScrollerGrid.tsx +4 -2
- package/src/components/ScrollerList.tsx +4 -2
|
@@ -43,6 +43,19 @@ export type GridLoadDataProps = {
|
|
|
43
43
|
*/
|
|
44
44
|
data?: GridData;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Grid data load partial props
|
|
48
|
+
*/
|
|
49
|
+
export type GridLoadDataPartialProps = {
|
|
50
|
+
/**
|
|
51
|
+
* Query paging data
|
|
52
|
+
*/
|
|
53
|
+
queryPaging?: Partial<QueryPagingData>;
|
|
54
|
+
/**
|
|
55
|
+
* Data related
|
|
56
|
+
*/
|
|
57
|
+
data?: GridData;
|
|
58
|
+
};
|
|
46
59
|
/**
|
|
47
60
|
* Grid data loader
|
|
48
61
|
*/
|
|
@@ -81,10 +94,7 @@ export interface GridLoader<T extends object> {
|
|
|
81
94
|
*/
|
|
82
95
|
threshold?: number | undefined;
|
|
83
96
|
}
|
|
84
|
-
|
|
85
|
-
* Grid loader states
|
|
86
|
-
*/
|
|
87
|
-
export type GridLoaderStates<T> = GridLoadDataProps & {
|
|
97
|
+
type GridLoaderProps<T> = {
|
|
88
98
|
/**
|
|
89
99
|
* Auto load data, otherwise call reset
|
|
90
100
|
* @default true
|
|
@@ -119,3 +129,12 @@ export type GridLoaderStates<T> = GridLoadDataProps & {
|
|
|
119
129
|
*/
|
|
120
130
|
idCache: Record<any, null>;
|
|
121
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Grid loader states
|
|
134
|
+
*/
|
|
135
|
+
export type GridLoaderStates<T> = GridLoadDataProps & GridLoaderProps<T>;
|
|
136
|
+
/**
|
|
137
|
+
* Grid loader states
|
|
138
|
+
*/
|
|
139
|
+
export type GridLoaderPartialStates<T> = GridLoadDataPartialProps & Partial<GridLoaderProps<T>>;
|
|
140
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Align } from 'react-window';
|
|
2
|
-
import {
|
|
2
|
+
import { GridLoaderPartialStates } from './GridLoader';
|
|
3
3
|
/**
|
|
4
4
|
* Grid method ref
|
|
5
5
|
*/
|
|
@@ -19,7 +19,7 @@ export interface GridMethodRef<T> {
|
|
|
19
19
|
* Reset
|
|
20
20
|
* @param add Additional data
|
|
21
21
|
*/
|
|
22
|
-
reset(add?:
|
|
22
|
+
reset(add?: GridLoaderPartialStates<T>): void;
|
|
23
23
|
/**
|
|
24
24
|
* Scroll to the specified offset (scrollTop or scrollLeft, depending on the direction prop).
|
|
25
25
|
*/
|
|
@@ -119,17 +119,19 @@ export const ScrollerGrid = (props) => {
|
|
|
119
119
|
};
|
|
120
120
|
// Reset the state and load again
|
|
121
121
|
const reset = (add, items = []) => {
|
|
122
|
+
const { queryPaging, ...rest } = add ?? {};
|
|
122
123
|
const resetState = {
|
|
123
124
|
queryPaging: {
|
|
124
125
|
...refs.current.queryPaging,
|
|
125
|
-
currentPage: 0
|
|
126
|
+
currentPage: 0,
|
|
127
|
+
...queryPaging
|
|
126
128
|
},
|
|
127
129
|
autoLoad: true,
|
|
128
130
|
loadedItems: 0,
|
|
129
131
|
hasNextPage: true,
|
|
130
132
|
isNextPageLoading: false,
|
|
131
133
|
lastLoadedItems: undefined,
|
|
132
|
-
...
|
|
134
|
+
...rest
|
|
133
135
|
};
|
|
134
136
|
Object.assign(refs.current, resetState);
|
|
135
137
|
// Reset items
|
|
@@ -113,17 +113,19 @@ export const ScrollerList = (props) => {
|
|
|
113
113
|
};
|
|
114
114
|
// Reset the state and load again
|
|
115
115
|
const reset = (add, items = []) => {
|
|
116
|
+
const { queryPaging, ...rest } = add ?? {};
|
|
116
117
|
const resetState = {
|
|
117
118
|
queryPaging: {
|
|
118
119
|
...stateRefs.current.queryPaging,
|
|
119
|
-
currentPage: 0
|
|
120
|
+
currentPage: 0,
|
|
121
|
+
...queryPaging
|
|
120
122
|
},
|
|
121
123
|
autoLoad: true,
|
|
122
124
|
lastLoadedItems: undefined,
|
|
123
125
|
loadedItems: 0,
|
|
124
126
|
hasNextPage: true,
|
|
125
127
|
isNextPageLoading: false,
|
|
126
|
-
...
|
|
128
|
+
...rest
|
|
127
129
|
};
|
|
128
130
|
Object.assign(stateRefs.current, resetState);
|
|
129
131
|
// Reset
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.38",
|
|
4
4
|
"description": "TypeScript ReactJs UI Independent Framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@emotion/css": "^11.11.2",
|
|
51
51
|
"@emotion/react": "^11.11.4",
|
|
52
52
|
"@emotion/styled": "^11.11.5",
|
|
53
|
-
"@etsoo/appscript": "^1.4.
|
|
53
|
+
"@etsoo/appscript": "^1.4.86",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.42",
|
|
55
55
|
"@etsoo/shared": "^1.2.37",
|
|
56
56
|
"react": "^18.3.1",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@babel/preset-env": "^7.24.5",
|
|
66
66
|
"@babel/runtime-corejs3": "^7.24.5",
|
|
67
67
|
"@testing-library/jest-dom": "^6.4.5",
|
|
68
|
-
"@testing-library/react": "^15.0.
|
|
68
|
+
"@testing-library/react": "^15.0.7",
|
|
69
69
|
"@types/jest": "^29.5.12",
|
|
70
70
|
"@types/react": "^18.3.1",
|
|
71
71
|
"@types/react-dom": "^18.3.0",
|
|
@@ -78,6 +78,21 @@ export type GridLoadDataProps = {
|
|
|
78
78
|
data?: GridData;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Grid data load partial props
|
|
83
|
+
*/
|
|
84
|
+
export type GridLoadDataPartialProps = {
|
|
85
|
+
/**
|
|
86
|
+
* Query paging data
|
|
87
|
+
*/
|
|
88
|
+
queryPaging?: Partial<QueryPagingData>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Data related
|
|
92
|
+
*/
|
|
93
|
+
data?: GridData;
|
|
94
|
+
};
|
|
95
|
+
|
|
81
96
|
/**
|
|
82
97
|
* Grid data loader
|
|
83
98
|
*/
|
|
@@ -125,10 +140,7 @@ export interface GridLoader<T extends object> {
|
|
|
125
140
|
threshold?: number | undefined;
|
|
126
141
|
}
|
|
127
142
|
|
|
128
|
-
|
|
129
|
-
* Grid loader states
|
|
130
|
-
*/
|
|
131
|
-
export type GridLoaderStates<T> = GridLoadDataProps & {
|
|
143
|
+
type GridLoaderProps<T> = {
|
|
132
144
|
/**
|
|
133
145
|
* Auto load data, otherwise call reset
|
|
134
146
|
* @default true
|
|
@@ -170,3 +182,14 @@ export type GridLoaderStates<T> = GridLoadDataProps & {
|
|
|
170
182
|
*/
|
|
171
183
|
idCache: Record<any, null>;
|
|
172
184
|
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Grid loader states
|
|
188
|
+
*/
|
|
189
|
+
export type GridLoaderStates<T> = GridLoadDataProps & GridLoaderProps<T>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Grid loader states
|
|
193
|
+
*/
|
|
194
|
+
export type GridLoaderPartialStates<T> = GridLoadDataPartialProps &
|
|
195
|
+
Partial<GridLoaderProps<T>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Align } from 'react-window';
|
|
2
|
-
import {
|
|
2
|
+
import { GridLoaderPartialStates } from './GridLoader';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Grid method ref
|
|
@@ -22,7 +22,7 @@ export interface GridMethodRef<T> {
|
|
|
22
22
|
* Reset
|
|
23
23
|
* @param add Additional data
|
|
24
24
|
*/
|
|
25
|
-
reset(add?:
|
|
25
|
+
reset(add?: GridLoaderPartialStates<T>): void;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Scroll to the specified offset (scrollTop or scrollLeft, depending on the direction prop).
|
|
@@ -318,17 +318,19 @@ export const ScrollerGrid = <T extends object>(props: ScrollerGridProps<T>) => {
|
|
|
318
318
|
|
|
319
319
|
// Reset the state and load again
|
|
320
320
|
const reset = (add?: Partial<GridLoaderStates<T>>, items: T[] = []) => {
|
|
321
|
+
const { queryPaging, ...rest } = add ?? {};
|
|
321
322
|
const resetState: Partial<GridLoaderStates<T>> = {
|
|
322
323
|
queryPaging: {
|
|
323
324
|
...refs.current.queryPaging,
|
|
324
|
-
currentPage: 0
|
|
325
|
+
currentPage: 0,
|
|
326
|
+
...queryPaging
|
|
325
327
|
},
|
|
326
328
|
autoLoad: true,
|
|
327
329
|
loadedItems: 0,
|
|
328
330
|
hasNextPage: true,
|
|
329
331
|
isNextPageLoading: false,
|
|
330
332
|
lastLoadedItems: undefined,
|
|
331
|
-
...
|
|
333
|
+
...rest
|
|
332
334
|
};
|
|
333
335
|
Object.assign(refs.current, resetState);
|
|
334
336
|
|
|
@@ -249,17 +249,19 @@ export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {
|
|
|
249
249
|
|
|
250
250
|
// Reset the state and load again
|
|
251
251
|
const reset = (add?: Partial<GridLoaderStates<T>>, items: T[] = []) => {
|
|
252
|
+
const { queryPaging, ...rest } = add ?? {};
|
|
252
253
|
const resetState: Partial<GridLoaderStates<T>> = {
|
|
253
254
|
queryPaging: {
|
|
254
255
|
...stateRefs.current.queryPaging,
|
|
255
|
-
currentPage: 0
|
|
256
|
+
currentPage: 0,
|
|
257
|
+
...queryPaging
|
|
256
258
|
},
|
|
257
259
|
autoLoad: true,
|
|
258
260
|
lastLoadedItems: undefined,
|
|
259
261
|
loadedItems: 0,
|
|
260
262
|
hasNextPage: true,
|
|
261
263
|
isNextPageLoading: false,
|
|
262
|
-
...
|
|
264
|
+
...rest
|
|
263
265
|
};
|
|
264
266
|
Object.assign(stateRefs.current, resetState);
|
|
265
267
|
|