06ddb6662a
Port HeroUI menu family and Dropdown from ce90ea3: Reka DropdownMenu base, MenuKey[] selection with section owners, 17 official demos, dropdown docs and B01 tests. Long-press stays demo-level; submenu close is level-scoped.
89 lines
2.7 KiB
Vue
89 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
IconDotsVertical,
|
|
IconPencil,
|
|
IconPlus,
|
|
IconTrash,
|
|
} from "@tabler/icons-vue";
|
|
import {
|
|
DropdownRoot,
|
|
DropdownTrigger,
|
|
DropdownPopover,
|
|
DropdownMenu,
|
|
DropdownItem,
|
|
DropdownSection,
|
|
Button,
|
|
Label,
|
|
Description,
|
|
Header,
|
|
Kbd,
|
|
KbdAbbr,
|
|
KbdContent,
|
|
Separator,
|
|
} from "@heroui-vue/components";
|
|
|
|
function onAction(key: string | number) {
|
|
console.log(`Selected: ${key}`);
|
|
}
|
|
</script>
|
|
<template>
|
|
<DropdownRoot>
|
|
<DropdownTrigger>
|
|
<Button is-icon-only aria-label="菜单" variant="secondary">
|
|
<IconDotsVertical class="outline-none" />
|
|
</Button>
|
|
</DropdownTrigger>
|
|
<DropdownPopover>
|
|
<DropdownMenu @action="onAction">
|
|
<DropdownSection>
|
|
<Header>操作</Header>
|
|
<DropdownItem id="new-file" text-value="新建文件">
|
|
<div class="flex h-8 items-start justify-center pt-px">
|
|
<IconPlus class="size-4 shrink-0 text-muted" />
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<Label>新建文件</Label>
|
|
<Description>创建新文件</Description>
|
|
</div>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>N</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="edit-file" text-value="编辑文件">
|
|
<div class="flex h-8 items-start justify-center pt-px">
|
|
<IconPencil class="size-4 shrink-0 text-muted" />
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<Label>编辑文件</Label>
|
|
<Description>进行修改</Description>
|
|
</div>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>E</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
</DropdownSection>
|
|
<Separator />
|
|
<DropdownSection>
|
|
<Header>危险区域</Header>
|
|
<DropdownItem id="delete-file" text-value="删除文件" variant="danger">
|
|
<div class="flex h-8 items-start justify-center pt-px">
|
|
<IconTrash class="size-4 shrink-0 text-danger" />
|
|
</div>
|
|
<div class="flex flex-col">
|
|
<Label>删除文件</Label>
|
|
<Description>移至废纸篓</Description>
|
|
</div>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdAbbr key-value="shift" />
|
|
<KbdContent>D</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
</DropdownSection>
|
|
</DropdownMenu>
|
|
</DropdownPopover>
|
|
</DropdownRoot>
|
|
</template>
|