@manuscripts/style-guide 1.12.17-LEAN-3720.0 → 1.13.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 (37) hide show
  1. package/dist/cjs/components/EditorHeader/EditorHeader.js +210 -0
  2. package/dist/cjs/components/EditorHeader/ProceedView.js +195 -0
  3. package/dist/cjs/components/RelativeDate.js +16 -4
  4. package/dist/cjs/index.js +1 -2
  5. package/dist/es/components/EditorHeader/EditorHeader.js +180 -0
  6. package/dist/es/components/EditorHeader/ProceedView.js +165 -0
  7. package/dist/es/components/RelativeDate.js +16 -4
  8. package/dist/es/index.js +1 -2
  9. package/dist/types/components/EditorHeader/EditorHeader.d.ts +68 -0
  10. package/dist/types/components/EditorHeader/ProceedView.d.ts +22 -0
  11. package/dist/types/components/RelativeDate.d.ts +4 -3
  12. package/dist/types/index.d.ts +1 -2
  13. package/package.json +1 -1
  14. package/dist/cjs/components/Comments/CommentActions.js +0 -98
  15. package/dist/cjs/components/Comments/CommentBody.js +0 -160
  16. package/dist/cjs/components/Comments/CommentTarget.js +0 -55
  17. package/dist/cjs/components/Comments/CommentUser.js +0 -76
  18. package/dist/cjs/components/Comments/CommentWrapper.js +0 -118
  19. package/dist/cjs/components/Comments/ResolveButton.js +0 -66
  20. package/dist/cjs/components/Comments/index.js +0 -21
  21. package/dist/cjs/components/ManuscriptNoteList.js +0 -210
  22. package/dist/es/components/Comments/CommentActions.js +0 -68
  23. package/dist/es/components/Comments/CommentBody.js +0 -131
  24. package/dist/es/components/Comments/CommentTarget.js +0 -29
  25. package/dist/es/components/Comments/CommentUser.js +0 -69
  26. package/dist/es/components/Comments/CommentWrapper.js +0 -88
  27. package/dist/es/components/Comments/ResolveButton.js +0 -59
  28. package/dist/es/components/Comments/index.js +0 -5
  29. package/dist/es/components/ManuscriptNoteList.js +0 -181
  30. package/dist/types/components/Comments/CommentActions.d.ts +0 -28
  31. package/dist/types/components/Comments/CommentBody.d.ts +0 -39
  32. package/dist/types/components/Comments/CommentTarget.d.ts +0 -21
  33. package/dist/types/components/Comments/CommentUser.d.ts +0 -23
  34. package/dist/types/components/Comments/CommentWrapper.d.ts +0 -26
  35. package/dist/types/components/Comments/ResolveButton.d.ts +0 -21
  36. package/dist/types/components/Comments/index.d.ts +0 -5
  37. package/dist/types/components/ManuscriptNoteList.d.ts +0 -45
@@ -0,0 +1,165 @@
1
+ import React, { useEffect, useMemo, useRef } from 'react';
2
+ import styled from 'styled-components';
3
+ import { Category, Dialog, DialogState, LoadingOverlay, NavDropdown, NavDropdownButton, NavDropdownContainer, PrimaryBoldHeading, PrimaryButton, SecondarySmallText, TaskStepDoneIcon, useDropdown, } from '../..';
4
+ import { AlertMessage, AlertMessageType } from '../AlertMessage';
5
+ import { PrimaryButtonSmall, } from './EditorHeader';
6
+ const DropdownWrapper = ({ disabled, button, primary, children }) => {
7
+ const { isOpen, toggleOpen, wrapperRef } = useDropdown();
8
+ return (React.createElement(NavDropdownContainer, { id: 'user-dropdown', ref: wrapperRef },
9
+ React.createElement(NavDropdownButton, { as: (primary && PrimaryButton) || undefined, disabled: disabled, isOpen: isOpen, onClick: toggleOpen }, button),
10
+ isOpen && React.createElement(NavDropdown, { direction: "left" }, children)));
11
+ };
12
+ const StepDetails = ({ icon, label, description, role }) => (React.createElement(React.Fragment, null,
13
+ icon && React.createElement(TaskStatus, null, icon),
14
+ React.createElement(TaskContainer, null,
15
+ React.createElement(PrimaryBoldHeading, null, label),
16
+ React.createElement(SecondarySmallText, null, description),
17
+ React.createElement(SecondarySmallText, null,
18
+ "Actor: ",
19
+ role.label))));
20
+ export const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialogData, previousStepType, currentStepType, isAnnotator, isProofer, hasPendingSuggestions, onCancelClick, continueDialogAction, message: Message, }) => {
21
+ const dialogMessages = useMemo(() => hasPendingSuggestions &&
22
+ !isAnnotator &&
23
+ !isProofer &&
24
+ dialogData.state !== DialogState.SUCCESS
25
+ ? {
26
+ header: 'The task can not be transitioned to the next step',
27
+ message: `There are still pending suggestions in the document.
28
+ It is not possible to complete the task without having them approved or rejected.`,
29
+ actions: {
30
+ primary: {
31
+ action: onCancelClick,
32
+ title: 'Ok',
33
+ },
34
+ onClose: onCancelClick,
35
+ },
36
+ }
37
+ : dialogData.state === DialogState.SUCCESS
38
+ ? {
39
+ header: 'Content reassigned successfully',
40
+ message: `to the ${currentStepType.label}`,
41
+ actions: {
42
+ primary: {
43
+ action: onCancelClick,
44
+ title: 'Close',
45
+ },
46
+ onClose: onCancelClick,
47
+ },
48
+ }
49
+ : {
50
+ header: 'Are you sure?',
51
+ message: 'You are about to complete your task. If you confirm, you will no longer be able to make any changes.',
52
+ actions: {
53
+ primary: {
54
+ action: continueDialogAction,
55
+ title: 'Continue',
56
+ },
57
+ secondary: {
58
+ action: onCancelClick,
59
+ title: 'Cancel',
60
+ },
61
+ onClose: onCancelClick,
62
+ },
63
+ }, [
64
+ dialogData,
65
+ continueDialogAction,
66
+ onCancelClick,
67
+ currentStepType,
68
+ hasPendingSuggestions,
69
+ isAnnotator,
70
+ isProofer,
71
+ ]);
72
+ const prevDialogMsgs = useRef();
73
+ const prevDialogueState = useRef();
74
+ useEffect(() => {
75
+ prevDialogMsgs.current = dialogMessages;
76
+ prevDialogueState.current = dialogData.state;
77
+ }, [dialogData.state]);
78
+ const messages = dialogData.state === DialogState.CLOSED && prevDialogMsgs.current
79
+ ? prevDialogMsgs.current
80
+ : dialogMessages;
81
+ const finalState = dialogData.state === DialogState.CLOSED && prevDialogueState.current
82
+ ? prevDialogueState.current
83
+ : dialogData.state;
84
+ return (React.createElement(React.Fragment, null,
85
+ (currentStepTransition && (currentStepTransition === null || currentStepTransition === void 0 ? void 0 : currentStepTransition.length) > 1 && (React.createElement(DropdownWrapper, { button: 'Complete task', disabled: disable, primary: true },
86
+ React.createElement(TaskDropdown, null, currentStepTransition &&
87
+ currentStepTransition.map((transition, index) => (React.createElement(Task, { key: 'task_' + transition.type.id, className: transition.status.id === 'success' ? 'happyPath' : '', value: index, onClick: onTransitionClick },
88
+ React.createElement("strong", null, transition.type.label),
89
+ transition.type.description))))))) || (React.createElement(PrimaryButtonSmall, { value: 0, onClick: onTransitionClick, disabled: disable }, "Complete task")),
90
+ finalState === DialogState.LOADING && (React.createElement(LoadingOverlay, null,
91
+ React.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026"))),
92
+ React.createElement(Dialog, { isOpen: dialogData.state !== DialogState.CLOSED &&
93
+ dialogData.state !== DialogState.LOADING, category: Category.confirmation, header: messages.header, message: messages.message, actions: messages.actions },
94
+ finalState === DialogState.SUCCESS && (React.createElement(Grid, null,
95
+ previousStepType && (React.createElement(StepDetails, Object.assign({}, previousStepType, { icon: React.createElement(React.Fragment, null,
96
+ React.createElement(TaskStepDoneIcon, null),
97
+ React.createElement(Line, null)) }))),
98
+ React.createElement(StepDetails, Object.assign({}, currentStepType)))),
99
+ finalState === DialogState.ERROR && (React.createElement(AlertMessage, { type: AlertMessageType.error, hideCloseButton: true }, dialogData.error)))));
100
+ };
101
+ const TaskDropdown = styled.div `
102
+ display: flex;
103
+ flex-direction: column;
104
+ padding: ${(props) => props.theme.grid.unit * 2}px 0;
105
+ `;
106
+ const Task = styled.button `
107
+ background: transparent;
108
+ border: none;
109
+ color: ${(props) => props.theme.colors.text.secondary};
110
+ cursor: pointer;
111
+ font: ${(props) => props.theme.font.weight.normal}
112
+ ${(props) => props.theme.font.size.small} /
113
+ ${(props) => props.theme.font.lineHeight.normal}
114
+ ${(props) => props.theme.font.family.sans};
115
+ order: 1;
116
+ outline: none;
117
+ padding: ${(props) => props.theme.grid.unit * 2}px
118
+ ${(props) => props.theme.grid.unit * 4}px;
119
+ text-align: left;
120
+ width: ${(props) => props.theme.grid.unit * 66}px;
121
+
122
+ &:not([disabled]):hover,
123
+ &:not([disabled]):focus {
124
+ background-color: ${(props) => props.theme.colors.button.default.background.hover};
125
+ }
126
+
127
+ strong {
128
+ color: ${(props) => props.theme.colors.text.primary};
129
+ display: block;
130
+ font-size: ${(props) => props.theme.font.size.normal};
131
+ line-height: ${(props) => props.theme.font.lineHeight.normal};
132
+ }
133
+
134
+ &.happyPath {
135
+ border-bottom: 1px solid ${(props) => props.theme.colors.border.tertiary};
136
+ order: 0;
137
+ }
138
+ `;
139
+ const TextAreaWrapper = styled.div `
140
+ margin-top: ${(props) => props.theme.grid.unit * 4}px;
141
+ `;
142
+ const Grid = styled.div `
143
+ display: grid;
144
+ grid-template-columns: max-content auto;
145
+ gap: 0 ${(props) => props.theme.grid.unit * 2}px;
146
+ margin-top: ${(props) => props.theme.grid.unit * 4}px;
147
+ background: ${(props) => props.theme.colors.background.secondary};
148
+ padding: ${(props) => props.theme.grid.unit * 6}px;
149
+ `;
150
+ const Line = styled.hr `
151
+ margin: 5px 0 0 0;
152
+ flex: 1;
153
+ border: 1px dashed #c9c9c9;
154
+ `;
155
+ const TaskStatus = styled.div `
156
+ grid-column: 1;
157
+ display: flex;
158
+ flex-direction: column;
159
+ align-items: center;
160
+ padding-top: 5px;
161
+ `;
162
+ const TaskContainer = styled.div `
163
+ grid-column: 2;
164
+ margin-bottom: 8px;
165
+ `;
@@ -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
@@ -42,10 +42,9 @@ export * from './components/Badge';
42
42
  export * from './components/NavDropdown';
43
43
  export * from './components/Dropdown';
44
44
  export * from './components/LoadingOverlay';
45
+ export * from './components/EditorHeader/EditorHeader';
45
46
  export * from './components/DatePicker';
46
47
  export * from './components/Text';
47
- export * from './components/ManuscriptNoteList';
48
- export * from './components/Comments';
49
48
  export * from './components/RelativeDate';
50
49
  export * from './components/Menus';
51
50
  export * from './components/SelectField';
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ export type PartialSubmission = {
3
+ id: string;
4
+ currentStep: SubmissionStep;
5
+ previousStep?: SubmissionStep | null | undefined;
6
+ nextStep?: SubmissionStep | null | undefined;
7
+ };
8
+ export type SubmissionStep = {
9
+ type: SubmissionStepType;
10
+ };
11
+ export type SubmissionStepTransition = {
12
+ status: {
13
+ id: string;
14
+ label: string;
15
+ };
16
+ type: SubmissionStepType;
17
+ };
18
+ export type SubmissionStepType = {
19
+ id: string;
20
+ label: string;
21
+ description: string;
22
+ transitions: Array<SubmissionStepTransition>;
23
+ role: {
24
+ label: string;
25
+ };
26
+ };
27
+ export declare enum DialogState {
28
+ INIT = 0,
29
+ LOADING = 1,
30
+ ERROR = 2,
31
+ SUCCESS = 3,
32
+ CLOSED = 4
33
+ }
34
+ export type ProceedDialogData = {
35
+ state: DialogState;
36
+ error?: string;
37
+ mutationError?: any;
38
+ updateState: (state: DialogState) => void;
39
+ clearError: () => void;
40
+ };
41
+ export declare const EditorHeader: React.FC<{
42
+ handleSnapshot?: () => Promise<void>;
43
+ submission: PartialSubmission;
44
+ hasPendingSuggestions?: boolean;
45
+ canCompleteTask: boolean;
46
+ exceptionDialog: React.FC<{
47
+ errorCode: string;
48
+ }>;
49
+ userRole: string;
50
+ submitProceed: {
51
+ dialogData: ProceedDialogData;
52
+ submit: (statusId: string, noteValue: string) => Promise<unknown>;
53
+ };
54
+ goBack?: () => void;
55
+ status?: 'saved' | 'saving' | 'offline' | 'failed';
56
+ isAnnotator: boolean;
57
+ isProofer: boolean;
58
+ message: React.FC;
59
+ disabelProceedNote?: boolean;
60
+ }>;
61
+ export declare const PrimaryButtonSmall: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {
62
+ type: "button" | "submit" | "reset";
63
+ } & {
64
+ danger?: boolean | undefined;
65
+ disabled?: boolean | undefined;
66
+ mini?: boolean | undefined;
67
+ }, "type">;
68
+ export declare const MediumTextArea: import("styled-components").StyledComponent<"textarea", import("styled-components").DefaultTheme, import("../Form").ErrorProps, never>;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { ProceedDialogData } from '../..';
3
+ import { SubmissionStepTransition, SubmissionStepType } from './EditorHeader';
4
+ export declare const ProceedView: React.FC<{
5
+ isAnnotator: boolean;
6
+ isProofer: boolean;
7
+ disable: boolean;
8
+ onTransitionClick: (event: unknown) => void;
9
+ onNoteChange?: (event: unknown) => void;
10
+ hasPendingSuggestions: boolean;
11
+ dialogData: ProceedDialogData;
12
+ noteValue: string;
13
+ currentStepTransition: SubmissionStepTransition[];
14
+ previousStepType: SubmissionStepType | undefined;
15
+ currentStepType: SubmissionStepType;
16
+ nextStepType: SubmissionStepType;
17
+ onCancelClick: () => void;
18
+ continueDialogAction: () => Promise<void>;
19
+ message: React.FC<{
20
+ isCentered: boolean;
21
+ }>;
22
+ }>;
@@ -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>;
@@ -43,10 +43,9 @@ export * from './components/Badge';
43
43
  export * from './components/NavDropdown';
44
44
  export * from './components/Dropdown';
45
45
  export * from './components/LoadingOverlay';
46
+ export * from './components/EditorHeader/EditorHeader';
46
47
  export * from './components/DatePicker';
47
48
  export * from './components/Text';
48
- export * from './components/ManuscriptNoteList';
49
- export * from './components/Comments';
50
49
  export * from './components/RelativeDate';
51
50
  export * from './components/Menus';
52
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.17-LEAN-3720.0",
4
+ "version": "1.13.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
- });