diff --git a/apps/docs/components/color-swatch.md b/apps/docs/components/color-swatch.md index 4ff5927..5e582f0 100644 --- a/apps/docs/components/color-swatch.md +++ b/apps/docs/components/color-swatch.md @@ -109,6 +109,8 @@ ColorSwatch 组件使用以下 CSS 类([查看源码样式](https://github.com `class` 遵循 Vue 的 class 绑定,可接收字符串、数组和对象,并与组件基础类合并;不要使用 React 的 `className`。`color` 省略或为 `undefined` 时继承最近的共享颜色 owner;`null` 与空字符串是显式清空。无效颜色字符串按本库 `parseColor` 边界抛出 `RangeError`。 +`style` 与 `styleFn` 可同时使用,合并顺序为组件基础样式 → `style` → `styleFn`;冲突属性由 `styleFn` 覆盖,普通样式不会因函数样式存在而丢失。 + 组件通过 `defineExpose` 暴露 `element`,指向实际根 DOM 元素;普通 `ref` 仍指向组件实例。`aria-roledescription` 与透明颜色的自动名称随 `ConfigProvider` 的 `locale` 切换;默认 `en-US`。 ### Style Render diff --git a/docs/tasks/ACTIVE.md b/docs/tasks/ACTIVE.md index 9fb36cb..d15a431 100644 --- a/docs/tasks/ACTIVE.md +++ b/docs/tasks/ACTIVE.md @@ -1,8 +1,8 @@ # 当前工作区交接 -- 任务:无进行中任务;COLOR-SWATCH 已交付到任务分支。 +- 任务:无进行中任务;COLOR-SWATCH 两项复核问题已修复并交付到任务分支。 - 工作区/分支:heroui-vue / feat/color-swatch-public(起点 60af6ee,未合 main、未 push)。 -- 结果入口:docs/tasks/results/COLOR-SWATCH.md。 +- 结果入口:docs/tasks/results/COLOR-SWATCH.md(含 CS-1/CS-2 返修记录)。 - 下一步:由用户选择新任务;不自动开始下一任务。 这里只记录当前占用和接续入口,不重复任务状态表。单目录串行;新会话先核对git状态,有进行中任务时不切分支覆盖。支持范围统一见AGENTS.md。 diff --git a/docs/tasks/results/COLOR-SWATCH.md b/docs/tasks/results/COLOR-SWATCH.md index 58c6d34..e1e2cca 100644 --- a/docs/tasks/results/COLOR-SWATCH.md +++ b/docs/tasks/results/COLOR-SWATCH.md @@ -19,7 +19,7 @@ | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | 行为与共享 owner | `pnpm exec vitest run tests/color-swatch.test.ts tests/color-swatch-demos.test.ts tests/color-foundation.test.ts tests/color-picker-composition.test.ts` | 67 项通过;含默认/显式/空值/无效色/透明度/动态更新/灰色hue/精度/attrs/ref/插槽/as/asChild/style/styleFn | | 颜色协议回归 | 同一命令;另跑 `tests/color-field-protocol`、`color-input-foundation`、`color-picker-protocol`、`color-slider-foundation`、`regressions/color/*` | 10 个颜色套件 150 项通过;`Color` 构造与公共类型调整未改接受值语义 | -| 全量客户端回归 | `pnpm test` | 88 文件 / 1293 项通过,无 skip;覆盖导航/总览新增分类 | +| 全量客户端回归 | `pnpm test` | 89 文件 / 1295 项通过,无 skip;覆盖导航/总览新增分类与两条组合回归 | | 公开类型 | `pnpm typecheck` | 通过;正反例覆盖 shape/size/color/styleFn/ColorChannel/ColorSpace/ColorInput,无 unused `@ts-expect-error` | | 文档生产构建 | `pnpm build:docs` | 通过;7 例由同一 SFC 进入预览/高亮 | | 独立tarball | `node scripts/check-package.mjs color-swatch` | 通过:包根导出、`colorSwatchVariants`、CSS/棋盘/变体、`parseColor` alpha;strict NodeNext 与 bundler 契约通过;构建声明无 `reka-ui`/Wire 泄漏 | @@ -34,3 +34,32 @@ - 未移植 React Stately 的色名表/`getColorName` 等全量 Color 辅助 API;无 `colorName` 时使用透明文案或 hex/hexa 作为自动描述,并已在文档记录。 - 继承使用本库共享颜色 owner;ColorSwatchPicker 的 `ColorSwatchContext` 与其私有选择家族未迁移,当前公共消费者尚无公开 Picker owner 可组合。 - `ColorSwatchPicker`、ColorArea/ColorField/ColorPicker/ColorSlider 等公共家族仍待后续任务;本提交不自动开始下一任务。 + +## 集成人复核(2026-10-26,270dea5) + +结论:暂不通过,先修下面同一问题表,不安排新组件。本轮未修改实现。 + +| ID | 来源 | 问题 / 复现 | 当前证据 | +| ---- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | +| CS-1 | 原组合契约遗漏 | ColorSwatch asChild,外层aria-labelledby="caption",插槽根id="child-id";Reka保留子元素ID,但组件仍输出自身生成ID作为aria-labelledby前缀,引用不存在的节点。动态更换子ID也须保持关联。 | tests/regressions/color/swatch-composition.test.ts 第一例失败:实际v-0 caption,DOM id为child-id | +| CS-2 | Vue样式适配回归 | 模板同时传:style="{outline:'2px solid red'}"与:style-fn="()=>({opacity:0.5})",styleFn分支直接忽略标准style;两者声明均允许且没有互斥说明,调用方普通样式丢失。普通样式应与计算样式保留,并明确冲突属性优先级。 | 同文件第二例失败:outline为空;预期普通outline和函数opacity都保留 | + +原4套/67项通过;新增2项均复现失败。保留这两项作为后续增量复核,不再按返修轮次新增探针或重复全库检查。CS-1修复需使用Vue公开VNode/透传能力,不能通过读取DOM后伪造ARIA或侵入私有ref结构;保留子元素/调用方ID、ref和动态更新。CS-2不需要新增另一种style API。 + +Color.toWire目前仍出现在公开class声明中,虽然没有泄漏Reka具名类型;它是既有桥接函数。请顺带核对是否应标为内部,而不要将其描述为完整RAC Color接口或为此重写颜色模型。本项为API边界提示,不新增本轮能力要求。 + +## 返修结果(CS-1 / CS-2) + +- 实施:在当前 `feat/color-swatch-public` 分支修复;准确 SHA 见本文件所在提交。 +- CS-1:改为一次读取默认作用域插槽的公开 VNode,取唯一有效根元素的 `id` 作为 `aria-labelledby` 前缀;优先级为子元素 `id` → 调用方 `id` → 生成 id,和 Reka Slot 的实际合并规则一致。未读取 DOM 后伪造 ARIA,未访问私有 ref 结构;子元素 id 动态更新、普通 `attrs`、`ref` 仍由公开 VNode/透传路径保留。复核用例 `tests/regressions/color/swatch-composition.test.ts` 第一例通过。 +- CS-2:普通 `style` 与 `styleFn` 同时参与渲染,合并顺序为基础样式 → `style` → `styleFn`;冲突属性由 `styleFn` 覆盖。文档已明确该顺序。复核用例第二例通过。 +- `Color.toWire` 仍作为既有内部桥接保留在类上并标注 `@internal`;它返回本库 `ColorInput`,不泄漏 Reka 命名类型,也未新增为文档化 RAC API。 + +| 检查 | 结果 | +| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| 两条组合回归 | `pnpm exec vitest run tests/regressions/color/swatch-composition.test.ts`:2/2 通过 | +| Swatch 定向套件 | `tests/color-swatch.test.ts`、`tests/color-swatch-demos.test.ts`:27/27 通过;任务卡五文件(含 foundation/picker 与回归)69/69 通过 | +| 全量回归 | `pnpm test`:89 文件 / 1295 项通过,无 skip | +| 类型与文档构建 | `pnpm typecheck`、`pnpm build:docs` 通过 | +| 独立产物 | `node scripts/check-package.mjs color-swatch` 通过;最终声明仍暴露 `element` 且无 Reka/Wire 泄漏 | +| 浏览器复验 | 5185 重新打开 `/components/color-swatch`:7 个预览、尺寸/圆角/透明度/棋盘、styleFn 发光/渐变、asChild `data-custom` 均正常;无控制台错误与横向溢出 | diff --git a/packages/vue/src/components/color-swatch/ColorSwatch.vue b/packages/vue/src/components/color-swatch/ColorSwatch.vue index bcea0f1..b94d474 100644 --- a/packages/vue/src/components/color-swatch/ColorSwatch.vue +++ b/packages/vue/src/components/color-swatch/ColorSwatch.vue @@ -1,13 +1,21 @@ diff --git a/packages/vue/src/components/color/value.ts b/packages/vue/src/components/color/value.ts index 07d0e3d..5fbe631 100644 --- a/packages/vue/src/components/color/value.ts +++ b/packages/vue/src/components/color/value.ts @@ -128,7 +128,7 @@ export class Color { : raw, ); } - /** Internal conversion bridge, omitted from the public Color instance type. */ + /** @internal Conversion bridge for library keying and tests. */ static toWire(value: Color): ColorInput { return { ...value.#value }; } diff --git a/tests/regressions/color/swatch-composition.test.ts b/tests/regressions/color/swatch-composition.test.ts new file mode 100644 index 0000000..595338a --- /dev/null +++ b/tests/regressions/color/swatch-composition.test.ts @@ -0,0 +1,51 @@ +import { afterEach, expect, it } from "vitest"; +import { mount } from "@vue/test-utils"; +import { defineComponent, h, ref, nextTick } from "vue"; +import { ColorSwatch } from "../../../packages/vue/src"; + +const wrappers: ReturnType[] = []; +afterEach(() => { + wrappers.splice(0).forEach((w) => w.unmount()); + document.body.innerHTML = ""; +}); +it("keeps asChild self-labelledby attached to the actual root ID", async () => { + const id = ref("child-id"); + const w = mount( + defineComponent({ + setup: () => () => + h("div", [ + h("span", { id: "caption" }, "Brand"), + h( + ColorSwatch, + { asChild: true, color: "#0485F7", "aria-labelledby": "caption" }, + { + default: () => h("div", { id: id.value }), + }, + ), + ]), + }), + { attachTo: document.body }, + ); + wrappers.push(w); + const root = w.get("[data-slot=color-swatch]"); + expect(root.attributes("aria-labelledby")).toBe( + `${root.attributes("id")} caption`, + ); + id.value = "next-child-id"; + await nextTick(); + expect(root.attributes("aria-labelledby")).toBe( + `${root.attributes("id")} caption`, + ); +}); +it("retains ordinary template styles together with styleFn", () => { + const w = mount( + defineComponent({ + components: { ColorSwatch }, + template: ``, + }), + ); + wrappers.push(w); + const style = (w.element as HTMLElement).style; + expect(style.outline).toBe("2px solid red"); + expect(style.opacity).toBe("0.5"); +});