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:
maoyingjie
2026-10-24 20:43:04 +08:00
parent 1c4ecc3def
commit 06ddb6662a
48 changed files with 3091 additions and 5 deletions
@@ -0,0 +1,55 @@
<script lang="ts">
import {
defineComponent,
h,
inject,
onMounted,
onUnmounted,
useAttrs,
} from "vue";
import { menuItemContextKey } from "../menu/context";
function ChevronIcon() {
return h(
"svg",
{
"aria-hidden": "true",
fill: "none",
height: "16",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
viewBox: "0 0 24 24",
width: "16",
},
[h("path", { d: "m9 18 6-6-6-6" })],
);
}
export default defineComponent({
name: "MenuItemSubmenuIndicator",
inheritAttrs: false,
props: { as: { type: String, default: "span" } },
setup(props, { slots }) {
const attrs = useAttrs();
const item = inject(menuItemContextKey, null);
item?.setHasSubmenu(true);
onMounted(() => item?.setHasSubmenu(true));
onUnmounted(() => item?.setHasSubmenu(false));
return () => {
if (!item?.hasSubmenu.value) return null;
return h(
props.as,
{
...attrs,
"aria-hidden": "true",
class: [item.slots.value.submenuIndicator(), attrs.class],
"data-slot": "submenu-indicator",
},
slots.default ? slots.default() : ChevronIcon(),
);
};
},
});
</script>