@firecms/collection_editor 3.0.0-canary.145 → 3.0.0-canary.147
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 +27 -29
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +26 -28
- package/dist/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/src/types/persisted_collection.ts +0 -1
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +4 -2
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +2 -6
- package/src/ui/collection_editor/GetCodeDialog.tsx +22 -20
- package/src/ui/collection_editor/PropertyEditView.tsx +1 -0
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";
|
|
@@ -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);
|
|
@@ -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,
|