Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VDataTable): improve headers value function typing #18703

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/vuetify/src/components/VDataTable/VDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import { computed, toRef } from 'vue'
import { genericComponent, propsFactory, useRender } from '@/util'

// Types
import type { UnwrapRef } from 'vue'
import type { DeepReadonly, UnwrapRef } from 'vue'
import type { Group } from './composables/group'
import type { CellProps, DataTableItem, InternalDataTableHeader, RowProps } from './types'
import type { CellProps, DataTableHeader, DataTableItem, InternalDataTableHeader, RowProps } from './types'
import type { VDataTableHeadersSlots } from './VDataTableHeaders'
import type { VDataTableRowsSlots } from './VDataTableRows'
import type { GenericProps, SelectItemKey } from '@/util'
Expand Down Expand Up @@ -101,6 +101,7 @@ export const VDataTable = genericComponent<new <T extends readonly any[], V>(
rowProps?: RowProps<ItemType<T>>
cellProps?: CellProps<ItemType<T>>
itemSelectable?: SelectItemKey<ItemType<T>>
headers?: DeepReadonly<DataTableHeader<ItemType<T>>[]>
modelValue?: V
'onUpdate:modelValue'?: (value: V) => void
},
Expand Down
6 changes: 3 additions & 3 deletions packages/vuetify/src/components/VDataTable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import type { SelectItemKey } from '@/util'

export type DataTableCompareFunction<T = any> = (a: T, b: T) => number

export type DataTableHeader = {
export type DataTableHeader<T = Record<string, any>> = {
key?: 'data-table-group' | 'data-table-select' | 'data-table-expand' | (string & {})
value?: SelectItemKey
value?: SelectItemKey<T>
title?: string

fixed?: boolean
Expand All @@ -26,7 +26,7 @@ export type DataTableHeader = {
sort?: DataTableCompareFunction
filter?: FilterFunction

children?: DataTableHeader[]
children?: DataTableHeader<T>[]
}

export type InternalDataTableHeader = Omit<DataTableHeader, 'key' | 'value' | 'children'> & {
Expand Down