UNPKG

@legion-ui-kit/react-core

Version:

To install the package into your project:

4 lines (3 loc) 1.28 kB
"use client"; import{jsx as e}from"react/jsx-runtime";import{useState as t,Children as s,useEffect as i}from"react";import r from"classnames";import o from"./styles/styles.module.scss.js";import a from"./TabPanel.js";import{snakeCase as l}from"../../helpers/typography.js";import{checkComponent as n}from"../../helpers/internal.js";import{TAB_PANEL_LIST_DEFAULT_PROPS as m,TABS_MOVEMENT as c,TABS_ANIMATION_DURATION as p,TABS_ANIMATION_DELAY as d,TAB_PANEL_SLIDE_DIRECTION as f,TAB_PANEL_DISPLAY_NAME as u}from"./Tab.constant.js";const h=h=>{const{activePanel:v=m.activePanel,children:y,className:g,slideDirection:j=m.slideDirection,style:N,...T}=h,b=j===f.horizontal,[D,P]=t(c.idle),[_,x]=t([v]),L=r(o.legion_tab_panel_list,g,o[D],{[o.vertical]:!b}),w=s.toArray(y).filter(e=>n(e,u));return i(()=>{const[e]=_;let t;e<v?(t=b?c.movingLeft:c.movingDown,x([e,v])):e>v?(t=b?c.movingRight:c.movingUp,x([v,e])):(t=c.idle,x([v])),P(l(t));const s=setTimeout(()=>{P(c.idle),x([v])},p+d);return()=>{clearTimeout(s)}},[v]),e("div",{className:L,style:{animationDuration:`${p}ms`,...N},...T,children:_.map(t=>{const{className:s,...i}=w[t].props,l=r(o.panel_child,s);return e(a,{className:l,...i},t)})})};h.displayName="TabPanelList";export{h as default}; //# sourceMappingURL=TabPanelList.js.map