@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
|
@@ -23,8 +23,6 @@ export type PropertyConfig<T extends CMSType = any> = {
|
|
|
23
23
|
* Default config for the property.
|
|
24
24
|
* This property or builder will be used as the base values for the resulting property.
|
|
25
25
|
* You can also use a builder function to generate the base property.
|
|
26
|
-
* You can use a builder function to generate the property based on the values or the path.
|
|
27
|
-
* You can also define a custom Field as a React component to be used for this property.
|
|
28
26
|
*/
|
|
29
27
|
property: PropertyOrBuilder<T>;
|
|
30
28
|
|
package/src/types/user.ts
CHANGED
package/src/util/builders.ts
CHANGED
|
@@ -27,9 +27,9 @@ import {
|
|
|
27
27
|
* @group Builder
|
|
28
28
|
*/
|
|
29
29
|
export function buildCollection<M extends Record<string, any> = any,
|
|
30
|
-
|
|
31
|
-
collection: EntityCollection<M,
|
|
32
|
-
): EntityCollection<M,
|
|
30
|
+
USER extends User = User>(
|
|
31
|
+
collection: EntityCollection<M, USER>
|
|
32
|
+
): EntityCollection<M, USER> {
|
|
33
33
|
return collection;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -120,9 +120,9 @@ export function buildEntityCallbacks<M extends Record<string, any> = any>(
|
|
|
120
120
|
* @param additionalFieldDelegate
|
|
121
121
|
* @group Builder
|
|
122
122
|
*/
|
|
123
|
-
export function buildAdditionalFieldDelegate<M extends Record<string, any>,
|
|
124
|
-
additionalFieldDelegate: AdditionalFieldDelegate<M,
|
|
125
|
-
): AdditionalFieldDelegate<M,
|
|
123
|
+
export function buildAdditionalFieldDelegate<M extends Record<string, any>, USER extends User = User>(
|
|
124
|
+
additionalFieldDelegate: AdditionalFieldDelegate<M, USER>
|
|
125
|
+
): AdditionalFieldDelegate<M, USER> {
|
|
126
126
|
return additionalFieldDelegate;
|
|
127
127
|
}
|
|
128
128
|
|
package/src/util/entities.ts
CHANGED
|
@@ -40,13 +40,15 @@ export function getDefaultValuesFor<M extends Record<string, any>>(properties: P
|
|
|
40
40
|
if (!properties) return {};
|
|
41
41
|
return Object.entries(properties)
|
|
42
42
|
.map(([key, property]) => {
|
|
43
|
+
if (!property) return {};
|
|
43
44
|
const value = getDefaultValueFor(property as PropertyOrBuilder);
|
|
44
45
|
return value === undefined ? {} : { [key]: value };
|
|
45
46
|
})
|
|
46
47
|
.reduce((a, b) => ({ ...a, ...b }), {}) as EntityValues<M>;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
export function getDefaultValueFor(property
|
|
50
|
+
export function getDefaultValueFor(property?: PropertyOrBuilder) {
|
|
51
|
+
if (!property) return undefined;
|
|
50
52
|
if (isPropertyBuilder(property)) return undefined;
|
|
51
53
|
if (property.defaultValue || property.defaultValue === null) {
|
|
52
54
|
return property.defaultValue;
|
package/src/util/icon_list.ts
CHANGED
|
@@ -1222,7 +1222,6 @@ export const iconSynonyms = {
|
|
|
1222
1222
|
picture_in_picture_alt: "cropped overlap photo position shape",
|
|
1223
1223
|
pie_chart: "analytics bars data diagram infographic measure metrics statistics tracking",
|
|
1224
1224
|
pie_chart_outline: "analytics bars data diagram infographic measure metrics statistics tracking",
|
|
1225
|
-
pie_chart_outlined: "graph",
|
|
1226
1225
|
pin: "1 2 3 digit key login logout number password pattern security star symbol unlock",
|
|
1227
1226
|
pinch: "arrows compress direction finger grasp hand navigation nip squeeze tweak",
|
|
1228
1227
|
pin_drop: "destination direction gps location maps navigation place stop",
|
package/src/util/icons.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { hashString } from "./hash";
|
|
3
|
-
import { coolIconKeys, Icon, iconKeys } from "@firecms/ui";
|
|
3
|
+
import { coolIconKeys, Icon, IconColor, iconKeys } from "@firecms/ui";
|
|
4
4
|
import { slugify } from "./strings";
|
|
5
5
|
import equal from "react-fast-compare"
|
|
6
6
|
|
|
7
|
-
export function getIcon(iconKey?: string, className?: string): React.ReactElement | undefined {
|
|
7
|
+
export function getIcon(iconKey?: string, className?: string, color?:IconColor): React.ReactElement | undefined {
|
|
8
8
|
if (!iconKey) return undefined;
|
|
9
9
|
iconKey = slugify(iconKey);
|
|
10
10
|
if (!(iconKey in iconKeysMap)) {
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
|
-
return iconKey in iconKeysMap ? <Icon iconKey={iconKey} size={"medium"} className={className}/> : undefined;
|
|
13
|
+
return iconKey in iconKeysMap ? <Icon iconKey={iconKey} size={"medium"} className={className} color={color}/> : undefined;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type IconViewProps = {
|
|
@@ -25,12 +25,16 @@ export const IconForView = React.memo(
|
|
|
25
25
|
function IconForView({
|
|
26
26
|
collectionOrView,
|
|
27
27
|
className,
|
|
28
|
-
|
|
28
|
+
color,
|
|
29
|
+
size = "medium",
|
|
29
30
|
}: {
|
|
30
|
-
collectionOrView?: IconViewProps,
|
|
31
|
+
collectionOrView?: IconViewProps,
|
|
32
|
+
color?: IconColor,
|
|
33
|
+
className?: string,
|
|
34
|
+
size?: "smallest" | "small" | "medium" | "large" | number,
|
|
31
35
|
}): React.ReactElement {
|
|
32
36
|
if (!collectionOrView) return <></>;
|
|
33
|
-
const icon = getIcon(collectionOrView.icon, className);
|
|
37
|
+
const icon = getIcon(collectionOrView.icon, className, color);
|
|
34
38
|
if (collectionOrView?.icon && icon)
|
|
35
39
|
return icon;
|
|
36
40
|
|
|
@@ -51,9 +55,9 @@ export const IconForView = React.memo(
|
|
|
51
55
|
if (!key)
|
|
52
56
|
key = coolIconKeys[hashString(collectionOrView.path) % iconsCount];
|
|
53
57
|
|
|
54
|
-
return <Icon iconKey={key} size={size} className={className}/>;
|
|
58
|
+
return <Icon iconKey={key} size={size} className={className} color={color}/>;
|
|
55
59
|
}, (prevProps, nextProps) => {
|
|
56
|
-
return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon);
|
|
60
|
+
return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon) && equal(prevProps.color, nextProps.color);
|
|
57
61
|
});
|
|
58
62
|
|
|
59
63
|
const iconKeysMap: Record<string, string> = iconKeys.reduce((acc: Record<string, string>, key) => {
|
package/src/util/objects.ts
CHANGED
|
@@ -125,6 +125,26 @@ export function removeUndefined(value: any, removeEmptyStrings?: boolean): any {
|
|
|
125
125
|
return value;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
export function removeNulls(value: any): any {
|
|
129
|
+
if (typeof value === "function") {
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
if (Array.isArray(value)) {
|
|
133
|
+
return value.map((v: any) => removeNulls(v));
|
|
134
|
+
}
|
|
135
|
+
if (typeof value === "object") {
|
|
136
|
+
const res: object = {};
|
|
137
|
+
if (value === null)
|
|
138
|
+
return value;
|
|
139
|
+
Object.keys(value).forEach((key) => {
|
|
140
|
+
if (value[key] !== null)
|
|
141
|
+
(res as any)[key] = removeNulls(value[key]);
|
|
142
|
+
});
|
|
143
|
+
return res;
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
|
|
128
148
|
export function isEmptyObject(obj: object) {
|
|
129
149
|
return obj &&
|
|
130
150
|
Object.getPrototypeOf(obj) === Object.prototype &&
|
package/src/util/permissions.ts
CHANGED
|
@@ -8,9 +8,9 @@ const DEFAULT_PERMISSIONS = {
|
|
|
8
8
|
delete: true
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export function resolvePermissions<M extends Record<string, any>,
|
|
11
|
+
export function resolvePermissions<M extends Record<string, any>, USER extends User>
|
|
12
12
|
(collection: EntityCollection<M>,
|
|
13
|
-
authController: AuthController<
|
|
13
|
+
authController: AuthController<USER>,
|
|
14
14
|
path: string,
|
|
15
15
|
entity: Entity<M> | null): Permissions | undefined {
|
|
16
16
|
|
|
@@ -34,29 +34,29 @@ export function resolvePermissions<M extends Record<string, any>, UserType exten
|
|
|
34
34
|
throw Error("New type of permission added and not mapped");
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function canEditEntity<M extends Record<string, any>,
|
|
37
|
+
export function canEditEntity<M extends Record<string, any>, USER extends User>
|
|
38
38
|
(
|
|
39
39
|
collection: EntityCollection<M>,
|
|
40
|
-
authController: AuthController<
|
|
40
|
+
authController: AuthController<USER>,
|
|
41
41
|
path: string,
|
|
42
42
|
entity: Entity<M> | null): boolean {
|
|
43
43
|
return resolvePermissions(collection, authController, path, entity)?.edit ?? DEFAULT_PERMISSIONS.edit;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function canCreateEntity<M extends Record<string, any>,
|
|
46
|
+
export function canCreateEntity<M extends Record<string, any>, USER extends User>
|
|
47
47
|
(
|
|
48
48
|
collection: EntityCollection<M>,
|
|
49
|
-
authController: AuthController<
|
|
49
|
+
authController: AuthController<USER>,
|
|
50
50
|
path: string,
|
|
51
51
|
entity: Entity<M> | null): boolean {
|
|
52
52
|
if (collection.collectionGroup) return false;
|
|
53
53
|
return resolvePermissions(collection, authController, path, entity)?.create ?? DEFAULT_PERMISSIONS.create;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export function canDeleteEntity<M extends Record<string, any>,
|
|
56
|
+
export function canDeleteEntity<M extends Record<string, any>, USER extends User>
|
|
57
57
|
(
|
|
58
58
|
collection: EntityCollection<M>,
|
|
59
|
-
authController: AuthController<
|
|
59
|
+
authController: AuthController<USER>,
|
|
60
60
|
path: string,
|
|
61
61
|
entity: Entity<M> | null): boolean {
|
|
62
62
|
return resolvePermissions(collection, authController, path, entity)?.delete ?? DEFAULT_PERMISSIONS.delete;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
EntityCollection,
|
|
5
|
+
PropertiesOrBuilders,
|
|
6
|
+
PropertyConfig,
|
|
7
|
+
PropertyOrBuilder,
|
|
8
|
+
ResolvedProperties,
|
|
9
|
+
ResolvedProperty
|
|
10
|
+
} from "../types";
|
|
4
11
|
import { isPropertyBuilder } from "./entities";
|
|
5
12
|
import { resolveProperty } from "./resolutions";
|
|
6
13
|
import { CircleIcon, FunctionsIcon } from "@firecms/ui";
|
|
@@ -11,7 +18,7 @@ export function isReferenceProperty(propertyOrBuilder: PropertyOrBuilder,
|
|
|
11
18
|
const resolvedProperty = resolveProperty({
|
|
12
19
|
propertyKey: "ignore", // TODO
|
|
13
20
|
propertyOrBuilder,
|
|
14
|
-
fields
|
|
21
|
+
propertyConfigs: fields
|
|
15
22
|
});
|
|
16
23
|
if (!resolvedProperty) return null;
|
|
17
24
|
if (resolvedProperty.dataType === "reference") {
|
|
@@ -63,7 +70,7 @@ export function getColorForProperty(property: PropertyOrBuilder, fields: Record<
|
|
|
63
70
|
* @param properties
|
|
64
71
|
* @param path
|
|
65
72
|
*/
|
|
66
|
-
export function getPropertyInPath<M extends Record<string, any>>(properties: PropertiesOrBuilders<M
|
|
73
|
+
export function getPropertyInPath<M extends Record<string, any>>(properties: PropertiesOrBuilders<M> | ResolvedProperties, path: string): PropertyOrBuilder<any, M> | undefined {
|
|
67
74
|
if (typeof properties === "object") {
|
|
68
75
|
if (path in properties) {
|
|
69
76
|
return properties[path];
|
package/src/util/references.ts
CHANGED
|
@@ -42,13 +42,19 @@ export function getEntityTitlePropertyKey<M extends Record<string, any>>(collect
|
|
|
42
42
|
|
|
43
43
|
export function getEntityImagePreviewPropertyKey<M extends object>(collection: ResolvedEntityCollection<M>): string | undefined {
|
|
44
44
|
|
|
45
|
-
// find first
|
|
45
|
+
// find first storage property of type image
|
|
46
46
|
for (const key in collection.properties) {
|
|
47
47
|
const property = collection.properties[key];
|
|
48
48
|
if (property.dataType === "string" && property.storage?.acceptedFiles?.includes("image/*")) {
|
|
49
49
|
return key;
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
}
|
|
52
|
+
// alternatively, look for the first array of images
|
|
53
|
+
for (const key in collection.properties) {
|
|
54
|
+
const property = collection.properties[key];
|
|
55
|
+
if (property.dataType === "array" && property.of?.dataType === "string" && property.of.storage?.acceptedFiles?.includes("image/*")) {
|
|
56
|
+
return key;
|
|
57
|
+
}
|
|
52
58
|
}
|
|
53
59
|
return undefined;
|
|
54
60
|
}
|
package/src/util/resolutions.ts
CHANGED
|
@@ -38,7 +38,7 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
38
38
|
values,
|
|
39
39
|
previousValues,
|
|
40
40
|
userConfigPersistence,
|
|
41
|
-
|
|
41
|
+
propertyConfigs,
|
|
42
42
|
ignoreMissingFields = false
|
|
43
43
|
}: {
|
|
44
44
|
collection: EntityCollection<M> | ResolvedEntityCollection<M>;
|
|
@@ -47,7 +47,7 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
47
47
|
values?: Partial<EntityValues<M>>,
|
|
48
48
|
previousValues?: Partial<EntityValues<M>>,
|
|
49
49
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
50
|
-
|
|
50
|
+
propertyConfigs?: Record<string, PropertyConfig>;
|
|
51
51
|
ignoreMissingFields?: boolean;
|
|
52
52
|
}): ResolvedEntityCollection<M> => {
|
|
53
53
|
|
|
@@ -67,7 +67,7 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
67
67
|
previousValues: usedPreviousValues,
|
|
68
68
|
path,
|
|
69
69
|
entityId,
|
|
70
|
-
|
|
70
|
+
propertyConfigs: propertyConfigs,
|
|
71
71
|
ignoreMissingFields
|
|
72
72
|
});
|
|
73
73
|
if (!childResolvedProperty) return {};
|
|
@@ -111,7 +111,7 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
111
111
|
entityId?: string,
|
|
112
112
|
index?: number,
|
|
113
113
|
fromBuilder?: boolean;
|
|
114
|
-
|
|
114
|
+
propertyConfigs?: Record<string, PropertyConfig<any>>;
|
|
115
115
|
ignoreMissingFields?: boolean;
|
|
116
116
|
}): ResolvedProperty<T> | null {
|
|
117
117
|
|
|
@@ -182,7 +182,7 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
if (resolvedProperty.propertyConfig && !isDefaultFieldConfigId(resolvedProperty.propertyConfig)) {
|
|
185
|
-
const cmsFields = props.
|
|
185
|
+
const cmsFields = props.propertyConfigs;
|
|
186
186
|
if (!cmsFields && !ignoreMissingFields) {
|
|
187
187
|
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`);
|
|
188
188
|
}
|
|
@@ -233,7 +233,7 @@ export function getArrayResolvedProperties<M>({
|
|
|
233
233
|
entityId?: string;
|
|
234
234
|
index?: number;
|
|
235
235
|
fromBuilder?: boolean;
|
|
236
|
-
|
|
236
|
+
propertyConfigs?: Record<string, PropertyConfig>
|
|
237
237
|
}) {
|
|
238
238
|
|
|
239
239
|
const of = property.of;
|
|
@@ -263,7 +263,7 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
263
263
|
entityId?: string,
|
|
264
264
|
index?: number,
|
|
265
265
|
fromBuilder?: boolean;
|
|
266
|
-
|
|
266
|
+
propertyConfigs?: Record<string, PropertyConfig>;
|
|
267
267
|
ignoreMissingFields?: boolean;
|
|
268
268
|
}): ResolvedArrayProperty {
|
|
269
269
|
const propertyValue = propertyKey ? getIn(props.values, propertyKey) : undefined;
|
|
@@ -370,7 +370,7 @@ export function resolveProperties<M extends Record<string, any>>({
|
|
|
370
370
|
entityId?: string,
|
|
371
371
|
index?: number,
|
|
372
372
|
fromBuilder?: boolean;
|
|
373
|
-
|
|
373
|
+
propertyConfigs?: Record<string, PropertyConfig>;
|
|
374
374
|
ignoreMissingFields?: boolean;
|
|
375
375
|
}): ResolvedProperties<M> {
|
|
376
376
|
return Object.entries<PropertyOrBuilder>(properties as Record<string, PropertyOrBuilder>)
|
|
@@ -70,7 +70,7 @@ export function useStorageUploadController<M extends object>({
|
|
|
70
70
|
throw Error("Storage meta must be specified");
|
|
71
71
|
|
|
72
72
|
const metadata: Record<string, any> | undefined = storage?.metadata;
|
|
73
|
-
const size = multipleFilesSupported ? "
|
|
73
|
+
const size = multipleFilesSupported ? "medium" : "large";
|
|
74
74
|
|
|
75
75
|
const compression: ImageCompression | undefined = storage?.imageCompression;
|
|
76
76
|
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface ArrayContainerProps<T> {
|
|
3
|
-
value: T[];
|
|
4
|
-
name: string;
|
|
5
|
-
addLabel: string;
|
|
6
|
-
buildEntry: (index: number, internalId: number) => React.ReactNode;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
small?: boolean;
|
|
9
|
-
onInternalIdAdded?: (id: number) => void;
|
|
10
|
-
includeAddButton?: boolean;
|
|
11
|
-
newDefaultEntry?: T | null;
|
|
12
|
-
setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => void;
|
|
13
|
-
className?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @group Form custom fields
|
|
17
|
-
*/
|
|
18
|
-
export declare function FormikArrayContainer<T>({ name, addLabel, value, disabled, buildEntry, small, onInternalIdAdded, includeAddButton, newDefaultEntry, setFieldValue, className }: ArrayContainerProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ArrayContainer } from "../../components";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
interface ArrayContainerProps<T> {
|
|
5
|
-
value: T[];
|
|
6
|
-
name: string;
|
|
7
|
-
addLabel: string;
|
|
8
|
-
buildEntry: (index: number, internalId: number) => React.ReactNode;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
small?: boolean;
|
|
11
|
-
onInternalIdAdded?: (id: number) => void;
|
|
12
|
-
includeAddButton?: boolean;
|
|
13
|
-
newDefaultEntry?: T | null;
|
|
14
|
-
setFieldValue: (field: string, value: any, shouldValidate?: boolean | undefined) => void;
|
|
15
|
-
className?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @group Form custom fields
|
|
20
|
-
*/
|
|
21
|
-
export function FormikArrayContainer<T>({
|
|
22
|
-
name,
|
|
23
|
-
addLabel,
|
|
24
|
-
value,
|
|
25
|
-
disabled = false,
|
|
26
|
-
buildEntry,
|
|
27
|
-
small,
|
|
28
|
-
onInternalIdAdded,
|
|
29
|
-
includeAddButton,
|
|
30
|
-
newDefaultEntry = null,
|
|
31
|
-
setFieldValue,
|
|
32
|
-
className
|
|
33
|
-
}: ArrayContainerProps<T>) {
|
|
34
|
-
|
|
35
|
-
return <ArrayContainer droppableId={name}
|
|
36
|
-
addLabel={addLabel}
|
|
37
|
-
value={value}
|
|
38
|
-
disabled={disabled}
|
|
39
|
-
buildEntry={buildEntry}
|
|
40
|
-
size={small ? "small" : "medium"}
|
|
41
|
-
onInternalIdAdded={onInternalIdAdded}
|
|
42
|
-
includeAddButton={includeAddButton}
|
|
43
|
-
newDefaultEntry={newDefaultEntry}
|
|
44
|
-
className={className}
|
|
45
|
-
onValueChange={(value) => setFieldValue(name, value)}
|
|
46
|
-
/>;
|
|
47
|
-
}
|