|
2 | 2 |
|
3 | 3 | import { cn } from "../../../../lib/utils"; |
4 | 4 | import { Table } from "../../table"; |
| 5 | +import { Tooltip } from "../../tooltip"; |
5 | 6 | import type { Column, Columns, SortableType } from "../types"; |
6 | 7 | import { ButtonSort } from "./button-sort"; |
7 | 8 |
|
8 | 9 | type ColumnDefaultProps<C extends Columns> = SortableType<C> & { |
9 | | - column: Column; |
| 10 | + column: Column; |
10 | 11 | }; |
11 | 12 |
|
12 | 13 | export function ColumnItem<C extends Columns>({ |
13 | | - column, |
14 | | - sortable, |
| 14 | + column, |
| 15 | + sortable, |
15 | 16 | }: ColumnDefaultProps<C>) { |
16 | | - return ( |
17 | | - <Table.Head key={column.id} className={column.className}> |
18 | | - <div |
19 | | - className={cn( |
20 | | - "flex space-x-1 items-center", |
21 | | - column.position && `justify-${column.position}` |
22 | | - )} |
23 | | - > |
24 | | - <div className="text-xs">{column.title}</div> |
25 | | - {sortable?.cols.includes(column.id) && ( |
26 | | - <ButtonSort |
27 | | - columnId={column.id} |
28 | | - sortBy={sortable.sortBy} |
29 | | - sortDirection={sortable.sortDirection} |
30 | | - onSort={sortable.onSort} |
31 | | - /> |
32 | | - )} |
33 | | - </div> |
34 | | - </Table.Head> |
35 | | - ); |
| 17 | + return ( |
| 18 | + <Table.Head key={column.id} className={column.className}> |
| 19 | + <div |
| 20 | + className={cn( |
| 21 | + "flex space-x-1 items-center", |
| 22 | + column.position && `justify-${column.position}`, |
| 23 | + )} |
| 24 | + > |
| 25 | + <div className="text-xs">{column.title}</div> |
| 26 | + |
| 27 | + {column.tooltip && ( |
| 28 | + <Tooltip.Provider skipDelayDuration={0} delayDuration={0}> |
| 29 | + <Tooltip.Root> |
| 30 | + <Tooltip.Trigger>{column.tooltip.trigger}</Tooltip.Trigger> |
| 31 | + <Tooltip.Content side={column.tooltip.side}> |
| 32 | + {column.tooltip.content} |
| 33 | + </Tooltip.Content> |
| 34 | + </Tooltip.Root> |
| 35 | + </Tooltip.Provider> |
| 36 | + )} |
| 37 | + |
| 38 | + {sortable?.cols.includes(column.id) && ( |
| 39 | + <ButtonSort |
| 40 | + columnId={column.id} |
| 41 | + sortBy={sortable.sortBy} |
| 42 | + sortDirection={sortable.sortDirection} |
| 43 | + onSort={sortable.onSort} |
| 44 | + /> |
| 45 | + )} |
| 46 | + </div> |
| 47 | + </Table.Head> |
| 48 | + ); |
36 | 49 | } |
0 commit comments