UNPKG

3.26 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 React = _interopRequireWildcard(_react);
14
15function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
16
17function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
19function _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; }
20
21function _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; }
22
23var PanelList = function (_React$PureComponent) {
24 _inherits(PanelList, _React$PureComponent);
25
26 function PanelList() {
27 _classCallCheck(this, PanelList);
28
29 return _possibleConstructorReturn(this, (PanelList.__proto__ || Object.getPrototypeOf(PanelList)).apply(this, arguments));
30 }
31
32 _createClass(PanelList, [{
33 key: 'render',
34 value: function render() {
35 var _props = this.props,
36 children = _props.children,
37 activeIndex = _props.activeIndex,
38 customStyle = _props.customStyle;
39
40 if (!children || activeIndex === undefined) {
41 return null;
42 }
43
44 var props = {};
45 if (customStyle && customStyle.Panel) {
46 props = _extends({}, props, { CustomPanelStyle: customStyle.Panel });
47 }
48
49 return children.map(function (child, index) {
50 return React.cloneElement(child, _extends({
51 key: index,
52 active: index === activeIndex,
53 index: index
54 }, props));
55 });
56 }
57 }]);
58
59 return PanelList;
60}(React.PureComponent);
61
62exports.default = PanelList;
63module.exports = exports['default'];
\No newline at end of file