@manuscripts/body-editor 1.7.19-LEAN-3143-1 → 1.7.20

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 (95) hide show
  1. package/dist/cjs/assets.js +1 -47
  2. package/dist/cjs/components/authors/AffiliationButton.js +105 -0
  3. package/dist/cjs/components/authors/AffiliationForm.js +50 -0
  4. package/dist/cjs/components/authors/AuthorActions.js +61 -0
  5. package/dist/cjs/components/authors/AuthorAffiliations.js +116 -0
  6. package/dist/cjs/components/authors/AuthorDetailsForm.js +97 -0
  7. package/dist/cjs/components/authors/AuthorFormPlaceholder.js +57 -0
  8. package/dist/cjs/components/authors/AuthorList.js +40 -0
  9. package/dist/cjs/components/authors/AuthorsModal.js +226 -0
  10. package/dist/cjs/components/{views/DeleteFootnoteDialog.js → authors/ChangeHandlingForm.js} +10 -18
  11. package/dist/cjs/components/authors/DeleteAuthorConfirmationDialog.js +23 -0
  12. package/dist/cjs/components/authors/DraggableAuthor.js +170 -0
  13. package/dist/cjs/components/authors/SaveAuthorConfirmationDialog.js +21 -0
  14. package/dist/cjs/configs/editor-plugins.js +1 -1
  15. package/dist/cjs/lib/array-reducer.js +2 -0
  16. package/dist/cjs/lib/authors.js +43 -0
  17. package/dist/cjs/lib/track-changes-utils.js +5 -1
  18. package/dist/cjs/lib/utils.js +1 -5
  19. package/dist/cjs/lib/view.js +97 -0
  20. package/dist/cjs/plugins/footnotes/index.js +2 -90
  21. package/dist/cjs/views/base_node_view.js +0 -19
  22. package/dist/cjs/views/bibliography_element.js +3 -2
  23. package/dist/cjs/views/citation_editable.js +3 -2
  24. package/dist/cjs/views/contributors.js +78 -25
  25. package/dist/es/assets.js +0 -46
  26. package/dist/es/components/authors/AffiliationButton.js +75 -0
  27. package/dist/es/components/authors/AffiliationForm.js +43 -0
  28. package/dist/es/components/authors/AuthorActions.js +31 -0
  29. package/dist/es/components/authors/AuthorAffiliations.js +85 -0
  30. package/dist/es/components/authors/AuthorDetailsForm.js +67 -0
  31. package/dist/es/components/authors/AuthorFormPlaceholder.js +50 -0
  32. package/dist/es/components/authors/AuthorList.js +33 -0
  33. package/dist/es/components/authors/AuthorsModal.js +196 -0
  34. package/dist/es/components/authors/ChangeHandlingForm.js +10 -0
  35. package/dist/es/components/authors/DeleteAuthorConfirmationDialog.js +16 -0
  36. package/dist/es/components/authors/DraggableAuthor.js +140 -0
  37. package/dist/es/components/authors/SaveAuthorConfirmationDialog.js +14 -0
  38. package/dist/es/configs/editor-plugins.js +1 -1
  39. package/dist/es/configs/editor-views.js +2 -2
  40. package/dist/es/lib/array-reducer.js +2 -0
  41. package/dist/es/lib/authors.js +36 -0
  42. package/dist/es/lib/track-changes-utils.js +3 -0
  43. package/dist/es/lib/utils.js +1 -4
  44. package/dist/es/lib/view.js +64 -0
  45. package/dist/es/plugins/footnotes/index.js +4 -89
  46. package/dist/es/views/base_node_view.js +0 -19
  47. package/dist/es/views/bibliography_element.js +3 -2
  48. package/dist/es/views/citation_editable.js +3 -2
  49. package/dist/es/views/contributors.js +79 -26
  50. package/dist/types/assets.d.ts +0 -1
  51. package/dist/types/components/authors/AffiliationButton.d.ts +8 -0
  52. package/dist/types/components/authors/AffiliationForm.d.ts +7 -0
  53. package/dist/types/components/authors/AuthorActions.d.ts +9 -0
  54. package/dist/types/components/authors/AuthorAffiliations.d.ts +11 -0
  55. package/dist/types/components/authors/AuthorDetailsForm.d.ts +30 -0
  56. package/dist/types/components/authors/AuthorFormPlaceholder.d.ts +2 -0
  57. package/dist/types/components/authors/AuthorList.d.ts +25 -0
  58. package/dist/types/components/authors/AuthorsModal.d.ts +26 -0
  59. package/dist/types/components/authors/ChangeHandlingForm.d.ts +5 -0
  60. package/dist/types/components/authors/DeleteAuthorConfirmationDialog.d.ts +9 -0
  61. package/dist/types/components/authors/DraggableAuthor.d.ts +25 -0
  62. package/dist/types/components/authors/SaveAuthorConfirmationDialog.d.ts +7 -0
  63. package/dist/types/components/outline/DraggableTree.d.ts +1 -1
  64. package/dist/types/configs/ManuscriptsEditor.d.ts +0 -2
  65. package/dist/types/configs/editor-plugins.d.ts +1 -1
  66. package/dist/types/configs/editor-views.d.ts +0 -28
  67. package/dist/types/lib/array-reducer.d.ts +5 -1
  68. package/dist/types/lib/authors.d.ts +23 -0
  69. package/dist/types/lib/track-changes-utils.d.ts +1 -0
  70. package/dist/types/lib/utils.d.ts +0 -1
  71. package/dist/types/lib/view.d.ts +25 -0
  72. package/dist/types/plugins/footnotes/index.d.ts +1 -2
  73. package/dist/types/views/base_node_view.d.ts +1 -4
  74. package/dist/types/views/bibliography_element_editable.d.ts +0 -2
  75. package/dist/types/views/blockquote_element_editable.d.ts +0 -2
  76. package/dist/types/views/bullet_list_editable.d.ts +0 -2
  77. package/dist/types/views/contributors.d.ts +25 -8
  78. package/dist/types/views/editable_block.d.ts +0 -2
  79. package/dist/types/views/equation_element_editable.d.ts +0 -2
  80. package/dist/types/views/figure_element_editable.d.ts +0 -2
  81. package/dist/types/views/footnote_editable.d.ts +0 -2
  82. package/dist/types/views/footnotes_element_editable.d.ts +0 -2
  83. package/dist/types/views/listing_element_editable.d.ts +0 -2
  84. package/dist/types/views/ordered_list_editable.d.ts +0 -2
  85. package/dist/types/views/paragraph_editable.d.ts +0 -2
  86. package/dist/types/views/placeholder_element_editable.d.ts +0 -2
  87. package/dist/types/views/pullquote_element_editable.d.ts +0 -2
  88. package/dist/types/views/section_title_editable.d.ts +0 -2
  89. package/dist/types/views/table_element_editable.d.ts +0 -2
  90. package/dist/types/views/toc_element_editable.d.ts +0 -2
  91. package/package.json +4 -3
  92. package/styles/AdvancedEditor.css +3 -3
  93. package/styles/Editor.css +2 -23
  94. package/dist/es/components/views/DeleteFootnoteDialog.js +0 -18
  95. package/dist/types/components/views/DeleteFootnoteDialog.d.ts +0 -7
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.deleteIcon = exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
18
+ exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
19
19
  exports.editIcon = `
20
20
  <svg
21
21
  width="14"
@@ -118,49 +118,3 @@ exports.alertIcon = `
118
118
  />
119
119
  </svg>
120
120
  `;
121
- exports.deleteIcon = `
122
- <svg
123
- width="13"
124
- height="15"
125
- viewBox="0 0 13 15"
126
- fill="none"
127
- xmlns="http://www.w3.org/2000/svg"
128
- >
129
- <path
130
- fill-rule="evenodd"
131
- clip-rule="evenodd"
132
- d="M2.00001 3C2 3.00135 2 3.00269 2 3.00404V13.004C2 13.5563 2.44772 14.004 3 14.004H10C10.5523 14.004 11 13.5563 11 13.004V3.00404C11 3.00269 11 3.00135 11 3C11.5978 3.34581 12 3.99215 12 4.73244V13.004C12 14.1086 11.1046 15.004 10 15.004H3C1.89543 15.004 1 14.1086 1 13.004V4.73244C1 3.99215 1.4022 3.34581 2.00001 3Z"
133
- fill="#C9C9C9"
134
- />
135
- <path
136
- fill-rule="evenodd"
137
- clip-rule="evenodd"
138
- d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3.5C3 4.32843 3.67157 5 4.5 5H8.5C9.32843 5 10 4.32843 10 3.5V1.5C10 0.671573 9.32843 0 8.5 0H4.5ZM9 1.5C9 1.22386 8.77614 1 8.5 1H4.5C4.22386 1 4 1.22386 4 1.5C4 1.77614 4.22386 2 4.5 2H8.5C8.77614 2 9 1.77614 9 1.5Z"
139
- fill="#C9C9C9"
140
- />
141
- <rect
142
- y="2"
143
- width="13"
144
- height="3"
145
- rx="1.5"
146
- fill="#C9C9C9"
147
- />
148
- <path
149
- fill-rule="evenodd"
150
- clip-rule="evenodd"
151
- d="M8 7.5C8 7.22386 8.22386 7 8.5 7C8.77614 7 9 7.22386 9 7.5V11.5C9 11.7761 8.77614 12 8.5 12C8.22386 12 8 11.7761 8 11.5V7.5Z"
152
- fill="#C9C9C9"
153
- />
154
- <path
155
- fill-rule="evenodd"
156
- clip-rule="evenodd"
157
- d="M4 7.5C4 7.22386 4.22386 7 4.5 7C4.77614 7 5 7.22386 5 7.5V11.5C5 11.7761 4.77614 12 4.5 12C4.22386 12 4 11.7761 4 11.5V7.5Z"
158
- fill="#C9C9C9"
159
- />
160
- <path
161
- fill-rule="evenodd"
162
- clip-rule="evenodd"
163
- d="M11.5 3C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4L1.5 4C1.22386 4 1 3.77614 1 3.5C1 3.22386 1.22386 3 1.5 3L11.5 3Z"
164
- fill="white"
165
- />
166
- </svg>`;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.AffiliationButton = void 0;
30
+ const ArrowDownBlue_1 = __importDefault(require("@manuscripts/assets/react/ArrowDownBlue"));
31
+ const style_guide_1 = require("@manuscripts/style-guide");
32
+ const lodash_1 = require("lodash");
33
+ const react_1 = __importStar(require("react"));
34
+ const styled_components_1 = __importDefault(require("styled-components"));
35
+ const authors_1 = require("../../lib/authors");
36
+ const AffiliationForm_1 = require("./AffiliationForm");
37
+ const Container = styled_components_1.default.div `
38
+ border: 1px solid ${(props) => props.theme.colors.border.field.default};
39
+ border-radius: ${(props) => props.theme.grid.radius.default};
40
+ background: ${(props) => props.theme.colors.background.primary};
41
+ margin-bottom: 2px;
42
+ overflow: hidden;
43
+ `;
44
+ const AffiliationFormContainer = styled_components_1.default.div `
45
+ border: 1px solid ${(props) => props.theme.colors.border.field.default};
46
+ border-radius: ${(props) => props.theme.grid.radius.default};
47
+ margin: 6px 12px 12px;
48
+ overflow: hidden;
49
+ `;
50
+ const AffiliationLabel = styled_components_1.default.div `
51
+ margin: 0;
52
+ display: flex;
53
+ align-items: center;
54
+ font-size: 0.875rem;
55
+ padding-right: 0.5rem;
56
+ `;
57
+ const DropdownIndicator = (0, styled_components_1.default)(ArrowDownBlue_1.default) `
58
+ border: 0;
59
+ border-radius: 50%;
60
+ margin-right: 0.6em;
61
+ min-width: 20px;
62
+ `;
63
+ const ToggleButton = styled_components_1.default.button `
64
+ flex-grow: 1;
65
+ display: flex;
66
+ align-items: center;
67
+ width: 100%;
68
+ background: transparent;
69
+ border: none;
70
+ text-align: left;
71
+ font-family: ${(props) => props.theme.font.family.sans};
72
+ font-size: 1rem;
73
+ padding: 0.6em 0.5em;
74
+ outline: none;
75
+
76
+ &.open svg {
77
+ transform: rotateX(180deg);
78
+ }
79
+ `;
80
+ const RemoveButton = styled_components_1.default.div `
81
+ cursor: pointer;
82
+ `;
83
+ const AffiliationButton = ({ affiliation, onSave, onRemove, }) => {
84
+ const [isOpen, setOpen] = (0, react_1.useState)(false);
85
+ const toggleOpen = () => {
86
+ setOpen((o) => !o);
87
+ };
88
+ const handleSave = (values) => {
89
+ if ((0, lodash_1.isEqual)(values, affiliation)) {
90
+ return;
91
+ }
92
+ const copy = Object.assign(Object.assign({}, affiliation), values);
93
+ onSave(copy);
94
+ };
95
+ return (react_1.default.createElement(Container, null,
96
+ react_1.default.createElement(AffiliationLabel, null,
97
+ react_1.default.createElement(ToggleButton, { type: "button", className: isOpen ? 'open' : '', onClick: toggleOpen },
98
+ react_1.default.createElement(DropdownIndicator, null),
99
+ (0, authors_1.affiliationLabel)(affiliation)),
100
+ react_1.default.createElement(RemoveButton, { onClick: onRemove },
101
+ react_1.default.createElement(style_guide_1.DeleteIcon, null))),
102
+ isOpen && (react_1.default.createElement(AffiliationFormContainer, null,
103
+ react_1.default.createElement(AffiliationForm_1.AffiliationForm, { values: affiliation, onSave: handleSave })))));
104
+ };
105
+ exports.AffiliationButton = AffiliationButton;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AffiliationForm = void 0;
7
+ const style_guide_1 = require("@manuscripts/style-guide");
8
+ const formik_1 = require("formik");
9
+ const react_1 = __importDefault(require("react"));
10
+ const styled_components_1 = __importDefault(require("styled-components"));
11
+ const ChangeHandlingForm_1 = require("./ChangeHandlingForm");
12
+ const Row = styled_components_1.default.div `
13
+ display: flex;
14
+ border-top: 1px solid ${(props) => props.theme.colors.border.field.default};
15
+ &:first-child {
16
+ border-top: none;
17
+ }
18
+ `;
19
+ const AffiliationsTextField = (0, styled_components_1.default)(style_guide_1.TextField) `
20
+ border: none;
21
+ border-radius: 0;
22
+ background: transparent;
23
+ &:not(:first-child) {
24
+ border-left: 1px solid ${(props) => props.theme.colors.border.field.default};
25
+ }
26
+
27
+ &[aria-invalid] {
28
+ background: ${(props) => props.theme.colors.background.warning};
29
+ }
30
+
31
+ &[aria-invalid]:focus {
32
+ background: transparent;
33
+ }
34
+ `;
35
+ const AffiliationForm = ({ values, onSave, }) => {
36
+ return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave }, () => (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onSave },
37
+ react_1.default.createElement(Row, null,
38
+ react_1.default.createElement(formik_1.Field, { name: "institution" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "institution", placeholder: "Institution Name" }, props.field))))),
39
+ react_1.default.createElement(Row, null,
40
+ react_1.default.createElement(formik_1.Field, { name: "department" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "department", placeholder: "Department" }, props.field))))),
41
+ react_1.default.createElement(Row, null,
42
+ react_1.default.createElement(formik_1.Field, { name: "addressLine1" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "addressLine1", placeholder: "Street Address" }, props.field))))),
43
+ react_1.default.createElement(Row, null,
44
+ react_1.default.createElement(formik_1.Field, { name: "city" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "city", placeholder: "City" }, props.field)))),
45
+ react_1.default.createElement(formik_1.Field, { name: "county" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "county", placeholder: "State / Province" }, props.field))))),
46
+ react_1.default.createElement(Row, null,
47
+ react_1.default.createElement(formik_1.Field, { name: "postCode" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "postCode", placeholder: "Postal Code" }, props.field)))),
48
+ react_1.default.createElement(formik_1.Field, { name: "country" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "country", placeholder: "Country" }, props.field)))))))));
49
+ };
50
+ exports.AffiliationForm = AffiliationForm;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.AuthorActions = void 0;
30
+ const style_guide_1 = require("@manuscripts/style-guide");
31
+ const react_1 = __importStar(require("react"));
32
+ const styled_components_1 = __importDefault(require("styled-components"));
33
+ const DeleteAuthorConfirmationDialog_1 = require("./DeleteAuthorConfirmationDialog");
34
+ const AuthorActionsContainer = styled_components_1.default.div `
35
+ display: flex;
36
+ `;
37
+ const RemoveButton = styled_components_1.default.div `
38
+ display: flex;
39
+ align-items: center;
40
+
41
+ svg {
42
+ cursor: pointer;
43
+ }
44
+ `;
45
+ const StyledButtonGroup = (0, styled_components_1.default)(style_guide_1.ButtonGroup) `
46
+ flex: 1;
47
+ `;
48
+ const AuthorActions = ({ author, onSave, onDelete, onCancel, }) => {
49
+ const [showDeleteDialog, setShowDeleteDialog] = (0, react_1.useState)(false);
50
+ return (react_1.default.createElement(AuthorActionsContainer, null,
51
+ react_1.default.createElement(DeleteAuthorConfirmationDialog_1.DeleteAuthorConfirmationDialog, { author: author, isOpen: showDeleteDialog, onDelete: () => {
52
+ setShowDeleteDialog(true);
53
+ onDelete();
54
+ }, onCancel: () => setShowDeleteDialog(false) }),
55
+ react_1.default.createElement(RemoveButton, { onClick: () => setShowDeleteDialog(true) },
56
+ react_1.default.createElement(style_guide_1.DeleteIcon, null)),
57
+ react_1.default.createElement(StyledButtonGroup, null,
58
+ react_1.default.createElement(style_guide_1.SecondaryButton, { onClick: onCancel }, "Cancel"),
59
+ react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: onSave }, "Save"))));
60
+ };
61
+ exports.AuthorActions = AuthorActions;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.AuthorAffiliations = exports.AddAffiliationIndicator = void 0;
30
+ const AddAuthor_1 = __importDefault(require("@manuscripts/assets/react/AddAuthor"));
31
+ const json_schema_1 = require("@manuscripts/json-schema");
32
+ const react_1 = __importStar(require("react"));
33
+ const creatable_1 = __importDefault(require("react-select/creatable"));
34
+ const styled_components_1 = __importStar(require("styled-components"));
35
+ const authors_1 = require("../../lib/authors");
36
+ const AffiliationButton_1 = require("./AffiliationButton");
37
+ const AddAffiliation = (0, styled_components_1.default)(AddAuthor_1.default) `
38
+ width: 24px;
39
+ height: 24px;
40
+ margin-right: 4px;
41
+
42
+ circle,
43
+ use {
44
+ fill: ${(props) => props.theme.colors.brand.default};
45
+ }
46
+
47
+ path {
48
+ mask: none;
49
+ }
50
+ `;
51
+ const AddAffiliationIndicator = () => react_1.default.createElement(AddAffiliation, null);
52
+ exports.AddAffiliationIndicator = AddAffiliationIndicator;
53
+ const getSelectStyles = (focus, theme) => ({
54
+ backgroundColor: focus
55
+ ? theme.colors.background.fifth
56
+ : theme.colors.background.primary,
57
+ borderColor: focus
58
+ ? theme.colors.border.field.active
59
+ : theme.colors.border.field.default,
60
+ '&:hover': {
61
+ backgroundColor: theme.colors.background.fifth,
62
+ },
63
+ borderRadius: theme.grid.radius.default,
64
+ boxShadow: 'none',
65
+ fontFamily: theme.font.family.sans,
66
+ });
67
+ const AuthorAffiliations = ({ author, affiliations, onSave, onAdd, onRemove, }) => {
68
+ const theme = (0, react_1.useContext)(styled_components_1.ThemeContext);
69
+ const [searchText, setSearchText] = (0, react_1.useState)('');
70
+ const affiliationMap = (0, react_1.useMemo)(() => new Map(affiliations.map((a) => [a.id, a])), [affiliations]);
71
+ const authorAffiliations = (0, react_1.useMemo)(() => {
72
+ var _a;
73
+ return (_a = author.affiliations) === null || _a === void 0 ? void 0 : _a.map((i) => affiliationMap.get(i));
74
+ }, [affiliationMap, author]);
75
+ const otherAffiliations = (0, react_1.useMemo)(() => {
76
+ var _a;
77
+ const copy = new Map(affiliationMap);
78
+ (_a = author.affiliations) === null || _a === void 0 ? void 0 : _a.forEach((i) => copy.delete(i));
79
+ return Array.from(copy.values());
80
+ }, [affiliationMap, author]);
81
+ const options = otherAffiliations.map((a) => ({
82
+ value: a.id,
83
+ label: (0, authors_1.affiliationLabel)(a),
84
+ }));
85
+ const handleChange = (id) => {
86
+ const affiliation = affiliationMap.get(id);
87
+ if (!affiliation) {
88
+ return;
89
+ }
90
+ onAdd(affiliation);
91
+ setSearchText('');
92
+ };
93
+ const handleCreate = (institution) => {
94
+ const affiliation = {
95
+ id: (0, json_schema_1.generateID)(json_schema_1.ObjectTypes.Affiliation),
96
+ addressLine1: '',
97
+ city: '',
98
+ country: '',
99
+ county: '',
100
+ department: '',
101
+ institution: institution,
102
+ postCode: '',
103
+ priority: 0,
104
+ };
105
+ onSave(affiliation);
106
+ onAdd(affiliation);
107
+ };
108
+ return (react_1.default.createElement(react_1.default.Fragment, null,
109
+ authorAffiliations.map((a) => (react_1.default.createElement(AffiliationButton_1.AffiliationButton, { key: `${author.id}-${a.id}`, affiliation: a, onSave: onSave, onRemove: () => onRemove(a) }))),
110
+ react_1.default.createElement(creatable_1.default, { options: options, isMulti: false, isClearable: true, value: null, inputValue: searchText, components: {
111
+ IndicatorsContainer: exports.AddAffiliationIndicator,
112
+ }, placeholder: "Begin typing to add affiliation", noOptionsMessage: () => 'Type the name of an institution', onChange: (i) => i && handleChange(i.value), onInputChange: setSearchText, onCreateOption: (v) => v && handleCreate(v), isValidNewOption: (t) => !!t, styles: {
113
+ control: (provided, state) => (Object.assign(Object.assign({}, provided), getSelectStyles(state.isFocused, theme))),
114
+ } })));
115
+ };
116
+ exports.AuthorAffiliations = AuthorAffiliations;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.AuthorDetailsForm = exports.Fieldset = exports.LabelText = void 0;
45
+ const style_guide_1 = require("@manuscripts/style-guide");
46
+ const formik_1 = require("formik");
47
+ const react_1 = __importStar(require("react"));
48
+ const styled_components_1 = __importDefault(require("styled-components"));
49
+ const ChangeHandlingForm_1 = require("./ChangeHandlingForm");
50
+ exports.LabelText = styled_components_1.default.div `
51
+ font: ${(props) => props.theme.font.weight.normal}
52
+ ${(props) => props.theme.font.size.normal} / 1
53
+ ${(props) => props.theme.font.family.sans};
54
+ letter-spacing: -0.2px;
55
+ color: ${(props) => props.theme.colors.text.primary};
56
+ `;
57
+ exports.Fieldset = styled_components_1.default.fieldset `
58
+ padding: 0;
59
+ margin: 0;
60
+ border: none;
61
+ `;
62
+ const OrcidContainer = styled_components_1.default.div `
63
+ margin: 16px 0 0;
64
+ `;
65
+ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, }) => {
66
+ const formRef = (0, react_1.useRef)(null);
67
+ if (actionsRef && !actionsRef.current) {
68
+ actionsRef.current = {
69
+ reset: () => {
70
+ var _a;
71
+ (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.resetForm();
72
+ },
73
+ };
74
+ }
75
+ return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, validateOnChange: false, innerRef: formRef }, (formik) => {
76
+ const isAuthor = formik.values.role === 'author';
77
+ return (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onChange },
78
+ react_1.default.createElement(exports.Fieldset, null,
79
+ react_1.default.createElement(style_guide_1.TextFieldGroupContainer, null,
80
+ react_1.default.createElement(formik_1.Field, { name: 'bibliographicName.given' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'given-name', placeholder: 'Given name' }, props.field)))),
81
+ react_1.default.createElement(formik_1.Field, { name: 'bibliographicName.family' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'family-name', placeholder: 'Family name' }, props.field))))),
82
+ react_1.default.createElement(formik_1.Field, { name: 'email', type: 'email' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'email', placeholder: 'Email address' }, props.field)))),
83
+ react_1.default.createElement(style_guide_1.CheckboxLabel, { disabled: !isAuthor },
84
+ react_1.default.createElement(formik_1.Field, { name: 'isCorresponding' }, (props) => (react_1.default.createElement(style_guide_1.CheckboxField, Object.assign({ id: 'isCorresponding', checked: props.field.value, disabled: !isAuthor }, props.field)))),
85
+ react_1.default.createElement(exports.LabelText, null, "Corresponding Author")),
86
+ react_1.default.createElement(style_guide_1.CheckboxLabel, null,
87
+ react_1.default.createElement(formik_1.Field, { name: 'role', type: 'checkbox' }, (props) => (react_1.default.createElement(style_guide_1.CheckboxField, { name: 'role', checked: isAuthor, onChange: (e) => {
88
+ formik.setFieldValue(props.field.name, e.target.checked ? 'author' : 'other', false);
89
+ } }))),
90
+ react_1.default.createElement(exports.LabelText, null, "Include in Authors List")),
91
+ react_1.default.createElement(OrcidContainer, null,
92
+ react_1.default.createElement(style_guide_1.TextFieldLabel, null,
93
+ react_1.default.createElement(exports.LabelText, null, "ORCID"),
94
+ react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...' }, props.field)))))))));
95
+ }));
96
+ };
97
+ exports.AuthorDetailsForm = AuthorDetailsForm;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AuthorFormPlaceholder = void 0;
7
+ const ContributorDetailsPlaceholder_1 = __importDefault(require("@manuscripts/assets/react/ContributorDetailsPlaceholder"));
8
+ const react_1 = __importDefault(require("react"));
9
+ const styled_components_1 = __importDefault(require("styled-components"));
10
+ const OuterContainer = styled_components_1.default.div `
11
+ display: flex;
12
+ flex-direction: column;
13
+ align-items: center;
14
+ justify-content: center;
15
+ height: 100%;
16
+ overflow-y: auto;
17
+ `;
18
+ const InnerContainer = styled_components_1.default.div `
19
+ text-align: center;
20
+ max-width: 480px;
21
+ font-size: ${(props) => props.theme.font.size.xlarge};
22
+ line-height: ${(props) => props.theme.font.lineHeight.large};
23
+ `;
24
+ const Placeholder = styled_components_1.default.div `
25
+ display: flex;
26
+ justify-content: center;
27
+ margin-bottom: ${(props) => props.theme.grid.unit * 5}px;
28
+ `;
29
+ const Action = styled_components_1.default.div `
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ font-size: ${(props) => props.theme.font.size.xlarge};
34
+ font-weight: ${(props) => props.theme.font.weight.medium};
35
+ letter-spacing: -0.5px;
36
+ `;
37
+ const Message = styled_components_1.default.div `
38
+ max-width: 400px;
39
+ font-size: ${(props) => props.theme.font.size.xlarge};
40
+ margin-top: ${(props) => props.theme.grid.unit * 6}px;
41
+ font-weight: ${(props) => props.theme.font.weight.light};
42
+ color: ${(props) => props.theme.colors.text.secondary};
43
+
44
+ @media (max-width: 850px) {
45
+ margin-right: ${(props) => props.theme.grid.unit * 5}px;
46
+ margin-left: ${(props) => props.theme.grid.unit * 5}px;
47
+ max-width: 350px;
48
+ }
49
+ `;
50
+ const AuthorFormPlaceholder = () => (react_1.default.createElement(OuterContainer, { "data-cy": 'author-details' },
51
+ react_1.default.createElement(InnerContainer, null,
52
+ react_1.default.createElement(Placeholder, null,
53
+ react_1.default.createElement(ContributorDetailsPlaceholder_1.default, null)),
54
+ react_1.default.createElement(react_1.default.Fragment, null,
55
+ react_1.default.createElement(Action, null, "Author Details"),
56
+ react_1.default.createElement(Message, null, "Select an author from the list to display their details here.")))));
57
+ exports.AuthorFormPlaceholder = AuthorFormPlaceholder;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.AuthorList = void 0;
22
+ const style_guide_1 = require("@manuscripts/style-guide");
23
+ const react_1 = __importDefault(require("react"));
24
+ const react_dnd_1 = require("react-dnd");
25
+ const react_dnd_html5_backend_1 = require("react-dnd-html5-backend");
26
+ const styled_components_1 = __importDefault(require("styled-components"));
27
+ const DraggableAuthor_1 = require("./DraggableAuthor");
28
+ const AuthorListContainer = styled_components_1.default.div `
29
+ flex: 1;
30
+ overflow-y: visible;
31
+ `;
32
+ const AuthorList = ({ author, authors, onSelect, moveAuthor, }) => {
33
+ return (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend },
34
+ react_1.default.createElement(AuthorListContainer, null,
35
+ react_1.default.createElement(style_guide_1.DragLayer, null),
36
+ authors.map((a) => {
37
+ return (react_1.default.createElement(DraggableAuthor_1.DraggableAuthor, { key: a.id, author: a, isSelected: a.id === (author === null || author === void 0 ? void 0 : author.id), onClick: () => onSelect(a), moveAuthor: moveAuthor }));
38
+ }))));
39
+ };
40
+ exports.AuthorList = AuthorList;