@firecms/core 3.0.0-alpha.81 → 3.0.0-alpha.83
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 +4 -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 +2 -2
- 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 +4878 -4856
- 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/EntityCollectionRowActions.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +33 -8
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +5 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +1 -1
- package/src/components/EntityCollectionTable/SimpleEntityCollectionTable.tsx +0 -2
- 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 +77 -48
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -3
- package/src/components/EntityPreview.tsx +11 -9
- package/src/components/HomePage/DefaultHomePage.tsx +9 -8
- package/src/components/HomePage/NavigationCollectionCard.tsx +6 -5
- package/src/components/ReferenceSelectionInner.tsx +38 -36
- 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 +7 -4
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
1
|
import { AuthController, FireCMSContext, User } from "../types";
|
|
3
2
|
import { useAuthController } from "./useAuthController";
|
|
4
3
|
import { useSideDialogsController } from "./useSideDialogsController";
|
|
@@ -9,8 +8,8 @@ import { useStorageSource } from "./useStorageSource";
|
|
|
9
8
|
import { useSnackbarController } from "./useSnackbarController";
|
|
10
9
|
import { useUserConfigurationPersistence } from "./useUserConfigurationPersistence";
|
|
11
10
|
import { useDialogsController } from "./useDialogsController";
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import { useCustomizationController } from "./useCustomizationController";
|
|
12
|
+
import { useAnalyticsController } from "./useAnalyticsController";
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Hook to retrieve the {@link FireCMSContext}.
|
|
@@ -23,7 +22,6 @@ export const FireCMSContextInstance = createContext<Partial<FireCMSContext>>({})
|
|
|
23
22
|
*/
|
|
24
23
|
export const useFireCMSContext = <UserType extends User = User, AuthControllerType extends AuthController<UserType> = AuthController<UserType>>(): FireCMSContext<UserType, AuthControllerType> => {
|
|
25
24
|
|
|
26
|
-
const partialContext = useContext(FireCMSContextInstance) as FireCMSContext<UserType, AuthControllerType>;
|
|
27
25
|
const authController = useAuthController<UserType, AuthControllerType>();
|
|
28
26
|
const sideDialogsController = useSideDialogsController();
|
|
29
27
|
const sideEntityController = useSideEntityController();
|
|
@@ -33,9 +31,10 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
33
31
|
const snackbarController = useSnackbarController();
|
|
34
32
|
const userConfigPersistence = useUserConfigurationPersistence();
|
|
35
33
|
const dialogsController = useDialogsController();
|
|
34
|
+
const customizationController = useCustomizationController();
|
|
35
|
+
const analyticsController = useAnalyticsController();
|
|
36
36
|
|
|
37
37
|
return {
|
|
38
|
-
...partialContext,
|
|
39
38
|
authController,
|
|
40
39
|
sideDialogsController,
|
|
41
40
|
sideEntityController,
|
|
@@ -44,7 +43,9 @@ export const useFireCMSContext = <UserType extends User = User, AuthControllerTy
|
|
|
44
43
|
storageSource,
|
|
45
44
|
snackbarController,
|
|
46
45
|
userConfigPersistence,
|
|
47
|
-
dialogsController
|
|
48
|
-
|
|
46
|
+
dialogsController,
|
|
47
|
+
customizationController,
|
|
48
|
+
analyticsController
|
|
49
|
+
};
|
|
49
50
|
|
|
50
51
|
};
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import {
|
|
23
23
|
saveEntityWithCallbacks,
|
|
24
24
|
useAuthController,
|
|
25
|
+
useCustomizationController,
|
|
25
26
|
useDataSource,
|
|
26
27
|
useEntityFetch,
|
|
27
28
|
useFireCMSContext,
|
|
@@ -98,6 +99,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
98
99
|
const sideDialogContext = useSideDialogContext();
|
|
99
100
|
const sideEntityController = useSideEntityController();
|
|
100
101
|
const snackbarController = useSnackbarController();
|
|
102
|
+
const customizationController = useCustomizationController();
|
|
101
103
|
const context = useFireCMSContext();
|
|
102
104
|
const authController = useAuthController<UserType>();
|
|
103
105
|
|
|
@@ -297,7 +299,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
297
299
|
};
|
|
298
300
|
|
|
299
301
|
const resolvedEntityViews = customViews ? customViews
|
|
300
|
-
.map(e => resolveEntityView(e,
|
|
302
|
+
.map(e => resolveEntityView(e, customizationController.entityViews))
|
|
301
303
|
.filter(Boolean) as EntityCustomView[]
|
|
302
304
|
: [];
|
|
303
305
|
const customViewsView: React.ReactNode[] | undefined = customViews && resolvedEntityViews
|
|
@@ -411,7 +413,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
411
413
|
}
|
|
412
414
|
|
|
413
415
|
function buildForm() {
|
|
414
|
-
const plugins =
|
|
416
|
+
const plugins = customizationController.plugins;
|
|
415
417
|
let form = <EntityForm
|
|
416
418
|
status={status}
|
|
417
419
|
path={path}
|
|
@@ -4,7 +4,6 @@ import { SideDialogPanelProps, SideDialogsController } from "../types";
|
|
|
4
4
|
import equal from "react-fast-compare"
|
|
5
5
|
|
|
6
6
|
export function useBuildSideDialogsController(): SideDialogsController {
|
|
7
|
-
console.log("useBuildSideDialogsController");
|
|
8
7
|
|
|
9
8
|
const location = useLocation();
|
|
10
9
|
const navigate = useNavigate();
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { resolveProperty } from "../util";
|
|
14
14
|
|
|
15
15
|
import { PropertyPreviewProps } from "./PropertyPreviewProps";
|
|
16
|
-
import {
|
|
16
|
+
import { useCustomizationController } from "../hooks";
|
|
17
17
|
import { EmptyValue } from "./components/EmptyValue";
|
|
18
18
|
import { UrlComponentPreview } from "./components/UrlComponentPreview";
|
|
19
19
|
import { StorageThumbnail } from "./components/StorageThumbnail";
|
|
@@ -37,7 +37,8 @@ import { ErrorView } from "../components";
|
|
|
37
37
|
*/
|
|
38
38
|
export const PropertyPreview = React.memo(function PropertyPreview<T extends CMSType>(props: PropertyPreviewProps<T>) {
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const customizationController = useCustomizationController();
|
|
41
|
+
|
|
41
42
|
let content: React.ReactNode | any;
|
|
42
43
|
const {
|
|
43
44
|
property: inputProperty,
|
|
@@ -53,7 +54,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
53
54
|
propertyKey,
|
|
54
55
|
propertyOrBuilder: inputProperty,
|
|
55
56
|
propertyValue: value,
|
|
56
|
-
fields:
|
|
57
|
+
fields: customizationController.propertyConfigs
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
if (value === undefined || property === null) {
|
|
@@ -210,7 +211,9 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
210
211
|
content = JSON.stringify(value);
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
return content === undefined || content === null
|
|
214
|
+
return content === undefined || content === null || (Array.isArray(content) && content.length === 0)
|
|
215
|
+
? <EmptyValue/>
|
|
216
|
+
: content;
|
|
214
217
|
}, equal);
|
|
215
218
|
|
|
216
219
|
function buildWrongValueType(name: string | undefined, dataType: string, value: any) {
|
|
@@ -2,8 +2,7 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { format } from "date-fns";
|
|
4
4
|
import * as locales from "date-fns/locale";
|
|
5
|
-
import {
|
|
6
|
-
import { useFireCMSContext } from "../../hooks";
|
|
5
|
+
import { useCustomizationController } from "../../hooks";
|
|
7
6
|
import { defaultDateFormat } from "../../util";
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -13,10 +12,10 @@ export function DatePreview({
|
|
|
13
12
|
date
|
|
14
13
|
}: { date: Date }): React.ReactElement {
|
|
15
14
|
|
|
16
|
-
const
|
|
15
|
+
const customizationController = useCustomizationController();
|
|
17
16
|
// @ts-ignore
|
|
18
|
-
const dateUtilsLocale =
|
|
19
|
-
const dateFormat: string =
|
|
17
|
+
const dateUtilsLocale = customizationController?.locale ? locales[customizationController?.locale] : undefined;
|
|
18
|
+
const dateFormat: string = customizationController?.dateTimeFormat ?? defaultDateFormat;
|
|
20
19
|
const formattedDate = date ? format(date, dateFormat, { locale: dateUtilsLocale }) : "";
|
|
21
20
|
|
|
22
21
|
return (
|
|
@@ -4,12 +4,18 @@ import { useMemo } from "react";
|
|
|
4
4
|
import { Entity, EntityCollection, EntityReference, ResolvedProperty } from "../../types";
|
|
5
5
|
|
|
6
6
|
import { getReferencePreviewKeys, getValueInPath, resolveCollection } from "../../util";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useCustomizationController,
|
|
9
|
+
useEntityFetch,
|
|
10
|
+
useNavigationController,
|
|
11
|
+
useSideEntityController
|
|
12
|
+
} from "../../hooks";
|
|
8
13
|
import { PropertyPreview } from "../PropertyPreview";
|
|
9
14
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
10
15
|
import { SkeletonPropertyComponent } from "../property_previews/SkeletonPropertyComponent";
|
|
11
16
|
import { cn, IconButton, KeyboardTabIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
|
|
12
17
|
import { ErrorView } from "../../components";
|
|
18
|
+
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
13
19
|
|
|
14
20
|
export type ReferencePreviewProps = {
|
|
15
21
|
disabled?: boolean;
|
|
@@ -58,13 +64,14 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
58
64
|
allowEntityNavigation = true
|
|
59
65
|
}: ReferencePreviewProps) {
|
|
60
66
|
|
|
61
|
-
const
|
|
67
|
+
const customizationController = useCustomizationController();
|
|
68
|
+
|
|
62
69
|
const navigationController = useNavigationController();
|
|
63
70
|
|
|
64
71
|
const collection = navigationController.getCollection<EntityCollection<M>>(reference.path);
|
|
65
72
|
if (!collection) {
|
|
66
|
-
if (
|
|
67
|
-
return <
|
|
73
|
+
if (customizationController.components?.missingReference) {
|
|
74
|
+
return <customizationController.components.missingReference path={reference.path}/>;
|
|
68
75
|
} else {
|
|
69
76
|
throw Error(`Couldn't find the corresponding collection view for the path: ${reference.path}`);
|
|
70
77
|
}
|
|
@@ -85,7 +92,9 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
85
92
|
collection: EntityCollection<M>
|
|
86
93
|
}) {
|
|
87
94
|
|
|
88
|
-
const
|
|
95
|
+
const customizationController = useCustomizationController();
|
|
96
|
+
|
|
97
|
+
const analyticsController = useAnalyticsController();
|
|
89
98
|
const sideEntityController = useSideEntityController();
|
|
90
99
|
|
|
91
100
|
const {
|
|
@@ -109,10 +118,10 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
109
118
|
collection,
|
|
110
119
|
path: reference.path,
|
|
111
120
|
values: usedEntity?.values,
|
|
112
|
-
fields:
|
|
121
|
+
fields: customizationController.propertyConfigs
|
|
113
122
|
}), [collection]);
|
|
114
123
|
|
|
115
|
-
const listProperties = useMemo(() => getReferencePreviewKeys(resolvedCollection,
|
|
124
|
+
const listProperties = useMemo(() => getReferencePreviewKeys(resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "small" || size === "medium" ? 3 : 1),
|
|
116
125
|
[previewProperties, resolvedCollection, size]);
|
|
117
126
|
|
|
118
127
|
let body: React.ReactNode;
|
|
@@ -179,7 +188,7 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({ referen
|
|
|
179
188
|
size={"small"}
|
|
180
189
|
onClick={(e) => {
|
|
181
190
|
e.stopPropagation();
|
|
182
|
-
|
|
191
|
+
analyticsController.onAnalyticsEvent?.("entity_click_from_reference", {
|
|
183
192
|
path: usedEntity.path,
|
|
184
193
|
entityId: usedEntity.id
|
|
185
194
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ErrorBoundary } from "../../components";
|
|
3
|
-
import {
|
|
3
|
+
import { useCustomizationController } from "../../hooks";
|
|
4
4
|
import { PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
5
5
|
import { PropertyPreview } from "../PropertyPreview";
|
|
6
6
|
import { resolveArrayProperty } from "../../util";
|
|
@@ -15,13 +15,13 @@ export function ArrayOfMapsPreview({
|
|
|
15
15
|
size,
|
|
16
16
|
// entity
|
|
17
17
|
}: PropertyPreviewProps<Record<string, any>[]>) {
|
|
18
|
-
const fireCMSContext = useFireCMSContext();
|
|
19
18
|
|
|
19
|
+
const customizationController = useCustomizationController();
|
|
20
20
|
const property = resolveArrayProperty({
|
|
21
21
|
propertyKey,
|
|
22
22
|
property: inputProperty,
|
|
23
23
|
propertyValue: value,
|
|
24
|
-
fields:
|
|
24
|
+
fields: customizationController.propertyConfigs
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
if (Array.isArray(property?.of)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResolvedReferenceProperty } from "../../types";
|
|
2
2
|
import { resolveArrayProperty } from "../../util";
|
|
3
|
-
import {
|
|
3
|
+
import { useCustomizationController } from "../../hooks";
|
|
4
4
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
5
5
|
import { ReferencePreview } from "../components/ReferencePreview";
|
|
6
6
|
|
|
@@ -14,12 +14,12 @@ export function ArrayOfReferencesPreview({
|
|
|
14
14
|
size
|
|
15
15
|
}: PropertyPreviewProps<any[]>) {
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const customizationController = useCustomizationController();
|
|
18
18
|
const property = resolveArrayProperty({
|
|
19
19
|
propertyKey,
|
|
20
20
|
property: inputProperty,
|
|
21
21
|
propertyValue: value,
|
|
22
|
-
fields:
|
|
22
|
+
fields: customizationController.propertyConfigs
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
if (Array.isArray(property?.of)) {
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { resolveArrayProperty } from "../../util";
|
|
4
4
|
import { ResolvedProperty } from "../../types";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { useCustomizationController } from "../../hooks";
|
|
7
7
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
8
8
|
import { PropertyPreview } from "../PropertyPreview";
|
|
9
9
|
import { ErrorBoundary } from "../../components";
|
|
@@ -19,12 +19,12 @@ export function ArrayOfStorageComponentsPreview({
|
|
|
19
19
|
size
|
|
20
20
|
}: PropertyPreviewProps<any[]>) {
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const customizationController = useCustomizationController();
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
26
|
propertyValue: value,
|
|
27
|
-
fields:
|
|
27
|
+
fields: customizationController.propertyConfigs
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (Array.isArray(property.of)) {
|
|
@@ -3,7 +3,7 @@ import { ResolvedStringProperty } from "../../types";
|
|
|
3
3
|
|
|
4
4
|
import { resolveArrayProperty } from "../../util";
|
|
5
5
|
import { PropertyPreviewProps, StringPropertyPreview } from "../../preview";
|
|
6
|
-
import {
|
|
6
|
+
import { useCustomizationController } from "../../hooks";
|
|
7
7
|
import { ErrorBoundary } from "../../components";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -17,12 +17,12 @@ export function ArrayOfStringsPreview({
|
|
|
17
17
|
size
|
|
18
18
|
}: PropertyPreviewProps<string[]>) {
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const customizationController = useCustomizationController();
|
|
21
21
|
const property = resolveArrayProperty({
|
|
22
22
|
propertyKey,
|
|
23
23
|
property: inputProperty,
|
|
24
24
|
propertyValue: value,
|
|
25
|
-
fields:
|
|
25
|
+
fields: customizationController.propertyConfigs
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
if (Array.isArray(property.of)) {
|
|
@@ -45,7 +45,7 @@ export function ArrayOfStringsPreview({
|
|
|
45
45
|
<StringPropertyPreview propertyKey={propertyKey}
|
|
46
46
|
property={stringProperty}
|
|
47
47
|
value={v}
|
|
48
|
-
|
|
48
|
+
// entity={entity}
|
|
49
49
|
size={size}/>
|
|
50
50
|
</ErrorBoundary>
|
|
51
51
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { resolveArrayProperty } from "../../util";
|
|
3
3
|
import { ResolvedProperty } from "../../types";
|
|
4
|
-
import {
|
|
4
|
+
import { useCustomizationController } from "../../hooks";
|
|
5
5
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
6
6
|
import { PropertyPreview } from "../PropertyPreview";
|
|
7
7
|
import { cn, defaultBorderMixin } from "@firecms/ui";
|
|
@@ -19,12 +19,12 @@ export function ArrayOneOfPreview({
|
|
|
19
19
|
// entity
|
|
20
20
|
}: PropertyPreviewProps<any[]>) {
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const customizationController = useCustomizationController();
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
26
|
propertyValue: value,
|
|
27
|
-
fields:
|
|
27
|
+
fields: customizationController.propertyConfigs
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (property?.dataType !== "array")
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import { resolveArrayProperty } from "../../util";
|
|
4
4
|
import { ResolvedProperty } from "../../types";
|
|
5
|
-
import {
|
|
5
|
+
import { useCustomizationController } from "../../hooks";
|
|
6
6
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
7
7
|
import { PropertyPreview } from "../PropertyPreview";
|
|
8
8
|
import { cn, defaultBorderMixin } from "@firecms/ui";
|
|
@@ -19,12 +19,12 @@ export function ArrayPropertyPreview({
|
|
|
19
19
|
size
|
|
20
20
|
}: PropertyPreviewProps<any[]>) {
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const customizationController = useCustomizationController();
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
26
|
propertyValue: value,
|
|
27
|
-
fields:
|
|
27
|
+
fields: customizationController.propertyConfigs
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (!property.of) {
|
package/src/types/collections.ts
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
|
|
8
|
+
export type CustomizationController = {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Builder for generating utility links for entities
|
|
12
|
+
*/
|
|
13
|
+
entityLinkBuilder?: EntityLinkBuilder;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Use plugins to modify the behaviour of the CMS.
|
|
17
|
+
*/
|
|
18
|
+
plugins?: FireCMSPlugin<any, any, any>[];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* List of additional custom views for entities.
|
|
22
|
+
* You can use the key to reference the custom view in
|
|
23
|
+
* the `entityViews` prop of a collection.
|
|
24
|
+
*
|
|
25
|
+
* You can also define an entity view from the UI.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
entityViews?: EntityCustomView[];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Format of the dates in the CMS.
|
|
32
|
+
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
33
|
+
*/
|
|
34
|
+
dateTimeFormat?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Locale of the CMS, currently only affecting dates
|
|
38
|
+
*/
|
|
39
|
+
locale?: Locale;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Record of custom form fields to be used in the CMS.
|
|
43
|
+
* You can use the key to reference the custom field in
|
|
44
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
45
|
+
*/
|
|
46
|
+
propertyConfigs: Record<string, PropertyConfig>;
|
|
47
|
+
|
|
48
|
+
components?: {
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Component to render when a reference is missing
|
|
52
|
+
*/
|
|
53
|
+
missingReference?: React.ComponentType<{
|
|
54
|
+
path: string,
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -30,7 +30,7 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
30
30
|
* Callback used when saving fails
|
|
31
31
|
* @param entitySaveProps
|
|
32
32
|
*/
|
|
33
|
-
onSaveFailure?(entitySaveProps:
|
|
33
|
+
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M, UserType>)
|
|
34
34
|
: Promise<void> | void;
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -39,7 +39,7 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
39
39
|
* error snackbar gets displayed.
|
|
40
40
|
* @param entitySaveProps
|
|
41
41
|
*/
|
|
42
|
-
onPreSave?(entitySaveProps:
|
|
42
|
+
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M, UserType>)
|
|
43
43
|
: Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -96,6 +96,25 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
|
|
|
96
96
|
context: FireCMSContext<UserType>;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Parameters passed to hooks before an entity is saved
|
|
101
|
+
* @group Models
|
|
102
|
+
*/
|
|
103
|
+
export type EntityOnPreSaveProps<M extends Record<string, any> = any, UserType extends User = User> =
|
|
104
|
+
Omit<EntityOnSaveProps<M, UserType>, "entityId">
|
|
105
|
+
& {
|
|
106
|
+
entityId?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parameters passed to hooks before an entity is saved
|
|
110
|
+
* @group Models
|
|
111
|
+
*/
|
|
112
|
+
export type EntityOnSaveFailureProps<M extends Record<string, any> = any, UserType extends User = User> =
|
|
113
|
+
Omit<EntityOnSaveProps<M, UserType>, "entityId">
|
|
114
|
+
& {
|
|
115
|
+
entityId?: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
99
118
|
/**
|
|
100
119
|
* Parameters passed to hooks when an entity is saved
|
|
101
120
|
* @group Models
|
|
@@ -121,7 +140,7 @@ export interface EntityOnSaveProps<M extends Record<string, any> = any, UserType
|
|
|
121
140
|
/**
|
|
122
141
|
* ID of the entity
|
|
123
142
|
*/
|
|
124
|
-
entityId
|
|
143
|
+
entityId: string;
|
|
125
144
|
|
|
126
145
|
/**
|
|
127
146
|
* Values being saved
|
|
@@ -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
|
/**
|
|
19
15
|
* Context that includes the internal controllers and contexts used by the app.
|
|
@@ -65,9 +61,9 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
|
|
|
65
61
|
authController: AuthControllerType;
|
|
66
62
|
|
|
67
63
|
/**
|
|
68
|
-
*
|
|
64
|
+
* This controller holds the customization options for the CMS.
|
|
69
65
|
*/
|
|
70
|
-
|
|
66
|
+
customizationController: CustomizationController;
|
|
71
67
|
|
|
72
68
|
/**
|
|
73
69
|
* Use this controller to display snackbars
|
|
@@ -80,49 +76,8 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
|
|
|
80
76
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
81
77
|
|
|
82
78
|
/**
|
|
83
|
-
*
|
|
84
|
-
* Currently, in ALPHA, and likely subject to change.
|
|
79
|
+
* Callback to send analytics events
|
|
85
80
|
*/
|
|
86
|
-
|
|
81
|
+
analyticsController?: AnalyticsController;
|
|
87
82
|
|
|
88
|
-
/**
|
|
89
|
-
* Callback used to get analytics events from the CMS
|
|
90
|
-
*/
|
|
91
|
-
onAnalyticsEvent?: (event: CMSAnalyticsEvent, data?: object) => void;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Record of custom form fields to be used in the CMS.
|
|
95
|
-
* You can use the key to reference the custom field in
|
|
96
|
-
* the `propertyConfig` prop of a property in a collection.
|
|
97
|
-
*/
|
|
98
|
-
propertyConfigs: Record<string, PropertyConfig>;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* List of additional custom views for entities.
|
|
102
|
-
* You can use the key to reference the custom view in
|
|
103
|
-
* the `entityViews` prop of a collection.
|
|
104
|
-
*
|
|
105
|
-
* You can also define an entity view from the UI.
|
|
106
|
-
*/
|
|
107
|
-
entityViews?: EntityCustomView[];
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Format of the dates in the CMS.
|
|
111
|
-
* Defaults to 'MMMM dd, yyyy, HH:mm:ss'
|
|
112
|
-
*/
|
|
113
|
-
dateTimeFormat?: string;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Locale of the CMS, currently only affecting dates
|
|
117
|
-
*/
|
|
118
|
-
locale?: Locale;
|
|
119
|
-
|
|
120
|
-
components?: {
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Component to render when a reference is missing
|
|
124
|
-
*/
|
|
125
|
-
missingReference?: React.ComponentType<{ path: string }>;
|
|
126
|
-
|
|
127
|
-
}
|
|
128
83
|
};
|