2021-05-12 13:06:53 +00:00
|
|
|
import { computed, ComputedRef, inject, UnwrapRef } from 'vue';
|
|
|
|
import {
|
|
|
|
ConfigProviderProps,
|
|
|
|
defaultConfigProvider,
|
|
|
|
Direction,
|
|
|
|
SizeType,
|
|
|
|
} from '../../config-provider';
|
2021-03-16 04:54:22 +00:00
|
|
|
|
2021-05-12 13:06:53 +00:00
|
|
|
export default (
|
|
|
|
name: string,
|
|
|
|
props: Record<any, any>,
|
|
|
|
): {
|
|
|
|
configProvider: UnwrapRef<ConfigProviderProps>;
|
|
|
|
prefixCls: ComputedRef<string>;
|
|
|
|
direction: ComputedRef<Direction>;
|
|
|
|
size: ComputedRef<SizeType>;
|
2021-05-24 10:09:11 +00:00
|
|
|
getTargetContainer: ComputedRef<() => HTMLElement>;
|
2021-05-26 09:31:16 +00:00
|
|
|
space: ComputedRef<{ size: SizeType | number }>;
|
2021-05-26 15:14:00 +00:00
|
|
|
pageHeader: ComputedRef<{ ghost: boolean }>;
|
2021-05-12 13:06:53 +00:00
|
|
|
} => {
|
|
|
|
const configProvider = inject<UnwrapRef<ConfigProviderProps>>(
|
|
|
|
'configProvider',
|
|
|
|
defaultConfigProvider,
|
|
|
|
);
|
2021-03-16 04:54:22 +00:00
|
|
|
const prefixCls = computed(() => configProvider.getPrefixCls(name, props.prefixCls));
|
2021-05-12 13:06:53 +00:00
|
|
|
const direction = computed(() => configProvider.direction);
|
2021-05-26 09:31:16 +00:00
|
|
|
const space = computed(() => configProvider.space);
|
2021-05-26 15:14:00 +00:00
|
|
|
const pageHeader = computed(() => configProvider.pageHeader);
|
2021-05-12 13:06:53 +00:00
|
|
|
const size = computed(() => props.size || configProvider.componentSize);
|
2021-05-24 10:09:11 +00:00
|
|
|
const getTargetContainer = computed(() => props.getTargetContainer);
|
2021-05-26 15:14:00 +00:00
|
|
|
return { configProvider, prefixCls, direction, size, getTargetContainer, space, pageHeader };
|
2021-03-16 04:54:22 +00:00
|
|
|
};
|