@manuscripts/style-guide 1.0.7 → 1.0.8-LEAN-2299

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 (25) hide show
  1. package/dist/cjs/components/AuthorForm/AuthorForm.js +2 -18
  2. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +3 -3
  3. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +1 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/lib/capabilities.js +13 -15
  6. package/dist/es/components/AuthorForm/AuthorForm.js +3 -19
  7. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +3 -3
  8. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +1 -1
  9. package/dist/es/index.js +1 -1
  10. package/dist/es/lib/capabilities.js +11 -13
  11. package/dist/types/components/FileManager/FileManager.d.ts +5 -5
  12. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +1 -1
  13. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +4 -4
  14. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +2 -2
  15. package/dist/types/components/FileManager/InlineFilesSection.d.ts +3 -3
  16. package/dist/types/components/FileManager/util.d.ts +3 -3
  17. package/dist/types/hooks/use-files.d.ts +4 -4
  18. package/dist/types/index.d.ts +1 -1
  19. package/dist/types/lib/capabilities.d.ts +3 -4
  20. package/dist/types/lib/inlineFiles.d.ts +3 -3
  21. package/dist/types/types.d.ts +0 -1
  22. package/package.json +1 -1
  23. /package/dist/cjs/lib/{lw-errors-decoder.js → errors-decoder.js} +0 -0
  24. /package/dist/es/lib/{lw-errors-decoder.js → errors-decoder.js} +0 -0
  25. /package/dist/types/lib/{lw-errors-decoder.d.ts → errors-decoder.d.ts} +0 -0
@@ -36,7 +36,6 @@ const Checkbox_1 = require("../Checkbox");
36
36
  const TextField_1 = require("../TextField");
37
37
  const TextFieldGroupContainer_1 = require("../TextFieldGroupContainer");
38
38
  const AuthorFormComponents_1 = require("./AuthorFormComponents");
39
- const ContributorRolesSelect_1 = require("./ContributorRolesSelect");
40
39
  const RemoveAuthorButton_1 = __importDefault(require("./RemoveAuthorButton"));
41
40
  const ensureString = (value) => value || '';
42
41
  const buildInitialValues = (author) => {
@@ -45,7 +44,6 @@ const buildInitialValues = (author) => {
45
44
  priority: Number(author.priority),
46
45
  email: ensureString(author.email),
47
46
  isCorresponding: Boolean(author.isCorresponding),
48
- isJointContributor: Boolean(author.isJointContributor),
49
47
  bibliographicName: {
50
48
  _id: author.bibliographicName._id,
51
49
  objectType: author.bibliographicName.objectType,
@@ -65,7 +63,7 @@ const OrcidContainer = styled_components_1.default.div `
65
63
  const RolesContainer = styled_components_1.default.div `
66
64
  margin: 16px 0;
67
65
  `;
68
- const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpen, handleRemoveAuthor, components, contributorRoles = [], createContributorRole, }) => {
66
+ const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpen, handleRemoveAuthor, components, }) => {
69
67
  const { Legend, TextField } = Object.assign(Object.assign({}, AuthorFormComponents_1.defaultAuthorFormComponents), components);
70
68
  return (react_1.default.createElement(formik_1.Formik, { initialValues: buildInitialValues(author), onSubmit: handleSave, enableReinitialize: true }, ({ values }) => {
71
69
  const isAuthor = values.role === 'author';
@@ -85,9 +83,6 @@ const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpen, hand
85
83
  react_1.default.createElement(AuthorFormComponents_1.LabelText, null, "Corresponding Author")),
86
84
  values.isCorresponding && (react_1.default.createElement(AuthorFormComponents_1.Label, null,
87
85
  react_1.default.createElement(formik_1.Field, { name: 'email', type: 'email' }, (props) => (react_1.default.createElement(AutoSaveInput_1.AutoSaveInput, Object.assign({}, props, { disabled: !isAuthor, component: TextField, saveOn: 'blur', placeholder: 'Email address', testId: "corresponding-email" })))))),
88
- react_1.default.createElement(Checkbox_1.CheckboxLabel, { disabled: !isAuthor },
89
- react_1.default.createElement(formik_1.Field, { name: 'isJointContributor' }, (props) => (react_1.default.createElement(AutoSaveInput_1.AutoSaveInput, Object.assign({}, props, { disabled: !isAuthor, component: Checkbox_1.CheckboxField, saveOn: 'change' })))),
90
- react_1.default.createElement(AuthorFormComponents_1.LabelText, null, "Joint Authorship with Next Author")),
91
86
  react_1.default.createElement(Checkbox_1.CheckboxLabel, null,
92
87
  react_1.default.createElement(formik_1.Field, { name: 'role', type: 'checkbox' }, (props) => (react_1.default.createElement(Checkbox_1.CheckboxField, { name: 'role', checked: isAuthor, onChange: (event) => __awaiter(void 0, void 0, void 0, function* () {
93
88
  props.form.setFieldValue(props.field.name, event.target.checked ? 'author' : 'other', false);
@@ -97,18 +92,7 @@ const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpen, hand
97
92
  react_1.default.createElement(OrcidContainer, null,
98
93
  react_1.default.createElement(TextField_1.TextFieldLabel, null,
99
94
  react_1.default.createElement(AuthorFormComponents_1.LabelText, null, "ORCID"),
100
- react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(AutoSaveInput_1.AutoSaveInput, Object.assign({}, props, { component: TextField, saveOn: 'blur', placeholder: 'https://orcid.org/...', testId: "bibliographic-name-family" }))))))),
101
- createContributorRole && (react_1.default.createElement(AuthorFormComponents_1.Fieldset, null,
102
- react_1.default.createElement(Legend, null, "Contributions"),
103
- react_1.default.createElement(formik_1.Field, { name: 'roles' }, (props) => (react_1.default.createElement(RolesContainer, null,
104
- react_1.default.createElement(ContributorRolesSelect_1.ContributorRolesSelect, { contributorRoles: contributorRoles, createContributorRole: createContributorRole, value: values.roles, setFieldValue: (value) => __awaiter(void 0, void 0, void 0, function* () {
105
- props.form.setFieldValue(props.field.name, value, false);
106
- yield props.form.submitForm();
107
- }) })))),
108
- react_1.default.createElement(formik_1.Field, { name: 'contribution' }, (props) => (react_1.default.createElement(TextField_1.TextArea, Object.assign({}, props.field, { onBlur: (event) => __awaiter(void 0, void 0, void 0, function* () {
109
- props.form.setFieldValue(props.field.name, event.target.value, false);
110
- yield props.form.submitForm();
111
- }), placeholder: 'If needed, describe contributions in more detail…' })))))))));
95
+ react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(AutoSaveInput_1.AutoSaveInput, Object.assign({}, props, { component: TextField, saveOn: 'blur', placeholder: 'https://orcid.org/...', testId: "bibliographic-name-family" }))))))))));
112
96
  }));
113
97
  };
114
98
  exports.AuthorForm = AuthorForm;
@@ -31,11 +31,11 @@ const react_1 = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
32
  const FileManager_1 = require("../FileManager");
33
33
  const DesignationActions_1 = require("./DesignationActions");
34
- const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
35
- const fileName = submissionAttachmentName.substring(0, submissionAttachmentName.lastIndexOf('.'));
34
+ const FileInfo = ({ showAttachmentName, showDesignationActions, title, fileAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
35
+ const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
36
36
  const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
37
37
  return (react_1.default.createElement(exports.FileInfoContainer, null,
38
- showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: submissionAttachmentName, dispatch: dispatch, can: can })),
38
+ showDesignationActions && designation !== undefined && (react_1.default.createElement(DesignationActions_1.DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: fileAttachmentName, dispatch: dispatch, can: can })),
39
39
  react_1.default.createElement(exports.FileNameTitleContainer, null,
40
40
  react_1.default.createElement(exports.FileTitle, null,
41
41
  !showAttachmentName ? fileName : title,
@@ -29,7 +29,7 @@ const FileSectionItem = ({ externalFile, title, showAttachmentName = false, show
29
29
  }
30
30
  } },
31
31
  react_1.default.createElement(FileTypeIcon_1.FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
32
- react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
32
+ react_1.default.createElement(FileInfo_1.FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, fileAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
33
33
  onClose && (react_1.default.createElement(IconCloseButton, { onClick: (e) => {
34
34
  e.preventDefault();
35
35
  onClose();
package/dist/cjs/index.js CHANGED
@@ -76,8 +76,8 @@ Object.defineProperty(exports, "useDeepCompareMemo", { enumerable: true, get: fu
76
76
  Object.defineProperty(exports, "useDeepCompareCallback", { enumerable: true, get: function () { return use_deep_compare_1.useDeepCompareCallback; } });
77
77
  __exportStar(require("./lib/authors"), exports);
78
78
  __exportStar(require("./lib/capabilities"), exports);
79
- var lw_errors_decoder_1 = require("./lib/lw-errors-decoder");
80
- Object.defineProperty(exports, "errorsDecoder", { enumerable: true, get: function () { return __importDefault(lw_errors_decoder_1).default; } });
79
+ var errors_decoder_1 = require("./lib/errors-decoder");
80
+ Object.defineProperty(exports, "errorsDecoder", { enumerable: true, get: function () { return __importDefault(errors_decoder_1).default; } });
81
81
  __exportStar(require("./types"), exports);
82
82
  var SelectDialogDesignation_1 = require("./components/FileManager/SelectDialogDesignation");
83
83
  Object.defineProperty(exports, "SelectDialogDesignation", { enumerable: true, get: function () { return SelectDialogDesignation_1.SelectDialogDesignation; } });
@@ -3,23 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CapabilitiesProvider = exports.useCalcPermission = exports.usePermissions = exports.getAllPermitted = exports.getLWCapabilities = void 0;
6
+ exports.CapabilitiesProvider = exports.useCalcPermission = exports.usePermissions = exports.getAllPermitted = exports.getCapabilities = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  var A;
9
9
  (function (A) {
10
- A["proceed"] = "proceed";
11
10
  A["updateAttachment"] = "update-attachment";
12
11
  A["updateDueDate"] = "update-due-date";
13
12
  A["addNote"] = "add-note";
14
13
  A["setMainManuscript"] = "set-main-manuscript";
15
14
  })(A || (A = {}));
16
- const getLWCapabilities = (project, profile, lwRole, actions) => {
15
+ const getCapabilities = (project, profile, role, actions) => {
17
16
  const isEditor = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.editors) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
18
17
  const isOwner = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.owners) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
19
18
  const isWriter = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.writers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
20
19
  const isAnnotator = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.annotators) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
21
20
  const isViewer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.viewers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
22
- const isLWProdEditor = () => lwRole == 'pe';
21
+ const isProdEditor = () => role == 'pe';
23
22
  const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
24
23
  return {
25
24
  handleSuggestion: isOwner() || isEditor() || isWriter(),
@@ -44,12 +43,11 @@ const getLWCapabilities = (project, profile, lwRole, actions) => {
44
43
  uploadFile: isOwner() || isEditor() || isWriter(),
45
44
  handleQualityReport: isOwner() || isEditor() || isWriter(),
46
45
  setMainManuscript: allowed(A.setMainManuscript),
47
- completeTask: !isViewer() && allowed(A.proceed),
48
- rejectTask: isLWProdEditor(),
49
- acceptTask: isLWProdEditor(),
50
- resolveOnHoldTask: isLWProdEditor(),
51
- putOnHoldTask: isLWProdEditor(),
52
- changeDueDate: isLWProdEditor() && allowed(A.updateDueDate),
46
+ rejectTask: isProdEditor(),
47
+ acceptTask: isProdEditor(),
48
+ resolveOnHoldTask: isProdEditor(),
49
+ putOnHoldTask: isProdEditor(),
50
+ changeDueDate: isProdEditor() && allowed(A.updateDueDate),
53
51
  previewAccess: true,
54
52
  editNotTracked: false,
55
53
  accessEditor: true,
@@ -59,9 +57,9 @@ const getLWCapabilities = (project, profile, lwRole, actions) => {
59
57
  shareProject: isOwner(),
60
58
  };
61
59
  };
62
- exports.getLWCapabilities = getLWCapabilities;
60
+ exports.getCapabilities = getCapabilities;
63
61
  const getAllPermitted = () => {
64
- const capabilities = (0, exports.getLWCapabilities)();
62
+ const capabilities = (0, exports.getCapabilities)();
65
63
  const allAllowed = Object.keys(capabilities).reduce((caps, item) => {
66
64
  caps[item] = true;
67
65
  return caps;
@@ -69,14 +67,14 @@ const getAllPermitted = () => {
69
67
  return allAllowed;
70
68
  };
71
69
  exports.getAllPermitted = getAllPermitted;
72
- const CapabilitiesContext = react_1.default.createContext((0, exports.getLWCapabilities)());
70
+ const CapabilitiesContext = react_1.default.createContext((0, exports.getCapabilities)());
73
71
  CapabilitiesContext.displayName = 'CapabilitiesContext';
74
72
  const usePermissions = () => {
75
73
  return react_1.default.useContext(CapabilitiesContext);
76
74
  };
77
75
  exports.usePermissions = usePermissions;
78
- const useCalcPermission = ({ project, profile, lwRole, permittedActions, }) => {
79
- return (0, exports.getLWCapabilities)(project, profile, lwRole, permittedActions);
76
+ const useCalcPermission = ({ project, profile, role, permittedActions, }) => {
77
+ return (0, exports.getCapabilities)(project, profile, role, permittedActions);
80
78
  };
81
79
  exports.useCalcPermission = useCalcPermission;
82
80
  const CapabilitiesProvider = (props) => {
@@ -27,10 +27,9 @@ import React from 'react';
27
27
  import styled from 'styled-components';
28
28
  import { AutoSaveInput } from '../AutoSaveInput';
29
29
  import { CheckboxField, CheckboxLabel } from '../Checkbox';
30
- import { TextArea, TextFieldLabel } from '../TextField';
30
+ import { TextFieldLabel } from '../TextField';
31
31
  import { TextFieldGroupContainer } from '../TextFieldGroupContainer';
32
32
  import { Container, defaultAuthorFormComponents, Fields, Fieldset, Label, LabelText, } from './AuthorFormComponents';
33
- import { ContributorRolesSelect } from './ContributorRolesSelect';
34
33
  import RemoveAuthorButton from './RemoveAuthorButton';
35
34
  const ensureString = (value) => value || '';
36
35
  const buildInitialValues = (author) => {
@@ -39,7 +38,6 @@ const buildInitialValues = (author) => {
39
38
  priority: Number(author.priority),
40
39
  email: ensureString(author.email),
41
40
  isCorresponding: Boolean(author.isCorresponding),
42
- isJointContributor: Boolean(author.isJointContributor),
43
41
  bibliographicName: {
44
42
  _id: author.bibliographicName._id,
45
43
  objectType: author.bibliographicName.objectType,
@@ -59,7 +57,7 @@ const OrcidContainer = styled.div `
59
57
  const RolesContainer = styled.div `
60
58
  margin: 16px 0;
61
59
  `;
62
- export const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpen, handleRemoveAuthor, components, contributorRoles = [], createContributorRole, }) => {
60
+ export const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpen, handleRemoveAuthor, components, }) => {
63
61
  const { Legend, TextField } = Object.assign(Object.assign({}, defaultAuthorFormComponents), components);
64
62
  return (React.createElement(Formik, { initialValues: buildInitialValues(author), onSubmit: handleSave, enableReinitialize: true }, ({ values }) => {
65
63
  const isAuthor = values.role === 'author';
@@ -79,9 +77,6 @@ export const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpe
79
77
  React.createElement(LabelText, null, "Corresponding Author")),
80
78
  values.isCorresponding && (React.createElement(Label, null,
81
79
  React.createElement(Field, { name: 'email', type: 'email' }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { disabled: !isAuthor, component: TextField, saveOn: 'blur', placeholder: 'Email address', testId: "corresponding-email" })))))),
82
- React.createElement(CheckboxLabel, { disabled: !isAuthor },
83
- React.createElement(Field, { name: 'isJointContributor' }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { disabled: !isAuthor, component: CheckboxField, saveOn: 'change' })))),
84
- React.createElement(LabelText, null, "Joint Authorship with Next Author")),
85
80
  React.createElement(CheckboxLabel, null,
86
81
  React.createElement(Field, { name: 'role', type: 'checkbox' }, (props) => (React.createElement(CheckboxField, { name: 'role', checked: isAuthor, onChange: (event) => __awaiter(void 0, void 0, void 0, function* () {
87
82
  props.form.setFieldValue(props.field.name, event.target.checked ? 'author' : 'other', false);
@@ -91,17 +86,6 @@ export const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpe
91
86
  React.createElement(OrcidContainer, null,
92
87
  React.createElement(TextFieldLabel, null,
93
88
  React.createElement(LabelText, null, "ORCID"),
94
- React.createElement(Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: TextField, saveOn: 'blur', placeholder: 'https://orcid.org/...', testId: "bibliographic-name-family" }))))))),
95
- createContributorRole && (React.createElement(Fieldset, null,
96
- React.createElement(Legend, null, "Contributions"),
97
- React.createElement(Field, { name: 'roles' }, (props) => (React.createElement(RolesContainer, null,
98
- React.createElement(ContributorRolesSelect, { contributorRoles: contributorRoles, createContributorRole: createContributorRole, value: values.roles, setFieldValue: (value) => __awaiter(void 0, void 0, void 0, function* () {
99
- props.form.setFieldValue(props.field.name, value, false);
100
- yield props.form.submitForm();
101
- }) })))),
102
- React.createElement(Field, { name: 'contribution' }, (props) => (React.createElement(TextArea, Object.assign({}, props.field, { onBlur: (event) => __awaiter(void 0, void 0, void 0, function* () {
103
- props.form.setFieldValue(props.field.name, event.target.value, false);
104
- yield props.form.submitForm();
105
- }), placeholder: 'If needed, describe contributions in more detail…' })))))))));
89
+ React.createElement(Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: TextField, saveOn: 'blur', placeholder: 'https://orcid.org/...', testId: "bibliographic-name-family" }))))))))));
106
90
  }));
107
91
  };
@@ -2,11 +2,11 @@ import React, { useContext } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { PermissionsContext } from '../FileManager';
4
4
  import { DesignationActions } from './DesignationActions';
5
- export const FileInfo = ({ showAttachmentName, showDesignationActions, title, submissionAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
6
- const fileName = submissionAttachmentName.substring(0, submissionAttachmentName.lastIndexOf('.'));
5
+ export const FileInfo = ({ showAttachmentName, showDesignationActions, title, fileAttachmentName, fileExtension, designation, attachmentId, handleChangeDesignation, dispatch, }) => {
6
+ const fileName = fileAttachmentName.substring(0, fileAttachmentName.lastIndexOf('.'));
7
7
  const can = useContext(PermissionsContext);
8
8
  return (React.createElement(FileInfoContainer, null,
9
- showDesignationActions && designation !== undefined && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: submissionAttachmentName, dispatch: dispatch, can: can })),
9
+ showDesignationActions && designation !== undefined && (React.createElement(DesignationActions, { designation: designation, attachmentId: attachmentId, fileExtension: fileExtension, handleChangeDesignation: handleChangeDesignation, fileName: fileAttachmentName, dispatch: dispatch, can: can })),
10
10
  React.createElement(FileNameTitleContainer, null,
11
11
  React.createElement(FileTitle, null,
12
12
  !showAttachmentName ? fileName : title,
@@ -23,7 +23,7 @@ export const FileSectionItem = ({ externalFile, title, showAttachmentName = fals
23
23
  }
24
24
  } },
25
25
  React.createElement(FileTypeIcon, { withDot: isMainManuscript, fileExtension: fileExtension, alt: externalFile.name }),
26
- React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, submissionAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
26
+ React.createElement(FileInfo, { fileExtension: fileExtension, showAttachmentName: showAttachmentName, showDesignationActions: showDesignationActions, fileAttachmentName: externalFile.name, title: title, designation: designation, attachmentId: externalFile.id, handleChangeDesignation: handleChangeDesignation, dispatch: dispatch })),
27
27
  onClose && (React.createElement(IconCloseButton, { onClick: (e) => {
28
28
  e.preventDefault();
29
29
  onClose();
package/dist/es/index.js CHANGED
@@ -53,7 +53,7 @@ export { useFiles } from './hooks/use-files';
53
53
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
54
54
  export * from './lib/authors';
55
55
  export * from './lib/capabilities';
56
- export { default as errorsDecoder } from './lib/lw-errors-decoder';
56
+ export { default as errorsDecoder } from './lib/errors-decoder';
57
57
  export * from './types';
58
58
  export { SelectDialogDesignation } from './components/FileManager/SelectDialogDesignation';
59
59
  export * from './components/LoadingOverlay';
@@ -1,19 +1,18 @@
1
1
  import React from 'react';
2
2
  var A;
3
3
  (function (A) {
4
- A["proceed"] = "proceed";
5
4
  A["updateAttachment"] = "update-attachment";
6
5
  A["updateDueDate"] = "update-due-date";
7
6
  A["addNote"] = "add-note";
8
7
  A["setMainManuscript"] = "set-main-manuscript";
9
8
  })(A || (A = {}));
10
- export const getLWCapabilities = (project, profile, lwRole, actions) => {
9
+ export const getCapabilities = (project, profile, role, actions) => {
11
10
  const isEditor = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.editors) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
12
11
  const isOwner = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.owners) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
13
12
  const isWriter = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.writers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
14
13
  const isAnnotator = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.annotators) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
15
14
  const isViewer = () => { var _a; return !!(profile && ((_a = project === null || project === void 0 ? void 0 : project.viewers) === null || _a === void 0 ? void 0 : _a.includes(profile.userID))); };
16
- const isLWProdEditor = () => lwRole == 'pe';
15
+ const isProdEditor = () => role == 'pe';
17
16
  const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
18
17
  return {
19
18
  handleSuggestion: isOwner() || isEditor() || isWriter(),
@@ -38,12 +37,11 @@ export const getLWCapabilities = (project, profile, lwRole, actions) => {
38
37
  uploadFile: isOwner() || isEditor() || isWriter(),
39
38
  handleQualityReport: isOwner() || isEditor() || isWriter(),
40
39
  setMainManuscript: allowed(A.setMainManuscript),
41
- completeTask: !isViewer() && allowed(A.proceed),
42
- rejectTask: isLWProdEditor(),
43
- acceptTask: isLWProdEditor(),
44
- resolveOnHoldTask: isLWProdEditor(),
45
- putOnHoldTask: isLWProdEditor(),
46
- changeDueDate: isLWProdEditor() && allowed(A.updateDueDate),
40
+ rejectTask: isProdEditor(),
41
+ acceptTask: isProdEditor(),
42
+ resolveOnHoldTask: isProdEditor(),
43
+ putOnHoldTask: isProdEditor(),
44
+ changeDueDate: isProdEditor() && allowed(A.updateDueDate),
47
45
  previewAccess: true,
48
46
  editNotTracked: false,
49
47
  accessEditor: true,
@@ -54,20 +52,20 @@ export const getLWCapabilities = (project, profile, lwRole, actions) => {
54
52
  };
55
53
  };
56
54
  export const getAllPermitted = () => {
57
- const capabilities = getLWCapabilities();
55
+ const capabilities = getCapabilities();
58
56
  const allAllowed = Object.keys(capabilities).reduce((caps, item) => {
59
57
  caps[item] = true;
60
58
  return caps;
61
59
  }, {});
62
60
  return allAllowed;
63
61
  };
64
- const CapabilitiesContext = React.createContext(getLWCapabilities());
62
+ const CapabilitiesContext = React.createContext(getCapabilities());
65
63
  CapabilitiesContext.displayName = 'CapabilitiesContext';
66
64
  export const usePermissions = () => {
67
65
  return React.useContext(CapabilitiesContext);
68
66
  };
69
- export const useCalcPermission = ({ project, profile, lwRole, permittedActions, }) => {
70
- return getLWCapabilities(project, profile, lwRole, permittedActions);
67
+ export const useCalcPermission = ({ project, profile, role, permittedActions, }) => {
68
+ return getCapabilities(project, profile, role, permittedActions);
71
69
  };
72
70
  export const CapabilitiesProvider = (props) => {
73
71
  const { can } = props;
@@ -2,12 +2,12 @@ import { Model } from '@manuscripts/json-schema';
2
2
  import { Build } from '@manuscripts/transform';
3
3
  import React from 'react';
4
4
  import { Capabilities } from '../../lib/capabilities';
5
- import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
6
- export type Upload = (file: File, designation: string) => Promise<boolean | SubmissionAttachment | undefined>;
7
- export type Replace = (attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean | SubmissionAttachment | undefined>;
5
+ import { FileAttachment } from './FileSectionItem/FileSectionItem';
6
+ export type Upload = (file: File, designation: string) => Promise<boolean | FileAttachment | undefined>;
7
+ export type Replace = (attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean | FileAttachment | undefined>;
8
8
  export type ChangeDesignation = (attachmentId: string, typeId: string, name: string) => Promise<boolean>;
9
9
  export interface FileManagement {
10
- getAttachments: () => SubmissionAttachment[];
10
+ getAttachments: () => FileAttachment[];
11
11
  upload: Upload;
12
12
  replace: Replace;
13
13
  changeDesignation: ChangeDesignation;
@@ -19,5 +19,5 @@ export declare const FileManager: React.FC<{
19
19
  saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
20
20
  enableDragAndDrop: boolean;
21
21
  can: Capabilities;
22
- addAttachmentToState?: (a: SubmissionAttachment) => void;
22
+ addAttachmentToState?: (a: FileAttachment) => void;
23
23
  }>;
@@ -6,7 +6,7 @@ export declare const FileInfo: React.FC<{
6
6
  showAttachmentName: boolean;
7
7
  showDesignationActions: boolean;
8
8
  title: string;
9
- submissionAttachmentName: string;
9
+ fileAttachmentName: string;
10
10
  fileExtension: string;
11
11
  designation?: Designation;
12
12
  attachmentId: string;
@@ -3,18 +3,18 @@ import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
3
3
  import { Maybe } from '../../SubmissionInspector/types';
4
4
  import { ChangeDesignation, Replace } from '../FileManager';
5
5
  import { Action } from '../FileSectionState';
6
- export type SubmissionAttachment = {
6
+ export type FileAttachment = {
7
7
  id: string;
8
8
  name: string;
9
- type: SubmissionAttachmentType;
9
+ type: FileAttachmentType;
10
10
  link: string;
11
11
  };
12
- export type SubmissionAttachmentType = {
12
+ export type FileAttachmentType = {
13
13
  id: string;
14
14
  label?: Maybe<string> | undefined;
15
15
  };
16
16
  export interface FileSectionItemProps {
17
- externalFile: SubmissionAttachment;
17
+ externalFile: FileAttachment;
18
18
  title: string;
19
19
  showAttachmentName?: boolean;
20
20
  showDesignationActions?: boolean;
@@ -2,12 +2,12 @@ import React, { Dispatch } from 'react';
2
2
  import { Maybe } from '../../SubmissionInspector/types';
3
3
  import { Replace } from '../FileManager';
4
4
  import { Action } from '../FileSectionState';
5
- import { SubmissionAttachment } from './FileSectionItem';
5
+ import { FileAttachment } from './FileSectionItem';
6
6
  export declare const ItemActions: React.FC<{
7
7
  downloadAttachmentHandler: (url: string) => void;
8
8
  replaceAttachmentHandler: Replace;
9
9
  detachAttachmnetHandler?: () => void;
10
- handleUpdateInline?: (attachment: SubmissionAttachment) => void;
10
+ handleUpdateInline?: (attachment: FileAttachment) => void;
11
11
  attachmentId: string;
12
12
  fileName: string;
13
13
  designation?: Maybe<string> | undefined;
@@ -1,6 +1,6 @@
1
1
  import React, { Dispatch } from 'react';
2
2
  import { Replace } from './FileManager';
3
- import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
3
+ import { FileAttachment } from './FileSectionItem/FileSectionItem';
4
4
  import { Action } from './FileSectionState';
5
5
  import { FileType } from './util';
6
6
  export declare const InlineFilesSection: React.FC<{
@@ -9,11 +9,11 @@ export declare const InlineFilesSection: React.FC<{
9
9
  label: string;
10
10
  type: FileType;
11
11
  caption?: string;
12
- attachments?: SubmissionAttachment[];
12
+ attachments?: FileAttachment[];
13
13
  }[];
14
14
  handleReplace: Replace;
15
15
  handleDownload: (url: string) => void;
16
- handleUpdateInline?: (modelId: string, attachment: SubmissionAttachment) => void;
16
+ handleUpdateInline?: (modelId: string, attachment: FileAttachment) => void;
17
17
  handleDetachFile?: (attachmentLink: string, modelId: string) => void;
18
18
  isEditor: boolean;
19
19
  dispatch: Dispatch<Action>;
@@ -1,6 +1,6 @@
1
1
  import { Capabilities } from '../../lib/capabilities';
2
2
  import { Maybe } from '../SubmissionInspector/types';
3
- import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
3
+ import { FileAttachment } from './FileSectionItem/FileSectionItem';
4
4
  export declare enum FileSectionType {
5
5
  Inline = 0,
6
6
  Supplements = 1,
@@ -44,9 +44,9 @@ export declare const designationWithAllowedDesignationsToTransitionMap: Map<Desi
44
44
  export declare const extensionsWithFileTypesMap: Map<string, FileType>;
45
45
  export declare const fileTypesWithTitlesMap: Map<FileType | undefined, string>;
46
46
  export declare const fileTypesWithIconMap: Map<FileType | undefined, JSX.Element>;
47
- export declare const generateAttachmentsTitles: (externalFiles: SubmissionAttachment[], fileSectionType: FileSectionType) => Array<{
47
+ export declare const generateAttachmentsTitles: (externalFiles: FileAttachment[], fileSectionType: FileSectionType) => Array<{
48
48
  title: string;
49
- externalFile: SubmissionAttachment;
49
+ externalFile: FileAttachment;
50
50
  }>;
51
51
  export declare const getDesignationActionsList: (designation: Designation, fileExtension: string) => Array<Designation>;
52
52
  export declare const getDesignationName: (designation: Designation) => string;
@@ -1,10 +1,10 @@
1
1
  import { Model } from '@manuscripts/json-schema';
2
- import { SubmissionAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
2
+ import { FileAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
3
3
  import { InlineFile } from '../lib/inlineFiles';
4
4
  type FilePredicate = (fileName: string) => boolean;
5
- export declare const useFiles: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[], filePredicate?: FilePredicate) => {
6
- otherFiles: SubmissionAttachment[];
7
- supplementFiles: SubmissionAttachment[];
5
+ export declare const useFiles: (modelMap: Map<string, Model>, attachments: FileAttachment[], filePredicate?: FilePredicate) => {
6
+ otherFiles: FileAttachment[];
7
+ supplementFiles: FileAttachment[];
8
8
  inlineFiles: InlineFile[];
9
9
  };
10
10
  export default useFiles;
@@ -54,7 +54,7 @@ export { useFiles } from './hooks/use-files';
54
54
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
55
55
  export * from './lib/authors';
56
56
  export * from './lib/capabilities';
57
- export { default as errorsDecoder } from './lib/lw-errors-decoder';
57
+ export { default as errorsDecoder } from './lib/errors-decoder';
58
58
  export * from './types';
59
59
  export { SelectDialogDesignation } from './components/FileManager/SelectDialogDesignation';
60
60
  export * from './components/LoadingOverlay';
@@ -24,7 +24,6 @@ export type Capabilities = {
24
24
  uploadFile: boolean;
25
25
  handleQualityReport: boolean;
26
26
  setMainManuscript: boolean;
27
- completeTask: boolean;
28
27
  rejectTask: boolean;
29
28
  acceptTask: boolean;
30
29
  resolveOnHoldTask: boolean;
@@ -41,14 +40,14 @@ export type Capabilities = {
41
40
  export interface ProviderProps {
42
41
  project?: Project;
43
42
  profile?: UserProfileWithAvatar;
44
- lwRole?: string;
43
+ role?: string;
45
44
  permittedActions?: string[];
46
45
  children?: React.ReactNode;
47
46
  }
48
- export declare const getLWCapabilities: (project?: Project, profile?: UserProfileWithAvatar, lwRole?: ProviderProps['lwRole'], actions?: string[]) => Capabilities;
47
+ export declare const getCapabilities: (project?: Project, profile?: UserProfileWithAvatar, role?: ProviderProps['role'], actions?: string[]) => Capabilities;
49
48
  export declare const getAllPermitted: () => Capabilities;
50
49
  export declare const usePermissions: () => Capabilities;
51
- export declare const useCalcPermission: ({ project, profile, lwRole, permittedActions, }: ProviderProps) => Capabilities;
50
+ export declare const useCalcPermission: ({ project, profile, role, permittedActions, }: ProviderProps) => Capabilities;
52
51
  export declare const CapabilitiesProvider: React.FC<{
53
52
  can: Capabilities;
54
53
  }>;
@@ -1,11 +1,11 @@
1
1
  import { Model } from '@manuscripts/json-schema';
2
- import { SubmissionAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
2
+ import { FileAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
3
3
  import { FileType } from '../components/FileManager/util';
4
4
  export type InlineFile = {
5
5
  id: string;
6
6
  label: string;
7
7
  type: FileType;
8
- attachments?: SubmissionAttachment[];
8
+ attachments?: FileAttachment[];
9
9
  };
10
- declare const _default: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[]) => InlineFile[];
10
+ declare const _default: (modelMap: Map<string, Model>, attachments: FileAttachment[]) => InlineFile[];
11
11
  export default _default;
@@ -66,7 +66,6 @@ export interface AuthorValues {
66
66
  priority: number;
67
67
  email: string;
68
68
  isCorresponding: boolean;
69
- isJointContributor: boolean;
70
69
  bibliographicName: BibliographicNameValues;
71
70
  role: string;
72
71
  roles: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "1.0.7",
4
+ "version": "1.0.8-LEAN-2299",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",