@manuscripts/style-guide 1.12.13-LEAN-3502.0 → 1.12.13-LEAN-3572.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 (33) hide show
  1. package/dist/cjs/components/EditorHeader/EditorHeader.js +0 -2
  2. package/dist/cjs/components/RelativeDate.js +16 -4
  3. package/dist/cjs/index.js +0 -2
  4. package/dist/es/components/EditorHeader/EditorHeader.js +0 -2
  5. package/dist/es/components/RelativeDate.js +16 -4
  6. package/dist/es/index.js +0 -2
  7. package/dist/types/components/RelativeDate.d.ts +4 -3
  8. package/dist/types/index.d.ts +0 -2
  9. package/package.json +1 -1
  10. package/dist/cjs/components/Comments/CommentActions.js +0 -98
  11. package/dist/cjs/components/Comments/CommentBody.js +0 -160
  12. package/dist/cjs/components/Comments/CommentTarget.js +0 -55
  13. package/dist/cjs/components/Comments/CommentUser.js +0 -76
  14. package/dist/cjs/components/Comments/CommentWrapper.js +0 -118
  15. package/dist/cjs/components/Comments/ResolveButton.js +0 -66
  16. package/dist/cjs/components/Comments/index.js +0 -21
  17. package/dist/cjs/components/ManuscriptNoteList.js +0 -210
  18. package/dist/es/components/Comments/CommentActions.js +0 -68
  19. package/dist/es/components/Comments/CommentBody.js +0 -131
  20. package/dist/es/components/Comments/CommentTarget.js +0 -29
  21. package/dist/es/components/Comments/CommentUser.js +0 -69
  22. package/dist/es/components/Comments/CommentWrapper.js +0 -88
  23. package/dist/es/components/Comments/ResolveButton.js +0 -59
  24. package/dist/es/components/Comments/index.js +0 -5
  25. package/dist/es/components/ManuscriptNoteList.js +0 -181
  26. package/dist/types/components/Comments/CommentActions.d.ts +0 -28
  27. package/dist/types/components/Comments/CommentBody.d.ts +0 -39
  28. package/dist/types/components/Comments/CommentTarget.d.ts +0 -21
  29. package/dist/types/components/Comments/CommentUser.d.ts +0 -23
  30. package/dist/types/components/Comments/CommentWrapper.d.ts +0 -26
  31. package/dist/types/components/Comments/ResolveButton.d.ts +0 -21
  32. package/dist/types/components/Comments/index.d.ts +0 -5
  33. package/dist/types/components/ManuscriptNoteList.d.ts +0 -45
@@ -153,7 +153,6 @@ exports.PrimaryButtonSmall = (0, styled_components_1.default)(__1.PrimaryButton)
153
153
  `;
154
154
  const Wrapper = styled_components_1.default.div `
155
155
  display: flex;
156
- z-index: 6;
157
156
  padding: ${(props) => props.theme.grid.unit * 3}px
158
157
  ${(props) => props.theme.grid.unit * 8}px;
159
158
  width: 100%;
@@ -161,7 +160,6 @@ const Wrapper = styled_components_1.default.div `
161
160
  align-items: center;
162
161
  border-bottom: 1px solid #f2f2f2;
163
162
  font-size: 14px;
164
- background: white;
165
163
 
166
164
  ${__1.NavDropdownContainer} + ${__1.NavDropdownContainer} {
167
165
  margin-left: ${(props) => props.theme.grid.unit * 2}px;
@@ -14,23 +14,35 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ var __rest = (this && this.__rest) || function (s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ };
17
28
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
30
  };
20
31
  Object.defineProperty(exports, "__esModule", { value: true });
21
32
  exports.RelativeDate = void 0;
22
33
  const react_1 = __importDefault(require("react"));
23
- const RelativeDate = ({ createdAt }) => {
24
- if (!createdAt) {
34
+ const RelativeDate = (_a) => {
35
+ var { date } = _a, props = __rest(_a, ["date"]);
36
+ if (!date) {
25
37
  return null;
26
38
  }
27
39
  const formatter = new Intl.RelativeTimeFormat('en', { style: 'short' });
28
- let value = Math.floor((createdAt - Date.now()) / 3600000);
40
+ let value = Math.floor((date - Date.now()) / 3600000);
29
41
  let unit = 'hour';
30
42
  if (Math.abs(value) > 24) {
31
43
  value = Math.floor(value / 24);
32
44
  unit = 'day';
33
45
  }
34
- return react_1.default.createElement("span", null, formatter.format(value, unit));
46
+ return react_1.default.createElement("span", Object.assign({}, props), formatter.format(value, unit));
35
47
  };
36
48
  exports.RelativeDate = RelativeDate;
package/dist/cjs/index.js CHANGED
@@ -65,8 +65,6 @@ __exportStar(require("./components/LoadingOverlay"), exports);
65
65
  __exportStar(require("./components/EditorHeader/EditorHeader"), exports);
66
66
  __exportStar(require("./components/DatePicker"), exports);
67
67
  __exportStar(require("./components/Text"), exports);
68
- __exportStar(require("./components/ManuscriptNoteList"), exports);
69
- __exportStar(require("./components/Comments"), exports);
70
68
  __exportStar(require("./components/RelativeDate"), exports);
71
69
  __exportStar(require("./components/Menus"), exports);
72
70
  __exportStar(require("./components/SelectField"), exports);
@@ -123,7 +123,6 @@ export const PrimaryButtonSmall = styled(PrimaryButton) `
123
123
  `;
124
124
  const Wrapper = styled.div `
125
125
  display: flex;
126
- z-index: 6;
127
126
  padding: ${(props) => props.theme.grid.unit * 3}px
128
127
  ${(props) => props.theme.grid.unit * 8}px;
129
128
  width: 100%;
@@ -131,7 +130,6 @@ const Wrapper = styled.div `
131
130
  align-items: center;
132
131
  border-bottom: 1px solid #f2f2f2;
133
132
  font-size: 14px;
134
- background: white;
135
133
 
136
134
  ${NavDropdownContainer} + ${NavDropdownContainer} {
137
135
  margin-left: ${(props) => props.theme.grid.unit * 2}px;
@@ -13,17 +13,29 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ var __rest = (this && this.__rest) || function (s, e) {
17
+ var t = {};
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
+ t[p] = s[p];
20
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
+ t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
16
27
  import React from 'react';
17
- export const RelativeDate = ({ createdAt }) => {
18
- if (!createdAt) {
28
+ export const RelativeDate = (_a) => {
29
+ var { date } = _a, props = __rest(_a, ["date"]);
30
+ if (!date) {
19
31
  return null;
20
32
  }
21
33
  const formatter = new Intl.RelativeTimeFormat('en', { style: 'short' });
22
- let value = Math.floor((createdAt - Date.now()) / 3600000);
34
+ let value = Math.floor((date - Date.now()) / 3600000);
23
35
  let unit = 'hour';
24
36
  if (Math.abs(value) > 24) {
25
37
  value = Math.floor(value / 24);
26
38
  unit = 'day';
27
39
  }
28
- return React.createElement("span", null, formatter.format(value, unit));
40
+ return React.createElement("span", Object.assign({}, props), formatter.format(value, unit));
29
41
  };
package/dist/es/index.js CHANGED
@@ -45,8 +45,6 @@ export * from './components/LoadingOverlay';
45
45
  export * from './components/EditorHeader/EditorHeader';
46
46
  export * from './components/DatePicker';
47
47
  export * from './components/Text';
48
- export * from './components/ManuscriptNoteList';
49
- export * from './components/Comments';
50
48
  export * from './components/RelativeDate';
51
49
  export * from './components/Menus';
52
50
  export * from './components/SelectField';
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import React from 'react';
17
- export declare const RelativeDate: React.FC<{
18
- createdAt?: number;
19
- }>;
17
+ export type RelativeDateProps = React.HTMLAttributes<HTMLSpanElement> & {
18
+ date?: number;
19
+ };
20
+ export declare const RelativeDate: React.FC<RelativeDateProps>;
@@ -46,8 +46,6 @@ export * from './components/LoadingOverlay';
46
46
  export * from './components/EditorHeader/EditorHeader';
47
47
  export * from './components/DatePicker';
48
48
  export * from './components/Text';
49
- export * from './components/ManuscriptNoteList';
50
- export * from './components/Comments';
51
49
  export * from './components/RelativeDate';
52
50
  export * from './components/Menus';
53
51
  export * from './components/SelectField';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "1.12.13-LEAN-3502.0",
4
+ "version": "1.12.13-LEAN-3572.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1,98 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 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.CommentActions = void 0;
45
- const react_1 = __importStar(require("react"));
46
- const styled_components_1 = __importDefault(require("styled-components"));
47
- const use_dropdown_1 = require("../../hooks/use-dropdown");
48
- const Button_1 = require("../Button");
49
- const Dropdown_1 = require("../Dropdown");
50
- const icons_1 = require("../icons");
51
- const ResolveButton_1 = require("./ResolveButton");
52
- const CommentActions = ({ id, target, can, isResolved, handleSetResolved, deleteComment, setIsEditing, isOwnComment, isProdNote, }) => {
53
- const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
54
- const handleRequestEdit = (0, react_1.useCallback)(() => {
55
- setIsEditing(true);
56
- }, [setIsEditing]);
57
- const handleRequestDelete = (0, react_1.useCallback)(() => deleteComment(id, target), [deleteComment, id, target]);
58
- const canResolve = (0, react_1.useMemo)(() => {
59
- if (!isProdNote) {
60
- return ((isOwnComment && (can === null || can === void 0 ? void 0 : can.resolveOwnComment)) || (can === null || can === void 0 ? void 0 : can.resolveOthersComment));
61
- }
62
- return can === null || can === void 0 ? void 0 : can.handleNotes;
63
- }, [isProdNote, isOwnComment, can]);
64
- const canHandle = (0, react_1.useMemo)(() => {
65
- if (!isProdNote) {
66
- return ((isOwnComment && (can === null || can === void 0 ? void 0 : can.handleOwnComments)) || (can === null || can === void 0 ? void 0 : can.handleOthersComments));
67
- }
68
- return can === null || can === void 0 ? void 0 : can.handleNotes;
69
- }, [isProdNote, isOwnComment, can]);
70
- return (react_1.default.createElement(Container, null,
71
- canResolve && handleSetResolved && (react_1.default.createElement(ResolveButton_1.ResolveButton, { id: id, resolved: isResolved, resolvedCallback: handleSetResolved, "aria-label": 'resolve comment' })),
72
- canHandle && (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
73
- react_1.default.createElement(ActionDropdownButton, { onClick: toggleOpen, className: "note-actions", "aria-label": 'actions list' },
74
- react_1.default.createElement(icons_1.DotsIcon, null)),
75
- isOpen && (react_1.default.createElement(Dropdown_1.DropdownList, { direction: 'right', width: 125, height: 96, onClick: toggleOpen },
76
- react_1.default.createElement(ActionButton, { onClick: handleRequestEdit }, "Edit"),
77
- react_1.default.createElement(ActionButton, { onClick: handleRequestDelete }, "Delete")))))));
78
- };
79
- exports.CommentActions = CommentActions;
80
- const Container = styled_components_1.default.div `
81
- display: flex;
82
- align-items: center;
83
- height: ${(props) => props.theme.grid.unit * 6}px;
84
- `;
85
- const ActionButton = (0, styled_components_1.default)(Button_1.IconTextButton) `
86
- display: inline-block;
87
- text-align: left;
88
- padding-left: ${(props) => props.theme.grid.unit * 4}px;
89
- `;
90
- const ActionDropdownButton = (0, styled_components_1.default)(Dropdown_1.DropdownButton) `
91
- &:not([disabled]):focus {
92
- circle {
93
- fill: ${(props) => props.theme.colors.brand.medium};
94
- }
95
- opacity: 1;
96
- }
97
- margin-left: ${(props) => props.theme.grid.unit}px;
98
- `;
@@ -1,160 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 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.CommentBody = void 0;
45
- const formik_1 = require("formik");
46
- const react_1 = __importStar(require("react"));
47
- const styled_components_1 = __importDefault(require("styled-components"));
48
- const Button_1 = require("../Button");
49
- const Form_1 = require("../Form");
50
- const icons_1 = require("../icons");
51
- const Tooltip_1 = require("../Tooltip");
52
- exports.CommentBody = react_1.default.memo(({ comment, saveComment, deleteComment, isReply, isNew, handleCreateReply, setIsEditing, scrollIntoHighlight, onFocusOut, isEditing, isProdNote, }) => {
53
- (0, react_1.useEffect)(() => {
54
- if (isNew) {
55
- setIsEditing(true);
56
- }
57
- }, [isNew, setIsEditing]);
58
- const cancelEditing = () => {
59
- setIsEditing(false);
60
- if (isNew) {
61
- deleteComment(comment._id);
62
- }
63
- };
64
- return (react_1.default.createElement(react_1.default.Fragment, null, isEditing ? (react_1.default.createElement(formik_1.Formik, { initialValues: comment, onSubmit: (values, actions) => {
65
- actions.setSubmitting(true);
66
- saveComment(values);
67
- setIsEditing(false);
68
- } }, ({ errors, values, setFieldValue }) => (react_1.default.createElement(formik_1.Form, null,
69
- errors.contents && react_1.default.createElement(Form_1.FormError, null, errors.contents),
70
- react_1.default.createElement(formik_1.Field, { name: 'contents' }, (props) => (react_1.default.createElement(CommentContent, null,
71
- react_1.default.createElement(StyledCommentField, { id: comment._id, autoFocus: isEditing, value: values.contents, onChange: (event) => setFieldValue(props.field.name, event.target.value), onBlur: (event) => onFocusOut &&
72
- onFocusOut(comment._id, event.target.value), placeholder: !isReply ? 'Comment...' : 'Reply...' })))),
73
- react_1.default.createElement(EditingCommentFooter, null,
74
- react_1.default.createElement(Actions, null,
75
- react_1.default.createElement(Button_1.SecondaryButton, { onClick: cancelEditing }, "Cancel"),
76
- react_1.default.createElement(Button_1.PrimaryButton, { disabled: !values.contents.replace(/<[^>]+>/g, '').length ||
77
- (!isNew &&
78
- (comment.contents === values.contents ||
79
- !values.contents.replace(/<[^>]+>/g, '').length)), type: "submit" }, "Save"))))))) : (react_1.default.createElement("div", null,
80
- react_1.default.createElement(CommentContent, { onClick: () => scrollIntoHighlight && scrollIntoHighlight(comment) },
81
- react_1.default.createElement(StyledCommentViewer, { "data-cy": "note-text" }, comment.contents)),
82
- !isReply && (react_1.default.createElement(CommentFooter, null,
83
- react_1.default.createElement("span", null,
84
- react_1.default.createElement(ActionButton, { hidden: !isProdNote, "data-tooltip-id": `reply-${comment._id}`, onClick: () => handleCreateReply(comment._id), "aria-label": 'reply', className: "reply-button note-actions" },
85
- react_1.default.createElement(icons_1.CommentReplyIcon, null))),
86
- react_1.default.createElement(Tooltip_1.Tooltip, { id: `reply-${comment._id}`, place: "bottom" }, "Reply")))))));
87
- });
88
- const CommentFooter = styled_components_1.default.div `
89
- margin-bottom: ${(props) => props.theme.grid.unit * 2}px;
90
- padding: ${(props) => props.theme.grid.unit * 2}px
91
- ${(props) => props.theme.grid.unit * 2}px 0;
92
- display: flex;
93
- justify-content: flex-end;
94
- height: ${(props) => props.theme.grid.unit * 6}px;
95
- `;
96
- const EditingCommentFooter = (0, styled_components_1.default)(CommentFooter) `
97
- justify-content: flex-end;
98
- padding: ${(props) => props.theme.grid.unit * 2}px
99
- ${(props) => props.theme.grid.unit * 4}px 0;
100
- `;
101
- const ActionButton = styled_components_1.default.button `
102
- border: none;
103
- background: none;
104
- cursor: pointer;
105
- &:not([disabled]):hover {
106
- path {
107
- stroke: ${(props) => props.theme.colors.brand.medium};
108
- }
109
- }
110
- `;
111
- const CommentContent = styled_components_1.default.div `
112
- cursor: pointer;
113
- padding: 0 ${(props) => props.theme.grid.unit * 4}px;
114
- `;
115
- const StyledCommentField = styled_components_1.default.textarea `
116
- cursor: text;
117
- font-family: ${(props) => props.theme.font.family.sans};
118
- color: ${(props) => props.theme.colors.text.primary};
119
- margin: ${(props) => props.theme.grid.unit * 2}px 0;
120
- resize: none;
121
-
122
- width: 100%;
123
- outline: 0;
124
- border: 1px solid #e2e2e2;
125
- border-radius: 6px;
126
-
127
- &:focus {
128
- background: #f2fbfc;
129
- border: 1px solid #bce7f6;
130
- border-radius: 6px;
131
- }
132
-
133
- .empty-node::before {
134
- position: absolute;
135
- color: #c9c9c9;
136
- cursor: text;
137
- pointer-events: none;
138
- }
139
-
140
- box-sizing: border-box;
141
- padding: 3px 16px 3px 16px;
142
- font-style: normal;
143
- font-weight: normal;
144
- font-size: 14px;
145
- line-height: 24px;
146
- `;
147
- const StyledCommentViewer = styled_components_1.default.div `
148
- flex: 1;
149
-
150
- font-family: ${(props) => props.theme.font.family.sans};
151
- line-height: 1.06;
152
- letter-spacing: -0.2px;
153
- color: ${(props) => props.theme.colors.text.primary};
154
- margin: ${(props) => props.theme.grid.unit * 2}px 0;
155
- `;
156
- const Actions = (0, styled_components_1.default)(Button_1.ButtonGroup) `
157
- & button:not(:last-of-type) {
158
- margin-right: 4px;
159
- }
160
- `;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 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
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.CommentTarget = void 0;
42
- const react_1 = __importStar(require("react"));
43
- exports.CommentTarget = react_1.default.memo(({ isSelected, children }) => {
44
- const threadRef = react_1.default.createRef();
45
- (0, react_1.useEffect)(() => {
46
- if (threadRef.current && isSelected) {
47
- threadRef.current.scrollIntoView({
48
- behavior: 'smooth',
49
- block: 'start',
50
- inline: 'nearest',
51
- });
52
- }
53
- });
54
- return (react_1.default.createElement("div", { "data-cy": "comment-target", ref: threadRef }, children));
55
- });
@@ -1,76 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 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.CommentUser = void 0;
22
- const react_1 = __importDefault(require("react"));
23
- const styled_components_1 = __importDefault(require("styled-components"));
24
- const Avatar_1 = require("../Avatar");
25
- const ManuscriptNoteList_1 = require("../ManuscriptNoteList");
26
- const CommentUserContainer = styled_components_1.default.div `
27
- display: flex;
28
- `;
29
- const CommentUserName = styled_components_1.default.div `
30
- margin: 0 ${(props) => props.theme.grid.unit * 2}px;
31
- font-weight: ${(props) => props.theme.font.weight.normal};
32
- max-width: ${(props) => props.theme.grid.unit * 50}px;
33
- white-space: nowrap;
34
- overflow: hidden;
35
- text-overflow: ellipsis;
36
- `;
37
- const DateText = (0, styled_components_1.default)(CommentUserName) `
38
- font-size: ${(props) => props.theme.font.size.small};
39
- line-height: ${(props) => props.theme.font.lineHeight.normal};
40
- font-weight: ${(props) => props.theme.font.weight.normal};
41
- color: ${(props) => props.theme.colors.text.secondary};
42
- `;
43
- const Header = styled_components_1.default.div `
44
- display: flex;
45
- flex-direction: column;
46
- font-size: ${(props) => props.theme.font.size.normal};
47
- `;
48
- const CommentUser = ({ contributions, getCollaboratorById, displayName, createdAt }) => {
49
- if (!contributions || !contributions.length) {
50
- return (react_1.default.createElement(CommentUserContainer, null,
51
- react_1.default.createElement(Header, null,
52
- react_1.default.createElement(Avatar_1.Avatar, { size: 20 })),
53
- react_1.default.createElement(Header, null,
54
- react_1.default.createElement(CommentUserName, null,
55
- "By ",
56
- displayName || '(unknown user)'),
57
- react_1.default.createElement(DateText, null,
58
- react_1.default.createElement(ManuscriptNoteList_1.LightRelativeDate, { createdAt: createdAt })))));
59
- }
60
- const [contribution] = contributions;
61
- const user = getCollaboratorById(contribution.profileID);
62
- const buildName = (name) => [name.given, name.family].filter((item) => item).join(' ');
63
- if (!user) {
64
- return null;
65
- }
66
- return (react_1.default.createElement(CommentUserContainer, null,
67
- react_1.default.createElement(Header, null,
68
- react_1.default.createElement(Avatar_1.Avatar, { size: 20 })),
69
- react_1.default.createElement(Header, null,
70
- react_1.default.createElement(CommentUserName, null,
71
- "By ",
72
- buildName(user.bibliographicName)),
73
- react_1.default.createElement(DateText, null,
74
- react_1.default.createElement(ManuscriptNoteList_1.LightRelativeDate, { createdAt: createdAt })))));
75
- };
76
- exports.CommentUser = CommentUser;