From c68d59c6a041b211dfdd5c564f7ddc1a4da65148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Tue, 28 Sep 2021 10:59:22 +0800 Subject: [PATCH] refactor(components): refactor menu (#3639) * refactor(menu): rename to kebab-case * refactor(menu): rename RootMenuProvider to MenuProvider * refactor(menu): rename menu.type to types * refactor(menu): extract menu props and emits * refactor(menu): change sub-menu.vue to ts * refactor(menu): extract menu-item-group props and emits * refactor(menu): extract menu-item props and emits * refactor(menu): extract sub-menu props and emits * refactor(menu): rename type RegisterMenuItem to MenuItemRegistered * refactor(menu): MenuProvider ref to reactive * refactor(menu): MenuProvider remove methods * refactor(menu): change submenus to subMenus * refactor(menu): remove RootMenuProps type * refactor(menu): MenuProvider improve types & rename submenu to subMenu * refactor(menu): menu add block to provide * refactor(menu): menu improve expose * refactor(menu): menu improve render types * refactor(menu): menu refactor types & change handle(Sub)MenuItemClick params * refactor(menu): menu refactor types * refactor(menu): menu-item-group improve types * refactor(menu): menu-item improve types * refactor(menu): sub-menu improve types * refactor(menu): use-menu improve types * refactor(menu): sub-menu fix types * refactor(menu): menu-collapse-transition improve types * refactor(menu): menu-item-group improve template * refactor(menu): menu-item rename emit param * refactor(menu): finally improve types * fix lint * chore: re-order import * chore: remove reactive --- .../components/menu/__tests__/menu.spec.ts | 14 +- packages/components/menu/index.ts | 12 +- .../menu/src/menu-collapse-transition.vue | 89 ++-- .../components/menu/src/menu-item-group.ts | 6 + .../components/menu/src/menu-item-group.vue | 53 ++ packages/components/menu/src/menu-item.ts | 24 + packages/components/menu/src/menu-item.vue | 128 +++++ packages/components/menu/src/menu.ts | 348 +++++++------ packages/components/menu/src/menu.type.ts | 103 ---- packages/components/menu/src/menuItem.vue | 128 ----- .../components/menu/src/menuItemGroup.vue | 67 --- packages/components/menu/src/sub-menu.ts | 422 +++++++++++++++ packages/components/menu/src/submenu.vue | 483 ------------------ packages/components/menu/src/types.ts | 39 ++ .../components/menu/src/use-menu-color.ts | 4 +- .../components/menu/src/use-menu-css-var.ts | 4 +- packages/components/menu/src/use-menu.ts | 27 +- 17 files changed, 938 insertions(+), 1013 deletions(-) create mode 100644 packages/components/menu/src/menu-item-group.ts create mode 100644 packages/components/menu/src/menu-item-group.vue create mode 100644 packages/components/menu/src/menu-item.ts create mode 100644 packages/components/menu/src/menu-item.vue delete mode 100644 packages/components/menu/src/menu.type.ts delete mode 100644 packages/components/menu/src/menuItem.vue delete mode 100644 packages/components/menu/src/menuItemGroup.vue create mode 100644 packages/components/menu/src/sub-menu.ts delete mode 100644 packages/components/menu/src/submenu.vue create mode 100644 packages/components/menu/src/types.ts diff --git a/packages/components/menu/__tests__/menu.spec.ts b/packages/components/menu/__tests__/menu.spec.ts index b04634fa30..2387f4406f 100644 --- a/packages/components/menu/__tests__/menu.spec.ts +++ b/packages/components/menu/__tests__/menu.spec.ts @@ -4,9 +4,9 @@ import { sleep } from '@element-plus/test-utils' import { rAF } from '@element-plus/test-utils/tick' import Menu from '../src/menu' -import MenuGroup from '../src/menuItemGroup.vue' -import MenuItem from '../src/menuItem.vue' -import SubMenu from '../src/submenu.vue' +import MenuGroup from '../src/menu-item-group.vue' +import MenuItem from '../src/menu-item.vue' +import SubMenu from '../src/sub-menu' const _mount = (template: string, options = {}) => mount({ @@ -119,7 +119,7 @@ describe('menu', () => { default-active="2" class="el-menu-vertical-demo" > - +