@corva/ui 3.76.0-10 → 3.76.0-2
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/AttachmentPreview/AttachmentPreview.js +1 -1
- package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.js.map +1 -1
- package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
- package/cjs-bundle/components/CommentCard/CommentCard.scss.js +1 -1
- package/cjs-bundle/components/CommentInput/index.js +1 -1
- package/cjs-bundle/components/CommentInput/index.js.map +1 -1
- package/cjs-bundle/components/CommentInputNext/CommentInputNext.scss.js +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.js.map +1 -1
- package/cjs-bundle/components/FeedCard/FeedCard.scss.js +1 -1
- package/cjs-bundle/componentsV2/AppCommonsProvider/AppCommonsContext.js.map +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/Actions/Actions.constants.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/Actions/Actions.constants.js.map +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/Actions/Actions.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/Actions/Actions.js.map +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/AppHeaderV3.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/AppHeaderV3.js.map +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/AppHeaderV3.scss.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/useResponsivity.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/useResponsivity.js.map +1 -1
- package/components/AttachmentPreview/AttachmentPreview.d.ts +0 -1
- package/components/AttachmentPreview/AttachmentPreview.d.ts.map +1 -1
- package/components/AttachmentPreview/AttachmentPreview.js +1 -1
- package/components/AttachmentPreview/AttachmentPreview.js.map +1 -1
- package/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
- package/components/CommentCard/CommentCard.scss.js +1 -1
- package/components/CommentInput/index.d.ts +24 -26
- package/components/CommentInput/index.js +1 -1
- package/components/CommentInput/index.js.map +1 -1
- package/components/CommentInputNext/CommentInputNext.scss.js +1 -1
- package/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.d.ts +9 -2
- package/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.d.ts.map +1 -1
- package/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.js.map +1 -1
- package/components/FeedCard/FeedCard.scss.js +1 -1
- package/componentsV2/AppCommonsProvider/AppCommonsContext.d.ts +6 -19
- package/componentsV2/AppCommonsProvider/AppCommonsContext.d.ts.map +1 -1
- package/componentsV2/AppCommonsProvider/AppCommonsContext.js.map +1 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.constants.d.ts +0 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.constants.d.ts.map +1 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.constants.js +1 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.constants.js.map +1 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.d.ts.map +1 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.js +1 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.js.map +1 -1
- package/componentsV2/AppHeader/V3/AppHeaderV3.d.ts.map +1 -1
- package/componentsV2/AppHeader/V3/AppHeaderV3.js +1 -1
- package/componentsV2/AppHeader/V3/AppHeaderV3.js.map +1 -1
- package/componentsV2/AppHeader/V3/AppHeaderV3.scss.js +1 -1
- package/componentsV2/AppHeader/V3/useResponsivity.js +1 -1
- package/componentsV2/AppHeader/V3/useResponsivity.js.map +1 -1
- package/mcp-server/server.mjs +3 -7
- package/package.json +1 -1
- package/styles/common.scss +0 -14
- package/styles/mixins.scss +0 -14
- package/tsconfig.tsbuildinfo +1 -1
- package/cjs-bundle/components/AttachmentPreview/useScrollOverflow.js +0 -2
- package/cjs-bundle/components/AttachmentPreview/useScrollOverflow.js.map +0 -1
- package/cjs-bundle/components/CommentInput/useCommentInput.js +0 -2
- package/cjs-bundle/components/CommentInput/useCommentInput.js.map +0 -1
- package/components/AttachmentPreview/__tests__/AttachmentPreview.overflow.test.d.ts +0 -2
- package/components/AttachmentPreview/__tests__/AttachmentPreview.overflow.test.d.ts.map +0 -1
- package/components/AttachmentPreview/useScrollOverflow.d.ts +0 -16
- package/components/AttachmentPreview/useScrollOverflow.d.ts.map +0 -1
- package/components/AttachmentPreview/useScrollOverflow.js +0 -2
- package/components/AttachmentPreview/useScrollOverflow.js.map +0 -1
- package/components/CommentInput/__tests__/useCommentInput.test.d.ts +0 -2
- package/components/CommentInput/__tests__/useCommentInput.test.d.ts.map +0 -1
- package/components/CommentInput/useCommentInput.d.ts +0 -26
- package/components/CommentInput/useCommentInput.d.ts.map +0 -1
- package/components/CommentInput/useCommentInput.js +0 -2
- package/components/CommentInput/useCommentInput.js.map +0 -1
- package/componentsV2/AppHeader/__tests__/AppHeaderEmbedded.test.d.ts +0 -2
- package/componentsV2/AppHeader/__tests__/AppHeaderEmbedded.test.d.ts.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("react");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=n(e),o=n(r);function u(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function c(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?u(Object(t),!0).forEach((function(r){i.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):u(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}exports.useScrollOverflow=function(e,r){var n=t.useState({left:{hiddenCount:0},right:{hiddenCount:0}}),i=o.default(n,2),u=i[0],l=i[1],f=t.useCallback((function(){var r=e.current;if(r){var t=function(e){for(var r=e.getBoundingClientRect(),t=0,n=0,i=0,o=Array.from(e.children);i<o.length;i++){var u=o[i].getBoundingClientRect();u.left<r.left-1&&(t+=1),u.right>r.right+1&&(n+=1)}return{left:t,right:n}}(r);l((function(e){return e.left.hiddenCount===t.left&&e.right.hiddenCount===t.right?e:{left:{hiddenCount:t.left},right:{hiddenCount:t.right}}}))}}),[e]);t.useLayoutEffect((function(){f();var r=e.current;if(r){r.addEventListener("scroll",f);var t="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(f);return null==t||t.observe(r),function(){r.removeEventListener("scroll",f),null==t||t.disconnect()}}}),[f,e,r]);var a=t.useCallback((function(r){var t=e.current;if(t){var n=Math.max(t.clientWidth-64,64);t.scrollBy({left:r*n})}}),[e]);return c(c({},u),{},{scrollByPage:a})};
|
|
2
|
-
//# sourceMappingURL=useScrollOverflow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollOverflow.js","sources":["../../../../src/components/AttachmentPreview/useScrollOverflow.ts"],"sourcesContent":["import { RefObject, useCallback, useLayoutEffect, useState } from 'react';\n\n// Sub-pixel scroll positions and the strip's edge padding must not count as overflow.\nconst EDGE_TOLERANCE_PX = 1;\n\nexport type OverflowEdge = {\n /** How many tiles are not fully in view past this edge. Zero means no arrow. */\n hiddenCount: number;\n};\n\nexport type ScrollOverflow = {\n left: OverflowEdge;\n right: OverflowEdge;\n scrollByPage: (direction: -1 | 1) => void;\n};\n\nconst countHidden = (scroller: HTMLElement) => {\n const bounds = scroller.getBoundingClientRect();\n let left = 0;\n let right = 0;\n\n for (const tile of Array.from(scroller.children)) {\n const rect = tile.getBoundingClientRect();\n // Not else-if: a tile wider than the viewport can be hidden past both edges at once.\n if (rect.left < bounds.left - EDGE_TOLERANCE_PX) left += 1;\n if (rect.right > bounds.right + EDGE_TOLERANCE_PX) right += 1;\n }\n\n return { left, right };\n};\n\n/**\n * Tracks which attachment tiles are scrolled out of view. The strip hides its scrollbar, so\n * these counts are the only overflow signal the arrows (and their tooltips) have.\n */\nexport const useScrollOverflow = (\n scrollerRef: RefObject<HTMLElement>,\n // The array itself, not its length: a drag-reorder of mixed-width tiles shifts what fits\n // without changing the count or firing a scroll event.\n items: readonly unknown[]\n): ScrollOverflow => {\n const [edges, setEdges] = useState({\n left: { hiddenCount: 0 },\n right: { hiddenCount: 0 },\n });\n\n const update = useCallback(() => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n\n const counts = countHidden(scroller);\n // Keep the previous state object when nothing changed, or every scroll event re-renders\n // the whole strip.\n setEdges(prev =>\n prev.left.hiddenCount === counts.left && prev.right.hiddenCount === counts.right\n ? prev\n : { left: { hiddenCount: counts.left }, right: { hiddenCount: counts.right } }\n );\n }, [scrollerRef]);\n\n // Layout effect so a strip that mounts already overflowing shows its arrow on first paint.\n useLayoutEffect(() => {\n update();\n\n const scroller = scrollerRef.current;\n if (!scroller) return undefined;\n\n scroller.addEventListener('scroll', update);\n // Guarded: jsdom has no ResizeObserver.\n const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);\n observer?.observe(scroller);\n\n return () => {\n scroller.removeEventListener('scroll', update);\n observer?.disconnect();\n };\n }, [update, scrollerRef, items]);\n\n const scrollByPage = useCallback(\n (direction: -1 | 1) => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n\n // Almost a full viewport, so one tile carries over as the reader's anchor. Smoothness\n // comes from the scroller's own scroll-behavior.\n const page = Math.max(scroller.clientWidth - 64, 64);\n scroller.scrollBy({ left: direction * page });\n },\n [scrollerRef]\n );\n\n return { ...edges, scrollByPage };\n};\n"],"names":["scrollerRef","items","_useState","useState","left","hiddenCount","right","_useState2","_slicedToArray","edges","setEdges","update","useCallback","scroller","current","counts","bounds","getBoundingClientRect","Array","from","children","_i","_Array$from","length","rect","countHidden","prev","useLayoutEffect","addEventListener","observer","ResizeObserver","undefined","observe","removeEventListener","disconnect","scrollByPage","direction","page","Math","max","clientWidth","scrollBy","_objectSpread"],"mappings":"23BAmCiC,SAC/BA,EAGAC,GAEA,IAAAC,EAA0BC,EAAAA,SAAS,CACjCC,KAAM,CAAEC,YAAa,GACrBC,MAAO,CAAED,YAAa,KACtBE,EAAAC,EAAAA,QAAAN,EAAA,GAHKO,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAKhBI,EAASC,EAAAA,aAAY,WACzB,IAAMC,EAAWb,EAAYc,QAC7B,GAAKD,EAAL,CAEA,IAAME,EAlCU,SAACF,GAKnB,IAJA,IAAMG,EAASH,EAASI,wBACpBb,EAAO,EACPE,EAAQ,EAEOY,EAAAA,EAAAA,EAAAA,MAAMC,KAAKN,EAASO,UAAWC,EAAAC,EAAAC,OAAAF,IAAA,CAA7C,IACGG,EADOF,EAAAD,GACKJ,wBAEdO,EAAKpB,KAAOY,EAAOZ,KArBD,IAqB2BA,GAAQ,GACrDoB,EAAKlB,MAAQU,EAAOV,MAtBF,IAsB6BA,GAAS,EAC9D,CAEA,MAAO,CAAEF,KAAAA,EAAME,MAAAA,EACjB,CAqBmBmB,CAAYZ,GAG3BH,GAAS,SAAAgB,GAAI,OACXA,EAAKtB,KAAKC,cAAgBU,EAAOX,MAAQsB,EAAKpB,MAAMD,cAAgBU,EAAOT,MACvEoB,EACA,CAAEtB,KAAM,CAAEC,YAAaU,EAAOX,MAAQE,MAAO,CAAED,YAAaU,EAAOT,UAR1D,CAUjB,GAAG,CAACN,IAGJ2B,EAAAA,iBAAgB,WACdhB,IAEA,IAAME,EAAWb,EAAYc,QAC7B,GAAKD,EAAL,CAEAA,EAASe,iBAAiB,SAAUjB,GAEpC,IAAMkB,EAAqC,oBAAnBC,oBAAiCC,EAAY,IAAID,eAAenB,GAGxF,OAFAkB,SAAAA,EAAUG,QAAQnB,GAEX,WACLA,EAASoB,oBAAoB,SAAUtB,GACvCkB,SAAAA,EAAUK,aATmB,CAWhC,GAAE,CAACvB,EAAQX,EAAaC,IAEzB,IAAMkC,EAAevB,eACnB,SAACwB,GACC,IAAMvB,EAAWb,EAAYc,QAC7B,GAAKD,EAAL,CAIA,IAAMwB,EAAOC,KAAKC,IAAI1B,EAAS2B,YAAc,GAAI,IACjD3B,EAAS4B,SAAS,CAAErC,KAAMgC,EAAYC,GALvB,CAMjB,GACA,CAACrC,IAGH,OAAA0C,EAAAA,EAAA,CAAA,EAAYjC,GAAK,CAAA,EAAA,CAAE0B,aAAAA,GACrB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAcK,QAAUhB,IAEp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D,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentPreview.overflow.test.d.ts","sourceRoot":"","sources":["../../../../src/components/AttachmentPreview/__tests__/AttachmentPreview.overflow.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
export type OverflowEdge = {
|
|
3
|
-
/** How many tiles are not fully in view past this edge. Zero means no arrow. */
|
|
4
|
-
hiddenCount: number;
|
|
5
|
-
};
|
|
6
|
-
export type ScrollOverflow = {
|
|
7
|
-
left: OverflowEdge;
|
|
8
|
-
right: OverflowEdge;
|
|
9
|
-
scrollByPage: (direction: -1 | 1) => void;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Tracks which attachment tiles are scrolled out of view. The strip hides its scrollbar, so
|
|
13
|
-
* these counts are the only overflow signal the arrows (and their tooltips) have.
|
|
14
|
-
*/
|
|
15
|
-
export declare const useScrollOverflow: (scrollerRef: RefObject<HTMLElement>, items: readonly unknown[]) => ScrollOverflow;
|
|
16
|
-
//# sourceMappingURL=useScrollOverflow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollOverflow.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentPreview/useScrollOverflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA0C,MAAM,OAAO,CAAC;AAK1E,MAAM,MAAM,YAAY,GAAG;IACzB,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;CAC3C,CAAC;AAiBF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,gBACf,SAAS,CAAC,WAAW,CAAC,SAG5B,SAAS,OAAO,EAAE,KACxB,cAoDF,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/slicedToArray";import{useState as t,useCallback as n,useLayoutEffect as i}from"react";function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function c(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var f=function(e,o){var f=t({left:{hiddenCount:0},right:{hiddenCount:0}}),l=r(f,2),u=l[0],a=l[1],d=n((function(){var r=e.current;if(r){var t=function(e){for(var r=e.getBoundingClientRect(),t=0,n=0,i=0,o=Array.from(e.children);i<o.length;i++){var c=o[i].getBoundingClientRect();c.left<r.left-1&&(t+=1),c.right>r.right+1&&(n+=1)}return{left:t,right:n}}(r);a((function(e){return e.left.hiddenCount===t.left&&e.right.hiddenCount===t.right?e:{left:{hiddenCount:t.left},right:{hiddenCount:t.right}}}))}}),[e]);i((function(){d();var r=e.current;if(r){r.addEventListener("scroll",d);var t="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(d);return null==t||t.observe(r),function(){r.removeEventListener("scroll",d),null==t||t.disconnect()}}}),[d,e,o]);var s=n((function(r){var t=e.current;if(t){var n=Math.max(t.clientWidth-64,64);t.scrollBy({left:r*n})}}),[e]);return c(c({},u),{},{scrollByPage:s})};export{f as useScrollOverflow};
|
|
2
|
-
//# sourceMappingURL=useScrollOverflow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollOverflow.js","sources":["../../../src/components/AttachmentPreview/useScrollOverflow.ts"],"sourcesContent":["import { RefObject, useCallback, useLayoutEffect, useState } from 'react';\n\n// Sub-pixel scroll positions and the strip's edge padding must not count as overflow.\nconst EDGE_TOLERANCE_PX = 1;\n\nexport type OverflowEdge = {\n /** How many tiles are not fully in view past this edge. Zero means no arrow. */\n hiddenCount: number;\n};\n\nexport type ScrollOverflow = {\n left: OverflowEdge;\n right: OverflowEdge;\n scrollByPage: (direction: -1 | 1) => void;\n};\n\nconst countHidden = (scroller: HTMLElement) => {\n const bounds = scroller.getBoundingClientRect();\n let left = 0;\n let right = 0;\n\n for (const tile of Array.from(scroller.children)) {\n const rect = tile.getBoundingClientRect();\n // Not else-if: a tile wider than the viewport can be hidden past both edges at once.\n if (rect.left < bounds.left - EDGE_TOLERANCE_PX) left += 1;\n if (rect.right > bounds.right + EDGE_TOLERANCE_PX) right += 1;\n }\n\n return { left, right };\n};\n\n/**\n * Tracks which attachment tiles are scrolled out of view. The strip hides its scrollbar, so\n * these counts are the only overflow signal the arrows (and their tooltips) have.\n */\nexport const useScrollOverflow = (\n scrollerRef: RefObject<HTMLElement>,\n // The array itself, not its length: a drag-reorder of mixed-width tiles shifts what fits\n // without changing the count or firing a scroll event.\n items: readonly unknown[]\n): ScrollOverflow => {\n const [edges, setEdges] = useState({\n left: { hiddenCount: 0 },\n right: { hiddenCount: 0 },\n });\n\n const update = useCallback(() => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n\n const counts = countHidden(scroller);\n // Keep the previous state object when nothing changed, or every scroll event re-renders\n // the whole strip.\n setEdges(prev =>\n prev.left.hiddenCount === counts.left && prev.right.hiddenCount === counts.right\n ? prev\n : { left: { hiddenCount: counts.left }, right: { hiddenCount: counts.right } }\n );\n }, [scrollerRef]);\n\n // Layout effect so a strip that mounts already overflowing shows its arrow on first paint.\n useLayoutEffect(() => {\n update();\n\n const scroller = scrollerRef.current;\n if (!scroller) return undefined;\n\n scroller.addEventListener('scroll', update);\n // Guarded: jsdom has no ResizeObserver.\n const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);\n observer?.observe(scroller);\n\n return () => {\n scroller.removeEventListener('scroll', update);\n observer?.disconnect();\n };\n }, [update, scrollerRef, items]);\n\n const scrollByPage = useCallback(\n (direction: -1 | 1) => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n\n // Almost a full viewport, so one tile carries over as the reader's anchor. Smoothness\n // comes from the scroller's own scroll-behavior.\n const page = Math.max(scroller.clientWidth - 64, 64);\n scroller.scrollBy({ left: direction * page });\n },\n [scrollerRef]\n );\n\n return { ...edges, scrollByPage };\n};\n"],"names":["useScrollOverflow","scrollerRef","items","_useState","useState","left","hiddenCount","right","_useState2","_slicedToArray","edges","setEdges","update","useCallback","scroller","current","counts","bounds","getBoundingClientRect","Array","from","children","_i","_Array$from","length","rect","countHidden","prev","useLayoutEffect","addEventListener","observer","ResizeObserver","undefined","observe","removeEventListener","disconnect","scrollByPage","direction","page","Math","max","clientWidth","scrollBy","_objectSpread"],"mappings":"+uBAGA,IAgCaA,EAAoB,SAC/BC,EAGAC,GAEA,IAAAC,EAA0BC,EAAS,CACjCC,KAAM,CAAEC,YAAa,GACrBC,MAAO,CAAED,YAAa,KACtBE,EAAAC,EAAAN,EAAA,GAHKO,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAKhBI,EAASC,GAAY,WACzB,IAAMC,EAAWb,EAAYc,QAC7B,GAAKD,EAAL,CAEA,IAAME,EAlCU,SAACF,GAKnB,IAJA,IAAMG,EAASH,EAASI,wBACpBb,EAAO,EACPE,EAAQ,EAEOY,EAAAA,EAAAA,EAAAA,MAAMC,KAAKN,EAASO,UAAWC,EAAAC,EAAAC,OAAAF,IAAA,CAA7C,IACGG,EADOF,EAAAD,GACKJ,wBAEdO,EAAKpB,KAAOY,EAAOZ,KArBD,IAqB2BA,GAAQ,GACrDoB,EAAKlB,MAAQU,EAAOV,MAtBF,IAsB6BA,GAAS,EAC9D,CAEA,MAAO,CAAEF,KAAAA,EAAME,MAAAA,EACjB,CAqBmBmB,CAAYZ,GAG3BH,GAAS,SAAAgB,GAAI,OACXA,EAAKtB,KAAKC,cAAgBU,EAAOX,MAAQsB,EAAKpB,MAAMD,cAAgBU,EAAOT,MACvEoB,EACA,CAAEtB,KAAM,CAAEC,YAAaU,EAAOX,MAAQE,MAAO,CAAED,YAAaU,EAAOT,UAR1D,CAUjB,GAAG,CAACN,IAGJ2B,GAAgB,WACdhB,IAEA,IAAME,EAAWb,EAAYc,QAC7B,GAAKD,EAAL,CAEAA,EAASe,iBAAiB,SAAUjB,GAEpC,IAAMkB,EAAqC,oBAAnBC,oBAAiCC,EAAY,IAAID,eAAenB,GAGxF,OAFAkB,SAAAA,EAAUG,QAAQnB,GAEX,WACLA,EAASoB,oBAAoB,SAAUtB,GACvCkB,SAAAA,EAAUK,aATmB,CAWhC,GAAE,CAACvB,EAAQX,EAAaC,IAEzB,IAAMkC,EAAevB,GACnB,SAACwB,GACC,IAAMvB,EAAWb,EAAYc,QAC7B,GAAKD,EAAL,CAIA,IAAMwB,EAAOC,KAAKC,IAAI1B,EAAS2B,YAAc,GAAI,IACjD3B,EAAS4B,SAAS,CAAErC,KAAMgC,EAAYC,GALvB,CAMjB,GACA,CAACrC,IAGH,OAAA0C,EAAAA,EAAA,CAAA,EAAYjC,GAAK,CAAA,EAAA,CAAE0B,aAAAA,GACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCommentInput.test.d.ts","sourceRoot":"","sources":["../../../../src/components/CommentInput/__tests__/useCommentInput.test.js"],"names":[],"mappings":""}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,2 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,eAAeC,IAAM,KAC5ET,EAAO,CACLlB,QAASqB,EAAQO,YACjB3B,cAAAA,EACAC,eAAgBD,EACZoB,EAAQK,eAAeG,WAAaC,EAAMC,iCAAiC9B,GAC3E,KACJE,eAAgBkB,EAAQK,eAAiBL,EAAQK,eAAeM,KAAO,QAI3EC,GAAgB,WACdnB,EAAOO,QAAU,CAAEhB,MAAAA,EAAOO,MAAAA,GAC1B,IAAMsB,EAAWlB,EAAc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,EAAQT,MAAMZ,SAChC0C,MAgDFE,kBAAAA,IAGIsC,EAAoB/D,GACxB,SAAAgE,GAAK,OAAItE,GAAS,SAAAQ,GAAO,OAAA+D,EAAAA,EAAA,CAAA,EAAU/D,GAAO,CAAA,EAAA,CAAErB,kBAAYqB,EAAQrB,SAAUmF,OAAAA,EAAME,SAAQ,GAAI,GAC5F,IAEIC,EAA+BnE,GACnC,SAAAZ,GAAsB,OACpBW,EAAO,CACLjB,cAAe,KACfC,eAAgB,KAChBC,eAAgB,KAChBI,uBAAAA,MAEJ,CAACW,IAEGqE,EAAmBpE,GACvB,SAAClB,EAAeC,EAAgBC,GAAc,OAC5Ce,EAAO,CAAEjB,cAAAA,EAAeC,eAAAA,EAAgBC,eAAAA,EAAgBI,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,MAC5BF,EAAMG,iBACNhD,IAEH,EACDsC,kBAAAA,EACAI,6BAAAA,EACAC,iBAAAA,EACAM,iBAAkB,WAAA,OAChB3E,EAAO,CAAEjB,cAAe,KAAMC,eAAgB,KAAMC,eAAgB,MAAO,EAC7E2F,kBAAmB,WAEjB,IAAMtD,EAAW1B,EAAOO,QAAQhB,MAAMgE,eACd,mBAAb7B,GAAyBvB,EAAYI,QAAQsB,KAAK,CAAEH,SAAAA,IAC/DtB,EAAOnB,EACT,EAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AppHeaderEmbedded.test.d.ts","sourceRoot":"","sources":["../../../../src/componentsV2/AppHeader/__tests__/AppHeaderEmbedded.test.tsx"],"names":[],"mappings":""}
|