DimensionPicker
- Status
- Implemented
- Family
- 9 of 13
- Registry
- @lopifi/dimension-picker
npx shadcn@latest add @lopifi/theme @lopifi/dimension-pickerThe component, rendering
Real data, the shipped component. Switch the theme to check the claims the spec makes below.
The four-layer spec
Entity, department, location, class, project, customer, vendor. Entity always required and always visible. Renders only the dimensions the chosen account requires.
Lifted verbatim from Accounting core (GL). 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/dimension-picker.tsx
- Lopifi dependencies · 3
- accounting.typescnmoney.types
- npm packages
- clsxtailwind-merge
- Registry entry
- /r/dimension-picker.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 * as React from "react";
import type { DimensionKey } from "@/lib/ledger/accounting.types";
import { cn } from "@/lib/ledger/cn";
const LABELS: Record<DimensionKey, string> = {
classId: "Class",
customerId: "Customer",
departmentId: "Department",
entityId: "Entity",
locationId: "Location",
productId: "Product",
projectId: "Project",
vendorId: "Vendor",
};
const OPTIONS: Record<DimensionKey, string[]> = {
classId: ["Core", "New product"],
customerId: ["Contoso", "Fabrikam", "Tailspin"],
departmentId: ["G&A", "Engineering", "Sales", "Marketing"],
entityId: ["Northwind Ltd", "Northwind GmbH", "Northwind Inc"],
locationId: ["London", "Berlin", "New York"],
productId: ["Platform", "Services"],
projectId: ["Atlas", "Beacon"],
vendorId: ["Baker & Co", "Vertex Cloud", "Meridian Legal"],
};
export interface DimensionPickerProps {
className?: string;
onValueChange: (value: Partial<Record<DimensionKey, string>>) => void;
/** Rendered from what the chosen account demands, not a global list. */
required: DimensionKey[];
value: Partial<Record<DimensionKey, string>>;
}
/** Entity is always required and always visible. */
export function DimensionPicker({ required, value, onValueChange, className }: DimensionPickerProps) {
const keys = React.useMemo(() => {
const set = new Set<DimensionKey>(["entityId", ...required]);
return [...set];
}, [required]);
return (
<div className={cn("flex flex-wrap gap-1", className)}>
{keys.map((key) => {
const missing = !value[key];
return (
<label className="block" key={key}>
<span className="sr-only">{LABELS[key]}</span>
<select
aria-invalid={missing}
className={cn(
"h-8 rounded-sm border bg-surface px-2 text-caption outline-none focus-visible:border-accent focus-visible:ring-2 focus-visible:ring-accent-subtle",
missing ? "border-negative text-text-tertiary" : "border-border",
)}
onChange={(e) => onValueChange({ ...value, [key]: e.target.value || undefined })}
value={value[key] ?? ""}
>
<option value="">{LABELS[key]}…</option>
{OPTIONS[key].map((o) => (
<option key={o} value={o}>
{o}
</option>
))}
</select>
</label>
);
})}
</div>
);
}
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 Accounting core (GL)
- JournalEntryDebit and credit as two columns. No signed-column variant.
- JournalEntryFormLine grid with live balance check and dimension capture.
- JournalEntryTableAll entries, with the gapless-numbering check.
- AccountPickerShows the normal balance. Blocks non-postable accounts.
- ChartOfAccountsHierarchy, statement mapping, unsupported-account flags.
- AccountRegisterGL detail with a running balance.
- AdjustingEntryFormTemplated by type. Auto-reverse defaults on for accruals.
- RecurringEntryTemplateTemplate editable; instances read-only.
- EntryReversalDialogHold-to-confirm. Never a delete.
- ScheduleTableOne shell, seven presets. Prepaids through debt.
- RollForwardOpening → movements → closing → tie. The universal shape.
- AccountTieOutEvery BS account, proven against its evidence.
- SchedulePreviewWhat the schedules will post, before they post.
- RevenueWaterfallDeferred balance recognizing by future period.
- DepreciationScheduleBook and tax in parallel. In-service date, not purchase date.
- LeaseScheduleROU asset and liability on diverging curves.
- AllowanceRollForwardWith the methodology shown, not just the number.
See also
A component is specified in one place, defined in another, and running in a third. All three, from here.
- Accounting core (GL) — the family specThe four-layer specification this component was built against, before it was written.Doc
- General ledger and accounting coreThe family running, with real figures in it, in both themes and at every density.Live
- CatalogAll 179 components, specified before they are written.Doc
- AccountA GL account in the chart of accounts. Always qualify when a bank account is meant.Term
Elsewhere in the system
Where DimensionPicker 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.
- DimensionPicker, runningThe gl 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
- Accounting core (GL)The general ledger layer. Specs for 18 React components: JournalEntry, JournalEntryForm, JournalEntryTable, AccountPicker and 14 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 Accounting core (GL) 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.