ant-design/components/cascader/hooks/useBase.ts

26 lines
763 B
TypeScript
Raw Normal View History

import * as React from 'react';
import { ConfigContext } from '../../config-provider';
2024-07-29 01:30:35 +08:00
import type { DirectionType, RenderEmptyHandler } from '../../config-provider';
2024-07-29 01:30:35 +08:00
function useBase(
customizePrefixCls?: string,
2024-07-29 01:30:35 +08:00
direction?: DirectionType,
): [
prefixCls: string,
cascaderPrefixCls: string,
2024-07-29 01:30:35 +08:00
direction?: DirectionType,
renderEmpty?: RenderEmptyHandler,
] {
const { getPrefixCls, direction: rootDirection, renderEmpty } = React.useContext(ConfigContext);
const mergedDirection = direction || rootDirection;
const prefixCls = getPrefixCls('select', customizePrefixCls);
const cascaderPrefixCls = getPrefixCls('cascader', customizePrefixCls);
return [prefixCls, cascaderPrefixCls, mergedDirection, renderEmpty];
}
2024-07-29 01:30:35 +08:00
export default useBase;