@manuscripts/style-guide 1.13.9-LEAN-3720.0 → 1.13.9-LEAN-3311.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.
- package/dist/cjs/components/EditorHeader/EditorHeader.js +210 -0
- package/dist/cjs/components/EditorHeader/ProceedView.js +195 -0
- package/dist/cjs/components/InsertTableDialog.js +130 -0
- package/dist/cjs/components/Menus/Menus.js +19 -2
- package/dist/cjs/hooks/use-menus.js +2 -2
- package/dist/cjs/index.js +2 -0
- package/dist/es/components/EditorHeader/EditorHeader.js +180 -0
- package/dist/es/components/EditorHeader/ProceedView.js +165 -0
- package/dist/es/components/InsertTableDialog.js +100 -0
- package/dist/es/components/Menus/Menus.js +19 -2
- package/dist/es/hooks/use-menus.js +2 -2
- package/dist/es/index.js +2 -0
- package/dist/types/components/EditorHeader/EditorHeader.d.ts +68 -0
- package/dist/types/components/EditorHeader/ProceedView.d.ts +22 -0
- package/dist/types/components/InsertTableDialog.d.ts +22 -0
- package/dist/types/components/Menus/Menus.d.ts +2 -2
- package/dist/types/hooks/use-menus.d.ts +2 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lib/menus.d.ts +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React, { useCallback, useState } from 'react';
|
|
11
|
+
import styled from 'styled-components';
|
|
12
|
+
import { ArrowLeftIcon, DropdownContainer, DropdownList, EditIcon, NavDropdownContainer, NavDropdownToggle, PrimaryButton, RoleAnnotatingIcon, RoleReadingIcon, SaveStatus, SecondaryButton, TextArea, useDropdown, } from '../..';
|
|
13
|
+
import { ProceedView } from './ProceedView';
|
|
14
|
+
export var DialogState;
|
|
15
|
+
(function (DialogState) {
|
|
16
|
+
DialogState[DialogState["INIT"] = 0] = "INIT";
|
|
17
|
+
DialogState[DialogState["LOADING"] = 1] = "LOADING";
|
|
18
|
+
DialogState[DialogState["ERROR"] = 2] = "ERROR";
|
|
19
|
+
DialogState[DialogState["SUCCESS"] = 3] = "SUCCESS";
|
|
20
|
+
DialogState[DialogState["CLOSED"] = 4] = "CLOSED";
|
|
21
|
+
})(DialogState || (DialogState = {}));
|
|
22
|
+
const Editing = { label: 'Editing', icon: EditIcon };
|
|
23
|
+
const MapUserRole = {
|
|
24
|
+
Editor: Editing,
|
|
25
|
+
Owner: Editing,
|
|
26
|
+
Writer: Editing,
|
|
27
|
+
Annotator: { label: 'Suggesting', icon: RoleAnnotatingIcon },
|
|
28
|
+
Viewer: { label: 'Reading', icon: RoleReadingIcon },
|
|
29
|
+
Proofer: { label: 'Proofing', icon: RoleAnnotatingIcon },
|
|
30
|
+
};
|
|
31
|
+
export const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, isProofer, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
|
|
32
|
+
var _a, _b, _c, _d, _e;
|
|
33
|
+
const [noteValue, setNoteValue] = useState('');
|
|
34
|
+
const [selectedTransitionIndex, setSelectedTransitionIndex] = useState();
|
|
35
|
+
const { dialogData, submit } = submitProceed;
|
|
36
|
+
const { updateState, clearError } = dialogData;
|
|
37
|
+
const continueDialogAction = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
if (submission && selectedTransitionIndex && handleSnapshot) {
|
|
39
|
+
const { status } = submission.currentStep.type.transitions[selectedTransitionIndex];
|
|
40
|
+
updateState(DialogState.LOADING);
|
|
41
|
+
yield handleSnapshot();
|
|
42
|
+
yield submit(status.id, noteValue);
|
|
43
|
+
}
|
|
44
|
+
}), [
|
|
45
|
+
submission,
|
|
46
|
+
selectedTransitionIndex,
|
|
47
|
+
handleSnapshot,
|
|
48
|
+
updateState,
|
|
49
|
+
submit,
|
|
50
|
+
noteValue,
|
|
51
|
+
]);
|
|
52
|
+
const onTransitionClick = useCallback((event) => {
|
|
53
|
+
updateState(DialogState.INIT);
|
|
54
|
+
setSelectedTransitionIndex(event.target.value || event.target.parentNode.value);
|
|
55
|
+
}, [setSelectedTransitionIndex, updateState]);
|
|
56
|
+
const onCancelClick = useCallback(() => {
|
|
57
|
+
setSelectedTransitionIndex(undefined);
|
|
58
|
+
clearError();
|
|
59
|
+
updateState(DialogState.CLOSED);
|
|
60
|
+
}, [setSelectedTransitionIndex, clearError, updateState]);
|
|
61
|
+
const onNoteChange = useCallback((event) => setNoteValue(event.target.value), [setNoteValue]);
|
|
62
|
+
const currentStepTransition = submission === null || submission === void 0 ? void 0 : submission.currentStep.type.transitions;
|
|
63
|
+
const disable = !currentStepTransition || !canCompleteTask;
|
|
64
|
+
const errorCode = (_d = (_c = (_b = (_a = dialogData.mutationError) === null || _a === void 0 ? void 0 : _a.graphQLErrors) === null || _b === void 0 ? void 0 : _b.find((error) => { var _a; return (_a = error === null || error === void 0 ? void 0 : error.extensions) === null || _a === void 0 ? void 0 : _a.code; })) === null || _c === void 0 ? void 0 : _c.extensions) === null || _d === void 0 ? void 0 : _d.code.name;
|
|
65
|
+
return (React.createElement(Wrapper, null,
|
|
66
|
+
goBack && (React.createElement(SecondaryButtonSmall, { onClick: goBack, type: "button" },
|
|
67
|
+
React.createElement(ArrowLeftIcon, null),
|
|
68
|
+
React.createElement("span", null, "Dashboard"))),
|
|
69
|
+
handleSnapshot &&
|
|
70
|
+
typeof hasPendingSuggestions == 'boolean' &&
|
|
71
|
+
submission.nextStep && (React.createElement(ProceedView, { isAnnotator: isAnnotator, isProofer: isProofer, disable: disable, onTransitionClick: onTransitionClick, hasPendingSuggestions: hasPendingSuggestions, dialogData: dialogData, noteValue: noteValue, currentStepTransition: currentStepTransition, currentStepType: submission.currentStep.type, previousStepType: (_e = submission.previousStep) === null || _e === void 0 ? void 0 : _e.type, nextStepType: submission.nextStep.type, onNoteChange: disabelProceedNote ? undefined : onNoteChange, continueDialogAction: continueDialogAction, onCancelClick: onCancelClick, message: message })),
|
|
72
|
+
status && (React.createElement(ChildWrapper, null,
|
|
73
|
+
React.createElement(SaveStatus, { status: status }))),
|
|
74
|
+
React.createElement(Spacer, null),
|
|
75
|
+
React.createElement(CurrentStepLabel, null, submission.currentStep.type.label),
|
|
76
|
+
React.createElement(CurrentActionLablel, null,
|
|
77
|
+
userRole &&
|
|
78
|
+
MapUserRole[userRole] &&
|
|
79
|
+
React.createElement(MapUserRole[userRole].icon),
|
|
80
|
+
React.createElement("span", null, userRole && MapUserRole[userRole].label)),
|
|
81
|
+
React.createElement(HelpDropdown, null),
|
|
82
|
+
errorCode && React.createElement(ExceptionDialog, { errorCode: errorCode })));
|
|
83
|
+
};
|
|
84
|
+
const HelpDropdown = () => {
|
|
85
|
+
const { isOpen, toggleOpen, wrapperRef } = useDropdown();
|
|
86
|
+
return (React.createElement(HelpDropdownContainer, { ref: wrapperRef },
|
|
87
|
+
React.createElement(HelpDropdownButton, { onClick: toggleOpen },
|
|
88
|
+
React.createElement("span", null, "Help"),
|
|
89
|
+
React.createElement(NavDropdownToggle, { className: isOpen ? 'open' : '' })),
|
|
90
|
+
isOpen && (React.createElement(DropdownList, { top: 12, direction: "right" },
|
|
91
|
+
React.createElement(DropdownItem, null, "Documentation")))));
|
|
92
|
+
};
|
|
93
|
+
const SecondaryButtonSmall = styled(SecondaryButton) `
|
|
94
|
+
font-size: inherit;
|
|
95
|
+
margin-right: ${(props) => props.theme.grid.unit * 2}px;
|
|
96
|
+
padding-top: ${(props) => props.theme.grid.unit * 0.75}px;
|
|
97
|
+
padding-bottom: ${(props) => props.theme.grid.unit * 0.75}px;
|
|
98
|
+
`;
|
|
99
|
+
const HelpDropdownButton = styled.button `
|
|
100
|
+
background: transparent;
|
|
101
|
+
border: none;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
`;
|
|
104
|
+
const HelpDropdownContainer = styled(DropdownContainer) `
|
|
105
|
+
border-left: 1px solid #f2f2f2;
|
|
106
|
+
margin: -${(props) => props.theme.grid.unit * 3}px ${(props) => props.theme.grid.unit * 2}px -${(props) => props.theme.grid.unit * 3}px
|
|
107
|
+
${(props) => props.theme.grid.unit * 6}px;
|
|
108
|
+
padding: ${(props) => props.theme.grid.unit * 4.75}px 0
|
|
109
|
+
${(props) => props.theme.grid.unit * 5}px
|
|
110
|
+
${(props) => props.theme.grid.unit * 4}px;
|
|
111
|
+
`;
|
|
112
|
+
const DropdownItem = styled.a `
|
|
113
|
+
color: inherit;
|
|
114
|
+
display: block;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
text-decoration: none;
|
|
117
|
+
padding: ${(props) => props.theme.grid.unit * 5}px;
|
|
118
|
+
`;
|
|
119
|
+
export const PrimaryButtonSmall = styled(PrimaryButton) `
|
|
120
|
+
padding-top: ${(props) => props.theme.grid.unit * 0.75}px;
|
|
121
|
+
padding-bottom: ${(props) => props.theme.grid.unit * 0.75}px;
|
|
122
|
+
font-size: inherit;
|
|
123
|
+
`;
|
|
124
|
+
const Wrapper = styled.div `
|
|
125
|
+
display: flex;
|
|
126
|
+
z-index: 6;
|
|
127
|
+
padding: ${(props) => props.theme.grid.unit * 3}px
|
|
128
|
+
${(props) => props.theme.grid.unit * 8}px;
|
|
129
|
+
width: 100%;
|
|
130
|
+
box-sizing: border-box;
|
|
131
|
+
align-items: center;
|
|
132
|
+
border-bottom: 1px solid #f2f2f2;
|
|
133
|
+
font-size: 14px;
|
|
134
|
+
background: white;
|
|
135
|
+
|
|
136
|
+
${NavDropdownContainer} + ${NavDropdownContainer} {
|
|
137
|
+
margin-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
138
|
+
}
|
|
139
|
+
${PrimaryButtonSmall} + ${NavDropdownContainer} {
|
|
140
|
+
margin-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
141
|
+
}
|
|
142
|
+
`;
|
|
143
|
+
const CurrentStepLabel = styled.span `
|
|
144
|
+
background: #f2f2f2;
|
|
145
|
+
border-radius: ${(props) => props.theme.grid.unit * 1.5}px;
|
|
146
|
+
padding: ${(props) => props.theme.grid.unit}px;
|
|
147
|
+
`;
|
|
148
|
+
const CurrentActionLablel = styled.span `
|
|
149
|
+
display: flex;
|
|
150
|
+
padding: 0 ${(props) => props.theme.grid.unit * 6}px;
|
|
151
|
+
svg {
|
|
152
|
+
margin-right: ${(props) => props.theme.grid.unit * 2.5}px;
|
|
153
|
+
}
|
|
154
|
+
`;
|
|
155
|
+
const ChildWrapper = styled.div `
|
|
156
|
+
display: inline-flex;
|
|
157
|
+
margin: 0 2em;
|
|
158
|
+
flex-direction: row;
|
|
159
|
+
align-items: center;
|
|
160
|
+
`;
|
|
161
|
+
const Grid = styled.div `
|
|
162
|
+
display: grid;
|
|
163
|
+
grid-template-columns: max-content auto;
|
|
164
|
+
gap: 0 ${(props) => props.theme.grid.unit * 2}px;
|
|
165
|
+
margin-top: ${(props) => props.theme.grid.unit * 4}px;
|
|
166
|
+
background: ${(props) => props.theme.colors.background.secondary};
|
|
167
|
+
padding: ${(props) => props.theme.grid.unit * 6}px;
|
|
168
|
+
`;
|
|
169
|
+
const Line = styled.hr `
|
|
170
|
+
margin: 5px 0 0 0;
|
|
171
|
+
flex: 1;
|
|
172
|
+
border: 1px dashed #c9c9c9;
|
|
173
|
+
`;
|
|
174
|
+
const Spacer = styled.div `
|
|
175
|
+
flex: auto;
|
|
176
|
+
`;
|
|
177
|
+
export const MediumTextArea = styled(TextArea) `
|
|
178
|
+
padding: 8px;
|
|
179
|
+
font-size: 1em;
|
|
180
|
+
`;
|
|
@@ -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
|
+
`;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2024 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import React, { useState } from 'react';
|
|
17
|
+
import Select from 'react-select';
|
|
18
|
+
import styled from 'styled-components';
|
|
19
|
+
import { CheckboxField, CheckboxLabel } from './Checkbox';
|
|
20
|
+
import { Category, Dialog } from './Dialog';
|
|
21
|
+
const Label = styled.div `
|
|
22
|
+
padding-right: 16px;
|
|
23
|
+
width: 150px;
|
|
24
|
+
`;
|
|
25
|
+
const SelectContainer = styled.div `
|
|
26
|
+
width: 182px;
|
|
27
|
+
height: 30px;
|
|
28
|
+
`;
|
|
29
|
+
const Container = styled.div `
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
padding-bottom: 16px;
|
|
33
|
+
`;
|
|
34
|
+
const OptionWrapper = styled.div `
|
|
35
|
+
padding-left: ${(props) => props.theme.grid.unit * 4}px;
|
|
36
|
+
padding-top: ${(props) => props.theme.grid.unit * 2}px;
|
|
37
|
+
padding-bottom: ${(props) => props.theme.grid.unit * 2}px;
|
|
38
|
+
|
|
39
|
+
background-color: ${(props) => props.focused ? props.theme.colors.background.fifth : 'transparent'};
|
|
40
|
+
|
|
41
|
+
&:hover {
|
|
42
|
+
background-color: ${(props) => props.theme.colors.background.fifth};
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
export const InsertTableDialog = ({ run, open, onClose }) => {
|
|
46
|
+
const [numberOfColumns, setNumColumns] = useState({ value: 4, label: `4` });
|
|
47
|
+
const [numberOfRows, setNumRows] = useState({ value: 4, label: `4` });
|
|
48
|
+
const [includeHeader, setIncludeHeader] = useState(true);
|
|
49
|
+
const handleColumnChange = (newValue) => {
|
|
50
|
+
setNumColumns(newValue);
|
|
51
|
+
};
|
|
52
|
+
const handleRowChange = (newValue) => {
|
|
53
|
+
setNumRows(newValue);
|
|
54
|
+
};
|
|
55
|
+
const options = Array.from({ length: 20 }, (_, index) => ({
|
|
56
|
+
value: index + 1,
|
|
57
|
+
label: `${index + 1}`,
|
|
58
|
+
}));
|
|
59
|
+
const OptionComponent = ({ innerProps, data, }) => {
|
|
60
|
+
return (React.createElement(OptionWrapper, Object.assign({}, innerProps, { ref: null }), data.label));
|
|
61
|
+
};
|
|
62
|
+
const insertTableDialogActions = {
|
|
63
|
+
primary: {
|
|
64
|
+
action: () => {
|
|
65
|
+
const tableConfig = {
|
|
66
|
+
numberOfColumns: numberOfColumns.value,
|
|
67
|
+
numberOfRows: numberOfRows.value,
|
|
68
|
+
includeHeader,
|
|
69
|
+
};
|
|
70
|
+
run(tableConfig);
|
|
71
|
+
onClose();
|
|
72
|
+
},
|
|
73
|
+
title: 'Create table',
|
|
74
|
+
},
|
|
75
|
+
secondary: {
|
|
76
|
+
action: onClose,
|
|
77
|
+
title: 'Cancel',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
return (React.createElement(Dialog, { isOpen: open, actions: insertTableDialogActions, category: Category.confirmation, header: 'Insert table', message: '' },
|
|
81
|
+
React.createElement(React.Fragment, null,
|
|
82
|
+
React.createElement(React.Fragment, null,
|
|
83
|
+
React.createElement(Container, null,
|
|
84
|
+
React.createElement(Label, null, "Number of columns:"),
|
|
85
|
+
React.createElement(SelectContainer, null,
|
|
86
|
+
React.createElement(Select, { onChange: (newValue) => handleColumnChange(newValue), value: numberOfColumns, options: options, components: {
|
|
87
|
+
Option: OptionComponent,
|
|
88
|
+
}, menuPosition: "fixed", maxMenuHeight: 150 }))),
|
|
89
|
+
React.createElement(Container, null,
|
|
90
|
+
React.createElement(Label, null, "Number of rows:"),
|
|
91
|
+
React.createElement(SelectContainer, null,
|
|
92
|
+
React.createElement(Select, { onChange: (newValue) => handleRowChange(newValue), value: numberOfRows, options: options, components: {
|
|
93
|
+
Option: OptionComponent,
|
|
94
|
+
}, menuPosition: "fixed", maxMenuHeight: 150 })))),
|
|
95
|
+
React.createElement(CheckboxLabel, null,
|
|
96
|
+
React.createElement(CheckboxField, { name: 'include-header', checked: includeHeader, onChange: (e) => {
|
|
97
|
+
setIncludeHeader(e.target.checked);
|
|
98
|
+
} }),
|
|
99
|
+
React.createElement("div", null, "Include header row")))));
|
|
100
|
+
};
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import React, { useState } from 'react';
|
|
17
17
|
import styled from 'styled-components';
|
|
18
18
|
import { Category, Dialog } from '../Dialog';
|
|
19
|
+
import { InsertTableDialog } from '../InsertTableDialog';
|
|
19
20
|
import { Submenu, SubmenusContainer, Text } from './Submenu';
|
|
20
21
|
const MenusContainer = styled.div `
|
|
21
22
|
display: flex;
|
|
@@ -40,6 +41,11 @@ const MenuContainer = styled.div `
|
|
|
40
41
|
`;
|
|
41
42
|
export const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
42
43
|
const [columnMenu, setColumnMenu] = useState(undefined);
|
|
44
|
+
const [openDialog, setOpenDialog] = useState(false);
|
|
45
|
+
const [indices, setIndices] = useState([]);
|
|
46
|
+
const toggleDialog = () => {
|
|
47
|
+
setOpenDialog(!openDialog);
|
|
48
|
+
};
|
|
43
49
|
return (React.createElement(MenusContainer, { ref: innerRef },
|
|
44
50
|
menus.map((menu, index) => {
|
|
45
51
|
return (React.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.isEnabled },
|
|
@@ -49,7 +55,17 @@ export const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
|
49
55
|
}, isOpen: menu.isOpen },
|
|
50
56
|
React.createElement(Text, null, menu.label)),
|
|
51
57
|
menu.isEnabled && menu.isOpen && menu.submenu && (React.createElement(SubmenusContainer, null, menu.submenu.map((submenu, sindex) => {
|
|
52
|
-
return (React.createElement(Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) =>
|
|
58
|
+
return (React.createElement(Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) => {
|
|
59
|
+
const indices = [index, sindex, ...i];
|
|
60
|
+
if ('id' in submenu &&
|
|
61
|
+
submenu.id === 'insert-table-element') {
|
|
62
|
+
setIndices(indices);
|
|
63
|
+
toggleDialog();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
handleClick(indices);
|
|
67
|
+
}
|
|
68
|
+
}, setColumnMenu: setColumnMenu }));
|
|
53
69
|
})))));
|
|
54
70
|
}),
|
|
55
71
|
React.createElement(ColumnChangeWarningDialog, { isOpen: !!columnMenu, primaryAction: () => {
|
|
@@ -57,7 +73,8 @@ export const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
|
57
73
|
columnMenu.run();
|
|
58
74
|
setColumnMenu(undefined);
|
|
59
75
|
}
|
|
60
|
-
}, secondaryAction: () => setColumnMenu(undefined) })
|
|
76
|
+
}, secondaryAction: () => setColumnMenu(undefined) }),
|
|
77
|
+
openDialog && (React.createElement(InsertTableDialog, { run: (tableConfig) => handleClick(indices, tableConfig), open: openDialog, onClose: toggleDialog }))));
|
|
61
78
|
};
|
|
62
79
|
export const orderedListContextMenu = [
|
|
63
80
|
{ items: ['1.', '2.', '3.'], type: 'order' },
|
|
@@ -50,13 +50,13 @@ const getMenuAt = (state, position) => {
|
|
|
50
50
|
export const useMenus = (menus) => {
|
|
51
51
|
const [pointer, setPointer] = useState(initialPointer);
|
|
52
52
|
const state = getMenuState(menus, pointer);
|
|
53
|
-
const handleClick = useCallback((indices) => {
|
|
53
|
+
const handleClick = useCallback((indices, tableConfig) => {
|
|
54
54
|
const menu = getMenuAt(state, indices);
|
|
55
55
|
if (!menu || !menu.isEnabled) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
if (menu.run) {
|
|
59
|
-
menu.run();
|
|
59
|
+
menu.run(tableConfig);
|
|
60
60
|
setPointer([-1, -1, -1]);
|
|
61
61
|
}
|
|
62
62
|
else if (menu.submenu) {
|
package/dist/es/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from './components/RadioButton';
|
|
|
20
20
|
export * from './components/AutoSaveInput';
|
|
21
21
|
export * from './components/Avatar';
|
|
22
22
|
export * from './components/Dialog';
|
|
23
|
+
export * from './components/InsertTableDialog';
|
|
23
24
|
export * from './components/Checkbox';
|
|
24
25
|
export * from './components/Form';
|
|
25
26
|
export * from './components/FileManager';
|
|
@@ -42,6 +43,7 @@ export * from './components/Badge';
|
|
|
42
43
|
export * from './components/NavDropdown';
|
|
43
44
|
export * from './components/Dropdown';
|
|
44
45
|
export * from './components/LoadingOverlay';
|
|
46
|
+
export * from './components/EditorHeader/EditorHeader';
|
|
45
47
|
export * from './components/DatePicker';
|
|
46
48
|
export * from './components/Text';
|
|
47
49
|
export * from './components/RelativeDate';
|
|
@@ -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
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2024 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import { TableConfig } from '../lib/menus';
|
|
18
|
+
export declare const InsertTableDialog: React.FC<{
|
|
19
|
+
run: (tableConfig: TableConfig) => void;
|
|
20
|
+
open: boolean;
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
}>;
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import React, { Ref } from 'react';
|
|
17
|
-
import { Menu } from '../../lib/menus';
|
|
17
|
+
import { Menu, TableConfig } from '../../lib/menus';
|
|
18
18
|
interface MenusProps {
|
|
19
19
|
menus: Menu[];
|
|
20
20
|
innerRef: Ref<HTMLDivElement>;
|
|
21
|
-
handleClick: (position: number[]) => void;
|
|
21
|
+
handleClick: (position: number[], tableConfig?: TableConfig) => void;
|
|
22
22
|
}
|
|
23
23
|
export declare const Menus: React.FC<MenusProps>;
|
|
24
24
|
export declare const orderedListContextMenu: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Menu, MenuSpec } from '../lib/menus';
|
|
2
|
+
import { Menu, MenuSpec, TableConfig } from '../lib/menus';
|
|
3
3
|
export declare const useMenus: (menus: MenuSpec[]) => {
|
|
4
4
|
menus: Menu[];
|
|
5
|
-
handleClick: (indices: number[]) => void;
|
|
5
|
+
handleClick: (indices: number[], tableConfig?: TableConfig) => void;
|
|
6
6
|
ref: import("react").RefObject<HTMLDivElement>;
|
|
7
7
|
};
|