@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.
- package/dist/cjs/components/{FileManager/DragLayer.js → DragLayer.js} +26 -50
- package/dist/cjs/components/FileManager/FileManager.js +1 -1
- package/dist/cjs/components/icons/index.js +3 -1
- package/dist/cjs/index.js +2 -6
- package/dist/es/components/{FileManager/DragLayer.js → DragLayer.js} +26 -27
- package/dist/es/components/FileManager/FileManager.js +1 -1
- package/dist/es/components/icons/index.js +1 -0
- package/dist/es/index.js +2 -6
- package/dist/types/components/AlertMessage.d.ts +1 -1
- package/dist/types/components/Button.d.ts +9 -9
- package/dist/types/components/EditorHeader/EditorHeader.d.ts +1 -1
- package/dist/types/components/InspectorSection.d.ts +1 -1
- package/dist/types/components/NavDropdown.d.ts +1 -1
- package/dist/types/components/StyledModal.d.ts +1 -1
- package/dist/types/components/icons/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -6
- package/package.json +1 -1
- package/dist/cjs/components/AffiliationsEditor/AffiliationsEditor.js +0 -62
- package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorItem.js +0 -176
- package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorProfile.js +0 -62
- package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorView.js +0 -80
- package/dist/cjs/components/AffiliationsEditor/index.js +0 -25
- package/dist/cjs/components/AffiliationsEditor/styles.js +0 -56
- package/dist/cjs/components/AuthorForm/AuthorForm.js +0 -99
- package/dist/cjs/components/AuthorForm/AuthorFormComponents.js +0 -63
- package/dist/cjs/components/AuthorForm/ContributorRolesSelect.js +0 -100
- package/dist/cjs/components/AuthorForm/RemoveAuthorButton.js +0 -45
- package/dist/cjs/components/AuthorForm/index.js +0 -32
- package/dist/cjs/components/AuthorName.js +0 -52
- package/dist/cjs/components/AuthorsDND/AuthorItemComponents.js +0 -22
- package/dist/cjs/components/AuthorsDND/AuthorsDND.js +0 -68
- package/dist/cjs/components/AuthorsDND/DraggableAuthorItem.js +0 -197
- package/dist/cjs/components/AuthorsDND/index.js +0 -23
- package/dist/cjs/lib/authors.js +0 -110
- package/dist/cjs/lib/formatAddress.js +0 -31
- package/dist/cjs/lib/name.js +0 -26
- package/dist/cjs/types.js +0 -17
- package/dist/es/components/AffiliationsEditor/AffiliationsEditor.js +0 -34
- package/dist/es/components/AffiliationsEditor/AffiliationsEditorItem.js +0 -146
- package/dist/es/components/AffiliationsEditor/AffiliationsEditorProfile.js +0 -34
- package/dist/es/components/AffiliationsEditor/AffiliationsEditorView.js +0 -52
- package/dist/es/components/AffiliationsEditor/index.js +0 -17
- package/dist/es/components/AffiliationsEditor/styles.js +0 -49
- package/dist/es/components/AuthorForm/AuthorForm.js +0 -92
- package/dist/es/components/AuthorForm/AuthorFormComponents.js +0 -57
- package/dist/es/components/AuthorForm/ContributorRolesSelect.js +0 -70
- package/dist/es/components/AuthorForm/RemoveAuthorButton.js +0 -40
- package/dist/es/components/AuthorForm/index.js +0 -16
- package/dist/es/components/AuthorName.js +0 -23
- package/dist/es/components/AuthorsDND/AuthorItemComponents.js +0 -19
- package/dist/es/components/AuthorsDND/AuthorsDND.js +0 -40
- package/dist/es/components/AuthorsDND/DraggableAuthorItem.js +0 -192
- package/dist/es/components/AuthorsDND/index.js +0 -16
- package/dist/es/lib/authors.js +0 -98
- package/dist/es/lib/formatAddress.js +0 -29
- package/dist/es/lib/name.js +0 -22
- package/dist/es/types.js +0 -16
- package/dist/types/components/AffiliationsEditor/AffiliationsEditor.d.ts +0 -31
- package/dist/types/components/AffiliationsEditor/AffiliationsEditorItem.d.ts +0 -26
- package/dist/types/components/AffiliationsEditor/AffiliationsEditorProfile.d.ts +0 -30
- package/dist/types/components/AffiliationsEditor/AffiliationsEditorView.d.ts +0 -34
- package/dist/types/components/AffiliationsEditor/index.d.ts +0 -17
- package/dist/types/components/AffiliationsEditor/styles.d.ts +0 -23
- package/dist/types/components/AuthorForm/AuthorForm.d.ts +0 -29
- package/dist/types/components/AuthorForm/AuthorFormComponents.d.ts +0 -31
- package/dist/types/components/AuthorForm/ContributorRolesSelect.d.ts +0 -23
- package/dist/types/components/AuthorForm/RemoveAuthorButton.d.ts +0 -27
- package/dist/types/components/AuthorForm/index.d.ts +0 -16
- package/dist/types/components/AuthorName.d.ts +0 -22
- package/dist/types/components/AuthorsDND/AuthorItemComponents.d.ts +0 -24
- package/dist/types/components/AuthorsDND/AuthorsDND.d.ts +0 -28
- package/dist/types/components/AuthorsDND/DraggableAuthorItem.d.ts +0 -50
- package/dist/types/components/AuthorsDND/index.d.ts +0 -16
- package/dist/types/lib/authors.d.ts +0 -30
- package/dist/types/lib/formatAddress.d.ts +0 -18
- package/dist/types/lib/name.d.ts +0 -17
- package/dist/types/types.d.ts +0 -80
- /package/dist/types/components/{FileManager/DragLayer.d.ts → DragLayer.d.ts} +0 -0
|
@@ -1,31 +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.default = (affiliation) => {
|
|
19
|
-
const { department, institution, addressLine1, city, county, country, postCode, } = affiliation;
|
|
20
|
-
return [
|
|
21
|
-
department,
|
|
22
|
-
institution,
|
|
23
|
-
addressLine1,
|
|
24
|
-
city,
|
|
25
|
-
county,
|
|
26
|
-
country,
|
|
27
|
-
postCode,
|
|
28
|
-
]
|
|
29
|
-
.filter(Boolean)
|
|
30
|
-
.join(', ');
|
|
31
|
-
};
|
package/dist/cjs/lib/name.js
DELETED
|
@@ -1,26 +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.initials = void 0;
|
|
19
|
-
const initials = (name) => name.given
|
|
20
|
-
? name.given
|
|
21
|
-
.trim()
|
|
22
|
-
.split(' ')
|
|
23
|
-
.map((part) => part.substr(0, 1).toUpperCase() + '.')
|
|
24
|
-
.join('')
|
|
25
|
-
: '';
|
|
26
|
-
exports.initials = initials;
|
package/dist/cjs/types.js
DELETED
|
@@ -1,17 +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 });
|
|
@@ -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, { useCallback, useState } from 'react';
|
|
17
|
-
import { affiliationsOptions } from '../../lib/authors';
|
|
18
|
-
import AffiliationsEditorView from './AffiliationsEditorView';
|
|
19
|
-
const AffiliationsEditor = ({ affiliations, authorAffiliations, addAuthorAffiliation, updateAffiliation, removeAuthorAffiliation, components, styleOverrides, }) => {
|
|
20
|
-
const [searchText, setSearchText] = useState('');
|
|
21
|
-
const handleChoose = useCallback((value) => {
|
|
22
|
-
if (value) {
|
|
23
|
-
const selectedAffiliation = value;
|
|
24
|
-
addAuthorAffiliation(selectedAffiliation.value);
|
|
25
|
-
}
|
|
26
|
-
setSearchText('');
|
|
27
|
-
}, [addAuthorAffiliation]);
|
|
28
|
-
const options = affiliationsOptions(affiliations, authorAffiliations);
|
|
29
|
-
const active = authorAffiliations
|
|
30
|
-
? authorAffiliations.map((item) => item.data)
|
|
31
|
-
: [];
|
|
32
|
-
return (React.createElement(AffiliationsEditorView, { options: options, selected: active, updateAffiliation: updateAffiliation, removeAuthorAffiliation: removeAuthorAffiliation, components: components, styleOverrides: styleOverrides, handleChoose: handleChoose, handleInputChange: setSearchText, inputValue: searchText }));
|
|
33
|
-
};
|
|
34
|
-
export default AffiliationsEditor;
|
|
@@ -1,146 +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 Trashcan from '@manuscripts/assets/react/AnnotationRemove';
|
|
17
|
-
import ArrowDownBlue from '@manuscripts/assets/react/ArrowDownBlue';
|
|
18
|
-
import { Field, Form, Formik } from 'formik';
|
|
19
|
-
import React, { useCallback } from 'react';
|
|
20
|
-
import styled from 'styled-components';
|
|
21
|
-
import { affiliationLabel } from '../../lib/authors';
|
|
22
|
-
import { AutoSaveInput } from '../AutoSaveInput';
|
|
23
|
-
import { TextField } from '../TextField';
|
|
24
|
-
const Section = styled.section `
|
|
25
|
-
border: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
26
|
-
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
27
|
-
background: ${(props) => props.theme.colors.background.primary};
|
|
28
|
-
margin-bottom: 2px;
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
`;
|
|
31
|
-
const Title = styled.h4 `
|
|
32
|
-
margin: 0;
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
font-size: 0.875rem;
|
|
36
|
-
padding-right: 0.5rem;
|
|
37
|
-
background: ${(props) => props.isInvalid ? props.theme.colors.background.warning : 'transparent'};
|
|
38
|
-
color: ${(props) => props.isInvalid ? props.theme.colors.text.warning : 'inherit'};
|
|
39
|
-
`;
|
|
40
|
-
const DropdownIndicator = styled(ArrowDownBlue) `
|
|
41
|
-
border: 0;
|
|
42
|
-
border-radius: 50%;
|
|
43
|
-
margin-right: 0.6em;
|
|
44
|
-
min-width: 20px;
|
|
45
|
-
`;
|
|
46
|
-
const ToggleButton = styled.button `
|
|
47
|
-
flex-grow: 1;
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
width: 100%;
|
|
51
|
-
background: transparent;
|
|
52
|
-
border: none;
|
|
53
|
-
text-align: left;
|
|
54
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
55
|
-
font-size: 1rem;
|
|
56
|
-
padding: 0.6em 0.5em;
|
|
57
|
-
|
|
58
|
-
outline: none;
|
|
59
|
-
|
|
60
|
-
&:focus {
|
|
61
|
-
color: ${(props) => props.theme.colors.button.primary.border.hover};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
svg {
|
|
65
|
-
transform: ${(props) => (props.isOpen ? 'rotateX(180deg)' : 'initial')};
|
|
66
|
-
}
|
|
67
|
-
`;
|
|
68
|
-
const RemoveButton = styled.button `
|
|
69
|
-
border: none;
|
|
70
|
-
background: transparent;
|
|
71
|
-
padding: 0;
|
|
72
|
-
|
|
73
|
-
outline: none;
|
|
74
|
-
|
|
75
|
-
&:focus path {
|
|
76
|
-
fill: ${(props) => props.theme.colors.button.primary.color.hover};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
svg {
|
|
80
|
-
width: 2rem;
|
|
81
|
-
height: 2rem;
|
|
82
|
-
}
|
|
83
|
-
`;
|
|
84
|
-
const AffiliationsForm = styled(Form) `
|
|
85
|
-
border: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
86
|
-
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
87
|
-
margin: 0.4rem 0.71rem 0.71rem;
|
|
88
|
-
overflow: hidden;
|
|
89
|
-
`;
|
|
90
|
-
const AffiliationsTextField = styled(TextField) `
|
|
91
|
-
border-radius: 0;
|
|
92
|
-
border-bottom: none;
|
|
93
|
-
border-right: none;
|
|
94
|
-
border-left: none;
|
|
95
|
-
background: transparent;
|
|
96
|
-
&:first-child {
|
|
97
|
-
border-top: none;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
&[aria-invalid] {
|
|
101
|
-
background: ${(props) => props.theme.colors.background.warning};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
&[aria-invalid]:focus {
|
|
105
|
-
background: transparent;
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
const Columns = styled.div `
|
|
109
|
-
display: flex;
|
|
110
|
-
`;
|
|
111
|
-
const Column = styled.div `
|
|
112
|
-
flex: 1 1 auto;
|
|
113
|
-
max-width: 50%;
|
|
114
|
-
border-top: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
115
|
-
border-left: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
116
|
-
&:first-child {
|
|
117
|
-
border-left: none;
|
|
118
|
-
}
|
|
119
|
-
`;
|
|
120
|
-
export const AffiliationsEditorItem = ({ affiliation, requestToggle, isOpen, updateAffiliation, removeAuthorAffiliation, }) => {
|
|
121
|
-
const remove = useCallback(() => {
|
|
122
|
-
removeAuthorAffiliation(affiliation);
|
|
123
|
-
}, [affiliation, removeAuthorAffiliation]);
|
|
124
|
-
const vivifiedAffiliation = Object.assign({ institution: '', department: '', addressLine1: '', addressLine2: '', addressLine3: '', city: '', county: '', country: '', postCode: '' }, affiliation);
|
|
125
|
-
const isInvalid = !vivifiedAffiliation.institution;
|
|
126
|
-
return (React.createElement(Section, null,
|
|
127
|
-
React.createElement(Title, { isInvalid: isInvalid },
|
|
128
|
-
React.createElement(ToggleButton, { type: "button", onClick: requestToggle, isOpen: isOpen },
|
|
129
|
-
React.createElement(DropdownIndicator, null,
|
|
130
|
-
React.createElement(ArrowDownBlue, null)),
|
|
131
|
-
affiliationLabel(affiliation)),
|
|
132
|
-
React.createElement(RemoveButton, { type: "button", "aria-label": "Delete this affiliation", onClick: remove },
|
|
133
|
-
React.createElement(Trashcan, null))),
|
|
134
|
-
isOpen && (React.createElement(Formik, { initialValues: vivifiedAffiliation, onSubmit: updateAffiliation }, () => (React.createElement(AffiliationsForm, null,
|
|
135
|
-
React.createElement(Field, { name: "institution" }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: AffiliationsTextField, saveOn: "blur", placeholder: "Institution Name", isInvalid: isInvalid })))),
|
|
136
|
-
React.createElement(Field, { name: "department" }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: AffiliationsTextField, saveOn: "blur", placeholder: "Department" })))),
|
|
137
|
-
React.createElement(Field, { name: "addressLine1" }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: AffiliationsTextField, saveOn: "blur", placeholder: "Street Address" })))),
|
|
138
|
-
React.createElement(Columns, null,
|
|
139
|
-
React.createElement(Column, null,
|
|
140
|
-
React.createElement(Field, { name: "city" }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: AffiliationsTextField, saveOn: "blur", placeholder: "City" })))),
|
|
141
|
-
React.createElement(Field, { name: "county" }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: AffiliationsTextField, saveOn: "blur", placeholder: "State / Province" }))))),
|
|
142
|
-
React.createElement(Column, null,
|
|
143
|
-
React.createElement(Field, { name: "postCode" }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: AffiliationsTextField, saveOn: "blur", placeholder: "Postal Code" })))),
|
|
144
|
-
React.createElement(Field, { name: "country" }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: AffiliationsTextField, saveOn: "blur", placeholder: "Country" }))))))))))));
|
|
145
|
-
};
|
|
146
|
-
export default AffiliationsEditorItem;
|
|
@@ -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 { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
|
-
import React, { useCallback, useState } from 'react';
|
|
18
|
-
import AffiliationsEditorView from './AffiliationsEditorView';
|
|
19
|
-
const AffiliationsEditorProfile = ({ affiliations, addAffiliation, updateAffiliation, removeAffiliation, components, styleOverrides, }) => {
|
|
20
|
-
const [searchText, setSearchText] = useState('');
|
|
21
|
-
const handleChoose = useCallback((value) => {
|
|
22
|
-
if (value) {
|
|
23
|
-
const selectedAffiliation = value;
|
|
24
|
-
addAffiliation(selectedAffiliation.value);
|
|
25
|
-
}
|
|
26
|
-
setSearchText('');
|
|
27
|
-
}, [addAffiliation]);
|
|
28
|
-
const affiliationsArr = Array.from(affiliations.values());
|
|
29
|
-
const updateUserProfileAffiliation = useCallback((data) => {
|
|
30
|
-
updateAffiliation(Object.assign(Object.assign({}, data), { objectType: ObjectTypes.UserProfileAffiliation }));
|
|
31
|
-
}, [updateAffiliation]);
|
|
32
|
-
return (React.createElement(AffiliationsEditorView, { options: [], selected: affiliationsArr, updateAffiliation: updateUserProfileAffiliation, removeAuthorAffiliation: removeAffiliation, components: components, styleOverrides: styleOverrides, handleChoose: handleChoose, handleInputChange: setSearchText, inputValue: searchText }));
|
|
33
|
-
};
|
|
34
|
-
export default AffiliationsEditorProfile;
|
|
@@ -1,52 +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, useState } from 'react';
|
|
17
|
-
import CreatableSelect from 'react-select/creatable';
|
|
18
|
-
import { ThemeContext } from 'styled-components';
|
|
19
|
-
import { defaultAuthorFormComponents, } from '../AuthorForm/AuthorFormComponents';
|
|
20
|
-
import { AffiliationsEditorItem } from './AffiliationsEditorItem';
|
|
21
|
-
import { AddAffiliationIndicator, Container, Field, List } from './styles';
|
|
22
|
-
const reactSelectComponents = {
|
|
23
|
-
IndicatorsContainer: AddAffiliationIndicator,
|
|
24
|
-
};
|
|
25
|
-
const AffiliationsEditorView = ({ options, selected, updateAffiliation, removeAuthorAffiliation, handleChoose, handleInputChange, inputValue, components, styleOverrides, }) => {
|
|
26
|
-
const { Legend } = Object.assign(Object.assign({}, defaultAuthorFormComponents), components);
|
|
27
|
-
const [currentSection, setCurrentSection] = useState('');
|
|
28
|
-
const requestOpen = (id) => {
|
|
29
|
-
setCurrentSection(id === currentSection ? '' : id);
|
|
30
|
-
};
|
|
31
|
-
const theme = useContext(ThemeContext);
|
|
32
|
-
return (React.createElement(Container, null,
|
|
33
|
-
React.createElement(Legend, null, "Affiliations"),
|
|
34
|
-
React.createElement(Field, null,
|
|
35
|
-
React.createElement(List, null, selected &&
|
|
36
|
-
selected.map((affiliation) => {
|
|
37
|
-
const { _id } = affiliation;
|
|
38
|
-
return (React.createElement(AffiliationsEditorItem, { key: _id, affiliation: affiliation, isOpen: currentSection === _id, requestToggle: () => requestOpen(_id), updateAffiliation: updateAffiliation, removeAuthorAffiliation: removeAuthorAffiliation }));
|
|
39
|
-
})),
|
|
40
|
-
React.createElement(CreatableSelect, { isMulti: false, isClearable: false, options: options, onInputChange: (t) => handleInputChange(t), inputValue: inputValue, onChange: handleChoose, value: null, placeholder: "Begin typing to add affiliation", isValidNewOption: (currentText) => !!currentText, components: reactSelectComponents, noOptionsMessage: () => 'Type the name of an institution', styles: {
|
|
41
|
-
control: (provided, state) => (Object.assign(Object.assign({}, provided), { backgroundColor: state.isFocused
|
|
42
|
-
? theme.colors.background.fifth
|
|
43
|
-
: theme.colors.background.primary, borderColor: state.isFocused
|
|
44
|
-
? theme.colors.border.field.active
|
|
45
|
-
: theme.colors.border.field.default, '&:hover': {
|
|
46
|
-
backgroundColor: theme.colors.background.fifth,
|
|
47
|
-
}, borderRadius: theme.grid.radius.default, boxShadow: 'none', fontFamily: theme.font.family.sans })),
|
|
48
|
-
menu: (provided) => (Object.assign(Object.assign({}, provided), { zIndex: (styleOverrides && styleOverrides.menuZIndex) ||
|
|
49
|
-
provided.zIndex })),
|
|
50
|
-
} }))));
|
|
51
|
-
};
|
|
52
|
-
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';
|
|
@@ -1,49 +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 AddAuthor from '@manuscripts/assets/react/AddAuthor';
|
|
17
|
-
import React from 'react';
|
|
18
|
-
import styled from 'styled-components';
|
|
19
|
-
export const Container = styled.div `
|
|
20
|
-
margin: 0 1.89rem 1rem;
|
|
21
|
-
`;
|
|
22
|
-
export const Field = styled.div `
|
|
23
|
-
margin: 1rem 0;
|
|
24
|
-
`;
|
|
25
|
-
export const List = styled.div `
|
|
26
|
-
margin-bottom: 0.5rem;
|
|
27
|
-
`;
|
|
28
|
-
export const AddAffiliationContainer = styled.div `
|
|
29
|
-
padding-right: 0.71rem;
|
|
30
|
-
display: flex;
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
justify-content: space-around;
|
|
33
|
-
|
|
34
|
-
svg {
|
|
35
|
-
width: 1.5rem;
|
|
36
|
-
height: 1.5rem;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
circle,
|
|
40
|
-
use {
|
|
41
|
-
fill: ${(props) => props.theme.colors.brand.default};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
path {
|
|
45
|
-
mask: none;
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
export const AddAffiliationIndicator = () => (React.createElement(AddAffiliationContainer, null,
|
|
49
|
-
React.createElement(AddAuthor, null)));
|
|
@@ -1,92 +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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
import { Field, Form, Formik } from 'formik';
|
|
26
|
-
import React from 'react';
|
|
27
|
-
import styled from 'styled-components';
|
|
28
|
-
import { AutoSaveInput } from '../AutoSaveInput';
|
|
29
|
-
import { CheckboxField, CheckboxLabel } from '../Checkbox';
|
|
30
|
-
import { TextFieldLabel } from '../TextField';
|
|
31
|
-
import { TextFieldGroupContainer } from '../TextFieldGroupContainer';
|
|
32
|
-
import { Container, defaultAuthorFormComponents, Fields, Fieldset, Label, LabelText, } from './AuthorFormComponents';
|
|
33
|
-
import RemoveAuthorButton from './RemoveAuthorButton';
|
|
34
|
-
const ensureString = (value) => value || '';
|
|
35
|
-
const buildInitialValues = (author) => {
|
|
36
|
-
return {
|
|
37
|
-
affiliations: author.affiliations || [],
|
|
38
|
-
_id: author._id,
|
|
39
|
-
priority: Number(author.priority),
|
|
40
|
-
email: ensureString(author.email),
|
|
41
|
-
isCorresponding: Boolean(author.isCorresponding),
|
|
42
|
-
bibliographicName: {
|
|
43
|
-
_id: author.bibliographicName._id,
|
|
44
|
-
objectType: author.bibliographicName.objectType,
|
|
45
|
-
given: ensureString(author.bibliographicName.given),
|
|
46
|
-
family: ensureString(author.bibliographicName.family),
|
|
47
|
-
suffix: ensureString(author.bibliographicName.suffix),
|
|
48
|
-
},
|
|
49
|
-
role: ensureString(author.role),
|
|
50
|
-
contribution: ensureString(author.contribution),
|
|
51
|
-
ORCIDIdentifier: ensureString(author.ORCIDIdentifier),
|
|
52
|
-
roles: author.roles || [],
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
const OrcidContainer = styled.div `
|
|
56
|
-
margin: 16px 0 0;
|
|
57
|
-
`;
|
|
58
|
-
const RolesContainer = styled.div `
|
|
59
|
-
margin: 16px 0;
|
|
60
|
-
`;
|
|
61
|
-
export const AuthorForm = ({ author, handleSave, removeAuthor, isRemoveAuthorOpen, handleRemoveAuthor, components, }) => {
|
|
62
|
-
const { Legend, TextField } = Object.assign(Object.assign({}, defaultAuthorFormComponents), components);
|
|
63
|
-
return (React.createElement(Formik, { initialValues: buildInitialValues(author), onSubmit: handleSave, enableReinitialize: true }, ({ values }) => {
|
|
64
|
-
const isAuthor = values.role === 'author';
|
|
65
|
-
return (React.createElement(Form, null,
|
|
66
|
-
React.createElement(Fields, null,
|
|
67
|
-
React.createElement(Fieldset, null,
|
|
68
|
-
React.createElement(Container, null,
|
|
69
|
-
React.createElement(Legend, null, "Details"),
|
|
70
|
-
React.createElement(RemoveAuthorButton, { author: author, removeAuthor: () => {
|
|
71
|
-
removeAuthor(author);
|
|
72
|
-
}, isOpen: isRemoveAuthorOpen, handleOpen: handleRemoveAuthor })),
|
|
73
|
-
React.createElement(TextFieldGroupContainer, null,
|
|
74
|
-
React.createElement(Field, { name: 'bibliographicName.given' }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: TextField, saveOn: 'blur', placeholder: 'Given name', testId: "bibliographic-name-given" })))),
|
|
75
|
-
React.createElement(Field, { name: 'bibliographicName.family' }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { component: TextField, saveOn: 'blur', placeholder: 'Family name', testId: "bibliographic-name-family" }))))),
|
|
76
|
-
React.createElement(CheckboxLabel, { disabled: !isAuthor },
|
|
77
|
-
React.createElement(Field, { name: 'isCorresponding' }, (props) => (React.createElement(AutoSaveInput, Object.assign({}, props, { disabled: !isAuthor, component: CheckboxField, saveOn: 'change', testId: "corresponding-checkbox" })))),
|
|
78
|
-
React.createElement(LabelText, null, "Corresponding Author")),
|
|
79
|
-
values.isCorresponding && (React.createElement(Label, null,
|
|
80
|
-
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" })))))),
|
|
81
|
-
React.createElement(CheckboxLabel, null,
|
|
82
|
-
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* () {
|
|
83
|
-
props.form.setFieldValue(props.field.name, event.target.checked ? 'author' : 'other', false);
|
|
84
|
-
yield props.form.submitForm();
|
|
85
|
-
}) }))),
|
|
86
|
-
React.createElement(LabelText, null, "Include in Authors List")),
|
|
87
|
-
React.createElement(OrcidContainer, null,
|
|
88
|
-
React.createElement(TextFieldLabel, null,
|
|
89
|
-
React.createElement(LabelText, null, "ORCID"),
|
|
90
|
-
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" }))))))))));
|
|
91
|
-
}));
|
|
92
|
-
};
|
|
@@ -1,57 +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 styled from 'styled-components';
|
|
17
|
-
import { CheckboxLabel } from '../Checkbox';
|
|
18
|
-
import { TextField } from '../TextField';
|
|
19
|
-
export const Fields = styled.div `
|
|
20
|
-
padding: 16px;
|
|
21
|
-
`;
|
|
22
|
-
export const Label = styled.label `
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
margin-bottom: 10px;
|
|
26
|
-
`;
|
|
27
|
-
export const LabelText = styled.div `
|
|
28
|
-
font: ${(props) => props.theme.font.weight.normal}
|
|
29
|
-
${(props) => props.theme.font.size.normal} / 1
|
|
30
|
-
${(props) => props.theme.font.family.sans};
|
|
31
|
-
letter-spacing: -0.2px;
|
|
32
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
33
|
-
`;
|
|
34
|
-
export const Fieldset = styled.fieldset `
|
|
35
|
-
border: none;
|
|
36
|
-
|
|
37
|
-
&:not(:last-child) {
|
|
38
|
-
margin-bottom: 16px;
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
export const Legend = styled.legend `
|
|
42
|
-
font: ${(props) => props.theme.font.weight.normal}
|
|
43
|
-
${(props) => props.theme.font.size.xlarge} /
|
|
44
|
-
${(props) => props.theme.font.lineHeight.large}
|
|
45
|
-
${(props) => props.theme.font.family.sans};
|
|
46
|
-
letter-spacing: -0.4px;
|
|
47
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
48
|
-
`;
|
|
49
|
-
export const Container = styled.div `
|
|
50
|
-
display: flex;
|
|
51
|
-
justify-content: space-between;
|
|
52
|
-
`;
|
|
53
|
-
export const defaultAuthorFormComponents = {
|
|
54
|
-
Legend,
|
|
55
|
-
CheckboxLabel,
|
|
56
|
-
TextField,
|
|
57
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2020 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
import React, { useMemo, useState } from 'react';
|
|
26
|
-
import CreatableSelect from 'react-select/creatable';
|
|
27
|
-
const sortRolesAlphabetical = (a, b) => a.name.localeCompare(b.name);
|
|
28
|
-
export const ContributorRolesSelect = ({ contributorRoles, createContributorRole, value, setFieldValue }) => {
|
|
29
|
-
const [saving, setSaving] = useState(false);
|
|
30
|
-
const selectedRoles = useMemo(() => value
|
|
31
|
-
.map((id) => contributorRoles.find((item) => item._id === id))
|
|
32
|
-
.flat(), [contributorRoles, value]);
|
|
33
|
-
const options = useMemo(() => {
|
|
34
|
-
const output = { local: [], 'dictionary.casrai.org': [] };
|
|
35
|
-
const groupedOptions = contributorRoles.reduce((output, contributorRole) => {
|
|
36
|
-
if (contributorRole.uri) {
|
|
37
|
-
const { hostname } = new URL(contributorRole.uri);
|
|
38
|
-
if (hostname in output) {
|
|
39
|
-
output[hostname].push(contributorRole);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
output.local.push(contributorRole);
|
|
44
|
-
}
|
|
45
|
-
return output;
|
|
46
|
-
}, output);
|
|
47
|
-
return [
|
|
48
|
-
{
|
|
49
|
-
options: groupedOptions.local.sort(sortRolesAlphabetical),
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
label: 'CASRAI CRediT',
|
|
53
|
-
options: groupedOptions['dictionary.casrai.org'].sort(sortRolesAlphabetical),
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
}, [contributorRoles]);
|
|
57
|
-
return (React.createElement(CreatableSelect, { 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) => {
|
|
58
|
-
const option = {
|
|
59
|
-
name: `Create "${inputValue}" role`,
|
|
60
|
-
};
|
|
61
|
-
return option;
|
|
62
|
-
}, onCreateOption: (inputValue) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
setSaving(true);
|
|
64
|
-
const contribution = yield createContributorRole(inputValue);
|
|
65
|
-
setSaving(false);
|
|
66
|
-
setFieldValue([...value, contribution._id]);
|
|
67
|
-
}), getOptionValue: (option) => option._id, getOptionLabel: (option) => option.name, onChange: (value) => {
|
|
68
|
-
setFieldValue(value.map((item) => item._id));
|
|
69
|
-
} }));
|
|
70
|
-
};
|