type: use DirectionType (#50117)

This commit is contained in:
lijianan 2024-07-29 01:30:35 +08:00 committed by GitHub
parent e8fa5938ab
commit 525e33737d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View File

@ -1,15 +1,15 @@
import * as React from 'react';
import { ConfigContext } from '../../config-provider';
import type { RenderEmptyHandler } from '../../config-provider';
import type { DirectionType, RenderEmptyHandler } from '../../config-provider';
export default function useBase(
function useBase(
customizePrefixCls?: string,
direction?: 'ltr' | 'rtl',
direction?: DirectionType,
): [
prefixCls: string,
cascaderPrefixCls: string,
direction?: 'ltr' | 'rtl',
direction?: DirectionType,
renderEmpty?: RenderEmptyHandler,
] {
const { getPrefixCls, direction: rootDirection, renderEmpty } = React.useContext(ConfigContext);
@ -21,3 +21,5 @@ export default function useBase(
return [prefixCls, cascaderPrefixCls, mergedDirection, renderEmpty];
}
export default useBase;

View File

@ -1,13 +1,15 @@
import React from 'react';
import type { DirectionType } from '../../config-provider';
export const offset = 4;
export default function dropIndicatorRender(props: {
function dropIndicatorRender(props: {
dropPosition: -1 | 0 | 1;
dropLevelOffset: number;
indent: number;
prefixCls: string;
direction: 'ltr' | 'rtl';
direction: DirectionType;
}) {
const { dropPosition, dropLevelOffset, prefixCls, indent, direction = 'ltr' } = props;
const startPosition = direction === 'ltr' ? 'left' : 'right';
@ -31,3 +33,5 @@ export default function dropIndicatorRender(props: {
}
return <div style={style} className={`${prefixCls}-drop-indicator`} />;
}
export default dropIndicatorRender;