Skip to Content
UI

Domain

Larger building blocks: money amounts, CSV import, kanban, uploads, job runs, trend chip.

Usage

import { Amount } from "@dapplelight/signet-ui/domain/amount"

export function InvoiceTotal({ paise }: { paise: number }) {
  return <Amount value={paise} minorUnits tone="auto" />
}

These are not in the barrel import; import each from its own path.

API

ExportWhat it does
domain/amount: Amount, formatAmountMoney with locale grouping, sign and credit/debit tone.
domain/csv-import: CsvImportPaste or pick a CSV, map columns, validate rows, import.
domain/csv-import: autoMatch, validateRowsThe mapping and validation steps as functions.
domain/csv-import: parseCsv, toCsv, csvField, detectDelimiterCSV parsing and writing.
domain/csv-import: DEFAULT_CSV_IMPORT_LABELSEvery string in English; override per key.
domain/job-runs: JobRuns, JobRunTable of background job runs with retry and cancel.
domain/kanban: Kanban, KanbanColumn, KanbanColumnHeader, KanbanColumnTitle, KanbanList, KanbanItemBoard with drag and keyboard moves.
domain/kanban: moveItem, findItemPure board helpers.
domain/trend-chip: TrendChip+4.2% ↑ in green or red.
domain/upload: Upload, xhrUploadDrop or pick files, upload with progress and retry.
TypesAmountProps, AmountTone, AmountValue, AmountPart, CsvField, CsvSchema, CsvMapping, CsvRowResult, CsvImportReport, CsvImportLabels, CsvImportProps, JobRunsProps, KanbanBoard, KanbanMove, KanbanMessages, KanbanProps, KanbanColumnProps, KanbanItemProps, UploadTarget, UploadTransport

Amount

OptionTypeDefault
valuenumber | string | bigintrequiredUse a string or bigint for exact values.
currencystring"INR"ISO 4217 code.
localestring"en-IN"Indian locales group by lakh and crore.
minorUnitsbooleanfalsevalue is paise or cents.
notation"standard" | "whole" | "compact""standard"Compact gives ₹12.5L, ₹1.2Cr, $1.3M.
decimalsnumbercurrency's ownIn compact notation, the maximum (default 1).
tone"credit" | "debit" | "transfer" | "auto"noneUses the theme's money slots. auto picks credit or debit from the sign.
signDisplayIntl signDisplay"auto""exceptZero" with tone="auto".
classNamesPartial<Record<"sign" | "currency" | "integer" | "fraction" | "compact", string>>noneClass per part.
renderReactElementnoneReplaces the <data> element.

formatAmount(value, options) returns { parts, major, sign } so a table cell or chart label formats the same way. Tones read --money-credit, --money-debit, --money-transfer (see the finance.css theme), falling back to status colours.

CsvImport

OptionTypeDefault
fieldsCsvField[]required{ key, label?, aliases?, required? }.
onImport(rows: T[]) => Promise<CsvImportReport | undefined> | CsvImportReport | undefinedrequiredGets the valid rows. Return { inserted, skipped?, errors? } to show server errors per row.
schema{ safeParse } (zod works)noneWithout it, rows are the mapped strings.
delimiterstringdetectedSeparator.
previewRowsnumber100Rows in the review table.
maxBytesnumber10 MBLargest file read.
labelsPartial<CsvImportLabels>EnglishOverride any string.
classNamesper partnoneroot, title, source, mapping, review, table, cell, error, actions, status.

Upload

OptionTypeDefault
getTarget(file: File) => Promise<UploadTarget>requiredAsk your server for { url, method?, headers? }.
onUploaded(file, target) => void | Promise<void>noneConfirm the upload with your server.
acceptstring[]anyimage/png or image/*. A hint; the server enforces.
maxBytesnumbernoneA hint; the server enforces.
multiplebooleanfalse
labelstring"Drop a file here or choose one"
transportUploadTransportxhrUploadXHR PUT, for progress.

JobRuns

OptionTypeDefault
runsJobRun[]required{ id, job, state, attempt, error?, progress?, updatedAt? }.
onRetry(run) => voidnoneButton on dead runs.
onCancel(run) => voidnoneButton on runs not done, dead or cancelled.
emptyMessagestringnone

Kanban

OptionTypeDefault
value / defaultValueRecord<string, string[]>{}Column id to ordered item ids.
onValueChange(board) => voidnoneThe whole board after a drop.
onItemMove(move) => voidnone{ item, from, to, index }, for saving to a server.
messagesPartial<KanbanMessages>EnglishScreen reader text.

KanbanColumn takes value and optional label; KanbanItem takes value and optional label. Keyboard: Space or Enter picks up, arrows move, Space or Enter drops, Escape cancels.

Examples

Import customers from a CSV

import { CsvImport } from "@dapplelight/signet-ui/domain/csv-import"
import { z } from "zod"

const row = z.object({ name: z.string().min(1), email: z.string().email() })

export function ImportCustomers() {
  return (
    <CsvImport
      fields={[
        { key: "name", required: true },
        { key: "email", aliases: ["E-mail"], required: true },
      ]}
      schema={row}
      onImport={async (rows) => {
        const res = await fetch("/api/customers/import", { method: "POST", body: JSON.stringify(rows) })
        return res.json() // { inserted, skipped?, errors? }
      }}
    />
  )
}

Order board

import { Kanban, KanbanColumn, KanbanColumnHeader, KanbanColumnTitle, KanbanItem, KanbanList } from "@dapplelight/signet-ui/domain/kanban"

export function OrderBoard({ orders }: { orders: Record<string, { id: string; label: string }[]> }) {
  return (
    <Kanban
      aria-label="Orders"
      defaultValue={{ new: ["o1", "o2"], packed: ["o3"], shipped: [] }}
      onItemMove={(m) => fetch(`/api/orders/${m.item}`, { method: "PATCH", body: JSON.stringify({ status: m.to }) })}
    >
      {(board) =>
        Object.keys(board).map((col) => (
          <KanbanColumn key={col} value={col}>
            <KanbanColumnHeader>
              <KanbanColumnTitle>{col}</KanbanColumnTitle>
            </KanbanColumnHeader>
            <KanbanList>
              {board[col]?.map((id) => (
                <KanbanItem key={id} value={id}>
                  {id}
                </KanbanItem>
              ))}
            </KanbanList>
          </KanbanColumn>
        ))
      }
    </Kanban>
  )
}

Upload with a presigned URL

import { Upload } from "@dapplelight/signet-ui/domain/upload"

export function ReceiptUpload() {
  return (
    <Upload
      accept={["image/*", "application/pdf"]}
      maxBytes={5 * 1024 * 1024}
      getTarget={async (file) => {
        const res = await fetch("/api/uploads", { method: "POST", body: JSON.stringify({ name: file.name, type: file.type }) })
        return res.json() // { url, method?, headers? }
      }}
    />
  )
}

Trend chip

import { TrendChip } from "@dapplelight/signet-ui/domain/trend-chip"

<TrendChip value={4.2} /> // "+4.2% ↑" in green; negatives are red; NaN shows a dash