跳到正文
简体中文

用法

import { DashboardTable } from './DashboardTable.jsx'

// Without rows the table shows its sample bakery orders. Your own records, statuses and moves:
<DashboardTable
  locale="en"
  rows={brews.list}   // [{ id, number, name, items: [string | { qty, name }], time, status, total }]
  statuses={[
    { id: 'resting', label: 'Resting', tone: 'progress', pulse: true },
    { id: 'tasted', label: 'Tasted', tone: 'success', icon: 'check' },
    { id: 'binned', label: 'Binned', tone: 'danger', void: true },
  ]}
  actions={[{ id: 'taste', label: 'Mark tasted', from: 'resting', to: 'tasted', icon: 'check' }]}
  columns={{ order: 'Brew', items: 'Recipe', time: 'Brewed', total: 'Score' }}
  format="number"
  labels={{ title: 'Brews this week', search: 'Search brews', searchPlaceholder: 'Bean, number or method' }}
  loading={brews.loading}
  error={brews.error}
  onRetry={brews.reload}
  onStatusChange={async (ids, status) => await brews.move(ids, status)}
/>

属性

属性类型默认值作用
locale'en' | 'zh-CN' | 'es' | 'ja''en'内置文字、示例订单以及时间和金额格式所用的语言。
rowsArray<{ id, number, name, items: Array<string | { qty, name }>, time, status, total }>sample orders记录列表。`time` 为当天零点起的分钟数或你自己的文字;`status` 是 `statuses` 里某个状态的 id。`customer`、`pickup` 是 `name`、`time` 的旧名。传入新数组会替换整张表。
statusesArray<{ id, label, tone: 'progress' | 'success' | 'warning' | 'danger' | 'neutral', pulse?, icon?, void? }>baking, ready, collected, cancelled按标签页顺序排列的状态。`pulse` 让标签呼吸闪动,`icon` 是 kit 图标,`void` 让金额变灰且该行不能选中。
actionsArray<{ id, label, from: string | string[], to, icon? }>Mark ready, Mark collected多选栏里的按钮。每个按钮把选中行里状态属于 `from` 的移到 `to`;第一个是主按钮。传空数组则不显示按钮。
columns{ order?, items?, time?, status?, total?: string | false } | Array<{ key, title, render(row), align? }>—传对象可重命名内置列(false 隐藏商品、时间或金额列);传数组则换成你自己的列。
format'currency' | 'number' | 'percent' | 'duration' | (value) => string'currency'金额列的写法:按 `currency` 的金额、普通数字、百分比、以秒计的时长,或你自己的函数。
currencystringby locale金额使用的 ISO 货币代码。
onStatusChange(ids, status) => Promise<void | false>—用 `actions` 中的某个操作推进所选行(示例里:烘焙中→待取货,待取货→已取货)。返回 false 则保持原状。
loadingbooleanfalse显示表格的骨架。
error / onRetryboolean | string / () => voidfalse显示带重试按钮的错误提示;传字符串可替换说明。
labelsobject—替换任意内置文字(键名见 copy.js),包括状态名称。

装进你的项目

把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。

DashboardTable.jsxdashboard-table.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/status-tag/ui/alert-banner/ui/text-input/ui/skeleton-shimmer/ui/sliding-tabs/ui/select-table/tokens.cssREADME.md

区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。