@@ -8,14 +8,15 @@ import { valueIsArray } from '../../chart/ChartUtils';
8
8
interface GridCellExpandProps {
9
9
value : string ;
10
10
width : number ;
11
+ lineBreakAfterListEntry ?: boolean ;
11
12
}
12
13
13
14
function isOverflown ( element : Element ) : boolean {
14
15
return element . scrollHeight > element . clientHeight || element . scrollWidth > element . clientWidth ;
15
16
}
16
17
17
18
const GridCellExpand = React . memo ( ( props : GridCellExpandProps ) => {
18
- const { width, value } = props ;
19
+ const { width, value, lineBreakAfterListEntry } = props ;
19
20
const wrapper = React . useRef < HTMLDivElement | null > ( null ) ;
20
21
const cellDiv = React . useRef ( null ) ;
21
22
const cellValue = React . useRef ( null ) ;
@@ -95,7 +96,14 @@ const GridCellExpand = React.memo((props: GridCellExpandProps) => {
95
96
{ showPopper && (
96
97
< Popper open = { showFullCell && anchorEl !== null } anchorEl = { anchorEl } style = { { width, marginLeft : - 17 } } >
97
98
< Paper elevation = { 1 } style = { { minHeight : wrapper . current ! . offsetHeight - 3 } } >
98
- < Typography variant = 'body2' style = { { padding : 8 , whiteSpace : 'normal' , wordBreak : 'break-word' } } >
99
+ < Typography
100
+ variant = 'body2'
101
+ style = { {
102
+ padding : 8 ,
103
+ whiteSpace : lineBreakAfterListEntry ? 'pre-line' : 'normal' ,
104
+ wordBreak : 'break-word' ,
105
+ } }
106
+ >
99
107
{ value }
100
108
</ Typography >
101
109
</ Paper >
@@ -106,19 +114,28 @@ const GridCellExpand = React.memo((props: GridCellExpandProps) => {
106
114
} ) ;
107
115
108
116
export function renderCellExpand ( params : GridRenderCellParams < any , string > , lineBreakAfterListEntry : boolean ) {
109
-
110
117
let value = params . value ?. low ? params . value . low : params . value ;
111
-
112
- if ( ! value ) {
113
- value = ""
114
- }
115
- return ( typeof value === "string" || value instanceof String )
116
- ? < GridCellExpand value = { RenderString ( value ) } width = { params . colDef . computedWidth } />
117
- : ( valueIsArray ( value ) ) ? < GridCellExpand value = { RenderArray ( Array . from ( value ) , false , lineBreakAfterListEntry ) } width = { params . colDef . computedWidth } />
118
- : < GridCellExpand value = { JSON . stringify ( value )
119
- . replaceAll ( ',' , lineBreakAfterListEntry ? ',\r\n' : ', ' )
120
- . replaceAll ( ']' , '' )
121
- . replaceAll ( '[' , '' )
122
- . replaceAll ( '"' , '' ) } width = { params . colDef . computedWidth } /> ;
123
118
119
+ if ( ! value ) {
120
+ value = '' ;
121
+ }
122
+ return typeof value === 'string' || value instanceof String ? (
123
+ < GridCellExpand value = { RenderString ( value ) } width = { params . colDef . computedWidth } lineBreakAfterListEntry />
124
+ ) : valueIsArray ( value ) ? (
125
+ < GridCellExpand
126
+ value = { RenderArray ( Array . from ( value ) , false , lineBreakAfterListEntry ) }
127
+ width = { params . colDef . computedWidth }
128
+ lineBreakAfterListEntry
129
+ />
130
+ ) : (
131
+ < GridCellExpand
132
+ value = { JSON . stringify ( value )
133
+ . replaceAll ( ',' , lineBreakAfterListEntry ? ',\r\n' : ', ' )
134
+ . replaceAll ( ']' , '' )
135
+ . replaceAll ( '[' , '' )
136
+ . replaceAll ( '"' , '' ) }
137
+ width = { params . colDef . computedWidth }
138
+ lineBreakAfterListEntry
139
+ />
140
+ ) ;
124
141
}
0 commit comments