@firecms/collection_editor 3.0.0-canary.140 → 3.0.0-canary.141

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.umd.js CHANGED
@@ -507,7 +507,10 @@
507
507
  const [inferring, setInferring] = React.useState(false);
508
508
  const inferredValuesRef = React.useRef(/* @__PURE__ */ new Set());
509
509
  const inferredValues = inferredValuesRef.current;
510
- const buildEntry = (index, internalId) => {
510
+ const buildEntry = ({
511
+ index,
512
+ internalId
513
+ }) => {
511
514
  const justAdded = lastInternalIdAdded === internalId;
512
515
  const entryError = errors?.enumValues && errors?.enumValues[index];
513
516
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -1759,7 +1762,7 @@
1759
1762
  value: values.spreadChildren ?? false
1760
1763
  }
1761
1764
  ),
1762
- /* @__PURE__ */ jsxRuntime.jsx(core.FieldCaption, { children: "Set this flag to true if you want to display the children of this group as individual columns." })
1765
+ /* @__PURE__ */ jsxRuntime.jsx(core.FieldCaption, { children: "Set this flag to true if you want to display the children of this group as individual columns. This will only work for top level groups." })
1763
1766
  ] }),
1764
1767
  /* @__PURE__ */ jsxRuntime.jsx(
1765
1768
  PropertyFormDialog,
@@ -2130,7 +2133,7 @@
2130
2133
  onPropertyMove: disabled ? void 0 : onPropertyMove
2131
2134
  }
2132
2135
  ),
2133
- !disabled && !values.oneOf?.propertiesOrder?.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full flex items-center justify-center p-4", children: "Add the first property to this block" })
2136
+ !disabled && values.oneOf?.propertiesOrder?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full flex items-center justify-center p-4", children: "Add the first property to this block" })
2134
2137
  ] })
2135
2138
  ] }),
2136
2139
  !disabled && /* @__PURE__ */ jsxRuntime.jsx(
@@ -3262,7 +3265,7 @@
3262
3265
  }
3263
3266
  }, [deferredValues, includeIdAndTitle, propertyNamespace]);
3264
3267
  React.useEffect(() => {
3265
- if (values?.id && onError) {
3268
+ if (values?.id && onError && !core.isEmptyObject(errors)) {
3266
3269
  onError(values?.id, propertyNamespace, errors);
3267
3270
  }
3268
3271
  }, [errors, propertyNamespace, values?.id]);
@@ -3782,21 +3785,34 @@
3782
3785
  );
3783
3786
  }
3784
3787
  function collectionToCode(collection) {
3785
- const propertyCleanup = (property) => {
3786
- const updatedProperty = {
3787
- ...property
3788
- };
3789
- delete updatedProperty.fromBuilder;
3790
- delete updatedProperty.resolved;
3791
- delete updatedProperty.propertiesOrder;
3792
- delete updatedProperty.editable;
3793
- if (updatedProperty.type === "map") {
3794
- return {
3795
- ...updatedProperty,
3796
- properties: updatedProperty.properties.map(propertyCleanup)
3797
- };
3788
+ const propertyCleanup = (value) => {
3789
+ if (typeof value === "function") {
3790
+ return value;
3791
+ }
3792
+ if (Array.isArray(value)) {
3793
+ return value.map((v) => propertyCleanup(v));
3794
+ }
3795
+ if (typeof value === "object") {
3796
+ if (value === null)
3797
+ return value;
3798
+ Object.keys(value).forEach((key) => {
3799
+ if (!core.isEmptyObject(value)) {
3800
+ const childRes = propertyCleanup(value[key]);
3801
+ if (childRes !== null && childRes !== void 0 && childRes !== false && !core.isEmptyObject(childRes)) {
3802
+ value[key] = childRes;
3803
+ } else {
3804
+ delete value[key];
3805
+ }
3806
+ }
3807
+ });
3798
3808
  }
3799
- return updatedProperty;
3809
+ delete value.fromBuilder;
3810
+ delete value.resolved;
3811
+ delete value.propertiesOrder;
3812
+ delete value.propertyConfig;
3813
+ delete value.resolvedProperties;
3814
+ delete value.editable;
3815
+ return value;
3800
3816
  };
3801
3817
  return {
3802
3818
  id: collection.id,
@@ -3811,7 +3827,9 @@
3811
3827
  customId: collection.customId,
3812
3828
  initialFilter: collection.initialFilter,
3813
3829
  initialSort: collection.initialSort,
3814
- properties: Object.entries(collection.properties ?? {}).map(([key, value]) => ({
3830
+ properties: Object.entries({
3831
+ ...collection.properties ?? {}
3832
+ }).map(([key, value]) => ({
3815
3833
  [key]: propertyCleanup(value)
3816
3834
  })).reduce((a, b) => ({ ...a, ...b }), {}),
3817
3835
  subcollections: (collection.subcollections ?? []).map(collectionToCode)