1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _isEqual2 = require('lodash/isEqual');
|
8 |
|
9 | var _isEqual3 = _interopRequireDefault(_isEqual2);
|
10 |
|
11 | 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; };
|
12 |
|
13 | 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; }; }();
|
14 |
|
15 | var _react = require('react');
|
16 |
|
17 | var _react2 = _interopRequireDefault(_react);
|
18 |
|
19 | var _reactabularTable = require('reactabular-table');
|
20 |
|
21 | var _types = require('./types');
|
22 |
|
23 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
24 |
|
25 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
26 |
|
27 | 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; }
|
28 |
|
29 | 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; }
|
30 |
|
31 | var BodyRow = function (_React$Component) {
|
32 | _inherits(BodyRow, _React$Component);
|
33 |
|
34 | function BodyRow(props) {
|
35 | _classCallCheck(this, BodyRow);
|
36 |
|
37 | var _this = _possibleConstructorReturn(this, (BodyRow.__proto__ || Object.getPrototypeOf(BodyRow)).call(this, props));
|
38 |
|
39 | _this.ref = null;
|
40 |
|
41 | _this.updateHeight = _this.updateHeight.bind(_this);
|
42 | return _this;
|
43 | }
|
44 |
|
45 | _createClass(BodyRow, [{
|
46 | key: 'componentDidMount',
|
47 | value: function componentDidMount() {
|
48 | this.updateHeight();
|
49 | }
|
50 | }, {
|
51 | key: 'componentDidUpdate',
|
52 | value: function componentDidUpdate() {
|
53 |
|
54 |
|
55 |
|
56 | if (this.context.initialMeasurement) {
|
57 | this.updateHeight();
|
58 | }
|
59 | }
|
60 | }, {
|
61 | key: 'render',
|
62 | value: function render() {
|
63 | var _this2 = this;
|
64 |
|
65 | return _react2.default.createElement('tr', _extends({}, this.props, {
|
66 | ref: function ref(e) {
|
67 | if (e) {
|
68 | _this2.ref = e;
|
69 | }
|
70 | }
|
71 | }));
|
72 | }
|
73 | }, {
|
74 | key: 'updateHeight',
|
75 | value: function updateHeight() {
|
76 | this.context.updateHeight(this.props['data-rowkey'], this.ref.offsetHeight);
|
77 | }
|
78 | }]);
|
79 |
|
80 | return BodyRow;
|
81 | }(_react2.default.Component);
|
82 |
|
83 | BodyRow.contextTypes = _types.bodyRowContextTypes;
|
84 | process.env.NODE_ENV !== "production" ? BodyRow.propTypes = _types.bodyRowTypes : void 0;
|
85 |
|
86 | BodyRow.shouldComponentUpdate = function (nextProps) {
|
87 | var previousProps = this.props;
|
88 |
|
89 |
|
90 |
|
91 | if (nextProps.rowData._measured) {
|
92 | return !((0, _reactabularTable.columnsAreEqual)(previousProps.columns, nextProps.columns) && (0, _isEqual3.default)(previousProps.rowData, nextProps.rowData));
|
93 | }
|
94 |
|
95 | return true;
|
96 | };
|
97 |
|
98 | exports.default = BodyRow; |
\ | No newline at end of file |