@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.es.js +38 -20
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +37 -19
- package/dist/index.umd.js.map +1 -1
- package/package.json +14 -14
- package/src/ui/collection_editor/EnumForm.tsx +5 -2
- package/src/ui/collection_editor/GetCodeDialog.tsx +32 -18
- package/src/ui/collection_editor/PropertyEditView.tsx +2 -2
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +2 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { FieldCaption, SearchIconsView, toSnakeCase, singular, IconForView, ArrayContainer, serializeRegExp, useSnackbarController, resolveEnumValues, isPropertyBuilder, useCustomizationController, getFieldConfig, ErrorBoundary, PropertyConfigBadge, unslugify, useNavigationController, mergeDeep, DEFAULT_FIELD_CONFIGS, isValidRegExp, getFieldId, ConfirmationDialog, useLargeLayout, makePropertiesEditable, resolveEntityView, useSelectionController, CircularProgressCenter, EntityCollectionTable, slugify, useAuthController, randomString, removeUndefined, ErrorView, removeInitialAndTrailingSlashes, getDefaultPropertiesOrder, joinCollectionLists } from "@firecms/core";
|
|
2
|
+
import { FieldCaption, SearchIconsView, toSnakeCase, singular, IconForView, ArrayContainer, serializeRegExp, useSnackbarController, resolveEnumValues, isPropertyBuilder, useCustomizationController, getFieldConfig, ErrorBoundary, PropertyConfigBadge, unslugify, useNavigationController, mergeDeep, DEFAULT_FIELD_CONFIGS, isValidRegExp, getFieldId, isEmptyObject, ConfirmationDialog, useLargeLayout, makePropertiesEditable, resolveEntityView, useSelectionController, CircularProgressCenter, EntityCollectionTable, slugify, useAuthController, randomString, removeUndefined, ErrorView, removeInitialAndTrailingSlashes, getDefaultPropertiesOrder, joinCollectionLists } from "@firecms/core";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import React__default, { useContext, useState, useEffect, useMemo, useRef, useDeferredValue, useCallback } from "react";
|
|
5
5
|
import equal from "react-fast-compare";
|
|
@@ -499,7 +499,10 @@ function EnumFormFields({
|
|
|
499
499
|
const [inferring, setInferring] = React__default.useState(false);
|
|
500
500
|
const inferredValuesRef = React__default.useRef(/* @__PURE__ */ new Set());
|
|
501
501
|
const inferredValues = inferredValuesRef.current;
|
|
502
|
-
const buildEntry = (
|
|
502
|
+
const buildEntry = ({
|
|
503
|
+
index,
|
|
504
|
+
internalId
|
|
505
|
+
}) => {
|
|
503
506
|
const justAdded = lastInternalIdAdded === internalId;
|
|
504
507
|
const entryError = errors?.enumValues && errors?.enumValues[index];
|
|
505
508
|
return /* @__PURE__ */ jsx(
|
|
@@ -1751,7 +1754,7 @@ function MapPropertyField({ disabled, getData, allowDataInference, propertyConfi
|
|
|
1751
1754
|
value: values.spreadChildren ?? false
|
|
1752
1755
|
}
|
|
1753
1756
|
),
|
|
1754
|
-
/* @__PURE__ */ jsx(FieldCaption, { children: "Set this flag to true if you want to display the children of this group as individual columns." })
|
|
1757
|
+
/* @__PURE__ */ jsx(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." })
|
|
1755
1758
|
] }),
|
|
1756
1759
|
/* @__PURE__ */ jsx(
|
|
1757
1760
|
PropertyFormDialog,
|
|
@@ -2122,7 +2125,7 @@ function BlockPropertyField({
|
|
|
2122
2125
|
onPropertyMove: disabled ? void 0 : onPropertyMove
|
|
2123
2126
|
}
|
|
2124
2127
|
),
|
|
2125
|
-
!disabled &&
|
|
2128
|
+
!disabled && values.oneOf?.propertiesOrder?.length === 0 && /* @__PURE__ */ jsx("div", { className: "h-full flex items-center justify-center p-4", children: "Add the first property to this block" })
|
|
2126
2129
|
] })
|
|
2127
2130
|
] }),
|
|
2128
2131
|
!disabled && /* @__PURE__ */ jsx(
|
|
@@ -3254,7 +3257,7 @@ function PropertyEditFormFields({
|
|
|
3254
3257
|
}
|
|
3255
3258
|
}, [deferredValues, includeIdAndTitle, propertyNamespace]);
|
|
3256
3259
|
useEffect(() => {
|
|
3257
|
-
if (values?.id && onError) {
|
|
3260
|
+
if (values?.id && onError && !isEmptyObject(errors)) {
|
|
3258
3261
|
onError(values?.id, propertyNamespace, errors);
|
|
3259
3262
|
}
|
|
3260
3263
|
}, [errors, propertyNamespace, values?.id]);
|
|
@@ -3774,21 +3777,34 @@ function GetCodeDialog({
|
|
|
3774
3777
|
);
|
|
3775
3778
|
}
|
|
3776
3779
|
function collectionToCode(collection) {
|
|
3777
|
-
const propertyCleanup = (
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
}
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3780
|
+
const propertyCleanup = (value) => {
|
|
3781
|
+
if (typeof value === "function") {
|
|
3782
|
+
return value;
|
|
3783
|
+
}
|
|
3784
|
+
if (Array.isArray(value)) {
|
|
3785
|
+
return value.map((v) => propertyCleanup(v));
|
|
3786
|
+
}
|
|
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]);
|
|
3793
|
+
if (childRes !== null && childRes !== void 0 && childRes !== false && !isEmptyObject(childRes)) {
|
|
3794
|
+
value[key] = childRes;
|
|
3795
|
+
} else {
|
|
3796
|
+
delete value[key];
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
});
|
|
3790
3800
|
}
|
|
3791
|
-
|
|
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;
|
|
3792
3808
|
};
|
|
3793
3809
|
return {
|
|
3794
3810
|
id: collection.id,
|
|
@@ -3803,7 +3819,9 @@ function collectionToCode(collection) {
|
|
|
3803
3819
|
customId: collection.customId,
|
|
3804
3820
|
initialFilter: collection.initialFilter,
|
|
3805
3821
|
initialSort: collection.initialSort,
|
|
3806
|
-
properties: Object.entries(
|
|
3822
|
+
properties: Object.entries({
|
|
3823
|
+
...collection.properties ?? {}
|
|
3824
|
+
}).map(([key, value]) => ({
|
|
3807
3825
|
[key]: propertyCleanup(value)
|
|
3808
3826
|
})).reduce((a, b) => ({ ...a, ...b }), {}),
|
|
3809
3827
|
subcollections: (collection.subcollections ?? []).map(collectionToCode)
|