fix(table): full-width empty state, sort focus ring and fr column widths
HD-08 scope, against heroui ce90ea3 table sources and their
react-aria/react-stately dependencies:
- TableBody empty state now spans every real leaf column by default
(self-registered TableColumns — selection and wrapper-rendered ones
included — reactively following column changes), explicit colspan
still wins, and the vnode-level empty detection keeps avoiding
unknown-component setup/render probing
- sorting keeps one activation per click/Enter/Space (single sort path
via the column) while the baseline focus ring returns: the trigger
button keeps keyboard focus and forwards its real :focus-visible
state to the th's existing [data-focus-visible] hook, so the inset
ring lands on the column header like the pinned source and the UA
outline is suppressed only inside a column; aria-sort="none" on
sortable unsorted columns matches useTableColumnHeader and stays
- defaultWidth="Nfr" distributes the remaining width by weight
instead of silently becoming auto: widths.ts ports react-stately's
calculateColumnSizes (static px/% first, fr flex-grow sharing,
min/max violation freezing, cascade rounding); fr mode locks
table-layout: fixed for exact geometry, re-shares on container
resize, freezes dragged columns to their pixel width and keeps
geometry (with flipped drag direction) in RTL; unmeasured
environments keep native widths
- .table__cell's text-start/font-normal verified to block caller
inheritance and narrowed to th.hv-table__cell { inherit }, keeping
the baseline td row-header typography while ancestor align/weight
cascade into cells again; th scope=row, corner selectors and the
resizer z-index fix are untouched
- tests/fixtures/table-layout.vue (playground) drives the real-browser
geometry/drag/RTL/theme verification; m35-m36 contract pins the two
new CSS markers in the final tarball
Full suite 111 files / 1657 tests, typecheck, build:docs and the
m35-m36 + handbook-styles tarball contracts pass.
This commit is contained in:
@@ -60,6 +60,8 @@ import {
|
||||
|
||||
在 `TableColumn` 上使用 `allows-sorting` 属性可启用列排序。在 `TableContent` 上使用 `sort-descriptor` 与 `update:sort-descriptor` 管理排序状态。将标签包裹在 `TableSortableColumnHeader` 中,并传入列的 `sort-direction` 以渲染默认升序/降序指示器。
|
||||
|
||||
列头是唯一的排序入口:点击、Enter、Space 各触发一次排序(`TableSortableColumnHeader` 的触发按钮承担键盘焦点,点击经冒泡汇入列的单一排序路径)。焦点环显示在列头 `th` 上(基线位置):触发按钮把真实 `:focus-visible` 状态转发到 `th` 的 `[data-focus-visible]` 钩子,按钮自身的 UA 轮廓在列内被抑制。
|
||||
|
||||
<ComponentPreview name="table-sorting" minHeight="380px" />
|
||||
|
||||
### 选择
|
||||
@@ -82,7 +84,7 @@ import {
|
||||
|
||||
### 列宽调整
|
||||
|
||||
将表格包裹在 `TableResizableContainer` 中,并在每个可调整宽度的列内添加 `TableColumnResizer`。列可用 `default-width="1fr"` 表示弹性初始宽度(映射为原生 `width: auto`,共享剩余空间;不实现 RAC 的 fr 权重比例)。
|
||||
将表格包裹在 `TableResizableContainer` 中,并在每个可调整宽度的列内添加 `TableColumnResizer`。列可用 `default-width="Nfr"` 表示按权重分配剩余宽度(与固定源一致):数字为 px、`N%` 为百分比,`Nfr` 列共享扣除固定/百分比列后的剩余宽度并按权重比例分配;未显式设置宽度的列在存在 `fr` 列时按 `1fr` 参与分配。`min-width` / `max-width` 对每列份额生效(超出时按 flex 语义冻结违规列并把余量再分配),容器缩放会重新分配、拖动后的列冻结为其像素宽度,RTL 下几何一致、拖动方向相反。
|
||||
|
||||
<ComponentPreview name="table-column-resizing" minHeight="420px" />
|
||||
|
||||
@@ -223,25 +225,25 @@ Table 同时支持 CSS 伪类与 data 属性,以提供更灵活的状态控制
|
||||
|
||||
### TableColumn
|
||||
|
||||
| Prop / 事件 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------------- | ------------------ | ------- | --------------------------------------------------------------------- |
|
||||
| `as` | `string` | `'th'` | 列头标签,scope=col |
|
||||
| `id` | `string` | — | 排序与树形列 id |
|
||||
| `allowsSorting` / `isRowHeader` | `boolean` | `false` | 排序列 / 对应正文单元格为 th[scope=row] |
|
||||
| `width` / `defaultWidth` | `number \| string` | — | 受控宽度 / 非受控初始宽度;数字为 px,`Nfr` 为弹性 auto(非权重比例) |
|
||||
| `minWidth` / `maxWidth` | `number` | — | 宽度上下限,优先于 Resizer 的缺省边界 |
|
||||
| `update:width` | `number` | — | 拖动/键盘提出的宽度,可使用 v-model:width |
|
||||
| 默认插槽 | 内容 | — | 列标签及排序、调整手柄 |
|
||||
| Prop / 事件 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------------- | ------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| `as` | `string` | `'th'` | 列头标签,scope=col |
|
||||
| `id` | `string` | — | 排序与树形列 id |
|
||||
| `allowsSorting` / `isRowHeader` | `boolean` | `false` | 排序列 / 对应正文单元格为 th[scope=row] |
|
||||
| `width` / `defaultWidth` | `number \| string` | — | 受控宽度 / 非受控初始宽度;数字为 px,`N%` 为百分比,`Nfr` 按权重分配剩余宽度(存在 fr 列时未设宽度的列按 `1fr` 参与) |
|
||||
| `minWidth` / `maxWidth` | `number` | — | 宽度上下限,优先于 Resizer 的缺省边界 |
|
||||
| `update:width` | `number` | — | 拖动/键盘提出的宽度,可使用 v-model:width |
|
||||
| 默认插槽 | 内容 | — | 列标签及排序、调整手柄 |
|
||||
|
||||
### TableBody
|
||||
|
||||
| Prop / 插槽 | 类型 | 默认值 | 描述 |
|
||||
| ----------- | ------------------ | --------- | --------------------------------------------------------------------------- |
|
||||
| `as` | `string` | `'tbody'` | 正文根 |
|
||||
| `empty` | `boolean` | 自动判断 | 为 `true` 时强制空状态;省略时若默认插槽未渲染任何行则视为空 |
|
||||
| `colspan` | `number \| string` | `1` | 空状态单元格跨列数 |
|
||||
| 默认插槽 | 行内容 | — | 动态行使用 v-for |
|
||||
| `#empty` | 空状态 | — | 空数据时渲染;包在 `role="presentation"` 行内,不参与选择、行计数与键盘导航 |
|
||||
| Prop / 插槽 | 类型 | 默认值 | 描述 |
|
||||
| ----------- | ------------------ | -------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| `as` | `string` | `'tbody'` | 正文根 |
|
||||
| `empty` | `boolean` | 自动判断 | 为 `true` 时强制空状态;省略时若默认插槽未渲染任何行则视为空 |
|
||||
| `colspan` | `number \| string` | 自动(实际叶子列数) | 空状态单元格跨列数;缺省跨全部实际叶子列(含选择列与包装渲染的列,随列增减更新),显式值优先 |
|
||||
| 默认插槽 | 行内容 | — | 动态行使用 v-for |
|
||||
| `#empty` | 空状态 | — | 空数据时渲染;包在 `role="presentation"` 行内,不参与选择、行计数与键盘导航 |
|
||||
|
||||
### TableRow
|
||||
|
||||
|
||||
Reference in New Issue
Block a user