@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.
- package/dist/index.es.js +28 -28
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +28 -28
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collections.d.ts +2 -1
- package/package.json +5 -5
- package/src/core/EntityEditView.tsx +1 -0
- package/src/hooks/data/save.ts +0 -6
- package/src/types/collections.ts +2 -1
- package/src/util/objects.ts +53 -20
|
@@ -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.
|
|
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.
|
|
57
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
58
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
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": "
|
|
110
|
+
"gitHead": "0ba87a9533643d2d58455e02e99b4cab92beaf64",
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
},
|
package/src/hooks/data/save.ts
CHANGED
|
@@ -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>({
|
package/src/types/collections.ts
CHANGED
|
@@ -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
|
*/
|
package/src/util/objects.ts
CHANGED
|
@@ -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>>(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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") {
|