@manuscripts/style-guide 2.0.17 → 2.0.18

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/index.js CHANGED
@@ -45,7 +45,6 @@ __exportStar(require("./components/Form"), exports);
45
45
  __exportStar(require("./components/Resizer"), exports);
46
46
  __exportStar(require("./components/SaveStatus"), exports);
47
47
  __exportStar(require("./components/StyledModal"), exports);
48
- __exportStar(require("./components/FootnotesSelector"), exports);
49
48
  __exportStar(require("./components/Sidebar"), exports);
50
49
  __exportStar(require("./components/RichText"), exports);
51
50
  __exportStar(require("./components/TextField"), exports);
package/dist/es/index.js CHANGED
@@ -25,7 +25,6 @@ export * from './components/Form';
25
25
  export * from './components/Resizer';
26
26
  export * from './components/SaveStatus';
27
27
  export * from './components/StyledModal';
28
- export * from './components/FootnotesSelector';
29
28
  export * from './components/Sidebar';
30
29
  export * from './components/RichText';
31
30
  export * from './components/TextField';
@@ -26,7 +26,6 @@ export * from './components/Form';
26
26
  export * from './components/Resizer';
27
27
  export * from './components/SaveStatus';
28
28
  export * from './components/StyledModal';
29
- export * from './components/FootnotesSelector';
30
29
  export * from './components/Sidebar';
31
30
  export * from './components/RichText';
32
31
  export * from './components/TextField';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/style-guide",
3
3
  "description": "Shared components for Manuscripts applications",
4
- "version": "2.0.17",
4
+ "version": "2.0.18",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1,174 +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.FootnotesSelector = void 0;
45
- const react_1 = __importStar(require("react"));
46
- const styled_components_1 = __importDefault(require("styled-components"));
47
- const Button_1 = require("./Button");
48
- const icons_1 = require("./icons");
49
- const NotesContainer = styled_components_1.default.div `
50
- height: 90vh;
51
- max-height: 400px;
52
- overflow-y: auto;
53
- `;
54
- const Actions = (0, styled_components_1.default)(Button_1.ButtonGroup) `
55
- align-items: center;
56
- box-shadow: 0 -2px 12px 0 rgba(216, 216, 216, 0.26);
57
- display: flex;
58
- justify-content: space-between;
59
- padding: ${(props) => props.theme.grid.unit * 4}px;
60
- `;
61
- const Container = styled_components_1.default.div `
62
- flex: 1;
63
- font-family: ${(props) => props.theme.font.family.sans};
64
- `;
65
- const AddNewFootnote = (0, styled_components_1.default)(Button_1.ButtonGroup) `
66
- button {
67
- margin-right: ${(props) => props.theme.grid.unit * 8}px;
68
- }
69
-
70
- button:hover,
71
- button:active {
72
- path {
73
- stroke: ${(props) => props.theme.colors.brand.medium};
74
- }
75
- rect {
76
- stroke: ${(props) => props.theme.colors.brand.medium};
77
- }
78
- }
79
- `;
80
- const FootnotesSelector = ({ notes, inlineFootnote, onAdd, onInsert, onCancel, addNewLabel }) => {
81
- let selectedNotesMap;
82
- if (inlineFootnote) {
83
- const rids = inlineFootnote.attrs.rids;
84
- const selectedNotes = notes.filter(({ node }) => rids.includes(node.attrs.id));
85
- selectedNotesMap = new Map(selectedNotes.map(({ node }) => [node.attrs.id, node]));
86
- }
87
- const [selections, setSelections] = (0, react_1.useState)(new Map(selectedNotesMap));
88
- const toggleSelection = (item) => {
89
- const id = item.attrs.id;
90
- if (selections.has(id)) {
91
- selections.delete(id);
92
- setSelections(new Map([...selections]));
93
- }
94
- else {
95
- selections.set(id, item);
96
- setSelections(new Map([...selections]));
97
- }
98
- };
99
- const isSelected = (item) => {
100
- return selections.has(item.attrs.id);
101
- };
102
- const handleClick = () => {
103
- return onInsert(notes.filter(({ node }) => selections.has(node.attrs.id)));
104
- };
105
- return (react_1.default.createElement(Container, null,
106
- react_1.default.createElement(NotesContainer, null,
107
- react_1.default.createElement(FootnotesList, { notes: notes, inlineFootnote: inlineFootnote, isSelected: isSelected, onSelect: toggleSelection })),
108
- react_1.default.createElement(Actions, null,
109
- react_1.default.createElement(AddNewFootnote, null,
110
- react_1.default.createElement(Button_1.IconTextButton, { onClick: onAdd },
111
- react_1.default.createElement(icons_1.AddNewIcon, null),
112
- addNewLabel || 'Add new')),
113
- react_1.default.createElement(Button_1.ButtonGroup, null,
114
- react_1.default.createElement(Button_1.SecondaryButton, { onClick: onCancel }, "Cancel"),
115
- react_1.default.createElement(Button_1.PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 && !inlineFootnote }, inlineFootnote ? 'Update' : 'Insert')))));
116
- };
117
- exports.FootnotesSelector = FootnotesSelector;
118
- const FootnotesList = ({ notes, isSelected, onSelect, inlineFootnote }) => {
119
- const selectedNotes = [];
120
- const remainingNotes = [];
121
- notes.forEach((note) => {
122
- const isNoteSelected = inlineFootnote && inlineFootnote.attrs.rids.includes(note.node.attrs.id);
123
- if (isNoteSelected) {
124
- selectedNotes.push(note);
125
- }
126
- else {
127
- remainingNotes.push(note);
128
- }
129
- });
130
- return (react_1.default.createElement(NotesListContainer, null,
131
- selectedNotes.map((note) => footnoteItem(note, isSelected, onSelect)),
132
- selectedNotes.length > 0 && remainingNotes.length > 0 && react_1.default.createElement(Separator, null),
133
- remainingNotes.map((note) => footnoteItem(note, isSelected, onSelect))));
134
- };
135
- const footnoteItem = (note, isSelected, onSelect) => {
136
- var _a;
137
- const { node, index } = note;
138
- return (react_1.default.createElement(FootnoteItem, { onClick: () => onSelect(node), key: node.attrs.id },
139
- react_1.default.createElement(StatusIcon, null, isSelected(node) ? (react_1.default.createElement(icons_1.AddedIcon, { "data-cy": 'plus-icon-ok' })) : (react_1.default.createElement(icons_1.AddIcon, { "data-cy": 'plus-icon' }))),
140
- react_1.default.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
141
- };
142
- const Separator = styled_components_1.default.div `
143
- height: 0;
144
- border-bottom: 1px solid #e2e2e2;
145
- margin: 4px 0;
146
- `;
147
- const NotesListContainer = styled_components_1.default.div `
148
- padding: ${(props) => props.theme.grid.unit * 6}px
149
- ${(props) => props.theme.grid.unit * 5}px;
150
- flex: 1;
151
- overflow-y: auto;
152
- `;
153
- const FootnoteItem = styled_components_1.default.div `
154
- cursor: pointer;
155
- padding: ${(props) => props.theme.grid.unit * 2}px 0;
156
- display: flex;
157
- `;
158
- const StatusIcon = styled_components_1.default.div `
159
- flex-shrink: 1;
160
- margin-right: ${(props) => props.theme.grid.unit * 3}px;
161
- margin-left: ${(props) => props.theme.grid.unit}px;
162
- height: ${(props) => props.theme.grid.unit * 6}px;
163
- width: ${(props) => props.theme.grid.unit * 6}px;
164
- display: inline-flex;
165
- justify-content: center;
166
- align-items: center;
167
- cursor: pointer;
168
- `;
169
- const NoteText = styled_components_1.default.div `
170
- color: ${(props) => props.theme.colors.text.primary};
171
- flex: 1;
172
- font-weight: ${(props) => props.theme.font.weight.normal};
173
- margin-top: 2px;
174
- `;
@@ -1,144 +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 React, { useState } from 'react';
17
- import styled from 'styled-components';
18
- import { ButtonGroup, IconTextButton, PrimaryButton, SecondaryButton, } from './Button';
19
- import { AddedIcon, AddIcon, AddNewIcon } from './icons';
20
- const NotesContainer = styled.div `
21
- height: 90vh;
22
- max-height: 400px;
23
- overflow-y: auto;
24
- `;
25
- const Actions = styled(ButtonGroup) `
26
- align-items: center;
27
- box-shadow: 0 -2px 12px 0 rgba(216, 216, 216, 0.26);
28
- display: flex;
29
- justify-content: space-between;
30
- padding: ${(props) => props.theme.grid.unit * 4}px;
31
- `;
32
- const Container = styled.div `
33
- flex: 1;
34
- font-family: ${(props) => props.theme.font.family.sans};
35
- `;
36
- const AddNewFootnote = styled(ButtonGroup) `
37
- button {
38
- margin-right: ${(props) => props.theme.grid.unit * 8}px;
39
- }
40
-
41
- button:hover,
42
- button:active {
43
- path {
44
- stroke: ${(props) => props.theme.colors.brand.medium};
45
- }
46
- rect {
47
- stroke: ${(props) => props.theme.colors.brand.medium};
48
- }
49
- }
50
- `;
51
- export const FootnotesSelector = ({ notes, inlineFootnote, onAdd, onInsert, onCancel, addNewLabel }) => {
52
- let selectedNotesMap;
53
- if (inlineFootnote) {
54
- const rids = inlineFootnote.attrs.rids;
55
- const selectedNotes = notes.filter(({ node }) => rids.includes(node.attrs.id));
56
- selectedNotesMap = new Map(selectedNotes.map(({ node }) => [node.attrs.id, node]));
57
- }
58
- const [selections, setSelections] = useState(new Map(selectedNotesMap));
59
- const toggleSelection = (item) => {
60
- const id = item.attrs.id;
61
- if (selections.has(id)) {
62
- selections.delete(id);
63
- setSelections(new Map([...selections]));
64
- }
65
- else {
66
- selections.set(id, item);
67
- setSelections(new Map([...selections]));
68
- }
69
- };
70
- const isSelected = (item) => {
71
- return selections.has(item.attrs.id);
72
- };
73
- const handleClick = () => {
74
- return onInsert(notes.filter(({ node }) => selections.has(node.attrs.id)));
75
- };
76
- return (React.createElement(Container, null,
77
- React.createElement(NotesContainer, null,
78
- React.createElement(FootnotesList, { notes: notes, inlineFootnote: inlineFootnote, isSelected: isSelected, onSelect: toggleSelection })),
79
- React.createElement(Actions, null,
80
- React.createElement(AddNewFootnote, null,
81
- React.createElement(IconTextButton, { onClick: onAdd },
82
- React.createElement(AddNewIcon, null),
83
- addNewLabel || 'Add new')),
84
- React.createElement(ButtonGroup, null,
85
- React.createElement(SecondaryButton, { onClick: onCancel }, "Cancel"),
86
- React.createElement(PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 && !inlineFootnote }, inlineFootnote ? 'Update' : 'Insert')))));
87
- };
88
- const FootnotesList = ({ notes, isSelected, onSelect, inlineFootnote }) => {
89
- const selectedNotes = [];
90
- const remainingNotes = [];
91
- notes.forEach((note) => {
92
- const isNoteSelected = inlineFootnote && inlineFootnote.attrs.rids.includes(note.node.attrs.id);
93
- if (isNoteSelected) {
94
- selectedNotes.push(note);
95
- }
96
- else {
97
- remainingNotes.push(note);
98
- }
99
- });
100
- return (React.createElement(NotesListContainer, null,
101
- selectedNotes.map((note) => footnoteItem(note, isSelected, onSelect)),
102
- selectedNotes.length > 0 && remainingNotes.length > 0 && React.createElement(Separator, null),
103
- remainingNotes.map((note) => footnoteItem(note, isSelected, onSelect))));
104
- };
105
- const footnoteItem = (note, isSelected, onSelect) => {
106
- var _a;
107
- const { node, index } = note;
108
- return (React.createElement(FootnoteItem, { onClick: () => onSelect(node), key: node.attrs.id },
109
- React.createElement(StatusIcon, null, isSelected(node) ? (React.createElement(AddedIcon, { "data-cy": 'plus-icon-ok' })) : (React.createElement(AddIcon, { "data-cy": 'plus-icon' }))),
110
- React.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
111
- };
112
- const Separator = styled.div `
113
- height: 0;
114
- border-bottom: 1px solid #e2e2e2;
115
- margin: 4px 0;
116
- `;
117
- const NotesListContainer = styled.div `
118
- padding: ${(props) => props.theme.grid.unit * 6}px
119
- ${(props) => props.theme.grid.unit * 5}px;
120
- flex: 1;
121
- overflow-y: auto;
122
- `;
123
- const FootnoteItem = styled.div `
124
- cursor: pointer;
125
- padding: ${(props) => props.theme.grid.unit * 2}px 0;
126
- display: flex;
127
- `;
128
- const StatusIcon = styled.div `
129
- flex-shrink: 1;
130
- margin-right: ${(props) => props.theme.grid.unit * 3}px;
131
- margin-left: ${(props) => props.theme.grid.unit}px;
132
- height: ${(props) => props.theme.grid.unit * 6}px;
133
- width: ${(props) => props.theme.grid.unit * 6}px;
134
- display: inline-flex;
135
- justify-content: center;
136
- align-items: center;
137
- cursor: pointer;
138
- `;
139
- const NoteText = styled.div `
140
- color: ${(props) => props.theme.colors.text.primary};
141
- flex: 1;
142
- font-weight: ${(props) => props.theme.font.weight.normal};
143
- margin-top: 2px;
144
- `;
@@ -1,29 +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 { FootnoteNode, InlineFootnoteNode } from '@manuscripts/transform';
17
- import React from 'react';
18
- export type FootnoteWithIndex = {
19
- node: FootnoteNode;
20
- index?: string;
21
- };
22
- export declare const FootnotesSelector: React.FC<{
23
- notes: FootnoteWithIndex[];
24
- inlineFootnote?: InlineFootnoteNode;
25
- onAdd: () => void;
26
- onInsert: (notes: FootnoteWithIndex[]) => void;
27
- onCancel: () => void;
28
- addNewLabel?: string;
29
- }>;