iter(g71): 数据表表头补 aria-sort 三态播报

This commit is contained in:
HIsheR
2026-10-26 12:40:24 +08:00
parent 532dcbb84f
commit a6d0692e15
4 changed files with 17 additions and 6 deletions
+10 -2
View File
@@ -102,8 +102,8 @@ export function dataTable<T extends { id: RowKey }>(props: DataTableProps<T>): H
},
);
const th = (col: (typeof props.columns)[number]) =>
h(
const th = (col: (typeof props.columns)[number]) => {
const el = h(
'th',
{
class: `${col.sortable ? 'ua-sortable' : ''}${col.align ? ` ua-align-${col.align}` : ''}`.trim(),
@@ -112,6 +112,14 @@ export function dataTable<T extends { id: RowKey }>(props: DataTableProps<T>): H
col.header ?? col.key,
col.sortable ? sortMark(col.key) : null,
);
if (col.sortable) {
effect(() => {
const rule = state().sorting.find((r) => r.key === col.key); // 与视觉箭头同源
el.setAttribute('aria-sort', rule ? (rule.dir === 'asc' ? 'ascending' : 'descending') : 'none');
});
}
return el;
};
/*** 骨架行:列宽与表头对齐,行数取当前每页条数(上限 6 行防过长) ***/
const skeletonRows = (): Node[] => {