UNPKG

admin-on-rest-fr05t1k

Version:

A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI

27 lines (23 loc) 942 B
import React, { PropTypes } from 'react'; import defaultsDeep from 'lodash.defaultsdeep'; import { TableRowColumn } from 'material-ui/Table'; const DatagridCell = ({ field, record, basePath, resource, style, defaultStyle, ...rest }) => { const computedStyle = defaultsDeep({}, style, field.props.style, field.type.defaultProps ? field.type.defaultProps.style : {}, defaultStyle); return ( <TableRowColumn style={computedStyle} {...rest}> {React.cloneElement(field, { record, basePath, resource })} </TableRowColumn> ); }; DatagridCell.propTypes = { field: PropTypes.element, record: PropTypes.object, // eslint-disable-line react/forbid-prop-types basePath: PropTypes.string, resource: PropTypes.string, style: PropTypes.object, defaultStyle: PropTypes.shape({ td: PropTypes.object, 'td:first-child': PropTypes.object, }), }; export default DatagridCell;