|
|
@@ -9,7 +9,7 @@ import {
|
|
|
import {PAGE_SIZE_LIST, TABLE_CELL_WIDTH} from '@utils';
|
|
|
import {Dispatch, ReactElement, ReactNode, SetStateAction} from 'react';
|
|
|
import {useTable, useTableShadow} from './hooks';
|
|
|
-import {RowSelectionState, flexRender} from '@tanstack/react-table';
|
|
|
+import {RowSelectionState} from '@tanstack/react-table';
|
|
|
import HeaderTh from './HeaderTh';
|
|
|
import {
|
|
|
DndContext,
|
|
|
@@ -25,13 +25,14 @@ import {
|
|
|
import classNames from 'classnames';
|
|
|
import './index.css';
|
|
|
import {ModifyData} from '@models';
|
|
|
+import BodyTr from './BodyTr';
|
|
|
|
|
|
export type LDColumnsType<T extends Record<string, unknown>> = {
|
|
|
dataIndex: keyof T,
|
|
|
title: string,
|
|
|
render?: (info: T, index: number) => ReactNode,
|
|
|
align?: 'left' | 'right' | 'center',
|
|
|
- fixed?: boolean,
|
|
|
+ fixed?: 'left' | 'right',
|
|
|
width?: number,
|
|
|
};
|
|
|
|
|
|
@@ -76,7 +77,7 @@ function LDTable<T extends Record<string, any>>(props: Props<T>): ReactElement {
|
|
|
|
|
|
const sensor = useSensor(PointerSensor);
|
|
|
const {
|
|
|
- isEnd,
|
|
|
+ scrollProgess,
|
|
|
scrollTableRef,
|
|
|
headerTableRef,
|
|
|
} = useTableShadow(getCenterTotalSize());
|
|
|
@@ -101,7 +102,7 @@ function LDTable<T extends Record<string, any>>(props: Props<T>): ReactElement {
|
|
|
<div className="ld-table-header-sticky" ref={headerTableRef}>
|
|
|
<table
|
|
|
className={classNames('ld-table', {
|
|
|
- 'ld-table-enabled-fixed-shadow': !isEnd,
|
|
|
+ 'ld-table-enabled-right-fixed-shadow': scrollProgess !== 'end',
|
|
|
})}
|
|
|
style={{width: getCenterTotalSize()}}
|
|
|
>
|
|
|
@@ -132,7 +133,7 @@ function LDTable<T extends Record<string, any>>(props: Props<T>): ReactElement {
|
|
|
<div className="ld-table-body-wrapper" ref={scrollTableRef}>
|
|
|
<table
|
|
|
className={classNames('ld-table', {
|
|
|
- 'ld-table-enabled-fixed-shadow': !isEnd,
|
|
|
+ 'ld-table-enabled-right-fixed-shadow': scrollProgess !== 'end',
|
|
|
})}
|
|
|
style={{width: getCenterTotalSize()}}
|
|
|
>
|
|
|
@@ -140,35 +141,7 @@ function LDTable<T extends Record<string, any>>(props: Props<T>): ReactElement {
|
|
|
{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>
|
|
|
+ <BodyTr getVisibleCells={getVisibleCells} key={id} />
|
|
|
);
|
|
|
})
|
|
|
) : (
|