@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
@@ -1,104 +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 styled from 'styled-components';
12
- import { useDropdown } from '../../hooks/use-dropdown';
13
- import { Category, Dialog } from '../Dialog';
14
- import { DropdownContainer, DropdownList } from '../Dropdown';
15
- import DotsIcon from '../icons/dots-icon';
16
- import { PermissionsContext } from './FileManager';
17
- export const FileActions = ({ sectionType, handleDownload, handleReplace, handleDetach, move, className, }) => {
18
- const can = useContext(PermissionsContext);
19
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
20
- const [isMoveDialogOpen, setMoveDialogOpen] = useState(false);
21
- const showDownload = (can === null || can === void 0 ? void 0 : can.downloadFiles) && handleDownload;
22
- const showReplace = (can === null || can === void 0 ? void 0 : can.replaceFile) && handleReplace;
23
- const showDetach = (can === null || can === void 0 ? void 0 : can.editArticle) && handleDetach;
24
- const showMove = (can === null || can === void 0 ? void 0 : can.editArticle) && move;
25
- const show = showDownload || showReplace || showDetach || showMove;
26
- const fileInputRef = useRef(null);
27
- const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
28
- if (handleReplace && event && event.target && event.target.files) {
29
- const file = event.target.files[0];
30
- yield handleReplace(file);
31
- }
32
- });
33
- const openFileDialog = () => {
34
- if (fileInputRef && fileInputRef.current) {
35
- fileInputRef.current.click();
36
- }
37
- };
38
- return show ? (React.createElement(DropdownContainer, { ref: wrapperRef },
39
- React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: "show-on-hover", "aria-label": "Actions", "aria-pressed": isOpen },
40
- React.createElement(DotsIcon, null)),
41
- isOpen && (React.createElement(FileActionDropdownList, { direction: "right", className: className, width: 192, top: 5, onClick: toggleOpen },
42
- showDownload && (React.createElement(FileAction, { onClick: handleDownload }, "Download")),
43
- showReplace && (React.createElement(React.Fragment, null,
44
- React.createElement(FileAction, { onClick: openFileDialog }, "Replace"),
45
- React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange }))),
46
- showDetach && React.createElement(FileAction, { onClick: handleDetach }, "Detach"),
47
- showMove && (React.createElement(FileAction, { onClick: () => setMoveDialogOpen(true) },
48
- "Move to ",
49
- move.sectionType)))),
50
- showMove && (React.createElement(MoveFileConfirmationDialog, { isOpen: isMoveDialogOpen, close: () => setMoveDialogOpen(false), source: sectionType, target: move.sectionType, handleMove: move.handler })))) : (React.createElement(React.Fragment, null));
51
- };
52
- const MoveFileConfirmationDialog = ({ isOpen, close, source, target, handleMove }) => {
53
- const header = `Are you sure you want to move this file to “${target}”?`;
54
- const message = `The file will be removed from “${source}” and added to “${target}”.`;
55
- const handleConfirm = () => __awaiter(void 0, void 0, void 0, function* () {
56
- yield handleMove();
57
- close();
58
- });
59
- return (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: header, message: message, actions: {
60
- primary: {
61
- action: handleConfirm,
62
- title: 'Move',
63
- },
64
- secondary: {
65
- action: () => close(),
66
- title: 'Cancel',
67
- },
68
- } }));
69
- };
70
- export const ActionsIcon = styled.button `
71
- border: none;
72
- background: transparent;
73
- cursor: pointer;
74
- padding: 0 8px;
75
- &:focus {
76
- outline: none;
77
- }
78
- &:hover svg circle {
79
- fill: #1a9bc7;
80
- }
81
- `;
82
- export const FileActionDropdownList = styled(DropdownList) `
83
- border: 1px solid #e2e2e2;
84
- box-sizing: border-box;
85
- box-shadow: 0 4px 9px rgba(0, 0, 0, 0.3);
86
- border-radius: 8px;
87
- min-width: 180px;
88
- background: ${(props) => props.theme.colors.background.primary};
89
- z-index: 999;
90
- text-align: left;
91
- overflow: hidden;
92
- `;
93
- export const FileAction = styled.div `
94
- font-family: ${(props) => props.theme.font.family.Lato};
95
- cursor: pointer;
96
- font-size: 16px;
97
- line-height: 24px;
98
- color: ${(props) => props.theme.colors.text.primary};
99
- padding: 16px;
100
- &:hover,
101
- &:focus {
102
- background: #f2fbfc;
103
- }
104
- `;
@@ -1,33 +0,0 @@
1
- import styled from 'styled-components';
2
- export const FileContainer = styled.div `
3
- display: flex;
4
- font-family: ${(props) => props.theme.font.family.Lato};
5
- align-items: center;
6
- cursor: pointer;
7
- box-sizing: border-box;
8
- position: relative;
9
- padding: 24px 18px;
10
- height: 72px;
11
-
12
- &.dragging {
13
- opacity: 0.2;
14
- }
15
-
16
- .file-icon {
17
- min-width: 20px;
18
- width: 20px;
19
- }
20
-
21
- .show-on-hover {
22
- display: none;
23
- }
24
-
25
- &:hover .show-on-hover {
26
- display: block;
27
- }
28
-
29
- &:hover,
30
- &:focus {
31
- background: #f2fbfc;
32
- }
33
- `;
@@ -1,18 +0,0 @@
1
- import { format } from 'date-fns';
2
- import React from 'react';
3
- import styled from 'styled-components';
4
- import { Tooltip } from './Tooltip';
5
- export const FileCreatedDate = ({ file, className }) => {
6
- return file.createdDate ? (React.createElement(FileDateContainer, { "data-tip": "File Uploaded", "data-for": `${file.id}-created-date`, className: className },
7
- React.createElement(FileDate, null, format(new Date(file.createdDate), 'M/d/yy, HH:mm')),
8
- React.createElement(Tooltip, { id: `${file.id}-created-date`, place: "bottom", offset: { top: 0 }, effect: "solid", className: "tooltip" }, "File Uploaded"))) : (React.createElement(React.Fragment, null));
9
- };
10
- export const FileDateContainer = styled.div `
11
- overflow: hidden;
12
- min-width: 80px;
13
- margin-left: 8px;
14
- `;
15
- export const FileDate = styled.div `
16
- font-size: ${(props) => props.theme.font.size.small};
17
- line-height: 27px;
18
- `;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import { FileTypeIcon } from './FileTypeIcon';
4
- export const FileName = ({ file }) => {
5
- return (React.createElement(React.Fragment, null,
6
- React.createElement(FileTypeIcon, { file: file }),
7
- React.createElement(FileNameText, null, file.name)));
8
- };
9
- export const FileNameText = styled.div `
10
- font-family: ${(props) => props.theme.font.family.Lato};
11
- font-size: ${(props) => props.theme.font.size.medium};
12
- line-height: ${(props) => props.theme.font.lineHeight.large};
13
- font-weight: ${(props) => props.theme.font.weight.normal};
14
- color: ${(props) => props.theme.colors.text.primary};
15
- margin-left: ${(props) => props.theme.grid.unit * 2}px;
16
- flex-grow: 1;
17
- overflow: hidden;
18
- white-space: nowrap;
19
- text-overflow: ellipsis;
20
- `;
@@ -1,163 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import { AlertMessage, AlertMessageType } from '../AlertMessage';
4
- import UnknownFormatFileIcon from '../icons/unknown-format-file-icon';
5
- import { FileContainer } from './FileContainer';
6
- import { FileNameText } from './FileName';
7
- export var FileSectionAlertType;
8
- (function (FileSectionAlertType) {
9
- FileSectionAlertType[FileSectionAlertType["NONE"] = 0] = "NONE";
10
- FileSectionAlertType[FileSectionAlertType["UPLOAD_IN_PROGRESS"] = 1] = "UPLOAD_IN_PROGRESS";
11
- FileSectionAlertType[FileSectionAlertType["UPLOAD_SUCCESSFUL"] = 2] = "UPLOAD_SUCCESSFUL";
12
- FileSectionAlertType[FileSectionAlertType["MOVE_SUCCESSFUL"] = 3] = "MOVE_SUCCESSFUL";
13
- })(FileSectionAlertType || (FileSectionAlertType = {}));
14
- export const FileSectionAlert = ({ alert }) => {
15
- return (React.createElement(React.Fragment, null,
16
- alert.type === FileSectionAlertType.UPLOAD_IN_PROGRESS && (React.createElement(FileUploadInProgressAlert, { name: alert.message })),
17
- alert.type === FileSectionAlertType.UPLOAD_SUCCESSFUL && (React.createElement(FileUploadSuccessful, null)),
18
- alert.type === FileSectionAlertType.MOVE_SUCCESSFUL && (React.createElement(FileMoveSuccessful, { name: alert.message }))));
19
- };
20
- const FileUploadInProgressAlert = ({ name }) => {
21
- return (React.createElement(FileUploadContainer, null,
22
- React.createElement(UnknownFormatFileIcon, null),
23
- React.createElement(FileUploadNameContainer, null,
24
- React.createElement(UploadFileNameText, null, name),
25
- React.createElement(FileUploadProgressBar, null))));
26
- };
27
- const FileUploadSuccessful = () => {
28
- return (React.createElement(AlertMessageContainer, null,
29
- React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
30
- text: 'OK',
31
- } }, "File uploaded successfully")));
32
- };
33
- const FileMoveSuccessful = ({ name }) => {
34
- return (React.createElement(AlertMessageContainer, null,
35
- React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
36
- text: 'OK',
37
- } },
38
- "File moved to ",
39
- name)));
40
- };
41
- const AlertMessageContainer = styled.div `
42
- margin-left: 16px;
43
- margin-right: 16px;
44
- `;
45
- const FileUploadContainer = styled(FileContainer) `
46
- background: #f2fbfc;
47
- `;
48
- const FileUploadNameContainer = styled.div `
49
- flex-grow: 1;
50
- margin-left: 8px;
51
- `;
52
- const UploadFileNameText = styled(FileNameText) `
53
- margin: 0;
54
- `;
55
- const FileUploadProgressBar = () => {
56
- return (React.createElement(LinearProgress, null,
57
- React.createElement(Bar, { className: "bar1" }),
58
- React.createElement(Bar, { className: "bar2" })));
59
- };
60
- const LinearProgress = styled.div `
61
- background: ${(props) => props.theme.colors.background.tertiary};
62
- opacity: 0.7;
63
- height: 4px;
64
- position: relative;
65
- width: 100%;
66
- margin: 8px auto 0;
67
- overflow: hidden;
68
- border-radius: 8px;
69
- animation: start 0.3s ease-in;
70
- `;
71
- const Bar = styled.div `
72
- position: absolute;
73
- opacity: 0.7;
74
- background: #1a9bc7;
75
- transition: transform 0.2s linear;
76
- left: 0;
77
- top: 0;
78
- bottom: 0;
79
- width: 100%;
80
-
81
- &.bar1 {
82
- animation: growBar1 2.5s infinite, moveBar1 2.5s infinite;
83
- }
84
-
85
- &.bar2 {
86
- animation: growBar2 2.5s infinite, moveBar2 2.5s infinite;
87
- }
88
-
89
- @keyframes growBar1 {
90
- 0% {
91
- animation-timing-function: linear;
92
- transform: scaleX(0.1);
93
- }
94
- 35% {
95
- animation-timing-function: cubic-bezier(0.3, 0.1, 0.7, 1);
96
- transform: scaleX(0.1);
97
- }
98
- 70% {
99
- animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
100
- transform: scaleX(0.8);
101
- }
102
- 100% {
103
- transform: scaleX(0.1);
104
- }
105
- }
106
-
107
- @keyframes moveBar1 {
108
- 0% {
109
- left: -105%;
110
- animation-timing-function: linear;
111
- }
112
- 20% {
113
- left: -105%;
114
- animation-timing-function: cubic-bezier(0.5, 0, 0.7, 0.4);
115
- }
116
- 60% {
117
- left: 21%;
118
- animation-timing-function: cubic-bezier(0.3, 0.4, 0.55, 0.9);
119
- }
120
- 80% {
121
- left: 40%;
122
- animation-timing-function: cubic-bezier(0.1, 0.2, 0.3, 0.95);
123
- }
124
- 100% {
125
- left: 90%;
126
- }
127
- }
128
-
129
- @keyframes growBar2 {
130
- 0% {
131
- animation-timing-function: cubic-bezier(0.2, 0, 0.5, 0.4);
132
- transform: scaleX(0.1);
133
- }
134
- 20% {
135
- animation-timing-function: cubic-bezier(0.1, 0.2, 0.6, 1);
136
- transform: scaleX(0.3);
137
- }
138
- 60% {
139
- animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
140
- transform: scaleX(0.6);
141
- }
142
- 100% {
143
- transform: scaleX(0.1);
144
- }
145
- }
146
- @keyframes moveBar2 {
147
- 0% {
148
- left: -100%;
149
- animation-timing-function: cubic-bezier(0.15, 0, 0.5, 0.4);
150
- }
151
- 25% {
152
- left: -50%;
153
- animation-timing-function: cubic-bezier(0.3, 0.3, 0.8, 0.7);
154
- }
155
- 50% {
156
- left: 45%;
157
- animation-timing-function: cubic-bezier(0.1, 0.6, 0.6, 0.9);
158
- }
159
- 100% {
160
- left: 95%;
161
- }
162
- }
163
- `;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import CorruptedFileIcon from '../icons/corrupted-file-icon';
3
- import DocumentIconWithDot from '../icons/document-icon-with-dot';
4
- import UnknownFormatFileIcon from '../icons/unknown-format-file-icon';
5
- import { getFileIcon } from './util';
6
- export const FileTypeIcon = ({ file }) => {
7
- if (file.type.id === 'missing') {
8
- return React.createElement(CorruptedFileIcon, { className: "file-icon" });
9
- }
10
- if (file.type.id === 'main-manuscript') {
11
- return React.createElement(DocumentIconWithDot, { className: "file-icon" });
12
- }
13
- const icon = getFileIcon(file);
14
- return icon || React.createElement(UnknownFormatFileIcon, { className: "file-icon" });
15
- };
@@ -1,74 +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 { buildSupplementaryMaterial } from '@manuscripts/transform';
11
- import React, { useContext, useEffect, useState } from 'react';
12
- import { useDrag } from 'react-dnd';
13
- import { getEmptyImage } from 'react-dnd-html5-backend';
14
- import { FileActions } from './FileActions';
15
- import { FileContainer } from './FileContainer';
16
- import { FileCreatedDate } from './FileCreatedDate';
17
- import { PermissionsContext } from './FileManager';
18
- import { FileManagerContext } from './FileManagerProvider';
19
- import { FileName } from './FileName';
20
- import { FileSectionAlert, FileSectionAlertType } from './FileSectionAlert';
21
- import { FileUploader } from './FileUploader';
22
- import { FileSectionType } from './util';
23
- export const OtherFilesSection = ({ files }) => {
24
- const { fileManagement, saveModel } = useContext(FileManagerContext);
25
- const can = useContext(PermissionsContext);
26
- const [alert, setAlert] = useState({
27
- type: FileSectionAlertType.NONE,
28
- message: '',
29
- });
30
- const upload = (file) => __awaiter(void 0, void 0, void 0, function* () {
31
- setAlert({
32
- type: FileSectionAlertType.UPLOAD_IN_PROGRESS,
33
- message: file.name,
34
- });
35
- yield fileManagement.upload(file);
36
- setAlert({
37
- type: FileSectionAlertType.UPLOAD_SUCCESSFUL,
38
- message: '',
39
- });
40
- });
41
- const moveToSupplements = (file) => __awaiter(void 0, void 0, void 0, function* () {
42
- const supplement = buildSupplementaryMaterial('', file.id);
43
- yield saveModel(supplement);
44
- setAlert({
45
- type: FileSectionAlertType.MOVE_SUCCESSFUL,
46
- message: FileSectionType.Supplements,
47
- });
48
- });
49
- return (React.createElement("div", null,
50
- (can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, { handler: upload }),
51
- React.createElement(FileSectionAlert, { alert: alert }),
52
- files.map((file) => (React.createElement(OtherFile, { key: file.id, file: file, handleDownload: () => fileManagement.download(file), handleMoveToSupplements: () => __awaiter(void 0, void 0, void 0, function* () { return yield moveToSupplements(file); }) })))));
53
- };
54
- const OtherFile = ({ file, handleDownload, handleMoveToSupplements }) => {
55
- const [{ isDragging }, drag, preview] = useDrag({
56
- item: {
57
- file,
58
- type: 'file',
59
- },
60
- collect: (monitor) => ({
61
- isDragging: monitor.isDragging(),
62
- }),
63
- });
64
- useEffect(() => {
65
- preview(getEmptyImage());
66
- }, [preview]);
67
- return (React.createElement(FileContainer, { key: file.id, ref: drag, className: isDragging ? 'dragging' : '' },
68
- React.createElement(FileName, { file: file }),
69
- React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
70
- React.createElement(FileActions, { sectionType: FileSectionType.OtherFile, handleDownload: handleDownload, move: {
71
- sectionType: FileSectionType.Supplements,
72
- handler: handleMoveToSupplements,
73
- } })));
74
- };
@@ -1,91 +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 } from '@manuscripts/transform';
12
- import React, { useContext, useEffect, useState } from 'react';
13
- import { useDrag } from 'react-dnd';
14
- import { getEmptyImage } from 'react-dnd-html5-backend';
15
- import { FileActions } from './FileActions';
16
- import { FileContainer } from './FileContainer';
17
- import { FileCreatedDate } from './FileCreatedDate';
18
- import { PermissionsContext } from './FileManager';
19
- import { FileManagerContext } from './FileManagerProvider';
20
- import { FileName } from './FileName';
21
- import { FileSectionAlert, FileSectionAlertType } from './FileSectionAlert';
22
- import { FileUploader } from './FileUploader';
23
- import { FileSectionType } from './util';
24
- export const SupplementsSection = ({ supplements }) => {
25
- const { modelMap, saveModel, deleteModel, fileManagement } = useContext(FileManagerContext);
26
- const can = useContext(PermissionsContext);
27
- const [alert, setAlert] = useState({
28
- type: FileSectionAlertType.NONE,
29
- message: '',
30
- });
31
- const upload = (file) => __awaiter(void 0, void 0, void 0, function* () {
32
- setAlert({
33
- type: FileSectionAlertType.UPLOAD_IN_PROGRESS,
34
- message: file.name,
35
- });
36
- const uploaded = yield fileManagement.upload(file);
37
- setAlert({
38
- type: FileSectionAlertType.UPLOAD_SUCCESSFUL,
39
- message: '',
40
- });
41
- return uploaded;
42
- });
43
- const handleUpload = (file) => __awaiter(void 0, void 0, void 0, function* () {
44
- const uploaded = yield upload(file);
45
- const supplement = buildSupplementaryMaterial('', uploaded.id);
46
- yield saveModel(supplement);
47
- });
48
- const handleReplace = (modelId, file) => __awaiter(void 0, void 0, void 0, function* () {
49
- const uploaded = yield upload(file);
50
- const supplement = modelMap.get(modelId);
51
- yield saveModel(Object.assign(Object.assign({}, supplement), { href: uploaded.id }));
52
- });
53
- const handleMoveToOtherFiles = (modelId) => __awaiter(void 0, void 0, void 0, function* () {
54
- yield deleteModel(modelId);
55
- setAlert({
56
- type: FileSectionAlertType.MOVE_SUCCESSFUL,
57
- message: FileSectionType.OtherFile,
58
- });
59
- });
60
- return (React.createElement(React.Fragment, null,
61
- (can === null || can === void 0 ? void 0 : can.uploadFile) && React.createElement(FileUploader, { handler: handleUpload }),
62
- React.createElement(FileSectionAlert, { alert: alert }),
63
- supplements.map((supplement) => (React.createElement(SupplementFile, { key: supplement.modelId, file: supplement, handleDownload: () => fileManagement.download(supplement), handleReplace: (f) => __awaiter(void 0, void 0, void 0, function* () { return yield handleReplace(supplement.modelId, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield handleMoveToOtherFiles(supplement.modelId); }) })))));
64
- };
65
- const SupplementFile = ({ file, handleDownload, handleReplace, handleDetach }) => {
66
- const [{ isDragging }, drag, preview] = useDrag({
67
- item: {
68
- file,
69
- model: {
70
- _id: file.modelId,
71
- objectType: ObjectTypes.Supplement,
72
- },
73
- type: 'file',
74
- },
75
- collect: (monitor) => ({
76
- isDragging: monitor.isDragging(),
77
- }),
78
- });
79
- useEffect(() => {
80
- preview(getEmptyImage());
81
- }, [preview]);
82
- return (React.createElement(FileContainer, { key: file.id, ref: drag, className: isDragging ? 'dragging' : '' },
83
- React.createElement(FileName, { file: file }),
84
- React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
85
- React.createElement(FileActions, { sectionType: FileSectionType.Supplements, handleDownload: file.id ? handleDownload : undefined, handleReplace: handleReplace, move: file.id
86
- ? {
87
- sectionType: FileSectionType.OtherFile,
88
- handler: handleDetach,
89
- }
90
- : undefined })));
91
- };
@@ -1,22 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import React from 'react';
17
- const CorruptedFileIcon = (props) => (React.createElement("svg", { width: "16", height: "18", viewBox: "0 0 16 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: props.className },
18
- React.createElement("path", { d: "M14.186 5.65149L13.6777 6.20297L14.186 5.65149L9.91329 1.71322C9.59104 1.4162 9.16952 1.25 8.7288 1.25H8.72312H8.7174H8.71165H8.70585H8.70003H8.69416H8.68826H8.68232H8.67635H8.67034H8.66429H8.65821H8.65209H8.64593H8.63974H8.63352H8.62725H8.62096H8.61462H8.60825H8.60185H8.59541H8.58894H8.58243H8.57588H8.5693H8.56269H8.55604H8.54936H8.54264H8.53589H8.5291H8.52228H8.51543H8.50854H8.50162H8.49466H8.48767H8.48064H8.47359H8.4665H8.45937H8.45221H8.44502H8.4378H8.43054H8.42325H8.41593H8.40857H8.40118H8.39376H8.38631H8.37882H8.37131H8.36376H8.35617H8.34856H8.34091H8.33323H8.32552H8.31778H8.31001H8.3022H8.29437H8.2865H8.2786H8.27067H8.26271H8.25472H8.2467H8.23864H8.23056H8.22244H8.2143H8.20612H8.19792H8.18968H8.18142H8.17312H8.16479H8.15644H8.14805H8.13964H8.13119H8.12272H8.11421H8.10568H8.09712H8.08852H8.0799H8.07126H8.06258H8.05387H8.04513H8.03637H8.02758H8.01876H8.00991H8.00103H7.99212H7.98319H7.97423H7.96524H7.95622H7.94718H7.9381H7.929H7.91987H7.91072H7.90154H7.89233H7.88309H7.87383H7.86454H7.85522H7.84588H7.83651H7.82711H7.81769H7.80824H7.79877H7.78926H7.77974H7.77018H7.7606H7.751H7.74137H7.73171H7.72203H7.71232H7.70259H7.69283H7.68305H7.67324H7.66341H7.65355H7.64367H7.63376H7.62383H7.61388H7.6039H7.59389H7.58386H7.57381H7.56373H7.55363H7.54351H7.53336H7.52319H7.51299H7.50277H7.49253H7.48226H7.47198H7.46166H7.45133H7.44097H7.43059H7.42019H7.40976H7.39931H7.38884H7.37834H7.36783H7.35729H7.34673H7.33615H7.32554H7.31492H7.30427H7.2936H7.28291H7.2722H7.26146H7.25071H7.23993H7.22913H7.21831H7.20747H7.19661H7.18573H7.17483H7.16391H7.15297H7.142H7.13102H7.12002H7.10899H7.09795H7.08688H7.0758H7.0647H7.05357H7.04243H7.03127H7.02009H7.00889H6.99767H6.98643H6.97517H6.96389H6.9526H6.94128H6.92995H6.9186H6.90723H6.89584H6.88443H6.87301H6.86156H6.8501H6.83862H6.82713H6.81561H6.80408H6.79253H6.78096H6.76938H6.75778H6.74616H6.73452H6.72287H6.7112H6.69951H6.68781H6.67609H6.66435H6.6526H6.64083H6.62904H6.61724H6.60542H6.59359H6.58173H6.56987H6.55799H6.54609H6.53418H6.52225H6.5103H6.49834H6.48637H6.47438H6.46238H6.45036H6.43832H6.42627H6.41421H6.40213H6.39004H6.37793H6.36581H6.35367H6.34152H6.32936H6.31718H6.30499H6.29279H6.28057H6.26834H6.25609H6.24383H6.23156H6.21927H6.20697H6.19466H6.18234H6.17H6.15765H6.14529H6.13291H6.12052H6.10812H6.09571H6.08329H6.07085H6.0584H6.04594H6.03347H6.02098H6.00849H5.99598H5.98346H5.97093H5.95839H5.94584H5.93327H5.9207H5.90811H5.89551H5.88291H5.87029H5.85766H5.84502H5.83237H5.81971H5.80704H5.79436H5.78167H5.76897H5.75626H5.74354H5.73081H5.71808H5.70533H5.69257H5.6798H5.66703H5.65424H5.64145H5.62865H5.61583H5.60301H5.59018H5.57735H5.5645H5.55165H5.53878H5.52591H5.51303H5.50015H5.48725H5.47435H5.46144H5.44852H5.4356H5.42266H5.40972H5.39677H5.38382H5.37086H5.35789H5.34491H5.33193H5.31894H5.30594H5.29294H5.27993H5.26692H5.2539H5.24087H5.22783H5.21479H5.20175H5.1887H5.17564H5.16258H5.14951H5.13643H5.12335H5.11027H5.09718H5.08408H5.07098H5.05788H5.04477H5.03165H5.01854H5.00541H4.99228H4.97915H4.96601H4.95287H4.93973H4.92658H4.91343H4.90027H4.88711H4.87395H4.86078H4.84761H4.83443H4.82126H4.80808H4.79489H4.7817H4.76851H4.75532H4.74213H4.72893H4.71573H4.70253H4.68932H4.67611H4.6629H4.64969H4.63648H4.62326H4.61004H4.59683H4.5836H4.57038H4.55716H4.54393H4.53071H4.51748H4.50425H4.49102H4.47779H4.46456H4.45133H4.43809H4.42486H4.41163H4.39839H4.38516H4.37192H4.35869H4.34545H4.33222H4.31899H4.30575H4.29252H4.27928H4.26605H4.25282H4.23959H4.22636H4.21313H4.1999H4.18667H4.17345H4.16022H4.147H4.13378H4.12056H4.10734H4.09412H4.0809H4.06769H4.05448H4.04127H4.02806H4.01486H4.00166H3.98846H3.97526H3.96206H3.94887H3.93568H3.9225H3.90931H3.89613H3.88296H3.86978H3.85661H3.84345H3.83028H3.81712H3.80397H3.79082H3.77767H3.76452H3.75138H3.73825H3.72512H3.71199H3.69887H3.68575H3.67264H3.65953H3.64642H3.63332H3.62023H3.60714H3.59406H3.58098H3.56791H3.55484H3.54178H3.52872H3.51567H3.50263H3.48959H3.47655H3.46353H3.45051H3.43749H3.42449H3.41148H3.39849H3.3855H3.37252H3.35955H3.34658H3.33362H3.32067H3.30772H3.29478H3.28185H3.26892H3.25601H3.2431H3.2302H3.21731H3.20442H3.19154H3.17867H3.16581H3.15296H3.14012H3.12728H3.11445H3.10163H3.08882H3.07602H3.06323H3.05045H3.03767H3.02491H3.01215H2.99941C2.03233 1.25 1.25 2.03408 1.25 3V15C1.25 15.9665 2.0335 16.75 3 16.75H13C13.9665 16.75 14.75 15.9665 14.75 15V6.93827C14.75 6.4494 14.5455 5.98282 14.186 5.65149Z", stroke: "#6E6E6E", strokeWidth: "1.5" }),
19
- React.createElement("path", { d: "M5 13C6.06061 11.4908 8.94545 9.37781 12 13", stroke: "#6E6E6E", strokeWidth: "1.5", strokeLinecap: "round" }),
20
- React.createElement("path", { d: "M5 5C5 5 5 5.52369 5 6.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeLinecap: "round" }),
21
- React.createElement("path", { d: "M9 2V7H14", stroke: "#6E6E6E", strokeWidth: "1.5" })));
22
- export default CorruptedFileIcon;
@@ -1,79 +0,0 @@
1
- import { ObjectTypes, } from '@manuscripts/json-schema';
2
- import { getModelsByType } from '@manuscripts/transform';
3
- import { FileType } from '../components/FileManager/util';
4
- export const isModelFile = (file) => {
5
- return file.modelId;
6
- };
7
- const MISSING_FILE = {
8
- id: '',
9
- name: 'Missing file',
10
- type: {
11
- id: 'missing',
12
- },
13
- };
14
- const getFile = (files, id) => {
15
- return files.filter((f) => f.id === id)[0] || MISSING_FILE;
16
- };
17
- const getFigureFiles = (element, modelMap, files) => {
18
- const figureFiles = [];
19
- element.containedObjectIDs.map((id) => {
20
- const model = modelMap.get(id);
21
- if (model && model.objectType === ObjectTypes.Figure) {
22
- const figure = model;
23
- if (figure.src) {
24
- figureFiles.push(Object.assign(Object.assign({}, getFile(files, figure.src)), { modelId: figure._id }));
25
- }
26
- }
27
- });
28
- return figureFiles;
29
- };
30
- const getSupplementFiles = (supplement, files) => {
31
- if (supplement.href) {
32
- const href = supplement.href;
33
- if (href) {
34
- return [
35
- Object.assign(Object.assign({}, getFile(files, href)), { modelId: supplement._id }),
36
- ];
37
- }
38
- }
39
- return [];
40
- };
41
- export const getInlineFiles = (modelMap, files) => {
42
- var _a;
43
- const elements = [];
44
- const orders = getOrderByType(modelMap);
45
- const sections = getModelsByType(modelMap, ObjectTypes.Section);
46
- const graphicalAbstractElementIds = (_a = sections.filter((s) => s.category === 'MPSectionCategory:abstract-graphical')[0]) === null || _a === void 0 ? void 0 : _a.elementIDs;
47
- graphicalAbstractElementIds === null || graphicalAbstractElementIds === void 0 ? void 0 : graphicalAbstractElementIds.map((id) => {
48
- const figure = modelMap.get(id);
49
- if (figure) {
50
- elements.push({
51
- modelId: id,
52
- type: FileType.GraphicalAbstract,
53
- label: 'Graphical Abstract',
54
- files: getFigureFiles(figure, modelMap, files),
55
- });
56
- }
57
- });
58
- const figures = getModelsByType(modelMap, ObjectTypes.FigureElement);
59
- const figureOrder = orders.get(ObjectTypes.FigureElement);
60
- if (figureOrder) {
61
- }
62
- figures === null || figures === void 0 ? void 0 : figures.filter((f) => !(graphicalAbstractElementIds === null || graphicalAbstractElementIds === void 0 ? void 0 : graphicalAbstractElementIds.includes(f._id))).map((figure, index) => ({
63
- modelId: figure._id,
64
- type: FileType.Figure,
65
- label: `Figure ${index + 1}`,
66
- files: getFigureFiles(figure, modelMap, files),
67
- })).forEach((e) => elements.push(e));
68
- return elements;
69
- };
70
- export const getSupplements = (modelMap, files) => {
71
- const supplements = getModelsByType(modelMap, ObjectTypes.Supplement);
72
- return supplements.flatMap((s) => getSupplementFiles(s, files));
73
- };
74
- const getOrderByType = (modelMap) => {
75
- const groups = new Map();
76
- const orders = getModelsByType(modelMap, ObjectTypes.ElementsOrder);
77
- orders.forEach((o) => groups.set(o.elementType, o));
78
- return groups;
79
- };
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { Move, Replace } from './FileManager';
3
- import { FileSectionType } from './util';
4
- export declare const FileActions: React.FC<{
5
- sectionType: FileSectionType;
6
- handleDownload?: () => void;
7
- handleReplace?: Replace;
8
- handleDetach?: () => void;
9
- move?: Move;
10
- className?: string;
11
- }>;
12
- export declare const ActionsIcon: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
13
- export declare const FileActionDropdownList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
14
- direction?: "left" | "right" | undefined;
15
- width?: number | undefined;
16
- height?: number | undefined;
17
- top?: number | undefined;
18
- }, never>;
19
- export declare const FileAction: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -1 +0,0 @@
1
- export declare const FileContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { FileAttachment } from '../../lib/files';
3
- export declare const FileCreatedDate: React.FC<{
4
- file: FileAttachment;
5
- className?: string;
6
- }>;
7
- export declare const FileDateContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
- export declare const FileDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;