@corva/ui 3.76.0-2 → 3.76.0-3
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.
- package/cjs-bundle/components/CommentInput/index.js +1 -1
- package/cjs-bundle/components/CommentInput/index.js.map +1 -1
- package/cjs-bundle/components/CommentInput/useCommentInput.js +2 -0
- package/cjs-bundle/components/CommentInput/useCommentInput.js.map +1 -0
- package/components/CommentInput/__tests__/useCommentInput.test.d.ts +2 -0
- package/components/CommentInput/__tests__/useCommentInput.test.d.ts.map +1 -0
- package/components/CommentInput/index.d.ts +26 -24
- package/components/CommentInput/index.js +1 -1
- package/components/CommentInput/index.js.map +1 -1
- package/components/CommentInput/useCommentInput.d.ts +26 -0
- package/components/CommentInput/useCommentInput.d.ts.map +1 -0
- package/components/CommentInput/useCommentInput.js +2 -0
- package/components/CommentInput/useCommentInput.js.map +1 -0
- package/mcp-server/server.mjs +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@babel/runtime/helpers/asyncToGenerator"),e=require("@babel/runtime/helpers/classCallCheck"),n=require("@babel/runtime/helpers/createClass"),a=require("@babel/runtime/helpers/assertThisInitialized"),i=require("@babel/runtime/helpers/inherits"),s=require("@babel/runtime/helpers/possibleConstructorReturn"),r=require("@babel/runtime/helpers/getPrototypeOf"),o=require("@babel/runtime/helpers/defineProperty"),l=require("@babel/runtime/regenerator"),u=require("react"),c=require("prop-types"),d=require("lodash/noop"),p=require("@material-ui/core/styles"),m=require("@material-ui/core"),h=require("classnames"),f=require("lodash"),g=require("@material-ui/core/colors/grey"),C=require("../../clients/jsonApi/index.js"),x=require("./styles.css.js"),v=require("../Avatar/index.js"),b=require("../FileUploadIconButton.js"),I=require("../EmojiIconButton.js"),y=require("../FailedFileUploading.js"),j=require("../UserMention/index.js"),F=require("../FilePreview/index.js"),E=require("../IconButton/index.js"),S=require("../Icons/SendIcon.js"),q=require("../UserMention/utils/index.js"),U=require("../../utils/main.js"),A=require("../../utils/mobileDetect.js"),N=require("../../utils/nativeMessages.js"),k=require("react/jsx-runtime");function M(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var R=M(t),P=M(e),T=M(n),B=M(a),w=M(i),L=M(s),z=M(r),D=M(o),_=M(l),O=M(c),H=M(d),K=M(h),V=M(g);function W(t){var e=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(t){return!1}}();return function(){var n,a=z.default(t);if(e){var i=z.default(this).constructor;n=Reflect.construct(a,arguments,i)}else n=a.apply(this,arguments);return L.default(this,n)}}var G={chatAvatarWrapper:{display:"flex",alignItems:"center",position:"absolute",left:0,height:32},commentTextFieldContainer:{position:"relative",margin:"0"},commentTextFieldContainerSpaceAround:{position:"relative",margin:"20px 10px"}},J=function(t){w.default(n,t);var e=W(n);function n(t){var a,i,s;return P.default(this,n),a=e.call(this,t),D.default(B.default(a),"handleSelectEmoji",(function(t){return a.setState((function(e){var n=e.comment;return{comment:"".concat(n).concat(t.native)}}))})),D.default(B.default(a),"postComment",(i=R.default(_.default.mark((function t(e){var n;return _.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,a.props.postComment(e);case 3:n=t.sent,t.next=9;break;case 6:t.prev=6,t.t0=t.catch(0),console.error(t.t0.message);case 9:return t.abrupt("return",n);case 10:case"end":return t.stop()}}),t,null,[[0,6]])}))),function(t){return i.apply(this,arguments)})),D.default(B.default(a),"patchComment",(s=R.default(_.default.mark((function t(e){var n,i,s,r;return _.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=a.props,i=n.editFeedItemId,s=n.editCommentId,t.prev=1,t.next=4,C.patchFeedItemComment(i,s,e);case 4:r=t.sent,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),console.error(t.t0.message);case 10:return t.abrupt("return",r);case 11:case"end":return t.stop()}}),t,null,[[1,7]])}))),function(t){return s.apply(this,arguments)})),D.default(B.default(a),"clearCommentField",(function(t){a.setState({comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null},(function(){a.focusOnRef(),t&&"function"==typeof t&&t()}))})),D.default(B.default(a),"handleKeyDown",(function(t){var e=t.key;"Escape"===e&&a.props.exitEditMode(),"Enter"===e&&(q.isSuggestionsListOpened()||(t.preventDefault(),a.handleSendComment()))})),D.default(B.default(a),"handleAttachmentLoadingError",(function(t){a.setState({attachmentUrl:null,attachmentName:null,attachmentSize:null,attachmentLoadingError:t})})),D.default(B.default(a),"handleFileUpload",(function(t,e,n){a.setState({attachmentUrl:t,attachmentName:e,attachmentSize:n,attachmentLoadingError:null})})),D.default(B.default(a),"handleNativeFileUpload",(function(){var t=a.state.comment;a.isEditMode?(N.notifyCommentEdit(t),a.clearCommentField(a.props.exitEditMode)):(N.notifyCommentPost(t),a.clearCommentField())})),D.default(B.default(a),"handleFileDelete",(function(){return a.setState({attachmentUrl:null,attachmentName:null,attachmentSize:null})})),D.default(B.default(a),"handleSendComment",R.default(_.default.mark((function t(){var e,n,i;return _.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((e=a.state.comment?a.state.comment.trim():null)||a.state.attachmentUrl){t.next=3;break}return t.abrupt("return");case 3:if(n={comment:{body:e,attachment:{url:a.state.attachmentUrl,size:a.state.attachmentSize,file_name:a.state.attachmentName}}},!a.isEditMode){t.next=16;break}return a.props.setIsEditting(!0),t.next=8,a.patchComment(n);case 8:return i=t.sent,t.next=11,a.props.patchCommentCallback(i);case 11:a.props.setIsEditting(!1),a.clearCommentField(),a.props.exitEditMode(),t.next=24;break;case 16:return a.props.setIsPosting(!0),t.next=19,a.postComment(n);case 19:return i=t.sent,t.next=22,a.props.postCommentCallback(i);case 22:a.props.setIsPosting(!1),a.clearCommentField();case 24:case"end":return t.stop()}}),t)})))),D.default(B.default(a),"handleCancelClick",(function(){a.setState({comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null},a.props.exitEditMode())})),a.state={comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null,attachmentLoadingError:null,isInputFocused:!1},a}return T.default(n,[{key:"componentDidMount",value:function(){this.isEditMode&&this.setInitialCommentValue()}},{key:"componentDidUpdate",value:function(t){(this.isEditMode&&!t.editFeedItemId||this.props.editCommentId&&this.props.editCommentId!==t.editCommentId)&&this.setInitialCommentValue()}},{key:"isEditMode",get:function(){return!!this.props.editFeedItemId}},{key:"setInitialCommentValue",value:function(){var t=this.props.editAttachment?this.props.editAttachment.url:null;this.setState({comment:this.props.editComment,attachmentUrl:t,attachmentName:t?this.props.editAttachment.file_name||U.default.getFileNameWithExtensionFromPath(t):null,attachmentSize:this.props.editAttachment?this.props.editAttachment.size:null})}},{key:"focusOnRef",value:function(){this.props.inputRef&&this.props.inputRef.current.focus()}},{key:"render",value:function(){var t,e=this,n=this.props,a=n.classes,i=n.currentUser,s="".concat(f.get(i,["attributes","first_name"])||f.get(i,"first_name")," ").concat(f.get(i,["attributes","last_name"])||f.get(i,"last_name")),r=this.state.isInputFocused||this.state.attachmentUrl||this.state.comment||this.props.editComment||(null===(t=this.props.editAttachment)||void 0===t?void 0:t.url);return k.jsxs("div",{style:this.props.spaceAround?G.commentTextFieldContainerSpaceAround:G.commentTextFieldContainer,children:[k.jsx("div",{style:G.chatAvatarWrapper,children:k.jsx(v.AvatarComponent,{displayName:s,size:32,imgSrc:this.props.currentUser&&this.props.currentUser.profile_photo})}),k.jsx(m.Paper,{className:this.props.classes.paperRoot,children:k.jsx(m.TextField,{"data-testid":"".concat("commentInput","_input"),placeholder:"Type Comment",FormHelperTextProps:{component:"div",margin:"dense"},InputProps:{inputComponent:j,inputProps:{onChange:function(t){return e.setState({comment:t})},singleLine:!0,value:this.state.comment||"",inputRef:this.props.inputRef,withLightTheme:!1,onMount:this.props.onMount,companyId:this.props.companyId,autoFocus:this.props.autoFocus,disabled:this.props.disabled,onFocus:function(){return e.setState({isInputFocused:!0})},onBlur:function(){return e.setState({isInputFocused:!1})},allowSuggestionsAboveCursor:!0},endAdornment:!this.props.isNative&&k.jsxs(m.InputAdornment,{position:"end",className:this.props.classes.inputAdornment,children:[!this.state.attachmentUrl&&k.jsx("div",{className:K.default(x.cCommentInputIconContainer,x.cCommentInputIconUpload),children:k.jsx(b.default,{openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:this.handleFileUpload,onError:this.handleAttachmentLoadingError,fileUploadIconClassName:this.props.classes.additionalActionButton,htmlColor:V.default[400],inputId:"comment-attachment-".concat(this.props.editCommentId||this.props.parentId),tooltipProps:{title:"Attach File",classes:{tooltip:a.iconTooltip},placement:"top"}})}),k.jsx("div",{className:x.cCommentInputIconContainer,children:k.jsx(I,{"data-testid":"".concat("commentInput","_emojiButton"),handleSelectEmoji:this.handleSelectEmoji,emojiIconClassName:this.props.classes.additionalActionButton,htmlColor:V.default[400],disableRipple:!0,tooltipProps:{title:"Add Emoji",classes:{tooltip:a.iconTooltip},placement:"top"}})})]}),disableUnderline:!0,classes:{root:this.props.classes.inputRoot,input:this.props.classes.inputEl}},className:this.props.classes.input,onKeyDown:this.handleKeyDown})}),this.state.attachmentLoadingError&&k.jsx(y,{errorMessage:this.state.attachmentLoadingError,className:this.props.classes.fileUploadingError}),this.state.attachmentUrl&&k.jsx(F,{fileName:this.state.attachmentName,fileUrl:this.state.attachmentUrl,handleFileDelete:this.handleFileDelete,classes:this.props.classes}),k.jsx(m.Collapse,{in:r,mountOnEnter:!0,unmountOnExit:!0,children:k.jsxs("div",{className:x.cCommentInputSendContainer,children:[k.jsx("div",{className:x.cCommentInputSendContainerCancel,children:k.jsx(m.Typography,{"data-testid":"".concat("commentInput","_cancel"),variant:"caption",className:K.default(this.props.classes.inputMain,this.props.classes.cancelText,this.props.classes.highlightedLabel),component:"div",gutterBottom:!0,onClick:this.handleCancelClick,children:"Cancel"})}),k.jsxs("div",{className:x.cCommentInputSendContainerSend,children:[k.jsxs(m.Typography,{variant:"caption",className:K.default(this.props.classes.inputMain,this.props.classes.inputHelper),component:"div",gutterBottom:!0,children:["Press ",k.jsx(m.Typography,{variant:"caption",color:"primary",className:K.default(this.props.classes.inputMain,this.props.classes.highlightedLabel),children:"Enter"})," to send"]}),k.jsx(E,{size:"large",tooltipProps:{title:"Send"},"data-testid":"".concat("commentInput","_sendButton"),onClick:this.handleSendComment,classes:{root:this.props.classes.sendButton},children:k.jsx(S,{})})]})]})})]})}}]),n}(u.PureComponent);J.propTypes={inputRef:O.default.shape({current:O.default.shape({focus:O.default.shape({})})}),editFeedItemId:O.default.number,editCommentId:O.default.number,editComment:O.default.string,editAttachment:O.default.shape({url:O.default.string,size:O.default.number,file_name:O.default.string}),spaceAround:O.default.bool,postComment:O.default.func.isRequired,postCommentCallback:O.default.func,patchCommentCallback:O.default.func,exitEditMode:O.default.func,setIsPosting:O.default.func,setIsEditting:O.default.func,onMount:O.default.func,autoFocus:O.default.bool,disabled:O.default.bool,classes:O.default.shape({}).isRequired,currentUser:O.default.shape(),isNative:O.default.bool,companyId:O.default.number,parentId:O.default.string},J.defaultProps={inputRef:null,editFeedItemId:null,editCommentId:null,parentId:null,editComment:null,editAttachment:{},spaceAround:!1,setIsPosting:H.default,setIsEditting:H.default,onMount:H.default,autoFocus:void 0,disabled:!1,patchCommentCallback:H.default,postCommentCallback:H.default,exitEditMode:H.default,companyId:null,currentUser:{},isNative:A.isNativeDetected};var Q=p.withStyles((function(t){return{paperRoot:{width:"calc(100% - 48px)",marginLeft:48,display:"inline-block",height:32,border:"0","&:focus-within":{boxShadow:"inset 0 0 0 2px ".concat(t.palette.primary.main)},boxShadow:"none",background:"#4D4D4D"},input:{paddingLeft:5,width:"100%"},inputRoot:{height:32,paddingRight:"8px",lineHeight:"29px",paddingLeft:"8px"},inputEl:{padding:"0 0 0 6px",height:"100%"},additionalActionButton:{padding:"6px"},nativeActionButton:{margin:"5px 10px",cursor:"pointer"},fileUploadingError:{marginTop:10,marginLeft:24},inputMain:{marginBottom:0,fontSize:"11px",color:t.palette.primary.text8},inputHelper:{display:"flex",paddingRight:5},cancelText:{cursor:"pointer"},highlightedLabel:{color:t.palette.primary.main},iconTooltip:{marginTop:"3px"},sendButton:{"&:hover":{backgroundColor:"rgba(3,188,212, 0.1)"},"&.MuiButtonBase-root":{padding:7}},inputAdornment:{marginBottom:"0!important",height:"100%"}}}))(J);module.exports=Q;
|
|
1
|
+
"use strict";var e=require("react"),t=require("prop-types"),n=require("lodash/noop"),i=require("@material-ui/core/styles"),o=require("@material-ui/core"),a=require("classnames"),l=require("lodash"),r=require("@material-ui/core/colors/grey"),d=require("./useCommentInput.js"),s=require("./styles.css.js"),u=require("../Avatar/index.js"),c=require("../FileUploadIconButton.js"),p=require("../EmojiIconButton.js"),m=require("../FailedFileUploading.js"),h=require("../UserMention/index.js"),f=require("../FilePreview/index.js"),g=require("../IconButton/index.js"),x=require("../Icons/SendIcon.js"),C=require("../../utils/mobileDetect.js"),v=require("react/jsx-runtime");function I(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=I(t),b=I(n),y=I(a),F=I(r),A={chatAvatarWrapper:{display:"flex",alignItems:"center",position:"absolute",left:0,height:32},commentTextFieldContainer:{position:"relative",margin:"0"},commentTextFieldContainerSpaceAround:{position:"relative",margin:"20px 10px"}},q={},E=e.forwardRef((function(t,n){var i=t.inputRef,a=void 0===i?null:i,r=t.editFeedItemId,I=void 0===r?null:r,j=t.editCommentId,E=void 0===j?null:j,N=t.parentId,T=void 0===N?null:N,B=t.editComment,S=void 0===B?null:B,U=t.editAttachment,R=void 0===U?q:U,w=t.spaceAround,M=void 0!==w&&w,P=t.postComment,k=t.setIsPosting,L=void 0===k?b.default:k,D=t.setIsEditting,_=void 0===D?b.default:D,H=t.onMount,z=void 0===H?b.default:H,O=t.autoFocus,K=t.disabled,W=void 0!==K&&K,G=t.patchCommentCallback,J=void 0===G?b.default:G,Q=t.postCommentCallback,V=void 0===Q?b.default:Q,X=t.exitEditMode,Y=void 0===X?b.default:X,Z=t.companyId,$=void 0===Z?null:Z,ee=t.currentUser,te=void 0===ee?q:ee,ne=t.isNative,ie=void 0===ne?C.isNativeDetected:ne,oe=t.classes,ae=d({inputRef:a,editFeedItemId:I,editCommentId:E,editComment:S,editAttachment:R,postComment:P,setIsPosting:L,setIsEditting:_,patchCommentCallback:J,postCommentCallback:V,exitEditMode:Y}),le=ae.state,re=ae.update,de=ae.imperativeHandle,se=ae.handleSendComment,ue=ae.handleKeyDown,ce=ae.handleSelectEmoji,pe=ae.handleAttachmentLoadingError,me=ae.handleFileUpload,he=ae.handleFileDelete,fe=ae.handleCancelClick;e.useImperativeHandle(n,(function(){return de}),[de]);var ge="".concat(l.get(te,["attributes","first_name"])||l.get(te,"first_name")," ").concat(l.get(te,["attributes","last_name"])||l.get(te,"last_name")),xe=le.isInputFocused||le.attachmentUrl||le.comment||S||(null==R?void 0:R.url);return v.jsxs("div",{style:M?A.commentTextFieldContainerSpaceAround:A.commentTextFieldContainer,children:[v.jsx("div",{style:A.chatAvatarWrapper,children:v.jsx(u.AvatarComponent,{displayName:ge,size:32,imgSrc:te&&te.profile_photo})}),v.jsx(o.Paper,{className:oe.paperRoot,children:v.jsx(o.TextField,{"data-testid":"".concat("commentInput","_input"),placeholder:"Type Comment",FormHelperTextProps:{component:"div",margin:"dense"},InputProps:{inputComponent:h,inputProps:{onChange:function(e){return re({comment:e})},singleLine:!0,value:le.comment||"",inputRef:a,withLightTheme:!1,onMount:z,companyId:$,autoFocus:O,disabled:W,onFocus:function(){return re({isInputFocused:!0})},onBlur:function(){return re({isInputFocused:!1})},allowSuggestionsAboveCursor:!0},endAdornment:!ie&&v.jsxs(o.InputAdornment,{position:"end",className:oe.inputAdornment,children:[!le.attachmentUrl&&v.jsx("div",{className:y.default(s.cCommentInputIconContainer,s.cCommentInputIconUpload),children:v.jsx(c.default,{openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:me,onError:pe,fileUploadIconClassName:oe.additionalActionButton,htmlColor:F.default[400],inputId:"comment-attachment-".concat(E||T),tooltipProps:{title:"Attach File",classes:{tooltip:oe.iconTooltip},placement:"top"}})}),v.jsx("div",{className:s.cCommentInputIconContainer,children:v.jsx(p,{"data-testid":"".concat("commentInput","_emojiButton"),handleSelectEmoji:ce,emojiIconClassName:oe.additionalActionButton,htmlColor:F.default[400],disableRipple:!0,tooltipProps:{title:"Add Emoji",classes:{tooltip:oe.iconTooltip},placement:"top"}})})]}),disableUnderline:!0,classes:{root:oe.inputRoot,input:oe.inputEl}},className:oe.input,onKeyDown:ue})}),le.attachmentLoadingError&&v.jsx(m,{errorMessage:le.attachmentLoadingError,className:oe.fileUploadingError}),le.attachmentUrl&&v.jsx(f,{fileName:le.attachmentName,fileUrl:le.attachmentUrl,handleFileDelete:he,classes:oe}),v.jsx(o.Collapse,{in:xe,mountOnEnter:!0,unmountOnExit:!0,children:v.jsxs("div",{className:s.cCommentInputSendContainer,children:[v.jsx("div",{className:s.cCommentInputSendContainerCancel,children:v.jsx(o.Typography,{"data-testid":"".concat("commentInput","_cancel"),variant:"caption",className:y.default(oe.inputMain,oe.cancelText,oe.highlightedLabel),component:"div",gutterBottom:!0,onClick:fe,children:"Cancel"})}),v.jsxs("div",{className:s.cCommentInputSendContainerSend,children:[v.jsxs(o.Typography,{variant:"caption",className:y.default(oe.inputMain,oe.inputHelper),component:"div",gutterBottom:!0,children:["Press ",v.jsx(o.Typography,{variant:"caption",color:"primary",className:y.default(oe.inputMain,oe.highlightedLabel),children:"Enter"})," to send"]}),v.jsx(g,{size:"large",tooltipProps:{title:"Send"},"data-testid":"".concat("commentInput","_sendButton"),onClick:se,classes:{root:oe.sendButton},children:v.jsx(x,{})})]})]})})]})})),N={inputRef:j.default.shape({current:j.default.shape({focus:j.default.shape({})})}),editFeedItemId:j.default.number,editCommentId:j.default.number,editComment:j.default.string,editAttachment:j.default.shape({url:j.default.string,size:j.default.number,file_name:j.default.string}),spaceAround:j.default.bool,postComment:j.default.func.isRequired,postCommentCallback:j.default.func,patchCommentCallback:j.default.func,exitEditMode:j.default.func,setIsPosting:j.default.func,setIsEditting:j.default.func,onMount:j.default.func,autoFocus:j.default.bool,disabled:j.default.bool,classes:j.default.shape({}).isRequired,currentUser:j.default.shape(),isNative:j.default.bool,companyId:j.default.number,parentId:j.default.string};E.propTypes=N;var T=i.withStyles((function(e){return{paperRoot:{width:"calc(100% - 48px)",marginLeft:48,display:"inline-block",height:32,border:"0","&:focus-within":{boxShadow:"inset 0 0 0 2px ".concat(e.palette.primary.main)},boxShadow:"none",background:"#4D4D4D"},input:{paddingLeft:5,width:"100%"},inputRoot:{height:32,paddingRight:"8px",lineHeight:"29px",paddingLeft:"8px"},inputEl:{padding:"0 0 0 6px",height:"100%"},additionalActionButton:{padding:"6px"},nativeActionButton:{margin:"5px 10px",cursor:"pointer"},fileUploadingError:{marginTop:10,marginLeft:24},inputMain:{marginBottom:0,fontSize:"11px",color:e.palette.primary.text8},inputHelper:{display:"flex",paddingRight:5},cancelText:{cursor:"pointer"},highlightedLabel:{color:e.palette.primary.main},iconTooltip:{marginTop:"3px"},sendButton:{"&:hover":{backgroundColor:"rgba(3,188,212, 0.1)"},"&.MuiButtonBase-root":{padding:7}},inputAdornment:{marginBottom:"0!important",height:"100%"}}}))(e.memo(E));module.exports=T;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/CommentInput/index.js"],"sourcesContent":["import { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport noop from 'lodash/noop';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Collapse, Typography, TextField, InputAdornment, Paper } from '@material-ui/core';\nimport classNames from 'classnames';\nimport { get } from 'lodash';\nimport grey from '@material-ui/core/colors/grey';\n\nimport { patchFeedItemComment } from '../../clients/jsonApi';\n\nimport styles from './styles.css';\n\nimport Avatar from '~components/Avatar';\nimport FileUploadIconButton from '~components/FileUploadIconButton';\nimport EmojiIconButton from '~components/EmojiIconButton';\nimport FailedFileUploading from '~components/FailedFileUploading';\nimport UserMention from '~components/UserMention';\nimport FilePreview from '~components/FilePreview';\nimport IconButton from '~components/IconButton';\nimport SendIcon from '~components/Icons/SendIcon';\nimport { isSuggestionsListOpened } from '~components/UserMention/utils';\nimport utils from '~utils/main';\nimport { isNativeDetected } from '~/utils/mobileDetect';\nimport { notifyCommentEdit, notifyCommentPost } from '~utils/nativeMessages'; // question here\n\nconst PAGE_NAME = 'commentInput';\n\nconst INPUT_HEIGHT = 32;\nconst AVATAR_SIZE = 32;\n\nconst style = {\n chatAvatarWrapper: {\n display: 'flex',\n alignItems: 'center',\n position: 'absolute',\n left: 0,\n height: INPUT_HEIGHT,\n },\n commentTextFieldContainer: { position: 'relative', margin: '0' },\n commentTextFieldContainerSpaceAround: { position: 'relative', margin: '20px 10px' },\n};\n\nconst muiStyles = theme => ({\n paperRoot: {\n width: 'calc(100% - 48px)',\n marginLeft: AVATAR_SIZE + 16,\n display: 'inline-block',\n height: INPUT_HEIGHT,\n border: '0',\n '&:focus-within': {\n boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}`,\n },\n boxShadow: 'none',\n background: '#4D4D4D',\n },\n input: {\n paddingLeft: 5,\n width: '100%',\n },\n inputRoot: {\n height: INPUT_HEIGHT,\n paddingRight: '8px',\n lineHeight: '29px',\n paddingLeft: '8px',\n },\n inputEl: { padding: '0 0 0 6px', height: '100%' },\n additionalActionButton: {\n padding: '6px',\n },\n nativeActionButton: {\n margin: '5px 10px',\n cursor: 'pointer',\n },\n fileUploadingError: {\n marginTop: 10,\n marginLeft: 24,\n },\n inputMain: {\n marginBottom: 0,\n fontSize: '11px',\n color: theme.palette.primary.text8,\n },\n inputHelper: {\n display: 'flex',\n paddingRight: 5,\n },\n cancelText: {\n cursor: 'pointer',\n },\n highlightedLabel: {\n color: theme.palette.primary.main,\n },\n iconTooltip: {\n marginTop: '3px',\n },\n sendButton: {\n '&:hover': {\n backgroundColor: 'rgba(3,188,212, 0.1)',\n },\n '&.MuiButtonBase-root': {\n padding: 7,\n },\n },\n inputAdornment: {\n marginBottom: '0!important',\n height: '100%',\n },\n});\n\nclass CommentInput extends PureComponent {\n constructor(props) {\n super(props);\n\n this.state = {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n\n attachmentLoadingError: null,\n isInputFocused: false,\n };\n }\n\n componentDidMount() {\n if (this.isEditMode) {\n this.setInitialCommentValue();\n }\n }\n\n componentDidUpdate(prevProps) {\n const enteredEditMode = this.isEditMode && !prevProps.editFeedItemId;\n if (\n enteredEditMode ||\n (this.props.editCommentId && this.props.editCommentId !== prevProps.editCommentId)\n ) {\n this.setInitialCommentValue();\n }\n }\n\n get isEditMode() {\n return !!this.props.editFeedItemId;\n }\n\n setInitialCommentValue() {\n const attachmentUrl = this.props.editAttachment ? this.props.editAttachment.url : null;\n\n this.setState({\n comment: this.props.editComment,\n attachmentUrl,\n attachmentName: attachmentUrl\n ? this.props.editAttachment.file_name ||\n utils.getFileNameWithExtensionFromPath(attachmentUrl)\n : null,\n attachmentSize: this.props.editAttachment ? this.props.editAttachment.size : null,\n });\n }\n\n handleSelectEmoji = emoji =>\n this.setState(({ comment }) => ({ comment: `${comment}${emoji.native}` }));\n\n postComment = async comment => {\n let commentResponse;\n try {\n commentResponse = await this.props.postComment(comment);\n } catch (e) {\n console.error(e.message);\n }\n\n return commentResponse;\n };\n\n patchComment = async comment => {\n const { editFeedItemId, editCommentId } = this.props;\n\n let commentResponse;\n\n try {\n commentResponse = await patchFeedItemComment(editFeedItemId, editCommentId, comment);\n } catch (e) {\n console.error(e.message);\n }\n\n return commentResponse;\n };\n\n focusOnRef() {\n if (this.props.inputRef) this.props.inputRef.current.focus();\n }\n\n clearCommentField = callback => {\n this.setState(\n {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n },\n () => {\n this.focusOnRef();\n if (callback && typeof callback === 'function') callback();\n }\n );\n };\n\n handleKeyDown = event => {\n const { key } = event;\n\n if (key === 'Escape') this.props.exitEditMode();\n\n if (key === 'Enter') {\n if (!isSuggestionsListOpened()) {\n event.preventDefault();\n this.handleSendComment();\n }\n }\n };\n\n handleAttachmentLoadingError = attachmentLoadingError => {\n this.setState({\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n attachmentLoadingError,\n });\n };\n\n handleFileUpload = (attachmentUrl, attachmentName, attachmentSize) => {\n this.setState({\n attachmentUrl,\n attachmentName,\n attachmentSize,\n attachmentLoadingError: null,\n });\n };\n\n handleNativeFileUpload = () => {\n const { comment } = this.state;\n\n if (this.isEditMode) {\n notifyCommentEdit(comment);\n this.clearCommentField(this.props.exitEditMode);\n } else {\n notifyCommentPost(comment);\n this.clearCommentField();\n }\n };\n\n handleFileDelete = () =>\n this.setState({ attachmentUrl: null, attachmentName: null, attachmentSize: null });\n\n handleSendComment = async () => {\n const textComment = this.state.comment ? this.state.comment.trim() : null;\n if (!textComment && !this.state.attachmentUrl) return;\n\n const comment = {\n comment: {\n body: textComment,\n attachment: {\n url: this.state.attachmentUrl,\n size: this.state.attachmentSize,\n file_name: this.state.attachmentName,\n },\n },\n };\n\n let commentResponse;\n\n if (this.isEditMode) {\n this.props.setIsEditting(true);\n\n commentResponse = await this.patchComment(comment);\n await this.props.patchCommentCallback(commentResponse);\n\n this.props.setIsEditting(false);\n this.clearCommentField();\n this.props.exitEditMode();\n } else {\n this.props.setIsPosting(true);\n\n commentResponse = await this.postComment(comment);\n await this.props.postCommentCallback(commentResponse);\n\n this.props.setIsPosting(false);\n this.clearCommentField();\n }\n };\n\n handleCancelClick = () => {\n this.setState(\n {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n },\n this.props.exitEditMode()\n );\n };\n\n render() {\n const { classes, currentUser } = this.props;\n\n const currentUserFullName = `${\n get(currentUser, ['attributes', 'first_name']) || get(currentUser, 'first_name')\n } ${get(currentUser, ['attributes', 'last_name']) || get(currentUser, 'last_name')}`;\n\n const isVisibleActionBar =\n this.state.isInputFocused ||\n this.state.attachmentUrl ||\n this.state.comment ||\n this.props.editComment ||\n this.props.editAttachment?.url;\n\n return (\n <div\n style={\n this.props.spaceAround\n ? style.commentTextFieldContainerSpaceAround\n : style.commentTextFieldContainer\n }\n >\n <div style={style.chatAvatarWrapper}>\n <Avatar\n displayName={currentUserFullName}\n size={AVATAR_SIZE}\n imgSrc={this.props.currentUser && this.props.currentUser.profile_photo}\n />\n </div>\n <Paper className={this.props.classes.paperRoot}>\n <TextField\n data-testid={`${PAGE_NAME}_input`}\n placeholder=\"Type Comment\"\n FormHelperTextProps={{\n component: 'div',\n margin: 'dense',\n }}\n InputProps={{\n inputComponent: UserMention,\n inputProps: {\n onChange: comment => this.setState({ comment }),\n singleLine: true,\n value: this.state.comment || '',\n inputRef: this.props.inputRef,\n withLightTheme: false,\n onMount: this.props.onMount,\n companyId: this.props.companyId,\n autoFocus: this.props.autoFocus,\n disabled: this.props.disabled,\n onFocus: () => this.setState({ isInputFocused: true }),\n onBlur: () => this.setState({ isInputFocused: false }),\n allowSuggestionsAboveCursor: true,\n },\n endAdornment: !this.props.isNative && (\n <InputAdornment position=\"end\" className={this.props.classes.inputAdornment}>\n {!this.state.attachmentUrl && (\n <div\n className={classNames(\n styles.cCommentInputIconContainer,\n styles.cCommentInputIconUpload\n )}\n >\n <FileUploadIconButton\n openPreviewDialogOnUpload={false}\n disableRipple\n onFinish={this.handleFileUpload}\n onError={this.handleAttachmentLoadingError}\n fileUploadIconClassName={this.props.classes.additionalActionButton}\n htmlColor={grey[400]}\n inputId={`comment-attachment-${\n this.props.editCommentId || this.props.parentId\n }`}\n tooltipProps={{\n title: 'Attach File',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n )}\n <div className={styles.cCommentInputIconContainer}>\n <EmojiIconButton\n data-testid={`${PAGE_NAME}_emojiButton`}\n handleSelectEmoji={this.handleSelectEmoji}\n emojiIconClassName={this.props.classes.additionalActionButton}\n htmlColor={grey[400]}\n disableRipple\n tooltipProps={{\n title: 'Add Emoji',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n </InputAdornment>\n ),\n disableUnderline: true,\n classes: {\n root: this.props.classes.inputRoot,\n input: this.props.classes.inputEl,\n },\n }}\n className={this.props.classes.input}\n onKeyDown={this.handleKeyDown}\n />\n </Paper>\n\n {this.state.attachmentLoadingError && (\n <FailedFileUploading\n errorMessage={this.state.attachmentLoadingError}\n className={this.props.classes.fileUploadingError}\n />\n )}\n\n {this.state.attachmentUrl && (\n <FilePreview\n fileName={this.state.attachmentName}\n fileUrl={this.state.attachmentUrl}\n handleFileDelete={this.handleFileDelete}\n classes={this.props.classes}\n />\n )}\n <Collapse in={isVisibleActionBar} mountOnEnter unmountOnExit>\n <div className={styles.cCommentInputSendContainer}>\n <div className={styles.cCommentInputSendContainerCancel}>\n <Typography\n data-testid={`${PAGE_NAME}_cancel`}\n variant=\"caption\"\n className={classNames(\n this.props.classes.inputMain,\n this.props.classes.cancelText,\n this.props.classes.highlightedLabel\n )}\n component=\"div\"\n gutterBottom\n onClick={this.handleCancelClick}\n >\n Cancel\n </Typography>\n </div>\n <div className={styles.cCommentInputSendContainerSend}>\n <Typography\n variant=\"caption\"\n className={classNames(this.props.classes.inputMain, this.props.classes.inputHelper)}\n component=\"div\"\n gutterBottom\n >\n Press \n <Typography\n variant=\"caption\"\n color=\"primary\"\n className={classNames(\n this.props.classes.inputMain,\n this.props.classes.highlightedLabel\n )}\n >\n Enter\n </Typography>\n to send\n </Typography>\n <IconButton\n size=\"large\"\n tooltipProps={{ title: 'Send' }}\n data-testid={`${PAGE_NAME}_sendButton`}\n onClick={this.handleSendComment}\n classes={{ root: this.props.classes.sendButton }}\n >\n <SendIcon />\n </IconButton>\n </div>\n </div>\n </Collapse>\n </div>\n );\n }\n}\n\nCommentInput.propTypes = {\n inputRef: PropTypes.shape({ current: PropTypes.shape({ focus: PropTypes.shape({}) }) }),\n editFeedItemId: PropTypes.number,\n editCommentId: PropTypes.number,\n editComment: PropTypes.string,\n editAttachment: PropTypes.shape({\n url: PropTypes.string,\n size: PropTypes.number,\n file_name: PropTypes.string,\n }),\n spaceAround: PropTypes.bool,\n postComment: PropTypes.func.isRequired,\n postCommentCallback: PropTypes.func,\n patchCommentCallback: PropTypes.func,\n exitEditMode: PropTypes.func,\n setIsPosting: PropTypes.func,\n setIsEditting: PropTypes.func,\n onMount: PropTypes.func,\n autoFocus: PropTypes.bool,\n disabled: PropTypes.bool,\n\n classes: PropTypes.shape({}).isRequired,\n\n currentUser: PropTypes.shape(),\n isNative: PropTypes.bool,\n companyId: PropTypes.number,\n parentId: PropTypes.string,\n};\n\nCommentInput.defaultProps = {\n inputRef: null,\n editFeedItemId: null,\n editCommentId: null,\n parentId: null,\n editComment: null,\n editAttachment: {},\n spaceAround: false,\n setIsPosting: noop,\n setIsEditting: noop,\n onMount: noop,\n autoFocus: undefined,\n disabled: false,\n patchCommentCallback: noop,\n postCommentCallback: noop,\n exitEditMode: noop,\n companyId: null,\n currentUser: {},\n\n isNative: isNativeDetected,\n};\n\nexport default withStyles(muiStyles)(CommentInput);\n"],"names":["style","chatAvatarWrapper","display","alignItems","position","left","height","commentTextFieldContainer","margin","commentTextFieldContainerSpaceAround","CommentInput","_PureComponent","_inherits","_super","_createSuper","props","_this","_ref2","_ref3","_classCallCheck","this","call","_defineProperty","_assertThisInitialized","emoji","setState","_ref","comment","native","_asyncToGenerator","_regeneratorRuntime","mark","commentResponse","wrap","_context","prev","next","postComment","sent","t0","console","error","message","abrupt","stop","_callee","_x","apply","arguments","_this$props","editFeedItemId","editCommentId","_context2","patchFeedItemComment","_callee2","_x2","callback","attachmentUrl","attachmentName","attachmentSize","focusOnRef","event","key","exitEditMode","isSuggestionsListOpened","preventDefault","handleSendComment","attachmentLoadingError","state","isEditMode","notifyCommentEdit","clearCommentField","notifyCommentPost","_callee3","textComment","_context3","trim","body","attachment","url","size","file_name","setIsEditting","patchComment","patchCommentCallback","setIsPosting","postCommentCallback","isInputFocused","_createClass","value","setInitialCommentValue","prevProps","get","editAttachment","editComment","utils","getFileNameWithExtensionFromPath","inputRef","current","focus","_this$props$editAttac","_this2","_this$props2","classes","currentUser","currentUserFullName","concat","isVisibleActionBar","_jsxs","spaceAround","children","_jsx","jsx","Avatar","displayName","imgSrc","profile_photo","Paper","className","paperRoot","TextField","placeholder","FormHelperTextProps","component","InputProps","inputComponent","UserMention","inputProps","onChange","singleLine","withLightTheme","onMount","companyId","autoFocus","disabled","onFocus","onBlur","allowSuggestionsAboveCursor","endAdornment","isNative","InputAdornment","inputAdornment","classNames","styles","cCommentInputIconContainer","cCommentInputIconUpload","FileUploadIconButton","openPreviewDialogOnUpload","disableRipple","onFinish","handleFileUpload","onError","handleAttachmentLoadingError","fileUploadIconClassName","additionalActionButton","htmlColor","grey","inputId","parentId","tooltipProps","title","tooltip","iconTooltip","placement","EmojiIconButton","handleSelectEmoji","emojiIconClassName","disableUnderline","root","inputRoot","input","inputEl","onKeyDown","handleKeyDown","FailedFileUploading","errorMessage","fileUploadingError","FilePreview","fileName","fileUrl","handleFileDelete","Collapse","in","mountOnEnter","unmountOnExit","jsxs","cCommentInputSendContainer","cCommentInputSendContainerCancel","Typography","variant","inputMain","cancelText","highlightedLabel","gutterBottom","onClick","handleCancelClick","cCommentInputSendContainerSend","inputHelper","color","IconButton","sendButton","SendIcon","PureComponent","propTypes","PropTypes","shape","number","string","bool","func","isRequired","defaultProps","noop","undefined","isNativeDetected","CommentInput$1","withStyles","theme","width","marginLeft","AVATAR_SIZE","border","boxShadow","palette","primary","main","background","paddingLeft","paddingRight","lineHeight","padding","nativeActionButton","cursor","marginTop","marginBottom","fontSize","text8","backgroundColor"],"mappings":"40DA0BA,IAKMA,EAAQ,CACZC,kBAAmB,CACjBC,QAAS,OACTC,WAAY,SACZC,SAAU,WACVC,KAAM,EACNC,OATiB,IAWnBC,0BAA2B,CAAEH,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../../src/components/CommentInput/index.js"],"sourcesContent":["import { forwardRef, memo, useImperativeHandle } from 'react';\nimport PropTypes from 'prop-types';\nimport noop from 'lodash/noop';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Collapse, Typography, TextField, InputAdornment, Paper } from '@material-ui/core';\nimport classNames from 'classnames';\nimport { get } from 'lodash';\nimport grey from '@material-ui/core/colors/grey';\n\nimport useCommentInput from './useCommentInput';\n\nimport styles from './styles.css';\n\nimport Avatar from '~components/Avatar';\nimport FileUploadIconButton from '~components/FileUploadIconButton';\nimport EmojiIconButton from '~components/EmojiIconButton';\nimport FailedFileUploading from '~components/FailedFileUploading';\nimport UserMention from '~components/UserMention';\nimport FilePreview from '~components/FilePreview';\nimport IconButton from '~components/IconButton';\nimport SendIcon from '~components/Icons/SendIcon';\nimport { isNativeDetected } from '~/utils/mobileDetect';\n\nconst PAGE_NAME = 'commentInput';\n\nconst INPUT_HEIGHT = 32;\nconst AVATAR_SIZE = 32;\n\nconst style = {\n chatAvatarWrapper: {\n display: 'flex',\n alignItems: 'center',\n position: 'absolute',\n left: 0,\n height: INPUT_HEIGHT,\n },\n commentTextFieldContainer: { position: 'relative', margin: '0' },\n commentTextFieldContainerSpaceAround: { position: 'relative', margin: '20px 10px' },\n};\n\nconst muiStyles = theme => ({\n paperRoot: {\n width: 'calc(100% - 48px)',\n marginLeft: AVATAR_SIZE + 16,\n display: 'inline-block',\n height: INPUT_HEIGHT,\n border: '0',\n '&:focus-within': {\n boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}`,\n },\n boxShadow: 'none',\n background: '#4D4D4D',\n },\n input: {\n paddingLeft: 5,\n width: '100%',\n },\n inputRoot: {\n height: INPUT_HEIGHT,\n paddingRight: '8px',\n lineHeight: '29px',\n paddingLeft: '8px',\n },\n inputEl: { padding: '0 0 0 6px', height: '100%' },\n additionalActionButton: {\n padding: '6px',\n },\n nativeActionButton: {\n margin: '5px 10px',\n cursor: 'pointer',\n },\n fileUploadingError: {\n marginTop: 10,\n marginLeft: 24,\n },\n inputMain: {\n marginBottom: 0,\n fontSize: '11px',\n color: theme.palette.primary.text8,\n },\n inputHelper: {\n display: 'flex',\n paddingRight: 5,\n },\n cancelText: {\n cursor: 'pointer',\n },\n highlightedLabel: {\n color: theme.palette.primary.main,\n },\n iconTooltip: {\n marginTop: '3px',\n },\n sendButton: {\n '&:hover': {\n backgroundColor: 'rgba(3,188,212, 0.1)',\n },\n '&.MuiButtonBase-root': {\n padding: 7,\n },\n },\n inputAdornment: {\n marginBottom: '0!important',\n height: '100%',\n },\n});\n\nconst emptyObject = {};\n\nconst CommentInput = forwardRef(\n /** @param {PropTypes.InferProps<typeof propTypes>} props */ function CommentInput(\n {\n inputRef = null,\n editFeedItemId = null,\n editCommentId = null,\n parentId = null,\n editComment = null,\n editAttachment = emptyObject,\n spaceAround = false,\n postComment,\n setIsPosting = noop,\n setIsEditting = noop,\n onMount = noop,\n autoFocus,\n disabled = false,\n patchCommentCallback = noop,\n postCommentCallback = noop,\n exitEditMode = noop,\n companyId = null,\n currentUser = emptyObject,\n isNative = isNativeDetected,\n classes,\n },\n ref\n ) {\n const {\n state,\n update,\n imperativeHandle,\n handleSendComment,\n handleKeyDown,\n handleSelectEmoji,\n handleAttachmentLoadingError,\n handleFileUpload,\n handleFileDelete,\n handleCancelClick,\n } = useCommentInput({\n inputRef,\n editFeedItemId,\n editCommentId,\n editComment,\n editAttachment,\n postComment,\n setIsPosting,\n setIsEditting,\n patchCommentCallback,\n postCommentCallback,\n exitEditMode,\n });\n useImperativeHandle(ref, () => imperativeHandle, [imperativeHandle]);\n\n const currentUserFullName = `${\n get(currentUser, ['attributes', 'first_name']) || get(currentUser, 'first_name')\n } ${get(currentUser, ['attributes', 'last_name']) || get(currentUser, 'last_name')}`;\n\n const isVisibleActionBar =\n state.isInputFocused ||\n state.attachmentUrl ||\n state.comment ||\n editComment ||\n editAttachment?.url;\n\n return (\n <div\n style={\n spaceAround ? style.commentTextFieldContainerSpaceAround : style.commentTextFieldContainer\n }\n >\n <div style={style.chatAvatarWrapper}>\n <Avatar\n displayName={currentUserFullName}\n size={AVATAR_SIZE}\n imgSrc={currentUser && currentUser.profile_photo}\n />\n </div>\n <Paper className={classes.paperRoot}>\n <TextField\n data-testid={`${PAGE_NAME}_input`}\n placeholder=\"Type Comment\"\n FormHelperTextProps={{\n component: 'div',\n margin: 'dense',\n }}\n InputProps={{\n inputComponent: UserMention,\n inputProps: {\n onChange: comment => update({ comment }),\n singleLine: true,\n value: state.comment || '',\n inputRef: inputRef,\n withLightTheme: false,\n onMount: onMount,\n companyId: companyId,\n autoFocus: autoFocus,\n disabled: disabled,\n onFocus: () => update({ isInputFocused: true }),\n onBlur: () => update({ isInputFocused: false }),\n allowSuggestionsAboveCursor: true,\n },\n endAdornment: !isNative && (\n <InputAdornment position=\"end\" className={classes.inputAdornment}>\n {!state.attachmentUrl && (\n <div\n className={classNames(\n styles.cCommentInputIconContainer,\n styles.cCommentInputIconUpload\n )}\n >\n <FileUploadIconButton\n openPreviewDialogOnUpload={false}\n disableRipple\n onFinish={handleFileUpload}\n onError={handleAttachmentLoadingError}\n fileUploadIconClassName={classes.additionalActionButton}\n htmlColor={grey[400]}\n inputId={`comment-attachment-${editCommentId || parentId}`}\n tooltipProps={{\n title: 'Attach File',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n )}\n <div className={styles.cCommentInputIconContainer}>\n <EmojiIconButton\n data-testid={`${PAGE_NAME}_emojiButton`}\n handleSelectEmoji={handleSelectEmoji}\n emojiIconClassName={classes.additionalActionButton}\n htmlColor={grey[400]}\n disableRipple\n tooltipProps={{\n title: 'Add Emoji',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n </InputAdornment>\n ),\n disableUnderline: true,\n classes: {\n root: classes.inputRoot,\n input: classes.inputEl,\n },\n }}\n className={classes.input}\n onKeyDown={handleKeyDown}\n />\n </Paper>\n\n {state.attachmentLoadingError && (\n <FailedFileUploading\n errorMessage={state.attachmentLoadingError}\n className={classes.fileUploadingError}\n />\n )}\n\n {state.attachmentUrl && (\n <FilePreview\n fileName={state.attachmentName}\n fileUrl={state.attachmentUrl}\n handleFileDelete={handleFileDelete}\n classes={classes}\n />\n )}\n <Collapse in={isVisibleActionBar} mountOnEnter unmountOnExit>\n <div className={styles.cCommentInputSendContainer}>\n <div className={styles.cCommentInputSendContainerCancel}>\n <Typography\n data-testid={`${PAGE_NAME}_cancel`}\n variant=\"caption\"\n className={classNames(\n classes.inputMain,\n classes.cancelText,\n classes.highlightedLabel\n )}\n component=\"div\"\n gutterBottom\n onClick={handleCancelClick}\n >\n Cancel\n </Typography>\n </div>\n <div className={styles.cCommentInputSendContainerSend}>\n <Typography\n variant=\"caption\"\n className={classNames(classes.inputMain, classes.inputHelper)}\n component=\"div\"\n gutterBottom\n >\n Press \n <Typography\n variant=\"caption\"\n color=\"primary\"\n className={classNames(classes.inputMain, classes.highlightedLabel)}\n >\n Enter\n </Typography>\n to send\n </Typography>\n <IconButton\n size=\"large\"\n tooltipProps={{ title: 'Send' }}\n data-testid={`${PAGE_NAME}_sendButton`}\n onClick={handleSendComment}\n classes={{ root: classes.sendButton }}\n >\n <SendIcon />\n </IconButton>\n </div>\n </div>\n </Collapse>\n </div>\n );\n }\n);\n\nconst propTypes = {\n inputRef: PropTypes.shape({ current: PropTypes.shape({ focus: PropTypes.shape({}) }) }),\n editFeedItemId: PropTypes.number,\n editCommentId: PropTypes.number,\n editComment: PropTypes.string,\n editAttachment: PropTypes.shape({\n url: PropTypes.string,\n size: PropTypes.number,\n file_name: PropTypes.string,\n }),\n spaceAround: PropTypes.bool,\n postComment: PropTypes.func.isRequired,\n postCommentCallback: PropTypes.func,\n patchCommentCallback: PropTypes.func,\n exitEditMode: PropTypes.func,\n setIsPosting: PropTypes.func,\n setIsEditting: PropTypes.func,\n onMount: PropTypes.func,\n autoFocus: PropTypes.bool,\n disabled: PropTypes.bool,\n\n classes: PropTypes.shape({}).isRequired,\n\n currentUser: PropTypes.shape(),\n isNative: PropTypes.bool,\n companyId: PropTypes.number,\n parentId: PropTypes.string,\n};\n\nCommentInput.propTypes = propTypes;\n\nexport default withStyles(muiStyles)(memo(CommentInput));\n"],"names":["style","chatAvatarWrapper","display","alignItems","position","left","height","commentTextFieldContainer","margin","commentTextFieldContainerSpaceAround","emptyObject","CommentInput","forwardRef","ref","_ref$inputRef","_ref","inputRef","_ref$editFeedItemId","editFeedItemId","_ref$editCommentId","editCommentId","_ref$parentId","parentId","_ref$editComment","editComment","_ref$editAttachment","editAttachment","_ref$spaceAround","spaceAround","postComment","_ref$setIsPosting","setIsPosting","noop","_ref$setIsEditting","setIsEditting","_ref$onMount","onMount","autoFocus","_ref$disabled","disabled","_ref$patchCommentCall","patchCommentCallback","_ref$postCommentCallb","postCommentCallback","_ref$exitEditMode","exitEditMode","_ref$companyId","companyId","_ref$currentUser","currentUser","_ref$isNative","isNative","isNativeDetected","classes","_useCommentInput","useCommentInput","state","update","imperativeHandle","handleSendComment","handleKeyDown","handleSelectEmoji","handleAttachmentLoadingError","handleFileUpload","handleFileDelete","handleCancelClick","useImperativeHandle","currentUserFullName","get","concat","isVisibleActionBar","isInputFocused","attachmentUrl","comment","url","_jsxs","children","_jsx","jsx","Avatar","displayName","size","imgSrc","profile_photo","Paper","className","paperRoot","TextField","placeholder","FormHelperTextProps","component","InputProps","inputComponent","UserMention","inputProps","onChange","singleLine","value","withLightTheme","onFocus","onBlur","allowSuggestionsAboveCursor","endAdornment","InputAdornment","inputAdornment","classNames","styles","cCommentInputIconContainer","cCommentInputIconUpload","FileUploadIconButton","openPreviewDialogOnUpload","disableRipple","onFinish","onError","fileUploadIconClassName","additionalActionButton","htmlColor","grey","inputId","tooltipProps","title","tooltip","iconTooltip","placement","EmojiIconButton","emojiIconClassName","disableUnderline","root","inputRoot","input","inputEl","onKeyDown","attachmentLoadingError","FailedFileUploading","errorMessage","fileUploadingError","FilePreview","fileName","attachmentName","fileUrl","Collapse","in","mountOnEnter","unmountOnExit","jsxs","cCommentInputSendContainer","cCommentInputSendContainerCancel","Typography","variant","inputMain","cancelText","highlightedLabel","gutterBottom","onClick","cCommentInputSendContainerSend","inputHelper","color","IconButton","sendButton","SendIcon","propTypes","PropTypes","shape","current","focus","number","string","file_name","bool","func","isRequired","withStyles","theme","width","marginLeft","AVATAR_SIZE","border","boxShadow","palette","primary","main","background","paddingLeft","paddingRight","lineHeight","padding","nativeActionButton","cursor","marginTop","marginBottom","fontSize","text8","backgroundColor","memo"],"mappings":"kwBA4BMA,EAAQ,CACZC,kBAAmB,CACjBC,QAAS,OACTC,WAAY,SACZC,SAAU,WACVC,KAAM,EACNC,OATiB,IAWnBC,0BAA2B,CAAEH,SAAU,WAAYI,OAAQ,KAC3DC,qCAAsC,CAAEL,SAAU,WAAYI,OAAQ,cAsElEE,EAAc,CAAA,EAEdC,EAAeC,EAAAA,YAC0C,SAuB3DC,EAAAA,GACA,IAAAC,EAAAC,EAtBEC,SAAAA,aAAW,KAAIF,EAAAG,EAAAF,EACfG,eAAAA,aAAiB,KAAID,EAAAE,EAAAJ,EACrBK,cAAAA,aAAgB,KAAID,EAAAE,EAAAN,EACpBO,SAAAA,aAAW,KAAID,EAAAE,EAAAR,EACfS,YAAAA,aAAc,KAAID,EAAAE,EAAAV,EAClBW,eAAAA,aAAiBhB,EAAWe,EAAAE,EAAAZ,EAC5Ba,YAAAA,cAAmBD,EACnBE,IAAAA,YAAWC,EAAAf,EACXgB,aAAAA,aAAeC,EAAI,QAAAF,EAAAG,EAAAlB,EACnBmB,cAAAA,aAAgBF,EAAI,QAAAC,EAAAE,EAAApB,EACpBqB,QAAAA,aAAUJ,EAAI,QAAAG,EACdE,IAAAA,UAASC,EAAAvB,EACTwB,SAAAA,cAAgBD,EAAAE,EAAAzB,EAChB0B,qBAAAA,aAAuBT,EAAI,QAAAQ,EAAAE,EAAA3B,EAC3B4B,oBAAAA,aAAsBX,EAAI,QAAAU,EAAAE,EAAA7B,EAC1B8B,a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,IAEdzB,UAAW,CACTwC,aAAc,EACdC,SAAU,OACVlC,MAAOgB,EAAMM,QAAQC,QAAQY,OAE/BpC,YAAa,CACXzJ,QAAS,OACTqL,aAAc,GAEhBjC,WAAY,CACVqC,OAAQ,WAEVpC,iBAAkB,CAChBK,MAAOgB,EAAMM,QAAQC,QAAQC,MAE/B1D,YAAa,CACXkE,UAAW,OAEb9B,WAAY,CACV,UAAW,CACTkC,gBAAiB,wBAEnB,uBAAwB,CACtBP,QAAS,IAGbjF,eAAgB,CACdqF,aAAc,cACdvL,OAAQ,QAEX,GA8PcqK,CAAsBsB,EAAIA,KAACtL"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/defineProperty"),n=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/regenerator"),a=require("react"),c=require("../../clients/jsonApi/index.js"),u=require("../UserMention/utils/index.js"),o=require("../../utils/main.js"),i=require("../../utils/nativeMessages.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=s(e),m=s(t),p=s(n),d=s(r);function f(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 h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach((function(t){m.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var b={comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null};module.exports=function(e){var t=a.useState(h(h({},b),{},{attachmentLoadingError:null,isInputFocused:!1})),n=p.default(t,2),r=n[0],s=n[1],m=a.useRef({props:e,state:r}),f=a.useRef(null),v=a.useRef([]),y=a.useCallback((function(e){return s((function(t){return h(h({},t),e)}))}),[]),C=function(){m.current.props.inputRef&&m.current.props.inputRef.current.focus()},I=function(){var e=m.current.props,t=e.editAttachment?e.editAttachment.url:null;y({comment:e.editComment,attachmentUrl:t,attachmentName:t?e.editAttachment.file_name||o.default.getFileNameWithExtensionFromPath(t):null,attachmentSize:e.editAttachment?e.editAttachment.size:null})};a.useLayoutEffect((function(){m.current={props:e,state:r};var t=f.current;f.current=e,(!t&&e.editFeedItemId||e.editFeedItemId&&t&&!t.editFeedItemId||t&&e.editCommentId&&e.editCommentId!==t.editCommentId)&&I();var n=v.current;v.current=[],n.forEach((function(e){var t=e.focus,n=e.callback;t&&C(),"function"==typeof n&&n()}))}));var g,k=function(e){v.current.push({focus:!0,callback:e}),y(b)},E=(g=l.default(d.default.mark((function e(){var t,n,r,a,u,o,i;return d.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=m.current,(n=t.state.comment?t.state.comment.trim():null)||t.state.attachmentUrl){e.next=4;break}return e.abrupt("return");case 4:if(r={comment:{body:n,attachment:{url:t.state.attachmentUrl,size:t.state.attachmentSize,file_name:t.state.attachmentName}}},!t.props.editFeedItemId){e.next=24;break}return t.props.setIsEditting(!0),e.prev=7,u=m.current.props,o=u.editFeedItemId,i=u.editCommentId,e.next=11,c.patchFeedItemComment(o,i,r);case 11:a=e.sent,e.next=17;break;case 14:e.prev=14,e.t0=e.catch(7),console.error(e.t0.message);case 17:return e.next=19,m.current.props.patchCommentCallback(a);case 19:m.current.props.setIsEditting(!1),k(),m.current.props.exitEditMode(),e.next=38;break;case 24:return t.props.setIsPosting(!0),e.prev=25,e.next=28,m.current.props.postComment(r);case 28:a=e.sent,e.next=34;break;case 31:e.prev=31,e.t1=e.catch(25),console.error(e.t1.message);case 34:return e.next=36,m.current.props.postCommentCallback(a);case 36:m.current.props.setIsPosting(!1),k();case 38:case"end":return e.stop()}}),e,null,[[7,14],[25,31]])}))),function(){return g.apply(this,arguments)}),O=a.useRef({clearCommentField:k,focusOnRef:C,setInitialCommentValue:I,handleNativeFileUpload:function(){var e=m.current;e.props.editFeedItemId?(i.notifyCommentEdit(e.state.comment),k(m.current.props.exitEditMode)):(i.notifyCommentPost(e.state.comment),k())},handleSendComment:E}),j=a.useCallback((function(e){return s((function(t){return h(h({},t),{},{comment:"".concat(t.comment).concat(e.native)})}))}),[]),x=a.useCallback((function(e){return y({attachmentUrl:null,attachmentName:null,attachmentSize:null,attachmentLoadingError:e})}),[y]),F=a.useCallback((function(e,t,n){return y({attachmentUrl:e,attachmentName:t,attachmentSize:n,attachmentLoadingError:null})}),[y]);return{state:r,update:y,imperativeHandle:O.current,handleSendComment:E,handleKeyDown:function(e){"Escape"===e.key&&m.current.props.exitEditMode(),"Enter"!==e.key||u.isSuggestionsListOpened()||(e.preventDefault(),E())},handleSelectEmoji:j,handleAttachmentLoadingError:x,handleFileUpload:F,handleFileDelete:function(){return y({attachmentUrl:null,attachmentName:null,attachmentSize:null})},handleCancelClick:function(){var e=m.current.props.exitEditMode();"function"==typeof e&&v.current.push({callback:e}),y(b)}}};
|
|
2
|
+
//# sourceMappingURL=useCommentInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCommentInput.js","sources":["../../../../src/components/CommentInput/useCommentInput.js"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { patchFeedItemComment } from '../../clients/jsonApi';\nimport { isSuggestionsListOpened } from '~components/UserMention/utils';\nimport utils from '~utils/main';\nimport { notifyCommentEdit, notifyCommentPost } from '~utils/nativeMessages';\n\nconst clearedComment = {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n};\n\nexport default function useCommentInput(props) {\n const [state, setState] = useState({\n ...clearedComment,\n attachmentLoadingError: null,\n isInputFocused: false,\n });\n const latest = useRef({ props, state });\n const previousProps = useRef(null);\n const afterCommit = useRef([]);\n const update = useCallback(patch => setState(current => ({ ...current, ...patch })), []);\n const focusOnRef = () => {\n if (latest.current.props.inputRef) latest.current.props.inputRef.current.focus();\n };\n const setInitialCommentValue = () => {\n const current = latest.current.props;\n const attachmentUrl = current.editAttachment ? current.editAttachment.url : null;\n update({\n comment: current.editComment,\n attachmentUrl,\n attachmentName: attachmentUrl\n ? current.editAttachment.file_name || utils.getFileNameWithExtensionFromPath(attachmentUrl)\n : null,\n attachmentSize: current.editAttachment ? current.editAttachment.size : null,\n });\n };\n\n useLayoutEffect(() => {\n latest.current = { props, state };\n const previous = previousProps.current;\n previousProps.current = props;\n if (\n (!previous && props.editFeedItemId) ||\n (props.editFeedItemId && previous && !previous.editFeedItemId) ||\n (previous && props.editCommentId && props.editCommentId !== previous.editCommentId)\n ) {\n setInitialCommentValue();\n }\n const pending = afterCommit.current;\n afterCommit.current = [];\n pending.forEach(({ focus, callback }) => {\n if (focus) focusOnRef();\n if (typeof callback === 'function') callback();\n });\n });\n\n const clearCommentField = callback => {\n afterCommit.current.push({ focus: true, callback });\n update(clearedComment);\n };\n const handleNativeFileUpload = () => {\n const current = latest.current;\n if (current.props.editFeedItemId) {\n notifyCommentEdit(current.state.comment);\n clearCommentField(latest.current.props.exitEditMode);\n } else {\n notifyCommentPost(current.state.comment);\n clearCommentField();\n }\n };\n const handleSendComment = async () => {\n const current = latest.current;\n const textComment = current.state.comment ? current.state.comment.trim() : null;\n if (!textComment && !current.state.attachmentUrl) return;\n const payload = {\n comment: {\n body: textComment,\n attachment: {\n url: current.state.attachmentUrl,\n size: current.state.attachmentSize,\n file_name: current.state.attachmentName,\n },\n },\n };\n let response;\n if (current.props.editFeedItemId) {\n current.props.setIsEditting(true);\n try {\n const { editFeedItemId, editCommentId } = latest.current.props;\n response = await patchFeedItemComment(editFeedItemId, editCommentId, payload);\n } catch (error) {\n console.error(error.message);\n }\n await latest.current.props.patchCommentCallback(response);\n latest.current.props.setIsEditting(false);\n clearCommentField();\n latest.current.props.exitEditMode();\n } else {\n current.props.setIsPosting(true);\n try {\n response = await latest.current.props.postComment(payload);\n } catch (error) {\n console.error(error.message);\n }\n await latest.current.props.postCommentCallback(response);\n latest.current.props.setIsPosting(false);\n clearCommentField();\n }\n };\n\n const imperativeHandle = useRef({\n clearCommentField,\n focusOnRef,\n setInitialCommentValue,\n handleNativeFileUpload,\n handleSendComment,\n });\n\n const handleSelectEmoji = useCallback(\n emoji => setState(current => ({ ...current, comment: `${current.comment}${emoji.native}` })),\n []\n );\n const handleAttachmentLoadingError = useCallback(\n attachmentLoadingError =>\n update({\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n attachmentLoadingError,\n }),\n [update]\n );\n const handleFileUpload = useCallback(\n (attachmentUrl, attachmentName, attachmentSize) =>\n update({ attachmentUrl, attachmentName, attachmentSize, attachmentLoadingError: null }),\n [update]\n );\n\n return {\n state,\n update,\n imperativeHandle: imperativeHandle.current,\n handleSendComment,\n handleKeyDown: event => {\n if (event.key === 'Escape') latest.current.props.exitEditMode();\n if (event.key === 'Enter' && !isSuggestionsListOpened()) {\n event.preventDefault();\n handleSendComment();\n }\n },\n handleSelectEmoji,\n handleAttachmentLoadingError,\n handleFileUpload,\n handleFileDelete: () =>\n update({ attachmentUrl: null, attachmentName: null, attachmentSize: null }),\n handleCancelClick: () => {\n // The legacy cancel handler exits synchronously, before clearing commits.\n const callback = latest.current.props.exitEditMode();\n if (typeof callback === 'function') afterCommit.current.push({ callback });\n update(clearedComment);\n },\n };\n}\n"],"names":["clearedComment","comment","attachmentUrl","attachmentName","attachmentSize","props","useState","attachmentLoadingError","isInputFocused","_useState2","_slicedToArray","_useState","state","setState","latest","useRef","previousProps","afterCommit","update","useCallback","patch","current","focusOnRef","inputRef","focus","setInitialCommentValue","editAttachment","url","editComment","file_name","utils","getFileNameWithExtensionFromPath","size","useLayoutEffect","previous","editFeedItemId","editCommentId","pending","forEach","_ref","callback","_ref2","clearCommentField","push","handleSendComment","_asyncToGenerator","_regeneratorRuntime","mark","_callee","textComment","payload","response","_latest$current$props","wrap","_context","prev","next","trim","abrupt","body","attachment","setIsEditting","patchFeedItemComment","sent","t0","console","error","message","patchCommentCallback","exitEditMode","setIsPosting","postComment","t1","postCommentCallback","stop","apply","this","arguments","imperativeHandle","handleNativeFileUpload","notifyCommentEdit","notifyCommentPost","handleSelectEmoji","emoji","_objectSpread","native","handleAttachmentLoadingError","handleFileUpload","handleKeyDown","event","key","isSuggestionsListOpened","preventDefault","handleFileDelete","handleCancelClick"],"mappings":"wjCAMA,IAAMA,EAAiB,CACrBC,QAAS,GACTC,cAAe,KACfC,eAAgB,KAChBC,eAAgB,qBAGH,SAAyBC,GACtC,IAA0BC,EAAAA,EAAAA,gBACrBN,GAAc,GAAA,CACjBO,uBAAwB,KACxBC,gBAAgB,KAChBC,EAAAC,EAAAA,QAAAC,EAAA,GAJKC,EAAKH,EAAA,GAAEI,EAAQJ,EAAA,GAKhBK,EAASC,EAAAA,OAAO,CAAEV,MAAAA,EAAOO,MAAAA,IACzBI,EAAgBD,SAAO,MACvBE,EAAcF,SAAO,IACrBG,EAASC,eAAY,SAAAC,GAAK,OAAIP,GAAS,SAAAQ,GAAO,OAAUA,EAAAA,EAAAA,CAAAA,EAAAA,GAAYD,EAAK,GAAI,GAAE,IAC/EE,EAAa,WACbR,EAAOO,QAAQhB,MAAMkB,UAAUT,EAAOO,QAAQhB,MAAMkB,SAASF,QAAQG,SAErEC,EAAyB,WAC7B,IAAMJ,EAAUP,EAAOO,QAAQhB,MACzBH,EAAgBmB,EAAQK,eAAiBL,EAAQK,eAAeC,IAAM,KAC5ET,EAAO,CACLjB,QAASoB,EAAQO,YACjB1B,cAAAA,EACAC,eAAgBD,EACZmB,EAAQK,eAAeG,WAAaC,UAAMC,iCAAiC7B,GAC3E,KACJE,eAAgBiB,EAAQK,eAAiBL,EAAQK,eAAeM,KAAO,QAI3EC,EAAAA,iBAAgB,WACdnB,EAAOO,QAAU,CAAEhB,MAAAA,EAAOO,MAAAA,GAC1B,IAAMsB,EAAWlB,EAAcK,QAC/BL,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vCY,EAAAA,kBAAkB5D,EAAQT,MAAMX,SAChCyC,MAgDFE,kBAAAA,IAGIsC,EAAoB/D,eACxB,SAAAgE,GAAK,OAAItE,GAAS,SAAAQ,GAAO,OAAA+D,EAAAA,EAAA,CAAA,EAAU/D,GAAO,CAAA,EAAA,CAAEpB,kBAAYoB,EAAQpB,SAAUkF,OAAAA,EAAME,SAAQ,GAAI,GAC5F,IAEIC,EAA+BnE,eACnC,SAAAZ,GAAsB,OACpBW,EAAO,CACLhB,cAAe,KACfC,eAAgB,KAChBC,eAAgB,KAChBG,uBAAAA,MAEJ,CAACW,IAEGqE,EAAmBpE,EAAWA,aAClC,SAACjB,EAAeC,EAAgBC,GAAc,OAC5Cc,EAAO,CAAEhB,cAAAA,EAAeC,eAAAA,EAAgBC,eAAAA,EAAgBG,uBAAwB,SAClF,CAACW,IAGH,MAAO,CACLN,MAAAA,EACAM,OAAAA,EACA4D,iBAAkBA,EAAiBzD,QACnCuB,kBAAAA,EACA4C,cAAe,SAAAC,GACK,WAAdA,EAAMC,KAAkB5E,EAAOO,QAAQhB,MAAMgE,eAC/B,UAAdoB,EAAMC,KAAoBC,EAAuBA,4BACnDF,EAAMG,iBACNhD,IAEH,EACDsC,kBAAAA,EACAI,6BAAAA,EACAC,iBAAAA,EACAM,iBAAkB,WAAA,OAChB3E,EAAO,CAAEhB,cAAe,KAAMC,eAAgB,KAAMC,eAAgB,MAAO,EAC7E0F,kBAAmB,WAEjB,IAAMtD,EAAW1B,EAAOO,QAAQhB,MAAMgE,eACd,mBAAb7B,GAAyBvB,EAAYI,QAAQsB,KAAK,CAAEH,SAAAA,IAC/DtB,EAAOlB,EACT,EAEJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCommentInput.test.d.ts","sourceRoot":"","sources":["../../../../src/components/CommentInput/__tests__/useCommentInput.test.js"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
declare const _default: import("react").ComponentType<Pick<
|
|
2
|
+
declare const _default: import("react").ComponentType<Pick<PropTypes.InferPropsInner<Pick<{
|
|
3
3
|
inputRef: PropTypes.Requireable<PropTypes.InferProps<{
|
|
4
4
|
current: PropTypes.Requireable<PropTypes.InferProps<{
|
|
5
5
|
focus: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
@@ -28,7 +28,7 @@ declare const _default: import("react").ComponentType<Pick<Pick<PropTypes.InferP
|
|
|
28
28
|
isNative: PropTypes.Requireable<boolean>;
|
|
29
29
|
companyId: PropTypes.Requireable<number>;
|
|
30
30
|
parentId: PropTypes.Requireable<string>;
|
|
31
|
-
}
|
|
31
|
+
}, PropTypes.RequiredKeys<{
|
|
32
32
|
inputRef: PropTypes.Requireable<PropTypes.InferProps<{
|
|
33
33
|
current: PropTypes.Requireable<PropTypes.InferProps<{
|
|
34
34
|
focus: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
@@ -57,33 +57,35 @@ declare const _default: import("react").ComponentType<Pick<Pick<PropTypes.InferP
|
|
|
57
57
|
isNative: PropTypes.Requireable<boolean>;
|
|
58
58
|
companyId: PropTypes.Requireable<number>;
|
|
59
59
|
parentId: PropTypes.Requireable<string>;
|
|
60
|
-
}
|
|
61
|
-
inputRef
|
|
60
|
+
}>>> & Partial<PropTypes.InferPropsInner<Pick<{
|
|
61
|
+
inputRef: PropTypes.Requireable<PropTypes.InferProps<{
|
|
62
62
|
current: PropTypes.Requireable<PropTypes.InferProps<{
|
|
63
63
|
focus: PropTypes.Requireable<PropTypes.InferProps<{}>>;
|
|
64
64
|
}>>;
|
|
65
|
-
}
|
|
66
|
-
editFeedItemId
|
|
67
|
-
editCommentId
|
|
68
|
-
editComment
|
|
69
|
-
editAttachment
|
|
65
|
+
}>>;
|
|
66
|
+
editFeedItemId: PropTypes.Requireable<number>;
|
|
67
|
+
editCommentId: PropTypes.Requireable<number>;
|
|
68
|
+
editComment: PropTypes.Requireable<string>;
|
|
69
|
+
editAttachment: PropTypes.Requireable<PropTypes.InferProps<{
|
|
70
70
|
url: PropTypes.Requireable<string>;
|
|
71
71
|
size: PropTypes.Requireable<number>;
|
|
72
72
|
file_name: PropTypes.Requireable<string>;
|
|
73
|
-
}
|
|
74
|
-
spaceAround
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
73
|
+
}>>;
|
|
74
|
+
spaceAround: PropTypes.Requireable<boolean>;
|
|
75
|
+
postComment: PropTypes.Validator<(...args: any[]) => any>;
|
|
76
|
+
postCommentCallback: PropTypes.Requireable<(...args: any[]) => any>;
|
|
77
|
+
patchCommentCallback: PropTypes.Requireable<(...args: any[]) => any>;
|
|
78
|
+
exitEditMode: PropTypes.Requireable<(...args: any[]) => any>;
|
|
79
|
+
setIsPosting: PropTypes.Requireable<(...args: any[]) => any>;
|
|
80
|
+
setIsEditting: PropTypes.Requireable<(...args: any[]) => any>;
|
|
81
|
+
onMount: PropTypes.Requireable<(...args: any[]) => any>;
|
|
82
|
+
autoFocus: PropTypes.Requireable<boolean>;
|
|
83
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
84
|
+
classes: PropTypes.Validator<NonNullable<PropTypes.InferProps<{}>>>;
|
|
85
|
+
currentUser: PropTypes.Requireable<PropTypes.InferProps<PropTypes.ValidationMap<any>>>;
|
|
86
|
+
isNative: PropTypes.Requireable<boolean>;
|
|
87
|
+
companyId: PropTypes.Requireable<number>;
|
|
88
|
+
parentId: PropTypes.Requireable<string>;
|
|
89
|
+
}, "autoFocus" | "companyId" | "currentUser" | "disabled" | "editAttachment" | "editComment" | "editCommentId" | "editFeedItemId" | "exitEditMode" | "inputRef" | "isNative" | "onMount" | "parentId" | "patchCommentCallback" | "postCommentCallback" | "setIsEditting" | "setIsPosting" | "spaceAround">>> & import("react").RefAttributes<any>, "autoFocus" | "companyId" | "currentUser" | "disabled" | "editAttachment" | "editComment" | "editCommentId" | "editFeedItemId" | "exitEditMode" | "inputRef" | "isNative" | "onMount" | "parentId" | "patchCommentCallback" | "postComment" | "postCommentCallback" | "setIsEditting" | "setIsPosting" | "spaceAround" | keyof import("react").RefAttributes<any>> & import("@material-ui/styles").StyledComponentProps<"additionalActionButton" | "cancelText" | "fileUploadingError" | "highlightedLabel" | "iconTooltip" | "input" | "inputAdornment" | "inputEl" | "inputHelper" | "inputMain" | "inputRoot" | "nativeActionButton" | "paperRoot" | "sendButton">>;
|
|
88
90
|
export default _default;
|
|
89
91
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/createClass";import o from"@babel/runtime/helpers/assertThisInitialized";import i from"@babel/runtime/helpers/inherits";import a from"@babel/runtime/helpers/possibleConstructorReturn";import r from"@babel/runtime/helpers/getPrototypeOf";import s from"@babel/runtime/helpers/defineProperty";import l from"@babel/runtime/regenerator";import{PureComponent as c}from"react";import p from"prop-types";import m from"lodash/noop";import{withStyles as u}from"@material-ui/core/styles";import{Paper as d,TextField as h,InputAdornment as f,Collapse as g,Typography as C}from"@material-ui/core";import b from"classnames";import{get as I}from"lodash";import v from"@material-ui/core/colors/grey";import{patchFeedItemComment as x}from"../../clients/jsonApi/index.js";import y from"./styles.css.js";import{AvatarComponent as E}from"../Avatar/index.js";import F from"../FileUploadIconButton.js";import S from"../EmojiIconButton.js";import U from"../FailedFileUploading.js";import N from"../UserMention/index.js";import k from"../FilePreview/index.js";import A from"../IconButton/index.js";import M from"../Icons/SendIcon.js";import{isSuggestionsListOpened as R}from"../UserMention/utils/index.js";import j from"../../utils/main.js";import{isNativeDetected as B}from"../../utils/mobileDetect.js";import{notifyCommentEdit as w,notifyCommentPost as P}from"../../utils/nativeMessages.js";import{jsxs as T,jsx as L}from"react/jsx-runtime";function z(t){var e=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(t){return!1}}();return function(){var n,o=r(t);if(e){var i=r(this).constructor;n=Reflect.construct(o,arguments,i)}else n=o.apply(this,arguments);return a(this,n)}}var D={chatAvatarWrapper:{display:"flex",alignItems:"center",position:"absolute",left:0,height:32},commentTextFieldContainer:{position:"relative",margin:"0"},commentTextFieldContainerSpaceAround:{position:"relative",margin:"20px 10px"}},_=function(a){i(p,c);var r=z(p);function p(n){var i,a,c;return e(this,p),i=r.call(this,n),s(o(i),"handleSelectEmoji",(function(t){return i.setState((function(e){var n=e.comment;return{comment:"".concat(n).concat(t.native)}}))})),s(o(i),"postComment",(a=t(l.mark((function t(e){var n;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,i.props.postComment(e);case 3:n=t.sent,t.next=9;break;case 6:t.prev=6,t.t0=t.catch(0),console.error(t.t0.message);case 9:return t.abrupt("return",n);case 10:case"end":return t.stop()}}),t,null,[[0,6]])}))),function(t){return a.apply(this,arguments)})),s(o(i),"patchComment",(c=t(l.mark((function t(e){var n,o,a,r;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=i.props,o=n.editFeedItemId,a=n.editCommentId,t.prev=1,t.next=4,x(o,a,e);case 4:r=t.sent,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),console.error(t.t0.message);case 10:return t.abrupt("return",r);case 11:case"end":return t.stop()}}),t,null,[[1,7]])}))),function(t){return c.apply(this,arguments)})),s(o(i),"clearCommentField",(function(t){i.setState({comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null},(function(){i.focusOnRef(),t&&"function"==typeof t&&t()}))})),s(o(i),"handleKeyDown",(function(t){var e=t.key;"Escape"===e&&i.props.exitEditMode(),"Enter"===e&&(R()||(t.preventDefault(),i.handleSendComment()))})),s(o(i),"handleAttachmentLoadingError",(function(t){i.setState({attachmentUrl:null,attachmentName:null,attachmentSize:null,attachmentLoadingError:t})})),s(o(i),"handleFileUpload",(function(t,e,n){i.setState({attachmentUrl:t,attachmentName:e,attachmentSize:n,attachmentLoadingError:null})})),s(o(i),"handleNativeFileUpload",(function(){var t=i.state.comment;i.isEditMode?(w(t),i.clearCommentField(i.props.exitEditMode)):(P(t),i.clearCommentField())})),s(o(i),"handleFileDelete",(function(){return i.setState({attachmentUrl:null,attachmentName:null,attachmentSize:null})})),s(o(i),"handleSendComment",t(l.mark((function t(){var e,n,o;return l.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((e=i.state.comment?i.state.comment.trim():null)||i.state.attachmentUrl){t.next=3;break}return t.abrupt("return");case 3:if(n={comment:{body:e,attachment:{url:i.state.attachmentUrl,size:i.state.attachmentSize,file_name:i.state.attachmentName}}},!i.isEditMode){t.next=16;break}return i.props.setIsEditting(!0),t.next=8,i.patchComment(n);case 8:return o=t.sent,t.next=11,i.props.patchCommentCallback(o);case 11:i.props.setIsEditting(!1),i.clearCommentField(),i.props.exitEditMode(),t.next=24;break;case 16:return i.props.setIsPosting(!0),t.next=19,i.postComment(n);case 19:return o=t.sent,t.next=22,i.props.postCommentCallback(o);case 22:i.props.setIsPosting(!1),i.clearCommentField();case 24:case"end":return t.stop()}}),t)})))),s(o(i),"handleCancelClick",(function(){i.setState({comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null},i.props.exitEditMode())})),i.state={comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null,attachmentLoadingError:null,isInputFocused:!1},i}return n(p,[{key:"componentDidMount",value:function(){this.isEditMode&&this.setInitialCommentValue()}},{key:"componentDidUpdate",value:function(t){(this.isEditMode&&!t.editFeedItemId||this.props.editCommentId&&this.props.editCommentId!==t.editCommentId)&&this.setInitialCommentValue()}},{key:"isEditMode",get:function(){return!!this.props.editFeedItemId}},{key:"setInitialCommentValue",value:function(){var t=this.props.editAttachment?this.props.editAttachment.url:null;this.setState({comment:this.props.editComment,attachmentUrl:t,attachmentName:t?this.props.editAttachment.file_name||j.getFileNameWithExtensionFromPath(t):null,attachmentSize:this.props.editAttachment?this.props.editAttachment.size:null})}},{key:"focusOnRef",value:function(){this.props.inputRef&&this.props.inputRef.current.focus()}},{key:"render",value:function(){var t,e=this,n=this.props,o=n.classes,i=n.currentUser,a="".concat(I(i,["attributes","first_name"])||I(i,"first_name")," ").concat(I(i,["attributes","last_name"])||I(i,"last_name")),r=this.state.isInputFocused||this.state.attachmentUrl||this.state.comment||this.props.editComment||(null===(t=this.props.editAttachment)||void 0===t?void 0:t.url);return T("div",{style:this.props.spaceAround?D.commentTextFieldContainerSpaceAround:D.commentTextFieldContainer,children:[L("div",{style:D.chatAvatarWrapper,children:L(E,{displayName:a,size:32,imgSrc:this.props.currentUser&&this.props.currentUser.profile_photo})}),L(d,{className:this.props.classes.paperRoot,children:L(h,{"data-testid":"".concat("commentInput","_input"),placeholder:"Type Comment",FormHelperTextProps:{component:"div",margin:"dense"},InputProps:{inputComponent:N,inputProps:{onChange:function(t){return e.setState({comment:t})},singleLine:!0,value:this.state.comment||"",inputRef:this.props.inputRef,withLightTheme:!1,onMount:this.props.onMount,companyId:this.props.companyId,autoFocus:this.props.autoFocus,disabled:this.props.disabled,onFocus:function(){return e.setState({isInputFocused:!0})},onBlur:function(){return e.setState({isInputFocused:!1})},allowSuggestionsAboveCursor:!0},endAdornment:!this.props.isNative&&T(f,{position:"end",className:this.props.classes.inputAdornment,children:[!this.state.attachmentUrl&&L("div",{className:b(y.cCommentInputIconContainer,y.cCommentInputIconUpload),children:L(F,{openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:this.handleFileUpload,onError:this.handleAttachmentLoadingError,fileUploadIconClassName:this.props.classes.additionalActionButton,htmlColor:v[400],inputId:"comment-attachment-".concat(this.props.editCommentId||this.props.parentId),tooltipProps:{title:"Attach File",classes:{tooltip:o.iconTooltip},placement:"top"}})}),L("div",{className:y.cCommentInputIconContainer,children:L(S,{"data-testid":"".concat("commentInput","_emojiButton"),handleSelectEmoji:this.handleSelectEmoji,emojiIconClassName:this.props.classes.additionalActionButton,htmlColor:v[400],disableRipple:!0,tooltipProps:{title:"Add Emoji",classes:{tooltip:o.iconTooltip},placement:"top"}})})]}),disableUnderline:!0,classes:{root:this.props.classes.inputRoot,input:this.props.classes.inputEl}},className:this.props.classes.input,onKeyDown:this.handleKeyDown})}),this.state.attachmentLoadingError&&L(U,{errorMessage:this.state.attachmentLoadingError,className:this.props.classes.fileUploadingError}),this.state.attachmentUrl&&L(k,{fileName:this.state.attachmentName,fileUrl:this.state.attachmentUrl,handleFileDelete:this.handleFileDelete,classes:this.props.classes}),L(g,{in:r,mountOnEnter:!0,unmountOnExit:!0,children:T("div",{className:y.cCommentInputSendContainer,children:[L("div",{className:y.cCommentInputSendContainerCancel,children:L(C,{"data-testid":"".concat("commentInput","_cancel"),variant:"caption",className:b(this.props.classes.inputMain,this.props.classes.cancelText,this.props.classes.highlightedLabel),component:"div",gutterBottom:!0,onClick:this.handleCancelClick,children:"Cancel"})}),T("div",{className:y.cCommentInputSendContainerSend,children:[T(C,{variant:"caption",className:b(this.props.classes.inputMain,this.props.classes.inputHelper),component:"div",gutterBottom:!0,children:["Press ",L(C,{variant:"caption",color:"primary",className:b(this.props.classes.inputMain,this.props.classes.highlightedLabel),children:"Enter"})," to send"]}),L(A,{size:"large",tooltipProps:{title:"Send"},"data-testid":"".concat("commentInput","_sendButton"),onClick:this.handleSendComment,classes:{root:this.props.classes.sendButton},children:L(M,{})})]})]})})]})}}]),p}();_.propTypes={inputRef:p.shape({current:p.shape({focus:p.shape({})})}),editFeedItemId:p.number,editCommentId:p.number,editComment:p.string,editAttachment:p.shape({url:p.string,size:p.number,file_name:p.string}),spaceAround:p.bool,postComment:p.func.isRequired,postCommentCallback:p.func,patchCommentCallback:p.func,exitEditMode:p.func,setIsPosting:p.func,setIsEditting:p.func,onMount:p.func,autoFocus:p.bool,disabled:p.bool,classes:p.shape({}).isRequired,currentUser:p.shape(),isNative:p.bool,companyId:p.number,parentId:p.string},_.defaultProps={inputRef:null,editFeedItemId:null,editCommentId:null,parentId:null,editComment:null,editAttachment:{},spaceAround:!1,setIsPosting:m,setIsEditting:m,onMount:m,autoFocus:void 0,disabled:!1,patchCommentCallback:m,postCommentCallback:m,exitEditMode:m,companyId:null,currentUser:{},isNative:B};var O=u((function(t){return{paperRoot:{width:"calc(100% - 48px)",marginLeft:48,display:"inline-block",height:32,border:"0","&:focus-within":{boxShadow:"inset 0 0 0 2px ".concat(t.palette.primary.main)},boxShadow:"none",background:"#4D4D4D"},input:{paddingLeft:5,width:"100%"},inputRoot:{height:32,paddingRight:"8px",lineHeight:"29px",paddingLeft:"8px"},inputEl:{padding:"0 0 0 6px",height:"100%"},additionalActionButton:{padding:"6px"},nativeActionButton:{margin:"5px 10px",cursor:"pointer"},fileUploadingError:{marginTop:10,marginLeft:24},inputMain:{marginBottom:0,fontSize:"11px",color:t.palette.primary.text8},inputHelper:{display:"flex",paddingRight:5},cancelText:{cursor:"pointer"},highlightedLabel:{color:t.palette.primary.main},iconTooltip:{marginTop:"3px"},sendButton:{"&:hover":{backgroundColor:"rgba(3,188,212, 0.1)"},"&.MuiButtonBase-root":{padding:7}},inputAdornment:{marginBottom:"0!important",height:"100%"}}}))(_);export{O as default};
|
|
1
|
+
import{forwardRef as t,useImperativeHandle as e,memo as n}from"react";import o from"prop-types";import i from"lodash/noop";import{withStyles as a}from"@material-ui/core/styles";import{Paper as r,TextField as l,InputAdornment as m,Collapse as d,Typography as s}from"@material-ui/core";import p from"classnames";import{get as c}from"lodash";import u from"@material-ui/core/colors/grey";import h from"./useCommentInput.js";import g from"./styles.css.js";import{AvatarComponent as f}from"../Avatar/index.js";import C from"../FileUploadIconButton.js";import v from"../EmojiIconButton.js";import I from"../FailedFileUploading.js";import b from"../UserMention/index.js";import x from"../FilePreview/index.js";import F from"../IconButton/index.js";import y from"../Icons/SendIcon.js";import{isNativeDetected as A}from"../../utils/mobileDetect.js";import{jsxs as E,jsx as N}from"react/jsx-runtime";var j={chatAvatarWrapper:{display:"flex",alignItems:"center",position:"absolute",left:0,height:32},commentTextFieldContainer:{position:"relative",margin:"0"},commentTextFieldContainerSpaceAround:{position:"relative",margin:"20px 10px"}},B={},U=t((function(t,n){var o=t.inputRef,a=void 0===o?null:o,U=t.editFeedItemId,S=void 0===U?null:U,T=t.editCommentId,R=void 0===T?null:T,M=t.parentId,k=void 0===M?null:M,L=t.editComment,P=void 0===L?null:L,w=t.editAttachment,_=void 0===w?B:w,D=t.spaceAround,H=void 0!==D&&D,z=t.postComment,O=t.setIsPosting,q=void 0===O?i:O,K=t.setIsEditting,W=void 0===K?i:K,G=t.onMount,J=void 0===G?i:G,Q=t.autoFocus,V=t.disabled,X=void 0!==V&&V,Y=t.patchCommentCallback,Z=void 0===Y?i:Y,$=t.postCommentCallback,tt=void 0===$?i:$,et=t.exitEditMode,nt=void 0===et?i:et,ot=t.companyId,it=void 0===ot?null:ot,at=t.currentUser,rt=void 0===at?B:at,lt=t.isNative,mt=void 0===lt?A:lt,dt=t.classes,st=h({inputRef:a,editFeedItemId:S,editCommentId:R,editComment:P,editAttachment:_,postComment:z,setIsPosting:q,setIsEditting:W,patchCommentCallback:Z,postCommentCallback:tt,exitEditMode:nt}),pt=st.state,ct=st.update,ut=st.imperativeHandle,ht=st.handleSendComment,gt=st.handleKeyDown,ft=st.handleSelectEmoji,Ct=st.handleAttachmentLoadingError,vt=st.handleFileUpload,It=st.handleFileDelete,bt=st.handleCancelClick;e(n,(function(){return ut}),[ut]);var xt="".concat(c(rt,["attributes","first_name"])||c(rt,"first_name")," ").concat(c(rt,["attributes","last_name"])||c(rt,"last_name")),Ft=pt.isInputFocused||pt.attachmentUrl||pt.comment||P||(null==_?void 0:_.url);return E("div",{style:H?j.commentTextFieldContainerSpaceAround:j.commentTextFieldContainer,children:[N("div",{style:j.chatAvatarWrapper,children:N(f,{displayName:xt,size:32,imgSrc:rt&&rt.profile_photo})}),N(r,{className:dt.paperRoot,children:N(l,{"data-testid":"".concat("commentInput","_input"),placeholder:"Type Comment",FormHelperTextProps:{component:"div",margin:"dense"},InputProps:{inputComponent:b,inputProps:{onChange:function(t){return ct({comment:t})},singleLine:!0,value:pt.comment||"",inputRef:a,withLightTheme:!1,onMount:J,companyId:it,autoFocus:Q,disabled:X,onFocus:function(){return ct({isInputFocused:!0})},onBlur:function(){return ct({isInputFocused:!1})},allowSuggestionsAboveCursor:!0},endAdornment:!mt&&E(m,{position:"end",className:dt.inputAdornment,children:[!pt.attachmentUrl&&N("div",{className:p(g.cCommentInputIconContainer,g.cCommentInputIconUpload),children:N(C,{openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:vt,onError:Ct,fileUploadIconClassName:dt.additionalActionButton,htmlColor:u[400],inputId:"comment-attachment-".concat(R||k),tooltipProps:{title:"Attach File",classes:{tooltip:dt.iconTooltip},placement:"top"}})}),N("div",{className:g.cCommentInputIconContainer,children:N(v,{"data-testid":"".concat("commentInput","_emojiButton"),handleSelectEmoji:ft,emojiIconClassName:dt.additionalActionButton,htmlColor:u[400],disableRipple:!0,tooltipProps:{title:"Add Emoji",classes:{tooltip:dt.iconTooltip},placement:"top"}})})]}),disableUnderline:!0,classes:{root:dt.inputRoot,input:dt.inputEl}},className:dt.input,onKeyDown:gt})}),pt.attachmentLoadingError&&N(I,{errorMessage:pt.attachmentLoadingError,className:dt.fileUploadingError}),pt.attachmentUrl&&N(x,{fileName:pt.attachmentName,fileUrl:pt.attachmentUrl,handleFileDelete:It,classes:dt}),N(d,{in:Ft,mountOnEnter:!0,unmountOnExit:!0,children:E("div",{className:g.cCommentInputSendContainer,children:[N("div",{className:g.cCommentInputSendContainerCancel,children:N(s,{"data-testid":"".concat("commentInput","_cancel"),variant:"caption",className:p(dt.inputMain,dt.cancelText,dt.highlightedLabel),component:"div",gutterBottom:!0,onClick:bt,children:"Cancel"})}),E("div",{className:g.cCommentInputSendContainerSend,children:[E(s,{variant:"caption",className:p(dt.inputMain,dt.inputHelper),component:"div",gutterBottom:!0,children:["Press ",N(s,{variant:"caption",color:"primary",className:p(dt.inputMain,dt.highlightedLabel),children:"Enter"})," to send"]}),N(F,{size:"large",tooltipProps:{title:"Send"},"data-testid":"".concat("commentInput","_sendButton"),onClick:ht,classes:{root:dt.sendButton},children:N(y,{})})]})]})})]})})),S={inputRef:o.shape({current:o.shape({focus:o.shape({})})}),editFeedItemId:o.number,editCommentId:o.number,editComment:o.string,editAttachment:o.shape({url:o.string,size:o.number,file_name:o.string}),spaceAround:o.bool,postComment:o.func.isRequired,postCommentCallback:o.func,patchCommentCallback:o.func,exitEditMode:o.func,setIsPosting:o.func,setIsEditting:o.func,onMount:o.func,autoFocus:o.bool,disabled:o.bool,classes:o.shape({}).isRequired,currentUser:o.shape(),isNative:o.bool,companyId:o.number,parentId:o.string};U.propTypes=S;var T=a((function(t){return{paperRoot:{width:"calc(100% - 48px)",marginLeft:48,display:"inline-block",height:32,border:"0","&:focus-within":{boxShadow:"inset 0 0 0 2px ".concat(t.palette.primary.main)},boxShadow:"none",background:"#4D4D4D"},input:{paddingLeft:5,width:"100%"},inputRoot:{height:32,paddingRight:"8px",lineHeight:"29px",paddingLeft:"8px"},inputEl:{padding:"0 0 0 6px",height:"100%"},additionalActionButton:{padding:"6px"},nativeActionButton:{margin:"5px 10px",cursor:"pointer"},fileUploadingError:{marginTop:10,marginLeft:24},inputMain:{marginBottom:0,fontSize:"11px",color:t.palette.primary.text8},inputHelper:{display:"flex",paddingRight:5},cancelText:{cursor:"pointer"},highlightedLabel:{color:t.palette.primary.main},iconTooltip:{marginTop:"3px"},sendButton:{"&:hover":{backgroundColor:"rgba(3,188,212, 0.1)"},"&.MuiButtonBase-root":{padding:7}},inputAdornment:{marginBottom:"0!important",height:"100%"}}}))(n(U));export{T as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/CommentInput/index.js"],"sourcesContent":["import { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport noop from 'lodash/noop';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Collapse, Typography, TextField, InputAdornment, Paper } from '@material-ui/core';\nimport classNames from 'classnames';\nimport { get } from 'lodash';\nimport grey from '@material-ui/core/colors/grey';\n\nimport { patchFeedItemComment } from '../../clients/jsonApi';\n\nimport styles from './styles.css';\n\nimport Avatar from '~components/Avatar';\nimport FileUploadIconButton from '~components/FileUploadIconButton';\nimport EmojiIconButton from '~components/EmojiIconButton';\nimport FailedFileUploading from '~components/FailedFileUploading';\nimport UserMention from '~components/UserMention';\nimport FilePreview from '~components/FilePreview';\nimport IconButton from '~components/IconButton';\nimport SendIcon from '~components/Icons/SendIcon';\nimport { isSuggestionsListOpened } from '~components/UserMention/utils';\nimport utils from '~utils/main';\nimport { isNativeDetected } from '~/utils/mobileDetect';\nimport { notifyCommentEdit, notifyCommentPost } from '~utils/nativeMessages'; // question here\n\nconst PAGE_NAME = 'commentInput';\n\nconst INPUT_HEIGHT = 32;\nconst AVATAR_SIZE = 32;\n\nconst style = {\n chatAvatarWrapper: {\n display: 'flex',\n alignItems: 'center',\n position: 'absolute',\n left: 0,\n height: INPUT_HEIGHT,\n },\n commentTextFieldContainer: { position: 'relative', margin: '0' },\n commentTextFieldContainerSpaceAround: { position: 'relative', margin: '20px 10px' },\n};\n\nconst muiStyles = theme => ({\n paperRoot: {\n width: 'calc(100% - 48px)',\n marginLeft: AVATAR_SIZE + 16,\n display: 'inline-block',\n height: INPUT_HEIGHT,\n border: '0',\n '&:focus-within': {\n boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}`,\n },\n boxShadow: 'none',\n background: '#4D4D4D',\n },\n input: {\n paddingLeft: 5,\n width: '100%',\n },\n inputRoot: {\n height: INPUT_HEIGHT,\n paddingRight: '8px',\n lineHeight: '29px',\n paddingLeft: '8px',\n },\n inputEl: { padding: '0 0 0 6px', height: '100%' },\n additionalActionButton: {\n padding: '6px',\n },\n nativeActionButton: {\n margin: '5px 10px',\n cursor: 'pointer',\n },\n fileUploadingError: {\n marginTop: 10,\n marginLeft: 24,\n },\n inputMain: {\n marginBottom: 0,\n fontSize: '11px',\n color: theme.palette.primary.text8,\n },\n inputHelper: {\n display: 'flex',\n paddingRight: 5,\n },\n cancelText: {\n cursor: 'pointer',\n },\n highlightedLabel: {\n color: theme.palette.primary.main,\n },\n iconTooltip: {\n marginTop: '3px',\n },\n sendButton: {\n '&:hover': {\n backgroundColor: 'rgba(3,188,212, 0.1)',\n },\n '&.MuiButtonBase-root': {\n padding: 7,\n },\n },\n inputAdornment: {\n marginBottom: '0!important',\n height: '100%',\n },\n});\n\nclass CommentInput extends PureComponent {\n constructor(props) {\n super(props);\n\n this.state = {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n\n attachmentLoadingError: null,\n isInputFocused: false,\n };\n }\n\n componentDidMount() {\n if (this.isEditMode) {\n this.setInitialCommentValue();\n }\n }\n\n componentDidUpdate(prevProps) {\n const enteredEditMode = this.isEditMode && !prevProps.editFeedItemId;\n if (\n enteredEditMode ||\n (this.props.editCommentId && this.props.editCommentId !== prevProps.editCommentId)\n ) {\n this.setInitialCommentValue();\n }\n }\n\n get isEditMode() {\n return !!this.props.editFeedItemId;\n }\n\n setInitialCommentValue() {\n const attachmentUrl = this.props.editAttachment ? this.props.editAttachment.url : null;\n\n this.setState({\n comment: this.props.editComment,\n attachmentUrl,\n attachmentName: attachmentUrl\n ? this.props.editAttachment.file_name ||\n utils.getFileNameWithExtensionFromPath(attachmentUrl)\n : null,\n attachmentSize: this.props.editAttachment ? this.props.editAttachment.size : null,\n });\n }\n\n handleSelectEmoji = emoji =>\n this.setState(({ comment }) => ({ comment: `${comment}${emoji.native}` }));\n\n postComment = async comment => {\n let commentResponse;\n try {\n commentResponse = await this.props.postComment(comment);\n } catch (e) {\n console.error(e.message);\n }\n\n return commentResponse;\n };\n\n patchComment = async comment => {\n const { editFeedItemId, editCommentId } = this.props;\n\n let commentResponse;\n\n try {\n commentResponse = await patchFeedItemComment(editFeedItemId, editCommentId, comment);\n } catch (e) {\n console.error(e.message);\n }\n\n return commentResponse;\n };\n\n focusOnRef() {\n if (this.props.inputRef) this.props.inputRef.current.focus();\n }\n\n clearCommentField = callback => {\n this.setState(\n {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n },\n () => {\n this.focusOnRef();\n if (callback && typeof callback === 'function') callback();\n }\n );\n };\n\n handleKeyDown = event => {\n const { key } = event;\n\n if (key === 'Escape') this.props.exitEditMode();\n\n if (key === 'Enter') {\n if (!isSuggestionsListOpened()) {\n event.preventDefault();\n this.handleSendComment();\n }\n }\n };\n\n handleAttachmentLoadingError = attachmentLoadingError => {\n this.setState({\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n attachmentLoadingError,\n });\n };\n\n handleFileUpload = (attachmentUrl, attachmentName, attachmentSize) => {\n this.setState({\n attachmentUrl,\n attachmentName,\n attachmentSize,\n attachmentLoadingError: null,\n });\n };\n\n handleNativeFileUpload = () => {\n const { comment } = this.state;\n\n if (this.isEditMode) {\n notifyCommentEdit(comment);\n this.clearCommentField(this.props.exitEditMode);\n } else {\n notifyCommentPost(comment);\n this.clearCommentField();\n }\n };\n\n handleFileDelete = () =>\n this.setState({ attachmentUrl: null, attachmentName: null, attachmentSize: null });\n\n handleSendComment = async () => {\n const textComment = this.state.comment ? this.state.comment.trim() : null;\n if (!textComment && !this.state.attachmentUrl) return;\n\n const comment = {\n comment: {\n body: textComment,\n attachment: {\n url: this.state.attachmentUrl,\n size: this.state.attachmentSize,\n file_name: this.state.attachmentName,\n },\n },\n };\n\n let commentResponse;\n\n if (this.isEditMode) {\n this.props.setIsEditting(true);\n\n commentResponse = await this.patchComment(comment);\n await this.props.patchCommentCallback(commentResponse);\n\n this.props.setIsEditting(false);\n this.clearCommentField();\n this.props.exitEditMode();\n } else {\n this.props.setIsPosting(true);\n\n commentResponse = await this.postComment(comment);\n await this.props.postCommentCallback(commentResponse);\n\n this.props.setIsPosting(false);\n this.clearCommentField();\n }\n };\n\n handleCancelClick = () => {\n this.setState(\n {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n },\n this.props.exitEditMode()\n );\n };\n\n render() {\n const { classes, currentUser } = this.props;\n\n const currentUserFullName = `${\n get(currentUser, ['attributes', 'first_name']) || get(currentUser, 'first_name')\n } ${get(currentUser, ['attributes', 'last_name']) || get(currentUser, 'last_name')}`;\n\n const isVisibleActionBar =\n this.state.isInputFocused ||\n this.state.attachmentUrl ||\n this.state.comment ||\n this.props.editComment ||\n this.props.editAttachment?.url;\n\n return (\n <div\n style={\n this.props.spaceAround\n ? style.commentTextFieldContainerSpaceAround\n : style.commentTextFieldContainer\n }\n >\n <div style={style.chatAvatarWrapper}>\n <Avatar\n displayName={currentUserFullName}\n size={AVATAR_SIZE}\n imgSrc={this.props.currentUser && this.props.currentUser.profile_photo}\n />\n </div>\n <Paper className={this.props.classes.paperRoot}>\n <TextField\n data-testid={`${PAGE_NAME}_input`}\n placeholder=\"Type Comment\"\n FormHelperTextProps={{\n component: 'div',\n margin: 'dense',\n }}\n InputProps={{\n inputComponent: UserMention,\n inputProps: {\n onChange: comment => this.setState({ comment }),\n singleLine: true,\n value: this.state.comment || '',\n inputRef: this.props.inputRef,\n withLightTheme: false,\n onMount: this.props.onMount,\n companyId: this.props.companyId,\n autoFocus: this.props.autoFocus,\n disabled: this.props.disabled,\n onFocus: () => this.setState({ isInputFocused: true }),\n onBlur: () => this.setState({ isInputFocused: false }),\n allowSuggestionsAboveCursor: true,\n },\n endAdornment: !this.props.isNative && (\n <InputAdornment position=\"end\" className={this.props.classes.inputAdornment}>\n {!this.state.attachmentUrl && (\n <div\n className={classNames(\n styles.cCommentInputIconContainer,\n styles.cCommentInputIconUpload\n )}\n >\n <FileUploadIconButton\n openPreviewDialogOnUpload={false}\n disableRipple\n onFinish={this.handleFileUpload}\n onError={this.handleAttachmentLoadingError}\n fileUploadIconClassName={this.props.classes.additionalActionButton}\n htmlColor={grey[400]}\n inputId={`comment-attachment-${\n this.props.editCommentId || this.props.parentId\n }`}\n tooltipProps={{\n title: 'Attach File',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n )}\n <div className={styles.cCommentInputIconContainer}>\n <EmojiIconButton\n data-testid={`${PAGE_NAME}_emojiButton`}\n handleSelectEmoji={this.handleSelectEmoji}\n emojiIconClassName={this.props.classes.additionalActionButton}\n htmlColor={grey[400]}\n disableRipple\n tooltipProps={{\n title: 'Add Emoji',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n </InputAdornment>\n ),\n disableUnderline: true,\n classes: {\n root: this.props.classes.inputRoot,\n input: this.props.classes.inputEl,\n },\n }}\n className={this.props.classes.input}\n onKeyDown={this.handleKeyDown}\n />\n </Paper>\n\n {this.state.attachmentLoadingError && (\n <FailedFileUploading\n errorMessage={this.state.attachmentLoadingError}\n className={this.props.classes.fileUploadingError}\n />\n )}\n\n {this.state.attachmentUrl && (\n <FilePreview\n fileName={this.state.attachmentName}\n fileUrl={this.state.attachmentUrl}\n handleFileDelete={this.handleFileDelete}\n classes={this.props.classes}\n />\n )}\n <Collapse in={isVisibleActionBar} mountOnEnter unmountOnExit>\n <div className={styles.cCommentInputSendContainer}>\n <div className={styles.cCommentInputSendContainerCancel}>\n <Typography\n data-testid={`${PAGE_NAME}_cancel`}\n variant=\"caption\"\n className={classNames(\n this.props.classes.inputMain,\n this.props.classes.cancelText,\n this.props.classes.highlightedLabel\n )}\n component=\"div\"\n gutterBottom\n onClick={this.handleCancelClick}\n >\n Cancel\n </Typography>\n </div>\n <div className={styles.cCommentInputSendContainerSend}>\n <Typography\n variant=\"caption\"\n className={classNames(this.props.classes.inputMain, this.props.classes.inputHelper)}\n component=\"div\"\n gutterBottom\n >\n Press \n <Typography\n variant=\"caption\"\n color=\"primary\"\n className={classNames(\n this.props.classes.inputMain,\n this.props.classes.highlightedLabel\n )}\n >\n Enter\n </Typography>\n to send\n </Typography>\n <IconButton\n size=\"large\"\n tooltipProps={{ title: 'Send' }}\n data-testid={`${PAGE_NAME}_sendButton`}\n onClick={this.handleSendComment}\n classes={{ root: this.props.classes.sendButton }}\n >\n <SendIcon />\n </IconButton>\n </div>\n </div>\n </Collapse>\n </div>\n );\n }\n}\n\nCommentInput.propTypes = {\n inputRef: PropTypes.shape({ current: PropTypes.shape({ focus: PropTypes.shape({}) }) }),\n editFeedItemId: PropTypes.number,\n editCommentId: PropTypes.number,\n editComment: PropTypes.string,\n editAttachment: PropTypes.shape({\n url: PropTypes.string,\n size: PropTypes.number,\n file_name: PropTypes.string,\n }),\n spaceAround: PropTypes.bool,\n postComment: PropTypes.func.isRequired,\n postCommentCallback: PropTypes.func,\n patchCommentCallback: PropTypes.func,\n exitEditMode: PropTypes.func,\n setIsPosting: PropTypes.func,\n setIsEditting: PropTypes.func,\n onMount: PropTypes.func,\n autoFocus: PropTypes.bool,\n disabled: PropTypes.bool,\n\n classes: PropTypes.shape({}).isRequired,\n\n currentUser: PropTypes.shape(),\n isNative: PropTypes.bool,\n companyId: PropTypes.number,\n parentId: PropTypes.string,\n};\n\nCommentInput.defaultProps = {\n inputRef: null,\n editFeedItemId: null,\n editCommentId: null,\n parentId: null,\n editComment: null,\n editAttachment: {},\n spaceAround: false,\n setIsPosting: noop,\n setIsEditting: noop,\n onMount: noop,\n autoFocus: undefined,\n disabled: false,\n patchCommentCallback: noop,\n postCommentCallback: noop,\n exitEditMode: noop,\n companyId: null,\n currentUser: {},\n\n isNative: isNativeDetected,\n};\n\nexport default withStyles(muiStyles)(CommentInput);\n"],"names":["style","chatAvatarWrapper","display","alignItems","position","left","height","commentTextFieldContainer","margin","commentTextFieldContainerSpaceAround","CommentInput","_PureComponent","_inherits","PureComponent","_super","_createSuper","props","_this","_ref2","_ref3","_classCallCheck","this","call","_defineProperty","_assertThisInitialized","emoji","setState","_ref","comment","native","_asyncToGenerator","_regeneratorRuntime","mark","commentResponse","wrap","_context","prev","next","postComment","sent","t0","console","error","message","abrupt","stop","_callee","_x","apply","arguments","_this$props","editFeedItemId","editCommentId","_context2","patchFeedItemComment","_callee2","_x2","callback","attachmentUrl","attachmentName","attachmentSize","focusOnRef","event","key","exitEditMode","isSuggestionsListOpened","preventDefault","handleSendComment","attachmentLoadingError","state","isEditMode","notifyCommentEdit","clearCommentField","notifyCommentPost","_callee3","textComment","_context3","trim","body","attachment","url","size","file_name","setIsEditting","patchComment","patchCommentCallback","setIsPosting","postCommentCallback","isInputFocused","_createClass","value","setInitialCommentValue","prevProps","get","editAttachment","editComment","utils","getFileNameWithExtensionFromPath","inputRef","current","focus","_this$props$editAttac","_this2","_this$props2","classes","currentUser","currentUserFullName","concat","isVisibleActionBar","_jsxs","spaceAround","children","_jsx","Avatar","displayName","imgSrc","profile_photo","Paper","className","paperRoot","TextField","placeholder","FormHelperTextProps","component","InputProps","inputComponent","UserMention","inputProps","onChange","singleLine","withLightTheme","onMount","companyId","autoFocus","disabled","onFocus","onBlur","allowSuggestionsAboveCursor","endAdornment","isNative","InputAdornment","inputAdornment","classNames","styles","cCommentInputIconContainer","cCommentInputIconUpload","FileUploadIconButton","openPreviewDialogOnUpload","disableRipple","onFinish","handleFileUpload","onError","handleAttachmentLoadingError","fileUploadIconClassName","additionalActionButton","htmlColor","grey","inputId","parentId","tooltipProps","title","tooltip","iconTooltip","placement","EmojiIconButton","handleSelectEmoji","emojiIconClassName","disableUnderline","root","inputRoot","input","inputEl","onKeyDown","handleKeyDown","FailedFileUploading","errorMessage","fileUploadingError","FilePreview","fileName","fileUrl","handleFileDelete","Collapse","in","mountOnEnter","unmountOnExit","cCommentInputSendContainer","cCommentInputSendContainerCancel","Typography","variant","inputMain","cancelText","highlightedLabel","gutterBottom","onClick","handleCancelClick","cCommentInputSendContainerSend","inputHelper","color","IconButton","sendButton","SendIcon","propTypes","PropTypes","shape","number","string","bool","func","isRequired","defaultProps","noop","undefined","isNativeDetected","CommentInput$1","withStyles","theme","width","marginLeft","AVATAR_SIZE","border","boxShadow","palette","primary","main","background","paddingLeft","paddingRight","lineHeight","padding","nativeActionButton","cursor","marginTop","marginBottom","fontSize","text8","backgroundColor"],"mappings":"m8DA0BA,IAKMA,EAAQ,CACZC,kBAAmB,CACjBC,QAAS,OACTC,WAAY,SACZC,SAAU,WACVC,KAAM,EACNC,OATiB,IAWnBC,0BAA2B,CAAEH,SAAU,WAAYI,OAAQ,KAC3DC,qCAAsC,CAAEL,SAAU,WAAYI,OAAQ,cAsElEE,EAAY,SAAAC,GAAAC,EAAAF,EAASG,GAAT,IAAAC,EAAAC,EAAAL,GAChB,SAAAA,EAAYM,GAAO,IAAAC,EAiDyDC,EAW3EC,EAjDG,OAXeC,EAAAC,KAAAX,GACjBO,EAAAH,EAAAQ,KAAAD,KAAML,GAAOO,EAAAC,EAAAP,GAAA,qBA+CK,SAAAQ,GAAK,OACvBR,EAAKS,UAAS,SAAAC,GAAA,IAAGC,IAAAA,QAAO,MAAQ,CAAEA,QAAYA,GAAAA,OAAAA,GAAUH,OAAAA,EAAMI,QAAU,GAAE,IAAAN,EAAAC,EAAAP,GAAA,eAAAC,EAAAY,EAAAC,EAAAC,MAE9D,WAAMJ,GAAO,IAAAK,EAAA,OAAAF,EAAAG,MAAA,SAAAC,GAAA,OAAA,OAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,OAAAF,EAAAC,KAAA,EAAAD,EAAAE,KAAA,EAGCpB,EAAKD,MAAMsB,YAAYV,GAAQ,KAAA,EAAvDK,EAAeE,EAAAI,KAAAJ,EAAAE,KAAA,EAAA,MAAA,KAAA,EAAAF,EAAAC,KAAA,EAAAD,EAAAK,GAAAL,EAAA,MAAA,GAEfM,QAAQC,MAAMP,EAAAK,GAAEG,SAAS,KAAA,EAAA,OAAAR,EAAAS,OAAA,SAGpBX,GAAe,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E,UAAU,EACVjD,qBAAsB6H,EACtB3H,oBAAqB2H,EACrBlJ,aAAckJ,EACd9E,UAAW,KACX3B,YAAa,CAAE,EAEfkC,SAAUyE,GAGZ,IAAAC,EAAeC,GAteG,SAAAC,GAAK,MAAK,CAC1BhG,UAAW,CACTiG,MAAO,oBACPC,WAAYC,GACZxN,QAAS,eACTI,OApBiB,GAqBjBqN,OAAQ,IACR,iBAAkB,CAChBC,oCAA8BL,EAAMM,QAAQC,QAAQC,OAEtDH,UAAW,OACXI,WAAY,WAEdtD,MAAO,CACLuD,YAAa,EACbT,MAAO,QAET/C,UAAW,CACTnK,OAjCiB,GAkCjB4N,aAAc,MACdC,WAAY,OACZF,YAAa,OAEftD,QAAS,CAAEyD,QAAS,YAAa9N,OAAQ,QACzCoJ,uBAAwB,CACtB0E,QAAS,OAEXC,mBAAoB,CAClB7N,OAAQ,WACR8N,OAAQ,WAEVtD,mBAAoB,CAClBuD,UAAW,GACXd,WAAY,IAEd5B,UAAW,CACT2C,aAAc,EACdC,SAAU,OACVpC,MAAOkB,EAAMM,QAAQC,QAAQY,OAE/BtC,YAAa,CACXlM,QAAS,OACTgO,aAAc,GAEhBpC,WAAY,CACVwC,OAAQ,WAEVvC,iBAAkB,CAChBM,MAAOkB,EAAMM,QAAQC,QAAQC,MAE/B7D,YAAa,CACXqE,UAAW,OAEbhC,WAAY,CACV,UAAW,CACToC,gBAAiB,wBAEnB,uBAAwB,CACtBP,QAAS,IAGbvF,eAAgB,CACd2F,aAAc,cACdlO,OAAQ,QAEX,GAqacgN,CAAsB5M"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/CommentInput/index.js"],"sourcesContent":["import { forwardRef, memo, useImperativeHandle } from 'react';\nimport PropTypes from 'prop-types';\nimport noop from 'lodash/noop';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Collapse, Typography, TextField, InputAdornment, Paper } from '@material-ui/core';\nimport classNames from 'classnames';\nimport { get } from 'lodash';\nimport grey from '@material-ui/core/colors/grey';\n\nimport useCommentInput from './useCommentInput';\n\nimport styles from './styles.css';\n\nimport Avatar from '~components/Avatar';\nimport FileUploadIconButton from '~components/FileUploadIconButton';\nimport EmojiIconButton from '~components/EmojiIconButton';\nimport FailedFileUploading from '~components/FailedFileUploading';\nimport UserMention from '~components/UserMention';\nimport FilePreview from '~components/FilePreview';\nimport IconButton from '~components/IconButton';\nimport SendIcon from '~components/Icons/SendIcon';\nimport { isNativeDetected } from '~/utils/mobileDetect';\n\nconst PAGE_NAME = 'commentInput';\n\nconst INPUT_HEIGHT = 32;\nconst AVATAR_SIZE = 32;\n\nconst style = {\n chatAvatarWrapper: {\n display: 'flex',\n alignItems: 'center',\n position: 'absolute',\n left: 0,\n height: INPUT_HEIGHT,\n },\n commentTextFieldContainer: { position: 'relative', margin: '0' },\n commentTextFieldContainerSpaceAround: { position: 'relative', margin: '20px 10px' },\n};\n\nconst muiStyles = theme => ({\n paperRoot: {\n width: 'calc(100% - 48px)',\n marginLeft: AVATAR_SIZE + 16,\n display: 'inline-block',\n height: INPUT_HEIGHT,\n border: '0',\n '&:focus-within': {\n boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}`,\n },\n boxShadow: 'none',\n background: '#4D4D4D',\n },\n input: {\n paddingLeft: 5,\n width: '100%',\n },\n inputRoot: {\n height: INPUT_HEIGHT,\n paddingRight: '8px',\n lineHeight: '29px',\n paddingLeft: '8px',\n },\n inputEl: { padding: '0 0 0 6px', height: '100%' },\n additionalActionButton: {\n padding: '6px',\n },\n nativeActionButton: {\n margin: '5px 10px',\n cursor: 'pointer',\n },\n fileUploadingError: {\n marginTop: 10,\n marginLeft: 24,\n },\n inputMain: {\n marginBottom: 0,\n fontSize: '11px',\n color: theme.palette.primary.text8,\n },\n inputHelper: {\n display: 'flex',\n paddingRight: 5,\n },\n cancelText: {\n cursor: 'pointer',\n },\n highlightedLabel: {\n color: theme.palette.primary.main,\n },\n iconTooltip: {\n marginTop: '3px',\n },\n sendButton: {\n '&:hover': {\n backgroundColor: 'rgba(3,188,212, 0.1)',\n },\n '&.MuiButtonBase-root': {\n padding: 7,\n },\n },\n inputAdornment: {\n marginBottom: '0!important',\n height: '100%',\n },\n});\n\nconst emptyObject = {};\n\nconst CommentInput = forwardRef(\n /** @param {PropTypes.InferProps<typeof propTypes>} props */ function CommentInput(\n {\n inputRef = null,\n editFeedItemId = null,\n editCommentId = null,\n parentId = null,\n editComment = null,\n editAttachment = emptyObject,\n spaceAround = false,\n postComment,\n setIsPosting = noop,\n setIsEditting = noop,\n onMount = noop,\n autoFocus,\n disabled = false,\n patchCommentCallback = noop,\n postCommentCallback = noop,\n exitEditMode = noop,\n companyId = null,\n currentUser = emptyObject,\n isNative = isNativeDetected,\n classes,\n },\n ref\n ) {\n const {\n state,\n update,\n imperativeHandle,\n handleSendComment,\n handleKeyDown,\n handleSelectEmoji,\n handleAttachmentLoadingError,\n handleFileUpload,\n handleFileDelete,\n handleCancelClick,\n } = useCommentInput({\n inputRef,\n editFeedItemId,\n editCommentId,\n editComment,\n editAttachment,\n postComment,\n setIsPosting,\n setIsEditting,\n patchCommentCallback,\n postCommentCallback,\n exitEditMode,\n });\n useImperativeHandle(ref, () => imperativeHandle, [imperativeHandle]);\n\n const currentUserFullName = `${\n get(currentUser, ['attributes', 'first_name']) || get(currentUser, 'first_name')\n } ${get(currentUser, ['attributes', 'last_name']) || get(currentUser, 'last_name')}`;\n\n const isVisibleActionBar =\n state.isInputFocused ||\n state.attachmentUrl ||\n state.comment ||\n editComment ||\n editAttachment?.url;\n\n return (\n <div\n style={\n spaceAround ? style.commentTextFieldContainerSpaceAround : style.commentTextFieldContainer\n }\n >\n <div style={style.chatAvatarWrapper}>\n <Avatar\n displayName={currentUserFullName}\n size={AVATAR_SIZE}\n imgSrc={currentUser && currentUser.profile_photo}\n />\n </div>\n <Paper className={classes.paperRoot}>\n <TextField\n data-testid={`${PAGE_NAME}_input`}\n placeholder=\"Type Comment\"\n FormHelperTextProps={{\n component: 'div',\n margin: 'dense',\n }}\n InputProps={{\n inputComponent: UserMention,\n inputProps: {\n onChange: comment => update({ comment }),\n singleLine: true,\n value: state.comment || '',\n inputRef: inputRef,\n withLightTheme: false,\n onMount: onMount,\n companyId: companyId,\n autoFocus: autoFocus,\n disabled: disabled,\n onFocus: () => update({ isInputFocused: true }),\n onBlur: () => update({ isInputFocused: false }),\n allowSuggestionsAboveCursor: true,\n },\n endAdornment: !isNative && (\n <InputAdornment position=\"end\" className={classes.inputAdornment}>\n {!state.attachmentUrl && (\n <div\n className={classNames(\n styles.cCommentInputIconContainer,\n styles.cCommentInputIconUpload\n )}\n >\n <FileUploadIconButton\n openPreviewDialogOnUpload={false}\n disableRipple\n onFinish={handleFileUpload}\n onError={handleAttachmentLoadingError}\n fileUploadIconClassName={classes.additionalActionButton}\n htmlColor={grey[400]}\n inputId={`comment-attachment-${editCommentId || parentId}`}\n tooltipProps={{\n title: 'Attach File',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n )}\n <div className={styles.cCommentInputIconContainer}>\n <EmojiIconButton\n data-testid={`${PAGE_NAME}_emojiButton`}\n handleSelectEmoji={handleSelectEmoji}\n emojiIconClassName={classes.additionalActionButton}\n htmlColor={grey[400]}\n disableRipple\n tooltipProps={{\n title: 'Add Emoji',\n classes: { tooltip: classes.iconTooltip },\n placement: 'top',\n }}\n />\n </div>\n </InputAdornment>\n ),\n disableUnderline: true,\n classes: {\n root: classes.inputRoot,\n input: classes.inputEl,\n },\n }}\n className={classes.input}\n onKeyDown={handleKeyDown}\n />\n </Paper>\n\n {state.attachmentLoadingError && (\n <FailedFileUploading\n errorMessage={state.attachmentLoadingError}\n className={classes.fileUploadingError}\n />\n )}\n\n {state.attachmentUrl && (\n <FilePreview\n fileName={state.attachmentName}\n fileUrl={state.attachmentUrl}\n handleFileDelete={handleFileDelete}\n classes={classes}\n />\n )}\n <Collapse in={isVisibleActionBar} mountOnEnter unmountOnExit>\n <div className={styles.cCommentInputSendContainer}>\n <div className={styles.cCommentInputSendContainerCancel}>\n <Typography\n data-testid={`${PAGE_NAME}_cancel`}\n variant=\"caption\"\n className={classNames(\n classes.inputMain,\n classes.cancelText,\n classes.highlightedLabel\n )}\n component=\"div\"\n gutterBottom\n onClick={handleCancelClick}\n >\n Cancel\n </Typography>\n </div>\n <div className={styles.cCommentInputSendContainerSend}>\n <Typography\n variant=\"caption\"\n className={classNames(classes.inputMain, classes.inputHelper)}\n component=\"div\"\n gutterBottom\n >\n Press \n <Typography\n variant=\"caption\"\n color=\"primary\"\n className={classNames(classes.inputMain, classes.highlightedLabel)}\n >\n Enter\n </Typography>\n to send\n </Typography>\n <IconButton\n size=\"large\"\n tooltipProps={{ title: 'Send' }}\n data-testid={`${PAGE_NAME}_sendButton`}\n onClick={handleSendComment}\n classes={{ root: classes.sendButton }}\n >\n <SendIcon />\n </IconButton>\n </div>\n </div>\n </Collapse>\n </div>\n );\n }\n);\n\nconst propTypes = {\n inputRef: PropTypes.shape({ current: PropTypes.shape({ focus: PropTypes.shape({}) }) }),\n editFeedItemId: PropTypes.number,\n editCommentId: PropTypes.number,\n editComment: PropTypes.string,\n editAttachment: PropTypes.shape({\n url: PropTypes.string,\n size: PropTypes.number,\n file_name: PropTypes.string,\n }),\n spaceAround: PropTypes.bool,\n postComment: PropTypes.func.isRequired,\n postCommentCallback: PropTypes.func,\n patchCommentCallback: PropTypes.func,\n exitEditMode: PropTypes.func,\n setIsPosting: PropTypes.func,\n setIsEditting: PropTypes.func,\n onMount: PropTypes.func,\n autoFocus: PropTypes.bool,\n disabled: PropTypes.bool,\n\n classes: PropTypes.shape({}).isRequired,\n\n currentUser: PropTypes.shape(),\n isNative: PropTypes.bool,\n companyId: PropTypes.number,\n parentId: PropTypes.string,\n};\n\nCommentInput.propTypes = propTypes;\n\nexport default withStyles(muiStyles)(memo(CommentInput));\n"],"names":["style","chatAvatarWrapper","display","alignItems","position","left","height","commentTextFieldContainer","margin","commentTextFieldContainerSpaceAround","emptyObject","CommentInput","forwardRef","ref","_ref$inputRef","_ref","inputRef","_ref$editFeedItemId","editFeedItemId","_ref$editCommentId","editCommentId","_ref$parentId","parentId","_ref$editComment","editComment","_ref$editAttachment","editAttachment","_ref$spaceAround","spaceAround","postComment","_ref$setIsPosting","setIsPosting","noop","_ref$setIsEditting","setIsEditting","_ref$onMount","onMount","autoFocus","_ref$disabled","disabled","_ref$patchCommentCall","patchCommentCallback","_ref$postCommentCallb","postCommentCallback","_ref$exitEditMode","exitEditMode","_ref$companyId","companyId","_ref$currentUser","currentUser","_ref$isNative","isNative","isNativeDetected","classes","_useCommentInput","useCommentInput","state","update","imperativeHandle","handleSendComment","handleKeyDown","handleSelectEmoji","handleAttachmentLoadingError","handleFileUpload","handleFileDelete","handleCancelClick","useImperativeHandle","currentUserFullName","get","concat","isVisibleActionBar","isInputFocused","attachmentUrl","comment","url","_jsxs","children","_jsx","Avatar","displayName","size","imgSrc","profile_photo","Paper","className","paperRoot","TextField","placeholder","FormHelperTextProps","component","InputProps","inputComponent","UserMention","inputProps","onChange","singleLine","value","withLightTheme","onFocus","onBlur","allowSuggestionsAboveCursor","endAdornment","InputAdornment","inputAdornment","classNames","styles","cCommentInputIconContainer","cCommentInputIconUpload","FileUploadIconButton","openPreviewDialogOnUpload","disableRipple","onFinish","onError","fileUploadIconClassName","additionalActionButton","htmlColor","grey","inputId","tooltipProps","title","tooltip","iconTooltip","placement","EmojiIconButton","emojiIconClassName","disableUnderline","root","inputRoot","input","inputEl","onKeyDown","attachmentLoadingError","FailedFileUploading","errorMessage","fileUploadingError","FilePreview","fileName","attachmentName","fileUrl","Collapse","in","mountOnEnter","unmountOnExit","cCommentInputSendContainer","cCommentInputSendContainerCancel","Typography","variant","inputMain","cancelText","highlightedLabel","gutterBottom","onClick","cCommentInputSendContainerSend","inputHelper","color","IconButton","sendButton","SendIcon","propTypes","PropTypes","shape","current","focus","number","string","file_name","bool","func","isRequired","withStyles","theme","width","marginLeft","AVATAR_SIZE","border","boxShadow","palette","primary","main","background","paddingLeft","paddingRight","lineHeight","padding","nativeActionButton","cursor","marginTop","marginBottom","fontSize","text8","backgroundColor","memo"],"mappings":"y3BAuBA,IAKMA,EAAQ,CACZC,kBAAmB,CACjBC,QAAS,OACTC,WAAY,SACZC,SAAU,WACVC,KAAM,EACNC,OATiB,IAWnBC,0BAA2B,CAAEH,SAAU,WAAYI,OAAQ,KAC3DC,qCAAsC,CAAEL,SAAU,WAAYI,OAAQ,cAsElEE,EAAc,CAAA,EAEdC,EAAeC,GAC0C,SAuB3DC,EAAAA,GACA,IAAAC,EAAAC,EAtBEC,SAAAA,aAAW,KAAIF,EAAAG,EAAAF,EACfG,eAAAA,aAAiB,KAAID,EAAAE,EAAAJ,EACrBK,cAAAA,aAAgB,KAAID,EAAAE,EAAAN,EACpBO,SAAAA,aAAW,KAAID,EAAAE,EAAAR,EACfS,YAAAA,aAAc,KAAID,EAAAE,EAAAV,EAClBW,eAAAA,aAAiBhB,EAAWe,EAAAE,EAAAZ,EAC5Ba,YAAAA,cAAmBD,EACnBE,IAAAA,YAAWC,EAAAf,EACXgB,aAAAA,aAAeC,EAAIF,EAAAG,EAAAlB,EACnBmB,cAAAA,aAAgBF,EAAIC,EAAAE,EAAApB,EACpBqB,QAAAA,aAAUJ,EAAIG,EACdE,IAAAA,UAASC,EAAAvB,EACTwB,SAAAA,cAAgBD,EAAAE,EAAAzB,EAChB0B,qBAAAA,aAAuBT,EAAIQ,EAAAE,EAAA3B,EAC3B4B,oBAAAA,cAAsBX,EAAIU,EAAAE,GAAA7B,EAC1B8B,aAAAA,eAAeb,EAAIY,GAAAE,GAAA/B,EACnBgC,UAAAA,eAAY,KAAID,GAAAE,GAAAjC,EAChBkC,YAAAA,eAAcvC,EAAWsC,GAAAE,GAAAnC,EACzBoC,SAAAA,eAAWC,EAAgBF,GAC3BG,KAAAA,QAIFC,GAWIC,EAAgB,CAClBvC,SAAAA,EACAE,eAAAA,EACAE,cAAAA,EACAI,YAAAA,EACAE,eAAAA,EAC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H,EAAUO,KAEpBjH,QAAS0G,EAAUC,MAAM,CAAA,GAAIQ,WAE7BvH,YAAa8G,EAAUC,QACvB7G,SAAU4G,EAAUO,KACpBvH,UAAWgH,EAAUI,OACrB7I,SAAUyI,EAAUK,QAGtBzJ,EAAamJ,UAAYA,EAEzB,IAAeW,EAAAA,GA/TG,SAAAC,GAAK,MAAK,CAC1BrF,UAAW,CACTsF,MAAO,oBACPC,WAAYC,GACZ3K,QAAS,eACTI,OApBiB,GAqBjBwK,OAAQ,IACR,iBAAkB,CAChBC,oCAA8BL,EAAMM,QAAQC,QAAQC,OAEtDH,UAAW,OACXI,WAAY,WAEdnD,MAAO,CACLoD,YAAa,EACbT,MAAO,QAET5C,UAAW,CACTzH,OAjCiB,GAkCjB+K,aAAc,MACdC,WAAY,OACZF,YAAa,OAEfnD,QAAS,CAAEsD,QAAS,YAAajL,OAAQ,QACzC4G,uBAAwB,CACtBqE,QAAS,OAEXC,mBAAoB,CAClBhL,OAAQ,WACRiL,OAAQ,WAEVnD,mBAAoB,CAClBoD,UAAW,GACXd,WAAY,IAEdzB,UAAW,CACTwC,aAAc,EACdC,SAAU,OACVlC,MAAOgB,EAAMM,QAAQC,QAAQY,OAE/BpC,YAAa,CACXvJ,QAAS,OACTmL,aAAc,GAEhBjC,WAAY,CACVqC,OAAQ,WAEVpC,iBAAkB,CAChBK,MAAOgB,EAAMM,QAAQC,QAAQC,MAE/BzD,YAAa,CACXiE,UAAW,OAEb9B,WAAY,CACV,UAAW,CACTkC,gBAAiB,wBAEnB,uBAAwB,CACtBP,QAAS,IAGbhF,eAAgB,CACdoF,aAAc,cACdrL,OAAQ,QAEX,GA8PcmK,CAAsBsB,EAAKpL"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default function useCommentInput(props: any): {
|
|
2
|
+
state: {
|
|
3
|
+
comment: string;
|
|
4
|
+
attachmentUrl: null;
|
|
5
|
+
attachmentName: null;
|
|
6
|
+
attachmentSize: null;
|
|
7
|
+
attachmentLoadingError: null;
|
|
8
|
+
isInputFocused: boolean;
|
|
9
|
+
};
|
|
10
|
+
update: (patch: any) => void;
|
|
11
|
+
imperativeHandle: {
|
|
12
|
+
clearCommentField: (callback: any) => void;
|
|
13
|
+
focusOnRef: () => void;
|
|
14
|
+
setInitialCommentValue: () => void;
|
|
15
|
+
handleNativeFileUpload: () => void;
|
|
16
|
+
handleSendComment: () => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
handleSendComment: () => Promise<void>;
|
|
19
|
+
handleKeyDown: (event: any) => void;
|
|
20
|
+
handleSelectEmoji: (emoji: any) => void;
|
|
21
|
+
handleAttachmentLoadingError: (attachmentLoadingError: any) => void;
|
|
22
|
+
handleFileUpload: (attachmentUrl: any, attachmentName: any, attachmentSize: any) => void;
|
|
23
|
+
handleFileDelete: () => void;
|
|
24
|
+
handleCancelClick: () => void;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useCommentInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCommentInput.d.ts","sourceRoot":"","sources":["../../../src/components/CommentInput/useCommentInput.js"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,KAAK,KAAA;;;;;;;;;;;;;;;;;;;;;;;;EAuJ5C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import t from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/helpers/defineProperty";import n from"@babel/runtime/helpers/slicedToArray";import r from"@babel/runtime/regenerator";import{useState as a,useRef as c,useCallback as o,useLayoutEffect as i}from"react";import{patchFeedItemComment as m}from"../../clients/jsonApi/index.js";import{isSuggestionsListOpened as u}from"../UserMention/utils/index.js";import s from"../../utils/main.js";import{notifyCommentEdit as l,notifyCommentPost as p}from"../../utils/nativeMessages.js";function d(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function f(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?d(Object(r),!0).forEach((function(n){e(t,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var h={comment:"",attachmentUrl:null,attachmentName:null,attachmentSize:null};function b(e){var d=a(f(f({},h),{},{attachmentLoadingError:null,isInputFocused:!1})),b=n(d,2),v=b[0],I=b[1],y=c({props:e,state:v}),g=c(null),x=c([]),O=o((function(t){return I((function(e){return f(f({},e),t)}))}),[]),j=function(){y.current.props.inputRef&&y.current.props.inputRef.current.focus()},E=function(){var t=y.current.props,e=t.editAttachment?t.editAttachment.url:null;O({comment:t.editComment,attachmentUrl:e,attachmentName:e?t.editAttachment.file_name||s.getFileNameWithExtensionFromPath(e):null,attachmentSize:t.editAttachment?t.editAttachment.size:null})};i((function(){y.current={props:e,state:v};var t=g.current;g.current=e,(!t&&e.editFeedItemId||e.editFeedItemId&&t&&!t.editFeedItemId||t&&e.editCommentId&&e.editCommentId!==t.editCommentId)&&E();var n=x.current;x.current=[],n.forEach((function(t){var e=t.focus,n=t.callback;e&&j(),"function"==typeof n&&n()}))}));var C,k=function(t){x.current.push({focus:!0,callback:t}),O(h)},F=(C=t(r.mark((function t(){var e,n,a,c,o,i,u;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=y.current,(n=e.state.comment?e.state.comment.trim():null)||e.state.attachmentUrl){t.next=4;break}return t.abrupt("return");case 4:if(a={comment:{body:n,attachment:{url:e.state.attachmentUrl,size:e.state.attachmentSize,file_name:e.state.attachmentName}}},!e.props.editFeedItemId){t.next=24;break}return e.props.setIsEditting(!0),t.prev=7,o=y.current.props,i=o.editFeedItemId,u=o.editCommentId,t.next=11,m(i,u,a);case 11:c=t.sent,t.next=17;break;case 14:t.prev=14,t.t0=t.catch(7),console.error(t.t0.message);case 17:return t.next=19,y.current.props.patchCommentCallback(c);case 19:y.current.props.setIsEditting(!1),k(),y.current.props.exitEditMode(),t.next=38;break;case 24:return e.props.setIsPosting(!0),t.prev=25,t.next=28,y.current.props.postComment(a);case 28:c=t.sent,t.next=34;break;case 31:t.prev=31,t.t1=t.catch(25),console.error(t.t1.message);case 34:return t.next=36,y.current.props.postCommentCallback(c);case 36:y.current.props.setIsPosting(!1),k();case 38:case"end":return t.stop()}}),t,null,[[7,14],[25,31]])}))),function(){return C.apply(this,arguments)}),P=c({clearCommentField:k,focusOnRef:j,setInitialCommentValue:E,handleNativeFileUpload:function(){var t=y.current;t.props.editFeedItemId?(l(t.state.comment),k(y.current.props.exitEditMode)):(p(t.state.comment),k())},handleSendComment:F}),S=o((function(t){return I((function(e){return f(f({},e),{},{comment:"".concat(e.comment).concat(t.native)})}))}),[]),U=o((function(t){return O({attachmentUrl:null,attachmentName:null,attachmentSize:null,attachmentLoadingError:t})}),[O]),w=o((function(t,e,n){return O({attachmentUrl:t,attachmentName:e,attachmentSize:n,attachmentLoadingError:null})}),[O]);return{state:v,update:O,imperativeHandle:P.current,handleSendComment:F,handleKeyDown:function(t){"Escape"===t.key&&y.current.props.exitEditMode(),"Enter"!==t.key||u()||(t.preventDefault(),F())},handleSelectEmoji:S,handleAttachmentLoadingError:U,handleFileUpload:w,handleFileDelete:function(){return O({attachmentUrl:null,attachmentName:null,attachmentSize:null})},handleCancelClick:function(){var t=y.current.props.exitEditMode();"function"==typeof t&&x.current.push({callback:t}),O(h)}}}export{b as default};
|
|
2
|
+
//# sourceMappingURL=useCommentInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCommentInput.js","sources":["../../../src/components/CommentInput/useCommentInput.js"],"sourcesContent":["import { useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport { patchFeedItemComment } from '../../clients/jsonApi';\nimport { isSuggestionsListOpened } from '~components/UserMention/utils';\nimport utils from '~utils/main';\nimport { notifyCommentEdit, notifyCommentPost } from '~utils/nativeMessages';\n\nconst clearedComment = {\n comment: '',\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n};\n\nexport default function useCommentInput(props) {\n const [state, setState] = useState({\n ...clearedComment,\n attachmentLoadingError: null,\n isInputFocused: false,\n });\n const latest = useRef({ props, state });\n const previousProps = useRef(null);\n const afterCommit = useRef([]);\n const update = useCallback(patch => setState(current => ({ ...current, ...patch })), []);\n const focusOnRef = () => {\n if (latest.current.props.inputRef) latest.current.props.inputRef.current.focus();\n };\n const setInitialCommentValue = () => {\n const current = latest.current.props;\n const attachmentUrl = current.editAttachment ? current.editAttachment.url : null;\n update({\n comment: current.editComment,\n attachmentUrl,\n attachmentName: attachmentUrl\n ? current.editAttachment.file_name || utils.getFileNameWithExtensionFromPath(attachmentUrl)\n : null,\n attachmentSize: current.editAttachment ? current.editAttachment.size : null,\n });\n };\n\n useLayoutEffect(() => {\n latest.current = { props, state };\n const previous = previousProps.current;\n previousProps.current = props;\n if (\n (!previous && props.editFeedItemId) ||\n (props.editFeedItemId && previous && !previous.editFeedItemId) ||\n (previous && props.editCommentId && props.editCommentId !== previous.editCommentId)\n ) {\n setInitialCommentValue();\n }\n const pending = afterCommit.current;\n afterCommit.current = [];\n pending.forEach(({ focus, callback }) => {\n if (focus) focusOnRef();\n if (typeof callback === 'function') callback();\n });\n });\n\n const clearCommentField = callback => {\n afterCommit.current.push({ focus: true, callback });\n update(clearedComment);\n };\n const handleNativeFileUpload = () => {\n const current = latest.current;\n if (current.props.editFeedItemId) {\n notifyCommentEdit(current.state.comment);\n clearCommentField(latest.current.props.exitEditMode);\n } else {\n notifyCommentPost(current.state.comment);\n clearCommentField();\n }\n };\n const handleSendComment = async () => {\n const current = latest.current;\n const textComment = current.state.comment ? current.state.comment.trim() : null;\n if (!textComment && !current.state.attachmentUrl) return;\n const payload = {\n comment: {\n body: textComment,\n attachment: {\n url: current.state.attachmentUrl,\n size: current.state.attachmentSize,\n file_name: current.state.attachmentName,\n },\n },\n };\n let response;\n if (current.props.editFeedItemId) {\n current.props.setIsEditting(true);\n try {\n const { editFeedItemId, editCommentId } = latest.current.props;\n response = await patchFeedItemComment(editFeedItemId, editCommentId, payload);\n } catch (error) {\n console.error(error.message);\n }\n await latest.current.props.patchCommentCallback(response);\n latest.current.props.setIsEditting(false);\n clearCommentField();\n latest.current.props.exitEditMode();\n } else {\n current.props.setIsPosting(true);\n try {\n response = await latest.current.props.postComment(payload);\n } catch (error) {\n console.error(error.message);\n }\n await latest.current.props.postCommentCallback(response);\n latest.current.props.setIsPosting(false);\n clearCommentField();\n }\n };\n\n const imperativeHandle = useRef({\n clearCommentField,\n focusOnRef,\n setInitialCommentValue,\n handleNativeFileUpload,\n handleSendComment,\n });\n\n const handleSelectEmoji = useCallback(\n emoji => setState(current => ({ ...current, comment: `${current.comment}${emoji.native}` })),\n []\n );\n const handleAttachmentLoadingError = useCallback(\n attachmentLoadingError =>\n update({\n attachmentUrl: null,\n attachmentName: null,\n attachmentSize: null,\n attachmentLoadingError,\n }),\n [update]\n );\n const handleFileUpload = useCallback(\n (attachmentUrl, attachmentName, attachmentSize) =>\n update({ attachmentUrl, attachmentName, attachmentSize, attachmentLoadingError: null }),\n [update]\n );\n\n return {\n state,\n update,\n imperativeHandle: imperativeHandle.current,\n handleSendComment,\n handleKeyDown: event => {\n if (event.key === 'Escape') latest.current.props.exitEditMode();\n if (event.key === 'Enter' && !isSuggestionsListOpened()) {\n event.preventDefault();\n handleSendComment();\n }\n },\n handleSelectEmoji,\n handleAttachmentLoadingError,\n handleFileUpload,\n handleFileDelete: () =>\n update({ attachmentUrl: null, attachmentName: null, attachmentSize: null }),\n handleCancelClick: () => {\n // The legacy cancel handler exits synchronously, before clearing commits.\n const callback = latest.current.props.exitEditMode();\n if (typeof callback === 'function') afterCommit.current.push({ callback });\n update(clearedComment);\n },\n };\n}\n"],"names":["clearedComment","comment","attachmentUrl","attachmentName","attachmentSize","useCommentInput","props","useState","attachmentLoadingError","isInputFocused","_useState2","_slicedToArray","_useState","state","setState","latest","useRef","previousProps","afterCommit","update","useCallback","patch","current","focusOnRef","inputRef","focus","setInitialCommentValue","editAttachment","url","editComment","file_name","utils","getFileNameWithExtensionFromPath","size","useLayoutEffect","previous","editFeedItemId","editCommentId","pending","forEach","_ref","callback","_ref2","clearCommentField","push","handleSendComment","_asyncToGenerator","_regeneratorRuntime","mark","_callee","textComment","payload","response","_latest$current$props","wrap","_context","prev","next","trim","abrupt","body","attachment","setIsEditting","patchFeedItemComment","sent","t0","console","error","message","patchCommentCallback","exitEditMode","setIsPosting","postComment","t1","postCommentCallback","stop","apply","this","arguments","imperativeHandle","handleNativeFileUpload","notifyCommentEdit","notifyCommentPost","handleSelectEmoji","emoji","_objectSpread","native","handleAttachmentLoadingError","handleFileUpload","handleKeyDown","event","key","isSuggestionsListOpened","preventDefault","handleFileDelete","handleCancelClick"],"mappings":"smCAMA,IAAMA,EAAiB,CACrBC,QAAS,GACTC,cAAe,KACfC,eAAgB,KAChBC,eAAgB,MAGH,SAASC,EAAgBC,GACtC,IAA0BC,EAAAA,SACrBP,GAAc,GAAA,CACjBQ,uBAAwB,KACxBC,gBAAgB,KAChBC,EAAAC,EAAAC,EAAA,GAJKC,EAAKH,EAAA,GAAEI,EAAQJ,EAAA,GAKhBK,EAASC,EAAO,CAAEV,MAAAA,EAAOO,MAAAA,IACzBI,EAAgBD,EAAO,MACvBE,EAAcF,EAAO,IACrBG,EAASC,GAAY,SAAAC,GAAK,OAAIP,GAAS,SAAAQ,GAAO,OAAUA,EAAAA,EAAAA,CAAAA,EAAAA,GAAYD,EAAK,GAAI,GAAE,IAC/EE,EAAa,WACbR,EAAOO,QAAQhB,MAAMkB,UAAUT,EAAOO,QAAQhB,MAAMkB,SAASF,QAAQG,SAErEC,EAAyB,WAC7B,IAAMJ,EAAUP,EAAOO,QAAQhB,MACzBJ,EAAgBoB,EAAQK,eAAiBL,EAAQK,eAAe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