wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
39 lines • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importDefault(require("react"));
var classnames_1 = tslib_1.__importDefault(require("classnames"));
var prop_types_1 = tslib_1.__importDefault(require("prop-types"));
var TabPropTypes = tslib_1.__importStar(require("../constants/tab-prop-types"));
var TabItem_1 = tslib_1.__importDefault(require("../TabItem"));
var withItemMaxWidth_1 = tslib_1.__importDefault(require("../withItemMaxWidth"));
var styles_scss_1 = tslib_1.__importDefault(require("../../styles.scss"));
var TabItems = /** @class */ (function (_super) {
tslib_1.__extends(TabItems, _super);
function TabItems() {
return _super !== null && _super.apply(this, arguments) || this;
}
TabItems.prototype.renderItem = function (item) {
var _a = this.props, activeId = _a.activeId, type = _a.type, width = _a.width, onClick = _a.onClick, itemMaxWidth = _a.itemMaxWidth;
return (react_1.default.createElement(TabItem_1.default, { key: item.id, dataHook: item.dataHook, item: item, itemMaxWidth: itemMaxWidth, isActive: activeId === item.id, type: type, width: width, onItemClick: onClick }));
};
TabItems.prototype.render = function () {
var _this = this;
var _a = this.props, items = _a.items, type = _a.type, dataHook = _a.dataHook;
var className = (0, classnames_1.default)(styles_scss_1.default.itemsContainer, styles_scss_1.default[type]);
return (react_1.default.createElement("ul", { className: className, "data-hook": dataHook, style: { minWidth: this.props.minWidth } }, items.map(function (item) { return _this.renderItem(item); })));
};
return TabItems;
}(react_1.default.Component));
TabItems.propTypes = {
activeId: TabPropTypes.activeId,
dataHook: prop_types_1.default.string,
itemMaxWidth: prop_types_1.default.number,
items: TabPropTypes.items.isRequired,
minWidth: TabPropTypes.width,
type: TabPropTypes.type,
width: TabPropTypes.width,
onClick: TabPropTypes.onClick,
};
exports.default = (0, withItemMaxWidth_1.default)(TabItems);
//# sourceMappingURL=index.js.map