UNPKG

softchatjs-react

Version:
2 lines 12.6 kB
import{createContext as Z,useContext as A}from"react";import{createContext as T,useContext as V,useState as X}from"react";import{jsx as G}from"react/jsx-runtime";var H=T({activeConversation:null,setActiveConversation:()=>{},conversations:[],setConversations:()=>{},showImageModal:[],setShowImageModal:()=>{},connectionStatus:{isConnected:!1,fetchingConversations:!1,connecting:!1},setConnectionStatus:()=>{}}),p=()=>V(H);var y={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 n1}from"react/jsx-runtime";var z=Z({config:{theme:y},client:null}),c=()=>A(z);import{useState as F,useCallback as W}from"react";import L from"../avartar/avartar.module.module.css";import{jsx as u}from"react/jsx-runtime";var B=({initials:e,url:o,size:t=35})=>{let{client:m,config:i}=c();return o?u("div",{className:L.avatar,style:{height:t,width:t,borderRadius:t},children:u("img",{src:o,alt:"avatar",style:{height:"100%",width:"100%",borderRadius:"100%"}})}):u("div",{className:L.avatar,style:{height:t,width:t,borderRadius:t,backgroundColor:i.theme.background.disabled},children:u("p",{style:{fontSize:35*.5,fontWeight:"bold",textTransform:"capitalize",color:i.theme.text.secondary},children:e})})},g=B;import{jsx as C}from"react/jsx-runtime";var b=e=>{let{size:o=25,color:t="black"}=e;return C("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C("path",{d:"M8.50007 5.5C8.50007 5.36739 8.44739 5.24022 8.35362 5.14645C8.25985 5.05268 8.13268 5 8.00007 5C7.86746 5 7.74028 5.05268 7.64651 5.14645C7.55275 5.24022 7.50007 5.36739 7.50007 5.5V7.5H5.50007C5.36746 7.5 5.24028 7.55268 5.14651 7.64645C5.05275 7.74022 5.00007 7.86739 5.00007 8C5.00007 8.13261 5.05275 8.25979 5.14651 8.35355C5.24028 8.44732 5.36746 8.5 5.50007 8.5H7.50007V10.5C7.50007 10.6326 7.55275 10.7598 7.64651 10.8536C7.74028 10.9473 7.86746 11 8.00007 11C8.13268 11 8.25985 10.9473 8.35362 10.8536C8.44739 10.7598 8.50007 10.6326 8.50007 10.5V8.5H10.5001C10.6327 8.5 10.7599 8.44732 10.8536 8.35355C10.9474 8.25979 11.0001 8.13261 11.0001 8C11.0001 7.86739 10.9474 7.74022 10.8536 7.64645C10.7599 7.55268 10.6327 7.5 10.5001 7.5H8.50007V5.5ZM8.00007 2C6.95912 1.99965 5.93598 2.27012 5.0312 2.78485C4.12641 3.29957 3.37111 4.04083 2.83949 4.9358C2.30788 5.83077 2.01825 6.84864 1.99907 7.88942C1.97988 8.93019 2.2318 9.95805 2.73007 10.872L2.02007 13.362C1.99508 13.4494 1.99442 13.542 2.01814 13.6298C2.04187 13.7176 2.08908 13.7972 2.1547 13.8602C2.22033 13.9231 2.30187 13.967 2.39057 13.9871C2.47926 14.0071 2.57175 14.0026 2.65807 13.974L4.99607 13.195C5.79293 13.6555 6.68504 13.9265 7.60338 13.987C8.52173 14.0475 9.44169 13.896 10.2921 13.5441C11.1425 13.1922 11.9006 12.6494 12.5077 11.9577C13.1147 11.266 13.5545 10.4439 13.7931 9.555C14.0316 8.6661 14.0624 7.73425 13.8832 6.83153C13.704 5.92882 13.3195 5.07943 12.7594 4.34908C12.1994 3.61873 11.4789 3.027 10.6536 2.61967C9.82834 2.21233 8.92041 2.00031 8.00007 2ZM3.00007 8C3.00023 6.8906 3.36935 5.81277 4.04931 4.93618C4.72928 4.05959 5.68146 3.43403 6.75597 3.15799C7.83048 2.88195 8.96627 2.97111 9.98455 3.41142C11.0028 3.85174 11.8457 4.6182 12.3806 5.59015C12.9155 6.5621 13.1119 7.68433 12.9389 8.78017C12.766 9.876 12.2335 10.8832 11.4253 11.6432C10.6172 12.4032 9.57917 12.8728 8.47478 12.9782C7.3704 13.0835 6.26234 12.8185 5.32507 12.225C5.26237 12.1853 5.19161 12.16 5.11793 12.151C5.04424 12.142 4.96948 12.1495 4.89907 12.173L3.24107 12.726L3.75107 10.945C3.76965 10.8794 3.77462 10.8107 3.76568 10.7431C3.75674 10.6755 3.73407 10.6105 3.69907 10.552C3.24112 9.77954 2.99967 8.898 3.00007 8Z",fill:t})})},w=e=>{let{size:o=25,color:t="black"}=e;return C("svg",{width:o,height:o,viewBox:"0 0 20 20",fill:"none",children:C("path",{d:"M14.158 1.02584C14.2838 1.06763 14.3879 1.15768 14.4474 1.2762C14.5068 1.39472 14.5167 1.532 14.475 1.65784L13.975 3.15784C13.9331 3.28382 13.8428 3.38799 13.7241 3.44744C13.6054 3.50689 13.468 3.51675 13.342 3.47484C13.216 3.43294 13.1118 3.34271 13.0524 3.224C12.9929 3.10529 12.9831 2.96782 13.025 2.84184L13.525 1.34184C13.5458 1.27951 13.5786 1.22189 13.6217 1.17226C13.6648 1.12264 13.7172 1.08199 13.776 1.05265C13.8348 1.0233 13.8988 1.00582 13.9643 1.00123C14.0299 0.996627 14.0957 1.00499 14.158 1.02584ZM17.855 2.85384C17.9014 2.80736 17.9382 2.75218 17.9633 2.69147C17.9884 2.63075 18.0013 2.56569 18.0013 2.49999C18.0012 2.43429 17.9882 2.36925 17.963 2.30857C17.9379 2.24789 17.901 2.19277 17.8545 2.14634C17.808 2.09992 17.7528 2.06311 17.6921 2.03801C17.6314 2.01291 17.5663 2.00002 17.5006 2.00007C17.4349 2.00011 17.3699 2.0131 17.3092 2.03828C17.2485 2.06347 17.1934 2.10036 17.147 2.14684L15.147 4.14684C15.0559 4.24115 15.0055 4.36745 15.0066 4.49855C15.0078 4.62964 15.0604 4.75505 15.1531 4.84775C15.2458 4.94046 15.3712 4.99304 15.5023 4.99418C15.6334 4.99532 15.7597 4.94492 15.854 4.85384L17.855 2.85384ZM7.60698 3.14584C7.74648 2.85208 7.95551 2.59676 8.21596 2.40201C8.47641 2.20726 8.78042 2.07897 9.10164 2.02824C9.42287 1.97751 9.75162 2.00587 10.0594 2.11088C10.3672 2.21589 10.6447 2.39436 10.868 2.63084L17.455 9.61084C17.6748 9.84373 17.8355 10.126 17.9235 10.4339C18.0115 10.7418 18.0243 11.0663 17.9608 11.3802C17.8973 11.6941 17.7594 11.9882 17.5586 12.2376C17.3578 12.4871 17.1 12.6847 16.807 12.8138L12.87 14.5498C13.0159 15.0703 13.0395 15.6175 12.9387 16.1486C12.838 16.6797 12.6158 17.1803 12.2895 17.6113C11.9631 18.0422 11.5415 18.3918 11.0576 18.6327C10.5736 18.8736 10.0405 18.9992 9.49998 18.9998C8.90423 19 8.31831 18.848 7.7977 18.5584C7.27709 18.2688 6.83902 17.8511 6.52498 17.3448L5.32498 17.8738C5.04921 17.9953 4.74326 18.0308 4.447 17.9759C4.15073 17.921 3.87787 17.7781 3.66398 17.5658L2.44198 16.3558C2.22101 16.137 2.07355 15.8549 2.01998 15.5485C1.96641 15.2421 2.00939 14.9267 2.14298 14.6458L7.60698 3.14584ZM7.45298 16.9348C7.78487 17.4086 8.27081 17.7527 8.82797 17.9083C9.38512 18.064 9.97901 18.0216 10.5084 17.7884C11.0378 17.5552 11.4699 17.1456 11.7312 16.6294C11.9924 16.1133 12.0665 15.5225 11.941 14.9578L7.45298 16.9348ZM10.141 3.31784C10.0294 3.19969 9.89068 3.11052 9.73687 3.05805C9.58305 3.00557 9.41877 2.99137 9.25823 3.01669C9.0977 3.042 8.94575 3.10605 8.81555 3.20331C8.68534 3.30057 8.5808 3.42809 8.51098 3.57484L3.04598 15.0748C3.00172 15.1684 2.98757 15.2733 3.00548 15.3752C3.02339 15.4772 3.07248 15.571 3.14598 15.6438L4.36798 16.8548C4.4393 16.9253 4.53016 16.9728 4.62878 16.991C4.7274 17.0091 4.8292 16.9973 4.92098 16.9568L16.403 11.8998C16.5495 11.8354 16.6784 11.7366 16.7788 11.612C16.8793 11.4873 16.9483 11.3404 16.9801 11.1835C17.012 11.0266 17.0057 10.8644 16.9618 10.7105C16.9179 10.5565 16.8377 10.4154 16.728 10.2988L10.141 3.31784ZM17 5.99985C16.8674 5.99985 16.7402 6.05252 16.6464 6.14629C16.5527 6.24006 16.5 6.36724 16.5 6.49985C16.5 6.63245 16.5527 6.75963 16.6464 6.8534C16.7402 6.94717 16.8674 6.99985 17 6.99985H18.5C18.6326 6.99985 18.7598 6.94717 18.8535 6.8534C18.9473 6.75963 19 6.63245 19 6.49985C19 6.36724 18.9473 6.24006 18.8535 6.14629C18.7598 6.05252 18.6326 5.99985 18.5 5.99985H17Z",fill:t})})};var M=e=>{let{size:o=25,color:t="black"}=e;return C("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C("path",{d:"M10.75 7C10.75 7.13261 10.6973 7.25979 10.6036 7.35355C10.5098 7.44732 10.3826 7.5 10.25 7.5H6C5.86739 7.5 5.74021 7.44732 5.64645 7.35355C5.55268 7.25979 5.5 7.13261 5.5 7C5.5 6.86739 5.55268 6.74021 5.64645 6.64645C5.74021 6.55268 5.86739 6.5 6 6.5H10.25C10.3826 6.5 10.5098 6.55268 10.6036 6.64645C10.6973 6.74021 10.75 6.86739 10.75 7ZM10.25 8.5H6C5.86739 8.5 5.74021 8.55268 5.64645 8.64645C5.55268 8.74021 5.5 8.86739 5.5 9C5.5 9.13261 5.55268 9.25979 5.64645 9.35355C5.74021 9.44732 5.86739 9.5 6 9.5H10.25C10.3826 9.5 10.5098 9.44732 10.6036 9.35355C10.6973 9.25979 10.75 9.13261 10.75 9C10.75 8.86739 10.6973 8.74021 10.6036 8.64645C10.5098 8.55268 10.3826 8.5 10.25 8.5ZM14.5 7.75C14.4982 9.40704 13.8391 10.9957 12.6674 12.1674C11.4957 13.3391 9.90704 13.9982 8.25 14H3C2.73478 14 2.48043 13.8946 2.29289 13.7071C2.10536 13.5196 2 13.2652 2 13V7.75C2 6.0924 2.65848 4.50268 3.83058 3.33058C5.00268 2.15848 6.5924 1.5 8.25 1.5C9.9076 1.5 11.4973 2.15848 12.6694 3.33058C13.8415 4.50268 14.5 6.0924 14.5 7.75ZM13.5 7.75C13.5 6.35761 12.9469 5.02226 11.9623 4.03769C10.9777 3.05312 9.64239 2.5 8.25 2.5C6.85761 2.5 5.52226 3.05312 4.53769 4.03769C3.55312 5.02226 3 6.35761 3 7.75V13H8.25C9.64193 12.9985 10.9764 12.4449 11.9607 11.4607C12.9449 10.4764 13.4985 9.14193 13.5 7.75Z",fill:t})})};import"./navigation.css";import{useState as B1,useMemo as N1}from"react";import v from"../user-conversations/index.module.module.css";import d from"../text/text.module.module.css";import{jsx as N}from"react/jsx-runtime";var U=e=>{let o={bold:d.textBold,medium:`${d.textMedium}`},t={sm:d.textSmall,md:d.textSizeMd,xs:d.textExtraSmall};return N("p",{style:e.styles,className:`${d.text} ${o[e.weight||"medium"]} ${t[e.size||"md"]}`,children:e.text})},f=U;import S from"dayjs";import v1 from"moment";import E from"dayjs/plugin/localizedFormat";import P from"dayjs/plugin/calendar";S.extend(E);S.extend(P);import{useState as b1}from"react";import{jsx as M1,jsxs as S1}from"react/jsx-runtime";import{IoCloseCircle as $}from"react-icons/io5";import{jsx as r,jsxs as x}from"react/jsx-runtime";var I=({users:e=[],userListRef:o,close:t})=>{let{client:m,config:i}=c(),h=n=>{try{m.newConversation(n,null).create("Hey there \u{1F44B}"),t()}catch(a){console.error(a?.message)}};return x("div",{ref:o,style:{background:i?.theme?.background?.secondary||"#202326"},className:v.userList,children:[x("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:15},children:[r(f,{styles:{color:i?.theme?.text?.primary||"white"},text:"Users"}),r("button",{onClick:t,style:{backgroundColor:"transparent",border:0,cursor:"pointer"},children:r($,{size:22})})]}),r("div",{className:v.scrollbar,style:{overflowY:"scroll",height:"300px"},children:e.map((n,a)=>x("div",{onClick:()=>{h(n)},className:v.userList__wrap,children:[r(g,{initials:n.username.substring(0,1),url:n.profileUrl}),r("div",{className:v.userList__user,style:{marginLeft:"6px"},children:r(f,{size:"sm",text:n.username,styles:{color:i?.theme?.text?.primary||"white"}})})]},a))})]})};import{Fragment as k,jsx as s,jsxs as D}from"react/jsx-runtime";function Y(e){let{client:o,config:t}=c(),{setActiveConversation:m}=p(),[i,h]=F(!1),n=[{label:"Chats",icon:s(M,{color:t.theme.icon,size:25}),key:"conversation-list",onClick:()=>{e.onViewChanged("conversation-list"),m(null)},visible:!0},{label:"New chat",icon:s(b,{color:t.theme.icon,size:25}),key:"new-chat",onClick:()=>h(!0),visible:e.userList.length>0},{label:"Broadcast lists",icon:s(w,{color:t.theme.icon,size:25}),key:"broadcast-lists",onClick:()=>{e.onViewChanged("broadcast-lists"),m(null)},visible:e.enableBroadcasts}];if(e.renderNavbar)return s("div",{style:{height:"100%",maxWidth:"50px",borderRight:`1px solid ${t.theme.divider}`,display:"flex",flexDirection:"column",alignItems:"center"},children:e.renderNavbar(n)});let a=W(()=>s(k,{children:n.filter(l=>l.visible).map((l,R)=>s("button",{className:"nav-btn",style:{borderRight:0,borderTop:0,borderBottom:0,cursor:e.connectionStatus.isConnected?"pointer":"progress",borderLeft:e.activeView===l.key?`2px solid ${t.theme.icon}`:`2px solid ${t.theme.background.secondary}`},title:l.label,onClick:()=>e.connectionStatus.isConnected?l.onClick():null,children:l.icon},R))}),[n,t.theme,e.activeView,e.connectionStatus]);return D(k,{children:[D("div",{style:{height:"100%",width:"50px",backgroundColor:t.theme.background.secondary,borderRight:`1px solid ${t.theme.divider}`,display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"20px",justifyContent:"space-between"},children:[s("label",{title:"Me",children:s(g,{url:e.chatUser.profileUrl,size:30,initials:e.chatUser.username.substring(0,1)})}),s("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:a()})]}),i&&s(I,{users:e.userList,userListRef:null,close:()=>h(!1)})]})}export{Y as default}; //# sourceMappingURL=index.mjs.map