@legion-ui-kit/react-core
Version:
To install the package into your project:
3 lines (2 loc) • 1.23 kB
JavaScript
import{jsx as s}from"react/jsx-runtime";import{Children as t,createElement as a}from"react";import e from"classnames";import o from"./styles/styles.module.scss.js";import r from"./TabList.js";import i from"./TabPanelList.js";import{isFunction as m}from"../../helpers/typeChecker.js";import{checkComponent as l}from"../../helpers/internal.js";import{checkTabsChildren as n}from"./Tabs.helper.js";import{TABS_DEFAULT_PROPS as c,TAB_PANEL_SLIDE_DIRECTION as p,TABS_POSITION as b,TAB_LIST_DISPLAY_NAME as f,TAB_PANEL_LIST_DISPLAY_NAME as h}from"./Tab.constant.js";const j=j=>{const{activeTab:T=c.activeTab,children:d,className:N,onChange:u,position:v=c.position,...y}=j,_=e(o.legion_tabs,N,o[v]),g=s=>{m(u)&&u(s)};return s("div",{className:_,...y,children:t.toArray(d).filter(s=>n(s)).map((t,m)=>{if(l(t,f)){const{className:s,...i}=t.props,l=e(o.tab_list_section,s);return a(r,{...i,key:`tabs-tab-list-${m}`,className:l,activeTab:T,onChange:g})}if(l(t,h)){const{className:a,...r}=t.props,l=e(o.panel_list_section,a),n=`tabs-panel-list-${m}`,c=v===b.top||v===b.bottom?p.horizontal:p.vertical;return s(i,{...r,className:l,activePanel:T,slideDirection:c},n)}})})};j.displayName="Tabs";export{j as default};
//# sourceMappingURL=Tabs.js.map