UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

33 lines (31 loc) 1.35 kB
import "../../../chunks/chunk-U5RRZUYZ.js"; // src/dashboard/view/diff/FieldDiff.tsx import { RichTextShape } from "alinea/core"; import { ListShape } from "alinea/core/shape/ListShape"; import { RecordShape } from "alinea/core/shape/RecordShape"; import { ScalarShape } from "alinea/core/shape/ScalarShape"; import { UnionShape } from "alinea/core/shape/UnionShape"; import { diffRecord } from "./DiffUtils.js"; import { FieldsDiff } from "./FieldsDiff.js"; import { ListDiff } from "./ListDiff.js"; import { RichTextDiff } from "./RichTextDiff.js"; import { ScalarDiff } from "./ScalarDiff.js"; import { jsx } from "react/jsx-runtime"; function FieldDiff({ shape, valueA, valueB }) { if (shape instanceof ScalarShape) { return /* @__PURE__ */ jsx(ScalarDiff, { valueA, valueB }); } else if (shape instanceof RichTextShape) { return /* @__PURE__ */ jsx(RichTextDiff, { shape, valueA, valueB }); } else if (shape instanceof ListShape) { return /* @__PURE__ */ jsx(ListDiff, { shape, valueA, valueB }); } else if (shape instanceof RecordShape) { const changes = diffRecord(shape, valueA, valueB); return /* @__PURE__ */ jsx(FieldsDiff, { changes, targetA: valueA, targetB: valueB }); } else if (shape instanceof UnionShape) { console.warn("UnionShape not supported yet"); } return null; } export { FieldDiff };