@firecms/core 3.0.0-canary.5 → 3.0.0-canary.50
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/README.md +2 -2
- package/dist/components/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -11
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +12 -3
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
- package/dist/components/EntityPreview.d.ts +25 -7
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/FieldCaption.d.ts +5 -0
- package/dist/components/FireCMSAppBar.d.ts +3 -2
- package/dist/components/HomePage/NavigationCard.d.ts +8 -0
- package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +2 -2
- package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
- package/dist/components/HomePage/index.d.ts +3 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +1 -1
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +4 -2
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/core/{EntityView.d.ts → EntityEditView.d.ts} +2 -2
- package/dist/core/NavigationRoutes.d.ts +1 -1
- package/dist/core/Scaffold.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/StorageItemPreview.d.ts +3 -2
- package/dist/form/components/StorageUploadProgress.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/StorageUploadFieldBinding.d.ts +4 -3
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
- package/dist/form/validation.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +2 -2
- package/dist/hooks/data/save.d.ts +2 -3
- package/dist/hooks/data/useDataSource.d.ts +2 -2
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useBuildNavigationController.d.ts +6 -4
- package/dist/hooks/useProjectLog.d.ts +6 -2
- package/dist/hooks/useStorageSource.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/index.es.js +10402 -9898
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -12
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +1 -4
- package/dist/preview/components/BooleanPreview.d.ts +5 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -7
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +37 -1
- package/dist/types/collections.d.ts +29 -5
- package/dist/types/datasource.d.ts +3 -6
- package/dist/types/entities.d.ts +5 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/entity_callbacks.d.ts +2 -2
- package/dist/types/entity_overrides.d.ts +6 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +14 -13
- package/dist/types/permissions.d.ts +5 -1
- package/dist/types/plugins.d.ts +20 -20
- package/dist/types/properties.d.ts +4 -4
- package/dist/types/property_config.d.ts +2 -2
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/storage.d.ts +11 -3
- package/dist/types/user.d.ts +5 -0
- package/dist/util/collections.d.ts +9 -1
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_synonyms.d.ts +1 -4
- package/dist/util/icons.d.ts +8 -2
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/references.d.ts +4 -2
- package/dist/util/resolutions.d.ts +9 -13
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +139 -119
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/DeleteEntityDialog.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +275 -278
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +44 -44
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -16
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +27 -32
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +11 -6
- package/src/components/EntityCollectionTable/internal/default_entity_actions.tsx +9 -5
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -4
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +69 -64
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityCollectionView/useSelectionController.tsx +30 -0
- package/src/components/EntityPreview.tsx +207 -70
- package/src/components/EntityView.tsx +84 -0
- package/src/components/FieldCaption.tsx +14 -0
- package/src/components/FireCMSAppBar.tsx +33 -11
- package/src/components/HomePage/DefaultHomePage.tsx +15 -11
- package/src/components/HomePage/NavigationCard.tsx +69 -0
- package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
- package/src/components/HomePage/index.tsx +3 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
- package/src/components/ReferenceWidget.tsx +4 -4
- package/src/components/SearchIconsView.tsx +4 -4
- package/src/components/SelectableTable/SelectableTable.tsx +1 -1
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +23 -8
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +35 -24
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +28 -20
- package/src/components/VirtualTable/VirtualTableProps.tsx +1 -1
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
- package/src/components/index.tsx +4 -2
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/core/Drawer.tsx +66 -39
- package/src/core/{EntityView.tsx → EntityEditView.tsx} +21 -40
- package/src/core/EntitySidePanel.tsx +2 -2
- package/src/core/FireCMS.tsx +18 -3
- package/src/core/NavigationRoutes.tsx +11 -4
- package/src/core/Scaffold.tsx +5 -4
- package/src/core/field_configs.tsx +1 -2
- package/src/form/EntityForm.tsx +40 -21
- package/src/form/PropertyFieldBinding.tsx +0 -2
- package/src/form/components/StorageItemPreview.tsx +5 -3
- package/src/form/components/StorageUploadProgress.tsx +7 -6
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +8 -12
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +15 -15
- package/src/form/field_bindings/MapFieldBinding.tsx +15 -15
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +1 -1
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -0
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +14 -5
- package/src/form/field_bindings/TextFieldBinding.tsx +7 -5
- package/src/form/validation.ts +3 -4
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +2 -2
- package/src/hooks/data/useCollectionFetch.tsx +1 -1
- package/src/hooks/data/useDataSource.tsx +8 -3
- package/src/hooks/data/useEntityFetch.tsx +4 -4
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBuildLocalConfigurationPersistence.tsx +9 -10
- package/src/hooks/useBuildModeController.tsx +11 -5
- package/src/hooks/useBuildNavigationController.tsx +199 -81
- package/src/hooks/useProjectLog.tsx +17 -7
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useStorageSource.tsx +7 -2
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/internal/useBuildDataSource.ts +42 -44
- package/src/internal/useBuildSideEntityController.tsx +86 -20
- package/src/preview/PropertyPreview.tsx +3 -14
- package/src/preview/PropertyPreviewProps.tsx +1 -11
- package/src/preview/components/BooleanPreview.tsx +19 -4
- package/src/preview/components/EnumValuesChip.tsx +1 -1
- package/src/preview/components/ReferencePreview.tsx +55 -147
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +0 -1
- package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
- package/src/types/analytics.ts +1 -0
- package/src/types/auth.tsx +50 -1
- package/src/types/collections.ts +33 -5
- package/src/types/datasource.ts +8 -5
- package/src/types/entities.ts +9 -1
- package/src/types/entity_actions.tsx +17 -0
- package/src/types/entity_callbacks.ts +2 -2
- package/src/types/entity_overrides.tsx +7 -0
- package/src/types/firecms.tsx +0 -1
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +17 -16
- package/src/types/permissions.ts +6 -1
- package/src/types/plugins.tsx +26 -28
- package/src/types/properties.ts +8 -6
- package/src/types/property_config.tsx +2 -2
- package/src/types/roles.ts +41 -0
- package/src/types/side_entity_controller.tsx +1 -0
- package/src/types/storage.ts +12 -3
- package/src/types/user.ts +7 -0
- package/src/util/collections.ts +22 -0
- package/src/util/entities.ts +1 -1
- package/src/util/icon_list.ts +2 -2
- package/src/util/icon_synonyms.ts +1 -4
- package/src/util/icons.tsx +11 -3
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +0 -14
- package/src/util/permissions.ts +11 -8
- package/src/util/references.ts +36 -5
- package/src/util/resolutions.ts +6 -24
- package/src/util/strings.ts +2 -2
- package/src/util/useTraceUpdate.tsx +2 -1
- package/dist/core/SideEntityView.d.ts +0 -7
- package/dist/internal/useLocaleConfig.d.ts +0 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
- package/src/core/SideEntityView.tsx +0 -38
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
package/src/util/permissions.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthController, Entity, EntityCollection, Permissions, User } from "../types";
|
|
2
|
+
import { fullPathToCollectionSegments } from "./paths";
|
|
2
3
|
|
|
3
4
|
const DEFAULT_PERMISSIONS = {
|
|
4
5
|
read: true,
|
|
@@ -10,8 +11,8 @@ const DEFAULT_PERMISSIONS = {
|
|
|
10
11
|
export function resolvePermissions<M extends Record<string, any>, UserType extends User>
|
|
11
12
|
(collection: EntityCollection<M>,
|
|
12
13
|
authController: AuthController<UserType>,
|
|
13
|
-
|
|
14
|
-
entity: Entity<M> | null): Permissions {
|
|
14
|
+
path: string,
|
|
15
|
+
entity: Entity<M> | null): Permissions | undefined {
|
|
15
16
|
|
|
16
17
|
const permission = collection.permissions;
|
|
17
18
|
if (permission === undefined) {
|
|
@@ -19,8 +20,10 @@ export function resolvePermissions<M extends Record<string, any>, UserType exten
|
|
|
19
20
|
} else if (typeof permission === "object") {
|
|
20
21
|
return permission as Permissions;
|
|
21
22
|
} else if (typeof permission === "function") {
|
|
23
|
+
const pathSegments = fullPathToCollectionSegments(path);
|
|
22
24
|
return permission({
|
|
23
25
|
entity,
|
|
26
|
+
path,
|
|
24
27
|
user: authController.user,
|
|
25
28
|
authController,
|
|
26
29
|
collection,
|
|
@@ -35,27 +38,27 @@ export function canEditEntity<M extends Record<string, any>, UserType extends Us
|
|
|
35
38
|
(
|
|
36
39
|
collection: EntityCollection<M>,
|
|
37
40
|
authController: AuthController<UserType>,
|
|
38
|
-
|
|
41
|
+
path: string,
|
|
39
42
|
entity: Entity<M> | null): boolean {
|
|
40
|
-
return resolvePermissions(collection, authController,
|
|
43
|
+
return resolvePermissions(collection, authController, path, entity)?.edit ?? DEFAULT_PERMISSIONS.edit;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
export function canCreateEntity<M extends Record<string, any>, UserType extends User>
|
|
44
47
|
(
|
|
45
48
|
collection: EntityCollection<M>,
|
|
46
49
|
authController: AuthController<UserType>,
|
|
47
|
-
|
|
50
|
+
path: string,
|
|
48
51
|
entity: Entity<M> | null): boolean {
|
|
49
|
-
return resolvePermissions(collection, authController,
|
|
52
|
+
return resolvePermissions(collection, authController, path, entity)?.create ?? DEFAULT_PERMISSIONS.create;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
export function canDeleteEntity<M extends Record<string, any>, UserType extends User>
|
|
53
56
|
(
|
|
54
57
|
collection: EntityCollection<M>,
|
|
55
58
|
authController: AuthController<UserType>,
|
|
56
|
-
|
|
59
|
+
path: string,
|
|
57
60
|
entity: Entity<M> | null): boolean {
|
|
58
|
-
return resolvePermissions(collection, authController,
|
|
61
|
+
return resolvePermissions(collection, authController, path, entity)?.delete ?? DEFAULT_PERMISSIONS.delete;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
// export function resolveCollectionsPermissions(roles: Role[]): Record<string, Permissions> {
|
package/src/util/references.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { EntityCollection, PropertyConfig } from "../types";
|
|
1
|
+
import { EntityCollection, PropertyConfig, ResolvedEntityCollection } from "../types";
|
|
2
2
|
import { isReferenceProperty } from "./property_utils";
|
|
3
3
|
import { isPropertyBuilder } from "./entities";
|
|
4
|
+
import { getFieldConfig } from "../core";
|
|
4
5
|
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function getEntityPreviewKeys(targetCollection: EntityCollection<any>,
|
|
7
|
+
fields: Record<string, PropertyConfig>,
|
|
8
|
+
previewProperties?: string[],
|
|
9
|
+
limit = 3) {
|
|
9
10
|
const allProperties = Object.keys(targetCollection.properties);
|
|
10
11
|
let listProperties = previewProperties?.filter(p => allProperties.includes(p as string));
|
|
11
12
|
if (listProperties && listProperties.length > 0) {
|
|
@@ -18,3 +19,33 @@ export function getReferencePreviewKeys(targetCollection: EntityCollection<any>,
|
|
|
18
19
|
}).slice(0, limit);
|
|
19
20
|
}
|
|
20
21
|
}
|
|
22
|
+
|
|
23
|
+
export function getEntityTitlePropertyKey<M extends Record<string, any>>(collection: EntityCollection<M>, propertyConfigs: Record<string, PropertyConfig<any>>): string | undefined {
|
|
24
|
+
if (collection.titleProperty) {
|
|
25
|
+
return collection.titleProperty as string;
|
|
26
|
+
}
|
|
27
|
+
// find first text field property
|
|
28
|
+
for (const key in collection.properties) {
|
|
29
|
+
const property = collection.properties[key];
|
|
30
|
+
if (!isPropertyBuilder(property)) {
|
|
31
|
+
const field = getFieldConfig(property, propertyConfigs);
|
|
32
|
+
if (field?.key === "text_field") {
|
|
33
|
+
return key;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getEntityImagePreviewPropertyKey<M extends object>(collection: ResolvedEntityCollection<M>): string | undefined {
|
|
41
|
+
|
|
42
|
+
// find first text field property
|
|
43
|
+
for (const key in collection.properties) {
|
|
44
|
+
const property = collection.properties[key];
|
|
45
|
+
if (property.dataType === "string" && property.storage?.acceptedFiles?.includes("image/*")) {
|
|
46
|
+
return key;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
package/src/util/resolutions.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { getDefaultValuesFor, isPropertyBuilder } from "./entities";
|
|
|
26
26
|
import { DEFAULT_ONE_OF_TYPE } from "./common";
|
|
27
27
|
import { getIn } from "@firecms/formex";
|
|
28
28
|
import { enumToObjectEntries } from "./enums";
|
|
29
|
-
import { isDefaultFieldConfigId } from "../core";
|
|
29
|
+
import { isDefaultFieldConfigId } from "../core/field_configs";
|
|
30
30
|
|
|
31
31
|
// import util from "util";
|
|
32
32
|
|
|
@@ -58,14 +58,12 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
58
58
|
|
|
59
59
|
const resolvedProperties = Object.entries(collection.properties)
|
|
60
60
|
.map(([key, propertyOrBuilder]) => {
|
|
61
|
-
const propertyValue = usedValues ? getIn(usedValues, key) : undefined;
|
|
62
61
|
const childResolvedProperty = resolveProperty({
|
|
63
62
|
propertyKey: key,
|
|
64
63
|
propertyOrBuilder: propertyOrBuilder as PropertyOrBuilder | ResolvedProperty,
|
|
65
64
|
values: usedValues,
|
|
66
65
|
previousValues: usedPreviousValues,
|
|
67
66
|
path,
|
|
68
|
-
propertyValue,
|
|
69
67
|
entityId,
|
|
70
68
|
fields
|
|
71
69
|
});
|
|
@@ -95,17 +93,14 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
95
93
|
* Resolve property builders, enums and arrays.
|
|
96
94
|
* @param propertyOrBuilder
|
|
97
95
|
* @param propertyValue
|
|
98
|
-
* @param values
|
|
99
96
|
*/
|
|
100
97
|
export function resolveProperty<T extends CMSType = CMSType, M extends Record<string, any> = any>({
|
|
101
98
|
propertyOrBuilder,
|
|
102
|
-
propertyValue,
|
|
103
99
|
fromBuilder = false,
|
|
104
100
|
...props
|
|
105
101
|
}: {
|
|
106
102
|
propertyKey?: string,
|
|
107
103
|
propertyOrBuilder: PropertyOrBuilder<T, M> | ResolvedProperty<T>,
|
|
108
|
-
propertyValue?: unknown,
|
|
109
104
|
values?: Partial<M>,
|
|
110
105
|
previousValues?: Partial<M>,
|
|
111
106
|
path?: string,
|
|
@@ -128,10 +123,11 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
128
123
|
if (!path)
|
|
129
124
|
throw Error("Trying to resolve a property builder without specifying the entity path");
|
|
130
125
|
|
|
126
|
+
const usedPropertyValue = props.propertyKey ? getIn(props.values, props.propertyKey) : undefined;
|
|
131
127
|
const result: Property<T> | null = propertyOrBuilder({
|
|
132
128
|
...props,
|
|
133
129
|
path,
|
|
134
|
-
propertyValue,
|
|
130
|
+
propertyValue: usedPropertyValue,
|
|
135
131
|
values: props.values ?? {},
|
|
136
132
|
previousValues: props.previousValues ?? props.values ?? {}
|
|
137
133
|
});
|
|
@@ -142,7 +138,6 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
142
138
|
|
|
143
139
|
resolvedProperty = resolveProperty({
|
|
144
140
|
...props,
|
|
145
|
-
propertyValue,
|
|
146
141
|
propertyOrBuilder: result,
|
|
147
142
|
fromBuilder: true
|
|
148
143
|
});
|
|
@@ -152,7 +147,6 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
152
147
|
const properties = resolveProperties({
|
|
153
148
|
...props,
|
|
154
149
|
properties: property.properties,
|
|
155
|
-
propertyValue
|
|
156
150
|
});
|
|
157
151
|
resolvedProperty = {
|
|
158
152
|
...property,
|
|
@@ -163,7 +157,6 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
163
157
|
} else if (property.dataType === "array") {
|
|
164
158
|
resolvedProperty = resolveArrayProperty({
|
|
165
159
|
property,
|
|
166
|
-
propertyValue,
|
|
167
160
|
fromBuilder,
|
|
168
161
|
...props
|
|
169
162
|
}) as ResolvedProperty<any>;
|
|
@@ -183,11 +176,11 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
183
176
|
if (resolvedProperty.propertyConfig && !isDefaultFieldConfigId(resolvedProperty.propertyConfig)) {
|
|
184
177
|
const cmsFields = props.fields;
|
|
185
178
|
if (!cmsFields) {
|
|
186
|
-
throw Error(`Trying to resolve a property with key ${resolvedProperty.propertyConfig} that inherits from a custom property config but no custom property configs were provided. Use the property
|
|
179
|
+
throw Error(`Trying to resolve a property with key '${resolvedProperty.propertyConfig}' that inherits from a custom property config but no custom property configs were provided. Use the property 'propertyConfigs' in your app config to provide them`);
|
|
187
180
|
}
|
|
188
181
|
const customField: PropertyConfig<any> = cmsFields[resolvedProperty.propertyConfig];
|
|
189
182
|
if (!customField) {
|
|
190
|
-
console.warn(`Trying to resolve a property with key ${resolvedProperty.propertyConfig} that inherits from a custom property config but no custom property config with that key was found. Check the
|
|
183
|
+
console.warn(`Trying to resolve a property with key '${resolvedProperty.propertyConfig}' that inherits from a custom property config but no custom property config with that key was found. Check the 'propertyConfigs' in your app config`)
|
|
191
184
|
console.warn("Available property configs", cmsFields);
|
|
192
185
|
return null;
|
|
193
186
|
}
|
|
@@ -198,7 +191,6 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
198
191
|
}
|
|
199
192
|
const customFieldProperty = resolveProperty<any>({
|
|
200
193
|
propertyOrBuilder: configPropertyOrBuilder,
|
|
201
|
-
propertyValue,
|
|
202
194
|
...props
|
|
203
195
|
});
|
|
204
196
|
if (customFieldProperty) {
|
|
@@ -219,12 +211,10 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
219
211
|
export function resolveArrayProperty<T extends any[], M>({
|
|
220
212
|
propertyKey,
|
|
221
213
|
property,
|
|
222
|
-
propertyValue,
|
|
223
214
|
...props
|
|
224
215
|
}: {
|
|
225
216
|
propertyKey?: string,
|
|
226
217
|
property: ArrayProperty<T> | ResolvedArrayProperty<T>,
|
|
227
|
-
propertyValue: any,
|
|
228
218
|
values?: Partial<M>,
|
|
229
219
|
previousValues?: Partial<M>,
|
|
230
220
|
path?: string,
|
|
@@ -233,6 +223,7 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
233
223
|
fromBuilder?: boolean;
|
|
234
224
|
fields?: Record<string, PropertyConfig>;
|
|
235
225
|
}): ResolvedArrayProperty {
|
|
226
|
+
const propertyValue = propertyKey ? getIn(props.values, propertyKey) : undefined;
|
|
236
227
|
|
|
237
228
|
if (property.of) {
|
|
238
229
|
if (Array.isArray(property.of)) {
|
|
@@ -244,7 +235,6 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
244
235
|
return resolveProperty({
|
|
245
236
|
propertyKey: `${propertyKey}.${index}`,
|
|
246
237
|
propertyOrBuilder: p as Property<any>,
|
|
247
|
-
propertyValue: Array.isArray(propertyValue) ? propertyValue[index] : undefined,
|
|
248
238
|
...props,
|
|
249
239
|
index
|
|
250
240
|
});
|
|
@@ -256,7 +246,6 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
256
246
|
? propertyValue.map((v: any, index: number) => resolveProperty({
|
|
257
247
|
propertyKey: `${propertyKey}.${index}`,
|
|
258
248
|
propertyOrBuilder: of,
|
|
259
|
-
propertyValue: v,
|
|
260
249
|
...props,
|
|
261
250
|
index
|
|
262
251
|
})).filter(e => Boolean(e)) as ResolvedProperty[]
|
|
@@ -264,7 +253,6 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
264
253
|
const ofProperty = resolveProperty({
|
|
265
254
|
propertyKey: `${propertyKey}`,
|
|
266
255
|
propertyOrBuilder: of,
|
|
267
|
-
propertyValue: undefined,
|
|
268
256
|
...props
|
|
269
257
|
});
|
|
270
258
|
if (!ofProperty)
|
|
@@ -287,14 +275,12 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
287
275
|
return resolveProperty({
|
|
288
276
|
propertyKey: `${propertyKey}.${index}`,
|
|
289
277
|
propertyOrBuilder: childProperty,
|
|
290
|
-
propertyValue,
|
|
291
278
|
...props
|
|
292
279
|
});
|
|
293
280
|
}).filter(e => Boolean(e)) as ResolvedProperty[]
|
|
294
281
|
: [];
|
|
295
282
|
const properties = resolveProperties<any>({
|
|
296
283
|
properties: property.oneOf.properties,
|
|
297
|
-
propertyValue: undefined,
|
|
298
284
|
...props
|
|
299
285
|
});
|
|
300
286
|
return {
|
|
@@ -326,11 +312,9 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
326
312
|
*/
|
|
327
313
|
export function resolveProperties<M extends Record<string, any>>({
|
|
328
314
|
properties,
|
|
329
|
-
propertyValue,
|
|
330
315
|
...props
|
|
331
316
|
}: {
|
|
332
317
|
properties: PropertiesOrBuilders<M>,
|
|
333
|
-
propertyValue: unknown,
|
|
334
318
|
values?: Partial<M>,
|
|
335
319
|
previousValues?: Partial<M>,
|
|
336
320
|
path?: string,
|
|
@@ -341,11 +325,9 @@ export function resolveProperties<M extends Record<string, any>>({
|
|
|
341
325
|
}): ResolvedProperties<M> {
|
|
342
326
|
return Object.entries<PropertyOrBuilder>(properties as Record<string, PropertyOrBuilder>)
|
|
343
327
|
.map(([key, property]) => {
|
|
344
|
-
const thisPropertyValue = propertyValue && typeof propertyValue === "object" ? getValueInPath(propertyValue, key) : undefined;
|
|
345
328
|
const childResolvedProperty = resolveProperty({
|
|
346
329
|
propertyKey: key,
|
|
347
330
|
propertyOrBuilder: property,
|
|
348
|
-
propertyValue: thisPropertyValue,
|
|
349
331
|
...props
|
|
350
332
|
});
|
|
351
333
|
if (!childResolvedProperty) return {};
|
package/src/util/strings.ts
CHANGED
|
@@ -56,8 +56,8 @@ export function unslugify(slug?: string): string {
|
|
|
56
56
|
const result = slug.replace(/[-_]/g, " ");
|
|
57
57
|
return result.replace(/\w\S*/g, function (txt) {
|
|
58
58
|
return txt.charAt(0).toUpperCase() + txt.substr(1);
|
|
59
|
-
});
|
|
59
|
+
}).trim();
|
|
60
60
|
} else {
|
|
61
|
-
return slug;
|
|
61
|
+
return slug.trim();
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
|
|
3
|
-
function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: number) {
|
|
3
|
+
export function printChanged(props: any, prev: any, path: string | undefined = "", depth: number | undefined = 0, maxDepth: number | undefined = 10) {
|
|
4
4
|
if (depth > maxDepth) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
@@ -17,6 +17,7 @@ function printChanged(props: any, prev: any, path = "", depth = 0, maxDepth: num
|
|
|
17
17
|
export function useTraceUpdate(props: any, maxDepth = 3) {
|
|
18
18
|
const prev = useRef(props);
|
|
19
19
|
useEffect(() => {
|
|
20
|
+
console.log("Changed props:");
|
|
20
21
|
printChanged(props, prev.current, "", 0, maxDepth);
|
|
21
22
|
prev.current = props;
|
|
22
23
|
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EntityViewProps } from "./EntityView";
|
|
2
|
-
import { User } from "../types";
|
|
3
|
-
export type SideEntityViewProps<M extends Record<string, any>> = EntityViewProps<M> & {
|
|
4
|
-
formWidth?: number | string;
|
|
5
|
-
onClose?: () => void;
|
|
6
|
-
};
|
|
7
|
-
export declare function SideEntityView<M extends Record<string, any>, UserType extends User>({ path, entityId, selectedSubPath, copy, collection, parentCollectionIds, onValuesAreModified, formWidth, onUpdate, onClose }: SideEntityViewProps<M>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useLocaleConfig(locale?: string): void;
|
package/dist/types/appcheck.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FirebaseApp } from "firebase/app";
|
|
2
|
-
/**
|
|
3
|
-
* @group Firebase
|
|
4
|
-
*/
|
|
5
|
-
export interface AppCheck {
|
|
6
|
-
firebaseApp?: FirebaseApp;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @group Firebase
|
|
10
|
-
*/
|
|
11
|
-
export interface AppCheckOptions {
|
|
12
|
-
providerKey: string;
|
|
13
|
-
useEnterpriseRecaptcha: boolean;
|
|
14
|
-
isTokenAutoRefreshEnabled?: boolean;
|
|
15
|
-
debugToken?: string;
|
|
16
|
-
forceRefresh?: boolean;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* @group Firebase
|
|
20
|
-
*/
|
|
21
|
-
export declare interface AppCheckTokenResult {
|
|
22
|
-
/**
|
|
23
|
-
* The token string in JWT format.
|
|
24
|
-
*/
|
|
25
|
-
readonly token: string;
|
|
26
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { useNavigate } from "react-router-dom";
|
|
2
|
-
|
|
3
|
-
import { useCustomizationController, useFireCMSContext } from "../../hooks";
|
|
4
|
-
import { PluginHomePageActionsProps, TopNavigationEntry } from "../../types";
|
|
5
|
-
import { IconForView } from "../../util";
|
|
6
|
-
import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
|
|
7
|
-
import { ArrowForwardIcon, Card, cn, IconButton, Markdown, StarBorderIcon, StarIcon, Typography } from "@firecms/ui";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This is the component used in the home page to render a card for each
|
|
11
|
-
* collection.
|
|
12
|
-
* @group Components
|
|
13
|
-
* @param view
|
|
14
|
-
* @param path
|
|
15
|
-
* @param collection
|
|
16
|
-
* @param url
|
|
17
|
-
* @param name
|
|
18
|
-
* @param description
|
|
19
|
-
* @param onClick
|
|
20
|
-
* @constructor
|
|
21
|
-
*/
|
|
22
|
-
export function NavigationCollectionCard({
|
|
23
|
-
view,
|
|
24
|
-
path,
|
|
25
|
-
collection,
|
|
26
|
-
url,
|
|
27
|
-
name,
|
|
28
|
-
description,
|
|
29
|
-
onClick
|
|
30
|
-
}: TopNavigationEntry & {
|
|
31
|
-
onClick?: () => void
|
|
32
|
-
}) {
|
|
33
|
-
|
|
34
|
-
const userConfigurationPersistence = useUserConfigurationPersistence();
|
|
35
|
-
const collectionIcon = <IconForView collectionOrView={collection ?? view}/>;
|
|
36
|
-
|
|
37
|
-
const navigate = useNavigate();
|
|
38
|
-
const context = useFireCMSContext();
|
|
39
|
-
const customizationController = useCustomizationController();
|
|
40
|
-
|
|
41
|
-
const favourite = (userConfigurationPersistence?.favouritePaths ?? []).includes(path);
|
|
42
|
-
|
|
43
|
-
let actions: React.ReactNode | undefined;
|
|
44
|
-
if (customizationController.plugins && collection) {
|
|
45
|
-
const actionProps: PluginHomePageActionsProps = {
|
|
46
|
-
path,
|
|
47
|
-
collection,
|
|
48
|
-
context
|
|
49
|
-
};
|
|
50
|
-
actions = <>
|
|
51
|
-
{customizationController.plugins.map((plugin, i) => (
|
|
52
|
-
plugin.homePage?.CollectionActions
|
|
53
|
-
? <plugin.homePage.CollectionActions
|
|
54
|
-
key={`actions_${i}`}
|
|
55
|
-
{...actionProps}
|
|
56
|
-
extraProps={plugin.homePage.extraProps}
|
|
57
|
-
/>
|
|
58
|
-
: null
|
|
59
|
-
))}
|
|
60
|
-
</>
|
|
61
|
-
;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<Card
|
|
66
|
-
className={cn("h-full p-4 cursor-pointer min-h-[230px]")}
|
|
67
|
-
onClick={() => {
|
|
68
|
-
onClick?.();
|
|
69
|
-
navigate(url);
|
|
70
|
-
if (userConfigurationPersistence) {
|
|
71
|
-
userConfigurationPersistence.setRecentlyVisitedPaths(
|
|
72
|
-
[path, ...(userConfigurationPersistence.recentlyVisitedPaths ?? []).filter(p => p !== path)]
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
}}>
|
|
76
|
-
|
|
77
|
-
<div className="flex flex-col items-start h-full">
|
|
78
|
-
<div
|
|
79
|
-
className="flex-grow w-full">
|
|
80
|
-
|
|
81
|
-
<div
|
|
82
|
-
className="h-10 flex items-center w-full justify-between text-gray-300 dark:text-gray-600">
|
|
83
|
-
|
|
84
|
-
{collectionIcon}
|
|
85
|
-
|
|
86
|
-
<div
|
|
87
|
-
className="flex items-center gap-1"
|
|
88
|
-
onClick={(event: React.MouseEvent) => {
|
|
89
|
-
event.preventDefault();
|
|
90
|
-
event.stopPropagation();
|
|
91
|
-
}}>
|
|
92
|
-
|
|
93
|
-
{actions}
|
|
94
|
-
|
|
95
|
-
{userConfigurationPersistence &&
|
|
96
|
-
<IconButton
|
|
97
|
-
onClick={(e) => {
|
|
98
|
-
e.preventDefault();
|
|
99
|
-
e.stopPropagation();
|
|
100
|
-
if (favourite) {
|
|
101
|
-
userConfigurationPersistence.setFavouritePaths(
|
|
102
|
-
userConfigurationPersistence.favouritePaths.filter(p => p !== path)
|
|
103
|
-
);
|
|
104
|
-
} else {
|
|
105
|
-
userConfigurationPersistence.setFavouritePaths(
|
|
106
|
-
[...userConfigurationPersistence.favouritePaths, path]
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
}}>
|
|
110
|
-
{
|
|
111
|
-
favourite
|
|
112
|
-
? <StarIcon
|
|
113
|
-
size={18}
|
|
114
|
-
className={"text-secondary"}/>
|
|
115
|
-
: <StarBorderIcon
|
|
116
|
-
size={18}
|
|
117
|
-
className={"text-gray-400 dark:text-gray-500"}/>}
|
|
118
|
-
</IconButton>}
|
|
119
|
-
|
|
120
|
-
</div>
|
|
121
|
-
|
|
122
|
-
</div>
|
|
123
|
-
|
|
124
|
-
<Typography gutterBottom variant="h5"
|
|
125
|
-
component="h2">
|
|
126
|
-
{name}
|
|
127
|
-
</Typography>
|
|
128
|
-
|
|
129
|
-
{description && <Typography variant="body2"
|
|
130
|
-
color="secondary"
|
|
131
|
-
component="div">
|
|
132
|
-
<Markdown source={description}/>
|
|
133
|
-
</Typography>}
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
|
-
<div style={{ alignSelf: "flex-end" }}>
|
|
137
|
-
|
|
138
|
-
<div className={"p-4"}>
|
|
139
|
-
<ArrowForwardIcon className="text-primary"/>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
|
|
143
|
-
</div>
|
|
144
|
-
|
|
145
|
-
</Card>);
|
|
146
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { EntityViewProps } from "./EntityView";
|
|
2
|
-
import { User } from "../types";
|
|
3
|
-
import { useSideDialogContext } from "./SideDialogs";
|
|
4
|
-
import { useSideEntityController } from "../hooks";
|
|
5
|
-
import { FORM_CONTAINER_WIDTH } from "../internal/common";
|
|
6
|
-
|
|
7
|
-
export type SideEntityViewProps<M extends Record<string, any>> = EntityViewProps<M> & {
|
|
8
|
-
formWidth?: number | string;
|
|
9
|
-
onClose?: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function SideEntityView<M extends Record<string, any>, UserType extends User>({
|
|
13
|
-
path,
|
|
14
|
-
entityId,
|
|
15
|
-
selectedSubPath,
|
|
16
|
-
copy,
|
|
17
|
-
collection,
|
|
18
|
-
parentCollectionIds,
|
|
19
|
-
onValuesAreModified,
|
|
20
|
-
formWidth,
|
|
21
|
-
onUpdate,
|
|
22
|
-
onClose
|
|
23
|
-
}: SideEntityViewProps<M>) {
|
|
24
|
-
|
|
25
|
-
const sideDialogContext = useSideDialogContext();
|
|
26
|
-
const sideEntityController = useSideEntityController();
|
|
27
|
-
const resolvedFormWidth: string = typeof formWidth === "number" ? `${formWidth}px` : formWidth ?? FORM_CONTAINER_WIDTH;
|
|
28
|
-
|
|
29
|
-
const onCloseHandler = () => {
|
|
30
|
-
if (onClose) {
|
|
31
|
-
onClose();
|
|
32
|
-
} else {
|
|
33
|
-
sideDialogContext.close();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return <></>;
|
|
38
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as locales from "date-fns/locale";
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import { registerLocale, setDefaultLocale } from "react-datepicker";
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
|
|
6
|
-
export function useLocaleConfig(locale?: string) {
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
if (!locale) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
const dateFnsLocale = locales[locale];
|
|
13
|
-
if (dateFnsLocale) {
|
|
14
|
-
registerLocale(locale, dateFnsLocale);
|
|
15
|
-
setDefaultLocale(locale);
|
|
16
|
-
}
|
|
17
|
-
}, [locale])
|
|
18
|
-
}
|
package/src/types/appcheck.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { FirebaseApp } from "firebase/app";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @group Firebase
|
|
5
|
-
*/
|
|
6
|
-
export interface AppCheck {
|
|
7
|
-
firebaseApp?: FirebaseApp;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @group Firebase
|
|
12
|
-
*/
|
|
13
|
-
export interface AppCheckOptions {
|
|
14
|
-
providerKey: string;
|
|
15
|
-
useEnterpriseRecaptcha: boolean;
|
|
16
|
-
isTokenAutoRefreshEnabled?: boolean;
|
|
17
|
-
debugToken?: string;
|
|
18
|
-
forceRefresh?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @group Firebase
|
|
23
|
-
*/
|
|
24
|
-
export declare interface AppCheckTokenResult {
|
|
25
|
-
/**
|
|
26
|
-
* The token string in JWT format.
|
|
27
|
-
*/
|
|
28
|
-
readonly token: string;
|
|
29
|
-
}
|