import type { ComputedRef, UnwrapRef } from 'vue'; import { computed, inject, provide } from 'vue'; import type { ConfigProviderProps, SizeType } from '../../config-provider'; import { defaultConfigProvider } from '../../config-provider'; const sizeProvider = Symbol('SizeProvider'); const useProvideSize = (props: Record): ComputedRef => { const configProvider = inject>( 'configProvider', defaultConfigProvider, ); const size = computed(() => props.size || configProvider.componentSize); provide(sizeProvider, size); return size; }; const useInjectSize = (props?: Record): ComputedRef => { const size: ComputedRef = props ? computed(() => props.size) : inject( sizeProvider, computed(() => 'default' as unknown as T), ); return size; }; export { useInjectSize, sizeProvider, useProvideSize }; export default useProvideSize;