@firecms/core 3.0.0-alpha.27 → 3.0.0-alpha.29
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/components/Popover.d.ts +3 -1
- package/dist/core/FireCMS.d.ts +2 -2
- package/dist/core/builders.d.ts +5 -5
- package/dist/core/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +4 -2
- package/dist/core/components/EntityCollectionTable/filters/ReferenceFilterField.d.ts +3 -3
- package/dist/core/components/EntityCollectionTable/internal/EntityCollectionRowActions.d.ts +15 -11
- package/dist/core/components/EntityCollectionTable/internal/default_entity_actions.d.ts +5 -0
- package/dist/core/components/EntityCollectionTable/types.d.ts +1 -37
- package/dist/core/components/FieldConfigBadge.d.ts +3 -3
- package/dist/core/components/VirtualTable/VirtualTableHeader.d.ts +2 -2
- package/dist/core/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/core/contexts/DialogsProvider.d.ts +4 -0
- package/dist/core/form_field_configs.d.ts +3 -3
- package/dist/core/index.d.ts +1 -1
- package/dist/core/internal/useBuildNavigationContext.d.ts +3 -3
- package/dist/core/util/property_utils.d.ts +5 -5
- package/dist/core/util/references.d.ts +2 -2
- package/dist/core/util/resolutions.d.ts +6 -6
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useBuildDataSource.d.ts +23 -0
- package/dist/hooks/useDialogsController.d.ts +11 -0
- package/dist/index.es.js +8996 -8583
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +67 -67
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.d.ts +1 -1
- package/dist/types/collections.d.ts +36 -13
- package/dist/types/datasource.d.ts +120 -11
- package/dist/types/dialogs_controller.d.ts +30 -0
- package/dist/types/entity_actions.d.ts +33 -0
- package/dist/types/fields.d.ts +1 -1
- package/dist/types/firecms.d.ts +8 -8
- package/dist/types/firecms_context.d.ts +10 -3
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +3 -3
- package/dist/types/plugins.d.ts +11 -10
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/{field_config.d.ts → property_config.d.ts} +3 -4
- package/package.json +3 -3
- package/src/components/Popover.tsx +10 -3
- package/src/components/Sheet.tsx +1 -0
- package/src/components/TextareaAutosize.tsx +2 -1
- package/src/core/FireCMS.tsx +9 -6
- package/src/core/builders.ts +11 -11
- package/src/core/components/ArrayContainer.tsx +1 -1
- package/src/core/components/EntityCollectionTable/EntityCollectionTable.tsx +20 -13
- package/src/core/components/EntityCollectionTable/EntityCollectionTableProps.tsx +5 -2
- package/src/core/components/EntityCollectionTable/filters/ReferenceFilterField.tsx +11 -6
- package/src/core/components/EntityCollectionTable/internal/EntityCollectionRowActions.tsx +96 -79
- package/src/core/components/EntityCollectionTable/internal/PropertyTableCell.tsx +2 -2
- package/src/core/components/EntityCollectionTable/internal/default_entity_actions.tsx +107 -0
- package/src/core/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +6 -2
- package/src/core/components/EntityCollectionTable/types.tsx +1 -56
- package/src/core/components/EntityCollectionView/EntityCollectionView.tsx +67 -43
- package/src/core/components/FieldConfigBadge.tsx +4 -4
- package/src/core/components/ReferenceSelectionInner.tsx +2 -2
- package/src/core/components/VirtualTable/VirtualTable.tsx +4 -6
- package/src/core/components/VirtualTable/VirtualTableHeader.tsx +21 -18
- package/src/core/components/VirtualTable/VirtualTableProps.tsx +1 -1
- package/src/core/contexts/DialogsProvider.tsx +50 -0
- package/src/core/form_field_configs.tsx +5 -5
- package/src/core/index.tsx +1 -1
- package/src/core/internal/useBuildNavigationContext.tsx +13 -13
- package/src/core/internal/useBuildSideEntityController.tsx +9 -1
- package/src/core/util/property_utils.tsx +5 -5
- package/src/core/util/references.ts +2 -2
- package/src/core/util/resolutions.ts +16 -11
- package/src/form/EntityForm.tsx +64 -7
- package/src/form/PropertyFieldBinding.tsx +4 -4
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +4 -6
- package/src/hooks/index.tsx +1 -0
- package/src/hooks/useBuildDataSource.ts +351 -0
- package/src/hooks/useDialogsController.tsx +14 -0
- package/src/hooks/useFireCMSContext.tsx +5 -11
- package/src/preview/property_previews/StringPropertyPreview.tsx +4 -2
- package/src/styles.ts +1 -1
- package/src/types/collections.ts +36 -17
- package/src/types/datasource.ts +174 -10
- package/src/types/dialogs_controller.tsx +31 -0
- package/src/types/entity_actions.tsx +36 -0
- package/src/types/fields.tsx +1 -1
- package/src/types/firecms.tsx +8 -8
- package/src/types/firecms_context.tsx +11 -3
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +3 -3
- package/src/types/plugins.tsx +11 -10
- package/src/types/properties.ts +1 -1
- package/src/types/{field_config.tsx → property_config.tsx} +3 -4
- /package/dist/core/contexts/{SnackbarContext.d.ts → SnackbarProvider.d.ts} +0 -0
- /package/src/core/contexts/{SnackbarContext.tsx → SnackbarProvider.tsx} +0 -0
package/src/types/datasource.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Entity, EntityStatus, EntityValues } from "./entities";
|
|
1
|
+
import { Entity, EntityReference, EntityStatus, EntityValues, GeoPoint } from "./entities";
|
|
2
2
|
import { EntityCollection, FilterValues } from "./collections";
|
|
3
|
-
import { ResolvedEntityCollection
|
|
3
|
+
import { ResolvedEntityCollection } from "./resolved_entities";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @category Datasource
|
|
@@ -198,7 +198,6 @@ export interface DataSource {
|
|
|
198
198
|
path: string,
|
|
199
199
|
name: string,
|
|
200
200
|
value: any,
|
|
201
|
-
property: ResolvedProperty,
|
|
202
201
|
entityId?: string
|
|
203
202
|
): Promise<boolean>;
|
|
204
203
|
|
|
@@ -214,12 +213,177 @@ export interface DataSource {
|
|
|
214
213
|
|
|
215
214
|
/**
|
|
216
215
|
* Check if the given filter combination is valid
|
|
217
|
-
* @param
|
|
216
|
+
* @param props
|
|
218
217
|
*/
|
|
219
|
-
isFilterCombinationValid?(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
isFilterCombinationValid?(props: FilterCombinationValidProps): boolean;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export type FilterCombinationValidProps = {
|
|
222
|
+
path: string;
|
|
223
|
+
collection: EntityCollection<any>;
|
|
224
|
+
filterValues: FilterValues<any>;
|
|
225
|
+
sortBy?: [string, "asc" | "desc"];
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export type SaveEntityDelegateProps<M extends Record<string, any> = any> = Omit<SaveEntityProps<M>, "collection">;
|
|
229
|
+
|
|
230
|
+
export type FetchCollectionDelegateProps<M extends Record<string, any> = any> =
|
|
231
|
+
Omit<FetchCollectionProps<M>, "collection">
|
|
232
|
+
& {
|
|
233
|
+
isCollectionGroup?: boolean
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export type ListenCollectionDelegateProps<M extends Record<string, any> = any> =
|
|
237
|
+
Omit<ListenCollectionProps<M>, "collection">
|
|
238
|
+
& {
|
|
239
|
+
isCollectionGroup?: boolean
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export interface DataSourceDelegate {
|
|
243
|
+
/**
|
|
244
|
+
* Fetch data from a collection
|
|
245
|
+
* @param path
|
|
246
|
+
* @param filter
|
|
247
|
+
* @param limit
|
|
248
|
+
* @param startAfter
|
|
249
|
+
* @param orderBy
|
|
250
|
+
* @param order
|
|
251
|
+
* @param searchString
|
|
252
|
+
* @return Function to cancel subscription
|
|
253
|
+
* @see useCollectionFetch if you need this functionality implemented as a hook
|
|
254
|
+
*/
|
|
255
|
+
fetchCollection<M extends Record<string, any> = any>({
|
|
256
|
+
path,
|
|
257
|
+
filter,
|
|
258
|
+
limit,
|
|
259
|
+
startAfter,
|
|
260
|
+
orderBy,
|
|
261
|
+
order,
|
|
262
|
+
searchString
|
|
263
|
+
}: FetchCollectionDelegateProps<M>): Promise<Entity<M>[]>;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Listen to a collection in a given path. If you don't implement this method
|
|
267
|
+
* `fetchCollection` will be used instead, with no real time updates.
|
|
268
|
+
* @param path
|
|
269
|
+
* @param onUpdate
|
|
270
|
+
* @param onError
|
|
271
|
+
* @param filter
|
|
272
|
+
* @param limit
|
|
273
|
+
* @param startAfter
|
|
274
|
+
* @param orderBy
|
|
275
|
+
* @param order
|
|
276
|
+
* @param searchString
|
|
277
|
+
* @return Function to cancel subscription
|
|
278
|
+
* @see useCollectionFetch if you need this functionality implemented as a hook
|
|
279
|
+
*/
|
|
280
|
+
listenCollection?<M extends Record<string, any> = any>({
|
|
281
|
+
path,
|
|
282
|
+
filter,
|
|
283
|
+
limit,
|
|
284
|
+
startAfter,
|
|
285
|
+
searchString,
|
|
286
|
+
orderBy,
|
|
287
|
+
order,
|
|
288
|
+
onUpdate,
|
|
289
|
+
onError
|
|
290
|
+
}: ListenCollectionDelegateProps<M>): () => void;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Retrieve an entity given a path and a collection
|
|
294
|
+
* @param path
|
|
295
|
+
* @param entityId
|
|
296
|
+
*/
|
|
297
|
+
fetchEntity<M extends Record<string, any> = any>({
|
|
298
|
+
path,
|
|
299
|
+
entityId,
|
|
300
|
+
}: Omit<FetchEntityProps<M>, "collection">): Promise<Entity<M> | undefined>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Get realtime updates on one entity.
|
|
304
|
+
* @param path
|
|
305
|
+
* @param entityId
|
|
306
|
+
* @param collection
|
|
307
|
+
* @param onUpdate
|
|
308
|
+
* @param onError
|
|
309
|
+
* @return Function to cancel subscription
|
|
310
|
+
*/
|
|
311
|
+
listenEntity?<M extends Record<string, any> = any>({
|
|
312
|
+
path,
|
|
313
|
+
entityId,
|
|
314
|
+
onUpdate,
|
|
315
|
+
onError
|
|
316
|
+
}: Omit<ListenEntityProps<M>, "collection">): () => void;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Save entity to the specified path
|
|
320
|
+
* @param path
|
|
321
|
+
* @param id
|
|
322
|
+
* @param collection
|
|
323
|
+
* @param status
|
|
324
|
+
*/
|
|
325
|
+
saveEntity<M extends Record<string, any> = any>({
|
|
326
|
+
path,
|
|
327
|
+
entityId,
|
|
328
|
+
values,
|
|
329
|
+
status
|
|
330
|
+
}: SaveEntityDelegateProps<M>): Promise<Entity<M>>;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Delete an entity
|
|
334
|
+
* @param entity
|
|
335
|
+
* @return was the whole deletion flow successful
|
|
336
|
+
*/
|
|
337
|
+
deleteEntity<M extends Record<string, any> = any>({ entity }: DeleteEntityProps<M>): Promise<void>;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Check if the given property is unique in the given collection
|
|
341
|
+
* @param path Collection path
|
|
342
|
+
* @param name of the property
|
|
343
|
+
* @param value
|
|
344
|
+
* @param entityId
|
|
345
|
+
* @return `true` if there are no other fields besides the given entity
|
|
346
|
+
*/
|
|
347
|
+
checkUniqueField(path: string, name: string, value: any, entityId?: string): Promise<boolean>;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Generate an id for a new entity
|
|
351
|
+
*/
|
|
352
|
+
generateEntityId(path: string): string;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Count the number of entities in a collection
|
|
356
|
+
*/
|
|
357
|
+
countEntities<M extends Record<string, any> = any>(props: FetchCollectionDelegateProps<M>): Promise<number>;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Check if the given filter combination is valid
|
|
361
|
+
* @param props
|
|
362
|
+
*/
|
|
363
|
+
isFilterCombinationValid?(props: Omit<FilterCombinationValidProps, "collection">): boolean;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Convert a FireCMS reference to a reference that can be used by the datasource
|
|
367
|
+
* @param reference
|
|
368
|
+
*/
|
|
369
|
+
buildReference: (reference: EntityReference) => any,
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Convert a FireCMS GeoPoint to a GeoPoint that can be used by the datasource
|
|
373
|
+
* @param geoPoint
|
|
374
|
+
*/
|
|
375
|
+
buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Get the object to generate the current time in the datasource
|
|
379
|
+
*/
|
|
380
|
+
currentTime(): any;
|
|
381
|
+
|
|
382
|
+
buildDate: (date: Date) => any;
|
|
383
|
+
|
|
384
|
+
buildDeleteFieldValue: () => any;
|
|
385
|
+
|
|
386
|
+
delegateToCMSModel: (data: any) => any;
|
|
387
|
+
|
|
388
|
+
setDateToMidnight: (input?: any) => any;
|
|
225
389
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controller to open the side dialog
|
|
3
|
+
* @category Hooks and utilities
|
|
4
|
+
*/
|
|
5
|
+
export interface DialogsController {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Close the last dialog
|
|
9
|
+
*/
|
|
10
|
+
close: () => void;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Open a dialog
|
|
14
|
+
* @param props
|
|
15
|
+
*/
|
|
16
|
+
open: (props: DialogControllerEntryProps) => { closeDialog: () => void };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Props used to open a side dialog
|
|
21
|
+
* @category Hooks and utilities
|
|
22
|
+
*/
|
|
23
|
+
export interface DialogControllerEntryProps {
|
|
24
|
+
|
|
25
|
+
key: string;
|
|
26
|
+
/**
|
|
27
|
+
* The component type that will be rendered
|
|
28
|
+
*/
|
|
29
|
+
Component: React.ComponentType<{ open: boolean }>;
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FireCMSContext } from "./firecms_context";
|
|
3
|
+
import { Entity } from "./entities";
|
|
4
|
+
import { EntityCollection, SelectionController } from "./collections";
|
|
5
|
+
import { User } from "./user";
|
|
6
|
+
import { SideEntityController } from "./side_entity_controller";
|
|
7
|
+
|
|
8
|
+
export type EntityAction<M extends object = any, UserType extends User = User> = {
|
|
9
|
+
name: string;
|
|
10
|
+
icon?: React.ReactElement;
|
|
11
|
+
onClick: (props: EntityActionClickProps<M, UserType>) => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Show this action in the menu, defaults to true
|
|
14
|
+
*/
|
|
15
|
+
collapsed?: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Show this action in the form, defaults to true
|
|
19
|
+
*/
|
|
20
|
+
includeInForm?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type EntityActionClickProps<M extends object, UserType extends User = User> = {
|
|
24
|
+
entity: Entity<M>;
|
|
25
|
+
context: FireCMSContext<UserType>;
|
|
26
|
+
fullPath?: string;
|
|
27
|
+
collection?: EntityCollection<M>;
|
|
28
|
+
selectionController?: SelectionController;
|
|
29
|
+
highlightEntity?: (entity: Entity<any>) => void;
|
|
30
|
+
unhighlightEntity?: (entity: Entity<any>) => void;
|
|
31
|
+
onCollectionChange?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* If this actions is being called from a side dialog
|
|
34
|
+
*/
|
|
35
|
+
sideEntityController?: SideEntityController;
|
|
36
|
+
};
|
package/src/types/fields.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { ResolvedEntityCollection, ResolvedProperty } from "./resolved_entities"
|
|
|
8
8
|
*
|
|
9
9
|
* @category Form custom fields
|
|
10
10
|
*/
|
|
11
|
-
export interface FieldProps<T extends CMSType =
|
|
11
|
+
export interface FieldProps<T extends CMSType = any, CustomProps = any, M extends Record<string, any> = any> {
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Key of the property
|
package/src/types/firecms.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { DataSource } from "./datasource";
|
|
|
5
5
|
import { EntityCollection, EntityCustomView } from "./collections";
|
|
6
6
|
import { CMSView } from "./navigation";
|
|
7
7
|
import { FireCMSContext } from "./firecms_context";
|
|
8
|
-
import {
|
|
8
|
+
import { PropertyConfig } from "./property_config";
|
|
9
9
|
import { Locale } from "./locales";
|
|
10
10
|
import { StorageSource } from "./storage";
|
|
11
11
|
import { EntityLinkBuilder } from "./entity_link_builder";
|
|
@@ -23,11 +23,11 @@ import { CMSAnalyticsEvent } from "./analytics";
|
|
|
23
23
|
* APIs directly, or a REST API.
|
|
24
24
|
* @category Models
|
|
25
25
|
*/
|
|
26
|
-
export type EntityCollectionsBuilder = (params: {
|
|
26
|
+
export type EntityCollectionsBuilder<EC extends EntityCollection> = (params: {
|
|
27
27
|
user: User | null,
|
|
28
28
|
authController: AuthController,
|
|
29
29
|
dataSource: DataSource
|
|
30
|
-
}) =>
|
|
30
|
+
}) => EC[] | Promise<EC[]>;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Use this callback to build custom views dynamically.
|
|
@@ -47,7 +47,7 @@ export type CMSViewsBuilder = (params: {
|
|
|
47
47
|
/**
|
|
48
48
|
* @category Models
|
|
49
49
|
*/
|
|
50
|
-
export type FireCMSProps<UserType extends User> = {
|
|
50
|
+
export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Use this function to return the components you want to render under
|
|
@@ -73,7 +73,7 @@ export type FireCMSProps<UserType extends User> = {
|
|
|
73
73
|
* Each of the navigation entries in this field
|
|
74
74
|
* generates an entry in the main menu.
|
|
75
75
|
*/
|
|
76
|
-
collections?:
|
|
76
|
+
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Custom additional views created by the developer, added to the main
|
|
@@ -84,9 +84,9 @@ export type FireCMSProps<UserType extends User> = {
|
|
|
84
84
|
/**
|
|
85
85
|
* Record of custom form fields to be used in the CMS.
|
|
86
86
|
* You can use the key to reference the custom field in
|
|
87
|
-
* the `
|
|
87
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
88
88
|
*/
|
|
89
|
-
fields?: Record<string,
|
|
89
|
+
fields?: Record<string, PropertyConfig>;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* List of additional custom views for entities.
|
|
@@ -148,7 +148,7 @@ export type FireCMSProps<UserType extends User> = {
|
|
|
148
148
|
* Use plugins to modify the behaviour of the CMS.
|
|
149
149
|
* Currently, in ALPHA, and likely subject to change.
|
|
150
150
|
*/
|
|
151
|
-
plugins?: FireCMSPlugin[];
|
|
151
|
+
plugins?: FireCMSPlugin<any, any, any>[];
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
* Callback used to get analytics events from the CMS
|
|
@@ -11,8 +11,9 @@ import { UserConfigurationPersistence } from "./local_config_persistence";
|
|
|
11
11
|
import { SideDialogsController } from "./side_dialogs_controller";
|
|
12
12
|
import { FireCMSPlugin } from "./plugins";
|
|
13
13
|
import { CMSAnalyticsEvent } from "./analytics";
|
|
14
|
-
import {
|
|
14
|
+
import { PropertyConfig } from "./property_config";
|
|
15
15
|
import { EntityCustomView } from "./collections";
|
|
16
|
+
import { DialogsController } from "./dialogs_controller";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Context that includes the internal controllers and contexts used by the app.
|
|
@@ -59,9 +60,16 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
|
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* Controller used to open side dialogs
|
|
63
|
+
* This is the controller used internally by side entity dialogs
|
|
64
|
+
* or reference dialogs.
|
|
62
65
|
*/
|
|
63
66
|
sideDialogsController: SideDialogsController;
|
|
64
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Controller used to open regular dialogs
|
|
70
|
+
*/
|
|
71
|
+
dialogsController: DialogsController;
|
|
72
|
+
|
|
65
73
|
/**
|
|
66
74
|
* Used auth controller
|
|
67
75
|
*/
|
|
@@ -96,9 +104,9 @@ export type FireCMSContext<UserType extends User = User, AuthControllerType exte
|
|
|
96
104
|
/**
|
|
97
105
|
* Record of custom form fields to be used in the CMS.
|
|
98
106
|
* You can use the key to reference the custom field in
|
|
99
|
-
* the `
|
|
107
|
+
* the `propertyConfig` prop of a property in a collection.
|
|
100
108
|
*/
|
|
101
|
-
fields: Record<string,
|
|
109
|
+
fields: Record<string, PropertyConfig>;
|
|
102
110
|
|
|
103
111
|
/**
|
|
104
112
|
* List of additional custom views for entities.
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./auth";
|
|
2
2
|
export * from "./entities";
|
|
3
|
+
export * from "./entity_actions";
|
|
3
4
|
export * from "./resolved_entities";
|
|
4
5
|
export * from "./properties";
|
|
5
6
|
export * from "./collections";
|
|
@@ -10,7 +11,7 @@ export * from "./user";
|
|
|
10
11
|
export * from "./colors";
|
|
11
12
|
export * from "./storage";
|
|
12
13
|
export * from "./fields";
|
|
13
|
-
export * from "./
|
|
14
|
+
export * from "./property_config";
|
|
14
15
|
export * from "./datasource";
|
|
15
16
|
export * from "./entity_link_builder";
|
|
16
17
|
export * from "./side_entity_controller";
|
package/src/types/navigation.ts
CHANGED
|
@@ -154,9 +154,9 @@ export interface CMSView {
|
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
* Icon key to use in this view.
|
|
157
|
-
* You can use any of the icons in the
|
|
158
|
-
* https://
|
|
159
|
-
* e.g. '
|
|
157
|
+
* You can use any of the icons in the Material specs:
|
|
158
|
+
* https://fonts.google.com/icons
|
|
159
|
+
* e.g. 'account_tree' or 'person'
|
|
160
160
|
*/
|
|
161
161
|
icon?: string;
|
|
162
162
|
|
package/src/types/plugins.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import { ResolvedProperty } from "./resolved_entities";
|
|
|
13
13
|
* NOTE: This is a work in progress and the API is not stable yet.
|
|
14
14
|
* @category Core
|
|
15
15
|
*/
|
|
16
|
-
export type FireCMSPlugin<PROPS = any, FORM_PROPS = any> = {
|
|
16
|
+
export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection> = {
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Name of the plugin
|
|
@@ -41,19 +41,19 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any> = {
|
|
|
41
41
|
* Use this component to add custom actions to the entity collections
|
|
42
42
|
* toolbar.
|
|
43
43
|
*/
|
|
44
|
-
CollectionActions?: React.ComponentType<CollectionActionsProps
|
|
44
|
+
CollectionActions?: React.ComponentType<CollectionActionsProps<any, any, EC>> | React.ComponentType<CollectionActionsProps<any, any, EC>>[];
|
|
45
45
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
form?: {
|
|
49
49
|
provider?: {
|
|
50
|
-
Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<any>>>;
|
|
50
|
+
Component: React.ComponentType<PropsWithChildren<FORM_PROPS & PluginFormActionProps<any, EC>>>;
|
|
51
51
|
props?: FORM_PROPS;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
Actions?: React.ComponentType<PluginFormActionProps
|
|
54
|
+
Actions?: React.ComponentType<PluginFormActionProps<any, EC>>;
|
|
55
55
|
|
|
56
|
-
fieldBuilder?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T>) => React.ComponentType<FieldProps<T>> | null;
|
|
56
|
+
fieldBuilder?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T, any, EC>) => React.ComponentType<FieldProps<T>> | null;
|
|
57
57
|
|
|
58
58
|
fieldBuilderEnabled?: <T extends CMSType = CMSType>(props: PluginFieldBuilderParams<T>) => boolean;
|
|
59
59
|
}
|
|
@@ -115,6 +115,7 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any> = {
|
|
|
115
115
|
fullPath: string,
|
|
116
116
|
parentPathSegments: string[],
|
|
117
117
|
onHover: boolean,
|
|
118
|
+
collection: EC;
|
|
118
119
|
}>;
|
|
119
120
|
|
|
120
121
|
/**
|
|
@@ -124,7 +125,7 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any> = {
|
|
|
124
125
|
AddColumnComponent?: React.ComponentType<{
|
|
125
126
|
fullPath: string,
|
|
126
127
|
parentPathSegments: string[],
|
|
127
|
-
collection:
|
|
128
|
+
collection: EC;
|
|
128
129
|
}>;
|
|
129
130
|
}
|
|
130
131
|
|
|
@@ -157,24 +158,24 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
|
|
|
157
158
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
export interface PluginFormActionProps<UserType extends User = User> {
|
|
161
|
+
export interface PluginFormActionProps<UserType extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
161
162
|
entityId?: string;
|
|
162
163
|
path: string;
|
|
163
164
|
status: EntityStatus;
|
|
164
|
-
collection:
|
|
165
|
+
collection: EC;
|
|
165
166
|
formContext?: FormContext<any>;
|
|
166
167
|
context: FireCMSContext<UserType>;
|
|
167
168
|
currentEntityId?: string;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Record<string, any> = any> = {
|
|
171
|
+
export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Record<string, any> = any, EC extends EntityCollection<M> = EntityCollection<M>> = {
|
|
171
172
|
fieldConfigId: string;
|
|
172
173
|
propertyKey: string;
|
|
173
174
|
property: Property<T> | ResolvedProperty<T>;
|
|
174
175
|
Field: React.ComponentType<FieldProps<T, any, M>>;
|
|
175
176
|
plugin: FireCMSPlugin;
|
|
176
177
|
path: string;
|
|
177
|
-
collection:
|
|
178
|
+
collection: EC;
|
|
178
179
|
};
|
|
179
180
|
|
|
180
181
|
export interface PluginGenericProps<UserType extends User = User> {
|
package/src/types/properties.ts
CHANGED
|
@@ -85,7 +85,7 @@ export interface BaseProperty<T extends CMSType, CustomProps = any> {
|
|
|
85
85
|
* All the configuration will be taken from the inherited config, and
|
|
86
86
|
* overwritten by the current property config.
|
|
87
87
|
*/
|
|
88
|
-
|
|
88
|
+
propertyConfig?: string;
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Longer description of a field, displayed under a popover
|
|
@@ -2,15 +2,14 @@ import React from "react";
|
|
|
2
2
|
import { CMSType, PropertyOrBuilder } from "./properties";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* This is the configuration object for
|
|
6
|
-
* property.
|
|
5
|
+
* This is the configuration object for a property.
|
|
7
6
|
* These configs are generated by default for the properties defined in your
|
|
8
7
|
* collections' configuration, but you can define your own to be used.
|
|
9
8
|
*/
|
|
10
|
-
export type
|
|
9
|
+
export type PropertyConfig<T extends CMSType = any> = {
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
* Key used to identify this
|
|
12
|
+
* Key used to identify this property config.
|
|
14
13
|
*/
|
|
15
14
|
key: string,
|
|
16
15
|
|
|
File without changes
|
|
File without changes
|