@firecms/core 3.0.0-beta.11 → 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 (201) hide show
  1. package/dist/app/Scaffold.d.ts +4 -0
  2. package/dist/components/ArrayContainer.d.ts +14 -3
  3. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +2 -1
  4. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
  5. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +15 -1
  6. package/dist/components/EntityCollectionTable/index.d.ts +1 -1
  7. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +8 -0
  8. package/dist/components/EntityJsonPreview.d.ts +3 -0
  9. package/dist/components/PropertyIdCopyTooltip.d.ts +1 -1
  10. package/dist/components/SelectableTable/SelectableTable.d.ts +12 -2
  11. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +1 -1
  12. package/dist/components/UnsavedChangesDialog.d.ts +8 -0
  13. package/dist/components/VirtualTable/VirtualTableProps.d.ts +13 -0
  14. package/dist/components/common/default_entity_actions.d.ts +0 -2
  15. package/dist/components/common/index.d.ts +1 -1
  16. package/dist/components/common/useColumnsIds.d.ts +1 -0
  17. package/dist/components/common/{useDataSourceEntityCollectionTableController.d.ts → useDataSourceTableController.d.ts} +10 -2
  18. package/dist/components/common/useDebouncedCallback.d.ts +1 -0
  19. package/dist/components/common/useScrollRestoration.d.ts +14 -0
  20. package/dist/contexts/BreacrumbsContext.d.ts +8 -0
  21. package/dist/core/DefaultAppBar.d.ts +8 -2
  22. package/dist/core/EntityEditView.d.ts +36 -21
  23. package/dist/core/EntityEditViewFormActions.d.ts +2 -0
  24. package/dist/core/FireCMS.d.ts +2 -2
  25. package/dist/core/FireCMSRouter.d.ts +4 -0
  26. package/dist/core/NavigationRoutes.d.ts +0 -1
  27. package/dist/core/SideDialogs.d.ts +4 -2
  28. package/dist/core/index.d.ts +2 -1
  29. package/dist/form/EntityForm.d.ts +49 -0
  30. package/dist/form/EntityFormActions.d.ts +17 -0
  31. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  32. package/dist/form/components/FormEntry.d.ts +6 -0
  33. package/dist/form/components/FormLayout.d.ts +5 -0
  34. package/dist/form/components/index.d.ts +2 -0
  35. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  36. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  37. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  38. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  39. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  40. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  41. package/dist/form/index.d.ts +16 -16
  42. package/dist/hooks/data/save.d.ts +1 -1
  43. package/dist/hooks/data/useEntityFetch.d.ts +2 -1
  44. package/dist/hooks/useBreadcrumbsController.d.ts +26 -0
  45. package/dist/hooks/useBuildNavigationController.d.ts +4 -1
  46. package/dist/hooks/useModeController.d.ts +1 -2
  47. package/dist/index.es.js +15842 -14396
  48. package/dist/index.es.js.map +1 -1
  49. package/dist/index.umd.js +15833 -14389
  50. package/dist/index.umd.js.map +1 -1
  51. package/dist/internal/useBuildDataSource.d.ts +3 -2
  52. package/dist/internal/useBuildSideEntityController.d.ts +3 -3
  53. package/dist/internal/useUnsavedChangesDialog.d.ts +7 -9
  54. package/dist/routes/CustomCMSRoute.d.ts +4 -0
  55. package/dist/routes/FireCMSRoute.d.ts +1 -0
  56. package/dist/routes/HomePageRoute.d.ts +3 -0
  57. package/dist/types/collections.d.ts +36 -10
  58. package/dist/types/datasource.d.ts +2 -2
  59. package/dist/types/dialogs_controller.d.ts +7 -3
  60. package/dist/types/entities.d.ts +1 -1
  61. package/dist/types/entity_actions.d.ts +10 -0
  62. package/dist/types/fields.d.ts +13 -3
  63. package/dist/types/firecms.d.ts +1 -1
  64. package/dist/types/navigation.d.ts +33 -12
  65. package/dist/types/plugins.d.ts +2 -0
  66. package/dist/types/properties.d.ts +40 -4
  67. package/dist/types/side_entity_controller.d.ts +6 -1
  68. package/dist/util/builders.d.ts +1 -1
  69. package/dist/util/createFormexStub.d.ts +2 -0
  70. package/dist/util/entity_actions.d.ts +2 -0
  71. package/dist/util/entity_cache.d.ts +23 -0
  72. package/dist/util/index.d.ts +1 -0
  73. package/dist/util/navigation_from_path.d.ts +6 -1
  74. package/dist/util/navigation_utils.d.ts +13 -1
  75. package/dist/util/objects.d.ts +1 -1
  76. package/dist/util/property_utils.d.ts +2 -2
  77. package/dist/util/references.d.ts +2 -2
  78. package/dist/util/resolutions.d.ts +12 -2
  79. package/package.json +20 -21
  80. package/src/app/Scaffold.tsx +13 -3
  81. package/src/components/ArrayContainer.tsx +60 -24
  82. package/src/components/CircularProgressCenter.tsx +1 -1
  83. package/src/components/DeleteEntityDialog.tsx +5 -3
  84. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +46 -23
  85. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +10 -4
  86. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +18 -1
  87. package/src/components/EntityCollectionTable/index.tsx +1 -1
  88. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +3 -3
  89. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +10 -13
  90. package/src/components/EntityCollectionView/EntityCollectionView.tsx +105 -47
  91. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +4 -2
  92. package/src/components/EntityJsonPreview.tsx +66 -0
  93. package/src/components/EntityPreview.tsx +10 -3
  94. package/src/components/EntityView.tsx +4 -1
  95. package/src/components/NotFoundPage.tsx +2 -2
  96. package/src/components/PropertyIdCopyTooltip.tsx +2 -3
  97. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +14 -7
  98. package/src/components/SelectableTable/SelectableTable.tsx +18 -3
  99. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +7 -7
  100. package/src/components/UnsavedChangesDialog.tsx +42 -0
  101. package/src/components/VirtualTable/VirtualTable.tsx +48 -3
  102. package/src/components/VirtualTable/VirtualTableProps.tsx +15 -0
  103. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +1 -1
  104. package/src/components/common/default_entity_actions.tsx +37 -37
  105. package/src/components/common/index.ts +1 -1
  106. package/src/components/common/useColumnsIds.tsx +1 -1
  107. package/src/components/common/useDataSourceTableController.tsx +420 -0
  108. package/src/components/common/useDebouncedCallback.tsx +20 -0
  109. package/src/components/common/useScrollRestoration.tsx +68 -0
  110. package/src/contexts/BreacrumbsContext.tsx +38 -0
  111. package/src/contexts/DialogsProvider.tsx +3 -2
  112. package/src/contexts/ModeController.tsx +1 -3
  113. package/src/core/DefaultAppBar.tsx +59 -17
  114. package/src/core/DefaultDrawer.tsx +1 -1
  115. package/src/core/EntityEditView.tsx +354 -1000
  116. package/src/core/EntityEditViewFormActions.tsx +199 -0
  117. package/src/core/EntitySidePanel.tsx +85 -15
  118. package/src/core/FireCMS.tsx +20 -16
  119. package/src/core/FireCMSRouter.tsx +17 -0
  120. package/src/core/NavigationRoutes.tsx +23 -32
  121. package/src/core/SideDialogs.tsx +20 -11
  122. package/src/core/index.tsx +4 -2
  123. package/src/form/EntityForm.tsx +782 -0
  124. package/src/form/EntityFormActions.tsx +169 -0
  125. package/src/form/PropertyFieldBinding.tsx +21 -16
  126. package/src/form/components/FormEntry.tsx +22 -0
  127. package/src/form/components/FormLayout.tsx +16 -0
  128. package/src/form/components/LabelWithIcon.tsx +6 -3
  129. package/src/form/components/StorageUploadProgress.tsx +1 -1
  130. package/src/form/components/index.tsx +2 -0
  131. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +8 -5
  132. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +5 -2
  133. package/src/form/field_bindings/BlockFieldBinding.tsx +5 -3
  134. package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -0
  135. package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
  136. package/src/form/field_bindings/MapFieldBinding.tsx +14 -16
  137. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +15 -8
  138. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +3 -3
  139. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
  140. package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -1
  141. package/src/form/field_bindings/RepeatFieldBinding.tsx +13 -4
  142. package/src/form/field_bindings/SelectFieldBinding.tsx +2 -2
  143. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +11 -6
  144. package/src/form/field_bindings/SwitchFieldBinding.tsx +1 -0
  145. package/src/form/field_bindings/TextFieldBinding.tsx +1 -0
  146. package/src/form/index.tsx +16 -32
  147. package/src/form/validation.ts +12 -6
  148. package/src/hooks/data/save.ts +25 -30
  149. package/src/hooks/data/useCollectionFetch.tsx +1 -1
  150. package/src/hooks/data/useEntityFetch.tsx +5 -1
  151. package/src/hooks/useBreadcrumbsController.tsx +31 -0
  152. package/src/hooks/useBuildModeController.tsx +15 -28
  153. package/src/hooks/useBuildNavigationController.tsx +81 -24
  154. package/src/hooks/useFireCMSContext.tsx +0 -30
  155. package/src/hooks/useLargeLayout.tsx +0 -35
  156. package/src/hooks/useModeController.tsx +1 -2
  157. package/src/hooks/useResolvedNavigationFrom.tsx +4 -6
  158. package/src/internal/useBuildDataSource.ts +9 -5
  159. package/src/internal/useBuildSideDialogsController.tsx +3 -2
  160. package/src/internal/useBuildSideEntityController.tsx +135 -88
  161. package/src/internal/useUnsavedChangesDialog.tsx +126 -92
  162. package/src/preview/PropertyPreview.tsx +12 -10
  163. package/src/preview/components/UrlComponentPreview.tsx +17 -18
  164. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
  165. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
  166. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
  167. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
  168. package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
  169. package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
  170. package/src/preview/property_previews/MapPropertyPreview.tsx +3 -2
  171. package/src/routes/CustomCMSRoute.tsx +21 -0
  172. package/src/routes/FireCMSRoute.tsx +246 -0
  173. package/src/routes/HomePageRoute.tsx +17 -0
  174. package/src/types/collections.ts +45 -13
  175. package/src/types/datasource.ts +2 -1
  176. package/src/types/dialogs_controller.tsx +7 -3
  177. package/src/types/entities.ts +1 -1
  178. package/src/types/entity_actions.tsx +12 -0
  179. package/src/types/fields.tsx +18 -3
  180. package/src/types/firecms.tsx +1 -1
  181. package/src/types/navigation.ts +41 -16
  182. package/src/types/plugins.tsx +2 -0
  183. package/src/types/properties.ts +48 -4
  184. package/src/types/side_dialogs_controller.tsx +2 -0
  185. package/src/types/side_entity_controller.tsx +11 -1
  186. package/src/util/builders.ts +5 -3
  187. package/src/util/createFormexStub.tsx +62 -0
  188. package/src/util/entity_actions.ts +28 -0
  189. package/src/util/entity_cache.ts +204 -0
  190. package/src/util/index.ts +1 -0
  191. package/src/util/join_collections.ts +6 -1
  192. package/src/util/navigation_from_path.ts +18 -7
  193. package/src/util/navigation_utils.ts +115 -14
  194. package/src/util/objects.ts +9 -2
  195. package/src/util/parent_references_from_path.ts +3 -3
  196. package/src/util/property_utils.tsx +7 -3
  197. package/src/util/references.ts +8 -6
  198. package/src/util/resolutions.ts +41 -12
  199. package/src/util/useStorageUploadController.tsx +60 -23
  200. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +0 -236
  201. /package/src/util/{common.tsx → common.ts} +0 -0
@@ -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 { EntityCollection, EntitySidePanelProps, NavigationController, SideDialogsController, SideEntityController } from "../types";
2
- export declare function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean): 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>[];
@@ -1,14 +1,12 @@
1
- import React from "react";
1
+ /**
2
+ * Custom hook to handle navigation blocking when there are unsaved changes.
3
+ *
4
+ * @param when - Indicates whether to block navigation.
5
+ * @param onSuccess - Callback invoked when navigation is confirmed.
6
+ * @returns An object containing the state of navigation blocking and handlers.
7
+ */
2
8
  export declare function useNavigationUnsavedChangesDialog(when: boolean, onSuccess: () => void): {
3
9
  navigationWasBlocked: boolean;
4
10
  handleCancel: () => void;
5
11
  handleOk: () => void;
6
12
  };
7
- export interface UnsavedChangesDialogProps {
8
- open: boolean;
9
- body?: React.ReactNode;
10
- title?: string;
11
- handleOk: () => void;
12
- handleCancel: () => void;
13
- }
14
- export declare function UnsavedChangesDialog({ open, handleOk, handleCancel, body, title }: UnsavedChangesDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { CMSView } from "../types";
2
+ export declare function CustomCMSRoute({ cmsView }: {
3
+ cmsView: CMSView;
4
+ }): import("react").ReactNode;
@@ -0,0 +1 @@
1
+ export declare function FireCMSRoute(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ export declare function HomePageRoute({ children }: {
2
+ children: React.ReactNode;
3
+ }): import("react").ReactNode;
@@ -72,6 +72,10 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
72
72
  * Set of properties that compose an entity
73
73
  */
74
74
  properties: PropertiesOrBuilders<M>;
75
+ /**
76
+ * Default preview properties displayed when this collection is referenced to.
77
+ */
78
+ previewProperties?: string[];
75
79
  /**
76
80
  * Title property of the entity. This is the property that will be used
77
81
  * as the title in entity related views and references.
@@ -79,11 +83,10 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
79
83
  */
80
84
  titleProperty?: keyof M;
81
85
  /**
82
- * Can this collection be edited by the end user.
83
- * Defaults to `true`.
84
- * Keep in mind that you can also set this prop to individual properties.
86
+ * When editing an entity, you can choose to open the entity in a side dialog
87
+ * or in a full screen dialog. Defaults to `full_screen`.
85
88
  */
86
- editable?: boolean;
89
+ openEntityMode?: "side_panel" | "full_screen";
87
90
  /**
88
91
  * Order in which the properties are displayed.
89
92
  * If you are specifying your collection as code, the order is the same as the
@@ -105,7 +108,7 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
105
108
  * `hidden` in the property definition,will be ignored.
106
109
  * `propertiesOrder` has precedence over `hidden`.
107
110
  */
108
- propertiesOrder?: (Extract<keyof M, string> | `subcollection:${string}`)[];
111
+ propertiesOrder?: (Extract<keyof M, string> | string | `subcollection:${string}` | "collectionGroupParent")[];
109
112
  /**
110
113
  * If enabled, content is loaded in batches. If `false` all entities in the
111
114
  * collection are loaded.
@@ -186,12 +189,14 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
186
189
  * Force a filter in this view. If applied, the rest of the filters will
187
190
  * be disabled. Filters applied with this prop cannot be changed.
188
191
  * e.g. `forceFilter: { age: [">=", 18] }`
192
+ * e.g. `forceFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
189
193
  */
190
194
  forceFilter?: FilterValues<Extract<keyof M, string>>;
191
195
  /**
192
196
  * Initial filters applied to the collection this collection is related to.
193
197
  * Defaults to none. Filters applied with this prop can be changed.
194
198
  * e.g. `initialFilter: { age: [">=", 18] }`
199
+ * e.g. `initialFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
195
200
  */
196
201
  initialFilter?: FilterValues<Extract<keyof M, string>>;
197
202
  /**
@@ -272,9 +277,22 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
272
277
  */
273
278
  sideDialogWidth?: number | string;
274
279
  /**
275
- * Default preview properties displayed when this collection is referenced to.
280
+ * Can this collection configuration be edited by the end user.
281
+ * Defaults to `true`.
282
+ * Keep in mind that you can also set this prop to individual properties.
283
+ * This prop has only effect if you are using the collection editor.
276
284
  */
277
- previewProperties?: string[];
285
+ editable?: boolean;
286
+ /**
287
+ * If set to true, the default values of the properties will be applied
288
+ * to the entity every time the entity is updated (not only when created).
289
+ * Defaults to false.
290
+ */
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;
278
296
  }
279
297
  /**
280
298
  * Parameter passed to the `Actions` prop in the collection configuration.
@@ -420,10 +438,12 @@ export type EntityCustomView<M extends Record<string, any> = any> = {
420
438
  */
421
439
  name: string;
422
440
  /**
423
- * If set to true, the actions of the entity will be included in the
424
- * bottom of the panel (save buttons, delete buttons, etc.)
441
+ * If set to true, the actions of the entity (save, discard,delete) will be
442
+ * included in the view. By default the actions are located in the right or bottom,
443
+ * based on the screen size. You can force the actions to be located at the bottom
444
+ * by setting this prop to "bottom".
425
445
  */
426
- includeActions?: boolean;
446
+ includeActions?: boolean | "bottom";
427
447
  /**
428
448
  * Builder for rendering the custom view
429
449
  */
@@ -485,6 +505,12 @@ export type EntityTableController<M extends Record<string, any> = any> = {
485
505
  clearFilter?: () => void;
486
506
  itemCount?: number;
487
507
  setItemCount?: (itemCount: number) => void;
508
+ initialScroll?: number;
509
+ onScroll?: (props: {
510
+ scrollDirection: "forward" | "backward";
511
+ scrollOffset: number;
512
+ scrollUpdateWasRequested: boolean;
513
+ }) => void;
488
514
  paginationEnabled?: boolean;
489
515
  pageSize?: number;
490
516
  checkFilterCombination?: (filterValues: FilterValues<any>, sortBy?: [string, "asc" | "desc"]) => boolean;
@@ -8,13 +8,13 @@ import { FireCMSContext } from "./firecms_context";
8
8
  export interface FetchEntityProps<M extends Record<string, any> = any> {
9
9
  path: string;
10
10
  entityId: string;
11
+ databaseId?: string;
11
12
  collection?: EntityCollection<M, any>;
12
13
  }
13
14
  /**
14
15
  * @group Datasource
15
16
  */
16
17
  export type ListenEntityProps<M extends Record<string, any> = any> = FetchEntityProps<M> & {
17
- databaseId?: string;
18
18
  onUpdate: (entity: Entity<M>) => void;
19
19
  onError?: (error: Error) => void;
20
20
  };
@@ -99,7 +99,7 @@ export interface DataSource {
99
99
  * @param entityId
100
100
  * @param collection
101
101
  */
102
- fetchEntity<M extends Record<string, any> = any>({ path, entityId, collection }: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
102
+ fetchEntity<M extends Record<string, any> = any>({ path, entityId, databaseId, collection }: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
103
103
  /**
104
104
  * Get realtime updates on one entity.
105
105
  * @param path
@@ -12,7 +12,7 @@ export interface DialogsController {
12
12
  * Open a dialog
13
13
  * @param props
14
14
  */
15
- open: (props: DialogControllerEntryProps) => {
15
+ open: <T extends object = object>(props: DialogControllerEntryProps<T>) => {
16
16
  closeDialog: () => void;
17
17
  };
18
18
  }
@@ -20,7 +20,7 @@ export interface DialogsController {
20
20
  * Props used to open a side dialog
21
21
  * @group Hooks and utilities
22
22
  */
23
- export interface DialogControllerEntryProps {
23
+ export interface DialogControllerEntryProps<T extends object = object> {
24
24
  key: string;
25
25
  /**
26
26
  * The component type that will be rendered
@@ -28,5 +28,9 @@ export interface DialogControllerEntryProps {
28
28
  Component: React.ComponentType<{
29
29
  open: boolean;
30
30
  closeDialog: () => void;
31
- }>;
31
+ } & T>;
32
+ /**
33
+ * Props to pass to the dialog component
34
+ */
35
+ props?: T;
32
36
  }
@@ -7,7 +7,7 @@ export type EntityStatus = "new" | "existing" | "copy";
7
7
  * Representation of an entity fetched from the datasource
8
8
  * @group Models
9
9
  */
10
- export interface Entity<M extends object> {
10
+ export interface Entity<M extends object = any> {
11
11
  /**
12
12
  * ID of the entity
13
13
  */
@@ -13,6 +13,15 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
13
13
  * Title of the action
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * Key of the action. You only need to provide this if you want to
18
+ * override the default actions.
19
+ * The default actions are:
20
+ * - edit
21
+ * - delete
22
+ * - copy
23
+ */
24
+ key?: string;
16
25
  /**
17
26
  * Icon of the action
18
27
  */
@@ -46,4 +55,5 @@ export type EntityActionClickProps<M extends object, USER extends User = User> =
46
55
  * If this actions is being called from a side dialog
47
56
  */
48
57
  sideEntityController?: SideEntityController;
58
+ openEntityMode: "side_panel" | "full_screen";
49
59
  };
@@ -1,6 +1,7 @@
1
1
  import { CMSType, Property, PropertyOrBuilder } from "./properties";
2
2
  import { ResolvedEntityCollection, ResolvedProperty } from "./resolved_entities";
3
3
  import { FormexController } from "@firecms/formex";
4
+ import { Entity } from "./entities";
4
5
  /**
5
6
  * When building a custom field you need to create a React component that takes
6
7
  * this interface as props.
@@ -67,7 +68,8 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
67
68
  */
68
69
  partOfArray?: boolean;
69
70
  /**
70
- * Should this field render with the minimal amount of UI elements
71
+ * Display the child properties directly, without being wrapped in an
72
+ * extendable panel. Note that this will also hide the title of this property.
71
73
  */
72
74
  minimalistView?: boolean;
73
75
  /**
@@ -131,10 +133,17 @@ export interface FormContext<M extends Record<string, any> = any> {
131
133
  * Path this entity is located at
132
134
  */
133
135
  path?: string;
136
+ status: "new" | "existing" | "copy";
137
+ entity?: Entity<M>;
138
+ savingError?: Error;
139
+ openEntityMode: "side_panel" | "full_screen";
134
140
  /**
135
- * 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
136
144
  */
137
145
  formex: FormexController<M>;
146
+ disabled: boolean;
138
147
  }
139
148
  /**
140
149
  * In case you need to render a field bound to a Property inside your
@@ -170,7 +179,8 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
170
179
  */
171
180
  partOfArray?: boolean;
172
181
  /**
173
- * Is this field part of a block (oneOf array)
182
+ * Display the child properties directly, without being wrapped in an
183
+ * extendable panel. Note that this will also hide the title of this property.
174
184
  */
175
185
  minimalistView?: boolean;
176
186
  /**
@@ -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
@@ -4,6 +4,7 @@ import { EntityReference } from "./entities";
4
4
  /**
5
5
  * Controller that includes the resolved navigation and utility methods and
6
6
  * attributes.
7
+ * This controller holds the state of the navigation including the collections.
7
8
  * @group Models
8
9
  */
9
10
  export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
@@ -48,6 +49,10 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
48
49
  * The collection is resolved from the given path or alias.
49
50
  */
50
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;
51
56
  /**
52
57
  * Get the collection configuration from its parent ids.
53
58
  */
@@ -57,11 +62,13 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
57
62
  */
58
63
  getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
59
64
  /**
60
- * Default path under the navigation routes of the CMS will be created
65
+ * Default path under the navigation routes of the CMS will be created.
66
+ * Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
61
67
  */
62
68
  basePath: string;
63
69
  /**
64
- * Default path under the collection routes of the CMS will be created
70
+ * Default path under the collection routes of the CMS will be created.
71
+ * It defaults to '/c'
65
72
  */
66
73
  baseCollectionPath: string;
67
74
  /**
@@ -72,14 +79,6 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
72
79
  * @param cmsPath
73
80
  */
74
81
  urlPathToDataPath: (cmsPath: string) => string;
75
- /**
76
- * Convert a collection or entity path to a URL path
77
- * @param path
78
- */
79
- buildCMSUrlPath: (path: string) => string;
80
- buildUrlEditCollectionPath: (props: {
81
- path: string;
82
- }) => string;
83
82
  /**
84
83
  * Base url path for the home screen
85
84
  */
@@ -97,10 +96,11 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
97
96
  */
98
97
  buildUrlCollectionPath: (path: string) => string;
99
98
  /**
100
- * Turn a path with aliases into a resolved path
99
+ * Turn a path with collection ids into a resolved path.
100
+ * The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
101
101
  * @param pathWithAliases
102
102
  */
103
- resolveAliasesFrom: (pathWithAliases: string) => string;
103
+ resolveIdsFrom: (pathWithAliases: string) => string;
104
104
  /**
105
105
  * Call this method to recalculate the navigation
106
106
  */
@@ -120,6 +120,27 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
120
120
  * @param ids
121
121
  */
122
122
  convertIdsToPaths: (ids: string[]) => string[];
123
+ /**
124
+ * A function to navigate to a specified route or URL.
125
+ *
126
+ * @param {string} to - The target route or URL to navigate to.
127
+ * @param {NavigateOptions} [options] - Optional configuration settings for navigation, such as replace behavior or state data.
128
+ */
129
+ navigate: (to: string, options?: NavigateOptions) => void;
130
+ };
131
+ export interface NavigateOptions {
132
+ replace?: boolean;
133
+ state?: any;
134
+ preventScrollReset?: boolean;
135
+ relative?: "route" | "path";
136
+ flushSync?: boolean;
137
+ viewTransition?: boolean;
138
+ }
139
+ export type NavigationBlocker = {
140
+ updateBlockListener: (path: string, block: boolean, basePath?: string) => () => void;
141
+ isBlocked: (path: string) => boolean;
142
+ proceed?: () => void;
143
+ reset?: () => void;
123
144
  };
124
145
  /**
125
146
  * Custom additional views created by the developer, added to the main
@@ -159,9 +159,11 @@ 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;
166
+ openEntityMode: "side_panel" | "full_screen";
165
167
  }
166
168
  export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
167
169
  fieldConfigId: 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
  */
@@ -103,6 +104,11 @@ export interface BaseProperty<T extends CMSType, CustomProps = any> {
103
104
  * save the new config. The saved config will then become the source of truth.
104
105
  */
105
106
  editable?: boolean;
107
+ /**
108
+ * A number between 0 and 100 that indicates the width of the field in the form view.
109
+ * It defaults to 100, but you can set it to 50 to have two fields in the same row.
110
+ */
111
+ widthPercentage?: number;
106
112
  }
107
113
  /**
108
114
  * @group Entity properties
@@ -200,6 +206,10 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
200
206
  * Entity ID
201
207
  */
202
208
  entityId?: string;
209
+ /**
210
+ * Controller to manage authentication
211
+ */
212
+ authController: AuthController;
203
213
  };
204
214
  /**
205
215
  * You can use this type to define a property dynamically, based
@@ -207,15 +217,15 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
207
217
  * current value of the property, as well as the path and entity ID.
208
218
  * @group Entity properties
209
219
  */
210
- 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;
211
221
  /**
212
222
  * @group Entity properties
213
223
  */
214
- export type PropertyOrBuilder<T extends CMSType = CMSType, M extends Record<string, any> = Record<string, any>> = Property<T> | PropertyBuilder<T, M>;
224
+ export type PropertyOrBuilder<T extends CMSType = CMSType, M extends Record<string, any> = any> = Property<T> | PropertyBuilder<T, M>;
215
225
  /**
216
226
  * @group Entity properties
217
227
  */
218
- export type PropertiesOrBuilders<M extends Record<string, any> = Record<string, any>> = {
228
+ export type PropertiesOrBuilders<M extends Record<string, any> = any> = {
219
229
  [k in keyof M]: PropertyOrBuilder<M[k], M>;
220
230
  };
221
231
  /**
@@ -278,7 +288,7 @@ export interface StringProperty extends BaseProperty<string> {
278
288
  enumValues?: EnumValues;
279
289
  /**
280
290
  * You can specify a `Storage` configuration. It is used to
281
- * indicate that this string refers to a path in Google Cloud Storage.
291
+ * indicate that this string refers to a path in your storage provider.
282
292
  */
283
293
  storage?: StorageConfig;
284
294
  /**
@@ -361,6 +371,21 @@ export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSTyp
361
371
  * Should the field be initially expanded. Defaults to `true`
362
372
  */
363
373
  expanded?: boolean;
374
+ /**
375
+ * Display the child properties directly, without being wrapped in an
376
+ * extendable panel.
377
+ */
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;
364
389
  }
365
390
  /**
366
391
  * @group Entity properties
@@ -400,6 +425,11 @@ export interface MapProperty<T extends Record<string, CMSType> = Record<string,
400
425
  * view
401
426
  */
402
427
  spreadChildren?: boolean;
428
+ /**
429
+ * Display the child properties directly, without being wrapped in an
430
+ * extendable panel. Note that this will also hide the title of this property.
431
+ */
432
+ minimalistView?: boolean;
403
433
  /**
404
434
  * Should the field be initially expanded. Defaults to `true`
405
435
  */
@@ -623,6 +653,12 @@ export type StorageConfig = {
623
653
  * Define maximal file size in bytes
624
654
  */
625
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;
626
662
  /**
627
663
  * Postprocess the saved value (storage path or URL)
628
664
  * after it has been resolved.
@@ -1,6 +1,7 @@
1
1
  import { EntityCollection } from "./collections";
2
2
  import { ResolvedEntityCollection } from "./resolved_entities";
3
3
  import { Entity } from "./entities";
4
+ import { EntityFormProps } from "../form";
4
5
  /**
5
6
  * Props used to open a side dialog
6
7
  * @group Hooks and utilities
@@ -22,7 +23,7 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
22
23
  * Open the entity with a selected sub-collection view. If the panel for this
23
24
  * entity was already open, it is replaced.
24
25
  */
25
- selectedSubPath?: string;
26
+ selectedTab?: string;
26
27
  /**
27
28
  * Use this prop to override the width of the form view.
28
29
  * e.g. "600px"
@@ -55,6 +56,10 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
55
56
  * Should this panel close when saving
56
57
  */
57
58
  closeOnSave?: boolean;
59
+ /**
60
+ * Override some form properties
61
+ */
62
+ formProps?: Partial<EntityFormProps<M>>;
58
63
  }
59
64
  /**
60
65
  * Controller to open the side dialog displaying entity forms
@@ -12,7 +12,7 @@ export declare function buildCollection<M extends Record<string, any> = any, USE
12
12
  * @param property
13
13
  * @group Builder
14
14
  */
15
- export declare function buildProperty<T extends CMSType = CMSType, P extends PropertyOrBuilder<T> = PropertyOrBuilder<T>, M extends Record<string, any> = Record<string, any>>(property: P): P extends StringProperty ? StringProperty : P extends NumberProperty ? NumberProperty : P extends BooleanProperty ? BooleanProperty : P extends DateProperty ? DateProperty : P extends GeopointProperty ? GeopointProperty : P extends ReferenceProperty ? ReferenceProperty : P extends ArrayProperty ? ArrayProperty : P extends MapProperty ? MapProperty : P extends PropertyBuilder<T, M> ? PropertyBuilder<T, M> : never;
15
+ export declare function buildProperty<T extends CMSType = CMSType, P extends PropertyOrBuilder<T> = PropertyOrBuilder<T>, M extends Record<string, any> = any>(property: P): P extends StringProperty ? StringProperty : P extends NumberProperty ? NumberProperty : P extends BooleanProperty ? BooleanProperty : P extends DateProperty ? DateProperty : P extends GeopointProperty ? GeopointProperty : P extends ReferenceProperty ? ReferenceProperty : P extends ArrayProperty ? ArrayProperty : P extends MapProperty ? MapProperty : P extends PropertyBuilder<T, M> ? PropertyBuilder<T, M> : never;
16
16
  /**
17
17
  * Identity function we use to defeat the type system of Typescript and preserve
18
18
  * the properties keys.
@@ -0,0 +1,2 @@
1
+ import { FormexController } from "@firecms/formex";
2
+ export declare function createFormexStub<T extends object>(values: T): FormexController<T>;
@@ -0,0 +1,2 @@
1
+ import { EntityAction } from "../types";
2
+ export declare function mergeEntityActions(currentActions: EntityAction[], newActions: EntityAction[]): EntityAction[];
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Saves data to the in-memory cache and persists it individually in `localStorage`.
3
+ * @param path - The unique path/key for the data.
4
+ * @param data - The data to cache and persist.
5
+ */
6
+ export declare function saveEntityToCache(path: string, data: object): void;
7
+ /**
8
+ * Retrieves an entity from the in-memory cache or `localStorage`.
9
+ * If the entity is not in the cache but exists in `localStorage`, it loads it into the cache.
10
+ * @param path - The unique path/key for the entity.
11
+ * @returns The cached entity or `undefined` if not found.
12
+ */
13
+ export declare function getEntityFromCache(path: string): object | undefined;
14
+ export declare function hasEntityInCache(path: string): boolean;
15
+ /**
16
+ * Removes an entity from both the in-memory cache and `localStorage`.
17
+ * @param path - The unique path/key for the entity to remove.
18
+ */
19
+ export declare function removeEntityFromCache(path: string): void;
20
+ /**
21
+ * Clears the entire in-memory cache and removes all related entities from `localStorage`.
22
+ */
23
+ export declare function clearEntityCache(): void;
@@ -7,6 +7,7 @@ export * from "./objects";
7
7
  export * from "./paths";
8
8
  export * from "./regexp";
9
9
  export * from "./navigation_utils";
10
+ export * from "./entity_actions";
10
11
  export * from "./useDebouncedCallback";
11
12
  export * from "./property_utils";
12
13
  export * from "./resolutions";
@@ -4,19 +4,24 @@ export interface NavigationViewEntityInternal<M extends Record<string, any>> {
4
4
  type: "entity";
5
5
  entityId: string;
6
6
  path: string;
7
+ fullPath: string;
7
8
  parentCollection: EntityCollection<M>;
8
9
  }
9
10
  export interface NavigationViewCollectionInternal<M extends Record<string, any>> {
10
11
  type: "collection";
12
+ id: string;
11
13
  path: string;
14
+ fullPath: string;
12
15
  collection: EntityCollection<M>;
13
16
  }
14
17
  export interface NavigationViewEntityCustomInternal<M extends Record<string, any>> {
15
18
  type: "custom_view";
16
19
  path: string;
20
+ fullPath: string;
21
+ entityId: string;
17
22
  view: EntityCustomView<M>;
18
23
  }
19
- export declare function getNavigationEntriesFromPathInternal(props: {
24
+ export declare function getNavigationEntriesFromPath(props: {
20
25
  path: string;
21
26
  collections: EntityCollection[] | undefined;
22
27
  currentFullPath?: string;
@@ -1,4 +1,4 @@
1
- import { EntityCollection } from "../types";
1
+ import { EntityCollection, NavigationController, SideEntityController } from "../types";
2
2
  export declare function removeInitialAndTrailingSlashes(s: string): string;
3
3
  export declare function removeInitialSlash(s: string): string;
4
4
  export declare function removeTrailingSlash(s: string): string;
@@ -18,3 +18,15 @@ 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, fullIdPath, selectedTab, sideEntityController, onClose, navigation }: {
22
+ openEntityMode: "side_panel" | "full_screen";
23
+ collection?: EntityCollection;
24
+ entityId?: string;
25
+ selectedTab?: string;
26
+ copy?: boolean;
27
+ path: string;
28
+ fullIdPath?: string;
29
+ sideEntityController: SideEntityController;
30
+ onClose?: () => void;
31
+ navigation: NavigationController;
32
+ }): void;
@@ -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;