UNPKG

zent

Version:

一套前端设计语言和基于React的实现

64 lines (54 loc) 1.32 kB
import React, { PureComponent, Component } from 'react'; import forEach from 'lodash/forEach'; import isFunction from 'lodash/isFunction'; import classnames from 'classnames'; import Cell from './Cell'; class Row extends (PureComponent || Component) { render() { const { prefix, columns, data, rowIndex, rowClassName, onRowClick, fixed, fixedColumnsBodyRowsHeight } = this.props; const cells = []; const className = isFunction(rowClassName) ? rowClassName(data, rowIndex) : rowClassName; let height = null; forEach(columns, (column, columnIndex) => { let pos = { row: rowIndex, column: columnIndex }; height = fixed && fixedColumnsBodyRowsHeight[columnIndex] ? fixedColumnsBodyRowsHeight[columnIndex] : null; cells.push( <Cell column={column} data={data} pos={pos} columnIndex={columnIndex} key={columnIndex} prefix={prefix} /> ); }); return ( <tr className={classnames(`${prefix}-grid-tr`, className)} onClick={e => onRowClick(data, rowIndex, e)} style={{ height }} > {cells} </tr> ); } } export default Row;