@firecms/core 3.0.0-alpha.80 → 3.0.0-alpha.82
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/EntityCollectionTable/EntityCollectionTableProps.d.ts +3 -3
- package/dist/components/EntityCollectionTable/column_utils.d.ts +2 -2
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +5 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/hooks/useCustomizationController.d.ts +11 -0
- package/dist/hooks/useFireCMSContext.d.ts +0 -1
- package/dist/index.es.js +4614 -4592
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildCustomizationController.d.ts +2 -0
- package/dist/types/analytics_controller.d.ts +7 -0
- package/dist/types/collections.d.ts +3 -0
- package/dist/types/customization_controller.d.ts +47 -0
- package/dist/types/entity_callbacks.d.ts +17 -3
- package/dist/types/firecms_context.d.ts +6 -46
- package/dist/types/index.d.ts +2 -0
- package/dist/util/icons.d.ts +4 -1
- package/dist/util/useTraceUpdate.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/DeleteEntityDialog.tsx +9 -3
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +28 -5
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +4 -5
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +125 -122
- package/src/components/EntityCollectionTable/filters/DateTimeFilterField.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -3
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +74 -50
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -3
- package/src/components/EntityPreview.tsx +11 -7
- package/src/components/HomePage/DefaultHomePage.tsx +9 -8
- package/src/components/HomePage/NavigationCollectionCard.tsx +6 -5
- package/src/components/ReferenceSelectionInner.tsx +13 -9
- package/src/components/VirtualTable/VirtualTable.tsx +23 -20
- package/src/components/VirtualTable/VirtualTableCell.tsx +27 -9
- package/src/components/VirtualTable/VirtualTableHeader.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableProps.tsx +2 -2
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +2 -2
- package/src/contexts/AnalyticsContext.tsx +4 -0
- package/src/contexts/CustomizationControllerContext.tsx +4 -0
- package/src/core/Drawer.tsx +7 -6
- package/src/core/FireCMS.tsx +39 -29
- package/src/form/EntityForm.tsx +16 -5
- package/src/form/PropertyFieldBinding.tsx +8 -10
- package/src/form/components/CustomIdField.tsx +7 -5
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +1 -2
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -2
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -6
- package/src/hooks/data/save.ts +8 -3
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useAnalyticsController.tsx +8 -0
- package/src/hooks/useCustomizationController.tsx +14 -0
- package/src/hooks/useFireCMSContext.tsx +8 -7
- package/src/internal/EntityView.tsx +4 -2
- package/src/internal/useBuildCustomizationController.tsx +5 -0
- package/src/internal/useBuildSideDialogsController.tsx +0 -1
- package/src/preview/PropertyPreview.tsx +4 -3
- package/src/preview/components/DatePreview.tsx +4 -5
- package/src/preview/components/ReferencePreview.tsx +17 -8
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -4
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +3 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +3 -3
- package/src/types/analytics_controller.tsx +10 -0
- package/src/types/collections.ts +3 -0
- package/src/types/customization_controller.tsx +58 -0
- package/src/types/entity_callbacks.ts +22 -3
- package/src/types/firecms_context.tsx +6 -51
- package/src/types/index.ts +2 -0
- package/src/util/icons.tsx +22 -19
- package/src/util/useTraceUpdate.tsx +5 -5
|
@@ -306,6 +306,9 @@ export type SelectionController<M extends Record<string, any> = any> = {
|
|
|
306
306
|
export type WhereFilterOp = "<" | "<=" | "==" | "!=" | ">=" | ">" | "array-contains" | "in" | "not-in" | "array-contains-any";
|
|
307
307
|
/**
|
|
308
308
|
* Used to define filters applied in collections
|
|
309
|
+
*
|
|
310
|
+
* e.g. `{ age: [">=", 18] }`
|
|
311
|
+
*
|
|
309
312
|
* @group Models
|
|
310
313
|
*/
|
|
311
314
|
export type FilterValues<Key extends string> = Partial<Record<Key, [WhereFilterOp, any]>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EntityLinkBuilder } from "./entity_link_builder";
|
|
3
|
+
import { FireCMSPlugin } from "./plugins";
|
|
4
|
+
import { EntityCustomView } from "./collections";
|
|
5
|
+
import { Locale } from "./locales";
|
|
6
|
+
import { PropertyConfig } from "./property_config";
|
|
7
|
+
export type CustomizationController = {
|
|
8
|
+
/**
|
|
9
|
+
* Builder for generating utility links for entities
|
|
10
|
+
*/
|
|
11
|
+
entityLinkBuilder?: EntityLinkBuilder;
|
|
12
|
+
/**
|
|
13
|
+
* Use plugins to modify the behaviour of the CMS.
|
|
14
|
+
*/
|
|
15
|
+
plugins?: FireCMSPlugin<any, any, any>[];
|
|
16
|
+
/**
|
|
17
|
+
* List of additional custom views for entities.
|
|
18
|
+
* You can use the key to reference the custom view in
|
|
19
|
+
* the `entityViews` prop of a collection.
|
|
20
|
+
*
|
|
21
|
+
* You can also define an entity view from the UI.
|
|
22
|
+
*/
|
|
23
|
+
entityViews?: EntityCustomView[];
|
|
24
|
+
/**
|
|
25
|
+
* Format of the dates in the CMS.
|
|
26
|
+
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
27
|
+
*/
|
|
28
|
+
dateTimeFormat?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Locale of the CMS, currently only affecting dates
|
|
31
|
+
*/
|
|
32
|
+
locale?: Locale;
|
|
33
|
+
/**
|
|
34
|
+
* Record of custom form fields to be used in the CMS.
|
|
35
|
+
* You can use the key to reference the custom field in
|
|
36
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
37
|
+
*/
|
|
38
|
+
propertyConfigs: Record<string, PropertyConfig>;
|
|
39
|
+
components?: {
|
|
40
|
+
/**
|
|
41
|
+
* Component to render when a reference is missing
|
|
42
|
+
*/
|
|
43
|
+
missingReference?: React.ComponentType<{
|
|
44
|
+
path: string;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -24,14 +24,14 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
24
24
|
* Callback used when saving fails
|
|
25
25
|
* @param entitySaveProps
|
|
26
26
|
*/
|
|
27
|
-
onSaveFailure?(entitySaveProps:
|
|
27
|
+
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M, UserType>): Promise<void> | void;
|
|
28
28
|
/**
|
|
29
29
|
* Callback used before saving, you need to return the values that will get
|
|
30
30
|
* saved. If you throw an error in this method the process stops, and an
|
|
31
31
|
* error snackbar gets displayed.
|
|
32
32
|
* @param entitySaveProps
|
|
33
33
|
*/
|
|
34
|
-
onPreSave?(entitySaveProps:
|
|
34
|
+
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M, UserType>): Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
35
35
|
/**
|
|
36
36
|
* Callback used after the entity is deleted.
|
|
37
37
|
* If you throw an error in this method the process stops, and an
|
|
@@ -78,6 +78,20 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
|
|
|
78
78
|
*/
|
|
79
79
|
context: FireCMSContext<UserType>;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Parameters passed to hooks before an entity is saved
|
|
83
|
+
* @group Models
|
|
84
|
+
*/
|
|
85
|
+
export type EntityOnPreSaveProps<M extends Record<string, any> = any, UserType extends User = User> = Omit<EntityOnSaveProps<M, UserType>, "entityId"> & {
|
|
86
|
+
entityId?: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Parameters passed to hooks before an entity is saved
|
|
90
|
+
* @group Models
|
|
91
|
+
*/
|
|
92
|
+
export type EntityOnSaveFailureProps<M extends Record<string, any> = any, UserType extends User = User> = Omit<EntityOnSaveProps<M, UserType>, "entityId"> & {
|
|
93
|
+
entityId?: string;
|
|
94
|
+
};
|
|
81
95
|
/**
|
|
82
96
|
* Parameters passed to hooks when an entity is saved
|
|
83
97
|
* @group Models
|
|
@@ -99,7 +113,7 @@ export interface EntityOnSaveProps<M extends Record<string, any> = any, UserType
|
|
|
99
113
|
/**
|
|
100
114
|
* ID of the entity
|
|
101
115
|
*/
|
|
102
|
-
entityId
|
|
116
|
+
entityId: string;
|
|
103
117
|
/**
|
|
104
118
|
* Values being saved
|
|
105
119
|
*/
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import { Locale } from "./locales";
|
|
2
1
|
import { DataSource } from "./datasource";
|
|
3
2
|
import { StorageSource } from "./storage";
|
|
4
3
|
import { NavigationController } from "./navigation";
|
|
5
4
|
import { SideEntityController } from "./side_entity_controller";
|
|
6
5
|
import { AuthController } from "./auth";
|
|
7
|
-
import { EntityLinkBuilder } from "./entity_link_builder";
|
|
8
6
|
import { User } from "./user";
|
|
9
7
|
import { SnackbarController } from "../hooks";
|
|
10
8
|
import { UserConfigurationPersistence } from "./local_config_persistence";
|
|
11
9
|
import { SideDialogsController } from "./side_dialogs_controller";
|
|
12
|
-
import { FireCMSPlugin } from "./plugins";
|
|
13
|
-
import { CMSAnalyticsEvent } from "./analytics";
|
|
14
|
-
import { PropertyConfig } from "./property_config";
|
|
15
|
-
import { EntityCustomView } from "./collections";
|
|
16
10
|
import { DialogsController } from "./dialogs_controller";
|
|
11
|
+
import { CustomizationController } from "./customization_controller";
|
|
12
|
+
import { AnalyticsController } from "./analytics_controller";
|
|
17
13
|
/**
|
|
18
14
|
* Context that includes the internal controllers and contexts used by the app.
|
|
19
15
|
* Some controllers and context included in this context can be accessed
|
|
@@ -56,9 +52,9 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
|
|
|
56
52
|
*/
|
|
57
53
|
authController: AuthControllerType;
|
|
58
54
|
/**
|
|
59
|
-
*
|
|
55
|
+
* This controller holds the customization options for the CMS.
|
|
60
56
|
*/
|
|
61
|
-
|
|
57
|
+
customizationController: CustomizationController;
|
|
62
58
|
/**
|
|
63
59
|
* Use this controller to display snackbars
|
|
64
60
|
*/
|
|
@@ -68,43 +64,7 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
|
|
|
68
64
|
*/
|
|
69
65
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
70
66
|
/**
|
|
71
|
-
*
|
|
72
|
-
* Currently, in ALPHA, and likely subject to change.
|
|
67
|
+
* Callback to send analytics events
|
|
73
68
|
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Callback used to get analytics events from the CMS
|
|
77
|
-
*/
|
|
78
|
-
onAnalyticsEvent?: (event: CMSAnalyticsEvent, data?: object) => void;
|
|
79
|
-
/**
|
|
80
|
-
* Record of custom form fields to be used in the CMS.
|
|
81
|
-
* You can use the key to reference the custom field in
|
|
82
|
-
* the `propertyConfig` prop of a property in a collection.
|
|
83
|
-
*/
|
|
84
|
-
propertyConfigs: Record<string, PropertyConfig>;
|
|
85
|
-
/**
|
|
86
|
-
* List of additional custom views for entities.
|
|
87
|
-
* You can use the key to reference the custom view in
|
|
88
|
-
* the `entityViews` prop of a collection.
|
|
89
|
-
*
|
|
90
|
-
* You can also define an entity view from the UI.
|
|
91
|
-
*/
|
|
92
|
-
entityViews?: EntityCustomView[];
|
|
93
|
-
/**
|
|
94
|
-
* Format of the dates in the CMS.
|
|
95
|
-
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
96
|
-
*/
|
|
97
|
-
dateTimeFormat?: string;
|
|
98
|
-
/**
|
|
99
|
-
* Locale of the CMS, currently only affecting dates
|
|
100
|
-
*/
|
|
101
|
-
locale?: Locale;
|
|
102
|
-
components?: {
|
|
103
|
-
/**
|
|
104
|
-
* Component to render when a reference is missing
|
|
105
|
-
*/
|
|
106
|
-
missingReference?: React.ComponentType<{
|
|
107
|
-
path: string;
|
|
108
|
-
}>;
|
|
109
|
-
};
|
|
69
|
+
analyticsController?: AnalyticsController;
|
|
110
70
|
};
|
package/dist/types/index.d.ts
CHANGED
package/dist/util/icons.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CMSView, EntityCollection } from "../types";
|
|
3
3
|
export declare function getIcon(iconKey?: string, className?: string): React.ReactElement | undefined;
|
|
4
|
-
export declare
|
|
4
|
+
export declare const IconForView: React.NamedExoticComponent<{
|
|
5
|
+
collectionOrView: EntityCollection | CMSView;
|
|
6
|
+
className?: string | undefined;
|
|
7
|
+
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useTraceUpdate(props: any): void;
|
|
1
|
+
export declare function useTraceUpdate(props: any, maxDepth?: number): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-alpha.
|
|
4
|
+
"version": "3.0.0-alpha.82",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@firecms/ui": "^3.0.0-alpha.
|
|
41
|
+
"@firecms/ui": "^3.0.0-alpha.82",
|
|
42
42
|
"@fontsource/ibm-plex-mono": "^5.0.8",
|
|
43
43
|
"@fontsource/roboto": "^5.0.8",
|
|
44
44
|
"@hello-pangea/dnd": "^16.5.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"dist",
|
|
108
108
|
"src"
|
|
109
109
|
],
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "46f5a2edf8418d2c209af9e059617d39213decb8",
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Entity, EntityCallbacks, EntityCollection } from "../types";
|
|
2
2
|
import React, { useCallback, useMemo, useState } from "react";
|
|
3
3
|
import { Button, CircularProgress, Dialog, DialogActions, DialogContent, Typography } from "@firecms/ui";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
deleteEntityWithCallbacks,
|
|
6
|
+
useCustomizationController,
|
|
7
|
+
useDataSource,
|
|
8
|
+
useFireCMSContext,
|
|
9
|
+
useSnackbarController
|
|
10
|
+
} from "../hooks";
|
|
5
11
|
import { resolveCollection } from "../util";
|
|
6
12
|
import { EntityPreview } from "./EntityPreview";
|
|
7
13
|
|
|
@@ -30,7 +36,7 @@ export function DeleteEntityDialog<M extends Record<string, any>>({
|
|
|
30
36
|
}: DeleteEntityDialogProps<M>) {
|
|
31
37
|
|
|
32
38
|
const dataSource = useDataSource();
|
|
33
|
-
|
|
39
|
+
const customizationController = useCustomizationController();
|
|
34
40
|
const snackbarController = useSnackbarController();
|
|
35
41
|
const [loading, setLoading] = useState(false);
|
|
36
42
|
|
|
@@ -52,7 +58,7 @@ export function DeleteEntityDialog<M extends Record<string, any>>({
|
|
|
52
58
|
const resolvedCollection = useMemo(() => resolveCollection<M>({
|
|
53
59
|
collection,
|
|
54
60
|
path,
|
|
55
|
-
fields:
|
|
61
|
+
fields: customizationController.propertyConfigs
|
|
56
62
|
}), [collection, path]);
|
|
57
63
|
|
|
58
64
|
const handleCancel = useCallback(() => {
|
|
@@ -119,7 +119,7 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
119
119
|
|
|
120
120
|
const largeLayout = useLargeLayout();
|
|
121
121
|
const disabledFilterChange = Boolean(forceFilter);
|
|
122
|
-
const selectedEntities = selectionController?.selectedEntities?.length > 0 ? selectionController?.selectedEntities : highlightedEntities;
|
|
122
|
+
const selectedEntities = (selectionController?.selectedEntities?.length > 0 ? selectionController?.selectedEntities : highlightedEntities)?.filter(Boolean);
|
|
123
123
|
|
|
124
124
|
const context: FireCMSContext<UserType> = useFireCMSContext();
|
|
125
125
|
|
|
@@ -131,12 +131,12 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
131
131
|
|
|
132
132
|
const filterIsSet = !!filterValues && Object.keys(filterValues).length > 0;
|
|
133
133
|
|
|
134
|
-
const loadNextPage = () => {
|
|
134
|
+
const loadNextPage = useCallback(() => {
|
|
135
135
|
if (!paginationEnabled || dataLoading || noMoreToLoad)
|
|
136
136
|
return;
|
|
137
137
|
if (itemCount !== undefined)
|
|
138
138
|
setItemCount?.(itemCount + pageSize);
|
|
139
|
-
};
|
|
139
|
+
}, [dataLoading, itemCount, noMoreToLoad, pageSize, paginationEnabled, setItemCount]);
|
|
140
140
|
|
|
141
141
|
useOutsideAlerter(ref,
|
|
142
142
|
() => {
|
|
@@ -245,7 +245,7 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
245
245
|
}
|
|
246
246
|
</ErrorBoundary>);
|
|
247
247
|
|
|
248
|
-
}, [
|
|
248
|
+
}, [inlineEditing, size, selectedEntityIds]);
|
|
249
249
|
|
|
250
250
|
const additionalCellRenderer = useCallback(({
|
|
251
251
|
column,
|
|
@@ -290,7 +290,7 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
290
290
|
</EntityTableCell>
|
|
291
291
|
);
|
|
292
292
|
|
|
293
|
-
}, [
|
|
293
|
+
}, [size, selectedEntityIds]);
|
|
294
294
|
|
|
295
295
|
const collectionColumns: VirtualTableColumn[] = useMemo(() => {
|
|
296
296
|
const columnsResult: VirtualTableColumn[] = propertiesToColumns({
|
|
@@ -365,6 +365,29 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
365
365
|
setFilterValues?.({ ...updatedFilterValues, ...forceFilter } as FilterValues<any>);
|
|
366
366
|
}, [forceFilter]);
|
|
367
367
|
|
|
368
|
+
// useTraceUpdate({
|
|
369
|
+
// data,
|
|
370
|
+
// columns,
|
|
371
|
+
// inlineEditing,
|
|
372
|
+
// size, selectedEntityIds, additionalCellRenderer, propertyCellRenderer,
|
|
373
|
+
// cellRenderer,
|
|
374
|
+
// onRowClick,
|
|
375
|
+
// onEndReached: loadNextPage,
|
|
376
|
+
// onResetPagination: resetPagination,
|
|
377
|
+
// error: dataLoadingError,
|
|
378
|
+
// paginationEnabled,
|
|
379
|
+
// onColumnResize,
|
|
380
|
+
// loading: dataLoading,
|
|
381
|
+
// filter: filterValues,
|
|
382
|
+
// onFilterUpdate,
|
|
383
|
+
// sortBy,
|
|
384
|
+
// onSortByUpdate: setSortBy,
|
|
385
|
+
// hoverRow,
|
|
386
|
+
// emptyComponent,
|
|
387
|
+
// checkFilterCombination,
|
|
388
|
+
// createFilterField,
|
|
389
|
+
// });
|
|
390
|
+
|
|
368
391
|
return (
|
|
369
392
|
|
|
370
393
|
<EntityCollectionTableContext.Provider
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
AdditionalFieldDelegate,
|
|
4
4
|
CollectionSize,
|
|
5
5
|
Entity,
|
|
6
|
+
EntityTableController,
|
|
6
7
|
FilterValues,
|
|
7
8
|
ResolvedProperties,
|
|
8
9
|
ResolvedProperty,
|
|
9
10
|
SelectionController,
|
|
10
|
-
EntityTableController,
|
|
11
11
|
User
|
|
12
12
|
} from "../../types";
|
|
13
13
|
import { OnCellValueChange, UniqueFieldValidator } from "./types";
|
|
@@ -21,7 +21,6 @@ export type OnColumnResizeParams = { width: number, key: string };
|
|
|
21
21
|
* @group Collection components
|
|
22
22
|
*/
|
|
23
23
|
export type EntityCollectionTableProps<M extends Record<string, any>,
|
|
24
|
-
|
|
25
24
|
UserType extends User = User> = {
|
|
26
25
|
|
|
27
26
|
/**
|
|
@@ -105,7 +104,7 @@ export type EntityCollectionTableProps<M extends Record<string, any>,
|
|
|
105
104
|
|
|
106
105
|
inlineEditing?: boolean | ((entity: Entity<M>) => boolean);
|
|
107
106
|
|
|
108
|
-
additionalFields?: AdditionalFieldDelegate<M,
|
|
107
|
+
additionalFields?: AdditionalFieldDelegate<M, UserType>[];
|
|
109
108
|
|
|
110
109
|
defaultSize?: CollectionSize;
|
|
111
110
|
|
|
@@ -119,11 +118,11 @@ export type EntityCollectionTableProps<M extends Record<string, any>,
|
|
|
119
118
|
|
|
120
119
|
endAdornment?: React.ReactNode;
|
|
121
120
|
|
|
122
|
-
AdditionalHeaderWidget?:
|
|
121
|
+
AdditionalHeaderWidget?: React.ComponentType<{
|
|
123
122
|
property: ResolvedProperty,
|
|
124
123
|
propertyKey: string,
|
|
125
124
|
onHover: boolean,
|
|
126
|
-
}
|
|
125
|
+
}>;
|
|
127
126
|
|
|
128
127
|
AddColumnComponent?: React.ComponentType;
|
|
129
128
|
|
|
@@ -22,11 +22,11 @@ export interface PropertiesToColumnsParams<M extends Record<string, any>> {
|
|
|
22
22
|
sortable?: boolean;
|
|
23
23
|
forceFilter?: FilterValues<keyof M extends string ? keyof M : never>;
|
|
24
24
|
disabledFilter?: boolean;
|
|
25
|
-
AdditionalHeaderWidget?:
|
|
25
|
+
AdditionalHeaderWidget?: React.ComponentType<{
|
|
26
26
|
property: ResolvedProperty,
|
|
27
27
|
propertyKey: string,
|
|
28
28
|
onHover: boolean,
|
|
29
|
-
}
|
|
29
|
+
}>;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function propertiesToColumns<M extends Record<string, any>>({ properties, sortable, forceFilter, disabledFilter, AdditionalHeaderWidget }: PropertiesToColumnsParams<M>): VirtualTableColumn[] {
|
|
@@ -43,7 +43,7 @@ export function propertiesToColumns<M extends Record<string, any>>({ properties,
|
|
|
43
43
|
return {
|
|
44
44
|
key: key as string,
|
|
45
45
|
align: getTableCellAlignment(property),
|
|
46
|
-
icon:
|
|
46
|
+
icon: getIconForProperty(property, "small"),
|
|
47
47
|
title: property.name ?? key as string,
|
|
48
48
|
sortable: sortable && (forceFilter ? Object.keys(forceFilter).includes(key) : true),
|
|
49
49
|
filter: !disabledFilter && filterable,
|