import type { ReactNode } from 'react'
/** Wireframe kit: structure-first components shared by POS and back office. */
export function PageHeader(props: { title: string; desc?: string; badge?: string; actions?: ReactNode }) {
return (
<>
{props.title}
{props.badge !== undefined &&
{props.badge}}
{props.actions}
{props.desc !== undefined && {props.desc}
}
>
)
}
export function Toolbar(props: { children: ReactNode }) {
return {props.children}
}
export function Button(props: {
children: ReactNode
onClick?: () => void
tone?: 'default' | 'primary' | 'danger'
hotkey?: string
}) {
const cls = `wf${props.tone === 'primary' ? ' primary' : props.tone === 'danger' ? ' danger' : ''}`
return (
)
}
export function Badge(props: { children: ReactNode; tone?: 'ok' | 'warn' | 'err' | 'accent' }) {
return {props.children}
}
export interface Column {
key: string
label: string
numeric?: boolean
}
export function DataTable(props: {
columns: Column[]
rows: Record[]
onRowClick?: (row: Record, index: number) => void
}) {
return (
{props.columns.map((c) => (
| {c.label} |
))}
{props.rows.map((row, i) => (
props.onRowClick?.(row, i)} style={props.onRowClick !== undefined ? { cursor: 'pointer' } : undefined}>
{props.columns.map((c) => (
| {row[c.key]} |
))}
))}
)
}
export function StatCard(props: { label: string; value: ReactNode; hint?: string }) {
return (
{props.label}
{props.value}
{props.hint !== undefined &&
{props.hint}
}
)
}
export function Stats(props: { children: ReactNode }) {
return {props.children}
}
export function EmptyState(props: { children: ReactNode }) {
return {props.children}
}
export function Field(props: { label: string; children: ReactNode }) {
return (
{props.children}
)
}
export function Modal(props: { title: string; onClose: () => void; children: ReactNode }) {
return (
e.stopPropagation()}>
{props.title}
{props.children}
)
}
export function Notice(props: { tone?: 'ok' | 'warn' | 'err'; children: ReactNode }) {
return {props.children}
}