`、`RouterLink` 等已具备导航能力的元素,以及需要自定义外观的 `span`/`div`:非原生可激活元素会获得 `role="link"`、`tabindex="0"`,Enter 触发一次激活(与点击同一 `click` 路径)。自定义元素上的 `href` 不会由浏览器直接导航,请用 `a` / 路由组件作为 asChild 目标,或在 `@click` 中自行处理跳转。禁用时仍可聚焦以便读出 `aria-disabled`,但不会激活。
+
+### LinkIcon
+
+| Prop | 类型 | 描述 |
+| ------- | -------- | ------------- |
+| `class` | `string` | 附加的 CSS 类 |
+
+默认插槽提供自定义图标元素;省略时使用内置箭头图标,并标记 `data-default-icon`。
+
+### 与路由库配合使用
+
+使用变体函数为框架专用链接添加样式:
+
+```vue
+
+
+
+ About Page
+
+
+
+```
+
+基础包不强依赖 Vue Router;可在应用层组合 `linkVariants` 或 `.hv-link` 类。
+
+### 直接应用类
+
+由于 HeroUI 使用 [BEM](https://getbem.com/) 类,你可以将 Link 样式直接应用到任意链接元素:
+
+```vue
+
+
+
+
+ About Page
+
+
+```
+
+```vue
+
+
+
+ About Page
+
+
+
+
+
+```
+
+## 相关组件
+
+[Button 按钮](./button) · [Card 卡片](./card)
diff --git a/apps/docs/components/spinner.md b/apps/docs/components/spinner.md
new file mode 100644
index 0000000..900b6ae
--- /dev/null
+++ b/apps/docs/components/spinner.md
@@ -0,0 +1,94 @@
+---
+title: Spinner 加载指示器
+description: 用于展示等待或处理中状态的加载指示组件
+component: spinner
+group: 组件
+---
+
+## 用法
+
+```vue
+
+```
+
+
+
+## 示例
+
+### 颜色
+
+
+
+### 尺寸
+
+
+
+### 速度
+
+为单个 Spinner 添加动画工具类即可调整其旋转速度。请同时加上 `motion-reduce:animate-none`,以便在用户开启“减少动态效果”时保持静止。
+
+
+
+## 自定义样式
+
+### Tailwind CSS
+
+
+
+### 全局 CSS
+
+若要自定义组件类,可使用 `@layer components` 指令。
+
+```css
+@layer components {
+ .hv-spinner {
+ @apply animate-spin;
+ }
+
+ .hv-spinner--accent {
+ color: var(--accent);
+ }
+}
+```
+
+## 样式参考
+
+HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
+
+### CSS 类
+
+Spinner 使用以下 CSS 类:
+
+#### 基础类与尺寸类 [!toc]
+
+- `.hv-spinner` - 基础样式与默认尺寸
+- `.hv-spinner--sm` - 小尺寸变体
+- `.hv-spinner--md` - 中等尺寸变体(默认)
+- `.hv-spinner--lg` - 大尺寸变体
+- `.hv-spinner--xl` - 特大尺寸变体
+
+#### 颜色类 [!toc]
+
+- `.hv-spinner--current` - 继承当前文本颜色
+- `.hv-spinner--accent` - 强调色变体
+- `.hv-spinner--danger` - 危险色变体
+- `.hv-spinner--success` - 成功色变体
+- `.hv-spinner--warning` - 警告色变体
+
+## API 参考
+
+### Spinner
+
+| Prop | 类型 | 默认值 | 描述 |
+| ------- | ------------------------------------------------------------- | ---------- | ------------------ |
+| `size` | `"sm" \| "md" \| "lg" \| "xl"` | `"md"` | Spinner 的尺寸 |
+| `color` | `"current" \| "accent" \| "success" \| "warning" \| "danger"` | `"accent"` | Spinner 的颜色变体 |
+| `class` | `string` | - | 额外的 CSS 类名 |
+
+根节点默认 `role="status"` 与 `aria-label="Loading"`,可通过 attrs 覆盖。内部 SVG 标记 `aria-hidden`,使用 `currentColor` 渐变;嵌入 Button 时保持所选尺寸(如 `size="sm"` 为 16px),不被 Button 的普通 SVG 规则覆盖。
+
+## 相关组件
+
+[Button 按钮](./button) · [Input 输入框](./input)
diff --git a/apps/docs/components/surface.md b/apps/docs/components/surface.md
new file mode 100644
index 0000000..46b5d75
--- /dev/null
+++ b/apps/docs/components/surface.md
@@ -0,0 +1,107 @@
+---
+title: Surface 表面
+description: 提供表面级样式与子组件上下文的容器组件
+component: surface
+group: 组件
+---
+
+## 用法
+
+```vue
+
+```
+
+
+
+## 示例
+
+### 变体
+
+Surface 提供描述 prominence 层级的语义变体:
+
+- **`default`** - 标准表面外观(bg-surface)
+- **`secondary`** - 中等 prominence(bg-surface-secondary)
+- **`tertiary`** - 较高 prominence(bg-surface-tertiary)
+- **`transparent`** - 透明背景,适用于遮罩层和自定义背景
+
+
+
+### 搭配表单
+
+在 Surface 内使用表单组件时,请使用 `variant="secondary"` 以应用适合表面背景的低强调变体。
+
+
+
+## 自定义样式
+
+### Tailwind CSS
+
+
+
+### 全局 CSS
+
+若要自定义组件类,可使用 `@layer components` 指令。
+
+```css
+@layer components {
+ .hv-surface {
+ @apply rounded-2xl border border-border;
+ }
+
+ .hv-surface--secondary {
+ @apply bg-gradient-to-br from-blue-50 to-purple-50;
+ }
+}
+```
+
+## 样式参考
+
+HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
+
+### CSS 类
+
+Surface 组件使用以下 CSS 类:
+
+#### 基础类 [!toc]
+
+- `.hv-surface` - Surface 根容器
+
+#### 变体类 [!toc]
+
+- `.hv-surface--default` - 默认 Surface 变体(bg-surface)
+- `.hv-surface--secondary` - Secondary Surface 变体(bg-surface-secondary)
+- `.hv-surface--tertiary` - Tertiary Surface 变体(bg-surface-tertiary)
+- `.hv-surface--transparent` - 透明 Surface 变体
+
+## API 参考
+
+### Surface
+
+| Prop | 类型 | 默认值 | 描述 |
+| --------- | --------------------------------------------------------- | ----------- | -------------------- |
+| `variant` | `"transparent" \| "default" \| "secondary" \| "tertiary"` | `"default"` | Surface 的视觉变体。 |
+| `class` | `string` | - | 额外的 CSS 类。 |
+
+默认插槽渲染 Surface 内容。其他属性与 DOM 事件透传到根 `div`。
+
+## Context API
+
+### surfaceContextKey
+
+子组件可通过 Surface 上下文读取当前变体:
+
+```vue
+
+```
+
+## 相关组件
+
+[Card 卡片](./card) · [Input 输入框](./input) · [Button 按钮](./button)
diff --git a/apps/docs/demos/button-loading-state.vue b/apps/docs/demos/button-loading-state.vue
index b01e73a..421c00d 100644
--- a/apps/docs/demos/button-loading-state.vue
+++ b/apps/docs/demos/button-loading-state.vue
@@ -1,8 +1,7 @@
diff --git a/apps/docs/demos/card-default.vue b/apps/docs/demos/card-default.vue
index 937e22b..aea6f15 100644
--- a/apps/docs/demos/card-default.vue
+++ b/apps/docs/demos/card-default.vue
@@ -1,5 +1,4 @@
@@ -19,16 +20,15 @@ import {
-
创作者中心
-
-
+
+
diff --git a/apps/docs/demos/card-with-form.vue b/apps/docs/demos/card-with-form.vue
index 3c46369..82a36d9 100644
--- a/apps/docs/demos/card-with-form.vue
+++ b/apps/docs/demos/card-with-form.vue
@@ -7,6 +7,7 @@ import {
CardContent,
CardFooter,
Button,
+ Link,
} from "@heroui-vue/components";
import { Input, Label } from "@heroui-vue/components";
import { ref, useId } from "vue";
@@ -51,13 +52,13 @@ const message = ref("");
-
忘记密码?
-
+
import { closeButtonVariants } from "@heroui-vue/styles";
-import { IconArrowUpRight, IconX } from "@tabler/icons-vue";
+import { IconX } from "@tabler/icons-vue";
import { IconCoin } from "@tabler/icons-vue";
import {
Card,
@@ -10,6 +10,8 @@ import {
CardContent,
CardFooter,
Button,
+ Link,
+ LinkIcon,
} from "@heroui-vue/components";
import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
@@ -87,15 +89,10 @@ import { AvatarRoot, AvatarImage, AvatarFallback } from "reka-ui";
-
+
前往设置
-
-
+
+
diff --git a/apps/docs/demos/input-on-surface.vue b/apps/docs/demos/input-on-surface.vue
index 52430f6..f88b347 100644
--- a/apps/docs/demos/input-on-surface.vue
+++ b/apps/docs/demos/input-on-surface.vue
@@ -1,9 +1,10 @@
-
-
+
diff --git a/apps/docs/demos/link-basic.vue b/apps/docs/demos/link-basic.vue
new file mode 100644
index 0000000..a581c2d
--- /dev/null
+++ b/apps/docs/demos/link-basic.vue
@@ -0,0 +1,9 @@
+
+
+
+ 立即行动
+
+
+
diff --git a/apps/docs/demos/link-custom-icon.vue b/apps/docs/demos/link-custom-icon.vue
new file mode 100644
index 0000000..ce877b2
--- /dev/null
+++ b/apps/docs/demos/link-custom-icon.vue
@@ -0,0 +1,20 @@
+
+
+
+
+ 外部链接
+
+
+
+
+
+ 前往页面
+
+
+
+
+
+
diff --git a/apps/docs/demos/link-custom-styles.vue b/apps/docs/demos/link-custom-styles.vue
new file mode 100644
index 0000000..edf4864
--- /dev/null
+++ b/apps/docs/demos/link-custom-styles.vue
@@ -0,0 +1,12 @@
+
+
+
+ 立即行动
+
+
+
diff --git a/apps/docs/demos/link-icon-placement.vue b/apps/docs/demos/link-icon-placement.vue
new file mode 100644
index 0000000..fe100bc
--- /dev/null
+++ b/apps/docs/demos/link-icon-placement.vue
@@ -0,0 +1,15 @@
+
+
+
+
+ 图标在末尾(默认)
+
+
+
+
+ 图标在开头
+
+
+
diff --git a/apps/docs/demos/link-render-function.vue b/apps/docs/demos/link-render-function.vue
new file mode 100644
index 0000000..27f35e2
--- /dev/null
+++ b/apps/docs/demos/link-render-function.vue
@@ -0,0 +1,11 @@
+
+
+
+
+ 立即行动
+
+
+
+
diff --git a/apps/docs/demos/link-underline-and-offset.vue b/apps/docs/demos/link-underline-and-offset.vue
new file mode 100644
index 0000000..b1a6e91
--- /dev/null
+++ b/apps/docs/demos/link-underline-and-offset.vue
@@ -0,0 +1,52 @@
+
+
+
+
+
默认悬浮下划线
+
+ 悬浮以查看下划线
+
+
+
+
+
+
始终显示下划线
+
+ 下划线始终可见
+
+
+
+
+
+
无下划线
+
+ 不带任何下划线的链接
+
+
+
+
+
+
调整下划线偏移
+
+
+ 偏移 1(1px 间距)
+
+
+
+ 偏移 2(2px 间距)
+
+
+
+ 偏移 3(3px 间距)
+
+
+
+ 偏移 4(4px 间距)
+
+
+
+
+
+
diff --git a/apps/docs/demos/spinner-basic.vue b/apps/docs/demos/spinner-basic.vue
new file mode 100644
index 0000000..a47e006
--- /dev/null
+++ b/apps/docs/demos/spinner-basic.vue
@@ -0,0 +1,8 @@
+
+
+
+
+
+
diff --git a/apps/docs/demos/spinner-colors.vue b/apps/docs/demos/spinner-colors.vue
new file mode 100644
index 0000000..4efba0b
--- /dev/null
+++ b/apps/docs/demos/spinner-colors.vue
@@ -0,0 +1,25 @@
+
+
+
+
+
+ {{ COLOR_LABELS[color] }}
+
+
+
diff --git a/apps/docs/demos/spinner-custom-styles.vue b/apps/docs/demos/spinner-custom-styles.vue
new file mode 100644
index 0000000..dd64cbf
--- /dev/null
+++ b/apps/docs/demos/spinner-custom-styles.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/apps/docs/demos/spinner-sizes.vue b/apps/docs/demos/spinner-sizes.vue
new file mode 100644
index 0000000..0177116
--- /dev/null
+++ b/apps/docs/demos/spinner-sizes.vue
@@ -0,0 +1,24 @@
+
+
+
+
+
+ {{ SIZE_LABELS[size] }}
+
+
+
diff --git a/apps/docs/demos/spinner-speed.vue b/apps/docs/demos/spinner-speed.vue
new file mode 100644
index 0000000..668abbc
--- /dev/null
+++ b/apps/docs/demos/spinner-speed.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+ 慢速
+
+
+
+ 默认
+
+
+
+ 快速
+
+
+
diff --git a/apps/docs/demos/surface-basic.vue b/apps/docs/demos/surface-basic.vue
new file mode 100644
index 0000000..3f1060c
--- /dev/null
+++ b/apps/docs/demos/surface-basic.vue
@@ -0,0 +1,12 @@
+
+
+
+ 表面内容
+ 这是默认表面变体,使用 bg-surface 样式。
+
+
diff --git a/apps/docs/demos/surface-custom-styles.vue b/apps/docs/demos/surface-custom-styles.vue
new file mode 100644
index 0000000..9dd0843
--- /dev/null
+++ b/apps/docs/demos/surface-custom-styles.vue
@@ -0,0 +1,12 @@
+
+
+
+ 账单概览
+ 在此查看发票和支付方式。
+
+
diff --git a/apps/docs/demos/surface-variants.vue b/apps/docs/demos/surface-variants.vue
new file mode 100644
index 0000000..e1a0e76
--- /dev/null
+++ b/apps/docs/demos/surface-variants.vue
@@ -0,0 +1,58 @@
+
+
+
+
+
默认
+
+ 表面内容
+
+ 这是默认表面变体,使用 bg-surface 样式。
+
+
+
+
+
+
次要
+
+ 表面内容
+
+ 这是次要表面变体,使用 bg-surface-secondary 样式。
+
+
+
+
+
+
第三
+
+ 表面内容
+
+ 这是第三表面变体,使用 bg-surface-tertiary 样式。
+
+
+
+
+
+
透明
+
+ 表面内容
+
+ 这是透明表面变体,无背景,适用于遮罩层和自定义背景的卡片。
+
+
+
+
+
diff --git a/apps/docs/demos/surface-with-form-components.vue b/apps/docs/demos/surface-with-form-components.vue
new file mode 100644
index 0000000..95a2dc6
--- /dev/null
+++ b/apps/docs/demos/surface-with-form-components.vue
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/docs/compatibility.md b/docs/compatibility.md
index da758ec..2e7c1bc 100644
--- a/docs/compatibility.md
+++ b/docs/compatibility.md
@@ -2,91 +2,91 @@
基于固定上游提交的公共组件导出清单。验证中不等于完整兼容;目前没有组件完成视觉、浏览器与完整行为验收。
-| 组件 | 状态 | 当前能力 / 差异 |
-| -------------------- | ------------------ | ------------------------------------------------------------------------------------------------ |
-| accordion | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| alert-dialog | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| autocomplete | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| avatar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| avatar-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| badge | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| breadcrumbs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
-| button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
-| checkbox | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| checkbox-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| chip | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| color-area | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| color-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| color-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| color-slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| color-swatch | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| close-button | 样式已移植 | Card 演示使用原生 button + closeButtonVariants + Tabler IconX;Vue CloseButton 组件尚未实现 |
-| combo-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| date-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| drawer | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| progress-bar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| progress-circle | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| time-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| disclosure | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| disclosure-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| error-message | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| kbd | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| link | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| popover | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| scroll-shadow | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| separator | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| skeleton | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| spinner | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| surface | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| toast | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| toggle-button | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
-| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
-| tabs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| tag | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| tag-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| toggle-button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| toolbar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| tooltip | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| input | 验证中(最小实现) | primary/secondary、fullWidth、原生属性、v-model/defaultValue、表单 reset;TextField 上下文未实现 |
-| input-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| textarea | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| textfield | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| search-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| typography | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| label | 验证中(原生标签) | for 关联、required/disabled/invalid;Switch 内采用 span 避免嵌套交互 |
-| description | 验证中(描述关联) | 唯一 ID、多个描述、Switch aria-describedby 关联 |
-| empty-state | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| field-error | 验证中(Switch) | 错误消息、ARIA 关联;完整 TextField 上下文未实现 |
-| fieldset | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| form | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| header | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| radio | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| radio-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| input-otp | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| alert | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| list-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| list-box-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| list-box-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| dropdown | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| menu | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| menu-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| menu-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| modal | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| number-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| pagination | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| select | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| meter | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| table | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| range-calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
-| calendar-year-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| 组件 | 状态 | 当前能力 / 差异 |
+| -------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------- |
+| accordion | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| alert-dialog | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| autocomplete | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| avatar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| avatar-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| badge | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| breadcrumbs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
+| button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
+| checkbox | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| checkbox-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| chip | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| color-area | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| color-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| color-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| color-slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| color-swatch | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| close-button | 样式已移植 | Card 演示使用原生 button + closeButtonVariants + Tabler IconX;Vue CloseButton 组件尚未实现 |
+| combo-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| date-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| date-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| date-range-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| drawer | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| progress-bar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| progress-circle | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| time-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| disclosure | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| disclosure-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| error-message | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| kbd | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
+| popover | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| scroll-shadow | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| separator | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| skeleton | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
+| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
+| toast | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| toggle-button | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
+| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
+| tabs | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| tag | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| tag-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| toggle-button-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| toolbar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| tooltip | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| input | 验证中(最小实现) | primary/secondary、fullWidth、原生属性、v-model/defaultValue、表单 reset;TextField 上下文未实现 |
+| input-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| textarea | 验证中(演示依赖) | 变体、v-model、表单 reset;为 Surface 表单演示移植,未完成独立 TextField 体系验收 |
+| textfield | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| search-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| typography | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| label | 验证中(原生标签) | for 关联、required/disabled/invalid;Switch 内采用 span 避免嵌套交互 |
+| description | 验证中(描述关联) | 唯一 ID、多个描述、Switch aria-describedby 关联 |
+| empty-state | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| field-error | 验证中(Switch) | 错误消息、ARIA 关联;完整 TextField 上下文未实现 |
+| fieldset | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| form | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| header | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| radio | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| radio-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| input-otp | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| alert | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| list-box | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| list-box-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| list-box-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| dropdown | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| menu | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| menu-item | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| menu-section | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| modal | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| number-field | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| pagination | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| select | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| meter | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| slider | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| table | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| range-calendar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| calendar-year-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
## 公共导出差异
@@ -100,11 +100,13 @@ React Aria 专属 rac 导出与 React 图标类型不移植;Vue 版 ConfigProv
## 已实现组件的文档清单复核
-Button 14 / 14,Card 7 / 7,Input 7 / 7,Switch 15 / 15,基线预览名称与顺序均已对齐。没有用空壳补足数量;预览与复制代码共用 SFC。
+Button 14 / 14,Card 7 / 7,Input 7 / 7,Switch 15 / 15,Surface 4 / 4,Link 6 / 6,Spinner 5 / 5,基线预览名称与顺序均已对齐。没有用空壳补足数量;预览与复制代码共用 SFC。
-Card 图片、头像、横向布局、表单与自定义样式已补齐;Input 的标签、类型、宽度与自定义样式已对齐。Switch 补齐图标、位置、分组、表单、状态插槽与自定义根容器。
+Card 图片、头像、横向布局、表单与自定义样式已补齐;Input 的标签、类型、宽度与自定义样式已对齐。Switch 补齐图标、位置、分组、表单、状态插槽与自定义根容器。Surface 覆盖变体与表单组合;Link 覆盖图标位置、文本装饰、自定义图标、asChild 与自定义样式;Spinner 覆盖颜色、尺寸、速度与自定义样式。
-框架适配差异:Avatar 使用 Reka 组合,表单与链接采用原生 HTML;图标使用 Tabler 官方 Vue 组件;演示不提供认证、支付等业务服务。完整 React Aria 事件模型、全库字段上下文及自动视觉回归仍不在本批完成范围。
+框架适配差异:Avatar 使用 Reka 组合,表单使用 Input/TextArea;链接原生锚点由 Link 组件封装;图标使用 Tabler 官方 Vue 组件(Link 自定义图标示例);演示不提供认证、支付等业务服务。完整 React Aria 事件模型、全库字段上下文及自动视觉回归仍不在本批完成范围。
+
+上游 Link 的 `underline-offset` 与 `underline-variants` 演示文件未出现在中英文文档预览清单,本批仅迁移文档引用的 6 个示例。Link `onPress`/`PressEvent` 与 `render` 由 `click` 与 `asChild` 适配;Spinner 默认图标为移植的基线 SVG,非 Tabler。
## 文档体验范围
diff --git a/docs/migrations/M01-M03-review.md b/docs/migrations/M01-M03-review.md
new file mode 100644
index 0000000..58d93f3
--- /dev/null
+++ b/docs/migrations/M01-M03-review.md
@@ -0,0 +1,147 @@
+# M01–M03 集成复核
+
+本文件保留各轮审查历史,当前结论以末尾“第四次集成复核”为准。
+
+日期:2026-10-21。审查基线为 `9d40dc0` 之后的当前未提交工作区,目标为 Surface、Link、Spinner,并检查其 TextArea 演示依赖与现有组件接入改动。
+
+结论:**待修正**。发现 3 个可复现的 Link 问题。Surface、Spinner 本轮代码和构建检查暂未发现阻断问题;不据此声明完整兼容或视觉验收通过。
+
+按用户要求,本轮没有打开浏览器或逐个操作页面;沿用实现者的浏览器记录作为交接信息,本轮独立证据来自源码对照、类型/构建及 jsdom 复现。
+
+## 1. [P1] autoFocus 挂载即抛出异常
+
+定位:`packages/vue/src/components/link/Link.vue:101–103`,模板 ref 位于 111 行。
+
+`ref="element"` 绑定的是 Reka Primitive 的 Vue 组件实例,声明为 HTMLElement 不会把它转换成实际 DOM。传入 `autoFocus=true` 后调用 `.focus()`,抛出 `TypeError: element.value?.focus is not a function`,挂载失败。
+
+复现:Vue Test Utils 挂载 `Link`,props 为 `{href: '#', autoFocus: true}`,并 attachTo document.body。当前在 mounted 阶段抛错,无法通过 activeElement 断言。
+
+修正方向:获取 Primitive 对应的真实 DOM(同时考虑 asChild),再执行 focus;公开的 element 引用也必须符合其声明的类型。增加普通锚点与 asChild 的自动聚焦回归,禁用情况下的聚焦策略需明确。
+
+## 2. [P2] asChild 的 span 示例没有可访问链接行为
+
+定位:`packages/vue/src/components/link/Link.vue:110–125`;`apps/docs/demos/link-render-function.vue:5–9`。
+
+当前把 href 等属性合并到 span,但 span 不会因此变成链接:没有 role=link、没有可进入 Tab 顺序的 tabindex,也没有 Enter 激活及真实导航处理。示例外观可用,但键盘与导航能力丢失。已有测试只验证 span 带有 href/class,没有验证它是否能作为链接使用。
+
+复现:挂载 `link`。实际 role/tabindex 均为 undefined;向 span 发送 Enter,调用方 click 次数仍为 0。
+
+修正方向:若继续支持任意元素,补齐自定义元素的链接语义、键盘激活与导航,并防止普通 a 或 RouterLink 重复触发;或把 asChild 明确限制为已经具备链接语义和行为的元素/组件,修改示例及 API 说明,记录与上游自定义 render 能力的差异。不能继续把带 href 的 span 描述为完整链接。
+
+复核时检查原生 a、约定支持的自定义元素/路由组件、禁用状态、键盘以及一次激活只产生一次事件。
+
+## 3. [P2] 事件守卫不兼容 Vue 合并后的监听器数组
+
+定位:`packages/vue/src/components/link/Link.vue:35–47`,同类调用位于 63–91 行。
+
+实现把 attrs 里的 onClick/onKeydown 等强制转换为单个 Handler,再用可选函数调用执行。但 Vue mergeProps 合并多个同名监听器会生成函数数组。数组并非可调用函数,启用链接触发事件时会抛出 `TypeError: parent is not a function`,所有调用方处理器均未执行;键盘与 capture 分支存在相同假设。
+
+复现:`h(Link, {href: '#', onClick: [first, second]}, () => 'link')`,点击后抛错,处理器计数为 0,预期各执行一次。这也对应包装组件使用 mergeProps 合并监听器的常见路径。
+
+修正方向:监听器调用逻辑兼容单函数与数组,保留合理的事件中断语义;同时确保禁用守卫始终先执行。补测 Vue mergeProps 形成的 click/capture/keydown 数组,启用时各执行一次、禁用激活时均不执行。
+
+## 已完成的检查
+
+- 原有测试:7 文件 / 52 项通过。
+- `vue-tsc --noEmit`:通过。
+- Prettier 全项目检查:通过。
+- `pnpm build:docs`:styles、components、声明文件及 VitePress 构建通过。
+- Surface / Link / TextArea 的组件 CSS 去掉来源注释和 hv- 前缀后,与固定上游基线一致。
+- Spinner 除增加 SVG 填满宿主尺寸的适配规则外,保留基线 CSS。
+- Surface 4、Link 6、Spinner 5 个文档预览名称与顺序,均与上游中文文档清单一致。
+- 补充的 6 个临时复现检查中,4 个失败断言对应上述 3 类问题;动态 Link ARIA/class/事件回调更新、Spinner ARIA/role 更新两个检查通过,未将这些潜在疑点误报为缺陷。
+- 临时复现文件已删除,没有修改对方的组件、测试、文档或迁移状态来掩盖失败;仅新增本报告。
+
+## 本轮边界
+
+- 没有重复浏览器视觉、焦点和布局检查;不把实现者的浏览器记录作为本轮独立验证通过。
+- 没有执行 Nuxt 水合、读屏、触屏、RTL、打包后独立安装或自动逐像素对比。
+- TextArea 已作为演示依赖进入公共导出,需继续保持“部分能力/未完整验收”的明确状态,不能因本轮构建通过就标为完整完成。
+- 建议先处理三个 Link 问题及对应回归,再重新运行检查,最后由集成人更新验收状态。不需要为此次代码返工重做所有页面点击。
+
+## 第二次集成复核(2026-10-21)
+
+结论:**仍待修正,未提交**。本轮继续遵守用户要求,不打开浏览器。
+
+已确认修复:普通 a / asChild 的 autoFocus 使用真实 DOM;监听器数组不再直接作为函数调用;span 增加 role/tabindex 并说明导航边界;download 缺省省略。原有 58 项测试、类型与格式检查通过。
+
+但新增键盘适配复现出以下问题,当前已有回归只发 keydown,没有模拟完整按键。
+
+### [P1] 一次完整 Enter 触发两次 click
+
+定位:`packages/vue/src/components/link/Link.vue:131–134`、91–112 行。
+
+keydown capture、keydown bubble、keyup 都调用带有激活逻辑的 guardKey。keydown 阶段先触发一次 click;keyup 是另一个未被 preventDefault 的事件,又触发一次。对 asChild span 完成一次按下/松开操作,调用方处理器执行 2 次,可能导致重复导航或重复业务动作。
+
+复现:挂载 `asChild=true` 的 Link,slot 为 span,onClick 递增计数;按顺序 trigger keydown Enter、keyup Enter,期望 1,实际 2。
+
+修正要求:禁用守卫与合成激活分离;只在约定的单一阶段激活一次,keyup 不再次执行。补测完整按键序列、原生 a 和禁用路径。
+
+### [P2] 调用方 keydown preventDefault 无法取消激活
+
+定位:`packages/vue/src/components/link/Link.vue:131–133`、98–112 行。
+
+合成 click 在 capture 阶段、调用方普通 keydown 监听器运行之前已经发生。调用方随后 preventDefault 无法撤销已经执行的 click。
+
+复现:asChild span,onClick 递增计数,onKeydown 调用 preventDefault;trigger keydown Enter,期望计数 0,实际 1。
+
+修正要求:capture 只做必要的禁用拦截,不提前执行合成默认动作;先遵守调用方事件取消,再决定是否激活。确认 capture 与 bubble 的取消均有效。
+
+### [P2] 监听器数组不保留 stopImmediatePropagation 语义
+
+定位:`packages/vue/src/components/link/Link.vue:53–61`。
+
+callHandlers 虽然能遍历数组,但首个处理器调用 stopImmediatePropagation 后仍会继续调用后续处理器,与 Vue 对合并原生监听器的处理不同。
+
+复现:onClick 数组包含 first 与 second;first 记录调用并 stopImmediatePropagation。点击后预期只有 first,实际 first/second 都执行。
+
+修正要求:兼容函数数组的同时保留即时中断语义;覆盖 click、capture 与键盘复用路径,禁用时继续确保所有激活处理器不执行。
+
+### 本轮验证与提交边界
+
+- 3 个临时复现检查全部失败,结果分别为 click 2 次、取消后 click 1 次、数组处理器执行 2 个。
+- 临时文件已清理;未修改组件实现及对方测试。
+- 原有测试 7 文件 / 58 项通过,类型检查与全项目格式检查通过。
+- 因仍存在阻断问题,本轮不提交这批迁移,也未重复生产构建和页面点击;提交条件尚未满足。
+
+## 第三次集成复核(2026-10-21)
+
+结论:**仍待修正,未提交**。上轮重复 Enter、keydown 取消与数组中断的回归已补齐;现有 63 项测试通过。但是用于替代 DOM click 的新实现引入了公共事件契约问题。
+
+### [P2] 键盘激活绕过 DOM click,事件目标为空且不传播
+
+定位:`packages/vue/src/components/link/Link.vue:135–144`。
+
+activateFromKeyboard 创建 MouseEvent 后没有向 el 派发,而是直接调用 attrs 的两个处理器。`bubbles: true` 不会让未派发的事件自动传播;传入的 el 参数实际上未被使用。
+
+实际后果:
+
+- Link 的 attrs.onClick 被调用,但 asChild 插槽元素自身的 onClick 不会调用。
+- 祖先容器的 click/capture 监听器收不到键盘激活,事件委托与包装组件行为不再等价于鼠标点击。
+- attrs.onClick 收到的 event.target/currentTarget 均为 null,常见的 DOM 读取和类型断言会失败。
+- capture 处理器只 preventDefault 时,代码直接跳过 bubble 回调;原生事件中 preventDefault 并不等于停止传播。
+
+独立复现(临时 Vitest,已清理):
+
+1. 外层 div 设置 onClick,内部 Link(asChild) 设置 onClick,slot span 也设置 onClick。向 span 触发 Enter keydown,期望 Link、span、祖先处理器均通过真实 click 路径调用;实际只有 Link 处理器调用。
+2. Link(asChild) 的 attrs.onClick 记录 target/currentTarget,Enter keydown 后期望都是 slot span,实际为 null。
+
+两项复现均失败。当前 63 项测试未覆盖真实点击事件的目标与传播,只验证了 attrs 回调计数。
+
+修正方向:通过真实根元素执行 click/dispatchEvent,保证单次激活、DOM 目标、插槽处理器和祖先传播;沿用现有禁用与取消检查。若同步嵌套事件在测试环境中存在时序问题,应定位事件注册/时间戳或合成调度问题,不以直接调用回调替代公开 DOM 事件。
+
+追加回归应覆盖:完整 Enter 仅激活一次;keydown/capture 可取消;target/currentTarget 正确;插槽自身与祖先 click 均能接收;普通 a 无重复激活;preventDefault 不吞掉正常传播,而 stopPropagation/stopImmediatePropagation 仍保持各自语义。
+
+本轮原有 63 项测试、类型检查、全项目格式检查通过;仍未打开浏览器,未修改组件或对方测试。因为存在上述阻断问题,不提交这批改动,也未重复生产构建。
+
+## 第四次集成复核(2026-10-21)
+
+结论:**通过本批代码与构建复核,可提交**。历史问题保留在前文,均不代表当前仍未修复。
+
+- 键盘激活已通过真实根元素 dispatchEvent 派发 click;完整 Enter 不重复激活,目标元素、插槽处理器及祖先传播恢复。
+- keydown 的 capture/bubble 取消、click capture 的 preventDefault 与 stopImmediatePropagation,以及监听器数组中断均有对应回归。
+- 独立临时复现 4 项全部通过:完整按键的目标与传播、两阶段取消、Vue mergeProps 数组中断、卸载原生监听器清理。临时文件已删除,未替换或修改组件实现。
+- 原有 7 文件 / 67 项测试通过;vue-tsc 类型检查通过;styles/components/声明文件/VitePress 生产构建通过。交接报告存在的 Prettier 格式问题已修正,并重新检查。
+- 本轮遵循用户要求,没有打开浏览器;不扩大为视觉、读屏、触屏、Nuxt 水合或独立打包安装验收通过。
+
+维护注意:键盘派发当前显式适配 Vue invoker 的私有 `_vts` 字段。当前安装版本下的独立复现和回归通过,但这不是 Vue 公共 API;未来升级 Vue 时必须重跑真实事件派发、取消、插槽与祖先传播检查,不能只看回调计数。此兼容性风险保留为已知维护边界,不据此声称未来 Vue 版本均已验收。
diff --git a/docs/migrations/M01-M03-surface-link-spinner.md b/docs/migrations/M01-M03-surface-link-spinner.md
new file mode 100644
index 0000000..7b4fee8
--- /dev/null
+++ b/docs/migrations/M01-M03-surface-link-spinner.md
@@ -0,0 +1,217 @@
+# M01–M03 迁移报告:Surface、Link、Spinner
+
+日期:2026-10-21
+起始提交:`9d40dc0`(工作区干净,分支 `main`)
+上游基线:HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`
+实现目录:`heroui-vue`(未改动 `../heroui`)
+
+## 1. 修改范围
+
+### 新增
+
+| 路径 | 用途 |
+| --------------------------------------------------------------------- | ---------------------------- |
+| `packages/styles/components/{surface,link,spinner,textarea}.css` | 基线 CSS,hv- 前缀 |
+| `packages/vue/src/components/surface/{Surface.vue,context.ts}` | Surface 与变体上下文 |
+| `packages/vue/src/components/link/{Link.vue,LinkIcon.vue,context.ts}` | Link 与默认图标 |
+| `packages/vue/src/components/spinner/Spinner.vue` | Spinner(含基线 SVG) |
+| `packages/vue/src/components/textarea/TextArea.vue` | TextArea(Surface 演示依赖) |
+| `apps/docs/demos/surface-*.vue`(4) | 基线演示 |
+| `apps/docs/demos/link-*.vue`(6) | 文档引用演示 |
+| `apps/docs/demos/spinner-*.vue`(5) | 基线演示 |
+| `apps/docs/components/{surface,link,spinner}.md` | 中文文档 |
+| `tests/surface-link-spinner.test.ts` | 行为测试(14 项) |
+| `docs/migrations/M01-M03-surface-link-spinner.md` | 本报告 |
+
+### 修改(含共享入口)
+
+| 路径 | 变更 |
+| ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
+| `packages/styles/src/index.ts` | 增加 surface/link/spinner/textarea 变体 |
+| `packages/styles/index.css` | 导入新 CSS;移除临时 `.hv-spinner` 圆环样式 |
+| `packages/vue/src/{index.ts,types.ts}` | 导出与类型 |
+| `packages/vue/src/components/button/Button.vue` | 加载指示器改用 Spinner |
+| `apps/docs/.vitepress/theme/Layout.vue` | 导航加入 Surface/Link/Spinner |
+| `apps/docs/.vitepress/theme/style.css` | `a { text-decoration: none }` 移入 `@layer base`(修复 utility 覆盖) |
+| `apps/docs/components.md` | 组件索引 |
+| `apps/docs/demos/{input-on-surface,card-default,card-with-form,card-with-images,button-loading,button-loading-state}.vue` | 替换临时适配 |
+| `tests/{aligned-components.test.ts,ssr.test.ts}` | 清单与 SSR 覆盖 |
+| `package.json` | `test:unit` 加入新测试文件 |
+| `docs/{compatibility,upstream,verification}.md` | 状态与来源 |
+
+未改锁文件与无关组件逻辑。
+
+## 2. 上游来源
+
+- Surface:`packages/react/src/components/surface/surface.tsx`、`packages/styles/components/surface.css`、`cn/react/components/(layout)/surface.mdx`、`demos/cn/surface/{basic,variants,custom-styles,with-form-components}`
+- Link:`…/link/link.tsx`、`link.css`、`(navigation)/link.mdx`、`demos/cn/link/{basic,icon-placement,underline-and-offset,custom-icon,render-function,custom-styles}`
+- Spinner:`…/spinner/spinner.tsx`、`spinner.css`、`(feedback)/spinner.mdx`、`demos/cn/spinner/{basic,colors,sizes,speed,custom-styles}`
+- Link 默认图标:`packages/react/src/components/icons.tsx` → `ExternalLinkIcon`
+- Spinner SVG:`SpinnerPrimitive` 渐变路径
+- TextArea(演示依赖):`packages/react/src/components/textarea/textarea.tsx`、`textarea.css`
+
+上游 `underline-offset.tsx`、`underline-variants.tsx` 未出现在中英文文档 `ComponentPreview` 清单,本批未迁移。许可:Apache-2.0(见 `third-party/HEROUI-LICENSE`)。
+
+## 3. API 对照
+
+### Surface
+
+| 上游 | Vue | 默认值 / 差异 |
+| ------------------------- | ------------------------------ | -------------------------------------------------------------- |
+| `variant` | `variant` | `"default"`;`transparent \| default \| secondary \| tertiary` |
+| `className` | `class` | — |
+| `children` | 默认插槽 | — |
+| `SurfaceContext` | `surfaceContextKey` + `inject` | 读取 `variant`(ComputedRef) |
+| `Surface` / `SurfaceRoot` | `Surface` | 命名导出,无 `Surface.Root` 点语法 |
+| `data-slot="surface"` | 同左 | — |
+
+### Link
+
+| 上游 | Vue | 默认值 / 差异 |
+| -------------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `href` / `target` / `rel` / `download` | 同名 | `target` 默认 `"_self"` |
+| `isDisabled` | `isDisabled` | `false`;`aria-disabled`;包装 attrs 的 click/keydown(含 capture)在禁用时 `preventDefault` + `stopImmediatePropagation`,调用方监听不触发;保留 href |
+| `onPress` (PressEvent) | `@click` | **不等价**;原生激活路径 |
+| `render` | `asChild` | 合并到默认插槽唯一元素 |
+| `autoFocus` | `autoFocus` | 挂载聚焦 |
+| `className` | `class` | — |
+| `Link.Icon` | `LinkIcon` | 默认 ExternalLinkIcon;有插槽内容时去掉 `data-default-icon` |
+| RAC 状态 props | 作用域插槽 | `isHovered/isPressed/isFocused/isFocusVisible/isDisabled` |
+| React Router 示例 | `linkVariants()` + `RouterLink` | 基础包不依赖 vue-router |
+
+### Spinner
+
+| 上游 | Vue | 默认值 / 差异 |
+| -------------------------------------- | -------- | ------------------------------------------------------- |
+| `size` | `size` | `"md"`;`sm\|md\|lg\|xl` → 16/24/32/40px |
+| `color` | `color` | `"accent"`;`current\|accent\|success\|warning\|danger` |
+| `className` | `class` | — |
+| `role="status"` `aria-label="Loading"` | 默认同左 | 可通过 attrs 覆盖 |
+| `SpinnerPrimitive` SVG | 内置 SVG | 渐变 id 使用 `useId` 保证唯一 |
+
+### TextArea(演示依赖)
+
+`modelValue`/`update:modelValue`、`defaultValue`、`variant`(primary/secondary)、`fullWidth`、`invalid`;与 Input 相同的表单 reset 行为。未做 TextField 上下文。
+
+## 4. 示例对照
+
+| 组件 | 基线顺序 | 缺失 |
+| ------- | --------------------------------------------------------------------------------------------- | ----- |
+| Surface | basic → variants → with-form-components → custom-styles | 0 / 4 |
+| Link | basic → icon-placement → underline-and-offset → custom-icon → render-function → custom-styles | 0 / 6 |
+| Spinner | basic → colors → sizes → speed → custom-styles | 0 / 5 |
+
+文案、结构与基线一致。替换项:
+
+1. Link `custom-icon`:`@gravity-ui/icons` → Tabler `IconExternalLink` / `IconLink`。
+2. Link `render-function`:`render={(props)=>…}` → `asChild` + `span[data-custom=foo]`。
+3. Surface `with-form-components`:依赖 TextArea(本批最小实现)。
+4. Button 加载演示:Tabler IconLoader2 → ``(对齐上游 CN)。
+5. Card 三处原生链接 → Link/LinkIcon。
+6. Input 表面演示 → Surface 容器。
+
+## 5. 命令结果
+
+| 命令 | 结果 |
+| ----------------------------------------------- | --------------------------------------- |
+| `pnpm test` | 7 文件 / 51 项通过 |
+| `pnpm typecheck` | 通过 |
+| `pnpm build:docs` | 通过(styles + components + VitePress) |
+| `pnpm format` | 通过 |
+| `pnpm build:playground` | **未执行** |
+| `test:browser` / `test:visual` / `test:package` | **未建立** |
+
+新增测试位于 `tests/surface-link-spinner.test.ts`,已纳入 `test:unit`。
+
+## 6. 浏览器证据
+
+地址 `http://127.0.0.1:5173`,IAB,桌面视口;主题通过文档主题切换检查浅/深。
+
+- `/components/surface`:4 例齐全;变体背景色与深色主题变量见 verification.md;表单例 Input/TextArea secondary。
+- `/components/link`:underline / no-underline / offset 1–4 计算值;默认与自定义图标;asChild=`span[data-custom=foo]`。
+- `/components/spinner`:四档尺寸、五色、role/aria、SVG viewBox。
+- `/components/button`:加载 Spinner 16px,`data-pending`/`aria-busy`。
+- `/components/card`:创作者中心、前往设置、忘记密码均为 `hv-link`。
+
+IAB 截图接口超时,本轮无位图;证据为 DOM 与计算样式。
+
+## 7. 已知差异与未验证项
+
+- `onPress`/`PressEvent`、RAC `render` 类型、RouterProvider 不等价。
+- 上游 2 个未引用演示文件未迁移。
+- TextArea 未做完整 TextField/Form 验收。
+- 未验证:SSR 水合、Nuxt、RTL、触屏、读屏、独立安装 dist、自动视觉对比、减少动态效果系统偏好实测(仅保证 `motion-reduce` 类存在)。
+- 不宣称与 HeroUI 完整兼容。
+
+## 8. 集成人复核步骤
+
+1. `pnpm test && pnpm typecheck && pnpm build:docs`。
+2. 打开 `http://127.0.0.1:5173/components/surface`,确认 4 例及 secondary 表单。
+3. `/components/link`:展开各例源码;Tab 应显示焦点环;自定义图标为 Tabler。
+4. `/components/spinner`:尺寸 16/24/32/40;Button 页加载例 Spinner 为 16px。
+5. Card 页确认链接为 Link;检查浅/深主题下表面与链接色。
+6. 对照本报告 API 表与 `docs/compatibility.md` 行状态。
+
+## 9. 共享文件改动(需集成人确认)
+
+- `packages/vue/src/index.ts`、`types.ts`
+- `packages/styles/src/index.ts`、`index.css`
+- `apps/docs/.vitepress/theme/{Layout.vue,style.css}`
+- `package.json`(`test:unit`)
+- `docs/compatibility.md`、`upstream.md`、`verification.md`
+
+## 10. 独立复核与修正(2026-10-21)
+
+独立 AI 复核结论为「待修正」,已按报告处理:
+
+| 问题 | 处理 |
+| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| 1 中:禁用 Link 未阻断父级 `@keydown`(attrs 监听先于组件守卫) | **已修**:`Link.vue` 将 `onClick`/`onClickCapture`/`onKeydown`/`onKeydownCapture`/`onKeyup` 包装为合并 attrs,禁用时先 `preventDefault`+`stopImmediatePropagation` 再不调用调用方;补测 keydown Enter/Space 与 `onClickCapture` |
+| 2 低-中:`@click.capture` 泄漏 | **已修**:同上包装 `onClickCapture` |
+| 3 低:Button 自动 Spinner 仅 `loading` | **不改行为**:文档已写明 `isPending` 不自动插入图标、`loading` 别名才自动显示;与上游 render-prop 手放 Spinner 一致 |
+| 4 信息:Link 文档「直接应用类」缺段 | **已补**:路由 `slots.icon()`、RouterLink `hv-link`、原生 a + `hv-link__icon` 三例 |
+
+复测:`pnpm test` 52 项通过(新增禁用 keydown/capture 回归);`pnpm typecheck` 通过。
+
+## 11. 二次复核返工(2026-10-21)
+
+集成复核报告 `docs/migrations/M01-M03-review.md` 提出 3 个 Link 问题,处理如下:
+
+| 问题 | 处理 |
+| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| P1 `autoFocus` 把 Primitive 实例当 DOM | **已修**:`:ref="setRoot"` 解析 `HTMLElement` / 实例 `$el`;`defineExpose({ element, focus })` 指向真实 DOM;普通锚点与 asChild 均可聚焦 |
+| P2 `asChild` span 无链接行为 | **已修**:asChild 根补充 `role="link"`、`tabindex="0"`;Enter 对非原生可激活元素合成一次 `click`(与鼠标同一路径,不重复触发 a/button);文档写明 span 上的 href 不自动导航,真实导航用 `a`/RouterLink |
+| P2 监听器数组抛错 | **已修**:`callHandlers` 兼容函数与函数数组;禁用时数组内处理器均不调用 |
+| 附带 | Vue 将 `download?: boolean` 缺省转为 `false` 并渲染 `download="false"`;改为仅在 true/字符串时输出 download 属性 |
+
+回归:新增 6 项(监听器数组、禁用数组、autoFocus 锚点/asChild、asChild 语义与 Enter、download 属性),`pnpm test` 共 **58** 项通过;连跑 3 次稳定。
+
+## 12. 三次复核返工(2026-10-21)
+
+集成复核 `docs/migrations/M01-M03-review.md` 第二次结论后,按 3 个问题修正:
+
+| 问题 | 处理 |
+| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
+| P1 Enter 重复激活 | **已修**:仅在 keydown **bubble** 合成一次激活;keyup 与 capture 只做禁用拦截,不再合成。完整 Enter 按下/松开只触发 1 次 click 语义 |
+| P2 无法取消键盘激活 | **已修**:先执行调用方 keydown(含 capture),若 `preventDefault` 或 `stopImmediatePropagation` 则不合成;取消在 capture/bubble 均有效 |
+| P2 数组丢失中断语义 | **已修**:`callHandlers` 包装 `stopImmediatePropagation`,数组内后续处理器不再执行 |
+
+附带根因:嵌套 `el.click()` 在 Primitive/Slot 下 Vue 的 bubble `onClick` 可能不触发;键盘激活改为**直接按 click 顺序调用** `onClickCapture` → `onClick`(与 RAC onPress 类似),可被 keydown 取消,且不依赖嵌套 DOM click。事件处理器在触发时从 `attrs` 读取,避免 computed 快照丢失。
+
+回归:完整按键序列、preventDefault/capture 取消、数组 `stopImmediatePropagation`。`pnpm test` **63** 项通过(连跑 10 次);typecheck、format、build:docs 通过。
+
+## 13. 四次复核返工:真实 DOM click(2026-10-21)
+
+集成复核指出键盘激活不能直接调用回调。已改为**真实派发 click**:
+
+| 问题 | 处理 |
+| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
+| 插槽/祖先收不到 click | `el.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }))`,插槽 `@click`、祖先 capture/bubble 均可达 |
+| target/currentTarget 为 null | 真实事件派发,二者均为触发元素 |
+| capture `preventDefault` 误当停传 | 不再在合成路径上把 `defaultPrevented` 当停止传播;原生事件语义保持 |
+
+**根因**:Vue `createInvoker` 在 `e._vts <= invoker.attached` 时跳过处理器;同一同步轮次创建的 invoker 共用 `getNow()` 时间戳。嵌套/合成 click 时先到的 Vue capture 设置 `_vts` 后,同毫秒的 bubble/插槽监听器被跳过。派发前将 `_vts` 设为 `Date.now() + 1`,保证所有 Vue 监听器执行。
+
+回归:完整 Enter 仅一次激活;keydown/capture 可取消;target/currentTarget;插槽与祖先 click;capture 仅 `preventDefault` 不阻断 bubble;原生 `a` 不重复激活;数组 `stopImmediatePropagation`。
+
+`pnpm test` **67** 项通过(文件 20 次 + 全量 15 次稳定);typecheck、format、build:docs 通过。
diff --git a/docs/upstream.md b/docs/upstream.md
index 8ffdc2d..9e0e7e5 100644
--- a/docs/upstream.md
+++ b/docs/upstream.md
@@ -3,16 +3,18 @@
- 项目:https://github.com/heroui-inc/heroui
- 基线版本:3.2.6
- 提交:ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960
-- 本次更新:2026-10-20
+- 本次更新:2026-10-21
## 已移植
-- packages/styles/components/{button,close-button,card,input,switch,switch-group,label,description}.css:只将组件类名加 hv- 前缀;Vue 状态适配集中在样式入口和组件层。
+- packages/styles/components/{button,close-button,card,input,textarea,switch,switch-group,label,description,surface,link,spinner}.css:只将组件类名加 hv- 前缀;Vue 状态适配集中在样式入口和组件层。
- packages/styles/themes/default/variables.css、themes/shared/theme.css:主题变量、OKLCH 颜色、派生公式和圆角尺寸。
- packages/styles/utilities、variants:焦点、禁用、减少动画等构建规则。
-- packages/styles/src/components/{button,card,input,switch}/*.styles.ts:变体与类名映射,增加命名空间。
-- apps/docs/content/docs/cn/react/components 下相应四个组件的标题、说明、示例顺序和 API 描述;React 特有部分转换为 Vue 用法。
-- apps/docs/src/demos/cn 下Button/Card/Input/Switch 全部基线示例的文案与布局;文档由新项目 SFC 实现。
+- packages/styles/src/components/{button,card,input,textarea,switch,surface,link,spinner}/*.styles.ts:变体与类名映射,增加命名空间。
+- apps/docs/content/docs/cn/react/components 下 Button/Card/Input/Switch/Surface/Link/Spinner 的标题、说明、示例顺序和 API 描述;React 特有部分转换为 Vue 用法。
+- apps/docs/src/demos/cn 下 Button/Card/Input/Switch/Surface/Link/Spinner 文档引用的基线示例文案与布局;文档由新项目 SFC 实现。
+- packages/react/src/components/icons.tsx 的 ExternalLinkIcon:LinkIcon 默认外部箭头图标。
+- packages/react/src/components/spinner/spinner.tsx 的 SpinnerPrimitive SVG(渐变路径)。
- apps/docs/public/fonts/Inter-{Regular,Medium,Bold}.ttf:文档字体资源。
## 来源声明
@@ -23,7 +25,11 @@
## 本批文档适配
-- Card 的头像使用已安装 Reka Avatar 的加载和 fallback 机制;图片沿用上游 CDN URL,不复制媒体文件。Link 使用原生 a,关闭按钮使用原生 button、closeButtonVariants 与基线 CloseButton CSS 组合;这些依赖不标记为库的已实现组件。
-- Card 表单使用原生 form/label 与 Input 组合,提交仅展示本地反馈,不实现登录与密码找回服务。
+- Card 的头像使用已安装 Reka Avatar 的加载和 fallback 机制;图片沿用上游 CDN URL,不复制媒体文件。关闭按钮使用原生 button、closeButtonVariants 与基线 CloseButton CSS 组合;Vue CloseButton 组件尚未实现。
+- Card 链接使用本库 Link + LinkIcon(默认基线图标);关闭按钮仍为原生组合。
+- Card 表单使用原生 form/label 与 Input 组合,提交仅展示本地反馈,不实现登录与密码找回服务。忘记密码链接使用 Link 与本地反馈。
- SwitchGroup 的方向布局 CSS 来自同一基线。Switch 的 native/ARIA 校验、表单 checkbox、reset、属性与事件透传由 Vue 状态层实现;FieldError 暂仅接入 Switch。
+- Surface 搭配表单示例使用 Input 与 TextArea 的 secondary 变体;TextArea 为本批为演示移植的最小实现。
+- Link 自定义图标示例将上游 `@gravity-ui/icons` 的 ArrowUpRightFromSquare / Link 替换为 Tabler `IconExternalLink` / `IconLink`(MIT),与项目图标约定一致。
+- Spinner 内部 SVG 来自基线 SpinnerPrimitive,不属于演示图标;Button 加载示例改用 Spinner(`color="current" size="sm"`),与上游 CN loading 示例一致。
- 图标统一使用 @tabler/icons-vue(MIT)的官方组件,未移植 React 图标依赖;尚未完成自动逐像素对比。
diff --git a/docs/verification.md b/docs/verification.md
index 09303f8..73ea47d 100644
--- a/docs/verification.md
+++ b/docs/verification.md
@@ -70,3 +70,14 @@
- 修复独立 utilities.css 缺少库 @theme inline 映射的问题。此前 accent/surface 等自定义颜色工具类没有生成,计算样式中渐变为 none、光晕与标签背景为透明。现在显式导入本库主题映射。
- 把通用预览 max-width:100% 约束放入 components 层,恢复 utilities 层 max-w-md 的优先级;桌面计算宽度由 654px 恢复为 448px。
- 实际浏览器分别验证浅色与深色:渐变、边框透明度、光晕、推荐标签背景及按钮 accent 阴影均存在,页面无水平溢出。未宣称自动逐像素对比通过。
+
+## Surface / Link / Spinner 迁移验证(M01–M03)
+
+验证日期:2026-10-21。开发地址 `http://127.0.0.1:5173`,桌面视口,IAB 浏览器。
+
+- `pnpm test`:7 个测试文件、51 项全部通过(新增 14 项 Surface/Link/Spinner/TextArea 行为测试;清单测试覆盖 Surface 4、Link 6、Spinner 5)。
+- `pnpm typecheck` 通过;`pnpm build:docs`(含 styles + components + VitePress)通过;`pnpm format` 通过。
+- Surface:浅色计算背景分别为 default `oklch(1 0 0)`、secondary `oklch(0.9524…)`、tertiary `oklch(0.9373…)`、transparent `rgba(0,0,0,0)`;深色切换后为 `oklch(0.2103…)` / `0.257` / `0.2721` / transparent。自定义样式示例渐变 `linear-gradient(to right bottom, accent/8, surface, surface-secondary)` 与 `border-accent/15` 生效。表单示例内 Input/TextArea 均为 secondary 变体。
+- Link:`underline` / `no-underline` / `underline-offset-1..4` 计算值正确;默认图标 `data-default-icon` 与内置 SVG;自定义图标为 Tabler 且无 default 标记;asChild 渲染 `span[data-custom=foo]` 并合并 href 与 link 类。修复文档全局 `a { text-decoration: none }` 未入层导致 utility 下划线被覆盖的问题(改入 `@layer base`)。
+- Spinner:尺寸 sm/md/lg/xl = 16/24/32/40px;颜色 current/accent/success/warning/danger 映射主题变量;`role="status"`、`aria-label="Loading"`、内部 SVG `aria-hidden` 与 viewBox;动画 `spin 0.75s`。Button 加载示例内 Spinner 为 16px,按钮 `data-pending` / `aria-busy`。
+- Card 页面三处链接已改为 Link/LinkIcon。IAB 截图接口超时,未能保存本轮位图证据;以上为 DOM/计算样式记录,不等同于逐像素视觉验收。
diff --git a/package.json b/package.json
index 6bc2851..6423d17 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
"build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build",
"typecheck": "vue-tsc --noEmit",
"test": "vitest run",
- "test:unit": "vitest run tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts",
+ "test:unit": "vitest run tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts",
"test:ssr": "vitest run tests/ssr.test.ts",
"format": "prettier --check .",
"format:fix": "prettier --write .",
diff --git a/packages/styles/components/link.css b/packages/styles/components/link.css
new file mode 100644
index 0000000..32a7ed8
--- /dev/null
+++ b/packages/styles/components/link.css
@@ -0,0 +1,82 @@
+/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
+ * See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
+
+/* Base link styles */
+.hv-link {
+ @apply relative inline-flex h-fit w-fit items-center rounded-xl font-medium text-link no-underline decoration-separator-tertiary decoration-[1.5px] underline-offset-4 no-highlight;
+
+ /**
+ * Transitions
+ * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
+ */
+ transition:
+ color 100ms var(--ease-smooth),
+ background-color 150ms var(--ease-smooth),
+ box-shadow 150ms var(--ease-out),
+ opacity 100ms var(--ease-out);
+ @apply motion-reduce:transition-none;
+
+ /* Cursor */
+ cursor: var(--cursor-interactive);
+
+ /* Hover state */
+ @media (hover: hover) {
+ &:hover,
+ &[data-hovered="true"] {
+ @apply underline decoration-muted/50;
+
+ .hv-link__icon {
+ @apply opacity-100;
+ }
+ }
+ }
+
+ /* Pressed state */
+ &:active,
+ &[data-pressed="true"] {
+ @apply underline decoration-muted;
+
+ .hv-link__icon {
+ @apply opacity-100;
+ }
+ }
+
+ /* Focus state */
+ &:focus-visible:not([data-focused]),
+ &[data-focus-visible="true"] {
+ @apply status-focused;
+
+ .hv-link__icon {
+ @apply opacity-100;
+ }
+ }
+
+ /* Disabled state */
+ &[aria-disabled="true"] {
+ @apply status-disabled;
+ }
+
+ .hv-link__icon {
+ @apply pointer-events-none inline-flex size-[0.75em] shrink-0 items-center justify-center text-current opacity-60;
+
+ /**
+ * Transitions
+ * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
+ */
+ transition: opacity 150ms var(--ease-out);
+ @apply motion-reduce:transition-none;
+
+ & svg {
+ @apply transform-gpu;
+ }
+ }
+
+ .hv-link__icon[data-default-icon="true"] {
+ @apply ms-1 pb-1.5;
+ }
+
+ /* Handle Link with Button Variants */
+ &.hv-button {
+ @apply gap-0 no-underline;
+ }
+}
diff --git a/packages/styles/components/spinner.css b/packages/styles/components/spinner.css
new file mode 100644
index 0000000..f6e28c2
--- /dev/null
+++ b/packages/styles/components/spinner.css
@@ -0,0 +1,50 @@
+/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
+ * See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
+
+/* Base spinner styles */
+.hv-spinner {
+ @apply pointer-events-none inline-flex size-6 shrink-0 animate-spin-fast motion-reduce:animate-none;
+}
+
+/* Size variants */
+.hv-spinner--sm {
+ @apply size-4;
+}
+
+.hv-spinner--md {
+ /* No styles as this is the default size */
+}
+
+.hv-spinner--lg {
+ @apply size-8;
+}
+
+.hv-spinner--xl {
+ @apply size-10;
+}
+
+/* Color variants */
+.hv-spinner--current {
+ color: inherit;
+}
+
+.hv-spinner--accent {
+ color: var(--accent);
+}
+
+.hv-spinner--danger {
+ color: var(--danger);
+}
+
+.hv-spinner--success {
+ color: var(--success);
+}
+
+.hv-spinner--warning {
+ color: var(--warning);
+}
+
+/* Spinner icon fills the host box; excluded from generic button SVG sizing via data-slot. */
+.hv-spinner > svg {
+ @apply size-full;
+}
diff --git a/packages/styles/components/surface.css b/packages/styles/components/surface.css
new file mode 100644
index 0000000..4c2b8ea
--- /dev/null
+++ b/packages/styles/components/surface.css
@@ -0,0 +1,26 @@
+/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
+ * See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
+
+/* Surface component styles */
+
+/* Block */
+.hv-surface {
+ @apply relative text-foreground;
+}
+
+/* Modifier - variant */
+.hv-surface--transparent {
+ @apply bg-transparent;
+}
+
+.hv-surface--default {
+ @apply bg-surface text-surface-foreground;
+}
+
+.hv-surface--secondary {
+ @apply bg-surface-secondary text-surface-secondary-foreground;
+}
+
+.hv-surface--tertiary {
+ @apply bg-surface-tertiary text-surface-tertiary-foreground;
+}
diff --git a/packages/styles/components/textarea.css b/packages/styles/components/textarea.css
new file mode 100644
index 0000000..0cdd840
--- /dev/null
+++ b/packages/styles/components/textarea.css
@@ -0,0 +1,91 @@
+/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
+ * See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
+
+/* use textarea instead of text-area to avoid conflict with Tailwind `text-` prefix */
+.hv-textarea {
+ @apply rounded-field border bg-field px-3 py-2 text-base text-field-foreground shadow-field outline-none placeholder:text-field-placeholder sm:text-sm;
+
+ min-height: 38px;
+
+ border-width: var(--border-width-field);
+ border-color: var(--field-border);
+
+ /**
+ * Transitions
+ * CRITICAL: motion-reduce must be AFTER transition for correct override specificity
+ */
+ transition:
+ background-color 150ms var(--ease-smooth),
+ border-color 150ms var(--ease-smooth),
+ box-shadow 150ms var(--ease-out);
+ @apply motion-reduce:transition-none;
+
+ @media (hover: hover) {
+ &:hover:not(:focus):not(:focus-visible),
+ &[data-hovered="true"]:not([data-focused="true"]):not(
+ [data-focus-visible="true"]
+ ) {
+ @apply bg-field-hover;
+ border-color: var(--field-border-hover);
+ }
+ }
+
+ /* Focus state */
+ &:focus,
+ &[data-focused="true"] {
+ @apply status-focused-field;
+ border-color: var(--field-border-focus);
+ background-color: var(--field-focus);
+ }
+
+ &[data-invalid="true"] {
+ @apply status-invalid-field;
+ background-color: var(--field-focus);
+ }
+
+ /* Disabled state */
+ &:disabled,
+ &[data-disabled="true"],
+ &[aria-disabled="true"] {
+ @apply status-disabled;
+ }
+}
+
+/* Variant property definitions */
+.hv-textarea--primary {
+ /* Default styles */
+}
+
+.hv-textarea--secondary {
+ @apply shadow-none;
+ background-color: var(--textarea-bg);
+
+ --textarea-bg: var(--default);
+ --textarea-bg-hover: var(--default-hover);
+ --textarea-bg-focus: var(--default);
+
+ @media (hover: hover) {
+ &:hover:not(:focus):not(:focus-visible),
+ &[data-hovered="true"]:not([data-focused="true"]):not(
+ [data-focus-visible="true"]
+ ) {
+ background-color: var(--textarea-bg-hover);
+ }
+ }
+
+ &:focus,
+ &[data-focused="true"] {
+ background-color: var(--textarea-bg-focus);
+ }
+
+ /* Invalid state */
+ &[data-invalid="true"] {
+ @apply status-invalid-field;
+ background-color: var(--textarea-bg-focus);
+ }
+}
+
+/* Full width modifier */
+.hv-textarea--full-width {
+ @apply w-full;
+}
diff --git a/packages/styles/index.css b/packages/styles/index.css
index 0ecfbc4..9fc6a00 100644
--- a/packages/styles/index.css
+++ b/packages/styles/index.css
@@ -9,10 +9,14 @@
@import "./components/close-button.css" layer(components);
@import "./components/card.css" layer(components);
@import "./components/input.css" layer(components);
+@import "./components/textarea.css" layer(components);
@import "./components/switch.css" layer(components);
@import "./components/switch-group.css" layer(components);
@import "./components/label.css" layer(components);
@import "./components/description.css" layer(components);
+@import "./components/surface.css" layer(components);
+@import "./components/link.css" layer(components);
+@import "./components/spinner.css" layer(components);
/* The Vue Switch uses Reka's native button for its clickable content. */
@layer components {
.hv-switch:has(.hv-switch__content:focus-visible) .hv-switch__control {
@@ -24,24 +28,6 @@
padding: 0;
font: inherit;
}
- .hv-spinner {
- width: 1em;
- height: 1em;
- border: 2px solid currentColor;
- border-right-color: transparent;
- border-radius: 50%;
- animation: hv-spin 0.75s linear infinite;
- }
- @keyframes hv-spin {
- to {
- transform: rotate(360deg);
- }
- }
- @media (prefers-reduced-motion: reduce) {
- .hv-spinner {
- animation: none;
- }
- }
}
@layer components {
diff --git a/packages/styles/src/index.ts b/packages/styles/src/index.ts
index 63d24e2..6e17397 100644
--- a/packages/styles/src/index.ts
+++ b/packages/styles/src/index.ts
@@ -127,3 +127,74 @@ export const closeButtonVariants = tv({
variants: { variant: { default: "hv-close-button--default" } },
});
export type CloseButtonVariants = VariantProps;
+
+export const surfaceVariants = tv({
+ base: "hv-surface",
+ defaultVariants: {
+ variant: "default",
+ },
+ variants: {
+ variant: {
+ default: "hv-surface--default",
+ secondary: "hv-surface--secondary",
+ tertiary: "hv-surface--tertiary",
+ transparent: "hv-surface--transparent",
+ },
+ },
+});
+
+export type SurfaceVariants = VariantProps;
+
+export const linkVariants = tv({
+ slots: {
+ base: "hv-link",
+ icon: "hv-link__icon",
+ },
+});
+
+export type LinkVariants = VariantProps;
+
+export const spinnerVariants = tv({
+ base: "hv-spinner",
+ defaultVariants: {
+ color: "accent",
+ size: "md",
+ },
+ variants: {
+ color: {
+ accent: "hv-spinner--accent",
+ current: "hv-spinner--current",
+ danger: "hv-spinner--danger",
+ success: "hv-spinner--success",
+ warning: "hv-spinner--warning",
+ },
+ size: {
+ lg: "hv-spinner--lg",
+ md: "hv-spinner--md",
+ sm: "hv-spinner--sm",
+ xl: "hv-spinner--xl",
+ },
+ },
+});
+
+export type SpinnerVariants = VariantProps;
+
+export const textAreaVariants = tv({
+ base: "hv-textarea",
+ defaultVariants: {
+ fullWidth: false,
+ variant: "primary",
+ },
+ variants: {
+ fullWidth: {
+ false: "",
+ true: "hv-textarea--full-width",
+ },
+ variant: {
+ primary: "hv-textarea--primary",
+ secondary: "hv-textarea--secondary",
+ },
+ },
+});
+
+export type TextAreaVariants = VariantProps;
diff --git a/packages/vue/src/components/button/Button.vue b/packages/vue/src/components/button/Button.vue
index 6ceb7f9..10b83c6 100644
--- a/packages/vue/src/components/button/Button.vue
+++ b/packages/vue/src/components/button/Button.vue
@@ -3,6 +3,7 @@ import { computed, ref, watch } from "vue";
import { Primitive } from "reka-ui";
import type { ButtonHTMLAttributes } from "vue";
import { buttonVariants, type ButtonVariants } from "@heroui-vue/styles";
+import Spinner from "../spinner/Spinner.vue";
defineOptions({ inheritAttrs: false });
const props = withDefaults(
defineProps<{
@@ -80,7 +81,12 @@ function focus(e: FocusEvent) {
pressed = false;
"
>
-
+
+import {
+ provide,
+ ref,
+ computed,
+ useAttrs,
+ onMounted,
+ onBeforeUnmount,
+} from "vue";
+import { Primitive } from "reka-ui";
+import { linkVariants } from "@heroui-vue/styles";
+import { linkContextKey } from "./context";
+
+defineOptions({ inheritAttrs: false });
+
+const props = withDefaults(
+ defineProps<{
+ href?: string;
+ target?: string;
+ rel?: string;
+ download?: boolean | string;
+ isDisabled?: boolean;
+ asChild?: boolean;
+ autoFocus?: boolean;
+ }>(),
+ {
+ target: "_self",
+ isDisabled: false,
+ asChild: false,
+ },
+);
+
+const slots = linkVariants();
+provide(linkContextKey, { slots });
+
+const attrs = useAttrs();
+const hovered = ref(false),
+ pressed = ref(false),
+ focused = ref(false),
+ focusVisible = ref(false);
+
+const element = ref();
+
+function resolveElement(raw: unknown): HTMLElement | undefined {
+ if (raw instanceof HTMLElement) return raw;
+ if (raw && typeof raw === "object") {
+ const el = (raw as { $el?: unknown }).$el;
+ if (el instanceof HTMLElement) return el;
+ }
+ return undefined;
+}
+
+type MaybeHandlers =
+ ((e: Event) => void) | Array<(e: Event) => void> | undefined | null;
+
+const immediateStopped = new WeakSet();
+
+function wasImmediateStopped(e: Event) {
+ return immediateStopped.has(e);
+}
+
+/** Invoke caller handlers (fn or Vue-merged array), honoring stopImmediatePropagation. */
+function callHandlers(handlers: MaybeHandlers, e: Event) {
+ const original = e.stopImmediatePropagation;
+ e.stopImmediatePropagation = function stopImmediatePropagationPatched(
+ this: Event,
+ ) {
+ immediateStopped.add(e);
+ original.call(e);
+ };
+ try {
+ if (typeof handlers === "function") {
+ handlers(e);
+ return;
+ }
+ if (Array.isArray(handlers)) {
+ for (const handler of handlers) {
+ if (wasImmediateStopped(e)) break;
+ if (typeof handler === "function") handler(e);
+ }
+ }
+ } finally {
+ e.stopImmediatePropagation = original;
+ }
+}
+
+function isActivationKey(e: KeyboardEvent) {
+ return e.key === "Enter" || e.key === " " || e.key === "Spacebar";
+}
+
+function isEnterKey(e: KeyboardEvent) {
+ return e.key === "Enter" || e.code === "Enter" || e.keyCode === 13;
+}
+
+function isNativeLinkTarget(el: EventTarget | null) {
+ if (!(el instanceof HTMLElement)) return false;
+ const tag = el.tagName;
+ return (
+ tag === "A" ||
+ tag === "BUTTON" ||
+ tag === "INPUT" ||
+ tag === "TEXTAREA" ||
+ tag === "SELECT" ||
+ el.isContentEditable === true
+ );
+}
+
+function liveAttr(name: string): MaybeHandlers {
+ return (attrs as Record)[name] as MaybeHandlers;
+}
+
+function guardClick(e: Event, parent: MaybeHandlers) {
+ if (props.isDisabled) {
+ e.preventDefault();
+ e.stopImmediatePropagation();
+ return;
+ }
+ callHandlers(parent, e);
+}
+
+/** Disabled-only gate for key events that must not synthesize activation. */
+function guardKeyPassthrough(e: Event, parent: MaybeHandlers) {
+ const ke = e as KeyboardEvent;
+ if (props.isDisabled && isActivationKey(ke)) {
+ ke.preventDefault();
+ ke.stopImmediatePropagation();
+ return;
+ }
+ callHandlers(parent, e);
+}
+
+function guardKeydownBubble(e: Event, parent: MaybeHandlers) {
+ const ke = e as KeyboardEvent;
+ if (props.isDisabled && isActivationKey(ke)) {
+ ke.preventDefault();
+ ke.stopImmediatePropagation();
+ return;
+ }
+ callHandlers(parent, e);
+ if (
+ !props.asChild ||
+ props.isDisabled ||
+ !isEnterKey(ke) ||
+ ke.defaultPrevented ||
+ wasImmediateStopped(e)
+ ) {
+ return;
+ }
+ const el =
+ element.value ??
+ (e.currentTarget instanceof HTMLElement ? e.currentTarget : undefined);
+ if (!el || isNativeLinkTarget(el)) return;
+ ke.preventDefault();
+ // Real DOM click (target/currentTarget, slot + ancestor propagation).
+ // Vue invokers skip events when e._vts <= invoker.attached, and invokers
+ // created in the same turn share one timestamp — which drops later listeners
+ // on a nested dispatch. Seed a strictly later _vts so every Vue handler runs.
+ const clickEvent = new MouseEvent("click", {
+ bubbles: true,
+ cancelable: true,
+ });
+ (clickEvent as unknown as { _vts: number })._vts = Date.now() + 1;
+ el.dispatchEvent(clickEvent);
+}
+
+// Non-event attrs only; click/keydown are bound natively so nested
+// el.click() during keydown still runs capture and bubble listeners.
+const passthroughAttrs = computed(() => {
+ const {
+ onClick: _onClick,
+ onClickCapture: _onClickCapture,
+ onKeydown: _onKeydown,
+ onKeydownCapture: _onKeydownCapture,
+ onKeyup: _onKeyup,
+ ...rest
+ } = attrs as Record;
+ return rest;
+});
+
+const onRootClickCapture = (e: Event) =>
+ guardClick(e, liveAttr("onClickCapture"));
+const onRootClickBubble = (e: Event) => guardClick(e, liveAttr("onClick"));
+const onRootKeydownCapture = (e: Event) =>
+ guardKeyPassthrough(e, liveAttr("onKeydownCapture"));
+const onRootKeydownBubble = (e: Event) =>
+ guardKeydownBubble(e, liveAttr("onKeydown"));
+const onRootKeyup = (e: Event) => guardKeyPassthrough(e, liveAttr("onKeyup"));
+
+let bound: HTMLElement | null = null;
+
+function unbindRoot() {
+ if (!bound) return;
+ bound.removeEventListener("click", onRootClickCapture, true);
+ bound.removeEventListener("click", onRootClickBubble, false);
+ bound.removeEventListener("keydown", onRootKeydownCapture, true);
+ bound.removeEventListener("keydown", onRootKeydownBubble, false);
+ bound.removeEventListener("keyup", onRootKeyup, false);
+ bound = null;
+}
+
+function bindRoot(el: HTMLElement) {
+ if (bound === el) return;
+ unbindRoot();
+ bound = el;
+ el.addEventListener("click", onRootClickCapture, true);
+ el.addEventListener("click", onRootClickBubble, false);
+ el.addEventListener("keydown", onRootKeydownCapture, true);
+ el.addEventListener("keydown", onRootKeydownBubble, false);
+ el.addEventListener("keyup", onRootKeyup, false);
+}
+
+function setRoot(raw: unknown) {
+ const el = resolveElement(raw);
+ element.value = el;
+ if (el) bindRoot(el);
+ else unbindRoot();
+}
+
+function focus(e: FocusEvent) {
+ focused.value = true;
+ focusVisible.value = (e.target as HTMLElement).matches(":focus-visible");
+}
+
+const downloadAttr = computed(() => {
+ if (props.download === undefined || props.download === false)
+ return undefined;
+ return props.download === true ? "" : props.download;
+});
+
+onMounted(() => {
+ if (element.value) bindRoot(element.value);
+ if (props.autoFocus) element.value?.focus();
+});
+
+onBeforeUnmount(() => {
+ unbindRoot();
+});
+
+defineExpose({
+ element,
+ focus: () => element.value?.focus(),
+});
+
+
+
+
+
+
+
diff --git a/packages/vue/src/components/link/LinkIcon.vue b/packages/vue/src/components/link/LinkIcon.vue
new file mode 100644
index 0000000..3d1c2b6
--- /dev/null
+++ b/packages/vue/src/components/link/LinkIcon.vue
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/vue/src/components/link/context.ts b/packages/vue/src/components/link/context.ts
new file mode 100644
index 0000000..6cf575c
--- /dev/null
+++ b/packages/vue/src/components/link/context.ts
@@ -0,0 +1,9 @@
+import type { InjectionKey } from "vue";
+import type { linkVariants } from "@heroui-vue/styles";
+
+export interface LinkContext {
+ slots: ReturnType;
+}
+
+export const linkContextKey: InjectionKey =
+ Symbol("HeroUIVue.Link");
diff --git a/packages/vue/src/components/spinner/Spinner.vue b/packages/vue/src/components/spinner/Spinner.vue
new file mode 100644
index 0000000..b2f8970
--- /dev/null
+++ b/packages/vue/src/components/spinner/Spinner.vue
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
diff --git a/packages/vue/src/components/surface/Surface.vue b/packages/vue/src/components/surface/Surface.vue
new file mode 100644
index 0000000..ee0173e
--- /dev/null
+++ b/packages/vue/src/components/surface/Surface.vue
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
diff --git a/packages/vue/src/components/surface/context.ts b/packages/vue/src/components/surface/context.ts
new file mode 100644
index 0000000..e45d5b0
--- /dev/null
+++ b/packages/vue/src/components/surface/context.ts
@@ -0,0 +1,9 @@
+import type { ComputedRef, InjectionKey } from "vue";
+import type { SurfaceVariants } from "@heroui-vue/styles";
+
+export interface SurfaceContext {
+ variant: ComputedRef;
+}
+
+export const surfaceContextKey: InjectionKey =
+ Symbol("HeroUIVue.Surface");
diff --git a/packages/vue/src/components/textarea/TextArea.vue b/packages/vue/src/components/textarea/TextArea.vue
new file mode 100644
index 0000000..4510cf8
--- /dev/null
+++ b/packages/vue/src/components/textarea/TextArea.vue
@@ -0,0 +1,79 @@
+
+
+
+
+
diff --git a/packages/vue/src/index.ts b/packages/vue/src/index.ts
index 6a4e75b..e981f86 100644
--- a/packages/vue/src/index.ts
+++ b/packages/vue/src/index.ts
@@ -18,10 +18,18 @@ export {
cardVariants,
inputVariants,
switchVariants,
+ surfaceVariants,
+ linkVariants,
+ spinnerVariants,
+ textAreaVariants,
type ButtonVariants,
type CardVariants,
type InputVariants,
type SwitchVariants,
+ type SurfaceVariants,
+ type LinkVariants,
+ type SpinnerVariants,
+ type TextAreaVariants,
} from "@heroui-vue/styles";
export type {
ButtonProps,
@@ -30,9 +38,24 @@ export type {
SwitchProps,
SwitchGroupProps,
LabelProps,
+ SurfaceProps,
+ LinkProps,
+ LinkIconProps,
+ SpinnerProps,
+ TextAreaProps,
} from "./types";
export { tv, cn, type VariantProps } from "@heroui-vue/styles";
export { default as SwitchGroup } from "./components/switch/SwitchGroup.vue";
export { default as FieldError } from "./components/switch/FieldError.vue";
+
+export { default as Surface } from "./components/surface/Surface.vue";
+export {
+ surfaceContextKey,
+ type SurfaceContext,
+} from "./components/surface/context";
+export { default as Link } from "./components/link/Link.vue";
+export { default as LinkIcon } from "./components/link/LinkIcon.vue";
+export { default as Spinner } from "./components/spinner/Spinner.vue";
+export { default as TextArea } from "./components/textarea/TextArea.vue";
diff --git a/packages/vue/src/types.ts b/packages/vue/src/types.ts
index 8548428..d94628d 100644
--- a/packages/vue/src/types.ts
+++ b/packages/vue/src/types.ts
@@ -2,11 +2,21 @@ import type Button from "./components/button/Button.vue";
import type Card from "./components/card/Card.vue";
import type Input from "./components/input/Input.vue";
import type Switch from "./components/switch/Switch.vue";
+import type Surface from "./components/surface/Surface.vue";
+import type Link from "./components/link/Link.vue";
+import type LinkIcon from "./components/link/LinkIcon.vue";
+import type Spinner from "./components/spinner/Spinner.vue";
+import type TextArea from "./components/textarea/TextArea.vue";
export type ButtonProps = InstanceType["$props"];
export type CardProps = InstanceType["$props"];
export type InputProps = InstanceType["$props"];
export type SwitchProps = InstanceType["$props"];
+export type SurfaceProps = InstanceType["$props"];
+export type LinkProps = InstanceType["$props"];
+export type LinkIconProps = InstanceType["$props"];
+export type SpinnerProps = InstanceType["$props"];
+export type TextAreaProps = InstanceType["$props"];
import type SwitchGroup from "./components/switch/SwitchGroup.vue";
import type Label from "./components/label/Label.vue";
diff --git a/tests/aligned-components.test.ts b/tests/aligned-components.test.ts
index c48ab07..f73c7a2 100644
--- a/tests/aligned-components.test.ts
+++ b/tests/aligned-components.test.ts
@@ -34,6 +34,16 @@ const inventory = {
"controlled",
"custom-styles",
],
+ link: [
+ "basic",
+ "icon-placement",
+ "underline-and-offset",
+ "custom-icon",
+ "render-function",
+ "custom-styles",
+ ],
+ spinner: ["basic", "colors", "sizes", "speed", "custom-styles"],
+ surface: ["basic", "variants", "with-form-components", "custom-styles"],
switch: [
"basic",
"sizes",
diff --git a/tests/ssr.test.ts b/tests/ssr.test.ts
index 3f31a76..81d5395 100644
--- a/tests/ssr.test.ts
+++ b/tests/ssr.test.ts
@@ -2,7 +2,17 @@
import { it, expect } from "vitest";
import { createSSRApp, h } from "vue";
import { renderToString } from "@vue/server-renderer";
-import { Button, Card, Input, Switch } from "../packages/vue/src";
+import {
+ Button,
+ Card,
+ Input,
+ Switch,
+ Surface,
+ Link,
+ LinkIcon,
+ Spinner,
+ TextArea,
+} from "../packages/vue/src";
it("renders the initial components without browser globals", async () => {
const html = await renderToString(
createSSRApp({
@@ -11,10 +21,18 @@ it("renders the initial components without browser globals", async () => {
h(Button, () => "保存"),
h(Input, { modelValue: "名称" }),
h(Switch, { checked: true, "aria-label": "通知" }),
+ h(Surface, { variant: "secondary" }, () => h("span", "表面")),
+ h(Link, { href: "#" }, () => ["链接", h(LinkIcon)]),
+ h(Spinner),
+ h(TextArea, { modelValue: "备注" }),
]),
}),
);
expect(html).toContain("保存");
expect(html).toContain('value="名称"');
expect(html).toContain('role="switch"');
+ expect(html).toContain("hv-surface--secondary");
+ expect(html).toContain('data-slot="link"');
+ expect(html).toContain('role="status"');
+ expect(html).toContain('data-slot="textarea"');
});
diff --git a/tests/surface-link-spinner.test.ts b/tests/surface-link-spinner.test.ts
new file mode 100644
index 0000000..d940a3e
--- /dev/null
+++ b/tests/surface-link-spinner.test.ts
@@ -0,0 +1,540 @@
+import { describe, it, expect } from "vitest";
+import { mount } from "@vue/test-utils";
+import { h, inject, defineComponent, nextTick } from "vue";
+import {
+ Surface,
+ surfaceContextKey,
+ Link,
+ LinkIcon,
+ Spinner,
+ TextArea,
+ Button,
+ Input,
+} from "../packages/vue/src";
+
+describe("Surface", () => {
+ it("applies the default variant and surface data-slot", () => {
+ const w = mount(Surface, {
+ props: { variant: "secondary" },
+ slots: { default: "内容" },
+ });
+ expect(w.classes()).toContain("hv-surface");
+ expect(w.classes()).toContain("hv-surface--secondary");
+ expect(w.attributes("data-slot")).toBe("surface");
+ });
+
+ it("provides the current variant to descendants", () => {
+ let seen: unknown;
+ const Child = defineComponent({
+ setup() {
+ seen = inject(surfaceContextKey)?.variant.value;
+ return () => h("span", "child");
+ },
+ });
+ mount(Surface, {
+ props: { variant: "tertiary" },
+ slots: { default: () => h(Child) },
+ });
+ expect(seen).toBe("tertiary");
+ });
+
+ it("forwards class and DOM attrs to the root", () => {
+ const w = mount(Surface, {
+ props: { variant: "transparent" },
+ attrs: { class: "custom", "data-id": "s1" },
+ slots: { default: "x" },
+ });
+ expect(w.classes()).toContain("hv-surface--transparent");
+ expect(w.classes()).toContain("custom");
+ expect(w.attributes("data-id")).toBe("s1");
+ });
+});
+
+describe("Link", () => {
+ it("renders an anchor with link classes and default icon mark", () => {
+ const w = mount(Link, {
+ props: { href: "https://example.com", target: "_blank" },
+ slots: {
+ default: () => ["立即行动", h(LinkIcon)],
+ },
+ });
+ const a = w.get("a");
+ expect(a.attributes("href")).toBe("https://example.com");
+ expect(a.attributes("target")).toBe("_blank");
+ expect(a.attributes("data-slot")).toBe("link");
+ expect(a.classes()).toContain("hv-link");
+ const icon = w.get("[data-slot=link-icon]");
+ expect(icon.attributes("data-default-icon")).toBe("true");
+ expect(icon.find("[data-slot=link-default-icon]").exists()).toBe(true);
+ });
+
+ it("omits download unless requested", () => {
+ const base = mount(Link, {
+ props: { href: "#", download: false },
+ slots: { default: "x" },
+ });
+ expect(base.get("a").attributes("download")).toBeUndefined();
+ const named = mount(Link, {
+ props: { href: "#", download: "report.pdf" },
+ slots: { default: "x" },
+ });
+ expect(named.get("a").attributes("download")).toBe("report.pdf");
+ });
+
+ it("disables activation and marks aria-disabled", async () => {
+ let clicks = 0;
+ let keydowns = 0;
+ let captureClicks = 0;
+ const w = mount(Link, {
+ props: { href: "#", isDisabled: true },
+ attrs: {
+ onClick: () => clicks++,
+ onClickCapture: () => captureClicks++,
+ onKeydown: () => keydowns++,
+ },
+ slots: { default: "禁用链接" },
+ });
+ const a = w.get("a");
+ expect(a.attributes("aria-disabled")).toBe("true");
+ expect(a.attributes("href")).toBe("#");
+ await a.trigger("click");
+ expect(clicks).toBe(0);
+ expect(captureClicks).toBe(0);
+ await a.trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ await a.trigger("keydown", { key: " " });
+ expect(keydowns).toBe(0);
+ });
+
+ it("still delivers click and keydown to the caller when enabled", async () => {
+ let clicks = 0;
+ let keydowns = 0;
+ const w = mount(Link, {
+ props: { href: "#", isDisabled: false },
+ attrs: {
+ onClick: () => clicks++,
+ onKeydown: () => keydowns++,
+ },
+ slots: { default: "启用链接" },
+ });
+ await w.get("a").trigger("click");
+ await w
+ .get("a")
+ .trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(clicks).toBe(1);
+ expect(keydowns).toBe(1);
+ });
+
+ it("invokes merged listener arrays once per handler", async () => {
+ const calls: string[] = [];
+ const w = mount(Link, {
+ props: { href: "#" },
+ attrs: {
+ onClick: [() => calls.push("a"), () => calls.push("b")],
+ onKeydown: [() => calls.push("k1"), () => calls.push("k2")],
+ },
+ slots: { default: "数组监听" },
+ });
+ await w.get("a").trigger("click");
+ await w
+ .get("a")
+ .trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(calls).toEqual(["a", "b", "k1", "k2"]);
+ });
+
+ it("suppresses merged listener arrays when disabled", async () => {
+ let hits = 0;
+ const w = mount(Link, {
+ props: { href: "#", isDisabled: true },
+ attrs: {
+ onClick: [() => hits++, () => hits++],
+ onClickCapture: [() => hits++],
+ onKeydown: [() => hits++, () => hits++],
+ },
+ slots: { default: "禁用数组" },
+ });
+ await w.get("a").trigger("click");
+ await w
+ .get("a")
+ .trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(hits).toBe(0);
+ });
+
+ it("autoFocus focuses the real DOM anchor", async () => {
+ const w = mount(Link, {
+ props: { href: "#", autoFocus: true },
+ attachTo: document.body,
+ slots: { default: "聚焦我" },
+ });
+ expect(document.activeElement).toBe(w.get("a").element);
+ expect((w.vm as { element?: HTMLElement }).element).toBe(
+ w.get("a").element,
+ );
+ w.unmount();
+ });
+
+ it("gives asChild custom roots link semantics and Enter activation", async () => {
+ let clicks = 0;
+ const w = mount(Link, {
+ props: { href: "#", asChild: true },
+ attrs: { onClick: () => clicks++ },
+ attachTo: document.body,
+ slots: {
+ default: () => h("span", { "data-custom": "foo" }, "自定义链接"),
+ },
+ });
+ const span = w.get("span[data-custom=foo]");
+ expect(span.attributes("role")).toBe("link");
+ expect(span.attributes("tabindex")).toBe("0");
+ expect(span.attributes("href")).toBe("#");
+ await span.trigger("keydown", {
+ key: "Enter",
+ code: "Enter",
+ keyCode: 13,
+ });
+ expect(clicks).toBe(1);
+ const spanEl = span.element as HTMLElement;
+ spanEl.focus();
+ expect(document.activeElement).toBe(spanEl);
+ spanEl.blur();
+ (w.vm as unknown as { focus: () => void }).focus();
+ expect(document.activeElement).toBe(spanEl);
+ w.unmount();
+ });
+
+ it("activates once per full Enter press (keydown + keyup)", async () => {
+ let clicks = 0;
+ const w = mount(Link, {
+ props: { href: "#", asChild: true },
+ attrs: { onClick: () => clicks++ },
+ slots: {
+ default: () => h("span", { "data-custom": "enter-once" }, "一次激活"),
+ },
+ });
+ const span = w.get("span[data-custom=enter-once]");
+ await span.trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ await span.trigger("keyup", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(clicks).toBe(1);
+ w.unmount();
+ });
+
+ it("allows caller preventDefault to cancel keyboard activation", async () => {
+ let clicks = 0;
+ const w = mount(Link, {
+ props: { href: "#", asChild: true },
+ attrs: {
+ onClick: () => clicks++,
+ onKeydown: (e: Event) => e.preventDefault(),
+ },
+ slots: {
+ default: () => h("span", { "data-custom": "cancel-kb" }, "可取消"),
+ },
+ });
+ await w
+ .get("span[data-custom=cancel-kb]")
+ .trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(clicks).toBe(0);
+ w.unmount();
+ });
+
+ it("allows caller capture preventDefault to cancel keyboard activation", async () => {
+ let clicks = 0;
+ const w = mount(Link, {
+ props: { href: "#", asChild: true },
+ attrs: {
+ onClick: () => clicks++,
+ onKeydownCapture: (e: Event) => e.preventDefault(),
+ },
+ slots: {
+ default: () => h("span", { "data-custom": "cancel-cap" }, "捕获取消"),
+ },
+ });
+ await w
+ .get("span[data-custom=cancel-cap]")
+ .trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(clicks).toBe(0);
+ w.unmount();
+ });
+
+ it("dispatches a real click to slot, link and ancestor on Enter", async () => {
+ const order: string[] = [];
+ const w = mount(
+ {
+ components: { Link },
+ setup() {
+ return { order };
+ },
+ template: `
+
+
+ 传播
+
+
+ `,
+ },
+ { attachTo: document.body },
+ );
+ const span = w.get("span[data-custom=propagates]");
+ await span.trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(order).toContain("link");
+ expect(order).toContain("slot");
+ expect(order).toContain("ancestor");
+ w.unmount();
+ });
+
+ it("sets target and currentTarget on keyboard-activated click", async () => {
+ let target: EventTarget | null = null;
+ let current: EventTarget | null = null;
+ const w = mount(Link, {
+ props: { href: "#", asChild: true },
+ attrs: {
+ onClick: (e: Event) => {
+ target = e.target;
+ current = e.currentTarget;
+ },
+ },
+ attachTo: document.body,
+ slots: {
+ default: () => h("span", { "data-custom": "evt-target" }, "目标"),
+ },
+ });
+ const span = w.get("span[data-custom=evt-target]");
+ await span.trigger("keydown", {
+ key: "Enter",
+ code: "Enter",
+ keyCode: 13,
+ });
+ expect(target).toBe(span.element);
+ expect(current).toBe(span.element);
+ w.unmount();
+ });
+
+ it("does not skip bubble when click capture only preventDefaults", async () => {
+ const order: string[] = [];
+ const w = mount(Link, {
+ props: { href: "#", asChild: true },
+ attrs: {
+ onClickCapture: (e: Event) => {
+ order.push("cap");
+ e.preventDefault();
+ },
+ onClick: () => order.push("bubble"),
+ },
+ attachTo: document.body,
+ slots: {
+ default: () => h("span", { "data-custom": "cap-pd" }, "取消默认"),
+ },
+ });
+ await w
+ .get("span[data-custom=cap-pd]")
+ .trigger("keydown", { key: "Enter", code: "Enter", keyCode: 13 });
+ expect(order).toEqual(["cap", "bubble"]);
+ w.unmount();
+ });
+
+ it("does not double-activate native anchors on Enter", async () => {
+ let clicks = 0;
+ const w = mount(Link, {
+ props: { href: "#" },
+ attrs: { onClick: () => clicks++ },
+ slots: { default: "原生锚点" },
+ });
+ await w.get("a").trigger("keydown", {
+ key: "Enter",
+ code: "Enter",
+ keyCode: 13,
+ });
+ expect(clicks).toBe(0);
+ });
+
+ it("stops later array handlers after stopImmediatePropagation", async () => {
+ const calls: string[] = [];
+ const w = mount(Link, {
+ props: { href: "#" },
+ attrs: {
+ onClick: [
+ (e: Event) => {
+ calls.push("first");
+ e.stopImmediatePropagation();
+ },
+ () => calls.push("second"),
+ ],
+ },
+ slots: { default: "中断数组" },
+ });
+ await w.get("a").trigger("click");
+ expect(calls).toEqual(["first"]);
+ });
+
+ it("stops later capture array handlers after stopImmediatePropagation", async () => {
+ const calls: string[] = [];
+ const w = mount(Link, {
+ props: { href: "#" },
+ attrs: {
+ onClickCapture: [
+ (e: Event) => {
+ calls.push("cap-first");
+ e.stopImmediatePropagation();
+ },
+ () => calls.push("cap-second"),
+ ],
+ },
+ slots: { default: "捕获中断" },
+ });
+ await w.get("a").trigger("click");
+ expect(calls).toEqual(["cap-first"]);
+ });
+
+ it("autoFocus works on asChild custom roots", async () => {
+ const w = mount(Link, {
+ props: { href: "#", asChild: true, autoFocus: true },
+ attachTo: document.body,
+ slots: {
+ default: () => h("span", { "data-custom": "focus-me" }, "聚焦"),
+ },
+ });
+ expect(document.activeElement).toBe(
+ w.get("span[data-custom=focus-me]").element,
+ );
+ w.unmount();
+ });
+
+ it("allows activation when enabled and keeps custom icon content", async () => {
+ let clicks = 0;
+ const w = mount(Link, {
+ props: { href: "#" },
+ attrs: { onClick: () => clicks++ },
+ slots: {
+ default: () => [
+ "前往页面",
+ h(LinkIcon, { class: "size-3" }, () =>
+ h("svg", { "data-custom-icon": "true" }),
+ ),
+ ],
+ },
+ });
+ const icon = w.get("[data-slot=link-icon]");
+ expect(icon.attributes("data-default-icon")).toBeUndefined();
+ expect(icon.find("[data-custom-icon]").exists()).toBe(true);
+ await w.get("a").trigger("click");
+ expect(clicks).toBe(1);
+ });
+
+ it("merges asChild onto a custom element", () => {
+ const w = mount(Link, {
+ props: { href: "#", asChild: true },
+ slots: {
+ default: () =>
+ h("span", { "data-custom": "foo" }, ["立即行动", h(LinkIcon)]),
+ },
+ });
+ const span = w.get("span[data-custom=foo]");
+ expect(span.attributes("href")).toBe("#");
+ expect(span.attributes("data-slot")).toBe("link");
+ expect(span.classes()).toContain("hv-link");
+ expect(span.find("[data-slot=link-icon]").exists()).toBe(true);
+ });
+});
+
+describe("Spinner", () => {
+ it("exposes loading semantics and size/color variants", () => {
+ const w = mount(Spinner, { props: { size: "sm", color: "danger" } });
+ expect(w.attributes("role")).toBe("status");
+ expect(w.attributes("aria-label")).toBe("Loading");
+ expect(w.attributes("data-slot")).toBe("spinner");
+ expect(w.classes()).toContain("hv-spinner--sm");
+ expect(w.classes()).toContain("hv-spinner--danger");
+ const svg = w.get("svg[data-slot=spinner-icon]");
+ expect(svg.attributes("aria-hidden")).toBe("true");
+ expect(svg.attributes("viewBox")).toBe("0 0 24 24");
+ });
+
+ it("allows aria overrides and keeps 16px footprint inside Button", async () => {
+ const custom = mount(Spinner, {
+ attrs: { "aria-label": "处理中", role: "presentation" },
+ });
+ expect(custom.attributes("aria-label")).toBe("处理中");
+ expect(custom.attributes("role")).toBe("presentation");
+
+ const button = mount(Button, {
+ props: { loading: true },
+ slots: { default: "上传中…" },
+ });
+ const spinner = button.get("[data-slot=spinner]");
+ expect(spinner.classes()).toContain("hv-spinner--sm");
+ expect(spinner.attributes("aria-hidden")).toBe("true");
+ expect(button.attributes("aria-busy")).toBe("true");
+ });
+
+ it("keeps gradient ids unique across instances", () => {
+ const w = mount({
+ render: () => [h(Spinner), h(Spinner)],
+ });
+ const ids = w.findAll("linearGradient").map((g) => g.attributes("id"));
+ expect(ids.length).toBe(4);
+ expect(new Set(ids).size).toBe(4);
+ });
+});
+
+describe("TextArea", () => {
+ it("emits values without mutating a controlled value", async () => {
+ const w = mount(TextArea, {
+ props: { modelValue: "原值", variant: "secondary" },
+ attrs: { "aria-label": "备注", name: "note" },
+ });
+ expect(w.classes()).toContain("hv-textarea--secondary");
+ await w.get("textarea").setValue("新值");
+ expect(w.emitted("update:modelValue")).toEqual([["新值"]]);
+ await w.setProps({ modelValue: "父级值" });
+ expect(w.element.value).toBe("父级值");
+ });
+
+ it("supports uncontrolled values and native form reset", async () => {
+ const form = document.createElement("form");
+ document.body.append(form);
+ const w = mount(TextArea, {
+ props: { defaultValue: "初始" },
+ attachTo: form,
+ });
+ await w.get("textarea").setValue("编辑");
+ expect(w.element.value).toBe("编辑");
+ form.reset();
+ await nextTick();
+ expect(w.element.value).toBe("初始");
+ w.unmount();
+ form.remove();
+ });
+
+ it("maps invalid state to documented CSS hooks", () => {
+ const w = mount(TextArea, { props: { invalid: true, fullWidth: true } });
+ expect(w.classes()).toContain("hv-textarea--full-width");
+ expect(w.attributes("data-invalid")).toBe("true");
+ expect(w.attributes("aria-invalid")).toBe("true");
+ });
+});
+
+describe("Surface form demo integration", () => {
+ it("renders secondary Input and TextArea inside a Surface", () => {
+ const w = mount({
+ render: () =>
+ h(Surface, { variant: "default" }, () => [
+ h(Input, {
+ placeholder: "使用次要变体的输入框",
+ variant: "secondary",
+ }),
+ h(TextArea, {
+ placeholder: "使用次要变体的文本域",
+ variant: "secondary",
+ }),
+ ]),
+ });
+ expect(w.get("[data-slot=surface]").attributes("data-slot")).toBe(
+ "surface",
+ );
+ expect(w.get("[data-slot=input]").classes()).toContain(
+ "hv-input--secondary",
+ );
+ expect(w.get("[data-slot=textarea]").classes()).toContain(
+ "hv-textarea--secondary",
+ );
+ });
+});