@manuscripts/style-guide 1.5.0-LEAN-3083 → 1.5.0-LEAN-2992
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/AffiliationsList.js +43 -0
- package/dist/cjs/components/AuthorsContainer.js +71 -0
- package/dist/cjs/components/AuthorsList/Author.js +99 -0
- package/dist/cjs/components/AuthorsList/AuthorsList.js +52 -0
- package/dist/cjs/components/AuthorsList/index.js +32 -0
- package/dist/cjs/components/Menus/Menus.js +62 -0
- package/dist/cjs/components/Menus/Shortcut.js +64 -0
- package/dist/cjs/components/Menus/Submenu.js +119 -0
- package/dist/cjs/components/Menus/index.js +17 -0
- package/dist/cjs/hooks/use-menus.js +89 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/lib/menus.js +22 -0
- package/dist/es/components/AffiliationsList.js +36 -0
- package/dist/es/components/AuthorsContainer.js +41 -0
- package/dist/es/components/AuthorsList/Author.js +69 -0
- package/dist/es/components/AuthorsList/AuthorsList.js +45 -0
- package/dist/es/components/AuthorsList/index.js +16 -0
- package/dist/es/components/Menus/Menus.js +55 -0
- package/dist/es/components/Menus/Shortcut.js +57 -0
- package/dist/es/components/Menus/Submenu.js +112 -0
- package/dist/es/components/Menus/index.js +1 -0
- package/dist/es/hooks/use-menus.js +85 -0
- package/dist/es/index.js +6 -0
- package/dist/es/lib/menus.js +18 -0
- package/dist/types/components/AffiliationsList.d.ts +22 -0
- package/dist/types/components/AuthorsContainer.d.ts +25 -0
- package/dist/types/components/AuthorsList/Author.d.ts +29 -0
- package/dist/types/components/AuthorsList/AuthorsList.d.ts +28 -0
- package/dist/types/components/AuthorsList/index.d.ts +16 -0
- package/dist/types/components/Menus/Menus.d.ts +24 -0
- package/dist/types/components/Menus/Shortcut.d.ts +23 -0
- package/dist/types/components/Menus/Submenu.d.ts +25 -0
- package/dist/types/components/Menus/index.d.ts +1 -0
- package/dist/types/hooks/use-menus.d.ts +7 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/lib/menus.d.ts +38 -0
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.AffiliationsList = void 0;
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
24
|
+
const formatAddress_1 = __importDefault(require("../lib/formatAddress"));
|
|
25
|
+
const Container = styled_components_1.default.table `
|
|
26
|
+
border-collapse: collapse;
|
|
27
|
+
font: inherit;
|
|
28
|
+
color: ${(props) => props.theme.colors.text.secondary};
|
|
29
|
+
margin-top: ${(props) => props.theme.grid.unit * 4}px;
|
|
30
|
+
`;
|
|
31
|
+
const Header = styled_components_1.default.th `
|
|
32
|
+
font-weight: ${(props) => props.theme.font.weight.normal}
|
|
33
|
+
padding: 0 4px 0 0;
|
|
34
|
+
vertical-align: top;
|
|
35
|
+
`;
|
|
36
|
+
const Body = styled_components_1.default.td `
|
|
37
|
+
padding: 0;
|
|
38
|
+
`;
|
|
39
|
+
const AffiliationsList = ({ affiliations, }) => (react_1.default.createElement(Container, null,
|
|
40
|
+
react_1.default.createElement("tbody", null, Array.from(affiliations.values()).map((affiliation, index) => (react_1.default.createElement("tr", { key: affiliation._id },
|
|
41
|
+
react_1.default.createElement(Header, null, index + 1),
|
|
42
|
+
react_1.default.createElement(Body, null, (0, formatAddress_1.default)(affiliation))))))));
|
|
43
|
+
exports.AffiliationsList = AffiliationsList;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2021 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.AuthorsContainer = void 0;
|
|
45
|
+
const react_1 = __importStar(require("react"));
|
|
46
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
47
|
+
const AffiliationsList_1 = require("./AffiliationsList");
|
|
48
|
+
const AuthorsList_1 = require("./AuthorsList");
|
|
49
|
+
const AuthorsContainer = ({ authorData, showEditButton, startEditing, selectAuthor, disableEditButton, }) => {
|
|
50
|
+
const authorAffiliations = (0, react_1.useMemo)(() => authorData.authors.filter((author) => author.role === 'author'), [authorData.authors]);
|
|
51
|
+
const isThereJointContributor = (0, react_1.useMemo)(() => authorData.authors.find((contributor) => contributor.isJointContributor), [authorData.authors]);
|
|
52
|
+
return (react_1.default.createElement(Container, { "data-cy": 'author-container' },
|
|
53
|
+
react_1.default.createElement(AuthorsList_1.AuthorsList, { authors: authorAffiliations, authorAffiliations: authorData.authorAffiliations, startEditing: startEditing, showEditButton: showEditButton, selectAuthor: selectAuthor, disableEditButton: disableEditButton }),
|
|
54
|
+
react_1.default.createElement(AffiliationsList_1.AffiliationsList, { affiliations: authorData.affiliations }),
|
|
55
|
+
isThereJointContributor && (react_1.default.createElement(LegendWrapper, null,
|
|
56
|
+
react_1.default.createElement(Legend, null, "\u2020"),
|
|
57
|
+
"These authors contributed equally to this work."))));
|
|
58
|
+
};
|
|
59
|
+
exports.AuthorsContainer = AuthorsContainer;
|
|
60
|
+
const Container = styled_components_1.default.div `
|
|
61
|
+
margin-top: ${(props) => props.theme.grid.unit * 4}px;
|
|
62
|
+
`;
|
|
63
|
+
const LegendWrapper = styled_components_1.default.p `
|
|
64
|
+
margin: ${(props) => props.theme.grid.unit * 4}px 0 0 0;
|
|
65
|
+
`;
|
|
66
|
+
const Legend = styled_components_1.default.span `
|
|
67
|
+
display: inline-block;
|
|
68
|
+
font-size: 0.75em;
|
|
69
|
+
line-height: 1;
|
|
70
|
+
vertical-align: top;
|
|
71
|
+
`;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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.Author = void 0;
|
|
45
|
+
const react_1 = __importDefault(require("react"));
|
|
46
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
47
|
+
const AuthorName_1 = require("../AuthorName");
|
|
48
|
+
const AuthorNotes = styled_components_1.default.span `
|
|
49
|
+
display: inline-block;
|
|
50
|
+
font-size: 0.75em;
|
|
51
|
+
line-height: 1;
|
|
52
|
+
vertical-align: top;
|
|
53
|
+
`;
|
|
54
|
+
const LinkSharedStyles = (0, styled_components_1.css) `
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
color: inherit;
|
|
57
|
+
outline: none;
|
|
58
|
+
|
|
59
|
+
&:not(:disabled) {
|
|
60
|
+
&:hover,
|
|
61
|
+
&:focus {
|
|
62
|
+
&,
|
|
63
|
+
span {
|
|
64
|
+
color: ${(props) => props.theme.colors.text.tertiary};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
const AuthorAffiliation = styled_components_1.default.span `
|
|
70
|
+
${LinkSharedStyles}
|
|
71
|
+
`;
|
|
72
|
+
const AuthorsContainer = styled_components_1.default.button `
|
|
73
|
+
display: inline-flex;
|
|
74
|
+
background: transparent;
|
|
75
|
+
border: 0;
|
|
76
|
+
font-size: 1rem;
|
|
77
|
+
${LinkSharedStyles}
|
|
78
|
+
|
|
79
|
+
&:not(:disabled) {
|
|
80
|
+
&:hover {
|
|
81
|
+
text-decoration: underline;
|
|
82
|
+
cursor: pointer !important;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
const Author = ({ author, affiliations, jointFirstAuthor, startEditing, selectAuthor, showEditButton, disableEditButton, }) => (react_1.default.createElement("span", { key: author._id },
|
|
87
|
+
showEditButton ? (react_1.default.createElement(AuthorsContainer, { disabled: disableEditButton, onClick: (e) => {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
startEditing && startEditing();
|
|
90
|
+
selectAuthor && selectAuthor(author);
|
|
91
|
+
} },
|
|
92
|
+
react_1.default.createElement(AuthorName_1.AuthorName, { name: author.bibliographicName, email: (author.isCorresponding && author.email) || undefined }))) : (react_1.default.createElement(AuthorName_1.AuthorName, { name: author.bibliographicName, email: (author.isCorresponding && author.email) || undefined })),
|
|
93
|
+
affiliations && (react_1.default.createElement(AuthorNotes, null, affiliations.map((affiliation, index) => (react_1.default.createElement(react_1.default.Fragment, { key: affiliation.data._id },
|
|
94
|
+
!!index && ',',
|
|
95
|
+
react_1.default.createElement(AuthorAffiliation, null, affiliation.ordinal)))))),
|
|
96
|
+
author.isCorresponding && (react_1.default.createElement(AuthorNotes, { title: 'Corresponding author' }, "*")),
|
|
97
|
+
jointFirstAuthor && (react_1.default.createElement(AuthorNotes, { title: 'Joint contributor' }, "\u2020"))));
|
|
98
|
+
exports.Author = Author;
|
|
99
|
+
exports.default = exports.Author;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.AuthorsList = void 0;
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
24
|
+
const authors_1 = require("../../lib/authors");
|
|
25
|
+
const Button_1 = require("../Button");
|
|
26
|
+
const Author_1 = require("./Author");
|
|
27
|
+
const AuthorsContainer = styled_components_1.default.div `
|
|
28
|
+
align-items: center;
|
|
29
|
+
display: flex;
|
|
30
|
+
|
|
31
|
+
@media (min-width: 768px) {
|
|
32
|
+
& ${Button_1.PrimaryButton} {
|
|
33
|
+
display: ${(props) => (props.isEmpty ? 'initial' : 'none')};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&:hover ${Button_1.PrimaryButton} {
|
|
37
|
+
display: initial;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
const AuthorsActions = styled_components_1.default.div `
|
|
42
|
+
align-items: center;
|
|
43
|
+
display: flex;
|
|
44
|
+
margin-left: ${(props) => props.theme.grid.unit * 2}px;
|
|
45
|
+
`;
|
|
46
|
+
const AuthorsList = ({ authors, authorAffiliations, startEditing, showEditButton, disableEditButton, selectAuthor, }) => (react_1.default.createElement(AuthorsContainer, { isEmpty: !authors.length },
|
|
47
|
+
react_1.default.createElement("div", null, authors.map((author, index) => (react_1.default.createElement(react_1.default.Fragment, { key: author._id },
|
|
48
|
+
!!index && ', ',
|
|
49
|
+
react_1.default.createElement(Author_1.Author, { author: author, jointFirstAuthor: (0, authors_1.isJointFirstAuthor)(authors, index), affiliations: authorAffiliations.get(author._id), selectAuthor: selectAuthor, startEditing: startEditing, showEditButton: showEditButton, disableEditButton: disableEditButton }))))),
|
|
50
|
+
showEditButton && startEditing && (react_1.default.createElement(AuthorsActions, null,
|
|
51
|
+
react_1.default.createElement(Button_1.PrimaryButton, { mini: true, onClick: startEditing, className: 'edit_authors_button', disabled: disableEditButton }, "Edit Authors")))));
|
|
52
|
+
exports.AuthorsList = AuthorsList;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
__exportStar(require("./AuthorsList"), exports);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.Menus = void 0;
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const react_modal_1 = __importDefault(require("react-modal"));
|
|
24
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
25
|
+
const Submenu_1 = require("./Submenu");
|
|
26
|
+
react_modal_1.default.setAppElement('#root');
|
|
27
|
+
const MenusContainer = styled_components_1.default.div `
|
|
28
|
+
display: flex;
|
|
29
|
+
font-size: 14px;
|
|
30
|
+
`;
|
|
31
|
+
const MenuHeading = styled_components_1.default.div `
|
|
32
|
+
padding: 4px 8px;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
border: 1px solid transparent;
|
|
35
|
+
border-bottom: none;
|
|
36
|
+
`;
|
|
37
|
+
const MenuContainer = styled_components_1.default.div `
|
|
38
|
+
position: relative;
|
|
39
|
+
|
|
40
|
+
& ${MenuHeading} {
|
|
41
|
+
background-color: #fff;
|
|
42
|
+
color: ${(props) => (props.isEnabled ? '#353535' : '#e2e2e2')};
|
|
43
|
+
|
|
44
|
+
&:hover {
|
|
45
|
+
background-color: ${(props) => (props.isEnabled ? '#f2fbfc' : '#fff')};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
const Menus = ({ menus, innerRef, handleClick, }) => {
|
|
50
|
+
return (react_1.default.createElement(MenusContainer, { ref: innerRef }, menus.map((menu, index) => {
|
|
51
|
+
return (react_1.default.createElement(MenuContainer, { key: `menu-${index}`, isEnabled: menu.isEnabled },
|
|
52
|
+
react_1.default.createElement(MenuHeading, { onMouseDown: (e) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
handleClick([index]);
|
|
55
|
+
}, isOpen: menu.isOpen },
|
|
56
|
+
react_1.default.createElement(Submenu_1.Text, null, menu.label)),
|
|
57
|
+
menu.isEnabled && menu.isOpen && menu.submenu && (react_1.default.createElement(Submenu_1.SubmenusContainer, null, menu.submenu.map((submenu, sindex) => {
|
|
58
|
+
return (react_1.default.createElement(Submenu_1.Submenu, { key: `${index}-${sindex}`, menu: submenu, handleClick: (i) => handleClick([index, sindex, ...i]) }));
|
|
59
|
+
})))));
|
|
60
|
+
})));
|
|
61
|
+
};
|
|
62
|
+
exports.Menus = Menus;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.Shortcut = exports.ShortcutContainer = void 0;
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
24
|
+
const isMac = /Mac/.test(window.navigator.platform);
|
|
25
|
+
exports.ShortcutContainer = styled_components_1.default.div `
|
|
26
|
+
display: inline-flex;
|
|
27
|
+
color: #6e6e6e;
|
|
28
|
+
margin-left: 16px;
|
|
29
|
+
flex-shrink: 0;
|
|
30
|
+
justify-content: flex-end;
|
|
31
|
+
`;
|
|
32
|
+
const macModifiers = {
|
|
33
|
+
Option: '⌥',
|
|
34
|
+
CommandOrControl: '⌘',
|
|
35
|
+
Shift: '⇧',
|
|
36
|
+
};
|
|
37
|
+
const pcModifiers = {
|
|
38
|
+
Option: 'Alt',
|
|
39
|
+
CommandOrControl: 'Ctrl',
|
|
40
|
+
Shift: 'Shift',
|
|
41
|
+
};
|
|
42
|
+
const modifiers = isMac ? macModifiers : pcModifiers;
|
|
43
|
+
const system = isMac ? 'mac' : 'pc';
|
|
44
|
+
const separator = isMac ? '' : '-';
|
|
45
|
+
const Character = styled_components_1.default.span `
|
|
46
|
+
display: inline-block;
|
|
47
|
+
min-width: 1ch;
|
|
48
|
+
`;
|
|
49
|
+
const parts = (shortcut) => {
|
|
50
|
+
const nodes = [];
|
|
51
|
+
for (const part of shortcut[system].split('+')) {
|
|
52
|
+
const modifier = modifiers[part];
|
|
53
|
+
if (modifier) {
|
|
54
|
+
nodes.push(modifier);
|
|
55
|
+
nodes.push(separator);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
nodes.push(react_1.default.createElement(Character, { key: part }, part));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return nodes;
|
|
62
|
+
};
|
|
63
|
+
const Shortcut = ({ shortcut }) => (react_1.default.createElement(exports.ShortcutContainer, null, parts(shortcut)));
|
|
64
|
+
exports.Shortcut = Shortcut;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.Submenu = exports.SubmenusContainer = exports.Text = void 0;
|
|
22
|
+
const TriangleCollapsed_1 = __importDefault(require("@manuscripts/assets/react/TriangleCollapsed"));
|
|
23
|
+
const react_1 = __importDefault(require("react"));
|
|
24
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
25
|
+
const menus_1 = require("../../lib/menus");
|
|
26
|
+
const Shortcut_1 = require("./Shortcut");
|
|
27
|
+
exports.Text = styled_components_1.default.div `
|
|
28
|
+
flex: 1 0 auto;
|
|
29
|
+
`;
|
|
30
|
+
const SubmenuContainer = styled_components_1.default.div `
|
|
31
|
+
position: relative;
|
|
32
|
+
`;
|
|
33
|
+
exports.SubmenusContainer = styled_components_1.default.div `
|
|
34
|
+
background: #fff;
|
|
35
|
+
border: 1px solid #e2e2e2;
|
|
36
|
+
border-radius: 4px;
|
|
37
|
+
box-shadow: 0 4px 9px 0 rgba(84, 83, 83, 0.3);
|
|
38
|
+
color: #353535;
|
|
39
|
+
min-width: 150px;
|
|
40
|
+
max-height: 70vh;
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
padding: 4px 0;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
width: auto;
|
|
45
|
+
z-index: 10;
|
|
46
|
+
|
|
47
|
+
position: absolute;
|
|
48
|
+
|
|
49
|
+
&[data-placement='bottom-start'] {
|
|
50
|
+
border-top-left-radius: 0;
|
|
51
|
+
border-top-right-radius: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&[data-placement='right-start'] {
|
|
55
|
+
top: 8px;
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
const NestedSubmenusContainer = (0, styled_components_1.default)(exports.SubmenusContainer) `
|
|
59
|
+
top: 0;
|
|
60
|
+
left: 100%;
|
|
61
|
+
`;
|
|
62
|
+
const Separator = styled_components_1.default.div `
|
|
63
|
+
height: 0;
|
|
64
|
+
border-bottom: 1px solid #e2e2e2;
|
|
65
|
+
margin: 4px 0;
|
|
66
|
+
`;
|
|
67
|
+
const Active = styled_components_1.default.div `
|
|
68
|
+
width: 16px;
|
|
69
|
+
display: inline-flex;
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
align-items: center;
|
|
73
|
+
`;
|
|
74
|
+
const Arrow = (0, styled_components_1.default)(TriangleCollapsed_1.default) `
|
|
75
|
+
margin-left: 8px;
|
|
76
|
+
`;
|
|
77
|
+
const Container = styled_components_1.default.div `
|
|
78
|
+
align-items: center;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
display: flex;
|
|
81
|
+
padding: 8px 16px 8px 4px;
|
|
82
|
+
position: relative;
|
|
83
|
+
${(props) => props.isOpen && 'background: #f2fbfc;'}
|
|
84
|
+
|
|
85
|
+
&:hover {
|
|
86
|
+
background: #f2fbfc;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.disabled {
|
|
90
|
+
cursor: default;
|
|
91
|
+
opacity: 0.4;
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
const activeContent = (menu) => (menu.isActive ? '✓' : '');
|
|
95
|
+
const Submenu = ({ menu, handleClick }) => {
|
|
96
|
+
if ((0, menus_1.isMenuSeparator)(menu)) {
|
|
97
|
+
return react_1.default.createElement(Separator, null);
|
|
98
|
+
}
|
|
99
|
+
if (!menu.submenu) {
|
|
100
|
+
return (react_1.default.createElement(Container, { isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled', onMouseDown: (e) => {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
handleClick([]);
|
|
103
|
+
} },
|
|
104
|
+
react_1.default.createElement(Active, null, activeContent(menu)),
|
|
105
|
+
react_1.default.createElement(exports.Text, null, menu.label),
|
|
106
|
+
menu.shortcut && react_1.default.createElement(Shortcut_1.Shortcut, { shortcut: menu.shortcut })));
|
|
107
|
+
}
|
|
108
|
+
return (react_1.default.createElement(SubmenuContainer, null,
|
|
109
|
+
react_1.default.createElement(Container, { onMouseDown: (e) => {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
handleClick([]);
|
|
112
|
+
}, isOpen: menu.isOpen, className: menu.isEnabled ? '' : 'disabled' },
|
|
113
|
+
react_1.default.createElement(Active, null, activeContent(menu)),
|
|
114
|
+
react_1.default.createElement(exports.Text, null, menu.label),
|
|
115
|
+
menu.submenu && react_1.default.createElement(Arrow, null),
|
|
116
|
+
menu.shortcut && react_1.default.createElement(Shortcut_1.Shortcut, { shortcut: menu.shortcut })),
|
|
117
|
+
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) => handleClick([index, ...i]) })))))));
|
|
118
|
+
};
|
|
119
|
+
exports.Submenu = Submenu;
|
|
@@ -0,0 +1,17 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Menus"), exports);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMenus = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const menus_1 = require("../lib/menus");
|
|
6
|
+
const initialPointer = [-1, -1, -1];
|
|
7
|
+
const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart, i) => {
|
|
8
|
+
if (i === depth) {
|
|
9
|
+
return index;
|
|
10
|
+
}
|
|
11
|
+
if (i > depth) {
|
|
12
|
+
return -1;
|
|
13
|
+
}
|
|
14
|
+
return pointerPart;
|
|
15
|
+
});
|
|
16
|
+
const isPart = (pointer, position) => {
|
|
17
|
+
const limit = position.length < 3 ? position.length : 3;
|
|
18
|
+
for (let i = 0; i < limit; i++) {
|
|
19
|
+
if (position[i] !== pointer[i]) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
const getSubmenuState = (specs, pointer, position) => {
|
|
26
|
+
return specs.map((spec, index) => {
|
|
27
|
+
if ((0, menus_1.isMenuSeparator)(spec)) {
|
|
28
|
+
return spec;
|
|
29
|
+
}
|
|
30
|
+
const current = [...position, index];
|
|
31
|
+
return Object.assign(Object.assign({}, spec), { submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, current), isOpen: isPart(pointer, current) });
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const getMenuState = (specs, pointer) => {
|
|
35
|
+
return specs.map((spec, index) => {
|
|
36
|
+
const position = [index];
|
|
37
|
+
return Object.assign(Object.assign({}, spec), { submenu: spec.submenu && getSubmenuState(spec.submenu, pointer, position), isOpen: isPart(pointer, position) });
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const getMenuAt = (state, position) => {
|
|
41
|
+
const [head, ...tail] = position.filter((i) => i !== -1);
|
|
42
|
+
const menu = state[head];
|
|
43
|
+
if ((0, menus_1.isMenuSeparator)(menu)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!tail.length) {
|
|
47
|
+
return menu;
|
|
48
|
+
}
|
|
49
|
+
else if (menu.submenu) {
|
|
50
|
+
return getMenuAt(menu.submenu, tail);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const useMenus = (menus) => {
|
|
54
|
+
const [pointer, setPointer] = (0, react_1.useState)(initialPointer);
|
|
55
|
+
const state = getMenuState(menus, pointer);
|
|
56
|
+
const handleClick = (0, react_1.useCallback)((indices) => {
|
|
57
|
+
const menu = getMenuAt(state, indices);
|
|
58
|
+
if (!menu || !menu.isEnabled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (menu.run) {
|
|
62
|
+
menu.run();
|
|
63
|
+
setPointer([-1, -1, -1]);
|
|
64
|
+
}
|
|
65
|
+
else if (menu.submenu) {
|
|
66
|
+
const depth = indices.length - 1;
|
|
67
|
+
const index = indices[depth];
|
|
68
|
+
setPointer(transformPointer(depth, index));
|
|
69
|
+
}
|
|
70
|
+
}, [state]);
|
|
71
|
+
const ref = (0, react_1.useRef)(null);
|
|
72
|
+
(0, react_1.useEffect)(() => {
|
|
73
|
+
const handleClickOutside = (event) => {
|
|
74
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
75
|
+
setPointer([-1, -1, -1]);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
document.addEventListener('click', handleClickOutside);
|
|
79
|
+
return () => {
|
|
80
|
+
document.removeEventListener('click', handleClickOutside);
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
return {
|
|
84
|
+
menus: state,
|
|
85
|
+
handleClick,
|
|
86
|
+
ref,
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
exports.useMenus = useMenus;
|