@manuscripts/style-guide 1.3.5 → 1.3.6

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