@manuscripts/style-guide 1.3.2-LEAN-2859-3 → 1.3.2-LEAN-2880-2

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 (102) hide show
  1. package/dist/cjs/components/FileManager/ConfirmationPopUp.js +90 -0
  2. package/dist/cjs/components/FileManager/DragItemArea.js +28 -0
  3. package/dist/cjs/components/FileManager/FileManager.js +125 -14
  4. package/dist/cjs/components/FileManager/FileManagerProvider.js +7 -2
  5. package/dist/cjs/components/FileManager/{DragLayer.js → FileSectionItem/DragLayer.js} +10 -12
  6. package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +76 -0
  7. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +115 -0
  8. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +95 -0
  9. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +37 -0
  10. package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +53 -0
  11. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +92 -0
  12. package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +120 -0
  13. package/dist/cjs/components/FileManager/FileSectionState.js +83 -0
  14. package/dist/cjs/components/FileManager/FilesSection.js +61 -0
  15. package/dist/cjs/components/FileManager/InlineFilesSection.js +123 -64
  16. package/dist/cjs/components/FileManager/ItemsAction.js +48 -0
  17. package/dist/cjs/components/FileManager/{Tooltip.js → TooltipDiv.js} +3 -8
  18. package/dist/cjs/components/FileManager/{FileUploader.js → UploadFileArea.js} +12 -19
  19. package/dist/cjs/components/FileManager/util.js +67 -52
  20. package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
  21. package/dist/cjs/hooks/use-deep-compare.js +2 -2
  22. package/dist/cjs/hooks/use-files.js +43 -29
  23. package/dist/cjs/index.js +4 -3
  24. package/dist/cjs/lib/inlineFiles.js +92 -0
  25. package/dist/es/components/FileManager/ConfirmationPopUp.js +62 -0
  26. package/dist/es/components/FileManager/DragItemArea.js +21 -0
  27. package/dist/es/components/FileManager/FileManager.js +124 -16
  28. package/dist/es/components/FileManager/FileManagerProvider.js +8 -3
  29. package/dist/es/components/FileManager/{DragLayer.js → FileSectionItem/DragLayer.js} +10 -12
  30. package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +46 -0
  31. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +85 -0
  32. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +88 -0
  33. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +30 -0
  34. package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +46 -0
  35. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +65 -0
  36. package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +113 -0
  37. package/dist/es/components/FileManager/FileSectionState.js +78 -0
  38. package/dist/es/components/FileManager/FilesSection.js +34 -0
  39. package/dist/es/components/FileManager/InlineFilesSection.js +124 -65
  40. package/dist/es/components/FileManager/ItemsAction.js +42 -0
  41. package/dist/es/components/FileManager/{Tooltip.js → TooltipDiv.js} +2 -7
  42. package/dist/es/components/FileManager/{FileUploader.js → UploadFileArea.js} +10 -17
  43. package/dist/es/components/FileManager/util.js +65 -47
  44. package/dist/es/components/icons/document-icon-with-dot.js +1 -1
  45. package/dist/es/hooks/use-deep-compare.js +2 -2
  46. package/dist/es/hooks/use-files.js +40 -29
  47. package/dist/es/index.js +2 -2
  48. package/dist/es/lib/inlineFiles.js +90 -0
  49. package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +12 -0
  50. package/dist/types/components/FileManager/DragItemArea.d.ts +4 -0
  51. package/dist/types/components/FileManager/FileManager.d.ts +8 -17
  52. package/dist/types/components/FileManager/FileManagerProvider.d.ts +18 -8
  53. package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +3 -0
  54. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +19 -0
  55. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +38 -0
  56. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +12 -0
  57. package/dist/types/components/FileManager/{FileTypeIcon.d.ts → FileSectionItem/FileTypeIcon.d.ts} +3 -2
  58. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +21 -0
  59. package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +4 -0
  60. package/dist/types/components/FileManager/FileSectionState.d.ts +38 -0
  61. package/dist/types/components/FileManager/FilesSection.d.ts +12 -0
  62. package/dist/types/components/FileManager/InlineFilesSection.d.ts +19 -3
  63. package/dist/types/components/FileManager/ItemsAction.d.ts +4 -0
  64. package/dist/types/components/FileManager/TooltipDiv.d.ts +1 -0
  65. package/dist/types/components/FileManager/UploadFileArea.d.ts +9 -0
  66. package/dist/types/components/FileManager/util.d.ts +12 -8
  67. package/dist/types/hooks/use-files.d.ts +6 -4
  68. package/dist/types/index.d.ts +2 -2
  69. package/dist/types/lib/inlineFiles.d.ts +11 -0
  70. package/package.json +2 -2
  71. package/dist/cjs/components/FileManager/FileActions.js +0 -134
  72. package/dist/cjs/components/FileManager/FileContainer.js +0 -39
  73. package/dist/cjs/components/FileManager/FileCreatedDate.js +0 -25
  74. package/dist/cjs/components/FileManager/FileName.js +0 -27
  75. package/dist/cjs/components/FileManager/FileSectionAlert.js +0 -170
  76. package/dist/cjs/components/FileManager/FileTypeIcon.js +0 -22
  77. package/dist/cjs/components/FileManager/OtherFilesSection.js +0 -101
  78. package/dist/cjs/components/FileManager/SupplementsSection.js +0 -118
  79. package/dist/cjs/components/icons/corrupted-file-icon.js +0 -27
  80. package/dist/cjs/lib/files.js +0 -85
  81. package/dist/es/components/FileManager/FileActions.js +0 -104
  82. package/dist/es/components/FileManager/FileContainer.js +0 -33
  83. package/dist/es/components/FileManager/FileCreatedDate.js +0 -18
  84. package/dist/es/components/FileManager/FileName.js +0 -20
  85. package/dist/es/components/FileManager/FileSectionAlert.js +0 -163
  86. package/dist/es/components/FileManager/FileTypeIcon.js +0 -15
  87. package/dist/es/components/FileManager/OtherFilesSection.js +0 -74
  88. package/dist/es/components/FileManager/SupplementsSection.js +0 -91
  89. package/dist/es/components/icons/corrupted-file-icon.js +0 -22
  90. package/dist/es/lib/files.js +0 -79
  91. package/dist/types/components/FileManager/FileActions.d.ts +0 -19
  92. package/dist/types/components/FileManager/FileContainer.d.ts +0 -1
  93. package/dist/types/components/FileManager/FileCreatedDate.d.ts +0 -8
  94. package/dist/types/components/FileManager/FileName.d.ts +0 -6
  95. package/dist/types/components/FileManager/FileSectionAlert.d.ts +0 -13
  96. package/dist/types/components/FileManager/FileUploader.d.ts +0 -4
  97. package/dist/types/components/FileManager/OtherFilesSection.d.ts +0 -5
  98. package/dist/types/components/FileManager/SupplementsSection.d.ts +0 -5
  99. package/dist/types/components/FileManager/Tooltip.d.ts +0 -2
  100. package/dist/types/components/icons/corrupted-file-icon.d.ts +0 -19
  101. package/dist/types/lib/files.d.ts +0 -24
  102. /package/dist/types/components/FileManager/{DragLayer.d.ts → FileSectionItem/DragLayer.d.ts} +0 -0
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.MoveFilePopup = exports.ConfirmationPopUp = void 0;
36
+ const json_schema_1 = require("@manuscripts/json-schema");
37
+ const transform_1 = require("@manuscripts/transform");
38
+ const react_1 = __importStar(require("react"));
39
+ const Dialog_1 = require("../Dialog");
40
+ const FileManagerProvider_1 = require("./FileManagerProvider");
41
+ const FileSectionState_1 = require("./FileSectionState");
42
+ const util_1 = require("./util");
43
+ const ConfirmationPopUp = ({ popupHeader, popUpMessage, isOpen, handleClose, handleMove }) => {
44
+ return (react_1.default.createElement(Dialog_1.Dialog, { isOpen: isOpen, category: Dialog_1.Category.confirmation, header: popupHeader, message: popUpMessage, actions: {
45
+ primary: {
46
+ action: handleMove,
47
+ title: 'Move',
48
+ },
49
+ secondary: {
50
+ action: handleClose,
51
+ title: 'Cancel',
52
+ },
53
+ } }));
54
+ };
55
+ exports.ConfirmationPopUp = ConfirmationPopUp;
56
+ const MoveFilePopup = ({ dispatch, }) => {
57
+ const { moveFilePopup: { isOpen, fileSection, attachmentId }, saveModel, deleteModel, modelMap, getAttachments, setMoveFilePopupData, } = (0, react_1.useContext)(FileManagerProvider_1.FileManagerContext);
58
+ const isSupplement = fileSection === util_1.FileSectionType.Supplements;
59
+ const message = {
60
+ popupHeader: `Are you sure you want to move this file to “${(!isSupplement && 'Supplements') || 'Other files'}”?`,
61
+ popUpMessage: `The file will be removed from the “${(isSupplement && 'Supplements') || 'Other files'}” and added to “${(!isSupplement && 'Supplements') || 'Other files'}”.`,
62
+ };
63
+ const closePopup = (0, react_1.useCallback)(() => setMoveFilePopupData({
64
+ isOpen: false,
65
+ fileSection: fileSection,
66
+ }), [fileSection, setMoveFilePopupData]);
67
+ const showSuccessMessage = (0, react_1.useCallback)(() => dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE(`File moved to ${(isSupplement && 'Other files') || 'Supplements'}.`, fileSection)), [dispatch, fileSection, isSupplement]);
68
+ const moveToSupplement = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
69
+ closePopup();
70
+ const attachment = getAttachments().find(({ id }) => id === attachmentId);
71
+ if (!attachment) {
72
+ return;
73
+ }
74
+ const model = (0, transform_1.buildSupplementaryMaterial)(attachment.name, `attachment:${attachment.id}`);
75
+ yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
76
+ showSuccessMessage();
77
+ }), [getAttachments, saveModel, showSuccessMessage, closePopup, attachmentId]);
78
+ const moveSupplementToOtherFiles = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
79
+ closePopup();
80
+ const model = (0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === attachmentId);
81
+ if (!model) {
82
+ return;
83
+ }
84
+ yield deleteModel(model._id);
85
+ showSuccessMessage();
86
+ }), [attachmentId, closePopup, deleteModel, modelMap, showSuccessMessage]);
87
+ return (react_1.default.createElement(react_1.default.Fragment, null,
88
+ react_1.default.createElement(exports.ConfirmationPopUp, Object.assign({ isOpen: isOpen }, message, { handleMove: () => (!isSupplement && moveToSupplement()) || moveSupplementToOtherFiles(), handleClose: closePopup }))));
89
+ };
90
+ exports.MoveFilePopup = MoveFilePopup;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DragItemArea = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const drag_drop_file_icon_1 = __importDefault(require("../icons/drag-drop-file-icon"));
10
+ const DragItemArea = ({ text }) => {
11
+ return (react_1.default.createElement(Container, null,
12
+ react_1.default.createElement("div", null,
13
+ react_1.default.createElement(drag_drop_file_icon_1.default, null)),
14
+ text));
15
+ };
16
+ exports.DragItemArea = DragItemArea;
17
+ const Container = styled_components_1.default.div `
18
+ display: flex;
19
+ flex-direction: column;
20
+ align-items: center;
21
+ justify-content: center;
22
+ font-size: 14px;
23
+ line-height: 24px;
24
+ font-family: ${(props) => props.theme.font.family.Lato};
25
+ color: ${(props) => props.theme.colors.text.onLight};
26
+ padding: 32px 0;
27
+ text-align: center;
28
+ `;
@@ -22,39 +22,150 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
25
37
  Object.defineProperty(exports, "__esModule", { value: true });
26
38
  exports.FileManager = exports.PermissionsContext = void 0;
39
+ const json_schema_1 = require("@manuscripts/json-schema");
40
+ const transform_1 = require("@manuscripts/transform");
27
41
  const react_1 = __importStar(require("react"));
42
+ const react_tooltip_1 = __importDefault(require("react-tooltip"));
28
43
  const index_1 = require("../../index");
29
44
  const Inspector_1 = require("../Inspector");
30
45
  const InspectorSection_1 = require("../InspectorSection");
31
- const DragLayer_1 = require("./DragLayer");
46
+ const ConfirmationPopUp_1 = require("./ConfirmationPopUp");
32
47
  const FileManagerProvider_1 = require("./FileManagerProvider");
48
+ const DraggableFileSectionItem_1 = require("./FileSectionItem/DraggableFileSectionItem");
49
+ const DragLayer_1 = require("./FileSectionItem/DragLayer");
50
+ const FileSectionItem_1 = require("./FileSectionItem/FileSectionItem");
51
+ const FileSectionState_1 = require("./FileSectionState");
52
+ const FilesSection_1 = require("./FilesSection");
33
53
  const InlineFilesSection_1 = require("./InlineFilesSection");
34
- const OtherFilesSection_1 = require("./OtherFilesSection");
35
- const SupplementsSection_1 = require("./SupplementsSection");
36
- const Tooltip_1 = require("./Tooltip");
54
+ const TooltipDiv_1 = require("./TooltipDiv");
55
+ const util_1 = require("./util");
37
56
  exports.PermissionsContext = (0, react_1.createContext)(null);
38
- const FileManager = ({ files, fileManagement, modelMap, saveModel, deleteModel, enableDragAndDrop, can, }) => {
39
- const { inlineFiles, supplements, otherFiles } = (0, index_1.useFiles)(modelMap, files);
40
- return (react_1.default.createElement(FileManagerProvider_1.FileManagerProvider, { saveModel: saveModel, deleteModel: deleteModel, modelMap: modelMap, fileManagement: fileManagement },
57
+ const FileManager = ({ modelMap, saveModel, deleteModel, enableDragAndDrop, can, fileManagement: { getAttachments, replace, upload }, addAttachmentToState, }) => {
58
+ const [state, dispatch] = (0, react_1.useReducer)(FileSectionState_1.reducer, (0, FileSectionState_1.getInitialState)());
59
+ const handleReplaceFile = (0, react_1.useCallback)((attachmentId, name, file) => __awaiter(void 0, void 0, void 0, function* () {
60
+ dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
61
+ const res = yield replace(attachmentId, name, file);
62
+ dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
63
+ if (res) {
64
+ dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.'));
65
+ }
66
+ return res;
67
+ }), [replace]);
68
+ const handleUploadFile = (0, react_1.useCallback)((file) => __awaiter(void 0, void 0, void 0, function* () {
69
+ dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
70
+ const res = yield upload(file);
71
+ dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
72
+ if (res) {
73
+ dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.', index_1.FileSectionType.OtherFile));
74
+ }
75
+ return res;
76
+ }), [upload]);
77
+ const handleUploadFileWithSupplement = (0, react_1.useCallback)((file) => __awaiter(void 0, void 0, void 0, function* () {
78
+ dispatch(FileSectionState_1.actions.HANDLE_UPLOAD_ACTION());
79
+ const response = yield upload(file);
80
+ if (typeof response === 'object') {
81
+ const { id, name } = response;
82
+ yield saveModel((0, transform_1.buildSupplementaryMaterial)(name, `attachment:${id}`));
83
+ }
84
+ dispatch(FileSectionState_1.actions.HANDLE_FINISH_UPLOAD());
85
+ if (response) {
86
+ dispatch(FileSectionState_1.actions.HANDLE_SUCCESS_MESSAGE('File uploaded successfully.', index_1.FileSectionType.Supplements));
87
+ }
88
+ return response;
89
+ }), [upload, saveModel]);
90
+ const handleSupplementReplace = (0, react_1.useCallback)((attachment, oldAttachmentId) => __awaiter(void 0, void 0, void 0, function* () {
91
+ 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);
92
+ yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
93
+ }), [modelMap, saveModel]);
94
+ const handleDownload = (0, react_1.useCallback)((url) => {
95
+ window.location.assign(url);
96
+ }, []);
97
+ const handleUpdateInline = (0, react_1.useCallback)((modelId, attachment) => __awaiter(void 0, void 0, void 0, function* () {
98
+ const figureModel = modelMap.get(modelId);
99
+ figureModel.src = `attachment:${attachment.id}`;
100
+ if (addAttachmentToState) {
101
+ addAttachmentToState(Object.assign({}, attachment));
102
+ }
103
+ yield saveModel(figureModel);
104
+ }), [modelMap, saveModel, addAttachmentToState]);
105
+ const attachments = getAttachments();
106
+ const { otherFiles, supplementFiles, inlineFiles } = (0, index_1.useFiles)(modelMap, attachments);
107
+ const handleDetachFile = (attachmentId, modelId) => {
108
+ const model = modelMap.get(modelId);
109
+ if (model) {
110
+ saveModel(Object.assign(Object.assign({}, model), { src: '' }));
111
+ }
112
+ };
113
+ const getFileSectionExternalFile = (fileSection) => {
114
+ const isSupplementOrOtherFilesTab = fileSection === index_1.FileSectionType.Supplements ||
115
+ fileSection === index_1.FileSectionType.OtherFile;
116
+ const isOtherFilesTab = fileSection === index_1.FileSectionType.OtherFile;
117
+ const itemsData = (fileSection === index_1.FileSectionType.Supplements && supplementFiles) ||
118
+ otherFiles;
119
+ const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
120
+ const filesItems = itemsDataWithTitle.map((element) => {
121
+ const itemProps = {
122
+ fileSection,
123
+ externalFile: element.externalFile,
124
+ title: element.title,
125
+ showAttachmentName: isSupplementOrOtherFilesTab,
126
+ showReplaceAction: !isOtherFilesTab,
127
+ handleDownload,
128
+ handleReplace: handleReplaceFile,
129
+ handleSupplementReplace,
130
+ dispatch: dispatch,
131
+ };
132
+ if (enableDragAndDrop && isSupplementOrOtherFilesTab) {
133
+ return (react_1.default.createElement(DraggableFileSectionItem_1.DraggableFileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id })));
134
+ }
135
+ else {
136
+ return (react_1.default.createElement(FileSectionItem_1.FileSectionItem, Object.assign({}, itemProps, { key: element.externalFile.id, isEditor: enableDragAndDrop })));
137
+ }
138
+ });
139
+ return filesItems;
140
+ };
141
+ return (react_1.default.createElement(FileManagerProvider_1.FileManagerProvider, { saveModel: saveModel, modelMap: modelMap, deleteModel: deleteModel, getAttachments: getAttachments },
41
142
  react_1.default.createElement(DragLayer_1.DragLayer, null),
42
143
  react_1.default.createElement(exports.PermissionsContext.Provider, { value: can },
43
- react_1.default.createElement(InspectorSection_1.InspectorSection, { title: 'Files', contentStyles: { margin: '24px 16px' } },
144
+ react_1.default.createElement(InspectorSection_1.InspectorSection, { title: 'Files', contentStyles: { margin: '24px' } },
44
145
  react_1.default.createElement(Inspector_1.InspectorTabs, { defaultIndex: 0, style: { overflow: 'visible' } },
45
146
  react_1.default.createElement(Inspector_1.InspectorTabList, null,
46
147
  react_1.default.createElement(Inspector_1.InspectorTab, { "data-for": "inline", "data-tip": true }, "Inline files"),
47
- react_1.default.createElement(Tooltip_1.Tooltip, { id: "inline", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" }, "Files that can be found inline in the manuscript."),
148
+ react_1.default.createElement(TooltipDiv_1.TooltipDiv, null,
149
+ react_1.default.createElement(react_tooltip_1.default, { id: "inline", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" },
150
+ react_1.default.createElement("div", null,
151
+ "Files that can be found inline ",
152
+ react_1.default.createElement("br", null),
153
+ " in the manuscript."))),
48
154
  react_1.default.createElement(Inspector_1.InspectorTab, { "data-for": "supplements", "data-tip": true }, "Supplements"),
49
- react_1.default.createElement(Tooltip_1.Tooltip, { id: "supplements", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" }, "Files that were marked as supplements."),
155
+ react_1.default.createElement(TooltipDiv_1.TooltipDiv, null,
156
+ react_1.default.createElement(react_tooltip_1.default, { id: "supplements", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" },
157
+ react_1.default.createElement("div", null, "Files that were marked as supplementaries."))),
50
158
  react_1.default.createElement(Inspector_1.InspectorTab, { "data-for": "other", "data-tip": true }, "Other files"),
51
- react_1.default.createElement(Tooltip_1.Tooltip, { id: "other", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" }, "Files excluded from the final submission.")),
159
+ react_1.default.createElement(TooltipDiv_1.TooltipDiv, null,
160
+ react_1.default.createElement(react_tooltip_1.default, { id: "other", place: "bottom", offset: { bottom: -11 }, effect: "solid", className: "tooltip" },
161
+ react_1.default.createElement("div", null, "Files excluded from the final submission.")))),
52
162
  react_1.default.createElement(Inspector_1.InspectorTabPanels, { style: { overflowY: 'visible', position: 'relative' } },
53
163
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
54
- react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { elements: inlineFiles, isEditor: enableDragAndDrop })),
164
+ react_1.default.createElement(InlineFilesSection_1.InlineFilesSection, { inlineFiles: inlineFiles, handleReplace: replace, handleDownload: handleDownload, handleUpdateInline: handleUpdateInline, handleDetachFile: handleDetachFile, isEditor: enableDragAndDrop, dispatch: dispatch })),
55
165
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
56
- react_1.default.createElement(SupplementsSection_1.SupplementsSection, { supplements: supplements })),
166
+ react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFileWithSupplement, fileSection: index_1.FileSectionType.Supplements, filesItem: getFileSectionExternalFile(index_1.FileSectionType.Supplements), state: state, dispatch: dispatch })),
57
167
  react_1.default.createElement(Inspector_1.InspectorTabPanel, null,
58
- react_1.default.createElement(OtherFilesSection_1.OtherFilesSection, { files: otherFiles }))))))));
168
+ react_1.default.createElement(FilesSection_1.FilesSection, { enableDragAndDrop: enableDragAndDrop, handleUpload: handleUploadFile, fileSection: index_1.FileSectionType.OtherFile, filesItem: getFileSectionExternalFile(index_1.FileSectionType.OtherFile), state: state, dispatch: dispatch }))))),
169
+ react_1.default.createElement(ConfirmationPopUp_1.MoveFilePopup, { dispatch: dispatch }))));
59
170
  };
60
171
  exports.FileManager = FileManager;
@@ -27,13 +27,18 @@ exports.FileManagerProvider = exports.FileManagerContext = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
28
  exports.FileManagerContext = (0, react_1.createContext)({
29
29
  saveModel: () => '',
30
+ moveFilePopup: { isOpen: false },
31
+ setMoveFilePopupData: () => '',
30
32
  });
31
- const FileManagerProvider = ({ children, saveModel, deleteModel, modelMap, fileManagement }) => {
33
+ const FileManagerProvider = ({ children, saveModel, deleteModel, modelMap, getAttachments }) => {
34
+ const [moveFilePopup, setMoveFilePopupData] = (0, react_1.useState)({ isOpen: false });
32
35
  return (react_1.default.createElement(exports.FileManagerContext.Provider, { value: {
33
36
  saveModel,
34
37
  deleteModel,
35
38
  modelMap,
36
- fileManagement,
39
+ getAttachments,
40
+ moveFilePopup,
41
+ setMoveFilePopupData,
37
42
  } }, children));
38
43
  };
39
44
  exports.FileManagerProvider = FileManagerProvider;
@@ -30,9 +30,7 @@ exports.DragLayer = void 0;
30
30
  const react_1 = __importStar(require("react"));
31
31
  const react_dnd_1 = require("react-dnd");
32
32
  const styled_components_1 = __importDefault(require("styled-components"));
33
- const FileContainer_1 = require("./FileContainer");
34
- const FileCreatedDate_1 = require("./FileCreatedDate");
35
- const FileName_1 = require("./FileName");
33
+ const FileSectionItem_1 = require("./FileSectionItem");
36
34
  function getItemStyles(initialOffset, currentOffset) {
37
35
  if (!initialOffset || !currentOffset) {
38
36
  return {
@@ -56,10 +54,8 @@ const DragLayer = () => {
56
54
  }));
57
55
  const renderItem = (0, react_1.useCallback)(() => {
58
56
  switch (itemType) {
59
- case 'file':
60
- return (react_1.default.createElement(DraggableFileContainer, null,
61
- react_1.default.createElement(FileName_1.FileName, { file: item.file }),
62
- item.file.createdDate && react_1.default.createElement(FileCreatedDate_1.FileCreatedDate, { file: item.file })));
57
+ case 'FileSectionItem':
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 } }));
63
59
  default:
64
60
  return null;
65
61
  }
@@ -67,7 +63,8 @@ const DragLayer = () => {
67
63
  if (!isDragging) {
68
64
  return null;
69
65
  }
70
- return (react_1.default.createElement(Container, { style: getItemStyles(initialOffset, currentOffset) }, renderItem()));
66
+ return (react_1.default.createElement(Container, null,
67
+ react_1.default.createElement("div", { style: getItemStyles(initialOffset, currentOffset) }, renderItem())));
71
68
  };
72
69
  exports.DragLayer = DragLayer;
73
70
  const Container = styled_components_1.default.div `
@@ -76,12 +73,13 @@ const Container = styled_components_1.default.div `
76
73
  z-index: 999;
77
74
  left: 0;
78
75
  top: 0;
79
- max-width: 400px;
76
+ width: 100%;
77
+ height: 100%;
80
78
  `;
81
- const DraggableFileContainer = (0, styled_components_1.default)(FileContainer_1.FileContainer) `
79
+ const CustomFileSectionItem = react_1.default.memo((0, styled_components_1.default)(FileSectionItem_1.FileSectionItem) `
82
80
  padding: 16px 32px;
83
81
  background: #f2fbfc;
84
82
  border: 1px solid #bce7f6;
85
- box-shadow: 0 4px 9px rgba(0, 0, 0, 0.3);
83
+ box-shadow: 0px 4px 9px rgba(0, 0, 0, 0.3);
86
84
  border-radius: 6px;
87
- `;
85
+ `);
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.DraggableFileSectionItem = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const react_dnd_1 = require("react-dnd");
32
+ const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
33
+ const styled_components_1 = __importDefault(require("styled-components"));
34
+ const FileSectionItem_1 = require("./FileSectionItem");
35
+ const itemPlaceHolderDraggingStyle = {
36
+ background: '#FAFAFA',
37
+ borderRadius: '6px',
38
+ height: '104px',
39
+ };
40
+ const draggingItemStyle = {
41
+ opacity: 0,
42
+ height: 0,
43
+ };
44
+ const DraggableFileSectionItem = (props) => {
45
+ const [draggingItemWidth, setDraggingItemWidth] = (0, react_1.useState)('100%');
46
+ const itemPlaceholderRef = (0, react_1.useRef)();
47
+ const [{ isDragging }, dragRef, preview] = (0, react_dnd_1.useDrag)({
48
+ item: {
49
+ id: props.title,
50
+ title: props.title,
51
+ externalFile: props.externalFile,
52
+ showAttachmentName: props.showAttachmentName,
53
+ width: draggingItemWidth,
54
+ type: 'FileSectionItem',
55
+ },
56
+ collect: (monitor) => ({
57
+ isDragging: monitor.isDragging(),
58
+ }),
59
+ });
60
+ (0, react_1.useEffect)(() => {
61
+ if (itemPlaceholderRef && itemPlaceholderRef.current) {
62
+ setDraggingItemWidth(itemPlaceholderRef.current.offsetWidth + 'px');
63
+ }
64
+ }, []);
65
+ (0, react_1.useEffect)(() => {
66
+ preview((0, react_dnd_html5_backend_1.getEmptyImage)());
67
+ }, [preview]);
68
+ return (react_1.default.createElement(ItemDraggingPlaceholderContainer, { style: isDragging ? itemPlaceHolderDraggingStyle : {}, ref: itemPlaceholderRef },
69
+ react_1.default.createElement(FileSectionItem_1.FileSectionItem, Object.assign({ style: isDragging ? draggingItemStyle : {}, dragRef: dragRef }, props))));
70
+ };
71
+ exports.DraggableFileSectionItem = DraggableFileSectionItem;
72
+ const ItemDraggingPlaceholderContainer = styled_components_1.default.div `
73
+ background: ${(props) => props.theme.colors.background.primary};
74
+ width: 100%;
75
+ position: relative;
76
+ `;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.FileDescription = exports.FileDate = exports.FileName = exports.FileNameContainer = exports.FileTitle = exports.FileNameTitleContainer = exports.FileInfoContainer = exports.FileDateContainer = exports.FileInfo = void 0;
30
+ const date_fns_1 = require("date-fns");
31
+ const react_1 = __importStar(require("react"));
32
+ const react_tooltip_1 = __importDefault(require("react-tooltip"));
33
+ const styled_components_1 = __importDefault(require("styled-components"));
34
+ const FileManager_1 = require("../FileManager");
35
+ const TooltipDiv_1 = require("../TooltipDiv");
36
+ const FileInfo = ({ showAttachmentName, title, fileAttachmentName, fileExtension, attachmentId, dispatch, fileCreatedDate, }) => {
37
+ const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
38
+ const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
39
+ return (react_1.default.createElement(exports.FileInfoContainer, null,
40
+ react_1.default.createElement(exports.FileNameTitleContainer, null,
41
+ react_1.default.createElement(exports.FileTitle, null,
42
+ !showAttachmentName ? fileName : title,
43
+ showAttachmentName && ':'),
44
+ showAttachmentName && (react_1.default.createElement(exports.FileNameContainer, null,
45
+ react_1.default.createElement(exports.FileName, null, fileName),
46
+ react_1.default.createElement("div", null,
47
+ ".",
48
+ fileExtension))),
49
+ fileCreatedDate && (react_1.default.createElement(exports.FileDateContainer, { "data-tip": "tooltip-content" },
50
+ react_1.default.createElement(exports.FileDate, null, (0, date_fns_1.format)(new Date(fileCreatedDate), 'M/d/yy, HH:mm')),
51
+ react_1.default.createElement(TooltipDiv_1.TooltipDiv, null,
52
+ react_1.default.createElement(react_tooltip_1.default, { place: "bottom", offset: { top: 0 }, effect: "solid", className: "tooltip" },
53
+ react_1.default.createElement("div", null, "File uploaded"))))))));
54
+ };
55
+ exports.FileInfo = FileInfo;
56
+ exports.FileDateContainer = styled_components_1.default.div `
57
+ line-height: 20px;
58
+ overflow: hidden;
59
+ width: 100%;
60
+ display: none;
61
+ justify-content: flex-end;
62
+ `;
63
+ exports.FileInfoContainer = styled_components_1.default.div `
64
+ margin-left: 8px;
65
+ overflow: hidden;
66
+ display: flex;
67
+ flex-direction: column;
68
+ justify-content: center;
69
+ align-items: start;
70
+ width: 100%;
71
+
72
+ &:hover ${exports.FileDateContainer} {
73
+ display: flex;
74
+ }
75
+ `;
76
+ exports.FileNameTitleContainer = styled_components_1.default.div `
77
+ display: flex;
78
+ width: 100%;
79
+ align-items: baseline;
80
+ `;
81
+ exports.FileTitle = styled_components_1.default.div `
82
+ color: ${(props) => props.theme.colors.text.primary};
83
+ font-weight: bold;
84
+ font-size: 16px;
85
+ line-height: 20px;
86
+ margin-right: 4px;
87
+ white-space: nowrap;
88
+ `;
89
+ exports.FileNameContainer = styled_components_1.default.div `
90
+ display: flex;
91
+ color: ${(props) => props.theme.colors.text.primary};
92
+ font-weight: normal;
93
+ font-size: 16px;
94
+ line-height: 20px;
95
+ overflow: hidden;
96
+ width: 100%;
97
+ `;
98
+ exports.FileName = styled_components_1.default.div `
99
+ text-overflow: ellipsis;
100
+ white-space: nowrap;
101
+ overflow: hidden;
102
+ width: 50px;
103
+ `;
104
+ exports.FileDate = styled_components_1.default.div `
105
+ font-size: font-size: ${(props) => props.theme.font.size.small};
106
+ `;
107
+ exports.FileDescription = styled_components_1.default.div `
108
+ color: ${(props) => props.theme.colors.text.secondary};
109
+ font-size: 14px;
110
+ line-height: 20px;
111
+ text-overflow: ellipsis;
112
+ white-space: nowrap;
113
+ overflow: hidden;
114
+ width: 100%;
115
+ `;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ItemContainer = exports.Item = exports.ActionsIcon = exports.FileSectionItem = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const use_dropdown_1 = require("../../../hooks/use-dropdown");
10
+ const Dropdown_1 = require("../../Dropdown");
11
+ const icons_1 = require("../../icons/");
12
+ const dots_icon_1 = __importDefault(require("../../icons/dots-icon"));
13
+ const FileInfo_1 = require("./FileInfo");
14
+ const FileTypeIcon_1 = require("./FileTypeIcon");
15
+ const ItemActions_1 = require("./ItemActions");
16
+ const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showReplaceAction = true, handleDownload, handleReplace, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
17
+ const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
18
+ const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
19
+ const isMainManuscript = externalFile.type.label === 'main-manuscript';
20
+ const isSelected = externalFile.id == window.location.hash.substr(1);
21
+ return (react_1.default.createElement(exports.Item, { ref: dragRef, className: className, style: style },
22
+ react_1.default.createElement(exports.ItemContainer, { onClick: () => {
23
+ window.location.hash =
24
+ isEditor && !isSelected ? `#${externalFile.id}` : '#';
25
+ if (isSelected) {
26
+ window.location.hash = `#${externalFile.id}`;
27
+ }
28
+ } },
29
+ react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
30
+ react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, fileCreatedDate: externalFile.createdDate, showAttachmentName: showAttachmentName, fileAttachmentName: externalFile.name, title: title, attachmentId: externalFile.id, dispatch: dispatch })),
31
+ onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
32
+ e.preventDefault();
33
+ onClose();
34
+ } },
35
+ react_1.default.createElement(icons_1.CloseOIcon, { color: '#6E6E6E' }))),
36
+ handleDownload && handleReplace && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
37
+ react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
38
+ react_1.default.createElement(dots_icon_1.default, null)),
39
+ isOpen && (react_1.default.createElement(ItemActions_1.ItemActions, { fileSection: fileSection, isMainManuscript: isMainManuscript, replaceAttachmentHandler: handleReplace, showReplaceAction: showReplaceAction, downloadAttachmentHandler: handleDownload, handleSupplementReplace: handleSupplementReplace, attachmentId: externalFile.id, fileName: externalFile.name, publicUrl: externalFile.link, hideActionList: toggleOpen, dispatch: dispatch }))))));
40
+ };
41
+ exports.FileSectionItem = FileSectionItem;
42
+ const IconCloseButton = styled_components_1.default.button `
43
+ border: none;
44
+ background: transparent;
45
+ cursor: pointer;
46
+ padding: 0 8px;
47
+ align-self: flex-start;
48
+ &:hover {
49
+ opacity: 0.5;
50
+ }
51
+ `;
52
+ exports.ActionsIcon = styled_components_1.default.button `
53
+ visibility: hidden;
54
+ border: none;
55
+ background: transparent;
56
+ cursor: pointer;
57
+ padding: 0 8px;
58
+ &:focus {
59
+ outline: none;
60
+ }
61
+ &:hover svg circle {
62
+ fill: #1a9bc7;
63
+ }
64
+ `;
65
+ exports.Item = styled_components_1.default.div `
66
+ display: flex;
67
+ font-family: ${(props) => props.theme.font.family.Lato};
68
+ padding: 20px 15px;
69
+ cursor: pointer;
70
+ box-sizing: border-box;
71
+ width: 100%;
72
+ position: relative;
73
+
74
+ &:hover,
75
+ &:focus {
76
+ background: #f2fbfc;
77
+ }
78
+
79
+ &:hover ${exports.ActionsIcon} {
80
+ visibility: visible;
81
+ }
82
+
83
+ ${Dropdown_1.DropdownContainer} {
84
+ position: absolute;
85
+ top: 24px;
86
+ right: 0;
87
+ margin-right: 8px;
88
+ }
89
+ `;
90
+ exports.ItemContainer = styled_components_1.default.div `
91
+ display: flex;
92
+ min-width: calc(100% - 8px);
93
+ padding-right: 4px;
94
+ box-sizing: border-box;
95
+ `;