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