fix: enforce handbook scrollbar and reduced motion contracts
This commit is contained in:
@@ -3,6 +3,11 @@ import { defineAsyncComponent } from "vue";
|
|||||||
|
|
||||||
// Keep regression URLs stable; load only the selected harness.
|
// Keep regression URLs stable; load only the selected harness.
|
||||||
const labs = [
|
const labs = [
|
||||||
|
{
|
||||||
|
key: "handbook",
|
||||||
|
title: "Handbook 实现规范",
|
||||||
|
component: defineAsyncComponent(() => import("./HandbookLab.vue")),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "color-field-protocol",
|
key: "color-field-protocol",
|
||||||
title: "颜色字段与 Picker",
|
title: "颜色字段与 Picker",
|
||||||
|
|||||||
@@ -0,0 +1,397 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { nextTick, onBeforeUnmount, ref } from "vue";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Input,
|
||||||
|
Spinner,
|
||||||
|
Skeleton,
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverDialog,
|
||||||
|
PopoverHeading,
|
||||||
|
Table,
|
||||||
|
TableScrollContainer,
|
||||||
|
TableContent,
|
||||||
|
TableHeader,
|
||||||
|
TableColumn,
|
||||||
|
TableBody,
|
||||||
|
TableRow,
|
||||||
|
TableCell,
|
||||||
|
} from "@heroui-vue/components";
|
||||||
|
import { buttonVariants, tv } from "@heroui-vue/styles";
|
||||||
|
|
||||||
|
const root = ref<HTMLElement>();
|
||||||
|
const local = ref<HTMLElement>();
|
||||||
|
const open = ref(false);
|
||||||
|
const reduced = ref(false);
|
||||||
|
const mode = ref("light");
|
||||||
|
const scrollMode = ref("none");
|
||||||
|
const clicks = ref(0);
|
||||||
|
const records = ref<string[]>([]);
|
||||||
|
const running = ref(false);
|
||||||
|
const surfaces = [
|
||||||
|
"hv-popover",
|
||||||
|
"hv-tooltip",
|
||||||
|
"hv-dropdown__popover",
|
||||||
|
"hv-select__popover",
|
||||||
|
"hv-combo-box__popover",
|
||||||
|
"hv-autocomplete__popover",
|
||||||
|
"hv-date-picker__popover",
|
||||||
|
"hv-date-range-picker__popover",
|
||||||
|
"hv-drawer__dialog",
|
||||||
|
"hv-drawer__backdrop",
|
||||||
|
];
|
||||||
|
const custom = tv({
|
||||||
|
extend: buttonVariants,
|
||||||
|
variants: { audit: { true: "audit-extra" } },
|
||||||
|
});
|
||||||
|
const frame = () =>
|
||||||
|
new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
|
||||||
|
const wait = (ms: number) =>
|
||||||
|
new Promise<void>((resolve) => setTimeout(resolve, ms));
|
||||||
|
function record(name: string, pass: boolean, detail: unknown) {
|
||||||
|
records.value.push(
|
||||||
|
`${pass ? "PASS" : "FAIL"} ${name}: ${JSON.stringify(detail)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function style(selector: string) {
|
||||||
|
return getComputedStyle(document.querySelector<HTMLElement>(selector)!);
|
||||||
|
}
|
||||||
|
// All changes are confined to this regression subtree; no saved user preferences.
|
||||||
|
async function inspect() {
|
||||||
|
if (running.value) return;
|
||||||
|
running.value = true;
|
||||||
|
records.value = [];
|
||||||
|
try {
|
||||||
|
mode.value = "light";
|
||||||
|
reduced.value = true;
|
||||||
|
await nextTick();
|
||||||
|
await frame();
|
||||||
|
const token = document.createElement("span");
|
||||||
|
token.style.color = "var(--accent)";
|
||||||
|
local.value!.append(token);
|
||||||
|
const accent = getComputedStyle(token).color;
|
||||||
|
const before = style("#audit-input").backgroundColor;
|
||||||
|
record(
|
||||||
|
"semantic button accent",
|
||||||
|
style("#audit-button").backgroundColor === accent,
|
||||||
|
{ accent, button: style("#audit-button").backgroundColor },
|
||||||
|
);
|
||||||
|
mode.value = "dark";
|
||||||
|
await nextTick();
|
||||||
|
await frame();
|
||||||
|
record(
|
||||||
|
"field follows dark theme",
|
||||||
|
before !== style("#audit-input").backgroundColor,
|
||||||
|
{ light: before, dark: style("#audit-input").backgroundColor },
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
"reduced spinner",
|
||||||
|
style("#audit-spinner").animationName === "none",
|
||||||
|
style("#audit-spinner").animationName,
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
"reduced button transition",
|
||||||
|
style("#audit-button").transitionProperty === "none",
|
||||||
|
style("#audit-button").transitionProperty,
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
"reduced skeleton shimmer",
|
||||||
|
getComputedStyle(document.querySelector("#audit-skeleton")!, "::after")
|
||||||
|
.animationName === "none",
|
||||||
|
getComputedStyle(document.querySelector("#audit-skeleton")!, "::after")
|
||||||
|
.animationName,
|
||||||
|
);
|
||||||
|
for (const [id, pseudo] of [
|
||||||
|
["#audit-skeleton-pulse", null],
|
||||||
|
["#audit-skeleton-parent", "::before"],
|
||||||
|
] as const) {
|
||||||
|
const animation = getComputedStyle(
|
||||||
|
document.querySelector(id)!,
|
||||||
|
pseudo,
|
||||||
|
).animationName;
|
||||||
|
record(`reduced skeleton ${id}`, animation === "none", animation);
|
||||||
|
}
|
||||||
|
const motionRules = Array.from(
|
||||||
|
document.querySelectorAll<HTMLElement>("[data-motion-probe]"),
|
||||||
|
).map((el) => ({
|
||||||
|
surface: el.className,
|
||||||
|
phase: el.dataset.motionProbe,
|
||||||
|
animation: getComputedStyle(el).animationName,
|
||||||
|
}));
|
||||||
|
record(
|
||||||
|
"all 20 BEM entrance/exit rules reduce motion",
|
||||||
|
motionRules.length === 20 &&
|
||||||
|
motionRules.every((item) => item.animation === "none"),
|
||||||
|
{
|
||||||
|
checked: motionRules.length,
|
||||||
|
failures: motionRules.filter((item) => item.animation !== "none"),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const composed = document.querySelector<HTMLElement>("#audit-composed")!;
|
||||||
|
const prior = clicks.value;
|
||||||
|
composed.click();
|
||||||
|
await nextTick();
|
||||||
|
record(
|
||||||
|
"asChild merges root and handlers once",
|
||||||
|
composed.tagName === "BUTTON" &&
|
||||||
|
composed.classList.contains("hv-button") &&
|
||||||
|
clicks.value === prior + 2,
|
||||||
|
{
|
||||||
|
tag: composed.tagName,
|
||||||
|
clicks: clicks.value - prior,
|
||||||
|
class: composed.className,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
"inline style and extended variants",
|
||||||
|
style("#audit-composed").borderTopWidth === "3px" &&
|
||||||
|
composed.classList.contains("audit-extra"),
|
||||||
|
{ border: style("#audit-composed").borderTopWidth },
|
||||||
|
);
|
||||||
|
for (const value of ["none", "default", "thin"]) {
|
||||||
|
scrollMode.value = value;
|
||||||
|
await nextTick();
|
||||||
|
await frame();
|
||||||
|
const expected = value === "default" ? "auto" : value;
|
||||||
|
record(
|
||||||
|
`scrollbar subtree ${value}`,
|
||||||
|
style("#audit-scroll").scrollbarWidth === expected,
|
||||||
|
style("#audit-scroll").scrollbarWidth,
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
`nested scrollbar overrides ${value}`,
|
||||||
|
style("#audit-inner-scroll").scrollbarWidth === "thin",
|
||||||
|
style("#audit-inner-scroll").scrollbarWidth,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
record(
|
||||||
|
"nested scrollbar overrides parent",
|
||||||
|
style("#audit-inner-scroll").scrollbarWidth === "thin",
|
||||||
|
style("#audit-inner-scroll").scrollbarWidth,
|
||||||
|
);
|
||||||
|
reduced.value = false;
|
||||||
|
await nextTick();
|
||||||
|
await frame();
|
||||||
|
const normalRules = Array.from(
|
||||||
|
document.querySelectorAll<HTMLElement>("[data-motion-probe]"),
|
||||||
|
).map((el) => getComputedStyle(el).animationName);
|
||||||
|
record(
|
||||||
|
"normal BEM animations retained",
|
||||||
|
normalRules.length === 20 && normalRules.every((name) => name !== "none"),
|
||||||
|
{ checked: normalRules.length },
|
||||||
|
);
|
||||||
|
open.value = true;
|
||||||
|
await nextTick();
|
||||||
|
await frame();
|
||||||
|
await frame();
|
||||||
|
const panel = document.querySelector<HTMLElement>("#audit-popover")!;
|
||||||
|
record(
|
||||||
|
"local portal theme",
|
||||||
|
panel &&
|
||||||
|
getComputedStyle(panel).getPropertyValue("--accent").trim() ===
|
||||||
|
getComputedStyle(local.value!).getPropertyValue("--accent").trim(),
|
||||||
|
{
|
||||||
|
parent: panel?.parentElement?.tagName,
|
||||||
|
accent:
|
||||||
|
panel && getComputedStyle(panel).getPropertyValue("--accent").trim(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
"popover visible and focused",
|
||||||
|
!!panel &&
|
||||||
|
panel.getBoundingClientRect().width > 0 &&
|
||||||
|
panel.contains(document.activeElement),
|
||||||
|
{
|
||||||
|
width: panel?.getBoundingClientRect().width,
|
||||||
|
focus: document.activeElement?.getAttribute("data-slot"),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
reduced.value = true;
|
||||||
|
await nextTick();
|
||||||
|
await frame();
|
||||||
|
await frame();
|
||||||
|
record(
|
||||||
|
"dynamic reduced motion clears entering",
|
||||||
|
!panel.hasAttribute("data-entering") &&
|
||||||
|
getComputedStyle(panel).animationName === "none",
|
||||||
|
{
|
||||||
|
entering: panel.dataset.entering,
|
||||||
|
animation: getComputedStyle(panel).animationName,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
open.value = false;
|
||||||
|
await nextTick();
|
||||||
|
await wait(70);
|
||||||
|
record(
|
||||||
|
"reduced exit unmounts",
|
||||||
|
!document.querySelector("#audit-popover"),
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
reduced.value = false;
|
||||||
|
await nextTick();
|
||||||
|
open.value = true;
|
||||||
|
await nextTick();
|
||||||
|
await wait(230);
|
||||||
|
open.value = false;
|
||||||
|
await nextTick();
|
||||||
|
await frame();
|
||||||
|
const exiting = document.querySelector<HTMLElement>("#audit-popover");
|
||||||
|
record(
|
||||||
|
"animated exit retained",
|
||||||
|
!!exiting && exiting.dataset.exiting === "true",
|
||||||
|
{ exiting: exiting?.dataset.exiting },
|
||||||
|
);
|
||||||
|
await wait(250);
|
||||||
|
record(
|
||||||
|
"animated exit unmounts",
|
||||||
|
!document.querySelector("#audit-popover"),
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
record(
|
||||||
|
"focus restores to trigger",
|
||||||
|
document.activeElement?.hasAttribute("data-audit-trigger") === true,
|
||||||
|
document.activeElement?.id,
|
||||||
|
);
|
||||||
|
token.remove();
|
||||||
|
} catch (error) {
|
||||||
|
record("scenario exception", false, String(error));
|
||||||
|
} finally {
|
||||||
|
running.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
open.value = false;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main
|
||||||
|
ref="root"
|
||||||
|
class="handbook-lab"
|
||||||
|
:data-reduce-motion="reduced ? 'true' : undefined"
|
||||||
|
>
|
||||||
|
<h1>Handbook 实现回归</h1>
|
||||||
|
<p>检查公开组件最终样式与行为;仅修改此测试子树,不保存主题偏好。</p>
|
||||||
|
<Button :is-disabled="running" @click="inspect">运行规范检查</Button>
|
||||||
|
<label>
|
||||||
|
<input v-model="reduced" type="checkbox" />
|
||||||
|
减少动效
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
局部主题
|
||||||
|
<select v-model="mode">
|
||||||
|
<option>light</option>
|
||||||
|
<option>dark</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<section ref="local" :class="mode" class="audit-theme">
|
||||||
|
<Card class="audit-card"><p>语义表面</p></Card>
|
||||||
|
<Button id="audit-button">语义强调色</Button>
|
||||||
|
<Input
|
||||||
|
id="audit-input"
|
||||||
|
aria-label="规范字段"
|
||||||
|
placeholder="键盘焦点检查"
|
||||||
|
/>
|
||||||
|
<Spinner id="audit-spinner" aria-label="规范加载" />
|
||||||
|
<Skeleton id="audit-skeleton" style="width: 100px; height: 20px" />
|
||||||
|
<Skeleton
|
||||||
|
id="audit-skeleton-pulse"
|
||||||
|
animation-type="pulse"
|
||||||
|
style="width: 100px; height: 20px"
|
||||||
|
/>
|
||||||
|
<Skeleton id="audit-skeleton-parent">
|
||||||
|
<Skeleton style="width: 100px; height: 20px" />
|
||||||
|
</Skeleton>
|
||||||
|
<Button
|
||||||
|
as-child
|
||||||
|
:class="custom({ audit: true })"
|
||||||
|
style="border: 3px solid currentColor"
|
||||||
|
@click="clicks++"
|
||||||
|
>
|
||||||
|
<button id="audit-composed" @click="clicks++">
|
||||||
|
组合按钮 {{ clicks }}
|
||||||
|
</button>
|
||||||
|
</Button>
|
||||||
|
<div :data-scrollbar="scrollMode">
|
||||||
|
<Table>
|
||||||
|
<TableScrollContainer id="audit-scroll" class="audit-scroll">
|
||||||
|
<TableContent aria-label="滚动条规范">
|
||||||
|
<TableHeader><TableColumn>内容</TableColumn></TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
<TableRow v-for="n in 12" :key="n" :row-key="n">
|
||||||
|
<TableCell>滚动内容 {{ n }}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</TableContent>
|
||||||
|
</TableScrollContainer>
|
||||||
|
</Table>
|
||||||
|
<div data-scrollbar="thin">
|
||||||
|
<Table>
|
||||||
|
<TableScrollContainer id="audit-inner-scroll" class="audit-scroll">
|
||||||
|
<TableContent aria-label="嵌套滚动条">
|
||||||
|
<TableHeader><TableColumn>内容</TableColumn></TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
<TableRow v-for="n in 12" :key="n" :row-key="n">
|
||||||
|
<TableCell>嵌套内容 {{ n }}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</TableContent>
|
||||||
|
</TableScrollContainer>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Popover v-model:open="open">
|
||||||
|
<Button data-audit-trigger>规范弹层</Button>
|
||||||
|
<PopoverContent id="audit-popover" :to="local">
|
||||||
|
<PopoverDialog>
|
||||||
|
<PopoverHeading>局部主题弹层</PopoverHeading>
|
||||||
|
<Button @click="open = false">关闭规范弹层</Button>
|
||||||
|
</PopoverDialog>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</section>
|
||||||
|
<!-- Raw BEM use is a public Handbook contract. These probes verify CSS only;
|
||||||
|
Popover above separately verifies the actual component lifecycle. -->
|
||||||
|
<div hidden aria-hidden="true">
|
||||||
|
<template v-for="surface in surfaces" :key="surface">
|
||||||
|
<div
|
||||||
|
v-for="phase in ['entering', 'exiting']"
|
||||||
|
:key="phase"
|
||||||
|
:class="surface"
|
||||||
|
:data-motion-probe="phase"
|
||||||
|
:data-entering="phase === 'entering' ? 'true' : undefined"
|
||||||
|
:data-exiting="phase === 'exiting' ? 'true' : undefined"
|
||||||
|
data-placement="bottom"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<pre aria-live="polite" id="audit-results">{{ records.join("\n") }}</pre>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.handbook-lab {
|
||||||
|
padding: 24px;
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
.audit-theme {
|
||||||
|
--accent: oklch(0.62 0.2 300);
|
||||||
|
padding: 20px;
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
background: var(--background);
|
||||||
|
color: var(--foreground);
|
||||||
|
}
|
||||||
|
.audit-scroll {
|
||||||
|
height: 72px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
pre {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -284,3 +284,7 @@ ComboBox/Autocomplete的正式组合、原30项返修和本轮定位/ref/ARIA/lo
|
|||||||
## FORM 正式迁移(2026-10-27)
|
## FORM 正式迁移(2026-10-27)
|
||||||
|
|
||||||
复用已有字段/FormData/reset协议,公开FormRoot及Props/实例/插槽类型;固定源中文3例与正式文档已接入。新增表单级invalid通知、取消默认焦点、外部form关联控件检查,避免重复invalid与后续组合字段抢焦点;choice共享适配与Switch尊重已取消事件。源Form无专用CSS,不新增variants或样式。具体范围/验证见 [FORM结果](tasks/results/FORM.md)。
|
复用已有字段/FormData/reset协议,公开FormRoot及Props/实例/插槽类型;固定源中文3例与正式文档已接入。新增表单级invalid通知、取消默认焦点、外部form关联控件检查,避免重复invalid与后续组合字段抢焦点;choice共享适配与Switch尊重已取消事件。源Form无专用CSS,不新增variants或样式。具体范围/验证见 [FORM结果](tasks/results/FORM.md)。
|
||||||
|
|
||||||
|
## Handbook 共享规范审计(2026-10-27)
|
||||||
|
|
||||||
|
固定源六篇56章节的实现证据与差异见 [Handbook审计](handbook-audit.md)。修复 data-scrollbar 三模式、八类浮层/Skeleton/Drawer 的减少动效与动态取消动画后的进入标记清理。按需 CSS 子路径、公共 useTheme、局部主题自动跨 Teleport 及 Skeleton 动画变量的局部/动态读取仍未提供;不声明所有组件已完成全部规范的浏览器验收。逐项场景与实际验证见 [任务结果](tasks/results/HANDBOOK-IMPLEMENTATION-AUDIT.md)。
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# Handbook 规范实现审计
|
||||||
|
|
||||||
|
2026-10-27;代码起点 `a9bfc71c8a34d2743d2f76f07a0e6355663115c8`。只对照 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960` 的中文 React Handbook 六篇(共 56 个二级章节),不追逐线上新文档。
|
||||||
|
|
||||||
|
## 结论与证据边界
|
||||||
|
|
||||||
|
组件不是没有应用规范:已移植语义变量、BEM、变体与大量状态选择器。但不能把“已有源码”写成“所有组件已验证”。本轮发现并修复了滚动条模式缺失、多个浮层和 Skeleton 减少动效遗漏,以及动态取消动画后进入状态未清理的问题;按需样式分入口、公共主题控制 API 等仍存在差异。
|
||||||
|
|
||||||
|
- **B1 真实组件浏览器**:`apps/playground/src/HandbookLab.vue`,开发入口 `http://127.0.0.1:5174/?handbook`,点击“运行规范检查”。Button 的强调色、Input 的浅深色、Button/Spinner/Skeleton 减少动效、TableScrollContainer 的三模式及嵌套覆盖、Button asChild 的 class/style/双端监听合并、Popover 的局部主题/可见焦点/动态取消/退出保留与卸载/焦点恢复。不是全库全状态矩阵。
|
||||||
|
- **B2 BEM 浏览器**:同页用普通 HTML 应用 10 类浮层 BEM × 进入/退出 = 20 条最终 CSS 规则,检查 `animationName === 'none'`。这是 Handbook“直接应用类名”的样式契约证据,不代表 10 类组件均完成生命周期验收。
|
||||||
|
- **U1 单测**:`tests/overlay-foundation.test.ts` 新用例在旧 animation.ts 上反证失败,在修复后通过;模拟 CSS 结果,只验证观察/清理协议,不用 jsdom 证明实际 CSS。
|
||||||
|
- **P1 独立包**:`node scripts/check-package.mjs handbook-styles`,检查最终 tarball ESM、CSS 模式选择器、tv 扩展与 bundler/NodeNext 正反类型。CSS 字符串只证明包装存在,效果由 B1/B2 验证。
|
||||||
|
- **S1 源码核对**:`packages/styles/themes/{default/variables,shared/theme}.css`、`packages/styles/{components,utilities,variants}`、`packages/styles/src/index.ts`、`packages/vue/src/components`。下面标为“源码支持”的条目未升级为全组件浏览器通过。
|
||||||
|
- **S2 API/导出核对**:`packages/{styles,vue}/package.json`、`packages/vue/src/index.ts`、组件 Props/作用域插槽;主题切换另见 `apps/docs/.vitepress/theme/DocsThemeSwitch.vue`。
|
||||||
|
|
||||||
|
本轮浏览器是桌面 Chromium/IAB、系统减少动效为 false;实际验证显式 `data-reduce-motion`。系统媒体查询分支在源码存在,本轮未改变操作系统设置,也未宣称完成所有浏览器/系统偏好矩阵。当前客户端边界不变,未运行 SSR/水合/Nuxt、逐像素或读屏专项。
|
||||||
|
|
||||||
|
## 发现与处置
|
||||||
|
|
||||||
|
| 编号 | 问题、影响 | 处置 / 实际边界 |
|
||||||
|
| ---- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| H01 | 缺官方 base/scrollbar.css;data-scrollbar none/default 在实际滚动区仍为 thin | 移植模式变量规则,在主题默认值之后导入;B1 的 Table 三模式和嵌套覆盖验证 |
|
||||||
|
| H02 | Popover/Tooltip/Dropdown/Select/ComboBox/Autocomplete/DatePicker/DateRangePicker 进出场块没有减少动画覆盖 | 各自原有状态块补 motion-reduce:animate-none/transition-none;B2 验证全部 16 条,Popover 另有 B1 生命周期验证 |
|
||||||
|
| H03 | Drawer 方向动画只有系统媒体查询覆盖,不支持显式 data-reduce-motion | 使用共享 motion-reduce 变体且保留方向规则所需优先级;B2 验证 dialog/backdrop 共 4 条 |
|
||||||
|
| H04 | Skeleton shimmer/pulse 没有减少动效覆盖,伪元素继续循环 | 根类使用共享变体,同时覆盖 ::before/::after;B1 已实测独立 shimmer、pulse 和父容器同步 shimmer |
|
||||||
|
| H05 | 浮层进入时祖先切换减少动效,动画无 animationend,data-entering 可能残留 | 共享动画观察祖先属性及 animationcancel;U1 反证 + B1 动态切换 |
|
||||||
|
| H06 | 样式包只输出整包预编译 CSS 和 JS 根入口 | 差异保留;不支持官方 base/themes/components/utilities/variants 的 CSS 子路径,也没有可供消费者直接 import 的源 @theme 入口。消费者自有 Tailwind 主题配置不能靠导入已编译 CSS 自动获得 |
|
||||||
|
| H07 | 文档站有三模式主题切换,组件包未导出 useTheme | 差异保留;消费者当前用 VueUse/应用逻辑设置 class/data-theme。不能将文档站功能写成公共库 API |
|
||||||
|
| H08 | body Teleport 不会自动继承触发器局部主题/减少动效/滚动条变量 | CSS DOM 继承边界,不能承诺自动传递;全局设置放 html,局部 Popover 使用 to 指向该主题容器(B1)。各组件的 portal/ConfigProvider 能力以实际 API 为准,不强行建立第二套主题状态源 |
|
||||||
|
| H09 | React className/style 函数、render、复合对象导出不能原样照搬 | Vue class/style、作用域插槽、as/asChild、具名部件;支持范围逐组件不同。例如 Button 暴露状态插槽,Input 没有通用状态插槽。不能写“所有组件都接受相同的函数属性” |
|
||||||
|
|
||||||
|
未把同名变量数量、CSS 文件数量或历史全量测试数作为实现完整率。ScrollShadow 的滚动时间线用于计算静态遮罩,不是时间驱动的装饰动画;本轮未一刀切删除该能力。
|
||||||
|
|
||||||
|
## 逐节清单:颜色(15)
|
||||||
|
|
||||||
|
来源 `apps/docs/content/docs/cn/react/getting-started/(handbook)/colors.mdx`。
|
||||||
|
|
||||||
|
| 官方二级章节 | 实现判断与证据 |
|
||||||
|
| -------------- | ------------------------------------------------------------------------------------------------- |
|
||||||
|
| 强调色 | 语义及 hover/soft 派生已有 S1;Button 实际 --accent 覆盖 B1;非所有状态逐一实测 |
|
||||||
|
| 默认(中性色) | --default、foreground、hover/soft 已有 S1;组件使用变体变量;全部消费路径未逐个实测 |
|
||||||
|
| 成功 | success/foreground/hover/soft 已有 S1;Alert/Chip 等使用,未做全状态视觉验收 |
|
||||||
|
| 警告 | warning 浅深值/派生已有 S1;未做全状态视觉验收 |
|
||||||
|
| 危险 | danger 浅深值/派生与 invalid-field-ring 已有 S1;相关行为保留既有测试,本轮不宣称新视觉验收 |
|
||||||
|
| 前景色 | foreground/muted/配对前景色已有 S1;局部主题继承可行,B1 抽验 |
|
||||||
|
| 背景色 | background/secondary/tertiary/inverse 已有 S1;局部容器 B1 |
|
||||||
|
| 表面色 | surface 三层及 overlay 分离已有 S1;Card/Popover 使用源码,Popover 局部 B1 |
|
||||||
|
| 表单字段 | field 背景/前景/placeholder/边框/hover/focus 已有 S1;Input 浅深切换 B1 |
|
||||||
|
| 分隔线 | separator/border 及层次派生已有 S1;未逐组件实测 |
|
||||||
|
| 其他 | focus/link/segment/backdrop 等已有 S1;不代表任意工具类自动对消费者可用(H06) |
|
||||||
|
| 基础色 | white/black/snow/eclipse 已有 S1;与模式无关 |
|
||||||
|
| 如何使用颜色 | 原生 CSS var 可用 B1;语义 Tailwind 工具在库构建内可用,消费者构建接入有 H06 差异 |
|
||||||
|
| 默认主题 | 固定变量已移植 S1,明暗解析 B1;需显式主题 DOM,不能把工具类媒体回退等同于全部 token 自动跟系统 |
|
||||||
|
| 自定义颜色 | 覆盖现有 token 可用 B1;新增 token 到 Tailwind 的 @theme 注册需消费者配置,未提供源主题包入口 H06 |
|
||||||
|
|
||||||
|
## 逐节清单:主题(8)
|
||||||
|
|
||||||
|
| 官方二级章节 | 实现判断与证据 |
|
||||||
|
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| 工作原理 | CSS 自定义属性、Tailwind 4 内部构建与分层已有 S1;发布策略不同 H06 |
|
||||||
|
| 快速开始 | 整包 CSS + class/data-theme 可用 B1/P1;浅深/品牌容器需重算派生变量,不能只在无主题标记祖先改基础色就承诺派生同步 |
|
||||||
|
| 自定义组件 | hv- BEM、class/style、CSS 层覆盖可用;B1 透传与边框,组件库不提供官方无前缀类名 |
|
||||||
|
| 导入策略 | 部分实现:只有整包 CSS;源样式、按组件/主题/基础层等策略不支持 H06 |
|
||||||
|
| 添加自定义颜色 | CSS 属性边界可行;新增 Tailwind 映射需消费者配置 H06 |
|
||||||
|
| 变量参考 | 原始/语义/派生变量及圆角、阴影、间距已有 S1;Skeleton --skeleton-animation 当前从 documentElement 挂载时读取,不支持局部/动态变量切换,不能按全局响应式配置承诺 |
|
||||||
|
| 滚动条 | H01 已修;真实 Table、嵌套控制 B1,CSS utilities 源入口仍 H06 |
|
||||||
|
| 资源 | 文档链接迁移待后续文稿任务,不构成运行时能力 |
|
||||||
|
|
||||||
|
## 逐节清单:样式(11)
|
||||||
|
|
||||||
|
| 官方二级章节 | 实现判断与证据 |
|
||||||
|
| -------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| 基础样式 | Vue class 字符串/数组/对象和 style,通过 attrs 落到组件 DOM;Button asChild B1,其他组件不能由此全部推断 |
|
||||||
|
| 滚动条 | 同 H01/B1;库滚动槽 @apply scrollbar 存在,消费者 raw utility 不因预编译包自动生成 H06 |
|
||||||
|
| 基于状态的样式 | Button 的 hovered/pressed/focused/focus-visible/pending 已映射;部分控件依赖原生伪类/Reka 状态,无统一 data-* 全集承诺 S1 |
|
||||||
|
| 渲染属性 | Vue 状态插槽替代,组件范围不同 H09;动态 class 放实际插槽节点或外部状态,不传 React 函数给 class |
|
||||||
|
| BEM 类名 | 已有 hv- 命名空间;B2 直接应用浮层状态类,P1 保留最终 CSS |
|
||||||
|
| 创建包装组件 | tv/VariantProps 与原组件组合已有;B1 实际扩展,P1 产物及类型,包装组件还须自行透传 attrs/插槽/ref |
|
||||||
|
| CSS-in-JS 集成 | class/style 边界可用;没有验证 styled-components/Emotion 的 React 专属绑定,不声明官方示例可直接运行 |
|
||||||
|
| 响应式设计 | 源 md/sm 与媒体规则已移植 S1;应用自定义工具需自行配置 Tailwind,未完成全库窄屏矩阵 |
|
||||||
|
| CSS 模块 | Vue $style/class 机制适用;本轮未建立 CSS Modules 独立消费者场景,不记为已验收 |
|
||||||
|
| 组件类名参考 | 真实命名源在 packages/styles/components;本地组件页参考,不保证未逐项核对的表格无遗漏 |
|
||||||
|
| 下一步 | 文稿导航任务,后续补齐指向 Vue 指南 |
|
||||||
|
|
||||||
|
## 逐节清单:动画(7)
|
||||||
|
|
||||||
|
| 官方二级章节 | 实现判断与证据 |
|
||||||
|
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| 内置动画 | 已有状态/定位原点/Presence 卸载;Popover 正常退出保留、卸载和恢复 B1;不能用一个组件证明全部弹层 |
|
||||||
|
| CSS 动画 | 内部 tw-animate-css 已打包;消费者自定义工具类仍依赖自己的编译配置 H06;B2 验证最终关键帧规则覆盖 |
|
||||||
|
| Framer Motion | React 专属库,不复制;Vue CSS/Transition 或消费者选择的 Vue 动画库是框架适配方向,本轮不增加依赖、不声称已集成第三方库 |
|
||||||
|
| 渲染属性 | 作用域插槽/asChild 替代 H09;B1 验证实际节点与监听保留,外部动画库与 ref 需单独验证 |
|
||||||
|
| 无障碍 | H02–H05 修复,B1/B2/U1;系统 reduce 分支存在但本轮只实测显式属性,body Portal 须遵守 H08 |
|
||||||
|
| 性能技巧 | 源有 transform/opacity/will-change 等;是编码指导,不等于有全库性能基准。布局高度动画按组件需要存在,不应为套用建议删除 |
|
||||||
|
| 下一步 | 文稿链接迁移待后续任务 |
|
||||||
|
|
||||||
|
## 逐节清单:组合(11)
|
||||||
|
|
||||||
|
| 官方二级章节 | 实现判断与证据 |
|
||||||
|
| ---------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| 与框架无关的样式 | 独立 @heroui-vue/styles JS/CSS 包,运行时不依赖 React;P1 |
|
||||||
|
| 多态样式 | 原生元素 + variants 可用 B1/P1;按钮行为不因换成 a 自动等价,不允许无语义换根 |
|
||||||
|
| 直接应用类名 | hv- BEM 已编译;B2 验证样式,不附带交互语义 |
|
||||||
|
| 使用变体函数 | styles 与 components 根重新导出 variants/tv/cn;P1 类型及实际扩展 |
|
||||||
|
| 复合组件 | Vue 具名 Root/Trigger/Content 等部件,原组件与 Root 别名共用对象;既有 api-root-aliases 契约,不使用 React X.Y 对象模式 |
|
||||||
|
| 混合使用变体函数 | variants 返回类/slots,需按真实返回类型组合;P1 验证继承,无全例视觉声明 |
|
||||||
|
| 自定义组件 | 插槽/attrs 组合已有;B1 实测 Button 监听与属性合并,复杂包装不能由此推断全部通过 |
|
||||||
|
| 自定义变体 | tv extend 与 VariantProps;B1/P1 |
|
||||||
|
| 自定义 DOM 元素 | as/asChild 支持按组件 API;B1 唯一原生 button,保留语义;H09,不把 Input 等本来没有 asChild 的组件扩大支持 |
|
||||||
|
| 框架集成 | Vue 客户端原生元素/可选路由适配方向;未验证每个 router 包。Next.js 不适用,Nuxt 服务端明确不支持 |
|
||||||
|
| 下一步 | 文稿链接迁移待后续任务 |
|
||||||
|
|
||||||
|
## 逐节清单:深色模式(4)
|
||||||
|
|
||||||
|
| 官方二级章节 | 实现判断与证据 |
|
||||||
|
| ----------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||||
|
| 在 Next.js 中使用 next-themes | React/Next 服务端方案不移植;Vue 客户端 CSS 标记已支持 B1,未重新启用服务端范围 |
|
||||||
|
| 使用自定义主题名称 | 自定义选择器变量可用;主题状态管理由应用负责 H07;局部弹层 H08 |
|
||||||
|
| 在 React 中使用 useTheme | 缺对应公共库 API H07;文档站 VueUse 三模式是站点实现,不能冒充库 API |
|
||||||
|
| 同时为两种主题设置样式 | light/dark/data-theme token 与 dark 自定义变体已有 S1;Input/局部 Popover 实测 B1,消费者 Tailwind 接入 H06 |
|
||||||
|
|
||||||
|
## 文稿迁移前仍须明确的边界
|
||||||
|
|
||||||
|
1. H06 按需 CSS/可编译主题入口是实际缺失能力,应单独设计打包契约并验证,不能靠拷贝官方 import 路径“补齐”。
|
||||||
|
2. H07 公共主题控制 API 是否新增需明确 API 设计;当前文稿应使用已存在的 VueUse/应用逻辑,不杜撰 useTheme。
|
||||||
|
3. Skeleton 全局动画变量目前只在挂载时读取 html;局部/动态行为尚未实现,先写准确边界。
|
||||||
|
4. H08 Portal 继承是应用 DOM 决策,文稿必须展示实际 to/全局标记策略;不宣称任意局部主题自动穿透。
|
||||||
|
5. 颜色、状态、响应式等未实测的组件与组合仍为源码核对,未因本轮全量行为测试通过就标记全部 Handbook 完全符合。
|
||||||
|
|
||||||
|
验证命令与实际结果见 [任务结果](tasks/results/HANDBOOK-IMPLEMENTATION-AUDIT.md)。本文件是实现审计,不是补齐后的用户 Handbook。
|
||||||
@@ -328,3 +328,10 @@ CSS/tv 仅加 `hv-` 前缀与 Apache-2.0 来源;`colorPickerVariants` 保持
|
|||||||
## FORM(2026-10-27)
|
## FORM(2026-10-27)
|
||||||
|
|
||||||
固定 `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/form/{form.tsx,index.ts}`、中文 `(forms)/form.mdx` 与 `apps/docs/src/demos/cn/form/{basic,render-function,custom-styles}.tsx`。源无专用CSS/variants;复用已有字段样式。保留3例布局、文案、验证规则与字段,render添加data-custom改为Vue attrs、Gravity Check图标用Tabler IconCheck、alert提交反馈改页内status、增加max-w-full适应窄屏;差异见 [Form文档](../apps/docs/components/form.md)。
|
固定 `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/form/{form.tsx,index.ts}`、中文 `(forms)/form.mdx` 与 `apps/docs/src/demos/cn/form/{basic,render-function,custom-styles}.tsx`。源无专用CSS/variants;复用已有字段样式。保留3例布局、文案、验证规则与字段,render添加data-custom改为Vue attrs、Gravity Check图标用Tabler IconCheck、alert提交反馈改页内status、增加max-w-full适应窄屏;差异见 [Form文档](../apps/docs/components/form.md)。
|
||||||
|
|
||||||
|
## HANDBOOK-IMPLEMENTATION-AUDIT(2026-10-27)
|
||||||
|
|
||||||
|
- 固定 `ce90ea3` 的中文 React getting-started/(handbook) 六篇,仅作为规范审计来源,未把 React/Next 专属示例复制成 Vue API。
|
||||||
|
- `packages/styles/base/scrollbar.css` 移植为本库同路径;保留 Apache-2.0 来源,导入放在本库主题默认值之后,保证显式模式优先。
|
||||||
|
- 本库 Popover/Tooltip/Dropdown/Select/ComboBox/Autocomplete/DatePicker/DateRangePicker 原有进出场块补共享 motion-reduce 规则;Drawer 系统媒体规则统一为共享显式属性/系统变体;Skeleton 覆盖自身和伪元素。属于规范缺口修复,不声称上游原 CSS 已全部满足文稿。
|
||||||
|
- `components/overlay/animation.ts` 为本库 Vue/Reka 生命周期修复,不移植 React runtime。完整证据与边界见 [审计](handbook-audit.md)。
|
||||||
|
|||||||
@@ -128,3 +128,7 @@ ColorPicker/Root、Trigger、Popover、colorPickerVariants 与固定源中文 6
|
|||||||
- 控制台:文档页与 tarball 消费者无 warn/error;playground 仅剩合成指针注入(无活动 pointerId)触发的 `setPointerCapture` NotFoundError,真实拖动/点击无此报错,属测试注入边界,未改组件。窄屏无可用视口模拟,仅验证可用高度收缩与 1000px 视口无横向滚动。
|
- 控制台:文档页与 tarball 消费者无 warn/error;playground 仅剩合成指针注入(无活动 pointerId)触发的 `setPointerCapture` NotFoundError,真实拖动/点击无此报错,属测试注入边界,未改组件。窄屏无可用视口模拟,仅验证可用高度收缩与 1000px 视口无横向滚动。
|
||||||
|
|
||||||
COLOR-PICKER 独立复核与集成(2026-10-27):复核修复 `74cd597`(提案事件文档与既有焦点测试时间戳隔离),合并 `23eecaf`。完整客户端回归107文件/1571项在任务分支和main分别通过;typecheck、最终文档构建、十契约tarball通过。独立浏览器补验改色同步、嵌套Select、Esc关闭还焦及390×844窄屏(弹层248px宽,页面无横向溢出)。原始实施限制保留,详见结果表。
|
COLOR-PICKER 独立复核与集成(2026-10-27):复核修复 `74cd597`(提案事件文档与既有焦点测试时间戳隔离),合并 `23eecaf`。完整客户端回归107文件/1571项在任务分支和main分别通过;typecheck、最终文档构建、十契约tarball通过。独立浏览器补验改色同步、嵌套Select、Esc关闭还焦及390×844窄屏(弹层248px宽,页面无横向溢出)。原始实施限制保留,详见结果表。
|
||||||
|
|
||||||
|
## Handbook 实现规范审计(2026-10-27)
|
||||||
|
|
||||||
|
固定源六篇56章节逐项核对,补共享样式/动画缺口;命令、失败反证与浏览器实际证据见 [任务结果](tasks/results/HANDBOOK-IMPLEMENTATION-AUDIT.md)。代表性组件验收与原生 BEM 样式探针分开记账,不能从本轮全量客户端回归推断全库全状态视觉符合。未执行 SSR/水合/Nuxt、逐像素或读屏矩阵。
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/* Adapted from HeroUI ce90ea3, packages/styles/base/scrollbar.css.
|
||||||
|
* Copyright 2025 NextUI Inc. Apache-2.0; see third-party/HEROUI-LICENSE. */
|
||||||
|
[data-scrollbar="thin"] {
|
||||||
|
--scrollbar-width: thin;
|
||||||
|
--scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
|
||||||
|
--scrollbar-gutter: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-scrollbar="default"] {
|
||||||
|
--scrollbar-width: auto;
|
||||||
|
--scrollbar-color: auto;
|
||||||
|
--scrollbar-gutter: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-scrollbar="none"] {
|
||||||
|
--scrollbar-width: none;
|
||||||
|
--scrollbar-color: auto;
|
||||||
|
--scrollbar-gutter: auto;
|
||||||
|
}
|
||||||
@@ -174,6 +174,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arrow styling */
|
/* Arrow styling */
|
||||||
|
|||||||
@@ -143,6 +143,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arrow styling */
|
/* Arrow styling */
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,25 +215,13 @@
|
|||||||
var(--drawer-exit-ease);
|
var(--drawer-exit-ease);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reduced motion must beat the direction-specific animation rules above. */
|
/* Reduced motion must beat direction-specific animation rules, including
|
||||||
@media (prefers-reduced-motion: reduce) {
|
* explicit data-reduce-motion on the element or its portal ancestor. */
|
||||||
.hv-drawer__dialog[data-entering="true"],
|
.hv-drawer__dialog[data-entering="true"][data-placement],
|
||||||
.hv-drawer__dialog[data-exiting="true"],
|
.hv-drawer__dialog[data-exiting="true"][data-placement],
|
||||||
.hv-drawer__dialog[data-entering="true"][data-placement="left"],
|
.hv-drawer__backdrop[data-entering="true"],
|
||||||
.hv-drawer__dialog[data-entering="true"][data-placement="right"],
|
.hv-drawer__backdrop[data-exiting="true"] {
|
||||||
.hv-drawer__dialog[data-entering="true"][data-placement="top"],
|
@apply motion-reduce:animate-none;
|
||||||
.hv-drawer__dialog[data-entering="true"][data-placement="bottom"],
|
|
||||||
.hv-drawer__dialog[data-exiting="true"][data-placement="left"],
|
|
||||||
.hv-drawer__dialog[data-exiting="true"][data-placement="right"],
|
|
||||||
.hv-drawer__dialog[data-exiting="true"][data-placement="top"],
|
|
||||||
.hv-drawer__dialog[data-exiting="true"][data-placement="bottom"] {
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hv-drawer__backdrop[data-entering="true"],
|
|
||||||
.hv-drawer__backdrop[data-exiting="true"] {
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes hv-drawer-backdrop-in {
|
@keyframes hv-drawer-backdrop-in {
|
||||||
|
|||||||
@@ -97,6 +97,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arrow styling */
|
/* Arrow styling */
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arrow styling */
|
/* Arrow styling */
|
||||||
|
|||||||
@@ -232,6 +232,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arrow styling */
|
/* Arrow styling */
|
||||||
|
|||||||
+5
@@ -46,3 +46,8 @@
|
|||||||
|
|
||||||
.hv-skeleton--none {
|
.hv-skeleton--none {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Also covers the synchronized parent shimmer pseudo-elements. */
|
||||||
|
.hv-skeleton {
|
||||||
|
@apply motion-reduce:animate-none;
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
&[data-exiting="true"],
|
&[data-exiting="true"],
|
||||||
&[data-entering="true"] {
|
&[data-entering="true"] {
|
||||||
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
@apply transition-[opacity,transform] will-change-[opacity,transform];
|
||||||
|
@apply motion-reduce:animate-none motion-reduce:transition-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Arrow styling */
|
/* Arrow styling */
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
@import "tailwindcss/preflight.css" layer(base);
|
@import "tailwindcss/preflight.css" layer(base);
|
||||||
@import "./themes/shared/theme.css";
|
@import "./themes/shared/theme.css";
|
||||||
@import "./themes/default/variables.css";
|
@import "./themes/default/variables.css";
|
||||||
|
/* Mode overrides must follow theme defaults so an explicit mode on a theme root wins. */
|
||||||
|
@import "./base/scrollbar.css" layer(base);
|
||||||
@import "./utilities/index.css";
|
@import "./utilities/index.css";
|
||||||
@import "./animations.css";
|
@import "./animations.css";
|
||||||
@import "./variants/index.css";
|
@import "./variants/index.css";
|
||||||
|
|||||||
@@ -40,12 +40,22 @@ export function useOverlayAnimation(
|
|||||||
if (!animation || animation === "none") entering.value = false;
|
if (!animation || animation === "none") entering.value = false;
|
||||||
};
|
};
|
||||||
const observer = new MutationObserver(check);
|
const observer = new MutationObserver(check);
|
||||||
observer.observe(el, { attributes: true, attributeFilter: ["style"] });
|
observer.observe(el, {
|
||||||
if (floating && wrapper)
|
|
||||||
observer.observe(wrapper, {
|
|
||||||
attributes: true,
|
attributes: true,
|
||||||
attributeFilter: ["style"],
|
attributeFilter: ["data-reduce-motion", "class", "style"],
|
||||||
});
|
});
|
||||||
|
// Reduced motion can change on a theme/portal ancestor while an entrance
|
||||||
|
// runs. A cancelled animation has no animationend to clear its marker.
|
||||||
|
for (
|
||||||
|
let ancestor = el.parentElement;
|
||||||
|
ancestor;
|
||||||
|
ancestor = ancestor.parentElement
|
||||||
|
)
|
||||||
|
observer.observe(ancestor, {
|
||||||
|
attributes: true,
|
||||||
|
attributeFilter: ["data-reduce-motion", "class", "style"],
|
||||||
|
});
|
||||||
|
el.addEventListener("animationcancel", check);
|
||||||
const media = el.ownerDocument.defaultView?.matchMedia?.(
|
const media = el.ownerDocument.defaultView?.matchMedia?.(
|
||||||
"(prefers-reduced-motion: reduce)",
|
"(prefers-reduced-motion: reduce)",
|
||||||
);
|
);
|
||||||
@@ -54,6 +64,7 @@ export function useOverlayAnimation(
|
|||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
stale = true;
|
stale = true;
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
|
el.removeEventListener("animationcancel", check);
|
||||||
media?.removeEventListener("change", check);
|
media?.removeEventListener("change", check);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -326,6 +326,43 @@ it("keeps non-modal content interactive outside without claiming a modal lock",
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("floating overlay animation lifecycle", () => {
|
describe("floating overlay animation lifecycle", () => {
|
||||||
|
it("clears an entrance cancelled by an ancestor reduced-motion change", async () => {
|
||||||
|
const { useOverlayAnimation } =
|
||||||
|
await import("../packages/vue/src/components/overlay/animation");
|
||||||
|
const element = ref<HTMLElement>();
|
||||||
|
const reduced = ref(false);
|
||||||
|
let phase!: ReturnType<typeof useOverlayAnimation>;
|
||||||
|
const realStyle = getComputedStyle;
|
||||||
|
const css = vi
|
||||||
|
.spyOn(window, "getComputedStyle")
|
||||||
|
.mockImplementation((el) => {
|
||||||
|
if (el === element.value)
|
||||||
|
return {
|
||||||
|
animationName: el.closest('[data-reduce-motion="true"]')
|
||||||
|
? "none"
|
||||||
|
: "enter",
|
||||||
|
} as CSSStyleDeclaration;
|
||||||
|
return realStyle(el);
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
fixture(
|
||||||
|
'<section :data-reduce-motion="reduced ? \'true\' : undefined"><div ref="element" /></section>',
|
||||||
|
() => {
|
||||||
|
phase = useOverlayAnimation(ref(true), element);
|
||||||
|
return { element, reduced };
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await settle();
|
||||||
|
expect(phase.entering.value).toBe(true);
|
||||||
|
reduced.value = true;
|
||||||
|
await settle();
|
||||||
|
// No synthetic animationend: CSS cancels the entrance entirely.
|
||||||
|
expect(phase.entering.value).toBe(false);
|
||||||
|
} finally {
|
||||||
|
css.mockRestore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
async function animationFixture(transform: string, animated = true) {
|
async function animationFixture(transform: string, animated = true) {
|
||||||
const { useOverlayAnimation } =
|
const { useOverlayAnimation } =
|
||||||
await import("../packages/vue/src/components/overlay/animation");
|
await import("../packages/vue/src/components/overlay/animation");
|
||||||
|
|||||||
@@ -17,6 +17,20 @@ for (const id of process.argv.slice(2)) {
|
|||||||
assert(css.includes(token), `Missing CSS ${token}`);
|
assert(css.includes(token), `Missing CSS ${token}`);
|
||||||
for (const name of spec.absent ?? [])
|
for (const name of spec.absent ?? [])
|
||||||
assert(!(name in lib), `Private component exposed: ${name}`);
|
assert(!(name in lib), `Private component exposed: ${name}`);
|
||||||
|
if (id === "handbook-styles") {
|
||||||
|
const extended = lib.tv({
|
||||||
|
extend: lib.buttonVariants,
|
||||||
|
variants: { intent: { quiet: "audit-quiet" } },
|
||||||
|
});
|
||||||
|
const classes = extended({ intent: "quiet", size: "sm" });
|
||||||
|
assert(
|
||||||
|
classes.includes("hv-button--sm") && classes.includes("audit-quiet"),
|
||||||
|
);
|
||||||
|
// This proves final CSS packaging; computed style and lifecycle assertions
|
||||||
|
// run separately in apps/playground/src/HandbookLab.vue.
|
||||||
|
for (const mode of ["none", "default", "thin"])
|
||||||
|
assert(new RegExp(`\\[data-scrollbar=["']?${mode}["']?\\]`).test(css));
|
||||||
|
}
|
||||||
if (id === "b02-pickers") {
|
if (id === "b02-pickers") {
|
||||||
assert(
|
assert(
|
||||||
lib
|
lib
|
||||||
|
|||||||
@@ -1,4 +1,23 @@
|
|||||||
{
|
{
|
||||||
|
"handbook-styles": {
|
||||||
|
"exports": [
|
||||||
|
"Button",
|
||||||
|
"Input",
|
||||||
|
"Popover",
|
||||||
|
"Table",
|
||||||
|
"buttonVariants",
|
||||||
|
"tv",
|
||||||
|
"cn"
|
||||||
|
],
|
||||||
|
"css": [
|
||||||
|
"data-scrollbar",
|
||||||
|
"--scrollbar-width",
|
||||||
|
"data-reduce-motion",
|
||||||
|
".hv-skeleton",
|
||||||
|
".hv-drawer__dialog",
|
||||||
|
".hv-popover"
|
||||||
|
]
|
||||||
|
},
|
||||||
"b01-menu-dropdown": {
|
"b01-menu-dropdown": {
|
||||||
"exports": [
|
"exports": [
|
||||||
"DropdownRoot",
|
"DropdownRoot",
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import { h } from "vue";
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Input,
|
||||||
|
buttonVariants,
|
||||||
|
type ButtonProps,
|
||||||
|
} from "@heroui-vue/components";
|
||||||
|
import { tv, type VariantProps, type ButtonVariants } from "@heroui-vue/styles";
|
||||||
|
|
||||||
|
const extended = tv({
|
||||||
|
extend: buttonVariants,
|
||||||
|
variants: { intent: { quiet: "opacity-70", loud: "font-bold" } },
|
||||||
|
});
|
||||||
|
type Extended = VariantProps<typeof extended>;
|
||||||
|
const valid: Extended = { intent: "quiet", size: "sm" };
|
||||||
|
extended(valid);
|
||||||
|
const native: ButtonProps = { asChild: true, variant: "secondary" };
|
||||||
|
h(Button, native, () => h("button", { type: "button" }, "Native composition"));
|
||||||
|
h(Input, {
|
||||||
|
"aria-label": "Field",
|
||||||
|
class: ["custom"],
|
||||||
|
style: { color: "var(--foreground)" },
|
||||||
|
});
|
||||||
|
// @ts-expect-error custom intent remains typed
|
||||||
|
const badIntent: Extended = { intent: "missing" };
|
||||||
|
// @ts-expect-error built-in variants remain typed
|
||||||
|
const badVariant: ButtonVariants = { variant: "missing" };
|
||||||
|
void badIntent;
|
||||||
|
void badVariant;
|
||||||
Reference in New Issue
Block a user