@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,40 +0,0 @@
1
- /*!
2
- * © 2019 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
- import React from 'react';
17
- import { initials } from '../../lib/name';
18
- import { PrimaryButton } from '../Button';
19
- import { Category, Dialog } from '../Dialog';
20
- class RemoveAuthorButton extends React.Component {
21
- render() {
22
- const { isOpen } = this.props;
23
- const { removeAuthor, author } = this.props;
24
- const actions = {
25
- primary: {
26
- action: this.props.handleOpen,
27
- title: 'Cancel',
28
- },
29
- secondary: {
30
- action: removeAuthor,
31
- title: 'Remove',
32
- isDestructive: true,
33
- },
34
- };
35
- return (React.createElement(React.Fragment, null,
36
- React.createElement(PrimaryButton, { danger: true, onClick: this.props.handleOpen }, "Delete"),
37
- isOpen && (React.createElement(Dialog, { isOpen: isOpen, actions: actions, category: Category.confirmation, header: 'Remove author', message: `Are you sure you want to remove ${initials(author.bibliographicName)}${' '}${author.bibliographicName.family} from the authors list?` }))));
38
- }
39
- }
40
- export default RemoveAuthorButton;
@@ -1,16 +0,0 @@
1
- /*!
2
- * © 2019 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 './AuthorForm';
@@ -1,23 +0,0 @@
1
- /*!
2
- * © 2019 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
- import React from 'react';
17
- import styled, { withTheme } from 'styled-components';
18
- import { initials } from '../lib/name';
19
- const NameParts = styled.span ``;
20
- const buildNameLiteral = (name) => [initials(name), name.family, name.suffix].filter((part) => part).join(' ');
21
- const AuthorNameComponent = ({ name, email, theme }) => !name.given && !name.family ? (React.createElement(NameParts, { color: theme.colors.text.secondary, "data-testid": `author-name--unknown` }, "Unknown Author")) : (React.createElement(NameParts, { "data-testid": `author-name--${name.given}` }, (email && buildNameLiteral(name).concat(' ').concat(`(${email})`)) ||
22
- buildNameLiteral(name)));
23
- export const AuthorName = withTheme(AuthorNameComponent);
@@ -1,19 +0,0 @@
1
- /*!
2
- * © 2019 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
- import { AuthorName } from '../AuthorName';
17
- export const defaultAuthorItemComponents = {
18
- AuthorName,
19
- };
@@ -1,40 +0,0 @@
1
- /*!
2
- * © 2019 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
- import React, { useContext } from 'react';
17
- import styled, { ThemeContext } from 'styled-components';
18
- import DraggableAuthorItem from './DraggableAuthorItem';
19
- const SidebarList = styled.div `
20
- flex: 1;
21
- overflow-y: visible;
22
- `;
23
- const AuthorsDND = ({ authors, selectAuthor, selectedAuthor, handleDrop, getSidebarItemDecorator, components, }) => {
24
- const theme = useContext(ThemeContext);
25
- return (React.createElement(SidebarList, null, authors.map((author, index) => {
26
- const user = {
27
- _id: author.userID,
28
- };
29
- const authorItem = {
30
- _id: author._id,
31
- priority: author.priority || null,
32
- index,
33
- };
34
- const decorator = getSidebarItemDecorator
35
- ? getSidebarItemDecorator(author._id)
36
- : null;
37
- return (React.createElement(DraggableAuthorItem, { key: author._id, authorItem: authorItem, onDrop: handleDrop, author: author, authors: authors, user: user, selectedAuthor: selectedAuthor, selectAuthor: selectAuthor, sidebarItemDecorator: decorator, components: components, theme: theme }));
38
- })));
39
- };
40
- export default AuthorsDND;
@@ -1,192 +0,0 @@
1
- /*!
2
- * © 2019 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
- import CorrespondingAuthorBadge from '@manuscripts/assets/react/CorrespondingAuthorBadge';
17
- import JointFirstAuthorBadge from '@manuscripts/assets/react/FirstAuthorBadge';
18
- import VerticalEllipsis from '@manuscripts/assets/react/VerticalEllipsis';
19
- import React from 'react';
20
- import { DragSource, DropTarget, } from 'react-dnd';
21
- import { findDOMNode } from 'react-dom';
22
- import styled from 'styled-components';
23
- import { isJointFirstAuthor } from '../../lib/authors';
24
- import { Avatar } from '../Avatar';
25
- import { defaultAuthorItemComponents, } from './AuthorItemComponents';
26
- const AuthorItemComponent = styled.div `
27
- margin: 0 -${(props) => props.theme.grid.unit * 5}px;
28
- padding: ${(props) => props.theme.grid.unit * 2}px
29
- ${(props) => props.theme.grid.unit * 5}px;
30
- display: flex;
31
- justify-content: space-between;
32
- align-items: center;
33
- cursor: pointer;
34
- transition: background-color 0.25s;
35
- opacity: ${(props) => props.opacity};
36
-
37
- &:hover,
38
- &.active {
39
- background: ${(props) => props.theme.colors.background.fifth};
40
- }
41
-
42
- &.active {
43
- border: 1px solid ${(props) => props.theme.colors.border.primary};
44
- border-left: 0;
45
- border-right: 0;
46
- }
47
- `;
48
- const AuthorMetadata = styled.div `
49
- display: flex;
50
- align-items: center;
51
- `;
52
- const AvatarContainer = styled.span `
53
- display: inline-flex;
54
- position: relative;
55
- `;
56
- const AuthorBadge = styled.span `
57
- display: inline-flex;
58
- align-items: center;
59
- justify-content: center;
60
- position: relative;
61
- `;
62
- const AuthorNotes = styled.span `
63
- position: absolute;
64
- top: 0;
65
- right: 0;
66
-
67
- & ${AuthorBadge}:not(:last-child) {
68
- right: -20%;
69
- }
70
- `;
71
- const AuthorNameSpace = styled.span `
72
- margin-left: 12px;
73
- `;
74
- const InvitedContainer = styled.div `
75
- display: flex;
76
- align-items: center;
77
- `;
78
- const AuthorDropPreview = styled.div `
79
- width: 100%;
80
- background: ${(props) => props.theme.colors.brand.dark};
81
- height: 1px;
82
- position: relative;
83
- `;
84
- const DragHandle = styled.div `
85
- margin-left: 12px;
86
-
87
- &:hover {
88
- cursor: move;
89
- }
90
- `;
91
- const dragSourceSpec = {
92
- beginDrag(props) {
93
- return {
94
- authorItem: props.authorItem,
95
- };
96
- },
97
- };
98
- const dropTargetSpec = {
99
- hover(_props, monitor, component) {
100
- if (!monitor.isOver({ shallow: true })) {
101
- return;
102
- }
103
- const hoveredNode = findDOMNode(component);
104
- const { top, bottom } = hoveredNode.getBoundingClientRect();
105
- const offset = monitor.getClientOffset();
106
- if (!offset) {
107
- return;
108
- }
109
- const verticalMiddle = (bottom - top) / 2;
110
- const verticalHover = offset.y - top;
111
- const item = monitor.getItem();
112
- item.position = verticalHover < verticalMiddle ? 'before' : 'after';
113
- component.setState({
114
- dragPosition: item.position,
115
- });
116
- },
117
- canDrop(props, monitor) {
118
- const item = monitor.getItem();
119
- return props.authorItem._id !== item.authorItem._id;
120
- },
121
- drop(props, monitor) {
122
- if (monitor.didDrop()) {
123
- return;
124
- }
125
- const item = monitor.getItem();
126
- const oldIndex = item.authorItem.index;
127
- const newIndex = props.authorItem.index + (item.position === 'after' ? 0.5 : -0.5);
128
- props.onDrop(oldIndex, newIndex);
129
- },
130
- };
131
- class AuthorComponent extends React.Component {
132
- constructor() {
133
- super(...arguments);
134
- this.state = {
135
- dragPosition: null,
136
- };
137
- this.mightDrop = () => this.props.item && this.props.isOverCurrent && this.props.canDrop;
138
- this.selectedAuthorClass = () => {
139
- const { selectedAuthor, author } = this.props;
140
- return selectedAuthor && selectedAuthor._id === author._id ? 'active' : '';
141
- };
142
- this.topPreviewStyles = (mightDrop, dragPosition) => ({
143
- top: '0px',
144
- visibility: mightDrop && dragPosition === 'before' ? 'visible' : 'hidden',
145
- });
146
- this.bottomPreviewStyles = (mightDrop, dragPosition) => ({
147
- bottom: '-1px',
148
- visibility: mightDrop && dragPosition === 'after' ? 'visible' : 'hidden',
149
- });
150
- }
151
- render() {
152
- const { dragPosition } = this.state;
153
- const { isDragging, connectDragSource, connectDropTarget, selectAuthor, author, authors, user, authorItem, sidebarItemDecorator, theme, components, } = this.props;
154
- const opacity = isDragging ? 0 : 1;
155
- const { AuthorName } = Object.assign(Object.assign({}, defaultAuthorItemComponents), components);
156
- return connectDragSource(React.createElement("div", null,
157
- React.createElement(AuthorDropPreview, { style: this.topPreviewStyles(this.mightDrop(), dragPosition) }),
158
- connectDropTarget(React.createElement("div", null,
159
- React.createElement(AuthorItemComponent, { key: author._id, onClick: () => selectAuthor(author), className: this.selectedAuthorClass(), opacity: opacity },
160
- React.createElement(AuthorMetadata, null,
161
- React.createElement(AvatarContainer, null,
162
- React.createElement(Avatar, { src: user.avatar, size: 36, color: '#6e6e6e' }),
163
- React.createElement(AuthorNotes, null,
164
- author.isCorresponding && (React.createElement(AuthorBadge, null,
165
- React.createElement(CorrespondingAuthorBadge, null))),
166
- isJointFirstAuthor(authors, authorItem.index) && (React.createElement(AuthorBadge, null,
167
- React.createElement(JointFirstAuthorBadge, null))))),
168
- React.createElement(AuthorNameSpace, null,
169
- React.createElement(AuthorName, { name: author.bibliographicName }))),
170
- React.createElement(InvitedContainer, null,
171
- sidebarItemDecorator,
172
- this.selectedAuthorClass() && (React.createElement(DragHandle, null,
173
- React.createElement(VerticalEllipsis, { color: theme.colors.brand.default }))))))),
174
- React.createElement(AuthorDropPreview, { style: this.bottomPreviewStyles(this.mightDrop(), dragPosition) })));
175
- }
176
- }
177
- const dragSourceCollector = (connect, monitor) => ({
178
- connectDragSource: connect.dragSource(),
179
- isDragging: monitor.isDragging(),
180
- item: monitor.getItem(),
181
- });
182
- const dropTargetCollector = (connect, monitor) => ({
183
- connectDropTarget: connect.dropTarget(),
184
- isOver: monitor.isOver(),
185
- isOverCurrent: monitor.isOver({ shallow: true }),
186
- canDrop: monitor.canDrop(),
187
- });
188
- const dragType = 'authorItem';
189
- const dragSource = DragSource(dragType, dragSourceSpec, dragSourceCollector);
190
- const dropTarget = DropTarget(dragType, dropTargetSpec, dropTargetCollector);
191
- const DraggableAuthorItem = dragSource(dropTarget(AuthorComponent));
192
- export default DraggableAuthorItem;
@@ -1,16 +0,0 @@
1
- /*!
2
- * © 2019 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 { default as AuthorsDND } from './AuthorsDND';
@@ -1,98 +0,0 @@
1
- /*!
2
- * © 2019 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
- import { ObjectTypes, } from '@manuscripts/json-schema';
17
- const getModelsByType = (modelMap, objectType) => {
18
- const output = [];
19
- for (const model of modelMap.values()) {
20
- if (model.objectType === objectType) {
21
- output.push(model);
22
- }
23
- }
24
- return output;
25
- };
26
- export const buildSortedAuthors = (modelMap) => {
27
- return getModelsByType(modelMap, ObjectTypes.Contributor)
28
- .filter((item) => item.role === 'author')
29
- .sort((a, b) => Number(a.priority) - Number(b.priority));
30
- };
31
- export const buildAuthorPriority = (authors) => {
32
- if (!authors.length) {
33
- return 0;
34
- }
35
- const priorities = authors.map((author) => Number(author.priority));
36
- return Math.max(...priorities) + 1;
37
- };
38
- export const buildAffiliationIDs = (authors) => {
39
- const ids = [];
40
- authors.forEach((author) => {
41
- if (author.affiliations) {
42
- author.affiliations.forEach((id) => {
43
- ids.push(id);
44
- });
45
- }
46
- });
47
- return ids.filter((value, index) => ids.indexOf(value) === index);
48
- };
49
- export const buildAuthorAffiliations = (authors, affiliations, uniqueAffiliationIDs) => {
50
- const items = new Map();
51
- authors.forEach((author) => {
52
- items.set(author._id, (author.affiliations || []).map((id) => {
53
- return {
54
- ordinal: uniqueAffiliationIDs.indexOf(id) + 1,
55
- data: affiliations.get(id),
56
- };
57
- }));
58
- });
59
- return items;
60
- };
61
- export const buildAffiliationsMap = (affiliationIDs, modelMap) => new Map(affiliationIDs.map((id) => [
62
- id,
63
- modelMap.get(id),
64
- ]));
65
- export const buildAuthorsAndAffiliations = (modelMap) => {
66
- const authors = buildSortedAuthors(modelMap);
67
- const affiliationIDs = buildAffiliationIDs(authors);
68
- const affiliations = buildAffiliationsMap(affiliationIDs, modelMap);
69
- const authorAffiliations = buildAuthorAffiliations(authors, affiliations, affiliationIDs);
70
- return {
71
- affiliations,
72
- authors,
73
- authorAffiliations,
74
- };
75
- };
76
- export const isJointFirstAuthor = (authors, index) => {
77
- const author = index === 0 ? authors[index] : authors[index - 1];
78
- return Boolean(author.isJointContributor);
79
- };
80
- export const affiliationLabel = (affiliation) => {
81
- const { department, institution = '' } = affiliation;
82
- if (!institution) {
83
- return '(unknown institution)';
84
- }
85
- return department ? `${institution} (${department})`.trim() : institution;
86
- };
87
- export const affiliationsOptions = (affiliations, authorAffiliations) => {
88
- if (!authorAffiliations) {
89
- return affiliationsOptions(affiliations, []);
90
- }
91
- const authorAffiliationsIds = new Set(authorAffiliations.map((authorAffiliation) => authorAffiliation.data._id));
92
- return Array.from(affiliations.values())
93
- .filter((affiliation) => !authorAffiliationsIds.has(affiliation._id))
94
- .map((affiliation) => ({
95
- value: affiliation._id,
96
- label: affiliationLabel(affiliation) || '',
97
- }));
98
- };
@@ -1,29 +0,0 @@
1
- /*!
2
- * © 2019 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 default (affiliation) => {
17
- const { department, institution, addressLine1, city, county, country, postCode, } = affiliation;
18
- return [
19
- department,
20
- institution,
21
- addressLine1,
22
- city,
23
- county,
24
- country,
25
- postCode,
26
- ]
27
- .filter(Boolean)
28
- .join(', ');
29
- };
@@ -1,22 +0,0 @@
1
- /*!
2
- * © 2019 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 const initials = (name) => name.given
17
- ? name.given
18
- .trim()
19
- .split(' ')
20
- .map((part) => part.substr(0, 1).toUpperCase() + '.')
21
- .join('')
22
- : '';
package/dist/es/types.js DELETED
@@ -1,16 +0,0 @@
1
- /*!
2
- * © 2019 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 {};
@@ -1,31 +0,0 @@
1
- /*!
2
- * © 2019 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
- import React from 'react';
17
- import { AffiliationGeneric, AuthorAffiliation } from '../../types';
18
- import { AuthorFormComponentOverrides } from '../AuthorForm/AuthorFormComponents';
19
- interface Props {
20
- affiliations: Map<string, AffiliationGeneric>;
21
- authorAffiliations?: AuthorAffiliation[];
22
- addAuthorAffiliation: (affiliation: AffiliationGeneric | string) => void;
23
- removeAuthorAffiliation: (affiliation: AffiliationGeneric) => void;
24
- updateAffiliation: (affiliation: AffiliationGeneric) => void;
25
- components?: AuthorFormComponentOverrides;
26
- styleOverrides?: {
27
- menuZIndex?: number;
28
- };
29
- }
30
- declare const AffiliationsEditor: React.FC<Props>;
31
- export default AffiliationsEditor;
@@ -1,26 +0,0 @@
1
- /*!
2
- * © 2019 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
- import React from 'react';
17
- import { AffiliationGeneric } from '../../types';
18
- interface Props {
19
- affiliation: AffiliationGeneric;
20
- requestToggle: () => void;
21
- isOpen: boolean;
22
- updateAffiliation: (affiliation: AffiliationGeneric) => void;
23
- removeAuthorAffiliation: (affiliation: AffiliationGeneric) => void;
24
- }
25
- export declare const AffiliationsEditorItem: React.FC<Props>;
26
- export default AffiliationsEditorItem;
@@ -1,30 +0,0 @@
1
- /*!
2
- * © 2019 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
- import { UserProfileAffiliation } from '@manuscripts/json-schema';
17
- import React from 'react';
18
- import { AuthorFormComponentOverrides } from '../AuthorForm/AuthorFormComponents';
19
- interface Props {
20
- affiliations: Map<string, UserProfileAffiliation>;
21
- addAffiliation: (affiliation: string) => void;
22
- removeAffiliation: (affiliation: UserProfileAffiliation) => void;
23
- updateAffiliation: (affiliation: UserProfileAffiliation) => void;
24
- components?: AuthorFormComponentOverrides;
25
- styleOverrides?: {
26
- menuZIndex?: number;
27
- };
28
- }
29
- declare const AffiliationsEditorProfile: React.FC<Props>;
30
- export default AffiliationsEditorProfile;
@@ -1,34 +0,0 @@
1
- /*!
2
- * © 2019 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
- import React from 'react';
17
- import { OnChangeValue } from 'react-select';
18
- import { AffiliationGeneric, AffiliationOption } from '../../types';
19
- import { AuthorFormComponentOverrides } from '../AuthorForm/AuthorFormComponents';
20
- interface Props {
21
- options: AffiliationOption[];
22
- selected: AffiliationGeneric[];
23
- inputValue: string;
24
- handleInputChange: (text: string) => void;
25
- handleChoose: (value: OnChangeValue<AffiliationOption, false>) => void;
26
- updateAffiliation: (affiliation: AffiliationGeneric) => void;
27
- removeAuthorAffiliation: (affiliation: AffiliationGeneric) => void;
28
- components?: AuthorFormComponentOverrides;
29
- styleOverrides?: {
30
- menuZIndex?: number;
31
- };
32
- }
33
- declare const AffiliationsEditorView: React.FC<Props>;
34
- export default AffiliationsEditorView;
@@ -1,17 +0,0 @@
1
- /*!
2
- * © 2019 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 { default as AffiliationsEditor } from './AffiliationsEditor';
17
- export { default as AffiliationsEditorProfile } from './AffiliationsEditorProfile';