@manuscripts/body-editor 2.7.7 → 2.7.8-LEAN-4213.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 (72) hide show
  1. package/dist/cjs/components/affiliations/AffiliationForm.js +106 -0
  2. package/dist/cjs/components/affiliations/AffiliationItem.js +112 -0
  3. package/dist/cjs/components/affiliations/AffiliationList.js +47 -0
  4. package/dist/cjs/components/affiliations/AffiliationsModal.js +418 -0
  5. package/dist/cjs/components/authors/AuthorDetailsForm.js +10 -2
  6. package/dist/cjs/components/authors/AuthorList.js +1 -1
  7. package/dist/cjs/components/authors/AuthorsModal.js +184 -80
  8. package/dist/cjs/components/authors/DraggableAuthor.js +0 -3
  9. package/dist/cjs/components/dialog/ConfirmationDialog.js +86 -0
  10. package/dist/cjs/components/form/FormFooter.js +32 -0
  11. package/dist/cjs/components/form/FormPlaceholder.js +43 -0
  12. package/dist/cjs/components/{authors/AuthorActions.js → form/ModalFormActions.js} +12 -11
  13. package/dist/cjs/plugins/affiliations.js +5 -38
  14. package/dist/cjs/useEditor.js +0 -1
  15. package/dist/cjs/versions.js +1 -1
  16. package/dist/cjs/views/affiliations.js +82 -14
  17. package/dist/cjs/views/contributors.js +1 -9
  18. package/dist/es/components/affiliations/AffiliationForm.js +76 -0
  19. package/dist/es/components/affiliations/AffiliationItem.js +82 -0
  20. package/dist/es/components/affiliations/AffiliationList.js +40 -0
  21. package/dist/es/components/affiliations/AffiliationsModal.js +388 -0
  22. package/dist/es/components/authors/AuthorDetailsForm.js +11 -3
  23. package/dist/es/components/authors/AuthorList.js +1 -1
  24. package/dist/es/components/authors/AuthorsModal.js +183 -79
  25. package/dist/es/components/authors/DraggableAuthor.js +0 -3
  26. package/dist/es/components/dialog/ConfirmationDialog.js +79 -0
  27. package/dist/es/components/form/FormFooter.js +27 -0
  28. package/dist/es/components/form/FormPlaceholder.js +36 -0
  29. package/dist/es/components/{authors/AuthorActions.js → form/ModalFormActions.js} +10 -9
  30. package/dist/es/plugins/affiliations.js +6 -39
  31. package/dist/es/useEditor.js +0 -1
  32. package/dist/es/versions.js +1 -1
  33. package/dist/es/views/affiliations.js +85 -17
  34. package/dist/es/views/contributors.js +1 -9
  35. package/dist/types/components/{authors → affiliations}/AffiliationForm.d.ts +5 -0
  36. package/dist/types/components/affiliations/AffiliationItem.d.ts +10 -0
  37. package/dist/types/components/affiliations/AffiliationList.d.ts +26 -0
  38. package/dist/types/components/affiliations/AffiliationsModal.d.ts +11 -0
  39. package/dist/types/components/authors/AuthorDetailsForm.d.ts +1 -0
  40. package/dist/types/components/authors/AuthorsModal.d.ts +2 -1
  41. package/dist/types/components/dialog/ConfirmationDialog.d.ts +15 -0
  42. package/dist/types/components/form/FormFooter.d.ts +5 -0
  43. package/dist/types/components/form/FormPlaceholder.d.ts +9 -0
  44. package/dist/types/components/{authors/AuthorActions.d.ts → form/ModalFormActions.d.ts} +4 -3
  45. package/dist/types/lib/dnd.d.ts +1 -1
  46. package/dist/types/selection.d.ts +7 -1
  47. package/dist/types/versions.d.ts +1 -1
  48. package/dist/types/views/affiliations.d.ts +11 -0
  49. package/dist/types/views/contributors.d.ts +0 -1
  50. package/package.json +2 -2
  51. package/styles/AdvancedEditor.css +8 -4
  52. package/styles/Editor.css +7 -0
  53. package/dist/cjs/components/authors/AffiliationButton.js +0 -104
  54. package/dist/cjs/components/authors/AffiliationForm.js +0 -50
  55. package/dist/cjs/components/authors/AuthorAffiliations.js +0 -120
  56. package/dist/cjs/components/authors/AuthorFormPlaceholder.js +0 -71
  57. package/dist/cjs/components/authors/DeleteAuthorConfirmationDialog.js +0 -36
  58. package/dist/cjs/components/authors/RequiredFieldConfirmationDialog.js +0 -39
  59. package/dist/cjs/components/authors/SaveAuthorConfirmationDialog.js +0 -39
  60. package/dist/es/components/authors/AffiliationButton.js +0 -74
  61. package/dist/es/components/authors/AffiliationForm.js +0 -43
  62. package/dist/es/components/authors/AuthorAffiliations.js +0 -89
  63. package/dist/es/components/authors/AuthorFormPlaceholder.js +0 -64
  64. package/dist/es/components/authors/DeleteAuthorConfirmationDialog.js +0 -29
  65. package/dist/es/components/authors/RequiredFieldConfirmationDialog.js +0 -32
  66. package/dist/es/components/authors/SaveAuthorConfirmationDialog.js +0 -32
  67. package/dist/types/components/authors/AffiliationButton.d.ts +0 -8
  68. package/dist/types/components/authors/AuthorAffiliations.d.ts +0 -11
  69. package/dist/types/components/authors/AuthorFormPlaceholder.d.ts +0 -2
  70. package/dist/types/components/authors/DeleteAuthorConfirmationDialog.d.ts +0 -7
  71. package/dist/types/components/authors/RequiredFieldConfirmationDialog.d.ts +0 -7
  72. package/dist/types/components/authors/SaveAuthorConfirmationDialog.d.ts +0 -7
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AuthorActions = void 0;
6
+ exports.ModalFormActions = void 0;
7
7
  const style_guide_1 = require("@manuscripts/style-guide");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const styled_components_1 = __importDefault(require("styled-components"));
10
- const DeleteAuthorConfirmationDialog_1 = require("./DeleteAuthorConfirmationDialog");
11
- const AuthorActionsContainer = styled_components_1.default.div `
10
+ const ConfirmationDialog_1 = require("../dialog/ConfirmationDialog");
11
+ const ActionsContainer = styled_components_1.default.div `
12
12
  display: flex;
13
13
  `;
14
14
  const StyledButtonGroup = (0, styled_components_1.default)(style_guide_1.ButtonGroup) `
@@ -20,8 +20,9 @@ const StyledIconButton = (0, styled_components_1.default)(style_guide_1.IconButt
20
20
  font-size: 14px;
21
21
  font-style: normal;
22
22
  font-weight: 400;
23
- line-height: 24px;
23
+ line-height: 1;
24
24
  width: auto;
25
+ height: 24px;
25
26
  &:disabled {
26
27
  color: #c9c9c9 !important;
27
28
  background-color: unset !important;
@@ -31,15 +32,15 @@ const StyledIconButton = (0, styled_components_1.default)(style_guide_1.IconButt
31
32
  margin-right: 4px;
32
33
  }
33
34
  `;
34
- const AuthorActions = ({ onSave, onDelete, showDeleteDialog, handleShowDeleteDialog, newAuthor, isDisableSave, }) => {
35
- return (react_1.default.createElement(AuthorActionsContainer, { "data-cy": "author-action" },
36
- react_1.default.createElement(DeleteAuthorConfirmationDialog_1.DeleteAuthorConfirmationDialog, { isOpen: showDeleteDialog, onDelete: () => {
37
- handleShowDeleteDialog();
35
+ const ModalFormActions = ({ type, onSave, onDelete, showDeleteDialog, handleShowDeleteDialog, newEntity, isDisableSave, }) => {
36
+ return (react_1.default.createElement(ActionsContainer, { "data-cy": `${type}-action` },
37
+ react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showDeleteDialog, onPrimary: () => {
38
38
  onDelete();
39
- }, onCancel: () => handleShowDeleteDialog() }),
39
+ handleShowDeleteDialog();
40
+ }, onSecondary: handleShowDeleteDialog, type: ConfirmationDialog_1.DialogType.DELETE, entityType: type }),
40
41
  react_1.default.createElement(StyledButtonGroup, null,
41
42
  react_1.default.createElement(StyledIconButton, { onClick: onSave, disabled: isDisableSave, type: "submit" },
42
43
  react_1.default.createElement(style_guide_1.PlusIcon, null),
43
- newAuthor ? 'Save Details' : 'Update Details'))));
44
+ newEntity ? 'Save Details' : 'Update Details'))));
44
45
  };
45
- exports.AuthorActions = AuthorActions;
46
+ exports.ModalFormActions = ModalFormActions;
@@ -21,7 +21,6 @@ const lodash_1 = require("lodash");
21
21
  const prosemirror_state_1 = require("prosemirror-state");
22
22
  const prosemirror_view_1 = require("prosemirror-view");
23
23
  const authors_1 = require("../lib/authors");
24
- const plugins_1 = require("../lib/plugins");
25
24
  const track_changes_utils_1 = require("../lib/track-changes-utils");
26
25
  exports.affiliationsKey = new prosemirror_state_1.PluginKey('affiliations');
27
26
  let id = 1;
@@ -48,9 +47,12 @@ const buildPluginState = (doc, $old) => {
48
47
  return $old;
49
48
  }
50
49
  const iAffiliations = new Set();
51
- contributors.sort(authors_1.authorComparator).forEach((attrs) => {
50
+ contributors
51
+ .filter((contrib) => !deletedContribId.has(contrib.id))
52
+ .sort(authors_1.authorComparator)
53
+ .forEach((attrs) => {
52
54
  attrs.affiliations.forEach((aff) => {
53
- !deletedContribId.has(attrs.id) && iAffiliations.add(aff);
55
+ iAffiliations.add(aff);
54
56
  });
55
57
  });
56
58
  const indexedAffiliationIds = new Map([...iAffiliations].map((id, i) => [id, i + 1]));
@@ -87,41 +89,6 @@ exports.default = () => {
87
89
  }
88
90
  },
89
91
  },
90
- appendTransaction(transactions, oldState, newState) {
91
- const affs = exports.affiliationsKey.getState(newState);
92
- if (!affs || !transactions.find((tr) => tr.docChanged || (0, plugins_1.isInit)(tr))) {
93
- return;
94
- }
95
- const $old = exports.affiliationsKey.getState(oldState);
96
- const affiliations = new Map();
97
- newState.doc.descendants((node, pos) => {
98
- if ((0, transform_1.isAffiliationNode)(node)) {
99
- affiliations.set(node.attrs.id, [node, pos]);
100
- }
101
- });
102
- const deleteIDs = [];
103
- for (const [id] of $old.indexedAffiliationIds.entries()) {
104
- if (!affs.indexedAffiliationIds.has(id)) {
105
- deleteIDs.push(id);
106
- }
107
- }
108
- if (!deleteIDs.length) {
109
- return;
110
- }
111
- const tr = newState.tr;
112
- tr.setMeta('origin', 'affiliations');
113
- for (const id of deleteIDs) {
114
- const affiliation = affiliations.get(id);
115
- if (!affiliation) {
116
- continue;
117
- }
118
- const [node, pos] = affiliation;
119
- if (node && !(0, track_changes_utils_1.isPendingInsert)(node)) {
120
- tr.delete(pos, pos + node.nodeSize);
121
- }
122
- }
123
- return tr;
124
- },
125
92
  props: {
126
93
  decorations: (state) => { var _a; return (_a = exports.affiliationsKey.getState(state)) === null || _a === void 0 ? void 0 : _a.decorations; },
127
94
  },
@@ -45,7 +45,6 @@ const useEditor = (externalProps) => {
45
45
  const localVersion = (0, prosemirror_collab_1.getVersion)(view.current.state);
46
46
  const since = yield collabProvider.stepsSince(localVersion);
47
47
  if (since && since.version <= localVersion) {
48
- console.log('detected run away update of document');
49
48
  return;
50
49
  }
51
50
  if ((since === null || since === void 0 ? void 0 : since.steps.length) && since.clientIDs.length) {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.7.7';
4
+ exports.VERSION = '2.7.8-LEAN-4213.0';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -19,7 +19,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.AffiliationsView = void 0;
22
+ const style_guide_1 = require("@manuscripts/style-guide");
23
+ const transform_1 = require("@manuscripts/transform");
22
24
  const prosemirror_state_1 = require("prosemirror-state");
25
+ const AffiliationsModal_1 = require("../components/affiliations/AffiliationsModal");
23
26
  const authors_1 = require("../lib/authors");
24
27
  const track_changes_utils_1 = require("../lib/track-changes-utils");
25
28
  const view_1 = require("../lib/view");
@@ -27,11 +30,90 @@ const affiliations_1 = require("../plugins/affiliations");
27
30
  const selected_suggestion_1 = require("../plugins/selected-suggestion");
28
31
  const block_view_1 = __importDefault(require("./block_view"));
29
32
  const creators_1 = require("./creators");
33
+ const ReactSubView_1 = __importDefault(require("./ReactSubView"));
30
34
  class AffiliationsView extends block_view_1.default {
31
35
  constructor() {
32
36
  super(...arguments);
33
37
  this.ignoreMutation = () => true;
34
38
  this.stopEvent = () => true;
39
+ this.handleClick = (event) => {
40
+ const element = event.target;
41
+ const item = element.closest('.affiliation');
42
+ if (item) {
43
+ const node = (0, view_1.findChildByID)(this.view, item.id);
44
+ if (!node) {
45
+ return;
46
+ }
47
+ const view = this.view;
48
+ const tr = view.state.tr;
49
+ tr.setSelection(prosemirror_state_1.NodeSelection.create(view.state.doc, node.pos));
50
+ view.dispatch(tr);
51
+ }
52
+ };
53
+ this.insertAffiliationNode = (attrs) => {
54
+ const pos = this.getPos();
55
+ const tr = this.view.state.tr;
56
+ const node = transform_1.schema.nodes.affiliation.create(attrs);
57
+ this.view.dispatch(tr.insert(pos + 1, node));
58
+ };
59
+ this.handleSaveAffiliation = (affiliation) => {
60
+ const update = (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.affiliation, affiliation);
61
+ if (!update) {
62
+ this.insertAffiliationNode(affiliation);
63
+ }
64
+ };
65
+ this.handleDeleteAffiliation = (affiliation) => {
66
+ (0, view_1.deleteNode)(this.view, affiliation.id);
67
+ };
68
+ this.handleEdit = (addNew) => {
69
+ var _a;
70
+ this.props.popper.destroy();
71
+ const contributors = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.contributor);
72
+ const affiliations = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.affiliation);
73
+ const componentProps = {
74
+ authors: contributors,
75
+ affiliations,
76
+ onSaveAffiliation: this.handleSaveAffiliation,
77
+ onDeleteAffiliation: this.handleDeleteAffiliation,
78
+ onUpdateAuthors: this.handleUpdateAuthors,
79
+ addNewAffiliation: addNew,
80
+ };
81
+ (_a = this.popper) === null || _a === void 0 ? void 0 : _a.remove();
82
+ this.popper = (0, ReactSubView_1.default)(this.props, AffiliationsModal_1.AffiliationsModal, componentProps, this.node, this.getPos, this.view);
83
+ this.container.appendChild(this.popper);
84
+ };
85
+ this.showContextMenu = () => {
86
+ const can = this.props.getCapabilities();
87
+ const componentProps = {
88
+ actions: [],
89
+ };
90
+ if (can.editArticle) {
91
+ componentProps.actions.push({
92
+ label: 'New Affiliation',
93
+ action: () => this.handleEdit(true),
94
+ icon: 'AddOutline',
95
+ });
96
+ componentProps.actions.push({
97
+ label: 'Edit',
98
+ action: () => this.handleEdit(),
99
+ icon: 'Edit',
100
+ });
101
+ }
102
+ this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
103
+ return this.contextMenu;
104
+ };
105
+ this.selectNode = () => {
106
+ this.dom.classList.add('ProseMirror-selectednode');
107
+ if (!(0, track_changes_utils_1.isDeleted)(this.node)) {
108
+ this.handleEdit(true);
109
+ }
110
+ };
111
+ this.actionGutterButtons = () => [this.showContextMenu()];
112
+ this.handleUpdateAuthors = (authors) => {
113
+ authors.forEach((author) => {
114
+ (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.contributor, author);
115
+ });
116
+ };
35
117
  }
36
118
  createElement() {
37
119
  this.container = document.createElement('div');
@@ -90,20 +172,6 @@ class AffiliationsView extends block_view_1.default {
90
172
  const index2 = aff2.index || 10000;
91
173
  return index1 - index2;
92
174
  }
93
- handleClick(event) {
94
- const element = event.target;
95
- const item = element.closest('.affiliation');
96
- if (item) {
97
- const node = (0, view_1.findChildByID)(this.view, item.id);
98
- if (!node) {
99
- return;
100
- }
101
- const view = this.view;
102
- const tr = view.state.tr;
103
- tr.setSelection(prosemirror_state_1.NodeSelection.create(view.state.doc, node.pos));
104
- view.dispatch(tr);
105
- }
106
- }
107
175
  updateSelection() {
108
176
  var _a;
109
177
  const state = this.view.state;
@@ -205,11 +205,11 @@ class ContributorsView extends block_view_1.default {
205
205
  affiliations,
206
206
  onSaveAuthor: this.handleSaveAuthor,
207
207
  onDeleteAuthor: this.handleDeleteAuthor,
208
- onSaveAffiliation: this.handleSaveAffiliation,
209
208
  addNewAuthor: addNew,
210
209
  };
211
210
  (_a = this.popper) === null || _a === void 0 ? void 0 : _a.remove();
212
211
  this.popper = (0, ReactSubView_1.default)(this.props, AuthorsModal_1.AuthorsModal, componentProps, this.node, this.getPos, this.view);
212
+ console.dir(this.popper);
213
213
  this.container.appendChild(this.popper);
214
214
  };
215
215
  this.handleSaveAuthor = (author) => {
@@ -221,14 +221,6 @@ class ContributorsView extends block_view_1.default {
221
221
  this.handleDeleteAuthor = (author) => {
222
222
  (0, view_1.deleteNode)(this.view, author.id);
223
223
  };
224
- this.handleSaveAffiliation = (affiliation) => {
225
- if (!(0, view_1.findChildByID)(this.view, affiliation.id)) {
226
- this.insertAffiliationNode(affiliation);
227
- }
228
- else {
229
- (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.affiliation, affiliation);
230
- }
231
- };
232
224
  this.insertAuthorNode = (attrs) => {
233
225
  const parent = (0, view_1.findChildByType)(this.view, transform_1.schema.nodes.contributors);
234
226
  const tr = this.view.state.tr;
@@ -0,0 +1,76 @@
1
+ import { TextArea, TextField } from '@manuscripts/style-guide';
2
+ import { Field, Formik } from 'formik';
3
+ import React, { useRef } from 'react';
4
+ import styled from 'styled-components';
5
+ import { ChangeHandlingForm } from '../ChangeHandlingForm';
6
+ const Row = styled.div `
7
+ display: flex;
8
+ `;
9
+ const AffiliationsTextField = styled(TextField) `
10
+ border-radius: 0;
11
+ background: transparent;
12
+ margin-bottom: 4px;
13
+ border-radius: ${(props) => props.theme.grid.radius.default};
14
+ &[aria-invalid] {
15
+ background: ${(props) => props.theme.colors.background.warning};
16
+ }
17
+
18
+ &[aria-invalid]:focus {
19
+ background: transparent;
20
+ }
21
+ `;
22
+ const DepartmentTextField = styled(TextArea) `
23
+ border-radius: 0;
24
+ background: transparent;
25
+ margin-bottom: 4px;
26
+ min-height: 60px;
27
+ border-radius: ${(props) => props.theme.grid.radius.default};
28
+ &[aria-invalid] {
29
+ background: ${(props) => props.theme.colors.background.warning};
30
+ }
31
+
32
+ &[aria-invalid]:focus {
33
+ background: transparent;
34
+ }
35
+ `;
36
+ const FormLabel = styled.legend `
37
+ &:not(:first-child) {
38
+ margin-top: 24px;
39
+ }
40
+ margin-bottom: 12px;
41
+ font: ${(props) => props.theme.font.weight.normal}
42
+ ${(props) => props.theme.font.size.xlarge} /
43
+ ${(props) => props.theme.font.lineHeight.large}
44
+ ${(props) => props.theme.font.family.sans};
45
+ letter-spacing: -0.4px;
46
+ color: ${(props) => props.theme.colors.text.secondary};
47
+ `;
48
+ const MarginRightTextField = styled(AffiliationsTextField) `
49
+ margin-right: 4px;
50
+ `;
51
+ export const AffiliationForm = ({ values, onSave, onChange, actionsRef, }) => {
52
+ if (actionsRef && !actionsRef.current) {
53
+ actionsRef.current = {
54
+ reset: () => {
55
+ var _a;
56
+ (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.resetForm();
57
+ },
58
+ };
59
+ }
60
+ const formRef = useRef(null);
61
+ return (React.createElement(Formik, { initialValues: values, onSubmit: onSave, innerRef: formRef, enableReinitialize: true }, () => (React.createElement(ChangeHandlingForm, { onChange: onChange },
62
+ React.createElement(FormLabel, null, "Institution*"),
63
+ React.createElement(Row, null,
64
+ React.createElement(Field, { name: "institution" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "institution", placeholder: "Institution Name" }, props.field))))),
65
+ React.createElement(FormLabel, null, "Details"),
66
+ React.createElement(Row, null,
67
+ React.createElement(Field, { name: "department" }, (props) => (React.createElement(DepartmentTextField, Object.assign({ id: "department", placeholder: "Department" }, props.field))))),
68
+ React.createElement(Row, null,
69
+ React.createElement(Field, { name: "addressLine1" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "addressLine1", placeholder: "Street Address" }, props.field))))),
70
+ React.createElement(Row, null,
71
+ React.createElement(Field, { name: "city" }, (props) => (React.createElement(MarginRightTextField, Object.assign({ id: "city", placeholder: "City" }, props.field)))),
72
+ React.createElement(Field, { name: "county" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "county", placeholder: "State / Province" }, props.field))))),
73
+ React.createElement(Row, null,
74
+ React.createElement(Field, { name: "postCode" }, (props) => (React.createElement(MarginRightTextField, Object.assign({ id: "postCode", placeholder: "Postal Code" }, props.field)))),
75
+ React.createElement(Field, { name: "country" }, ({ field }) => (React.createElement(AffiliationsTextField, Object.assign({ id: "country", placeholder: "Country" }, field)))))))));
76
+ };
@@ -0,0 +1,82 @@
1
+ import { AffiliationIcon, CrclTickAnimation, DeleteIcon, Tooltip, } from '@manuscripts/style-guide';
2
+ import React, { useRef } from 'react';
3
+ import styled from 'styled-components';
4
+ const AffiliationContainer = styled.div `
5
+ padding: ${(props) => props.theme.grid.unit * 2}px 0
6
+ ${(props) => props.theme.grid.unit * 2}px;
7
+ display: flex;
8
+ align-items: center;
9
+ transition: background-color 0.25s;
10
+ border: 1px solid transparent;
11
+ border-left: 0;
12
+ border-right: 0;
13
+ cursor: pointer;
14
+ &:hover,
15
+ &.active {
16
+ background: ${(props) => props.theme.colors.background.fifth};
17
+ }
18
+
19
+ &.active {
20
+ border-color: ${(props) => props.theme.colors.border.primary};
21
+ }
22
+ `;
23
+ const AffiliationName = styled.div `
24
+ margin-left: 12px;
25
+ flex: 1;
26
+ text-overflow: ellipsis;
27
+ white-space: nowrap;
28
+ overflow: hidden;
29
+ width: 250px;
30
+ `;
31
+ const AffiliationDetails = styled.div `
32
+ margin-left: 12px;
33
+ flex: 1;
34
+ font-size: 12px;
35
+ font-style: normal;
36
+ font-weight: 400;
37
+ line-height: 16px;
38
+ margin-top: 2px;
39
+ color: ${(props) => props.theme.colors.text.secondary};
40
+ `;
41
+ const AffiliationBox = styled.div `
42
+ display: flex;
43
+ flex-direction: column;
44
+ margin-left: 4px;
45
+ `;
46
+ const RemoveButton = styled.div `
47
+ display: flex;
48
+ align-items: center;
49
+ margin-right: 8px;
50
+ svg {
51
+ cursor: pointer;
52
+ }
53
+ .icon_element {
54
+ fill: #6e6e6e;
55
+ }
56
+ `;
57
+ export const AffiliationItem = ({ affiliation, isSelected, onClick, onDelete, showSuccessIcon, }) => {
58
+ var _a;
59
+ const ref = useRef(null);
60
+ if (isSelected) {
61
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
62
+ behavior: 'smooth',
63
+ block: 'nearest',
64
+ });
65
+ }
66
+ return (React.createElement(AffiliationContainer, { onClick: onClick, className: isSelected ? 'active' : '', ref: ref },
67
+ React.createElement(AffiliationIcon, { opacity: showSuccessIcon ? 0.05 : 1, style: { minWidth: 24, minHeight: 24 } }),
68
+ React.createElement(AffiliationBox, null,
69
+ React.createElement(AffiliationName, null, affiliation.institution),
70
+ React.createElement(AffiliationDetails, null,
71
+ affiliation.city && (React.createElement(React.Fragment, null,
72
+ affiliation.city,
73
+ affiliation.county || affiliation.country ? ', ' : '')),
74
+ affiliation.county && (React.createElement(React.Fragment, null,
75
+ affiliation.county,
76
+ affiliation.country ? ', ' : '')),
77
+ affiliation.country && React.createElement(React.Fragment, null, affiliation.country))),
78
+ showSuccessIcon && (React.createElement(CrclTickAnimation, { size: 36, style: { position: 'absolute', left: '10px' } })),
79
+ isSelected && (React.createElement(RemoveButton, { onClick: () => onDelete(), "data-tooltip-id": 'delete-button-tooltip' },
80
+ React.createElement(DeleteIcon, { fill: '#6E6E6E' }),
81
+ React.createElement(Tooltip, { id: 'delete-button-tooltip', place: "bottom" }, 'Delete')))));
82
+ };
@@ -0,0 +1,40 @@
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 from 'styled-components';
18
+ import { AffiliationItem } from './AffiliationItem';
19
+ const AffiliationListContainer = styled.div `
20
+ flex: 1;
21
+ overflow-y: visible;
22
+ margin-left: 16px;
23
+ `;
24
+ const AffiliationListTitle = styled.h2 `
25
+ color: #6e6e6e;
26
+ font-size: 18px;
27
+ font-weight: 400;
28
+ line-height: 24px;
29
+ margin-left: 14px;
30
+ margin-top: 20px;
31
+ `;
32
+ export const AffiliationList = ({ affiliation, affiliations, onSelect, onDelete, lastSavedAffiliationId, }) => {
33
+ return (React.createElement(React.Fragment, null,
34
+ React.createElement(AffiliationListTitle, null, "Existing Affiliations"),
35
+ React.createElement(AffiliationListContainer, { "data-cy": "affiliation-list" }, affiliations.map((a) => {
36
+ return (React.createElement(AffiliationItem, { key: a.id, affiliation: a, isSelected: a.id === (affiliation === null || affiliation === void 0 ? void 0 : affiliation.id), onClick: () => {
37
+ return onSelect(a);
38
+ }, onDelete: () => onDelete(), showSuccessIcon: lastSavedAffiliationId === a.id }));
39
+ }))));
40
+ };