import { size, theme } from '@planview/pv-utilities' import React from 'react' import styled, { css } from 'styled-components' import { useGridContext, useGridSelector } from '../../../context/grid-context' import { GridColumnMoveHandle } from '../../../layout' import { GridHeaderGroupCellDefaultRenderer } from '../../../renderers' import { GridHeaderCellExpand } from '../../grid-header-cell-expand' import { useColumnBorders } from '../../../hooks/use-column-borders' const Wrap = styled.div<{ $leftBorder?: boolean $rightBorder?: boolean $bottomBorder?: boolean }>` ${(props) => props.$leftBorder ? `border-left: 1px solid ${theme.borderLight}` : null}; ${(props) => props.$rightBorder ? css` border-right: 1px solid ${theme.borderLight}; ` : null}; ${(props) => props.$bottomBorder ? `border-bottom: 1px solid ${theme.borderLight}` : null}; overflow: hidden; box-sizing: border-box; position: relative; ` const InnerWrap = styled.div` display: flex; ` export const GridHeaderCellOverlay = ({ columnId, height = size.small, spacer = false, isDragging = false, last = false, }: { columnId: string height?: number spacer?: boolean isDragging?: boolean last?: boolean }) => { const { selectors } = useGridContext() const { actualWidth, data: column } = useGridSelector((state) => selectors.selectColumn(state, columnId) ) const { showLeftBorder, showRightBorder } = useColumnBorders( columnId, 'header' ) const CellHeaderComponent = column.header?.Renderer return ( {spacer ? null : CellHeaderComponent ? ( <> {isDragging && ( )} {!!column.tree && ( )} ) : ( column.label )} ) } export const GridHeaderGroupCellOverlay = ({ columnId, height = size.small, spacer = false, isDragging = false, last = false, }: { columnId: string height?: number spacer?: boolean isDragging?: boolean last?: boolean }) => { const { selectors } = useGridContext() const { actualWidth } = useGridSelector((state) => selectors.selectColumn(state, columnId) ) return ( {spacer ? null : ( <> {isDragging && ( )} )} ) }