Skip to content

Commit

Permalink
fix(types): inherit parent component prop types
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Sep 19, 2022
1 parent b2619ff commit 1a33712
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 18 deletions.
11 changes: 6 additions & 5 deletions packages/vuetify/src/components/VAutocomplete/VAutocomplete.tsx
Expand Up @@ -24,6 +24,7 @@ import { genericComponent, useRender, wrapInArray } from '@/util'

// Types
import type { FilterMatch } from '@/composables/filter'
import type { InternalItem } from '@/composables/items'
import type { MakeSlots } from '@/util'
import type { VFieldSlots } from '@/components/VField/VField'
import type { VInputSlots } from '@/components/VInput/VInput'
Expand Down Expand Up @@ -65,11 +66,11 @@ export const VAutocomplete = genericComponent<new <
multiple?: Multiple
modelValue?: Readonly<V>
'onUpdate:modelValue'?: (val: V) => void
}
} & Omit<VTextField['$props'], 'modelValue' | 'onUpdate:modelValue'>
$slots: Omit<VInputSlots & VFieldSlots, 'default'> & MakeSlots<{
item: [{ item: T, index: number, props: Record<string, unknown> }]
chip: [{ item: T, index: number, props: Record<string, unknown> }]
selection: [{ item: T, index: number }]
item: [{ item: InternalItem<T>, index: number, props: Record<string, unknown> }]
chip: [{ item: InternalItem<T>, index: number, props: Record<string, unknown> }]
selection: [{ item: InternalItem<T>, index: number }]
'no-data': []
}>
}>()({
Expand Down Expand Up @@ -160,7 +161,7 @@ export const VAutocomplete = genericComponent<new <

const isSelecting = ref(false)

function select (item: any) {
function select (item: InternalItem) {
if (props.multiple) {
const index = selected.value.findIndex(selection => selection === item.value)

Expand Down
8 changes: 4 additions & 4 deletions packages/vuetify/src/components/VCombobox/VCombobox.tsx
Expand Up @@ -68,11 +68,11 @@ export const VCombobox = genericComponent<new <
multiple?: Multiple
modelValue?: Readonly<V>
'onUpdate:modelValue'?: (val: V) => void
}
} & Omit<VTextField['$props'], 'modelValue' | 'onUpdate:modelValue'>
$slots: Omit<VInputSlots & VFieldSlots, 'default'> & MakeSlots<{
item: [{ item: T, index: number, props: Record<string, unknown> }]
chip: [{ item: T, index: number, props: Record<string, unknown> }]
selection: [{ item: T, index: number }]
item: [{ item: InternalItem<T>, index: number, props: Record<string, unknown> }]
chip: [{ item: InternalItem<T>, index: number, props: Record<string, unknown> }]
selection: [{ item: InternalItem<T>, index: number }]
'no-data': []
}>
}>()({
Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VDialog/VDialog.tsx
Expand Up @@ -21,6 +21,7 @@ import type { OverlaySlots } from '@/components/VOverlay/VOverlay'

export const VDialog = genericComponent<new () => {
$slots: OverlaySlots
$props: VOverlay['$props']
}>()({
name: 'VDialog',

Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VMenu/VMenu.tsx
Expand Up @@ -22,6 +22,7 @@ import type { OverlaySlots } from '@/components/VOverlay/VOverlay'

export const VMenu = genericComponent<new () => {
$slots: OverlaySlots
$props: VOverlay['$props']
}>()({
name: 'VMenu',

Expand Down
8 changes: 4 additions & 4 deletions packages/vuetify/src/components/VSelect/VSelect.tsx
Expand Up @@ -81,11 +81,11 @@ export const VSelect = genericComponent<new <
multiple?: Multiple
modelValue?: Readonly<V>
'onUpdate:modelValue'?: (val: V) => void
}
} & Omit<VTextField['$props'], 'modelValue' | 'onUpdate:modelValue'>
$slots: Omit<VInputSlots & VFieldSlots, 'default'> & MakeSlots<{
item: [{ item: T, index: number, props: Record<string, unknown> }]
chip: [{ item: T, index: number, props: Record<string, unknown> }]
selection: [{ item: T, index: number }]
item: [{ item: InternalItem<T>, index: number, props: Record<string, unknown> }]
chip: [{ item: InternalItem<T>, index: number, props: Record<string, unknown> }]
selection: [{ item: InternalItem<T>, index: number }]
'no-data': []
}>
}>()({
Expand Down
16 changes: 13 additions & 3 deletions packages/vuetify/src/components/VSnackbar/VSnackbar.tsx
Expand Up @@ -17,9 +17,19 @@ import { forwardRefs } from '@/composables/forwardRefs'

// Utilities
import { onMounted, ref, watch } from 'vue'
import { defineComponent, useRender } from '@/util'

export const VSnackbar = defineComponent({
import { genericComponent, useRender } from '@/util'

// Types
import type { MakeSlots } from '@/util'

export const VSnackbar = genericComponent<new () => {
$slots: MakeSlots<{
activator: [{ isActive: boolean, props: Record<string, any> }]
default: []
actions: []
}>
$props: VOverlay['$props']
}>()({
name: 'VSnackbar',

props: {
Expand Down
1 change: 1 addition & 0 deletions packages/vuetify/src/components/VTooltip/VTooltip.tsx
Expand Up @@ -21,6 +21,7 @@ import type { StrategyProps } from '@/components/VOverlay/locationStrategies'

export const VTooltip = genericComponent<new () => {
$slots: OverlaySlots
$props: VOverlay['$props']
}>()({
name: 'VTooltip',

Expand Down
4 changes: 2 additions & 2 deletions packages/vuetify/src/composables/items.ts
Expand Up @@ -6,7 +6,7 @@ import { getPropertyFromItem, pick, propsFactory } from '@/util'
import type { PropType } from 'vue'
import type { SelectItemKey } from '@/util'

export interface InternalItem {
export interface InternalItem<T = any> {
title: string
value: any
props: {
Expand All @@ -15,7 +15,7 @@ export interface InternalItem {
value: any
}
children?: InternalItem[]
raw: any
raw: T
}

export interface ItemProps {
Expand Down

0 comments on commit 1a33712

Please sign in to comment.