@manuscripts/style-guide 0.31.10 → 0.31.11

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.
@@ -33,10 +33,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.FileManager = exports.PermissionsContext = void 0;
35
35
  const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
36
- const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
37
36
  const react_1 = __importStar(require("react"));
38
37
  const react_tooltip_1 = __importDefault(require("react-tooltip"));
39
- const inlineFiles_1 = __importDefault(require("../../lib/inlineFiles"));
38
+ const inlineFiles_1 = __importStar(require("../../lib/inlineFiles"));
40
39
  const AlertMessage_1 = require("../AlertMessage");
41
40
  const Inspector_1 = require("../Inspector");
42
41
  const InspectorSection_1 = require("../InspectorSection");
@@ -86,25 +85,17 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
86
85
  return handleDownload(publicUrl);
87
86
  }, [handleDownload]);
88
87
  const inlineFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.default)(modelMap, attachments), [modelMap.values(), attachments]);
89
- const inlineAttachmentsIds = (0, react_1.useMemo)(() => {
88
+ const supplementFiles = (0, react_1.useMemo)(() => (0, inlineFiles_1.getSupplementFiles)(modelMap, attachments), [attachments, modelMap.size]);
89
+ const excludedAttachmentsIds = (0, react_1.useMemo)(() => {
90
90
  const attachmentsIDs = new Set();
91
91
  inlineFiles.map(({ attachments }) => {
92
92
  if (attachments) {
93
93
  attachments.map((attachment) => attachmentsIDs.add(attachment.id));
94
94
  }
95
95
  });
96
+ supplementFiles.map(({ id }) => attachmentsIDs.add(id));
96
97
  return attachmentsIDs;
97
- }, [inlineFiles]);
98
- const supplementFiles = (0, react_1.useMemo)(() => {
99
- const supplements = new Map((0, manuscript_transform_1.getModelsByType)(modelMap, manuscripts_json_schema_1.ObjectTypes.Supplement).map((supplement) => {
100
- var _a;
101
- return [
102
- (_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''),
103
- supplement,
104
- ];
105
- }));
106
- return attachments.filter((attachment) => supplements.has(attachment.id));
107
- }, [attachments, modelMap.size]);
98
+ }, [inlineFiles, supplementFiles]);
108
99
  const getFileSectionExternalFile = (fileSection) => {
109
100
  const isSupplementOrOtherFilesTab = fileSection === util_1.FileSectionType.Supplements ||
110
101
  fileSection === util_1.FileSectionType.OtherFile;
@@ -113,7 +104,7 @@ const FileManager = ({ submissionId, attachments, modelMap, saveModel, enableDra
113
104
  const designation = util_1.namesWithDesignationMap.get(element.type.label);
114
105
  return (designation !== undefined &&
115
106
  util_1.designationWithFileSectionsMap.get(designation) === fileSection &&
116
- !inlineAttachmentsIds.has(element.id));
107
+ !excludedAttachmentsIds.has(element.id));
117
108
  });
118
109
  const itemsDataWithTitle = (0, util_1.generateAttachmentsTitles)(itemsData, fileSection);
119
110
  const filesItems = itemsDataWithTitle.map((element) => {
package/dist/cjs/index.js CHANGED
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  return (mod && mod.__esModule) ? mod : { "default": mod };
29
29
  };
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.SelectDialogDesignation = exports.errorsDecoder = exports.PdfPreview = exports.inlineFiles = void 0;
31
+ exports.SelectDialogDesignation = exports.errorsDecoder = exports.PdfPreview = exports.getSupplementFiles = exports.inlineFiles = void 0;
32
32
  __exportStar(require("./components/AffiliationsEditor"), exports);
33
33
  __exportStar(require("./components/AffiliationsList"), exports);
34
34
  __exportStar(require("./components/AuthorForm"), exports);
@@ -62,6 +62,7 @@ __exportStar(require("./components/Inspector"), exports);
62
62
  __exportStar(require("./components/InspectorSection"), exports);
63
63
  var inlineFiles_1 = require("./lib/inlineFiles");
64
64
  Object.defineProperty(exports, "inlineFiles", { enumerable: true, get: function () { return __importDefault(inlineFiles_1).default; } });
65
+ Object.defineProperty(exports, "getSupplementFiles", { enumerable: true, get: function () { return inlineFiles_1.getSupplementFiles; } });
65
66
  var PdfPreview_1 = require("./components/PdfPreview");
66
67
  Object.defineProperty(exports, "PdfPreview", { enumerable: true, get: function () { return __importDefault(PdfPreview_1).default; } });
67
68
  __exportStar(require("./components/SubmissionInspector"), exports);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSupplementFiles = void 0;
3
4
  const manuscript_transform_1 = require("@manuscripts/manuscript-transform");
4
5
  const manuscripts_json_schema_1 = require("@manuscripts/manuscripts-json-schema");
5
6
  const util_1 = require("../components/FileManager/util");
@@ -119,3 +120,8 @@ const getAuxiliaryObjects = (modelMap) => {
119
120
  const sortAuxiliaryObject = (orderObject, auxiliaryObjectIds) => {
120
121
  return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
121
122
  };
123
+ const getSupplementFiles = (modelMap, attachments) => {
124
+ const supplements = new Map((0, manuscript_transform_1.getModelsByType)(modelMap, manuscripts_json_schema_1.ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
125
+ return attachments.filter((attachment) => supplements.has(attachment.id));
126
+ };
127
+ exports.getSupplementFiles = getSupplementFiles;
@@ -7,11 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { buildSupplementaryMaterial, getModelsByType, } from '@manuscripts/manuscript-transform';
11
- import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
10
+ import { buildSupplementaryMaterial, } from '@manuscripts/manuscript-transform';
12
11
  import React, { createContext, useCallback, useMemo, useReducer } from 'react';
13
12
  import ReactTooltip from 'react-tooltip';
14
- import getInlineFiles from '../../lib/inlineFiles';
13
+ import getInlineFiles, { getSupplementFiles } from '../../lib/inlineFiles';
15
14
  import { AlertMessage, AlertMessageType } from '../AlertMessage';
16
15
  import { InspectorTab, InspectorTabList, InspectorTabPanel, InspectorTabPanels, InspectorTabs, } from '../Inspector';
17
16
  import { InspectorSection } from '../InspectorSection';
@@ -61,25 +60,17 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
61
60
  return handleDownload(publicUrl);
62
61
  }, [handleDownload]);
63
62
  const inlineFiles = useMemo(() => getInlineFiles(modelMap, attachments), [modelMap.values(), attachments]);
64
- const inlineAttachmentsIds = useMemo(() => {
63
+ const supplementFiles = useMemo(() => getSupplementFiles(modelMap, attachments), [attachments, modelMap.size]);
64
+ const excludedAttachmentsIds = useMemo(() => {
65
65
  const attachmentsIDs = new Set();
66
66
  inlineFiles.map(({ attachments }) => {
67
67
  if (attachments) {
68
68
  attachments.map((attachment) => attachmentsIDs.add(attachment.id));
69
69
  }
70
70
  });
71
+ supplementFiles.map(({ id }) => attachmentsIDs.add(id));
71
72
  return attachmentsIDs;
72
- }, [inlineFiles]);
73
- const supplementFiles = useMemo(() => {
74
- const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => {
75
- var _a;
76
- return [
77
- (_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''),
78
- supplement,
79
- ];
80
- }));
81
- return attachments.filter((attachment) => supplements.has(attachment.id));
82
- }, [attachments, modelMap.size]);
73
+ }, [inlineFiles, supplementFiles]);
83
74
  const getFileSectionExternalFile = (fileSection) => {
84
75
  const isSupplementOrOtherFilesTab = fileSection === FileSectionType.Supplements ||
85
76
  fileSection === FileSectionType.OtherFile;
@@ -88,7 +79,7 @@ export const FileManager = ({ submissionId, attachments, modelMap, saveModel, en
88
79
  const designation = namesWithDesignationMap.get(element.type.label);
89
80
  return (designation !== undefined &&
90
81
  designationWithFileSectionsMap.get(designation) === fileSection &&
91
- !inlineAttachmentsIds.has(element.id));
82
+ !excludedAttachmentsIds.has(element.id));
92
83
  });
93
84
  const itemsDataWithTitle = generateAttachmentsTitles(itemsData, fileSection);
94
85
  const filesItems = itemsDataWithTitle.map((element) => {
package/dist/es/index.js CHANGED
@@ -44,7 +44,7 @@ export * from './components/Tip';
44
44
  export * from './components/icons';
45
45
  export * from './components/Inspector';
46
46
  export * from './components/InspectorSection';
47
- export { default as inlineFiles } from './lib/inlineFiles';
47
+ export { default as inlineFiles, getSupplementFiles } from './lib/inlineFiles';
48
48
  export { default as PdfPreview } from './components/PdfPreview';
49
49
  export * from './components/SubmissionInspector';
50
50
  export * from './components/Dropdown';
@@ -1,4 +1,4 @@
1
- import { hasObjectType } from '@manuscripts/manuscript-transform';
1
+ import { getModelsByType, hasObjectType, } from '@manuscripts/manuscript-transform';
2
2
  import { ObjectTypes, } from '@manuscripts/manuscripts-json-schema';
3
3
  import { FileType } from '../components/FileManager/util';
4
4
  const getCaptionText = (caption) => caption &&
@@ -117,3 +117,7 @@ const getAuxiliaryObjects = (modelMap) => {
117
117
  const sortAuxiliaryObject = (orderObject, auxiliaryObjectIds) => {
118
118
  return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
119
119
  };
120
+ export const getSupplementFiles = (modelMap, attachments) => {
121
+ const supplements = new Map(getModelsByType(modelMap, ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
122
+ return attachments.filter((attachment) => supplements.has(attachment.id));
123
+ };
@@ -45,7 +45,7 @@ export * from './components/Tip';
45
45
  export * from './components/icons';
46
46
  export * from './components/Inspector';
47
47
  export * from './components/InspectorSection';
48
- export { default as inlineFiles } from './lib/inlineFiles';
48
+ export { default as inlineFiles, getSupplementFiles } from './lib/inlineFiles';
49
49
  export { default as PdfPreview } from './components/PdfPreview';
50
50
  export * from './components/SubmissionInspector';
51
51
  export * from './components/Dropdown';
@@ -9,3 +9,4 @@ declare const _default: (modelMap: Map<string, Model>, attachments: SubmissionAt
9
9
  attachments?: SubmissionAttachment[] | undefined;
10
10
  }[];
11
11
  export default _default;
12
+ export declare const getSupplementFiles: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[]) => SubmissionAttachment[];
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": "0.31.10",
4
+ "version": "0.31.11",
5
5
  "repository": "gitlab:atypon-opensource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",