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,122 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
DropdownRoot,
|
||||
DropdownTrigger,
|
||||
DropdownPopover,
|
||||
DropdownMenu,
|
||||
DropdownItem,
|
||||
DropdownItemIndicator,
|
||||
DropdownSection,
|
||||
Button,
|
||||
Header,
|
||||
Label,
|
||||
Kbd,
|
||||
KbdAbbr,
|
||||
KbdContent,
|
||||
Separator,
|
||||
} from "@heroui-vue/components";
|
||||
import type { MenuKey } from "@heroui-vue/components";
|
||||
|
||||
const textStyles = ref<MenuKey[]>(["bold", "italic"]);
|
||||
const textAlignment = ref<MenuKey[]>(["left"]);
|
||||
</script>
|
||||
<template>
|
||||
<DropdownRoot>
|
||||
<DropdownTrigger>
|
||||
<Button aria-label="菜单" variant="secondary">样式</Button>
|
||||
</DropdownTrigger>
|
||||
<DropdownPopover class="min-w-[256px]">
|
||||
<DropdownMenu>
|
||||
<DropdownSection>
|
||||
<Header>操作</Header>
|
||||
<DropdownItem id="cut" text-value="剪切">
|
||||
<Label>剪切</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>X</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="copy" text-value="复制">
|
||||
<Label>复制</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>C</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="paste" text-value="粘贴">
|
||||
<Label>粘贴</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>U</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
</DropdownSection>
|
||||
<Separator />
|
||||
<DropdownSection
|
||||
:selected-keys="textStyles"
|
||||
selection-mode="multiple"
|
||||
@update:selected-keys="(keys: MenuKey[]) => (textStyles = keys)"
|
||||
>
|
||||
<Header>文本样式</Header>
|
||||
<DropdownItem id="bold" text-value="粗体">
|
||||
<DropdownItemIndicator />
|
||||
<Label>粗体</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>B</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="italic" text-value="斜体">
|
||||
<DropdownItemIndicator />
|
||||
<Label>斜体</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>I</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="underline" text-value="下划线">
|
||||
<DropdownItemIndicator />
|
||||
<Label>下划线</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="command" />
|
||||
<KbdContent>U</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
</DropdownSection>
|
||||
<Separator />
|
||||
<DropdownSection
|
||||
:selected-keys="textAlignment"
|
||||
selection-mode="single"
|
||||
@update:selected-keys="(keys: MenuKey[]) => (textAlignment = keys)"
|
||||
>
|
||||
<Header>文本对齐</Header>
|
||||
<DropdownItem id="left" text-value="左对齐">
|
||||
<DropdownItemIndicator type="dot" />
|
||||
<Label>左对齐</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="alt" />
|
||||
<KbdContent>A</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="center" text-value="居中">
|
||||
<DropdownItemIndicator type="dot" />
|
||||
<Label>居中</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="alt" />
|
||||
<KbdContent>H</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
<DropdownItem id="right" text-value="右对齐">
|
||||
<DropdownItemIndicator type="dot" />
|
||||
<Label>右对齐</Label>
|
||||
<Kbd class="ms-auto" variant="light">
|
||||
<KbdAbbr key-value="alt" />
|
||||
<KbdContent>D</KbdContent>
|
||||
</Kbd>
|
||||
</DropdownItem>
|
||||
</DropdownSection>
|
||||
</DropdownMenu>
|
||||
</DropdownPopover>
|
||||
</DropdownRoot>
|
||||
</template>
|
||||
Reference in New Issue
Block a user