@manuscripts/style-guide 1.3.2-LEAN-2585-0 → 1.3.2-LEAN-2859-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/cjs/components/AuthorsList/Author.js +11 -19
  2. package/dist/cjs/components/AuthorsList/AuthorsList.js +1 -1
  3. package/dist/cjs/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  4. package/dist/cjs/components/FileManager/FileActions.js +135 -0
  5. package/dist/cjs/components/FileManager/FileContainer.js +38 -0
  6. package/dist/cjs/components/FileManager/FileCreatedDate.js +25 -0
  7. package/dist/cjs/components/FileManager/FileManager.js +14 -125
  8. package/dist/cjs/components/FileManager/FileManagerProvider.js +2 -7
  9. package/dist/cjs/components/FileManager/FileName.js +29 -0
  10. package/dist/cjs/components/FileManager/FileSectionAlert.js +170 -0
  11. package/dist/cjs/components/FileManager/FileTypeIcon.js +31 -0
  12. package/dist/cjs/components/FileManager/{UploadFileArea.js → FileUploader.js} +19 -12
  13. package/dist/cjs/components/FileManager/InlineFilesSection.js +63 -123
  14. package/dist/cjs/components/FileManager/OtherFilesSection.js +101 -0
  15. package/dist/cjs/components/FileManager/SupplementsSection.js +118 -0
  16. package/dist/cjs/components/FileManager/{TooltipDiv.js → Tooltip.js} +8 -3
  17. package/dist/cjs/components/FileManager/util.js +29 -66
  18. package/dist/cjs/components/icons/corrupted-file-icon.js +27 -0
  19. package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
  20. package/dist/cjs/hooks/use-files.js +13 -43
  21. package/dist/cjs/index.js +3 -4
  22. package/dist/cjs/lib/files.js +85 -0
  23. package/dist/es/components/AuthorsList/Author.js +11 -19
  24. package/dist/es/components/AuthorsList/AuthorsList.js +1 -1
  25. package/dist/es/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  26. package/dist/es/components/FileManager/FileActions.js +105 -0
  27. package/dist/es/components/FileManager/FileContainer.js +32 -0
  28. package/dist/es/components/FileManager/FileCreatedDate.js +18 -0
  29. package/dist/es/components/FileManager/FileManager.js +16 -124
  30. package/dist/es/components/FileManager/FileManagerProvider.js +3 -8
  31. package/dist/es/components/FileManager/FileName.js +22 -0
  32. package/dist/es/components/FileManager/FileSectionAlert.js +163 -0
  33. package/dist/es/components/FileManager/FileTypeIcon.js +24 -0
  34. package/dist/es/components/FileManager/{UploadFileArea.js → FileUploader.js} +17 -10
  35. package/dist/es/components/FileManager/InlineFilesSection.js +64 -124
  36. package/dist/es/components/FileManager/OtherFilesSection.js +74 -0
  37. package/dist/es/components/FileManager/SupplementsSection.js +91 -0
  38. package/dist/es/components/FileManager/{TooltipDiv.js → Tooltip.js} +7 -2
  39. package/dist/es/components/FileManager/util.js +28 -64
  40. package/dist/es/components/icons/corrupted-file-icon.js +22 -0
  41. package/dist/es/components/icons/document-icon-with-dot.js +1 -1
  42. package/dist/es/hooks/use-files.js +13 -40
  43. package/dist/es/index.js +2 -2
  44. package/dist/es/lib/files.js +79 -0
  45. package/dist/types/components/AuthorsList/Author.d.ts +0 -1
  46. package/dist/types/components/FileManager/FileActions.d.ts +19 -0
  47. package/dist/types/components/FileManager/FileContainer.d.ts +1 -0
  48. package/dist/types/components/FileManager/FileCreatedDate.d.ts +8 -0
  49. package/dist/types/components/FileManager/FileManager.d.ts +15 -8
  50. package/dist/types/components/FileManager/FileManagerProvider.d.ts +8 -18
  51. package/dist/types/components/FileManager/FileName.d.ts +6 -0
  52. package/dist/types/components/FileManager/FileSectionAlert.d.ts +13 -0
  53. package/dist/types/components/FileManager/{FileSectionItem/FileTypeIcon.d.ts → FileTypeIcon.d.ts} +2 -3
  54. package/dist/types/components/FileManager/FileUploader.d.ts +4 -0
  55. package/dist/types/components/FileManager/InlineFilesSection.d.ts +3 -19
  56. package/dist/types/components/FileManager/OtherFilesSection.d.ts +5 -0
  57. package/dist/types/components/FileManager/SupplementsSection.d.ts +5 -0
  58. package/dist/types/components/FileManager/Tooltip.d.ts +2 -0
  59. package/dist/types/components/FileManager/util.d.ts +3 -10
  60. package/dist/types/components/icons/corrupted-file-icon.d.ts +19 -0
  61. package/dist/types/hooks/use-files.d.ts +5 -6
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/lib/files.d.ts +25 -0
  64. package/package.json +1 -1
  65. package/dist/cjs/components/FileManager/ConfirmationPopUp.js +0 -90
  66. package/dist/cjs/components/FileManager/DragItemArea.js +0 -28
  67. package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -76
  68. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +0 -115
  69. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +0 -95
  70. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -37
  71. package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -53
  72. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +0 -92
  73. package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -120
  74. package/dist/cjs/components/FileManager/FileSectionState.js +0 -83
  75. package/dist/cjs/components/FileManager/FilesSection.js +0 -61
  76. package/dist/cjs/components/FileManager/ItemsAction.js +0 -48
  77. package/dist/cjs/lib/inlineFiles.js +0 -92
  78. package/dist/es/components/FileManager/ConfirmationPopUp.js +0 -62
  79. package/dist/es/components/FileManager/DragItemArea.js +0 -21
  80. package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -46
  81. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +0 -85
  82. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +0 -88
  83. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -30
  84. package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -46
  85. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +0 -65
  86. package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -113
  87. package/dist/es/components/FileManager/FileSectionState.js +0 -78
  88. package/dist/es/components/FileManager/FilesSection.js +0 -34
  89. package/dist/es/components/FileManager/ItemsAction.js +0 -42
  90. package/dist/es/lib/inlineFiles.js +0 -90
  91. package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +0 -12
  92. package/dist/types/components/FileManager/DragItemArea.d.ts +0 -4
  93. package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +0 -3
  94. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -19
  95. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +0 -38
  96. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -12
  97. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -21
  98. package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +0 -4
  99. package/dist/types/components/FileManager/FileSectionState.d.ts +0 -38
  100. package/dist/types/components/FileManager/FilesSection.d.ts +0 -12
  101. package/dist/types/components/FileManager/ItemsAction.d.ts +0 -4
  102. package/dist/types/components/FileManager/TooltipDiv.d.ts +0 -1
  103. package/dist/types/components/FileManager/UploadFileArea.d.ts +0 -9
  104. package/dist/types/lib/inlineFiles.d.ts +0 -11
  105. /package/dist/types/components/FileManager/{FileSectionItem/DragLayer.d.ts → DragLayer.d.ts} +0 -0
@@ -1,48 +0,0 @@
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.ActionsSeparator = exports.ActionsLabel = exports.ActionsItem = exports.ActionsBox = void 0;
7
- const styled_components_1 = __importDefault(require("styled-components"));
8
- exports.ActionsBox = styled_components_1.default.ul `
9
- border: 1px solid #e2e2e2;
10
- box-sizing: border-box;
11
- box-shadow: 0px 4px 9px rgba(0, 0, 0, 0.3);
12
- border-radius: 4px;
13
- min-width: 180px;
14
- background: ${(props) => props.theme.colors.background.primary};
15
- margin: 0;
16
- padding: 8px 0;
17
- z-index: 999;
18
- text-align: left;
19
- list-style-type: none;
20
- `;
21
- exports.ActionsItem = styled_components_1.default.li `
22
- font-family: ${(props) => props.theme.font.family.Lato};
23
- cursor: pointer;
24
- font-size: 16px;
25
- line-height: 24px;
26
- color: ${(props) => props.theme.colors.text.primary};
27
- list-style: none;
28
- padding: 8px 16px;
29
- &:hover,
30
- &:focus {
31
- background: #f2fbfc;
32
- }
33
- `;
34
- exports.ActionsLabel = styled_components_1.default.li `
35
- font-family: ${(props) => props.theme.font.family.Lato};
36
- font-size: 12px;
37
- line-height: 16px;
38
- color: ${(props) => props.theme.colors.text.onLight};
39
- list-style: none;
40
- padding: 8px 16px;
41
- cursor: default;
42
- `;
43
- exports.ActionsSeparator = styled_components_1.default.li `
44
- height: 1px;
45
- background: ${(props) => props.theme.colors.background.tertiary};
46
- margin: 8px 0;
47
- cursor: default;
48
- `;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const json_schema_1 = require("@manuscripts/json-schema");
4
- const transform_1 = require("@manuscripts/transform");
5
- const util_1 = require("../components/FileManager/util");
6
- const getFigureData = (element, modelMap, attachmentsMap) => {
7
- const attachments = [];
8
- element.containedObjectIDs.map((id) => {
9
- const object = modelMap.get(id);
10
- if (object && object.objectType === json_schema_1.ObjectTypes.Figure) {
11
- const figure = object;
12
- if (figure.src) {
13
- const attachment = attachmentsMap.get(figure.src.replace('attachment:', ''));
14
- if (attachment) {
15
- attachment.modelId = id;
16
- attachments.push(attachment);
17
- }
18
- }
19
- }
20
- });
21
- return {
22
- id: element._id,
23
- attachments,
24
- };
25
- };
26
- exports.default = (modelMap, attachments) => {
27
- const files = [];
28
- const attachmentsMap = new Map(attachments.map((attachment) => [attachment.id, attachment]));
29
- const { graphicalAbstractFigureId, figureElement } = getAuxiliaryObjects(modelMap);
30
- if (graphicalAbstractFigureId) {
31
- const element = modelMap.get(graphicalAbstractFigureId);
32
- files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Graphical Abstract`, type: util_1.FileType.GraphicalAbstract }));
33
- }
34
- figureElement.map((id, index) => {
35
- const element = modelMap.get(id);
36
- files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Figure ${index + 1}`, type: util_1.FileType.Figure }));
37
- });
38
- return files;
39
- };
40
- const getAuxiliaryObjects = (modelMap) => {
41
- var _a, _b;
42
- let graphicalAbstractFigureId, figureElementIds = [];
43
- const tableElementIds = [], orderObjects = {};
44
- for (const model of modelMap.values()) {
45
- switch (model.objectType) {
46
- case json_schema_1.ObjectTypes.Section: {
47
- const section = model;
48
- if (section.category === 'MPSectionCategory:abstract-graphical') {
49
- graphicalAbstractFigureId = (_a = section.elementIDs) === null || _a === void 0 ? void 0 : _a.find((id) => {
50
- const obj = modelMap.get(id);
51
- return obj && (0, transform_1.hasObjectType)(json_schema_1.ObjectTypes.FigureElement)(obj);
52
- });
53
- }
54
- else {
55
- (_b = section.elementIDs) === null || _b === void 0 ? void 0 : _b.map((elementId) => {
56
- const element = modelMap.get(elementId);
57
- if (!element) {
58
- return;
59
- }
60
- switch (element.objectType) {
61
- case json_schema_1.ObjectTypes.FigureElement:
62
- figureElementIds.push(element._id);
63
- break;
64
- case json_schema_1.ObjectTypes.TableElement:
65
- tableElementIds.push(element._id);
66
- break;
67
- }
68
- });
69
- }
70
- break;
71
- }
72
- case json_schema_1.ObjectTypes.ElementsOrder: {
73
- const elementsOrder = model;
74
- orderObjects[elementsOrder.elementType] = elementsOrder;
75
- }
76
- }
77
- }
78
- if (graphicalAbstractFigureId) {
79
- figureElementIds = figureElementIds.filter((id) => id != graphicalAbstractFigureId);
80
- }
81
- return {
82
- graphicalAbstractFigureId,
83
- figureElement: sortAuxiliaryObject(figureElementIds, orderObjects[json_schema_1.ObjectTypes.FigureElement]),
84
- tableElement: sortAuxiliaryObject(tableElementIds, orderObjects[json_schema_1.ObjectTypes.TableElement]),
85
- };
86
- };
87
- const sortAuxiliaryObject = (auxiliaryObjectIds, orderObject) => {
88
- if (!orderObject) {
89
- return auxiliaryObjectIds;
90
- }
91
- return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
92
- };
@@ -1,62 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { ObjectTypes } from '@manuscripts/json-schema';
11
- import { buildSupplementaryMaterial, getModelsByType, } from '@manuscripts/transform';
12
- import React, { useCallback, useContext } from 'react';
13
- import { Category, Dialog } from '../Dialog';
14
- import { FileManagerContext } from './FileManagerProvider';
15
- import { actions } from './FileSectionState';
16
- import { FileSectionType } from './util';
17
- export const ConfirmationPopUp = ({ popupHeader, popUpMessage, isOpen, handleClose, handleMove }) => {
18
- return (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: popupHeader, message: popUpMessage, actions: {
19
- primary: {
20
- action: handleMove,
21
- title: 'Move',
22
- },
23
- secondary: {
24
- action: handleClose,
25
- title: 'Cancel',
26
- },
27
- } }));
28
- };
29
- export const MoveFilePopup = ({ dispatch, }) => {
30
- const { moveFilePopup: { isOpen, fileSection, attachmentId }, saveModel, deleteModel, modelMap, getAttachments, setMoveFilePopupData, } = useContext(FileManagerContext);
31
- const isSupplement = fileSection === FileSectionType.Supplements;
32
- const message = {
33
- popupHeader: `Are you sure you want to move this file to “${(!isSupplement && 'Supplements') || 'Other files'}”?`,
34
- popUpMessage: `The file will be removed from the “${(isSupplement && 'Supplements') || 'Other files'}” and added to “${(!isSupplement && 'Supplements') || 'Other files'}”.`,
35
- };
36
- const closePopup = useCallback(() => setMoveFilePopupData({
37
- isOpen: false,
38
- fileSection: fileSection,
39
- }), [fileSection, setMoveFilePopupData]);
40
- const showSuccessMessage = useCallback(() => dispatch(actions.HANDLE_SUCCESS_MESSAGE(`File moved to ${(isSupplement && 'Other files') || 'Supplements'}.`, fileSection)), [dispatch, fileSection, isSupplement]);
41
- const moveToSupplement = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
42
- closePopup();
43
- const attachment = getAttachments().find(({ id }) => id === attachmentId);
44
- if (!attachment) {
45
- return;
46
- }
47
- const model = buildSupplementaryMaterial(attachment.name, `attachment:${attachment.id}`);
48
- yield saveModel(Object.assign(Object.assign({}, model), { title: attachment.name, href: `attachment:${attachment.id}` }));
49
- showSuccessMessage();
50
- }), [getAttachments, saveModel, showSuccessMessage, closePopup, attachmentId]);
51
- const moveSupplementToOtherFiles = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
52
- closePopup();
53
- const model = getModelsByType(modelMap, ObjectTypes.Supplement).find(({ href }) => (href === null || href === void 0 ? void 0 : href.replace('attachment:', '')) === attachmentId);
54
- if (!model) {
55
- return;
56
- }
57
- yield deleteModel(model._id);
58
- showSuccessMessage();
59
- }), [attachmentId, closePopup, deleteModel, modelMap, showSuccessMessage]);
60
- return (React.createElement(React.Fragment, null,
61
- React.createElement(ConfirmationPopUp, Object.assign({ isOpen: isOpen }, message, { handleMove: () => (!isSupplement && moveToSupplement()) || moveSupplementToOtherFiles(), handleClose: closePopup }))));
62
- };
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import DragAndDropFileIcon from '../icons/drag-drop-file-icon';
4
- export const DragItemArea = ({ text }) => {
5
- return (React.createElement(Container, null,
6
- React.createElement("div", null,
7
- React.createElement(DragAndDropFileIcon, null)),
8
- text));
9
- };
10
- const Container = styled.div `
11
- display: flex;
12
- flex-direction: column;
13
- align-items: center;
14
- justify-content: center;
15
- font-size: 14px;
16
- line-height: 24px;
17
- font-family: ${(props) => props.theme.font.family.Lato};
18
- color: ${(props) => props.theme.colors.text.onLight};
19
- padding: 32px 0;
20
- text-align: center;
21
- `;
@@ -1,46 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
- import { useDrag } from 'react-dnd';
3
- import { getEmptyImage } from 'react-dnd-html5-backend';
4
- import styled from 'styled-components';
5
- import { FileSectionItem } from './FileSectionItem';
6
- const itemPlaceHolderDraggingStyle = {
7
- background: '#FAFAFA',
8
- borderRadius: '6px',
9
- height: '104px',
10
- };
11
- const draggingItemStyle = {
12
- opacity: 0,
13
- height: 0,
14
- };
15
- export const DraggableFileSectionItem = (props) => {
16
- const [draggingItemWidth, setDraggingItemWidth] = useState('100%');
17
- const itemPlaceholderRef = useRef();
18
- const [{ isDragging }, dragRef, preview] = useDrag({
19
- item: {
20
- id: props.title,
21
- title: props.title,
22
- externalFile: props.externalFile,
23
- showAttachmentName: props.showAttachmentName,
24
- width: draggingItemWidth,
25
- type: 'FileSectionItem',
26
- },
27
- collect: (monitor) => ({
28
- isDragging: monitor.isDragging(),
29
- }),
30
- });
31
- useEffect(() => {
32
- if (itemPlaceholderRef && itemPlaceholderRef.current) {
33
- setDraggingItemWidth(itemPlaceholderRef.current.offsetWidth + 'px');
34
- }
35
- }, []);
36
- useEffect(() => {
37
- preview(getEmptyImage());
38
- }, [preview]);
39
- return (React.createElement(ItemDraggingPlaceholderContainer, { style: isDragging ? itemPlaceHolderDraggingStyle : {}, ref: itemPlaceholderRef },
40
- React.createElement(FileSectionItem, Object.assign({ style: isDragging ? draggingItemStyle : {}, dragRef: dragRef }, props))));
41
- };
42
- const ItemDraggingPlaceholderContainer = styled.div `
43
- background: ${(props) => props.theme.colors.background.primary};
44
- width: 100%;
45
- position: relative;
46
- `;
@@ -1,85 +0,0 @@
1
- import { format } from 'date-fns';
2
- import React, { useContext } from 'react';
3
- import ReactTooltip from 'react-tooltip';
4
- import styled from 'styled-components';
5
- import { PermissionsContext } from '../FileManager';
6
- import { TooltipDiv } from '../TooltipDiv';
7
- export const FileInfo = ({ showAttachmentName, title, fileAttachmentName, fileExtension, attachmentId, dispatch, fileCreatedDate, }) => {
8
- const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
9
- const can = useContext(PermissionsContext);
10
- return (React.createElement(FileInfoContainer, null,
11
- React.createElement(FileNameTitleContainer, null,
12
- React.createElement(FileTitle, null,
13
- !showAttachmentName ? fileName : title,
14
- showAttachmentName && ':'),
15
- showAttachmentName && (React.createElement(FileNameContainer, null,
16
- React.createElement(FileName, null, fileName),
17
- React.createElement("div", null,
18
- ".",
19
- fileExtension))),
20
- fileCreatedDate && (React.createElement(FileDateContainer, { "data-tip": "tooltip-content" },
21
- React.createElement(FileDate, null, format(new Date(fileCreatedDate), 'M/d/yy, HH:mm')),
22
- React.createElement(TooltipDiv, null,
23
- React.createElement(ReactTooltip, { place: "bottom", offset: { top: 0 }, effect: "solid", className: "tooltip" },
24
- React.createElement("div", null, "File uploaded"))))))));
25
- };
26
- export const FileDateContainer = styled.div `
27
- line-height: 20px;
28
- overflow: hidden;
29
- width: 100%;
30
- display: none;
31
- justify-content: flex-end;
32
- `;
33
- export const FileInfoContainer = styled.div `
34
- margin-left: 8px;
35
- overflow: hidden;
36
- display: flex;
37
- flex-direction: column;
38
- justify-content: center;
39
- align-items: start;
40
- width: 100%;
41
-
42
- &:hover ${FileDateContainer} {
43
- display: flex;
44
- }
45
- `;
46
- export const FileNameTitleContainer = styled.div `
47
- display: flex;
48
- width: 100%;
49
- align-items: baseline;
50
- `;
51
- export const FileTitle = styled.div `
52
- color: ${(props) => props.theme.colors.text.primary};
53
- font-weight: bold;
54
- font-size: 16px;
55
- line-height: 20px;
56
- margin-right: 4px;
57
- white-space: nowrap;
58
- `;
59
- export const FileNameContainer = styled.div `
60
- display: flex;
61
- color: ${(props) => props.theme.colors.text.primary};
62
- font-weight: normal;
63
- font-size: 16px;
64
- line-height: 20px;
65
- overflow: hidden;
66
- width: 100%;
67
- `;
68
- export const FileName = styled.div `
69
- text-overflow: ellipsis;
70
- white-space: nowrap;
71
- overflow: hidden;
72
- width: 50px;
73
- `;
74
- export const FileDate = styled.div `
75
- font-size: font-size: ${(props) => props.theme.font.size.small};
76
- `;
77
- export const FileDescription = styled.div `
78
- color: ${(props) => props.theme.colors.text.secondary};
79
- font-size: 14px;
80
- line-height: 20px;
81
- text-overflow: ellipsis;
82
- white-space: nowrap;
83
- overflow: hidden;
84
- width: 100%;
85
- `;
@@ -1,88 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import { useDropdown } from '../../../hooks/use-dropdown';
4
- import { DropdownContainer } from '../../Dropdown';
5
- import { CloseOIcon } from '../../icons/';
6
- import DotsIcon from '../../icons/dots-icon';
7
- import { FileInfo } from './FileInfo';
8
- import { FileTypeIcon } from './FileTypeIcon';
9
- import { ItemActions } from './ItemActions';
10
- export const FileSectionItem = ({ fileSection, externalFile, title, showAttachmentName = false, showReplaceAction = true, handleDownload, handleReplace, handleSupplementReplace, dispatch, dragRef, className, style, onClose, isEditor, }) => {
11
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
12
- const fileExtension = externalFile.name.substring(externalFile.name.lastIndexOf('.') + 1);
13
- const isMainManuscript = externalFile.type.label === 'main-manuscript';
14
- const isSelected = externalFile.id == window.location.hash.substr(1);
15
- return (React.createElement(Item, { ref: dragRef, className: className, style: style },
16
- React.createElement(ItemContainer, { onClick: () => {
17
- window.location.hash =
18
- isEditor && !isSelected ? `#${externalFile.id}` : '#';
19
- if (isSelected) {
20
- window.location.hash = `#${externalFile.id}`;
21
- }
22
- } },
23
- React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
24
- React.createElement(FileInfo, { fileExtension: fileExtension, fileCreatedDate: externalFile.createdDate, showAttachmentName: showAttachmentName, fileAttachmentName: externalFile.name, title: title, attachmentId: externalFile.id, dispatch: dispatch })),
25
- onClose && (React.createElement(IconCloseButton, { onClick: (e) => {
26
- e.preventDefault();
27
- onClose();
28
- } },
29
- React.createElement(CloseOIcon, { color: '#6E6E6E' }))),
30
- handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
31
- React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", "aria-label": "Download or Replace", "aria-pressed": isOpen },
32
- React.createElement(DotsIcon, null)),
33
- isOpen && (React.createElement(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 }))))));
34
- };
35
- const IconCloseButton = styled.button `
36
- border: none;
37
- background: transparent;
38
- cursor: pointer;
39
- padding: 0 8px;
40
- align-self: flex-start;
41
- &:hover {
42
- opacity: 0.5;
43
- }
44
- `;
45
- export const ActionsIcon = styled.button `
46
- visibility: hidden;
47
- border: none;
48
- background: transparent;
49
- cursor: pointer;
50
- padding: 0 8px;
51
- &:focus {
52
- outline: none;
53
- }
54
- &:hover svg circle {
55
- fill: #1a9bc7;
56
- }
57
- `;
58
- export const Item = styled.div `
59
- display: flex;
60
- font-family: ${(props) => props.theme.font.family.Lato};
61
- padding: 20px 15px;
62
- cursor: pointer;
63
- box-sizing: border-box;
64
- width: 100%;
65
- position: relative;
66
-
67
- &:hover,
68
- &:focus {
69
- background: #f2fbfc;
70
- }
71
-
72
- &:hover ${ActionsIcon} {
73
- visibility: visible;
74
- }
75
-
76
- ${DropdownContainer} {
77
- position: absolute;
78
- top: 24px;
79
- right: 0;
80
- margin-right: 8px;
81
- }
82
- `;
83
- export const ItemContainer = styled.div `
84
- display: flex;
85
- min-width: calc(100% - 8px);
86
- padding-right: 4px;
87
- box-sizing: border-box;
88
- `;
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import { FileInfoContainer, FileName, FileNameContainer } from './FileInfo';
4
- import { Item, ItemContainer } from './FileSectionItem';
5
- import { FileTypeIcon } from './FileTypeIcon';
6
- import { ProgressBarUploadItem } from './ProgressBarUploadItem';
7
- export const FileSectionUploadItem = ({ fileName, isLoading, dragRef, className, style, }) => {
8
- const fileExtension = fileName.substring(fileName.lastIndexOf('.') + 1);
9
- fileName = fileName.substring(0, fileName.lastIndexOf('.'));
10
- return (React.createElement(Item, { ref: dragRef, className: className, style: style },
11
- React.createElement(UploadItemContainer, null,
12
- React.createElement(FileTypeIcon, { withDot: false }),
13
- React.createElement(FileInfoContainer, null,
14
- React.createElement(FileNameContainer, null,
15
- React.createElement(FileName, null, fileName),
16
- React.createElement("div", null,
17
- ".",
18
- fileExtension)),
19
- isLoading && React.createElement(ProgressBarUploadItem, null)))));
20
- };
21
- export const UploadItemContainer = styled(ItemContainer) `
22
- min-width: calc(100% - 16px);
23
- `;
24
- export const ProgressBar = styled.div `
25
- background: #1a9bc7;
26
- opacity: 0.7;
27
- border-radius: 8px 0 0 8px;
28
- width: 20%;
29
- height: 100%;
30
- `;
@@ -1,46 +0,0 @@
1
- import React from 'react';
2
- import ReactTooltip from 'react-tooltip';
3
- import styled from 'styled-components';
4
- import DocumentIconWithDot from '../../icons/document-icon-with-dot';
5
- import UnknownFormatFileIcon from '../../icons/unknown-format-file-icon';
6
- import { TooltipDiv } from '../TooltipDiv';
7
- import { extensionsWithFileTypesMap, fileTypesWithIconMap } from '../util';
8
- export const FileTypeIcon = ({ withDot, fileExtension, alt }) => {
9
- let fileIcon = React.createElement(UnknownFormatFileIcon, null);
10
- if (withDot) {
11
- return (React.createElement(Container, null,
12
- React.createElement(DocumentIconWithDot, null),
13
- React.createElement(TooltipDiv, null,
14
- React.createElement(ReactTooltip, { id: "dot", place: "bottom", effect: "float", className: "tooltip" },
15
- React.createElement("div", null, "Main manuscript. Only one file per submission")))));
16
- }
17
- if (fileExtension) {
18
- const fileType = extensionsWithFileTypesMap.get(fileExtension.toLowerCase());
19
- fileIcon = fileTypesWithIconMap.get(fileType);
20
- }
21
- return React.createElement(Container, null, fileIcon);
22
- };
23
- const Container = styled.div `
24
- width: 40px;
25
- min-width: 40px;
26
- height: 40px;
27
- display: flex;
28
- justify-content: center;
29
- align-items: center;
30
- box-sizing: border-box;
31
- border-radius: 4px;
32
- position: relative;
33
- `;
34
- const Img = styled.img `
35
- width: 100%;
36
- height: 100%;
37
- border-radius: 4px;
38
- `;
39
- const VideoIconContainer = styled.div `
40
- width: 100%;
41
- height: 100%;
42
- position: absolute;
43
- display: flex;
44
- align-items: center;
45
- justify-content: center;
46
- `;
@@ -1,65 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import React, { useContext, useRef, useState, } from 'react';
11
- import { DropdownList } from '../../Dropdown';
12
- import { PermissionsContext } from '../FileManager';
13
- import { FileManagerContext } from '../FileManagerProvider';
14
- import { actions } from '../FileSectionState';
15
- import { ActionsItem } from '../ItemsAction';
16
- import { FileSectionType } from '../util';
17
- export const ItemActions = ({ fileSection, isMainManuscript, downloadAttachmentHandler, replaceAttachmentHandler, handleSupplementReplace, detachAttachmnetHandler, handleUpdateInline, attachmentId, fileName, publicUrl, hideActionList, dispatch, dropDownClassName, showReplaceAction, }) => {
18
- const can = useContext(PermissionsContext);
19
- const { setMoveFilePopupData } = useContext(FileManagerContext);
20
- const canBeReplaced = showReplaceAction == undefined || showReplaceAction;
21
- const fileInputRef = useRef(null);
22
- const [selectedFile, setSelectedFile] = useState();
23
- const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
24
- if (event && event.target && event.target.files) {
25
- const file = event.target.files[0];
26
- setSelectedFile(file);
27
- if (dispatch) {
28
- dispatch(actions.HANDLE_UPLOAD_ACTION());
29
- }
30
- const result = yield replaceAttachmentHandler(attachmentId, fileName, file);
31
- if (fileSection === FileSectionType.Supplements &&
32
- typeof result === 'object' &&
33
- handleSupplementReplace) {
34
- handleSupplementReplace(result, attachmentId);
35
- }
36
- if (typeof result === 'object' && handleUpdateInline) {
37
- handleUpdateInline(result);
38
- }
39
- if (dispatch) {
40
- dispatch(actions.HANDLE_FINISH_UPLOAD());
41
- }
42
- hideActionList();
43
- }
44
- });
45
- const openFileDialog = () => {
46
- if (fileInputRef && fileInputRef.current) {
47
- fileInputRef.current.click();
48
- }
49
- };
50
- return (React.createElement(DropdownList, { direction: 'right', className: dropDownClassName, width: 200, height: 120, top: 5, onClick: hideActionList },
51
- React.createElement(ActionsItem, { onClick: () => {
52
- publicUrl !== undefined ? downloadAttachmentHandler(publicUrl) : {};
53
- } }, "Download"),
54
- (can === null || can === void 0 ? void 0 : can.replaceFile) && canBeReplaced && (React.createElement(React.Fragment, null,
55
- React.createElement(ActionsItem, { onClick: openFileDialog }, "Replace"),
56
- React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: (e) => handleChange(e), value: '' }))),
57
- (can === null || can === void 0 ? void 0 : can.editArticle) && detachAttachmnetHandler && (React.createElement(ActionsItem, { onClick: () => detachAttachmnetHandler() }, "Detach")),
58
- !isMainManuscript &&
59
- fileSection !== FileSectionType.Inline &&
60
- (can === null || can === void 0 ? void 0 : can.moveFile) && (React.createElement(ActionsItem, { onClick: () => setMoveFilePopupData({ isOpen: true, attachmentId, fileSection }) },
61
- "Move to",
62
- ' ',
63
- (fileSection === FileSectionType.OtherFile && 'Supplements') ||
64
- 'Other files'))));
65
- };