@firecms/core 3.0.0-beta.8 → 3.0.0-beta.9

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 (190) hide show
  1. package/dist/app/Drawer.d.ts +1 -1
  2. package/dist/app/Scaffold.d.ts +1 -1
  3. package/dist/components/ArrayContainer.d.ts +2 -1
  4. package/dist/components/CircularProgressCenter.d.ts +1 -1
  5. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
  6. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
  7. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  8. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
  9. package/dist/components/EntityPreview.d.ts +1 -1
  10. package/dist/components/ErrorView.d.ts +1 -1
  11. package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
  12. package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
  13. package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
  14. package/dist/components/VirtualTable/VirtualTableProps.d.ts +10 -6
  15. package/dist/components/common/useColumnsIds.d.ts +2 -1
  16. package/dist/components/index.d.ts +1 -0
  17. package/dist/core/DefaultAppBar.d.ts +1 -1
  18. package/dist/core/DefaultDrawer.d.ts +1 -1
  19. package/dist/core/DrawerNavigationItem.d.ts +2 -1
  20. package/dist/core/EntityEditView.d.ts +3 -3
  21. package/dist/core/FireCMS.d.ts +1 -1
  22. package/dist/core/NavigationRoutes.d.ts +1 -1
  23. package/dist/form/PropertyFieldBinding.d.ts +1 -1
  24. package/dist/form/components/FormikArrayContainer.d.ts +2 -1
  25. package/dist/form/components/LabelWithIcon.d.ts +1 -1
  26. package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
  27. package/dist/form/components/index.d.ts +1 -0
  28. package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
  29. package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
  30. package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
  31. package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
  32. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  33. package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
  34. package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
  35. package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
  36. package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
  37. package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
  38. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
  39. package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
  40. package/dist/form/index.d.ts +3 -3
  41. package/dist/form/useClearRestoreValue.d.ts +2 -2
  42. package/dist/hooks/useProjectLog.d.ts +2 -2
  43. package/dist/index.es.js +14127 -11014
  44. package/dist/index.es.js.map +1 -1
  45. package/dist/index.umd.js +19987 -587
  46. package/dist/index.umd.js.map +1 -1
  47. package/dist/preview/PropertyPreviewProps.d.ts +1 -1
  48. package/dist/preview/components/EnumValuesChip.d.ts +1 -1
  49. package/dist/preview/components/ReferencePreview.d.ts +1 -1
  50. package/dist/types/auth.d.ts +1 -1
  51. package/dist/types/collections.d.ts +12 -3
  52. package/dist/types/datasource.d.ts +35 -22
  53. package/dist/types/entities.d.ts +1 -0
  54. package/dist/types/entity_overrides.d.ts +2 -2
  55. package/dist/types/fields.d.ts +20 -15
  56. package/dist/types/navigation.d.ts +1 -0
  57. package/dist/types/properties.d.ts +18 -18
  58. package/dist/types/side_dialogs_controller.d.ts +10 -0
  59. package/dist/types/storage.d.ts +75 -0
  60. package/dist/util/entities.d.ts +1 -1
  61. package/dist/util/icon_list.d.ts +5 -1
  62. package/dist/util/icons.d.ts +1 -0
  63. package/dist/util/index.d.ts +1 -0
  64. package/dist/util/plurals.d.ts +0 -2
  65. package/dist/util/property_utils.d.ts +1 -1
  66. package/dist/util/resolutions.d.ts +15 -1
  67. package/dist/util/storage.d.ts +1 -1
  68. package/dist/util/useStorageUploadController.d.ts +2 -2
  69. package/package.json +15 -17
  70. package/src/app/Drawer.tsx +1 -1
  71. package/src/app/Scaffold.tsx +22 -27
  72. package/src/components/ArrayContainer.tsx +15 -10
  73. package/src/components/CircularProgressCenter.tsx +1 -1
  74. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -9
  75. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
  76. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
  77. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
  78. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
  79. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
  80. package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
  81. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -5
  82. package/src/components/EntityCollectionView/EntityCollectionView.tsx +26 -25
  83. package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
  84. package/src/components/EntityPreview.tsx +30 -31
  85. package/src/components/ErrorView.tsx +1 -1
  86. package/src/components/HomePage/DefaultHomePage.tsx +24 -18
  87. package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
  88. package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
  89. package/src/components/PropertyIdCopyTooltip.tsx +48 -0
  90. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
  91. package/src/components/SearchIconsView.tsx +5 -2
  92. package/src/components/SelectableTable/SelectableTable.tsx +2 -4
  93. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
  94. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
  95. package/src/components/VirtualTable/VirtualTable.tsx +33 -9
  96. package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
  97. package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
  98. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
  99. package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
  100. package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
  101. package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
  102. package/src/components/common/useColumnsIds.tsx +13 -0
  103. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
  104. package/src/components/common/useTableSearchHelper.ts +1 -0
  105. package/src/components/index.tsx +1 -0
  106. package/src/core/DefaultAppBar.tsx +3 -3
  107. package/src/core/DefaultDrawer.tsx +18 -12
  108. package/src/core/DrawerNavigationItem.tsx +31 -27
  109. package/src/core/EntityEditView.tsx +136 -109
  110. package/src/core/FireCMS.tsx +2 -2
  111. package/src/core/NavigationRoutes.tsx +1 -1
  112. package/src/core/SideDialogs.tsx +1 -0
  113. package/src/core/field_configs.tsx +5 -5
  114. package/src/form/PropertyFieldBinding.tsx +24 -14
  115. package/src/form/components/CustomIdField.tsx +4 -2
  116. package/src/form/components/FieldHelperText.tsx +1 -1
  117. package/src/form/components/FormikArrayContainer.tsx +4 -1
  118. package/src/form/components/LabelWithIcon.tsx +27 -19
  119. package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
  120. package/src/form/components/StorageItemPreview.tsx +1 -0
  121. package/src/form/components/StorageUploadProgress.tsx +0 -1
  122. package/src/form/components/index.tsx +1 -0
  123. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +22 -14
  124. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +24 -22
  125. package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
  126. package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
  127. package/src/form/field_bindings/KeyValueFieldBinding.tsx +8 -7
  128. package/src/form/field_bindings/MapFieldBinding.tsx +16 -24
  129. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
  130. package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
  131. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -7
  132. package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
  133. package/src/form/field_bindings/RepeatFieldBinding.tsx +27 -17
  134. package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
  135. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +36 -17
  136. package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
  137. package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
  138. package/src/form/index.tsx +4 -9
  139. package/src/form/useClearRestoreValue.tsx +2 -2
  140. package/src/hooks/data/delete.ts +2 -1
  141. package/src/hooks/data/save.ts +5 -2
  142. package/src/hooks/data/useDataSource.tsx +11 -3
  143. package/src/hooks/useBuildNavigationController.tsx +10 -3
  144. package/src/hooks/useProjectLog.tsx +18 -7
  145. package/src/internal/useBuildDataSource.ts +59 -76
  146. package/src/internal/useBuildSideDialogsController.tsx +1 -0
  147. package/src/internal/useBuildSideEntityController.tsx +17 -4
  148. package/src/internal/useUnsavedChangesDialog.tsx +3 -1
  149. package/src/preview/PropertyPreview.tsx +2 -2
  150. package/src/preview/PropertyPreviewProps.tsx +1 -1
  151. package/src/preview/components/BooleanPreview.tsx +1 -1
  152. package/src/preview/components/EnumValuesChip.tsx +1 -1
  153. package/src/preview/components/ImagePreview.tsx +4 -2
  154. package/src/preview/components/ReferencePreview.tsx +2 -13
  155. package/src/preview/components/UrlComponentPreview.tsx +1 -1
  156. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
  157. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
  158. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
  159. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
  160. package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
  161. package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
  162. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
  163. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  164. package/src/preview/util.ts +2 -2
  165. package/src/types/auth.tsx +1 -1
  166. package/src/types/collections.ts +15 -4
  167. package/src/types/datasource.ts +42 -27
  168. package/src/types/entities.ts +2 -0
  169. package/src/types/entity_overrides.tsx +2 -2
  170. package/src/types/fields.tsx +23 -17
  171. package/src/types/navigation.ts +1 -0
  172. package/src/types/properties.ts +18 -17
  173. package/src/types/side_dialogs_controller.tsx +13 -0
  174. package/src/types/storage.ts +82 -0
  175. package/src/util/entities.ts +1 -1
  176. package/src/util/icon_list.ts +14 -9
  177. package/src/util/icons.tsx +8 -2
  178. package/src/util/index.ts +1 -0
  179. package/src/util/plurals.ts +0 -2
  180. package/src/util/property_utils.tsx +1 -1
  181. package/src/util/references.ts +3 -0
  182. package/src/util/resolutions.ts +43 -11
  183. package/src/util/storage.ts +6 -2
  184. package/src/util/useStorageUploadController.tsx +15 -7
  185. package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
  186. package/dist/form/PropertiesForm.d.ts +0 -8
  187. package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
  188. package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
  189. package/src/form/PropertiesForm.tsx +0 -81
  190. package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
@@ -2,7 +2,7 @@ import { CMSType, Property, ResolvedProperty } from "../types";
2
2
  /**
3
3
  * @group Preview components
4
4
  */
5
- export type PreviewSize = "medium" | "small" | "tiny";
5
+ export type PreviewSize = "medium" | "small" | "smallest";
6
6
  /**
7
7
  * @group Preview components
8
8
  */
@@ -3,7 +3,7 @@ import { EnumValues } from "../../types";
3
3
  export interface EnumValuesChipProps {
4
4
  enumValues?: EnumValues;
5
5
  enumKey: string | number;
6
- size: "tiny" | "small" | "medium";
6
+ size: "smallest" | "small" | "medium";
7
7
  className?: string;
8
8
  children?: React.ReactNode;
9
9
  }
@@ -14,4 +14,4 @@ export type ReferencePreviewProps = {
14
14
  /**
15
15
  * @group Preview components
16
16
  */
17
- export declare const ReferencePreview: React.FunctionComponent<ReferencePreviewProps>;
17
+ export declare const ReferencePreview: (props: ReferencePreviewProps) => import("react/jsx-runtime").JSX.Element;
@@ -8,7 +8,7 @@ import { StorageSource } from "./storage";
8
8
  * to do it as the result of a hook.
9
9
  * @group Hooks and utilities
10
10
  */
11
- export type AuthController<UserType extends User = any, ExtraData extends any = any> = {
11
+ export type AuthController<UserType extends User = any, ExtraData = any> = {
12
12
  /**
13
13
  * The user currently logged in
14
14
  * The values can be: the user object, null if they skipped login
@@ -44,6 +44,11 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
44
44
  * This path also determines the URL in FireCMS, unless an alias is specified
45
45
  */
46
46
  path: string;
47
+ /**
48
+ * Optional database id of this collection. If not specified, the default
49
+ * database id will be used.
50
+ */
51
+ databaseId?: string;
47
52
  /**
48
53
  * If this collection is a top level navigation entry, you can set this
49
54
  * property to `true` to indicate that this collection is a collection group.
@@ -53,7 +58,8 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
53
58
  * Icon key to use in this collection.
54
59
  * You can use any of the icons in the Material specs:
55
60
  * https://fonts.google.com/icons
56
- * e.g. 'account_tree' or 'person'
61
+ * e.g. 'account_tree' or 'person'.
62
+ * Find all the icons in https://firecms.co/docs/icons
57
63
  */
58
64
  icon?: string;
59
65
  /**
@@ -265,6 +271,10 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
265
271
  * Width of the side dialog (in pixels) when opening an entity in this collection.
266
272
  */
267
273
  sideDialogWidth?: number | string;
274
+ /**
275
+ * Default preview properties displayed when this collection is referenced to.
276
+ */
277
+ previewProperties?: string[];
268
278
  }
269
279
  /**
270
280
  * Parameter passed to the `Actions` prop in the collection configuration.
@@ -313,14 +323,13 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, Use
313
323
  /**
314
324
  * Use this controller to retrieve the selected entities or modify them in
315
325
  * an {@link EntityCollection}
316
- * If you want to pass a `SelectionController` to
317
326
  * @group Models
318
327
  */
319
328
  export type SelectionController<M extends Record<string, any> = any> = {
320
329
  selectedEntities: Entity<M>[];
321
330
  setSelectedEntities: Dispatch<SetStateAction<Entity<M>[]>>;
322
331
  isEntitySelected: (entity: Entity<M>) => boolean;
323
- toggleEntitySelection: (entity: Entity<M>) => void;
332
+ toggleEntitySelection: (entity: Entity<M>, newSelectedState?: boolean) => void;
324
333
  };
325
334
  /**
326
335
  * Filter conditions in a `Query.where()` clause are specified using the
@@ -14,6 +14,7 @@ export interface FetchEntityProps<M extends Record<string, any> = any> {
14
14
  * @group Datasource
15
15
  */
16
16
  export type ListenEntityProps<M extends Record<string, any> = any> = FetchEntityProps<M> & {
17
+ databaseId?: string;
17
18
  onUpdate: (entity: Entity<M>) => void;
18
19
  onError?: (error: Error) => void;
19
20
  };
@@ -53,11 +54,11 @@ export interface SaveEntityProps<M extends Record<string, any> = any> {
53
54
  */
54
55
  export interface DeleteEntityProps<M extends Record<string, any> = any> {
55
56
  entity: Entity<M>;
57
+ collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
56
58
  }
57
59
  /**
58
- * Implement this interface and pass it to a {@link FireCMS}
59
- * to connect it to your data source.
60
- * A Firestore implementation of this interface can be found in {@link useFirestoreDataSource}
60
+ * Component in charge of communicating with the data source.
61
+ * Usually you won't need to implement this interface, but a {@link DataSourceDelegate} instead.
61
62
  * @group Datasource
62
63
  */
63
64
  export interface DataSource {
@@ -122,21 +123,21 @@ export interface DataSource {
122
123
  * @param entity
123
124
  * @return was the whole deletion flow successful
124
125
  */
125
- deleteEntity<M extends Record<string, any> = any>({ entity }: DeleteEntityProps<M>): Promise<void>;
126
+ deleteEntity<M extends Record<string, any> = any>({ entity, collection }: DeleteEntityProps<M>): Promise<void>;
126
127
  /**
127
128
  * Check if the given property is unique in the given collection
128
129
  * @param path Collection path
129
130
  * @param name of the property
130
131
  * @param value
131
- * @param property
132
+ * @param collection
132
133
  * @param entityId
133
134
  * @return `true` if there are no other fields besides the given entity
134
135
  */
135
- checkUniqueField(path: string, name: string, value: any, entityId?: string): Promise<boolean>;
136
+ checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection): Promise<boolean>;
136
137
  /**
137
138
  * Generate an id for a new entity
138
139
  */
139
- generateEntityId(path: string): string;
140
+ generateEntityId(path: string, collection: EntityCollection): string;
140
141
  /**
141
142
  * Count the number of entities in a collection
142
143
  */
@@ -164,14 +165,22 @@ export type FilterCombinationValidProps = {
164
165
  filterValues: FilterValues<any>;
165
166
  sortBy?: [string, "asc" | "desc"];
166
167
  };
167
- export type SaveEntityDelegateProps<M extends Record<string, any> = any> = Omit<SaveEntityProps<M>, "collection">;
168
- export type FetchCollectionDelegateProps<M extends Record<string, any> = any> = Omit<FetchCollectionProps<M>, "collection"> & {
169
- isCollectionGroup?: boolean;
170
- };
171
- export type ListenCollectionDelegateProps<M extends Record<string, any> = any> = ListenCollectionProps<M> & {
172
- isCollectionGroup?: boolean;
173
- };
168
+ export type SaveEntityDelegateProps<M extends Record<string, any> = any> = SaveEntityProps<M>;
169
+ export type FetchCollectionDelegateProps<M extends Record<string, any> = any> = FetchCollectionProps<M>;
170
+ export type ListenCollectionDelegateProps<M extends Record<string, any> = any> = ListenCollectionProps<M>;
174
171
  export interface DataSourceDelegate {
172
+ /**
173
+ * Key that identifies this data source delegate
174
+ */
175
+ key: string;
176
+ /**
177
+ * If the data source has been initialised
178
+ */
179
+ initialised?: boolean;
180
+ /**
181
+ * If the user is authenticated to use the data source
182
+ */
183
+ authenticated?: boolean;
175
184
  /**
176
185
  * Fetch data from a collection
177
186
  * @param path
@@ -206,7 +215,7 @@ export interface DataSourceDelegate {
206
215
  * @param path
207
216
  * @param entityId
208
217
  */
209
- fetchEntity<M extends Record<string, any> = any>({ path, entityId, }: Omit<FetchEntityProps<M>, "collection">): Promise<Entity<M> | undefined>;
218
+ fetchEntity<M extends Record<string, any> = any>({ path, entityId, }: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
210
219
  /**
211
220
  * Get realtime updates on one entity.
212
221
  * @param path
@@ -216,12 +225,12 @@ export interface DataSourceDelegate {
216
225
  * @param onError
217
226
  * @return Function to cancel subscription
218
227
  */
219
- listenEntity?<M extends Record<string, any> = any>({ path, entityId, onUpdate, onError }: Omit<ListenEntityProps<M>, "collection">): () => void;
228
+ listenEntity?<M extends Record<string, any> = any>({ path, entityId, onUpdate, onError }: ListenEntityProps<M>): () => void;
220
229
  /**
221
230
  * Save entity to the specified path
222
231
  * @param path
223
- * @param id
224
- * @param collection
232
+ * @param entityId
233
+ * @param values
225
234
  * @param status
226
235
  */
227
236
  saveEntity<M extends Record<string, any> = any>({ path, entityId, values, status }: SaveEntityDelegateProps<M>): Promise<Entity<M>>;
@@ -237,13 +246,14 @@ export interface DataSourceDelegate {
237
246
  * @param name of the property
238
247
  * @param value
239
248
  * @param entityId
249
+ * @param collection
240
250
  * @return `true` if there are no other fields besides the given entity
241
251
  */
242
- checkUniqueField(path: string, name: string, value: any, entityId?: string): Promise<boolean>;
252
+ checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection): Promise<boolean>;
243
253
  /**
244
254
  * Generate an id for a new entity
245
255
  */
246
- generateEntityId(path: string): string;
256
+ generateEntityId(path: string, collection?: EntityCollection): string;
247
257
  /**
248
258
  * Count the number of entities in a collection
249
259
  */
@@ -252,17 +262,20 @@ export interface DataSourceDelegate {
252
262
  * Check if the given filter combination is valid
253
263
  * @param props
254
264
  */
255
- isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection">): boolean;
265
+ isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection"> & {
266
+ databaseId?: string;
267
+ }): boolean;
256
268
  /**
257
269
  * Get the object to generate the current time in the datasource
258
270
  */
259
- currentTime(): any;
271
+ currentTime?: () => any;
260
272
  delegateToCMSModel: (data: any) => any;
261
273
  cmsToDelegateModel: (data: any) => any;
262
274
  setDateToMidnight: (input?: any) => any;
263
275
  initTextSearch?: (props: {
264
276
  context: FireCMSContext;
265
277
  path: string;
278
+ databaseId?: string;
266
279
  collection: EntityCollection;
267
280
  parentCollectionIds?: string[];
268
281
  }) => Promise<boolean>;
@@ -21,6 +21,7 @@ export interface Entity<M extends object> {
21
21
  * Current values
22
22
  */
23
23
  values: EntityValues<M>;
24
+ databaseId?: string;
24
25
  }
25
26
  /**
26
27
  * This type represents a record of key value pairs as described in an
@@ -1,6 +1,6 @@
1
- import { DataSource } from "./datasource";
1
+ import { DataSourceDelegate } from "./datasource";
2
2
  import { StorageSource } from "./storage";
3
3
  export type EntityOverrides = {
4
- dataSource?: DataSource;
4
+ dataSourceDelegate?: DataSourceDelegate;
5
5
  storageSource?: StorageSource;
6
6
  };
@@ -1,4 +1,4 @@
1
- import { CMSType, PropertyOrBuilder } from "./properties";
1
+ import { CMSType, Property, PropertyOrBuilder } from "./properties";
2
2
  import { ResolvedEntityCollection, ResolvedProperty } from "./resolved_entities";
3
3
  import { FormexController } from "@firecms/formex";
4
4
  /**
@@ -52,7 +52,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
52
52
  /**
53
53
  * Property related to this field
54
54
  */
55
- property: ResolvedProperty<T>;
55
+ property: Property<T> | ResolvedProperty<T>;
56
56
  /**
57
57
  * Should this field include a description
58
58
  */
@@ -67,13 +67,9 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
67
67
  */
68
68
  partOfArray?: boolean;
69
69
  /**
70
- * Is this field part of a block (oneOf array)
71
- */
72
- partOfBlock?: boolean;
73
- /**
74
- * Is this field being rendered in the entity table popup
70
+ * Should this field render with the minimal amount of UI elements
75
71
  */
76
- tableMode?: boolean;
72
+ minimalistView?: boolean;
77
73
  /**
78
74
  * Should this field autofocus on mount
79
75
  */
@@ -81,7 +77,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
81
77
  /**
82
78
  * Additional properties set by the developer
83
79
  */
84
- customProps?: CustomProps;
80
+ customProps: CustomProps;
85
81
  /**
86
82
  * Additional values related to the state of the form or the entity
87
83
  */
@@ -90,6 +86,10 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
90
86
  * Flag to indicate if this field should be disabled
91
87
  */
92
88
  disabled?: boolean;
89
+ /**
90
+ * Size of the field
91
+ */
92
+ size?: "smallest" | "small" | "medium";
93
93
  }
94
94
  /**
95
95
  * Context passed to custom fields
@@ -118,7 +118,7 @@ export interface FormContext<M extends Record<string, any> = any> {
118
118
  /**
119
119
  * Entity id, it can be null if it's a new entity
120
120
  */
121
- entityId?: string;
121
+ entityId: string;
122
122
  /**
123
123
  * Path this entity is located at
124
124
  */
@@ -157,10 +157,6 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
157
157
  * field is being edited
158
158
  */
159
159
  underlyingValueHasChanged?: boolean;
160
- /**
161
- * Is this field being rendered in a table
162
- */
163
- tableMode?: boolean;
164
160
  /**
165
161
  * Is this field part of an array
166
162
  */
@@ -168,7 +164,7 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
168
164
  /**
169
165
  * Is this field part of a block (oneOf array)
170
166
  */
171
- partOfBlock?: boolean;
167
+ minimalistView?: boolean;
172
168
  /**
173
169
  * Should the field take focus when rendered. When opening the popup view
174
170
  * in table mode, it makes sense to put the focus on the only field rendered.
@@ -178,4 +174,13 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
178
174
  * Should this field be disabled
179
175
  */
180
176
  disabled?: boolean;
177
+ /**
178
+ * Index of the field in the array.
179
+ * Only used when the field is part of an array.
180
+ */
181
+ index?: number;
182
+ /**
183
+ * The size of the field
184
+ */
185
+ size?: "smallest" | "small" | "medium";
181
186
  }
@@ -144,6 +144,7 @@ export interface CMSView {
144
144
  * You can use any of the icons in the Material specs:
145
145
  * https://fonts.google.com/icons
146
146
  * e.g. 'account_tree' or 'person'
147
+ * Find all the icons in https://firecms.co/docs/icons
147
148
  */
148
149
  icon?: string;
149
150
  /**
@@ -8,7 +8,7 @@ import { ChipColorKey, ChipColorScheme } from "@firecms/ui";
8
8
  /**
9
9
  * @group Entity properties
10
10
  */
11
- export type DataType<T extends CMSType = CMSType> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends Date ? "date" : T extends GeoPoint ? "geopoint" : T extends Vector ? "vector" : T extends EntityReference ? "reference" : T extends Array<CMSType> ? "array" : T extends Record<string, any> ? "map" : never;
11
+ export type DataType<T extends CMSType = CMSType> = T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends Date ? "date" : T extends GeoPoint ? "geopoint" : T extends Vector ? "vector" : T extends EntityReference ? "reference" : T extends Array<any> ? "array" : T extends Record<string, any> ? "map" : never;
12
12
  /**
13
13
  * @group Entity properties
14
14
  */
@@ -20,7 +20,7 @@ export type AnyProperty = StringProperty | NumberProperty | BooleanProperty | Da
20
20
  /**
21
21
  * @group Entity properties
22
22
  */
23
- export type Property<T extends CMSType = CMSType> = T extends string ? StringProperty : T extends number ? NumberProperty : T extends boolean ? BooleanProperty : T extends Date ? DateProperty : T extends GeoPoint ? GeopointProperty : T extends EntityReference ? ReferenceProperty : T extends Array<CMSType> ? ArrayProperty<T> : T extends Record<string, any> ? MapProperty<T> : AnyProperty;
23
+ export type Property<T extends CMSType = any> = T extends string ? StringProperty : T extends number ? NumberProperty : T extends boolean ? BooleanProperty : T extends Date ? DateProperty : T extends GeoPoint ? GeopointProperty : T extends EntityReference ? ReferenceProperty : T extends Array<CMSType> ? ArrayProperty<T> : T extends Record<string, any> ? MapProperty<T> : AnyProperty;
24
24
  /**
25
25
  * Interface including all common properties of a CMS property
26
26
  * @group Entity properties
@@ -207,7 +207,7 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
207
207
  * current value of the property, as well as the path and entity ID.
208
208
  * @group Entity properties
209
209
  */
210
- export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, path, entityId }: PropertyBuilderProps<M>) => Property<T> | null;
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;
211
211
  /**
212
212
  * @group Entity properties
213
213
  */
@@ -306,7 +306,7 @@ export interface StringProperty extends BaseProperty<string> {
306
306
  /**
307
307
  * @group Entity properties
308
308
  */
309
- export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSType = CMSType> extends BaseProperty<T> {
309
+ export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSType = any> extends BaseProperty<T> {
310
310
  dataType: "array";
311
311
  /**
312
312
  * The property of this array.
@@ -583,13 +583,13 @@ export type StorageConfig = {
583
583
  * You can use this prop to customize the uploaded filename.
584
584
  * You can use a function as a callback or a string where you
585
585
  * specify some placeholders that get replaced with the corresponding values.
586
- * - {file} - Full file name
587
- * - {file.name} - Name of the file without extension
588
- * - {file.ext} - Extension of the file
589
- * - {rand} - Random value used to avoid name collisions
590
- * - {entityId} - ID of the entity
591
- * - {propertyKey} - ID of this property
592
- * - {path} - Path of this entity
586
+ * - `{file}` - Full file name
587
+ * - `{file.name}` - Name of the file without extension
588
+ * - `{file.ext}` - Extension of the file
589
+ * - `{rand}` - Random value used to avoid name collisions
590
+ * - `{entityId}` - ID of the entity
591
+ * - `{propertyKey}` - ID of this property
592
+ * - `{path}` - Path of this entity
593
593
  *
594
594
  * @param context
595
595
  */
@@ -599,13 +599,13 @@ export type StorageConfig = {
599
599
  *
600
600
  * You can use a function as a callback or a string where you
601
601
  * specify some placeholders that get replaced with the corresponding values.
602
- * - {file} - Full file name
603
- * - {file.name} - Name of the file without extension
604
- * - {file.ext} - Extension of the file
605
- * - {rand} - Random value used to avoid name collisions
606
- * - {entityId} - ID of the entity
607
- * - {propertyKey} - ID of this property
608
- * - {path} - Path of this entity
602
+ * - `{file}` - Full file name
603
+ * - `{file.name}` - Name of the file without extension
604
+ * - `{file.ext}` - Extension of the file
605
+ * - `{rand}` - Random value used to avoid name collisions
606
+ * - `{entityId}` - ID of the entity
607
+ * - `{propertyKey}` - ID of this property
608
+ * - `{path}` - Path of this entity
609
609
  */
610
610
  storagePath: string | ((context: UploadedFileContext) => string);
611
611
  /**
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  /**
2
3
  * Controller to open the side dialog
3
4
  * @group Hooks and utilities
@@ -11,6 +12,11 @@ export interface SideDialogsController {
11
12
  * List of side panels currently open
12
13
  */
13
14
  sidePanels: SideDialogPanelProps[];
15
+ /**
16
+ * Override the current side panels
17
+ * @param panels
18
+ */
19
+ setSidePanels: (panels: SideDialogPanelProps[]) => void;
14
20
  /**
15
21
  * Open one or multiple side panels
16
22
  * @param props
@@ -54,4 +60,8 @@ export interface SideDialogPanelProps {
54
60
  * Callback when the panel is closed
55
61
  */
56
62
  onClose?: () => void;
63
+ /**
64
+ * Use this prop to store additional data in the panel
65
+ */
66
+ additional?: any;
57
67
  }
@@ -87,4 +87,79 @@ export interface StorageSource {
87
87
  * @param bucket
88
88
  */
89
89
  getFile: (path: string, bucket?: string) => Promise<File | null>;
90
+ /**
91
+ * Delete a file.
92
+ * @param path
93
+ * @param bucket
94
+ */
95
+ deleteFile: (path: string, bucket?: string) => Promise<void>;
96
+ /**
97
+ * List the contents of a path.
98
+ * @param path
99
+ * @param options
100
+ */
101
+ list: (path: string, options?: {
102
+ bucket?: string;
103
+ maxResults?: number;
104
+ pageToken?: string;
105
+ }) => Promise<StorageListResult>;
106
+ }
107
+ /**
108
+ * Result returned by list().
109
+ * @public
110
+ */
111
+ export declare interface StorageListResult {
112
+ /**
113
+ * References to prefixes (sub-folders). You can call list() on them to
114
+ * get its contents.
115
+ *
116
+ * Folders are implicit based on '/' in the object paths.
117
+ * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
118
+ * will return '/a/b' as a prefix.
119
+ */
120
+ prefixes: StorageReference[];
121
+ /**
122
+ * Objects in this directory.
123
+ * You can call getMetadata() and getDownloadUrl() on them.
124
+ */
125
+ items: StorageReference[];
126
+ /**
127
+ * If set, there might be more results for this list. Use this token to resume the list.
128
+ */
129
+ nextPageToken?: string;
130
+ }
131
+ /**
132
+ * Represents a reference to a Google Cloud Storage object. Developers can
133
+ * upload, download, and delete objects, as well as get/set object metadata.
134
+ * @public
135
+ */
136
+ export declare interface StorageReference {
137
+ /**
138
+ * Returns a gs:// URL for this object in the form
139
+ * `gs://<bucket>/<path>/<to>/<object>`
140
+ * @returns The gs:// URL.
141
+ */
142
+ toString(): string;
143
+ /**
144
+ * A reference to the root of this object's bucket.
145
+ */
146
+ root: StorageReference;
147
+ /**
148
+ * The name of the bucket containing this reference's object.
149
+ */
150
+ bucket: string;
151
+ /**
152
+ * The full path of this object.
153
+ */
154
+ fullPath: string;
155
+ /**
156
+ * The short name of this object, which is the last component of the full path.
157
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
158
+ */
159
+ name: string;
160
+ /**
161
+ * A reference pointing to the parent location of this reference, or null if
162
+ * this reference is the root.
163
+ */
164
+ parent: StorageReference | null;
90
165
  }
@@ -1,5 +1,5 @@
1
1
  import { CMSType, DataType, Entity, EntityReference, EntityStatus, EntityValues, PropertiesOrBuilders, Property, PropertyBuilder, PropertyOrBuilder, ResolvedProperties, ResolvedProperty } from "../types";
2
- export declare function isReadOnly(property: Property | ResolvedProperty): boolean;
2
+ export declare function isReadOnly(property: Property<any> | ResolvedProperty<any>): boolean;
3
3
  export declare function isHidden(property: Property | ResolvedProperty): boolean;
4
4
  export declare function isPropertyBuilder<T extends CMSType, M extends Record<string, any>>(propertyOrBuilder?: PropertyOrBuilder<T, M> | Property<T> | ResolvedProperty<T>): propertyOrBuilder is PropertyBuilder<T, M>;
5
5
  export declare function getDefaultValuesFor<M extends Record<string, any>>(properties: PropertiesOrBuilders<M> | ResolvedProperties<M>): Partial<EntityValues<M>>;
@@ -1 +1,5 @@
1
- export declare const iconsSearch: any;
1
+ import Fuse from "fuse.js";
2
+ export declare const iconsSearch: Fuse<{
3
+ key: string;
4
+ synonyms: any;
5
+ }>;
@@ -10,4 +10,5 @@ export type IconViewProps = {
10
10
  export declare const IconForView: React.NamedExoticComponent<{
11
11
  collectionOrView?: IconViewProps;
12
12
  className?: string;
13
+ size?: "smallest" | "small" | "medium" | "large" | number;
13
14
  }>;
@@ -21,3 +21,4 @@ export * from "./make_properties_editable";
21
21
  export * from "./join_collections";
22
22
  export * from "./builders";
23
23
  export * from "./useTraceUpdate";
24
+ export * from "./storage";
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Returns the plural of an English word.
3
3
  *
4
- * @export
5
4
  * @param {string} word
6
5
  * @param {number} [amount]
7
6
  * @returns {string}
@@ -10,7 +9,6 @@ export declare function plural(word: string, amount?: number): string;
10
9
  /**
11
10
  * Returns the singular of an English word.
12
11
  *
13
- * @export
14
12
  * @param {string} word
15
13
  * @param {number} [amount]
16
14
  * @returns {string}
@@ -3,7 +3,7 @@ import { EntityCollection, PropertiesOrBuilders, PropertyConfig, PropertyOrBuild
3
3
  export declare function isReferenceProperty(propertyOrBuilder: PropertyOrBuilder, fields: Record<string, PropertyConfig>): boolean | null;
4
4
  export declare function getIdIcon(size: "small" | "medium" | "large"): React.ReactNode;
5
5
  export declare function getIconForWidget(widget: PropertyConfig | undefined, size: "small" | "medium" | "large"): import("react/jsx-runtime").JSX.Element;
6
- export declare function getIconForProperty(property: PropertyOrBuilder | ResolvedProperty, size?: "small" | "medium" | "large", fields?: Record<string, PropertyConfig>): React.ReactNode;
6
+ export declare function getIconForProperty(property: PropertyOrBuilder<any> | ResolvedProperty<any>, size?: "small" | "medium" | "large", fields?: Record<string, PropertyConfig>): React.ReactNode;
7
7
  export declare function getColorForProperty(property: PropertyOrBuilder, fields: Record<string, PropertyConfig>): string;
8
8
  /**
9
9
  * Get a property in a property tree from a path like
@@ -26,6 +26,19 @@ export declare function resolveProperty<T extends CMSType = CMSType, M extends R
26
26
  fields?: Record<string, PropertyConfig<any>>;
27
27
  ignoreMissingFields?: boolean;
28
28
  }): ResolvedProperty<T> | null;
29
+ export declare function getArrayResolvedProperties<M>({ propertyKey, propertyValue, property, ...props }: {
30
+ propertyValue: any;
31
+ propertyKey?: string;
32
+ property: ArrayProperty<any> | ResolvedArrayProperty<any>;
33
+ ignoreMissingFields: boolean;
34
+ values?: Partial<M>;
35
+ previousValues?: Partial<M>;
36
+ path?: string;
37
+ entityId?: string;
38
+ index?: number;
39
+ fromBuilder?: boolean;
40
+ fields?: Record<string, PropertyConfig>;
41
+ }): ResolvedProperty[];
29
42
  export declare function resolveArrayProperty<T extends any[], M>({ propertyKey, property, ignoreMissingFields, ...props }: {
30
43
  propertyKey?: string;
31
44
  property: ArrayProperty<T> | ResolvedArrayProperty<T>;
@@ -43,7 +56,8 @@ export declare function resolveArrayProperty<T extends any[], M>({ propertyKey,
43
56
  * @param properties
44
57
  * @param value
45
58
  */
46
- export declare function resolveProperties<M extends Record<string, any>>({ properties, ignoreMissingFields, ...props }: {
59
+ export declare function resolveProperties<M extends Record<string, any>>({ propertyKey, properties, ignoreMissingFields, ...props }: {
60
+ propertyKey?: string;
47
61
  properties: PropertiesOrBuilders<M>;
48
62
  values?: Partial<M>;
49
63
  previousValues?: Partial<M>;
@@ -9,7 +9,7 @@ interface ResolveFilenameStringParams<M extends object> {
9
9
  file: File;
10
10
  propertyKey: string;
11
11
  }
12
- export declare function resolveFilenameString<M extends object>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveFilenameStringParams<M>): Promise<string>;
12
+ export declare function resolveStorageFilenameString<M extends object>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveFilenameStringParams<M>): Promise<string>;
13
13
  interface ResolveStoragePathStringParams<M extends object> {
14
14
  input: string | ((context: UploadedFileContext) => string);
15
15
  storage: StorageConfig;
@@ -1,4 +1,4 @@
1
- import { EntityValues, ResolvedArrayProperty, ResolvedStringProperty, StorageConfig, StorageSource } from "../types";
1
+ import { ArrayProperty, EntityValues, ResolvedArrayProperty, ResolvedStringProperty, StorageConfig, StorageSource, StringProperty } from "../types";
2
2
  import { PreviewSize } from "../preview";
3
3
  /**
4
4
  * Internal representation of an item in the storage
@@ -20,7 +20,7 @@ export declare function useStorageUploadController<M extends object>({ entityId,
20
20
  value: string | string[] | null;
21
21
  path?: string;
22
22
  propertyKey: string;
23
- property: ResolvedStringProperty | ResolvedArrayProperty<string[]>;
23
+ property: StringProperty | ArrayProperty<string[]> | ResolvedStringProperty | ResolvedArrayProperty<string[]>;
24
24
  storageSource: StorageSource;
25
25
  disabled: boolean;
26
26
  onChange: (value: string | string[] | null) => void;