@firecms/collection_editor 3.0.0-alpha.35 → 3.0.0-alpha.37
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/index.es.js +1115 -1096
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +2 -2
- package/dist/types/persisted_collection.d.ts +2 -3
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +2 -1
- package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +2 -2
- package/dist/ui/collection_editor/PropertyEditView.d.ts +1 -1
- package/dist/ui/collection_editor/PropertyTree.d.ts +2 -2
- package/dist/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +2 -2
- package/dist/ui/collection_editor/properties/BlockPropertyField.d.ts +2 -2
- package/dist/ui/collection_editor/properties/MapPropertyField.d.ts +2 -2
- package/dist/ui/collection_editor/properties/RepeatPropertyField.d.ts +2 -2
- package/dist/ui/collection_editor/utils/update_property_for_widget.d.ts +1 -1
- package/package.json +4 -4
- package/src/ConfigControllerProvider.tsx +6 -6
- package/src/types/collection_editor_controller.tsx +1 -1
- package/src/types/persisted_collection.ts +2 -2
- package/src/ui/EditorCollectionAction.tsx +1 -1
- package/src/ui/RootCollectionSuggestions.tsx +1 -1
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +52 -14
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +6 -6
- package/src/ui/collection_editor/PropertyEditView.tsx +12 -12
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +4 -4
- package/src/ui/collection_editor/PropertyTree.tsx +3 -2
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +9 -11
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +3 -3
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +3 -3
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +4 -6
- package/src/ui/collection_editor/utils/update_property_for_widget.ts +6 -3
- package/src/useCollectionEditorPlugin.tsx +10 -4
|
@@ -16,8 +16,7 @@ import {
|
|
|
16
16
|
PropertyConfig,
|
|
17
17
|
Select,
|
|
18
18
|
Tooltip,
|
|
19
|
-
Typography
|
|
20
|
-
useFireCMSContext
|
|
19
|
+
Typography
|
|
21
20
|
} from "@firecms/core";
|
|
22
21
|
import React, { useState } from "react";
|
|
23
22
|
import { OnPropertyChangedParams, PropertyFormDialog, PropertyWithId } from "../PropertyEditView";
|
|
@@ -30,12 +29,12 @@ import { buildPropertyFromData } from "@firecms/schema_inference";
|
|
|
30
29
|
|
|
31
30
|
export function CollectionEditorImportMapping({
|
|
32
31
|
importConfig,
|
|
33
|
-
|
|
32
|
+
propertyConfigs,
|
|
34
33
|
collectionEditable
|
|
35
34
|
}:
|
|
36
35
|
{
|
|
37
36
|
importConfig: ImportConfig,
|
|
38
|
-
|
|
37
|
+
propertyConfigs: Record<string, PropertyConfig>,
|
|
39
38
|
collectionEditable: boolean
|
|
40
39
|
}) {
|
|
41
40
|
|
|
@@ -181,7 +180,7 @@ export function CollectionEditorImportMapping({
|
|
|
181
180
|
importKey
|
|
182
181
|
})}
|
|
183
182
|
propertyKey={propertyKey}
|
|
184
|
-
|
|
183
|
+
propertyConfigs={propertyConfigs}/>}
|
|
185
184
|
/>;
|
|
186
185
|
}}/>
|
|
187
186
|
</Container>
|
|
@@ -203,7 +202,7 @@ export function CollectionEditorImportMapping({
|
|
|
203
202
|
}}
|
|
204
203
|
autoOpenTypeSelect={false}
|
|
205
204
|
existingProperty={false}
|
|
206
|
-
|
|
205
|
+
propertyConfigs={propertyConfigs}/>
|
|
207
206
|
|
|
208
207
|
<div style={{ height: "52px" }}/>
|
|
209
208
|
</div>
|
|
@@ -215,7 +214,7 @@ function PropertySelect({
|
|
|
215
214
|
property,
|
|
216
215
|
onPropertyChanged,
|
|
217
216
|
propertyKey,
|
|
218
|
-
|
|
217
|
+
propertyConfigs,
|
|
219
218
|
disabled
|
|
220
219
|
}: {
|
|
221
220
|
property: Property | null,
|
|
@@ -226,13 +225,12 @@ function PropertySelect({
|
|
|
226
225
|
previousId,
|
|
227
226
|
namespace
|
|
228
227
|
}: OnPropertyChangedParams) => void,
|
|
229
|
-
|
|
228
|
+
propertyConfigs: Record<string, PropertyConfig>,
|
|
230
229
|
disabled?: boolean
|
|
231
230
|
}) {
|
|
232
231
|
|
|
233
|
-
const { fields } = useFireCMSContext();
|
|
234
232
|
const fieldId = property ? getFieldId(property) : null;
|
|
235
|
-
const widget = property ? getFieldConfig(property,
|
|
233
|
+
const widget = property ? getFieldConfig(property, propertyConfigs) : null;
|
|
236
234
|
|
|
237
235
|
const [selectOpen, setSelectOpen] = useState(false);
|
|
238
236
|
|
|
@@ -253,7 +251,7 @@ function PropertySelect({
|
|
|
253
251
|
return <FieldConfigBadge propertyConfig={widget}/>
|
|
254
252
|
}}
|
|
255
253
|
onValueChange={(newSelectedWidgetId) => {
|
|
256
|
-
const newProperty = updatePropertyFromWidget(property, newSelectedWidgetId,
|
|
254
|
+
const newProperty = updatePropertyFromWidget(property, newSelectedWidgetId, propertyConfigs)
|
|
257
255
|
if (!propertyKey) return;
|
|
258
256
|
onPropertyChanged({
|
|
259
257
|
id: propertyKey,
|
|
@@ -5,11 +5,11 @@ import { PropertyFormDialog } from "../PropertyEditView";
|
|
|
5
5
|
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util";
|
|
6
6
|
import { PropertyTree } from "../PropertyTree";
|
|
7
7
|
|
|
8
|
-
export function BlockPropertyField({ disabled, getData, allowDataInference,
|
|
8
|
+
export function BlockPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
|
|
9
9
|
disabled: boolean;
|
|
10
10
|
getData?: () => Promise<object[]>;
|
|
11
11
|
allowDataInference: boolean;
|
|
12
|
-
|
|
12
|
+
propertyConfigs: Record<string, PropertyConfig>,
|
|
13
13
|
collectionEditable: boolean;
|
|
14
14
|
}) {
|
|
15
15
|
|
|
@@ -128,7 +128,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, cust
|
|
|
128
128
|
autoOpenTypeSelect={!selectedPropertyKey}
|
|
129
129
|
onPropertyChanged={onPropertyCreated}
|
|
130
130
|
existingPropertyKeys={selectedPropertyKey ? undefined : values.oneOf?.propertiesOrder}
|
|
131
|
-
|
|
131
|
+
propertyConfigs={propertyConfigs}/>}
|
|
132
132
|
|
|
133
133
|
</>);
|
|
134
134
|
}
|
|
@@ -15,11 +15,11 @@ import { PropertyTree } from "../PropertyTree";
|
|
|
15
15
|
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
|
|
16
16
|
import { FieldHelperView } from "./FieldHelperView";
|
|
17
17
|
|
|
18
|
-
export function MapPropertyField({ disabled, getData, allowDataInference,
|
|
18
|
+
export function MapPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
|
|
19
19
|
disabled: boolean;
|
|
20
20
|
getData?: () => Promise<object[]>;
|
|
21
21
|
allowDataInference: boolean;
|
|
22
|
-
|
|
22
|
+
propertyConfigs: Record<string, PropertyConfig>,
|
|
23
23
|
collectionEditable: boolean;
|
|
24
24
|
}) {
|
|
25
25
|
|
|
@@ -150,7 +150,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, custom
|
|
|
150
150
|
autoOpenTypeSelect={!selectedPropertyKey}
|
|
151
151
|
onPropertyChanged={onPropertyCreated}
|
|
152
152
|
existingPropertyKeys={selectedPropertyKey ? undefined : propertiesOrder}
|
|
153
|
-
|
|
153
|
+
propertyConfigs={propertyConfigs}
|
|
154
154
|
/>
|
|
155
155
|
|
|
156
156
|
</>);
|
|
@@ -21,7 +21,7 @@ export function RepeatPropertyField({
|
|
|
21
21
|
disabled,
|
|
22
22
|
getData,
|
|
23
23
|
allowDataInference,
|
|
24
|
-
|
|
24
|
+
propertyConfigs,
|
|
25
25
|
collectionEditable
|
|
26
26
|
}: {
|
|
27
27
|
showErrors: boolean,
|
|
@@ -29,12 +29,10 @@ export function RepeatPropertyField({
|
|
|
29
29
|
disabled: boolean,
|
|
30
30
|
getData?: () => Promise<object[]>;
|
|
31
31
|
allowDataInference: boolean;
|
|
32
|
-
|
|
32
|
+
propertyConfigs: Record<string, PropertyConfig>,
|
|
33
33
|
collectionEditable: boolean;
|
|
34
34
|
}) {
|
|
35
35
|
|
|
36
|
-
const { fields } = useFireCMSContext();
|
|
37
|
-
|
|
38
36
|
const {
|
|
39
37
|
values,
|
|
40
38
|
handleChange,
|
|
@@ -52,7 +50,7 @@ export function RepeatPropertyField({
|
|
|
52
50
|
setFieldValue("of", property);
|
|
53
51
|
}, []);
|
|
54
52
|
|
|
55
|
-
const widget = ofProperty && getFieldConfig(ofProperty,
|
|
53
|
+
const widget = ofProperty && getFieldConfig(ofProperty, propertyConfigs);
|
|
56
54
|
return (
|
|
57
55
|
<>
|
|
58
56
|
<div className={"col-span-12"}>
|
|
@@ -97,7 +95,7 @@ export function RepeatPropertyField({
|
|
|
97
95
|
includeIdAndName={false}
|
|
98
96
|
onPropertyChanged={onPropertyChanged}
|
|
99
97
|
forceShowErrors={showErrors}
|
|
100
|
-
|
|
98
|
+
propertyConfigs={propertyConfigs}
|
|
101
99
|
collectionEditable={collectionEditable}
|
|
102
100
|
/>
|
|
103
101
|
</Paper>
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
export function updatePropertyFromWidget(propertyData: any,
|
|
14
14
|
selectedWidgetId: string | undefined,
|
|
15
|
-
|
|
15
|
+
propertyConfigs: Record<string, PropertyConfig>): Property {
|
|
16
16
|
|
|
17
17
|
let updatedProperty;
|
|
18
18
|
if (selectedWidgetId === "text_field") {
|
|
@@ -260,8 +260,11 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
260
260
|
}
|
|
261
261
|
} satisfies ArrayProperty
|
|
262
262
|
);
|
|
263
|
-
} else if (selectedWidgetId &&
|
|
264
|
-
updatedProperty = {
|
|
263
|
+
} else if (selectedWidgetId && propertyConfigs[selectedWidgetId]) {
|
|
264
|
+
updatedProperty = {
|
|
265
|
+
...propertyConfigs[selectedWidgetId].property,
|
|
266
|
+
propertyConfig: selectedWidgetId
|
|
267
|
+
};
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
return updatedProperty;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
EntityCollection,
|
|
4
|
+
FireCMSPlugin,
|
|
5
|
+
joinCollectionLists,
|
|
6
|
+
makePropertiesEditable,
|
|
7
|
+
Properties,
|
|
8
|
+
User
|
|
9
|
+
} from "@firecms/core";
|
|
3
10
|
import { ConfigControllerProvider } from "./ConfigControllerProvider";
|
|
4
11
|
import { CollectionEditorPermissionsBuilder } from "./types/config_permissions";
|
|
5
12
|
import { EditorCollectionAction } from "./ui/EditorCollectionAction";
|
|
@@ -74,12 +81,11 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
74
81
|
const injectCollections = useCallback(
|
|
75
82
|
(collections: EntityCollection[]) => {
|
|
76
83
|
const markAsEditable = (c: PersistedCollection) => {
|
|
77
|
-
makePropertiesEditable(c.properties);
|
|
84
|
+
makePropertiesEditable(c.properties as Properties);
|
|
78
85
|
c.subcollections?.forEach(markAsEditable);
|
|
79
86
|
};
|
|
80
87
|
const editableCollections = collectionConfigController.collections ?? [];
|
|
81
88
|
editableCollections.forEach(markAsEditable);
|
|
82
|
-
console.debug("Injecting collections", { editableCollections, collections });
|
|
83
89
|
return joinCollectionLists(editableCollections, collections);
|
|
84
90
|
},
|
|
85
91
|
[collectionConfigController.collections]);
|
|
@@ -105,7 +111,7 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
105
111
|
}
|
|
106
112
|
},
|
|
107
113
|
homePage: {
|
|
108
|
-
|
|
114
|
+
additionalChildrenEnd: <RootCollectionSuggestions/>,
|
|
109
115
|
CollectionActions: HomePageEditorCollectionAction,
|
|
110
116
|
AdditionalCards: NewCollectionCard,
|
|
111
117
|
},
|