mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
chore(useUI): add option to force appConfig merge
This commit is contained in:
@@ -4,7 +4,7 @@ import { useAppConfig } from '#imports'
|
||||
import { mergeConfig, omit, get } from '../utils'
|
||||
import { Strategy } from '../types'
|
||||
|
||||
export const useUI = <T>(key, $ui: Ref<Partial<T & { strategy: Strategy }> | undefined>, $config?: Ref<T> | T, $wrapperClass?: Ref<string>) => {
|
||||
export const useUI = <T>(key, $ui: Ref<Partial<T & { strategy: Strategy }> | undefined>, $config?: Ref<T> | T, $wrapperClass?: Ref<string>, withAppConfig: boolean = false) => {
|
||||
const $attrs = useAttrs()
|
||||
const appConfig = useAppConfig()
|
||||
|
||||
@@ -12,11 +12,12 @@ export const useUI = <T>(key, $ui: Ref<Partial<T & { strategy: Strategy }> | und
|
||||
const _ui = toValue($ui)
|
||||
const _config = toValue($config)
|
||||
const _wrapperClass = toValue($wrapperClass)
|
||||
|
||||
return mergeConfig<T>(
|
||||
_ui?.strategy || (appConfig.ui?.strategy as Strategy),
|
||||
_wrapperClass ? { wrapper: _wrapperClass } : {},
|
||||
_ui || {},
|
||||
process.dev ? get(appConfig.ui, key, {}) : {},
|
||||
(process.dev || withAppConfig) ? get(appConfig.ui, key, {}) : {},
|
||||
_config || {}
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user