Skip to content

Commit

Permalink
feat: 테이블 데이터 타입화
Browse files Browse the repository at this point in the history
  • Loading branch information
musma-sujan7 committed Dec 22, 2023
1 parent 9e5b1be commit 781939b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/react-component/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Box } from 'src/elements'
import { Size } from 'src/types'

import { TableBody, TableHead, TableToolbar } from './components'
import { TableColumn, ToolbarOption } from './types'
import { TableColumn, TableData, ToolbarOption } from './types'

export interface TableProps<T> extends HTMLAttributes<HTMLTableElement> {
/**
Expand Down Expand Up @@ -67,7 +67,7 @@ export interface TableProps<T> extends HTMLAttributes<HTMLTableElement> {
onRowClick?: (rowData: T) => void
}

export function Table<T extends { id: string }>({
export function Table<T extends TableData>({
data,
columns,
rounded = 'md',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ReactNode, useCallback } from 'react'
import { useCallback } from 'react'

import { useTheme } from '@emotion/react'

import { Checkbox, Typography } from 'src/components'

import { TableColumn } from '../types'
import { TableColumn, TableData } from '../types'

interface TableBodyProps<T> {
/**
Expand Down Expand Up @@ -45,11 +45,7 @@ interface TableBodyProps<T> {
onCheckboxClick?: (rowData: T) => void
}

interface TableDataProps extends Record<string, ReactNode> {
id: string
}

export function TableBody<T extends TableDataProps>({
export function TableBody<T extends TableData>({
columns,
data,
withCheckbox = false,
Expand Down
5 changes: 5 additions & 0 deletions packages/react-component/src/components/Table/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { ReactNode } from 'react'

export interface TableData {
id: string
[key: string]: ReactNode
}

export interface TableColumn {
columnName: string
columnLabel: ReactNode
Expand Down

0 comments on commit 781939b

Please sign in to comment.