@corva/ui 3.74.0-0 → 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 (412) 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/AssetEditor/AssetEditorAutocomplete.js +1 -1
  6. package/cjs-bundle/components/AssetEditor/AssetEditorAutocomplete.js.map +1 -1
  7. package/cjs-bundle/components/AssetEditorV2/index.js +1 -1
  8. package/cjs-bundle/components/AssetEditorV2/index.js.map +1 -1
  9. package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js +2 -0
  10. package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js.map +1 -0
  11. package/cjs-bundle/components/AttachmentLightbox/AttachmentLightbox.js +1 -1
  12. package/cjs-bundle/components/AttachmentLightbox/AttachmentLightbox.js.map +1 -1
  13. package/cjs-bundle/components/AttachmentLightbox/AttachmentLightbox.scss.js +1 -1
  14. package/cjs-bundle/components/AttachmentLightbox/AttachmentPreviewPane.js +2 -0
  15. package/cjs-bundle/components/AttachmentLightbox/AttachmentPreviewPane.js.map +1 -0
  16. package/cjs-bundle/components/AttachmentLightbox/copyImageToClipboard.js +2 -0
  17. package/cjs-bundle/components/AttachmentLightbox/copyImageToClipboard.js.map +1 -0
  18. package/cjs-bundle/components/AttachmentLightbox/downloadAttachment.js +2 -0
  19. package/cjs-bundle/components/AttachmentLightbox/downloadAttachment.js.map +1 -0
  20. package/cjs-bundle/components/AttachmentLightbox/useAttachmentLightbox.js +1 -1
  21. package/cjs-bundle/components/AttachmentLightbox/useAttachmentLightbox.js.map +1 -1
  22. package/cjs-bundle/components/AttachmentLightbox/useZoomPan.js +2 -0
  23. package/cjs-bundle/components/AttachmentLightbox/useZoomPan.js.map +1 -0
  24. package/cjs-bundle/components/AttachmentPreview/AttachmentActionsMenu.js +2 -0
  25. package/cjs-bundle/components/AttachmentPreview/AttachmentActionsMenu.js.map +1 -0
  26. package/cjs-bundle/components/AttachmentPreview/AttachmentDownloadLink.js +2 -0
  27. package/cjs-bundle/components/AttachmentPreview/AttachmentDownloadLink.js.map +1 -0
  28. package/cjs-bundle/components/AttachmentPreview/AttachmentImage.js +2 -0
  29. package/cjs-bundle/components/AttachmentPreview/AttachmentImage.js.map +1 -0
  30. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.js +1 -1
  31. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.js.map +1 -1
  32. package/cjs-bundle/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
  33. package/cjs-bundle/components/AttachmentPreview/AttachmentRow.js +1 -1
  34. package/cjs-bundle/components/AttachmentPreview/AttachmentRow.js.map +1 -1
  35. package/cjs-bundle/components/AttachmentPreview/AttachmentTile.js +1 -1
  36. package/cjs-bundle/components/AttachmentPreview/AttachmentTile.js.map +1 -1
  37. package/cjs-bundle/components/AttachmentPreview/useStoredAttachment.js +2 -0
  38. package/cjs-bundle/components/AttachmentPreview/useStoredAttachment.js.map +1 -0
  39. package/cjs-bundle/components/AttachmentPreview/useStoredAttachments.js +1 -1
  40. package/cjs-bundle/components/AttachmentPreview/useStoredAttachments.js.map +1 -1
  41. package/cjs-bundle/components/BICOffsetPickerDialog/index.js +1 -1
  42. package/cjs-bundle/components/BICOffsetPickerDialog/index.js.map +1 -1
  43. package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
  44. package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
  45. package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js +1 -1
  46. package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js.map +1 -1
  47. package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
  48. package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
  49. package/cjs-bundle/components/CommentCard/CommentCard.js +1 -1
  50. package/cjs-bundle/components/CommentCard/CommentCard.js.map +1 -1
  51. package/cjs-bundle/components/CommentCard/CommentMenu.js +1 -1
  52. package/cjs-bundle/components/CommentCard/CommentMenu.js.map +1 -1
  53. package/cjs-bundle/components/CommentComposer/CommentComposer.js +1 -1
  54. package/cjs-bundle/components/CommentComposer/CommentComposer.js.map +1 -1
  55. package/cjs-bundle/components/CommentComposer/CommentReplyInput.js +1 -1
  56. package/cjs-bundle/components/CommentComposer/CommentReplyInput.js.map +1 -1
  57. package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js +1 -1
  58. package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js.map +1 -1
  59. package/cjs-bundle/components/CommentInputNext/CommentInputNext.js +1 -1
  60. package/cjs-bundle/components/CommentInputNext/CommentInputNext.js.map +1 -1
  61. package/cjs-bundle/components/CommentInputNext/useFilePaste.js +2 -0
  62. package/cjs-bundle/components/CommentInputNext/useFilePaste.js.map +1 -0
  63. package/cjs-bundle/components/DevCenter/AppsDataProvider/AppsDataProvider.js +1 -1
  64. package/cjs-bundle/components/DevCenter/AppsDataProvider/AppsDataProvider.js.map +1 -1
  65. package/cjs-bundle/components/DocumentViewer/DocumentViewer.js +1 -1
  66. package/cjs-bundle/components/DocumentViewer/DocumentViewer.js.map +1 -1
  67. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
  68. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
  69. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
  70. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
  71. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
  72. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
  73. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
  74. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
  75. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
  76. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
  77. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
  78. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
  79. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
  80. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
  81. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
  82. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
  83. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
  84. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
  85. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
  86. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
  87. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
  88. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
  89. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
  90. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
  91. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
  92. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
  93. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
  94. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
  95. package/cjs-bundle/components/IconMenu/index.js +1 -1
  96. package/cjs-bundle/components/IconMenu/index.js.map +1 -1
  97. package/cjs-bundle/components/KeyboardDateTimePicker.js +1 -1
  98. package/cjs-bundle/components/KeyboardDateTimePicker.js.map +1 -1
  99. package/cjs-bundle/components/LinkedText/LinkedText.js +2 -0
  100. package/cjs-bundle/components/LinkedText/LinkedText.js.map +1 -0
  101. package/cjs-bundle/components/LinkedText/LinkedText.scss.js +2 -0
  102. package/cjs-bundle/components/LinkedText/LinkedText.scss.js.map +1 -0
  103. package/cjs-bundle/components/NewDocumentViewer/utils.js +1 -1
  104. package/cjs-bundle/components/NewDocumentViewer/utils.js.map +1 -1
  105. package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
  106. package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
  107. package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
  108. package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
  109. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
  110. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
  111. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
  112. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
  113. package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
  114. package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
  115. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
  116. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
  117. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
  118. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
  119. package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
  120. package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
  121. package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
  122. package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
  123. package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
  124. package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
  125. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
  126. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
  127. package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js +1 -1
  128. package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
  129. package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
  130. package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
  131. package/cjs-bundle/components/PostInput/PostInput.js +1 -1
  132. package/cjs-bundle/components/PostInput/PostInput.js.map +1 -1
  133. package/cjs-bundle/components/UserMention/constants.js +1 -1
  134. package/cjs-bundle/components/UserMention/constants.js.map +1 -1
  135. package/cjs-bundle/components/UserMention/index.js +1 -1
  136. package/cjs-bundle/components/UserMention/index.js.map +1 -1
  137. package/cjs-bundle/components/index.js +1 -1
  138. package/cjs-bundle/componentsV2/ButtonIcon/ButtonIcon.js +1 -1
  139. package/cjs-bundle/componentsV2/ButtonIcon/ButtonIcon.js.map +1 -1
  140. package/cjs-bundle/componentsV2/ButtonIcon/ButtonIcon.scss.js +1 -1
  141. package/cjs-bundle/componentsV2/Modal/Modal.js +1 -1
  142. package/cjs-bundle/componentsV2/Modal/Modal.js.map +1 -1
  143. package/cjs-bundle/componentsV2/Modal/constants.js +2 -0
  144. package/cjs-bundle/componentsV2/Modal/constants.js.map +1 -0
  145. package/cjs-bundle/effects/useOutsideClick.js +1 -1
  146. package/cjs-bundle/effects/useOutsideClick.js.map +1 -1
  147. package/cjs-bundle/utils/fetchAttachment.js +2 -0
  148. package/cjs-bundle/utils/fetchAttachment.js.map +1 -0
  149. package/cjs-bundle/utils/links.js +2 -0
  150. package/cjs-bundle/utils/links.js.map +1 -0
  151. package/components/AddComment/Popover.js +1 -1
  152. package/components/AddComment/Popover.js.map +1 -1
  153. package/components/AddComment/components/Content.js +1 -1
  154. package/components/AddComment/components/Content.js.map +1 -1
  155. package/components/AssetEditor/AssetEditorAutocomplete.d.ts +96 -13
  156. package/components/AssetEditor/AssetEditorAutocomplete.d.ts.map +1 -1
  157. package/components/AssetEditor/AssetEditorAutocomplete.js +1 -1
  158. package/components/AssetEditor/AssetEditorAutocomplete.js.map +1 -1
  159. package/components/AssetEditorV2/index.d.ts +28 -12
  160. package/components/AssetEditorV2/index.d.ts.map +1 -1
  161. package/components/AssetEditorV2/index.js +1 -1
  162. package/components/AssetEditorV2/index.js.map +1 -1
  163. package/components/AttachmentLightbox/AttachmentDocument.d.ts +6 -0
  164. package/components/AttachmentLightbox/AttachmentDocument.d.ts.map +1 -0
  165. package/components/AttachmentLightbox/AttachmentDocument.js +2 -0
  166. package/components/AttachmentLightbox/AttachmentDocument.js.map +1 -0
  167. package/components/AttachmentLightbox/AttachmentLightbox.d.ts +9 -8
  168. package/components/AttachmentLightbox/AttachmentLightbox.d.ts.map +1 -1
  169. package/components/AttachmentLightbox/AttachmentLightbox.js +1 -1
  170. package/components/AttachmentLightbox/AttachmentLightbox.js.map +1 -1
  171. package/components/AttachmentLightbox/AttachmentLightbox.scss.js +1 -1
  172. package/components/AttachmentLightbox/AttachmentPreviewPane.d.ts +9 -0
  173. package/components/AttachmentLightbox/AttachmentPreviewPane.d.ts.map +1 -0
  174. package/components/AttachmentLightbox/AttachmentPreviewPane.js +2 -0
  175. package/components/AttachmentLightbox/AttachmentPreviewPane.js.map +1 -0
  176. package/components/AttachmentLightbox/__tests__/AttachmentDocument.test.d.ts +2 -0
  177. package/components/AttachmentLightbox/__tests__/AttachmentDocument.test.d.ts.map +1 -0
  178. package/components/AttachmentLightbox/__tests__/AttachmentLightbox.test.d.ts +2 -0
  179. package/components/AttachmentLightbox/__tests__/AttachmentLightbox.test.d.ts.map +1 -0
  180. package/components/AttachmentLightbox/__tests__/copyImageToClipboard.test.d.ts +2 -0
  181. package/components/AttachmentLightbox/__tests__/copyImageToClipboard.test.d.ts.map +1 -0
  182. package/components/AttachmentLightbox/__tests__/downloadAttachment.test.d.ts +2 -0
  183. package/components/AttachmentLightbox/__tests__/downloadAttachment.test.d.ts.map +1 -0
  184. package/components/AttachmentLightbox/__tests__/useZoomPan.test.d.ts +2 -0
  185. package/components/AttachmentLightbox/__tests__/useZoomPan.test.d.ts.map +1 -0
  186. package/components/AttachmentLightbox/copyImageToClipboard.d.ts +4 -0
  187. package/components/AttachmentLightbox/copyImageToClipboard.d.ts.map +1 -0
  188. package/components/AttachmentLightbox/copyImageToClipboard.js +2 -0
  189. package/components/AttachmentLightbox/copyImageToClipboard.js.map +1 -0
  190. package/components/AttachmentLightbox/downloadAttachment.d.ts +10 -0
  191. package/components/AttachmentLightbox/downloadAttachment.d.ts.map +1 -0
  192. package/components/AttachmentLightbox/downloadAttachment.js +2 -0
  193. package/components/AttachmentLightbox/downloadAttachment.js.map +1 -0
  194. package/components/AttachmentLightbox/useAttachmentLightbox.d.ts +6 -2
  195. package/components/AttachmentLightbox/useAttachmentLightbox.d.ts.map +1 -1
  196. package/components/AttachmentLightbox/useAttachmentLightbox.js +1 -1
  197. package/components/AttachmentLightbox/useAttachmentLightbox.js.map +1 -1
  198. package/components/AttachmentLightbox/useZoomPan.d.ts +29 -0
  199. package/components/AttachmentLightbox/useZoomPan.d.ts.map +1 -0
  200. package/components/AttachmentLightbox/useZoomPan.js +2 -0
  201. package/components/AttachmentLightbox/useZoomPan.js.map +1 -0
  202. package/components/AttachmentPreview/AttachmentActionsMenu.d.ts +16 -0
  203. package/components/AttachmentPreview/AttachmentActionsMenu.d.ts.map +1 -0
  204. package/components/AttachmentPreview/AttachmentActionsMenu.js +2 -0
  205. package/components/AttachmentPreview/AttachmentActionsMenu.js.map +1 -0
  206. package/components/AttachmentPreview/AttachmentDownloadLink.d.ts +11 -0
  207. package/components/AttachmentPreview/AttachmentDownloadLink.d.ts.map +1 -0
  208. package/components/AttachmentPreview/AttachmentDownloadLink.js +2 -0
  209. package/components/AttachmentPreview/AttachmentDownloadLink.js.map +1 -0
  210. package/components/AttachmentPreview/AttachmentImage.d.ts +12 -0
  211. package/components/AttachmentPreview/AttachmentImage.d.ts.map +1 -0
  212. package/components/AttachmentPreview/AttachmentImage.js +2 -0
  213. package/components/AttachmentPreview/AttachmentImage.js.map +1 -0
  214. package/components/AttachmentPreview/AttachmentPreview.d.ts.map +1 -1
  215. package/components/AttachmentPreview/AttachmentPreview.js +1 -1
  216. package/components/AttachmentPreview/AttachmentPreview.js.map +1 -1
  217. package/components/AttachmentPreview/AttachmentPreview.scss.js +1 -1
  218. package/components/AttachmentPreview/AttachmentPreview.types.d.ts +7 -0
  219. package/components/AttachmentPreview/AttachmentPreview.types.d.ts.map +1 -1
  220. package/components/AttachmentPreview/AttachmentRow.d.ts +7 -3
  221. package/components/AttachmentPreview/AttachmentRow.d.ts.map +1 -1
  222. package/components/AttachmentPreview/AttachmentRow.js +1 -1
  223. package/components/AttachmentPreview/AttachmentRow.js.map +1 -1
  224. package/components/AttachmentPreview/AttachmentTile.d.ts +5 -1
  225. package/components/AttachmentPreview/AttachmentTile.d.ts.map +1 -1
  226. package/components/AttachmentPreview/AttachmentTile.js +1 -1
  227. package/components/AttachmentPreview/AttachmentTile.js.map +1 -1
  228. package/components/AttachmentPreview/__tests__/AttachmentActionsMenu.test.d.ts +2 -0
  229. package/components/AttachmentPreview/__tests__/AttachmentActionsMenu.test.d.ts.map +1 -0
  230. package/components/AttachmentPreview/__tests__/AttachmentDownloadLink.test.d.ts +2 -0
  231. package/components/AttachmentPreview/__tests__/AttachmentDownloadLink.test.d.ts.map +1 -0
  232. package/components/AttachmentPreview/__tests__/AttachmentImage.test.d.ts +2 -0
  233. package/components/AttachmentPreview/__tests__/AttachmentImage.test.d.ts.map +1 -0
  234. package/components/AttachmentPreview/__tests__/AttachmentTile.test.d.ts +2 -0
  235. package/components/AttachmentPreview/__tests__/AttachmentTile.test.d.ts.map +1 -0
  236. package/components/AttachmentPreview/__tests__/useStoredAttachments.test.d.ts +2 -0
  237. package/components/AttachmentPreview/__tests__/useStoredAttachments.test.d.ts.map +1 -0
  238. package/components/AttachmentPreview/useStoredAttachment.d.ts +8 -0
  239. package/components/AttachmentPreview/useStoredAttachment.d.ts.map +1 -1
  240. package/components/AttachmentPreview/useStoredAttachment.js +2 -0
  241. package/components/AttachmentPreview/useStoredAttachment.js.map +1 -0
  242. package/components/AttachmentPreview/useStoredAttachments.d.ts +1 -1
  243. package/components/AttachmentPreview/useStoredAttachments.d.ts.map +1 -1
  244. package/components/AttachmentPreview/useStoredAttachments.js +1 -1
  245. package/components/AttachmentPreview/useStoredAttachments.js.map +1 -1
  246. package/components/BICOffsetPickerDialog/index.js +1 -1
  247. package/components/BICOffsetPickerDialog/index.js.map +1 -1
  248. package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
  249. package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
  250. package/components/Casing/CasingTableV2/components/Component.js +1 -1
  251. package/components/Casing/CasingTableV2/components/Component.js.map +1 -1
  252. package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
  253. package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
  254. package/components/CommentCard/CommentCard.d.ts.map +1 -1
  255. package/components/CommentCard/CommentCard.js +1 -1
  256. package/components/CommentCard/CommentCard.js.map +1 -1
  257. package/components/CommentCard/CommentCard.types.d.ts +2 -0
  258. package/components/CommentCard/CommentCard.types.d.ts.map +1 -1
  259. package/components/CommentCard/CommentMenu.d.ts.map +1 -1
  260. package/components/CommentCard/CommentMenu.js +1 -1
  261. package/components/CommentCard/CommentMenu.js.map +1 -1
  262. package/components/CommentComposer/CommentComposer.d.ts.map +1 -1
  263. package/components/CommentComposer/CommentComposer.js +1 -1
  264. package/components/CommentComposer/CommentComposer.js.map +1 -1
  265. package/components/CommentComposer/CommentReplyInput.d.ts.map +1 -1
  266. package/components/CommentComposer/CommentReplyInput.js +1 -1
  267. package/components/CommentComposer/CommentReplyInput.js.map +1 -1
  268. package/components/CommentComposer/__tests__/useAttachmentUpload.linked.test.d.ts +2 -0
  269. package/components/CommentComposer/__tests__/useAttachmentUpload.linked.test.d.ts.map +1 -0
  270. package/components/CommentComposer/useAttachmentUpload.d.ts +1 -0
  271. package/components/CommentComposer/useAttachmentUpload.d.ts.map +1 -1
  272. package/components/CommentComposer/useAttachmentUpload.js +1 -1
  273. package/components/CommentComposer/useAttachmentUpload.js.map +1 -1
  274. package/components/CommentInputNext/CommentInputNext.d.ts +2 -0
  275. package/components/CommentInputNext/CommentInputNext.d.ts.map +1 -1
  276. package/components/CommentInputNext/CommentInputNext.js +1 -1
  277. package/components/CommentInputNext/CommentInputNext.js.map +1 -1
  278. package/components/CommentInputNext/__tests__/useFilePaste.test.d.ts +2 -0
  279. package/components/CommentInputNext/__tests__/useFilePaste.test.d.ts.map +1 -0
  280. package/components/CommentInputNext/useFilePaste.d.ts +17 -0
  281. package/components/CommentInputNext/useFilePaste.d.ts.map +1 -0
  282. package/components/CommentInputNext/useFilePaste.js +2 -0
  283. package/components/CommentInputNext/useFilePaste.js.map +1 -0
  284. package/components/DevCenter/AppsDataProvider/AppsDataProvider.d.ts +5 -1
  285. package/components/DevCenter/AppsDataProvider/AppsDataProvider.d.ts.map +1 -1
  286. package/components/DevCenter/AppsDataProvider/AppsDataProvider.js +1 -1
  287. package/components/DevCenter/AppsDataProvider/AppsDataProvider.js.map +1 -1
  288. package/components/DocumentViewer/DocumentViewer.js +1 -1
  289. package/components/DocumentViewer/DocumentViewer.js.map +1 -1
  290. package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
  291. package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
  292. package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
  293. package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
  294. package/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
  295. package/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
  296. package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
  297. package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
  298. package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
  299. package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
  300. package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
  301. package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
  302. package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
  303. package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
  304. package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
  305. package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
  306. package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
  307. package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
  308. package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
  309. package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
  310. package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
  311. package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
  312. package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
  313. package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
  314. package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
  315. package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
  316. package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
  317. package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
  318. package/components/IconMenu/index.d.ts +67 -21
  319. package/components/IconMenu/index.d.ts.map +1 -1
  320. package/components/IconMenu/index.js +1 -1
  321. package/components/IconMenu/index.js.map +1 -1
  322. package/components/KeyboardDateTimePicker.d.ts +6 -7
  323. package/components/KeyboardDateTimePicker.d.ts.map +1 -1
  324. package/components/KeyboardDateTimePicker.js +1 -1
  325. package/components/KeyboardDateTimePicker.js.map +1 -1
  326. package/components/LinkedText/LinkedText.d.ts +17 -0
  327. package/components/LinkedText/LinkedText.d.ts.map +1 -0
  328. package/components/LinkedText/LinkedText.js +2 -0
  329. package/components/LinkedText/LinkedText.js.map +1 -0
  330. package/components/LinkedText/LinkedText.scss.js +2 -0
  331. package/components/LinkedText/LinkedText.scss.js.map +1 -0
  332. package/components/LinkedText/__tests__/LinkedText.test.d.ts +2 -0
  333. package/components/LinkedText/__tests__/LinkedText.test.d.ts.map +1 -0
  334. package/components/LinkedText/index.d.ts +2 -0
  335. package/components/LinkedText/index.d.ts.map +1 -0
  336. package/components/NewDocumentViewer/utils.d.ts.map +1 -1
  337. package/components/NewDocumentViewer/utils.js +1 -1
  338. package/components/NewDocumentViewer/utils.js.map +1 -1
  339. package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
  340. package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
  341. package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
  342. package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
  343. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
  344. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
  345. package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
  346. package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
  347. package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
  348. package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
  349. package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
  350. package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
  351. package/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
  352. package/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
  353. package/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
  354. package/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
  355. package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
  356. package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
  357. package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
  358. package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
  359. package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
  360. package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
  361. package/components/PadOffsetsPicker/StagesSelector.js +1 -1
  362. package/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
  363. package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
  364. package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
  365. package/components/PostInput/PostInput.d.ts +20 -10
  366. package/components/PostInput/PostInput.d.ts.map +1 -1
  367. package/components/PostInput/PostInput.js +1 -1
  368. package/components/PostInput/PostInput.js.map +1 -1
  369. package/components/UserMention/__tests__/highlightLinks.test.d.ts +2 -0
  370. package/components/UserMention/__tests__/highlightLinks.test.d.ts.map +1 -0
  371. package/components/UserMention/constants.d.ts +1 -0
  372. package/components/UserMention/constants.d.ts.map +1 -1
  373. package/components/UserMention/constants.js +1 -1
  374. package/components/UserMention/constants.js.map +1 -1
  375. package/components/UserMention/index.js +1 -1
  376. package/components/UserMention/index.js.map +1 -1
  377. package/components/index.d.ts +2 -0
  378. package/components/index.d.ts.map +1 -1
  379. package/components/index.js +1 -1
  380. package/componentsV2/ButtonIcon/ButtonIcon.d.ts +2 -0
  381. package/componentsV2/ButtonIcon/ButtonIcon.d.ts.map +1 -1
  382. package/componentsV2/ButtonIcon/ButtonIcon.js +1 -1
  383. package/componentsV2/ButtonIcon/ButtonIcon.js.map +1 -1
  384. package/componentsV2/ButtonIcon/ButtonIcon.scss.js +1 -1
  385. package/componentsV2/ButtonIcon/ButtonIcon.stories.d.ts +1 -0
  386. package/componentsV2/ButtonIcon/ButtonIcon.stories.d.ts.map +1 -1
  387. package/componentsV2/Modal/Modal.d.ts.map +1 -1
  388. package/componentsV2/Modal/Modal.js +1 -1
  389. package/componentsV2/Modal/Modal.js.map +1 -1
  390. package/componentsV2/Modal/constants.d.ts +3 -0
  391. package/componentsV2/Modal/constants.d.ts.map +1 -0
  392. package/componentsV2/Modal/constants.js +2 -0
  393. package/componentsV2/Modal/constants.js.map +1 -0
  394. package/effects/__tests__/useOutsideClick.test.d.ts.map +1 -1
  395. package/effects/useOutsideClick.d.ts.map +1 -1
  396. package/effects/useOutsideClick.js +1 -1
  397. package/effects/useOutsideClick.js.map +1 -1
  398. package/mcp-server/server.mjs +35 -9
  399. package/package.json +1 -1
  400. package/tsconfig.tsbuildinfo +1 -1
  401. package/utils/__tests__/fetchAttachment.test.d.ts +2 -0
  402. package/utils/__tests__/fetchAttachment.test.d.ts.map +1 -0
  403. package/utils/__tests__/links.test.d.ts +2 -0
  404. package/utils/__tests__/links.test.d.ts.map +1 -0
  405. package/utils/fetchAttachment.d.ts +3 -0
  406. package/utils/fetchAttachment.d.ts.map +1 -0
  407. package/utils/fetchAttachment.js +2 -0
  408. package/utils/fetchAttachment.js.map +1 -0
  409. package/utils/links.d.ts +14 -0
  410. package/utils/links.d.ts.map +1 -0
  411. package/utils/links.js +2 -0
  412. package/utils/links.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"AssetEditorAutocomplete.js","sources":["../../../../src/components/AssetEditor/AssetEditorAutocomplete.js"],"sourcesContent":["import { useMemo, useState, useEffect, forwardRef } from 'react';\nimport PropTypes from 'prop-types';\nimport { debounce, identity } from 'lodash';\nimport {\n FormControl,\n InputLabel,\n TextField,\n FormHelperText,\n withStyles,\n Typography,\n List,\n InputAdornment,\n Chip,\n Tooltip,\n} from '@material-ui/core';\nimport { Search as SearchIcon } from '@material-ui/icons';\nimport { Autocomplete } from '@material-ui/lab';\n\nimport TruncatedText from '../TruncatedText';\n\nimport { PER_PAGE, SCROLL_THRESHOLD } from './constants';\nimport { useAssetAutoCompleteSelectData } from './effects';\n\nconst PAGE_NAME = 'DC_SingleAssetEditorAutocomplete';\n\nconst muiStyles = theme => ({\n formControl: {},\n listbox: { maxHeight: 350 },\n root: { fontSize: 16 },\n inputRoot: {\n paddingTop: 16,\n padding: '8px 0',\n paddingBottom: 0,\n width: 350,\n fontSize: 16,\n },\n popupIndicator: { display: 'none' },\n option: {\n paddingLeft: '16px !important',\n height: 36,\n '&[aria-disabled=true]': {\n color: theme.palette.primary.text9,\n opacity: 1,\n backgroundColor: 'unset',\n },\n },\n noOptions: { padding: 0 },\n searchIcon: { fontSize: '20px !important' },\n});\n\nconst infoListItemStyles = {\n paddingLeft: '16px',\n height: 36,\n listStyleType: 'none',\n display: 'flex',\n alignItems: 'center',\n};\n\n/* eslint-disable react/prop-types */\nconst InfoListItem = ({ text = 'Loading...' }) => (\n <li key=\"loading\" style={infoListItemStyles}>\n <Typography variant=\"body2\" color=\"textSecondary\">\n {text}\n </Typography>\n </li>\n);\n\nconst ListboxComponent = forwardRef(({ children, loading, hasMore, ...otherProps }, ref) => (\n <List {...otherProps} ref={ref} role=\"listbox\">\n {children}\n {(hasMore || loading) && <InfoListItem />}\n </List>\n));\n/* eslint-enable react/prop-types */\n\nconst AssetEditorAutocomplete = ({\n 'data-testid': dataTestId = DEFAULT_ASSET_EDITOR_AUTOCOMPLETE_DATA_TESTID,\n appKey = null,\n assetType,\n classes,\n companyId,\n currentValue,\n disabled = false,\n disableClearable = true,\n errorText = '',\n isMultiple = false,\n isNullable = false,\n label = 'Choose An Asset',\n onChange,\n parentAssetId,\n parentAssetType,\n queryParams = DEFAULT_ASSET_EDITOR_AUTOCOMPLETE_QUERY_PARAMS,\n autocompleteProps = {},\n assetFields,\n}) => {\n // NOTE: Store currently selected option\n const [currentOption, setCurrentOption] = useState(isMultiple ? [] : null);\n\n const [searchText, setSearchText] = useState(''); // NOTE: For ui input\n const [searchValue, setSearchValue] = useState(''); // NOTE: Used for api filtering\n const [isSearchMode, setSearchMode] = useState(false);\n\n const [scrollPage, setScrollPage] = useState(1);\n const [hasMore, setHasMore] = useState(true);\n\n useEffect(() => {\n // NOTE: Asset type has been changed. Clear currently selected option\n setCurrentOption(isMultiple ? [] : null);\n setScrollPage(1);\n setSearchMode(false);\n }, [assetType]);\n\n const { assets, loading } = useAssetAutoCompleteSelectData({\n appKey,\n assetType,\n companyId,\n currentValue,\n isMultiple,\n parentAssetId,\n parentAssetType,\n scrollPage,\n searchText,\n setCurrentOption,\n queryParams,\n assetFields,\n });\n\n useEffect(() => {\n const hasMoreAssets = assets.length >= PER_PAGE * scrollPage;\n setHasMore(hasMoreAssets);\n }, [assets, scrollPage]);\n\n const onInputChange = useMemo(\n () =>\n debounce(value => {\n setScrollPage(1);\n setSearchText(value);\n }, 200),\n []\n );\n\n const handleInputChange = (event, value, reason) => {\n if (reason === 'input') {\n setSearchValue(value);\n setSearchMode(true);\n onInputChange(value); // NOTE: Trigger api call\n } else {\n // NOTE: Clean searchText for \"reset\" and \"clear\" reasons\n setSearchText('');\n }\n };\n\n const handleFetchNext = useMemo(\n () => debounce(() => setScrollPage(prevScrollPage => prevScrollPage + 1), 250),\n []\n );\n const onClose = () => {\n setSearchValue('');\n setSearchText('');\n setSearchMode(false);\n setScrollPage(1);\n };\n\n const onScrollListbox = event => {\n if (!hasMore || loading) return;\n const listboxNode = event.currentTarget;\n if (\n listboxNode.scrollTop + listboxNode.clientHeight >\n listboxNode.scrollHeight - SCROLL_THRESHOLD\n ) {\n handleFetchNext();\n }\n };\n\n const renderInput = params => (\n <TextField\n {...params}\n variant=\"standard\"\n placeholder=\"Search for asset...\"\n {...(!isMultiple && {\n InputProps: {\n ...params.InputProps,\n startAdornment: (\n <InputAdornment>\n <SearchIcon className={classes.searchIcon} />\n </InputAdornment>\n ),\n },\n })}\n />\n );\n\n const renderOption = ({ id, name }) => (\n <TruncatedText key={id} data-testid={`${PAGE_NAME}_option_${name}MenuItem`}>\n {isMultiple && currentValue.includes(id) ? `${name} (already selected)` : name}\n </TruncatedText>\n );\n\n const autocompleteClasses = {\n endAdornment: classes.endAdornment,\n inputRoot: classes.inputRoot,\n listbox: classes.listbox,\n noOptions: classes.noOptions,\n option: classes.option,\n popupIndicator: classes.popupIndicator,\n root: classes.root,\n };\n\n return (\n <FormControl disabled={disabled} error={!!errorText} className={classes.formControl}>\n {!isNullable && <InputLabel shrink>{label}</InputLabel>}\n <Tooltip title={currentOption?.name ?? ''}>\n <Autocomplete\n disabled={disabled}\n blurOnSelect\n classes={autocompleteClasses}\n clearOnBlur\n clearOnEscape\n data-testid={dataTestId}\n disableClearable={disableClearable}\n filterOptions={identity}\n getOptionLabel={option => option?.name}\n getOptionSelected={(option, value) => option && value && option.id === value.id}\n inputValue={isSearchMode ? searchValue : currentOption?.name || ''}\n ListboxComponent={ListboxComponent}\n ListboxProps={{ onScroll: onScrollListbox, loading, hasMore }}\n options={assets}\n onChange={(event, selected) => {\n setCurrentOption(selected);\n onChange(isMultiple ? selected.map(({ id }) => id) : selected?.id ?? null, selected);\n }}\n onClose={onClose}\n onInputChange={handleInputChange}\n noOptionsText={<InfoListItem text={loading ? 'Loading...' : 'No options'} />}\n renderInput={renderInput}\n renderOption={renderOption}\n value={currentOption}\n multiple={isMultiple}\n {...(isMultiple && {\n renderTags: (value, getTagProps) => {\n return value.map((option, index) => (\n <Chip key={option.id} label={option?.name} {...getTagProps({ index })} />\n ));\n },\n getOptionDisabled: option => currentValue.includes(option.id),\n })}\n {...autocompleteProps}\n />\n </Tooltip>\n <FormHelperText>{errorText}</FormHelperText>\n </FormControl>\n );\n};\n\nconst DEFAULT_ASSET_EDITOR_AUTOCOMPLETE_DATA_TESTID = `${PAGE_NAME}_autoComplete`;\nconst DEFAULT_ASSET_EDITOR_AUTOCOMPLETE_QUERY_PARAMS = {};\n\nAssetEditorAutocomplete.propTypes = {\n label: PropTypes.string,\n currentValue: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)]),\n isNullable: PropTypes.bool,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.shape({}).isRequired,\n disableClearable: PropTypes.bool,\n parentAssetId: PropTypes.number,\n parentAssetType: PropTypes.string,\n companyId: PropTypes.number,\n assetType: PropTypes.string.isRequired,\n errorText: PropTypes.string,\n 'data-testid': PropTypes.string,\n disabled: PropTypes.bool,\n isMultiple: PropTypes.bool,\n appKey: PropTypes.string,\n queryParams: PropTypes.shape({}),\n};\n\nexport default withStyles(muiStyles)(AssetEditorAutocomplete);\n"],"names":["PAGE_NAME","infoListItemStyles","paddingLeft","height","listStyleType","display","alignItems","InfoListItem","_ref","_ref$text","text","_jsx","style","children","Typography","variant","color","ListboxComponent","forwardRef","ref","loading","hasMore","otherProps","_objectWithoutProperties","_ref2","_excluded","_jsxs","List","_objectSpread","role","AssetEditorAutocomplete","_ref3","_currentOption$name","_ref3$dataTestid","dataTestId","DEFAULT_ASSET_EDITOR_AUTOCOMPLETE_DATA_TESTID","_ref3$appKey","appKey","assetType","classes","companyId","currentValue","_ref3$disabled","disabled","_ref3$disableClearabl","disableClearable","_ref3$errorText","errorText","_ref3$isMultiple","isMultiple","_ref3$isNullable","isNullable","_ref3$label","label","onChange","parentAssetId","parentAssetType","_ref3$queryParams","queryParams","DEFAULT_ASSET_EDITOR_AUTOCOMPLETE_QUERY_PARAMS","_ref3$autocompletePro","autocompleteProps","assetFields","_useState","useState","_useState2","_slicedToArray","currentOption","setCurrentOption","_useState4","_useState3","searchText","setSearchText","_useState6","_useState5","searchValue","setSearchValue","_useState8","_useState7","isSearchMode","setSearchMode","_useState10","_useState9","scrollPage","setScrollPage","_useState12","_useState11","setHasMore","useEffect","_useAssetAutoComplete","useAssetAutoCompleteSelectData","assets","hasMoreAssets","length","PER_PAGE","onInputChange","useMemo","debounce","value","handleFetchNext","prevScrollPage","autocompleteClasses","endAdornment","inputRoot","listbox","noOptions","option","popupIndicator","root","FormControl","error","className","formControl","InputLabel","shrink","Tooltip","title","name","Autocomplete","blurOnSelect","clearOnBlur","clearOnEscape","filterOptions","identity","getOptionLabel","getOptionSelected","id","inputValue","ListboxProps","onScroll","event","listboxNode","currentTarget","scrollTop","clientHeight","scrollHeight","SCROLL_THRESHOLD","options","selected","_selected$id","map","_ref5","onClose","reason","noOptionsText","renderInput","params","TextField","placeholder","InputProps","startAdornment","InputAdornment","SearchIcon","searchIcon","renderOption","_ref4","TruncatedText","includes","multiple","renderTags","getTagProps","index","Chip","getOptionDisabled","FormHelperText","propTypes","PropTypes","string","oneOfType","number","arrayOf","bool","func","isRequired","shape","AssetEditorAutocomplete$1","withStyles","theme","maxHeight","fontSize","paddingTop","padding","paddingBottom","width","palette","primary","text9","opacity","backgroundColor"],"m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EkC,MAGvB,EAEMZ,EAAmDnC,GAAAA,OAAAA,EAAwB,iBAC3E2D,EAAiD,CAAA,EAEvD7B,EAAwBuI,UAAY,CAClChH,MAAOiH,EAAS,QAACC,OACjB9H,aAAc6H,EAAS,QAACE,UAAU,CAACF,UAAUG,OAAQH,EAAS,QAACI,QAAQJ,EAAAA,QAAUG,UACjFtH,WAAYmH,EAAS,QAACK,KACtBrH,SAAUgH,EAAAA,QAAUM,KAAKC,WACzBtI,QAAS+H,EAAS,QAACQ,MAAM,CAAA,GAAID,WAC7BhI,iBAAkByH,EAAS,QAACK,KAC5BpH,cAAe+G,EAAS,QAACG,OACzBjH,gBAAiB8G,EAAS,QAACC,OAC3B/H,UAAW8H,EAAS,QAACG,OACrBnI,UAAWgI,EAAAA,QAAUC,OAAOM,WAC5B9H,UAAWuH,EAAS,QAACC,OACrB,cAAeD,EAAS,QAACC,OACzB5H,SAAU2H,EAAS,QAACK,KACpB1H,WAAYqH,EAAS,QAACK,KACtBtI,OAAQiI,EAAS,QAACC,OAClB7G,YAAa4G,EAAAA,QAAUQ,MAAM,KAG/B,IAAAC,EAAeC,cA3PG,SAAAC,GAAK,MAAK,CAC1BjE,YAAa,CAAE,EACfR,QAAS,CAAE0E,UAAW,KACtBtE,KAAM,CAAEuE,SAAU,IAClB5E,UAAW,CACT6E,WAAY,GACZC,QAAS,QACTC,cAAe,EACfC,MAAO,IACPJ,SAAU,IAEZxE,eAAgB,CAAEtG,QAAS,QAC3BqG,OAAQ,CACNxG,YAAa,kBACbC,OAAQ,GACR,wBAAyB,CACvBa,MAAOiK,EAAMO,QAAQC,QAAQC,MAC7BC,QAAS,EACTC,gBAAiB,UAGrBnF,UAAW,CAAE4E,QAAS,GACtB5B,WAAY,CAAE0B,SAAU,mBACzB,GAoOcH,CAAsBlJ"}
1
+ {"version":3,"file":"AssetEditorAutocomplete.js","sources":["../../../../src/components/AssetEditor/AssetEditorAutocomplete.js"],"sourcesContent":["import { useMemo, useState, useEffect, forwardRef } from 'react';\nimport PropTypes from 'prop-types';\nimport { debounce, identity } from 'lodash';\nimport {\n FormControl,\n InputLabel,\n TextField,\n FormHelperText,\n withStyles,\n Typography,\n List,\n InputAdornment,\n Chip,\n Tooltip,\n} from '@material-ui/core';\nimport { Search as SearchIcon } from '@material-ui/icons';\nimport { Autocomplete } from '@material-ui/lab';\n\nimport TruncatedText from '../TruncatedText';\n\nimport { PER_PAGE, SCROLL_THRESHOLD } from './constants';\nimport { useAssetAutoCompleteSelectData } from './effects';\n\nconst PAGE_NAME = 'DC_SingleAssetEditorAutocomplete';\n\nconst muiStyles = theme => ({\n formControl: {},\n listbox: { maxHeight: 350 },\n root: { fontSize: 16 },\n inputRoot: {\n paddingTop: 16,\n padding: '8px 0',\n paddingBottom: 0,\n width: 350,\n fontSize: 16,\n },\n popupIndicator: { display: 'none' },\n option: {\n paddingLeft: '16px !important',\n height: 36,\n '&[aria-disabled=true]': {\n color: theme.palette.primary.text9,\n opacity: 1,\n backgroundColor: 'unset',\n },\n },\n noOptions: { padding: 0 },\n searchIcon: { fontSize: '20px !important' },\n});\n\nconst infoListItemStyles = {\n paddingLeft: '16px',\n height: 36,\n listStyleType: 'none',\n display: 'flex',\n alignItems: 'center',\n};\n\n/* eslint-disable react/prop-types */\nconst InfoListItem = ({ text = 'Loading...' }) => (\n <li key=\"loading\" style={infoListItemStyles}>\n <Typography variant=\"body2\" color=\"textSecondary\">\n {text}\n </Typography>\n </li>\n);\n\nconst ListboxComponent = forwardRef(({ children, loading, hasMore, ...otherProps }, ref) => (\n <List {...otherProps} ref={ref} role=\"listbox\">\n {children}\n {(hasMore || loading) && <InfoListItem />}\n </List>\n));\n/* eslint-enable react/prop-types */\n\nconst AssetEditorAutocomplete = ({\n 'data-testid': dataTestId,\n appKey,\n assetType,\n classes,\n companyId,\n currentValue,\n disabled,\n disableClearable,\n errorText,\n isMultiple,\n isNullable,\n label,\n onChange,\n parentAssetId,\n parentAssetType,\n queryParams,\n autocompleteProps = {},\n assetFields,\n}) => {\n // NOTE: Store currently selected option\n const [currentOption, setCurrentOption] = useState(isMultiple ? [] : null);\n\n const [searchText, setSearchText] = useState(''); // NOTE: For ui input\n const [searchValue, setSearchValue] = useState(''); // NOTE: Used for api filtering\n const [isSearchMode, setSearchMode] = useState(false);\n\n const [scrollPage, setScrollPage] = useState(1);\n const [hasMore, setHasMore] = useState(true);\n\n useEffect(() => {\n // NOTE: Asset type has been changed. Clear currently selected option\n setCurrentOption(isMultiple ? [] : null);\n setScrollPage(1);\n setSearchMode(false);\n }, [assetType]);\n\n const { assets, loading } = useAssetAutoCompleteSelectData({\n appKey,\n assetType,\n companyId,\n currentValue,\n isMultiple,\n parentAssetId,\n parentAssetType,\n scrollPage,\n searchText,\n setCurrentOption,\n queryParams,\n assetFields,\n });\n\n useEffect(() => {\n const hasMoreAssets = assets.length >= PER_PAGE * scrollPage;\n setHasMore(hasMoreAssets);\n }, [assets, scrollPage]);\n\n const onInputChange = useMemo(\n () =>\n debounce(value => {\n setScrollPage(1);\n setSearchText(value);\n }, 200),\n []\n );\n\n const handleInputChange = (event, value, reason) => {\n if (reason === 'input') {\n setSearchValue(value);\n setSearchMode(true);\n onInputChange(value); // NOTE: Trigger api call\n } else {\n // NOTE: Clean searchText for \"reset\" and \"clear\" reasons\n setSearchText('');\n }\n };\n\n const handleFetchNext = useMemo(\n () => debounce(() => setScrollPage(prevScrollPage => prevScrollPage + 1), 250),\n []\n );\n const onClose = () => {\n setSearchValue('');\n setSearchText('');\n setSearchMode(false);\n setScrollPage(1);\n };\n\n const onScrollListbox = event => {\n if (!hasMore || loading) return;\n const listboxNode = event.currentTarget;\n if (\n listboxNode.scrollTop + listboxNode.clientHeight >\n listboxNode.scrollHeight - SCROLL_THRESHOLD\n ) {\n handleFetchNext();\n }\n };\n\n const renderInput = params => (\n <TextField\n {...params}\n variant=\"standard\"\n placeholder=\"Search for asset...\"\n {...(!isMultiple && {\n InputProps: {\n ...params.InputProps,\n startAdornment: (\n <InputAdornment>\n <SearchIcon className={classes.searchIcon} />\n </InputAdornment>\n ),\n },\n })}\n />\n );\n\n const renderOption = ({ id, name }) => (\n <TruncatedText key={id} data-testid={`${PAGE_NAME}_option_${name}MenuItem`}>\n {isMultiple && currentValue.includes(id) ? `${name} (already selected)` : name}\n </TruncatedText>\n );\n\n const autocompleteClasses = {\n endAdornment: classes.endAdornment,\n inputRoot: classes.inputRoot,\n listbox: classes.listbox,\n noOptions: classes.noOptions,\n option: classes.option,\n popupIndicator: classes.popupIndicator,\n root: classes.root,\n };\n\n return (\n <FormControl disabled={disabled} error={!!errorText} className={classes.formControl}>\n {!isNullable && <InputLabel shrink>{label}</InputLabel>}\n <Tooltip title={currentOption?.name ?? ''}>\n <Autocomplete\n disabled={disabled}\n blurOnSelect\n classes={autocompleteClasses}\n clearOnBlur\n clearOnEscape\n data-testid={dataTestId}\n disableClearable={disableClearable}\n filterOptions={identity}\n getOptionLabel={option => option?.name}\n getOptionSelected={(option, value) => option && value && option.id === value.id}\n inputValue={isSearchMode ? searchValue : currentOption?.name || ''}\n ListboxComponent={ListboxComponent}\n ListboxProps={{ onScroll: onScrollListbox, loading, hasMore }}\n options={assets}\n onChange={(event, selected) => {\n setCurrentOption(selected);\n onChange(isMultiple ? selected.map(({ id }) => id) : selected?.id ?? null, selected);\n }}\n onClose={onClose}\n onInputChange={handleInputChange}\n noOptionsText={<InfoListItem text={loading ? 'Loading...' : 'No options'} />}\n renderInput={renderInput}\n renderOption={renderOption}\n value={currentOption}\n multiple={isMultiple}\n {...(isMultiple && {\n renderTags: (value, getTagProps) => {\n return value.map((option, index) => (\n <Chip key={option.id} label={option?.name} {...getTagProps({ index })} />\n ));\n },\n getOptionDisabled: option => currentValue.includes(option.id),\n })}\n {...autocompleteProps}\n />\n </Tooltip>\n <FormHelperText>{errorText}</FormHelperText>\n </FormControl>\n );\n};\n\nAssetEditorAutocomplete.defaultProps = {\n label: 'Choose An Asset',\n currentValue: undefined,\n disableClearable: true,\n isNullable: false,\n parentAssetId: undefined,\n parentAssetType: undefined,\n companyId: undefined,\n errorText: '',\n 'data-testid': `${PAGE_NAME}_autoComplete`,\n disabled: false,\n isMultiple: false,\n appKey: null,\n queryParams: {},\n};\n\nAssetEditorAutocomplete.propTypes = {\n label: PropTypes.string,\n currentValue: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)]),\n isNullable: PropTypes.bool,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.shape({}).isRequired,\n disableClearable: PropTypes.bool,\n parentAssetId: PropTypes.number,\n parentAssetType: PropTypes.string,\n companyId: PropTypes.number,\n assetType: PropTypes.string.isRequired,\n errorText: PropTypes.string,\n 'data-testid': PropTypes.string,\n disabled: PropTypes.bool,\n isMultiple: PropTypes.bool,\n appKey: PropTypes.string,\n queryParams: PropTypes.shape({}),\n};\n\nexport default withStyles(muiStyles)(AssetEditorAutocomplete);\n"],"names":["PAGE_NAME","infoListItemStyles","paddingLeft","height","listStyleType","display","alignItems","InfoListItem","_ref","_ref$text","text","_jsx","style","children","Typography","variant","color","ListboxComponent","forwardRef","ref","loading","hasMore","otherProps","_objectWithoutProperties","_ref2","_excluded","_jsxs","List","_objectSpread","role","AssetEditorAutocomplete","_ref3","_currentOption$name","dataTestId","appKey","assetType","classes","companyId","currentValue","disabled","disableClearable","errorText","isMultiple","isNullable","label","onChange","parentAssetId","parentAssetType","queryParams","_ref3$autocompletePro","autocompleteProps","assetFields","_useState","useState","_useState2","_slicedToArray","currentOption","setCurrentOption","_useState4","_useState3","searchText","setSearchText","_useState6","_useState5","searchValue","setSearchValue","_useState8","_useState7","isSearchMode","setSearchMode","_useState10","_useState9","scrollPage","setScrollPage","_useState12","_useState11","setHasMore","useEffect","_useAssetAutoComplete","useAssetAutoCompleteSelectData","assets","hasMoreAssets","length","PER_PAGE","onInputChange","useMemo","debounce","value","handleFetchNext","prevScrollPage","autocompleteClasses","endAdornment","inputRoot","listbox","noOptions","option","popupIndicator","root","FormControl","error","className","formControl","InputLabel","shrink","Tooltip","title","name","Autocomplete","blurOnSelect","clearOnBlur","clearOnEscape","filterOptions","identity","getOptionLabel","getOptionSelected","id","inputValue","ListboxProps","onScroll","event","listboxNode","currentTarget","scrollTop","clientHeight","scrollHeight","SCROLL_THRESHOLD","options","selected","_selected$id","map","_ref5","onClose","reason","noOptionsText","renderInput","params","TextField","placeholder","InputProps","startAdornment","InputAdornment","SearchIcon","searchIcon","renderOption","_ref4","TruncatedText","includes","multiple","renderTags","getTagProps","index","Chip","getOptionDisabled","FormHelperText","defaultProps","undefined","concat","propTypes","PropTypes","string","oneOfType","number","arrayOf","bool","func","isRequired","shape","AssetEditorAutocomplete$1","withStyles","theme","maxHeight","fontSize","paddingTop","padding","paddingBottom","width","palette","primary","text9","opacity","backgroundColor"],"mappings":"kqCAuBA,IAAMA,EAAY,mCA2BZC,EAAqB,CACzBC,YAAa,OACbC,OAAQ,GACRC,cAAe,OACfC,QAAS,OACTC,WAAY,UAIRC,EAAe,SAAHC,GAAA,IAAAC,EAAAD,EAAME,KAAAA,aAAO,aAAYD,EAAA,OACzCE,EAAAA,IAAA,KAAA,CAAkBC,MAAOX,EAAmBY,SAC1CF,MAACG,aAAU,CAACC,QAAQ,QAAQC,MAAM,gBAAeH,SAC9CH,KAFG,UAIH,EAGDO,EAAmBC,EAAUA,YAAC,WAAgDC,GAAG,IAAhDN,IAAAA,SAAUO,IAAAA,QAASC,IAAAA,QAAYC,EAAUC,EAAA,QAAAC,EAAAC,GAAA,OAC9EC,EAAAA,KAACC,EAAAA,KAAIC,EAAAA,EAAA,GAAKN,GAAU,GAAA,CAAEH,IAAKA,EAAKU,KAAK,UAAShB,SAC3CA,CAAAA,GACCQ,GAAWD,IAAYT,MAACJ,EAAe,CAAA,MACpC,IAIHuB,EAA0B,SAmB1BC,GAAA,IAAAC,EAlBWC,IAAf,eACAC,IAAAA,OACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,UACAC,IAAAA,aACAC,IAAAA,SACAC,IAAAA,iBACAC,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gF,WAAY,GACZC,QAAS,QACTC,cAAe,EACfC,MAAO,IACPJ,SAAU,IAEZ3E,eAAgB,CAAE3F,QAAS,QAC3B0F,OAAQ,CACN7F,YAAa,kBACbC,OAAQ,GACR,wBAAyB,CACvBa,MAAOyJ,EAAMO,QAAQC,QAAQC,MAC7BC,QAAS,EACTC,gBAAiB,UAGrBtF,UAAW,CAAE+E,QAAS,GACtB/B,WAAY,CAAE6B,SAAU,mBACzB,GAiPcH,CAAsB1I"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@babel/runtime/helpers/toConsumableArray"),t=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),a=require("react"),r=require("prop-types"),l=require("lodash"),n=require("classnames"),i=require("@material-ui/core"),u=require("./components/PrimaryAssetSelect.js"),d=require("./components/SecondaryAssetSelect.js");require("./components/SelectItem.js");var o=require("./components/MultipleAssetsToggle.js"),c=require("./components/PrimaryAssetSelectV2.js"),p=require("./constants.js"),f=require("./utils/index.js");require("../../constants/goals.js");var y=require("../../constants/segment.js");require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/appPackages.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js");var A=require("../../constants/assetTypes.js");require("../../constants/corvaCompanyId.js"),require("../GradientManager/configuration/constants.js");var m=require("react/jsx-runtime");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var v=g(e),S=g(t),b=g(s),T=g(r),j=g(n);function h(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,a)}return s}function q(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?h(Object(s),!0).forEach((function(t){S.default(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):h(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}var I=i.makeStyles({title:{fontWeight:400,fontSize:20,margin:"24px 0 16px"}}),E=function(e){var t=e.appKey,s=void 0===t?null:t,r=e.appType,n=e.className,i=e.company,g=e.defaultValue,T=e.secondaryDefaultValue,h=e.disabled,E=e.isHiddenTitle,D=void 0!==E&&E,F=e.isNullable,x=void 0!==F&&F,N=e.label,R=void 0===N?"Choose An Asset":N,V=e.onSettingsChange,w=e.primaryAssetFields,G=void 0===w?P:w,Y=e.secondaryAssetFields,L=void 0===Y?_:Y,k=e.isExtendedSelect,H=e.isRequiredAssetId,K=e.settings,M=e.isVisibleMultipleAssetsToggle,U=void 0!==M&&M,W=e.assetsLimit,z=void 0===W?null:W,B=e.isDisabledSecondaryAssetSelect,J=void 0!==B&&B,Q=e.isDrillingPlatformApp,X=e.secondaryAssetHelpText,Z=void 0===X?null:X,$=e.onChange,ee=void 0===$?O:$,te=e.elementsClassNames,se=void 0===te?C:te,ae=l.get(r,["primaryAsset","assetType","type"]),re=l.get(r,["primaryAsset","assetType","id"]),le=l.get(r,["primaryAsset","assetType","label"]),ne=l.get(r,["primaryAsset","groups"]),ie=l.get(r,["secondaryAsset"],!1),ue=l.get(r,["secondaryAsset","assetType","type"]),de=l.get(r,["secondaryAsset","assetType","id"]),oe=l.get(r,["secondaryAsset","assetType","label"]),ce=l.get(K,re),pe=ce?Number(ce):null,fe=l.get(K,de)?Number(l.get(K,de)):T||null,ye=a.useState({id:pe||g}),Ae=b.default(ye,2),me=Ae[0],ge=Ae[1],ve=a.useState(fe),Se=b.default(ve,2),be=Se[0],Te=Se[1],je=a.useState(!1),he=b.default(je,2),qe=he[0],Ie=he[1],Ee=a.useState(),Pe=b.default(Ee,2),_e=Pe[0],Oe=Pe[1],Ce=a.useState(!1),De=b.default(Ce,2),Fe=De[0],xe=De[1],Ne=a.useRef(!1),Re=function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];V.apply(void 0,t.concat([Ne.current]))},Ve=I(),we=ae===A.ASSET_TYPES.rig.type||ae===A.ASSET_TYPES.intervention_unit.type?c:u,Ge=Q&&null!=me&&me.assetId?null==me?void 0:me.assetId:null==me?void 0:me.id,Ye=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};ge(t),Te(null),Ie(!1);var s=(e={},S.default(e,re,null),S.default(e,de,null),S.default(e,"assets",null),e);Re(s)},Le=ie&&(Fe?Boolean(me.length)&&!qe:(null==me?void 0:me.id)&&!qe);return a.useEffect((function(){l.isEmpty(K)&&Ye(Fe&&[])}),[K]),m.jsxs("div",{className:j.default(Ve.main,n),children:[!D&&m.jsx("div",{className:j.default(Ve.title,se.title),children:"Asset"}),U&&m.jsx(o,{onChange:function(e){Ne.current=!!e,xe(e),Ye(e&&[])},className:se.multiAssetSwitch,checked:Fe}),m.jsx("div",{className:se.primaryAssetSelect,children:m.jsx(we,{appKey:s,assetType:ae,company:i,currentOption:me,currentValue:null==me?void 0:me.id,"data-testid":"".concat("DC_AppSettingsAssetEditor","_primaryAssetEditorAutocomplete"),isSecondaryAssetPresent:ie,defaultValue:g,disableClearable:!x,disabled:h,isNullable:x,isRequiredAssetId:H,label:R,multiple:Fe,onChange:function(e){if(ee({primary:e}),Fe)!function(e){var t,s;if(!(e.length>z)){var a=(null===(t=e[0])||void 0===t?void 0:t.group)===y.PAD_GROUP.name,r=(null===(s=e[0])||void 0===s?void 0:s.group)===y.FRAC_FLEET_GROUP.name,l=1===e.length&&a,n=1===e.length&&r;if(l?(Ie(!0),Oe(y.PAD_GROUP)):n&&Oe(y.FRAC_FLEET_GROUP),a){ge(e);var i=null==e?void 0:e.reduce((function(e,t){var s=t.parentFracFleetId,a=t.id,r={fracFleetId:s,padId:a};return k&&(r.assetId=s,r.replacedPadId=a),s?[].concat(v.default(e),[r]):e}),[]);Re({assets:i})}else{ge(e);var u=e.reduce((function(e,t){var s=S.default({},"".concat(t.type,"Id"),t.id);return H&&(s.assetId=t.assetId),k&&(s.assetId=t.assetId||t.id),[].concat(v.default(e),[s])}),[]);Re({assets:u})}}}(e);else{var t=e.id,s=e.type,a=e.parentFracFleetId;if(t)if(s!==A.ASSET_TYPES.pad.type){ge(e),Te(null);var r=S.default({},re,t);H&&(r.assetId=e.assetId),de&&(r[de]=null),Re(r),Ie(!1)}else{var l;ge(e),Ie(!0),Te(t);var n=(l={},S.default(l,A.ASSET_TYPES.frac_fleet.id,Number(a)),S.default(l,A.ASSET_TYPES.pad.id,t),l);Re(n)}}},setCurrentOption:ge,selectedGroup:_e,onGroupChange:function(e){Oe(e),Ye(Fe&&[])},onGroupReset:function(){Oe(null),Ye(Fe&&[])},groups:ne,onInputReset:Ye,onActiveAssetIdChange:function(e){ge((function(t){return q(q({},t),{},{activeWellId:e})}))},isDrillingPlatformApp:Q,assetFields:f.getPrimaryAssetFields(ae,G,Q)})}),Le&&m.jsxs("div",{className:se.secondaryAssetSelect,children:[Z,m.jsx(d.default,{assetFields:ue===A.ASSET_TYPES.pad.type?[].concat(v.default(L),["pad.active","pad.current"]):L,activeWellId:null==me?void 0:me.activeWellId,appKey:s,assetType:ue,company:i,currentValue:be,"data-testid":"".concat("DC_AppSettingsAssetEditor","_secondaryAutoComplete"),defaultValue:Fe?p.ACTIVE_ASSETS_ID:p.ACTIVE_ASSET_ID,disabled:Fe||J||h,isDrillingPlatformApp:Q,isNullable:x,isRequiredAssetId:H,onChange:function(e){var t=e.id,s=e.assetId,a=e.name;ee({secondary:{name:a}}),Te(t);var r=t===p.ACTIVE_ASSET_ID?null:t,l=S.default({},de,r);H&&ue===A.ASSET_TYPES.well.type?Re(q(q({},l),{},{replacedAssetId:Q?r:s})):Re(l)},parentAssetId:Ge,parentAssetType:Q?"parent_asset_id":ae,primaryAssetLabel:le,secondaryAssetLabel:oe})]})]})},P=[],_=[],O=l.noop,C={};E.propTypes={assetsLimit:T.default.number,settings:T.default.shape({}).isRequired,appType:T.default.shape({}).isRequired,defaultValue:T.default.any,secondaryDefaultValue:T.default.any,onSettingsChange:T.default.func.isRequired,label:T.default.string,isNullable:T.default.bool,isHiddenTitle:T.default.bool,appKey:T.default.string,isVisibleMultipleAssetsToggle:T.default.bool,isDisabledSecondaryAssetSelect:T.default.bool,primaryAssetFields:T.default.arrayOf(T.default.shape({})),secondaryAssetFields:T.default.arrayOf(T.default.shape({})),secondaryAssetHelpText:T.default.oneOfType([T.default.element,T.default.string]),onChange:T.default.func,elementsClassNames:T.default.shape({title:T.default.string,multiAssetSwitch:T.default.string,primaryAssetSelect:T.default.string,secondaryAssetSelect:T.default.string})},module.exports=E;
1
+ "use strict";var e=require("@babel/runtime/helpers/toConsumableArray"),t=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),a=require("react"),r=require("prop-types"),l=require("lodash"),n=require("classnames"),i=require("@material-ui/core"),u=require("./components/PrimaryAssetSelect.js"),d=require("./components/SecondaryAssetSelect.js");require("./components/SelectItem.js");var o=require("./components/MultipleAssetsToggle.js"),c=require("./components/PrimaryAssetSelectV2.js"),p=require("./constants.js"),f=require("./utils/index.js");require("../../constants/goals.js");var y=require("../../constants/segment.js");require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/appPackages.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js");var A=require("../../constants/assetTypes.js");require("../../constants/corvaCompanyId.js"),require("../GradientManager/configuration/constants.js");var m=require("react/jsx-runtime");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var S=g(e),b=g(t),v=g(s),T=g(r),j=g(n);function h(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,a)}return s}function q(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?h(Object(s),!0).forEach((function(t){b.default(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):h(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}var I=i.makeStyles({title:{fontWeight:400,fontSize:20,margin:"24px 0 16px"}}),E=function(e){var t=e.appKey,s=e.appType,r=e.className,n=e.company,i=e.defaultValue,g=e.secondaryDefaultValue,T=e.disabled,h=e.isHiddenTitle,E=e.isNullable,P=e.label,_=e.onSettingsChange,C=e.primaryAssetFields,O=e.secondaryAssetFields,D=e.isExtendedSelect,F=e.isRequiredAssetId,N=e.settings,V=e.isVisibleMultipleAssetsToggle,x=e.assetsLimit,R=e.isDisabledSecondaryAssetSelect,w=e.isDrillingPlatformApp,G=e.secondaryAssetHelpText,L=e.onChange,Y=e.elementsClassNames,H=l.get(s,["primaryAsset","assetType","type"]),K=l.get(s,["primaryAsset","assetType","id"]),M=l.get(s,["primaryAsset","assetType","label"]),k=l.get(s,["primaryAsset","groups"]),U=l.get(s,["secondaryAsset"],!1),W=l.get(s,["secondaryAsset","assetType","type"]),z=l.get(s,["secondaryAsset","assetType","id"]),B=l.get(s,["secondaryAsset","assetType","label"]),J=l.get(N,K),Q=J?Number(J):null,X=l.get(N,z)?Number(l.get(N,z)):g||null,Z=a.useState({id:Q||i}),$=v.default(Z,2),ee=$[0],te=$[1],se=a.useState(X),ae=v.default(se,2),re=ae[0],le=ae[1],ne=a.useState(!1),ie=v.default(ne,2),ue=ie[0],de=ie[1],oe=a.useState(),ce=v.default(oe,2),pe=ce[0],fe=ce[1],ye=a.useState(!1),Ae=v.default(ye,2),me=Ae[0],ge=Ae[1],Se=a.useRef(!1),be=function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];_.apply(void 0,t.concat([Se.current]))},ve=I(),Te=H===A.ASSET_TYPES.rig.type||H===A.ASSET_TYPES.intervention_unit.type?c:u,je=w&&null!=ee&&ee.assetId?null==ee?void 0:ee.assetId:null==ee?void 0:ee.id,he=function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};te(t),le(null),de(!1);var s=(e={},b.default(e,K,null),b.default(e,z,null),b.default(e,"assets",null),e);be(s)},qe=U&&(me?Boolean(ee.length)&&!ue:(null==ee?void 0:ee.id)&&!ue);return a.useEffect((function(){l.isEmpty(N)&&he(me&&[])}),[N]),m.jsxs("div",{className:j.default(ve.main,r),children:[!h&&m.jsx("div",{className:j.default(ve.title,Y.title),children:"Asset"}),V&&m.jsx(o,{onChange:function(e){Se.current=!!e,ge(e),he(e&&[])},className:Y.multiAssetSwitch,checked:me}),m.jsx("div",{className:Y.primaryAssetSelect,children:m.jsx(Te,{appKey:t,assetType:H,company:n,currentOption:ee,currentValue:null==ee?void 0:ee.id,"data-testid":"".concat("DC_AppSettingsAssetEditor","_primaryAssetEditorAutocomplete"),isSecondaryAssetPresent:U,defaultValue:i,disableClearable:!E,disabled:T,isNullable:E,isRequiredAssetId:F,label:P,multiple:me,onChange:function(e){if(L({primary:e}),me)!function(e){var t,s;if(!(e.length>x)){var a=(null===(t=e[0])||void 0===t?void 0:t.group)===y.PAD_GROUP.name,r=(null===(s=e[0])||void 0===s?void 0:s.group)===y.FRAC_FLEET_GROUP.name,l=1===e.length&&a,n=1===e.length&&r;if(l?(de(!0),fe(y.PAD_GROUP)):n&&fe(y.FRAC_FLEET_GROUP),a){te(e);var i=null==e?void 0:e.reduce((function(e,t){var s=t.parentFracFleetId,a=t.id,r={fracFleetId:s,padId:a};return D&&(r.assetId=s,r.replacedPadId=a),s?[].concat(S.default(e),[r]):e}),[]);be({assets:i})}else{te(e);var u=e.reduce((function(e,t){var s=b.default({},"".concat(t.type,"Id"),t.id);return F&&(s.assetId=t.assetId),D&&(s.assetId=t.assetId||t.id),[].concat(S.default(e),[s])}),[]);be({assets:u})}}}(e);else{var t=e.id,s=e.type,a=e.parentFracFleetId;if(t)if(s!==A.ASSET_TYPES.pad.type){te(e),le(null);var r=b.default({},K,t);F&&(r.assetId=e.assetId),z&&(r[z]=null),be(r),de(!1)}else{var l;te(e),de(!0),le(t);var n=(l={},b.default(l,A.ASSET_TYPES.frac_fleet.id,Number(a)),b.default(l,A.ASSET_TYPES.pad.id,t),l);be(n)}}},setCurrentOption:te,selectedGroup:pe,onGroupChange:function(e){fe(e),he(me&&[])},onGroupReset:function(){fe(null),he(me&&[])},groups:k,onInputReset:he,onActiveAssetIdChange:function(e){te((function(t){return q(q({},t),{},{activeWellId:e})}))},isDrillingPlatformApp:w,assetFields:f.getPrimaryAssetFields(H,C,w)})}),qe&&m.jsxs("div",{className:Y.secondaryAssetSelect,children:[G,m.jsx(d.default,{assetFields:W===A.ASSET_TYPES.pad.type?[].concat(S.default(O),["pad.active","pad.current"]):O,activeWellId:null==ee?void 0:ee.activeWellId,appKey:t,assetType:W,company:n,currentValue:re,"data-testid":"".concat("DC_AppSettingsAssetEditor","_secondaryAutoComplete"),defaultValue:me?p.ACTIVE_ASSETS_ID:p.ACTIVE_ASSET_ID,disabled:me||R||T,isDrillingPlatformApp:w,isNullable:E,isRequiredAssetId:F,onChange:function(e){var t=e.id,s=e.assetId,a=e.name;L({secondary:{name:a}}),le(t);var r=t===p.ACTIVE_ASSET_ID?null:t,l=b.default({},z,r);F&&W===A.ASSET_TYPES.well.type?be(q(q({},l),{},{replacedAssetId:w?r:s})):be(l)},parentAssetId:je,parentAssetType:w?"parent_asset_id":H,primaryAssetLabel:M,secondaryAssetLabel:B})]})]})};E.defaultProps={assetsLimit:null,label:"Choose An Asset",isNullable:!1,defaultValue:void 0,secondaryDefaultValue:void 0,isHiddenTitle:!1,appKey:null,isVisibleMultipleAssetsToggle:!1,isDisabledSecondaryAssetSelect:!1,primaryAssetFields:[],secondaryAssetFields:[],secondaryAssetHelpText:null,onChange:l.noop,elementsClassNames:{}},E.propTypes={assetsLimit:T.default.number,settings:T.default.shape({}).isRequired,appType:T.default.shape({}).isRequired,defaultValue:T.default.any,secondaryDefaultValue:T.default.any,onSettingsChange:T.default.func.isRequired,label:T.default.string,isNullable:T.default.bool,isHiddenTitle:T.default.bool,appKey:T.default.string,isVisibleMultipleAssetsToggle:T.default.bool,isDisabledSecondaryAssetSelect:T.default.bool,primaryAssetFields:T.default.arrayOf(T.default.shape({})),secondaryAssetFields:T.default.arrayOf(T.default.shape({})),secondaryAssetHelpText:T.default.oneOfType([T.default.element,T.default.string]),onChange:T.default.func,elementsClassNames:T.default.shape({title:T.default.string,multiAssetSwitch:T.default.string,primaryAssetSelect:T.default.string,secondaryAssetSelect:T.default.string})},module.exports=E;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/AssetEditorV2/index.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { get, isEmpty, noop } from 'lodash';\nimport classNames from 'classnames';\nimport { makeStyles } from '@material-ui/core';\n\nimport { PrimaryAssetSelect, PrimaryAssetSelectV2, SecondaryAssetSelect } from './components';\nimport { ACTIVE_ASSET_ID, ACTIVE_ASSETS_ID } from './constants';\nimport MultipleAssetsToggle from './components/MultipleAssetsToggle';\nimport { getPrimaryAssetFields } from './utils';\n\nimport { ASSET_TYPES } from '~/constants';\nimport { FRAC_FLEET_GROUP, PAD_GROUP } from '~/constants/segment';\n\nconst useStyles = makeStyles({\n title: { fontWeight: 400, fontSize: 20, margin: '24px 0 16px' },\n});\n\nconst PAGE_NAME = 'DC_AppSettingsAssetEditor';\nconst PARENT_ASSET_ID = 'parent_asset_id';\n\nconst AppSettingsAssetEditor = ({\n appKey = null,\n appType,\n className,\n company,\n defaultValue,\n secondaryDefaultValue,\n disabled,\n isHiddenTitle = false,\n isNullable = false,\n label = 'Choose An Asset',\n onSettingsChange: propsOnSettingsChange,\n primaryAssetFields = DEFAULT_APP_SETTINGS_ASSET_EDITOR_PRIMARY_ASSET_FIELDS,\n secondaryAssetFields = DEFAULT_APP_SETTINGS_ASSET_EDITOR_SECONDARY_ASSET_FIELDS,\n isExtendedSelect,\n isRequiredAssetId,\n settings,\n isVisibleMultipleAssetsToggle = false,\n assetsLimit = null,\n isDisabledSecondaryAssetSelect = false,\n isDrillingPlatformApp,\n secondaryAssetHelpText = null,\n onChange = DEFAULT_APP_SETTINGS_ASSET_EDITOR_ON_CHANGE,\n elementsClassNames = DEFAULT_APP_SETTINGS_ASSET_EDITOR_ELEMENTS_CLASS_NAMES,\n}) => {\n const primaryAssetType = get(appType, ['primaryAsset', 'assetType', 'type']);\n const primaryAssetIdType = get(appType, ['primaryAsset', 'assetType', 'id']);\n const primaryAssetLabel = get(appType, ['primaryAsset', 'assetType', 'label']);\n const primaryAssetSelectGroups = get(appType, ['primaryAsset', 'groups']);\n\n const isSecondaryAssetPresent = get(appType, ['secondaryAsset'], false);\n\n const secondaryAssetType = get(appType, ['secondaryAsset', 'assetType', 'type']);\n const secondaryAssetIdType = get(appType, ['secondaryAsset', 'assetType', 'id']);\n const secondaryAssetLabel = get(appType, ['secondaryAsset', 'assetType', 'label']);\n\n const currentValue = get(settings, primaryAssetIdType);\n const initialPrimaryAssetId = currentValue ? Number(currentValue) : null;\n const initialSecondaryAssetId = get(settings, secondaryAssetIdType)\n ? Number(get(settings, secondaryAssetIdType))\n : secondaryDefaultValue || null;\n const [primaryAsset, setPrimaryAsset] = useState({ id: initialPrimaryAssetId || defaultValue });\n\n const [secondaryAssetId, setSecondaryAssetId] = useState(initialSecondaryAssetId);\n const [isPadSelectedAsPrimaryAsset, setIsPadSelectedAsPrimaryAsset] = useState(false);\n const [selectedGroup, setSelectedGroup] = useState();\n const [isMultipleAssets, setIsMultipleAssets] = useState(false);\n const isMultipleAssetsRef = useRef(false);\n const onSettingsChange = (...args) => {\n propsOnSettingsChange(...args, isMultipleAssetsRef.current);\n };\n\n const styles = useStyles();\n\n const PrimaryAssetSelectComponent =\n primaryAssetType === ASSET_TYPES.rig.type ||\n primaryAssetType === ASSET_TYPES.intervention_unit.type\n ? PrimaryAssetSelectV2\n : PrimaryAssetSelect;\n\n const parentAssetId =\n isDrillingPlatformApp && primaryAsset?.assetId ? primaryAsset?.assetId : primaryAsset?.id;\n\n const onSecondaryAssetChange = ({ id, assetId, name }) => {\n onChange({ secondary: { name } });\n setSecondaryAssetId(id);\n const secondaryAssetId = id === ACTIVE_ASSET_ID ? null : id;\n const assetSettings = { [secondaryAssetIdType]: secondaryAssetId };\n\n if (isRequiredAssetId && secondaryAssetType === ASSET_TYPES.well.type) {\n onSettingsChange({\n ...assetSettings,\n replacedAssetId: isDrillingPlatformApp ? secondaryAssetId : assetId,\n });\n return;\n }\n\n onSettingsChange(assetSettings);\n };\n\n const onMultipleAssetChange = selected => {\n if (selected.length > assetsLimit) return;\n\n const isPadSelected = selected[0]?.group === PAD_GROUP.name;\n const isFracFleetSelected = selected[0]?.group === FRAC_FLEET_GROUP.name;\n const isFirstPadSelected = selected.length === 1 && isPadSelected;\n const isFirstFracFleetSelected = selected.length === 1 && isFracFleetSelected;\n\n if (isFirstPadSelected) {\n setIsPadSelectedAsPrimaryAsset(true);\n setSelectedGroup(PAD_GROUP);\n } else if (isFirstFracFleetSelected) {\n setSelectedGroup(FRAC_FLEET_GROUP);\n }\n\n if (isPadSelected) {\n setPrimaryAsset(selected);\n const assetsSetting = selected?.reduce((acc, { parentFracFleetId, id }) => {\n const settings = {\n fracFleetId: parentFracFleetId,\n padId: id,\n };\n\n if (isExtendedSelect) {\n settings.assetId = parentFracFleetId;\n settings.replacedPadId = id;\n }\n return parentFracFleetId ? [...acc, settings] : acc;\n }, []);\n\n onSettingsChange({\n assets: assetsSetting,\n });\n return;\n }\n\n setPrimaryAsset(selected);\n const assetsSetting = selected.reduce((acc, asset) => {\n const settings = { [`${asset.type}Id`]: asset.id };\n if (isRequiredAssetId) {\n settings.assetId = asset.assetId;\n }\n if (isExtendedSelect) {\n settings.assetId = asset.assetId || asset.id;\n }\n return [...acc, settings];\n }, []);\n onSettingsChange({\n assets: assetsSetting,\n });\n };\n\n const onPrimaryAssetChange = selected => {\n onChange({ primary: selected });\n if (isMultipleAssets) {\n onMultipleAssetChange(selected);\n return;\n }\n const { id, type, parentFracFleetId } = selected;\n if (!id) return;\n if (type === ASSET_TYPES.pad.type) {\n setPrimaryAsset(selected);\n setIsPadSelectedAsPrimaryAsset(true);\n setSecondaryAssetId(id);\n const assetSetting = {\n [ASSET_TYPES.frac_fleet.id]: Number(parentFracFleetId),\n [ASSET_TYPES.pad.id]: id,\n };\n onSettingsChange(assetSetting);\n return;\n }\n\n setPrimaryAsset(selected);\n setSecondaryAssetId(null);\n const assetSetting = { [primaryAssetIdType]: id };\n if (isRequiredAssetId) assetSetting.assetId = selected.assetId;\n if (secondaryAssetIdType) assetSetting[secondaryAssetIdType] = null;\n onSettingsChange(assetSetting);\n setIsPadSelectedAsPrimaryAsset(false);\n };\n\n const handlePrimaryAssetReset = (defaultValue = {}) => {\n setPrimaryAsset(defaultValue);\n setSecondaryAssetId(null);\n\n setIsPadSelectedAsPrimaryAsset(false);\n const assetSetting = {\n [primaryAssetIdType]: null,\n [secondaryAssetIdType]: null,\n assets: null,\n };\n onSettingsChange(assetSetting);\n };\n\n const handleMultipleAssetsChange = checked => {\n isMultipleAssetsRef.current = !!checked;\n setIsMultipleAssets(checked);\n handlePrimaryAssetReset(checked && []);\n };\n\n const handleGroupChange = newGroup => {\n setSelectedGroup(newGroup);\n handlePrimaryAssetReset(isMultipleAssets && []);\n };\n\n const handleGroupReset = () => {\n setSelectedGroup(null);\n handlePrimaryAssetReset(isMultipleAssets && []);\n };\n\n const secondaryAssetSelectIsVisible =\n isSecondaryAssetPresent &&\n (isMultipleAssets\n ? Boolean(primaryAsset.length) && !isPadSelectedAsPrimaryAsset\n : primaryAsset?.id && !isPadSelectedAsPrimaryAsset);\n\n useEffect(() => {\n if (isEmpty(settings)) {\n handlePrimaryAssetReset(isMultipleAssets && []);\n }\n }, [settings]);\n\n return (\n <div className={classNames(styles.main, className)}>\n {!isHiddenTitle && (\n <div className={classNames(styles.title, elementsClassNames.title)}>Asset</div>\n )}\n {isVisibleMultipleAssetsToggle && (\n <MultipleAssetsToggle\n onChange={handleMultipleAssetsChange}\n className={elementsClassNames.multiAssetSwitch}\n checked={isMultipleAssets}\n />\n )}\n <div className={elementsClassNames.primaryAssetSelect}>\n <PrimaryAssetSelectComponent\n appKey={appKey}\n assetType={primaryAssetType}\n company={company}\n currentOption={primaryAsset}\n currentValue={primaryAsset?.id}\n data-testid={`${PAGE_NAME}_primaryAssetEditorAutocomplete`}\n isSecondaryAssetPresent={isSecondaryAssetPresent}\n defaultValue={defaultValue}\n disableClearable={!isNullable}\n disabled={disabled}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n label={label}\n multiple={isMultipleAssets}\n onChange={onPrimaryAssetChange}\n setCurrentOption={setPrimaryAsset}\n selectedGroup={selectedGroup}\n onGroupChange={handleGroupChange}\n onGroupReset={handleGroupReset}\n groups={primaryAssetSelectGroups}\n onInputReset={handlePrimaryAssetReset}\n onActiveAssetIdChange={activeAssetId => {\n setPrimaryAsset(primaryAsset => ({ ...primaryAsset, activeWellId: activeAssetId }));\n }}\n isDrillingPlatformApp={isDrillingPlatformApp}\n assetFields={getPrimaryAssetFields(\n primaryAssetType,\n primaryAssetFields,\n isDrillingPlatformApp\n )}\n />\n </div>\n {secondaryAssetSelectIsVisible && (\n <div className={elementsClassNames.secondaryAssetSelect}>\n {secondaryAssetHelpText}\n <SecondaryAssetSelect\n assetFields={\n secondaryAssetType === ASSET_TYPES.pad.type\n ? [...secondaryAssetFields, 'pad.active', 'pad.current']\n : secondaryAssetFields\n }\n activeWellId={primaryAsset?.activeWellId}\n appKey={appKey}\n assetType={secondaryAssetType}\n company={company}\n currentValue={secondaryAssetId}\n data-testid={`${PAGE_NAME}_secondaryAutoComplete`}\n defaultValue={isMultipleAssets ? ACTIVE_ASSETS_ID : ACTIVE_ASSET_ID}\n disabled={isMultipleAssets || isDisabledSecondaryAssetSelect || disabled}\n isDrillingPlatformApp={isDrillingPlatformApp}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n onChange={onSecondaryAssetChange}\n parentAssetId={parentAssetId}\n parentAssetType={isDrillingPlatformApp ? PARENT_ASSET_ID : primaryAssetType}\n primaryAssetLabel={primaryAssetLabel}\n secondaryAssetLabel={secondaryAssetLabel}\n />\n </div>\n )}\n </div>\n );\n};\n\nconst DEFAULT_APP_SETTINGS_ASSET_EDITOR_PRIMARY_ASSET_FIELDS = [];\nconst DEFAULT_APP_SETTINGS_ASSET_EDITOR_SECONDARY_ASSET_FIELDS = [];\nconst DEFAULT_APP_SETTINGS_ASSET_EDITOR_ON_CHANGE = noop;\nconst DEFAULT_APP_SETTINGS_ASSET_EDITOR_ELEMENTS_CLASS_NAMES = {};\n\nAppSettingsAssetEditor.propTypes = {\n assetsLimit: PropTypes.number,\n settings: PropTypes.shape({}).isRequired,\n appType: PropTypes.shape({}).isRequired,\n defaultValue: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n secondaryDefaultValue: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n onSettingsChange: PropTypes.func.isRequired,\n label: PropTypes.string,\n isNullable: PropTypes.bool,\n isHiddenTitle: PropTypes.bool,\n appKey: PropTypes.string,\n isVisibleMultipleAssetsToggle: PropTypes.bool,\n isDisabledSecondaryAssetSelect: PropTypes.bool,\n primaryAssetFields: PropTypes.arrayOf(PropTypes.shape({})),\n secondaryAssetFields: PropTypes.arrayOf(PropTypes.shape({})),\n secondaryAssetHelpText: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),\n onChange: PropTypes.func,\n elementsClassNames: PropTypes.shape({\n title: PropTypes.string,\n multiAssetSwitch: PropTypes.string,\n primaryAssetSelect: PropTypes.string,\n secondaryAssetSelect: PropTypes.string,\n }),\n};\n\nexport default AppSettingsAssetEditor;\n"],"names":["useStyles","makeStyles","title","fontWeight","fontSize","margin","AppSettingsAssetEditor","_ref","_ref$appKey","appKey","appType","className","company","defaultValue","secondaryDefaultValue","disabled","_ref$isHiddenTitle","isHiddenTitle","_ref$isNullable","isNullable","_ref$label","label","propsOnSettingsChange","onSettingsChange","_ref$primaryAssetFiel","primaryAssetFields","DEFAULT_APP_SETTINGS_ASSET_EDITOR_PRIMARY_ASSET_FIELDS","_ref$secondaryAssetFi","secondaryAssetFields","DEFAULT_APP_SETTINGS_ASSET_EDITOR_SECONDARY_ASSET_FIELDS","isExtendedSelect","isRequiredAssetId","settings","_ref$isVisibleMultipl","isVisibleMultipleAssetsToggle","_ref$assetsLimit","assetsLimit","_ref$isDisabledSecond","isDisabledSecondaryAssetSelect","isDrillingPlatformApp","_ref$secondaryAssetHe","secondaryAssetHelpText","_ref$onChange","onChange","DEFAULT_APP_SETTINGS_ASSET_EDITOR_ON_CHANGE","_ref$elementsClassNam","elementsClassNames","DEFAULT_APP_SETTINGS_ASSET_EDITOR_ELEMENTS_CLASS_NAMES","primaryAssetType","get","primaryAssetIdType","primaryAssetLabel","primaryAssetSelectGroups","isSecondaryAssetPresent","secondaryAssetType","secondaryAssetIdType","secondaryAssetLabel","currentValue","initialPrimaryAssetId","Number","initialSecondaryAssetId","_useState","useState","id","_useState2","_slicedToArray","primaryAsset","setPrimaryAsset","_useState4","_useState3","secondaryAssetId","setSecondaryAssetId","_useState6","_useState5","isPadSelectedAsPrimaryAsset","setIsPadSelectedAsPrimaryAsset","_useState7","_useState8","selectedGroup","setSelectedGroup","_useState10","_useState9","isMultipleAssets","setIsMultipleAssets","isMultipleAssetsRef","useRef","_len","arguments","length","args","Array","_key","concat","current","styles","PrimaryAssetSelectComponent","ASSET_TYPES","rig","type","intervention_unit","PrimaryAssetSelectV2","PrimaryAssetSelect","parentAssetId","assetId","handlePrimaryAssetReset","_assetSetting4","undefined","assetSetting","_defineProperty","secondaryAssetSelectIsVisible","Boolean","useEffect","isEmpty","_jsxs","classNames","main","children","_jsx","jsx","MultipleAssetsToggle","checked","multiAssetSwitch","primaryAssetSelect","assetType","currentOption","disableClearable","multiple","selected","primary","_selected$","_selected$2","isPadSelected","group","PAD_GROUP","name","isFracFleetSelected","FRAC_FLEET_GROUP","isFirstPadSelected","isFirstFracFleetSelected","assetsSetting","reduce","acc","_ref3","parentFracFleetId","fracFleetId","padId","replacedPadId","assets","asset","onMultipleAssetChange","pad","_assetSetting2","frac_fleet","setCurrentOption","onGroupChange","newGroup","onGroupReset","groups","onInputReset","onActiveAssetIdChange","activeAssetId","_objectSpread","activeWellId","assetFields","getPrimaryAssetFields","jsxs","secondaryAssetSelect","SecondaryAssetSelect","_toConsumableArray","ACTIVE_ASSETS_ID","ACTIVE_ASSET_ID","_ref2","secondary","assetSettings","well","replacedAssetId","parentAssetType","noop","propTypes","PropTypes","number","shape","isRequired","any","func","string","bool","arrayOf","oneOfType","element"],"mappings":"g0DAcA,IAAMA,EAAYC,EAAAA,WAAW,CAC3BC,MAAO,CAAEC,WAAY,IAAKC,SAAU,GAAIC,OAAQ,iBAM5CC,EAAyB,SAwBzBC,GAAA,IAAAC,EAAAD,EAvBJE,OAAAA,aAAS,KAAID,EACbE,IAAAA,QACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,aACAC,IAAAA,sBACAC,IAAAA,SAAQC,EAAAT,EACRU,cAAAA,cAAqBD,EAAAE,EAAAX,EACrBY,WAAAA,cAAkBD,EAAAE,EAAAb,EAClBc,MAAAA,aAAQ,kBAAiBD,EACPE,IAAlBC,iBAAgBC,EAAAjB,EAChBkB,mBAAAA,aAAqBC,EAAsDF,EAAAG,EAAApB,EAC3EqB,qBAAAA,aAAuBC,EAAwDF,EAC/EG,IAAAA,iBACAC,IAAAA,kBACAC,IAAAA,SAAQC,EAAA1B,EACR2B,8BAAAA,cAAqCD,EAAAE,EAAA5B,EACrC6B,YAAAA,aAAc,KAAID,EAAAE,EAAA9B,EAClB+B,+BAAAA,cAAsCD,EACtCE,IAAAA,sBAAqBC,EAAAjC,EACrBkC,uBAAAA,aAAyB,KAAID,EAAAE,EAAAnC,EAC7B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ClI,EAAyD,CAAA,EAE/DzC,EAAuB4K,UAAY,CACjC9I,YAAa+I,EAAS,QAACC,OACvBpJ,SAAUmJ,EAAS,QAACE,MAAM,CAAA,GAAIC,WAC9B5K,QAASyK,EAAS,QAACE,MAAM,CAAA,GAAIC,WAC7BzK,aAAcsK,EAAS,QAACI,IACxBzK,sBAAuBqK,EAAS,QAACI,IACjChK,iBAAkB4J,EAAAA,QAAUK,KAAKF,WACjCjK,MAAO8J,EAAS,QAACM,OACjBtK,WAAYgK,EAAS,QAACO,KACtBzK,cAAekK,EAAS,QAACO,KACzBjL,OAAQ0K,EAAS,QAACM,OAClBvJ,8BAA+BiJ,EAAS,QAACO,KACzCpJ,+BAAgC6I,EAAS,QAACO,KAC1CjK,mBAAoB0J,EAAS,QAACQ,QAAQR,EAAS,QAACE,MAAM,CAAE,IACxDzJ,qBAAsBuJ,EAAS,QAACQ,QAAQR,EAAS,QAACE,MAAM,CAAE,IAC1D5I,uBAAwB0I,EAAS,QAACS,UAAU,CAACT,EAAS,QAACU,QAASV,EAAAA,QAAUM,SAC1E9I,SAAUwI,EAAS,QAACK,KACpB1I,mBAAoBqI,EAAS,QAACE,MAAM,CAClCnL,MAAOiL,EAAS,QAACM,OACjBhE,iBAAkB0D,EAAS,QAACM,OAC5B/D,mBAAoByD,EAAS,QAACM,OAC9BnB,qBAAsBa,EAAS,QAACM"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/AssetEditorV2/index.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { get, isEmpty, noop } from 'lodash';\nimport classNames from 'classnames';\nimport { makeStyles } from '@material-ui/core';\n\nimport { PrimaryAssetSelect, PrimaryAssetSelectV2, SecondaryAssetSelect } from './components';\nimport { ACTIVE_ASSET_ID, ACTIVE_ASSETS_ID } from './constants';\nimport MultipleAssetsToggle from './components/MultipleAssetsToggle';\nimport { getPrimaryAssetFields } from './utils';\n\nimport { ASSET_TYPES } from '~/constants';\nimport { FRAC_FLEET_GROUP, PAD_GROUP } from '~/constants/segment';\n\nconst useStyles = makeStyles({\n title: { fontWeight: 400, fontSize: 20, margin: '24px 0 16px' },\n});\n\nconst PAGE_NAME = 'DC_AppSettingsAssetEditor';\nconst PARENT_ASSET_ID = 'parent_asset_id';\n\nconst AppSettingsAssetEditor = ({\n appKey,\n appType,\n className,\n company,\n defaultValue,\n secondaryDefaultValue,\n disabled,\n isHiddenTitle,\n isNullable,\n label,\n onSettingsChange: propsOnSettingsChange,\n primaryAssetFields,\n secondaryAssetFields,\n isExtendedSelect,\n isRequiredAssetId,\n settings,\n isVisibleMultipleAssetsToggle,\n assetsLimit,\n isDisabledSecondaryAssetSelect,\n isDrillingPlatformApp,\n secondaryAssetHelpText,\n onChange,\n elementsClassNames,\n}) => {\n const primaryAssetType = get(appType, ['primaryAsset', 'assetType', 'type']);\n const primaryAssetIdType = get(appType, ['primaryAsset', 'assetType', 'id']);\n const primaryAssetLabel = get(appType, ['primaryAsset', 'assetType', 'label']);\n const primaryAssetSelectGroups = get(appType, ['primaryAsset', 'groups']);\n\n const isSecondaryAssetPresent = get(appType, ['secondaryAsset'], false);\n\n const secondaryAssetType = get(appType, ['secondaryAsset', 'assetType', 'type']);\n const secondaryAssetIdType = get(appType, ['secondaryAsset', 'assetType', 'id']);\n const secondaryAssetLabel = get(appType, ['secondaryAsset', 'assetType', 'label']);\n\n const currentValue = get(settings, primaryAssetIdType);\n const initialPrimaryAssetId = currentValue ? Number(currentValue) : null;\n const initialSecondaryAssetId = get(settings, secondaryAssetIdType)\n ? Number(get(settings, secondaryAssetIdType))\n : secondaryDefaultValue || null;\n const [primaryAsset, setPrimaryAsset] = useState({ id: initialPrimaryAssetId || defaultValue });\n\n const [secondaryAssetId, setSecondaryAssetId] = useState(initialSecondaryAssetId);\n const [isPadSelectedAsPrimaryAsset, setIsPadSelectedAsPrimaryAsset] = useState(false);\n const [selectedGroup, setSelectedGroup] = useState();\n const [isMultipleAssets, setIsMultipleAssets] = useState(false);\n const isMultipleAssetsRef = useRef(false);\n const onSettingsChange = (...args) => {\n propsOnSettingsChange(...args, isMultipleAssetsRef.current);\n };\n\n const styles = useStyles();\n\n const PrimaryAssetSelectComponent =\n primaryAssetType === ASSET_TYPES.rig.type ||\n primaryAssetType === ASSET_TYPES.intervention_unit.type\n ? PrimaryAssetSelectV2\n : PrimaryAssetSelect;\n\n const parentAssetId =\n isDrillingPlatformApp && primaryAsset?.assetId ? primaryAsset?.assetId : primaryAsset?.id;\n\n const onSecondaryAssetChange = ({ id, assetId, name }) => {\n onChange({ secondary: { name } });\n setSecondaryAssetId(id);\n const secondaryAssetId = id === ACTIVE_ASSET_ID ? null : id;\n const assetSettings = { [secondaryAssetIdType]: secondaryAssetId };\n\n if (isRequiredAssetId && secondaryAssetType === ASSET_TYPES.well.type) {\n onSettingsChange({\n ...assetSettings,\n replacedAssetId: isDrillingPlatformApp ? secondaryAssetId : assetId,\n });\n return;\n }\n\n onSettingsChange(assetSettings);\n };\n\n const onMultipleAssetChange = selected => {\n if (selected.length > assetsLimit) return;\n\n const isPadSelected = selected[0]?.group === PAD_GROUP.name;\n const isFracFleetSelected = selected[0]?.group === FRAC_FLEET_GROUP.name;\n const isFirstPadSelected = selected.length === 1 && isPadSelected;\n const isFirstFracFleetSelected = selected.length === 1 && isFracFleetSelected;\n\n if (isFirstPadSelected) {\n setIsPadSelectedAsPrimaryAsset(true);\n setSelectedGroup(PAD_GROUP);\n } else if (isFirstFracFleetSelected) {\n setSelectedGroup(FRAC_FLEET_GROUP);\n }\n\n if (isPadSelected) {\n setPrimaryAsset(selected);\n const assetsSetting = selected?.reduce((acc, { parentFracFleetId, id }) => {\n const settings = {\n fracFleetId: parentFracFleetId,\n padId: id,\n };\n\n if (isExtendedSelect) {\n settings.assetId = parentFracFleetId;\n settings.replacedPadId = id;\n }\n return parentFracFleetId ? [...acc, settings] : acc;\n }, []);\n\n onSettingsChange({\n assets: assetsSetting,\n });\n return;\n }\n\n setPrimaryAsset(selected);\n const assetsSetting = selected.reduce((acc, asset) => {\n const settings = { [`${asset.type}Id`]: asset.id };\n if (isRequiredAssetId) {\n settings.assetId = asset.assetId;\n }\n if (isExtendedSelect) {\n settings.assetId = asset.assetId || asset.id;\n }\n return [...acc, settings];\n }, []);\n onSettingsChange({\n assets: assetsSetting,\n });\n };\n\n const onPrimaryAssetChange = selected => {\n onChange({ primary: selected });\n if (isMultipleAssets) {\n onMultipleAssetChange(selected);\n return;\n }\n const { id, type, parentFracFleetId } = selected;\n if (!id) return;\n if (type === ASSET_TYPES.pad.type) {\n setPrimaryAsset(selected);\n setIsPadSelectedAsPrimaryAsset(true);\n setSecondaryAssetId(id);\n const assetSetting = {\n [ASSET_TYPES.frac_fleet.id]: Number(parentFracFleetId),\n [ASSET_TYPES.pad.id]: id,\n };\n onSettingsChange(assetSetting);\n return;\n }\n\n setPrimaryAsset(selected);\n setSecondaryAssetId(null);\n const assetSetting = { [primaryAssetIdType]: id };\n if (isRequiredAssetId) assetSetting.assetId = selected.assetId;\n if (secondaryAssetIdType) assetSetting[secondaryAssetIdType] = null;\n onSettingsChange(assetSetting);\n setIsPadSelectedAsPrimaryAsset(false);\n };\n\n const handlePrimaryAssetReset = (defaultValue = {}) => {\n setPrimaryAsset(defaultValue);\n setSecondaryAssetId(null);\n\n setIsPadSelectedAsPrimaryAsset(false);\n const assetSetting = {\n [primaryAssetIdType]: null,\n [secondaryAssetIdType]: null,\n assets: null,\n };\n onSettingsChange(assetSetting);\n };\n\n const handleMultipleAssetsChange = checked => {\n isMultipleAssetsRef.current = !!checked;\n setIsMultipleAssets(checked);\n handlePrimaryAssetReset(checked && []);\n };\n\n const handleGroupChange = newGroup => {\n setSelectedGroup(newGroup);\n handlePrimaryAssetReset(isMultipleAssets && []);\n };\n\n const handleGroupReset = () => {\n setSelectedGroup(null);\n handlePrimaryAssetReset(isMultipleAssets && []);\n };\n\n const secondaryAssetSelectIsVisible =\n isSecondaryAssetPresent &&\n (isMultipleAssets\n ? Boolean(primaryAsset.length) && !isPadSelectedAsPrimaryAsset\n : primaryAsset?.id && !isPadSelectedAsPrimaryAsset);\n\n useEffect(() => {\n if (isEmpty(settings)) {\n handlePrimaryAssetReset(isMultipleAssets && []);\n }\n }, [settings]);\n\n return (\n <div className={classNames(styles.main, className)}>\n {!isHiddenTitle && (\n <div className={classNames(styles.title, elementsClassNames.title)}>Asset</div>\n )}\n {isVisibleMultipleAssetsToggle && (\n <MultipleAssetsToggle\n onChange={handleMultipleAssetsChange}\n className={elementsClassNames.multiAssetSwitch}\n checked={isMultipleAssets}\n />\n )}\n <div className={elementsClassNames.primaryAssetSelect}>\n <PrimaryAssetSelectComponent\n appKey={appKey}\n assetType={primaryAssetType}\n company={company}\n currentOption={primaryAsset}\n currentValue={primaryAsset?.id}\n data-testid={`${PAGE_NAME}_primaryAssetEditorAutocomplete`}\n isSecondaryAssetPresent={isSecondaryAssetPresent}\n defaultValue={defaultValue}\n disableClearable={!isNullable}\n disabled={disabled}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n label={label}\n multiple={isMultipleAssets}\n onChange={onPrimaryAssetChange}\n setCurrentOption={setPrimaryAsset}\n selectedGroup={selectedGroup}\n onGroupChange={handleGroupChange}\n onGroupReset={handleGroupReset}\n groups={primaryAssetSelectGroups}\n onInputReset={handlePrimaryAssetReset}\n onActiveAssetIdChange={activeAssetId => {\n setPrimaryAsset(primaryAsset => ({ ...primaryAsset, activeWellId: activeAssetId }));\n }}\n isDrillingPlatformApp={isDrillingPlatformApp}\n assetFields={getPrimaryAssetFields(\n primaryAssetType,\n primaryAssetFields,\n isDrillingPlatformApp\n )}\n />\n </div>\n {secondaryAssetSelectIsVisible && (\n <div className={elementsClassNames.secondaryAssetSelect}>\n {secondaryAssetHelpText}\n <SecondaryAssetSelect\n assetFields={\n secondaryAssetType === ASSET_TYPES.pad.type\n ? [...secondaryAssetFields, 'pad.active', 'pad.current']\n : secondaryAssetFields\n }\n activeWellId={primaryAsset?.activeWellId}\n appKey={appKey}\n assetType={secondaryAssetType}\n company={company}\n currentValue={secondaryAssetId}\n data-testid={`${PAGE_NAME}_secondaryAutoComplete`}\n defaultValue={isMultipleAssets ? ACTIVE_ASSETS_ID : ACTIVE_ASSET_ID}\n disabled={isMultipleAssets || isDisabledSecondaryAssetSelect || disabled}\n isDrillingPlatformApp={isDrillingPlatformApp}\n isNullable={isNullable}\n isRequiredAssetId={isRequiredAssetId}\n onChange={onSecondaryAssetChange}\n parentAssetId={parentAssetId}\n parentAssetType={isDrillingPlatformApp ? PARENT_ASSET_ID : primaryAssetType}\n primaryAssetLabel={primaryAssetLabel}\n secondaryAssetLabel={secondaryAssetLabel}\n />\n </div>\n )}\n </div>\n );\n};\n\nAppSettingsAssetEditor.defaultProps = {\n assetsLimit: null,\n label: 'Choose An Asset',\n isNullable: false,\n defaultValue: undefined,\n secondaryDefaultValue: undefined,\n isHiddenTitle: false,\n appKey: null,\n isVisibleMultipleAssetsToggle: false,\n isDisabledSecondaryAssetSelect: false,\n primaryAssetFields: [],\n secondaryAssetFields: [],\n secondaryAssetHelpText: null,\n onChange: noop,\n elementsClassNames: {},\n};\n\nAppSettingsAssetEditor.propTypes = {\n assetsLimit: PropTypes.number,\n settings: PropTypes.shape({}).isRequired,\n appType: PropTypes.shape({}).isRequired,\n defaultValue: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n secondaryDefaultValue: PropTypes.any, // eslint-disable-line react/forbid-prop-types\n onSettingsChange: PropTypes.func.isRequired,\n label: PropTypes.string,\n isNullable: PropTypes.bool,\n isHiddenTitle: PropTypes.bool,\n appKey: PropTypes.string,\n isVisibleMultipleAssetsToggle: PropTypes.bool,\n isDisabledSecondaryAssetSelect: PropTypes.bool,\n primaryAssetFields: PropTypes.arrayOf(PropTypes.shape({})),\n secondaryAssetFields: PropTypes.arrayOf(PropTypes.shape({})),\n secondaryAssetHelpText: PropTypes.oneOfType([PropTypes.element, PropTypes.string]),\n onChange: PropTypes.func,\n elementsClassNames: PropTypes.shape({\n title: PropTypes.string,\n multiAssetSwitch: PropTypes.string,\n primaryAssetSelect: PropTypes.string,\n secondaryAssetSelect: PropTypes.string,\n }),\n};\n\nexport default AppSettingsAssetEditor;\n"],"names":["useStyles","makeStyles","title","fontWeight","fontSize","margin","AppSettingsAssetEditor","_ref","appKey","appType","className","company","defaultValue","secondaryDefaultValue","disabled","isHiddenTitle","isNullable","label","propsOnSettingsChange","onSettingsChange","primaryAssetFields","secondaryAssetFields","isExtendedSelect","isRequiredAssetId","settings","isVisibleMultipleAssetsToggle","assetsLimit","isDisabledSecondaryAssetSelect","isDrillingPlatformApp","secondaryAssetHelpText","onChange","elementsClassNames","primaryAssetType","get","primaryAssetIdType","primaryAssetLabel","primaryAssetSelectGroups","isSecondaryAssetPresent","secondaryAssetType","secondaryAssetIdType","secondaryAssetLabel","currentValue","initialPrimaryAssetId","Number","initialSecondaryAssetId","_useState","useState","id","_useState2","_slicedToArray","primaryAsset","setPrimaryAsset","_useState4","_useState3","secondaryAssetId","setSecondaryAssetId","_useState6","_useState5","isPadSelectedAsPrimaryAsset","setIsPadSelectedAsPrimaryAsset","_useState7","_useState8","selectedGroup","setSelectedGroup","_useState10","_useState9","isMultipleAssets","setIsMultipleAssets","isMultipleAssetsRef","useRef","_len","arguments","length","args","Array","_key","concat","current","styles","PrimaryAssetSelectComponent","ASSET_TYPES","rig","type","intervention_unit","PrimaryAssetSelectV2","PrimaryAssetSelect","parentAssetId","assetId","handlePrimaryAssetReset","_assetSetting4","undefined","assetSetting","_defineProperty","secondaryAssetSelectIsVisible","Boolean","useEffect","isEmpty","_jsxs","classNames","main","children","_jsx","jsx","MultipleAssetsToggle","checked","multiAssetSwitch","primaryAssetSelect","assetType","currentOption","disableClearable","multiple","selected","primary","_selected$","_selected$2","isPadSelected","group","PAD_GROUP","name","isFracFleetSelected","FRAC_FLEET_GROUP","isFirstPadSelected","isFirstFracFleetSelected","assetsSetting","reduce","acc","_ref3","parentFracFleetId","fracFleetId","padId","replacedPadId","assets","asset","onMultipleAssetChange","pad","_assetSetting2","frac_fleet","setCurrentOption","onGroupChange","newGroup","onGroupReset","groups","onInputReset","onActiveAssetIdChange","activeAssetId","_objectSpread","activeWellId","assetFields","getPrimaryAssetFields","jsxs","secondaryAssetSelect","SecondaryAssetSelect","_toConsumableArray","ACTIVE_ASSETS_ID","ACTIVE_ASSET_ID","_ref2","secondary","assetSettings","well","replacedAssetId","parentAssetType","defaultProps","noop","propTypes","PropTypes","number","shape","isRequired","any","func","string","bool","arrayOf","oneOfType","element"],"mappings":"g0DAcA,IAAMA,EAAYC,EAAAA,WAAW,CAC3BC,MAAO,CAAEC,WAAY,IAAKC,SAAU,GAAIC,OAAQ,iBAM5CC,EAAyB,SAwBzBC,GAAA,IAvBJC,IAAAA,OACAC,IAAAA,QACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,aACAC,IAAAA,sBACAC,IAAAA,SACAC,IAAAA,cACAC,IAAAA,WACAC,IAAAA,MACkBC,IAAlBC,iBACAC,IAAAA,mBACAC,IAAAA,qBACAC,IAAAA,iBACAC,IAAAA,kBACAC,IAAAA,SACAC,IAAAA,8BACAC,IAAAA,YACAC,IAAAA,+BACAC,IAAAA,sBACAC,IAAAA,uBACAC,IAAAA,SACAC,IAAAA,mBAEMC,EAAmBC,EAAAA,IAAIxB,EAAS,CAAC,eAAgB,YAAa,SAC9DyB,EAAqBD,EAAAA,IAAIxB,EAAS,CAAC,eAAgB,YAAa,OAChE0B,EAAoBF,EAAAA,IAAIxB,EAAS,CAAC,eAAgB,YAAa,UAC/D2B,EAA2BH,EAAAA,IAAIxB,EAAS,CAAC,eAAgB,WAEzD4B,EAA0BJ,EAAAA,IAAIxB,EAAS,CAAC,mBAAmB,GAE3D6B,EAAqBL,EAAAA,IAAIxB,EAAS,CAAC,iBAAkB,YAAa,SAClE8B,EAAuBN,EAAAA,IAAIxB,EAAS,CAAC,iBAAkB,YAAa,OACpE+B,EAAsBP,EAAAA,IAAIxB,EAAS,CAAC,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AeqJ,EAAS,QAACO,KACzBnK,OAAQ4J,EAAS,QAACM,OAClBjJ,8BAA+B2I,EAAS,QAACO,KACzChJ,+BAAgCyI,EAAS,QAACO,KAC1CvJ,mBAAoBgJ,EAAS,QAACQ,QAAQR,EAAS,QAACE,MAAM,CAAE,IACxDjJ,qBAAsB+I,EAAS,QAACQ,QAAQR,EAAS,QAACE,MAAM,CAAE,IAC1DzI,uBAAwBuI,EAAS,QAACS,UAAU,CAACT,EAAS,QAACU,QAASV,EAAAA,QAAUM,SAC1E5I,SAAUsI,EAAS,QAACK,KACpB1I,mBAAoBqI,EAAS,QAACE,MAAM,CAClCpK,MAAOkK,EAAS,QAACM,OACjBjE,iBAAkB2D,EAAS,QAACM,OAC5BhE,mBAAoB0D,EAAS,QAACM,OAC9BpB,qBAAsBc,EAAS,QAACM"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/toArray"),a=require("@babel/runtime/regenerator"),n=require("react"),i=require("../../componentsV2/FileIcon/FileIcon.js"),s=require("../../componentsV2/Button/Button.js"),c=require("../../componentsV2/LoaderCircular/LoaderCircular.js"),o=require("../NewDocumentViewer/components/TextViewer.js"),u=require("../NewDocumentViewer/components/CsvViewer.js"),l=require("../NewDocumentViewer/components/PdfViewer.js"),d=require("../NewDocumentViewer/utils.js"),f=require("./downloadAttachment.js"),m=require("./AttachmentLightbox.scss.js"),p=require("../../utils/fetchAttachment.js"),x=require("../../utils/fileExtension.js"),b=require("../../utils/main.js"),h=require("react/jsx-runtime");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var w=v(e),j=v(t),k=v(r),q=v(a),N={pdf:"pdf",csv:"table",xlsx:"table",txt:"text",json:"text"},g=function(e){var t=k.default(e),r=t[0],a=void 0===r?[]:r,n=t.slice(1),i=function(e){var t=new Map;return e.map((function(e,r){var a,n=e||"Column ".concat(r+1),i=null!==(a=t.get(n))&&void 0!==a?a:0;return t.set(n,i+1),i?"".concat(n," (").concat(i+1,")"):n}))}(a);return n.map((function(e){return Object.fromEntries(i.map((function(t,r){var a;return[t,null!==(a=e[r])&&void 0!==a?a:""]})))}))},L=function(){var e=j.default(q.default.mark((function e(t,r){var a,n;return q.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("pdf"!==r){e.next=7;break}return e.next=3,p.fetchAttachment(t);case 3:return e.next=5,e.sent.blob();case 5:return n=e.sent,e.abrupt("return",URL.createObjectURL(n.type?n:new Blob([n],{type:"application/pdf"})));case 7:if("csv"!==r){e.next=9;break}return e.abrupt("return",d.getCsvData(t));case 9:if("xlsx"!==r){e.next=24;break}return e.t0=g,e.next=13,d.getXlsxData(t);case 13:if(e.t2=a=e.sent,e.t1=null!==e.t2,!e.t1){e.next=17;break}e.t1=void 0!==a;case 17:if(!e.t1){e.next=21;break}e.t3=a,e.next=22;break;case 21:e.t3=[];case 22:return e.t4=e.t3,e.abrupt("return",(0,e.t0)(e.t4));case 24:return e.abrupt("return",d.getTextData(t));case 25:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),F=["pdf","text","table"];exports.AttachmentDocument=function(e){var t=e.item,r=b.default.getFileNameWithExtensionFromPath(t.name),a=x.getFileExtension(r),d=t.src||t.downloadUrl||"",p=N[a],v=function(e,t,r){var a=n.useState((function(){return{data:"",isLoading:!!e&&F.includes(r),hasFailed:!1}})),i=w.default(a,2),s=i[0],c=i[1];return n.useEffect((function(){if(e&&F.includes(r)){var a=!0;c({data:"",isLoading:!0,hasFailed:!1});var n="";return L(e,t).then((function(e){"pdf"===r&&(n=e),a?c({data:e,isLoading:!1,hasFailed:!1}):n&&URL.revokeObjectURL(n)})).catch((function(t){console.error('Failed to read attachment "'.concat(e,'"'),t),a&&c({data:"",isLoading:!1,hasFailed:!0})})),function(){a=!1,n&&URL.revokeObjectURL(n)}}c({data:"",isLoading:!1,hasFailed:!1})}),[e,t,r]),s}(d,a,p),k=v.data,g=v.isLoading,D=v.hasFailed;if(g)return h.jsx("div",{className:m.documentState,"data-testid":"attachment-preview-loading",children:h.jsx(c.LoaderCircular,{size:"medium"})});var V=!!d&&!D;if(V&&"pdf"===p)return h.jsx("div",{className:m.documentFrame,children:h.jsx(l.PdfViewer,{fileUrl:k,fileName:r})});if(V&&"table"===p)return h.jsx("div",{className:m.documentTable,children:h.jsx(u.CsvViewer,{fileData:k})});if(V&&"text"===p)return h.jsx("div",{className:m.documentText,children:h.jsx(o.TextViewer,{fileData:k})});var y=D||!d&&!!p;return h.jsxs("div",{className:m.documentState,"data-testid":"attachment-preview-fallback",children:[h.jsx(i.FileIcon,{name:r,size:48}),h.jsx("div",{className:m.fallbackName,children:r}),h.jsx("div",{className:m.fallbackHint,children:y?"This file could not be opened.":"No preview available for this file type."}),!(!t.downloadUrl&&!t.src)&&h.jsx("a",{href:t.downloadUrl||t.src,download:r,target:"_blank",rel:"noopener noreferrer",className:m.fallbackDownload,"data-testid":"attachment-preview-fallback-download",onClick:function(){var e=j.default(q.default.mark((function e(a){var n;return q.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.downloadUrl||t.src||"",a.preventDefault(),e.next=4,f.downloadAttachment(n,r);case 4:if(e.sent){e.next=6;break}f.openAttachmentInNewTab(n);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),children:h.jsx(s.Button,{type:"secondary",size:"medium",children:"Download"})})]})};
2
+ //# sourceMappingURL=AttachmentDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachmentDocument.js","sources":["../../../../src/components/AttachmentLightbox/AttachmentDocument.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { FileIcon } from '../../componentsV2/FileIcon';\nimport { Button } from '../../componentsV2/Button';\nimport { LoaderCircular } from '../../componentsV2/LoaderCircular';\nimport { CsvViewer, PdfViewer, TextViewer } from '../NewDocumentViewer/components';\nimport { getCsvData, getTextData, getXlsxData } from '../NewDocumentViewer/utils';\nimport type { AttachmentPreviewItem } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport { downloadAttachment, openAttachmentInNewTab } from './downloadAttachment';\n\nimport styles from './AttachmentLightbox.scss';\n\nimport { fetchAttachment } from '~/utils/fetchAttachment';\nimport { getFileExtension } from '~/utils/fileExtension';\nimport utils from '~/utils/main';\n\nconst RENDERERS = {\n pdf: 'pdf',\n csv: 'table',\n xlsx: 'table',\n txt: 'text',\n json: 'text',\n} as const;\n\ntype Renderer = typeof RENDERERS[keyof typeof RENDERERS];\n\ntype TableRow = Record<string, unknown>;\n\n/** The table viewer keys cells off the first row, so every column needs its own name. */\nconst toColumnNames = (header: string[]): string[] => {\n const seen = new Map<string, number>();\n\n return header.map((column, index) => {\n const name = column || `Column ${index + 1}`;\n const taken = seen.get(name) ?? 0;\n\n seen.set(name, taken + 1);\n\n return taken ? `${name} (${taken + 1})` : name;\n });\n};\n\nconst toTableRows = (rows: string[][]): TableRow[] => {\n const [header = [], ...body] = rows;\n const columns = toColumnNames(header);\n\n return body.map(row =>\n Object.fromEntries(columns.map((column, index) => [column, row[index] ?? '']))\n );\n};\n\nconst fetchData = async (src: string, extension: string) => {\n if (extension === 'pdf') {\n // The host serves this as a download, which navigates a frame to `about:blank` and shows\n // nothing. Holding the bytes ourselves lets the viewer render them whatever it was sent as.\n const blob = await (await fetchAttachment(src)).blob();\n\n return URL.createObjectURL(blob.type ? blob : new Blob([blob], { type: 'application/pdf' }));\n }\n if (extension === 'csv') return getCsvData(src);\n if (extension === 'xlsx') return toTableRows((await getXlsxData(src)) ?? []);\n\n return getTextData(src);\n};\n\nconst NEEDS_DATA: Renderer[] = ['pdf', 'text', 'table'];\nconst useDocumentData = (src: string, extension: string, renderer?: Renderer) => {\n const [state, setState] = useState<{\n data: string | TableRow[];\n isLoading: boolean;\n hasFailed: boolean;\n }>(() => ({\n data: '',\n isLoading: !!src && NEEDS_DATA.includes(renderer as Renderer),\n hasFailed: false,\n }));\n\n useEffect(() => {\n if (!src || !NEEDS_DATA.includes(renderer as Renderer)) {\n setState({ data: '', isLoading: false, hasFailed: false });\n\n return undefined;\n }\n\n let isActive = true;\n setState({ data: '', isLoading: true, hasFailed: false });\n\n let objectUrl = '';\n\n fetchData(src, extension)\n .then(data => {\n if (renderer === 'pdf') objectUrl = data as string;\n\n if (isActive) {\n setState({ data: data as string | TableRow[], isLoading: false, hasFailed: false });\n } else if (objectUrl) {\n URL.revokeObjectURL(objectUrl);\n }\n })\n .catch(error => {\n console.error(`Failed to read attachment \"${src}\"`, error);\n if (isActive) setState({ data: '', isLoading: false, hasFailed: true });\n });\n\n return () => {\n isActive = false;\n if (objectUrl) URL.revokeObjectURL(objectUrl);\n };\n }, [src, extension, renderer]);\n\n return state;\n};\n\nexport type AttachmentDocumentProps = {\n item: AttachmentPreviewItem;\n};\n\nexport const AttachmentDocument = ({ item }: AttachmentDocumentProps) => {\n const fileName = utils.getFileNameWithExtensionFromPath(item.name);\n const extension = getFileExtension(fileName);\n const src = item.src || item.downloadUrl || '';\n const renderer: Renderer | undefined = RENDERERS[extension as keyof typeof RENDERERS];\n\n const { data, isLoading, hasFailed } = useDocumentData(src, extension, renderer);\n\n if (isLoading) {\n return (\n <div className={styles.documentState} data-testid=\"attachment-preview-loading\">\n <LoaderCircular size=\"medium\" />\n </div>\n );\n }\n\n const isRenderable = !!src && !hasFailed;\n\n if (isRenderable && renderer === 'pdf') {\n return (\n <div className={styles.documentFrame}>\n <PdfViewer fileUrl={data as string} fileName={fileName} />\n </div>\n );\n }\n\n if (isRenderable && renderer === 'table') {\n return (\n <div className={styles.documentTable}>\n <CsvViewer fileData={data as TableRow[]} />\n </div>\n );\n }\n\n if (isRenderable && renderer === 'text') {\n return (\n <div className={styles.documentText}>\n <TextViewer fileData={data as string} />\n </div>\n );\n }\n\n const isUnopenable = hasFailed || (!src && !!renderer);\n\n return (\n <div className={styles.documentState} data-testid=\"attachment-preview-fallback\">\n <FileIcon name={fileName} size={48} />\n <div className={styles.fallbackName}>{fileName}</div>\n <div className={styles.fallbackHint}>\n {isUnopenable\n ? 'This file could not be opened.'\n : 'No preview available for this file type.'}\n </div>\n {!!(item.downloadUrl || item.src) && (\n <a\n href={item.downloadUrl || item.src}\n download={fileName}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={styles.fallbackDownload}\n data-testid=\"attachment-preview-fallback-download\"\n onClick={async event => {\n const url = item.downloadUrl || item.src || '';\n event.preventDefault();\n\n if (!(await downloadAttachment(url, fileName))) openAttachmentInNewTab(url);\n }}\n >\n <Button type=\"secondary\" size=\"medium\">\n Download\n </Button>\n </a>\n )}\n </div>\n );\n};\n"],"names":["RENDERERS","pdf","csv","xlsx","txt","json","toTableRows","rows","_rows","_toArray","_rows$","header","body","slice","columns","seen","Map","map","column","index","_seen$get","name","taken","get","set","concat","toColumnNames","row","Object","fromEntries","_row$index","fetchData","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","src","extension","_yield$getXlsxData","blob","wrap","_context","prev","next","fetchAttachment","sent","abrupt","URL","createObjectURL","type","Blob","getCsvData","t0","getXlsxData","t2","t1","t3","t4","getTextData","stop","_x","_x2","apply","this","arguments","NEEDS_DATA","_ref2","item","fileName","utils","getFileNameWithExtensionFromPath","getFileExtension","downloadUrl","renderer","_useDocumentData","_useState","useState","data","isLoading","includes","hasFailed","_useState2","_slicedToArray","state","setState","useEffect","isActive","objectUrl","then","revokeObjectURL","catch","error","console","useDocumentData","_jsx","className","styles","documentState","children","LoaderCircular","size","isRenderable","documentFrame","PdfViewer","fileUrl","documentTable","CsvViewer","fileData","documentText","TextViewer","isUnopenable","_jsxs","FileIcon","jsx","fallbackName","fallbackHint","href","download","target","rel","fallbackDownload","onClick","_ref3","event","url","_context2","preventDefault","downloadAttachment","openAttachmentInNewTab","_callee2","_x3","Button"],"mappings":"o+BAiBMA,EAAY,CAChBC,IAAK,MACLC,IAAK,QACLC,KAAM,QACNC,IAAK,O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hD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@material-ui/core"),t=require("./AttachmentLightbox.scss.js"),s=require("react/jsx-runtime");exports.AttachmentLightbox=function(a){var r,i=a.attachment,n=a.onClose,o=a.testId;return s.jsxs(e.Dialog,{open:!!i,onClose:n,maxWidth:!1,classes:{paper:t.paper},"data-testid":o,children:[!i&&s.jsx("span",{}),"video"===(null==i?void 0:i.kind)&&s.jsx("video",{src:i.src,className:t.media,controls:!0,autoPlay:!0,playsInline:!0}),!!i&&"video"!==i.kind&&s.jsx("img",{src:i.src,alt:null!==(r=i.name)&&void 0!==r?r:"Attachment",className:t.media})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var s=require("react"),o=require("../../componentsV2/Modal/Modal.js"),c=require("../../componentsV2/ButtonIcon/ButtonIcon.js"),e=require("../AttachmentPreview/AttachmentRow.js"),n=require("./AttachmentPreviewPane.js"),i=require("./AttachmentLightbox.scss.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("react/jsx-runtime");exports.AttachmentLightbox=function(u){var a=u.items,m=u.activeId,I=u.onActiveIdChange,l=u.onClose,j=u.onShare,q=u.title,d=void 0===q?"Files":q,h=u.testId,p=a.findIndex((function(s){return s.id===m})),v=-1===p?void 0:a[p],C=s.useCallback((function(s){var o=a[p+s];o&&I(o.id)}),[a,p,I]);s.useEffect((function(){if(v){var s=function(s){if(!s.defaultPrevented){var o=s.target;"function"==typeof(null==o?void 0:o.closest)&&o.closest('video, audio, input, textarea, [role="menu"]')||("ArrowLeft"===s.key&&C(-1),"ArrowRight"===s.key&&C(1))}};return document.addEventListener("keydown",s),function(){return document.removeEventListener("keydown",s)}}}),[v,C]);var x=a.length>1?t.jsxs("div",{className:i.strip,children:[t.jsx(c.ButtonIcon,{size:"large",ariaLabel:"Previous attachment",disabled:p<=0,onClick:function(){return C(-1)},testId:"attachment-lightbox-prev",children:t.jsx(r.LeftIcon,{})}),t.jsx(e.AttachmentRow,{items:a,selectedId:null!=m?m:void 0,hideActions:!0,onItemClick:function(s){return I(s.id)},className:i.stripRow,testId:"attachment-lightbox-strip"}),t.jsx(c.ButtonIcon,{size:"large",ariaLabel:"Next attachment",disabled:-1===p||p>=a.length-1,onClick:function(){return C(1)},testId:"attachment-lightbox-next",children:t.jsx(r.RightIcon,{})})]}):void 0;return t.jsx(o.Modal,{open:!!v,size:"fullscreen",title:d,onClose:l,actions:x,testId:h,children:!!v&&t.jsx(n.AttachmentPreviewPane,{item:v,onShare:j})})};
2
2
  //# sourceMappingURL=AttachmentLightbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentLightbox.js","sources":["../../../../src/components/AttachmentLightbox/AttachmentLightbox.tsx"],"sourcesContent":["import { Dialog } from '@material-ui/core';\n\nimport type { AttachmentKind } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport styles from './AttachmentLightbox.scss';\n\nexport type LightboxAttachment = {\n src: string;\n name?: string;\n kind?: AttachmentKind;\n};\n\nexport type AttachmentLightboxProps = {\n /** `null` keeps the lightbox closed. */\n attachment: LightboxAttachment | null;\n onClose: () => void;\n testId?: string;\n};\n\nexport const AttachmentLightbox = ({ attachment, onClose, testId }: AttachmentLightboxProps) => (\n <Dialog\n open={!!attachment}\n onClose={onClose}\n maxWidth={false}\n classes={{ paper: styles.paper }}\n data-testid={testId}\n >\n {!attachment && <span />}\n\n {attachment?.kind === 'video' && (\n // eslint-disable-next-line jsx-a11y/media-has-caption\n <video src={attachment.src} className={styles.media} controls autoPlay playsInline />\n )}\n\n {!!attachment && attachment.kind !== 'video' && (\n <img src={attachment.src} alt={attachment.name ?? 'Attachment'} className={styles.media} />\n )}\n </Dialog>\n);\n"],"names":["_ref","_attachment$name","attachment","onClose","testId","_jsxs","Dialog","open","maxWidth","classes","paper","styles","children","_jsx","jsx","kind","src","className","media","controls","autoPlay","playsInline","alt","name"],"mappings":"2MAmBkC,SAAHA,GAAA,IAAAC,EAAMC,IAAAA,WAAYC,IAAAA,QAASC,IAAAA,OAAM,OAC9DC,EAAAA,KAACC,EAAAA,OAAM,CACLC,OAAQL,EACRC,QAASA,EACTK,UAAU,EACVC,QAAS,CAAEC,MAAOC,EAAOD,OACzB,cAAaN,EAAOQ,SAAA,EAElBV,GAAcW,EAAAC,IAAA,OAAA,CAAA,GAEM,WAArBZ,aAAAA,EAAAA,EAAYa,OAEXF,EAAAA,IAAA,QAAA,CAAOG,IAAKd,EAAWc,IAAKC,UAAWN,EAAOO,MAAOC,UAAQ,EAACC,UAAQ,EAACC,aAAW,MAGjFnB,GAAkC,UAApBA,EAAWa,MAC1BF,EAAAC,IAAA,MAAA,CAAKE,IAAKd,EAAWc,IAAKM,YAAKpB,EAAAA,EAAWqB,oBAAQ,aAAcN,UAAWN,EAAOO,UAE7E"}
1
+ {"version":3,"file":"AttachmentLightbox.js","sources":["../../../../src/components/AttachmentLightbox/AttachmentLightbox.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect } from 'react';\n\nimport { Modal } from '../../componentsV2/Modal';\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { AttachmentRow } from '../AttachmentPreview/AttachmentRow';\nimport type { AttachmentPreviewItem } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport { AttachmentPreviewPane } from './AttachmentPreviewPane';\n\nimport styles from './AttachmentLightbox.scss';\n\nimport { LeftIcon, RightIcon } from '~/icons';\n\nexport type AttachmentLightboxProps = {\n items: AttachmentPreviewItem[];\n /** `null` keeps the lightbox closed. */\n activeId: AttachmentPreviewItem['id'] | null;\n onActiveIdChange: (id: AttachmentPreviewItem['id']) => void;\n onClose: () => void;\n /** Adds \"Share file\" to the overflow menu. */\n onShare?: (item: AttachmentPreviewItem) => void;\n title?: ReactNode;\n testId?: string;\n};\n\nexport const AttachmentLightbox = ({\n items,\n activeId,\n onActiveIdChange,\n onClose,\n onShare,\n title = 'Files',\n testId,\n}: AttachmentLightboxProps) => {\n const activeIndex = items.findIndex(item => item.id === activeId);\n const active = activeIndex === -1 ? undefined : items[activeIndex];\n\n const step = useCallback(\n (delta: number) => {\n const next = items[activeIndex + delta];\n\n if (next) onActiveIdChange(next.id);\n },\n [items, activeIndex, onActiveIdChange]\n );\n\n useEffect(() => {\n if (!active) return undefined;\n\n const handleKeyDown = (event: KeyboardEvent) => {\n // A focused <video> seeks with the arrows; only steer when nothing nearer claims the key.\n if (event.defaultPrevented) return;\n\n // With nothing focused the target is the document, which has no `closest`.\n const target = event.target as Element | null;\n\n if (\n typeof target?.closest === 'function' &&\n target.closest('video, audio, input, textarea, [role=\"menu\"]')\n ) {\n return;\n }\n\n if (event.key === 'ArrowLeft') step(-1);\n if (event.key === 'ArrowRight') step(1);\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [active, step]);\n\n const strip =\n items.length > 1 ? (\n <div className={styles.strip}>\n <ButtonIcon\n size=\"large\"\n ariaLabel=\"Previous attachment\"\n disabled={activeIndex <= 0}\n onClick={() => step(-1)}\n testId=\"attachment-lightbox-prev\"\n >\n <LeftIcon />\n </ButtonIcon>\n\n <AttachmentRow\n items={items}\n selectedId={activeId ?? undefined}\n hideActions\n onItemClick={item => onActiveIdChange(item.id)}\n className={styles.stripRow}\n testId=\"attachment-lightbox-strip\"\n />\n\n <ButtonIcon\n size=\"large\"\n ariaLabel=\"Next attachment\"\n disabled={activeIndex === -1 || activeIndex >= items.length - 1}\n onClick={() => step(1)}\n testId=\"attachment-lightbox-next\"\n >\n <RightIcon />\n </ButtonIcon>\n </div>\n ) : undefined;\n\n return (\n <Modal\n open={!!active}\n size=\"fullscreen\"\n title={title}\n onClose={onClose}\n actions={strip}\n testId={testId}\n >\n {!!active && <AttachmentPreviewPane item={active} onShare={onShare} />}\n </Modal>\n );\n};\n"],"names":["_ref","items","activeId","onActiveIdChange","onClose","onShare","_ref$title","title","testId","activeIndex","findIndex","item","id","active","undefined","step","useCallback","delta","next","useEffect","handleKeyDown","event","defaultPrevented","target","closest","key","document","addEventListener","removeEventListener","strip","length","_jsxs","className","styles","children","_jsx","ButtonIcon","size","ariaLabel","disabled","onClick","LeftIcon","AttachmentRow","selectedId","hideActions","onItemClick","stripRow","RightIcon","Modal","open","actions","AttachmentPreviewPane"],"mappings":"stIAyBkC,SAQHA,GAAA,IAP7BC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,iBACAC,IAAAA,QACAC,IAAAA,QAAOC,EAAAN,EACPO,MAAAA,aAAQ,QAAOD,EACfE,IAAAA,OAEMC,EAAcR,EAAMS,WAAU,SAAAC,GAAI,OAAIA,EAAKC,KAAOV,KACl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CACJC,OAAQpC,EACRwB,KAAK,aACL9B,MAAOA,EACPH,QAASA,EACT8C,QAASrB,EACTrB,OAAQA,EAAO0B,WAEZrB,GAAUsB,EAAAA,IAACgB,EAAAA,sBAAqB,CAACxC,KAAME,EAAQR,QAASA,KAGjE"}
@@ -1,2 +1,2 @@
1
- "use strict";require('./../../ext-esm/style-inject/dist/style-inject.es.js')(".AttachmentLightbox_paper__sWaTp{background:transparent;box-shadow:none;margin:0}.AttachmentLightbox_media__CElIX{display:block;max-height:90vh;max-width:90vw}"),module.exports={paper:"AttachmentLightbox_paper__sWaTp",media:"AttachmentLightbox_media__CElIX"};
1
+ "use strict";require('./../../ext-esm/style-inject/dist/style-inject.es.js')(".AttachmentLightbox_strip__6Ahrc{align-items:center;display:flex;flex:1;gap:8px;justify-content:center;min-width:0}.AttachmentLightbox_stripRow__uue68.AttachmentLightbox_stripRow__uue68{flex:0 1 auto;gap:8px;justify-content:flex-start}.AttachmentLightbox_pane__KzcgJ{background:rgb(from var(--palette-primary-text-1) r g b/.02);border-radius:8px;display:flex;flex-direction:column;height:100%;padding:8px 16px 16px;position:relative}.AttachmentLightbox_paneHeader__Z6qqZ{align-items:center;display:flex;gap:16px;justify-content:space-between;padding:4px 0}.AttachmentLightbox_paneName__wHaha{display:flex;flex-direction:column;justify-content:center;min-width:0}.AttachmentLightbox_paneFileName__Ans-0{color:var(--palette-primary-text-1);font-size:16px;font-weight:500;line-height:22px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.AttachmentLightbox_paneFileSize__kHpFZ{color:var(--palette-primary-text-6);font-size:12px;line-height:16px}.AttachmentLightbox_paneActions__HYZPg{align-items:center;display:flex;flex-shrink:0;gap:8px}.AttachmentLightbox_paneActionLink__ij8qw{color:inherit;display:inline-flex;text-decoration:none}.AttachmentLightbox_paneViewport__eNxCs{display:flex;flex:1;margin-top:8px;min-height:0;overflow:auto}.AttachmentLightbox_paneViewportPannable__aioSN{cursor:grab}.AttachmentLightbox_paneViewportPanning__ZN5R3{cursor:grabbing;user-select:none}.AttachmentLightbox_paneZoomBox__Z1Ccd{display:flex;flex:none;height:calc(100%*var(--attachment-zoom, 1));width:calc(100%*var(--attachment-zoom, 1))}.AttachmentLightbox_paneMedia__nXjJ0{-webkit-user-drag:none;border-radius:8px;height:100%;object-fit:contain;user-select:none;width:100%}.AttachmentLightbox_paneZoomControls__y7ImM{bottom:8px;display:flex;flex-direction:column;gap:8px;position:absolute;right:8px;z-index:2}.AttachmentLightbox_paneZoomButton__kndeG{display:inline-flex}.AttachmentLightbox_documentFrame__-AP36,.AttachmentLightbox_documentTable__vMkX5,.AttachmentLightbox_documentText__Tn8b7{border-radius:8px;height:100%;overflow:auto;position:relative;width:100%}.AttachmentLightbox_documentText__Tn8b7{color:var(--palette-primary-text-1);font-size:14px;line-height:20px;padding:16px}.AttachmentLightbox_documentText__Tn8b7 pre{font-family:inherit;margin:0;white-space:pre-wrap;word-break:break-word}.AttachmentLightbox_documentTable__vMkX5{color:var(--palette-primary-text-1)}.AttachmentLightbox_documentState__h-iDd{align-items:center;display:flex;flex-direction:column;gap:8px;justify-content:center;margin:auto;padding:24px;text-align:center}.AttachmentLightbox_fallbackName__JO0HH{color:var(--palette-primary-text-1);font-size:16px;line-height:22px;margin-top:8px;word-break:break-word}.AttachmentLightbox_fallbackHint__tPWNV{color:var(--palette-primary-text-6);font-size:14px;line-height:20px;margin-bottom:8px}.AttachmentLightbox_fallbackDownload__Noq5-{text-decoration:none}"),module.exports={spacing:"8",strip:"AttachmentLightbox_strip__6Ahrc",stripRow:"AttachmentLightbox_stripRow__uue68",pane:"AttachmentLightbox_pane__KzcgJ",paneHeader:"AttachmentLightbox_paneHeader__Z6qqZ",paneName:"AttachmentLightbox_paneName__wHaha",paneFileName:"AttachmentLightbox_paneFileName__Ans-0",paneFileSize:"AttachmentLightbox_paneFileSize__kHpFZ",paneActions:"AttachmentLightbox_paneActions__HYZPg",paneActionLink:"AttachmentLightbox_paneActionLink__ij8qw",paneViewport:"AttachmentLightbox_paneViewport__eNxCs",paneViewportPannable:"AttachmentLightbox_paneViewportPannable__aioSN",paneViewportPanning:"AttachmentLightbox_paneViewportPanning__ZN5R3",paneZoomBox:"AttachmentLightbox_paneZoomBox__Z1Ccd",paneMedia:"AttachmentLightbox_paneMedia__nXjJ0",paneZoomControls:"AttachmentLightbox_paneZoomControls__y7ImM",paneZoomButton:"AttachmentLightbox_paneZoomButton__kndeG",documentFrame:"AttachmentLightbox_documentFrame__-AP36",documentTable:"AttachmentLightbox_documentTable__vMkX5",documentText:"AttachmentLightbox_documentText__Tn8b7",documentState:"AttachmentLightbox_documentState__h-iDd",fallbackName:"AttachmentLightbox_fallbackName__JO0HH",fallbackHint:"AttachmentLightbox_fallbackHint__tPWNV",fallbackDownload:"AttachmentLightbox_fallbackDownload__Noq5-"};
2
2
  //# sourceMappingURL=AttachmentLightbox.scss.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var s=require("@babel/runtime/helpers/defineProperty"),e=require("react"),o=require("classnames"),c=require("../../componentsV2/ButtonIcon/ButtonIcon.js"),n=require("../../componentsV2/Tooltip/Tooltip.js"),i=require("../AttachmentPreview/AttachmentActionsMenu.js"),r=require("../AttachmentPreview/AttachmentImage.js"),t=require("../AttachmentPreview/AttachmentDownloadLink.js"),u=require("./AttachmentDocument.js"),a=require("./useZoomPan.js"),m=require("./AttachmentLightbox.scss.js"),l=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 j=require("../../utils/formatFileSize.js"),d=require("../../utils/main.js"),p=require("react/jsx-runtime");function q(s){return s&&"object"==typeof s&&"default"in s?s:{default:s}}var I=q(s),h=q(o);function v(s,e){var o=Object.keys(s);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);e&&(c=c.filter((function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),o.push.apply(o,c)}return o}function b(s){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?v(Object(o),!0).forEach((function(e){I.default(s,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach((function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(o,e))}))}return s}exports.AttachmentPreviewPane=function(s){var o,q=s.item,I=s.onShare,v=e.useRef(null),f=null!==(o=q.kind)&&void 0!==o?o:"file",O="image"===f||"video"===f,P=a.useZoomPan({canZoom:O,canPan:"image"===f,resetKey:q.id}),x=P.viewportRef,g=P.zoom,A=P.zoomIn,C=P.zoomOut,y=P.canZoomIn,w=P.canZoomOut,F=P.isPannable,N=P.isPanning,z=P.panHandlers,k=d.default.getFileNameWithExtensionFromPath(q.name),D=q.downloadUrl||q.src;return p.jsxs("div",{className:m.pane,"data-testid":"attachment-preview-pane",children:[p.jsxs("div",{className:m.paneHeader,children:[p.jsxs("div",{className:m.paneName,children:[p.jsx("div",{className:m.paneFileName,title:k,children:k}),void 0!==q.size&&p.jsx("div",{className:m.paneFileSize,children:j.formatFileSize(q.size)})]}),p.jsxs("div",{className:m.paneActions,children:[!!D&&p.jsx(t.AttachmentDownloadLink,{url:D,fileName:k,className:m.paneActionLink,testId:"attachment-preview-download"}),p.jsx(i.AttachmentActionsMenu,{item:q,onShare:I,imageRef:v})]})]}),p.jsx("div",b(b({className:h.default(m.paneViewport,F&&m.paneViewportPannable,N&&m.paneViewportPanning),ref:x},z),{},{children:p.jsxs("div",{className:m.paneZoomBox,style:{"--attachment-zoom":g},"data-testid":"attachment-preview-zoom-box",children:["image"===f&&p.jsx(r.AttachmentImage,{ref:v,src:q.src,alt:k,className:m.paneMedia,draggable:!1}),"video"===f&&p.jsx("video",{src:q.src,className:m.paneMedia,controls:!0,autoPlay:!0,playsInline:!0}),"file"===f&&p.jsx(u.AttachmentDocument,{item:q},q.id)]})})),O&&p.jsxs("div",{className:m.paneZoomControls,children:[p.jsx(n.Tooltip,{title:"Zoom in",placement:"left",children:p.jsx("span",{className:m.paneZoomButton,children:p.jsx(c.ButtonIcon,{size:"small",type:"tertiaryBg",ariaLabel:"Zoom in",disabled:!y,onClick:A,testId:"attachment-preview-zoom-in",children:p.jsx(l.PlusIcon,{})})})}),p.jsx(n.Tooltip,{title:"Zoom out",placement:"left",children:p.jsx("span",{className:m.paneZoomButton,children:p.jsx(c.ButtonIcon,{size:"small",type:"tertiaryBg",ariaLabel:"Zoom out",disabled:!w,onClick:C,testId:"attachment-preview-zoom-out",children:p.jsx(l.MinusIcon,{})})})})]})]})};
2
+ //# sourceMappingURL=AttachmentPreviewPane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachmentPreviewPane.js","sources":["../../../../src/components/AttachmentLightbox/AttachmentPreviewPane.tsx"],"sourcesContent":["import { CSSProperties, useRef } from 'react';\nimport classNames from 'classnames';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { AttachmentActionsMenu } from '../AttachmentPreview/AttachmentActionsMenu';\nimport { AttachmentImage } from '../AttachmentPreview/AttachmentImage';\nimport { AttachmentDownloadLink } from '../AttachmentPreview/AttachmentDownloadLink';\nimport type { AttachmentPreviewItem } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport { AttachmentDocument } from './AttachmentDocument';\nimport { useZoomPan } from './useZoomPan';\n\nimport styles from './AttachmentLightbox.scss';\n\nimport { MinusIcon, PlusIcon } from '~/icons';\nimport { formatFileSize } from '~/utils/formatFileSize';\nimport utils from '~/utils/main';\n\nexport type AttachmentPreviewPaneProps = {\n item: AttachmentPreviewItem;\n /** Adds \"Share file\" to the overflow menu. */\n onShare?: (item: AttachmentPreviewItem) => void;\n};\n\n/** Zoom is media-only — document viewers scroll and zoom on their own. */\nexport const AttachmentPreviewPane = ({ item, onShare }: AttachmentPreviewPaneProps) => {\n const imageRef = useRef<HTMLImageElement>(null);\n const kind = item.kind ?? 'file';\n const isMedia = kind === 'image' || kind === 'video';\n\n const {\n viewportRef,\n zoom,\n zoomIn,\n zoomOut,\n canZoomIn,\n canZoomOut,\n isPannable,\n isPanning,\n panHandlers,\n // Panning a zoomed <video> would swallow its own controls, so only images get the drag.\n } = useZoomPan({ canZoom: isMedia, canPan: kind === 'image', resetKey: item.id });\n\n const fileName = utils.getFileNameWithExtensionFromPath(item.name);\n const downloadUrl = item.downloadUrl || item.src;\n\n return (\n <div className={styles.pane} data-testid=\"attachment-preview-pane\">\n <div className={styles.paneHeader}>\n <div className={styles.paneName}>\n <div className={styles.paneFileName} title={fileName}>\n {fileName}\n </div>\n {item.size !== undefined && (\n <div className={styles.paneFileSize}>{formatFileSize(item.size)}</div>\n )}\n </div>\n\n <div className={styles.paneActions}>\n {!!downloadUrl && (\n <AttachmentDownloadLink\n url={downloadUrl}\n fileName={fileName}\n className={styles.paneActionLink}\n testId=\"attachment-preview-download\"\n />\n )}\n\n <AttachmentActionsMenu item={item} onShare={onShare} imageRef={imageRef} />\n </div>\n </div>\n\n <div\n className={classNames(\n styles.paneViewport,\n isPannable && styles.paneViewportPannable,\n isPanning && styles.paneViewportPanning\n )}\n ref={viewportRef}\n {...panHandlers}\n >\n <div\n className={styles.paneZoomBox}\n style={{ '--attachment-zoom': zoom } as CSSProperties}\n data-testid=\"attachment-preview-zoom-box\"\n >\n {kind === 'image' && (\n <AttachmentImage\n ref={imageRef}\n src={item.src}\n alt={fileName}\n className={styles.paneMedia}\n draggable={false}\n />\n )}\n\n {kind === 'video' && (\n // eslint-disable-next-line jsx-a11y/media-has-caption\n <video src={item.src} className={styles.paneMedia} controls autoPlay playsInline />\n )}\n\n {/* Keyed: a kept-alive instance would pair the previous file's data with the new\n renderer for one render. */}\n {kind === 'file' && <AttachmentDocument key={item.id} item={item} />}\n </div>\n </div>\n\n {isMedia && (\n <div className={styles.paneZoomControls}>\n {/* A disabled button fires no events, so the tooltip listens on a wrapper instead. */}\n <Tooltip title=\"Zoom in\" placement=\"left\">\n <span className={styles.paneZoomButton}>\n <ButtonIcon\n size=\"small\"\n type=\"tertiaryBg\"\n ariaLabel=\"Zoom in\"\n disabled={!canZoomIn}\n onClick={zoomIn}\n testId=\"attachment-preview-zoom-in\"\n >\n <PlusIcon />\n </ButtonIcon>\n </span>\n </Tooltip>\n\n <Tooltip title=\"Zoom out\" placement=\"left\">\n <span className={styles.paneZoomButton}>\n <ButtonIcon\n size=\"small\"\n type=\"tertiaryBg\"\n ariaLabel=\"Zoom out\"\n disabled={!canZoomOut}\n onClick={zoomOut}\n testId=\"attachment-preview-zoom-out\"\n >\n <MinusIcon />\n </ButtonIcon>\n </span>\n </Tooltip>\n </div>\n )}\n </div>\n );\n};\n"],"names":["_ref","_item$kind","item","onShare","imageRef","useRef","kind","isMedia","_useZoomPan","useZoomPan","canZoom","canPan","resetKey","id","viewportRef","zoom","zoomIn","zoomOut","canZoomIn","canZoomOut","isPannable","isPanning","panHandlers","fileName","utils","getFileNameWithExtensionFromPath","name","downloadUrl","src","_jsxs","className","styles","pane","children","jsxs","paneHeader","paneName","_jsx","jsx","paneFileName","title","undefined","size","paneFileSize","formatFileSize","paneActions","AttachmentDownloadLink","url","paneActionLink","testId","AttachmentActionsMenu","_objectSpread","classNames","paneViewport","paneViewportPannable","paneViewportPanning","ref","paneZoomBox","style","AttachmentImage","alt","paneMedia","draggable","controls","autoPlay","playsInline","AttachmentDocument","paneZoomControls","Tooltip","placement","paneZoomButton","ButtonIcon","type","ariaLabel","disabled","onClick","PlusIcon","MinusIcon"],"mappings":"wqKA0BqC,SAAmDA,GAAA,IAAAC,EAAhDC,IAAAA,KAAMC,IAAAA,QACtCC,EAAWC,SAAyB,MACpCC,UAAOJ,EAAAA,EAAKI,oBAAQ,OACpBC,EAAmB,UAATD,GAA6B,UAATA,EAEpCE,EAWIC,EAAAA,WAAW,CAAEC,QAASH,EAASI,OAAiB,UAATL,EAAkBM,SAAUV,EAAKW,KAV1EC,IAAAA,YACAC,IAAAA,KACAC,IAAAA,OACAC,IAAAA,QACAC,IAAAA,UACAC,IAAAA,WACAC,IAAAA,WACAC,IAAAA,UACAC,IAAAA,YAIIC,EAAWC,EAAK,QAACC,iCAAiCvB,EAAKwB,MACvDC,EAAczB,EAAKyB,aAAezB,EAAK0B,IAE7C,OACEC,EAAAA,KAAA,MAAA,CAAKC,UAAWC,EAAOC,KAAM,cAAY,0BAAyBC,SAChE,CAAAJ,EAAAK,KAAA,MAAA,CAAKJ,UAAWC,EAAOI,WAAWF,SAChC,CAAAJ,EAAAK,KAAA,MAAA,CAAKJ,UAAWC,EAAOK,SAASH,SAC9B,CAAAI,EAAAC,IAAA,MAAA,CAAKR,UAAWC,EAAOQ,aAAcC,MAAOjB,EAASU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,aACLC,UAAU,UACVC,UAAWxD,EACXyD,QAAS3D,EACTiC,OAAO,6BAA4BhB,SAEnCI,EAAAA,IAACuC,EAAQA,SAAA,UAKfvC,MAAC+B,UAAO,CAAC5B,MAAM,WAAW6B,UAAU,OAAMpC,SACxCI,EAAAC,IAAA,OAAA,CAAMR,UAAWC,EAAOuC,eAAerC,SACrCI,MAACkC,aAAU,CACT7B,KAAK,QACL8B,KAAK,aACLC,UAAU,WACVC,UAAWvD,EACXwD,QAAS1D,EACTgC,OAAO,8BAA6BhB,SAEpCI,EAAAA,IAACwC,EAASA,UAAA,eAQ1B"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/regenerator"),r=require("../../utils/fetchAttachment.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(e),u=n(t),o=function(e,t,r){var n=document.createElement("canvas");n.width=t,n.height=r;var a=n.getContext("2d");if(!a)throw new Error("Could not get a 2d canvas context");return a.drawImage(e,0,0),new Promise((function(e,t){n.toBlob((function(r){return r?e(r):t(new Error("Could not encode the image"))}),"image/png")}))},c=function(){var e=a.default(u.default.mark((function e(t){var r;return u.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,createImageBitmap(t);case 2:return r=e.sent,e.abrupt("return",o(r,r.width,r.height));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i=function(){var e=a.default(u.default.mark((function e(t){return u.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",o(t,t.naturalWidth,t.naturalHeight));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),s=function(){var e=a.default(u.default.mark((function e(t){var n,a;return u.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.fetchAttachment(t);case 2:if((n=e.sent).ok){e.next=5;break}throw new Error("Could not read the image (".concat(n.status,")"));case 5:return e.next=7,n.blob();case 7:return a=e.sent,e.abrupt("return","image/png"===a.type?a:c(a));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),p=function(){var e;return"undefined"!=typeof ClipboardItem&&!(null===(e=navigator.clipboard)||void 0===e||!e.write)},f=function(e){return navigator.clipboard.write([new ClipboardItem({"image/png":e})])},l=function(e){return!(null==e||!e.complete||!e.naturalWidth)},d=function(){var e=a.default(u.default.mark((function e(t,r){return u.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(p()){e.next=2;break}return e.abrupt("return",!1);case 2:if(!l(r)){e.next=11;break}return e.prev=3,e.next=6,f(i(r));case 6:return e.abrupt("return",!0);case 9:e.prev=9,e.t0=e.catch(3);case 11:if(t){e.next=13;break}return e.abrupt("return",!1);case 13:return e.prev=13,e.next=16,f(s(t));case 16:return e.abrupt("return",!0);case 19:return e.prev=19,e.t1=e.catch(13),console.error('Failed to copy attachment "'.concat(t,'" to the clipboard'),e.t1),e.abrupt("return",!1);case 23:case"end":return e.stop()}}),e,null,[[3,9],[13,19]])})));return function(t,r){return e.apply(this,arguments)}}();exports.copyImageToClipboard=d,exports.getCanCopyImages=p;
2
+ //# sourceMappingURL=copyImageToClipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyImageToClipboard.js","sources":["../../../../src/components/AttachmentLightbox/copyImageToClipboard.ts"],"sourcesContent":["import { fetchAttachment } from '~/utils/fetchAttachment';\n\nconst toPng = (source: CanvasImageSource, width: number, height: number): Promise<Blob> => {\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n\n const context = canvas.getContext('2d');\n\n if (!context) throw new Error('Could not get a 2d canvas context');\n\n context.drawImage(source, 0, 0);\n\n return new Promise((resolve, reject) => {\n // Throws for an image the page was not allowed to read, which is the tainted-canvas signal.\n canvas.toBlob(\n encoded => (encoded ? resolve(encoded) : reject(new Error('Could not encode the image'))),\n 'image/png'\n );\n });\n};\n\nconst encodeAsPng = async (blob: Blob): Promise<Blob> => {\n const bitmap = await createImageBitmap(blob);\n\n return toPng(bitmap, bitmap.width, bitmap.height);\n};\n\nconst pngFromElement = async (image: HTMLImageElement): Promise<Blob> =>\n toPng(image, image.naturalWidth, image.naturalHeight);\n\n// Chrome only accepts PNG on the clipboard, so anything else is re-encoded.\nconst fetchAsPng = async (src: string): Promise<Blob> => {\n const response = await fetchAttachment(src);\n\n if (!response.ok) throw new Error(`Could not read the image (${response.status})`);\n\n const blob = await response.blob();\n\n return blob.type === 'image/png' ? blob : encodeAsPng(blob);\n};\n\nexport const getCanCopyImages = () =>\n typeof ClipboardItem !== 'undefined' && !!navigator.clipboard?.write;\n\nconst write = (png: Promise<Blob>) =>\n // A promise, not an awaited blob: Safari requires the write inside the user gesture.\n navigator.clipboard.write([new ClipboardItem({ 'image/png': png })]);\n\nconst isReady = (image?: HTMLImageElement | null) => !!image?.complete && !!image.naturalWidth;\n\n/** Copies the pixels already on screen when the page may read them, else fetches the bytes. */\nexport const copyImageToClipboard = async (\n src: string,\n image?: HTMLImageElement | null\n): Promise<boolean> => {\n if (!getCanCopyImages()) return false;\n\n if (isReady(image)) {\n try {\n await write(pngFromElement(image as HTMLImageElement));\n\n return true;\n } catch {}\n }\n\n if (!src) return false;\n\n try {\n await write(fetchAsPng(src));\n\n return true;\n } catch (error) {\n console.error(`Failed to copy attachment \"${src}\" to the clipboard`, error);\n\n return false;\n }\n};\n"],"names":["toPng","source","width","height","canvas","document","createElement","context","getContext","Error","drawImage","Promise","resolve","reject","toBlob","encoded","encodeAsPng","_ref","_asyncToGenerator","_regeneratorRuntime","mark","blob","bitmap","wrap","_context","prev","next","createImageBitmap","sent","stop","_callee","_x","apply","this","arguments","pngFromElement","_ref2","image","_context2","naturalWidth","naturalHeight","_callee2","_x2","fetchAsPng","_ref3","src","response","_context3","fetchAttachment","ok","concat","status","type","_callee3","_x3","getCanCopyImages","_navigator$clipboard","ClipboardItem","navigator","clipboard","write","png","isReady","complete","copyImage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kB,CAAAY,EAAAzC,KAAA,EAAA,KAAA,CAAA,OAAAyC,EAAAC,OAAA,UAAS,GAAK,KAAA,EAAA,IAEjCN,EAAQzB,GAAM,CAAA8B,EAAAzC,KAAA,GAAA,KAAA,CAAA,OAAAyC,EAAA1C,KAAA,EAAA0C,EAAAzC,KAAA,EAERkC,EAAMzB,EAAeE,IAA2B,KAAA,EAAA,OAAA8B,EAAAC,OAAA,UAE/C,GAAI,KAAA,EAAAD,EAAA1C,KAAA,EAAA0C,EAAAE,GAAAF,EAAA,MAAA,GAAA,KAAA,GAAA,GAIVtB,EAAG,CAAAsB,EAAAzC,KAAA,GAAA,KAAA,CAAA,OAAAyC,EAAAC,OAAA,UAAS,GAAK,KAAA,GAAA,OAAAD,EAAA1C,KAAA,GAAA0C,EAAAzC,KAAA,GAGdkC,EAAMjB,EAAWE,IAAK,KAAA,GAAA,OAAAsB,EAAAC,OAAA,UAErB,GAAI,KAAA,GAEiE,OAFjED,EAAA1C,KAAA,GAAA0C,EAAAG,GAAAH,EAAA,MAAA,IAEXI,QAAQC,MAAoC3B,8BAAAA,OAAAA,EAA+B,sBAAAsB,EAAAG,IAACH,EAAAC,OAAA,UAErE,GAAK,KAAA,GAAA,IAAA,MAAA,OAAAD,EAAAtC,OAAA,GAAAqC,EAAA,KAAA,CAAA,CAAA,EAAA,GAAA,CAAA,GAAA,KAEf,KAAA,OAAA,SAzBgCO,EAAAC,GAAA,OAAAT,EAAAjC,MAAAC,KAAAC,UAAA,CAAA,CAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/regenerator"),r=require("../../utils/fetchAttachment.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(e),o=n(t),c=function(){var e=a.default(o.default.mark((function e(t,n){var a,c,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",!1);case 2:return e.prev=2,e.next=5,r.fetchAttachment(t);case 5:if((a=e.sent).ok){e.next=8;break}throw new Error("Could not read the file (".concat(a.status,")"));case 8:return e.t0=URL,e.next=11,a.blob();case 11:return e.t1=e.sent,c=e.t0.createObjectURL.call(e.t0,e.t1),(u=document.createElement("a")).href=c,u.download=n,document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(c),e.abrupt("return",!0);case 23:return e.prev=23,e.t2=e.catch(2),console.error('Failed to download "'.concat(t,'"'),e.t2),e.abrupt("return",!1);case 27:case"end":return e.stop()}}),e,null,[[2,23]])})));return function(t,r){return e.apply(this,arguments)}}(),u=["http:","https:","blob:"],s=function(e){if(e)try{var t=new URL(e,window.location.href).protocol;if(!u.includes(t))throw new Error("Refusing to open a ".concat(t," url"));window.open(e,"_blank","noopener")}catch(t){console.error('Failed to open "'.concat(e,'"'),t)}},l=function(){var e=a.default(o.default.mark((function e(t,r){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c(t,r);case 2:if(e.sent){e.next=4;break}s(t);case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();exports.downloadAttachment=c,exports.openAttachmentInNewTab=s,exports.saveAttachment=l;
2
+ //# sourceMappingURL=downloadAttachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"downloadAttachment.js","sources":["../../../../src/components/AttachmentLightbox/downloadAttachment.ts"],"sourcesContent":["import { fetchAttachment } from '~/utils/fetchAttachment';\n\n/**\n * `download` is ignored cross-origin, where a plain link navigates the app away instead. Fetching\n * the bytes and handing the browser a blob url saves under the right name wherever the file lives.\n */\nexport const downloadAttachment = async (url: string, fileName: string): Promise<boolean> => {\n if (!url) return false;\n\n try {\n const response = await fetchAttachment(url);\n\n if (!response.ok) throw new Error(`Could not read the file (${response.status})`);\n\n const blobUrl = URL.createObjectURL(await response.blob());\n const link = document.createElement('a');\n\n link.href = blobUrl;\n link.download = fileName;\n document.body.appendChild(link);\n link.click();\n link.remove();\n URL.revokeObjectURL(blobUrl);\n\n return true;\n } catch (error) {\n console.error(`Failed to download \"${url}\"`, error);\n\n return false;\n }\n};\n\nconst SAFE_SCHEMES = ['http:', 'https:', 'blob:'];\n\n/** Stored data, not a literal: an unchecked `javascript:` url would run on open. */\nexport const openAttachmentInNewTab = (url: string): void => {\n // An empty one resolves to the page itself, passes the check below, and opens a blank tab.\n if (!url) return;\n\n try {\n const { protocol } = new URL(url, window.location.href);\n\n if (!SAFE_SCHEMES.includes(protocol)) throw new Error(`Refusing to open a ${protocol} url`);\n\n window.open(url, '_blank', 'noopener');\n } catch (error) {\n console.error(`Failed to open \"${url}\"`, error);\n }\n};\n\n/** Saves the file, falling back to a tab when the bytes cannot be read. */\nexport const saveAttachment = async (url: string, fileName: string): Promise<void> => {\n if (!(await downloadAttachment(url, fileName))) openAttachmentInNewTab(url);\n};\n"],"names":["downloadAttachment","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","url","fileName","response","blobUrl","link","wrap","_context","prev","next","abrupt","fetchAttachment","sent","ok","Error","concat","status","t0","URL","blob","t1","createObjectURL","call","document","createElement","href","download","body","appendChild","click","remove","revokeObjectURL","t2","console","error","stop","_x","_x2","apply","this","arguments","SAFE_SCHEMES","openAttachmentInNewTab","protocol","window","location","includes","open","saveAttachment","_ref2","_callee2","_context2","_x3","_x4"],"mappings":"2SAMaA,EAAkB,WAAA,IAAGC,EAAAC,EAAAA,QAAAC,EAAA,QAAAC,MAAA,SAAAC,EAAOC,EAAaC,GAAgB,IAAAC,EAAAC,EAAAC,EAAA,OAAAP,UAAAQ,MAAA,SAAAC,GAAA,OAAA,OAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,GAC/DR,EAAG,CAAAM,EAAAE,KAAA,EAAA,KAAA,CAAA,OAAAF,EAAAG,OAAA,UAAS,GAAK,KAAA,EAAA,OAAAH,EAAAC,KAAA,EAAAD,EAAAE,KAAA,EAGGE,EAAAA,gBAAgBV,G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,EAAAA,QAAAC,EAAA,QAAAC,MAAA,SAAAmD,EAAOjD,EAAaC,GAAgB,OAAAJ,UAAAQ,MAAA,SAAA6C,GAAA,OAAA,OAAAA,EAAA3C,KAAA2C,EAAA1C,MAAA,KAAA,EAAA,OAAA0C,EAAA1C,KAAA,EACpDd,EAAmBM,EAAKC,GAAS,KAAA,EAAA,GAAAiD,EAAAvC,KAAA,CAAAuC,EAAA1C,KAAA,EAAA,KAAA,CAAGiC,EAAuBzC,GAAK,KAAA,EAAA,IAAA,MAAA,OAAAkD,EAAAhB,OAAA,GAAAe,EAC7E,KAAA,OAAA,SAF0BE,EAAAC,GAAA,OAAAJ,EAAAX,MAAAC,KAAAC,UAAA,CAAA,CAAA"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),r=require("./AttachmentLightbox.js"),n=require("react/jsx-runtime");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=i(e);exports.useAttachmentLightbox=function(){var e=t.useState(null),i=u.default(e,2),a=i[0],o=i[1];return{openAttachment:function(e){("image"===e.kind||"video"===e.kind)&&e.src&&o({src:e.src,name:e.name,kind:e.kind})},lightbox:n.jsx(r.AttachmentLightbox,{attachment:a,onClose:function(){return o(null)}})}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),r=require("./AttachmentLightbox.js"),n=require("react/jsx-runtime");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);exports.useAttachmentLightbox=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=i.onShare,a=t.useState(null),c=o.default(a,2),l=c[0],s=c[1],h=function(e){e.isUploading||e.error||s(e.id)};return{openAttachment:h,lightbox:n.jsx(r.AttachmentLightbox,{items:e,activeId:l,onActiveIdChange:s,onClose:function(){return s(null)},onShare:u})}};
2
2
  //# sourceMappingURL=useAttachmentLightbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAttachmentLightbox.js","sources":["../../../../src/components/AttachmentLightbox/useAttachmentLightbox.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport type { AttachmentPreviewItem } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport { AttachmentLightbox, LightboxAttachment } from './AttachmentLightbox';\n\n/** Images and videos open in the lightbox; documents are left to their download link. */\nexport const useAttachmentLightbox = () => {\n const [attachment, setAttachment] = useState<LightboxAttachment | null>(null);\n\n const openAttachment = (item: AttachmentPreviewItem) => {\n const isPlayable = item.kind === 'image' || item.kind === 'video';\n\n if (isPlayable && item.src) {\n setAttachment({ src: item.src, name: item.name, kind: item.kind });\n }\n };\n\n return {\n openAttachment,\n lightbox: <AttachmentLightbox attachment={attachment} onClose={() => setAttachment(null)} />,\n };\n};\n"],"names":["useState","_useState2","_slicedToArray","_useState","attachment","setAttachment","openAttachment","item","kind","src","name","lightbox","_jsx","AttachmentLightbox","onClose"],"mappings":"kUAOqC,WACnC,IAAoCA,EAAAA,EAAQA,SAA4B,MAAKC,EAAAC,EAAAA,QAAAC,EAAA,GAAtEC,EAAUH,EAAA,GAAEI,EAAaJ,EAAA,GAUhC,MAAO,CACLK,eATqB,SAACC,IACW,UAAdA,EAAKC,MAAkC,UAAdD,EAAKC,OAE/BD,EAAKE,KACrBJ,EAAc,CAAEI,IAAKF,EAAKE,IAAKC,KAAMH,EAAKG,KAAMF,KAAMD,EAAKC,QAM7DG,SAAUC,MAACC,qBAAkB,CAACT,WAAYA,EAAYU,QAAS,WAAA,OAAMT,EAAc,KAAK,IAE5F"}
1
+ {"version":3,"file":"useAttachmentLightbox.js","sources":["../../../../src/components/AttachmentLightbox/useAttachmentLightbox.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport type { AttachmentPreviewItem } from '../AttachmentPreview/AttachmentPreview.types';\n\nimport { AttachmentLightbox } from './AttachmentLightbox';\n\nexport type UseAttachmentLightboxOptions = {\n /** Adds \"Share file\" to the overflow menu. */\n onShare?: (item: AttachmentPreviewItem) => void;\n};\n\n/** Wires attachments to the preview modal; a kind with no renderer shows a download card. */\nexport const useAttachmentLightbox = (\n items: AttachmentPreviewItem[],\n { onShare }: UseAttachmentLightboxOptions = {}\n) => {\n const [activeId, setActiveId] = useState<AttachmentPreviewItem['id'] | null>(null);\n\n const openAttachment = (item: AttachmentPreviewItem) => {\n if (!item.isUploading && !item.error) setActiveId(item.id);\n };\n\n return {\n openAttachment,\n lightbox: (\n <AttachmentLightbox\n items={items}\n activeId={activeId}\n onActiveIdChange={setActiveId}\n onClose={() => setActiveId(null)}\n onShare={onShare}\n />\n ),\n };\n};\n"],"names":["items","_ref","arguments","length","undefined","onShare","useState","_useState2","_slicedToArray","_useState","activeId","setActiveId","openAttachment","item","isUploading","error","id","lightbox","_jsx","AttachmentLightbox","onActiveIdChange","onClose"],"mappings":"kUAYqC,SACnCA,GAEG,IAAAC,EAAAC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GADyC,CAAE,EAA5CG,IAAAA,QAE8BC,EAAAA,EAAQA,SAAqC,MAAKC,EAAAC,EAAAA,QAAAC,EAAA,GAA3EC,EAAQH,EAAA,GAAEI,EAAWJ,EAAA,GAEtBK,EAAiB,SAACC,GACjBA,EAAKC,aAAgBD,EAAKE,OAAOJ,EAAYE,EAAKG,KAGzD,MAAO,CACLJ,eAAAA,EACAK,SACEC,MAACC,qBAAkB,CACjBnB,MAAOA,EACPU,SAAUA,EACVU,iBAAkBT,EAClBU,QAAS,WAAA,OAAMV,EAAY,KAAM,EACjCN,QAASA,IAIjB"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),l=function(e){return Math.min(Math.max(e,1),3)};exports.MAX_ZOOM=3,exports.MIN_ZOOM=1,exports.ZOOM_STEP=.5,exports.useZoomPan=function(e){var r=e.canZoom,o=e.canPan,c=e.resetKey,u=t.useRef(null),i=t.useState(1),a=n.default(i,2),s=a[0],f=a[1],p=t.useState(!1),v=n.default(p,2),d=v[0],h=v[1],b=t.useRef(s),P=t.useRef(null),m=t.useRef(null);t.useEffect((function(){b.current=s}),[s]),t.useEffect((function(){f(1),P.current=null}),[c]),t.useEffect((function(){var e=u.current;if(e){var t=P.current;P.current=null,t?(e.scrollLeft=t.ratioX*e.scrollWidth-t.offsetX,e.scrollTop=t.ratioY*e.scrollHeight-t.offsetY):(e.scrollLeft=(e.scrollWidth-e.clientWidth)/2,e.scrollTop=(e.scrollHeight-e.clientHeight)/2)}}),[s,c]);var C=t.useCallback((function(e,t){var r=l(b.current+e);r!==b.current&&(t&&(P.current=t),f(r))}),[]),X=t.useCallback((function(){return C(.5)}),[C]),Y=t.useCallback((function(){return C(-.5)}),[C]);t.useEffect((function(){var e=u.current;if(e&&r){var t=function(t){var r=.004*-t.deltaY;if(l(b.current+r)!==b.current){t.preventDefault();var n=e.getBoundingClientRect(),o=t.clientX-n.left,c=t.clientY-n.top;C(r,{ratioX:e.scrollWidth?(e.scrollLeft+o)/e.scrollWidth:.5,ratioY:e.scrollHeight?(e.scrollTop+c)/e.scrollHeight:.5,offsetX:o,offsetY:c})}};return e.addEventListener("wheel",t,{passive:!1}),function(){return e.removeEventListener("wheel",t)}}}),[r,C]);var L=o&&s>1,M=t.useCallback((function(e){var t,r=u.current;!L||e.button>0||!r||(m.current={pointerX:e.clientX,pointerY:e.clientY,scrollLeft:r.scrollLeft,scrollTop:r.scrollTop},null===(t=r.setPointerCapture)||void 0===t||t.call(r,e.pointerId),h(!0))}),[L]),O=t.useCallback((function(e){var t=m.current,r=u.current;t&&r&&(r.scrollLeft=t.scrollLeft-(e.clientX-t.pointerX),r.scrollTop=t.scrollTop-(e.clientY-t.pointerY))}),[]),T=t.useCallback((function(e){var t,r;m.current&&(m.current=null,null===(t=u.current)||void 0===t||null===(r=t.releasePointerCapture)||void 0===r||r.call(t,e.pointerId),h(!1))}),[]);return{viewportRef:u,zoom:s,zoomIn:X,zoomOut:Y,canZoomIn:s<3,canZoomOut:s>1,isPannable:L,isPanning:d,panHandlers:{onPointerDown:M,onPointerMove:O,onPointerUp:T,onPointerCancel:T}}};
2
+ //# sourceMappingURL=useZoomPan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useZoomPan.js","sources":["../../../../src/components/AttachmentLightbox/useZoomPan.ts"],"sourcesContent":["import { PointerEvent as ReactPointerEvent, useCallback, useEffect, useRef, useState } from 'react';\n\nexport const MIN_ZOOM = 1;\nexport const MAX_ZOOM = 3;\nexport const ZOOM_STEP = 0.5;\n\n// A trackpad pinch arrives as a wheel event; this turns its delta into a comfortable travel.\nconst WHEEL_SENSITIVITY = 0.004;\n\nconst clampZoom = (zoom: number) => Math.min(Math.max(zoom, MIN_ZOOM), MAX_ZOOM);\n\n/** Where the pointer sat in the content, so the same point stays put across a zoom. */\ntype Anchor = { ratioX: number; ratioY: number; offsetX: number; offsetY: number };\n\ntype Drag = { pointerX: number; pointerY: number; scrollLeft: number; scrollTop: number };\n\n/**\n * The scroll box does the panning, so a zoom only resizes the content and puts the scroll offset\n * back where the viewer was looking.\n */\nexport const useZoomPan = ({\n canZoom,\n canPan,\n resetKey,\n}: {\n canZoom: boolean;\n canPan: boolean;\n resetKey: unknown;\n}) => {\n const viewportRef = useRef<HTMLDivElement>(null);\n const [zoom, setZoom] = useState(MIN_ZOOM);\n const [isPanning, setIsPanning] = useState(false);\n\n const zoomRef = useRef(zoom);\n const anchorRef = useRef<Anchor | null>(null);\n const dragRef = useRef<Drag | null>(null);\n\n useEffect(() => {\n zoomRef.current = zoom;\n }, [zoom]);\n\n useEffect(() => {\n setZoom(MIN_ZOOM);\n anchorRef.current = null;\n }, [resetKey]);\n\n // Runs after the box has resized, so scrollWidth/Height are the new ones.\n useEffect(() => {\n const viewport = viewportRef.current;\n\n if (!viewport) return;\n\n const anchor = anchorRef.current;\n anchorRef.current = null;\n\n if (anchor) {\n viewport.scrollLeft = anchor.ratioX * viewport.scrollWidth - anchor.offsetX;\n viewport.scrollTop = anchor.ratioY * viewport.scrollHeight - anchor.offsetY;\n } else {\n viewport.scrollLeft = (viewport.scrollWidth - viewport.clientWidth) / 2;\n viewport.scrollTop = (viewport.scrollHeight - viewport.clientHeight) / 2;\n }\n }, [zoom, resetKey]);\n\n const zoomBy = useCallback((delta: number, anchor?: Anchor) => {\n const next = clampZoom(zoomRef.current + delta);\n\n if (next === zoomRef.current) return;\n if (anchor) anchorRef.current = anchor;\n\n setZoom(next);\n }, []);\n\n const zoomIn = useCallback(() => zoomBy(ZOOM_STEP), [zoomBy]);\n const zoomOut = useCallback(() => zoomBy(-ZOOM_STEP), [zoomBy]);\n\n // Native listener: React's onWheel is passive, so it could not block the page from scrolling.\n useEffect(() => {\n const viewport = viewportRef.current;\n\n if (!viewport || !canZoom) return undefined;\n\n const handleWheel = (event: WheelEvent) => {\n const delta = -event.deltaY * WHEEL_SENSITIVITY;\n\n // Already as big or small as it goes: let the wheel scroll whatever is behind the preview.\n if (clampZoom(zoomRef.current + delta) === zoomRef.current) return;\n\n event.preventDefault();\n\n const rect = viewport.getBoundingClientRect();\n const offsetX = event.clientX - rect.left;\n const offsetY = event.clientY - rect.top;\n\n zoomBy(delta, {\n ratioX: viewport.scrollWidth ? (viewport.scrollLeft + offsetX) / viewport.scrollWidth : 0.5,\n ratioY: viewport.scrollHeight\n ? (viewport.scrollTop + offsetY) / viewport.scrollHeight\n : 0.5,\n offsetX,\n offsetY,\n });\n };\n\n viewport.addEventListener('wheel', handleWheel, { passive: false });\n\n return () => viewport.removeEventListener('wheel', handleWheel);\n }, [canZoom, zoomBy]);\n\n const isPannable = canPan && zoom > MIN_ZOOM;\n\n const onPointerDown = useCallback(\n (event: ReactPointerEvent<HTMLDivElement>) => {\n const viewport = viewportRef.current;\n\n // `> 0` rather than `!== 0`: only a reported secondary/middle button should bail.\n if (!isPannable || event.button > 0 || !viewport) return;\n\n dragRef.current = {\n pointerX: event.clientX,\n pointerY: event.clientY,\n scrollLeft: viewport.scrollLeft,\n scrollTop: viewport.scrollTop,\n };\n viewport.setPointerCapture?.(event.pointerId);\n setIsPanning(true);\n },\n [isPannable]\n );\n\n const onPointerMove = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n const viewport = viewportRef.current;\n\n if (!drag || !viewport) return;\n\n viewport.scrollLeft = drag.scrollLeft - (event.clientX - drag.pointerX);\n viewport.scrollTop = drag.scrollTop - (event.clientY - drag.pointerY);\n }, []);\n\n const onPointerUp = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {\n if (!dragRef.current) return;\n\n dragRef.current = null;\n viewportRef.current?.releasePointerCapture?.(event.pointerId);\n setIsPanning(false);\n }, []);\n\n return {\n viewportRef,\n zoom,\n zoomIn,\n zoomOut,\n canZoomIn: zoom < MAX_ZOOM,\n canZoomOut: zoom > MIN_ZOOM,\n isPannable,\n isPanning,\n panHandlers: { onPointerDown, onPointerMove, onPointerUp, onPointerCancel: onPointerUp },\n };\n};\n"],"names":["clampZoom","zoom","Math","min","max","_ref","canZoom","canPan","resetKey","viewportRef","useRef","useState","_useState2","_slicedToArray","_useState","setZoom","_useState4","_useState3","isPanning","setIsPanning","zoomRef","anchorRef","dragRef","useEffect","current","viewport","anchor","scrollLeft","ratioX","scrollWidth","offsetX","scrollTop","ratioY","scrollHeight","offsetY","clientWidth","clientHeight","zoomBy","useCallback","delta","next","zoomIn","zoomOut","handleWheel","event","deltaY","preventDefault","rect","getBoundingClientRect","clientX","left","clientY","top","addEventListener","passive","removeEventListener","isPannable","onPointerDown","_viewport$setPointerC","button","pointerX","pointerY","setPointerCapture","call","pointerId","onPointerMove","drag","onPointerUp","_viewportRef$current","_viewportRef$current$","releasePointerCapture","canZoomIn","canZoomOut","panHandlers","onPointerCancel"],"mappings":"gOASMA,EAAY,SAACC,GAAY,OAAKC,KAAKC,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