@firecms/core 3.0.0-canary.85 → 3.0.0-canary.87
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/dist/components/VirtualTable/VirtualTableProps.d.ts +10 -6
- package/dist/index.es.js +30 -9
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +30 -9
- package/dist/index.umd.js.map +1 -1
- package/dist/types/datasource.d.ts +4 -0
- package/package.json +6 -6
- package/src/components/SelectableTable/SelectableTable.tsx +0 -1
- package/src/components/VirtualTable/VirtualTable.tsx +33 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
- package/src/types/datasource.ts +5 -0
|
@@ -175,6 +175,10 @@ export interface DataSourceDelegate {
|
|
|
175
175
|
* Key that identifies this data source delegate
|
|
176
176
|
*/
|
|
177
177
|
key: string;
|
|
178
|
+
/**
|
|
179
|
+
* If the data source has been initialised
|
|
180
|
+
*/
|
|
181
|
+
initialised?: boolean;
|
|
178
182
|
/**
|
|
179
183
|
* Fetch data from a collection
|
|
180
184
|
* @param path
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.87",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
50
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
49
|
+
"@firecms/formex": "^3.0.0-canary.87",
|
|
50
|
+
"@firecms/ui": "^3.0.0-canary.87",
|
|
51
51
|
"@fontsource/jetbrains-mono": "^5.0.20",
|
|
52
52
|
"@hello-pangea/dnd": "^16.6.0",
|
|
53
53
|
"@radix-ui/react-portal": "^1.1.1",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"firebase": "^10.5.2",
|
|
73
73
|
"react": "^18.3.1",
|
|
74
74
|
"react-dom": "^18.3.1",
|
|
75
|
-
"react-router": "^6.
|
|
76
|
-
"react-router-dom": "^6.
|
|
75
|
+
"react-router": "^6.25.1",
|
|
76
|
+
"react-router-dom": "^6.25.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@jest/globals": "^29.7.0",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"dist",
|
|
103
103
|
"src"
|
|
104
104
|
],
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "c94eecac10211d63540f88519b2d19a0941b7387",
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public"
|
|
108
108
|
},
|
|
@@ -221,7 +221,6 @@ export const SelectableTable = React.memo<SelectableTableProps<any>>(
|
|
|
221
221
|
onEndReached={loadNextPage}
|
|
222
222
|
onResetPagination={resetPagination}
|
|
223
223
|
error={dataLoadingError}
|
|
224
|
-
paginationEnabled={paginationEnabled}
|
|
225
224
|
onColumnResize={onColumnResize}
|
|
226
225
|
rowHeight={getRowHeight(size)}
|
|
227
226
|
loading={dataLoading}
|
|
@@ -91,6 +91,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
91
91
|
data,
|
|
92
92
|
onResetPagination,
|
|
93
93
|
onEndReached,
|
|
94
|
+
endOffset = 600,
|
|
94
95
|
rowHeight = 54,
|
|
95
96
|
columns: columnsProp,
|
|
96
97
|
onRowClick,
|
|
@@ -110,7 +111,8 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
110
111
|
style,
|
|
111
112
|
className,
|
|
112
113
|
endAdornment,
|
|
113
|
-
AddColumnComponent
|
|
114
|
+
AddColumnComponent,
|
|
115
|
+
debug
|
|
114
116
|
}: VirtualTableProps<T>) {
|
|
115
117
|
|
|
116
118
|
const sortByProperty: string | undefined = sortBy ? sortBy[0] : undefined;
|
|
@@ -128,10 +130,14 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
128
130
|
const [measureRef, bounds] = useMeasure();
|
|
129
131
|
|
|
130
132
|
const onColumnResizeInternal = useCallback((params: OnVirtualTableColumnResizeParams) => {
|
|
133
|
+
if (debug)
|
|
134
|
+
console.log("onColumnResizeInternal", params);
|
|
131
135
|
setColumns(columns.map((column) => column.key === params.column.key ? params.column : column));
|
|
132
136
|
}, [columns]);
|
|
133
137
|
|
|
134
138
|
const onColumnResizeEndInternal = useCallback((params: OnVirtualTableColumnResizeParams) => {
|
|
139
|
+
if (debug)
|
|
140
|
+
console.log("onColumnResizeEndInternal", params);
|
|
135
141
|
setColumns(columns.map((column) => column.key === params.column.key ? params.column : column));
|
|
136
142
|
if (onColumnResize) {
|
|
137
143
|
onColumnResize(params);
|
|
@@ -142,10 +148,14 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
142
148
|
const filterRef = useRef<VirtualTableFilterValues<any> | undefined>();
|
|
143
149
|
|
|
144
150
|
useEffect(() => {
|
|
151
|
+
if (debug)
|
|
152
|
+
console.log("Filter updated", filterInput);
|
|
145
153
|
filterRef.current = filterInput;
|
|
146
154
|
}, [filterInput]);
|
|
147
155
|
|
|
148
156
|
const scrollToTop = useCallback(() => {
|
|
157
|
+
if (debug)
|
|
158
|
+
console.log("scrollToTop");
|
|
149
159
|
endReachCallbackThreshold.current = 0;
|
|
150
160
|
if (tableRef.current) {
|
|
151
161
|
// scrollRef.current = [scrollRef.current[0], 0];
|
|
@@ -155,6 +165,9 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
155
165
|
|
|
156
166
|
const onColumnSort = useCallback((key: string) => {
|
|
157
167
|
|
|
168
|
+
if (debug)
|
|
169
|
+
console.log("onColumnSort", key);
|
|
170
|
+
|
|
158
171
|
const isDesc = sortByProperty === key && currentSort === "desc";
|
|
159
172
|
const isAsc = sortByProperty === key && currentSort === "asc";
|
|
160
173
|
const newSort = isAsc ? "desc" : (isDesc ? undefined : "asc");
|
|
@@ -181,21 +194,21 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
181
194
|
scrollToTop();
|
|
182
195
|
}, [checkFilterCombination, currentSort, onFilterUpdate, onResetPagination, onSortByUpdate, scrollToTop, sortByProperty]);
|
|
183
196
|
|
|
184
|
-
const resetSort = useCallback(() => {
|
|
185
|
-
endReachCallbackThreshold.current = 0;
|
|
186
|
-
if (onSortByUpdate)
|
|
187
|
-
onSortByUpdate(undefined);
|
|
188
|
-
}, [onSortByUpdate]);
|
|
189
|
-
|
|
190
197
|
const maxScroll = Math.max((data?.length ?? 0) * rowHeight - bounds.height, 0);
|
|
198
|
+
if (debug)
|
|
199
|
+
console.log("maxScroll", maxScroll);
|
|
200
|
+
|
|
191
201
|
const onEndReachedInternal = useCallback((scrollOffset: number) => {
|
|
192
|
-
if (
|
|
202
|
+
if (debug)
|
|
203
|
+
console.log("onEndReachedInternal", scrollOffset, endReachCallbackThreshold.current + endOffset);
|
|
204
|
+
if (onEndReached && (data?.length ?? 0) > 0 && scrollOffset > endReachCallbackThreshold.current + endOffset) {
|
|
193
205
|
endReachCallbackThreshold.current = scrollOffset;
|
|
194
206
|
onEndReached();
|
|
195
207
|
}
|
|
196
208
|
}, [data?.length, onEndReached]);
|
|
197
209
|
|
|
198
210
|
const onScroll = useCallback(({
|
|
211
|
+
scrollDirection,
|
|
199
212
|
scrollOffset,
|
|
200
213
|
scrollUpdateWasRequested
|
|
201
214
|
}: {
|
|
@@ -203,11 +216,19 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
203
216
|
scrollOffset: number,
|
|
204
217
|
scrollUpdateWasRequested: boolean;
|
|
205
218
|
}) => {
|
|
206
|
-
if
|
|
219
|
+
if(debug)
|
|
220
|
+
console.log("onScroll", {
|
|
221
|
+
scrollDirection,
|
|
222
|
+
scrollOffset,
|
|
223
|
+
scrollUpdateWasRequested
|
|
224
|
+
});
|
|
225
|
+
if (!scrollUpdateWasRequested && (scrollOffset >= maxScroll - endOffset))
|
|
207
226
|
onEndReachedInternal(scrollOffset);
|
|
208
227
|
}, [maxScroll, onEndReachedInternal]);
|
|
209
228
|
|
|
210
229
|
const onFilterUpdateInternal = useCallback((column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp, any]) => {
|
|
230
|
+
if(debug)
|
|
231
|
+
console.log("onFilterUpdateInternal", column, filterForProperty);
|
|
211
232
|
|
|
212
233
|
endReachCallbackThreshold.current = 0;
|
|
213
234
|
const filter = filterRef.current;
|
|
@@ -272,6 +293,9 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
272
293
|
AddColumnComponent
|
|
273
294
|
};
|
|
274
295
|
|
|
296
|
+
if(debug)
|
|
297
|
+
console.log("VirtualTable render", virtualListController);
|
|
298
|
+
|
|
275
299
|
// useTraceUpdate(virtualListController);
|
|
276
300
|
return (
|
|
277
301
|
<div
|
|
@@ -31,11 +31,6 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
31
31
|
*/
|
|
32
32
|
cellRenderer: React.ComponentType<CellRendererParams<T>>;
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* If enabled, content is loaded in batch
|
|
36
|
-
*/
|
|
37
|
-
paginationEnabled?: boolean;
|
|
38
|
-
|
|
39
34
|
/**
|
|
40
35
|
* Set this callback if you want to support some combinations
|
|
41
36
|
* of filter combinations only.
|
|
@@ -50,6 +45,11 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
50
45
|
*/
|
|
51
46
|
onEndReached?: () => void;
|
|
52
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Offset in pixels where the onEndReached callback is triggered
|
|
50
|
+
*/
|
|
51
|
+
endOffset?: number;
|
|
52
|
+
|
|
53
53
|
/**
|
|
54
54
|
* When the pagination should be reset. E.g. the filters or sorting
|
|
55
55
|
* has been reset.
|
|
@@ -147,9 +147,14 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
147
147
|
*/
|
|
148
148
|
AddColumnComponent?: React.ComponentType;
|
|
149
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Debug mode
|
|
152
|
+
*/
|
|
153
|
+
debug?: boolean;
|
|
154
|
+
|
|
150
155
|
}
|
|
151
156
|
|
|
152
|
-
export type CellRendererParams<T
|
|
157
|
+
export type CellRendererParams<T = any> = {
|
|
153
158
|
column: VirtualTableColumn;
|
|
154
159
|
columns: VirtualTableColumn[];
|
|
155
160
|
columnIndex: number;
|
|
@@ -163,7 +168,7 @@ export type CellRendererParams<T extends any = any> = {
|
|
|
163
168
|
* @see Table
|
|
164
169
|
* @group Components
|
|
165
170
|
*/
|
|
166
|
-
export interface VirtualTableColumn<CustomProps
|
|
171
|
+
export interface VirtualTableColumn<CustomProps = any> {
|
|
167
172
|
|
|
168
173
|
/**
|
|
169
174
|
* Data key for the cell value, could be "a.b.c"
|
|
@@ -237,7 +242,6 @@ export type OnVirtualTableColumnResizeParams = {
|
|
|
237
242
|
column: VirtualTableColumn
|
|
238
243
|
};
|
|
239
244
|
|
|
240
|
-
|
|
241
245
|
/**
|
|
242
246
|
* @see Table
|
|
243
247
|
* @group Components
|
package/src/types/datasource.ts
CHANGED