@corva/ui 3.74.0-1 → 3.74.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.
Files changed (376) hide show
  1. package/cjs-bundle/components/AddComment/Popover.js +1 -1
  2. package/cjs-bundle/components/AddComment/Popover.js.map +1 -1
  3. package/cjs-bundle/components/AddComment/components/Content.js +1 -1
  4. package/cjs-bundle/components/AddComment/components/Content.js.map +1 -1
  5. package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js +2 -0
  6. package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js.map +1 -0
  7. package/cjs-bundle/components/AttachmentLightbox/AttachmentLightbox.js +1 -1
  8. package/cjs-bundle/components/AttachmentLightbox/AttachmentLightbox.js.map +1 -1
  9. package/cjs-bundle/components/AttachmentLightbox/AttachmentLightbox.scss.js +1 -1
  10. package/cjs-bundle/components/AttachmentLightbox/AttachmentPreviewPane.js +2 -0
  11. package/cjs-bundle/components/AttachmentLightbox/AttachmentPreviewPane.js.map +1 -0
  12. package/cjs-bundle/components/AttachmentLightbox/copyImageToClipboard.js +2 -0
  13. package/cjs-bundle/components/AttachmentLightbox/copyImageToClipboard.js.map +1 -0
  14. package/cjs-bundle/components/AttachmentLightbox/downloadAttachment.js +2 -0
  15. package/cjs-bundle/components/AttachmentLightbox/downloadAttachment.js.map +1 -0
  16. package/cjs-bundle/components/AttachmentLightbox/useAttachmentLightbox.js +1 -1
  17. package/cjs-bundle/components/AttachmentLightbox/useAttachmentLightbox.js.map +1 -1
  18. package/cjs-bundle/components/AttachmentLightbox/useZoomPan.js +2 -0
  19. package/cjs-bundle/components/AttachmentLightbox/useZoomPan.js.map +1 -0
  20. package/cjs-bundle/components/AttachmentPreview/AttachmentActionsMenu.js +2 -0
  21. package/cjs-bundle/components/AttachmentPreview/AttachmentActionsMenu.js.map +1 -0
  22. package/cjs-bundle/components/AttachmentPreview/AttachmentDownloadLink.js +2 -0
  23. package/cjs-bundle/components/AttachmentPreview/AttachmentDownloadLink.js.map +1 -0
  24. package/cjs-bundle/components/AttachmentPreview/AttachmentImage.js +2 -0
  25. package/cjs-bundle/components/AttachmentPreview/AttachmentImage.js.map +1 -0
  26. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.js +1 -1
  27. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.js.map +1 -1
  28. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
  29. package/cjs-bundle/components/AttachmentPreview/AttachmentRow.js +1 -1
  30. package/cjs-bundle/components/AttachmentPreview/AttachmentRow.js.map +1 -1
  31. package/cjs-bundle/components/AttachmentPreview/AttachmentTile.js +1 -1
  32. package/cjs-bundle/components/AttachmentPreview/AttachmentTile.js.map +1 -1
  33. package/cjs-bundle/components/AttachmentPreview/useStoredAttachment.js +2 -0
  34. package/cjs-bundle/components/AttachmentPreview/useStoredAttachment.js.map +1 -0
  35. package/cjs-bundle/components/AttachmentPreview/useStoredAttachments.js +1 -1
  36. package/cjs-bundle/components/AttachmentPreview/useStoredAttachments.js.map +1 -1
  37. package/cjs-bundle/components/BICOffsetPickerDialog/index.js +1 -1
  38. package/cjs-bundle/components/BICOffsetPickerDialog/index.js.map +1 -1
  39. package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
  40. package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
  41. package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js +1 -1
  42. package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js.map +1 -1
  43. package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
  44. package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
  45. package/cjs-bundle/components/CommentCard/CommentCard.js +1 -1
  46. package/cjs-bundle/components/CommentCard/CommentCard.js.map +1 -1
  47. package/cjs-bundle/components/CommentCard/CommentMenu.js +1 -1
  48. package/cjs-bundle/components/CommentCard/CommentMenu.js.map +1 -1
  49. package/cjs-bundle/components/CommentComposer/CommentComposer.js +1 -1
  50. package/cjs-bundle/components/CommentComposer/CommentComposer.js.map +1 -1
  51. package/cjs-bundle/components/CommentComposer/CommentReplyInput.js +1 -1
  52. package/cjs-bundle/components/CommentComposer/CommentReplyInput.js.map +1 -1
  53. package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js +1 -1
  54. package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js.map +1 -1
  55. package/cjs-bundle/components/CommentInputNext/CommentInputNext.js +1 -1
  56. package/cjs-bundle/components/CommentInputNext/CommentInputNext.js.map +1 -1
  57. package/cjs-bundle/components/CommentInputNext/useFilePaste.js +2 -0
  58. package/cjs-bundle/components/CommentInputNext/useFilePaste.js.map +1 -0
  59. package/cjs-bundle/components/DocumentViewer/DocumentViewer.js +1 -1
  60. package/cjs-bundle/components/DocumentViewer/DocumentViewer.js.map +1 -1
  61. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
  62. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
  63. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
  64. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
  65. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
  66. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
  67. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
  68. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
  69. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
  70. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
  71. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
  72. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
  73. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
  74. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
  75. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
  76. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
  77. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
  78. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
  79. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
  80. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
  81. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
  82. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
  83. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
  84. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
  85. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
  86. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
  87. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
  88. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
  89. package/cjs-bundle/components/LinkedText/LinkedText.js +2 -0
  90. package/cjs-bundle/components/LinkedText/LinkedText.js.map +1 -0
  91. package/cjs-bundle/components/LinkedText/LinkedText.scss.js +2 -0
  92. package/cjs-bundle/components/LinkedText/LinkedText.scss.js.map +1 -0
  93. package/cjs-bundle/components/NewDocumentViewer/utils.js +1 -1
  94. package/cjs-bundle/components/NewDocumentViewer/utils.js.map +1 -1
  95. package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
  96. package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
  97. package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
  98. package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
  99. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
  100. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
  101. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
  102. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
  103. package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
  104. package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
  105. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
  106. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
  107. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
  108. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
  109. package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
  110. package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
  111. package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
  112. package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
  113. package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
  114. package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
  115. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
  116. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
  117. package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js +1 -1
  118. package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
  119. package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
  120. package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
  121. package/cjs-bundle/components/UserMention/constants.js +1 -1
  122. package/cjs-bundle/components/UserMention/constants.js.map +1 -1
  123. package/cjs-bundle/components/UserMention/index.js +1 -1
  124. package/cjs-bundle/components/UserMention/index.js.map +1 -1
  125. package/cjs-bundle/components/index.js +1 -1
  126. package/cjs-bundle/componentsV2/ButtonIcon/ButtonIcon.js +1 -1
  127. package/cjs-bundle/componentsV2/ButtonIcon/ButtonIcon.js.map +1 -1
  128. package/cjs-bundle/componentsV2/ButtonIcon/ButtonIcon.scss.js +1 -1
  129. package/cjs-bundle/componentsV2/Modal/Modal.js +1 -1
  130. package/cjs-bundle/componentsV2/Modal/Modal.js.map +1 -1
  131. package/cjs-bundle/componentsV2/Modal/constants.js +2 -0
  132. package/cjs-bundle/componentsV2/Modal/constants.js.map +1 -0
  133. package/cjs-bundle/effects/useOutsideClick.js +1 -1
  134. package/cjs-bundle/effects/useOutsideClick.js.map +1 -1
  135. package/cjs-bundle/utils/fetchAttachment.js +2 -0
  136. package/cjs-bundle/utils/fetchAttachment.js.map +1 -0
  137. package/cjs-bundle/utils/links.js +2 -0
  138. package/cjs-bundle/utils/links.js.map +1 -0
  139. package/components/AddComment/Popover.js +1 -1
  140. package/components/AddComment/Popover.js.map +1 -1
  141. package/components/AddComment/components/Content.js +1 -1
  142. package/components/AddComment/components/Content.js.map +1 -1
  143. package/components/AttachmentLightbox/AttachmentDocument.d.ts +6 -0
  144. package/components/AttachmentLightbox/AttachmentDocument.d.ts.map +1 -0
  145. package/components/AttachmentLightbox/AttachmentDocument.js +2 -0
  146. package/components/AttachmentLightbox/AttachmentDocument.js.map +1 -0
  147. package/components/AttachmentLightbox/AttachmentLightbox.d.ts +9 -8
  148. package/components/AttachmentLightbox/AttachmentLightbox.d.ts.map +1 -1
  149. package/components/AttachmentLightbox/AttachmentLightbox.js +1 -1
  150. package/components/AttachmentLightbox/AttachmentLightbox.js.map +1 -1
  151. package/components/AttachmentLightbox/AttachmentLightbox.scss.js +1 -1
  152. package/components/AttachmentLightbox/AttachmentPreviewPane.d.ts +9 -0
  153. package/components/AttachmentLightbox/AttachmentPreviewPane.d.ts.map +1 -0
  154. package/components/AttachmentLightbox/AttachmentPreviewPane.js +2 -0
  155. package/components/AttachmentLightbox/AttachmentPreviewPane.js.map +1 -0
  156. package/components/AttachmentLightbox/__tests__/AttachmentDocument.test.d.ts +2 -0
  157. package/components/AttachmentLightbox/__tests__/AttachmentDocument.test.d.ts.map +1 -0
  158. package/components/AttachmentLightbox/__tests__/AttachmentLightbox.test.d.ts +2 -0
  159. package/components/AttachmentLightbox/__tests__/AttachmentLightbox.test.d.ts.map +1 -0
  160. package/components/AttachmentLightbox/__tests__/copyImageToClipboard.test.d.ts +2 -0
  161. package/components/AttachmentLightbox/__tests__/copyImageToClipboard.test.d.ts.map +1 -0
  162. package/components/AttachmentLightbox/__tests__/downloadAttachment.test.d.ts +2 -0
  163. package/components/AttachmentLightbox/__tests__/downloadAttachment.test.d.ts.map +1 -0
  164. package/components/AttachmentLightbox/__tests__/useZoomPan.test.d.ts +2 -0
  165. package/components/AttachmentLightbox/__tests__/useZoomPan.test.d.ts.map +1 -0
  166. package/components/AttachmentLightbox/copyImageToClipboard.d.ts +4 -0
  167. package/components/AttachmentLightbox/copyImageToClipboard.d.ts.map +1 -0
  168. package/components/AttachmentLightbox/copyImageToClipboard.js +2 -0
  169. package/components/AttachmentLightbox/copyImageToClipboard.js.map +1 -0
  170. package/components/AttachmentLightbox/downloadAttachment.d.ts +10 -0
  171. package/components/AttachmentLightbox/downloadAttachment.d.ts.map +1 -0
  172. package/components/AttachmentLightbox/downloadAttachment.js +2 -0
  173. package/components/AttachmentLightbox/downloadAttachment.js.map +1 -0
  174. package/components/AttachmentLightbox/useAttachmentLightbox.d.ts +6 -2
  175. package/components/AttachmentLightbox/useAttachmentLightbox.d.ts.map +1 -1
  176. package/components/AttachmentLightbox/useAttachmentLightbox.js +1 -1
  177. package/components/AttachmentLightbox/useAttachmentLightbox.js.map +1 -1
  178. package/components/AttachmentLightbox/useZoomPan.d.ts +29 -0
  179. package/components/AttachmentLightbox/useZoomPan.d.ts.map +1 -0
  180. package/components/AttachmentLightbox/useZoomPan.js +2 -0
  181. package/components/AttachmentLightbox/useZoomPan.js.map +1 -0
  182. package/components/AttachmentPreview/AttachmentActionsMenu.d.ts +16 -0
  183. package/components/AttachmentPreview/AttachmentActionsMenu.d.ts.map +1 -0
  184. package/components/AttachmentPreview/AttachmentActionsMenu.js +2 -0
  185. package/components/AttachmentPreview/AttachmentActionsMenu.js.map +1 -0
  186. package/components/AttachmentPreview/AttachmentDownloadLink.d.ts +11 -0
  187. package/components/AttachmentPreview/AttachmentDownloadLink.d.ts.map +1 -0
  188. package/components/AttachmentPreview/AttachmentDownloadLink.js +2 -0
  189. package/components/AttachmentPreview/AttachmentDownloadLink.js.map +1 -0
  190. package/components/AttachmentPreview/AttachmentImage.d.ts +12 -0
  191. package/components/AttachmentPreview/AttachmentImage.d.ts.map +1 -0
  192. package/components/AttachmentPreview/AttachmentImage.js +2 -0
  193. package/components/AttachmentPreview/AttachmentImage.js.map +1 -0
  194. package/components/AttachmentPreview/AttachmentPreview.d.ts.map +1 -1
  195. package/components/AttachmentPreview/AttachmentPreview.js +1 -1
  196. package/components/AttachmentPreview/AttachmentPreview.js.map +1 -1
  197. package/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
  198. package/components/AttachmentPreview/AttachmentPreview.types.d.ts +7 -0
  199. package/components/AttachmentPreview/AttachmentPreview.types.d.ts.map +1 -1
  200. package/components/AttachmentPreview/AttachmentRow.d.ts +7 -3
  201. package/components/AttachmentPreview/AttachmentRow.d.ts.map +1 -1
  202. package/components/AttachmentPreview/AttachmentRow.js +1 -1
  203. package/components/AttachmentPreview/AttachmentRow.js.map +1 -1
  204. package/components/AttachmentPreview/AttachmentTile.d.ts +5 -1
  205. package/components/AttachmentPreview/AttachmentTile.d.ts.map +1 -1
  206. package/components/AttachmentPreview/AttachmentTile.js +1 -1
  207. package/components/AttachmentPreview/AttachmentTile.js.map +1 -1
  208. package/components/AttachmentPreview/__tests__/AttachmentActionsMenu.test.d.ts +2 -0
  209. package/components/AttachmentPreview/__tests__/AttachmentActionsMenu.test.d.ts.map +1 -0
  210. package/components/AttachmentPreview/__tests__/AttachmentDownloadLink.test.d.ts +2 -0
  211. package/components/AttachmentPreview/__tests__/AttachmentDownloadLink.test.d.ts.map +1 -0
  212. package/components/AttachmentPreview/__tests__/AttachmentImage.test.d.ts +2 -0
  213. package/components/AttachmentPreview/__tests__/AttachmentImage.test.d.ts.map +1 -0
  214. package/components/AttachmentPreview/__tests__/AttachmentTile.test.d.ts +2 -0
  215. package/components/AttachmentPreview/__tests__/AttachmentTile.test.d.ts.map +1 -0
  216. package/components/AttachmentPreview/__tests__/useStoredAttachments.test.d.ts +2 -0
  217. package/components/AttachmentPreview/__tests__/useStoredAttachments.test.d.ts.map +1 -0
  218. package/components/AttachmentPreview/useStoredAttachment.d.ts +8 -0
  219. package/components/AttachmentPreview/useStoredAttachment.d.ts.map +1 -1
  220. package/components/AttachmentPreview/useStoredAttachment.js +2 -0
  221. package/components/AttachmentPreview/useStoredAttachment.js.map +1 -0
  222. package/components/AttachmentPreview/useStoredAttachments.d.ts +1 -1
  223. package/components/AttachmentPreview/useStoredAttachments.d.ts.map +1 -1
  224. package/components/AttachmentPreview/useStoredAttachments.js +1 -1
  225. package/components/AttachmentPreview/useStoredAttachments.js.map +1 -1
  226. package/components/BICOffsetPickerDialog/index.js +1 -1
  227. package/components/BICOffsetPickerDialog/index.js.map +1 -1
  228. package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
  229. package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
  230. package/components/Casing/CasingTableV2/components/Component.js +1 -1
  231. package/components/Casing/CasingTableV2/components/Component.js.map +1 -1
  232. package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
  233. package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
  234. package/components/CommentCard/CommentCard.d.ts.map +1 -1
  235. package/components/CommentCard/CommentCard.js +1 -1
  236. package/components/CommentCard/CommentCard.js.map +1 -1
  237. package/components/CommentCard/CommentCard.types.d.ts +2 -0
  238. package/components/CommentCard/CommentCard.types.d.ts.map +1 -1
  239. package/components/CommentCard/CommentMenu.d.ts.map +1 -1
  240. package/components/CommentCard/CommentMenu.js +1 -1
  241. package/components/CommentCard/CommentMenu.js.map +1 -1
  242. package/components/CommentComposer/CommentComposer.d.ts.map +1 -1
  243. package/components/CommentComposer/CommentComposer.js +1 -1
  244. package/components/CommentComposer/CommentComposer.js.map +1 -1
  245. package/components/CommentComposer/CommentReplyInput.d.ts.map +1 -1
  246. package/components/CommentComposer/CommentReplyInput.js +1 -1
  247. package/components/CommentComposer/CommentReplyInput.js.map +1 -1
  248. package/components/CommentComposer/__tests__/useAttachmentUpload.linked.test.d.ts +2 -0
  249. package/components/CommentComposer/__tests__/useAttachmentUpload.linked.test.d.ts.map +1 -0
  250. package/components/CommentComposer/useAttachmentUpload.d.ts +1 -0
  251. package/components/CommentComposer/useAttachmentUpload.d.ts.map +1 -1
  252. package/components/CommentComposer/useAttachmentUpload.js +1 -1
  253. package/components/CommentComposer/useAttachmentUpload.js.map +1 -1
  254. package/components/CommentInputNext/CommentInputNext.d.ts +2 -0
  255. package/components/CommentInputNext/CommentInputNext.d.ts.map +1 -1
  256. package/components/CommentInputNext/CommentInputNext.js +1 -1
  257. package/components/CommentInputNext/CommentInputNext.js.map +1 -1
  258. package/components/CommentInputNext/__tests__/useFilePaste.test.d.ts +2 -0
  259. package/components/CommentInputNext/__tests__/useFilePaste.test.d.ts.map +1 -0
  260. package/components/CommentInputNext/useFilePaste.d.ts +17 -0
  261. package/components/CommentInputNext/useFilePaste.d.ts.map +1 -0
  262. package/components/CommentInputNext/useFilePaste.js +2 -0
  263. package/components/CommentInputNext/useFilePaste.js.map +1 -0
  264. package/components/DocumentViewer/DocumentViewer.js +1 -1
  265. package/components/DocumentViewer/DocumentViewer.js.map +1 -1
  266. package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
  267. package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
  268. package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
  269. package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
  270. package/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
  271. package/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
  272. package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
  273. package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
  274. package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
  275. package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
  276. package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
  277. package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
  278. package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
  279. package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
  280. package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
  281. package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
  282. package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
  283. package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
  284. package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
  285. package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
  286. package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
  287. package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
  288. package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
  289. package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
  290. package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
  291. package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
  292. package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
  293. package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
  294. package/components/LinkedText/LinkedText.d.ts +17 -0
  295. package/components/LinkedText/LinkedText.d.ts.map +1 -0
  296. package/components/LinkedText/LinkedText.js +2 -0
  297. package/components/LinkedText/LinkedText.js.map +1 -0
  298. package/components/LinkedText/LinkedText.scss.js +2 -0
  299. package/components/LinkedText/LinkedText.scss.js.map +1 -0
  300. package/components/LinkedText/__tests__/LinkedText.test.d.ts +2 -0
  301. package/components/LinkedText/__tests__/LinkedText.test.d.ts.map +1 -0
  302. package/components/LinkedText/index.d.ts +2 -0
  303. package/components/LinkedText/index.d.ts.map +1 -0
  304. package/components/NewDocumentViewer/utils.d.ts.map +1 -1
  305. package/components/NewDocumentViewer/utils.js +1 -1
  306. package/components/NewDocumentViewer/utils.js.map +1 -1
  307. package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
  308. package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
  309. package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
  310. package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
  311. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
  312. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
  313. package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
  314. package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
  315. package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
  316. package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
  317. package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
  318. package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
  319. package/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
  320. package/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
  321. package/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
  322. package/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
  323. package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
  324. package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
  325. package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
  326. package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
  327. package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
  328. package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
  329. package/components/PadOffsetsPicker/StagesSelector.js +1 -1
  330. package/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
  331. package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
  332. package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
  333. package/components/UserMention/__tests__/highlightLinks.test.d.ts +2 -0
  334. package/components/UserMention/__tests__/highlightLinks.test.d.ts.map +1 -0
  335. package/components/UserMention/constants.d.ts +1 -0
  336. package/components/UserMention/constants.d.ts.map +1 -1
  337. package/components/UserMention/constants.js +1 -1
  338. package/components/UserMention/constants.js.map +1 -1
  339. package/components/UserMention/index.js +1 -1
  340. package/components/UserMention/index.js.map +1 -1
  341. package/components/index.d.ts +2 -0
  342. package/components/index.d.ts.map +1 -1
  343. package/components/index.js +1 -1
  344. package/componentsV2/ButtonIcon/ButtonIcon.d.ts +2 -0
  345. package/componentsV2/ButtonIcon/ButtonIcon.d.ts.map +1 -1
  346. package/componentsV2/ButtonIcon/ButtonIcon.js +1 -1
  347. package/componentsV2/ButtonIcon/ButtonIcon.js.map +1 -1
  348. package/componentsV2/ButtonIcon/ButtonIcon.scss.js +1 -1
  349. package/componentsV2/ButtonIcon/ButtonIcon.stories.d.ts +1 -0
  350. package/componentsV2/ButtonIcon/ButtonIcon.stories.d.ts.map +1 -1
  351. package/componentsV2/Modal/Modal.d.ts.map +1 -1
  352. package/componentsV2/Modal/Modal.js +1 -1
  353. package/componentsV2/Modal/Modal.js.map +1 -1
  354. package/componentsV2/Modal/constants.d.ts +3 -0
  355. package/componentsV2/Modal/constants.d.ts.map +1 -0
  356. package/componentsV2/Modal/constants.js +2 -0
  357. package/componentsV2/Modal/constants.js.map +1 -0
  358. package/effects/__tests__/useOutsideClick.test.d.ts.map +1 -1
  359. package/effects/useOutsideClick.d.ts.map +1 -1
  360. package/effects/useOutsideClick.js +1 -1
  361. package/effects/useOutsideClick.js.map +1 -1
  362. package/mcp-server/server.mjs +35 -9
  363. package/package.json +1 -1
  364. package/tsconfig.tsbuildinfo +1 -1
  365. package/utils/__tests__/fetchAttachment.test.d.ts +2 -0
  366. package/utils/__tests__/fetchAttachment.test.d.ts.map +1 -0
  367. package/utils/__tests__/links.test.d.ts +2 -0
  368. package/utils/__tests__/links.test.d.ts.map +1 -0
  369. package/utils/fetchAttachment.d.ts +3 -0
  370. package/utils/fetchAttachment.d.ts.map +1 -0
  371. package/utils/fetchAttachment.js +2 -0
  372. package/utils/fetchAttachment.js.map +1 -0
  373. package/utils/links.d.ts +14 -0
  374. package/utils/links.d.ts.map +1 -0
  375. package/utils/links.js +2 -0
  376. package/utils/links.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"CommentComposer.js","sources":["../../../../src/components/CommentComposer/CommentComposer.tsx"],"sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n onSubmit();\n };\n\n return (\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={trailing}\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : 'Attach file'\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","jsx","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","fieldRef","useRef","CommentInput","field","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","jsxs","_Fragment","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","current","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","setSelectionRange","length","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread"],"mappings":"gxKA4EA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WAAY,OACZC,YAAa,CACXC,gBAP2B,gCAQ3BC,KAAM,CAAED,gBARmB,iCAS3BE,KAAM,CACJC,MAAO,gCACP,WAAY,CAAEH,gBAAiB,2DAK/BI,EAAmB,SAACC,GAA0C,OAClEC,EAAAA,KAAA,MAAA,CAAKC,UAAWC,EAAOC,WAAWC,SAAA,CAChCC,MAACC,kBAAM,CAACC,KAAM,GAAIC,IAAKT,EAAMU,QAASC,OAAQX,EAAMY,MAAO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EC,EAAAA,OAAOC,yBAAyBD,OAAOE,eAAehE,GAAQ,gBAAQ,IAAAuD,OAAA,EAAtEA,EAAwEU,IAEzFJ,SAAAA,EAAUK,KAAKlE,EAAO4D,GACtB5D,EAAMmE,kBAAkBP,EAAUQ,OAAQR,EAAUQ,QACpDpE,EAAMqE,cAAc,IAAIC,MAAM,QAAS,CAAEC,SAAS,KAClDvE,EAAMqE,cAAc,IAAIC,MAAM,QAAS,CAAEC,SAAS,IAXtC,GAoF0D/H,SAC5DC,MAAC+H,UAAkB,CAAC7I,SAAS,gBAGjCc,EAAAQ,IAAA,OAAA,CAAMZ,UAAWC,EAAOmI,SAASjI,SAC/BC,MAACiI,EAAe,CACdC,KAAMlI,MAACmI,kBAAe,CAACjI,KAAM,KAC7BkI,kBAAmB,SAACC,GAAyB,OAC3C1H,EAAgBD,GAAAA,OAAAA,UAAO2H,EAAMC,QAAS,SAMhDC,UACK1G,UAAAA,EAAU8F,WAAY5F,IACvBpC,EAAAA,KAAAoG,EAAAA,SAAA,CAAAhG,SAAA,CACEC,MAACwI,kBAAe,CAAC5D,KAAM/C,QAAAA,EAAY,GAAI4G,WAAY3G,IAClDC,GAAe/B,MAAC0I,EAAAA,eAAcC,EAAA,CAAA,EAAK5G,QAMhD"}
1
+ {"version":3,"file":"CommentComposer.js","sources":["../../../../src/components/CommentComposer/CommentComposer.tsx"],"sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n onSubmit();\n };\n\n return (\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={trailing}\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n highlightLinks: true,\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : 'Attach file'\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","jsx","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","fieldRef","useRef","CommentInput","field","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","highlightLinks","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","jsxs","_Fragment","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","current","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","setSelectionRange","length","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread"],"mappings":"gxKA4EA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WAAY,OACZC,YAAa,CACXC,gBAP2B,gCAQ3BC,KAAM,CAAED,gBARmB,iCAS3BE,KAAM,CACJC,MAAO,gCACP,WAAY,CAAEH,gBAAiB,2DAK/BI,EAAmB,SAACC,GAA0C,OAClEC,EAAAA,KAAA,MAAA,CAAKC,UAAWC,EAAOC,WAAWC,SAAA,CAChCC,MAACC,kBAAM,CAACC,KAAM,GAAIC,IAAKT,EAAMU,QAASC,OAAQX,EAAMY,MAAOC,YAAab,EAAMU,UAC9EJ,EAAAQ,IAAA,OAAA,CAAAT,SAAOL,EAAMU,YACT,0BAGuB,SAwBHK,GAAA,IAvB1BC,IAAAA,KACAC,IAAAA,aACAC,IAAAA,SACAC,IAAAA,UACAC,IAAAA,YACAC,IAAAA,YACAC,IAAAA,oBAAmBC,EAAAR,EACnBS,eAAAA,aAAiBC,EAAuBA,wBAAAF,EACxCG,IAAAA,WACAC,IAAAA,mBACAC,IAAAA,gBACAC,IAAAA,kBACAC,IAAAA,uBACAC,IAAAA,SACAC,IAAAA,UAASC,EAAAlB,EACTmB,YAAAA,aAAc,mBAAkBD,EAChCE,IAAAA,SACAC,IAAAA,iBACAC,IAAAA,YACAC,IAAAA,SACAC,IAAAA,SACArC,IAAAA,UACAsC,IAAAA,OAGMC,IAAYnB,EACZoB,EAAQC,EAAAA,SACZ,WAAA,OAAOF,EAAUpB,QAAAA,EAAe,GAAM,CAACK,GAAYkB,OAAO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MC,QAAS,SAMhDC,UACK7G,UAAAA,EAAUiG,WAAY/F,IACvBpC,EAAAA,KAAAuG,EAAAA,SAAA,CAAAnG,SAAA,CACEC,MAAC2I,kBAAe,CAAC9D,KAAMhD,QAAAA,EAAY,GAAI+G,WAAY9G,IAClDC,GAAe/B,MAAC6I,EAAAA,eAAcC,EAAA,CAAA,EAAK/G,QAMhD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),a=require("@babel/runtime/regenerator"),n=require("react"),r=require("../../componentsV2/Avatar/Avatar.js"),i=require("../AttachFileButton/AttachFileButton.js"),l=require("../CommentInputNext/CommentInputNext.js"),o=require("../FailedFileUploading.js"),u=require("./useAttachmentUpload.js"),s=require("react/jsx-runtime");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(e),m=c(t),p=c(a),h=[];exports.CommentReplyInput=function(e){var t=e.onSubmit,a=e.author,c=e.disabled,f=e.placeholder,v=void 0===f?"Reply":f,b=e.autoFocus,A=void 0===b||b,F=e.maxAttachments,x=e.initialBody,j=void 0===x?"":x,g=e.initialAttachments,q=void 0===g?h:g,y=e.onCancel,S=e.testId,C=n.useState(j),R=m.default(C,2),I=R[0],U=R[1],B=n.useState(q),k=m.default(B,2),w=k[0],D=k[1],M=n.useState(null),N=m.default(M,2),T=N[0],_=N[1],z=u.useAttachmentUpload({value:w,onChange:D,onError:_,maxFiles:F}),E=function(){var e=d.default(p.default.mark((function e(a){return p.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t(a,w);case 2:if(e.t0=e.sent,!1!==e.t0){e.next=5;break}return e.abrupt("return");case 5:U(""),D([]),z.clearAttachments();case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return s.jsx(l.CommentInput,{bare:!0,autoFocus:A,placeholder:v,value:I,onChange:U,canSubmit:!(!I.trim()&&!w.length||z.isUploading),onSubmit:E,onCancel:y,disabled:c,attachments:z.items,onAttachmentRemove:z.removeAttachment,onAttachmentRetry:z.handleRetry,onAttachmentReorder:z.reorderAttachments,onFilesDrop:z.addFiles,testId:S,attachmentSlot:T?s.jsx(o,{errorMessage:T}):void 0,toolbar:s.jsx(i.AttachFileButton,{inputRef:z.fileInputRef,onClick:z.openFileDialog,onFileSelect:z.handleFileSelect,multiple:!0,disabled:z.isFull,tooltip:z.isFull?"Up to ".concat(z.maxFiles," files can be attached"):"Attach file"}),leading:s.jsx(r.Avatar,{size:32,name:null==a?void 0:a.name,imageSrc:null==a?void 0:a.avatarUrl})})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),a=require("@babel/runtime/regenerator"),n=require("react"),r=require("../../componentsV2/Avatar/Avatar.js"),i=require("../AttachFileButton/AttachFileButton.js"),l=require("../CommentInputNext/CommentInputNext.js"),o=require("../FailedFileUploading.js"),u=require("./useAttachmentUpload.js"),s=require("react/jsx-runtime");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(e),m=c(t),p=c(a),h=[];exports.CommentReplyInput=function(e){var t=e.onSubmit,a=e.author,c=e.disabled,f=e.placeholder,v=void 0===f?"Reply":f,b=e.autoFocus,A=void 0===b||b,F=e.maxAttachments,x=e.initialBody,g=void 0===x?"":x,j=e.initialAttachments,q=void 0===j?h:j,y=e.onCancel,S=e.testId,C=n.useState(g),I=m.default(C,2),R=I[0],U=I[1],k=n.useState(q),B=m.default(k,2),w=B[0],D=B[1],L=n.useState(null),M=m.default(L,2),N=M[0],P=M[1],T=u.useAttachmentUpload({value:w,onChange:D,onError:P,maxFiles:F}),_=function(){var e=d.default(p.default.mark((function e(a){return p.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t(a,w);case 2:if(e.t0=e.sent,!1!==e.t0){e.next=5;break}return e.abrupt("return");case 5:U(""),D([]),T.clearAttachments();case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return s.jsx(l.CommentInput,{bare:!0,autoFocus:A,placeholder:v,value:R,onChange:U,canSubmit:!(!R.trim()&&!w.length||T.isUploading),onSubmit:_,onCancel:y,disabled:c,attachments:T.items,onAttachmentRemove:T.removeAttachment,onAttachmentRetry:T.handleRetry,onAttachmentReorder:T.reorderAttachments,onFilesDrop:T.addFiles,onImageLinkPaste:T.addLinkedImage,testId:S,attachmentSlot:N?s.jsx(o,{errorMessage:N}):void 0,toolbar:s.jsx(i.AttachFileButton,{inputRef:T.fileInputRef,onClick:T.openFileDialog,onFileSelect:T.handleFileSelect,multiple:!0,disabled:T.isFull,tooltip:T.isFull?"Up to ".concat(T.maxFiles," files can be attached"):"Attach file"}),leading:s.jsx(r.Avatar,{size:32,name:null==a?void 0:a.name,imageSrc:null==a?void 0:a.avatarUrl})})};
2
2
  //# sourceMappingURL=CommentReplyInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommentReplyInput.js","sources":["../../../../src/components/CommentComposer/CommentReplyInput.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { Avatar } from '../../componentsV2/Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport FailedFileUploading from '../FailedFileUploading';\n\nimport { useAttachmentUpload, UploadedAttachment } from './useAttachmentUpload';\n\nconst EMPTY_ATTACHMENTS: UploadedAttachment[] = [];\n\nexport type CommentReplyInputProps = {\n /** Resolving to `false` keeps the draft, so a failed post can be retried. */\n onSubmit: (\n body: string,\n attachments: UploadedAttachment[]\n ) => void | boolean | Promise<void | boolean>;\n author?: { name?: string; avatarUrl?: string };\n disabled?: boolean;\n placeholder?: string;\n autoFocus?: boolean;\n maxAttachments?: number;\n initialBody?: string;\n initialAttachments?: UploadedAttachment[];\n onCancel?: () => void;\n testId?: string;\n};\n\nexport const CommentReplyInput = ({\n onSubmit,\n author,\n disabled,\n placeholder = 'Reply',\n autoFocus = true,\n maxAttachments,\n initialBody = '',\n initialAttachments = EMPTY_ATTACHMENTS,\n onCancel,\n testId,\n}: CommentReplyInputProps) => {\n const [body, setBody] = useState(initialBody);\n const [attachments, setAttachments] = useState<UploadedAttachment[]>(initialAttachments);\n const [attachmentError, setAttachmentError] = useState<string | null>(null);\n\n const upload = useAttachmentUpload({\n value: attachments,\n onChange: setAttachments,\n onError: setAttachmentError,\n maxFiles: maxAttachments,\n });\n\n const handleSubmit = async (value: string) => {\n if ((await onSubmit(value, attachments)) === false) return;\n\n setBody('');\n setAttachments([]);\n upload.clearAttachments();\n };\n\n return (\n <CommentInput\n bare\n autoFocus={autoFocus}\n placeholder={placeholder}\n value={body}\n onChange={setBody}\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n canSubmit={(!!body.trim() || !!attachments.length) && !upload.isUploading}\n onSubmit={handleSubmit}\n onCancel={onCancel}\n disabled={disabled}\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={upload.reorderAttachments}\n onFilesDrop={upload.addFiles}\n testId={testId}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n multiple\n disabled={upload.isFull}\n tooltip={upload.isFull ? `Up to ${upload.maxFiles} files can be attached` : 'Attach file'}\n />\n }\n leading={<Avatar size={32} name={author?.name} imageSrc={author?.avatarUrl} />}\n />\n );\n};\n"],"names":["EMPTY_ATTACHMENTS","_ref","onSubmit","author","disabled","_ref$placeholder","placeholder","_ref$autoFocus","autoFocus","maxAttachments","_ref$initialBody","initialBody","_ref$initialAttachmen","initialAttachments","onCancel","testId","useState","_useState2","_slicedToArray","_useState","body","setBody","_useState4","_useState3","attachments","setAttachments","_useState6","_useState5","attachmentError","setAttachmentError","upload","useAttachmentUpload","value","onChange","onError","maxFiles","handleSubmit","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","wrap","_context","prev","next","t0","sent","abrupt","clearAttachments","stop","_callee","_x","apply","this","arguments","_jsx","CommentInput","bare","canSubmit","trim","length","isUploading","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","onFilesDrop","addFiles","attachmentSlot","jsx","FailedFileUploading","errorMessage","undefined","toolbar","AttachFileButton","inputRef","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","multiple","isFull","tooltip","leading","Avatar","size","name","imageSrc","avatarUrl"],"mappings":"klBASMA,EAA0C,6BAmBf,SAWHC,GAAA,IAV5BC,IAAAA,SACAC,IAAAA,OACAC,IAAAA,SAAQC,EAAAJ,EACRK,YAAAA,aAAc,QAAOD,EAAAE,EAAAN,EACrBO,UAAAA,cAAgBD,EAChBE,IAAAA,eAAcC,EAAAT,EACdU,YAAAA,aAAc,GAAED,EAAAE,EAAAX,EAChBY,mBAAAA,aAAqBb,EAAiBY,EACtCE,IAAAA,SACAC,IAAAA,OAEwBC,EAAAA,EAAQA,SAACL,GAAYM,EAAAC,EAAAA,QAAAC,EAAA,GAAtCC,EAAIH,EAAA,GAAEI,EAAOJ,EAAA,GACkBD,EAAAA,EAAQA,SAAuBH,GAAmBS,EAAAJ,EAAAA,QAAAK,EAAA,GAAjFC,EAAWF,EAAA,GAAEG,EAAcH,EAAA,GACYN,EAAAA,EAAQA,SAAgB,MAAKU,EAAAR,EAAAA,QAAAS,EAAA,GAApEC,EAAeF,EAAA,GAAEG,EAAkBH,EAAA,GAEpCI,EAASC,EAAAA,oBAAoB,CACjCC,MAAOR,EACPS,SAAUR,EACVS,QAASL,EACTM,SAAU1B,IAGN2B,EAAY,WAAA,IAAAC,EAAAC,EAAAA,QAAAC,EAAAA,QAAAC,MAAG,WAAOR,GAAa,OAAAO,UAAAE,MAAA,SAAAC,GAAA,OAAA,OAAA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ourcesContent":["import { useState } from 'react';\n\nimport { Avatar } from '../../componentsV2/Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport FailedFileUploading from '../FailedFileUploading';\n\nimport { useAttachmentUpload, UploadedAttachment } from './useAttachmentUpload';\n\nconst EMPTY_ATTACHMENTS: UploadedAttachment[] = [];\n\nexport type CommentReplyInputProps = {\n /** Resolving to `false` keeps the draft, so a failed post can be retried. */\n onSubmit: (\n body: string,\n attachments: UploadedAttachment[]\n ) => void | boolean | Promise<void | boolean>;\n author?: { name?: string; avatarUrl?: string };\n disabled?: boolean;\n placeholder?: string;\n autoFocus?: boolean;\n maxAttachments?: number;\n initialBody?: string;\n initialAttachments?: UploadedAttachment[];\n onCancel?: () => void;\n testId?: string;\n};\n\nexport const CommentReplyInput = ({\n onSubmit,\n author,\n disabled,\n placeholder = 'Reply',\n autoFocus = true,\n maxAttachments,\n initialBody = '',\n initialAttachments = EMPTY_ATTACHMENTS,\n onCancel,\n testId,\n}: CommentReplyInputProps) => {\n const [body, setBody] = useState(initialBody);\n const [attachments, setAttachments] = useState<UploadedAttachment[]>(initialAttachments);\n const [attachmentError, setAttachmentError] = useState<string | null>(null);\n\n const upload = useAttachmentUpload({\n value: attachments,\n onChange: setAttachments,\n onError: setAttachmentError,\n maxFiles: maxAttachments,\n });\n\n const handleSubmit = async (value: string) => {\n if ((await onSubmit(value, attachments)) === false) return;\n\n setBody('');\n setAttachments([]);\n upload.clearAttachments();\n };\n\n return (\n <CommentInput\n bare\n autoFocus={autoFocus}\n placeholder={placeholder}\n value={body}\n onChange={setBody}\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n canSubmit={(!!body.trim() || !!attachments.length) && !upload.isUploading}\n onSubmit={handleSubmit}\n onCancel={onCancel}\n disabled={disabled}\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={upload.reorderAttachments}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n testId={testId}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n multiple\n disabled={upload.isFull}\n tooltip={upload.isFull ? `Up to ${upload.maxFiles} files can be attached` : 'Attach file'}\n />\n }\n leading={<Avatar size={32} name={author?.name} imageSrc={author?.avatarUrl} />}\n />\n );\n};\n"],"names":["EMPTY_ATTACHMENTS","_ref","onSubmit","author","disabled","_ref$placeholder","placeholder","_ref$autoFocus","autoFocus","maxAttachments","_ref$initialBody","initialBody","_ref$initialAttachmen","initialAttachments","onCancel","testId","useState","_useState2","_slicedToArray","_useState","body","setBody","_useState4","_useState3","attachments","setAttachments","_useState6","_useState5","attachmentError","setAttachmentError","upload","useAttachmentUpload","value","onChange","onError","maxFiles","handleSubmit","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","wrap","_context","prev","next","t0","sent","abrupt","clearAttachments","stop","_callee","_x","apply","this","arguments","_jsx","CommentInput","bare","canSubmit","trim","length","isUploading","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","attachmentSlot","jsx","FailedFileUploading","errorMessage","undefined","toolbar","AttachFileButton","inputRef","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","multiple","isFull","tooltip","leading","Avatar","size","name","imageSrc","avatarUrl"],"mappings":"klBASMA,EAA0C,6BAmBf,SAWHC,GAAA,IAV5BC,IAAAA,SACAC,IAAAA,OACAC,IAAAA,SAAQC,EAAAJ,EACRK,YAAAA,aAAc,QAAOD,EAAAE,EAAAN,EACrBO,UAAAA,cAAgBD,EAChBE,IAAAA,eAAcC,EAAAT,EACdU,YAAAA,aAAc,GAAED,EAAAE,EAAAX,EAChBY,mBAAAA,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AoBjC,EAAOkC,iBAC3BC,kBAAmBnC,EAAOoC,YAC1BC,oBAAqBrC,EAAOsC,mBAC5BC,YAAavC,EAAOwC,SACpBC,iBAAkBzC,EAAO0C,eACzBzD,OAAQA,EACR0D,eACE7C,EAAkB2B,EAAAmB,IAACC,EAAmB,CAACC,aAAchD,SAAsBiD,EAE7EC,QACEvB,MAACwB,mBAAgB,CACfC,SAAUlD,EAAOmD,aACjBC,QAASpD,EAAOqD,eAChBC,aAActD,EAAOuD,iBACrBC,UAAQ,EACRlF,SAAU0B,EAAOyD,OACjBC,QAAS1D,EAAOyD,uBAAkBzD,EAAOK,SAAmC,0BAAA,gBAGhFsD,QAASlC,MAACmC,SAAM,CAACC,KAAM,GAAIC,KAAMzF,aAAAA,EAAAA,EAAQyF,KAAMC,SAAU1F,aAAM,EAANA,EAAQ2F,aAGvE"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),u=require("@babel/runtime/regenerator"),i=require("react"),l=require("react-s3-uploader/s3upload"),o=require("../AttachmentPreview/getAttachmentKind.js"),a=require("../AttachFileButton/AttachFileButton.js"),c=require("../../clients/jsonApi/index.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=f(e),d=f(r),p=f(n),v=f(t),h=f(u),m=f(l);function g(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function b(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?g(Object(n),!0).forEach((function(r){p.default(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var U=function(e){return e.type.startsWith("image/")?"image":e.type.startsWith("video/")?"video":"file"},w=function(e){return(e/1048576).toFixed(1)},y=function(e){return{id:e.url,name:e.name,file:null,previewUrl:"",isUploading:!1,error:null,uploaded:e}},k=0;exports.DEFAULT_MAX_ATTACHMENTS=10,exports.useAttachmentUpload=function(e){var r,n,t=e.value,u=e.onChange,l=e.onError,f=e.maxSizeBytes,p=e.maxFiles,g=void 0===p?10:p,j=e.accept,C=void 0===j?a.ACCEPTED_ATTACHMENT_TYPES:j,O=i.useState([]),A=v.default(O,2),E=A[0],S=A[1],R=i.useRef(null),x=i.useRef(new Map),F=i.useRef(new Map),P=i.useRef([]),L=i.useRef(u),T=i.useRef(l);L.current=u,T.current=l;var q=i.useRef([]),M=i.useCallback((function(e){var r=e(P.current);P.current=r,S(r),q.current=function(e){return e.map((function(e){return e.uploaded})).filter(Boolean)}(r),L.current(q.current)}),[]),D=i.useCallback((function(e,r){return M((function(n){return n.map((function(n){return n.id===e?b(b({},n),r):n}))}))}),[M]),B=i.useCallback((function(e){var r,n;null===(r=x.current.get(e))||void 0===r||r.abortUpload(),x.current.delete(e),F.current.set(e,(null!==(n=F.current.get(e))&&void 0!==n?n:0)+1)}),[]),_=i.useCallback((function(e){null!=e&&e.previewUrl&&URL.revokeObjectURL(e.previewUrl)}),[]),z=i.useCallback((function(){var e,r,n;null===(e=T.current)||void 0===e||e.call(T,null!==(r=null===(n=P.current.find((function(e){return e.error})))||void 0===n?void 0:n.error)&&void 0!==r?r:null)}),[]);i.useEffect((function(){return function(){x.current.forEach((function(e){return e.abortUpload()})),x.current.clear(),P.current.forEach((function(e){e.previewUrl&&URL.revokeObjectURL(e.previewUrl)}))}}),[]);var W=i.useCallback((function(e,r){var n,t=(null!==(n=F.current.get(e))&&void 0!==n?n:0)+1;F.current.set(e,t);var u,i,l=function(){return F.current.get(e)===t},o=function(r){var n;l()&&(D(e,{isUploading:!1,error:r}),null===(n=T.current)||void 0===n||n.call(T,r))},a="",f=new m.default({files:[r],preprocess:function(e,r){return r(e)},onProgress:function(){},getSignedUrl:(i=d.default(h.default.mark((function e(r,n){var t;return h.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c.getS3SignedUrl(r.name,r.type);case 3:t=e.sent,a=t.file_name,n(b(b({},t),{},{signedUrl:t.signed_url})),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),o((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"Failed to upload the file");case 11:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(e,r){return i.apply(this,arguments)}),onFinishS3Put:(u=d.default(h.default.mark((function n(){var t,u;return h.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,c.getS3DownloadLink(a);case 3:if(t=n.sent,u=t.url,l()){n.next=7;break}return n.abrupt("return");case 7:x.current.delete(e),D(e,{isUploading:!1,error:null,uploaded:{url:u,name:a,size:r.size}}),z(),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(0),o((null===n.t0||void 0===n.t0?void 0:n.t0.message)||"Failed to upload the file");case 15:case"end":return n.stop()}}),n,null,[[0,12]])}))),function(){return u.apply(this,arguments)}),onError:function(e){return o(e||"Failed to upload the file")}});x.current.set(e,f)}),[D,z]),K=i.useCallback((function(e){var r,n,t,u,i=e.filter((function(e){return function(e,r){return r.split(",").map((function(e){return e.trim().toLowerCase()})).filter(Boolean).some((function(r){if(r.startsWith("."))return e.name.toLowerCase().endsWith(r);if(r.endsWith("/*")){var n=e.type.toLowerCase();return n?n.startsWith(r.slice(0,-1)):o.getAttachmentKind({name:e.name})===r.slice(0,-1)}return e.type.toLowerCase()===r}))}(e,C)})),l=i.length<e.length?1===e.length?"That file type is not supported.":"Some files were skipped — unsupported file type.":null,a="You can attach up to ".concat(g," files."),c=g-P.current.length;if(!i.length||c<=0){var d;null===(d=T.current)||void 0===d||d.call(T,i.length?a:l)}else{var p=i.slice(0,c),v=p.map((function(e){var r=U(e),n=!!f&&e.size>f;return{id:"attachment-".concat(k+=1),name:e.name,file:e,previewUrl:"file"===r?"":URL.createObjectURL(e),isUploading:!n,error:n?"File is too large (".concat(w(e.size)," MB). Maximum size is ").concat(w(f)," MB."):null,uploaded:null}}));M((function(e){return[].concat(s.default(e),s.default(v))}));var h=i.length>p.length?a:null;null===(r=T.current)||void 0===r||r.call(T,null!==(n=null!==(t=null===(u=P.current.find((function(e){return e.error})))||void 0===u?void 0:u.error)&&void 0!==t?t:l)&&void 0!==n?n:h),v.filter((function(e){return!e.error})).forEach((function(e){return W(e.id,e.file)}))}}),[M,g,f,W,C]),H=i.useCallback((function(e){var r,n=Array.from(null!==(r=e.target.files)&&void 0!==r?r:[]);R.current&&(R.current.value=""),n.length&&K(n)}),[K]),N=i.useCallback((function(){var e;return null===(e=R.current)||void 0===e?void 0:e.click()}),[]),Y=i.useCallback((function(e){var r=String(e);B(r),_(P.current.find((function(e){return e.id===r}))),M((function(e){return e.filter((function(e){return e.id!==r}))})),z()}),[B,_,M,z]),G=i.useCallback((function(e){var r=String(e),n=P.current.find((function(e){return e.id===r}));null!=n&&n.file&&(B(r),D(r,{isUploading:!0,error:null}),z(),W(r,n.file))}),[B,D,W,z]),I=i.useCallback((function(e){return M((function(r){var n=new Map(r.map((function(e){return[e.id,e]}))),t=e.map((function(e){return n.get(String(e))})).filter(Boolean),u=r.filter((function(r){return!e.some((function(e){return String(e)===r.id}))}));return[].concat(s.default(t),s.default(u))}))}),[M]),X=i.useCallback((function(){var e;P.current.forEach((function(e){B(e.id),_(e)})),M((function(){return[]})),null===(e=T.current)||void 0===e||e.call(T,null)}),[B,M,_]);i.useEffect((function(){var e,r,n;(r=q.current,n=t,r.length===n.length&&r.every((function(e,r){return e.url===n[r].url})))||(P.current.forEach((function(e){B(e.id),e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),P.current=t.map(y),q.current=t,S(P.current),null===(e=T.current)||void 0===e||e.call(T,null))}),[t,B]);var J=i.useState({}),Q=v.default(J,2),V=Q[0],Z=Q[1],$=i.useRef(V);$.current=V;var ee=E.filter((function(e){return!e.file&&e.uploaded})).map((function(e){return e.uploaded.name})).join("|");return i.useEffect((function(){var e=ee.split("|").filter((function(e){return e&&!(e in $.current)}));if(e.length){var r=!0;return Promise.all(e.map((function(e){return c.getS3DownloadLink(e,"inline").then((function(r){var n=r.url;return[e,n]})).catch((function(r){return console.error('Failed to sign stored attachment "'.concat(e,'"'),r),[e,""]}))}))).then((function(e){r&&Z((function(r){return b(b({},r),Object.fromEntries(e))}))})),function(){r=!1}}}),[ee]),{items:E.reduce((function(e,r){var n;if(r.file)return e.push({id:r.id,name:r.name,src:r.previewUrl,kind:U(r.file),isUploading:r.isUploading,error:null!==(n=r.error)&&void 0!==n?n:void 0}),e;var t=r.uploaded,u=o.getAttachmentKind(t),i=V[t.name];return"file"===u||i?(e.push({id:r.id,name:t.name,src:i,kind:u}),e):e}),[]),fileInputRef:R,openFileDialog:N,handleFileSelect:H,addFiles:K,removeAttachment:Y,handleRetry:G,reorderAttachments:I,clearAttachments:X,isUploading:E.some((function(e){return e.isUploading})),error:null!==(r=null===(n=E.find((function(e){return e.error})))||void 0===n?void 0:n.error)&&void 0!==r?r:null,count:E.length,isFull:E.length>=g,maxFiles:g}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),u=require("@babel/runtime/regenerator"),i=require("react"),l=require("react-s3-uploader/s3upload"),o=require("../AttachmentPreview/getAttachmentKind.js"),a=require("../AttachFileButton/AttachFileButton.js"),c=require("../../clients/jsonApi/index.js"),f=require("../../utils/links.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=s(e),p=s(r),v=s(n),m=s(t),h=s(u),g=s(l);function b(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function U(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?b(Object(n),!0).forEach((function(r){v.default(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var w=function(e){return e.type.startsWith("image/")?"image":e.type.startsWith("video/")?"video":"file"},k=function(e){return(e/1048576).toFixed(1)},y=function(e){return{id:e.url,name:e.name,file:null,previewUrl:"",isUploading:!1,error:null,uploaded:e}},j=0,C=function(){return"attachment-".concat(j+=1)};exports.DEFAULT_MAX_ATTACHMENTS=10,exports.useAttachmentUpload=function(e){var r,n,t=e.value,u=e.onChange,l=e.onError,s=e.maxSizeBytes,v=e.maxFiles,b=void 0===v?10:v,j=e.accept,O=void 0===j?a.ACCEPTED_ATTACHMENT_TYPES:j,A=i.useState([]),E=m.default(A,2),S=E[0],R=E[1],F=i.useRef(null),x=i.useRef(new Map),L=i.useRef(new Map),P=i.useRef([]),T=i.useRef(u),q=i.useRef(l);T.current=u,q.current=l;var z=i.useRef([]),M=i.useCallback((function(e){var r=e(P.current);P.current=r,R(r),z.current=function(e){return e.map((function(e){return e.uploaded})).filter(Boolean)}(r),T.current(z.current)}),[]),D=i.useCallback((function(e,r){return M((function(n){return n.map((function(n){return n.id===e?U(U({},n),r):n}))}))}),[M]),B=i.useCallback((function(e){var r,n;null===(r=x.current.get(e))||void 0===r||r.abortUpload(),x.current.delete(e),L.current.set(e,(null!==(n=L.current.get(e))&&void 0!==n?n:0)+1)}),[]),_=i.useCallback((function(e){null!=e&&e.previewUrl&&URL.revokeObjectURL(e.previewUrl)}),[]),W=i.useCallback((function(){var e,r,n;null===(e=q.current)||void 0===e||e.call(q,null!==(r=null===(n=P.current.find((function(e){return e.error})))||void 0===n?void 0:n.error)&&void 0!==r?r:null)}),[]);i.useEffect((function(){return function(){x.current.forEach((function(e){return e.abortUpload()})),x.current.clear(),P.current.forEach((function(e){e.previewUrl&&URL.revokeObjectURL(e.previewUrl)}))}}),[]);var K=i.useCallback((function(e,r){var n,t=(null!==(n=L.current.get(e))&&void 0!==n?n:0)+1;L.current.set(e,t);var u,i,l=function(){return L.current.get(e)===t},o=function(r){var n;l()&&(D(e,{isUploading:!1,error:r}),null===(n=q.current)||void 0===n||n.call(q,r))},a="",f=new g.default({files:[r],preprocess:function(e,r){return r(e)},onProgress:function(){},getSignedUrl:(i=p.default(h.default.mark((function e(r,n){var t;return h.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,c.getS3SignedUrl(r.name,r.type);case 3:t=e.sent,a=t.file_name,n(U(U({},t),{},{signedUrl:t.signed_url})),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),o((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"Failed to upload the file");case 11:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(e,r){return i.apply(this,arguments)}),onFinishS3Put:(u=p.default(h.default.mark((function n(){var t,u;return h.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,c.getS3DownloadLink(a);case 3:if(t=n.sent,u=t.url,l()){n.next=7;break}return n.abrupt("return");case 7:x.current.delete(e),D(e,{isUploading:!1,error:null,uploaded:{url:u,name:a,size:r.size}}),W(),n.next=15;break;case 12:n.prev=12,n.t0=n.catch(0),o((null===n.t0||void 0===n.t0?void 0:n.t0.message)||"Failed to upload the file");case 15:case"end":return n.stop()}}),n,null,[[0,12]])}))),function(){return u.apply(this,arguments)}),onError:function(e){return o(e||"Failed to upload the file")}});x.current.set(e,f)}),[D,W]),N=i.useCallback((function(e){var r,n=f.getUrlFileName(e);n&&(P.current.length>=b?null===(r=q.current)||void 0===r||r.call(q,"You can attach up to ".concat(b," files.")):P.current.some((function(r){var n;return(null===(n=r.uploaded)||void 0===n?void 0:n.url)===e}))||M((function(r){return[].concat(d.default(r),[{id:C(),name:n,file:null,previewUrl:e,isUploading:!1,error:null,uploaded:{url:e,name:n}}])})))}),[M,b]),Y=i.useCallback((function(e){var r,n,t,u,i=e.filter((function(e){return function(e,r){return r.split(",").map((function(e){return e.trim().toLowerCase()})).filter(Boolean).some((function(r){if(r.startsWith("."))return e.name.toLowerCase().endsWith(r);if(r.endsWith("/*")){var n=e.type.toLowerCase();return n?n.startsWith(r.slice(0,-1)):o.getAttachmentKind({name:e.name})===r.slice(0,-1)}return e.type.toLowerCase()===r}))}(e,O)})),l=i.length<e.length?1===e.length?"That file type is not supported.":"Some files were skipped — unsupported file type.":null,a="You can attach up to ".concat(b," files."),c=b-P.current.length;if(!i.length||c<=0){var f;null===(f=q.current)||void 0===f||f.call(q,i.length?a:l)}else{var p=i.slice(0,c),v=p.map((function(e){var r=w(e),n=!!s&&e.size>s;return{id:C(),name:e.name,file:e,previewUrl:"file"===r?"":URL.createObjectURL(e),isUploading:!n,error:n?"File is too large (".concat(k(e.size)," MB). Maximum size is ").concat(k(s)," MB."):null,uploaded:null}}));M((function(e){return[].concat(d.default(e),d.default(v))}));var m=i.length>p.length?a:null;null===(r=q.current)||void 0===r||r.call(q,null!==(n=null!==(t=null===(u=P.current.find((function(e){return e.error})))||void 0===u?void 0:u.error)&&void 0!==t?t:l)&&void 0!==n?n:m),v.filter((function(e){return!e.error})).forEach((function(e){return K(e.id,e.file)}))}}),[M,b,s,K,O]),H=i.useCallback((function(e){var r,n=Array.from(null!==(r=e.target.files)&&void 0!==r?r:[]);F.current&&(F.current.value=""),n.length&&Y(n)}),[Y]),I=i.useCallback((function(){var e;return null===(e=F.current)||void 0===e?void 0:e.click()}),[]),G=i.useCallback((function(e){var r=String(e);B(r),_(P.current.find((function(e){return e.id===r}))),M((function(e){return e.filter((function(e){return e.id!==r}))})),W()}),[B,_,M,W]),X=i.useCallback((function(e){var r=String(e),n=P.current.find((function(e){return e.id===r}));null!=n&&n.file&&(B(r),D(r,{isUploading:!0,error:null}),W(),K(r,n.file))}),[B,D,K,W]),J=i.useCallback((function(e){return M((function(r){var n=new Map(r.map((function(e){return[e.id,e]}))),t=e.map((function(e){return n.get(String(e))})).filter(Boolean),u=r.filter((function(r){return!e.some((function(e){return String(e)===r.id}))}));return[].concat(d.default(t),d.default(u))}))}),[M]),Q=i.useCallback((function(){var e;P.current.forEach((function(e){B(e.id),_(e)})),M((function(){return[]})),null===(e=q.current)||void 0===e||e.call(q,null)}),[B,M,_]);i.useEffect((function(){var e,r,n;(r=z.current,n=t,r.length===n.length&&r.every((function(e,r){return e.url===n[r].url})))||(P.current.forEach((function(e){B(e.id),e.previewUrl&&URL.revokeObjectURL(e.previewUrl)})),P.current=t.map(y),z.current=t,R(P.current),null===(e=q.current)||void 0===e||e.call(q,null))}),[t,B]);var V=i.useState({}),Z=m.default(V,2),$=Z[0],ee=Z[1],re=i.useRef($);re.current=$;var ne=S.filter((function(e){return!e.file&&!e.previewUrl&&e.uploaded})).map((function(e){return e.uploaded.name})).join("|");return i.useEffect((function(){var e=ne.split("|").filter((function(e){return e&&!(e in re.current)}));if(e.length){var r=!0;return Promise.all(e.map((function(e){return c.getS3DownloadLink(e,"inline").then((function(r){var n=r.url;return[e,n]})).catch((function(r){return console.error('Failed to sign stored attachment "'.concat(e,'"'),r),[e,""]}))}))).then((function(e){r&&ee((function(r){return U(U({},r),Object.fromEntries(e))}))})),function(){r=!1}}}),[ne]),{items:S.reduce((function(e,r){var n;if(r.file)return e.push({id:r.id,name:r.name,src:r.previewUrl,kind:w(r.file),size:r.file.size,isUploading:r.isUploading,error:null!==(n=r.error)&&void 0!==n?n:void 0}),e;var t=r.uploaded,u=o.getAttachmentKind(t),i=r.previewUrl||$[t.name];return"file"===u||i?(e.push({id:r.id,name:t.name,src:i,kind:u,size:t.size}),e):e}),[]),fileInputRef:F,openFileDialog:I,handleFileSelect:H,addFiles:Y,addLinkedImage:N,removeAttachment:G,handleRetry:X,reorderAttachments:J,clearAttachments:Q,isUploading:S.some((function(e){return e.isUploading})),error:null!==(r=null===(n=S.find((function(e){return e.error})))||void 0===n?void 0:n.error)&&void 0!==r?r:null,count:S.length,isFull:S.length>=b,maxFiles:b}};
2
2
  //# sourceMappingURL=useAttachmentUpload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAttachmentUpload.js","sources":["../../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl, getS3DownloadLink } from '~/clients/jsonApi';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const { url } = await getS3DownloadLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>({});\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n .filter(entry => !entry.file && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getS3DownloadLink(name, 'inline')\n .then(({ url }: { url: string }) => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n isUploading: entry.isUploading,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n const src = storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_yield$getS3DownloadL","_context2","getS3DownloadLink","abrupt","size","addFiles","_onErrorRef$current4","_ref2","_entriesRef$current$f3","_entriesRef$current$f4","supported","split","rule","trim","toLowerCase","some","endsWith","slice","getAttachmentKind","isAcceptedType","unsupported","length","tooMany","room","_onErrorRef$current3","accepted","added","kind","isTooLarge","concat","createObjectURL","overflow","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current5","_onErrorRef$current6","a","b","every","index","_useState3","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","Promise","all","then","_ref3","catch","console","resolved","_objectSpread","Object","fromEntries","items","reduce","acc","_entry$error","push","src","undefined","stored","count","isFull"],"mappings":"gtCAwCO,IAoBDA,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,Q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8H,EAAOT,oBAAkBiE,GACzBF,EAAMtB,EAAWwB,EAAO1L,MAE9B,MAAa,SAATkI,GAAoBsD,GAExBH,EAAIE,KAAK,CAAEzL,GAAIyC,EAAMzC,GAAIE,KAAM0L,EAAO1L,KAAMwL,IAAAA,EAAKtD,KAAAA,IAC1CmD,GAH6BA,CAIrC,GAAE,IAID7J,aAAAA,EACAoH,eAAAA,EACAL,iBAAAA,EACA3B,SAAAA,EACAmC,iBAAAA,EACAG,YAAAA,EACAE,mBAAAA,EACAK,iBAAAA,EACAvJ,YAAaoB,EAAQgG,MAAK,SAAA/E,GAAK,OAAIA,EAAMrC,eACzCC,MAAgD,UAAzC,UAAAmB,EAAQqC,MAAK,SAAApB,GAAK,OAAIA,EAAMpC,KAAK,WAAjC,IAAAK,OAAA,EAAAA,EAAoCL,aAAK,IAAAI,EAAAA,EAAI,KACpDoL,MAAOrK,EAAQsG,OACfgE,OAAQtK,EAAQsG,QAAU9G,EAC1BA,SAAAA,EAEJ"}
1
+ {"version":3,"file":"useAttachmentUpload.js","sources":["../../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl, getS3DownloadLink } from '~/clients/jsonApi';\nimport { getUrlFileName } from '~/utils/links';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const { url } = await getS3DownloadLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n /** Nothing is uploaded: a comment attachment is a url, so the link itself is the attachment. */\n const addLinkedImage = useCallback(\n (url: string) => {\n const name = getUrlFileName(url);\n\n if (!name) return;\n if (entriesRef.current.length >= maxFiles) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n if (entriesRef.current.some(entry => entry.uploaded?.url === url)) return;\n\n commit(prev => [\n ...prev,\n {\n id: nextEntryId(),\n name,\n file: null,\n previewUrl: url,\n isUploading: false,\n error: null,\n uploaded: { url, name },\n },\n ]);\n },\n [commit, maxFiles]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>({});\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n // A linked image carries its own url, so there is no key of ours to sign.\n .filter(entry => !entry.file && !entry.previewUrl && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getS3DownloadLink(name, 'inline')\n .then(({ url }: { url: string }) => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n size: entry.file.size,\n isUploading: entry.isUploading,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n // A linked image is already a url; only one of ours has an S3 key worth signing.\n const src = entry.previewUrl || storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind, size: stored.size });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n addLinkedImage,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","nextEntryId","concat","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_yield$getS3DownloadL","_context2","getS3DownloadLink","abrupt","size","addLinkedImage","_onErrorRef$current3","getUrlFileName","length","some","_entry$uploaded","_toConsumableArray","addFiles","_onErrorRef$current5","_ref2","_entriesRef$current$f3","_entriesRef$current$f4","supported","split","rule","trim","toLowerCase","endsWith","slice","getAttachmentKind","isAcceptedType","unsupported","tooMany","room","_onErrorRef$current4","accepted","added","kind","isTooLarge","createObjectURL","overflow","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current6","_onErrorRef$current7","a","b","every","index","_useState3","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","Promise","all","then","_ref3","catch","console","resolved","_objectSpread","Object","fromEntries","items","reduce","acc","_entry$error","push","src","undefined","stored","count","isFull"],"mappings":"kvCAyCO,IAoBDA,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,QACvCF,EAAKC,KAAKC,WAAW,UAAkB,QACpC,MACT,EAEMC,EAAW,SAACC,GAAa,OAAMA,EAAK,SAAkBC,QAAQ,EAAE,EAQhEC,EAAgB,SAACC,GAA8B,MAAa,CAChEC,GAAID,EAAWE,IACfC,KAAMH,EAAWG,KACjBV,KAAM,KACNW,WAAY,GACZC,aAAa,EACbC,MAAO,KACPC,SAAUP,EACX,EAEGQ,EAAW,EACTC,EAAc,WAElB,MAAA,cAAAC,OADAF,GAAY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GAAInJ,EAAMnD,KAUR,OATAqM,EAAIE,KAAK,CACP/L,GAAI2C,EAAM3C,GACVE,KAAMyC,EAAMzC,KACZ8L,IAAKrJ,EAAMxC,WACXwI,KAAMpJ,EAAYoD,EAAMnD,MACxBuH,KAAMpE,EAAMnD,KAAKuH,KACjB3G,YAAauC,EAAMvC,YACnBC,MAAsB4L,QAAftJ,EAAAA,EAAMtC,aAAS4L,IAAAA,EAAAA,OAAAA,IAEjBJ,EAGT,IAAMK,EAASvJ,EAAMrC,SACfqI,EAAOR,oBAAkB+D,GAEzBF,EAAMrJ,EAAMxC,YAAcuK,EAAWwB,EAAOhM,MAElD,MAAa,SAATyI,GAAoBqD,GAExBH,EAAIE,KAAK,CAAE/L,GAAI2C,EAAM3C,GAAIE,KAAMgM,EAAOhM,KAAM8L,IAAAA,EAAKrD,KAAAA,EAAM5B,KAAMmF,EAAOnF,OAC7D8E,GAH6BA,CAIrC,GAAE,IAIDjK,aAAAA,EACAwH,eAAAA,EACAL,iBAAAA,EACAxB,SAAAA,EACAP,eAAAA,EACAuC,iBAAAA,EACAG,YAAAA,EACAE,mBAAAA,EACAK,iBAAAA,EACA7J,YAAasB,EAAQ0F,MAAK,SAAAzE,GAAK,OAAIA,EAAMvC,eACzCC,MAAgD,UAAzC,UAAAqB,EAAQqC,MAAK,SAAApB,GAAK,OAAIA,EAAMtC,KAAK,WAAjC,IAAAO,OAAA,EAAAA,EAAoCP,aAAK,IAAAM,EAAAA,EAAI,KACpDwL,MAAOzK,EAAQyF,OACfiF,OAAQ1K,EAAQyF,QAAUjG,EAC1BA,SAAAA,EAEJ"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),o=require("react"),i=require("classnames"),c=require("../../componentsV2/ButtonIcon/ButtonIcon.js"),n=require("../../componentsV2/Tooltip/Tooltip.js"),r=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/DragOne.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/SearchOne.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/MoreApp.js"),require("../../icons/customIcons/icons/Pad.js"),require("../../icons/customIcons/icons/DrilloutUnit.js"),require("../../icons/customIcons/icons/FracFleet.js"),require("../../icons/customIcons/icons/Global.js"),require("../../icons/customIcons/icons/Program.js"),require("../../icons/customIcons/icons/Rig.js"),require("../../icons/customIcons/icons/Well.js"),require("../../icons/customIcons/icons/Gap.js"),require("../../icons/customIcons/icons/Pin.js"),require("../../icons/customIcons/icons/CloseOneFilled.js"),require("../../icons/customIcons/icons/AttentionFilled.js"),require("../../icons/customIcons/icons/CheckOneFilled.js"),require("../../icons/customIcons/icons/Archive.js"),require("../../icons/customIcons/icons/ArchiveCancel.js"),require("../../icons/customIcons/icons/Unarchive.js"),require("../../icons/customIcons/icons/Archived.js"),require("../../icons/customIcons/icons/InterventionUnit.js"),require("../../icons/customIcons/icons/CloudDelete.js"),require("../../icons/customIcons/icons/Lasso.js"),require("../../icons/customIcons/icons/Radius.js"),require("../../icons/customIcons/icons/ErrorOps.js"),require("../../icons/customIcons/icons/DataTypeOps.js"),require("../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../icons/customIcons/icons/CalibrationOps.js"),require("../../icons/customIcons/icons/CriticalOps.js"),require("../../icons/customIcons/icons/Company.js"),require("../../icons/customIcons/icons/ArchiveOne.js"),require("../../icons/customIcons/icons/ParseBotFusion.js"),require("../../icons/customIcons/icons/Connect.js"),require("../../icons/customIcons/icons/PuzzleOne.js"),require("../../icons/customIcons/icons/Feed.js"),require("../../icons/customIcons/icons/Prompt.js"),require("../../icons/customIcons/icons/Companies.js"),require("../../icons/customIcons/icons/ClipboardAi.js"),require("../../icons/customIcons/icons/Key.js"),require("../../icons/customIcons/icons/AtSignCrossed.js"),require("../../icons/customIcons/icons/MappingManual.js"),require("../../icons/customIcons/icons/Mapping.js"),require("../../icons/customIcons/icons/Metrics.js"),require("../../icons/customIcons/icons/Drops.js"),require("../../icons/customIcons/icons/ClipboardSearch.js"),require("../../icons/customIcons/icons/Template.js"),require("../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../icons/customIcons/icons/UnitConversion.js"),require("../../icons/customIcons/icons/NPT.js"),require("../../icons/customIcons/icons/GuidedFrac.js");var t=require("../AttachmentPreview/AttachmentPreview.js");require("../../componentsV2/FileIcon/FileIcon.js"),require("@material-ui/core");var u=require("react/jsx-runtime");require("../AttachmentPreview/AttachmentPreview.scss.js"),require("../../utils/main.js"),require("file-extension"),require("image-extensions"),require("video-extensions"),require("../../clients/jsonApi/index.js"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator");var a=require("./useFileDrop.js"),l=require("./CommentInputNext.scss.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=m(e),j=m(s),q=m(i);function I(e,s){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);s&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable}))),o.push.apply(o,i)}return o}function p(e){for(var s=1;s<arguments.length;s++){var o=null!=arguments[s]?arguments[s]:{};s%2?I(Object(o),!0).forEach((function(s){d.default(e,s,o[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):I(Object(o)).forEach((function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(o,s))}))}return e}var h=o.forwardRef((function(e,s){var i=e.placeholder,m=void 0===i?"Add a comment":i,d=e.value,I=e.onChange,h=e.onSubmit,v=e.onCancel,f=e.disabled,b=e.autoFocus,x=e.minRows,g=void 0===x?1:x,O=e.maxRows,y=e.field,C=e.canSubmit,P=e.bare,F=e.leading,A=e.trailing,w=e.sendTooltip,D=void 0===w?"Send":w,N=e.attachments,R=e.onAttachmentRemove,S=e.onAttachmentRetry,k=e.onAttachmentReorder,E=e.onFilesDrop,M=e.dropLabel,T=void 0===M?"Drop files here":M,B=e.attachmentSlot,G=e.toolbar,U=e.footer,L=e.embedded,z=e.className,H=e.testId,K=a.useFileDrop(f?void 0:E),V=K.isDragging,W=K.dropHandlers,_=V&&u.jsx("div",{className:l.dropOverlay,children:T}),Y=void 0!==d,Z=o.useState(""),J=j.default(Z,2),Q=J[0],X=J[1],$=Y?d:Q,ee=null!=O?O:P?12:8,se=o.useRef(null),oe=o.useCallback((function(e){if(se.current=e,e){var s=e;s.style.height="auto";var o=20*ee;s.style.height="".concat(Math.min(s.scrollHeight,o),"px"),s.style.overflowY=s.scrollHeight>o?"auto":"hidden"}}),[ee]);o.useLayoutEffect((function(){y||oe(se.current)}),[$,y,oe]);var ie=(null!=C?C:!!$.trim())&&!f,ce=function(){ie&&(null==h||h($.trim()),Y||y||X(""))},ne=null!=y?y:u.jsx("textarea",{ref:oe,className:l.input,rows:g,placeholder:m,value:$,disabled:f,autoFocus:b,onChange:function(e){var s;s=e.target.value,Y||X(s),null==I||I(s),oe(e.target)},onKeyDown:function(e){if("Escape"===e.key&&v)return e.preventDefault(),void v();"Enter"!==e.key||e.shiftKey||(e.preventDefault(),ce())}}),re=null!=A?A:u.jsx(n.Tooltip,{title:D,children:u.jsx("span",{className:l.send,children:u.jsx(c.ButtonIcon,{size:P?"xs":"small",type:"primary",disabled:!ie,onClick:ce,testId:"comment-input-send",children:u.jsx(r.ArrowUpIcon,{})})})}),te=((null==N?void 0:N.length)||B)&&u.jsxs("div",{className:l.attachment,children:[null!=N&&N.length?u.jsx(t.AttachmentPreview,{items:N,onRemove:R,onRetry:S,onReorder:k}):null,B]});return P?u.jsxs("div",p(p({ref:s,"data-testid":H,className:q.default(l.rootBare,z)},W),{},{children:[_,u.jsxs("div",{className:l.fieldRow,children:[F&&u.jsx("div",{className:l.leading,children:F}),u.jsxs("div",{className:q.default(l.field,!!te&&l.fieldExpanded,f&&l.fieldDisabled),children:[u.jsxs("div",{className:l.fieldMain,children:[ne,te]}),G&&u.jsx("div",{className:l.bareToolbar,children:G}),re]})]})]})):u.jsxs("div",p(p({ref:s,"data-testid":H,className:q.default(l.root,L&&l.rootEmbedded,z)},W),{},{children:[_,u.jsxs("div",{className:l.inputPanel,children:[ne,te,u.jsxs("div",{className:l.toolbarRow,children:[u.jsx("div",{className:l.toolbar,children:G}),re]})]}),U&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:l.divider}),u.jsx("div",{className:l.metaShare,children:U})]})]}))}));exports.CommentInput=h;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),o=require("react"),i=require("classnames"),n=require("../../componentsV2/ButtonIcon/ButtonIcon.js"),c=require("../../componentsV2/Tooltip/Tooltip.js"),r=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/DragOne.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/SearchOne.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/MoreApp.js"),require("../../icons/customIcons/icons/Pad.js"),require("../../icons/customIcons/icons/DrilloutUnit.js"),require("../../icons/customIcons/icons/FracFleet.js"),require("../../icons/customIcons/icons/Global.js"),require("../../icons/customIcons/icons/Program.js"),require("../../icons/customIcons/icons/Rig.js"),require("../../icons/customIcons/icons/Well.js"),require("../../icons/customIcons/icons/Gap.js"),require("../../icons/customIcons/icons/Pin.js"),require("../../icons/customIcons/icons/CloseOneFilled.js"),require("../../icons/customIcons/icons/AttentionFilled.js"),require("../../icons/customIcons/icons/CheckOneFilled.js"),require("../../icons/customIcons/icons/Archive.js"),require("../../icons/customIcons/icons/ArchiveCancel.js"),require("../../icons/customIcons/icons/Unarchive.js"),require("../../icons/customIcons/icons/Archived.js"),require("../../icons/customIcons/icons/InterventionUnit.js"),require("../../icons/customIcons/icons/CloudDelete.js"),require("../../icons/customIcons/icons/Lasso.js"),require("../../icons/customIcons/icons/Radius.js"),require("../../icons/customIcons/icons/ErrorOps.js"),require("../../icons/customIcons/icons/DataTypeOps.js"),require("../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../icons/customIcons/icons/CalibrationOps.js"),require("../../icons/customIcons/icons/CriticalOps.js"),require("../../icons/customIcons/icons/Company.js"),require("../../icons/customIcons/icons/ArchiveOne.js"),require("../../icons/customIcons/icons/ParseBotFusion.js"),require("../../icons/customIcons/icons/Connect.js"),require("../../icons/customIcons/icons/PuzzleOne.js"),require("../../icons/customIcons/icons/Feed.js"),require("../../icons/customIcons/icons/Prompt.js"),require("../../icons/customIcons/icons/Companies.js"),require("../../icons/customIcons/icons/ClipboardAi.js"),require("../../icons/customIcons/icons/Key.js"),require("../../icons/customIcons/icons/AtSignCrossed.js"),require("../../icons/customIcons/icons/MappingManual.js"),require("../../icons/customIcons/icons/Mapping.js"),require("../../icons/customIcons/icons/Metrics.js"),require("../../icons/customIcons/icons/Drops.js"),require("../../icons/customIcons/icons/ClipboardSearch.js"),require("../../icons/customIcons/icons/Template.js"),require("../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../icons/customIcons/icons/UnitConversion.js"),require("../../icons/customIcons/icons/NPT.js"),require("../../icons/customIcons/icons/GuidedFrac.js");var t=require("../AttachmentPreview/AttachmentPreview.js");require("../../componentsV2/FileIcon/FileIcon.js"),require("@material-ui/core");var u=require("react/jsx-runtime");require("../../componentsV2/Menu/Menu.js"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/regenerator"),require("../../clients/jsonApi/index.js"),require("../../utils/main.js"),require("../AttachmentPreview/AttachmentImage.js"),require("../AttachmentPreview/AttachmentPreview.scss.js"),require("file-extension"),require("image-extensions"),require("video-extensions");var a=require("./useFileDrop.js"),l=require("./useFilePaste.js"),m=require("./CommentInputNext.scss.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=d(e),q=d(s),I=d(i);function p(e,s){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);s&&(i=i.filter((function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable}))),o.push.apply(o,i)}return o}function h(e){for(var s=1;s<arguments.length;s++){var o=null!=arguments[s]?arguments[s]:{};s%2?p(Object(o),!0).forEach((function(s){j.default(e,s,o[s])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):p(Object(o)).forEach((function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(o,s))}))}return e}var v=o.forwardRef((function(e,s){var i=e.placeholder,d=void 0===i?"Add a comment":i,j=e.value,p=e.onChange,v=e.onSubmit,f=e.onCancel,b=e.disabled,x=e.autoFocus,g=e.minRows,O=void 0===g?1:g,y=e.maxRows,C=e.field,P=e.canSubmit,F=e.bare,A=e.leading,w=e.trailing,D=e.sendTooltip,N=void 0===D?"Send":D,R=e.attachments,k=e.onAttachmentRemove,M=e.onAttachmentRetry,S=e.onAttachmentReorder,E=e.onFilesDrop,T=e.onImageLinkPaste,B=e.dropLabel,L=void 0===B?"Drop files here":B,G=e.attachmentSlot,U=e.toolbar,H=e.footer,V=e.embedded,z=e.className,K=e.testId,W=a.useFileDrop(b?void 0:E),_=W.isDragging,Y=W.dropHandlers,Z=l.useFilePaste(b?{}:{onFiles:E,onImageLink:T}).pasteHandlers,J=_&&u.jsx("div",{className:m.dropOverlay,children:L}),Q=void 0!==j,X=o.useState(""),$=q.default(X,2),ee=$[0],se=$[1],oe=Q?j:ee,ie=null!=y?y:F?12:8,ne=o.useRef(null),ce=o.useCallback((function(e){if(ne.current=e,e){var s=e;s.style.height="auto";var o=20*ie;s.style.height="".concat(Math.min(s.scrollHeight,o),"px"),s.style.overflowY=s.scrollHeight>o?"auto":"hidden"}}),[ie]);o.useLayoutEffect((function(){C||ce(ne.current)}),[oe,C,ce]);var re=(null!=P?P:!!oe.trim())&&!b,te=function(){re&&(null==v||v(oe.trim()),Q||C||se(""))},ue=null!=C?C:u.jsx("textarea",{ref:ce,className:m.input,rows:O,placeholder:d,value:oe,disabled:b,autoFocus:x,onChange:function(e){var s;s=e.target.value,Q||se(s),null==p||p(s),ce(e.target)},onKeyDown:function(e){if("Escape"===e.key&&f)return e.preventDefault(),void f();"Enter"!==e.key||e.shiftKey||(e.preventDefault(),te())}}),ae=null!=w?w:u.jsx(c.Tooltip,{title:N,children:u.jsx("span",{className:m.send,children:u.jsx(n.ButtonIcon,{size:F?"xs":"small",type:"primary",disabled:!re,onClick:te,testId:"comment-input-send",children:u.jsx(r.ArrowUpIcon,{})})})}),le=((null==R?void 0:R.length)||G)&&u.jsxs("div",{className:m.attachment,children:[null!=R&&R.length?u.jsx(t.AttachmentPreview,{items:R,onRemove:k,onRetry:M,onReorder:S}):null,G]});return F?u.jsxs("div",h(h(h({ref:s,"data-testid":K,className:I.default(m.rootBare,z)},Y),Z),{},{children:[J,u.jsxs("div",{className:m.fieldRow,children:[A&&u.jsx("div",{className:m.leading,children:A}),u.jsxs("div",{className:I.default(m.field,!!le&&m.fieldExpanded,b&&m.fieldDisabled),children:[u.jsxs("div",{className:m.fieldMain,children:[ue,le]}),U&&u.jsx("div",{className:m.bareToolbar,children:U}),ae]})]})]})):u.jsxs("div",h(h(h({ref:s,"data-testid":K,className:I.default(m.root,V&&m.rootEmbedded,z)},Y),Z),{},{children:[J,u.jsxs("div",{className:m.inputPanel,children:[ue,le,u.jsxs("div",{className:m.toolbarRow,children:[u.jsx("div",{className:m.toolbar,children:U}),ae]})]}),H&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:m.divider}),u.jsx("div",{className:m.metaShare,children:H})]})]}))}));exports.CommentInput=v;
2
2
  //# sourceMappingURL=CommentInputNext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommentInputNext.js","sources":["../../../../src/components/CommentInputNext/CommentInputNext.tsx"],"sourcesContent":["import {\n forwardRef,\n KeyboardEvent,\n ReactNode,\n useState,\n useCallback,\n useRef,\n useLayoutEffect,\n ChangeEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { ArrowUpIcon } from '../../icons';\nimport { AttachmentPreview } from '../AttachmentPreview';\nimport { AttachmentPreviewItem } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport { useFileDrop } from './useFileDrop';\n\nimport styles from './CommentInputNext.scss';\n\nexport type CommentInputProps = {\n placeholder?: string;\n value?: string;\n onChange?: (value: string) => void;\n onSubmit?: (value: string) => void;\n onCancel?: () => void;\n disabled?: boolean;\n autoFocus?: boolean;\n minRows?: number;\n maxRows?: number;\n\n /** Editable control rendered in place of the built-in textarea. */\n field?: ReactNode;\n canSubmit?: boolean;\n /** Drop the outer surface so the field sits flush, for the in-card reply input. */\n bare?: boolean;\n\n leading?: ReactNode;\n /** Replaces the default send button. */\n trailing?: ReactNode;\n sendTooltip?: string;\n\n attachments?: AttachmentPreviewItem[];\n onAttachmentRemove?: (id: AttachmentPreviewItem['id']) => void;\n onAttachmentRetry?: (id: AttachmentPreviewItem['id']) => void;\n /** Enables drag-to-reorder on the attachment strip. */\n onAttachmentReorder?: (orderedIds: AttachmentPreviewItem['id'][]) => void;\n /** Enables dropping files from the desktop onto the composer. */\n onFilesDrop?: (files: File[]) => void;\n dropLabel?: string;\n /** Extra content in the attachment area, e.g. an upload-error banner. */\n attachmentSlot?: ReactNode;\n toolbar?: ReactNode;\n footer?: ReactNode;\n /** Render flush inside a host surface: no background, full-width divider. */\n embedded?: boolean;\n\n className?: string;\n testId?: string;\n};\n\nconst LINE_HEIGHT_PX = 20;\nconst DEFAULT_MAX_ROWS = 8;\nconst BARE_MAX_ROWS = 12;\n\nexport const CommentInput = forwardRef<HTMLDivElement, CommentInputProps>(\n (\n {\n placeholder = 'Add a comment',\n value,\n onChange,\n onSubmit,\n onCancel,\n disabled,\n autoFocus,\n minRows = 1,\n maxRows,\n field,\n canSubmit,\n bare,\n leading,\n trailing,\n sendTooltip = 'Send',\n attachments,\n onAttachmentRemove,\n onAttachmentRetry,\n onAttachmentReorder,\n onFilesDrop,\n dropLabel = 'Drop files here',\n attachmentSlot,\n toolbar,\n footer,\n embedded,\n className,\n testId,\n },\n ref\n ) => {\n const { isDragging, dropHandlers } = useFileDrop(disabled ? undefined : onFilesDrop);\n const dropOverlay = isDragging && <div className={styles.dropOverlay}>{dropLabel}</div>;\n\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState('');\n const text = isControlled ? value : internalValue;\n\n // The bare reply field has no toolbar row, so text may fill the whole box.\n const rowsCap = maxRows ?? (bare ? BARE_MAX_ROWS : DEFAULT_MAX_ROWS);\n\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const resize = useCallback(\n (el: HTMLTextAreaElement | null) => {\n textareaRef.current = el;\n if (!el) return;\n const node = el;\n node.style.height = 'auto';\n const maxHeight = rowsCap * LINE_HEIGHT_PX;\n node.style.height = `${Math.min(node.scrollHeight, maxHeight)}px`;\n node.style.overflowY = node.scrollHeight > maxHeight ? 'auto' : 'hidden';\n },\n [rowsCap]\n );\n\n // The ref callback won't fire for a prop-driven value change.\n useLayoutEffect(() => {\n if (!field) resize(textareaRef.current);\n }, [text, field, resize]);\n\n const setText = (next: string) => {\n if (!isControlled) setInternalValue(next);\n onChange?.(next);\n };\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n setText(event.target.value);\n resize(event.target);\n };\n\n const canSend = (canSubmit ?? !!text.trim()) && !disabled;\n\n const submit = () => {\n if (!canSend) return;\n onSubmit?.(text.trim());\n if (!isControlled && !field) setInternalValue('');\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Escape' && onCancel) {\n event.preventDefault();\n onCancel();\n return;\n }\n\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n submit();\n }\n };\n\n const editor = field ?? (\n <textarea\n ref={resize}\n className={styles.input}\n rows={minRows}\n placeholder={placeholder}\n value={text}\n disabled={disabled}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n />\n );\n\n const sendButton = trailing ?? (\n // A disabled button fires no events, so the tooltip needs its own target.\n <Tooltip title={sendTooltip}>\n <span className={styles.send}>\n <ButtonIcon\n size={bare ? 'xs' : 'small'}\n type=\"primary\"\n disabled={!canSend}\n onClick={submit}\n testId=\"comment-input-send\"\n >\n <ArrowUpIcon />\n </ButtonIcon>\n </span>\n </Tooltip>\n );\n\n const attachmentArea = (attachments?.length || attachmentSlot) && (\n <div className={styles.attachment}>\n {attachments?.length ? (\n <AttachmentPreview\n items={attachments}\n onRemove={onAttachmentRemove}\n onRetry={onAttachmentRetry}\n onReorder={onAttachmentReorder}\n />\n ) : null}\n {attachmentSlot}\n </div>\n );\n\n if (bare) {\n return (\n <div\n ref={ref}\n data-testid={testId}\n className={classNames(styles.rootBare, className)}\n {...dropHandlers}\n >\n {dropOverlay}\n <div className={styles.fieldRow}>\n {leading && <div className={styles.leading}>{leading}</div>}\n <div\n className={classNames(\n styles.field,\n !!attachmentArea && styles.fieldExpanded,\n disabled && styles.fieldDisabled\n )}\n >\n <div className={styles.fieldMain}>\n {editor}\n {attachmentArea}\n </div>\n {toolbar && <div className={styles.bareToolbar}>{toolbar}</div>}\n {sendButton}\n </div>\n </div>\n </div>\n );\n }\n\n return (\n <div\n ref={ref}\n data-testid={testId}\n className={classNames(styles.root, embedded && styles.rootEmbedded, className)}\n {...dropHandlers}\n >\n {dropOverlay}\n <div className={styles.inputPanel}>\n {editor}\n {attachmentArea}\n <div className={styles.toolbarRow}>\n <div className={styles.toolbar}>{toolbar}</div>\n {sendButton}\n </div>\n </div>\n\n {footer && (\n <>\n <div className={styles.divider} />\n <div className={styles.metaShare}>{footer}</div>\n </>\n )}\n </div>\n );\n }\n);\n"],"names":["CommentInput","forwardRef","_ref","ref","_ref$placeholder","placeholder","value","onChange","onSubmit","onCancel","disabled","autoFocus","_ref$minRows","minRows","maxRows","field","canSubmit","bare","leading","trailing","_ref$sendTooltip","sendTooltip","attachments","onAttachmentRemove","onAttachmentRetry","onAttachmentReorder","onFilesDrop","_ref$dropLabel","dropLabel","attachmentSlot","toolbar","footer","embedded","className","testId","_useFileDrop","useFileDrop","undefined","isDragging","dropHandlers","dropOverlay","_jsx","jsx","styles","children","isControlled","useState","_useState2","_slicedToArray","_useState","internalValue","setInternalValue","text","rowsCap","textareaRef","useRef","resize","useCallback","el","current","node","style","height","maxHeight","Math","min","scrollHeight","overflowY","useLayoutEffect","canSend","trim","submit","editor","input","rows","event","next","target","onKeyDown","key","preventDefault","shiftKey","sendButton","Tooltip","title","send","ButtonIcon","size","type","onClick","ArrowUpIcon","attachmentArea","length","_jsxs","attachment","AttachmentPreview","items","onRemove","onRetry","onReorder","_objectSpread","classNames","rootBare","jsxs","fieldRow","fieldExpanded","fieldDisabled","fieldMain","bareToolbar","root","rootEmbedded","inputPanel","toolbarRow","_Fragment","divider","metaShare"],"mappings":"k2KA+DA,IAIaA,EAAeC,EAAUA,YACpC,SAAAC,EA8BEC,GACG,IAAAC,EAAAF,EA7BDG,YAAAA,aAAc,gBAAeD,EAC7BE,IAAAA,MACAC,IAAAA,SACAC,IAAAA,SACAC,IAAAA,SACAC,IAAAA,SACAC,IAAAA,UAASC,EAAAV,EACTW,QAAAA,aAAU,EAACD,EACXE,IAAAA,QACAC,IAAAA,MACAC,IAAAA,UACAC,IAAAA,KACAC,IAAAA,QACAC,IAAAA,SAAQC,EAAAlB,EACRmB,YAAAA,aAAc,OAAMD,EACpBE,IAAAA,YACAC,IAAAA,mBACAC,IAAAA,kBACAC,IAAAA,oBACAC,IAAAA,YAAWC,EAAAzB,EACX0B,UAAAA,aAAY,kBAAiBD,EAC7BE,IAAAA,eACAC,IAAAA,QACAC,IAAAA,OACAC,IAAAA,SACAC,IAAAA,UACAC,IAAAA,OAIFC,EAAqCC,EAAWA,YAAC1B,OAAW2B,EAAYX,GAAhEY,IAAAA,WAAYC,IAAAA,aACdC,EAAcF,GAAcG,EA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U,QAAC1D,EAAOkE,KAAM7E,GAAYW,EAAOmE,aAAc7E,IAChEM,GAAY,GAAA,CAAAK,SAAA,CAEfJ,EACDqD,EAAAU,KAAA,MAAA,CAAKtE,UAAWU,EAAOoE,WAAWnE,SAC/B4B,CAAAA,GACAmB,GACDE,EAAAA,KAAA,MAAA,CAAK5D,UAAWU,EAAOqE,WAAWpE,SAChC,CAAAH,EAAAC,IAAA,MAAA,CAAKT,UAAWU,EAAOb,QAAQc,SAAEd,IAChCoD,SAIJnD,GACC8D,EAAAU,KAAAU,WAAA,CAAArE,SACE,CAAAH,EAAAC,IAAA,MAAA,CAAKT,UAAWU,EAAOuE,UACvBzE,EAAAC,IAAA,MAAA,CAAKT,UAAWU,EAAOwE,UAAUvE,SAAEb,UAK7C"}
1
+ {"version":3,"file":"CommentInputNext.js","sources":["../../../../src/components/CommentInputNext/CommentInputNext.tsx"],"sourcesContent":["import {\n forwardRef,\n KeyboardEvent,\n ReactNode,\n useState,\n useCallback,\n useRef,\n useLayoutEffect,\n ChangeEvent,\n} from 'react';\nimport classNames from 'classnames';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { ArrowUpIcon } from '../../icons';\nimport { AttachmentPreview } from '../AttachmentPreview';\nimport { AttachmentPreviewItem } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport { useFileDrop } from './useFileDrop';\nimport { useFilePaste } from './useFilePaste';\n\nimport styles from './CommentInputNext.scss';\n\nexport type CommentInputProps = {\n placeholder?: string;\n value?: string;\n onChange?: (value: string) => void;\n onSubmit?: (value: string) => void;\n onCancel?: () => void;\n disabled?: boolean;\n autoFocus?: boolean;\n minRows?: number;\n maxRows?: number;\n\n /** Editable control rendered in place of the built-in textarea. */\n field?: ReactNode;\n canSubmit?: boolean;\n /** Drop the outer surface so the field sits flush, for the in-card reply input. */\n bare?: boolean;\n\n leading?: ReactNode;\n /** Replaces the default send button. */\n trailing?: ReactNode;\n sendTooltip?: string;\n\n attachments?: AttachmentPreviewItem[];\n onAttachmentRemove?: (id: AttachmentPreviewItem['id']) => void;\n onAttachmentRetry?: (id: AttachmentPreviewItem['id']) => void;\n /** Enables drag-to-reorder on the attachment strip. */\n onAttachmentReorder?: (orderedIds: AttachmentPreviewItem['id'][]) => void;\n /** Enables dropping files from the desktop onto the composer. */\n onFilesDrop?: (files: File[]) => void;\n /** Given a pasted link that points at an image. */\n onImageLinkPaste?: (url: string) => void;\n dropLabel?: string;\n /** Extra content in the attachment area, e.g. an upload-error banner. */\n attachmentSlot?: ReactNode;\n toolbar?: ReactNode;\n footer?: ReactNode;\n /** Render flush inside a host surface: no background, full-width divider. */\n embedded?: boolean;\n\n className?: string;\n testId?: string;\n};\n\nconst LINE_HEIGHT_PX = 20;\nconst DEFAULT_MAX_ROWS = 8;\nconst BARE_MAX_ROWS = 12;\n\nexport const CommentInput = forwardRef<HTMLDivElement, CommentInputProps>(\n (\n {\n placeholder = 'Add a comment',\n value,\n onChange,\n onSubmit,\n onCancel,\n disabled,\n autoFocus,\n minRows = 1,\n maxRows,\n field,\n canSubmit,\n bare,\n leading,\n trailing,\n sendTooltip = 'Send',\n attachments,\n onAttachmentRemove,\n onAttachmentRetry,\n onAttachmentReorder,\n onFilesDrop,\n onImageLinkPaste,\n dropLabel = 'Drop files here',\n attachmentSlot,\n toolbar,\n footer,\n embedded,\n className,\n testId,\n },\n ref\n ) => {\n const { isDragging, dropHandlers } = useFileDrop(disabled ? undefined : onFilesDrop);\n const { pasteHandlers } = useFilePaste(\n disabled ? {} : { onFiles: onFilesDrop, onImageLink: onImageLinkPaste }\n );\n const dropOverlay = isDragging && <div className={styles.dropOverlay}>{dropLabel}</div>;\n\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState('');\n const text = isControlled ? value : internalValue;\n\n // The bare reply field has no toolbar row, so text may fill the whole box.\n const rowsCap = maxRows ?? (bare ? BARE_MAX_ROWS : DEFAULT_MAX_ROWS);\n\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const resize = useCallback(\n (el: HTMLTextAreaElement | null) => {\n textareaRef.current = el;\n if (!el) return;\n const node = el;\n node.style.height = 'auto';\n const maxHeight = rowsCap * LINE_HEIGHT_PX;\n node.style.height = `${Math.min(node.scrollHeight, maxHeight)}px`;\n node.style.overflowY = node.scrollHeight > maxHeight ? 'auto' : 'hidden';\n },\n [rowsCap]\n );\n\n // The ref callback won't fire for a prop-driven value change.\n useLayoutEffect(() => {\n if (!field) resize(textareaRef.current);\n }, [text, field, resize]);\n\n const setText = (next: string) => {\n if (!isControlled) setInternalValue(next);\n onChange?.(next);\n };\n\n const handleChange = (event: ChangeEvent<HTMLTextAreaElement>) => {\n setText(event.target.value);\n resize(event.target);\n };\n\n const canSend = (canSubmit ?? !!text.trim()) && !disabled;\n\n const submit = () => {\n if (!canSend) return;\n onSubmit?.(text.trim());\n if (!isControlled && !field) setInternalValue('');\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Escape' && onCancel) {\n event.preventDefault();\n onCancel();\n return;\n }\n\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n submit();\n }\n };\n\n const editor = field ?? (\n <textarea\n ref={resize}\n className={styles.input}\n rows={minRows}\n placeholder={placeholder}\n value={text}\n disabled={disabled}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n />\n );\n\n const sendButton = trailing ?? (\n // A disabled button fires no events, so the tooltip needs its own target.\n <Tooltip title={sendTooltip}>\n <span className={styles.send}>\n <ButtonIcon\n size={bare ? 'xs' : 'small'}\n type=\"primary\"\n disabled={!canSend}\n onClick={submit}\n testId=\"comment-input-send\"\n >\n <ArrowUpIcon />\n </ButtonIcon>\n </span>\n </Tooltip>\n );\n\n const attachmentArea = (attachments?.length || attachmentSlot) && (\n <div className={styles.attachment}>\n {attachments?.length ? (\n <AttachmentPreview\n items={attachments}\n onRemove={onAttachmentRemove}\n onRetry={onAttachmentRetry}\n onReorder={onAttachmentReorder}\n />\n ) : null}\n {attachmentSlot}\n </div>\n );\n\n if (bare) {\n return (\n <div\n ref={ref}\n data-testid={testId}\n className={classNames(styles.rootBare, className)}\n {...dropHandlers}\n {...pasteHandlers}\n >\n {dropOverlay}\n <div className={styles.fieldRow}>\n {leading && <div className={styles.leading}>{leading}</div>}\n <div\n className={classNames(\n styles.field,\n !!attachmentArea && styles.fieldExpanded,\n disabled && styles.fieldDisabled\n )}\n >\n <div className={styles.fieldMain}>\n {editor}\n {attachmentArea}\n </div>\n {toolbar && <div className={styles.bareToolbar}>{toolbar}</div>}\n {sendButton}\n </div>\n </div>\n </div>\n );\n }\n\n return (\n <div\n ref={ref}\n data-testid={testId}\n className={classNames(styles.root, embedded && styles.rootEmbedded, className)}\n {...dropHandlers}\n {...pasteHandlers}\n >\n {dropOverlay}\n <div className={styles.inputPanel}>\n {editor}\n {attachmentArea}\n <div className={styles.toolbarRow}>\n <div className={styles.toolbar}>{toolbar}</div>\n {sendButton}\n </div>\n </div>\n\n {footer && (\n <>\n <div className={styles.divider} />\n <div className={styles.metaShare}>{footer}</div>\n </>\n )}\n </div>\n );\n }\n);\n"],"names":["CommentInput","forwardRef","_ref","ref","_ref$placeholder","placeholder","value","onChange","onSubmit","onCancel","disabled","autoFocus","_ref$minRows","minRows","maxRows","field","canSubmit","bare","leading","trailing","_ref$sendTooltip","sendTooltip","attachments","onAttachmentRemove","onAttachmentRetry","onAttachmentReorder","onFilesDrop","onImageLinkPaste","_ref$dropLabel","dropLabel","attachmentSlot","toolbar","footer","embedded","className","testId","_useFileDrop","useFileDrop","undefined","isDragging","dropHandlers","pasteHandlers","useFilePaste","onFiles","onImageLink","dropOverlay","_jsx","jsx","styles","children","isControlled","useState","_useState2","_slicedToArray","_useState","internalValue","setInternalValue","text","rowsCap","textareaRef","useRef","resize","useCallback","el","current","node","style","height","maxHeight","Math","min","scrollHeight","overflowY","useLayoutEffect","canSend","trim","submit","editor","input","rows","event","next","target","onKeyDown","key","preventDefault","shiftKey","sendButton","Tooltip","title","send","ButtonIcon","size","type","onClick","ArrowUpIcon","attachmentArea","length","_jsxs","attachment","AttachmentPreview","items","onRemove","onRetry","onReorder","jsxs","_objectSpread","classNames","rootBare","fieldRow","fieldExpanded","fieldDisabled","fieldMain","bareToolbar","root","rootEmbedded","inputPanel","toolbarRow","_Fragment","divider","metaShare"],"mappings":"+9KAkEA,IAIaA,EAAeC,EAAUA,YACpC,SAAAC,EA+BEC,GACG,IAAAC,EAAAF,EA9BDG,YAAAA,aAAc,gBAAeD,EAC7BE,IAAAA,MACAC,IAAAA,SACAC,IAAAA,SACAC,IAAAA,SACAC,IAAAA,SACAC,IAAAA,UAASC,EAAAV,EACTW,QAAAA,aAAU,EAACD,EACXE,IAAAA,QACAC,IAAAA,MACAC,IAAAA,UACAC,IAAAA,KACAC,IAAAA,QACAC,IAAAA,SAAQC,EAAAlB,EACRmB,YAAAA,aAAc,OAAMD,EACpBE,IAAAA,YACAC,IAAAA,mBACAC,IAAAA,kBACAC,IAAAA,oBACAC,IAAAA,YACAC,IAAAA,iBAAgBC,EAAA1B,EAChB2B,UAAAA,aAAY,kBAAiBD,EAC7BE,IAAAA,eACAC,IAAAA,QACAC,IAAAA,OACAC,IAAAA,SACAC,IAAAA,UACAC,IAAAA,OAIFC,EAAqCC,EAAWA,YAAC3B,OAAW4B,EAAYZ,GAAhEa,IAAAA,WAAYC,IAAAA,aACZC,EAAkBC,EAAAA,aACxBhC,EAAW,GAAK,CAAEiC,QAASjB,EAAakB,YAAajB,IAD/Cc,cAGFI,EAAcN,GAAcO,EAAAC,IAAA,MAAA,CAAKb,UAAWc,EAAOH,YAAYI,SAAEpB,IAEjEqB,OAAyBZ,IAAVhC,EACqB6C,EAAAA,EAAQA,SAAC,IAAGC,EAAAC,EAAAA,QAAAC,EAAA,GAA/CC,GAAaH,EAAA,GAAEI,GAAgBJ,EAAA,GAChCK,GAA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B4B,CAAAA,GACAmB,GACDE,EAAAA,KAAA,MAAA,CAAKhE,UAAWc,EAAOqE,WAAWpE,SAChC,CAAAH,EAAAC,IAAA,MAAA,CAAKb,UAAWc,EAAOjB,QAAQkB,SAAElB,IAChCwD,SAIJvD,GACCkE,EAAAO,KAAAa,WAAA,CAAArE,SACE,CAAAH,EAAAC,IAAA,MAAA,CAAKb,UAAWc,EAAOuE,UACvBzE,EAAAC,IAAA,MAAA,CAAKb,UAAWc,EAAOwE,UAAUvE,SAAEjB,UAK7C"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../utils/links.js"),r=function(e){var t;return Array.from(null!==(t=null==e?void 0:e.items)&&void 0!==t?t:[]).filter((function(e){return"file"===e.kind})).map((function(e){return e.getAsFile()})).filter((function(e){return!!e}))};exports.getPastedFiles=r,exports.useFilePaste=function(n){var i=n.onFiles,l=n.onImageLink,a=e.useCallback((function(e){var n,a,u=r(e.clipboardData);if(u.length)return e.preventDefault(),void(null==i||i(u));var o=t.readPastedLink(null!==(n=null===(a=e.clipboardData)||void 0===a?void 0:a.getData("text/plain"))&&void 0!==n?n:"");o&&t.getIsImageUrl(o)&&(null==l||l(o))}),[i,l]);return{pasteHandlers:e.useMemo((function(){return i||l?{onPaste:a}:void 0}),[i,l,a])}};
2
+ //# sourceMappingURL=useFilePaste.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFilePaste.js","sources":["../../../../src/components/CommentInputNext/useFilePaste.ts"],"sourcesContent":["import { ClipboardEvent, useCallback, useMemo } from 'react';\n\nimport { getIsImageUrl, readPastedLink } from '~/utils/links';\n\ntype PasteHandlers = {\n onPaste: (event: ClipboardEvent) => void;\n};\n\ntype UseFilePasteOptions = {\n onFiles?: (files: File[]) => void;\n /** Given a pasted link that points at an image. The link still lands in the text. */\n onImageLink?: (url: string) => void;\n};\n\n/** A pasted screenshot has no name of its own, so the kind comes off the clipboard item. */\nexport const getPastedFiles = (clipboardData: DataTransfer | null): File[] =>\n Array.from(clipboardData?.items ?? [])\n .filter(item => item.kind === 'file')\n .map(item => item.getAsFile())\n .filter((file): file is File => !!file);\n\n/** Returns no handler when there is nothing to hand a paste to, so it never intercepts one. */\nexport const useFilePaste = ({ onFiles, onImageLink }: UseFilePasteOptions) => {\n const onPaste = useCallback(\n (event: ClipboardEvent) => {\n const files = getPastedFiles(event.clipboardData);\n\n if (files.length) {\n // Text pasted alongside is the source app's markup for the file, not a message.\n event.preventDefault();\n onFiles?.(files);\n\n return;\n }\n\n const url = readPastedLink(event.clipboardData?.getData('text/plain') ?? '');\n\n if (url && getIsImageUrl(url)) onImageLink?.(url);\n },\n [onFiles, onImageLink]\n );\n\n const pasteHandlers: PasteHandlers | undefined = useMemo(\n () => (onFiles || onImageLink ? { onPaste } : undefined),\n [onFiles, onImageLink, onPaste]\n );\n\n return { pasteHandlers };\n};\n"],"names":["getPastedFiles","clipboardData","_clipboardData$items","Array","from","items","filter","item","kind","map","getAsFile","file","_ref","onFiles","onImageLink","onPaste","useCallback","event","_event$clipboardData$","_event$clipboardData","files","length","preventDefault","url","readPastedLink","getData","getIsImageUrl","pasteHandlers","useMemo","undefined"],"mappings":"6HAeaA,EAAiB,SAACC,GAAkC,IAAAC,EAAA,OAC/DC,MAAMC,eAAKH,aAAAA,EAAAA,EAAeI,qBAAS,IAChCC,QAAO,SAAAC,GAAI,MAAkB,SAAdA,EAAKC,IAAe,IACnCC,KAAI,SAAAF,GAAI,OAAIA,EAAKG,WAAW,IAC5BJ,QAAO,SAACK,GAAI,QAAqBA,IAAK,gDAGf,SAAmDC,GAAA,IAAhDC,IAAAA,QAASC,IAAAA,YAChCC,EAAUC,eACd,SAACC,GAA0B,IAAAC,EAAAC,EACnBC,EAAQpB,EAAeiB,EAAMhB,eAEnC,GAAImB,EAAMC,OAKR,OAHAJ,EAAMK,sBACNT,SAAAA,EAAUO,IAKZ,IAAMG,EAAMC,iBAAyD,QAA3CN,EAAC,QAADC,EAACF,EAAMhB,qBAAN,IAAAkB,OAAA,EAAAA,EAAqBM,QAAQ,qBAAa,IAAAP,EAAAA,EAAI,IAErEK,GAAOG,EAAaA,cAACH,KAAMT,SAAAA,EAAcS,GAC/C,GACA,CAACV,EAASC,IAQZ,MAAO,CAAEa,cALwCC,EAAAA,SAC/C,WAAA,OAAOf,GAAWC,EAAc,CAAEC,QAAAA,QAAYc,CAAU,GACxD,CAAChB,EAASC,EAAaC,IAI3B"}