import { Typography } from 'antd';

type AdminCellLineProps = {
  primary?: string | null;
  secondary?: string | null;
  separator?: string;
};

/** 表格单元格：主/副信息同一行展示，超出省略，hover 显示全文 */
export function AdminCellLine({
  primary,
  secondary,
  separator = ' · ',
}: AdminCellLineProps) {
  const main = primary?.trim() || '—';
  const sub = secondary?.trim();
  const full = sub ? `${main}${separator}${sub}` : main;

  return (
    <Typography.Text
      className="admin-cell-line"
      ellipsis={{ tooltip: full }}
      style={{ maxWidth: '100%' }}
    >
      {main}
      {sub ? (
        <span className="admin-cell-line-secondary">
          {separator}
          {sub}
        </span>
      ) : null}
    </Typography.Text>
  );
}
