Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a4e9f4962 | |||
| 6119d73323 | |||
| 6ece365168 | |||
| c56580e9b4 | |||
| 40d1d926be | |||
| fc2b3879b8 | |||
| ac5b48eec4 | |||
| 602ae84264 | |||
| de8aebcd93 | |||
| f3a38e27e4 | |||
| e8989d136a | |||
| ae364578ce | |||
| 01882160e6 |
@@ -90,6 +90,11 @@ export const componentItems: DocsItem[] = [
|
||||
url: "/components/close-button",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "ColorArea 颜色区域",
|
||||
url: "/components/color-area",
|
||||
category: "colors",
|
||||
},
|
||||
{
|
||||
title: "ColorSwatch 颜色色块",
|
||||
url: "/components/color-swatch",
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
---
|
||||
title: ColorArea 颜色区域
|
||||
description: 二维颜色选择器,允许用户从渐变区域中选择颜色
|
||||
component: color-area
|
||||
group: 组件
|
||||
---
|
||||
|
||||
## 用法
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { ColorArea, ColorAreaThumb } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ColorArea>
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
</template>
|
||||
```
|
||||
|
||||
<ComponentPreview name="color-area-basic" />
|
||||
|
||||
## 组件结构
|
||||
|
||||
Vue 版使用具名部件:`ColorArea` 负责共享颜色状态、渐变背景与指针/键盘事务,`ColorAreaThumb` 负责滑块定位和两个原生轴。`ColorAreaRoot` 是 `ColorArea` 的别名。
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { ColorArea, ColorAreaThumb } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ColorArea>
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
</template>
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 带定位点
|
||||
|
||||
<ComponentPreview name="color-area-with-dots" />
|
||||
|
||||
### 色彩空间与通道
|
||||
|
||||
使用 `colorSpace` 设置颜色空间(RGB、HSL、HSB),使用 `xChannel`/`yChannel` 自定义各轴显示的颜色通道。示例继续使用上游的英文控件标签、通道名称与示例顺序。
|
||||
|
||||
<ComponentPreview name="color-area-space-and-channels" />
|
||||
|
||||
### 禁用
|
||||
|
||||
<ComponentPreview name="color-area-disabled" />
|
||||
|
||||
### 受控组件
|
||||
|
||||
使用 `v-model` 绑定本库 `Color` 或颜色字符串;色块与二维区域共享同一个接受值。
|
||||
|
||||
<ComponentPreview name="color-area-controlled" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
上游 `render` 用于替换根元素和滑块元素:Vue 版在根元素上使用 `as` 更换标签,或用 `asChild` 把区域属性和事件合并到默认插槽中唯一的自定义根元素;滑块使用 `as` 更换标签。`data-*`、`aria-*`、事件、`class` 与 `style` 直接透传。
|
||||
|
||||
<ComponentPreview name="color-area-render-function" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="color-area-custom-styles" />
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
可使用 `@layer components` 指令自定义 ColorArea 组件类。
|
||||
[了解更多](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes)。
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-color-area {
|
||||
@apply rounded-3xl;
|
||||
}
|
||||
|
||||
.hv-color-area__thumb {
|
||||
@apply size-5 border-4;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 `hv-`。
|
||||
|
||||
### CSS 类
|
||||
|
||||
ColorArea 组件使用以下 CSS 类([查看源码样式](https://github.com/heroui-inc/heroui/blob/v3/packages/styles/components/color-area.css)):
|
||||
|
||||
#### 基础类 [!toc]
|
||||
|
||||
- `.hv-color-area` - 渐变背景与内阴影的基础样式
|
||||
- `.hv-color-area--show-dots` - 添加点阵网格覆盖层以精确选色
|
||||
|
||||
#### 元素类 [!toc]
|
||||
|
||||
- `.hv-color-area__thumb` - 可拖拽的滑块指示器
|
||||
|
||||
组件通过行内自定义属性提供当前绘制值:`--color-area-background` 保存基础色与全部梯度图层,`--color-area-thumb-color` 保存滑块颜色。传入的 `style` 与 `styleFn` 在基础样式之后合并,可覆盖冲突属性。
|
||||
|
||||
### 交互状态
|
||||
|
||||
组件同时支持 CSS 伪类与 data 属性:
|
||||
|
||||
- **Disabled**:`[data-disabled="true"]`
|
||||
- **Focus**:`[data-focus-visible="true"]`
|
||||
- **Dragging**:`[data-dragging="true"]`(仅 thumb)
|
||||
- **ReadOnly**:`[data-readonly="true"]`(本库扩展,不改变基线 CSS)
|
||||
|
||||
## API 参考
|
||||
|
||||
### ColorArea
|
||||
|
||||
| Prop / 事件 | 类型 | 默认值 | 描述 |
|
||||
| ------------------------- | --------------------------------------------- | -------------------------------- | ---------------------------------------------------------------------- |
|
||||
| `v-model` (`modelValue`) | `string \| Color \| null` | - | 当前颜色(受控);更新时触发 `update:modelValue` |
|
||||
| `value` | `string \| Color \| null` | - | `modelValue` 的低优先级别名;与共享颜色模型一致 |
|
||||
| `defaultValue` | `string \| Color \| null` | `#ffffff` | 非受控初始值 |
|
||||
| `colorSpace` | `"rgb" \| "hsl" \| "hsb"` | 接受值自身的颜色空间 | 通道使用的颜色空间 |
|
||||
| `xChannel` | `ColorAxisChannel` | 空间内第一个非 `yChannel` 的通道 | 水平轴颜色通道;RGB 默认 `red`,HSL/HSB 默认 `hue` |
|
||||
| `yChannel` | `ColorAxisChannel` | 空间内第一个非 `xChannel` 的通道 | 垂直轴颜色通道;RGB 默认 `green`,HSL/HSB 默认 `saturation` |
|
||||
| `xName` / `yName` | `string` | - | 两个轴的原生表单名称;分别提交通道数值 |
|
||||
| `form` | `string` | - | 关联的外部 `form` id |
|
||||
| `isDisabled` / `disabled` | `boolean` | `false` | 是否禁用;`disabled` 为别名 |
|
||||
| `isReadOnly` | `boolean` | `false` | 本库扩展:阻止编辑但保留焦点和 Tab 顺序 |
|
||||
| `showDots` | `boolean` | `false` | 是否显示点阵网格覆盖层 |
|
||||
| `locale` | `string` | `ConfigProvider` / `en-US` | 轴的可访问名称与数值格式 |
|
||||
| `dir` | `"ltr" \| "rtl"` | `ConfigProvider` / `ltr` | 布局方向;影响坐标映射与背景方向 |
|
||||
| `aria-label` | `string` | 本地化“颜色区域” | 组的可访问名称;提供 `aria-labelledby` 时不生成默认名称 |
|
||||
| `as` | `string` | `"div"` | 自定义根元素标签;对应上游 `render` 的元素替换 |
|
||||
| `asChild` | `boolean` | `false` | 将区域属性、样式和事件合并到默认插槽中唯一的自定义根元素 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
| `style` | `StyleValue \| ((renderProps) => StyleValue)` | - | 行内样式或上游 style render prop;在组件基础样式之后合并 |
|
||||
| `styleFn` | `(renderProps) => StyleValue` | - | 模板中的 style 函数别名;在基础样式和 `style` 之后合并 |
|
||||
| `@update:modelValue` | `(color: Color \| null) => void` | - | 提出颜色更新;供 `v-model` 使用 |
|
||||
| `@change` | `(color: Color \| null) => void` | - | 提出不同于当前接受值的颜色时触发;受控父级可拒绝 |
|
||||
| `@changeEnd` | `(color: Color \| null) => void` | - | 手势、键盘交互或失焦结束时触发一次;取消、卸载或外部替换不伪造完成事件 |
|
||||
| 默认插槽 | `ColorAreaThumb` | - | 区域内的滑块;省略时没有可交互的原生轴 |
|
||||
|
||||
`changeEnd` 只在本次事务确有颜色更新提案时触发(不要求受控父级接受),回调参数是最后一次提案。受控父级拒绝提案时,滑块、两个轴、背景和原生值都保持接受值,同一手势可以再次提案;取消指针、`lostpointercapture`、窗口失焦、禁用/只读切换、卸载和外部颜色替换只终止本控件事务,不取消兄弟控件的拖动。
|
||||
|
||||
省略全部 `modelValue`/`value`/`defaultValue` 时会继承最近的共享颜色 owner(当前私有组合与后续公开颜色组件使用同一协议);显式值覆盖继承,显式 `null` 清空接受值并用默认色绘制区域。空字符串和无效颜色不是“清空”:它们按 `parseColor` 边界抛出 `RangeError`。
|
||||
|
||||
`colorSpace`、`xChannel`、`yChannel` 必须形成一个合法的有序轴组合;同一通道、通道不属于所选空间或 `alpha` 轴会抛出 `RangeError`。可用的 18 个有序轴组合(三种空间 × 六个方向)共用与指针相同的通道映射,并保留 alpha 与灰色色相。
|
||||
|
||||
固定源 1.21.1 的 `useColorAreaState` 实际以 `#ffffff` 为默认值,并按 `getColorSpaceAxes` 的通道顺序推断未指定的轴;上游中文 API 简表标注的 `saturation`/`brightness` 与该运行时默认不一致。本库以固定源实际行为为准:RGB 默认 `red`/`green`,HSL/HSB 默认 `hue`/`saturation`;需要饱和度 × 明度或饱和度 × 亮度时显式传入 `xChannel`/`yChannel`(“色彩空间与通道”示例即如此)。
|
||||
|
||||
`isReadOnly` 与 `disabled` 别名是本库在固定源之外保留的现有扩展;没有新增 React Aria 的完整 props 集合。
|
||||
|
||||
### ColorAreaThumb
|
||||
|
||||
Vue 版写作 `ColorAreaThumb`(对应上游 `ColorArea.Thumb`)。
|
||||
|
||||
| Prop / 插槽 | 类型 | 默认值 | 描述 |
|
||||
| --------------- | --------------------------------------------- | ------- | -------------------------------------------------------- |
|
||||
| `as` | `string` | `"div"` | 自定义滑块标签;对应上游 `render` 的元素替换 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类(Vue class 绑定) |
|
||||
| `style` | `StyleValue \| ((renderProps) => StyleValue)` | - | 行内样式或上游 style render prop;在滑块基础样式之后合并 |
|
||||
| `styleFn` | `(renderProps) => StyleValue` | - | 模板中的 style 函数别名 |
|
||||
| `data-*` / ARIA | 原生属性 | - | 透传到滑块根元素 |
|
||||
|
||||
滑块内包含两个真正提交的原生 `range` 输入:两个轴都有本地化可访问名称、数值范围和格式化值,但只有一个进入 Tab 顺序;方向键按轴移动焦点。组件不使用一个虚构的二维 `aria-valuenow` 代替这两个轴。
|
||||
|
||||
`ColorAreaRenderProps` 包含 `{ color, space, x, y }`;`ColorAreaThumbRenderProps` 额外包含 `{ percent, isDragging, isDisabled, isReadOnly }`。根实例通过 `defineExpose` 公开 `element`(实际根 DOM)与 `color`(当前接受值)。
|
||||
|
||||
### 包根导出
|
||||
|
||||
`ColorArea`、`ColorAreaRoot`、`ColorAreaThumb`、`colorAreaVariants`、`ColorAreaVariants` 以及上述 Props/插槽/样式类型均从 `@heroui-vue/components` 导出。`ColorArea` 与 `ColorAreaRoot` 是同一个组件。
|
||||
|
||||
## 相关组件
|
||||
|
||||
本批次公开 ColorArea 与 ColorSwatch。ColorField、ColorInputGroup、ColorPicker、ColorSlider 与 ColorSwatchPicker 仍为私有颜色协议,尚未提供公共页面。
|
||||
@@ -152,4 +152,4 @@ ColorSwatch 组件使用以下 CSS 类([查看源码样式](https://github.com
|
||||
|
||||
## 相关组件
|
||||
|
||||
本批次仅公开 ColorSwatch。ColorArea、ColorField、ColorPicker、ColorSlider 与 ColorSwatchPicker 仍为私有颜色协议,尚未提供公共页面。
|
||||
本批次公开 ColorArea 与 ColorSwatch。ColorField、ColorInputGroup、ColorPicker、ColorSlider 与 ColorSwatchPicker 仍为私有颜色协议,尚未提供公共页面。
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ColorArea, ColorAreaThumb } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-56 max-w-full items-center justify-center">
|
||||
<ColorArea default-value="rgb(116, 52, 255)">
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import { shallowRef } from "vue";
|
||||
import {
|
||||
ColorArea,
|
||||
ColorAreaThumb,
|
||||
ColorSwatch,
|
||||
parseColor,
|
||||
type Color,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const color = shallowRef<Color | null>(parseColor("#9B80FF"));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<ColorArea
|
||||
v-model="color"
|
||||
color-space="rgb"
|
||||
x-channel="red"
|
||||
y-channel="green"
|
||||
>
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
<div class="flex w-[300px] items-center gap-3">
|
||||
<ColorSwatch :color="color" size="md" />
|
||||
<p class="text-sm text-muted">
|
||||
Current color:
|
||||
<span class="font-medium">
|
||||
{{ color ? color.toString("hex") : "(empty)" }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ColorArea, ColorAreaThumb } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ColorArea class="size-44 rounded-3xl" default-value="rgb(116, 52, 255)">
|
||||
<ColorAreaThumb class="size-5 rounded-full border-4 border-white" />
|
||||
</ColorArea>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ColorArea, ColorAreaThumb } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-56 max-w-full items-center justify-center">
|
||||
<ColorArea is-disabled default-value="hsl(200, 100%, 50%)">
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ColorArea, ColorAreaThumb } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-56 max-w-full items-center justify-center">
|
||||
<ColorArea as-child default-value="rgb(116, 52, 255)">
|
||||
<div data-custom="slider">
|
||||
<ColorAreaThumb as="span" data-custom="thumb" />
|
||||
</div>
|
||||
</ColorArea>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,187 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, shallowRef } from "vue";
|
||||
import {
|
||||
ColorArea,
|
||||
ColorAreaThumb,
|
||||
Label,
|
||||
ListBox,
|
||||
ListBoxItem,
|
||||
ListBoxItemIndicator,
|
||||
Select,
|
||||
SelectIndicator,
|
||||
SelectPopover,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
parseColor,
|
||||
type Color,
|
||||
type ColorAxisChannel,
|
||||
type ColorSpace,
|
||||
type SelectModelValue,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
interface ChannelOption {
|
||||
id: ColorAxisChannel;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const colorSpaces: Array<{ id: ColorSpace; name: string }> = [
|
||||
{ id: "rgb", name: "RGB" },
|
||||
{ id: "hsl", name: "HSL" },
|
||||
{ id: "hsb", name: "HSB" },
|
||||
];
|
||||
|
||||
const channelsBySpace: Record<ColorSpace, ChannelOption[]> = {
|
||||
hsb: [
|
||||
{ id: "hue", name: "Hue" },
|
||||
{ id: "saturation", name: "Saturation" },
|
||||
{ id: "brightness", name: "Brightness" },
|
||||
],
|
||||
hsl: [
|
||||
{ id: "hue", name: "Hue" },
|
||||
{ id: "saturation", name: "Saturation" },
|
||||
{ id: "lightness", name: "Lightness" },
|
||||
],
|
||||
rgb: [
|
||||
{ id: "red", name: "Red" },
|
||||
{ id: "green", name: "Green" },
|
||||
{ id: "blue", name: "Blue" },
|
||||
],
|
||||
};
|
||||
|
||||
const color = shallowRef<Color | null>(parseColor("hsb(219, 58%, 93%)"));
|
||||
const colorSpace = ref<ColorSpace>("hsb");
|
||||
const xChannel = ref<ColorAxisChannel>("saturation");
|
||||
const yChannel = ref<ColorAxisChannel>("brightness");
|
||||
|
||||
const channels = computed(() => channelsBySpace[colorSpace.value]);
|
||||
const xChannelOptions = computed(() =>
|
||||
channels.value.filter((channel) => channel.id !== yChannel.value),
|
||||
);
|
||||
const yChannelOptions = computed(() =>
|
||||
channels.value.filter((channel) => channel.id !== xChannel.value),
|
||||
);
|
||||
|
||||
function handleColorSpaceChange(value: SelectModelValue) {
|
||||
if (typeof value !== "string") return;
|
||||
const space = value as ColorSpace;
|
||||
colorSpace.value = space;
|
||||
if (space === "rgb") {
|
||||
xChannel.value = "blue";
|
||||
yChannel.value = "green";
|
||||
} else if (space === "hsl") {
|
||||
xChannel.value = "saturation";
|
||||
yChannel.value = "lightness";
|
||||
} else {
|
||||
xChannel.value = "saturation";
|
||||
yChannel.value = "brightness";
|
||||
}
|
||||
}
|
||||
|
||||
function handleXChannel(value: SelectModelValue) {
|
||||
if (typeof value === "string") xChannel.value = value as ColorAxisChannel;
|
||||
}
|
||||
|
||||
function handleYChannel(value: SelectModelValue) {
|
||||
if (typeof value === "string") yChannel.value = value as ColorAxisChannel;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col items-center gap-6">
|
||||
<div class="flex gap-4">
|
||||
<Select
|
||||
class="w-32"
|
||||
:model-value="colorSpace"
|
||||
@update:model-value="handleColorSpaceChange"
|
||||
>
|
||||
<Label>Color Space</Label>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
<SelectIndicator />
|
||||
</SelectTrigger>
|
||||
<SelectPopover>
|
||||
<ListBox>
|
||||
<ListBoxItem
|
||||
v-for="space in colorSpaces"
|
||||
:key="space.id"
|
||||
:id="space.id"
|
||||
:text-value="space.name"
|
||||
>
|
||||
{{ space.name }}
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</SelectPopover>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
class="w-36"
|
||||
:model-value="xChannel"
|
||||
@update:model-value="handleXChannel"
|
||||
>
|
||||
<Label>X Axis</Label>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
<SelectIndicator />
|
||||
</SelectTrigger>
|
||||
<SelectPopover>
|
||||
<ListBox>
|
||||
<ListBoxItem
|
||||
v-for="channel in xChannelOptions"
|
||||
:key="channel.id"
|
||||
:id="channel.id"
|
||||
:text-value="channel.name"
|
||||
>
|
||||
{{ channel.name }}
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</SelectPopover>
|
||||
</Select>
|
||||
|
||||
<Select
|
||||
class="w-36"
|
||||
:model-value="yChannel"
|
||||
@update:model-value="handleYChannel"
|
||||
>
|
||||
<Label>Y Axis</Label>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
<SelectIndicator />
|
||||
</SelectTrigger>
|
||||
<SelectPopover>
|
||||
<ListBox>
|
||||
<ListBoxItem
|
||||
v-for="channel in yChannelOptions"
|
||||
:key="channel.id"
|
||||
:id="channel.id"
|
||||
:text-value="channel.name"
|
||||
>
|
||||
{{ channel.name }}
|
||||
<ListBoxItemIndicator />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</SelectPopover>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<ColorArea
|
||||
v-model="color"
|
||||
:color-space="colorSpace"
|
||||
:x-channel="xChannel"
|
||||
:y-channel="yChannel"
|
||||
>
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
|
||||
<div class="flex items-center gap-3">
|
||||
<div
|
||||
class="size-8 rounded-md border border-default"
|
||||
:style="{ backgroundColor: color?.toString('css') }"
|
||||
/>
|
||||
<code class="rounded bg-default/50 px-2 py-1 text-sm">
|
||||
{{ color?.toString(colorSpace) ?? "(empty)" }}
|
||||
</code>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ColorArea, ColorAreaThumb } from "@heroui-vue/components";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-56 max-w-full items-center justify-center">
|
||||
<ColorArea show-dots default-value="hsl(200, 100%, 50%)">
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
</div>
|
||||
</template>
|
||||
+92
-86
@@ -4,91 +4,91 @@
|
||||
|
||||
固定上游公共组件清单;状态、差异和验证范围逐组件记录,不以单项测试通过声明整库完整兼容。
|
||||
|
||||
| 组件 | 状态 | 当前能力 / 差异 |
|
||||
| -------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| accordion | 验证中(M23) | Accordion/Item/Heading/Trigger/Panel/Body/Indicator;10/10 基线例;surface/hideSeparator;复用组键协议 |
|
||||
| alert-dialog | 验证中(M33) | 11 部件;role=alertdialog;默认不误关;14/14 基线例;Reka Dialog 底座 |
|
||||
| autocomplete | 已迁移(有已知差异) | Autocomplete 七部件;24/24 基线例;触发器单一 Tab 入口 + 弹层内搜索框虚拟焦点、受控开关/文本、多选 Value 用作用域插槽;见 B02 报告 |
|
||||
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
|
||||
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
|
||||
| badge | 验证中(最小实现) | Badge/BadgeAnchor/BadgeLabel;四角定位、圆点、文本/数字自动包装;Anchor 非链接 |
|
||||
| breadcrumbs | 验证中(M17) | Breadcrumbs/BreadcrumbsItem;7/7 基线例;ol+aria-label、末项 current、禁用/无 href span、separator 插槽;onAction 未提供,class 同时落 li/link |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
| button-group | 验证中(M26) | ButtonGroup/ButtonGroupSeparator;9/9 基线例;直接子 Button 继承 size/variant/isDisabled/fullWidth;嵌套不继承;圆角与 outline 边框处理 |
|
||||
| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
|
||||
| checkbox | 验证中(基线实现) | 原生 label/input;checked/isSelected、半选、primary/secondary、Content/Control/Indicator;15 个基线预览 |
|
||||
| checkbox-group | 验证中(基线实现) | 数组模型、同名重复提交、required/readonly/disabled/reset、组标签与成员描述隔离;10 个基线预览 |
|
||||
| chip | 验证中(最小实现) | color/size/variant;纯文本/数字自动包装为 ChipLabel;显式部件不重复包装;组合内容可动态切换 |
|
||||
| color-area | 私有基建已验证(COLOR-01) | 接受值、二维键盘、18 轴组合、指针捕获与两个原生轴/reset 已验证;未公开部件或 7 个正式预览 |
|
||||
| color-field | 私有组合协议已验证 | Root/Input及InputGroup前后缀、校验/关联、locale/草稿/IME/reset已验证;未公开包根、variants或正式13例,见COLOR-06。 |
|
||||
| color-picker | 私有组合协议已验证 | Picker/Trigger/Popover共享owner、字段/轨道联动与单一提交/reset已验证;未公开包根、variants或正式6例,见COLOR-08。 |
|
||||
| color-slider | 私有轨道已验证 | 自定义轨道、指针捕获/取消、键盘/方向/渐变及共享owner已验证;未公开Slider家族及正式文档,见COLOR-04。 |
|
||||
| color-swatch | 已迁移(客户端) | ColorSwatch/ColorSwatchRoot、circle/square、xs–xl、透明棋盘;7/7 基线例;省略 color 继承最近共享 owner,显式值覆盖;公开 Color/parseColor 子集;render 映射 as/asChild,style 函数映射 styleFn;见 COLOR-SWATCH 结果 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 验证中(最小实现) | 专用 CSS/变体、默认基线 CloseIcon、插槽替换图标、isDisabled、aria-label 默认 Close;onPress 由 click 适配 |
|
||||
| combo-box | 已迁移(有已知差异) | ComboBox 五部件;24/24 基线例;可编辑输入 + 过滤 + 虚拟焦点、form-value key/text、menu-trigger 三态、多选 Value;见 B02 报告 |
|
||||
| date-field | 已迁移(有已知差异) | DateField 七部件与 DateInputGroup 六部件、17 预览;完整 ISO、字段校验、reset、SSR/水合与浏览器重点检查,见 DATE-02 报告;本地化整日期粘贴、13 月/era 编辑等仍待专项。 |
|
||||
| date-picker | 已迁移(客户端,有已知差异) | DatePicker/Root、Trigger、TriggerIndicator、Popover;10/10 基线例;复用 DateField 字段、Calendar 视图/年份层与 Popover;唯一日期提交、受控拒绝/重试、时间草稿、locale/RTL、嵌套 Modal Escape;见 DATE-PICKER 结果。 |
|
||||
| date-range-picker | 已迁移(客户端,有已知差异) | DateRangePicker 五部件;10/10 基线例;复用双端点 DateField、RangeCalendar 与 Popover;完整范围/双命名提交/时间草稿/非连续策略;见 DATE-RANGE-PICKER 结果。 |
|
||||
| drawer | 验证中(M34) | 11 部件;四方向拖动关闭(30%/0.5px/ms);9/9 基线例;Content/Dialog 职责分离 |
|
||||
| progress-bar | 验证中(M18) | ProgressBar/Output/Track/Fill;7/7 基线例;确定/未知进度、min/max/formatOptions/valueLabel;custom-value 的 NumberField/Select 为原生临时控件 |
|
||||
| progress-circle | 验证中(M19) | ProgressCircle/Track/TrackCircle/FillCircle;7/7 基线例;圆环几何可覆盖;与 ProgressBar 共用取值语义 |
|
||||
| time-field | 已迁移(客户端) | TimeField/Root及六个共享输入部件;15/15基线例;Time/CalendarDateTime/ZonedDateTime、完整精度、受控拒绝、键盘/Enter、校验/提交/reset;框架差异见 TIME-FIELD 结果。 |
|
||||
| disclosure | 验证中(M21) | Disclosure/Heading/Trigger/Content/Body/Indicator;3/3 基线例;v-model:expanded;asChild 触发;高度动画映射测量变量 |
|
||||
| disclosure-group | 验证中(M22) | DisclosureGroup + useDisclosureGroupNavigation;3/3 基线例;展开键为数组(string 或 number);单选替换/多选增量 |
|
||||
| error-message | 已迁移(有已知差异) | ErrorMessage 单部件;2/2 基线例;复用字段错误 id 与样式变量,`slot="errorMessage"` 仅为 DOM 标记,不做校验也不改 aria-invalid;见 B03 报告 |
|
||||
| kbd | 验证中(最小实现) | variant;KbdAbbr keyValue 映射与 title;KbdContent;上下文类名;导出 kbdKeysMap/LabelMap |
|
||||
| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
|
||||
| popover | 验证中(OVERLAY-02) | Root/Trigger/Content/Dialog/Heading/Arrow;6/6 基线例;逻辑定位/碰撞/退出/标题;模态 closeAutoFocus 不支持取消恢复,见 OVERLAY-02 |
|
||||
| scroll-shadow | 验证中(M24) | 7/7 基线例;fade/方向/尺寸/偏移/受控可见性;VueUse 测量与公开 useScrollShadow,RTL/动态内容;CSS scroll timeline 保留 |
|
||||
| separator | 验证中(最小实现) | orientation/variant/decorative;默认 hr + role=separator;asChild 自定义根;Reka Separator |
|
||||
| skeleton | 验证中(最小实现) | shimmer/pulse/none、--skeleton-animation 全局默认、父级单次 shimmer;挂载后改 CSS 变量不自动更新 |
|
||||
| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
|
||||
| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
|
||||
| toast | 验证中(M35 + 保真返修) | Provider/Toast/Content/Indicator/Title/Description/Action/Close + 队列;11/11 例;role=alertdialog + 标题/描述关联 + content role=alert;indicator data-swapped;自有计时(无双倒计时);getQueue 不提供,见文档差异 |
|
||||
| toggle-button | 验证中(M27) | ToggleButton;7/7 基线例;v-model/isSelected/defaultSelected;data-selected/pressed/hover/focus;Enter/Space;组内 radio 语义 |
|
||||
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
|
||||
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
|
||||
| tabs | 验证中(M25) | 七部件、10/10 基线例;primary/secondary、方向/对齐、受控/键盘/禁用/滚动/指示器;Vue 模型与 ID/集合差异见报告 |
|
||||
| tag | 已迁移(有已知差异) | Tag/TagRemoveButton;与 TagGroup 同页 12 例;textValue 决定文字与移除按钮名称 `Remove tag {文本}`;移除由行统一处理;见 B03 报告 |
|
||||
| tag-group | 已迁移(有已知差异) | TagGroup/TagGroupList 两部件;role=grid/row、single/multiple、disabledKeys、移除与焦点恢复、aria-labelledby/describedby;12/12 基线例;见 B03 报告 |
|
||||
| toggle-button-group | 验证中(M28) | ToggleButtonGroup/Separator;10/10 基线例;single/multiple、disallowEmptySelection、roving focus;Vue 数组模型替代 Set<Key> |
|
||||
| toolbar | 验证中(M29) | Toolbar;5/5 基线例;isAttached/orientation/dir;跨组单 Tab 入口与方向键;子组焦点让位;Separator 垂直继承 |
|
||||
| tooltip | 验证中(OVERLAY-02) | Root/Trigger/Content/Arrow;6/6 基线例;CSS 延迟/焦点/禁用/替换/定位;Provider warmup 与 RAC 全局调度不同 |
|
||||
| input | 验证中(字段接入) | 接入 TextField;复用值恢复/reset/ARIA;独立使用保持兼容;完整消费验收未完成 |
|
||||
| input-group | 验证中(字段接入) | Root/Input/TextArea/Prefix/Suffix;复用 useTextControl;变体继承 TextField 可覆盖;前后缀非表单字段 |
|
||||
| textarea | 验证中(字段接入) | rows 默认 3;变体/fullWidth/受控/FormData/reset;独立页 7/7 示例;接入 useTextControl |
|
||||
| textfield | 验证中(字段接入) | 值/状态/约束/校验/ID;独立页 13/13 示例;render 自定义根类型未支持(data-* 透传) |
|
||||
| search-field | 验证中(FORM-02) | 五部件、15 基线例;共享文本内核、clear/submit/IME/reset/SSR,边界见 FORM-02 |
|
||||
| typography | 验证中(M15) | Typography/Heading/Paragraph/Code/Prose 具名导出;6/6 基线例;type/as/align/color/weight/truncate;render 映射为 as |
|
||||
| label | 验证中(通用字段) | 自动 for、Switch 内 span、状态继承;独立页 2/2 示例 |
|
||||
| description | 验证中(通用字段) | 动态 ID 清理、外部 describedby 合并;独立页 2/2 示例;SSR 包装限制见基础协议 |
|
||||
| empty-state | 验证中(M16) | 单根 EmptyState;4 个自编示例(基线无页面/示例);默认 fallback;空节点判断与上游 children 真值回退边界不同 |
|
||||
| field-error | 验证中(通用字段) | 作用域插槽 validationErrors;独立页 2/2 示例;无完整 validationDetails(见基础协议) |
|
||||
| fieldset | 验证中(FORM-02) | 四部件、3 基线例与禁用验证例;响应式禁用、首 Legend 例外,边界见 FORM-02 |
|
||||
| form | 验证中(基础设施) | native/aria 校验、FormData/reset、服务端错误;完整基线文档与生态集成未完成 |
|
||||
| header | 验证中(M31) | Header/HeaderRoot;原生 `<header>` 集合分组标题;基线无独立文档/演示,自编 3 例并标注;无 v-model |
|
||||
| radio | 验证中(基线实现) | 原生 radio + Content/Control/Indicator;须在 RadioGroup 内,成员禁用/只读、作用域状态 |
|
||||
| radio-group | 验证中(基线实现) | 标量模型、roving Tab/方向键/dir/loop、原生提交/校验/reset;12 个基线预览 |
|
||||
| input-otp | 验证中(M32) | Root/Group/Slot/Separator + 3 正则常量;Reka PinInput 底座;字符串+索引数组;reset/Fieldset/Form/ARIA/mask 已接入;11/11 例;自动填充/IME/读屏未真机验证 |
|
||||
| alert | 验证中(最小实现) | status 五态;默认图标随 status;自定义 Indicator 空内容回退;内部 Surface 重置为 default |
|
||||
| list-box | 验证中(LISTBOX-01) | 四部件、9/9 基线例;typed key/数组模型、none/single/multiple、键盘/范围/全选、1000 项固定行高虚拟化;差异见 LISTBOX-01 |
|
||||
| list-box-item | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| list-box-section | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| dropdown | 验证中(B01) | Root/Trigger/Popover/Menu/Section/Item/ItemIndicator/SubmenuIndicator/SubmenuTrigger;17/17 基线例;Reka DropdownMenu;数组选择模型 |
|
||||
| menu | 验证中(B01) | MenuRoot/Menu 列表与选择/动作上下文;无独立官方文档页,契约折叠于 Dropdown;见 B01 |
|
||||
| menu-item | 验证中(B01) | MenuItem/Indicator/SubmenuIndicator;variant default/danger、checkmark/dot;见 B01 |
|
||||
| menu-section | 验证中(B01) | MenuSection 分组与分组级选择;见 B01 |
|
||||
| modal | 验证中(OVERLAY-02) | Root/Trigger/Backdrop/Container/Dialog/Heading/Header/Body/Footer/Icon/Close/CloseTrigger;14/14 基线例;焦点/锁/滚动/退出动画;Vue close 部件替代 React slot |
|
||||
| pagination | 验证中(M30) | 组合式 nav 容器(无 total/page 状态机);11 具名部件;9/9 基线例;onPress→@click;显式 aria-current 可覆盖 |
|
||||
| number-field | 验证中(NUMBER-01) | 五部件与 17/17 基线例;Reka 数值内核;受控/只读/表单 reset、SSR/水合;差异见 NUMBER-01 报告 |
|
||||
| select | 验证中(SELECT-01) | 六部件、19/19 例、单/多选、清空、字段/原生提交/SSR/异步;复用 ListBox + Popover,重点浏览器已验,限制见 SELECT-01 |
|
||||
| meter | 验证中(M20) | Meter/Output/Track/Fill;6/6 基线例;role=meter progressbar;无 isIndeterminate;测量语义独立于 Progress |
|
||||
| slider | 验证中(SLIDER-01) | 六部件、9/9 基线例;原生 range/局部指针适配,单值/范围、受控/reset/SSR/水合;差异见 SLIDER-01 |
|
||||
| table | 验证中(M36 + 保真返修) | 15 部件;选择/排序/原生语义;13 演示;TableBody `#empty` 空状态;全选半选;defaultWidth 的 1fr 按原生 auto 弹性适配,不承诺 fr 比例;虚拟化固定 42px 窗口、TanStack 分页行模型;RAC TableLayout 不导出,见 M36 |
|
||||
| calendar | 已迁移(有已知差异) | 月/周/日、多选、焦点/翻页、国际历法、年份层与 19 预览;局部日期视图/键盘适配,默认历法边界等差异见 DATE-03。 |
|
||||
| range-calendar | 已迁移(客户端,有已知差异) | RangeCalendar/Root、九个具名日历部件、共享六个 CalendarYearPicker 部件;20/20 基线例;点击/键盘/鼠标拖选、受控拒绝、跨月/RTL;触屏长按拖选未实现,见 RANGE-CALENDAR 结果。 |
|
||||
| calendar-year-picker | 已迁移(DATE-03) | 六个独立具名部件、三列年份、窗口/格式/era、覆盖测量、焦点与关闭;不导出 React 上下文。 |
|
||||
| 组件 | 状态 | 当前能力 / 差异 |
|
||||
| -------------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| accordion | 验证中(M23) | Accordion/Item/Heading/Trigger/Panel/Body/Indicator;10/10 基线例;surface/hideSeparator;复用组键协议 |
|
||||
| alert-dialog | 验证中(M33) | 11 部件;role=alertdialog;默认不误关;14/14 基线例;Reka Dialog 底座 |
|
||||
| autocomplete | 已迁移(有已知差异) | Autocomplete 七部件;24/24 基线例;触发器单一 Tab 入口 + 弹层内搜索框虚拟焦点、受控开关/文本、多选 Value 用作用域插槽;见 B02 报告 |
|
||||
| avatar | 验证中(最小实现) | Reka Avatar 加载/回退;size/color/variant;Image asChild;AvatarGroup 继承仅限直接子级 |
|
||||
| avatar-group | 验证中(最小实现) | max 截断与自动计数、显式 Count 不受截断、isGrid、overlap clip/ring;默认无 role=group |
|
||||
| badge | 验证中(最小实现) | Badge/BadgeAnchor/BadgeLabel;四角定位、圆点、文本/数字自动包装;Anchor 非链接 |
|
||||
| breadcrumbs | 验证中(M17) | Breadcrumbs/BreadcrumbsItem;7/7 基线例;ol+aria-label、末项 current、禁用/无 href span、separator 插槽;onAction 未提供,class 同时落 li/link |
|
||||
| button | 验证中(最小实现) | 基线全部 7 种变体、尺寸、isIconOnly/isDisabled/isPending;PressEvent 与 Vue click 差异见文档 |
|
||||
| button-group | 验证中(M26) | ButtonGroup/ButtonGroupSeparator;9/9 基线例;直接子 Button 继承 size/variant/isDisabled/fullWidth;嵌套不继承;圆角与 outline 边框处理 |
|
||||
| card | 验证中(最小实现) | 4 种表面变体;Header/Title/Description/Content/Footer 已实现;以基线 CSS 为准 |
|
||||
| checkbox | 验证中(基线实现) | 原生 label/input;checked/isSelected、半选、primary/secondary、Content/Control/Indicator;15 个基线预览 |
|
||||
| checkbox-group | 验证中(基线实现) | 数组模型、同名重复提交、required/readonly/disabled/reset、组标签与成员描述隔离;10 个基线预览 |
|
||||
| chip | 验证中(最小实现) | color/size/variant;纯文本/数字自动包装为 ChipLabel;显式部件不重复包装;组合内容可动态切换 |
|
||||
| color-area | 已迁移(客户端) | ColorArea/ColorAreaRoot、ColorAreaThumb;showDots、colorSpace/RGB/HSL/HSB 与 18 个有序轴组合、共享 owner、受控拒绝、原生两轴提交/reset、locale/RTL、readOnly;7/7 基线例;Root render 映射 as/asChild,Thumb 映射 as,style 函数映射 styleFn;见 COLOR-AREA 结果 |
|
||||
| color-field | 私有组合协议已验证 | Root/Input及InputGroup前后缀、校验/关联、locale/草稿/IME/reset已验证;未公开包根、variants或正式13例,见COLOR-06。 |
|
||||
| color-picker | 私有组合协议已验证 | Picker/Trigger/Popover共享owner、字段/轨道联动与单一提交/reset已验证;未公开包根、variants或正式6例,见COLOR-08。 |
|
||||
| color-slider | 私有轨道已验证 | 自定义轨道、指针捕获/取消、键盘/方向/渐变及共享owner已验证;未公开Slider家族及正式文档,见COLOR-04。 |
|
||||
| color-swatch | 已迁移(客户端) | ColorSwatch/ColorSwatchRoot、circle/square、xs–xl、透明棋盘;7/7 基线例;省略 color 继承最近共享 owner,显式值覆盖;公开 Color/parseColor 子集;render 映射 as/asChild,style 函数映射 styleFn;见 COLOR-SWATCH 结果 |
|
||||
| color-swatch-picker | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
|
||||
| close-button | 验证中(最小实现) | 专用 CSS/变体、默认基线 CloseIcon、插槽替换图标、isDisabled、aria-label 默认 Close;onPress 由 click 适配 |
|
||||
| combo-box | 已迁移(有已知差异) | ComboBox 五部件;24/24 基线例;可编辑输入 + 过滤 + 虚拟焦点、form-value key/text、menu-trigger 三态、多选 Value;见 B02 报告 |
|
||||
| date-field | 已迁移(有已知差异) | DateField 七部件与 DateInputGroup 六部件、17 预览;完整 ISO、字段校验、reset、SSR/水合与浏览器重点检查,见 DATE-02 报告;本地化整日期粘贴、13 月/era 编辑等仍待专项。 |
|
||||
| date-picker | 已迁移(客户端,有已知差异) | DatePicker/Root、Trigger、TriggerIndicator、Popover;10/10 基线例;复用 DateField 字段、Calendar 视图/年份层与 Popover;唯一日期提交、受控拒绝/重试、时间草稿、locale/RTL、嵌套 Modal Escape;见 DATE-PICKER 结果。 |
|
||||
| date-range-picker | 已迁移(客户端,有已知差异) | DateRangePicker 五部件;10/10 基线例;复用双端点 DateField、RangeCalendar 与 Popover;完整范围/双命名提交/时间草稿/非连续策略;见 DATE-RANGE-PICKER 结果。 |
|
||||
| drawer | 验证中(M34) | 11 部件;四方向拖动关闭(30%/0.5px/ms);9/9 基线例;Content/Dialog 职责分离 |
|
||||
| progress-bar | 验证中(M18) | ProgressBar/Output/Track/Fill;7/7 基线例;确定/未知进度、min/max/formatOptions/valueLabel;custom-value 的 NumberField/Select 为原生临时控件 |
|
||||
| progress-circle | 验证中(M19) | ProgressCircle/Track/TrackCircle/FillCircle;7/7 基线例;圆环几何可覆盖;与 ProgressBar 共用取值语义 |
|
||||
| time-field | 已迁移(客户端) | TimeField/Root及六个共享输入部件;15/15基线例;Time/CalendarDateTime/ZonedDateTime、完整精度、受控拒绝、键盘/Enter、校验/提交/reset;框架差异见 TIME-FIELD 结果。 |
|
||||
| disclosure | 验证中(M21) | Disclosure/Heading/Trigger/Content/Body/Indicator;3/3 基线例;v-model:expanded;asChild 触发;高度动画映射测量变量 |
|
||||
| disclosure-group | 验证中(M22) | DisclosureGroup + useDisclosureGroupNavigation;3/3 基线例;展开键为数组(string 或 number);单选替换/多选增量 |
|
||||
| error-message | 已迁移(有已知差异) | ErrorMessage 单部件;2/2 基线例;复用字段错误 id 与样式变量,`slot="errorMessage"` 仅为 DOM 标记,不做校验也不改 aria-invalid;见 B03 报告 |
|
||||
| kbd | 验证中(最小实现) | variant;KbdAbbr keyValue 映射与 title;KbdContent;上下文类名;导出 kbdKeysMap/LabelMap |
|
||||
| link | 验证中(最小实现) | 原生 a + LinkIcon;isDisabled/asChild/焦点与 data 状态;默认图标为基线 ExternalLinkIcon;onPress 由 click 适配 |
|
||||
| popover | 验证中(OVERLAY-02) | Root/Trigger/Content/Dialog/Heading/Arrow;6/6 基线例;逻辑定位/碰撞/退出/标题;模态 closeAutoFocus 不支持取消恢复,见 OVERLAY-02 |
|
||||
| scroll-shadow | 验证中(M24) | 7/7 基线例;fade/方向/尺寸/偏移/受控可见性;VueUse 测量与公开 useScrollShadow,RTL/动态内容;CSS scroll timeline 保留 |
|
||||
| separator | 验证中(最小实现) | orientation/variant/decorative;默认 hr + role=separator;asChild 自定义根;Reka Separator |
|
||||
| skeleton | 验证中(最小实现) | shimmer/pulse/none、--skeleton-animation 全局默认、父级单次 shimmer;挂载后改 CSS 变量不自动更新 |
|
||||
| spinner | 验证中(最小实现) | size/color 变体、role=status、内置渐变 SVG;嵌入 Button 保持 16px;reduced-motion 支持 |
|
||||
| surface | 验证中(最小实现) | 4 种变体、data-slot、surfaceContextKey 提供当前变体;Input 文档表面示例已替换为 Surface |
|
||||
| toast | 验证中(M35 + 保真返修) | Provider/Toast/Content/Indicator/Title/Description/Action/Close + 队列;11/11 例;role=alertdialog + 标题/描述关联 + content role=alert;indicator data-swapped;自有计时(无双倒计时);getQueue 不提供,见文档差异 |
|
||||
| toggle-button | 验证中(M27) | ToggleButton;7/7 基线例;v-model/isSelected/defaultSelected;data-selected/pressed/hover/focus;Enter/Space;组内 radio 语义 |
|
||||
| switch | 验证中(最小实现) | 根字段与组合部件、3 尺寸、ARIA 透传、原生/ARIA 校验、FormData/reset;PressEvent 不等价 |
|
||||
| switch-group | 验证中(布局) | vertical/horizontal;不共享选择值,已移植基线 CSS |
|
||||
| tabs | 验证中(M25) | 七部件、10/10 基线例;primary/secondary、方向/对齐、受控/键盘/禁用/滚动/指示器;Vue 模型与 ID/集合差异见报告 |
|
||||
| tag | 已迁移(有已知差异) | Tag/TagRemoveButton;与 TagGroup 同页 12 例;textValue 决定文字与移除按钮名称 `Remove tag {文本}`;移除由行统一处理;见 B03 报告 |
|
||||
| tag-group | 已迁移(有已知差异) | TagGroup/TagGroupList 两部件;role=grid/row、single/multiple、disabledKeys、移除与焦点恢复、aria-labelledby/describedby;12/12 基线例;见 B03 报告 |
|
||||
| toggle-button-group | 验证中(M28) | ToggleButtonGroup/Separator;10/10 基线例;single/multiple、disallowEmptySelection、roving focus;Vue 数组模型替代 Set<Key> |
|
||||
| toolbar | 验证中(M29) | Toolbar;5/5 基线例;isAttached/orientation/dir;跨组单 Tab 入口与方向键;子组焦点让位;Separator 垂直继承 |
|
||||
| tooltip | 验证中(OVERLAY-02) | Root/Trigger/Content/Arrow;6/6 基线例;CSS 延迟/焦点/禁用/替换/定位;Provider warmup 与 RAC 全局调度不同 |
|
||||
| input | 验证中(字段接入) | 接入 TextField;复用值恢复/reset/ARIA;独立使用保持兼容;完整消费验收未完成 |
|
||||
| input-group | 验证中(字段接入) | Root/Input/TextArea/Prefix/Suffix;复用 useTextControl;变体继承 TextField 可覆盖;前后缀非表单字段 |
|
||||
| textarea | 验证中(字段接入) | rows 默认 3;变体/fullWidth/受控/FormData/reset;独立页 7/7 示例;接入 useTextControl |
|
||||
| textfield | 验证中(字段接入) | 值/状态/约束/校验/ID;独立页 13/13 示例;render 自定义根类型未支持(data-* 透传) |
|
||||
| search-field | 验证中(FORM-02) | 五部件、15 基线例;共享文本内核、clear/submit/IME/reset/SSR,边界见 FORM-02 |
|
||||
| typography | 验证中(M15) | Typography/Heading/Paragraph/Code/Prose 具名导出;6/6 基线例;type/as/align/color/weight/truncate;render 映射为 as |
|
||||
| label | 验证中(通用字段) | 自动 for、Switch 内 span、状态继承;独立页 2/2 示例 |
|
||||
| description | 验证中(通用字段) | 动态 ID 清理、外部 describedby 合并;独立页 2/2 示例;SSR 包装限制见基础协议 |
|
||||
| empty-state | 验证中(M16) | 单根 EmptyState;4 个自编示例(基线无页面/示例);默认 fallback;空节点判断与上游 children 真值回退边界不同 |
|
||||
| field-error | 验证中(通用字段) | 作用域插槽 validationErrors;独立页 2/2 示例;无完整 validationDetails(见基础协议) |
|
||||
| fieldset | 验证中(FORM-02) | 四部件、3 基线例与禁用验证例;响应式禁用、首 Legend 例外,边界见 FORM-02 |
|
||||
| form | 验证中(基础设施) | native/aria 校验、FormData/reset、服务端错误;完整基线文档与生态集成未完成 |
|
||||
| header | 验证中(M31) | Header/HeaderRoot;原生 `<header>` 集合分组标题;基线无独立文档/演示,自编 3 例并标注;无 v-model |
|
||||
| radio | 验证中(基线实现) | 原生 radio + Content/Control/Indicator;须在 RadioGroup 内,成员禁用/只读、作用域状态 |
|
||||
| radio-group | 验证中(基线实现) | 标量模型、roving Tab/方向键/dir/loop、原生提交/校验/reset;12 个基线预览 |
|
||||
| input-otp | 验证中(M32) | Root/Group/Slot/Separator + 3 正则常量;Reka PinInput 底座;字符串+索引数组;reset/Fieldset/Form/ARIA/mask 已接入;11/11 例;自动填充/IME/读屏未真机验证 |
|
||||
| alert | 验证中(最小实现) | status 五态;默认图标随 status;自定义 Indicator 空内容回退;内部 Surface 重置为 default |
|
||||
| list-box | 验证中(LISTBOX-01) | 四部件、9/9 基线例;typed key/数组模型、none/single/multiple、键盘/范围/全选、1000 项固定行高虚拟化;差异见 LISTBOX-01 |
|
||||
| list-box-item | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| list-box-section | 验证中(LISTBOX-01) | ListBox 子部件;独立标签/描述作用域、自动分组名称、原生标签替换、状态/指示器;见 LISTBOX-01 |
|
||||
| dropdown | 验证中(B01) | Root/Trigger/Popover/Menu/Section/Item/ItemIndicator/SubmenuIndicator/SubmenuTrigger;17/17 基线例;Reka DropdownMenu;数组选择模型 |
|
||||
| menu | 验证中(B01) | MenuRoot/Menu 列表与选择/动作上下文;无独立官方文档页,契约折叠于 Dropdown;见 B01 |
|
||||
| menu-item | 验证中(B01) | MenuItem/Indicator/SubmenuIndicator;variant default/danger、checkmark/dot;见 B01 |
|
||||
| menu-section | 验证中(B01) | MenuSection 分组与分组级选择;见 B01 |
|
||||
| modal | 验证中(OVERLAY-02) | Root/Trigger/Backdrop/Container/Dialog/Heading/Header/Body/Footer/Icon/Close/CloseTrigger;14/14 基线例;焦点/锁/滚动/退出动画;Vue close 部件替代 React slot |
|
||||
| pagination | 验证中(M30) | 组合式 nav 容器(无 total/page 状态机);11 具名部件;9/9 基线例;onPress→@click;显式 aria-current 可覆盖 |
|
||||
| number-field | 验证中(NUMBER-01) | 五部件与 17/17 基线例;Reka 数值内核;受控/只读/表单 reset、SSR/水合;差异见 NUMBER-01 报告 |
|
||||
| select | 验证中(SELECT-01) | 六部件、19/19 例、单/多选、清空、字段/原生提交/SSR/异步;复用 ListBox + Popover,重点浏览器已验,限制见 SELECT-01 |
|
||||
| meter | 验证中(M20) | Meter/Output/Track/Fill;6/6 基线例;role=meter progressbar;无 isIndeterminate;测量语义独立于 Progress |
|
||||
| slider | 验证中(SLIDER-01) | 六部件、9/9 基线例;原生 range/局部指针适配,单值/范围、受控/reset/SSR/水合;差异见 SLIDER-01 |
|
||||
| table | 验证中(M36 + 保真返修) | 15 部件;选择/排序/原生语义;13 演示;TableBody `#empty` 空状态;全选半选;defaultWidth 的 1fr 按原生 auto 弹性适配,不承诺 fr 比例;虚拟化固定 42px 窗口、TanStack 分页行模型;RAC TableLayout 不导出,见 M36 |
|
||||
| calendar | 已迁移(有已知差异) | 月/周/日、多选、焦点/翻页、国际历法、年份层与 19 预览;局部日期视图/键盘适配,默认历法边界等差异见 DATE-03。 |
|
||||
| range-calendar | 已迁移(客户端,有已知差异) | RangeCalendar/Root、九个具名日历部件、共享六个 CalendarYearPicker 部件;20/20 基线例;点击/键盘/鼠标拖选、受控拒绝、跨月/RTL;触屏长按拖选未实现,见 RANGE-CALENDAR 结果。 |
|
||||
| calendar-year-picker | 已迁移(DATE-03) | 六个独立具名部件、三列年份、窗口/格式/era、覆盖测量、焦点与关闭;不导出 React 上下文。 |
|
||||
|
||||
## 公共导出差异
|
||||
|
||||
@@ -223,7 +223,7 @@ Toast 11/11 与 Table 13/13 预览、各部件 Props、文档和默认源样式
|
||||
|
||||
## COLOR-01 颜色基建
|
||||
|
||||
颜色值、接受值/继承 owner、二维交互与梯度已由私有夹具验证;不表示公开组件或 React Stately Color 全 API 完成。范围和限制见 [COLOR-01](component-notes.md),公共Swatch迁移见 [当前任务卡](tasks/COLOR-SWATCH.md);旧COLOR-02不再作为调度依据。
|
||||
颜色值、接受值/继承 owner、二维交互与梯度已由私有夹具验证;公共 ColorArea 迁移见 [COLOR-AREA 结果](tasks/results/COLOR-AREA.md),公共 Swatch 见 [COLOR-SWATCH](tasks/results/COLOR-SWATCH.md)。固定源 1.21.1 的实际默认值为 `#ffffff`,未指定轴按接受值空间首两个通道推断(RGB red/green,HSL/HSB hue/saturation);中文 API 简表的 saturation/brightness 与运行时不同,迁移按源码行为实现。旧COLOR-02不再作为调度依据。
|
||||
|
||||
## COLOR-03 颜色输入基建
|
||||
|
||||
@@ -241,6 +241,12 @@ ColorField/ColorInputGroup 内部 Root/Input/前后缀、校验/关联、独立
|
||||
|
||||
ColorPicker/Trigger/Popover 正式组合内部已接入,共享非空 owner、现有 Popover 和单一原生提交/reset。尚无包根导出、公共 variants/六例完成声明;默认值、明确 Vue 扩展和公开待办见 [COLOR-08](component-notes.md)。
|
||||
|
||||
## COLOR-AREA 公共颜色区域(2026-10-26)
|
||||
|
||||
公开 ColorArea/ColorAreaRoot、ColorAreaThumb、Props/RenderProps/插槽/样式类型与 colorAreaVariants;固定源中文 7 例、API/样式参考与导航已接入。复用共享 Color/model 接受值、二维指针/键盘事务、18 个有序轴组合和既有 hv-color-area CSS;Root 输出 data-slot/color-area 与可访问组名,Thumb 输出两个本地化命名原生轴和单 Tab 入口。
|
||||
|
||||
上游 render 映射为 `as`/`asChild` 与 attrs,style 函数在模板中使用 `styleFn`;`xName`/`yName`/`form` 只提交两个轴,继承 owner 时不重复完整颜色提交。固定源默认 `#ffffff`、按接受值空间推断轴;默认指针捕获与 mouse/touch 手势、受控拒绝/重试、动态 owner、表单/reset、浅深主题和最终 tarball 的验证边界见 [任务结果](tasks/results/COLOR-AREA.md)。
|
||||
|
||||
## B02 公开组合接手验收
|
||||
|
||||
ComboBox/Autocomplete的正式组合、原30项返修和本轮定位/ref/ARIA/locale修复已集成,独立浏览器消费已补验。精确范围与未验证项以 [B02-REVIEW结果](tasks/results/B02-REVIEW.md) 为准;历史“not actionable/未做浏览器产物”不再是当前结果。后续迁移从docs/tasks统一入口开始,不重复派发旧清单中的日期/颜色基建。
|
||||
|
||||
@@ -15,7 +15,13 @@
|
||||
|
||||
DateField/TimeField/Calendar/CalendarYearPicker已公开;RangeCalendar只有私有内核,DatePicker/DateRangePicker尚未迁移。保留DateValue、历法/时区与精度边界,不强制JS Date;本地化整日期粘贴、13月/era编辑等尚有待办。见 [日期决策](decisions/date-calendar-foundation.md)、[DateField文档](../apps/docs/components/date-field.md)、[Calendar文档](../apps/docs/components/calendar.md)。
|
||||
|
||||
颜色value/model与Area/Slider/Field/InputGroup/Picker私有协议已有实现,公共Color/parseColor及组件家族仍待任务验收。不能把内核/夹具通过写成公共完成。共享owner、归一化通道、接受值与草稿保持同一状态源。见 [颜色决策](decisions/color-foundation.md);下一项只有用户选定后才按 [COLOR-SWATCH卡](tasks/COLOR-SWATCH.md) 执行。
|
||||
颜色共享 value/model、二维 Area、Slider、Field/InputGroup、Picker 私有协议与既有夹具已验证;ColorSwatch 与 ColorArea 已作为公共组件迁移,ColorField/ColorSlider/ColorPicker/ColorSwatchPicker 仍未公开。不能把内核/夹具通过写成整族完成。共享 owner、归一化通道、接受值与草稿保持同一状态源。ColorArea 按固定源运行时默认 `#ffffff` 与空间首通道推断轴,见 [颜色决策](decisions/color-foundation.md) 与 [COLOR-AREA 结果](tasks/results/COLOR-AREA.md)。
|
||||
|
||||
## COLOR-AREA(2026-10-26)
|
||||
|
||||
ColorArea/ColorAreaRoot、ColorAreaThumb 与 colorAreaVariants 已公开,复用 hv-color-area CSS 和共享二维内核;固定源中文 7 例全部迁移。Root 负责接受值、背景、指针/键盘事务与组标签,Thumb 负责定位、两个本地化命名原生轴和单 Tab 入口;两个轴的 xName/yName/form 只提交通道值,owner 的完整颜色提交不重复。
|
||||
|
||||
上游 render 改 `as`/`asChild` 与 attrs;style 函数在模板中用 `styleFn`,Thumb 仅支持 `as`(无 asChild,避免把两个原生轴移出滑块)。`isReadOnly` 与 `disabled` 是保留的库扩展;`null` 清空接受值并按默认白绘制,空字符串按 parseColor 边界抛错。固定源 1.21.1 默认 `#ffffff`,默认轴取空间首两个通道(RGB red/green,HSL/HSB hue/saturation),与中文 API 简表标注的 saturation/brightness 不同;实现与文档以运行时行为为准。触屏拖出边界、lostcapture/pointercancel 清理真实浏览器已验证;CDP 合成鼠标不保持 pointer capture,鼠标捕获仅由单元夹具覆盖,未把它误记为浏览器通过。完整证据与限制见 [任务结果](tasks/results/COLOR-AREA.md)。
|
||||
|
||||
## 当前不投入
|
||||
|
||||
|
||||
+6
-6
@@ -2,27 +2,27 @@
|
||||
|
||||
> 当前仅支持浏览器客户端使用,暂不支持SSR、服务端水合或Nuxt服务端渲染。除用户明确重新启用外,不开发、不修复、不新增也不运行相关专项;历史通过记录不构成支持承诺。
|
||||
|
||||
更新:2026-10-26。只描述当前实现,不以历史测试总数声明完整兼容。
|
||||
更新:2026-10-27。只描述当前实现,不以历史测试总数声明完整兼容。
|
||||
|
||||
## 已有能力
|
||||
|
||||
- 展示、按钮、导航、展开、反馈等主要家族已有公共组件与文档。
|
||||
- 字段/Form、Checkbox/Radio、数值/Slider/OTP、弹层/菜单、集合/ListBox/Select、ComboBox/Autocomplete、Tag、Toast/Table已集成。
|
||||
- DateField、TimeField、Calendar、CalendarYearPicker、DatePicker 与 DateRangePicker 已有公共组件;RangeCalendar 已完成公共客户端迁移(20 个基线预览),范围选择与 Calendar 共用视图/焦点/年份设施。DatePicker 复用 DateField 字段、Calendar 视图与 Popover 弹层,10 个基线预览已接入。DateRangePicker 复用双端点 DateField、RangeCalendar 与 Popover,10 个基线预览已接入。
|
||||
- ColorSwatch/ColorSwatchRoot及Color/parseColor公共子集已公开;Area、Slider、Field/InputGroup、Picker组合协议仍有私有实现和回归夹具,尚未作为完整公共颜色家族发布。
|
||||
- 兼容矩阵目前84条(包含子部件与基础设施),文档有68个组件页面。矩阵中的“验证中”保留其原有限制,不升级为完整兼容。
|
||||
- ColorSwatch/ColorSwatchRoot及Color/parseColor公共子集已公开;ColorArea/ColorAreaRoot、ColorAreaThumb 与 colorAreaVariants 已公开,复用共享颜色 owner、二维交互与固定源 7 例。Area、Slider、Field/InputGroup、Picker组合协议仍有私有实现和回归夹具;ColorField/ColorSlider/ColorPicker/ColorSwatchPicker尚未作为完整公共颜色家族发布。
|
||||
- 兼容矩阵目前85条(包含子部件与基础设施),文档有69个组件页面。矩阵中的“验证中”保留其原有限制,不升级为完整兼容。
|
||||
|
||||
## 尚未完成的公共家族
|
||||
|
||||
ColorArea、ColorField、ColorSlider、ColorSwatchPicker、ColorPicker,共5项;已有私有内核不等于公共迁移完成。ColorInputGroup仍为私有协议;Color/parseColor公共边界已随COLOR-SWATCH验收。
|
||||
ColorField、ColorSlider、ColorSwatchPicker、ColorPicker,共4项;已有私有内核不等于公共迁移完成。ColorInputGroup仍为私有协议;Color/parseColor公共边界已随COLOR-SWATCH验收,ColorArea 已随 COLOR-AREA 验收。
|
||||
|
||||
TIME-FIELD 已完成公共迁移和客户端验收,见 [结果](tasks/results/TIME-FIELD.md);COLOR-SWATCH 见 [结果](tasks/results/COLOR-SWATCH.md)。RANGE-CALENDAR 结果见 [任务结果](tasks/results/RANGE-CALENDAR.md)。DATE-RANGE-PICKER 结果见 [任务结果](tasks/results/DATE-RANGE-PICKER.md)。后续由用户选择一项,在实际前置具备后创建任务卡;不自动并行推进。
|
||||
TIME-FIELD 已完成公共迁移和客户端验收,见 [结果](tasks/results/TIME-FIELD.md);COLOR-SWATCH 见 [结果](tasks/results/COLOR-SWATCH.md),COLOR-AREA 见 [结果](tasks/results/COLOR-AREA.md)。RANGE-CALENDAR 结果见 [任务结果](tasks/results/RANGE-CALENDAR.md)。DATE-RANGE-PICKER 结果见 [任务结果](tasks/results/DATE-RANGE-PICKER.md)。后续由用户选择一项,在实际前置具备后创建任务卡;不自动并行推进。
|
||||
|
||||
## 当前工程边界
|
||||
|
||||
唯一Vue工作目录heroui-vue,一任务一分支、会话串行。b01/b02/b03已删除并解除Git登记;core内容已整合,是否保留该目录不影响运行。开发默认文档5173,playground按实际脚本;服务只在任务需要时启动,结束按用户要求停止。
|
||||
|
||||
已完成的单目录整合见 [结果](tasks/results/WORKSPACE-CONSOLIDATION.md)。当前客户端全量回归97文件/1415项通过;本轮DateRangePicker新增2文件/45项,任务定向18文件/254项通过,已通过增量复核与全量回归并合入 main,见任务结果;SSR历史用例已删除。逐像素自动对比、完整读屏矩阵、真机矩阵及Nuxt集成暂不投入。维护清理的实际结果见 [MAINTENANCE](tasks/results/MAINTENANCE.md)。
|
||||
已完成的单目录整合见 [结果](tasks/results/WORKSPACE-CONSOLIDATION.md)。当前客户端全量回归99文件/1445项通过;本轮ColorArea新增2文件/30项,任务定向12文件/173项通过;已通过独立复核并合入 main,结果见任务文件;SSR历史用例已删除。逐像素自动对比、完整读屏矩阵、真机矩阵及Nuxt集成暂不投入。维护清理的实际结果见 [MAINTENANCE](tasks/results/MAINTENANCE.md)。
|
||||
|
||||
## 按需入口
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# 当前工作区交接
|
||||
|
||||
- 任务:DATE-RANGE-PICKER 已通过增量复核与集成全量回归,按用户授权合入 main;无进行中任务,结果见 `docs/tasks/results/DATE-RANGE-PICKER.md`。
|
||||
- 工作区/分支:heroui-vue / main。
|
||||
- 起点:`89d2454f35a472e60861dbce2bf47bd892311ac9`(含任务卡与入口变更;父提交 d30ef64 含全部前置实现)。
|
||||
- 实施提交:`ff7c4ee45a966253e0ab691b104817307e92a832`;交付提交:`cf9798ad61238aafc4b940c363198b4a5034b19a`;首轮复核修复:`10540410b5db8867130931d3bd71f96943de080a`。
|
||||
- 合并提交:`b600d4d388fd155d9d20288dfc3d4e2bee65df1f`;任务状态 accepted。
|
||||
- 复核状态:R1 国际历法显示/提交分离、R2 动态 endpoint、R3 只读时间草稿已核销;独立复跑 6 文件/124 项及 typecheck 通过;自然退出动画的既有证据限制保留。
|
||||
- 验证:全量 97 文件/1415 项、任务定向 18 文件/254 项、typecheck、build:docs、五个 tarball 契约通过;未新增浏览器专项。
|
||||
- 历史:DATE-PICKER、RANGE-CALENDAR、TIME-FIELD、COLOR-SWATCH 已合入 main。
|
||||
- 预览:文档站 5173,`/components/date-range-picker`;playground 5174 已停止。
|
||||
- 任务:COLOR-AREA 已通过集成复核并按用户授权合入 main,状态 accepted;无进行中任务。结果见 `docs/tasks/results/COLOR-AREA.md`。
|
||||
- 工作区/分支:heroui-vue / `main`。
|
||||
- 起点:`01882160e698eaa1ec9473defa5397407e819ace`(含 COLOR-AREA 任务卡与 README 入口;父提交 `2f47c2d` 含全部元数据前置)。
|
||||
- 实施提交:`ae364578ceec84dca9ffce833623990d3911af47`;交付提交:`40d1d926becddcb066f0dd76ec126806b117fd3f`(本文件所在提交仅补齐该 SHA)。
|
||||
- 复核提交:`6ece365`;合并提交:`6119d73323a2c70dd63a40a0d10584bb0c4363f6`;远端状态以 `git status -sb` 为准。
|
||||
- 验证:全量 99 文件/1445 项、任务定向 12 文件/173 项、typecheck、build:docs、`check-package color-area color-swatch` 通过;真实 Chrome 5173 已检查 7 例、触屏捕获/取消、键盘焦点、浅深主题,控制台无新增 warn/error。
|
||||
- 已知限制:固定源运行时默认 `#ffffff`、RGB red/green、HSL/HSB hue/saturation 与中文 API 简表不同;Thumb 仅 `as`(无 asChild);鼠标 pointer capture 的浏览器证据受 CDP 合成事件限制,触屏捕获与 jsdom 鼠标捕获断言互补;未做 SSR/逐像素/完整读屏/真机矩阵。
|
||||
- 预览:文档 5173,`/components/color-area`;该服务为复用现有进程,未停止;playground 未启动。
|
||||
- 历史:DATE-RANGE-PICKER、DATE-PICKER、RANGE-CALENDAR、TIME-FIELD、COLOR-SWATCH 已合入 main。
|
||||
|
||||
单目录串行;新会话先核对 git 状态和结果文件。支持范围统一见 AGENTS.md,不自动开始下一项任务。
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<!-- task-metadata
|
||||
{
|
||||
"base": "2f47c2d5d2418640a2977aa1f9511db6af18ed76",
|
||||
"upstream": "ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960",
|
||||
"status": "accepted",
|
||||
"requires": [
|
||||
"packages/vue/src/components/color/value.ts",
|
||||
"packages/vue/src/components/color/model.ts",
|
||||
"packages/vue/src/components/color/area.ts",
|
||||
"packages/vue/src/components/color/gradient.ts",
|
||||
"packages/vue/src/components/color-swatch/ColorSwatch.vue",
|
||||
"packages/vue/tests/fixtures/ColorAreaFoundation.vue",
|
||||
"packages/styles/components/color-area.css",
|
||||
"tests/color-foundation.test.ts",
|
||||
"tests/package/client-checks.json"
|
||||
],
|
||||
"sources": [
|
||||
"packages/react/src/components/color-area/index.ts",
|
||||
"packages/react/src/components/color-area/color-area.tsx",
|
||||
"packages/react/tests/components/color-area/color-area.test.tsx",
|
||||
"packages/styles/components/color-area.css",
|
||||
"packages/styles/src/components/color-area/color-area.styles.ts",
|
||||
"apps/docs/content/docs/cn/react/components/(colors)/color-area.mdx",
|
||||
"apps/docs/src/demos/cn/color-area/index.ts",
|
||||
"apps/docs/src/demos/cn/color-area/basic.tsx",
|
||||
"apps/docs/src/demos/cn/color-area/with-dots.tsx",
|
||||
"apps/docs/src/demos/cn/color-area/space-and-channels.tsx",
|
||||
"apps/docs/src/demos/cn/color-area/disabled.tsx",
|
||||
"apps/docs/src/demos/cn/color-area/controlled.tsx",
|
||||
"apps/docs/src/demos/cn/color-area/render-function.tsx",
|
||||
"apps/docs/src/demos/cn/color-area/custom-styles.tsx"
|
||||
],
|
||||
"checks": [
|
||||
"pnpm exec vitest run tests/color-area.test.ts tests/color-area-demos.test.ts tests/color-foundation.test.ts tests/color-swatch.test.ts tests/color-picker-composition.test.ts tests/color-picker-protocol.test.ts tests/color-slider-foundation.test.ts tests/color-input-foundation.test.ts tests/color-field-protocol.test.ts tests/regressions/color",
|
||||
"pnpm typecheck",
|
||||
"pnpm build:docs",
|
||||
"node scripts/check-package.mjs color-area color-swatch"
|
||||
]
|
||||
}
|
||||
-->
|
||||
|
||||
# COLOR-AREA:公共二维颜色区域迁移
|
||||
|
||||
## 目标与交接
|
||||
|
||||
由一个 AI 在一个任务分支完成 ColorArea 客户端公共迁移:Root/Thumb、类型和变体、固定源样式、完整中文文档与 7 个基线示例,并验证真实二维操作及独立发布产物。本卡记录实施与验证结果,准确证据见 `docs/tasks/results/COLOR-AREA.md`。
|
||||
|
||||
前置已经集成:不可变 Color/parseColor 公共子集、共享颜色 owner/事务、二维交互及梯度内核、ColorSwatch。现有 CSS 和私有夹具不等于公共 ColorArea 已完成。
|
||||
|
||||
1. 先读 AGENTS.md、docs/tasks/README.md、ACTIVE.md、tests/README.md 和本卡,检查 Git 分支、完整 HEAD、未提交改动及其他会话占用。单目录串行,不自动 clone/worktree,不覆盖未知内容。
|
||||
2. 规划文件与入口变更已先保存为 Git 提交 `01882160e698eaa1ec9473defa5397407e819ace` 再交接;启动提交包含本卡及元数据列出的前置,不只满足最低祖先。运行 `node scripts/task-check.mjs COLOR-AREA`;其通过仅证明前置存在。
|
||||
3. 确认前一任务交接后,从上述提交创建 `feat/color-area-public`,记录准确起点 SHA,更新 ACTIVE.md 和本卡状态。缺依赖时用 `pnpm install --frozen-lockfile`,不重生成锁文件。
|
||||
4. 通过前置检查输出的只读参考目录,使用 `git show <upstream>:<path>` 阅读固定源;不跟随参考工作树最新内容。构建不能依赖参考目录。
|
||||
5. 先读 docs/decisions/color-foundation.md,再读 value.ts/model.ts/area.ts/gradient.ts 与 packages/vue/tests/fixtures/ColorAreaFoundation.vue。以当前代码为准,历史文档中旧路径或“尚未公开 Color”不覆盖已集成事实。
|
||||
|
||||
## 公共契约与实现边界
|
||||
|
||||
先建立“固定源 API → Vue API → DOM/状态 → 证据”表,包含源码继承的实际能力,不能只抄中文页简表。
|
||||
|
||||
- 导出 ColorArea/ColorAreaRoot、ColorAreaThumb、相应 Props、实际插槽/实例状态类型,以及 colorAreaVariants/ColorAreaVariants;复用现有公共 Color 类型,不泄漏 React、Reka 内部类型或事务 token。
|
||||
- 普通值使用 `v-model`,明确与 value/defaultValue 的优先级、显式 null/省略/无效值策略;change/changeEnd 复用既有接受值与事务语义。受控父级拒绝时,thumb、轴输入、背景和预览保持接受值,同一操作可再次提案;取消不伪造完成事件。
|
||||
- 复用最近颜色 owner;无自身值时继承,显式值覆盖。动态增加/移除值属性、切换 owner、外部更新、禁用/只读及卸载必须正确终止本控件事务,不取消兄弟控件事务。不另建颜色状态源。
|
||||
- 核对 colorSpace/xChannel/yChannel 的默认值、推断、合法组合和动态切换;18 个有序轴组合沿用既有算法。保留 alpha、灰色色相和完整接受值精度,不经 hex 往返量化。无效/重复轴的处理以现有协议和源审计形成明确文档及类型边界。
|
||||
- 支持固定源适用的 isDisabled、showDots、xName/yName/form、标签与描述关联、locale/dir、原生 attrs/事件、class/style、焦点和 ref。isReadOnly 等现有扩展若保留须标明。render/className/函数 style 用项目已有 as/asChild、作用域插槽、class/style 或 styleFn 约定适配,逐项记录可支持范围,不机械保留 React API。
|
||||
- Root 输出 data-slot="color-area",Thumb 输出 data-slot="color-area-thumb";验证 disabled/focus-visible/dragging 到真实 DOM 和 CSS 的映射。两个原生轴提供可访问名称、数值/单位及既有单 Tab 入口,不以虚构二维 aria-valuenow 替代。
|
||||
- 表单沿用 xName/yName/form 的两个轴提交/reset;共享 Picker 的完整颜色提交仍归 owner。不得给继承子项增加重复隐藏颜色值或重复 reset 所有权。
|
||||
- 样式沿用 hv-color-area CSS、颜色背景/Thumb 变量、showDots、尺寸/边框/阴影/焦点和 reduced-motion;检查已有 CSS 是否已进入入口,不重复移植。不以文档补丁修复组件。
|
||||
- 不公开 ColorSlider、ColorField/ColorInputGroup、ColorSwatchPicker 或 ColorPicker,不增加颜色解析格式/全量 React Color API,不修改无关日期、集合、弹层协议。共享缺口先加失败用例,再作最小修复。
|
||||
|
||||
## 文档与示例
|
||||
|
||||
文档入口 `/components/color-area`。固定中文标题“ColorArea 颜色区域”、介绍、章节、示例内容/顺序及 API/样式表保持基线;框架适配差异明确标注。
|
||||
|
||||
按顺序迁移 basic、with-dots、space-and-channels、disabled、controlled、render-function、custom-styles,共 7 例。使用本库公共部件;渲染函数例改成等效 Vue 作用域插槽,不能删成静态展示。演示预览/复制/高亮来自同一 SFC;图标使用 Tabler 官方 Vue 图标。
|
||||
|
||||
包根、types、styles 入口、共享导航仅增量修改;同步 docs/compatibility.md、docs/upstream.md、docs/status.md 和适用的 docs/verification.md。只将本项从未完成清单移出,其他颜色家族保持实际状态。
|
||||
|
||||
## 实施与验收
|
||||
|
||||
先完成真实 `<ColorArea><ColorAreaThumb /></ColorArea>` 的 basic 闭环,证明拖动、键盘、受控值和 DOM/样式一致,再自行完成剩余示例及边界;内部步骤不等待用户逐次批准。
|
||||
|
||||
验证命令唯一来源为顶部 checks。新增 color-area.test.ts、color-area-demos.test.ts 以及包消费契约,复用已有基础回归,避免重复编写底层算法测试。若改共享内核,按实际影响补相应使用者检查。
|
||||
|
||||
| 验收项 | 用户可见通过条件及证据 |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| 公开 API | 包根可导入 Root/Thumb/Props/variants;类型正反例覆盖合法空间/通道、值与事件/插槽,错误用法确实拒绝 |
|
||||
| 接受值/事件 | 非受控更新;受控接受、拒绝和再次提案;结束只触发正确次数,取消/卸载/禁用切换不伪造 changeEnd;外部更新无旧手势回写 |
|
||||
| 共享组合 | 私有既有 Picker owner 中公开 Area 与 Swatch 联动,显式覆盖及动态恢复继承正常;公共演示不依赖私有导出 |
|
||||
| 键盘/基础可访问性 | 实际 Tab 进入、焦点环、方向键、Shift、Home/End、PageUp/Down、RTL 与既有轴协议一致;禁用不可改值,标签和轴值有明确关联 |
|
||||
| 真实指针 | 公开组合中点击选色、拖动、抓取偏移、拖出边界仍捕获、pointercancel/lostcapture 清理正确;边框/缩放/尺寸变化后的坐标与 thumb 一致。使用真实浏览器几何和事件,不以 jsdom 假布局作为通过证据 |
|
||||
| 原生表单 | xName/yName 对应值准确,外部 form 归属/reset 可复现;受控拒绝后真实 input.value 回到接受值,组合无重复完整颜色提交 |
|
||||
| 视觉/内容 | 7/7 源例逐项核销;浅深、showDots、禁用、焦点、拖动放大、透明色与关键空间/交换轴可见检查;记录计算尺寸和背景/Thumb 一致性,不宣称逐像素一致 |
|
||||
| 发布产物 | 在 tests/package/client-checks.json 和类型契约增量加入 color-area;移除旧契约中仅针对 ColorArea 的“暂不公开”断言,其余私有家族边界保留。统一 check-package 验最终 tarball ESM/CSS 与 strict bundler/NodeNext 正反类型,不用源码 alias |
|
||||
|
||||
浏览器默认沿用文档 5173;先检查现有服务 URL/工作目录,需启动时 `pnpm dev`。端口冲突只用 HEROUI_DOCS_PORT 显式选择空闲端口,不停其他会话服务。记录浏览器、入口、操作、断言及实际结论;工具或环境失败写未验,不能当通过。
|
||||
|
||||
当前仅支持客户端:不开发、不修复、不新增也不运行 SSR/水合/Nuxt 服务端专项;文档静态构建照常。不建立逐像素自动对比、完整读屏矩阵、真机矩阵或 Nuxt 集成专项。
|
||||
|
||||
## 交付
|
||||
|
||||
按 docs/tasks/RESULT-TEMPLATE.md 写入 docs/tasks/results/COLOR-AREA.md:准确起点/实现/交付 SHA、源→实现→验证表、7 例核销、命令结论、浏览器可复现步骤、明确差异和未完成项。临时截图/日志可外放,关键断言与结论须在仓库。更新任务状态与 ACTIVE.md,使下一会话可从文件接续。
|
||||
|
||||
普通实施提交到任务分支,不自行合 main 或 push,不给其他会话派发消息。规划卡不代表迁移完成;发现当前实现已变化时先核对具体文件/导出,避免重复覆盖。
|
||||
@@ -21,6 +21,7 @@
|
||||
| 卡 | 用途 |
|
||||
| ----------------------------------- | ------------------------------------ |
|
||||
| [COLOR-SWATCH](COLOR-SWATCH.md) | 公共颜色值/Swatch家族 |
|
||||
| [COLOR-AREA](COLOR-AREA.md) | 复用二维颜色内核的公共 ColorArea 迁移 |
|
||||
| [TIME-FIELD](TIME-FIELD.md) | 复用日期/字段设施的时间字段 |
|
||||
| [RANGE-CALENDAR](RANGE-CALENDAR.md) | 公共范围日历客户端迁移 |
|
||||
| [DATE-PICKER](DATE-PICKER.md) | 复用日期/字段/弹层的公共日期选择器迁移 |
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
# COLOR-AREA 交付 / 接续
|
||||
|
||||
- 分支:`feat/color-area-public`
|
||||
- 起点:`01882160e698eaa1ec9473defa5397407e819ace`(含 COLOR-AREA 任务卡与 README 入口;父提交 `2f47c2d` 已含全部元数据前置)
|
||||
- 实施提交:`ae364578ceec84dca9ffce833623990d3911af47`
|
||||
- 交付提交:`40d1d926becddcb066f0dd76ec126806b117fd3f`(含实现、结果、最终文档与轴 change 修正;其后提交仅记录该 SHA)
|
||||
- 范围:仅客户端;未开发或宣称 SSR、水合、Nuxt 服务端、逐像素自动对比、完整读屏/真机矩阵。实施交付时未合 main、未 push;现已按用户授权完成集成,见下文。
|
||||
|
||||
## 改动
|
||||
|
||||
- 新增 `packages/vue/src/components/color-area/{ColorArea.vue,ColorAreaThumb.vue,context.ts,types.ts,labels.ts}`:公开 `ColorArea`/`ColorAreaRoot`、`ColorAreaThumb`、Props/RenderProps/插槽/样式/Expose 类型;Root 提供组语义、共享颜色 owner、背景与指针/键盘事务,Thumb 提供定位、两个本地化命名原生轴和单 Tab 入口。
|
||||
- 复用既有 `components/color/{value,model,area,gradient}.ts`,不新增颜色状态源;`xName`/`yName`/`form` 只提交两个轴,owner 的完整颜色提交/reset 不重复。保留 `isReadOnly` 与 `disabled` 别名并标注为库扩展。
|
||||
- `packages/styles/src/index.ts` 增加 `colorAreaVariants`(base/thumb 槽位与 `showDots`),样式入口注释改为公共 ColorArea;沿用既有 `hv-color-area` CSS 与 Apache 声明,没有重复移植 CSS。
|
||||
- 修正共享轴推断以匹配固定源 `react-stately@3.9.0` 的运行时行为:默认 `#ffffff`;未指定 `colorSpace` 时使用接受值空间,未指定轴时取空间首两个通道(RGB red/green,HSL/HSB hue/saturation)。私有 `ColorAreaFoundation` 显式保留 saturation×brightness,避免改写 Picker 集成测试语义。
|
||||
- 新增中文 `apps/docs/components/color-area.md`、7 个基线示例(basic/with-dots/space-and-channels/disabled/controlled/render-function/custom-styles)、导航与颜色分类入口;预览/复制/高亮共用同一 SFC,图标依赖未新增。
|
||||
- 新增 `tests/color-area.test.ts`(20 项)、`tests/color-area-demos.test.ts`(10 项)、`tests/package/color-area-contract.ts`,扩展 `client-checks.json`/`check-client.mjs`;旧颜色契约仅移除 ColorArea 的“暂不公开”断言,其余私有家族保留。
|
||||
- 同步 `docs/{compatibility,upstream,status,verification,component-notes}.md` 与 ColorSwatch 相关组件段落;任务卡状态改为 review,ACTIVE 记录本分支与结果入口。
|
||||
|
||||
## 源 → 实现 → 验证
|
||||
|
||||
| 固定源能力 | Vue 实现 | 证据 |
|
||||
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- |
|
||||
| `ColorAreaRoot` / `ColorThumb` 二部件与 `colorAreaVariants` | `ColorArea`/`ColorAreaRoot` + `ColorAreaThumb`;ctx 传递 root/thumb/x/y;`data-slot=color-area`、`color-area-thumb` | `color-area.test.ts` 结构/变体/as/asChild/Thumb as;浏览器 7 个预览 DOM 检查 |
|
||||
| `value/defaultValue/onChange/onChangeEnd` | `v-model`/`value`/`defaultValue`、`update:modelValue`/`change`/`changeEnd`;共享 `useColorState` 接受值与事务 | 非受控、受控接受/拒绝/重试、changeEnd 次数、取消/禁用/外部替换、精度/alpha |
|
||||
| `colorSpace/xChannel/yChannel` 默认与推断 | `colorAxes` 按固定源运行时顺序;`colorSpace` 省略取接受值空间 | rgb/hsl/hsb 默认轴、动态切换、18 组合沿用既有梯度与约束反例 |
|
||||
| `isDisabled/showDots` | `isDisabled`/`disabled`、`showDots`;Root/Thumb data 状态与 CSS | 单测 + 浏览器禁用/定位点/尺寸/焦点 |
|
||||
| `xName/yName/form` | 两个真实 range 输入;共享 `useChoiceForm` reset | 内部/外部 form 的提交、reset、真实 input.value 恢复 |
|
||||
| `render/className/style` | Root `as`/`asChild`,Thumb `as`;Vue class 绑定;`style`/`styleFn` 合并。Thumb 不提供 asChild,避免把两个原生轴移出滑块 | render-function demo、style/styleFn 普通样式保留、attrs 透传 |
|
||||
| 无障碍二维语义 | 两个原生轴、本地化名称/格式化值、单 Tab 入口、方向键切换焦点;组默认名本地化 | zh-CN/rtl 单测;真实浏览器键盘焦点环与 Tab 索引 |
|
||||
| 指针/捕获/边界 | 复用 area.ts 稳定根捕获、抓取偏移、内容盒几何、取消/失焦/卸载清理 | jsdom 捕获/取消/兄弟隔离/几何;真实 Chrome 触屏拖出边界与 lostcapture/pointercancel |
|
||||
| 样式与主题 | `hv-color-area`、showDots、Thumb 尺寸/边框/阴影、data-focus-visible/dragging/disabled、`--color-area-background`/`thumb-color` | 计算样式 224×224/176×176、Thumb 16/20px、RGB screen 与 HSL/HSB 图层、浅深主题 |
|
||||
|
||||
## 7 例核销
|
||||
|
||||
1. basic:224×224,RGB red/green 默认轴,`rgb(116,52,255)` Thumb 位置与背景一致。
|
||||
2. with-dots:`hv-color-area--show-dots` 与点阵覆盖层;HSL 默认 hue/saturation。
|
||||
3. space-and-channels:三个 Select 初始 HSB/Saturation/Brightness;切换 RGB 后 Blue/Green 与 255 上限,X 改 Red 生效;代码值随空间变化。
|
||||
4. disabled:Root/Thumb `data-disabled`,两个原生轴 disabled,键盘/指针不改值。
|
||||
5. controlled:`v-model` 与 ColorSwatch 同步;真实拖动/键盘后 HEX 与色块更新。
|
||||
6. render-function:Root asChild 保留 `data-custom=slider`,Thumb `as=span` 保留 `data-custom=thumb`,交互仍可用。
|
||||
7. custom-styles:`size-44 rounded-3xl` 实际 176×176/24px;Thumb `size-5 border-4` 实际 20px/4px。
|
||||
|
||||
## 命令结论
|
||||
|
||||
| 命令 | 结果 |
|
||||
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `node scripts/task-check.mjs COLOR-AREA` | 通过;起点提交含任务卡与全部前置 |
|
||||
| 任务卡 checks `pnpm exec vitest run ...`(12 文件) | **173/173 通过**(color-area 20 + demos 10 + foundation 31 + swatch 18 + picker composition 9/protocol 8 + slider 17 + input 24 + field 25 + regressions/color 11) |
|
||||
| `pnpm test` | **99 文件 / 1445 项通过**,无 skip |
|
||||
| `pnpm typecheck` | 通过;新增契约正反例生效 |
|
||||
| `pnpm build:docs` | 通过;保留既有 >500kB chunk 提示,不是组件 SSR 验收 |
|
||||
| `node scripts/check-package.mjs color-area color-swatch` | 通过:最终 tarball 独立安装、ESM 导出/CSS/variants、strict NodeNext 与 bundler 类型正反例;无 `reka-ui` 声明泄漏 |
|
||||
|
||||
## 真实浏览器
|
||||
|
||||
环境:文档 5173(Chrome,1280×900 CSS 视口,headless CDP + 桌面浏览器视口截图)。未停止复用中的文档服务。
|
||||
|
||||
- 7 个预览顺序与内容正确;基础/定位点/禁用 224×224,自定义 176×176、24px 圆角;Thumb 16px,拖动/自定义 20px,3px 白边。
|
||||
- 真实点击色彩空间 Select 选择 RGB 后,触发器变为 RGB/Blue/Green,区域轴名称与 255 上限同步,代码值显示 `rgb(100, 148, 237)`;页面无横向溢出。
|
||||
- 计算背景:RGB `screen` 三层、HSL/HSB 渐变图层;`--color-area-background` 与 `--color-area-thumb-color` 为真实值;`showDots` 点阵存在;浅/深主题尺寸、颜色、圆角一致。
|
||||
- 触屏(真实 pointer 事件):按下即选中并聚焦 x 轴;拖到区内/区外均保持 `setPointerCapture`,Thumb 跟随并 clamp 到 100%/边界;pointerup 提交、`data-dragging` 清理。
|
||||
- 受控区域临时应用 8px 边框与 `scale(1.2)` 后,内容盒 249.6×249.6;点击 25%/75% 目标点得到 x=63.75、y=63.75,Thumb 中心与目标点误差小于 0.02px。
|
||||
- `releasePointerCapture` 后下一次指针事件取消手势,数值不再回写;`pointercancel` 立即清理且保留接受值;禁用区域触摸不改值。
|
||||
- 键盘:ArrowRight 改 X、ArrowUp 改 Y 并切换单 Tab 入口;Thumb `data-focus-visible=true`,计算 outline 3px 与焦点阴影存在;控制台无新增 warn/error。
|
||||
- 受限说明:CDP 合成**鼠标**事件本身不保持 pointer capture(中性 div 可复现),因此鼠标区外拖动不作为浏览器通过证据;鼠标捕获/取消由 jsdom 的 `setPointerCapture` 断言覆盖。触屏 pointer 捕获为真实浏览器证据。
|
||||
|
||||
## 差异与遗留
|
||||
|
||||
- 固定源中文 API 简表写 `xChannel=saturation`、`yChannel=brightness`,但其运行时 `getColorSpaceAxes` 实际为空间首两通道;本库按运行时行为实现并在文档明确该差异。默认值同为运行时 `#ffffff`。
|
||||
- React `render` 未机械保留:Root 用 `as`/`asChild`,Thumb 用 `as`;style 函数在模板中通过 `styleFn`。Thumb 不支持 asChild(会破坏两个原生轴位于滑块内的结构)。
|
||||
- 基础/定位点/禁用/render 示例增加一个仅用于文档预览宽度的布局容器,避免共享 `.demo-row > *` 的 `max-width:100%` 覆盖组件 `max-w-56`;组件、参数、文案与示例顺序不变。
|
||||
- `isReadOnly`、`disabled` 别名、`data-readonly` 是保留的库扩展;未移植 React Aria 完整 attributes/state API、色名接口或二维 `aria-valuenow`。
|
||||
- 显式 `null` 清空接受值并以默认白绘制;空字符串/无效色按 `parseColor` 抛 `RangeError`。
|
||||
- 未开展 SSR/水合/Nuxt、逐像素对比、完整读屏和真机矩阵;鼠标准确的 pointer capture 浏览器证据受 CDP 合成事件限制,见上。
|
||||
- ColorField、ColorSlider、ColorPicker、ColorSwatchPicker、ColorInputGroup 仍为私有协议;本提交不自动开始下一任务。
|
||||
|
||||
## 集成复核(2026-10-27)
|
||||
|
||||
- 复核基线:`c56580e9b4e384b0d4b186d7499644aee6b11beb`。检查公共组件、类型、共享轴推断改动、状态/事务、表单、全部示例和消费契约,未发现阻断合并的实现问题。
|
||||
- R1(文档,已修复):事件表把 change 写为接受值变化,容易误导受控拒绝场景;改为颜色更新提案,并明确 changeEnd 不要求父级接受。行为与既有受控拒绝测试一致,未改运行时代码。
|
||||
- 独立复跑:`pnpm test` 99 文件/1445 项通过;`pnpm typecheck`、`pnpm build:docs` 通过;`node scripts/check-package.mjs color-area color-swatch` 最终 tarball ESM/CSS/variants 与 bundler/NodeNext 正反类型通过。产物检查首次因沙箱 DNS 失败,联网重跑通过,不将失败计为通过。
|
||||
- 独立浏览器抽查:IAB 的文档 `/components/color-area`,7 个区域尺寸为 224px(自定义 176px);受控 Red 从 155 经 ArrowRight 到 156,Green 从 128 经 ArrowUp 到 129,颜色同步且焦点转至 Y 轴、单 Tab 入口和 focus-visible 正确;Color Space 选择 RGB 后为 Blue/Green、max=255,背景同步。控制台 warn/error 为空。此次未重复实施方的捕获/几何专项,原证据及鼠标捕获限制保留。
|
||||
- 结论:accepted;用户已授权提交、合 main 和 push。合并及远端最终 SHA 见 Git 历史与 ACTIVE.md。
|
||||
|
||||
- 集成提交:`6119d73323a2c70dd63a40a0d10584bb0c4363f6`(main,合入复核提交 `6ece365`);合并无冲突,运行时代码与独立复核通过的版本一致。
|
||||
@@ -253,6 +253,14 @@ CSS/tv 仅加 `hv-` 前缀与 Apache-2.0 来源;`circle/square`、`xs/sm/md/lg
|
||||
|
||||
上游 `render` 映射为 `as`/`asChild` 与原生 attrs;`style` render prop 的函数形式在 Vue 模板中改为 `styleFn`(Vue 编译器会规整保留的 `style` 函数值),普通样式仍用 `style`。默认作用域插槽接收 `{ color }`。未迁移 ColorSwatchPicker 的 `ColorSwatchContext`(该家族不在本任务范围),也没有运行时依赖相邻 React 仓库。
|
||||
|
||||
## COLOR-AREA ColorArea(2026-10-26)
|
||||
|
||||
固定 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/color-area/{index.ts,color-area.tsx}`、`packages/styles/components/color-area.css`、`packages/styles/src/components/color-area/color-area.styles.ts`,中文 `(colors)/color-area.mdx` 与 `demos/cn/color-area` 全部 7 例(basic/with-dots/space-and-channels/disabled/controlled/render-function/custom-styles)。
|
||||
|
||||
CSS/tv 仅加 `hv-` 前缀与 Apache-2.0 来源;`showDots`、`hv-color-area`/`__thumb` 与 data-disabled/focus-visible/dragging 保持基线。Vue 侧复用本库 `components/color/{value,model,area,gradient}.ts` 的不可变 Color、共享 owner、二维事务与梯度,不包装 React Aria。固定源 `react-stately@3.9.0` 的 `useColorAreaState` 默认 `#ffffff`,`getColorSpaceAxes` 未指定轴时取空间首个剩余通道(RGB red/green,HSL/HSB hue/saturation);本库按该运行时行为实现,未照抄中文 API 简表的 saturation/brightness。上游 `render` 映射为 `as`/`asChild`(Root)与 `as`(Thumb),style 函数在模板中使用 `styleFn`。
|
||||
|
||||
ColorArea 的 `xName`/`yName`/`form` 只生成两个原生 range 输入;共享 owner 的完整颜色提交仍归 owner,未在子项增加重复隐藏颜色或 reset 所有权。默认值、受控拒绝/重试、动态 owner、locale/RTL、readOnly 扩展、真实浏览器和 tarball 证据见 [任务结果](tasks/results/COLOR-AREA.md)。
|
||||
|
||||
## TIME-FIELD(2026-10-26)
|
||||
|
||||
固定 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/time-field/{index.ts,time-field.tsx}`、共享 date-input-group、`packages/styles/components/time-field.css` 与 `packages/styles/src/components/time-field/time-field.styles.ts`,中文 `(date-and-time)/time-field.mdx` 和 `demos/cn/time-field` 全部15例。
|
||||
|
||||
@@ -59,3 +59,16 @@ Playground 5174 嵌套 Modal 场景:面板在 Modal 上方可见/可操作,E
|
||||
差异与限制:固定源 `slot="start"/"end"` 改为 `endpoint` prop;格式选项的 `w-full` 弹层在 Portal 自动宽度下映射为 252px 日历 + 24px 内边距;字段编辑无法显示毫秒,保留端点先前精度。未开展 SSR/水合/Nuxt、逐像素、完整读屏/真机矩阵;触屏长按拖选仍是 RangeCalendar 已知缺口。详情见 [任务结果](tasks/results/DATE-RANGE-PICKER.md)。
|
||||
|
||||
首轮复核 R1–R3 已修复:locale 历法显示与提交历法分离(Hebrew 下显示 5784、编辑后 change 仍为 Gregorian);动态 `endpoint` 同时切换显示与编辑适配器(start→end 后 ArrowUp 只改 end);只读/禁用时 `setTimeRange` 不再写空值时间草稿。复核反例与补充回归计入 date-range-picker 33 项;全量 97 文件/1415 项、定向 18 文件/254 项、类型检查、文档构建与五契约 tarball 检查通过。修复以行为测试核销,未新增浏览器专项。
|
||||
|
||||
## COLOR-AREA(2026-10-26,客户端)
|
||||
|
||||
公开 ColorArea/ColorAreaRoot、ColorAreaThumb、colorAreaVariants、Props/RenderProps/插槽/样式类型;固定源中文 7 例全部迁移,预览/复制/高亮共用同一 SFC。新增 20 项公共行为测试与 10 项文档/示例测试;修正共享颜色轴推断为固定源运行时行为(`#ffffff` 默认,RGB red/green,HSL/HSB hue/saturation),既有私有夹具显式保留 saturation×brightness。
|
||||
|
||||
- `pnpm test`:99 文件/1445 项客户端回归通过。
|
||||
- 任务定向 12 文件/173 项通过:color-area 两个新文件、color-foundation、color-swatch、picker composition/protocol、slider/input/field 基础及 regressions/color。
|
||||
- `pnpm typecheck`、`pnpm build:docs`:通过;文档构建保留已有大 chunk 提示,不是组件 SSR 验收。
|
||||
- `node scripts/check-package.mjs color-area color-swatch`:最终 tarball 独立安装、ESM/CSS/variants 与 strict NodeNext/bundler 类型正反例通过;旧契约仅移除 ColorArea 的“暂不公开”断言。
|
||||
|
||||
真实文档 5173(Chrome,1280×900 CSS 视口):7 个预览顺序正确;基础/定位点/禁用 224×224,自定义 176×176、圆角 24px,Thumb 16px(拖动/自定义 20px);RGB screen 混合与 HSL/HSB 图层、showDots、当前色变量、浅深主题和焦点环均实际检查;实际点击色彩空间 Select 切到 RGB 后轴名称、255 上限与代码值同步。8px 边框 + `scale(1.2)` 的内容盒 249.6×249.6 点击映射与 Thumb 中心误差 <0.02px。触屏拖拽在区内/拖出边界均保持 pointer capture,pointerup 提交并清理;releasePointerCapture 后下一次指针事件取消拖动且不回写旧手势;pointercancel 清理且保留接受值;禁用区域触摸不改变值。键盘 ArrowRight/ArrowUp 更新对应轴、切换单 Tab 入口并显示 3px 焦点轮廓与焦点阴影;控制台无新增 warn/error。
|
||||
|
||||
CDP 合成鼠标事件本身不保持 pointer capture(中性 div 复现),因此鼠标区外拖动未作为浏览器通过证据,鼠标捕获仍由单元夹具的 `setPointerCapture` 断言覆盖;未开展 SSR/水合/Nuxt、逐像素、完整读屏或真机矩阵。详情见 [任务结果](tasks/results/COLOR-AREA.md)。
|
||||
|
||||
@@ -173,9 +173,10 @@
|
||||
|
||||
@import "./components/calendar-year-picker.css" layer(components);
|
||||
|
||||
/* Private color interaction foundation; public components are not exported yet. */
|
||||
/* Public ColorArea (COLOR-AREA). */
|
||||
@import "./components/color-area.css" layer(components);
|
||||
|
||||
/* Private color interaction foundation; remaining color families are not public. */
|
||||
@import "./components/color-slider.css" layer(components);
|
||||
|
||||
@import "./components/color-field.css" layer(components);
|
||||
|
||||
@@ -1828,6 +1828,27 @@ export const colorSwatchVariants = tv({
|
||||
|
||||
export type ColorSwatchVariants = VariantProps<typeof colorSwatchVariants>;
|
||||
|
||||
/** HeroUI 3.2.6 / ce90ea3, Apache-2.0; hv namespace only. */
|
||||
export const colorAreaVariants = tv({
|
||||
defaultVariants: {
|
||||
showDots: false,
|
||||
},
|
||||
slots: {
|
||||
base: "hv-color-area",
|
||||
thumb: "hv-color-area__thumb",
|
||||
},
|
||||
variants: {
|
||||
showDots: {
|
||||
false: {},
|
||||
true: {
|
||||
base: "hv-color-area--show-dots",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type ColorAreaVariants = VariantProps<typeof colorAreaVariants>;
|
||||
|
||||
/** HeroUI 3.2.6 / ce90ea3, Apache-2.0; hv namespace only. */
|
||||
export const timeFieldVariants = tv({
|
||||
base: "hv-time-field",
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
computed,
|
||||
provide,
|
||||
shallowRef,
|
||||
useAttrs,
|
||||
watch,
|
||||
type CSSProperties,
|
||||
type StyleValue,
|
||||
} from "vue";
|
||||
import { Primitive, useForwardExpose } from "reka-ui";
|
||||
import { colorAreaVariants } from "@heroui-vue/styles";
|
||||
import { useColorState } from "../color/model";
|
||||
import { useColorArea } from "../color/area";
|
||||
import { colorAreaBackground } from "../color/gradient";
|
||||
import {
|
||||
parseColor,
|
||||
type Color,
|
||||
type ColorAxisChannel,
|
||||
type ColorSpace,
|
||||
type ColorValue,
|
||||
} from "../color/value";
|
||||
import { colorAreaKey, type ColorAreaElements } from "./context";
|
||||
import { colorAreaLabel } from "./labels";
|
||||
import type {
|
||||
ColorAreaRenderProps,
|
||||
ColorAreaSlots,
|
||||
ColorAreaStyle,
|
||||
ColorAreaStyleFn,
|
||||
} from "./types";
|
||||
|
||||
defineOptions({ inheritAttrs: false, name: "ColorArea" });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** Accepted color; the Vue `v-model` value. Omitted inherits the nearest owner. */
|
||||
modelValue?: ColorValue | null;
|
||||
/** Lower-priority alias for `modelValue`, matching the shared color model. */
|
||||
value?: ColorValue | null;
|
||||
/** Initial color for uncontrolled use. */
|
||||
defaultValue?: ColorValue | null;
|
||||
colorSpace?: ColorSpace;
|
||||
xChannel?: ColorAxisChannel;
|
||||
yChannel?: ColorAxisChannel;
|
||||
xName?: string;
|
||||
yName?: string;
|
||||
form?: string;
|
||||
isDisabled?: boolean;
|
||||
/** Alias for `isDisabled`. */
|
||||
disabled?: boolean;
|
||||
/** Library extension: blocks edits without removing the area from the tab order. */
|
||||
isReadOnly?: boolean;
|
||||
showDots?: boolean;
|
||||
locale?: string;
|
||||
dir?: "ltr" | "rtl";
|
||||
/** Render a different root element; corresponds to the upstream render prop. */
|
||||
as?: string;
|
||||
/** Merge the area attributes and handlers onto the single default-slot root. */
|
||||
asChild?: boolean;
|
||||
/** Vue style binding or upstream style function, merged after base styles. */
|
||||
style?: ColorAreaStyle;
|
||||
/** Template-friendly alias for the style function; receives render props. */
|
||||
styleFn?: ColorAreaStyleFn;
|
||||
}>(),
|
||||
{
|
||||
colorSpace: undefined,
|
||||
xChannel: undefined,
|
||||
yChannel: undefined,
|
||||
xName: undefined,
|
||||
yName: undefined,
|
||||
form: undefined,
|
||||
isDisabled: false,
|
||||
disabled: false,
|
||||
isReadOnly: false,
|
||||
showDots: false,
|
||||
locale: undefined,
|
||||
dir: undefined,
|
||||
as: "div",
|
||||
asChild: false,
|
||||
style: undefined,
|
||||
styleFn: undefined,
|
||||
},
|
||||
);
|
||||
|
||||
defineSlots<ColorAreaSlots>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [value: Color | null];
|
||||
change: [value: Color | null];
|
||||
changeEnd: [value: Color | null];
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
const state = useColorState(props, {
|
||||
fallback: () => parseColor("#ffffff"),
|
||||
inherit: true,
|
||||
change: (value) => {
|
||||
emit("update:modelValue", value);
|
||||
emit("change", value);
|
||||
},
|
||||
changeEnd: (value) => emit("changeEnd", value),
|
||||
});
|
||||
|
||||
const elements: ColorAreaElements = {
|
||||
root: shallowRef<HTMLElement>(),
|
||||
thumb: shallowRef<HTMLElement>(),
|
||||
focusX: shallowRef<HTMLInputElement>(),
|
||||
focusY: shallowRef<HTMLInputElement>(),
|
||||
};
|
||||
const control = useColorArea(state, props, elements);
|
||||
const { axes, dir, focusedAxis, locale } = control;
|
||||
const disabled = state.disabled;
|
||||
const readOnly = state.readOnly;
|
||||
const focusVisible = shallowRef(false);
|
||||
|
||||
const styles = computed(() => colorAreaVariants({ showDots: props.showDots }));
|
||||
const background = computed(() =>
|
||||
colorAreaBackground(
|
||||
axes.value.color,
|
||||
axes.value.space,
|
||||
axes.value.x,
|
||||
axes.value.y,
|
||||
dir.value,
|
||||
),
|
||||
);
|
||||
const baseStyle = computed<CSSProperties>(() => {
|
||||
const paint = background.value;
|
||||
return {
|
||||
"--color-area-background": [paint.backgroundImage, paint.backgroundColor]
|
||||
.filter(Boolean)
|
||||
.join(", "),
|
||||
backgroundBlendMode: paint.backgroundBlendMode,
|
||||
touchAction: disabled.value || readOnly.value ? "auto" : "none",
|
||||
} as CSSProperties;
|
||||
});
|
||||
const renderProps = computed<ColorAreaRenderProps>(() => ({
|
||||
color: axes.value.color,
|
||||
space: axes.value.space,
|
||||
x: axes.value.x,
|
||||
y: axes.value.y,
|
||||
}));
|
||||
const ordinaryStyle = computed<StyleValue | undefined>(() => {
|
||||
const value = props.style;
|
||||
return typeof value === "function" ? value(renderProps.value) : value;
|
||||
});
|
||||
const computedStyle = computed<StyleValue | undefined>(() =>
|
||||
props.styleFn?.(renderProps.value),
|
||||
);
|
||||
|
||||
const label = computed(() => {
|
||||
const explicit = attrs["aria-label"];
|
||||
if (explicit != null) return String(explicit);
|
||||
if (attrs["aria-labelledby"] != null) return undefined;
|
||||
return colorAreaLabel(locale.value);
|
||||
});
|
||||
|
||||
// Expose before `useForwardExpose` so the forwarded `$el` getter and these
|
||||
// getters coexist on the public instance.
|
||||
defineExpose({
|
||||
element: elements.root,
|
||||
color: computed<Color | null>(() => state.value.value),
|
||||
});
|
||||
|
||||
const { forwardRef, currentElement } = useForwardExpose();
|
||||
watch(
|
||||
currentElement,
|
||||
(element) => {
|
||||
elements.root.value = (element as HTMLElement | null) ?? undefined;
|
||||
},
|
||||
{ immediate: true, flush: "sync" },
|
||||
);
|
||||
|
||||
provide(colorAreaKey, {
|
||||
elements,
|
||||
state,
|
||||
control,
|
||||
styles,
|
||||
focusVisible,
|
||||
disabled,
|
||||
readOnly,
|
||||
locale,
|
||||
dir,
|
||||
options: props,
|
||||
});
|
||||
|
||||
function axis(event: Event) {
|
||||
const value = (event.target as HTMLElement | null)?.getAttribute?.(
|
||||
"data-axis",
|
||||
);
|
||||
return value === "x" || value === "y" ? value : undefined;
|
||||
}
|
||||
function onKeydown(event: KeyboardEvent) {
|
||||
if (axis(event)) control.keydown(event);
|
||||
}
|
||||
function onInput(event: Event) {
|
||||
const channel = axis(event);
|
||||
if (channel) control.input(channel, event);
|
||||
}
|
||||
function onChange(event: Event) {
|
||||
if (axis(event)) control.commit();
|
||||
}
|
||||
function onFocusin(event: FocusEvent) {
|
||||
const target = event.target as HTMLElement | null;
|
||||
if (!target) return;
|
||||
focusVisible.value = target.matches(":focus-visible");
|
||||
const channel = target.getAttribute("data-axis");
|
||||
if (channel === "x" || channel === "y") focusedAxis.value = channel;
|
||||
}
|
||||
function onFocusout(event: FocusEvent) {
|
||||
const next = event.relatedTarget as Node | null;
|
||||
if (!elements.root.value?.contains(next)) {
|
||||
focusVisible.value = false;
|
||||
control.blur();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive
|
||||
:ref="forwardRef"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
v-bind="attrs"
|
||||
:class="styles.base()"
|
||||
:style="[baseStyle, ordinaryStyle, computedStyle]"
|
||||
role="group"
|
||||
data-slot="color-area"
|
||||
:dir="dir"
|
||||
:aria-label="label"
|
||||
:data-disabled="disabled || undefined"
|
||||
:data-readonly="readOnly || undefined"
|
||||
@keydown="onKeydown"
|
||||
@keyup="control.keyup"
|
||||
@input="onInput"
|
||||
@change="onChange"
|
||||
@focusin="onFocusin"
|
||||
@focusout="onFocusout"
|
||||
@pointerdown="control.pointerdown"
|
||||
@pointermove="control.pointermove"
|
||||
@pointerup="control.pointerup"
|
||||
@pointercancel="control.cancel"
|
||||
@lostpointercapture="control.cancel"
|
||||
>
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
@@ -0,0 +1,155 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, watch, type CSSProperties, type StyleValue } from "vue";
|
||||
import { Primitive, useForwardExpose } from "reka-ui";
|
||||
import { useColorAreaContext } from "./context";
|
||||
import { colorChannelLabel } from "./labels";
|
||||
import type {
|
||||
ColorAreaThumbRenderProps,
|
||||
ColorAreaThumbStyle,
|
||||
ColorAreaThumbStyleFn,
|
||||
} from "./types";
|
||||
|
||||
defineOptions({ inheritAttrs: false, name: "ColorAreaThumb" });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** Render a different thumb element; corresponds to the upstream render prop. */
|
||||
as?: string;
|
||||
/** Vue style binding or upstream style function, merged after base styles. */
|
||||
style?: ColorAreaThumbStyle;
|
||||
/** Template-friendly alias for the style function; receives render props. */
|
||||
styleFn?: ColorAreaThumbStyleFn;
|
||||
}>(),
|
||||
{
|
||||
as: "div",
|
||||
style: undefined,
|
||||
styleFn: undefined,
|
||||
},
|
||||
);
|
||||
|
||||
const {
|
||||
elements,
|
||||
control,
|
||||
styles,
|
||||
focusVisible,
|
||||
disabled,
|
||||
readOnly,
|
||||
locale,
|
||||
dir,
|
||||
options,
|
||||
} = useColorAreaContext();
|
||||
const { axes, percent, dragging, focusedAxis, x, y } = control;
|
||||
|
||||
const xInput = elements.focusX;
|
||||
const yInput = elements.focusY;
|
||||
|
||||
defineExpose({ element: elements.thumb });
|
||||
|
||||
const { forwardRef, currentElement } = useForwardExpose();
|
||||
watch(
|
||||
currentElement,
|
||||
(element) => {
|
||||
elements.thumb.value = (element as HTMLElement | null) ?? undefined;
|
||||
},
|
||||
{ immediate: true, flush: "sync" },
|
||||
);
|
||||
|
||||
const xLabel = computed(() => colorChannelLabel(axes.value.x, locale.value));
|
||||
const yLabel = computed(() => colorChannelLabel(axes.value.y, locale.value));
|
||||
const xValueText = computed(() =>
|
||||
axes.value.color.formatChannelValue(axes.value.x, locale.value),
|
||||
);
|
||||
const yValueText = computed(() =>
|
||||
axes.value.color.formatChannelValue(axes.value.y, locale.value),
|
||||
);
|
||||
const xMax = computed(
|
||||
() => axes.value.color.getChannelRange(axes.value.x).maxValue,
|
||||
);
|
||||
const yMax = computed(
|
||||
() => axes.value.color.getChannelRange(axes.value.y).maxValue,
|
||||
);
|
||||
|
||||
const baseStyle = computed<CSSProperties>(() => ({
|
||||
position: "absolute",
|
||||
left: `${(dir.value === "rtl" ? 1 - percent.value.x : percent.value.x) * 100}%`,
|
||||
top: `${(1 - percent.value.y) * 100}%`,
|
||||
transform: "translate(-50%, -50%)",
|
||||
"--color-area-thumb-color": axes.value.color.toString("css"),
|
||||
}));
|
||||
const renderProps = computed<ColorAreaThumbRenderProps>(() => ({
|
||||
color: axes.value.color,
|
||||
space: axes.value.space,
|
||||
x: axes.value.x,
|
||||
y: axes.value.y,
|
||||
percent: { ...percent.value },
|
||||
isDragging: dragging.value,
|
||||
isDisabled: disabled.value,
|
||||
isReadOnly: readOnly.value,
|
||||
}));
|
||||
const ordinaryStyle = computed<StyleValue | undefined>(() => {
|
||||
const value = props.style;
|
||||
return typeof value === "function" ? value(renderProps.value) : value;
|
||||
});
|
||||
const computedStyle = computed<StyleValue | undefined>(() =>
|
||||
props.styleFn?.(renderProps.value),
|
||||
);
|
||||
|
||||
const hiddenStyle: CSSProperties = {
|
||||
position: "absolute",
|
||||
width: "1px",
|
||||
height: "1px",
|
||||
overflow: "hidden",
|
||||
clipPath: "inset(50%)",
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive
|
||||
:ref="forwardRef"
|
||||
:as="as"
|
||||
v-bind="$attrs"
|
||||
:class="styles.thumb()"
|
||||
:style="[baseStyle, ordinaryStyle, computedStyle]"
|
||||
data-slot="color-area-thumb"
|
||||
:data-dragging="dragging || undefined"
|
||||
:data-focus-visible="focusVisible || undefined"
|
||||
:data-disabled="disabled || undefined"
|
||||
:data-readonly="readOnly || undefined"
|
||||
>
|
||||
<input
|
||||
ref="xInput"
|
||||
type="range"
|
||||
step="any"
|
||||
data-axis="x"
|
||||
:tabindex="focusedAxis === 'x' ? 0 : -1"
|
||||
:name="options.xName"
|
||||
:form="options.form"
|
||||
:aria-label="xLabel"
|
||||
:aria-valuetext="xValueText"
|
||||
:min="0"
|
||||
:max="xMax"
|
||||
:value="x"
|
||||
:disabled="disabled"
|
||||
:aria-readonly="readOnly || undefined"
|
||||
:style="hiddenStyle"
|
||||
/>
|
||||
<input
|
||||
ref="yInput"
|
||||
type="range"
|
||||
step="any"
|
||||
data-axis="y"
|
||||
aria-orientation="vertical"
|
||||
:tabindex="focusedAxis === 'y' ? 0 : -1"
|
||||
:name="options.yName"
|
||||
:form="options.form"
|
||||
:aria-label="yLabel"
|
||||
:aria-valuetext="yValueText"
|
||||
:min="0"
|
||||
:max="yMax"
|
||||
:value="y"
|
||||
:disabled="disabled"
|
||||
:aria-readonly="readOnly || undefined"
|
||||
:style="hiddenStyle"
|
||||
/>
|
||||
</Primitive>
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
inject,
|
||||
type ComputedRef,
|
||||
type InjectionKey,
|
||||
type ShallowRef,
|
||||
} from "vue";
|
||||
import type { ColorState } from "../color/model";
|
||||
import type { ColorAreaControl, ColorAreaOptions } from "../color/area";
|
||||
|
||||
export interface ColorAreaElements {
|
||||
root: ShallowRef<HTMLElement | undefined>;
|
||||
thumb: ShallowRef<HTMLElement | undefined>;
|
||||
focusX: ShallowRef<HTMLInputElement | undefined>;
|
||||
focusY: ShallowRef<HTMLInputElement | undefined>;
|
||||
}
|
||||
|
||||
export interface ColorAreaStyles {
|
||||
base: () => string;
|
||||
thumb: () => string;
|
||||
}
|
||||
|
||||
export interface ColorAreaContext {
|
||||
elements: ColorAreaElements;
|
||||
state: ColorState;
|
||||
control: ColorAreaControl;
|
||||
styles: ComputedRef<ColorAreaStyles>;
|
||||
focusVisible: ShallowRef<boolean>;
|
||||
disabled: ComputedRef<boolean>;
|
||||
readOnly: ComputedRef<boolean>;
|
||||
locale: ComputedRef<string>;
|
||||
dir: ComputedRef<"ltr" | "rtl">;
|
||||
options: ColorAreaOptions;
|
||||
}
|
||||
|
||||
export const colorAreaKey: InjectionKey<ColorAreaContext> =
|
||||
Symbol("hv-color-area");
|
||||
|
||||
export function useColorAreaContext() {
|
||||
const context = inject(colorAreaKey, undefined);
|
||||
if (!context)
|
||||
throw new Error("ColorAreaThumb must be rendered inside ColorArea.");
|
||||
return context;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { ColorAxisChannel } from "../color/value";
|
||||
|
||||
const english: Record<ColorAxisChannel, string> = {
|
||||
red: "Red",
|
||||
green: "Green",
|
||||
blue: "Blue",
|
||||
hue: "Hue",
|
||||
saturation: "Saturation",
|
||||
lightness: "Lightness",
|
||||
brightness: "Brightness",
|
||||
};
|
||||
|
||||
const chinese: Record<ColorAxisChannel, string> = {
|
||||
red: "红色",
|
||||
green: "绿色",
|
||||
blue: "蓝色",
|
||||
hue: "色相",
|
||||
saturation: "饱和度",
|
||||
lightness: "亮度",
|
||||
brightness: "明度",
|
||||
};
|
||||
|
||||
function isChinese(locale: string) {
|
||||
return locale.toLowerCase().startsWith("zh");
|
||||
}
|
||||
|
||||
/** Localized native axis name; other locales fall back to the English term. */
|
||||
export function colorChannelLabel(channel: ColorAxisChannel, locale: string) {
|
||||
return (isChinese(locale) ? chinese : english)[channel];
|
||||
}
|
||||
|
||||
/** Default group name used when the consumer does not supply a label. */
|
||||
export function colorAreaLabel(locale: string) {
|
||||
return isChinese(locale) ? "颜色区域" : "Color area";
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import type { StyleValue, VNodeChild } from "vue";
|
||||
import type { Color, ColorAxisChannel, ColorSpace } from "../color/value";
|
||||
|
||||
/** Values shared by the public style functions and render state. */
|
||||
export interface ColorAreaRenderProps {
|
||||
/** Display color for the current space; defaults to the accepted value. */
|
||||
color: Color;
|
||||
space: ColorSpace;
|
||||
x: ColorAxisChannel;
|
||||
y: ColorAxisChannel;
|
||||
}
|
||||
|
||||
export interface ColorAreaThumbRenderProps extends ColorAreaRenderProps {
|
||||
/** Accepted axis positions in the 0–1 content box, before RTL mapping. */
|
||||
percent: { x: number; y: number };
|
||||
isDragging: boolean;
|
||||
isDisabled: boolean;
|
||||
isReadOnly: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function form of the upstream `style` render prop. Vue's template compiler
|
||||
* reserves `style` for ordinary bindings, so templates pass the function
|
||||
* through `styleFn`; render functions may pass it directly.
|
||||
*/
|
||||
export type ColorAreaStyleFn = (
|
||||
renderProps: ColorAreaRenderProps,
|
||||
) => StyleValue | undefined;
|
||||
|
||||
/** Vue style binding (object/array/string) or the upstream style function. */
|
||||
export type ColorAreaStyle = StyleValue | ColorAreaStyleFn;
|
||||
|
||||
export type ColorAreaThumbStyleFn = (
|
||||
renderProps: ColorAreaThumbRenderProps,
|
||||
) => StyleValue | undefined;
|
||||
|
||||
export type ColorAreaThumbStyle = StyleValue | ColorAreaThumbStyleFn;
|
||||
|
||||
/** Default slot; render one ColorAreaThumb per area. */
|
||||
export interface ColorAreaSlots {
|
||||
default?: () => VNodeChild;
|
||||
}
|
||||
|
||||
/**
|
||||
* State exposed by the root instance. Refs are unwrapped on the public
|
||||
* instance proxy, matching the ColorSwatch `element` convention.
|
||||
*/
|
||||
export interface ColorAreaExpose {
|
||||
element: HTMLElement | null;
|
||||
color: Color | null;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export function useColorArea(
|
||||
const axes = computed(() =>
|
||||
colorAxes(
|
||||
state.value.value ??
|
||||
new Color({ space: "hsb", h: 0, s: 100, b: 100, alpha: 1 }),
|
||||
new Color({ space: "rgb", r: 255, g: 255, b: 255, alpha: 1 }),
|
||||
props.colorSpace,
|
||||
props.xChannel,
|
||||
props.yChannel,
|
||||
@@ -156,6 +156,7 @@ export function useColorArea(
|
||||
// Capture the stable area, never the transient child that received pointerdown.
|
||||
owner.setPointerCapture?.(event.pointerId);
|
||||
event.preventDefault();
|
||||
focusedAxis.value = "x";
|
||||
thumb.value?.focus({ preventScroll: true });
|
||||
if (!inThumb) update(point);
|
||||
}
|
||||
@@ -323,3 +324,4 @@ export function useColorArea(
|
||||
blur: () => stop(true),
|
||||
};
|
||||
}
|
||||
export type ColorAreaControl = ReturnType<typeof useColorArea>;
|
||||
|
||||
@@ -311,33 +311,16 @@ export function colorAxes(
|
||||
x?: ColorAxisChannel,
|
||||
y?: ColorAxisChannel,
|
||||
) {
|
||||
const working =
|
||||
space ??
|
||||
(x === "red" ||
|
||||
x === "green" ||
|
||||
x === "blue" ||
|
||||
y === "red" ||
|
||||
y === "green" ||
|
||||
y === "blue"
|
||||
? "rgb"
|
||||
: x === "lightness" || y === "lightness"
|
||||
? "hsl"
|
||||
: x === "brightness" || y === "brightness"
|
||||
? "hsb"
|
||||
: color.getColorSpace() === "rgb"
|
||||
? "hsb"
|
||||
: color.getColorSpace());
|
||||
// Matches the fixed source: the value's own space wins when `colorSpace` is
|
||||
// omitted, and an omitted axis takes the first remaining channel in that
|
||||
// space (RGB red/green, HSL/HSB hue/saturation).
|
||||
const working = space ?? color.getColorSpace();
|
||||
const native = channels[working];
|
||||
const xChannel = x ?? (working === "rgb" ? "red" : "saturation");
|
||||
const yChannel =
|
||||
y ??
|
||||
native.find(
|
||||
(c) =>
|
||||
c !== xChannel &&
|
||||
(c === "brightness" || c === "lightness" || c === "green"),
|
||||
) ??
|
||||
native.find((c) => c !== xChannel)!;
|
||||
const xChannel = x ?? native.find((channel) => channel !== y);
|
||||
const yChannel = y ?? native.find((channel) => channel !== xChannel);
|
||||
if (
|
||||
!xChannel ||
|
||||
!yChannel ||
|
||||
xChannel === yChannel ||
|
||||
!native.includes(xChannel) ||
|
||||
!native.includes(yChannel)
|
||||
|
||||
@@ -1136,6 +1136,26 @@ export {
|
||||
type AutocompleteVariants,
|
||||
} from "@heroui-vue/styles";
|
||||
|
||||
export { default as ColorArea } from "./components/color-area/ColorArea.vue";
|
||||
export { default as ColorAreaRoot } from "./components/color-area/ColorArea.vue";
|
||||
export { default as ColorAreaThumb } from "./components/color-area/ColorAreaThumb.vue";
|
||||
export { colorAreaVariants, type ColorAreaVariants } from "@heroui-vue/styles";
|
||||
export type {
|
||||
ColorAreaExpose,
|
||||
ColorAreaRenderProps,
|
||||
ColorAreaSlots,
|
||||
ColorAreaStyle,
|
||||
ColorAreaStyleFn,
|
||||
ColorAreaThumbRenderProps,
|
||||
ColorAreaThumbStyle,
|
||||
ColorAreaThumbStyleFn,
|
||||
} from "./components/color-area/types";
|
||||
export type {
|
||||
ColorAreaProps,
|
||||
ColorAreaRootProps,
|
||||
ColorAreaThumbProps,
|
||||
} from "./types";
|
||||
|
||||
export { default as ColorSwatch } from "./components/color-swatch/ColorSwatch.vue";
|
||||
export { default as ColorSwatchRoot } from "./components/color-swatch/ColorSwatch.vue";
|
||||
export {
|
||||
|
||||
@@ -911,6 +911,11 @@ export type AutocompleteFilterProps = InstanceType<
|
||||
import type ColorSwatch from "./components/color-swatch/ColorSwatch.vue";
|
||||
export type ColorSwatchProps = InstanceType<typeof ColorSwatch>["$props"];
|
||||
export type ColorSwatchRootProps = ColorSwatchProps;
|
||||
import type ColorArea from "./components/color-area/ColorArea.vue";
|
||||
import type ColorAreaThumb from "./components/color-area/ColorAreaThumb.vue";
|
||||
export type ColorAreaProps = InstanceType<typeof ColorArea>["$props"];
|
||||
export type ColorAreaRootProps = ColorAreaProps;
|
||||
export type ColorAreaThumbProps = InstanceType<typeof ColorAreaThumb>["$props"];
|
||||
export type {
|
||||
ColorSwatchRenderProps,
|
||||
ColorSwatchSlots,
|
||||
|
||||
+6
-1
@@ -11,7 +11,12 @@ import {
|
||||
import { colorAreaBackground } from "../../src/components/color/gradient";
|
||||
import { parseColor, type Color } from "../../src/components/color/value";
|
||||
defineOptions({ inheritAttrs: false });
|
||||
const props = defineProps<ColorModelProps & ColorAreaOptions>();
|
||||
const props = withDefaults(defineProps<ColorModelProps & ColorAreaOptions>(), {
|
||||
// The private picker proof uses the common saturation × brightness square;
|
||||
// public ColorArea inference follows the fixed source's channel order.
|
||||
xChannel: "saturation",
|
||||
yChannel: "brightness",
|
||||
});
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [Color | null];
|
||||
change: [Color | null];
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { ColorArea, Select, parseColor } from "../packages/vue/src";
|
||||
import Basic from "../apps/docs/demos/color-area-basic.vue";
|
||||
import WithDots from "../apps/docs/demos/color-area-with-dots.vue";
|
||||
import SpaceAndChannels from "../apps/docs/demos/color-area-space-and-channels.vue";
|
||||
import Disabled from "../apps/docs/demos/color-area-disabled.vue";
|
||||
import Controlled from "../apps/docs/demos/color-area-controlled.vue";
|
||||
import RenderFunction from "../apps/docs/demos/color-area-render-function.vue";
|
||||
import CustomStyles from "../apps/docs/demos/color-area-custom-styles.vue";
|
||||
|
||||
const mounted: ReturnType<typeof mount>[] = [];
|
||||
function render(component: Parameters<typeof mount>[0]) {
|
||||
const w = mount(component, { attachTo: document.body });
|
||||
mounted.push(w);
|
||||
return w;
|
||||
}
|
||||
afterEach(() => {
|
||||
mounted.splice(0).forEach((w) => w.unmount());
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
const root = (w: ReturnType<typeof mount>) =>
|
||||
w.get<HTMLElement>("[data-slot=color-area]");
|
||||
const thumb = (w: ReturnType<typeof mount>) =>
|
||||
w.get<HTMLElement>("[data-slot=color-area-thumb]");
|
||||
const axis = (w: ReturnType<typeof mount>, name: "x" | "y") =>
|
||||
w.get<HTMLInputElement>(`[data-axis="${name}"]`);
|
||||
|
||||
const previews = [
|
||||
"basic",
|
||||
"with-dots",
|
||||
"space-and-channels",
|
||||
"disabled",
|
||||
"controlled",
|
||||
"render-function",
|
||||
"custom-styles",
|
||||
];
|
||||
|
||||
describe("ColorArea documentation demos", () => {
|
||||
it("keeps the seven pinned previews in the upstream order", () => {
|
||||
const document = readFileSync("apps/docs/components/color-area.md", "utf8");
|
||||
const names = [
|
||||
...document.matchAll(/<ComponentPreview name="color-area-([^"]+)"/g),
|
||||
].map((match) => match[1]);
|
||||
expect(names).toEqual(previews);
|
||||
for (const name of previews) {
|
||||
const source = readFileSync(
|
||||
`apps/docs/demos/color-area-${name}.vue`,
|
||||
"utf8",
|
||||
);
|
||||
expect(source).toContain("<template>");
|
||||
expect(source).toContain('from "@heroui-vue/components"');
|
||||
expect(source).not.toContain("className");
|
||||
}
|
||||
});
|
||||
|
||||
it("renders the basic color area from the baseline default value", () => {
|
||||
const w = render(Basic);
|
||||
expect(root(w).classes()).toContain("hv-color-area");
|
||||
expect(axis(w, "x").element.value).toBe("116");
|
||||
expect(axis(w, "y").element.value).toBe("52");
|
||||
expect(axis(w, "x").attributes("aria-label")).toBe("Red");
|
||||
expect(axis(w, "y").attributes("aria-label")).toBe("Green");
|
||||
expect(thumb(w).element.style.left).toBe(`${(116 / 255) * 100}%`);
|
||||
expect(
|
||||
root(w).element.style.getPropertyValue("--color-area-background"),
|
||||
).toContain("linear-gradient");
|
||||
});
|
||||
|
||||
it("applies the dots overlay variant", () => {
|
||||
const w = render(WithDots);
|
||||
expect(root(w).classes()).toContain("hv-color-area--show-dots");
|
||||
expect(axis(w, "x").element.value).toBe("200");
|
||||
expect(axis(w, "y").element.value).toBe("100");
|
||||
});
|
||||
|
||||
it("switches color space and axes in the space-and-channels example", async () => {
|
||||
const w = render(SpaceAndChannels);
|
||||
const selects = w.findAllComponents(Select);
|
||||
expect(selects).toHaveLength(3);
|
||||
expect(w.findAll("[data-slot=color-area]")).toHaveLength(1);
|
||||
expect(axis(w, "x").attributes("aria-label")).toBe("Saturation");
|
||||
expect(axis(w, "y").attributes("aria-label")).toBe("Brightness");
|
||||
expect(axis(w, "x").element.value).toBe("58");
|
||||
expect(axis(w, "y").element.value).toBe("93");
|
||||
expect(w.text()).toContain("hsb(219, 58%, 93%)");
|
||||
|
||||
await selects[0]!.vm.$emit("update:modelValue", "rgb");
|
||||
await flushPromises();
|
||||
expect(axis(w, "x").attributes("aria-label")).toBe("Blue");
|
||||
expect(axis(w, "y").attributes("aria-label")).toBe("Green");
|
||||
expect(w.text()).toMatch(/rgb\(/);
|
||||
|
||||
await w.findAllComponents(Select)[1]!.vm.$emit("update:modelValue", "red");
|
||||
await flushPromises();
|
||||
expect(axis(w, "x").attributes("aria-label")).toBe("Red");
|
||||
expect(axis(w, "x").attributes("max")).toBe("255");
|
||||
});
|
||||
|
||||
it("disables both axes and pointer interaction", async () => {
|
||||
const w = render(Disabled);
|
||||
expect(root(w).attributes("data-disabled")).toBe("true");
|
||||
expect(axis(w, "x").element.disabled).toBe(true);
|
||||
expect(axis(w, "y").element.disabled).toBe(true);
|
||||
await axis(w, "x").trigger("keydown", { key: "ArrowRight" });
|
||||
expect(w.findComponent(ColorArea).emitted("change")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps the controlled swatch and hex output in sync", async () => {
|
||||
const w = render(Controlled);
|
||||
const swatch = w.get<HTMLElement>("[data-slot=color-swatch]");
|
||||
expect(swatch.element.style.backgroundColor).toBe(
|
||||
parseColor("#9B80FF").toString("css"),
|
||||
);
|
||||
expect(axis(w, "x").element.value).toBe("155");
|
||||
expect(axis(w, "y").element.value).toBe("128");
|
||||
await axis(w, "x").trigger("keydown", { key: "ArrowRight" });
|
||||
await axis(w, "x").trigger("keyup", { key: "ArrowRight" });
|
||||
await flushPromises();
|
||||
expect(w.text()).toContain("#9C80FF");
|
||||
expect(swatch.element.style.backgroundColor).toBe(
|
||||
parseColor("#9C80FF").toString("css"),
|
||||
);
|
||||
});
|
||||
|
||||
it("maps the render-function demo to asChild, as and native attributes", async () => {
|
||||
const w = render(RenderFunction);
|
||||
const area = root(w);
|
||||
expect(area.attributes("data-custom")).toBe("slider");
|
||||
expect(area.element.tagName).toBe("DIV");
|
||||
expect(area.classes()).toContain("hv-color-area");
|
||||
expect(area.attributes("role")).toBe("group");
|
||||
const handle = thumb(w);
|
||||
expect(handle.attributes("data-custom")).toBe("thumb");
|
||||
expect(handle.element.tagName).toBe("SPAN");
|
||||
expect(handle.classes()).toContain("hv-color-area__thumb");
|
||||
expect(axis(w, "x").element.value).toBe("116");
|
||||
|
||||
await axis(w, "x").trigger("keydown", { key: "ArrowRight" });
|
||||
await axis(w, "x").trigger("keyup", { key: "ArrowRight" });
|
||||
await flushPromises();
|
||||
expect(axis(w, "x").element.value).toBe("117");
|
||||
});
|
||||
|
||||
it("merges the custom style classes onto the real parts", () => {
|
||||
const w = render(CustomStyles);
|
||||
const area = root(w);
|
||||
const handle = thumb(w);
|
||||
for (const name of ["size-44", "rounded-3xl", "hv-color-area"]) {
|
||||
expect(area.classes()).toContain(name);
|
||||
}
|
||||
for (const name of [
|
||||
"size-5",
|
||||
"rounded-full",
|
||||
"border-4",
|
||||
"border-white",
|
||||
"hv-color-area__thumb",
|
||||
]) {
|
||||
expect(handle.classes()).toContain(name);
|
||||
}
|
||||
});
|
||||
|
||||
it("documents the Vue API, adaptation range and related state", () => {
|
||||
const document = readFileSync("apps/docs/components/color-area.md", "utf8");
|
||||
expect(document).toContain("title: ColorArea 颜色区域");
|
||||
expect(document).toContain("ColorAreaThumb");
|
||||
expect(document).toContain("`colorSpace`");
|
||||
expect(document).toContain("`xChannel`");
|
||||
expect(document).toContain("`yChannel`");
|
||||
expect(document).toContain("`showDots`");
|
||||
expect(document).toContain("`asChild`");
|
||||
expect(document).toContain("`styleFn`");
|
||||
expect(document).toContain("`isReadOnly`");
|
||||
expect(document).toContain("`xName` / `yName`");
|
||||
expect(document).toContain("ColorAreaRenderProps");
|
||||
expect(document).toContain("changeEnd");
|
||||
expect(document).not.toMatch(/\|\s*`className`\s*\|/);
|
||||
expect(document).not.toContain("### ColorArea.Thumb");
|
||||
expect(document).toContain("ColorField");
|
||||
expect(document).toContain("仍为私有颜色协议");
|
||||
});
|
||||
|
||||
it("adds ColorArea to the shared navigation before ColorSwatch", () => {
|
||||
const navigation = readFileSync(
|
||||
"apps/docs/.vitepress/theme/navigation.ts",
|
||||
"utf8",
|
||||
);
|
||||
const area = navigation.indexOf("ColorArea 颜色区域");
|
||||
const swatch = navigation.indexOf("ColorSwatch 颜色色块");
|
||||
expect(area).toBeGreaterThan(-1);
|
||||
expect(swatch).toBeGreaterThan(area);
|
||||
expect(navigation).toContain('url: "/components/color-area"');
|
||||
expect(navigation).toContain('category: "colors"');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,620 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { defineComponent, ref, shallowRef } from "vue";
|
||||
import {
|
||||
ColorArea,
|
||||
ColorAreaRoot,
|
||||
ColorAreaThumb,
|
||||
ColorSwatch,
|
||||
ConfigProvider,
|
||||
colorAreaVariants,
|
||||
parseColor,
|
||||
type Color,
|
||||
} from "../packages/vue/src";
|
||||
import ColorPickerFoundation from "../packages/vue/tests/fixtures/ColorPickerFoundation.vue";
|
||||
|
||||
const mounted: ReturnType<typeof mount>[] = [];
|
||||
function render(
|
||||
component: Parameters<typeof mount>[0],
|
||||
options: Parameters<typeof mount>[1] = {},
|
||||
) {
|
||||
const w = mount(component, { attachTo: document.body, ...options });
|
||||
mounted.push(w);
|
||||
return w;
|
||||
}
|
||||
function area(
|
||||
props: Record<string, unknown> = {},
|
||||
template = '<ColorArea v-bind="props"><ColorAreaThumb /></ColorArea>',
|
||||
setup: () => Record<string, unknown> = () => ({}),
|
||||
) {
|
||||
return render(
|
||||
defineComponent({
|
||||
components: { ColorArea, ColorAreaThumb },
|
||||
setup: () => ({ props, ...setup() }),
|
||||
template,
|
||||
}),
|
||||
);
|
||||
}
|
||||
afterEach(() => {
|
||||
mounted.splice(0).forEach((w) => w.unmount());
|
||||
document.body.innerHTML = "";
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
const root = (w: ReturnType<typeof mount>) =>
|
||||
w.get<HTMLElement>("[data-slot=color-area]");
|
||||
const thumb = (w: ReturnType<typeof mount>) =>
|
||||
w.get<HTMLElement>("[data-slot=color-area-thumb]");
|
||||
const x = (w: ReturnType<typeof mount>) =>
|
||||
w.get<HTMLInputElement>('[data-axis="x"]');
|
||||
const y = (w: ReturnType<typeof mount>) =>
|
||||
w.get<HTMLInputElement>('[data-axis="y"]');
|
||||
const axisValue = (w: ReturnType<typeof mount>, axis: "x" | "y") =>
|
||||
w.get<HTMLInputElement>(`[data-axis="${axis}"]`).element.value;
|
||||
const thumbColor = (w: ReturnType<typeof mount>) =>
|
||||
thumb(w).element.style.getPropertyValue("--color-area-thumb-color");
|
||||
const emitted = (w: ReturnType<typeof mount>, name: string) =>
|
||||
w.findComponent(ColorArea).emitted(name) ?? [];
|
||||
async function key(
|
||||
w: ReturnType<typeof mount>,
|
||||
name: string,
|
||||
up = true,
|
||||
extra = {},
|
||||
axis: "x" | "y" = "x",
|
||||
) {
|
||||
const input = w.get(`[data-axis="${axis}"]`);
|
||||
await input.trigger("keydown", { key: name, ...extra });
|
||||
if (up) await input.trigger("keyup", { key: name, ...extra });
|
||||
await flushPromises();
|
||||
}
|
||||
function geometry(
|
||||
w: ReturnType<typeof mount>,
|
||||
selector = "[data-slot=color-area]",
|
||||
) {
|
||||
const node = w.get<HTMLElement>(selector).element;
|
||||
let captured: number | undefined;
|
||||
Object.defineProperties(node, {
|
||||
offsetWidth: { get: () => 224, configurable: true },
|
||||
offsetHeight: { get: () => 224, configurable: true },
|
||||
});
|
||||
vi.spyOn(node, "getBoundingClientRect").mockReturnValue({
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: 224,
|
||||
height: 224,
|
||||
right: 224,
|
||||
bottom: 224,
|
||||
x: 0,
|
||||
y: 0,
|
||||
toJSON: () => ({}),
|
||||
});
|
||||
node.setPointerCapture = vi.fn((id) => {
|
||||
captured = id;
|
||||
});
|
||||
node.hasPointerCapture = vi.fn((id) => captured === id);
|
||||
node.releasePointerCapture = vi.fn(() => {
|
||||
captured = undefined;
|
||||
});
|
||||
return node;
|
||||
}
|
||||
async function pointer(node: Element, type: string, extra = {}) {
|
||||
const event = new Event(type, { bubbles: true, cancelable: true });
|
||||
Object.assign(event, {
|
||||
pointerId: 1,
|
||||
pointerType: "mouse",
|
||||
isPrimary: true,
|
||||
button: 0,
|
||||
clientX: 112,
|
||||
clientY: 112,
|
||||
...extra,
|
||||
});
|
||||
node.dispatchEvent(event);
|
||||
await flushPromises();
|
||||
return event;
|
||||
}
|
||||
|
||||
describe("ColorArea public contract", () => {
|
||||
it("renders the baseline root, thumb, two axes and background variable", () => {
|
||||
const w = area({ defaultValue: "hsl(200, 100%, 50%)" });
|
||||
expect(ColorAreaRoot).toBe(ColorArea);
|
||||
const node = root(w);
|
||||
expect(node.attributes("role")).toBe("group");
|
||||
expect(node.attributes("dir")).toBe("ltr");
|
||||
expect(node.classes()).toEqual(expect.arrayContaining(["hv-color-area"]));
|
||||
expect(node.classes()).not.toContain("hv-color-area--show-dots");
|
||||
expect(
|
||||
node.element.style.getPropertyValue("--color-area-background"),
|
||||
).toContain("linear-gradient");
|
||||
expect(node.element.style.backgroundBlendMode).toBe("normal");
|
||||
|
||||
const handle = thumb(w);
|
||||
expect(handle.classes()).toContain("hv-color-area__thumb");
|
||||
expect(handle.element.tagName).toBe("DIV");
|
||||
expect(parseFloat(handle.element.style.left)).toBeCloseTo(
|
||||
(200 / 360) * 100,
|
||||
);
|
||||
expect(handle.element.style.top).toBe("0%");
|
||||
expect(handle.element.style.transform).toBe("translate(-50%, -50%)");
|
||||
expect(
|
||||
handle.element.style.getPropertyValue("--color-area-thumb-color"),
|
||||
).toBe(parseColor("hsl(200, 100%, 50%)").toString("css"));
|
||||
|
||||
expect(x(w).attributes("type")).toBe("range");
|
||||
expect(x(w).attributes("step")).toBe("any");
|
||||
expect(x(w).attributes("aria-label")).toBe("Hue");
|
||||
expect(x(w).attributes("aria-valuetext")).toBe("200°");
|
||||
expect(x(w).attributes("min")).toBe("0");
|
||||
expect(x(w).attributes("max")).toBe("360");
|
||||
expect(x(w).attributes("tabindex")).toBe("0");
|
||||
expect(y(w).attributes("aria-label")).toBe("Saturation");
|
||||
expect(y(w).attributes("aria-orientation")).toBe("vertical");
|
||||
expect(y(w).attributes("tabindex")).toBe("-1");
|
||||
expect(x(w).element.value).toBe("200");
|
||||
expect(y(w).element.value).toBe("100");
|
||||
});
|
||||
|
||||
it("maps showDots to the variant classes", () => {
|
||||
const w = area({ defaultValue: "#ff0000", showDots: true });
|
||||
expect(root(w).classes()).toContain("hv-color-area--show-dots");
|
||||
expect(colorAreaVariants({ showDots: true }).base()).toContain(
|
||||
"hv-color-area--show-dots",
|
||||
);
|
||||
expect(colorAreaVariants().thumb()).toBe("hv-color-area__thumb");
|
||||
});
|
||||
|
||||
it("updates an uncontrolled area through the native axes and commits once", async () => {
|
||||
const w = area({
|
||||
defaultValue: "hsb(240, 50%, 50%)",
|
||||
xChannel: "saturation",
|
||||
yChannel: "brightness",
|
||||
});
|
||||
await key(w, "ArrowRight", false);
|
||||
expect(x(w).element.value).toBe("51");
|
||||
expect(thumb(w).element.style.left).toBe("51%");
|
||||
expect(emitted(w, "update:modelValue")).toHaveLength(1);
|
||||
expect(emitted(w, "change")).toHaveLength(1);
|
||||
expect(emitted(w, "changeEnd")).toHaveLength(0);
|
||||
await x(w).trigger("keyup", { key: "ArrowRight" });
|
||||
expect(emitted(w, "changeEnd")).toHaveLength(1);
|
||||
const value = emitted(w, "changeEnd")[0]![0] as Color;
|
||||
expect(value.getChannelValue("saturation")).toBe(51);
|
||||
expect(value.getChannelValue("alpha")).toBe(1);
|
||||
|
||||
await key(w, "ArrowUp", true, {}, "y");
|
||||
expect(y(w).element.value).toBe("51");
|
||||
expect(x(w).attributes("tabindex")).toBe("-1");
|
||||
expect(y(w).attributes("tabindex")).toBe("0");
|
||||
expect(document.activeElement).toBe(y(w).element);
|
||||
});
|
||||
|
||||
it("keeps the accepted value on controlled rejection and allows retries", async () => {
|
||||
const value = shallowRef(parseColor("hsb(240,50%,50%)"));
|
||||
const w = render(
|
||||
defineComponent({
|
||||
components: { ColorArea, ColorAreaThumb },
|
||||
setup: () => ({ value }),
|
||||
template: `<ColorArea :model-value="value" x-channel="saturation" y-channel="brightness"><ColorAreaThumb /></ColorArea>`,
|
||||
}),
|
||||
);
|
||||
for (let i = 0; i < 2; i++) await key(w, "ArrowRight");
|
||||
expect(emitted(w, "change")).toHaveLength(2);
|
||||
expect(
|
||||
(emitted(w, "change")[1]![0] as Color).getChannelValue("saturation"),
|
||||
).toBe(51);
|
||||
expect(x(w).element.value).toBe("50");
|
||||
expect(thumb(w).element.style.left).toBe("50%");
|
||||
|
||||
value.value = parseColor("hsb(240,80%,70%)");
|
||||
await flushPromises();
|
||||
expect(x(w).element.value).toBe("80");
|
||||
expect(y(w).element.value).toBe("70");
|
||||
expect(thumb(w).element.style.left).toBe("80%");
|
||||
expect(parseFloat(thumb(w).element.style.top)).toBeCloseTo(30);
|
||||
});
|
||||
|
||||
it("commits pointer drags once and cleans up cancellations", async () => {
|
||||
const w = area({
|
||||
defaultValue: "hsb(240, 50%, 50%)",
|
||||
xChannel: "saturation",
|
||||
yChannel: "brightness",
|
||||
});
|
||||
const node = geometry(w);
|
||||
await pointer(node, "pointerdown", { clientX: 112, clientY: 112 });
|
||||
await pointer(node, "pointermove", { clientX: 168, clientY: 112 });
|
||||
await pointer(node, "pointerup", { clientX: 168, clientY: 112 });
|
||||
expect(node.setPointerCapture).toHaveBeenCalledWith(1);
|
||||
expect(node.releasePointerCapture).toHaveBeenCalledWith(1);
|
||||
expect(emitted(w, "change")).toHaveLength(1);
|
||||
expect(emitted(w, "changeEnd")).toHaveLength(1);
|
||||
expect(
|
||||
(emitted(w, "changeEnd")[0]![0] as Color).getChannelValue("saturation"),
|
||||
).toBe(75);
|
||||
|
||||
const cancel = area({
|
||||
colorSpace: "hsb",
|
||||
xChannel: "saturation",
|
||||
yChannel: "brightness",
|
||||
});
|
||||
const cancelled = geometry(cancel);
|
||||
await pointer(cancelled, "pointerdown");
|
||||
await pointer(cancelled, "pointermove", { clientX: 168 });
|
||||
await pointer(cancelled, "pointercancel");
|
||||
expect(emitted(cancel, "changeEnd")).toHaveLength(0);
|
||||
expect(cancelled.releasePointerCapture).toHaveBeenCalledWith(1);
|
||||
});
|
||||
|
||||
it("honors disabled and read-only permissions", async () => {
|
||||
const disabled = area({ isDisabled: true, defaultValue: "#ff0000" });
|
||||
expect(root(disabled).attributes("data-disabled")).toBe("true");
|
||||
expect(thumb(disabled).attributes("data-disabled")).toBe("true");
|
||||
expect(x(disabled).attributes()).toHaveProperty("disabled");
|
||||
const node = geometry(disabled);
|
||||
await pointer(node, "pointerdown");
|
||||
await key(disabled, "ArrowRight");
|
||||
expect(emitted(disabled, "change")).toHaveLength(0);
|
||||
expect(node.setPointerCapture).not.toHaveBeenCalled();
|
||||
|
||||
const readOnly = area({ isReadOnly: true, defaultValue: "#ff0000" });
|
||||
expect(root(readOnly).attributes("data-readonly")).toBe("true");
|
||||
expect(x(readOnly).attributes("aria-readonly")).toBe("true");
|
||||
expect(x(readOnly).attributes()).not.toHaveProperty("disabled");
|
||||
await key(readOnly, "ArrowRight");
|
||||
expect(emitted(readOnly, "change")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("supports channels, color spaces and locale-aware labels", () => {
|
||||
const rgb = area({
|
||||
colorSpace: "rgb",
|
||||
defaultValue: "rgb(10, 20, 30)",
|
||||
});
|
||||
expect(x(rgb).attributes("aria-label")).toBe("Red");
|
||||
expect(y(rgb).attributes("aria-label")).toBe("Green");
|
||||
expect(x(rgb).attributes("max")).toBe("255");
|
||||
expect(x(rgb).element.value).toBe("10");
|
||||
expect(thumb(rgb).element.style.left).toBe(`${(10 / 255) * 100}%`);
|
||||
|
||||
const zh = render(
|
||||
defineComponent({
|
||||
components: { ConfigProvider, ColorArea, ColorAreaThumb },
|
||||
template: `<ConfigProvider locale="zh-CN" dir="rtl">
|
||||
<ColorArea default-value="hsb(240,25%,50%)" x-channel="saturation" y-channel="brightness">
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>
|
||||
</ConfigProvider>`,
|
||||
}),
|
||||
);
|
||||
expect(root(zh).attributes("aria-label")).toBe("颜色区域");
|
||||
expect(root(zh).attributes("dir")).toBe("rtl");
|
||||
expect(x(zh).attributes("aria-label")).toBe("饱和度");
|
||||
expect(y(zh).attributes("aria-label")).toBe("明度");
|
||||
expect(x(zh).attributes("aria-valuetext")).toBe("25%");
|
||||
expect(thumb(zh).element.style.left).toBe("75%");
|
||||
expect(
|
||||
root(zh).element.style.getPropertyValue("--color-area-background"),
|
||||
).toContain("to left");
|
||||
});
|
||||
|
||||
it("supports as, asChild, class, style, styleFn and exposed state", () => {
|
||||
const styleFn = vi.fn(({ color }: { color: Color }) => ({
|
||||
outline: `1px solid ${color.toString("hex")}`,
|
||||
}));
|
||||
const w = area(
|
||||
{},
|
||||
`<ColorArea as-child default-value="#ff0000" :style="{ opacity: 0.9 }" :style-fn="styleFn" ref="areaRef">
|
||||
<div data-custom="area"><ColorAreaThumb as="span" data-custom="thumb" /></div>
|
||||
</ColorArea>`,
|
||||
() => ({ styleFn }),
|
||||
);
|
||||
const node = root(w);
|
||||
expect(node.element.tagName).toBe("DIV");
|
||||
expect(node.attributes("data-custom")).toBe("area");
|
||||
expect(node.attributes("role")).toBe("group");
|
||||
expect(node.classes()).toContain("hv-color-area");
|
||||
expect(node.element.style.opacity).toBe("0.9");
|
||||
expect(node.element.style.outline).toBe("1px solid #FF0000");
|
||||
expect(styleFn).toHaveBeenCalled();
|
||||
expect(thumb(w).element.tagName).toBe("SPAN");
|
||||
expect(thumb(w).attributes("data-custom")).toBe("thumb");
|
||||
const exposed = w.vm.$refs.areaRef as {
|
||||
element: HTMLElement;
|
||||
color: Color;
|
||||
};
|
||||
expect(exposed.element).toBe(node.element);
|
||||
expect(exposed.color.toString("hex")).toBe("#FF0000");
|
||||
});
|
||||
|
||||
it("keeps one Tab entry and restores focused axes", async () => {
|
||||
const w = area({ defaultValue: "hsb(240,50%,50%)" });
|
||||
expect(x(w).attributes("tabindex")).toBe("0");
|
||||
expect(y(w).attributes("tabindex")).toBe("-1");
|
||||
await key(w, "ArrowUp", true, {}, "x");
|
||||
expect(document.activeElement).toBe(y(w).element);
|
||||
expect(y(w).attributes("tabindex")).toBe("0");
|
||||
expect(x(w).attributes("tabindex")).toBe("-1");
|
||||
await key(w, "ArrowRight", true, {}, "y");
|
||||
expect(document.activeElement).toBe(x(w).element);
|
||||
expect(x(w).attributes("tabindex")).toBe("0");
|
||||
});
|
||||
|
||||
it("keeps the thumb grab offset and cleans up when disabled mid-drag", async () => {
|
||||
const disabled = ref(false);
|
||||
const w = area(
|
||||
{},
|
||||
`<ColorArea :is-disabled="disabled" default-value="hsb(240,50%,50%)" x-channel="saturation" y-channel="brightness"><ColorAreaThumb /></ColorArea>`,
|
||||
() => ({ disabled }),
|
||||
);
|
||||
const node = geometry(w);
|
||||
await pointer(thumb(w).element, "pointerdown", {
|
||||
clientX: 115,
|
||||
clientY: 112,
|
||||
});
|
||||
expect(thumb(w).attributes("data-dragging")).toBe("true");
|
||||
await pointer(node, "pointermove", { clientX: 137.4, clientY: 112 });
|
||||
expect(
|
||||
(emitted(w, "change")[0]![0] as Color).getChannelValue("saturation"),
|
||||
).toBeCloseTo(60);
|
||||
disabled.value = true;
|
||||
await flushPromises();
|
||||
await pointer(node, "pointerup", { clientX: 137.4 });
|
||||
expect(emitted(w, "changeEnd")).toHaveLength(0);
|
||||
expect(node.releasePointerCapture).toHaveBeenCalledWith(1);
|
||||
expect(thumb(w).attributes("data-dragging")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("cancels stale keyboard transactions after an external replacement", async () => {
|
||||
const value = shallowRef(parseColor("hsb(240,50%,50%)"));
|
||||
const w = render(
|
||||
defineComponent({
|
||||
components: { ColorArea, ColorAreaThumb },
|
||||
setup: () => ({ value }),
|
||||
template: `<ColorArea :model-value="value" x-channel="saturation" y-channel="brightness"><ColorAreaThumb /></ColorArea>`,
|
||||
}),
|
||||
);
|
||||
await key(w, "ArrowRight", false);
|
||||
value.value = parseColor("hsb(90,25%,75%)");
|
||||
await flushPromises();
|
||||
await x(w).trigger("keyup", { key: "ArrowRight" });
|
||||
expect(emitted(w, "changeEnd")).toHaveLength(0);
|
||||
expect(x(w).element.value).toBe("25");
|
||||
});
|
||||
|
||||
it("honors consumer cancellation of keyboard and pointer defaults", async () => {
|
||||
const w = area(
|
||||
{},
|
||||
`<ColorArea default-value="#ff0000" @keydown.prevent @pointerdown.prevent>
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>`,
|
||||
);
|
||||
const node = geometry(w);
|
||||
await key(w, "ArrowRight");
|
||||
await pointer(node, "pointerdown");
|
||||
expect(emitted(w, "change")).toHaveLength(0);
|
||||
expect(node.setPointerCapture).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("submits and resets the two named axes, including an external form", async () => {
|
||||
const w = area(
|
||||
{},
|
||||
`<form><ColorArea default-value="hsb(240,50%,50%)" x-channel="saturation" y-channel="brightness" x-name="s" y-name="b">
|
||||
<ColorAreaThumb />
|
||||
</ColorArea></form>`,
|
||||
);
|
||||
await key(w, "ArrowUp", true, {}, "y");
|
||||
const form = w.get("form").element as HTMLFormElement;
|
||||
expect(new FormData(form).get("s")).toBe("50");
|
||||
expect(new FormData(form).get("b")).toBe("51");
|
||||
form.reset();
|
||||
await flushPromises();
|
||||
expect(x(w).element.value).toBe("50");
|
||||
expect(y(w).element.value).toBe("50");
|
||||
|
||||
const external = area(
|
||||
{},
|
||||
`<form id="external-area"></form>
|
||||
<ColorArea form="external-area" default-value="hsb(240,50%,50%)" x-channel="saturation" y-channel="brightness" x-name="s" y-name="b">
|
||||
<ColorAreaThumb />
|
||||
</ColorArea>`,
|
||||
);
|
||||
const outside = external.get("#external-area").element as HTMLFormElement;
|
||||
await key(external, "ArrowRight");
|
||||
expect(new FormData(outside).get("s")).toBe("51");
|
||||
outside.reset();
|
||||
await flushPromises();
|
||||
expect(x(external).element.value).toBe("50");
|
||||
});
|
||||
|
||||
it("shares the nearest color owner, supports overrides and restores inheritance", async () => {
|
||||
const override = shallowRef<Record<string, unknown>>({});
|
||||
const w = render(
|
||||
defineComponent({
|
||||
components: {
|
||||
Picker: ColorPickerFoundation,
|
||||
ColorArea,
|
||||
ColorAreaThumb,
|
||||
ColorSwatch,
|
||||
},
|
||||
setup: () => ({ override }),
|
||||
template: `<form><Picker name="color" default-value="hsb(240,50%,50%)">
|
||||
<ColorArea v-bind="override" color-space="hsb" x-channel="saturation" y-channel="brightness"><ColorAreaThumb /></ColorArea>
|
||||
<ColorSwatch data-owner-swatch />
|
||||
</Picker></form>`,
|
||||
}),
|
||||
);
|
||||
const picker = w.findComponent(ColorPickerFoundation);
|
||||
const swatch = () =>
|
||||
w.get<HTMLElement>("[data-owner-swatch]").element.style.backgroundColor;
|
||||
expect(x(w).element.value).toBe("50");
|
||||
expect(swatch()).toBe(parseColor("hsb(240,50%,50%)").toString("css"));
|
||||
|
||||
await key(w, "ArrowRight");
|
||||
expect(picker.emitted("change")).toHaveLength(1);
|
||||
expect(x(w).element.value).toBe("51");
|
||||
expect(swatch()).toBe(parseColor("hsb(240,51%,50%)").toString("css"));
|
||||
|
||||
override.value = { modelValue: "hsb(10,20%,30%)" };
|
||||
await flushPromises();
|
||||
expect(x(w).element.value).toBe("20");
|
||||
await key(w, "ArrowRight");
|
||||
expect(picker.emitted("change")).toHaveLength(1);
|
||||
expect(x(w).element.value).toBe("20");
|
||||
|
||||
override.value = {};
|
||||
await flushPromises();
|
||||
expect(x(w).element.value).toBe("51");
|
||||
await key(w, "ArrowRight");
|
||||
expect(picker.emitted("change")).toHaveLength(2);
|
||||
expect(
|
||||
new FormData(w.get("form").element as HTMLFormElement).getAll("color"),
|
||||
).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("supports thumb style functions and preserves ordinary styles", () => {
|
||||
const styleFn = vi.fn(
|
||||
({ percent }: { percent: { x: number; y: number } }) => ({
|
||||
opacity: percent.x,
|
||||
}),
|
||||
);
|
||||
const w = area(
|
||||
{},
|
||||
`<ColorArea default-value="hsb(240,25%,50%)" x-channel="saturation" y-channel="brightness">
|
||||
<ColorAreaThumb :style="{ borderColor: 'black' }" :style-fn="styleFn" data-custom="thumb" />
|
||||
</ColorArea>`,
|
||||
() => ({ styleFn }),
|
||||
);
|
||||
const handle = thumb(w);
|
||||
expect(handle.attributes("data-custom")).toBe("thumb");
|
||||
expect(handle.element.style.borderColor).toBe("black");
|
||||
expect(handle.element.style.opacity).toBe("0.25");
|
||||
expect(styleFn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
percent: { x: 0.25, y: 0.5 },
|
||||
isDragging: false,
|
||||
isDisabled: false,
|
||||
isReadOnly: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("uses the documented default, explicit null and root label fallbacks", async () => {
|
||||
const fallback = area();
|
||||
expect(x(fallback).element.value).toBe("255");
|
||||
expect(y(fallback).element.value).toBe("255");
|
||||
expect(thumb(fallback).element.style.left).toBe("100%");
|
||||
expect(thumb(fallback).element.style.top).toBe("0%");
|
||||
|
||||
const cleared = area(
|
||||
{},
|
||||
`<ColorArea :model-value="null"><ColorAreaThumb /></ColorArea>`,
|
||||
);
|
||||
expect(x(cleared).element.value).toBe("255");
|
||||
expect(y(cleared).element.value).toBe("255");
|
||||
expect(thumb(cleared).element.style.left).toBe("100%");
|
||||
expect(thumb(cleared).element.style.top).toBe("0%");
|
||||
await key(cleared, "ArrowLeft");
|
||||
expect(emitted(cleared, "change")).toHaveLength(1);
|
||||
|
||||
const labelled = area(
|
||||
{},
|
||||
`<div>
|
||||
<ColorArea aria-label="主题色"><ColorAreaThumb /></ColorArea>
|
||||
<ColorArea aria-labelledby="area-caption"><ColorAreaThumb /></ColorArea>
|
||||
<span id="area-caption">说明</span>
|
||||
</div>`,
|
||||
);
|
||||
const roots = labelled.findAll<HTMLElement>("[data-slot=color-area]");
|
||||
expect(roots[0]!.attributes("aria-label")).toBe("主题色");
|
||||
expect(roots[1]!.attributes("aria-label")).toBeUndefined();
|
||||
expect(roots[1]!.attributes("aria-labelledby")).toBe("area-caption");
|
||||
});
|
||||
|
||||
it("honors modelValue over value over defaultValue and the disabled alias", async () => {
|
||||
const both = area(
|
||||
{},
|
||||
`<ColorArea model-value="#ff0000" value="#00ff00" default-value="#0000ff"><ColorAreaThumb /></ColorArea>`,
|
||||
);
|
||||
expect(axisValue(both, "x")).toBe("255");
|
||||
expect(thumbColor(both)).toBe("rgb(255, 0, 0)");
|
||||
|
||||
const valueOnly = area(
|
||||
{},
|
||||
`<ColorArea value="#00ff00" default-value="#0000ff"><ColorAreaThumb /></ColorArea>`,
|
||||
);
|
||||
expect(thumbColor(valueOnly)).toBe("rgb(0, 255, 0)");
|
||||
|
||||
const disabled = area({ disabled: true, defaultValue: "#ff0000" });
|
||||
expect(root(disabled).attributes("data-disabled")).toBe("true");
|
||||
expect(x(disabled).element.disabled).toBe(true);
|
||||
});
|
||||
|
||||
it("re-infer axes when colorSpace and channel props change dynamically", async () => {
|
||||
const props = shallowRef<Record<string, unknown>>({
|
||||
defaultValue: "hsb(240, 50%, 50%)",
|
||||
colorSpace: "hsb",
|
||||
});
|
||||
const w = area(
|
||||
{},
|
||||
`<ColorArea v-bind="props"><ColorAreaThumb /></ColorArea>`,
|
||||
() => ({
|
||||
props,
|
||||
}),
|
||||
);
|
||||
expect(x(w).attributes("aria-label")).toBe("Hue");
|
||||
expect(y(w).attributes("aria-label")).toBe("Saturation");
|
||||
expect(x(w).element.value).toBe("240");
|
||||
|
||||
props.value = {
|
||||
defaultValue: "hsb(240, 50%, 50%)",
|
||||
colorSpace: "rgb",
|
||||
};
|
||||
await flushPromises();
|
||||
expect(x(w).attributes("aria-label")).toBe("Red");
|
||||
expect(y(w).attributes("aria-label")).toBe("Green");
|
||||
expect(x(w).attributes("max")).toBe("255");
|
||||
|
||||
props.value = {
|
||||
defaultValue: "hsb(240, 50%, 50%)",
|
||||
colorSpace: "rgb",
|
||||
xChannel: "green",
|
||||
yChannel: "blue",
|
||||
};
|
||||
await flushPromises();
|
||||
expect(x(w).attributes("aria-label")).toBe("Green");
|
||||
expect(y(w).attributes("aria-label")).toBe("Blue");
|
||||
expect(thumb(w).element.style.left).not.toBe("");
|
||||
|
||||
props.value = {
|
||||
defaultValue: "hsl(200, 50%, 50%)",
|
||||
colorSpace: "hsl",
|
||||
};
|
||||
await flushPromises();
|
||||
expect(x(w).attributes("aria-label")).toBe("Hue");
|
||||
expect(y(w).attributes("aria-label")).toBe("Saturation");
|
||||
expect(x(w).attributes("max")).toBe("360");
|
||||
});
|
||||
|
||||
it("keeps accepted alpha and fractional channel precision through keyboard changes", async () => {
|
||||
const value = parseColor("hsb(240,50.123%,50.567%,.321)");
|
||||
const w = area({
|
||||
defaultValue: value,
|
||||
xChannel: "saturation",
|
||||
yChannel: "brightness",
|
||||
});
|
||||
expect(x(w).element.value).toBe("50.123");
|
||||
await key(w, "ArrowUp", true, {}, "y");
|
||||
const proposal = emitted(w, "change")[0]![0] as Color;
|
||||
expect(proposal.getChannelValue("alpha")).toBe(0.321);
|
||||
expect(proposal.getChannelValue("saturation")).toBe(50.123);
|
||||
expect(proposal.getChannelValue("brightness")).toBeCloseTo(51.567);
|
||||
});
|
||||
|
||||
it("requires the thumb to be rendered inside the root", () => {
|
||||
expect(() =>
|
||||
render(
|
||||
defineComponent({
|
||||
components: { ColorAreaThumb },
|
||||
template: `<ColorAreaThumb />`,
|
||||
}),
|
||||
),
|
||||
).toThrow(/ColorAreaThumb must be rendered inside ColorArea/);
|
||||
});
|
||||
});
|
||||
@@ -171,9 +171,19 @@ describe("immutable private color value boundary", () => {
|
||||
});
|
||||
it("resolves legal space defaults and rejects duplicate/mismatched axes", () => {
|
||||
expect(colorAxes(parseColor("#f00"))).toMatchObject({
|
||||
space: "rgb",
|
||||
x: "red",
|
||||
y: "green",
|
||||
});
|
||||
expect(colorAxes(parseColor("hsl(200, 50%, 50%)"))).toMatchObject({
|
||||
space: "hsl",
|
||||
x: "hue",
|
||||
y: "saturation",
|
||||
});
|
||||
expect(colorAxes(parseColor("hsb(240, 50%, 50%)"))).toMatchObject({
|
||||
space: "hsb",
|
||||
x: "saturation",
|
||||
y: "brightness",
|
||||
x: "hue",
|
||||
y: "saturation",
|
||||
});
|
||||
expect(colorAxes(parseColor("#f00"), "rgb")).toMatchObject({
|
||||
x: "red",
|
||||
|
||||
@@ -90,6 +90,42 @@ for (const id of process.argv.slice(2)) {
|
||||
.base()
|
||||
.includes("hv-select--secondary"),
|
||||
);
|
||||
if (id === "color-area") {
|
||||
assert(lib.ColorArea === lib.ColorAreaRoot);
|
||||
assert(lib.ColorAreaThumb);
|
||||
assert(
|
||||
lib
|
||||
.colorAreaVariants({ showDots: true })
|
||||
.base()
|
||||
.includes("hv-color-area--show-dots"),
|
||||
);
|
||||
assert(
|
||||
lib.colorAreaVariants().thumb() === "hv-color-area__thumb",
|
||||
"ColorArea thumb class must stay in the baseline namespace",
|
||||
);
|
||||
const areaDts = readFileSync(
|
||||
new URL(
|
||||
"./node_modules/@heroui-vue/components/dist/components/color-area/ColorArea.vue.d.ts",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
const thumbDts = readFileSync(
|
||||
new URL(
|
||||
"./node_modules/@heroui-vue/components/dist/components/color-area/ColorAreaThumb.vue.d.ts",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
assert(
|
||||
!areaDts.includes("reka-ui"),
|
||||
"ColorArea declarations leak Reka types",
|
||||
);
|
||||
assert(
|
||||
!thumbDts.includes("reka-ui"),
|
||||
"ColorAreaThumb declarations leak Reka types",
|
||||
);
|
||||
}
|
||||
if (id === "color-swatch") {
|
||||
assert(lib.ColorSwatch === lib.ColorSwatchRoot);
|
||||
assert(
|
||||
|
||||
@@ -110,6 +110,23 @@
|
||||
".hv-calendar-year-picker__year-cell"
|
||||
]
|
||||
},
|
||||
"color-area": {
|
||||
"exports": [
|
||||
"ColorArea",
|
||||
"ColorAreaRoot",
|
||||
"ColorAreaThumb",
|
||||
"colorAreaVariants",
|
||||
"Color",
|
||||
"parseColor"
|
||||
],
|
||||
"css": [
|
||||
".hv-color-area",
|
||||
".hv-color-area--show-dots",
|
||||
".hv-color-area__thumb",
|
||||
"--color-area-background",
|
||||
"--color-area-thumb-color"
|
||||
]
|
||||
},
|
||||
"color-field-protocol": {
|
||||
"exports": [],
|
||||
"css": [
|
||||
@@ -120,24 +137,12 @@
|
||||
".hv-color-input-group__prefix",
|
||||
".hv-color-input-group__suffix"
|
||||
],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
"absent": ["ColorSlider", "ColorField", "ColorInputGroup", "ColorPicker"]
|
||||
},
|
||||
"color-foundation": {
|
||||
"exports": [],
|
||||
"css": [".hv-color-area", ".hv-color-area__thumb"],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
"absent": ["ColorSlider", "ColorField", "ColorInputGroup", "ColorPicker"]
|
||||
},
|
||||
"color-picker-protocol": {
|
||||
"exports": [],
|
||||
@@ -146,13 +151,7 @@
|
||||
".hv-color-picker__trigger",
|
||||
".hv-color-picker__popover"
|
||||
],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
"absent": ["ColorSlider", "ColorField", "ColorInputGroup", "ColorPicker"]
|
||||
},
|
||||
"color-slider-foundation": {
|
||||
"exports": [],
|
||||
@@ -166,13 +165,7 @@
|
||||
"max-height:inherit",
|
||||
"overscroll-behavior:contain"
|
||||
],
|
||||
"absent": [
|
||||
"ColorArea",
|
||||
"ColorSlider",
|
||||
"ColorField",
|
||||
"ColorInputGroup",
|
||||
"ColorPicker"
|
||||
]
|
||||
"absent": ["ColorSlider", "ColorField", "ColorInputGroup", "ColorPicker"]
|
||||
},
|
||||
"date-field": {
|
||||
"exports": [
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import {
|
||||
ColorArea,
|
||||
ColorAreaRoot,
|
||||
ColorAreaThumb,
|
||||
colorAreaVariants,
|
||||
parseColor,
|
||||
type Color,
|
||||
type ColorAreaExpose,
|
||||
type ColorAreaProps,
|
||||
type ColorAreaRenderProps,
|
||||
type ColorAreaRootProps,
|
||||
type ColorAreaSlots,
|
||||
type ColorAreaStyle,
|
||||
type ColorAreaStyleFn,
|
||||
type ColorAreaThumbProps,
|
||||
type ColorAreaThumbRenderProps,
|
||||
type ColorAreaThumbStyle,
|
||||
type ColorAreaThumbStyleFn,
|
||||
type ColorAreaVariants,
|
||||
type ColorAxisChannel,
|
||||
type ColorSpace,
|
||||
type ColorValue,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const color = parseColor("#9B80FF");
|
||||
const value: ColorValue = color;
|
||||
const axis: ColorAxisChannel = "saturation";
|
||||
const space: ColorSpace = "hsb";
|
||||
const style: ColorAreaStyle = { outline: "1px solid black" };
|
||||
const styleFn: ColorAreaStyleFn = ({ color: current }) => ({
|
||||
outline: `1px solid ${current.toString("hex")}`,
|
||||
});
|
||||
const styleRender: ColorAreaStyle = ({ color: current }) => ({
|
||||
background: current.toString("css"),
|
||||
});
|
||||
const thumbStyle: ColorAreaThumbStyle = ({ percent }) => ({
|
||||
opacity: percent.x,
|
||||
});
|
||||
const thumbStyleFn: ColorAreaThumbStyleFn = ({ isDragging }) => ({
|
||||
width: isDragging ? "20px" : "16px",
|
||||
});
|
||||
const props: ColorAreaProps = {
|
||||
modelValue: color,
|
||||
value,
|
||||
defaultValue: "hsb(240, 50%, 50%)",
|
||||
colorSpace: space,
|
||||
xChannel: "hue",
|
||||
yChannel: axis,
|
||||
xName: "hue",
|
||||
yName: "saturation",
|
||||
form: "color-form",
|
||||
isDisabled: false,
|
||||
disabled: false,
|
||||
isReadOnly: false,
|
||||
showDots: true,
|
||||
locale: "zh-CN",
|
||||
dir: "rtl",
|
||||
as: "div",
|
||||
asChild: false,
|
||||
style,
|
||||
styleFn,
|
||||
};
|
||||
const rootProps: ColorAreaRootProps = props;
|
||||
const thumbProps: ColorAreaThumbProps = {
|
||||
as: "span",
|
||||
style: thumbStyle,
|
||||
styleFn: thumbStyleFn,
|
||||
};
|
||||
const slots: ColorAreaSlots = { default: () => null };
|
||||
const variants: ColorAreaVariants = { showDots: true };
|
||||
const render: ColorAreaRenderProps = {
|
||||
color,
|
||||
space: "hsb",
|
||||
x: "hue",
|
||||
y: "saturation",
|
||||
};
|
||||
const thumbRender: ColorAreaThumbRenderProps = {
|
||||
...render,
|
||||
percent: { x: 1, y: 0 },
|
||||
isDragging: false,
|
||||
isDisabled: false,
|
||||
isReadOnly: false,
|
||||
};
|
||||
const exposed: ColorAreaExpose = { element: null, color: null };
|
||||
const typedColor: Color = parseColor("rgb(1, 2, 3)");
|
||||
|
||||
// @ts-expect-error alpha is not a two-dimensional axis
|
||||
const badAxis: ColorAxisChannel = "alpha";
|
||||
// @ts-expect-error the public space set is rgb | hsl | hsb
|
||||
const badSpace: ColorSpace = "lab";
|
||||
// @ts-expect-error showDots only accepts a boolean
|
||||
const badVariant: ColorAreaVariants = { showDots: "yes" };
|
||||
// @ts-expect-error xChannel is a channel name, not an index
|
||||
const badProps: ColorAreaProps = { xChannel: 1 };
|
||||
const badRender: ColorAreaRenderProps = {
|
||||
// @ts-expect-error render props require a Color instance
|
||||
color: "#fff",
|
||||
space: "rgb",
|
||||
x: "red",
|
||||
y: "green",
|
||||
};
|
||||
const badThumb: ColorAreaThumbRenderProps = {
|
||||
...render,
|
||||
// @ts-expect-error the thumb exposes percent, not raw pixel coordinates
|
||||
percent: 1,
|
||||
isDragging: false,
|
||||
isDisabled: false,
|
||||
isReadOnly: false,
|
||||
};
|
||||
|
||||
void [
|
||||
ColorArea,
|
||||
ColorAreaRoot,
|
||||
ColorAreaThumb,
|
||||
colorAreaVariants,
|
||||
value,
|
||||
axis,
|
||||
space,
|
||||
styleRender,
|
||||
props,
|
||||
rootProps,
|
||||
thumbProps,
|
||||
slots,
|
||||
variants,
|
||||
render,
|
||||
thumbRender,
|
||||
exposed,
|
||||
typedColor,
|
||||
badAxis,
|
||||
badSpace,
|
||||
badVariant,
|
||||
badProps,
|
||||
badRender,
|
||||
badThumb,
|
||||
];
|
||||
Reference in New Issue
Block a user