fix(components): declare ui prop with PartialString when arrays in theme slots

This commit is contained in:
Benjamin Canac
2024-07-02 15:02:29 +02:00
parent 52146dc260
commit 5cc4457a74
8 changed files with 18 additions and 12 deletions

View File

@@ -5,6 +5,7 @@ import _appConfig from '#build/app.config'
import theme from '#build/ui/button'
import type { LinkProps } from './Link.vue'
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
import type { PartialString } from '../types/utils'
const appConfig = _appConfig as AppConfig & { ui: { button: Partial<typeof theme> } }
@@ -22,7 +23,7 @@ export interface ButtonProps extends UseComponentIconsProps, Omit<LinkProps, 'ra
/** Render the button full width. */
block?: boolean
class?: any
ui?: Partial<typeof button.slots>
ui?: PartialString<typeof button.slots>
}
export interface ButtonSlots {

View File

@@ -8,7 +8,7 @@ import _appConfig from '#build/app.config'
import theme from '#build/ui/command-palette'
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
import type { AvatarProps, ButtonProps, ChipProps, KbdProps, InputProps } from '../types'
import type { DynamicSlots } from '../types/utils'
import type { DynamicSlots, PartialString } from '../types/utils'
const appConfig = _appConfig as AppConfig & { ui: { commandPalette: Partial<typeof theme> } }
@@ -75,7 +75,7 @@ export interface CommandPaletteProps<G, T> extends Pick<ComboboxRootProps, 'mult
*/
fuse?: UseFuseOptions<T>
class?: any
ui?: Partial<typeof commandPalette.slots>
ui?: PartialString<typeof commandPalette.slots>
}
export type CommandPaletteEmits<T> = ComboboxRootEmits<T>

View File

@@ -7,7 +7,7 @@ import _appConfig from '#build/app.config'
import theme from '#build/ui/input-menu'
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
import type { AvatarProps, ChipProps, InputProps } from '../types'
import type { AcceptableValue, ArrayOrWrapped } from '../types/utils'
import type { AcceptableValue, ArrayOrWrapped, PartialString } from '../types/utils'
const appConfig = _appConfig as AppConfig & { ui: { inputMenu: Partial<typeof theme> } }
@@ -82,7 +82,7 @@ export interface InputMenuProps<T> extends Pick<ComboboxRootProps<T>, 'modelValu
filter?: boolean | string[]
items?: T[] | T[][]
class?: any
ui?: Partial<typeof inputMenu.slots>
ui?: PartialString<typeof inputMenu.slots>
}
export type InputMenuEmits<T> = ComboboxRootEmits<T> & {

View File

@@ -6,7 +6,7 @@ import _appConfig from '#build/app.config'
import theme from '#build/ui/select'
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
import type { AvatarProps, ChipProps, InputProps } from '../types'
import type { AcceptableValue } from '../types/utils'
import type { AcceptableValue, PartialString } from '../types/utils'
const appConfig = _appConfig as AppConfig & { ui: { select: Partial<typeof theme> } }
@@ -60,7 +60,7 @@ export interface SelectProps<T> extends Omit<SelectRootProps, 'dir'>, UseCompone
portal?: boolean
items?: T[] | T[][]
class?: any
ui?: Partial<typeof select.slots>
ui?: PartialString<typeof select.slots>
}
export type SelectEmits = SelectRootEmits & {

View File

@@ -6,7 +6,7 @@ import _appConfig from '#build/app.config'
import theme from '#build/ui/select-menu'
import type { UseComponentIconsProps } from '../composables/useComponentIcons'
import type { AvatarProps, ChipProps, InputProps } from '../types'
import type { AcceptableValue, ArrayOrWrapped } from '../types/utils'
import type { AcceptableValue, ArrayOrWrapped, PartialString } from '../types/utils'
const appConfig = _appConfig as AppConfig & { ui: { selectMenu: Partial<typeof theme> } }
@@ -69,7 +69,7 @@ export interface SelectMenuProps<T> extends Pick<ComboboxRootProps<T>, 'modelVal
filter?: boolean | string[]
items?: T[] | T[][]
class?: any
ui?: Partial<typeof selectMenu.slots>
ui?: PartialString<typeof selectMenu.slots>
}
export type SelectMenuEmits<T> = ComboboxRootEmits<T> & {

View File

@@ -4,6 +4,7 @@ import type { SwitchRootProps } from 'radix-vue'
import type { AppConfig } from '@nuxt/schema'
import _appConfig from '#build/app.config'
import theme from '#build/ui/switch'
import type { PartialString } from '../types/utils'
const appConfig = _appConfig as AppConfig & { ui: { switch: Partial<typeof theme> } }
@@ -35,7 +36,7 @@ export interface SwitchProps extends Pick<SwitchRootProps, 'disabled' | 'id' | '
/** The state of the switch when it is initially rendered. Use when you do not need to control its state. */
defaultValue?: boolean
class?: any
ui?: Partial<typeof switchTv.slots>
ui?: PartialString<typeof switchTv.slots>
}
export interface SwitchEmits {

View File

@@ -5,7 +5,7 @@ import type { AppConfig } from '@nuxt/schema'
import _appConfig from '#build/app.config'
import theme from '#build/ui/tabs'
import type { AvatarProps } from '../types'
import type { DynamicSlots } from '../types/utils'
import type { DynamicSlots, PartialString } from '../types/utils'
const appConfig = _appConfig as AppConfig & { ui: { tabs: Partial<typeof theme> } }
@@ -42,7 +42,7 @@ export interface TabsProps<T> extends Pick<TabsRootProps, 'defaultValue' | 'mode
*/
content?: boolean | Omit<TabsContentProps, 'as' | 'asChild' | 'value'>
class?: any
ui?: Partial<typeof tabs.slots>
ui?: PartialString<typeof tabs.slots>
}
export interface TabsEmits extends TabsRootEmits {}

View File

@@ -12,3 +12,7 @@ export type GetObjectField<MaybeObject, Key extends string> = MaybeObject extend
export type AcceptableValue = string | number | boolean | Record<string, any>
export type ArrayOrWrapped<T> = T extends any[] ? T : Array<T>
export type PartialString<T> = {
[K in keyof T]?: string
}