@corva/ui 3.77.0-1 → 3.77.0-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs-bundle/components/AddComment/Popover.js +1 -1
- package/cjs-bundle/components/AddComment/Popover.js.map +1 -1
- package/cjs-bundle/components/AddComment/components/Content.js +1 -1
- package/cjs-bundle/components/AddComment/components/Content.js.map +1 -1
- package/cjs-bundle/components/AttachFileButton/AttachFileButton.js +1 -1
- package/cjs-bundle/components/AttachFileButton/AttachFileButton.js.map +1 -1
- package/cjs-bundle/components/BICOffsetPickerDialog/index.js +1 -1
- package/cjs-bundle/components/BICOffsetPickerDialog/index.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
- package/cjs-bundle/components/CommentCard/CommentCard.js +1 -1
- package/cjs-bundle/components/CommentCard/CommentCard.js.map +1 -1
- package/cjs-bundle/components/CommentCard/CommentCard.scss.js +1 -1
- package/cjs-bundle/components/CommentComposer/CommentComposer.js +1 -1
- package/cjs-bundle/components/CommentComposer/CommentComposer.js.map +1 -1
- package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js +1 -1
- package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js.map +1 -1
- package/cjs-bundle/components/DocumentViewer/DocumentViewer.js +1 -1
- package/cjs-bundle/components/DocumentViewer/DocumentViewer.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/metrics/fetchMetricsAggregate.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/metrics/fetchMetricsAggregate.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/metrics/fetchMudAggregate.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/metrics/fetchMudAggregate.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/getAllAssets.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/getAllAssets.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByBounds.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByBounds.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByIds.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByIds.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/wells/fetchWellsByRigIds.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/api/wells/fetchWellsByRigIds.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
- package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js +1 -1
- package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
- package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
- package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
- package/cjs-bundle/components/WellhubFilePicker/WellhubFilePicker.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/WellhubFilePicker.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/api/fetchWellhubRecords.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/api/fetchWellhubRecords.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/api/postWellhubRecords.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/api/postWellhubRecords.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/api/registerAttachmentsInWellhub.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/api/registerAttachmentsInWellhub.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.scss.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.scss.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.scss.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.scss.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/constants.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/constants.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/hooks/useWellhubFiles.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/hooks/useWellhubFiles.js.map +1 -0
- package/cjs-bundle/components/WellhubFilePicker/utils/wellhubRecords.js +2 -0
- package/cjs-bundle/components/WellhubFilePicker/utils/wellhubRecords.js.map +1 -0
- package/cjs-bundle/components/index.js +1 -1
- package/cjs-bundle/utils/fetchDataByChunks.js +2 -0
- package/cjs-bundle/utils/fetchDataByChunks.js.map +1 -0
- package/components/AddComment/Popover.js +1 -1
- package/components/AddComment/Popover.js.map +1 -1
- package/components/AddComment/components/Content.js +1 -1
- package/components/AddComment/components/Content.js.map +1 -1
- package/components/AttachFileButton/AttachFileButton.d.ts +3 -1
- package/components/AttachFileButton/AttachFileButton.d.ts.map +1 -1
- package/components/AttachFileButton/AttachFileButton.js +1 -1
- package/components/AttachFileButton/AttachFileButton.js.map +1 -1
- package/components/AttachFileButton/__tests__/AttachFileButton.test.d.ts +2 -0
- package/components/AttachFileButton/__tests__/AttachFileButton.test.d.ts.map +1 -0
- package/components/BICOffsetPickerDialog/index.js +1 -1
- package/components/BICOffsetPickerDialog/index.js.map +1 -1
- package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
- package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
- package/components/Casing/CasingTableV2/components/Component.js +1 -1
- package/components/Casing/CasingTableV2/components/Component.js.map +1 -1
- package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
- package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
- package/components/CommentCard/CommentCard.d.ts.map +1 -1
- package/components/CommentCard/CommentCard.js +1 -1
- package/components/CommentCard/CommentCard.js.map +1 -1
- package/components/CommentCard/CommentCard.scss.js +1 -1
- package/components/CommentCard/CommentCard.types.d.ts +0 -1
- package/components/CommentCard/CommentCard.types.d.ts.map +1 -1
- package/components/CommentComposer/CommentComposer.d.ts +3 -1
- package/components/CommentComposer/CommentComposer.d.ts.map +1 -1
- package/components/CommentComposer/CommentComposer.js +1 -1
- package/components/CommentComposer/CommentComposer.js.map +1 -1
- package/components/CommentComposer/__tests__/useAttachmentUpload.stored.test.d.ts +2 -0
- package/components/CommentComposer/__tests__/useAttachmentUpload.stored.test.d.ts.map +1 -0
- package/components/CommentComposer/useAttachmentUpload.d.ts +4 -0
- package/components/CommentComposer/useAttachmentUpload.d.ts.map +1 -1
- package/components/CommentComposer/useAttachmentUpload.js +1 -1
- package/components/CommentComposer/useAttachmentUpload.js.map +1 -1
- package/components/DocumentViewer/DocumentViewer.js +1 -1
- package/components/DocumentViewer/DocumentViewer.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
- package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
- package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
- package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
- package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
- package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
- package/components/OffsetWellPickerV5/api/metrics/fetchMetricsAggregate.js +1 -1
- package/components/OffsetWellPickerV5/api/metrics/fetchMetricsAggregate.js.map +1 -1
- package/components/OffsetWellPickerV5/api/metrics/fetchMudAggregate.js +1 -1
- package/components/OffsetWellPickerV5/api/metrics/fetchMudAggregate.js.map +1 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/getAllAssets.js +1 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/getAllAssets.js.map +1 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByBounds.js +1 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByBounds.js.map +1 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByIds.js +1 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/getAssetsByIds.js.map +1 -1
- package/components/OffsetWellPickerV5/api/wells/fetchWellsByRigIds.js +1 -1
- package/components/OffsetWellPickerV5/api/wells/fetchWellsByRigIds.js.map +1 -1
- package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
- package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
- package/components/PadOffsetsPicker/StagesSelector.js +1 -1
- package/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
- package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
- package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
- package/components/WellhubFilePicker/WellhubFilePicker.d.ts +10 -0
- package/components/WellhubFilePicker/WellhubFilePicker.d.ts.map +1 -0
- package/components/WellhubFilePicker/WellhubFilePicker.js +2 -0
- package/components/WellhubFilePicker/WellhubFilePicker.js.map +1 -0
- package/components/WellhubFilePicker/WellhubFilePicker.types.d.ts +34 -0
- package/components/WellhubFilePicker/WellhubFilePicker.types.d.ts.map +1 -0
- package/components/WellhubFilePicker/api/__tests__/registerAttachmentsInWellhub.test.d.ts +2 -0
- package/components/WellhubFilePicker/api/__tests__/registerAttachmentsInWellhub.test.d.ts.map +1 -0
- package/components/WellhubFilePicker/api/fetchWellhubRecords.d.ts +4 -0
- package/components/WellhubFilePicker/api/fetchWellhubRecords.d.ts.map +1 -0
- package/components/WellhubFilePicker/api/fetchWellhubRecords.js +2 -0
- package/components/WellhubFilePicker/api/fetchWellhubRecords.js.map +1 -0
- package/components/WellhubFilePicker/api/index.d.ts +4 -0
- package/components/WellhubFilePicker/api/index.d.ts.map +1 -0
- package/components/WellhubFilePicker/api/postWellhubRecords.d.ts +10 -0
- package/components/WellhubFilePicker/api/postWellhubRecords.d.ts.map +1 -0
- package/components/WellhubFilePicker/api/postWellhubRecords.js +2 -0
- package/components/WellhubFilePicker/api/postWellhubRecords.js.map +1 -0
- package/components/WellhubFilePicker/api/registerAttachmentsInWellhub.d.ts +22 -0
- package/components/WellhubFilePicker/api/registerAttachmentsInWellhub.d.ts.map +1 -0
- package/components/WellhubFilePicker/api/registerAttachmentsInWellhub.js +2 -0
- package/components/WellhubFilePicker/api/registerAttachmentsInWellhub.js.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.d.ts +15 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.d.ts.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.js +2 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.js.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.scss.js +2 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/WellhubFileCard.scss.js.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/index.d.ts +3 -0
- package/components/WellhubFilePicker/components/WellhubFileCard/index.d.ts.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.d.ts +17 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.d.ts.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.js +2 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.js.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.scss.js +2 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/WellhubFilePickerView.scss.js.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/__tests__/WellhubFilePickerView.test.d.ts +2 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/__tests__/WellhubFilePickerView.test.d.ts.map +1 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/index.d.ts +3 -0
- package/components/WellhubFilePicker/components/WellhubFilePickerView/index.d.ts.map +1 -0
- package/components/WellhubFilePicker/constants.d.ts +5 -0
- package/components/WellhubFilePicker/constants.d.ts.map +1 -0
- package/components/WellhubFilePicker/constants.js +2 -0
- package/components/WellhubFilePicker/constants.js.map +1 -0
- package/components/WellhubFilePicker/hooks/index.d.ts +2 -0
- package/components/WellhubFilePicker/hooks/index.d.ts.map +1 -0
- package/components/WellhubFilePicker/hooks/useWellhubFiles.d.ts +8 -0
- package/components/WellhubFilePicker/hooks/useWellhubFiles.d.ts.map +1 -0
- package/components/WellhubFilePicker/hooks/useWellhubFiles.js +2 -0
- package/components/WellhubFilePicker/hooks/useWellhubFiles.js.map +1 -0
- package/components/WellhubFilePicker/index.d.ts +6 -0
- package/components/WellhubFilePicker/index.d.ts.map +1 -0
- package/components/WellhubFilePicker/utils/index.d.ts +2 -0
- package/components/WellhubFilePicker/utils/index.d.ts.map +1 -0
- package/components/WellhubFilePicker/utils/wellhubRecords.d.ts +10 -0
- package/components/WellhubFilePicker/utils/wellhubRecords.d.ts.map +1 -0
- package/components/WellhubFilePicker/utils/wellhubRecords.js +2 -0
- package/components/WellhubFilePicker/utils/wellhubRecords.js.map +1 -0
- package/components/index.d.ts +3 -0
- package/components/index.d.ts.map +1 -1
- package/components/index.js +1 -1
- package/mcp-server/server.mjs +92 -11
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/fetchDataByChunks.d.ts.map +1 -0
- package/utils/fetchDataByChunks.js +2 -0
- package/utils/fetchDataByChunks.js.map +1 -0
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/fetchDataByChunks.js +0 -2
- package/cjs-bundle/components/OffsetWellPickerV5/api/shared/fetchers/fetchDataByChunks.js.map +0 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/fetchDataByChunks.d.ts.map +0 -1
- package/components/OffsetWellPickerV5/api/shared/fetchers/fetchDataByChunks.js +0 -2
- package/components/OffsetWellPickerV5/api/shared/fetchers/fetchDataByChunks.js.map +0 -1
- /package/{components/OffsetWellPickerV5/api/shared/fetchers → utils}/fetchDataByChunks.d.ts +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o from"@babel/runtime/helpers/defineProperty";import{useMemo as
|
|
1
|
+
import o from"@babel/runtime/helpers/defineProperty";import s from"@babel/runtime/helpers/slicedToArray";import{useMemo as t,useCallback as n,useState as i,useRef as c}from"react";import{Input as e}from"@material-ui/core";import r from"@material-ui/icons/AlternateEmail";import{ButtonIcon as m}from"../../componentsV2/ButtonIcon/ButtonIcon.js";import{Tooltip as l}from"../../componentsV2/Tooltip/Tooltip.js";import{SmilingFaceIcon as a}from"../../icons/iconParkIcons.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/DragOne.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/SearchOne.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/InfoRounded.js";import"../../icons/customIcons/icons/FlameFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import"../../icons/customIcons/icons/Pad.js";import"../../icons/customIcons/icons/DrilloutUnit.js";import"../../icons/customIcons/icons/FracFleet.js";import"../../icons/customIcons/icons/Global.js";import"../../icons/customIcons/icons/Program.js";import"../../icons/customIcons/icons/Rig.js";import"../../icons/customIcons/icons/Well.js";import"../../icons/customIcons/icons/Gap.js";import"../../icons/customIcons/icons/Pin.js";import"../../icons/customIcons/icons/PinOne.js";import"../../icons/customIcons/icons/PinOneCrossed.js";import"../../icons/customIcons/icons/CloseOneFilled.js";import"../../icons/customIcons/icons/AttentionFilled.js";import"../../icons/customIcons/icons/CheckOneFilled.js";import"../../icons/customIcons/icons/Archive.js";import"../../icons/customIcons/icons/ArchiveCancel.js";import"../../icons/customIcons/icons/Unarchive.js";import"../../icons/customIcons/icons/Archived.js";import"../../icons/customIcons/icons/InterventionUnit.js";import"../../icons/customIcons/icons/CloudDelete.js";import"../../icons/customIcons/icons/Lasso.js";import"../../icons/customIcons/icons/Radius.js";import"../../icons/customIcons/icons/ErrorOps.js";import"../../icons/customIcons/icons/DataTypeOps.js";import"../../icons/customIcons/icons/FalsePositiveOps.js";import"../../icons/customIcons/icons/CalibrationOps.js";import"../../icons/customIcons/icons/CriticalOps.js";import"../../icons/customIcons/icons/Company.js";import"../../icons/customIcons/icons/ArchiveOne.js";import"../../icons/customIcons/icons/ParseBotFusion.js";import"../../icons/customIcons/icons/Connect.js";import"../../icons/customIcons/icons/PuzzleOne.js";import"../../icons/customIcons/icons/Feed.js";import"../../icons/customIcons/icons/Prompt.js";import"../../icons/customIcons/icons/Companies.js";import"../../icons/customIcons/icons/ClipboardAi.js";import"../../icons/customIcons/icons/Key.js";import"../../icons/customIcons/icons/AtSignCrossed.js";import"../../icons/customIcons/icons/MappingManual.js";import"../../icons/customIcons/icons/Mapping.js";import"../../icons/customIcons/icons/Metrics.js";import"../../icons/customIcons/icons/Drops.js";import"../../icons/customIcons/icons/ClipboardSearch.js";import"../../icons/customIcons/icons/Template.js";import"../../icons/customIcons/icons/ClipboardMetrics.js";import"../../icons/customIcons/icons/ClipboardBuilder.js";import"../../icons/customIcons/icons/UnitConversion.js";import"../../icons/customIcons/icons/NPT.js";import"../../icons/customIcons/icons/GuidedFrac.js";import{AvatarComponent as p}from"../Avatar/index.js";import{AttachFileButton as u}from"../AttachFileButton/AttachFileButton.js";import{CommentInput as d}from"../CommentInputNext/CommentInputNext.js";import j from"../EmojiIconButton.js";import h from"../FailedFileUploading.js";import I from"../UserMention/index.js";import{isSuggestionsListOpened as b}from"../UserMention/utils/index.js";import{WellhubFilePicker as f}from"../WellhubFilePicker/WellhubFilePicker.js";import"@babel/runtime/helpers/toConsumableArray";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";import"uuid";import"lodash";import"lodash/set";import"lodash/get";import"lodash/unset";import"moment";import"../../clients/jsonApi/index.js";import"../../clients/subscriptions/constants.js";import"../../clients/subscriptions.v1.js";import"../../clients/subscriptions/subscriptions-client.factory.js";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import"../../clients/sso/auth0.js";import"../../clients/sso/oauth2.js";import"../../clients/api/rateLimiter.js";import{useAttachmentUpload as g,DEFAULT_MAX_ATTACHMENTS as v}from"./useAttachmentUpload.js";import{CommentMetaLine as C}from"./CommentMetaLine.js";import{ShareToChatRow as y}from"./ShareToChatRow.js";import F from"./CommentComposer.scss.js";import{jsxs as O,Fragment as A,jsx as S}from"react/jsx-runtime";function P(o,s){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(o);s&&(n=n.filter((function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable}))),t.push.apply(t,n)}return t}function x(s){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){o(s,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(o){Object.defineProperty(s,o,Object.getOwnPropertyDescriptor(n,o))}))}return s}var k={fontSize:14,lineHeight:"20px",suggestions:{backgroundColor:"var(--palette-background-b-9)",list:{backgroundColor:"var(--palette-background-b-9)"},item:{color:"var(--palette-primary-text-1)","&focused":{backgroundColor:"rgb(from var(--palette-primary-text-1) r g b / 0.08)"}}}},E=function(o){return O("div",{className:F.suggestion,children:[S(p,{size:26,alt:o.display,imgSrc:o.photo,displayName:o.display}),S("span",{children:o.display})]})},w=function(o){var p=o.body,P=o.onBodyChange,w=o.onSubmit,D=o.canSubmit,R=o.currentUser,M=o.attachments,U=o.onAttachmentsChange,N=o.maxAttachments,B=void 0===N?v:N,L=o.attachment,T=o.onAttachmentChange,z=o.attachmentError,W=o.onAttachmentError,G=o.maxAttachmentSizeBytes,q=o.wellhubContext,K=o.disabled,H=o.autoFocus,V=o.placeholder,Q=void 0===V?"Add a comment...":V,Z=o.metaRows,$=o.isMetaSingleLine,J=o.shareToChat,X=o.trailing,Y=o.embedded,_=o.className,oo=o.testId,so=!!U,to=t((function(){return so?null!=M?M:[]:[L].filter(Boolean)}),[so,M,L]),no=n((function(o){var s;U?U(o):null==T||T(null!==(s=o[0])&&void 0!==s?s:null)}),[U,T]),io=g({value:to,onChange:no,onError:W,maxSizeBytes:G,maxFiles:so?B:1}),co=D&&!io.isUploading,eo=i(!1),ro=s(eo,2),mo=ro[0],lo=ro[1],ao=t((function(){return to.map((function(o){return o.name}))}),[to]),po=c(null);return O(A,{children:[S(d,{value:p,canSubmit:co,disabled:K,onSubmit:w,trailing:X,embedded:Y,className:_,testId:oo,field:S(e,{inputComponent:I,inputProps:{onChange:P,currentUser:R,allowEmptyQuery:!0,suggestionsPortalHost:document.querySelector("body"),withLightTheme:!1,mentionProps:{renderSuggestion:E},highlightLinks:!0,style:k},value:p,placeholder:Q,inputRef:po,className:F.mentionField,onKeyDown:function(o){"Enter"!==o.key||o.shiftKey||co&&!K&&(b()||(o.preventDefault(),w()))},disableUnderline:!0,rows:1,fullWidth:!0,multiline:!0,autoFocus:H}),attachments:io.items,onAttachmentRemove:io.removeAttachment,onAttachmentRetry:io.handleRetry,onAttachmentReorder:so?io.reorderAttachments:void 0,onFilesDrop:io.addFiles,onImageLinkPaste:io.addLinkedImage,dropLabel:1===io.maxFiles?"Drop a file here":"Drop files here",attachmentSlot:z?S(h,{errorMessage:z}):void 0,toolbar:O(A,{children:[S(u,{inputRef:io.fileInputRef,onClick:io.openFileDialog,onFileSelect:io.handleFileSelect,onWellhubSelect:q?function(){return lo(!0)}:void 0,multiple:so,disabled:io.isFull,tooltip:io.isFull?"Up to ".concat(io.maxFiles," ").concat(1===io.maxFiles?"file":"files"," can be attached"):"Attach ".concat(so?"files":"file")}),S(l,{title:"Mention someone",children:S(m,{size:"xs",type:"tertiary",onClick:function(){var o,s=po.current;if(s){s.focus();var t=!!s.value&&!/\s$/.test(s.value),n="".concat(s.value).concat(t?" @":"@"),i=null===(o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(s),"value"))||void 0===o?void 0:o.set;null==i||i.call(s,n),s.setSelectionRange(n.length,n.length),s.dispatchEvent(new Event("input",{bubbles:!0})),s.dispatchEvent(new Event("keyup",{bubbles:!0}))}},children:S(r,{fontSize:"inherit"})})}),S("span",{className:F.iconSlot,children:S(j,{icon:S(a,{size:16}),handleSelectEmoji:function(o){return P("".concat(p).concat(o.native))}})})]}),footer:(!(null==Z||!Z.length)||!!J)&&O(A,{children:[S(C,{rows:null!=Z?Z:[],singleLine:$}),J&&S(y,x({},J))]})}),q&&S(f,x(x({},q),{},{open:mo,maxSelectable:io.maxFiles-io.count,attachedFileNames:ao,onAdd:function(o){lo(!1),io.addStoredFiles(o.map((function(o){return{fileName:o.fileName}})))},onClose:function(){return lo(!1)}}))]})};export{w as CommentComposer};
|
|
2
2
|
//# sourceMappingURL=CommentComposer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommentComposer.js","sources":["../../../src/components/CommentComposer/CommentComposer.tsx"],"sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n onSubmit();\n };\n\n return (\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={trailing}\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n highlightLinks: true,\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : 'Attach file'\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","CommentComposer","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","fieldRef","useRef","CommentInput","field","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","highlightLinks","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","_Fragment","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","current","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","setSelectionRange","length","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread"],"mappings":"26KA4EA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WAAY,OACZC,YAAa,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AK,WAAWX,QAxFzB,WAAM,IAAAY,EACrBzD,EAAQH,GAAS6D,QACvB,GAAK1D,EAAL,CAEAA,EAAM2D,QAEN,IAAMC,IAAe5D,EAAMnB,QAAU,MAAMgF,KAAK7D,EAAMnB,OAChDiF,EAAe9D,GAAAA,OAAAA,EAAMnB,OAAQ+E,OAAAA,EAAa,KAAO,KACjDG,EAAiF,QAAtEC,EAAAA,OAAOC,yBAAyBD,OAAOE,eAAelE,GAAQ,gBAAQ,IAAAyD,OAAA,EAAtEA,EAAwEU,IAEzFJ,SAAAA,EAAUK,KAAKpE,EAAO8D,GACtB9D,EAAMqE,kBAAkBP,EAAUQ,OAAQR,EAAUQ,QACpDtE,EAAMuE,cAAc,IAAIC,MAAM,QAAS,CAAEC,SAAS,KAClDzE,EAAMuE,cAAc,IAAIC,MAAM,QAAS,CAAEC,SAAS,IAXtC,GAsF0DjI,SAC5DC,EAACiI,EAAkB,CAAC/I,SAAS,gBAGjCc,EAAA,OAAA,CAAMJ,UAAWC,EAAOqI,SAASnI,SAC/BC,EAACmI,EAAe,CACdC,KAAMpI,EAACqI,EAAe,CAACnI,KAAM,KAC7BoI,kBAAmB,SAACC,GAAyB,OAC3C5H,EAAgBD,GAAAA,OAAAA,UAAO6H,EAAMC,QAAS,SAMhDC,UACK5G,UAAAA,EAAUgG,WAAY9F,IACvBpC,EAAAsG,EAAA,CAAAlG,SAAA,CACEC,EAAC0I,EAAe,CAAC7D,KAAMhD,QAAAA,EAAY,GAAI8G,WAAY7G,IAClDC,GAAe/B,EAAC4I,EAAcC,EAAA,CAAA,EAAK9G,QAMhD"}
|
|
1
|
+
{"version":3,"file":"CommentComposer.js","sources":["../../../src/components/CommentComposer/CommentComposer.tsx"],"sourcesContent":["import {\n CSSProperties,\n FormEventHandler,\n KeyboardEvent,\n ReactNode,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Input } from '@material-ui/core';\nimport AlternateEmailIcon from '@material-ui/icons/AlternateEmail';\n\nimport { ButtonIcon } from '../../componentsV2/ButtonIcon';\nimport { Tooltip } from '../../componentsV2/Tooltip';\nimport { SmilingFaceIcon } from '../../icons';\nimport Avatar from '../Avatar';\nimport { AttachFileButton } from '../AttachFileButton';\nimport { CommentInput } from '../CommentInputNext/CommentInputNext';\nimport EmojiIconButton from '../EmojiIconButton';\nimport FailedFileUploading from '../FailedFileUploading';\nimport UserMention from '../UserMention';\nimport { isSuggestionsListOpened } from '../UserMention/utils';\nimport { WellhubFilePicker } from '../WellhubFilePicker';\nimport type { WellhubContext, WellhubFile } from '../WellhubFilePicker';\n\nimport {\n useAttachmentUpload,\n UploadedAttachment,\n DEFAULT_MAX_ATTACHMENTS,\n} from './useAttachmentUpload';\nimport { CommentMetaLine, CommentMetaRow } from './CommentMetaLine';\nimport { ShareToChatRow, ShareToChatRowProps } from './ShareToChatRow';\n\nimport styles from './CommentComposer.scss';\n\n/* eslint-disable camelcase -- mirrors the platform's snake_case user payload. */\nexport type CommentComposerUser = {\n id?: number;\n company_id?: number;\n first_name?: string;\n last_name?: string;\n profile_photo?: string;\n [key: string]: unknown;\n};\n/* eslint-enable camelcase */\n\nexport type CommentComposerProps = {\n body: string;\n onBodyChange: (value: string) => void;\n onSubmit: () => void;\n canSubmit: boolean;\n currentUser: CommentComposerUser;\n\n attachments?: UploadedAttachment[];\n onAttachmentsChange?: (attachments: UploadedAttachment[]) => void;\n maxAttachments?: number;\n /** @deprecated Use `attachments` — kept so single-attachment callers keep working. */\n attachment?: UploadedAttachment | null;\n /** @deprecated Use `onAttachmentsChange`. */\n onAttachmentChange?: (attachment: UploadedAttachment | null) => void;\n attachmentError?: string | null;\n onAttachmentError?: (message: string | null) => void;\n maxAttachmentSizeBytes?: number;\n wellhubContext?: WellhubContext;\n\n disabled?: boolean;\n autoFocus?: boolean;\n placeholder?: string;\n metaRows?: CommentMetaRow[];\n isMetaSingleLine?: boolean;\n shareToChat?: Omit<ShareToChatRowProps, 'testId'>;\n /** Replaces the default send button, e.g. the edit form's Cancel/Save. */\n trailing?: ReactNode;\n /** Render flush inside a host card instead of as its own surface. */\n embedded?: boolean;\n className?: string;\n testId?: string;\n};\n\nconst SUGGESTIONS_BACKGROUND = 'var(--palette-background-b-9)';\n\n// Module-level so react-mentions isn't re-rendered on every keystroke.\nconst MENTION_INPUT_STYLE = {\n fontSize: 14,\n lineHeight: '20px',\n suggestions: {\n backgroundColor: SUGGESTIONS_BACKGROUND,\n list: { backgroundColor: SUGGESTIONS_BACKGROUND },\n item: {\n color: 'var(--palette-primary-text-1)',\n '&focused': { backgroundColor: 'rgb(from var(--palette-primary-text-1) r g b / 0.08)' },\n },\n },\n} as unknown as CSSProperties;\n\nconst renderSuggestion = (entry: { display: string; photo?: string }) => (\n <div className={styles.suggestion}>\n <Avatar size={26} alt={entry.display} imgSrc={entry.photo} displayName={entry.display} />\n <span>{entry.display}</span>\n </div>\n);\n\nexport const CommentComposer = ({\n body,\n onBodyChange,\n onSubmit,\n canSubmit,\n currentUser,\n attachments,\n onAttachmentsChange,\n maxAttachments = DEFAULT_MAX_ATTACHMENTS,\n attachment,\n onAttachmentChange,\n attachmentError,\n onAttachmentError,\n maxAttachmentSizeBytes,\n wellhubContext,\n disabled,\n autoFocus,\n placeholder = 'Add a comment...',\n metaRows,\n isMetaSingleLine,\n shareToChat,\n trailing,\n embedded,\n className,\n testId,\n}: CommentComposerProps) => {\n // Callers still on the singular props get the old one-file behaviour, unchanged.\n const isMulti = !!onAttachmentsChange;\n const value = useMemo(\n () => (isMulti ? attachments ?? [] : ([attachment].filter(Boolean) as UploadedAttachment[])),\n [isMulti, attachments, attachment]\n );\n\n const handleAttachmentsChange = useCallback(\n (next: UploadedAttachment[]) => {\n if (onAttachmentsChange) onAttachmentsChange(next);\n else onAttachmentChange?.(next[0] ?? null);\n },\n [onAttachmentsChange, onAttachmentChange]\n );\n\n const upload = useAttachmentUpload({\n value,\n onChange: handleAttachmentsChange,\n onError: onAttachmentError,\n maxSizeBytes: maxAttachmentSizeBytes,\n maxFiles: isMulti ? maxAttachments : 1,\n });\n\n // An attachment only lands once S3 confirms, so posting mid-upload would drop it.\n const canSend = canSubmit && !upload.isUploading;\n\n const [isWellhubOpen, setIsWellhubOpen] = useState(false);\n const attachedKeys = useMemo(() => value.map(item => item.name), [value]);\n\n const addWellhubFiles = (files: WellhubFile[]) => {\n setIsWellhubOpen(false);\n upload.addStoredFiles(files.map(file => ({ fileName: file.fileName })));\n };\n\n const fieldRef = useRef<HTMLTextAreaElement | null>(null);\n\n // react-mentions opens suggestions from textarea events, so type \"@\" instead of setting state.\n const mentionSomeone = () => {\n const field = fieldRef.current;\n if (!field) return;\n\n field.focus();\n\n const needsSpace = !!field.value && !/\\s$/.test(field.value);\n const nextValue = `${field.value}${needsSpace ? ' @' : '@'}`;\n const setValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(field), 'value')?.set;\n\n setValue?.call(field, nextValue);\n field.setSelectionRange(nextValue.length, nextValue.length);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n field.dispatchEvent(new Event('keyup', { bubbles: true }));\n };\n\n const handleEnterKey = (event: KeyboardEvent) => {\n if (event.key !== 'Enter' || event.shiftKey) return;\n if (!canSend || disabled) return;\n if (isSuggestionsListOpened()) return;\n\n event.preventDefault();\n onSubmit();\n };\n\n return (\n <>\n <CommentInput\n value={body}\n canSubmit={canSend}\n disabled={disabled}\n onSubmit={onSubmit}\n trailing={trailing}\n embedded={embedded}\n className={className}\n testId={testId}\n field={\n <Input\n inputComponent={UserMention}\n inputProps={{\n // UserMention calls onChange with the text string, not a DOM event.\n onChange: onBodyChange as unknown as FormEventHandler<HTMLInputElement>,\n currentUser,\n allowEmptyQuery: true,\n suggestionsPortalHost: document.querySelector('body'),\n withLightTheme: false,\n mentionProps: { renderSuggestion },\n highlightLinks: true,\n style: MENTION_INPUT_STYLE,\n }}\n value={body}\n placeholder={placeholder}\n inputRef={fieldRef}\n className={styles.mentionField}\n onKeyDown={handleEnterKey}\n disableUnderline\n rows={1}\n fullWidth\n multiline\n autoFocus={autoFocus}\n />\n }\n attachments={upload.items}\n onAttachmentRemove={upload.removeAttachment}\n onAttachmentRetry={upload.handleRetry}\n onAttachmentReorder={isMulti ? upload.reorderAttachments : undefined}\n onFilesDrop={upload.addFiles}\n onImageLinkPaste={upload.addLinkedImage}\n dropLabel={upload.maxFiles === 1 ? 'Drop a file here' : 'Drop files here'}\n attachmentSlot={\n attachmentError ? <FailedFileUploading errorMessage={attachmentError} /> : undefined\n }\n toolbar={\n <>\n <AttachFileButton\n inputRef={upload.fileInputRef}\n onClick={upload.openFileDialog}\n onFileSelect={upload.handleFileSelect}\n onWellhubSelect={wellhubContext ? () => setIsWellhubOpen(true) : undefined}\n multiple={isMulti}\n disabled={upload.isFull}\n tooltip={\n upload.isFull\n ? `Up to ${upload.maxFiles} ${\n upload.maxFiles === 1 ? 'file' : 'files'\n } can be attached`\n : `Attach ${isMulti ? 'files' : 'file'}`\n }\n />\n <Tooltip title=\"Mention someone\">\n <ButtonIcon size=\"xs\" type=\"tertiary\" onClick={mentionSomeone}>\n <AlternateEmailIcon fontSize=\"inherit\" />\n </ButtonIcon>\n </Tooltip>\n <span className={styles.iconSlot}>\n <EmojiIconButton\n icon={<SmilingFaceIcon size={16} />}\n handleSelectEmoji={(emoji: { native: string }) =>\n onBodyChange(`${body}${emoji.native}`)\n }\n />\n </span>\n </>\n }\n footer={\n (!!metaRows?.length || !!shareToChat) && (\n <>\n <CommentMetaLine rows={metaRows ?? []} singleLine={isMetaSingleLine} />\n {shareToChat && <ShareToChatRow {...shareToChat} />}\n </>\n )\n }\n />\n\n {wellhubContext && (\n <WellhubFilePicker\n {...wellhubContext}\n open={isWellhubOpen}\n maxSelectable={upload.maxFiles - upload.count}\n attachedFileNames={attachedKeys}\n onAdd={addWellhubFiles}\n onClose={() => setIsWellhubOpen(false)}\n />\n )}\n </>\n );\n};\n"],"names":["MENTION_INPUT_STYLE","fontSize","lineHeight","suggestions","backgroundColor","list","item","color","renderSuggestion","entry","_jsxs","className","styles","suggestion","children","_jsx","Avatar","size","alt","display","imgSrc","photo","displayName","CommentComposer","_ref","body","onBodyChange","onSubmit","canSubmit","currentUser","attachments","onAttachmentsChange","_ref$maxAttachments","maxAttachments","DEFAULT_MAX_ATTACHMENTS","attachment","onAttachmentChange","attachmentError","onAttachmentError","maxAttachmentSizeBytes","wellhubContext","disabled","autoFocus","_ref$placeholder","placeholder","metaRows","isMetaSingleLine","shareToChat","trailing","embedded","testId","isMulti","value","useMemo","filter","Boolean","handleAttachmentsChange","useCallback","next","_next$","upload","useAttachmentUpload","onChange","onError","maxSizeBytes","maxFiles","canSend","isUploading","useState","_useState2","_slicedToArray","_useState","isWellhubOpen","setIsWellhubOpen","attachedKeys","map","name","fieldRef","useRef","_Fragment","CommentInput","field","Input","inputComponent","UserMention","inputProps","allowEmptyQuery","suggestionsPortalHost","document","querySelector","withLightTheme","mentionProps","highlightLinks","style","inputRef","mentionField","onKeyDown","event","key","shiftKey","isSuggestionsListOpened","preventDefault","disableUnderline","rows","fullWidth","multiline","items","onAttachmentRemove","removeAttachment","onAttachmentRetry","handleRetry","onAttachmentReorder","reorderAttachments","undefined","onFilesDrop","addFiles","onImageLinkPaste","addLinkedImage","dropLabel","attachmentSlot","FailedFileUploading","errorMessage","toolbar","AttachFileButton","fileInputRef","onClick","openFileDialog","onFileSelect","handleFileSelect","onWellhubSelect","multiple","isFull","tooltip","concat","Tooltip","title","ButtonIcon","type","_Object$getOwnPropert","current","focus","needsSpace","test","nextValue","setValue","Object","getOwnPropertyDescriptor","getPrototypeOf","set","call","setSelectionRange","length","dispatchEvent","Event","bubbles","AlternateEmailIcon","iconSlot","EmojiIconButton","icon","SmilingFaceIcon","handleSelectEmoji","emoji","native","footer","CommentMetaLine","singleLine","ShareToChatRow","_objectSpread","WellhubFilePicker","open","maxSelectable","count","attachedFileNames","onAdd","files","addStoredFiles","file","fileName","onClose"],"mappings":"mqMAgFA,IAGMA,EAAsB,CAC1BC,SAAU,GACVC,WA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,GAAIwH,WAAYvH,IAClDC,GAAehC,EAACuJ,EAAcC,EAAA,CAAA,EAAKxH,SAM3CP,GACCzB,EAACyJ,SACKhI,GAAc,GAAA,CAClBiI,KAAMjG,GACNkG,cAAe9G,GAAOK,SAAWL,GAAO+G,MACxCC,kBAAmBlG,GACnBmG,MAhIgB,SAACC,GACvBrG,IAAiB,GACjBb,GAAOmH,eAAeD,EAAMnG,KAAI,SAAAqG,GAAI,MAAK,CAAEC,SAAUD,EAAKC,SAAW,MA+H/DC,QAAS,WAAA,OAAMzG,IAAiB,EAAM,OAKhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAttachmentUpload.stored.test.d.ts","sourceRoot":"","sources":["../../../../src/components/CommentComposer/__tests__/useAttachmentUpload.stored.test.tsx"],"names":[],"mappings":""}
|
|
@@ -22,6 +22,10 @@ export declare const useAttachmentUpload: ({ value, onChange, onError, maxSizeBy
|
|
|
22
22
|
handleFileSelect: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
23
23
|
addFiles: (files: File[]) => void;
|
|
24
24
|
addLinkedImage: (url: string) => void;
|
|
25
|
+
addStoredFiles: (files: {
|
|
26
|
+
fileName: string;
|
|
27
|
+
size?: number;
|
|
28
|
+
}[]) => Promise<void>;
|
|
25
29
|
removeAttachment: (id: AttachmentPreviewItem['id']) => void;
|
|
26
30
|
handleRetry: (id: AttachmentPreviewItem['id']) => void;
|
|
27
31
|
reorderAttachments: (orderedIds: AttachmentPreviewItem['id'][]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAttachmentUpload.d.ts","sourceRoot":"","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA4C,MAAM,OAAO,CAAC;AAG9E,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,8CAA8C,CAAC;AAQtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAA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AcF,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAkD1C,eAAO,MAAM,mBAAmB,kEAO7B,0BAA0B;;;;8BA8PjB,WAAW,CAAC,gBAAgB,CAAC;sBApD7B,IAAI,EAAE;0BAnFR,MAAM;4BA8BE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;2BAqH9C,qBAAqB,CAAC,IAAI,CAAC;sBAW3B,qBAAqB,CAAC,IAAI,CAAC;qCAcnB,qBAAqB,CAAC,IAAI,CAAC,EAAE;;;;;;;CA2H7C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import r from"@babel/runtime/helpers/toConsumableArray";import e from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/slicedToArray";import i from"@babel/runtime/regenerator";import{useState as o,useRef as u,useCallback as l,useEffect as c}from"react";import a from"react-s3-uploader/s3upload";import{getAttachmentKind as f}from"../AttachmentPreview/getAttachmentKind.js";import{ACCEPTED_ATTACHMENT_TYPES as s}from"../AttachFileButton/AttachFileButton.js";import{getS3SignedUrl as d}from"../../clients/jsonApi/index.js";import{getUrlFileName as p}from"../../utils/links.js";import{getSignedLink as v,peekSignedLink as m}from"../../utils/signedLinkCache.js";function h(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function g(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?h(Object(t),!0).forEach((function(e){n(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}var b=10,w=function(r){return r.type.startsWith("image/")?"image":r.type.startsWith("video/")?"video":"file"},U=function(r){return(r/1048576).toFixed(1)},y=function(r){return{id:r.url,name:r.name,file:null,previewUrl:"",isUploading:!1,error:null,uploaded:r}},j=0,O=function(){return"attachment-".concat(j+=1)},k=function(n){var h,b,j=n.value,k=n.onChange,F=n.onError,x=n.maxSizeBytes,L=n.maxFiles,P=void 0===L?10:L,A=n.accept,S=void 0===A?s:A,z=o([]),E=t(z,2),R=E[0],B=E[1],C=u(null),D=u(new Map),M=u(new Map),W=u([]),T=u(k),I=u(F);T.current=k,I.current=F;var Y=u([]),_=l((function(r){var e=r(W.current);W.current=e,B(e),Y.current=function(r){return r.map((function(r){return r.uploaded})).filter(Boolean)}(e),T.current(Y.current)}),[]),G=l((function(r,e){return _((function(n){return n.map((function(n){return n.id===r?g(g({},n),e):n}))}))}),[_]),K=l((function(r){var e,n;null===(e=D.current.get(r))||void 0===e||e.abortUpload(),D.current.delete(r),M.current.set(r,(null!==(n=M.current.get(r))&&void 0!==n?n:0)+1)}),[]),q=l((function(r){null!=r&&r.previewUrl&&URL.revokeObjectURL(r.previewUrl)}),[]),H=l((function(){var r,e,n;null===(r=I.current)||void 0===r||r.call(I,null!==(e=null===(n=W.current.find((function(r){return r.error})))||void 0===n?void 0:n.error)&&void 0!==e?e:null)}),[]);c((function(){return function(){D.current.forEach((function(r){return r.abortUpload()})),D.current.clear(),W.current.forEach((function(r){r.previewUrl&&URL.revokeObjectURL(r.previewUrl)}))}}),[]);var J=l((function(r,n){var t,o=(null!==(t=M.current.get(r))&&void 0!==t?t:0)+1;M.current.set(r,o);var u,l,c=function(){return M.current.get(r)===o},f=function(e){var n;c()&&(G(r,{isUploading:!1,error:e}),null===(n=I.current)||void 0===n||n.call(I,e))},s="",p=new a({files:[n],preprocess:function(r,e){return e(r)},onProgress:function(){},getSignedUrl:(l=e(i.mark((function r(e,n){var t;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,d(e.name,e.type);case 3:t=r.sent,s=t.file_name,n(g(g({},t),{},{signedUrl:t.signed_url})),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(0),f((null===r.t0||void 0===r.t0?void 0:r.t0.message)||"Failed to upload the file");case 11:case"end":return r.stop()}}),r,null,[[0,8]])}))),function(r,e){return l.apply(this,arguments)}),onFinishS3Put:(u=e(i.mark((function e(){var t;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,v(s);case 3:if(t=e.sent,c()){e.next=6;break}return e.abrupt("return");case 6:D.current.delete(r),G(r,{isUploading:!1,error:null,uploaded:{url:t,name:s,size:n.size}}),H(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(0),f((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"Failed to upload the file");case 14:case"end":return e.stop()}}),e,null,[[0,11]])}))),function(){return u.apply(this,arguments)}),onError:function(r){return f(r||"Failed to upload the file")}});D.current.set(r,p)}),[G,H]),N=l((function(e){var n,t=p(e);t&&(W.current.length>=P?null===(n=I.current)||void 0===n||n.call(I,"You can attach up to ".concat(P," files.")):W.current.some((function(r){var n;return(null===(n=r.uploaded)||void 0===n?void 0:n.url)===e}))||_((function(n){return[].concat(r(n),[{id:O(),name:t,file:null,previewUrl:e,isUploading:!1,error:null,uploaded:{url:e,name:t}}])})))}),[_,P]),Q=l((function(e){var n,t,i,o,u=e.filter((function(r){return function(r,e){return e.split(",").map((function(r){return r.trim().toLowerCase()})).filter(Boolean).some((function(e){if(e.startsWith("."))return r.name.toLowerCase().endsWith(e);if(e.endsWith("/*")){var n=r.type.toLowerCase();return n?n.startsWith(e.slice(0,-1)):f({name:r.name})===e.slice(0,-1)}return r.type.toLowerCase()===e}))}(r,S)})),l=u.length<e.length?1===e.length?"That file type is not supported.":"Some files were skipped — unsupported file type.":null,c="You can attach up to ".concat(P," files."),a=P-W.current.length;if(!u.length||a<=0){var s;null===(s=I.current)||void 0===s||s.call(I,u.length?c:l)}else{var d=u.slice(0,a),p=d.map((function(r){var e=w(r),n=!!x&&r.size>x;return{id:O(),name:r.name,file:r,previewUrl:"file"===e?"":URL.createObjectURL(r),isUploading:!n,error:n?"File is too large (".concat(U(r.size)," MB). Maximum size is ").concat(U(x)," MB."):null,uploaded:null}}));_((function(e){return[].concat(r(e),r(p))}));var v=u.length>d.length?c:null;null===(n=I.current)||void 0===n||n.call(I,null!==(t=null!==(i=null===(o=W.current.find((function(r){return r.error})))||void 0===o?void 0:o.error)&&void 0!==i?i:l)&&void 0!==t?t:v),p.filter((function(r){return!r.error})).forEach((function(r){return J(r.id,r.file)}))}}),[_,P,x,J,S]),V=l((function(r){var e,n=Array.from(null!==(e=r.target.files)&&void 0!==e?e:[]);C.current&&(C.current.value=""),n.length&&Q(n)}),[Q]),X=l((function(){var r;return null===(r=C.current)||void 0===r?void 0:r.click()}),[]),Z=l((function(r){var e=String(r);K(e),q(W.current.find((function(r){return r.id===e}))),_((function(r){return r.filter((function(r){return r.id!==e}))})),H()}),[K,q,_,H]),$=l((function(r){var e=String(r),n=W.current.find((function(r){return r.id===e}));null!=n&&n.file&&(K(e),G(e,{isUploading:!0,error:null}),H(),J(e,n.file))}),[K,G,J,H]),rr=l((function(e){return _((function(n){var t=new Map(n.map((function(r){return[r.id,r]}))),i=e.map((function(r){return t.get(String(r))})).filter(Boolean),o=n.filter((function(r){return!e.some((function(e){return String(e)===r.id}))}));return[].concat(r(i),r(o))}))}),[_]),er=l((function(){var r;W.current.forEach((function(r){K(r.id),q(r)})),_((function(){return[]})),null===(r=I.current)||void 0===r||r.call(I,null)}),[K,_,q]);c((function(){var r,e,n;(e=Y.current,n=j,e.length===n.length&&e.every((function(r,e){return r.url===n[e].url})))||(W.current.forEach((function(r){K(r.id),r.previewUrl&&URL.revokeObjectURL(r.previewUrl)})),W.current=j.map(y),Y.current=j,B(W.current),null===(r=I.current)||void 0===r||r.call(I,null))}),[j,K]);var nr=o((function(){return j.reduce((function(r,e){var n=m(e.name,"inline");return n&&(r[e.name]=n),r}),{})})),tr=t(nr,2),ir=tr[0],or=tr[1],ur=u(ir);ur.current=ir;var lr=R.filter((function(r){return!r.file&&!r.previewUrl&&r.uploaded})).map((function(r){return r.uploaded.name})).join("|");return c((function(){var r=lr.split("|").filter((function(r){return r&&!(r in ur.current)}));if(r.length){var e=!0;return Promise.all(r.map((function(r){return v(r,"inline").then((function(e){return[r,e]})).catch((function(e){return console.error('Failed to sign stored attachment "'.concat(r,'"'),e),[r,""]}))}))).then((function(r){e&&or((function(e){return g(g({},e),Object.fromEntries(r))}))})),function(){e=!1}}}),[lr]),{items:R.reduce((function(r,e){var n;if(e.file)return r.push({id:e.id,name:e.name,src:e.previewUrl,kind:w(e.file),size:e.file.size,isUploading:e.isUploading,hideDownload:!0,error:null!==(n=e.error)&&void 0!==n?n:void 0}),r;var t=e.uploaded,i=f(t),o=e.previewUrl||ir[t.name];return"file"===i||o?(r.push({id:e.id,name:t.name,src:o,kind:i,size:t.size,hideDownload:!0}),r):r}),[]),fileInputRef:C,openFileDialog:X,handleFileSelect:V,addFiles:Q,addLinkedImage:N,removeAttachment:Z,handleRetry:$,reorderAttachments:rr,clearAttachments:er,isUploading:R.some((function(r){return r.isUploading})),error:null!==(h=null===(b=R.find((function(r){return r.error})))||void 0===b?void 0:b.error)&&void 0!==h?h:null,count:R.length,isFull:R.length>=P,maxFiles:P}};export{b as DEFAULT_MAX_ATTACHMENTS,k as useAttachmentUpload};
|
|
1
|
+
import r from"@babel/runtime/helpers/toConsumableArray";import e from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/slicedToArray";import i from"@babel/runtime/regenerator";import{useState as u,useRef as o,useCallback as l,useEffect as c}from"react";import a from"react-s3-uploader/s3upload";import{getAttachmentKind as f}from"../AttachmentPreview/getAttachmentKind.js";import{ACCEPTED_ATTACHMENT_TYPES as s}from"../AttachFileButton/AttachFileButton.js";import{getS3SignedUrl as d}from"../../clients/jsonApi/index.js";import{getUrlFileName as p}from"../../utils/links.js";import{getSignedLink as v,peekSignedLink as m}from"../../utils/signedLinkCache.js";function h(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function g(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?h(Object(t),!0).forEach((function(e){n(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):h(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}var b=10,w=function(r){return r.type.startsWith("image/")?"image":r.type.startsWith("video/")?"video":"file"},U=function(r){return(r/1048576).toFixed(1)},y=function(r){return{id:r.url,name:r.name,file:null,previewUrl:"",isUploading:!1,error:null,uploaded:r}},j=0,O=function(){return"attachment-".concat(j+=1)},x=function(n){var h,b,j=n.value,x=n.onChange,k=n.onError,F=n.maxSizeBytes,L=n.maxFiles,P=void 0===L?10:L,z=n.accept,S=void 0===z?s:z,A=u([]),E=t(A,2),R=E[0],B=E[1],C=o(null),D=o(new Map),M=o(new Map),W=o([]),N=o(x),Y=o(k);N.current=x,Y.current=k;var I=o([]),T=l((function(r){var e=r(W.current);W.current=e,B(e),I.current=function(r){return r.map((function(r){return r.uploaded})).filter(Boolean)}(e),N.current(I.current)}),[]),_=l((function(r,e){return T((function(n){return n.map((function(n){return n.id===r?g(g({},n),e):n}))}))}),[T]),G=l((function(r){var e,n;null===(e=D.current.get(r))||void 0===e||e.abortUpload(),D.current.delete(r),M.current.set(r,(null!==(n=M.current.get(r))&&void 0!==n?n:0)+1)}),[]),K=l((function(r){null!=r&&r.previewUrl&&URL.revokeObjectURL(r.previewUrl)}),[]),q=l((function(){var r,e,n;null===(r=Y.current)||void 0===r||r.call(Y,null!==(e=null===(n=W.current.find((function(r){return r.error})))||void 0===n?void 0:n.error)&&void 0!==e?e:null)}),[]);c((function(){return function(){D.current.forEach((function(r){return r.abortUpload()})),D.current.clear(),W.current.forEach((function(r){r.previewUrl&&URL.revokeObjectURL(r.previewUrl)}))}}),[]);var H=l((function(r,n){var t,u=(null!==(t=M.current.get(r))&&void 0!==t?t:0)+1;M.current.set(r,u);var o,l,c=function(){return M.current.get(r)===u},f=function(e){var n;c()&&(_(r,{isUploading:!1,error:e}),null===(n=Y.current)||void 0===n||n.call(Y,e))},s="",p=new a({files:[n],preprocess:function(r,e){return e(r)},onProgress:function(){},getSignedUrl:(l=e(i.mark((function r(e,n){var t;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,d(e.name,e.type);case 3:t=r.sent,s=t.file_name,n(g(g({},t),{},{signedUrl:t.signed_url})),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(0),f((null===r.t0||void 0===r.t0?void 0:r.t0.message)||"Failed to upload the file");case 11:case"end":return r.stop()}}),r,null,[[0,8]])}))),function(r,e){return l.apply(this,arguments)}),onFinishS3Put:(o=e(i.mark((function e(){var t;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,v(s);case 3:if(t=e.sent,c()){e.next=6;break}return e.abrupt("return");case 6:D.current.delete(r),_(r,{isUploading:!1,error:null,uploaded:{url:t,name:s,size:n.size}}),q(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(0),f((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"Failed to upload the file");case 14:case"end":return e.stop()}}),e,null,[[0,11]])}))),function(){return o.apply(this,arguments)}),onError:function(r){return f(r||"Failed to upload the file")}});D.current.set(r,p)}),[_,q]),J=l((function(e){var n,t=p(e);t&&(W.current.length>=P?null===(n=Y.current)||void 0===n||n.call(Y,"You can attach up to ".concat(P," files.")):W.current.some((function(r){var n;return(null===(n=r.uploaded)||void 0===n?void 0:n.url)===e}))||T((function(n){return[].concat(r(n),[{id:O(),name:t,file:null,previewUrl:e,isUploading:!1,error:null,uploaded:{url:e,name:t}}])})))}),[T,P]),Q=l(function(){var n=e(i.mark((function e(n){var t,u,o,l,c,a,f,s,d,p,m;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((o=n.filter((function(r,e,n){return!W.current.some((function(e){var n;return(null===(n=e.uploaded)||void 0===n?void 0:n.name)===r.fileName}))&&n.findIndex((function(e){return e.fileName===r.fileName}))===e}))).length){e.next=3;break}return e.abrupt("return");case 3:if(!((l=P-W.current.length)<=0)){e.next=7;break}return null===(c=Y.current)||void 0===c||c.call(Y,"You can attach up to ".concat(P," files.")),e.abrupt("return");case 7:return a=o.slice(0,l),e.next=10,Promise.all(a.map((function(r){return v(r.fileName).then((function(e){return{url:e,name:r.fileName,size:r.size}})).catch((function(){return null}))})));case 10:f=e.sent,s=f.filter(Boolean),d=0,s.length&&T((function(e){var n=s.slice(0,Math.max(P-e.length,0));return d=n.length,[].concat(r(e),r(n.map((function(r){return g(g({},y(r)),{},{id:O()})}))))})),p=f.length-s.length,m=o.length>a.length||d<s.length,null===(t=Y.current)||void 0===t||t.call(Y,p&&"Could not attach ".concat(1===p?"a file":"".concat(p," files")," from Wellhub.")||m&&"You can attach up to ".concat(P," files.")||(null===(u=W.current.find((function(r){return r.error})))||void 0===u?void 0:u.error)||null);case 17:case"end":return e.stop()}}),e)})));return function(r){return n.apply(this,arguments)}}(),[T,P]),V=l((function(e){var n,t,i,u,o=e.filter((function(r){return function(r,e){return e.split(",").map((function(r){return r.trim().toLowerCase()})).filter(Boolean).some((function(e){if(e.startsWith("."))return r.name.toLowerCase().endsWith(e);if(e.endsWith("/*")){var n=r.type.toLowerCase();return n?n.startsWith(e.slice(0,-1)):f({name:r.name})===e.slice(0,-1)}return r.type.toLowerCase()===e}))}(r,S)})),l=o.length<e.length?1===e.length?"That file type is not supported.":"Some files were skipped — unsupported file type.":null,c="You can attach up to ".concat(P," files."),a=P-W.current.length;if(!o.length||a<=0){var s;null===(s=Y.current)||void 0===s||s.call(Y,o.length?c:l)}else{var d=o.slice(0,a),p=d.map((function(r){var e=w(r),n=!!F&&r.size>F;return{id:O(),name:r.name,file:r,previewUrl:"file"===e?"":URL.createObjectURL(r),isUploading:!n,error:n?"File is too large (".concat(U(r.size)," MB). Maximum size is ").concat(U(F)," MB."):null,uploaded:null}}));T((function(e){return[].concat(r(e),r(p))}));var v=o.length>d.length?c:null;null===(n=Y.current)||void 0===n||n.call(Y,null!==(t=null!==(i=null===(u=W.current.find((function(r){return r.error})))||void 0===u?void 0:u.error)&&void 0!==i?i:l)&&void 0!==t?t:v),p.filter((function(r){return!r.error})).forEach((function(r){return H(r.id,r.file)}))}}),[T,P,F,H,S]),X=l((function(r){var e,n=Array.from(null!==(e=r.target.files)&&void 0!==e?e:[]);C.current&&(C.current.value=""),n.length&&V(n)}),[V]),Z=l((function(){var r;return null===(r=C.current)||void 0===r?void 0:r.click()}),[]),$=l((function(r){var e=String(r);G(e),K(W.current.find((function(r){return r.id===e}))),T((function(r){return r.filter((function(r){return r.id!==e}))})),q()}),[G,K,T,q]),rr=l((function(r){var e=String(r),n=W.current.find((function(r){return r.id===e}));null!=n&&n.file&&(G(e),_(e,{isUploading:!0,error:null}),q(),H(e,n.file))}),[G,_,H,q]),er=l((function(e){return T((function(n){var t=new Map(n.map((function(r){return[r.id,r]}))),i=e.map((function(r){return t.get(String(r))})).filter(Boolean),u=n.filter((function(r){return!e.some((function(e){return String(e)===r.id}))}));return[].concat(r(i),r(u))}))}),[T]),nr=l((function(){var r;W.current.forEach((function(r){G(r.id),K(r)})),T((function(){return[]})),null===(r=Y.current)||void 0===r||r.call(Y,null)}),[G,T,K]);c((function(){var r,e,n;(e=I.current,n=j,e.length===n.length&&e.every((function(r,e){return r.url===n[e].url})))||(W.current.forEach((function(r){G(r.id),r.previewUrl&&URL.revokeObjectURL(r.previewUrl)})),W.current=j.map(y),I.current=j,B(W.current),null===(r=Y.current)||void 0===r||r.call(Y,null))}),[j,G]);var tr=u((function(){return j.reduce((function(r,e){var n=m(e.name,"inline");return n&&(r[e.name]=n),r}),{})})),ir=t(tr,2),ur=ir[0],or=ir[1],lr=o(ur);lr.current=ur;var cr=R.filter((function(r){return!r.file&&!r.previewUrl&&r.uploaded})).map((function(r){return r.uploaded.name})).join("|");return c((function(){var r=cr.split("|").filter((function(r){return r&&!(r in lr.current)}));if(r.length){var e=!0;return Promise.all(r.map((function(r){return v(r,"inline").then((function(e){return[r,e]})).catch((function(e){return console.error('Failed to sign stored attachment "'.concat(r,'"'),e),[r,""]}))}))).then((function(r){e&&or((function(e){return g(g({},e),Object.fromEntries(r))}))})),function(){e=!1}}}),[cr]),{items:R.reduce((function(r,e){var n;if(e.file)return r.push({id:e.id,name:e.name,src:e.previewUrl,kind:w(e.file),size:e.file.size,isUploading:e.isUploading,hideDownload:!0,error:null!==(n=e.error)&&void 0!==n?n:void 0}),r;var t=e.uploaded,i=f(t),u=e.previewUrl||ur[t.name];return"file"===i||u?(r.push({id:e.id,name:t.name,src:u,kind:i,size:t.size,hideDownload:!0}),r):r}),[]),fileInputRef:C,openFileDialog:Z,handleFileSelect:X,addFiles:V,addLinkedImage:J,addStoredFiles:Q,removeAttachment:$,handleRetry:rr,reorderAttachments:er,clearAttachments:nr,isUploading:R.some((function(r){return r.isUploading})),error:null!==(h=null===(b=R.find((function(r){return r.error})))||void 0===b?void 0:b.error)&&void 0!==h?h:null,count:R.length,isFull:R.length>=P,maxFiles:P}};export{b as DEFAULT_MAX_ATTACHMENTS,x as useAttachmentUpload};
|
|
2
2
|
//# sourceMappingURL=useAttachmentUpload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAttachmentUpload.js","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl } from '~/clients/jsonApi';\nimport { getUrlFileName } from '~/utils/links';\nimport { getSignedLink, peekSignedLink } from '~/utils/signedLinkCache';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const url = await getSignedLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n /** Nothing is uploaded: a comment attachment is a url, so the link itself is the attachment. */\n const addLinkedImage = useCallback(\n (url: string) => {\n const name = getUrlFileName(url);\n\n if (!name) return;\n if (entriesRef.current.length >= maxFiles) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n if (entriesRef.current.some(entry => entry.uploaded?.url === url)) return;\n\n commit(prev => [\n ...prev,\n {\n id: nextEntryId(),\n name,\n file: null,\n previewUrl: url,\n isUploading: false,\n error: null,\n uploaded: { url, name },\n },\n ]);\n },\n [commit, maxFiles]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>(() =>\n value.reduce<Record<string, string>>((acc, attachment) => {\n const src = peekSignedLink(attachment.name, 'inline');\n if (src) acc[attachment.name] = src;\n\n return acc;\n }, {})\n );\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n // A linked image carries its own url, so there is no key of ours to sign.\n .filter(entry => !entry.file && !entry.previewUrl && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getSignedLink(name, 'inline')\n .then(url => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n size: entry.file.size,\n isUploading: entry.isUploading,\n hideDownload: true,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n // A linked image is already a url; only one of ours has an S3 key worth signing.\n const src = entry.previewUrl || storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind, size: stored.size, hideDownload: true });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n addLinkedImage,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["DEFAULT_MAX_ATTACHMENTS","getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","nextEntryId","concat","useAttachmentUpload","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_context2","getSignedLink","abrupt","size","addLinkedImage","_onErrorRef$current3","getUrlFileName","length","some","_entry$uploaded","_toConsumableArray","addFiles","_onErrorRef$current5","_ref2","_entriesRef$current$f3","_entriesRef$current$f4","supported","split","rule","trim","toLowerCase","endsWith","slice","getAttachmentKind","isAcceptedType","unsupported","tooMany","room","_onErrorRef$current4","accepted","added","kind","isTooLarge","createObjectURL","overflow","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current6","_onErrorRef$current7","a","b","every","index","_useState3","reduce","acc","src","peekSignedLink","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","Promise","all","then","catch","console","resolved","_objectSpread","Object","fromEntries","items","_entry$error","push","hideDownload","undefined","stored","count","isFull"],"mappings":"myCA0CO,IAAMA,EAA0B,GAoBjCC,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,QACvCF,EAAKC,KAAKC,WAAW,UAAkB,QACpC,MACT,EAEMC,EAAW,SAACC,GAAa,OAAMA,EAAK,SAAkBC,QAAQ,EAAE,EAQhEC,EAAgB,SAACC,GAA8B,MAAa,CAChEC,GAAID,EAAWE,IACfC,KAAMH,EAAWG,KACjBV,KAAM,KACNW,WAAY,GACZC,aAAa,EACbC,MAAO,KACPC,SAAUP,EACX,EAEGQ,EAAW,EACTC,EAAc,WAElB,MAAA,cAAAC,OADAF,GAAY,EAEd,EAEaG,EAAsB,SAODC,GAAA,IAAAC,EAAAC,EANhCC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,QACAC,IAAAA,aAAYC,EAAAP,EACZQ,SAAAA,aAvDqC,GAuDHD,EAAAE,EAAAT,EAClCU,OAAAA,aAASC,EAAyBF,EAEJG,EAAAA,EAAkB,IAAGC,EAAAC,EAAAC,EAAA,GAA5CC,EAAOH,EAAA,GAAEI,EAAUJ,EAAA,GAEpBK,EAAeC,EAAyB,MACxCC,EAAeD,EAAO,IAAIE,KAE1BC,EAAcH,EAAO,IAAIE,KAEzBE,EAAaJ,EAAgB,IAC7BK,EAAcL,EAAOf,GACrBqB,EAAaN,EAAOd,GAE1BmB,EAAYE,QAAUtB,EACtBqB,EAAWC,QAAUrB,EAIrB,IAAMsB,EAAaR,EAA6B,IAE1CS,EAASC,GAAY,SAACC,GAC1B,IAAMC,EAAOD,EAAQP,EAAWG,SAChCH,EAAWG,QAAUK,EACrBd,EAAWc,GACXJ,EAAWD,QApDK,SAACV,GAAgB,OACnCA,EAAQgB,KAAI,SAAAC,GAAK,OAAIA,EAAMtC,QAAQ,IAAEuC,OAAO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ACzCC,MAAgD,UAAzC,UAAAsB,EAAQqC,MAAK,SAAApB,GAAK,OAAIA,EAAMvC,KAAK,WAAjC,IAAAQ,OAAA,EAAAA,EAAoCR,aAAK,IAAAO,EAAAA,EAAI,KACpDwL,MAAOzK,EAAQwF,OACfkF,OAAQ1K,EAAQwF,QAAUhG,EAC1BA,SAAAA,EAEJ"}
|
|
1
|
+
{"version":3,"file":"useAttachmentUpload.js","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl } from '~/clients/jsonApi';\nimport { getUrlFileName } from '~/utils/links';\nimport { getSignedLink, peekSignedLink } from '~/utils/signedLinkCache';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const url = await getSignedLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n /** Nothing is uploaded: a comment attachment is a url, so the link itself is the attachment. */\n const addLinkedImage = useCallback(\n (url: string) => {\n const name = getUrlFileName(url);\n\n if (!name) return;\n if (entriesRef.current.length >= maxFiles) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n if (entriesRef.current.some(entry => entry.uploaded?.url === url)) return;\n\n commit(prev => [\n ...prev,\n {\n id: nextEntryId(),\n name,\n file: null,\n previewUrl: url,\n isUploading: false,\n error: null,\n uploaded: { url, name },\n },\n ]);\n },\n [commit, maxFiles]\n );\n\n /** Attaches files already in S3 (e.g. Wellhub picks): nothing to upload, the key is signed. */\n const addStoredFiles = useCallback(\n async (files: { fileName: string; size?: number }[]) => {\n const fresh = files.filter(\n (file, index, list) =>\n !entriesRef.current.some(entry => entry.uploaded?.name === file.fileName) &&\n list.findIndex(other => other.fileName === file.fileName) === index\n );\n if (!fresh.length) return;\n\n const room = maxFiles - entriesRef.current.length;\n if (room <= 0) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n const accepted = fresh.slice(0, room);\n const signed = await Promise.all(\n accepted.map(file =>\n getSignedLink(file.fileName)\n .then(url => ({ url, name: file.fileName, size: file.size }))\n .catch(() => null)\n )\n );\n const attachments = signed.filter(Boolean) as UploadedAttachment[];\n\n // Files may have been dropped in while the keys were signing, so re-check the room.\n let added = 0;\n if (attachments.length) {\n commit(prev => {\n const fitting = attachments.slice(0, Math.max(maxFiles - prev.length, 0));\n added = fitting.length;\n\n return [\n ...prev,\n ...fitting.map(attachment => ({ ...toStoredEntry(attachment), id: nextEntryId() })),\n ];\n });\n }\n\n const failed = signed.length - attachments.length;\n const overflow = fresh.length > accepted.length || added < attachments.length;\n onErrorRef.current?.(\n (failed &&\n `Could not attach ${failed === 1 ? 'a file' : `${failed} files`} from Wellhub.`) ||\n (overflow && `You can attach up to ${maxFiles} files.`) ||\n entriesRef.current.find(entry => entry.error)?.error ||\n null\n );\n },\n [commit, maxFiles]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>(() =>\n value.reduce<Record<string, string>>((acc, attachment) => {\n const src = peekSignedLink(attachment.name, 'inline');\n if (src) acc[attachment.name] = src;\n\n return acc;\n }, {})\n );\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n // A linked image carries its own url, so there is no key of ours to sign.\n .filter(entry => !entry.file && !entry.previewUrl && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getSignedLink(name, 'inline')\n .then(url => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n size: entry.file.size,\n isUploading: entry.isUploading,\n hideDownload: true,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n // A linked image is already a url; only one of ours has an S3 key worth signing.\n const src = entry.previewUrl || storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind, size: stored.size, hideDownload: true });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n addLinkedImage,\n addStoredFiles,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["DEFAULT_MAX_ATTACHMENTS","getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","nextEntryId","concat","useAttachmentUpload","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_context2","getSignedLink","abrupt","size","addLinkedImage","_onErrorRef$current3","getUrlFileName","length","some","_entry$uploaded","_toConsumableArray","addStoredFiles","_ref2","_onErrorRef$current5","_entriesRef$current$f3","fresh","room","_onErrorRef$current4","accepted","signed","attachments","added","failed","overflow","_context3","index","list","_entry$uploaded2","fileName","findIndex","other","slice","Promise","all","then","catch","fitting","Math","max","_callee3","_x3","addFiles","_onErrorRef$current7","_ref3","_entriesRef$current$f4","_entriesRef$current$f5","supported","split","rule","trim","toLowerCase","endsWith","getAttachmentKind","isAcceptedType","unsupported","tooMany","_onErrorRef$current6","kind","isTooLarge","createObjectURL","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current8","_onErrorRef$current9","a","b","every","_useState3","reduce","acc","src","peekSignedLink","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","console","resolved","_objectSpread","Object","fromEntries","items","_entry$error","push","hideDownload","undefined","stored","count","isFull"],"mappings":"myCA0CO,IAAMA,EAA0B,GAoBjCC,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,QACvCF,EAAKC,KAAKC,WAAW,UAAkB,QACpC,MACT,EAEMC,EAAW,SAACC,GAAa,OAAMA,EAAK,SAAkBC,QAAQ,EAAE,EAQhEC,EAAgB,SAACC,GAA8B,MAAa,CAChEC,GAAID,EAAWE,IACfC,KAAMH,EAAWG,KACjBV,KAAM,KACNW,WAAY,GACZC,aAAa,EACbC,MAAO,KACPC,SAAUP,EACX,EAEGQ,EAAW,EACTC,EAAc,WAElB,MAAA,cAAAC,OADAF,GAAY,EAEd,EAEaG,EAAsB,SAODC,GAAA,IAAAC,EAAAC,EANhCC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,QACAC,IAAAA,aAAYC,EAAAP,EACZQ,SAAAA,aAvDqC,GAuDHD,EAAAE,EAAAT,EAClCU,OAAAA,aAASC,EAAyBF,EAEJG,EAAAA,EAAkB,IAAGC,EAAAC,EAAAC,EAAA,GAA5CC,EAAOH,EAAA,GAAEI,EAAUJ,EAAA,GAEpBK,EAAeC,EAAyB,MACxCC,EAAeD,EAAO,IAAIE,KAE1BC,EAAcH,EAAO,IAAIE,KAEzBE,EAAaJ,EAAgB,IAC7BK,EAAcL,EAAOf,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