alinea
Version:
Headless git-based CMS
52 lines (50 loc) • 1.46 kB
JavaScript
import "../../../chunks/chunk-NZLE2WMY.js";
// src/dashboard/view/diff/FieldDiff.tsx
import { ListShape } from "alinea/core/shape/ListShape";
import { RecordShape } from "alinea/core/shape/RecordShape";
import { RichTextShape } from "alinea/core/shape/RichTextShape";
import { ScalarShape } from "alinea/core/shape/ScalarShape";
import { UnionShape } from "alinea/core/shape/UnionShape";
import { diffRecord } from "./DiffUtils.js";
import { ListDiff } from "./ListDiff.js";
import { RichTextDiff } from "./RichTextDiff.js";
import { ScalarDiff } from "./ScalarDiff.js";
import { jsx } from "react/jsx-runtime";
function FieldDiff({ FieldsDiff, shape, valueA, valueB }) {
if (shape instanceof ScalarShape) {
return /* @__PURE__ */ jsx(ScalarDiff, { valueA, valueB });
}
if (shape instanceof RichTextShape) {
return /* @__PURE__ */ jsx(
RichTextDiff,
{
FieldsDiff,
shape,
valueA,
valueB
}
);
}
if (shape instanceof ListShape) {
return /* @__PURE__ */ jsx(
ListDiff,
{
FieldsDiff,
shape,
valueA,
valueB
}
);
}
if (shape instanceof RecordShape) {
const changes = diffRecord(shape, valueA, valueB);
return /* @__PURE__ */ jsx(FieldsDiff, { changes, targetA: valueA, targetB: valueB });
}
if (shape instanceof UnionShape) {
console.warn("UnionShape not supported yet");
}
return null;
}
export {
FieldDiff
};