{"version":3,"file":"data_room_preview_file_list-DYoE9v_v.js","sources":["../../../app/javascript/data_room/components/DataRoomPreviewFileList.jsx","../../../app/javascript/entrypoints/data_room_preview_file_list.ts"],"sourcesContent":["/* eslint-disable camelcase */\nimport React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport TreeView from 'react-treeview';\nimport { sortBy } from 'lodash';\n\nconst DataRoomPreviewFileList = ({ data_room_files, data_room_folders }) => {\n const drFolders = data_room_folders.map((drf) => ({\n ...drf,\n collapsed: true,\n }));\n\n const [foldersData, setFoldersData] = useState(sortBy(drFolders, 'order'));\n\n useEffect(() => {\n const updatedFolders = data_room_folders.map((drf) => ({\n ...drf,\n collapsed: true,\n }));\n setFoldersData(sortBy(updatedFolders, 'order'));\n }, [data_room_folders]);\n\n const handleToggleFolder = (evt) => {\n const idx = parseInt(evt.target.dataset.index, 10);\n const fData = [...foldersData];\n fData[idx] = {\n ...fData[idx],\n collapsed: !foldersData[idx].collapsed,\n };\n setFoldersData(fData);\n };\n\n const viewFileBtn = (dataRoomFile) => {\n if (!dataRoomFile.file.document_name.toLowerCase().includes('.pdf'))\n return null;\n\n return (\n \n View\n \n );\n };\n\n const expandFolderBtn = (collapsed, idx) => (\n \n );\n\n const downloadFileBtn = (dataRoomFile) => {\n if (dataRoomFile.file.can_download) {\n return (\n \n Download\n \n );\n }\n return null;\n };\n\n const renderDocumentName = (dataRoomFile) => {\n if (dataRoomFile.file.can_download) {\n return (\n \n {!!dataRoomFile.description && (\n
\n No Data Room Files or Folders available.\n
\n );\n }\n\n return (\n <>\n {foldersData.map((folder, idx) => renderFolderNode(folder, idx))}\n {sortBy(data_room_files, 'order').map((file) => renderDataRoomFile(file))}\n >\n );\n};\n\nDataRoomPreviewFileList.propTypes = {\n data_room_files: PropTypes.array,\n data_room_folders: PropTypes.array,\n};\n\nDataRoomPreviewFileList.defaultProps = {\n data_room_files: [],\n data_room_folders: [],\n};\n\nexport default DataRoomPreviewFileList;\n","import initApp from './common';\nimport DataRoomPreviewFileList from '../data_room/components/DataRoomPreviewFileList';\n\ninitApp(DataRoomPreviewFileList, { root: 'data-room-preview-file-list-root' });\n"],"names":["DataRoomPreviewFileList","data_room_files","data_room_folders","drFolders","drf","foldersData","setFoldersData","useState","sortBy","useEffect","updatedFolders","handleToggleFolder","evt","idx","fData","viewFileBtn","dataRoomFile","jsx","expandFolderBtn","collapsed","downloadFileBtn","renderDocumentName","jsxs","renderDataRoomFile","renderDataRoomFolder","dataRoomFolder","id","name","files_count","renderFolderNode","sub_folders","files","isSubFolderVisible","TreeView","Fragment","folder","file","PropTypes","initApp"],"mappings":"gOAMA,MAAMA,EAA0B,CAAC,CAAE,gBAAAC,EAAiB,kBAAAC,KAAwB,CAC1E,MAAMC,EAAYD,EAAkB,IAAKE,IAAS,CAChD,GAAGA,EACH,UAAW,EACX,EAAA,EAEI,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAASC,EAAAA,OAAOL,EAAW,OAAO,CAAC,EAEzEM,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAiBR,EAAkB,IAAKE,IAAS,CACrD,GAAGA,EACH,UAAW,EACX,EAAA,EACaE,EAAAE,EAAA,OAAOE,EAAgB,OAAO,CAAC,CAAA,EAC7C,CAACR,CAAiB,CAAC,EAEhB,MAAAS,EAAsBC,GAAQ,CAClC,MAAMC,EAAM,SAASD,EAAI,OAAO,QAAQ,MAAO,EAAE,EAC3CE,EAAQ,CAAC,GAAGT,CAAW,EAC7BS,EAAMD,CAAG,EAAI,CACX,GAAGC,EAAMD,CAAG,EACZ,UAAW,CAACR,EAAYQ,CAAG,EAAE,SAAA,EAE/BP,EAAeQ,CAAK,CAAA,EAGhBC,EAAeC,GACdA,EAAa,KAAK,cAAc,YAAY,EAAE,SAAS,MAAM,EAIhEC,EAAA,IAAC,IAAA,CACC,KAAM,mBAAmBD,EAAa,EAAE,GACxC,UAAU,0CACV,IAAI,sBACJ,OAAO,SACR,SAAA,MAAA,CAAA,EARM,KAcLE,E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