@manuscripts/style-guide 1.3.5-LEAN-2705-5 → 1.3.6-LEAN-2585-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 (115) hide show
  1. package/dist/cjs/components/AuthorsList/Author.js +19 -11
  2. package/dist/cjs/components/AuthorsList/AuthorsList.js +1 -1
  3. package/dist/cjs/components/EditorHeader/EditorHeader.js +11 -3
  4. package/dist/cjs/components/EditorHeader/ProceedView.js +6 -25
  5. package/dist/cjs/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  6. package/dist/cjs/components/FileManager/FileActions.js +134 -0
  7. package/dist/cjs/components/FileManager/FileContainer.js +39 -0
  8. package/dist/cjs/components/FileManager/FileCreatedDate.js +25 -0
  9. package/dist/cjs/components/FileManager/FileManager.js +14 -125
  10. package/dist/cjs/components/FileManager/FileManagerProvider.js +2 -7
  11. package/dist/cjs/components/FileManager/FileName.js +27 -0
  12. package/dist/cjs/components/FileManager/FileSectionAlert.js +170 -0
  13. package/dist/cjs/components/FileManager/FileTypeIcon.js +22 -0
  14. package/dist/cjs/components/FileManager/{UploadFileArea.js → FileUploader.js} +19 -12
  15. package/dist/cjs/components/FileManager/InlineFilesSection.js +71 -126
  16. package/dist/cjs/components/FileManager/OtherFilesSection.js +101 -0
  17. package/dist/cjs/components/FileManager/SupplementsSection.js +118 -0
  18. package/dist/cjs/components/FileManager/{TooltipDiv.js → Tooltip.js} +8 -3
  19. package/dist/cjs/components/FileManager/util.js +52 -67
  20. package/dist/cjs/components/icons/corrupted-file-icon.js +27 -0
  21. package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
  22. package/dist/cjs/hooks/use-deep-compare.js +2 -2
  23. package/dist/cjs/hooks/use-files.js +29 -43
  24. package/dist/cjs/index.js +3 -4
  25. package/dist/cjs/lib/capabilities.js +1 -2
  26. package/dist/cjs/lib/files.js +85 -0
  27. package/dist/es/components/AuthorsList/Author.js +19 -11
  28. package/dist/es/components/AuthorsList/AuthorsList.js +1 -1
  29. package/dist/es/components/EditorHeader/EditorHeader.js +11 -3
  30. package/dist/es/components/EditorHeader/ProceedView.js +7 -26
  31. package/dist/es/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  32. package/dist/es/components/FileManager/FileActions.js +104 -0
  33. package/dist/es/components/FileManager/FileContainer.js +33 -0
  34. package/dist/es/components/FileManager/FileCreatedDate.js +18 -0
  35. package/dist/es/components/FileManager/FileManager.js +16 -124
  36. package/dist/es/components/FileManager/FileManagerProvider.js +3 -8
  37. package/dist/es/components/FileManager/FileName.js +20 -0
  38. package/dist/es/components/FileManager/FileSectionAlert.js +163 -0
  39. package/dist/es/components/FileManager/FileTypeIcon.js +15 -0
  40. package/dist/es/components/FileManager/{UploadFileArea.js → FileUploader.js} +17 -10
  41. package/dist/es/components/FileManager/InlineFilesSection.js +72 -127
  42. package/dist/es/components/FileManager/OtherFilesSection.js +74 -0
  43. package/dist/es/components/FileManager/SupplementsSection.js +91 -0
  44. package/dist/es/components/FileManager/{TooltipDiv.js → Tooltip.js} +7 -2
  45. package/dist/es/components/FileManager/util.js +47 -65
  46. package/dist/es/components/icons/corrupted-file-icon.js +22 -0
  47. package/dist/es/components/icons/document-icon-with-dot.js +1 -1
  48. package/dist/es/hooks/use-deep-compare.js +2 -2
  49. package/dist/es/hooks/use-files.js +29 -40
  50. package/dist/es/index.js +2 -2
  51. package/dist/es/lib/capabilities.js +1 -2
  52. package/dist/es/lib/files.js +79 -0
  53. package/dist/types/components/AuthorsList/Author.d.ts +1 -0
  54. package/dist/types/components/EditorHeader/ProceedView.d.ts +1 -0
  55. package/dist/types/components/FileManager/FileActions.d.ts +19 -0
  56. package/dist/types/components/FileManager/FileContainer.d.ts +1 -0
  57. package/dist/types/components/FileManager/FileCreatedDate.d.ts +8 -0
  58. package/dist/types/components/FileManager/FileManager.d.ts +17 -8
  59. package/dist/types/components/FileManager/FileManagerProvider.d.ts +8 -18
  60. package/dist/types/components/FileManager/FileName.d.ts +6 -0
  61. package/dist/types/components/FileManager/FileSectionAlert.d.ts +13 -0
  62. package/dist/types/components/FileManager/{FileSectionItem/FileTypeIcon.d.ts → FileTypeIcon.d.ts} +2 -3
  63. package/dist/types/components/FileManager/FileUploader.d.ts +4 -0
  64. package/dist/types/components/FileManager/InlineFilesSection.d.ts +3 -19
  65. package/dist/types/components/FileManager/OtherFilesSection.d.ts +5 -0
  66. package/dist/types/components/FileManager/SupplementsSection.d.ts +5 -0
  67. package/dist/types/components/FileManager/Tooltip.d.ts +2 -0
  68. package/dist/types/components/FileManager/util.d.ts +8 -12
  69. package/dist/types/components/icons/corrupted-file-icon.d.ts +19 -0
  70. package/dist/types/hooks/use-files.d.ts +4 -6
  71. package/dist/types/index.d.ts +2 -2
  72. package/dist/types/lib/capabilities.d.ts +0 -1
  73. package/dist/types/lib/files.d.ts +24 -0
  74. package/package.json +3 -3
  75. package/dist/cjs/components/FileManager/ConfirmationPopUp.js +0 -90
  76. package/dist/cjs/components/FileManager/DragItemArea.js +0 -28
  77. package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -76
  78. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +0 -115
  79. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +0 -95
  80. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -37
  81. package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -53
  82. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +0 -92
  83. package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -120
  84. package/dist/cjs/components/FileManager/FileSectionState.js +0 -83
  85. package/dist/cjs/components/FileManager/FilesSection.js +0 -61
  86. package/dist/cjs/components/FileManager/ItemsAction.js +0 -48
  87. package/dist/cjs/lib/inlineFiles.js +0 -92
  88. package/dist/es/components/FileManager/ConfirmationPopUp.js +0 -62
  89. package/dist/es/components/FileManager/DragItemArea.js +0 -21
  90. package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -46
  91. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +0 -85
  92. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +0 -88
  93. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -30
  94. package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -46
  95. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +0 -65
  96. package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -113
  97. package/dist/es/components/FileManager/FileSectionState.js +0 -78
  98. package/dist/es/components/FileManager/FilesSection.js +0 -34
  99. package/dist/es/components/FileManager/ItemsAction.js +0 -42
  100. package/dist/es/lib/inlineFiles.js +0 -90
  101. package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +0 -12
  102. package/dist/types/components/FileManager/DragItemArea.d.ts +0 -4
  103. package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +0 -3
  104. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -19
  105. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +0 -38
  106. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -12
  107. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -21
  108. package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +0 -4
  109. package/dist/types/components/FileManager/FileSectionState.d.ts +0 -38
  110. package/dist/types/components/FileManager/FilesSection.d.ts +0 -12
  111. package/dist/types/components/FileManager/ItemsAction.d.ts +0 -4
  112. package/dist/types/components/FileManager/TooltipDiv.d.ts +0 -1
  113. package/dist/types/components/FileManager/UploadFileArea.d.ts +0 -9
  114. package/dist/types/lib/inlineFiles.d.ts +0 -11
  115. /package/dist/types/components/FileManager/{FileSectionItem/DragLayer.d.ts → DragLayer.d.ts} +0 -0
@@ -0,0 +1,163 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { AlertMessage, AlertMessageType } from '../AlertMessage';
4
+ import UnknownFormatFileIcon from '../icons/unknown-format-file-icon';
5
+ import { FileContainer } from './FileContainer';
6
+ import { FileNameText } from './FileName';
7
+ export var FileSectionAlertType;
8
+ (function (FileSectionAlertType) {
9
+ FileSectionAlertType[FileSectionAlertType["NONE"] = 0] = "NONE";
10
+ FileSectionAlertType[FileSectionAlertType["UPLOAD_IN_PROGRESS"] = 1] = "UPLOAD_IN_PROGRESS";
11
+ FileSectionAlertType[FileSectionAlertType["UPLOAD_SUCCESSFUL"] = 2] = "UPLOAD_SUCCESSFUL";
12
+ FileSectionAlertType[FileSectionAlertType["MOVE_SUCCESSFUL"] = 3] = "MOVE_SUCCESSFUL";
13
+ })(FileSectionAlertType || (FileSectionAlertType = {}));
14
+ export const FileSectionAlert = ({ alert }) => {
15
+ return (React.createElement(React.Fragment, null,
16
+ alert.type === FileSectionAlertType.UPLOAD_IN_PROGRESS && (React.createElement(FileUploadInProgressAlert, { name: alert.message })),
17
+ alert.type === FileSectionAlertType.UPLOAD_SUCCESSFUL && (React.createElement(FileUploadSuccessful, null)),
18
+ alert.type === FileSectionAlertType.MOVE_SUCCESSFUL && (React.createElement(FileMoveSuccessful, { name: alert.message }))));
19
+ };
20
+ const FileUploadInProgressAlert = ({ name }) => {
21
+ return (React.createElement(FileUploadContainer, null,
22
+ React.createElement(UnknownFormatFileIcon, null),
23
+ React.createElement(FileUploadNameContainer, null,
24
+ React.createElement(UploadFileNameText, null, name),
25
+ React.createElement(FileUploadProgressBar, null))));
26
+ };
27
+ const FileUploadSuccessful = () => {
28
+ return (React.createElement(AlertMessageContainer, null,
29
+ React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
30
+ text: 'OK',
31
+ } }, "File uploaded successfully")));
32
+ };
33
+ const FileMoveSuccessful = ({ name }) => {
34
+ return (React.createElement(AlertMessageContainer, null,
35
+ React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
36
+ text: 'OK',
37
+ } },
38
+ "File moved to ",
39
+ name)));
40
+ };
41
+ const AlertMessageContainer = styled.div `
42
+ margin-left: 16px;
43
+ margin-right: 16px;
44
+ `;
45
+ const FileUploadContainer = styled(FileContainer) `
46
+ background: #f2fbfc;
47
+ `;
48
+ const FileUploadNameContainer = styled.div `
49
+ flex-grow: 1;
50
+ margin-left: 8px;
51
+ `;
52
+ const UploadFileNameText = styled(FileNameText) `
53
+ margin: 0;
54
+ `;
55
+ const FileUploadProgressBar = () => {
56
+ return (React.createElement(LinearProgress, null,
57
+ React.createElement(Bar, { className: "bar1" }),
58
+ React.createElement(Bar, { className: "bar2" })));
59
+ };
60
+ const LinearProgress = styled.div `
61
+ background: ${(props) => props.theme.colors.background.tertiary};
62
+ opacity: 0.7;
63
+ height: 4px;
64
+ position: relative;
65
+ width: 100%;
66
+ margin: 8px auto 0;
67
+ overflow: hidden;
68
+ border-radius: 8px;
69
+ animation: start 0.3s ease-in;
70
+ `;
71
+ const Bar = styled.div `
72
+ position: absolute;
73
+ opacity: 0.7;
74
+ background: #1a9bc7;
75
+ transition: transform 0.2s linear;
76
+ left: 0;
77
+ top: 0;
78
+ bottom: 0;
79
+ width: 100%;
80
+
81
+ &.bar1 {
82
+ animation: growBar1 2.5s infinite, moveBar1 2.5s infinite;
83
+ }
84
+
85
+ &.bar2 {
86
+ animation: growBar2 2.5s infinite, moveBar2 2.5s infinite;
87
+ }
88
+
89
+ @keyframes growBar1 {
90
+ 0% {
91
+ animation-timing-function: linear;
92
+ transform: scaleX(0.1);
93
+ }
94
+ 35% {
95
+ animation-timing-function: cubic-bezier(0.3, 0.1, 0.7, 1);
96
+ transform: scaleX(0.1);
97
+ }
98
+ 70% {
99
+ animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
100
+ transform: scaleX(0.8);
101
+ }
102
+ 100% {
103
+ transform: scaleX(0.1);
104
+ }
105
+ }
106
+
107
+ @keyframes moveBar1 {
108
+ 0% {
109
+ left: -105%;
110
+ animation-timing-function: linear;
111
+ }
112
+ 20% {
113
+ left: -105%;
114
+ animation-timing-function: cubic-bezier(0.5, 0, 0.7, 0.4);
115
+ }
116
+ 60% {
117
+ left: 21%;
118
+ animation-timing-function: cubic-bezier(0.3, 0.4, 0.55, 0.9);
119
+ }
120
+ 80% {
121
+ left: 40%;
122
+ animation-timing-function: cubic-bezier(0.1, 0.2, 0.3, 0.95);
123
+ }
124
+ 100% {
125
+ left: 90%;
126
+ }
127
+ }
128
+
129
+ @keyframes growBar2 {
130
+ 0% {
131
+ animation-timing-function: cubic-bezier(0.2, 0, 0.5, 0.4);
132
+ transform: scaleX(0.1);
133
+ }
134
+ 20% {
135
+ animation-timing-function: cubic-bezier(0.1, 0.2, 0.6, 1);
136
+ transform: scaleX(0.3);
137
+ }
138
+ 60% {
139
+ animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
140
+ transform: scaleX(0.6);
141
+ }
142
+ 100% {
143
+ transform: scaleX(0.1);
144
+ }
145
+ }
146
+ @keyframes moveBar2 {
147
+ 0% {
148
+ left: -100%;
149
+ animation-timing-function: cubic-bezier(0.15, 0, 0.5, 0.4);
150
+ }
151
+ 25% {
152
+ left: -50%;
153
+ animation-timing-function: cubic-bezier(0.3, 0.3, 0.8, 0.7);
154
+ }
155
+ 50% {
156
+ left: 45%;
157
+ animation-timing-function: cubic-bezier(0.1, 0.6, 0.6, 0.9);
158
+ }
159
+ 100% {
160
+ left: 95%;
161
+ }
162
+ }
163
+ `;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import CorruptedFileIcon from '../icons/corrupted-file-icon';
3
+ import DocumentIconWithDot from '../icons/document-icon-with-dot';
4
+ import UnknownFormatFileIcon from '../icons/unknown-format-file-icon';
5
+ import { getFileIcon } from './util';
6
+ export const FileTypeIcon = ({ file }) => {
7
+ if (file.type.id === 'missing') {
8
+ return React.createElement(CorruptedFileIcon, { className: "file-icon" });
9
+ }
10
+ if (file.type.id === 'main-manuscript') {
11
+ return React.createElement(DocumentIconWithDot, { className: "file-icon" });
12
+ }
13
+ const icon = getFileIcon(file);
14
+ return icon || React.createElement(UnknownFormatFileIcon, { className: "file-icon" });
15
+ };
@@ -1,27 +1,35 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import React, { useCallback, useRef } from 'react';
2
11
  import { useDrop } from 'react-dnd';
3
12
  import { NativeTypes } from 'react-dnd-html5-backend';
4
13
  import styled, { css } from 'styled-components';
5
- import { actions } from './FileSectionState';
6
- export const UploadFileArea = ({ fileSection, dispatch }) => {
14
+ export const FileUploader = ({ handler }) => {
7
15
  const fileInputRef = useRef(null);
8
16
  const openFileDialog = () => {
9
17
  if (fileInputRef && fileInputRef.current) {
10
18
  fileInputRef.current.click();
11
19
  }
12
20
  };
13
- const handleChange = (event) => {
21
+ const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
14
22
  if (event && event.target && event.target.files) {
15
23
  const file = event.target.files[0];
16
- dispatch(actions.UPLOAD_FILE(file, fileSection));
24
+ yield handler(file);
17
25
  }
18
- };
19
- const handleFileDrop = useCallback((monitor) => {
26
+ });
27
+ const handleFileDrop = useCallback((monitor) => __awaiter(void 0, void 0, void 0, function* () {
20
28
  if (monitor) {
21
29
  const file = monitor.getItem().files[0];
22
- dispatch(actions.UPLOAD_FILE(file, fileSection));
30
+ yield handler(file);
23
31
  }
24
- }, [dispatch, fileSection]);
32
+ }), [handler]);
25
33
  const [{ canDrop, isOver }, dropRef] = useDrop({
26
34
  accept: [NativeTypes.FILE],
27
35
  drop(item, monitor) {
@@ -55,8 +63,7 @@ const Container = styled.div `
55
63
  font-family: ${(props) => props.theme.font.family.Lato};
56
64
  color: ${(props) => props.theme.colors.text.onLight};
57
65
  cursor: pointer;
58
- margin-bottom: 7px;
59
- margin-top: 16px;
66
+ margin: 16px 16px 8px;
60
67
  ${(props) => props.active
61
68
  ? css `
62
69
  ${activeBoxStyle}
@@ -1,158 +1,103 @@
1
- import { format } from 'date-fns';
2
- import React, { useCallback } from 'react';
3
- import ReactTooltip from 'react-tooltip';
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, { useCallback, useContext } from 'react';
4
11
  import styled from 'styled-components';
5
- import { useDropdown } from '../../hooks/use-dropdown';
6
- import DotsIcon from '../icons/dots-icon';
7
- import { FileInfoContainer, FileNameTitleContainer, FileTitle, } from './FileSectionItem/FileInfo';
8
- import { ActionsIcon, Item, } from './FileSectionItem/FileSectionItem';
9
- import { ItemActions } from './FileSectionItem/ItemActions';
10
- import { extensionsWithFileTypesMap, FileSectionType, fileTypesWithIconMap, } from './util';
12
+ import { FileActions } from './FileActions';
13
+ import { FileContainer } from './FileContainer';
14
+ import { FileCreatedDate } from './FileCreatedDate';
15
+ import { FileManagerContext } from './FileManagerProvider';
16
+ import { FileName } from './FileName';
17
+ import { FileSectionType, getFileTypeIcon } from './util';
11
18
  const trackedJoint = ':dataTracked:';
12
- export const InlineFilesSection = ({ handleReplace, handleDownload, handleUpdateInline, handleDetachFile, inlineFiles, isEditor, dispatch, }) => {
19
+ export const InlineFilesSection = ({ elements, isEditor }) => {
20
+ const { modelMap, fileManagement, saveModel } = useContext(FileManagerContext);
21
+ const navigateToElement = (id) => {
22
+ const clearedId = id.split(trackedJoint)[0];
23
+ const isSelected = clearedId == window.location.hash.substring(1);
24
+ window.location.hash = !isSelected ? `#${clearedId}` : '#';
25
+ };
13
26
  const onElementClick = useCallback((e) => {
14
27
  if (!isEditor) {
15
28
  return;
16
29
  }
17
- const { id } = e.currentTarget;
18
- const clearedId = id.split(trackedJoint)[0];
19
- const isSelected = clearedId == window.location.hash.substr(1);
20
- window.location.hash = !isSelected ? `#${clearedId}` : '#';
21
- if (isSelected) {
22
- window.location.hash = `#${clearedId}`;
23
- }
30
+ navigateToElement(e.currentTarget.id);
24
31
  }, [isEditor]);
25
- return (React.createElement("div", null, inlineFiles.map((file, index) => {
32
+ const updateFigureSrc = (modelId, src) => __awaiter(void 0, void 0, void 0, function* () {
33
+ const figure = modelMap.get(modelId);
34
+ if (figure) {
35
+ yield saveModel(Object.assign(Object.assign({}, figure), { src: src }));
36
+ }
37
+ });
38
+ const detach = (element, file) => __awaiter(void 0, void 0, void 0, function* () {
39
+ yield updateFigureSrc(file.modelId, '');
40
+ navigateToElement(element.modelId);
41
+ });
42
+ const replace = (element, model, file) => __awaiter(void 0, void 0, void 0, function* () {
43
+ const uploaded = yield fileManagement.upload(file);
44
+ yield updateFigureSrc(model.modelId, uploaded.id);
45
+ navigateToElement(element.modelId);
46
+ });
47
+ return (React.createElement(React.Fragment, null, elements.map((element, index) => {
26
48
  var _a;
27
- return (React.createElement(ElementItem, { className: 'item', key: index, id: file.id, onClick: onElementClick },
28
- React.createElement(FileReferences, { className: 'refItems' }, (_a = file.attachments) === null || _a === void 0 ? void 0 : _a.map((attachment) => (React.createElement(React.Fragment, null,
29
- React.createElement(FileReference, { key: attachment.id, attachment: attachment, handleReplace: handleReplace, handleUpdateInline: handleUpdateInline, handleDetachFile: handleDetachFile, handleDownload: handleDownload, dispatch: dispatch }))))),
30
- React.createElement(Element, { className: 'element' },
31
- fileTypesWithIconMap.get(file.type),
32
- React.createElement(FileInfoContainer, null,
33
- React.createElement(FileNameTitleContainer, null,
34
- React.createElement(FileTitle, null, file.label))))));
49
+ return (React.createElement(Element, { key: index, id: element.modelId, onClick: onElementClick },
50
+ React.createElement(ElementLabelContainer, null,
51
+ getFileTypeIcon(element.type),
52
+ React.createElement(ElementLabel, null, element.label)),
53
+ React.createElement(ElementFilesContainer, null, (_a = element.files) === null || _a === void 0 ? void 0 : _a.map((file) => (React.createElement(ElementFile, { key: file.modelId, file: file, handleReplace: (f) => __awaiter(void 0, void 0, void 0, function* () { return yield replace(element, file, f); }), handleDetach: () => __awaiter(void 0, void 0, void 0, function* () { return yield detach(element, file); }), handleDownload: () => fileManagement.download(file) }))))));
35
54
  })));
36
55
  };
37
- const FileReference = ({ attachment, handleReplace, handleDownload, handleUpdateInline, handleDetachFile, dispatch, }) => {
38
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
39
- if (!attachment || !attachment.name) {
40
- return null;
41
- }
42
- const fileExtension = attachment.name.substring(attachment.name.lastIndexOf('.') + 1);
43
- return (React.createElement(FileReferenceItem, { key: attachment.id },
44
- React.createElement(Container, null,
45
- fileTypesWithIconMap.get(extensionsWithFileTypesMap.get(fileExtension)),
46
- React.createElement(FileReferenceName, null, attachment.name)),
47
- attachment.createdDate && (React.createElement(FileDateContainer, { "data-tip": "tooltip-content" },
48
- React.createElement(FileDate, null, format(new Date(attachment.createdDate), 'M/d/yy, HH:mm')),
49
- React.createElement(ReactTooltip, { place: "bottom", offset: { top: 0 }, effect: "solid", className: "tooltip" }, "File Uploaded"))),
50
- handleDownload && handleReplace && (React.createElement(DropdownContainer, { ref: wrapperRef },
51
- React.createElement(ActionsIcon, { onClick: toggleOpen, type: "button", className: 'external_file_dropdown', "aria-label": "Download or Replace or Detach", "aria-pressed": isOpen },
52
- React.createElement(DotsIcon, null)),
53
- isOpen && (React.createElement(ItemActions, { fileSection: FileSectionType.Inline, replaceAttachmentHandler: handleReplace, showReplaceAction: true, handleUpdateInline: (uploadAttachment) => handleUpdateInline &&
54
- (attachment === null || attachment === void 0 ? void 0 : attachment.modelId) &&
55
- handleUpdateInline(attachment.modelId, uploadAttachment), detachAttachmnetHandler: () => handleDetachFile &&
56
- attachment.modelId &&
57
- handleDetachFile(attachment.id, attachment.modelId), downloadAttachmentHandler: handleDownload, attachmentId: attachment.id, fileName: attachment.name, publicUrl: attachment.link, hideActionList: toggleOpen, dispatch: dispatch, dropDownClassName: 'ref_item_dropdown' }))))));
56
+ const ElementFile = ({ file, handleReplace, handleDownload, handleDetach }) => {
57
+ return (React.createElement(ModelFileContainer, null,
58
+ React.createElement(FileName, { file: file }),
59
+ React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
60
+ React.createElement(FileActions, { sectionType: FileSectionType.Inline, handleDownload: file.id ? handleDownload : undefined, handleDetach: file.id ? handleDetach : undefined, handleReplace: handleReplace })));
58
61
  };
59
- export const FileDateContainer = styled.div `
60
- overflow: hidden;
61
- display: none;
62
- width: 100%;
63
- justify-content: flex-end;
64
- `;
65
- const ElementItem = styled(Item) `
62
+ const Element = styled.div `
66
63
  display: flex;
67
- // this will allow us to select the previous sibling node,
68
- // to change the background on the hover for adjacent node
69
- flex-direction: column-reverse;
64
+ flex-direction: column;
70
65
  padding: 0;
71
66
 
72
- :hover {
73
- background: #f2fbfc;
74
- }
75
-
76
- .refItems:hover ~ .element {
77
- background: white !important;
78
- }
79
- &:hover ${FileDateContainer} {
80
- display: flex;
81
- }
67
+ border-bottom: 1px dashed #f0f0f0;
82
68
 
83
- .refItems:hover {
84
- background: white !important;
69
+ svg {
70
+ width: 24px;
85
71
  }
86
72
 
87
- border-bottom: 1px dashed #f0f0f0;
88
-
89
73
  :last-child {
90
74
  border-bottom: 0;
91
75
  }
92
76
  `;
93
- const Container = styled.div `
77
+ const ElementLabelContainer = styled.div `
94
78
  display: flex;
95
- width: 100%;
79
+ padding: 20px 16px;
80
+ cursor: pointer;
96
81
  `;
97
- const Element = styled.div `
98
- display: flex;
99
- padding: 20px 15px;
100
- `;
101
- const FileReferences = styled.div `
102
- display: flex;
103
- align-items: center;
104
- justify-content: space-between;
105
- width: 100%;
82
+ const ElementLabel = styled.div `
83
+ color: ${(props) => props.theme.colors.text.primary};
84
+ font-weight: bold;
85
+ font-size: 16px;
86
+ line-height: 20px;
87
+ white-space: nowrap;
88
+ margin-left: ${(props) => props.theme.grid.unit * 2}px;
106
89
  `;
107
- const FileReferenceItem = styled.div `
108
- display: flex;
90
+ const ElementFilesContainer = styled.div `
109
91
  width: 100%;
110
- align-items: space;
111
- justify-content: space-between;
112
- width: 100% svg {
113
- width: 14px;
114
- height: 17px;
92
+ > :last-child {
93
+ margin-bottom: 25px;
115
94
  }
95
+ `;
96
+ const ModelFileContainer = styled(FileContainer) `
97
+ padding: 8px 16px;
98
+ height: 40px;
116
99
 
117
100
  path {
118
101
  fill: #6e6e6e;
119
102
  }
120
-
121
- padding: ${(props) => props.theme.grid.unit * 2}px
122
- ${(props) => props.theme.grid.unit * 4}px;
123
-
124
- :hover {
125
- background: #f2fbfc;
126
- }
127
-
128
- .external_file_dropdown {
129
- opacity: 0;
130
- }
131
- :hover .external_file_dropdown {
132
- opacity: 1;
133
- }
134
-
135
- .ref_item_dropdown {
136
- top: 65%;
137
- right: 10px;
138
- width: 180px;
139
- }
140
- :last-child {
141
- margin-bottom: 25px;
142
- }
143
- `;
144
- const FileReferenceName = styled.div `
145
- font-family: ${(props) => props.theme.font.family.Lato};
146
- font-size: ${(props) => props.theme.font.size.medium};
147
- line-height: ${(props) => props.theme.font.lineHeight.large};
148
- font-weight: ${(props) => props.theme.font.weight.normal};
149
- color: ${(props) => props.theme.colors.text.primary};
150
- margin-left: ${(props) => props.theme.grid.unit * 2}px;
151
- `;
152
- const DropdownContainer = styled.div `
153
- position: relative;
154
- `;
155
- export const FileDate = styled.div `
156
- font-size: ${(props) => props.theme.font.size.small};
157
- line-height: 27px;
158
103
  `;
@@ -0,0 +1,74 @@
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
+ };
@@ -0,0 +1,91 @@
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,6 +1,7 @@
1
+ import ReactTooltip from 'react-tooltip';
1
2
  import styled from 'styled-components';
2
- export const TooltipDiv = styled.div `
3
- .tooltip {
3
+ export const Tooltip = styled(ReactTooltip) `
4
+ &.tooltip {
4
5
  font-size: 12px;
5
6
  line-height: 16px;
6
7
  font-family: ${(props) => props.theme.font.family.Lato};
@@ -11,5 +12,9 @@ export const TooltipDiv = styled.div `
11
12
  text-align: center;
12
13
  white-space: nowrap;
13
14
  pointer-events: none;
15
+
16
+ &.place-bottom::after {
17
+ background: #353535;
18
+ }
14
19
  }
15
20
  `;