@manuscripts/style-guide 1.5.0-LEAN-2915 → 1.5.0-LEAN-3180

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.
Files changed (70) hide show
  1. package/dist/cjs/components/Avatar.js +1 -1
  2. package/dist/cjs/components/Dialog.js +3 -3
  3. package/dist/cjs/components/References/BibliographyItemSource.js +91 -0
  4. package/dist/cjs/components/References/CitationEditor.js +146 -0
  5. package/dist/cjs/components/References/CitationViewer.js +47 -0
  6. package/dist/cjs/components/References/ReferenceForm.js +406 -0
  7. package/dist/cjs/components/References/ReferenceLine.js +52 -0
  8. package/dist/cjs/components/References/ReferenceSearch.js +124 -0
  9. package/dist/cjs/components/References/ReferenceSearchResults.js +68 -0
  10. package/dist/cjs/components/References/ReferenceSearchResultsPlaceholder.js +43 -0
  11. package/dist/cjs/components/References/ReferenceSearchSection.js +118 -0
  12. package/dist/cjs/components/References/ReferencesModal.js +217 -0
  13. package/dist/cjs/components/References/SearchInput.js +103 -0
  14. package/dist/cjs/components/References/index.js +20 -0
  15. package/dist/cjs/components/SelectField.js +25 -0
  16. package/dist/cjs/components/Sidebar.js +44 -0
  17. package/dist/cjs/components/StyledModal.js +80 -3
  18. package/dist/cjs/components/icons/delete-icon.js +15 -0
  19. package/dist/cjs/components/icons/link-icon.js +11 -0
  20. package/dist/cjs/components/icons/template-icon.js +11 -0
  21. package/dist/cjs/hooks/use-scroll-detection.js +53 -0
  22. package/dist/cjs/index.js +1 -1
  23. package/dist/es/components/Avatar.js +1 -1
  24. package/dist/es/components/Dialog.js +2 -2
  25. package/dist/es/components/References/BibliographyItemSource.js +64 -0
  26. package/dist/es/components/References/CitationEditor.js +116 -0
  27. package/dist/es/components/References/CitationViewer.js +40 -0
  28. package/dist/es/components/References/ReferenceForm.js +376 -0
  29. package/dist/es/components/References/ReferenceLine.js +42 -0
  30. package/dist/es/components/References/ReferenceSearch.js +94 -0
  31. package/dist/es/components/References/ReferenceSearchResults.js +61 -0
  32. package/dist/es/components/References/ReferenceSearchResultsPlaceholder.js +36 -0
  33. package/dist/es/components/References/ReferenceSearchSection.js +88 -0
  34. package/dist/es/components/References/ReferencesModal.js +186 -0
  35. package/dist/es/components/References/SearchInput.js +73 -0
  36. package/dist/es/components/References/index.js +4 -0
  37. package/dist/es/components/SelectField.js +18 -0
  38. package/dist/es/components/Sidebar.js +18 -0
  39. package/dist/es/components/StyledModal.js +81 -3
  40. package/dist/es/components/icons/delete-icon.js +8 -0
  41. package/dist/es/components/icons/link-icon.js +4 -0
  42. package/dist/es/components/icons/template-icon.js +4 -0
  43. package/dist/es/hooks/use-scroll-detection.js +49 -0
  44. package/dist/es/index.js +1 -1
  45. package/dist/types/components/Dialog.d.ts +1 -1
  46. package/dist/types/components/References/BibliographyItemSource.d.ts +38 -0
  47. package/dist/types/components/References/CitationEditor.d.ts +17 -0
  48. package/dist/types/components/References/CitationViewer.d.ts +24 -0
  49. package/dist/types/components/References/ReferenceForm.d.ts +31 -0
  50. package/dist/types/components/References/ReferenceLine.d.ts +10 -0
  51. package/dist/types/components/References/ReferenceSearch.d.ts +26 -0
  52. package/dist/types/components/References/ReferenceSearchResults.d.ts +26 -0
  53. package/dist/types/components/References/ReferenceSearchResultsPlaceholder.d.ts +2 -0
  54. package/dist/types/components/References/ReferenceSearchSection.d.ts +25 -0
  55. package/dist/types/components/References/ReferencesModal.d.ts +14 -0
  56. package/dist/types/components/References/SearchInput.d.ts +18 -0
  57. package/dist/types/components/References/index.d.ts +4 -0
  58. package/dist/types/components/SelectField.d.ts +27 -0
  59. package/dist/types/components/Sidebar.d.ts +2 -0
  60. package/dist/types/components/StyledModal.d.ts +26 -4
  61. package/dist/types/components/icons/delete-icon.d.ts +2 -0
  62. package/dist/types/components/icons/link-icon.d.ts +2 -0
  63. package/dist/types/components/icons/template-icon.d.ts +2 -0
  64. package/dist/types/hooks/use-scroll-detection.d.ts +22 -0
  65. package/dist/types/index.d.ts +1 -1
  66. package/dist/types/theme.d.ts +0 -2
  67. package/package.json +2 -1
  68. package/dist/cjs/components/SimpleModal.js +0 -95
  69. package/dist/es/components/SimpleModal.js +0 -88
  70. package/dist/types/components/SimpleModal.d.ts +0 -41
@@ -46,7 +46,7 @@ const AvatarNormal_1 = __importDefault(require("@manuscripts/assets/react/Avatar
46
46
  const react_1 = __importStar(require("react"));
47
47
  const styled_components_1 = __importDefault(require("styled-components"));
48
48
  const AvatarContainer = styled_components_1.default.div `
49
- display: flex;
49
+ display: inline-flex;
50
50
  align-items: center;
51
51
  justify-content: center;
52
52
  position: relative;
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.Dialog = exports.Category = exports.MessageContainer = exports.ModalBody = void 0;
30
+ exports.Dialog = exports.Category = exports.MessageContainer = exports.DialogModalBody = void 0;
31
31
  const AttentionRed_1 = __importDefault(require("@manuscripts/assets/react/AttentionRed"));
32
32
  const react_1 = __importDefault(require("react"));
33
33
  const styled_components_1 = __importDefault(require("styled-components"));
@@ -40,7 +40,7 @@ const Icon = styled_components_1.default.div `
40
40
  display: inline-flex;
41
41
  align-items: center;
42
42
  `;
43
- exports.ModalBody = styled_components_1.default.div `
43
+ exports.DialogModalBody = styled_components_1.default.div `
44
44
  border-radius: ${(props) => props.theme.grid.radius.default};
45
45
  box-shadow: ${(props) => props.theme.shadow.dropShadow};
46
46
  background: ${(props) => props.theme.colors.background.primary};
@@ -121,7 +121,7 @@ class Dialog extends react_1.default.Component {
121
121
  const { actions, isOpen, header, message, category, children, confirmFieldText, className, } = this.props;
122
122
  const { primaryActionDisabled } = this.state;
123
123
  return (react_1.default.createElement(StyledModal_1.StyledModal, { isOpen: isOpen, onRequestClose: actions.onClose, shouldCloseOnOverlayClick: true, className: className },
124
- react_1.default.createElement(exports.ModalBody, null,
124
+ react_1.default.createElement(exports.DialogModalBody, null,
125
125
  react_1.default.createElement(HeaderContainer, null,
126
126
  category === Category.error && (react_1.default.createElement(Icon, null,
127
127
  react_1.default.createElement(AttentionRed_1.default, null))),
@@ -0,0 +1,91 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.DocumentReferenceSource = void 0;
42
+ const fuzzysort = __importStar(require("fuzzysort"));
43
+ const newestFirst = (a, b) => {
44
+ if (a.createdAt === b.createdAt) {
45
+ return 0;
46
+ }
47
+ if (!a.createdAt) {
48
+ return -1;
49
+ }
50
+ if (!b.createdAt) {
51
+ return 1;
52
+ }
53
+ return b.createdAt - a.createdAt;
54
+ };
55
+ class DocumentReferenceSource {
56
+ constructor(items) {
57
+ this.id = 'document';
58
+ this.label = 'Document';
59
+ this.items = items;
60
+ }
61
+ search(query, limit) {
62
+ if (!query) {
63
+ return {
64
+ response: Promise.resolve({
65
+ items: [...this.items].sort(newestFirst).slice(0, limit),
66
+ total: this.items.length,
67
+ }),
68
+ };
69
+ }
70
+ const index = [...this.items].sort(newestFirst).map((i) => {
71
+ var _a;
72
+ return {
73
+ item: i,
74
+ title: i.title,
75
+ authors: (_a = i.author) === null || _a === void 0 ? void 0 : _a.map((a) => `${a.given} ${a.family}`).join(', '),
76
+ };
77
+ });
78
+ const results = fuzzysort.go(query, index, {
79
+ keys: ['title', 'authors'],
80
+ limit: limit,
81
+ threshold: -1000,
82
+ });
83
+ return {
84
+ response: Promise.resolve({
85
+ items: results.map((r) => r.obj.item),
86
+ total: results.total,
87
+ }),
88
+ };
89
+ }
90
+ }
91
+ exports.DocumentReferenceSource = DocumentReferenceSource;
@@ -0,0 +1,146 @@
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.CitationEditor = void 0;
30
+ const AnnotationEdit_1 = __importDefault(require("@manuscripts/assets/react/AnnotationEdit"));
31
+ const CloseIconDark_1 = __importDefault(require("@manuscripts/assets/react/CloseIconDark"));
32
+ const transform_1 = require("@manuscripts/transform");
33
+ const react_1 = __importStar(require("react"));
34
+ const styled_components_1 = __importDefault(require("styled-components"));
35
+ const Button_1 = require("../Button");
36
+ const Dialog_1 = require("../Dialog");
37
+ const icons_1 = require("../icons");
38
+ const CitationViewer_1 = require("./CitationViewer");
39
+ const ReferenceLine_1 = require("./ReferenceLine");
40
+ const ReferenceSearch_1 = require("./ReferenceSearch");
41
+ const ReferencesModal_1 = require("./ReferencesModal");
42
+ const AddCommentButtonText = styled_components_1.default.div `
43
+ display: contents;
44
+ font-family: ${(props) => props.theme.font.family.sans};
45
+ font-weight: ${(props) => props.theme.font.weight.normal};
46
+ font-size: ${(props) => props.theme.font.size.small};
47
+ line-height: ${(props) => props.theme.font.lineHeight.large};
48
+ color: ${(props) => props.theme.colors.text.primary};
49
+ `;
50
+ const CitedItemActions = styled_components_1.default.div `
51
+ display: flex;
52
+ align-items: center;
53
+ margin-left: 12px;
54
+
55
+ svg.remove-icon {
56
+ height: ${(props) => props.theme.grid.unit * 4}px;
57
+ width: ${(props) => props.theme.grid.unit * 4}px;
58
+ }
59
+ `;
60
+ const ActionButton = (0, styled_components_1.default)(Button_1.IconButton).attrs({
61
+ size: 24,
62
+ }) `
63
+ :disabled {
64
+ background-color: transparent !important;
65
+ border-color: transparent !important;
66
+ color: rgb(255, 255, 255);
67
+ path,
68
+ g {
69
+ fill: ${(props) => props.theme.colors.background.tertiary} !important;
70
+ }
71
+ }
72
+ :not(:disabled):focus,
73
+ :not(:disabled):hover {
74
+ path,
75
+ g {
76
+ fill: ${(props) => props.theme.colors.brand.medium} !important;
77
+ }
78
+ }
79
+ `;
80
+ const EditReferenceButton = (0, styled_components_1.default)(ActionButton) `
81
+ margin-right: ${(props) => props.theme.grid.unit * 3}px;
82
+ `;
83
+ const Actions = styled_components_1.default.div `
84
+ margin: ${(props) => props.theme.grid.unit * 4}px;
85
+ display: flex;
86
+ justify-content: space-between;
87
+ align-items: center;
88
+ `;
89
+ const CitationEditor = ({ rids, items, citationCounts, sources, handleCite, handleUncite, handleSave, handleDelete, handleComment, handleCancel, canEdit, }) => {
90
+ const [deleteDialog, setDeleteDialog] = (0, react_1.useState)({ show: false });
91
+ const [editingForm, setEditingForm] = (0, react_1.useState)({
92
+ show: false,
93
+ });
94
+ const [searching, setSearching] = (0, react_1.useState)(false);
95
+ const handleAdd = () => {
96
+ setSearching(false);
97
+ const item = (0, transform_1.buildBibliographyItem)({});
98
+ handleSave(item);
99
+ handleCite([item]);
100
+ setEditingForm({ show: true, item: item });
101
+ };
102
+ const cited = (0, react_1.useMemo)(() => {
103
+ return rids.flatMap((rid) => items.filter((i) => i._id === rid));
104
+ }, [rids, items]);
105
+ if (searching) {
106
+ return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { sources: sources, items: items, handleAdd: handleAdd, handleCite: (items) => {
107
+ setSearching(false);
108
+ handleCite(items);
109
+ }, handleCancel: () => setSearching(false) }));
110
+ }
111
+ if (!rids.length) {
112
+ return (react_1.default.createElement(ReferenceSearch_1.ReferenceSearch, { sources: sources, items: items, handleAdd: handleAdd, handleCite: handleCite, handleCancel: handleCancel }));
113
+ }
114
+ return (react_1.default.createElement(react_1.default.Fragment, null,
115
+ react_1.default.createElement(Dialog_1.Dialog, { isOpen: deleteDialog.show, category: Dialog_1.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: {
116
+ secondary: {
117
+ action: () => {
118
+ if (deleteDialog.id) {
119
+ handleUncite(deleteDialog.id);
120
+ setDeleteDialog({ show: false });
121
+ }
122
+ },
123
+ title: 'Remove',
124
+ },
125
+ primary: {
126
+ action: () => setDeleteDialog({ show: false }),
127
+ title: 'Cancel',
128
+ },
129
+ } }),
130
+ react_1.default.createElement(CitationViewer_1.CitedItems, null, cited.map((item) => (react_1.default.createElement(CitationViewer_1.CitedItem, { key: item._id },
131
+ react_1.default.createElement(ReferenceLine_1.ReferenceLine, { item: item }),
132
+ react_1.default.createElement(CitedItemActions, null,
133
+ react_1.default.createElement(EditReferenceButton, { value: item._id, disabled: !canEdit, onClick: () => setEditingForm({ show: true, item: item }) },
134
+ react_1.default.createElement(AnnotationEdit_1.default, { color: '#6E6E6E' })),
135
+ react_1.default.createElement(ActionButton, { disabled: !canEdit, onClick: () => setDeleteDialog({ show: true, id: item._id }) },
136
+ react_1.default.createElement(CloseIconDark_1.default, { className: 'remove-icon' }))))))),
137
+ react_1.default.createElement(ReferencesModal_1.ReferencesModal, { isOpen: editingForm.show, handleCancel: () => setEditingForm({ show: false }), items: items, citationCounts: citationCounts, item: editingForm.item, handleSave: handleSave, handleDelete: handleDelete }),
138
+ react_1.default.createElement(Actions, null,
139
+ react_1.default.createElement(Button_1.IconTextButton, { onClick: handleComment },
140
+ react_1.default.createElement(icons_1.AddComment, null),
141
+ react_1.default.createElement(AddCommentButtonText, null, "Add Comment")),
142
+ react_1.default.createElement(Button_1.ButtonGroup, null,
143
+ react_1.default.createElement(Button_1.SecondaryButton, { onClick: handleCancel }, "Done"),
144
+ react_1.default.createElement(Button_1.PrimaryButton, { disabled: !canEdit, onClick: () => setSearching(true) }, "Add Citation")))));
145
+ };
146
+ exports.CitationEditor = CitationEditor;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2024 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.CitationViewer = exports.CitedItem = exports.CitedItems = void 0;
22
+ const addons_1 = require("@storybook/addons");
23
+ const react_1 = __importDefault(require("react"));
24
+ const styled_components_1 = __importDefault(require("styled-components"));
25
+ const ReferenceLine_1 = require("./ReferenceLine");
26
+ exports.CitedItems = styled_components_1.default.div `
27
+ padding: 0 ${(props) => props.theme.grid.unit * 4}px;
28
+ font-family: ${(props) => props.theme.font.family.sans};
29
+ max-height: 70vh;
30
+ min-height: 100px;
31
+ overflow-y: auto;
32
+ `;
33
+ exports.CitedItem = styled_components_1.default.div `
34
+ display: flex;
35
+ padding: ${(props) => props.theme.grid.unit * 4}px 0;
36
+
37
+ &:not(:last-of-type) {
38
+ border-bottom: 1px solid ${(props) => props.theme.colors.border.secondary};
39
+ }
40
+ `;
41
+ const CitationViewer = ({ rids, items, }) => {
42
+ const cited = (0, addons_1.useMemo)(() => {
43
+ return rids.flatMap((rid) => items.filter((i) => i._id === rid));
44
+ }, [rids, items]);
45
+ return (react_1.default.createElement(exports.CitedItems, null, cited.map((item) => (react_1.default.createElement(ReferenceLine_1.ReferenceLine, { key: item._id, item: item })))));
46
+ };
47
+ exports.CitationViewer = CitationViewer;