@manuscripts/style-guide 2.0.18 → 2.0.19

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
@@ -72,7 +72,6 @@ Object.defineProperty(exports, "useDeepCompareMemo", { enumerable: true, get: fu
72
72
  Object.defineProperty(exports, "useDeepCompareCallback", { enumerable: true, get: function () { return use_deep_compare_1.useDeepCompareCallback; } });
73
73
  __exportStar(require("./lib/capabilities"), exports);
74
74
  __exportStar(require("./lib/files"), exports);
75
- __exportStar(require("./lib/comments"), exports);
76
75
  __exportStar(require("./lib/menus"), exports);
77
76
  var errors_decoder_1 = require("./lib/errors-decoder");
78
77
  Object.defineProperty(exports, "errorsDecoder", { enumerable: true, get: function () { return __importDefault(errors_decoder_1).default; } });
package/dist/es/index.js CHANGED
@@ -50,6 +50,5 @@ export * from './hooks/use-scroll-detection';
50
50
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
51
51
  export * from './lib/capabilities';
52
52
  export * from './lib/files';
53
- export * from './lib/comments';
54
53
  export * from './lib/menus';
55
54
  export { default as errorsDecoder } from './lib/errors-decoder';
@@ -51,6 +51,5 @@ export * from './hooks/use-scroll-detection';
51
51
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
52
52
  export * from './lib/capabilities';
53
53
  export * from './lib/files';
54
- export * from './lib/comments';
55
54
  export * from './lib/menus';
56
55
  export { default as errorsDecoder } from './lib/errors-decoder';
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.18",
4
+ "version": "2.0.19",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -33,7 +33,6 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@manuscripts/json-schema": "2.2.11",
36
- "@manuscripts/transform": "2.3.31",
37
36
  "@reach/tabs": "^0.18.0",
38
37
  "date-fns": "^2.29.3",
39
38
  "formik": "^2.2.9",
@@ -1,104 +0,0 @@
1
- "use strict";
2
- /*!
3
- * © 2020 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.buildName = exports.buildNoteTree = exports.buildCommentTree = exports.isSavedComment = void 0;
19
- const isSavedComment = (comment) => {
20
- return !!comment.createdAt;
21
- };
22
- exports.isSavedComment = isSavedComment;
23
- const oldestFirst = (a, b) => Number(a.createdAt) - Number(b.createdAt);
24
- const buildCommentsMap = (comments) => {
25
- const map = new Map();
26
- for (const comment of comments.sort(oldestFirst)) {
27
- const data = map.get(comment.target);
28
- if (data) {
29
- map.set(comment.target, {
30
- comment: data.comment,
31
- children: data.children.concat(comment),
32
- });
33
- }
34
- else {
35
- map.set(comment._id, {
36
- comment,
37
- children: [],
38
- });
39
- }
40
- }
41
- return map;
42
- };
43
- const buildTargetsMap = (commentsMap) => {
44
- const map = new Map();
45
- for (const commentData of commentsMap.values()) {
46
- const { target } = commentData.comment;
47
- const data = map.get(target);
48
- if (data) {
49
- map.set(target, data.concat(commentData));
50
- }
51
- else {
52
- map.set(target, [commentData]);
53
- }
54
- }
55
- return map;
56
- };
57
- const buildCommentsTreeMap = (doc, targetsMap) => {
58
- const map = new Map();
59
- doc.descendants((node) => {
60
- const targetID = node.attrs.rid || node.attrs.id;
61
- if (targetID) {
62
- const target = targetsMap.get(targetID);
63
- if (target) {
64
- map.set(targetID, target);
65
- }
66
- }
67
- });
68
- if (map.size < targetsMap.size) {
69
- for (const commentsData of targetsMap.values()) {
70
- const comments = commentsData;
71
- if (!map.has(comments[0].comment.target) &&
72
- comments[0].comment.target.startsWith('MPHighlight') &&
73
- comments[0].comment.originalText) {
74
- map.set(comments[0].comment.target, comments);
75
- }
76
- }
77
- }
78
- return map;
79
- };
80
- const buildNotesTreeMap = (targetsMap) => {
81
- const map = new Map();
82
- for (const notesData of targetsMap.values()) {
83
- const notes = notesData;
84
- map.set(notes[0].comment.target, notes);
85
- }
86
- return map;
87
- };
88
- const buildCommentTree = (doc, comments, newComment) => {
89
- if (newComment) {
90
- return (0, exports.buildCommentTree)(doc, [...comments, newComment]);
91
- }
92
- const commentsMap = buildCommentsMap(comments);
93
- const targetsMap = buildTargetsMap(commentsMap);
94
- return buildCommentsTreeMap(doc, targetsMap);
95
- };
96
- exports.buildCommentTree = buildCommentTree;
97
- const buildNoteTree = (comments) => {
98
- const commentsMap = buildCommentsMap(comments);
99
- const targetsMap = buildTargetsMap(commentsMap);
100
- return buildNotesTreeMap(targetsMap);
101
- };
102
- exports.buildNoteTree = buildNoteTree;
103
- const buildName = (name) => [name.given, name.family].filter((item) => item).join(' ');
104
- exports.buildName = buildName;
@@ -1,97 +0,0 @@
1
- /*!
2
- * © 2020 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
- export const isSavedComment = (comment) => {
17
- return !!comment.createdAt;
18
- };
19
- const oldestFirst = (a, b) => Number(a.createdAt) - Number(b.createdAt);
20
- const buildCommentsMap = (comments) => {
21
- const map = new Map();
22
- for (const comment of comments.sort(oldestFirst)) {
23
- const data = map.get(comment.target);
24
- if (data) {
25
- map.set(comment.target, {
26
- comment: data.comment,
27
- children: data.children.concat(comment),
28
- });
29
- }
30
- else {
31
- map.set(comment._id, {
32
- comment,
33
- children: [],
34
- });
35
- }
36
- }
37
- return map;
38
- };
39
- const buildTargetsMap = (commentsMap) => {
40
- const map = new Map();
41
- for (const commentData of commentsMap.values()) {
42
- const { target } = commentData.comment;
43
- const data = map.get(target);
44
- if (data) {
45
- map.set(target, data.concat(commentData));
46
- }
47
- else {
48
- map.set(target, [commentData]);
49
- }
50
- }
51
- return map;
52
- };
53
- const buildCommentsTreeMap = (doc, targetsMap) => {
54
- const map = new Map();
55
- doc.descendants((node) => {
56
- const targetID = node.attrs.rid || node.attrs.id;
57
- if (targetID) {
58
- const target = targetsMap.get(targetID);
59
- if (target) {
60
- map.set(targetID, target);
61
- }
62
- }
63
- });
64
- if (map.size < targetsMap.size) {
65
- for (const commentsData of targetsMap.values()) {
66
- const comments = commentsData;
67
- if (!map.has(comments[0].comment.target) &&
68
- comments[0].comment.target.startsWith('MPHighlight') &&
69
- comments[0].comment.originalText) {
70
- map.set(comments[0].comment.target, comments);
71
- }
72
- }
73
- }
74
- return map;
75
- };
76
- const buildNotesTreeMap = (targetsMap) => {
77
- const map = new Map();
78
- for (const notesData of targetsMap.values()) {
79
- const notes = notesData;
80
- map.set(notes[0].comment.target, notes);
81
- }
82
- return map;
83
- };
84
- export const buildCommentTree = (doc, comments, newComment) => {
85
- if (newComment) {
86
- return buildCommentTree(doc, [...comments, newComment]);
87
- }
88
- const commentsMap = buildCommentsMap(comments);
89
- const targetsMap = buildTargetsMap(commentsMap);
90
- return buildCommentsTreeMap(doc, targetsMap);
91
- };
92
- export const buildNoteTree = (comments) => {
93
- const commentsMap = buildCommentsMap(comments);
94
- const targetsMap = buildTargetsMap(commentsMap);
95
- return buildNotesTreeMap(targetsMap);
96
- };
97
- export const buildName = (name) => [name.given, name.family].filter((item) => item).join(' ');
@@ -1,30 +0,0 @@
1
- /*!
2
- * © 2020 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 { BibliographicName, CommentAnnotation, Contribution, ManuscriptNote } from '@manuscripts/json-schema';
17
- import { Build, ManuscriptNode } from '@manuscripts/transform';
18
- export type CommentType = ManuscriptNote | CommentAnnotation;
19
- export interface UnsavedComment extends Build<CommentAnnotation> {
20
- contributions: Contribution[];
21
- }
22
- export interface CommentData<T = CommentType> {
23
- comment: T;
24
- children: T[];
25
- }
26
- export declare const isSavedComment: (comment: CommentType | UnsavedComment) => comment is CommentType;
27
- export type CommentsTreeMap<T = CommentType> = Map<string, CommentData<T>[]>;
28
- export declare const buildCommentTree: (doc: ManuscriptNode, comments: CommentType[], newComment?: CommentType) => CommentsTreeMap<CommentType>;
29
- export declare const buildNoteTree: (comments: CommentType[]) => CommentsTreeMap<CommentType>;
30
- export declare const buildName: (name: Pick<BibliographicName, 'given' | 'family'>) => string;