2
2
3
3
import { IconChevronDown , IconChevronUp , IconHamburger } from "justd-icons"
4
4
import type {
5
- CellProps as CellPrimitiveProps ,
6
- ColumnProps as ColumnPrimitiveProps ,
7
- RowProps as RowPrimitiveProps ,
5
+ CellProps ,
6
+ ColumnProps ,
7
+ RowProps ,
8
8
TableBodyProps ,
9
- TableHeaderProps as TableHeaderPrimitiveProps ,
9
+ TableHeaderProps ,
10
10
TableProps as TablePrimitiveProps
11
11
} from "react-aria-components"
12
12
import {
13
13
Button ,
14
- Cell as CellPrimitive ,
14
+ Cell ,
15
15
Collection ,
16
- Column as ColumnPrimitive ,
17
- Row as RowPrimitive ,
16
+ Column ,
17
+ Row ,
18
18
Table as TablePrimitive ,
19
- TableBody as TableBodyPrimitive ,
19
+ TableBody ,
20
20
TableHeader ,
21
21
useTableOptions
22
22
} from "react-aria-components"
@@ -51,25 +51,25 @@ const Table = ({ children, className, ...props }: TableProps) => (
51
51
)
52
52
53
53
const Body = < T extends object > ( props : TableBodyProps < T > ) => (
54
- < TableBodyPrimitive { ...props } className = { cn ( "[&_.tr:last-child]:border-0" ) } />
54
+ < TableBody { ...props } className = { cn ( "[&_.tr:last-child]:border-0" ) } />
55
55
)
56
56
57
- interface CellProps extends CellPrimitiveProps {
57
+ interface TableCellProps extends CellProps {
58
58
className ?: string
59
59
}
60
60
61
- const Cell = ( { children, className, ...props } : CellProps ) => (
62
- < CellPrimitive { ...props } className = { cell ( { className } ) } >
61
+ const TableCell = ( { children, className, ...props } : TableCellProps ) => (
62
+ < Cell { ...props } className = { cell ( { className } ) } >
63
63
{ children }
64
- </ CellPrimitive >
64
+ </ Cell >
65
65
)
66
66
67
- interface ColumnProps extends ColumnPrimitiveProps {
67
+ interface TableColumnProps extends ColumnProps {
68
68
className ?: string
69
69
}
70
70
71
- const Column = ( { children, className, ...props } : ColumnProps ) => (
72
- < ColumnPrimitive { ...props } className = { column ( { className } ) } >
71
+ const TableColumn = ( { children, className, ...props } : TableColumnProps ) => (
72
+ < Column { ...props } className = { column ( { className } ) } >
73
73
{ ( { allowsSorting, sortDirection } ) => (
74
74
< div className = "flex [&>[data-slot=icon]]:shrink-0 items-center gap-2" >
75
75
< >
@@ -85,10 +85,10 @@ const Column = ({ children, className, ...props }: ColumnProps) => (
85
85
</ >
86
86
</ div >
87
87
) }
88
- </ ColumnPrimitive >
88
+ </ Column >
89
89
)
90
90
91
- interface HeaderProps < T extends object > extends TableHeaderPrimitiveProps < T > {
91
+ interface HeaderProps < T extends object > extends TableHeaderProps < T > {
92
92
className ?: string
93
93
}
94
94
@@ -107,14 +107,20 @@ const Header = <T extends object>({ children, className, columns, ...props }: He
107
107
)
108
108
}
109
109
110
- interface RowProps < T extends object > extends RowPrimitiveProps < T > {
110
+ interface TableRow < T extends object > extends RowProps < T > {
111
111
className ?: string
112
112
}
113
113
114
- const Row = < T extends object > ( { children, className, columns, id, ...props } : RowProps < T > ) => {
114
+ const TableRow = < T extends object > ( {
115
+ children,
116
+ className,
117
+ columns,
118
+ id,
119
+ ...props
120
+ } : TableRow < T > ) => {
115
121
const { selectionBehavior, allowsDragging } = useTableOptions ( )
116
122
return (
117
- < RowPrimitive
123
+ < Row
118
124
id = { id }
119
125
{ ...props }
120
126
className = { row ( {
@@ -141,14 +147,14 @@ const Row = <T extends object>({ children, className, columns, id, ...props }: R
141
147
</ Cell >
142
148
) }
143
149
< Collection items = { columns } > { children } </ Collection >
144
- </ RowPrimitive >
150
+ </ Row >
145
151
)
146
152
}
147
153
148
154
Table . Body = Body
149
- Table . Cell = Cell
150
- Table . Column = Column
155
+ Table . Cell = TableCell
156
+ Table . Column = TableColumn
151
157
Table . Header = Header
152
- Table . Row = Row
158
+ Table . Row = TableRow
153
159
154
160
export { Table }
0 commit comments