@manuscripts/style-guide 1.7.11 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/cjs/components/{FileManager/DragLayer.js → DragLayer.js} +26 -50
  2. package/dist/cjs/components/FileManager/FileManager.js +1 -1
  3. package/dist/cjs/components/icons/index.js +3 -1
  4. package/dist/cjs/index.js +2 -6
  5. package/dist/es/components/{FileManager/DragLayer.js → DragLayer.js} +26 -27
  6. package/dist/es/components/FileManager/FileManager.js +1 -1
  7. package/dist/es/components/icons/index.js +1 -0
  8. package/dist/es/index.js +2 -6
  9. package/dist/types/components/AlertMessage.d.ts +1 -1
  10. package/dist/types/components/Button.d.ts +9 -9
  11. package/dist/types/components/EditorHeader/EditorHeader.d.ts +1 -1
  12. package/dist/types/components/InspectorSection.d.ts +1 -1
  13. package/dist/types/components/NavDropdown.d.ts +1 -1
  14. package/dist/types/components/StyledModal.d.ts +1 -1
  15. package/dist/types/components/icons/index.d.ts +1 -0
  16. package/dist/types/index.d.ts +2 -6
  17. package/package.json +1 -1
  18. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditor.js +0 -62
  19. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorItem.js +0 -176
  20. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorProfile.js +0 -62
  21. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorView.js +0 -80
  22. package/dist/cjs/components/AffiliationsEditor/index.js +0 -25
  23. package/dist/cjs/components/AffiliationsEditor/styles.js +0 -56
  24. package/dist/cjs/components/AuthorForm/AuthorForm.js +0 -99
  25. package/dist/cjs/components/AuthorForm/AuthorFormComponents.js +0 -63
  26. package/dist/cjs/components/AuthorForm/ContributorRolesSelect.js +0 -100
  27. package/dist/cjs/components/AuthorForm/RemoveAuthorButton.js +0 -45
  28. package/dist/cjs/components/AuthorForm/index.js +0 -32
  29. package/dist/cjs/components/AuthorName.js +0 -52
  30. package/dist/cjs/components/AuthorsDND/AuthorItemComponents.js +0 -22
  31. package/dist/cjs/components/AuthorsDND/AuthorsDND.js +0 -68
  32. package/dist/cjs/components/AuthorsDND/DraggableAuthorItem.js +0 -197
  33. package/dist/cjs/components/AuthorsDND/index.js +0 -23
  34. package/dist/cjs/lib/authors.js +0 -110
  35. package/dist/cjs/lib/formatAddress.js +0 -31
  36. package/dist/cjs/lib/name.js +0 -26
  37. package/dist/cjs/types.js +0 -17
  38. package/dist/es/components/AffiliationsEditor/AffiliationsEditor.js +0 -34
  39. package/dist/es/components/AffiliationsEditor/AffiliationsEditorItem.js +0 -146
  40. package/dist/es/components/AffiliationsEditor/AffiliationsEditorProfile.js +0 -34
  41. package/dist/es/components/AffiliationsEditor/AffiliationsEditorView.js +0 -52
  42. package/dist/es/components/AffiliationsEditor/index.js +0 -17
  43. package/dist/es/components/AffiliationsEditor/styles.js +0 -49
  44. package/dist/es/components/AuthorForm/AuthorForm.js +0 -92
  45. package/dist/es/components/AuthorForm/AuthorFormComponents.js +0 -57
  46. package/dist/es/components/AuthorForm/ContributorRolesSelect.js +0 -70
  47. package/dist/es/components/AuthorForm/RemoveAuthorButton.js +0 -40
  48. package/dist/es/components/AuthorForm/index.js +0 -16
  49. package/dist/es/components/AuthorName.js +0 -23
  50. package/dist/es/components/AuthorsDND/AuthorItemComponents.js +0 -19
  51. package/dist/es/components/AuthorsDND/AuthorsDND.js +0 -40
  52. package/dist/es/components/AuthorsDND/DraggableAuthorItem.js +0 -192
  53. package/dist/es/components/AuthorsDND/index.js +0 -16
  54. package/dist/es/lib/authors.js +0 -98
  55. package/dist/es/lib/formatAddress.js +0 -29
  56. package/dist/es/lib/name.js +0 -22
  57. package/dist/es/types.js +0 -16
  58. package/dist/types/components/AffiliationsEditor/AffiliationsEditor.d.ts +0 -31
  59. package/dist/types/components/AffiliationsEditor/AffiliationsEditorItem.d.ts +0 -26
  60. package/dist/types/components/AffiliationsEditor/AffiliationsEditorProfile.d.ts +0 -30
  61. package/dist/types/components/AffiliationsEditor/AffiliationsEditorView.d.ts +0 -34
  62. package/dist/types/components/AffiliationsEditor/index.d.ts +0 -17
  63. package/dist/types/components/AffiliationsEditor/styles.d.ts +0 -23
  64. package/dist/types/components/AuthorForm/AuthorForm.d.ts +0 -29
  65. package/dist/types/components/AuthorForm/AuthorFormComponents.d.ts +0 -31
  66. package/dist/types/components/AuthorForm/ContributorRolesSelect.d.ts +0 -23
  67. package/dist/types/components/AuthorForm/RemoveAuthorButton.d.ts +0 -27
  68. package/dist/types/components/AuthorForm/index.d.ts +0 -16
  69. package/dist/types/components/AuthorName.d.ts +0 -22
  70. package/dist/types/components/AuthorsDND/AuthorItemComponents.d.ts +0 -24
  71. package/dist/types/components/AuthorsDND/AuthorsDND.d.ts +0 -28
  72. package/dist/types/components/AuthorsDND/DraggableAuthorItem.d.ts +0 -50
  73. package/dist/types/components/AuthorsDND/index.d.ts +0 -16
  74. package/dist/types/lib/authors.d.ts +0 -30
  75. package/dist/types/lib/formatAddress.d.ts +0 -18
  76. package/dist/types/lib/name.d.ts +0 -17
  77. package/dist/types/types.d.ts +0 -80
  78. /package/dist/types/components/{FileManager/DragLayer.d.ts → DragLayer.d.ts} +0 -0
@@ -1,100 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
41
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
42
- return new (P || (P = Promise))(function (resolve, reject) {
43
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
44
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
45
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
46
- step((generator = generator.apply(thisArg, _arguments || [])).next());
47
- });
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.ContributorRolesSelect = void 0;
54
- const react_1 = __importStar(require("react"));
55
- const creatable_1 = __importDefault(require("react-select/creatable"));
56
- const sortRolesAlphabetical = (a, b) => a.name.localeCompare(b.name);
57
- const ContributorRolesSelect = ({ contributorRoles, createContributorRole, value, setFieldValue }) => {
58
- const [saving, setSaving] = (0, react_1.useState)(false);
59
- const selectedRoles = (0, react_1.useMemo)(() => value
60
- .map((id) => contributorRoles.find((item) => item._id === id))
61
- .flat(), [contributorRoles, value]);
62
- const options = (0, react_1.useMemo)(() => {
63
- const output = { local: [], 'dictionary.casrai.org': [] };
64
- const groupedOptions = contributorRoles.reduce((output, contributorRole) => {
65
- if (contributorRole.uri) {
66
- const { hostname } = new URL(contributorRole.uri);
67
- if (hostname in output) {
68
- output[hostname].push(contributorRole);
69
- }
70
- }
71
- else {
72
- output.local.push(contributorRole);
73
- }
74
- return output;
75
- }, output);
76
- return [
77
- {
78
- options: groupedOptions.local.sort(sortRolesAlphabetical),
79
- },
80
- {
81
- label: 'CASRAI CRediT',
82
- options: groupedOptions['dictionary.casrai.org'].sort(sortRolesAlphabetical),
83
- },
84
- ];
85
- }, [contributorRoles]);
86
- return (react_1.default.createElement(creatable_1.default, { options: options, value: selectedRoles, isMulti: true, isClearable: true, isLoading: saving, placeholder: 'Begin typing or choose contribution', noOptionsMessage: () => 'Type the name of a contributor role', getNewOptionData: (inputValue) => {
87
- const option = {
88
- name: `Create "${inputValue}" role`,
89
- };
90
- return option;
91
- }, onCreateOption: (inputValue) => __awaiter(void 0, void 0, void 0, function* () {
92
- setSaving(true);
93
- const contribution = yield createContributorRole(inputValue);
94
- setSaving(false);
95
- setFieldValue([...value, contribution._id]);
96
- }), getOptionValue: (option) => option._id, getOptionLabel: (option) => option.name, onChange: (value) => {
97
- setFieldValue(value.map((item) => item._id));
98
- } }));
99
- };
100
- exports.ContributorRolesSelect = ContributorRolesSelect;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- const react_1 = __importDefault(require("react"));
22
- const name_1 = require("../../lib/name");
23
- const Button_1 = require("../Button");
24
- const Dialog_1 = require("../Dialog");
25
- class RemoveAuthorButton extends react_1.default.Component {
26
- render() {
27
- const { isOpen } = this.props;
28
- const { removeAuthor, author } = this.props;
29
- const actions = {
30
- primary: {
31
- action: this.props.handleOpen,
32
- title: 'Cancel',
33
- },
34
- secondary: {
35
- action: removeAuthor,
36
- title: 'Remove',
37
- isDestructive: true,
38
- },
39
- };
40
- return (react_1.default.createElement(react_1.default.Fragment, null,
41
- react_1.default.createElement(Button_1.PrimaryButton, { danger: true, onClick: this.props.handleOpen }, "Delete"),
42
- isOpen && (react_1.default.createElement(Dialog_1.Dialog, { isOpen: isOpen, actions: actions, category: Dialog_1.Category.confirmation, header: 'Remove author', message: `Are you sure you want to remove ${(0, name_1.initials)(author.bibliographicName)}${' '}${author.bibliographicName.family} from the authors list?` }))));
43
- }
44
- }
45
- exports.default = RemoveAuthorButton;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
29
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- __exportStar(require("./AuthorForm"), exports);
@@ -1,52 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.AuthorName = void 0;
45
- const react_1 = __importDefault(require("react"));
46
- const styled_components_1 = __importStar(require("styled-components"));
47
- const name_1 = require("../lib/name");
48
- const NameParts = styled_components_1.default.span ``;
49
- const buildNameLiteral = (name) => [(0, name_1.initials)(name), name.family, name.suffix].filter((part) => part).join(' ');
50
- const AuthorNameComponent = ({ name, email, theme }) => !name.given && !name.family ? (react_1.default.createElement(NameParts, { color: theme.colors.text.secondary, "data-testid": `author-name--unknown` }, "Unknown Author")) : (react_1.default.createElement(NameParts, { "data-testid": `author-name--${name.given}` }, (email && buildNameLiteral(name).concat(' ').concat(`(${email})`)) ||
51
- buildNameLiteral(name)));
52
- exports.AuthorName = (0, styled_components_1.withTheme)(AuthorNameComponent);
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.defaultAuthorItemComponents = void 0;
19
- const AuthorName_1 = require("../AuthorName");
20
- exports.defaultAuthorItemComponents = {
21
- AuthorName: AuthorName_1.AuthorName,
22
- };
@@ -1,68 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- const react_1 = __importStar(require("react"));
45
- const styled_components_1 = __importStar(require("styled-components"));
46
- const DraggableAuthorItem_1 = __importDefault(require("./DraggableAuthorItem"));
47
- const SidebarList = styled_components_1.default.div `
48
- flex: 1;
49
- overflow-y: visible;
50
- `;
51
- const AuthorsDND = ({ authors, selectAuthor, selectedAuthor, handleDrop, getSidebarItemDecorator, components, }) => {
52
- const theme = (0, react_1.useContext)(styled_components_1.ThemeContext);
53
- return (react_1.default.createElement(SidebarList, null, authors.map((author, index) => {
54
- const user = {
55
- _id: author.userID,
56
- };
57
- const authorItem = {
58
- _id: author._id,
59
- priority: author.priority || null,
60
- index,
61
- };
62
- const decorator = getSidebarItemDecorator
63
- ? getSidebarItemDecorator(author._id)
64
- : null;
65
- return (react_1.default.createElement(DraggableAuthorItem_1.default, { key: author._id, authorItem: authorItem, onDrop: handleDrop, author: author, authors: authors, user: user, selectedAuthor: selectedAuthor, selectAuthor: selectAuthor, sidebarItemDecorator: decorator, components: components, theme: theme }));
66
- })));
67
- };
68
- exports.default = AuthorsDND;
@@ -1,197 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- const CorrespondingAuthorBadge_1 = __importDefault(require("@manuscripts/assets/react/CorrespondingAuthorBadge"));
22
- const FirstAuthorBadge_1 = __importDefault(require("@manuscripts/assets/react/FirstAuthorBadge"));
23
- const VerticalEllipsis_1 = __importDefault(require("@manuscripts/assets/react/VerticalEllipsis"));
24
- const react_1 = __importDefault(require("react"));
25
- const react_dnd_1 = require("react-dnd");
26
- const react_dom_1 = require("react-dom");
27
- const styled_components_1 = __importDefault(require("styled-components"));
28
- const authors_1 = require("../../lib/authors");
29
- const Avatar_1 = require("../Avatar");
30
- const AuthorItemComponents_1 = require("./AuthorItemComponents");
31
- const AuthorItemComponent = styled_components_1.default.div `
32
- margin: 0 -${(props) => props.theme.grid.unit * 5}px;
33
- padding: ${(props) => props.theme.grid.unit * 2}px
34
- ${(props) => props.theme.grid.unit * 5}px;
35
- display: flex;
36
- justify-content: space-between;
37
- align-items: center;
38
- cursor: pointer;
39
- transition: background-color 0.25s;
40
- opacity: ${(props) => props.opacity};
41
-
42
- &:hover,
43
- &.active {
44
- background: ${(props) => props.theme.colors.background.fifth};
45
- }
46
-
47
- &.active {
48
- border: 1px solid ${(props) => props.theme.colors.border.primary};
49
- border-left: 0;
50
- border-right: 0;
51
- }
52
- `;
53
- const AuthorMetadata = styled_components_1.default.div `
54
- display: flex;
55
- align-items: center;
56
- `;
57
- const AvatarContainer = styled_components_1.default.span `
58
- display: inline-flex;
59
- position: relative;
60
- `;
61
- const AuthorBadge = styled_components_1.default.span `
62
- display: inline-flex;
63
- align-items: center;
64
- justify-content: center;
65
- position: relative;
66
- `;
67
- const AuthorNotes = styled_components_1.default.span `
68
- position: absolute;
69
- top: 0;
70
- right: 0;
71
-
72
- & ${AuthorBadge}:not(:last-child) {
73
- right: -20%;
74
- }
75
- `;
76
- const AuthorNameSpace = styled_components_1.default.span `
77
- margin-left: 12px;
78
- `;
79
- const InvitedContainer = styled_components_1.default.div `
80
- display: flex;
81
- align-items: center;
82
- `;
83
- const AuthorDropPreview = styled_components_1.default.div `
84
- width: 100%;
85
- background: ${(props) => props.theme.colors.brand.dark};
86
- height: 1px;
87
- position: relative;
88
- `;
89
- const DragHandle = styled_components_1.default.div `
90
- margin-left: 12px;
91
-
92
- &:hover {
93
- cursor: move;
94
- }
95
- `;
96
- const dragSourceSpec = {
97
- beginDrag(props) {
98
- return {
99
- authorItem: props.authorItem,
100
- };
101
- },
102
- };
103
- const dropTargetSpec = {
104
- hover(_props, monitor, component) {
105
- if (!monitor.isOver({ shallow: true })) {
106
- return;
107
- }
108
- const hoveredNode = (0, react_dom_1.findDOMNode)(component);
109
- const { top, bottom } = hoveredNode.getBoundingClientRect();
110
- const offset = monitor.getClientOffset();
111
- if (!offset) {
112
- return;
113
- }
114
- const verticalMiddle = (bottom - top) / 2;
115
- const verticalHover = offset.y - top;
116
- const item = monitor.getItem();
117
- item.position = verticalHover < verticalMiddle ? 'before' : 'after';
118
- component.setState({
119
- dragPosition: item.position,
120
- });
121
- },
122
- canDrop(props, monitor) {
123
- const item = monitor.getItem();
124
- return props.authorItem._id !== item.authorItem._id;
125
- },
126
- drop(props, monitor) {
127
- if (monitor.didDrop()) {
128
- return;
129
- }
130
- const item = monitor.getItem();
131
- const oldIndex = item.authorItem.index;
132
- const newIndex = props.authorItem.index + (item.position === 'after' ? 0.5 : -0.5);
133
- props.onDrop(oldIndex, newIndex);
134
- },
135
- };
136
- class AuthorComponent extends react_1.default.Component {
137
- constructor() {
138
- super(...arguments);
139
- this.state = {
140
- dragPosition: null,
141
- };
142
- this.mightDrop = () => this.props.item && this.props.isOverCurrent && this.props.canDrop;
143
- this.selectedAuthorClass = () => {
144
- const { selectedAuthor, author } = this.props;
145
- return selectedAuthor && selectedAuthor._id === author._id ? 'active' : '';
146
- };
147
- this.topPreviewStyles = (mightDrop, dragPosition) => ({
148
- top: '0px',
149
- visibility: mightDrop && dragPosition === 'before' ? 'visible' : 'hidden',
150
- });
151
- this.bottomPreviewStyles = (mightDrop, dragPosition) => ({
152
- bottom: '-1px',
153
- visibility: mightDrop && dragPosition === 'after' ? 'visible' : 'hidden',
154
- });
155
- }
156
- render() {
157
- const { dragPosition } = this.state;
158
- const { isDragging, connectDragSource, connectDropTarget, selectAuthor, author, authors, user, authorItem, sidebarItemDecorator, theme, components, } = this.props;
159
- const opacity = isDragging ? 0 : 1;
160
- const { AuthorName } = Object.assign(Object.assign({}, AuthorItemComponents_1.defaultAuthorItemComponents), components);
161
- return connectDragSource(react_1.default.createElement("div", null,
162
- react_1.default.createElement(AuthorDropPreview, { style: this.topPreviewStyles(this.mightDrop(), dragPosition) }),
163
- connectDropTarget(react_1.default.createElement("div", null,
164
- react_1.default.createElement(AuthorItemComponent, { key: author._id, onClick: () => selectAuthor(author), className: this.selectedAuthorClass(), opacity: opacity },
165
- react_1.default.createElement(AuthorMetadata, null,
166
- react_1.default.createElement(AvatarContainer, null,
167
- react_1.default.createElement(Avatar_1.Avatar, { src: user.avatar, size: 36, color: '#6e6e6e' }),
168
- react_1.default.createElement(AuthorNotes, null,
169
- author.isCorresponding && (react_1.default.createElement(AuthorBadge, null,
170
- react_1.default.createElement(CorrespondingAuthorBadge_1.default, null))),
171
- (0, authors_1.isJointFirstAuthor)(authors, authorItem.index) && (react_1.default.createElement(AuthorBadge, null,
172
- react_1.default.createElement(FirstAuthorBadge_1.default, null))))),
173
- react_1.default.createElement(AuthorNameSpace, null,
174
- react_1.default.createElement(AuthorName, { name: author.bibliographicName }))),
175
- react_1.default.createElement(InvitedContainer, null,
176
- sidebarItemDecorator,
177
- this.selectedAuthorClass() && (react_1.default.createElement(DragHandle, null,
178
- react_1.default.createElement(VerticalEllipsis_1.default, { color: theme.colors.brand.default }))))))),
179
- react_1.default.createElement(AuthorDropPreview, { style: this.bottomPreviewStyles(this.mightDrop(), dragPosition) })));
180
- }
181
- }
182
- const dragSourceCollector = (connect, monitor) => ({
183
- connectDragSource: connect.dragSource(),
184
- isDragging: monitor.isDragging(),
185
- item: monitor.getItem(),
186
- });
187
- const dropTargetCollector = (connect, monitor) => ({
188
- connectDropTarget: connect.dropTarget(),
189
- isOver: monitor.isOver(),
190
- isOverCurrent: monitor.isOver({ shallow: true }),
191
- canDrop: monitor.canDrop(),
192
- });
193
- const dragType = 'authorItem';
194
- const dragSource = (0, react_dnd_1.DragSource)(dragType, dragSourceSpec, dragSourceCollector);
195
- const dropTarget = (0, react_dnd_1.DropTarget)(dragType, dropTargetSpec, dropTargetCollector);
196
- const DraggableAuthorItem = dragSource(dropTarget(AuthorComponent));
197
- exports.default = DraggableAuthorItem;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.AuthorsDND = void 0;
22
- var AuthorsDND_1 = require("./AuthorsDND");
23
- Object.defineProperty(exports, "AuthorsDND", { enumerable: true, get: function () { return __importDefault(AuthorsDND_1).default; } });
@@ -1,110 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2019 Atypon Systems LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.affiliationsOptions = exports.affiliationLabel = exports.isJointFirstAuthor = exports.buildAuthorsAndAffiliations = exports.buildAffiliationsMap = exports.buildAuthorAffiliations = exports.buildAffiliationIDs = exports.buildAuthorPriority = exports.buildSortedAuthors = void 0;
19
- const json_schema_1 = require("@manuscripts/json-schema");
20
- const getModelsByType = (modelMap, objectType) => {
21
- const output = [];
22
- for (const model of modelMap.values()) {
23
- if (model.objectType === objectType) {
24
- output.push(model);
25
- }
26
- }
27
- return output;
28
- };
29
- const buildSortedAuthors = (modelMap) => {
30
- return getModelsByType(modelMap, json_schema_1.ObjectTypes.Contributor)
31
- .filter((item) => item.role === 'author')
32
- .sort((a, b) => Number(a.priority) - Number(b.priority));
33
- };
34
- exports.buildSortedAuthors = buildSortedAuthors;
35
- const buildAuthorPriority = (authors) => {
36
- if (!authors.length) {
37
- return 0;
38
- }
39
- const priorities = authors.map((author) => Number(author.priority));
40
- return Math.max(...priorities) + 1;
41
- };
42
- exports.buildAuthorPriority = buildAuthorPriority;
43
- const buildAffiliationIDs = (authors) => {
44
- const ids = [];
45
- authors.forEach((author) => {
46
- if (author.affiliations) {
47
- author.affiliations.forEach((id) => {
48
- ids.push(id);
49
- });
50
- }
51
- });
52
- return ids.filter((value, index) => ids.indexOf(value) === index);
53
- };
54
- exports.buildAffiliationIDs = buildAffiliationIDs;
55
- const buildAuthorAffiliations = (authors, affiliations, uniqueAffiliationIDs) => {
56
- const items = new Map();
57
- authors.forEach((author) => {
58
- items.set(author._id, (author.affiliations || []).map((id) => {
59
- return {
60
- ordinal: uniqueAffiliationIDs.indexOf(id) + 1,
61
- data: affiliations.get(id),
62
- };
63
- }));
64
- });
65
- return items;
66
- };
67
- exports.buildAuthorAffiliations = buildAuthorAffiliations;
68
- const buildAffiliationsMap = (affiliationIDs, modelMap) => new Map(affiliationIDs.map((id) => [
69
- id,
70
- modelMap.get(id),
71
- ]));
72
- exports.buildAffiliationsMap = buildAffiliationsMap;
73
- const buildAuthorsAndAffiliations = (modelMap) => {
74
- const authors = (0, exports.buildSortedAuthors)(modelMap);
75
- const affiliationIDs = (0, exports.buildAffiliationIDs)(authors);
76
- const affiliations = (0, exports.buildAffiliationsMap)(affiliationIDs, modelMap);
77
- const authorAffiliations = (0, exports.buildAuthorAffiliations)(authors, affiliations, affiliationIDs);
78
- return {
79
- affiliations,
80
- authors,
81
- authorAffiliations,
82
- };
83
- };
84
- exports.buildAuthorsAndAffiliations = buildAuthorsAndAffiliations;
85
- const isJointFirstAuthor = (authors, index) => {
86
- const author = index === 0 ? authors[index] : authors[index - 1];
87
- return Boolean(author.isJointContributor);
88
- };
89
- exports.isJointFirstAuthor = isJointFirstAuthor;
90
- const affiliationLabel = (affiliation) => {
91
- const { department, institution = '' } = affiliation;
92
- if (!institution) {
93
- return '(unknown institution)';
94
- }
95
- return department ? `${institution} (${department})`.trim() : institution;
96
- };
97
- exports.affiliationLabel = affiliationLabel;
98
- const affiliationsOptions = (affiliations, authorAffiliations) => {
99
- if (!authorAffiliations) {
100
- return (0, exports.affiliationsOptions)(affiliations, []);
101
- }
102
- const authorAffiliationsIds = new Set(authorAffiliations.map((authorAffiliation) => authorAffiliation.data._id));
103
- return Array.from(affiliations.values())
104
- .filter((affiliation) => !authorAffiliationsIds.has(affiliation._id))
105
- .map((affiliation) => ({
106
- value: affiliation._id,
107
- label: (0, exports.affiliationLabel)(affiliation) || '',
108
- }));
109
- };
110
- exports.affiliationsOptions = affiliationsOptions;