@manuscripts/style-guide 1.3.2-LEAN-2859-1 → 1.3.2-LEAN-2880-1
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/dist/cjs/components/FileManager/ConfirmationPopUp.js +90 -0
- package/dist/cjs/components/FileManager/DragItemArea.js +28 -0
- package/dist/cjs/components/FileManager/FileManager.js +125 -14
- package/dist/cjs/components/FileManager/FileManagerProvider.js +7 -2
- package/dist/cjs/components/FileManager/{DragLayer.js → FileSectionItem/DragLayer.js} +10 -12
- package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +76 -0
- package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +115 -0
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +95 -0
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +37 -0
- package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +53 -0
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +92 -0
- package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +120 -0
- package/dist/cjs/components/FileManager/FileSectionState.js +83 -0
- package/dist/cjs/components/FileManager/FilesSection.js +61 -0
- package/dist/cjs/components/FileManager/InlineFilesSection.js +123 -64
- package/dist/cjs/components/FileManager/ItemsAction.js +48 -0
- package/dist/cjs/components/FileManager/{Tooltip.js → TooltipDiv.js} +3 -8
- package/dist/cjs/components/FileManager/{FileUploader.js → UploadFileArea.js} +12 -19
- package/dist/cjs/components/FileManager/util.js +66 -29
- package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
- package/dist/cjs/hooks/use-files.js +43 -14
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/lib/inlineFiles.js +92 -0
- package/dist/es/components/FileManager/ConfirmationPopUp.js +62 -0
- package/dist/es/components/FileManager/DragItemArea.js +21 -0
- package/dist/es/components/FileManager/FileManager.js +124 -16
- package/dist/es/components/FileManager/FileManagerProvider.js +8 -3
- package/dist/es/components/FileManager/{DragLayer.js → FileSectionItem/DragLayer.js} +10 -12
- package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +46 -0
- package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +85 -0
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +88 -0
- package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +30 -0
- package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +46 -0
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +65 -0
- package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +113 -0
- package/dist/es/components/FileManager/FileSectionState.js +78 -0
- package/dist/es/components/FileManager/FilesSection.js +34 -0
- package/dist/es/components/FileManager/InlineFilesSection.js +124 -65
- package/dist/es/components/FileManager/ItemsAction.js +42 -0
- package/dist/es/components/FileManager/{Tooltip.js → TooltipDiv.js} +2 -7
- package/dist/es/components/FileManager/{FileUploader.js → UploadFileArea.js} +10 -17
- package/dist/es/components/FileManager/util.js +64 -28
- package/dist/es/components/icons/document-icon-with-dot.js +1 -1
- package/dist/es/hooks/use-files.js +40 -14
- package/dist/es/index.js +2 -2
- package/dist/es/lib/inlineFiles.js +90 -0
- package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +12 -0
- package/dist/types/components/FileManager/DragItemArea.d.ts +4 -0
- package/dist/types/components/FileManager/FileManager.d.ts +8 -17
- package/dist/types/components/FileManager/FileManagerProvider.d.ts +18 -8
- package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +3 -0
- package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +19 -0
- package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +38 -0
- package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +12 -0
- package/dist/types/components/FileManager/{FileTypeIcon.d.ts → FileSectionItem/FileTypeIcon.d.ts} +3 -2
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +21 -0
- package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +4 -0
- package/dist/types/components/FileManager/FileSectionState.d.ts +38 -0
- package/dist/types/components/FileManager/FilesSection.d.ts +12 -0
- package/dist/types/components/FileManager/InlineFilesSection.d.ts +19 -3
- package/dist/types/components/FileManager/ItemsAction.d.ts +4 -0
- package/dist/types/components/FileManager/TooltipDiv.d.ts +1 -0
- package/dist/types/components/FileManager/UploadFileArea.d.ts +9 -0
- package/dist/types/components/FileManager/util.d.ts +10 -3
- package/dist/types/hooks/use-files.d.ts +6 -5
- package/dist/types/index.d.ts +2 -2
- package/dist/types/lib/inlineFiles.d.ts +11 -0
- package/package.json +2 -2
- package/dist/cjs/components/FileManager/FileActions.js +0 -135
- package/dist/cjs/components/FileManager/FileContainer.js +0 -38
- package/dist/cjs/components/FileManager/FileCreatedDate.js +0 -25
- package/dist/cjs/components/FileManager/FileName.js +0 -27
- package/dist/cjs/components/FileManager/FileSectionAlert.js +0 -170
- package/dist/cjs/components/FileManager/FileTypeIcon.js +0 -31
- package/dist/cjs/components/FileManager/OtherFilesSection.js +0 -101
- package/dist/cjs/components/FileManager/SupplementsSection.js +0 -118
- package/dist/cjs/components/icons/corrupted-file-icon.js +0 -27
- package/dist/cjs/lib/files.js +0 -85
- package/dist/es/components/FileManager/FileActions.js +0 -105
- package/dist/es/components/FileManager/FileContainer.js +0 -32
- package/dist/es/components/FileManager/FileCreatedDate.js +0 -18
- package/dist/es/components/FileManager/FileName.js +0 -20
- package/dist/es/components/FileManager/FileSectionAlert.js +0 -163
- package/dist/es/components/FileManager/FileTypeIcon.js +0 -24
- package/dist/es/components/FileManager/OtherFilesSection.js +0 -74
- package/dist/es/components/FileManager/SupplementsSection.js +0 -91
- package/dist/es/components/icons/corrupted-file-icon.js +0 -22
- package/dist/es/lib/files.js +0 -79
- package/dist/types/components/FileManager/FileActions.d.ts +0 -19
- package/dist/types/components/FileManager/FileContainer.d.ts +0 -1
- package/dist/types/components/FileManager/FileCreatedDate.d.ts +0 -8
- package/dist/types/components/FileManager/FileName.d.ts +0 -6
- package/dist/types/components/FileManager/FileSectionAlert.d.ts +0 -13
- package/dist/types/components/FileManager/FileUploader.d.ts +0 -4
- package/dist/types/components/FileManager/OtherFilesSection.d.ts +0 -5
- package/dist/types/components/FileManager/SupplementsSection.d.ts +0 -5
- package/dist/types/components/FileManager/Tooltip.d.ts +0 -2
- package/dist/types/components/icons/corrupted-file-icon.d.ts +0 -19
- package/dist/types/lib/files.d.ts +0 -24
- /package/dist/types/components/FileManager/{DragLayer.d.ts → FileSectionItem/DragLayer.d.ts} +0 -0
|
@@ -1,35 +1,27 @@
|
|
|
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
1
|
import React, { useCallback, useRef } from 'react';
|
|
11
2
|
import { useDrop } from 'react-dnd';
|
|
12
3
|
import { NativeTypes } from 'react-dnd-html5-backend';
|
|
13
4
|
import styled, { css } from 'styled-components';
|
|
14
|
-
|
|
5
|
+
import { actions } from './FileSectionState';
|
|
6
|
+
export const UploadFileArea = ({ fileSection, dispatch }) => {
|
|
15
7
|
const fileInputRef = useRef(null);
|
|
16
8
|
const openFileDialog = () => {
|
|
17
9
|
if (fileInputRef && fileInputRef.current) {
|
|
18
10
|
fileInputRef.current.click();
|
|
19
11
|
}
|
|
20
12
|
};
|
|
21
|
-
const handleChange = (event) =>
|
|
13
|
+
const handleChange = (event) => {
|
|
22
14
|
if (event && event.target && event.target.files) {
|
|
23
15
|
const file = event.target.files[0];
|
|
24
|
-
|
|
16
|
+
dispatch(actions.UPLOAD_FILE(file, fileSection));
|
|
25
17
|
}
|
|
26
|
-
}
|
|
27
|
-
const handleFileDrop = useCallback((monitor) =>
|
|
18
|
+
};
|
|
19
|
+
const handleFileDrop = useCallback((monitor) => {
|
|
28
20
|
if (monitor) {
|
|
29
21
|
const file = monitor.getItem().files[0];
|
|
30
|
-
|
|
22
|
+
dispatch(actions.UPLOAD_FILE(file, fileSection));
|
|
31
23
|
}
|
|
32
|
-
}
|
|
24
|
+
}, [dispatch, fileSection]);
|
|
33
25
|
const [{ canDrop, isOver }, dropRef] = useDrop({
|
|
34
26
|
accept: [NativeTypes.FILE],
|
|
35
27
|
drop(item, monitor) {
|
|
@@ -63,7 +55,8 @@ const Container = styled.div `
|
|
|
63
55
|
font-family: ${(props) => props.theme.font.family.Lato};
|
|
64
56
|
color: ${(props) => props.theme.colors.text.onLight};
|
|
65
57
|
cursor: pointer;
|
|
66
|
-
margin:
|
|
58
|
+
margin-bottom: 7px;
|
|
59
|
+
margin-top: 16px;
|
|
67
60
|
${(props) => props.active
|
|
68
61
|
? css `
|
|
69
62
|
${activeBoxStyle}
|
|
@@ -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["Inline"] = "Inline
|
|
17
|
-
FileSectionType["Supplements"] = "Supplements";
|
|
18
|
-
FileSectionType["OtherFile"] =
|
|
16
|
+
FileSectionType[FileSectionType["Inline"] = 0] = "Inline";
|
|
17
|
+
FileSectionType[FileSectionType["Supplements"] = 1] = "Supplements";
|
|
18
|
+
FileSectionType[FileSectionType["OtherFile"] = 2] = "OtherFile";
|
|
19
19
|
})(FileSectionType || (FileSectionType = {}));
|
|
20
20
|
export var FileType;
|
|
21
21
|
(function (FileType) {
|
|
@@ -68,42 +68,78 @@ 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
|
+
]);
|
|
71
84
|
export const fileTypesWithIconMap = new Map([
|
|
72
|
-
[FileType.Audio, React.createElement(AudioIcon, { key: FileType.Audio
|
|
73
|
-
[FileType.Video, React.createElement(VideoIcon, { key: FileType.Video
|
|
85
|
+
[FileType.Audio, React.createElement(AudioIcon, { key: FileType.Audio })],
|
|
86
|
+
[FileType.Video, React.createElement(VideoIcon, { key: FileType.Video })],
|
|
74
87
|
[
|
|
75
88
|
FileType.PlainDocument,
|
|
76
|
-
React.createElement(DocumentIcon, { key: FileType.PlainDocument, color: "#1A9BC7"
|
|
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" }),
|
|
89
|
+
React.createElement(DocumentIcon, { key: FileType.PlainDocument, color: "#1A9BC7" }),
|
|
93
90
|
],
|
|
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 })],
|
|
94
95
|
[
|
|
95
96
|
FileType.CompressedFile,
|
|
96
|
-
React.createElement(CompressedFileIcon, { key: FileType.CompressedFile
|
|
97
|
+
React.createElement(CompressedFileIcon, { key: FileType.CompressedFile }),
|
|
97
98
|
],
|
|
98
99
|
[
|
|
99
100
|
FileType.PlainText,
|
|
100
|
-
React.createElement(DocumentIcon, { key: FileType.PlainText, color: "#FFBD26"
|
|
101
|
+
React.createElement(DocumentIcon, { key: FileType.PlainText, color: "#FFBD26" }),
|
|
101
102
|
],
|
|
102
|
-
[FileType.Image, React.createElement(ImageIcon, { key: FileType.Image
|
|
103
|
-
[FileType.Figure, React.createElement(FigureIcon, { key: FileType.Figure
|
|
103
|
+
[FileType.Image, React.createElement(ImageIcon, { key: FileType.Image })],
|
|
104
|
+
[FileType.Figure, React.createElement(FigureIcon, { key: FileType.Figure })],
|
|
104
105
|
[
|
|
105
106
|
FileType.GraphicalAbstract,
|
|
106
|
-
React.createElement(GraphicalAbstractIcon, { key: FileType.GraphicalAbstract
|
|
107
|
+
React.createElement(GraphicalAbstractIcon, { key: FileType.GraphicalAbstract }),
|
|
107
108
|
],
|
|
108
|
-
[undefined, React.createElement(UnknownFormatFileIcon, { key: undefined
|
|
109
|
+
[undefined, React.createElement(UnknownFormatFileIcon, { key: undefined })],
|
|
109
110
|
]);
|
|
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
|
+
];
|
|
@@ -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", {
|
|
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 },
|
|
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,20 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
2
|
+
import { getModelsByType } from '@manuscripts/transform';
|
|
3
|
+
import getInlineFiles from '../lib/inlineFiles';
|
|
2
4
|
import { useDeepCompareMemo } from './use-deep-compare';
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return files.filter((f) => !excluded.has(f.id) && (!filter || filter(f)));
|
|
5
|
+
const getInlineFilesIds = (inlineFiles) => {
|
|
6
|
+
return inlineFiles
|
|
7
|
+
.map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
|
|
8
|
+
.flat();
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
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);
|
|
14
40
|
return {
|
|
15
|
-
inlineFiles,
|
|
16
|
-
supplements,
|
|
17
41
|
otherFiles,
|
|
42
|
+
supplementFiles,
|
|
43
|
+
inlineFiles,
|
|
18
44
|
};
|
|
19
|
-
}, [...Array.from(modelMap.values()), ...
|
|
45
|
+
}, [...Array.from(modelMap.values()), ...attachments]);
|
|
20
46
|
export default useFiles;
|
package/dist/es/index.js
CHANGED
|
@@ -31,6 +31,7 @@ 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';
|
|
34
35
|
export * from './components/Resizer';
|
|
35
36
|
export * from './components/SaveStatus';
|
|
36
37
|
export * from './components/SimpleModal';
|
|
@@ -48,11 +49,10 @@ export * from './components/NavDropdown';
|
|
|
48
49
|
export * from './components/SubmissionInspector';
|
|
49
50
|
export * from './components/Dropdown';
|
|
50
51
|
export * from './hooks/use-dropdown';
|
|
51
|
-
export
|
|
52
|
+
export { useFiles } from './hooks/use-files';
|
|
52
53
|
export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
|
|
53
54
|
export * from './lib/authors';
|
|
54
55
|
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';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ObjectTypes, } from '@manuscripts/json-schema';
|
|
2
|
+
import { hasObjectType } from '@manuscripts/transform';
|
|
3
|
+
import { FileType } from '../components/FileManager/util';
|
|
4
|
+
const getFigureData = (element, modelMap, attachmentsMap) => {
|
|
5
|
+
const attachments = [];
|
|
6
|
+
element.containedObjectIDs.map((id) => {
|
|
7
|
+
const object = modelMap.get(id);
|
|
8
|
+
if (object && object.objectType === ObjectTypes.Figure) {
|
|
9
|
+
const figure = object;
|
|
10
|
+
if (figure.src) {
|
|
11
|
+
const attachment = attachmentsMap.get(figure.src.replace('attachment:', ''));
|
|
12
|
+
if (attachment) {
|
|
13
|
+
attachment.modelId = id;
|
|
14
|
+
attachments.push(attachment);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
id: element._id,
|
|
21
|
+
attachments,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export default (modelMap, attachments) => {
|
|
25
|
+
const files = [];
|
|
26
|
+
const attachmentsMap = new Map(attachments.map((attachment) => [attachment.id, attachment]));
|
|
27
|
+
const { graphicalAbstractFigureId, figureElement } = getAuxiliaryObjects(modelMap);
|
|
28
|
+
if (graphicalAbstractFigureId) {
|
|
29
|
+
const element = modelMap.get(graphicalAbstractFigureId);
|
|
30
|
+
files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Graphical Abstract`, type: FileType.GraphicalAbstract }));
|
|
31
|
+
}
|
|
32
|
+
figureElement.map((id, index) => {
|
|
33
|
+
const element = modelMap.get(id);
|
|
34
|
+
files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Figure ${index + 1}`, type: FileType.Figure }));
|
|
35
|
+
});
|
|
36
|
+
return files;
|
|
37
|
+
};
|
|
38
|
+
const getAuxiliaryObjects = (modelMap) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
let graphicalAbstractFigureId, figureElementIds = [];
|
|
41
|
+
const tableElementIds = [], orderObjects = {};
|
|
42
|
+
for (const model of modelMap.values()) {
|
|
43
|
+
switch (model.objectType) {
|
|
44
|
+
case ObjectTypes.Section: {
|
|
45
|
+
const section = model;
|
|
46
|
+
if (section.category === 'MPSectionCategory:abstract-graphical') {
|
|
47
|
+
graphicalAbstractFigureId = (_a = section.elementIDs) === null || _a === void 0 ? void 0 : _a.find((id) => {
|
|
48
|
+
const obj = modelMap.get(id);
|
|
49
|
+
return obj && hasObjectType(ObjectTypes.FigureElement)(obj);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
(_b = section.elementIDs) === null || _b === void 0 ? void 0 : _b.map((elementId) => {
|
|
54
|
+
const element = modelMap.get(elementId);
|
|
55
|
+
if (!element) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
switch (element.objectType) {
|
|
59
|
+
case ObjectTypes.FigureElement:
|
|
60
|
+
figureElementIds.push(element._id);
|
|
61
|
+
break;
|
|
62
|
+
case ObjectTypes.TableElement:
|
|
63
|
+
tableElementIds.push(element._id);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case ObjectTypes.ElementsOrder: {
|
|
71
|
+
const elementsOrder = model;
|
|
72
|
+
orderObjects[elementsOrder.elementType] = elementsOrder;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (graphicalAbstractFigureId) {
|
|
77
|
+
figureElementIds = figureElementIds.filter((id) => id != graphicalAbstractFigureId);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
graphicalAbstractFigureId,
|
|
81
|
+
figureElement: sortAuxiliaryObject(figureElementIds, orderObjects[ObjectTypes.FigureElement]),
|
|
82
|
+
tableElement: sortAuxiliaryObject(tableElementIds, orderObjects[ObjectTypes.TableElement]),
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const sortAuxiliaryObject = (auxiliaryObjectIds, orderObject) => {
|
|
86
|
+
if (!orderObject) {
|
|
87
|
+
return auxiliaryObjectIds;
|
|
88
|
+
}
|
|
89
|
+
return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
|
|
90
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { Dispatch } from 'react';
|
|
2
|
+
import { Action } from './FileSectionState';
|
|
3
|
+
export declare const ConfirmationPopUp: React.FC<{
|
|
4
|
+
popupHeader: string;
|
|
5
|
+
popUpMessage: string;
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
handleClose: () => void;
|
|
8
|
+
handleMove: () => void;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const MoveFilePopup: React.FC<{
|
|
11
|
+
dispatch: Dispatch<Action>;
|
|
12
|
+
}>;
|
|
@@ -1,31 +1,22 @@
|
|
|
1
1
|
import { Model } from '@manuscripts/json-schema';
|
|
2
2
|
import { Build } from '@manuscripts/transform';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { FileSectionType } from '../../index';
|
|
5
4
|
import { Capabilities } from '../../lib/capabilities';
|
|
6
|
-
import { FileAttachment } from '
|
|
7
|
-
export type Upload = (file: File) => Promise<FileAttachment>;
|
|
8
|
-
export type
|
|
9
|
-
export type PreviewLink = (file: FileAttachment) => string | undefined;
|
|
10
|
-
export type Replace = (file: File) => Promise<void>;
|
|
11
|
-
export type Move = {
|
|
12
|
-
sectionType: FileSectionType;
|
|
13
|
-
handler: () => Promise<void>;
|
|
14
|
-
};
|
|
5
|
+
import { FileAttachment } from './FileSectionItem/FileSectionItem';
|
|
6
|
+
export type Upload = (file: File) => Promise<boolean | FileAttachment | undefined>;
|
|
7
|
+
export type Replace = (attachmentId: string, name: string, file: File) => Promise<boolean | FileAttachment | undefined>;
|
|
15
8
|
export interface FileManagement {
|
|
9
|
+
getAttachments: () => FileAttachment[];
|
|
16
10
|
upload: Upload;
|
|
17
|
-
|
|
18
|
-
previewLink: PreviewLink;
|
|
11
|
+
replace: Replace;
|
|
19
12
|
}
|
|
20
|
-
export type SaveModel = <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
21
|
-
export type DeleteModel = (id: string) => Promise<string>;
|
|
22
13
|
export declare const PermissionsContext: React.Context<Capabilities | null>;
|
|
23
14
|
export declare const FileManager: React.FC<{
|
|
24
|
-
files: FileAttachment[];
|
|
25
15
|
fileManagement: FileManagement;
|
|
26
16
|
modelMap: Map<string, Model>;
|
|
27
|
-
saveModel:
|
|
28
|
-
deleteModel:
|
|
17
|
+
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
18
|
+
deleteModel: (id: string) => Promise<string>;
|
|
29
19
|
enableDragAndDrop: boolean;
|
|
30
20
|
can: Capabilities;
|
|
21
|
+
addAttachmentToState?: (a: FileAttachment) => void;
|
|
31
22
|
}>;
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { Model } from '@manuscripts/json-schema';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { Build } from '@manuscripts/transform';
|
|
3
|
+
import React, { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
import { FileAttachment } from './FileSectionItem/FileSectionItem';
|
|
5
|
+
import { FileSectionType } from './util';
|
|
6
|
+
type MoveFilePopup = {
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
fileSection?: FileSectionType;
|
|
9
|
+
attachmentId?: string;
|
|
10
|
+
};
|
|
4
11
|
export declare const FileManagerContext: React.Context<{
|
|
5
|
-
saveModel:
|
|
6
|
-
deleteModel:
|
|
12
|
+
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
13
|
+
deleteModel: (id: string) => Promise<string>;
|
|
7
14
|
modelMap: Map<string, Model>;
|
|
8
|
-
|
|
15
|
+
getAttachments: () => FileAttachment[];
|
|
16
|
+
moveFilePopup: MoveFilePopup;
|
|
17
|
+
setMoveFilePopupData: Dispatch<SetStateAction<MoveFilePopup>>;
|
|
9
18
|
}>;
|
|
10
19
|
export declare const FileManagerProvider: React.FC<{
|
|
11
|
-
saveModel:
|
|
12
|
-
deleteModel:
|
|
20
|
+
saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
|
|
21
|
+
deleteModel: (id: string) => Promise<string>;
|
|
13
22
|
modelMap: Map<string, Model>;
|
|
14
|
-
|
|
23
|
+
getAttachments: () => FileAttachment[];
|
|
15
24
|
}>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { Dispatch } from 'react';
|
|
2
|
+
import { Action } from '../FileSectionState';
|
|
3
|
+
export declare const FileInfo: React.FC<{
|
|
4
|
+
showAttachmentName: boolean;
|
|
5
|
+
title: string;
|
|
6
|
+
fileAttachmentName: string;
|
|
7
|
+
fileExtension: string;
|
|
8
|
+
attachmentId: string;
|
|
9
|
+
fileCreatedDate: Date;
|
|
10
|
+
dispatch?: Dispatch<Action>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const FileDateContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
13
|
+
export declare const FileInfoContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
14
|
+
export declare const FileNameTitleContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
15
|
+
export declare const FileTitle: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
16
|
+
export declare const FileNameContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
17
|
+
export declare const FileName: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
18
|
+
export declare const FileDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
19
|
+
export declare const FileDescription: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { CSSProperties, Dispatch } from 'react';
|
|
2
|
+
import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
|
|
3
|
+
import { Maybe } from '../../SubmissionInspector/types';
|
|
4
|
+
import { Replace } from '../FileManager';
|
|
5
|
+
import { Action } from '../FileSectionState';
|
|
6
|
+
import { FileSectionType } from '../util';
|
|
7
|
+
export type FileAttachment = {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
type: FileAttachmentType;
|
|
11
|
+
link: string;
|
|
12
|
+
createdDate: Date;
|
|
13
|
+
};
|
|
14
|
+
export type FileAttachmentType = {
|
|
15
|
+
id: string;
|
|
16
|
+
label?: Maybe<string> | undefined;
|
|
17
|
+
};
|
|
18
|
+
export interface FileSectionItemProps {
|
|
19
|
+
externalFile: FileAttachment;
|
|
20
|
+
fileSection: FileSectionType;
|
|
21
|
+
title: string;
|
|
22
|
+
showAttachmentName?: boolean;
|
|
23
|
+
showActions?: boolean;
|
|
24
|
+
showReplaceAction?: boolean;
|
|
25
|
+
handleDownload?: (url: string) => void;
|
|
26
|
+
handleReplace?: Replace;
|
|
27
|
+
handleSupplementReplace?: (attachment: FileAttachment, oldAttachmentId: string) => void;
|
|
28
|
+
dispatch?: Dispatch<Action>;
|
|
29
|
+
dragRef?: DragElementWrapper<DragSourceOptions>;
|
|
30
|
+
className?: string;
|
|
31
|
+
style?: CSSProperties;
|
|
32
|
+
onClose?: () => void;
|
|
33
|
+
isEditor?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const FileSectionItem: React.FC<FileSectionItemProps>;
|
|
36
|
+
export declare const ActionsIcon: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
|
|
37
|
+
export declare const Item: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
38
|
+
export declare const ItemContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
|
2
|
+
import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
|
|
3
|
+
export interface FileSectionItemProps {
|
|
4
|
+
fileName: string;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
dragRef?: DragElementWrapper<DragSourceOptions>;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
export declare const FileSectionUploadItem: React.FC<FileSectionItemProps>;
|
|
11
|
+
export declare const UploadItemContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
12
|
+
export declare const ProgressBar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { Dispatch } from 'react';
|
|
2
|
+
import { Replace } from '../FileManager';
|
|
3
|
+
import { Action } from '../FileSectionState';
|
|
4
|
+
import { FileSectionType } from '../util';
|
|
5
|
+
import { FileAttachment } from './FileSectionItem';
|
|
6
|
+
export declare const ItemActions: React.FC<{
|
|
7
|
+
fileSection: FileSectionType;
|
|
8
|
+
isMainManuscript?: boolean;
|
|
9
|
+
downloadAttachmentHandler: (url: string) => void;
|
|
10
|
+
replaceAttachmentHandler: Replace;
|
|
11
|
+
detachAttachmnetHandler?: () => void;
|
|
12
|
+
handleUpdateInline?: (attachment: FileAttachment) => void;
|
|
13
|
+
handleSupplementReplace?: (attachment: FileAttachment, oldAttachmentId: string) => void;
|
|
14
|
+
attachmentId: string;
|
|
15
|
+
fileName: string;
|
|
16
|
+
publicUrl: string | undefined;
|
|
17
|
+
hideActionList: (e?: React.MouseEvent) => void;
|
|
18
|
+
dispatch?: Dispatch<Action>;
|
|
19
|
+
dropDownClassName?: string;
|
|
20
|
+
showReplaceAction?: boolean;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const ProgressBarUploadItem: React.FC;
|
|
3
|
+
export declare const LinearProgress: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
4
|
+
export declare const Bar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FileSectionType } from './util';
|
|
2
|
+
export declare const getInitialState: () => State;
|
|
3
|
+
export interface State {
|
|
4
|
+
uploadedFile: File | undefined;
|
|
5
|
+
isUploadFile: boolean;
|
|
6
|
+
moveToOtherState: {
|
|
7
|
+
typeId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
} | undefined;
|
|
10
|
+
fileUploadedSuccessfullySection: FileSectionType | undefined;
|
|
11
|
+
successMessage: string;
|
|
12
|
+
isShowSuccessMessage: boolean;
|
|
13
|
+
currentSection: FileSectionType | undefined;
|
|
14
|
+
}
|
|
15
|
+
declare enum ActionTypes {
|
|
16
|
+
UPLOAD_FILE = "UploadFile",
|
|
17
|
+
MOVE_FILE = "moveFile",
|
|
18
|
+
HANDLE_CANCEL_UPLOAD = "handleCancel",
|
|
19
|
+
HANDLE_UPLOAD_ACTION = "handleUpload",
|
|
20
|
+
HANDLE_FINISH_UPLOAD = "handleFinishUpload",
|
|
21
|
+
HANDLE_SUCCESS_MESSAGE = "handleSuccessMessage",
|
|
22
|
+
HANDLE_SUCCESS_MESSAGE_DISMISS = "handleSuccessMessageDismiss"
|
|
23
|
+
}
|
|
24
|
+
export declare const reducer: (state: State, action: Action) => State;
|
|
25
|
+
export interface Action {
|
|
26
|
+
type: ActionTypes;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
export declare const actions: {
|
|
30
|
+
UPLOAD_FILE: (uploadFile: File, sectionType: FileSectionType) => Action;
|
|
31
|
+
HANDLE_UPLOAD_ACTION: () => Action;
|
|
32
|
+
HANDLE_CANCEL_UPLOAD: () => Action;
|
|
33
|
+
MOVE_FILE: (attachmentId: string, typeId: string, name: string, successMoveMessage: string) => Action;
|
|
34
|
+
HANDLE_FINISH_UPLOAD: () => Action;
|
|
35
|
+
HANDLE_SUCCESS_MESSAGE: (successMessage: string, sectionType?: FileSectionType) => Action;
|
|
36
|
+
HANDLE_SUCCESS_MESSAGE_DISMISS: () => Action;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { Dispatch } from 'react';
|
|
2
|
+
import { Upload } from './FileManager';
|
|
3
|
+
import { Action, State } from './FileSectionState';
|
|
4
|
+
import { FileSectionType } from './util';
|
|
5
|
+
export declare const FilesSection: React.FC<{
|
|
6
|
+
enableDragAndDrop: boolean;
|
|
7
|
+
handleUpload: Upload;
|
|
8
|
+
fileSection: FileSectionType;
|
|
9
|
+
filesItem: JSX.Element[];
|
|
10
|
+
dispatch: Dispatch<Action>;
|
|
11
|
+
state: State;
|
|
12
|
+
}>;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, { Dispatch } from 'react';
|
|
2
|
+
import { Replace } from './FileManager';
|
|
3
|
+
import { FileAttachment } from './FileSectionItem/FileSectionItem';
|
|
4
|
+
import { Action } from './FileSectionState';
|
|
5
|
+
import { FileType } from './util';
|
|
3
6
|
export declare const InlineFilesSection: React.FC<{
|
|
4
|
-
|
|
7
|
+
inlineFiles: {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
type: FileType;
|
|
11
|
+
caption?: string;
|
|
12
|
+
attachments?: FileAttachment[];
|
|
13
|
+
}[];
|
|
14
|
+
handleReplace: Replace;
|
|
15
|
+
handleDownload: (url: string) => void;
|
|
16
|
+
handleUpdateInline?: (modelId: string, attachment: FileAttachment) => void;
|
|
17
|
+
handleDetachFile?: (attachmentLink: string, modelId: string) => void;
|
|
5
18
|
isEditor: boolean;
|
|
19
|
+
dispatch: Dispatch<Action>;
|
|
6
20
|
}>;
|
|
21
|
+
export declare const FileDateContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
22
|
+
export declare const FileDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|