2023-11-14 19:17:23 +08:00
|
|
|
import { unit } from '@ant-design/cssinjs';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
2022-03-09 15:33:39 +08:00
|
|
|
import { getStyle as getCheckboxStyle } from '../../checkbox/style';
|
2024-07-23 17:23:43 +08:00
|
|
|
import type {
|
|
|
|
AliasToken,
|
|
|
|
FullToken,
|
|
|
|
GenerateStyle,
|
|
|
|
GetDefaultToken,
|
|
|
|
CSSUtil,
|
|
|
|
} from '../../theme/internal';
|
2023-11-29 17:23:45 +08:00
|
|
|
import { genStyleHooks, mergeToken } from '../../theme/internal';
|
2023-08-18 10:23:57 +08:00
|
|
|
import type { TreeSharedToken } from '../../tree/style';
|
|
|
|
import { genTreeStyle, initComponentToken } from '../../tree/style';
|
|
|
|
|
|
|
|
export interface ComponentToken extends TreeSharedToken {}
|
2022-03-09 15:33:39 +08:00
|
|
|
|
2022-04-07 12:20:34 +08:00
|
|
|
interface TreeSelectToken extends FullToken<'TreeSelect'> {
|
2022-03-09 15:33:39 +08:00
|
|
|
treePrefixCls: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// =============================== Base ===============================
|
2022-11-19 13:47:33 +08:00
|
|
|
const genBaseStyle: GenerateStyle<TreeSelectToken> = (token) => {
|
2022-06-21 11:06:06 +08:00
|
|
|
const { componentCls, treePrefixCls, colorBgElevated } = token;
|
2022-03-09 15:33:39 +08:00
|
|
|
const treeCls = `.${treePrefixCls}`;
|
|
|
|
|
|
|
|
return [
|
|
|
|
// ======================================================
|
|
|
|
// == Dropdown ==
|
|
|
|
// ======================================================
|
|
|
|
{
|
2022-04-07 12:20:34 +08:00
|
|
|
[`${componentCls}-dropdown`]: [
|
2022-03-09 15:33:39 +08:00
|
|
|
{
|
2023-11-14 19:17:23 +08:00
|
|
|
padding: `${unit(token.paddingXS)} ${unit(token.calc(token.paddingXS).div(2).equal())}`,
|
2022-03-09 15:33:39 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
// ====================== Tree ======================
|
2022-06-21 11:06:06 +08:00
|
|
|
genTreeStyle(
|
|
|
|
treePrefixCls,
|
2023-11-14 19:17:23 +08:00
|
|
|
mergeToken<AliasToken & TreeSharedToken & CSSUtil>(token, {
|
|
|
|
colorBgContainer: colorBgElevated,
|
|
|
|
}),
|
2022-06-21 11:06:06 +08:00
|
|
|
),
|
2022-03-09 15:33:39 +08:00
|
|
|
{
|
|
|
|
[treeCls]: {
|
|
|
|
borderRadius: 0,
|
2023-07-07 18:58:20 +08:00
|
|
|
[`${treeCls}-list-holder-inner`]: {
|
2022-03-09 15:33:39 +08:00
|
|
|
alignItems: 'stretch',
|
|
|
|
|
|
|
|
[`${treeCls}-treenode`]: {
|
|
|
|
[`${treeCls}-node-content-wrapper`]: {
|
|
|
|
flex: 'auto',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
// ==================== Checkbox ====================
|
2022-04-21 02:06:22 +08:00
|
|
|
getCheckboxStyle(`${treePrefixCls}-checkbox`, token),
|
2022-03-09 15:33:39 +08:00
|
|
|
|
|
|
|
// ====================== RTL =======================
|
|
|
|
{
|
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
|
|
|
|
[`${treeCls}-switcher${treeCls}-switcher_close`]: {
|
|
|
|
[`${treeCls}-switcher-icon svg`]: {
|
|
|
|
transform: 'rotate(90deg)',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-11-14 19:17:23 +08:00
|
|
|
export const prepareComponentToken: GetDefaultToken<'TreeSelect'> = initComponentToken;
|
|
|
|
|
2022-03-09 15:33:39 +08:00
|
|
|
// ============================== Export ==============================
|
2023-11-29 17:23:45 +08:00
|
|
|
export default function useTreeSelectStyle(
|
|
|
|
prefixCls: string,
|
|
|
|
treePrefixCls: string,
|
|
|
|
rootCls: string,
|
|
|
|
) {
|
|
|
|
return genStyleHooks(
|
2023-08-18 10:23:57 +08:00
|
|
|
'TreeSelect',
|
|
|
|
(token) => {
|
|
|
|
const treeSelectToken = mergeToken<TreeSelectToken>(token, { treePrefixCls });
|
|
|
|
return [genBaseStyle(treeSelectToken)];
|
|
|
|
},
|
|
|
|
initComponentToken,
|
2023-11-29 17:23:45 +08:00
|
|
|
)(prefixCls, rootCls);
|
2022-03-09 15:33:39 +08:00
|
|
|
}
|