@@ -4,56 +4,61 @@ import cs from 'classnames';
44import PropTypes from 'prop-types' ;
55
66import _ from './utils' ;
7+ import eventDelegater from './cell-event-delegater' ;
78
8- const FooterCell = ( props ) => {
9- const { index, column, columnData } = props ;
9+ class FooterCell extends eventDelegater ( React . Component ) {
10+ render ( ) {
11+ const { index, column, columnData } = this . props ;
1012
11- const {
12- footer,
13- footerTitle,
14- footerAlign,
15- footerFormatter,
16- footerEvents,
17- footerClasses,
18- footerStyle,
19- footerAttrs
20- } = column ;
13+ const {
14+ footer,
15+ footerTitle,
16+ footerAlign,
17+ footerFormatter,
18+ footerEvents,
19+ footerClasses,
20+ footerStyle,
21+ footerAttrs
22+ } = column ;
2123
22- const cellAttrs = {
23- ...( _ . isFunction ( footerAttrs ) ? footerAttrs ( column , index ) : footerAttrs ) ,
24- ...footerEvents
25- } ;
24+ const delegateEvents = this . delegate ( footerEvents ) ;
25+ const cellAttrs = {
26+ ...( _ . isFunction ( footerAttrs ) ? footerAttrs ( column , index ) : footerAttrs ) ,
27+ ...delegateEvents
28+ } ;
2629
27- let text = '' ;
28- if ( _ . isString ( footer ) ) {
29- text = footer ;
30- } else if ( _ . isFunction ( footer ) ) {
31- text = footer ( columnData , column , index ) ;
32- }
3330
34- let cellStyle = { } ;
35- const cellClasses = _ . isFunction ( footerClasses ) ? footerClasses ( column , index ) : footerClasses ;
31+ let text = '' ;
32+ if ( _ . isString ( footer ) ) {
33+ text = footer ;
34+ } else if ( _ . isFunction ( footer ) ) {
35+ text = footer ( columnData , column , index ) ;
36+ }
3637
37- if ( footerStyle ) {
38- cellStyle = _ . isFunction ( footerStyle ) ? footerStyle ( column , index ) : footerStyle ;
39- cellStyle = cellStyle ? { ...cellStyle } : cellStyle ;
40- }
38+ let cellStyle = { } ;
39+ const cellClasses = _ . isFunction ( footerClasses ) ? footerClasses ( column , index ) : footerClasses ;
4140
42- if ( footerTitle ) {
43- cellAttrs . title = _ . isFunction ( footerTitle ) ? footerTitle ( column , index ) : text ;
44- }
41+ if ( footerStyle ) {
42+ cellStyle = _ . isFunction ( footerStyle ) ? footerStyle ( column , index ) : footerStyle ;
43+ cellStyle = cellStyle ? { ...cellStyle } : cellStyle ;
44+ }
4545
46- if ( footerAlign ) {
47- cellStyle . textAlign = _ . isFunction ( footerAlign ) ? footerAlign ( column , index ) : footerAlign ;
48- }
46+ if ( footerTitle ) {
47+ cellAttrs . title = _ . isFunction ( footerTitle ) ? footerTitle ( column , index ) : text ;
48+ }
4949
50- if ( cellClasses ) cellAttrs . className = cs ( cellAttrs . className , cellClasses ) ;
51- if ( ! _ . isEmptyObject ( cellStyle ) ) cellAttrs . style = cellStyle ;
50+ if ( footerAlign ) {
51+ cellStyle . textAlign = _ . isFunction ( footerAlign ) ? footerAlign ( column , index ) : footerAlign ;
52+ }
5253
53- const children = footerFormatter ? footerFormatter ( column , index ) : text ;
54+ if ( cellClasses ) cellAttrs . className = cs ( cellAttrs . className , cellClasses ) ;
55+ if ( ! _ . isEmptyObject ( cellStyle ) ) cellAttrs . style = cellStyle ;
5456
55- return React . createElement ( 'th' , cellAttrs , children ) ;
56- } ;
57+ const children = footerFormatter ? footerFormatter ( column , index ) : text ;
58+
59+ return React . createElement ( 'th' , cellAttrs , children ) ;
60+ }
61+ }
5762
5863FooterCell . propTypes = {
5964 columnData : PropTypes . array ,
0 commit comments