|
|
@@ -75,8 +75,11 @@ function LDTable<T extends Record<string, any>>(props: Props<T>): ReactElement {
|
|
|
});
|
|
|
|
|
|
const sensor = useSensor(PointerSensor);
|
|
|
-
|
|
|
- const isEnd = useTableShadow(getCenterTotalSize());
|
|
|
+ const {
|
|
|
+ isEnd,
|
|
|
+ scrollTableRef,
|
|
|
+ headerTableRef,
|
|
|
+ } = useTableShadow(getCenterTotalSize());
|
|
|
|
|
|
return (
|
|
|
<Spin spinning={isSearching}>
|
|
|
@@ -95,78 +98,92 @@ function LDTable<T extends Record<string, any>>(props: Props<T>): ReactElement {
|
|
|
items={(columns).map(val => val.dataIndex.toString())}
|
|
|
strategy={horizontalListSortingStrategy}
|
|
|
>
|
|
|
- <table
|
|
|
- className={classNames('ld-table', {
|
|
|
- 'ld-table-enabled-fixed-shadow': !isEnd,
|
|
|
- })}
|
|
|
- style={{width: getCenterTotalSize()}}
|
|
|
- >
|
|
|
- <thead className="ld-table-head">
|
|
|
- {getHeaderGroups().map(function({id, headers}) {
|
|
|
- return (
|
|
|
- <tr key={id}>
|
|
|
- {headers.map(header => (
|
|
|
- <HeaderTh key={header.id} header={header} />
|
|
|
- ))}
|
|
|
- </tr>
|
|
|
- );
|
|
|
+ <div className="ld-table-header-sticky" ref={headerTableRef}>
|
|
|
+ <table
|
|
|
+ className={classNames('ld-table', {
|
|
|
+ 'ld-table-enabled-fixed-shadow': !isEnd,
|
|
|
})}
|
|
|
- </thead>
|
|
|
- <tbody className="ld-table-body">
|
|
|
- {getRowModel().rows.length > 0 ? (
|
|
|
- getRowModel().rows.map(function({id, getVisibleCells}) {
|
|
|
+ style={{width: getCenterTotalSize()}}
|
|
|
+ >
|
|
|
+ <thead className="ld-table-head">
|
|
|
+ {getHeaderGroups().map(function({id, headers}) {
|
|
|
return (
|
|
|
<tr key={id}>
|
|
|
- {getVisibleCells().map(function({
|
|
|
- id,
|
|
|
- column,
|
|
|
- getContext,
|
|
|
- }) {
|
|
|
- const {align, fixed} = column.columnDef.meta as {
|
|
|
- align?: 'left' | 'center' | 'right';
|
|
|
- fixed: boolean;
|
|
|
- };
|
|
|
- return (
|
|
|
- <td
|
|
|
- key={id}
|
|
|
- className={classNames({
|
|
|
- 'ld-table-fixed-right ld-table-fixed-shadow': fixed,
|
|
|
- })}
|
|
|
- style={{
|
|
|
- width: column.getSize(),
|
|
|
- textAlign: align ?? 'left',
|
|
|
- }}
|
|
|
- >
|
|
|
- {flexRender(column.columnDef.cell, getContext())}
|
|
|
- </td>
|
|
|
- );
|
|
|
- })}
|
|
|
+ {headers.map(header => (
|
|
|
+ <HeaderTh key={header.id} header={header} />
|
|
|
+ ))}
|
|
|
</tr>
|
|
|
);
|
|
|
- })
|
|
|
- ) : (
|
|
|
- <tr>
|
|
|
- <td
|
|
|
- colSpan={getHeaderGroups()[0].headers.length}
|
|
|
- style={{padding: 0}}
|
|
|
- >
|
|
|
- <Empty
|
|
|
- image={Empty.PRESENTED_IMAGE_SIMPLE}
|
|
|
- style={{
|
|
|
- width: '400px',
|
|
|
- position: 'sticky',
|
|
|
- left: '50%',
|
|
|
- transform: 'translateX(-50%)',
|
|
|
- overflow: 'hidden',
|
|
|
- margin: 0,
|
|
|
- padding: '50px 10px',
|
|
|
- }}
|
|
|
- />
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- )}
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
+ })}
|
|
|
+ </thead>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ <div className="ld-table-body-wrapper" ref={scrollTableRef}>
|
|
|
+ <table
|
|
|
+ className={classNames('ld-table', {
|
|
|
+ 'ld-table-enabled-fixed-shadow': !isEnd,
|
|
|
+ })}
|
|
|
+ style={{width: getCenterTotalSize()}}
|
|
|
+ >
|
|
|
+ <tbody className="ld-table-body">
|
|
|
+ {getRowModel().rows.length > 0 ? (
|
|
|
+ getRowModel().rows.map(function({id, getVisibleCells}) {
|
|
|
+ return (
|
|
|
+ <tr key={id}>
|
|
|
+ {getVisibleCells().map(function({
|
|
|
+ id,
|
|
|
+ column,
|
|
|
+ getContext,
|
|
|
+ }) {
|
|
|
+ const {align, fixed} = column.columnDef.meta as {
|
|
|
+ align?: 'left' | 'center' | 'right';
|
|
|
+ fixed: boolean;
|
|
|
+ };
|
|
|
+ return (
|
|
|
+ <td
|
|
|
+ key={id}
|
|
|
+ className={classNames({
|
|
|
+ 'ld-table-fixed-right ld-table-fixed-shadow': fixed,
|
|
|
+ })}
|
|
|
+ style={{
|
|
|
+ width: column.getSize(),
|
|
|
+ textAlign: align ?? 'left',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {flexRender(
|
|
|
+ column.columnDef.cell,
|
|
|
+ getContext(),
|
|
|
+ )}
|
|
|
+ </td>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </tr>
|
|
|
+ );
|
|
|
+ })
|
|
|
+ ) : (
|
|
|
+ <tr>
|
|
|
+ <td
|
|
|
+ colSpan={getHeaderGroups()[0].headers.length}
|
|
|
+ style={{padding: 0}}
|
|
|
+ >
|
|
|
+ <Empty
|
|
|
+ image={Empty.PRESENTED_IMAGE_SIMPLE}
|
|
|
+ style={{
|
|
|
+ width: '400px',
|
|
|
+ position: 'sticky',
|
|
|
+ left: '50%',
|
|
|
+ transform: 'translateX(-50%)',
|
|
|
+ overflow: 'hidden',
|
|
|
+ margin: 0,
|
|
|
+ padding: '50px 10px',
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ )}
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
<DragOverlay>
|
|
|
{active ? (
|
|
|
<HeaderTh
|