alinea
Version:
Headless git-based CMS
46 lines (42 loc) • 1.45 kB
JavaScript
import {
dist_default
} from "../../../chunks/chunk-A5O3N2GS.js";
import "../../../chunks/chunk-NZLE2WMY.js";
// src/dashboard/view/diff/EntryDiff.tsx
import { Type } from "alinea/core/Type";
import { Chip, TextLabel } from "alinea/ui";
import { useConfig } from "../../hook/UseConfig.js";
import { diffRecord } from "./DiffUtils.js";
// src/dashboard/view/diff/EntryDiff.module.scss
var EntryDiff_module_default = {
"root": "alinea-EntryDiff"
};
// src/dashboard/view/diff/EntryDiff.tsx
import { FieldsDiff } from "./FieldsDiff.js";
import { jsx, jsxs } from "react/jsx-runtime";
var styles = dist_default(EntryDiff_module_default);
function EntryDiff({ entryA, entryB }) {
const { schema } = useConfig();
const typeA = schema[entryA.type];
const typeB = schema[entryB.type];
const typeChanged = typeA !== typeB;
if (typeChanged)
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx(Chip, { children: /* @__PURE__ */ jsx(TextLabel, { label: Type.label(typeA) }) }),
" ",
"=>",
/* @__PURE__ */ jsx(Chip, { children: /* @__PURE__ */ jsx(TextLabel, { label: Type.label(typeB) }) })
] });
const changes = diffRecord(Type.shape(typeA), entryA.data, entryB.data);
return /* @__PURE__ */ jsx("div", { className: styles.root(), children: /* @__PURE__ */ jsx(
FieldsDiff,
{
changes,
targetA: entryA.data,
targetB: entryB.data
}
) });
}
export {
EntryDiff
};