UNPKG

4.12 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _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; };
8
9var _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; }; }();
10
11var _react = require('react');
12
13var _react2 = _interopRequireDefault(_react);
14
15var _types = require('./types');
16
17function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
20
21function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
23function _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; }
24
25function _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; }
26
27var BodyWrapper = function (_React$Component) {
28 _inherits(BodyWrapper, _React$Component);
29
30 function BodyWrapper(props) {
31 _classCallCheck(this, BodyWrapper);
32
33 var _this = _possibleConstructorReturn(this, (BodyWrapper.__proto__ || Object.getPrototypeOf(BodyWrapper)).call(this, props));
34
35 _this.ref = null;
36 return _this;
37 }
38
39 _createClass(BodyWrapper, [{
40 key: 'render',
41 value: function render() {
42 var _this2 = this;
43
44 var _props = this.props,
45 children = _props.children,
46 props = _objectWithoutProperties(_props, ['children']);
47
48 var _context = this.context,
49 startHeight = _context.startHeight,
50 endHeight = _context.endHeight,
51 showExtraRow = _context.showExtraRow;
52
53 var startRow = tr({
54 key: 'start-row',
55 style: {
56 height: startHeight
57 }
58 });
59 var endRow = tr({
60 key: 'end-row',
61 style: {
62 height: endHeight
63 }
64 });
65 // Extra row to keep onRow indexing stable instead of even/odd. This is important
66 // for styling.
67 var rows = [startRow].concat(children).concat(endRow);
68
69 if (showExtraRow) {
70 rows.unshift(tr({
71 key: 'extra-row',
72 style: {
73 height: 0
74 }
75 }));
76 }
77
78 return _react2.default.createElement('tbody', _extends({}, props, {
79 ref: function ref(e) {
80 _this2.ref = e;
81 }
82 }), rows);
83 }
84 }, {
85 key: 'getRef',
86 value: function getRef() {
87 return this.ref;
88 }
89 }]);
90
91 return BodyWrapper;
92}(_react2.default.Component);
93
94BodyWrapper.contextTypes = _types.bodyWrapperContextTypes;
95process.env.NODE_ENV !== "production" ? BodyWrapper.propTypes = _types.bodyWrapperTypes : void 0;
96
97function tr(props) {
98 return _react2.default.createElement('tr', props);
99}
100
101exports.default = BodyWrapper;
\No newline at end of file