mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 08:59:40 +08:00
821ac5bc97
* refactor: select use genHook * chore: code clean * refactor: tree-select support genHook * chore: code clean * chore: code clean * fix: tree style
80 lines
2.4 KiB
TypeScript
80 lines
2.4 KiB
TypeScript
// import '../../style/index.less';
|
|
// import './index.less';
|
|
|
|
// // style dependencies
|
|
// // deps-lint-skip: tree, form
|
|
// import '../../select/style';
|
|
// import '../../empty/style';
|
|
|
|
// deps-lint-skip-all
|
|
import { GenerateStyle, genComponentStyleHook, FullToken } from '../../_util/theme';
|
|
import { getStyle as getCheckboxStyle } from '../../checkbox/style';
|
|
import { genTreeStyle } from '../../tree/style';
|
|
|
|
interface TreeSelectToken extends FullToken<'TreeSelect'> {
|
|
treePrefixCls: string;
|
|
}
|
|
|
|
// =============================== Base ===============================
|
|
const genBaseStyle: GenerateStyle<TreeSelectToken> = (token, hashId) => {
|
|
const { componentCls, treePrefixCls } = token;
|
|
const treeCls = `.${treePrefixCls}`;
|
|
|
|
return [
|
|
// ======================================================
|
|
// == Dropdown ==
|
|
// ======================================================
|
|
{
|
|
[`${componentCls}-dropdown`]: [
|
|
{
|
|
padding: `${token.paddingXS}px ${token.paddingXS / 2}px`,
|
|
},
|
|
|
|
// ====================== Tree ======================
|
|
genTreeStyle(treePrefixCls, token, hashId!),
|
|
{
|
|
[treeCls]: {
|
|
borderRadius: 0,
|
|
'&-list-holder-inner': {
|
|
alignItems: 'stretch',
|
|
|
|
[`${treeCls}-treenode`]: {
|
|
[`${treeCls}-node-content-wrapper`]: {
|
|
flex: 'auto',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
// ==================== Checkbox ====================
|
|
getCheckboxStyle(`${treePrefixCls}-checkbox`, token, hashId!),
|
|
|
|
// ====================== RTL =======================
|
|
{
|
|
'&-rtl': {
|
|
direction: 'rtl',
|
|
|
|
[`${treeCls}-switcher${treeCls}-switcher_close`]: {
|
|
[`${treeCls}-switcher-icon svg`]: {
|
|
transform: 'rotate(90deg)',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
];
|
|
};
|
|
|
|
// ============================== Export ==============================
|
|
export default function useTreeSelectStyle(prefixCls: string, treePrefixCls: string) {
|
|
return genComponentStyleHook('TreeSelect', (token, { hashId }) => {
|
|
const treeSelectToken: TreeSelectToken = {
|
|
...token,
|
|
treePrefixCls,
|
|
};
|
|
return [genBaseStyle(treeSelectToken, hashId)];
|
|
})(prefixCls);
|
|
}
|