mirror of
https://github.com/antd-tiny-vue/antd-tiny-vue.git
synced 2025-03-15 15:05:11 +08:00
34 lines
892 B
TypeScript
34 lines
892 B
TypeScript
import { computed, inject, provide } from 'vue'
|
|
|
|
export const defaultIconPrefixCls = 'anticon'
|
|
|
|
const defaultGetPrefixCls = (suffixCls?: string, customizePrefixCls?: string) => {
|
|
if (customizePrefixCls) return customizePrefixCls
|
|
|
|
return suffixCls ? `ant-${suffixCls}` : 'ant'
|
|
}
|
|
|
|
export const ConfigProviderContext = Symbol('ConfigProviderContext')
|
|
|
|
export const defaultConfigProviderState = () => {
|
|
const getPrefixCls = defaultGetPrefixCls
|
|
const iconPrefixCls = computed(() => defaultIconPrefixCls)
|
|
return {
|
|
getPrefixCls,
|
|
iconPrefixCls
|
|
}
|
|
}
|
|
|
|
const useProviderConfigProvide = () => {
|
|
const defaultState = defaultConfigProviderState()
|
|
provide(ConfigProviderContext, defaultState)
|
|
return {
|
|
...defaultState
|
|
}
|
|
}
|
|
|
|
export { useProviderConfigProvide }
|
|
export const useProviderConfigState = () => {
|
|
return inject(ConfigProviderContext, defaultConfigProviderState())
|
|
}
|