@manuscripts/style-guide 1.7.8-LEAN-3301 → 1.7.8-LEAN-3278

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 (81) hide show
  1. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditor.js +62 -0
  2. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorItem.js +176 -0
  3. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorProfile.js +62 -0
  4. package/dist/cjs/components/AffiliationsEditor/AffiliationsEditorView.js +80 -0
  5. package/dist/cjs/components/AffiliationsEditor/index.js +25 -0
  6. package/dist/cjs/components/AffiliationsEditor/styles.js +56 -0
  7. package/dist/cjs/components/AuthorForm/AuthorForm.js +99 -0
  8. package/dist/cjs/components/AuthorForm/AuthorFormComponents.js +63 -0
  9. package/dist/cjs/components/AuthorForm/ContributorRolesSelect.js +100 -0
  10. package/dist/cjs/components/AuthorForm/RemoveAuthorButton.js +45 -0
  11. package/dist/cjs/components/AuthorForm/index.js +32 -0
  12. package/dist/cjs/components/AuthorName.js +52 -0
  13. package/dist/cjs/components/AuthorsDND/AuthorItemComponents.js +22 -0
  14. package/dist/cjs/components/AuthorsDND/AuthorsDND.js +68 -0
  15. package/dist/cjs/components/AuthorsDND/DraggableAuthorItem.js +197 -0
  16. package/dist/cjs/components/AuthorsDND/index.js +23 -0
  17. package/dist/cjs/components/{DragLayer.js → FileManager/DragLayer.js} +50 -26
  18. package/dist/cjs/components/FileManager/FileManager.js +1 -1
  19. package/dist/cjs/components/icons/index.js +1 -3
  20. package/dist/cjs/index.js +6 -2
  21. package/dist/cjs/lib/authors.js +110 -0
  22. package/dist/cjs/lib/capabilities.js +1 -1
  23. package/dist/cjs/lib/formatAddress.js +31 -0
  24. package/dist/cjs/lib/name.js +26 -0
  25. package/dist/cjs/types.js +17 -0
  26. package/dist/es/components/AffiliationsEditor/AffiliationsEditor.js +34 -0
  27. package/dist/es/components/AffiliationsEditor/AffiliationsEditorItem.js +146 -0
  28. package/dist/es/components/AffiliationsEditor/AffiliationsEditorProfile.js +34 -0
  29. package/dist/es/components/AffiliationsEditor/AffiliationsEditorView.js +52 -0
  30. package/dist/es/components/AffiliationsEditor/index.js +17 -0
  31. package/dist/es/components/AffiliationsEditor/styles.js +49 -0
  32. package/dist/es/components/AuthorForm/AuthorForm.js +92 -0
  33. package/dist/es/components/AuthorForm/AuthorFormComponents.js +57 -0
  34. package/dist/es/components/AuthorForm/ContributorRolesSelect.js +70 -0
  35. package/dist/es/components/AuthorForm/RemoveAuthorButton.js +40 -0
  36. package/dist/es/components/AuthorForm/index.js +16 -0
  37. package/dist/es/components/AuthorName.js +23 -0
  38. package/dist/es/components/AuthorsDND/AuthorItemComponents.js +19 -0
  39. package/dist/es/components/AuthorsDND/AuthorsDND.js +40 -0
  40. package/dist/es/components/AuthorsDND/DraggableAuthorItem.js +192 -0
  41. package/dist/es/components/AuthorsDND/index.js +16 -0
  42. package/dist/es/components/{DragLayer.js → FileManager/DragLayer.js} +27 -26
  43. package/dist/es/components/FileManager/FileManager.js +1 -1
  44. package/dist/es/components/icons/index.js +0 -1
  45. package/dist/es/index.js +6 -2
  46. package/dist/es/lib/authors.js +98 -0
  47. package/dist/es/lib/capabilities.js +1 -1
  48. package/dist/es/lib/formatAddress.js +29 -0
  49. package/dist/es/lib/name.js +22 -0
  50. package/dist/es/types.js +16 -0
  51. package/dist/types/components/AffiliationsEditor/AffiliationsEditor.d.ts +31 -0
  52. package/dist/types/components/AffiliationsEditor/AffiliationsEditorItem.d.ts +26 -0
  53. package/dist/types/components/AffiliationsEditor/AffiliationsEditorProfile.d.ts +30 -0
  54. package/dist/types/components/AffiliationsEditor/AffiliationsEditorView.d.ts +34 -0
  55. package/dist/types/components/AffiliationsEditor/index.d.ts +17 -0
  56. package/dist/types/components/AffiliationsEditor/styles.d.ts +23 -0
  57. package/dist/types/components/AlertMessage.d.ts +1 -1
  58. package/dist/types/components/AuthorForm/AuthorForm.d.ts +29 -0
  59. package/dist/types/components/AuthorForm/AuthorFormComponents.d.ts +31 -0
  60. package/dist/types/components/AuthorForm/ContributorRolesSelect.d.ts +23 -0
  61. package/dist/types/components/AuthorForm/RemoveAuthorButton.d.ts +27 -0
  62. package/dist/types/components/AuthorForm/index.d.ts +16 -0
  63. package/dist/types/components/AuthorName.d.ts +22 -0
  64. package/dist/types/components/AuthorsDND/AuthorItemComponents.d.ts +24 -0
  65. package/dist/types/components/AuthorsDND/AuthorsDND.d.ts +28 -0
  66. package/dist/types/components/AuthorsDND/DraggableAuthorItem.d.ts +50 -0
  67. package/dist/types/components/AuthorsDND/index.d.ts +16 -0
  68. package/dist/types/components/Button.d.ts +9 -9
  69. package/dist/types/components/EditorHeader/EditorHeader.d.ts +1 -1
  70. package/dist/types/components/InspectorSection.d.ts +1 -1
  71. package/dist/types/components/NavDropdown.d.ts +1 -1
  72. package/dist/types/components/StyledModal.d.ts +1 -1
  73. package/dist/types/components/icons/index.d.ts +0 -1
  74. package/dist/types/index.d.ts +6 -2
  75. package/dist/types/lib/authors.d.ts +30 -0
  76. package/dist/types/lib/capabilities.d.ts +1 -1
  77. package/dist/types/lib/formatAddress.d.ts +18 -0
  78. package/dist/types/lib/name.d.ts +17 -0
  79. package/dist/types/types.d.ts +80 -0
  80. package/package.json +1 -1
  81. /package/dist/types/components/{DragLayer.d.ts → FileManager/DragLayer.d.ts} +0 -0
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.DeleteIcon = exports.PlusIcon = exports.PullQuoteIcon = exports.BlockQuoteIcon = exports.LeftArrow = exports.AnnotatorIcon = exports.ReadingIcon = exports.EditIcon = exports.UnsupportedFormatFileIcon = exports.MissingImage = exports.UploadIcon = exports.AttachIcon = exports.TaskStepNextIcon = exports.TaskStepDoneIcon = exports.TaskStepCurrentIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.UserIcon = exports.TickMarkIcon = exports.SearchIcon = exports.ProjectsListIcon = exports.ProjectIcon = exports.ProjectNotificationIcon = exports.OrcidIcon = exports.GoogleIcon = exports.AddComment = exports.CloseOIcon = exports.CloseIcon = exports.BookmarkIcon = exports.BackArrowIcon = exports.AddIconInverted = exports.AddIconActive = exports.AddAuthor = void 0;
21
+ exports.PlusIcon = exports.PullQuoteIcon = exports.BlockQuoteIcon = exports.LeftArrow = exports.AnnotatorIcon = exports.ReadingIcon = exports.EditIcon = exports.UnsupportedFormatFileIcon = exports.MissingImage = exports.UploadIcon = exports.AttachIcon = exports.TaskStepNextIcon = exports.TaskStepDoneIcon = exports.TaskStepCurrentIcon = exports.ZoomOutIcon = exports.ZoomInIcon = exports.UserIcon = exports.TickMarkIcon = exports.SearchIcon = exports.ProjectsListIcon = exports.ProjectIcon = exports.ProjectNotificationIcon = exports.OrcidIcon = exports.GoogleIcon = exports.AddComment = exports.CloseOIcon = exports.CloseIcon = exports.BookmarkIcon = exports.BackArrowIcon = exports.AddIconInverted = exports.AddIconActive = exports.AddAuthor = void 0;
22
22
  var add_author_1 = require("./add-author");
23
23
  Object.defineProperty(exports, "AddAuthor", { enumerable: true, get: function () { return __importDefault(add_author_1).default; } });
24
24
  var add_icon_active_1 = require("./add-icon-active");
@@ -83,5 +83,3 @@ var pull_quote_icon_1 = require("./pull-quote-icon");
83
83
  Object.defineProperty(exports, "PullQuoteIcon", { enumerable: true, get: function () { return __importDefault(pull_quote_icon_1).default; } });
84
84
  var plus_icon_1 = require("./plus-icon");
85
85
  Object.defineProperty(exports, "PlusIcon", { enumerable: true, get: function () { return __importDefault(plus_icon_1).default; } });
86
- var delete_icon_1 = require("./delete-icon");
87
- Object.defineProperty(exports, "DeleteIcon", { enumerable: true, get: function () { return delete_icon_1.DeleteIcon; } });
package/dist/cjs/index.js CHANGED
@@ -33,6 +33,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.errorsDecoder = exports.useDeepCompareCallback = exports.useDeepCompareMemo = void 0;
36
+ __exportStar(require("./components/AffiliationsEditor"), exports);
37
+ __exportStar(require("./components/AuthorForm"), exports);
38
+ __exportStar(require("./components/AuthorName"), exports);
39
+ __exportStar(require("./components/AuthorsDND"), exports);
36
40
  __exportStar(require("./components/AlertMessage"), exports);
37
41
  __exportStar(require("./components/Button"), exports);
38
42
  __exportStar(require("./components/RadioButton"), exports);
@@ -47,8 +51,6 @@ __exportStar(require("./components/Resizer"), exports);
47
51
  __exportStar(require("./components/SaveStatus"), exports);
48
52
  __exportStar(require("./components/StyledModal"), exports);
49
53
  __exportStar(require("./components/TableFootnotesSelector"), exports);
50
- __exportStar(require("./components/Sidebar"), exports);
51
- __exportStar(require("./components/DragLayer"), exports);
52
54
  __exportStar(require("./components/TextField"), exports);
53
55
  __exportStar(require("./components/TextFieldContainer"), exports);
54
56
  __exportStar(require("./components/TextFieldError"), exports);
@@ -75,9 +77,11 @@ __exportStar(require("./hooks/use-menus"), exports);
75
77
  var use_deep_compare_1 = require("./hooks/use-deep-compare");
76
78
  Object.defineProperty(exports, "useDeepCompareMemo", { enumerable: true, get: function () { return use_deep_compare_1.useDeepCompareMemo; } });
77
79
  Object.defineProperty(exports, "useDeepCompareCallback", { enumerable: true, get: function () { return use_deep_compare_1.useDeepCompareCallback; } });
80
+ __exportStar(require("./lib/authors"), exports);
78
81
  __exportStar(require("./lib/capabilities"), exports);
79
82
  __exportStar(require("./lib/files"), exports);
80
83
  __exportStar(require("./lib/comments"), exports);
81
84
  __exportStar(require("./lib/menus"), exports);
82
85
  var errors_decoder_1 = require("./lib/errors-decoder");
83
86
  Object.defineProperty(exports, "errorsDecoder", { enumerable: true, get: function () { return __importDefault(errors_decoder_1).default; } });
87
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,110 @@
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;
@@ -23,6 +23,7 @@ const getCapabilities = (project, profile, role, actions) => {
23
23
  const allowed = (action) => !!(actions === null || actions === void 0 ? void 0 : actions.includes(action));
24
24
  return {
25
25
  handleSuggestion: isOwner() || isEditor() || isWriter(),
26
+ editWithoutTracking: isWriter(),
26
27
  rejectOwnSuggestion: !isViewer(),
27
28
  createSuggestion: !isViewer(),
28
29
  viewSuggestion: true,
@@ -52,7 +53,6 @@ const getCapabilities = (project, profile, role, actions) => {
52
53
  putOnHoldTask: isProdEditor(),
53
54
  changeDueDate: isProdEditor() && allowed(Actions.updateDueDate),
54
55
  previewAccess: true,
55
- editNotTracked: false,
56
56
  accessEditor: true,
57
57
  formatArticle: !isViewer(),
58
58
  editArticle: !isViewer(),
@@ -0,0 +1,31 @@
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
+ };
@@ -0,0 +1,26 @@
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;
@@ -0,0 +1,17 @@
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 });
@@ -0,0 +1,34 @@
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;
@@ -0,0 +1,146 @@
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;
@@ -0,0 +1,34 @@
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;
@@ -0,0 +1,52 @@
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;
@@ -0,0 +1,17 @@
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';
@@ -0,0 +1,49 @@
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)));