import React from 'react';
import { cn } from '@/lib/utils';
/**
* 控制台数据表格容器组件
* 提供统一的表格布局和样式基础
*/
interface DataTableShellProps {
/** 表格标题 */
title?: string;
/** 标题右侧的操作区 */
titleAction?: React.ReactNode;
/** 表格内容 */
children: React.ReactNode;
/** 空状态内容 */
empty?: React.ReactNode;
/** 是否为空 */
isEmpty?: boolean;
/** 额外的 className */
className?: string;
/** 表格容器的 className */
tableClassName?: string;
}
/**
* 数据表格容器组件
* 用于控制台中统一展示表格数据
*/
export function DataTableShell({
title,
titleAction,
children,
empty,
isEmpty = false,
className,
tableClassName,
}: DataTableShellProps) {
return (
{/* 标题行 */}
{(title || titleAction) && (
{title && (
{title}
)}
{titleAction && (
{titleAction}
)}
)}
{/* 表格容器 */}
{isEmpty ? (
empty || (
暂无数据
)
) : (
)}
);
}
/**
* 表格头部组件
*/
interface DataTableHeadProps {
children: React.ReactNode;
className?: string;
}
export function DataTableHead({ children, className }: DataTableHeadProps) {
return (
{children}
);
}
/**
* 表格行组件
*/
interface DataTableRowProps {
children: React.ReactNode;
className?: string;
onClick?: () => void;
}
export function DataTableRow({ children, className, onClick }: DataTableRowProps) {
return (
{children}
);
}
/**
* 表格单元格组件
*/
interface DataTableCellProps {
children: React.ReactNode;
className?: string;
header?: boolean;
}
export function DataTableCell({ children, className, header }: DataTableCellProps) {
const Tag = header ? 'th' : 'td';
return (
{children}
);
}