@bothub-chat/ui
Version:
Bothub UI Components
2 lines (1 loc) • 2.53 kB
JavaScript
import{__rest as e}from"tslib";import{jsxs as o,jsx as t,Fragment as n}from"react/jsx-runtime";import{useState as l,useRef as i,useCallback as r,useEffect as d}from"react";import{useDroppable as s}from"@dnd-kit/core";import{SidebarGroupStyled as c,SidebarGroupNameWithOutline as a,SidebarGroupNameWithBg as p,SidebarGroupName as h,SidebarGroupDragHandle as m,SidebarGroupTooltip as k,SidebarGroupDragFolder as f,SidebarGroupSkeletonIcon as u,SidebarGroupNameBox as v,SidebarGroupArrowDown as b,SidebarGroupSkeleton as x,SidebarChatList as M,SidebarGroupsStyled as $}from"./styled.js";export{SidebarGroupCheckbox,SidebarGroupIconContainer}from"./styled.js";import{Tooltip as j}from"../../tooltip/index.js";import{useSidebar as g}from"../context.js";import{TooltipConsumer as E}from"../../tooltip/context.js";const L=$=>{var{children:L}=$,T=e($,["children"]);const[C,y]=void 0!==T.open?[T.open,T.onHandleOpen]:l(!1),{setNodeRef:D}=s({id:T.skeleton?"draggable-skeleton":T.id}),{isOpen:G}=g(),O=i(null),S=r((()=>{null==y||y(!C)}),[C,y]),[W,w]=l(!0);d((()=>{if(O.current){const{scrollWidth:e,offsetWidth:o}=O.current;w(e<=o)}}),[!T.skeleton&&T.name]);const H=!T.skeleton&&T.edit&&T.over;return o(c,{$over:H,ref:!T.skeleton&&T.edit?D:void 0,children:[!T.isDefault&&t(a,{$active:!T.skeleton&&T.active,$open:C,children:t(p,{children:o(h,{$open:C,$skeleton:!!T.skeleton,$edit:!T.skeleton&&T.edit,onClick:T.skeleton?void 0:S,children:[!T.skeleton&&T.edit&&t(m,{}),!T.skeleton&&t(n,{children:t(k,{label:T.name,placement:"center-right",placementX:15,disabled:T.name.length<=0||G,children:t(E,{children:({handleTooltipMouseEnter:e,handleTooltipMouseLeave:o})=>t(f,{onMouseEnter:e,onMouseLeave:o,fill:T.color})})})}),T.skeleton&&t(u,{width:24,height:24}),!T.skeleton&&t(j,{label:T.name,placement:"top-left",disabled:W,children:t(E,{children:({handleTooltipMouseEnter:e,handleTooltipMouseLeave:o})=>t(v,{ref:O,onMouseEnter:e,onMouseLeave:o,children:T.name})})}),!T.skeleton&&t(b,{}),!T.skeleton&&T.edit&&T.checkbox,!T.skeleton&&!T.edit&&T.actions,T.skeleton&&t(x,{})]})})}),t(M,{$open:T.isDefault||C,children:L})]})},T=({children:e})=>t($,{children:e});export{M as SidebarChatList,L as SidebarGroup,b as SidebarGroupArrowDown,f as SidebarGroupDragFolder,m as SidebarGroupDragHandle,h as SidebarGroupName,v as SidebarGroupNameBox,p as SidebarGroupNameWithBg,a as SidebarGroupNameWithOutline,x as SidebarGroupSkeleton,u as SidebarGroupSkeletonIcon,c as SidebarGroupStyled,k as SidebarGroupTooltip,T as SidebarGroups,$ as SidebarGroupsStyled};