mirror of
https://github.com/antd-tiny-vue/antd-tiny-vue.git
synced 2024-11-10 17:49:18 +08:00
29 lines
804 B
TypeScript
29 lines
804 B
TypeScript
import { createInjectionState } from '@vueuse/core'
|
|
import { computed } from 'vue'
|
|
|
|
export const defaultIconPrefixCls = 'anticon'
|
|
|
|
const defaultGetPrefixCls = (suffixCls?: string, customizePrefixCls?: string) => {
|
|
if (customizePrefixCls) return customizePrefixCls
|
|
|
|
return suffixCls ? `ant-${suffixCls}` : 'ant'
|
|
}
|
|
const [useProviderConfigProvide, useProviderConfigInject] = createInjectionState(() => {
|
|
const getPrefixCls = defaultGetPrefixCls
|
|
const iconPrefixCls = computed(() => defaultIconPrefixCls)
|
|
return {
|
|
getPrefixCls,
|
|
iconPrefixCls
|
|
}
|
|
})
|
|
|
|
export { useProviderConfigProvide }
|
|
export const useProviderConfigState = () => {
|
|
return (
|
|
useProviderConfigInject() ?? {
|
|
getPrefixCls: defaultGetPrefixCls,
|
|
iconPrefixCls: computed(() => defaultIconPrefixCls)
|
|
}
|
|
)
|
|
}
|