merge: preserve documentation shell updates alongside Toast and Table
This commit is contained in:
@@ -467,3 +467,12 @@ DateField/DateInputGroup 已公开,先读[DATE-02 报告](docs/migrations/DATE
|
||||
- 默认结构、合法原生 DOM、真实状态所有者、完整逻辑集合、事件取消、跨 app 实例暂停、焦点及 SSR key 稳定均需各自断言。几何数值与实际布局/命中区分别验证。
|
||||
- 每部件 Props 必须从包根导出,Promise 回调要保留推断;演示依赖只保留实际使用的适配。文档内容、API、样式表与报告以当前实现为准,不保留互相矛盾的旧完成声明。
|
||||
- 当前结果见 [M35/M36 验收](docs/migrations/M35-M36-acceptance.md)。下一批从同步后的 main 新分支开始,三张旧 PNG 保留、不提交。
|
||||
|
||||
## DOCS-01 文档壳层维护(2026-10-24)
|
||||
|
||||
- 先读 [DOCS-01](docs/migrations/DOCS-01-shell-alignment.md)。新增组件页同步更新 `apps/docs/.vitepress/theme/navigation.ts` 的顺序与分类,禁止重新在 Layout 硬编码另一份导航;清单回归必须覆盖每个真实组件页且无假链接。
|
||||
- 侧栏、移动菜单、组件总览和前后页共用清单;根指南与组件分区独立。组件来源链接可从实际路由推导,不能依赖每页可选 frontmatter.component。
|
||||
- 文档公共控件优先使用本库组件,同时检查真实 role、tabindex、target、焦点与 SPA 行为。Link 省略 target 时不输出属性;显式 target 必须保留。不要为替换控件破坏组合框输入焦点或 API table 语义。
|
||||
- 弹层内目录跳转先处理关闭/焦点恢复,再路由和滚动;验证 URL、activeElement 与标题可见性,不能仅断言 hash 改变。
|
||||
- 保持正文/演示 not-prose 边界、满宽换行表格和同 SFC 预览/高亮/复制。禁止无层级的全局 button/input 字体、cursor 等重置覆盖库变体;异步高亮/observer/timer 需清理。
|
||||
- 文档导航索引应覆盖所有实际根指南与组件页;展示真实社区版本及固定设计基线,不伪造尚未提供的版本、框架或组件选项。缺少的公共组件可保留现有语义实现并记录。
|
||||
|
||||
@@ -15,10 +15,15 @@ export default defineConfig({
|
||||
config(md) {
|
||||
const fence = md.renderer.rules.fence!;
|
||||
md.renderer.rules.fence = (...args) =>
|
||||
fence(...args).replace(
|
||||
/(<button\b[^>]*class="copy"[^>]*>)(<\/button>)/g,
|
||||
'$1<DocsCopyIcon class="copy-icon" aria-hidden="true" :size="16" /><DocsCheckIcon class="copied-icon" aria-hidden="true" :size="16" />$2',
|
||||
);
|
||||
fence(...args)
|
||||
.replace(
|
||||
/(<button\b[^>]*class="copy"[^>]*>)(<\/button>)/g,
|
||||
'$1<DocsCopyIcon class="copy-icon" aria-hidden="true" :size="16" /><DocsCheckIcon class="copied-icon" aria-hidden="true" :size="16" />$2',
|
||||
)
|
||||
.replace(
|
||||
/<button([^>]*class="copy"[^>]*)>([\s\S]*?)<\/button>/g,
|
||||
'<DocsCopyButton$1 variant="ghost" is-icon-only>$2</DocsCopyButton>',
|
||||
);
|
||||
},
|
||||
},
|
||||
vite: {
|
||||
|
||||
@@ -47,9 +47,9 @@ export function docsDataPlugin(root: string): Plugin {
|
||||
);
|
||||
}
|
||||
const pages = [
|
||||
"introduction.md",
|
||||
"guide.md",
|
||||
"themes.md",
|
||||
...(await readdir(root))
|
||||
.filter((name) => name.endsWith(".md") && name !== "index.md")
|
||||
.sort(),
|
||||
...(await readdir(path.join(root, "components")))
|
||||
.filter((f) => f.endsWith(".md"))
|
||||
.map((f) => "components/" + f),
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import { IconCode, IconCopy } from "@tabler/icons-vue";
|
||||
import { computed, ref, watch, onBeforeUnmount, useId } from "vue";
|
||||
import { IconCode, IconCopy, IconCheck } from "@tabler/icons-vue";
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
watch,
|
||||
onBeforeUnmount,
|
||||
onMounted,
|
||||
useId,
|
||||
defineAsyncComponent,
|
||||
} from "vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
import { highlights } from "virtual:docs-data";
|
||||
const props = defineProps<{
|
||||
name: string;
|
||||
align?: "center" | "start" | "end";
|
||||
isBgSolid?: boolean;
|
||||
hideCode?: boolean;
|
||||
minHeight?: string;
|
||||
description?: string;
|
||||
}>();
|
||||
const demos = import.meta.glob("../../demos/*.vue", {
|
||||
eager: true,
|
||||
import: "default",
|
||||
});
|
||||
const loaders = import.meta.glob("../../demos/*.vue", { import: "default" });
|
||||
const demos = Object.fromEntries(
|
||||
Object.entries(loaders).map(([name, loader]) => [
|
||||
name,
|
||||
defineAsyncComponent(loader as () => Promise<import("vue").Component>),
|
||||
]),
|
||||
);
|
||||
const sources = import.meta.glob("../../demos/*.vue", {
|
||||
eager: true,
|
||||
query: "?raw",
|
||||
@@ -24,20 +39,44 @@ const expanded = ref(false),
|
||||
copyStatus = ref("复制代码");
|
||||
const id = useId();
|
||||
const highlightedCode = ref("");
|
||||
watch([expanded, () => props.name], async ([open, name], _, onCleanup) => {
|
||||
let current = true;
|
||||
onCleanup(() => {
|
||||
current = false;
|
||||
});
|
||||
highlightedCode.value = "";
|
||||
if (open) {
|
||||
try {
|
||||
const result = await highlights[name]?.();
|
||||
if (current) highlightedCode.value = result?.default ?? "";
|
||||
} catch {
|
||||
// The plain source remains available if a highlight chunk cannot load.
|
||||
}
|
||||
const preview = ref<HTMLElement>();
|
||||
let generation = 0;
|
||||
let observer: IntersectionObserver | undefined;
|
||||
async function highlight() {
|
||||
const current = ++generation;
|
||||
try {
|
||||
const result = await highlights[props.name]?.();
|
||||
if (current === generation) highlightedCode.value = result?.default ?? "";
|
||||
} catch {
|
||||
/* Plain same-SFC source remains available. */
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => props.name,
|
||||
() => {
|
||||
highlightedCode.value = "";
|
||||
void highlight();
|
||||
},
|
||||
);
|
||||
watch(expanded, (value) => {
|
||||
if (value && !highlightedCode.value) void highlight();
|
||||
});
|
||||
onMounted(() => {
|
||||
if (!preview.value || props.hideCode) return;
|
||||
if (typeof IntersectionObserver === "undefined") {
|
||||
void highlight();
|
||||
return;
|
||||
}
|
||||
observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (entries.some((entry) => entry.isIntersecting)) {
|
||||
void highlight();
|
||||
observer?.disconnect();
|
||||
}
|
||||
},
|
||||
{ rootMargin: "200px" },
|
||||
);
|
||||
observer.observe(preview.value);
|
||||
});
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
async function copy() {
|
||||
@@ -53,12 +92,18 @@ async function copy() {
|
||||
copyStatus.value = "复制失败,请手动选择代码";
|
||||
}
|
||||
}
|
||||
onBeforeUnmount(() => clearTimeout(timer));
|
||||
onBeforeUnmount(() => {
|
||||
clearTimeout(timer);
|
||||
generation++;
|
||||
observer?.disconnect();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="component-preview-container" :data-name="name">
|
||||
<p v-if="description" class="preview-description">{{ description }}</p>
|
||||
<div
|
||||
class="preview not-prose"
|
||||
:class="{ 'preview-only': hideCode }"
|
||||
:style="{
|
||||
alignItems:
|
||||
align === 'start'
|
||||
@@ -69,50 +114,59 @@ onBeforeUnmount(() => clearTimeout(timer));
|
||||
background: isBgSolid ? 'var(--background)' : undefined,
|
||||
}"
|
||||
>
|
||||
<div class="demo-row">
|
||||
<div class="demo-row" :style="{ minHeight }">
|
||||
<component :is="component" v-if="component" />
|
||||
<p v-else role="alert">示例不存在:{{ name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="code-section">
|
||||
<div class="code-toolbar">
|
||||
<span class="code-language">
|
||||
<span class="code-dot" aria-hidden="true" />
|
||||
Vue
|
||||
</span>
|
||||
<div>
|
||||
<button
|
||||
:aria-label="(expanded ? '收起' : '展开') + name + ' 示例代码'"
|
||||
:aria-controls="id"
|
||||
:aria-expanded="expanded"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
<IconCode aria-hidden="true" :size="14" />
|
||||
{{ expanded ? "收起代码" : "展开代码" }}
|
||||
</button>
|
||||
<button :aria-label="'复制' + name + ' 示例代码'" @click="copy">
|
||||
<IconCopy aria-hidden="true" :size="14" />
|
||||
复制代码
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
class="copy-feedback"
|
||||
:class="{ 'sr-only': copyStatus === '复制代码' }"
|
||||
role="status"
|
||||
<div
|
||||
v-if="!hideCode"
|
||||
ref="preview"
|
||||
class="code-section not-prose"
|
||||
:data-expanded="expanded"
|
||||
>
|
||||
<Button
|
||||
class="preview-copy"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
is-icon-only
|
||||
:aria-label="'复制' + name + ' 示例代码'"
|
||||
@click="copy"
|
||||
>
|
||||
{{ copyStatus === "复制代码" ? "" : copyStatus }}
|
||||
</p>
|
||||
<IconCheck
|
||||
v-if="copyStatus === '已复制'"
|
||||
aria-hidden="true"
|
||||
:size="16"
|
||||
/>
|
||||
<IconCopy v-else aria-hidden="true" :size="16" />
|
||||
</Button>
|
||||
<div
|
||||
v-if="expanded"
|
||||
:id="id"
|
||||
class="highlighted-source"
|
||||
tabindex="0"
|
||||
:aria-hidden="!expanded || undefined"
|
||||
:tabindex="expanded ? 0 : undefined"
|
||||
:aria-label="name + ' 示例源码'"
|
||||
>
|
||||
<div v-if="highlightedCode" v-html="highlightedCode" />
|
||||
<pre v-else><code>{{ code }}</code></pre>
|
||||
<pre
|
||||
v-else
|
||||
><code>{{expanded ? code : code.split('\n').slice(0,5).join('\n')}}</code></pre>
|
||||
</div>
|
||||
<Button
|
||||
class="preview-expand"
|
||||
size="sm"
|
||||
variant="tertiary"
|
||||
:aria-label="(expanded ? '收起' : '展开') + name + ' 示例代码'"
|
||||
:aria-controls="id"
|
||||
:aria-expanded="expanded"
|
||||
@click="expanded = !expanded"
|
||||
>
|
||||
<IconCode :size="14" aria-hidden="true" />
|
||||
{{ expanded ? "收起代码" : "展开代码" }}
|
||||
</Button>
|
||||
<p class="sr-only" role="status">
|
||||
{{ copyStatus === "复制代码" ? "" : copyStatus }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -10,15 +10,21 @@ import {
|
||||
} from "vue";
|
||||
import { withBase, useRouter } from "vitepress";
|
||||
import {
|
||||
DialogRoot,
|
||||
DialogTrigger,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
DialogClose,
|
||||
} from "reka-ui";
|
||||
Button,
|
||||
Link,
|
||||
Kbd,
|
||||
Modal,
|
||||
ModalTrigger,
|
||||
ModalBackdrop,
|
||||
ModalContainer,
|
||||
ModalDialog,
|
||||
ModalHeading,
|
||||
SearchField,
|
||||
SearchFieldGroup,
|
||||
SearchFieldInput,
|
||||
SearchFieldSearchIcon,
|
||||
EmptyState,
|
||||
} from "@heroui-vue/components";
|
||||
import { searchIndex } from "virtual:docs-data";
|
||||
import { searchDocs, searchExcerpt } from "./search";
|
||||
const router = useRouter();
|
||||
@@ -26,7 +32,7 @@ const navigating = ref(false);
|
||||
const open = ref(false),
|
||||
query = ref(""),
|
||||
active = ref(0),
|
||||
field = ref<HTMLInputElement>();
|
||||
field = ref<{ focus: () => void }>();
|
||||
const results = computed(() => searchDocs(searchIndex, query.value));
|
||||
watch(query, () => {
|
||||
active.value = 0;
|
||||
@@ -36,11 +42,31 @@ watch(open, (value) => {
|
||||
else navigating.value = false;
|
||||
});
|
||||
function shortcut(event: KeyboardEvent) {
|
||||
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
||||
if (
|
||||
!event.defaultPrevented &&
|
||||
!event.isComposing &&
|
||||
!event.repeat &&
|
||||
(event.metaKey || event.ctrlKey) &&
|
||||
event.key.toLowerCase() === "k"
|
||||
) {
|
||||
event.preventDefault();
|
||||
open.value = !open.value;
|
||||
}
|
||||
}
|
||||
function keydown(event: KeyboardEvent) {
|
||||
if (event.defaultPrevented || event.isComposing || event.keyCode === 229)
|
||||
return;
|
||||
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
||||
event.preventDefault();
|
||||
move(event.key === "ArrowDown" ? 1 : -1);
|
||||
} else if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
navigate();
|
||||
} else if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
open.value = false;
|
||||
}
|
||||
}
|
||||
function move(delta: number) {
|
||||
if (!results.value.length) return;
|
||||
active.value =
|
||||
@@ -67,6 +93,9 @@ function navigate() {
|
||||
const entry = results.value[active.value];
|
||||
if (entry) void navigateTo(entry);
|
||||
}
|
||||
function guardEscape(event: KeyboardEvent) {
|
||||
if (event.isComposing) event.preventDefault();
|
||||
}
|
||||
function closeAutoFocus(event: Event) {
|
||||
if (navigating.value) event.preventDefault();
|
||||
}
|
||||
@@ -74,83 +103,113 @@ onMounted(() => window.addEventListener("keydown", shortcut));
|
||||
onBeforeUnmount(() => window.removeEventListener("keydown", shortcut));
|
||||
</script>
|
||||
<template>
|
||||
<DialogRoot v-model:open="open">
|
||||
<DialogTrigger class="search-trigger" aria-label="搜索文档">
|
||||
<IconSearch aria-hidden="true" :size="17" />
|
||||
<span>搜索文档…</span>
|
||||
<kbd>⌘ / Ctrl K</kbd>
|
||||
</DialogTrigger>
|
||||
<DialogPortal>
|
||||
<DialogOverlay class="search-overlay" />
|
||||
<DialogContent
|
||||
class="search-dialog"
|
||||
@open-auto-focus.prevent="field?.focus()"
|
||||
@close-auto-focus="closeAutoFocus"
|
||||
>
|
||||
<DialogTitle class="sr-only">搜索文档</DialogTitle>
|
||||
<DialogDescription class="sr-only">
|
||||
搜索组件、参数和用法;使用方向键选择,回车打开,Esc 关闭。
|
||||
</DialogDescription>
|
||||
<div class="search-field">
|
||||
<input
|
||||
ref="field"
|
||||
v-model="query"
|
||||
placeholder="搜索组件、参数或用法…"
|
||||
aria-label="搜索组件、参数或用法"
|
||||
role="combobox"
|
||||
aria-autocomplete="list"
|
||||
aria-controls="doc-search-results"
|
||||
:aria-expanded="Boolean(query.trim())"
|
||||
:aria-activedescendant="
|
||||
results.length ? 'search-result-' + active : undefined
|
||||
"
|
||||
@keydown.down.prevent="move(1)"
|
||||
@keydown.up.prevent="move(-1)"
|
||||
@keydown.enter.prevent="navigate"
|
||||
/>
|
||||
<DialogClose class="search-close" aria-label="关闭搜索">
|
||||
Esc
|
||||
</DialogClose>
|
||||
</div>
|
||||
<div
|
||||
class="search-results"
|
||||
id="doc-search-results"
|
||||
role="listbox"
|
||||
aria-label="搜索结果"
|
||||
<Modal v-model:open="open">
|
||||
<ModalTrigger as-child>
|
||||
<Button class="search-trigger" variant="secondary" aria-label="搜索文档">
|
||||
<IconSearch aria-hidden="true" :size="17" />
|
||||
<span>搜索文档…</span>
|
||||
<Kbd>⌘ / Ctrl K</Kbd>
|
||||
</Button>
|
||||
</ModalTrigger>
|
||||
<ModalBackdrop class="docs-search-backdrop" variant="blur">
|
||||
<ModalContainer placement="top" size="lg" class="docs-search-container">
|
||||
<ModalDialog
|
||||
class="search-dialog"
|
||||
@open-auto-focus.prevent="field?.focus()"
|
||||
@close-auto-focus="closeAutoFocus"
|
||||
@escape-key-down="guardEscape"
|
||||
>
|
||||
<p v-if="!query.trim()" class="search-empty">
|
||||
试试搜索「isPending」「主题」或「受控」
|
||||
<ModalHeading class="sr-only">搜索文档</ModalHeading>
|
||||
<p class="sr-only" id="docs-search-instructions">
|
||||
搜索组件、参数和用法;使用方向键选择,回车打开,Esc 关闭。
|
||||
</p>
|
||||
<p v-else-if="!results.length" class="search-empty" role="status">
|
||||
没有找到“{{ query }}”,试试组件名或参数名。
|
||||
</p>
|
||||
<a
|
||||
v-for="(entry, index) in results"
|
||||
:id="'search-result-' + index"
|
||||
:key="entry.url"
|
||||
:href="withBase(entry.url)"
|
||||
role="option"
|
||||
:aria-selected="index === active"
|
||||
:tabindex="-1"
|
||||
@mousemove="active = index"
|
||||
@click.prevent="navigateTo(entry)"
|
||||
<div class="search-field">
|
||||
<SearchField
|
||||
v-model="query"
|
||||
class="docs-search-input"
|
||||
aria-label="搜索组件、参数或用法"
|
||||
>
|
||||
<SearchFieldGroup>
|
||||
<SearchFieldSearchIcon />
|
||||
<SearchFieldInput
|
||||
ref="field"
|
||||
placeholder="搜索组件、参数或用法…"
|
||||
aria-label="搜索组件、参数或用法"
|
||||
role="combobox"
|
||||
aria-autocomplete="list"
|
||||
aria-describedby="docs-search-instructions"
|
||||
aria-controls="doc-search-results"
|
||||
:aria-expanded="Boolean(query.trim())"
|
||||
:aria-activedescendant="
|
||||
query.trim() && results.length
|
||||
? 'search-result-' + active
|
||||
: undefined
|
||||
"
|
||||
@keydown="keydown"
|
||||
/>
|
||||
</SearchFieldGroup>
|
||||
</SearchField>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
class="search-close"
|
||||
aria-label="关闭搜索"
|
||||
@click="open = false"
|
||||
>
|
||||
<Kbd>Esc</Kbd>
|
||||
</Button>
|
||||
</div>
|
||||
<div
|
||||
class="search-results"
|
||||
id="doc-search-results"
|
||||
role="listbox"
|
||||
aria-label="搜索结果"
|
||||
>
|
||||
<span class="result-title">
|
||||
{{ entry.title }}
|
||||
<span>{{ entry.section }}</span>
|
||||
<EmptyState v-if="!query.trim()" class="search-empty">
|
||||
<IconSearch :size="24" aria-hidden="true" />
|
||||
<p>试试搜索「isPending」「主题」或「受控」</p>
|
||||
</EmptyState>
|
||||
<EmptyState
|
||||
v-else-if="!results.length"
|
||||
class="search-empty"
|
||||
role="status"
|
||||
>
|
||||
<p>没有找到“{{ query }}”,试试组件名或参数名。</p>
|
||||
</EmptyState>
|
||||
<Link
|
||||
v-for="(entry, index) in results"
|
||||
:id="'search-result-' + index"
|
||||
:key="entry.url"
|
||||
:href="withBase(entry.url)"
|
||||
role="option"
|
||||
:aria-selected="index === active"
|
||||
:tabindex="-1"
|
||||
@mousemove="active = index"
|
||||
@click.prevent="navigateTo(entry)"
|
||||
>
|
||||
<span class="result-title">
|
||||
{{ entry.title }}
|
||||
<span>{{ entry.section }}</span>
|
||||
</span>
|
||||
<span class="result-excerpt">
|
||||
{{ searchExcerpt(entry, query) || "查看文档" }}
|
||||
</span>
|
||||
</Link>
|
||||
</div>
|
||||
<div class="search-footer" aria-live="polite">
|
||||
<span>
|
||||
{{ query.trim() ? results.length + " 条结果" : "本地文档搜索" }}
|
||||
</span>
|
||||
<span class="result-excerpt">
|
||||
{{ searchExcerpt(entry, query) || "查看文档" }}
|
||||
<span>
|
||||
<Kbd>↑</Kbd>
|
||||
<Kbd>↓</Kbd>
|
||||
选择
|
||||
<Kbd>↵</Kbd>
|
||||
打开
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="search-footer" aria-live="polite">
|
||||
<span>
|
||||
{{ query.trim() ? results.length + " 条结果" : "本地文档搜索" }}
|
||||
</span>
|
||||
<span>↑ ↓ 选择 ↵ 打开</span>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
</div>
|
||||
</ModalDialog>
|
||||
</ModalContainer>
|
||||
</ModalBackdrop>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { Card, CardTitle, CardDescription } from "@heroui-vue/components";
|
||||
import { withBase } from "vitepress";
|
||||
import { IconArrowUpRight } from "@tabler/icons-vue";
|
||||
import { searchIndex } from "virtual:docs-data";
|
||||
import { componentItems } from "./navigation";
|
||||
const props = defineProps<{ category: string }>();
|
||||
const items = computed(() =>
|
||||
componentItems.filter((item) => item.category === props.category),
|
||||
);
|
||||
function description(url: string) {
|
||||
return (
|
||||
searchIndex.find((entry) => entry.url === url && entry.section === "概览")
|
||||
?.text ?? "查看组件用法与 API"
|
||||
);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="components-grid not-prose">
|
||||
<Card
|
||||
v-for="item in items"
|
||||
:key="item.url"
|
||||
as="a"
|
||||
:href="withBase(item.url)"
|
||||
class="component-index-card"
|
||||
variant="transparent"
|
||||
>
|
||||
<CardTitle>
|
||||
{{ item.title }}
|
||||
<IconArrowUpRight aria-hidden="true" :size="16" />
|
||||
</CardTitle>
|
||||
<CardDescription>{{ description(item.url) }}</CardDescription>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from "@heroui-vue/components";
|
||||
import { withBase } from "vitepress";
|
||||
import type { DocsGroup } from "./navigation";
|
||||
defineProps<{ groups: DocsGroup[]; current: string; label?: string }>();
|
||||
const emit = defineEmits<{ navigate: [] }>();
|
||||
</script>
|
||||
<template>
|
||||
<nav :aria-label="label ?? '文档导航'" class="sidebar-tree">
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<Link
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:aria-current="current === item.url ? 'page' : undefined"
|
||||
@click="emit('navigate')"
|
||||
>
|
||||
{{ item.title }}
|
||||
</Link>
|
||||
</section>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -0,0 +1,86 @@
|
||||
<script setup lang="ts">
|
||||
import { useColorMode } from "@vueuse/core";
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverTrigger,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
ToggleButtonGroup,
|
||||
ToggleButton,
|
||||
} from "@heroui-vue/components";
|
||||
import { IconSun, IconMoon, IconDeviceDesktop } from "@tabler/icons-vue";
|
||||
const mode = useColorMode({
|
||||
storageKey: "vitepress-theme-appearance",
|
||||
emitAuto: true,
|
||||
});
|
||||
const choices = [
|
||||
{ id: "light", label: "浅色主题", icon: IconSun },
|
||||
{ id: "dark", label: "深色主题", icon: IconMoon },
|
||||
{ id: "auto", label: "跟随系统", icon: IconDeviceDesktop },
|
||||
] as const;
|
||||
function setTheme(value: unknown) {
|
||||
if (value === "light" || value === "dark" || value === "auto")
|
||||
mode.value = value;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<ToggleButtonGroup
|
||||
class="docs-theme-wide"
|
||||
:model-value="mode"
|
||||
selection-mode="single"
|
||||
disallow-empty-selection
|
||||
aria-label="外观"
|
||||
size="sm"
|
||||
@update:model-value="setTheme"
|
||||
>
|
||||
<ToggleButton
|
||||
v-for="choice in choices"
|
||||
:id="choice.id"
|
||||
:key="choice.id"
|
||||
is-icon-only
|
||||
:aria-label="choice.label"
|
||||
>
|
||||
<component :is="choice.icon" aria-hidden="true" :size="15" />
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
class="docs-theme-compact"
|
||||
variant="ghost"
|
||||
is-icon-only
|
||||
size="sm"
|
||||
aria-label="选择外观"
|
||||
>
|
||||
<IconSun v-if="mode === 'light'" :size="18" />
|
||||
<IconMoon v-else-if="mode === 'dark'" :size="18" />
|
||||
<IconDeviceDesktop v-else :size="18" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent placement="bottom end">
|
||||
<PopoverDialog>
|
||||
<PopoverHeading class="sr-only">外观</PopoverHeading>
|
||||
<ToggleButtonGroup
|
||||
:model-value="mode"
|
||||
selection-mode="single"
|
||||
disallow-empty-selection
|
||||
aria-label="外观"
|
||||
size="sm"
|
||||
@update:model-value="setTheme"
|
||||
>
|
||||
<ToggleButton
|
||||
v-for="choice in choices"
|
||||
:id="choice.id"
|
||||
:key="choice.id"
|
||||
is-icon-only
|
||||
:aria-label="choice.label"
|
||||
>
|
||||
<component :is="choice.icon" aria-hidden="true" :size="16" />
|
||||
</ToggleButton>
|
||||
</ToggleButtonGroup>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from "@heroui-vue/components";
|
||||
interface TocEntry {
|
||||
title: string;
|
||||
slug: string;
|
||||
children?: TocEntry[];
|
||||
}
|
||||
defineProps<{ headers: TocEntry[]; active: string }>();
|
||||
const emit = defineEmits<{ navigate: [slug: string, event: MouseEvent] }>();
|
||||
</script>
|
||||
<template>
|
||||
<nav class="toc-links" aria-label="本页目录">
|
||||
<template v-for="heading in headers" :key="heading.slug">
|
||||
<Link
|
||||
:href="'#' + heading.slug"
|
||||
:aria-current="active === heading.slug ? 'location' : undefined"
|
||||
@click="emit('navigate', heading.slug, $event)"
|
||||
>
|
||||
{{ heading.title }}
|
||||
</Link>
|
||||
<Link
|
||||
v-for="child in heading.children"
|
||||
:key="child.slug"
|
||||
class="nested"
|
||||
:href="'#' + child.slug"
|
||||
:aria-current="active === child.slug ? 'location' : undefined"
|
||||
@click="emit('navigate', child.slug, $event)"
|
||||
>
|
||||
{{ child.title }}
|
||||
</Link>
|
||||
</template>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -1,11 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
IconSun,
|
||||
IconMoon,
|
||||
IconMenu2,
|
||||
IconX,
|
||||
IconArrowUpRight,
|
||||
} from "@tabler/icons-vue";
|
||||
import {
|
||||
computed,
|
||||
ref,
|
||||
@@ -14,175 +7,186 @@ import {
|
||||
onMounted,
|
||||
onBeforeUnmount,
|
||||
} from "vue";
|
||||
import { useData, useRoute, withBase, onContentUpdated } from "vitepress";
|
||||
import {
|
||||
DialogRoot,
|
||||
DialogTrigger,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
DialogClose,
|
||||
} from "reka-ui";
|
||||
useData,
|
||||
useRoute,
|
||||
useRouter,
|
||||
withBase,
|
||||
onContentUpdated,
|
||||
} from "vitepress";
|
||||
import {
|
||||
Button,
|
||||
Link,
|
||||
Chip,
|
||||
Separator,
|
||||
Breadcrumbs,
|
||||
BreadcrumbsItem,
|
||||
Card,
|
||||
Drawer,
|
||||
DrawerTrigger,
|
||||
DrawerBackdrop,
|
||||
DrawerContent,
|
||||
DrawerDialog,
|
||||
DrawerHeader,
|
||||
DrawerHeading,
|
||||
DrawerBody,
|
||||
DrawerCloseTrigger,
|
||||
Popover,
|
||||
PopoverTrigger,
|
||||
PopoverContent,
|
||||
PopoverDialog,
|
||||
PopoverHeading,
|
||||
ScrollShadow,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconMenu2,
|
||||
IconArrowUpRight,
|
||||
IconBook2,
|
||||
IconComponents,
|
||||
IconList,
|
||||
IconChevronDown,
|
||||
IconBrandVue,
|
||||
IconBrandGithub,
|
||||
IconArrowLeft,
|
||||
IconArrowRight,
|
||||
} from "@tabler/icons-vue";
|
||||
import DocSearch from "./DocSearch.vue";
|
||||
const { frontmatter, page, isDark } = useData();
|
||||
import DocsSidebar from "./DocsSidebar.vue";
|
||||
import DocsToc from "./DocsToc.vue";
|
||||
import DocsThemeSwitch from "./DocsThemeSwitch.vue";
|
||||
import {
|
||||
guideGroups,
|
||||
componentGroups,
|
||||
componentItems,
|
||||
docsPath,
|
||||
docsSection,
|
||||
adjacentPages,
|
||||
} from "./navigation";
|
||||
const { frontmatter, page, site } = useData();
|
||||
const route = useRoute();
|
||||
const mobile = ref(false),
|
||||
activeSlug = ref("");
|
||||
const copyMessage = ref("");
|
||||
let copyTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
onBeforeUnmount(() => clearTimeout(copyTimer));
|
||||
const groups = [
|
||||
{
|
||||
title: "开始使用",
|
||||
items: [
|
||||
{ title: "介绍", url: "/introduction" },
|
||||
{ title: "安装", url: "/guide" },
|
||||
{ title: "主题", url: "/themes" },
|
||||
{ title: "字段与表单基础", url: "/fields" },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "组件",
|
||||
items: [
|
||||
{ title: "Accordion 手风琴", url: "/components/accordion" },
|
||||
{ title: "Alert 警告", url: "/components/alert" },
|
||||
{ title: "AlertDialog 警告对话框", url: "/components/alert-dialog" },
|
||||
{ title: "Avatar 头像", url: "/components/avatar" },
|
||||
{ title: "AvatarGroup 头像组", url: "/components/avatar-group" },
|
||||
{ title: "Badge 徽章", url: "/components/badge" },
|
||||
{ title: "Breadcrumbs 面包屑", url: "/components/breadcrumbs" },
|
||||
{ title: "Button 按钮", url: "/components/button" },
|
||||
{
|
||||
title: "ButtonGroup 按钮组",
|
||||
url: "/components/button-group",
|
||||
},
|
||||
{ title: "Card 卡片", url: "/components/card" },
|
||||
{ title: "Checkbox 复选框", url: "/components/checkbox" },
|
||||
{ title: "CheckboxGroup 复选框组", url: "/components/checkbox-group" },
|
||||
{ title: "Chip 标签", url: "/components/chip" },
|
||||
{ title: "CloseButton 关闭按钮", url: "/components/close-button" },
|
||||
{ title: "DateField 日期字段", url: "/components/date-field" },
|
||||
{ title: "Description 描述", url: "/components/description" },
|
||||
{ title: "Disclosure 折叠面板", url: "/components/disclosure" },
|
||||
{
|
||||
title: "DisclosureGroup 折叠面板组",
|
||||
url: "/components/disclosure-group",
|
||||
},
|
||||
{ title: "Drawer 抽屉", url: "/components/drawer" },
|
||||
{ title: "EmptyState 空状态", url: "/components/empty-state" },
|
||||
{ title: "FieldError 字段错误", url: "/components/field-error" },
|
||||
{ title: "Fieldset 字段组", url: "/components/fieldset" },
|
||||
{ title: "Header 标题", url: "/components/header" },
|
||||
{ title: "Input 输入框", url: "/components/input" },
|
||||
{ title: "InputOTP 验证码输入", url: "/components/input-otp" },
|
||||
{ title: "InputGroup 输入框组", url: "/components/input-group" },
|
||||
{ title: "Kbd 键盘按键", url: "/components/kbd" },
|
||||
{ title: "Label 标签", url: "/components/label" },
|
||||
{ title: "Link 链接", url: "/components/link" },
|
||||
{ title: "Meter 计量条", url: "/components/meter" },
|
||||
{ title: "Modal 模态框", url: "/components/modal" },
|
||||
{ title: "Pagination 分页", url: "/components/pagination" },
|
||||
{ title: "Popover 弹出框", url: "/components/popover" },
|
||||
{ title: "ProgressBar 进度条", url: "/components/progress-bar" },
|
||||
{
|
||||
title: "ProgressCircle 环形进度条",
|
||||
url: "/components/progress-circle",
|
||||
},
|
||||
{ title: "RadioGroup 单选框组", url: "/components/radio-group" },
|
||||
{ title: "ScrollShadow 滚动阴影", url: "/components/scroll-shadow" },
|
||||
{ title: "SearchField 搜索框", url: "/components/search-field" },
|
||||
{ title: "Separator 分隔符", url: "/components/separator" },
|
||||
{ title: "Skeleton 骨架屏", url: "/components/skeleton" },
|
||||
{ title: "Spinner 加载指示器", url: "/components/spinner" },
|
||||
{ title: "Surface 表面", url: "/components/surface" },
|
||||
{ title: "Switch 开关", url: "/components/switch" },
|
||||
{ title: "Tabs 标签页", url: "/components/tabs" },
|
||||
{ title: "Table 表格", url: "/components/table" },
|
||||
{ title: "TextArea 多行文本框", url: "/components/textarea" },
|
||||
{ title: "TextField 文本输入框", url: "/components/text-field" },
|
||||
{ title: "Toast 轻提示", url: "/components/toast" },
|
||||
{ title: "Toolbar 工具栏", url: "/components/toolbar" },
|
||||
{ title: "NumberField 数字输入框", url: "/components/number-field" },
|
||||
{ title: "Slider 滑块", url: "/components/slider" },
|
||||
{ title: "ListBox 列表框", url: "/components/list-box" },
|
||||
{ title: "Select 选择器", url: "/components/select" },
|
||||
{ title: "Tooltip 工具提示", url: "/components/tooltip" },
|
||||
{
|
||||
title: "ToggleButton 切换按钮",
|
||||
url: "/components/toggle-button",
|
||||
},
|
||||
{
|
||||
title: "ToggleButtonGroup 切换按钮组",
|
||||
url: "/components/toggle-button-group",
|
||||
},
|
||||
{ title: "Typography 排版", url: "/components/typography" },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const items = groups.flatMap((g) => g.items);
|
||||
const currentIndex = computed(() =>
|
||||
items.findIndex((item) => selected(item.url)),
|
||||
);
|
||||
const previous = computed(() => items[currentIndex.value - 1]);
|
||||
const next = computed(() => items[currentIndex.value + 1]);
|
||||
function selected(url: string) {
|
||||
return (
|
||||
route.path === withBase(url) ||
|
||||
route.path === withBase(url + ".html") ||
|
||||
(url === "/components/button" && route.path === withBase("/"))
|
||||
);
|
||||
const router = useRouter();
|
||||
let pendingToc: { slug: string; path: string } | undefined;
|
||||
function navigateToc(slug: string, event: MouseEvent) {
|
||||
event.preventDefault();
|
||||
pendingToc = { slug, path: current.value };
|
||||
tocOpen.value = false;
|
||||
}
|
||||
async function finishTocNavigation(event: Event) {
|
||||
const target = pendingToc;
|
||||
pendingToc = undefined;
|
||||
if (!target || current.value !== target.path) return;
|
||||
event.preventDefault();
|
||||
await router.go(
|
||||
withBase(target.path + "#" + encodeURIComponent(target.slug)),
|
||||
);
|
||||
await nextTick();
|
||||
if (current.value !== target.path) return;
|
||||
const heading = document.getElementById(target.slug);
|
||||
heading?.setAttribute("tabindex", "-1");
|
||||
heading?.focus({ preventScroll: true });
|
||||
heading?.scrollIntoView({ block: "start" });
|
||||
}
|
||||
const current = computed(() => docsPath(route.path, site.value.base));
|
||||
const section = computed(() => docsSection(route.path, site.value.base));
|
||||
const groups = computed(() =>
|
||||
section.value === "components" ? componentGroups : guideGroups,
|
||||
);
|
||||
const adjacent = computed(() => adjacentPages(route.path, site.value.base));
|
||||
const componentSlug = computed(() =>
|
||||
componentItems.some((item) => item.url === current.value)
|
||||
? current.value.split("/").pop()
|
||||
: undefined,
|
||||
);
|
||||
const headers = computed(() => page.value.headers ?? []);
|
||||
const flatHeaders = computed(() =>
|
||||
headers.value.flatMap((h) => [h, ...(h.children ?? [])]),
|
||||
headers.value.flatMap((heading) => [heading, ...(heading.children ?? [])]),
|
||||
);
|
||||
let ticking = false;
|
||||
const mobile = ref(false),
|
||||
tocOpen = ref(false),
|
||||
activeSlug = ref("");
|
||||
const sidebar = ref<{ $el?: HTMLElement }>();
|
||||
const copyMessage = ref("");
|
||||
let copyTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
let frame = 0;
|
||||
function updateActive() {
|
||||
ticking = false;
|
||||
const headings = flatHeaders.value
|
||||
.map((h) => document.getElementById(h.slug))
|
||||
.filter((el): el is HTMLElement => Boolean(el));
|
||||
let active = headings[0]?.id ?? "";
|
||||
for (const heading of headings) {
|
||||
if (heading.getBoundingClientRect().top <= 120) active = heading.id;
|
||||
else break;
|
||||
frame = 0;
|
||||
let active = flatHeaders.value[0]?.slug ?? "";
|
||||
for (const heading of flatHeaders.value) {
|
||||
const element = document.getElementById(heading.slug);
|
||||
if (element && element.getBoundingClientRect().top <= 160)
|
||||
active = heading.slug;
|
||||
else if (element) break;
|
||||
}
|
||||
if (
|
||||
window.innerHeight + window.scrollY >=
|
||||
document.documentElement.scrollHeight - 2
|
||||
)
|
||||
active = flatHeaders.value.at(-1)?.slug ?? active;
|
||||
activeSlug.value = active;
|
||||
}
|
||||
function onScroll() {
|
||||
if (!ticking) {
|
||||
ticking = true;
|
||||
requestAnimationFrame(updateActive);
|
||||
}
|
||||
if (!frame) frame = requestAnimationFrame(updateActive);
|
||||
}
|
||||
function revealCurrent() {
|
||||
const element = sidebar.value?.$el?.querySelector<HTMLElement>(
|
||||
'[aria-current="page"]',
|
||||
);
|
||||
const viewport = sidebar.value?.$el;
|
||||
if (!element || !viewport || !viewport.clientHeight) return;
|
||||
const top = element.getBoundingClientRect().top,
|
||||
bounds = viewport.getBoundingClientRect();
|
||||
if (
|
||||
top < bounds.top ||
|
||||
element.getBoundingClientRect().bottom > bounds.bottom
|
||||
)
|
||||
element.scrollIntoView({ block: "nearest" });
|
||||
}
|
||||
onMounted(() => {
|
||||
window.addEventListener("scroll", onScroll, { passive: true });
|
||||
updateActive();
|
||||
revealCurrent();
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("scroll", onScroll);
|
||||
cancelAnimationFrame(frame);
|
||||
clearTimeout(copyTimer);
|
||||
});
|
||||
onBeforeUnmount(() => window.removeEventListener("scroll", onScroll));
|
||||
onContentUpdated(() => {
|
||||
void nextTick(updateActive);
|
||||
void nextTick(() => {
|
||||
updateActive();
|
||||
revealCurrent();
|
||||
});
|
||||
});
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
mobile.value = false;
|
||||
tocOpen.value = false;
|
||||
void nextTick(() => {
|
||||
if (!window.location.hash)
|
||||
window.scrollTo({ top: 0, behavior: "instant" });
|
||||
updateActive();
|
||||
revealCurrent();
|
||||
});
|
||||
},
|
||||
);
|
||||
function focusPage(event: Event) {
|
||||
if (!navigationFromDrawer) return;
|
||||
event.preventDefault();
|
||||
navigationFromDrawer = false;
|
||||
document
|
||||
.querySelector<HTMLElement>(".docs-main h1")
|
||||
?.focus({ preventScroll: true });
|
||||
}
|
||||
let navigationFromDrawer = false;
|
||||
function leaveDrawer() {
|
||||
navigationFromDrawer = true;
|
||||
mobile.value = false;
|
||||
}
|
||||
async function copyMarkdownCode(event: MouseEvent) {
|
||||
const target = (event.target as HTMLElement).closest<HTMLButtonElement>(
|
||||
"button.copy",
|
||||
);
|
||||
if (!target) return;
|
||||
const code = target.parentElement?.querySelector("pre code")?.textContent;
|
||||
if (!code) return;
|
||||
const code = target?.parentElement?.querySelector("pre code")?.textContent;
|
||||
if (!target || !code) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(code);
|
||||
target.classList.add("copied");
|
||||
@@ -202,167 +206,257 @@ async function copyMarkdownCode(event: MouseEvent) {
|
||||
</script>
|
||||
<template>
|
||||
<div class="docs-layout">
|
||||
<a class="skip" href="#main">跳至内容</a>
|
||||
<Link class="skip" href="#main">跳至内容</Link>
|
||||
<p class="sr-only" role="status">{{ copyMessage }}</p>
|
||||
<header class="docs-nav">
|
||||
<a class="brand" :href="withBase('/components/button')">
|
||||
heroui
|
||||
<span>Vue</span>
|
||||
</a>
|
||||
<span class="version">v0.0.1</span>
|
||||
<nav aria-label="主导航">
|
||||
<a
|
||||
:href="withBase('/guide')"
|
||||
:class="{
|
||||
active:
|
||||
!frontmatter.component && route.path !== withBase('/themes'),
|
||||
}"
|
||||
>
|
||||
文档
|
||||
</a>
|
||||
<a
|
||||
:href="withBase('/components/button')"
|
||||
:class="{ active: Boolean(frontmatter.component) }"
|
||||
>
|
||||
组件
|
||||
</a>
|
||||
<a
|
||||
:href="withBase('/themes')"
|
||||
:class="{ active: route.path === withBase('/themes') }"
|
||||
>
|
||||
主题
|
||||
</a>
|
||||
</nav>
|
||||
<div class="nav-tools">
|
||||
<div class="docs-nav-main">
|
||||
<div class="docs-brand-group">
|
||||
<Link
|
||||
class="brand"
|
||||
:href="withBase('/')"
|
||||
aria-label="HeroUI Vue 文档首页"
|
||||
>
|
||||
heroui
|
||||
<Chip size="sm" variant="soft">Vue</Chip>
|
||||
</Link>
|
||||
<Popover>
|
||||
<PopoverTrigger as-child>
|
||||
<Button
|
||||
class="version"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
aria-label="版本信息"
|
||||
>
|
||||
v0.0.1
|
||||
<IconChevronDown :size="12" aria-hidden="true" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent placement="bottom start">
|
||||
<PopoverDialog class="version-panel">
|
||||
<PopoverHeading>HeroUI Vue</PopoverHeading>
|
||||
<p>社区独立实现 · v0.0.1</p>
|
||||
<Separator />
|
||||
<Link
|
||||
href="https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
设计基线 HeroUI v3.2.6
|
||||
<IconArrowUpRight :size="13" aria-hidden="true" />
|
||||
</Link>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
<DocSearch />
|
||||
<button
|
||||
class="theme-toggle"
|
||||
:aria-label="isDark ? '切换浅色主题' : '切换深色主题'"
|
||||
@click="isDark = !isDark"
|
||||
>
|
||||
<IconSun v-if="isDark" aria-hidden="true" :size="18" />
|
||||
<IconMoon v-else aria-hidden="true" :size="18" />
|
||||
</button>
|
||||
<DialogRoot v-model:open="mobile">
|
||||
<DialogTrigger class="mobile-menu" aria-label="打开文档目录">
|
||||
<IconMenu2 aria-hidden="true" :size="20" />
|
||||
</DialogTrigger>
|
||||
<DialogPortal>
|
||||
<DialogOverlay class="mobile-nav-overlay" />
|
||||
<DialogContent class="mobile-nav-dialog">
|
||||
<div class="mobile-nav-heading">
|
||||
<DialogTitle>文档目录</DialogTitle>
|
||||
<DialogClose aria-label="关闭文档目录">
|
||||
<IconX aria-hidden="true" :size="20" />
|
||||
</DialogClose>
|
||||
</div>
|
||||
<nav aria-label="移动端文档导航">
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<a
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:aria-current="selected(item.url) ? 'page' : undefined"
|
||||
@click="mobile = false"
|
||||
>
|
||||
{{ item.title }}
|
||||
</a>
|
||||
</section>
|
||||
</nav>
|
||||
</DialogContent>
|
||||
</DialogPortal>
|
||||
</DialogRoot>
|
||||
<div class="nav-tools">
|
||||
<Link
|
||||
class="docs-github"
|
||||
href="https://git.myjdemo.cn/maoyingjie/heroui-vue"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
aria-label="项目源码"
|
||||
>
|
||||
<IconBrandGithub :size="19" aria-hidden="true" />
|
||||
</Link>
|
||||
<DocsThemeSwitch />
|
||||
<Drawer v-model:open="mobile">
|
||||
<DrawerTrigger as-child>
|
||||
<Button
|
||||
class="mobile-menu"
|
||||
is-icon-only
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
aria-label="打开文档目录"
|
||||
>
|
||||
<IconMenu2 :size="20" aria-hidden="true" />
|
||||
</Button>
|
||||
</DrawerTrigger>
|
||||
<DrawerBackdrop>
|
||||
<DrawerContent placement="left" class="docs-drawer-content">
|
||||
<DrawerDialog
|
||||
class="docs-drawer-dialog"
|
||||
@close-auto-focus="focusPage"
|
||||
>
|
||||
<DrawerHeader class="docs-drawer-heading">
|
||||
<DrawerHeading>文档目录</DrawerHeading>
|
||||
<DrawerCloseTrigger aria-label="关闭文档目录" />
|
||||
</DrawerHeader>
|
||||
<DrawerBody>
|
||||
<nav class="mobile-section-links" aria-label="文档栏目">
|
||||
<Link
|
||||
:href="withBase('/introduction')"
|
||||
:aria-current="section === 'guide' ? 'page' : undefined"
|
||||
@click="leaveDrawer"
|
||||
>
|
||||
快速开始
|
||||
</Link>
|
||||
<Link
|
||||
:href="withBase('/components')"
|
||||
:aria-current="
|
||||
section === 'components' ? 'page' : undefined
|
||||
"
|
||||
@click="leaveDrawer"
|
||||
>
|
||||
组件
|
||||
</Link>
|
||||
</nav>
|
||||
<Separator />
|
||||
<DocsSidebar
|
||||
:groups="groups"
|
||||
:current="current"
|
||||
label="移动端文档导航"
|
||||
@navigate="leaveDrawer"
|
||||
/>
|
||||
</DrawerBody>
|
||||
</DrawerDialog>
|
||||
</DrawerContent>
|
||||
</DrawerBackdrop>
|
||||
</Drawer>
|
||||
</div>
|
||||
</div>
|
||||
<div class="docs-nav-sections">
|
||||
<nav aria-label="主导航">
|
||||
<Link
|
||||
:href="withBase('/introduction')"
|
||||
:aria-current="section === 'guide' ? 'page' : undefined"
|
||||
>
|
||||
<IconBook2 :size="16" aria-hidden="true" />
|
||||
快速开始
|
||||
</Link>
|
||||
<Link
|
||||
:href="withBase('/components')"
|
||||
:aria-current="section === 'components' ? 'page' : undefined"
|
||||
>
|
||||
<IconComponents :size="16" aria-hidden="true" />
|
||||
组件
|
||||
</Link>
|
||||
</nav>
|
||||
<Chip class="framework" size="sm" variant="soft">
|
||||
<IconBrandVue :size="14" aria-hidden="true" />
|
||||
Vue 3
|
||||
</Chip>
|
||||
</div>
|
||||
</header>
|
||||
<div class="docs-body">
|
||||
<aside class="docs-sidebar" aria-label="文档导航">
|
||||
<div class="framework">
|
||||
<span class="vue-mark">V</span>
|
||||
Vue
|
||||
<span class="framework-note">组件库</span>
|
||||
</div>
|
||||
<section v-for="group in groups" :key="group.title">
|
||||
<h2>{{ group.title }}</h2>
|
||||
<a
|
||||
v-for="item in group.items"
|
||||
:key="item.url"
|
||||
:href="withBase(item.url)"
|
||||
:class="{ selected: selected(item.url) }"
|
||||
:aria-current="selected(item.url) ? 'page' : undefined"
|
||||
>
|
||||
{{ item.title }}
|
||||
</a>
|
||||
</section>
|
||||
<p class="community">
|
||||
独立社区实现
|
||||
<br />
|
||||
设计基线 HeroUI v3.2.6
|
||||
</p>
|
||||
<aside class="docs-sidebar" aria-label="侧栏">
|
||||
<ScrollShadow
|
||||
ref="sidebar"
|
||||
class="docs-sidebar-scroll"
|
||||
:hide-scroll-bar="false"
|
||||
>
|
||||
<DocsSidebar :groups="groups" :current="current" />
|
||||
<p class="community">
|
||||
独立社区实现
|
||||
<br />
|
||||
设计基线 HeroUI v3.2.6
|
||||
</p>
|
||||
</ScrollShadow>
|
||||
</aside>
|
||||
<main id="main" class="docs-main">
|
||||
<div class="breadcrumb">
|
||||
{{ frontmatter.group ?? "文档" }}
|
||||
<span>›</span>
|
||||
{{ frontmatter.title }}
|
||||
</div>
|
||||
<h1>{{ frontmatter.title }}</h1>
|
||||
<p class="page-description">{{ frontmatter.description }}</p>
|
||||
<div v-if="frontmatter.component" class="source-links">
|
||||
<a
|
||||
:href="`https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/react/src/components/${frontmatter.component}`"
|
||||
<div v-if="headers.length" class="mobile-toc">
|
||||
<Popover v-model:open="tocOpen" is-non-modal>
|
||||
<PopoverTrigger as-child>
|
||||
<Button variant="ghost" size="sm">
|
||||
<IconList :size="16" aria-hidden="true" />
|
||||
本页内容
|
||||
<IconChevronDown :size="14" aria-hidden="true" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent
|
||||
placement="bottom start"
|
||||
class="mobile-toc-content"
|
||||
@close-auto-focus="finishTocNavigation"
|
||||
>
|
||||
<PopoverDialog>
|
||||
<PopoverHeading class="sr-only">本页内容</PopoverHeading>
|
||||
<DocsToc
|
||||
:headers="headers"
|
||||
:active="activeSlug"
|
||||
@navigate="navigateToc"
|
||||
/>
|
||||
</PopoverDialog>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
<main id="main" class="docs-main" tabindex="-1">
|
||||
<nav aria-label="面包屑">
|
||||
<Breadcrumbs class="breadcrumb" aria-label="页面路径">
|
||||
<BreadcrumbsItem
|
||||
:href="
|
||||
withBase(
|
||||
section === 'components' ? '/components' : '/introduction',
|
||||
)
|
||||
"
|
||||
>
|
||||
{{ section === "components" ? "组件" : "快速开始" }}
|
||||
</BreadcrumbsItem>
|
||||
<BreadcrumbsItem>{{ frontmatter.title }}</BreadcrumbsItem>
|
||||
</Breadcrumbs>
|
||||
</nav>
|
||||
<h1 tabindex="-1">{{ frontmatter.title }}</h1>
|
||||
<p v-if="frontmatter.description" class="page-description">
|
||||
{{ frontmatter.description }}
|
||||
</p>
|
||||
<div v-if="componentSlug" class="source-links">
|
||||
<Link
|
||||
:href="`https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/react/src/components/${componentSlug}`"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
React 参考源码
|
||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
||||
</a>
|
||||
<a
|
||||
:href="`https://github.com/heroui-inc/heroui/blob/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/styles/components/${frontmatter.component}.css`"
|
||||
<IconArrowUpRight :size="12" aria-hidden="true" />
|
||||
</Link>
|
||||
<Link
|
||||
:href="`https://github.com/heroui-inc/heroui/blob/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/styles/components/${componentSlug}.css`"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
rel="noreferrer noopener"
|
||||
>
|
||||
样式源码
|
||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
||||
</a>
|
||||
<IconArrowUpRight :size="12" aria-hidden="true" />
|
||||
</Link>
|
||||
</div>
|
||||
<div @click="copyMarkdownCode"><Content class="docs-content" /></div>
|
||||
<nav class="page-navigation" aria-label="相邻页面">
|
||||
<a v-if="previous" :href="withBase(previous.url)">
|
||||
<span>上一页</span>
|
||||
<strong>{{ previous.title }}</strong>
|
||||
</a>
|
||||
<a v-if="next" class="page-next" :href="withBase(next.url)">
|
||||
<span>下一页</span>
|
||||
<strong>{{ next.title }}</strong>
|
||||
</a>
|
||||
<Card
|
||||
v-if="adjacent.previous"
|
||||
as="a"
|
||||
:href="withBase(adjacent.previous.url)"
|
||||
class="page-prev"
|
||||
variant="transparent"
|
||||
>
|
||||
<IconArrowLeft :size="18" aria-hidden="true" />
|
||||
<span>
|
||||
上一页
|
||||
<strong>{{ adjacent.previous.title }}</strong>
|
||||
</span>
|
||||
</Card>
|
||||
<Card
|
||||
v-if="adjacent.next"
|
||||
as="a"
|
||||
:href="withBase(adjacent.next.url)"
|
||||
class="page-next"
|
||||
variant="transparent"
|
||||
>
|
||||
<span>
|
||||
下一页
|
||||
<strong>{{ adjacent.next.title }}</strong>
|
||||
</span>
|
||||
<IconArrowRight :size="18" aria-hidden="true" />
|
||||
</Card>
|
||||
</nav>
|
||||
<footer class="docs-footer">
|
||||
基于 HeroUI v3 设计的 Vue 实现 ·
|
||||
<a :href="withBase('/introduction')">实现范围与差异</a>
|
||||
<Link :href="withBase('/introduction')">实现范围与差异</Link>
|
||||
</footer>
|
||||
</main>
|
||||
<aside v-if="headers.length" class="docs-toc" aria-label="本页目录">
|
||||
<p>本页内容</p>
|
||||
<template v-for="h in headers" :key="h.slug">
|
||||
<a
|
||||
:href="'#' + h.slug"
|
||||
:class="{ current: activeSlug === h.slug }"
|
||||
:aria-current="activeSlug === h.slug ? 'location' : undefined"
|
||||
>
|
||||
{{ h.title }}
|
||||
</a>
|
||||
<a
|
||||
v-for="child in h.children"
|
||||
:key="child.slug"
|
||||
class="nested"
|
||||
:class="{ current: activeSlug === child.slug }"
|
||||
:aria-current="activeSlug === child.slug ? 'location' : undefined"
|
||||
:href="'#' + child.slug"
|
||||
>
|
||||
{{ child.title }}
|
||||
</a>
|
||||
</template>
|
||||
<aside v-if="headers.length" class="docs-toc" aria-label="本页目录区域">
|
||||
<p>
|
||||
<IconList :size="16" aria-hidden="true" />
|
||||
本页内容
|
||||
</p>
|
||||
<ScrollShadow class="docs-toc-scroll">
|
||||
<DocsToc :headers="headers" :active="activeSlug" />
|
||||
</ScrollShadow>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import type { Theme } from "vitepress";
|
||||
import { IconCopy, IconCheck } from "@tabler/icons-vue";
|
||||
import { Button } from "@heroui-vue/components";
|
||||
import DocsComponents from "./DocsComponents.vue";
|
||||
import Layout from "./Layout.vue";
|
||||
import Demo from "./Demo.vue";
|
||||
import "@heroui-vue/styles/css";
|
||||
import "./utilities.css";
|
||||
import "./style.css";
|
||||
import "./shell.css";
|
||||
export default {
|
||||
Layout,
|
||||
enhanceApp({ app }) {
|
||||
app.component("ComponentPreview", Demo);
|
||||
app.component("DocsCopyButton", Button);
|
||||
app.component("DocsComponents", DocsComponents);
|
||||
app.component("DocsCopyIcon", IconCopy);
|
||||
app.component("DocsCheckIcon", IconCheck);
|
||||
},
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
/** Local manifest in pinned HeroUI meta.json order. Only real Vue pages belong here.
|
||||
* Sidebar, overview, breadcrumbs, previous/next and tests share this data. */
|
||||
export interface DocsItem {
|
||||
title: string;
|
||||
url: string;
|
||||
category?: string;
|
||||
}
|
||||
export interface DocsGroup {
|
||||
title: string;
|
||||
items: DocsItem[];
|
||||
}
|
||||
export const componentItems: DocsItem[] = [
|
||||
{
|
||||
title: "Accordion 手风琴",
|
||||
url: "/components/accordion",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Alert 警告",
|
||||
url: "/components/alert",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "AlertDialog 警告对话框",
|
||||
url: "/components/alert-dialog",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "Avatar 头像",
|
||||
url: "/components/avatar",
|
||||
category: "media",
|
||||
},
|
||||
{
|
||||
title: "AvatarGroup 头像组",
|
||||
url: "/components/avatar-group",
|
||||
category: "media",
|
||||
},
|
||||
{
|
||||
title: "Badge 徽章",
|
||||
url: "/components/badge",
|
||||
category: "data-display",
|
||||
},
|
||||
{
|
||||
title: "Breadcrumbs 面包屑",
|
||||
url: "/components/breadcrumbs",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Button 按钮",
|
||||
url: "/components/button",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "ButtonGroup 按钮组",
|
||||
url: "/components/button-group",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "Card 卡片",
|
||||
url: "/components/card",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Checkbox 复选框",
|
||||
url: "/components/checkbox",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "CheckboxGroup 复选框组",
|
||||
url: "/components/checkbox-group",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Chip 标签",
|
||||
url: "/components/chip",
|
||||
category: "data-display",
|
||||
},
|
||||
{
|
||||
title: "CloseButton 关闭按钮",
|
||||
url: "/components/close-button",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "DateField 日期字段",
|
||||
url: "/components/date-field",
|
||||
category: "date-and-time",
|
||||
},
|
||||
{
|
||||
title: "Description 描述",
|
||||
url: "/components/description",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Disclosure 折叠面板",
|
||||
url: "/components/disclosure",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "DisclosureGroup 折叠面板组",
|
||||
url: "/components/disclosure-group",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Drawer 抽屉",
|
||||
url: "/components/drawer",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "EmptyState 空状态",
|
||||
url: "/components/empty-state",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "FieldError 字段错误",
|
||||
url: "/components/field-error",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Fieldset 字段组",
|
||||
url: "/components/fieldset",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Header 标题",
|
||||
url: "/components/header",
|
||||
category: "typography",
|
||||
},
|
||||
{
|
||||
title: "Input 输入框",
|
||||
url: "/components/input",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "InputGroup 输入框组",
|
||||
url: "/components/input-group",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "InputOTP 验证码输入",
|
||||
url: "/components/input-otp",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Kbd 键盘按键",
|
||||
url: "/components/kbd",
|
||||
category: "typography",
|
||||
},
|
||||
{
|
||||
title: "Label 标签",
|
||||
url: "/components/label",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Link 链接",
|
||||
url: "/components/link",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "ListBox 列表框",
|
||||
url: "/components/list-box",
|
||||
category: "collections",
|
||||
},
|
||||
{
|
||||
title: "Meter 计量条",
|
||||
url: "/components/meter",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "Modal 模态框",
|
||||
url: "/components/modal",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "NumberField 数字输入框",
|
||||
url: "/components/number-field",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Pagination 分页",
|
||||
url: "/components/pagination",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "Popover 弹出框",
|
||||
url: "/components/popover",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "ProgressBar 进度条",
|
||||
url: "/components/progress-bar",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "ProgressCircle 环形进度条",
|
||||
url: "/components/progress-circle",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "RadioGroup 单选框组",
|
||||
url: "/components/radio-group",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "ScrollShadow 滚动阴影",
|
||||
url: "/components/scroll-shadow",
|
||||
category: "utilities",
|
||||
},
|
||||
{
|
||||
title: "SearchField 搜索框",
|
||||
url: "/components/search-field",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Select 选择器",
|
||||
url: "/components/select",
|
||||
category: "pickers",
|
||||
},
|
||||
{
|
||||
title: "Separator 分隔符",
|
||||
url: "/components/separator",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Skeleton 骨架屏",
|
||||
url: "/components/skeleton",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "Slider 滑块",
|
||||
url: "/components/slider",
|
||||
category: "controls",
|
||||
},
|
||||
{
|
||||
title: "Spinner 加载指示器",
|
||||
url: "/components/spinner",
|
||||
category: "feedback",
|
||||
},
|
||||
{
|
||||
title: "Surface 表面",
|
||||
url: "/components/surface",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Switch 开关",
|
||||
url: "/components/switch",
|
||||
category: "controls",
|
||||
},
|
||||
{
|
||||
title: "Table 表格",
|
||||
url: "/components/table",
|
||||
category: "data-display",
|
||||
},
|
||||
{
|
||||
title: "Tabs 标签页",
|
||||
url: "/components/tabs",
|
||||
category: "navigation",
|
||||
},
|
||||
{
|
||||
title: "TextArea 多行文本框",
|
||||
url: "/components/textarea",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "TextField 文本输入框",
|
||||
url: "/components/text-field",
|
||||
category: "forms",
|
||||
},
|
||||
{
|
||||
title: "Toast 轻提示",
|
||||
url: "/components/toast",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "ToggleButton 切换按钮",
|
||||
url: "/components/toggle-button",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "ToggleButtonGroup 切换按钮组",
|
||||
url: "/components/toggle-button-group",
|
||||
category: "buttons",
|
||||
},
|
||||
{
|
||||
title: "Toolbar 工具栏",
|
||||
url: "/components/toolbar",
|
||||
category: "layout",
|
||||
},
|
||||
{
|
||||
title: "Tooltip 工具提示",
|
||||
url: "/components/tooltip",
|
||||
category: "overlays",
|
||||
},
|
||||
{
|
||||
title: "Typography 排版",
|
||||
url: "/components/typography",
|
||||
category: "typography",
|
||||
},
|
||||
];
|
||||
export const guideGroups: DocsGroup[] = [
|
||||
{
|
||||
title: "概述",
|
||||
items: [
|
||||
{ title: "介绍", url: "/introduction" },
|
||||
{ title: "快速开始", url: "/guide" },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "手册",
|
||||
items: [
|
||||
{ title: "主题", url: "/themes" },
|
||||
{ title: "字段与表单基础", url: "/fields" },
|
||||
],
|
||||
},
|
||||
];
|
||||
export const componentGroups: DocsGroup[] = [
|
||||
{ title: "概述", items: [{ title: "所有组件(Vue)", url: "/components" }] },
|
||||
{ title: "组件", items: componentItems },
|
||||
];
|
||||
export const categories = [
|
||||
["buttons", "按钮"],
|
||||
["collections", "集合"],
|
||||
["colors", "颜色"],
|
||||
["controls", "控件"],
|
||||
["data-display", "数据展示"],
|
||||
["date-and-time", "日期与时间"],
|
||||
["feedback", "反馈"],
|
||||
["forms", "表单"],
|
||||
["layout", "布局"],
|
||||
["media", "媒体"],
|
||||
["navigation", "导航"],
|
||||
["overlays", "浮层"],
|
||||
["pickers", "选择器"],
|
||||
["typography", "排版"],
|
||||
["utilities", "工具"],
|
||||
] as const;
|
||||
export function docsPath(path: string, base = "/") {
|
||||
let value = path.split(/[?#]/)[0];
|
||||
if (base !== "/" && value === base.replace(/\/$/, "")) value = "/";
|
||||
if (base !== "/" && value.startsWith(base))
|
||||
value = "/" + value.slice(base.length);
|
||||
value = value.replace(/\.html$/, "").replace(/\/$/, "");
|
||||
return !value || value === "/index" ? "/introduction" : value;
|
||||
}
|
||||
export function docsSection(path: string, base = "/"): "guide" | "components" {
|
||||
const normalized = docsPath(path, base);
|
||||
return normalized === "/components" || normalized.startsWith("/components/")
|
||||
? "components"
|
||||
: "guide";
|
||||
}
|
||||
export function adjacentPages(path: string, base = "/") {
|
||||
const groups =
|
||||
docsSection(path, base) === "components" ? componentGroups : guideGroups;
|
||||
const items = groups.flatMap((group) => group.items);
|
||||
const index = items.findIndex((item) => item.url === docsPath(path, base));
|
||||
return {
|
||||
previous: index > 0 ? items[index - 1] : undefined,
|
||||
next: index >= 0 ? items[index + 1] : undefined,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,689 @@
|
||||
/* Adapted from HeroUI ce90ea3 notebook layout + global.css; see docs/upstream.md.
|
||||
* Local routes/community version replace React/Native and unavailable services. */
|
||||
:root {
|
||||
--docs-width: 1400px;
|
||||
--docs-header-height: 96px;
|
||||
--docs-sidebar-width: 220px;
|
||||
--docs-toc-width: 240px;
|
||||
}
|
||||
html {
|
||||
scroll-padding-top: 154px;
|
||||
}
|
||||
.docs-layout {
|
||||
max-width: var(--docs-width);
|
||||
margin: auto;
|
||||
}
|
||||
.docs-nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 30;
|
||||
height: var(--docs-header-height);
|
||||
background: var(--background);
|
||||
}
|
||||
.docs-nav-main {
|
||||
height: 56px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr minmax(220px, 400px) 1fr;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 0 24px;
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-brand-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
.docs-nav .brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--foreground);
|
||||
font-size: 25px;
|
||||
font-weight: 800;
|
||||
letter-spacing: -1.4px;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.docs-nav .brand .hv-chip {
|
||||
letter-spacing: 0;
|
||||
font-weight: 500;
|
||||
font-size: 11px;
|
||||
}
|
||||
.docs-nav .version {
|
||||
padding: 4px 0;
|
||||
height: auto;
|
||||
min-width: 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.version-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-width: 210px;
|
||||
}
|
||||
.version-panel p {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.version-panel .hv-link {
|
||||
font-size: 13px;
|
||||
gap: 6px;
|
||||
}
|
||||
.nav-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
.docs-github {
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-nav-sections {
|
||||
display: flex;
|
||||
height: 40px;
|
||||
align-items: flex-end;
|
||||
gap: 24px;
|
||||
padding: 0 24px;
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-nav-sections nav {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 24px;
|
||||
height: 100%;
|
||||
}
|
||||
.docs-nav-sections nav .hv-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0 0 7px;
|
||||
height: 100%;
|
||||
border-bottom: 2px solid transparent;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--muted);
|
||||
border-radius: 0;
|
||||
}
|
||||
.docs-nav-sections nav .hv-link[aria-current="page"] {
|
||||
border-color: var(--foreground);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.docs-nav-sections .framework {
|
||||
margin: 0 0 6px auto;
|
||||
}
|
||||
.docs-theme-wide {
|
||||
padding: 2px;
|
||||
border-radius: 14px;
|
||||
background: var(--default);
|
||||
gap: 0;
|
||||
}
|
||||
.docs-theme-wide .hv-toggle-button {
|
||||
min-width: 28px;
|
||||
width: 28px;
|
||||
height: 26px;
|
||||
border: 0;
|
||||
border-radius: 12px;
|
||||
padding: 4px;
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-theme-wide .hv-toggle-button[data-selected="true"] {
|
||||
background: var(--surface);
|
||||
color: var(--foreground);
|
||||
box-shadow: var(--surface-shadow);
|
||||
}
|
||||
.docs-theme-compact,
|
||||
.mobile-menu {
|
||||
display: none;
|
||||
}
|
||||
.docs-body {
|
||||
display: grid;
|
||||
grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr) var(
|
||||
--docs-toc-width
|
||||
);
|
||||
align-items: start;
|
||||
}
|
||||
.docs-sidebar {
|
||||
position: sticky;
|
||||
top: var(--docs-header-height);
|
||||
height: calc(100dvh - var(--docs-header-height));
|
||||
padding: 16px 0 8px 12px;
|
||||
}
|
||||
.docs-sidebar-scroll {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding: 8px 16px 16px 4px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: transparent transparent;
|
||||
}
|
||||
.docs-sidebar-scroll:hover,
|
||||
.docs-sidebar-scroll:focus-within {
|
||||
scrollbar-color: var(--muted) transparent;
|
||||
}
|
||||
.sidebar-tree section {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.sidebar-tree h2 {
|
||||
margin: 0;
|
||||
padding: 8px 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.sidebar-tree .hv-link {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
padding: 7px 12px;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
color: var(--muted);
|
||||
border-radius: var(--radius-field);
|
||||
word-break: keep-all;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.sidebar-tree .hv-link:hover {
|
||||
background: var(--default-soft);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.sidebar-tree .hv-link[aria-current="page"] {
|
||||
background: var(--surface);
|
||||
box-shadow: var(--surface-shadow);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.community {
|
||||
font-size: 11px;
|
||||
line-height: 1.8;
|
||||
color: var(--muted);
|
||||
padding: 16px 12px;
|
||||
}
|
||||
.docs-main {
|
||||
min-width: 0;
|
||||
padding: 32px 48px 64px;
|
||||
width: 100%;
|
||||
outline: none;
|
||||
}
|
||||
.docs-main > .page-description {
|
||||
font-size: 18px;
|
||||
line-height: 1.65;
|
||||
color: var(--muted);
|
||||
margin: 0 0 32px;
|
||||
}
|
||||
.docs-main > h1 {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
letter-spacing: -0.6px;
|
||||
margin: 16px 0;
|
||||
outline: none;
|
||||
}
|
||||
.docs-main .breadcrumb {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-main .breadcrumb .hv-link {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-main .breadcrumb [aria-current="page"] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.source-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin: -12px 0 32px;
|
||||
}
|
||||
.source-links .hv-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 5px 9px;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 7px;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.source-links .hv-link:hover {
|
||||
background: var(--default-soft);
|
||||
color: var(--foreground);
|
||||
}
|
||||
.docs-toc {
|
||||
position: sticky;
|
||||
top: var(--docs-header-height);
|
||||
height: calc(100dvh - var(--docs-header-height));
|
||||
padding: 24px 16px 16px;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.docs-toc > p {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
.docs-toc-scroll {
|
||||
max-height: calc(100% - 40px);
|
||||
overflow-y: auto;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
.toc-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.toc-links .hv-link {
|
||||
display: block;
|
||||
padding: 6px 8px 6px 12px;
|
||||
line-height: 1.5;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.toc-links .hv-link.nested {
|
||||
padding-left: 24px;
|
||||
}
|
||||
.toc-links .hv-link:hover,
|
||||
.toc-links .hv-link[aria-current="location"] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.mobile-toc {
|
||||
display: none;
|
||||
}
|
||||
.page-navigation {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
margin-top: 48px;
|
||||
}
|
||||
.page-navigation .hv-card {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 12px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.page-navigation .hv-card:hover {
|
||||
background: var(--default-soft);
|
||||
}
|
||||
.page-navigation span {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.page-navigation strong {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--foreground);
|
||||
}
|
||||
.page-navigation .page-next {
|
||||
grid-column: 2;
|
||||
justify-content: flex-end;
|
||||
text-align: right;
|
||||
}
|
||||
.docs-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
margin-top: 28px;
|
||||
padding-top: 24px;
|
||||
border-top: 1px solid var(--docs-border);
|
||||
font-size: 12px;
|
||||
line-height: 1.8;
|
||||
color: var(--muted);
|
||||
}
|
||||
.docs-footer .hv-link {
|
||||
font-size: 12px;
|
||||
}
|
||||
.components-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.component-index-card {
|
||||
padding: 18px;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 12px;
|
||||
}
|
||||
.component-index-card:hover {
|
||||
background: var(--default-soft);
|
||||
}
|
||||
.component-index-card .hv-card__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.component-index-card .hv-card__description {
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.search-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
justify-content: flex-start;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
border-radius: 12px;
|
||||
background: var(--field);
|
||||
box-shadow: var(--field-shadow);
|
||||
}
|
||||
.search-trigger .hv-kbd {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
padding: 2px 5px;
|
||||
background: var(--default);
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
box-shadow: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.docs-search-container {
|
||||
padding-top: min(16vh, 120px);
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
.search-dialog {
|
||||
width: min(620px, calc(100vw - 32px));
|
||||
max-width: 620px;
|
||||
padding: 0;
|
||||
gap: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--docs-border);
|
||||
border-radius: 16px;
|
||||
box-shadow: var(--overlay-shadow);
|
||||
}
|
||||
.search-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.docs-search-input .hv-search-field__group {
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
outline: none;
|
||||
}
|
||||
.docs-search-input .hv-search-field__input {
|
||||
font-size: 16px;
|
||||
padding: 8px 6px;
|
||||
}
|
||||
.search-close {
|
||||
padding: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.search-close .hv-kbd {
|
||||
font-size: 11px;
|
||||
border: 1px solid var(--docs-border);
|
||||
box-shadow: none;
|
||||
}
|
||||
.search-results {
|
||||
max-height: calc(65dvh - 100px);
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
.search-results .hv-link {
|
||||
display: block;
|
||||
padding: 12px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
color: var(--foreground);
|
||||
}
|
||||
.search-results .hv-link[aria-selected="true"] {
|
||||
background: var(--default);
|
||||
border-color: var(--docs-border);
|
||||
}
|
||||
.result-title {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.result-title > span {
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: var(--muted);
|
||||
}
|
||||
.result-excerpt {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
margin-top: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: var(--muted);
|
||||
}
|
||||
.search-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 32px 16px;
|
||||
min-height: 150px;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
text-align: center;
|
||||
}
|
||||
.search-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 12px 18px;
|
||||
border-top: 1px solid var(--docs-border);
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.search-footer > span:last-child {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.search-footer .hv-kbd {
|
||||
font-size: 10px;
|
||||
box-shadow: none;
|
||||
border: 0;
|
||||
}
|
||||
.docs-drawer-dialog {
|
||||
width: min(340px, 88vw);
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
border-radius: 0;
|
||||
touch-action: auto !important;
|
||||
}
|
||||
.docs-drawer-heading {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
.docs-drawer-heading [data-slot="drawer-close-trigger"] {
|
||||
position: static;
|
||||
}
|
||||
.mobile-section-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
padding: 4px 12px 16px;
|
||||
}
|
||||
.mobile-section-links .hv-link {
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.mobile-section-links [aria-current="page"] {
|
||||
color: var(--foreground);
|
||||
}
|
||||
.mobile-toc-content {
|
||||
max-height: min(60dvh, 480px);
|
||||
width: min(340px, calc(100vw - 32px));
|
||||
overflow-y: auto;
|
||||
}
|
||||
.skip {
|
||||
position: fixed;
|
||||
top: -60px;
|
||||
left: 16px;
|
||||
z-index: 100;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--surface);
|
||||
}
|
||||
.skip:focus {
|
||||
top: 8px;
|
||||
}
|
||||
@media (max-width: 1279px) {
|
||||
.docs-body {
|
||||
grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr);
|
||||
}
|
||||
.docs-toc {
|
||||
display: none;
|
||||
}
|
||||
.docs-main {
|
||||
grid-column: 2;
|
||||
padding: 20px 24px 64px;
|
||||
}
|
||||
.mobile-toc {
|
||||
display: block;
|
||||
grid-column: 2;
|
||||
position: sticky;
|
||||
top: var(--docs-header-height);
|
||||
z-index: 15;
|
||||
padding: 4px 16px;
|
||||
background: var(--background);
|
||||
border-bottom: 1px solid var(--docs-border);
|
||||
}
|
||||
.docs-sidebar {
|
||||
grid-row: 1 / span 2;
|
||||
}
|
||||
.version {
|
||||
display: none;
|
||||
}
|
||||
.docs-nav-main {
|
||||
grid-template-columns: 1fr minmax(180px, 360px) 1fr;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
:root {
|
||||
--docs-header-height: 92px;
|
||||
}
|
||||
.docs-nav-main {
|
||||
height: 56px;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
gap: 8px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.docs-nav-sections {
|
||||
height: 36px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.docs-nav-sections nav {
|
||||
gap: 20px;
|
||||
}
|
||||
.docs-nav-sections nav .hv-link {
|
||||
font-size: 13px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
.docs-sidebar {
|
||||
display: none;
|
||||
}
|
||||
.docs-body {
|
||||
display: block;
|
||||
}
|
||||
.docs-main {
|
||||
padding: 24px 20px 48px;
|
||||
}
|
||||
.docs-main > h1 {
|
||||
font-size: 28px;
|
||||
}
|
||||
.docs-main > .page-description {
|
||||
font-size: 16px;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
.docs-nav .brand {
|
||||
font-size: 23px;
|
||||
gap: 6px;
|
||||
}
|
||||
.nav-tools {
|
||||
gap: 4px;
|
||||
}
|
||||
.docs-github,
|
||||
.docs-theme-wide {
|
||||
display: none;
|
||||
}
|
||||
.docs-theme-compact,
|
||||
.mobile-menu {
|
||||
display: inline-flex;
|
||||
}
|
||||
.search-trigger {
|
||||
justify-self: end;
|
||||
min-width: 36px;
|
||||
width: 36px;
|
||||
padding: 8px;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
}
|
||||
.search-trigger span,
|
||||
.search-trigger .hv-kbd {
|
||||
display: none;
|
||||
}
|
||||
.mobile-toc {
|
||||
top: var(--docs-header-height);
|
||||
padding: 4px 12px;
|
||||
}
|
||||
.docs-search-container {
|
||||
padding-top: 12px;
|
||||
}
|
||||
.search-dialog {
|
||||
max-height: calc(100dvh - 24px);
|
||||
}
|
||||
.search-results {
|
||||
max-height: calc(70dvh - 110px);
|
||||
}
|
||||
.source-links .hv-link {
|
||||
font-size: 11px;
|
||||
}
|
||||
.components-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.page-navigation .hv-card {
|
||||
padding: 12px;
|
||||
}
|
||||
.page-navigation strong {
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
html {
|
||||
scroll-behavior: auto;
|
||||
}
|
||||
}
|
||||
.component-index-card:focus-visible,
|
||||
.page-navigation a:focus-visible {
|
||||
outline: 2px solid var(--focus);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+50
-55
@@ -1,67 +1,62 @@
|
||||
---
|
||||
title: 组件
|
||||
description: 已迁移组件及文档
|
||||
title: 所有组件(Vue)
|
||||
description: 浏览库中所有可用组件的完整列表,更多组件正在路上。
|
||||
---
|
||||
|
||||
- [Accordion 手风琴](./components/accordion)
|
||||
- [Alert 警告](./components/alert)
|
||||
- [Avatar 头像](./components/avatar)
|
||||
- [AvatarGroup 头像组](./components/avatar-group)
|
||||
- [Badge 徽章](./components/badge)
|
||||
- [Breadcrumbs 面包屑](./components/breadcrumbs)
|
||||
- [Button 按钮](./components/button)
|
||||
- [ButtonGroup 按钮组](./components/button-group)
|
||||
- [Card 卡片](./components/card)
|
||||
- [Chip 标签](./components/chip)
|
||||
- [CloseButton 关闭按钮](./components/close-button)
|
||||
- [Description 描述](./components/description)
|
||||
- [Disclosure 折叠面板](./components/disclosure)
|
||||
- [DisclosureGroup 折叠面板组](./components/disclosure-group)
|
||||
- [EmptyState 空状态](./components/empty-state)
|
||||
- [FieldError 字段错误](./components/field-error)
|
||||
- [Input 输入框](./components/input)
|
||||
- [InputGroup 输入框组](./components/input-group)
|
||||
- [Kbd 键盘按键](./components/kbd)
|
||||
- [Label 标签](./components/label)
|
||||
- [Link 链接](./components/link)
|
||||
- [Meter 计量条](./components/meter)
|
||||
- [ProgressBar 进度条](./components/progress-bar)
|
||||
- [ProgressCircle 环形进度条](./components/progress-circle)
|
||||
- [Separator 分隔符](./components/separator)
|
||||
- [Skeleton 骨架屏](./components/skeleton)
|
||||
- [Spinner 加载指示器](./components/spinner)
|
||||
- [Surface 表面](./components/surface)
|
||||
- [Switch 开关](./components/switch)
|
||||
- [TextArea 多行文本框](./components/textarea)
|
||||
- [TextField 文本输入框](./components/text-field)
|
||||
- [Typography 排版](./components/typography)
|
||||
仅展示已经实现并提供文档的 Vue 组件。各组件的支持范围与已知差异请查看对应 API 页面。
|
||||
|
||||
- [Fieldset 字段组](./components/fieldset)
|
||||
- [SearchField 搜索框](./components/search-field)
|
||||
## 按钮
|
||||
|
||||
- [Checkbox 复选框](./components/checkbox)
|
||||
- [CheckboxGroup 复选框组](./components/checkbox-group)
|
||||
- [RadioGroup 单选框组](./components/radio-group)
|
||||
<DocsComponents category="buttons" />
|
||||
|
||||
- [Modal 模态框](./components/modal)
|
||||
- [Popover 弹出框](./components/popover)
|
||||
- [Tooltip 工具提示](./components/tooltip)
|
||||
## 集合
|
||||
|
||||
- [ScrollShadow 滚动阴影](./components/scroll-shadow)
|
||||
- [Tabs 标签页](./components/tabs)
|
||||
- [Toolbar 工具栏](./components/toolbar)
|
||||
- [ToggleButton 切换按钮](./components/toggle-button)
|
||||
- [ToggleButtonGroup 切换按钮组](./components/toggle-button-group)
|
||||
<DocsComponents category="collections" />
|
||||
|
||||
- [Pagination 分页](./components/pagination)
|
||||
- [Header 标题](./components/header)
|
||||
- [InputOTP 验证码输入](./components/input-otp)
|
||||
## 控件
|
||||
|
||||
- [NumberField 数字输入框](./components/number-field)
|
||||
<DocsComponents category="controls" />
|
||||
|
||||
- [Slider 滑块](./components/slider)
|
||||
## 数据展示
|
||||
|
||||
- [DateField 日期字段](./components/date-field):日期分段输入、描述与表单校验。
|
||||
<DocsComponents category="data-display" />
|
||||
|
||||
- [Toast 轻提示](./components/toast):通知队列、Promise、独立队列与自定义布局。
|
||||
- [Table 表格](./components/table):选择、排序、列宽、加载与固定行高虚拟窗口。
|
||||
## 日期与时间
|
||||
|
||||
<DocsComponents category="date-and-time" />
|
||||
|
||||
## 反馈
|
||||
|
||||
<DocsComponents category="feedback" />
|
||||
|
||||
## 表单
|
||||
|
||||
<DocsComponents category="forms" />
|
||||
|
||||
## 布局
|
||||
|
||||
<DocsComponents category="layout" />
|
||||
|
||||
## 媒体
|
||||
|
||||
<DocsComponents category="media" />
|
||||
|
||||
## 导航
|
||||
|
||||
<DocsComponents category="navigation" />
|
||||
|
||||
## 浮层
|
||||
|
||||
<DocsComponents category="overlays" />
|
||||
|
||||
## 选择器
|
||||
|
||||
<DocsComponents category="pickers" />
|
||||
|
||||
## 排版
|
||||
|
||||
<DocsComponents category="typography" />
|
||||
|
||||
## 工具
|
||||
|
||||
<DocsComponents category="utilities" />
|
||||
|
||||
@@ -140,16 +140,16 @@ Breadcrumbs 组件使用以下 CSS 类([查看源码样式](https://github.com
|
||||
|
||||
### BreadcrumbsItem
|
||||
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------ | --------------------------- | --------- | -------------------------------------------------------------------------------- |
|
||||
| `href` | `string` | - | 链接 URL;未提供时渲染不可导航的 `span[role="link"]`,当前项与禁用项也不可导航。 |
|
||||
| `target` | `string` | `'_self'` | 链接目标;仅在带 `href` 的可导航项输出。 |
|
||||
| `rel` | `string` | - | 链接关系。 |
|
||||
| `download` | `boolean \| string` | - | 原生下载属性。 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用当前项链接。 |
|
||||
| `as` | `string` | `'li'` | 自定义项元素标签;对应上游 `render` 的元素替换。 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类;同时合并到 `li` 与内部链接。 |
|
||||
| 默认插槽 | `{ isCurrent, isDisabled }` | - | 项内容;可用作用域状态渲染条件内容。 |
|
||||
| 属性 | 类型 | 默认值 | 描述 |
|
||||
| ------------ | --------------------------- | ------- | -------------------------------------------------------------------------------- |
|
||||
| `href` | `string` | - | 链接 URL;未提供时渲染不可导航的 `span[role="link"]`,当前项与禁用项也不可导航。 |
|
||||
| `target` | `string` | — | 链接目标;省略时使用浏览器同窗口默认行为,仅为可导航项输出显式传入的值。 |
|
||||
| `rel` | `string` | - | 链接关系。 |
|
||||
| `download` | `boolean \| string` | - | 原生下载属性。 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用当前项链接。 |
|
||||
| `as` | `string` | `'li'` | 自定义项元素标签;对应上游 `render` 的元素替换。 |
|
||||
| `class` | `string \| Array \| Object` | - | 附加 CSS 类;同时合并到 `li` 与内部链接。 |
|
||||
| 默认插槽 | `{ isCurrent, isDisabled }` | - | 项内容;可用作用域状态渲染条件内容。 |
|
||||
|
||||
`li` 根节点接收除事件处理器外的 `$attrs`;`onClick`、`onKeydown`、`onFocus` 等事件绑定到真实链接,从而复用 `Link` 的禁用拦截与事件顺序。`isLast` 和 `separatorSlot` 由 `Breadcrumbs` 自动注入,不列入公开 `BreadcrumbsItemProps` 类型或 API 表,调用方无需设置。
|
||||
|
||||
|
||||
@@ -126,16 +126,16 @@ Link 使用以下 CSS 类:
|
||||
|
||||
### Link
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | ------------------- | --------- | -------------------------------------------------------------- |
|
||||
| `href` | `string` | - | 锚点的目标 URL |
|
||||
| `target` | `string` | `"_self"` | 在何处打开链接文档 |
|
||||
| `rel` | `string` | - | 当前文档与链接文档的关系 |
|
||||
| `download` | `boolean \| string` | - | 触发下载而非导航;`true` 渲染 `download`,`false`/未传省略属性 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用指针与键盘交互;保留可聚焦与 `aria-disabled` |
|
||||
| `asChild` | `boolean` | `false` | 合并到默认插槽唯一元素,并补充 `role="link"` 与 `tabindex="0"` |
|
||||
| `autoFocus` | `boolean` | - | 挂载后聚焦真实 DOM 根元素(含 asChild) |
|
||||
| `class` | `string` | - | 与默认样式合并的自定义类 |
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | ------------------- | ------- | ---------------------------------------------------------------------- |
|
||||
| `href` | `string` | - | 锚点的目标 URL |
|
||||
| `target` | `string` | — | 在何处打开链接文档;省略时使用浏览器同窗口默认行为,不输出 target 属性 |
|
||||
| `rel` | `string` | - | 当前文档与链接文档的关系 |
|
||||
| `download` | `boolean \| string` | - | 触发下载而非导航;`true` 渲染 `download`,`false`/未传省略属性 |
|
||||
| `isDisabled` | `boolean` | `false` | 禁用指针与键盘交互;保留可聚焦与 `aria-disabled` |
|
||||
| `asChild` | `boolean` | `false` | 合并到默认插槽唯一元素,并补充 `role="link"` 与 `tabindex="0"` |
|
||||
| `autoFocus` | `boolean` | - | 挂载后聚焦真实 DOM 根元素(含 asChild) |
|
||||
| `class` | `string` | - | 与默认样式合并的自定义类 |
|
||||
|
||||
默认插槽渲染链接内部内容。作用域插槽提供 `isDisabled`、`isHovered`、`isPressed`、`isFocused`、`isFocusVisible`。`@click` 等 DOM 事件通过 attrs 透传;`isDisabled` 时阻止激活(含 Vue 合并后的监听器数组)。React Aria 的 `onPress` / `PressEvent` 由原生 `click` 适配,不等价。
|
||||
|
||||
|
||||
@@ -26,13 +26,11 @@ import {
|
||||
## 组件结构
|
||||
|
||||
```vue
|
||||
<TableScrollContainer>
|
||||
<Table>
|
||||
<Table>
|
||||
<TableScrollContainer>
|
||||
<TableContent>
|
||||
<TableHeader>
|
||||
<TableRow row-key="head">
|
||||
<TableColumn>商品</TableColumn>
|
||||
</TableRow>
|
||||
<TableColumn id="name" is-row-header>商品</TableColumn>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow v-for="r in rows" :key="r.id" :row-key="r.id">
|
||||
@@ -40,8 +38,8 @@ import {
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</TableContent>
|
||||
</Table>
|
||||
</TableScrollContainer>
|
||||
</TableScrollContainer>
|
||||
</Table>
|
||||
```
|
||||
|
||||
`row-key` 为稳定行标识;`disabled-keys` 禁用选择;`v-model:selected-keys` 受控选择;`v-model:sort-descriptor` 受控排序(`aria-sort` 同步)。
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ import { Button } from "@heroui-vue/components";
|
||||
|
||||
| 命令 | 功能 |
|
||||
| -------------- | --------------- |
|
||||
| pnpm dev | 组件实验页 |
|
||||
| pnpm dev:docs | 组件文档 |
|
||||
| pnpm dev | 文档开发站 |
|
||||
| pnpm dev:docs | 文档开发站 |
|
||||
| pnpm build | 库与样式构建 |
|
||||
| pnpm typecheck | Vue 类型检查 |
|
||||
| pnpm test | 行为与 SSR 测试 |
|
||||
|
||||
+13
-133
@@ -1,142 +1,22 @@
|
||||
---
|
||||
title: Button 按钮
|
||||
description: 可点击的按钮组件,支持多种变体与状态
|
||||
component: button
|
||||
group: 组件
|
||||
title: 介绍
|
||||
description: 美观、现代的 Vue UI 组件库
|
||||
---
|
||||
|
||||
## 用法
|
||||
## 设计原则
|
||||
|
||||
```vue
|
||||
<script setup lang="ts">
|
||||
import { Button } from "@heroui-vue/components";
|
||||
</script>
|
||||
```
|
||||
以固定提交的 HeroUI v3.2.6 为设计基线,保持组件的样式、布局、文案、变体、参数语义和主题高度一致。仅在框架机制要求时转换事件、插槽、响应式状态与部件导出方式。
|
||||
|
||||
<ComponentPreview name="button-basic" />
|
||||
## 当前范围
|
||||
|
||||
## 示例
|
||||
已经提供展示、导航、表单、集合、弹层等组件,以及 DateField 日期分段输入。完整列表见[所有组件](/components),各页明确记录已知差异。左侧目录只列出实际存在的组件;未迁移的能力不以占位演示代替。
|
||||
|
||||
### 变体
|
||||
## Vue 差异
|
||||
|
||||
<ComponentPreview name="button-variants" />
|
||||
- `className` → `class`。
|
||||
- 函数 children → 作用域插槽。
|
||||
- `Card.Header` → `CardHeader` 等独立导出。
|
||||
- Input 使用 `v-model`;Switch 使用 `v-model:checked`,保留 isSelected 等上游语义属性。
|
||||
- 框架专属的 PressEvent 与原生 click 不声明等价。
|
||||
|
||||
### 尺寸
|
||||
|
||||
<ComponentPreview name="button-sizes" />
|
||||
|
||||
### 带图标
|
||||
|
||||
<ComponentPreview name="button-with-icons" />
|
||||
|
||||
### 仅图标
|
||||
|
||||
<ComponentPreview name="button-icon-only" />
|
||||
|
||||
### 加载中
|
||||
|
||||
此例固定展示上传中的外观;加载期间阻止重复提交,但保留键盘焦点。要体验开始、完成和再次上传,请使用下一例。
|
||||
|
||||
<ComponentPreview name="button-loading" />
|
||||
|
||||
### 加载中(点击触发)
|
||||
|
||||
点击“上传文件”后进入加载状态,2 秒后恢复,可重复操作。
|
||||
|
||||
<ComponentPreview name="button-loading-state" />
|
||||
|
||||
### 宽度充满
|
||||
|
||||
<ComponentPreview name="button-full-width" />
|
||||
|
||||
### 禁用状态
|
||||
|
||||
<ComponentPreview name="button-disabled" />
|
||||
|
||||
### 社交媒体按钮
|
||||
|
||||
<ComponentPreview name="button-social" />
|
||||
|
||||
### 渲染函数
|
||||
|
||||
Vue 使用 `asChild` 将按钮属性与交互合并到一个自定义原生 button,作用域插槽提供状态。对应上游 render 函数示例,不将 render prop 原样搬入 Vue。
|
||||
|
||||
<ComponentPreview name="button-render-function" />
|
||||
|
||||
### 添加自定义变体
|
||||
|
||||
可通过包装组件并添加自定义变体来扩展组件。下面使用与上游相同的 `tv` 扩展方式,提供额外的圆角与尺寸配置。
|
||||
|
||||
<ComponentPreview name="button-custom-variants" />
|
||||
|
||||
### 添加涟漪效果
|
||||
|
||||
通过组合添加涟漪。本示例使用 Vue 和 CSS 实现,支持指针、Enter 和空格触发;不直接依赖上游 React 的 m3-ripple,减少动态效果时缩短动画。
|
||||
|
||||
<ComponentPreview name="button-ripple-effect" />
|
||||
|
||||
## 自定义样式
|
||||
|
||||
### Tailwind CSS
|
||||
|
||||
<ComponentPreview name="button-custom-styles" />
|
||||
|
||||
使用标准 `class` 属性添加工具类。组件保持上游的尺寸、间距、BEM 结构与状态钩子;类名前缀改为 `hv-`。
|
||||
|
||||
```vue
|
||||
<Button class="rounded-lg">自定义圆角</Button>
|
||||
```
|
||||
|
||||
### 全局 CSS
|
||||
|
||||
```css
|
||||
@layer components {
|
||||
.hv-button--primary {
|
||||
--button-bg: oklch(0.6 0.2 300);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 样式参考
|
||||
|
||||
基础类为 `.hv-button`,变体为 `.hv-button--primary` 等;尺寸为 `.hv-button--sm` / `md` / `lg`。支持 `.hv-button--icon-only` 和 `.hv-button--full-width`。
|
||||
|
||||
### 交互状态
|
||||
|
||||
保留 `data-hovered`、`data-pressed`、`data-focused`、`data-focus-visible`、`data-pending` 状态;键盘焦点样式与鼠标焦点区分。加载期间保留焦点并阻止重复点击,通过 aria-disabled 呈现半透明的原变体颜色。
|
||||
|
||||
## API 参考
|
||||
|
||||
### Button
|
||||
|
||||
| Prop | 类型 | 默认值 | 描述 |
|
||||
| ------------ | --------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------- |
|
||||
| `variant` | `'primary' \| 'secondary' \| 'tertiary' \| 'outline' \| 'ghost' \| 'danger' \| 'danger-soft'` | `'primary'` | 视觉样式变体 |
|
||||
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 按钮尺寸 |
|
||||
| `fullWidth` | `boolean` | `false` | 是否占满容器宽度 |
|
||||
| `isDisabled` | `boolean` | `false` | 是否禁用 |
|
||||
| `isPending` | `boolean` | `false` | 是否处于加载状态 |
|
||||
| `isIconOnly` | `boolean` | `false` | 是否仅包含图标 |
|
||||
| `asChild` | `boolean` | `false` | 将属性与交互合并到默认插槽中唯一的原生 button |
|
||||
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | 原生按钮类型 |
|
||||
|
||||
### 事件与插槽
|
||||
|
||||
Vue 使用 `@click` 和默认作用域插槽。插槽提供 `isPending`、`isPressed`、`isHovered`、`isFocused`、`isFocusVisible`、`isDisabled`。原生属性、class、style、事件透传至 button。
|
||||
|
||||
`onPress` / PressEvent 与 `@click` 的事件模型不同,不宣称完全等价。初版 `disabled` / `loading` 继续作为兼容别名;新代码使用 `isDisabled` / `isPending`。`isPending` 不自动插入加载图标,采用上游的组合方式。`loading` 是相同加载语义的兼容别名,额外自动显示旋转图标;不会设置原生 disabled。`asChild` 下内容由调用者完整组合,默认插槽必须只包含一个原生 button。
|
||||
|
||||
### 作用域插槽状态
|
||||
|
||||
| 参数 | 类型 | 描述 |
|
||||
| ---------------- | --------- | -------------------------------- |
|
||||
| `isPending` | `boolean` | 是否处于加载状态 |
|
||||
| `isPressed` | `boolean` | 是否正在按下 |
|
||||
| `isHovered` | `boolean` | 是否悬停 |
|
||||
| `isFocused` | `boolean` | 是否聚焦 |
|
||||
| `isFocusVisible` | `boolean` | 是否显示键盘焦点指示器 |
|
||||
| `isDisabled` | `boolean` | 是否由禁用属性禁用,不与加载混用 |
|
||||
|
||||
## 相关组件
|
||||
|
||||
[Card 卡片](/components/card) · [Input 输入框](/components/input) · [Switch 开关](/components/switch)
|
||||
具体未覆盖能力在各组件 API 页说明。此项目为独立社区实现,不是官方 Vue 发行版。
|
||||
|
||||
@@ -9,7 +9,7 @@ description: 美观、现代的 Vue UI 组件库
|
||||
|
||||
## 当前范围
|
||||
|
||||
已迁移 Button、Card、Input、Switch 的主要视觉和组合结构,仍需完整视觉与交互验收。左侧导航只列出实际存在的组件,未迁移的组件不以占位演示代替。
|
||||
已经提供展示、导航、表单、集合、弹层等组件,以及 DateField 日期分段输入。完整列表见[所有组件](/components),各页明确记录已知差异。左侧目录只列出实际存在的组件;未迁移的能力不以占位演示代替。
|
||||
|
||||
## Vue 差异
|
||||
|
||||
|
||||
@@ -206,3 +206,7 @@ React render 自定义根类型不支持;原生 attrs/具名部件/作用域
|
||||
## M35–M36 Toast / Table 接手收尾(2026-10-24)
|
||||
|
||||
Toast 11/11 与 Table 13/13 预览、各部件 Props、文档和默认源样式已接入。队列隔离/测量/焦点/SSR 与表格导航/范围/逻辑行/响应式列宽已补齐,详见 [最终验收](./migrations/M35-M36-acceptance.md)。Table 虚拟化为固定行高窗口,不导出 RAC TableLayout,不声称可变行高/拖放/完整 RAC API。读屏、真机、Nuxt 和自动逐像素未验。
|
||||
|
||||
## DOCS-01 文档架构(2026-10-24)
|
||||
|
||||
文档分区导航、布局尺寸、组件分类、预览/代码折叠按固定基线对齐,公共控件复用本库组件。缺少的公共 ComboBox、Table 不在本轮插入迁移,搜索结果和 Markdown API 表保留原生语义。Link/BreadcrumbsItem 省略 target 时不输出该属性,仍为浏览器默认同窗口行为;显式 target 保留。验证范围、视觉差异与未验收项见 [DOCS-01](migrations/DOCS-01-shell-alignment.md)。
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# DOCS-01:文档架构与公共控件对齐
|
||||
|
||||
本轮在 DateField 合入 main 后实施,按用户要求暂停 Calendar/YearPicker,优先调整文档整体结构与体验。固定参考 HeroUI v3.2.6 / ce90ea3,不追随上游后续变化。
|
||||
|
||||
## 对齐范围
|
||||
|
||||
- 参考 notebook layout/sidebar/page/toc、global.css、中文组件 meta 与 overview、component-preview-container、component-source/codeblock-client、version-selector/frameworks-tabs/search-dialog。
|
||||
- 双层顶部导航 56+40px;移动端 56+36px;布局最大宽 1400px、侧栏 220px、右侧目录 240px,按断点显示。正文间距、标题、来源链接、前后页、代码与预览统一维护。
|
||||
- `navigation.ts` 是已实现页面、分区、顺序和分类的唯一清单。“快速开始”和“组件”显示各自侧栏;组件总览按官方分类展示实际可用页面,不为未迁移组件创建假链接。首页是介绍,不再重复 Button。
|
||||
- 桌面侧栏与移动 Drawer 共用导航;桌面目录与移动 Popover 共用章节数据。移动目录关闭后再执行 hash 路由、焦点与滚动,防止弹层焦点恢复把页面拉回顶部。
|
||||
- 使用 Button、Link、Chip、Separator、Breadcrumbs、ToggleButtonGroup、Popover、Drawer、ScrollShadow、Card,以及搜索用的 Modal、SearchField、Kbd、EmptyState。图标继续使用 Tabler Vue。
|
||||
- 搜索结果保留原生 ARIA combobox/listbox 结构;尚无公共 ComboBox,不用会移动输入焦点的 ListBox 代替。Markdown API 表仍为语义 table,保留满宽、固定布局、长内容换行和短表不收缩要求。分类卡片使用文字介绍,未复制上游 CDN 缩略图。
|
||||
|
||||
## 示例、样式和导航修正
|
||||
|
||||
- 预览区域最小 350px,桌面 40px / 移动 16px 内边距;代码默认 150px 折叠、渐隐并提供底部展开。预览、复制与高亮继续来自同一 SFC。
|
||||
- 演示组件按需加载;高亮在接近视口或展开时加载,卸载清理 observer 和异步代次。原始源码仍随索引导入,不宣称已解决所有包体积问题。
|
||||
- Markdown 代码复制改用库 Button,30px 控件内居中 16px 图标,保留键盘、复制反馈与失败提示。
|
||||
- 删除无层级的全局 button/input 字体及按钮 cursor 覆盖,避免文档 CSS 压过库组件变体。演示继续隔离 prose 样式。
|
||||
- Link 保留调用方 role/tabindex;Link 与 BreadcrumbsItem 不再无条件输出 `target="_self"`,省略时仍为浏览器默认同窗口导航。显式 target 保留,文档 SPA 路由不再被隐式 target 阻止。这是实现修正,不引入 Vue Router 依赖。
|
||||
- 搜索索引涵盖实际根文档和组件文档,支持方向键、Enter、Escape、快捷键与 IME 守卫;打开聚焦输入,关闭恢复触发器,导航后保留目标章节焦点。
|
||||
- 隐藏目录 `.vitepress/theme` 的运行时 TS/Vue 文件明确纳入 vue-tsc。未升级 VitePress,也未把其既有 Vite 5/根 Vite 7 配置类型差异描述为已解决。
|
||||
|
||||
## 验证与边界
|
||||
|
||||
- 完整 Vitest:59 文件 / 795 项通过;新增文档清单、分区导航、真实搜索索引、搜索焦点/IME/键盘、同源代码、移动菜单和目录关闭跳转回归。类型检查通过。
|
||||
- 5174 真实浏览器重点检查安装代码复制、图标居中、展开源码与高亮、搜索 isPending 的方向键/Enter 跳转及 Escape 焦点恢复、深色/跟随系统、桌面目录。Button 两张表在 1280px 视口均宽 724px,scrollWidth=clientWidth,页面无横向溢出。
|
||||
- 390px iframe 实际响应式视口检查移动菜单、分区切换与目录跳转。修复后“表单”目录关闭并聚焦对应标题,内容在固定头部下可见。临时审查页面验后删除,不作为正式站点内容。
|
||||
- 这不是全部页面逐像素、完整读屏、物理触屏或全浏览器验收;保留缺失组件及上述差异。最终构建、格式与独立产物回归结果同步在 verification.md。
|
||||
@@ -24,3 +24,11 @@
|
||||
保留 main 的 Select / DateField / 日期基建、共享导出、样式、导航和测试脚本;共享追加冲突按两边内容增量合并。合并后 pnpm test:68 文件 / 849 项通过,typecheck、build:docs 和 diff 检查通过。
|
||||
|
||||
合并后的最终 tarball 另以 `*-verified.tgz` 安装到上述独立消费者;Toast/Table、Select、DateField、ListBox、Slider、M30–M32、M33–M34 共 7 份 ESM/CSS/SSR 消费脚本,以及全部契约的 bundler / NodeNext 类型正反例通过。无源码 alias;保留根目录三张旧 PNG,未提交或删除。
|
||||
|
||||
## 并行 DOCS-01 更新的最终集成
|
||||
|
||||
普通推送检测到远程新增 `671a276` 文档壳层改版,未强推;再合并该 main,保留其 Layout/分类总览/导航、Link/Breadcrumbs、搜索与样式改动。Toast/Table 加入统一 navigation.ts,按源 meta 顺序和分类显示(Table=data-display,Toast=overlays)。修正结构代码中的重复表头 tr,避免与 Header 的自动行冲突。
|
||||
|
||||
最终 pnpm test:69 文件 / 861 项通过;typecheck、build:docs、导航专项 10 项和 diff 检查通过。包含文档壳层的 `*-integrated.tgz` 再安装到同一独立消费者,7 份 ESM/CSS/SSR 脚本及全部 bundler/NodeNext 契约通过。
|
||||
|
||||
浏览器旧缓存页不能作为新壳层证据。新服务已恢复 5173,但本次最终浏览器补验落在连接失败的内部 data 页面并被工具 URL 策略阻断,未绕过;不声明已经完成合并后新文档壳层的真实浏览器复验。此前 Toast/Table 几何证据和 DOCS-01 独立报告的验证分别保留,未升级为全站视觉验收。
|
||||
|
||||
@@ -51,6 +51,6 @@ Menu/Root、MenuItem/Root/Indicator/SubmenuIndicator、MenuSection/Root、Dropdo
|
||||
|
||||
浏览器只验关键定位、嵌套、焦点、长按和时序;不要求逐个点全部预览。代码与行为测试覆盖其余契约,同页挂载全部预览检查实例/ID/控制台。测试断言最终角色、焦点、事件与已接受值,不以 HTML 非空或文件存在代替。
|
||||
|
||||
同步 docs/compatibility.md、upstream.md(新增移植来源)、verification.md、导航和包导出;增量修改,不整文件覆盖。分别写 M37-menu.md、M38-dropdown.md:源契约→实现→断言/浏览器/产物证据→真实差异。未验读屏/真机/Nuxt/逐像素如实列出;初期审计和历史失败不冒充最终验收。提交前 git diff --check、检查未提交截图未入暂存,交回复核,不替集成人合 main。
|
||||
同步 docs/compatibility.md、upstream.md(新增移植来源)、verification.md、导航(统一维护 apps/docs/.vitepress/theme/navigation.ts)和包导出;增量修改,不整文件覆盖。分别写 M37-menu.md、M38-dropdown.md:源契约→实现→断言/浏览器/产物证据→真实差异。未验读屏/真机/Nuxt/逐像素如实列出;初期审计和历史失败不冒充最终验收。提交前 git diff --check、检查未提交截图未入暂存,交回复核,不替集成人合 main。
|
||||
|
||||
当前 main 的 DateField 工作流另有文档站对齐优先约定;本提示词作为后续候选保留,尚未派发或启动,按用户下一步安排执行。
|
||||
|
||||
@@ -192,3 +192,7 @@ M18–M20 的标签桥接在 Vue 使用 indicator 注册表与 SSR 直接/原生
|
||||
## M35–M36 Toast / Table(2026-10-24 接手收尾)
|
||||
|
||||
固定 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`:`packages/react/src/components/toast`、`table`,`packages/styles/components/toast.css`、`table.css` 与对应 tv,中文 `(overlays)/toast.mdx`、`(data-display)/table.mdx` 及 `demos/cn/toast` 11 例、`table` 13 例。样式/默认图标保留 Apache-2.0 来源,演示图标采用 Tabler Vue。DOM/data-state/退出/测量及原生表格布局适配见 M35/M36 报告;没有依赖相邻 React 仓库构建。
|
||||
|
||||
## DOCS-01 文档布局来源(2026-10-24)
|
||||
|
||||
固定 ce90ea3 的 `apps/docs/src/components/fumadocs/layouts/notebook`、page/toc、`apps/docs/src/app/global.css`、中文组件 meta/overview、component-preview-container、component-source/codeblock-client 与版本/框架/搜索控件。布局尺寸、导航分区、示例结构适配到 VitePress 和本库 Vue 组件,保留 HeroUI Apache-2.0 来源声明;没有运行时依赖相邻仓库。分类缩略图未复制,缺失组件与搜索/Table 原生语义保留项见 [DOCS-01](migrations/DOCS-01-shell-alignment.md)。
|
||||
|
||||
@@ -867,3 +867,14 @@ typecheck、build:docs、build:playground、format、diff-check 与 dist 正反
|
||||
最终记录见 [M35–M36 验收](./migrations/M35-M36-acceptance.md),历史五轮 review 只是失败/返修过程,不代替当前实现范围。任务分支 59 文件/747 项、typecheck、build:docs、真实 node SSR/重建队列水合通过;独立 tarball 与合并结果以验收记录为准。重点浏览器证实 Toast 展开几何、Table 40px 实际列宽增量及 1000 行虚拟窗口导航;未声明完整读屏、真机、Nuxt 或自动逐像素。
|
||||
|
||||
M35/M36 合并最新 main 后:68 文件/849 项、typecheck、build:docs 通过;7 份独立 ESM/CSS/SSR 消费脚本及所有契约的 bundler/NodeNext 类型正反例通过,包含 Select/DateField 的已有产物回归。消费目录 /private/tmp/heroui-m35-final-consumer,最终文件名 *-verified.tgz。
|
||||
|
||||
## DOCS-01 文档壳层验收(2026-10-24)
|
||||
|
||||
- 完整测试 **59 文件 / 795 项通过**,typecheck、build:docs(两库及静态页渲染)、全仓 Prettier 和 git diff --check 通过;仍有既存文档 chunk 超过 500kB 提示。
|
||||
- 新增 10 项壳层回归,覆盖真实页面清单/分区/分类、根路径与 base、真实搜索索引、搜索键盘/IME/焦点、示例源码展开及移动目录关闭后的路由与焦点。Link 追加 role/tabindex 和 target 透传回归。Select 异步重试测试改用 VTU trigger,避开同毫秒原生 click 被 Vue 事件时间戳过滤,不改产品逻辑或削弱断言。
|
||||
- 5174 浏览器验证代码复制的实际文本、30px 按钮与 16px 图标中心一致、示例 Shiki、搜索 isPending/方向键/Enter/目标章节焦点、Escape 恢复触发器、主题切换及桌面目录。Button 长短两表均 724px,scrollWidth=clientWidth,页面无横向溢出。
|
||||
- 390px iframe 验证移动导航分区和目录关闭跳转;修复隐式 target 导致全页刷新、Popover 关闭恢复焦点拉回页面顶部两处问题。截图 `/private/tmp/heroui-docs-shell-review.png`、`/private/tmp/heroui-docs-mobile-review.png`;临时验收 HTML 已删除。未声称物理触屏、完整读屏、全页面逐像素或跨浏览器验收。
|
||||
- 最新 components tarball 重新安装到 `/private/tmp/heroui-slider-consumer`,DateField、Select、ListBox、M33–M34 的 ESM/Node SSR/CSS 与 NodeNext/bundler 严格正反类型消费回归通过,没有源码 alias。
|
||||
- 布局来源、已替换控件及原生搜索结果/API table 保留原因见 [DOCS-01](migrations/DOCS-01-shell-alignment.md)。本轮不继续迁移 Calendar/YearPicker。
|
||||
|
||||
最终又合入并行推送的 DOCS-01(671a276),Toast/Table 纳入 navigation.ts 的唯一清单和分类。69 文件/861 项、typecheck、build:docs、10 项文档清单专项通过;*-integrated.tgz 的 7 份独立消费脚本与两种类型解析契约通过。合并后新壳层浏览器补验受 URL 策略阻断,未把旧缓存视作验收、未绕过,详情见 M35-M36-acceptance。
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
"build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build",
|
||||
"typecheck": "vue-tsc --noEmit",
|
||||
"test": "vitest run",
|
||||
"test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts tests/toolbar.test.ts tests/m29-review.probe.test.ts tests/m30-m32-review.probe.test.ts tests/pagination.test.ts tests/header.test.ts tests/input-otp.test.ts tests/number-field-foundation.test.ts tests/number-field.test.ts tests/slider-foundation.test.ts tests/slider.test.ts tests/collection-state.test.ts tests/collection-foundation.test.ts tests/list-box.test.ts tests/alert-dialog.test.ts tests/drawer.test.ts tests/m33-m34-review.probe.test.ts tests/m33-m34-lifecycle-review.probe.test.ts tests/m33-m34-coexist.test.ts tests/select.test.ts tests/date-value.test.ts tests/date-model.test.ts tests/date-foundation.test.ts tests/date-field.test.ts tests/date-field-demos.test.ts tests/toast.test.ts tests/table.test.ts tests/m35-m36-takeover.test.ts tests/m35-m36-review.probe.test.ts tests/m35-m36-review-2.probe.test.ts tests/m35-m36-review-3.probe.test.ts tests/m35-m36-review-4.probe.test.ts tests/m35-m36-review-5.probe.test.ts tests/m35-m36-hydration.test.ts",
|
||||
"test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts tests/toolbar.test.ts tests/m29-review.probe.test.ts tests/m30-m32-review.probe.test.ts tests/pagination.test.ts tests/header.test.ts tests/input-otp.test.ts tests/number-field-foundation.test.ts tests/number-field.test.ts tests/slider-foundation.test.ts tests/slider.test.ts tests/collection-state.test.ts tests/collection-foundation.test.ts tests/list-box.test.ts tests/alert-dialog.test.ts tests/drawer.test.ts tests/m33-m34-review.probe.test.ts tests/m33-m34-lifecycle-review.probe.test.ts tests/m33-m34-coexist.test.ts tests/select.test.ts tests/date-value.test.ts tests/date-model.test.ts tests/date-foundation.test.ts tests/date-field.test.ts tests/date-field-demos.test.ts tests/toast.test.ts tests/table.test.ts tests/m35-m36-takeover.test.ts tests/m35-m36-review.probe.test.ts tests/m35-m36-review-2.probe.test.ts tests/m35-m36-review-3.probe.test.ts tests/m35-m36-review-4.probe.test.ts tests/m35-m36-review-5.probe.test.ts tests/m35-m36-hydration.test.ts tests/docs-shell.test.ts",
|
||||
"test:ssr": "vitest run tests/ssr.test.ts tests/input-otp-ssr.test.ts tests/slider-foundation-ssr.test.ts tests/slider-ssr.test.ts tests/collection-foundation-ssr.test.ts tests/list-box-ssr.test.ts tests/select-ssr.test.ts tests/date-foundation-ssr.test.ts tests/date-field-ssr.test.ts tests/m35-m36-ssr.test.ts",
|
||||
"format": "prettier --check .",
|
||||
"format:fix": "prettier --write .",
|
||||
|
||||
@@ -63,7 +63,7 @@ export default defineComponent({
|
||||
},
|
||||
target: {
|
||||
type: String,
|
||||
default: "_self",
|
||||
default: undefined,
|
||||
},
|
||||
rel: {
|
||||
type: String,
|
||||
|
||||
@@ -26,7 +26,7 @@ const props = withDefaults(
|
||||
autoFocus?: boolean;
|
||||
}>(),
|
||||
{
|
||||
target: "_self",
|
||||
target: undefined,
|
||||
isDisabled: false,
|
||||
asChild: false,
|
||||
},
|
||||
@@ -263,8 +263,12 @@ defineExpose({
|
||||
:rel="rel"
|
||||
:download="downloadAttr"
|
||||
:class="slots.base()"
|
||||
:role="asChild ? 'link' : undefined"
|
||||
:tabindex="disabled ? -1 : asChild ? 0 : undefined"
|
||||
:role="(attrs.role as string | undefined) ?? (asChild ? 'link' : undefined)"
|
||||
:tabindex="
|
||||
disabled
|
||||
? -1
|
||||
: ((attrs.tabindex as number | undefined) ?? (asChild ? 0 : undefined))
|
||||
"
|
||||
:aria-disabled="disabled || undefined"
|
||||
:data-hovered="(!disabled && hovered) || undefined"
|
||||
:data-pressed="(!disabled && pressed) || undefined"
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import { mount, flushPromises, DOMWrapper } from "@vue/test-utils";
|
||||
import { nextTick } from "vue";
|
||||
import {
|
||||
componentItems,
|
||||
componentGroups,
|
||||
guideGroups,
|
||||
docsPath,
|
||||
docsSection,
|
||||
adjacentPages,
|
||||
} from "../apps/docs/.vitepress/theme/navigation";
|
||||
import { searchIndex } from "virtual:docs-data";
|
||||
import { searchDocs } from "../apps/docs/.vitepress/theme/search";
|
||||
const host = vi.hoisted(() => ({
|
||||
route: { path: "/components/button" },
|
||||
page: { headers: [] as { title: string; slug: string; children: [] }[] },
|
||||
go: vi.fn(),
|
||||
}));
|
||||
vi.mock("vitepress", async () => {
|
||||
const { reactive, ref } = await import("vue");
|
||||
const route = reactive(host.route);
|
||||
host.route = route;
|
||||
const data = {
|
||||
site: ref({ base: "/" }),
|
||||
frontmatter: ref({ title: "Button 按钮", description: "按钮说明" }),
|
||||
page: ref(host.page),
|
||||
isDark: ref(false),
|
||||
};
|
||||
host.page = data.page.value;
|
||||
const router = {
|
||||
go: host.go.mockImplementation(async (value: string) => {
|
||||
route.path = value;
|
||||
}),
|
||||
};
|
||||
return {
|
||||
withBase: (value: string) => value,
|
||||
useRoute: () => route,
|
||||
useData: () => data,
|
||||
onContentUpdated: () => {},
|
||||
useRouter: () => router,
|
||||
};
|
||||
});
|
||||
import Layout from "../apps/docs/.vitepress/theme/Layout.vue";
|
||||
import DocSearch from "../apps/docs/.vitepress/theme/DocSearch.vue";
|
||||
import Demo from "../apps/docs/.vitepress/theme/Demo.vue";
|
||||
const wrappers: ReturnType<typeof mount>[] = [];
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
host.go.mockImplementation(async (value: string) => {
|
||||
host.route.path = value;
|
||||
});
|
||||
host.page.headers = [];
|
||||
const storage = new Map<string, string>();
|
||||
vi.stubGlobal("localStorage", {
|
||||
getItem: (key: string) => storage.get(key) ?? null,
|
||||
setItem: (key: string, value: string) => storage.set(key, String(value)),
|
||||
removeItem: (key: string) => storage.delete(key),
|
||||
clear: () => storage.clear(),
|
||||
key: (index: number) => [...storage.keys()][index] ?? null,
|
||||
get length() {
|
||||
return storage.size;
|
||||
},
|
||||
});
|
||||
Object.defineProperty(HTMLElement.prototype, "scrollIntoView", {
|
||||
value: vi.fn(),
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
});
|
||||
afterEach(() => {
|
||||
wrappers.splice(0).forEach((w) => w.unmount());
|
||||
document.body.innerHTML = "";
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
function fixture(component: never, options = {}) {
|
||||
const w = mount(component, { attachTo: document.body, ...options });
|
||||
wrappers.push(w);
|
||||
return w;
|
||||
}
|
||||
function keyboard(element: Element, key: string, extras = {}) {
|
||||
element.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
...extras,
|
||||
}),
|
||||
);
|
||||
}
|
||||
function input() {
|
||||
return document.querySelector<HTMLInputElement>(
|
||||
'[role="combobox"][aria-controls="doc-search-results"]',
|
||||
)!;
|
||||
}
|
||||
async function search(text: string) {
|
||||
input().value = text;
|
||||
input().dispatchEvent(new Event("input", { bubbles: true }));
|
||||
await flushPromises();
|
||||
}
|
||||
describe("documentation structure", () => {
|
||||
it("makes every existing component page reachable exactly once in navigation and its category overview", () => {
|
||||
const pages = readdirSync("apps/docs/components")
|
||||
.filter((name) => name.endsWith(".md"))
|
||||
.map((name) => "/components/" + name.slice(0, -3))
|
||||
.sort();
|
||||
expect(componentItems.map((item) => item.url).sort()).toEqual(pages);
|
||||
expect(new Set(componentItems.map((item) => item.url)).size).toBe(
|
||||
componentItems.length,
|
||||
);
|
||||
const overview = readFileSync("apps/docs/components.md", "utf8");
|
||||
for (const item of componentItems)
|
||||
expect(overview).toContain(`category="${item.category}"`);
|
||||
for (const group of [...guideGroups, ...componentGroups])
|
||||
for (const item of group.items)
|
||||
expect(readFileSync("apps/docs" + item.url + ".md", "utf8")).toContain(
|
||||
"title:",
|
||||
);
|
||||
});
|
||||
it("normalizes root, html, hashes and deployed base paths without confusing guide and component routes", () => {
|
||||
expect(docsPath("/docs/", "/docs/")).toBe("/introduction");
|
||||
expect(docsPath("/docs", "/docs/")).toBe("/introduction");
|
||||
expect(docsPath("/docs/components/button.html#api", "/docs/")).toBe(
|
||||
"/components/button",
|
||||
);
|
||||
expect(docsSection("/components.html")).toBe("components");
|
||||
expect(docsSection("/components-other")).toBe("guide");
|
||||
expect(adjacentPages("/components/button").next?.url).toBe(
|
||||
"/components/button-group",
|
||||
);
|
||||
expect(adjacentPages("/components/textarea").next?.url).toBe(
|
||||
"/components/text-field",
|
||||
);
|
||||
expect(adjacentPages("/introduction").previous).toBeUndefined();
|
||||
expect(adjacentPages("/not-found").next).toBeUndefined();
|
||||
});
|
||||
it("searches the actual fields and overview pages as well as component APIs", () => {
|
||||
expect(searchIndex.some((entry) => entry.url === "/fields")).toBe(true);
|
||||
expect(searchIndex.some((entry) => entry.url === "/components")).toBe(true);
|
||||
expect(
|
||||
searchDocs(searchIndex, "isPending").some((entry) =>
|
||||
entry.url.startsWith("/components/button#"),
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
it("switches sidebar and previous/next from the current route, independently of optional component frontmatter", async () => {
|
||||
const route = host.route;
|
||||
route.path = "/components/button";
|
||||
const w = fixture(Layout as never, {
|
||||
global: {
|
||||
stubs: {
|
||||
Content: { template: '<div><h2 id="button">Button</h2></div>' },
|
||||
},
|
||||
},
|
||||
});
|
||||
await flushPromises();
|
||||
expect(
|
||||
w.get('.docs-sidebar [aria-current="page"]').attributes("href"),
|
||||
).toBe("/components/button");
|
||||
expect(w.findAll(".docs-sidebar a").length).toBe(componentItems.length + 1);
|
||||
expect(w.get(".page-navigation .page-next").attributes("href")).toBe(
|
||||
"/components/button-group",
|
||||
);
|
||||
route.path = "/guide";
|
||||
await nextTick();
|
||||
await flushPromises();
|
||||
expect(w.findAll(".docs-sidebar a")).toHaveLength(4);
|
||||
expect(
|
||||
w.get('.docs-sidebar [aria-current="page"]').attributes("href"),
|
||||
).toBe("/guide");
|
||||
expect(w.get(".page-navigation .page-next").attributes("href")).toBe(
|
||||
"/themes",
|
||||
);
|
||||
});
|
||||
});
|
||||
describe("documentation search using library fields and Modal", () => {
|
||||
it("focuses input, preserves option ARIA and skips IME navigation", async () => {
|
||||
const w = fixture(DocSearch as never);
|
||||
await w.get('button[aria-label="搜索文档"]').trigger("click");
|
||||
await flushPromises();
|
||||
expect(document.activeElement).toBe(input());
|
||||
expect(input().getAttribute("aria-activedescendant")).toBeNull();
|
||||
await search("isPending");
|
||||
const option = document.getElementById("search-result-0")!;
|
||||
expect(option.getAttribute("role")).toBe("option");
|
||||
expect(option.getAttribute("tabindex")).toBe("-1");
|
||||
keyboard(input(), "ArrowDown", { isComposing: true });
|
||||
await nextTick();
|
||||
expect(input().getAttribute("aria-activedescendant")).toBe(
|
||||
"search-result-0",
|
||||
);
|
||||
keyboard(input(), "ArrowDown");
|
||||
await nextTick();
|
||||
expect(input().getAttribute("aria-activedescendant")).toBe(
|
||||
"search-result-1",
|
||||
);
|
||||
keyboard(input(), "Escape");
|
||||
await flushPromises();
|
||||
expect(document.querySelector('[data-slot="modal-dialog"]')).toBeNull();
|
||||
});
|
||||
it("restores trigger focus after Escape and opens with the keyboard shortcut", async () => {
|
||||
const w = fixture(DocSearch as never);
|
||||
const trigger = w.get('button[aria-label="搜索文档"]')
|
||||
.element as HTMLButtonElement;
|
||||
trigger.focus();
|
||||
keyboard(document.body, "k", { ctrlKey: true });
|
||||
await flushPromises();
|
||||
expect(document.activeElement).toBe(input());
|
||||
await search("no-such-component-xyz");
|
||||
expect(document.querySelector('[role="status"]')?.textContent).toContain(
|
||||
"没有找到",
|
||||
);
|
||||
keyboard(input(), "Escape");
|
||||
await flushPromises();
|
||||
expect(document.activeElement).toBe(trigger);
|
||||
});
|
||||
});
|
||||
it("keeps preview expand/copy controls as library buttons and expands full same-SFC source", async () => {
|
||||
const w = fixture(Demo as never, { props: { name: "button-basic" } });
|
||||
await flushPromises();
|
||||
const expand = w.get("button[aria-controls]");
|
||||
expect(expand.classes()).toContain("hv-button");
|
||||
expect(expand.attributes("aria-expanded")).toBe("false");
|
||||
expect(w.get(".code-section").attributes("data-expanded")).toBe("false");
|
||||
await expand.trigger("click");
|
||||
await flushPromises();
|
||||
expect(expand.attributes("aria-expanded")).toBe("true");
|
||||
expect(w.get(".highlighted-source").text()).toContain("<Button");
|
||||
});
|
||||
|
||||
it("navigates search results with Enter and keeps focus on the destination instead of the closed trigger", async () => {
|
||||
const target = document.createElement("h2");
|
||||
target.id = "button";
|
||||
target.textContent = "Button";
|
||||
document.body.append(target);
|
||||
const w = fixture(DocSearch as never);
|
||||
await w.get('button[aria-label="搜索文档"]').trigger("click");
|
||||
await flushPromises();
|
||||
await search("isPending");
|
||||
keyboard(input(), "Enter");
|
||||
await flushPromises();
|
||||
expect(host.go).toHaveBeenCalledWith("/components/button#button");
|
||||
expect(document.activeElement).toBe(target);
|
||||
expect(document.querySelector('[data-slot="modal-dialog"]')).toBeNull();
|
||||
});
|
||||
it("uses the same current section in the mobile Drawer and releases it on close", async () => {
|
||||
host.route.path = "/components/button";
|
||||
const w = fixture(Layout as never, { global: { stubs: { Content: true } } });
|
||||
await flushPromises();
|
||||
await w.get(".mobile-menu").trigger("click");
|
||||
await flushPromises();
|
||||
const dialog = document.querySelector('[data-slot="drawer-dialog"]')!;
|
||||
expect(dialog).not.toBeNull();
|
||||
expect(
|
||||
dialog
|
||||
.querySelector('[aria-label="移动端文档导航"] [aria-current="page"]')
|
||||
?.getAttribute("href"),
|
||||
).toBe("/components/button");
|
||||
(
|
||||
dialog.querySelector('[aria-label="关闭文档目录"]') as HTMLButtonElement
|
||||
).click();
|
||||
await flushPromises();
|
||||
expect(document.querySelector('[data-slot="drawer-dialog"]')).toBeNull();
|
||||
});
|
||||
it("closes the mobile TOC before navigating and focuses the requested heading", async () => {
|
||||
host.route.path = "/components/button";
|
||||
host.page.headers = [{ title: "Section", slug: "section", children: [] }];
|
||||
const w = fixture(Layout as never, {
|
||||
global: {
|
||||
stubs: {
|
||||
Content: { template: '<div><h2 id="section">Section</h2></div>' },
|
||||
},
|
||||
},
|
||||
});
|
||||
await flushPromises();
|
||||
const toggle = w
|
||||
.findAll("button")
|
||||
.find((button) => button.text().includes("本页内容"))!;
|
||||
await toggle.trigger("click");
|
||||
await flushPromises();
|
||||
const link = document.querySelector(".mobile-toc-content a")!;
|
||||
await new DOMWrapper(link).trigger("click");
|
||||
await flushPromises();
|
||||
expect(host.go).toHaveBeenCalledWith("/components/button#section");
|
||||
expect(document.activeElement).toBe(document.getElementById("section"));
|
||||
expect(document.querySelector(".mobile-toc-content")).toBeNull();
|
||||
});
|
||||
@@ -1,3 +1,4 @@
|
||||
import { componentItems } from "../apps/docs/.vitepress/theme/navigation";
|
||||
import { describe, it, expect, afterEach, vi } from "vitest";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import { readFileSync } from "node:fs";
|
||||
@@ -664,32 +665,19 @@ describe("M18–M20 review regressions", () => {
|
||||
});
|
||||
|
||||
describe("M18–M20 docs navigation", () => {
|
||||
it("registers the three pages in Layout sidebar groups", () => {
|
||||
const source = readFileSync(
|
||||
"apps/docs/.vitepress/theme/Layout.vue",
|
||||
"utf8",
|
||||
it("preserves the three pages in the shared sidebar/previous-next model", () => {
|
||||
const urls = componentItems.map((item) => item.url);
|
||||
for (const slug of ["meter", "progress-bar", "progress-circle"])
|
||||
expect(urls).toContain("/components/" + slug);
|
||||
expect(urls.indexOf("/components/meter")).toBeGreaterThan(
|
||||
urls.indexOf("/components/link"),
|
||||
);
|
||||
expect(urls.indexOf("/components/progress-circle")).toBeGreaterThan(
|
||||
urls.indexOf("/components/progress-bar"),
|
||||
);
|
||||
expect(urls.indexOf("/components/radio-group")).toBeGreaterThan(
|
||||
urls.indexOf("/components/progress-circle"),
|
||||
);
|
||||
for (const url of [
|
||||
"/components/meter",
|
||||
"/components/progress-bar",
|
||||
"/components/progress-circle",
|
||||
]) {
|
||||
expect(source).toContain(`url: "${url}"`);
|
||||
}
|
||||
expect(source).toContain("Meter 计量条");
|
||||
expect(source).toContain("ProgressBar 进度条");
|
||||
expect(source).toContain("ProgressCircle 环形进度条");
|
||||
// Order relative to neighbors used by prev/next
|
||||
const link = source.indexOf('url: "/components/link"');
|
||||
const meter = source.indexOf('url: "/components/meter"');
|
||||
const bar = source.indexOf('url: "/components/progress-bar"');
|
||||
const circle = source.indexOf('url: "/components/progress-circle"');
|
||||
const radio = source.indexOf('url: "/components/radio-group"');
|
||||
expect(link).toBeGreaterThan(-1);
|
||||
expect(meter).toBeGreaterThan(link);
|
||||
expect(bar).toBeGreaterThan(meter);
|
||||
expect(circle).toBeGreaterThan(bar);
|
||||
expect(radio).toBeGreaterThan(circle);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { mount, flushPromises } from "@vue/test-utils";
|
||||
import { mount, flushPromises, DOMWrapper } from "@vue/test-utils";
|
||||
import { createSSRApp, defineComponent, h, ref } from "vue";
|
||||
import { renderToString } from "@vue/server-renderer";
|
||||
import {
|
||||
@@ -620,7 +620,7 @@ describe("Select async demo lifecycle", () => {
|
||||
'[data-slot="select-popover"] button',
|
||||
),
|
||||
].find((button) => button.textContent?.includes("加载更多"))!;
|
||||
more.click();
|
||||
await new DOMWrapper(more).trigger("click");
|
||||
await flushPromises();
|
||||
expect(w.get("select").text()).toContain("bulbasaur");
|
||||
const retry = [
|
||||
@@ -629,7 +629,7 @@ describe("Select async demo lifecycle", () => {
|
||||
),
|
||||
].find((button) => button.textContent?.includes("重试"))!;
|
||||
expect(retry).toBeTruthy();
|
||||
retry.click();
|
||||
await new DOMWrapper(retry).trigger("click");
|
||||
await flushPromises();
|
||||
await vi.waitFor(() =>
|
||||
expect(w.get("select").text()).toContain("ivysaur"),
|
||||
|
||||
@@ -538,3 +538,24 @@ describe("Surface form demo integration", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves explicit role and tabindex on a native Link used as a search option", () => {
|
||||
const w = mount(Link, {
|
||||
props: { href: "/components/button" },
|
||||
attrs: { role: "option", tabindex: -1, "aria-selected": "true" },
|
||||
});
|
||||
expect(w.attributes("role")).toBe("option");
|
||||
expect(w.attributes("tabindex")).toBe("-1");
|
||||
expect(w.attributes("aria-selected")).toBe("true");
|
||||
w.unmount();
|
||||
});
|
||||
it("omits the implicit same-window target so host routers can intercept navigation", () => {
|
||||
const w = mount(Link, { props: { href: "/components/button" } });
|
||||
expect(w.attributes("target")).toBeUndefined();
|
||||
w.unmount();
|
||||
const explicit = mount(Link, {
|
||||
props: { href: "/components/button", target: "_self" },
|
||||
});
|
||||
expect(explicit.attributes("target")).toBe("_self");
|
||||
explicit.unmount();
|
||||
});
|
||||
|
||||
+4
-1
@@ -21,6 +21,9 @@
|
||||
"apps/**/*.ts",
|
||||
"apps/**/*.vue",
|
||||
"tests/**/*.ts",
|
||||
"vitest.config.ts"
|
||||
"vitest.config.ts",
|
||||
"apps/docs/.vitepress/theme/**/*.ts",
|
||||
"apps/docs/.vitepress/theme/**/*.vue",
|
||||
"apps/docs/.vitepress/env.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,10 +1,20 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { docsDataPlugin } from "./apps/docs/.vitepress/docs-data";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
plugins: [
|
||||
vue(),
|
||||
docsDataPlugin(fileURLToPath(new URL("./apps/docs", import.meta.url))),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
vitepress: fileURLToPath(
|
||||
new URL(
|
||||
"./apps/docs/node_modules/vitepress/dist/client/index.js",
|
||||
import.meta.url,
|
||||
),
|
||||
),
|
||||
"@heroui-vue/components": fileURLToPath(
|
||||
new URL("./packages/vue/src/index.ts", import.meta.url),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user