@manuscripts/style-guide 1.13.15 → 1.13.16
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.
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/lib/files.js +125 -77
- package/dist/es/index.js +0 -3
- package/dist/es/lib/files.js +117 -73
- package/dist/types/index.d.ts +0 -3
- package/dist/types/lib/files.d.ts +19 -24
- package/package.json +1 -1
- package/dist/cjs/components/FileManager/FileActions.js +0 -134
- package/dist/cjs/components/FileManager/FileContainer.js +0 -39
- package/dist/cjs/components/FileManager/FileCreatedDate.js +0 -25
- package/dist/cjs/components/FileManager/FileManager.js +0 -60
- package/dist/cjs/components/FileManager/FileManagerDragLayer.js +0 -55
- package/dist/cjs/components/FileManager/FileManagerProvider.js +0 -39
- package/dist/cjs/components/FileManager/FileName.js +0 -27
- package/dist/cjs/components/FileManager/FileSectionAlert.js +0 -170
- package/dist/cjs/components/FileManager/FileTypeIcon.js +0 -20
- package/dist/cjs/components/FileManager/FileUploader.js +0 -85
- package/dist/cjs/components/FileManager/InlineFilesSection.js +0 -133
- package/dist/cjs/components/FileManager/OtherFilesSection.js +0 -101
- package/dist/cjs/components/FileManager/SupplementsSection.js +0 -118
- package/dist/cjs/components/FileManager/index.js +0 -32
- package/dist/cjs/components/FileManager/util.js +0 -138
- package/dist/cjs/hooks/use-files.js +0 -39
- package/dist/es/components/FileManager/FileActions.js +0 -104
- package/dist/es/components/FileManager/FileContainer.js +0 -33
- package/dist/es/components/FileManager/FileCreatedDate.js +0 -18
- package/dist/es/components/FileManager/FileManager.js +0 -33
- package/dist/es/components/FileManager/FileManagerDragLayer.js +0 -48
- package/dist/es/components/FileManager/FileManagerProvider.js +0 -12
- package/dist/es/components/FileManager/FileName.js +0 -20
- package/dist/es/components/FileManager/FileSectionAlert.js +0 -163
- package/dist/es/components/FileManager/FileTypeIcon.js +0 -13
- package/dist/es/components/FileManager/FileUploader.js +0 -58
- package/dist/es/components/FileManager/InlineFilesSection.js +0 -103
- package/dist/es/components/FileManager/OtherFilesSection.js +0 -74
- package/dist/es/components/FileManager/SupplementsSection.js +0 -91
- package/dist/es/components/FileManager/index.js +0 -16
- package/dist/es/components/FileManager/util.js +0 -128
- package/dist/es/hooks/use-files.js +0 -35
- package/dist/types/components/FileManager/FileActions.d.ts +0 -19
- package/dist/types/components/FileManager/FileContainer.d.ts +0 -1
- package/dist/types/components/FileManager/FileCreatedDate.d.ts +0 -8
- package/dist/types/components/FileManager/FileManager.d.ts +0 -30
- package/dist/types/components/FileManager/FileManagerDragLayer.d.ts +0 -2
- package/dist/types/components/FileManager/FileManagerProvider.d.ts +0 -15
- package/dist/types/components/FileManager/FileName.d.ts +0 -6
- package/dist/types/components/FileManager/FileSectionAlert.d.ts +0 -13
- package/dist/types/components/FileManager/FileTypeIcon.d.ts +0 -5
- package/dist/types/components/FileManager/FileUploader.d.ts +0 -5
- package/dist/types/components/FileManager/InlineFilesSection.d.ts +0 -6
- package/dist/types/components/FileManager/OtherFilesSection.d.ts +0 -5
- package/dist/types/components/FileManager/SupplementsSection.d.ts +0 -5
- package/dist/types/components/FileManager/index.d.ts +0 -16
- package/dist/types/components/FileManager/util.d.ts +0 -25
- package/dist/types/hooks/use-files.d.ts +0 -8
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useDragLayer } from 'react-dnd';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { FileContainer } from './FileContainer';
|
|
5
|
-
import { FileCreatedDate } from './FileCreatedDate';
|
|
6
|
-
import { FileName } from './FileName';
|
|
7
|
-
const Container = styled.div `
|
|
8
|
-
position: fixed;
|
|
9
|
-
pointer-events: none;
|
|
10
|
-
z-index: 999;
|
|
11
|
-
left: 0;
|
|
12
|
-
top: 0;
|
|
13
|
-
max-width: 400px;
|
|
14
|
-
`;
|
|
15
|
-
const DraggableFileContainer = styled(FileContainer) `
|
|
16
|
-
padding: 16px 32px;
|
|
17
|
-
background: #f2fbfc;
|
|
18
|
-
border: 1px solid #bce7f6;
|
|
19
|
-
box-shadow: 0 4px 9px rgba(0, 0, 0, 0.3);
|
|
20
|
-
border-radius: 6px;
|
|
21
|
-
`;
|
|
22
|
-
const getItemStyles = (currentOffset) => {
|
|
23
|
-
if (!currentOffset) {
|
|
24
|
-
return {
|
|
25
|
-
display: 'none',
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const { x, y } = currentOffset;
|
|
29
|
-
const transform = `translate(${x}px, ${y}px)`;
|
|
30
|
-
return {
|
|
31
|
-
transform,
|
|
32
|
-
WebkitTransform: transform,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export const FileManagerDragLayer = () => {
|
|
36
|
-
const { itemType, isDragging, item, currentOffset } = useDragLayer((monitor) => ({
|
|
37
|
-
item: monitor.getItem(),
|
|
38
|
-
itemType: monitor.getItemType(),
|
|
39
|
-
currentOffset: monitor.getSourceClientOffset(),
|
|
40
|
-
isDragging: monitor.isDragging(),
|
|
41
|
-
}));
|
|
42
|
-
if (!isDragging) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
return (React.createElement(Container, { style: getItemStyles(currentOffset) }, itemType === 'file' && (React.createElement(DraggableFileContainer, null,
|
|
46
|
-
React.createElement(FileName, { file: item.file }),
|
|
47
|
-
item.file.createdDate && React.createElement(FileCreatedDate, { file: item.file })))));
|
|
48
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React, { createContext } from 'react';
|
|
2
|
-
export const FileManagerContext = createContext({
|
|
3
|
-
saveModel: () => '',
|
|
4
|
-
});
|
|
5
|
-
export const FileManagerProvider = ({ children, saveModel, deleteModel, modelMap, fileManagement }) => {
|
|
6
|
-
return (React.createElement(FileManagerContext.Provider, { value: {
|
|
7
|
-
saveModel,
|
|
8
|
-
deleteModel,
|
|
9
|
-
modelMap,
|
|
10
|
-
fileManagement,
|
|
11
|
-
} }, children));
|
|
12
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { FileTypeIcon } from './FileTypeIcon';
|
|
4
|
-
export const FileName = ({ file }) => {
|
|
5
|
-
return (React.createElement(React.Fragment, null,
|
|
6
|
-
React.createElement(FileTypeIcon, { file: file }),
|
|
7
|
-
React.createElement(FileNameText, { "data-cy": "filename" }, file.name)));
|
|
8
|
-
};
|
|
9
|
-
export const FileNameText = styled.div `
|
|
10
|
-
font-family: ${(props) => props.theme.font.family.Lato};
|
|
11
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
12
|
-
line-height: ${(props) => props.theme.font.lineHeight.large};
|
|
13
|
-
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
14
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
15
|
-
margin-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
16
|
-
flex-grow: 1;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
text-overflow: ellipsis;
|
|
20
|
-
`;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { AlertMessage, AlertMessageType } from '../AlertMessage';
|
|
4
|
-
import { FileUnknownIcon } from '../icons';
|
|
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(FileUnknownIcon, null),
|
|
23
|
-
React.createElement(FileUploadNameContainer, null,
|
|
24
|
-
React.createElement(UploadFileNameText, null, name),
|
|
25
|
-
React.createElement(FileUploadProgressBar, null))));
|
|
26
|
-
};
|
|
27
|
-
const FileUploadSuccessful = () => {
|
|
28
|
-
return (React.createElement(AlertMessageContainer, null,
|
|
29
|
-
React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
|
|
30
|
-
text: 'OK',
|
|
31
|
-
} }, "File uploaded successfully")));
|
|
32
|
-
};
|
|
33
|
-
const FileMoveSuccessful = ({ name }) => {
|
|
34
|
-
return (React.createElement(AlertMessageContainer, null,
|
|
35
|
-
React.createElement(AlertMessage, { type: AlertMessageType.success, hideCloseButton: true, dismissButton: {
|
|
36
|
-
text: 'OK',
|
|
37
|
-
} },
|
|
38
|
-
"File moved to ",
|
|
39
|
-
name)));
|
|
40
|
-
};
|
|
41
|
-
const AlertMessageContainer = styled.div `
|
|
42
|
-
margin-left: 16px;
|
|
43
|
-
margin-right: 16px;
|
|
44
|
-
`;
|
|
45
|
-
const FileUploadContainer = styled(FileContainer) `
|
|
46
|
-
background: #f2fbfc;
|
|
47
|
-
`;
|
|
48
|
-
const FileUploadNameContainer = styled.div `
|
|
49
|
-
flex-grow: 1;
|
|
50
|
-
margin-left: 8px;
|
|
51
|
-
`;
|
|
52
|
-
const UploadFileNameText = styled(FileNameText) `
|
|
53
|
-
margin: 0;
|
|
54
|
-
`;
|
|
55
|
-
const FileUploadProgressBar = () => {
|
|
56
|
-
return (React.createElement(LinearProgress, null,
|
|
57
|
-
React.createElement(Bar, { className: "bar1" }),
|
|
58
|
-
React.createElement(Bar, { className: "bar2" })));
|
|
59
|
-
};
|
|
60
|
-
const LinearProgress = styled.div `
|
|
61
|
-
background: ${(props) => props.theme.colors.background.tertiary};
|
|
62
|
-
opacity: 0.7;
|
|
63
|
-
height: 4px;
|
|
64
|
-
position: relative;
|
|
65
|
-
width: 100%;
|
|
66
|
-
margin: 8px auto 0;
|
|
67
|
-
overflow: hidden;
|
|
68
|
-
border-radius: 8px;
|
|
69
|
-
animation: start 0.3s ease-in;
|
|
70
|
-
`;
|
|
71
|
-
const Bar = styled.div `
|
|
72
|
-
position: absolute;
|
|
73
|
-
opacity: 0.7;
|
|
74
|
-
background: #1a9bc7;
|
|
75
|
-
transition: transform 0.2s linear;
|
|
76
|
-
left: 0;
|
|
77
|
-
top: 0;
|
|
78
|
-
bottom: 0;
|
|
79
|
-
width: 100%;
|
|
80
|
-
|
|
81
|
-
&.bar1 {
|
|
82
|
-
animation: growBar1 2.5s infinite, moveBar1 2.5s infinite;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&.bar2 {
|
|
86
|
-
animation: growBar2 2.5s infinite, moveBar2 2.5s infinite;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@keyframes growBar1 {
|
|
90
|
-
0% {
|
|
91
|
-
animation-timing-function: linear;
|
|
92
|
-
transform: scaleX(0.1);
|
|
93
|
-
}
|
|
94
|
-
35% {
|
|
95
|
-
animation-timing-function: cubic-bezier(0.3, 0.1, 0.7, 1);
|
|
96
|
-
transform: scaleX(0.1);
|
|
97
|
-
}
|
|
98
|
-
70% {
|
|
99
|
-
animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
|
|
100
|
-
transform: scaleX(0.8);
|
|
101
|
-
}
|
|
102
|
-
100% {
|
|
103
|
-
transform: scaleX(0.1);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
@keyframes moveBar1 {
|
|
108
|
-
0% {
|
|
109
|
-
left: -105%;
|
|
110
|
-
animation-timing-function: linear;
|
|
111
|
-
}
|
|
112
|
-
20% {
|
|
113
|
-
left: -105%;
|
|
114
|
-
animation-timing-function: cubic-bezier(0.5, 0, 0.7, 0.4);
|
|
115
|
-
}
|
|
116
|
-
60% {
|
|
117
|
-
left: 21%;
|
|
118
|
-
animation-timing-function: cubic-bezier(0.3, 0.4, 0.55, 0.9);
|
|
119
|
-
}
|
|
120
|
-
80% {
|
|
121
|
-
left: 40%;
|
|
122
|
-
animation-timing-function: cubic-bezier(0.1, 0.2, 0.3, 0.95);
|
|
123
|
-
}
|
|
124
|
-
100% {
|
|
125
|
-
left: 90%;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@keyframes growBar2 {
|
|
130
|
-
0% {
|
|
131
|
-
animation-timing-function: cubic-bezier(0.2, 0, 0.5, 0.4);
|
|
132
|
-
transform: scaleX(0.1);
|
|
133
|
-
}
|
|
134
|
-
20% {
|
|
135
|
-
animation-timing-function: cubic-bezier(0.1, 0.2, 0.6, 1);
|
|
136
|
-
transform: scaleX(0.3);
|
|
137
|
-
}
|
|
138
|
-
60% {
|
|
139
|
-
animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1.4);
|
|
140
|
-
transform: scaleX(0.6);
|
|
141
|
-
}
|
|
142
|
-
100% {
|
|
143
|
-
transform: scaleX(0.1);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
@keyframes moveBar2 {
|
|
147
|
-
0% {
|
|
148
|
-
left: -100%;
|
|
149
|
-
animation-timing-function: cubic-bezier(0.15, 0, 0.5, 0.4);
|
|
150
|
-
}
|
|
151
|
-
25% {
|
|
152
|
-
left: -50%;
|
|
153
|
-
animation-timing-function: cubic-bezier(0.3, 0.3, 0.8, 0.7);
|
|
154
|
-
}
|
|
155
|
-
50% {
|
|
156
|
-
left: 45%;
|
|
157
|
-
animation-timing-function: cubic-bezier(0.1, 0.6, 0.6, 0.9);
|
|
158
|
-
}
|
|
159
|
-
100% {
|
|
160
|
-
left: 95%;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FileCorruptedIcon, FileMainDocumentIcon, FileUnknownIcon, } from '../icons';
|
|
3
|
-
import { getFileIcon } from './util';
|
|
4
|
-
export const FileTypeIcon = ({ file }) => {
|
|
5
|
-
if (file.type.id === 'missing') {
|
|
6
|
-
return React.createElement(FileCorruptedIcon, { className: "file-icon" });
|
|
7
|
-
}
|
|
8
|
-
if (file.type.id === 'main-manuscript') {
|
|
9
|
-
return React.createElement(FileMainDocumentIcon, { className: "file-icon" });
|
|
10
|
-
}
|
|
11
|
-
const icon = getFileIcon(file);
|
|
12
|
-
return icon || React.createElement(FileUnknownIcon, { className: "file-icon" });
|
|
13
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { useDrop } from 'react-dnd';
|
|
3
|
-
import { NativeTypes } from 'react-dnd-html5-backend';
|
|
4
|
-
import styled, { css } from 'styled-components';
|
|
5
|
-
export const FileUploader = ({ onUpload }) => {
|
|
6
|
-
const fileInputRef = useRef(null);
|
|
7
|
-
const openFileDialog = () => {
|
|
8
|
-
if (fileInputRef && fileInputRef.current) {
|
|
9
|
-
fileInputRef.current.click();
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
const handleChange = (event) => {
|
|
13
|
-
if (event && event.target && event.target.files) {
|
|
14
|
-
const file = event.target.files[0];
|
|
15
|
-
onUpload(file);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const [{ canDrop, isOver }, dropRef] = useDrop({
|
|
19
|
-
accept: [NativeTypes.FILE],
|
|
20
|
-
drop: (item) => {
|
|
21
|
-
const file = item.files[0];
|
|
22
|
-
onUpload(file);
|
|
23
|
-
},
|
|
24
|
-
collect: (monitor) => ({
|
|
25
|
-
isOver: monitor.isOver(),
|
|
26
|
-
canDrop: monitor.canDrop(),
|
|
27
|
-
}),
|
|
28
|
-
});
|
|
29
|
-
const isActive = canDrop && isOver;
|
|
30
|
-
return (React.createElement(Container, { ref: dropRef, "data-cy": "file-uploader", active: isActive, onClick: openFileDialog },
|
|
31
|
-
React.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange, value: '' }),
|
|
32
|
-
"Drag or click to upload a new file"));
|
|
33
|
-
};
|
|
34
|
-
const activeBoxStyle = css `
|
|
35
|
-
background: #f2fbfc;
|
|
36
|
-
border: 1px dashed #bce7f6;
|
|
37
|
-
`;
|
|
38
|
-
const Container = styled.div `
|
|
39
|
-
background: ${(props) => props.theme.colors.background.secondary};
|
|
40
|
-
border: 1px dashed #e2e2e2;
|
|
41
|
-
box-sizing: border-box;
|
|
42
|
-
border-radius: 8px;
|
|
43
|
-
height: 80px;
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
justify-content: center;
|
|
47
|
-
font-size: 14px;
|
|
48
|
-
line-height: 24px;
|
|
49
|
-
font-family: ${(props) => props.theme.font.family.Lato};
|
|
50
|
-
color: ${(props) => props.theme.colors.text.onLight};
|
|
51
|
-
cursor: pointer;
|
|
52
|
-
margin: 16px 16px 8px;
|
|
53
|
-
${(props) => props.active
|
|
54
|
-
? css `
|
|
55
|
-
${activeBoxStyle}
|
|
56
|
-
`
|
|
57
|
-
: css ``}
|
|
58
|
-
`;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import React, { useCallback, useContext } from 'react';
|
|
11
|
-
import styled from 'styled-components';
|
|
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';
|
|
18
|
-
const trackedJoint = ':dataTracked:';
|
|
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
|
-
};
|
|
26
|
-
const onElementClick = useCallback((e) => {
|
|
27
|
-
if (!isEditor) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
navigateToElement(e.currentTarget.id);
|
|
31
|
-
}, [isEditor]);
|
|
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) => {
|
|
48
|
-
var _a;
|
|
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, { "data-cy": "file-elements-container" }, (_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) }))))));
|
|
54
|
-
})));
|
|
55
|
-
};
|
|
56
|
-
const ElementFile = ({ file, handleReplace, handleDownload, handleDetach }) => {
|
|
57
|
-
return (React.createElement(ModelFileContainer, { "data-cy": "file-container" },
|
|
58
|
-
React.createElement(FileName, { file: file }),
|
|
59
|
-
React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
60
|
-
React.createElement(FileActions, { "data-cy": "file-actions", sectionType: FileSectionType.Inline, handleDownload: file.id ? handleDownload : undefined, handleDetach: file.id ? handleDetach : undefined, handleReplace: handleReplace })));
|
|
61
|
-
};
|
|
62
|
-
const Element = styled.div `
|
|
63
|
-
display: flex;
|
|
64
|
-
flex-direction: column;
|
|
65
|
-
padding: 0;
|
|
66
|
-
|
|
67
|
-
border-bottom: 1px dashed #f0f0f0;
|
|
68
|
-
|
|
69
|
-
svg {
|
|
70
|
-
width: 24px;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
:last-child {
|
|
74
|
-
border-bottom: 0;
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
const ElementLabelContainer = styled.div `
|
|
78
|
-
display: flex;
|
|
79
|
-
padding: 20px 16px;
|
|
80
|
-
cursor: pointer;
|
|
81
|
-
`;
|
|
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;
|
|
89
|
-
`;
|
|
90
|
-
const ElementFilesContainer = styled.div `
|
|
91
|
-
width: 100%;
|
|
92
|
-
> :last-child {
|
|
93
|
-
margin-bottom: 25px;
|
|
94
|
-
}
|
|
95
|
-
`;
|
|
96
|
-
const ModelFileContainer = styled(FileContainer) `
|
|
97
|
-
padding: 8px 16px;
|
|
98
|
-
height: 40px;
|
|
99
|
-
|
|
100
|
-
path {
|
|
101
|
-
fill: #6e6e6e;
|
|
102
|
-
}
|
|
103
|
-
`;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { buildSupplement } from '@manuscripts/json-schema';
|
|
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 handleUpload = (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 = buildSupplement('', 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, { onUpload: handleUpload }),
|
|
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 }, dragRef, preview] = useDrag({
|
|
56
|
-
type: 'file',
|
|
57
|
-
item: {
|
|
58
|
-
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, "data-cy": "file-container", ref: dragRef, className: isDragging ? 'dragging' : '' },
|
|
68
|
-
React.createElement(FileName, { file: file }),
|
|
69
|
-
React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
70
|
-
React.createElement(FileActions, { sectionType: FileSectionType.OtherFile, handleDownload: handleDownload, move: {
|
|
71
|
-
sectionType: FileSectionType.Supplements,
|
|
72
|
-
handler: handleMoveToSupplements,
|
|
73
|
-
} })));
|
|
74
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { buildSupplement, ObjectTypes, } from '@manuscripts/json-schema';
|
|
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 SupplementsSection = ({ supplements }) => {
|
|
24
|
-
const { modelMap, saveModel, deleteModel, fileManagement } = 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
|
-
const uploaded = yield fileManagement.upload(file);
|
|
36
|
-
setAlert({
|
|
37
|
-
type: FileSectionAlertType.UPLOAD_SUCCESSFUL,
|
|
38
|
-
message: '',
|
|
39
|
-
});
|
|
40
|
-
return uploaded;
|
|
41
|
-
});
|
|
42
|
-
const handleUpload = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
const uploaded = yield upload(file);
|
|
44
|
-
const supplement = buildSupplement('', uploaded.id);
|
|
45
|
-
yield saveModel(Object.assign(Object.assign({}, supplement), { MIME: file.type }));
|
|
46
|
-
});
|
|
47
|
-
const handleReplace = (modelId, file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
const uploaded = yield upload(file);
|
|
49
|
-
const supplement = buildSupplement('', uploaded.id);
|
|
50
|
-
yield deleteModel(modelId);
|
|
51
|
-
yield saveModel(Object.assign(Object.assign({}, supplement), { MIME: file.type }));
|
|
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, { onUpload: 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 }, dragRef, preview] = useDrag({
|
|
67
|
-
type: 'file',
|
|
68
|
-
item: {
|
|
69
|
-
file,
|
|
70
|
-
model: {
|
|
71
|
-
_id: file.modelId,
|
|
72
|
-
objectType: ObjectTypes.Supplement,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
collect: (monitor) => ({
|
|
76
|
-
isDragging: monitor.isDragging(),
|
|
77
|
-
}),
|
|
78
|
-
});
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
preview(getEmptyImage());
|
|
81
|
-
}, [preview]);
|
|
82
|
-
return (React.createElement(FileContainer, { "data-cy": "file-container", key: file.id, ref: dragRef, className: isDragging ? 'dragging' : '' },
|
|
83
|
-
React.createElement(FileName, { file: file }),
|
|
84
|
-
React.createElement(FileCreatedDate, { file: file, className: "show-on-hover" }),
|
|
85
|
-
React.createElement(FileActions, { "data-cy": "file-actions", 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,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
export * from './FileManager';
|