@firecms/core 3.0.0-beta.12 → 3.0.0-beta.13

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 (84) hide show
  1. package/dist/app/Scaffold.d.ts +4 -0
  2. package/dist/components/ArrayContainer.d.ts +12 -5
  3. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +4 -0
  4. package/dist/components/EntityJsonPreview.d.ts +3 -0
  5. package/dist/core/DefaultAppBar.d.ts +8 -2
  6. package/dist/core/EntityEditView.d.ts +8 -1
  7. package/dist/core/FireCMS.d.ts +2 -2
  8. package/dist/form/EntityForm.d.ts +5 -1
  9. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  10. package/dist/hooks/data/save.d.ts +1 -1
  11. package/dist/index.es.js +8630 -8578
  12. package/dist/index.es.js.map +1 -1
  13. package/dist/index.umd.js +8663 -8612
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/internal/useBuildDataSource.d.ts +3 -2
  16. package/dist/internal/useBuildSideEntityController.d.ts +3 -3
  17. package/dist/types/collections.d.ts +6 -0
  18. package/dist/types/fields.d.ts +4 -1
  19. package/dist/types/firecms.d.ts +1 -1
  20. package/dist/types/navigation.d.ts +4 -0
  21. package/dist/types/plugins.d.ts +1 -0
  22. package/dist/types/properties.d.ts +22 -1
  23. package/dist/util/createFormexStub.d.ts +2 -0
  24. package/dist/util/navigation_utils.d.ts +2 -1
  25. package/dist/util/objects.d.ts +1 -1
  26. package/dist/util/property_utils.d.ts +2 -2
  27. package/dist/util/references.d.ts +2 -2
  28. package/dist/util/resolutions.d.ts +11 -6
  29. package/package.json +6 -5
  30. package/src/app/Scaffold.tsx +13 -3
  31. package/src/components/ArrayContainer.tsx +40 -23
  32. package/src/components/DeleteEntityDialog.tsx +4 -2
  33. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +8 -6
  34. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -2
  35. package/src/components/EntityCollectionView/EntityCollectionView.tsx +22 -6
  36. package/src/components/EntityJsonPreview.tsx +66 -0
  37. package/src/components/EntityPreview.tsx +10 -3
  38. package/src/components/EntityView.tsx +4 -1
  39. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -1
  40. package/src/components/VirtualTable/VirtualTable.tsx +29 -1
  41. package/src/components/common/default_entity_actions.tsx +15 -4
  42. package/src/core/DefaultAppBar.tsx +17 -5
  43. package/src/core/EntityEditView.tsx +111 -35
  44. package/src/core/FireCMS.tsx +13 -12
  45. package/src/form/EntityForm.tsx +31 -23
  46. package/src/form/PropertyFieldBinding.tsx +8 -5
  47. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +4 -1
  48. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -0
  49. package/src/form/field_bindings/BlockFieldBinding.tsx +1 -1
  50. package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
  51. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +6 -2
  52. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +2 -2
  53. package/src/form/field_bindings/RepeatFieldBinding.tsx +8 -2
  54. package/src/form/field_bindings/SelectFieldBinding.tsx +1 -1
  55. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +5 -2
  56. package/src/hooks/data/save.ts +24 -29
  57. package/src/hooks/useBuildNavigationController.tsx +12 -1
  58. package/src/hooks/useFireCMSContext.tsx +0 -30
  59. package/src/internal/useBuildDataSource.ts +9 -5
  60. package/src/internal/useBuildSideEntityController.tsx +26 -20
  61. package/src/preview/PropertyPreview.tsx +4 -2
  62. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
  63. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
  64. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
  65. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
  66. package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
  67. package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
  68. package/src/routes/FireCMSRoute.tsx +15 -4
  69. package/src/types/collections.ts +7 -0
  70. package/src/types/fields.tsx +5 -1
  71. package/src/types/firecms.tsx +1 -1
  72. package/src/types/navigation.ts +5 -0
  73. package/src/types/plugins.tsx +1 -0
  74. package/src/types/properties.ts +27 -1
  75. package/src/types/side_entity_controller.tsx +5 -0
  76. package/src/util/createFormexStub.tsx +62 -0
  77. package/src/util/join_collections.ts +3 -1
  78. package/src/util/navigation_from_path.ts +5 -1
  79. package/src/util/navigation_utils.ts +64 -15
  80. package/src/util/objects.ts +5 -1
  81. package/src/util/property_utils.tsx +7 -3
  82. package/src/util/references.ts +8 -6
  83. package/src/util/resolutions.ts +17 -9
  84. package/src/util/useStorageUploadController.tsx +21 -2
@@ -1,11 +1,12 @@
1
- import { DataSource, DataSourceDelegate, NavigationController, PropertyConfig } from "../types";
1
+ import { AuthController, DataSource, DataSourceDelegate, NavigationController, PropertyConfig } from "../types";
2
2
  /**
3
3
  * Use this hook to build a {@link DataSource} based on Firestore
4
4
  * @param firebaseApp
5
5
  * @group Firebase
6
6
  */
7
- export declare function useBuildDataSource({ delegate, propertyConfigs, navigationController }: {
7
+ export declare function useBuildDataSource({ delegate, propertyConfigs, navigationController, authController }: {
8
8
  delegate: DataSourceDelegate;
9
9
  propertyConfigs?: Record<string, PropertyConfig>;
10
10
  navigationController: NavigationController;
11
+ authController: AuthController;
11
12
  }): DataSource;
@@ -1,4 +1,4 @@
1
- import { CustomizationController, EntityCollection, EntitySidePanelProps, NavigationController, SideDialogsController, SideEntityController } from "../types";
2
- export declare function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean, customizationController: CustomizationController): string;
3
- export declare const useBuildSideEntityController: (navigation: NavigationController, sideDialogsController: SideDialogsController) => SideEntityController;
1
+ import { AuthController, CustomizationController, EntityCollection, EntitySidePanelProps, NavigationController, SideDialogsController, SideEntityController } from "../types";
2
+ export declare function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean, customizationController: CustomizationController, authController: AuthController): string;
3
+ export declare const useBuildSideEntityController: (navigation: NavigationController, sideDialogsController: SideDialogsController, authController: AuthController) => SideEntityController;
4
4
  export declare function buildSidePanelsFromUrl(path: string, collections: EntityCollection[], newFlag: boolean): EntitySidePanelProps<any>[];
@@ -189,12 +189,14 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
189
189
  * Force a filter in this view. If applied, the rest of the filters will
190
190
  * be disabled. Filters applied with this prop cannot be changed.
191
191
  * e.g. `forceFilter: { age: [">=", 18] }`
192
+ * e.g. `forceFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
192
193
  */
193
194
  forceFilter?: FilterValues<Extract<keyof M, string>>;
194
195
  /**
195
196
  * Initial filters applied to the collection this collection is related to.
196
197
  * Defaults to none. Filters applied with this prop can be changed.
197
198
  * e.g. `initialFilter: { age: [">=", 18] }`
199
+ * e.g. `initialFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
198
200
  */
199
201
  initialFilter?: FilterValues<Extract<keyof M, string>>;
200
202
  /**
@@ -287,6 +289,10 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
287
289
  * Defaults to false.
288
290
  */
289
291
  alwaysApplyDefaultValues?: boolean;
292
+ /**
293
+ * If set to true, a tab including the JSON representation of the entity will be included.
294
+ */
295
+ includeJsonView?: boolean;
290
296
  }
291
297
  /**
292
298
  * Parameter passed to the `Actions` prop in the collection configuration.
@@ -138,9 +138,12 @@ export interface FormContext<M extends Record<string, any> = any> {
138
138
  savingError?: Error;
139
139
  openEntityMode: "side_panel" | "full_screen";
140
140
  /**
141
- * This is the underlying formex controller that powers the form
141
+ * This is the underlying formex controller that powers the form.
142
+ * If you are in a red only mode, the formex controller is there, but you can't
143
+ * operate with it
142
144
  */
143
145
  formex: FormexController<M>;
146
+ disabled: boolean;
144
147
  }
145
148
  /**
146
149
  * In case you need to render a field bound to a Property inside your
@@ -44,7 +44,7 @@ export type CMSViewsBuilder = (params: {
44
44
  /**
45
45
  * @group Models
46
46
  */
47
- export type FireCMSProps<USER extends User, EC extends EntityCollection> = {
47
+ export type FireCMSProps<USER extends User> = {
48
48
  /**
49
49
  * Use this function to return the components you want to render under
50
50
  * FireCMS
@@ -49,6 +49,10 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
49
49
  * The collection is resolved from the given path or alias.
50
50
  */
51
51
  getCollection: (pathOrId: string, includeUserOverride?: boolean) => EC | undefined;
52
+ /**
53
+ * Get the top level collection configuration for a given id
54
+ */
55
+ getCollectionById: (id: string) => EC | undefined;
52
56
  /**
53
57
  * Get the collection configuration from its parent ids.
54
58
  */
@@ -159,6 +159,7 @@ export interface PluginFormActionProps<USER extends User = User, EC extends Enti
159
159
  path: string;
160
160
  status: EntityStatus;
161
161
  collection: EC;
162
+ disabled: boolean;
162
163
  formContext?: FormContext<any>;
163
164
  context: FireCMSContext<USER>;
164
165
  currentEntityId?: string;
@@ -5,6 +5,7 @@ import { EntityReference, EntityValues, GeoPoint, Vector } from "./entities";
5
5
  import { ResolvedArrayProperty, ResolvedStringProperty } from "./resolved_entities";
6
6
  import { FilterValues } from "./collections";
7
7
  import { ChipColorKey, ChipColorScheme } from "@firecms/ui";
8
+ import { AuthController } from "./auth";
8
9
  /**
9
10
  * @group Entity properties
10
11
  */
@@ -205,6 +206,10 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
205
206
  * Entity ID
206
207
  */
207
208
  entityId?: string;
209
+ /**
210
+ * Controller to manage authentication
211
+ */
212
+ authController: AuthController;
208
213
  };
209
214
  /**
210
215
  * You can use this type to define a property dynamically, based
@@ -212,7 +217,7 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
212
217
  * current value of the property, as well as the path and entity ID.
213
218
  * @group Entity properties
214
219
  */
215
- export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, index, path, entityId }: PropertyBuilderProps<M>) => Property<T> | null;
220
+ export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, index, path, entityId, authController }: PropertyBuilderProps<M>) => Property<T> | null;
216
221
  /**
217
222
  * @group Entity properties
218
223
  */
@@ -371,6 +376,16 @@ export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSTyp
371
376
  * extendable panel.
372
377
  */
373
378
  minimalistView?: boolean;
379
+ /**
380
+ * Can the elements in this array be reordered. Defaults to `true`.
381
+ * This prop has no effect if `disabled` is set to true.
382
+ */
383
+ sortable?: boolean;
384
+ /**
385
+ * Can the elements in this array be added. Defaults to `true`
386
+ * This prop has no effect if `disabled` is set to true.
387
+ */
388
+ canAddElements?: boolean;
374
389
  }
375
390
  /**
376
391
  * @group Entity properties
@@ -638,6 +653,12 @@ export type StorageConfig = {
638
653
  * Define maximal file size in bytes
639
654
  */
640
655
  maxSize?: number;
656
+ /**
657
+ * Use this callback to process the file before uploading it to the storage.
658
+ * If nothing is returned, the file is uploaded as it is.
659
+ * @param file
660
+ */
661
+ processFile?: (file: File) => Promise<File> | undefined;
641
662
  /**
642
663
  * Postprocess the saved value (storage path or URL)
643
664
  * after it has been resolved.
@@ -0,0 +1,2 @@
1
+ import { FormexController } from "@firecms/formex";
2
+ export declare function createFormexStub<T extends object>(values: T): FormexController<T>;
@@ -18,13 +18,14 @@ export declare function getCollectionByPathOrId(pathOrId: string, collections: E
18
18
  * @param subpaths
19
19
  */
20
20
  export declare function getCollectionPathsCombinations(subpaths: string[]): string[];
21
- export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, selectedTab, sideEntityController, onClose, navigation }: {
21
+ export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, fullIdPath, selectedTab, sideEntityController, onClose, navigation }: {
22
22
  openEntityMode: "side_panel" | "full_screen";
23
23
  collection?: EntityCollection;
24
24
  entityId?: string;
25
25
  selectedTab?: string;
26
26
  copy?: boolean;
27
27
  path: string;
28
+ fullIdPath?: string;
28
29
  sideEntityController: SideEntityController;
29
30
  onClose?: () => void;
30
31
  navigation: NavigationController;
@@ -1,6 +1,6 @@
1
1
  export declare const pick: <T>(obj: T, ...args: any[]) => T;
2
2
  export declare function isObject(item: any): any;
3
- export declare function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(target: T, source: U): T & U;
3
+ export declare function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(target: T, source: U, ignoreUndefined?: boolean): T & U;
4
4
  export declare function getValueInPath(o: object | undefined, path: string): any;
5
5
  export declare function removeInPath(o: object, path: string): object | undefined;
6
6
  export declare function removeFunctions(o: object | undefined): any;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { EntityCollection, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedProperties, ResolvedProperty } from "../types";
3
- export declare function isReferenceProperty(propertyOrBuilder: PropertyOrBuilder, fields: Record<string, PropertyConfig>): boolean | null;
2
+ import { AuthController, EntityCollection, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedProperties, ResolvedProperty } from "../types";
3
+ export declare function isReferenceProperty(authController: AuthController, propertyOrBuilder: PropertyOrBuilder, fields: Record<string, PropertyConfig>): boolean | null;
4
4
  export declare function getIdIcon(size: "small" | "medium" | "large"): React.ReactNode;
5
5
  export declare function getIconForWidget(widget: PropertyConfig | undefined, size: "small" | "medium" | "large"): import("react/jsx-runtime").JSX.Element;
6
6
  export declare function getIconForProperty(property: PropertyOrBuilder<any> | ResolvedProperty<any>, size?: "small" | "medium" | "large", fields?: Record<string, PropertyConfig>): React.ReactNode;
@@ -1,4 +1,4 @@
1
- import { EntityCollection, PropertyConfig, ResolvedEntityCollection } from "../types";
2
- export declare function getEntityPreviewKeys(targetCollection: EntityCollection<any>, fields: Record<string, PropertyConfig>, previewProperties?: string[], limit?: number): string[];
1
+ import { AuthController, EntityCollection, PropertyConfig, ResolvedEntityCollection } from "../types";
2
+ export declare function getEntityPreviewKeys(authController: AuthController, targetCollection: EntityCollection<any>, fields: Record<string, PropertyConfig>, previewProperties?: string[], limit?: number): string[];
3
3
  export declare function getEntityTitlePropertyKey<M extends Record<string, any>>(collection: EntityCollection<M>, propertyConfigs: Record<string, PropertyConfig<any>>): string | undefined;
4
4
  export declare function getEntityImagePreviewPropertyKey<M extends object>(collection: ResolvedEntityCollection<M>): string | undefined;
@@ -1,5 +1,5 @@
1
- import { ArrayProperty, CMSType, CustomizationController, EntityCollection, EntityCustomView, EntityValues, EnumValueConfig, EnumValues, NumberProperty, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedArrayProperty, ResolvedEntityCollection, ResolvedNumberProperty, ResolvedProperties, ResolvedProperty, ResolvedStringProperty, StringProperty, UserConfigurationPersistence } from "../types";
2
- export declare const resolveCollection: <M extends Record<string, any>>({ collection, path, entityId, values, previousValues, userConfigPersistence, propertyConfigs, ignoreMissingFields }: {
1
+ import { ArrayProperty, AuthController, CMSType, CustomizationController, EntityCollection, EntityCustomView, EntityValues, EnumValueConfig, EnumValues, NumberProperty, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedArrayProperty, ResolvedEntityCollection, ResolvedNumberProperty, ResolvedProperties, ResolvedProperty, ResolvedStringProperty, StringProperty, UserConfigurationPersistence } from "../types";
2
+ export declare const resolveCollection: <M extends Record<string, any>>({ collection, path, entityId, values, previousValues, userConfigPersistence, propertyConfigs, ignoreMissingFields, authController }: {
3
3
  collection: EntityCollection<M> | ResolvedEntityCollection<M>;
4
4
  path: string;
5
5
  entityId?: string;
@@ -8,6 +8,7 @@ export declare const resolveCollection: <M extends Record<string, any>>({ collec
8
8
  userConfigPersistence?: UserConfigurationPersistence;
9
9
  propertyConfigs?: Record<string, PropertyConfig>;
10
10
  ignoreMissingFields?: boolean;
11
+ authController: AuthController;
11
12
  }) => ResolvedEntityCollection<M>;
12
13
  /**
13
14
  * Resolve property builders, enums and arrays.
@@ -25,6 +26,7 @@ export declare function resolveProperty<T extends CMSType = CMSType, M extends R
25
26
  fromBuilder?: boolean;
26
27
  propertyConfigs?: Record<string, PropertyConfig<any>>;
27
28
  ignoreMissingFields?: boolean;
29
+ authController: AuthController;
28
30
  }): ResolvedProperty<T> | null;
29
31
  export declare function getArrayResolvedProperties<M>({ propertyKey, propertyValue, property, ...props }: {
30
32
  propertyValue: any;
@@ -38,6 +40,7 @@ export declare function getArrayResolvedProperties<M>({ propertyKey, propertyVal
38
40
  index?: number;
39
41
  fromBuilder?: boolean;
40
42
  propertyConfigs?: Record<string, PropertyConfig>;
43
+ authController: AuthController;
41
44
  }): ResolvedProperty[];
42
45
  export declare function resolveArrayProperty<T extends any[], M>({ propertyKey, property, ignoreMissingFields, ...props }: {
43
46
  propertyKey?: string;
@@ -50,6 +53,7 @@ export declare function resolveArrayProperty<T extends any[], M>({ propertyKey,
50
53
  fromBuilder?: boolean;
51
54
  propertyConfigs?: Record<string, PropertyConfig>;
52
55
  ignoreMissingFields?: boolean;
56
+ authController: AuthController;
53
57
  }): ResolvedArrayProperty;
54
58
  /**
55
59
  * Resolve enums and arrays for properties
@@ -67,6 +71,7 @@ export declare function resolveProperties<M extends Record<string, any>>({ prope
67
71
  fromBuilder?: boolean;
68
72
  propertyConfigs?: Record<string, PropertyConfig>;
69
73
  ignoreMissingFields?: boolean;
74
+ authController: AuthController;
70
75
  }): ResolvedProperties<M>;
71
76
  /**
72
77
  * Resolve enum aliases for a string or number property
@@ -76,8 +81,8 @@ export declare function resolveProperties<M extends Record<string, any>>({ prope
76
81
  export declare function resolvePropertyEnum(property: StringProperty | NumberProperty, fromBuilder?: boolean): ResolvedStringProperty | ResolvedNumberProperty;
77
82
  export declare function resolveEnumValues(input: EnumValues): EnumValueConfig[] | undefined;
78
83
  export declare function resolveEntityView(entityView: string | EntityCustomView<any>, contextEntityViews?: EntityCustomView<any>[]): EntityCustomView<any> | undefined;
79
- export declare function resolvedSelectedEntityView<M extends Record<string, any>>(customViews: (string | EntityCustomView<M>)[] | undefined, customizationController: CustomizationController, selectedTab?: string): {
80
- resolvedEntityViews: EntityCustomView[];
81
- selectedEntityView: EntityCustomView | undefined;
82
- selectedSecondaryForm: EntityCustomView | undefined;
84
+ export declare function resolvedSelectedEntityView<M extends Record<string, any>>(customViews: (string | EntityCustomView<M>)[] | undefined, customizationController: CustomizationController, selectedTab?: string, canEdit?: boolean): {
85
+ resolvedEntityViews: EntityCustomView<M>[];
86
+ selectedEntityView: EntityCustomView<M> | undefined;
87
+ selectedSecondaryForm: EntityCustomView<M> | undefined;
83
88
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-beta.12",
4
+ "version": "3.0.0-beta.13",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -50,9 +50,9 @@
50
50
  "./package.json": "./package.json"
51
51
  },
52
52
  "dependencies": {
53
- "@firecms/editor": "^3.0.0-beta.12",
54
- "@firecms/formex": "^3.0.0-beta.12",
55
- "@firecms/ui": "^3.0.0-beta.12",
53
+ "@firecms/editor": "^3.0.0-beta.13",
54
+ "@firecms/formex": "^3.0.0-beta.13",
55
+ "@firecms/ui": "^3.0.0-beta.13",
56
56
  "@hello-pangea/dnd": "^17.0.0",
57
57
  "@radix-ui/react-portal": "^1.1.3",
58
58
  "clsx": "^2.1.1",
@@ -62,6 +62,7 @@
62
62
  "markdown-it": "^14.1.0",
63
63
  "notistack": "^3.0.2",
64
64
  "object-hash": "^3.0.0",
65
+ "prism-react-renderer": "^2.4.1",
65
66
  "react-dropzone": "^14.3.5",
66
67
  "react-fast-compare": "^3.2.2",
67
68
  "react-image-file-resizer": "^0.4.8",
@@ -104,7 +105,7 @@
104
105
  "dist",
105
106
  "src"
106
107
  ],
107
- "gitHead": "8de3edb4560643922fe44e9c357985f64c3951c1",
108
+ "gitHead": "26d5e1f33a7ac00c78e45cd3cb3c397f4ba00821",
108
109
  "publishConfig": {
109
110
  "access": "public"
110
111
  },
@@ -23,6 +23,11 @@ export interface ScaffoldProps {
23
23
  */
24
24
  logo?: string;
25
25
 
26
+ /**
27
+ * If true, the main content will be padded in large layouts. Defaults to true.
28
+ */
29
+ padding?: boolean;
30
+
26
31
  className?: string;
27
32
 
28
33
  style?: React.CSSProperties;
@@ -47,7 +52,8 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
47
52
  autoOpenDrawer,
48
53
  logo,
49
54
  className,
50
- style
55
+ style,
56
+ padding = true
51
57
  } = props;
52
58
 
53
59
  const drawerChildren = React.Children.toArray(children).filter((child: any) => child.type.componentType === "Drawer");
@@ -116,10 +122,14 @@ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
116
122
 
117
123
  <main
118
124
  className="flex flex-col flex-grow overflow-auto">
125
+
119
126
  {hasAppBar && <DrawerHeader/>}
127
+
120
128
  <div
121
- className={cls(defaultBorderMixin, "flex-grow overflow-auto lg:m-0 lg:mx-4 lg:mb-4 lg:rounded-lg lg:border lg:border-solid m-0 mt-1", {
122
- "lg:mt-4": !hasAppBar
129
+ className={cls(defaultBorderMixin, "flex-grow overflow-auto m-0 ", {
130
+ "lg:mt-4": !hasAppBar,
131
+ "mt-1 lg:m-0 lg:mx-4 lg:mb-4 lg:rounded-lg lg:border lg:border-solid": padding,
132
+ "border-t": hasAppBar && !padding,
123
133
  })}>
124
134
 
125
135
  <ErrorBoundary>
@@ -37,7 +37,12 @@ export interface ArrayContainerProps<T> {
37
37
  disabled?: boolean;
38
38
  size?: "small" | "medium";
39
39
  onInternalIdAdded?: (id: number) => void;
40
+ /**
41
+ * @deprecated Use `canAddElements` instead
42
+ */
40
43
  includeAddButton?: boolean;
44
+ canAddElements?: boolean;
45
+ sortable?: boolean;
41
46
  newDefaultEntry: T;
42
47
  onValueChange: (value: T[]) => void,
43
48
  className?: string;
@@ -66,7 +71,9 @@ export function ArrayContainer<T>({
66
71
  buildEntry,
67
72
  size = "medium",
68
73
  onInternalIdAdded,
69
- includeAddButton,
74
+ includeAddButton: deprecatedIncludeAddButton,
75
+ canAddElements: canAddElementsProp = true,
76
+ sortable = true,
70
77
  newDefaultEntry,
71
78
  onValueChange,
72
79
  className,
@@ -74,6 +81,9 @@ export function ArrayContainer<T>({
74
81
  max = Infinity
75
82
  }: ArrayContainerProps<T>) {
76
83
 
84
+ const canAddElements = (canAddElementsProp || canAddElementsProp === undefined)
85
+ && (deprecatedIncludeAddButton === undefined || deprecatedIncludeAddButton);
86
+
77
87
  const hasValue = value && Array.isArray(value) && value.length > 0;
78
88
 
79
89
  // Used to track the ids that have displayed the initial show animation
@@ -193,7 +203,8 @@ export function ArrayContainer<T>({
193
203
  storedProps={itemCustomPropsRef.current[internalId]}
194
204
  updateItemCustomProps={updateItemCustomProps}
195
205
  addInIndex={addInIndex}
196
- includeAddButton={includeAddButton}
206
+ canAddElements={canAddElements}
207
+ sortable={sortable}
197
208
  />
198
209
  );
199
210
  }}
@@ -208,7 +219,7 @@ export function ArrayContainer<T>({
208
219
  <Draggable
209
220
  key={`array_field_${internalId}`}
210
221
  draggableId={`array_field_${internalId}`}
211
- isDragDisabled={disabled}
222
+ isDragDisabled={disabled || !sortable}
212
223
  index={index}>
213
224
  {(provided, snapshot) => (
214
225
  <ArrayContainerItem
@@ -224,7 +235,8 @@ export function ArrayContainer<T>({
224
235
  storedProps={itemCustomPropsRef.current[internalId]}
225
236
  updateItemCustomProps={updateItemCustomProps}
226
237
  addInIndex={addInIndex}
227
- includeAddButton={includeAddButton}
238
+ canAddElements={canAddElements}
239
+ sortable={sortable}
228
240
  />
229
241
  )}
230
242
  </Draggable>
@@ -233,7 +245,7 @@ export function ArrayContainer<T>({
233
245
 
234
246
  {droppableProvided.placeholder}
235
247
 
236
- {includeAddButton && (
248
+ {canAddElements && (
237
249
  <div className="my-4 justify-center text-left">
238
250
  <Button
239
251
  variant={"text"}
@@ -263,7 +275,8 @@ type ArrayContainerItemProps = {
263
275
  remove: (index: number) => void,
264
276
  copy: (index: number) => void,
265
277
  addInIndex?: (index: number) => void,
266
- includeAddButton?: boolean,
278
+ canAddElements?: boolean,
279
+ sortable: boolean,
267
280
  isDragging: boolean,
268
281
  storedProps?: object,
269
282
  updateItemCustomProps: (internalId: number, props: object) => void
@@ -278,7 +291,8 @@ export function ArrayContainerItem({
278
291
  buildEntry,
279
292
  remove,
280
293
  addInIndex,
281
- includeAddButton,
294
+ canAddElements,
295
+ sortable,
282
296
  copy,
283
297
  isDragging,
284
298
  storedProps,
@@ -311,7 +325,8 @@ export function ArrayContainerItem({
311
325
  index={index}
312
326
  provided={provided}
313
327
  addInIndex={addInIndex}
314
- includeAddButton={includeAddButton}
328
+ canAddElements={canAddElements}
329
+ sortable={sortable}
315
330
  copy={copy}/>
316
331
  </div>
317
332
  </div>;
@@ -324,7 +339,8 @@ export function ArrayItemOptions({
324
339
  index,
325
340
  provided,
326
341
  copy,
327
- includeAddButton,
342
+ canAddElements,
343
+ sortable,
328
344
  addInIndex
329
345
  }: {
330
346
  direction?: "row" | "column",
@@ -333,7 +349,8 @@ export function ArrayItemOptions({
333
349
  index: number,
334
350
  provided: any,
335
351
  copy: (index: number) => void,
336
- includeAddButton?: boolean,
352
+ sortable: boolean,
353
+ canAddElements?: boolean,
337
354
  addInIndex?: (index: number) => void
338
355
  }) {
339
356
 
@@ -349,10 +366,10 @@ export function ArrayItemOptions({
349
366
  delayDuration={400}
350
367
  open={menuOpen ? false : undefined}
351
368
  side={direction === "column" ? "left" : undefined}
352
- title="Drag to move. Click for more options">
369
+ title={!disabled && sortable ? "Drag to move. Click for more options" : undefined}>
353
370
  <IconButton
354
371
  size="small"
355
- disabled={disabled}
372
+ disabled={disabled || !canAddElements}
356
373
  onClick={(e) => {
357
374
  e.preventDefault();
358
375
  setMenuOpen(true);
@@ -360,7 +377,7 @@ export function ArrayItemOptions({
360
377
  onDragStart={(e: any) => {
361
378
  setMenuOpen(false);
362
379
  }}
363
- className={`cursor-${disabled ? "inherit" : "grab"}`}>
380
+ className={disabled || !sortable ? "cursor-inherit" : "cursor-grab"}>
364
381
  <HandleIcon/>
365
382
  </IconButton>
366
383
 
@@ -384,20 +401,20 @@ export function ArrayItemOptions({
384
401
  Copy
385
402
  </MenuItem>
386
403
 
387
- {includeAddButton && addInIndex && <MenuItem dense
388
- onClick={() => {
389
- setMenuOpen(false);
390
- addInIndex(index);
391
- }}>
404
+ {addInIndex && <MenuItem dense
405
+ onClick={() => {
406
+ setMenuOpen(false);
407
+ addInIndex(index);
408
+ }}>
392
409
  <KeyboardArrowUpIcon size={"small"}/>
393
410
  Add on top
394
411
  </MenuItem>}
395
412
 
396
- {includeAddButton && addInIndex && <MenuItem dense
397
- onClick={() => {
398
- setMenuOpen(false);
399
- addInIndex(index + 1);
400
- }}>
413
+ {addInIndex && <MenuItem dense
414
+ onClick={() => {
415
+ setMenuOpen(false);
416
+ addInIndex(index + 1);
417
+ }}>
401
418
  <KeyboardArrowDownIcon size={"small"}/>
402
419
  Add below
403
420
  </MenuItem>}
@@ -3,6 +3,7 @@ import React, { useCallback, useMemo, useState } from "react";
3
3
  import { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle } from "@firecms/ui";
4
4
  import {
5
5
  deleteEntityWithCallbacks,
6
+ useAuthController,
6
7
  useCustomizationController,
7
8
  useDataSource,
8
9
  useFireCMSContext,
@@ -34,7 +35,7 @@ export function DeleteEntityDialog<M extends Record<string, any>>({
34
35
  onMultipleEntitiesDelete,
35
36
  path
36
37
  }: DeleteEntityDialogProps<M>) {
37
-
38
+ const authController = useAuthController();
38
39
  const dataSource = useDataSource(collection);
39
40
  const customizationController = useCustomizationController();
40
41
  const snackbarController = useSnackbarController();
@@ -50,7 +51,8 @@ export function DeleteEntityDialog<M extends Record<string, any>>({
50
51
  const resolvedCollection = useMemo(() => resolveCollection<M>({
51
52
  collection,
52
53
  path,
53
- propertyConfigs: customizationController.propertyConfigs
54
+ propertyConfigs: customizationController.propertyConfigs,
55
+ authController
54
56
  }), [collection, path]);
55
57
 
56
58
  const handleCancel = useCallback(() => {
@@ -165,19 +165,21 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
165
165
 
166
166
  {!hideId && size !== "xs" && (
167
167
  <div
168
- className="w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center flex items-center justify-center gap-1"
168
+ className="w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center justify-center flex items-center gap-1"
169
169
  onClick={(event) => {
170
170
  event.stopPropagation();
171
171
  }}>
172
- {hasDraft && <Tooltip title={"Unsaved changes"} className={"inline"}>
172
+ {hasDraft && <Tooltip title={"Local unsaved changes"} className={"inline"}>
173
173
  <Chip colorScheme={"orangeDarker"} className={"p-0.5"}>
174
174
  <EditIcon size={12}/>
175
175
  </Chip>
176
176
  </Tooltip>}
177
- {entity
178
- ? entity.id
179
- : <Skeleton/>
180
- }
177
+ <span className="min-w-0 truncate text-center">
178
+ {entity
179
+ ? entity.id
180
+ : <Skeleton/>
181
+ }
182
+ </span>
181
183
  </div>
182
184
  )}
183
185
 
@@ -21,7 +21,7 @@ import { ElementResizeListener } from "./ElementResizeListener";
21
21
  import { getPropertyInPath, isReadOnly, resolveCollection } from "../../../../util";
22
22
  import { Button, CloseIcon, DialogActions, IconButton, Typography } from "@firecms/ui";
23
23
  import { PropertyFieldBinding, yupToFormErrors } from "../../../../form";
24
- import { useCustomizationController, useDataSource, useFireCMSContext } from "../../../../hooks";
24
+ import { useAuthController, useCustomizationController, useDataSource, useFireCMSContext } from "../../../../hooks";
25
25
  import { OnCellValueChangeParams } from "../../../common";
26
26
 
27
27
  interface PopupFormFieldProps<M extends Record<string, any>> {
@@ -107,6 +107,7 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
107
107
  }) {
108
108
 
109
109
  const fireCMSContext = useFireCMSContext();
110
+ const authController = useAuthController();
110
111
  const customizationController = useCustomizationController();
111
112
 
112
113
  const [savingError, setSavingError] = React.useState<any>();
@@ -121,7 +122,8 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
121
122
  path,
122
123
  values: entity?.values,
123
124
  entityId,
124
- propertyConfigs: customizationController.propertyConfigs
125
+ propertyConfigs: customizationController.propertyConfigs,
126
+ authController
125
127
  })
126
128
  : undefined;
127
129
 
@@ -273,6 +275,7 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
273
275
  formex,
274
276
  status: "existing",
275
277
  openEntityMode: "side_panel",
278
+ disabled: false,
276
279
  };
277
280
 
278
281
  const property: ResolvedProperty<any> | undefined = propertyKey && getPropertyInPath(collection?.properties ?? {} as ResolvedProperties, propertyKey as string);