index.tsx 988 Bytes
import { Table, type TableProps } from 'antd';
import { useScrollbarRemeasure } from '../../hooks/useScrollbarRemeasure';

/**
 * 项目统一表格。
 *
 * rootClassName 统一挂 uj:表头底色、行 hover、分隔线、分页贴底这些规则
 * 都在 @uj/ui 的 styles/ui.css 里以 .uj-table 为作用域,页面不需要自己写。
 * 组件的几何量仍然由 themeConfig 的 Table token 下发。
 *
 * scrollbarRemeasure:见 FillTable 同名字段注释 —— wujie 异步注入细滚动条规则可能晚于
 * 首次挂载,强制表格在规则进入文档后重挂载一次,消除表头/表体错位。
 */
export function UTable<T>(props: TableProps<T>) {
  const { size = 'middle', rootClassName, ...rest } = props;
  const remeasureEpoch = useScrollbarRemeasure(true);
  return (
    <Table<T>
      key={`uj-ut-${remeasureEpoch}`}
      size={size}
      rootClassName={['uj-table', rootClassName].filter(Boolean).join(' ')}
      {...rest}
    />
  );
}