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)

43 lines (39 loc) 1.39 kB
import "../../../chunks/chunk-U5RRZUYZ.js"; // src/dashboard/view/diff/EntryDiff.tsx import { Type } from "alinea/core"; import { Chip, TextLabel, fromModule } 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 = fromModule(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 };