@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 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
- if (typeof value === "function") {
3782
- return value;
3782
+ const valueCopy = clone(value);
3783
+ if (typeof valueCopy === "function") {
3784
+ return valueCopy;
3783
3785
  }
3784
- if (Array.isArray(value)) {
3785
- return value.map((v) => propertyCleanup(v));
3786
+ if (Array.isArray(valueCopy)) {
3787
+ return valueCopy.map((v) => propertyCleanup(v));
3786
3788
  }
3787
- if (typeof value === "object") {
3788
- if (value === null)
3789
- return value;
3790
- Object.keys(value).forEach((key) => {
3791
- if (!isEmptyObject(value)) {
3792
- const childRes = propertyCleanup(value[key]);
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
- value[key] = childRes;
3796
+ valueCopy[key] = childRes;
3795
3797
  } else {
3796
- delete value[key];
3798
+ delete valueCopy[key];
3797
3799
  }
3798
3800
  }
3799
3801
  });
3800
3802
  }
3801
- delete value.fromBuilder;
3802
- delete value.resolved;
3803
- delete value.propertiesOrder;
3804
- delete value.propertyConfig;
3805
- delete value.resolvedProperties;
3806
- delete value.editable;
3807
- return value;
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({ values: initialValues });
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,