Skip to content

Commit dca638b

Browse files
authored
Merge pull request #46 from solved-ac/feature/fix-types
Fixed polymorphism
2 parents 285805b + 7327989 commit dca638b

33 files changed

+90
-42
lines changed

src/components/$Item/Enumerate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled'
22
import React, { ElementType, useContext } from 'react'
33
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
4+
import { forwardRefWithGenerics } from '../../utils/ref'
45
import { ItemizeContext } from './ItemizeContext'
56

67
const marginMap = {
@@ -31,7 +32,7 @@ export interface EnumerateProps {
3132
margin?: 'none' | 'normal' | 'wide'
3233
}
3334

34-
export const Enumerate: PC<'ol', EnumerateProps> = React.forwardRef(
35+
export const Enumerate: PC<'ol', EnumerateProps> = forwardRefWithGenerics(
3536
<T extends ElementType>(props: PP<T, EnumerateProps>, ref?: PR<T>) => {
3637
const itemizeContext = useContext(ItemizeContext)
3738
const {

src/components/$Item/Item.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled'
22
import React, { ElementType, useContext } from 'react'
33
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
4+
import { forwardRefWithGenerics } from '../../utils/ref'
45
import { ItemizeContext } from './ItemizeContext'
56

67
interface ItemContainerProps {
@@ -20,7 +21,7 @@ export interface ItemProps {
2021
marker?: string
2122
}
2223

23-
export const Item: PC<'li', ItemProps> = React.forwardRef(
24+
export const Item: PC<'li', ItemProps> = forwardRefWithGenerics(
2425
<T extends ElementType>(props: PP<T, ItemProps>, ref?: PR<T>) => {
2526
const itemizeContext = useContext(ItemizeContext)
2627
const { marker = itemizeContext.marker, as = 'li', ...rest } = props

src/components/$Item/Itemize.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled'
22
import React, { ElementType, useContext } from 'react'
33
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
4+
import { forwardRefWithGenerics } from '../../utils/ref'
45
import { ItemizeContext } from './ItemizeContext'
56

67
const marginMap = {
@@ -31,7 +32,7 @@ export interface ItemizeProps {
3132
margin?: 'none' | 'normal' | 'wide'
3233
}
3334

34-
export const Itemize: PC<'ul', ItemizeProps> = React.forwardRef(
35+
export const Itemize: PC<'ul', ItemizeProps> = forwardRefWithGenerics(
3536
<T extends ElementType>(props: PP<T, ItemizeProps>, ref?: PR<T>) => {
3637
const itemizeContext = useContext(ItemizeContext)
3738
const {

src/components/$List/List.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled'
22
import React, { ElementType } from 'react'
33
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
4+
import { forwardRefWithGenerics } from '../../utils/ref'
45

56
const paddingMap = {
67
none: 'padding: 0;',
@@ -21,7 +22,7 @@ export interface ListProps {
2122
padding?: 'none' | 'normal' | 'wide'
2223
}
2324

24-
export const List: PC<'ul', ListProps> = React.forwardRef(
25+
export const List: PC<'ul', ListProps> = forwardRefWithGenerics(
2526
<T extends ElementType>(props: PP<T, ListProps>, ref?: PR<T>) => {
2627
const { padding = 'normal', children, as = 'ul', ...rest } = props
2728

src/components/$List/ListItem.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from '@emotion/styled'
33
import React, { ElementType } from 'react'
44
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
55
import { computeHoverColor, readableColor } from '../../utils/color'
6+
import { forwardRefWithGenerics } from '../../utils/ref'
67
import { cssClickable, cssVariables } from '../../utils/styles'
78
import { transparentHoverTemplate } from '../../utils/variables'
89

@@ -63,7 +64,7 @@ export interface ListItemProps {
6364
padding?: 'none' | 'normal' | 'wide'
6465
}
6566

66-
export const ListItem: PC<'div', ListItemProps> = React.forwardRef(
67+
export const ListItem: PC<'div', ListItemProps> = forwardRefWithGenerics(
6768
<T extends ElementType>(props: PP<T, ListItemProps>, ref?: PR<T>) => {
6869
const solvedTheme = useTheme()
6970

src/components/$Tab/Tab.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ellipsis } from 'polished'
44
import React, { ElementType } from 'react'
55
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
66
import { computeHoverColor, readableColor } from '../../utils/color'
7+
import { forwardRefWithGenerics } from '../../utils/ref'
78
import { cssClickable, cssVariables } from '../../utils/styles'
89
import { transparentHoverTemplate } from '../../utils/variables'
910

@@ -62,7 +63,7 @@ export interface TabProps {
6263
accentColor?: string
6364
}
6465

65-
export const Tab: PC<'a', TabProps> = React.forwardRef(
66+
export const Tab: PC<'a', TabProps> = forwardRefWithGenerics(
6667
<T extends ElementType>(props: PP<T, TabProps>, ref?: PR<T>) => {
6768
const solvedTheme = useTheme()
6869

src/components/$Tab/Tabs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled'
22
import React, { ElementType } from 'react'
33
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
4+
import { forwardRefWithGenerics } from '../../utils/ref'
45

56
interface TabsContainerProps {
67
fullWidth: boolean
@@ -19,7 +20,7 @@ export interface TabsProps {
1920
multiline?: boolean
2021
}
2122

22-
export const Tabs: PC<'nav', TabsProps> = React.forwardRef(
23+
export const Tabs: PC<'nav', TabsProps> = forwardRefWithGenerics(
2324
<T extends ElementType>(props: PP<T, TabsProps>, ref?: PR<T>) => {
2425
const { fullWidth = false, multiline = false, as = 'nav', ...rest } = props
2526
return (

src/components/$Table/Cell.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { css } from '@emotion/react'
22
import styled from '@emotion/styled'
33
import React, { ElementType, useContext } from 'react'
44
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
5+
import { forwardRefWithGenerics } from '../../utils/ref'
56
import { TableContext } from './TableContext'
67
import { TableRowGroupContext } from './TableRowGroupContext'
78

@@ -38,7 +39,7 @@ export interface CellProps {
3839
numeric?: boolean
3940
}
4041

41-
export const Cell: PC<'td', CellProps> = React.forwardRef(
42+
export const Cell: PC<'td', CellProps> = forwardRefWithGenerics(
4243
<T extends ElementType>(props: PP<T, CellProps>, ref?: PR<T>) => {
4344
const tableContext = useContext(TableContext)
4445
const tableRowGroupContext = useContext(TableRowGroupContext)

src/components/$Table/Row.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled'
22
import React, { ElementType, useContext } from 'react'
33
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
4+
import { forwardRefWithGenerics } from '../../utils/ref'
45
import { TableContext } from './TableContext'
56

67
interface RowContainerProps {
@@ -17,7 +18,7 @@ export interface RowProps {
1718
padding?: 'none' | 'dense' | 'normal' | 'wide'
1819
}
1920

20-
export const Row: PC<'tr', RowProps> = React.forwardRef(
21+
export const Row: PC<'tr', RowProps> = forwardRefWithGenerics(
2122
<T extends ElementType>(props: PP<T, RowProps>, ref?: PR<T>) => {
2223
const tableContext = useContext(TableContext)
2324
const {

src/components/$Table/Table.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import styled from '@emotion/styled'
22
import React, { ElementType } from 'react'
33
import { PC, PP, PR } from '../../types/PolymorphicElementProps'
4+
import { forwardRefWithGenerics } from '../../utils/ref'
45
import { TableContext } from './TableContext'
56
import { TableRowGroupContext } from './TableRowGroupContext'
67

@@ -19,7 +20,7 @@ export interface TableProps {
1920
padding?: 'none' | 'dense' | 'normal' | 'wide'
2021
}
2122

22-
export const Table: PC<'table', TableProps> = React.forwardRef(
23+
export const Table: PC<'table', TableProps> = forwardRefWithGenerics(
2324
<T extends ElementType>(props: PP<T, TableProps>, ref?: PR<T>) => {
2425
const {
2526
fullWidth = false,

0 commit comments

Comments
 (0)