ant-design/components/menu/interface.ts
gregor-mueller 48eb543646
fix(Menu): Set correct value type for MenuItem data attributes (#54539)
* fix(Menu): Set correct value type for MenuItem data attributes

* Update components/menu/interface.ts

Co-authored-by: afc163 <afc163@gmail.com>
Signed-off-by: thinkasany <480968828@qq.com>

* change the type to `unknown` to support anything

* Update components/menu/interface.ts

Signed-off-by: thinkasany <480968828@qq.com>

---------

Signed-off-by: thinkasany <480968828@qq.com>
Co-authored-by: thinkasany <480968828@qq.com>
Co-authored-by: afc163 <afc163@gmail.com>
2025-07-31 16:17:42 +08:00

41 lines
1,023 B
TypeScript

import type {
MenuDividerType as RcMenuDividerType,
MenuItemGroupType as RcMenuItemGroupType,
MenuItemType as RcMenuItemType,
SubMenuType as RcSubMenuType,
} from 'rc-menu/lib/interface';
export type DataAttributes = {
[Key in `data-${string}`]: unknown;
};
export interface MenuItemType extends RcMenuItemType, DataAttributes {
danger?: boolean;
icon?: React.ReactNode;
title?: string;
}
export interface SubMenuType<T extends MenuItemType = MenuItemType>
extends Omit<RcSubMenuType, 'children'> {
icon?: React.ReactNode;
theme?: 'dark' | 'light';
children: ItemType<T>[];
}
export interface MenuItemGroupType<T extends MenuItemType = MenuItemType>
extends Omit<RcMenuItemGroupType, 'children'> {
children?: ItemType<T>[];
key?: React.Key;
}
export interface MenuDividerType extends RcMenuDividerType {
dashed?: boolean;
key?: React.Key;
}
export type ItemType<T extends MenuItemType = MenuItemType> =
| T
| SubMenuType<T>
| MenuItemGroupType<T>
| MenuDividerType
| null;