myprojectpackageprav
Version:
My package in npm
35 lines • 3.16 kB
JavaScript
import { __spreadArray } from "tslib";
import React, { useState } from "react";
import './tabs.css';
export default function Tabs(props) {
var _a = useState(props.items), items = _a[0], setItems = _a[1];
function show(event, index) {
var tabs = items;
tabs.map(function (item, index_item) {
item['is_active'] = 'false';
if (index === index_item) {
item['is_active'] = 'true';
}
return item;
});
setItems(__spreadArray([], tabs, true));
}
return (React.createElement("div", { className: "tabs" },
React.createElement("div", { className: (props === null || props === void 0 ? void 0 : props.className) ? "customTabs ".concat(props === null || props === void 0 ? void 0 : props.className) : 'customTabs' },
React.createElement("ul", { className: props === null || props === void 0 ? void 0 : props.tabsul },
React.createElement("div", { className: (props === null || props === void 0 ? void 0 : props.tablistclassName) ? "customTabs-list ".concat(props === null || props === void 0 ? void 0 : props.tablistclassName) : 'customTabs-list' }, items.map(function (item, index) {
return (React.createElement("li", null,
React.createElement("a", { tabIndex: 0, href: "javascript:void(0)", title: (item === null || item === void 0 ? void 0 : item.title) || (item === null || item === void 0 ? void 0 : item.tabtitle), key: index, onClick: function (event) { return show(event, index); }, className: item['is_active'] === 'true' ? (props === null || props === void 0 ? void 0 : props.anchorclass) ? "active ".concat(props === null || props === void 0 ? void 0 : props.anchorclass) : 'active' : (props === null || props === void 0 ? void 0 : props.anchorclass) ? "".concat(props === null || props === void 0 ? void 0 : props.anchorclass) : '' },
(item === null || item === void 0 ? void 0 : item.icon) && React.createElement("span", { className: item === null || item === void 0 ? void 0 : item.icon }),
" ", item === null || item === void 0 ? void 0 :
item.tabtitle,
" ",
(props === null || props === void 0 ? void 0 : props.badge) && React.createElement("span", { className: props === null || props === void 0 ? void 0 : props.badge }, item === null || item === void 0 ? void 0 : item.count))));
})), props === null || props === void 0 ? void 0 :
props.isButtons)),
React.createElement("div", { className: props === null || props === void 0 ? void 0 : props.tabscontentarea }, items.map(function (item, index) {
return (React.createElement("div", { key: index, className: "customTabs-content ".concat(item['is_active'] === 'true' ? 'active' : '') },
React.createElement("div", { className: props === null || props === void 0 ? void 0 : props.contentstyles }, item === null || item === void 0 ? void 0 : item.content)));
}))));
}
//# sourceMappingURL=tabs.js.map