Skip to content

Commit 66c3c5f

Browse files
committed
fix?
1 parent ae27917 commit 66c3c5f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/styled-react/src/components/DataTable.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1-
import {Table as PrimerDataTable} from '@primer/react/experimental'
1+
import {Table as PrimerDataTable, type TableContainerProps} from '@primer/react/experimental'
22
import {sx, type SxProp} from '../sx'
33
import styled from 'styled-components'
44
import type React from 'react'
5-
import type {ComponentProps} from 'react'
65

76
const {Container: PrimerDataTableContainer, ...rest} = PrimerDataTable
87

9-
type DataTableContainerProps = ComponentProps<typeof PrimerDataTable.Container> & SxProp
8+
type DataTableContainerProps<As extends React.ElementType = 'div'> = TableContainerProps<As> & SxProp
109

11-
const DataTableContainer: React.ComponentType<DataTableContainerProps> = styled(PrimerDataTableContainer).withConfig({
10+
const StyleDataTableContainer: React.ComponentType<DataTableContainerProps> = styled(
11+
PrimerDataTableContainer,
12+
).withConfig({
1213
shouldForwardProp: prop => (prop as keyof DataTableContainerProps) !== 'sx',
1314
})<DataTableContainerProps>`
1415
${sx}
15-
`
16+
` as typeof PrimerDataTable.Container & {
17+
<As extends React.ElementType = 'div'>(props: DataTableContainerProps<As>): React.ReactElement | null
18+
}
19+
20+
const DataTableContainer = function DataTableContainer<As extends React.ElementType = 'div'>({
21+
as,
22+
...rest
23+
}: DataTableContainerProps<As>) {
24+
return <StyleDataTableContainer {...rest} {...(as ? {forwardedAs: as} : {})} />
25+
}
1626

1727
const Table: typeof PrimerDataTable & {
1828
Container: typeof DataTableContainer

0 commit comments

Comments
 (0)