@firecms/collection_editor 3.0.0-beta.4.pre.2 → 3.0.0-beta.5
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 +61 -51
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +1 -1
- package/package.json +12 -12
- package/src/ui/NewCollectionButton.tsx +12 -10
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +5 -5
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +6 -5
- package/src/ui/collection_editor/GetCodeDialog.tsx +15 -3
- package/src/useCollectionEditorPlugin.tsx +1 -1
|
@@ -30,7 +30,7 @@ export interface CollectionEditorDialogProps {
|
|
|
30
30
|
parentCollection?: PersistedCollection;
|
|
31
31
|
}
|
|
32
32
|
export declare function CollectionEditorDialog(props: CollectionEditorDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export declare function CollectionEditor
|
|
33
|
+
export declare function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
34
34
|
handleCancel: () => void;
|
|
35
35
|
setFormDirty: (dirty: boolean) => void;
|
|
36
36
|
}): import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.5",
|
|
5
5
|
"main": "./dist/index.umd.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@firecms/data_import_export": "^3.0.0-beta.
|
|
11
|
-
"@firecms/formex": "^3.0.0-beta.
|
|
12
|
-
"@firecms/schema_inference": "^3.0.0-beta.
|
|
13
|
-
"@firecms/ui": "^3.0.0-beta.
|
|
10
|
+
"@firecms/data_import_export": "^3.0.0-beta.5",
|
|
11
|
+
"@firecms/formex": "^3.0.0-beta.5",
|
|
12
|
+
"@firecms/schema_inference": "^3.0.0-beta.5",
|
|
13
|
+
"@firecms/ui": "^3.0.0-beta.5",
|
|
14
14
|
"json5": "^2.2.3",
|
|
15
15
|
"prism-react-renderer": "^2.3.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "^18.2.0",
|
|
19
19
|
"react-dom": "^18.2.0",
|
|
20
|
-
"react-router": "^6.22.
|
|
21
|
-
"react-router-dom": "^6.22.
|
|
20
|
+
"react-router": "^6.22.0",
|
|
21
|
+
"react-router-dom": "^6.22.0"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"import": "./dist/index.es.js",
|
|
26
26
|
"require": "./dist/index.umd.js",
|
|
27
|
-
"types": "./dist/
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
28
|
},
|
|
29
29
|
"./package.json": "./package.json"
|
|
30
30
|
},
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"eslint-plugin-react": "^7.34.1",
|
|
68
68
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
69
69
|
"jest": "^29.7.0",
|
|
70
|
-
"react-router": "^6.22.
|
|
71
|
-
"react-router-dom": "^6.22.
|
|
70
|
+
"react-router": "^6.22.0",
|
|
71
|
+
"react-router-dom": "^6.22.0",
|
|
72
72
|
"ts-jest": "^29.1.2",
|
|
73
73
|
"typescript": "^5.4.2",
|
|
74
|
-
"vite": "^5.
|
|
74
|
+
"vite": "^5.2.3",
|
|
75
75
|
"vite-plugin-fonts": "^0.7.0"
|
|
76
76
|
},
|
|
77
77
|
"files": [
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "8bf864185c9617aa3f120e59c873c8b8bda8dac4"
|
|
85
85
|
}
|
|
@@ -3,14 +3,16 @@ import { useCollectionEditorController } from "../useCollectionEditorController"
|
|
|
3
3
|
|
|
4
4
|
export function NewCollectionButton() {
|
|
5
5
|
const collectionEditorController = useCollectionEditorController();
|
|
6
|
-
return <
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
return <div className={"bg-gray-50 dark:bg-gray-900 min-w-fit rounded"}>
|
|
7
|
+
<Button className={"min-w-fit"}
|
|
8
|
+
variant={"outlined"}
|
|
9
|
+
onClick={() => collectionEditorController.createCollection({
|
|
10
|
+
parentCollectionIds: [],
|
|
11
|
+
redirect: true,
|
|
12
|
+
sourceClick: "new_collection_button"
|
|
13
|
+
})}>
|
|
14
|
+
<AddIcon/>
|
|
15
|
+
New collection
|
|
16
|
+
</Button>
|
|
17
|
+
</div>
|
|
16
18
|
}
|
|
@@ -136,7 +136,7 @@ type EditorView = "welcome"
|
|
|
136
136
|
| "extra_view"
|
|
137
137
|
| "subcollections";
|
|
138
138
|
|
|
139
|
-
export function CollectionEditor
|
|
139
|
+
export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
140
140
|
handleCancel: () => void,
|
|
141
141
|
setFormDirty: (dirty: boolean) => void
|
|
142
142
|
}) {
|
|
@@ -154,14 +154,14 @@ export function CollectionEditor<M extends Record<string, any>>(props: Collectio
|
|
|
154
154
|
const collectionsInThisLevel = (props.parentCollection ? props.parentCollection.subcollections : collections) ?? [];
|
|
155
155
|
const existingPaths = collectionsInThisLevel.map(col => col.path.trim().toLowerCase());
|
|
156
156
|
const existingIds = collectionsInThisLevel.map(col => col.id?.trim().toLowerCase()).filter(Boolean) as string[];
|
|
157
|
-
const [collection, setCollection] = React.useState<PersistedCollection<
|
|
157
|
+
const [collection, setCollection] = React.useState<PersistedCollection<any> | undefined>();
|
|
158
158
|
const [initialLoadingCompleted, setInitialLoadingCompleted] = React.useState(false);
|
|
159
159
|
|
|
160
160
|
useEffect(() => {
|
|
161
161
|
try {
|
|
162
162
|
if (navigation.initialised) {
|
|
163
163
|
if (props.editedCollectionId) {
|
|
164
|
-
setCollection(navigation.getCollectionFromPaths
|
|
164
|
+
setCollection(navigation.getCollectionFromPaths([...(props.parentCollectionIds ?? []), props.editedCollectionId]));
|
|
165
165
|
} else {
|
|
166
166
|
setCollection(undefined);
|
|
167
167
|
}
|
|
@@ -186,14 +186,14 @@ export function CollectionEditor<M extends Record<string, any>>(props: Collectio
|
|
|
186
186
|
}
|
|
187
187
|
: undefined;
|
|
188
188
|
|
|
189
|
-
const initialValues: PersistedCollection<
|
|
189
|
+
const initialValues: PersistedCollection<any> = initialCollection
|
|
190
190
|
? applyPropertyConfigs(initialCollection, propertyConfigs)
|
|
191
191
|
: {
|
|
192
192
|
id: initialValuesProp?.path ?? randomString(16),
|
|
193
193
|
path: initialValuesProp?.path ?? "",
|
|
194
194
|
name: initialValuesProp?.name ?? "",
|
|
195
195
|
group: initialValuesProp?.group ?? "",
|
|
196
|
-
properties: {} as PropertiesOrBuilders
|
|
196
|
+
properties: {} as PropertiesOrBuilders,
|
|
197
197
|
propertiesOrder: [],
|
|
198
198
|
icon: coolIconKeys[Math.floor(Math.random() * coolIconKeys.length)],
|
|
199
199
|
ownerId: authController.user?.uid ?? ""
|
|
@@ -496,11 +496,12 @@ export function CollectionPropertiesEditorForm({
|
|
|
496
496
|
collectionEditable={collectionEditable}
|
|
497
497
|
existingPropertyKeys={values.propertiesOrder as string[]}/>
|
|
498
498
|
|
|
499
|
-
<
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
499
|
+
<ErrorBoundary>
|
|
500
|
+
<GetCodeDialog
|
|
501
|
+
collection={values}
|
|
502
|
+
open={codeDialogOpen}
|
|
503
|
+
onOpenChange={setCodeDialogOpen}/>
|
|
504
|
+
</ErrorBoundary>
|
|
504
505
|
</>
|
|
505
506
|
);
|
|
506
507
|
}
|
|
@@ -5,11 +5,17 @@ import JSON5 from "json5";
|
|
|
5
5
|
import { Highlight, themes } from "prism-react-renderer"
|
|
6
6
|
import { camelCase } from "./utils/strings";
|
|
7
7
|
|
|
8
|
-
export function GetCodeDialog({
|
|
8
|
+
export function GetCodeDialog({
|
|
9
|
+
collection,
|
|
10
|
+
onOpenChange,
|
|
11
|
+
open
|
|
12
|
+
}: { onOpenChange: (open: boolean) => void, collection: any, open: any }) {
|
|
9
13
|
|
|
10
14
|
const snackbarController = useSnackbarController();
|
|
11
15
|
|
|
12
|
-
const code =
|
|
16
|
+
const code = collection
|
|
17
|
+
? "import { EntityCollection } from \"firecms\";\n\nconst " + (collection?.name ? camelCase(collection.name) : "my") + "Collection:EntityCollection = " + JSON5.stringify(collectionToCode(collection), null, "\t")
|
|
18
|
+
: "No collection selected";
|
|
13
19
|
return <Dialog open={open}
|
|
14
20
|
onOpenChange={onOpenChange}
|
|
15
21
|
maxWidth={"4xl"}>
|
|
@@ -29,7 +35,13 @@ export function GetCodeDialog({ collection, onOpenChange, open }: { onOpenChange
|
|
|
29
35
|
code={code}
|
|
30
36
|
language="typescript"
|
|
31
37
|
>
|
|
32
|
-
{({
|
|
38
|
+
{({
|
|
39
|
+
className,
|
|
40
|
+
style,
|
|
41
|
+
tokens,
|
|
42
|
+
getLineProps,
|
|
43
|
+
getTokenProps
|
|
44
|
+
}) => (
|
|
33
45
|
<pre style={style} className={"p-4 rounded text-sm"}>
|
|
34
46
|
{tokens.map((line, i) => (
|
|
35
47
|
<div key={i} {...getLineProps({ line })}>
|
|
@@ -81,7 +81,7 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
81
81
|
}: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection> {
|
|
82
82
|
|
|
83
83
|
return {
|
|
84
|
-
|
|
84
|
+
key: "collection_editor",
|
|
85
85
|
loading: collectionConfigController.loading,
|
|
86
86
|
provider: {
|
|
87
87
|
Component: ConfigControllerProvider,
|