Skip to content

Commit

Permalink
chore(useUI): add option to force appConfig merge
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Oct 12, 2023
1 parent 3ae78aa commit 0bd12fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runtime/composables/useUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ 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()

const ui = computed(() => {
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 || {}
)
})
Expand Down

1 comment on commit 0bd12fd

@vercel
Copy link

@vercel vercel bot commented on 0bd12fd Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui.nuxt.com
ui-git-dev-nuxt-js.vercel.app
ui-nuxt-js.vercel.app

Please sign in to comment.