@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.
- package/dist/app/Drawer.d.ts +1 -1
- package/dist/app/Scaffold.d.ts +1 -1
- package/dist/components/ArrayContainer.d.ts +2 -1
- package/dist/components/CircularProgressCenter.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +0 -1
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/components/ErrorView.d.ts +1 -1
- package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
- package/dist/components/HomePage/NavigationCardBinding.d.ts +1 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +8 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +10 -6
- package/dist/components/common/useColumnsIds.d.ts +2 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/core/DefaultAppBar.d.ts +1 -1
- package/dist/core/DefaultDrawer.d.ts +1 -1
- package/dist/core/DrawerNavigationItem.d.ts +2 -1
- package/dist/core/EntityEditView.d.ts +3 -3
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FormikArrayContainer.d.ts +2 -1
- package/dist/form/components/LabelWithIcon.d.ts +1 -1
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +15 -0
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +11 -0
- package/dist/form/field_bindings/{MultiSelectBinding.d.ts → MultiSelectFieldBinding.d.ts} +1 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +3 -3
- package/dist/form/useClearRestoreValue.d.ts +2 -2
- package/dist/hooks/useProjectLog.d.ts +2 -2
- package/dist/index.es.js +14127 -11014
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19987 -587
- package/dist/index.umd.js.map +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/types/auth.d.ts +1 -1
- package/dist/types/collections.d.ts +12 -3
- package/dist/types/datasource.d.ts +35 -22
- package/dist/types/entities.d.ts +1 -0
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/fields.d.ts +20 -15
- package/dist/types/navigation.d.ts +1 -0
- package/dist/types/properties.d.ts +18 -18
- package/dist/types/side_dialogs_controller.d.ts +10 -0
- package/dist/types/storage.d.ts +75 -0
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_list.d.ts +5 -1
- package/dist/util/icons.d.ts +1 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/plurals.d.ts +0 -2
- package/dist/util/property_utils.d.ts +1 -1
- package/dist/util/resolutions.d.ts +15 -1
- package/dist/util/storage.d.ts +1 -1
- package/dist/util/useStorageUploadController.d.ts +2 -2
- package/package.json +15 -17
- package/src/app/Drawer.tsx +1 -1
- package/src/app/Scaffold.tsx +22 -27
- package/src/components/ArrayContainer.tsx +15 -10
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -9
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -2
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +4 -2
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +21 -14
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +12 -4
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +17 -19
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +19 -7
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +3 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +26 -25
- package/src/components/EntityCollectionView/useSelectionController.tsx +19 -7
- package/src/components/EntityPreview.tsx +30 -31
- package/src/components/ErrorView.tsx +1 -1
- package/src/components/HomePage/DefaultHomePage.tsx +24 -18
- package/src/components/HomePage/NavigationCardBinding.tsx +1 -1
- package/src/components/HomePage/SmallNavigationCard.tsx +1 -2
- package/src/components/PropertyIdCopyTooltip.tsx +48 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -6
- package/src/components/SearchIconsView.tsx +5 -2
- package/src/components/SelectableTable/SelectableTable.tsx +2 -4
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +1 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +54 -7
- package/src/components/VirtualTable/VirtualTable.tsx +33 -9
- package/src/components/VirtualTable/VirtualTableCell.tsx +1 -9
- package/src/components/VirtualTable/VirtualTableProps.tsx +12 -8
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +14 -28
- package/src/components/common/useColumnsIds.tsx +13 -0
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -12
- package/src/components/common/useTableSearchHelper.ts +1 -0
- package/src/components/index.tsx +1 -0
- package/src/core/DefaultAppBar.tsx +3 -3
- package/src/core/DefaultDrawer.tsx +18 -12
- package/src/core/DrawerNavigationItem.tsx +31 -27
- package/src/core/EntityEditView.tsx +136 -109
- package/src/core/FireCMS.tsx +2 -2
- package/src/core/NavigationRoutes.tsx +1 -1
- package/src/core/SideDialogs.tsx +1 -0
- package/src/core/field_configs.tsx +5 -5
- package/src/form/PropertyFieldBinding.tsx +24 -14
- package/src/form/components/CustomIdField.tsx +4 -2
- package/src/form/components/FieldHelperText.tsx +1 -1
- package/src/form/components/FormikArrayContainer.tsx +4 -1
- package/src/form/components/LabelWithIcon.tsx +27 -19
- package/src/form/components/LabelWithIconAndTooltip.tsx +28 -0
- package/src/form/components/StorageItemPreview.tsx +1 -0
- package/src/form/components/StorageUploadProgress.tsx +0 -1
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +22 -14
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +24 -22
- package/src/form/field_bindings/BlockFieldBinding.tsx +13 -11
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -14
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +8 -7
- package/src/form/field_bindings/MapFieldBinding.tsx +16 -24
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +150 -0
- package/src/form/field_bindings/{MultiSelectBinding.tsx → MultiSelectFieldBinding.tsx} +25 -20
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +9 -7
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +27 -18
- package/src/form/field_bindings/RepeatFieldBinding.tsx +27 -17
- package/src/form/field_bindings/SelectFieldBinding.tsx +17 -10
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +36 -17
- package/src/form/field_bindings/SwitchFieldBinding.tsx +9 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +26 -23
- package/src/form/index.tsx +4 -9
- package/src/form/useClearRestoreValue.tsx +2 -2
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/save.ts +5 -2
- package/src/hooks/data/useDataSource.tsx +11 -3
- package/src/hooks/useBuildNavigationController.tsx +10 -3
- package/src/hooks/useProjectLog.tsx +18 -7
- package/src/internal/useBuildDataSource.ts +59 -76
- package/src/internal/useBuildSideDialogsController.tsx +1 -0
- package/src/internal/useBuildSideEntityController.tsx +17 -4
- package/src/internal/useUnsavedChangesDialog.tsx +3 -1
- package/src/preview/PropertyPreview.tsx +2 -2
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +4 -2
- package/src/preview/components/ReferencePreview.tsx +2 -13
- package/src/preview/components/UrlComponentPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/MapPropertyPreview.tsx +1 -1
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +2 -2
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +2 -2
- package/src/types/auth.tsx +1 -1
- package/src/types/collections.ts +15 -4
- package/src/types/datasource.ts +42 -27
- package/src/types/entities.ts +2 -0
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/fields.tsx +23 -17
- package/src/types/navigation.ts +1 -0
- package/src/types/properties.ts +18 -17
- package/src/types/side_dialogs_controller.tsx +13 -0
- package/src/types/storage.ts +82 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +14 -9
- package/src/util/icons.tsx +8 -2
- package/src/util/index.ts +1 -0
- package/src/util/plurals.ts +0 -2
- package/src/util/property_utils.tsx +1 -1
- package/src/util/references.ts +3 -0
- package/src/util/resolutions.ts +43 -11
- package/src/util/storage.ts +6 -2
- package/src/util/useStorageUploadController.tsx +15 -7
- package/dist/components/PropertyIdCopyTooltipContent.d.ts +0 -3
- package/dist/form/PropertiesForm.d.ts +0 -8
- package/dist/form/field_bindings/MarkdownFieldBinding.d.ts +0 -9
- package/src/components/PropertyIdCopyTooltipContent.tsx +0 -27
- package/src/form/PropertiesForm.tsx +0 -81
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +0 -695
package/src/types/collections.ts
CHANGED
|
@@ -51,6 +51,12 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
51
51
|
*/
|
|
52
52
|
path: string;
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Optional database id of this collection. If not specified, the default
|
|
56
|
+
* database id will be used.
|
|
57
|
+
*/
|
|
58
|
+
databaseId?: string;
|
|
59
|
+
|
|
54
60
|
/**
|
|
55
61
|
* If this collection is a top level navigation entry, you can set this
|
|
56
62
|
* property to `true` to indicate that this collection is a collection group.
|
|
@@ -61,7 +67,8 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
61
67
|
* Icon key to use in this collection.
|
|
62
68
|
* You can use any of the icons in the Material specs:
|
|
63
69
|
* https://fonts.google.com/icons
|
|
64
|
-
* e.g. 'account_tree' or 'person'
|
|
70
|
+
* e.g. 'account_tree' or 'person'.
|
|
71
|
+
* Find all the icons in https://firecms.co/docs/icons
|
|
65
72
|
*/
|
|
66
73
|
icon?: string;
|
|
67
74
|
|
|
@@ -82,7 +89,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
82
89
|
* as the title in entity related views and references.
|
|
83
90
|
* If not specified, the first property simple text property will be used.
|
|
84
91
|
*/
|
|
85
|
-
titleProperty?: keyof M
|
|
92
|
+
titleProperty?: keyof M;
|
|
86
93
|
|
|
87
94
|
/**
|
|
88
95
|
* Can this collection be edited by the end user.
|
|
@@ -304,6 +311,11 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
304
311
|
* Width of the side dialog (in pixels) when opening an entity in this collection.
|
|
305
312
|
*/
|
|
306
313
|
sideDialogWidth?: number | string;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Default preview properties displayed when this collection is referenced to.
|
|
317
|
+
*/
|
|
318
|
+
previewProperties?: string[];
|
|
307
319
|
}
|
|
308
320
|
|
|
309
321
|
/**
|
|
@@ -362,14 +374,13 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, Use
|
|
|
362
374
|
/**
|
|
363
375
|
* Use this controller to retrieve the selected entities or modify them in
|
|
364
376
|
* an {@link EntityCollection}
|
|
365
|
-
* If you want to pass a `SelectionController` to
|
|
366
377
|
* @group Models
|
|
367
378
|
*/
|
|
368
379
|
export type SelectionController<M extends Record<string, any> = any> = {
|
|
369
380
|
selectedEntities: Entity<M>[];
|
|
370
381
|
setSelectedEntities: Dispatch<SetStateAction<Entity<M>[]>>;
|
|
371
382
|
isEntitySelected: (entity: Entity<M>) => boolean;
|
|
372
|
-
toggleEntitySelection: (entity: Entity<M
|
|
383
|
+
toggleEntitySelection: (entity: Entity<M>, newSelectedState?: boolean) => void;
|
|
373
384
|
}
|
|
374
385
|
|
|
375
386
|
/**
|
package/src/types/datasource.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entity,
|
|
1
|
+
import { Entity, EntityStatus, EntityValues } from "./entities";
|
|
2
2
|
import { EntityCollection, FilterValues } from "./collections";
|
|
3
3
|
import { ResolvedEntityCollection } from "./resolved_entities";
|
|
4
4
|
import { FireCMSContext } from "./firecms_context";
|
|
@@ -18,6 +18,7 @@ export interface FetchEntityProps<M extends Record<string, any> = any> {
|
|
|
18
18
|
export type ListenEntityProps<M extends Record<string, any> = any> =
|
|
19
19
|
FetchEntityProps<M>
|
|
20
20
|
& {
|
|
21
|
+
databaseId?: string;
|
|
21
22
|
onUpdate: (entity: Entity<M>) => void,
|
|
22
23
|
onError?: (error: Error) => void,
|
|
23
24
|
}
|
|
@@ -63,12 +64,12 @@ export interface SaveEntityProps<M extends Record<string, any> = any> {
|
|
|
63
64
|
*/
|
|
64
65
|
export interface DeleteEntityProps<M extends Record<string, any> = any> {
|
|
65
66
|
entity: Entity<M>;
|
|
67
|
+
collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* A Firestore implementation of this interface can be found in {@link useFirestoreDataSource}
|
|
71
|
+
* Component in charge of communicating with the data source.
|
|
72
|
+
* Usually you won't need to implement this interface, but a {@link DataSourceDelegate} instead.
|
|
72
73
|
* @group Datasource
|
|
73
74
|
*/
|
|
74
75
|
export interface DataSource {
|
|
@@ -182,7 +183,8 @@ export interface DataSource {
|
|
|
182
183
|
*/
|
|
183
184
|
deleteEntity<M extends Record<string, any> = any>(
|
|
184
185
|
{
|
|
185
|
-
entity
|
|
186
|
+
entity,
|
|
187
|
+
collection
|
|
186
188
|
}: DeleteEntityProps<M>
|
|
187
189
|
): Promise<void>;
|
|
188
190
|
|
|
@@ -191,7 +193,7 @@ export interface DataSource {
|
|
|
191
193
|
* @param path Collection path
|
|
192
194
|
* @param name of the property
|
|
193
195
|
* @param value
|
|
194
|
-
* @param
|
|
196
|
+
* @param collection
|
|
195
197
|
* @param entityId
|
|
196
198
|
* @return `true` if there are no other fields besides the given entity
|
|
197
199
|
*/
|
|
@@ -199,13 +201,14 @@ export interface DataSource {
|
|
|
199
201
|
path: string,
|
|
200
202
|
name: string,
|
|
201
203
|
value: any,
|
|
202
|
-
entityId?: string
|
|
204
|
+
entityId?: string,
|
|
205
|
+
collection?: EntityCollection
|
|
203
206
|
): Promise<boolean>;
|
|
204
207
|
|
|
205
208
|
/**
|
|
206
209
|
* Generate an id for a new entity
|
|
207
210
|
*/
|
|
208
|
-
generateEntityId(path: string): string;
|
|
211
|
+
generateEntityId(path: string, collection: EntityCollection): string;
|
|
209
212
|
|
|
210
213
|
/**
|
|
211
214
|
* Count the number of entities in a collection
|
|
@@ -239,21 +242,29 @@ export type FilterCombinationValidProps = {
|
|
|
239
242
|
sortBy?: [string, "asc" | "desc"];
|
|
240
243
|
};
|
|
241
244
|
|
|
242
|
-
export type SaveEntityDelegateProps<M extends Record<string, any> = any> =
|
|
245
|
+
export type SaveEntityDelegateProps<M extends Record<string, any> = any> = SaveEntityProps<M>;
|
|
243
246
|
|
|
244
|
-
export type FetchCollectionDelegateProps<M extends Record<string, any> = any> =
|
|
245
|
-
Omit<FetchCollectionProps<M>, "collection">
|
|
246
|
-
& {
|
|
247
|
-
isCollectionGroup?: boolean
|
|
248
|
-
};
|
|
247
|
+
export type FetchCollectionDelegateProps<M extends Record<string, any> = any> = FetchCollectionProps<M>;
|
|
249
248
|
|
|
250
|
-
export type ListenCollectionDelegateProps<M extends Record<string, any> = any> =
|
|
251
|
-
ListenCollectionProps<M>
|
|
252
|
-
& {
|
|
253
|
-
isCollectionGroup?: boolean;
|
|
254
|
-
};
|
|
249
|
+
export type ListenCollectionDelegateProps<M extends Record<string, any> = any> = ListenCollectionProps<M>;
|
|
255
250
|
|
|
256
251
|
export interface DataSourceDelegate {
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Key that identifies this data source delegate
|
|
255
|
+
*/
|
|
256
|
+
key: string;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* If the data source has been initialised
|
|
260
|
+
*/
|
|
261
|
+
initialised?: boolean;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* If the user is authenticated to use the data source
|
|
265
|
+
*/
|
|
266
|
+
authenticated?: boolean;
|
|
267
|
+
|
|
257
268
|
/**
|
|
258
269
|
* Fetch data from a collection
|
|
259
270
|
* @param path
|
|
@@ -311,7 +322,7 @@ export interface DataSourceDelegate {
|
|
|
311
322
|
fetchEntity<M extends Record<string, any> = any>({
|
|
312
323
|
path,
|
|
313
324
|
entityId,
|
|
314
|
-
}:
|
|
325
|
+
}: FetchEntityProps<M>): Promise<Entity<M> | undefined>;
|
|
315
326
|
|
|
316
327
|
/**
|
|
317
328
|
* Get realtime updates on one entity.
|
|
@@ -327,13 +338,13 @@ export interface DataSourceDelegate {
|
|
|
327
338
|
entityId,
|
|
328
339
|
onUpdate,
|
|
329
340
|
onError
|
|
330
|
-
}:
|
|
341
|
+
}: ListenEntityProps<M>): () => void;
|
|
331
342
|
|
|
332
343
|
/**
|
|
333
344
|
* Save entity to the specified path
|
|
334
345
|
* @param path
|
|
335
|
-
* @param
|
|
336
|
-
* @param
|
|
346
|
+
* @param entityId
|
|
347
|
+
* @param values
|
|
337
348
|
* @param status
|
|
338
349
|
*/
|
|
339
350
|
saveEntity<M extends Record<string, any> = any>({
|
|
@@ -356,14 +367,15 @@ export interface DataSourceDelegate {
|
|
|
356
367
|
* @param name of the property
|
|
357
368
|
* @param value
|
|
358
369
|
* @param entityId
|
|
370
|
+
* @param collection
|
|
359
371
|
* @return `true` if there are no other fields besides the given entity
|
|
360
372
|
*/
|
|
361
|
-
checkUniqueField(path: string, name: string, value: any, entityId?: string): Promise<boolean>;
|
|
373
|
+
checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection): Promise<boolean>;
|
|
362
374
|
|
|
363
375
|
/**
|
|
364
376
|
* Generate an id for a new entity
|
|
365
377
|
*/
|
|
366
|
-
generateEntityId(path: string): string;
|
|
378
|
+
generateEntityId(path: string, collection?: EntityCollection): string;
|
|
367
379
|
|
|
368
380
|
/**
|
|
369
381
|
* Count the number of entities in a collection
|
|
@@ -374,12 +386,14 @@ export interface DataSourceDelegate {
|
|
|
374
386
|
* Check if the given filter combination is valid
|
|
375
387
|
* @param props
|
|
376
388
|
*/
|
|
377
|
-
isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection">
|
|
389
|
+
isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection"> & {
|
|
390
|
+
databaseId?: string
|
|
391
|
+
}): boolean;
|
|
378
392
|
|
|
379
393
|
/**
|
|
380
394
|
* Get the object to generate the current time in the datasource
|
|
381
395
|
*/
|
|
382
|
-
currentTime()
|
|
396
|
+
currentTime?: () => any;
|
|
383
397
|
|
|
384
398
|
delegateToCMSModel: (data: any) => any;
|
|
385
399
|
|
|
@@ -390,6 +404,7 @@ export interface DataSourceDelegate {
|
|
|
390
404
|
initTextSearch?: (props: {
|
|
391
405
|
context: FireCMSContext,
|
|
392
406
|
path: string,
|
|
407
|
+
databaseId?: string,
|
|
393
408
|
collection: EntityCollection,
|
|
394
409
|
parentCollectionIds?: string[]
|
|
395
410
|
}) => Promise<boolean>;
|
package/src/types/entities.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataSource } from "./datasource";
|
|
1
|
+
import { DataSource, DataSourceDelegate } from "./datasource";
|
|
2
2
|
import { StorageSource } from "./storage";
|
|
3
3
|
|
|
4
4
|
export type EntityOverrides = {
|
|
5
|
-
|
|
5
|
+
dataSourceDelegate?: DataSourceDelegate;
|
|
6
6
|
storageSource?: StorageSource;
|
|
7
7
|
};
|
package/src/types/fields.tsx
CHANGED
|
@@ -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
|
|
|
@@ -62,7 +62,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
62
62
|
/**
|
|
63
63
|
* Property related to this field
|
|
64
64
|
*/
|
|
65
|
-
property: ResolvedProperty<T>;
|
|
65
|
+
property: Property<T> | ResolvedProperty<T>;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Should this field include a description
|
|
@@ -81,14 +81,9 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
81
81
|
partOfArray?: boolean;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
85
|
-
*/
|
|
86
|
-
partOfBlock?: boolean;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Is this field being rendered in the entity table popup
|
|
84
|
+
* Should this field render with the minimal amount of UI elements
|
|
90
85
|
*/
|
|
91
|
-
|
|
86
|
+
minimalistView?: boolean;
|
|
92
87
|
|
|
93
88
|
/**
|
|
94
89
|
* Should this field autofocus on mount
|
|
@@ -98,7 +93,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
98
93
|
/**
|
|
99
94
|
* Additional properties set by the developer
|
|
100
95
|
*/
|
|
101
|
-
customProps
|
|
96
|
+
customProps: CustomProps
|
|
102
97
|
|
|
103
98
|
/**
|
|
104
99
|
* Additional values related to the state of the form or the entity
|
|
@@ -110,6 +105,11 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
110
105
|
*/
|
|
111
106
|
disabled?: boolean;
|
|
112
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Size of the field
|
|
110
|
+
*/
|
|
111
|
+
size?: "smallest" | "small" | "medium";
|
|
112
|
+
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -144,7 +144,7 @@ export interface FormContext<M extends Record<string, any> = any> {
|
|
|
144
144
|
/**
|
|
145
145
|
* Entity id, it can be null if it's a new entity
|
|
146
146
|
*/
|
|
147
|
-
entityId
|
|
147
|
+
entityId: string;
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* Path this entity is located at
|
|
@@ -192,11 +192,6 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
192
192
|
*/
|
|
193
193
|
underlyingValueHasChanged?: boolean;
|
|
194
194
|
|
|
195
|
-
/**
|
|
196
|
-
* Is this field being rendered in a table
|
|
197
|
-
*/
|
|
198
|
-
tableMode?: boolean;
|
|
199
|
-
|
|
200
195
|
/**
|
|
201
196
|
* Is this field part of an array
|
|
202
197
|
*/
|
|
@@ -205,7 +200,7 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
205
200
|
/**
|
|
206
201
|
* Is this field part of a block (oneOf array)
|
|
207
202
|
*/
|
|
208
|
-
|
|
203
|
+
minimalistView?: boolean;
|
|
209
204
|
|
|
210
205
|
/**
|
|
211
206
|
* Should the field take focus when rendered. When opening the popup view
|
|
@@ -217,4 +212,15 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
217
212
|
* Should this field be disabled
|
|
218
213
|
*/
|
|
219
214
|
disabled?: boolean;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Index of the field in the array.
|
|
218
|
+
* Only used when the field is part of an array.
|
|
219
|
+
*/
|
|
220
|
+
index?: number;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* The size of the field
|
|
224
|
+
*/
|
|
225
|
+
size?: "smallest" | "small" | "medium",
|
|
220
226
|
}
|
package/src/types/navigation.ts
CHANGED
package/src/types/properties.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type DataType<T extends CMSType = CMSType> =
|
|
|
17
17
|
T extends GeoPoint ? "geopoint" :
|
|
18
18
|
T extends Vector ? "vector" :
|
|
19
19
|
T extends EntityReference ? "reference" :
|
|
20
|
-
T extends Array<
|
|
20
|
+
T extends Array<any> ? "array" :
|
|
21
21
|
T extends Record<string, any> ? "map" : never;
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -49,7 +49,7 @@ export type AnyProperty =
|
|
|
49
49
|
/**
|
|
50
50
|
* @group Entity properties
|
|
51
51
|
*/
|
|
52
|
-
export type Property<T extends CMSType =
|
|
52
|
+
export type Property<T extends CMSType = any> =
|
|
53
53
|
T extends string ? StringProperty :
|
|
54
54
|
T extends number ? NumberProperty :
|
|
55
55
|
T extends boolean ? BooleanProperty :
|
|
@@ -277,6 +277,7 @@ export type PropertyBuilder<T extends CMSType = any, M extends Record<string, an
|
|
|
277
277
|
values,
|
|
278
278
|
previousValues,
|
|
279
279
|
propertyValue,
|
|
280
|
+
index,
|
|
280
281
|
path,
|
|
281
282
|
entityId
|
|
282
283
|
}: PropertyBuilderProps<M>) => Property<T> | null;
|
|
@@ -404,7 +405,7 @@ export interface StringProperty extends BaseProperty<string> {
|
|
|
404
405
|
/**
|
|
405
406
|
* @group Entity properties
|
|
406
407
|
*/
|
|
407
|
-
export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSType =
|
|
408
|
+
export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSType = any> extends BaseProperty<T> {
|
|
408
409
|
|
|
409
410
|
dataType: "array";
|
|
410
411
|
|
|
@@ -733,13 +734,13 @@ export type StorageConfig = {
|
|
|
733
734
|
* You can use this prop to customize the uploaded filename.
|
|
734
735
|
* You can use a function as a callback or a string where you
|
|
735
736
|
* specify some placeholders that get replaced with the corresponding values.
|
|
736
|
-
* - {file} - Full file name
|
|
737
|
-
* - {file.name} - Name of the file without extension
|
|
738
|
-
* - {file.ext} - Extension of the file
|
|
739
|
-
* - {rand} - Random value used to avoid name collisions
|
|
740
|
-
* - {entityId} - ID of the entity
|
|
741
|
-
* - {propertyKey} - ID of this property
|
|
742
|
-
* - {path} - Path of this entity
|
|
737
|
+
* - `{file}` - Full file name
|
|
738
|
+
* - `{file.name}` - Name of the file without extension
|
|
739
|
+
* - `{file.ext}` - Extension of the file
|
|
740
|
+
* - `{rand}` - Random value used to avoid name collisions
|
|
741
|
+
* - `{entityId}` - ID of the entity
|
|
742
|
+
* - `{propertyKey}` - ID of this property
|
|
743
|
+
* - `{path}` - Path of this entity
|
|
743
744
|
*
|
|
744
745
|
* @param context
|
|
745
746
|
*/
|
|
@@ -750,13 +751,13 @@ export type StorageConfig = {
|
|
|
750
751
|
*
|
|
751
752
|
* You can use a function as a callback or a string where you
|
|
752
753
|
* specify some placeholders that get replaced with the corresponding values.
|
|
753
|
-
* - {file} - Full file name
|
|
754
|
-
* - {file.name} - Name of the file without extension
|
|
755
|
-
* - {file.ext} - Extension of the file
|
|
756
|
-
* - {rand} - Random value used to avoid name collisions
|
|
757
|
-
* - {entityId} - ID of the entity
|
|
758
|
-
* - {propertyKey} - ID of this property
|
|
759
|
-
* - {path} - Path of this entity
|
|
754
|
+
* - `{file}` - Full file name
|
|
755
|
+
* - `{file.name}` - Name of the file without extension
|
|
756
|
+
* - `{file.ext}` - Extension of the file
|
|
757
|
+
* - `{rand}` - Random value used to avoid name collisions
|
|
758
|
+
* - `{entityId}` - ID of the entity
|
|
759
|
+
* - `{propertyKey}` - ID of this property
|
|
760
|
+
* - `{path}` - Path of this entity
|
|
760
761
|
*/
|
|
761
762
|
storagePath: string | ((context: UploadedFileContext) => string);
|
|
762
763
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Controller to open the side dialog
|
|
3
5
|
* @group Hooks and utilities
|
|
@@ -14,6 +16,12 @@ export interface SideDialogsController {
|
|
|
14
16
|
*/
|
|
15
17
|
sidePanels: SideDialogPanelProps[];
|
|
16
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Override the current side panels
|
|
21
|
+
* @param panels
|
|
22
|
+
*/
|
|
23
|
+
setSidePanels: (panels: SideDialogPanelProps[]) => void;
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* Open one or multiple side panels
|
|
19
27
|
* @param props
|
|
@@ -65,4 +73,9 @@ export interface SideDialogPanelProps {
|
|
|
65
73
|
* Callback when the panel is closed
|
|
66
74
|
*/
|
|
67
75
|
onClose?: () => void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Use this prop to store additional data in the panel
|
|
79
|
+
*/
|
|
80
|
+
additional?: any;
|
|
68
81
|
}
|
package/src/types/storage.ts
CHANGED
|
@@ -102,4 +102,86 @@ export interface StorageSource {
|
|
|
102
102
|
* @param bucket
|
|
103
103
|
*/
|
|
104
104
|
getFile: (path: string, bucket?: string) => Promise<File | null>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Delete a file.
|
|
108
|
+
* @param path
|
|
109
|
+
* @param bucket
|
|
110
|
+
*/
|
|
111
|
+
deleteFile: (path: string, bucket?: string) => Promise<void>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* List the contents of a path.
|
|
115
|
+
* @param path
|
|
116
|
+
* @param options
|
|
117
|
+
*/
|
|
118
|
+
list: (path: string, options?: {
|
|
119
|
+
bucket?: string,
|
|
120
|
+
maxResults?: number,
|
|
121
|
+
pageToken?: string
|
|
122
|
+
}) => Promise<StorageListResult>;
|
|
123
|
+
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Result returned by list().
|
|
128
|
+
* @public
|
|
129
|
+
*/
|
|
130
|
+
export declare interface StorageListResult {
|
|
131
|
+
/**
|
|
132
|
+
* References to prefixes (sub-folders). You can call list() on them to
|
|
133
|
+
* get its contents.
|
|
134
|
+
*
|
|
135
|
+
* Folders are implicit based on '/' in the object paths.
|
|
136
|
+
* For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
|
|
137
|
+
* will return '/a/b' as a prefix.
|
|
138
|
+
*/
|
|
139
|
+
prefixes: StorageReference[];
|
|
140
|
+
/**
|
|
141
|
+
* Objects in this directory.
|
|
142
|
+
* You can call getMetadata() and getDownloadUrl() on them.
|
|
143
|
+
*/
|
|
144
|
+
items: StorageReference[];
|
|
145
|
+
/**
|
|
146
|
+
* If set, there might be more results for this list. Use this token to resume the list.
|
|
147
|
+
*/
|
|
148
|
+
nextPageToken?: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Represents a reference to a Google Cloud Storage object. Developers can
|
|
153
|
+
* upload, download, and delete objects, as well as get/set object metadata.
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
export declare interface StorageReference {
|
|
157
|
+
/**
|
|
158
|
+
* Returns a gs:// URL for this object in the form
|
|
159
|
+
* `gs://<bucket>/<path>/<to>/<object>`
|
|
160
|
+
* @returns The gs:// URL.
|
|
161
|
+
*/
|
|
162
|
+
toString(): string;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A reference to the root of this object's bucket.
|
|
166
|
+
*/
|
|
167
|
+
root: StorageReference;
|
|
168
|
+
/**
|
|
169
|
+
* The name of the bucket containing this reference's object.
|
|
170
|
+
*/
|
|
171
|
+
bucket: string;
|
|
172
|
+
/**
|
|
173
|
+
* The full path of this object.
|
|
174
|
+
*/
|
|
175
|
+
fullPath: string;
|
|
176
|
+
/**
|
|
177
|
+
* The short name of this object, which is the last component of the full path.
|
|
178
|
+
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
|
|
179
|
+
*/
|
|
180
|
+
name: string;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* A reference pointing to the parent location of this reference, or null if
|
|
184
|
+
* this reference is the root.
|
|
185
|
+
*/
|
|
186
|
+
parent: StorageReference | null;
|
|
105
187
|
}
|
package/src/util/entities.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "../types";
|
|
16
16
|
import { DEFAULT_ONE_OF_TYPE, DEFAULT_ONE_OF_VALUE } from "./common";
|
|
17
17
|
|
|
18
|
-
export function isReadOnly(property: Property | ResolvedProperty): boolean {
|
|
18
|
+
export function isReadOnly(property: Property<any> | ResolvedProperty<any>): boolean {
|
|
19
19
|
if (property.readOnly)
|
|
20
20
|
return true;
|
|
21
21
|
if (property.dataType === "date") {
|
package/src/util/icon_list.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { iconSynonyms } from "./icon_synonyms";
|
|
2
2
|
import { iconKeys } from "@firecms/ui";
|
|
3
|
+
import Fuse from "fuse.js";
|
|
3
4
|
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import * as JsSearch from "js-search";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
iconsSearch.addIndex("synonyms");
|
|
9
|
-
|
|
10
|
-
iconsSearch.addDocuments(iconKeys
|
|
6
|
+
const map = iconKeys
|
|
11
7
|
.map((importName) => {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
const iconSynonym = importName in iconSynonyms ? iconSynonyms[importName] : "";
|
|
12
10
|
return {
|
|
13
11
|
key: importName,
|
|
14
|
-
|
|
15
|
-
synonyms: iconSynonyms[importName] ?? [],
|
|
12
|
+
synonyms: iconSynonym,
|
|
16
13
|
}
|
|
17
|
-
})
|
|
14
|
+
});
|
|
15
|
+
export const iconsSearch = new Fuse(map, {
|
|
16
|
+
isCaseSensitive: false,
|
|
17
|
+
shouldSort: true,
|
|
18
|
+
distance: 0,
|
|
19
|
+
keys: ["key", "synonyms"]
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
|
package/src/util/icons.tsx
CHANGED
|
@@ -22,7 +22,13 @@ export type IconViewProps = {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const IconForView = React.memo(
|
|
25
|
-
function IconForView({
|
|
25
|
+
function IconForView({
|
|
26
|
+
collectionOrView,
|
|
27
|
+
className,
|
|
28
|
+
size = "medium"
|
|
29
|
+
}: {
|
|
30
|
+
collectionOrView?: IconViewProps, className?: string, size?: "smallest" | "small" | "medium" | "large" | number,
|
|
31
|
+
}): React.ReactElement {
|
|
26
32
|
if (!collectionOrView) return <></>;
|
|
27
33
|
const icon = getIcon(collectionOrView.icon, className);
|
|
28
34
|
if (collectionOrView?.icon && icon)
|
|
@@ -45,7 +51,7 @@ export const IconForView = React.memo(
|
|
|
45
51
|
if (!key)
|
|
46
52
|
key = coolIconKeys[hashString(collectionOrView.path) % iconsCount];
|
|
47
53
|
|
|
48
|
-
return <Icon iconKey={key} size={
|
|
54
|
+
return <Icon iconKey={key} size={size} className={className}/>;
|
|
49
55
|
}, (prevProps, nextProps) => {
|
|
50
56
|
return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon);
|
|
51
57
|
});
|
package/src/util/index.ts
CHANGED
package/src/util/plurals.ts
CHANGED
|
@@ -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}
|
|
@@ -92,7 +91,6 @@ export function plural(word: string, amount?: number): string {
|
|
|
92
91
|
/**
|
|
93
92
|
* Returns the singular of an English word.
|
|
94
93
|
*
|
|
95
|
-
* @export
|
|
96
94
|
* @param {string} word
|
|
97
95
|
* @param {number} [amount]
|
|
98
96
|
* @returns {string}
|
|
@@ -35,7 +35,7 @@ export function getIconForWidget(widget: PropertyConfig | undefined,
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function getIconForProperty(
|
|
38
|
-
property: PropertyOrBuilder | ResolvedProperty
|
|
38
|
+
property: PropertyOrBuilder<any> | ResolvedProperty<any>,
|
|
39
39
|
size: "small" | "medium" | "large" = "small",
|
|
40
40
|
fields: Record<string, PropertyConfig> = {}
|
|
41
41
|
): React.ReactNode {
|
package/src/util/references.ts
CHANGED
|
@@ -9,6 +9,9 @@ export function getEntityPreviewKeys(targetCollection: EntityCollection<any>,
|
|
|
9
9
|
limit = 3) {
|
|
10
10
|
const allProperties = Object.keys(targetCollection.properties);
|
|
11
11
|
let listProperties = previewProperties?.filter(p => allProperties.includes(p as string));
|
|
12
|
+
if (!listProperties && targetCollection.previewProperties) {
|
|
13
|
+
listProperties = targetCollection.previewProperties?.filter(p => allProperties.includes(p as string));
|
|
14
|
+
}
|
|
12
15
|
if (listProperties && listProperties.length > 0) {
|
|
13
16
|
return listProperties;
|
|
14
17
|
} else {
|