feat(types): support custom values from app.config.ts (#863)

This commit is contained in:
Benjamin Canac
2023-11-17 18:48:50 +01:00
committed by GitHub
parent bcc46b87f5
commit 7339324355
26 changed files with 132 additions and 57 deletions

View File

@@ -39,12 +39,11 @@ import UIcon from '../elements/Icon.vue'
import UAvatar from '../elements/Avatar.vue'
import UButton from '../elements/Button.vue'
import { useUI } from '../../composables/useUI'
import type { Avatar, Button, NestedKeyOf, Strategy } from '../../types'
import type { Avatar, Button, AlertColor, AlertVariant, Strategy } from '../../types'
import { mergeConfig } from '../../utils'
// @ts-expect-error
import appConfig from '#build/app.config'
import { alert } from '#ui/ui.config'
import colors from '#ui-colors'
const config = mergeConfig<typeof alert>(appConfig.ui.strategy, appConfig.ui.alert, alert)
@@ -81,14 +80,14 @@ export default defineComponent({
default: () => []
},
color: {
type: String as PropType<keyof typeof config.color | typeof colors[number]>,
type: String as PropType<AlertColor>,
default: () => config.default.color,
validator (value: string) {
return [...appConfig.ui.colors, ...Object.keys(config.color)].includes(value)
}
},
variant: {
type: String as PropType<keyof typeof config.variant | NestedKeyOf<typeof config.color>>,
type: String as PropType<AlertVariant>,
default: () => config.default.variant,
validator (value: string) {
return [

View File

@@ -17,7 +17,7 @@ export default defineComponent({
inheritAttrs: false,
props: {
size: {
type: String as PropType<keyof typeof avatarConfig.size>,
type: String as PropType<AvatarSize>,
default: null,
validator (value: string) {
return Object.keys(avatarConfig.size).includes(value)

View File

@@ -10,7 +10,7 @@ import type { PropType } from 'vue'
import { twMerge, twJoin } from 'tailwind-merge'
import { useUI } from '../../composables/useUI'
import { mergeConfig } from '../../utils'
import type { Strategy } from '../../types'
import type { KbdSize, Strategy } from '../../types'
// @ts-expect-error
import appConfig from '#build/app.config'
import { kbd } from '#ui/ui.config'
@@ -25,7 +25,7 @@ export default defineComponent({
default: null
},
size: {
type: String as PropType<keyof typeof config.size>,
type: String as PropType<KbdSize>,
default: () => config.default.size,
validator (value: string) {
return Object.keys(config.size).includes(value)