feat: migrate Tag, TagGroup and ErrorMessage with collection and focus contracts

Port the fixed HeroUI baseline tag/tag-group/error-message components onto the
existing collection selection/registry protocols instead of a second state model.

- TagGroup owns selection, disabled scope, removal requests and name/description
  wiring; TagGroupList renders the role=grid node and Tag renders role=row.
- Removal has one path: a press inside the remove subtree is a removal request,
  so custom remove buttons work without a second event source; focus follows the
  next neighbour only after the item is actually gone.
- ErrorMessage keeps the baseline slot marker and reuses the field part ids
  without gaining validation or aria-invalid semantics.
- Ship the 12 tag-group and 2 error-message previews, both doc pages, navigation,
  a 35-case behavioural suite and independent tarball consumption checks.
This commit is contained in:
maoyingjie
2026-10-25 10:45:43 +08:00
parent 3532cc6aad
commit af6bfda3ee
40 changed files with 3790 additions and 4 deletions
+3 -3
View File
@@ -34,7 +34,7 @@
| time-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| disclosure | 验证中(M21) | Disclosure/Heading/Trigger/Content/Body/Indicator;3/3 基线例;v-model:expanded;asChild 触发;高度动画映射测量变量 |
| disclosure-group | 验证中(M22) | DisclosureGroup + useDisclosureGroupNavigation;3/3 基线例;展开键为数组(string 或 number);单选替换/多选增量 |
| error-message | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| error-message | 已迁移(有已知差异) | ErrorMessage 单部件;2/2 基线例;复用字段错误 id 与样式变量,`slot="errorMessage"` 仅为 DOM 标记,不做校验也不改 aria-invalid;见 B03 报告 |
| kbd | 验证中(最小实现) | variant;KbdAbbr keyValue 映射与 title;KbdContent;上下文类名;导出 kbdKeysMap/LabelMap |
| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
| popover | 验证中(OVERLAY-02) | Root/Trigger/Content/Dialog/Heading/Arrow;6/6 基线例;逻辑定位/碰撞/退出/标题;模态 closeAutoFocus 不支持取消恢复,见 OVERLAY-02 |
@@ -48,8 +48,8 @@
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
| tabs | 验证中(M25) | 七部件、10/10 基线例;primary/secondary、方向/对齐、受控/键盘/禁用/滚动/指示器;Vue 模型与 ID/集合差异见报告 |
| tag | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| tag-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| tag | 已迁移(有已知差异) | Tag/TagRemoveButton;与 TagGroup 同页 12 例;textValue 决定文字与移除按钮名称 `Remove tag {文本}`;移除由行统一处理;见 B03 报告 |
| tag-group | 已迁移(有已知差异) | TagGroup/TagGroupList 两部件;role=grid/row、single/multiple、disabledKeys、移除与焦点恢复、aria-labelledby/describedby;12/12 基线例;见 B03 报告 |
| toggle-button-group | 验证中(M28) | ToggleButtonGroup/Separator;10/10 基线例;single/multiple、disallowEmptySelection、roving focus;Vue 数组模型替代 Set<Key> |
| toolbar | 验证中(M29) | Toolbar;5/5 基线例;isAttached/orientation/dir;跨组单 Tab 入口与方向键;子组焦点让位;Separator 垂直继承 |
| tooltip | 验证中(OVERLAY-02) | Root/Trigger/Content/Arrow;6/6 基线例;CSS 延迟/焦点/禁用/替换/定位;Provider warmup 与 RAC 全局调度不同 |
+176
View File
@@ -0,0 +1,176 @@
# B03 Tag / TagGroup / ErrorMessage 迁移报告
分支 `feat/b03-tag-error-message`,起点 `3532cc6`(本地 main,含 B01 合并 `836752d`、交接说明 `3532cc6`)。**未合 main、未推送**。独立 worktree `heroui-vue-b03`(`heroui-vue-b01` 当时有 5181 开发服务运行,未在其 checkout 切分支)。
固定基线 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`。开发端口 5183。
## 1. 源公开契约
### 源文件
- `packages/react/src/components/tag/tag.tsx`、`tag-group/tag-group.tsx`、`error-message/error-message.tsx`
- `packages/styles/components/{tag,tag-group,error-message}.css`
- `packages/styles/src/components/{tag,tag-group,error-message}/*.styles.ts`
- 中文正文:`apps/docs/content/docs/cn/react/components/(collections)/tag-group.mdx`、`(forms)/error-message.mdx`
- 演示:`apps/docs/src/demos/cn/tag-group`(12 例)、`demos/cn/error-message`(2 例)
- 行为证据(RAC 未安装、无法读源码,用上游测试代替):`packages/react/tests/components/{tag-group,tag,error-message}`
### 部件与公开能力
| 源部件 | 公开 Props / 事件 | 状态与状态标记 |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `TagGroup` | selectionMode、selectedKeys、defaultSelectedKeys、onSelectionChange、disabledKeys、isDisabled、onRemove、size、variant、className、children、render | 组级禁用、单选/多选、移除回调;`data-slot="tag-group"` |
| `TagGroup.List` | items、renderEmptyState、className、children、render | `role="grid"`、`aria-label`/`aria-labelledby`/`aria-describedby`、`aria-atomic`/`aria-relevant` |
| `Tag` | id、textValue、isDisabled、className、children(含 render props)、render | `role="row"`、`aria-selected`/`aria-disabled`、`data-selected`/`data-disabled`/`data-hovered`/`data-pressed`/`data-focus-visible` |
| `Tag.RemoveButton` | className、children | 默认渲染条件 `allowsRemoving`;可访问名称 `Remove tag {文本}`;点击不改变选择 |
| `ErrorMessage` | className、children | `<p class="error-message" slot="errorMessage" data-slot="error-message">`,仅展示、不校验 |
上游测试确认的契约:网格下有若干 `row`;`aria-label` 或 `Label` 命名网格;单选点击切换 `aria-selected`;`disabledKeys` 与 `isDisabled` 输出 `aria-disabled`;默认移除按钮存在时可访问名称为 `Remove tag News`;`Delete` 键移除当前聚焦标签并调用 `onRemove(Set)`;`size`/`variant` 在 `Tag` 上渲染为 `tag--lg`/`tag--surface`;自定义 `Tag.RemoveButton` 替换默认按钮。
### 预览清单(顺序与固定正文一致)
tag-group:basic、sizes、variants、disabled、selection-modes、controlled、with-error-message、with-list-data、with-prefix、with-remove-button、render-function、custom-styles(12)。
error-message:basic、custom-styles(2)。
## 2. 实现映射
| 层 | 实现 |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 状态 | 复用 `collection/selection`(`useCollectionSelection`)与 `collection/registry`,未修改内核 |
| 组件 | `TagGroup`(状态/注册/焦点/移除/名称关联)、`TagGroupList`(grid 节点)、`Tag`(row)、`TagRemoveButton`、`ErrorMessage` |
| 插槽 | 全部使用具名/作用域插槽:`Tag` 默认插槽提供 `TagRenderState`,`TagGroupList` 提供 `{ item, index }` 与 `empty` |
| 事件 | `update:modelValue`、`selectionChange`、`remove`(载荷为 `TagKey[]`,替代 React 的 `Set<Key>`) |
| 描述关联 | `TagGroup` 提供 `fieldContextKey`(kind=group),`Label`/`Description`/`ErrorMessage` 经 `useFieldPart` 注册;渲染期 id 规划保证首次渲染即可正确 `aria-labelledby`/`aria-describedby` |
| 样式 | 三个 CSS 文件按上游数值移植,仅加 `hv-` 前缀;tv 变体加入 `@heroui-vue/styles` |
| 底座差异 | 未使用 Reka 的集合组件(无对应 grid/row 语义),按本地 choice/collection 协议组合原生 DOM |
公开 API 摘要:
- `TagGroup`:`selection-mode`、`model-value`/`selected-keys`/`default-value`/`default-selected-keys`、`disabled-keys`、`is-disabled`、`disallow-empty-selection`、`size`、`variant`、`dir`、`as`、`as-child`;`@update:model-value`、`@selection-change`、`@remove`。
- `TagGroupList`:`items`(需 `id`)、`as`、`as-child`;默认插槽 `{ item, index }`、`empty` 插槽。
- `Tag`:`id`(必填)、`text-value`、`is-disabled`、`as`、`as-child`;作用域插槽状态 `isSelected`/`isDisabled`/`isHovered`/`isPressed`/`isFocused`/`isFocusVisible`/`allowsRemoving`。
- `TagRemoveButton`:`text-value`、`is-disabled`;默认插槽替换图标。
- `ErrorMessage`:无自有 Props(`id`/`class` 为普通属性),默认插槽为内容。
## 3. 命令与真实结果
| 命令 | 结果 |
| --------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `pnpm typecheck` | 通过 |
| `pnpm test` | **74 文件 / 973 项**通过(新增 `tests/tag-error-message.test.ts` 35 项);连跑两次一致 |
| `pnpm build:docs` | 退出码 0(含 SSG 预渲染) |
| `pnpm format` | 通过(提交前已仅对本批文件执行 `--write`) |
| `git diff --check` | 通过 |
| `node consume-b03-tag-error-message.mjs`(独立消费者) | 通过:11 项导出、SSR HTML 契约、8 类 CSS 选择器与 list 内边距规则 |
| `tsc --moduleResolution bundler` / `nodenext`(契约文件) | 两种模式均通过;4 个 `@ts-expect-error` 反例实际触发 |
独立消费目录 `/private/tmp/heroui-b03-consumer`:`pnpm pack` 两份 tarball + `pnpm-workspace.yaml` overrides(pnpm 11 写法),无源码 alias。
### 新增/修改文件
- 新增:`packages/styles/components/{tag,tag-group,error-message}.css`、`packages/vue/src/components/tag/*`、`packages/vue/src/components/error-message/ErrorMessage.vue`、`apps/docs/components/{tag-group,error-message}.md`、14 个 `apps/docs/demos/*.vue`、`tests/tag-error-message.test.ts`、`tests/package/{consume-b03-tag-error-message.mjs,b03-tag-error-message-contract.ts}`
- 增量修改:`packages/styles/index.css`(3 行 import)、`packages/styles/src/index.ts`(3 个 tv,追加)、`packages/vue/src/index.ts`(导出,追加)、`packages/vue/src/types.ts`(Props 类型,追加)、`apps/docs/.vitepress/theme/navigation.ts`(2 条)、`package.json`(test:unit 列表)
- 未改动:共享 collection/field/choice 内核、Toast/Table 文件、文档外壳样式、锁文件、`apps/docs/.vitepress/theme/style.css`
## 4. 浏览器重点证据
127.0.0.1:5183(strictPort),浅色 + 深色。
- 语义:`role="grid"` + `aria-label="标签"`;行 `role="row"`;`Label` 在组内渲染为 `span` 并成为 `aria-labelledby`;Description 与 ErrorMessage 的 id 同时进入 `aria-describedby`。
- 选择:点击 `资讯` 后 `aria-selected/data-selected` 同步,背景 `oklab(0.6204 -0.0543052 -0.187286 / 0.2)`(accent-soft),字体 12px、圆角 12px、内边距 4px 8px。
- 键盘:`ArrowRight` 资讯→旅行、`End`→购物、`Space` 选中购物并取消资讯(单选替换);`:focus-visible` 与 `data-focus-visible="true"` 同时成立,2px surface + 4px focus 双层焦点环。
- 移除:按钮 12×12,`::after` 命中区 24×24;点击后 `旅行` 消失,焦点落到 `游戏`。
- 尺寸/变体/禁用:sm 2px 8px、md 4px 8px、lg 6px 10px/14px/16px;surface 背景 `oklch(1 0 0)`;`isDisabled` 与 `disabledKeys` 均 `aria-disabled`/`data-disabled` + opacity 0.5;深色默认背景 `oklch(0.274 0.006 286.033)`。
- 文档:6 张正文表格均 728px(= 正文宽度)、`display: table`、`table-layout: fixed`、`scrollWidth === clientWidth`;侧栏顺序 EmptyState → ErrorMessage → FieldError、TagGroup 在 Tabs 与 TextArea 之间;ErrorMessage 页输出 `<p class="hv-error-message" slot="errorMessage">`。
## 5. 上游差异(逐项记录)
1. **部件命名**:`TagGroup.List` / `Tag.RemoveButton` → 具名导出 `TagGroupList` / `TagRemoveButton`(项目公共 API 约定)。
2. **render 函数**:React `render` 自定义 DOM 元素 → Vue `as`(标签名)与 `as-child`(唯一子元素)。render-function 示例用 `as="section"` 演示同一能力。
3. **`useListData`**:Vue 无对应公共 hook,with-list-data 示例改为响应式数组 + 计算 selected,保留数据驱动、移除、空状态与已选展示。
4. **数据驱动列表的 key**:`TagGroupList` 的 `items` 要求每项带 `id`(作用域插槽自行渲染 `Tag`,`:key` 由调用方给出),等价于 RAC 从渲染函数返回元素取 key。
5. **`FieldSlotsGate` / RAC `TextContext`**:该 gate 只为 RAC 集合的隐藏渲染趟次服务;Vue 端集合不存在隐藏趟次,改为字段上下文注册 + 渲染期 id 规划(`prepare`),首次渲染即写出正确 `aria-labelledby`/`aria-describedby`。未移植该 gate。
6. **`ErrorMessage` 的 `slot` 属性**:保留为普通 DOM 属性(CSS 钩子,样式表同时匹配 `[slot="errorMessage"]` 与 `[data-slot="error-message"]`),在 Vue 中写成 `slot="..."` 放在父组件上会被当作插槽分配,文档已提示直接放默认插槽。
7. **`ErrorMessage` 的 ARIA**:上游经 `TextContext` 提供节点但不设置 `aria-invalid`/`aria-errormessage`;本库把已渲染的 ErrorMessage id 并入所属组的 `aria-describedby`(增补项,未改变校验语义),并明确不覆盖 `FieldError`。
8. **移除按钮名称**:`Remove tag {标签文本}` 与固定基线测试字符串一致;自定义移除按钮由 `Tag` 克隆时注入 `text-value`,因此也能得到同样名称。
9. **移除事件载荷**:`onRemove(Set<Key>)` → `@remove(TagKey[])`。
10. **额外接受的能力**:`dir`、`disallowEmptySelection`、`as`/`as-child`。RAC 支持但基线文档表格未列;已写入本库 API 表。
11. **单选语义**:单击已选中标签会取消选择(RAC 默认 toggle 行为),`disallow-empty-selection` 可阻止清空。
12. **无表单值**:TagGroup 不生成隐藏 input、不参与 FormData,与基线一致。
## 6. 验证边界与未验证项
- 未做逐像素视觉对比;尺寸/配色以计算样式核对。
- 未做读屏软件实测;`aria-atomic="false"` + `aria-relevant="additions text"` 依据 RAC `useTagGroup` 的 TagList 属性,未在真实 AT 上复验播报。
- 未验证物理触屏、窄屏断点截图、RTL 视觉(RTL 仅由单测覆盖方向键翻转)。
- 截图:本轮首次截图成功(页面顶部),随后 IAB 合成器持续返回 `capture timed out`,因此后续证据全部改用计算样式与 DOM 查询;未以旧截图冒充新证据。
- 未建立自动 visual/浏览器测试入口(项目现状),浏览器结论来自本轮手工重点验证。
## 7. 共享缺口与需要注意的环境问题
**(重要)Vue 事件 invoker 的同毫秒跳过**:`@vue/runtime-dom` 的 `createInvoker` 在 `e._vts <= invoker.attached` 时直接返回,`invoker.attached` 来自按微任务缓存的 `Date.now()`。若在 `mount()` 后**同一毫秒内**同步 `dispatchEvent` 一个合成事件,监听器会被静默跳过,表现为「事件处理器有时不执行」,并且**同一个事件上后运行的处理器更容易被跳过**(先运行的处理器写入 `e._vts`)。本轮一开始把它误判为 CloseButton 缺陷,实际是测试环境现象:浏览器中用户点击远晚于监听器挂载时间,不会触发该守卫。本批做法:单测统一用 `settle()`(`setTimeout(2)`)跨过该毫秒,并在报告中记录,避免后续批次再次误判为组件缺陷。**没有为此改动任何共享组件**。
其他缺口:
- `CloseButton` 被 `TagRemoveButton` 复用(视觉与基线一致,含默认 CloseIcon)。若后续批次要给 `CloseButton` 增加自带 `@click` 语义,需要回归本组件的移除路径。
- 移除逻辑集中在 `Tag` 行的点击处理:命中 `[data-slot="tag-remove-button"]` 时请求移除而非选择。这样自定义移除按钮(不经 `TagRemoveButton`)也能工作,且只有一条移除路径(不会重复触发)。
- 复制示例代码沿用文档站既有能力,未新增文档外壳改动。
## 8. 集成增量(便于解决共享文件冲突)
导出(`packages/vue/src/index.ts`,追加在文件末尾):
```ts
export { default as Tag } from "./components/tag/Tag.vue";
export { default as TagGroup } from "./components/tag/TagGroup.vue";
export { default as TagGroupList } from "./components/tag/TagGroupList.vue";
export { default as TagRemoveButton } from "./components/tag/TagRemoveButton.vue";
export type {
TagProps,
TagGroupProps,
TagGroupListProps,
TagRemoveButtonProps,
} from "./types";
export type {
TagKey,
TagGroupDataItem,
TagRenderState,
TagGroupOptions,
} from "./components/tag/context";
export { default as ErrorMessage } from "./components/error-message/ErrorMessage.vue";
export type { ErrorMessageProps } from "./types";
export {
tagVariants,
tagGroupVariants,
errorMessageVariants,
type TagVariants,
type TagGroupVariants,
type ErrorMessageVariants,
} from "@heroui-vue/styles";
```
样式入口(`packages/styles/index.css`):
```css
@import "./components/error-message.css" layer(components); /* description.css 之后 */
@import "./components/tag-group.css" layer(components); /* dropdown.css 之后 */
@import "./components/tag.css" layer(components);
```
样式变体(`packages/styles/src/index.ts` 末尾追加):`tagVariants`(slots: base/removeButton;size sm/md/lg;variant default/surface)、`tagGroupVariants`(base/list)、`errorMessageVariants`(base)。
导航(`apps/docs/.vitepress/theme/navigation.ts`):`ErrorMessage 错误消息`(forms,EmptyState 之后)、`TagGroup 标签组`(collections,Tabs 之后)。
依赖:无新增。`@tabler/icons-vue` 仅用于 apps/docs(既有依赖)。
兼容矩阵条目已写入 `docs/compatibility.md`(tag / tag-group / error-message 三行)。
## 9. 复核最短路径
1. `pnpm typecheck && pnpm test`(重点看 `tests/tag-error-message.test.ts` 35 项)。
2. `pnpm dev:docs`(5183)打开 `/components/tag-group`:
- 点击「资讯」→ 选中;`ArrowRight`/`End`/`Space` 检查焦点与选择;
- 「带移除按钮」第一组点 `旅行` 的 ×,确认标签消失且焦点落到「游戏」;
- 检查 sm/md/lg 间距、surface 背景、禁用透明度 0.5、键盘焦点环。
3. 打开 `/components/error-message`:确认两个示例渲染 `<p class="hv-error-message" slot="errorMessage">`,并检查 API 表满宽无溢出。
4. 独立消费:把 `tests/package/{consume-b03-tag-error-message.mjs,b03-tag-error-message-contract.ts}` 复制到工作区外的新工程,装两份 `pnpm pack` 产物后执行脚本 + 两种 `tsc` 模式。
+6
View File
@@ -202,3 +202,9 @@ M18–M20 的标签桥接在 Vue 使用 indicator 注册表与 SSR 直接/原生
## B01 Menu / Dropdown(2026-10-24)
固定 ce90ea3 的 `packages/react/src/components/{menu,menu-item,menu-section,dropdown}`、`packages/styles/components/{menu,menu-item,menu-section,dropdown}.css` 与对应 tv,中文 `(collections)/dropdown.mdx` 及 `demos/cn/dropdown` 17 例。样式加 hv- 前缀;演示图标采用 Tabler Vue。Menu/Item/Section 无独立 Web 文档页(native menu.mdx 属 heroui-native,不作为本契约)。底座为安装版 Reka 2.11 DropdownMenu,未复制 React 源码构建。
## B03 Tag / TagGroup / ErrorMessage(2026-10-25)
固定 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/{tag,tag-group,error-message}`、`packages/styles/components/{tag,tag-group,error-message}.css`、`packages/styles/src/components/{tag,tag-group,error-message}/*.styles.ts`,中文 `(collections)/tag-group.mdx`、`(forms)/error-message.mdx` 与 `demos/cn/tag-group` 12 例、`demos/cn/error-message` 2 例。Tag 无独立文档页,按固定 tag-group 正文与示例迁移。
CSS/tv 仅加 `hv-` 前缀与 Vue 状态适配,保留 Apache-2.0 来源。TagRemoveButton 复用本库 CloseButton 与基线 CloseIcon,可访问名称为 `Remove tag {标签文本}`(固定基线测试的同一字符串)。上游 `TagGroup.List` / `Tag.RemoveButton` 在本库为具名导出 `TagGroupList` / `TagRemoveButton`;React `render` 函数对应 `as` / `as-child`;`useListData` 演示改为 Vue 响应式数组。RAC 的 `FieldSlotsGate`/`TextContext` 只在集合渲染时需要,Vue 端改用字段上下文与渲染期 id 规划,不移植该 gate。无新增依赖,未运行时依赖相邻 React 仓库。
+24
View File
@@ -985,3 +985,27 @@ Button/PopoverTrigger/Link/ToggleButtonGroup 源码及几何复核后,移除
## 2026-10-25 B01 最终验收
整批23项复核回归通过;集成人修正CSS.escape测试补丁边界并将相关探针加入test:unit入口。最终pnpm test为73文件/938项通过,无未捕获错误;typecheck、build:docs和diff检查通过。独立消费夹具真实浏览器确认子菜单First向上循环至Last。范围及限制见 `migrations/B01-final-acceptance.md`,不新增SSR/水合/Nuxt要求,未合main、未推送。
## 2026-10-25 B03 Tag / TagGroup / ErrorMessage
迁移与差异范围见 [B03 报告](migrations/B03-tag-error-message.md):Tag、TagGroup、TagGroupList、TagRemoveButton、ErrorMessage 五部件,TagGroup 12 例 + ErrorMessage 2 例,分支 `feat/b03-tag-error-message`(起点 `3532cc6`,未合 main、未推送)。
### 自动化
- `pnpm typecheck`:通过(vue-tsc --noEmit)。
- `pnpm test`:**74 文件 / 973 项**通过(本批新增 `tests/tag-error-message.test.ts` 35 项,同时加入 `test:unit` 显式列表);连续两次执行结果一致。
- `pnpm build:docs`:退出码 0;SSG 预渲染阶段曾在 `elementFromRef` 触发 `Element is not defined`,已用非浏览器环境保护修复后重跑通过。
- `pnpm format`(prettier --check .)与 `git diff --check`:通过。
- 独立 tarball 消费(`/private/tmp/heroui-b03-consumer`,pnpm 11.25.0 + 两份 `pnpm pack` 产物):`node consume-b03-tag-error-message.mjs` 通过(11 项导出、SSR HTML 契约、CSS 选择器);`b03-tag-error-message-contract.ts` 在 `--moduleResolution bundler` 与 `nodenext` 两种模式下通过,4 个 `@ts-expect-error` 反例均实际触发。
### 浏览器重点验证(127.0.0.1:5183,Chromium/IAB,浅色 + 深色)
- 语义:列表 `role="grid"`、`aria-label` 来自 TagGroup 的 `aria-label`,行 `role="row"`;`Label` 存在时 `aria-labelledby` 指向 Label(`span`),Description/ErrorMessage 的 id 进入 `aria-describedby`。
- 选择:点击行后 `aria-selected/data-selected` 同步,选中态背景为 `accent-soft`(`oklab(0.6204 -0.0543052 -0.187286 / 0.2)`),单选用 `ArrowRight`/`End` 移动焦点(资讯→旅行→购物),`Space` 切换后原选中项取消。
- 尺寸/变体:`sm` 2px 8px/12px/12px、`md` 4px 8px/12px/12px、`lg` 6px 10px/14px/16px;`surface` 背景为 `oklch(1 0 0)`,`default` 为 `oklch(0.94 0.001 286.375)`;深色下默认背景 `oklch(0.274 0.006 286.033)`、文字 `oklch(0.9911 0 0)`。
- 禁用:`isDisabled` 与 `disabledKeys` 均输出 `aria-disabled="true"`/`data-disabled="true"`,计算透明度 0.5。
- 移除:移除按钮 12×12,`::after` 提供 24×24 命中区;点击后该标签消失,焦点落到原位置的下一个标签(旅行被移除后落到游戏)。
- 焦点环:键盘聚焦标签时 `:focus-visible` 与 `data-focus-visible="true"` 同时成立,`status-focused` 上屏(2px surface + 4px focus 双层 box-shadow)。
- 文档:API 表格全部 728px = 正文宽度、`display: table`、`table-layout: fixed`、`scrollWidth === clientWidth`(长 16 行与短 4 行表均无横向溢出);侧栏顺序为 EmptyState → ErrorMessage → FieldError,TagGroup 位于 Tabs 与 TextArea 之间;ErrorMessage 页面渲染 `<p class="hv-error-message" slot="errorMessage">`。
未验证:逐像素对比、读屏软件、物理触屏、窄屏断点截图。截图在本轮首次采集后 IAB 合成器不再返回帧(`capture timed out`),因此尺寸/配色改为计算样式断言,未以旧截图充当本轮证据。