@manuscripts/style-guide 1.1.4 → 1.1.5-LEAN-2192-v2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/components/FileManager/FileManager.js +8 -20
  2. package/dist/cjs/components/FileManager/FileSectionItem/DragLayer.js +1 -1
  3. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +1 -3
  4. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +4 -6
  5. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +3 -16
  6. package/dist/cjs/components/FileManager/FileSectionState.js +5 -14
  7. package/dist/cjs/components/FileManager/FilesSection.js +7 -20
  8. package/dist/cjs/components/FileManager/InlineFilesSection.js +1 -1
  9. package/dist/cjs/components/FileManager/util.js +1 -323
  10. package/dist/cjs/index.js +1 -3
  11. package/dist/cjs/lib/capabilities.js +0 -1
  12. package/dist/es/components/FileManager/FileManager.js +9 -21
  13. package/dist/es/components/FileManager/FileSectionItem/DragLayer.js +1 -1
  14. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +1 -3
  15. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +4 -6
  16. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +4 -17
  17. package/dist/es/components/FileManager/FileSectionState.js +5 -14
  18. package/dist/es/components/FileManager/FilesSection.js +9 -22
  19. package/dist/es/components/FileManager/InlineFilesSection.js +1 -1
  20. package/dist/es/components/FileManager/util.js +0 -318
  21. package/dist/es/index.js +0 -1
  22. package/dist/es/lib/capabilities.js +0 -1
  23. package/dist/types/components/FileManager/FileManager.d.ts +2 -4
  24. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -5
  25. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +1 -3
  26. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -2
  27. package/dist/types/components/FileManager/FileSectionState.d.ts +2 -5
  28. package/dist/types/components/FileManager/util.d.ts +0 -30
  29. package/dist/types/index.d.ts +0 -1
  30. package/dist/types/lib/capabilities.d.ts +0 -1
  31. package/package.json +1 -1
  32. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActions.js +0 -131
  33. package/dist/cjs/components/FileManager/FileSectionItem/DesignationActionsList.js +0 -54
  34. package/dist/cjs/components/FileManager/SelectDesignationActions.js +0 -74
  35. package/dist/cjs/components/FileManager/SelectDialogDesignation.js +0 -33
  36. package/dist/es/components/FileManager/FileSectionItem/DesignationActions.js +0 -101
  37. package/dist/es/components/FileManager/FileSectionItem/DesignationActionsList.js +0 -47
  38. package/dist/es/components/FileManager/SelectDesignationActions.js +0 -44
  39. package/dist/es/components/FileManager/SelectDialogDesignation.js +0 -26
  40. package/dist/types/components/FileManager/FileSectionItem/DesignationActions.d.ts +0 -14
  41. package/dist/types/components/FileManager/FileSectionItem/DesignationActionsList.d.ts +0 -13
  42. package/dist/types/components/FileManager/SelectDesignationActions.d.ts +0 -12
  43. package/dist/types/components/FileManager/SelectDialogDesignation.d.ts +0 -11
@@ -52,32 +52,29 @@ const InlineFilesSection_1 = require("./InlineFilesSection");
52
52
  const TooltipDiv_1 = require("./TooltipDiv");
53
53
  const util_1 = require("./util");
54
54
  exports.PermissionsContext = (0, react_1.createContext)(null);
55
- const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, changeDesignation, replace, upload }, addAttachmentToState, }) => {
55
+ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManagement: { getAttachments, replace, upload }, addAttachmentToState, }) => {
56
56
  const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
57
- const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file, typeId) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file) => __awaiter(void 0, void 0, void 0, function* () {
58
58
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
59
- dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.namesWithDesignationMap.get(typeId) || util_1.Designation.Document));
60
- const res = yield replace(attachmentId, name, file, typeId);
59
+ const res = yield replace(attachmentId, name, file);
61
60
  dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
62
61
  if (res) {
63
62
  dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
64
63
  }
65
64
  return res;
66
65
  }), [replace]);
67
- const handleUploadFile = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
66
+ const handleUploadFile = (0, react_1.useCallback)((file) => __awaiter(void 0, void 0, void 0, function* () {
68
67
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
69
- if (util_1.namesWithDesignationMap.get(designation) == util_1.Designation.Supplementary) {
70
- dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(util_1.Designation.Supplementary));
71
- }
72
- const res = yield upload(file, designation);
68
+ const res = yield upload(file);
73
69
  dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
74
70
  if (res) {
75
71
  dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.', index_1.FileSectionType.OtherFile));
76
72
  }
77
73
  return res;
78
74
  }), [upload]);
79
- const handleUploadFileWithSupplement = (0, react_1.useCallback)((file, designation) => __awaiter(void 0, void 0, void 0, function* () {
80
- const response = yield upload(file, designation);
75
+ const handleUploadFileWithSupplement = (0, react_1.useCallback)((file) => __awaiter(void 0, void 0, void 0, function* () {
76
+ dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
77
+ const response = yield upload(file);
81
78
  if (typeof response === 'object') {
82
79
  const { id, name } = response;
83
80
  yield saveModel((0, transform_1.buildSupplementaryMaterial)(name, `attachment:${id}`));
@@ -92,13 +89,6 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
92
89
  const model = (0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === oldAttachmentId);
93
90
  yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
94
91
  }), [modelMap, saveModel]);
95
- const handleChangeDesignationFile = (0, react_1.useCallback)((attachmentId, typeId, name) => __awaiter(void 0, void 0, void 0, function* () {
96
- const res = yield changeDesignation(attachmentId, typeId, name);
97
- if (res) {
98
- dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE(''));
99
- }
100
- return res;
101
- }), [changeDesignation]);
102
92
  const handleDownload = (0, react_1.useCallback)((url) => {
103
93
  window.location.assign(url);
104
94
  }, []);
@@ -131,12 +121,10 @@ const FileManager = ({ modelMap, saveModel, enableDragAndDrop, can, fileManageme
131
121
  externalFile: element.externalFile,
132
122
  title: element.title,
133
123
  showAttachmentName: isSupplementOrOtherFilesTab,
134
- showDesignationActions: isSupplementOrOtherFilesTab,
135
124
  showReplaceAction: !isOtherFilesTab,
136
125
  handleDownload,
137
126
  handleReplace: handleReplaceFile,
138
127
  handleSupplementReplace,
139
- handleChangeDesignation: handleChangeDesignationFile,
140
128
  dispatch: dispatch,
141
129
  };
142
130
  if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
@@ -55,7 +55,7 @@ const DragLayer = () => {
55
55
  const renderItem = (0, react_1.useCallback)(() => {
56
56
  switch (itemType) {
57
57
  case 'FileSectionItem':
58
- return (react_1.default.createElement(CustomFileSectionItem, { title: item.title, externalFile: item.externalFile, showAttachmentName: item.showAttachmentName, withDot: item.withDot, showSecondaryActions: false, showDesignationActions: false, style: { width: item.width } }));
58
+ return (react_1.default.createElement(CustomFileSectionItem, { title: item.title, externalFile: item.externalFile, showAttachmentName: item.showAttachmentName, withDot: item.withDot, showSecondaryActions: false, style: { width: item.width } }));
59
59
  default:
60
60
  return null;
61
61
  }
@@ -30,12 +30,10 @@ exports.FileDescription = exports.FileName = exports.FileNameContainer = exports
30
30
  const react_1 = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
32
  const FileManager_1 = require("../FileManager");
33
- const DesignationActions_1 = require("./DesignationActions");
34
- const FileInfo = ({ showAttachmentName, showDesignationActions, title, fileAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
33
+ const FileInfo = ({ showAttachmentName, title, fileAttachmentName, fileExtension, attachmentId, dispatch, }) => {
35
34
  const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
36
35
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
37
36
  return (react_1.default.createElement(exports.FileInfoContainer, null,
38
- showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: fileAttachmentName, dispatch: dispatch, can: can })),
39
37
  react_1.default.createElement(exports.FileNameTitleContainer, null,
40
38
  react_1.default.createElement(exports.FileTitle, null,
41
39
  !showAttachmentName ? fileName : title,
@@ -10,15 +10,13 @@ const use_dropdown_1 = require("../../../hooks/use-dropdown");
10
10
  const Dropdown_1 = require("../../Dropdown");
11
11
  const icons_1 = require("../../icons/");
12
12
  const dots_icon_1 = __importDefault(require("../../icons/dots-icon"));
13
- const util_1 = require("../util");
14
13
  const FileInfo_1 = require("./FileInfo");
15
14
  const FileTypeIcon_1 = require("./FileTypeIcon");
16
15
  const ItemActions_1 = require("./ItemActions");
17
- const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showDesignationActions = false, showReplaceAction = true, handleDownload, handleReplace, handleChangeDesignation, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
16
+ const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showReplaceAction = true, handleDownload, handleReplace, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
18
17
  const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
19
18
  const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
20
- const designation = util_1.namesWithDesignationMap.get(externalFile.type.label);
21
- const isMainManuscript = designation === util_1.Designation.MainManuscript;
19
+ const isMainManuscript = externalFile.type.label === 'main-manuscript';
22
20
  const isSelected = externalFile.id == window.location.hash.substr(1);
23
21
  return (react_1.default.createElement(exports.Item, { ref: dragRef, className: className, style: style },
24
22
  react_1.default.createElement(exports.ItemContainer, { onClick: () => {
@@ -29,7 +27,7 @@ const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName
29
27
  }
30
28
  } },
31
29
  react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
32
- react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, fileAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
30
+ react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, fileAttachmentName: externalFile.name, title: title, attachmentId: externalFile.id, dispatch: dispatch })),
33
31
  onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
34
32
  e.preventDefault();
35
33
  onClose();
@@ -38,7 +36,7 @@ const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName
38
36
  handleDownload && handleReplace && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
39
37
  react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
40
38
  react_1.default.createElement(dots_icon_1.default, null)),
41
- isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name, designation: externalFile.type.label, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
39
+ isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
42
40
  };
43
41
  exports.FileSectionItem = FileSectionItem;
44
42
  const IconCloseButton = styled_components_1.default.button `
@@ -39,21 +39,9 @@ const FileManager_1 = require("../FileManager");
39
39
  const FileSectionState_1 = require("../FileSectionState");
40
40
  const ItemsAction_1 = require("../ItemsAction");
41
41
  const util_1 = require("../util");
42
- const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, designation, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
43
- const attachmentDesignation = designation == undefined ? 'undefined' : designation;
44
- const attachmentDesignationName = attachmentDesignation !== 'undefined'
45
- ? util_1.namesWithDesignationMap.get(attachmentDesignation)
46
- : undefined;
42
+ const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
47
43
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
48
- const canBeReplaced = ((showReplaceAction == undefined || showReplaceAction) &&
49
- (attachmentDesignationName == undefined ||
50
- ![
51
- util_1.Designation.MainManuscript,
52
- util_1.Designation.SubmissionFile,
53
- util_1.Designation.SubmissionPdf,
54
- ].includes(attachmentDesignationName))) ||
55
- (attachmentDesignationName == util_1.Designation.MainManuscript &&
56
- (can === null || can === void 0 ? void 0 : can.setMainManuscript));
44
+ const canBeReplaced = showReplaceAction == undefined || showReplaceAction;
57
45
  const fileInputRef = (0, react_1.useRef)(null);
58
46
  const [selectedFile, setSelectedFile] = (0, react_1.useState)();
59
47
  const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
@@ -62,9 +50,8 @@ const ItemActions = ({ fileSection, downloadAttachmentHandler, replaceAttachment
62
50
  setSelectedFile(file);
63
51
  if (dispatch) {
64
52
  dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
65
- dispatch(FileSectionState_1.actions.SELECT_DESIGNATION(attachmentDesignationName || util_1.Designation.Document));
66
53
  }
67
- const result = yield replaceAttachmentHandler(attachmentId, fileName, file, attachmentDesignation);
54
+ const result = yield replaceAttachmentHandler(attachmentId, fileName, file);
68
55
  if (fileSection === util_1.FileSectionType.Supplements &&
69
56
  typeof result === 'object' &&
70
57
  handleSupplementReplace) {
@@ -8,15 +8,13 @@ const getInitialState = () => ({
8
8
  fileUploadedSuccessfullySection: undefined,
9
9
  successMessage: '',
10
10
  isShowSuccessMessage: false,
11
- selectDesignation: undefined,
12
- showDesignationPopup: undefined,
11
+ currentSection: undefined,
13
12
  });
14
13
  exports.getInitialState = getInitialState;
15
14
  var ActionTypes;
16
15
  (function (ActionTypes) {
17
16
  ActionTypes["UPLOAD_FILE"] = "UploadFile";
18
17
  ActionTypes["MOVE_FILE"] = "moveFile";
19
- ActionTypes["SELECT_DESIGNATION"] = "selectDesignation";
20
18
  ActionTypes["HANDLE_CANCEL_UPLOAD"] = "handleCancel";
21
19
  ActionTypes["HANDLE_UPLOAD_ACTION"] = "handleUpload";
22
20
  ActionTypes["HANDLE_FINISH_UPLOAD"] = "handleFinishUpload";
@@ -26,7 +24,7 @@ var ActionTypes;
26
24
  const reducer = (state, action) => {
27
25
  switch (action.type) {
28
26
  case ActionTypes.UPLOAD_FILE: {
29
- return Object.assign(Object.assign({}, state), { showDesignationPopup: action.sectionType, uploadedFile: action.uploadFile, selectDesignation: undefined });
27
+ return Object.assign(Object.assign({}, state), { uploadedFile: action.uploadFile, currentSection: action.sectionType });
30
28
  }
31
29
  case ActionTypes.MOVE_FILE: {
32
30
  return Object.assign(Object.assign({}, state), { moveToOtherState: {
@@ -34,17 +32,14 @@ const reducer = (state, action) => {
34
32
  name: action.name,
35
33
  }, successMessage: action.successMoveMessage, isShowSuccessMessage: false });
36
34
  }
37
- case ActionTypes.SELECT_DESIGNATION: {
38
- return Object.assign(Object.assign({}, state), { selectDesignation: action.designation });
39
- }
40
35
  case ActionTypes.HANDLE_UPLOAD_ACTION: {
41
- return Object.assign(Object.assign({}, state), { showDesignationPopup: undefined, isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
36
+ return Object.assign(Object.assign({}, state), { isUploadFile: true, isShowSuccessMessage: false, successMessage: '' });
42
37
  }
43
38
  case ActionTypes.HANDLE_CANCEL_UPLOAD: {
44
- return Object.assign(Object.assign({}, state), { showDesignationPopup: undefined });
39
+ return Object.assign({}, state);
45
40
  }
46
41
  case ActionTypes.HANDLE_FINISH_UPLOAD: {
47
- return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined, selectDesignation: undefined });
42
+ return Object.assign(Object.assign({}, state), { isUploadFile: false, uploadedFile: undefined });
48
43
  }
49
44
  case ActionTypes.HANDLE_SUCCESS_MESSAGE: {
50
45
  return Object.assign(Object.assign({}, state), { isShowSuccessMessage: true, successMessage: action.successMessage, fileUploadedSuccessfullySection: action.sectionType });
@@ -68,10 +63,6 @@ exports.actions = {
68
63
  HANDLE_CANCEL_UPLOAD: () => ({
69
64
  type: ActionTypes.HANDLE_CANCEL_UPLOAD,
70
65
  }),
71
- SELECT_DESIGNATION: (designation) => ({
72
- type: ActionTypes.SELECT_DESIGNATION,
73
- designation,
74
- }),
75
66
  MOVE_FILE: (attachmentId, typeId, name, successMoveMessage) => ({
76
67
  type: ActionTypes.MOVE_FILE,
77
68
  typeId,
@@ -26,11 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.FilesSection = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
28
  const AlertMessage_1 = require("../AlertMessage");
29
- const DragItemArea_1 = require("./DragItemArea");
30
29
  const FileManager_1 = require("./FileManager");
31
30
  const FileSectionUploadItem_1 = require("./FileSectionItem/FileSectionUploadItem");
32
31
  const FileSectionState_1 = require("./FileSectionState");
33
- const SelectDialogDesignation_1 = require("./SelectDialogDesignation");
34
32
  const UploadFileArea_1 = require("./UploadFileArea");
35
33
  const util_1 = require("./util");
36
34
  const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem, dispatch, state, }) => {
@@ -40,13 +38,12 @@ const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem,
40
38
  }
41
39
  const isSupplementFilesTab = fileSection === util_1.FileSectionType.Supplements;
42
40
  const isOtherFileTab = fileSection === util_1.FileSectionType.OtherFile;
43
- const handleUploadOtherFile = () => {
44
- dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
45
- state.uploadedFile &&
46
- state.selectDesignation !== undefined &&
47
- handleUpload(state.uploadedFile, (0, util_1.getDesignationName)(state.selectDesignation));
48
- };
49
41
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
42
+ (0, react_1.useEffect)(() => {
43
+ state.uploadedFile &&
44
+ fileSection === state.currentSection &&
45
+ handleUpload(state.uploadedFile);
46
+ }, [state.uploadedFile]);
50
47
  const handleSuccessMessage = () => {
51
48
  return (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.success, hideCloseButton: true, dismissButton: {
52
49
  text: 'OK',
@@ -56,19 +53,9 @@ const FilesSection = ({ enableDragAndDrop, handleUpload, fileSection, filesItem,
56
53
  return (react_1.default.createElement("div", null,
57
54
  (can === null || can === void 0 ? void 0 : can.uploadFile) && (react_1.default.createElement(react_1.default.Fragment, null,
58
55
  (isOtherFileTab || isSupplementFilesTab) && (react_1.default.createElement(UploadFileArea_1.UploadFileArea, { handleUploadFile: handleUpload, fileSection: fileSection, dispatch: dispatch })),
59
- state.isUploadFile &&
60
- state.uploadedFile &&
61
- state.selectDesignation !== undefined && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
56
+ state.isUploadFile && state.uploadedFile && (react_1.default.createElement(FileSectionUploadItem_1.FileSectionUploadItem, { fileName: state.uploadedFile.name, isLoading: state.isUploadFile })))),
62
57
  state.fileUploadedSuccessfullySection === fileSection &&
63
58
  handleSuccessMessage(),
64
- react_1.default.createElement(SelectDialogDesignation_1.SelectDialogDesignation, { isOpen: state.showDesignationPopup === fileSection, fileExtension: uploadedFileExtension, handleCancel: () => {
65
- dispatch(FileSectionState_1.actions.HANDLE_CANCEL_UPLOAD());
66
- }, uploadFileHandler: handleUploadOtherFile, dispatch: dispatch, fileSection: fileSection }),
67
- filesItem,
68
- (can === null || can === void 0 ? void 0 : can.changeDesignation) &&
69
- enableDragAndDrop &&
70
- (isSupplementFilesTab || isOtherFileTab) && (react_1.default.createElement(DragItemArea_1.DragItemArea, { text: isSupplementFilesTab
71
- ? 'Drag the items to place them in the text'
72
- : 'Drag the items to place in the Supplements section or in the text' }))));
59
+ filesItem));
73
60
  };
74
61
  exports.FilesSection = FilesSection;
@@ -78,7 +78,7 @@ const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdate
78
78
  (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
79
79
  handleUpdateInline(attachment.modelId, uploadAttachment), detachAttachmnetHandler: () => handleDetachFile &&
80
80
  attachment.modelId &&
81
- handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, designation: attachment.type.label, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
81
+ handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
82
82
  };
83
83
  const ElementItem = (0, styled_components_1.default)(FileSectionItem_1.Item) `
84
84
  display: flex;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.droppableSections = exports.getUploadFileDesignationList = exports.getDesignationByFileSection = exports.getDesignationName = exports.getDesignationActionsList = exports.generateAttachmentsTitles = exports.fileTypesWithIconMap = exports.fileTypesWithTitlesMap = exports.extensionsWithFileTypesMap = exports.designationWithAllowedDesignationsToTransitionMap = exports.designationWithAllowedMediaTypesMap = exports.designationWithReadableNamesMap = exports.namesWithDesignationMap = exports.designationWithFileSectionsMap = exports.Designation = exports.FileType = exports.FileSectionType = void 0;
6
+ exports.droppableSections = exports.generateAttachmentsTitles = exports.fileTypesWithIconMap = exports.fileTypesWithTitlesMap = exports.extensionsWithFileTypesMap = exports.FileType = exports.FileSectionType = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const audio_icon_1 = __importDefault(require("../icons/audio-icon"));
9
9
  const code_file_icon_1 = __importDefault(require("../icons/code-file-icon"));
@@ -38,245 +38,6 @@ var FileType;
38
38
  FileType[FileType["Figure"] = 10] = "Figure";
39
39
  FileType[FileType["GraphicalAbstract"] = 11] = "GraphicalAbstract";
40
40
  })(FileType = exports.FileType || (exports.FileType = {}));
41
- var Designation;
42
- (function (Designation) {
43
- Designation[Designation["Figure"] = 0] = "Figure";
44
- Designation[Designation["Table"] = 1] = "Table";
45
- Designation[Designation["Supplementary"] = 2] = "Supplementary";
46
- Designation[Designation["ConflictOfInterest"] = 3] = "ConflictOfInterest";
47
- Designation[Designation["Document"] = 4] = "Document";
48
- Designation[Designation["GraphicalAbstract"] = 5] = "GraphicalAbstract";
49
- Designation[Designation["GraphicalAbstractImage"] = 6] = "GraphicalAbstractImage";
50
- Designation[Designation["GraphicalAbstractText"] = 7] = "GraphicalAbstractText";
51
- Designation[Designation["Metadata"] = 8] = "Metadata";
52
- Designation[Designation["SubmissionFile"] = 9] = "SubmissionFile";
53
- Designation[Designation["SubmissionPdf"] = 10] = "SubmissionPdf";
54
- Designation[Designation["TitlePage"] = 11] = "TitlePage";
55
- Designation[Designation["Dataset"] = 12] = "Dataset";
56
- Designation[Designation["MainManuscript"] = 13] = "MainManuscript";
57
- })(Designation = exports.Designation || (exports.Designation = {}));
58
- exports.designationWithFileSectionsMap = new Map([
59
- [Designation.Figure, FileSectionType.OtherFile],
60
- [Designation.Table, FileSectionType.OtherFile],
61
- [Designation.Supplementary, FileSectionType.Supplements],
62
- [Designation.ConflictOfInterest, FileSectionType.OtherFile],
63
- [Designation.Document, FileSectionType.OtherFile],
64
- [Designation.GraphicalAbstract, FileSectionType.OtherFile],
65
- [Designation.GraphicalAbstractImage, FileSectionType.OtherFile],
66
- [Designation.GraphicalAbstractText, FileSectionType.OtherFile],
67
- [Designation.Metadata, FileSectionType.OtherFile],
68
- [Designation.SubmissionFile, FileSectionType.OtherFile],
69
- [Designation.SubmissionPdf, FileSectionType.OtherFile],
70
- [Designation.TitlePage, FileSectionType.OtherFile],
71
- [Designation.Dataset, FileSectionType.OtherFile],
72
- [Designation.MainManuscript, FileSectionType.OtherFile],
73
- ]);
74
- exports.namesWithDesignationMap = new Map([
75
- ['figure', Designation.Figure],
76
- ['table', Designation.Table],
77
- ['supplementary', Designation.Supplementary],
78
- ['conflict-of-interest', Designation.ConflictOfInterest],
79
- ['document', Designation.Document],
80
- ['graphical-abstract', Designation.GraphicalAbstract],
81
- ['graphical-abstract-image', Designation.GraphicalAbstractImage],
82
- ['graphical-abstract-text', Designation.GraphicalAbstractText],
83
- ['metadata', Designation.Metadata],
84
- ['submission-file', Designation.SubmissionFile],
85
- ['submission-pdf', Designation.SubmissionPdf],
86
- ['title-page', Designation.TitlePage],
87
- ['dataset', Designation.Dataset],
88
- ['main-manuscript', Designation.MainManuscript],
89
- ]);
90
- exports.designationWithReadableNamesMap = new Map([
91
- [Designation.Figure, 'Figure'],
92
- [Designation.Table, 'Table'],
93
- [Designation.Supplementary, 'Supplementary'],
94
- [Designation.ConflictOfInterest, 'Conflict Of Interest'],
95
- [Designation.Document, 'Document'],
96
- [Designation.GraphicalAbstract, 'Graphical Abstract'],
97
- [Designation.GraphicalAbstractImage, 'Graphical Abstract Image'],
98
- [Designation.GraphicalAbstractText, 'Graphical Abstract Text'],
99
- [Designation.Metadata, 'Metadata'],
100
- [Designation.SubmissionFile, 'Submission File'],
101
- [Designation.SubmissionPdf, 'Submission PDF'],
102
- [Designation.TitlePage, 'Title Page'],
103
- [Designation.Dataset, 'Dataset'],
104
- [Designation.MainManuscript, 'Main Manuscript'],
105
- ]);
106
- exports.designationWithAllowedMediaTypesMap = new Map([
107
- [Designation.Figure, ['jpeg', 'png', 'tiff', 'pdf', 'svg', 'ai']],
108
- [
109
- Designation.Table,
110
- ['xls', 'csv', 'tsv', 'tex', 'html', 'jpeg', 'jpg', 'png', 'gif', 'tiff'],
111
- ],
112
- [Designation.Supplementary, []],
113
- [Designation.ConflictOfInterest, ['doc', 'docx', 'pdf', 'tex', 'txt']],
114
- [Designation.Document, ['doc', 'docx', 'pdf', 'tex']],
115
- [Designation.GraphicalAbstract, ['doc', 'docx', 'pdf', 'tex', 'txt']],
116
- [
117
- Designation.GraphicalAbstractImage,
118
- ['jpeg', 'png', 'tiff', 'gif', 'pdf', 'eps'],
119
- ],
120
- [Designation.GraphicalAbstractText, ['doc', 'docx', 'pdf', 'tex', 'txt']],
121
- [Designation.Metadata, ['xml']],
122
- [Designation.SubmissionFile, []],
123
- [Designation.SubmissionPdf, ['pdf']],
124
- [Designation.TitlePage, ['doc', 'docx', 'pdf', 'tex', 'txt']],
125
- [Designation.Dataset, []],
126
- [Designation.MainManuscript, ['manuproj', 'docx']],
127
- ]);
128
- exports.designationWithAllowedDesignationsToTransitionMap = new Map([
129
- [
130
- Designation.Figure,
131
- [
132
- Designation.SubmissionFile,
133
- Designation.Supplementary,
134
- Designation.GraphicalAbstractImage,
135
- Designation.Dataset,
136
- ],
137
- ],
138
- [
139
- Designation.Table,
140
- [
141
- Designation.Supplementary,
142
- Designation.SubmissionFile,
143
- Designation.Dataset,
144
- ],
145
- ],
146
- [
147
- Designation.Supplementary,
148
- [
149
- Designation.Supplementary,
150
- Designation.SubmissionFile,
151
- Designation.Document,
152
- Designation.Figure,
153
- Designation.GraphicalAbstractImage,
154
- Designation.ConflictOfInterest,
155
- Designation.SubmissionPdf,
156
- Designation.Metadata,
157
- Designation.GraphicalAbstractText,
158
- Designation.GraphicalAbstract,
159
- Designation.TitlePage,
160
- Designation.Table,
161
- Designation.Dataset,
162
- ],
163
- ],
164
- [
165
- Designation.ConflictOfInterest,
166
- [
167
- Designation.ConflictOfInterest,
168
- Designation.Document,
169
- Designation.GraphicalAbstract,
170
- Designation.GraphicalAbstractImage,
171
- Designation.GraphicalAbstractText,
172
- Designation.Metadata,
173
- Designation.SubmissionFile,
174
- Designation.SubmissionPdf,
175
- Designation.Dataset,
176
- ],
177
- ],
178
- [
179
- Designation.Document,
180
- [
181
- Designation.ConflictOfInterest,
182
- Designation.Document,
183
- Designation.GraphicalAbstract,
184
- Designation.GraphicalAbstractImage,
185
- Designation.GraphicalAbstractText,
186
- Designation.Metadata,
187
- Designation.SubmissionFile,
188
- Designation.SubmissionPdf,
189
- Designation.MainManuscript,
190
- Designation.Dataset,
191
- ],
192
- ],
193
- [
194
- Designation.GraphicalAbstract,
195
- [
196
- Designation.Document,
197
- Designation.SubmissionFile,
198
- Designation.Supplementary,
199
- Designation.Dataset,
200
- ],
201
- ],
202
- [
203
- Designation.GraphicalAbstractImage,
204
- [
205
- Designation.Figure,
206
- Designation.SubmissionFile,
207
- Designation.Supplementary,
208
- Designation.Dataset,
209
- ],
210
- ],
211
- [
212
- Designation.GraphicalAbstractText,
213
- [
214
- Designation.Document,
215
- Designation.SubmissionFile,
216
- Designation.Supplementary,
217
- Designation.Dataset,
218
- ],
219
- ],
220
- [Designation.Metadata, [Designation.SubmissionFile, Designation.Dataset]],
221
- [
222
- Designation.SubmissionFile,
223
- [
224
- Designation.Supplementary,
225
- Designation.SubmissionFile,
226
- Designation.Document,
227
- Designation.Figure,
228
- Designation.GraphicalAbstractImage,
229
- Designation.ConflictOfInterest,
230
- Designation.SubmissionPdf,
231
- Designation.Metadata,
232
- Designation.GraphicalAbstractText,
233
- Designation.GraphicalAbstract,
234
- Designation.TitlePage,
235
- Designation.Table,
236
- Designation.Dataset,
237
- ],
238
- ],
239
- [
240
- Designation.SubmissionPdf,
241
- [
242
- Designation.ConflictOfInterest,
243
- Designation.Document,
244
- Designation.GraphicalAbstract,
245
- Designation.GraphicalAbstractImage,
246
- Designation.GraphicalAbstractText,
247
- Designation.Metadata,
248
- Designation.SubmissionFile,
249
- Designation.SubmissionPdf,
250
- Designation.Dataset,
251
- ],
252
- ],
253
- [
254
- Designation.TitlePage,
255
- [
256
- Designation.Document,
257
- Designation.SubmissionFile,
258
- Designation.Supplementary,
259
- Designation.Dataset,
260
- ],
261
- ],
262
- [
263
- Designation.Dataset,
264
- [
265
- Designation.Supplementary,
266
- Designation.SubmissionFile,
267
- Designation.Document,
268
- Designation.Figure,
269
- Designation.GraphicalAbstractImage,
270
- Designation.ConflictOfInterest,
271
- Designation.SubmissionPdf,
272
- Designation.Metadata,
273
- Designation.GraphicalAbstractText,
274
- Designation.GraphicalAbstract,
275
- Designation.TitlePage,
276
- Designation.Table,
277
- ],
278
- ],
279
- ]);
280
41
  exports.extensionsWithFileTypesMap = new Map([
281
42
  ['png', FileType.Image],
282
43
  ['jpg', FileType.Image],
@@ -385,89 +146,6 @@ const generateAttachmentsTitles = (externalFiles, fileSectionType) => {
385
146
  return result;
386
147
  };
387
148
  exports.generateAttachmentsTitles = generateAttachmentsTitles;
388
- const getDesignationActionsList = (designation, fileExtension) => {
389
- const allowedDesignationsToTransition = exports.designationWithAllowedDesignationsToTransitionMap.get(designation);
390
- if (allowedDesignationsToTransition) {
391
- if (designation === Designation.Supplementary ||
392
- designation === Designation.SubmissionFile) {
393
- return allowedDesignationsToTransition;
394
- }
395
- else {
396
- allowedDesignationsToTransition.filter((value) => {
397
- const allowedMediaTypes = exports.designationWithAllowedMediaTypesMap.get(value);
398
- if (allowedMediaTypes) {
399
- return allowedMediaTypes.indexOf(fileExtension) !== -1;
400
- }
401
- else {
402
- return false;
403
- }
404
- });
405
- return allowedDesignationsToTransition;
406
- }
407
- }
408
- else {
409
- return [];
410
- }
411
- };
412
- exports.getDesignationActionsList = getDesignationActionsList;
413
- const getDesignationName = (designation) => {
414
- let result = undefined;
415
- exports.namesWithDesignationMap.forEach((value, key, map) => {
416
- if (value === designation) {
417
- result = key;
418
- }
419
- });
420
- if (result == undefined) {
421
- result = '';
422
- }
423
- return result;
424
- };
425
- exports.getDesignationName = getDesignationName;
426
- const getDesignationByFileSection = (fileSectionType) => {
427
- const result = new Array();
428
- exports.designationWithFileSectionsMap.forEach((value, key, map) => {
429
- if (value === fileSectionType) {
430
- result.push(key);
431
- }
432
- });
433
- return result;
434
- };
435
- exports.getDesignationByFileSection = getDesignationByFileSection;
436
- const getUploadFileDesignationList = (fileExtension, fileSectionType, can) => {
437
- const result = new Array();
438
- const checkDesignation = (value) => {
439
- if (value === Designation.MainManuscript && !(can === null || can === void 0 ? void 0 : can.setMainManuscript)) {
440
- return;
441
- }
442
- const allowedExtension = exports.designationWithAllowedMediaTypesMap.get(value);
443
- const isAllowed = allowedExtension === null || allowedExtension === void 0 ? void 0 : allowedExtension.includes(fileExtension);
444
- if (isAllowed ||
445
- value === Designation.Supplementary ||
446
- value === Designation.SubmissionFile ||
447
- value === Designation.Dataset) {
448
- const label = exports.designationWithReadableNamesMap.get(value);
449
- if (label) {
450
- result.push({
451
- value: value,
452
- label: label,
453
- });
454
- }
455
- }
456
- };
457
- if (typeof fileSectionType === 'number') {
458
- const allowedDesignationByFileSection = (0, exports.getDesignationByFileSection)(fileSectionType);
459
- allowedDesignationByFileSection.forEach(checkDesignation);
460
- }
461
- else if (Array.isArray(fileSectionType)) {
462
- exports.designationWithFileSectionsMap.forEach((value, key) => {
463
- if (fileSectionType.includes(key)) {
464
- checkDesignation(key);
465
- }
466
- });
467
- }
468
- return result;
469
- };
470
- exports.getUploadFileDesignationList = getUploadFileDesignationList;
471
149
  exports.droppableSections = [
472
150
  FileSectionType.Supplements,
473
151
  FileSectionType.OtherFile,
package/dist/cjs/index.js CHANGED
@@ -32,7 +32,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
32
32
  return (mod && mod.__esModule) ? mod : { "default": mod };
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.SelectDialogDesignation = exports.errorsDecoder = exports.useDeepCompareCallback = exports.useDeepCompareMemo = exports.useFiles = void 0;
35
+ exports.errorsDecoder = exports.useDeepCompareCallback = exports.useDeepCompareMemo = exports.useFiles = void 0;
36
36
  __exportStar(require("./components/AffiliationsEditor"), exports);
37
37
  __exportStar(require("./components/AffiliationsList"), exports);
38
38
  __exportStar(require("./components/AuthorForm"), exports);
@@ -79,7 +79,5 @@ __exportStar(require("./lib/capabilities"), exports);
79
79
  var errors_decoder_1 = require("./lib/errors-decoder");
80
80
  Object.defineProperty(exports, "errorsDecoder", { enumerable: true, get: function () { return __importDefault(errors_decoder_1).default; } });
81
81
  __exportStar(require("./types"), exports);
82
- var SelectDialogDesignation_1 = require("./components/FileManager/SelectDialogDesignation");
83
- Object.defineProperty(exports, "SelectDialogDesignation", { enumerable: true, get: function () { return SelectDialogDesignation_1.SelectDialogDesignation; } });
84
82
  __exportStar(require("./components/LoadingOverlay"), exports);
85
83
  __exportStar(require("./components/EditorHeader/EditorHeader"), exports);