@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
@@ -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
@@ -15,6 +15,16 @@ export type EntityAction<M extends object = any, USER extends User = User> = {
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
  */
@@ -53,4 +63,6 @@ export type EntityActionClickProps<M extends object, USER extends User = User> =
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
  };
@@ -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
 
@@ -160,10 +162,22 @@ export interface FormContext<M extends Record<string, any> = any> {
160
162
  */
161
163
  path?: string;
162
164
 
165
+ status: "new" | "existing" | "copy";
166
+
167
+ entity?: Entity<M>;
168
+
169
+ savingError?: Error;
170
+
171
+ openEntityMode: "side_panel" | "full_screen";
172
+
163
173
  /**
164
- * This is the underlying formex controller that powers the form
174
+ * This is the underlying formex controller that powers the form.
175
+ * If you are in a red only mode, the formex controller is there, but you can't
176
+ * operate with it
165
177
  */
166
178
  formex: FormexController<M>;
179
+
180
+ disabled: boolean;
167
181
  }
168
182
 
169
183
  /**
@@ -207,7 +221,8 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
207
221
  partOfArray?: boolean;
208
222
 
209
223
  /**
210
- * Is this field part of a block (oneOf array)
224
+ * Display the child properties directly, without being wrapped in an
225
+ * extendable panel. Note that this will also hide the title of this property.
211
226
  */
212
227
  minimalistView?: boolean;
213
228
 
@@ -47,7 +47,7 @@ export type CMSViewsBuilder = (params: {
47
47
  /**
48
48
  * @group Models
49
49
  */
50
- export type FireCMSProps<USER extends User, EC extends EntityCollection> = {
50
+ export type FireCMSProps<USER extends User> = {
51
51
 
52
52
  /**
53
53
  * Use this function to return the components you want to render under
@@ -5,6 +5,7 @@ import { EntityReference } from "./entities";
5
5
  /**
6
6
  * Controller that includes the resolved navigation and utility methods and
7
7
  * attributes.
8
+ * This controller holds the state of the navigation including the collections.
8
9
  * @group Models
9
10
  */
10
11
  export type NavigationController<EC extends EntityCollection = EntityCollection<any>> = {
@@ -56,8 +57,13 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
56
57
  * Get the collection configuration for a given path.
57
58
  * The collection is resolved from the given path or alias.
58
59
  */
59
- getCollection: (pathOrId: string,
60
- includeUserOverride?: boolean) => EC | undefined;
60
+ getCollection: (pathOrId: string, includeUserOverride?: boolean) => EC | undefined;
61
+
62
+ /**
63
+ * Get the top level collection configuration for a given id
64
+ */
65
+ getCollectionById: (id: string) => EC | undefined;
66
+
61
67
  /**
62
68
  * Get the collection configuration from its parent ids.
63
69
  */
@@ -69,12 +75,14 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
69
75
  getCollectionFromPaths: (pathSegments: string[]) => EC | undefined;
70
76
 
71
77
  /**
72
- * Default path under the navigation routes of the CMS will be created
78
+ * Default path under the navigation routes of the CMS will be created.
79
+ * Defaults to '/'. You may want to change this `basepath` to 'admin' for example.
73
80
  */
74
81
  basePath: string;
75
82
 
76
83
  /**
77
- * Default path under the collection routes of the CMS will be created
84
+ * Default path under the collection routes of the CMS will be created.
85
+ * It defaults to '/c'
78
86
  */
79
87
  baseCollectionPath: string;
80
88
 
@@ -87,16 +95,6 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
87
95
  */
88
96
  urlPathToDataPath: (cmsPath: string) => string;
89
97
 
90
- /**
91
- * Convert a collection or entity path to a URL path
92
- * @param path
93
- */
94
- buildCMSUrlPath: (path: string) => string;
95
-
96
- buildUrlEditCollectionPath: (props: {
97
- path: string
98
- }) => string;
99
-
100
98
  /**
101
99
  * Base url path for the home screen
102
100
  */
@@ -117,10 +115,11 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
117
115
  buildUrlCollectionPath: (path: string) => string;
118
116
 
119
117
  /**
120
- * Turn a path with aliases into a resolved path
118
+ * Turn a path with collection ids into a resolved path.
119
+ * The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
121
120
  * @param pathWithAliases
122
121
  */
123
- resolveAliasesFrom: (pathWithAliases: string) => string;
122
+ resolveIdsFrom: (pathWithAliases: string) => string;
124
123
 
125
124
  /**
126
125
  * Call this method to recalculate the navigation
@@ -144,8 +143,34 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
144
143
  * @param ids
145
144
  */
146
145
  convertIdsToPaths: (ids: string[]) => string[];
146
+
147
+ /**
148
+ * A function to navigate to a specified route or URL.
149
+ *
150
+ * @param {string} to - The target route or URL to navigate to.
151
+ * @param {NavigateOptions} [options] - Optional configuration settings for navigation, such as replace behavior or state data.
152
+ */
153
+ navigate: (to: string, options?: NavigateOptions) => void;
154
+
147
155
  }
148
156
 
157
+ export interface NavigateOptions {
158
+ replace?: boolean;
159
+ state?: any;
160
+ preventScrollReset?: boolean;
161
+ relative?: "route" | "path";
162
+ flushSync?: boolean;
163
+ viewTransition?: boolean;
164
+ }
165
+
166
+ // currently not used, in favor of a single blocker in `FireCMSRoute`
167
+ export type NavigationBlocker = {
168
+ updateBlockListener: (path: string, block: boolean, basePath?: string) => () => void;
169
+ isBlocked: (path: string) => boolean;
170
+ proceed?: () => void;
171
+ reset?: () => void;
172
+ };
173
+
149
174
  /**
150
175
  * Custom additional views created by the developer, added to the main
151
176
  * navigation.
@@ -192,9 +192,11 @@ export interface PluginFormActionProps<USER extends User = User, EC extends Enti
192
192
  path: string;
193
193
  status: EntityStatus;
194
194
  collection: EC;
195
+ disabled: boolean;
195
196
  formContext?: FormContext<any>;
196
197
  context: FireCMSContext<USER>;
197
198
  currentEntityId?: string;
199
+ openEntityMode: "side_panel" | "full_screen";
198
200
  }
199
201
 
200
202
  export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
@@ -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
  /**
10
11
  * @group Entity properties
@@ -156,6 +157,12 @@ export interface BaseProperty<T extends CMSType, CustomProps = any> {
156
157
  * save the new config. The saved config will then become the source of truth.
157
158
  */
158
159
  editable?: boolean;
160
+
161
+ /**
162
+ * A number between 0 and 100 that indicates the width of the field in the form view.
163
+ * It defaults to 100, but you can set it to 50 to have two fields in the same row.
164
+ */
165
+ widthPercentage?: number;
159
166
  }
160
167
 
161
168
  /**
@@ -264,6 +271,11 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> =
264
271
  * Entity ID
265
272
  */
266
273
  entityId?: string;
274
+
275
+ /**
276
+ * Controller to manage authentication
277
+ */
278
+ authController: AuthController;
267
279
  };
268
280
 
269
281
  /**
@@ -279,20 +291,21 @@ export type PropertyBuilder<T extends CMSType = any, M extends Record<string, an
279
291
  propertyValue,
280
292
  index,
281
293
  path,
282
- entityId
294
+ entityId,
295
+ authController
283
296
  }: PropertyBuilderProps<M>) => Property<T> | null;
284
297
 
285
298
  /**
286
299
  * @group Entity properties
287
300
  */
288
- export type PropertyOrBuilder<T extends CMSType = CMSType, M extends Record<string, any> = Record<string, any>> =
301
+ export type PropertyOrBuilder<T extends CMSType = CMSType, M extends Record<string, any> = any> =
289
302
  Property<T>
290
303
  | PropertyBuilder<T, M>;
291
304
 
292
305
  /**
293
306
  * @group Entity properties
294
307
  */
295
- export type PropertiesOrBuilders<M extends Record<string, any> = Record<string, any>> =
308
+ export type PropertiesOrBuilders<M extends Record<string, any> = any> =
296
309
  {
297
310
  [k in keyof M]: PropertyOrBuilder<M[k], M>;
298
311
  };
@@ -371,7 +384,7 @@ export interface StringProperty extends BaseProperty<string> {
371
384
 
372
385
  /**
373
386
  * You can specify a `Storage` configuration. It is used to
374
- * indicate that this string refers to a path in Google Cloud Storage.
387
+ * indicate that this string refers to a path in your storage provider.
375
388
  */
376
389
  storage?: StorageConfig;
377
390
 
@@ -469,6 +482,24 @@ export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSTyp
469
482
  */
470
483
  expanded?: boolean;
471
484
 
485
+ /**
486
+ * Display the child properties directly, without being wrapped in an
487
+ * extendable panel.
488
+ */
489
+ minimalistView?: boolean;
490
+
491
+ /**
492
+ * Can the elements in this array be reordered. Defaults to `true`.
493
+ * This prop has no effect if `disabled` is set to true.
494
+ */
495
+ sortable?: boolean;
496
+
497
+ /**
498
+ * Can the elements in this array be added. Defaults to `true`
499
+ * This prop has no effect if `disabled` is set to true.
500
+ */
501
+ canAddElements?: boolean;
502
+
472
503
  }
473
504
 
474
505
  /**
@@ -517,6 +548,12 @@ export interface MapProperty<T extends Record<string, CMSType> = Record<string,
517
548
  */
518
549
  spreadChildren?: boolean;
519
550
 
551
+ /**
552
+ * Display the child properties directly, without being wrapped in an
553
+ * extendable panel. Note that this will also hide the title of this property.
554
+ */
555
+ minimalistView?: boolean;
556
+
520
557
  /**
521
558
  * Should the field be initially expanded. Defaults to `true`
522
559
  */
@@ -778,6 +815,13 @@ export type StorageConfig = {
778
815
  */
779
816
  maxSize?: number,
780
817
 
818
+ /**
819
+ * Use this callback to process the file before uploading it to the storage.
820
+ * If nothing is returned, the file is uploaded as it is.
821
+ * @param file
822
+ */
823
+ processFile?: (file: File) => Promise<File> | undefined;
824
+
781
825
  /**
782
826
  * Postprocess the saved value (storage path or URL)
783
827
  * after it has been resolved.
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ import { EntityFormProps } from "../form";
2
3
 
3
4
  /**
4
5
  * Controller to open the side dialog
@@ -78,4 +79,5 @@ export interface SideDialogPanelProps {
78
79
  * Use this prop to store additional data in the panel
79
80
  */
80
81
  additional?: any;
82
+
81
83
  }
@@ -2,6 +2,7 @@ import { EntityCollection } from "./collections";
2
2
  import { ResolvedEntityCollection } from "./resolved_entities";
3
3
  import { Entity } from "./entities";
4
4
  import { EntityOverrides } from "./entity_overrides";
5
+ import { EntityFormProps } from "../form";
5
6
 
6
7
  /**
7
8
  * Props used to open a side dialog
@@ -19,6 +20,11 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
19
20
  */
20
21
  entityId?: string;
21
22
 
23
+ // /**
24
+ // * Navigation path with ids of the entity
25
+ // */
26
+ // fullIdPath: string;
27
+
22
28
  /**
23
29
  * Set this flag to true if you want to make a copy of an existing entity
24
30
  */
@@ -28,7 +34,7 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
28
34
  * Open the entity with a selected sub-collection view. If the panel for this
29
35
  * entity was already open, it is replaced.
30
36
  */
31
- selectedSubPath?: string;
37
+ selectedTab?: string;
32
38
 
33
39
  /**
34
40
  * Use this prop to override the width of the form view.
@@ -66,6 +72,10 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
66
72
  */
67
73
  closeOnSave?: boolean;
68
74
 
75
+ /**
76
+ * Override some form properties
77
+ */
78
+ formProps?: Partial<EntityFormProps<M>>;
69
79
  }
70
80
 
71
81
  /**
@@ -26,8 +26,10 @@ import {
26
26
  * @param collection
27
27
  * @group Builder
28
28
  */
29
- export function buildCollection<M extends Record<string, any> = any,
30
- USER extends User = User>(
29
+ export function buildCollection<
30
+ M extends Record<string, any> = any,
31
+ USER extends User = User>
32
+ (
31
33
  collection: EntityCollection<M, USER>
32
34
  ): EntityCollection<M, USER> {
33
35
  return collection;
@@ -39,7 +41,7 @@ export function buildCollection<M extends Record<string, any> = any,
39
41
  * @param property
40
42
  * @group Builder
41
43
  */
42
- export function buildProperty<T extends CMSType = CMSType, P extends PropertyOrBuilder<T> = PropertyOrBuilder<T>, M extends Record<string, any> = Record<string, any>>(
44
+ export function buildProperty<T extends CMSType = CMSType, P extends PropertyOrBuilder<T> = PropertyOrBuilder<T>, M extends Record<string, any> = any>(
43
45
  property: P
44
46
  ):
45
47
  P extends StringProperty ? StringProperty :
@@ -0,0 +1,62 @@
1
+ import { FormexController } from "@firecms/formex";
2
+
3
+ export function createFormexStub<T extends object>(values: T): FormexController<T> {
4
+ const errorMessage = "You are in a read-only context. You cannot modify the formex controller.";
5
+
6
+ return {
7
+ values,
8
+ initialValues: values,
9
+ touched: {} as Record<string, boolean>,
10
+ dirty: false,
11
+ errors: {} as Record<string, string>,
12
+ submitCount: 0,
13
+ isSubmitting: false,
14
+ isValidating: false,
15
+ version: 0,
16
+ canUndo: false,
17
+ canRedo: false,
18
+
19
+ setValues: () => {
20
+ throw new Error(errorMessage);
21
+ },
22
+ setFieldValue: () => {
23
+ throw new Error(errorMessage);
24
+ },
25
+ setFieldTouched: () => {
26
+ throw new Error(errorMessage);
27
+ },
28
+ setDirty: () => {
29
+ throw new Error(errorMessage);
30
+ },
31
+ setSubmitCount: () => {
32
+ throw new Error(errorMessage);
33
+ },
34
+ setFieldError: () => {
35
+ throw new Error(errorMessage);
36
+ },
37
+ handleChange: () => {
38
+ throw new Error(errorMessage);
39
+ },
40
+ handleBlur: () => {
41
+ throw new Error(errorMessage);
42
+ },
43
+ handleSubmit: () => {
44
+ throw new Error(errorMessage);
45
+ },
46
+ validate: () => {
47
+ throw new Error(errorMessage);
48
+ },
49
+ resetForm: () => {
50
+ throw new Error(errorMessage);
51
+ },
52
+ setSubmitting: () => {
53
+ throw new Error(errorMessage);
54
+ },
55
+ undo: () => {
56
+ throw new Error(errorMessage);
57
+ },
58
+ redo: () => {
59
+ throw new Error(errorMessage);
60
+ }
61
+ };
62
+ }
@@ -0,0 +1,28 @@
1
+ import { EntityAction } from "../types";
2
+
3
+ const reservedKeys = ["edit", "copy", "delete"];
4
+
5
+ export function mergeEntityActions(currentActions: EntityAction[], newActions: EntityAction[]): EntityAction[] {
6
+ // given the current actions, replace the ones with the same key
7
+ // and append the new ones
8
+ const updatedActions: EntityAction[] = [];
9
+ currentActions.forEach(action => {
10
+ const newAction = newActions.find(a => a.key === action.key);
11
+ if (newAction) {
12
+ const mergedAction = {
13
+ ...action,
14
+ ...newAction
15
+ }
16
+ updatedActions.push(mergedAction);
17
+ } else {
18
+ updatedActions.push(action);
19
+ }
20
+ });
21
+ newActions.forEach(action => {
22
+ if (!currentActions.find(a => a.key === action.key) && (!action.key || !reservedKeys.includes(action.key))) {
23
+ updatedActions.push(action);
24
+ }
25
+ });
26
+ return updatedActions;
27
+
28
+ }