@manuscripts/style-guide 1.5.0-LEAN-3180-3 → 1.5.1
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/Avatar.js +1 -1
- package/dist/cjs/components/Dialog.js +3 -3
- package/dist/cjs/components/SimpleModal.js +95 -0
- package/dist/cjs/components/StyledModal.js +3 -80
- package/dist/cjs/index.js +1 -1
- package/dist/es/components/Avatar.js +1 -1
- package/dist/es/components/Dialog.js +2 -2
- package/dist/es/components/SimpleModal.js +88 -0
- package/dist/es/components/StyledModal.js +3 -81
- package/dist/es/index.js +1 -1
- package/dist/types/components/Dialog.d.ts +1 -1
- package/dist/types/components/SimpleModal.d.ts +41 -0
- package/dist/types/components/StyledModal.d.ts +4 -26
- package/dist/types/index.d.ts +1 -1
- package/dist/types/theme.d.ts +2 -0
- package/package.json +1 -2
- package/dist/cjs/components/References/BibliographyItemSource.js +0 -91
- package/dist/cjs/components/References/CitationEditor.js +0 -146
- package/dist/cjs/components/References/CitationViewer.js +0 -69
- package/dist/cjs/components/References/ReferenceForm.js +0 -415
- 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 -219
- package/dist/cjs/components/References/SearchInput.js +0 -103
- package/dist/cjs/components/References/index.js +0 -20
- package/dist/cjs/components/SelectField.js +0 -25
- package/dist/cjs/components/Sidebar.js +0 -44
- package/dist/cjs/components/icons/delete-icon.js +0 -15
- package/dist/cjs/components/icons/link-icon.js +0 -11
- package/dist/cjs/components/icons/template-icon.js +0 -11
- package/dist/cjs/hooks/use-scroll-detection.js +0 -53
- package/dist/es/components/References/BibliographyItemSource.js +0 -64
- package/dist/es/components/References/CitationEditor.js +0 -116
- package/dist/es/components/References/CitationViewer.js +0 -39
- package/dist/es/components/References/ReferenceForm.js +0 -385
- 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 -188
- package/dist/es/components/References/SearchInput.js +0 -73
- package/dist/es/components/References/index.js +0 -4
- package/dist/es/components/SelectField.js +0 -18
- package/dist/es/components/Sidebar.js +0 -18
- package/dist/es/components/icons/delete-icon.js +0 -8
- package/dist/es/components/icons/link-icon.js +0 -4
- package/dist/es/components/icons/template-icon.js +0 -4
- package/dist/es/hooks/use-scroll-detection.js +0 -49
- 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
- package/dist/types/components/SelectField.d.ts +0 -27
- package/dist/types/components/Sidebar.d.ts +0 -2
- package/dist/types/components/icons/delete-icon.d.ts +0 -2
- package/dist/types/components/icons/link-icon.d.ts +0 -2
- package/dist/types/components/icons/template-icon.d.ts +0 -2
- package/dist/types/hooks/use-scroll-detection.d.ts +0 -22
|
@@ -1,53 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.useScrollDetection = void 0;
|
|
19
|
-
const react_1 = require("react");
|
|
20
|
-
const useScrollDetection = (topTrigger, bottomTrigger) => {
|
|
21
|
-
const refRoot = (0, react_1.useRef)();
|
|
22
|
-
const observer = (0, react_1.useRef)();
|
|
23
|
-
const [triggers, setTriggers] = (0, react_1.useState)({ bottom: false, top: false });
|
|
24
|
-
const ref = (node) => {
|
|
25
|
-
if (!node) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
refRoot.current = node;
|
|
29
|
-
if (refRoot.current && !observer.current) {
|
|
30
|
-
const listener = () => {
|
|
31
|
-
if (!refRoot.current) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const node = refRoot.current;
|
|
35
|
-
if (node.scrollTop == 0) {
|
|
36
|
-
node.scrollTop = 1;
|
|
37
|
-
}
|
|
38
|
-
const topRatio = node.scrollTop / node.offsetHeight;
|
|
39
|
-
const bottomRatio = 1 -
|
|
40
|
-
(node.scrollHeight - node.offsetHeight - node.scrollTop) /
|
|
41
|
-
node.offsetHeight;
|
|
42
|
-
const newVal = { top: false, bottom: false };
|
|
43
|
-
newVal.top = topRatio <= topTrigger;
|
|
44
|
-
newVal.bottom = Math.round(bottomRatio * 100) / 100 >= bottomTrigger;
|
|
45
|
-
setTriggers(newVal);
|
|
46
|
-
};
|
|
47
|
-
refRoot.current.addEventListener('scroll', listener);
|
|
48
|
-
observer.current = listener;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
return { ref, triggers };
|
|
52
|
-
};
|
|
53
|
-
exports.useScrollDetection = useScrollDetection;
|
|
@@ -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
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import AnnotationEdit from '@manuscripts/assets/react/AnnotationEdit';
|
|
2
|
-
import CloseIconDark from '@manuscripts/assets/react/CloseIconDark';
|
|
3
|
-
import { buildBibliographyItem } from '@manuscripts/transform';
|
|
4
|
-
import React, { useMemo, useState } from 'react';
|
|
5
|
-
import styled from 'styled-components';
|
|
6
|
-
import { ButtonGroup, IconButton, IconTextButton, PrimaryButton, SecondaryButton, } from '../Button';
|
|
7
|
-
import { Category, Dialog } from '../Dialog';
|
|
8
|
-
import { AddComment } from '../icons';
|
|
9
|
-
import { CitedItem, CitedItems } from './CitationViewer';
|
|
10
|
-
import { ReferenceLine } from './ReferenceLine';
|
|
11
|
-
import { ReferenceSearch } from './ReferenceSearch';
|
|
12
|
-
import { ReferencesModal } from './ReferencesModal';
|
|
13
|
-
const AddCommentButtonText = styled.div `
|
|
14
|
-
display: contents;
|
|
15
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
16
|
-
font-weight: ${(props) => props.theme.font.weight.normal};
|
|
17
|
-
font-size: ${(props) => props.theme.font.size.small};
|
|
18
|
-
line-height: ${(props) => props.theme.font.lineHeight.large};
|
|
19
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
20
|
-
`;
|
|
21
|
-
const CitedItemActions = styled.div `
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
margin-left: 12px;
|
|
25
|
-
|
|
26
|
-
svg.remove-icon {
|
|
27
|
-
height: ${(props) => props.theme.grid.unit * 4}px;
|
|
28
|
-
width: ${(props) => props.theme.grid.unit * 4}px;
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
const ActionButton = styled(IconButton).attrs({
|
|
32
|
-
size: 24,
|
|
33
|
-
}) `
|
|
34
|
-
:disabled {
|
|
35
|
-
background-color: transparent !important;
|
|
36
|
-
border-color: transparent !important;
|
|
37
|
-
color: rgb(255, 255, 255);
|
|
38
|
-
path,
|
|
39
|
-
g {
|
|
40
|
-
fill: ${(props) => props.theme.colors.background.tertiary} !important;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
:not(:disabled):focus,
|
|
44
|
-
:not(:disabled):hover {
|
|
45
|
-
path,
|
|
46
|
-
g {
|
|
47
|
-
fill: ${(props) => props.theme.colors.brand.medium} !important;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
|
-
const EditReferenceButton = styled(ActionButton) `
|
|
52
|
-
margin-right: ${(props) => props.theme.grid.unit * 3}px;
|
|
53
|
-
`;
|
|
54
|
-
const Actions = styled.div `
|
|
55
|
-
margin: ${(props) => props.theme.grid.unit * 4}px;
|
|
56
|
-
display: flex;
|
|
57
|
-
justify-content: space-between;
|
|
58
|
-
align-items: center;
|
|
59
|
-
`;
|
|
60
|
-
export const CitationEditor = ({ query, rids, items, citationCounts, sources, onCite, onUncite, onSave, onDelete, onComment, onCancel, canEdit, }) => {
|
|
61
|
-
const [deleteDialog, setDeleteDialog] = useState({ show: false });
|
|
62
|
-
const [editingForm, setEditingForm] = useState({
|
|
63
|
-
show: false,
|
|
64
|
-
});
|
|
65
|
-
const [searching, setSearching] = useState(false);
|
|
66
|
-
const handleAdd = () => {
|
|
67
|
-
setSearching(false);
|
|
68
|
-
const item = buildBibliographyItem({});
|
|
69
|
-
onSave(item);
|
|
70
|
-
onCite([item]);
|
|
71
|
-
setEditingForm({ show: true, item: item });
|
|
72
|
-
};
|
|
73
|
-
const cited = useMemo(() => {
|
|
74
|
-
return rids.flatMap((rid) => items.filter((i) => i._id === rid));
|
|
75
|
-
}, [rids, items]);
|
|
76
|
-
if (searching) {
|
|
77
|
-
return (React.createElement(ReferenceSearch, { sources: sources, items: items, onAdd: handleAdd, onCite: (items) => {
|
|
78
|
-
setSearching(false);
|
|
79
|
-
onCite(items);
|
|
80
|
-
}, onCancel: () => setSearching(false) }));
|
|
81
|
-
}
|
|
82
|
-
if (!rids.length) {
|
|
83
|
-
return (React.createElement(ReferenceSearch, { query: query, sources: sources, items: items, onAdd: handleAdd, onCite: onCite, onCancel: onCancel }));
|
|
84
|
-
}
|
|
85
|
-
return (React.createElement(React.Fragment, null,
|
|
86
|
-
React.createElement(Dialog, { isOpen: deleteDialog.show, category: Category.confirmation, header: "Remove cited item", message: "Are you sure you want to remove this cited item? It will still exist in the reference list.", actions: {
|
|
87
|
-
secondary: {
|
|
88
|
-
action: () => {
|
|
89
|
-
if (deleteDialog.id) {
|
|
90
|
-
onUncite(deleteDialog.id);
|
|
91
|
-
setDeleteDialog({ show: false });
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
title: 'Remove',
|
|
95
|
-
},
|
|
96
|
-
primary: {
|
|
97
|
-
action: () => setDeleteDialog({ show: false }),
|
|
98
|
-
title: 'Cancel',
|
|
99
|
-
},
|
|
100
|
-
} }),
|
|
101
|
-
React.createElement(CitedItems, null, cited.map((item) => (React.createElement(CitedItem, { key: item._id },
|
|
102
|
-
React.createElement(ReferenceLine, { item: item }),
|
|
103
|
-
React.createElement(CitedItemActions, null,
|
|
104
|
-
React.createElement(EditReferenceButton, { value: item._id, disabled: !canEdit, onClick: () => setEditingForm({ show: true, item: item }) },
|
|
105
|
-
React.createElement(AnnotationEdit, { color: '#6E6E6E' })),
|
|
106
|
-
React.createElement(ActionButton, { disabled: !canEdit, onClick: () => setDeleteDialog({ show: true, id: item._id }) },
|
|
107
|
-
React.createElement(CloseIconDark, { className: 'remove-icon' }))))))),
|
|
108
|
-
React.createElement(ReferencesModal, { isOpen: editingForm.show, onCancel: () => setEditingForm({ show: false }), items: items, citationCounts: citationCounts, item: editingForm.item, onSave: onSave, onDelete: onDelete }),
|
|
109
|
-
React.createElement(Actions, null,
|
|
110
|
-
React.createElement(IconTextButton, { onClick: onComment },
|
|
111
|
-
React.createElement(AddComment, null),
|
|
112
|
-
React.createElement(AddCommentButtonText, null, "Add Comment")),
|
|
113
|
-
React.createElement(ButtonGroup, null,
|
|
114
|
-
React.createElement(SecondaryButton, { onClick: onCancel }, "Done"),
|
|
115
|
-
React.createElement(PrimaryButton, { disabled: !canEdit, onClick: () => setSearching(true) }, "Add Citation")))));
|
|
116
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
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, { useMemo } from 'react';
|
|
17
|
-
import styled from 'styled-components';
|
|
18
|
-
import { ReferenceLine } from './ReferenceLine';
|
|
19
|
-
export const CitedItems = styled.div `
|
|
20
|
-
padding: 0 ${(props) => props.theme.grid.unit * 4}px;
|
|
21
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
22
|
-
max-height: 70vh;
|
|
23
|
-
min-height: 100px;
|
|
24
|
-
overflow-y: auto;
|
|
25
|
-
`;
|
|
26
|
-
export const CitedItem = styled.div `
|
|
27
|
-
display: flex;
|
|
28
|
-
padding: ${(props) => props.theme.grid.unit * 4}px 0;
|
|
29
|
-
|
|
30
|
-
&:not(:last-of-type) {
|
|
31
|
-
border-bottom: 1px solid ${(props) => props.theme.colors.border.secondary};
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
export const CitationViewer = ({ rids, items, }) => {
|
|
35
|
-
const cited = useMemo(() => {
|
|
36
|
-
return rids.flatMap((rid) => items.filter((i) => i._id === rid));
|
|
37
|
-
}, [rids, items]);
|
|
38
|
-
return (React.createElement(CitedItems, null, cited.map((item) => (React.createElement(ReferenceLine, { key: item._id, item: item })))));
|
|
39
|
-
};
|
|
@@ -1,385 +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 AddAuthor from '@manuscripts/assets/react/AddAuthor';
|
|
17
|
-
import Trashcan from '@manuscripts/assets/react/AnnotationRemove';
|
|
18
|
-
import ArrowDownBlue from '@manuscripts/assets/react/ArrowDownBlue';
|
|
19
|
-
import { buildBibliographicDate, buildBibliographicName, } from '@manuscripts/transform';
|
|
20
|
-
import { Field, FieldArray, Form, Formik, useFormikContext, } from 'formik';
|
|
21
|
-
import React, { useEffect, useRef, useState, } from 'react';
|
|
22
|
-
import ReactTooltip from 'react-tooltip';
|
|
23
|
-
import styled from 'styled-components';
|
|
24
|
-
import { ButtonGroup, IconButton, PrimaryButton, SecondaryButton, } from '../Button';
|
|
25
|
-
import { Category, Dialog } from '../Dialog';
|
|
26
|
-
import { DeleteIcon } from '../icons/delete-icon';
|
|
27
|
-
import { LinkIcon } from '../icons/link-icon';
|
|
28
|
-
import { SelectField } from '../SelectField';
|
|
29
|
-
import { TextArea, TextField } from '../TextField';
|
|
30
|
-
export const LabelContainer = styled.div `
|
|
31
|
-
display: flex;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
align-items: center;
|
|
34
|
-
margin-bottom: ${(props) => props.theme.grid.unit}px;
|
|
35
|
-
`;
|
|
36
|
-
const Label = styled.label `
|
|
37
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
38
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
39
|
-
display: flex;
|
|
40
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
41
|
-
`;
|
|
42
|
-
const FieldLabel = styled.label `
|
|
43
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
44
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
45
|
-
color: ${(props) => props.theme.colors.text.muted};
|
|
46
|
-
padding-right: ${(props) => props.theme.grid.unit * 3}px;
|
|
47
|
-
`;
|
|
48
|
-
const NameFieldContainer = styled.div `
|
|
49
|
-
display: flex;
|
|
50
|
-
align-items: center;
|
|
51
|
-
justify-content: space-between;
|
|
52
|
-
background-color: ${(props) => props.theme.colors.background.primary};
|
|
53
|
-
:not(:last-child) {
|
|
54
|
-
border-bottom: 1px solid ${(props) => props.theme.colors.text.muted};
|
|
55
|
-
}
|
|
56
|
-
`;
|
|
57
|
-
const NameField = styled.input `
|
|
58
|
-
font-size: ${(props) => props.theme.font.size.normal};
|
|
59
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
60
|
-
${(props) => props.theme.grid.unit * 4}px;
|
|
61
|
-
box-sizing: border-box;
|
|
62
|
-
border: none;
|
|
63
|
-
background-color: transparent;
|
|
64
|
-
width: 50%;
|
|
65
|
-
|
|
66
|
-
&:focus {
|
|
67
|
-
outline: none;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
&::placeholder {
|
|
71
|
-
color: ${(props) => props.theme.colors.text.muted};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&:hover::placeholder {
|
|
75
|
-
color: ${(props) => props.theme.colors.text.secondary};
|
|
76
|
-
}
|
|
77
|
-
`;
|
|
78
|
-
const YearField = styled(Field) `
|
|
79
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
80
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
81
|
-
${(props) => props.theme.grid.unit * 3}px;
|
|
82
|
-
font-size: ${(props) => props.theme.font.size.medium};
|
|
83
|
-
color: ${(props) => props.theme.colors.text.primary};
|
|
84
|
-
border-radius: ${(props) => props.theme.grid.radius.small};
|
|
85
|
-
border: solid 1px ${(props) => props.theme.colors.text.muted};
|
|
86
|
-
`;
|
|
87
|
-
const Button = styled(IconButton).attrs({
|
|
88
|
-
defaultColor: true,
|
|
89
|
-
size: 24,
|
|
90
|
-
}) `
|
|
91
|
-
circle,
|
|
92
|
-
use {
|
|
93
|
-
fill: ${(props) => props.theme.colors.brand.default};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
path {
|
|
97
|
-
mask: none;
|
|
98
|
-
}
|
|
99
|
-
`;
|
|
100
|
-
const Actions = styled.div `
|
|
101
|
-
flex-shrink: 1;
|
|
102
|
-
display: flex;
|
|
103
|
-
justify-content: space-between;
|
|
104
|
-
align-items: center;
|
|
105
|
-
|
|
106
|
-
.tooltip {
|
|
107
|
-
max-width: ${(props) => props.theme.grid.unit * 39}px;
|
|
108
|
-
padding: ${(props) => props.theme.grid.unit * 2}px;
|
|
109
|
-
border-radius: 6px;
|
|
110
|
-
}
|
|
111
|
-
`;
|
|
112
|
-
export const FormField = styled.div `
|
|
113
|
-
padding: ${(props) => props.theme.grid.unit * 3}px;
|
|
114
|
-
`;
|
|
115
|
-
const ReferenceTextField = styled(TextField) `
|
|
116
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
117
|
-
${(props) => props.theme.grid.unit * 3}px;
|
|
118
|
-
`;
|
|
119
|
-
export const ReferenceTextArea = styled(TextArea) `
|
|
120
|
-
padding: ${(props) => props.theme.grid.unit * 2}px
|
|
121
|
-
${(props) => props.theme.grid.unit * 3}px;
|
|
122
|
-
height: ${(props) => props.theme.grid.unit * 20}px;
|
|
123
|
-
resize: none;
|
|
124
|
-
`;
|
|
125
|
-
export const FlexForm = styled(Form) `
|
|
126
|
-
height: 100%;
|
|
127
|
-
display: flex;
|
|
128
|
-
flex-direction: column;
|
|
129
|
-
overflow: hidden;
|
|
130
|
-
`;
|
|
131
|
-
export const FormFields = styled.div `
|
|
132
|
-
flex: 1;
|
|
133
|
-
overflow-y: auto;
|
|
134
|
-
`;
|
|
135
|
-
const AuthorDropDown = ({ author, index, remove, onChange }) => {
|
|
136
|
-
const [isOpen, setIsOpen] = useState(!!author['isNew']);
|
|
137
|
-
const fullName = [author.given, author.family].join(' ').trim();
|
|
138
|
-
const title = fullName.length > 0 ? fullName : 'Edit author name';
|
|
139
|
-
return (React.createElement(Section, { key: author._id },
|
|
140
|
-
React.createElement(Title, null,
|
|
141
|
-
React.createElement(ToggleButton, { type: "button", onClick: () => setIsOpen(!isOpen), isOpen: isOpen },
|
|
142
|
-
React.createElement(DropdownIndicator, null,
|
|
143
|
-
React.createElement(ArrowDownBlue, null)),
|
|
144
|
-
title),
|
|
145
|
-
React.createElement(RemoveButton, { type: "button", "aria-label": "Delete this affiliation", onClick: () => remove(index) },
|
|
146
|
-
React.createElement(Trashcan, null))),
|
|
147
|
-
isOpen && (React.createElement(AuthorForm, null,
|
|
148
|
-
React.createElement(Field, { name: `author.${index}.given`, value: author.given, onChange: onChange }, ({ field }) => (React.createElement(NameFieldContainer, null,
|
|
149
|
-
React.createElement(NameField, Object.assign({}, field, { id: field.name, placeholder: 'Given', autoFocus: true })),
|
|
150
|
-
React.createElement(FieldLabel, { htmlFor: field.name }, "Given")))),
|
|
151
|
-
React.createElement(Field, { name: `author.${index}.family`, value: author.family, onChange: onChange }, ({ field }) => (React.createElement(NameFieldContainer, null,
|
|
152
|
-
React.createElement(NameField, Object.assign({}, field, { id: field.name, placeholder: 'Family', autoFocus: true })),
|
|
153
|
-
React.createElement(FieldLabel, { htmlFor: field.name }, "Family"))))))));
|
|
154
|
-
};
|
|
155
|
-
const bibliographyItemTypes = [
|
|
156
|
-
['article', 'Article'],
|
|
157
|
-
['article-journal', 'Journal Article'],
|
|
158
|
-
['article-magazine', 'Magazine Article'],
|
|
159
|
-
['article-newspaper', 'Newspaper Article'],
|
|
160
|
-
['bill', 'Bill'],
|
|
161
|
-
['book', 'Book'],
|
|
162
|
-
['broadcast', 'Broadcast'],
|
|
163
|
-
['chapter', 'Chapter'],
|
|
164
|
-
['dataset', 'Dataset'],
|
|
165
|
-
['entry', 'Entry'],
|
|
166
|
-
['entry-dictionary', 'Dictionary Entry'],
|
|
167
|
-
['entry-encyclopedia', 'Encyclopedia Entry'],
|
|
168
|
-
['figure', 'Figure'],
|
|
169
|
-
['graphic', 'Graphic'],
|
|
170
|
-
['interview', 'Interview'],
|
|
171
|
-
['legal_case', 'Legal Case'],
|
|
172
|
-
['legislation', 'Legislation'],
|
|
173
|
-
['manuscript', 'Manuscript'],
|
|
174
|
-
['map', 'Map'],
|
|
175
|
-
['motion_picture', 'Motion Picture'],
|
|
176
|
-
['musical_score', 'Musical Score'],
|
|
177
|
-
['pamphlet', 'Pamphlet'],
|
|
178
|
-
['paper-conference', 'Conference Paper'],
|
|
179
|
-
['patent', 'Patent'],
|
|
180
|
-
['personal_communication', 'Personal Communication'],
|
|
181
|
-
['post', 'Post'],
|
|
182
|
-
['post-weblog', 'Blog Post'],
|
|
183
|
-
['report', 'Report'],
|
|
184
|
-
['review', 'Review'],
|
|
185
|
-
['review-book', 'Book Review'],
|
|
186
|
-
['song', 'Song'],
|
|
187
|
-
['speech', 'Speech'],
|
|
188
|
-
['thesis', 'Thesis'],
|
|
189
|
-
['treaty', 'Treaty'],
|
|
190
|
-
['webpage', 'Web Page'],
|
|
191
|
-
];
|
|
192
|
-
const bibliographyItemTypeOptions = bibliographyItemTypes.map((i) => ({
|
|
193
|
-
label: i[1],
|
|
194
|
-
value: i[0],
|
|
195
|
-
}));
|
|
196
|
-
const ChangeHandlingForm = (props) => {
|
|
197
|
-
const { values } = useFormikContext();
|
|
198
|
-
useEffect(() => {
|
|
199
|
-
var _a;
|
|
200
|
-
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values);
|
|
201
|
-
}, [props.onChange, values]);
|
|
202
|
-
return React.createElement(FlexForm, null, props.children);
|
|
203
|
-
};
|
|
204
|
-
export const ReferenceForm = ({ values, showDelete, onChange, onDelete, onCancel, onSave, actionsRef, }) => {
|
|
205
|
-
const fieldsRef = useRef(null);
|
|
206
|
-
useEffect(() => {
|
|
207
|
-
if (fieldsRef.current) {
|
|
208
|
-
fieldsRef.current.scrollTop = 0;
|
|
209
|
-
}
|
|
210
|
-
}, [values]);
|
|
211
|
-
const formRef = useRef(null);
|
|
212
|
-
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
|
213
|
-
if (actionsRef && !actionsRef.current) {
|
|
214
|
-
actionsRef.current = {
|
|
215
|
-
reset: () => {
|
|
216
|
-
var _a;
|
|
217
|
-
(_a = formRef.current) === null || _a === void 0 ? void 0 : _a.resetForm();
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
return (React.createElement(Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, innerRef: formRef }, (formik) => {
|
|
222
|
-
return (React.createElement(ChangeHandlingForm, { onChange: onChange },
|
|
223
|
-
React.createElement(Dialog, { isOpen: showDeleteDialog, category: Category.confirmation, header: "Delete Reference", message: "Are you sure you want to delete this reference from the list?", actions: {
|
|
224
|
-
secondary: {
|
|
225
|
-
action: () => {
|
|
226
|
-
onDelete();
|
|
227
|
-
setShowDeleteDialog(false);
|
|
228
|
-
},
|
|
229
|
-
title: 'Delete',
|
|
230
|
-
},
|
|
231
|
-
primary: {
|
|
232
|
-
action: () => setShowDeleteDialog(false),
|
|
233
|
-
title: 'Cancel',
|
|
234
|
-
},
|
|
235
|
-
} }),
|
|
236
|
-
React.createElement(Actions, null,
|
|
237
|
-
React.createElement(ButtonGroup, null,
|
|
238
|
-
React.createElement(IconButton, { defaultColor: true, as: "a", href: `https://doi.org/${formik.values.DOI}`, target: '_blank' },
|
|
239
|
-
React.createElement(LinkIcon, null)),
|
|
240
|
-
React.createElement("div", { "data-tip": true, "data-for": 'delete-button' },
|
|
241
|
-
React.createElement(DeleteButton, { defaultColor: true, disabled: !showDelete, onClick: () => setShowDeleteDialog(true) },
|
|
242
|
-
React.createElement(DeleteIcon, null)),
|
|
243
|
-
React.createElement(ReactTooltip, { disable: showDelete, id: 'delete-button', place: "bottom", effect: "solid", offset: { top: 15 }, className: "tooltip" }, "Unable to delete because the item is used in the document"))),
|
|
244
|
-
React.createElement(ButtonGroup, null,
|
|
245
|
-
React.createElement(SecondaryButton, { onClick: onCancel }, "Cancel"),
|
|
246
|
-
React.createElement(PrimaryButton, { type: "submit" }, "Save"))),
|
|
247
|
-
React.createElement(FormFields, { ref: fieldsRef },
|
|
248
|
-
React.createElement(FormField, null,
|
|
249
|
-
React.createElement(LabelContainer, null,
|
|
250
|
-
React.createElement(Label, { htmlFor: 'citation-item-type' }, "Type")),
|
|
251
|
-
React.createElement(Field, { id: 'citation-item-type', name: 'type', component: SelectField, options: bibliographyItemTypeOptions })),
|
|
252
|
-
React.createElement(FormField, null,
|
|
253
|
-
React.createElement(LabelContainer, null,
|
|
254
|
-
React.createElement(Label, null, "Title")),
|
|
255
|
-
React.createElement(Field, { name: 'title' }, (props) => (React.createElement(ReferenceTextArea, Object.assign({ id: 'title' }, props.field))))),
|
|
256
|
-
React.createElement(FieldArray, { name: 'author', render: ({ push, remove }) => (React.createElement(FormField, null,
|
|
257
|
-
React.createElement(LabelContainer, null,
|
|
258
|
-
React.createElement(Label, null, "Authors"),
|
|
259
|
-
React.createElement(Button, { onClick: () => push(buildBibliographicName({
|
|
260
|
-
given: '',
|
|
261
|
-
family: '',
|
|
262
|
-
isNew: true,
|
|
263
|
-
})) },
|
|
264
|
-
React.createElement(AddAuthor, { height: 17, width: 17 }))),
|
|
265
|
-
React.createElement("div", null, formik.values.author &&
|
|
266
|
-
formik.values.author.map((author, index) => (React.createElement(AuthorDropDown, { key: index, index: index, author: author, remove: remove, onChange: formik.handleChange })))))) }),
|
|
267
|
-
React.createElement(FormField, null,
|
|
268
|
-
React.createElement(LabelContainer, null,
|
|
269
|
-
React.createElement(Label, { htmlFor: "issued['date-parts'][0][0]" }, "Year")),
|
|
270
|
-
React.createElement(YearField, { name: "issued['date-parts'][0][0]", type: 'number', step: 1, onChange: (event) => {
|
|
271
|
-
const { value } = event.target;
|
|
272
|
-
if (value) {
|
|
273
|
-
if (formik.values.issued) {
|
|
274
|
-
formik.setFieldValue("issued['date-parts'][0][0]", Number(value));
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
formik.setFieldValue('issued', buildBibliographicDate({
|
|
278
|
-
'date-parts': [[Number(value)]],
|
|
279
|
-
}));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
formik.setFieldValue('issued', '');
|
|
284
|
-
}
|
|
285
|
-
} })),
|
|
286
|
-
React.createElement(FormField, null,
|
|
287
|
-
React.createElement(LabelContainer, null,
|
|
288
|
-
React.createElement(Label, { htmlFor: 'container-title' }, "Container Title")),
|
|
289
|
-
React.createElement(Field, { name: 'container-title' }, (props) => (React.createElement(ReferenceTextArea, Object.assign({ id: 'container-title' }, props.field))))),
|
|
290
|
-
React.createElement(FormField, null,
|
|
291
|
-
React.createElement(LabelContainer, null,
|
|
292
|
-
React.createElement(Label, { htmlFor: 'volume' }, "Volume")),
|
|
293
|
-
React.createElement(Field, { name: 'volume' }, (props) => (React.createElement(ReferenceTextField, Object.assign({ id: 'volume' }, props.field))))),
|
|
294
|
-
React.createElement(FormField, null,
|
|
295
|
-
React.createElement(LabelContainer, null,
|
|
296
|
-
React.createElement(Label, { htmlFor: 'issue' }, "Issue")),
|
|
297
|
-
React.createElement(Field, { name: 'issue' }, (props) => (React.createElement(ReferenceTextField, Object.assign({ id: 'issue' }, props.field))))),
|
|
298
|
-
React.createElement(FormField, null,
|
|
299
|
-
React.createElement(LabelContainer, null,
|
|
300
|
-
React.createElement(Label, { htmlFor: 'page' }, "Page")),
|
|
301
|
-
React.createElement(Field, { name: 'page' }, (props) => (React.createElement(ReferenceTextField, Object.assign({ id: 'page' }, props.field))))),
|
|
302
|
-
React.createElement(FormField, null,
|
|
303
|
-
React.createElement(LabelContainer, null,
|
|
304
|
-
React.createElement(Label, { htmlFor: 'url' }, "URL")),
|
|
305
|
-
React.createElement(Field, { name: 'URL' }, (props) => (React.createElement(ReferenceTextField, Object.assign({ type: 'url', id: 'url' }, props.field))))),
|
|
306
|
-
React.createElement(FormField, null,
|
|
307
|
-
React.createElement(LabelContainer, null,
|
|
308
|
-
React.createElement(Label, { htmlFor: 'doi' }, "DOI")),
|
|
309
|
-
React.createElement(Field, { name: 'DOI' }, (props) => (React.createElement(ReferenceTextField, Object.assign({ id: 'doi', pattern: '(https://doi.org/)?10..+' }, props.field))))),
|
|
310
|
-
React.createElement(FormField, null,
|
|
311
|
-
React.createElement(LabelContainer, null,
|
|
312
|
-
React.createElement(Label, { htmlFor: 'supplement' }, "Supplement")),
|
|
313
|
-
React.createElement(Field, { name: 'supplement' }, (props) => (React.createElement(ReferenceTextField, Object.assign({ type: 'supplement', id: 'supplement' }, props.field))))))));
|
|
314
|
-
}));
|
|
315
|
-
};
|
|
316
|
-
const DeleteButton = styled(IconButton) `
|
|
317
|
-
background-color: ${(props) => props.theme.colors.background.primary} !important;
|
|
318
|
-
border-color: ${(props) => props.theme.colors.background.primary} !important;
|
|
319
|
-
.icon_element {
|
|
320
|
-
fill: ${(props) => (props.disabled && '#c9c9c9') || '#F35143'} !important;
|
|
321
|
-
}
|
|
322
|
-
`;
|
|
323
|
-
const Section = styled.section `
|
|
324
|
-
border: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
325
|
-
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
326
|
-
background: ${(props) => props.theme.colors.background.primary};
|
|
327
|
-
margin-bottom: ${(props) => props.theme.grid.unit * 3}px;
|
|
328
|
-
overflow: hidden;
|
|
329
|
-
`;
|
|
330
|
-
const AuthorForm = styled(Section) `
|
|
331
|
-
margin: ${(props) => props.theme.grid.unit * 3}px;
|
|
332
|
-
`;
|
|
333
|
-
const Title = styled.h4 `
|
|
334
|
-
margin: 0;
|
|
335
|
-
display: flex;
|
|
336
|
-
align-items: center;
|
|
337
|
-
font-size: 0.875rem;
|
|
338
|
-
padding-right: 0.5rem;
|
|
339
|
-
background: ${(props) => props.isInvalid ? props.theme.colors.background.warning : 'transparent'};
|
|
340
|
-
color: ${(props) => props.isInvalid ? props.theme.colors.text.warning : 'inherit'};
|
|
341
|
-
`;
|
|
342
|
-
const DropdownIndicator = styled(ArrowDownBlue) `
|
|
343
|
-
border: 0;
|
|
344
|
-
border-radius: 50%;
|
|
345
|
-
margin-right: 0.6em;
|
|
346
|
-
min-width: 20px;
|
|
347
|
-
`;
|
|
348
|
-
const ToggleButton = styled.button `
|
|
349
|
-
flex-grow: 1;
|
|
350
|
-
display: flex;
|
|
351
|
-
align-items: center;
|
|
352
|
-
width: 100%;
|
|
353
|
-
background: transparent;
|
|
354
|
-
border: none;
|
|
355
|
-
text-align: left;
|
|
356
|
-
font-family: ${(props) => props.theme.font.family.sans};
|
|
357
|
-
font-size: 1rem;
|
|
358
|
-
padding: 0.6em 0.5em;
|
|
359
|
-
|
|
360
|
-
outline: none;
|
|
361
|
-
|
|
362
|
-
&:focus {
|
|
363
|
-
color: ${(props) => props.theme.colors.button.primary.border.hover};
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
svg {
|
|
367
|
-
transform: ${(props) => (props.isOpen ? 'rotateX(180deg)' : 'initial')};
|
|
368
|
-
}
|
|
369
|
-
`;
|
|
370
|
-
const RemoveButton = styled.button `
|
|
371
|
-
border: none;
|
|
372
|
-
background: transparent;
|
|
373
|
-
padding: 0;
|
|
374
|
-
|
|
375
|
-
outline: none;
|
|
376
|
-
|
|
377
|
-
&:focus path {
|
|
378
|
-
fill: ${(props) => props.theme.colors.button.primary.color.hover};
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
svg {
|
|
382
|
-
width: 2rem;
|
|
383
|
-
height: 2rem;
|
|
384
|
-
}
|
|
385
|
-
`;
|