Files
UI/packages/core/table-core/ua.manifest.json
T

46 lines
2.4 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"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 / settle / api 四钩子)传入 plugins 即插入管线"
]
}
}