Files
heroui-vue/docs/tasks/results/API-ROOT-AND-PROGRESS-DEMO.md
T

59 lines
7.6 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.
# API-ROOT-AND-PROGRESS-DEMO 交付
- 分支 `task/api-root-and-progress-demo`;起点 `e0dd052cc3626303ee0dbeb74c4f9ad69f938998`(含本任务卡);此前 main 同 `e0dd052`。
- 实施提交 `8f51b0e097968d5560b4871a279d07c2900046da`(代码、任务卡、README 任务表);结果/进度记录见本提交。未合 main、未 push。
- 固定源 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/*/index.ts` 公开导出、`apps/docs/src/demos/cn/progress-bar/custom-value.tsx`、`apps/docs/content/docs/cn/react/components/meta.json`;只读核对。
## 一、Root 别名映射(上游名称 → Vue 现有组件 → 目标别名 → 状态)
核对口径:以固定上游每个组件 barrel 的公开值导出为准,取 `XxxRoot` 且上游同名导出 `Xxx` 的成对根名(含上游自有组件模块的 `ListBoxItemRoot/ListBoxSectionRoot/MenuItemRoot/MenuSectionRoot/DateInputGroupRoot`)。机器可读完整清单与断言在 `tests/package/client-checks.json` 的 `api-root-aliases.aliases`(82 对)。
| 类别 | 数量 | 明细 |
| --- | --- | --- |
| 本轮新增 `XxxRoot` 值别名 | 55 | Accordion、Alert、Autocomplete、AvatarGroup、Badge、Breadcrumbs、Button、ButtonGroup、Card、Checkbox、Chip、CloseButton、ComboBox、DateInputGroup、Description、Disclosure、DisclosureGroup、EmptyState、ErrorMessage、FieldError、Fieldset、Input、InputGroup、Kbd、Label、Link、ListBoxItem、ListBoxSection、MenuItem、MenuSection、Meter、Modal、Popover、ProgressBar、ProgressCircle、Radio、RadioGroup、ScrollShadow、SearchField、Separator、Skeleton、Spinner、Surface、Switch、SwitchGroup、Tabs、Tag、TagGroup、TextArea、TextField、ToggleButton、ToggleButtonGroup、Toolbar、Tooltip、Typography(各补 `+Root` 同对象导出) |
| 本轮新增反向别名 | 1 | `Dropdown`(此前仅 `DropdownRoot`;上游导出双名) |
| 基线已有双名(不改) | 26 | AlertDialog、Avatar、Calendar、ColorArea、ColorField、ColorInputGroup、ColorPicker、ColorSlider、ColorSwatch、ColorSwatchPicker、DateField、DatePicker、DateRangePicker、Drawer、Form、Header、InputOTP、ListBox、Menu、NumberField、Pagination、RangeCalendar、Select、Slider、Table、TimeField |
| 合计上游成对根名 | 82 | 与上游逐项一致,缺口 0(审计脚本重跑确认) |
类型侧(同一类型双名,不杜撰上游没有的名称):新增 57 个 `XxxRootProps`(上表 55 项减 MenuItem/MenuSection 加 AlertDialog/Drawer)+ `MenuItemRootProps`、`MenuSectionRootProps`、`MenuProps`、`DropdownProps`,共 59 个。例外:上游无 `CheckboxGroupRoot`(checkbox-group 只导出 `CheckboxGroup`)故不加;上游 toast barrel 只导出 `Toast`(无 `ToastRoot`/`ToastRootProps`),本库 `ToastRoot` 值兼容名保留不删、不计入 82 对;上游无 `TagProps`(只有 `TagRootProps`),本库 `TagProps` 旧名保留;`ColorField*` 等 3 项经 `export type *` 已有 RootProps,非缺口。上游 `Xxx.Props` 复合类型命名空间属 React 类型机制,列为框架语义差异,不平移。
## 二、ProgressBar 演示回填
`apps/docs/demos/progress-bar-custom-value.vue`(预览/复制/高亮同一 SFC,文件名未变)用包根公共 NumberField(Group/Input/IncrementButton/DecrementButton)替换三个原生 number input,公共 Select(Trigger/Value/Indicator/Popover + ListBox/ListBoxItem/Indicator)替换原生 select;保留固定源中文文案、顺序、布局、初始 750/0/1000、四格式选项与 `variant="secondary"`。边界沿用既有处理并明确:清空/无效草稿拒绝并恢复上一接受值;越界提交收敛到当前范围。`progress-bar.md` 与 `compatibility.md` 的“原生临时控件”陈述已修正;其他 progress/indicator 演示扫描无同类临时替代。
## 场景与证据
| 验收场景 | 断言或复现步骤 | 实际结果 |
| --- | --- | --- |
| 别名完整清单 | `node scripts/task-check.mjs` 前置 + 审计脚本对照上游 barrel | 55 项与报告口径一致(55 缺 Root + 1 反向 `Dropdown`);重跑缺口 0 |
| 别名身份等价 | `node scripts/check-package.mjs api-root-aliases`(`check-client.mjs` 遍历 82 对 `lib[a]===lib[b]`、164 具名导出) | 通过(最终 tarball) |
| 别名类型/事件/插槽/实例 | `tests/package/api-root-aliases-contract.ts` strict NodeNext/bundler 正反例(`Same<>` 等价、`h()` 属性/事件/插槽、`@ts-expect-error` 变体与事件负载反例) | 通过(最终 tarball;泛型函数式 ListBox/Calendar 以组件对象等价覆盖实例成员) |
| 演示输入/步进 | `pnpm exec vitest run tests/progress-meter.test.ts`(6 个 custom-value 用例)+ 真实浏览器键入 500 → 500/50%/50%;增/减按钮 → 501(fill 50.1%)/500 | 通过 |
| 清空/无效草稿 | 单测:清空/`abc`/`-` 拒绝恢复、无 NaN;浏览器:清空 + Tab 恢复“500”,字母被输入层过滤 | 通过 |
| 动态上下限 | 单测 + 浏览器:min→800 时值 200→800(min=800、输出 0%);max→600 时值 900→600(max=600、输出 100%、增量按钮禁用) | 通过 |
| 四格式与键盘 | 浏览器 Select:ArrowDown 打开面板(208×168、4 项可见可点)→ ArrowDown+Enter 选 小数/单位(输出 600 / 600英里,页内 Intl 计算一致);点击 货币 → US$600.00,面板关闭、选择值回显 | 通过 |
| 浅深主题/窄屏/控制台 | 明确深色与浅色各截图;390px 同源 iframe:documentScrollWidth==clientWidth==390 无页面横向溢出、演示纵排、表无溢出;console 无 warn/error | 通过(截图存 opencode-browser 临时目录) |
| 单测/类型/文档构建 | `pnpm exec vitest run tests/progress-meter.test.ts tests/number-field.test.ts tests/select.test.ts tests/docs-shell.test.ts`(91 项)、`pnpm typecheck`、`pnpm build:docs` | 通过(chunk 大小提示为既有) |
| 最终产物回归 | `node scripts/check-package.mjs api-root-aliases form avatar b01-menu-dropdown` | 通过 |
| 文档排序 | 对照固定 meta.json 逐项审计 74 项:仅 `dropdown` 错位(位于 link 后),已归位 drawer 后;empty-state/header 为真实 Vue 页按字母位;类别全匹配;`docs-shell.test.ts` 增加固定顺序断言 | 通过 |
相关命令:
```sh
pnpm exec vitest run tests/progress-meter.test.ts tests/number-field.test.ts tests/select.test.ts tests/docs-shell.test.ts
pnpm typecheck
pnpm build:docs
node scripts/check-package.mjs api-root-aliases form avatar b01-menu-dropdown
```
## 缺陷修复(随本任务)
NumberFieldInput 的 `keydown` 在任意按键后 `nextTick(restore)`,会把同任务内真实键入的字符还原(同任务 keydown+insertText 探针:`1,0005` 微任务后回退 `1,000`;逐步键入/退格呈“每次从提交文本重算”)。已改为仅状态键(步进/边界/Enter)恢复提交文本,普通键入保留草稿;`tests/number-field.test.ts` 新增键入保留回归(16 项通过)。受影响面核对:既有受控拒绝/清空恢复、步进边界、表单用例全部保持通过。
## 未完成与限制
- 全量 `pnpm test` 未跑(按任务卡与 tests/README 选取相关套件;集成阶段再全量)。
- NumberField 键入修复的真实输入链路由浏览器键入与同任务探针验证;未做人工 IME 逐输入法矩阵(不在范围)。
- 逐像素对比、完整读屏矩阵、真机矩阵、SSR/水合/Nuxt 不在范围。`ToastRoot`/`TagProps` 等本库兼容旧名保留并已记录;未新增上游不存在的名称。
- 上游 `Xxx.Props` 复合类型命名空间未平移(React 类型机制差异),如需另行立项。