fix(demos): restore form, overlay and toast demos to the pinned cn baseline

HD-02 scope, all against heroui ce90ea3 cn sources:

- card: add the text-primary class to the coin icons (source parity);
  card-with-form drops the added required validation and inline business
  note, restores the plain href="#" forgot-password link and the baseline
  alert("表单提交成功!") submit feedback (autocomplete kept: no visible
  impact, allowed by the task card)
- input-group-with-textarea: restore the four Tooltips and the Enter Kbd
  hint; drop the stale "Tooltip 组件尚未迁移" note from input-group.md
- alert-dialog: restore the h-px top light line in custom-styles and the
  truncated/missing description text in sizes/custom-portal/
  custom-animations (+ controlled); align the fluid-slide icon with the
  modal mapping (IconArrowBarUp for gravity-ui:arrow-up-from-line)
- toast: restore the upstream demo layout shells (variants/simple/
  custom-indicator/custom-queue) and the action button default variant:
  ToastActionButton now falls back to the Button defaults (primary/md)
  like upstream ToastActionButton, so variants' actions render primary,
  danger stays danger and default stays tertiary; toast.md defaults fixed
- submit demos: restore baseline feedback and structure — alert() for
  card/fieldset/form/checkbox/checkbox-group/switch/select/combo-box/
  autocomplete and console.log for search/number/time field form examples;
  modal-with-form returns to the close-only footer (no submit/result row);
  drop the added inline status/result rows and the max-w-full/
  max-sm:min-w-0 width guards from the restored demos
- radio-group-validation: add the missing text-muted to the result line;
  label.md invalid example gives the real control its invalid state and
  matches the baseline input shape

Tests re-pinned to the baseline contracts (alert/console/close behavior,
four tooltips + Kbd, positional modal footer); full suite 110 files /
1617 tests, typecheck, build:docs and the m35-m36 tarball contract pass.
This commit is contained in:
maoyingjie
2026-10-28 14:10:10 +08:00
parent e9760810b8
commit 53e76f676d
53 changed files with 531 additions and 572 deletions
+1 -1
View File
@@ -123,7 +123,7 @@ Fieldset 复合组件暴露以下 CSS 选择器:
三个部件使用对应 BEM 基础类,class 接受字符串、数组和对象。命名导出替代 React 对象式子部件;原生属性直接传递,不使用 nativeProps 对象。根元素固定为语义化原生元素,暂不提供 React render 根元素替换。
Fieldset 不维护字段值或校验队列。请使用 Form + TextField / SearchField,提交与 reset 沿用原生表单;示例展示实际 FormData 与成功反馈,不执行后台保存。
Fieldset 不维护字段值或校验队列。请使用 Form + TextField / SearchField,提交与 reset 沿用原生表单;示例以 `alert` 给出成功反馈,不执行后台保存。
## 相关组件
+24 -24
View File
@@ -80,32 +80,32 @@ import { Form, Button } from "@heroui-vue/components";
Form 复用本库共享字段上下文与浏览器 Constraint Validation API。`FormRoot` 是同一组件别名;原生属性、ARIA、class、style 与 DOM 监听器透传到实际 form。
| Prop / 事件 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| `action` | `string` | - | 提交表单数据的 URL;保留浏览器传统提交 |
| `class` | Vue class 绑定 | - | 应用于 form 元素的布局与样式 |
| 默认插槽 | `() => VNodeChild` | - | 表单内容(字段、按钮等) |
| `enctype` | `string` | - | 原生编码类型,如 `multipart/form-data` |
| `method` | `string` | - | 原生提交方法,如 `get` / `post` |
| `@invalid` | `(event: Event) => void` | - | 每个无效控件每次检查通知一次;`preventDefault()` 取消默认焦点,不放行无效提交 |
| `@reset` | `(event: Event) => void` | - | 原生重置事件;可 `preventDefault()` 取消 |
| `@submit` | `(event: SubmitEvent) => void` | - | 校验通过或显式跳过校验时调用;使用 `.prevent` 接管提交 |
| `target` | `string` | - | 提交后显示响应的位置 |
| `validationBehavior` | `'native' \| 'aria'` | `'native'` | 默认字段校验策略;字段可覆盖 |
| `validationErrors` | `Record<string, string \| string[]>` | `{}` | 按字段名映射的服务端错误;编辑该字段后忽略当前响应中的错误 |
| `aria-label` | `string` | - | 表单的无障碍名称 |
| `aria-labelledby` | `string` | - | 标注表单的元素 ID |
| `novalidate` / `noValidate` | `boolean` | `false`(调用方意图) | 为 `true` 或空属性时跳过本库提交检查;实际 DOM 始终有 novalidate,见下文 |
| `render`(上游) | Vue attrs / 默认插槽替代 | - | 添加原生属性直接透传;不移植 React DOMRenderFunction |
| Prop / 事件 | 类型 | 默认值 | 描述 |
| --------------------------- | ------------------------------------ | --------------------- | ----------------------------------------------------------------------------- |
| `action` | `string` | - | 提交表单数据的 URL;保留浏览器传统提交 |
| `class` | Vue class 绑定 | - | 应用于 form 元素的布局与样式 |
| 默认插槽 | `() => VNodeChild` | - | 表单内容(字段、按钮等) |
| `enctype` | `string` | - | 原生编码类型,如 `multipart/form-data` |
| `method` | `string` | - | 原生提交方法,如 `get` / `post` |
| `@invalid` | `(event: Event) => void` | - | 每个无效控件每次检查通知一次;`preventDefault()` 取消默认焦点,不放行无效提交 |
| `@reset` | `(event: Event) => void` | - | 原生重置事件;可 `preventDefault()` 取消 |
| `@submit` | `(event: SubmitEvent) => void` | - | 校验通过或显式跳过校验时调用;使用 `.prevent` 接管提交 |
| `target` | `string` | - | 提交后显示响应的位置 |
| `validationBehavior` | `'native' \| 'aria'` | `'native'` | 默认字段校验策略;字段可覆盖 |
| `validationErrors` | `Record<string, string \| string[]>` | `{}` | 按字段名映射的服务端错误;编辑该字段后忽略当前响应中的错误 |
| `aria-label` | `string` | - | 表单的无障碍名称 |
| `aria-labelledby` | `string` | - | 标注表单的元素 ID |
| `novalidate` / `noValidate` | `boolean` | `false`(调用方意图) | 为 `true` 或空属性时跳过本库提交检查;实际 DOM 始终有 novalidate,见下文 |
| `render`(上游) | Vue attrs / 默认插槽替代 | - | 添加原生属性直接透传;不移植 React DOMRenderFunction |
公开类型包含 `FormProps`、`FormRootProps`、`FormSlots`、`FormExpose`。实例能力是 Vue 扩展:
| 实例成员 | 类型 | 说明 |
| --- | --- | --- |
| `element` | `HTMLFormElement \| undefined` | 挂载后实际 form |
| `checkValidity()` | `() => boolean` | 按 native/aria 策略检查并产生 invalid;不自动聚焦 |
| `reportValidity()` | `() => boolean` | 检查并聚焦首个无效字段,除非调用方取消;错误由 FieldError 展示,不重复调用原生气泡校验 |
| `reset()` | `() => void` | 调用原生 form.reset(),遵守取消与既有受控值协议 |
| 实例成员 | 类型 | 说明 |
| ------------------ | ------------------------------ | -------------------------------------------------------------------------------------- |
| `element` | `HTMLFormElement \| undefined` | 挂载后实际 form |
| `checkValidity()` | `() => boolean` | 按 native/aria 策略检查并产生 invalid;不自动聚焦 |
| `reportValidity()` | `() => boolean` | 检查并聚焦首个无效字段,除非调用方取消;错误由 FieldError 展示,不重复调用原生气泡校验 |
| `reset()` | `() => void` | 调用原生 form.reset(),遵守取消与既有受控值协议 |
### Form Validation
@@ -174,7 +174,7 @@ Form 与共享字段组件协作:
- 错误通过 FieldError 与真实控件的 ARIA 描述关联。
- `validationBehavior="aria"` 保留错误语义但不阻止提交。
三个预览沿用固定源的字段、文案、校验与布局;为适应窄屏增加 `max-w-full`,提交结果用页内 `status` 替代上游 `alert`,reset 同时清除该反馈。React 专属机制按上述 Vue 方式适配。当前仅支持浏览器客户端;未将完整读屏矩阵或逐像素比较视为已完成。
三个预览沿用固定源的字段、文案、校验、布局与提交反馈:有效提交以 `alert` 展示表单数据,`reset` 重置字段与校验错误。React 专属机制按上述 Vue 方式适配。当前仅支持浏览器客户端;未将完整读屏矩阵或逐像素比较视为已完成。
## 相关案例
-2
View File
@@ -167,8 +167,6 @@ InputGroup 会自动反映父级 TextField 的无效状态。
多行输入请使用 **InputGroupTextArea**,并搭配前缀与后缀。当存在 textarea 时,容器高度会自动适应内容,并将前缀/后缀与顶部对齐。
上游示例中的 Tooltip 由原生 `title` 与 `aria-label` 适配(Tooltip 组件尚未迁移)。
<ComponentPreview name="input-group-with-textarea" />
## 自定义样式
+1 -1
View File
@@ -52,7 +52,7 @@ import { Label, Input } from "@heroui-vue/components";
<template>
<Label for="password" is-invalid>密码</Label>
<Input id="password" type="password" />
<Input id="password" invalid />
</template>
```
+1 -1
View File
@@ -392,7 +392,7 @@ NumberFieldDecrementButton 支持原生 button 属性、事件、`isDisabled`
- FormData 只提交一份未格式化的完整数值,显示货币或百分比不改变提交值。native 校验阻止无效提交;aria 只展示状态。reset 尊重取消,非受控恢复初值,受控保留父值。validate 为同步函数;不提供 RAC validationDetails。
- React render prop 对应默认作用域插槽;class/style 函数改用 Vue 绑定,不支持 React PressEvent。渲染函数示例用 data-custom 透传表达相同默认 div 的自定义属性,不宣称支持任意 React render 回调。
- 增减按钮的 click 可取消;支持指针按住重复、释放/取消/移出清理及键盘激活。默认图标移植上游公共图标,自定义图标示例使用 Tabler Vue。任意非原生交互 asChild 根的键盘语义由调用方负责。
- 校验示例的百分比模型按 0–1 判断(原演示将模型与 0–100 混用);表单示例仅本地模拟提交,反馈与定时器清理不代表真实业务请求。
- 校验示例的百分比模型按 0–1 判断(原演示将模型与 0–100 混用);表单示例与基线一致,仅本地模拟提交并将提交值输出到控制台,定时器清理不代表真实业务请求。
- SSR 关联预规划支持直接部件、原生包装及 NumberFieldGroup。自定义 Vue 包装内部的 ID 请显式指定;完整读屏、触屏及 Nuxt 验收以验证报告为准。
- 上游 Input API 表还列有 variant,但固定实现只从根生成样式;Vue 同样使用根 variant,自定义 Input 外观通过 class/style,不暴露无效的叶子 variant 参数。
+1 -1
View File
@@ -103,7 +103,7 @@ SearchField 组件支持两种视觉变体:
### 表单示例
完整的表单集成示例,包含校验、实际 FormData 和模拟提交反馈;没有后台搜索请求。
完整的表单集成示例,包含校验与模拟提交(提交值输出到控制台);没有后台搜索请求。
<ComponentPreview name="search-field-form-example" />
+1 -1
View File
@@ -341,7 +341,7 @@ Select 组件使用以下 CSS 类([查看源码样式](https://github.com/hero
- 关闭态从已知 ListBox/Section/Item 插槽预规划元数据;不执行任意包装组件的 setup/render。不透明包装请提供 Select 的 `items`,否则首次打开前未知选项只能显示 key,且无法提交未知选项。
- 唯一原生 select 提交层保留字符串边界,多选使用重复 name;类型区分只用于组件值与事件。浏览器自动填充通过选中 option 的索引恢复原始 key,不把内部编码放进 FormData。
- 支持原生必填、重置、Fieldset 与 Form 错误关联;跨浏览器自动填充与实际屏幕阅读器播报仍需专项验收,不声明等同 React Aria 全部能力。
- 样式及 19 个中文示例来自固定 HeroUI 基线;React 渲染函数改为 Vue 插槽,文档的表单成功反馈使用内联状态,图标扩展示例使用 Tabler。
- 样式及 19 个中文示例来自固定 HeroUI 基线;React 渲染函数改为 Vue 插槽,表单成功反馈与基线一致使用 `alert`,图标扩展示例使用 Tabler。
## 相关组件
+1 -1
View File
@@ -452,7 +452,7 @@ TimeFieldSuffix 接受标准 HTML `div` 属性:
- `locale` / `dir` 默认读取 ConfigProvider(否则 en-US / ltr);可显式覆盖。`form` 支持外部表单,`autoComplete` 默认 off;`disabled` 是 isDisabled 的原生别名。Root 暴露 `element` / `focus()`。
- React `render` 改为 `as` 和原生 attrs;children render prop 改默认作用域插槽。class/style 函数不直接移植,使用插槽状态和 Vue 绑定。没有声明继承全部 RAC props;Reka 的 step/stepSnapping 不作为额外公共 API。
- Group 支持 `variant`、`fullWidth`、`as`;Input、InputContainer、Segment、Prefix、Suffix 支持 `as` 和原生 attrs,Segment 还要求 `segment`。Input 的视觉变体由 Group 设置。取消按键需在实际 Segment 上使用 `@keydown.prevent`(可按需 stop);Root 的冒泡监听晚于分段编辑,不能撤销已经完成的子处理。
- 表单示例在模拟提交后显示实际提交值并清空;替代上游控制台反馈,保留 1500ms 加载流程并在卸载时清理计时器。
- 表单示例与基线一致:模拟提交(1500ms 加载)后将实际提交值输出到控制台并清空输入,卸载时清理计时器。
- 当前仅支持浏览器客户端。未开展完整系统 IME、读屏、真机或逐像素自动对比专项。
Enter 在实际 Segment 上触发所属原生表单的 `requestSubmit()`(支持外部 form),遵守原生约束校验和 `@keydown.prevent`。blur 不重复发送已经接受的值。
+7 -7
View File
@@ -274,13 +274,13 @@ Toast 使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/
### ToastActionButton
| Prop / 事件 | 类型 | 默认值 | 描述 |
| ---------------------------- | ------------ | ------------- | --------------------------------------------------------------- |
| `variant` | Button 变体 | `'secondary'` | 按钮变体 |
| `size` | Button 尺寸 | `'sm'` | 按钮尺寸 |
| `isDisabled` | `boolean` | `false` | 禁用 |
| `@click` | `MouseEvent` | — | 默认命令式动作先调用用户处理,再关闭;preventDefault 可阻止关闭 |
| 其余 Button props / 默认插槽 | 见 Button | — | 透传给基础 Button;自定义插槽中的按钮可调用 close |
| Prop / 事件 | 类型 | 默认值 | 描述 |
| ---------------------------- | ------------ | ----------- | --------------------------------------------------------------- |
| `variant` | Button 变体 | `'primary'` | 按钮变体(与上游一致,回落到 Button 默认变体) |
| `size` | Button 尺寸 | `'md'` | 按钮尺寸(与上游一致,回落到 Button 默认尺寸) |
| `isDisabled` | `boolean` | `false` | 禁用 |
| `@click` | `MouseEvent` | — | 默认命令式动作先调用用户处理,再关闭;preventDefault 可阻止关闭 |
| 其余 Button props / 默认插槽 | 见 Button | — | 透传给基础 Button;自定义插槽中的按钮可调用 close |
### ToastCloseButton
@@ -1,5 +1,8 @@
<script setup lang="ts">
import { IconArrowUp, IconSparkles } from "@tabler/icons-vue";
import {
IconArrowBarUp as ArrowUpFromLine,
IconSparkles,
} from "@tabler/icons-vue";
import {
AlertDialog,
AlertDialogBackdrop,
@@ -28,9 +31,9 @@ const animations = [
},
{
name: "流体滑入",
icon: IconArrowUp,
icon: ArrowUpFromLine,
description:
"模拟在介质中运动并受流体阻力影响,避免机械式线性,更自然、更贴地。",
"模拟在介质中运动并受流体阻力影响,避免机械式线性,更自然、更贴地,适合底部抽屉或 Toast。",
backdropClass:
"data-[entering]:duration-500 data-[entering]:ease-[cubic-bezier(0.25,1,0.5,1)] data-[exiting]:duration-200 data-[exiting]:ease-[cubic-bezier(0.5,0,0.75,0)]",
containerClass:
@@ -50,10 +50,17 @@ const portalEl = ref<HTMLElement | null>(null);
</AlertDialogHeader>
<AlertDialogBody>
<p class="text-sm text-muted">
此段为示例占位文案,用于演示在自定义容器内渲染对话框时的滚动与排版效果。
此段为示例占位文案,用于演示在自定义容器内渲染对话框时的滚动与排版效果。实际项目中请替换为真实说明内容。
</p>
<p class="text-sm text-muted">
通过将浮层挂载到局部容器,可以配合裁剪、缩放或卡片布局,避免遮挡整个页面。
通过将浮层挂载到局部容器,可以配合裁剪、缩放或卡片布局,避免遮挡整个页面,同时仍保持焦点管理与无障碍行为。
</p>
<p class="text-sm text-muted">
若容器存在
<code>transform</code>
或
<code>filter</code>
等属性,请注意浏览器会为其创建新的包含块,从而影响定位与层级关系。
</p>
</AlertDialogBody>
<AlertDialogFooter>
@@ -29,6 +29,10 @@ import {
aria-hidden="true"
class="pointer-events-none absolute inset-x-0 top-0 h-24 bg-linear-to-b from-accent/6 to-transparent dark:from-accent/10"
/>
<div
aria-hidden="true"
class="pointer-events-none absolute inset-x-8 top-0 h-px bg-linear-to-r from-transparent via-accent/35 to-transparent dark:via-accent/45"
/>
<AlertDialogHeader class="relative">
<AlertDialogIcon status="accent" />
<AlertDialogHeading>确定要退出账户吗?</AlertDialogHeading>
+3 -2
View File
@@ -45,12 +45,13 @@ const sizes = ["xs", "sm", "md", "lg", "cover"] as const;
<p v-if="size === 'cover'">
此警告框使用
<code>cover</code>
尺寸:在移动端与桌面端保留边距铺满可视区域,仍保持圆角与标准内边距。
尺寸:在移动端与桌面端保留边距(移动端约 16px、桌面端约
40px)铺满可视区域,仍保持圆角与标准内边距,适合需要最大宽度又保留对话框气质的关键确认。
</p>
<p v-else>
此警告框使用
<code>{{ size }}</code>
尺寸。在移动端各尺寸都会接近全宽以便阅读;在桌面端则对应不同的最大宽度。
尺寸。在移动端各尺寸都会接近全宽以便阅读;在桌面端则对应不同的最大宽度,以适配不同信息量。
</p>
</AlertDialogBody>
<AlertDialogFooter>
+2 -9
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import {
Autocomplete,
AutocompleteClearButton,
@@ -41,13 +40,10 @@ const countries = [
{ id: "germany", name: "Germany" },
];
const message = ref<string | null>(null);
function onSubmit(event: Event) {
event.preventDefault();
const formData = new FormData(event.currentTarget as HTMLFormElement);
void formData;
message.value = "表单提交成功!";
// The Form guard already blocks invalid submits, so a reached handler is valid.
alert("表单提交成功!");
}
</script>
@@ -144,8 +140,5 @@ function onSubmit(event: Event) {
<FieldError />
</Autocomplete>
<Button type="submit">提交</Button>
<p v-if="message" role="status" class="text-sm text-muted">
{{ message }}
</p>
</Form>
</template>
+1 -1
View File
@@ -12,7 +12,7 @@ import {
</script>
<template>
<Card class="w-[400px]">
<IconCoin role="img" aria-label="美元图标" class="size-6" />
<IconCoin role="img" aria-label="美元图标" class="text-primary size-6" />
<CardHeader>
<CardTitle>成为 Acme 创作者!</CardTitle>
<CardDescription>
+7 -20
View File
@@ -10,10 +10,12 @@ import {
Link,
} from "@heroui-vue/components";
import { Input, Label } from "@heroui-vue/components";
import { ref, useId } from "vue";
import { useId } from "vue";
const id = useId();
const submitted = ref(false);
const message = ref("");
function onSubmit(event: Event) {
event.preventDefault();
alert("表单提交成功!");
}
</script>
<template>
<Card class="w-full max-w-md">
@@ -21,7 +23,7 @@ const message = ref("");
<CardTitle>登录</CardTitle>
<CardDescription>输入账号信息以访问您的账户</CardDescription>
</CardHeader>
<form class="flex flex-col" @submit.prevent="submitted = true">
<form class="flex flex-col" @submit="onSubmit">
<CardContent>
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-1">
@@ -33,7 +35,6 @@ const message = ref("");
autocomplete="email"
placeholder="email@example.com"
variant="secondary"
required
/>
</div>
<div class="flex flex-col gap-1">
@@ -45,28 +46,14 @@ const message = ref("");
autocomplete="current-password"
placeholder="••••••••"
variant="secondary"
required
/>
</div>
</div>
</CardContent>
<CardFooter class="mt-4 flex flex-col gap-2">
<Button class="w-full" type="submit">登录</Button>
<Link
class="text-center text-sm"
href="#"
@click.prevent="message = '请联系账户管理员重置密码。'"
>
忘记密码?
</Link>
<Link class="text-center text-sm" href="#">忘记密码?</Link>
</CardFooter>
<p
v-if="submitted || message"
role="status"
class="mt-2 text-sm text-muted"
>
{{ message || "表单提交成功!此示例不会发送账号信息。" }}
</p>
</form>
</Card>
</template>
+1 -1
View File
@@ -62,7 +62,7 @@ import {
<IconCoin
role="img"
aria-label="美元图标"
class="size-8 shrink-0"
class="text-primary size-8 shrink-0"
/>
<div class="flex flex-col gap-1">
<span class="text-xs font-medium text-muted uppercase">
+4 -9
View File
@@ -6,15 +6,13 @@ import {
Checkbox,
Button,
} from "@heroui-vue/components";
import { ref } from "vue";
const result = ref("");
function submit(event: Event) {
const data = new FormData(event.currentTarget as HTMLFormElement);
result.value =
"表单提交数据:\n" +
Array.from(data)
alert(
`表单提交数据:\n${Array.from(data)
.map(([key, value]) => `${key}: ${value}`)
.join("\n");
.join("\n")}`,
);
}
</script>
<template>
@@ -46,8 +44,5 @@ function submit(event: Event) {
</Checkbox>
</div>
<Button class="mt-4" size="sm" type="submit" variant="primary">提交</Button>
<pre v-if="result" role="status" class="whitespace-pre-wrap text-sm">{{
result
}}</pre>
</form>
</template>
@@ -10,11 +10,10 @@ import {
Button,
Form,
} from "@heroui-vue/components";
import { ref } from "vue";
const result = ref("");
function submit(event: Event) {
const data = new FormData(event.currentTarget as HTMLFormElement);
result.value = "已选偏好:" + data.getAll("preferences").join(", ");
const values = data.getAll("preferences");
alert(`已选偏好:${values.join(", ")}`);
}
</script>
<template>
@@ -48,6 +47,5 @@ function submit(event: Event) {
<FieldError>请至少选择一种通知方式。</FieldError>
</CheckboxGroup>
<Button type="submit">提交</Button>
<p v-if="result" role="status" class="text-sm">{{ result }}</p>
</Form>
</template>
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
ComboBox,
@@ -36,10 +35,8 @@ function validate(value: string | number | (string | number)[] | null) {
return true;
}
const message = ref("");
function onSubmit() {
message.value = "表单提交成功!";
alert("表单提交成功!");
}
</script>
@@ -67,6 +64,5 @@ function onSubmit() {
<FieldError />
</ComboBox>
<Button class="w-fit" type="submit">提交</Button>
<p v-if="message" class="text-sm text-muted" role="status">{{ message }}</p>
</Form>
</template>
+1 -7
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
ComboBox,
@@ -16,11 +15,9 @@ import {
Surface,
} from "@heroui-vue/components";
const message = ref("");
function onSubmit(event: Event) {
event.preventDefault();
message.value = "表单提交成功!";
alert("表单提交成功!");
}
</script>
@@ -64,9 +61,6 @@ function onSubmit(event: Event) {
<FieldError />
</ComboBox>
<Button type="submit">提交</Button>
<p v-if="message" class="text-sm text-muted" role="status">
{{ message }}
</p>
</Form>
</Surface>
</template>
+2 -9
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
ComboBox,
@@ -15,12 +14,9 @@ import {
ListBoxItemIndicator,
} from "@heroui-vue/components";
const submitted = ref(false);
function submit(event: Event) {
function submit() {
// The Form guard already blocks invalid submits, so a reached handler is valid.
void new FormData(event.currentTarget as HTMLFormElement);
submitted.value = true;
alert("表单提交成功!");
}
</script>
@@ -63,8 +59,5 @@ function submit(event: Event) {
<FieldError />
</ComboBox>
<Button type="submit">提交</Button>
<p v-if="submitted" role="status" class="text-sm text-muted">
表单提交成功!
</p>
</Form>
</template>
+3 -11
View File
@@ -14,19 +14,14 @@ import {
TextField,
} from "@heroui-vue/components";
import { IconDeviceFloppy } from "@tabler/icons-vue";
import { ref } from "vue";
const result = ref("");
function validateName(value: string) {
return value.length < 3 ? "姓名至少需要 3 个字符" : null;
}
function validateBio(value: string) {
return value.length < 10 ? "简介至少需要 10 个字符" : null;
}
function submit(event: Event) {
const data = Object.fromEntries(
new FormData(event.currentTarget as HTMLFormElement),
);
result.value = `表单提交成功!${JSON.stringify(data)}`;
function submit() {
alert("表单提交成功!");
}
</script>
<template>
@@ -57,11 +52,8 @@ function submit(event: Event) {
<IconDeviceFloppy aria-hidden="true" />
保存更改
</Button>
<Button type="reset" variant="secondary" @click="result = ''">
取消
</Button>
<Button type="reset" variant="secondary">取消</Button>
</FieldsetActions>
</Fieldset>
<p v-if="result" class="text-sm text-muted" role="status">{{ result }}</p>
</Form>
</template>
+3 -11
View File
@@ -14,19 +14,14 @@ import {
TextField,
} from "@heroui-vue/components";
import { IconDeviceFloppy } from "@tabler/icons-vue";
import { ref } from "vue";
const result = ref("");
function validateName(value: string) {
return value.length < 3 ? "姓名至少需要 3 个字符" : null;
}
function validateBio(value: string) {
return value.length < 10 ? "简介至少需要 10 个字符" : null;
}
function submit(event: Event) {
const data = Object.fromEntries(
new FormData(event.currentTarget as HTMLFormElement),
);
result.value = `表单提交成功!${JSON.stringify(data)}`;
function submit() {
alert("表单提交成功!");
}
const shell =
"rounded-xl border border-border/70 bg-linear-to-b from-neutral-50/90 to-white p-4 ring-1 ring-black/5 dark:from-neutral-900/80 dark:to-neutral-900 dark:ring-white/10";
@@ -67,11 +62,8 @@ const fieldClass =
<IconDeviceFloppy aria-hidden="true" />
保存更改
</Button>
<Button type="reset" variant="secondary" @click="result = ''">
取消
</Button>
<Button type="reset" variant="secondary">取消</Button>
</FieldsetActions>
</Fieldset>
<p v-if="result" class="text-sm text-muted" role="status">{{ result }}</p>
</Form>
</template>
+4 -14
View File
@@ -15,24 +15,19 @@ import {
Surface,
} from "@heroui-vue/components";
import { IconDeviceFloppy } from "@tabler/icons-vue";
import { ref } from "vue";
const result = ref("");
function validateName(value: string) {
return value.length < 3 ? "姓名至少需要 3 个字符" : null;
}
function validateBio(value: string) {
return value.length < 10 ? "简介至少需要 10 个字符" : null;
}
function submit(event: Event) {
const data = Object.fromEntries(
new FormData(event.currentTarget as HTMLFormElement),
);
result.value = `表单提交成功!${JSON.stringify(data)}`;
function submit() {
alert("表单提交成功!");
}
</script>
<template>
<div class="flex items-center justify-center rounded-3xl bg-surface p-6">
<Surface class="w-full min-w-[380px] max-sm:min-w-0">
<Surface class="w-full min-w-[380px]">
<Form @submit.prevent="submit">
<Fieldset class="w-full">
<FieldsetLegend>个人资料设置</FieldsetLegend>
@@ -60,14 +55,9 @@ function submit(event: Event) {
<IconDeviceFloppy aria-hidden="true" />
保存更改
</Button>
<Button type="reset" variant="tertiary" @click="result = ''">
取消
</Button>
<Button type="reset" variant="tertiary">取消</Button>
</FieldsetActions>
</Fieldset>
<p v-if="result" class="text-sm text-muted" role="status">
{{ result }}
</p>
</Form>
</Surface>
</div>
+2 -14
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import { IconCheck } from "@tabler/icons-vue";
import {
Button,
@@ -11,7 +10,6 @@ import {
TextField,
} from "@heroui-vue/components";
const result = ref("");
function onSubmit(event: Event) {
event.preventDefault();
const formData = new FormData(event.currentTarget as HTMLFormElement);
@@ -19,7 +17,7 @@ function onSubmit(event: Event) {
formData.forEach((value, key) => {
data[key] = value.toString();
});
result.value = `表单提交数据:${JSON.stringify(data, null, 2)}`;
alert(`表单提交数据:${JSON.stringify(data, null, 2)}`);
}
function validateEmail(value: string) {
return /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(value)
@@ -35,11 +33,7 @@ function validatePassword(value: string) {
</script>
<template>
<Form
class="flex w-96 max-w-full flex-col gap-4"
@submit="onSubmit"
@reset="result = ''"
>
<Form class="flex w-96 flex-col gap-4" @submit="onSubmit">
<TextField is-required name="email" type="email" :validate="validateEmail">
<Label>邮箱</Label>
<Input placeholder="john@example.com" />
@@ -64,11 +58,5 @@ function validatePassword(value: string) {
</Button>
<Button type="reset" variant="secondary">重置</Button>
</div>
<pre
v-if="result"
role="status"
aria-label="提交结果"
class="whitespace-pre-wrap break-all text-xs"
>{{ result }}</pre>
</Form>
</template>
+1 -1
View File
@@ -4,7 +4,7 @@ import { Button, Form, Input, Label, TextField } from "@heroui-vue/components";
<template>
<Form
class="flex w-80 max-w-full flex-col gap-3 rounded-xl border border-border/80 bg-surface p-4 shadow-sm"
class="flex w-80 flex-col gap-3 rounded-xl border border-border/80 bg-surface p-4 shadow-sm"
@submit.prevent
>
<TextField is-required name="email" type="email">
+2 -15
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import { IconCheck } from "@tabler/icons-vue";
import {
Button,
@@ -11,7 +10,6 @@ import {
TextField,
} from "@heroui-vue/components";
const result = ref("");
function onSubmit(event: Event) {
event.preventDefault();
const formData = new FormData(event.currentTarget as HTMLFormElement);
@@ -19,7 +17,7 @@ function onSubmit(event: Event) {
formData.forEach((value, key) => {
data[key] = value.toString();
});
result.value = `表单提交数据:${JSON.stringify(data, null, 2)}`;
alert(`表单提交数据:${JSON.stringify(data, null, 2)}`);
}
function validateEmail(value: string) {
return /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(value)
@@ -35,12 +33,7 @@ function validatePassword(value: string) {
</script>
<template>
<Form
class="flex w-96 max-w-full flex-col gap-4"
data-custom="foo"
@submit="onSubmit"
@reset="result = ''"
>
<Form class="flex w-96 flex-col gap-4" data-custom="foo" @submit="onSubmit">
<TextField is-required name="email" type="email" :validate="validateEmail">
<Label>邮箱</Label>
<Input placeholder="john@example.com" />
@@ -65,11 +58,5 @@ function validatePassword(value: string) {
</Button>
<Button type="reset" variant="secondary">重置</Button>
</div>
<pre
v-if="result"
role="status"
aria-label="提交结果"
class="whitespace-pre-wrap break-all text-xs"
>{{ result }}</pre>
</Form>
</template>
+53 -30
View File
@@ -6,8 +6,12 @@ import {
InputGroupPrefix,
InputGroupSuffix,
InputGroupTextArea,
Kbd,
KbdAbbr,
Spinner,
TextField,
Tooltip,
TooltipContent,
} from "@heroui-vue/components";
import {
IconArrowUp,
@@ -53,45 +57,64 @@ function handleSubmit() {
:rows="5"
/>
<InputGroupSuffix class="flex w-full items-center gap-1.5 px-3 py-0">
<Button
is-icon-only
aria-label="附加文件"
size="sm"
title="添加文件等"
variant="tertiary"
>
<IconPlus aria-hidden="true" />
</Button>
<Button
is-icon-only
aria-label="连接应用"
size="sm"
title="连接应用"
variant="tertiary"
>
<IconPlugConnected aria-hidden="true" />
</Button>
<div class="ms-auto flex items-center gap-1.5">
<Tooltip :delay="0">
<Button
is-icon-only
aria-label="语音输入"
aria-label="附加文件"
size="sm"
title="语音输入"
variant="ghost"
variant="tertiary"
>
<IconMicrophone aria-hidden="true" />
<IconPlus aria-hidden="true" />
</Button>
<TooltipContent>
<p class="text-xs">添加文件等</p>
</TooltipContent>
</Tooltip>
<Tooltip :delay="0">
<Button
is-icon-only
aria-label="发送提示"
:is-disabled="!value.trim()"
:is-pending="isSubmitting"
title="发送"
@click="handleSubmit"
aria-label="连接应用"
size="sm"
variant="tertiary"
>
<Spinner v-if="isSubmitting" color="current" size="sm" />
<IconArrowUp v-else aria-hidden="true" />
<IconPlugConnected aria-hidden="true" />
</Button>
<TooltipContent>
<p class="text-xs">连接应用</p>
</TooltipContent>
</Tooltip>
<div class="ms-auto flex items-center gap-1.5">
<Tooltip :delay="0">
<Button
is-icon-only
aria-label="语音输入"
size="sm"
variant="ghost"
>
<IconMicrophone aria-hidden="true" />
</Button>
<TooltipContent>
<p class="text-xs">语音输入</p>
</TooltipContent>
</Tooltip>
<Tooltip :delay="0">
<Button
is-icon-only
aria-label="发送提示"
:is-disabled="!value.trim()"
:is-pending="isSubmitting"
@click="handleSubmit"
>
<Spinner v-if="isSubmitting" color="current" size="sm" />
<IconArrowUp v-else aria-hidden="true" />
</Button>
<TooltipContent class="flex items-center gap-1">
<p class="text-xs">发送</p>
<Kbd class="h-4 rounded-sm px-1">
<KbdAbbr key-value="enter" />
</Kbd>
</TooltipContent>
</Tooltip>
</div>
</InputGroupSuffix>
</InputGroup>
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import { IconPencil, IconSquarePlus, IconTrash } from "@tabler/icons-vue";
import {
Description,
@@ -14,7 +13,9 @@ import {
Separator,
Surface,
} from "@heroui-vue/components";
const message = ref("");
function onAction(key: string | number) {
alert(`已选项目:${key}`);
}
const actions = [
{
id: "new-file",
@@ -33,56 +34,53 @@ const actions = [
];
</script>
<template>
<div class="space-y-3">
<Surface class="w-[256px] rounded-3xl shadow-surface">
<ListBox
aria-label="文件操作"
class="w-full p-2"
selection-mode="none"
@action="message = `已选项目:${$event}`"
:disabled-keys="['delete-file']"
>
<ListBoxSection>
<Header>操作</Header>
<ListBoxItem
v-for="action in actions"
:key="action.id"
:id="action.id"
:text-value="action.title"
>
<div class="flex h-8 items-start justify-center pt-px">
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
</div>
<div class="flex flex-col">
<Label>{{ action.title }}</Label>
<Description>{{ action.description }}</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdContent>{{ action.shortcut }}</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
<Separator />
<ListBoxSection>
<Header>危险区域</Header>
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
<div class="flex h-8 items-start justify-center pt-px">
<IconTrash class="size-4 shrink-0 text-danger" />
</div>
<div class="flex flex-col">
<Label>删除文件</Label>
<Description>移至废纸篓</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdAbbr key-value="shift" />
<KbdContent>D</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
</ListBox>
</Surface>
<p v-if="message" role="status" class="text-sm text-muted">{{ message }}</p>
</div>
<Surface class="w-[256px] rounded-3xl shadow-surface">
<ListBox
aria-label="文件操作"
class="w-full p-2"
selection-mode="none"
@action="onAction"
:disabled-keys="['delete-file']"
>
<ListBoxSection>
<Header>操作</Header>
<ListBoxItem
v-for="action in actions"
:key="action.id"
:id="action.id"
:text-value="action.title"
>
<div class="flex h-8 items-start justify-center pt-px">
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
</div>
<div class="flex flex-col">
<Label>{{ action.title }}</Label>
<Description>{{ action.description }}</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdContent>{{ action.shortcut }}</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
<Separator />
<ListBoxSection>
<Header>危险区域</Header>
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
<div class="flex h-8 items-start justify-center pt-px">
<IconTrash class="size-4 shrink-0 text-danger" />
</div>
<div class="flex flex-col">
<Label>删除文件</Label>
<Description>移至废纸篓</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdAbbr key-value="shift" />
<KbdContent>D</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
</ListBox>
</Surface>
</template>
+51 -53
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import { IconPencil, IconSquarePlus, IconTrash } from "@tabler/icons-vue";
import {
Description,
@@ -14,7 +13,9 @@ import {
Separator,
Surface,
} from "@heroui-vue/components";
const message = ref("");
function onAction(key: string | number) {
alert(`已选项目:${key}`);
}
const actions = [
{
id: "new-file",
@@ -33,55 +34,52 @@ const actions = [
];
</script>
<template>
<div class="space-y-3">
<Surface class="w-[256px] rounded-3xl shadow-surface">
<ListBox
aria-label="文件操作"
class="w-full p-2"
selection-mode="none"
@action="message = `已选项目:${$event}`"
>
<ListBoxSection>
<Header>操作</Header>
<ListBoxItem
v-for="action in actions"
:key="action.id"
:id="action.id"
:text-value="action.title"
>
<div class="flex h-8 items-start justify-center pt-px">
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
</div>
<div class="flex flex-col">
<Label>{{ action.title }}</Label>
<Description>{{ action.description }}</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdContent>{{ action.shortcut }}</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
<Separator />
<ListBoxSection>
<Header>危险区域</Header>
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
<div class="flex h-8 items-start justify-center pt-px">
<IconTrash class="size-4 shrink-0 text-danger" />
</div>
<div class="flex flex-col">
<Label>删除文件</Label>
<Description>移至废纸篓</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdAbbr key-value="shift" />
<KbdContent>D</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
</ListBox>
</Surface>
<p v-if="message" role="status" class="text-sm text-muted">{{ message }}</p>
</div>
<Surface class="w-[256px] rounded-3xl shadow-surface">
<ListBox
aria-label="文件操作"
class="w-full p-2"
selection-mode="none"
@action="onAction"
>
<ListBoxSection>
<Header>操作</Header>
<ListBoxItem
v-for="action in actions"
:key="action.id"
:id="action.id"
:text-value="action.title"
>
<div class="flex h-8 items-start justify-center pt-px">
<component :is="action.icon" class="size-4 shrink-0 text-muted" />
</div>
<div class="flex flex-col">
<Label>{{ action.title }}</Label>
<Description>{{ action.description }}</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdContent>{{ action.shortcut }}</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
<Separator />
<ListBoxSection>
<Header>危险区域</Header>
<ListBoxItem id="delete-file" text-value="删除文件" variant="danger">
<div class="flex h-8 items-start justify-center pt-px">
<IconTrash class="size-4 shrink-0 text-danger" />
</div>
<div class="flex flex-col">
<Label>删除文件</Label>
<Description>移至废纸篓</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdAbbr key-value="shift" />
<KbdContent>D</KbdContent>
</Kbd>
</ListBoxItem>
</ListBoxSection>
</ListBox>
</Surface>
</template>
+53 -71
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref, useId } from "vue";
import {
Button,
Input,
@@ -17,78 +16,61 @@ import {
ModalIcon,
Surface,
TextField,
useOverlayState,
} from "@heroui-vue/components";
import { IconMail as Envelope } from "@tabler/icons-vue";
const state = useOverlayState();
const formId = useId();
const result = ref<Record<string, FormDataEntryValue>>();
function submit(event: SubmitEvent) {
result.value = Object.fromEntries(
new FormData(event.currentTarget as HTMLFormElement),
);
state.close();
}
</script>
<template>
<div>
<Modal :state="state">
<Button variant="secondary">打开联系表单</Button>
<ModalBackdrop>
<ModalContainer placement="auto">
<ModalDialog class="sm:max-w-md">
<ModalCloseTrigger></ModalCloseTrigger>
<ModalHeader>
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
<Envelope aria-hidden="true" class="size-5"></Envelope>
</ModalIcon>
<ModalHeading>联系我们</ModalHeading>
<p class="mt-1.5 text-sm leading-5 text-muted">
填写下方表单,我们会尽快回复。在移动端弹出键盘时,模态框会自动适配。
</p>
</ModalHeader>
<ModalBody class="p-6">
<Surface variant="default">
<form
:id="formId"
class="flex flex-col gap-4"
@submit.prevent="submit"
>
<TextField class="w-full" name="name" type="text">
<Label>姓名</Label>
<Input placeholder="输入你的姓名"></Input>
</TextField>
<TextField class="w-full" name="email" type="email">
<Label>邮箱</Label>
<Input placeholder="输入你的邮箱"></Input>
</TextField>
<TextField class="w-full" name="phone" type="tel">
<Label>电话</Label>
<Input placeholder="输入你的电话号码"></Input>
</TextField>
<TextField class="w-full" name="company">
<Label>公司</Label>
<Input placeholder="输入公司名称"></Input>
</TextField>
<TextField class="w-full" name="message">
<Label>留言</Label>
<Input placeholder="输入留言内容"></Input>
</TextField>
</form>
</Surface>
</ModalBody>
<ModalFooter>
<ModalClose as-child>
<Button variant="secondary">取消</Button>
</ModalClose>
<Button type="submit" :form="formId">发送消息</Button>
</ModalFooter>
</ModalDialog>
</ModalContainer>
</ModalBackdrop>
</Modal>
<p v-if="result" role="status" class="mt-3 text-sm text-muted">
已记录表单:{{ result }}
</p>
</div>
<Modal>
<Button variant="secondary">打开联系表单</Button>
<ModalBackdrop>
<ModalContainer placement="auto">
<ModalDialog class="sm:max-w-md">
<ModalCloseTrigger></ModalCloseTrigger>
<ModalHeader>
<ModalIcon class="bg-accent-soft text-accent-soft-foreground">
<Envelope aria-hidden="true" class="size-5"></Envelope>
</ModalIcon>
<ModalHeading>联系我们</ModalHeading>
<p class="mt-1.5 text-sm leading-5 text-muted">
填写下方表单,我们会尽快回复。在移动端弹出键盘时,模态框会自动适配。
</p>
</ModalHeader>
<ModalBody class="p-6">
<Surface variant="default">
<form class="flex flex-col gap-4">
<TextField class="w-full" name="name" type="text">
<Label>姓名</Label>
<Input placeholder="输入你的姓名"></Input>
</TextField>
<TextField class="w-full" name="email" type="email">
<Label>邮箱</Label>
<Input placeholder="输入你的邮箱"></Input>
</TextField>
<TextField class="w-full" name="phone" type="tel">
<Label>电话</Label>
<Input placeholder="输入你的电话号码"></Input>
</TextField>
<TextField class="w-full" name="company">
<Label>公司</Label>
<Input placeholder="输入公司名称"></Input>
</TextField>
<TextField class="w-full" name="message">
<Label>留言</Label>
<Input placeholder="输入留言内容"></Input>
</TextField>
</form>
</Surface>
</ModalBody>
<ModalFooter>
<ModalClose as-child>
<Button variant="secondary">取消</Button>
</ModalClose>
<ModalClose as-child>
<Button>发送消息</Button>
</ModalClose>
</ModalFooter>
</ModalDialog>
</ModalContainer>
</ModalBackdrop>
</Modal>
</template>
+4 -10
View File
@@ -14,8 +14,7 @@ import {
Spinner,
} from "@heroui-vue/components";
const value = ref<number | null>(null),
isSubmitting = ref(false),
feedback = ref("");
isSubmitting = ref(false);
const STOCK_AVAILABLE = 3;
const isOutOfStock = computed(
() => value.value !== null && value.value > STOCK_AVAILABLE,
@@ -30,12 +29,11 @@ function submit() {
)
return;
isSubmitting.value = true;
feedback.value = "";
// Local demonstration only; no order or network request is created.
// Simulate API call
timer = setTimeout(() => {
console.log("Order submitted:", { quantity: value.value });
value.value = null;
isSubmitting.value = false;
feedback.value = "模拟提交成功";
}, 1500);
}
onBeforeUnmount(() => {
@@ -43,10 +41,7 @@ onBeforeUnmount(() => {
});
</script>
<template>
<Form
class="flex w-[280px] max-w-full flex-col gap-4"
@submit.prevent="submit"
>
<Form class="flex w-[280px] flex-col gap-4" @submit.prevent="submit">
<NumberField
v-model="value"
is-required
@@ -79,6 +74,5 @@ onBeforeUnmount(() => {
</template>
<template v-else>下单</template>
</Button>
<p v-if="feedback" role="status">{{ feedback }}</p>
</Form>
</template>
+1 -1
View File
@@ -9,7 +9,7 @@ import {
} from "@heroui-vue/components";
</script>
<template>
<div class="w-[400px] max-w-full space-y-4">
<div class="w-[400px] space-y-4">
<NumberField fullWidth :defaultValue="1024" :minValue="0" name="width">
<Label>宽度</Label>
<NumberFieldGroup>
+1 -1
View File
@@ -52,6 +52,6 @@ function submit(event: Event) {
<FieldError>请先选择订阅套餐再继续。</FieldError>
</RadioGroup>
<Button class="mt-2 w-fit" type="submit">Submit</Button>
<p v-if="result" role="status" class="text-sm">{{ result }}</p>
<p v-if="result" role="status" class="text-sm text-muted">{{ result }}</p>
</Form>
</template>
@@ -15,20 +15,17 @@ import { Form } from "@heroui-vue/components";
import { computed, onBeforeUnmount, ref } from "vue";
const value = ref("");
const isSubmitting = ref(false);
const result = ref("");
const isInvalid = computed(
() => value.value.length > 0 && value.value.length < 3,
);
let timer: ReturnType<typeof setTimeout> | undefined;
onBeforeUnmount(() => clearTimeout(timer));
function submit(event: Event) {
function submit() {
if (value.value.length < 3 || isSubmitting.value) return;
const query = new FormData(event.currentTarget as HTMLFormElement).get(
"search",
);
isSubmitting.value = true;
// Simulate API call
timer = setTimeout(() => {
result.value = `已模拟提交搜索:${query}`;
console.log("Search submitted:", { query: value.value });
value.value = "";
isSubmitting.value = false;
}, 1500);
@@ -65,6 +62,5 @@ function submit(event: Event) {
</template>
<template v-else>搜索</template>
</Button>
<p v-if="result" role="status" class="text-sm text-muted">{{ result }}</p>
</Form>
</template>
+4 -6
View File
@@ -14,12 +14,13 @@ import {
Button,
Surface,
} from "@heroui-vue/components";
import { ref } from "vue";
const submitted = ref(false);
function submit() {
alert("表单提交成功!");
}
</script>
<template>
<Surface class="w-[320px] rounded-3xl p-6">
<Form class="flex w-full flex-col gap-4" @submit.prevent="submitted = true">
<Form class="flex w-full flex-col gap-4" @submit.prevent="submit">
<Select
is-required
class="w-full"
@@ -105,9 +106,6 @@ const submitted = ref(false);
<FieldError />
</Select>
<Button type="submit">提交</Button>
<p v-if="submitted" role="status" class="text-sm text-success">
表单提交成功!
</p>
</Form>
</Surface>
</template>
+4 -9
View File
@@ -13,14 +13,12 @@ import {
FieldError,
Button,
} from "@heroui-vue/components";
import { ref } from "vue";
const submitted = ref(false);
function submit() {
alert("表单提交成功!");
}
</script>
<template>
<Form
class="flex w-[256px] flex-col gap-4"
@submit.prevent="submitted = true"
>
<Form class="flex w-[256px] flex-col gap-4" @submit.prevent="submit">
<Select is-required class="w-full" name="state" placeholder="请选择">
<Label>州</Label>
<SelectTrigger>
@@ -94,8 +92,5 @@ const submitted = ref(false);
<FieldError />
</Select>
<Button type="submit">提交</Button>
<p v-if="submitted" role="status" class="text-sm text-success">
表单提交成功!
</p>
</Form>
</template>
+9 -21
View File
@@ -7,13 +7,13 @@ import {
SwitchGroup,
Button,
} from "@heroui-vue/components";
import { ref } from "vue";
const result = ref("");
function submit(event: Event) {
const values = [...new FormData(event.target as HTMLFormElement).entries()];
result.value = values.length
? "表单提交内容:" + values.map(([k, v]) => `${k}: ${v}`).join(",")
: "未选择任何选项";
const data = new FormData(event.currentTarget as HTMLFormElement);
alert(
`表单提交内容:\n${Array.from(data)
.map(([key, value]) => `${key}: ${value}`)
.join("\n")}`,
);
}
</script>
<template>
@@ -38,20 +38,8 @@ function submit(event: Event) {
</SwitchContent>
</Switch>
</SwitchGroup>
<div class="flex gap-2">
<Button class="mt-4" size="sm" type="submit">Submit</Button>
<Button
class="mt-4"
size="sm"
type="reset"
variant="secondary"
@click="result = ''"
>
重置
</Button>
</div>
<output v-if="result" class="text-sm text-muted" aria-live="polite">
{{ result }}
</output>
<Button class="mt-4" size="sm" type="submit" variant="primary">
Submit
</Button>
</form>
</template>
+2 -6
View File
@@ -30,14 +30,13 @@ const isInvalid = computed(() => {
});
import { onBeforeUnmount } from "vue";
const isSubmitting = shallowRef(false);
const submitted = shallowRef("");
let timer: ReturnType<typeof setTimeout> | undefined;
function submit() {
if (!value.value || isInvalid.value || isSubmitting.value) return;
const payload = value.value.toString();
isSubmitting.value = true;
// Simulate API call
timer = setTimeout(() => {
submitted.value = payload;
console.log("Time submitted:", { time: value.value });
value.value = null;
isSubmitting.value = false;
}, 1500);
@@ -78,8 +77,5 @@ onBeforeUnmount(() => clearTimeout(timer));
>
{{ isSubmitting ? "提交中…" : "提交" }}
</Button>
<output v-if="submitted" class="text-sm text-muted">
已提交:{{ submitted }}
</output>
</Form>
</template>
+1 -1
View File
@@ -21,7 +21,7 @@ function show() {
</script>
<template>
<div class="flex flex-col gap-3">
<div class="flex h-full max-w-xl flex-col items-center justify-center">
<Button size="sm" variant="secondary" @click="show">自定义指示器</Button>
<ToastProvider :queue="queue" to="body" />
</div>
+47 -43
View File
@@ -11,51 +11,55 @@ onBeforeUnmount(() =>
);
</script>
<template>
<div
class="flex h-full max-w-4xl flex-wrap items-center justify-center gap-4"
>
<Button
size="sm"
variant="secondary"
@click="
notificationQueue.add({
title: '新通知',
description: '您有一条新消息',
variant: 'default',
})
"
>
添加通知(最多 2 条)
</Button>
<Button
size="sm"
variant="danger-soft"
@click="
errorQueue.add({
title: '发生错误',
description: '保存更改失败',
variant: 'danger',
})
"
>
添加错误(最多 3 条)
</Button>
<Button
size="sm"
variant="secondary"
class="text-success"
@click="
successQueue.add({
title: '成功!',
description: `操作 ${Date.now()}`,
variant: 'success',
})
"
>
添加成功(最多 1 条)
</Button>
<div class="flex h-full max-w-4xl items-center justify-center gap-4">
<ToastProvider :queue="notificationQueue" to="body" placement="bottom" />
<div class="flex justify-center gap-2">
<Button
size="sm"
variant="secondary"
@click="
notificationQueue.add({
title: '新通知',
description: '您有一条新消息',
variant: 'default',
})
"
>
添加通知(最多 2 条)
</Button>
</div>
<ToastProvider :queue="errorQueue" to="body" placement="bottom start" />
<div class="flex justify-center gap-2">
<Button
size="sm"
variant="danger-soft"
@click="
errorQueue.add({
title: '发生错误',
description: '保存更改失败',
variant: 'danger',
})
"
>
添加错误(最多 3 条)
</Button>
</div>
<ToastProvider :queue="successQueue" to="body" placement="bottom end" />
<div class="flex justify-center gap-2">
<Button
size="sm"
variant="secondary"
class="text-success"
@click="
successQueue.add({
title: '成功!',
description: `操作 ${Date.now()}`,
variant: 'success',
})
"
>
添加成功(最多 1 条)
</Button>
</div>
</div>
</template>
+27 -21
View File
@@ -11,26 +11,32 @@ const toast = createToastFunction(queue);
onBeforeUnmount(() => queue.destroy());
</script>
<template>
<div class="flex h-full max-w-xl flex-wrap items-center justify-center gap-4">
<Button size="sm" variant="secondary" @click="toast('简单消息')">
默认
</Button>
<Button size="sm" variant="secondary" @click="toast.success('操作已完成')">
成功
</Button>
<Button size="sm" variant="secondary" @click="toast.info('有新更新可用')">
信息
</Button>
<Button
size="sm"
variant="secondary"
@click="toast.warning('请检查您的设置')"
>
警告
</Button>
<Button size="sm" variant="secondary" @click="toast.danger('出了点问题')">
错误
</Button>
<ToastProvider :queue="queue" to="body" />
<div class="flex h-full max-w-xl flex-col items-center justify-center">
<div class="flex w-full flex-wrap items-center justify-center gap-4">
<Button size="sm" variant="secondary" @click="toast('简单消息')">
默认
</Button>
<Button
size="sm"
variant="secondary"
@click="toast.success('操作已完成')"
>
成功
</Button>
<Button size="sm" variant="secondary" @click="toast.info('有新更新可用')">
信息
</Button>
<Button
size="sm"
variant="secondary"
@click="toast.warning('请检查您的设置')"
>
警告
</Button>
<Button size="sm" variant="secondary" @click="toast.danger('出了点问题')">
错误
</Button>
<ToastProvider :queue="queue" to="body" />
</div>
</div>
</template>
+27 -25
View File
@@ -62,7 +62,7 @@ function show(v: (typeof variants)[number]["key"]) {
actionProps: {
label: item.action,
variant:
v === "danger" ? "danger" : v === "default" ? "tertiary" : "secondary",
v === "danger" ? "danger" : v === "default" ? "tertiary" : undefined,
class:
v === "success"
? "bg-success text-success-foreground"
@@ -75,29 +75,31 @@ function show(v: (typeof variants)[number]["key"]) {
</script>
<template>
<div class="flex flex-wrap gap-3">
<Button
v-for="v in variants"
:key="v.key"
size="sm"
:variant="
v.key === 'danger'
? 'danger-soft'
: v.key === 'accent'
? 'secondary'
: 'tertiary'
"
:class="
v.key === 'success'
? 'text-success'
: v.key === 'warning'
? 'text-warning'
: undefined
"
@click="show(v.key)"
>
{{ v.label }}
</Button>
<ToastProvider :queue="queue" to="body" />
<div class="flex h-full max-w-xl flex-col items-center justify-center">
<div class="flex w-full flex-wrap items-center justify-center gap-4">
<Button
v-for="v in variants"
:key="v.key"
size="sm"
:variant="
v.key === 'danger'
? 'danger-soft'
: v.key === 'accent'
? 'secondary'
: 'tertiary'
"
:class="
v.key === 'success'
? 'text-success'
: v.key === 'warning'
? 'text-warning'
: undefined
"
@click="show(v.key)"
>
{{ v.label }}
</Button>
<ToastProvider :queue="queue" to="body" />
</div>
</div>
</template>
+2 -2
View File
@@ -169,7 +169,7 @@ M18–M20 的标签桥接在 Vue 使用 indicator 注册表与 SSR 直接/原生
## LISTBOX-01(2026-10-23)
固定 ce90ea3 的 list-box / list-box-item / list-box-section 源码、CSS/tv,以及中文正文和九个预览。CSS/tv 按 hv- 移植,源勾选图形遵循原 Apache-2.0;文档图标用现有 Tabler Vue。原 alert 演示改为内联状态反馈,React render 改 as/插槽,Virtualizer/ListLayout 改 VueUse 固定行高虚拟化。依据、差异与限制见 [LISTBOX-01](component-notes.md)。
固定 ce90ea3 的 list-box / list-box-item / list-box-section 源码、CSS/tv,以及中文正文和九个预览。CSS/tv 按 hv- 移植,源勾选图形遵循原 Apache-2.0;文档图标用现有 Tabler Vue。原 alert 演示曾改为内联状态反馈(2026-10-28 HD-02 已按固定基线恢复为 alert 反馈与原结构),React render 改 as/插槽,Virtualizer/ListLayout 改 VueUse 固定行高虚拟化。依据、差异与限制见 [LISTBOX-01](component-notes.md)。
## M33–M34(2026-10-23)
@@ -327,7 +327,7 @@ CSS/tv 仅加 `hv-` 前缀与 Apache-2.0 来源;`colorPickerVariants` 保持
## FORM(2026-10-27)
固定 `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/form/{form.tsx,index.ts}`、中文 `(forms)/form.mdx` 与 `apps/docs/src/demos/cn/form/{basic,render-function,custom-styles}.tsx`。源无专用CSS/variants;复用已有字段样式。保留3例布局、文案、验证规则与字段,render添加data-custom改为Vue attrs、Gravity Check图标用Tabler IconCheck、alert提交反馈改页内status、增加max-w-full适应窄屏;差异见 [Form文档](../apps/docs/components/form.md)。
固定 `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/form/{form.tsx,index.ts}`、中文 `(forms)/form.mdx` 与 `apps/docs/src/demos/cn/form/{basic,render-function,custom-styles}.tsx`。源无专用CSS/variants;复用已有字段样式。保留3例布局、文案、验证规则与字段,render添加data-custom改为Vue attrs、Gravity Check图标用Tabler IconCheck;alert提交反馈曾改页内status、增加max-w-full(2026-10-28 HD-02 已按固定基线恢复 alert 反馈并移除该宽度守卫);差异见 [Form文档](../apps/docs/components/form.md)。
## HANDBOOK-IMPLEMENTATION-AUDIT(2026-10-27)
@@ -9,11 +9,13 @@ export default defineComponent({
inheritAttrs: false,
props: {
isDisabled: { type: Boolean, default: false },
// Upstream ToastActionButton renders a plain Button without variant/size
// overrides, so these fall back to the Button defaults (primary / md).
variant: {
type: String as PropType<ButtonVariants["variant"]>,
default: "secondary",
default: "primary",
},
size: { type: String as PropType<ButtonVariants["size"]>, default: "sm" },
size: { type: String as PropType<ButtonVariants["size"]>, default: "md" },
},
setup(props, { slots }) {
const attrs = useAttrs();
+19 -3
View File
@@ -1,4 +1,4 @@
import { describe, it, expect } from "vitest";
import { describe, it, expect, vi } from "vitest";
import { mount } from "@vue/test-utils";
import { h, nextTick, ref } from "vue";
import { readFileSync } from "node:fs";
@@ -89,6 +89,7 @@ describe("aligned examples", () => {
w.unmount();
});
it("submits actual selected values and restores Switch defaults on form reset", async () => {
const alert = vi.spyOn(window, "alert").mockImplementation(() => {});
const w = mount(SwitchForm, { attachTo: document.body });
const form = w.get("form").element as HTMLFormElement;
const switches = w.findAll("[role=switch]");
@@ -98,13 +99,19 @@ describe("aligned examples", () => {
expect(new FormData(form).get("notifications")).toBe("on");
expect(new FormData(form).has("newsletter")).toBe(false);
await w.get("form").trigger("submit");
expect(w.get("output").text()).toContain("notifications: on");
// Baseline feedback: one alert carrying the real submitted entries.
expect(alert).toHaveBeenCalledTimes(1);
expect(alert.mock.calls[0][0]).toContain("表单提交内容:");
expect(alert.mock.calls[0][0]).toContain("notifications: on");
expect(alert.mock.calls[0][0]).not.toContain("newsletter");
expect(w.find("output").exists()).toBe(false);
form.reset();
await nextTick();
await nextTick();
expect(switches[0].attributes("aria-checked")).toBe("false");
expect(switches[1].attributes("aria-checked")).toBe("true");
w.unmount();
alert.mockRestore();
});
it("passes root ARIA attributes into composed SwitchContent and preserves container styles", async () => {
const name = ref("静音");
@@ -169,12 +176,21 @@ describe("aligned examples", () => {
w.unmount();
});
it("renders a working Card form using labelled native fields", async () => {
const alert = vi.spyOn(window, "alert").mockImplementation(() => {});
const w = mount(CardForm);
expect(w.findAll("label")).toHaveLength(2);
// Baseline has no added required validation: the empty form submits too.
await w.get("form").trigger("submit");
expect(alert).toHaveBeenCalledWith("表单提交成功!");
expect(w.find("[role=status]").exists()).toBe(false);
await w.get("input[type=email]").setValue("test@example.com");
await w.get("input[type=password]").setValue("test-pass");
await w.get("form").trigger("submit");
expect(w.get("[role=status]").text()).toContain("表单提交成功");
expect(alert).toHaveBeenCalledTimes(2);
expect(
new FormData(w.get("form").element as HTMLFormElement).get("email"),
).toBe("test@example.com");
w.unmount();
alert.mockRestore();
});
});
+31 -8
View File
@@ -82,7 +82,13 @@ describe("Autocomplete docs and demos", () => {
expect(source, name).toContain("SearchFieldClearButton");
// The ported .hv-empty-state padding must not be overridden per demo.
expect(source, name).not.toMatch(/<EmptyState\s+class=/);
expect(source, name).not.toContain("alert(");
// Baseline feedback: only the required demo submits through the plain
// success alert, exactly like the pinned cn source.
if (name === "required") {
expect(source, name).toContain('alert("表单提交成功!")');
} else {
expect(source, name).not.toContain("alert(");
}
}
});
@@ -170,11 +176,12 @@ describe("Autocomplete docs and demos", () => {
}
});
it("submits the required and name demos", async () => {
it("blocks empty required submits and keeps the baseline success alert", async () => {
const formDemo =
(await import("../apps/docs/demos/autocomplete-required.vue")) as {
default: Component;
};
const alert = vi.spyOn(window, "alert").mockImplementation(() => {});
const wrapper = mount(formDemo.default, { attachTo: document.body });
mounted.push(wrapper);
await nextTick();
@@ -191,20 +198,36 @@ describe("Autocomplete docs and demos", () => {
false,
);
// `Form` renders novalidate and guards submit itself: an empty required
// field must keep the demo's status line empty.
// field must keep the demo's baseline alert silent.
const form = pickerForm;
const submit = (
wrapper.element as HTMLElement
).querySelector<HTMLButtonElement>('button[type="submit"]')!;
submit.click();
await nextTick();
await settle();
expect(form.getAttribute("novalidate")).not.toBeNull();
expect(
(wrapper.element as HTMLElement)
.querySelector('[role="status"]')
?.textContent?.trim() ?? "",
).toBe("");
expect(alert).not.toHaveBeenCalled();
// Choose a value in both required pickers: the valid submit then fires
// the plain baseline success alert (cn/autocomplete/required.tsx).
for (const trigger of root.querySelectorAll<HTMLElement>(
'[data-slot="autocomplete-trigger"]',
)) {
trigger.dispatchEvent(new MouseEvent("click", { bubbles: true }));
await nextTick();
await settle();
const option = document.querySelector<HTMLElement>('[role="option"]')!;
option.click();
await nextTick();
await settle();
}
submit.click();
await nextTick();
await settle();
expect(alert).toHaveBeenCalledTimes(1);
expect(alert).toHaveBeenCalledWith("表单提交成功!");
wrapper.unmount();
mounted.pop();
alert.mockRestore();
});
});
+6 -3
View File
@@ -458,19 +458,22 @@ it("keeps the baseline preview inventories and exact fieldset submission feedbac
).toContain("<template>");
const { default: Demo } =
await import("../apps/docs/demos/fieldset-basic.vue");
const alert = vi.spyOn(window, "alert").mockImplementation(() => {});
const w = mount(Demo, { attachTo: document.body });
await w.get("input[name=name]").setValue("Jane");
await w.get("input[name=email]").setValue("jane@example.com");
await w.get("textarea").setValue("A detailed biography.");
(w.get("form").element as HTMLFormElement).requestSubmit();
await settle();
const status = w.get('[role="status"]');
expect(status.text()).toContain('"name":"Jane"');
expect(status.text()).toContain('"email":"jane@example.com"');
// Baseline feedback: the plain success alert, no inline result row.
expect(alert).toHaveBeenCalledTimes(1);
expect(alert).toHaveBeenCalledWith("表单提交成功!");
expect(w.find('[role="status"]').exists()).toBe(false);
await w.get('button[type="reset"]').trigger("click");
await settle();
expect((w.get("input[name=name]").element as HTMLInputElement).value).toBe(
"",
);
alert.mockRestore();
w.unmount();
});
+9 -10
View File
@@ -242,8 +242,9 @@ describe("Form public validation", () => {
describe("Form fixed-source demos", () => {
it.each([FormBasic, FormRenderFunction])(
"validates both fields, submits exact data, and resets values/errors/results",
"validates both fields, submits exact data via the baseline alert, and resets values/errors",
async (Demo) => {
const alert = vi.spyOn(window, "alert").mockImplementation(() => {});
const w = mount(Demo, { attachTo: document.body });
wrappers.push(w);
const form = w.get("form").element as HTMLFormElement;
@@ -268,19 +269,17 @@ describe("Form fixed-source demos", () => {
submit(form);
await settle();
expect(w.get("[data-slot=field-error]").text()).toBe(error);
expect(w.find('[role="status"]').exists()).toBe(false);
expect(alert).not.toHaveBeenCalled();
}
await password.setValue("Password1");
await settle();
submit(form);
await settle();
expect(w.get('[role="status"]').text()).toContain("表单提交数据:");
expect(w.get('[role="status"]').text()).toContain(
'"email": "john@example.com"',
);
expect(w.get('[role="status"]').text()).toContain(
'"password": "Password1"',
);
expect(alert).toHaveBeenCalledTimes(1);
const message = alert.mock.calls[0][0] as string;
expect(message).toContain("表单提交数据:");
expect(message).toContain('"email": "john@example.com"');
expect(message).toContain('"password": "Password1"');
expect([...new FormData(form)]).toEqual([
["email", "john@example.com"],
["password", "Password1"],
@@ -290,8 +289,8 @@ describe("Form fixed-source demos", () => {
expect((email.element as HTMLInputElement).value).toBe("");
expect((password.element as HTMLInputElement).value).toBe("");
expect(w.find("[data-slot=field-error]").exists()).toBe(false);
expect(w.find('[role="status"]').exists()).toBe(false);
if (Demo === FormRenderFunction) expect(form.dataset.custom).toBe("foo");
alert.mockRestore();
},
);
+5 -1
View File
@@ -445,7 +445,11 @@ describe("M12 demo inventory", () => {
"utf8",
);
expect(textarea).toContain("InputGroupTextArea");
expect(textarea).not.toContain("Tooltip");
// Baseline tooltip contract: the four tooltips are restored (with the
// Enter Kbd hint on the send action) instead of native title attributes.
expect(textarea.match(/<Tooltip\b/g) ?? []).toHaveLength(4);
expect(textarea).toContain('key-value="enter"');
expect(textarea).not.toContain('title="');
});
});
+10 -5
View File
@@ -64,7 +64,7 @@ it("matches the exact baseline 14/6/6 preview inventory and compiles/mounts thei
}
});
it("submits real form data and reports it without pretending to send a network message", async () => {
it("keeps the baseline close-only footer and real named form fields", async () => {
const demo = demos["../apps/docs/demos/modal-with-form.vue"] as Component;
const w = mount(demo, { attachTo: document.body });
try {
@@ -78,12 +78,17 @@ it("submits real form data and reports it without pretending to send a network m
field.dispatchEvent(new Event("input", { bubbles: true }));
const form = document.querySelector("form")!;
expect(new FormData(form).get("name")).toBe("Vue用户");
form.dispatchEvent(
new Event("submit", { bubbles: true, cancelable: true }),
);
// Baseline contract: the footer buttons only close the dialog — the
// example performs no submit and renders no result row.
const send = [
...document.querySelectorAll<HTMLButtonElement>("button"),
].find((button) => button.textContent?.trim() === "发送消息")!;
expect(send).toBeDefined();
send.click();
await flushPromises();
expect(w.get("[role=status]").text()).toContain("Vue用户");
expect(document.querySelector("[role=dialog]")).toBeNull();
expect(w.find("[role=status]").exists()).toBe(false);
expect(w.text()).not.toContain("已记录表单");
} finally {
w.unmount();
await flushPromises();
+11 -2
View File
@@ -72,10 +72,11 @@ describe("TimeField documentation", () => {
w.unmount();
}
});
it("validates business hours and submits the actual value with loading/reset feedback", async () => {
it("validates business hours and submits the actual value with baseline console feedback", async () => {
const w = mount(
demos["../apps/docs/demos/time-field-form-example.vue"] as never,
);
const log = vi.spyOn(console, "log").mockImplementation(() => {});
try {
const input = w.get('[data-slot="time-field-value"]');
await input.setValue("08:30");
@@ -94,12 +95,20 @@ describe("TimeField documentation", () => {
await w.get("form").trigger("submit");
expect(w.get("button").text()).toBe("提交中…");
await vi.advanceTimersByTimeAsync(1500);
expect(w.get("output").text()).toBe("已提交:14:30:45");
// Baseline feedback: the submitted time is logged to the console and
// the field clears; there is no inline output row.
expect(log).toHaveBeenCalledTimes(1);
expect(log.mock.calls[0][0]).toBe("Time submitted:");
expect(String((log.mock.calls[0][1] as { time: unknown }).time)).toBe(
"14:30:45",
);
expect(w.find("output").exists()).toBe(false);
expect((input.element as HTMLInputElement).value).toBe("");
expect(w.get('[data-type="hour"]').attributes("data-placeholder")).toBe(
"true",
);
} finally {
log.mockRestore();
w.unmount();
}
});