feat(docs): align documentation shell with HeroUI baseline
This commit is contained in:
@@ -460,3 +460,12 @@ Vaul Vue 官方已说明停止维护并推荐 Reka Drawer;新项目不采用 V
|
|||||||
DateField/DateInputGroup 已公开,先读[DATE-02 报告](docs/migrations/DATE-02-date-field.md)。空值受控拒绝不能靠重新传 null 触发底座 watch;回归完整提案、部分草稿和 reset,保留原节点/焦点。使用 shallowRef 保留日期类类型,完整 ISO 原生提交不跟显示粒度裁剪。Reka Root asChild/导航取消、完整日期粘贴和 13 月/era 差异必须保留说明。
|
DateField/DateInputGroup 已公开,先读[DATE-02 报告](docs/migrations/DATE-02-date-field.md)。空值受控拒绝不能靠重新传 null 触发底座 watch;回归完整提案、部分草稿和 reset,保留原节点/焦点。使用 shallowRef 保留日期类类型,完整 ISO 原生提交不跟显示粒度裁剪。Reka Root asChild/导航取消、完整日期粘贴和 13 月/era 差异必须保留说明。
|
||||||
|
|
||||||
用户最新要求:完成 DateField 后暂停组件迁移,先对齐文档站整体架构、结构、布局与公共控件;已经具备的 HeroUI Vue 组件用于文档壳层,暂缺的保留现有实现,不为文档任务插入 Calendar。
|
用户最新要求:完成 DateField 后暂停组件迁移,先对齐文档站整体架构、结构、布局与公共控件;已经具备的 HeroUI Vue 组件用于文档壳层,暂缺的保留现有实现,不为文档任务插入 Calendar。
|
||||||
|
|
||||||
|
## 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,9 +15,14 @@ export default defineConfig({
|
|||||||
config(md) {
|
config(md) {
|
||||||
const fence = md.renderer.rules.fence!;
|
const fence = md.renderer.rules.fence!;
|
||||||
md.renderer.rules.fence = (...args) =>
|
md.renderer.rules.fence = (...args) =>
|
||||||
fence(...args).replace(
|
fence(...args)
|
||||||
|
.replace(
|
||||||
/(<button\b[^>]*class="copy"[^>]*>)(<\/button>)/g,
|
/(<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',
|
'$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>',
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ export function docsDataPlugin(root: string): Plugin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const pages = [
|
const pages = [
|
||||||
"introduction.md",
|
...(await readdir(root))
|
||||||
"guide.md",
|
.filter((name) => name.endsWith(".md") && name !== "index.md")
|
||||||
"themes.md",
|
.sort(),
|
||||||
...(await readdir(path.join(root, "components")))
|
...(await readdir(path.join(root, "components")))
|
||||||
.filter((f) => f.endsWith(".md"))
|
.filter((f) => f.endsWith(".md"))
|
||||||
.map((f) => "components/" + f),
|
.map((f) => "components/" + f),
|
||||||
|
|||||||
@@ -1,16 +1,31 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { IconCode, IconCopy } from "@tabler/icons-vue";
|
import { IconCode, IconCopy, IconCheck } from "@tabler/icons-vue";
|
||||||
import { computed, ref, watch, onBeforeUnmount, useId } from "vue";
|
import {
|
||||||
|
computed,
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
onBeforeUnmount,
|
||||||
|
onMounted,
|
||||||
|
useId,
|
||||||
|
defineAsyncComponent,
|
||||||
|
} from "vue";
|
||||||
|
import { Button } from "@heroui-vue/components";
|
||||||
import { highlights } from "virtual:docs-data";
|
import { highlights } from "virtual:docs-data";
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
name: string;
|
name: string;
|
||||||
align?: "center" | "start" | "end";
|
align?: "center" | "start" | "end";
|
||||||
isBgSolid?: boolean;
|
isBgSolid?: boolean;
|
||||||
|
hideCode?: boolean;
|
||||||
|
minHeight?: string;
|
||||||
|
description?: string;
|
||||||
}>();
|
}>();
|
||||||
const demos = import.meta.glob("../../demos/*.vue", {
|
const loaders = import.meta.glob("../../demos/*.vue", { import: "default" });
|
||||||
eager: true,
|
const demos = Object.fromEntries(
|
||||||
import: "default",
|
Object.entries(loaders).map(([name, loader]) => [
|
||||||
});
|
name,
|
||||||
|
defineAsyncComponent(loader as () => Promise<import("vue").Component>),
|
||||||
|
]),
|
||||||
|
);
|
||||||
const sources = import.meta.glob("../../demos/*.vue", {
|
const sources = import.meta.glob("../../demos/*.vue", {
|
||||||
eager: true,
|
eager: true,
|
||||||
query: "?raw",
|
query: "?raw",
|
||||||
@@ -24,20 +39,44 @@ const expanded = ref(false),
|
|||||||
copyStatus = ref("复制代码");
|
copyStatus = ref("复制代码");
|
||||||
const id = useId();
|
const id = useId();
|
||||||
const highlightedCode = ref("");
|
const highlightedCode = ref("");
|
||||||
watch([expanded, () => props.name], async ([open, name], _, onCleanup) => {
|
const preview = ref<HTMLElement>();
|
||||||
let current = true;
|
let generation = 0;
|
||||||
onCleanup(() => {
|
let observer: IntersectionObserver | undefined;
|
||||||
current = false;
|
async function highlight() {
|
||||||
});
|
const current = ++generation;
|
||||||
highlightedCode.value = "";
|
|
||||||
if (open) {
|
|
||||||
try {
|
try {
|
||||||
const result = await highlights[name]?.();
|
const result = await highlights[props.name]?.();
|
||||||
if (current) highlightedCode.value = result?.default ?? "";
|
if (current === generation) highlightedCode.value = result?.default ?? "";
|
||||||
} catch {
|
} catch {
|
||||||
// The plain source remains available if a highlight chunk cannot load.
|
/* 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;
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||||
async function copy() {
|
async function copy() {
|
||||||
@@ -53,12 +92,18 @@ async function copy() {
|
|||||||
copyStatus.value = "复制失败,请手动选择代码";
|
copyStatus.value = "复制失败,请手动选择代码";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onBeforeUnmount(() => clearTimeout(timer));
|
onBeforeUnmount(() => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
generation++;
|
||||||
|
observer?.disconnect();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="component-preview-container" :data-name="name">
|
<div class="component-preview-container" :data-name="name">
|
||||||
|
<p v-if="description" class="preview-description">{{ description }}</p>
|
||||||
<div
|
<div
|
||||||
class="preview not-prose"
|
class="preview not-prose"
|
||||||
|
:class="{ 'preview-only': hideCode }"
|
||||||
:style="{
|
:style="{
|
||||||
alignItems:
|
alignItems:
|
||||||
align === 'start'
|
align === 'start'
|
||||||
@@ -69,50 +114,59 @@ onBeforeUnmount(() => clearTimeout(timer));
|
|||||||
background: isBgSolid ? 'var(--background)' : undefined,
|
background: isBgSolid ? 'var(--background)' : undefined,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div class="demo-row">
|
<div class="demo-row" :style="{ minHeight }">
|
||||||
<component :is="component" v-if="component" />
|
<component :is="component" v-if="component" />
|
||||||
<p v-else role="alert">示例不存在:{{ name }}</p>
|
<p v-else role="alert">示例不存在:{{ name }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="code-section">
|
<div
|
||||||
<div class="code-toolbar">
|
v-if="!hideCode"
|
||||||
<span class="code-language">
|
ref="preview"
|
||||||
<span class="code-dot" aria-hidden="true" />
|
class="code-section not-prose"
|
||||||
Vue
|
:data-expanded="expanded"
|
||||||
</span>
|
>
|
||||||
<div>
|
<Button
|
||||||
<button
|
class="preview-copy"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
is-icon-only
|
||||||
|
:aria-label="'复制' + name + ' 示例代码'"
|
||||||
|
@click="copy"
|
||||||
|
>
|
||||||
|
<IconCheck
|
||||||
|
v-if="copyStatus === '已复制'"
|
||||||
|
aria-hidden="true"
|
||||||
|
:size="16"
|
||||||
|
/>
|
||||||
|
<IconCopy v-else aria-hidden="true" :size="16" />
|
||||||
|
</Button>
|
||||||
|
<div
|
||||||
|
:id="id"
|
||||||
|
class="highlighted-source"
|
||||||
|
:aria-hidden="!expanded || undefined"
|
||||||
|
:tabindex="expanded ? 0 : undefined"
|
||||||
|
:aria-label="name + ' 示例源码'"
|
||||||
|
>
|
||||||
|
<div v-if="highlightedCode" v-html="highlightedCode" />
|
||||||
|
<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-label="(expanded ? '收起' : '展开') + name + ' 示例代码'"
|
||||||
:aria-controls="id"
|
:aria-controls="id"
|
||||||
:aria-expanded="expanded"
|
:aria-expanded="expanded"
|
||||||
@click="expanded = !expanded"
|
@click="expanded = !expanded"
|
||||||
>
|
>
|
||||||
<IconCode aria-hidden="true" :size="14" />
|
<IconCode :size="14" aria-hidden="true" />
|
||||||
{{ expanded ? "收起代码" : "展开代码" }}
|
{{ expanded ? "收起代码" : "展开代码" }}
|
||||||
</button>
|
</Button>
|
||||||
<button :aria-label="'复制' + name + ' 示例代码'" @click="copy">
|
<p class="sr-only" role="status">
|
||||||
<IconCopy aria-hidden="true" :size="14" />
|
|
||||||
复制代码
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p
|
|
||||||
class="copy-feedback"
|
|
||||||
:class="{ 'sr-only': copyStatus === '复制代码' }"
|
|
||||||
role="status"
|
|
||||||
>
|
|
||||||
{{ copyStatus === "复制代码" ? "" : copyStatus }}
|
{{ copyStatus === "复制代码" ? "" : copyStatus }}
|
||||||
</p>
|
</p>
|
||||||
<div
|
|
||||||
v-if="expanded"
|
|
||||||
:id="id"
|
|
||||||
class="highlighted-source"
|
|
||||||
tabindex="0"
|
|
||||||
:aria-label="name + ' 示例源码'"
|
|
||||||
>
|
|
||||||
<div v-if="highlightedCode" v-html="highlightedCode" />
|
|
||||||
<pre v-else><code>{{ code }}</code></pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -10,15 +10,21 @@ import {
|
|||||||
} from "vue";
|
} from "vue";
|
||||||
import { withBase, useRouter } from "vitepress";
|
import { withBase, useRouter } from "vitepress";
|
||||||
import {
|
import {
|
||||||
DialogRoot,
|
Button,
|
||||||
DialogTrigger,
|
Link,
|
||||||
DialogPortal,
|
Kbd,
|
||||||
DialogOverlay,
|
Modal,
|
||||||
DialogContent,
|
ModalTrigger,
|
||||||
DialogTitle,
|
ModalBackdrop,
|
||||||
DialogDescription,
|
ModalContainer,
|
||||||
DialogClose,
|
ModalDialog,
|
||||||
} from "reka-ui";
|
ModalHeading,
|
||||||
|
SearchField,
|
||||||
|
SearchFieldGroup,
|
||||||
|
SearchFieldInput,
|
||||||
|
SearchFieldSearchIcon,
|
||||||
|
EmptyState,
|
||||||
|
} from "@heroui-vue/components";
|
||||||
import { searchIndex } from "virtual:docs-data";
|
import { searchIndex } from "virtual:docs-data";
|
||||||
import { searchDocs, searchExcerpt } from "./search";
|
import { searchDocs, searchExcerpt } from "./search";
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -26,7 +32,7 @@ const navigating = ref(false);
|
|||||||
const open = ref(false),
|
const open = ref(false),
|
||||||
query = ref(""),
|
query = ref(""),
|
||||||
active = ref(0),
|
active = ref(0),
|
||||||
field = ref<HTMLInputElement>();
|
field = ref<{ focus: () => void }>();
|
||||||
const results = computed(() => searchDocs(searchIndex, query.value));
|
const results = computed(() => searchDocs(searchIndex, query.value));
|
||||||
watch(query, () => {
|
watch(query, () => {
|
||||||
active.value = 0;
|
active.value = 0;
|
||||||
@@ -36,11 +42,31 @@ watch(open, (value) => {
|
|||||||
else navigating.value = false;
|
else navigating.value = false;
|
||||||
});
|
});
|
||||||
function shortcut(event: KeyboardEvent) {
|
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();
|
event.preventDefault();
|
||||||
open.value = !open.value;
|
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) {
|
function move(delta: number) {
|
||||||
if (!results.value.length) return;
|
if (!results.value.length) return;
|
||||||
active.value =
|
active.value =
|
||||||
@@ -67,6 +93,9 @@ function navigate() {
|
|||||||
const entry = results.value[active.value];
|
const entry = results.value[active.value];
|
||||||
if (entry) void navigateTo(entry);
|
if (entry) void navigateTo(entry);
|
||||||
}
|
}
|
||||||
|
function guardEscape(event: KeyboardEvent) {
|
||||||
|
if (event.isComposing) event.preventDefault();
|
||||||
|
}
|
||||||
function closeAutoFocus(event: Event) {
|
function closeAutoFocus(event: Event) {
|
||||||
if (navigating.value) event.preventDefault();
|
if (navigating.value) event.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -74,43 +103,61 @@ onMounted(() => window.addEventListener("keydown", shortcut));
|
|||||||
onBeforeUnmount(() => window.removeEventListener("keydown", shortcut));
|
onBeforeUnmount(() => window.removeEventListener("keydown", shortcut));
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<DialogRoot v-model:open="open">
|
<Modal v-model:open="open">
|
||||||
<DialogTrigger class="search-trigger" aria-label="搜索文档">
|
<ModalTrigger as-child>
|
||||||
|
<Button class="search-trigger" variant="secondary" aria-label="搜索文档">
|
||||||
<IconSearch aria-hidden="true" :size="17" />
|
<IconSearch aria-hidden="true" :size="17" />
|
||||||
<span>搜索文档…</span>
|
<span>搜索文档…</span>
|
||||||
<kbd>⌘ / Ctrl K</kbd>
|
<Kbd>⌘ / Ctrl K</Kbd>
|
||||||
</DialogTrigger>
|
</Button>
|
||||||
<DialogPortal>
|
</ModalTrigger>
|
||||||
<DialogOverlay class="search-overlay" />
|
<ModalBackdrop class="docs-search-backdrop" variant="blur">
|
||||||
<DialogContent
|
<ModalContainer placement="top" size="lg" class="docs-search-container">
|
||||||
|
<ModalDialog
|
||||||
class="search-dialog"
|
class="search-dialog"
|
||||||
@open-auto-focus.prevent="field?.focus()"
|
@open-auto-focus.prevent="field?.focus()"
|
||||||
@close-auto-focus="closeAutoFocus"
|
@close-auto-focus="closeAutoFocus"
|
||||||
|
@escape-key-down="guardEscape"
|
||||||
>
|
>
|
||||||
<DialogTitle class="sr-only">搜索文档</DialogTitle>
|
<ModalHeading class="sr-only">搜索文档</ModalHeading>
|
||||||
<DialogDescription class="sr-only">
|
<p class="sr-only" id="docs-search-instructions">
|
||||||
搜索组件、参数和用法;使用方向键选择,回车打开,Esc 关闭。
|
搜索组件、参数和用法;使用方向键选择,回车打开,Esc 关闭。
|
||||||
</DialogDescription>
|
</p>
|
||||||
<div class="search-field">
|
<div class="search-field">
|
||||||
<input
|
<SearchField
|
||||||
ref="field"
|
|
||||||
v-model="query"
|
v-model="query"
|
||||||
|
class="docs-search-input"
|
||||||
|
aria-label="搜索组件、参数或用法"
|
||||||
|
>
|
||||||
|
<SearchFieldGroup>
|
||||||
|
<SearchFieldSearchIcon />
|
||||||
|
<SearchFieldInput
|
||||||
|
ref="field"
|
||||||
placeholder="搜索组件、参数或用法…"
|
placeholder="搜索组件、参数或用法…"
|
||||||
aria-label="搜索组件、参数或用法"
|
aria-label="搜索组件、参数或用法"
|
||||||
role="combobox"
|
role="combobox"
|
||||||
aria-autocomplete="list"
|
aria-autocomplete="list"
|
||||||
|
aria-describedby="docs-search-instructions"
|
||||||
aria-controls="doc-search-results"
|
aria-controls="doc-search-results"
|
||||||
:aria-expanded="Boolean(query.trim())"
|
:aria-expanded="Boolean(query.trim())"
|
||||||
:aria-activedescendant="
|
:aria-activedescendant="
|
||||||
results.length ? 'search-result-' + active : undefined
|
query.trim() && results.length
|
||||||
|
? 'search-result-' + active
|
||||||
|
: undefined
|
||||||
"
|
"
|
||||||
@keydown.down.prevent="move(1)"
|
@keydown="keydown"
|
||||||
@keydown.up.prevent="move(-1)"
|
|
||||||
@keydown.enter.prevent="navigate"
|
|
||||||
/>
|
/>
|
||||||
<DialogClose class="search-close" aria-label="关闭搜索">
|
</SearchFieldGroup>
|
||||||
Esc
|
</SearchField>
|
||||||
</DialogClose>
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
class="search-close"
|
||||||
|
aria-label="关闭搜索"
|
||||||
|
@click="open = false"
|
||||||
|
>
|
||||||
|
<Kbd>Esc</Kbd>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="search-results"
|
class="search-results"
|
||||||
@@ -118,13 +165,18 @@ onBeforeUnmount(() => window.removeEventListener("keydown", shortcut));
|
|||||||
role="listbox"
|
role="listbox"
|
||||||
aria-label="搜索结果"
|
aria-label="搜索结果"
|
||||||
>
|
>
|
||||||
<p v-if="!query.trim()" class="search-empty">
|
<EmptyState v-if="!query.trim()" class="search-empty">
|
||||||
试试搜索「isPending」「主题」或「受控」
|
<IconSearch :size="24" aria-hidden="true" />
|
||||||
</p>
|
<p>试试搜索「isPending」「主题」或「受控」</p>
|
||||||
<p v-else-if="!results.length" class="search-empty" role="status">
|
</EmptyState>
|
||||||
没有找到“{{ query }}”,试试组件名或参数名。
|
<EmptyState
|
||||||
</p>
|
v-else-if="!results.length"
|
||||||
<a
|
class="search-empty"
|
||||||
|
role="status"
|
||||||
|
>
|
||||||
|
<p>没有找到“{{ query }}”,试试组件名或参数名。</p>
|
||||||
|
</EmptyState>
|
||||||
|
<Link
|
||||||
v-for="(entry, index) in results"
|
v-for="(entry, index) in results"
|
||||||
:id="'search-result-' + index"
|
:id="'search-result-' + index"
|
||||||
:key="entry.url"
|
:key="entry.url"
|
||||||
@@ -142,15 +194,22 @@ onBeforeUnmount(() => window.removeEventListener("keydown", shortcut));
|
|||||||
<span class="result-excerpt">
|
<span class="result-excerpt">
|
||||||
{{ searchExcerpt(entry, query) || "查看文档" }}
|
{{ searchExcerpt(entry, query) || "查看文档" }}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-footer" aria-live="polite">
|
<div class="search-footer" aria-live="polite">
|
||||||
<span>
|
<span>
|
||||||
{{ query.trim() ? results.length + " 条结果" : "本地文档搜索" }}
|
{{ query.trim() ? results.length + " 条结果" : "本地文档搜索" }}
|
||||||
</span>
|
</span>
|
||||||
<span>↑ ↓ 选择 ↵ 打开</span>
|
<span>
|
||||||
|
<Kbd>↑</Kbd>
|
||||||
|
<Kbd>↓</Kbd>
|
||||||
|
选择
|
||||||
|
<Kbd>↵</Kbd>
|
||||||
|
打开
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</ModalDialog>
|
||||||
</DialogPortal>
|
</ModalContainer>
|
||||||
</DialogRoot>
|
</ModalBackdrop>
|
||||||
|
</Modal>
|
||||||
</template>
|
</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">
|
<script setup lang="ts">
|
||||||
import {
|
|
||||||
IconSun,
|
|
||||||
IconMoon,
|
|
||||||
IconMenu2,
|
|
||||||
IconX,
|
|
||||||
IconArrowUpRight,
|
|
||||||
} from "@tabler/icons-vue";
|
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
ref,
|
ref,
|
||||||
@@ -14,173 +7,186 @@ import {
|
|||||||
onMounted,
|
onMounted,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { useData, useRoute, withBase, onContentUpdated } from "vitepress";
|
|
||||||
import {
|
import {
|
||||||
DialogRoot,
|
useData,
|
||||||
DialogTrigger,
|
useRoute,
|
||||||
DialogPortal,
|
useRouter,
|
||||||
DialogOverlay,
|
withBase,
|
||||||
DialogContent,
|
onContentUpdated,
|
||||||
DialogTitle,
|
} from "vitepress";
|
||||||
DialogClose,
|
import {
|
||||||
} from "reka-ui";
|
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";
|
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 route = useRoute();
|
||||||
const mobile = ref(false),
|
const router = useRouter();
|
||||||
activeSlug = ref("");
|
let pendingToc: { slug: string; path: string } | undefined;
|
||||||
const copyMessage = ref("");
|
function navigateToc(slug: string, event: MouseEvent) {
|
||||||
let copyTimer: ReturnType<typeof setTimeout> | undefined;
|
event.preventDefault();
|
||||||
onBeforeUnmount(() => clearTimeout(copyTimer));
|
pendingToc = { slug, path: current.value };
|
||||||
const groups = [
|
tocOpen.value = false;
|
||||||
{
|
|
||||||
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: "TextArea 多行文本框", url: "/components/textarea" },
|
|
||||||
{ title: "TextField 文本输入框", url: "/components/text-field" },
|
|
||||||
{ 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("/"))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
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 headers = computed(() => page.value.headers ?? []);
|
||||||
const flatHeaders = computed(() =>
|
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() {
|
function updateActive() {
|
||||||
ticking = false;
|
frame = 0;
|
||||||
const headings = flatHeaders.value
|
let active = flatHeaders.value[0]?.slug ?? "";
|
||||||
.map((h) => document.getElementById(h.slug))
|
for (const heading of flatHeaders.value) {
|
||||||
.filter((el): el is HTMLElement => Boolean(el));
|
const element = document.getElementById(heading.slug);
|
||||||
let active = headings[0]?.id ?? "";
|
if (element && element.getBoundingClientRect().top <= 160)
|
||||||
for (const heading of headings) {
|
active = heading.slug;
|
||||||
if (heading.getBoundingClientRect().top <= 120) active = heading.id;
|
else if (element) break;
|
||||||
else break;
|
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
window.innerHeight + window.scrollY >=
|
||||||
|
document.documentElement.scrollHeight - 2
|
||||||
|
)
|
||||||
|
active = flatHeaders.value.at(-1)?.slug ?? active;
|
||||||
activeSlug.value = active;
|
activeSlug.value = active;
|
||||||
}
|
}
|
||||||
function onScroll() {
|
function onScroll() {
|
||||||
if (!ticking) {
|
if (!frame) frame = requestAnimationFrame(updateActive);
|
||||||
ticking = true;
|
|
||||||
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(() => {
|
onMounted(() => {
|
||||||
window.addEventListener("scroll", onScroll, { passive: true });
|
window.addEventListener("scroll", onScroll, { passive: true });
|
||||||
updateActive();
|
updateActive();
|
||||||
|
revealCurrent();
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener("scroll", onScroll);
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
|
clearTimeout(copyTimer);
|
||||||
});
|
});
|
||||||
onBeforeUnmount(() => window.removeEventListener("scroll", onScroll));
|
|
||||||
onContentUpdated(() => {
|
onContentUpdated(() => {
|
||||||
void nextTick(updateActive);
|
void nextTick(() => {
|
||||||
|
updateActive();
|
||||||
|
revealCurrent();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
watch(
|
watch(
|
||||||
() => route.path,
|
() => route.path,
|
||||||
() => {
|
() => {
|
||||||
mobile.value = false;
|
mobile.value = false;
|
||||||
|
tocOpen.value = false;
|
||||||
void nextTick(() => {
|
void nextTick(() => {
|
||||||
if (!window.location.hash)
|
|
||||||
window.scrollTo({ top: 0, behavior: "instant" });
|
|
||||||
updateActive();
|
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) {
|
async function copyMarkdownCode(event: MouseEvent) {
|
||||||
const target = (event.target as HTMLElement).closest<HTMLButtonElement>(
|
const target = (event.target as HTMLElement).closest<HTMLButtonElement>(
|
||||||
"button.copy",
|
"button.copy",
|
||||||
);
|
);
|
||||||
if (!target) return;
|
const code = target?.parentElement?.querySelector("pre code")?.textContent;
|
||||||
const code = target.parentElement?.querySelector("pre code")?.textContent;
|
if (!target || !code) return;
|
||||||
if (!code) return;
|
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(code);
|
await navigator.clipboard.writeText(code);
|
||||||
target.classList.add("copied");
|
target.classList.add("copied");
|
||||||
@@ -200,167 +206,257 @@ async function copyMarkdownCode(event: MouseEvent) {
|
|||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="docs-layout">
|
<div class="docs-layout">
|
||||||
<a class="skip" href="#main">跳至内容</a>
|
<Link class="skip" href="#main">跳至内容</Link>
|
||||||
<p class="sr-only" role="status">{{ copyMessage }}</p>
|
<p class="sr-only" role="status">{{ copyMessage }}</p>
|
||||||
<header class="docs-nav">
|
<header class="docs-nav">
|
||||||
<a class="brand" :href="withBase('/components/button')">
|
<div class="docs-nav-main">
|
||||||
heroui
|
<div class="docs-brand-group">
|
||||||
<span>Vue</span>
|
<Link
|
||||||
</a>
|
class="brand"
|
||||||
<span class="version">v0.0.1</span>
|
:href="withBase('/')"
|
||||||
<nav aria-label="主导航">
|
aria-label="HeroUI Vue 文档首页"
|
||||||
<a
|
|
||||||
:href="withBase('/guide')"
|
|
||||||
:class="{
|
|
||||||
active:
|
|
||||||
!frontmatter.component && route.path !== withBase('/themes'),
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
文档
|
heroui
|
||||||
</a>
|
<Chip size="sm" variant="soft">Vue</Chip>
|
||||||
<a
|
</Link>
|
||||||
:href="withBase('/components/button')"
|
<Popover>
|
||||||
:class="{ active: Boolean(frontmatter.component) }"
|
<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 />
|
||||||
|
<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"
|
||||||
>
|
>
|
||||||
组件
|
组件
|
||||||
</a>
|
</Link>
|
||||||
<a
|
|
||||||
:href="withBase('/themes')"
|
|
||||||
:class="{ active: route.path === withBase('/themes') }"
|
|
||||||
>
|
|
||||||
主题
|
|
||||||
</a>
|
|
||||||
</nav>
|
</nav>
|
||||||
<div class="nav-tools">
|
<Separator />
|
||||||
<DocSearch />
|
<DocsSidebar
|
||||||
<button
|
:groups="groups"
|
||||||
class="theme-toggle"
|
:current="current"
|
||||||
:aria-label="isDark ? '切换浅色主题' : '切换深色主题'"
|
label="移动端文档导航"
|
||||||
@click="isDark = !isDark"
|
@navigate="leaveDrawer"
|
||||||
>
|
/>
|
||||||
<IconSun v-if="isDark" aria-hidden="true" :size="18" />
|
</DrawerBody>
|
||||||
<IconMoon v-else aria-hidden="true" :size="18" />
|
</DrawerDialog>
|
||||||
</button>
|
</DrawerContent>
|
||||||
<DialogRoot v-model:open="mobile">
|
</DrawerBackdrop>
|
||||||
<DialogTrigger class="mobile-menu" aria-label="打开文档目录">
|
</Drawer>
|
||||||
<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>
|
</div>
|
||||||
<nav aria-label="移动端文档导航">
|
</div>
|
||||||
<section v-for="group in groups" :key="group.title">
|
<div class="docs-nav-sections">
|
||||||
<h2>{{ group.title }}</h2>
|
<nav aria-label="主导航">
|
||||||
<a
|
<Link
|
||||||
v-for="item in group.items"
|
:href="withBase('/introduction')"
|
||||||
:key="item.url"
|
:aria-current="section === 'guide' ? 'page' : undefined"
|
||||||
:href="withBase(item.url)"
|
|
||||||
:aria-current="selected(item.url) ? 'page' : undefined"
|
|
||||||
@click="mobile = false"
|
|
||||||
>
|
>
|
||||||
{{ item.title }}
|
<IconBook2 :size="16" aria-hidden="true" />
|
||||||
</a>
|
快速开始
|
||||||
</section>
|
</Link>
|
||||||
|
<Link
|
||||||
|
:href="withBase('/components')"
|
||||||
|
:aria-current="section === 'components' ? 'page' : undefined"
|
||||||
|
>
|
||||||
|
<IconComponents :size="16" aria-hidden="true" />
|
||||||
|
组件
|
||||||
|
</Link>
|
||||||
</nav>
|
</nav>
|
||||||
</DialogContent>
|
<Chip class="framework" size="sm" variant="soft">
|
||||||
</DialogPortal>
|
<IconBrandVue :size="14" aria-hidden="true" />
|
||||||
</DialogRoot>
|
Vue 3
|
||||||
|
</Chip>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="docs-body">
|
<div class="docs-body">
|
||||||
<aside class="docs-sidebar" aria-label="文档导航">
|
<aside class="docs-sidebar" aria-label="侧栏">
|
||||||
<div class="framework">
|
<ScrollShadow
|
||||||
<span class="vue-mark">V</span>
|
ref="sidebar"
|
||||||
Vue
|
class="docs-sidebar-scroll"
|
||||||
<span class="framework-note">组件库</span>
|
:hide-scroll-bar="false"
|
||||||
</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 }}
|
<DocsSidebar :groups="groups" :current="current" />
|
||||||
</a>
|
|
||||||
</section>
|
|
||||||
<p class="community">
|
<p class="community">
|
||||||
独立社区实现
|
独立社区实现
|
||||||
<br />
|
<br />
|
||||||
设计基线 HeroUI v3.2.6
|
设计基线 HeroUI v3.2.6
|
||||||
</p>
|
</p>
|
||||||
|
</ScrollShadow>
|
||||||
</aside>
|
</aside>
|
||||||
<main id="main" class="docs-main">
|
<div v-if="headers.length" class="mobile-toc">
|
||||||
<div class="breadcrumb">
|
<Popover v-model:open="tocOpen" is-non-modal>
|
||||||
{{ frontmatter.group ?? "文档" }}
|
<PopoverTrigger as-child>
|
||||||
<span>›</span>
|
<Button variant="ghost" size="sm">
|
||||||
{{ frontmatter.title }}
|
<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>
|
</div>
|
||||||
<h1>{{ frontmatter.title }}</h1>
|
<main id="main" class="docs-main" tabindex="-1">
|
||||||
<p class="page-description">{{ frontmatter.description }}</p>
|
<nav aria-label="面包屑">
|
||||||
<div v-if="frontmatter.component" class="source-links">
|
<Breadcrumbs class="breadcrumb" aria-label="页面路径">
|
||||||
<a
|
<BreadcrumbsItem
|
||||||
:href="`https://github.com/heroui-inc/heroui/tree/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/react/src/components/${frontmatter.component}`"
|
: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"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer noopener"
|
||||||
>
|
>
|
||||||
React 参考源码
|
React 参考源码
|
||||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
<IconArrowUpRight :size="12" aria-hidden="true" />
|
||||||
</a>
|
</Link>
|
||||||
<a
|
<Link
|
||||||
:href="`https://github.com/heroui-inc/heroui/blob/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/styles/components/${frontmatter.component}.css`"
|
:href="`https://github.com/heroui-inc/heroui/blob/ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960/packages/styles/components/${componentSlug}.css`"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer noopener"
|
||||||
>
|
>
|
||||||
样式源码
|
样式源码
|
||||||
<IconArrowUpRight aria-hidden="true" :size="12" />
|
<IconArrowUpRight :size="12" aria-hidden="true" />
|
||||||
</a>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div @click="copyMarkdownCode"><Content class="docs-content" /></div>
|
<div @click="copyMarkdownCode"><Content class="docs-content" /></div>
|
||||||
<nav class="page-navigation" aria-label="相邻页面">
|
<nav class="page-navigation" aria-label="相邻页面">
|
||||||
<a v-if="previous" :href="withBase(previous.url)">
|
<Card
|
||||||
<span>上一页</span>
|
v-if="adjacent.previous"
|
||||||
<strong>{{ previous.title }}</strong>
|
as="a"
|
||||||
</a>
|
:href="withBase(adjacent.previous.url)"
|
||||||
<a v-if="next" class="page-next" :href="withBase(next.url)">
|
class="page-prev"
|
||||||
<span>下一页</span>
|
variant="transparent"
|
||||||
<strong>{{ next.title }}</strong>
|
>
|
||||||
</a>
|
<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>
|
</nav>
|
||||||
<footer class="docs-footer">
|
<footer class="docs-footer">
|
||||||
基于 HeroUI v3 设计的 Vue 实现 ·
|
基于 HeroUI v3 设计的 Vue 实现 ·
|
||||||
<a :href="withBase('/introduction')">实现范围与差异</a>
|
<Link :href="withBase('/introduction')">实现范围与差异</Link>
|
||||||
</footer>
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
<aside v-if="headers.length" class="docs-toc" aria-label="本页目录">
|
<aside v-if="headers.length" class="docs-toc" aria-label="本页目录区域">
|
||||||
<p>本页内容</p>
|
<p>
|
||||||
<template v-for="h in headers" :key="h.slug">
|
<IconList :size="16" aria-hidden="true" />
|
||||||
<a
|
本页内容
|
||||||
:href="'#' + h.slug"
|
</p>
|
||||||
:class="{ current: activeSlug === h.slug }"
|
<ScrollShadow class="docs-toc-scroll">
|
||||||
:aria-current="activeSlug === h.slug ? 'location' : undefined"
|
<DocsToc :headers="headers" :active="activeSlug" />
|
||||||
>
|
</ScrollShadow>
|
||||||
{{ 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>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
import type { Theme } from "vitepress";
|
import type { Theme } from "vitepress";
|
||||||
import { IconCopy, IconCheck } from "@tabler/icons-vue";
|
import { IconCopy, IconCheck } from "@tabler/icons-vue";
|
||||||
|
import { Button } from "@heroui-vue/components";
|
||||||
|
import DocsComponents from "./DocsComponents.vue";
|
||||||
import Layout from "./Layout.vue";
|
import Layout from "./Layout.vue";
|
||||||
import Demo from "./Demo.vue";
|
import Demo from "./Demo.vue";
|
||||||
import "@heroui-vue/styles/css";
|
import "@heroui-vue/styles/css";
|
||||||
import "./utilities.css";
|
import "./utilities.css";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
import "./shell.css";
|
||||||
export default {
|
export default {
|
||||||
Layout,
|
Layout,
|
||||||
enhanceApp({ app }) {
|
enhanceApp({ app }) {
|
||||||
app.component("ComponentPreview", Demo);
|
app.component("ComponentPreview", Demo);
|
||||||
|
app.component("DocsCopyButton", Button);
|
||||||
|
app.component("DocsComponents", DocsComponents);
|
||||||
app.component("DocsCopyIcon", IconCopy);
|
app.component("DocsCopyIcon", IconCopy);
|
||||||
app.component("DocsCheckIcon", IconCheck);
|
app.component("DocsCheckIcon", IconCheck);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,349 @@
|
|||||||
|
/** 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: "Tabs 标签页",
|
||||||
|
url: "/components/tabs",
|
||||||
|
category: "navigation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "TextArea 多行文本框",
|
||||||
|
url: "/components/textarea",
|
||||||
|
category: "forms",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "TextField 文本输入框",
|
||||||
|
url: "/components/text-field",
|
||||||
|
category: "forms",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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
+51
-53
@@ -1,64 +1,62 @@
|
|||||||
---
|
---
|
||||||
title: 组件
|
title: 所有组件(Vue)
|
||||||
description: 已迁移组件及文档
|
description: 浏览库中所有可用组件的完整列表,更多组件正在路上。
|
||||||
---
|
---
|
||||||
|
|
||||||
- [Accordion 手风琴](./components/accordion)
|
仅展示已经实现并提供文档的 Vue 组件。各组件的支持范围与已知差异请查看对应 API 页面。
|
||||||
- [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)
|
|
||||||
|
|
||||||
- [Fieldset 字段组](./components/fieldset)
|
## 按钮
|
||||||
- [SearchField 搜索框](./components/search-field)
|
|
||||||
|
|
||||||
- [Checkbox 复选框](./components/checkbox)
|
<DocsComponents category="buttons" />
|
||||||
- [CheckboxGroup 复选框组](./components/checkbox-group)
|
|
||||||
- [RadioGroup 单选框组](./components/radio-group)
|
|
||||||
|
|
||||||
- [Modal 模态框](./components/modal)
|
## 集合
|
||||||
- [Popover 弹出框](./components/popover)
|
|
||||||
- [Tooltip 工具提示](./components/tooltip)
|
|
||||||
|
|
||||||
- [ScrollShadow 滚动阴影](./components/scroll-shadow)
|
<DocsComponents category="collections" />
|
||||||
- [Tabs 标签页](./components/tabs)
|
|
||||||
- [Toolbar 工具栏](./components/toolbar)
|
|
||||||
- [ToggleButton 切换按钮](./components/toggle-button)
|
|
||||||
- [ToggleButtonGroup 切换按钮组](./components/toggle-button-group)
|
|
||||||
|
|
||||||
- [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" />
|
||||||
|
|
||||||
|
## 日期与时间
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
|||||||
@@ -141,9 +141,9 @@ Breadcrumbs 组件使用以下 CSS 类([查看源码样式](https://github.com
|
|||||||
### BreadcrumbsItem
|
### BreadcrumbsItem
|
||||||
|
|
||||||
| 属性 | 类型 | 默认值 | 描述 |
|
| 属性 | 类型 | 默认值 | 描述 |
|
||||||
| ------------ | --------------------------- | --------- | -------------------------------------------------------------------------------- |
|
| ------------ | --------------------------- | ------- | -------------------------------------------------------------------------------- |
|
||||||
| `href` | `string` | - | 链接 URL;未提供时渲染不可导航的 `span[role="link"]`,当前项与禁用项也不可导航。 |
|
| `href` | `string` | - | 链接 URL;未提供时渲染不可导航的 `span[role="link"]`,当前项与禁用项也不可导航。 |
|
||||||
| `target` | `string` | `'_self'` | 链接目标;仅在带 `href` 的可导航项输出。 |
|
| `target` | `string` | — | 链接目标;省略时使用浏览器同窗口默认行为,仅为可导航项输出显式传入的值。 |
|
||||||
| `rel` | `string` | - | 链接关系。 |
|
| `rel` | `string` | - | 链接关系。 |
|
||||||
| `download` | `boolean \| string` | - | 原生下载属性。 |
|
| `download` | `boolean \| string` | - | 原生下载属性。 |
|
||||||
| `isDisabled` | `boolean` | `false` | 禁用当前项链接。 |
|
| `isDisabled` | `boolean` | `false` | 禁用当前项链接。 |
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ Link 使用以下 CSS 类:
|
|||||||
### Link
|
### Link
|
||||||
|
|
||||||
| Prop | 类型 | 默认值 | 描述 |
|
| Prop | 类型 | 默认值 | 描述 |
|
||||||
| ------------ | ------------------- | --------- | -------------------------------------------------------------- |
|
| ------------ | ------------------- | ------- | ---------------------------------------------------------------------- |
|
||||||
| `href` | `string` | - | 锚点的目标 URL |
|
| `href` | `string` | - | 锚点的目标 URL |
|
||||||
| `target` | `string` | `"_self"` | 在何处打开链接文档 |
|
| `target` | `string` | — | 在何处打开链接文档;省略时使用浏览器同窗口默认行为,不输出 target 属性 |
|
||||||
| `rel` | `string` | - | 当前文档与链接文档的关系 |
|
| `rel` | `string` | - | 当前文档与链接文档的关系 |
|
||||||
| `download` | `boolean \| string` | - | 触发下载而非导航;`true` 渲染 `download`,`false`/未传省略属性 |
|
| `download` | `boolean \| string` | - | 触发下载而非导航;`true` 渲染 `download`,`false`/未传省略属性 |
|
||||||
| `isDisabled` | `boolean` | `false` | 禁用指针与键盘交互;保留可聚焦与 `aria-disabled` |
|
| `isDisabled` | `boolean` | `false` | 禁用指针与键盘交互;保留可聚焦与 `aria-disabled` |
|
||||||
|
|||||||
+2
-2
@@ -58,8 +58,8 @@ import { Button } from "@heroui-vue/components";
|
|||||||
|
|
||||||
| 命令 | 功能 |
|
| 命令 | 功能 |
|
||||||
| -------------- | --------------- |
|
| -------------- | --------------- |
|
||||||
| pnpm dev | 组件实验页 |
|
| pnpm dev | 文档开发站 |
|
||||||
| pnpm dev:docs | 组件文档 |
|
| pnpm dev:docs | 文档开发站 |
|
||||||
| pnpm build | 库与样式构建 |
|
| pnpm build | 库与样式构建 |
|
||||||
| pnpm typecheck | Vue 类型检查 |
|
| pnpm typecheck | Vue 类型检查 |
|
||||||
| pnpm test | 行为与 SSR 测试 |
|
| pnpm test | 行为与 SSR 测试 |
|
||||||
|
|||||||
+13
-133
@@ -1,142 +1,22 @@
|
|||||||
---
|
---
|
||||||
title: Button 按钮
|
title: 介绍
|
||||||
description: 可点击的按钮组件,支持多种变体与状态
|
description: 美观、现代的 Vue UI 组件库
|
||||||
component: button
|
|
||||||
group: 组件
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 用法
|
## 设计原则
|
||||||
|
|
||||||
```vue
|
以固定提交的 HeroUI v3.2.6 为设计基线,保持组件的样式、布局、文案、变体、参数语义和主题高度一致。仅在框架机制要求时转换事件、插槽、响应式状态与部件导出方式。
|
||||||
<script setup lang="ts">
|
|
||||||
import { Button } from "@heroui-vue/components";
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
<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 不声明等价。
|
||||||
|
|
||||||
### 尺寸
|
具体未覆盖能力在各组件 API 页说明。此项目为独立社区实现,不是官方 Vue 发行版。
|
||||||
|
|
||||||
<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)
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ description: 美观、现代的 Vue UI 组件库
|
|||||||
|
|
||||||
## 当前范围
|
## 当前范围
|
||||||
|
|
||||||
已迁移 Button、Card、Input、Switch 的主要视觉和组合结构,仍需完整视觉与交互验收。左侧导航只列出实际存在的组件,未迁移的组件不以占位演示代替。
|
已经提供展示、导航、表单、集合、弹层等组件,以及 DateField 日期分段输入。完整列表见[所有组件](/components),各页明确记录已知差异。左侧目录只列出实际存在的组件;未迁移的能力不以占位演示代替。
|
||||||
|
|
||||||
## Vue 差异
|
## Vue 差异
|
||||||
|
|
||||||
|
|||||||
@@ -202,3 +202,7 @@ React render 自定义根类型不支持;原生 attrs/具名部件/作用域
|
|||||||
- **InputOTP**:Reka PinInput 底座;公开字符串 + 内部索引数组(中间空位不左移);complete 仅首次填满。11/11 示例。消费 fieldContextKey,未改共享内核。真实自动填充/IME/读屏未验证。详见 [M32](./migrations/M32-input-otp.md)。
|
- **InputOTP**:Reka PinInput 底座;公开字符串 + 内部索引数组(中间空位不左移);complete 仅首次填满。11/11 示例。消费 fieldContextKey,未改共享内核。真实自动填充/IME/读屏未验证。详见 [M32](./migrations/M32-input-otp.md)。
|
||||||
|
|
||||||
以上不构成整库完成声明;逐像素、读屏、Nuxt 水合、独立安装仍未验收。
|
以上不构成整库完成声明;逐像素、读屏、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。
|
||||||
@@ -188,3 +188,7 @@ M18–M20 的标签桥接在 Vue 使用 indicator 注册表与 SSR 直接/原生
|
|||||||
## DATE-02 来源与适配
|
## DATE-02 来源与适配
|
||||||
|
|
||||||
移植 ce90ea3 date-field/date-input-group 的 React 部件、CSS、variants、中文正文与全部 17 预览。样式仅加 hv- 前缀及 Vue 状态适配;公开行为与底座差异、原生 ISO 提交、空值拒绝恢复详见 [DATE-02](migrations/DATE-02-date-field.md)。日期库 3.12.4 显式 dependency/external,不依赖上游源码。
|
移植 ce90ea3 date-field/date-input-group 的 React 部件、CSS、variants、中文正文与全部 17 预览。样式仅加 hv- 前缀及 Vue 状态适配;公开行为与底座差异、原生 ISO 提交、空值拒绝恢复详见 [DATE-02](migrations/DATE-02-date-field.md)。日期库 3.12.4 显式 dependency/external,不依赖上游源码。
|
||||||
|
|
||||||
|
## 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)。
|
||||||
|
|||||||
@@ -747,3 +747,12 @@ typecheck、build:docs、build:playground、format、diff-check 与 dist 正反
|
|||||||
- 5174 浏览器重点验证逐段输入、真实 ISO 值、设为今天/清空、秒粒度 + America/Los_Angeles/PST、深浅色、错误样式、代码高亮与 API 表格无横溢出。截图 `/private/tmp/heroui-date-field-review.png`。未做自动逐像素、完整读屏、触屏及全部历法编辑验收。
|
- 5174 浏览器重点验证逐段输入、真实 ISO 值、设为今天/清空、秒粒度 + America/Los_Angeles/PST、深浅色、错误样式、代码高亮与 API 表格无横溢出。截图 `/private/tmp/heroui-date-field-review.png`。未做自动逐像素、完整读屏、触屏及全部历法编辑验收。
|
||||||
- 两份 tarball 安装至独立 `/private/tmp/heroui-slider-consumer`,DateField ESM/Node SSR/CSS 及 NodeNext/bundler 严格正反类型通过。初次消费发现 Props 未从主入口转出,已补齐并重打包复验;错误值/粒度/变体/范围/segment 反例均实际触发诊断。Select/ListBox/M33–M34 产物消费与 NodeNext 契约回归通过。
|
- 两份 tarball 安装至独立 `/private/tmp/heroui-slider-consumer`,DateField ESM/Node SSR/CSS 及 NodeNext/bundler 严格正反类型通过。初次消费发现 Props 未从主入口转出,已补齐并重打包复验;错误值/粒度/变体/范围/segment 反例均实际触发诊断。Select/ListBox/M33–M34 产物消费与 NodeNext 契约回归通过。
|
||||||
- Date foundation 中 Calendar 仍仅为私有探针,不能据此标记公共 Calendar 完成。按用户要求暂停 Calendar/YearPicker,接下来先调整文档壳层。
|
- Date foundation 中 Calendar 仍仅为私有探针,不能据此标记公共 Calendar 完成。按用户要求暂停 Calendar/YearPicker,接下来先调整文档壳层。
|
||||||
|
|
||||||
|
## 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。
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
"build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build",
|
"build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build",
|
||||||
"typecheck": "vue-tsc --noEmit",
|
"typecheck": "vue-tsc --noEmit",
|
||||||
"test": "vitest run",
|
"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",
|
"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/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",
|
"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",
|
||||||
"format": "prettier --check .",
|
"format": "prettier --check .",
|
||||||
"format:fix": "prettier --write .",
|
"format:fix": "prettier --write .",
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
target: {
|
target: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "_self",
|
default: undefined,
|
||||||
},
|
},
|
||||||
rel: {
|
rel: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const props = withDefaults(
|
|||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
target: "_self",
|
target: undefined,
|
||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
asChild: false,
|
asChild: false,
|
||||||
},
|
},
|
||||||
@@ -263,8 +263,12 @@ defineExpose({
|
|||||||
:rel="rel"
|
:rel="rel"
|
||||||
:download="downloadAttr"
|
:download="downloadAttr"
|
||||||
:class="slots.base()"
|
:class="slots.base()"
|
||||||
:role="asChild ? 'link' : undefined"
|
:role="(attrs.role as string | undefined) ?? (asChild ? 'link' : undefined)"
|
||||||
:tabindex="disabled ? -1 : asChild ? 0 : undefined"
|
:tabindex="
|
||||||
|
disabled
|
||||||
|
? -1
|
||||||
|
: ((attrs.tabindex as number | undefined) ?? (asChild ? 0 : undefined))
|
||||||
|
"
|
||||||
:aria-disabled="disabled || undefined"
|
:aria-disabled="disabled || undefined"
|
||||||
:data-hovered="(!disabled && hovered) || undefined"
|
:data-hovered="(!disabled && hovered) || undefined"
|
||||||
:data-pressed="(!disabled && pressed) || 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 { describe, it, expect, afterEach, vi } from "vitest";
|
||||||
import { renderToString } from "@vue/server-renderer";
|
import { renderToString } from "@vue/server-renderer";
|
||||||
import { readFileSync } from "node:fs";
|
import { readFileSync } from "node:fs";
|
||||||
@@ -664,32 +665,19 @@ describe("M18–M20 review regressions", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("M18–M20 docs navigation", () => {
|
describe("M18–M20 docs navigation", () => {
|
||||||
it("registers the three pages in Layout sidebar groups", () => {
|
it("preserves the three pages in the shared sidebar/previous-next model", () => {
|
||||||
const source = readFileSync(
|
const urls = componentItems.map((item) => item.url);
|
||||||
"apps/docs/.vitepress/theme/Layout.vue",
|
for (const slug of ["meter", "progress-bar", "progress-circle"])
|
||||||
"utf8",
|
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 { 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 { createSSRApp, defineComponent, h, ref } from "vue";
|
||||||
import { renderToString } from "@vue/server-renderer";
|
import { renderToString } from "@vue/server-renderer";
|
||||||
import {
|
import {
|
||||||
@@ -620,7 +620,7 @@ describe("Select async demo lifecycle", () => {
|
|||||||
'[data-slot="select-popover"] button',
|
'[data-slot="select-popover"] button',
|
||||||
),
|
),
|
||||||
].find((button) => button.textContent?.includes("加载更多"))!;
|
].find((button) => button.textContent?.includes("加载更多"))!;
|
||||||
more.click();
|
await new DOMWrapper(more).trigger("click");
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
expect(w.get("select").text()).toContain("bulbasaur");
|
expect(w.get("select").text()).toContain("bulbasaur");
|
||||||
const retry = [
|
const retry = [
|
||||||
@@ -629,7 +629,7 @@ describe("Select async demo lifecycle", () => {
|
|||||||
),
|
),
|
||||||
].find((button) => button.textContent?.includes("重试"))!;
|
].find((button) => button.textContent?.includes("重试"))!;
|
||||||
expect(retry).toBeTruthy();
|
expect(retry).toBeTruthy();
|
||||||
retry.click();
|
await new DOMWrapper(retry).trigger("click");
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
await vi.waitFor(() =>
|
await vi.waitFor(() =>
|
||||||
expect(w.get("select").text()).toContain("ivysaur"),
|
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/**/*.ts",
|
||||||
"apps/**/*.vue",
|
"apps/**/*.vue",
|
||||||
"tests/**/*.ts",
|
"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 { defineConfig } from "vitest/config";
|
||||||
|
import { docsDataPlugin } from "./apps/docs/.vitepress/docs-data";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import { fileURLToPath, URL } from "node:url";
|
import { fileURLToPath, URL } from "node:url";
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue()],
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
docsDataPlugin(fileURLToPath(new URL("./apps/docs", import.meta.url))),
|
||||||
|
],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
vitepress: fileURLToPath(
|
||||||
|
new URL(
|
||||||
|
"./apps/docs/node_modules/vitepress/dist/client/index.js",
|
||||||
|
import.meta.url,
|
||||||
|
),
|
||||||
|
),
|
||||||
"@heroui-vue/components": fileURLToPath(
|
"@heroui-vue/components": fileURLToPath(
|
||||||
new URL("./packages/vue/src/index.ts", import.meta.url),
|
new URL("./packages/vue/src/index.ts", import.meta.url),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user