1717 * under the License.
1818 */
1919
20- import React , { FunctionComponent , HTMLAttributes , memo } from 'react' ;
20+ import React , { forwardRef , HTMLAttributes , memo } from 'react' ;
2121import classnames from 'classnames' ;
2222import {
2323 EuiDataGridControlColumn ,
@@ -51,86 +51,47 @@ const DefaultColumnFormatter: EuiDataGridPopoverContent = ({ children }) => {
5151 return < EuiText > { children } </ EuiText > ;
5252} ;
5353
54- const EuiDataGridFooterRow : FunctionComponent < EuiDataGridFooterRowProps > = memo (
55- ( {
56- leadingControlColumns,
57- trailingControlColumns,
58- columns,
59- schema,
60- popoverContents,
61- columnWidths,
62- defaultColumnWidth,
63- className,
64- renderCellValue,
65- rowIndex,
66- interactiveCellId,
67- 'data-test-subj' : _dataTestSubj ,
68- visibleRowIndex = rowIndex ,
69- ...rest
70- } ) => {
71- const classes = classnames (
72- 'euiDataGridRow' ,
73- 'euiDataGridFooter' ,
74- className
75- ) ;
76- const dataTestSubj = classnames ( 'dataGridRow' , _dataTestSubj ) ;
54+ const EuiDataGridFooterRow = memo (
55+ forwardRef < HTMLDivElement , EuiDataGridFooterRowProps > (
56+ (
57+ {
58+ leadingControlColumns,
59+ trailingControlColumns,
60+ columns,
61+ schema,
62+ popoverContents,
63+ columnWidths,
64+ defaultColumnWidth,
65+ className,
66+ renderCellValue,
67+ rowIndex,
68+ interactiveCellId,
69+ 'data-test-subj' : _dataTestSubj ,
70+ visibleRowIndex = rowIndex ,
71+ ...rest
72+ } ,
73+ ref
74+ ) => {
75+ const classes = classnames (
76+ 'euiDataGridRow' ,
77+ 'euiDataGridFooter' ,
78+ className
79+ ) ;
80+ const dataTestSubj = classnames ( 'dataGridRow' , _dataTestSubj ) ;
7781
78- return (
79- < div
80- role = "row"
81- className = { classes }
82- data-test-subj = { dataTestSubj }
83- { ...rest } >
84- { leadingControlColumns . map ( ( { id, width } , i ) => (
85- < EuiDataGridCell
86- key = { `${ id } -${ rowIndex } ` }
87- rowIndex = { rowIndex }
88- visibleRowIndex = { visibleRowIndex }
89- colIndex = { i }
90- columnId = { id }
91- popoverContent = { DefaultColumnFormatter }
92- width = { width }
93- renderCellValue = { ( ) => null }
94- interactiveCellId = { interactiveCellId }
95- isExpandable = { true }
96- className = "euiDataGridFooterCell euiDataGridRowCell--controlColumn"
97- />
98- ) ) }
99- { columns . map ( ( { id } , i ) => {
100- const columnType = schema [ id ] ? schema [ id ] . columnType : null ;
101- const popoverContent =
102- ( columnType && popoverContents [ columnType ] ) ||
103- DefaultColumnFormatter ;
104-
105- const width = columnWidths [ id ] || defaultColumnWidth ;
106- const columnPosition = i + leadingControlColumns . length ;
107-
108- return (
82+ return (
83+ < div
84+ ref = { ref }
85+ role = "row"
86+ className = { classes }
87+ data-test-subj = { dataTestSubj }
88+ { ...rest } >
89+ { leadingControlColumns . map ( ( { id, width } , i ) => (
10990 < EuiDataGridCell
11091 key = { `${ id } -${ rowIndex } ` }
11192 rowIndex = { rowIndex }
11293 visibleRowIndex = { visibleRowIndex }
113- colIndex = { columnPosition }
114- columnId = { id }
115- columnType = { columnType }
116- popoverContent = { popoverContent }
117- width = { width || undefined }
118- renderCellValue = { renderCellValue }
119- interactiveCellId = { interactiveCellId }
120- isExpandable = { true }
121- className = "euiDataGridFooterCell"
122- />
123- ) ;
124- } ) }
125- { trailingControlColumns . map ( ( { id, width } , i ) => {
126- const colIndex = i + columns . length + leadingControlColumns . length ;
127-
128- return (
129- < EuiDataGridCell
130- key = { `${ id } -${ rowIndex } ` }
131- rowIndex = { rowIndex }
132- visibleRowIndex = { visibleRowIndex }
133- colIndex = { colIndex }
94+ colIndex = { i }
13495 columnId = { id }
13596 popoverContent = { DefaultColumnFormatter }
13697 width = { width }
@@ -139,11 +100,58 @@ const EuiDataGridFooterRow: FunctionComponent<EuiDataGridFooterRowProps> = memo(
139100 isExpandable = { true }
140101 className = "euiDataGridFooterCell euiDataGridRowCell--controlColumn"
141102 />
142- ) ;
143- } ) }
144- </ div >
145- ) ;
146- }
103+ ) ) }
104+ { columns . map ( ( { id } , i ) => {
105+ const columnType = schema [ id ] ? schema [ id ] . columnType : null ;
106+ const popoverContent =
107+ ( columnType && popoverContents [ columnType ] ) ||
108+ DefaultColumnFormatter ;
109+
110+ const width = columnWidths [ id ] || defaultColumnWidth ;
111+ const columnPosition = i + leadingControlColumns . length ;
112+
113+ return (
114+ < EuiDataGridCell
115+ key = { `${ id } -${ rowIndex } ` }
116+ rowIndex = { rowIndex }
117+ visibleRowIndex = { visibleRowIndex }
118+ colIndex = { columnPosition }
119+ columnId = { id }
120+ columnType = { columnType }
121+ popoverContent = { popoverContent }
122+ width = { width || undefined }
123+ renderCellValue = { renderCellValue }
124+ interactiveCellId = { interactiveCellId }
125+ isExpandable = { true }
126+ className = "euiDataGridFooterCell"
127+ />
128+ ) ;
129+ } ) }
130+ { trailingControlColumns . map ( ( { id, width } , i ) => {
131+ const colIndex = i + columns . length + leadingControlColumns . length ;
132+
133+ return (
134+ < EuiDataGridCell
135+ key = { `${ id } -${ rowIndex } ` }
136+ rowIndex = { rowIndex }
137+ visibleRowIndex = { visibleRowIndex }
138+ colIndex = { colIndex }
139+ columnId = { id }
140+ popoverContent = { DefaultColumnFormatter }
141+ width = { width }
142+ renderCellValue = { ( ) => null }
143+ interactiveCellId = { interactiveCellId }
144+ isExpandable = { true }
145+ className = "euiDataGridFooterCell euiDataGridRowCell--controlColumn"
146+ />
147+ ) ;
148+ } ) }
149+ </ div >
150+ ) ;
151+ }
152+ )
147153) ;
148154
155+ EuiDataGridFooterRow . displayName = 'EuiDataGridFooterRow' ;
156+
149157export { EuiDataGridFooterRow } ;
0 commit comments