|
import type { CSSProperties } from 'react'; |
|
|
|
import { genCompactItemStyle } from '../../style/compact-item'; |
|
import type { FullToken, GenerateStyle, GlobalToken } from '../../theme/internal'; |
|
import { genStyleHooks } from '../../theme/internal'; |
|
import getColumnsStyle from './columns'; |
|
|
|
export interface ComponentToken { |
|
|
|
|
|
|
|
|
|
controlWidth: number | string; |
|
|
|
|
|
|
|
|
|
controlItemWidth: number | string; |
|
|
|
|
|
|
|
|
|
dropdownHeight: number | string; |
|
|
|
|
|
|
|
|
|
optionSelectedBg: string; |
|
|
|
|
|
|
|
|
|
optionSelectedColor: string; |
|
|
|
|
|
|
|
|
|
optionSelectedFontWeight: CSSProperties['fontWeight']; |
|
|
|
|
|
|
|
|
|
optionPadding: CSSProperties['padding']; |
|
|
|
|
|
|
|
|
|
menuPadding: CSSProperties['padding']; |
|
} |
|
|
|
export type CascaderToken = FullToken<'Cascader'>; |
|
|
|
|
|
const genBaseStyle: GenerateStyle<CascaderToken> = (token) => { |
|
const { componentCls, antCls } = token; |
|
|
|
return [ |
|
|
|
|
|
|
|
{ |
|
[componentCls]: { |
|
width: token.controlWidth, |
|
}, |
|
}, |
|
|
|
|
|
|
|
{ |
|
[`${componentCls}-dropdown`]: [ |
|
{ |
|
[`&${antCls}-select-dropdown`]: { |
|
padding: 0, |
|
}, |
|
}, |
|
getColumnsStyle(token), |
|
], |
|
}, |
|
|
|
|
|
|
|
{ |
|
[`${componentCls}-dropdown-rtl`]: { |
|
direction: 'rtl', |
|
}, |
|
}, |
|
|
|
|
|
|
|
genCompactItemStyle(token), |
|
]; |
|
}; |
|
|
|
|
|
export const prepareComponentToken = (token: GlobalToken) => { |
|
const itemPaddingVertical = Math.round( |
|
(token.controlHeight - token.fontSize * token.lineHeight) / 2, |
|
); |
|
|
|
return { |
|
controlWidth: 184, |
|
controlItemWidth: 111, |
|
dropdownHeight: 180, |
|
optionSelectedBg: token.controlItemBgActive, |
|
optionSelectedFontWeight: token.fontWeightStrong, |
|
optionPadding: `${itemPaddingVertical}px ${token.paddingSM}px`, |
|
menuPadding: token.paddingXXS, |
|
optionSelectedColor: token.colorText, |
|
}; |
|
}; |
|
|
|
export default genStyleHooks('Cascader', (token) => [genBaseStyle(token)], prepareComponentToken, { |
|
unitless: { |
|
optionSelectedFontWeight: true, |
|
}, |
|
}); |
|
|