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

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 (267) hide show
  1. package/dist/components/ArrayContainer.d.ts +22 -6
  2. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +2 -1
  3. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
  4. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +17 -3
  5. package/dist/components/EntityCollectionTable/index.d.ts +1 -1
  6. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +6 -3
  7. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +4 -0
  8. package/dist/components/PropertyIdCopyTooltip.d.ts +1 -1
  9. package/dist/components/SelectableTable/SelectableTable.d.ts +12 -2
  10. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +1 -1
  11. package/dist/components/UnsavedChangesDialog.d.ts +8 -0
  12. package/dist/components/VirtualTable/VirtualTableProps.d.ts +13 -0
  13. package/dist/components/common/default_entity_actions.d.ts +0 -2
  14. package/dist/components/common/index.d.ts +1 -1
  15. package/dist/components/common/useColumnsIds.d.ts +1 -0
  16. package/dist/components/common/{useDataSourceEntityCollectionTableController.d.ts → useDataSourceTableController.d.ts} +10 -2
  17. package/dist/components/common/useDebouncedCallback.d.ts +1 -0
  18. package/dist/components/common/useScrollRestoration.d.ts +14 -0
  19. package/dist/contexts/BreacrumbsContext.d.ts +8 -0
  20. package/dist/core/EntityEditView.d.ts +30 -22
  21. package/dist/core/EntityEditViewFormActions.d.ts +2 -0
  22. package/dist/core/FireCMS.d.ts +1 -1
  23. package/dist/core/FireCMSRouter.d.ts +4 -0
  24. package/dist/core/NavigationRoutes.d.ts +0 -1
  25. package/dist/core/SideDialogs.d.ts +4 -2
  26. package/dist/core/index.d.ts +2 -1
  27. package/dist/form/EntityForm.d.ts +45 -0
  28. package/dist/form/EntityFormActions.d.ts +17 -0
  29. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  30. package/dist/form/components/FormEntry.d.ts +6 -0
  31. package/dist/form/components/FormLayout.d.ts +5 -0
  32. package/dist/form/components/index.d.ts +2 -1
  33. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  34. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  35. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  36. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  37. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
  38. package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -2
  39. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  40. package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -2
  41. package/dist/form/index.d.ts +16 -16
  42. package/dist/hooks/data/delete.d.ts +4 -4
  43. package/dist/hooks/data/save.d.ts +3 -3
  44. package/dist/hooks/data/useCollectionFetch.d.ts +1 -1
  45. package/dist/hooks/data/useEntityFetch.d.ts +4 -3
  46. package/dist/hooks/useAuthController.d.ts +1 -1
  47. package/dist/hooks/useBreadcrumbsController.d.ts +26 -0
  48. package/dist/hooks/useBuildNavigationController.d.ts +7 -4
  49. package/dist/hooks/useFireCMSContext.d.ts +1 -1
  50. package/dist/hooks/useModeController.d.ts +1 -2
  51. package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
  52. package/dist/hooks/useValidateAuthenticator.d.ts +3 -3
  53. package/dist/index.es.js +17032 -12909
  54. package/dist/index.es.js.map +1 -1
  55. package/dist/index.umd.js +17019 -12898
  56. package/dist/index.umd.js.map +1 -1
  57. package/dist/internal/useBuildSideEntityController.d.ts +2 -2
  58. package/dist/internal/useUnsavedChangesDialog.d.ts +7 -9
  59. package/dist/preview/PropertyPreviewProps.d.ts +1 -1
  60. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  61. package/dist/preview/util.d.ts +3 -3
  62. package/dist/routes/CustomCMSRoute.d.ts +4 -0
  63. package/dist/routes/FireCMSRoute.d.ts +1 -0
  64. package/dist/routes/HomePageRoute.d.ts +3 -0
  65. package/dist/types/auth.d.ts +7 -9
  66. package/dist/types/collections.d.ts +44 -23
  67. package/dist/types/datasource.d.ts +2 -6
  68. package/dist/types/dialogs_controller.d.ts +7 -3
  69. package/dist/types/entities.d.ts +1 -1
  70. package/dist/types/entity_actions.d.ts +14 -4
  71. package/dist/types/entity_callbacks.d.ts +16 -16
  72. package/dist/types/export_import.d.ts +4 -4
  73. package/dist/types/fields.d.ts +27 -4
  74. package/dist/types/firecms.d.ts +2 -2
  75. package/dist/types/firecms_context.d.ts +1 -1
  76. package/dist/types/navigation.d.ts +29 -12
  77. package/dist/types/permissions.d.ts +4 -4
  78. package/dist/types/plugins.d.ts +9 -8
  79. package/dist/types/properties.d.ts +18 -3
  80. package/dist/types/property_config.d.ts +0 -2
  81. package/dist/types/side_entity_controller.d.ts +6 -1
  82. package/dist/types/user.d.ts +1 -0
  83. package/dist/util/builders.d.ts +3 -3
  84. package/dist/util/entities.d.ts +1 -1
  85. package/dist/util/entity_actions.d.ts +2 -0
  86. package/dist/util/entity_cache.d.ts +23 -0
  87. package/dist/util/icon_synonyms.d.ts +0 -1
  88. package/dist/util/icons.d.ts +3 -1
  89. package/dist/util/index.d.ts +1 -0
  90. package/dist/util/navigation_from_path.d.ts +6 -1
  91. package/dist/util/navigation_utils.d.ts +12 -1
  92. package/dist/util/objects.d.ts +1 -0
  93. package/dist/util/permissions.d.ts +4 -4
  94. package/dist/util/property_utils.d.ts +2 -2
  95. package/dist/util/resolutions.d.ts +12 -7
  96. package/package.json +129 -125
  97. package/src/app/Scaffold.tsx +4 -4
  98. package/src/components/ArrayContainer.tsx +115 -34
  99. package/src/components/CircularProgressCenter.tsx +1 -1
  100. package/src/components/ConfirmationDialog.tsx +2 -2
  101. package/src/components/DeleteEntityDialog.tsx +10 -19
  102. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +44 -20
  103. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +23 -17
  104. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +20 -3
  105. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +6 -4
  106. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +8 -9
  107. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -11
  108. package/src/components/EntityCollectionTable/index.tsx +1 -1
  109. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +3 -3
  110. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +5 -5
  111. package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +2 -2
  112. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +77 -73
  113. package/src/components/EntityCollectionView/EntityCollectionView.tsx +90 -49
  114. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +4 -2
  115. package/src/components/EntityCollectionView/useSelectionController.tsx +5 -4
  116. package/src/components/EntityPreview.tsx +39 -30
  117. package/src/components/EntityView.tsx +5 -5
  118. package/src/components/ErrorView.tsx +3 -3
  119. package/src/components/HomePage/DefaultHomePage.tsx +1 -0
  120. package/src/components/HomePage/FavouritesView.tsx +6 -11
  121. package/src/components/HomePage/NavigationCard.tsx +1 -1
  122. package/src/components/HomePage/NavigationCardBinding.tsx +4 -9
  123. package/src/components/HomePage/NavigationGroup.tsx +1 -1
  124. package/src/components/NotFoundPage.tsx +2 -2
  125. package/src/components/PropertyConfigBadge.tsx +1 -1
  126. package/src/components/PropertyIdCopyTooltip.tsx +3 -4
  127. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +13 -8
  128. package/src/components/SelectableTable/SelectableTable.tsx +20 -5
  129. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +4 -2
  130. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +10 -8
  131. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +7 -5
  132. package/src/components/UnsavedChangesDialog.tsx +42 -0
  133. package/src/components/VirtualTable/VirtualTable.tsx +19 -2
  134. package/src/components/VirtualTable/VirtualTableHeader.tsx +8 -8
  135. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +1 -1
  136. package/src/components/VirtualTable/VirtualTableProps.tsx +15 -0
  137. package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
  138. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
  139. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +1 -1
  140. package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +2 -0
  141. package/src/components/common/default_entity_actions.tsx +26 -37
  142. package/src/components/common/index.ts +1 -1
  143. package/src/components/common/useColumnsIds.tsx +1 -1
  144. package/src/components/common/useDataSourceTableController.tsx +420 -0
  145. package/src/components/common/useDebouncedCallback.tsx +20 -0
  146. package/src/components/common/useScrollRestoration.tsx +68 -0
  147. package/src/contexts/BreacrumbsContext.tsx +38 -0
  148. package/src/contexts/DialogsProvider.tsx +3 -2
  149. package/src/contexts/ModeController.tsx +1 -3
  150. package/src/contexts/SnackbarProvider.tsx +2 -0
  151. package/src/core/DefaultAppBar.tsx +56 -25
  152. package/src/core/DefaultDrawer.tsx +11 -9
  153. package/src/core/DrawerNavigationItem.tsx +4 -4
  154. package/src/core/EntityEditView.tsx +282 -1006
  155. package/src/core/EntityEditViewFormActions.tsx +199 -0
  156. package/src/core/EntitySidePanel.tsx +85 -15
  157. package/src/core/FireCMS.tsx +12 -9
  158. package/src/core/FireCMSRouter.tsx +17 -0
  159. package/src/core/NavigationRoutes.tsx +23 -32
  160. package/src/core/SideDialogs.tsx +21 -12
  161. package/src/core/field_configs.tsx +4 -4
  162. package/src/core/index.tsx +4 -2
  163. package/src/form/EntityForm.tsx +774 -0
  164. package/src/form/EntityFormActions.tsx +169 -0
  165. package/src/form/PropertyFieldBinding.tsx +39 -30
  166. package/src/form/components/CustomIdField.tsx +2 -0
  167. package/src/form/components/FormEntry.tsx +22 -0
  168. package/src/form/components/FormLayout.tsx +16 -0
  169. package/src/form/components/LabelWithIcon.tsx +6 -3
  170. package/src/form/components/StorageItemPreview.tsx +3 -3
  171. package/src/form/components/StorageUploadProgress.tsx +1 -1
  172. package/src/form/components/index.tsx +2 -1
  173. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +7 -6
  174. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +20 -12
  175. package/src/form/field_bindings/BlockFieldBinding.tsx +45 -25
  176. package/src/form/field_bindings/DateTimeFieldBinding.tsx +2 -1
  177. package/src/form/field_bindings/KeyValueFieldBinding.tsx +10 -7
  178. package/src/form/field_bindings/MapFieldBinding.tsx +69 -52
  179. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +9 -6
  180. package/src/form/field_bindings/MultiSelectFieldBinding.tsx +1 -1
  181. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
  182. package/src/form/field_bindings/ReferenceFieldBinding.tsx +5 -5
  183. package/src/form/field_bindings/RepeatFieldBinding.tsx +30 -22
  184. package/src/form/field_bindings/SelectFieldBinding.tsx +6 -5
  185. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +7 -5
  186. package/src/form/field_bindings/SwitchFieldBinding.tsx +26 -25
  187. package/src/form/field_bindings/TextFieldBinding.tsx +4 -3
  188. package/src/form/index.tsx +16 -32
  189. package/src/form/validation.ts +12 -6
  190. package/src/hooks/data/delete.ts +4 -4
  191. package/src/hooks/data/save.ts +8 -9
  192. package/src/hooks/data/useCollectionFetch.tsx +3 -3
  193. package/src/hooks/data/useEntityFetch.tsx +10 -6
  194. package/src/hooks/useAuthController.tsx +1 -1
  195. package/src/hooks/useBreadcrumbsController.tsx +31 -0
  196. package/src/hooks/useBuildModeController.tsx +15 -28
  197. package/src/hooks/useBuildNavigationController.tsx +74 -29
  198. package/src/hooks/useFireCMSContext.tsx +5 -5
  199. package/src/hooks/useLargeLayout.tsx +0 -35
  200. package/src/hooks/useModeController.tsx +1 -2
  201. package/src/hooks/useResolvedNavigationFrom.tsx +9 -11
  202. package/src/hooks/useValidateAuthenticator.tsx +3 -3
  203. package/src/internal/useBuildDataSource.ts +1 -1
  204. package/src/internal/useBuildSideDialogsController.tsx +3 -2
  205. package/src/internal/useBuildSideEntityController.tsx +124 -83
  206. package/src/internal/useUnsavedChangesDialog.tsx +127 -93
  207. package/src/preview/PropertyPreview.tsx +11 -11
  208. package/src/preview/PropertyPreviewProps.tsx +1 -1
  209. package/src/preview/components/BooleanPreview.tsx +1 -1
  210. package/src/preview/components/EmptyValue.tsx +1 -1
  211. package/src/preview/components/EnumValuesChip.tsx +1 -1
  212. package/src/preview/components/ImagePreview.tsx +5 -6
  213. package/src/preview/components/UrlComponentPreview.tsx +20 -21
  214. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  215. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -2
  216. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +2 -2
  217. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +1 -1
  218. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
  219. package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -2
  220. package/src/preview/property_previews/MapPropertyPreview.tsx +7 -6
  221. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +12 -12
  222. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  223. package/src/preview/util.ts +10 -10
  224. package/src/routes/CustomCMSRoute.tsx +21 -0
  225. package/src/routes/FireCMSRoute.tsx +235 -0
  226. package/src/routes/HomePageRoute.tsx +17 -0
  227. package/src/types/auth.tsx +8 -12
  228. package/src/types/collections.ts +52 -26
  229. package/src/types/datasource.ts +2 -6
  230. package/src/types/dialogs_controller.tsx +7 -3
  231. package/src/types/entities.ts +1 -1
  232. package/src/types/entity_actions.tsx +16 -4
  233. package/src/types/entity_callbacks.ts +18 -18
  234. package/src/types/export_import.ts +4 -4
  235. package/src/types/fields.tsx +33 -4
  236. package/src/types/firecms.tsx +2 -2
  237. package/src/types/firecms_context.tsx +1 -1
  238. package/src/types/navigation.ts +36 -16
  239. package/src/types/permissions.ts +5 -5
  240. package/src/types/plugins.tsx +9 -8
  241. package/src/types/properties.ts +21 -3
  242. package/src/types/property_config.tsx +0 -2
  243. package/src/types/side_dialogs_controller.tsx +2 -0
  244. package/src/types/side_entity_controller.tsx +6 -1
  245. package/src/types/user.ts +2 -0
  246. package/src/util/builders.ts +10 -8
  247. package/src/util/entities.ts +3 -1
  248. package/src/util/entity_actions.ts +28 -0
  249. package/src/util/entity_cache.ts +204 -0
  250. package/src/util/icon_list.ts +1 -0
  251. package/src/util/icon_synonyms.ts +0 -1
  252. package/src/util/icons.tsx +12 -8
  253. package/src/util/index.ts +1 -0
  254. package/src/util/join_collections.ts +3 -0
  255. package/src/util/navigation_from_path.ts +13 -6
  256. package/src/util/navigation_utils.ts +53 -1
  257. package/src/util/objects.ts +24 -1
  258. package/src/util/parent_references_from_path.ts +3 -3
  259. package/src/util/permissions.ts +8 -8
  260. package/src/util/property_utils.tsx +10 -3
  261. package/src/util/references.ts +8 -2
  262. package/src/util/resolutions.ts +34 -13
  263. package/src/util/useStorageUploadController.tsx +40 -22
  264. package/dist/form/components/FormikArrayContainer.d.ts +0 -19
  265. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +0 -236
  266. package/src/form/components/FormikArrayContainer.tsx +0 -47
  267. /package/src/util/{common.tsx → common.ts} +0 -0
@@ -9,18 +9,13 @@ import { StorageSource } from "./storage";
9
9
  * to do it as the result of a hook.
10
10
  * @group Hooks and utilities
11
11
  */
12
- export type AuthController<UserType extends User = any, ExtraData = any> = {
12
+ export type AuthController<USER extends User = any, ExtraData = any> = {
13
13
 
14
14
  /**
15
15
  * The user currently logged in
16
16
  * The values can be: the user object, null if they skipped login
17
17
  */
18
- user: UserType | null;
19
-
20
- /**
21
- * Roles related to the logged user
22
- */
23
- roles?: Role[];
18
+ user: USER | null;
24
19
 
25
20
  /**
26
21
  * Initial loading flag. It is used not to display the login screen
@@ -64,26 +59,27 @@ export type AuthController<UserType extends User = any, ExtraData = any> = {
64
59
 
65
60
  setExtra: (extra: ExtraData) => void;
66
61
 
67
- // setUser?: (user: UserType | null) => void;
62
+ setUser?: (user: USER | null) => void;
63
+
64
+ setUserRoles?: (roles: Role[]) => void;
68
65
 
69
- // setRoles?: (roles: Role[]) => void;
70
66
  };
71
67
 
72
68
  /**
73
69
  * Implement this function to allow access to specific users.
74
70
  * @group Hooks and utilities
75
71
  */
76
- export type Authenticator<UserType extends User = User, Controller extends AuthController<UserType> = AuthController<UserType>> = (props: {
72
+ export type Authenticator<USER extends User = User> = (props: {
77
73
 
78
74
  /**
79
75
  * Logged-in user or null
80
76
  */
81
- user: UserType | null;
77
+ user: USER | null;
82
78
 
83
79
  /**
84
80
  * AuthController
85
81
  */
86
- authController: Controller;
82
+ authController: AuthController<USER>;
87
83
 
88
84
  /**
89
85
  * Connector to your database, e.g. your Firestore database
@@ -17,7 +17,7 @@ import { EntityOverrides } from "./entity_overrides";
17
17
  *
18
18
  * @group Models
19
19
  */
20
- export interface EntityCollection<M extends Record<string, any> = any, UserType extends User = any> {
20
+ export interface EntityCollection<M extends Record<string, any> = any, USER extends User = any> {
21
21
 
22
22
  /**
23
23
  * You can set an alias that will be used internally instead of the `path`.
@@ -84,6 +84,11 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
84
84
  */
85
85
  properties: PropertiesOrBuilders<M>;
86
86
 
87
+ /**
88
+ * Default preview properties displayed when this collection is referenced to.
89
+ */
90
+ previewProperties?: string[];
91
+
87
92
  /**
88
93
  * Title property of the entity. This is the property that will be used
89
94
  * as the title in entity related views and references.
@@ -92,11 +97,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
92
97
  titleProperty?: keyof M;
93
98
 
94
99
  /**
95
- * Can this collection be edited by the end user.
96
- * Defaults to `true`.
97
- * Keep in mind that you can also set this prop to individual properties.
100
+ * When editing an entity, you can choose to open the entity in a side dialog
101
+ * or in a full screen dialog. Defaults to `full_screen`.
98
102
  */
99
- editable?: boolean;
103
+ openEntityMode?: "side_panel" | "full_screen";
100
104
 
101
105
  /**
102
106
  * Order in which the properties are displayed.
@@ -119,7 +123,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
119
123
  * `hidden` in the property definition,will be ignored.
120
124
  * `propertiesOrder` has precedence over `hidden`.
121
125
  */
122
- propertiesOrder?: (Extract<keyof M, string> | `subcollection:${string}`)[];
126
+ propertiesOrder?: (Extract<keyof M, string> | string | `subcollection:${string}` | "collectionGroupParent")[];
123
127
 
124
128
  /**
125
129
  * If enabled, content is loaded in batches. If `false` all entities in the
@@ -139,7 +143,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
139
143
  * Permissions the logged-in user can perform on this collection.
140
144
  * If not specified everything defaults to `true`.
141
145
  */
142
- permissions?: Permissions | PermissionsBuilder<EntityCollection, UserType, M>;
146
+ permissions?: Permissions | PermissionsBuilder<EntityCollection, USER, M>;
143
147
 
144
148
  /**
145
149
  * Are the entities in this collection selectable. Defaults to `true`
@@ -158,7 +162,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
158
162
  * is being created, updated or deleted.
159
163
  * Useful for adding your own logic or blocking the execution of the operation.
160
164
  */
161
- callbacks?: EntityCallbacks<M, UserType>;
165
+ callbacks?: EntityCallbacks<M, USER>;
162
166
 
163
167
  /**
164
168
  * Builder for rendering additional components such as buttons in the
@@ -189,7 +193,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
189
193
  * }
190
194
  * ```
191
195
  */
192
- entityActions?: EntityAction<M, UserType>[];
196
+ entityActions?: EntityAction<M, USER>[];
193
197
 
194
198
  /**
195
199
  * Pass your own selection controller if you want to control selected
@@ -241,7 +245,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
241
245
  * You can add additional fields to the collection view by implementing
242
246
  * an additional field delegate.
243
247
  */
244
- additionalFields?: AdditionalFieldDelegate<M, UserType>[];
248
+ additionalFields?: AdditionalFieldDelegate<M, USER>[];
245
249
 
246
250
  /**
247
251
  * Default size of the rendered collection
@@ -294,7 +298,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
294
298
  /**
295
299
  *
296
300
  */
297
- exportable?: boolean | ExportConfig<UserType>;
301
+ exportable?: boolean | ExportConfig<USER>;
298
302
 
299
303
  /**
300
304
  * User id of the owner of this collection. This is used only by plugins, or if you
@@ -313,9 +317,19 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
313
317
  sideDialogWidth?: number | string;
314
318
 
315
319
  /**
316
- * Default preview properties displayed when this collection is referenced to.
320
+ * Can this collection configuration be edited by the end user.
321
+ * Defaults to `true`.
322
+ * Keep in mind that you can also set this prop to individual properties.
323
+ * This prop has only effect if you are using the collection editor.
317
324
  */
318
- previewProperties?: string[];
325
+ editable?: boolean;
326
+
327
+ /**
328
+ * If set to true, the default values of the properties will be applied
329
+ * to the entity every time the entity is updated (not only when created).
330
+ * Defaults to false.
331
+ */
332
+ alwaysApplyDefaultValues?: boolean;
319
333
  }
320
334
 
321
335
  /**
@@ -325,7 +339,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
325
339
  *
326
340
  * @group Models
327
341
  */
328
- export interface CollectionActionsProps<M extends Record<string, any> = any, UserType extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
342
+ export interface CollectionActionsProps<M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
329
343
  /**
330
344
  * Full collection path of this entity. This is the full path, like
331
345
  * `users/1234/addresses`
@@ -362,7 +376,7 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, Use
362
376
  /**
363
377
  * Context of the app status
364
378
  */
365
- context: FireCMSContext<UserType>;
379
+ context: FireCMSContext<USER>;
366
380
 
367
381
  /**
368
382
  * Count of the entities in this collection
@@ -424,9 +438,9 @@ export type FilterCombination<Key extends string> = Partial<Record<Key, "asc" |
424
438
  */
425
439
  export type CollectionSize = "xs" | "s" | "m" | "l" | "xl";
426
440
 
427
- export type AdditionalFieldDelegateProps<M extends Record<string, any> = any, UserType extends User = User> = {
441
+ export type AdditionalFieldDelegateProps<M extends Record<string, any> = any, USER extends User = User> = {
428
442
  entity: Entity<M>,
429
- context: FireCMSContext<UserType>
443
+ context: FireCMSContext<USER>
430
444
  };
431
445
 
432
446
  /**
@@ -435,7 +449,7 @@ export type AdditionalFieldDelegateProps<M extends Record<string, any> = any, Us
435
449
  * @group Models
436
450
  */
437
451
  export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
438
- UserType extends User = User> {
452
+ USER extends User = User> {
439
453
 
440
454
  /**
441
455
  * ID of this column. You can use this id in the `properties` field of the
@@ -456,7 +470,7 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
456
470
  /**
457
471
  * Builder for the content of the cell for this column
458
472
  */
459
- Builder?: React.ComponentType<AdditionalFieldDelegateProps<M, UserType>>;
473
+ Builder?: React.ComponentType<AdditionalFieldDelegateProps<M, USER>>;
460
474
 
461
475
  /**
462
476
  * If this column needs to update dynamically based on other properties,
@@ -491,21 +505,26 @@ export type EntityCustomView<M extends Record<string, any> = any> =
491
505
  /**
492
506
  * Key of this custom view.
493
507
  */
494
- key: string,
508
+ key: string;
509
+
495
510
  /**
496
511
  * Name of this custom view.
497
512
  */
498
- name: string,
513
+ name: string;
514
+
499
515
  /**
500
- * If set to true, the actions of the entity will be included in the
501
- * bottom of the panel (save buttons, delete buttons, etc.)
516
+ * If set to true, the actions of the entity (save, discard,delete) will be
517
+ * included in the view. By default the actions are located in the right or bottom,
518
+ * based on the screen size. You can force the actions to be located at the bottom
519
+ * by setting this prop to "bottom".
502
520
  */
503
- includeActions?: boolean;
521
+ includeActions?: boolean | "bottom";
522
+
504
523
  /**
505
524
  * Builder for rendering the custom view
506
525
  */
507
526
  Builder?: React.ComponentType<EntityCustomViewParams<M>>;
508
- }
527
+ };
509
528
 
510
529
  /**
511
530
  * Parameters passed to the builder in charge of rendering a custom panel for
@@ -570,6 +589,12 @@ export type EntityTableController<M extends Record<string, any> = any> = {
570
589
  clearFilter?: () => void;
571
590
  itemCount?: number;
572
591
  setItemCount?: (itemCount: number) => void;
592
+ initialScroll?: number;
593
+ onScroll?: (props: {
594
+ scrollDirection: "forward" | "backward",
595
+ scrollOffset: number,
596
+ scrollUpdateWasRequested: boolean
597
+ }) => void;
573
598
  paginationEnabled?: boolean;
574
599
  pageSize?: number;
575
600
  checkFilterCombination?: (filterValues: FilterValues<any>,
@@ -585,5 +610,6 @@ export type SelectedCellProps<M extends Record<string, any>> = {
585
610
  cellRect: DOMRect;
586
611
  width: number;
587
612
  height: number;
588
- entity: Entity<M>;
613
+ entityPath: string;
614
+ entityId: string;
589
615
  };
@@ -9,6 +9,7 @@ import { FireCMSContext } from "./firecms_context";
9
9
  export interface FetchEntityProps<M extends Record<string, any> = any> {
10
10
  path: string;
11
11
  entityId: string;
12
+ databaseId?: string;
12
13
  collection?: EntityCollection<M, any>
13
14
  }
14
15
 
@@ -18,7 +19,6 @@ export interface FetchEntityProps<M extends Record<string, any> = any> {
18
19
  export type ListenEntityProps<M extends Record<string, any> = any> =
19
20
  FetchEntityProps<M>
20
21
  & {
21
- databaseId?: string;
22
22
  onUpdate: (entity: Entity<M>) => void,
23
23
  onError?: (error: Error) => void,
24
24
  }
@@ -139,6 +139,7 @@ export interface DataSource {
139
139
  fetchEntity<M extends Record<string, any> = any>({
140
140
  path,
141
141
  entityId,
142
+ databaseId,
142
143
  collection
143
144
  }: FetchEntityProps<M>
144
145
  ): Promise<Entity<M> | undefined>;
@@ -260,11 +261,6 @@ export interface DataSourceDelegate {
260
261
  */
261
262
  initialised?: boolean;
262
263
 
263
- /**
264
- * If the user is authenticated to use the data source
265
- */
266
- authenticated?: boolean;
267
-
268
264
  /**
269
265
  * Fetch data from a collection
270
266
  * @param path
@@ -15,19 +15,23 @@ export interface DialogsController {
15
15
  * Open a dialog
16
16
  * @param props
17
17
  */
18
- open: (props: DialogControllerEntryProps) => { closeDialog: () => void };
18
+ open: <T extends object = object>(props: DialogControllerEntryProps<T>) => { closeDialog: () => void };
19
19
  }
20
20
 
21
21
  /**
22
22
  * Props used to open a side dialog
23
23
  * @group Hooks and utilities
24
24
  */
25
- export interface DialogControllerEntryProps {
25
+ export interface DialogControllerEntryProps<T extends object = object> {
26
26
 
27
27
  key: string;
28
28
  /**
29
29
  * The component type that will be rendered
30
30
  */
31
- Component: React.ComponentType<{ open: boolean, closeDialog: () => void }>;
31
+ Component: React.ComponentType<{ open: boolean, closeDialog: () => void } & T>;
32
+ /**
33
+ * Props to pass to the dialog component
34
+ */
35
+ props?: T;
32
36
 
33
37
  }
@@ -8,7 +8,7 @@ export type EntityStatus = "new" | "existing" | "copy";
8
8
  * Representation of an entity fetched from the datasource
9
9
  * @group Models
10
10
  */
11
- export interface Entity<M extends object> {
11
+ export interface Entity<M extends object = any> {
12
12
 
13
13
  /**
14
14
  * ID of the entity
@@ -9,12 +9,22 @@ import { SideEntityController } from "./side_entity_controller";
9
9
  * An entity action is a custom action that can be performed on an entity.
10
10
  * They are displayed in the entity view and in the collection view.
11
11
  */
12
- export type EntityAction<M extends object = any, UserType extends User = User> = {
12
+ export type EntityAction<M extends object = any, USER extends User = User> = {
13
13
  /**
14
14
  * Title of the action
15
15
  */
16
16
  name: string;
17
17
 
18
+ /**
19
+ * Key of the action. You only need to provide this if you want to
20
+ * override the default actions.
21
+ * The default actions are:
22
+ * - edit
23
+ * - delete
24
+ * - copy
25
+ */
26
+ key?: string;
27
+
18
28
  /**
19
29
  * Icon of the action
20
30
  */
@@ -24,7 +34,7 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
24
34
  * Callback when the action is clicked
25
35
  * @param props
26
36
  */
27
- onClick: (props: EntityActionClickProps<M, UserType>) => Promise<void> | void;
37
+ onClick: (props: EntityActionClickProps<M, USER>) => Promise<void> | void;
28
38
 
29
39
  /**
30
40
  * Show this action collapsed in the menu of the collection view.
@@ -40,9 +50,9 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
40
50
 
41
51
  }
42
52
 
43
- export type EntityActionClickProps<M extends object, UserType extends User = User> = {
53
+ export type EntityActionClickProps<M extends object, USER extends User = User> = {
44
54
  entity: Entity<M>;
45
- context: FireCMSContext<UserType>;
55
+ context: FireCMSContext<USER>;
46
56
  fullPath?: string;
47
57
  collection?: EntityCollection<M>;
48
58
  selectionController?: SelectionController;
@@ -53,4 +63,6 @@ export type EntityActionClickProps<M extends object, UserType extends User = Use
53
63
  * If this actions is being called from a side dialog
54
64
  */
55
65
  sideEntityController?: SideEntityController;
66
+
67
+ openEntityMode: "side_panel" | "full_screen";
56
68
  };
@@ -10,27 +10,27 @@ import { User } from "./user";
10
10
  * Useful for adding your own logic or blocking the execution of the operation.
11
11
  * @group Models
12
12
  */
13
- export type EntityCallbacks<M extends Record<string, any> = any, UserType extends User = User> = {
13
+ export type EntityCallbacks<M extends Record<string, any> = any, USER extends User = User> = {
14
14
 
15
15
  /**
16
16
  * Callback used after fetching data
17
17
  * @param entityFetchProps
18
18
  */
19
- onFetch?(entityFetchProps: EntityOnFetchProps<M, UserType>)
19
+ onFetch?(entityFetchProps: EntityOnFetchProps<M, USER>)
20
20
  : Promise<Entity<M>> | Entity<M>;
21
21
 
22
22
  /**
23
23
  * Callback used when save is successful
24
24
  * @param entitySaveProps
25
25
  */
26
- onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M, UserType>)
26
+ onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M, USER>)
27
27
  : Promise<void> | void;
28
28
 
29
29
  /**
30
30
  * Callback used when saving fails
31
31
  * @param entitySaveProps
32
32
  */
33
- onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M, UserType>)
33
+ onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M, USER>)
34
34
  : Promise<void> | void;
35
35
 
36
36
  /**
@@ -39,7 +39,7 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
39
39
  * error snackbar gets displayed.
40
40
  * @param entitySaveProps
41
41
  */
42
- onPreSave?(entitySaveProps: EntityOnPreSaveProps<M, UserType>)
42
+ onPreSave?(entitySaveProps: EntityOnPreSaveProps<M, USER>)
43
43
  : Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
44
44
 
45
45
  /**
@@ -49,14 +49,14 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
49
49
  *
50
50
  * @param entityDeleteProps
51
51
  */
52
- onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M, UserType>): void;
52
+ onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
53
53
 
54
54
  /**
55
55
  * Callback used after the entity is deleted.
56
56
  *
57
57
  * @param entityDeleteProps
58
58
  */
59
- onDelete?(entityDeleteProps: EntityOnDeleteProps<M, UserType>): void;
59
+ onDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
60
60
 
61
61
  /**
62
62
  * Callback fired when any value in the form changes. You can use it
@@ -73,12 +73,12 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
73
73
  * Parameters passed to hooks when an entity is fetched
74
74
  * @group Models
75
75
  */
76
- export interface EntityOnFetchProps<M extends Record<string, any> = any, UserType extends User = User> {
76
+ export interface EntityOnFetchProps<M extends Record<string, any> = any, USER extends User = User> {
77
77
 
78
78
  /**
79
79
  * Collection of the entity
80
80
  */
81
- collection: EntityCollection<M, UserType>;
81
+ collection: EntityCollection<M, USER>;
82
82
 
83
83
  /**
84
84
  * Full path of the CMS where this collection is being fetched.
@@ -94,15 +94,15 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
94
94
  /**
95
95
  * Context of the app status
96
96
  */
97
- context: FireCMSContext<UserType>;
97
+ context: FireCMSContext<USER>;
98
98
  }
99
99
 
100
100
  /**
101
101
  * Parameters passed to hooks before an entity is saved
102
102
  * @group Models
103
103
  */
104
- export type EntityOnPreSaveProps<M extends Record<string, any> = any, UserType extends User = User> =
105
- Omit<EntityOnSaveProps<M, UserType>, "entityId">
104
+ export type EntityOnPreSaveProps<M extends Record<string, any> = any, USER extends User = User> =
105
+ Omit<EntityOnSaveProps<M, USER>, "entityId">
106
106
  & {
107
107
  entityId?: string;
108
108
  }
@@ -110,8 +110,8 @@ export type EntityOnPreSaveProps<M extends Record<string, any> = any, UserType e
110
110
  * Parameters passed to hooks before an entity is saved
111
111
  * @group Models
112
112
  */
113
- export type EntityOnSaveFailureProps<M extends Record<string, any> = any, UserType extends User = User> =
114
- Omit<EntityOnSaveProps<M, UserType>, "entityId">
113
+ export type EntityOnSaveFailureProps<M extends Record<string, any> = any, USER extends User = User> =
114
+ Omit<EntityOnSaveProps<M, USER>, "entityId">
115
115
  & {
116
116
  entityId?: string;
117
117
  }
@@ -120,7 +120,7 @@ export type EntityOnSaveFailureProps<M extends Record<string, any> = any, UserTy
120
120
  * Parameters passed to hooks when an entity is saved
121
121
  * @group Models
122
122
  */
123
- export interface EntityOnSaveProps<M extends Record<string, any> = any, UserType extends User = User> {
123
+ export interface EntityOnSaveProps<M extends Record<string, any> = any, USER extends User = User> {
124
124
 
125
125
  /**
126
126
  * Resolved collection of the entity
@@ -161,14 +161,14 @@ export interface EntityOnSaveProps<M extends Record<string, any> = any, UserType
161
161
  /**
162
162
  * Context of the app status
163
163
  */
164
- context: FireCMSContext<UserType>;
164
+ context: FireCMSContext<USER>;
165
165
  }
166
166
 
167
167
  /**
168
168
  * Parameters passed to hooks when an entity is deleted
169
169
  * @group Models
170
170
  */
171
- export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserType extends User = User> {
171
+ export interface EntityOnDeleteProps<M extends Record<string, any> = any, USER extends User = User> {
172
172
 
173
173
  /**
174
174
  * collection of the entity being deleted
@@ -193,7 +193,7 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserTy
193
193
  /**
194
194
  * Context of the app status
195
195
  */
196
- context: FireCMSContext<UserType>;
196
+ context: FireCMSContext<USER>;
197
197
  }
198
198
 
199
199
  /**
@@ -7,20 +7,20 @@ import { FireCMSContext } from "./firecms_context";
7
7
  * exports
8
8
  * @group Models
9
9
  */
10
- export interface ExportConfig<UserType extends User = User> {
11
- additionalFields: ExportMappingFunction<UserType> [];
10
+ export interface ExportConfig<USER extends User = User> {
11
+ additionalFields: ExportMappingFunction<USER> [];
12
12
  }
13
13
 
14
14
  /**
15
15
  * @group Models
16
16
  */
17
- export interface ExportMappingFunction<UserType extends User = User> {
17
+ export interface ExportMappingFunction<USER extends User = User> {
18
18
  key: string;
19
19
  builder: ({
20
20
  entity,
21
21
  context
22
22
  }: {
23
23
  entity: Entity<any>,
24
- context: FireCMSContext<UserType>
24
+ context: FireCMSContext<USER>
25
25
  }) => Promise<string> | string;
26
26
  }
@@ -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
  /**
6
7
  * When building a custom field you need to create a React component that takes
@@ -81,7 +82,8 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
81
82
  partOfArray?: boolean;
82
83
 
83
84
  /**
84
- * Should this field render with the minimal amount of UI elements
85
+ * Display the child properties directly, without being wrapped in an
86
+ * extendable panel. Note that this will also hide the title of this property.
85
87
  */
86
88
  minimalistView?: boolean;
87
89
 
@@ -108,7 +110,16 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
108
110
  /**
109
111
  * Size of the field
110
112
  */
111
- size?: "smallest" | "small" | "medium";
113
+ size?: "small" | "medium" | "large";
114
+
115
+ /**
116
+ * Some properties might change internal state (like expanding a panel).
117
+ * This function should be called when the internal state changes.
118
+ * This is used to preserve state in array containers.
119
+ *
120
+ * @param property
121
+ */
122
+ onPropertyChange?: (property: Partial<Property<any>>) => void;
112
123
 
113
124
  }
114
125
 
@@ -151,6 +162,14 @@ export interface FormContext<M extends Record<string, any> = any> {
151
162
  */
152
163
  path?: string;
153
164
 
165
+ status: "new" | "existing" | "copy";
166
+
167
+ entity?: Entity<M>;
168
+
169
+ savingError?: Error;
170
+
171
+ openEntityMode: "side_panel" | "full_screen";
172
+
154
173
  /**
155
174
  * This is the underlying formex controller that powers the form
156
175
  */
@@ -198,7 +217,8 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
198
217
  partOfArray?: boolean;
199
218
 
200
219
  /**
201
- * Is this field part of a block (oneOf array)
220
+ * Display the child properties directly, without being wrapped in an
221
+ * extendable panel. Note that this will also hide the title of this property.
202
222
  */
203
223
  minimalistView?: boolean;
204
224
 
@@ -222,5 +242,14 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
222
242
  /**
223
243
  * The size of the field
224
244
  */
225
- size?: "smallest" | "small" | "medium",
245
+ size?: "small" | "medium" | "large",
246
+
247
+ /**
248
+ * Some properties might change internal state (like expanding a panel).
249
+ * This function should be called when the internal state changes.
250
+ * This is used to preserve state in array containers.
251
+ *
252
+ * @param property
253
+ */
254
+ onPropertyChange?: (property: Partial<Property<any>>) => void;
226
255
  }
@@ -47,7 +47,7 @@ export type CMSViewsBuilder = (params: {
47
47
  /**
48
48
  * @group Models
49
49
  */
50
- export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
50
+ export type FireCMSProps<USER extends User, EC extends EntityCollection> = {
51
51
 
52
52
  /**
53
53
  * Use this function to return the components you want to render under
@@ -119,7 +119,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
119
119
  /**
120
120
  * Delegate for implementing your auth operations.
121
121
  */
122
- authController: AuthController<UserType>;
122
+ authController: AuthController<USER>;
123
123
 
124
124
  /**
125
125
  * Use this controller to access the configuration that is stored locally,
@@ -18,7 +18,7 @@ import { AnalyticsController } from "./analytics_controller";
18
18
  * @group Hooks and utilities
19
19
  * @see useFireCMSContext
20
20
  */
21
- export type FireCMSContext<UserType extends User = User, AuthControllerType extends AuthController<UserType> = AuthController<UserType>> = {
21
+ export type FireCMSContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = {
22
22
 
23
23
  /**
24
24
  * Connector to your database, e.g. your Firestore database