UNPKG

alinea

Version:
79 lines (75 loc) 2.94 kB
import { dist_default } from "../../../chunks/chunk-A5O3N2GS.js"; import { useAtom, useAtomValue } from "../../../chunks/chunk-TOJF2G3X.js"; import "../../../chunks/chunk-WJ67RR7S.js"; import "../../../chunks/chunk-NZLE2WMY.js"; // src/dashboard/view/entry/EntryHistory.tsx import { HStack, Icon, Loader, VStack } from "alinea/ui"; import { Ellipsis } from "alinea/ui/Ellipsis"; import { IcOutlineRemoveRedEye } from "alinea/ui/icons/IcOutlineRemoveRedEye"; import { IcRoundPublishedWithChanges } from "alinea/ui/icons/IcRoundPublishedWithChanges"; import { Suspense } from "react"; // src/dashboard/view/entry/EntryHistory.module.scss var EntryHistory_module_default = { "root": "alinea-EntryHistory", "list": "alinea-EntryHistory-list", "list-revision": "alinea-EntryHistory-list-revision", "listRevision": "alinea-EntryHistory-list-revision", "is-selected": "alinea-EntryHistory-is-selected", "isSelected": "alinea-EntryHistory-is-selected" }; // src/dashboard/view/entry/EntryHistory.tsx import { jsx, jsxs } from "react/jsx-runtime"; var styles = dist_default(EntryHistory_module_default); function EntryHistory({ editor }) { return /* @__PURE__ */ jsx("header", { className: styles.root(), children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Loader, { absolute: true }), children: /* @__PURE__ */ jsx(RevisionList, { editor }) }) }); } function RevisionList({ editor }) { const revisions = useAtomValue(editor.revisionsAtom); return /* @__PURE__ */ jsx("ul", { className: styles.list(), children: revisions.map((revision, index) => { return /* @__PURE__ */ jsx( RevisionItem, { editor, revision, isCurrent: index === 0 }, revision.ref ); }) }); } function RevisionItem({ editor, revision, isCurrent }) { const date = new Date(revision.createdAt); const [previewRevision, setPreviewRevision] = useAtom(editor.previewRevision); return /* @__PURE__ */ jsx( "button", { type: "button", title: revision.description, className: styles.list.revision({ selected: previewRevision ? previewRevision.ref === revision.ref : isCurrent, current: isCurrent }), onClick: () => setPreviewRevision(isCurrent ? void 0 : revision), children: /* @__PURE__ */ jsxs(HStack, { center: true, gap: 10, children: [ isCurrent ? /* @__PURE__ */ jsx(Icon, { icon: IcOutlineRemoveRedEye, size: 18 }) : /* @__PURE__ */ jsx(Icon, { icon: IcRoundPublishedWithChanges, size: 18 }), /* @__PURE__ */ jsxs(VStack, { align: "flex-start", children: [ /* @__PURE__ */ jsx("b", { children: date.toLocaleDateString(void 0, { year: "numeric", month: "long", day: "numeric" }) }), /* @__PURE__ */ jsx(Ellipsis, { children: revision.user?.name }) ] }) ] }) }, revision.ref ); } export { EntryHistory };