@manuscripts/style-guide 1.3.5 → 1.3.6-LEAN-2705

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 (110) hide show
  1. package/dist/cjs/components/EditorHeader/EditorHeader.js +3 -11
  2. package/dist/cjs/components/EditorHeader/ProceedView.js +25 -6
  3. package/dist/cjs/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  4. package/dist/cjs/components/FileManager/FileActions.js +134 -0
  5. package/dist/cjs/components/FileManager/FileContainer.js +39 -0
  6. package/dist/cjs/components/FileManager/FileCreatedDate.js +25 -0
  7. package/dist/cjs/components/FileManager/FileManager.js +14 -125
  8. package/dist/cjs/components/FileManager/FileManagerProvider.js +2 -7
  9. package/dist/cjs/components/FileManager/FileName.js +27 -0
  10. package/dist/cjs/components/FileManager/FileSectionAlert.js +170 -0
  11. package/dist/cjs/components/FileManager/FileTypeIcon.js +22 -0
  12. package/dist/cjs/components/FileManager/{UploadFileArea.js → FileUploader.js} +19 -12
  13. package/dist/cjs/components/FileManager/InlineFilesSection.js +71 -126
  14. package/dist/cjs/components/FileManager/OtherFilesSection.js +101 -0
  15. package/dist/cjs/components/FileManager/SupplementsSection.js +118 -0
  16. package/dist/cjs/components/FileManager/{TooltipDiv.js → Tooltip.js} +8 -3
  17. package/dist/cjs/components/FileManager/util.js +52 -67
  18. package/dist/cjs/components/icons/corrupted-file-icon.js +27 -0
  19. package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
  20. package/dist/cjs/hooks/use-deep-compare.js +2 -2
  21. package/dist/cjs/hooks/use-files.js +29 -43
  22. package/dist/cjs/index.js +3 -4
  23. package/dist/cjs/lib/capabilities.js +1 -0
  24. package/dist/cjs/lib/files.js +85 -0
  25. package/dist/es/components/EditorHeader/EditorHeader.js +3 -11
  26. package/dist/es/components/EditorHeader/ProceedView.js +26 -7
  27. package/dist/es/components/FileManager/{FileSectionItem/DragLayer.js → DragLayer.js} +12 -10
  28. package/dist/es/components/FileManager/FileActions.js +104 -0
  29. package/dist/es/components/FileManager/FileContainer.js +33 -0
  30. package/dist/es/components/FileManager/FileCreatedDate.js +18 -0
  31. package/dist/es/components/FileManager/FileManager.js +16 -124
  32. package/dist/es/components/FileManager/FileManagerProvider.js +3 -8
  33. package/dist/es/components/FileManager/FileName.js +20 -0
  34. package/dist/es/components/FileManager/FileSectionAlert.js +163 -0
  35. package/dist/es/components/FileManager/FileTypeIcon.js +15 -0
  36. package/dist/es/components/FileManager/{UploadFileArea.js → FileUploader.js} +17 -10
  37. package/dist/es/components/FileManager/InlineFilesSection.js +72 -127
  38. package/dist/es/components/FileManager/OtherFilesSection.js +74 -0
  39. package/dist/es/components/FileManager/SupplementsSection.js +91 -0
  40. package/dist/es/components/FileManager/{TooltipDiv.js → Tooltip.js} +7 -2
  41. package/dist/es/components/FileManager/util.js +47 -65
  42. package/dist/es/components/icons/corrupted-file-icon.js +22 -0
  43. package/dist/es/components/icons/document-icon-with-dot.js +1 -1
  44. package/dist/es/hooks/use-deep-compare.js +2 -2
  45. package/dist/es/hooks/use-files.js +29 -40
  46. package/dist/es/index.js +2 -2
  47. package/dist/es/lib/capabilities.js +1 -0
  48. package/dist/es/lib/files.js +79 -0
  49. package/dist/types/components/EditorHeader/ProceedView.d.ts +0 -1
  50. package/dist/types/components/FileManager/FileActions.d.ts +19 -0
  51. package/dist/types/components/FileManager/FileContainer.d.ts +1 -0
  52. package/dist/types/components/FileManager/FileCreatedDate.d.ts +8 -0
  53. package/dist/types/components/FileManager/FileManager.d.ts +17 -8
  54. package/dist/types/components/FileManager/FileManagerProvider.d.ts +8 -18
  55. package/dist/types/components/FileManager/FileName.d.ts +6 -0
  56. package/dist/types/components/FileManager/FileSectionAlert.d.ts +13 -0
  57. package/dist/types/components/FileManager/{FileSectionItem/FileTypeIcon.d.ts → FileTypeIcon.d.ts} +2 -3
  58. package/dist/types/components/FileManager/FileUploader.d.ts +4 -0
  59. package/dist/types/components/FileManager/InlineFilesSection.d.ts +3 -19
  60. package/dist/types/components/FileManager/OtherFilesSection.d.ts +5 -0
  61. package/dist/types/components/FileManager/SupplementsSection.d.ts +5 -0
  62. package/dist/types/components/FileManager/Tooltip.d.ts +2 -0
  63. package/dist/types/components/FileManager/util.d.ts +8 -12
  64. package/dist/types/components/icons/corrupted-file-icon.d.ts +19 -0
  65. package/dist/types/hooks/use-files.d.ts +4 -6
  66. package/dist/types/index.d.ts +2 -2
  67. package/dist/types/lib/capabilities.d.ts +1 -0
  68. package/dist/types/lib/files.d.ts +24 -0
  69. package/package.json +3 -3
  70. package/dist/cjs/components/FileManager/ConfirmationPopUp.js +0 -90
  71. package/dist/cjs/components/FileManager/DragItemArea.js +0 -28
  72. package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -76
  73. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +0 -115
  74. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +0 -95
  75. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -37
  76. package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -53
  77. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +0 -92
  78. package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -120
  79. package/dist/cjs/components/FileManager/FileSectionState.js +0 -83
  80. package/dist/cjs/components/FileManager/FilesSection.js +0 -61
  81. package/dist/cjs/components/FileManager/ItemsAction.js +0 -48
  82. package/dist/cjs/lib/inlineFiles.js +0 -92
  83. package/dist/es/components/FileManager/ConfirmationPopUp.js +0 -62
  84. package/dist/es/components/FileManager/DragItemArea.js +0 -21
  85. package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +0 -46
  86. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +0 -85
  87. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +0 -88
  88. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +0 -30
  89. package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +0 -46
  90. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +0 -65
  91. package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +0 -113
  92. package/dist/es/components/FileManager/FileSectionState.js +0 -78
  93. package/dist/es/components/FileManager/FilesSection.js +0 -34
  94. package/dist/es/components/FileManager/ItemsAction.js +0 -42
  95. package/dist/es/lib/inlineFiles.js +0 -90
  96. package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +0 -12
  97. package/dist/types/components/FileManager/DragItemArea.d.ts +0 -4
  98. package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +0 -3
  99. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +0 -19
  100. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +0 -38
  101. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +0 -12
  102. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +0 -21
  103. package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +0 -4
  104. package/dist/types/components/FileManager/FileSectionState.d.ts +0 -38
  105. package/dist/types/components/FileManager/FilesSection.d.ts +0 -12
  106. package/dist/types/components/FileManager/ItemsAction.d.ts +0 -4
  107. package/dist/types/components/FileManager/TooltipDiv.d.ts +0 -1
  108. package/dist/types/components/FileManager/UploadFileArea.d.ts +0 -9
  109. package/dist/types/lib/inlineFiles.d.ts +0 -11
  110. /package/dist/types/components/FileManager/{FileSectionItem/DragLayer.d.ts → DragLayer.d.ts} +0 -0
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * © 2019 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 from 'react';
17
+ const CorruptedFileIcon = (props) => (React.createElement("svg", { width: "16", height: "18", viewBox: "0 0 16 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: props.className },
18
+ React.createElement("path", { d: "M14.186 5.65149L13.6777 6.20297L14.186 5.65149L9.91329 1.71322C9.59104 1.4162 9.16952 1.25 8.7288 1.25H8.72312H8.7174H8.71165H8.70585H8.70003H8.69416H8.68826H8.68232H8.67635H8.67034H8.66429H8.65821H8.65209H8.64593H8.63974H8.63352H8.62725H8.62096H8.61462H8.60825H8.60185H8.59541H8.58894H8.58243H8.57588H8.5693H8.56269H8.55604H8.54936H8.54264H8.53589H8.5291H8.52228H8.51543H8.50854H8.50162H8.49466H8.48767H8.48064H8.47359H8.4665H8.45937H8.45221H8.44502H8.4378H8.43054H8.42325H8.41593H8.40857H8.40118H8.39376H8.38631H8.37882H8.37131H8.36376H8.35617H8.34856H8.34091H8.33323H8.32552H8.31778H8.31001H8.3022H8.29437H8.2865H8.2786H8.27067H8.26271H8.25472H8.2467H8.23864H8.23056H8.22244H8.2143H8.20612H8.19792H8.18968H8.18142H8.17312H8.16479H8.15644H8.14805H8.13964H8.13119H8.12272H8.11421H8.10568H8.09712H8.08852H8.0799H8.07126H8.06258H8.05387H8.04513H8.03637H8.02758H8.01876H8.00991H8.00103H7.99212H7.98319H7.97423H7.96524H7.95622H7.94718H7.9381H7.929H7.91987H7.91072H7.90154H7.89233H7.88309H7.87383H7.86454H7.85522H7.84588H7.83651H7.82711H7.81769H7.80824H7.79877H7.78926H7.77974H7.77018H7.7606H7.751H7.74137H7.73171H7.72203H7.71232H7.70259H7.69283H7.68305H7.67324H7.66341H7.65355H7.64367H7.63376H7.62383H7.61388H7.6039H7.59389H7.58386H7.57381H7.56373H7.55363H7.54351H7.53336H7.52319H7.51299H7.50277H7.49253H7.48226H7.47198H7.46166H7.45133H7.44097H7.43059H7.42019H7.40976H7.39931H7.38884H7.37834H7.36783H7.35729H7.34673H7.33615H7.32554H7.31492H7.30427H7.2936H7.28291H7.2722H7.26146H7.25071H7.23993H7.22913H7.21831H7.20747H7.19661H7.18573H7.17483H7.16391H7.15297H7.142H7.13102H7.12002H7.10899H7.09795H7.08688H7.0758H7.0647H7.05357H7.04243H7.03127H7.02009H7.00889H6.99767H6.98643H6.97517H6.96389H6.9526H6.94128H6.92995H6.9186H6.90723H6.89584H6.88443H6.87301H6.86156H6.8501H6.83862H6.82713H6.81561H6.80408H6.79253H6.78096H6.76938H6.75778H6.74616H6.73452H6.72287H6.7112H6.69951H6.68781H6.67609H6.66435H6.6526H6.64083H6.62904H6.61724H6.60542H6.59359H6.58173H6.56987H6.55799H6.54609H6.53418H6.52225H6.5103H6.49834H6.48637H6.47438H6.46238H6.45036H6.43832H6.42627H6.41421H6.40213H6.39004H6.37793H6.36581H6.35367H6.34152H6.32936H6.31718H6.30499H6.29279H6.28057H6.26834H6.25609H6.24383H6.23156H6.21927H6.20697H6.19466H6.18234H6.17H6.15765H6.14529H6.13291H6.12052H6.10812H6.09571H6.08329H6.07085H6.0584H6.04594H6.03347H6.02098H6.00849H5.99598H5.98346H5.97093H5.95839H5.94584H5.93327H5.9207H5.90811H5.89551H5.88291H5.87029H5.85766H5.84502H5.83237H5.81971H5.80704H5.79436H5.78167H5.76897H5.75626H5.74354H5.73081H5.71808H5.70533H5.69257H5.6798H5.66703H5.65424H5.64145H5.62865H5.61583H5.60301H5.59018H5.57735H5.5645H5.55165H5.53878H5.52591H5.51303H5.50015H5.48725H5.47435H5.46144H5.44852H5.4356H5.42266H5.40972H5.39677H5.38382H5.37086H5.35789H5.34491H5.33193H5.31894H5.30594H5.29294H5.27993H5.26692H5.2539H5.24087H5.22783H5.21479H5.20175H5.1887H5.17564H5.16258H5.14951H5.13643H5.12335H5.11027H5.09718H5.08408H5.07098H5.05788H5.04477H5.03165H5.01854H5.00541H4.99228H4.97915H4.96601H4.95287H4.93973H4.92658H4.91343H4.90027H4.88711H4.87395H4.86078H4.84761H4.83443H4.82126H4.80808H4.79489H4.7817H4.76851H4.75532H4.74213H4.72893H4.71573H4.70253H4.68932H4.67611H4.6629H4.64969H4.63648H4.62326H4.61004H4.59683H4.5836H4.57038H4.55716H4.54393H4.53071H4.51748H4.50425H4.49102H4.47779H4.46456H4.45133H4.43809H4.42486H4.41163H4.39839H4.38516H4.37192H4.35869H4.34545H4.33222H4.31899H4.30575H4.29252H4.27928H4.26605H4.25282H4.23959H4.22636H4.21313H4.1999H4.18667H4.17345H4.16022H4.147H4.13378H4.12056H4.10734H4.09412H4.0809H4.06769H4.05448H4.04127H4.02806H4.01486H4.00166H3.98846H3.97526H3.96206H3.94887H3.93568H3.9225H3.90931H3.89613H3.88296H3.86978H3.85661H3.84345H3.83028H3.81712H3.80397H3.79082H3.77767H3.76452H3.75138H3.73825H3.72512H3.71199H3.69887H3.68575H3.67264H3.65953H3.64642H3.63332H3.62023H3.60714H3.59406H3.58098H3.56791H3.55484H3.54178H3.52872H3.51567H3.50263H3.48959H3.47655H3.46353H3.45051H3.43749H3.42449H3.41148H3.39849H3.3855H3.37252H3.35955H3.34658H3.33362H3.32067H3.30772H3.29478H3.28185H3.26892H3.25601H3.2431H3.2302H3.21731H3.20442H3.19154H3.17867H3.16581H3.15296H3.14012H3.12728H3.11445H3.10163H3.08882H3.07602H3.06323H3.05045H3.03767H3.02491H3.01215H2.99941C2.03233 1.25 1.25 2.03408 1.25 3V15C1.25 15.9665 2.0335 16.75 3 16.75H13C13.9665 16.75 14.75 15.9665 14.75 15V6.93827C14.75 6.4494 14.5455 5.98282 14.186 5.65149Z", stroke: "#6E6E6E", strokeWidth: "1.5" }),
19
+ React.createElement("path", { d: "M5 13C6.06061 11.4908 8.94545 9.37781 12 13", stroke: "#6E6E6E", strokeWidth: "1.5", strokeLinecap: "round" }),
20
+ React.createElement("path", { d: "M5 5C5 5 5 5.52369 5 6.5", stroke: "#6E6E6E", strokeWidth: "1.5", strokeLinecap: "round" }),
21
+ React.createElement("path", { d: "M9 2V7H14", stroke: "#6E6E6E", strokeWidth: "1.5" })));
22
+ export default CorruptedFileIcon;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import React from 'react';
17
- const DocumentIconWithDot = (props) => (React.createElement("svg", { width: "28", height: "33", viewBox: "0 0 28 33", fill: "none", xmlns: "http://www.w3.org/2000/svg", "data-for": "dot", "data-tip": true },
17
+ const DocumentIconWithDot = (props) => (React.createElement("svg", { className: props.className, width: "28", height: "33", style: { marginLeft: -7, marginTop: -4 }, viewBox: "0 0 28 33", fill: "none", xmlns: "http://www.w3.org/2000/svg", "data-for": "dot", "data-tip": true },
18
18
  React.createElement("rect", { x: "9", y: "9.71973", width: "18", height: "22", rx: "2", stroke: "#1A9BC7", strokeWidth: "2" }),
19
19
  React.createElement("rect", { x: "13.167", y: "14.0771", width: "5.66667", height: "1.14286", rx: "0.5", fill: "#1A9BC7", stroke: "#1A9BC7" }),
20
20
  React.createElement("rect", { x: "13.167", y: "19.791", width: "9.66667", height: "1.14286", rx: "0.5", fill: "#1A9BC7", stroke: "#1A9BC7" }),
@@ -22,5 +22,5 @@ const useDeepCompare = (deps) => {
22
22
  }
23
23
  return ref.current;
24
24
  };
25
- export const useDeepCompareMemo = (callback, deps) => useMemo(callback, [useDeepCompare(deps), callback]);
26
- export const useDeepCompareCallback = (callback, deps) => useCallback(callback, [useDeepCompare(deps), callback]);
25
+ export const useDeepCompareMemo = (callback, deps) => useMemo(callback, [useDeepCompare(deps)]);
26
+ export const useDeepCompareCallback = (callback, deps) => useCallback(callback, [useDeepCompare(deps)]);
@@ -1,46 +1,35 @@
1
1
  import { ObjectTypes } from '@manuscripts/json-schema';
2
- import { getModelsByType } from '@manuscripts/transform';
3
- import getInlineFiles from '../lib/inlineFiles';
2
+ import { getInlineFiles, getSupplements, } from '../lib/files';
4
3
  import { useDeepCompareMemo } from './use-deep-compare';
5
- const getInlineFilesIds = (inlineFiles) => {
6
- return inlineFiles
7
- .map(({ attachments }) => (attachments === null || attachments === void 0 ? void 0 : attachments.map(({ id }) => ({ id }))) || [])
8
- .flat();
4
+ const types = [
5
+ ObjectTypes.Section,
6
+ ObjectTypes.FigureElement,
7
+ ObjectTypes.Figure,
8
+ ObjectTypes.Supplement,
9
+ ObjectTypes.ElementsOrder,
10
+ ];
11
+ const getOtherFiles = (inlineFiles, supplements, files) => {
12
+ const excluded = new Set();
13
+ inlineFiles.flatMap((f) => f.files).forEach((f) => excluded.add(f.id));
14
+ supplements.forEach((s) => excluded.add(s.id));
15
+ return files.filter((f) => !excluded.has(f.id));
9
16
  };
10
- const getSupplementFiles = (modelMap, inlineFiles, attachments, filePredicate) => {
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));
13
- return attachments.filter((attachment) => {
14
- if (supplements.has(attachment.id) && filePredicate) {
15
- return (!excludedAttachmentsIds.has(attachment.id) &&
16
- filePredicate(attachment.name));
17
+ export const useFiles = (modelMap, files) => {
18
+ const models = [];
19
+ for (const [_, model] of modelMap.entries()) {
20
+ if (types.includes(model.objectType)) {
21
+ models.push(model);
17
22
  }
18
- else {
19
- return (!excludedAttachmentsIds.has(attachment.id) &&
20
- supplements.has(attachment.id));
21
- }
22
- });
23
- };
24
- const getOtherFiles = (inlineFiles, supplementFiles, attachments, filePredicate) => {
25
- const inlineFilesAttachmentIds = getInlineFilesIds(inlineFiles);
26
- const excludedAttachmentsIds = new Set([...inlineFilesAttachmentIds, ...supplementFiles].map(({ id }) => id));
27
- return attachments.filter(({ id, name }) => {
28
- if (!excludedAttachmentsIds.has(id) && filePredicate) {
29
- return filePredicate(name);
30
- }
31
- else {
32
- return !excludedAttachmentsIds.has(id);
33
- }
34
- });
23
+ }
24
+ return useDeepCompareMemo(() => {
25
+ const inlineFiles = getInlineFiles(modelMap, files);
26
+ const supplements = getSupplements(modelMap, files);
27
+ const otherFiles = getOtherFiles(inlineFiles, supplements, files);
28
+ return {
29
+ inlineFiles,
30
+ supplements,
31
+ otherFiles,
32
+ };
33
+ }, [models, files]);
35
34
  };
36
- export const useFiles = (modelMap, attachments, filePredicate) => useDeepCompareMemo(() => {
37
- const inlineFiles = getInlineFiles(modelMap, attachments);
38
- const supplementFiles = getSupplementFiles(modelMap, inlineFiles, attachments, filePredicate);
39
- const otherFiles = getOtherFiles(inlineFiles, supplementFiles, attachments, filePredicate);
40
- return {
41
- otherFiles,
42
- supplementFiles,
43
- inlineFiles,
44
- };
45
- }, [...Array.from(modelMap.values()), ...attachments]);
46
35
  export default useFiles;
package/dist/es/index.js CHANGED
@@ -31,7 +31,6 @@ export * from './components/Checkbox';
31
31
  export * from './components/Form';
32
32
  export * from './components/FileManager';
33
33
  export * from './components/FileManager/util';
34
- export * from './components/FileManager/FileSectionItem/FileSectionItem';
35
34
  export * from './components/Resizer';
36
35
  export * from './components/SaveStatus';
37
36
  export * from './components/SimpleModal';
@@ -49,10 +48,11 @@ export * from './components/NavDropdown';
49
48
  export * from './components/SubmissionInspector';
50
49
  export * from './components/Dropdown';
51
50
  export * from './hooks/use-dropdown';
52
- export { useFiles } from './hooks/use-files';
51
+ export * from './hooks/use-files';
53
52
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
54
53
  export * from './lib/authors';
55
54
  export * from './lib/capabilities';
55
+ export * from './lib/files';
56
56
  export { default as errorsDecoder } from './lib/errors-decoder';
57
57
  export * from './types';
58
58
  export * from './components/LoadingOverlay';
@@ -53,6 +53,7 @@ export const getCapabilities = (project, profile, role, actions) => {
53
53
  editMetadata: !(isViewer() || isAnnotator() || isProofer()),
54
54
  editCitationsAndRefs: !(isViewer() || isAnnotator() || isProofer()),
55
55
  shareProject: isOwner(),
56
+ applySaveChanges: !(isAnnotator() || isProofer()),
56
57
  };
57
58
  };
58
59
  export const getAllPermitted = () => {
@@ -0,0 +1,79 @@
1
+ import { ObjectTypes, } from '@manuscripts/json-schema';
2
+ import { getModelsByType } from '@manuscripts/transform';
3
+ import { FileType } from '../components/FileManager/util';
4
+ export const isModelFile = (file) => {
5
+ return file.modelId;
6
+ };
7
+ const MISSING_FILE = {
8
+ id: '',
9
+ name: 'Missing file',
10
+ type: {
11
+ id: 'missing',
12
+ },
13
+ };
14
+ const getFile = (files, id) => {
15
+ return files.filter((f) => f.id === id)[0] || MISSING_FILE;
16
+ };
17
+ const getFigureFiles = (element, modelMap, files) => {
18
+ const figureFiles = [];
19
+ element.containedObjectIDs.map((id) => {
20
+ const model = modelMap.get(id);
21
+ if (model && model.objectType === ObjectTypes.Figure) {
22
+ const figure = model;
23
+ if (figure.src) {
24
+ figureFiles.push(Object.assign(Object.assign({}, getFile(files, figure.src)), { modelId: figure._id }));
25
+ }
26
+ }
27
+ });
28
+ return figureFiles;
29
+ };
30
+ const getSupplementFiles = (supplement, files) => {
31
+ if (supplement.href) {
32
+ const href = supplement.href;
33
+ if (href) {
34
+ return [
35
+ Object.assign(Object.assign({}, getFile(files, href)), { modelId: supplement._id }),
36
+ ];
37
+ }
38
+ }
39
+ return [];
40
+ };
41
+ export const getInlineFiles = (modelMap, files) => {
42
+ var _a;
43
+ const elements = [];
44
+ const orders = getOrderByType(modelMap);
45
+ const sections = getModelsByType(modelMap, ObjectTypes.Section);
46
+ const graphicalAbstractElementIds = (_a = sections.filter((s) => s.category === 'MPSectionCategory:abstract-graphical')[0]) === null || _a === void 0 ? void 0 : _a.elementIDs;
47
+ graphicalAbstractElementIds === null || graphicalAbstractElementIds === void 0 ? void 0 : graphicalAbstractElementIds.map((id) => {
48
+ const figure = modelMap.get(id);
49
+ if (figure) {
50
+ elements.push({
51
+ modelId: id,
52
+ type: FileType.GraphicalAbstract,
53
+ label: 'Graphical Abstract',
54
+ files: getFigureFiles(figure, modelMap, files),
55
+ });
56
+ }
57
+ });
58
+ const figures = getModelsByType(modelMap, ObjectTypes.FigureElement);
59
+ const figureOrder = orders.get(ObjectTypes.FigureElement);
60
+ if (figureOrder) {
61
+ }
62
+ figures === null || figures === void 0 ? void 0 : figures.filter((f) => !(graphicalAbstractElementIds === null || graphicalAbstractElementIds === void 0 ? void 0 : graphicalAbstractElementIds.includes(f._id))).map((figure, index) => ({
63
+ modelId: figure._id,
64
+ type: FileType.Figure,
65
+ label: `Figure ${index + 1}`,
66
+ files: getFigureFiles(figure, modelMap, files),
67
+ })).forEach((e) => elements.push(e));
68
+ return elements;
69
+ };
70
+ export const getSupplements = (modelMap, files) => {
71
+ const supplements = getModelsByType(modelMap, ObjectTypes.Supplement);
72
+ return supplements.flatMap((s) => getSupplementFiles(s, files));
73
+ };
74
+ const getOrderByType = (modelMap) => {
75
+ const groups = new Map();
76
+ const orders = getModelsByType(modelMap, ObjectTypes.ElementsOrder);
77
+ orders.forEach((o) => groups.set(o.elementType, o));
78
+ return groups;
79
+ };
@@ -14,7 +14,6 @@ export declare const ProceedView: React.FC<{
14
14
  previousStepType: SubmissionStepType | undefined;
15
15
  currentStepType: SubmissionStepType;
16
16
  nextStepType: SubmissionStepType;
17
- confirmationDialog: boolean;
18
17
  onCancelClick: () => void;
19
18
  continueDialogAction: () => Promise<void>;
20
19
  message: React.FC<{
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { Move, Replace } from './FileManager';
3
+ import { FileSectionType } from './util';
4
+ export declare const FileActions: React.FC<{
5
+ sectionType: FileSectionType;
6
+ handleDownload?: () => void;
7
+ handleReplace?: Replace;
8
+ handleDetach?: () => void;
9
+ move?: Move;
10
+ className?: string;
11
+ }>;
12
+ export declare const ActionsIcon: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
13
+ export declare const FileActionDropdownList: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
14
+ direction?: "left" | "right" | undefined;
15
+ width?: number | undefined;
16
+ height?: number | undefined;
17
+ top?: number | undefined;
18
+ }, never>;
19
+ export declare const FileAction: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1 @@
1
+ export declare const FileContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare const FileCreatedDate: React.FC<{
4
+ file: FileAttachment;
5
+ className?: string;
6
+ }>;
7
+ export declare const FileDateContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
8
+ export declare const FileDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -1,22 +1,31 @@
1
1
  import { Model } from '@manuscripts/json-schema';
2
2
  import { Build } from '@manuscripts/transform';
3
3
  import React from 'react';
4
+ import { FileSectionType } from '../../index';
4
5
  import { Capabilities } from '../../lib/capabilities';
5
- import { FileAttachment } from './FileSectionItem/FileSectionItem';
6
- export type Upload = (file: File) => Promise<boolean | FileAttachment | undefined>;
7
- export type Replace = (attachmentId: string, name: string, file: File) => Promise<boolean | FileAttachment | undefined>;
6
+ import { FileAttachment } from '../../lib/files';
7
+ export type Upload = (file: File) => Promise<FileAttachment>;
8
+ export type Download = (file: FileAttachment) => void;
9
+ export type PreviewLink = (file: FileAttachment) => string | undefined;
10
+ export type Replace = (file: File) => Promise<void>;
11
+ export type Move = {
12
+ sectionType: FileSectionType;
13
+ handler: () => Promise<void>;
14
+ };
8
15
  export interface FileManagement {
9
- getAttachments: () => FileAttachment[];
10
16
  upload: Upload;
11
- replace: Replace;
17
+ download: Download;
18
+ previewLink: PreviewLink;
12
19
  }
20
+ export type SaveModel = <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
21
+ export type DeleteModel = (id: string) => Promise<string>;
13
22
  export declare const PermissionsContext: React.Context<Capabilities | null>;
14
23
  export declare const FileManager: React.FC<{
24
+ files: FileAttachment[];
15
25
  fileManagement: FileManagement;
16
26
  modelMap: Map<string, Model>;
17
- saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
18
- deleteModel: (id: string) => Promise<string>;
27
+ saveModel: SaveModel;
28
+ deleteModel: DeleteModel;
19
29
  enableDragAndDrop: boolean;
20
30
  can: Capabilities;
21
- addAttachmentToState?: (a: FileAttachment) => void;
22
31
  }>;
@@ -1,25 +1,15 @@
1
1
  import { Model } from '@manuscripts/json-schema';
2
- import { Build } from '@manuscripts/transform';
3
- import React, { Dispatch, SetStateAction } from 'react';
4
- import { FileAttachment } from './FileSectionItem/FileSectionItem';
5
- import { FileSectionType } from './util';
6
- type MoveFilePopup = {
7
- isOpen: boolean;
8
- fileSection?: FileSectionType;
9
- attachmentId?: string;
10
- };
2
+ import React from 'react';
3
+ import { DeleteModel, FileManagement, SaveModel } from './FileManager';
11
4
  export declare const FileManagerContext: React.Context<{
12
- saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
13
- deleteModel: (id: string) => Promise<string>;
5
+ saveModel: SaveModel;
6
+ deleteModel: DeleteModel;
14
7
  modelMap: Map<string, Model>;
15
- getAttachments: () => FileAttachment[];
16
- moveFilePopup: MoveFilePopup;
17
- setMoveFilePopupData: Dispatch<SetStateAction<MoveFilePopup>>;
8
+ fileManagement: FileManagement;
18
9
  }>;
19
10
  export declare const FileManagerProvider: React.FC<{
20
- saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
21
- deleteModel: (id: string) => Promise<string>;
11
+ saveModel: SaveModel;
12
+ deleteModel: DeleteModel;
22
13
  modelMap: Map<string, Model>;
23
- getAttachments: () => FileAttachment[];
14
+ fileManagement: FileManagement;
24
15
  }>;
25
- export {};
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare const FileName: React.FC<{
4
+ file: FileAttachment;
5
+ }>;
6
+ export declare const FileNameText: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export declare enum FileSectionAlertType {
3
+ NONE = 0,
4
+ UPLOAD_IN_PROGRESS = 1,
5
+ UPLOAD_SUCCESSFUL = 2,
6
+ MOVE_SUCCESSFUL = 3
7
+ }
8
+ export declare const FileSectionAlert: React.FC<{
9
+ alert: {
10
+ type: FileSectionAlertType;
11
+ message: string;
12
+ };
13
+ }>;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
2
3
  export declare const FileTypeIcon: React.FC<{
3
- withDot: boolean;
4
- fileExtension?: string;
5
- alt?: string;
4
+ file: FileAttachment;
6
5
  }>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const FileUploader: React.FC<{
3
+ handler: (file: File) => Promise<void>;
4
+ }>;
@@ -1,22 +1,6 @@
1
- import React, { Dispatch } from 'react';
2
- import { Replace } from './FileManager';
3
- import { FileAttachment } from './FileSectionItem/FileSectionItem';
4
- import { Action } from './FileSectionState';
5
- import { FileType } from './util';
1
+ import React from 'react';
2
+ import { ElementFiles } from '../../lib/files';
6
3
  export declare const InlineFilesSection: React.FC<{
7
- inlineFiles: {
8
- id: string;
9
- label: string;
10
- type: FileType;
11
- caption?: string;
12
- attachments?: FileAttachment[];
13
- }[];
14
- handleReplace: Replace;
15
- handleDownload: (url: string) => void;
16
- handleUpdateInline?: (modelId: string, attachment: FileAttachment) => void;
17
- handleDetachFile?: (attachmentLink: string, modelId: string) => void;
4
+ elements: ElementFiles[];
18
5
  isEditor: boolean;
19
- dispatch: Dispatch<Action>;
20
6
  }>;
21
- export declare const FileDateContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
22
- export declare const FileDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { FileAttachment } from '../../lib/files';
3
+ export declare const OtherFilesSection: React.FC<{
4
+ files: FileAttachment[];
5
+ }>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { ModelFile } from '../../lib/files';
3
+ export declare const SupplementsSection: React.FC<{
4
+ supplements: ModelFile[];
5
+ }>;
@@ -0,0 +1,2 @@
1
+ import ReactTooltip from 'react-tooltip';
2
+ export declare const Tooltip: import("styled-components").StyledComponent<typeof ReactTooltip, import("styled-components").DefaultTheme, {}, never>;
@@ -1,8 +1,8 @@
1
- import { FileAttachment } from './FileSectionItem/FileSectionItem';
1
+ import { FileAttachment } from '../../lib/files';
2
2
  export declare enum FileSectionType {
3
- Inline = 0,
4
- Supplements = 1,
5
- OtherFile = 2
3
+ Inline = "Inline files",
4
+ Supplements = "Supplements",
5
+ OtherFile = "Other files"
6
6
  }
7
7
  export declare enum FileType {
8
8
  Image = 0,
@@ -18,11 +18,7 @@ export declare enum FileType {
18
18
  Figure = 10,
19
19
  GraphicalAbstract = 11
20
20
  }
21
- export declare const extensionsWithFileTypesMap: Map<string, FileType>;
22
- export declare const fileTypesWithTitlesMap: Map<FileType | undefined, string>;
23
- export declare const fileTypesWithIconMap: Map<FileType | undefined, JSX.Element>;
24
- export declare const generateAttachmentsTitles: (externalFiles: FileAttachment[], fileSectionType: FileSectionType) => Array<{
25
- title: string;
26
- externalFile: FileAttachment;
27
- }>;
28
- export declare const droppableSections: FileSectionType[];
21
+ export declare const getFileType: (file: FileAttachment) => FileType | undefined;
22
+ export declare const getFileIcon: (file: FileAttachment) => JSX.Element | undefined;
23
+ export declare const getFileTypeIcon: (type: FileType) => JSX.Element | undefined;
24
+ export declare const isImageFile: (file: FileAttachment) => boolean;
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * © 2019 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 from 'react';
17
+ import { IconProps } from './types';
18
+ declare const CorruptedFileIcon: React.FC<IconProps>;
19
+ export default CorruptedFileIcon;
@@ -1,10 +1,8 @@
1
1
  import { Model } from '@manuscripts/json-schema';
2
- import { FileAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
3
- import { InlineFile } from '../lib/inlineFiles';
4
- type FilePredicate = (fileName: string) => boolean;
5
- export declare const useFiles: (modelMap: Map<string, Model>, attachments: FileAttachment[], filePredicate?: FilePredicate) => {
2
+ import { ElementFiles, FileAttachment, ModelFile } from '../lib/files';
3
+ export declare const useFiles: (modelMap: Map<string, Model>, files: FileAttachment[]) => {
4
+ inlineFiles: ElementFiles[];
5
+ supplements: ModelFile[];
6
6
  otherFiles: FileAttachment[];
7
- supplementFiles: FileAttachment[];
8
- inlineFiles: InlineFile[];
9
7
  };
10
8
  export default useFiles;
@@ -32,7 +32,6 @@ export * from './components/Checkbox';
32
32
  export * from './components/Form';
33
33
  export * from './components/FileManager';
34
34
  export * from './components/FileManager/util';
35
- export * from './components/FileManager/FileSectionItem/FileSectionItem';
36
35
  export * from './components/Resizer';
37
36
  export * from './components/SaveStatus';
38
37
  export * from './components/SimpleModal';
@@ -50,10 +49,11 @@ export * from './components/NavDropdown';
50
49
  export * from './components/SubmissionInspector';
51
50
  export * from './components/Dropdown';
52
51
  export * from './hooks/use-dropdown';
53
- export { useFiles } from './hooks/use-files';
52
+ export * from './hooks/use-files';
54
53
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
55
54
  export * from './lib/authors';
56
55
  export * from './lib/capabilities';
56
+ export * from './lib/files';
57
57
  export { default as errorsDecoder } from './lib/errors-decoder';
58
58
  export * from './types';
59
59
  export * from './components/LoadingOverlay';
@@ -38,6 +38,7 @@ export type Capabilities = {
38
38
  editMetadata: boolean;
39
39
  shareProject: boolean;
40
40
  editCitationsAndRefs: boolean;
41
+ applySaveChanges: boolean;
41
42
  };
42
43
  export interface ProviderProps {
43
44
  project?: Project;
@@ -0,0 +1,24 @@
1
+ import { Model } from '@manuscripts/json-schema';
2
+ import { FileType } from '../components/FileManager/util';
3
+ export type FileDesignation = {
4
+ id: string;
5
+ label?: string;
6
+ };
7
+ export type FileAttachment = {
8
+ id: string;
9
+ name: string;
10
+ type: FileDesignation;
11
+ createdDate?: Date;
12
+ };
13
+ export type ModelFile = FileAttachment & {
14
+ modelId: string;
15
+ };
16
+ export type ElementFiles = {
17
+ modelId: string;
18
+ label: string;
19
+ type: FileType;
20
+ files: ModelFile[];
21
+ };
22
+ export declare const isModelFile: (file: FileAttachment) => file is ModelFile;
23
+ export declare const getInlineFiles: (modelMap: Map<string, Model>, files: FileAttachment[]) => ElementFiles[];
24
+ export declare const getSupplements: (modelMap: Map<string, Model>, files: FileAttachment[]) => ModelFile[];
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.3.5",
4
+ "version": "1.3.6-LEAN-2705",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -20,7 +20,7 @@
20
20
  "build:es": "tsc --outDir dist/es --declarationDir dist/types --declaration",
21
21
  "build-storybook": "build-storybook",
22
22
  "dev": "npm-run-all --parallel 'build:* --project tsconfig.build.json --watch'",
23
- "lint": "eslint src stories --ext .ts,.tsx --max-warnings=0",
23
+ "lint": "eslint src --ext .ts,.tsx --max-warnings=0",
24
24
  "lint:fix": "eslint src stories --fix --ext .ts,.tsx --max-warnings=0",
25
25
  "prebuild": "rimraf dist",
26
26
  "prettier": "prettier --write \"{src,stories}/**/*.{ts,tsx}\"",
@@ -141,4 +141,4 @@
141
141
  "resolutions": {
142
142
  "@types/react": "^17.0.2"
143
143
  }
144
- }
144
+ }