iter(g71): 数据表表头补 aria-sort 三态播报
This commit is contained in:
@@ -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[] => {
|
||||
|
||||
Reference in New Issue
Block a user