@etsoo/materialui 1.0.8 → 1.0.9
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/ListMoreDisplay.js +6 -3
- package/lib/ScrollerListEx.d.ts +1 -6
- package/lib/ScrollerListEx.js +3 -3
- package/lib/TableEx.js +2 -1
- package/package.json +1 -1
- package/src/ListMoreDisplay.tsx +5 -3
- package/src/ScrollerListEx.tsx +3 -11
- package/src/TableEx.tsx +2 -1
package/lib/ListMoreDisplay.js
CHANGED
|
@@ -22,7 +22,8 @@ export function ListMoreDisplay(props) {
|
|
|
22
22
|
orderBy: defaultOrderBy,
|
|
23
23
|
batchSize: 10,
|
|
24
24
|
loadedItems: 0,
|
|
25
|
-
selectedItems: []
|
|
25
|
+
selectedItems: [],
|
|
26
|
+
idCache: {}
|
|
26
27
|
});
|
|
27
28
|
const ref = refs.current;
|
|
28
29
|
// States
|
|
@@ -59,13 +60,15 @@ export function ListMoreDisplay(props) {
|
|
|
59
60
|
// Next page
|
|
60
61
|
ref.currentPage = currentPage + 1;
|
|
61
62
|
// Update rows
|
|
62
|
-
if (states.items == null || reset)
|
|
63
|
+
if (states.items == null || reset) {
|
|
63
64
|
setStates({ items, completed: !hasNextPage });
|
|
64
|
-
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
65
67
|
setStates({
|
|
66
68
|
items: [...states.items, ...items],
|
|
67
69
|
completed: !hasNextPage
|
|
68
70
|
});
|
|
71
|
+
}
|
|
69
72
|
};
|
|
70
73
|
const reset = (data) => {
|
|
71
74
|
// Update the form data
|
package/lib/ScrollerListEx.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare type ScrollerListExItemSize = ((index: number) => [number, number
|
|
|
34
34
|
/**
|
|
35
35
|
* Extended ScrollerList Props
|
|
36
36
|
*/
|
|
37
|
-
export declare type ScrollerListExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> & {
|
|
37
|
+
export declare type ScrollerListExProps<T extends object, D extends DataTypes.Keys<T>> = Omit<ScrollerListProps<T, D>, 'itemRenderer' | 'itemSize'> & {
|
|
38
38
|
/**
|
|
39
39
|
* Alternating colors for odd/even rows
|
|
40
40
|
*/
|
|
@@ -47,11 +47,6 @@ export declare type ScrollerListExProps<T extends object, D extends DataTypes.Ke
|
|
|
47
47
|
* Item renderer
|
|
48
48
|
*/
|
|
49
49
|
itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
|
|
50
|
-
/**
|
|
51
|
-
* Id field
|
|
52
|
-
* Failed: D extends { id: DataTypes.IdType } ? { idField?: D } : { idField: D }
|
|
53
|
-
*/
|
|
54
|
-
idField?: D;
|
|
55
50
|
/**
|
|
56
51
|
* Item size, a function indicates its a variable size list
|
|
57
52
|
*/
|
package/lib/ScrollerListEx.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css } from '@emotion/css';
|
|
2
2
|
import { ScrollerList } from '@etsoo/react';
|
|
3
|
-
import {
|
|
3
|
+
import { Utils } from '@etsoo/shared';
|
|
4
4
|
import { useTheme } from '@mui/material';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { MUGlobal } from './MUGlobal';
|
|
@@ -112,7 +112,7 @@ export function ScrollerListEx(props) {
|
|
|
112
112
|
return selected;
|
|
113
113
|
};
|
|
114
114
|
// Destruct
|
|
115
|
-
const { alternatingColors = [undefined, undefined], className, idField = 'id', innerItemRenderer, itemSize,
|
|
115
|
+
const { alternatingColors = [undefined, undefined], className, idField = 'id', innerItemRenderer, itemSize, itemRenderer = (itemProps) => {
|
|
116
116
|
const [itemHeight, space, margins] = calculateItemSize(itemProps.index);
|
|
117
117
|
return defaultItemRenderer({
|
|
118
118
|
itemHeight,
|
|
@@ -163,5 +163,5 @@ export function ScrollerListEx(props) {
|
|
|
163
163
|
return size + space;
|
|
164
164
|
};
|
|
165
165
|
// Layout
|
|
166
|
-
return (React.createElement(ScrollerList, { className: Utils.mergeClasses('ScrollerListEx-Body', className, createGridStyle(alternatingColors, selectedColor)),
|
|
166
|
+
return (React.createElement(ScrollerList, { className: Utils.mergeClasses('ScrollerListEx-Body', className, createGridStyle(alternatingColors, selectedColor)), idField: idField, itemRenderer: itemRenderer, itemSize: itemSizeLocal, ...rest }));
|
|
167
167
|
}
|
package/lib/TableEx.js
CHANGED
|
@@ -51,7 +51,8 @@ export function TableEx(props) {
|
|
|
51
51
|
? (_a = columns.find((column) => column.field === defaultOrderBy)) === null || _a === void 0 ? void 0 : _a.sortAsc
|
|
52
52
|
: undefined,
|
|
53
53
|
batchSize: rowsPerPageLocal,
|
|
54
|
-
selectedItems: []
|
|
54
|
+
selectedItems: [],
|
|
55
|
+
idCache: {}
|
|
55
56
|
});
|
|
56
57
|
const state = stateRefs.current;
|
|
57
58
|
// Reset the state and load again
|
package/package.json
CHANGED
package/src/ListMoreDisplay.tsx
CHANGED
|
@@ -92,7 +92,8 @@ export function ListMoreDisplay<
|
|
|
92
92
|
orderBy: defaultOrderBy,
|
|
93
93
|
batchSize: 10,
|
|
94
94
|
loadedItems: 0,
|
|
95
|
-
selectedItems: []
|
|
95
|
+
selectedItems: [],
|
|
96
|
+
idCache: {}
|
|
96
97
|
});
|
|
97
98
|
const ref = refs.current;
|
|
98
99
|
|
|
@@ -141,13 +142,14 @@ export function ListMoreDisplay<
|
|
|
141
142
|
ref.currentPage = currentPage + 1;
|
|
142
143
|
|
|
143
144
|
// Update rows
|
|
144
|
-
if (states.items == null || reset)
|
|
145
|
+
if (states.items == null || reset) {
|
|
145
146
|
setStates({ items, completed: !hasNextPage });
|
|
146
|
-
else
|
|
147
|
+
} else {
|
|
147
148
|
setStates({
|
|
148
149
|
items: [...states.items, ...items],
|
|
149
150
|
completed: !hasNextPage
|
|
150
151
|
});
|
|
152
|
+
}
|
|
151
153
|
};
|
|
152
154
|
|
|
153
155
|
const reset = (data?: GridData) => {
|
package/src/ScrollerListEx.tsx
CHANGED
|
@@ -120,7 +120,7 @@ export type ScrollerListExItemSize =
|
|
|
120
120
|
export type ScrollerListExProps<
|
|
121
121
|
T extends object,
|
|
122
122
|
D extends DataTypes.Keys<T>
|
|
123
|
-
> = Omit<ScrollerListProps<T>, 'itemRenderer' | 'itemSize'> & {
|
|
123
|
+
> = Omit<ScrollerListProps<T, D>, 'itemRenderer' | 'itemSize'> & {
|
|
124
124
|
/**
|
|
125
125
|
* Alternating colors for odd/even rows
|
|
126
126
|
*/
|
|
@@ -138,12 +138,6 @@ export type ScrollerListExProps<
|
|
|
138
138
|
*/
|
|
139
139
|
itemRenderer?: (props: ListChildComponentProps<T>) => React.ReactElement;
|
|
140
140
|
|
|
141
|
-
/**
|
|
142
|
-
* Id field
|
|
143
|
-
* Failed: D extends { id: DataTypes.IdType } ? { idField?: D } : { idField: D }
|
|
144
|
-
*/
|
|
145
|
-
idField?: D;
|
|
146
|
-
|
|
147
141
|
/**
|
|
148
142
|
* Item size, a function indicates its a variable size list
|
|
149
143
|
*/
|
|
@@ -302,8 +296,6 @@ export function ScrollerListEx<
|
|
|
302
296
|
idField = 'id' as D,
|
|
303
297
|
innerItemRenderer,
|
|
304
298
|
itemSize,
|
|
305
|
-
itemKey = (index: number, data: T) =>
|
|
306
|
-
DataTypes.getIdValue1(data, idField) ?? index,
|
|
307
299
|
itemRenderer = (itemProps) => {
|
|
308
300
|
const [itemHeight, space, margins] = calculateItemSize(
|
|
309
301
|
itemProps.index
|
|
@@ -372,13 +364,13 @@ export function ScrollerListEx<
|
|
|
372
364
|
|
|
373
365
|
// Layout
|
|
374
366
|
return (
|
|
375
|
-
<ScrollerList<T>
|
|
367
|
+
<ScrollerList<T, D>
|
|
376
368
|
className={Utils.mergeClasses(
|
|
377
369
|
'ScrollerListEx-Body',
|
|
378
370
|
className,
|
|
379
371
|
createGridStyle(alternatingColors, selectedColor)
|
|
380
372
|
)}
|
|
381
|
-
|
|
373
|
+
idField={idField}
|
|
382
374
|
itemRenderer={itemRenderer}
|
|
383
375
|
itemSize={itemSizeLocal}
|
|
384
376
|
{...rest}
|
package/src/TableEx.tsx
CHANGED
|
@@ -163,7 +163,8 @@ export function TableEx<
|
|
|
163
163
|
? columns.find((column) => column.field === defaultOrderBy)?.sortAsc
|
|
164
164
|
: undefined,
|
|
165
165
|
batchSize: rowsPerPageLocal,
|
|
166
|
-
selectedItems: []
|
|
166
|
+
selectedItems: [],
|
|
167
|
+
idCache: {}
|
|
167
168
|
});
|
|
168
169
|
const state = stateRefs.current;
|
|
169
170
|
|