2024-04-08 14:04:08 +08:00
|
|
|
import { unit } from '@ant-design/cssinjs';
|
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2023-09-13 17:53:54 +08:00
|
|
|
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { GenerateStyle } from '../../theme/internal';
|
2022-05-31 10:10:35 +08:00
|
|
|
import type { TableToken } from './index';
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const genSelectionStyle: GenerateStyle<TableToken, CSSObject> = (token) => {
|
2022-06-02 18:47:14 +08:00
|
|
|
const {
|
|
|
|
componentCls,
|
|
|
|
antCls,
|
|
|
|
iconCls,
|
|
|
|
fontSizeIcon,
|
2023-04-06 17:16:27 +08:00
|
|
|
padding,
|
2022-06-02 18:47:14 +08:00
|
|
|
paddingXS,
|
2023-11-17 13:46:41 +08:00
|
|
|
headerIconColor,
|
|
|
|
headerIconHoverColor,
|
2023-04-06 17:16:27 +08:00
|
|
|
tableSelectionColumnWidth,
|
2023-09-13 17:53:54 +08:00
|
|
|
tableSelectedRowBg,
|
|
|
|
tableSelectedRowHoverBg,
|
|
|
|
tableRowHoverBg,
|
2023-11-17 13:46:41 +08:00
|
|
|
tablePaddingHorizontal,
|
|
|
|
calc,
|
2022-06-02 18:47:14 +08:00
|
|
|
} = token;
|
2023-04-06 17:16:27 +08:00
|
|
|
|
2022-05-31 10:10:35 +08:00
|
|
|
return {
|
|
|
|
[`${componentCls}-wrapper`]: {
|
|
|
|
// ========================== Selections ==========================
|
|
|
|
[`${componentCls}-selection-col`]: {
|
2023-04-06 17:16:27 +08:00
|
|
|
width: tableSelectionColumnWidth,
|
|
|
|
[`&${componentCls}-selection-col-with-dropdown`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
width: calc(tableSelectionColumnWidth)
|
|
|
|
.add(fontSizeIcon)
|
|
|
|
.add(calc(padding).div(4))
|
|
|
|
.equal(),
|
2023-04-06 17:16:27 +08:00
|
|
|
},
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-bordered ${componentCls}-selection-col`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
width: calc(tableSelectionColumnWidth).add(calc(paddingXS).mul(2)).equal(),
|
2023-04-06 17:16:27 +08:00
|
|
|
[`&${componentCls}-selection-col-with-dropdown`]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
width: calc(tableSelectionColumnWidth)
|
|
|
|
.add(fontSizeIcon)
|
|
|
|
.add(calc(padding).div(4))
|
|
|
|
.add(calc(paddingXS).mul(2))
|
|
|
|
.equal(),
|
2023-04-06 17:16:27 +08:00
|
|
|
},
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`
|
|
|
|
table tr th${componentCls}-selection-column,
|
2023-09-12 17:33:59 +08:00
|
|
|
table tr td${componentCls}-selection-column,
|
|
|
|
${componentCls}-selection-column
|
2022-05-31 10:10:35 +08:00
|
|
|
`]: {
|
|
|
|
paddingInlineEnd: token.paddingXS,
|
|
|
|
paddingInlineStart: token.paddingXS,
|
|
|
|
textAlign: 'center',
|
|
|
|
|
|
|
|
[`${antCls}-radio-wrapper`]: {
|
|
|
|
marginInlineEnd: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`table tr th${componentCls}-selection-column${componentCls}-cell-fix-left`]: {
|
2024-08-11 16:18:49 +08:00
|
|
|
zIndex: calc(token.zIndexTableFixed).add(1).equal({ unit: false }),
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`table tr th${componentCls}-selection-column::after`]: {
|
|
|
|
backgroundColor: 'transparent !important',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-selection`]: {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-selection-extra`]: {
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
zIndex: 1,
|
|
|
|
cursor: 'pointer',
|
|
|
|
transition: `all ${token.motionDurationSlow}`,
|
|
|
|
marginInlineStart: '100%',
|
2023-11-17 13:46:41 +08:00
|
|
|
paddingInlineStart: unit(calc(tablePaddingHorizontal).div(4).equal()),
|
2022-05-31 10:10:35 +08:00
|
|
|
|
|
|
|
[iconCls]: {
|
2023-11-17 13:46:41 +08:00
|
|
|
color: headerIconColor,
|
2022-06-02 18:47:14 +08:00
|
|
|
fontSize: fontSizeIcon,
|
2022-05-31 10:10:35 +08:00
|
|
|
verticalAlign: 'baseline',
|
|
|
|
|
|
|
|
'&:hover': {
|
2023-11-17 13:46:41 +08:00
|
|
|
color: headerIconHoverColor,
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-09-13 17:53:54 +08:00
|
|
|
|
|
|
|
// ============================= Rows =============================
|
|
|
|
[`${componentCls}-tbody`]: {
|
|
|
|
[`${componentCls}-row`]: {
|
|
|
|
[`&${componentCls}-row-selected`]: {
|
|
|
|
[`> ${componentCls}-cell`]: {
|
|
|
|
background: tableSelectedRowBg,
|
|
|
|
|
|
|
|
'&-row-hover': {
|
|
|
|
background: tableSelectedRowHoverBg,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`> ${componentCls}-cell-row-hover`]: {
|
|
|
|
background: tableRowHoverBg,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-05-31 10:10:35 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default genSelectionStyle;
|