@manuscripts/style-guide 1.12.1 → 1.12.2
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/icons/index.js +5 -1
- package/dist/cjs/index.js +2 -1
- package/dist/es/components/icons/index.js +2 -0
- package/dist/es/index.js +2 -1
- package/dist/types/components/icons/index.d.ts +2 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +2 -2
- package/dist/cjs/components/References/BibliographyItemSource.js +0 -91
- package/dist/cjs/components/References/CitationEditor.js +0 -142
- package/dist/cjs/components/References/CitationViewer.js +0 -69
- package/dist/cjs/components/References/ReferenceForm.js +0 -414
- package/dist/cjs/components/References/ReferenceLine.js +0 -52
- package/dist/cjs/components/References/ReferenceSearch.js +0 -124
- package/dist/cjs/components/References/ReferenceSearchResults.js +0 -68
- package/dist/cjs/components/References/ReferenceSearchResultsPlaceholder.js +0 -43
- package/dist/cjs/components/References/ReferenceSearchSection.js +0 -118
- package/dist/cjs/components/References/ReferencesModal.js +0 -226
- package/dist/cjs/components/References/SearchInput.js +0 -103
- package/dist/cjs/components/References/index.js +0 -20
- package/dist/es/components/References/BibliographyItemSource.js +0 -64
- package/dist/es/components/References/CitationEditor.js +0 -112
- package/dist/es/components/References/CitationViewer.js +0 -39
- package/dist/es/components/References/ReferenceForm.js +0 -384
- package/dist/es/components/References/ReferenceLine.js +0 -42
- package/dist/es/components/References/ReferenceSearch.js +0 -94
- package/dist/es/components/References/ReferenceSearchResults.js +0 -61
- package/dist/es/components/References/ReferenceSearchResultsPlaceholder.js +0 -36
- package/dist/es/components/References/ReferenceSearchSection.js +0 -88
- package/dist/es/components/References/ReferencesModal.js +0 -195
- package/dist/es/components/References/SearchInput.js +0 -73
- package/dist/es/components/References/index.js +0 -4
- package/dist/types/components/References/BibliographyItemSource.d.ts +0 -38
- package/dist/types/components/References/CitationEditor.d.ts +0 -18
- package/dist/types/components/References/CitationViewer.d.ts +0 -24
- package/dist/types/components/References/ReferenceForm.d.ts +0 -35
- package/dist/types/components/References/ReferenceLine.d.ts +0 -10
- package/dist/types/components/References/ReferenceSearch.d.ts +0 -26
- package/dist/types/components/References/ReferenceSearchResults.d.ts +0 -26
- package/dist/types/components/References/ReferenceSearchResultsPlaceholder.d.ts +0 -2
- package/dist/types/components/References/ReferenceSearchSection.d.ts +0 -25
- package/dist/types/components/References/ReferencesModal.d.ts +0 -14
- package/dist/types/components/References/SearchInput.d.ts +0 -18
- package/dist/types/components/References/index.d.ts +0 -4
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ReferenceSearchResultsPlaceholder = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
const ReferenceLine_1 = require("./ReferenceLine");
|
|
10
|
-
const ReferenceSearchResults_1 = require("./ReferenceSearchResults");
|
|
11
|
-
const IconPlaceholderContainer = styled_components_1.default.div `
|
|
12
|
-
width: 36px;
|
|
13
|
-
`;
|
|
14
|
-
const IconPlaceholder = styled_components_1.default.span `
|
|
15
|
-
margin-left: 8px;
|
|
16
|
-
`;
|
|
17
|
-
const MetadataPlaceholder = (0, styled_components_1.default)(ReferenceLine_1.Metadata) `
|
|
18
|
-
background: ${(props) => props.theme.colors.text.muted};
|
|
19
|
-
height: 1.2em;
|
|
20
|
-
`;
|
|
21
|
-
const TitlePlaceholder = styled_components_1.default.div `
|
|
22
|
-
background: ${(props) => props.theme.colors.border.primary};
|
|
23
|
-
height: 1.2em;
|
|
24
|
-
`;
|
|
25
|
-
const SearchingLabel = styled_components_1.default.div `
|
|
26
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
27
|
-
margin-left: ${(props) => props.theme.grid.unit * 9}px;
|
|
28
|
-
`;
|
|
29
|
-
const ReferenceSearchResultPlaceholder = (0, styled_components_1.default)(ReferenceSearchResults_1.ReferenceSearchResult) `
|
|
30
|
-
opacity: 0.2;
|
|
31
|
-
`;
|
|
32
|
-
const Placeholder = () => (react_1.default.createElement(ReferenceSearchResultPlaceholder, null,
|
|
33
|
-
react_1.default.createElement(IconPlaceholderContainer, null,
|
|
34
|
-
react_1.default.createElement(IconPlaceholder, null, "...")),
|
|
35
|
-
react_1.default.createElement(ReferenceLine_1.MetadataContainer, null,
|
|
36
|
-
react_1.default.createElement(TitlePlaceholder, null),
|
|
37
|
-
react_1.default.createElement(MetadataPlaceholder, null))));
|
|
38
|
-
const ReferenceSearchResultsPlaceholder = () => (react_1.default.createElement(ReferenceSearchResults_1.ReferenceSearchResultsContainer, null,
|
|
39
|
-
react_1.default.createElement(SearchingLabel, null, "Searching"),
|
|
40
|
-
react_1.default.createElement(Placeholder, null),
|
|
41
|
-
react_1.default.createElement(Placeholder, null),
|
|
42
|
-
react_1.default.createElement(Placeholder, null)));
|
|
43
|
-
exports.ReferenceSearchResultsPlaceholder = ReferenceSearchResultsPlaceholder;
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2023 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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.ReferenceSearchSection = exports.Arrow = void 0;
|
|
54
|
-
const ArrowDownUp_1 = __importDefault(require("@manuscripts/assets/react/ArrowDownUp"));
|
|
55
|
-
const react_1 = __importStar(require("react"));
|
|
56
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
57
|
-
const ReferenceSearchResults_1 = require("./ReferenceSearchResults");
|
|
58
|
-
const ReferenceSearchResultsPlaceholder_1 = require("./ReferenceSearchResultsPlaceholder");
|
|
59
|
-
const SearchSourceLabel = styled_components_1.default.div `
|
|
60
|
-
margin: 0 ${(props) => props.theme.grid.unit * 4}px
|
|
61
|
-
${(props) => props.theme.grid.unit * 2}px;
|
|
62
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
63
|
-
cursor: pointer;
|
|
64
|
-
|
|
65
|
-
&:hover {
|
|
66
|
-
color: ${(props) => props.theme.colors.text.muted};
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
exports.Arrow = (0, styled_components_1.default)(ArrowDownUp_1.default) `
|
|
70
|
-
margin-right: 16px;
|
|
71
|
-
margin-left: 10px;
|
|
72
|
-
|
|
73
|
-
user-select: none;
|
|
74
|
-
|
|
75
|
-
transform: rotate(180deg);
|
|
76
|
-
|
|
77
|
-
&.open {
|
|
78
|
-
transform: rotate(0deg);
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
81
|
-
const ReferenceSearchSection = ({ query, source, isSelected, onSelect }) => {
|
|
82
|
-
const [expanded, setExpanded] = (0, react_1.useState)(true);
|
|
83
|
-
const [state, setState] = (0, react_1.useState)();
|
|
84
|
-
const [limit, setLimit] = (0, react_1.useState)(3);
|
|
85
|
-
const toggleExpanded = () => {
|
|
86
|
-
setExpanded((value) => !value);
|
|
87
|
-
};
|
|
88
|
-
(0, react_1.useEffect)(() => {
|
|
89
|
-
const search = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
const job = source.search(query, limit);
|
|
91
|
-
setState((s) => {
|
|
92
|
-
if ((s === null || s === void 0 ? void 0 : s.type) === 'running' && s.job.cancel) {
|
|
93
|
-
s.job.cancel();
|
|
94
|
-
}
|
|
95
|
-
return {
|
|
96
|
-
type: 'running',
|
|
97
|
-
job,
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
const response = yield job.response;
|
|
101
|
-
if (job.isCancelled) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
setState(Object.assign({ type: 'completed' }, response));
|
|
105
|
-
});
|
|
106
|
-
search();
|
|
107
|
-
}, [source, query, limit]);
|
|
108
|
-
const handleShowMore = () => {
|
|
109
|
-
setLimit(25);
|
|
110
|
-
};
|
|
111
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
112
|
-
react_1.default.createElement(SearchSourceLabel, { onClick: toggleExpanded },
|
|
113
|
-
react_1.default.createElement(exports.Arrow, { className: expanded ? 'open' : '' }),
|
|
114
|
-
source.label),
|
|
115
|
-
expanded && (state === null || state === void 0 ? void 0 : state.type) === 'running' && (react_1.default.createElement(ReferenceSearchResultsPlaceholder_1.ReferenceSearchResultsPlaceholder, null)),
|
|
116
|
-
expanded && (state === null || state === void 0 ? void 0 : state.type) === 'completed' && (react_1.default.createElement(ReferenceSearchResults_1.ReferenceSearchResults, { items: state.items, total: state.total, isSelected: isSelected, onSelect: onSelect, onShowMore: handleShowMore }))));
|
|
117
|
-
};
|
|
118
|
-
exports.ReferenceSearchSection = ReferenceSearchSection;
|
|
@@ -1,226 +0,0 @@
|
|
|
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.ReferencesModal = exports.normalize = void 0;
|
|
30
|
-
const ReferenceLibraryIcon_1 = __importDefault(require("@manuscripts/assets/react/ReferenceLibraryIcon"));
|
|
31
|
-
const lodash_1 = require("lodash");
|
|
32
|
-
const react_1 = __importStar(require("react"));
|
|
33
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
34
|
-
const use_scroll_detection_1 = require("../../hooks/use-scroll-detection");
|
|
35
|
-
const Dialog_1 = require("../Dialog");
|
|
36
|
-
const Sidebar_1 = require("../Sidebar");
|
|
37
|
-
const StyledModal_1 = require("../StyledModal");
|
|
38
|
-
const Tooltip_1 = require("../Tooltip");
|
|
39
|
-
const ReferenceForm_1 = require("./ReferenceForm");
|
|
40
|
-
const ReferenceLine_1 = require("./ReferenceLine");
|
|
41
|
-
const ReferencesModalContainer = (0, styled_components_1.default)(StyledModal_1.ModalContainer) `
|
|
42
|
-
min-width: 960px;
|
|
43
|
-
`;
|
|
44
|
-
const ReferencesSidebar = (0, styled_components_1.default)(StyledModal_1.ModalSidebar) `
|
|
45
|
-
width: 70%;
|
|
46
|
-
`;
|
|
47
|
-
const ReferencesSidebarContent = (0, styled_components_1.default)(Sidebar_1.SidebarContent) `
|
|
48
|
-
overflow-y: auto;
|
|
49
|
-
`;
|
|
50
|
-
const ReferencesInnerWrapper = styled_components_1.default.div `
|
|
51
|
-
width: 100%;
|
|
52
|
-
`;
|
|
53
|
-
const ReferenceButton = styled_components_1.default.div `
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
display: flex;
|
|
56
|
-
justify-content: flex-start;
|
|
57
|
-
padding: ${(props) => props.theme.grid.unit * 4}px 0;
|
|
58
|
-
border-top: 1px solid transparent;
|
|
59
|
-
border-bottom: 1px solid transparent;
|
|
60
|
-
|
|
61
|
-
path {
|
|
62
|
-
fill: #c9c9c9;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
:hover {
|
|
66
|
-
background: ${(props) => props.theme.colors.background.info};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&.selected {
|
|
70
|
-
background: ${(props) => props.theme.colors.background.info};
|
|
71
|
-
border-top-color: #bce7f6;
|
|
72
|
-
border-bottom-color: #bce7f6;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.tooltip {
|
|
76
|
-
max-width: ${(props) => props.theme.grid.unit * 25}px;
|
|
77
|
-
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
78
|
-
border-radius: 6px;
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
81
|
-
const IconContainer = styled_components_1.default.div `
|
|
82
|
-
padding-right: ${(props) => props.theme.grid.unit * 5}px;
|
|
83
|
-
position: relative;
|
|
84
|
-
`;
|
|
85
|
-
const CitationCount = styled_components_1.default.div `
|
|
86
|
-
border-radius: 50%;
|
|
87
|
-
width: 12px;
|
|
88
|
-
height: 12px;
|
|
89
|
-
position: absolute;
|
|
90
|
-
color: #ffffff;
|
|
91
|
-
background-color: #bce7f6;
|
|
92
|
-
text-align: center;
|
|
93
|
-
vertical-align: top;
|
|
94
|
-
top: 0;
|
|
95
|
-
left: 16px;
|
|
96
|
-
font-size: 9px;
|
|
97
|
-
|
|
98
|
-
&.unused {
|
|
99
|
-
background-color: #fe8f1f;
|
|
100
|
-
}
|
|
101
|
-
`;
|
|
102
|
-
const selectionTopOffset = 10;
|
|
103
|
-
const pageSize = 12;
|
|
104
|
-
const topTrigger = 0.2;
|
|
105
|
-
const bottomTrigger = 0.8;
|
|
106
|
-
const dropLimit = 36;
|
|
107
|
-
const normalize = (item) => ({
|
|
108
|
-
_id: item._id,
|
|
109
|
-
title: item.title || '',
|
|
110
|
-
author: item.author || [],
|
|
111
|
-
DOI: item.DOI || '',
|
|
112
|
-
issued: item.issued,
|
|
113
|
-
type: item.type || '',
|
|
114
|
-
'container-title': item['container-title'] || '',
|
|
115
|
-
URL: item.URL || '',
|
|
116
|
-
issue: item.issue ? String(item.issue) : '',
|
|
117
|
-
volume: item.volume ? String(item.volume) : '',
|
|
118
|
-
supplement: item.supplement ? String(item.supplement) : '',
|
|
119
|
-
page: item.page ? String(item.page) : '',
|
|
120
|
-
});
|
|
121
|
-
exports.normalize = normalize;
|
|
122
|
-
const ReferencesModal = ({ isOpen, onCancel, items, item, citationCounts, onSave, onDelete, }) => {
|
|
123
|
-
const [confirm, setConfirm] = (0, react_1.useState)(false);
|
|
124
|
-
const valuesRef = (0, react_1.useRef)();
|
|
125
|
-
const [selection, setSelection] = (0, react_1.useState)();
|
|
126
|
-
const selectionRef = (0, react_1.useRef)(null);
|
|
127
|
-
const isSelected = (item) => {
|
|
128
|
-
return item._id === (selection === null || selection === void 0 ? void 0 : selection._id);
|
|
129
|
-
};
|
|
130
|
-
const selectionIndex = items.findIndex(isSelected);
|
|
131
|
-
(0, react_1.useEffect)(() => {
|
|
132
|
-
setSelection(item);
|
|
133
|
-
}, [item]);
|
|
134
|
-
(0, react_1.useEffect)(() => {
|
|
135
|
-
setTimeout(() => {
|
|
136
|
-
var _a;
|
|
137
|
-
(_a = selectionRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({
|
|
138
|
-
block: 'center',
|
|
139
|
-
behavior: 'auto',
|
|
140
|
-
});
|
|
141
|
-
}, 100);
|
|
142
|
-
}, [selectionIndex]);
|
|
143
|
-
const { ref, triggers } = (0, use_scroll_detection_1.useScrollDetection)(topTrigger, bottomTrigger);
|
|
144
|
-
const [startIndex, setStartIndex] = (0, react_1.useState)(Math.max(0, selectionIndex - selectionTopOffset));
|
|
145
|
-
const [endIndex, setEndIndex] = (0, react_1.useState)(pageSize);
|
|
146
|
-
(0, react_1.useEffect)(() => {
|
|
147
|
-
const base = Math.max(0, selectionIndex - selectionTopOffset);
|
|
148
|
-
setStartIndex(base);
|
|
149
|
-
setEndIndex(Math.min(items.length - 1, base + pageSize));
|
|
150
|
-
}, [selectionIndex, items]);
|
|
151
|
-
(0, react_1.useEffect)(() => {
|
|
152
|
-
if (triggers.top) {
|
|
153
|
-
const newFirst = Math.max(0, startIndex - pageSize);
|
|
154
|
-
setStartIndex(newFirst);
|
|
155
|
-
setEndIndex(Math.min(newFirst + dropLimit, endIndex));
|
|
156
|
-
}
|
|
157
|
-
if (triggers.bottom) {
|
|
158
|
-
const newLast = Math.min(items.length - 1, endIndex + pageSize);
|
|
159
|
-
setEndIndex(newLast);
|
|
160
|
-
setStartIndex(Math.max(newLast - dropLimit, startIndex));
|
|
161
|
-
}
|
|
162
|
-
}, [triggers, items]);
|
|
163
|
-
const actionsRef = (0, react_1.useRef)();
|
|
164
|
-
const reset = () => {
|
|
165
|
-
var _a;
|
|
166
|
-
(_a = actionsRef.current) === null || _a === void 0 ? void 0 : _a.reset();
|
|
167
|
-
setConfirm(false);
|
|
168
|
-
};
|
|
169
|
-
const save = (values) => {
|
|
170
|
-
if (!values || !selection) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const item = Object.assign(Object.assign({}, selection), values);
|
|
174
|
-
onSave(item);
|
|
175
|
-
setSelection(item);
|
|
176
|
-
setConfirm(false);
|
|
177
|
-
};
|
|
178
|
-
const handleDelete = () => {
|
|
179
|
-
if (!selection) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
onDelete(selection);
|
|
183
|
-
setSelection(undefined);
|
|
184
|
-
};
|
|
185
|
-
const handleItemClick = (item) => {
|
|
186
|
-
const values = valuesRef.current;
|
|
187
|
-
if (values && selection && !(0, lodash_1.isEqual)(values, (0, exports.normalize)(selection))) {
|
|
188
|
-
setConfirm(true);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
setSelection(item);
|
|
192
|
-
};
|
|
193
|
-
const handleChange = (values) => {
|
|
194
|
-
valuesRef.current = values;
|
|
195
|
-
};
|
|
196
|
-
if (items.length <= 0) {
|
|
197
|
-
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
198
|
-
}
|
|
199
|
-
return (react_1.default.createElement(StyledModal_1.StyledModal, { isOpen: isOpen, onRequestClose: onCancel },
|
|
200
|
-
react_1.default.createElement(Dialog_1.Dialog, { isOpen: confirm, category: Dialog_1.Category.confirmation, header: "You've made changes to this option", message: "Would you like to save or discard your changes?", actions: {
|
|
201
|
-
secondary: {
|
|
202
|
-
action: () => reset(),
|
|
203
|
-
title: 'Discard',
|
|
204
|
-
},
|
|
205
|
-
primary: {
|
|
206
|
-
action: () => save(valuesRef.current),
|
|
207
|
-
title: 'Save',
|
|
208
|
-
},
|
|
209
|
-
} }),
|
|
210
|
-
react_1.default.createElement(ReferencesModalContainer, null,
|
|
211
|
-
react_1.default.createElement(StyledModal_1.ModalHeader, null,
|
|
212
|
-
react_1.default.createElement(StyledModal_1.CloseButton, { onClick: onCancel })),
|
|
213
|
-
react_1.default.createElement(StyledModal_1.ModalBody, null,
|
|
214
|
-
react_1.default.createElement(ReferencesSidebar, null,
|
|
215
|
-
react_1.default.createElement(StyledModal_1.ModalSidebarHeader, null,
|
|
216
|
-
react_1.default.createElement(StyledModal_1.ModalSidebarTitle, null, "References")),
|
|
217
|
-
react_1.default.createElement(ReferencesSidebarContent, { ref: ref },
|
|
218
|
-
react_1.default.createElement(ReferencesInnerWrapper, null, items.slice(startIndex, endIndex + 1).map((item) => (react_1.default.createElement(ReferenceButton, { key: item._id, id: item._id, className: isSelected(item) ? 'selected' : '', onClick: () => handleItemClick(item), ref: isSelected(item) ? selectionRef : null },
|
|
219
|
-
react_1.default.createElement(IconContainer, null,
|
|
220
|
-
react_1.default.createElement(ReferenceLibraryIcon_1.default, null),
|
|
221
|
-
(citationCounts.get(item._id) || 0) > 0 ? (react_1.default.createElement(CitationCount, { "data-tooltip-id": "citation-count-tooltip" }, citationCounts.get(item._id))) : (react_1.default.createElement(CitationCount, { className: "unused" }, "0"))),
|
|
222
|
-
react_1.default.createElement(ReferenceLine_1.ReferenceLine, { item: item }))))),
|
|
223
|
-
react_1.default.createElement(Tooltip_1.Tooltip, { id: "citation-count-tooltip", place: "bottom" }, "Number of times used in the document"))),
|
|
224
|
-
react_1.default.createElement(StyledModal_1.ScrollableModalContent, null, selection && (react_1.default.createElement(ReferenceForm_1.ReferenceForm, { values: (0, exports.normalize)(selection), showDelete: !citationCounts.get(selection._id), onChange: handleChange, onCancel: onCancel, onDelete: handleDelete, onSave: save, actionsRef: actionsRef })))))));
|
|
225
|
-
};
|
|
226
|
-
exports.ReferencesModal = ReferencesModal;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2023 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.SearchInput = exports.SearchWrapper = void 0;
|
|
45
|
-
const SearchIconNoBG_1 = __importDefault(require("@manuscripts/assets/react/SearchIconNoBG"));
|
|
46
|
-
const react_1 = __importStar(require("react"));
|
|
47
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
48
|
-
const TextField_1 = require("../TextField");
|
|
49
|
-
const SearchContainer = styled_components_1.default.div `
|
|
50
|
-
align-items: center;
|
|
51
|
-
display: flex;
|
|
52
|
-
flex: 1 0 auto;
|
|
53
|
-
position: relative;
|
|
54
|
-
margin: 12px;
|
|
55
|
-
`;
|
|
56
|
-
const SearchIconContainer = styled_components_1.default.span `
|
|
57
|
-
display: flex;
|
|
58
|
-
left: ${(props) => props.theme.grid.unit * 4}px;
|
|
59
|
-
position: absolute;
|
|
60
|
-
z-index: 2;
|
|
61
|
-
|
|
62
|
-
path {
|
|
63
|
-
fill: ${(props) => props.theme.colors.text.primary};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&.active path {
|
|
67
|
-
fill: ${(props) => props.theme.colors.brand.medium};
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
const SearchTextField = (0, styled_components_1.default)(TextField_1.TextField) `
|
|
71
|
-
-webkit-appearance: textfield;
|
|
72
|
-
padding-left: ${(props) => props.theme.grid.unit * 11}px;
|
|
73
|
-
&:hover,
|
|
74
|
-
&:focus {
|
|
75
|
-
background-color: ${(props) => props.theme.colors.background.fifth};
|
|
76
|
-
}
|
|
77
|
-
`;
|
|
78
|
-
exports.SearchWrapper = styled_components_1.default.div `
|
|
79
|
-
display: flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
padding: ${(props) => props.theme.grid.unit * 3}px;
|
|
82
|
-
`;
|
|
83
|
-
const SearchInput = (props) => {
|
|
84
|
-
const [hover, setHover] = (0, react_1.useState)(false);
|
|
85
|
-
const [focus, setFocus] = (0, react_1.useState)(false);
|
|
86
|
-
const onFocus = () => {
|
|
87
|
-
setFocus(true);
|
|
88
|
-
};
|
|
89
|
-
const onBlur = () => {
|
|
90
|
-
setFocus(false);
|
|
91
|
-
};
|
|
92
|
-
const onMouseEnter = () => {
|
|
93
|
-
setHover(true);
|
|
94
|
-
};
|
|
95
|
-
const onMouseLeave = () => {
|
|
96
|
-
setHover(false);
|
|
97
|
-
};
|
|
98
|
-
return (react_1.default.createElement(SearchContainer, { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onFocus: onFocus, onBlur: onBlur },
|
|
99
|
-
react_1.default.createElement(SearchIconContainer, { className: hover || focus ? 'active' : '' },
|
|
100
|
-
react_1.default.createElement(SearchIconNoBG_1.default, null)),
|
|
101
|
-
react_1.default.createElement(SearchTextField, Object.assign({}, props, { type: "search", placeholder: "Search", autoComplete: "off" }))));
|
|
102
|
-
};
|
|
103
|
-
exports.SearchInput = SearchInput;
|
|
@@ -1,20 +0,0 @@
|
|
|
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("./CitationEditor"), exports);
|
|
18
|
-
__exportStar(require("./CitationViewer"), exports);
|
|
19
|
-
__exportStar(require("./ReferencesModal"), exports);
|
|
20
|
-
__exportStar(require("./BibliographyItemSource"), exports);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2023 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 * as fuzzysort from 'fuzzysort';
|
|
17
|
-
const newestFirst = (a, b) => {
|
|
18
|
-
if (a.createdAt === b.createdAt) {
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
if (!a.createdAt) {
|
|
22
|
-
return -1;
|
|
23
|
-
}
|
|
24
|
-
if (!b.createdAt) {
|
|
25
|
-
return 1;
|
|
26
|
-
}
|
|
27
|
-
return b.createdAt - a.createdAt;
|
|
28
|
-
};
|
|
29
|
-
export class DocumentReferenceSource {
|
|
30
|
-
constructor(items) {
|
|
31
|
-
this.id = 'document';
|
|
32
|
-
this.label = 'Document';
|
|
33
|
-
this.items = items;
|
|
34
|
-
}
|
|
35
|
-
search(query, limit) {
|
|
36
|
-
if (!query) {
|
|
37
|
-
return {
|
|
38
|
-
response: Promise.resolve({
|
|
39
|
-
items: [...this.items].sort(newestFirst).slice(0, limit),
|
|
40
|
-
total: this.items.length,
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const index = [...this.items].sort(newestFirst).map((i) => {
|
|
45
|
-
var _a;
|
|
46
|
-
return {
|
|
47
|
-
item: i,
|
|
48
|
-
title: i.title,
|
|
49
|
-
authors: (_a = i.author) === null || _a === void 0 ? void 0 : _a.map((a) => `${a.given} ${a.family}`).join(', '),
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
const results = fuzzysort.go(query, index, {
|
|
53
|
-
keys: ['title', 'authors'],
|
|
54
|
-
limit: limit,
|
|
55
|
-
threshold: -1000,
|
|
56
|
-
});
|
|
57
|
-
return {
|
|
58
|
-
response: Promise.resolve({
|
|
59
|
-
items: results.map((r) => r.obj.item),
|
|
60
|
-
total: results.total,
|
|
61
|
-
}),
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|