Skip to content

Commit 4eb792a

Browse files
refactor: simplify Table component props by using ComponentPropsWithoutRef
1 parent 66805c0 commit 4eb792a

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed
Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1-
import {
2-
Box,
3-
type DevupComponentBaseProps,
4-
type DevupComponentProps,
5-
} from '@devup-ui/react'
1+
import { Box } from '@devup-ui/react'
2+
import { ComponentPropsWithoutRef } from 'react'
63

7-
// FIXME: Merge type is not exported in @devup-ui/react
8-
type Merge<T, U> = Omit<T, Extract<keyof T, keyof U>> & U
9-
10-
type TableComponentProps<T extends React.ElementType> = Merge<
11-
DevupComponentBaseProps<T>,
12-
DevupComponentProps<T>
13-
>
14-
15-
const TableRoot = ({ ...props }: TableComponentProps<'table'>) => {
4+
export const Table = ({ ...props }: ComponentPropsWithoutRef<'table'>) => {
165
return (
176
<Box borderRadius="0.5rem" overflow="hidden">
187
<Box as="table" borderCollapse="collapse" borderSpacing={0} {...props} />
198
</Box>
209
)
2110
}
2211

23-
const TableHead = ({ ...props }: TableComponentProps<'thead'>) => {
12+
export const Table = ({ ...props }: ComponentPropsWithoutRef<'thead'>) => {
2413
return (
2514
<Box
2615
as="thead"
@@ -34,11 +23,11 @@ const TableHead = ({ ...props }: TableComponentProps<'thead'>) => {
3423
)
3524
}
3625

37-
const TableBody = ({ ...props }: TableComponentProps<'tbody'>) => {
26+
export const Table = ({ ...props }: ComponentPropsWithoutRef<'tbody'>) => {
3827
return <Box as="tbody" {...props}></Box>
3928
}
4029

41-
const TableRow = ({ ...props }: TableComponentProps<'tr'>) => {
30+
export const Table = ({ ...props }: ComponentPropsWithoutRef<'tr'>) => {
4231
return (
4332
<Box
4433
as="tr"
@@ -53,16 +42,10 @@ const TableRow = ({ ...props }: TableComponentProps<'tr'>) => {
5342
)
5443
}
5544

56-
const TableCell = ({ ...props }: TableComponentProps<'td'>) => {
45+
export const Table = ({ ...props }: ComponentPropsWithoutRef<'td'>) => {
5746
return <Box as="td" padding="0.5rem 1rem" {...props} />
5847
}
5948

60-
const TableHeaderCell = ({ ...props }: TableComponentProps<'th'>) => {
49+
export const Table = ({ ...props }: ComponentPropsWithoutRef<'th'>) => {
6150
return <Box as="th" padding="0.5rem 1rem" textAlign="left" {...props} />
6251
}
63-
64-
export { TableBody, TableCell, TableHead, TableHeaderCell, TableRoot, TableRow }
65-
66-
export function Table() {
67-
return <></>
68-
}

0 commit comments

Comments
 (0)