043a5418f3
- menu-item.css keys disabled styling off the presence attribute Reka emits. - Dropdown surfaces drive the ported enter/exit animations and use data-side for placement-specific motion. - One role=menu per popup; items render their key as DOM id; submenu surfaces point aria-labelledby at the real trigger; MenuSection names its group from a nested Header. - Custom (asChild) triggers stay keyboard focusable; library Button/Avatar keep their own layout instead of the custom-trigger rules. - Items emit data-focused/data-hovered/data-pressed, expose the upstream render props to slots, and merge caller classes through tailwind-variants. - Submenu triggers declare hasSubmenu explicitly and forward class/ARIA; the default submenu indicator uses the baseline chevron artwork. - Demos restore Kbd slot="keyboard" (27x), IconSquarePlus, and remove the added comment, stray space and duplicated indicator SVGs. - Document the page after the official structure and API tables, including renamed props, Vue extensions and remaining gaps.
59 lines
1.7 KiB
Vue
59 lines
1.7 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" slot="keyboard" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>N</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="open" text-value="打开">
|
|
<Label>打开</Label>
|
|
<Kbd class="ms-auto" slot="keyboard" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>O</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="save" text-value="保存">
|
|
<Label>保存</Label>
|
|
<Kbd class="ms-auto" slot="keyboard" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdContent>S</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
<DropdownItem id="delete" text-value="删除" variant="danger">
|
|
<Label>删除</Label>
|
|
<Kbd class="ms-auto" slot="keyboard" variant="light">
|
|
<KbdAbbr key-value="command" />
|
|
<KbdAbbr key-value="shift" />
|
|
<KbdContent>D</KbdContent>
|
|
</Kbd>
|
|
</DropdownItem>
|
|
</DropdownMenu>
|
|
</DropdownPopover>
|
|
</DropdownRoot>
|
|
</template>
|