feat: migrate Menu and Dropdown with selection and submenus
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.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
DropdownRoot,
|
||||
DropdownTrigger,
|
||||
DropdownPopover,
|
||||
DropdownMenu,
|
||||
DropdownItem,
|
||||
DropdownItemIndicator,
|
||||
Button,
|
||||
Label,
|
||||
} from "@heroui-vue/components";
|
||||
import type { MenuKey } from "@heroui-vue/components";
|
||||
|
||||
const selected = ref<MenuKey[]>(["bold"]);
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex min-w-sm flex-col items-center justify-center gap-4">
|
||||
<p class="text-sm text-muted">
|
||||
已选:{{ selected.length > 0 ? selected.join("、") : "无" }}
|
||||
</p>
|
||||
<DropdownRoot>
|
||||
<DropdownTrigger>
|
||||
<Button aria-label="菜单" variant="secondary">操作</Button>
|
||||
</DropdownTrigger>
|
||||
<DropdownPopover>
|
||||
<DropdownMenu
|
||||
:selected-keys="selected"
|
||||
selection-mode="multiple"
|
||||
@update:selected-keys="(keys: MenuKey[]) => (selected = keys)"
|
||||
>
|
||||
<DropdownItem id="bold" text-value="粗体">
|
||||
<Label>粗体</Label>
|
||||
<DropdownItemIndicator />
|
||||
</DropdownItem>
|
||||
<DropdownItem id="italic" text-value="斜体">
|
||||
<Label>斜体</Label>
|
||||
<DropdownItemIndicator />
|
||||
</DropdownItem>
|
||||
<DropdownItem id="underline" text-value="下划线">
|
||||
<Label>下划线</Label>
|
||||
<DropdownItemIndicator />
|
||||
</DropdownItem>
|
||||
</DropdownMenu>
|
||||
</DropdownPopover>
|
||||
</DropdownRoot>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user