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.
69 lines
2.0 KiB
Vue
69 lines
2.0 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
IconDeviceFloppy,
|
|
IconFolderOpen,
|
|
IconPlus,
|
|
IconTrash,
|
|
} from "@tabler/icons-vue";
|
|
import {
|
|
DropdownRoot,
|
|
DropdownTrigger,
|
|
DropdownPopover,
|
|
DropdownMenu,
|
|
DropdownItem,
|
|
Button,
|
|
Label,
|
|
Kbd,
|
|
KbdAbbr,
|
|
KbdContent,
|
|
} from "@heroui-vue/components";
|
|
|
|
function onAction(key: string | number) {
|
|
console.log(`Selected: ${key}`);
|
|
}
|
|
</script>
|
|
<template>
|
|
<DropdownRoot>
|
|
<DropdownTrigger>
|
|
<Button aria-label="菜单" variant="secondary">操作</Button>
|
|
</DropdownTrigger>
|
|
<DropdownPopover>
|
|
<DropdownMenu @action="onAction">
|
|
<DropdownItem id="new-file" text-value="新建文件">
|
|
<IconPlus class="size-4 shrink-0 text-muted" />
|
|
<Label>新建文件</Label>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>N</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="open-file" text-value="打开文件">
|
|
<IconFolderOpen class="size-4 shrink-0 text-muted" />
|
|
<Label>打开文件</Label>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>O</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="save-file" text-value="保存文件">
|
|
<IconDeviceFloppy class="size-4 shrink-0 text-muted" />
|
|
<Label>保存文件</Label>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>S</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="delete-file" text-value="删除文件" variant="danger">
|
|
<IconTrash class="size-4 shrink-0 text-danger" />
|
|
<Label>删除文件</Label>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdAbbr key-value="shift" />
|
|
<KbdContent>D</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
</DropdownMenu>
|
|
</DropdownPopover>
|
|
</DropdownRoot>
|
|
</template>
|