2023-12-21 13:39:04 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
|
|
|
import { unit } from '@ant-design/cssinjs';
|
|
|
|
|
2024-04-08 14:04:08 +08:00
|
|
|
import type { SelectToken } from './token';
|
|
|
|
|
2023-12-21 13:39:04 +08:00
|
|
|
// =====================================================
|
|
|
|
// == Outlined ==
|
|
|
|
// =====================================================
|
|
|
|
const genBaseOutlinedStyle = (
|
|
|
|
token: SelectToken,
|
|
|
|
options: {
|
|
|
|
borderColor: string;
|
|
|
|
hoverBorderHover: string;
|
|
|
|
activeBorderColor: string;
|
2024-09-22 18:36:05 +08:00
|
|
|
activeOutlineColor: string;
|
2024-11-20 11:54:49 +08:00
|
|
|
color: string;
|
2023-12-21 13:39:04 +08:00
|
|
|
},
|
|
|
|
): CSSObject => {
|
|
|
|
const { componentCls, antCls, controlOutlineWidth } = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`&:not(${componentCls}-customize-input) ${componentCls}-selector`]: {
|
|
|
|
border: `${unit(token.lineWidth)} ${token.lineType} ${options.borderColor}`,
|
|
|
|
background: token.selectorBg,
|
|
|
|
},
|
|
|
|
[`&:not(${componentCls}-disabled):not(${componentCls}-customize-input):not(${antCls}-pagination-size-changer)`]:
|
|
|
|
{
|
|
|
|
[`&:hover ${componentCls}-selector`]: {
|
|
|
|
borderColor: options.hoverBorderHover,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-focused& ${componentCls}-selector`]: {
|
|
|
|
borderColor: options.activeBorderColor,
|
2024-09-22 18:36:05 +08:00
|
|
|
boxShadow: `0 0 0 ${unit(controlOutlineWidth)} ${options.activeOutlineColor}`,
|
2023-12-21 13:39:04 +08:00
|
|
|
outline: 0,
|
|
|
|
},
|
2024-11-20 11:54:49 +08:00
|
|
|
[`${componentCls}-prefix`]: {
|
|
|
|
color: options.color,
|
|
|
|
},
|
2023-12-21 13:39:04 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genOutlinedStatusStyle = (
|
|
|
|
token: SelectToken,
|
|
|
|
options: {
|
|
|
|
status: string;
|
|
|
|
borderColor: string;
|
|
|
|
hoverBorderHover: string;
|
|
|
|
activeBorderColor: string;
|
2024-09-22 18:36:05 +08:00
|
|
|
activeOutlineColor: string;
|
2024-11-20 11:54:49 +08:00
|
|
|
color: string;
|
2023-12-21 13:39:04 +08:00
|
|
|
},
|
|
|
|
): CSSObject => ({
|
|
|
|
[`&${token.componentCls}-status-${options.status}`]: {
|
|
|
|
...genBaseOutlinedStyle(token, options),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const genOutlinedStyle = (token: SelectToken): CSSObject => ({
|
|
|
|
'&-outlined': {
|
|
|
|
...genBaseOutlinedStyle(token, {
|
|
|
|
borderColor: token.colorBorder,
|
2024-09-22 18:36:05 +08:00
|
|
|
hoverBorderHover: token.hoverBorderColor,
|
|
|
|
activeBorderColor: token.activeBorderColor,
|
|
|
|
activeOutlineColor: token.activeOutlineColor,
|
2024-11-20 11:54:49 +08:00
|
|
|
color: token.colorText,
|
2023-12-21 13:39:04 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
...genOutlinedStatusStyle(token, {
|
|
|
|
status: 'error',
|
|
|
|
borderColor: token.colorError,
|
|
|
|
hoverBorderHover: token.colorErrorHover,
|
|
|
|
activeBorderColor: token.colorError,
|
2024-09-22 18:36:05 +08:00
|
|
|
activeOutlineColor: token.colorErrorOutline,
|
2024-11-20 11:54:49 +08:00
|
|
|
color: token.colorError,
|
2023-12-21 13:39:04 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
...genOutlinedStatusStyle(token, {
|
|
|
|
status: 'warning',
|
|
|
|
borderColor: token.colorWarning,
|
|
|
|
hoverBorderHover: token.colorWarningHover,
|
|
|
|
activeBorderColor: token.colorWarning,
|
2024-09-22 18:36:05 +08:00
|
|
|
activeOutlineColor: token.colorWarningOutline,
|
2024-11-20 11:54:49 +08:00
|
|
|
color: token.colorWarning,
|
2023-12-21 13:39:04 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
[`&${token.componentCls}-disabled`]: {
|
|
|
|
[`&:not(${token.componentCls}-customize-input) ${token.componentCls}-selector`]: {
|
|
|
|
background: token.colorBgContainerDisabled,
|
|
|
|
color: token.colorTextDisabled,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${token.componentCls}-multiple ${token.componentCls}-selection-item`]: {
|
|
|
|
background: token.multipleItemBg,
|
|
|
|
border: `${unit(token.lineWidth)} ${token.lineType} ${token.multipleItemBorderColor}`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// == Filled ==
|
|
|
|
// =====================================================
|
|
|
|
const genBaseFilledStyle = (
|
|
|
|
token: SelectToken,
|
|
|
|
options: {
|
|
|
|
bg: string;
|
|
|
|
hoverBg: string;
|
|
|
|
activeBorderColor: string;
|
|
|
|
color: string;
|
|
|
|
},
|
|
|
|
): CSSObject => {
|
|
|
|
const { componentCls, antCls } = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[`&:not(${componentCls}-customize-input) ${componentCls}-selector`]: {
|
|
|
|
background: options.bg,
|
|
|
|
border: `${unit(token.lineWidth)} ${token.lineType} transparent`,
|
|
|
|
color: options.color,
|
|
|
|
},
|
|
|
|
[`&:not(${componentCls}-disabled):not(${componentCls}-customize-input):not(${antCls}-pagination-size-changer)`]:
|
|
|
|
{
|
|
|
|
[`&:hover ${componentCls}-selector`]: {
|
|
|
|
background: options.hoverBg,
|
|
|
|
},
|
|
|
|
|
|
|
|
[`${componentCls}-focused& ${componentCls}-selector`]: {
|
|
|
|
background: token.selectorBg,
|
|
|
|
borderColor: options.activeBorderColor,
|
|
|
|
outline: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const genFilledStatusStyle = (
|
|
|
|
token: SelectToken,
|
|
|
|
options: {
|
|
|
|
status: string;
|
|
|
|
bg: string;
|
|
|
|
hoverBg: string;
|
|
|
|
activeBorderColor: string;
|
|
|
|
color: string;
|
|
|
|
},
|
|
|
|
): CSSObject => ({
|
|
|
|
[`&${token.componentCls}-status-${options.status}`]: {
|
|
|
|
...genBaseFilledStyle(token, options),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const genFilledStyle = (token: SelectToken): CSSObject => ({
|
|
|
|
'&-filled': {
|
|
|
|
...genBaseFilledStyle(token, {
|
|
|
|
bg: token.colorFillTertiary,
|
|
|
|
hoverBg: token.colorFillSecondary,
|
2024-09-27 18:49:49 +08:00
|
|
|
activeBorderColor: token.activeBorderColor,
|
2023-12-21 13:39:04 +08:00
|
|
|
color: token.colorText,
|
|
|
|
}),
|
|
|
|
|
|
|
|
...genFilledStatusStyle(token, {
|
|
|
|
status: 'error',
|
|
|
|
bg: token.colorErrorBg,
|
|
|
|
hoverBg: token.colorErrorBgHover,
|
|
|
|
activeBorderColor: token.colorError,
|
|
|
|
color: token.colorError,
|
|
|
|
}),
|
|
|
|
|
|
|
|
...genFilledStatusStyle(token, {
|
|
|
|
status: 'warning',
|
|
|
|
bg: token.colorWarningBg,
|
|
|
|
hoverBg: token.colorWarningBgHover,
|
|
|
|
activeBorderColor: token.colorWarning,
|
|
|
|
color: token.colorWarning,
|
|
|
|
}),
|
|
|
|
|
|
|
|
[`&${token.componentCls}-disabled`]: {
|
|
|
|
[`&:not(${token.componentCls}-customize-input) ${token.componentCls}-selector`]: {
|
|
|
|
borderColor: token.colorBorder,
|
|
|
|
background: token.colorBgContainerDisabled,
|
|
|
|
color: token.colorTextDisabled,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${token.componentCls}-multiple ${token.componentCls}-selection-item`]: {
|
|
|
|
background: token.colorBgContainer,
|
|
|
|
border: `${unit(token.lineWidth)} ${token.lineType} ${token.colorSplit}`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// == Borderless ==
|
|
|
|
// =====================================================
|
|
|
|
const genBorderlessStyle = (token: SelectToken): CSSObject => ({
|
|
|
|
'&-borderless': {
|
|
|
|
[`${token.componentCls}-selector`]: {
|
|
|
|
background: 'transparent',
|
2024-11-20 11:54:49 +08:00
|
|
|
border: `${unit(token.lineWidth)} ${token.lineType} transparent`,
|
2023-12-21 13:39:04 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
[`&${token.componentCls}-disabled`]: {
|
|
|
|
[`&:not(${token.componentCls}-customize-input) ${token.componentCls}-selector`]: {
|
|
|
|
color: token.colorTextDisabled,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${token.componentCls}-multiple ${token.componentCls}-selection-item`]: {
|
|
|
|
background: token.multipleItemBg,
|
|
|
|
border: `${unit(token.lineWidth)} ${token.lineType} ${token.multipleItemBorderColor}`,
|
|
|
|
},
|
2024-06-26 21:35:12 +08:00
|
|
|
|
|
|
|
// Status
|
|
|
|
[`&${token.componentCls}-status-error`]: {
|
2024-11-20 11:54:49 +08:00
|
|
|
[`${token.componentCls}-prefix, ${token.componentCls}-selection-item`]: {
|
2024-06-26 21:35:12 +08:00
|
|
|
color: token.colorError,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`&${token.componentCls}-status-warning`]: {
|
2024-11-20 11:54:49 +08:00
|
|
|
[`${token.componentCls}-prefix, ${token.componentCls}-selection-item`]: {
|
2024-06-26 21:35:12 +08:00
|
|
|
color: token.colorWarning,
|
|
|
|
},
|
|
|
|
},
|
2023-12-21 13:39:04 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const genVariantsStyle = (token: SelectToken): CSSObject => ({
|
|
|
|
[token.componentCls]: {
|
|
|
|
...genOutlinedStyle(token),
|
|
|
|
...genFilledStyle(token),
|
|
|
|
...genBorderlessStyle(token),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default genVariantsStyle;
|