@firecms/collection_editor 3.0.0-canary.144 → 3.0.0-canary.146
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 +40 -42
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +39 -41
- package/dist/index.umd.js.map +1 -1
- package/dist/types/config_permissions.d.ts +2 -2
- package/dist/types/persisted_collection.d.ts +1 -1
- package/dist/useCollectionEditorPlugin.d.ts +4 -4
- package/package.json +8 -8
- package/src/types/config_permissions.ts +1 -1
- package/src/types/persisted_collection.ts +2 -3
- package/src/ui/CollectionViewHeaderAction.tsx +1 -1
- package/src/ui/NewCollectionButton.tsx +1 -1
- package/src/ui/PropertyAddColumnComponent.tsx +2 -2
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +1 -1
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +5 -3
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +2 -2
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +3 -7
- package/src/ui/collection_editor/GetCodeDialog.tsx +22 -20
- package/src/ui/collection_editor/PropertyEditView.tsx +1 -0
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +1 -1
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +1 -1
- package/src/useCollectionEditorPlugin.tsx +6 -6
package/dist/index.es.js
CHANGED
|
@@ -5,7 +5,7 @@ import React__default, { useContext, useState, useEffect, useMemo, useRef, useDe
|
|
|
5
5
|
import equal from "react-fast-compare";
|
|
6
6
|
import { useAutoComplete, Container, Typography, Tooltip, IconButton, Chip, TextField, cls, DebouncedTextField, Autocomplete, AutocompleteItem, ExpandablePanel, SettingsIcon, ClearIcon, Select, SelectItem, BooleanSwitchWithLabel, Dialog, AutoAwesomeIcon, Badge, ListIcon, Button, CircularProgress, Paper, DialogContent, DialogActions, RuleIcon, FileUploadIcon, MultiSelect, MultiSelectItem, cardMixin, cardClickableMixin, cardSelectedMixin, FunctionsIcon, RemoveCircleIcon, defaultBorderMixin, RemoveIcon, DragHandleIcon, AddIcon, SelectGroup, InfoLabel, DeleteIcon, fieldBackgroundMixin, fieldBackgroundDisabledMixin, fieldBackgroundHoverMixin, DialogTitle, Card, WarningOffIcon, ContentCopyIcon, CodeIcon, Table, TableBody, TableRow, TableCell, Alert, Icon, coolIconKeys, Tabs, Tab, ArrowBackIcon, LoadingButton, DoneIcon, Menu, MoreVertIcon, MenuItem, SaveIcon, UndoIcon } from "@firecms/ui";
|
|
7
7
|
import * as Yup from "yup";
|
|
8
|
-
import { useFormex, Field, getIn, useCreateFormex, Formex } from "@firecms/formex";
|
|
8
|
+
import { useFormex, Field, getIn, useCreateFormex, Formex, clone } from "@firecms/formex";
|
|
9
9
|
import { extractEnumFromValues, buildPropertyFromData, buildEntityPropertiesFromData } from "@firecms/schema_inference";
|
|
10
10
|
import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd";
|
|
11
11
|
import JSON5 from "json5";
|
|
@@ -193,7 +193,7 @@ function CollectionDetailsForm({
|
|
|
193
193
|
{
|
|
194
194
|
expanded: advancedPanelExpanded,
|
|
195
195
|
onExpandedChange: setAdvancedPanelExpanded,
|
|
196
|
-
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-
|
|
196
|
+
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-surface-500", children: [
|
|
197
197
|
/* @__PURE__ */ jsx(SettingsIcon, {}),
|
|
198
198
|
/* @__PURE__ */ jsx(
|
|
199
199
|
Typography,
|
|
@@ -997,7 +997,7 @@ function ValidationPanel({
|
|
|
997
997
|
initiallyExpanded: false,
|
|
998
998
|
asField: true,
|
|
999
999
|
innerClassName: "p-4",
|
|
1000
|
-
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-
|
|
1000
|
+
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-surface-500", children: [
|
|
1001
1001
|
/* @__PURE__ */ jsx(RuleIcon, {}),
|
|
1002
1002
|
/* @__PURE__ */ jsx(
|
|
1003
1003
|
Typography,
|
|
@@ -1134,7 +1134,7 @@ function StoragePropertyField({
|
|
|
1134
1134
|
/* @__PURE__ */ jsx("div", { className: "col-span-12", children: /* @__PURE__ */ jsx(
|
|
1135
1135
|
ExpandablePanel,
|
|
1136
1136
|
{
|
|
1137
|
-
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-
|
|
1137
|
+
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-surface-500", children: [
|
|
1138
1138
|
/* @__PURE__ */ jsx(FileUploadIcon, {}),
|
|
1139
1139
|
/* @__PURE__ */ jsx(
|
|
1140
1140
|
Typography,
|
|
@@ -1382,7 +1382,7 @@ function NonEditablePropertyPreview({
|
|
|
1382
1382
|
!propertyConfig && /* @__PURE__ */ jsx(
|
|
1383
1383
|
"div",
|
|
1384
1384
|
{
|
|
1385
|
-
className: "h-8 w-8 p-1 rounded-full shadow text-white bg-
|
|
1385
|
+
className: "h-8 w-8 p-1 rounded-full shadow text-white bg-surface-500",
|
|
1386
1386
|
children: /* @__PURE__ */ jsx(FunctionsIcon, { color: "inherit", size: "medium" })
|
|
1387
1387
|
}
|
|
1388
1388
|
),
|
|
@@ -2918,7 +2918,7 @@ function MarkdownPropertyField({
|
|
|
2918
2918
|
/* @__PURE__ */ jsx("div", { className: "col-span-12", children: /* @__PURE__ */ jsx(
|
|
2919
2919
|
ExpandablePanel,
|
|
2920
2920
|
{
|
|
2921
|
-
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-
|
|
2921
|
+
title: /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-surface-500", children: [
|
|
2922
2922
|
/* @__PURE__ */ jsx(FileUploadIcon, {}),
|
|
2923
2923
|
/* @__PURE__ */ jsx(
|
|
2924
2924
|
Typography,
|
|
@@ -3048,6 +3048,7 @@ const PropertyForm = React__default.memo(
|
|
|
3048
3048
|
onPropertyChanged?.(params);
|
|
3049
3049
|
};
|
|
3050
3050
|
const formexController = useCreateFormex({
|
|
3051
|
+
debugId: "PROPERTY_FORM",
|
|
3051
3052
|
initialValues: property ? { id: propertyKey, ...property } : initialValue,
|
|
3052
3053
|
initialErrors,
|
|
3053
3054
|
validateOnChange: true,
|
|
@@ -3708,7 +3709,7 @@ function GetCodeDialog({
|
|
|
3708
3709
|
open
|
|
3709
3710
|
}) {
|
|
3710
3711
|
const snackbarController = useSnackbarController();
|
|
3711
|
-
const code = collection ? 'import { EntityCollection } from "@firecms/core";\n\nconst ' + (collection?.name ? camelCase(collection.name) : "my") + "Collection:EntityCollection = " + JSON5.stringify(collectionToCode(collection), null, " ") : "No collection selected";
|
|
3712
|
+
const code = collection ? 'import { EntityCollection } from "@firecms/core";\n\nconst ' + (collection?.name ? camelCase(collection.name) : "my") + "Collection:EntityCollection = " + JSON5.stringify(collectionToCode({ ...collection }), null, " ") : "No collection selected";
|
|
3712
3713
|
return /* @__PURE__ */ jsxs(
|
|
3713
3714
|
Dialog,
|
|
3714
3715
|
{
|
|
@@ -3778,33 +3779,34 @@ function GetCodeDialog({
|
|
|
3778
3779
|
}
|
|
3779
3780
|
function collectionToCode(collection) {
|
|
3780
3781
|
const propertyCleanup = (value) => {
|
|
3781
|
-
|
|
3782
|
-
|
|
3782
|
+
const valueCopy = clone(value);
|
|
3783
|
+
if (typeof valueCopy === "function") {
|
|
3784
|
+
return valueCopy;
|
|
3783
3785
|
}
|
|
3784
|
-
if (Array.isArray(
|
|
3785
|
-
return
|
|
3786
|
+
if (Array.isArray(valueCopy)) {
|
|
3787
|
+
return valueCopy.map((v) => propertyCleanup(v));
|
|
3786
3788
|
}
|
|
3787
|
-
if (typeof
|
|
3788
|
-
if (
|
|
3789
|
-
return
|
|
3790
|
-
Object.keys(
|
|
3791
|
-
if (!isEmptyObject(
|
|
3792
|
-
const childRes = propertyCleanup(
|
|
3789
|
+
if (typeof valueCopy === "object") {
|
|
3790
|
+
if (valueCopy === null)
|
|
3791
|
+
return valueCopy;
|
|
3792
|
+
Object.keys(valueCopy).forEach((key) => {
|
|
3793
|
+
if (!isEmptyObject(valueCopy)) {
|
|
3794
|
+
const childRes = propertyCleanup(valueCopy[key]);
|
|
3793
3795
|
if (childRes !== null && childRes !== void 0 && childRes !== false && !isEmptyObject(childRes)) {
|
|
3794
|
-
|
|
3796
|
+
valueCopy[key] = childRes;
|
|
3795
3797
|
} else {
|
|
3796
|
-
delete
|
|
3798
|
+
delete valueCopy[key];
|
|
3797
3799
|
}
|
|
3798
3800
|
}
|
|
3799
3801
|
});
|
|
3800
3802
|
}
|
|
3801
|
-
delete
|
|
3802
|
-
delete
|
|
3803
|
-
delete
|
|
3804
|
-
delete
|
|
3805
|
-
delete
|
|
3806
|
-
delete
|
|
3807
|
-
return
|
|
3803
|
+
delete valueCopy.fromBuilder;
|
|
3804
|
+
delete valueCopy.resolved;
|
|
3805
|
+
delete valueCopy.propertiesOrder;
|
|
3806
|
+
delete valueCopy.propertyConfig;
|
|
3807
|
+
delete valueCopy.resolvedProperties;
|
|
3808
|
+
delete valueCopy.editable;
|
|
3809
|
+
return valueCopy;
|
|
3808
3810
|
};
|
|
3809
3811
|
return {
|
|
3810
3812
|
id: collection.id,
|
|
@@ -3959,15 +3961,10 @@ function CollectionPropertiesEditorForm({
|
|
|
3959
3961
|
previousId,
|
|
3960
3962
|
namespace
|
|
3961
3963
|
}) => {
|
|
3964
|
+
console.log("!!!!!! onPropertyChanged", property);
|
|
3962
3965
|
const fullId = id ? getFullId(id, namespace) : void 0;
|
|
3963
3966
|
const propertyPath = fullId ? idToPropertiesPath(fullId) : void 0;
|
|
3964
3967
|
if (previousId && previousId !== id) {
|
|
3965
|
-
console.debug("onPropertyChanged, id change", {
|
|
3966
|
-
id,
|
|
3967
|
-
property,
|
|
3968
|
-
previousId,
|
|
3969
|
-
namespace
|
|
3970
|
-
});
|
|
3971
3968
|
const previousFullId = getFullId(previousId, namespace);
|
|
3972
3969
|
const previousPropertyPath = idToPropertiesPath(previousFullId);
|
|
3973
3970
|
const currentPropertiesOrder = getCurrentPropertiesOrder(namespace);
|
|
@@ -4023,7 +4020,7 @@ function CollectionPropertiesEditorForm({
|
|
|
4023
4020
|
setSelectedPropertyKey(propertyKey);
|
|
4024
4021
|
setSelectedPropertyNamespace(namespace);
|
|
4025
4022
|
};
|
|
4026
|
-
const body = /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 gap-2 h-full bg-
|
|
4023
|
+
const body = /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 gap-2 h-full bg-surface-50 dark:bg-surface-900", children: [
|
|
4027
4024
|
/* @__PURE__ */ jsxs("div", { className: cls(
|
|
4028
4025
|
"p-4 md:p-8 pb-20 md:pb-20",
|
|
4029
4026
|
"col-span-12 lg:col-span-5 h-full overflow-auto",
|
|
@@ -5124,9 +5121,9 @@ function TemplateButton({
|
|
|
5124
5121
|
onClick,
|
|
5125
5122
|
className: cls(
|
|
5126
5123
|
"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",
|
|
5127
|
-
"text-
|
|
5124
|
+
"text-surface-700 dark:text-surface-accent-300",
|
|
5128
5125
|
"hover:border-primary-dark hover:text-primary-dark dark:hover:text-primary focus:ring-primary hover:ring-1 hover:ring-primary",
|
|
5129
|
-
"border-
|
|
5126
|
+
"border-surface-400 dark:border-surface-600 "
|
|
5130
5127
|
),
|
|
5131
5128
|
children: [
|
|
5132
5129
|
icon,
|
|
@@ -5697,7 +5694,7 @@ function CollectionEditorInternal({
|
|
|
5697
5694
|
try {
|
|
5698
5695
|
if (!isNewCollection) {
|
|
5699
5696
|
saveCollection(newCollectionState).then(() => {
|
|
5700
|
-
formexController.resetForm(
|
|
5697
|
+
formexController.resetForm();
|
|
5701
5698
|
handleClose(newCollectionState);
|
|
5702
5699
|
});
|
|
5703
5700
|
return;
|
|
@@ -5781,7 +5778,8 @@ function CollectionEditorInternal({
|
|
|
5781
5778
|
const formController = useCreateFormex({
|
|
5782
5779
|
initialValues,
|
|
5783
5780
|
onSubmit,
|
|
5784
|
-
validation
|
|
5781
|
+
validation,
|
|
5782
|
+
debugId: "COLLECTION_EDITOR"
|
|
5785
5783
|
});
|
|
5786
5784
|
const {
|
|
5787
5785
|
values,
|
|
@@ -5836,7 +5834,7 @@ function CollectionEditorInternal({
|
|
|
5836
5834
|
Tabs,
|
|
5837
5835
|
{
|
|
5838
5836
|
value: currentView,
|
|
5839
|
-
className: cls(defaultBorderMixin, "justify-end bg-
|
|
5837
|
+
className: cls(defaultBorderMixin, "justify-end bg-surface-50 dark:bg-surface-950 border-b"),
|
|
5840
5838
|
onValueChange: (v) => setCurrentView(v),
|
|
5841
5839
|
children: [
|
|
5842
5840
|
/* @__PURE__ */ jsx(Tab, { value: "details", children: "Details" }),
|
|
@@ -6499,7 +6497,7 @@ function CollectionViewHeaderAction({
|
|
|
6499
6497
|
children: /* @__PURE__ */ jsx(
|
|
6500
6498
|
IconButton,
|
|
6501
6499
|
{
|
|
6502
|
-
className: onHover ? "bg-white dark:bg-
|
|
6500
|
+
className: onHover ? "bg-white dark:bg-surface-950" : "hidden",
|
|
6503
6501
|
onClick: () => {
|
|
6504
6502
|
collectionEditorController.editProperty({
|
|
6505
6503
|
propertyKey,
|
|
@@ -6537,7 +6535,7 @@ function PropertyAddColumnComponent({
|
|
|
6537
6535
|
children: /* @__PURE__ */ jsx(
|
|
6538
6536
|
"div",
|
|
6539
6537
|
{
|
|
6540
|
-
className: "p-0.5 w-20 h-full flex items-center justify-center cursor-pointer bg-
|
|
6538
|
+
className: "p-0.5 w-20 h-full flex items-center justify-center cursor-pointer bg-surface-100 bg-opacity-40 hover:bg-surface-100 dark:bg-surface-950 dark:bg-opacity-40 dark:hover:bg-surface-950",
|
|
6541
6539
|
onClick: () => {
|
|
6542
6540
|
collectionEditorController.editProperty({
|
|
6543
6541
|
editedCollectionId: collection.id,
|
|
@@ -6555,7 +6553,7 @@ function PropertyAddColumnComponent({
|
|
|
6555
6553
|
}
|
|
6556
6554
|
function NewCollectionButton() {
|
|
6557
6555
|
const collectionEditorController = useCollectionEditorController();
|
|
6558
|
-
return /* @__PURE__ */ jsx("div", { className: "bg-
|
|
6556
|
+
return /* @__PURE__ */ jsx("div", { className: "bg-surface-50 dark:bg-surface-900 min-w-fit rounded", children: /* @__PURE__ */ jsxs(
|
|
6559
6557
|
Button,
|
|
6560
6558
|
{
|
|
6561
6559
|
className: "min-w-fit",
|
|
@@ -6755,7 +6753,7 @@ function IntroWidget({}) {
|
|
|
6755
6753
|
return /* @__PURE__ */ jsxs(
|
|
6756
6754
|
Paper,
|
|
6757
6755
|
{
|
|
6758
|
-
className: "my-4 px-4 py-6 flex flex-col bg-white dark:bg-
|
|
6756
|
+
className: "my-4 px-4 py-6 flex flex-col bg-white dark:bg-surface-accent-800 gap-2",
|
|
6759
6757
|
children: [
|
|
6760
6758
|
/* @__PURE__ */ jsx(Typography, { variant: "subtitle2", className: "uppercase", children: "No collections found" }),
|
|
6761
6759
|
/* @__PURE__ */ jsx(Typography, { children: "Start building collections in FireCMS easily. Map them to your existing database data, import from files, or use our templates." }),
|