UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

2 lines (1 loc) 2.13 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/Box"),i=require("@mui/material/Stack"),o=require("../../../locales/index.js"),n=require("../../locale.json.js"),a=require("../../CommentCard/CommentCard.container.js"),s=require("../../CommentField/CommentField.container.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=d(t),c=d(i);const m="NexusCommentThreadItem",u=r.forwardRef(((t,i)=>{const{currentUser:d,expanded:u,comment:p,onReplyAdd:C,onClick:h,mode:x,richTextConfig:g,onReplyEditing:f,...j}=t,v=p.replies?p.replies.length:0,y=u&&v>0,[b,q]=r.useState(""),R=o.useTranslate(n.default),T=r.useRef();return r.useImperativeHandle(i,(()=>({scrollToEnd(){T.current&&T.current.scrollIntoView({behavior:"smooth"})}})),[]),e.jsxs(l.default,{"data-testid":`${m}-root`,className:`${m}-root`,onClick:p.editing?void 0:()=>h?.(p),ref:i,...j,children:[e.jsxs(c.default,{className:`${m}-commentList`,children:[e.jsxs(l.default,{children:[e.jsx(a.CommentCardContainer,{...p,canResolve:p.canResolve??!0,replies:u?0:v,participants:u?[]:p.participants,disableHover:!!p.selected,mode:x,richTextConfig:g,sx:{backgroundColor:"inherit","& .MuiCardContent-root":{padding:e=>e.spacing(4,5,u?3:5,5)}}},p.id),y&&p?.replies?.map((r=>e.jsx(a.CommentCardContainer,{...r,sx:{backgroundColor:"inherit","& .MuiCardContent-root":{padding:e=>e.spacing(4,5)}},canResolve:!1,disableHover:!0,mode:x,richTextConfig:g,highlight:p.highlight,onSelected:(e,t)=>{t.stopPropagation(),h(p,r)},selected:!0},r.id)))]}),e.jsx(l.default,{ref:T})]}),(u||b)&&e.jsx(l.default,{"data-testid":`${m}-replyField`,className:`${m}-replyField`,sx:{width:"100%",display:u?"normal":"none",backgroundColor:u&&0===v?e=>`rgba(${e.vars.palette.primary.mainChannel} / 0.04)`:"inherit"},onClick:e=>e.stopPropagation(),children:e.jsx(s.CommentFieldContainer,{author:d,onSave:(e,r,t,i)=>C(p.id,e,r,t,i),onCommentChange:(e,r,t,i)=>{q(e),f?.(p.id,e,r,t,i)},sx:{px:5,py:4},mode:x,richTextConfig:g,placeholder:R("Reply")})})]},p.id)}));exports.CommentThreadItem=u;