@manuscripts/style-guide 1.3.5-LEAN-2705-5 → 1.3.6-LEAN-2585-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.
- package/dist/cjs/components/AuthorsList/Author.js +19 -11
- package/dist/cjs/components/AuthorsList/AuthorsList.js +1 -1
- package/dist/cjs/components/EditorHeader/EditorHeader.js +11 -3
- package/dist/cjs/components/EditorHeader/ProceedView.js +6 -25
- package/dist/cjs/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
- package/dist/cjs/components/FileManager/FileActions.js +134 -0
- package/dist/cjs/components/FileManager/FileContainer.js +39 -0
- package/dist/cjs/components/FileManager/FileCreatedDate.js +25 -0
- package/dist/cjs/components/FileManager/FileManager.js +14 -125
- package/dist/cjs/components/FileManager/FileManagerProvider.js +2 -7
- package/dist/cjs/components/FileManager/FileName.js +27 -0
- package/dist/cjs/components/FileManager/FileSectionAlert.js +170 -0
- package/dist/cjs/components/FileManager/FileTypeIcon.js +22 -0
- package/dist/cjs/components/FileManager/{UploadFileArea.js → FileUploader.js} +19 -12
- package/dist/cjs/components/FileManager/InlineFilesSection.js +71 -126
- package/dist/cjs/components/FileManager/OtherFilesSection.js +101 -0
- package/dist/cjs/components/FileManager/SupplementsSection.js +118 -0
- package/dist/cjs/components/FileManager/{TooltipDiv.js → Tooltip.js} +8 -3
- package/dist/cjs/components/FileManager/util.js +52 -67
- package/dist/cjs/components/icons/corrupted-file-icon.js +27 -0
- package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
- package/dist/cjs/hooks/use-deep-compare.js +2 -2
- package/dist/cjs/hooks/use-files.js +29 -43
- package/dist/cjs/index.js +3 -4
- package/dist/cjs/lib/capabilities.js +1 -2
- package/dist/cjs/lib/files.js +85 -0
- package/dist/es/components/AuthorsList/Author.js +19 -11
- package/dist/es/components/AuthorsList/AuthorsList.js +1 -1
- package/dist/es/components/EditorHeader/EditorHeader.js +11 -3
- package/dist/es/components/EditorHeader/ProceedView.js +7 -26
- package/dist/es/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
- package/dist/es/components/FileManager/FileActions.js +104 -0
- package/dist/es/components/FileManager/FileContainer.js +33 -0
- package/dist/es/components/FileManager/FileCreatedDate.js +18 -0
- package/dist/es/components/FileManager/FileManager.js +16 -124
- package/dist/es/components/FileManager/FileManagerProvider.js +3 -8
- package/dist/es/components/FileManager/FileName.js +20 -0
- package/dist/es/components/FileManager/FileSectionAlert.js +163 -0
- package/dist/es/components/FileManager/FileTypeIcon.js +15 -0
- package/dist/es/components/FileManager/{UploadFileArea.js → FileUploader.js} +17 -10
- package/dist/es/components/FileManager/InlineFilesSection.js +72 -127
- package/dist/es/components/FileManager/OtherFilesSection.js +74 -0
- package/dist/es/components/FileManager/SupplementsSection.js +91 -0
- package/dist/es/components/FileManager/{TooltipDiv.js → Tooltip.js} +7 -2
- package/dist/es/components/FileManager/util.js +47 -65
- package/dist/es/components/icons/corrupted-file-icon.js +22 -0
- package/dist/es/components/icons/document-icon-with-dot.js +1 -1
- package/dist/es/hooks/use-deep-compare.js +2 -2
- package/dist/es/hooks/use-files.js +29 -40
- package/dist/es/index.js +2 -2
- package/dist/es/lib/capabilities.js +1 -2
- package/dist/es/lib/files.js +79 -0
- package/dist/types/components/AuthorsList/Author.d.ts +1 -0
- package/dist/types/components/EditorHeader/ProceedView.d.ts +1 -0
- package/dist/types/components/FileManager/FileActions.d.ts +19 -0
- package/dist/types/components/FileManager/FileContainer.d.ts +1 -0
- package/dist/types/components/FileManager/FileCreatedDate.d.ts +8 -0
- package/dist/types/components/FileManager/FileManager.d.ts +17 -8
- package/dist/types/components/FileManager/FileManagerProvider.d.ts +8 -18
- package/dist/types/components/FileManager/FileName.d.ts +6 -0
- package/dist/types/components/FileManager/FileSectionAlert.d.ts +13 -0
- package/dist/types/components/FileManager/{FileSectionItem/FileTypeIcon.d.ts → FileTypeIcon.d.ts} +2 -3
- package/dist/types/components/FileManager/FileUploader.d.ts +4 -0
- package/dist/types/components/FileManager/InlineFilesSection.d.ts +3 -19
- package/dist/types/components/FileManager/OtherFilesSection.d.ts +5 -0
- package/dist/types/components/FileManager/SupplementsSection.d.ts +5 -0
- package/dist/types/components/FileManager/Tooltip.d.ts +2 -0
- package/dist/types/components/FileManager/util.d.ts +8 -12
- package/dist/types/components/icons/corrupted-file-icon.d.ts +19 -0
- package/dist/types/hooks/use-files.d.ts +4 -6
- package/dist/types/index.d.ts +2 -2
- package/dist/types/lib/capabilities.d.ts +0 -1
- package/dist/types/lib/files.d.ts +24 -0
- package/package.json +3 -3
- package/dist/cjs/components/FileManager/ConfirmationPopUp.js +0 -90
- package/dist/cjs/components/FileManager/DragItemArea.js +0 -28
- package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -76
- package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +0 -115
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +0 -95
- package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -37
- package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -53
- package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +0 -92
- package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -120
- package/dist/cjs/components/FileManager/FileSectionState.js +0 -83
- package/dist/cjs/components/FileManager/FilesSection.js +0 -61
- package/dist/cjs/components/FileManager/ItemsAction.js +0 -48
- package/dist/cjs/lib/inlineFiles.js +0 -92
- package/dist/es/components/FileManager/ConfirmationPopUp.js +0 -62
- package/dist/es/components/FileManager/DragItemArea.js +0 -21
- package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -46
- package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +0 -85
- package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +0 -88
- package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -30
- package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -46
- package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +0 -65
- package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -113
- package/dist/es/components/FileManager/FileSectionState.js +0 -78
- package/dist/es/components/FileManager/FilesSection.js +0 -34
- package/dist/es/components/FileManager/ItemsAction.js +0 -42
- package/dist/es/lib/inlineFiles.js +0 -90
- package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +0 -12
- package/dist/types/components/FileManager/DragItemArea.d.ts +0 -4
- package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +0 -3
- package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -19
- package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +0 -38
- package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -12
- package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -21
- package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +0 -4
- package/dist/types/components/FileManager/FileSectionState.d.ts +0 -38
- package/dist/types/components/FileManager/FilesSection.d.ts +0 -12
- package/dist/types/components/FileManager/ItemsAction.d.ts +0 -4
- package/dist/types/components/FileManager/TooltipDiv.d.ts +0 -1
- package/dist/types/components/FileManager/UploadFileArea.d.ts +0 -9
- package/dist/types/lib/inlineFiles.d.ts +0 -11
- /package/dist/types/components/FileManager/{FileSectionItem/DragLayer.d.ts → DragLayer.d.ts} +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { AlertMessage, AlertMessageType } from '../AlertMessage';
|
|
4
|
+
import UnknownFormatFileIcon from '../icons/unknown-format-file-icon';
|
|
5
|
+
import { FileContainer } from './FileContainer';
|
|
6
|
+
import { FileNameText } from './FileName';
|
|
7
|
+
export var FileSectionAlertType;
|
|
8
|
+
(function (FileSectionAlertType) {
|
|
9
|
+
FileSectionAlertType[FileSectionAlertType["NONE"] = 0] = "NONE";
|
|
10
|
+
FileSectionAlertType[FileSectionAlertType["UPLOAD_IN_PROGRESS"] = 1] = "UPLOAD_IN_PROGRESS";
|
|
11
|
+
FileSectionAlertType[FileSectionAlertType["UPLOAD_SUCCESSFUL"] = 2] = "UPLOAD_SUCCESSFUL";
|
|
12
|
+
FileSectionAlertType[FileSectionAlertType["MOVE_SUCCESSFUL"] = 3] = "MOVE_SUCCESSFUL";
|
|
13
|
+
})(FileSectionAlertType || (FileSectionAlertType = {}));
|
|
14
|
+
export const FileSectionAlert = ({ alert }) => {
|
|
15
|
+
return (React.createElement(React.Fragment, null,
|
|
16
|
+
alert.type === FileSectionAlertType.UPLOAD_IN_PROGRESS && (React.createElement(FileUploadInProgressAlert, { name: alert.message })),
|
|
17
|
+
alert.type === FileSectionAlertType.UPLOAD_SUCCESSFUL && (React.createElement(FileUploadSuccessful, null)),
|
|
18
|
+
alert.type === FileSectionAlertType.MOVE_SUCCESSFUL && (React.createElement(FileMoveSuccessful, { name: alert.message }))));
|
|
19
|
+
};
|
|
20
|
+
const FileUploadInProgressAlert = ({ name }) => {
|
|
21
|
+
return (React.createElement(FileUploadContainer, null,
|
|
22
|
+
React.createElement(UnknownFormatFileIcon, null),
|
|
23
|
+
React.createElement(FileUploadNameContainer, null,
|
|
24
|
+
React.createElement(UploadFileNameText, null, name),
|
|
25
|
+
React.createElement(FileUploadProgressBar, null))));
|
|
26
|
+
};
|
|
27
|
+
const FileUploadSuccessful = () => {
|
|
28
|
+
return (React.createElement(AlertMessageContainer, null,
|
|
29
|
+
React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
|
|
30
|
+
text: 'OK',
|
|
31
|
+
} }, "File uploaded successfully")));
|
|
32
|
+
};
|
|
33
|
+
const FileMoveSuccessful = ({ name }) => {
|
|
34
|
+
return (React.createElement(AlertMessageContainer, null,
|
|
35
|
+
React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
|
|
36
|
+
text: 'OK',
|
|
37
|
+
} },
|
|
38
|
+
"File moved to ",
|
|
39
|
+
name)));
|
|
40
|
+
};
|
|
41
|
+
const AlertMessageContainer = styled.div `
|
|
42
|
+
margin-left: 16px;
|
|
43
|
+
margin-right: 16px;
|
|
44
|
+
`;
|
|
45
|
+
const FileUploadContainer = styled(FileContainer) `
|
|
46
|
+
background: #f2fbfc;
|
|
47
|
+
`;
|
|
48
|
+
const FileUploadNameContainer = styled.div `
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
margin-left: 8px;
|
|
51
|
+
`;
|
|
52
|
+
const UploadFileNameText = styled(FileNameText) `
|
|
53
|
+
margin: 0;
|
|
54
|
+
`;
|
|
55
|
+
const FileUploadProgressBar = () => {
|
|
56
|
+
return (React.createElement(LinearProgress, null,
|
|
57
|
+
React.createElement(Bar, { className: "bar1" }),
|
|
58
|
+
React.createElement(Bar, { className: "bar2" })));
|
|
59
|
+
};
|
|
60
|
+
const LinearProgress = styled.div `
|
|
61
|
+
background: ${(props) => props.theme.colors.background.tertiary};
|
|
62
|
+
opacity: 0.7;
|
|
63
|
+
height: 4px;
|
|
64
|
+
position: relative;
|
|
65
|
+
width: 100%;
|
|
66
|
+
margin: 8px auto 0;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
border-radius: 8px;
|
|
69
|
+
animation: start 0.3s ease-in;
|
|
70
|
+
`;
|
|
71
|
+
const Bar = styled.div `
|
|
72
|
+
position: absolute;
|
|
73
|
+
opacity: 0.7;
|
|
74
|
+
background: #1a9bc7;
|
|
75
|
+
transition: transform 0.2s linear;
|
|
76
|
+
left: 0;
|
|
77
|
+
top: 0;
|
|
78
|
+
bottom: 0;
|
|
79
|
+
width: 100%;
|
|
80
|
+
|
|
81
|
+
&.bar1 {
|
|
82
|
+
animation: growBar1 2.5s infinite, moveBar1 2.5s infinite;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&.bar2 {
|
|
86
|
+
animation: growBar2 2.5s infinite, moveBar2 2.5s infinite;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@keyframes growBar1 {
|
|
90
|
+
0% {
|
|
91
|
+
animation-timing-function: linear;
|
|
92
|
+
transform: scaleX(0.1);
|
|
93
|
+
}
|
|
94
|
+
35% {
|
|
95
|
+
animation-timing-function: cubic-bezier(0.3, 0.1, 0.7, 1);
|
|
96
|
+
transform: scaleX(0.1);
|
|
97
|
+
}
|
|
98
|
+
70% {
|
|
99
|
+
animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
|
|
100
|
+
transform: scaleX(0.8);
|
|
101
|
+
}
|
|
102
|
+
100% {
|
|
103
|
+
transform: scaleX(0.1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@keyframes moveBar1 {
|
|
108
|
+
0% {
|
|
109
|
+
left: -105%;
|
|
110
|
+
animation-timing-function: linear;
|
|
111
|
+
}
|
|
112
|
+
20% {
|
|
113
|
+
left: -105%;
|
|
114
|
+
animation-timing-function: cubic-bezier(0.5, 0, 0.7, 0.4);
|
|
115
|
+
}
|
|
116
|
+
60% {
|
|
117
|
+
left: 21%;
|
|
118
|
+
animation-timing-function: cubic-bezier(0.3, 0.4, 0.55, 0.9);
|
|
119
|
+
}
|
|
120
|
+
80% {
|
|
121
|
+
left: 40%;
|
|
122
|
+
animation-timing-function: cubic-bezier(0.1, 0.2, 0.3, 0.95);
|
|
123
|
+
}
|
|
124
|
+
100% {
|
|
125
|
+
left: 90%;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@keyframes growBar2 {
|
|
130
|
+
0% {
|
|
131
|
+
animation-timing-function: cubic-bezier(0.2, 0, 0.5, 0.4);
|
|
132
|
+
transform: scaleX(0.1);
|
|
133
|
+
}
|
|
134
|
+
20% {
|
|
135
|
+
animation-timing-function: cubic-bezier(0.1, 0.2, 0.6, 1);
|
|
136
|
+
transform: scaleX(0.3);
|
|
137
|
+
}
|
|
138
|
+
60% {
|
|
139
|
+
animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
|
|
140
|
+
transform: scaleX(0.6);
|
|
141
|
+
}
|
|
142
|
+
100% {
|
|
143
|
+
transform: scaleX(0.1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
@keyframes moveBar2 {
|
|
147
|
+
0% {
|
|
148
|
+
left: -100%;
|
|
149
|
+
animation-timing-function: cubic-bezier(0.15, 0, 0.5, 0.4);
|
|
150
|
+
}
|
|
151
|
+
25% {
|
|
152
|
+
left: -50%;
|
|
153
|
+
animation-timing-function: cubic-bezier(0.3, 0.3, 0.8, 0.7);
|
|
154
|
+
}
|
|
155
|
+
50% {
|
|
156
|
+
left: 45%;
|
|
157
|
+
animation-timing-function: cubic-bezier(0.1, 0.6, 0.6, 0.9);
|
|
158
|
+
}
|
|
159
|
+
100% {
|
|
160
|
+
left: 95%;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CorruptedFileIcon from '../icons/corrupted-file-icon';
|
|
3
|
+
import DocumentIconWithDot from '../icons/document-icon-with-dot';
|
|
4
|
+
import UnknownFormatFileIcon from '../icons/unknown-format-file-icon';
|
|
5
|
+
import { getFileIcon } from './util';
|
|
6
|
+
export const FileTypeIcon = ({ file }) => {
|
|
7
|
+
if (file.type.id === 'missing') {
|
|
8
|
+
return React.createElement(CorruptedFileIcon, { className: "file-icon" });
|
|
9
|
+
}
|
|
10
|
+
if (file.type.id === 'main-manuscript') {
|
|
11
|
+
return React.createElement(DocumentIconWithDot, { className: "file-icon" });
|
|
12
|
+
}
|
|
13
|
+
const icon = getFileIcon(file);
|
|
14
|
+
return icon || React.createElement(UnknownFormatFileIcon, { className: "file-icon" });
|
|
15
|
+
};
|
|
@@ -1,27 +1,35 @@
|
|
|
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
|
+
};
|
|
1
10
|
import React, { useCallback, useRef } from 'react';
|
|
2
11
|
import { useDrop } from 'react-dnd';
|
|
3
12
|
import { NativeTypes } from 'react-dnd-html5-backend';
|
|
4
13
|
import styled, { css } from 'styled-components';
|
|
5
|
-
|
|
6
|
-
export const UploadFileArea = ({ fileSection, dispatch }) => {
|
|
14
|
+
export const FileUploader = ({ handler }) => {
|
|
7
15
|
const fileInputRef = useRef(null);
|
|
8
16
|
const openFileDialog = () => {
|
|
9
17
|
if (fileInputRef && fileInputRef.current) {
|
|
10
18
|
fileInputRef.current.click();
|
|
11
19
|
}
|
|
12
20
|
};
|
|
13
|
-
const handleChange = (event) => {
|
|
21
|
+
const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
22
|
if (event && event.target && event.target.files) {
|
|
15
23
|
const file = event.target.files[0];
|
|
16
|
-
|
|
24
|
+
yield handler(file);
|
|
17
25
|
}
|
|
18
|
-
};
|
|
19
|
-
const handleFileDrop = useCallback((monitor) => {
|
|
26
|
+
});
|
|
27
|
+
const handleFileDrop = useCallback((monitor) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
28
|
if (monitor) {
|
|
21
29
|
const file = monitor.getItem().files[0];
|
|
22
|
-
|
|
30
|
+
yield handler(file);
|
|
23
31
|
}
|
|
24
|
-
}, [
|
|
32
|
+
}), [handler]);
|
|
25
33
|
const [{ canDrop, isOver }, dropRef] = useDrop({
|
|
26
34
|
accept: [NativeTypes.FILE],
|
|
27
35
|
drop(item, monitor) {
|
|
@@ -55,8 +63,7 @@ const Container = styled.div `
|
|
|
55
63
|
font-family: ${(props) => props.theme.font.family.Lato};
|
|
56
64
|
color: ${(props) => props.theme.colors.text.onLight};
|
|
57
65
|
cursor: pointer;
|
|
58
|
-
margin
|
|
59
|
-
margin-top: 16px;
|
|
66
|
+
margin: 16px 16px 8px;
|
|
60
67
|
${(props) => props.active
|
|
61
68
|
? css `
|
|
62
69
|
${activeBoxStyle}
|
|
@@ -1,158 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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, getFileTypeIcon } from './util';
|
|
11
18
|
const trackedJoint = ':dataTracked:';
|
|
12
|
-
export const InlineFilesSection = ({
|
|
19
|
+
export const InlineFilesSection = ({ elements, isEditor }) => {
|
|
20
|
+
const { modelMap, fileManagement, saveModel } = useContext(FileManagerContext);
|
|
21
|
+
const navigateToElement = (id) => {
|
|
22
|
+
const clearedId = id.split(trackedJoint)[0];
|
|
23
|
+
const isSelected = clearedId == window.location.hash.substring(1);
|
|
24
|
+
window.location.hash = !isSelected ? `#${clearedId}` : '#';
|
|
25
|
+
};
|
|
13
26
|
const onElementClick = useCallback((e) => {
|
|
14
27
|
if (!isEditor) {
|
|
15
28
|
return;
|
|
16
29
|
}
|
|
17
|
-
|
|
18
|
-
const clearedId = id.split(trackedJoint)[0];
|
|
19
|
-
const isSelected = clearedId == window.location.hash.substr(1);
|
|
20
|
-
window.location.hash = !isSelected ? `#${clearedId}` : '#';
|
|
21
|
-
if (isSelected) {
|
|
22
|
-
window.location.hash = `#${clearedId}`;
|
|
23
|
-
}
|
|
30
|
+
navigateToElement(e.currentTarget.id);
|
|
24
31
|
}, [isEditor]);
|
|
25
|
-
|
|
32
|
+
const updateFigureSrc = (modelId, src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
const figure = modelMap.get(modelId);
|
|
34
|
+
if (figure) {
|
|
35
|
+
yield saveModel(Object.assign(Object.assign({}, figure), { src: src }));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const detach = (element, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
yield updateFigureSrc(file.modelId, '');
|
|
40
|
+
navigateToElement(element.modelId);
|
|
41
|
+
});
|
|
42
|
+
const replace = (element, model, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
const uploaded = yield fileManagement.upload(file);
|
|
44
|
+
yield updateFigureSrc(model.modelId, uploaded.id);
|
|
45
|
+
navigateToElement(element.modelId);
|
|
46
|
+
});
|
|
47
|
+
return (React.createElement(React.Fragment, null, elements.map((element, index) => {
|
|
26
48
|
var _a;
|
|
27
|
-
return (React.createElement(
|
|
28
|
-
React.createElement(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
React.createElement(FileInfoContainer, null,
|
|
33
|
-
React.createElement(FileNameTitleContainer, null,
|
|
34
|
-
React.createElement(FileTitle, null, file.label))))));
|
|
49
|
+
return (React.createElement(Element, { key: index, id: element.modelId, onClick: onElementClick },
|
|
50
|
+
React.createElement(ElementLabelContainer, null,
|
|
51
|
+
getFileTypeIcon(element.type),
|
|
52
|
+
React.createElement(ElementLabel, null, element.label)),
|
|
53
|
+
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(element, file, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield detach(element, file); }), handleDownload: () => fileManagement.download(file) }))))));
|
|
35
54
|
})));
|
|
36
55
|
};
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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' }))))));
|
|
56
|
+
const ElementFile = ({ file, handleReplace, handleDownload, handleDetach }) => {
|
|
57
|
+
return (React.createElement(ModelFileContainer, null,
|
|
58
|
+
React.createElement(FileName, { file: file }),
|
|
59
|
+
React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
60
|
+
React.createElement(FileActions, { sectionType: FileSectionType.Inline, handleDownload: file.id ? handleDownload : undefined, handleDetach: file.id ? handleDetach : undefined, handleReplace: handleReplace })));
|
|
58
61
|
};
|
|
59
|
-
|
|
60
|
-
overflow: hidden;
|
|
61
|
-
display: none;
|
|
62
|
-
width: 100%;
|
|
63
|
-
justify-content: flex-end;
|
|
64
|
-
`;
|
|
65
|
-
const ElementItem = styled(Item) `
|
|
62
|
+
const Element = styled.div `
|
|
66
63
|
display: flex;
|
|
67
|
-
|
|
68
|
-
// to change the background on the hover for adjacent node
|
|
69
|
-
flex-direction: column-reverse;
|
|
64
|
+
flex-direction: column;
|
|
70
65
|
padding: 0;
|
|
71
66
|
|
|
72
|
-
:
|
|
73
|
-
background: #f2fbfc;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.refItems:hover ~ .element {
|
|
77
|
-
background: white !important;
|
|
78
|
-
}
|
|
79
|
-
&:hover ${FileDateContainer} {
|
|
80
|
-
display: flex;
|
|
81
|
-
}
|
|
67
|
+
border-bottom: 1px dashed #f0f0f0;
|
|
82
68
|
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
svg {
|
|
70
|
+
width: 24px;
|
|
85
71
|
}
|
|
86
72
|
|
|
87
|
-
border-bottom: 1px dashed #f0f0f0;
|
|
88
|
-
|
|
89
73
|
:last-child {
|
|
90
74
|
border-bottom: 0;
|
|
91
75
|
}
|
|
92
76
|
`;
|
|
93
|
-
const
|
|
77
|
+
const ElementLabelContainer = styled.div `
|
|
94
78
|
display: flex;
|
|
95
|
-
|
|
79
|
+
padding: 20px 16px;
|
|
80
|
+
cursor: pointer;
|
|
96
81
|
`;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
justify-content: space-between;
|
|
105
|
-
width: 100%;
|
|
82
|
+
const ElementLabel = styled.div `
|
|
83
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
84
|
+
font-weight: bold;
|
|
85
|
+
font-size: 16px;
|
|
86
|
+
line-height: 20px;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
margin-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
106
89
|
`;
|
|
107
|
-
const
|
|
108
|
-
display: flex;
|
|
90
|
+
const ElementFilesContainer = styled.div `
|
|
109
91
|
width: 100%;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
width: 100% svg {
|
|
113
|
-
width: 14px;
|
|
114
|
-
height: 17px;
|
|
92
|
+
> :last-child {
|
|
93
|
+
margin-bottom: 25px;
|
|
115
94
|
}
|
|
95
|
+
`;
|
|
96
|
+
const ModelFileContainer = styled(FileContainer) `
|
|
97
|
+
padding: 8px 16px;
|
|
98
|
+
height: 40px;
|
|
116
99
|
|
|
117
100
|
path {
|
|
118
101
|
fill: #6e6e6e;
|
|
119
102
|
}
|
|
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
103
|
`;
|
|
@@ -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
|
|
3
|
-
|
|
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
|
`;
|