mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
type: code optimization (#50116)
This commit is contained in:
parent
525e33737d
commit
836d1bbbad
@ -3,11 +3,7 @@ import LeftOutlined from '@ant-design/icons/LeftOutlined';
|
||||
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
|
||||
import RightOutlined from '@ant-design/icons/RightOutlined';
|
||||
|
||||
export default function useColumnIcons(
|
||||
prefixCls: string,
|
||||
rtl: boolean,
|
||||
expandIcon?: React.ReactNode,
|
||||
) {
|
||||
const useColumnIcons = (prefixCls: string, rtl: boolean, expandIcon?: React.ReactNode) => {
|
||||
let mergedExpandIcon = expandIcon;
|
||||
if (!expandIcon) {
|
||||
mergedExpandIcon = rtl ? <LeftOutlined /> : <RightOutlined />;
|
||||
@ -19,5 +15,10 @@ export default function useColumnIcons(
|
||||
</span>
|
||||
);
|
||||
|
||||
return [mergedExpandIcon, loadingIcon];
|
||||
}
|
||||
return React.useMemo<Readonly<[React.ReactNode, React.ReactNode]>>(
|
||||
() => [mergedExpandIcon, loadingIcon] as const,
|
||||
[mergedExpandIcon],
|
||||
);
|
||||
};
|
||||
|
||||
export default useColumnIcons;
|
||||
|
@ -1,22 +1,14 @@
|
||||
import { useContext } from 'react';
|
||||
import { genStyleUtils } from '@ant-design/cssinjs-utils';
|
||||
import type { GetCompUnitless } from '@ant-design/cssinjs-utils/es/util/genStyleUtils';
|
||||
|
||||
import { ConfigContext } from '../../config-provider/context';
|
||||
import { genCommonStyle, genLinkStyle } from '../../style';
|
||||
import type {
|
||||
AliasToken,
|
||||
ComponentTokenMap,
|
||||
SeedToken,
|
||||
} from '../interface';
|
||||
|
||||
import localUseToken, { unitless } from '../useToken';
|
||||
import type { AliasToken, ComponentTokenMap, SeedToken } from '../interface';
|
||||
import useLocalToken, { unitless } from '../useToken';
|
||||
import useResetIconStyle from './useResetIconStyle';
|
||||
|
||||
export const {
|
||||
genStyleHooks,
|
||||
genComponentStyleHook,
|
||||
genSubStyleComponent,
|
||||
} = genStyleUtils<
|
||||
export const { genStyleHooks, genComponentStyleHook, genSubStyleComponent } = genStyleUtils<
|
||||
ComponentTokenMap,
|
||||
AliasToken,
|
||||
SeedToken
|
||||
@ -29,18 +21,11 @@ export const {
|
||||
return {
|
||||
rootPrefixCls,
|
||||
iconPrefixCls,
|
||||
}
|
||||
};
|
||||
},
|
||||
useToken: () => {
|
||||
const [theme, realToken, hashId, token, cssVar] = localUseToken();
|
||||
|
||||
return {
|
||||
theme,
|
||||
realToken,
|
||||
hashId,
|
||||
token,
|
||||
cssVar,
|
||||
};
|
||||
const [theme, realToken, hashId, token, cssVar] = useLocalToken();
|
||||
return { theme, realToken, hashId, token, cssVar };
|
||||
},
|
||||
useCSP: () => {
|
||||
const { csp, iconPrefixCls } = useContext(ConfigContext);
|
||||
@ -50,14 +35,7 @@ export const {
|
||||
|
||||
return csp ?? {};
|
||||
},
|
||||
getResetStyles: (token) =>
|
||||
[
|
||||
{
|
||||
// Link
|
||||
'&': genLinkStyle(token),
|
||||
},
|
||||
]
|
||||
,
|
||||
getResetStyles: (token) => [{ '&': genLinkStyle(token) }],
|
||||
getCommonStyle: genCommonStyle,
|
||||
getCompUnitless: () => unitless as any,
|
||||
})
|
||||
getCompUnitless: (() => unitless) as GetCompUnitless<ComponentTokenMap, AliasToken>,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user