@manuscripts/style-guide 2.0.7-LEAN-3573-menus.0 → 2.0.7
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/InsertTableDialog.js +130 -0
- package/dist/cjs/components/Menus/Menus.js +126 -13
- package/dist/cjs/components/Menus/Submenu.js +39 -25
- package/dist/cjs/components/Menus/index.js +0 -1
- package/dist/cjs/hooks/use-menus.js +5 -2
- package/dist/cjs/index.js +1 -0
- package/dist/es/components/InsertTableDialog.js +100 -0
- package/dist/es/components/Menus/Menus.js +101 -12
- package/dist/es/components/Menus/Submenu.js +37 -22
- package/dist/es/components/Menus/index.js +0 -1
- package/dist/es/hooks/use-menus.js +5 -2
- package/dist/es/index.js +1 -0
- package/dist/types/components/InsertTableDialog.d.ts +22 -0
- package/dist/types/components/Menus/Menus.d.ts +22 -2
- package/dist/types/components/Menus/Submenu.d.ts +3 -4
- package/dist/types/components/Menus/index.d.ts +0 -1
- package/dist/types/hooks/use-menus.d.ts +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/menus.d.ts +11 -7
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -14,13 +14,38 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
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
|
+
};
|
|
17
40
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
42
|
};
|
|
20
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.Menus = void 0;
|
|
22
|
-
const react_1 =
|
|
44
|
+
exports.ColumnChangeWarningDialog = exports.Label = exports.Block = exports.BlockItem = exports.StyleBlock = exports.ListContainer = exports.bulletListContextMenu = exports.orderedListContextMenu = exports.Menus = void 0;
|
|
45
|
+
const react_1 = __importStar(require("react"));
|
|
23
46
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
47
|
+
const Dialog_1 = require("../Dialog");
|
|
48
|
+
const InsertTableDialog_1 = require("../InsertTableDialog");
|
|
24
49
|
const Submenu_1 = require("./Submenu");
|
|
25
50
|
const MenusContainer = styled_components_1.default.div `
|
|
26
51
|
display: flex;
|
|
@@ -44,16 +69,104 @@ const MenuContainer = styled_components_1.default.div `
|
|
|
44
69
|
}
|
|
45
70
|
`;
|
|
46
71
|
const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
};
|
|
78
|
+
return (react_1.default.createElement(MenusContainer, { ref: innerRef },
|
|
79
|
+
menus.map((menu, index) => {
|
|
80
|
+
return (react_1.default.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.isEnabled },
|
|
81
|
+
react_1.default.createElement(MenuHeading, { onMouseDown: (e) => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
handleClick([index]);
|
|
84
|
+
}, isOpen: menu.isOpen },
|
|
85
|
+
react_1.default.createElement(Submenu_1.Text, null, menu.label)),
|
|
86
|
+
menu.isEnabled && menu.isOpen && menu.submenu && (react_1.default.createElement(Submenu_1.SubmenusContainer, null, menu.submenu.map((submenu, sindex) => {
|
|
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 }));
|
|
98
|
+
})))));
|
|
99
|
+
}),
|
|
100
|
+
react_1.default.createElement(exports.ColumnChangeWarningDialog, { isOpen: !!columnMenu, primaryAction: () => {
|
|
101
|
+
if (columnMenu === null || columnMenu === void 0 ? void 0 : columnMenu.run) {
|
|
102
|
+
columnMenu.run();
|
|
103
|
+
setColumnMenu(undefined);
|
|
104
|
+
}
|
|
105
|
+
}, secondaryAction: () => setColumnMenu(undefined) }),
|
|
106
|
+
openDialog && (react_1.default.createElement(InsertTableDialog_1.InsertTableDialog, { run: (tableConfig) => handleClick(indices, tableConfig), open: openDialog, onClose: toggleDialog }))));
|
|
58
107
|
};
|
|
59
108
|
exports.Menus = Menus;
|
|
109
|
+
exports.orderedListContextMenu = [
|
|
110
|
+
{ items: ['1.', '2.', '3.'], type: 'order' },
|
|
111
|
+
{ items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
|
|
112
|
+
{ items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
|
|
113
|
+
{ items: ['I.', 'II.', 'III.'], type: 'roman-upper' },
|
|
114
|
+
{ items: ['i.', 'ii.', 'iii.'], type: 'roman-lower' },
|
|
115
|
+
];
|
|
116
|
+
exports.bulletListContextMenu = [
|
|
117
|
+
{ items: ['•', '•', '•'], type: 'bullet' },
|
|
118
|
+
{ items: ['-', '-', '-'], type: 'simple' },
|
|
119
|
+
];
|
|
120
|
+
exports.ListContainer = styled_components_1.default.div `
|
|
121
|
+
padding: ${(props) => props.theme.grid.unit * 4}px;
|
|
122
|
+
display: grid;
|
|
123
|
+
grid-template-columns:
|
|
124
|
+
${(props) => props.theme.grid.unit * 21}px
|
|
125
|
+
${(props) => props.theme.grid.unit * 21}px;
|
|
126
|
+
gap: 6px;
|
|
127
|
+
`;
|
|
128
|
+
exports.StyleBlock = styled_components_1.default.div `
|
|
129
|
+
border: 1px solid ${(props) => props.theme.colors.border.tertiary};
|
|
130
|
+
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
row-gap: ${(props) => props.theme.grid.unit * 2}px;
|
|
135
|
+
|
|
136
|
+
&:hover {
|
|
137
|
+
background: ${(props) => props.theme.colors.button.default.border.hover};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&:active {
|
|
141
|
+
border-color: ${(props) => props.theme.colors.border.primary};
|
|
142
|
+
}
|
|
143
|
+
`;
|
|
144
|
+
exports.BlockItem = styled_components_1.default.div `
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
gap: 6px;
|
|
148
|
+
`;
|
|
149
|
+
exports.Block = styled_components_1.default.div `
|
|
150
|
+
height: 3px;
|
|
151
|
+
width: ${(props) => props.theme.grid.unit * 14}px;
|
|
152
|
+
background: ${(props) => props.theme.colors.border.tertiary};
|
|
153
|
+
`;
|
|
154
|
+
exports.Label = styled_components_1.default.div `
|
|
155
|
+
font-family: Lato, serif;
|
|
156
|
+
font-size: ${(props) => props.theme.font.size.small};
|
|
157
|
+
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
158
|
+
line-height: ${(props) => props.theme.font.lineHeight.small};
|
|
159
|
+
font-style: normal;
|
|
160
|
+
color: ${(props) => (props.hide && 'white') || 'initial'};
|
|
161
|
+
`;
|
|
162
|
+
const ColumnChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (react_1.default.createElement(Dialog_1.Dialog, { isOpen: isOpen, category: Dialog_1.Category.confirmation, header: "This change can't be tracked", message: "This column action won't be marked as chnage. Do you want to continue?", actions: {
|
|
163
|
+
primary: {
|
|
164
|
+
action: primaryAction,
|
|
165
|
+
title: 'Ok',
|
|
166
|
+
},
|
|
167
|
+
secondary: {
|
|
168
|
+
action: secondaryAction,
|
|
169
|
+
title: 'Cancel',
|
|
170
|
+
},
|
|
171
|
+
} }));
|
|
172
|
+
exports.ColumnChangeWarningDialog = ColumnChangeWarningDialog;
|
|
@@ -18,16 +18,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.Submenu = exports.
|
|
21
|
+
exports.Submenu = exports.SubmenusContainer = exports.Text = void 0;
|
|
22
22
|
const react_1 = __importDefault(require("react"));
|
|
23
23
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
24
24
|
const menus_1 = require("../../lib/menus");
|
|
25
25
|
const icons_1 = require("../icons");
|
|
26
|
+
const Menus_1 = require("./Menus");
|
|
26
27
|
const Shortcut_1 = require("./Shortcut");
|
|
27
28
|
exports.Text = styled_components_1.default.div `
|
|
28
29
|
flex: 1 0 auto;
|
|
29
30
|
`;
|
|
30
|
-
|
|
31
|
+
const SubmenuContainer = styled_components_1.default.div `
|
|
31
32
|
position: relative;
|
|
32
33
|
`;
|
|
33
34
|
exports.SubmenusContainer = styled_components_1.default.div `
|
|
@@ -53,7 +54,7 @@ exports.SubmenusContainer = styled_components_1.default.div `
|
|
|
53
54
|
top: 8px;
|
|
54
55
|
}
|
|
55
56
|
`;
|
|
56
|
-
|
|
57
|
+
const NestedSubmenusContainer = (0, styled_components_1.default)(exports.SubmenusContainer) `
|
|
57
58
|
top: 0;
|
|
58
59
|
left: 100%;
|
|
59
60
|
`;
|
|
@@ -90,32 +91,45 @@ const Container = styled_components_1.default.div `
|
|
|
90
91
|
}
|
|
91
92
|
`;
|
|
92
93
|
const activeContent = (menu) => (menu.isActive ? '✓' : '');
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
e.preventDefault();
|
|
99
|
-
handleClick([]);
|
|
100
|
-
} },
|
|
101
|
-
react_1.default.createElement(Active, null, activeContent(menu)),
|
|
102
|
-
react_1.default.createElement(exports.Text, null, menu.label),
|
|
103
|
-
menu.submenu && react_1.default.createElement(Arrow, null),
|
|
104
|
-
menu.shortcut && react_1.default.createElement(Shortcut_1.Shortcut, { shortcut: menu.shortcut })));
|
|
105
|
-
};
|
|
106
|
-
exports.SubmenuLabel = SubmenuLabel;
|
|
107
|
-
const Submenu = ({ menu, handleClick }) => {
|
|
94
|
+
const isColumnMenu = (menu) => (menu.role !== 'separator' &&
|
|
95
|
+
menu.id === 'format-table-add-column-before') ||
|
|
96
|
+
menu.id === 'format-table-add-column-after' ||
|
|
97
|
+
menu.id === 'format-table-delete-column';
|
|
98
|
+
const Submenu = ({ menu, handleClick, setColumnMenu, }) => {
|
|
108
99
|
if ((0, menus_1.isMenuSeparator)(menu)) {
|
|
109
100
|
return react_1.default.createElement(Separator, null);
|
|
110
101
|
}
|
|
111
|
-
if (menu.
|
|
112
|
-
return react_1.default.createElement(menu.
|
|
102
|
+
if (!menu.submenu && !menu.options) {
|
|
103
|
+
return (react_1.default.createElement(Container, { isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled', onMouseDown: (e) => {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
handleClick([]);
|
|
106
|
+
} },
|
|
107
|
+
react_1.default.createElement(Active, null, activeContent(menu)),
|
|
108
|
+
react_1.default.createElement(exports.Text, null, menu.label),
|
|
109
|
+
menu.shortcut && react_1.default.createElement(Shortcut_1.Shortcut, { shortcut: menu.shortcut })));
|
|
113
110
|
}
|
|
114
|
-
if (
|
|
115
|
-
|
|
111
|
+
if (menu.options) {
|
|
112
|
+
const styles = menu.id === 'bullet-list-context-menu'
|
|
113
|
+
? Menus_1.bulletListContextMenu
|
|
114
|
+
: Menus_1.orderedListContextMenu;
|
|
115
|
+
return (react_1.default.createElement(Menus_1.ListContainer, null, styles.map((style, index) => (react_1.default.createElement(Menus_1.StyleBlock, { key: index, onClick: () => {
|
|
116
|
+
menu.options && menu.options[style.type]();
|
|
117
|
+
handleClick([-1, -1]);
|
|
118
|
+
} }, style.items.map((style, index) => (react_1.default.createElement(Menus_1.BlockItem, { key: index },
|
|
119
|
+
react_1.default.createElement(Menus_1.Label, { hide: style === '-' }, style),
|
|
120
|
+
react_1.default.createElement(Menus_1.Block, null)))))))));
|
|
116
121
|
}
|
|
117
|
-
return (react_1.default.createElement(
|
|
118
|
-
react_1.default.createElement(
|
|
119
|
-
|
|
122
|
+
return (react_1.default.createElement(SubmenuContainer, null,
|
|
123
|
+
react_1.default.createElement(Container, { onMouseDown: (e) => {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
handleClick([]);
|
|
126
|
+
}, isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled' },
|
|
127
|
+
react_1.default.createElement(Active, null, activeContent(menu)),
|
|
128
|
+
react_1.default.createElement(exports.Text, null, menu.label),
|
|
129
|
+
menu.submenu && react_1.default.createElement(Arrow, null),
|
|
130
|
+
menu.shortcut && react_1.default.createElement(Shortcut_1.Shortcut, { shortcut: menu.shortcut })),
|
|
131
|
+
menu.submenu && menu.isOpen && (react_1.default.createElement(NestedSubmenusContainer, null, menu.submenu.map((submenu, index) => (react_1.default.createElement(exports.Submenu, { key: `menu-${index}`, menu: submenu, handleClick: (i) => isColumnMenu(submenu) && setColumnMenu
|
|
132
|
+
? setColumnMenu(submenu)
|
|
133
|
+
: handleClick([index, ...i]) })))))));
|
|
120
134
|
};
|
|
121
135
|
exports.Submenu = Submenu;
|
|
@@ -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) {
|
|
@@ -67,6 +67,9 @@ const useMenus = (menus) => {
|
|
|
67
67
|
const index = indices[depth];
|
|
68
68
|
setPointer(transformPointer(depth, index));
|
|
69
69
|
}
|
|
70
|
+
if (menu.options) {
|
|
71
|
+
setPointer([-1, -1, -1]);
|
|
72
|
+
}
|
|
70
73
|
}, [state]);
|
|
71
74
|
const ref = (0, react_1.useRef)(null);
|
|
72
75
|
(0, react_1.useEffect)(() => {
|
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/Resizer"), exports);
|
|
@@ -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
|
+
};
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import React from 'react';
|
|
16
|
+
import React, { useState } from 'react';
|
|
17
17
|
import styled from 'styled-components';
|
|
18
|
+
import { Category, Dialog } from '../Dialog';
|
|
19
|
+
import { InsertTableDialog } from '../InsertTableDialog';
|
|
18
20
|
import { Submenu, SubmenusContainer, Text } from './Submenu';
|
|
19
21
|
const MenusContainer = styled.div `
|
|
20
22
|
display: flex;
|
|
@@ -38,15 +40,102 @@ const MenuContainer = styled.div `
|
|
|
38
40
|
}
|
|
39
41
|
`;
|
|
40
42
|
export const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
const [columnMenu, setColumnMenu] = useState(undefined);
|
|
44
|
+
const [openDialog, setOpenDialog] = useState(false);
|
|
45
|
+
const [indices, setIndices] = useState([]);
|
|
46
|
+
const toggleDialog = () => {
|
|
47
|
+
setOpenDialog(!openDialog);
|
|
48
|
+
};
|
|
49
|
+
return (React.createElement(MenusContainer, { ref: innerRef },
|
|
50
|
+
menus.map((menu, index) => {
|
|
51
|
+
return (React.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.isEnabled },
|
|
52
|
+
React.createElement(MenuHeading, { onMouseDown: (e) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
handleClick([index]);
|
|
55
|
+
}, isOpen: menu.isOpen },
|
|
56
|
+
React.createElement(Text, null, menu.label)),
|
|
57
|
+
menu.isEnabled && menu.isOpen && menu.submenu && (React.createElement(SubmenusContainer, null, menu.submenu.map((submenu, sindex) => {
|
|
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 }));
|
|
69
|
+
})))));
|
|
70
|
+
}),
|
|
71
|
+
React.createElement(ColumnChangeWarningDialog, { isOpen: !!columnMenu, primaryAction: () => {
|
|
72
|
+
if (columnMenu === null || columnMenu === void 0 ? void 0 : columnMenu.run) {
|
|
73
|
+
columnMenu.run();
|
|
74
|
+
setColumnMenu(undefined);
|
|
75
|
+
}
|
|
76
|
+
}, secondaryAction: () => setColumnMenu(undefined) }),
|
|
77
|
+
openDialog && (React.createElement(InsertTableDialog, { run: (tableConfig) => handleClick(indices, tableConfig), open: openDialog, onClose: toggleDialog }))));
|
|
52
78
|
};
|
|
79
|
+
export const orderedListContextMenu = [
|
|
80
|
+
{ items: ['1.', '2.', '3.'], type: 'order' },
|
|
81
|
+
{ items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
|
|
82
|
+
{ items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
|
|
83
|
+
{ items: ['I.', 'II.', 'III.'], type: 'roman-upper' },
|
|
84
|
+
{ items: ['i.', 'ii.', 'iii.'], type: 'roman-lower' },
|
|
85
|
+
];
|
|
86
|
+
export const bulletListContextMenu = [
|
|
87
|
+
{ items: ['•', '•', '•'], type: 'bullet' },
|
|
88
|
+
{ items: ['-', '-', '-'], type: 'simple' },
|
|
89
|
+
];
|
|
90
|
+
export const ListContainer = styled.div `
|
|
91
|
+
padding: ${(props) => props.theme.grid.unit * 4}px;
|
|
92
|
+
display: grid;
|
|
93
|
+
grid-template-columns:
|
|
94
|
+
${(props) => props.theme.grid.unit * 21}px
|
|
95
|
+
${(props) => props.theme.grid.unit * 21}px;
|
|
96
|
+
gap: 6px;
|
|
97
|
+
`;
|
|
98
|
+
export const StyleBlock = styled.div `
|
|
99
|
+
border: 1px solid ${(props) => props.theme.colors.border.tertiary};
|
|
100
|
+
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: column;
|
|
104
|
+
row-gap: ${(props) => props.theme.grid.unit * 2}px;
|
|
105
|
+
|
|
106
|
+
&:hover {
|
|
107
|
+
background: ${(props) => props.theme.colors.button.default.border.hover};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&:active {
|
|
111
|
+
border-color: ${(props) => props.theme.colors.border.primary};
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
export const BlockItem = styled.div `
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: 6px;
|
|
118
|
+
`;
|
|
119
|
+
export const Block = styled.div `
|
|
120
|
+
height: 3px;
|
|
121
|
+
width: ${(props) => props.theme.grid.unit * 14}px;
|
|
122
|
+
background: ${(props) => props.theme.colors.border.tertiary};
|
|
123
|
+
`;
|
|
124
|
+
export const Label = styled.div `
|
|
125
|
+
font-family: Lato, serif;
|
|
126
|
+
font-size: ${(props) => props.theme.font.size.small};
|
|
127
|
+
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
128
|
+
line-height: ${(props) => props.theme.font.lineHeight.small};
|
|
129
|
+
font-style: normal;
|
|
130
|
+
color: ${(props) => (props.hide && 'white') || 'initial'};
|
|
131
|
+
`;
|
|
132
|
+
export const ColumnChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: "This change can't be tracked", message: "This column action won't be marked as chnage. Do you want to continue?", actions: {
|
|
133
|
+
primary: {
|
|
134
|
+
action: primaryAction,
|
|
135
|
+
title: 'Ok',
|
|
136
|
+
},
|
|
137
|
+
secondary: {
|
|
138
|
+
action: secondaryAction,
|
|
139
|
+
title: 'Cancel',
|
|
140
|
+
},
|
|
141
|
+
} }));
|
|
@@ -17,11 +17,12 @@ import React from 'react';
|
|
|
17
17
|
import styled from 'styled-components';
|
|
18
18
|
import { isMenuSeparator } from '../../lib/menus';
|
|
19
19
|
import { TriangleCollapsedIcon } from '../icons';
|
|
20
|
+
import { Block, BlockItem, bulletListContextMenu, Label, ListContainer, orderedListContextMenu, StyleBlock, } from './Menus';
|
|
20
21
|
import { Shortcut } from './Shortcut';
|
|
21
22
|
export const Text = styled.div `
|
|
22
23
|
flex: 1 0 auto;
|
|
23
24
|
`;
|
|
24
|
-
|
|
25
|
+
const SubmenuContainer = styled.div `
|
|
25
26
|
position: relative;
|
|
26
27
|
`;
|
|
27
28
|
export const SubmenusContainer = styled.div `
|
|
@@ -47,7 +48,7 @@ export const SubmenusContainer = styled.div `
|
|
|
47
48
|
top: 8px;
|
|
48
49
|
}
|
|
49
50
|
`;
|
|
50
|
-
|
|
51
|
+
const NestedSubmenusContainer = styled(SubmenusContainer) `
|
|
51
52
|
top: 0;
|
|
52
53
|
left: 100%;
|
|
53
54
|
`;
|
|
@@ -84,30 +85,44 @@ const Container = styled.div `
|
|
|
84
85
|
}
|
|
85
86
|
`;
|
|
86
87
|
const activeContent = (menu) => (menu.isActive ? '✓' : '');
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
handleClick([]);
|
|
94
|
-
} },
|
|
95
|
-
React.createElement(Active, null, activeContent(menu)),
|
|
96
|
-
React.createElement(Text, null, menu.label),
|
|
97
|
-
menu.submenu && React.createElement(Arrow, null),
|
|
98
|
-
menu.shortcut && React.createElement(Shortcut, { shortcut: menu.shortcut })));
|
|
99
|
-
};
|
|
100
|
-
export const Submenu = ({ menu, handleClick }) => {
|
|
88
|
+
const isColumnMenu = (menu) => (menu.role !== 'separator' &&
|
|
89
|
+
menu.id === 'format-table-add-column-before') ||
|
|
90
|
+
menu.id === 'format-table-add-column-after' ||
|
|
91
|
+
menu.id === 'format-table-delete-column';
|
|
92
|
+
export const Submenu = ({ menu, handleClick, setColumnMenu, }) => {
|
|
101
93
|
if (isMenuSeparator(menu)) {
|
|
102
94
|
return React.createElement(Separator, null);
|
|
103
95
|
}
|
|
104
|
-
if (menu.
|
|
105
|
-
return React.createElement(menu.
|
|
96
|
+
if (!menu.submenu && !menu.options) {
|
|
97
|
+
return (React.createElement(Container, { isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled', onMouseDown: (e) => {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
handleClick([]);
|
|
100
|
+
} },
|
|
101
|
+
React.createElement(Active, null, activeContent(menu)),
|
|
102
|
+
React.createElement(Text, null, menu.label),
|
|
103
|
+
menu.shortcut && React.createElement(Shortcut, { shortcut: menu.shortcut })));
|
|
106
104
|
}
|
|
107
|
-
if (
|
|
108
|
-
|
|
105
|
+
if (menu.options) {
|
|
106
|
+
const styles = menu.id === 'bullet-list-context-menu'
|
|
107
|
+
? bulletListContextMenu
|
|
108
|
+
: orderedListContextMenu;
|
|
109
|
+
return (React.createElement(ListContainer, null, styles.map((style, index) => (React.createElement(StyleBlock, { key: index, onClick: () => {
|
|
110
|
+
menu.options && menu.options[style.type]();
|
|
111
|
+
handleClick([-1, -1]);
|
|
112
|
+
} }, style.items.map((style, index) => (React.createElement(BlockItem, { key: index },
|
|
113
|
+
React.createElement(Label, { hide: style === '-' }, style),
|
|
114
|
+
React.createElement(Block, null)))))))));
|
|
109
115
|
}
|
|
110
116
|
return (React.createElement(SubmenuContainer, null,
|
|
111
|
-
React.createElement(
|
|
112
|
-
|
|
117
|
+
React.createElement(Container, { onMouseDown: (e) => {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
handleClick([]);
|
|
120
|
+
}, isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled' },
|
|
121
|
+
React.createElement(Active, null, activeContent(menu)),
|
|
122
|
+
React.createElement(Text, null, menu.label),
|
|
123
|
+
menu.submenu && React.createElement(Arrow, null),
|
|
124
|
+
menu.shortcut && React.createElement(Shortcut, { shortcut: menu.shortcut })),
|
|
125
|
+
menu.submenu && menu.isOpen && (React.createElement(NestedSubmenusContainer, null, menu.submenu.map((submenu, index) => (React.createElement(Submenu, { key: `menu-${index}`, menu: submenu, handleClick: (i) => isColumnMenu(submenu) && setColumnMenu
|
|
126
|
+
? setColumnMenu(submenu)
|
|
127
|
+
: handleClick([index, ...i]) })))))));
|
|
113
128
|
};
|
|
@@ -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) {
|
|
@@ -64,6 +64,9 @@ export const useMenus = (menus) => {
|
|
|
64
64
|
const index = indices[depth];
|
|
65
65
|
setPointer(transformPointer(depth, index));
|
|
66
66
|
}
|
|
67
|
+
if (menu.options) {
|
|
68
|
+
setPointer([-1, -1, -1]);
|
|
69
|
+
}
|
|
67
70
|
}, [state]);
|
|
68
71
|
const ref = useRef(null);
|
|
69
72
|
useEffect(() => {
|
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/Resizer';
|
|
@@ -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,31 @@
|
|
|
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
|
+
export declare const orderedListContextMenu: {
|
|
25
|
+
items: string[];
|
|
26
|
+
type: string;
|
|
27
|
+
}[];
|
|
28
|
+
export declare const bulletListContextMenu: {
|
|
29
|
+
items: string[];
|
|
30
|
+
type: string;
|
|
31
|
+
}[];
|
|
32
|
+
export declare const ListContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
33
|
+
export declare const StyleBlock: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
34
|
+
export declare const BlockItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
35
|
+
export declare const Block: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
36
|
+
export declare const Label: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
37
|
+
hide?: boolean | undefined;
|
|
38
|
+
}, never>;
|
|
39
|
+
export declare const ColumnChangeWarningDialog: React.FC<{
|
|
40
|
+
isOpen: boolean;
|
|
41
|
+
primaryAction: () => void;
|
|
42
|
+
secondaryAction: () => void;
|
|
43
|
+
}>;
|
|
24
44
|
export {};
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
import React from 'react';
|
|
17
17
|
import { Menu, MenuSeparator } from '../../lib/menus';
|
|
18
18
|
export declare const Text: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
19
|
-
export declare const SubmenuContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
20
19
|
export declare const SubmenusContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
21
|
-
|
|
22
|
-
export interface SubmenuProps {
|
|
20
|
+
interface SubmenuProps {
|
|
23
21
|
menu: Menu | MenuSeparator;
|
|
24
22
|
handleClick: (position: number[]) => void;
|
|
23
|
+
setColumnMenu?: React.Dispatch<React.SetStateAction<undefined | Menu>>;
|
|
25
24
|
}
|
|
26
|
-
export declare const SubmenuLabel: React.FC<SubmenuProps>;
|
|
27
25
|
export declare const Submenu: React.FC<SubmenuProps>;
|
|
26
|
+
export {};
|
|
@@ -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
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './components/RadioButton';
|
|
|
21
21
|
export * from './components/AutoSaveInput';
|
|
22
22
|
export * from './components/Avatar';
|
|
23
23
|
export * from './components/Dialog';
|
|
24
|
+
export * from './components/InsertTableDialog';
|
|
24
25
|
export * from './components/Checkbox';
|
|
25
26
|
export * from './components/Form';
|
|
26
27
|
export * from './components/Resizer';
|
|
@@ -13,25 +13,29 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
16
|
+
import { ManuscriptTransaction } from '@manuscripts/transform';
|
|
17
|
+
export type Dispatch = (tr: ManuscriptTransaction) => void;
|
|
17
18
|
export interface MenuShortcut {
|
|
18
19
|
mac: string;
|
|
19
20
|
pc: string;
|
|
20
21
|
}
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
export type TableConfig = {
|
|
23
|
+
numberOfColumns: number;
|
|
24
|
+
numberOfRows: number;
|
|
25
|
+
includeHeader: boolean;
|
|
26
|
+
};
|
|
25
27
|
export interface MenuSpec {
|
|
26
28
|
id: string;
|
|
27
29
|
label: string;
|
|
28
30
|
role?: string;
|
|
29
31
|
shortcut?: MenuShortcut;
|
|
30
|
-
component?: React.FC<MenuComponentProps>;
|
|
31
32
|
isActive?: boolean;
|
|
32
33
|
isEnabled: boolean;
|
|
33
|
-
run?: () => void;
|
|
34
|
+
run?: (tableConfig?: TableConfig) => void;
|
|
34
35
|
submenu?: (MenuSpec | MenuSeparator)[];
|
|
36
|
+
options?: {
|
|
37
|
+
[key: string]: () => void;
|
|
38
|
+
};
|
|
35
39
|
}
|
|
36
40
|
export interface Menu extends MenuSpec {
|
|
37
41
|
isOpen: boolean;
|
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": "2.0.7
|
|
4
|
+
"version": "2.0.7",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@manuscripts/json-schema": "2.2.10",
|
|
36
|
-
"@manuscripts/transform": "2.3.
|
|
36
|
+
"@manuscripts/transform": "2.3.25",
|
|
37
37
|
"@reach/tabs": "^0.18.0",
|
|
38
38
|
"date-fns": "^2.29.3",
|
|
39
39
|
"formik": "^2.2.9",
|