@firecms/core 3.0.0-canary.200 → 3.0.0-canary.202

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.
@@ -281,6 +281,12 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
281
281
  * This prop has only effect if you are using the collection editor.
282
282
  */
283
283
  editable?: boolean;
284
+ /**
285
+ * If set to true, the default values of the properties will be applied
286
+ * to the entity every time the entity is updated (not only when created).
287
+ * Defaults to false.
288
+ */
289
+ alwaysApplyDefaultValues?: boolean;
284
290
  }
285
291
  /**
286
292
  * Parameter passed to the `Actions` prop in the collection configuration.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.200",
4
+ "version": "3.0.0-canary.202",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -50,9 +50,9 @@
50
50
  "./package.json": "./package.json"
51
51
  },
52
52
  "dependencies": {
53
- "@firecms/editor": "^3.0.0-canary.200",
54
- "@firecms/formex": "^3.0.0-canary.200",
55
- "@firecms/ui": "^3.0.0-canary.200",
53
+ "@firecms/editor": "^3.0.0-canary.202",
54
+ "@firecms/formex": "^3.0.0-canary.202",
55
+ "@firecms/ui": "^3.0.0-canary.202",
56
56
  "@hello-pangea/dnd": "^17.0.0",
57
57
  "@radix-ui/react-portal": "^1.1.3",
58
58
  "clsx": "^2.1.1",
@@ -104,7 +104,7 @@
104
104
  "dist",
105
105
  "src"
106
106
  ],
107
- "gitHead": "436e2b226039bdd2f3fe2f78a4e072200a715ddb",
107
+ "gitHead": "6e21f87de35d34c8c4fcb15d1e5f1d07b0f69488",
108
108
  "publishConfig": {
109
109
  "access": "public"
110
110
  },
@@ -6,7 +6,8 @@ import {
6
6
  EntityStatus,
7
7
  EntityValues,
8
8
  FormContext,
9
- PluginFormActionProps, PropertyConfig,
9
+ PluginFormActionProps,
10
+ PropertyConfig,
10
11
  PropertyFieldBindingProps,
11
12
  ResolvedEntityCollection
12
13
  } from "../types";
@@ -19,6 +20,7 @@ import {
19
20
  getValueInPath,
20
21
  isHidden,
21
22
  isReadOnly,
23
+ mergeDeep,
22
24
  resolveCollection,
23
25
  useDebouncedCallback
24
26
  } from "../util";
@@ -638,7 +640,12 @@ function getInitialEntityValues<M extends object>(
638
640
  });
639
641
  const properties = resolvedCollection.properties;
640
642
  if ((status === "existing" || status === "copy") && entity) {
641
- return entity.values ?? getDefaultValuesFor(properties);
643
+ if (!collection.alwaysApplyDefaultValues) {
644
+ return entity.values ?? getDefaultValuesFor(properties);
645
+ } else {
646
+ const defaultValues = getDefaultValuesFor(properties);
647
+ return mergeDeep(defaultValues, entity.values ?? {});
648
+ }
642
649
  } else if (status === "new") {
643
650
  return getDefaultValuesFor(properties);
644
651
  } else {
@@ -323,6 +323,13 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
323
323
  * This prop has only effect if you are using the collection editor.
324
324
  */
325
325
  editable?: boolean;
326
+
327
+ /**
328
+ * If set to true, the default values of the properties will be applied
329
+ * to the entity every time the entity is updated (not only when created).
330
+ * Defaults to false.
331
+ */
332
+ alwaysApplyDefaultValues?: boolean;
326
333
  }
327
334
 
328
335
  /**
@@ -18,7 +18,10 @@ export function mergeDeep<T extends Record<any, any>, U extends Record<any, any>
18
18
  if (targetIsObject && isObject(source)) {
19
19
  Object.keys(source).forEach(key => {
20
20
  const sourceElement = source[key];
21
- if (isObject(sourceElement)) {
21
+ if (sourceElement instanceof Date) {
22
+ // Assign a new Date instance with the same time value
23
+ Object.assign(output, { [key]: new Date(sourceElement.getTime()) });
24
+ } else if (isObject(sourceElement)) {
22
25
  if (!(key in target))
23
26
  Object.assign(output, { [key]: sourceElement });
24
27
  else