@@ -394,19 +394,21 @@ window.ReactDOM["default"] = window.ReactDOM;
394
394
395
395
( function ( global , factory ) {
396
396
if ( typeof define === 'function' && define . amd ) {
397
- define ( [ 'exports' , 'react' , './lib/is_react_component' , './lib/stringable' , './unsafe' ] , factory ) ;
397
+ define ( [ 'exports' , 'react' , './lib/is_react_component' , './lib/stringable' , './unsafe' , './lib/filter_props_from' ] , factory ) ;
398
398
} else if ( typeof exports !== 'undefined' )
B41A
{
399
- factory ( exports , require ( 'react' ) , require ( './lib/is_react_component' ) , require ( './lib/stringable' ) , require ( './unsafe' ) ) ;
399
+ factory ( exports , require ( 'react' ) , require ( './lib/is_react_component' ) , require ( './lib/stringable' ) , require ( './unsafe' ) , require ( './lib/filter_props_from' ) ) ;
400
400
} else {
401
401
var mod = {
402
402
exports : { }
403
403
} ;
404
- factory ( mod . exports , global . React , global . is_react_component , global . stringable , global . unsafe ) ;
404
+ factory ( mod . exports , global . React , global . is_react_component , global . stringable , global . unsafe , global . filter_props_from ) ;
405
405
global . td = mod . exports ;
406
406
}
407
- } ) ( this , function ( exports , _react , _libIs_react_component , _libStringable , _unsafe ) {
407
+ } ) ( this , function ( exports , _react , _libIs_react_component , _libStringable , _unsafe , _libFilter_props_from ) {
408
408
'use strict' ;
409
409
410
+ var _extends = Object . assign || function ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] ; for ( var key in source ) { if ( Object . prototype . hasOwnProperty . call ( source , key ) ) { target [ key ] = source [ key ] ; } } } return target ; } ;
411
+
410
412
var _createClass = ( function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( 'value' in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
411
413
412
414
var _get = function get ( _x , _x2 , _x3 ) { var _again = true ; _function: while ( _again ) { var object = _x , property = _x2 , receiver = _x3 ; _again = false ; if ( object === null ) object = Function . prototype ; var desc = Object . getOwnPropertyDescriptor ( object , property ) ; if ( desc === undefined ) { var parent = Object . getPrototypeOf ( object ) ; if ( parent === null ) { return undefined ; } else { _x = parent ; _x2 = property ; _x3 = receiver ; _again = true ; desc = parent = undefined ; continue _function; } } else if ( 'value' in desc ) { return desc . value ; } else { var getter = desc . get ; if ( getter === undefined ) { return undefined ; } return getter . call ( receiver ) ; } } } ;
@@ -425,50 +427,44 @@ window.ReactDOM["default"] = window.ReactDOM;
425
427
}
426
428
427
429
_createClass ( Td , [ {
428
- key : 'handleClick ' ,
429
- value : function handleClick ( e ) {
430
- if ( typeof this . props . handleClick === 'function ') {
431
- return this . props . handleClick ( e , this ) ;
430
+ key : 'stringifyIfNotReactComponent ' ,
431
+ value : function stringifyIfNotReactComponent ( object ) {
432
+ if ( ! ( 0 , _libIs_react_component . isReactComponent ) ( object ) && ( 0 , _libStringable . stringable ) ( object ) && typeof object !== 'undefined ') {
433
+ return object . toString ( ) ;
432
434
}
435
+ return null ;
433
436
}
434
437
} , {
435
438
key : 'render' ,
436
439
value : function render ( ) {
437
- var tdProps = {
438
- className : this . props . className ,
439
- onClick : this . handleClick . bind ( this )
440
- } ;
441
-
442
- if ( typeof this . props . style !== 'undefined' ) {
443
- tdProps . style = this . props . style ;
444
- }
445
-
446
440
// Attach any properties on the column to this Td object to allow things like custom event handlers
441
+ var mergedProps = ( 0 , _libFilter_props_from . filterPropsFrom ) ( this . props ) ;
447
442
if ( typeof this . props . column === 'object' ) {
448
443
for ( var key in this . props . column ) {
449
444
if ( key !== 'key' && key !== 'name' ) {
450
- tdProps [ key ] = this . props . column [ key ] ;
445
+ mergedProps [ key ] = this . props . column [ key ] ;
451
446
}
452
447
}
453
448
}
449
+ // handleClick aliases onClick event
450
+ mergedProps . onClick = this . props . handleClick ;
454
451
455
- var data = this . props . data ;
456
-
457
- if ( typeof this . props . children !== 'undefined' ) {
458
- if ( ( 0 , _libIs_react_component . isReactComponent ) ( this . props . children ) ) {
459
- data = this . props . children ;
460
- } else if ( typeof this . props . data === 'undefined' && ( 0 , _libStringable . stringable ) ( this . props . children ) ) {
461
- data = this . props . children . toString ( ) ;
462
- }
452
+ var stringifiedChildProps ;
463
453
464
- if ( ( 0 , _unsafe . isUnsafe ) ( this . props . children ) ) {
465
- tdProps . dangerouslySetInnerHTML = { __html : this . props . children . toString ( ) } ;
466
- } else {
467
- tdProps . children = data ;
468
- }
454
+ if ( typeof this . props . data === 'undefined' ) {
455
+ stringifiedChildProps = this . stringifyIfNotReactComponent ( this . props . children ) ;
469
456
}
470
457
471
- return _react [ 'default' ] . createElement ( 'td' , tdProps ) ;
458
+ if ( ( 0 , _unsafe . isUnsafe ) ( this . props . children ) ) {
459
+ return _react [ 'default' ] . createElement ( 'td' , _extends ( { } , mergedProps , {
460
+ dangerouslySetInnerHTML : { __html : this . props . children . toString ( ) } } ) ) ;
461
+ } else {
462
+ return _react [ 'default' ] . createElement (
463
+ 'td' ,
464
+ mergedProps ,
465
+ stringifiedChildProps || this . props . children
466
+ ) ;
467
+ }
472
468
}
473
469
} ] ) ;
474
470
0 commit comments