element-plus/packages/components/menu/src/menu-item.ts

25 lines
763 B
TypeScript

import { buildProps, definePropType } from '@element-plus/utils/props'
import { isString } from '@element-plus/utils/util'
import type { ExtractPropTypes } from 'vue'
import type { RouteLocationRaw } from 'vue-router'
import type { MenuItemRegistered } from './types'
export const menuItemProps = buildProps({
index: {
type: definePropType<string | null>([String, null]),
default: null,
},
route: {
type: definePropType<RouteLocationRaw>([String, Object]),
},
disabled: Boolean,
} as const)
export type MenuItemProps = ExtractPropTypes<typeof menuItemProps>
export const menuItemEmits = {
click: (item: MenuItemRegistered) =>
isString(item.index) && Array.isArray(item.indexPath),
}
export type MenuItemEmits = typeof menuItemEmits