UNPKG

softchatjs-react

Version:
2 lines 3.59 kB
import{useEffect as R,useState as V}from"react";import f from"./broadcast-lists.module.module.css";import{jsx as m}from"react/jsx-runtime";var v=e=>{let{size:i=25,color:t="black"}=e;return m("svg",{width:i,height:i*2,viewBox:"0 0 12 24",fill:"none",children:m("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.1569 12.7111L4.49994 18.3681L3.08594 16.9541L8.03594 12.0041L3.08594 7.05414L4.49994 5.64014L10.1569 11.2971C10.3444 11.4847 10.4497 11.739 10.4497 12.0041C10.4497 12.2693 10.3444 12.5236 10.1569 12.7111Z",fill:t})})};import{createContext as y,useContext as S}from"react";import{createContext as b,useContext as w,useState as D}from"react";import{jsx as _}from"react/jsx-runtime";var M=b({activeConversation:null,setActiveConversation:()=>{},conversations:[],setConversations:()=>{},showImageModal:[],setShowImageModal:()=>{},connectionStatus:{isConnected:!1,fetchingConversations:!1,connecting:!1},setConnectionStatus:()=>{}}),g=()=>w(M);var L={background:{primary:"#1b1d21",secondary:"#202326",disabled:"#E0E0E0"},text:{primary:"white",secondary:"#4A4A4A",disabled:"#9E9E9E"},action:{primary:"#007AFF",secondary:"#5AA3FF"},chatBubble:{left:{bgColor:"#343434",messageColor:"white",messageTimeColor:"#6D6D6D",replyBorderColor:"#D1D1D6"},right:{bgColor:"#343434",messageColor:"white",messageTimeColor:"#6D6D6D",replyBorderColor:"#A3D1FF"}},icon:"white",divider:"rgba(128, 128, 128, 0.136)",hideDivider:!1,input:{bgColor:"#1b1d21",textColor:"white",emojiPickerTheme:"dark"}};import{jsx as j}from"react/jsx-runtime";var I=y({config:{theme:L},client:null}),p=()=>S(I);import s from"../text/text.module.module.css";import{jsx as H}from"react/jsx-runtime";var Z=e=>{let i={bold:s.textBold,medium:`${s.textMedium}`},t={sm:s.textSmall,md:s.textSizeMd,xs:s.textExtraSmall};return H("p",{style:e.styles,className:`${s.text} ${i[e.weight||"medium"]} ${t[e.size||"md"]}`,children:e.text})},l=Z;import{PiPlusCircle as B}from"react-icons/pi";import{jsx as C,jsxs as r}from"react/jsx-runtime";function A(e){let{onCreateBroadcastList:i}=e,{client:t,config:n}=p(),{setActiveConversation:u}=g(),[c,d]=V([]),h=o=>{let a=Object.values(o.broadcastListMeta).flat();d(a)},x=()=>{try{let o=t.getBroadcastLists(),a=Object.values(o).flat();d(a)}catch{}};return R(()=>(t&&(x(),t.subscribe("broadcast_list_meta_changed",h)),()=>{t.unsubscribe("broadcast_list_meta_changed",h)}),[t]),r("main",{className:f.broadcast_container,style:{borderRight:`1px solid ${n.theme.divider}`,backgroundColor:n.theme.background.secondary,padding:"20px"},children:[r("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",alignItems:"center"},children:[C("p",{style:{fontWeight:"bold",fontSize:"26px"},children:"Broadcast lists"}),C("button",{onClick:()=>i?.(),style:{border:0,backgroundColor:"transparent"},children:C(B,{size:22,color:n.theme.icon})})]}),r("div",{style:{},children:[c.length===0&&C("div",{style:{flex:1,height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:C(l,{styles:{textAlign:"left",marginRight:"15px",color:n.theme.text.disabled},size:"sm",text:"No broadcast lists available yet"})}),c.length>0&&c.map((o,a)=>r("div",{className:f.broadcast_item,onClick:()=>u(o),children:[r("div",{children:[C(l,{styles:{textAlign:"left",marginRight:"15px",color:n.theme.text.primary},size:"md",text:o.conversation.name}),C(l,{styles:{textAlign:"left",marginRight:"15px",color:n.theme.text.disabled},size:"sm",text:`${o.conversation.participants.length} recipients`})]}),C(v,{size:10,color:n.theme.icon})]},a))]})]})}export{A as default}; //# sourceMappingURL=index.mjs.map