Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(comp:menu): type of MenuItem is optional #712

Merged
merged 2 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions packages/components/menu/__tests__/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { renderWork, wait } from '@tests'

import Menu from '../src/Menu'
// import MenuDivider from '../src/MenuDivider'
import MenuItem from '../src/children/MenuItem'
import MenuItem from '../src/contents/MenuItem'
// import MenuItemGroup from '../src/MenuItemGroup'
import MenuSub from '../src/children/menu-sub/MenuSub'
import MenuSub from '../src/contents/menu-sub/MenuSub'
import { MenuData, MenuProps } from '../src/types'

const dataSource: MenuData[] = [
{ type: 'item', key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ type: 'item', key: 'item2', icon: 'mail', label: 'Item 2' },
{ type: 'item', key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ key: 'item2', icon: 'mail', label: 'Item 2' },
{ key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ type: 'divider', key: 'divider1' },
{
type: 'sub',
Expand All @@ -26,8 +26,8 @@ const dataSource: MenuData[] = [
key: 'itemGroup1',
label: 'Item Group 1',
children: [
{ type: 'item', key: 'item4', label: 'Item 4' },
{ type: 'item', key: 'item5', label: 'Item 5' },
{ key: 'item4', label: 'Item 4' },
{ key: 'item5', label: 'Item 5' },
],
},
{ type: 'divider', key: 'divider2' },
Expand All @@ -36,17 +36,17 @@ const dataSource: MenuData[] = [
key: 'sub2',
label: 'Menu Sub 2',
children: [
{ type: 'item', key: 'item6', label: 'Item 6' },
{ type: 'item', key: 'item7', label: 'Item 7' },
{ key: 'item6', label: 'Item 6' },
{ key: 'item7', label: 'Item 7' },
],
},
{
type: 'sub',
key: 'sub3',
label: 'Menu Sub 3',
children: [
{ type: 'item', key: 'item8', label: 'Item 8' },
{ type: 'item', key: 'item9', label: 'Item 9' },
{ key: 'item8', label: 'Item 8' },
{ key: 'item9', label: 'Item 9' },
],
},
],
Expand All @@ -58,8 +58,8 @@ const dataSource: MenuData[] = [
label: 'Menu Sub 4',
disabled: true,
children: [
{ type: 'item', key: 'item10', label: 'Item 10' },
{ type: 'item', key: 'item11', label: 'Item 11' },
{ key: 'item10', label: 'Item 10' },
{ key: 'item11', label: 'Item 11' },
],
},
]
Expand Down
22 changes: 11 additions & 11 deletions packages/components/menu/demo/Horizontal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { h } from 'vue'
import { MenuData } from '@idux/components/menu'

const dataSource: MenuData[] = [
{ type: 'item', key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ type: 'item', key: 'item2', icon: 'mail', label: 'Item 2' },
{ type: 'item', key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ key: 'item2', icon: 'mail', label: 'Item 2' },
{ key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ type: 'divider', key: 'divider1' },
{
type: 'sub',
Expand All @@ -22,8 +22,8 @@ const dataSource: MenuData[] = [
key: 'itemGroup1',
label: 'Item Group 1',
children: [
{ type: 'item', key: 'item4', label: 'Item 4' },
{ type: 'item', key: 'item5', label: 'Item 5' },
{ key: 'item4', label: 'Item 4' },
{ key: 'item5', label: 'Item 5' },
],
},
{ type: 'divider', key: 'divider2' },
Expand All @@ -32,17 +32,17 @@ const dataSource: MenuData[] = [
key: 'sub2',
label: 'Menu Sub 2',
children: [
{ type: 'item', key: 'item6', label: 'Item 6' },
{ type: 'item', key: 'item7', label: 'Item 7' },
{ key: 'item6', label: 'Item 6' },
{ key: 'item7', label: 'Item 7' },
],
},
{
type: 'sub',
key: 'sub3',
label: 'Menu Sub 3',
children: [
{ type: 'item', key: 'item8', label: 'Item 8' },
{ type: 'item', key: 'item9', label: 'Item 9' },
{ key: 'item8', label: 'Item 8' },
{ key: 'item9', label: 'Item 9' },
],
},
],
Expand All @@ -54,8 +54,8 @@ const dataSource: MenuData[] = [
label: 'Menu Sub 4',
disabled: true,
children: [
{ type: 'item', key: 'item10', label: 'Item 10' },
{ type: 'item', key: 'item11', label: 'Item 11' },
{ key: 'item10', label: 'Item 10' },
{ key: 'item11', label: 'Item 11' },
],
},
]
Expand Down
24 changes: 12 additions & 12 deletions packages/components/menu/demo/Inline.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<template>
<IxMenu mode="inline" :dataSource="dataSource" style="width: 256px"> </IxMenu>
<IxMenu mode="inline" multiple :dataSource="dataSource" style="width: 256px"> </IxMenu>
</template>
<script setup lang="ts">
import { h } from 'vue'

import { MenuData } from '@idux/components/menu'

const dataSource: MenuData[] = [
{ type: 'item', key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ type: 'item', key: 'item2', icon: 'mail', label: 'Item 2' },
{ type: 'item', key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ key: 'item2', icon: 'mail', label: 'Item 2' },
{ key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ type: 'divider', key: 'divider1' },
{
type: 'sub',
Expand All @@ -22,8 +22,8 @@ const dataSource: MenuData[] = [
key: 'itemGroup1',
label: 'Item Group 1',
children: [
{ type: 'item', key: 'item4', label: 'Item 4' },
{ type: 'item', key: 'item5', label: 'Item 5' },
{ key: 'item4', label: 'Item 4' },
{ key: 'item5', label: 'Item 5' },
],
},
{ type: 'divider', key: 'divider2' },
Expand All @@ -32,17 +32,17 @@ const dataSource: MenuData[] = [
key: 'sub2',
label: 'Menu Sub 2',
children: [
{ type: 'item', key: 'item6', label: 'Item 6' },
{ type: 'item', key: 'item7', label: 'Item 7' },
{ key: 'item6', label: 'Item 6' },
{ key: 'item7', label: 'Item 7' },
],
},
{
type: 'sub',
key: 'sub3',
label: 'Menu Sub 3',
children: [
{ type: 'item', key: 'item8', label: 'Item 8' },
{ type: 'item', key: 'item9', label: 'Item 9' },
{ key: 'item8', label: 'Item 8' },
{ key: 'item9', label: 'Item 9' },
],
},
],
Expand All @@ -54,8 +54,8 @@ const dataSource: MenuData[] = [
label: 'Menu Sub 4',
disabled: true,
children: [
{ type: 'item', key: 'item10', label: 'Item 10' },
{ type: 'item', key: 'item11', label: 'Item 11' },
{ key: 'item10', label: 'Item 10' },
{ key: 'item11', label: 'Item 11' },
],
},
]
Expand Down
20 changes: 10 additions & 10 deletions packages/components/menu/demo/SingleOpen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const dataSource: MenuData[] = [
key: 'itemGroup1',
label: 'Item Group 1',
children: [
{ type: 'item', key: 'item4', label: 'Item 4' },
{ type: 'item', key: 'item5', label: 'Item 5' },
{ key: 'item4', label: 'Item 4' },
{ key: 'item5', label: 'Item 5' },
],
},
{ type: 'divider', key: 'divider2' },
Expand All @@ -37,17 +37,17 @@ const dataSource: MenuData[] = [
key: 'sub2',
label: 'Menu Sub 2',
children: [
{ type: 'item', key: 'item6', label: 'Item 6' },
{ type: 'item', key: 'item7', label: 'Item 7' },
{ key: 'item6', label: 'Item 6' },
{ key: 'item7', label: 'Item 7' },
],
},
{
type: 'sub',
key: 'sub3',
label: 'Menu Sub 3',
children: [
{ type: 'item', key: 'item8', label: 'Item 8' },
{ type: 'item', key: 'item9', label: 'Item 9' },
{ key: 'item8', label: 'Item 8' },
{ key: 'item9', label: 'Item 9' },
],
},
],
Expand All @@ -58,8 +58,8 @@ const dataSource: MenuData[] = [
icon: 'github',
label: 'Menu Sub 4',
children: [
{ type: 'item', key: 'item10', label: 'Item 10' },
{ type: 'item', key: 'item11', label: 'Item 11' },
{ key: 'item10', label: 'Item 10' },
{ key: 'item11', label: 'Item 11' },
],
},
{
Expand All @@ -68,8 +68,8 @@ const dataSource: MenuData[] = [
icon: 'github',
label: 'Menu Sub 5',
children: [
{ type: 'item', key: 'item12', label: 'Item 12' },
{ type: 'item', key: 'item13', label: 'Item 13' },
{ key: 'item12', label: 'Item 12' },
{ key: 'item13', label: 'Item 13' },
],
},
]
Expand Down
19 changes: 9 additions & 10 deletions packages/components/menu/demo/Slots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import { IxIcon } from '@idux/components/icon'
import { MenuData } from '@idux/components/menu'

const dataSource: MenuData[] = [
{ type: 'item', key: 'item1', icon: 'home', label: 'Item 1', slots: { label: 'label' } },
{ key: 'item1', icon: 'home', label: 'Item 1', slots: { label: 'label' } },
{
type: 'item',
key: 'item2',
label: 'Item 2',
slots: { label: item => h('a', item.label), icon: () => h(IxIcon, { name: 'mail' }) },
Expand All @@ -36,8 +35,8 @@ const dataSource: MenuData[] = [
label: 'Item Group 1',

children: [
{ type: 'item', key: 'item4', label: 'Item 4', slots: { label: 'label' } },
{ type: 'item', key: 'item5', label: 'Item 5' },
{ key: 'item4', label: 'Item 4', slots: { label: 'label' } },
{ key: 'item5', label: 'Item 5' },
],
},
{ type: 'divider', key: 'divider2' },
Expand All @@ -46,17 +45,17 @@ const dataSource: MenuData[] = [
key: 'sub2',
label: 'Menu Sub 2',
children: [
{ type: 'item', key: 'item6', label: 'Item 6', slots: { label: 'label' } },
{ type: 'item', key: 'item7', label: 'Item 7' },
{ key: 'item6', label: 'Item 6', slots: { label: 'label' } },
{ key: 'item7', label: 'Item 7' },
],
},
{
type: 'sub',
key: 'sub3',
label: 'Menu Sub 3',
children: [
{ type: 'item', key: 'item8', label: 'Item 8' },
{ type: 'item', key: 'item9', label: 'Item 9' },
{ key: 'item8', label: 'Item 8' },
{ key: 'item9', label: 'Item 9' },
],
},
],
Expand All @@ -67,8 +66,8 @@ const dataSource: MenuData[] = [
label: 'Menu Sub 4',
slots: { label: 'label', icon: 'subIcon' },
children: [
{ type: 'item', key: 'item10', label: 'Item 10' },
{ type: 'item', key: 'item11', label: 'Item 911' },
{ key: 'item10', label: 'Item 10' },
{ key: 'item11', label: 'Item 911' },
],
},
]
Expand Down
22 changes: 11 additions & 11 deletions packages/components/menu/demo/StateSwitching.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const selectedKeys = ref([])
const expandedKeys = ref([])

const dataSource: MenuData[] = [
{ type: 'item', key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ type: 'item', key: 'item2', icon: 'mail', label: 'Item 2' },
{ type: 'item', key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ key: 'item1', icon: 'home', slots: { label: () => h('a', 'Item 1') } },
{ key: 'item2', icon: 'mail', label: 'Item 2' },
{ key: 'item3', icon: 'appstore', label: 'Item 3', disabled: true },
{ type: 'divider', key: 'divider1' },
{
type: 'sub',
Expand All @@ -67,8 +67,8 @@ const dataSource: MenuData[] = [
key: 'itemGroup1',
label: 'Item Group 1',
children: [
{ type: 'item', key: 'item4', label: 'Item 4' },
{ type: 'item', key: 'item5', label: 'Item 5' },
{ key: 'item4', label: 'Item 4' },
{ key: 'item5', label: 'Item 5' },
],
},
{ type: 'divider', key: 'divider2' },
Expand All @@ -77,17 +77,17 @@ const dataSource: MenuData[] = [
key: 'sub2',
label: 'Menu Sub 2',
children: [
{ type: 'item', key: 'item6', label: 'Item 6' },
{ type: 'item', key: 'item7', label: 'Item 7' },
{ key: 'item6', label: 'Item 6' },
{ key: 'item7', label: 'Item 7' },
],
},
{
type: 'sub',
key: 'sub3',
label: 'Menu Sub 3',
children: [
{ type: 'item', key: 'item8', label: 'Item 8' },
{ type: 'item', key: 'item9', label: 'Item 9' },
{ key: 'item8', label: 'Item 8' },
{ key: 'item9', label: 'Item 9' },
],
},
],
Expand All @@ -99,8 +99,8 @@ const dataSource: MenuData[] = [
label: 'Menu Sub 4',
disabled: true,
children: [
{ type: 'item', key: 'item10', label: 'Item 10' },
{ type: 'item', key: 'item11', label: 'Item 11' },
{ key: 'item10', label: 'Item 10' },
{ key: 'item11', label: 'Item 11' },
],
},
]
Expand Down
Loading