@firecms/core 3.0.0-beta.10 → 3.0.0-beta.11
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/ArrayContainer.d.ts +17 -5
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +6 -3
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +1 -1
- package/dist/core/EntityEditView.d.ts +1 -1
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/index.d.ts +0 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -2
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +1 -2
- package/dist/hooks/data/delete.d.ts +4 -4
- package/dist/hooks/data/save.d.ts +3 -3
- package/dist/hooks/data/useCollectionFetch.d.ts +1 -1
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/useAuthController.d.ts +1 -1
- package/dist/hooks/useBuildNavigationController.d.ts +3 -3
- package/dist/hooks/useFireCMSContext.d.ts +1 -1
- package/dist/hooks/useResolvedNavigationFrom.d.ts +3 -3
- package/dist/hooks/useValidateAuthenticator.d.ts +3 -3
- package/dist/index.es.js +17515 -14786
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +17912 -15184
- 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/util.d.ts +3 -3
- package/dist/types/auth.d.ts +7 -9
- package/dist/types/collections.d.ts +14 -13
- package/dist/types/datasource.d.ts +0 -4
- package/dist/types/entity_actions.d.ts +4 -4
- package/dist/types/entity_callbacks.d.ts +16 -16
- package/dist/types/export_import.d.ts +4 -4
- package/dist/types/fields.d.ts +18 -2
- package/dist/types/firecms.d.ts +2 -2
- package/dist/types/firecms_context.d.ts +1 -1
- package/dist/types/permissions.d.ts +4 -4
- package/dist/types/plugins.d.ts +8 -8
- package/dist/types/property_config.d.ts +0 -2
- package/dist/types/user.d.ts +1 -0
- package/dist/util/builders.d.ts +2 -2
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +0 -1
- package/dist/util/icons.d.ts +3 -1
- package/dist/util/objects.d.ts +1 -0
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/property_utils.d.ts +2 -2
- package/dist/util/resolutions.d.ts +6 -6
- package/package.json +131 -125
- package/src/app/Scaffold.tsx +4 -4
- package/src/components/ArrayContainer.tsx +79 -17
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/ConfirmationDialog.tsx +2 -2
- package/src/components/DeleteEntityDialog.tsx +9 -18
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +4 -1
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +14 -14
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +2 -2
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +6 -4
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +8 -9
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +5 -11
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +5 -5
- package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +2 -2
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +79 -69
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +9 -10
- package/src/components/EntityCollectionView/useSelectionController.tsx +5 -4
- package/src/components/EntityPreview.tsx +39 -30
- package/src/components/EntityView.tsx +5 -5
- package/src/components/ErrorView.tsx +3 -3
- package/src/components/HomePage/DefaultHomePage.tsx +1 -0
- package/src/components/HomePage/FavouritesView.tsx +6 -11
- package/src/components/HomePage/NavigationCard.tsx +1 -1
- package/src/components/HomePage/NavigationCardBinding.tsx +4 -9
- package/src/components/HomePage/NavigationGroup.tsx +1 -1
- package/src/components/PropertyConfigBadge.tsx +1 -1
- package/src/components/PropertyIdCopyTooltip.tsx +1 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +2 -2
- package/src/components/SelectableTable/SelectableTable.tsx +2 -2
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +4 -2
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +3 -1
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +7 -5
- package/src/components/VirtualTable/VirtualTableHeader.tsx +8 -8
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +2 -0
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +2 -2
- package/src/contexts/SnackbarProvider.tsx +2 -0
- package/src/core/DefaultAppBar.tsx +12 -11
- package/src/core/DefaultDrawer.tsx +11 -9
- package/src/core/DrawerNavigationItem.tsx +4 -4
- package/src/core/EntityEditView.tsx +50 -52
- package/src/core/FireCMS.tsx +5 -5
- package/src/core/SideDialogs.tsx +1 -1
- package/src/core/field_configs.tsx +4 -4
- package/src/form/PropertyFieldBinding.tsx +27 -20
- package/src/form/components/CustomIdField.tsx +2 -0
- package/src/form/components/StorageItemPreview.tsx +3 -3
- package/src/form/components/index.tsx +0 -1
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +3 -2
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +16 -10
- package/src/form/field_bindings/BlockFieldBinding.tsx +41 -23
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +10 -7
- package/src/form/field_bindings/MapFieldBinding.tsx +58 -39
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +4 -4
- package/src/form/field_bindings/RepeatFieldBinding.tsx +25 -20
- package/src/form/field_bindings/SelectFieldBinding.tsx +5 -4
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +1 -1
- package/src/form/field_bindings/SwitchFieldBinding.tsx +25 -25
- package/src/form/field_bindings/TextFieldBinding.tsx +3 -3
- package/src/hooks/data/delete.ts +4 -4
- package/src/hooks/data/save.ts +7 -8
- package/src/hooks/data/useCollectionFetch.tsx +2 -2
- package/src/hooks/data/useEntityFetch.tsx +5 -5
- package/src/hooks/useAuthController.tsx +1 -1
- package/src/hooks/useBuildNavigationController.tsx +5 -6
- package/src/hooks/useFireCMSContext.tsx +5 -5
- package/src/hooks/useResolvedNavigationFrom.tsx +5 -5
- package/src/hooks/useValidateAuthenticator.tsx +3 -3
- package/src/internal/useBuildDataSource.ts +1 -1
- package/src/internal/useUnsavedChangesDialog.tsx +2 -2
- package/src/preview/PropertyPreview.tsx +3 -3
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/preview/components/BooleanPreview.tsx +1 -1
- package/src/preview/components/EmptyValue.tsx +1 -1
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ImagePreview.tsx +5 -6
- package/src/preview/components/UrlComponentPreview.tsx +4 -4
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +1 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -2
- package/src/preview/property_previews/MapPropertyPreview.tsx +4 -4
- package/src/preview/property_previews/SkeletonPropertyComponent.tsx +12 -12
- package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
- package/src/preview/util.ts +10 -10
- package/src/types/auth.tsx +8 -12
- package/src/types/collections.ts +14 -13
- package/src/types/datasource.ts +0 -5
- package/src/types/entity_actions.tsx +4 -4
- package/src/types/entity_callbacks.ts +18 -18
- package/src/types/export_import.ts +4 -4
- package/src/types/fields.tsx +20 -2
- package/src/types/firecms.tsx +2 -2
- package/src/types/firecms_context.tsx +1 -1
- package/src/types/permissions.ts +5 -5
- package/src/types/plugins.tsx +8 -8
- package/src/types/property_config.tsx +0 -2
- package/src/types/user.ts +2 -0
- package/src/util/builders.ts +6 -6
- package/src/util/entities.ts +3 -1
- package/src/util/icon_list.ts +1 -0
- package/src/util/icon_synonyms.ts +0 -1
- package/src/util/icons.tsx +12 -8
- package/src/util/objects.ts +20 -0
- package/src/util/permissions.ts +8 -8
- package/src/util/property_utils.tsx +10 -3
- package/src/util/references.ts +8 -2
- package/src/util/resolutions.ts +8 -8
- package/src/util/useStorageUploadController.tsx +1 -1
- package/dist/form/components/FormikArrayContainer.d.ts +0 -19
- package/src/form/components/FormikArrayContainer.tsx +0 -47
|
@@ -81,17 +81,17 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
|
|
|
81
81
|
return <></>;
|
|
82
82
|
|
|
83
83
|
let mapPropertyKeys: string[];
|
|
84
|
-
if (size === "
|
|
84
|
+
if (size === "large") {
|
|
85
85
|
mapPropertyKeys = Object.keys(property.properties);
|
|
86
86
|
} else {
|
|
87
87
|
mapPropertyKeys = (property.previewProperties || Object.keys(property.properties)) as string[];
|
|
88
|
-
if (size === "
|
|
88
|
+
if (size === "medium")
|
|
89
89
|
mapPropertyKeys = mapPropertyKeys.slice(0, 3);
|
|
90
|
-
else if (size === "
|
|
90
|
+
else if (size === "small")
|
|
91
91
|
mapPropertyKeys = mapPropertyKeys.slice(0, 1);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
if (size !== "
|
|
94
|
+
if (size !== "large")
|
|
95
95
|
return (
|
|
96
96
|
<div
|
|
97
97
|
className="w-full flex flex-col space-y-4"
|
|
@@ -101,7 +101,7 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
|
|
|
101
101
|
{property.properties && property.properties[key] &&
|
|
102
102
|
<SkeletonPropertyComponent
|
|
103
103
|
property={property.properties[key]}
|
|
104
|
-
size={"
|
|
104
|
+
size={"medium"}/>}
|
|
105
105
|
</div>
|
|
106
106
|
))}
|
|
107
107
|
</div>
|
|
@@ -128,7 +128,7 @@ function renderMap<T extends Record<string, any>>(property: ResolvedMapProperty<
|
|
|
128
128
|
{property.properties && property.properties[key] &&
|
|
129
129
|
<SkeletonPropertyComponent
|
|
130
130
|
property={property.properties[key]}
|
|
131
|
-
size={"
|
|
131
|
+
size={"medium"}/>}
|
|
132
132
|
</th>
|
|
133
133
|
</tr>
|
|
134
134
|
);
|
|
@@ -160,7 +160,7 @@ function renderArrayOfMaps<M extends Record<string, any>>(properties: ResolvedPr
|
|
|
160
160
|
>
|
|
161
161
|
<SkeletonPropertyComponent
|
|
162
162
|
property={(properties)[key]}
|
|
163
|
-
size={"
|
|
163
|
+
size={"medium"}/>
|
|
164
164
|
</th>
|
|
165
165
|
)
|
|
166
166
|
)}
|
|
@@ -210,7 +210,7 @@ function renderGenericArrayCell(
|
|
|
210
210
|
<>
|
|
211
211
|
<SkeletonPropertyComponent key={`i_${index}`}
|
|
212
212
|
property={property}
|
|
213
|
-
size={"
|
|
213
|
+
size={"medium"}/>
|
|
214
214
|
</>
|
|
215
215
|
)}
|
|
216
216
|
</div>
|
|
@@ -226,7 +226,7 @@ function renderUrlAudioComponent() {
|
|
|
226
226
|
|
|
227
227
|
export function renderSkeletonImageThumbnail(size: PreviewSize) {
|
|
228
228
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
229
|
-
const imageSize = size === "
|
|
229
|
+
const imageSize = size === "small" ? 40 : size === "medium" ? 100 : 200;
|
|
230
230
|
return (
|
|
231
231
|
<Skeleton width={imageSize}
|
|
232
232
|
height={imageSize}/>
|
|
@@ -236,8 +236,8 @@ export function renderSkeletonImageThumbnail(size: PreviewSize) {
|
|
|
236
236
|
function renderUrlVideo(size: PreviewSize) {
|
|
237
237
|
|
|
238
238
|
return (
|
|
239
|
-
<Skeleton width={size !== "
|
|
240
|
-
height={size !== "
|
|
239
|
+
<Skeleton width={size !== "large" ? 300 : 500}
|
|
240
|
+
height={size !== "large" ? 200 : 250}/>
|
|
241
241
|
);
|
|
242
242
|
}
|
|
243
243
|
|
|
@@ -245,7 +245,7 @@ function renderReference() {
|
|
|
245
245
|
return <Skeleton width={200} height={100}/>;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
function renderUrlComponent(property: ResolvedStringProperty, size: PreviewSize = "
|
|
248
|
+
function renderUrlComponent(property: ResolvedStringProperty, size: PreviewSize = "large") {
|
|
249
249
|
|
|
250
250
|
if (typeof property.url === "boolean") {
|
|
251
251
|
return <div style={{
|
|
@@ -45,14 +45,14 @@ export function StringPropertyPreview({
|
|
|
45
45
|
if (!value) return <></>;
|
|
46
46
|
const lines = value.split("\n");
|
|
47
47
|
return value && value.includes("\n")
|
|
48
|
-
? <div className={cls("overflow-x-scroll", size === "
|
|
48
|
+
? <div className={cls("overflow-x-scroll", size === "small" ? "text-sm" : "")}>
|
|
49
49
|
{lines.map((str, index) =>
|
|
50
50
|
<React.Fragment key={`string_preview_${index}`}>
|
|
51
51
|
<span>{str}</span>
|
|
52
52
|
{index !== lines.length - 1 && <br/>}
|
|
53
53
|
</React.Fragment>)}
|
|
54
54
|
</div>
|
|
55
|
-
: (size === "
|
|
55
|
+
: (size === "small"
|
|
56
56
|
? <span className={"text-sm"}>{value}</span>
|
|
57
57
|
: <>{value}</>
|
|
58
58
|
);
|
package/src/preview/util.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { CollectionSize } from "../types";
|
|
2
2
|
import { PreviewSize } from "./PropertyPreviewProps";
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
4
|
+
export const SMALL_THUMBNAIL = 40;
|
|
5
|
+
export const MEDIUM_THUMBNAIL = 100;
|
|
6
|
+
export const LARGE_THUMBNAIL = 200;
|
|
7
7
|
|
|
8
8
|
export function getThumbnailMeasure(size: PreviewSize): number {
|
|
9
|
-
if (size === "
|
|
10
|
-
return TINY_THUMBNAIL;
|
|
11
|
-
else if (size === "small")
|
|
9
|
+
if (size === "small")
|
|
12
10
|
return SMALL_THUMBNAIL;
|
|
13
11
|
else if (size === "medium")
|
|
14
|
-
return
|
|
12
|
+
return MEDIUM_THUMBNAIL;
|
|
13
|
+
else if (size === "large")
|
|
14
|
+
return LARGE_THUMBNAIL;
|
|
15
15
|
else throw Error("Thumbnail size not mapped");
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,12 +19,12 @@ export function getPreviewSizeFrom(size: CollectionSize): PreviewSize {
|
|
|
19
19
|
switch (size) {
|
|
20
20
|
case "xs":
|
|
21
21
|
case "s":
|
|
22
|
-
return "smallest";
|
|
23
|
-
case "m":
|
|
24
22
|
return "small";
|
|
23
|
+
case "m":
|
|
24
|
+
return "medium";
|
|
25
25
|
case "l":
|
|
26
26
|
case "xl":
|
|
27
|
-
return "
|
|
27
|
+
return "large";
|
|
28
28
|
default:
|
|
29
29
|
throw Error("Missing mapping value in getPreviewSizeFrom: " + size);
|
|
30
30
|
}
|
package/src/types/auth.tsx
CHANGED
|
@@ -9,18 +9,13 @@ import { StorageSource } from "./storage";
|
|
|
9
9
|
* to do it as the result of a hook.
|
|
10
10
|
* @group Hooks and utilities
|
|
11
11
|
*/
|
|
12
|
-
export type AuthController<
|
|
12
|
+
export type AuthController<USER extends User = any, ExtraData = any> = {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The user currently logged in
|
|
16
16
|
* The values can be: the user object, null if they skipped login
|
|
17
17
|
*/
|
|
18
|
-
user:
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Roles related to the logged user
|
|
22
|
-
*/
|
|
23
|
-
roles?: Role[];
|
|
18
|
+
user: USER | null;
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* Initial loading flag. It is used not to display the login screen
|
|
@@ -64,26 +59,27 @@ export type AuthController<UserType extends User = any, ExtraData = any> = {
|
|
|
64
59
|
|
|
65
60
|
setExtra: (extra: ExtraData) => void;
|
|
66
61
|
|
|
67
|
-
|
|
62
|
+
setUser?: (user: USER | null) => void;
|
|
63
|
+
|
|
64
|
+
setUserRoles?: (roles: Role[]) => void;
|
|
68
65
|
|
|
69
|
-
// setRoles?: (roles: Role[]) => void;
|
|
70
66
|
};
|
|
71
67
|
|
|
72
68
|
/**
|
|
73
69
|
* Implement this function to allow access to specific users.
|
|
74
70
|
* @group Hooks and utilities
|
|
75
71
|
*/
|
|
76
|
-
export type Authenticator<
|
|
72
|
+
export type Authenticator<USER extends User = User> = (props: {
|
|
77
73
|
|
|
78
74
|
/**
|
|
79
75
|
* Logged-in user or null
|
|
80
76
|
*/
|
|
81
|
-
user:
|
|
77
|
+
user: USER | null;
|
|
82
78
|
|
|
83
79
|
/**
|
|
84
80
|
* AuthController
|
|
85
81
|
*/
|
|
86
|
-
authController:
|
|
82
|
+
authController: AuthController<USER>;
|
|
87
83
|
|
|
88
84
|
/**
|
|
89
85
|
* Connector to your database, e.g. your Firestore database
|
package/src/types/collections.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { EntityOverrides } from "./entity_overrides";
|
|
|
17
17
|
*
|
|
18
18
|
* @group Models
|
|
19
19
|
*/
|
|
20
|
-
export interface EntityCollection<M extends Record<string, any> = any,
|
|
20
|
+
export interface EntityCollection<M extends Record<string, any> = any, USER extends User = any> {
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* You can set an alias that will be used internally instead of the `path`.
|
|
@@ -139,7 +139,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
139
139
|
* Permissions the logged-in user can perform on this collection.
|
|
140
140
|
* If not specified everything defaults to `true`.
|
|
141
141
|
*/
|
|
142
|
-
permissions?: Permissions | PermissionsBuilder<EntityCollection,
|
|
142
|
+
permissions?: Permissions | PermissionsBuilder<EntityCollection, USER, M>;
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Are the entities in this collection selectable. Defaults to `true`
|
|
@@ -158,7 +158,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
158
158
|
* is being created, updated or deleted.
|
|
159
159
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
160
160
|
*/
|
|
161
|
-
callbacks?: EntityCallbacks<M,
|
|
161
|
+
callbacks?: EntityCallbacks<M, USER>;
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
* Builder for rendering additional components such as buttons in the
|
|
@@ -189,7 +189,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
189
189
|
* }
|
|
190
190
|
* ```
|
|
191
191
|
*/
|
|
192
|
-
entityActions?: EntityAction<M,
|
|
192
|
+
entityActions?: EntityAction<M, USER>[];
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
195
|
* Pass your own selection controller if you want to control selected
|
|
@@ -241,7 +241,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
241
241
|
* You can add additional fields to the collection view by implementing
|
|
242
242
|
* an additional field delegate.
|
|
243
243
|
*/
|
|
244
|
-
additionalFields?: AdditionalFieldDelegate<M,
|
|
244
|
+
additionalFields?: AdditionalFieldDelegate<M, USER>[];
|
|
245
245
|
|
|
246
246
|
/**
|
|
247
247
|
* Default size of the rendered collection
|
|
@@ -294,7 +294,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
294
294
|
/**
|
|
295
295
|
*
|
|
296
296
|
*/
|
|
297
|
-
exportable?: boolean | ExportConfig<
|
|
297
|
+
exportable?: boolean | ExportConfig<USER>;
|
|
298
298
|
|
|
299
299
|
/**
|
|
300
300
|
* User id of the owner of this collection. This is used only by plugins, or if you
|
|
@@ -325,7 +325,7 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
325
325
|
*
|
|
326
326
|
* @group Models
|
|
327
327
|
*/
|
|
328
|
-
export interface CollectionActionsProps<M extends Record<string, any> = any,
|
|
328
|
+
export interface CollectionActionsProps<M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
329
329
|
/**
|
|
330
330
|
* Full collection path of this entity. This is the full path, like
|
|
331
331
|
* `users/1234/addresses`
|
|
@@ -362,7 +362,7 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, Use
|
|
|
362
362
|
/**
|
|
363
363
|
* Context of the app status
|
|
364
364
|
*/
|
|
365
|
-
context: FireCMSContext<
|
|
365
|
+
context: FireCMSContext<USER>;
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
368
|
* Count of the entities in this collection
|
|
@@ -424,9 +424,9 @@ export type FilterCombination<Key extends string> = Partial<Record<Key, "asc" |
|
|
|
424
424
|
*/
|
|
425
425
|
export type CollectionSize = "xs" | "s" | "m" | "l" | "xl";
|
|
426
426
|
|
|
427
|
-
export type AdditionalFieldDelegateProps<M extends Record<string, any> = any,
|
|
427
|
+
export type AdditionalFieldDelegateProps<M extends Record<string, any> = any, USER extends User = User> = {
|
|
428
428
|
entity: Entity<M>,
|
|
429
|
-
context: FireCMSContext<
|
|
429
|
+
context: FireCMSContext<USER>
|
|
430
430
|
};
|
|
431
431
|
|
|
432
432
|
/**
|
|
@@ -435,7 +435,7 @@ export type AdditionalFieldDelegateProps<M extends Record<string, any> = any, Us
|
|
|
435
435
|
* @group Models
|
|
436
436
|
*/
|
|
437
437
|
export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
|
|
438
|
-
|
|
438
|
+
USER extends User = User> {
|
|
439
439
|
|
|
440
440
|
/**
|
|
441
441
|
* ID of this column. You can use this id in the `properties` field of the
|
|
@@ -456,7 +456,7 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any,
|
|
|
456
456
|
/**
|
|
457
457
|
* Builder for the content of the cell for this column
|
|
458
458
|
*/
|
|
459
|
-
Builder?: React.ComponentType<AdditionalFieldDelegateProps<M,
|
|
459
|
+
Builder?: React.ComponentType<AdditionalFieldDelegateProps<M, USER>>;
|
|
460
460
|
|
|
461
461
|
/**
|
|
462
462
|
* If this column needs to update dynamically based on other properties,
|
|
@@ -585,5 +585,6 @@ export type SelectedCellProps<M extends Record<string, any>> = {
|
|
|
585
585
|
cellRect: DOMRect;
|
|
586
586
|
width: number;
|
|
587
587
|
height: number;
|
|
588
|
-
|
|
588
|
+
entityPath: string;
|
|
589
|
+
entityId: string;
|
|
589
590
|
};
|
package/src/types/datasource.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { SideEntityController } from "./side_entity_controller";
|
|
|
9
9
|
* An entity action is a custom action that can be performed on an entity.
|
|
10
10
|
* They are displayed in the entity view and in the collection view.
|
|
11
11
|
*/
|
|
12
|
-
export type EntityAction<M extends object = any,
|
|
12
|
+
export type EntityAction<M extends object = any, USER extends User = User> = {
|
|
13
13
|
/**
|
|
14
14
|
* Title of the action
|
|
15
15
|
*/
|
|
@@ -24,7 +24,7 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
24
24
|
* Callback when the action is clicked
|
|
25
25
|
* @param props
|
|
26
26
|
*/
|
|
27
|
-
onClick: (props: EntityActionClickProps<M,
|
|
27
|
+
onClick: (props: EntityActionClickProps<M, USER>) => Promise<void> | void;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Show this action collapsed in the menu of the collection view.
|
|
@@ -40,9 +40,9 @@ export type EntityAction<M extends object = any, UserType extends User = User> =
|
|
|
40
40
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export type EntityActionClickProps<M extends object,
|
|
43
|
+
export type EntityActionClickProps<M extends object, USER extends User = User> = {
|
|
44
44
|
entity: Entity<M>;
|
|
45
|
-
context: FireCMSContext<
|
|
45
|
+
context: FireCMSContext<USER>;
|
|
46
46
|
fullPath?: string;
|
|
47
47
|
collection?: EntityCollection<M>;
|
|
48
48
|
selectionController?: SelectionController;
|
|
@@ -10,27 +10,27 @@ import { User } from "./user";
|
|
|
10
10
|
* Useful for adding your own logic or blocking the execution of the operation.
|
|
11
11
|
* @group Models
|
|
12
12
|
*/
|
|
13
|
-
export type EntityCallbacks<M extends Record<string, any> = any,
|
|
13
|
+
export type EntityCallbacks<M extends Record<string, any> = any, USER extends User = User> = {
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Callback used after fetching data
|
|
17
17
|
* @param entityFetchProps
|
|
18
18
|
*/
|
|
19
|
-
onFetch?(entityFetchProps: EntityOnFetchProps<M,
|
|
19
|
+
onFetch?(entityFetchProps: EntityOnFetchProps<M, USER>)
|
|
20
20
|
: Promise<Entity<M>> | Entity<M>;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Callback used when save is successful
|
|
24
24
|
* @param entitySaveProps
|
|
25
25
|
*/
|
|
26
|
-
onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M,
|
|
26
|
+
onSaveSuccess?(entitySaveProps: EntityOnSaveProps<M, USER>)
|
|
27
27
|
: Promise<void> | void;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Callback used when saving fails
|
|
31
31
|
* @param entitySaveProps
|
|
32
32
|
*/
|
|
33
|
-
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M,
|
|
33
|
+
onSaveFailure?(entitySaveProps: EntityOnSaveFailureProps<M, USER>)
|
|
34
34
|
: Promise<void> | void;
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -39,7 +39,7 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
39
39
|
* error snackbar gets displayed.
|
|
40
40
|
* @param entitySaveProps
|
|
41
41
|
*/
|
|
42
|
-
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M,
|
|
42
|
+
onPreSave?(entitySaveProps: EntityOnPreSaveProps<M, USER>)
|
|
43
43
|
: Promise<Partial<EntityValues<M>>> | Partial<EntityValues<M>>;
|
|
44
44
|
|
|
45
45
|
/**
|
|
@@ -49,14 +49,14 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
49
49
|
*
|
|
50
50
|
* @param entityDeleteProps
|
|
51
51
|
*/
|
|
52
|
-
onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M,
|
|
52
|
+
onPreDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Callback used after the entity is deleted.
|
|
56
56
|
*
|
|
57
57
|
* @param entityDeleteProps
|
|
58
58
|
*/
|
|
59
|
-
onDelete?(entityDeleteProps: EntityOnDeleteProps<M,
|
|
59
|
+
onDelete?(entityDeleteProps: EntityOnDeleteProps<M, USER>): void;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Callback fired when any value in the form changes. You can use it
|
|
@@ -73,12 +73,12 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
73
73
|
* Parameters passed to hooks when an entity is fetched
|
|
74
74
|
* @group Models
|
|
75
75
|
*/
|
|
76
|
-
export interface EntityOnFetchProps<M extends Record<string, any> = any,
|
|
76
|
+
export interface EntityOnFetchProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Collection of the entity
|
|
80
80
|
*/
|
|
81
|
-
collection: EntityCollection<M,
|
|
81
|
+
collection: EntityCollection<M, USER>;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Full path of the CMS where this collection is being fetched.
|
|
@@ -94,15 +94,15 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, UserTyp
|
|
|
94
94
|
/**
|
|
95
95
|
* Context of the app status
|
|
96
96
|
*/
|
|
97
|
-
context: FireCMSContext<
|
|
97
|
+
context: FireCMSContext<USER>;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Parameters passed to hooks before an entity is saved
|
|
102
102
|
* @group Models
|
|
103
103
|
*/
|
|
104
|
-
export type EntityOnPreSaveProps<M extends Record<string, any> = any,
|
|
105
|
-
Omit<EntityOnSaveProps<M,
|
|
104
|
+
export type EntityOnPreSaveProps<M extends Record<string, any> = any, USER extends User = User> =
|
|
105
|
+
Omit<EntityOnSaveProps<M, USER>, "entityId">
|
|
106
106
|
& {
|
|
107
107
|
entityId?: string;
|
|
108
108
|
}
|
|
@@ -110,8 +110,8 @@ export type EntityOnPreSaveProps<M extends Record<string, any> = any, UserType e
|
|
|
110
110
|
* Parameters passed to hooks before an entity is saved
|
|
111
111
|
* @group Models
|
|
112
112
|
*/
|
|
113
|
-
export type EntityOnSaveFailureProps<M extends Record<string, any> = any,
|
|
114
|
-
Omit<EntityOnSaveProps<M,
|
|
113
|
+
export type EntityOnSaveFailureProps<M extends Record<string, any> = any, USER extends User = User> =
|
|
114
|
+
Omit<EntityOnSaveProps<M, USER>, "entityId">
|
|
115
115
|
& {
|
|
116
116
|
entityId?: string;
|
|
117
117
|
}
|
|
@@ -120,7 +120,7 @@ export type EntityOnSaveFailureProps<M extends Record<string, any> = any, UserTy
|
|
|
120
120
|
* Parameters passed to hooks when an entity is saved
|
|
121
121
|
* @group Models
|
|
122
122
|
*/
|
|
123
|
-
export interface EntityOnSaveProps<M extends Record<string, any> = any,
|
|
123
|
+
export interface EntityOnSaveProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
126
|
* Resolved collection of the entity
|
|
@@ -161,14 +161,14 @@ export interface EntityOnSaveProps<M extends Record<string, any> = any, UserType
|
|
|
161
161
|
/**
|
|
162
162
|
* Context of the app status
|
|
163
163
|
*/
|
|
164
|
-
context: FireCMSContext<
|
|
164
|
+
context: FireCMSContext<USER>;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* Parameters passed to hooks when an entity is deleted
|
|
169
169
|
* @group Models
|
|
170
170
|
*/
|
|
171
|
-
export interface EntityOnDeleteProps<M extends Record<string, any> = any,
|
|
171
|
+
export interface EntityOnDeleteProps<M extends Record<string, any> = any, USER extends User = User> {
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
174
|
* collection of the entity being deleted
|
|
@@ -193,7 +193,7 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, UserTy
|
|
|
193
193
|
/**
|
|
194
194
|
* Context of the app status
|
|
195
195
|
*/
|
|
196
|
-
context: FireCMSContext<
|
|
196
|
+
context: FireCMSContext<USER>;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
|
@@ -7,20 +7,20 @@ import { FireCMSContext } from "./firecms_context";
|
|
|
7
7
|
* exports
|
|
8
8
|
* @group Models
|
|
9
9
|
*/
|
|
10
|
-
export interface ExportConfig<
|
|
11
|
-
additionalFields: ExportMappingFunction<
|
|
10
|
+
export interface ExportConfig<USER extends User = User> {
|
|
11
|
+
additionalFields: ExportMappingFunction<USER> [];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @group Models
|
|
16
16
|
*/
|
|
17
|
-
export interface ExportMappingFunction<
|
|
17
|
+
export interface ExportMappingFunction<USER extends User = User> {
|
|
18
18
|
key: string;
|
|
19
19
|
builder: ({
|
|
20
20
|
entity,
|
|
21
21
|
context
|
|
22
22
|
}: {
|
|
23
23
|
entity: Entity<any>,
|
|
24
|
-
context: FireCMSContext<
|
|
24
|
+
context: FireCMSContext<USER>
|
|
25
25
|
}) => Promise<string> | string;
|
|
26
26
|
}
|
package/src/types/fields.tsx
CHANGED
|
@@ -108,7 +108,16 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
|
|
|
108
108
|
/**
|
|
109
109
|
* Size of the field
|
|
110
110
|
*/
|
|
111
|
-
size?: "
|
|
111
|
+
size?: "small" | "medium" | "large";
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Some properties might change internal state (like expanding a panel).
|
|
115
|
+
* This function should be called when the internal state changes.
|
|
116
|
+
* This is used to preserve state in array containers.
|
|
117
|
+
*
|
|
118
|
+
* @param property
|
|
119
|
+
*/
|
|
120
|
+
onPropertyChange?: (property: Partial<Property<any>>) => void;
|
|
112
121
|
|
|
113
122
|
}
|
|
114
123
|
|
|
@@ -222,5 +231,14 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
|
|
|
222
231
|
/**
|
|
223
232
|
* The size of the field
|
|
224
233
|
*/
|
|
225
|
-
size?: "
|
|
234
|
+
size?: "small" | "medium" | "large",
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Some properties might change internal state (like expanding a panel).
|
|
238
|
+
* This function should be called when the internal state changes.
|
|
239
|
+
* This is used to preserve state in array containers.
|
|
240
|
+
*
|
|
241
|
+
* @param property
|
|
242
|
+
*/
|
|
243
|
+
onPropertyChange?: (property: Partial<Property<any>>) => void;
|
|
226
244
|
}
|
package/src/types/firecms.tsx
CHANGED
|
@@ -47,7 +47,7 @@ export type CMSViewsBuilder = (params: {
|
|
|
47
47
|
/**
|
|
48
48
|
* @group Models
|
|
49
49
|
*/
|
|
50
|
-
export type FireCMSProps<
|
|
50
|
+
export type FireCMSProps<USER extends User, EC extends EntityCollection> = {
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Use this function to return the components you want to render under
|
|
@@ -119,7 +119,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
119
119
|
/**
|
|
120
120
|
* Delegate for implementing your auth operations.
|
|
121
121
|
*/
|
|
122
|
-
authController: AuthController<
|
|
122
|
+
authController: AuthController<USER>;
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Use this controller to access the configuration that is stored locally,
|
|
@@ -18,7 +18,7 @@ import { AnalyticsController } from "./analytics_controller";
|
|
|
18
18
|
* @group Hooks and utilities
|
|
19
19
|
* @see useFireCMSContext
|
|
20
20
|
*/
|
|
21
|
-
export type FireCMSContext<
|
|
21
|
+
export type FireCMSContext<USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>> = {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Connector to your database, e.g. your Firestore database
|
package/src/types/permissions.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface Permissions {
|
|
|
32
32
|
* Props passed to a {@link PermissionsBuilder}
|
|
33
33
|
* @group Models
|
|
34
34
|
*/
|
|
35
|
-
export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCollection,
|
|
35
|
+
export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCollection, USER extends User = User, M extends object = InferCollectionType<EC>> {
|
|
36
36
|
/**
|
|
37
37
|
* Entity being edited, might be null in some cases, when the operation
|
|
38
38
|
* refers to the collection.
|
|
@@ -54,7 +54,7 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
54
54
|
/**
|
|
55
55
|
* Logged in user
|
|
56
56
|
*/
|
|
57
|
-
user:
|
|
57
|
+
user: USER | null;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Collection these permissions apply to
|
|
@@ -64,7 +64,7 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
64
64
|
/**
|
|
65
65
|
* Auth controller
|
|
66
66
|
*/
|
|
67
|
-
authController: AuthController<
|
|
67
|
+
authController: AuthController<USER>;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -72,10 +72,10 @@ export interface PermissionsBuilderProps<EC extends EntityCollection = EntityCol
|
|
|
72
72
|
* based on the logged user or collection.
|
|
73
73
|
* @group Models
|
|
74
74
|
*/
|
|
75
|
-
export type PermissionsBuilder<EC extends EntityCollection = EntityCollection,
|
|
75
|
+
export type PermissionsBuilder<EC extends EntityCollection = EntityCollection, USER extends User = User, M extends object = InferCollectionType<EC>> =
|
|
76
76
|
(({
|
|
77
77
|
pathSegments,
|
|
78
78
|
user,
|
|
79
79
|
collection,
|
|
80
80
|
authController
|
|
81
|
-
}: PermissionsBuilderProps<EC,
|
|
81
|
+
}: PermissionsBuilderProps<EC, USER, M>) => Permissions | undefined);
|
package/src/types/plugins.tsx
CHANGED
|
@@ -166,7 +166,7 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
166
166
|
*
|
|
167
167
|
* @group Models
|
|
168
168
|
*/
|
|
169
|
-
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any,
|
|
169
|
+
export interface PluginHomePageActionsProps<EP extends object = object, M extends Record<string, any> = any, USER extends User = User, EC extends EntityCollection<M> = EntityCollection<M>> {
|
|
170
170
|
/**
|
|
171
171
|
* Collection path of this entity. This is the full path, like
|
|
172
172
|
* `users/1234/addresses`
|
|
@@ -181,19 +181,19 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
|
|
|
181
181
|
/**
|
|
182
182
|
* Context of the app status
|
|
183
183
|
*/
|
|
184
|
-
context: FireCMSContext<
|
|
184
|
+
context: FireCMSContext<USER>;
|
|
185
185
|
|
|
186
186
|
extraProps?: EP;
|
|
187
187
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
export interface PluginFormActionProps<
|
|
190
|
+
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
191
191
|
entityId?: string;
|
|
192
192
|
path: string;
|
|
193
193
|
status: EntityStatus;
|
|
194
194
|
collection: EC;
|
|
195
195
|
formContext?: FormContext<any>;
|
|
196
|
-
context: FireCMSContext<
|
|
196
|
+
context: FireCMSContext<USER>;
|
|
197
197
|
currentEntityId?: string;
|
|
198
198
|
}
|
|
199
199
|
|
|
@@ -207,11 +207,11 @@ export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Reco
|
|
|
207
207
|
collection?: EC;
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
-
export interface PluginGenericProps<
|
|
211
|
-
context: FireCMSContext<
|
|
210
|
+
export interface PluginGenericProps<USER extends User = User> {
|
|
211
|
+
context: FireCMSContext<USER>;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
export interface PluginHomePageAdditionalCardsProps<
|
|
214
|
+
export interface PluginHomePageAdditionalCardsProps<USER extends User = User> {
|
|
215
215
|
group?: string;
|
|
216
|
-
context: FireCMSContext<
|
|
216
|
+
context: FireCMSContext<USER>;
|
|
217
217
|
}
|