@firecms/collection_editor 3.0.0-alpha.9 → 3.0.0-beta.10
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/LICENSE +114 -21
- package/dist/ConfigControllerProvider.d.ts +13 -3
- package/dist/index.d.ts +4 -2
- package/dist/index.es.js +5587 -4976
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6829 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +36 -8
- package/dist/types/collection_inference.d.ts +1 -1
- package/dist/types/config_controller.d.ts +33 -6
- package/dist/types/persisted_collection.d.ts +4 -2
- package/dist/ui/CollectionViewHeaderAction.d.ts +11 -0
- package/dist/{components → ui}/EditorCollectionAction.d.ts +1 -1
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/dist/ui/MissingReferenceWidget.d.ts +3 -0
- package/dist/ui/NewCollectionButton.d.ts +1 -0
- package/dist/ui/PropertyAddColumnComponent.d.ts +8 -0
- package/dist/{components → ui}/collection_editor/CollectionDetailsForm.d.ts +3 -2
- package/dist/{components → ui}/collection_editor/CollectionEditorDialog.d.ts +15 -11
- package/dist/{components → ui}/collection_editor/CollectionEditorWelcomeView.d.ts +3 -3
- package/dist/{components → ui}/collection_editor/CollectionPropertiesEditorForm.d.ts +8 -6
- package/dist/{components → ui}/collection_editor/CollectionYupValidation.d.ts +3 -0
- package/dist/ui/collection_editor/EntityCustomViewsSelectDialog.d.ts +4 -0
- package/dist/{components → ui}/collection_editor/EnumForm.d.ts +1 -2
- package/dist/ui/collection_editor/GetCodeDialog.d.ts +5 -0
- package/dist/{components → ui}/collection_editor/PropertyEditView.d.ts +21 -11
- package/dist/{components → ui}/collection_editor/PropertyFieldPreview.d.ts +4 -3
- package/dist/{components → ui}/collection_editor/PropertyTree.d.ts +11 -7
- package/dist/{components → ui}/collection_editor/SubcollectionsEditTab.d.ts +3 -3
- package/dist/ui/collection_editor/SwitchControl.d.ts +8 -0
- package/dist/{components → ui}/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +14 -0
- package/dist/{components → ui}/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/{components → ui}/collection_editor/properties/BlockPropertyField.d.ts +4 -1
- package/dist/{components → ui}/collection_editor/properties/CommonPropertyFields.d.ts +1 -1
- package/dist/{components → ui}/collection_editor/properties/MapPropertyField.d.ts +4 -1
- package/dist/ui/collection_editor/properties/MarkdownPropertyField.d.ts +4 -0
- package/dist/{components → ui}/collection_editor/properties/RepeatPropertyField.d.ts +4 -1
- package/dist/{components → ui}/collection_editor/properties/StringPropertyField.d.ts +1 -1
- package/dist/ui/collection_editor/properties/UrlPropertyField.d.ts +4 -0
- package/dist/ui/collection_editor/templates/blog_template.d.ts +2 -0
- package/dist/ui/collection_editor/templates/pages_template.d.ts +2 -0
- package/dist/ui/collection_editor/templates/products_template.d.ts +2 -0
- package/dist/ui/collection_editor/templates/users_template.d.ts +2 -0
- package/dist/{components → ui}/collection_editor/util.d.ts +1 -0
- package/dist/ui/collection_editor/utils/strings.d.ts +1 -0
- package/dist/ui/collection_editor/utils/supported_fields.d.ts +3 -0
- package/dist/ui/collection_editor/utils/update_property_for_widget.d.ts +2 -0
- package/dist/useCollectionEditorPlugin.d.ts +17 -6
- package/dist/utils/collections.d.ts +6 -0
- package/dist/utils/entities.d.ts +3 -4
- package/package.json +35 -37
- package/src/ConfigControllerProvider.tsx +350 -0
- package/src/index.ts +36 -0
- package/src/types/collection_editor_controller.tsx +53 -0
- package/src/types/collection_inference.ts +3 -0
- package/src/types/config_controller.tsx +60 -0
- package/src/types/config_permissions.ts +20 -0
- package/src/types/persisted_collection.ts +9 -0
- package/src/ui/CollectionViewHeaderAction.tsx +48 -0
- package/src/ui/EditorCollectionAction.tsx +56 -0
- package/src/ui/EditorCollectionActionStart.tsx +88 -0
- package/src/ui/HomePageEditorCollectionAction.tsx +89 -0
- package/src/ui/MissingReferenceWidget.tsx +37 -0
- package/src/ui/NewCollectionButton.tsx +18 -0
- package/src/ui/NewCollectionCard.tsx +48 -0
- package/src/ui/PropertyAddColumnComponent.tsx +47 -0
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +426 -0
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +826 -0
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +214 -0
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +513 -0
- package/src/ui/collection_editor/CollectionYupValidation.tsx +7 -0
- package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +37 -0
- package/src/ui/collection_editor/EnumForm.tsx +357 -0
- package/src/ui/collection_editor/GetCodeDialog.tsx +122 -0
- package/src/ui/collection_editor/PropertyEditView.tsx +789 -0
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +204 -0
- package/src/ui/collection_editor/PropertyTree.tsx +254 -0
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +269 -0
- package/src/ui/collection_editor/SwitchControl.tsx +39 -0
- package/src/ui/collection_editor/UnsavedChangesDialog.tsx +47 -0
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +53 -0
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +299 -0
- package/src/ui/collection_editor/import/clean_import_data.ts +53 -0
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +144 -0
- package/src/ui/collection_editor/properties/BooleanPropertyField.tsx +40 -0
- package/src/ui/collection_editor/properties/CommonPropertyFields.tsx +110 -0
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +89 -0
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +114 -0
- package/src/ui/collection_editor/properties/KeyValuePropertyField.tsx +20 -0
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +150 -0
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +139 -0
- package/src/ui/collection_editor/properties/NumberPropertyField.tsx +38 -0
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +160 -0
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +108 -0
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +215 -0
- package/src/ui/collection_editor/properties/StringPropertyField.tsx +70 -0
- package/src/ui/collection_editor/properties/UrlPropertyField.tsx +89 -0
- package/src/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +45 -0
- package/src/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx +50 -0
- package/src/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx +61 -0
- package/src/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx +115 -0
- package/src/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +150 -0
- package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +28 -0
- package/src/ui/collection_editor/templates/blog_template.ts +115 -0
- package/src/ui/collection_editor/templates/pages_template.ts +183 -0
- package/src/ui/collection_editor/templates/products_template.ts +88 -0
- package/src/ui/collection_editor/templates/users_template.ts +42 -0
- package/src/ui/collection_editor/util.ts +28 -0
- package/src/ui/collection_editor/utils/strings.ts +9 -0
- package/src/ui/collection_editor/utils/supported_fields.tsx +29 -0
- package/src/ui/collection_editor/utils/update_property_for_widget.ts +271 -0
- package/src/ui/collection_editor/utils/useTraceUpdate.tsx +23 -0
- package/src/useCollectionEditorController.tsx +9 -0
- package/src/useCollectionEditorPlugin.tsx +164 -0
- package/src/useCollectionsConfigController.tsx +9 -0
- package/src/utils/arrays.ts +3 -0
- package/src/utils/collections.ts +30 -0
- package/src/utils/entities.ts +38 -0
- package/src/vite-env.d.ts +1 -0
- package/dist/components/collection_editor/PropertySelectItem.d.ts +0 -8
- package/dist/components/collection_editor/SelectIcons.d.ts +0 -6
- package/dist/components/collection_editor/import/CollectionEditorImportMapping.d.ts +0 -4
- package/dist/components/collection_editor/properties/FieldHelperView.d.ts +0 -4
- package/dist/components/collection_editor/templates/blog_template.d.ts +0 -10
- package/dist/components/collection_editor/templates/products_template.d.ts +0 -12
- package/dist/components/collection_editor/templates/users_template.d.ts +0 -7
- package/dist/components/collection_editor/utils/supported_fields.d.ts +0 -3
- package/dist/components/collection_editor/utils/update_property_for_widget.d.ts +0 -3
- package/dist/types/editable_properties.d.ts +0 -10
- package/dist/utils/icons.d.ts +0 -2
- package/dist/utils/synonyms.d.ts +0 -1951
- /package/dist/{components → ui}/HomePageEditorCollectionAction.d.ts +0 -0
- /package/dist/{components → ui}/NewCollectionCard.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/UnsavedChangesDialog.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/BooleanPropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/DateTimePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/EnumPropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/KeyValuePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/NumberPropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/ReferencePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/StoragePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/advanced/AdvancedPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/ArrayPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/GeneralPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/NumberPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/StringPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/ValidationPanel.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/utils/useTraceUpdate.d.ts +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { EntityCollection, unslugify, } from "@firecms/core";
|
|
3
|
+
import { Button, Card, Chip, CircularProgress, cls, Container, Icon, Tooltip, Typography, } from "@firecms/ui";
|
|
4
|
+
|
|
5
|
+
import { productsCollectionTemplate } from "./templates/products_template";
|
|
6
|
+
import { blogCollectionTemplate } from "./templates/blog_template";
|
|
7
|
+
import { usersCollectionTemplate } from "./templates/users_template";
|
|
8
|
+
import { ImportFileUpload } from "@firecms/data_import_export";
|
|
9
|
+
import { pagesCollectionTemplate } from "./templates/pages_template";
|
|
10
|
+
import { useFormex } from "@firecms/formex";
|
|
11
|
+
|
|
12
|
+
export function CollectionEditorWelcomeView({
|
|
13
|
+
path,
|
|
14
|
+
pathSuggestions,
|
|
15
|
+
parentCollection,
|
|
16
|
+
onContinue,
|
|
17
|
+
existingCollectionPaths
|
|
18
|
+
}: {
|
|
19
|
+
path: string;
|
|
20
|
+
pathSuggestions?: (path: string) => Promise<string[]>;
|
|
21
|
+
parentCollection?: EntityCollection;
|
|
22
|
+
onContinue: (importData?: object[], propertiesOrder?: string[]) => void;
|
|
23
|
+
existingCollectionPaths?: string[];
|
|
24
|
+
}) {
|
|
25
|
+
|
|
26
|
+
const [loadingPathSuggestions, setLoadingPathSuggestions] = useState(false);
|
|
27
|
+
const [filteredPathSuggestions, setFilteredPathSuggestions] = useState<string[] | undefined>();
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (pathSuggestions && existingCollectionPaths) {
|
|
30
|
+
setLoadingPathSuggestions(true);
|
|
31
|
+
pathSuggestions(path)
|
|
32
|
+
.then(suggestions => {
|
|
33
|
+
const filteredSuggestions = suggestions.filter(s => !(existingCollectionPaths ?? []).find(c => c.trim().toLowerCase() === s.trim().toLowerCase()));
|
|
34
|
+
setFilteredPathSuggestions(filteredSuggestions);
|
|
35
|
+
})
|
|
36
|
+
.finally(() => setLoadingPathSuggestions(false));
|
|
37
|
+
}
|
|
38
|
+
}, [existingCollectionPaths, path, pathSuggestions]);
|
|
39
|
+
|
|
40
|
+
// const {
|
|
41
|
+
// values,
|
|
42
|
+
// setFieldValue,
|
|
43
|
+
// setValues,
|
|
44
|
+
// handleChange,
|
|
45
|
+
// touched,
|
|
46
|
+
// errors,
|
|
47
|
+
// setFieldTouched,
|
|
48
|
+
// isSubmitting,
|
|
49
|
+
// submitCount
|
|
50
|
+
// } = useFormex<EntityCollection>();
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
values,
|
|
54
|
+
setFieldValue,
|
|
55
|
+
setValues,
|
|
56
|
+
submitCount
|
|
57
|
+
} = useFormex<EntityCollection>();
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className={"overflow-auto my-auto"}>
|
|
61
|
+
<Container maxWidth={"4xl"} className={"flex flex-col gap-4 p-8 m-auto"}>
|
|
62
|
+
|
|
63
|
+
<div
|
|
64
|
+
className="flex flex-row py-2 pt-3 items-center">
|
|
65
|
+
<Typography variant={"h4"} className={"flex-grow"}>
|
|
66
|
+
New collection
|
|
67
|
+
</Typography>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
{parentCollection && <Chip colorScheme={"tealDarker"}>
|
|
71
|
+
<Typography variant={"caption"}>
|
|
72
|
+
This is a subcollection of <b>{parentCollection.name}</b>
|
|
73
|
+
</Typography>
|
|
74
|
+
</Chip>}
|
|
75
|
+
|
|
76
|
+
<div className={"my-2"}>
|
|
77
|
+
<Typography variant={"caption"}
|
|
78
|
+
color={"secondary"}>
|
|
79
|
+
● Use one of the existing paths in your database:
|
|
80
|
+
</Typography>
|
|
81
|
+
<div className={"flex flex-wrap gap-x-2 gap-y-1 items-center my-2 min-h-7"}>
|
|
82
|
+
|
|
83
|
+
{loadingPathSuggestions && !filteredPathSuggestions && <CircularProgress size={"small"}/>}
|
|
84
|
+
|
|
85
|
+
{filteredPathSuggestions?.map((suggestion, index) => (
|
|
86
|
+
<Chip key={suggestion}
|
|
87
|
+
colorScheme={"cyanLighter"}
|
|
88
|
+
onClick={() => {
|
|
89
|
+
setFieldValue("name", unslugify(suggestion));
|
|
90
|
+
setFieldValue("id", suggestion);
|
|
91
|
+
setFieldValue("path", suggestion);
|
|
92
|
+
setFieldValue("properties", undefined);
|
|
93
|
+
onContinue();
|
|
94
|
+
}}
|
|
95
|
+
size="small">
|
|
96
|
+
{suggestion}
|
|
97
|
+
</Chip>
|
|
98
|
+
))}
|
|
99
|
+
|
|
100
|
+
{!loadingPathSuggestions && (filteredPathSuggestions ?? [])?.length === 0 &&
|
|
101
|
+
<Typography variant={"caption"}>
|
|
102
|
+
No suggestions
|
|
103
|
+
</Typography>
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div className={"my-2"}>
|
|
111
|
+
<Typography variant={"caption"}
|
|
112
|
+
color={"secondary"}>
|
|
113
|
+
● Select a template:
|
|
114
|
+
</Typography>
|
|
115
|
+
|
|
116
|
+
<div className={"flex gap-4"}>
|
|
117
|
+
<TemplateButton title={"Products"}
|
|
118
|
+
subtitle={"A collection of products with images, prices and stock"}
|
|
119
|
+
icon={<Icon size={"small"} iconKey={productsCollectionTemplate.icon!}/>}
|
|
120
|
+
onClick={() => {
|
|
121
|
+
setValues(productsCollectionTemplate);
|
|
122
|
+
onContinue();
|
|
123
|
+
}}/>
|
|
124
|
+
<TemplateButton title={"Users"}
|
|
125
|
+
subtitle={"A collection of users with emails, names and roles"}
|
|
126
|
+
icon={<Icon size={"small"} iconKey={usersCollectionTemplate.icon!}/>}
|
|
127
|
+
onClick={() => {
|
|
128
|
+
setValues(usersCollectionTemplate);
|
|
129
|
+
onContinue();
|
|
130
|
+
}}/>
|
|
131
|
+
<TemplateButton title={"Blog posts"}
|
|
132
|
+
subtitle={"A collection of blog posts with images, authors and complex content"}
|
|
133
|
+
icon={<Icon size={"small"} iconKey={blogCollectionTemplate.icon!}/>}
|
|
134
|
+
onClick={() => {
|
|
135
|
+
setValues(blogCollectionTemplate);
|
|
136
|
+
onContinue();
|
|
137
|
+
}}/>
|
|
138
|
+
<TemplateButton title={"Pages"}
|
|
139
|
+
subtitle={"A collection of pages with images, authors and complex content"}
|
|
140
|
+
icon={<Icon size={"small"} iconKey={pagesCollectionTemplate.icon!}/>}
|
|
141
|
+
onClick={() => {
|
|
142
|
+
setValues(pagesCollectionTemplate);
|
|
143
|
+
onContinue();
|
|
144
|
+
}}/>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
{!parentCollection && <div>
|
|
150
|
+
|
|
151
|
+
<Typography variant={"caption"}
|
|
152
|
+
color={"secondary"}
|
|
153
|
+
className={"mb-2"}>
|
|
154
|
+
● Create a collection from a file (csv, json, xls, xslx...)
|
|
155
|
+
</Typography>
|
|
156
|
+
|
|
157
|
+
<ImportFileUpload onDataAdded={(data, propertiesOrder) => onContinue(data, propertiesOrder)}/>
|
|
158
|
+
|
|
159
|
+
</div>}
|
|
160
|
+
|
|
161
|
+
<div>
|
|
162
|
+
|
|
163
|
+
<Button variant={"text"} onClick={() => onContinue()} className={"my-2"}>
|
|
164
|
+
Continue from scratch
|
|
165
|
+
</Button>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
{/*<div style={{ height: "52px" }}/>*/}
|
|
169
|
+
|
|
170
|
+
</Container>
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function TemplateButton({
|
|
176
|
+
title,
|
|
177
|
+
subtitle,
|
|
178
|
+
icon,
|
|
179
|
+
onClick
|
|
180
|
+
}: {
|
|
181
|
+
title: string,
|
|
182
|
+
icon: React.ReactNode,
|
|
183
|
+
subtitle: string,
|
|
184
|
+
onClick?: () => void
|
|
185
|
+
}) {
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<Tooltip title={subtitle}
|
|
189
|
+
asChild={true}>
|
|
190
|
+
<Card
|
|
191
|
+
onClick={onClick}
|
|
192
|
+
className={cls(
|
|
193
|
+
"my-2 rounded-md border mx-0 p-6 px-4 focus:outline-none transition ease-in-out duration-150 flex flex-row gap-4 items-center",
|
|
194
|
+
"text-gray-700 dark:text-slate-300",
|
|
195
|
+
"hover:border-primary-dark hover:text-primary-dark dark:hover:text-primary focus:ring-primary hover:ring-1 hover:ring-primary",
|
|
196
|
+
"border-gray-400 dark:border-gray-600 "
|
|
197
|
+
)}
|
|
198
|
+
>
|
|
199
|
+
{icon}
|
|
200
|
+
<div className={"flex flex-col items-start"}>
|
|
201
|
+
|
|
202
|
+
<Typography variant={"subtitle1"}>
|
|
203
|
+
{title}
|
|
204
|
+
</Typography>
|
|
205
|
+
{/*<Typography>*/}
|
|
206
|
+
{/* {subtitle}*/}
|
|
207
|
+
{/*</Typography>*/}
|
|
208
|
+
|
|
209
|
+
</div>
|
|
210
|
+
</Card>
|
|
211
|
+
</Tooltip>
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
}
|