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 _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; }
|
22 |
|
23 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
24 |
|
25 | 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; }
|
26 |
|
27 | 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; }
|
28 |
|
29 | function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
30 |
|
31 | var Container = _styledComponents2.default.div(_templateObject);
|
32 |
|
33 | var Tabs = function (_Component) {
|
34 | _inherits(Tabs, _Component);
|
35 |
|
36 | function Tabs() {
|
37 | var _ref;
|
38 |
|
39 | var _temp, _this, _ret;
|
40 |
|
41 | _classCallCheck(this, Tabs);
|
42 |
|
43 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
44 | args[_key] = arguments[_key];
|
45 | }
|
46 |
|
47 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Tabs.__proto__ || Object.getPrototypeOf(Tabs)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
48 | currentTab: 0
|
49 | }, _this.onTabClick = function (id) {
|
50 | _this.setState({ currentTab: id });
|
51 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
52 | }
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | |
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | _createClass(Tabs, [{
|
75 | key: 'getChildContext',
|
76 | value: function getChildContext() {
|
77 | return {
|
78 | onTabClick: this.onTabClick,
|
79 | currentTab: this.state.currentTab,
|
80 | activeColor: this.props.activeColor,
|
81 | inactiveColor: this.props.inactiveColor,
|
82 | activeBackground: this.props.activeBackground,
|
83 | inactiveBackground: this.props.inactiveBackground
|
84 | };
|
85 | }
|
86 | }, {
|
87 | key: 'render',
|
88 |
|
89 |
|
90 | |
91 |
|
92 |
|
93 |
|
94 |
|
95 | value: function render() {
|
96 | var _props = this.props,
|
97 | children = _props.children,
|
98 | other = _objectWithoutProperties(_props, ['children']);
|
99 |
|
100 | return _react2.default.createElement(
|
101 | Container,
|
102 | other,
|
103 | _react.Children.map(children, function (child, key) {
|
104 | return (0, _react.cloneElement)(child, { key: key });
|
105 | })
|
106 | );
|
107 | }
|
108 | }]);
|
109 |
|
110 | return Tabs;
|
111 | }(_react.Component);
|
112 |
|
113 | Tabs.propTypes = {
|
114 | children: _react.PropTypes.node.isRequired,
|
115 | activeColor: _react.PropTypes.string,
|
116 | inactiveColor: _react.PropTypes.string,
|
117 | activeBackground: _react.PropTypes.string,
|
118 | inactiveBackground: _react.PropTypes.string
|
119 | };
|
120 | Tabs.defaultProps = {
|
121 | activeColor: 'black',
|
122 | inactiveColor: 'white',
|
123 | activeBackground: 'white',
|
124 | inactiveBackground: 'black'
|
125 | };
|
126 | Tabs.childContextTypes = {
|
127 | onTabClick: _react.PropTypes.func.isRequired,
|
128 | currentTab: _react.PropTypes.number.isRequired,
|
129 | activeColor: _react.PropTypes.string.isRequired,
|
130 | inactiveColor: _react.PropTypes.string.isRequired,
|
131 | activeBackground: _react.PropTypes.string.isRequired,
|
132 | inactiveBackground: _react.PropTypes.string.isRequired
|
133 | };
|
134 | exports.default = Tabs; |
\ | No newline at end of file |