wix-style-react
Version:
86 lines (75 loc) • 3.25 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import React from 'react';
import PropTypes from 'prop-types';
import * as TabPropTypes from '../constants/tab-prop-types';
import TabItem from '../TabItem';
import withItemMaxWidth from '../withItemMaxWidth';
import { st, classes } from '../../Tabs.st.css';
var TabItems = /*#__PURE__*/function (_React$Component) {
_inherits(TabItems, _React$Component);
var _super = _createSuper(TabItems);
function TabItems() {
_classCallCheck(this, TabItems);
return _super.apply(this, arguments);
}
_createClass(TabItems, [{
key: "renderItem",
value: function renderItem(item) {
var _this$props = this.props,
activeId = _this$props.activeId,
type = _this$props.type,
width = _this$props.width,
onClick = _this$props.onClick,
itemMaxWidth = _this$props.itemMaxWidth,
size = _this$props.size;
return /*#__PURE__*/React.createElement(TabItem, {
key: item.id,
dataHook: item.dataHook,
item: item,
itemMaxWidth: itemMaxWidth,
isActive: activeId === item.id,
type: type,
width: width,
onItemClick: onClick,
size: size
});
}
}, {
key: "render",
value: function render() {
var _this = this;
var _this$props2 = this.props,
items = _this$props2.items,
type = _this$props2.type,
dataHook = _this$props2.dataHook;
return /*#__PURE__*/React.createElement("ul", {
"data-type": type,
"data-hook": dataHook,
className: st(classes.itemsContainer, classes[type]),
style: {
minWidth: this.props.minWidth
}
}, items.map(function (item) {
return _this.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);