UNPKG

wix-style-react

Version:
117 lines (85 loc) 4.54 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); 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; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _tabPropTypes = require('../constants/tab-prop-types'); var TabPropTypes = _interopRequireWildcard(_tabPropTypes); var _TabItem = require('../TabItem'); var _TabItem2 = _interopRequireDefault(_TabItem); var _withItemMaxWidth = require('../withItemMaxWidth'); var _withItemMaxWidth2 = _interopRequireDefault(_withItemMaxWidth); var _Tabs = require('../../Tabs.scss'); var _Tabs2 = _interopRequireDefault(_Tabs); function _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; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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; } 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; } var TabItems = function (_React$Component) { _inherits(TabItems, _React$Component); function TabItems() { _classCallCheck(this, TabItems); return _possibleConstructorReturn(this, (TabItems.__proto__ || Object.getPrototypeOf(TabItems)).apply(this, arguments)); } _createClass(TabItems, [{ key: 'renderItem', value: function renderItem(item) { var _props = this.props, activeId = _props.activeId, type = _props.type, width = _props.width, onClick = _props.onClick, itemMaxWidth = _props.itemMaxWidth; return _react2.default.createElement(_TabItem2.default, { key: item.id, dataHook: item.dataHook, item: item, itemMaxWidth: itemMaxWidth, isActive: activeId === item.id, type: type, width: width, onItemClick: onClick }); } }, { key: 'render', value: function render() { var _this2 = this; var _props2 = this.props, items = _props2.items, type = _props2.type, dataHook = _props2.dataHook; var className = (0, _classnames2.default)(_Tabs2.default.itemsContainer, _Tabs2.default[type]); return _react2.default.createElement( 'ul', { className: className, 'data-hook': dataHook, style: { minWidth: this.props.minWidth } }, items.map(function (item) { return _this2.renderItem(item); }) ); } }]); return TabItems; }(_react2.default.Component); TabItems.propTypes = { activeId: TabPropTypes.activeId, dataHook: _propTypes2.default.string, itemMaxWidth: _propTypes2.default.number, items: TabPropTypes.items.isRequired, minWidth: TabPropTypes.width, type: TabPropTypes.type, width: TabPropTypes.width, onClick: TabPropTypes.onClick }; exports.default = (0, _withItemMaxWidth2.default)(TabItems);