From 53e76f676d55de9822e7550b4260816c486ab3fe Mon Sep 17 00:00:00 2001 From: maoyingjie Date: Wed, 28 Oct 2026 14:10:10 +0800 Subject: [PATCH] fix(demos): restore form, overlay and toast demos to the pinned cn baseline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- apps/docs/components/fieldset.md | 2 +- apps/docs/components/form.md | 48 +++---- apps/docs/components/input-group.md | 2 - apps/docs/components/label.md | 2 +- apps/docs/components/number-field.md | 2 +- apps/docs/components/search-field.md | 2 +- apps/docs/components/select.md | 2 +- apps/docs/components/time-field.md | 2 +- apps/docs/components/toast.md | 14 +- .../demos/alert-dialog-custom-animations.vue | 9 +- .../docs/demos/alert-dialog-custom-portal.vue | 11 +- .../docs/demos/alert-dialog-custom-styles.vue | 4 + apps/docs/demos/alert-dialog-sizes.vue | 5 +- apps/docs/demos/autocomplete-required.vue | 11 +- apps/docs/demos/card-default.vue | 2 +- apps/docs/demos/card-with-form.vue | 27 +--- apps/docs/demos/card-with-images.vue | 2 +- apps/docs/demos/checkbox-form.vue | 13 +- apps/docs/demos/checkbox-group-validation.vue | 6 +- .../demos/combo-box-custom-validation.vue | 6 +- apps/docs/demos/combo-box-on-surface.vue | 8 +- apps/docs/demos/combo-box-required.vue | 11 +- apps/docs/demos/fieldset-basic.vue | 14 +- apps/docs/demos/fieldset-custom-styles.vue | 14 +- apps/docs/demos/fieldset-on-surface.vue | 18 +-- apps/docs/demos/form-basic.vue | 16 +-- apps/docs/demos/form-custom-styles.vue | 2 +- apps/docs/demos/form-render-function.vue | 17 +-- apps/docs/demos/input-group-with-textarea.vue | 83 +++++++----- .../demos/list-box-with-disabled-items.vue | 106 ++++++++------- apps/docs/demos/list-box-with-sections.vue | 104 +++++++-------- apps/docs/demos/modal-with-form.vue | 124 ++++++++---------- apps/docs/demos/number-field-form-example.vue | 14 +- apps/docs/demos/number-field-full-width.vue | 2 +- apps/docs/demos/radio-group-validation.vue | 2 +- apps/docs/demos/search-field-form-example.vue | 10 +- apps/docs/demos/select-on-surface.vue | 10 +- apps/docs/demos/select-required.vue | 13 +- apps/docs/demos/switch-form.vue | 30 ++--- apps/docs/demos/time-field-form-example.vue | 8 +- apps/docs/demos/toast-custom-indicator.vue | 2 +- apps/docs/demos/toast-custom-queue.vue | 90 +++++++------ apps/docs/demos/toast-simple.vue | 48 ++++--- apps/docs/demos/toast-variants.vue | 52 ++++---- docs/upstream.md | 4 +- .../components/toast/ToastActionButton.vue | 6 +- tests/aligned-components.test.ts | 22 +++- tests/autocomplete-demos.test.ts | 39 ++++-- tests/fieldset-search-field.test.ts | 9 +- tests/form.test.ts | 19 ++- tests/input-group.test.ts | 6 +- tests/overlay-demos.test.ts | 15 ++- tests/time-field-demos.test.ts | 13 +- 53 files changed, 531 insertions(+), 572 deletions(-) diff --git a/apps/docs/components/fieldset.md b/apps/docs/components/fieldset.md index 51918af..96e92f4 100644 --- a/apps/docs/components/fieldset.md +++ b/apps/docs/components/fieldset.md @@ -123,7 +123,7 @@ Fieldset 复合组件暴露以下 CSS 选择器: 三个部件使用对应 BEM 基础类,class 接受字符串、数组和对象。命名导出替代 React 对象式子部件;原生属性直接传递,不使用 nativeProps 对象。根元素固定为语义化原生元素,暂不提供 React render 根元素替换。 -Fieldset 不维护字段值或校验队列。请使用 Form + TextField / SearchField,提交与 reset 沿用原生表单;示例展示实际 FormData 与成功反馈,不执行后台保存。 +Fieldset 不维护字段值或校验队列。请使用 Form + TextField / SearchField,提交与 reset 沿用原生表单;示例以 `alert` 给出成功反馈,不执行后台保存。 ## 相关组件 diff --git a/apps/docs/components/form.md b/apps/docs/components/form.md index 023ce8f..fd0f24b 100644 --- a/apps/docs/components/form.md +++ b/apps/docs/components/form.md @@ -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` | `{}` | 按字段名映射的服务端错误;编辑该字段后忽略当前响应中的错误 | -| `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` | `{}` | 按字段名映射的服务端错误;编辑该字段后忽略当前响应中的错误 | +| `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 方式适配。当前仅支持浏览器客户端;未将完整读屏矩阵或逐像素比较视为已完成。 ## 相关案例 diff --git a/apps/docs/components/input-group.md b/apps/docs/components/input-group.md index 76b5b89..78b7918 100644 --- a/apps/docs/components/input-group.md +++ b/apps/docs/components/input-group.md @@ -167,8 +167,6 @@ InputGroup 会自动反映父级 TextField 的无效状态。 多行输入请使用 **InputGroupTextArea**,并搭配前缀与后缀。当存在 textarea 时,容器高度会自动适应内容,并将前缀/后缀与顶部对齐。 -上游示例中的 Tooltip 由原生 `title` 与 `aria-label` 适配(Tooltip 组件尚未迁移)。 - ## 自定义样式 diff --git a/apps/docs/components/label.md b/apps/docs/components/label.md index ec6da56..6366e8f 100644 --- a/apps/docs/components/label.md +++ b/apps/docs/components/label.md @@ -52,7 +52,7 @@ import { Label, Input } from "@heroui-vue/components"; ``` diff --git a/apps/docs/components/number-field.md b/apps/docs/components/number-field.md index 8c33101..ec93618 100644 --- a/apps/docs/components/number-field.md +++ b/apps/docs/components/number-field.md @@ -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 参数。 diff --git a/apps/docs/components/search-field.md b/apps/docs/components/search-field.md index 06e79b3..55eb6c3 100644 --- a/apps/docs/components/search-field.md +++ b/apps/docs/components/search-field.md @@ -103,7 +103,7 @@ SearchField 组件支持两种视觉变体: ### 表单示例 -完整的表单集成示例,包含校验、实际 FormData 和模拟提交反馈;没有后台搜索请求。 +完整的表单集成示例,包含校验与模拟提交(提交值输出到控制台);没有后台搜索请求。 diff --git a/apps/docs/components/select.md b/apps/docs/components/select.md index fd5486d..54ff581 100644 --- a/apps/docs/components/select.md +++ b/apps/docs/components/select.md @@ -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。 ## 相关组件 diff --git a/apps/docs/components/time-field.md b/apps/docs/components/time-field.md index cb36ccc..9c928c8 100644 --- a/apps/docs/components/time-field.md +++ b/apps/docs/components/time-field.md @@ -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 不重复发送已经接受的值。 diff --git a/apps/docs/components/toast.md b/apps/docs/components/toast.md index 96c8fbe..b7dccd5 100644 --- a/apps/docs/components/toast.md +++ b/apps/docs/components/toast.md @@ -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 diff --git a/apps/docs/demos/alert-dialog-custom-animations.vue b/apps/docs/demos/alert-dialog-custom-animations.vue index fbb814e..99a96cb 100644 --- a/apps/docs/demos/alert-dialog-custom-animations.vue +++ b/apps/docs/demos/alert-dialog-custom-animations.vue @@ -1,5 +1,8 @@ @@ -144,8 +140,5 @@ function onSubmit(event: Event) { -

- {{ message }} -

diff --git a/apps/docs/demos/card-default.vue b/apps/docs/demos/card-default.vue index aea6f15..b6e40a1 100644 --- a/apps/docs/demos/card-default.vue +++ b/apps/docs/demos/card-default.vue @@ -12,7 +12,7 @@ import { diff --git a/apps/docs/demos/combo-box-on-surface.vue b/apps/docs/demos/combo-box-on-surface.vue index f580e7f..dabb6a1 100644 --- a/apps/docs/demos/combo-box-on-surface.vue +++ b/apps/docs/demos/combo-box-on-surface.vue @@ -1,5 +1,4 @@ @@ -64,9 +61,6 @@ function onSubmit(event: Event) { -

- {{ message }} -

diff --git a/apps/docs/demos/combo-box-required.vue b/apps/docs/demos/combo-box-required.vue index 6195ff9..ed36f5c 100644 --- a/apps/docs/demos/combo-box-required.vue +++ b/apps/docs/demos/combo-box-required.vue @@ -1,5 +1,4 @@ @@ -63,8 +59,5 @@ function submit(event: Event) { -

- 表单提交成功! -

diff --git a/apps/docs/demos/fieldset-basic.vue b/apps/docs/demos/fieldset-basic.vue index 1469e29..9f4f2da 100644 --- a/apps/docs/demos/fieldset-basic.vue +++ b/apps/docs/demos/fieldset-basic.vue @@ -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("表单提交成功!"); } diff --git a/apps/docs/demos/fieldset-custom-styles.vue b/apps/docs/demos/fieldset-custom-styles.vue index 7d20119..aa668df 100644 --- a/apps/docs/demos/fieldset-custom-styles.vue +++ b/apps/docs/demos/fieldset-custom-styles.vue @@ -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 =