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.
59 lines
1.6 KiB
Vue
59 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
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" text-value="新建">
|
|
<Label>新建</Label>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>N</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="open" text-value="打开">
|
|
<Label>打开</Label>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>O</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="save" text-value="保存">
|
|
<Label>保存</Label>
|
|
<Kbd class="ms-auto" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>S</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="delete" text-value="删除" variant="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>
|