@firecms/core 3.0.0-beta.5 → 3.0.0-beta.7
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/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +1 -0
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +11 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityPreview.d.ts +3 -2
- package/dist/components/FireCMSAppBar.d.ts +4 -2
- package/dist/components/ReferenceWidget.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -6
- package/dist/components/VirtualTable/types.d.ts +3 -3
- package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/core/Drawer.d.ts +5 -12
- package/dist/core/DrawerNavigationItem.d.ts +9 -0
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/core/Scaffold.d.ts +8 -12
- package/dist/core/index.d.ts +3 -4
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/hooks/data/save.d.ts +1 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useValidateAuthenticator.d.ts +2 -6
- package/dist/index.es.js +10087 -9914
- 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/useBuildDataSource.d.ts +1 -16
- package/dist/preview/components/ReferencePreview.d.ts +2 -1
- package/dist/types/collections.d.ts +13 -2
- package/dist/types/datasource.d.ts +2 -5
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/plugins.d.ts +3 -1
- package/dist/types/properties.d.ts +10 -2
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +1 -97
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/resolutions.d.ts +13 -13
- package/package.json +139 -119
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +19 -18
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +10 -6
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +38 -34
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -1
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +47 -25
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityPreview.tsx +9 -7
- package/src/components/EntityView.tsx +5 -5
- package/src/components/FireCMSAppBar.tsx +32 -15
- package/src/components/HomePage/DefaultHomePage.tsx +1 -1
- package/src/components/HomePage/NavigationCard.tsx +2 -2
- package/src/components/HomePage/SmallNavigationCard.tsx +5 -5
- package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -0
- package/src/components/ReferenceWidget.tsx +21 -11
- package/src/components/SearchIconsView.tsx +5 -5
- package/src/components/SelectableTable/SelectableTable.tsx +5 -3
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +22 -7
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +28 -6
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +36 -29
- package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -6
- package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
- package/src/components/VirtualTable/types.tsx +2 -3
- package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +2 -2
- package/src/components/common/index.ts +1 -0
- package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useColumnsIds.tsx +10 -2
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +11 -0
- package/src/components/index.tsx +1 -0
- package/src/core/Drawer.tsx +16 -68
- package/src/core/DrawerNavigationItem.tsx +62 -0
- package/src/core/EntityEditView.tsx +7 -8
- package/src/core/EntitySidePanel.tsx +1 -1
- package/src/core/FireCMS.tsx +37 -42
- package/src/core/NavigationRoutes.tsx +3 -4
- package/src/core/Scaffold.tsx +80 -66
- package/src/core/field_configs.tsx +2 -3
- package/src/core/index.tsx +3 -4
- package/src/form/EntityForm.tsx +29 -21
- package/src/form/PropertyFieldBinding.tsx +0 -2
- package/src/form/components/StorageItemPreview.tsx +2 -2
- package/src/form/components/StorageUploadProgress.tsx +3 -3
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -2
- package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -4
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +15 -13
- package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +4 -4
- package/src/hooks/data/save.ts +3 -1
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +8 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +77 -21
- package/src/hooks/useProjectLog.tsx +3 -3
- package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
- package/src/hooks/useValidateAuthenticator.tsx +17 -37
- package/src/internal/useBuildDataSource.ts +42 -47
- package/src/internal/useBuildSideEntityController.tsx +86 -22
- package/src/preview/PropertyPreview.tsx +4 -14
- package/src/preview/components/BooleanPreview.tsx +2 -2
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ReferencePreview.tsx +21 -22
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
- package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/types/collections.ts +19 -3
- package/src/types/datasource.ts +7 -4
- package/src/types/entities.ts +9 -1
- package/src/types/entity_actions.tsx +16 -3
- package/src/types/index.ts +0 -1
- package/src/types/navigation.ts +2 -3
- package/src/types/plugins.tsx +4 -3
- package/src/types/properties.ts +15 -4
- package/src/types/storage.ts +1 -1
- package/src/util/entities.ts +1 -1
- package/src/util/enums.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +3 -99
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +8 -21
- package/src/util/resolutions.ts +32 -31
- package/dist/components/VirtualTable/common.d.ts +0 -2
- package/dist/core/SideEntityView.d.ts +0 -7
- package/dist/internal/useBuildCustomizationController.d.ts +0 -2
- package/dist/internal/useLocaleConfig.d.ts +0 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/core/SideEntityView.tsx +0 -38
- package/src/internal/useBuildCustomizationController.tsx +0 -5
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
|
@@ -2,14 +2,15 @@ import { useCallback, useEffect, useRef } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
EntityCollection,
|
|
4
4
|
EntitySidePanelProps,
|
|
5
|
-
NavigationController,
|
|
5
|
+
NavigationController, PropertyConfig,
|
|
6
|
+
ResolvedProperty,
|
|
6
7
|
SideDialogPanelProps,
|
|
7
8
|
SideDialogsController,
|
|
8
9
|
SideEntityController
|
|
9
10
|
} from "../types";
|
|
10
11
|
import { getNavigationEntriesFromPathInternal, NavigationViewInternal } from "../util/navigation_from_path";
|
|
11
12
|
import { useLocation } from "react-router-dom";
|
|
12
|
-
import { removeInitialAndTrailingSlashes, resolveDefaultSelectedView } from "../util";
|
|
13
|
+
import { removeInitialAndTrailingSlashes, resolveCollection, resolveDefaultSelectedView } from "../util";
|
|
13
14
|
import { ADDITIONAL_TAB_WIDTH, CONTAINER_FULL_WIDTH, FORM_CONTAINER_WIDTH } from "./common";
|
|
14
15
|
import { useLargeLayout } from "../hooks";
|
|
15
16
|
import { EntitySidePanel } from "../core/EntitySidePanel";
|
|
@@ -19,8 +20,67 @@ const NEW_URL_HASH = "new";
|
|
|
19
20
|
export function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean): string {
|
|
20
21
|
if (small) return CONTAINER_FULL_WIDTH;
|
|
21
22
|
const mainViewSelected = !props.selectedSubPath;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
let resolvedWidth: string | undefined;
|
|
24
|
+
if (props.width) {
|
|
25
|
+
resolvedWidth = typeof props.width === "number" ? `${props.width}px` : props.width;
|
|
26
|
+
} else if (props.collection?.sideDialogWidth) {
|
|
27
|
+
resolvedWidth = typeof props.collection.sideDialogWidth === "number" ? `${props.collection.sideDialogWidth}px` : props.collection.sideDialogWidth;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!mainViewSelected) {
|
|
31
|
+
return `calc(${ADDITIONAL_TAB_WIDTH} + ${resolvedWidth ?? FORM_CONTAINER_WIDTH})`
|
|
32
|
+
} else {
|
|
33
|
+
if (resolvedWidth) {
|
|
34
|
+
return resolvedWidth
|
|
35
|
+
} else if (!props.collection) {
|
|
36
|
+
return FORM_CONTAINER_WIDTH;
|
|
37
|
+
} else {
|
|
38
|
+
return calculateCollectionDesiredWidth(props.collection);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const collectionViewWidthCache: { [key: string]: string } = {};
|
|
44
|
+
|
|
45
|
+
function calculateCollectionDesiredWidth(collection: EntityCollection<any>): string {
|
|
46
|
+
if (collectionViewWidthCache[collection.id]) {
|
|
47
|
+
return collectionViewWidthCache[collection.id];
|
|
48
|
+
}
|
|
49
|
+
const resolvedCollection = resolveCollection({
|
|
50
|
+
collection,
|
|
51
|
+
path: "__ignored",
|
|
52
|
+
ignoreMissingFields: true
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
let result = FORM_CONTAINER_WIDTH
|
|
56
|
+
if (resolvedCollection?.properties) {
|
|
57
|
+
const values = Object.values(resolvedCollection.properties).map((p: ResolvedProperty) => getNestedPropertiesDepth(p));
|
|
58
|
+
const maxDepth = Math.max(...values);
|
|
59
|
+
if (maxDepth < 3) {
|
|
60
|
+
result = FORM_CONTAINER_WIDTH;
|
|
61
|
+
} else {
|
|
62
|
+
result = 768 + 32 * (maxDepth - 2) + "px";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
collectionViewWidthCache[collection.id] = result;
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getNestedPropertiesDepth(property: ResolvedProperty, accumulator: number = 0): number {
|
|
70
|
+
if (property.dataType === "map" && property.properties) {
|
|
71
|
+
const values = Object.values(property.properties).flatMap((property) => getNestedPropertiesDepth(property, accumulator + 1));
|
|
72
|
+
return Math.max(...values);
|
|
73
|
+
} else if (property.dataType === "array" && property.oneOf) {
|
|
74
|
+
return accumulator + 3;
|
|
75
|
+
} else if (property.dataType === "array" && property.of) {
|
|
76
|
+
if (Array.isArray(property.of)) {
|
|
77
|
+
return Math.max(...property.of.map((p) => getNestedPropertiesDepth(p, accumulator + 1)));
|
|
78
|
+
} else {
|
|
79
|
+
return getNestedPropertiesDepth(property.of, accumulator + 1);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
return accumulator + 1;
|
|
83
|
+
}
|
|
24
84
|
}
|
|
25
85
|
|
|
26
86
|
export const useBuildSideEntityController = (navigation: NavigationController,
|
|
@@ -40,20 +100,20 @@ export const useBuildSideEntityController = (navigation: NavigationController,
|
|
|
40
100
|
const entityOrCollectionPath = navigation.urlPathToDataPath(location.pathname);
|
|
41
101
|
const panelsFromUrl = buildSidePanelsFromUrl(entityOrCollectionPath, navigation.collections ?? [], newFlag);
|
|
42
102
|
for (let i = 0; i < panelsFromUrl.length; i++) {
|
|
43
|
-
const
|
|
103
|
+
const props = panelsFromUrl[i];
|
|
44
104
|
setTimeout(() => {
|
|
45
105
|
if (i === 0)
|
|
46
|
-
sideDialogsController.replace(propsToSidePanel(
|
|
106
|
+
sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout));
|
|
47
107
|
else
|
|
48
|
-
sideDialogsController.open(propsToSidePanel(
|
|
108
|
+
sideDialogsController.open(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout))
|
|
49
109
|
}, 1);
|
|
50
110
|
}
|
|
51
111
|
} else {
|
|
52
|
-
console.warn("Location path is not a collection path");
|
|
112
|
+
// console.warn("Location path is not a collection path");
|
|
53
113
|
}
|
|
54
114
|
initialised.current = true;
|
|
55
115
|
}
|
|
56
|
-
}, [location, navigation, sideDialogsController, smallLayout]);
|
|
116
|
+
}, [location, navigation.loading, navigation.isUrlCollectionPath, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, sideDialogsController, smallLayout, navigation]);
|
|
57
117
|
|
|
58
118
|
const close = useCallback(() => {
|
|
59
119
|
sideDialogsController.close();
|
|
@@ -76,9 +136,9 @@ export const useBuildSideEntityController = (navigation: NavigationController,
|
|
|
76
136
|
sideDialogsController.open(propsToSidePanel({
|
|
77
137
|
selectedSubPath: defaultSelectedView,
|
|
78
138
|
...props,
|
|
79
|
-
}, navigation, smallLayout));
|
|
139
|
+
}, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout));
|
|
80
140
|
|
|
81
|
-
}, [sideDialogsController, navigation, smallLayout]);
|
|
141
|
+
}, [sideDialogsController, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout]);
|
|
82
142
|
|
|
83
143
|
const replace = useCallback((props: EntitySidePanelProps<any>) => {
|
|
84
144
|
|
|
@@ -86,9 +146,9 @@ export const useBuildSideEntityController = (navigation: NavigationController,
|
|
|
86
146
|
throw Error("If you want to copy an entity you need to provide an entityId");
|
|
87
147
|
}
|
|
88
148
|
|
|
89
|
-
sideDialogsController.replace(propsToSidePanel(props, navigation, smallLayout));
|
|
149
|
+
sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout));
|
|
90
150
|
|
|
91
|
-
}, [navigation, sideDialogsController, smallLayout]);
|
|
151
|
+
}, [navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, sideDialogsController, smallLayout]);
|
|
92
152
|
|
|
93
153
|
return {
|
|
94
154
|
close,
|
|
@@ -119,7 +179,8 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
|
|
|
119
179
|
sidePanels.push({
|
|
120
180
|
path: navigationEntry.path,
|
|
121
181
|
entityId: navigationEntry.entityId,
|
|
122
|
-
copy: false
|
|
182
|
+
copy: false,
|
|
183
|
+
width: navigationEntry.parentCollection?.sideDialogWidth
|
|
123
184
|
}
|
|
124
185
|
);
|
|
125
186
|
} else if (navigationEntry.type === "custom_view") {
|
|
@@ -149,27 +210,30 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
|
|
|
149
210
|
return sidePanels;
|
|
150
211
|
}
|
|
151
212
|
|
|
152
|
-
const propsToSidePanel = (props: EntitySidePanelProps<any>,
|
|
213
|
+
const propsToSidePanel = (props: EntitySidePanelProps<any>,
|
|
214
|
+
buildUrlCollectionPath: (path: string) => string,
|
|
215
|
+
resolveAliasesFrom: (pathWithAliases: string) => string,
|
|
216
|
+
smallLayout: boolean): SideDialogPanelProps => {
|
|
153
217
|
|
|
154
218
|
const collectionPath = removeInitialAndTrailingSlashes(props.path);
|
|
155
219
|
|
|
156
220
|
const newPath = props.entityId
|
|
157
|
-
?
|
|
158
|
-
:
|
|
159
|
-
const resolvedPath =
|
|
221
|
+
? buildUrlCollectionPath(`${collectionPath}/${props.entityId}/${props.selectedSubPath || ""}`)
|
|
222
|
+
: buildUrlCollectionPath(`${collectionPath}#${NEW_URL_HASH}`);
|
|
223
|
+
const resolvedPath = resolveAliasesFrom(props.path);
|
|
160
224
|
|
|
161
225
|
const resolvedPanelProps: EntitySidePanelProps<any> = {
|
|
162
226
|
...props,
|
|
163
|
-
path: resolvedPath
|
|
227
|
+
path: resolvedPath,
|
|
164
228
|
};
|
|
165
229
|
|
|
166
|
-
return
|
|
230
|
+
return {
|
|
167
231
|
key: `${props.path}/${props.entityId}`,
|
|
168
232
|
component: <EntitySidePanel {...resolvedPanelProps}/>,
|
|
169
233
|
urlPath: newPath,
|
|
170
|
-
parentUrlPath:
|
|
234
|
+
parentUrlPath: buildUrlCollectionPath(collectionPath),
|
|
171
235
|
width: getEntityViewWidth(props, smallLayout),
|
|
172
236
|
onClose: props.onClose
|
|
173
|
-
}
|
|
237
|
+
};
|
|
174
238
|
}
|
|
175
239
|
;
|
|
@@ -53,7 +53,6 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
53
53
|
const property = resolveProperty({
|
|
54
54
|
propertyKey,
|
|
55
55
|
propertyOrBuilder: inputProperty,
|
|
56
|
-
propertyValue: value,
|
|
57
56
|
fields: customizationController.propertyConfigs
|
|
58
57
|
});
|
|
59
58
|
|
|
@@ -92,7 +91,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
92
91
|
size={props.size}
|
|
93
92
|
storagePathOrDownloadUrl={value}/>;
|
|
94
93
|
} else if (stringProperty.markdown) {
|
|
95
|
-
content = <Markdown source={value}/>;
|
|
94
|
+
content = <Markdown source={value} size={"small"}/>;
|
|
96
95
|
} else {
|
|
97
96
|
content = <StringPropertyPreview {...props}
|
|
98
97
|
property={stringProperty}
|
|
@@ -113,17 +112,7 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
113
112
|
content = <ArrayPropertyPreview {...props}
|
|
114
113
|
value={value}
|
|
115
114
|
property={property as ResolvedArrayProperty}/>;
|
|
116
|
-
}
|
|
117
|
-
// else if (arrayProperty.of.dataType === "map") {
|
|
118
|
-
// content =
|
|
119
|
-
// <ArrayOfMapsPreview propertyKey={propertyKey}
|
|
120
|
-
// property={property as ResolvedArrayProperty}
|
|
121
|
-
// value={value as Record<string, any>[]} // This might be wrong
|
|
122
|
-
// entity={entity}
|
|
123
|
-
// size={size}
|
|
124
|
-
// />;
|
|
125
|
-
// }
|
|
126
|
-
else if (arrayProperty.of.dataType === "reference") {
|
|
115
|
+
} else if (arrayProperty.of.dataType === "reference") {
|
|
127
116
|
content = <ArrayOfReferencesPreview {...props}
|
|
128
117
|
value={value}
|
|
129
118
|
property={property as ResolvedArrayProperty}/>;
|
|
@@ -182,8 +171,9 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
|
|
|
182
171
|
content = <ReferencePreview
|
|
183
172
|
disabled={!property.path}
|
|
184
173
|
previewProperties={property.previewProperties}
|
|
174
|
+
includeId={property.includeId}
|
|
175
|
+
includeEntityLink={property.includeEntityLink}
|
|
185
176
|
size={props.size}
|
|
186
|
-
// onClick={props.onClick}
|
|
187
177
|
reference={value as EntityReference}
|
|
188
178
|
/>;
|
|
189
179
|
} else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Checkbox,
|
|
2
|
+
import { Checkbox, cls } from "@firecms/ui";
|
|
3
3
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
4
4
|
import { Property } from "../../types";
|
|
5
5
|
|
|
@@ -21,6 +21,6 @@ export function BooleanPreview({
|
|
|
21
21
|
size={size}
|
|
22
22
|
color={"secondary"}/>
|
|
23
23
|
{property.name && <span
|
|
24
|
-
className={
|
|
24
|
+
className={cls("text-text-secondary dark:text-text-secondary-dark", size === "tiny" ? "text-sm" : "")}>{property.name}</span>}
|
|
25
25
|
</div>;
|
|
26
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Chip } from "@firecms/ui";
|
|
2
3
|
import { EnumValues } from "../../types";
|
|
3
4
|
import { buildEnumLabel, enumToObjectEntries, getColorScheme, getLabelOrConfigFrom } from "../../util/enums";
|
|
4
|
-
import { Chip } from "@firecms/ui";
|
|
5
5
|
|
|
6
6
|
export interface EnumValuesChipProps {
|
|
7
7
|
enumValues?: EnumValues;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
import { Entity, EntityCollection, EntityReference } from "../../types";
|
|
4
|
-
import {
|
|
5
|
-
useCustomizationController,
|
|
6
|
-
useEntityFetch,
|
|
7
|
-
useNavigationController,
|
|
8
|
-
useSideEntityController
|
|
9
|
-
} from "../../hooks";
|
|
4
|
+
import { useCustomizationController, useEntityFetch, useNavigationController } from "../../hooks";
|
|
10
5
|
import { PreviewSize } from "../PropertyPreviewProps";
|
|
11
|
-
import {
|
|
6
|
+
import { Skeleton } from "@firecms/ui";
|
|
12
7
|
import { ErrorView } from "../../components";
|
|
13
|
-
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
14
8
|
import { EntityPreview, EntityPreviewContainer } from "../../components/EntityPreview";
|
|
15
9
|
|
|
16
10
|
export type ReferencePreviewProps = {
|
|
@@ -20,7 +14,8 @@ export type ReferencePreviewProps = {
|
|
|
20
14
|
previewProperties?: string[];
|
|
21
15
|
onClick?: (e: React.SyntheticEvent) => void;
|
|
22
16
|
hover?: boolean;
|
|
23
|
-
|
|
17
|
+
includeEntityLink?: boolean;
|
|
18
|
+
includeId?: boolean;
|
|
24
19
|
};
|
|
25
20
|
|
|
26
21
|
/**
|
|
@@ -46,19 +41,20 @@ function areEqual(prevProps: ReferencePreviewProps, nextProps: ReferencePreviewP
|
|
|
46
41
|
prevProps.hover === nextProps.hover &&
|
|
47
42
|
prevProps.reference?.id === nextProps.reference?.id &&
|
|
48
43
|
prevProps.reference?.path === nextProps.reference?.path &&
|
|
49
|
-
prevProps.
|
|
44
|
+
prevProps.includeEntityLink === nextProps.includeEntityLink
|
|
50
45
|
;
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
function ReferencePreviewInternal
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
function ReferencePreviewInternal({
|
|
49
|
+
disabled,
|
|
50
|
+
reference,
|
|
51
|
+
previewProperties,
|
|
52
|
+
size,
|
|
53
|
+
hover,
|
|
54
|
+
onClick,
|
|
55
|
+
includeEntityLink = true,
|
|
56
|
+
includeId = true
|
|
57
|
+
}: ReferencePreviewProps) {
|
|
62
58
|
|
|
63
59
|
const customizationController = useCustomizationController();
|
|
64
60
|
|
|
@@ -79,7 +75,8 @@ function ReferencePreviewInternal<M extends Record<string, any>>({
|
|
|
79
75
|
previewProperties={previewProperties}
|
|
80
76
|
size={size}
|
|
81
77
|
disabled={disabled}
|
|
82
|
-
|
|
78
|
+
includeEntityLink={includeEntityLink}
|
|
79
|
+
includeId={includeId}
|
|
83
80
|
onClick={onClick}
|
|
84
81
|
hover={hover}/>
|
|
85
82
|
}
|
|
@@ -90,7 +87,8 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
|
90
87
|
previewProperties,
|
|
91
88
|
size,
|
|
92
89
|
disabled,
|
|
93
|
-
|
|
90
|
+
includeEntityLink,
|
|
91
|
+
includeId,
|
|
94
92
|
onClick,
|
|
95
93
|
hover
|
|
96
94
|
}: ReferencePreviewProps & {
|
|
@@ -158,7 +156,8 @@ function ReferencePreviewExisting<M extends Record<string, any> = any>({
|
|
|
158
156
|
entity={usedEntity}
|
|
159
157
|
collection={collection}
|
|
160
158
|
onClick={onClick}
|
|
161
|
-
|
|
159
|
+
includeEntityLink={includeEntityLink}
|
|
160
|
+
includeId={includeId}
|
|
162
161
|
hover={hover}/>;
|
|
163
162
|
|
|
164
163
|
}
|
|
@@ -18,7 +18,6 @@ export function ArrayOfReferencesPreview({
|
|
|
18
18
|
const property = resolveArrayProperty({
|
|
19
19
|
propertyKey,
|
|
20
20
|
property: inputProperty,
|
|
21
|
-
propertyValue: value,
|
|
22
21
|
fields: customizationController.propertyConfigs
|
|
23
22
|
});
|
|
24
23
|
|
|
@@ -43,6 +42,8 @@ export function ArrayOfReferencesPreview({
|
|
|
43
42
|
previewProperties={ofProperty.previewProperties}
|
|
44
43
|
size={childSize}
|
|
45
44
|
reference={reference}
|
|
45
|
+
includeId={ofProperty.includeId}
|
|
46
|
+
includeEntityLink={ofProperty.includeEntityLink}
|
|
46
47
|
/>
|
|
47
48
|
</div>;
|
|
48
49
|
}
|
|
@@ -4,7 +4,7 @@ import { ResolvedProperty } from "../../types";
|
|
|
4
4
|
import { useCustomizationController } from "../../hooks";
|
|
5
5
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
6
6
|
import { PropertyPreview } from "../PropertyPreview";
|
|
7
|
-
import {
|
|
7
|
+
import { cls, defaultBorderMixin } from "@firecms/ui";
|
|
8
8
|
import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "../../util/common";
|
|
9
9
|
import { ErrorBoundary } from "../../components";
|
|
10
10
|
|
|
@@ -23,7 +23,6 @@ export function ArrayOneOfPreview({
|
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
|
-
propertyValue: value,
|
|
27
26
|
fields: customizationController.propertyConfigs
|
|
28
27
|
});
|
|
29
28
|
|
|
@@ -50,7 +49,7 @@ export function ArrayOneOfPreview({
|
|
|
50
49
|
values.map((value, index) =>
|
|
51
50
|
<React.Fragment
|
|
52
51
|
key={"preview_array_" + value + "_" + index}>
|
|
53
|
-
<div className={
|
|
52
|
+
<div className={cls(defaultBorderMixin, "m-1 border-b last:border-b-0")}>
|
|
54
53
|
<ErrorBoundary>
|
|
55
54
|
{value && <PropertyPreview
|
|
56
55
|
propertyKey={propertyKey}
|
|
@@ -5,7 +5,7 @@ import { ResolvedProperty } from "../../types";
|
|
|
5
5
|
import { useCustomizationController } from "../../hooks";
|
|
6
6
|
import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
7
7
|
import { PropertyPreview } from "../PropertyPreview";
|
|
8
|
-
import {
|
|
8
|
+
import { cls, defaultBorderMixin } from "@firecms/ui";
|
|
9
9
|
import { ErrorBoundary } from "../../components";
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -23,7 +23,6 @@ export function ArrayPropertyPreview({
|
|
|
23
23
|
const property = resolveArrayProperty({
|
|
24
24
|
propertyKey,
|
|
25
25
|
property: inputProperty,
|
|
26
|
-
propertyValue: value,
|
|
27
26
|
fields: customizationController.propertyConfigs
|
|
28
27
|
});
|
|
29
28
|
|
|
@@ -49,7 +48,7 @@ export function ArrayPropertyPreview({
|
|
|
49
48
|
return of
|
|
50
49
|
? <React.Fragment
|
|
51
50
|
key={"preview_array_" + index}>
|
|
52
|
-
<div className={
|
|
51
|
+
<div className={cls(defaultBorderMixin, "m-1 border-b last:border-b-0")}>
|
|
53
52
|
<ErrorBoundary>
|
|
54
53
|
<PropertyPreview
|
|
55
54
|
propertyKey={propertyKey}
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { ResolvedMapProperty } from "../../types";
|
|
4
4
|
import { PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
5
5
|
import { PropertyPreview } from "../PropertyPreview";
|
|
6
|
-
import {
|
|
6
|
+
import { cls, defaultBorderMixin, Typography } from "@firecms/ui";
|
|
7
7
|
import { ErrorBoundary } from "../../components";
|
|
8
8
|
import { EmptyValue } from "../components/EmptyValue";
|
|
9
9
|
|
|
@@ -61,7 +61,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
|
|
|
61
61
|
return (
|
|
62
62
|
<div
|
|
63
63
|
key={`map_preview_table_${key}}`}
|
|
64
|
-
className={
|
|
64
|
+
className={cls(defaultBorderMixin, "last:border-b-0 border-b")}>
|
|
65
65
|
<div
|
|
66
66
|
className={"flex flex-row pt-0.5 pb-0.5 gap-2"}>
|
|
67
67
|
<div
|
|
@@ -87,7 +87,7 @@ export function MapPropertyPreview<T extends Record<string, any> = Record<string
|
|
|
87
87
|
</div>
|
|
88
88
|
|
|
89
89
|
{(childProperty.dataType === "map" || childProperty === "array") &&
|
|
90
|
-
<div className={
|
|
90
|
+
<div className={cls(defaultBorderMixin, "border-l pl-4 ml-2 my-2")}>
|
|
91
91
|
<PropertyPreview
|
|
92
92
|
propertyKey={key}
|
|
93
93
|
value={(value)[key]}
|
|
@@ -113,7 +113,7 @@ export function KeyValuePreview({ value }: { value: any }) {
|
|
|
113
113
|
Object.entries(value).map(([key, childValue]) => (
|
|
114
114
|
<div
|
|
115
115
|
key={`map_preview_table_${key}}`}
|
|
116
|
-
className={
|
|
116
|
+
className={cls(defaultBorderMixin, "last:border-b-0 border-b")}>
|
|
117
117
|
<div
|
|
118
118
|
className={"flex flex-row pt-0.5 pb-0.5 gap-2"}>
|
|
119
119
|
<div
|
|
@@ -135,7 +135,7 @@ export function KeyValuePreview({ value }: { value: any }) {
|
|
|
135
135
|
</div>
|
|
136
136
|
</div>
|
|
137
137
|
{typeof childValue === "object" &&
|
|
138
|
-
<div className={
|
|
138
|
+
<div className={cls(defaultBorderMixin, "border-l pl-4")}>
|
|
139
139
|
<KeyValuePreview value={childValue}/>
|
|
140
140
|
</div>
|
|
141
141
|
}
|
|
@@ -6,7 +6,7 @@ import { PreviewType } from "../../types";
|
|
|
6
6
|
import { UrlComponentPreview } from "../components/UrlComponentPreview";
|
|
7
7
|
import { PropertyPreviewProps } from "../PropertyPreviewProps";
|
|
8
8
|
import { ErrorBoundary } from "../../components";
|
|
9
|
-
import { Chip,
|
|
9
|
+
import { Chip, cls, getColorSchemeForSeed } from "@firecms/ui";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @group Preview components
|
|
@@ -45,7 +45,7 @@ export function StringPropertyPreview({
|
|
|
45
45
|
if (!value) return <></>;
|
|
46
46
|
const lines = value.split("\n");
|
|
47
47
|
return value && value.includes("\n")
|
|
48
|
-
? <div className={
|
|
48
|
+
? <div className={cls("overflow-x-scroll", size === "tiny" ? "text-sm" : "")}>
|
|
49
49
|
{lines.map((str, index) =>
|
|
50
50
|
<React.Fragment key={`string_preview_${index}`}>
|
|
51
51
|
<span>{str}</span>
|
package/src/types/collections.ts
CHANGED
|
@@ -107,8 +107,12 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
107
107
|
* `subcollection:`. e.g. `subcollection:orders`.
|
|
108
108
|
* - If you are using a collection group, you will also have an
|
|
109
109
|
* additional `collectionGroupParent` column.
|
|
110
|
+
* You can use this prop to hide some properties from the table view.
|
|
111
|
+
* Note that if you set this prop, other ways to hide fields, like
|
|
112
|
+
* `hidden` in the property definition,will be ignored.
|
|
113
|
+
* `propertiesOrder` has precedence over `hidden`.
|
|
110
114
|
*/
|
|
111
|
-
propertiesOrder?: Extract<keyof M, string>[];
|
|
115
|
+
propertiesOrder?: (Extract<keyof M, string> | `subcollection:${string}`)[];
|
|
112
116
|
|
|
113
117
|
/**
|
|
114
118
|
* If enabled, content is loaded in batches. If `false` all entities in the
|
|
@@ -290,7 +294,16 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
290
294
|
* are writing custom code
|
|
291
295
|
*/
|
|
292
296
|
ownerId?: string;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Overrides for the entity view, like the data source or the storage source.
|
|
300
|
+
*/
|
|
293
301
|
overrides?: EntityOverrides;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Width of the side dialog (in pixels) when opening an entity in this collection.
|
|
305
|
+
*/
|
|
306
|
+
sideDialogWidth?: number | string;
|
|
294
307
|
}
|
|
295
308
|
|
|
296
309
|
/**
|
|
@@ -451,7 +464,10 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
|
|
|
451
464
|
* view.
|
|
452
465
|
* @param entity
|
|
453
466
|
*/
|
|
454
|
-
value?: (props: {
|
|
467
|
+
value?: (props: {
|
|
468
|
+
entity: Entity<M>,
|
|
469
|
+
context: FireCMSContext<any>
|
|
470
|
+
}) => string | number | Promise<string | number> | undefined;
|
|
455
471
|
}
|
|
456
472
|
|
|
457
473
|
/**
|
|
@@ -523,7 +539,7 @@ export type EntityTableController<M extends Record<string, any> = any> = {
|
|
|
523
539
|
filterValues?: FilterValues<Extract<keyof M, string>>;
|
|
524
540
|
setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string>>) => void;
|
|
525
541
|
sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
|
|
526
|
-
setSortBy?: (sortBy
|
|
542
|
+
setSortBy?: (sortBy?: [Extract<keyof M, string>, "asc" | "desc"]) => void;
|
|
527
543
|
searchString?: string;
|
|
528
544
|
setSearchString?: (searchString?: string) => void;
|
|
529
545
|
clearFilter?: () => void;
|
package/src/types/datasource.ts
CHANGED
|
@@ -216,6 +216,7 @@ export interface DataSource {
|
|
|
216
216
|
* @param props
|
|
217
217
|
*/
|
|
218
218
|
isFilterCombinationValid?(props: FilterCombinationValidProps): boolean;
|
|
219
|
+
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
export type FilterCombinationValidProps = {
|
|
@@ -366,24 +367,26 @@ export interface DataSourceDelegate {
|
|
|
366
367
|
* Convert a FireCMS reference to a reference that can be used by the datasource
|
|
367
368
|
* @param reference
|
|
368
369
|
*/
|
|
369
|
-
buildReference: (reference: EntityReference) => any,
|
|
370
|
+
// buildReference: (reference: EntityReference) => any,
|
|
370
371
|
|
|
371
372
|
/**
|
|
372
373
|
* Convert a FireCMS GeoPoint to a GeoPoint that can be used by the datasource
|
|
373
374
|
* @param geoPoint
|
|
374
375
|
*/
|
|
375
|
-
buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
376
|
+
// buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
376
377
|
|
|
377
378
|
/**
|
|
378
379
|
* Get the object to generate the current time in the datasource
|
|
379
380
|
*/
|
|
380
381
|
currentTime(): any;
|
|
381
382
|
|
|
382
|
-
buildDate: (date: Date) => any;
|
|
383
|
+
// buildDate: (date: Date) => any;
|
|
383
384
|
|
|
384
|
-
buildDeleteFieldValue: () => any;
|
|
385
|
+
// buildDeleteFieldValue: () => any;
|
|
385
386
|
|
|
386
387
|
delegateToCMSModel: (data: any) => any;
|
|
387
388
|
|
|
389
|
+
cmsToDelegateModel: (data: any) => any;
|
|
390
|
+
|
|
388
391
|
setDateToMidnight: (input?: any) => any;
|
|
389
392
|
}
|
package/src/types/entities.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type EntityValues<M extends object> = M;
|
|
|
37
37
|
/**
|
|
38
38
|
* Class used to create a reference to an entity in a different path
|
|
39
39
|
*/
|
|
40
|
-
export class EntityReference
|
|
40
|
+
export class EntityReference {
|
|
41
41
|
/**
|
|
42
42
|
* ID of the entity
|
|
43
43
|
*/
|
|
@@ -78,3 +78,11 @@ export class GeoPoint {
|
|
|
78
78
|
this.longitude = longitude;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
export class Vector {
|
|
83
|
+
readonly value: number[];
|
|
84
|
+
|
|
85
|
+
constructor(value: number[]) {
|
|
86
|
+
this.value = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -4,11 +4,26 @@ import { Entity } from "./entities";
|
|
|
4
4
|
import { EntityCollection, SelectionController } from "./collections";
|
|
5
5
|
import { User } from "./user";
|
|
6
6
|
import { SideEntityController } from "./side_entity_controller";
|
|
7
|
-
import { EntityOverrides } from "./entity_overrides";
|
|
8
7
|
|
|
8
|
+
/**
|
|
9
|
+
* An entity action is a custom action that can be performed on an entity.
|
|
10
|
+
* They are displayed in the entity view and in the collection view.
|
|
11
|
+
*/
|
|
9
12
|
export type EntityAction<M extends object = any, UserType extends User = User> = {
|
|
13
|
+
/**
|
|
14
|
+
* Title of the action
|
|
15
|
+
*/
|
|
10
16
|
name: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Icon of the action
|
|
20
|
+
*/
|
|
11
21
|
icon?: React.ReactElement;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Callback when the action is clicked
|
|
25
|
+
* @param props
|
|
26
|
+
*/
|
|
12
27
|
onClick: (props: EntityActionClickProps<M, UserType>) => Promise<void> | void;
|
|
13
28
|
|
|
14
29
|
/**
|
|
@@ -25,8 +40,6 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
25
40
|
|
|
26
41
|
}
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
|
|
30
43
|
export type EntityActionClickProps<M extends object, UserType extends User = User> = {
|
|
31
44
|
entity: Entity<M>;
|
|
32
45
|
context: FireCMSContext<UserType>;
|