1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | 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; }; }();
|
8 |
|
9 | var _templateObject = _taggedTemplateLiteral([''], ['']);
|
10 |
|
11 | var _styledComponents = require('styled-components');
|
12 |
|
13 | var _styledComponents2 = _interopRequireDefault(_styledComponents);
|
14 |
|
15 | var _react = require('react');
|
16 |
|
17 | var _react2 = _interopRequireDefault(_react);
|
18 |
|
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20 |
|
21 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
22 |
|
23 | 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; }
|
24 |
|
25 | 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; }
|
26 |
|
27 | function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
28 |
|
29 | var Container = _styledComponents2.default.div(_templateObject);
|
30 |
|
31 | var Tabs = function (_Component) {
|
32 | _inherits(Tabs, _Component);
|
33 |
|
34 | function Tabs() {
|
35 | var _ref;
|
36 |
|
37 | var _temp, _this, _ret;
|
38 |
|
39 | _classCallCheck(this, Tabs);
|
40 |
|
41 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
42 | args[_key] = arguments[_key];
|
43 | }
|
44 |
|
45 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Tabs.__proto__ || Object.getPrototypeOf(Tabs)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
46 | currentTab: 0
|
47 | }, _this.onTabClick = function (id) {
|
48 | _this.setState({ currentTab: id });
|
49 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
50 | }
|
51 |
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | _createClass(Tabs, [{
|
60 | key: 'getChildContext',
|
61 | value: function getChildContext() {
|
62 | return {
|
63 | onTabClick: this.onTabClick,
|
64 | currentTab: this.state.currentTab
|
65 | };
|
66 | }
|
67 | }, {
|
68 | key: 'render',
|
69 |
|
70 |
|
71 | |
72 |
|
73 |
|
74 |
|
75 |
|
76 | value: function render() {
|
77 | return _react2.default.createElement(
|
78 | Container,
|
79 | null,
|
80 | _react.Children.map(this.props.children, function (child, key) {
|
81 | return (0, _react.cloneElement)(child, { key: key });
|
82 | })
|
83 | );
|
84 | }
|
85 | }]);
|
86 |
|
87 | return Tabs;
|
88 | }(_react.Component);
|
89 |
|
90 | Tabs.propTypes = {
|
91 | children: _react.PropTypes.node.isRequired
|
92 | };
|
93 | Tabs.childContextTypes = {
|
94 | onTabClick: _react.PropTypes.func.isRequired,
|
95 | currentTab: _react.PropTypes.number.isRequired
|
96 | };
|
97 | exports.default = Tabs; |
\ | No newline at end of file |