658dfbb7d9
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.
104 lines
3.1 KiB
Vue
104 lines
3.1 KiB
Vue
<script setup lang="ts">
|
|
import { ref, watch } from "vue";
|
|
import {
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableColumn,
|
|
TableColumnResizer,
|
|
TableContent,
|
|
TableHeader,
|
|
TableRow,
|
|
TableResizableContainer,
|
|
TableScrollContainer,
|
|
TableSortableColumnHeader,
|
|
} from "@heroui-vue/components";
|
|
|
|
/**
|
|
* HD-08 column width verification harness: managed `fr` widths share the
|
|
* remaining space by weight next to fixed/percent columns, min/max clamp the
|
|
* shares, container resizing re-shares, dragging freezes the touched column
|
|
* and RTL keeps geometry (only drag direction flips).
|
|
*/
|
|
const widths = [620, 900, 1400];
|
|
const hostWidth = ref(900);
|
|
const rtl = ref(false);
|
|
const dark = ref(false);
|
|
watch(
|
|
dark,
|
|
(value) => {
|
|
document.documentElement.dataset.theme = value ? "dark" : "light";
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
const rows = [
|
|
{ id: "1", email: "kate@acme.com", name: "Kate Moore", role: "首席执行官" },
|
|
{ id: "2", email: "john@acme.com", name: "John Smith", role: "首席技术官" },
|
|
{ id: "3", email: "sara@acme.com", name: "Sara Johnson", role: "首席营销官" },
|
|
];
|
|
</script>
|
|
|
|
<template>
|
|
<main style="padding: 24px; display: grid; gap: 16px">
|
|
<div style="display: flex; gap: 16px">
|
|
<label>
|
|
容器宽度
|
|
<select v-model.number="hostWidth">
|
|
<option v-for="width in widths" :key="width" :value="width">
|
|
{{ width }}px
|
|
</option>
|
|
</select>
|
|
</label>
|
|
<label>
|
|
<input v-model="rtl" type="checkbox" />
|
|
RTL
|
|
</label>
|
|
<label>
|
|
<input v-model="dark" type="checkbox" />
|
|
深色主题
|
|
</label>
|
|
</div>
|
|
<div
|
|
id="table-host"
|
|
:dir="rtl ? 'rtl' : 'ltr'"
|
|
:style="{ width: `${hostWidth}px` }"
|
|
>
|
|
<Table>
|
|
<TableResizableContainer>
|
|
<TableScrollContainer>
|
|
<TableContent aria-label="列宽验证表格">
|
|
<TableHeader>
|
|
<TableColumn
|
|
id="name"
|
|
allows-sorting
|
|
default-width="1fr"
|
|
:min-width="120"
|
|
>
|
|
<TableSortableColumnHeader>姓名</TableSortableColumnHeader>
|
|
<TableColumnResizer />
|
|
</TableColumn>
|
|
<TableColumn id="role" default-width="2fr" :min-width="100">
|
|
角色
|
|
<TableColumnResizer />
|
|
</TableColumn>
|
|
<TableColumn id="status" :width="180">状态</TableColumn>
|
|
<TableColumn id="email" width="20%" :max-width="240">
|
|
邮箱
|
|
</TableColumn>
|
|
</TableHeader>
|
|
<TableBody>
|
|
<TableRow v-for="row in rows" :key="row.id" :row-key="row.id">
|
|
<TableCell>{{ row.name }}</TableCell>
|
|
<TableCell>{{ row.role }}</TableCell>
|
|
<TableCell>在职</TableCell>
|
|
<TableCell>{{ row.email }}</TableCell>
|
|
</TableRow>
|
|
</TableBody>
|
|
</TableContent>
|
|
</TableScrollContainer>
|
|
</TableResizableContainer>
|
|
</Table>
|
|
</div>
|
|
</main>
|
|
</template>
|