Skip to content

Commit

Permalink
fix(VDataIterator): generic slot types
Browse files Browse the repository at this point in the history
fixes #19285
  • Loading branch information
KaelWD committed Feb 29, 2024
1 parent 65aff8f commit 478ef31
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/vuetify/src/components/VDataIterator/VDataIterator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import { genericComponent, propsFactory, useRender } from '@/util'
import type { DataIteratorItem } from './composables/items'
import type { Group } from '@/components/VDataTable/composables/group'
import type { SortItem } from '@/components/VDataTable/composables/sort'
import type { GenericProps } from '@/util'

type VDataIteratorSlotProps = {
type VDataIteratorSlotProps<T> = {
page: number
itemsPerPage: number
sortBy: readonly SortItem[]
Expand All @@ -45,14 +46,14 @@ type VDataIteratorSlotProps = {
toggleExpand: ReturnType<typeof provideExpanded>['toggleExpand']
isGroupOpen: ReturnType<typeof provideGroupBy>['isGroupOpen']
toggleGroup: ReturnType<typeof provideGroupBy>['toggleGroup']
items: readonly DataIteratorItem[]
groupedItems: readonly (DataIteratorItem | Group<DataIteratorItem>)[]
items: readonly DataIteratorItem<T>[]
groupedItems: readonly (DataIteratorItem<T> | Group<DataIteratorItem<T>>)[]
}

export type VDataIteratorSlots = {
default: VDataIteratorSlotProps
header: VDataIteratorSlotProps
footer: VDataIteratorSlotProps
export type VDataIteratorSlots<T> = {
default: VDataIteratorSlotProps<T>
header: VDataIteratorSlotProps<T>
footer: VDataIteratorSlotProps<T>
'no-data': never
}

Expand All @@ -71,7 +72,12 @@ export const makeVDataIteratorProps = propsFactory({
...makeTagProps(),
}, 'VDataIterator')

export const VDataIterator = genericComponent<VDataIteratorSlots>()({
export const VDataIterator = genericComponent<new <T> (
props: {
items?: readonly T[]
},
slots: VDataIteratorSlots<T>,
) => GenericProps<typeof props, typeof slots>>()({
name: 'VDataIterator',

props: makeVDataIteratorProps(),
Expand Down

0 comments on commit 478ef31

Please sign in to comment.