2021-06-26 09:35:40 +08:00
|
|
|
import type { RequiredMark } from '../../form/Form';
|
|
|
|
import type { ComputedRef, UnwrapRef, VNodeChild } from 'vue';
|
|
|
|
import { computed, inject } from 'vue';
|
|
|
|
import type { ConfigProviderProps, Direction, SizeType } from '../../config-provider';
|
|
|
|
import { defaultConfigProvider } 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>;
|
2021-05-24 18:09:11 +08:00
|
|
|
getTargetContainer: ComputedRef<() => HTMLElement>;
|
2021-05-26 17:31:16 +08:00
|
|
|
space: ComputedRef<{ size: SizeType | number }>;
|
2021-05-26 23:14:00 +08:00
|
|
|
pageHeader: ComputedRef<{ ghost: boolean }>;
|
2021-05-28 17:31:15 +08:00
|
|
|
form?: ComputedRef<{
|
|
|
|
requiredMark?: RequiredMark;
|
|
|
|
}>;
|
2021-06-30 10:03:17 +08:00
|
|
|
autoInsertSpaceInButton: ComputedRef<Boolean>;
|
2021-06-23 14:44:21 +08:00
|
|
|
renderEmpty?: ComputedRef<(componentName?: string) => VNodeChild | JSX.Element>;
|
2021-05-12 21:06:53 +08:00
|
|
|
} => {
|
|
|
|
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);
|
2021-06-30 10:03:17 +08:00
|
|
|
const autoInsertSpaceInButton = computed(() => configProvider.autoInsertSpaceInButton);
|
2021-06-23 14:44:21 +08:00
|
|
|
const renderEmpty = computed(() => configProvider.renderEmpty);
|
2021-05-26 17:31:16 +08:00
|
|
|
const space = computed(() => configProvider.space);
|
2021-05-26 23:14:00 +08:00
|
|
|
const pageHeader = computed(() => configProvider.pageHeader);
|
2021-05-28 17:31:15 +08:00
|
|
|
const form = computed(() => configProvider.form);
|
2021-05-12 21:06:53 +08:00
|
|
|
const size = computed(() => props.size || configProvider.componentSize);
|
2021-05-24 18:09:11 +08:00
|
|
|
const getTargetContainer = computed(() => props.getTargetContainer);
|
2021-05-28 17:31:15 +08:00
|
|
|
return {
|
|
|
|
configProvider,
|
|
|
|
prefixCls,
|
|
|
|
direction,
|
|
|
|
size,
|
|
|
|
getTargetContainer,
|
|
|
|
space,
|
|
|
|
pageHeader,
|
|
|
|
form,
|
2021-06-30 10:03:17 +08:00
|
|
|
autoInsertSpaceInButton,
|
2021-06-23 14:44:21 +08:00
|
|
|
renderEmpty,
|
2021-05-28 17:31:15 +08:00
|
|
|
};
|
2021-03-16 12:54:22 +08:00
|
|
|
};
|