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' ;
1
5
import { Event } from '@ui5/webcomponents-react-base/lib/Event' ;
2
6
import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper' ;
3
7
import { Icon } from '@ui5/webcomponents-react/lib/Icon' ;
4
8
import React , { CSSProperties , DragEventHandler , FC , ReactNode , ReactNodeArray , useMemo } from 'react' ;
5
9
import { createUseStyles , useTheme } from 'react-jss' ;
6
10
import { JSSTheme } from '../../../interfaces/JSSTheme' ;
7
- import { Resizer } from './Resizer' ;
8
11
import { ColumnType } from '../types/ColumnType' ;
9
12
import { 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' ;
14
13
15
14
export interface ColumnHeaderProps {
16
15
id : string ;
@@ -64,6 +63,16 @@ const styles = ({ parameters }: JSSTheme) => ({
64
63
'& :last-child' : {
65
64
marginLeft : '0.25rem'
66
65
}
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
67
76
}
68
77
} ) ;
69
78
@@ -106,7 +115,16 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
106
115
const groupingIcon = column . isGrouped ? < Icon name = "group-2" /> : null ;
107
116
108
117
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
+ >
110
128
< span
111
129
title = { typeof children === 'string' ? children : null }
112
130
style = { { textOverflow : 'ellipsis' , overflowX : 'hidden' , whiteSpace : 'nowrap' } }
@@ -120,13 +138,26 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
120
138
</ div >
121
139
</ div >
122
140
) ;
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
+ ] ) ;
124
156
125
157
const isResizable = ! isLastColumn && column . canResize ;
126
158
const theme = useTheme ( ) as JSSTheme ;
127
159
const innerStyle : CSSProperties = useMemo ( ( ) => {
128
- const modifiedStyles = {
129
- ...style ,
160
+ const modifiedStyles : CSSProperties = {
130
161
width : '100%' ,
131
162
fontWeight : 'normal' ,
132
163
cursor : 'pointer' ,
@@ -137,26 +168,15 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
137
168
modifiedStyles . maxWidth = `calc(100% - 16px)` ;
138
169
}
139
170
if ( dragOver ) {
140
- modifiedStyles . borderLeft = ' 3px solid ' + theme . parameters . sapSelectedColor ;
171
+ modifiedStyles . borderLeft = ` 3px solid ${ theme . parameters . sapSelectedColor } ` ;
141
172
}
142
- return modifiedStyles as CSSProperties ;
143
- } , [ style , isResizable ] ) ;
173
+ return modifiedStyles ;
174
+ } , [ isResizable , dragOver ] ) ;
144
175
145
176
if ( ! column ) return null ;
146
177
147
178
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" >
160
180
{ groupable || sortable || filterable ? (
161
181
< ColumnHeaderModal
162
182
openBy = { openBy }
@@ -171,7 +191,7 @@ export const ColumnHeader: FC<ColumnHeaderProps> = (props) => {
171
191
) : (
172
192
< div style = { { ...innerStyle , display : 'inline-block' , cursor : 'auto' } } > { openBy } </ div >
173
193
) }
174
- { isResizable && < Resizer { ...props } /> }
194
+ < div { ...column . getResizerProps ( ) } className = { classes . resizer } />
175
195
</ div >
176
196
) ;
177
197
} ;
0 commit comments