@manuscripts/style-guide 1.3.5 → 1.3.6
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/{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/files.js +85 -0
- 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/files.js +79 -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/files.d.ts +24 -0
- package/package.json +1 -1
- 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
|
@@ -1,141 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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, getModelsByType, } from '@manuscripts/transform';
|
|
12
|
-
import React, { createContext, useCallback, useReducer } from 'react';
|
|
13
|
-
import ReactTooltip from 'react-tooltip';
|
|
14
|
-
import { FileSectionType, useFiles } from '../../index';
|
|
1
|
+
import React, { createContext } from 'react';
|
|
2
|
+
import { useFiles } from '../../index';
|
|
15
3
|
import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
|
|
16
4
|
import { InspectorSection } from '../InspectorSection';
|
|
17
|
-
import {
|
|
5
|
+
import { DragLayer } from './DragLayer';
|
|
18
6
|
import { FileManagerProvider } from './FileManagerProvider';
|
|
19
|
-
import { DraggableFileSectionItem } from './FileSectionItem/DraggableFileSectionItem';
|
|
20
|
-
import { DragLayer } from './FileSectionItem/DragLayer';
|
|
21
|
-
import { FileSectionItem, } from './FileSectionItem/FileSectionItem';
|
|
22
|
-
import { actions, getInitialState, reducer } from './FileSectionState';
|
|
23
|
-
import { FilesSection } from './FilesSection';
|
|
24
7
|
import { InlineFilesSection } from './InlineFilesSection';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
8
|
+
import { OtherFilesSection } from './OtherFilesSection';
|
|
9
|
+
import { SupplementsSection } from './SupplementsSection';
|
|
10
|
+
import { Tooltip } from './Tooltip';
|
|
27
11
|
export const PermissionsContext = createContext(null);
|
|
28
|
-
export const FileManager = ({ modelMap, saveModel, deleteModel, enableDragAndDrop, can,
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
32
|
-
const res = yield replace(attachmentId, name, file);
|
|
33
|
-
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
34
|
-
if (res) {
|
|
35
|
-
dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
|
|
36
|
-
}
|
|
37
|
-
return res;
|
|
38
|
-
}), [replace]);
|
|
39
|
-
const handleUploadFile = useCallback((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
41
|
-
const res = yield upload(file);
|
|
42
|
-
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
43
|
-
if (res) {
|
|
44
|
-
dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.', FileSectionType.OtherFile));
|
|
45
|
-
}
|
|
46
|
-
return res;
|
|
47
|
-
}), [upload]);
|
|
48
|
-
const handleUploadFileWithSupplement = useCallback((file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
dispatch(actions.HANDLE_UPLOAD_ACTION());
|
|
50
|
-
const response = yield upload(file);
|
|
51
|
-
if (typeof response === 'object') {
|
|
52
|
-
const { id, name } = response;
|
|
53
|
-
yield saveModel(buildSupplementaryMaterial(name, `attachment:${id}`));
|
|
54
|
-
}
|
|
55
|
-
dispatch(actions.HANDLE_FINISH_UPLOAD());
|
|
56
|
-
if (response) {
|
|
57
|
-
dispatch(actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.', FileSectionType.Supplements));
|
|
58
|
-
}
|
|
59
|
-
return response;
|
|
60
|
-
}), [upload, saveModel]);
|
|
61
|
-
const handleSupplementReplace = useCallback((attachment, oldAttachmentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
const model = getModelsByType(modelMap, ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === oldAttachmentId);
|
|
63
|
-
yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
|
|
64
|
-
}), [modelMap, saveModel]);
|
|
65
|
-
const handleDownload = useCallback((url) => {
|
|
66
|
-
window.location.assign(url);
|
|
67
|
-
}, []);
|
|
68
|
-
const handleUpdateInline = useCallback((modelId, attachment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
const figureModel = modelMap.get(modelId);
|
|
70
|
-
figureModel.src = `attachment:${attachment.id}`;
|
|
71
|
-
if (addAttachmentToState) {
|
|
72
|
-
addAttachmentToState(Object.assign({}, attachment));
|
|
73
|
-
}
|
|
74
|
-
yield saveModel(figureModel);
|
|
75
|
-
}), [modelMap, saveModel, addAttachmentToState]);
|
|
76
|
-
const attachments = getAttachments();
|
|
77
|
-
const { otherFiles, supplementFiles, inlineFiles } = useFiles(modelMap, attachments);
|
|
78
|
-
const handleDetachFile = (attachmentId, modelId) => {
|
|
79
|
-
const model = modelMap.get(modelId);
|
|
80
|
-
if (model) {
|
|
81
|
-
saveModel(Object.assign(Object.assign({}, model), { src: '' }));
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const getFileSectionExternalFile = (fileSection) => {
|
|
85
|
-
const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
|
|
86
|
-
fileSection === FileSectionType.OtherFile;
|
|
87
|
-
const isOtherFilesTab = fileSection === FileSectionType.OtherFile;
|
|
88
|
-
const itemsData = (fileSection === FileSectionType.Supplements && supplementFiles) ||
|
|
89
|
-
otherFiles;
|
|
90
|
-
const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
|
|
91
|
-
const filesItems = itemsDataWithTitle.map((element) => {
|
|
92
|
-
const itemProps = {
|
|
93
|
-
fileSection,
|
|
94
|
-
externalFile: element.externalFile,
|
|
95
|
-
title: element.title,
|
|
96
|
-
showAttachmentName: isSupplementOrOtherFilesTab,
|
|
97
|
-
showReplaceAction: !isOtherFilesTab,
|
|
98
|
-
handleDownload,
|
|
99
|
-
handleReplace: handleReplaceFile,
|
|
100
|
-
handleSupplementReplace,
|
|
101
|
-
dispatch: dispatch,
|
|
102
|
-
};
|
|
103
|
-
if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
|
|
104
|
-
return (React.createElement(DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id })));
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return (React.createElement(FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id, isEditor: enableDragAndDrop })));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
return filesItems;
|
|
111
|
-
};
|
|
112
|
-
return (React.createElement(FileManagerProvider, { saveModel: saveModel, modelMap: modelMap, deleteModel: deleteModel, getAttachments: getAttachments },
|
|
12
|
+
export const FileManager = ({ files, fileManagement, modelMap, saveModel, deleteModel, enableDragAndDrop, can, }) => {
|
|
13
|
+
const { inlineFiles, supplements, otherFiles } = useFiles(modelMap, files);
|
|
14
|
+
return (React.createElement(FileManagerProvider, { saveModel: saveModel, deleteModel: deleteModel, modelMap: modelMap, fileManagement: fileManagement },
|
|
113
15
|
React.createElement(DragLayer, null),
|
|
114
16
|
React.createElement(PermissionsContext.Provider, { value: can },
|
|
115
|
-
React.createElement(InspectorSection, { title: 'Files', contentStyles: { margin: '24px' } },
|
|
17
|
+
React.createElement(InspectorSection, { title: 'Files', contentStyles: { margin: '24px 16px' } },
|
|
116
18
|
React.createElement(InspectorTabs, { defaultIndex: 0, style: { overflow: 'visible' } },
|
|
117
19
|
React.createElement(InspectorTabList, null,
|
|
118
20
|
React.createElement(InspectorTab, { "data-for": "inline", "data-tip": true }, "Inline files"),
|
|
119
|
-
React.createElement(
|
|
120
|
-
React.createElement(ReactTooltip, { id: "inline", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" },
|
|
121
|
-
React.createElement("div", null,
|
|
122
|
-
"Files that can be found inline ",
|
|
123
|
-
React.createElement("br", null),
|
|
124
|
-
" in the manuscript."))),
|
|
21
|
+
React.createElement(Tooltip, { id: "inline", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" }, "Files that can be found inline in the manuscript."),
|
|
125
22
|
React.createElement(InspectorTab, { "data-for": "supplements", "data-tip": true }, "Supplements"),
|
|
126
|
-
React.createElement(
|
|
127
|
-
React.createElement(ReactTooltip, { id: "supplements", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" },
|
|
128
|
-
React.createElement("div", null, "Files that were marked as supplementaries."))),
|
|
23
|
+
React.createElement(Tooltip, { id: "supplements", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" }, "Files that were marked as supplements."),
|
|
129
24
|
React.createElement(InspectorTab, { "data-for": "other", "data-tip": true }, "Other files"),
|
|
130
|
-
React.createElement(
|
|
131
|
-
React.createElement(ReactTooltip, { id: "other", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" },
|
|
132
|
-
React.createElement("div", null, "Files excluded from the final submission.")))),
|
|
25
|
+
React.createElement(Tooltip, { id: "other", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" }, "Files excluded from the final submission.")),
|
|
133
26
|
React.createElement(InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
|
|
134
27
|
React.createElement(InspectorTabPanel, null,
|
|
135
|
-
React.createElement(InlineFilesSection, {
|
|
28
|
+
React.createElement(InlineFilesSection, { elements: inlineFiles, isEditor: enableDragAndDrop })),
|
|
136
29
|
React.createElement(InspectorTabPanel, null,
|
|
137
|
-
React.createElement(
|
|
30
|
+
React.createElement(SupplementsSection, { supplements: supplements })),
|
|
138
31
|
React.createElement(InspectorTabPanel, null,
|
|
139
|
-
React.createElement(
|
|
140
|
-
React.createElement(MoveFilePopup, { dispatch: dispatch }))));
|
|
32
|
+
React.createElement(OtherFilesSection, { files: otherFiles }))))))));
|
|
141
33
|
};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import React, { createContext
|
|
1
|
+
import React, { createContext } from 'react';
|
|
2
2
|
export const FileManagerContext = createContext({
|
|
3
3
|
saveModel: () => '',
|
|
4
|
-
moveFilePopup: { isOpen: false },
|
|
5
|
-
setMoveFilePopupData: () => '',
|
|
6
4
|
});
|
|
7
|
-
export const FileManagerProvider = ({ children, saveModel, deleteModel, modelMap,
|
|
8
|
-
const [moveFilePopup, setMoveFilePopupData] = useState({ isOpen: false });
|
|
5
|
+
export const FileManagerProvider = ({ children, saveModel, deleteModel, modelMap, fileManagement }) => {
|
|
9
6
|
return (React.createElement(FileManagerContext.Provider, { value: {
|
|
10
7
|
saveModel,
|
|
11
8
|
deleteModel,
|
|
12
9
|
modelMap,
|
|
13
|
-
|
|
14
|
-
moveFilePopup,
|
|
15
|
-
setMoveFilePopupData,
|
|
10
|
+
fileManagement,
|
|
16
11
|
} }, children));
|
|
17
12
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { FileTypeIcon } from './FileTypeIcon';
|
|
4
|
+
export const FileName = ({ file }) => {
|
|
5
|
+
return (React.createElement(React.Fragment, null,
|
|
6
|
+
React.createElement(FileTypeIcon, { file: file }),
|
|
7
|
+
React.createElement(FileNameText, null, file.name)));
|
|
8
|
+
};
|
|
9
|
+
export const FileNameText = styled.div `
|
|
10
|
+
font-family: ${(props) => props.theme.font.family.Lato};
|
|
11
|
+
font-size: ${(props) => props.theme.font.size.medium};
|
|
12
|
+
line-height: ${(props) => props.theme.font.lineHeight.large};
|
|
13
|
+
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
14
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
15
|
+
margin-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
`;
|
|
@@ -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}
|