@firecms/core 3.0.0-beta.6 → 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.
Files changed (129) hide show
  1. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
  2. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +4 -2
  3. package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +1 -0
  4. package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
  5. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
  6. package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
  7. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  8. package/dist/components/EntityPreview.d.ts +3 -2
  9. package/dist/components/FireCMSAppBar.d.ts +4 -2
  10. package/dist/components/ReferenceWidget.d.ts +3 -1
  11. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
  12. package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -6
  13. package/dist/components/VirtualTable/types.d.ts +3 -3
  14. package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
  15. package/dist/components/common/index.d.ts +1 -0
  16. package/dist/components/common/table_height.d.ts +5 -0
  17. package/dist/components/common/types.d.ts +3 -5
  18. package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
  19. package/dist/components/index.d.ts +1 -0
  20. package/dist/core/Drawer.d.ts +5 -12
  21. package/dist/core/DrawerNavigationItem.d.ts +9 -0
  22. package/dist/core/NavigationRoutes.d.ts +1 -1
  23. package/dist/core/Scaffold.d.ts +8 -12
  24. package/dist/core/index.d.ts +3 -4
  25. package/dist/hooks/data/save.d.ts +1 -2
  26. package/dist/hooks/index.d.ts +1 -0
  27. package/dist/index.es.js +9950 -9912
  28. package/dist/index.es.js.map +1 -1
  29. package/dist/index.umd.js +5 -5
  30. package/dist/index.umd.js.map +1 -1
  31. package/dist/preview/components/ReferencePreview.d.ts +2 -1
  32. package/dist/types/collections.d.ts +8 -1
  33. package/dist/types/entity_actions.d.ts +14 -0
  34. package/dist/types/navigation.d.ts +2 -2
  35. package/dist/types/properties.d.ts +8 -0
  36. package/dist/util/icon_synonyms.d.ts +1 -97
  37. package/dist/util/objects.d.ts +1 -1
  38. package/dist/util/resolutions.d.ts +8 -8
  39. package/package.json +139 -122
  40. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
  41. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +9 -7
  42. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
  43. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +22 -15
  44. package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
  45. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -1
  46. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +2 -2
  47. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +2 -2
  48. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +5 -6
  49. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
  50. package/src/components/EntityCollectionView/EntityCollectionView.tsx +19 -20
  51. package/src/components/EntityPreview.tsx +9 -7
  52. package/src/components/EntityView.tsx +4 -4
  53. package/src/components/FireCMSAppBar.tsx +32 -15
  54. package/src/components/HomePage/NavigationCard.tsx +2 -2
  55. package/src/components/HomePage/SmallNavigationCard.tsx +5 -5
  56. package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
  57. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -0
  58. package/src/components/ReferenceWidget.tsx +21 -11
  59. package/src/components/SearchIconsView.tsx +5 -5
  60. package/src/components/SelectableTable/SelectableTable.tsx +4 -2
  61. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +4 -1
  62. package/src/components/VirtualTable/VirtualTable.tsx +10 -11
  63. package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
  64. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
  65. package/src/components/VirtualTable/VirtualTableProps.tsx +1 -6
  66. package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
  67. package/src/components/VirtualTable/types.tsx +2 -3
  68. package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +2 -2
  69. package/src/components/common/index.ts +1 -0
  70. package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
  71. package/src/components/common/types.tsx +3 -5
  72. package/src/components/common/useColumnsIds.tsx +10 -2
  73. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +11 -0
  74. package/src/components/index.tsx +1 -0
  75. package/src/core/Drawer.tsx +16 -68
  76. package/src/core/DrawerNavigationItem.tsx +62 -0
  77. package/src/core/EntityEditView.tsx +7 -8
  78. package/src/core/EntitySidePanel.tsx +1 -1
  79. package/src/core/FireCMS.tsx +36 -40
  80. package/src/core/NavigationRoutes.tsx +3 -4
  81. package/src/core/Scaffold.tsx +80 -66
  82. package/src/core/field_configs.tsx +1 -1
  83. package/src/core/index.tsx +3 -4
  84. package/src/form/EntityForm.tsx +29 -21
  85. package/src/form/PropertyFieldBinding.tsx +0 -2
  86. package/src/form/components/StorageItemPreview.tsx +2 -2
  87. package/src/form/components/StorageUploadProgress.tsx +3 -3
  88. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -2
  89. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
  90. package/src/form/field_bindings/KeyValueFieldBinding.tsx +4 -4
  91. package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
  92. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
  93. package/src/form/field_bindings/ReferenceFieldBinding.tsx +15 -13
  94. package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
  95. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +4 -4
  96. package/src/hooks/data/save.ts +2 -1
  97. package/src/hooks/index.tsx +1 -0
  98. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +2 -3
  99. package/src/hooks/useBuildNavigationController.tsx +1 -2
  100. package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
  101. package/src/hooks/useValidateAuthenticator.tsx +15 -15
  102. package/src/internal/useBuildSideEntityController.tsx +72 -11
  103. package/src/preview/PropertyPreview.tsx +2 -2
  104. package/src/preview/components/BooleanPreview.tsx +2 -2
  105. package/src/preview/components/EnumValuesChip.tsx +1 -1
  106. package/src/preview/components/ReferencePreview.tsx +21 -22
  107. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
  108. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
  109. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
  110. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
  111. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
  112. package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
  113. package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
  114. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  115. package/src/types/collections.ts +14 -2
  116. package/src/types/entity_actions.tsx +16 -3
  117. package/src/types/navigation.ts +1 -2
  118. package/src/types/properties.ts +10 -0
  119. package/src/types/storage.ts +1 -1
  120. package/src/util/enums.ts +1 -1
  121. package/src/util/icon_list.ts +2 -2
  122. package/src/util/icon_synonyms.ts +3 -99
  123. package/src/util/objects.ts +8 -21
  124. package/src/util/resolutions.ts +32 -31
  125. package/dist/components/VirtualTable/common.d.ts +0 -2
  126. package/dist/core/SideEntityView.d.ts +0 -7
  127. package/dist/internal/useBuildCustomizationController.d.ts +0 -2
  128. package/src/core/SideEntityView.tsx +0 -38
  129. package/src/internal/useBuildCustomizationController.tsx +0 -5
@@ -8,7 +8,7 @@ import {
8
8
  ArrowDropDownIcon,
9
9
  BooleanSwitchWithLabel,
10
10
  Button,
11
- cn,
11
+ cls,
12
12
  DateTimeField,
13
13
  defaultBorderMixin,
14
14
  ExpandablePanel,
@@ -316,7 +316,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
316
316
  }}/>;
317
317
  } else if (dataType === "array") {
318
318
  return <div
319
- className={cn(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
319
+ className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
320
320
  <ArrayContainer value={entryValue}
321
321
  newDefaultEntry={""}
322
322
  droppableId={rowId.toString()}
@@ -349,7 +349,7 @@ function MapKeyValueRow<T extends Record<string, any>>({
349
349
  </div>;
350
350
  } else if (dataType === "map") {
351
351
  return <div
352
- className={cn(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
352
+ className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
353
353
  <MapEditView value={entryValue}
354
354
  fieldName={fieldKey}
355
355
  setValue={(updatedValue) => {
@@ -482,7 +482,7 @@ function ArrayKeyValueRow<T>({
482
482
  Arrays of arrays are not supported.
483
483
  </Typography>;
484
484
  } else if (dataType === "map") {
485
- return <div className={cn(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
485
+ return <div className={cls(defaultBorderMixin, "ml-2 pl-2 border-l border-solid")}>
486
486
  <MapEditView value={entryValue}
487
487
  setValue={(updatedValue) => {
488
488
  setValue(updatedValue);
@@ -8,7 +8,7 @@ import { FieldHelperText, LabelWithIcon } from "../components";
8
8
  import { FieldProps } from "../../types";
9
9
  import { getIconForProperty } from "../../util";
10
10
  import {
11
- cn,
11
+ cls,
12
12
  fieldBackgroundDisabledMixin,
13
13
  fieldBackgroundHoverMixin,
14
14
  fieldBackgroundMixin,
@@ -81,7 +81,7 @@ export function MarkdownFieldBinding({
81
81
  </Typography>}
82
82
 
83
83
  <MdEditor value={internalValue ?? ""}
84
- className={cn(fieldBackgroundMixin,
84
+ className={cls(fieldBackgroundMixin,
85
85
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
86
86
  "text-base")}
87
87
  readOnly={disabled}
@@ -6,7 +6,7 @@ import { PropertyPreview } from "../../preview";
6
6
  import { FieldHelperText, LabelWithIcon } from "../components";
7
7
  import { ErrorBoundary } from "../../components";
8
8
  import { getIconForProperty } from "../../util";
9
- import { cn, paperMixin } from "@firecms/ui";
9
+ import { cls, paperMixin } from "@firecms/ui";
10
10
 
11
11
  /**
12
12
  *
@@ -47,7 +47,7 @@ export function ReadOnlyFieldBinding({
47
47
  }
48
48
 
49
49
  <div
50
- className={cn(paperMixin, "min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar")}>
50
+ className={cls(paperMixin, "min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar")}>
51
51
 
52
52
  <ErrorBoundary>
53
53
  <PropertyPreview propertyKey={propertyKey}
@@ -27,19 +27,19 @@ export function ReferenceFieldBinding<M extends Record<string, any>>(props: Fiel
27
27
 
28
28
  }
29
29
 
30
- function ReferenceFieldBindingInternal<M extends Record<string, any>>({
31
- value,
32
- setValue,
33
- error,
34
- showError,
35
- isSubmitting,
36
- disabled,
37
- touched,
38
- autoFocus,
39
- property,
40
- includeDescription,
41
- context
42
- }: FieldProps<EntityReference>) {
30
+ function ReferenceFieldBindingInternal({
31
+ value,
32
+ setValue,
33
+ error,
34
+ showError,
35
+ isSubmitting,
36
+ disabled,
37
+ touched,
38
+ autoFocus,
39
+ property,
40
+ includeDescription,
41
+ context
42
+ }: FieldProps<EntityReference>) {
43
43
  if (!property.path) {
44
44
  throw new Error("Property path is required for ReferenceFieldBinding");
45
45
  }
@@ -99,6 +99,8 @@ function ReferenceFieldBindingInternal<M extends Record<string, any>>({
99
99
  size={"medium"}
100
100
  onClick={disabled || isSubmitting ? undefined : onEntryClick}
101
101
  reference={value}
102
+ includeEntityLink={property.includeEntityLink}
103
+ includeId={property.includeId}
102
104
  />}
103
105
 
104
106
  {!value && <div className="justify-center text-left">
@@ -4,7 +4,7 @@ import { EnumType, FieldProps } from "../../types";
4
4
  import { FieldHelperText, LabelWithIcon } from "../components";
5
5
  import { EnumValuesChip } from "../../preview";
6
6
  import { getIconForProperty } from "../../util";
7
- import { ClearIcon, cn, IconButton, Select, SelectItem } from "@firecms/ui";
7
+ import { ClearIcon, cls, IconButton, Select, SelectItem } from "@firecms/ui";
8
8
  import { useClearRestoreValue } from "../useClearRestoreValue";
9
9
 
10
10
  type SelectProps<T extends EnumType> = FieldProps<T>;
@@ -48,10 +48,10 @@ export function SelectFieldBinding<T extends EnumType>({
48
48
  <>
49
49
 
50
50
  <Select
51
- value={value ? value.toString() : ""}
51
+ value={value !== undefined && value != null ? value.toString() : ""}
52
52
  disabled={disabled}
53
53
  position="item-aligned"
54
- inputClassName={cn("w-full")}
54
+ inputClassName={cls("w-full")}
55
55
  label={<LabelWithIcon icon={getIconForProperty(property, "small")}
56
56
  required={property.validation?.required}
57
57
  title={property.name}
@@ -20,7 +20,7 @@ import { StorageFieldItem, useStorageUploadController } from "../../util/useStor
20
20
  import { StorageUploadProgress } from "../components/StorageUploadProgress";
21
21
  import { StorageItemPreview } from "../components/StorageItemPreview";
22
22
  import {
23
- cn,
23
+ cls,
24
24
  fieldBackgroundDisabledMixin,
25
25
  fieldBackgroundHoverMixin,
26
26
  fieldBackgroundMixin,
@@ -203,7 +203,7 @@ function FileDropComponent({
203
203
  return (
204
204
  <div
205
205
  {...getRootProps()}
206
- className={cn(
206
+ className={cls(
207
207
  fieldBackgroundMixin,
208
208
  disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin,
209
209
  dropZoneClasses,
@@ -220,7 +220,7 @@ function FileDropComponent({
220
220
  <div
221
221
  {...droppableProvided.droppableProps}
222
222
  ref={droppableProvided.innerRef}
223
- className={cn("flex items-center p-1 no-scrollbar",
223
+ className={cls("flex items-center p-1 no-scrollbar",
224
224
  multipleFilesSupported && internalValue.length ? "overflow-auto" : "",
225
225
  multipleFilesSupported && internalValue.length ? "min-h-[180px]" : "min-h-[250px]"
226
226
  )}
@@ -268,7 +268,7 @@ function FileDropComponent({
268
268
  ref={provided.innerRef}
269
269
  {...provided.draggableProps}
270
270
  {...provided.dragHandleProps}
271
- className={cn(focusedMixin, "rounded-md")}
271
+ className={cls(focusedMixin, "rounded-md")}
272
272
  style={{
273
273
  ...provided.draggableProps.style
274
274
  }}
@@ -17,7 +17,6 @@ import { resolveCollection } from "../../util";
17
17
  export type SaveEntityWithCallbacksProps<M extends Record<string, any>> =
18
18
  SaveEntityProps<M> &
19
19
  {
20
- callbacks?: EntityCallbacks<M>;
21
20
  onSaveSuccess?: (updatedEntity: Entity<M>) => void,
22
21
  onSaveFailure?: (e: Error) => void,
23
22
  onPreSaveHookError?: (e: Error) => void,
@@ -109,6 +108,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
109
108
  updatedValues = values;
110
109
  }
111
110
 
111
+ console.log("Saving entity", entityId, updatedValues);
112
112
  return dataSource.saveEntity({
113
113
  collection,
114
114
  path: resolvedPath,
@@ -117,6 +117,7 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, Use
117
117
  previousValues,
118
118
  status
119
119
  }).then((entity) => {
120
+ console.log("Entity saved");
120
121
  try {
121
122
  if (callbacks?.onSaveSuccess) {
122
123
  const resolvedCollection = resolveCollection<M>({
@@ -10,6 +10,7 @@ export * from "./useResolvedNavigationFrom";
10
10
 
11
11
  export * from "./useStorageSource";
12
12
  export * from "./useAuthController";
13
+ export * from "./useDialogsController";
13
14
  export * from "./useSideDialogsController";
14
15
  export * from "./useSideEntityController";
15
16
  export * from "./useFireCMSContext";
@@ -22,10 +22,9 @@ export function useBuildLocalConfigurationPersistence(): UserConfigurationPersis
22
22
  const onCollectionModified = useCallback(<M extends Record<string, any>>(path: string, data: PartialEntityCollection<M>) => {
23
23
  const storageKey = `collection_config::${stripCollectionPath(path)}`;
24
24
  localStorage.setItem(storageKey, JSON.stringify(data));
25
- const currentCache = configCache.current;
26
- const cachedConfig = currentCache[storageKey];
25
+ const cachedConfig = configCache.current[storageKey];
27
26
  const newConfig = mergeDeep(cachedConfig ?? getCollectionFromStorage(path), data);
28
- configCache.current = mergeDeep(currentCache, newConfig);
27
+ configCache.current[storageKey] = mergeDeep(configCache.current[storageKey], newConfig);
29
28
  }, [getCollectionFromStorage]);
30
29
 
31
30
  const [recentlyVisitedPaths, _setRecentlyVisitedPaths] = useState<string[]>([]);
@@ -241,7 +241,6 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
241
241
 
242
242
  const getCollection = useCallback((
243
243
  idOrPath: string,
244
- entityId?: string,
245
244
  includeUserOverride = false
246
245
  ): EC | undefined => {
247
246
  const collections = collectionsRef.current;
@@ -251,7 +250,7 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
251
250
  const baseCollection = getCollectionByPathOrId(removeInitialAndTrailingSlashes(idOrPath), collections);
252
251
 
253
252
  const userOverride = includeUserOverride ? userConfigPersistence?.getCollectionConfig(idOrPath) : undefined;
254
- const overriddenCollection = baseCollection ? mergeDeep(baseCollection, userOverride) : undefined;
253
+ const overriddenCollection = baseCollection ? mergeDeep(baseCollection, userOverride ?? {}) : undefined;
255
254
 
256
255
  let result: Partial<EntityCollection> | undefined = overriddenCollection;
257
256
 
@@ -80,7 +80,7 @@ export function resolveNavigationFrom<M extends Record<string, any>, UserType ex
80
80
  if (entry.type === "collection") {
81
81
  return Promise.resolve(entry);
82
82
  } else if (entry.type === "entity") {
83
- const collection = navigation.getCollection(entry.path, entry.entityId);
83
+ const collection = navigation.getCollection(entry.path);
84
84
  if (!collection) {
85
85
  throw Error(`No collection defined in the navigation for the entity with path ${entry.path}`);
86
86
  }
@@ -11,20 +11,21 @@ import { AuthController, Authenticator, DataSourceDelegate, StorageSource, User
11
11
  * @param storageSource
12
12
  * @param dataSourceDelegate
13
13
  */
14
- export function useValidateAuthenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>>({
15
- disabled,
16
- authController,
17
- authenticator,
18
- storageSource,
19
- dataSourceDelegate
20
- }:
21
- {
22
- disabled?: boolean,
23
- authController: Controller,
24
- authenticator?: boolean | Authenticator<UserType, Controller>,
25
- dataSourceDelegate: DataSourceDelegate;
26
- storageSource: StorageSource;
27
- }): {
14
+ export function useValidateAuthenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>>
15
+ ({
16
+ disabled,
17
+ authController,
18
+ authenticator,
19
+ storageSource,
20
+ dataSourceDelegate
21
+ }:
22
+ {
23
+ disabled?: boolean,
24
+ authController: Controller,
25
+ authenticator?: boolean | Authenticator<UserType, Controller>,
26
+ dataSourceDelegate: DataSourceDelegate;
27
+ storageSource: StorageSource;
28
+ }): {
28
29
  canAccessMainView: boolean,
29
30
  authLoading: boolean,
30
31
  notAllowedError: any,
@@ -70,7 +71,6 @@ export function useValidateAuthenticator<UserType extends User = User, Controlle
70
71
  }
71
72
 
72
73
  const delegateUser = authController.user;
73
- console.debug("Checking authentication for user", delegateUser);
74
74
 
75
75
  if (authenticator instanceof Function && delegateUser && !equal(checkedUserRef.current?.uid, delegateUser.uid)) {
76
76
  setAuthLoading(true);
@@ -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
- const resolvedWidth: string | undefined = typeof props.width === "number" ? `${props.width}px` : props.width;
23
- return !mainViewSelected ? `calc(${ADDITIONAL_TAB_WIDTH} + ${resolvedWidth ?? FORM_CONTAINER_WIDTH})` : resolvedWidth ?? FORM_CONTAINER_WIDTH
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,12 +100,12 @@ 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 panel = panelsFromUrl[i];
103
+ const props = panelsFromUrl[i];
44
104
  setTimeout(() => {
45
105
  if (i === 0)
46
- sideDialogsController.replace(propsToSidePanel(panel, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout));
106
+ sideDialogsController.replace(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout));
47
107
  else
48
- sideDialogsController.open(propsToSidePanel(panel, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout))
108
+ sideDialogsController.open(propsToSidePanel(props, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout))
49
109
  }, 1);
50
110
  }
51
111
  } else {
@@ -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") {
@@ -163,16 +224,16 @@ const propsToSidePanel = (props: EntitySidePanelProps<any>,
163
224
 
164
225
  const resolvedPanelProps: EntitySidePanelProps<any> = {
165
226
  ...props,
166
- path: resolvedPath
227
+ path: resolvedPath,
167
228
  };
168
229
 
169
- return ({
230
+ return {
170
231
  key: `${props.path}/${props.entityId}`,
171
232
  component: <EntitySidePanel {...resolvedPanelProps}/>,
172
233
  urlPath: newPath,
173
234
  parentUrlPath: buildUrlCollectionPath(collectionPath),
174
235
  width: getEntityViewWidth(props, smallLayout),
175
236
  onClose: props.onClose
176
- });
237
+ };
177
238
  }
178
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
 
@@ -172,8 +171,9 @@ export const PropertyPreview = React.memo(function PropertyPreview<T extends CMS
172
171
  content = <ReferencePreview
173
172
  disabled={!property.path}
174
173
  previewProperties={property.previewProperties}
174
+ includeId={property.includeId}
175
+ includeEntityLink={property.includeEntityLink}
175
176
  size={props.size}
176
- // onClick={props.onClick}
177
177
  reference={value as EntityReference}
178
178
  />;
179
179
  } else {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Checkbox, cn } from "@firecms/ui";
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={cn("text-text-secondary dark:text-text-secondary-dark", size === "tiny" ? "text-sm" : "")}>{property.name}</span>}
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 { IconButton, KeyboardTabIcon, Skeleton, Tooltip } from "@firecms/ui";
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
- allowEntityNavigation?: boolean;
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.allowEntityNavigation === nextProps.allowEntityNavigation
44
+ prevProps.includeEntityLink === nextProps.includeEntityLink
50
45
  ;
51
46
  }
52
47
 
53
- function ReferencePreviewInternal<M extends Record<string, any>>({
54
- disabled,
55
- reference,
56
- previewProperties,
57
- size,
58
- hover,
59
- onClick,
60
- allowEntityNavigation = true
61
- }: ReferencePreviewProps) {
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
- allowEntityNavigation={allowEntityNavigation}
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
- allowEntityNavigation,
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
- includeEntityNavigation={allowEntityNavigation}
159
+ includeEntityLink={includeEntityLink}
160
+ includeId={includeId}
162
161
  hover={hover}/>;
163
162
 
164
163
  }
@@ -20,7 +20,6 @@ export function ArrayOfMapsPreview({
20
20
  const property = resolveArrayProperty({
21
21
  propertyKey,
22
22
  property: inputProperty,
23
- propertyValue: value,
24
23
  fields: customizationController.propertyConfigs
25
24
  });
26
25
 
@@ -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
  }
@@ -23,7 +23,6 @@ export function ArrayOfStorageComponentsPreview({
23
23
  const property = resolveArrayProperty({
24
24
  propertyKey,
25
25
  property: inputProperty,
26
- propertyValue: value,
27
26
  fields: customizationController.propertyConfigs
28
27
  });
29
28
 
@@ -21,7 +21,6 @@ export function ArrayOfStringsPreview({
21
21
  const property = resolveArrayProperty({
22
22
  propertyKey,
23
23
  property: inputProperty,
24
- propertyValue: value,
25
24
  fields: customizationController.propertyConfigs
26
25
  });
27
26
 
@@ -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 { cn, defaultBorderMixin } from "@firecms/ui";
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={cn(defaultBorderMixin, "m-1 border-b last:border-b-0")}>
52
+ <div className={cls(defaultBorderMixin, "m-1 border-b last:border-b-0")}>
54
53
  <ErrorBoundary>
55
54
  {value && <PropertyPreview
56
55
  propertyKey={propertyKey}