import { forwardRef, type HTMLAttributes, type ForwardedRef } from 'react'
import {
getTableProps,
getTableCaptionProps,
getTableHeadCellProps,
getTableBodyCellProps,
getTableRowProps,
splitClassNameProp,
} from '@pluralsight/headless-styles'
//
type TableProps = HTMLAttributes
function TableEl(props: TableProps, ref: ForwardedRef) {
const { children, ...nativeProps } = props
const pandoProps = getTableProps({
classNames: splitClassNameProp(props.className),
})
return (
)
}
//
type TableCaptionProps = HTMLAttributes
function TableCaptionEl(
props: TableCaptionProps,
ref: ForwardedRef
) {
const { children, ...nativeProps } = props
const pandoProps = getTableCaptionProps({
classNames: splitClassNameProp(props.className),
})
return (
{children}
)
}
//
// There is no styling needed for the table head, but we need to
// include it in the API for completeness.
type TableHeadProps = HTMLAttributes
function TableHeadEl(
props: TableHeadProps,
ref: ForwardedRef
) {
return
}
// |
type TableHeadCellProps = HTMLAttributes
function TableHeadCellEl(
props: TableHeadCellProps,
ref: ForwardedRef
) {
const { children, ...nativeProps } = props
const pandoProps = getTableHeadCellProps({
classNames: splitClassNameProp(props.className),
})
return (
{children}
|
)
}
//
// There is no styling needed for the table body, but we need to
// include it in the API for completeness.
type TableBodyProps = HTMLAttributes
function TableBodyEl(
props: TableBodyProps,
ref: ForwardedRef
) {
return
}
//
type TableRowProps = HTMLAttributes
function TableRowEl(
props: TableRowProps,
ref: ForwardedRef
) {
const { children, ...nativeProps } = props
const pandoProps = getTableRowProps({
classNames: splitClassNameProp(props.className),
})
return (
{children}
)
}
// |
type TableBodyCellProps = HTMLAttributes
function TableBodyCellEl(
props: TableBodyCellProps,
ref: ForwardedRef
) {
const { children, ...nativeProps } = props
const pandoProps = getTableBodyCellProps({
classNames: splitClassNameProp(props.className),
})
return (
{children}
|
)
}
// exports
export const Table = forwardRef(TableEl)
export const Caption = forwardRef(
TableCaptionEl
)
export const THead = forwardRef(
TableHeadEl
)
export const TH = forwardRef(
TableHeadCellEl
)
export const TBody = forwardRef(
TableBodyEl
)
export const TR = forwardRef(TableRowEl)
export const TD = forwardRef(
TableBodyCellEl
)