Compare commits

..

No commits in common. "ecb2708b4efbd3a49bbcded402f03b68bcba784c" and "b3b5574d86dd27b70146487c561785c54d5c5347" have entirely different histories.

View File

@ -31,19 +31,6 @@ const getColumnId = (header) => {
return columnId; return columnId;
} }
// Ширина закреплённых дочерних колонок группового заголовка
const getPinnedColumnsWidth = (header, pinningColumn) => {
let width = 0;
for (const leaf of header.getLeafHeaders()) {
if (pinningColumn.includes(leaf.column.id)) {
width += leaf.column.getSize();
} else {
break;
}
}
return width;
};
const calculateLeftOffset = (table, columnOrHeader) => { const calculateLeftOffset = (table, columnOrHeader) => {
const columnId = getColumnId(columnOrHeader); const columnId = getColumnId(columnOrHeader);
const pinnedColumns = table.getState().columnPinning.left || []; const pinnedColumns = table.getState().columnPinning.left || [];
@ -135,13 +122,8 @@ const ColumnNumberCell = ({ column, table }) => {
const HeaderCell = ({ header, table, onClick, hightlight, onChangeWidth }) => { const HeaderCell = ({ header, table, onClick, hightlight, onChangeWidth }) => {
const column = header.column; const column = header.column;
const pinningColumn = table.getState().columnPinning.left || [];
const isGroup = header.subHeaders?.length > 0;
const isPinned = isColumnPin(table, header); const isPinned = isColumnPin(table, header);
const leftOffset = calculateLeftOffset(table, header); const leftOffset = calculateLeftOffset(table, header);
const headerSize = header.getSize();
const pinnedBandWidth = isGroup ? getPinnedColumnsWidth(header, pinningColumn) : 0;
const splitGroup = isGroup && isPinned && pinnedBandWidth > 0 && pinnedBandWidth < headerSize;
const customBgColor = column.columnDef?.muiTableHeadCellProps?.sx?.backgroundColor; const customBgColor = column.columnDef?.muiTableHeadCellProps?.sx?.backgroundColor;
const color = column.columnDef?.muiTableHeadCellProps?.sx?.color || '#000000'; const color = column.columnDef?.muiTableHeadCellProps?.sx?.color || '#000000';
@ -175,14 +157,22 @@ const HeaderCell = ({ header, table, onClick, hightlight, onChangeWidth }) => {
return `${totalPinnedWidth}px`; return `${totalPinnedWidth}px`;
}; };
const renderCell = (width, textLeft) => ( return (
<div
style={{
position: isPinned ? 'sticky' : 'relative',
left: isPinned ? leftOffset : 'auto',
zIndex: isPinned ? 21 : 'auto',
}}
>
<div style={{ position: 'relative' }}> <div style={{ position: 'relative' }}>
<div <div
key={header.id}
onClick={() => onClick(header)} onClick={() => onClick(header)}
style={{ style={{
width: width + 'px', width: header.getSize() + 'px',
minWidth: width + 'px', minWidth: header.getSize() + 'px',
maxWidth: width + 'px', maxWidth: header.getSize() + 'px',
position: 'relative', position: 'relative',
padding: '4px 6px', padding: '4px 6px',
textAlign: 'center', textAlign: 'center',
@ -202,7 +192,7 @@ const HeaderCell = ({ header, table, onClick, hightlight, onChangeWidth }) => {
style={{ style={{
textAlign: 'center', textAlign: 'center',
position: 'sticky', position: 'sticky',
left: textLeft, left: getTextLeftOffset(),
right: 0, right: 0,
paddingRight: '0.5rem', paddingRight: '0.5rem',
paddingLeft: '0.5rem', paddingLeft: '0.5rem',
@ -215,30 +205,6 @@ const HeaderCell = ({ header, table, onClick, hightlight, onChangeWidth }) => {
<ColumnResizer reportDragDeltaX={handleChangeWidth} /> <ColumnResizer reportDragDeltaX={handleChangeWidth} />
</div> </div>
</div> </div>
);
if (splitGroup) {
return (
<>
<div style={{ position: 'sticky', left: leftOffset, zIndex: 21, flexShrink: 0 }}>
{renderCell(pinnedBandWidth, '0')}
</div>
<div style={{ position: 'relative', flexShrink: 0 }}>
{renderCell(headerSize - pinnedBandWidth, getTextLeftOffset(true))}
</div>
</>
);
}
return (
<div
style={{
position: isPinned ? 'sticky' : 'relative',
left: isPinned ? leftOffset : 'auto',
zIndex: isPinned ? 21 : 'auto',
}}
>
{renderCell(headerSize, getTextLeftOffset())}
</div> </div>
); );
}; };