Files
heroui-vue/docs/migrations/M13-field-docs.md
T

106 lines
6.5 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.
# M13 字段文档交接报告
实施日期:2026-10-21。状态:实施者自测完成,待集成人复核。**未提交、未推送。**
## 1. 起点与范围
| 项 | 值 |
| --------- | ---------------------------------------------------------------------------------------- |
| 起始 HEAD | `37e11e6`(feat: add InputGroup and verify shared field integration) |
| 工作区 | 干净;未改 field/useFieldPart/useTextControl/TextField/Form guard/Switch/InputGroup 核心 |
| 上游 | HeroUI 3.2.6 / `ce90ea3`(`../heroui` 只读) |
| 范围 | TextField、Label、Description、FieldError 四个独立中文文档页及全部基线内容 |
## 2. 交付
### 文档页(新建)
- `apps/docs/components/text-field.md`(13 预览)
- `apps/docs/components/label.md`(2 预览)
- `apps/docs/components/description.md`(2 预览)
- `apps/docs/components/field-error.md`(2 预览)
### 演示(新建 16;复用 3)
复用:`textfield-basic` / `textfield-with-description` / `textfield-validation`(FORM-01 已有)。
新建 TextField 10:on-surface、required、disabled、full-width、controlled、with-error、textarea、input-types、render-function、text-field-custom-styles。
新建 Label 2、Description 2、FieldError 2。
### 其他
- 导航与 `components.md` 增加四页;`fields.md` 保留基础设施用途并链接组件页。
- `tests/field-docs-textarea.test.ts`(与 M14 共用,见 M14 报告)。
## 3. 上游来源
| 路径 | 用途 |
| --------------------------------------------------------------------------- | ---------------------------------------- |
| `.../(forms)/{text-field,label,description,field-error}.mdx` | 标题、结构、示例次序、正文代码、API 叙述 |
| `apps/docs/src/demos/cn/{textfield,label,description,field-error}/` | 16 个新演示的文案与布局 |
| `packages/react/src/components/{textfield,label,description,field-error}/*` | API 语义对照 |
| `packages/styles/components/{textfield,label,description,field-error}.css` | 样式类说明(hv- 已存在) |
## 4. 示例与正文对照
- TextField 13/13:名称与 CN 文档顺序一致;custom-styles 预览名保持上游 `text-field-custom-styles`。
- Label/Description/FieldError 各 2/2。
- 正文代码示例已改为 Vue:Label 必填/禁用/无效;Description 搭配表单与 TextField;FieldError 基础校验、动态错误(作用域插槽)、自定义校验(含 validate)、多条错误(v-for)。
## 5. API 差异(Vue 契约)
| 上游 | Vue |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `htmlFor` | `for` |
| `value`/`onChange` | `v-model` / `update:modelValue` |
| `className`/`children` | `class` / 默认插槽 |
| `render` 自定义根 | 未支持元素类型替换;`data-*` 透传到根(render-function 示例已注明) |
| FieldError render `(validation)=>` | 作用域插槽 `validationErrors` / `isInvalid` |
| `validationErrors` 数组 prop | Form `validation-errors`(按 name 映射) |
| TextFieldRenderProps | 作用域插槽 isDisabled/isReadOnly/isRequired/isInvalid/validationErrors;无 isFocusWithin/isFocusVisible |
不提供完整 `validationDetails`;文档已注明。
## 6. 回归与命令
| 要求 | 结果 |
| --------------------------------- | --------------------------- |
| 文档契约(无 className/children) | 测试通过 |
| 预览清单 13+2+2+2 | 测试通过 |
| 三份既有示例与 /fields 保留 | 测试通过 |
| Label/Description/FieldError 关联 | field-foundation + 本批测试 |
`pnpm test` 13 文件 / **201**(含 SSR 3);`pnpm test:unit` 12 文件 / **198**(不含 SSR);typecheck / build:docs / format 通过。
## 7. 浏览器证据
`http://127.0.0.1:5173`:text-field 22 字段 / data-custom 1;field-error 输入 "ab" 显示错误;四页 API 表桌面与 390 窄屏均无溢出。
## 8. 未验证
浅/深切换交互、位图、Nuxt、RTL、读屏、独立安装、逐像素。
## 9. 最短复核步骤
1. `pnpm test && pnpm typecheck && pnpm build:docs`
2. 打开 `/components/text-field` 数预览 13;核对 render 示例注释。
3. `/components/label`、`description`、`field-error`:对照正文代码是否 Vue 且可运行。
4. `/fields` 仍为指南页并链接四个组件页。
## 10. 需集成人确认
- TextField 根元素类型自定义(render/asChild)是否列入后续协议扩展。
- custom-styles 预览名 `text-field-custom-styles` 与 `textfield-*` 前缀不一致(对齐上游命名)。
实施者不宣布验收通过。
## 11. 复核返工记录(实施者,2026-10-21)
独立复核两项 P2 已修:
1. FieldError「动态错误信息」「多条错误信息」正文示例:补 `password` + `validatePassword` 真实错误源,使用 FieldError 作用域插槽与 `validation-behavior="aria"`;多条示例返回两条错误并 v-for 渲染。完整 SFC 可编译,输入 `abc` 显示预期消息。
2. TextField API 表补齐 `autoComplete`、`inputMode`、`form`,以及 `update:modelValue` 事件与 `focus`/`element` 暴露;TextArea 页补事件与暴露说明。
回归新增:正文 SFC 脚本绑定检查、动态/多条错误消息行为、API 表关键字、`autoComplete`/`inputMode`/`form` 下发到真实控件、focus/element 暴露。`pnpm test` **208**(+7)、typecheck、format 通过。未改共享 field/TextField/Form 核心。