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