2024-04-08 14:04:08 +08:00
|
|
|
|
import { unit } from '@ant-design/cssinjs';
|
|
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-05-31 10:10:35 +08:00
|
|
|
|
import { TinyColor } from '@ctrl/tinycolor';
|
2023-09-13 17:53:54 +08:00
|
|
|
|
|
2023-02-19 16:24:20 +08:00
|
|
|
|
import { clearFix, resetComponent } from '../../style';
|
2023-11-17 13:46:41 +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-31 10:10:35 +08:00
|
|
|
|
import genBorderedStyle from './bordered';
|
|
|
|
|
import genEllipsisStyle from './ellipsis';
|
|
|
|
|
import genEmptyStyle from './empty';
|
|
|
|
|
import genExpandStyle from './expand';
|
|
|
|
|
import genFilterStyle from './filter';
|
|
|
|
|
import genFixedStyle from './fixed';
|
2022-06-02 18:47:14 +08:00
|
|
|
|
import genPaginationStyle from './pagination';
|
2022-05-31 10:10:35 +08:00
|
|
|
|
import genRadiusStyle from './radius';
|
|
|
|
|
import genRtlStyle from './rtl';
|
|
|
|
|
import genSelectionStyle from './selection';
|
|
|
|
|
import genSizeStyle from './size';
|
|
|
|
|
import genSorterStyle from './sorter';
|
|
|
|
|
import genStickyStyle from './sticky';
|
|
|
|
|
import genSummaryStyle from './summary';
|
2023-08-28 17:36:23 +08:00
|
|
|
|
import genVirtualStyle from './virtual';
|
2022-05-31 10:10:35 +08:00
|
|
|
|
|
2023-08-09 10:52:39 +08:00
|
|
|
|
export interface ComponentToken {
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表头背景
|
|
|
|
|
* @descEN Background of table header
|
|
|
|
|
*/
|
|
|
|
|
headerBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表头文字颜色
|
|
|
|
|
* @descEN Color of table header text
|
|
|
|
|
*/
|
|
|
|
|
headerColor: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表头排序激活态背景色
|
|
|
|
|
* @descEN Background color of table header when sorted
|
|
|
|
|
*/
|
|
|
|
|
headerSortActiveBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表头排序激活态悬浮背景色
|
|
|
|
|
* @descEN Background color of table header when sorted and hovered
|
|
|
|
|
*/
|
|
|
|
|
headerSortHoverBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格排序列背景色
|
|
|
|
|
* @descEN Background color of table sorted column
|
|
|
|
|
*/
|
|
|
|
|
bodySortBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格行悬浮背景色
|
|
|
|
|
* @descEN Background color of table hovered row
|
|
|
|
|
*/
|
|
|
|
|
rowHoverBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格行选中背景色
|
|
|
|
|
* @descEN Background color of table selected row
|
|
|
|
|
*/
|
|
|
|
|
rowSelectedBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格行选中悬浮背景色
|
|
|
|
|
* @descEN Background color of table selected row when hovered
|
|
|
|
|
*/
|
|
|
|
|
rowSelectedHoverBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格行展开背景色
|
|
|
|
|
* @descEN Background color of table expanded row
|
|
|
|
|
*/
|
|
|
|
|
rowExpandedBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格纵向内间距
|
|
|
|
|
* @descEN Vertical padding of table cell
|
|
|
|
|
*/
|
|
|
|
|
cellPaddingBlock: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格横向内间距(默认大尺寸)
|
|
|
|
|
* @descEN Horizontal padding of table cell (large size by default)
|
|
|
|
|
*/
|
|
|
|
|
cellPaddingInline: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格纵向内间距(中等尺寸)
|
|
|
|
|
* @descEN Vertical padding of table cell (middle size)
|
|
|
|
|
*/
|
|
|
|
|
cellPaddingBlockMD: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格横向内间距(中等尺寸)
|
|
|
|
|
* @descEN Horizontal padding of table cell (middle size)
|
|
|
|
|
*/
|
|
|
|
|
cellPaddingInlineMD: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格纵向内间距(小尺寸)
|
|
|
|
|
* @descEN Vertical padding of table cell (small size)
|
|
|
|
|
*/
|
|
|
|
|
cellPaddingBlockSM: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格横向内间距(小尺寸)
|
|
|
|
|
* @descEN Horizontal padding of table cell (small size)
|
|
|
|
|
*/
|
|
|
|
|
cellPaddingInlineSM: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格边框/分割线颜色
|
|
|
|
|
* @descEN Border color of table
|
|
|
|
|
*/
|
|
|
|
|
borderColor: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表头圆角
|
|
|
|
|
* @descEN Border radius of table header
|
|
|
|
|
*/
|
|
|
|
|
headerBorderRadius: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格底部背景色
|
|
|
|
|
* @descEN Background of footer
|
|
|
|
|
*/
|
|
|
|
|
footerBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表格底部文字颜色
|
|
|
|
|
* @descEN Color of footer text
|
|
|
|
|
*/
|
|
|
|
|
footerColor: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格文字大小(默认大尺寸)
|
|
|
|
|
* @descEN Font size of table cell (large size by default)
|
|
|
|
|
*/
|
|
|
|
|
cellFontSize: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格文字大小(中等尺寸)
|
|
|
|
|
* @descEN Font size of table cell (middle size)
|
|
|
|
|
*/
|
|
|
|
|
cellFontSizeMD: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 单元格文字大小(小尺寸)
|
|
|
|
|
* @descEN Font size of table cell (small size)
|
|
|
|
|
*/
|
|
|
|
|
cellFontSizeSM: number;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表头分割线颜色
|
|
|
|
|
* @descEN Split border color of table header
|
|
|
|
|
*/
|
|
|
|
|
headerSplitColor: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 固定表头排序激活态背景色
|
|
|
|
|
* @descEN Background color of fixed table header when sorted
|
|
|
|
|
*/
|
|
|
|
|
fixedHeaderSortActiveBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 表头过滤按钮悬浮背景色
|
|
|
|
|
* @descEN Background color of table header filter button when hovered
|
|
|
|
|
*/
|
|
|
|
|
headerFilterHoverBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 过滤下拉菜单选项背景
|
|
|
|
|
* @descEN Background of filter dropdown menu item
|
|
|
|
|
*/
|
|
|
|
|
filterDropdownMenuBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 过滤下拉菜单颜色
|
|
|
|
|
* @descEN Color of filter dropdown
|
|
|
|
|
*/
|
|
|
|
|
filterDropdownBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 展开按钮背景色
|
|
|
|
|
* @descEN Background of expand button
|
|
|
|
|
*/
|
|
|
|
|
expandIconBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc 选择列宽度
|
|
|
|
|
* @descEN Width of selection column
|
|
|
|
|
*/
|
2024-07-14 00:36:43 +08:00
|
|
|
|
selectionColumnWidth: number | string;
|
2023-08-09 10:52:39 +08:00
|
|
|
|
/**
|
|
|
|
|
* @desc Sticky 模式下滚动条背景色
|
|
|
|
|
* @descEN Background of sticky scrollbar
|
|
|
|
|
*/
|
|
|
|
|
stickyScrollBarBg: string;
|
|
|
|
|
/**
|
|
|
|
|
* @desc Sticky 模式下滚动条圆角
|
|
|
|
|
* @descEN Border radius of sticky scrollbar
|
|
|
|
|
*/
|
|
|
|
|
stickyScrollBarBorderRadius: number;
|
2023-11-17 13:46:41 +08:00
|
|
|
|
|
|
|
|
|
/** @internal */
|
|
|
|
|
expandIconMarginTop: number;
|
|
|
|
|
/** @internal */
|
|
|
|
|
expandIconHalfInner: number;
|
|
|
|
|
/** @internal */
|
|
|
|
|
expandIconSize: number;
|
|
|
|
|
/** @internal */
|
|
|
|
|
expandIconScale: number;
|
|
|
|
|
/** @internal */
|
|
|
|
|
headerIconColor: string;
|
|
|
|
|
/** @internal */
|
|
|
|
|
headerIconHoverColor: string;
|
2023-08-09 10:52:39 +08:00
|
|
|
|
}
|
2022-06-17 18:47:47 +08:00
|
|
|
|
|
2022-05-31 10:10:35 +08:00
|
|
|
|
export interface TableToken extends FullToken<'Table'> {
|
|
|
|
|
tableFontSize: number;
|
|
|
|
|
tableBg: string;
|
|
|
|
|
tableRadius: number;
|
|
|
|
|
tablePaddingHorizontal: number;
|
|
|
|
|
tablePaddingVertical: number;
|
|
|
|
|
tablePaddingHorizontalMiddle: number;
|
|
|
|
|
tablePaddingVerticalMiddle: number;
|
|
|
|
|
tablePaddingHorizontalSmall: number;
|
|
|
|
|
tablePaddingVerticalSmall: number;
|
|
|
|
|
tableBorderColor: string;
|
|
|
|
|
tableHeaderTextColor: string;
|
|
|
|
|
tableHeaderBg: string;
|
|
|
|
|
tableFooterTextColor: string;
|
|
|
|
|
tableFooterBg: string;
|
|
|
|
|
tableHeaderCellSplitColor: string;
|
|
|
|
|
tableHeaderSortBg: string;
|
|
|
|
|
tableHeaderSortHoverBg: string;
|
|
|
|
|
tableBodySortBg: string;
|
|
|
|
|
tableFixedHeaderSortActiveBg: string;
|
|
|
|
|
tableHeaderFilterActiveBg: string;
|
|
|
|
|
tableFilterDropdownBg: string;
|
2024-07-14 00:36:43 +08:00
|
|
|
|
tableFilterDropdownHeight: number | string;
|
2022-05-31 10:10:35 +08:00
|
|
|
|
tableRowHoverBg: string;
|
|
|
|
|
tableSelectedRowBg: string;
|
|
|
|
|
tableSelectedRowHoverBg: string;
|
2022-06-02 18:47:14 +08:00
|
|
|
|
|
|
|
|
|
tableFontSizeMiddle: number;
|
|
|
|
|
tableFontSizeSmall: number;
|
2024-07-14 00:36:43 +08:00
|
|
|
|
tableSelectionColumnWidth: number | string;
|
2022-05-31 10:10:35 +08:00
|
|
|
|
tableExpandIconBg: string;
|
2023-11-17 13:46:41 +08:00
|
|
|
|
tableExpandColumnWidth: number | string;
|
2022-05-31 10:10:35 +08:00
|
|
|
|
tableExpandedRowBg: string;
|
2022-06-02 18:47:14 +08:00
|
|
|
|
tableFilterDropdownWidth: number;
|
|
|
|
|
tableFilterDropdownSearchWidth: number;
|
|
|
|
|
|
|
|
|
|
// Z-Index
|
|
|
|
|
zIndexTableFixed: number;
|
2023-11-17 13:46:41 +08:00
|
|
|
|
zIndexTableSticky: number | string;
|
2022-06-02 18:47:14 +08:00
|
|
|
|
|
|
|
|
|
// Virtual Scroll Bar
|
|
|
|
|
tableScrollThumbSize: number;
|
|
|
|
|
tableScrollThumbBg: string;
|
|
|
|
|
tableScrollThumbBgHover: string;
|
|
|
|
|
tableScrollBg: string;
|
2022-05-31 10:10:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
|
const genTableStyle: GenerateStyle<TableToken, CSSObject> = (token) => {
|
2022-06-02 18:47:14 +08:00
|
|
|
|
const {
|
|
|
|
|
componentCls,
|
|
|
|
|
fontWeightStrong,
|
|
|
|
|
tablePaddingVertical,
|
|
|
|
|
tablePaddingHorizontal,
|
2023-11-17 13:46:41 +08:00
|
|
|
|
tableExpandColumnWidth,
|
2022-11-01 15:06:38 +08:00
|
|
|
|
lineWidth,
|
|
|
|
|
lineType,
|
2022-06-02 18:47:14 +08:00
|
|
|
|
tableBorderColor,
|
|
|
|
|
tableFontSize,
|
|
|
|
|
tableBg,
|
|
|
|
|
tableRadius,
|
|
|
|
|
tableHeaderTextColor,
|
2022-12-22 16:03:55 +08:00
|
|
|
|
motionDurationMid,
|
2022-06-02 18:47:14 +08:00
|
|
|
|
tableHeaderBg,
|
|
|
|
|
tableHeaderCellSplitColor,
|
|
|
|
|
tableFooterTextColor,
|
|
|
|
|
tableFooterBg,
|
2023-11-17 13:46:41 +08:00
|
|
|
|
calc,
|
2022-06-02 18:47:14 +08:00
|
|
|
|
} = token;
|
2023-11-17 13:46:41 +08:00
|
|
|
|
const tableBorder = `${unit(lineWidth)} ${lineType} ${tableBorderColor}`;
|
2022-05-31 10:10:35 +08:00
|
|
|
|
return {
|
|
|
|
|
[`${componentCls}-wrapper`]: {
|
|
|
|
|
clear: 'both',
|
|
|
|
|
maxWidth: '100%',
|
|
|
|
|
...clearFix(),
|
|
|
|
|
|
|
|
|
|
[componentCls]: {
|
|
|
|
|
...resetComponent(token),
|
2022-06-02 18:47:14 +08:00
|
|
|
|
fontSize: tableFontSize,
|
|
|
|
|
background: tableBg,
|
2023-11-17 13:46:41 +08:00
|
|
|
|
borderRadius: `${unit(tableRadius)} ${unit(tableRadius)} 0 0`,
|
2024-02-20 11:10:22 +08:00
|
|
|
|
// https://github.com/ant-design/ant-design/issues/47486
|
|
|
|
|
scrollbarColor: `${token.tableScrollThumbBg} ${token.tableScrollBg}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
},
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/17611
|
|
|
|
|
table: {
|
|
|
|
|
width: '100%',
|
|
|
|
|
textAlign: 'start',
|
2023-11-17 13:46:41 +08:00
|
|
|
|
borderRadius: `${unit(tableRadius)} ${unit(tableRadius)} 0 0`,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
borderCollapse: 'separate',
|
|
|
|
|
borderSpacing: 0,
|
|
|
|
|
},
|
|
|
|
|
|
2023-09-25 10:49:10 +08:00
|
|
|
|
// ============================= Cell ==============================
|
2022-05-31 10:10:35 +08:00
|
|
|
|
[`
|
2023-08-28 17:36:23 +08:00
|
|
|
|
${componentCls}-cell,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
${componentCls}-thead > tr > th,
|
2023-03-02 20:51:40 +08:00
|
|
|
|
${componentCls}-tbody > tr > th,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
${componentCls}-tbody > tr > td,
|
|
|
|
|
tfoot > tr > th,
|
|
|
|
|
tfoot > tr > td
|
|
|
|
|
`]: {
|
|
|
|
|
position: 'relative',
|
2023-11-17 13:46:41 +08:00
|
|
|
|
padding: `${unit(tablePaddingVertical)} ${unit(tablePaddingHorizontal)}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
overflowWrap: 'break-word',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ============================ Title =============================
|
|
|
|
|
[`${componentCls}-title`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
|
padding: `${unit(tablePaddingVertical)} ${unit(tablePaddingHorizontal)}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ============================ Header ============================
|
|
|
|
|
[`${componentCls}-thead`]: {
|
2022-12-15 20:45:58 +08:00
|
|
|
|
[`
|
|
|
|
|
> tr > th,
|
|
|
|
|
> tr > td
|
|
|
|
|
`]: {
|
2022-05-31 10:10:35 +08:00
|
|
|
|
position: 'relative',
|
2022-06-02 18:47:14 +08:00
|
|
|
|
color: tableHeaderTextColor,
|
|
|
|
|
fontWeight: fontWeightStrong,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
textAlign: 'start',
|
2022-06-02 18:47:14 +08:00
|
|
|
|
background: tableHeaderBg,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
borderBottom: tableBorder,
|
2022-12-22 16:03:55 +08:00
|
|
|
|
transition: `background ${motionDurationMid} ease`,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
|
|
|
|
|
"&[colspan]:not([colspan='1'])": {
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
[`&:not(:last-child):not(${componentCls}-selection-column):not(${componentCls}-row-expand-icon-cell):not([colspan])::before`]:
|
|
|
|
|
{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
top: '50%',
|
|
|
|
|
insetInlineEnd: 0,
|
|
|
|
|
width: 1,
|
|
|
|
|
height: '1.6em',
|
2022-06-02 18:47:14 +08:00
|
|
|
|
backgroundColor: tableHeaderCellSplitColor,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
transform: 'translateY(-50%)',
|
2022-12-22 16:03:55 +08:00
|
|
|
|
transition: `background-color ${motionDurationMid}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
content: '""',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'> tr:not(:last-child) > th[colspan]': {
|
|
|
|
|
borderBottom: 0,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ============================ Body ============================
|
|
|
|
|
[`${componentCls}-tbody`]: {
|
|
|
|
|
'> tr': {
|
2024-06-22 21:59:12 +08:00
|
|
|
|
'> th, > td': {
|
2022-12-22 16:03:55 +08:00
|
|
|
|
transition: `background ${motionDurationMid}, border-color ${motionDurationMid}`,
|
2023-01-31 14:24:12 +08:00
|
|
|
|
borderBottom: tableBorder,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
|
|
|
|
|
// ========================= Nest Table ===========================
|
|
|
|
|
[`
|
|
|
|
|
> ${componentCls}-wrapper:only-child,
|
|
|
|
|
> ${componentCls}-expanded-row-fixed > ${componentCls}-wrapper:only-child
|
|
|
|
|
`]: {
|
|
|
|
|
[componentCls]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
|
marginBlock: unit(calc(tablePaddingVertical).mul(-1).equal()),
|
|
|
|
|
marginInline: `${unit(
|
|
|
|
|
calc(tableExpandColumnWidth).sub(tablePaddingHorizontal).equal(),
|
|
|
|
|
)}
|
|
|
|
|
${unit(calc(tablePaddingHorizontal).mul(-1).equal())}`,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
[`${componentCls}-tbody > tr:last-child > td`]: {
|
|
|
|
|
borderBottom: 0,
|
|
|
|
|
'&:first-child, &:last-child': {
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
2023-03-02 20:51:40 +08:00
|
|
|
|
'> th': {
|
|
|
|
|
position: 'relative',
|
|
|
|
|
color: tableHeaderTextColor,
|
|
|
|
|
fontWeight: fontWeightStrong,
|
|
|
|
|
textAlign: 'start',
|
|
|
|
|
background: tableHeaderBg,
|
|
|
|
|
borderBottom: tableBorder,
|
|
|
|
|
transition: `background ${motionDurationMid} ease`,
|
|
|
|
|
},
|
2022-05-31 10:10:35 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ============================ Footer ============================
|
|
|
|
|
[`${componentCls}-footer`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
|
padding: `${unit(tablePaddingVertical)} ${unit(tablePaddingHorizontal)}`,
|
2022-06-02 18:47:14 +08:00
|
|
|
|
color: tableFooterTextColor,
|
|
|
|
|
background: tableFooterBg,
|
2022-05-31 10:10:35 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-17 13:46:41 +08:00
|
|
|
|
export const prepareComponentToken: GetDefaultToken<'Table'> = (token) => {
|
|
|
|
|
const {
|
|
|
|
|
colorFillAlter,
|
|
|
|
|
colorBgContainer,
|
|
|
|
|
colorTextHeading,
|
|
|
|
|
colorFillSecondary,
|
|
|
|
|
colorFillContent,
|
|
|
|
|
controlItemBgActive,
|
|
|
|
|
controlItemBgActiveHover,
|
|
|
|
|
padding,
|
|
|
|
|
paddingSM,
|
|
|
|
|
paddingXS,
|
|
|
|
|
colorBorderSecondary,
|
|
|
|
|
borderRadiusLG,
|
|
|
|
|
controlHeight,
|
|
|
|
|
colorTextPlaceholder,
|
|
|
|
|
fontSize,
|
|
|
|
|
fontSizeSM,
|
|
|
|
|
lineHeight,
|
|
|
|
|
lineWidth,
|
|
|
|
|
colorIcon,
|
|
|
|
|
colorIconHover,
|
|
|
|
|
opacityLoading,
|
|
|
|
|
controlInteractiveSize,
|
|
|
|
|
} = token;
|
|
|
|
|
|
|
|
|
|
const colorFillSecondarySolid = new TinyColor(colorFillSecondary)
|
|
|
|
|
.onBackground(colorBgContainer)
|
|
|
|
|
.toHexShortString();
|
|
|
|
|
const colorFillContentSolid = new TinyColor(colorFillContent)
|
|
|
|
|
.onBackground(colorBgContainer)
|
|
|
|
|
.toHexShortString();
|
|
|
|
|
const colorFillAlterSolid = new TinyColor(colorFillAlter)
|
|
|
|
|
.onBackground(colorBgContainer)
|
|
|
|
|
.toHexShortString();
|
|
|
|
|
|
|
|
|
|
const baseColorAction = new TinyColor(colorIcon);
|
|
|
|
|
const baseColorActionHover = new TinyColor(colorIconHover);
|
|
|
|
|
|
|
|
|
|
const expandIconHalfInner = controlInteractiveSize / 2 - lineWidth;
|
|
|
|
|
const expandIconSize = expandIconHalfInner * 2 + lineWidth * 3;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
headerBg: colorFillAlterSolid,
|
|
|
|
|
headerColor: colorTextHeading,
|
|
|
|
|
headerSortActiveBg: colorFillSecondarySolid,
|
|
|
|
|
headerSortHoverBg: colorFillContentSolid,
|
|
|
|
|
bodySortBg: colorFillAlterSolid,
|
|
|
|
|
rowHoverBg: colorFillAlterSolid,
|
|
|
|
|
rowSelectedBg: controlItemBgActive,
|
|
|
|
|
rowSelectedHoverBg: controlItemBgActiveHover,
|
|
|
|
|
rowExpandedBg: colorFillAlter,
|
|
|
|
|
cellPaddingBlock: padding,
|
|
|
|
|
cellPaddingInline: padding,
|
|
|
|
|
cellPaddingBlockMD: paddingSM,
|
|
|
|
|
cellPaddingInlineMD: paddingXS,
|
|
|
|
|
cellPaddingBlockSM: paddingXS,
|
|
|
|
|
cellPaddingInlineSM: paddingXS,
|
|
|
|
|
borderColor: colorBorderSecondary,
|
|
|
|
|
headerBorderRadius: borderRadiusLG,
|
|
|
|
|
footerBg: colorFillAlterSolid,
|
|
|
|
|
footerColor: colorTextHeading,
|
|
|
|
|
cellFontSize: fontSize,
|
|
|
|
|
cellFontSizeMD: fontSize,
|
|
|
|
|
cellFontSizeSM: fontSize,
|
|
|
|
|
headerSplitColor: colorBorderSecondary,
|
|
|
|
|
fixedHeaderSortActiveBg: colorFillSecondarySolid,
|
|
|
|
|
headerFilterHoverBg: colorFillContent,
|
|
|
|
|
filterDropdownMenuBg: colorBgContainer,
|
|
|
|
|
filterDropdownBg: colorBgContainer,
|
|
|
|
|
expandIconBg: colorBgContainer,
|
|
|
|
|
selectionColumnWidth: controlHeight,
|
|
|
|
|
stickyScrollBarBg: colorTextPlaceholder,
|
|
|
|
|
stickyScrollBarBorderRadius: 100,
|
|
|
|
|
expandIconMarginTop:
|
|
|
|
|
(fontSize * lineHeight - lineWidth * 3) / 2 -
|
|
|
|
|
Math.ceil((fontSizeSM * 1.4 - lineWidth * 3) / 2),
|
|
|
|
|
headerIconColor: baseColorAction
|
|
|
|
|
.clone()
|
|
|
|
|
.setAlpha(baseColorAction.getAlpha() * opacityLoading)
|
|
|
|
|
.toRgbString(),
|
|
|
|
|
headerIconHoverColor: baseColorActionHover
|
|
|
|
|
.clone()
|
|
|
|
|
.setAlpha(baseColorActionHover.getAlpha() * opacityLoading)
|
|
|
|
|
.toRgbString(),
|
|
|
|
|
expandIconHalfInner,
|
|
|
|
|
expandIconSize,
|
|
|
|
|
expandIconScale: controlInteractiveSize / expandIconSize,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-31 10:10:35 +08:00
|
|
|
|
// ============================== Export ==============================
|
2023-11-29 17:23:45 +08:00
|
|
|
|
export default genStyleHooks(
|
2023-08-09 10:52:39 +08:00
|
|
|
|
'Table',
|
|
|
|
|
(token) => {
|
|
|
|
|
const {
|
|
|
|
|
colorTextHeading,
|
|
|
|
|
colorSplit,
|
|
|
|
|
colorBgContainer,
|
|
|
|
|
controlInteractiveSize: checkboxSize,
|
|
|
|
|
headerBg,
|
|
|
|
|
headerColor,
|
|
|
|
|
headerSortActiveBg,
|
|
|
|
|
headerSortHoverBg,
|
|
|
|
|
bodySortBg,
|
|
|
|
|
rowHoverBg,
|
|
|
|
|
rowSelectedBg,
|
|
|
|
|
rowSelectedHoverBg,
|
|
|
|
|
rowExpandedBg,
|
|
|
|
|
cellPaddingBlock,
|
|
|
|
|
cellPaddingInline,
|
|
|
|
|
cellPaddingBlockMD,
|
|
|
|
|
cellPaddingInlineMD,
|
|
|
|
|
cellPaddingBlockSM,
|
|
|
|
|
cellPaddingInlineSM,
|
|
|
|
|
borderColor,
|
|
|
|
|
footerBg,
|
|
|
|
|
footerColor,
|
|
|
|
|
headerBorderRadius,
|
|
|
|
|
cellFontSize,
|
|
|
|
|
cellFontSizeMD,
|
|
|
|
|
cellFontSizeSM,
|
|
|
|
|
headerSplitColor,
|
|
|
|
|
fixedHeaderSortActiveBg,
|
|
|
|
|
headerFilterHoverBg,
|
|
|
|
|
filterDropdownBg,
|
|
|
|
|
expandIconBg,
|
|
|
|
|
selectionColumnWidth,
|
|
|
|
|
stickyScrollBarBg,
|
2023-11-17 13:46:41 +08:00
|
|
|
|
calc,
|
2023-08-09 10:52:39 +08:00
|
|
|
|
} = token;
|
2022-06-02 18:47:14 +08:00
|
|
|
|
|
2023-08-09 10:52:39 +08:00
|
|
|
|
const zIndexTableFixed: number = 2;
|
2022-06-02 18:47:14 +08:00
|
|
|
|
|
2023-08-09 10:52:39 +08:00
|
|
|
|
const tableToken = mergeToken<TableToken>(token, {
|
|
|
|
|
tableFontSize: cellFontSize,
|
|
|
|
|
tableBg: colorBgContainer,
|
|
|
|
|
tableRadius: headerBorderRadius,
|
2022-12-28 18:10:11 +08:00
|
|
|
|
|
2023-08-09 10:52:39 +08:00
|
|
|
|
tablePaddingVertical: cellPaddingBlock,
|
|
|
|
|
tablePaddingHorizontal: cellPaddingInline,
|
|
|
|
|
tablePaddingVerticalMiddle: cellPaddingBlockMD,
|
|
|
|
|
tablePaddingHorizontalMiddle: cellPaddingInlineMD,
|
|
|
|
|
tablePaddingVerticalSmall: cellPaddingBlockSM,
|
|
|
|
|
tablePaddingHorizontalSmall: cellPaddingInlineSM,
|
|
|
|
|
tableBorderColor: borderColor,
|
|
|
|
|
tableHeaderTextColor: headerColor,
|
|
|
|
|
tableHeaderBg: headerBg,
|
|
|
|
|
tableFooterTextColor: footerColor,
|
|
|
|
|
tableFooterBg: footerBg,
|
|
|
|
|
tableHeaderCellSplitColor: headerSplitColor,
|
|
|
|
|
tableHeaderSortBg: headerSortActiveBg,
|
|
|
|
|
tableHeaderSortHoverBg: headerSortHoverBg,
|
|
|
|
|
tableBodySortBg: bodySortBg,
|
|
|
|
|
tableFixedHeaderSortActiveBg: fixedHeaderSortActiveBg,
|
|
|
|
|
tableHeaderFilterActiveBg: headerFilterHoverBg,
|
|
|
|
|
tableFilterDropdownBg: filterDropdownBg,
|
|
|
|
|
tableRowHoverBg: rowHoverBg,
|
|
|
|
|
tableSelectedRowBg: rowSelectedBg,
|
|
|
|
|
tableSelectedRowHoverBg: rowSelectedHoverBg,
|
|
|
|
|
zIndexTableFixed,
|
|
|
|
|
zIndexTableSticky: zIndexTableFixed + 1,
|
|
|
|
|
tableFontSizeMiddle: cellFontSizeMD,
|
|
|
|
|
tableFontSizeSmall: cellFontSizeSM,
|
|
|
|
|
tableSelectionColumnWidth: selectionColumnWidth,
|
|
|
|
|
tableExpandIconBg: expandIconBg,
|
2023-11-17 13:46:41 +08:00
|
|
|
|
tableExpandColumnWidth: calc(checkboxSize).add(calc(token.padding).mul(2)).equal(),
|
2023-08-09 10:52:39 +08:00
|
|
|
|
tableExpandedRowBg: rowExpandedBg,
|
2022-09-16 14:58:05 +08:00
|
|
|
|
|
2023-08-09 10:52:39 +08:00
|
|
|
|
// Dropdown
|
|
|
|
|
tableFilterDropdownWidth: 120,
|
|
|
|
|
tableFilterDropdownHeight: 264,
|
|
|
|
|
tableFilterDropdownSearchWidth: 140,
|
2022-06-02 18:47:14 +08:00
|
|
|
|
|
2023-08-09 10:52:39 +08:00
|
|
|
|
// Virtual Scroll Bar
|
|
|
|
|
tableScrollThumbSize: 8, // Mac scroll bar size
|
|
|
|
|
tableScrollThumbBg: stickyScrollBarBg,
|
|
|
|
|
tableScrollThumbBgHover: colorTextHeading,
|
|
|
|
|
tableScrollBg: colorSplit,
|
|
|
|
|
});
|
2022-06-02 18:47:14 +08:00
|
|
|
|
|
2023-08-09 10:52:39 +08:00
|
|
|
|
return [
|
|
|
|
|
genTableStyle(tableToken),
|
|
|
|
|
genPaginationStyle(tableToken),
|
|
|
|
|
genSummaryStyle(tableToken),
|
|
|
|
|
genSorterStyle(tableToken),
|
|
|
|
|
genFilterStyle(tableToken),
|
|
|
|
|
genBorderedStyle(tableToken),
|
|
|
|
|
genRadiusStyle(tableToken),
|
|
|
|
|
genExpandStyle(tableToken),
|
|
|
|
|
genSummaryStyle(tableToken),
|
|
|
|
|
genEmptyStyle(tableToken),
|
|
|
|
|
genSelectionStyle(tableToken),
|
|
|
|
|
genFixedStyle(tableToken),
|
|
|
|
|
genStickyStyle(tableToken),
|
|
|
|
|
genEllipsisStyle(tableToken),
|
|
|
|
|
genSizeStyle(tableToken),
|
|
|
|
|
genRtlStyle(tableToken),
|
2023-08-28 17:36:23 +08:00
|
|
|
|
genVirtualStyle(tableToken),
|
2023-08-09 10:52:39 +08:00
|
|
|
|
];
|
|
|
|
|
},
|
2023-11-17 13:46:41 +08:00
|
|
|
|
prepareComponentToken,
|
2023-11-29 17:23:45 +08:00
|
|
|
|
{
|
|
|
|
|
unitless: {
|
|
|
|
|
expandIconScale: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-08-09 10:52:39 +08:00
|
|
|
|
);
|