UNPKG

@bothub-chat/ui

Version:

Bothub UI Components

2 lines (1 loc) 823 B
import{jsxs as r,jsx as t,Fragment as e}from"react/jsx-runtime";import{useState as l,useEffect as i}from"react";import{ScrollableTabsTab as a,ScrollableTabsTabLabel as n,ScrollableTabsFullWidth as o}from"./styled.js";import{Slider as d}from"../slider/index.js";const c=({tabs:c,variant:m="primary",component:s="a",selectedTab:p,defaultTabId:f,fullWidth:h,notNullable:u,onClick:b})=>{const[v,y]=l(p||f||null);i(()=>{p&&y(p)},[p]);const $=c.map(({id:e,label:l,icon:i,href:o})=>r(a,{as:s,$variant:m,$selected:e===v,$fullWidth:h,onClick:()=>(r=>{const t=r===v?u?r:null:r;y(t),null==b||b(t)})(e),href:"a"===s?o:void 0,"data-test":l,children:[i,t(n,{$variant:m,children:l})]},e));return t(e,{children:h?t(o,{children:$}):t(d,{arrowsSize:"primary"===m?"md":"sm",gap:"primary"===m?20:8,children:$})})};export{c as ScrollableTabs};