@manuscripts/style-guide 1.3.2-LEAN-2585-0 → 1.3.2-LEAN-2859-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/cjs/components/AuthorsList/Author.js +11 -19
  2. package/dist/cjs/components/AuthorsList/AuthorsList.js +1 -1
  3. package/dist/cjs/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  4. package/dist/cjs/components/FileManager/FileActions.js +135 -0
  5. package/dist/cjs/components/FileManager/FileContainer.js +38 -0
  6. package/dist/cjs/components/FileManager/FileCreatedDate.js +25 -0
  7. package/dist/cjs/components/FileManager/FileManager.js +14 -125
  8. package/dist/cjs/components/FileManager/FileManagerProvider.js +2 -7
  9. package/dist/cjs/components/FileManager/FileName.js +29 -0
  10. package/dist/cjs/components/FileManager/FileSectionAlert.js +170 -0
  11. package/dist/cjs/components/FileManager/FileTypeIcon.js +31 -0
  12. package/dist/cjs/components/FileManager/{UploadFileArea.js → FileUploader.js} +19 -12
  13. package/dist/cjs/components/FileManager/InlineFilesSection.js +63 -123
  14. package/dist/cjs/components/FileManager/OtherFilesSection.js +101 -0
  15. package/dist/cjs/components/FileManager/SupplementsSection.js +118 -0
  16. package/dist/cjs/components/FileManager/{TooltipDiv.js → Tooltip.js} +8 -3
  17. package/dist/cjs/components/FileManager/util.js +29 -66
  18. package/dist/cjs/components/icons/corrupted-file-icon.js +27 -0
  19. package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
  20. package/dist/cjs/hooks/use-files.js +13 -43
  21. package/dist/cjs/index.js +3 -4
  22. package/dist/cjs/lib/files.js +85 -0
  23. package/dist/es/components/AuthorsList/Author.js +11 -19
  24. package/dist/es/components/AuthorsList/AuthorsList.js +1 -1
  25. package/dist/es/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  26. package/dist/es/components/FileManager/FileActions.js +105 -0
  27. package/dist/es/components/FileManager/FileContainer.js +32 -0
  28. package/dist/es/components/FileManager/FileCreatedDate.js +18 -0
  29. package/dist/es/components/FileManager/FileManager.js +16 -124
  30. package/dist/es/components/FileManager/FileManagerProvider.js +3 -8
  31. package/dist/es/components/FileManager/FileName.js +22 -0
  32. package/dist/es/components/FileManager/FileSectionAlert.js +163 -0
  33. package/dist/es/components/FileManager/FileTypeIcon.js +24 -0
  34. package/dist/es/components/FileManager/{UploadFileArea.js → FileUploader.js} +17 -10
  35. package/dist/es/components/FileManager/InlineFilesSection.js +64 -124
  36. package/dist/es/components/FileManager/OtherFilesSection.js +74 -0
  37. package/dist/es/components/FileManager/SupplementsSection.js +91 -0
  38. package/dist/es/components/FileManager/{TooltipDiv.js → Tooltip.js} +7 -2
  39. package/dist/es/components/FileManager/util.js +28 -64
  40. package/dist/es/components/icons/corrupted-file-icon.js +22 -0
  41. package/dist/es/components/icons/document-icon-with-dot.js +1 -1
  42. package/dist/es/hooks/use-files.js +13 -40
  43. package/dist/es/index.js +2 -2
  44. package/dist/es/lib/files.js +79 -0
  45. package/dist/types/components/AuthorsList/Author.d.ts +0 -1
  46. package/dist/types/components/FileManager/FileActions.d.ts +19 -0
  47. package/dist/types/components/FileManager/FileContainer.d.ts +1 -0
  48. package/dist/types/components/FileManager/FileCreatedDate.d.ts +8 -0
  49. package/dist/types/components/FileManager/FileManager.d.ts +15 -8
  50. package/dist/types/components/FileManager/FileManagerProvider.d.ts +8 -18
  51. package/dist/types/components/FileManager/FileName.d.ts +6 -0
  52. package/dist/types/components/FileManager/FileSectionAlert.d.ts +13 -0
  53. package/dist/types/components/FileManager/{FileSectionItem/FileTypeIcon.d.ts → FileTypeIcon.d.ts} +2 -3
  54. package/dist/types/components/FileManager/FileUploader.d.ts +4 -0
  55. package/dist/types/components/FileManager/InlineFilesSection.d.ts +3 -19
  56. package/dist/types/components/FileManager/OtherFilesSection.d.ts +5 -0
  57. package/dist/types/components/FileManager/SupplementsSection.d.ts +5 -0
  58. package/dist/types/components/FileManager/Tooltip.d.ts +2 -0
  59. package/dist/types/components/FileManager/util.d.ts +3 -10
  60. package/dist/types/components/icons/corrupted-file-icon.d.ts +19 -0
  61. package/dist/types/hooks/use-files.d.ts +5 -6
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/lib/files.d.ts +25 -0
  64. package/package.json +1 -1
  65. package/dist/cjs/components/FileManager/ConfirmationPopUp.js +0 -90
  66. package/dist/cjs/components/FileManager/DragItemArea.js +0 -28
  67. package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -76
  68. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +0 -115
  69. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +0 -95
  70. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -37
  71. package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -53
  72. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +0 -92
  73. package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -120
  74. package/dist/cjs/components/FileManager/FileSectionState.js +0 -83
  75. package/dist/cjs/components/FileManager/FilesSection.js +0 -61
  76. package/dist/cjs/components/FileManager/ItemsAction.js +0 -48
  77. package/dist/cjs/lib/inlineFiles.js +0 -92
  78. package/dist/es/components/FileManager/ConfirmationPopUp.js +0 -62
  79. package/dist/es/components/FileManager/DragItemArea.js +0 -21
  80. package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -46
  81. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +0 -85
  82. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +0 -88
  83. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -30
  84. package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -46
  85. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +0 -65
  86. package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -113
  87. package/dist/es/components/FileManager/FileSectionState.js +0 -78
  88. package/dist/es/components/FileManager/FilesSection.js +0 -34
  89. package/dist/es/components/FileManager/ItemsAction.js +0 -42
  90. package/dist/es/lib/inlineFiles.js +0 -90
  91. package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +0 -12
  92. package/dist/types/components/FileManager/DragItemArea.d.ts +0 -4
  93. package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +0 -3
  94. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -19
  95. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +0 -38
  96. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -12
  97. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -21
  98. package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +0 -4
  99. package/dist/types/components/FileManager/FileSectionState.d.ts +0 -38
  100. package/dist/types/components/FileManager/FilesSection.d.ts +0 -12
  101. package/dist/types/components/FileManager/ItemsAction.d.ts +0 -4
  102. package/dist/types/components/FileManager/TooltipDiv.d.ts +0 -1
  103. package/dist/types/components/FileManager/UploadFileArea.d.ts +0 -9
  104. package/dist/types/lib/inlineFiles.d.ts +0 -11
  105. /package/dist/types/components/FileManager/{FileSectionItem/DragLayer.d.ts → DragLayer.d.ts} +0 -0
@@ -1,158 +1,98 @@
1
- import { format } from 'date-fns';
2
- import React, { useCallback } from 'react';
3
- import ReactTooltip from 'react-tooltip';
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import React, { useCallback, useContext } from 'react';
4
11
  import styled from 'styled-components';
5
- import { useDropdown } from '../../hooks/use-dropdown';
6
- import DotsIcon from '../icons/dots-icon';
7
- import { FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSectionItem/FileInfo';
8
- import { ActionsIcon, Item, } from './FileSectionItem/FileSectionItem';
9
- import { ItemActions } from './FileSectionItem/ItemActions';
10
- import { extensionsWithFileTypesMap, FileSectionType, fileTypesWithIconMap, } from './util';
12
+ import { FileActions } from './FileActions';
13
+ import { FileContainer } from './FileContainer';
14
+ import { FileCreatedDate } from './FileCreatedDate';
15
+ import { FileManagerContext } from './FileManagerProvider';
16
+ import { FileName } from './FileName';
17
+ import { FileSectionType, fileTypesWithIconMap } from './util';
11
18
  const trackedJoint = ':dataTracked:';
12
- export const InlineFilesSection = ({ handleReplace, handleDownload, handleUpdateInline, handleDetachFile, inlineFiles, isEditor, dispatch, }) => {
19
+ export const InlineFilesSection = ({ elements, isEditor }) => {
20
+ const { modelMap, fileManagement, saveModel } = useContext(FileManagerContext);
13
21
  const onElementClick = useCallback((e) => {
14
22
  if (!isEditor) {
15
23
  return;
16
24
  }
17
25
  const { id } = e.currentTarget;
18
26
  const clearedId = id.split(trackedJoint)[0];
19
- const isSelected = clearedId == window.location.hash.substr(1);
27
+ const isSelected = clearedId == window.location.hash.substring(1);
20
28
  window.location.hash = !isSelected ? `#${clearedId}` : '#';
21
- if (isSelected) {
22
- window.location.hash = `#${clearedId}`;
23
- }
24
29
  }, [isEditor]);
25
- return (React.createElement("div", null, inlineFiles.map((file, index) => {
30
+ const updateFigureSrc = (modelId, src) => __awaiter(void 0, void 0, void 0, function* () {
31
+ const figure = modelMap.get(modelId);
32
+ if (figure) {
33
+ yield saveModel(Object.assign(Object.assign({}, figure), { src: src }));
34
+ }
35
+ });
36
+ const detach = (modelId) => __awaiter(void 0, void 0, void 0, function* () {
37
+ yield updateFigureSrc(modelId, '');
38
+ });
39
+ const replace = (modelId, file) => __awaiter(void 0, void 0, void 0, function* () {
40
+ const uploaded = yield fileManagement.upload(file);
41
+ yield updateFigureSrc(modelId, uploaded.id);
42
+ });
43
+ return (React.createElement(React.Fragment, null, elements.map((element, index) => {
26
44
  var _a;
27
- return (React.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
28
- React.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (React.createElement(React.Fragment, null,
29
- React.createElement(FileReference, { key: attachment.id, attachment: attachment, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDetachFile: handleDetachFile, handleDownload: handleDownload, dispatch: dispatch }))))),
30
- React.createElement(Element, { className: 'element' },
31
- fileTypesWithIconMap.get(file.type),
32
- React.createElement(FileInfoContainer, null,
33
- React.createElement(FileNameTitleContainer, null,
34
- React.createElement(FileTitle, null, file.label))))));
45
+ return (React.createElement(Element, { key: index, id: element.modelId, onClick: onElementClick },
46
+ React.createElement(ElementLabelContainer, null,
47
+ fileTypesWithIconMap.get(element.type),
48
+ React.createElement(ElementLabel, null, element.label)),
49
+ React.createElement(ElementFilesContainer, null, (_a = element.files) === null || _a === void 0 ? void 0 : _a.map((file) => (React.createElement(ElementFile, { key: file.modelId, file: file, handleReplace: (f) => __awaiter(void 0, void 0, void 0, function* () { return yield replace(file.modelId, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield detach(file.modelId); }), handleDownload: () => fileManagement.download(file) }))))));
35
50
  })));
36
51
  };
37
- const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdateInline, handleDetachFile, dispatch, }) => {
38
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
39
- if (!attachment || !attachment.name) {
40
- return null;
41
- }
42
- const fileExtension = attachment.name.substring(attachment.name.lastIndexOf('.') + 1);
43
- return (React.createElement(FileReferenceItem, { key: attachment.id },
44
- React.createElement(Container, null,
45
- fileTypesWithIconMap.get(extensionsWithFileTypesMap.get(fileExtension)),
46
- React.createElement(FileReferenceName, null, attachment.name)),
47
- attachment.createdDate && (React.createElement(FileDateContainer, { "data-tip": "tooltip-content" },
48
- React.createElement(FileDate, null, format(new Date(attachment.createdDate), 'M/d/yy, HH:mm')),
49
- React.createElement(ReactTooltip, { place: "bottom", offset: { top: 0 }, effect: "solid", className: "tooltip" }, "File Uploaded"))),
50
- handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
51
- React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace or Detach", "aria-pressed": isOpen },
52
- React.createElement(DotsIcon, null)),
53
- isOpen && (React.createElement(ItemActions, { fileSection: FileSectionType.Inline, replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
54
- (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
55
- handleUpdateInline(attachment.modelId, uploadAttachment), detachAttachmnetHandler: () => handleDetachFile &&
56
- attachment.modelId &&
57
- handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
52
+ const ElementFile = ({ file, handleReplace, handleDownload, handleDetach }) => {
53
+ return (React.createElement(ModelFileContainer, null,
54
+ React.createElement(FileName, { file: file }),
55
+ React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
56
+ React.createElement(FileActions, { sectionType: FileSectionType.Inline, handleDownload: file.id ? handleDownload : undefined, handleDetach: file.id ? handleDetach : undefined, handleReplace: handleReplace })));
58
57
  };
59
- export const FileDateContainer = styled.div `
60
- overflow: hidden;
61
- display: none;
62
- width: 100%;
63
- justify-content: flex-end;
64
- `;
65
- const ElementItem = styled(Item) `
58
+ const Element = styled.div `
66
59
  display: flex;
67
- // this will allow us to select the previous sibling node,
68
- // to change the background on the hover for adjacent node
69
- flex-direction: column-reverse;
60
+ flex-direction: column;
70
61
  padding: 0;
71
62
 
72
- :hover {
73
- background: #f2fbfc;
74
- }
75
-
76
- .refItems:hover ~ .element {
77
- background: white !important;
78
- }
79
- &:hover ${FileDateContainer} {
80
- display: flex;
81
- }
63
+ border-bottom: 1px dashed #f0f0f0;
82
64
 
83
- .refItems:hover {
84
- background: white !important;
65
+ svg {
66
+ width: 24px;
85
67
  }
86
68
 
87
- border-bottom: 1px dashed #f0f0f0;
88
-
89
69
  :last-child {
90
70
  border-bottom: 0;
91
71
  }
92
72
  `;
93
- const Container = styled.div `
94
- display: flex;
95
- width: 100%;
96
- `;
97
- const Element = styled.div `
73
+ const ElementLabelContainer = styled.div `
98
74
  display: flex;
99
- padding: 20px 15px;
75
+ padding: 20px 16px;
100
76
  `;
101
- const FileReferences = styled.div `
102
- display: flex;
103
- align-items: center;
104
- justify-content: space-between;
105
- width: 100%;
77
+ const ElementLabel = styled.div `
78
+ color: ${(props) => props.theme.colors.text.primary};
79
+ font-weight: bold;
80
+ font-size: 16px;
81
+ line-height: 20px;
82
+ white-space: nowrap;
83
+ margin-left: ${(props) => props.theme.grid.unit * 2}px;
106
84
  `;
107
- const FileReferenceItem = styled.div `
108
- display: flex;
85
+ const ElementFilesContainer = styled.div `
109
86
  width: 100%;
110
- align-items: space;
111
- justify-content: space-between;
112
- width: 100% svg {
113
- width: 14px;
114
- height: 17px;
87
+ > :last-child {
88
+ margin-bottom: 25px;
115
89
  }
90
+ `;
91
+ const ModelFileContainer = styled(FileContainer) `
92
+ padding: 8px 16px;
93
+ height: 40px;
116
94
 
117
95
  path {
118
96
  fill: #6e6e6e;
119
97
  }
120
-
121
- padding: ${(props) => props.theme.grid.unit * 2}px
122
- ${(props) => props.theme.grid.unit * 4}px;
123
-
124
- :hover {
125
- background: #f2fbfc;
126
- }
127
-
128
- .external_file_dropdown {
129
- opacity: 0;
130
- }
131
- :hover .external_file_dropdown {
132
- opacity: 1;
133
- }
134
-
135
- .ref_item_dropdown {
136
- top: 65%;
137
- right: 10px;
138
- width: 180px;
139
- }
140
- :last-child {
141
- margin-bottom: 25px;
142
- }
143
- `;
144
- const FileReferenceName = styled.div `
145
- font-family: ${(props) => props.theme.font.family.Lato};
146
- font-size: ${(props) => props.theme.font.size.medium};
147
- line-height: ${(props) => props.theme.font.lineHeight.large};
148
- font-weight: ${(props) => props.theme.font.weight.normal};
149
- color: ${(props) => props.theme.colors.text.primary};
150
- margin-left: ${(props) => props.theme.grid.unit * 2}px;
151
- `;
152
- const DropdownContainer = styled.div `
153
- position: relative;
154
- `;
155
- export const FileDate = styled.div `
156
- font-size: ${(props) => props.theme.font.size.small};
157
- line-height: 27px;
158
98
  `;
@@ -0,0 +1,74 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { buildSupplementaryMaterial } from '@manuscripts/transform';
11
+ import React, { useContext, useEffect, useState } from 'react';
12
+ import { useDrag } from 'react-dnd';
13
+ import { getEmptyImage } from 'react-dnd-html5-backend';
14
+ import { FileActions } from './FileActions';
15
+ import { FileContainer } from './FileContainer';
16
+ import { FileCreatedDate } from './FileCreatedDate';
17
+ import { PermissionsContext } from './FileManager';
18
+ import { FileManagerContext } from './FileManagerProvider';
19
+ import { FileName } from './FileName';
20
+ import { FileSectionAlert, FileSectionAlertType } from './FileSectionAlert';
21
+ import { FileUploader } from './FileUploader';
22
+ import { FileSectionType } from './util';
23
+ export const OtherFilesSection = ({ files }) => {
24
+ const { fileManagement, saveModel } = useContext(FileManagerContext);
25
+ const can = useContext(PermissionsContext);
26
+ const [alert, setAlert] = useState({
27
+ type: FileSectionAlertType.NONE,
28
+ message: '',
29
+ });
30
+ const upload = (file) => __awaiter(void 0, void 0, void 0, function* () {
31
+ setAlert({
32
+ type: FileSectionAlertType.UPLOAD_IN_PROGRESS,
33
+ message: file.name,
34
+ });
35
+ yield fileManagement.upload(file);
36
+ setAlert({
37
+ type: FileSectionAlertType.UPLOAD_SUCCESSFUL,
38
+ message: '',
39
+ });
40
+ });
41
+ const moveToSupplements = (file) => __awaiter(void 0, void 0, void 0, function* () {
42
+ const supplement = buildSupplementaryMaterial('', file.id);
43
+ yield saveModel(supplement);
44
+ setAlert({
45
+ type: FileSectionAlertType.MOVE_SUCCESSFUL,
46
+ message: FileSectionType.Supplements,
47
+ });
48
+ });
49
+ return (React.createElement("div", null,
50
+ (can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, { handler: upload }),
51
+ React.createElement(FileSectionAlert, { alert: alert }),
52
+ files.map((file) => (React.createElement(OtherFile, { key: file.id, file: file, handleDownload: () => fileManagement.download(file), handleMoveToSupplements: () => __awaiter(void 0, void 0, void 0, function* () { return yield moveToSupplements(file); }) })))));
53
+ };
54
+ const OtherFile = ({ file, handleDownload, handleMoveToSupplements }) => {
55
+ const [{ isDragging }, drag, preview] = useDrag({
56
+ item: {
57
+ file,
58
+ type: 'file',
59
+ },
60
+ collect: (monitor) => ({
61
+ isDragging: monitor.isDragging(),
62
+ }),
63
+ });
64
+ useEffect(() => {
65
+ preview(getEmptyImage());
66
+ }, [preview]);
67
+ return (React.createElement(FileContainer, { key: file.id, ref: drag, className: isDragging ? 'dragging' : '' },
68
+ React.createElement(FileName, { file: file }),
69
+ React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
70
+ React.createElement(FileActions, { sectionType: FileSectionType.OtherFile, handleDownload: handleDownload, move: {
71
+ sectionType: FileSectionType.Supplements,
72
+ handler: handleMoveToSupplements,
73
+ } })));
74
+ };
@@ -0,0 +1,91 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { ObjectTypes } from '@manuscripts/json-schema';
11
+ import { buildSupplementaryMaterial } from '@manuscripts/transform';
12
+ import React, { useContext, useEffect, useState } from 'react';
13
+ import { useDrag } from 'react-dnd';
14
+ import { getEmptyImage } from 'react-dnd-html5-backend';
15
+ import { FileActions } from './FileActions';
16
+ import { FileContainer } from './FileContainer';
17
+ import { FileCreatedDate } from './FileCreatedDate';
18
+ import { PermissionsContext } from './FileManager';
19
+ import { FileManagerContext } from './FileManagerProvider';
20
+ import { FileName } from './FileName';
21
+ import { FileSectionAlert, FileSectionAlertType } from './FileSectionAlert';
22
+ import { FileUploader } from './FileUploader';
23
+ import { FileSectionType } from './util';
24
+ export const SupplementsSection = ({ supplements }) => {
25
+ const { modelMap, saveModel, deleteModel, fileManagement } = useContext(FileManagerContext);
26
+ const can = useContext(PermissionsContext);
27
+ const [alert, setAlert] = useState({
28
+ type: FileSectionAlertType.NONE,
29
+ message: '',
30
+ });
31
+ const upload = (file) => __awaiter(void 0, void 0, void 0, function* () {
32
+ setAlert({
33
+ type: FileSectionAlertType.UPLOAD_IN_PROGRESS,
34
+ message: file.name,
35
+ });
36
+ const uploaded = yield fileManagement.upload(file);
37
+ setAlert({
38
+ type: FileSectionAlertType.UPLOAD_SUCCESSFUL,
39
+ message: '',
40
+ });
41
+ return uploaded;
42
+ });
43
+ const handleUpload = (file) => __awaiter(void 0, void 0, void 0, function* () {
44
+ const uploaded = yield upload(file);
45
+ const supplement = buildSupplementaryMaterial('', uploaded.id);
46
+ yield saveModel(supplement);
47
+ });
48
+ const handleReplace = (modelId, file) => __awaiter(void 0, void 0, void 0, function* () {
49
+ const uploaded = yield upload(file);
50
+ const supplement = modelMap.get(modelId);
51
+ yield saveModel(Object.assign(Object.assign({}, supplement), { href: uploaded.id }));
52
+ });
53
+ const handleMoveToOtherFiles = (modelId) => __awaiter(void 0, void 0, void 0, function* () {
54
+ yield deleteModel(modelId);
55
+ setAlert({
56
+ type: FileSectionAlertType.MOVE_SUCCESSFUL,
57
+ message: FileSectionType.OtherFile,
58
+ });
59
+ });
60
+ return (React.createElement(React.Fragment, null,
61
+ (can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, { handler: handleUpload }),
62
+ React.createElement(FileSectionAlert, { alert: alert }),
63
+ supplements.map((supplement) => (React.createElement(SupplementFile, { key: supplement.modelId, file: supplement, handleDownload: () => fileManagement.download(supplement), handleReplace: (f) => __awaiter(void 0, void 0, void 0, function* () { return yield handleReplace(supplement.modelId, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield handleMoveToOtherFiles(supplement.modelId); }) })))));
64
+ };
65
+ const SupplementFile = ({ file, handleDownload, handleReplace, handleDetach }) => {
66
+ const [{ isDragging }, drag, preview] = useDrag({
67
+ item: {
68
+ file,
69
+ model: {
70
+ _id: file.modelId,
71
+ objectType: ObjectTypes.Supplement,
72
+ },
73
+ type: 'file',
74
+ },
75
+ collect: (monitor) => ({
76
+ isDragging: monitor.isDragging(),
77
+ }),
78
+ });
79
+ useEffect(() => {
80
+ preview(getEmptyImage());
81
+ }, [preview]);
82
+ return (React.createElement(FileContainer, { key: file.id, ref: drag, className: isDragging ? 'dragging' : '' },
83
+ React.createElement(FileName, { file: file }),
84
+ React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
85
+ React.createElement(FileActions, { sectionType: FileSectionType.Supplements, handleDownload: file.id ? handleDownload : undefined, handleReplace: handleReplace, move: file.id
86
+ ? {
87
+ sectionType: FileSectionType.OtherFile,
88
+ handler: handleDetach,
89
+ }
90
+ : undefined })));
91
+ };
@@ -1,6 +1,7 @@
1
+ import ReactTooltip from 'react-tooltip';
1
2
  import styled from 'styled-components';
2
- export const TooltipDiv = styled.div `
3
- .tooltip {
3
+ export const Tooltip = styled(ReactTooltip) `
4
+ &.tooltip {
4
5
  font-size: 12px;
5
6
  line-height: 16px;
6
7
  font-family: ${(props) => props.theme.font.family.Lato};
@@ -11,5 +12,9 @@ export const TooltipDiv = styled.div `
11
12
  text-align: center;
12
13
  white-space: nowrap;
13
14
  pointer-events: none;
15
+
16
+ &.place-bottom::after {
17
+ background: #353535;
18
+ }
14
19
  }
15
20
  `;
@@ -13,9 +13,9 @@ import UnknownFormatFileIcon from '../icons/unknown-format-file-icon';
13
13
  import VideoIcon from '../icons/video-icon';
14
14
  export var FileSectionType;
15
15
  (function (FileSectionType) {
16
- FileSectionType[FileSectionType["Inline"] = 0] = "Inline";
17
- FileSectionType[FileSectionType["Supplements"] = 1] = "Supplements";
18
- FileSectionType[FileSectionType["OtherFile"] = 2] = "OtherFile";
16
+ FileSectionType["Inline"] = "Inline files";
17
+ FileSectionType["Supplements"] = "Supplements";
18
+ FileSectionType["OtherFile"] = "Other files";
19
19
  })(FileSectionType || (FileSectionType = {}));
20
20
  export var FileType;
21
21
  (function (FileType) {
@@ -68,78 +68,42 @@ export const extensionsWithFileTypesMap = new Map([
68
68
  ['tgz', FileType.CompressedFile],
69
69
  ['txt', FileType.PlainText],
70
70
  ]);
71
- export const fileTypesWithTitlesMap = new Map([
72
- [FileType.Image, 'Image'],
73
- [FileType.Audio, 'Audio'],
74
- [FileType.Video, 'Video'],
75
- [FileType.PlainDocument, 'Doc'],
76
- [FileType.SheetsWorkbooks, 'Table'],
77
- [FileType.Latex, 'Doc'],
78
- [FileType.CodeFile, 'Code File'],
79
- [FileType.PdfFile, 'Doc'],
80
- [FileType.CompressedFile, 'Compressed File'],
81
- [FileType.PlainText, 'Plain Text'],
82
- [undefined, 'Unknown'],
83
- ]);
84
71
  export const fileTypesWithIconMap = new Map([
85
- [FileType.Audio, React.createElement(AudioIcon, { key: FileType.Audio })],
86
- [FileType.Video, React.createElement(VideoIcon, { key: FileType.Video })],
72
+ [FileType.Audio, React.createElement(AudioIcon, { key: FileType.Audio, className: "file-icon" })],
73
+ [FileType.Video, React.createElement(VideoIcon, { key: FileType.Video, className: "file-icon" })],
87
74
  [
88
75
  FileType.PlainDocument,
89
- React.createElement(DocumentIcon, { key: FileType.PlainDocument, color: "#1A9BC7" }),
76
+ React.createElement(DocumentIcon, { key: FileType.PlainDocument, color: "#1A9BC7", className: "file-icon" }),
77
+ ],
78
+ [
79
+ FileType.SheetsWorkbooks,
80
+ React.createElement(TableIcon, { key: FileType.SheetsWorkbooks, className: "file-icon" }),
81
+ ],
82
+ [
83
+ FileType.Latex,
84
+ React.createElement(LatexIcon, { key: FileType.Latex, color: "#1A9BC7", className: "file-icon" }),
85
+ ],
86
+ [
87
+ FileType.CodeFile,
88
+ React.createElement(CodeFileIcon, { key: FileType.CodeFile, className: "file-icon" }),
89
+ ],
90
+ [
91
+ FileType.PdfFile,
92
+ React.createElement(PdfFileIcon, { key: FileType.PdfFile, className: "file-icon" }),
90
93
  ],
91
- [FileType.SheetsWorkbooks, React.createElement(TableIcon, { key: FileType.SheetsWorkbooks })],
92
- [FileType.Latex, React.createElement(LatexIcon, { key: FileType.Latex, color: "#1A9BC7" })],
93
- [FileType.CodeFile, React.createElement(CodeFileIcon, { key: FileType.CodeFile })],
94
- [FileType.PdfFile, React.createElement(PdfFileIcon, { key: FileType.PdfFile })],
95
94
  [
96
95
  FileType.CompressedFile,
97
- React.createElement(CompressedFileIcon, { key: FileType.CompressedFile }),
96
+ React.createElement(CompressedFileIcon, { key: FileType.CompressedFile, className: "file-icon" }),
98
97
  ],
99
98
  [
100
99
  FileType.PlainText,
101
- React.createElement(DocumentIcon, { key: FileType.PlainText, color: "#FFBD26" }),
100
+ React.createElement(DocumentIcon, { key: FileType.PlainText, color: "#FFBD26", className: "file-icon" }),
102
101
  ],
103
- [FileType.Image, React.createElement(ImageIcon, { key: FileType.Image })],
104
- [FileType.Figure, React.createElement(FigureIcon, { key: FileType.Figure })],
102
+ [FileType.Image, React.createElement(ImageIcon, { key: FileType.Image, className: "file-icon" })],
103
+ [FileType.Figure, React.createElement(FigureIcon, { key: FileType.Figure, className: "file-icon" })],
105
104
  [
106
105
  FileType.GraphicalAbstract,
107
- React.createElement(GraphicalAbstractIcon, { key: FileType.GraphicalAbstract }),
106
+ React.createElement(GraphicalAbstractIcon, { key: FileType.GraphicalAbstract, className: "file-icon" }),
108
107
  ],
109
- [undefined, React.createElement(UnknownFormatFileIcon, { key: undefined })],
108
+ [undefined, React.createElement(UnknownFormatFileIcon, { key: undefined, className: "file-icon" })],
110
109
  ]);
111
- export const generateAttachmentsTitles = (externalFiles, fileSectionType) => {
112
- const titleCountersMap = new Map();
113
- const externalFilesWithTitlesMap = new Map();
114
- externalFiles.forEach((element) => {
115
- const fileExtension = element.name.substring(element.name.lastIndexOf('.') + 1);
116
- const fileType = extensionsWithFileTypesMap.get(fileExtension.toLowerCase());
117
- const fileTitle = fileTypesWithTitlesMap.get(fileType);
118
- if (fileSectionType === FileSectionType.Inline) {
119
- externalFilesWithTitlesMap.set(element.name, element);
120
- }
121
- else {
122
- if (fileTitle !== undefined) {
123
- const oldCount = titleCountersMap.get(fileTitle);
124
- if (oldCount) {
125
- const newCount = oldCount + 1;
126
- titleCountersMap.set(fileTitle, newCount);
127
- externalFilesWithTitlesMap.set(`${fileTitle} ${newCount}`, element);
128
- }
129
- else {
130
- titleCountersMap.set(fileTitle, 1);
131
- externalFilesWithTitlesMap.set(`${fileTitle} 1`, element);
132
- }
133
- }
134
- }
135
- });
136
- const result = Array.from(externalFilesWithTitlesMap, ([key, value]) => ({
137
- title: key,
138
- externalFile: value,
139
- }));
140
- return result;
141
- };
142
- export const droppableSections = [
143
- FileSectionType.Supplements,
144
- FileSectionType.OtherFile,
145
- ];
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import React from 'react';
17
+ const CorruptedFileIcon = (props) => (React.createElement("svg", { width: "16", height: "18", viewBox: "0 0 16 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: props.className },
18
+ React.createElement("path", { d: "M14.186 5.65149L13.6777 6.20297L14.186 5.65149L9.91329 1.71322C9.59104 1.4162 9.16952 1.25 8.7288 1.25H8.72312H8.7174H8.71165H8.70585H8.70003H8.69416H8.68826H8.68232H8.67635H8.67034H8.66429H8.65821H8.65209H8.64593H8.63974H8.63352H8.62725H8.62096H8.61462H8.60825H8.60185H8.59541H8.58894H8.58243H8.57588H8.5693H8.56269H8.55604H8.54936H8.54264H8.53589H8.5291H8.52228H8.51543H8.50854H8.50162H8.49466H8.48767H8.48064H8.47359H8.4665H8.45937H8.45221H8.44502H8.4378H8.43054H8.42325H8.41593H8.40857H8.40118H8.39376H8.38631H8.37882H8.37131H8.36376H8.35617H8.34856H8.34091H8.33323H8.32552H8.31778H8.31001H8.3022H8.29437H8.2865H8.2786H8.27067H8.26271H8.25472H8.2467H8.23864H8.23056H8.22244H8.2143H8.20612H8.19792H8.18968H8.18142H8.17312H8.16479H8.15644H8.14805H8.13964H8.13119H8.12272H8.11421H8.10568H8.09712H8.08852H8.0799H8.07126H8.06258H8.05387H8.04513H8.03637H8.02758H8.01876H8.00991H8.00103H7.99212H7.98319H7.97423H7.96524H7.95622H7.94718H7.9381H7.929H7.91987H7.91072H7.90154H7.89233H7.88309H7.87383H7.86454H7.85522H7.84588H7.83651H7.82711H7.81769H7.80824H7.79877H7.78926H7.77974H7.77018H7.7606H7.751H7.74137H7.73171H7.72203H7.71232H7.70259H7.69283H7.68305H7.67324H7.66341H7.65355H7.64367H7.63376H7.62383H7.61388H7.6039H7.59389H7.58386H7.57381H7.56373H7.55363H7.54351H7.53336H7.52319H7.51299H7.50277H7.49253H7.48226H7.47198H7.46166H7.45133H7.44097H7.43059H7.42019H7.40976H7.39931H7.38884H7.37834H7.36783H7.35729H7.34673H7.33615H7.32554H7.31492H7.30427H7.2936H7.28291H7.2722H7.26146H7.25071H7.23993H7.22913H7.21831H7.20747H7.19661H7.18573H7.17483H7.16391H7.15297H7.142H7.13102H7.12002H7.10899H7.09795H7.08688H7.0758H7.0647H7.05357H7.04243H7.03127H7.02009H7.00889H6.99767H6.98643H6.97517H6.96389H6.9526H6.94128H6.92995H6.9186H6.90723H6.89584H6.88443H6.87301H6.86156H6.8501H6.83862H6.82713H6.81561H6.80408H6.79253H6.78096H6.76938H6.75778H6.74616H6.73452H6.72287H6.7112H6.69951H6.68781H6.67609H6.66435H6.6526H6.64083H6.62904H6.61724H6.60542H6.59359H6.58173H6.56987H6.55799H6.54609H6.53418H6.52225H6.5103H6.49834H6.48637H6.47438H6.46238H6.45036H6.43832H6.42627H6.41421H6.40213H6.39004H6.37793H6.36581H6.35367H6.34152H6.32936H6.31718H6.30499H6.29279H6.28057H6.26834H6.25609H6.24383H6.23156H6.21927H6.20697H6.19466H6.18234H6.17H6.15765H6.14529H6.13291H6.12052H6.10812H6.09571H6.08329H6.07085H6.0584H6.04594H6.03347H6.02098H6.00849H5.99598H5.98346H5.97093H5.95839H5.94584H5.93327H5.9207H5.90811H5.89551H5.88291H5.87029H5.85766H5.84502H5.83237H5.81971H5.80704H5.79436H5.78167H5.76897H5.75626H5.74354H5.73081H5.71808H5.70533H5.69257H5.6798H5.66703H5.65424H5.64145H5.62865H5.61583H5.60301H5.59018H5.57735H5.5645H5.55165H5.53878H5.52591H5.51303H5.50015H5.48725H5.47435H5.46144H5.44852H5.4356H5.42266H5.40972H5.39677H5.38382H5.37086H5.35789H5.34491H5.33193H5.31894H5.30594H5.29294H5.27993H5.26692H5.2539H5.24087H5.22783H5.21479H5.20175H5.1887H5.17564H5.16258H5.14951H5.13643H5.12335H5.11027H5.09718H5.08408H5.07098H5.05788H5.04477H5.03165H5.01854H5.00541H4.99228H4.97915H4.96601H4.95287H4.93973H4.92658H4.91343H4.90027H4.88711H4.87395H4.86078H4.84761H4.83443H4.82126H4.80808H4.79489H4.7817H4.76851H4.75532H4.74213H4.72893H4.71573H4.70253H4.68932H4.67611H4.6629H4.64969H4.63648H4.62326H4.61004H4.59683H4.5836H4.57038H4.55716H4.54393H4.53071H4.51748H4.50425H4.49102H4.47779H4.46456H4.45133H4.43809H4.42486H4.41163H4.39839H4.38516H4.37192H4.35869H4.34545H4.33222H4.31899H4.30575H4.29252H4.27928H4.26605H4.25282H4.23959H4.22636H4.21313H4.1999H4.18667H4.17345H4.16022H4.147H4.13378H4.12056H4.10734H4.09412H4.0809H4.06769H4.05448H4.04127H4.02806H4.01486H4.00166H3.98846H3.97526H3.96206H3.94887H3.93568H3.9225H3.90931H3.89613H3.88296H3.86978H3.85661H3.84345H3.83028H3.81712H3.80397H3.79082H3.77767H3.76452H3.75138H3.73825H3.72512H3.71199H3.69887H3.68575H3.67264H3.65953H3.64642H3.63332H3.62023H3.60714H3.59406H3.58098H3.56791H3.55484H3.54178H3.52872H3.51567H3.50263H3.48959H3.47655H3.46353H3.45051H3.43749H3.42449H3.41148H3.39849H3.3855H3.37252H3.35955H3.34658H3.33362H3.32067H3.30772H3.29478H3.28185H3.26892H3.25601H3.2431H3.2302H3.21731H3.20442H3.19154H3.17867H3.16581H3.15296H3.14012H3.12728H3.11445H3.10163H3.08882H3.07602H3.06323H3.05045H3.03767H3.02491H3.01215H2.99941C2.03233 1.25 1.25 2.03408 1.25 3V15C1.25 15.9665 2.0335 16.75 3 16.75H13C13.9665 16.75 14.75 15.9665 14.75 15V6.93827C14.75 6.4494 14.5455 5.98282 14.186 5.65149Z", stroke: "#6E6E6E", strokeWidth: "1.5" }),
19
+ React.createElement("path", { d: "M5 13C6.06061 11.4908 8.94545 9.37781 12 13", stroke: "#6E6E6E", strokeWidth: "1.5", strokeLinecap: "round" }),
20
+ React.createElement("path", { d: "M5 5C5 5 5 5.52369 5 6.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeLinecap: "round" }),
21
+ React.createElement("path", { d: "M9 2V7H14", stroke: "#6E6E6E", strokeWidth: "1.5" })));
22
+ export default CorruptedFileIcon;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import React from 'react';
17
- const DocumentIconWithDot = (props) => (React.createElement("svg", { width: "28", height: "33", viewBox: "0 0 28 33", fill: "none", xmlns: "http://www.w3.org/2000/svg", "data-for": "dot", "data-tip": true },
17
+ const DocumentIconWithDot = (props) => (React.createElement("svg", { className: props.className, width: "28", height: "33", style: { marginLeft: -7, marginTop: -4 }, viewBox: "0 0 28 33", fill: "none", xmlns: "http://www.w3.org/2000/svg", "data-for": "dot", "data-tip": true },
18
18
  React.createElement("rect", { x: "9", y: "9.71973", width: "18", height: "22", rx: "2", stroke: "#1A9BC7", strokeWidth: "2" }),
19
19
  React.createElement("rect", { x: "13.167", y: "14.0771", width: "5.66667", height: "1.14286", rx: "0.5", fill: "#1A9BC7", stroke: "#1A9BC7" }),
20
20
  React.createElement("rect", { x: "13.167", y: "19.791", width: "9.66667", height: "1.14286", rx: "0.5", fill: "#1A9BC7", stroke: "#1A9BC7" }),
@@ -1,46 +1,19 @@
1
- import { ObjectTypes } from '@manuscripts/json-schema';
2
- import { getModelsByType } from '@manuscripts/transform';
3
- import getInlineFiles from '../lib/inlineFiles';
1
+ import { getInlineFiles, getSupplements, } from '../lib/files';
4
2
  import { useDeepCompareMemo } from './use-deep-compare';
5
- const getInlineFilesIds = (inlineFiles) => {
6
- return inlineFiles
7
- .map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
8
- .flat();
3
+ const getOtherFiles = (inlineFiles, supplements, files, filter) => {
4
+ const excluded = new Set();
5
+ inlineFiles.flatMap((f) => f.files).forEach((f) => excluded.add(f.id));
6
+ supplements.forEach((s) => excluded.add(s.id));
7
+ return files.filter((f) => !excluded.has(f.id) && (!filter || filter(f)));
9
8
  };
10
- const getSupplementFiles = (modelMap, inlineFiles, attachments, filePredicate) => {
11
- const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
12
- const excludedAttachmentsIds = new Set(getInlineFilesIds(inlineFiles).map(({ id }) => id));
13
- return attachments.filter((attachment) => {
14
- if (supplements.has(attachment.id) && filePredicate) {
15
- return (!excludedAttachmentsIds.has(attachment.id) &&
16
- filePredicate(attachment.name));
17
- }
18
- else {
19
- return (!excludedAttachmentsIds.has(attachment.id) &&
20
- supplements.has(attachment.id));
21
- }
22
- });
23
- };
24
- const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
25
- const inlineFilesAttachmentIds = getInlineFilesIds(inlineFiles);
26
- const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
27
- return attachments.filter(({ id, name }) => {
28
- if (!excludedAttachmentsIds.has(id) && filePredicate) {
29
- return filePredicate(name);
30
- }
31
- else {
32
- return !excludedAttachmentsIds.has(id);
33
- }
34
- });
35
- };
36
- export const useFiles = (modelMap, attachments, filePredicate) => useDeepCompareMemo(() => {
37
- const inlineFiles = getInlineFiles(modelMap, attachments);
38
- const supplementFiles = getSupplementFiles(modelMap, inlineFiles, attachments, filePredicate);
39
- const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
9
+ export const useFiles = (modelMap, files, filter) => useDeepCompareMemo(() => {
10
+ const inlineFiles = getInlineFiles(modelMap, files);
11
+ const supplements = getSupplements(modelMap, files);
12
+ const otherFiles = getOtherFiles(inlineFiles, supplements, files, filter);
40
13
  return {
41
- otherFiles,
42
- supplementFiles,
43
14
  inlineFiles,
15
+ supplements,
16
+ otherFiles,
44
17
  };
45
- }, [...Array.from(modelMap.values()), ...attachments]);
18
+ }, [...Array.from(modelMap.values()), ...files]);
46
19
  export default useFiles;
package/dist/es/index.js CHANGED
@@ -31,7 +31,6 @@ export * from './components/Checkbox';
31
31
  export * from './components/Form';
32
32
  export * from './components/FileManager';
33
33
  export * from './components/FileManager/util';
34
- export * from './components/FileManager/FileSectionItem/FileSectionItem';
35
34
  export * from './components/Resizer';
36
35
  export * from './components/SaveStatus';
37
36
  export * from './components/SimpleModal';
@@ -49,10 +48,11 @@ export * from './components/NavDropdown';
49
48
  export * from './components/SubmissionInspector';
50
49
  export * from './components/Dropdown';
51
50
  export * from './hooks/use-dropdown';
52
- export { useFiles } from './hooks/use-files';
51
+ export * from './hooks/use-files';
53
52
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
54
53
  export * from './lib/authors';
55
54
  export * from './lib/capabilities';
55
+ export * from './lib/files';
56
56
  export { default as errorsDecoder } from './lib/errors-decoder';
57
57
  export * from './types';
58
58
  export * from './components/LoadingOverlay';