2022-05-16 12:21:14 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
|
2022-11-23 20:22:38 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
2022-10-28 16:44:19 +08:00
|
|
|
import { resetComponent, resetIcon, textEllipsis } from '../../style';
|
2022-05-16 12:21:14 +08:00
|
|
|
|
2022-06-02 16:17:40 +08:00
|
|
|
export interface ComponentToken {
|
|
|
|
listWidth: number;
|
|
|
|
listWidthLG: number;
|
|
|
|
listHeight: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface TransferToken extends FullToken<'Transfer'> {
|
|
|
|
transferItemHeight: number;
|
2022-05-16 12:21:14 +08:00
|
|
|
transferHeaderVerticalPadding: number;
|
|
|
|
transferItemPaddingVertical: number;
|
2022-10-25 17:04:36 +08:00
|
|
|
transferHeaderHeight: number;
|
2022-06-02 16:17:40 +08:00
|
|
|
}
|
2022-05-16 12:21:14 +08:00
|
|
|
|
|
|
|
const genTransferCustomizeStyle: GenerateStyle<TransferToken> = (
|
|
|
|
token: TransferToken,
|
|
|
|
): CSSObject => {
|
2022-06-02 16:17:40 +08:00
|
|
|
const { antCls, componentCls, listHeight, controlHeightLG, marginXXS, margin } = token;
|
2022-05-16 12:21:14 +08:00
|
|
|
|
|
|
|
const tableCls = `${antCls}-table`;
|
|
|
|
const inputCls = `${antCls}-input`;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`${componentCls}-customize-list`]: {
|
|
|
|
[`${componentCls}-list`]: {
|
|
|
|
flex: '1 1 50%',
|
|
|
|
width: 'auto',
|
|
|
|
height: 'auto',
|
2022-06-02 16:17:40 +08:00
|
|
|
minHeight: listHeight,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
// =================== Hook Components ===================
|
|
|
|
[`${tableCls}-wrapper`]: {
|
|
|
|
[`${tableCls}-small`]: {
|
|
|
|
border: 0,
|
|
|
|
borderRadius: 0,
|
|
|
|
|
|
|
|
[`${tableCls}-selection-column`]: {
|
2022-06-02 16:17:40 +08:00
|
|
|
width: controlHeightLG,
|
|
|
|
minWidth: controlHeightLG,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${tableCls}-pagination${tableCls}-pagination`]: {
|
2022-06-02 16:17:40 +08:00
|
|
|
margin: `${margin}px 0 ${marginXXS}px`,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${inputCls}[disabled]`]: {
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genTransferStatusColor = (token: TransferToken, color: string): CSSObject => {
|
2022-06-02 16:17:40 +08:00
|
|
|
const { componentCls, colorBorder } = token;
|
2022-05-16 12:21:14 +08:00
|
|
|
return {
|
|
|
|
[`${componentCls}-list`]: {
|
|
|
|
borderColor: color,
|
|
|
|
|
|
|
|
'&-search:not([disabled])': {
|
2022-06-02 16:17:40 +08:00
|
|
|
borderColor: colorBorder,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genTransferStatusStyle: GenerateStyle<TransferToken> = (token: TransferToken): CSSObject => {
|
|
|
|
const { componentCls } = token;
|
|
|
|
return {
|
|
|
|
[`${componentCls}-status-error`]: {
|
|
|
|
...genTransferStatusColor(token, token.colorError),
|
|
|
|
},
|
|
|
|
[`${componentCls}-status-warning`]: {
|
|
|
|
...genTransferStatusColor(token, token.colorWarning),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genTransferListStyle: GenerateStyle<TransferToken> = (token: TransferToken): CSSObject => {
|
|
|
|
const {
|
|
|
|
componentCls,
|
2022-06-02 16:17:40 +08:00
|
|
|
colorBorder,
|
|
|
|
colorSplit,
|
2022-11-01 15:06:38 +08:00
|
|
|
lineWidth,
|
2022-06-02 16:17:40 +08:00
|
|
|
transferItemHeight,
|
2022-05-16 12:21:14 +08:00
|
|
|
transferHeaderHeight,
|
|
|
|
transferHeaderVerticalPadding,
|
|
|
|
transferItemPaddingVertical,
|
2022-06-02 16:17:40 +08:00
|
|
|
controlItemBgActive,
|
|
|
|
controlItemBgActiveHover,
|
|
|
|
colorTextDisabled,
|
|
|
|
listHeight,
|
|
|
|
listWidth,
|
|
|
|
listWidthLG,
|
|
|
|
fontSizeIcon,
|
|
|
|
marginXS,
|
|
|
|
paddingSM,
|
2022-11-01 15:06:38 +08:00
|
|
|
lineType,
|
2022-06-02 16:17:40 +08:00
|
|
|
iconCls,
|
2022-08-05 15:23:36 +08:00
|
|
|
motionDurationSlow,
|
2022-05-16 12:21:14 +08:00
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
2022-06-02 16:17:40 +08:00
|
|
|
width: listWidth,
|
|
|
|
height: listHeight,
|
2022-11-01 15:06:38 +08:00
|
|
|
border: `${lineWidth}px ${lineType} ${colorBorder}`,
|
|
|
|
borderRadius: token.borderRadiusLG,
|
2022-05-16 12:21:14 +08:00
|
|
|
|
|
|
|
'&-with-pagination': {
|
2022-06-02 16:17:40 +08:00
|
|
|
width: listWidthLG,
|
2022-05-16 12:21:14 +08:00
|
|
|
height: 'auto',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-search': {
|
2022-06-02 16:17:40 +08:00
|
|
|
[`${iconCls}-search`]: {
|
|
|
|
color: colorTextDisabled,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-header': {
|
|
|
|
display: 'flex',
|
|
|
|
flex: 'none',
|
|
|
|
alignItems: 'center',
|
|
|
|
height: transferHeaderHeight,
|
|
|
|
// border-top is on the transfer dom. We should minus 1px for this
|
2022-06-02 16:17:40 +08:00
|
|
|
padding: `${
|
2022-11-01 15:06:38 +08:00
|
|
|
transferHeaderVerticalPadding - lineWidth
|
2022-06-02 16:17:40 +08:00
|
|
|
}px ${paddingSM}px ${transferHeaderVerticalPadding}px`,
|
2022-05-16 12:21:14 +08:00
|
|
|
color: token.colorText,
|
2022-06-28 20:33:01 +08:00
|
|
|
background: token.colorBgContainer,
|
2022-11-01 15:06:38 +08:00
|
|
|
borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
|
|
|
|
borderRadius: `${token.borderRadiusLG}px ${token.borderRadiusLG}px 0 0`,
|
2022-05-16 12:21:14 +08:00
|
|
|
|
|
|
|
'> *:not(:last-child)': {
|
2022-10-25 17:04:36 +08:00
|
|
|
marginInlineEnd: 4, // This is magic and fixed number, DO NOT use token since it may change.
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'> *': {
|
|
|
|
flex: 'none',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-title': {
|
2022-10-28 16:44:19 +08:00
|
|
|
...textEllipsis,
|
2022-05-16 12:21:14 +08:00
|
|
|
flex: 'auto',
|
|
|
|
textAlign: 'end',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-dropdown': {
|
2022-06-02 16:17:40 +08:00
|
|
|
...resetIcon(),
|
|
|
|
|
|
|
|
fontSize: fontSizeIcon,
|
2022-05-16 12:21:14 +08:00
|
|
|
transform: 'translateY(10%)',
|
|
|
|
cursor: 'pointer',
|
|
|
|
|
|
|
|
'&[disabled]': {
|
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-body': {
|
|
|
|
display: 'flex',
|
|
|
|
flex: 'auto',
|
|
|
|
flexDirection: 'column',
|
|
|
|
overflow: 'hidden',
|
2022-11-01 15:06:38 +08:00
|
|
|
fontSize: token.fontSize,
|
2022-05-16 12:21:14 +08:00
|
|
|
|
|
|
|
'&-search-wrapper': {
|
|
|
|
position: 'relative',
|
|
|
|
flex: 'none',
|
2022-06-02 16:17:40 +08:00
|
|
|
padding: paddingSM,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-content': {
|
|
|
|
flex: 'auto',
|
|
|
|
margin: 0,
|
|
|
|
padding: 0,
|
|
|
|
overflow: 'auto',
|
|
|
|
listStyle: 'none',
|
|
|
|
|
|
|
|
'&-item': {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
2022-06-02 16:17:40 +08:00
|
|
|
minHeight: transferItemHeight,
|
|
|
|
padding: `${transferItemPaddingVertical}px ${paddingSM}px`,
|
2022-08-05 15:23:36 +08:00
|
|
|
transition: `all ${motionDurationSlow}`,
|
2022-05-16 12:21:14 +08:00
|
|
|
|
|
|
|
'> *:not(:last-child)': {
|
2022-06-02 16:17:40 +08:00
|
|
|
marginInlineEnd: marginXS,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'> *': {
|
|
|
|
flex: 'none',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-text': {
|
2022-10-28 16:44:19 +08:00
|
|
|
...textEllipsis,
|
2022-05-16 12:21:14 +08:00
|
|
|
flex: 'auto',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-remove': {
|
|
|
|
position: 'relative',
|
2022-06-02 16:17:40 +08:00
|
|
|
color: colorBorder,
|
2022-05-16 12:21:14 +08:00
|
|
|
|
2022-08-05 15:23:36 +08:00
|
|
|
cursor: 'pointer',
|
|
|
|
transition: `all ${motionDurationSlow}`,
|
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
color: token.colorLinkHover,
|
|
|
|
},
|
|
|
|
|
2022-05-16 12:21:14 +08:00
|
|
|
'&::after': {
|
|
|
|
position: 'absolute',
|
|
|
|
insert: `-${transferItemPaddingVertical}px -50%`,
|
|
|
|
content: '""',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-01-17 17:51:59 +08:00
|
|
|
[`&:not(${componentCls}-list-content-item-disabled)`]: {
|
2022-05-16 12:21:14 +08:00
|
|
|
'&:hover': {
|
|
|
|
backgroundColor: token.controlItemBgHover,
|
|
|
|
cursor: 'pointer',
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${componentCls}-list-content-item-checked:hover`]: {
|
2022-06-02 16:17:40 +08:00
|
|
|
backgroundColor: controlItemBgActiveHover,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-checked': {
|
2022-06-02 16:17:40 +08:00
|
|
|
backgroundColor: controlItemBgActive,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-disabled': {
|
2022-06-02 16:17:40 +08:00
|
|
|
color: colorTextDisabled,
|
2022-05-16 12:21:14 +08:00
|
|
|
cursor: 'not-allowed',
|
|
|
|
},
|
|
|
|
},
|
2023-01-17 17:51:59 +08:00
|
|
|
|
|
|
|
// Do not change hover style when `oneWay` mode
|
|
|
|
[`&-show-remove ${componentCls}-list-content-item:not(${componentCls}-list-content-item-disabled):hover`]:
|
|
|
|
{
|
|
|
|
background: 'transparent',
|
|
|
|
cursor: 'default',
|
|
|
|
},
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-pagination': {
|
|
|
|
padding: `${token.paddingXS}px 0`,
|
|
|
|
textAlign: 'end',
|
2022-11-01 15:06:38 +08:00
|
|
|
borderTop: `${lineWidth}px ${lineType} ${colorSplit}`,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
'&-body-not-found': {
|
|
|
|
flex: 'none',
|
|
|
|
width: '100%',
|
|
|
|
margin: 'auto 0',
|
2022-06-02 16:17:40 +08:00
|
|
|
color: colorTextDisabled,
|
2022-05-16 12:21:14 +08:00
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
|
|
|
|
'&-footer': {
|
2022-11-01 15:06:38 +08:00
|
|
|
borderTop: `${lineWidth}px ${lineType} ${colorSplit}`,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genTransferStyle: GenerateStyle<TransferToken> = (token: TransferToken): CSSObject => {
|
2022-06-02 16:17:40 +08:00
|
|
|
const {
|
|
|
|
antCls,
|
|
|
|
iconCls,
|
|
|
|
componentCls,
|
|
|
|
transferHeaderHeight,
|
|
|
|
marginXS,
|
|
|
|
marginXXS,
|
|
|
|
fontSizeIcon,
|
|
|
|
fontSize,
|
|
|
|
lineHeight,
|
|
|
|
} = token;
|
2022-05-16 12:21:14 +08:00
|
|
|
|
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
...resetComponent(token),
|
|
|
|
|
|
|
|
position: 'relative',
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'stretch',
|
|
|
|
|
|
|
|
[`${componentCls}-disabled`]: {
|
|
|
|
[`${componentCls}-list`]: {
|
2022-06-28 20:33:01 +08:00
|
|
|
background: token.colorBgContainerDisabled,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-list`]: genTransferListStyle(token),
|
|
|
|
|
|
|
|
[`${componentCls}-operation`]: {
|
|
|
|
display: 'flex',
|
|
|
|
flex: 'none',
|
|
|
|
flexDirection: 'column',
|
|
|
|
alignSelf: 'center',
|
2022-06-02 16:17:40 +08:00
|
|
|
margin: `0 ${marginXS}px`,
|
2022-05-16 12:21:14 +08:00
|
|
|
verticalAlign: 'middle',
|
|
|
|
|
|
|
|
[`${antCls}-btn`]: {
|
|
|
|
display: 'block',
|
|
|
|
|
|
|
|
'&:first-child': {
|
2022-06-02 16:17:40 +08:00
|
|
|
marginBottom: marginXXS,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[iconCls]: {
|
2022-06-02 16:17:40 +08:00
|
|
|
fontSize: fontSizeIcon,
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${antCls}-empty-image`]: {
|
2022-06-02 16:17:40 +08:00
|
|
|
maxHeight: transferHeaderHeight / 2 - Math.round(fontSize * lineHeight),
|
2022-05-16 12:21:14 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genTransferRTLStyle: GenerateStyle<TransferToken> = (token: TransferToken): CSSObject => {
|
|
|
|
const { componentCls } = token;
|
|
|
|
return {
|
|
|
|
[`${componentCls}-rtl`]: {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-06-02 16:17:40 +08:00
|
|
|
export default genComponentStyleHook(
|
|
|
|
'Transfer',
|
2022-11-19 13:47:33 +08:00
|
|
|
(token) => {
|
2022-11-01 15:06:38 +08:00
|
|
|
const { fontSize, lineHeight, lineWidth, controlHeightLG, controlHeight } = token;
|
2022-06-02 16:17:40 +08:00
|
|
|
|
|
|
|
const fontHeight = Math.round(fontSize * lineHeight);
|
|
|
|
const transferHeaderHeight = controlHeightLG;
|
|
|
|
const transferItemHeight = controlHeight;
|
|
|
|
|
|
|
|
const transferToken = mergeToken<TransferToken>(token, {
|
|
|
|
transferItemHeight,
|
|
|
|
transferHeaderHeight,
|
2022-11-01 15:06:38 +08:00
|
|
|
transferHeaderVerticalPadding: Math.ceil((transferHeaderHeight - lineWidth - fontHeight) / 2),
|
2022-06-02 16:17:40 +08:00
|
|
|
transferItemPaddingVertical: (transferItemHeight - fontHeight) / 2,
|
|
|
|
});
|
|
|
|
|
|
|
|
return [
|
|
|
|
genTransferStyle(transferToken),
|
|
|
|
genTransferCustomizeStyle(transferToken),
|
|
|
|
genTransferStatusStyle(transferToken),
|
|
|
|
genTransferRTLStyle(transferToken),
|
|
|
|
];
|
|
|
|
},
|
|
|
|
{
|
|
|
|
listWidth: 180,
|
|
|
|
listHeight: 200,
|
|
|
|
listWidthLG: 250,
|
|
|
|
},
|
|
|
|
);
|