TransactionDetail
- Status
- Implemented
- Family
- 5 of 13
- Registry
- @lopifi/transaction-detail
npx shadcn@latest add @lopifi/theme @lopifi/transaction-detailThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
A sheet on phone, a side panel on desktop. Everything: full amounts, FX detail if converted, attachments, the categorization rule that fired, the full audit trail with actor and timestamp. Inline editing for category and memo, with optimistic update and rollback on failure.
Lifted verbatim from Ledger & tables. The doc and this page are the same paragraphs, so they cannot disagree.
What lands in your repository
One component is never one file. Everything below is copied into your project, where you own it.
- Files
components/ledger/transaction-detail.tsx
- Lopifi dependencies · 23
- clipboardcncolumn-headerentity-markfigurefiscal-periodformat-moneygroup-rowsiconsmoneymoney.typesreferencesheetstatus-pilltable-sorttooltiptransaction-cardtransaction-tableuse-column-priorityuse-column-widthsuse-densityuse-grid-navuse-table-sort
- npm packages
- @base-ui-components/react@tanstack/react-virtualclass-variance-authorityclsxtailwind-mergevaul
- Registry entry
- /r/transaction-detail.json
The whole component
No compiled bundle, no black box. This is the file the registry copies, and the file you will edit.
"use client";
import type * as React from "react";
import { formatDate, formatTimestamp } from "@/lib/ledger/fiscal-period";
import { Figure } from "@/components/ledger/figure";
import { Reference } from "@/components/ledger/reference";
import { Sheet } from "@/components/ledger/sheet";
import { StatusPill } from "@/components/ledger/status-pill";
import type { Transaction } from "@/components/ledger/transaction-table";
export type AuditEvent = {
at: Date;
actor: string;
role: string;
action: string;
onBehalfOf?: string;
};
export interface TransactionDetailProps {
attachments?: { name: string; size: string }[];
auditTrail?: AuditEvent[];
/** The rule that fired, if any — shown, because it is editable context. */
categorizationRule?: string;
onOpenChange: (open: boolean) => void;
open: boolean;
transaction: Transaction | null;
}
/**
* A sheet on phone, a side panel on desktop. Everything: full amounts, the
* rule that fired, the attachments, and the full audit trail with actor,
* role and timestamp.
*/
export function TransactionDetail({
transaction: t,
open,
onOpenChange,
auditTrail = [],
categorizationRule,
attachments = [],
}: TransactionDetailProps) {
if (!t) return null;
return (
<Sheet
description={formatDate(t.date)}
onOpenChange={onOpenChange}
open={open}
side="right"
title={t.description}
>
<div className="space-y-6">
<div>
<Figure colorBySign size="lg" value={t.amount} />
<div className="mt-2">
<StatusPill entity="Transaction" status={t.status} />
</div>
</div>
<dl className="space-y-2">
<Row label="Account">
{t.account} <span className="reference-numeric">•••• {t.accountLast4}</span>
</Row>
<Row label="Category">{t.category}</Row>
<Row label="Reference">
<Reference truncate={false} value={t.reference} />
</Row>
{t.memo ? <Row label="Memo">{t.memo}</Row> : null}
{t.createdBy ? <Row label="Created by">{t.createdBy}</Row> : null}
</dl>
{categorizationRule ? (
<section>
<h3 className="text-label font-medium text-text-secondary">Categorization rule</h3>
<p className="mt-1 rounded-sm bg-surface-sunken p-3 text-body">{categorizationRule}</p>
</section>
) : null}
{attachments.length > 0 ? (
<section>
<h3 className="text-label font-medium text-text-secondary">Attachments</h3>
<ul className="mt-2 space-y-1">
{attachments.map((a) => (
<li
className="flex items-center justify-between rounded-sm border border-border px-3 py-2 text-body"
key={a.name}
>
<span className="truncate">{a.name}</span>
<span className="numeric text-caption text-text-tertiary">{a.size}</span>
</li>
))}
</ul>
</section>
) : null}
{auditTrail.length > 0 ? (
<section>
<h3 className="text-label font-medium text-text-secondary">Audit trail</h3>
<ol className="mt-2 space-y-3">
{auditTrail.map((e, i) => (
<li className="border-l-2 border-border pl-3" key={i}>
<p className="text-body">{e.action}</p>
<p className="text-caption text-text-secondary">
{e.actor} ({e.role}){e.onBehalfOf ? ` on behalf of ${e.onBehalfOf}` : ""}
</p>
<p className="numeric text-caption text-text-tertiary">{formatTimestamp(e.at)}</p>
</li>
))}
</ol>
</section>
) : null}
</div>
</Sheet>
);
}
function Row({ label, children }: { label: string; children: React.ReactNode }) {
return (
<div className="flex items-baseline justify-between gap-6 border-b border-border-subtle pb-2">
<dt className="text-body text-text-secondary">{label}</dt>
<dd className="text-right text-body">{children}</dd>
</div>
);
}
export { Money } from "@/components/ledger/money";
The accounting it encodes
Concepts this component renders. Each one is defined once, in the lexicon, and used identically in the code and the copy.
Also in Ledger & tables
- TransactionTableThe workhorse. Virtualized, sticky, priority-collapsing.
- TransactionRowDesktop row.Spec
- TransactionCardThe mobile re-rank.
- LedgerTableDouble-entry with debit/credit columns and a balance check.
- AgingTableAR/AP buckets, 0-30-60-90+.
- ReconciliationViewTwo-pane matcher. The match animation.
- CategoryPickerHierarchical with rule creation.
- FilterBarURL-param-backed filters with resolved-value chips.
- BulkActionBarSelection count + actions, safe-area aware.
- ColumnManagerShow/hide/reorder with drag.
- GroupPickerOne cut through a table, with subtotals per group.
- ExportMenuCSV/XLSX/PDF with a stated scope.
- TableColumnsSort and resize for a table that renders on the server.
- ColumnHeaderThe sortable, draggable header cell.
- PeriodGridThe ruled grid. Frozen panes, hidden columns, hover change, ⌘C.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Ledger & tables — the family specThe four-layer specification this component was built against, before it was written.Doc
- Ledger tables and transaction registersThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- Audit trailThe immutable record of every state changeTerm
Elsewhere in the system
Where TransactionDetail sits in the rest of the system — the live section it renders in, the calculators that compute what it displays, and the ledger payloads it is fed from.
- TransactionDetail, runningThe tables showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Ledger & tablesThe table is the product. It gets the same design investment as the hero card. Specs for 15 React components: TransactionTable, TransactionRow, TransactionCard, TransactionDetail and 11 more.Doc
Components are copied into your repository and meant to be edited — rounding policy, fiscal calendar and compliance copy differ per company.
Told when Ledger & tables changes
Components are copied into your repo, so a fix here does not reach you on its own. One email when a component in this family changes in a way that needs a migration — and nothing when it does not.