@firecms/core 3.0.0-canary.244 → 3.0.0-canary.246

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.
@@ -111,7 +111,8 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
111
111
  propertiesOrder?: (Extract<keyof M, string> | string | `subcollection:${string}` | "collectionGroupParent")[];
112
112
  /**
113
113
  * If enabled, content is loaded in batches. If `false` all entities in the
114
- * collection are loaded.
114
+ * collection are loaded. This means that when reaching the end of the
115
+ * collection, the CMS will load more entities.
115
116
  * You can specify a number to specify the pagination size (50 by default)
116
117
  * Defaults to `true`
117
118
  */
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.244",
4
+ "version": "3.0.0-canary.246",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -53,9 +53,9 @@
53
53
  "@dnd-kit/core": "^6.3.1",
54
54
  "@dnd-kit/modifiers": "^9.0.0",
55
55
  "@dnd-kit/sortable": "^10.0.0",
56
- "@firecms/editor": "^3.0.0-canary.244",
57
- "@firecms/formex": "^3.0.0-canary.244",
58
- "@firecms/ui": "^3.0.0-canary.244",
56
+ "@firecms/editor": "^3.0.0-canary.246",
57
+ "@firecms/formex": "^3.0.0-canary.246",
58
+ "@firecms/ui": "^3.0.0-canary.246",
59
59
  "@radix-ui/react-portal": "^1.1.3",
60
60
  "clsx": "^2.1.1",
61
61
  "date-fns": "^3.6.0",
@@ -107,7 +107,7 @@
107
107
  "dist",
108
108
  "src"
109
109
  ],
110
- "gitHead": "6b3dcdc942e0fd64e3023b5361c34ec2ac2bb1d3",
110
+ "gitHead": "0ba87a9533643d2d58455e02e99b4cab92beaf64",
111
111
  "publishConfig": {
112
112
  "access": "public"
113
113
  },
@@ -337,6 +337,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
337
337
  entity={entity}
338
338
  path={path}
339
339
  collection={collection}/>
340
+ <div className="h-16"/>
340
341
  </div>
341
342
  </div> : null;
342
343
 
@@ -100,11 +100,6 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, USE
100
100
  updatedValues = values;
101
101
  }
102
102
 
103
- console.debug("Saving entity", {
104
- entityId,
105
- updatedValues,
106
- collection
107
- });
108
103
  return dataSource.saveEntity({
109
104
  collection,
110
105
  path: resolvedPath,
@@ -142,7 +137,6 @@ export async function saveEntityWithCallbacks<M extends Record<string, any>, USE
142
137
  onSaveSuccess(entity);
143
138
  })
144
139
  .catch((e) => {
145
- console.error("!!!", e);
146
140
  if (callbacks?.onSaveFailure) {
147
141
 
148
142
  const resolvedCollection = resolveCollection<M>({
@@ -127,7 +127,8 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
127
127
 
128
128
  /**
129
129
  * If enabled, content is loaded in batches. If `false` all entities in the
130
- * collection are loaded.
130
+ * collection are loaded. This means that when reaching the end of the
131
+ * collection, the CMS will load more entities.
131
132
  * You can specify a number to specify the pagination size (50 by default)
132
133
  * Defaults to `true`
133
134
  */
@@ -12,32 +12,65 @@ export function isObject(item: any) {
12
12
  return item && typeof item === "object" && !Array.isArray(item);
13
13
  }
14
14
 
15
- export function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(target: T, source: U, ignoreUndefined: boolean = false): T & U {
16
- const targetIsObject = isObject(target);
17
- const output = targetIsObject ? { ...target } : target;
18
- if (targetIsObject && isObject(source)) {
19
- Object.keys(source).forEach(key => {
20
- const sourceElement = source[key];
21
- // Skip undefined values when ignoreUndefined is true
22
- if (ignoreUndefined && sourceElement === undefined) {
23
- return;
15
+ export function mergeDeep<T extends Record<any, any>, U extends Record<any, any>>(
16
+ target: T,
17
+ source: U,
18
+ ignoreUndefined: boolean = false
19
+ ): T & U {
20
+ // If target is not a true object (e.g., null, array, primitive), return target itself.
21
+ if (!isObject(target)) {
22
+ return target as T & U;
23
+ }
24
+
25
+ // Create a shallow copy of the target to avoid modifying the original object.
26
+ const output = { ...target };
27
+
28
+ // If source is not a true object, there's nothing to merge from it.
29
+ // Return the shallow copy of target.
30
+ if (!isObject(source)) {
31
+ return output as T & U;
32
+ }
33
+
34
+ // Iterate over keys in the source object.
35
+ for (const key in source) {
36
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
37
+ const sourceValue = source[key];
38
+ const outputValue = (output as any)[key]; // Current value in our merged object (originating from target)
39
+
40
+ // Skip if source value is undefined and ignoreUndefined is true.
41
+ // This handles both not adding new undefined properties and not overwriting existing properties with undefined.
42
+ if (ignoreUndefined && sourceValue === undefined) {
43
+ continue;
24
44
  }
25
- if (sourceElement instanceof Date) {
26
- // Assign a new Date instance with the same time value
27
- Object.assign(output, { [key]: new Date(sourceElement.getTime()) });
28
- } else if (isObject(sourceElement)) {
29
- if (!(key in target))
30
- Object.assign(output, { [key]: sourceElement });
31
- else
32
- (output as any)[key] = mergeDeep((target as any)[key], sourceElement);
45
+
46
+ if ((sourceValue as any) instanceof Date) {
47
+ // If source value is a Date, create a new Date instance.
48
+ (output as any)[key] = new Date(sourceValue.getTime());
49
+ } else if (Array.isArray(sourceValue)) {
50
+ // If source value is an array, create a shallow copy of the array.
51
+ (output as any)[key] = [...sourceValue];
52
+ } else if (isObject(sourceValue)) {
53
+ // If source value is an object:
54
+ if (isObject(outputValue)) {
55
+ // If the corresponding value in output (from target) is also an object, recurse.
56
+ // Ensure the ignoreUndefined flag is passed down.
57
+ (output as any)[key] = mergeDeep(outputValue, sourceValue, ignoreUndefined);
58
+ } else {
59
+ // If output's value (from target) is not an object (e.g., null, primitive, or key didn't exist in original target),
60
+ // overwrite with the source object.
61
+ (output as any)[key] = sourceValue;
62
+ }
33
63
  } else {
34
- Object.assign(output, { [key]: sourceElement });
64
+ // If source value is a primitive, null, or undefined (and not ignored).
65
+ (output as any)[key] = sourceValue;
35
66
  }
36
- });
67
+ }
37
68
  }
38
- return output as T;
69
+
70
+ return output as T & U;
39
71
  }
40
72
 
73
+
41
74
  export function getValueInPath(o: object | undefined, path: string): any {
42
75
  if (!o) return undefined;
43
76
  if (typeof o === "object") {