@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.
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.MediumTextArea = exports.PrimaryButtonSmall = exports.EditorHeader = exports.DialogState = void 0;
39
+ const react_1 = __importStar(require("react"));
40
+ const styled_components_1 = __importDefault(require("styled-components"));
41
+ const __1 = require("../..");
42
+ const ProceedView_1 = require("./ProceedView");
43
+ var DialogState;
44
+ (function (DialogState) {
45
+ DialogState[DialogState["INIT"] = 0] = "INIT";
46
+ DialogState[DialogState["LOADING"] = 1] = "LOADING";
47
+ DialogState[DialogState["ERROR"] = 2] = "ERROR";
48
+ DialogState[DialogState["SUCCESS"] = 3] = "SUCCESS";
49
+ DialogState[DialogState["CLOSED"] = 4] = "CLOSED";
50
+ })(DialogState = exports.DialogState || (exports.DialogState = {}));
51
+ const Editing = { label: 'Editing', icon: __1.EditIcon };
52
+ const MapUserRole = {
53
+ Editor: Editing,
54
+ Owner: Editing,
55
+ Writer: Editing,
56
+ Annotator: { label: 'Suggesting', icon: __1.RoleAnnotatingIcon },
57
+ Viewer: { label: 'Reading', icon: __1.RoleReadingIcon },
58
+ Proofer: { label: 'Proofing', icon: __1.RoleAnnotatingIcon },
59
+ };
60
+ const EditorHeader = ({ handleSnapshot, submission, hasPendingSuggestions, userRole, canCompleteTask, submitProceed, goBack, status, isAnnotator, isProofer, message, exceptionDialog: ExceptionDialog, disabelProceedNote, }) => {
61
+ var _a, _b, _c, _d, _e;
62
+ const [noteValue, setNoteValue] = (0, react_1.useState)('');
63
+ const [selectedTransitionIndex, setSelectedTransitionIndex] = (0, react_1.useState)();
64
+ const { dialogData, submit } = submitProceed;
65
+ const { updateState, clearError } = dialogData;
66
+ const continueDialogAction = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
67
+ if (submission && selectedTransitionIndex && handleSnapshot) {
68
+ const { status } = submission.currentStep.type.transitions[selectedTransitionIndex];
69
+ updateState(DialogState.LOADING);
70
+ yield handleSnapshot();
71
+ yield submit(status.id, noteValue);
72
+ }
73
+ }), [
74
+ submission,
75
+ selectedTransitionIndex,
76
+ handleSnapshot,
77
+ updateState,
78
+ submit,
79
+ noteValue,
80
+ ]);
81
+ const onTransitionClick = (0, react_1.useCallback)((event) => {
82
+ updateState(DialogState.INIT);
83
+ setSelectedTransitionIndex(event.target.value || event.target.parentNode.value);
84
+ }, [setSelectedTransitionIndex, updateState]);
85
+ const onCancelClick = (0, react_1.useCallback)(() => {
86
+ setSelectedTransitionIndex(undefined);
87
+ clearError();
88
+ updateState(DialogState.CLOSED);
89
+ }, [setSelectedTransitionIndex, clearError, updateState]);
90
+ const onNoteChange = (0, react_1.useCallback)((event) => setNoteValue(event.target.value), [setNoteValue]);
91
+ const currentStepTransition = submission === null || submission === void 0 ? void 0 : submission.currentStep.type.transitions;
92
+ const disable = !currentStepTransition || !canCompleteTask;
93
+ 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;
94
+ return (react_1.default.createElement(Wrapper, null,
95
+ goBack && (react_1.default.createElement(SecondaryButtonSmall, { onClick: goBack, type: "button" },
96
+ react_1.default.createElement(__1.ArrowLeftIcon, null),
97
+ react_1.default.createElement("span", null, "Dashboard"))),
98
+ handleSnapshot &&
99
+ typeof hasPendingSuggestions == 'boolean' &&
100
+ submission.nextStep && (react_1.default.createElement(ProceedView_1.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 })),
101
+ status && (react_1.default.createElement(ChildWrapper, null,
102
+ react_1.default.createElement(__1.SaveStatus, { status: status }))),
103
+ react_1.default.createElement(Spacer, null),
104
+ react_1.default.createElement(CurrentStepLabel, null, submission.currentStep.type.label),
105
+ react_1.default.createElement(CurrentActionLablel, null,
106
+ userRole &&
107
+ MapUserRole[userRole] &&
108
+ react_1.default.createElement(MapUserRole[userRole].icon),
109
+ react_1.default.createElement("span", null, userRole && MapUserRole[userRole].label)),
110
+ react_1.default.createElement(HelpDropdown, null),
111
+ errorCode && react_1.default.createElement(ExceptionDialog, { errorCode: errorCode })));
112
+ };
113
+ exports.EditorHeader = EditorHeader;
114
+ const HelpDropdown = () => {
115
+ const { isOpen, toggleOpen, wrapperRef } = (0, __1.useDropdown)();
116
+ return (react_1.default.createElement(HelpDropdownContainer, { ref: wrapperRef },
117
+ react_1.default.createElement(HelpDropdownButton, { onClick: toggleOpen },
118
+ react_1.default.createElement("span", null, "Help"),
119
+ react_1.default.createElement(__1.NavDropdownToggle, { className: isOpen ? 'open' : '' })),
120
+ isOpen && (react_1.default.createElement(__1.DropdownList, { top: 12, direction: "right" },
121
+ react_1.default.createElement(DropdownItem, null, "Documentation")))));
122
+ };
123
+ const SecondaryButtonSmall = (0, styled_components_1.default)(__1.SecondaryButton) `
124
+ font-size: inherit;
125
+ margin-right: ${(props) => props.theme.grid.unit * 2}px;
126
+ padding-top: ${(props) => props.theme.grid.unit * 0.75}px;
127
+ padding-bottom: ${(props) => props.theme.grid.unit * 0.75}px;
128
+ `;
129
+ const HelpDropdownButton = styled_components_1.default.button `
130
+ background: transparent;
131
+ border: none;
132
+ cursor: pointer;
133
+ `;
134
+ const HelpDropdownContainer = (0, styled_components_1.default)(__1.DropdownContainer) `
135
+ border-left: 1px solid #f2f2f2;
136
+ margin: -${(props) => props.theme.grid.unit * 3}px ${(props) => props.theme.grid.unit * 2}px -${(props) => props.theme.grid.unit * 3}px
137
+ ${(props) => props.theme.grid.unit * 6}px;
138
+ padding: ${(props) => props.theme.grid.unit * 4.75}px 0
139
+ ${(props) => props.theme.grid.unit * 5}px
140
+ ${(props) => props.theme.grid.unit * 4}px;
141
+ `;
142
+ const DropdownItem = styled_components_1.default.a `
143
+ color: inherit;
144
+ display: block;
145
+ cursor: pointer;
146
+ text-decoration: none;
147
+ padding: ${(props) => props.theme.grid.unit * 5}px;
148
+ `;
149
+ exports.PrimaryButtonSmall = (0, styled_components_1.default)(__1.PrimaryButton) `
150
+ padding-top: ${(props) => props.theme.grid.unit * 0.75}px;
151
+ padding-bottom: ${(props) => props.theme.grid.unit * 0.75}px;
152
+ font-size: inherit;
153
+ `;
154
+ const Wrapper = styled_components_1.default.div `
155
+ display: flex;
156
+ z-index: 6;
157
+ padding: ${(props) => props.theme.grid.unit * 3}px
158
+ ${(props) => props.theme.grid.unit * 8}px;
159
+ width: 100%;
160
+ box-sizing: border-box;
161
+ align-items: center;
162
+ border-bottom: 1px solid #f2f2f2;
163
+ font-size: 14px;
164
+ background: white;
165
+
166
+ ${__1.NavDropdownContainer} + ${__1.NavDropdownContainer} {
167
+ margin-left: ${(props) => props.theme.grid.unit * 2}px;
168
+ }
169
+ ${exports.PrimaryButtonSmall} + ${__1.NavDropdownContainer} {
170
+ margin-left: ${(props) => props.theme.grid.unit * 2}px;
171
+ }
172
+ `;
173
+ const CurrentStepLabel = styled_components_1.default.span `
174
+ background: #f2f2f2;
175
+ border-radius: ${(props) => props.theme.grid.unit * 1.5}px;
176
+ padding: ${(props) => props.theme.grid.unit}px;
177
+ `;
178
+ const CurrentActionLablel = styled_components_1.default.span `
179
+ display: flex;
180
+ padding: 0 ${(props) => props.theme.grid.unit * 6}px;
181
+ svg {
182
+ margin-right: ${(props) => props.theme.grid.unit * 2.5}px;
183
+ }
184
+ `;
185
+ const ChildWrapper = styled_components_1.default.div `
186
+ display: inline-flex;
187
+ margin: 0 2em;
188
+ flex-direction: row;
189
+ align-items: center;
190
+ `;
191
+ const Grid = styled_components_1.default.div `
192
+ display: grid;
193
+ grid-template-columns: max-content auto;
194
+ gap: 0 ${(props) => props.theme.grid.unit * 2}px;
195
+ margin-top: ${(props) => props.theme.grid.unit * 4}px;
196
+ background: ${(props) => props.theme.colors.background.secondary};
197
+ padding: ${(props) => props.theme.grid.unit * 6}px;
198
+ `;
199
+ const Line = styled_components_1.default.hr `
200
+ margin: 5px 0 0 0;
201
+ flex: 1;
202
+ border: 1px dashed #c9c9c9;
203
+ `;
204
+ const Spacer = styled_components_1.default.div `
205
+ flex: auto;
206
+ `;
207
+ exports.MediumTextArea = (0, styled_components_1.default)(__1.TextArea) `
208
+ padding: 8px;
209
+ font-size: 1em;
210
+ `;
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ProceedView = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const __1 = require("../..");
33
+ const AlertMessage_1 = require("../AlertMessage");
34
+ const EditorHeader_1 = require("./EditorHeader");
35
+ const DropdownWrapper = ({ disabled, button, primary, children }) => {
36
+ const { isOpen, toggleOpen, wrapperRef } = (0, __1.useDropdown)();
37
+ return (react_1.default.createElement(__1.NavDropdownContainer, { id: 'user-dropdown', ref: wrapperRef },
38
+ react_1.default.createElement(__1.NavDropdownButton, { as: (primary && __1.PrimaryButton) || undefined, disabled: disabled, isOpen: isOpen, onClick: toggleOpen }, button),
39
+ isOpen && react_1.default.createElement(__1.NavDropdown, { direction: "left" }, children)));
40
+ };
41
+ const StepDetails = ({ icon, label, description, role }) => (react_1.default.createElement(react_1.default.Fragment, null,
42
+ icon && react_1.default.createElement(TaskStatus, null, icon),
43
+ react_1.default.createElement(TaskContainer, null,
44
+ react_1.default.createElement(__1.PrimaryBoldHeading, null, label),
45
+ react_1.default.createElement(__1.SecondarySmallText, null, description),
46
+ react_1.default.createElement(__1.SecondarySmallText, null,
47
+ "Actor: ",
48
+ role.label))));
49
+ const ProceedView = ({ currentStepTransition, onTransitionClick, disable, dialogData, previousStepType, currentStepType, isAnnotator, isProofer, hasPendingSuggestions, onCancelClick, continueDialogAction, message: Message, }) => {
50
+ const dialogMessages = (0, react_1.useMemo)(() => hasPendingSuggestions &&
51
+ !isAnnotator &&
52
+ !isProofer &&
53
+ dialogData.state !== __1.DialogState.SUCCESS
54
+ ? {
55
+ header: 'The task can not be transitioned to the next step',
56
+ message: `There are still pending suggestions in the document.
57
+ It is not possible to complete the task without having them approved or rejected.`,
58
+ actions: {
59
+ primary: {
60
+ action: onCancelClick,
61
+ title: 'Ok',
62
+ },
63
+ onClose: onCancelClick,
64
+ },
65
+ }
66
+ : dialogData.state === __1.DialogState.SUCCESS
67
+ ? {
68
+ header: 'Content reassigned successfully',
69
+ message: `to the ${currentStepType.label}`,
70
+ actions: {
71
+ primary: {
72
+ action: onCancelClick,
73
+ title: 'Close',
74
+ },
75
+ onClose: onCancelClick,
76
+ },
77
+ }
78
+ : {
79
+ header: 'Are you sure?',
80
+ message: 'You are about to complete your task. If you confirm, you will no longer be able to make any changes.',
81
+ actions: {
82
+ primary: {
83
+ action: continueDialogAction,
84
+ title: 'Continue',
85
+ },
86
+ secondary: {
87
+ action: onCancelClick,
88
+ title: 'Cancel',
89
+ },
90
+ onClose: onCancelClick,
91
+ },
92
+ }, [
93
+ dialogData,
94
+ continueDialogAction,
95
+ onCancelClick,
96
+ currentStepType,
97
+ hasPendingSuggestions,
98
+ isAnnotator,
99
+ isProofer,
100
+ ]);
101
+ const prevDialogMsgs = (0, react_1.useRef)();
102
+ const prevDialogueState = (0, react_1.useRef)();
103
+ (0, react_1.useEffect)(() => {
104
+ prevDialogMsgs.current = dialogMessages;
105
+ prevDialogueState.current = dialogData.state;
106
+ }, [dialogData.state]);
107
+ const messages = dialogData.state === __1.DialogState.CLOSED && prevDialogMsgs.current
108
+ ? prevDialogMsgs.current
109
+ : dialogMessages;
110
+ const finalState = dialogData.state === __1.DialogState.CLOSED && prevDialogueState.current
111
+ ? prevDialogueState.current
112
+ : dialogData.state;
113
+ return (react_1.default.createElement(react_1.default.Fragment, null,
114
+ (currentStepTransition && (currentStepTransition === null || currentStepTransition === void 0 ? void 0 : currentStepTransition.length) > 1 && (react_1.default.createElement(DropdownWrapper, { button: 'Complete task', disabled: disable, primary: true },
115
+ react_1.default.createElement(TaskDropdown, null, currentStepTransition &&
116
+ currentStepTransition.map((transition, index) => (react_1.default.createElement(Task, { key: 'task_' + transition.type.id, className: transition.status.id === 'success' ? 'happyPath' : '', value: index, onClick: onTransitionClick },
117
+ react_1.default.createElement("strong", null, transition.type.label),
118
+ transition.type.description))))))) || (react_1.default.createElement(EditorHeader_1.PrimaryButtonSmall, { value: 0, onClick: onTransitionClick, disabled: disable }, "Complete task")),
119
+ finalState === __1.DialogState.LOADING && (react_1.default.createElement(__1.LoadingOverlay, null,
120
+ react_1.default.createElement(Message, { isCentered: true }, "Proceeding with your submission\u2026"))),
121
+ react_1.default.createElement(__1.Dialog, { isOpen: dialogData.state !== __1.DialogState.CLOSED &&
122
+ dialogData.state !== __1.DialogState.LOADING, category: __1.Category.confirmation, header: messages.header, message: messages.message, actions: messages.actions },
123
+ finalState === __1.DialogState.SUCCESS && (react_1.default.createElement(Grid, null,
124
+ previousStepType && (react_1.default.createElement(StepDetails, Object.assign({}, previousStepType, { icon: react_1.default.createElement(react_1.default.Fragment, null,
125
+ react_1.default.createElement(__1.TaskStepDoneIcon, null),
126
+ react_1.default.createElement(Line, null)) }))),
127
+ react_1.default.createElement(StepDetails, Object.assign({}, currentStepType)))),
128
+ finalState === __1.DialogState.ERROR && (react_1.default.createElement(AlertMessage_1.AlertMessage, { type: AlertMessage_1.AlertMessageType.error, hideCloseButton: true }, dialogData.error)))));
129
+ };
130
+ exports.ProceedView = ProceedView;
131
+ const TaskDropdown = styled_components_1.default.div `
132
+ display: flex;
133
+ flex-direction: column;
134
+ padding: ${(props) => props.theme.grid.unit * 2}px 0;
135
+ `;
136
+ const Task = styled_components_1.default.button `
137
+ background: transparent;
138
+ border: none;
139
+ color: ${(props) => props.theme.colors.text.secondary};
140
+ cursor: pointer;
141
+ font: ${(props) => props.theme.font.weight.normal}
142
+ ${(props) => props.theme.font.size.small} /
143
+ ${(props) => props.theme.font.lineHeight.normal}
144
+ ${(props) => props.theme.font.family.sans};
145
+ order: 1;
146
+ outline: none;
147
+ padding: ${(props) => props.theme.grid.unit * 2}px
148
+ ${(props) => props.theme.grid.unit * 4}px;
149
+ text-align: left;
150
+ width: ${(props) => props.theme.grid.unit * 66}px;
151
+
152
+ &:not([disabled]):hover,
153
+ &:not([disabled]):focus {
154
+ background-color: ${(props) => props.theme.colors.button.default.background.hover};
155
+ }
156
+
157
+ strong {
158
+ color: ${(props) => props.theme.colors.text.primary};
159
+ display: block;
160
+ font-size: ${(props) => props.theme.font.size.normal};
161
+ line-height: ${(props) => props.theme.font.lineHeight.normal};
162
+ }
163
+
164
+ &.happyPath {
165
+ border-bottom: 1px solid ${(props) => props.theme.colors.border.tertiary};
166
+ order: 0;
167
+ }
168
+ `;
169
+ const TextAreaWrapper = styled_components_1.default.div `
170
+ margin-top: ${(props) => props.theme.grid.unit * 4}px;
171
+ `;
172
+ const Grid = styled_components_1.default.div `
173
+ display: grid;
174
+ grid-template-columns: max-content auto;
175
+ gap: 0 ${(props) => props.theme.grid.unit * 2}px;
176
+ margin-top: ${(props) => props.theme.grid.unit * 4}px;
177
+ background: ${(props) => props.theme.colors.background.secondary};
178
+ padding: ${(props) => props.theme.grid.unit * 6}px;
179
+ `;
180
+ const Line = styled_components_1.default.hr `
181
+ margin: 5px 0 0 0;
182
+ flex: 1;
183
+ border: 1px dashed #c9c9c9;
184
+ `;
185
+ const TaskStatus = styled_components_1.default.div `
186
+ grid-column: 1;
187
+ display: flex;
188
+ flex-direction: column;
189
+ align-items: center;
190
+ padding-top: 5px;
191
+ `;
192
+ const TaskContainer = styled_components_1.default.div `
193
+ grid-column: 2;
194
+ margin-bottom: 8px;
195
+ `;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2024 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.InsertTableDialog = void 0;
45
+ const react_1 = __importStar(require("react"));
46
+ const react_select_1 = __importDefault(require("react-select"));
47
+ const styled_components_1 = __importDefault(require("styled-components"));
48
+ const Checkbox_1 = require("./Checkbox");
49
+ const Dialog_1 = require("./Dialog");
50
+ const Label = styled_components_1.default.div `
51
+ padding-right: 16px;
52
+ width: 150px;
53
+ `;
54
+ const SelectContainer = styled_components_1.default.div `
55
+ width: 182px;
56
+ height: 30px;
57
+ `;
58
+ const Container = styled_components_1.default.div `
59
+ display: flex;
60
+ align-items: center;
61
+ padding-bottom: 16px;
62
+ `;
63
+ const OptionWrapper = styled_components_1.default.div `
64
+ padding-left: ${(props) => props.theme.grid.unit * 4}px;
65
+ padding-top: ${(props) => props.theme.grid.unit * 2}px;
66
+ padding-bottom: ${(props) => props.theme.grid.unit * 2}px;
67
+
68
+ background-color: ${(props) => props.focused ? props.theme.colors.background.fifth : 'transparent'};
69
+
70
+ &:hover {
71
+ background-color: ${(props) => props.theme.colors.background.fifth};
72
+ }
73
+ `;
74
+ const InsertTableDialog = ({ run, open, onClose }) => {
75
+ const [numberOfColumns, setNumColumns] = (0, react_1.useState)({ value: 4, label: `4` });
76
+ const [numberOfRows, setNumRows] = (0, react_1.useState)({ value: 4, label: `4` });
77
+ const [includeHeader, setIncludeHeader] = (0, react_1.useState)(true);
78
+ const handleColumnChange = (newValue) => {
79
+ setNumColumns(newValue);
80
+ };
81
+ const handleRowChange = (newValue) => {
82
+ setNumRows(newValue);
83
+ };
84
+ const options = Array.from({ length: 20 }, (_, index) => ({
85
+ value: index + 1,
86
+ label: `${index + 1}`,
87
+ }));
88
+ const OptionComponent = ({ innerProps, data, }) => {
89
+ return (react_1.default.createElement(OptionWrapper, Object.assign({}, innerProps, { ref: null }), data.label));
90
+ };
91
+ const insertTableDialogActions = {
92
+ primary: {
93
+ action: () => {
94
+ const tableConfig = {
95
+ numberOfColumns: numberOfColumns.value,
96
+ numberOfRows: numberOfRows.value,
97
+ includeHeader,
98
+ };
99
+ run(tableConfig);
100
+ onClose();
101
+ },
102
+ title: 'Create table',
103
+ },
104
+ secondary: {
105
+ action: onClose,
106
+ title: 'Cancel',
107
+ },
108
+ };
109
+ return (react_1.default.createElement(Dialog_1.Dialog, { isOpen: open, actions: insertTableDialogActions, category: Dialog_1.Category.confirmation, header: 'Insert table', message: '' },
110
+ react_1.default.createElement(react_1.default.Fragment, null,
111
+ react_1.default.createElement(react_1.default.Fragment, null,
112
+ react_1.default.createElement(Container, null,
113
+ react_1.default.createElement(Label, null, "Number of columns:"),
114
+ react_1.default.createElement(SelectContainer, null,
115
+ react_1.default.createElement(react_select_1.default, { onChange: (newValue) => handleColumnChange(newValue), value: numberOfColumns, options: options, components: {
116
+ Option: OptionComponent,
117
+ }, menuPosition: "fixed", maxMenuHeight: 150 }))),
118
+ react_1.default.createElement(Container, null,
119
+ react_1.default.createElement(Label, null, "Number of rows:"),
120
+ react_1.default.createElement(SelectContainer, null,
121
+ react_1.default.createElement(react_select_1.default, { onChange: (newValue) => handleRowChange(newValue), value: numberOfRows, options: options, components: {
122
+ Option: OptionComponent,
123
+ }, menuPosition: "fixed", maxMenuHeight: 150 })))),
124
+ react_1.default.createElement(Checkbox_1.CheckboxLabel, null,
125
+ react_1.default.createElement(Checkbox_1.CheckboxField, { name: 'include-header', checked: includeHeader, onChange: (e) => {
126
+ setIncludeHeader(e.target.checked);
127
+ } }),
128
+ react_1.default.createElement("div", null, "Include header row")))));
129
+ };
130
+ exports.InsertTableDialog = InsertTableDialog;
@@ -45,6 +45,7 @@ exports.ColumnChangeWarningDialog = exports.Label = exports.Block = exports.Bloc
45
45
  const react_1 = __importStar(require("react"));
46
46
  const styled_components_1 = __importDefault(require("styled-components"));
47
47
  const Dialog_1 = require("../Dialog");
48
+ const InsertTableDialog_1 = require("../InsertTableDialog");
48
49
  const Submenu_1 = require("./Submenu");
49
50
  const MenusContainer = styled_components_1.default.div `
50
51
  display: flex;
@@ -69,6 +70,11 @@ const MenuContainer = styled_components_1.default.div `
69
70
  `;
70
71
  const Menus = ({ menus, innerRef, handleClick, }) => {
71
72
  const [columnMenu, setColumnMenu] = (0, react_1.useState)(undefined);
73
+ const [openDialog, setOpenDialog] = (0, react_1.useState)(false);
74
+ const [indices, setIndices] = (0, react_1.useState)([]);
75
+ const toggleDialog = () => {
76
+ setOpenDialog(!openDialog);
77
+ };
72
78
  return (react_1.default.createElement(MenusContainer, { ref: innerRef },
73
79
  menus.map((menu, index) => {
74
80
  return (react_1.default.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.isEnabled },
@@ -78,7 +84,17 @@ const Menus = ({ menus, innerRef, handleClick, }) => {
78
84
  }, isOpen: menu.isOpen },
79
85
  react_1.default.createElement(Submenu_1.Text, null, menu.label)),
80
86
  menu.isEnabled && menu.isOpen && menu.submenu && (react_1.default.createElement(Submenu_1.SubmenusContainer, null, menu.submenu.map((submenu, sindex) => {
81
- return (react_1.default.createElement(Submenu_1.Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) => handleClick([index, sindex, ...i]), setColumnMenu: setColumnMenu }));
87
+ return (react_1.default.createElement(Submenu_1.Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) => {
88
+ const indices = [index, sindex, ...i];
89
+ if ('id' in submenu &&
90
+ submenu.id === 'insert-table-element') {
91
+ setIndices(indices);
92
+ toggleDialog();
93
+ }
94
+ else {
95
+ handleClick(indices);
96
+ }
97
+ }, setColumnMenu: setColumnMenu }));
82
98
  })))));
83
99
  }),
84
100
  react_1.default.createElement(exports.ColumnChangeWarningDialog, { isOpen: !!columnMenu, primaryAction: () => {
@@ -86,7 +102,8 @@ const Menus = ({ menus, innerRef, handleClick, }) => {
86
102
  columnMenu.run();
87
103
  setColumnMenu(undefined);
88
104
  }
89
- }, secondaryAction: () => setColumnMenu(undefined) })));
105
+ }, secondaryAction: () => setColumnMenu(undefined) }),
106
+ openDialog && (react_1.default.createElement(InsertTableDialog_1.InsertTableDialog, { run: (tableConfig) => handleClick(indices, tableConfig), open: openDialog, onClose: toggleDialog }))));
90
107
  };
91
108
  exports.Menus = Menus;
92
109
  exports.orderedListContextMenu = [
@@ -53,13 +53,13 @@ const getMenuAt = (state, position) => {
53
53
  const useMenus = (menus) => {
54
54
  const [pointer, setPointer] = (0, react_1.useState)(initialPointer);
55
55
  const state = getMenuState(menus, pointer);
56
- const handleClick = (0, react_1.useCallback)((indices) => {
56
+ const handleClick = (0, react_1.useCallback)((indices, tableConfig) => {
57
57
  const menu = getMenuAt(state, indices);
58
58
  if (!menu || !menu.isEnabled) {
59
59
  return;
60
60
  }
61
61
  if (menu.run) {
62
- menu.run();
62
+ menu.run(tableConfig);
63
63
  setPointer([-1, -1, -1]);
64
64
  }
65
65
  else if (menu.submenu) {
package/dist/cjs/index.js CHANGED
@@ -40,6 +40,7 @@ __exportStar(require("./components/RadioButton"), exports);
40
40
  __exportStar(require("./components/AutoSaveInput"), exports);
41
41
  __exportStar(require("./components/Avatar"), exports);
42
42
  __exportStar(require("./components/Dialog"), exports);
43
+ __exportStar(require("./components/InsertTableDialog"), exports);
43
44
  __exportStar(require("./components/Checkbox"), exports);
44
45
  __exportStar(require("./components/Form"), exports);
45
46
  __exportStar(require("./components/FileManager"), exports);
@@ -62,6 +63,7 @@ __exportStar(require("./components/Badge"), exports);
62
63
  __exportStar(require("./components/NavDropdown"), exports);
63
64
  __exportStar(require("./components/Dropdown"), exports);
64
65
  __exportStar(require("./components/LoadingOverlay"), exports);
66
+ __exportStar(require("./components/EditorHeader/EditorHeader"), exports);
65
67
  __exportStar(require("./components/DatePicker"), exports);
66
68
  __exportStar(require("./components/Text"), exports);
67
69
  __exportStar(require("./components/RelativeDate"), exports);