Line data Source code
1 16 : <script setup lang="ts">
2 : import { computed, toValue } from 'vue'
3 :
4 : import MenuRadioGroup from './MenuRadioGroup.vue'
5 : import MenuSub from './MenuSub.vue'
6 : import MenuSubContent from './MenuSubContent.vue'
7 : import MenuSubTrigger from './MenuSubTrigger.vue'
8 : import type { MenuItemRadioGroup, MenuItemSubmenu } from './types'
9 :
10 : const { item } = defineProps<{
11 : item: MenuItemSubmenu | MenuItemRadioGroup
12 : }>()
13 :
14 2355 : const disabled = computed(
15 : () =>
16 : toValue(item.disabled) ||
17 : (item.items ?? item.radioGroup.options).length === 0
18 : )
19 1183 : </script>
20 :
21 : <template>
22 8376 : <MenuSub>
23 : <MenuSubTrigger
24 : :aria-label="toValue(item.label)"
25 : :disabled
26 : :class="toValue(item.class)"
27 : >
28 : <slot />
29 : </MenuSubTrigger>
30 : <MenuSubContent :side-offset="2" :align-offset="-5">
31 : <slot v-if="item.items" name="content" :items="item.items" />
32 : <MenuRadioGroup
33 : v-else
34 : :model-value="toValue(item.radioGroup.value)"
35 : :options="item.radioGroup.options"
36 : />
37 : </MenuSubContent>
38 : </MenuSub>
39 : </template>
|