2023-07-17 10:13:22 +08:00
|
|
|
import type { CSSProperties } from 'react';
|
2022-11-30 18:56:36 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2023-11-29 17:23:45 +08:00
|
|
|
import { unit } from '@ant-design/cssinjs';
|
2023-05-26 17:15:03 +08:00
|
|
|
import { TinyColor } from '@ctrl/tinycolor';
|
2023-11-14 02:59:19 +08:00
|
|
|
import type { CssUtil } from 'antd-style';
|
2023-11-13 10:15:07 +08:00
|
|
|
|
2023-05-26 17:15:03 +08:00
|
|
|
import { clearFix, resetComponent, resetIcon } from '../../style';
|
2022-07-28 20:33:10 +08:00
|
|
|
import { genCollapseMotion, initSlideMotion, initZoomMotion } from '../../style/motion';
|
2024-01-12 15:03:03 +08:00
|
|
|
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
2023-11-29 17:23:45 +08:00
|
|
|
import { genStyleHooks, mergeToken } from '../../theme/internal';
|
2022-05-23 10:58:30 +08:00
|
|
|
import getHorizontalStyle from './horizontal';
|
|
|
|
import getRTLStyle from './rtl';
|
|
|
|
import getThemeStyle from './theme';
|
|
|
|
import getVerticalStyle from './vertical';
|
2017-06-30 21:07:01 +08:00
|
|
|
|
2022-04-20 15:31:04 +08:00
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
2022-05-23 10:58:30 +08:00
|
|
|
export interface ComponentToken {
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 弹出菜单的宽度
|
|
|
|
* @descEN Width of popup menu
|
|
|
|
*/
|
2024-07-14 00:36:43 +08:00
|
|
|
dropdownWidth: number | string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 弹出菜单的 z-index
|
|
|
|
* @descEN z-index of popup menu
|
|
|
|
*/
|
2022-05-23 10:58:30 +08:00
|
|
|
zIndexPopup: number;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Group
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `groupTitleColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorGroupTitle: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 分组标题文字颜色
|
|
|
|
* @descEN Color of group title text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
groupTitleColor: string;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 分组标题文字高度
|
|
|
|
* @descEN line-height of group title
|
|
|
|
*/
|
2023-11-13 09:38:05 +08:00
|
|
|
groupTitleLineHeight: string | number;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 分组标题文字大小
|
|
|
|
* @descEN font-size of group title
|
|
|
|
*/
|
|
|
|
groupTitleFontSize: number;
|
2022-07-28 20:33:10 +08:00
|
|
|
|
|
|
|
// radius
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemBorderRadius` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
radiusItem: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项的圆角
|
|
|
|
* @descEN Radius of menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemBorderRadius: number;
|
|
|
|
|
|
|
|
/** @deprecated Use `subMenuItemBorderRadius` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
radiusSubMenuItem: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 子菜单项的圆角
|
|
|
|
* @descEN Radius of sub-menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBorderRadius: number;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Item Text
|
|
|
|
// > Default
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemText: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字颜色
|
|
|
|
* @descEN Color of menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemHoverColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemTextHover: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字悬浮颜色
|
|
|
|
* @descEN Hover color of menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemHoverColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `horizontalItemHoverColor` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemTextHoverHorizontal: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 水平菜单项文字悬浮颜色
|
|
|
|
* @descEN Hover color of horizontal menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemHoverColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemSelectedColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemTextSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemSelectedColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `horizontalItemSelectedColor` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemTextSelectedHorizontal: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 水平菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected horizontal menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemSelectedColor: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// > Disabled
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemDisabledColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemTextDisabled: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项文字禁用颜色
|
|
|
|
* @descEN Color of disabled menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemDisabledColor: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// > Danger
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `dangerItemColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemText: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字颜色
|
|
|
|
* @descEN Color of danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemHoverColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemTextHover: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字悬浮颜色
|
|
|
|
* @descEN Hover color of danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemHoverColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemSelectedColor` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorDangerItemTextSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemSelectedColor: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemActiveBg` instead */
|
2022-09-19 22:17:26 +08:00
|
|
|
colorDangerItemBgActive: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字激活颜色
|
|
|
|
* @descEN Color of active danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemActiveBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `dangerItemSelectedBg` instead */
|
2022-09-19 22:17:26 +08:00
|
|
|
colorDangerItemBgSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 危险菜单项文字选中颜色
|
|
|
|
* @descEN Color of selected danger menu item text
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
dangerItemSelectedBg: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Item Bg
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBg: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项背景色
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemHoverBg` instead */
|
2022-10-18 17:04:06 +08:00
|
|
|
colorItemBgHover: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项悬浮态背景色
|
|
|
|
* @descEN Background color of menu item when hover
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemHoverBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `subMenuItemBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorSubItemBg: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 子菜单项背景色
|
|
|
|
* @descEN Background color of sub-menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBg: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// > Default
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `itemActiveBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBgActive: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项激活态背景色
|
|
|
|
* @descEN Background color of menu item when active
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemActiveBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `itemSelectedBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBgSelected: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项选中态背景色
|
|
|
|
* @descEN Background color of menu item when selected
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
itemSelectedBg: string;
|
|
|
|
|
|
|
|
/** @deprecated Use `horizontalItemSelectedBg` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorItemBgSelectedHorizontal: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 水平菜单项选中态背景色
|
|
|
|
* @descEN Background color of horizontal menu item when selected
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemSelectedBg: string;
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Ink Bar
|
2023-06-06 16:11:18 +08:00
|
|
|
/** @deprecated Use `activeBarWidth` instead */
|
2024-07-14 00:36:43 +08:00
|
|
|
colorActiveBarWidth: number | string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项指示条宽度
|
|
|
|
* @descEN Width of menu item active bar
|
|
|
|
*/
|
2024-07-14 00:36:43 +08:00
|
|
|
activeBarWidth: number | string;
|
2023-06-06 16:11:18 +08:00
|
|
|
|
|
|
|
/** @deprecated Use `activeBarHeight` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorActiveBarHeight: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项指示条高度
|
|
|
|
* @descEN Height of menu item active bar
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
activeBarHeight: number;
|
|
|
|
|
|
|
|
/** @deprecated Use `activeBarBorderWidth` instead */
|
2022-07-28 20:33:10 +08:00
|
|
|
colorActiveBarBorderSize: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项指示条边框宽度
|
|
|
|
* @descEN Border width of menu item active bar
|
|
|
|
*/
|
2024-07-14 00:36:43 +08:00
|
|
|
activeBarBorderWidth: number | string;
|
2022-10-18 17:04:06 +08:00
|
|
|
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项横向外间距
|
|
|
|
* @descEN Horizontal margin of menu item
|
|
|
|
*/
|
2022-10-18 17:04:06 +08:00
|
|
|
itemMarginInline: number;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 横向菜单项横悬浮态背景色
|
|
|
|
* @descEN Background color of horizontal menu item when hover
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemHoverBg: string;
|
2023-07-05 17:49:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 横向菜单项圆角
|
|
|
|
* @descEN Border radius of horizontal menu item
|
|
|
|
*/
|
2023-06-06 16:11:18 +08:00
|
|
|
horizontalItemBorderRadius: number;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单项高度
|
|
|
|
* @descEN Height of menu item
|
|
|
|
*/
|
2024-07-14 00:36:43 +08:00
|
|
|
itemHeight: number | string;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 收起后的宽度
|
|
|
|
* @descEN Width when collapsed
|
|
|
|
*/
|
2024-07-14 00:36:43 +08:00
|
|
|
collapsedWidth: number | string;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 弹出框背景色
|
|
|
|
* @descEN Background color of popup
|
|
|
|
*/
|
|
|
|
popupBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 菜单项纵向外间距
|
|
|
|
* @descEN margin-block of menu item
|
|
|
|
*/
|
|
|
|
itemMarginBlock: CSSProperties['marginBlock'];
|
|
|
|
/**
|
|
|
|
* @desc 菜单项横向内间距
|
|
|
|
* @descEN padding-inline of menu item
|
|
|
|
*/
|
|
|
|
itemPaddingInline: CSSProperties['paddingInline'];
|
|
|
|
/**
|
|
|
|
* @desc 横向菜单行高
|
|
|
|
* @descEN LineHeight of horizontal menu item
|
|
|
|
*/
|
|
|
|
horizontalLineHeight: CSSProperties['lineHeight'];
|
|
|
|
/**
|
|
|
|
* @desc 图标与文字间距
|
|
|
|
* @descEN Spacing between icon and text
|
|
|
|
*/
|
|
|
|
iconMarginInlineEnd: CSSProperties['marginInlineEnd'];
|
|
|
|
/**
|
|
|
|
* @desc 图标尺寸
|
|
|
|
* @descEN Size of icon
|
|
|
|
*/
|
|
|
|
iconSize: number;
|
|
|
|
/**
|
|
|
|
* @desc 收起时图标尺寸
|
|
|
|
* @descEN Size of icon when collapsed
|
|
|
|
*/
|
|
|
|
collapsedIconSize: number;
|
|
|
|
|
|
|
|
// Dark
|
2023-12-29 16:49:57 +08:00
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的浮层菜单的背景颜色
|
|
|
|
* @descEN The background color of the overlay menu in dark mode.
|
|
|
|
*/
|
|
|
|
darkPopupBg: string;
|
2023-07-17 10:13:22 +08:00
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项文字颜色
|
|
|
|
* @descEN Color of menu item text in dark mode
|
|
|
|
*/
|
|
|
|
darkItemColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项文字颜色
|
|
|
|
* @descEN Color of danger menu item text in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项背景
|
|
|
|
* @descEN Background of menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的子菜单项背景
|
|
|
|
* @descEN Background of submenu item in dark mode
|
|
|
|
*/
|
|
|
|
darkSubMenuItemBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项选中颜色
|
|
|
|
* @descEN Color of selected menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemSelectedColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项选中背景
|
|
|
|
* @descEN Background of active menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemSelectedBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项悬浮背景
|
|
|
|
* @descEN Background of hovered menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemHoverBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的分组标题文字颜色
|
|
|
|
* @descEN Color of group title text in dark mode
|
|
|
|
*/
|
|
|
|
darkGroupTitleColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项悬浮颜色
|
|
|
|
* @descEN Color of hovered menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemHoverColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的菜单项禁用颜色
|
|
|
|
* @descEN Color of disabled menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkItemDisabledColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项选中背景
|
|
|
|
* @descEN Background of active danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemSelectedBg: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项悬浮文字背景
|
|
|
|
* @descEN Background of hovered danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemHoverColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项选中文字颜色
|
|
|
|
* @descEN Color of selected danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemSelectedColor: string;
|
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的危险菜单项激活态背景
|
|
|
|
* @descEN Background of active danger menu item in dark mode
|
|
|
|
*/
|
|
|
|
darkDangerItemActiveBg: string;
|
2023-11-13 09:38:05 +08:00
|
|
|
/** @internal */
|
2024-07-14 00:36:43 +08:00
|
|
|
itemWidth: number | string;
|
2022-07-28 20:33:10 +08:00
|
|
|
}
|
|
|
|
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc Menu 组件的 Token
|
|
|
|
* @descEN Token for Menu component
|
|
|
|
*/
|
2022-07-28 20:33:10 +08:00
|
|
|
export interface MenuToken extends FullToken<'Menu'> {
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 水平菜单高度
|
|
|
|
* @descEN Height of horizontal menu
|
|
|
|
*/
|
2023-11-13 09:38:05 +08:00
|
|
|
menuHorizontalHeight: number | string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单箭头尺寸
|
|
|
|
* @descEN Size of menu arrow
|
|
|
|
*/
|
2023-11-13 09:38:05 +08:00
|
|
|
menuArrowSize: number | string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 菜单箭头偏移量
|
|
|
|
* @descEN Offset of menu arrow
|
|
|
|
*/
|
2023-11-13 09:38:05 +08:00
|
|
|
menuArrowOffset: number | string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 子菜单背景色
|
|
|
|
* @descEN Background color of sub-menu
|
|
|
|
*/
|
2022-11-25 16:00:01 +08:00
|
|
|
menuSubMenuBg: string;
|
2024-08-13 18:18:59 +08:00
|
|
|
/**
|
|
|
|
* @desc 暗色模式下的浮层菜单背景色
|
|
|
|
* @descEN Background color of popup menu in dark mode
|
|
|
|
*/
|
2023-12-29 16:49:57 +08:00
|
|
|
darkPopupBg: string;
|
2022-05-23 10:58:30 +08:00
|
|
|
}
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-11-30 18:56:36 +08:00
|
|
|
const genMenuItemStyle = (token: MenuToken): CSSObject => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
motionDurationSlow,
|
|
|
|
motionDurationMid,
|
|
|
|
motionEaseInOut,
|
|
|
|
motionEaseOut,
|
|
|
|
iconCls,
|
2023-07-17 10:13:22 +08:00
|
|
|
iconSize,
|
|
|
|
iconMarginInlineEnd,
|
2022-11-30 18:56:36 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
// >>>>> Item
|
|
|
|
[`${componentCls}-item, ${componentCls}-submenu-title`]: {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'block',
|
|
|
|
margin: 0,
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
cursor: 'pointer',
|
|
|
|
transition: [
|
|
|
|
`border-color ${motionDurationSlow}`,
|
|
|
|
`background ${motionDurationSlow}`,
|
|
|
|
`padding ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
|
|
|
|
|
|
|
[`${componentCls}-item-icon, ${iconCls}`]: {
|
2023-07-17 10:13:22 +08:00
|
|
|
minWidth: iconSize,
|
|
|
|
fontSize: iconSize,
|
2022-11-30 18:56:36 +08:00
|
|
|
transition: [
|
|
|
|
`font-size ${motionDurationMid} ${motionEaseOut}`,
|
|
|
|
`margin ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`color ${motionDurationSlow}`,
|
|
|
|
].join(','),
|
|
|
|
|
|
|
|
'+ span': {
|
2023-07-17 10:13:22 +08:00
|
|
|
marginInlineStart: iconMarginInlineEnd,
|
2022-11-30 18:56:36 +08:00
|
|
|
opacity: 1,
|
|
|
|
transition: [
|
|
|
|
`opacity ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`margin ${motionDurationSlow}`,
|
|
|
|
`color ${motionDurationSlow}`,
|
|
|
|
].join(','),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-item-icon`]: {
|
|
|
|
...resetIcon(),
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-item-only-child`]: {
|
|
|
|
[`> ${iconCls}, > ${componentCls}-item-icon`]: {
|
|
|
|
marginInlineEnd: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Disabled state sets text to gray and nukes hover/tab effects
|
|
|
|
[`${componentCls}-item-disabled, ${componentCls}-submenu-disabled`]: {
|
|
|
|
background: 'none !important',
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
|
|
|
|
'&::after': {
|
|
|
|
borderColor: 'transparent !important',
|
|
|
|
},
|
|
|
|
|
|
|
|
a: {
|
|
|
|
color: 'inherit !important',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`> ${componentCls}-submenu-title`]: {
|
|
|
|
color: 'inherit !important',
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genSubMenuArrowStyle = (token: MenuToken): CSSObject => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
motionDurationSlow,
|
|
|
|
motionEaseInOut,
|
|
|
|
borderRadius,
|
|
|
|
menuArrowSize,
|
|
|
|
menuArrowOffset,
|
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`${componentCls}-submenu`]: {
|
2024-06-22 21:59:12 +08:00
|
|
|
'&-expand-icon, &-arrow': {
|
2022-11-30 18:56:36 +08:00
|
|
|
position: 'absolute',
|
|
|
|
top: '50%',
|
|
|
|
insetInlineEnd: token.margin,
|
|
|
|
width: menuArrowSize,
|
|
|
|
color: 'currentcolor',
|
|
|
|
transform: 'translateY(-50%)',
|
2023-01-01 00:26:54 +08:00
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseInOut}, opacity ${motionDurationSlow}`,
|
2022-11-30 18:56:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-arrow': {
|
|
|
|
// →
|
|
|
|
'&::before, &::after': {
|
|
|
|
position: 'absolute',
|
2023-11-13 09:38:05 +08:00
|
|
|
width: token.calc(menuArrowSize).mul(0.6).equal(),
|
|
|
|
height: token.calc(menuArrowSize).mul(0.15).equal(),
|
2022-11-30 18:56:36 +08:00
|
|
|
backgroundColor: 'currentcolor',
|
|
|
|
borderRadius,
|
|
|
|
transition: [
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`transform ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`top ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`color ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&::before': {
|
2023-11-13 09:38:05 +08:00
|
|
|
transform: `rotate(45deg) translateY(${unit(
|
|
|
|
token.calc(menuArrowOffset).mul(-1).equal(),
|
|
|
|
)})`,
|
2022-11-30 18:56:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
2023-11-13 09:38:05 +08:00
|
|
|
transform: `rotate(-45deg) translateY(${unit(menuArrowOffset)})`,
|
2022-11-30 18:56:36 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// =============================== Base ===============================
|
2022-11-15 22:08:30 +08:00
|
|
|
const getBaseStyle: GenerateStyle<MenuToken> = (token) => {
|
2022-04-20 15:31:04 +08:00
|
|
|
const {
|
|
|
|
antCls,
|
2022-05-23 10:58:30 +08:00
|
|
|
componentCls,
|
|
|
|
fontSize,
|
2022-04-20 15:31:04 +08:00
|
|
|
motionDurationSlow,
|
2022-05-23 10:58:30 +08:00
|
|
|
motionDurationMid,
|
2022-04-20 15:31:04 +08:00
|
|
|
motionEaseInOut,
|
|
|
|
paddingXS,
|
2022-05-23 10:58:30 +08:00
|
|
|
padding,
|
2022-07-21 17:00:42 +08:00
|
|
|
colorSplit,
|
2022-05-23 10:58:30 +08:00
|
|
|
lineWidth,
|
|
|
|
zIndexPopup,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadiusLG,
|
2023-06-06 16:11:18 +08:00
|
|
|
subMenuItemBorderRadius,
|
2022-05-23 10:58:30 +08:00
|
|
|
menuArrowSize,
|
|
|
|
menuArrowOffset,
|
|
|
|
lineType,
|
2023-07-17 10:13:22 +08:00
|
|
|
groupTitleLineHeight,
|
|
|
|
groupTitleFontSize,
|
2022-04-20 15:31:04 +08:00
|
|
|
} = token;
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
return [
|
|
|
|
// Misc
|
|
|
|
{
|
|
|
|
'': {
|
2024-08-05 22:30:55 +08:00
|
|
|
[componentCls]: {
|
2022-11-20 01:08:15 +08:00
|
|
|
...clearFix(),
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Hidden
|
2024-06-22 21:59:12 +08:00
|
|
|
'&-hidden': {
|
2022-05-23 10:58:30 +08:00
|
|
|
display: 'none',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu-hidden`]: {
|
|
|
|
display: 'none',
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
[componentCls]: {
|
|
|
|
...resetComponent(token),
|
2022-11-17 18:37:48 +08:00
|
|
|
...clearFix(),
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
marginBottom: 0,
|
|
|
|
paddingInlineStart: 0, // Override default ul/ol
|
|
|
|
fontSize,
|
|
|
|
lineHeight: 0, // Fix display inline-block gap
|
|
|
|
listStyle: 'none',
|
|
|
|
outline: 'none',
|
2023-04-25 22:53:14 +08:00
|
|
|
// Magic cubic here but smooth transition
|
|
|
|
transition: `width ${motionDurationSlow} cubic-bezier(0.2, 0, 0, 1) 0s`,
|
2022-05-23 10:58:30 +08:00
|
|
|
|
2024-06-22 21:59:12 +08:00
|
|
|
'ul, ol': {
|
2022-05-23 10:58:30 +08:00
|
|
|
margin: 0,
|
2022-04-20 15:31:04 +08:00
|
|
|
padding: 0,
|
2022-05-23 10:58:30 +08:00
|
|
|
listStyle: 'none',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Overflow ellipsis
|
2024-06-22 21:59:12 +08:00
|
|
|
'&-overflow': {
|
2022-05-23 10:58:30 +08:00
|
|
|
display: 'flex',
|
2022-04-20 15:31:04 +08:00
|
|
|
|
|
|
|
[`${componentCls}-item`]: {
|
2022-05-23 10:58:30 +08:00
|
|
|
flex: 'none',
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
2022-11-10 22:03:34 +08:00
|
|
|
[`${componentCls}-item, ${componentCls}-submenu, ${componentCls}-submenu-title`]: {
|
2023-06-06 16:11:18 +08:00
|
|
|
borderRadius: token.itemBorderRadius,
|
2022-07-28 20:33:10 +08:00
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item-group-title`]: {
|
2023-11-13 09:38:05 +08:00
|
|
|
padding: `${unit(paddingXS)} ${unit(padding)}`,
|
2023-07-17 10:13:22 +08:00
|
|
|
fontSize: groupTitleFontSize,
|
|
|
|
lineHeight: groupTitleLineHeight,
|
2022-05-23 10:58:30 +08:00
|
|
|
transition: `all ${motionDurationSlow}`,
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`&-horizontal ${componentCls}-submenu`]: {
|
|
|
|
transition: [
|
|
|
|
`border-color ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu, ${componentCls}-submenu-inline`]: {
|
|
|
|
transition: [
|
|
|
|
`border-color ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`padding ${motionDurationMid} ${motionEaseInOut}`,
|
|
|
|
].join(','),
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu ${componentCls}-sub`]: {
|
|
|
|
cursor: 'initial',
|
|
|
|
transition: [
|
|
|
|
`background ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
`padding ${motionDurationSlow} ${motionEaseInOut}`,
|
2022-12-25 22:55:47 +08:00
|
|
|
].join(','),
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-title-content`]: {
|
2024-09-03 07:15:18 +08:00
|
|
|
display: 'inline-flex',
|
|
|
|
alignItems: 'center',
|
2022-05-23 10:58:30 +08:00
|
|
|
transition: `color ${motionDurationSlow}`,
|
2023-10-08 09:57:58 +08:00
|
|
|
|
2024-09-03 07:15:18 +08:00
|
|
|
'> a:first-child': {
|
|
|
|
flexGrow: 1,
|
|
|
|
},
|
|
|
|
|
2023-10-08 09:57:58 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/41143
|
|
|
|
[`> ${antCls}-typography-ellipsis-single-line`]: {
|
|
|
|
display: 'inline',
|
|
|
|
verticalAlign: 'unset',
|
|
|
|
},
|
2024-09-03 07:15:18 +08:00
|
|
|
|
|
|
|
[`${componentCls}-item-extra`]: {
|
|
|
|
marginInlineStart: 'auto',
|
|
|
|
paddingInlineStart: token.padding,
|
|
|
|
fontSize: token.fontSizeSM,
|
|
|
|
color: token.colorTextDescription,
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item a`]: {
|
|
|
|
'&::before': {
|
|
|
|
position: 'absolute',
|
|
|
|
inset: 0,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
content: '""',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// Removed a Badge related style seems it's safe
|
|
|
|
// https://github.com/ant-design/ant-design/issues/19809
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// >>>>> Divider
|
|
|
|
[`${componentCls}-item-divider`]: {
|
|
|
|
overflow: 'hidden',
|
|
|
|
lineHeight: 0,
|
2022-07-21 17:00:42 +08:00
|
|
|
borderColor: colorSplit,
|
2022-05-23 10:58:30 +08:00
|
|
|
borderStyle: lineType,
|
2023-01-16 19:55:12 +08:00
|
|
|
borderWidth: 0,
|
2022-05-23 10:58:30 +08:00
|
|
|
borderTopWidth: lineWidth,
|
|
|
|
marginBlock: lineWidth,
|
|
|
|
padding: 0,
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
'&-dashed': {
|
|
|
|
borderStyle: 'dashed',
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-11-30 18:56:36 +08:00
|
|
|
// Item
|
|
|
|
...genMenuItemStyle(token),
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item-group`]: {
|
|
|
|
[`${componentCls}-item-group-list`]: {
|
|
|
|
margin: 0,
|
|
|
|
padding: 0,
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-item, ${componentCls}-submenu-title`]: {
|
2023-11-13 09:38:05 +08:00
|
|
|
paddingInline: `${unit(token.calc(fontSize).mul(2).equal())} ${unit(padding)}`,
|
2022-05-23 10:58:30 +08:00
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// ======================= Sub Menu =======================
|
|
|
|
'&-submenu': {
|
|
|
|
'&-popup': {
|
|
|
|
position: 'absolute',
|
|
|
|
zIndex: zIndexPopup,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderRadius: borderRadiusLG,
|
2022-05-23 10:58:30 +08:00
|
|
|
boxShadow: 'none',
|
|
|
|
transformOrigin: '0 0',
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2023-05-26 17:15:03 +08:00
|
|
|
[`&${componentCls}-submenu`]: {
|
|
|
|
background: 'transparent',
|
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/13955
|
|
|
|
'&::before': {
|
|
|
|
position: 'absolute',
|
2024-01-30 17:55:55 +08:00
|
|
|
inset: 0,
|
2022-05-23 10:58:30 +08:00
|
|
|
zIndex: -1,
|
|
|
|
width: '100%',
|
|
|
|
height: '100%',
|
|
|
|
opacity: 0,
|
|
|
|
content: '""',
|
|
|
|
},
|
2024-01-30 11:08:02 +08:00
|
|
|
|
|
|
|
[`> ${componentCls}`]: {
|
|
|
|
borderRadius: borderRadiusLG,
|
|
|
|
|
|
|
|
...genMenuItemStyle(token),
|
|
|
|
...genSubMenuArrowStyle(token),
|
|
|
|
|
|
|
|
[`${componentCls}-item, ${componentCls}-submenu > ${componentCls}-submenu-title`]: {
|
|
|
|
borderRadius: subMenuItemBorderRadius,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-submenu-title::after`]: {
|
|
|
|
transition: `transform ${motionDurationSlow} ${motionEaseInOut}`,
|
|
|
|
},
|
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2023-05-26 17:15:03 +08:00
|
|
|
[`
|
|
|
|
&-placement-leftTop,
|
|
|
|
&-placement-bottomRight,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '100% 0',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-leftBottom,
|
|
|
|
&-placement-topRight,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '100% 100%',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-rightBottom,
|
|
|
|
&-placement-topLeft,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '0 100%',
|
|
|
|
},
|
|
|
|
|
2023-06-06 16:11:18 +08:00
|
|
|
[`
|
|
|
|
&-placement-bottomLeft,
|
|
|
|
&-placement-rightTop,
|
|
|
|
`]: {
|
|
|
|
transformOrigin: '0 0',
|
|
|
|
},
|
|
|
|
|
2023-05-26 17:15:03 +08:00
|
|
|
[`
|
|
|
|
&-placement-leftTop,
|
|
|
|
&-placement-leftBottom
|
|
|
|
`]: {
|
|
|
|
paddingInlineEnd: token.paddingXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-rightTop,
|
|
|
|
&-placement-rightBottom
|
|
|
|
`]: {
|
|
|
|
paddingInlineStart: token.paddingXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-topRight,
|
|
|
|
&-placement-topLeft
|
|
|
|
`]: {
|
|
|
|
paddingBottom: token.paddingXS,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
&-placement-bottomRight,
|
|
|
|
&-placement-bottomLeft
|
|
|
|
`]: {
|
|
|
|
paddingTop: token.paddingXS,
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
2022-11-30 18:56:36 +08:00
|
|
|
...genSubMenuArrowStyle(token),
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`&-inline-collapsed ${componentCls}-submenu-arrow,
|
|
|
|
&-inline ${componentCls}-submenu-arrow`]: {
|
|
|
|
// ↓
|
2022-04-20 15:31:04 +08:00
|
|
|
'&::before': {
|
2023-11-13 09:38:05 +08:00
|
|
|
transform: `rotate(-45deg) translateX(${unit(menuArrowOffset)})`,
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&::after': {
|
2023-11-13 09:38:05 +08:00
|
|
|
transform: `rotate(45deg) translateX(${unit(
|
|
|
|
token.calc(menuArrowOffset).mul(-1).equal(),
|
|
|
|
)})`,
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
[`${componentCls}-submenu-open${componentCls}-submenu-inline > ${componentCls}-submenu-title > ${componentCls}-submenu-arrow`]:
|
|
|
|
{
|
|
|
|
// ↑
|
2023-11-13 09:38:05 +08:00
|
|
|
transform: `translateY(${unit(token.calc(menuArrowSize).mul(0.2).mul(-1).equal())})`,
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
'&::after': {
|
2023-11-13 09:38:05 +08:00
|
|
|
transform: `rotate(-45deg) translateX(${unit(
|
|
|
|
token.calc(menuArrowOffset).mul(-1).equal(),
|
|
|
|
)})`,
|
2022-05-23 10:58:30 +08:00
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
'&::before': {
|
2023-11-13 09:38:05 +08:00
|
|
|
transform: `rotate(45deg) translateX(${unit(menuArrowOffset)})`,
|
2022-05-23 10:58:30 +08:00
|
|
|
},
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// Integration with header element so menu items have the same height
|
2022-05-23 10:58:30 +08:00
|
|
|
{
|
|
|
|
[`${antCls}-layout-header`]: {
|
|
|
|
[componentCls]: {
|
|
|
|
lineHeight: 'inherit',
|
|
|
|
},
|
2022-04-20 15:31:04 +08:00
|
|
|
},
|
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
];
|
2022-04-20 15:31:04 +08:00
|
|
|
};
|
|
|
|
|
2023-11-13 09:38:05 +08:00
|
|
|
export const prepareComponentToken: GetDefaultToken<'Menu'> = (token) => {
|
|
|
|
const {
|
|
|
|
colorPrimary,
|
|
|
|
colorError,
|
|
|
|
colorTextDisabled,
|
|
|
|
colorErrorBg,
|
|
|
|
colorText,
|
|
|
|
colorTextDescription,
|
|
|
|
colorBgContainer,
|
|
|
|
colorFillAlter,
|
|
|
|
colorFillContent,
|
|
|
|
lineWidth,
|
|
|
|
lineWidthBold,
|
|
|
|
controlItemBgActive,
|
|
|
|
colorBgTextHover,
|
|
|
|
controlHeightLG,
|
|
|
|
lineHeight,
|
|
|
|
colorBgElevated,
|
|
|
|
marginXXS,
|
|
|
|
padding,
|
|
|
|
fontSize,
|
|
|
|
controlHeightSM,
|
|
|
|
fontSizeLG,
|
|
|
|
colorTextLightSolid,
|
|
|
|
colorErrorHover,
|
|
|
|
} = token;
|
|
|
|
|
2024-01-12 15:03:03 +08:00
|
|
|
const activeBarWidth = token.activeBarWidth ?? 0;
|
|
|
|
const activeBarBorderWidth = token.activeBarBorderWidth ?? lineWidth;
|
|
|
|
const itemMarginInline = token.itemMarginInline ?? token.marginXXS;
|
|
|
|
|
2023-11-13 09:38:05 +08:00
|
|
|
const colorTextDark = new TinyColor(colorTextLightSolid).setAlpha(0.65).toRgbString();
|
|
|
|
|
|
|
|
return {
|
|
|
|
dropdownWidth: 160,
|
|
|
|
zIndexPopup: token.zIndexPopupBase + 50,
|
|
|
|
radiusItem: token.borderRadiusLG,
|
|
|
|
itemBorderRadius: token.borderRadiusLG,
|
|
|
|
radiusSubMenuItem: token.borderRadiusSM,
|
|
|
|
subMenuItemBorderRadius: token.borderRadiusSM,
|
|
|
|
colorItemText: colorText,
|
|
|
|
itemColor: colorText,
|
|
|
|
colorItemTextHover: colorText,
|
|
|
|
itemHoverColor: colorText,
|
|
|
|
colorItemTextHoverHorizontal: colorPrimary,
|
|
|
|
horizontalItemHoverColor: colorPrimary,
|
|
|
|
colorGroupTitle: colorTextDescription,
|
|
|
|
groupTitleColor: colorTextDescription,
|
|
|
|
colorItemTextSelected: colorPrimary,
|
|
|
|
itemSelectedColor: colorPrimary,
|
|
|
|
colorItemTextSelectedHorizontal: colorPrimary,
|
|
|
|
horizontalItemSelectedColor: colorPrimary,
|
|
|
|
colorItemBg: colorBgContainer,
|
|
|
|
itemBg: colorBgContainer,
|
|
|
|
colorItemBgHover: colorBgTextHover,
|
|
|
|
itemHoverBg: colorBgTextHover,
|
|
|
|
colorItemBgActive: colorFillContent,
|
|
|
|
itemActiveBg: controlItemBgActive,
|
|
|
|
colorSubItemBg: colorFillAlter,
|
|
|
|
subMenuItemBg: colorFillAlter,
|
|
|
|
colorItemBgSelected: controlItemBgActive,
|
|
|
|
itemSelectedBg: controlItemBgActive,
|
|
|
|
colorItemBgSelectedHorizontal: 'transparent',
|
|
|
|
horizontalItemSelectedBg: 'transparent',
|
|
|
|
colorActiveBarWidth: 0,
|
2024-01-12 15:03:03 +08:00
|
|
|
activeBarWidth,
|
2023-11-13 09:38:05 +08:00
|
|
|
colorActiveBarHeight: lineWidthBold,
|
|
|
|
activeBarHeight: lineWidthBold,
|
|
|
|
colorActiveBarBorderSize: lineWidth,
|
2024-01-12 15:03:03 +08:00
|
|
|
activeBarBorderWidth,
|
2023-11-13 09:38:05 +08:00
|
|
|
|
|
|
|
// Disabled
|
|
|
|
colorItemTextDisabled: colorTextDisabled,
|
|
|
|
itemDisabledColor: colorTextDisabled,
|
|
|
|
|
|
|
|
// Danger
|
|
|
|
colorDangerItemText: colorError,
|
|
|
|
dangerItemColor: colorError,
|
|
|
|
colorDangerItemTextHover: colorError,
|
|
|
|
dangerItemHoverColor: colorError,
|
|
|
|
colorDangerItemTextSelected: colorError,
|
|
|
|
dangerItemSelectedColor: colorError,
|
|
|
|
colorDangerItemBgActive: colorErrorBg,
|
|
|
|
dangerItemActiveBg: colorErrorBg,
|
|
|
|
colorDangerItemBgSelected: colorErrorBg,
|
|
|
|
dangerItemSelectedBg: colorErrorBg,
|
|
|
|
|
2024-01-12 15:03:03 +08:00
|
|
|
itemMarginInline,
|
2023-11-13 09:38:05 +08:00
|
|
|
|
|
|
|
horizontalItemBorderRadius: 0,
|
|
|
|
horizontalItemHoverBg: 'transparent',
|
|
|
|
itemHeight: controlHeightLG,
|
|
|
|
groupTitleLineHeight: lineHeight,
|
|
|
|
collapsedWidth: controlHeightLG * 2,
|
|
|
|
popupBg: colorBgElevated,
|
|
|
|
itemMarginBlock: marginXXS,
|
|
|
|
itemPaddingInline: padding,
|
|
|
|
horizontalLineHeight: `${controlHeightLG * 1.15}px`,
|
|
|
|
iconSize: fontSize,
|
|
|
|
iconMarginInlineEnd: controlHeightSM - fontSize,
|
|
|
|
collapsedIconSize: fontSizeLG,
|
|
|
|
groupTitleFontSize: fontSize,
|
|
|
|
|
|
|
|
// Disabled
|
|
|
|
darkItemDisabledColor: new TinyColor(colorTextLightSolid).setAlpha(0.25).toRgbString(),
|
|
|
|
|
|
|
|
// Dark
|
|
|
|
darkItemColor: colorTextDark,
|
|
|
|
darkDangerItemColor: colorError,
|
|
|
|
darkItemBg: '#001529',
|
2023-11-14 02:59:19 +08:00
|
|
|
darkPopupBg: '#001529',
|
2023-11-13 09:38:05 +08:00
|
|
|
darkSubMenuItemBg: '#000c17',
|
|
|
|
darkItemSelectedColor: colorTextLightSolid,
|
|
|
|
darkItemSelectedBg: colorPrimary,
|
|
|
|
darkDangerItemSelectedBg: colorError,
|
|
|
|
darkItemHoverBg: 'transparent',
|
|
|
|
darkGroupTitleColor: colorTextDark,
|
|
|
|
darkItemHoverColor: colorTextLightSolid,
|
|
|
|
darkDangerItemHoverColor: colorErrorHover,
|
|
|
|
darkDangerItemSelectedColor: colorTextLightSolid,
|
|
|
|
darkDangerItemActiveBg: colorError,
|
|
|
|
|
2023-11-22 20:53:48 +08:00
|
|
|
// internal
|
2024-01-12 15:03:03 +08:00
|
|
|
itemWidth: activeBarWidth
|
|
|
|
? `calc(100% + ${activeBarBorderWidth}px)`
|
|
|
|
: `calc(100% - ${itemMarginInline * 2}px)`,
|
2023-11-13 09:38:05 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-04-20 15:31:04 +08:00
|
|
|
// ============================== Export ==============================
|
2024-06-22 21:59:12 +08:00
|
|
|
export default (prefixCls: string, rootCls: string = prefixCls, injectStyle = true) => {
|
2023-11-29 17:23:45 +08:00
|
|
|
const useStyle = genStyleHooks(
|
2022-05-23 10:58:30 +08:00
|
|
|
'Menu',
|
2023-07-17 10:13:22 +08:00
|
|
|
(token) => {
|
2023-03-27 10:08:22 +08:00
|
|
|
const {
|
|
|
|
colorBgElevated,
|
|
|
|
controlHeightLG,
|
|
|
|
fontSize,
|
2023-07-17 10:13:22 +08:00
|
|
|
darkItemColor,
|
|
|
|
darkDangerItemColor,
|
|
|
|
darkItemBg,
|
|
|
|
darkSubMenuItemBg,
|
|
|
|
darkItemSelectedColor,
|
|
|
|
darkItemSelectedBg,
|
|
|
|
darkDangerItemSelectedBg,
|
|
|
|
darkItemHoverBg,
|
|
|
|
darkGroupTitleColor,
|
|
|
|
darkItemHoverColor,
|
|
|
|
darkItemDisabledColor,
|
|
|
|
darkDangerItemHoverColor,
|
|
|
|
darkDangerItemSelectedColor,
|
|
|
|
darkDangerItemActiveBg,
|
2023-12-29 16:49:57 +08:00
|
|
|
popupBg,
|
|
|
|
darkPopupBg,
|
2023-03-27 10:08:22 +08:00
|
|
|
} = token;
|
2022-05-23 10:58:30 +08:00
|
|
|
|
2023-11-13 09:38:05 +08:00
|
|
|
const menuArrowSize = token.calc(fontSize).div(7).mul(5).equal();
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
// Menu Token
|
2023-11-13 09:38:05 +08:00
|
|
|
const menuToken = mergeToken<MenuToken & CssUtil>(token, {
|
2022-05-23 10:58:30 +08:00
|
|
|
menuArrowSize,
|
2023-11-13 09:38:05 +08:00
|
|
|
menuHorizontalHeight: token.calc(controlHeightLG).mul(1.15).equal(),
|
|
|
|
menuArrowOffset: token.calc(menuArrowSize).mul(0.25).equal(),
|
2022-11-25 16:00:01 +08:00
|
|
|
menuSubMenuBg: colorBgElevated,
|
2023-11-13 09:38:05 +08:00
|
|
|
calc: token.calc,
|
2023-12-29 16:49:57 +08:00
|
|
|
popupBg,
|
2022-05-23 10:58:30 +08:00
|
|
|
});
|
|
|
|
|
2023-07-17 10:13:22 +08:00
|
|
|
const menuDarkToken = mergeToken<MenuToken>(menuToken, {
|
|
|
|
itemColor: darkItemColor,
|
|
|
|
itemHoverColor: darkItemHoverColor,
|
|
|
|
groupTitleColor: darkGroupTitleColor,
|
|
|
|
itemSelectedColor: darkItemSelectedColor,
|
|
|
|
itemBg: darkItemBg,
|
2023-12-29 16:49:57 +08:00
|
|
|
popupBg: darkPopupBg,
|
2023-07-17 10:13:22 +08:00
|
|
|
subMenuItemBg: darkSubMenuItemBg,
|
|
|
|
itemActiveBg: 'transparent',
|
|
|
|
itemSelectedBg: darkItemSelectedBg,
|
|
|
|
activeBarHeight: 0,
|
|
|
|
activeBarBorderWidth: 0,
|
|
|
|
itemHoverBg: darkItemHoverBg,
|
2023-01-09 16:50:08 +08:00
|
|
|
|
2023-07-17 10:13:22 +08:00
|
|
|
// Disabled
|
|
|
|
itemDisabledColor: darkItemDisabledColor,
|
|
|
|
|
|
|
|
// Danger
|
|
|
|
dangerItemColor: darkDangerItemColor,
|
|
|
|
dangerItemHoverColor: darkDangerItemHoverColor,
|
|
|
|
dangerItemSelectedColor: darkDangerItemSelectedColor,
|
|
|
|
dangerItemActiveBg: darkDangerItemActiveBg,
|
|
|
|
dangerItemSelectedBg: darkDangerItemSelectedBg,
|
|
|
|
|
|
|
|
menuSubMenuBg: darkSubMenuItemBg,
|
|
|
|
|
|
|
|
// Horizontal
|
2024-02-18 09:58:39 +08:00
|
|
|
horizontalItemSelectedColor: darkItemSelectedColor,
|
|
|
|
horizontalItemSelectedBg: darkItemSelectedBg,
|
2023-07-17 10:13:22 +08:00
|
|
|
});
|
2022-09-19 22:17:26 +08:00
|
|
|
|
2022-05-23 10:58:30 +08:00
|
|
|
return [
|
|
|
|
// Basic
|
|
|
|
getBaseStyle(menuToken),
|
|
|
|
|
|
|
|
// Horizontal
|
2022-07-28 20:33:10 +08:00
|
|
|
getHorizontalStyle(menuToken), // Hard code for some light style
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
// Vertical
|
2022-07-28 20:33:10 +08:00
|
|
|
getVerticalStyle(menuToken), // Hard code for some light style
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
// Theme
|
2022-09-19 22:17:26 +08:00
|
|
|
getThemeStyle(menuToken, 'light'),
|
|
|
|
getThemeStyle(menuDarkToken, 'dark'),
|
2022-05-23 10:58:30 +08:00
|
|
|
|
|
|
|
// RTL
|
|
|
|
getRTLStyle(menuToken),
|
2022-07-19 22:53:38 +08:00
|
|
|
|
|
|
|
// Motion
|
|
|
|
genCollapseMotion(menuToken),
|
2022-07-28 20:33:10 +08:00
|
|
|
|
|
|
|
initSlideMotion(menuToken, 'slide-up'),
|
|
|
|
initSlideMotion(menuToken, 'slide-down'),
|
|
|
|
initZoomMotion(menuToken, 'zoom-big'),
|
2022-05-23 10:58:30 +08:00
|
|
|
];
|
|
|
|
},
|
2023-11-13 09:38:05 +08:00
|
|
|
prepareComponentToken,
|
2023-06-06 16:11:18 +08:00
|
|
|
{
|
|
|
|
deprecatedTokens: [
|
|
|
|
['colorGroupTitle', 'groupTitleColor'],
|
|
|
|
['radiusItem', 'itemBorderRadius'],
|
|
|
|
['radiusSubMenuItem', 'subMenuItemBorderRadius'],
|
|
|
|
['colorItemText', 'itemColor'],
|
|
|
|
['colorItemTextHover', 'itemHoverColor'],
|
|
|
|
['colorItemTextHoverHorizontal', 'horizontalItemHoverColor'],
|
|
|
|
['colorItemTextSelected', 'itemSelectedColor'],
|
|
|
|
['colorItemTextSelectedHorizontal', 'horizontalItemSelectedColor'],
|
|
|
|
['colorItemTextDisabled', 'itemDisabledColor'],
|
|
|
|
['colorDangerItemText', 'dangerItemColor'],
|
|
|
|
['colorDangerItemTextHover', 'dangerItemHoverColor'],
|
|
|
|
['colorDangerItemTextSelected', 'dangerItemSelectedColor'],
|
|
|
|
['colorDangerItemBgActive', 'dangerItemActiveBg'],
|
|
|
|
['colorDangerItemBgSelected', 'dangerItemSelectedBg'],
|
|
|
|
['colorItemBg', 'itemBg'],
|
|
|
|
['colorItemBgHover', 'itemHoverBg'],
|
|
|
|
['colorSubItemBg', 'subMenuItemBg'],
|
|
|
|
['colorItemBgActive', 'itemActiveBg'],
|
|
|
|
['colorItemBgSelectedHorizontal', 'horizontalItemSelectedBg'],
|
|
|
|
['colorActiveBarWidth', 'activeBarWidth'],
|
|
|
|
['colorActiveBarHeight', 'activeBarHeight'],
|
|
|
|
['colorActiveBarBorderSize', 'activeBarBorderWidth'],
|
2023-07-10 10:36:35 +08:00
|
|
|
['colorItemBgSelected', 'itemSelectedBg'],
|
2023-06-06 16:11:18 +08:00
|
|
|
],
|
2023-11-29 17:23:45 +08:00
|
|
|
// Dropdown will handle menu style self. We do not need to handle this.
|
|
|
|
injectStyle,
|
|
|
|
unitless: {
|
|
|
|
groupTitleLineHeight: true,
|
|
|
|
},
|
2023-06-06 16:11:18 +08:00
|
|
|
},
|
2022-05-23 10:58:30 +08:00
|
|
|
);
|
2022-04-20 15:31:04 +08:00
|
|
|
|
2023-11-29 17:23:45 +08:00
|
|
|
return useStyle(prefixCls, rootCls);
|
2022-04-25 10:54:00 +08:00
|
|
|
};
|