2021-05-12 21:06:53 +08:00
|
|
|
import { computed, ComputedRef, inject, UnwrapRef } from 'vue';
|
|
|
|
import {
|
|
|
|
ConfigProviderProps,
|
|
|
|
defaultConfigProvider,
|
|
|
|
Direction,
|
|
|
|
SizeType,
|
|
|
|
} from '../../config-provider';
|
2021-03-16 12:54:22 +08:00
|
|
|
|
2021-05-12 21:06:53 +08:00
|
|
|
export default (
|
|
|
|
name: string,
|
|
|
|
props: Record<any, any>,
|
|
|
|
): {
|
|
|
|
configProvider: UnwrapRef<ConfigProviderProps>;
|
|
|
|
prefixCls: ComputedRef<string>;
|
|
|
|
direction: ComputedRef<Direction>;
|
|
|
|
size: ComputedRef<SizeType>;
|
|
|
|
} => {
|
|
|
|
const configProvider = inject<UnwrapRef<ConfigProviderProps>>(
|
|
|
|
'configProvider',
|
|
|
|
defaultConfigProvider,
|
|
|
|
);
|
2021-03-16 12:54:22 +08:00
|
|
|
const prefixCls = computed(() => configProvider.getPrefixCls(name, props.prefixCls));
|
2021-05-12 21:06:53 +08:00
|
|
|
const direction = computed(() => configProvider.direction);
|
|
|
|
const size = computed(() => props.size || configProvider.componentSize);
|
|
|
|
return { configProvider, prefixCls, direction, size };
|
2021-03-16 12:54:22 +08:00
|
|
|
};
|