From 05ec0ea368c625d7ad13831780ccf224b73f58e6 Mon Sep 17 00:00:00 2001 From: danranvm Date: Mon, 10 Jan 2022 10:44:11 +0800 Subject: [PATCH 1/2] feat(comp:menu): type of MenuItem is optional --- .../components/menu/__tests__/menu.spec.ts | 26 ++++---- packages/components/menu/demo/Horizontal.vue | 22 +++---- packages/components/menu/demo/Inline.vue | 24 +++---- packages/components/menu/demo/SingleOpen.vue | 20 +++--- packages/components/menu/demo/Slots.vue | 19 +++--- .../components/menu/demo/StateSwitching.vue | 22 +++---- packages/components/menu/demo/Vertical.vue | 22 +++---- packages/components/menu/docs/Index.zh.md | 65 +++++++++++++++++-- packages/components/menu/src/Menu.tsx | 2 +- .../{children => contents}/MenuDivider.tsx | 0 .../src/{children => contents}/MenuItem.tsx | 18 ++--- .../{children => contents}/MenuItemGroup.tsx | 0 .../menu/src/{children => contents}/Utils.tsx | 2 +- .../menu-sub/InlineContent.tsx | 0 .../menu-sub/MenuSub.tsx | 1 + .../menu-sub/OverlayContent.tsx | 0 .../{children => contents}/menu-sub/Title.tsx | 21 ++++-- packages/components/menu/src/token.ts | 1 + packages/components/menu/src/types.ts | 36 +++++----- 19 files changed, 181 insertions(+), 120 deletions(-) rename packages/components/menu/src/{children => contents}/MenuDivider.tsx (100%) rename packages/components/menu/src/{children => contents}/MenuItem.tsx (84%) rename packages/components/menu/src/{children => contents}/MenuItemGroup.tsx (100%) rename packages/components/menu/src/{children => contents}/Utils.tsx (97%) rename packages/components/menu/src/{children => contents}/menu-sub/InlineContent.tsx (100%) rename packages/components/menu/src/{children => contents}/menu-sub/MenuSub.tsx (99%) rename packages/components/menu/src/{children => contents}/menu-sub/OverlayContent.tsx (100%) rename packages/components/menu/src/{children => contents}/menu-sub/Title.tsx (74%) diff --git a/packages/components/menu/__tests__/menu.spec.ts b/packages/components/menu/__tests__/menu.spec.ts index ca27f5b0f..d2dc0f905 100644 --- a/packages/components/menu/__tests__/menu.spec.ts +++ b/packages/components/menu/__tests__/menu.spec.ts @@ -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', @@ -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' }, @@ -36,8 +36,8 @@ 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' }, ], }, { @@ -45,8 +45,8 @@ const dataSource: MenuData[] = [ 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' }, ], }, ], @@ -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' }, ], }, ] diff --git a/packages/components/menu/demo/Horizontal.vue b/packages/components/menu/demo/Horizontal.vue index 7dc03a5cb..c160e198c 100644 --- a/packages/components/menu/demo/Horizontal.vue +++ b/packages/components/menu/demo/Horizontal.vue @@ -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', @@ -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' }, @@ -32,8 +32,8 @@ 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' }, ], }, { @@ -41,8 +41,8 @@ const dataSource: MenuData[] = [ 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' }, ], }, ], @@ -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' }, ], }, ] diff --git a/packages/components/menu/demo/Inline.vue b/packages/components/menu/demo/Inline.vue index 5b96e8f89..d301ec685 100644 --- a/packages/components/menu/demo/Inline.vue +++ b/packages/components/menu/demo/Inline.vue @@ -1,5 +1,5 @@