@etsoo/react 1.7.38 → 1.7.40

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.
@@ -82,7 +82,7 @@ export interface GridLoader<T extends object> {
82
82
  * @param ref Ref
83
83
  * @returns Result
84
84
  */
85
- onInitLoad?: (ref: any) => [T[], Partial<GridLoaderStates<T>>?] | null | undefined;
85
+ onInitLoad?: (ref: any) => [T[], GridLoaderPartialStates<T>?] | null | undefined;
86
86
  /**
87
87
  * Handler for updating rows
88
88
  * @param rows Rows
@@ -72,8 +72,7 @@ export const ScrollerGrid = (props) => {
72
72
  }
73
73
  else {
74
74
  // Set current page
75
- var currentPage = refs.current.queryPaging.currentPage ?? 0;
76
- refs.current.queryPaging.currentPage = currentPage + pageAdd;
75
+ refs.current.queryPaging.currentPage += pageAdd;
77
76
  // Update rows, avoid duplicate items
78
77
  const newRows = [...rows];
79
78
  for (const item of result) {
@@ -121,11 +120,6 @@ export const ScrollerGrid = (props) => {
121
120
  const reset = (add, items = []) => {
122
121
  const { queryPaging, ...rest } = add ?? {};
123
122
  const resetState = {
124
- queryPaging: {
125
- ...refs.current.queryPaging,
126
- currentPage: 0,
127
- ...queryPaging
128
- },
129
123
  autoLoad: true,
130
124
  loadedItems: 0,
131
125
  hasNextPage: true,
@@ -134,6 +128,10 @@ export const ScrollerGrid = (props) => {
134
128
  ...rest
135
129
  };
136
130
  Object.assign(refs.current, resetState);
131
+ Object.assign(refs.current.queryPaging, {
132
+ currentPage: 0,
133
+ ...queryPaging
134
+ });
137
135
  // Reset items
138
136
  if (refs.current.isMounted !== false)
139
137
  setRows(items, true);
@@ -41,7 +41,7 @@ export const ScrollerList = (props) => {
41
41
  currentPage: 0,
42
42
  orderBy: defaultOrderBy,
43
43
  orderByAsc: defaultOrderByAsc,
44
- batchSize: batchSize
44
+ batchSize
45
45
  },
46
46
  autoLoad,
47
47
  loadedItems: 0,
@@ -89,9 +89,7 @@ export const ScrollerList = (props) => {
89
89
  setRows(newRows);
90
90
  }
91
91
  else {
92
- var currentPage = stateRefs.current.queryPaging.currentPage ?? 0;
93
- stateRefs.current.queryPaging.currentPage =
94
- currentPage + pageAdd;
92
+ stateRefs.current.queryPaging.currentPage += pageAdd;
95
93
  // Update rows, avoid duplicate items
96
94
  const newRows = [...rows];
97
95
  for (const item of result) {
@@ -115,11 +113,6 @@ export const ScrollerList = (props) => {
115
113
  const reset = (add, items = []) => {
116
114
  const { queryPaging, ...rest } = add ?? {};
117
115
  const resetState = {
118
- queryPaging: {
119
- ...stateRefs.current.queryPaging,
120
- currentPage: 0,
121
- ...queryPaging
122
- },
123
116
  autoLoad: true,
124
117
  lastLoadedItems: undefined,
125
118
  loadedItems: 0,
@@ -128,6 +121,10 @@ export const ScrollerList = (props) => {
128
121
  ...rest
129
122
  };
130
123
  Object.assign(stateRefs.current, resetState);
124
+ Object.assign(stateRefs.current.queryPaging, {
125
+ currentPage: 0,
126
+ ...queryPaging
127
+ });
131
128
  // Reset
132
129
  if (stateRefs.current.isMounted !== false)
133
130
  setRows(items, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.7.38",
3
+ "version": "1.7.40",
4
4
  "description": "TypeScript ReactJs UI Independent Framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -125,7 +125,7 @@ export interface GridLoader<T extends object> {
125
125
  */
126
126
  onInitLoad?: (
127
127
  ref: any
128
- ) => [T[], Partial<GridLoaderStates<T>>?] | null | undefined;
128
+ ) => [T[], GridLoaderPartialStates<T>?] | null | undefined;
129
129
 
130
130
  /**
131
131
  * Handler for updating rows
@@ -7,7 +7,12 @@ import {
7
7
  VariableSizeGrid,
8
8
  VariableSizeGridProps
9
9
  } from 'react-window';
10
- import { GridLoadDataProps, GridLoader, GridLoaderStates } from './GridLoader';
10
+ import {
11
+ GridLoadDataProps,
12
+ GridLoader,
13
+ GridLoaderPartialStates,
14
+ GridLoaderStates
15
+ } from './GridLoader';
11
16
  import { GridMethodRef } from './GridMethodRef';
12
17
 
13
18
  export type ScrollerGridItemRendererProps<T> = Omit<
@@ -255,8 +260,7 @@ export const ScrollerGrid = <T extends object>(props: ScrollerGridProps<T>) => {
255
260
  setRows(newRows);
256
261
  } else {
257
262
  // Set current page
258
- var currentPage = refs.current.queryPaging.currentPage ?? 0;
259
- refs.current.queryPaging.currentPage = currentPage + pageAdd;
263
+ refs.current.queryPaging.currentPage += pageAdd;
260
264
 
261
265
  // Update rows, avoid duplicate items
262
266
  const newRows = [...rows];
@@ -317,14 +321,9 @@ export const ScrollerGrid = <T extends object>(props: ScrollerGridProps<T>) => {
317
321
  };
318
322
 
319
323
  // Reset the state and load again
320
- const reset = (add?: Partial<GridLoaderStates<T>>, items: T[] = []) => {
324
+ const reset = (add?: GridLoaderPartialStates<T>, items: T[] = []) => {
321
325
  const { queryPaging, ...rest } = add ?? {};
322
- const resetState: Partial<GridLoaderStates<T>> = {
323
- queryPaging: {
324
- ...refs.current.queryPaging,
325
- currentPage: 0,
326
- ...queryPaging
327
- },
326
+ const resetState: GridLoaderPartialStates<T> = {
328
327
  autoLoad: true,
329
328
  loadedItems: 0,
330
329
  hasNextPage: true,
@@ -333,6 +332,10 @@ export const ScrollerGrid = <T extends object>(props: ScrollerGridProps<T>) => {
333
332
  ...rest
334
333
  };
335
334
  Object.assign(refs.current, resetState);
335
+ Object.assign(refs.current.queryPaging, {
336
+ currentPage: 0,
337
+ ...queryPaging
338
+ });
336
339
 
337
340
  // Reset items
338
341
  if (refs.current.isMounted !== false) setRows(items, true);
@@ -12,6 +12,7 @@ import { useCombinedRefs } from '../uses/useCombinedRefs';
12
12
  import {
13
13
  GridLoadDataProps,
14
14
  GridLoader,
15
+ GridLoaderPartialStates,
15
16
  GridLoaderStates,
16
17
  GridSizeGet
17
18
  } from './GridLoader';
@@ -158,7 +159,7 @@ export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {
158
159
  currentPage: 0,
159
160
  orderBy: defaultOrderBy,
160
161
  orderByAsc: defaultOrderByAsc,
161
- batchSize: batchSize
162
+ batchSize
162
163
  },
163
164
  autoLoad,
164
165
  loadedItems: 0,
@@ -219,10 +220,7 @@ export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {
219
220
  // Update rows
220
221
  setRows(newRows);
221
222
  } else {
222
- var currentPage =
223
- stateRefs.current.queryPaging.currentPage ?? 0;
224
- stateRefs.current.queryPaging.currentPage =
225
- currentPage + pageAdd;
223
+ stateRefs.current.queryPaging.currentPage += pageAdd;
226
224
 
227
225
  // Update rows, avoid duplicate items
228
226
  const newRows = [...rows];
@@ -248,14 +246,9 @@ export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {
248
246
  };
249
247
 
250
248
  // Reset the state and load again
251
- const reset = (add?: Partial<GridLoaderStates<T>>, items: T[] = []) => {
249
+ const reset = (add?: GridLoaderPartialStates<T>, items: T[] = []) => {
252
250
  const { queryPaging, ...rest } = add ?? {};
253
- const resetState: Partial<GridLoaderStates<T>> = {
254
- queryPaging: {
255
- ...stateRefs.current.queryPaging,
256
- currentPage: 0,
257
- ...queryPaging
258
- },
251
+ const resetState: GridLoaderPartialStates<T> = {
259
252
  autoLoad: true,
260
253
  lastLoadedItems: undefined,
261
254
  loadedItems: 0,
@@ -264,6 +257,10 @@ export const ScrollerList = <T extends object>(props: ScrollerListProps<T>) => {
264
257
  ...rest
265
258
  };
266
259
  Object.assign(stateRefs.current, resetState);
260
+ Object.assign(stateRefs.current.queryPaging, {
261
+ currentPage: 0,
262
+ ...queryPaging
263
+ });
267
264
 
268
265
  // Reset
269
266
  if (stateRefs.current.isMounted !== false) setRows(items, true);