DrilldownSheet
- Status
- Implemented
- Family
- 6 of 13
- Registry
- @lopifi/drilldown-sheet
npx shadcn@latest add @lopifi/theme @lopifi/drilldown-sheetThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Click a statement line → the GL entries behind it. Sheet on phone, side panel on desktop. The entries sum to the line, and the sum is displayed — that verification is the whole point of drilling down. Links onward to source documents.
Lifted verbatim from Statements. 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.
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 { cn } from "@/lib/ledger/cn";
import { formatDateShort } from "@/lib/ledger/fiscal-period";
import type { MoneyValue } from "@/lib/ledger/money.types";
import { ArrowTopRightOnSquareIcon, CheckIcon, ExclamationTriangleIcon } from "@/components/ledger/icons";
import { Money } from "@/components/ledger/money";
import { Reference } from "@/components/ledger/reference";
import { Rule } from "@/components/ledger/rule";
import { Sheet } from "@/components/ledger/sheet";
export type GlEntry = {
id: string;
date: Date;
journal: string;
account: string;
memo: string;
amount: MoneyValue;
sourceDocument?: string;
};
export interface DrilldownSheetProps {
entries: GlEntry[];
/** Passed in — the component doesn't sum. It compares. */
entriesTotal: MoneyValue;
lineLabel: string;
/** The statement line's value, as reported. */
lineValue: MoneyValue;
onOpenChange: (open: boolean) => void;
open: boolean;
/** The resolved period the figure was read from. Shown under the line
label rather than concatenated into it — one heading, not a slug. */
periodLabel?: string;
}
/**
* Statement line → the GL entries behind it. The entries sum to the line and
* the sum is displayed — that verification is the whole point of drilling
* down.
*
* Two columns, not four: the memo is what identifies an entry to a human, so
* it leads, and the date, journal, account and source document sit under it
* as one quiet provenance line. Everything else competing for the same
* horizontal space is what made this hard to read.
*/
export function DrilldownSheet({
open,
onOpenChange,
lineLabel,
periodLabel,
lineValue,
entries,
entriesTotal,
}: DrilldownSheetProps) {
const ties = Number(entriesTotal.amount) === Number(lineValue.amount);
const difference = Number(entriesTotal.amount) - Number(lineValue.amount);
return (
<Sheet
description={
periodLabel
? `${periodLabel} · ${entries.length} general ledger entries`
: `${entries.length} general ledger entries`
}
onOpenChange={onOpenChange}
open={open}
side="right"
title={lineLabel}
>
<table className="w-full">
<caption className="sr-only">Entries behind {lineLabel}</caption>
<thead>
<tr className="border-b border-border-subtle">
<th className="py-2 text-left text-label text-text-secondary" scope="col">
Entry
</th>
<th className="py-2 text-right text-label text-text-secondary" scope="col">
Amount
</th>
</tr>
</thead>
<tbody>
{entries.map((e) => (
<tr className="border-b border-border-subtle align-top" key={e.id}>
<th className="py-2.5 pr-4 text-left font-normal" scope="row">
<span className="block text-body">{e.memo}</span>
{/* Provenance, one line, tertiary: the reader scans memos
and amounts, and only reaches for this when an entry looks
wrong. */}
{/* Each separator travels with the item it precedes, so a
wrap at 480px never strands a "·" at the end of a line. */}
<span className="mt-0.5 flex flex-wrap items-center gap-x-1.5 text-caption text-text-tertiary">
<span className="numeric">{formatDateShort(e.date)}</span>
<span className="flex items-center gap-x-1.5 whitespace-nowrap">
<span aria-hidden="true">·</span>
{/* Not copyable here. A copy control per row is a button
every four lines, and hiding it until hover either
reserves the gap anyway or reflows the line under the
pointer. The entry opens from its source document. */}
<Reference copyable={false} truncate={false} value={e.journal} />
</span>
<span className="whitespace-nowrap">
<span aria-hidden="true" className="mr-1.5">
·
</span>
{e.account}
</span>
{e.sourceDocument ? (
<span className="whitespace-nowrap">
<span aria-hidden="true" className="mr-1.5">
·
</span>
<a
className="inline-flex items-center gap-1 align-middle text-accent hover:underline"
href="#source"
>
<ArrowTopRightOnSquareIcon aria-hidden="true" className="size-3" />
{e.sourceDocument}
</a>
</span>
) : null}
</span>
</th>
<td className="py-2.5 text-right">
<Money accounting value={e.amount} />
</td>
</tr>
))}
</tbody>
<tfoot>
<tr>
<td />
<td>
<Rule variant="subtotal" />
</td>
</tr>
<tr>
<th className="py-2 text-left text-label font-medium" scope="row">
Entries total
</th>
<td className="py-2 text-right">
<Money accounting size="md" value={entriesTotal} />
</td>
</tr>
<tr>
<th className="py-2 text-left text-label text-text-secondary" scope="row">
Statement line
</th>
<td className="py-2 text-right">
<Money accounting tone="secondary" value={lineValue} />
</td>
</tr>
</tfoot>
</table>
{/* When it ties this is a receipt, not an announcement — one quiet
line. When it does not, it is the most important thing on screen. */}
<p
className={cn(
"mt-4 flex items-center gap-2 text-body",
ties ? "text-text-secondary" : "rounded-sm bg-negative-subtle px-3 py-2 text-negative",
)}
role={ties ? undefined : "alert"}
>
{ties ? (
<CheckIcon aria-hidden="true" className="size-4 shrink-0 text-positive" />
) : (
<ExclamationTriangleIcon aria-hidden="true" className="size-4 shrink-0" />
)}
{ties ? (
"The entries sum to the statement line."
) : (
<>
The entries do not sum to the statement line — out by{" "}
<Money tone="inherit" value={{ amount: difference, currency: lineValue.currency }} />.
</>
)}
</p>
</Sheet>
);
}
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 Statements
- StatementTableThe shared shell: hierarchy, periods, rules.
- StatementRowIndent level, subtotal, total, expand.
- ProfitAndLossP&L with period comparison and variance.
- BalanceSheetAssets / liabilities / equity, with the balance check.
- CashFlowStatementOperating / investing / financing.
- StatementToolbarBasis, period, comparison, currency, consolidation.
- PeriodPickerFiscal-aware. Never assumes January.
- VarianceCellAbsolute + percent + significance flag.
- FluxAnalysisPeriod-over-period explanations.
- TrialBalanceAll accounts with the debit=credit proof.
- CloseChecklistTasks, owners, blockers, sign-off.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Statements — the family specThe four-layer specification this component was built against, before it was written.Doc
- Financial statement componentsThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- General ledgerThe complete set of accounts, holding every posted entryTerm
Elsewhere in the system
Where DrilldownSheet 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.
- DrilldownSheet, runningThe statements showcase — live, with theme, density, greyscale and reduced-motion switches.Live
- Dimensions and segmentsHow many ways can a company slice its profit and loss?API
- StatementsThe largest gap in the market. No component library ships a <BalanceSheet />. This family is the reason Lopifi exists. Specs for 12 React components: StatementTable, StatementRow, ProfitAndLoss, BalanceSheet and 8 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 Statements 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.