0de9b6e66e
- core/table-core: Headless 表格内核(排序/筛选/分页/选择插件 + 冒烟 9 项) - core/frame: signal/computed/effect + hyperscript 微框架(零依赖) - skin/ui: 16 个 DOM 组件(含自绘 select、滑动指示条 tabs、行选择 dataTable、form 表单校验) - design/tokens: --ua-* 设计令牌(light/dark) - tools/cli: ua 命令行(index/list/info/docs/style/mcp)+ MCP 注册表服务 - apps: demo 演示站(esbuild 单文件)+ docs 双轨文档(人类版 + llms-full.txt)
46 lines
2.4 KiB
JSON
46 lines
2.4 KiB
JSON
{
|
||
"name": "@ui-arch/table-core",
|
||
"type": "headless-core",
|
||
"description": "Headless table state machine: immutable state, dispatch/reducer, composable derive pipeline (filter -> sort -> paginate) with per-stage memoization. No DOM, no framework dependency.",
|
||
"tags": [
|
||
"table",
|
||
"headless",
|
||
"state-machine",
|
||
"datagrid"
|
||
],
|
||
"api": {
|
||
"entry": "src/index.ts",
|
||
"exports": [
|
||
"createTable(options) -> TableInstance: create headless table instance",
|
||
"sortPlugin(options?) -> multi-column sorting plugin (asc -> desc -> off cycle)",
|
||
"filterPlugin(options?) -> column filter plugin (default substring match, custom predicate supported)",
|
||
"paginationPlugin() -> client-side pagination with page clamping, exposes setPage/nextPage/prevPage/getPageInfo",
|
||
"selectionPlugin() -> rowKey-based selection, exposes selectAllVisible"
|
||
],
|
||
"keyTypes": [
|
||
"ColumnDef",
|
||
"TableState",
|
||
"TablePlugin",
|
||
"RowModel",
|
||
"Action"
|
||
]
|
||
},
|
||
"usage": "const table = createTable({ data, columns, rowKey: 'id', plugins: [filterPlugin(), sortPlugin(), paginationPlugin()], initialState: { pagination: { page: 1, pageSize: 20 } } }); table.dispatch({ type: 'toggleSort', key: 'name' }); table.getVisibleRows()",
|
||
"conventions": [
|
||
"selection/expanded must store rowKey, never row index",
|
||
"derive pipeline order is fixed: filter -> sort -> paginate",
|
||
"actions are the only way to mutate state; state is immutable"
|
||
],
|
||
"docs": {
|
||
"intro": "Headless 表格内核:不渲染任何 DOM,只管理状态与派生。任何渲染层通过 getVisibleRows() 拿行模型,配 subscribe() 刷新。",
|
||
"steps": [
|
||
"创建实例:const table = createTable({ data, columns, rowKey: 'id', plugins: [filterPlugin(), sortPlugin(), paginationPlugin()] })",
|
||
"取派生数据:table.getVisibleRows() 返回 { rows, total };total 语义固定 = 筛选后、分页前的行数",
|
||
"变更状态:只能 dispatch action,如 table.dispatch({ type: 'toggleSort', key: 'name' });状态不可变",
|
||
"订阅刷新:table.subscribe(fn),fn 里重新 getVisibleRows() 并交给渲染层",
|
||
"分页信息:api.getPageInfo() 返回 { page, pageSize, totalPages };越界页码自动钳制",
|
||
"扩展能力:实现 TablePlugin(derive / patchState / api 三钩子)传入 plugins 即插入管线"
|
||
]
|
||
}
|
||
}
|