@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
package/dist/index.es.js
CHANGED
|
@@ -251,31 +251,36 @@ function isObject(item) {
|
|
|
251
251
|
return item && typeof item === "object" && !Array.isArray(item);
|
|
252
252
|
}
|
|
253
253
|
function mergeDeep(target, source, ignoreUndefined = false) {
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
if (!isObject(target)) {
|
|
255
|
+
return target;
|
|
256
|
+
}
|
|
257
|
+
const output = {
|
|
256
258
|
...target
|
|
257
|
-
}
|
|
258
|
-
if (
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
259
|
+
};
|
|
260
|
+
if (!isObject(source)) {
|
|
261
|
+
return output;
|
|
262
|
+
}
|
|
263
|
+
for (const key in source) {
|
|
264
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
265
|
+
const sourceValue = source[key];
|
|
266
|
+
const outputValue = output[key];
|
|
267
|
+
if (ignoreUndefined && sourceValue === void 0) {
|
|
268
|
+
continue;
|
|
263
269
|
}
|
|
264
|
-
if (
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
} else if (isObject(
|
|
269
|
-
if (
|
|
270
|
-
[key]
|
|
271
|
-
}
|
|
272
|
-
|
|
270
|
+
if (sourceValue instanceof Date) {
|
|
271
|
+
output[key] = new Date(sourceValue.getTime());
|
|
272
|
+
} else if (Array.isArray(sourceValue)) {
|
|
273
|
+
output[key] = [...sourceValue];
|
|
274
|
+
} else if (isObject(sourceValue)) {
|
|
275
|
+
if (isObject(outputValue)) {
|
|
276
|
+
output[key] = mergeDeep(outputValue, sourceValue, ignoreUndefined);
|
|
277
|
+
} else {
|
|
278
|
+
output[key] = sourceValue;
|
|
279
|
+
}
|
|
273
280
|
} else {
|
|
274
|
-
|
|
275
|
-
[key]: sourceElement
|
|
276
|
-
});
|
|
281
|
+
output[key] = sourceValue;
|
|
277
282
|
}
|
|
278
|
-
}
|
|
283
|
+
}
|
|
279
284
|
}
|
|
280
285
|
return output;
|
|
281
286
|
}
|
|
@@ -4406,11 +4411,6 @@ async function saveEntityWithCallbacks({
|
|
|
4406
4411
|
} else {
|
|
4407
4412
|
updatedValues = values;
|
|
4408
4413
|
}
|
|
4409
|
-
console.debug("Saving entity", {
|
|
4410
|
-
entityId,
|
|
4411
|
-
updatedValues,
|
|
4412
|
-
collection
|
|
4413
|
-
});
|
|
4414
4414
|
return dataSource.saveEntity({
|
|
4415
4415
|
collection,
|
|
4416
4416
|
path: resolvedPath,
|
|
@@ -4445,7 +4445,6 @@ async function saveEntityWithCallbacks({
|
|
|
4445
4445
|
}
|
|
4446
4446
|
if (onSaveSuccess) onSaveSuccess(entity);
|
|
4447
4447
|
}).catch((e) => {
|
|
4448
|
-
console.error("!!!", e);
|
|
4449
4448
|
if (callbacks?.onSaveFailure) {
|
|
4450
4449
|
const resolvedCollection = resolveCollection({
|
|
4451
4450
|
collection,
|
|
@@ -21885,7 +21884,8 @@ function EntityEditViewInner({
|
|
|
21885
21884
|
};
|
|
21886
21885
|
const entityReadOnlyView = !canEdit && entity ? /* @__PURE__ */ jsx("div", { className: cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", canEdit || !mainViewVisible || selectedSecondaryForm ? "hidden" : ""), children: /* @__PURE__ */ jsxs("div", { className: cls("relative flex flex-col max-w-4xl lg:max-w-3xl xl:max-w-4xl 2xl:max-w-6xl w-full h-fit"), children: [
|
|
21887
21886
|
/* @__PURE__ */ jsx(Typography, { className: "mt-16 mb-8 mx-8", variant: "h4", children: collection.singularName ?? collection.name }),
|
|
21888
|
-
/* @__PURE__ */ jsx(EntityView, { className: "px-8 h-full overflow-auto", entity, path, collection })
|
|
21887
|
+
/* @__PURE__ */ jsx(EntityView, { className: "px-8 h-full overflow-auto", entity, path, collection }),
|
|
21888
|
+
/* @__PURE__ */ jsx("div", { className: "h-16" })
|
|
21889
21889
|
] }) }) : null;
|
|
21890
21890
|
const entityView = /* @__PURE__ */ jsx(EntityForm, { collection, path, entityId: entityId ?? usedEntity?.id, onValuesModified, entity, initialDirtyValues: cachedDirtyValues, openEntityMode: layout, forceActionsAtTheBottom: actionsAtTheBottom, initialStatus: status, className: cls((!mainViewVisible || !canEdit) && !selectedSecondaryForm ? "hidden" : "", formProps?.className), EntityFormActionsComponent: EntityEditViewFormActions, disabled: !canEdit, ...formProps, onEntityChange: (entity_0) => {
|
|
21891
21891
|
setUsedEntity(entity_0);
|