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.84 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),a=require("@mui/material/Stack"),n=require("@mui/material/Card"),i=require("@mui/material/CardContent"),o=require("clsx"),r=require("./CommentCard.styles.js"),s=require("../../locales/index.js"),d=require("../locale.json.js"),l=require("./CommentCardHeader.js"),u=require("./CommentCardContent.js"),c=require("../CommentField/CommentField.container.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var C=m(a),g=m(n),h=m(i),p=m(o);const x=(e,t)=>{if(e.length<1)return[];const a=[];return e.forEach((e=>{a.find((t=>t.id===e.id))||e.id===t.id||a.push(e)})),a};exports.CommentCardComponent=a=>{const{id:n,author:i,participants:o=[],statusMapping:m,dateModified:f,stackDate:v=!0,message:j,attachments:q=[],tags:S=[],metadata:y,tagging:M=!1,onTagCancel:b,highlight:k,maxLines:E=3,replies:R=0,actions:T=[],disableHover:w,selected:H,unread:L,resolved:P,canResolve:F,onResolved:A=()=>{},onUnresolved:I=()=>{},onLayoutChange:N,onSelected:D,editing:U,onEditCancel:_,onEditSave:O,mode:z="plaintext",richTextConfig:B,sx:G={},...J}=a,K=T.length>0,Q=v||w,V=t.useMemo((()=>x(o,i)),[o,i]),W=s.useTranslate(d.default),X=t.useRef(null),[Y,Z]=t.useState(!1),[$,ee]=t.useState(!1),[te,ae]=t.useState(!1),ne=t.useCallback((()=>{if(!X.current)return;const e=X.current?.scrollHeight||parseInt(window.getComputedStyle(X.current).height,10),t=parseInt(window.getComputedStyle(X.current).lineHeight,10);Z(e>t*E),ee(!!H)}),[E,j,H]);t.useEffect((()=>{ne()}),[ne]);const ie=U?e.jsx(C.default,{direction:"row",sx:{alignItems:"center",mb:4},onClick:e=>{e.stopPropagation()},children:e.jsx(c.CommentFieldContainer,{author:i,richTextConfig:B,initialComment:j,initialAttachments:q,initialTags:S,initialMetadata:y,onSave:O,onCancel:_,onCommentChange:()=>{N?.()},mode:z,state:"edit"})}):e.jsxs(e.Fragment,{children:[e.jsx(l.CommentCardHeader,{id:n,author:i,unread:L,editing:U,uniqueParticipants:V,statusMapping:m,shouldStackDate:Q,hovering:te,hasActions:K,canResolve:F,resolved:P,dateModified:f,disableHover:w,actions:T,onUnresolved:I,onResolved:A,t:W}),e.jsx(u.CommentCardContent,{multiRowRef:X,expanded:$,expandable:Y,onExpandClick:e=>{e.stopPropagation(),ee((e=>!e)),N?.()},maxLines:E,message:j,attachments:q,tags:S,metadata:y,tagging:M,onTagCancel:b,highlight:k,selected:H,replies:R,mode:z,onEditSave:O,richTextConfig:B,onLayoutChange:N,t:W})]});return e.jsx(g.default,{"data-testid":"CommentCard",...J,sx:[r.styles.card,G],className:p.default({[r.classes.active]:H,[r.classes.clickable]:(D||K||F)&&!U&&!w},"NexusCommentCard-root"),elevation:0,onClick:D&&!U?e=>D(n,e):void 0,onMouseEnter:w?void 0:()=>ae(!0),onMouseLeave:()=>ae(!1),children:e.jsx(h.default,{sx:{px:6,py:4},children:ie})})},exports.getNonAuthorParticipants=x;