Files
heroui-vue/docs/migrations/FORM-02-fieldset-search-field.md
T
2026-10-22 08:46:02 +08:00

40 lines
4.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# FORM-02 Fieldset / SearchField 与禁用基建
日期:2026-10-22。起点 `1160568`,初始工作区干净;本批由集成人实施。
## 范围与架构
- Fieldset / FieldsetLegend / FieldGroup / FieldsetActions 四个具名部件,原生语义,CSS 与 tv 从固定 ce90ea3 移植,仅 hv- 命名空间适配。
- 禁用作用域 `field/disabled.ts` 接入 TextField、独立 Input/TextArea、Label、Button、CloseButton、Link、Switch、SearchField。动态变化保持 ARIA/data/可交互性与 FormData 一致;本库 Fieldset 的首个直接 Legend 保留原生例外,内层 disabled=false 不能解除祖先禁用。keyed Legend 例外位置变化保留输入状态。
- 从既有 TextField 抽取 `field/useTextField.ts`,保持原有值、初始值、校验、Form、描述注册与 SSR 预规划。TextField 与 SearchField 共用内核,后者不挂额外 TextField DOM/CSS,也不复制字段状态。已存在测试全部回归。
- SearchField / Group / Input / SearchIcon / ClearButton 五个部件;Group 预规划明确的控件 ID,原始 Enter 表单提交与专属 submit 回调分开,调用方 root/input keydown 可取消;支持 IME/repeat 防护、Escape 非空清空、readonly/disabled、受控拒绝与焦点恢复。
- CloseButton 允许 data-slot 覆盖以接 SearchField 清除状态;其捕获 guard 和 Button guard 在用户捕获监听前阻止禁用激活。默认 IconSearch 来自基线 icons.tsx,沿用现有默认 CloseIcon;示例自定义图标使用 Tabler。
## 基线内容
- Fieldset 3/3:basic、on-surface、custom-styles;姓名/邮箱/简介、同步校验、保存/取消、Surface 与定制样式保持。新增 disabled 协议验证例另计。
- SearchField 15/15:basic、variants、on-surface、with-description、required、disabled、full-width、validation、controlled、form-example、with-validation、custom-icons、with-keyboard-shortcut、render-function、custom-styles。预览/复制/高亮共用 SFC。
- 基线 alert/console 提交反馈在 Vue 演示中改为 role=status 的实际 FormData/模拟查询结果;没有后台保存或搜索。定时器和快捷键监听卸载清理。Fieldset Surface 示例补窄屏 min-width 约束;未改变桌面目标宽度。
- Vue 不提供 React render 自定义根类型,根属性透传保留基线 div+data-custom 示例效果。原生属性直接透传而非 nativeProps。错误仍通过 Form.validationErrors,校验暂仅同步。
## 验证
- `pnpm test`:14 文件 / 226 项,含 node SSR 4 项。
- `pnpm test:unit`:13 文件 / 222 项,不含 node SSR;包含实际 jsdom 水合。
- `pnpm typecheck`、`pnpm build:docs`、`pnpm format`、`git diff --check` 通过。
- 新增专项 17 项、node SSR 1 项:禁用传播、首个/多个/原生/动态 Legend、嵌套、FormData、省略、受控拒绝、reset/取消、clear/focus、Enter/Escape、IME/repeat、事件取消/数组、SSR/水合、动态 attrs/变体/图标、实际字段演示提交与 reset、SSR 叶子初始值和显式 ID 删除。
- 组件 CSS 还原 hv- 前缀、去注释与空白后与固定基线一致;styles/index.css 另有明确的 Vue Legend 标签适配,防止祖先禁用选择器压暗原生例外中的可用标签;公共类型产物检查见 verification.md。
## 浏览器实测(5173)
- /components/search-field:清空后 value=''、实际 input 保持焦点、按钮 aria-hidden=true 且 opacity=0;Escape 清空;Enter 表单提交出现搜索中…,完成反馈“已模拟提交搜索:verified query”,值恢复为空。
- SearchField 浅/深切换,深色 group 背景 oklch(0.2103 0.0059 285.89),高度 36px、圆角 12px。390×844 时所有 group 在视口内,四张 API/事件/插槽表 350px,无水平溢出。
- /components/fieldset:无效提交显示姓名/邮箱/简介错误;填入 Jane / jane@example.com / 详细简介后真实 FormData 反馈正确。禁用例组外提交={};Legend 操作可用;启用后提交 name/notifications/nested 值。首个 Legend 内 Label 实测 opacity=1、pointer-events=auto,点击能激活其关联按钮。390×844 页面与表格无溢出;1280×900 表格均为 736px 与正文等宽。
- 控制台 error/warn 为空。临时主题恢复浅色,视口恢复正常。截图 `/private/tmp/heroui-vue-form02-fieldset.png`。
## 边界与后续
未完成独立打包安装、自动视觉比较、完整读屏/触屏/RTL、Nuxt;没有据 CSS 一致宣称逐像素一致。Fieldset 仅静态识别直接/Fragment 中的 Legend,不识别任意自定义 Vue 包装内部的原生 Legend。
Checkbox/Radio 分组底座发现 disabled 原生值与 reset 缺口,实测和实施契约见 `docs/decisions/selection-field-foundation.md`,仍由集成人先实施。Typography/EmptyState/Breadcrumbs 可继续交给其他 AI,明确冻结共享字段、禁用、Form 与 SearchField 协议。