2022-03-09 00:29:00 +08:00
|
|
|
// import '../../style/index.less';
|
|
|
|
// import './index.less';
|
2016-04-27 20:44:36 +08:00
|
|
|
|
2022-03-09 00:29:00 +08:00
|
|
|
// // style dependencies
|
|
|
|
// import '../../empty/style';
|
|
|
|
// import '../../select/style';
|
2022-02-17 15:08:13 +08:00
|
|
|
|
2022-03-09 00:29:00 +08:00
|
|
|
// // deps-lint-skip: form
|
|
|
|
|
|
|
|
// deps-lint-skip-all
|
|
|
|
import {
|
|
|
|
DerivativeToken,
|
|
|
|
useStyleRegister,
|
|
|
|
useToken,
|
|
|
|
UseComponentStyleResult,
|
2022-03-11 14:29:29 +08:00
|
|
|
GenerateStyle,
|
2022-03-09 00:29:00 +08:00
|
|
|
} from '../../_util/theme';
|
|
|
|
import { getStyle as getCheckboxStyle } from '../../checkbox/style';
|
|
|
|
|
|
|
|
interface CascaderToken extends DerivativeToken {
|
2022-03-09 15:33:39 +08:00
|
|
|
prefixCls: string;
|
2022-03-09 00:29:00 +08:00
|
|
|
cascaderCls: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================== Base ===============================
|
2022-03-11 14:29:29 +08:00
|
|
|
const genBaseStyle: GenerateStyle<CascaderToken> = (token, hashId) => {
|
2022-03-09 15:33:39 +08:00
|
|
|
const { prefixCls, cascaderCls } = token;
|
2022-03-09 00:29:00 +08:00
|
|
|
const cascaderMenuItemCls = `${cascaderCls}-menu-item`;
|
|
|
|
const iconCls = `
|
|
|
|
${cascaderMenuItemCls}-expand ${cascaderMenuItemCls}-expand-icon,
|
|
|
|
${cascaderMenuItemCls}-loading-icon
|
|
|
|
`;
|
|
|
|
|
|
|
|
const itemPaddingVertical = Math.round(
|
|
|
|
(token.controlHeight - token.fontSize * token.lineHeight) / 2,
|
|
|
|
);
|
|
|
|
|
|
|
|
return [
|
|
|
|
// =====================================================
|
|
|
|
// == Control ==
|
|
|
|
// =====================================================
|
|
|
|
{
|
|
|
|
[cascaderCls]: {
|
|
|
|
width: 184, // FIXME: hardcode in v4
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
// == Popup ==
|
|
|
|
// =====================================================
|
|
|
|
{
|
2022-03-09 15:33:39 +08:00
|
|
|
[`${cascaderCls}-dropdown`]: [
|
|
|
|
// ==================== Checkbox ====================
|
2022-03-11 14:29:29 +08:00
|
|
|
getCheckboxStyle(`${prefixCls}-checkbox`, token, hashId!),
|
2022-03-09 15:33:39 +08:00
|
|
|
{
|
|
|
|
[cascaderCls]: {
|
|
|
|
// ================== Checkbox ==================
|
|
|
|
'&-checkbox': {
|
|
|
|
top: 0,
|
|
|
|
marginInlineEnd: token.paddingXS,
|
2022-03-09 00:29:00 +08:00
|
|
|
},
|
|
|
|
|
2022-03-09 15:33:39 +08:00
|
|
|
// ==================== Menu ====================
|
|
|
|
// >>> Menus
|
|
|
|
'&-menus': {
|
2022-03-09 00:29:00 +08:00
|
|
|
display: 'flex',
|
|
|
|
flexWrap: 'nowrap',
|
2022-03-09 15:33:39 +08:00
|
|
|
alignItems: 'flex-start',
|
|
|
|
|
|
|
|
[`&${cascaderCls}-menu-empty`]: {
|
|
|
|
[`${cascaderCls}-menu`]: {
|
|
|
|
width: '100%',
|
|
|
|
height: 'auto',
|
|
|
|
|
|
|
|
[cascaderMenuItemCls]: {
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextDisabled,
|
2022-03-09 15:33:39 +08:00
|
|
|
cursor: 'default',
|
|
|
|
pointerEvents: 'none',
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 00:29:00 +08:00
|
|
|
},
|
2022-03-09 15:33:39 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
// >>> Menu
|
|
|
|
'&-menu': {
|
|
|
|
minWidth: 111, // FIXME: hardcode in v4
|
|
|
|
height: 180, // FIXME: hardcode in v4
|
|
|
|
margin: `-${token.paddingXS}px 0`,
|
|
|
|
padding: `${token.paddingXS}px 0`,
|
|
|
|
overflow: 'auto',
|
|
|
|
verticalAlign: 'top',
|
|
|
|
listStyle: 'none',
|
2022-03-22 13:26:29 +08:00
|
|
|
borderInlineEnd: `${token.controlLineWidth}px ${token.controlLineType} ${token.colorSplit}`,
|
2022-03-09 15:33:39 +08:00
|
|
|
'-ms-overflow-style': '-ms-autohiding-scrollbar', // https://github.com/ant-design/ant-design/issues/11857
|
|
|
|
|
|
|
|
'&-item': {
|
|
|
|
display: 'flex',
|
|
|
|
flexWrap: 'nowrap',
|
|
|
|
alignItems: 'center',
|
|
|
|
padding: `${itemPaddingVertical}px ${token.paddingSM}px`,
|
|
|
|
overflow: 'hidden',
|
|
|
|
lineHeight: token.lineHeight,
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
textOverflow: 'ellipsis',
|
|
|
|
cursor: 'pointer',
|
2022-03-22 20:02:04 +08:00
|
|
|
transition: `all ${token.motionDurationSlow}`,
|
2022-03-09 00:29:00 +08:00
|
|
|
|
|
|
|
'&:hover': {
|
2022-03-22 20:02:04 +08:00
|
|
|
background: token.controlItemBgHover,
|
2022-03-09 00:29:00 +08:00
|
|
|
},
|
2022-03-09 15:33:39 +08:00
|
|
|
' &-disabled': {
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextDisabled,
|
2022-03-09 15:33:39 +08:00
|
|
|
cursor: 'not-allowed',
|
|
|
|
|
|
|
|
'&:hover': {
|
|
|
|
background: 'transparent',
|
|
|
|
},
|
|
|
|
|
|
|
|
[iconCls]: {
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextDisabled,
|
2022-03-09 15:33:39 +08:00
|
|
|
},
|
2022-03-09 00:29:00 +08:00
|
|
|
},
|
|
|
|
|
2022-03-09 15:33:39 +08:00
|
|
|
[`&-active:not(${cascaderMenuItemCls}-disabled)`]: {
|
|
|
|
[`&, &:hover`]: {
|
|
|
|
fontWeight: 600, // FIXME: hardcode
|
2022-03-22 20:02:04 +08:00
|
|
|
backgroundColor: token.controlItemBgActive,
|
2022-03-09 15:33:39 +08:00
|
|
|
},
|
2022-03-09 00:29:00 +08:00
|
|
|
},
|
|
|
|
|
2022-03-09 15:33:39 +08:00
|
|
|
'&-content': {
|
|
|
|
flex: 'auto',
|
|
|
|
},
|
2022-03-09 00:29:00 +08:00
|
|
|
|
2022-03-09 15:33:39 +08:00
|
|
|
[iconCls]: {
|
|
|
|
marginInlineStart: token.paddingXXS,
|
2022-03-22 13:26:29 +08:00
|
|
|
color: token.colorTextSecondary,
|
2022-03-09 15:33:39 +08:00
|
|
|
fontSize: 10, // FIXME: hardcode in v4
|
|
|
|
},
|
2022-03-09 00:29:00 +08:00
|
|
|
|
2022-03-09 15:33:39 +08:00
|
|
|
'&-keyword': {
|
2022-03-24 14:30:48 +08:00
|
|
|
color: token.colorHighlight,
|
2022-03-09 15:33:39 +08:00
|
|
|
},
|
2022-03-09 00:29:00 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-03-09 15:33:39 +08:00
|
|
|
],
|
2022-03-09 00:29:00 +08:00
|
|
|
},
|
|
|
|
// =====================================================
|
|
|
|
// == RTL ==
|
|
|
|
// =====================================================
|
|
|
|
{
|
|
|
|
[`${cascaderCls}-dropdown-rtl`]: {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
|
|
|
export default function useStyle(prefixCls: string): UseComponentStyleResult {
|
|
|
|
const [theme, token, hashId] = useToken();
|
|
|
|
|
|
|
|
const cascaderToken: CascaderToken = {
|
|
|
|
...token,
|
2022-03-09 15:33:39 +08:00
|
|
|
prefixCls,
|
2022-03-09 00:29:00 +08:00
|
|
|
cascaderCls: `.${prefixCls}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
|
|
|
useStyleRegister({ theme, token, hashId, path: [prefixCls] }, () => [
|
2022-03-09 15:33:39 +08:00
|
|
|
genBaseStyle(cascaderToken, hashId),
|
2022-03-09 00:29:00 +08:00
|
|
|
]),
|
|
|
|
hashId,
|
|
|
|
];
|
|
|
|
}
|