wix-style-react
Version:
wix-style-react
88 lines (72 loc) • 3.57 kB
JavaScript
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; }; }();
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; }
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import * as TabPropTypes from '../constants/tab-prop-types';
import TabItem from '../TabItem';
import withItemMaxWidth from '../withItemMaxWidth';
import styles from '../../Tabs.scss';
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 React.createElement(TabItem, {
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 = classNames(styles.itemsContainer, styles[type]);
return React.createElement(
'ul',
{
className: className,
'data-hook': dataHook,
style: { minWidth: this.props.minWidth }
},
items.map(function (item) {
return _this2.renderItem(item);
})
);
}
}]);
return TabItems;
}(React.Component);
TabItems.propTypes = {
activeId: TabPropTypes.activeId,
dataHook: PropTypes.string,
itemMaxWidth: PropTypes.number,
items: TabPropTypes.items.isRequired,
minWidth: TabPropTypes.width,
type: TabPropTypes.type,
width: TabPropTypes.width,
onClick: TabPropTypes.onClick
};
export default withItemMaxWidth(TabItems);