@manuscripts/style-guide 1.1.12 → 1.1.14-LEAN-2501-test

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.
@@ -8,21 +8,27 @@ const json_schema_1 = require("@manuscripts/json-schema");
8
8
  const transform_1 = require("@manuscripts/transform");
9
9
  const inlineFiles_1 = __importDefault(require("../lib/inlineFiles"));
10
10
  const use_deep_compare_1 = require("./use-deep-compare");
11
- const getSupplementFiles = (modelMap, attachments, filePredicate) => {
11
+ const getInlineFilesIds = (inlineFiles) => {
12
+ return inlineFiles
13
+ .map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
14
+ .flat();
15
+ };
16
+ const getSupplementFiles = (modelMap, inlineFiles, attachments, filePredicate) => {
12
17
  const supplements = new Map((0, transform_1.getModelsByType)(modelMap, json_schema_1.ObjectTypes.Supplement).map((supplement) => { var _a; return [(_a = supplement.href) === null || _a === void 0 ? void 0 : _a.replace('attachment:', ''), supplement]; }));
18
+ const excludedAttachmentsIds = new Set(getInlineFilesIds(inlineFiles).map(({ id }) => id));
13
19
  return attachments.filter((attachment) => {
14
20
  if (supplements.has(attachment.id) && filePredicate) {
15
- return filePredicate(attachment.name);
21
+ return (!excludedAttachmentsIds.has(attachment.id) &&
22
+ filePredicate(attachment.name));
16
23
  }
17
24
  else {
18
- return supplements.has(attachment.id);
25
+ return (!excludedAttachmentsIds.has(attachment.id) &&
26
+ supplements.has(attachment.id));
19
27
  }
20
28
  });
21
29
  };
22
30
  const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
23
- const inlineFilesAttachmentIds = inlineFiles
24
- .map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
25
- .flat();
31
+ const inlineFilesAttachmentIds = getInlineFilesIds(inlineFiles);
26
32
  const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
27
33
  return attachments.filter(({ id, name }) => {
28
34
  if (!excludedAttachmentsIds.has(id) && filePredicate) {
@@ -35,7 +41,7 @@ const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate)
35
41
  };
36
42
  const useFiles = (modelMap, attachments, filePredicate) => (0, use_deep_compare_1.useDeepCompareMemo)(() => {
37
43
  const inlineFiles = (0, inlineFiles_1.default)(modelMap, attachments);
38
- const supplementFiles = getSupplementFiles(modelMap, attachments, filePredicate);
44
+ const supplementFiles = getSupplementFiles(modelMap, inlineFiles, attachments, filePredicate);
39
45
  const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
40
46
  return {
41
47
  otherFiles,
@@ -2,21 +2,27 @@ import { ObjectTypes } from '@manuscripts/json-schema';
2
2
  import { getModelsByType } from '@manuscripts/transform';
3
3
  import getInlineFiles from '../lib/inlineFiles';
4
4
  import { useDeepCompareMemo } from './use-deep-compare';
5
- const getSupplementFiles = (modelMap, attachments, filePredicate) => {
5
+ const getInlineFilesIds = (inlineFiles) => {
6
+ return inlineFiles
7
+ .map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
8
+ .flat();
9
+ };
10
+ const getSupplementFiles = (modelMap, inlineFiles, attachments, filePredicate) => {
6
11
  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]; }));
12
+ const excludedAttachmentsIds = new Set(getInlineFilesIds(inlineFiles).map(({ id }) => id));
7
13
  return attachments.filter((attachment) => {
8
14
  if (supplements.has(attachment.id) && filePredicate) {
9
- return filePredicate(attachment.name);
15
+ return (!excludedAttachmentsIds.has(attachment.id) &&
16
+ filePredicate(attachment.name));
10
17
  }
11
18
  else {
12
- return supplements.has(attachment.id);
19
+ return (!excludedAttachmentsIds.has(attachment.id) &&
20
+ supplements.has(attachment.id));
13
21
  }
14
22
  });
15
23
  };
16
24
  const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
17
- const inlineFilesAttachmentIds = inlineFiles
18
- .map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
19
- .flat();
25
+ const inlineFilesAttachmentIds = getInlineFilesIds(inlineFiles);
20
26
  const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
21
27
  return attachments.filter(({ id, name }) => {
22
28
  if (!excludedAttachmentsIds.has(id) && filePredicate) {
@@ -29,7 +35,7 @@ const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate)
29
35
  };
30
36
  export const useFiles = (modelMap, attachments, filePredicate) => useDeepCompareMemo(() => {
31
37
  const inlineFiles = getInlineFiles(modelMap, attachments);
32
- const supplementFiles = getSupplementFiles(modelMap, attachments, filePredicate);
38
+ const supplementFiles = getSupplementFiles(modelMap, inlineFiles, attachments, filePredicate);
33
39
  const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
34
40
  return {
35
41
  otherFiles,
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": "1.1.12",
4
+ "version": "1.1.14-LEAN-2501-test",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -36,10 +36,10 @@
36
36
  "@formatjs/intl-relativetimeformat": "^4.5.9",
37
37
  "@formatjs/intl-utils": "^2.2.0",
38
38
  "@manuscripts/assets": "^0.6.2",
39
- "@manuscripts/transform": "^1.3.1",
40
- "@manuscripts/json-schema": "^2.0.2",
39
+ "@manuscripts/transform": "^1.3.4-LEAN-2501-test",
40
+ "@manuscripts/json-schema": "^2.1.0",
41
41
  "@manuscripts/title-editor": "^1.1.0",
42
- "@manuscripts/comment-editor": "^1.0.2",
42
+ "@manuscripts/comment-editor": "^1.0.3",
43
43
  "@reach/tabs": "^0.11.2",
44
44
  "formik": "^2.2.9",
45
45
  "date-fns": "^2.29.3",
@@ -64,7 +64,7 @@
64
64
  "react-modern-calendar-datepicker": "^3.1.3",
65
65
  "react-popper": "^1.3.11",
66
66
  "react-router-dom": "^5.2.0",
67
- "react-select": "^5.0.1",
67
+ "react-select": "^5.7.3",
68
68
  "react-sizeme": "^2.6.12",
69
69
  "react-tooltip": "^4.2.11",
70
70
  "styled-components": "^5.2.0"
@@ -137,7 +137,6 @@
137
137
  "react-modern-calendar-datepicker": "^3.1.3",
138
138
  "react-popper": "^1.3.11",
139
139
  "react-router-dom": "^5.2.0",
140
- "react-select": "^5.0.1",
141
140
  "react-sizeme": "^2.6.12",
142
141
  "react-tooltip": "^4.2.11"
143
142
  },