@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/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.140",
4
+ "version": "3.0.0-canary.141",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "source": "src/index.ts",
9
9
  "dependencies": {
10
- "@firecms/data_export": "^3.0.0-canary.140",
11
- "@firecms/data_import": "^3.0.0-canary.140",
12
- "@firecms/data_import_export": "^3.0.0-canary.140",
13
- "@firecms/formex": "^3.0.0-canary.140",
14
- "@firecms/schema_inference": "^3.0.0-canary.140",
15
- "@firecms/ui": "^3.0.0-canary.140",
10
+ "@firecms/data_export": "^3.0.0-canary.141",
11
+ "@firecms/data_import": "^3.0.0-canary.141",
12
+ "@firecms/data_import_export": "^3.0.0-canary.141",
13
+ "@firecms/formex": "^3.0.0-canary.141",
14
+ "@firecms/schema_inference": "^3.0.0-canary.141",
15
+ "@firecms/ui": "^3.0.0-canary.141",
16
16
  "json5": "^2.2.3",
17
17
  "prism-react-renderer": "^2.4.0"
18
18
  },
@@ -50,15 +50,15 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jest/globals": "^29.7.0",
53
- "@types/react": "^18.3.11",
54
- "@types/react-dom": "^18.3.0",
55
- "@vitejs/plugin-react": "^4.3.2",
53
+ "@types/react": "^18.3.12",
54
+ "@types/react-dom": "^18.3.1",
55
+ "@vitejs/plugin-react": "^4.3.3",
56
56
  "jest": "^29.7.0",
57
- "react-router": "^6.26.2",
58
- "react-router-dom": "^6.26.2",
57
+ "react-router": "^6.27.0",
58
+ "react-router-dom": "^6.27.0",
59
59
  "ts-jest": "^29.2.5",
60
60
  "typescript": "^5.6.3",
61
- "vite": "^5.4.8"
61
+ "vite": "^5.4.10"
62
62
  },
63
63
  "files": [
64
64
  "dist",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "112132e315d1ae63babf9f53500c00bc37a2d8e4"
70
+ "gitHead": "84beb9dab81946354e94b91d72a49889a2ca537c"
71
71
  }
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect } from "react";
2
2
  import equal from "react-fast-compare"
3
3
 
4
- import { ArrayContainer, EnumValueConfig, EnumValues, FieldCaption, } from "@firecms/core";
4
+ import { ArrayContainer, ArrayEntryParams, EnumValueConfig, EnumValues, FieldCaption, } from "@firecms/core";
5
5
  import {
6
6
  AutoAwesomeIcon,
7
7
  Badge,
@@ -121,7 +121,10 @@ function EnumFormFields({
121
121
  const inferredValuesRef = React.useRef(new Set());
122
122
  const inferredValues = inferredValuesRef.current;
123
123
 
124
- const buildEntry = (index: number, internalId: number) => {
124
+ const buildEntry = ({
125
+ index,
126
+ internalId
127
+ }:ArrayEntryParams) => {
125
128
  const justAdded = lastInternalIdAdded === internalId;
126
129
  const entryError = errors?.enumValues && errors?.enumValues[index];
127
130
  return <EnumEntry index={index}
@@ -1,4 +1,4 @@
1
- import { EntityCollection, useSnackbarController } from "@firecms/core";
1
+ import { EntityCollection, isEmptyObject, useSnackbarController } from "@firecms/core";
2
2
  import { Button, ContentCopyIcon, Dialog, DialogActions, DialogContent, Typography, } from "@firecms/ui";
3
3
  import React from "react";
4
4
  import JSON5 from "json5";
@@ -78,24 +78,36 @@ export function GetCodeDialog({
78
78
 
79
79
  function collectionToCode(collection: EntityCollection): object {
80
80
 
81
- const propertyCleanup = (property: any) => {
82
-
83
- const updatedProperty = {
84
- ...property
85
- };
81
+ const propertyCleanup = (value: any): any => {
82
+ if (typeof value === "function") {
83
+ return value;
84
+ }
85
+ if (Array.isArray(value)) {
86
+ return value.map((v: any) => propertyCleanup(v));
87
+ }
88
+ if (typeof value === "object") {
89
+ if (value === null)
90
+ return value;
91
+ Object.keys(value).forEach((key) => {
92
+ if (!isEmptyObject(value)) {
93
+ const childRes = propertyCleanup(value[key]);
94
+ if (childRes !== null && childRes !== undefined && childRes !== false && !isEmptyObject(childRes)) {
95
+ value[key] = childRes;
96
+ } else {
97
+ delete value[key];
98
+ }
99
+ }
100
+ });
101
+ }
86
102
 
87
- delete updatedProperty.fromBuilder;
88
- delete updatedProperty.resolved;
89
- delete updatedProperty.propertiesOrder;
90
- delete updatedProperty.editable;
103
+ delete value.fromBuilder;
104
+ delete value.resolved;
105
+ delete value.propertiesOrder;
106
+ delete value.propertyConfig;
107
+ delete value.resolvedProperties;
108
+ delete value.editable;
91
109
 
92
- if (updatedProperty.type === "map") {
93
- return {
94
- ...updatedProperty,
95
- properties: updatedProperty.properties.map(propertyCleanup)
96
- }
97
- }
98
- return updatedProperty;
110
+ return value;
99
111
  }
100
112
 
101
113
  return {
@@ -111,7 +123,9 @@ function collectionToCode(collection: EntityCollection): object {
111
123
  customId: collection.customId,
112
124
  initialFilter: collection.initialFilter,
113
125
  initialSort: collection.initialSort,
114
- properties: Object.entries(collection.properties ?? {})
126
+ properties: Object.entries({
127
+ ...(collection.properties ?? {})
128
+ })
115
129
  .map(([key, value]) => ({
116
130
  [key]: propertyCleanup(value)
117
131
  }))
@@ -6,7 +6,7 @@ import {
6
6
  ConfirmationDialog,
7
7
  DEFAULT_FIELD_CONFIGS,
8
8
  getFieldConfig,
9
- getFieldId,
9
+ getFieldId, isEmptyObject,
10
10
  isPropertyBuilder,
11
11
  isValidRegExp,
12
12
  mergeDeep,
@@ -380,7 +380,7 @@ function PropertyEditFormFields({
380
380
  }, [deferredValues, includeIdAndTitle, propertyNamespace]);
381
381
 
382
382
  useEffect(() => {
383
- if (values?.id && onError) {
383
+ if (values?.id && onError && !isEmptyObject(errors)) {
384
384
  onError(values?.id, propertyNamespace, errors);
385
385
  }
386
386
  }, [errors, propertyNamespace, values?.id]);
@@ -110,7 +110,7 @@ export function BlockPropertyField({
110
110
  ? undefined
111
111
  : onPropertyMove}/>
112
112
 
113
- {!disabled && !values.oneOf?.propertiesOrder?.length &&
113
+ {!disabled && (values.oneOf?.propertiesOrder?.length === 0)&&
114
114
  <div className="h-full flex items-center justify-center p-4">
115
115
  Add the first property to this block
116
116
  </div>}
@@ -113,7 +113,8 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
113
113
  value={values.spreadChildren ?? false}
114
114
  />
115
115
  <FieldCaption>
116
- Set this flag to true if you want to display the children of this group as individual columns.
116
+ Set this flag to true if you want to display the children of this group as individual columns. This
117
+ will only work for top level groups.
117
118
  </FieldCaption>
118
119
  </div>
119
120