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:
maoyingjie
2026-10-29 10:59:24 +08:00
parent aac93db658
commit 658dfbb7d9
14 changed files with 629 additions and 34 deletions
@@ -42,7 +42,16 @@ export default defineComponent({
([node, id, isRowHeader]) => {
if (!ctx?.columns) return;
const next = new Map(ctx.columns.value);
if (node) next.set(token, { node, id, isRowHeader });
if (node)
next.set(token, {
node,
id,
isRowHeader,
widthSpec,
applyWidth: (px: number | undefined) => {
resolvedWidth.value = px;
},
});
else next.delete(token);
ctx.columns.value = next;
},
@@ -59,6 +68,8 @@ export default defineComponent({
const width = computed(() =>
props.width !== undefined ? props.width : internalWidth.value,
);
/** Pixel width resolved by the managed (fr) layout; unset stays native. */
const resolvedWidth = ref<number | undefined>(undefined);
const setWidth = (next: number) => {
if (props.width === undefined) internalWidth.value = next;
emit("update:width", next);
@@ -69,6 +80,11 @@ export default defineComponent({
width,
setWidth,
});
const widthSpec = () => ({
width: width.value,
minWidth: props.minWidth,
maxWidth: props.maxWidth,
});
const cssWidth = (value: string | number | undefined) => {
if (value === undefined) return undefined;
if (typeof value === "number") return `${value}px`;
@@ -97,7 +113,10 @@ export default defineComponent({
ref: element,
class: [ctx?.slots.value.column(), attrs.class],
style: {
width: cssWidth(width.value),
width:
resolvedWidth.value !== undefined
? `${resolvedWidth.value}px`
: cssWidth(width.value),
minWidth: cssWidth(
typeof width.value === "number"
? Math.max(props.minWidth ?? 0, width.value)