@firecms/core 3.0.0-canary.84 → 3.0.0-canary.86
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/hooks/useProjectLog.d.ts +2 -2
- package/dist/index.es.js +53 -20
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +53 -20
- package/dist/index.umd.js.map +1 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/datasource.d.ts +13 -6
- package/package.json +13 -13
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -0
- package/src/components/EntityPreview.tsx +1 -0
- package/src/components/SelectableTable/SelectableTable.tsx +0 -1
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/VirtualTable/VirtualTable.tsx +33 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
- package/src/core/FireCMS.tsx +1 -1
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/hooks/data/useDataSource.tsx +1 -1
- package/src/hooks/useProjectLog.tsx +18 -7
- package/src/internal/useBuildDataSource.ts +2 -2
- package/src/types/auth.tsx +1 -1
- package/src/types/collections.ts +1 -1
- package/src/types/datasource.ts +17 -7
|
@@ -25,10 +25,6 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
25
25
|
* The renderer receives props `{ cellData, columns, column, columnIndex, rowData, rowIndex, container, isScrolling }`
|
|
26
26
|
*/
|
|
27
27
|
cellRenderer: React.ComponentType<CellRendererParams<T>>;
|
|
28
|
-
/**
|
|
29
|
-
* If enabled, content is loaded in batch
|
|
30
|
-
*/
|
|
31
|
-
paginationEnabled?: boolean;
|
|
32
28
|
/**
|
|
33
29
|
* Set this callback if you want to support some combinations
|
|
34
30
|
* of filter combinations only.
|
|
@@ -40,6 +36,10 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
40
36
|
* A callback function when scrolling the table to near the end
|
|
41
37
|
*/
|
|
42
38
|
onEndReached?: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Offset in pixels where the onEndReached callback is triggered
|
|
41
|
+
*/
|
|
42
|
+
endOffset?: number;
|
|
43
43
|
/**
|
|
44
44
|
* When the pagination should be reset. E.g. the filters or sorting
|
|
45
45
|
* has been reset.
|
|
@@ -119,8 +119,12 @@ export interface VirtualTableProps<T extends Record<string, any>> {
|
|
|
119
119
|
* @param column
|
|
120
120
|
*/
|
|
121
121
|
AddColumnComponent?: React.ComponentType;
|
|
122
|
+
/**
|
|
123
|
+
* Debug mode
|
|
124
|
+
*/
|
|
125
|
+
debug?: boolean;
|
|
122
126
|
}
|
|
123
|
-
export type CellRendererParams<T
|
|
127
|
+
export type CellRendererParams<T = any> = {
|
|
124
128
|
column: VirtualTableColumn;
|
|
125
129
|
columns: VirtualTableColumn[];
|
|
126
130
|
columnIndex: number;
|
|
@@ -133,7 +137,7 @@ export type CellRendererParams<T extends any = any> = {
|
|
|
133
137
|
* @see Table
|
|
134
138
|
* @group Components
|
|
135
139
|
*/
|
|
136
|
-
export interface VirtualTableColumn<CustomProps
|
|
140
|
+
export interface VirtualTableColumn<CustomProps = any> {
|
|
137
141
|
/**
|
|
138
142
|
* Data key for the cell value, could be "a.b.c"
|
|
139
143
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AuthController, FireCMSPlugin } from "../types";
|
|
1
|
+
import { AuthController, DataSourceDelegate, FireCMSPlugin } from "../types";
|
|
2
2
|
export declare const DEFAULT_SERVER_DEV = "https://api-kdoe6pj3qq-ey.a.run.app";
|
|
3
3
|
export declare const DEFAULT_SERVER = "https://api-drplyi3b6q-ey.a.run.app";
|
|
4
4
|
export type AccessResponse = {
|
|
5
5
|
blocked?: boolean;
|
|
6
6
|
message?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare function useProjectLog(authController: AuthController, plugins?: FireCMSPlugin<any, any, any>[]): AccessResponse | null;
|
|
8
|
+
export declare function useProjectLog(authController: AuthController, dataSourceDelegate: DataSourceDelegate, plugins?: FireCMSPlugin<any, any, any>[]): AccessResponse | null;
|
package/dist/index.es.js
CHANGED
|
@@ -5169,6 +5169,7 @@ const EntityPreviewContainerInner = React.forwardRef(({
|
|
|
5169
5169
|
},
|
|
5170
5170
|
className: cls(
|
|
5171
5171
|
"bg-white dark:bg-gray-900",
|
|
5172
|
+
"min-h-[42px]",
|
|
5172
5173
|
fullwidth ? "w-full" : "",
|
|
5173
5174
|
"items-center",
|
|
5174
5175
|
hover ? "hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800" : "",
|
|
@@ -7141,6 +7142,7 @@ const TableReferenceFieldSuccess = React__default.memo(
|
|
|
7141
7142
|
updateValue(entity ? getReferenceFrom(entity) : null);
|
|
7142
7143
|
}, [updateValue]);
|
|
7143
7144
|
const onMultipleEntitiesSelected = useCallback((entities) => {
|
|
7145
|
+
console.log("onMultipleEntitiesSelected", entities);
|
|
7144
7146
|
updateValue(entities.map((e) => getReferenceFrom(e)));
|
|
7145
7147
|
}, [updateValue]);
|
|
7146
7148
|
const selectedEntityIds = internalValue ? Array.isArray(internalValue) ? internalValue.map((ref) => ref.id) : internalValue.id ? [internalValue.id] : [] : [];
|
|
@@ -9050,6 +9052,7 @@ const VirtualTable = React__default.memo(
|
|
|
9050
9052
|
data,
|
|
9051
9053
|
onResetPagination,
|
|
9052
9054
|
onEndReached,
|
|
9055
|
+
endOffset = 600,
|
|
9053
9056
|
rowHeight = 54,
|
|
9054
9057
|
columns: columnsProp,
|
|
9055
9058
|
onRowClick,
|
|
@@ -9069,7 +9072,8 @@ const VirtualTable = React__default.memo(
|
|
|
9069
9072
|
style,
|
|
9070
9073
|
className,
|
|
9071
9074
|
endAdornment,
|
|
9072
|
-
AddColumnComponent
|
|
9075
|
+
AddColumnComponent,
|
|
9076
|
+
debug
|
|
9073
9077
|
}) {
|
|
9074
9078
|
const sortByProperty = sortBy ? sortBy[0] : void 0;
|
|
9075
9079
|
const currentSort = sortBy ? sortBy[1] : void 0;
|
|
@@ -9081,9 +9085,13 @@ const VirtualTable = React__default.memo(
|
|
|
9081
9085
|
}, [columnsProp]);
|
|
9082
9086
|
const [measureRef, bounds] = useMeasure();
|
|
9083
9087
|
const onColumnResizeInternal = useCallback((params) => {
|
|
9088
|
+
if (debug)
|
|
9089
|
+
console.log("onColumnResizeInternal", params);
|
|
9084
9090
|
setColumns(columns.map((column) => column.key === params.column.key ? params.column : column));
|
|
9085
9091
|
}, [columns]);
|
|
9086
9092
|
const onColumnResizeEndInternal = useCallback((params) => {
|
|
9093
|
+
if (debug)
|
|
9094
|
+
console.log("onColumnResizeEndInternal", params);
|
|
9087
9095
|
setColumns(columns.map((column) => column.key === params.column.key ? params.column : column));
|
|
9088
9096
|
if (onColumnResize) {
|
|
9089
9097
|
onColumnResize(params);
|
|
@@ -9091,15 +9099,21 @@ const VirtualTable = React__default.memo(
|
|
|
9091
9099
|
}, [columns, onColumnResize]);
|
|
9092
9100
|
const filterRef = useRef();
|
|
9093
9101
|
useEffect(() => {
|
|
9102
|
+
if (debug)
|
|
9103
|
+
console.log("Filter updated", filterInput);
|
|
9094
9104
|
filterRef.current = filterInput;
|
|
9095
9105
|
}, [filterInput]);
|
|
9096
9106
|
const scrollToTop = useCallback(() => {
|
|
9107
|
+
if (debug)
|
|
9108
|
+
console.log("scrollToTop");
|
|
9097
9109
|
endReachCallbackThreshold.current = 0;
|
|
9098
9110
|
if (tableRef.current) {
|
|
9099
9111
|
tableRef.current.scrollTo(tableRef.current?.scrollLeft, 0);
|
|
9100
9112
|
}
|
|
9101
9113
|
}, []);
|
|
9102
9114
|
const onColumnSort = useCallback((key) => {
|
|
9115
|
+
if (debug)
|
|
9116
|
+
console.log("onColumnSort", key);
|
|
9103
9117
|
const isDesc = sortByProperty === key && currentSort === "desc";
|
|
9104
9118
|
const isAsc = sortByProperty === key && currentSort === "asc";
|
|
9105
9119
|
const newSort = isAsc ? "desc" : isDesc ? void 0 : "asc";
|
|
@@ -9120,26 +9134,34 @@ const VirtualTable = React__default.memo(
|
|
|
9120
9134
|
}
|
|
9121
9135
|
scrollToTop();
|
|
9122
9136
|
}, [checkFilterCombination, currentSort, onFilterUpdate, onResetPagination, onSortByUpdate, scrollToTop, sortByProperty]);
|
|
9123
|
-
useCallback(() => {
|
|
9124
|
-
endReachCallbackThreshold.current = 0;
|
|
9125
|
-
if (onSortByUpdate)
|
|
9126
|
-
onSortByUpdate(void 0);
|
|
9127
|
-
}, [onSortByUpdate]);
|
|
9128
9137
|
const maxScroll = Math.max((data?.length ?? 0) * rowHeight - bounds.height, 0);
|
|
9138
|
+
if (debug)
|
|
9139
|
+
console.log("maxScroll", maxScroll);
|
|
9129
9140
|
const onEndReachedInternal = useCallback((scrollOffset) => {
|
|
9130
|
-
if (
|
|
9141
|
+
if (debug)
|
|
9142
|
+
console.log("onEndReachedInternal", scrollOffset, endReachCallbackThreshold.current + endOffset);
|
|
9143
|
+
if (onEndReached && (data?.length ?? 0) > 0 && scrollOffset > endReachCallbackThreshold.current + endOffset) {
|
|
9131
9144
|
endReachCallbackThreshold.current = scrollOffset;
|
|
9132
9145
|
onEndReached();
|
|
9133
9146
|
}
|
|
9134
9147
|
}, [data?.length, onEndReached]);
|
|
9135
9148
|
const onScroll = useCallback(({
|
|
9149
|
+
scrollDirection,
|
|
9136
9150
|
scrollOffset,
|
|
9137
9151
|
scrollUpdateWasRequested
|
|
9138
9152
|
}) => {
|
|
9139
|
-
if (
|
|
9153
|
+
if (debug)
|
|
9154
|
+
console.log("onScroll", {
|
|
9155
|
+
scrollDirection,
|
|
9156
|
+
scrollOffset,
|
|
9157
|
+
scrollUpdateWasRequested
|
|
9158
|
+
});
|
|
9159
|
+
if (!scrollUpdateWasRequested && scrollOffset >= maxScroll - endOffset)
|
|
9140
9160
|
onEndReachedInternal(scrollOffset);
|
|
9141
9161
|
}, [maxScroll, onEndReachedInternal]);
|
|
9142
9162
|
const onFilterUpdateInternal = useCallback((column, filterForProperty) => {
|
|
9163
|
+
if (debug)
|
|
9164
|
+
console.log("onFilterUpdateInternal", column, filterForProperty);
|
|
9143
9165
|
endReachCallbackThreshold.current = 0;
|
|
9144
9166
|
const filter = filterRef.current;
|
|
9145
9167
|
let newFilterValue = filter ? { ...filter } : {};
|
|
@@ -9201,6 +9223,8 @@ const VirtualTable = React__default.memo(
|
|
|
9201
9223
|
endAdornment,
|
|
9202
9224
|
AddColumnComponent
|
|
9203
9225
|
};
|
|
9226
|
+
if (debug)
|
|
9227
|
+
console.log("VirtualTable render", virtualListController);
|
|
9204
9228
|
return /* @__PURE__ */ jsx(
|
|
9205
9229
|
"div",
|
|
9206
9230
|
{
|
|
@@ -9861,7 +9885,6 @@ const SelectableTable = React__default.memo(
|
|
|
9861
9885
|
onEndReached: loadNextPage,
|
|
9862
9886
|
onResetPagination: resetPagination,
|
|
9863
9887
|
error: dataLoadingError,
|
|
9864
|
-
paginationEnabled,
|
|
9865
9888
|
onColumnResize,
|
|
9866
9889
|
rowHeight: getRowHeight(size),
|
|
9867
9890
|
loading: dataLoading,
|
|
@@ -14628,7 +14651,7 @@ function DateTimeFieldBinding({
|
|
|
14628
14651
|
DateTimeField,
|
|
14629
14652
|
{
|
|
14630
14653
|
value: internalValue,
|
|
14631
|
-
onChange: (dateValue) => setValue(dateValue
|
|
14654
|
+
onChange: (dateValue) => setValue(dateValue),
|
|
14632
14655
|
size: "medium",
|
|
14633
14656
|
mode: property.mode,
|
|
14634
14657
|
clearable: property.clearable,
|
|
@@ -19167,7 +19190,7 @@ function useBuildDataSource({
|
|
|
19167
19190
|
inputValues: firestoreValues,
|
|
19168
19191
|
properties,
|
|
19169
19192
|
status,
|
|
19170
|
-
timestampNowValue: delegate.currentTime(),
|
|
19193
|
+
timestampNowValue: delegate.currentTime?.() ?? /* @__PURE__ */ new Date(),
|
|
19171
19194
|
setDateToMidnight: delegate.setDateToMidnight
|
|
19172
19195
|
}
|
|
19173
19196
|
) : firestoreValues;
|
|
@@ -19223,7 +19246,7 @@ function useBuildDataSource({
|
|
|
19223
19246
|
filter,
|
|
19224
19247
|
orderBy,
|
|
19225
19248
|
order,
|
|
19226
|
-
isCollectionGroup: Boolean(collection.collectionGroup)
|
|
19249
|
+
isCollectionGroup: Boolean(collection.collectionGroup)
|
|
19227
19250
|
});
|
|
19228
19251
|
} : void 0,
|
|
19229
19252
|
isFilterCombinationValid: useCallback(({
|
|
@@ -19249,8 +19272,13 @@ function useBuildDataSource({
|
|
|
19249
19272
|
};
|
|
19250
19273
|
}
|
|
19251
19274
|
const DEFAULT_SERVER = "https://api-drplyi3b6q-ey.a.run.app";
|
|
19252
|
-
async function makeRequest(authController, pluginKeys) {
|
|
19253
|
-
|
|
19275
|
+
async function makeRequest(authController, dataSourceKey, pluginKeys) {
|
|
19276
|
+
let idToken;
|
|
19277
|
+
try {
|
|
19278
|
+
idToken = await authController.getAuthToken();
|
|
19279
|
+
} catch (e) {
|
|
19280
|
+
idToken = null;
|
|
19281
|
+
}
|
|
19254
19282
|
return fetch(
|
|
19255
19283
|
DEFAULT_SERVER + "/access_log",
|
|
19256
19284
|
{
|
|
@@ -19258,24 +19286,29 @@ async function makeRequest(authController, pluginKeys) {
|
|
|
19258
19286
|
method: "POST",
|
|
19259
19287
|
headers: {
|
|
19260
19288
|
"Content-Type": "application/json",
|
|
19261
|
-
Authorization: `Basic ${
|
|
19289
|
+
Authorization: `Basic ${idToken}`
|
|
19262
19290
|
},
|
|
19263
|
-
body: JSON.stringify({
|
|
19291
|
+
body: JSON.stringify({
|
|
19292
|
+
email: authController.user?.email ?? null,
|
|
19293
|
+
datasource: dataSourceKey,
|
|
19294
|
+
plugins: pluginKeys
|
|
19295
|
+
})
|
|
19264
19296
|
}
|
|
19265
19297
|
).then(async (res) => {
|
|
19266
19298
|
return res.json();
|
|
19267
19299
|
});
|
|
19268
19300
|
}
|
|
19269
|
-
function useProjectLog(authController, plugins) {
|
|
19301
|
+
function useProjectLog(authController, dataSourceDelegate, plugins) {
|
|
19270
19302
|
const [accessResponse, setAccessResponse] = useState(null);
|
|
19271
19303
|
const accessedUserRef = useRef(null);
|
|
19304
|
+
const dataSourceKey = dataSourceDelegate.key;
|
|
19272
19305
|
const pluginKeys = plugins?.map((plugin) => plugin.key);
|
|
19273
19306
|
useEffect(() => {
|
|
19274
19307
|
if (authController.user && authController.user.uid !== accessedUserRef.current && !authController.initialLoading) {
|
|
19275
|
-
makeRequest(authController, pluginKeys).then(setAccessResponse);
|
|
19308
|
+
makeRequest(authController, dataSourceKey, pluginKeys).then(setAccessResponse);
|
|
19276
19309
|
accessedUserRef.current = authController.user.uid;
|
|
19277
19310
|
}
|
|
19278
|
-
}, [authController, pluginKeys]);
|
|
19311
|
+
}, [authController, dataSourceKey, pluginKeys]);
|
|
19279
19312
|
return accessResponse;
|
|
19280
19313
|
}
|
|
19281
19314
|
function FireCMS(props) {
|
|
@@ -19317,7 +19350,7 @@ function FireCMS(props) {
|
|
|
19317
19350
|
const analyticsController = useMemo(() => ({
|
|
19318
19351
|
onAnalyticsEvent
|
|
19319
19352
|
}), []);
|
|
19320
|
-
const accessResponse = useProjectLog(authController, plugins);
|
|
19353
|
+
const accessResponse = useProjectLog(authController, dataSourceDelegate, plugins);
|
|
19321
19354
|
if (navigationController.navigationLoadingError) {
|
|
19322
19355
|
return /* @__PURE__ */ jsx(CenteredView, { maxWidth: "md", children: /* @__PURE__ */ jsx(
|
|
19323
19356
|
ErrorView,
|