@corva/ui 0.60.0-rc.0 → 0.60.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),a=require("prop-types"),i=require("react-player"),s=require("@material-ui/core/styles"),r=require("@material-ui/core/Typography"),l=require("@material-ui/core"),n=require("@material-ui/icons/Image"),o=require("@material-ui/icons/SaveAlt"),c=require("@material-ui/icons/Fullscreen"),d=require("@material-ui/core/colors/grey"),u=require("../FileTypeIcon.js"),m=require("../ImageViewer/index.js"),h=require("../GoogleDocsViewer/index.js"),p=require("../IconButton/index.js"),g=require("../../utils/mobileDetect.js"),f=require("../../utils/fileExtension.js");require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions.js"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../utils/env.js"),require("../GradientManager/configuration/constants.js");var x=require("../../effects/useSignedURL.js");require("../../utils/index.js"),require("uuid"),require("jsona"),require("../StatusBadge/constants.js");var j=require("../../utils/main.js"),v=require("./styles.css.js"),q=require("react/jsx-runtime");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=b(e),w=b(a),y=b(i),I=b(r),A=b(n),F=b(o),P=b(c),S=b(d),D=S.default[200],L=S.default[400],W={label:"small",value:135},z={label:"medium",value:300},U={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===W.label?W.value:z.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:D,borderRadius:3,marginTop:10,height:135,width:135}},R=function(e){return q.jsxs(q.Fragment,{children:[q.jsxs("div",{onClick:e.openLightbox,className:v.cAttachmentImg,children:[q.jsx("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:U.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),q.jsx("div",{"data-testid":"".concat("Attachment","_button"),className:v.cAttachmentImgPreviwBtn,children:q.jsx(P.default,{})})]}),!e.imageIsLoaded&&q.jsx("div",{style:U.imagePlaceholder,children:q.jsx(A.default,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:L,fontSize:"large"})}),e.lightboxIsOpen&&q.jsx(m,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},C=function(e){var t=x(e.attachmentFileName);return q.jsxs("div",{className:v.cAttachmentFileWrapper,children:[q.jsxs("div",{className:v.cAttachmentFileDownloadWrapper,style:U.fileDownloadWrapper,onClick:e.openPreview,children:[q.jsx(u,{fileName:e.displayName||e.attachmentUrl,className:v.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),q.jsx("div",{"data-testid":"".concat("Attachment","_name"),className:v.cAttachmentFileDownloadWrapperFileName,children:q.jsx(I.default,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:j.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),q.jsx(l.Dialog,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g.isNativeDetected?e.classes.nativeDialog:e.classes.dialog},children:q.jsx(h,{fileUrl:e.attachmentUrl,fileName:j.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),q.jsx("a",{download:e.displayName,href:t,className:v.cAttachmentFileDownloadWrapperForm,children:q.jsx(p,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:q.jsx(F.default,{className:e.classes.downloadIcon})})})]})};function O(e){var a=t.useState(!1),i=N.default(a,2),s=i[0],r=i[1],l=t.useState(!1),n=N.default(l,2),o=n[0],c=n[1],d=t.useState(!1),u=N.default(d,2),m=u[0],h=u[1],p=e.displayName||e.attachmentUrl||e.fileName,j=f.getIsImage(p),b=f.getIsVideo(p),w=x(!e.attachmentUrl&&e.fileName),I=e.attachmentUrl||w,A=t.useCallback((function(e){return e.preventDefault()}),[]);return j?q.jsx("div",{className:v.cAttachment,children:q.jsx(R,{size:e.size,openLightbox:function(){return c(!0)},attachmentUrl:I,setImageIsLoaded:function(){return r(!0)},imageIsLoaded:s,lightboxIsOpen:o,handleLightboxOpen:function(){g.isNativeDetected&&document.documentElement.addEventListener("touchmove",A,{passive:!1})},handleLightboxClose:function(){g.isNativeDetected&&document.documentElement.removeEventListener("touchmove",A),c(!1)},classes:e.classes})}):b&&y.default.canPlay(I)?q.jsx("div",{className:v.cAttachment,children:q.jsx(y.default,{"data-testid":"".concat("Attachment","_player"),className:v.cAttachmentReactPlayer,url:I,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:e.size===W.label?W.value:z.value,width:null})}):q.jsx("div",{className:v.cAttachment,children:q.jsx(C,{attachmentUrl:I,attachmentFileName:e.fileName,attachmentSize:e.attachmentSize,displayName:e.displayName,openPreview:function(){return h(!0)},closePreview:function(e){e.stopPropagation(),h(!1)},previewIsOpen:m,classes:e.classes,small:e.small})})}O.propTypes={attachmentUrl:w.default.string.isRequired,attachmentSize:w.default.number,displayName:w.default.string,fileName:w.default.string,size:w.default.oneOf([W.label,z.label]),classes:w.default.shape({}).isRequired,small:w.default.bool},O.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:z.label,small:!1};var E=s.withStyles((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(O);module.exports=E;
1
+ "use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),a=require("prop-types"),i=require("react-player"),s=require("@material-ui/core/styles"),r=require("@material-ui/core/Typography"),l=require("@material-ui/core"),n=require("@material-ui/icons/Image"),o=require("@material-ui/icons/SaveAlt"),c=require("@material-ui/icons/Fullscreen"),d=require("@material-ui/core/colors/grey"),u=require("../FileTypeIcon.js"),m=require("../ImageViewer/index.js"),h=require("../GoogleDocsViewer/index.js"),p=require("../IconButton/index.js"),g=require("../../utils/mobileDetect.js"),f=require("../../utils/fileExtension.js");require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions.js"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../utils/env.js"),require("../GradientManager/configuration/constants.js");var x=require("../../effects/useSignedURL.js");require("../../utils/index.js"),require("uuid"),require("jsona"),require("../StatusBadge/constants.js");var j=require("../../utils/main.js"),v=require("./styles.css.js"),q=require("react/jsx-runtime");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=b(e),w=b(a),y=b(i),I=b(r),A=b(n),F=b(o),P=b(c),S=b(d),D=S.default[200],L=S.default[400],W={label:"small",value:135},z={label:"medium",value:300},U={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===W.label?W.value:z.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:D,borderRadius:3,marginTop:10,height:135,width:135}},R=function(e){return q.jsxs(q.Fragment,{children:[q.jsxs("div",{onClick:e.openLightbox,className:v.cAttachmentImg,children:[q.jsx("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:U.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),q.jsx("div",{"data-testid":"".concat("Attachment","_button"),className:v.cAttachmentImgPreviwBtn,children:q.jsx(P.default,{})})]}),!e.imageIsLoaded&&q.jsx("div",{style:U.imagePlaceholder,children:q.jsx(A.default,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:L,fontSize:"large"})}),e.lightboxIsOpen&&q.jsx(m,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},C=function(e){var t=x(e.attachmentFileName);return q.jsxs("div",{className:v.cAttachmentFileWrapper,children:[q.jsxs("div",{className:v.cAttachmentFileDownloadWrapper,style:U.fileDownloadWrapper,onClick:e.openPreview,children:[q.jsx(u,{fileName:e.displayName||e.attachmentUrl,className:v.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),q.jsx("div",{"data-testid":"".concat("Attachment","_name"),className:v.cAttachmentFileDownloadWrapperFileName,children:q.jsx(I.default,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:j.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),q.jsx(l.Dialog,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g.isNativeDetected?e.classes.nativeDialog:e.classes.dialog},children:q.jsx(h,{fileUrl:t,fileName:j.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),q.jsx("a",{download:e.displayName,href:t,className:v.cAttachmentFileDownloadWrapperForm,children:q.jsx(p,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:q.jsx(F.default,{className:e.classes.downloadIcon})})})]})};function O(e){var a=t.useState(!1),i=N.default(a,2),s=i[0],r=i[1],l=t.useState(!1),n=N.default(l,2),o=n[0],c=n[1],d=t.useState(!1),u=N.default(d,2),m=u[0],h=u[1],p=e.displayName||e.attachmentUrl||e.fileName,j=f.getIsImage(p),b=f.getIsVideo(p),w=x(!e.attachmentUrl&&e.fileName),I=e.attachmentUrl||w,A=t.useCallback((function(e){return e.preventDefault()}),[]);return j?q.jsx("div",{className:v.cAttachment,children:q.jsx(R,{size:e.size,openLightbox:function(){return c(!0)},attachmentUrl:I,setImageIsLoaded:function(){return r(!0)},imageIsLoaded:s,lightboxIsOpen:o,handleLightboxOpen:function(){g.isNativeDetected&&document.documentElement.addEventListener("touchmove",A,{passive:!1})},handleLightboxClose:function(){g.isNativeDetected&&document.documentElement.removeEventListener("touchmove",A),c(!1)},classes:e.classes})}):b&&y.default.canPlay(I)?q.jsx("div",{className:v.cAttachment,children:q.jsx(y.default,{"data-testid":"".concat("Attachment","_player"),className:v.cAttachmentReactPlayer,url:I,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:e.size===W.label?W.value:z.value,width:null})}):q.jsx("div",{className:v.cAttachment,children:q.jsx(C,{attachmentUrl:I,attachmentFileName:e.fileName,attachmentSize:e.attachmentSize,displayName:e.displayName,openPreview:function(){return h(!0)},closePreview:function(e){e.stopPropagation(),h(!1)},previewIsOpen:m,classes:e.classes,small:e.small})})}O.propTypes={attachmentUrl:w.default.string.isRequired,attachmentSize:w.default.number,displayName:w.default.string,fileName:w.default.string,size:w.default.oneOf([W.label,z.label]),classes:w.default.shape({}).isRequired,small:w.default.bool},O.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:z.label,small:!1};var E=s.withStyles((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(O);module.exports=E;
@@ -1 +1 @@
1
- "use strict";var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/assertThisInitialized"),i=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),o=require("@babel/runtime/helpers/getPrototypeOf"),s=require("@babel/runtime/helpers/defineProperty"),l=require("@babel/runtime/regenerator"),u=require("react"),c=require("prop-types"),d=require("moment"),m=require("lodash"),p=require("classnames"),h=require("@material-ui/core/styles"),f=require("@material-ui/core/Typography"),v=require("@material-ui/core/Menu"),g=require("@material-ui/core/MenuItem"),y=require("@material-ui/icons/MoreVert"),b=require("../CommentWrapper.js"),j=require("../CommentLoader.js"),C=require("../CommentInput/index.js"),x=require("../Avatar/index.js"),q=require("../Attachment/index.js"),D=require("../IconButton/index.js"),M=require("../ConfirmationDialog.js"),w=require("../UserCardPopover.js"),E=require("../UserMention/utils/index.js"),I=require("../../utils/mobileDetect.js"),O=require("../../clients/jsonApi/index.js"),k=require("../../utils/main.js"),A=require("./styles.css.js"),N=require("react/jsx-runtime");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var S=_(e),R=_(t),P=_(n),U=_(r),T=_(i),z=_(a),L=_(o),W=_(s),B=_(l),F=_(c),H=_(d),V=_(p),K=_(f),Y=_(v),G=_(g),J=_(y);function Q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=L.default(e);if(t){var i=L.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return z.default(this,n)}}var Z={chatAvatarWrapper:{paddingTop:2,position:"absolute",top:6,left:0},commentInfoContainer:{display:"inline-flex",alignItems:"center",width:"100%",paddingTop:5},userNameWrapper:{overflow:"hidden"},infoContainer:{display:"inline-block",verticalAlign:"top",width:"100%",paddingLeft:33}},$=function(e){T.default(n,e);var t=X(n);function n(e){var r,i;return R.default(this,n),r=t.call(this,e),W.default(U.default(r),"deleteComment",(i=S.default(B.default.mark((function e(t,n){var r;return B.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,O.deleteFeedItemComment(t,n);case 3:r=e.sent,e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),console.error(e.t0);case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,null,[[0,6]])}))),function(e,t){return i.apply(this,arguments)})),W.default(U.default(r),"showIntoView",(function(){r.props.handleShowOnMount(),r.commentEl.current.scrollIntoView({block:"end"})})),W.default(U.default(r),"handleToggleActionsMenu",(function(e){var t=e.currentTarget;r.setState((function(e){return{actionsMenuAnchorEl:e.actionsMenuAnchorEl?null:t}}))})),W.default(U.default(r),"handleKeyDown",(function(e){27===e.keyCode&&r.setState({isEditing:!1}),document.removeEventListener("keydown",r.handleKeyDown,!1)})),W.default(U.default(r),"handleEditMenuItem",(function(){document.addEventListener("keydown",r.handleKeyDown,!1),r.setState({isEditing:!0},(function(){r.inputEl.current&&r.inputEl.current.focus()}))})),W.default(U.default(r),"getEditCommentProps",(function(){var e=r.props.comment,t=e.id,n=e.body,i=e.attachment;return{editFeedItemId:e.feed_activity_id,editCommentId:t,editComment:n,editAttachment:i}})),W.default(U.default(r),"onEditFinish",(function(){r.setState({isEditing:!1,isLoading:!1})})),W.default(U.default(r),"handleDeleteMenuItem",(function(){r.setState({openDeleteDialog:!0})})),W.default(U.default(r),"handleDelete",S.default(B.default.mark((function e(){var t,n,i;return B.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.props.comment.id,n=r.props.comment.feed_activity_id,r.setState({isLoading:!0}),e.next=5,r.deleteComment(n,t);case 5:i=e.sent,r.setState({isLoading:!1,openDeleteDialog:!1}),i&&r.props.handleDeleteCallback(t);case 8:case"end":return e.stop()}}),e)})))),r.state={actionsMenuAnchorEl:null,isLoading:!1,isEditing:!1,openDeleteDialog:!1},r.inputEl=u.createRef(),r.commentEl=u.createRef(),r}return P.default(n,[{key:"componentDidMount",value:function(){this.props.showOnMount&&this.showIntoView()}},{key:"isCurrentUserCommentCreator",get:function(){return Number(m.get(this.props.comment,["user","id"]))===Number(this.props.currentUser.id)}},{key:"renderMenuIcon",value:function(){var e=this.isCurrentUserCommentCreator,t=this.isCurrentUserCommentCreator||m.includes(this.props.comment.allowed_actions,"destroy");return t||e?N.jsxs("div",{className:A.cCommentMenu,children:[N.jsx(D,{"data-testid":"".concat("comment","_menuButton"),"aria-label":"Actions","aria-owns":this.state.actionsMenuAnchorEl?"c-comment__actions-menu":void 0,"aria-haspopup":"true",className:this.props.classes.iconButtonRoot,size:"small",onClick:this.handleToggleActionsMenu,children:N.jsx(J.default,{})}),N.jsxs(Y.default,{id:"c-comment__actions-menu",anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:this.state.actionsMenuAnchorEl,open:!!this.state.actionsMenuAnchorEl,onClick:this.handleToggleActionsMenu,children:[e&&N.jsx(G.default,{"data-testid":"".concat("comment","_editMenuItem"),onClick:this.handleEditMenuItem,children:"Edit"}),t&&N.jsx(G.default,{"data-testid":"".concat("comment","_deleteMenuItem"),onClick:this.handleDeleteMenuItem,children:"Delete"})]})]}):null}},{key:"render",value:function(){var e,t,n=this,r=this.state,i=r.isLoading,a=r.isEditing;if(i){var o=this.props.spaceAround;return N.jsx(j,{spaceAround:o})}var s=this.props,l=s.comment,u=s.classes,c=s.spaceAround,d=s.isNative,p=s.patchCommentCallback,h=s.companyId;if(a)return N.jsx(C,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(n),!0).forEach((function(t){W.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({inputRef:this.inputEl,postComment:m.noop,exitEditMode:this.onEditFinish,setIsEditting:function(){return n.setState({isLoading:!0})},patchCommentCallback:p,companyId:h,currentUser:this.props.currentUser},this.getEditCommentProps()));var f=k.getUserFullName(l.user),v=d?"MM/DD HH:mm":"MM/DD/YY HH:mm",g=H.default(l.created_at).format(v),y=(null==l||null===(e=l.attachment)||void 0===e?void 0:e.signed_url)||(null==l||null===(t=l.attachment)||void 0===t?void 0:t.url),D=m.get(l,["attachment","size"]);return N.jsxs("div",{"data-testid":"".concat("comment","_commentItem_").concat(l.body),className:V.default(A.cComment,W.default({},A.cCommentNative,d)),ref:this.commentEl,children:[N.jsxs(b,{spaceAround:c,className:this.props.classes.commentWrapper,children:[N.jsx("div",{style:Z.chatAvatarWrapper,children:d?N.jsx(x.default,{size:24,displayName:f,imgSrc:m.get(l,["user","profile_photo"]),className:this.props.classes.avatar}):N.jsx(w,{user:l.user,currentUser:this.props.currentUser,children:N.jsx(x.default,{size:24,displayName:f,imgSrc:m.get(l,["user","profile_photo"]),className:this.props.classes.avatar})})}),N.jsxs("div",{style:Z.infoContainer,children:[N.jsx("div",{children:N.jsxs("div",{style:Z.commentInfoContainer,children:[N.jsx("div",{style:Z.userNameWrapper,children:N.jsx(K.default,{"data-testid":"".concat("comment","_userName"),variant:"subtitle2",noWrap:!0,className:u.userName,children:f})}),N.jsx("div",{style:Z.timeWrapper,children:N.jsx(K.default,{"data-testid":"".concat("comment","_addTime"),variant:"caption",classes:{root:u.timeRoot},children:g})})]})}),N.jsxs("div",{className:A.cCommentBody,children:[this.renderMenuIcon(),N.jsx(K.default,{"data-testid":"".concat("comment","_commentMessage"),variant:"body1",classes:{root:u.textRoot},children:E.formatMentionText(l.body,l.mentioned_users,d,"#00bcd4",this.props.currentUser)}),y&&N.jsx(q,{attachmentUrl:y,attachmentSize:D,size:"small"})]})]})]}),this.state.openDeleteDialog&&N.jsx(M,{open:this.state.openDeleteDialog,text:"Do you really want to delete comment?",handleClose:function(){return n.setState({openDeleteDialog:!1})},handleOk:this.handleDelete,okText:"Delete"})]})}}]),n}(u.PureComponent);$.propTypes={comment:F.default.shape({}).isRequired,showOnMount:F.default.bool,spaceAround:F.default.bool,handleShowOnMount:F.default.func,handleEdit:F.default.func,handleDeleteCallback:F.default.func.isRequired,patchCommentCallback:F.default.func.isRequired,companyId:F.default.number,currentUser:F.default.shape(),classes:F.default.shape({}).isRequired,isNative:F.default.bool},$.defaultProps={showOnMount:!1,spaceAround:!1,handleShowOnMount:m.noop,handleEdit:m.noop,companyId:null,isNative:I.isNativeDetected,currentUser:{}};var ee=h.withStyles((function(e){return{commentWrapper:{width:"100%"},timeRoot:{color:e.palette.primary.text7,float:"right",marginRight:5,marginLeft:8,fontSize:"12px"},textRoot:{marginTop:5,color:"#CCC",fontWeight:"normal",fontSize:"14px"},iconButtonRoot:{float:"right",visibility:"hidden",color:e.palette.primary.text7},userName:{fontSize:"12px",fontWeight:"bold"}}}))($);module.exports=ee;
1
+ "use strict";var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/createClass"),r=require("@babel/runtime/helpers/assertThisInitialized"),i=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),o=require("@babel/runtime/helpers/getPrototypeOf"),s=require("@babel/runtime/helpers/defineProperty"),l=require("@babel/runtime/regenerator"),u=require("react"),c=require("prop-types"),d=require("moment"),m=require("lodash"),p=require("classnames"),f=require("@material-ui/core/styles"),h=require("@material-ui/core/Typography"),v=require("@material-ui/core/Menu"),g=require("@material-ui/core/MenuItem"),y=require("@material-ui/icons/MoreVert"),b=require("../CommentWrapper.js"),j=require("../CommentLoader.js"),C=require("../CommentInput/index.js"),x=require("../Avatar/index.js"),q=require("../Attachment/index.js"),D=require("../IconButton/index.js"),M=require("../ConfirmationDialog.js"),w=require("../UserCardPopover.js"),E=require("../UserMention/utils/index.js"),I=require("../../utils/mobileDetect.js"),O=require("../../clients/jsonApi/index.js"),k=require("../../utils/main.js"),N=require("./styles.css.js"),A=require("react/jsx-runtime");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var S=_(e),R=_(t),P=_(n),U=_(r),T=_(i),z=_(a),L=_(o),W=_(s),B=_(l),F=_(c),H=_(d),V=_(p),K=_(h),Y=_(v),G=_(g),J=_(y);function Q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function X(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=L.default(e);if(t){var i=L.default(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return z.default(this,n)}}var Z={chatAvatarWrapper:{paddingTop:2,position:"absolute",top:6,left:0},commentInfoContainer:{display:"inline-flex",alignItems:"center",width:"100%",paddingTop:5},userNameWrapper:{overflow:"hidden"},infoContainer:{display:"inline-block",verticalAlign:"top",width:"100%",paddingLeft:33}},$=function(e){T.default(n,e);var t=X(n);function n(e){var r,i;return R.default(this,n),r=t.call(this,e),W.default(U.default(r),"deleteComment",(i=S.default(B.default.mark((function e(t,n){var r;return B.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,O.deleteFeedItemComment(t,n);case 3:r=e.sent,e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),console.error(e.t0);case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,null,[[0,6]])}))),function(e,t){return i.apply(this,arguments)})),W.default(U.default(r),"showIntoView",(function(){r.props.handleShowOnMount(),r.commentEl.current.scrollIntoView({block:"end"})})),W.default(U.default(r),"handleToggleActionsMenu",(function(e){var t=e.currentTarget;r.setState((function(e){return{actionsMenuAnchorEl:e.actionsMenuAnchorEl?null:t}}))})),W.default(U.default(r),"handleKeyDown",(function(e){27===e.keyCode&&r.setState({isEditing:!1}),document.removeEventListener("keydown",r.handleKeyDown,!1)})),W.default(U.default(r),"handleEditMenuItem",(function(){document.addEventListener("keydown",r.handleKeyDown,!1),r.setState({isEditing:!0},(function(){r.inputEl.current&&r.inputEl.current.focus()}))})),W.default(U.default(r),"getEditCommentProps",(function(){var e=r.props.comment,t=e.id,n=e.body,i=e.attachment;return{editFeedItemId:e.feed_activity_id,editCommentId:t,editComment:n,editAttachment:i}})),W.default(U.default(r),"onEditFinish",(function(){r.setState({isEditing:!1,isLoading:!1})})),W.default(U.default(r),"handleDeleteMenuItem",(function(){r.setState({openDeleteDialog:!0})})),W.default(U.default(r),"handleDelete",S.default(B.default.mark((function e(){var t,n,i;return B.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.props.comment.id,n=r.props.comment.feed_activity_id,r.setState({isLoading:!0}),e.next=5,r.deleteComment(n,t);case 5:i=e.sent,r.setState({isLoading:!1,openDeleteDialog:!1}),i&&r.props.handleDeleteCallback(t);case 8:case"end":return e.stop()}}),e)})))),r.state={actionsMenuAnchorEl:null,isLoading:!1,isEditing:!1,openDeleteDialog:!1},r.inputEl=u.createRef(),r.commentEl=u.createRef(),r}return P.default(n,[{key:"componentDidMount",value:function(){this.props.showOnMount&&this.showIntoView()}},{key:"isCurrentUserCommentCreator",get:function(){return Number(m.get(this.props.comment,["user","id"]))===Number(this.props.currentUser.id)}},{key:"renderMenuIcon",value:function(){var e=this.isCurrentUserCommentCreator,t=this.isCurrentUserCommentCreator||m.includes(this.props.comment.allowed_actions,"destroy");return t||e?A.jsxs("div",{className:N.cCommentMenu,children:[A.jsx(D,{"data-testid":"".concat("comment","_menuButton"),"aria-label":"Actions","aria-owns":this.state.actionsMenuAnchorEl?"c-comment__actions-menu":void 0,"aria-haspopup":"true",className:this.props.classes.iconButtonRoot,size:"small",onClick:this.handleToggleActionsMenu,children:A.jsx(J.default,{})}),A.jsxs(Y.default,{id:"c-comment__actions-menu",anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:this.state.actionsMenuAnchorEl,open:!!this.state.actionsMenuAnchorEl,onClick:this.handleToggleActionsMenu,children:[e&&A.jsx(G.default,{"data-testid":"".concat("comment","_editMenuItem"),onClick:this.handleEditMenuItem,children:"Edit"}),t&&A.jsx(G.default,{"data-testid":"".concat("comment","_deleteMenuItem"),onClick:this.handleDeleteMenuItem,children:"Delete"})]})]}):null}},{key:"render",value:function(){var e,t,n=this,r=this.state,i=r.isLoading,a=r.isEditing;if(i){var o=this.props.spaceAround;return A.jsx(j,{spaceAround:o})}var s=this.props,l=s.comment,u=s.classes,c=s.spaceAround,d=s.isNative,p=s.patchCommentCallback,f=s.companyId;if(a)return A.jsx(C,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Q(Object(n),!0).forEach((function(t){W.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({inputRef:this.inputEl,postComment:m.noop,exitEditMode:this.onEditFinish,setIsEditting:function(){return n.setState({isLoading:!0})},patchCommentCallback:p,companyId:f,currentUser:this.props.currentUser},this.getEditCommentProps()));var h=k.getUserFullName(l.user),v=d?"MM/DD HH:mm":"MM/DD/YY HH:mm",g=H.default(l.created_at).format(v),y=(null==l||null===(e=l.attachment)||void 0===e?void 0:e.signed_url)||(null==l||null===(t=l.attachment)||void 0===t?void 0:t.url),D=m.get(l,["attachment","size"]),I=m.get(l,["attachment","file_name"]);return A.jsxs("div",{"data-testid":"".concat("comment","_commentItem_").concat(l.body),className:V.default(N.cComment,W.default({},N.cCommentNative,d)),ref:this.commentEl,children:[A.jsxs(b,{spaceAround:c,className:this.props.classes.commentWrapper,children:[A.jsx("div",{style:Z.chatAvatarWrapper,children:d?A.jsx(x.default,{size:24,displayName:h,imgSrc:m.get(l,["user","profile_photo"]),className:this.props.classes.avatar}):A.jsx(w,{user:l.user,currentUser:this.props.currentUser,children:A.jsx(x.default,{size:24,displayName:h,imgSrc:m.get(l,["user","profile_photo"]),className:this.props.classes.avatar})})}),A.jsxs("div",{style:Z.infoContainer,children:[A.jsx("div",{children:A.jsxs("div",{style:Z.commentInfoContainer,children:[A.jsx("div",{style:Z.userNameWrapper,children:A.jsx(K.default,{"data-testid":"".concat("comment","_userName"),variant:"subtitle2",noWrap:!0,className:u.userName,children:h})}),A.jsx("div",{style:Z.timeWrapper,children:A.jsx(K.default,{"data-testid":"".concat("comment","_addTime"),variant:"caption",classes:{root:u.timeRoot},children:g})})]})}),A.jsxs("div",{className:N.cCommentBody,children:[this.renderMenuIcon(),A.jsx(K.default,{"data-testid":"".concat("comment","_commentMessage"),variant:"body1",classes:{root:u.textRoot},children:E.formatMentionText(l.body,l.mentioned_users,d,"#00bcd4",this.props.currentUser)}),y&&A.jsx(q,{attachmentUrl:y,attachmentSize:D,size:"small",fileName:I})]})]})]}),this.state.openDeleteDialog&&A.jsx(M,{open:this.state.openDeleteDialog,text:"Do you really want to delete comment?",handleClose:function(){return n.setState({openDeleteDialog:!1})},handleOk:this.handleDelete,okText:"Delete"})]})}}]),n}(u.PureComponent);$.propTypes={comment:F.default.shape({}).isRequired,showOnMount:F.default.bool,spaceAround:F.default.bool,handleShowOnMount:F.default.func,handleEdit:F.default.func,handleDeleteCallback:F.default.func.isRequired,patchCommentCallback:F.default.func.isRequired,companyId:F.default.number,currentUser:F.default.shape(),classes:F.default.shape({}).isRequired,isNative:F.default.bool},$.defaultProps={showOnMount:!1,spaceAround:!1,handleShowOnMount:m.noop,handleEdit:m.noop,companyId:null,isNative:I.isNativeDetected,currentUser:{}};var ee=f.withStyles((function(e){return{commentWrapper:{width:"100%"},timeRoot:{color:e.palette.primary.text7,float:"right",marginRight:5,marginLeft:8,fontSize:"12px"},textRoot:{marginTop:5,color:"#CCC",fontWeight:"normal",fontSize:"14px"},iconButtonRoot:{float:"right",visibility:"hidden",color:e.palette.primary.text7},userName:{fontSize:"12px",fontWeight:"bold"}}}))($);module.exports=ee;
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useCallback as a}from"react";import i from"prop-types";import o from"react-player";import{withStyles as r}from"@material-ui/core/styles";import n from"@material-ui/core/Typography";import{Dialog as l}from"@material-ui/core";import s from"@material-ui/icons/Image";import m from"@material-ui/icons/SaveAlt";import c from"@material-ui/icons/Fullscreen";import d from"@material-ui/core/colors/grey";import p from"../FileTypeIcon.js";import h from"../ImageViewer/index.js";import u from"../GoogleDocsViewer/index.js";import f from"../IconButton/index.js";import{isNativeDetected as g}from"../../utils/mobileDetect.js";import{getIsImage as v,getIsVideo as b}from"../../utils/fileExtension.js";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/regenerator";import"querystring";import"uuid/v1";import"lodash";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../utils/env.js";import"../GradientManager/configuration/constants.js";import N from"../../effects/useSignedURL.js";import"../../utils/index.js";import"uuid";import"jsona";import"../StatusBadge/constants.js";import w from"../../utils/main.js";import x from"./styles.css.js";import{jsx as y,jsxs as j,Fragment as I}from"react/jsx-runtime";var A=d[200],F=d[400],P={label:"small",value:135},L={label:"medium",value:300},W={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===P.label?P.value:L.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:A,borderRadius:3,marginTop:10,height:135,width:135}},z=function(e){return j(I,{children:[j("div",{onClick:e.openLightbox,className:x.cAttachmentImg,children:[y("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:W.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),y("div",{"data-testid":"".concat("Attachment","_button"),className:x.cAttachmentImgPreviwBtn,children:y(c,{})})]}),!e.imageIsLoaded&&y("div",{style:W.imagePlaceholder,children:y(s,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:F,fontSize:"large"})}),e.lightboxIsOpen&&y(h,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},U=function(e){var t=N(e.attachmentFileName);return j("div",{className:x.cAttachmentFileWrapper,children:[j("div",{className:x.cAttachmentFileDownloadWrapper,style:W.fileDownloadWrapper,onClick:e.openPreview,children:[y(p,{fileName:e.displayName||e.attachmentUrl,className:x.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),y("div",{"data-testid":"".concat("Attachment","_name"),className:x.cAttachmentFileDownloadWrapperFileName,children:y(n,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),y(l,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g?e.classes.nativeDialog:e.classes.dialog},children:y(u,{fileUrl:e.attachmentUrl,fileName:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),y("a",{download:e.displayName,href:t,className:x.cAttachmentFileDownloadWrapperForm,children:y(f,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:y(m,{className:e.classes.downloadIcon})})})]})};function R(i){var r=t(!1),n=e(r,2),l=n[0],s=n[1],m=t(!1),c=e(m,2),d=c[0],p=c[1],h=t(!1),u=e(h,2),f=u[0],w=u[1],j=i.displayName||i.attachmentUrl||i.fileName,I=v(j),A=b(j),F=N(!i.attachmentUrl&&i.fileName),W=i.attachmentUrl||F,R=a((function(e){return e.preventDefault()}),[]);return I?y("div",{className:x.cAttachment,children:y(z,{size:i.size,openLightbox:function(){return p(!0)},attachmentUrl:W,setImageIsLoaded:function(){return s(!0)},imageIsLoaded:l,lightboxIsOpen:d,handleLightboxOpen:function(){g&&document.documentElement.addEventListener("touchmove",R,{passive:!1})},handleLightboxClose:function(){g&&document.documentElement.removeEventListener("touchmove",R),p(!1)},classes:i.classes})}):A&&o.canPlay(W)?y("div",{className:x.cAttachment,children:y(o,{"data-testid":"".concat("Attachment","_player"),className:x.cAttachmentReactPlayer,url:W,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:i.size===P.label?P.value:L.value,width:null})}):y("div",{className:x.cAttachment,children:y(U,{attachmentUrl:W,attachmentFileName:i.fileName,attachmentSize:i.attachmentSize,displayName:i.displayName,openPreview:function(){return w(!0)},closePreview:function(e){e.stopPropagation(),w(!1)},previewIsOpen:f,classes:i.classes,small:i.small})})}R.propTypes={attachmentUrl:i.string.isRequired,attachmentSize:i.number,displayName:i.string,fileName:i.string,size:i.oneOf([P.label,L.label]),classes:i.shape({}).isRequired,small:i.bool},R.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:L.label,small:!1};var S=r((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(R);export{S as default};
1
+ import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useCallback as a}from"react";import i from"prop-types";import o from"react-player";import{withStyles as r}from"@material-ui/core/styles";import n from"@material-ui/core/Typography";import{Dialog as s}from"@material-ui/core";import l from"@material-ui/icons/Image";import m from"@material-ui/icons/SaveAlt";import c from"@material-ui/icons/Fullscreen";import d from"@material-ui/core/colors/grey";import p from"../FileTypeIcon.js";import h from"../ImageViewer/index.js";import u from"../GoogleDocsViewer/index.js";import f from"../IconButton/index.js";import{isNativeDetected as g}from"../../utils/mobileDetect.js";import{getIsImage as v,getIsVideo as b}from"../../utils/fileExtension.js";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/regenerator";import"querystring";import"uuid/v1";import"lodash";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../utils/env.js";import"../GradientManager/configuration/constants.js";import N from"../../effects/useSignedURL.js";import"../../utils/index.js";import"uuid";import"jsona";import"../StatusBadge/constants.js";import w from"../../utils/main.js";import x from"./styles.css.js";import{jsx as y,jsxs as j,Fragment as I}from"react/jsx-runtime";var A=d[200],F=d[400],P={label:"small",value:135},L={label:"medium",value:300},W={fileImage:function(e,t){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:t===P.label?P.value:L.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:A,borderRadius:3,marginTop:10,height:135,width:135}},z=function(e){return j(I,{children:[j("div",{onClick:e.openLightbox,className:x.cAttachmentImg,children:[y("img",{"data-testid":"".concat("Attachment","_image"),src:e.attachmentUrl,style:W.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),y("div",{"data-testid":"".concat("Attachment","_button"),className:x.cAttachmentImgPreviwBtn,children:y(c,{})})]}),!e.imageIsLoaded&&y("div",{style:W.imagePlaceholder,children:y(l,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:F,fontSize:"large"})}),e.lightboxIsOpen&&y(h,{mainSrc:e.attachmentUrl,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},U=function(e){var t=N(e.attachmentFileName);return j("div",{className:x.cAttachmentFileWrapper,children:[j("div",{className:x.cAttachmentFileDownloadWrapper,style:W.fileDownloadWrapper,onClick:e.openPreview,children:[y(p,{fileName:e.displayName||e.attachmentUrl,className:x.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),y("div",{"data-testid":"".concat("Attachment","_name"),className:x.cAttachmentFileDownloadWrapperFileName,children:y(n,{variant:"subtitle2",noWrap:!0,className:e.classes.fileName,children:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl)})}),y(s,{open:e.previewIsOpen,onClose:e.closePreview,classes:{root:e.classes.dialogRoot,paper:g?e.classes.nativeDialog:e.classes.dialog},children:y(u,{fileUrl:t,fileName:w.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),fileSize:e.attachmentSize,onClose:e.closePreview,width:"100%",height:"100%"})})]}),y("a",{download:e.displayName,href:t,className:x.cAttachmentFileDownloadWrapperForm,children:y(f,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:y(m,{className:e.classes.downloadIcon})})})]})};function R(i){var r=t(!1),n=e(r,2),s=n[0],l=n[1],m=t(!1),c=e(m,2),d=c[0],p=c[1],h=t(!1),u=e(h,2),f=u[0],w=u[1],j=i.displayName||i.attachmentUrl||i.fileName,I=v(j),A=b(j),F=N(!i.attachmentUrl&&i.fileName),W=i.attachmentUrl||F,R=a((function(e){return e.preventDefault()}),[]);return I?y("div",{className:x.cAttachment,children:y(z,{size:i.size,openLightbox:function(){return p(!0)},attachmentUrl:W,setImageIsLoaded:function(){return l(!0)},imageIsLoaded:s,lightboxIsOpen:d,handleLightboxOpen:function(){g&&document.documentElement.addEventListener("touchmove",R,{passive:!1})},handleLightboxClose:function(){g&&document.documentElement.removeEventListener("touchmove",R),p(!1)},classes:i.classes})}):A&&o.canPlay(W)?y("div",{className:x.cAttachment,children:y(o,{"data-testid":"".concat("Attachment","_player"),className:x.cAttachmentReactPlayer,url:W,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:i.size===P.label?P.value:L.value,width:null})}):y("div",{className:x.cAttachment,children:y(U,{attachmentUrl:W,attachmentFileName:i.fileName,attachmentSize:i.attachmentSize,displayName:i.displayName,openPreview:function(){return w(!0)},closePreview:function(e){e.stopPropagation(),w(!1)},previewIsOpen:f,classes:i.classes,small:i.small})})}R.propTypes={attachmentUrl:i.string.isRequired,attachmentSize:i.number,displayName:i.string,fileName:i.string,size:i.oneOf([P.label,L.label]),classes:i.shape({}).isRequired,small:i.bool},R.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:L.label,small:!1};var S=r((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3}}}))(R);export{S as default};
@@ -1 +1 @@
1
- import e from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/assertThisInitialized";import o from"@babel/runtime/helpers/inherits";import i from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import s from"@babel/runtime/helpers/defineProperty";import c from"@babel/runtime/regenerator";import{createRef as m,PureComponent as l}from"react";import p from"prop-types";import u from"moment";import{get as d,includes as h,noop as f}from"lodash";import v from"classnames";import{withStyles as y}from"@material-ui/core/styles";import g from"@material-ui/core/Typography";import b from"@material-ui/core/Menu";import C from"@material-ui/core/MenuItem";import D from"@material-ui/icons/MoreVert";import M from"../CommentWrapper.js";import E from"../CommentLoader.js";import w from"../CommentInput/index.js";import O from"../Avatar/index.js";import I from"../Attachment/index.js";import j from"../IconButton/index.js";import k from"../ConfirmationDialog.js";import x from"../UserCardPopover.js";import{formatMentionText as A}from"../UserMention/utils/index.js";import{isNativeDetected as N}from"../../utils/mobileDetect.js";import{deleteFeedItemComment as _}from"../../clients/jsonApi/index.js";import S from"../../utils/main.js";import R from"./styles.css.js";import{jsxs as P,jsx as U}from"react/jsx-runtime";function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=a(e);if(t){var o=a(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return i(this,n)}}var L={chatAvatarWrapper:{paddingTop:2,position:"absolute",top:6,left:0},commentInfoContainer:{display:"inline-flex",alignItems:"center",width:"100%",paddingTop:5},userNameWrapper:{overflow:"hidden"},infoContainer:{display:"inline-block",verticalAlign:"top",width:"100%",paddingLeft:33}},W=function(i){o(p,l);var a=z(p);function p(n){var o,i;return t(this,p),o=a.call(this,n),s(r(o),"deleteComment",(i=e(c.mark((function e(t,n){var r;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_(t,n);case 3:r=e.sent,e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),console.error(e.t0);case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,null,[[0,6]])}))),function(e,t){return i.apply(this,arguments)})),s(r(o),"showIntoView",(function(){o.props.handleShowOnMount(),o.commentEl.current.scrollIntoView({block:"end"})})),s(r(o),"handleToggleActionsMenu",(function(e){var t=e.currentTarget;o.setState((function(e){return{actionsMenuAnchorEl:e.actionsMenuAnchorEl?null:t}}))})),s(r(o),"handleKeyDown",(function(e){27===e.keyCode&&o.setState({isEditing:!1}),document.removeEventListener("keydown",o.handleKeyDown,!1)})),s(r(o),"handleEditMenuItem",(function(){document.addEventListener("keydown",o.handleKeyDown,!1),o.setState({isEditing:!0},(function(){o.inputEl.current&&o.inputEl.current.focus()}))})),s(r(o),"getEditCommentProps",(function(){var e=o.props.comment,t=e.id,n=e.body,r=e.attachment;return{editFeedItemId:e.feed_activity_id,editCommentId:t,editComment:n,editAttachment:r}})),s(r(o),"onEditFinish",(function(){o.setState({isEditing:!1,isLoading:!1})})),s(r(o),"handleDeleteMenuItem",(function(){o.setState({openDeleteDialog:!0})})),s(r(o),"handleDelete",e(c.mark((function e(){var t,n,r;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.props.comment.id,n=o.props.comment.feed_activity_id,o.setState({isLoading:!0}),e.next=5,o.deleteComment(n,t);case 5:r=e.sent,o.setState({isLoading:!1,openDeleteDialog:!1}),r&&o.props.handleDeleteCallback(t);case 8:case"end":return e.stop()}}),e)})))),o.state={actionsMenuAnchorEl:null,isLoading:!1,isEditing:!1,openDeleteDialog:!1},o.inputEl=m(),o.commentEl=m(),o}return n(p,[{key:"componentDidMount",value:function(){this.props.showOnMount&&this.showIntoView()}},{key:"isCurrentUserCommentCreator",get:function(){return Number(d(this.props.comment,["user","id"]))===Number(this.props.currentUser.id)}},{key:"renderMenuIcon",value:function(){var e=this.isCurrentUserCommentCreator,t=this.isCurrentUserCommentCreator||h(this.props.comment.allowed_actions,"destroy");return t||e?P("div",{className:R.cCommentMenu,children:[U(j,{"data-testid":"".concat("comment","_menuButton"),"aria-label":"Actions","aria-owns":this.state.actionsMenuAnchorEl?"c-comment__actions-menu":void 0,"aria-haspopup":"true",className:this.props.classes.iconButtonRoot,size:"small",onClick:this.handleToggleActionsMenu,children:U(D,{})}),P(b,{id:"c-comment__actions-menu",anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:this.state.actionsMenuAnchorEl,open:!!this.state.actionsMenuAnchorEl,onClick:this.handleToggleActionsMenu,children:[e&&U(C,{"data-testid":"".concat("comment","_editMenuItem"),onClick:this.handleEditMenuItem,children:"Edit"}),t&&U(C,{"data-testid":"".concat("comment","_deleteMenuItem"),onClick:this.handleDeleteMenuItem,children:"Delete"})]})]}):null}},{key:"render",value:function(){var e,t,n=this,r=this.state,o=r.isLoading,i=r.isEditing;if(o){var a=this.props.spaceAround;return U(E,{spaceAround:a})}var c=this.props,m=c.comment,l=c.classes,p=c.spaceAround,h=c.isNative,y=c.patchCommentCallback,b=c.companyId;if(i)return U(w,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({inputRef:this.inputEl,postComment:f,exitEditMode:this.onEditFinish,setIsEditting:function(){return n.setState({isLoading:!0})},patchCommentCallback:y,companyId:b,currentUser:this.props.currentUser},this.getEditCommentProps()));var C=S.getUserFullName(m.user),D=h?"MM/DD HH:mm":"MM/DD/YY HH:mm",j=u(m.created_at).format(D),N=(null==m||null===(e=m.attachment)||void 0===e?void 0:e.signed_url)||(null==m||null===(t=m.attachment)||void 0===t?void 0:t.url),_=d(m,["attachment","size"]);return P("div",{"data-testid":"".concat("comment","_commentItem_").concat(m.body),className:v(R.cComment,s({},R.cCommentNative,h)),ref:this.commentEl,children:[P(M,{spaceAround:p,className:this.props.classes.commentWrapper,children:[U("div",{style:L.chatAvatarWrapper,children:h?U(O,{size:24,displayName:C,imgSrc:d(m,["user","profile_photo"]),className:this.props.classes.avatar}):U(x,{user:m.user,currentUser:this.props.currentUser,children:U(O,{size:24,displayName:C,imgSrc:d(m,["user","profile_photo"]),className:this.props.classes.avatar})})}),P("div",{style:L.infoContainer,children:[U("div",{children:P("div",{style:L.commentInfoContainer,children:[U("div",{style:L.userNameWrapper,children:U(g,{"data-testid":"".concat("comment","_userName"),variant:"subtitle2",noWrap:!0,className:l.userName,children:C})}),U("div",{style:L.timeWrapper,children:U(g,{"data-testid":"".concat("comment","_addTime"),variant:"caption",classes:{root:l.timeRoot},children:j})})]})}),P("div",{className:R.cCommentBody,children:[this.renderMenuIcon(),U(g,{"data-testid":"".concat("comment","_commentMessage"),variant:"body1",classes:{root:l.textRoot},children:A(m.body,m.mentioned_users,h,"#00bcd4",this.props.currentUser)}),N&&U(I,{attachmentUrl:N,attachmentSize:_,size:"small"})]})]})]}),this.state.openDeleteDialog&&U(k,{open:this.state.openDeleteDialog,text:"Do you really want to delete comment?",handleClose:function(){return n.setState({openDeleteDialog:!1})},handleOk:this.handleDelete,okText:"Delete"})]})}}]),p}();W.propTypes={comment:p.shape({}).isRequired,showOnMount:p.bool,spaceAround:p.bool,handleShowOnMount:p.func,handleEdit:p.func,handleDeleteCallback:p.func.isRequired,patchCommentCallback:p.func.isRequired,companyId:p.number,currentUser:p.shape(),classes:p.shape({}).isRequired,isNative:p.bool},W.defaultProps={showOnMount:!1,spaceAround:!1,handleShowOnMount:f,handleEdit:f,companyId:null,isNative:N,currentUser:{}};var B=y((function(e){return{commentWrapper:{width:"100%"},timeRoot:{color:e.palette.primary.text7,float:"right",marginRight:5,marginLeft:8,fontSize:"12px"},textRoot:{marginTop:5,color:"#CCC",fontWeight:"normal",fontSize:"14px"},iconButtonRoot:{float:"right",visibility:"hidden",color:e.palette.primary.text7},userName:{fontSize:"12px",fontWeight:"bold"}}}))(W);export{B as default};
1
+ import e from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import r from"@babel/runtime/helpers/assertThisInitialized";import o from"@babel/runtime/helpers/inherits";import i from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import s from"@babel/runtime/helpers/defineProperty";import c from"@babel/runtime/regenerator";import{createRef as m,PureComponent as l}from"react";import p from"prop-types";import u from"moment";import{get as d,includes as h,noop as f}from"lodash";import v from"classnames";import{withStyles as y}from"@material-ui/core/styles";import g from"@material-ui/core/Typography";import b from"@material-ui/core/Menu";import C from"@material-ui/core/MenuItem";import D from"@material-ui/icons/MoreVert";import M from"../CommentWrapper.js";import E from"../CommentLoader.js";import w from"../CommentInput/index.js";import O from"../Avatar/index.js";import I from"../Attachment/index.js";import j from"../IconButton/index.js";import k from"../ConfirmationDialog.js";import x from"../UserCardPopover.js";import{formatMentionText as A}from"../UserMention/utils/index.js";import{isNativeDetected as N}from"../../utils/mobileDetect.js";import{deleteFeedItemComment as _}from"../../clients/jsonApi/index.js";import S from"../../utils/main.js";import R from"./styles.css.js";import{jsxs as P,jsx as U}from"react/jsx-runtime";function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=a(e);if(t){var o=a(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return i(this,n)}}var L={chatAvatarWrapper:{paddingTop:2,position:"absolute",top:6,left:0},commentInfoContainer:{display:"inline-flex",alignItems:"center",width:"100%",paddingTop:5},userNameWrapper:{overflow:"hidden"},infoContainer:{display:"inline-block",verticalAlign:"top",width:"100%",paddingLeft:33}},W=function(i){o(p,l);var a=z(p);function p(n){var o,i;return t(this,p),o=a.call(this,n),s(r(o),"deleteComment",(i=e(c.mark((function e(t,n){var r;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,_(t,n);case 3:r=e.sent,e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),console.error(e.t0);case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,null,[[0,6]])}))),function(e,t){return i.apply(this,arguments)})),s(r(o),"showIntoView",(function(){o.props.handleShowOnMount(),o.commentEl.current.scrollIntoView({block:"end"})})),s(r(o),"handleToggleActionsMenu",(function(e){var t=e.currentTarget;o.setState((function(e){return{actionsMenuAnchorEl:e.actionsMenuAnchorEl?null:t}}))})),s(r(o),"handleKeyDown",(function(e){27===e.keyCode&&o.setState({isEditing:!1}),document.removeEventListener("keydown",o.handleKeyDown,!1)})),s(r(o),"handleEditMenuItem",(function(){document.addEventListener("keydown",o.handleKeyDown,!1),o.setState({isEditing:!0},(function(){o.inputEl.current&&o.inputEl.current.focus()}))})),s(r(o),"getEditCommentProps",(function(){var e=o.props.comment,t=e.id,n=e.body,r=e.attachment;return{editFeedItemId:e.feed_activity_id,editCommentId:t,editComment:n,editAttachment:r}})),s(r(o),"onEditFinish",(function(){o.setState({isEditing:!1,isLoading:!1})})),s(r(o),"handleDeleteMenuItem",(function(){o.setState({openDeleteDialog:!0})})),s(r(o),"handleDelete",e(c.mark((function e(){var t,n,r;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.props.comment.id,n=o.props.comment.feed_activity_id,o.setState({isLoading:!0}),e.next=5,o.deleteComment(n,t);case 5:r=e.sent,o.setState({isLoading:!1,openDeleteDialog:!1}),r&&o.props.handleDeleteCallback(t);case 8:case"end":return e.stop()}}),e)})))),o.state={actionsMenuAnchorEl:null,isLoading:!1,isEditing:!1,openDeleteDialog:!1},o.inputEl=m(),o.commentEl=m(),o}return n(p,[{key:"componentDidMount",value:function(){this.props.showOnMount&&this.showIntoView()}},{key:"isCurrentUserCommentCreator",get:function(){return Number(d(this.props.comment,["user","id"]))===Number(this.props.currentUser.id)}},{key:"renderMenuIcon",value:function(){var e=this.isCurrentUserCommentCreator,t=this.isCurrentUserCommentCreator||h(this.props.comment.allowed_actions,"destroy");return t||e?P("div",{className:R.cCommentMenu,children:[U(j,{"data-testid":"".concat("comment","_menuButton"),"aria-label":"Actions","aria-owns":this.state.actionsMenuAnchorEl?"c-comment__actions-menu":void 0,"aria-haspopup":"true",className:this.props.classes.iconButtonRoot,size:"small",onClick:this.handleToggleActionsMenu,children:U(D,{})}),P(b,{id:"c-comment__actions-menu",anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},anchorEl:this.state.actionsMenuAnchorEl,open:!!this.state.actionsMenuAnchorEl,onClick:this.handleToggleActionsMenu,children:[e&&U(C,{"data-testid":"".concat("comment","_editMenuItem"),onClick:this.handleEditMenuItem,children:"Edit"}),t&&U(C,{"data-testid":"".concat("comment","_deleteMenuItem"),onClick:this.handleDeleteMenuItem,children:"Delete"})]})]}):null}},{key:"render",value:function(){var e,t,n=this,r=this.state,o=r.isLoading,i=r.isEditing;if(o){var a=this.props.spaceAround;return U(E,{spaceAround:a})}var c=this.props,m=c.comment,l=c.classes,p=c.spaceAround,h=c.isNative,y=c.patchCommentCallback,b=c.companyId;if(i)return U(w,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({inputRef:this.inputEl,postComment:f,exitEditMode:this.onEditFinish,setIsEditting:function(){return n.setState({isLoading:!0})},patchCommentCallback:y,companyId:b,currentUser:this.props.currentUser},this.getEditCommentProps()));var C=S.getUserFullName(m.user),D=h?"MM/DD HH:mm":"MM/DD/YY HH:mm",j=u(m.created_at).format(D),N=(null==m||null===(e=m.attachment)||void 0===e?void 0:e.signed_url)||(null==m||null===(t=m.attachment)||void 0===t?void 0:t.url),_=d(m,["attachment","size"]),z=d(m,["attachment","file_name"]);return P("div",{"data-testid":"".concat("comment","_commentItem_").concat(m.body),className:v(R.cComment,s({},R.cCommentNative,h)),ref:this.commentEl,children:[P(M,{spaceAround:p,className:this.props.classes.commentWrapper,children:[U("div",{style:L.chatAvatarWrapper,children:h?U(O,{size:24,displayName:C,imgSrc:d(m,["user","profile_photo"]),className:this.props.classes.avatar}):U(x,{user:m.user,currentUser:this.props.currentUser,children:U(O,{size:24,displayName:C,imgSrc:d(m,["user","profile_photo"]),className:this.props.classes.avatar})})}),P("div",{style:L.infoContainer,children:[U("div",{children:P("div",{style:L.commentInfoContainer,children:[U("div",{style:L.userNameWrapper,children:U(g,{"data-testid":"".concat("comment","_userName"),variant:"subtitle2",noWrap:!0,className:l.userName,children:C})}),U("div",{style:L.timeWrapper,children:U(g,{"data-testid":"".concat("comment","_addTime"),variant:"caption",classes:{root:l.timeRoot},children:j})})]})}),P("div",{className:R.cCommentBody,children:[this.renderMenuIcon(),U(g,{"data-testid":"".concat("comment","_commentMessage"),variant:"body1",classes:{root:l.textRoot},children:A(m.body,m.mentioned_users,h,"#00bcd4",this.props.currentUser)}),N&&U(I,{attachmentUrl:N,attachmentSize:_,size:"small",fileName:z})]})]})]}),this.state.openDeleteDialog&&U(k,{open:this.state.openDeleteDialog,text:"Do you really want to delete comment?",handleClose:function(){return n.setState({openDeleteDialog:!1})},handleOk:this.handleDelete,okText:"Delete"})]})}}]),p}();W.propTypes={comment:p.shape({}).isRequired,showOnMount:p.bool,spaceAround:p.bool,handleShowOnMount:p.func,handleEdit:p.func,handleDeleteCallback:p.func.isRequired,patchCommentCallback:p.func.isRequired,companyId:p.number,currentUser:p.shape(),classes:p.shape({}).isRequired,isNative:p.bool},W.defaultProps={showOnMount:!1,spaceAround:!1,handleShowOnMount:f,handleEdit:f,companyId:null,isNative:N,currentUser:{}};var B=y((function(e){return{commentWrapper:{width:"100%"},timeRoot:{color:e.palette.primary.text7,float:"right",marginRight:5,marginLeft:8,fontSize:"12px"},textRoot:{marginTop:5,color:"#CCC",fontWeight:"normal",fontSize:"14px"},iconButtonRoot:{float:"right",visibility:"hidden",color:e.palette.primary.text7},userName:{fontSize:"12px",fontWeight:"bold"}}}))(W);export{B as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/ui",
3
- "version": "0.60.0-rc.0",
3
+ "version": "0.60.0-rc.1",
4
4
  "description": "Shared components/utils for Corva ui projects",
5
5
  "keywords": [
6
6
  "corva-ui"