11import { type MaybeRef , type Ref , ref , toRef } from "vue" ;
2+ import { getSortable } from "./helpers/get-sortable" ;
23
34/**
45 * @public
@@ -14,6 +15,7 @@ export interface TableColumnBase {
1415 header : string | Readonly < Ref < string > > ;
1516 description ?: string | Readonly < Ref < string | null > > ;
1617 size ?: TableColumnSize | Readonly < Ref < TableColumnSize | null > > ;
18+ sort ?: boolean ;
1719 enabled ?: MaybeRef < boolean > ;
1820}
1921
@@ -41,30 +43,33 @@ export type OmittedNormalizedColumnProperties =
4143 | "id"
4244 | "header"
4345 | "description"
46+ | "sortable"
4447 | "size"
4548 | "component"
4649 | "enabled" ;
4750
4851/**
4952 * @internal
5053 */
51- export function normalizeBaseColumn (
52- column : TableColumnBase ,
54+ export function normalizeBaseColumn < K = never > (
55+ column : TableColumnBase & { sort ?: boolean ; key ?: K } ,
5356) : Pick <
54- NormalizedTableColumnBase < unknown > ,
55- Exclude < OmittedNormalizedColumnProperties , "component" >
57+ NormalizedTableColumnBase < K > ,
58+ "id" | "header" | "description" | "size" | "enabled" | "sortable"
5659> {
5760 const id = Symbol ( ) ;
5861 const header = toRef ( column . header ) ;
5962 const description =
6063 column . description !== undefined ? toRef ( column . description ) : ref ( "" ) ;
6164 const size : Readonly < Ref < TableColumnSize | null > > =
6265 column . size !== undefined ? toRef ( column . size ) : ref ( "grow" ) ;
66+ const sortable = getSortable ( column ) ;
6367
6468 return {
6569 id,
6670 header,
6771 description,
72+ sortable,
6873 size,
6974 enabled : column . enabled ?? true ,
7075 } ;
0 commit comments