dh-c
Version:
The front-end development engineers jimberton gulp react component
80 lines (58 loc) • 2.8 kB
JavaScript
;
exports.__esModule = true;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _cell = require('./cell');
var _cell2 = _interopRequireDefault(_cell);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var DatasheetRow = function (_React$Component) {
_inherits(DatasheetRow, _React$Component);
function DatasheetRow(props) {
_classCallCheck(this, DatasheetRow);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
_this.state = {
data: []
};
return _this;
}
DatasheetRow.prototype.componentWillMount = function componentWillMount() {
if (this.props.data && Array.isArray(this.props.data)) {
this.state.data = this.props.data;
}
};
DatasheetRow.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return nextProps.index === this.props.index;
};
DatasheetRow.prototype.render = function render() {
var _this2 = this;
// const data = this.state.data;
var _props = this.props,
index = _props.index,
data = _props.data;
return _react2.default.createElement(
'tr',
null,
data.map(function (item, idx) {
return _react2.default.createElement(_cell2.default, {
key: 'datasheet-cell-' + idx,
index: idx,
rIndex: index,
selected: item.selected,
editable: item.editable,
value: item.value,
readOnly: item.readOnly,
onChange: _this2.props.onChange,
onClick: _this2.props.onSelectCell,
onDoubleClick: _this2.props.onDoubleClick
});
})
);
};
return DatasheetRow;
}(_react2.default.Component);
exports.default = DatasheetRow;