mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-18 05:58:07 +01:00
feat(module)!: use tailwind-merge for app.config & move config to components & type props (#692)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
This commit is contained in:
24
src/runtime/composables/useUI.ts
Normal file
24
src/runtime/composables/useUI.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { computed, toValue, useAttrs } from 'vue'
|
||||
import { useAppConfig } from '#imports'
|
||||
import { mergeConfig, omit } from '../utils'
|
||||
import { Strategy } from '../types'
|
||||
|
||||
export const useUI = <T>(key, $ui: Partial<T & { strategy: Strategy }>, $config?: T, { mergeWrapper = false }: { mergeWrapper?: boolean } = {}) => {
|
||||
const $attrs = useAttrs()
|
||||
const appConfig = useAppConfig()
|
||||
|
||||
const ui = computed(() => mergeConfig<T>(
|
||||
$ui?.strategy || (appConfig.ui?.strategy as Strategy),
|
||||
mergeWrapper ? { wrapper: $attrs?.class } : {},
|
||||
$ui || {},
|
||||
process.dev ? (appConfig.ui[key] || {}) : {},
|
||||
toValue($config || {})
|
||||
))
|
||||
const attrs = computed(() => omit($attrs, ['class']))
|
||||
|
||||
return {
|
||||
ui,
|
||||
attrs,
|
||||
attrsClass: mergeWrapper ? undefined : $attrs?.class as string
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user