1+ import '@ui5/webcomponents-icons/dist/icons/filter' ;
2+ import '@ui5/webcomponents-icons/dist/icons/group-2' ;
3+ import '@ui5/webcomponents-icons/dist/icons/sort-ascending' ;
4+ import '@ui5/webcomponents-icons/dist/icons/sort-descending' ;
15import { Event } from '@ui5/webcomponents-react-base/lib/Event' ;
26import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper' ;
37import { Icon } from '@ui5/webcomponents-react/lib/Icon' ;
48import React , { CSSProperties , DragEventHandler , FC , ReactNode , ReactNodeArray , useMemo } from 'react' ;
59import { createUseStyles , useTheme } from 'react-jss' ;
610import { JSSTheme } from '../../../interfaces/JSSTheme' ;
7- import { Resizer } from './Resizer' ;
811import { ColumnType } from '../types/ColumnType' ;
912import { ColumnHeaderModal } from './ColumnHeaderModal' ;
10- import '@ui5/webcomponents-icons/dist/icons/filter' ;
11- import '@ui5/webcomponents-icons/dist/icons/group-2' ;
12- import '@ui5/webcomponents-icons/dist/icons/sort-descending' ;
13- import '@ui5/webcomponents-icons/dist/icons/sort-ascending' ;
1413
1514export interface ColumnHeaderProps {
1615 id : string ;
@@ -64,6 +63,16 @@ const styles = ({ parameters }: JSSTheme) => ({
6463 '& :last-child' : {
6564 marginLeft : '0.25rem'
6665 }
66+ } ,
67+ resizer : {
68+ display : 'inline-block' ,
69+ width : '16px' ,
70+ height : '100%' ,
71+ position : 'absolute' ,
72+ right : 0 ,
73+ top : 0 ,
74+ transform : 'translateX(50%)' ,
75+ zIndex : 1
6776 }
6877} ) ;
6978
@@ -106,7 +115,16 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
106115 const groupingIcon = column . isGrouped ? < Icon name = "group-2" /> : null ;
107116
108117 return (
109- < div className = { classNames . valueOf ( ) } >
118+ < div
119+ className = { classNames . valueOf ( ) }
120+ draggable = { isDraggable }
121+ onDragEnter = { onDragEnter }
122+ onDragOver = { onDragOver }
123+ onDragStart = { onDragStart }
124+ onDrop = { onDrop }
125+ onDragEnd = { onDragEnd }
126+ data-column-id = { id }
127+ >
110128 < span
111129 title = { typeof children === 'string' ? children : null }
112130 style = { { textOverflow : 'ellipsis' , overflowX : 'hidden' , whiteSpace : 'nowrap' } }
@@ -120,13 +138,26 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
120138 </ div >
121139 </ div >
122140 ) ;
123- } , [ classes , column . filterValue , column . isSorted , column . isGrouped , column . isSortedDesc , children ] ) ;
141+ } , [
142+ classes ,
143+ column . filterValue ,
144+ column . isSorted ,
145+ column . isGrouped ,
146+ column . isSortedDesc ,
147+ children ,
148+ isDraggable ,
149+ onDragEnter ,
150+ onDragOver ,
151+ onDragStart ,
152+ onDrop ,
153+ onDragEnd ,
154+ id
155+ ] ) ;
124156
125157 const isResizable = ! isLastColumn && column . canResize ;
126158 const theme = useTheme ( ) as JSSTheme ;
127159 const innerStyle : CSSProperties = useMemo ( ( ) => {
128- const modifiedStyles = {
129- ...style ,
160+ const modifiedStyles : CSSProperties = {
130161 width : '100%' ,
131162 fontWeight : 'normal' ,
132163 cursor : 'pointer' ,
@@ -137,26 +168,15 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
137168 modifiedStyles . maxWidth = `calc(100% - 16px)` ;
138169 }
139170 if ( dragOver ) {
140- modifiedStyles . borderLeft = ' 3px solid ' + theme . parameters . sapSelectedColor ;
171+ modifiedStyles . borderLeft = ` 3px solid ${ theme . parameters . sapSelectedColor } ` ;
141172 }
142- return modifiedStyles as CSSProperties ;
143- } , [ style , isResizable ] ) ;
173+ return modifiedStyles ;
174+ } , [ isResizable , dragOver ] ) ;
144175
145176 if ( ! column ) return null ;
146177
147178 return (
148- < div
149- id = { id }
150- className = { className }
151- style = { style }
152- role = "columnheader"
153- draggable = { isDraggable }
154- onDragEnter = { onDragEnter }
155- onDragOver = { onDragOver }
156- onDragStart = { onDragStart }
157- onDrop = { onDrop }
158- onDragEnd = { onDragEnd }
159- >
179+ < div id = { id } className = { className } style = { style } role = "columnheader" >
160180 { groupable || sortable || filterable ? (
161181 < ColumnHeaderModal
162182 openBy = { openBy }
@@ -171,7 +191,7 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
171191 ) : (
172192 < div style = { { ...innerStyle , display : 'inline-block' , cursor : 'auto' } } > { openBy } </ div >
173193 ) }
174- { isResizable && < Resizer { ...props } /> }
194+ < div { ...column . getResizerProps ( ) } className = { classes . resizer } />
175195 </ div >
176196 ) ;
177197} ;
0 commit comments