@manuscripts/style-guide 1.3.2-LEAN-2859-2 → 1.3.2-LEAN-2880-1

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 (102) hide show
  1. package/dist/cjs/components/FileManager/ConfirmationPopUp.js +90 -0
  2. package/dist/cjs/components/FileManager/DragItemArea.js +28 -0
  3. package/dist/cjs/components/FileManager/FileManager.js +125 -14
  4. package/dist/cjs/components/FileManager/FileManagerProvider.js +7 -2
  5. package/dist/cjs/components/FileManager/{DragLayer.js → FileSectionItem/DragLayer.js} +10 -12
  6. package/dist/cjs/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +76 -0
  7. package/dist/cjs/components/FileManager/FileSectionItem/FileInfo.js +115 -0
  8. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionItem.js +95 -0
  9. package/dist/cjs/components/FileManager/FileSectionItem/FileSectionUploadItem.js +37 -0
  10. package/dist/cjs/components/FileManager/FileSectionItem/FileTypeIcon.js +53 -0
  11. package/dist/cjs/components/FileManager/FileSectionItem/ItemActions.js +92 -0
  12. package/dist/cjs/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +120 -0
  13. package/dist/cjs/components/FileManager/FileSectionState.js +83 -0
  14. package/dist/cjs/components/FileManager/FilesSection.js +61 -0
  15. package/dist/cjs/components/FileManager/InlineFilesSection.js +123 -64
  16. package/dist/cjs/components/FileManager/ItemsAction.js +48 -0
  17. package/dist/cjs/components/FileManager/{Tooltip.js → TooltipDiv.js} +3 -8
  18. package/dist/cjs/components/FileManager/{FileUploader.js → UploadFileArea.js} +12 -19
  19. package/dist/cjs/components/FileManager/util.js +67 -52
  20. package/dist/cjs/components/icons/document-icon-with-dot.js +1 -1
  21. package/dist/cjs/hooks/use-deep-compare.js +2 -2
  22. package/dist/cjs/hooks/use-files.js +43 -29
  23. package/dist/cjs/index.js +4 -3
  24. package/dist/cjs/lib/inlineFiles.js +92 -0
  25. package/dist/es/components/FileManager/ConfirmationPopUp.js +62 -0
  26. package/dist/es/components/FileManager/DragItemArea.js +21 -0
  27. package/dist/es/components/FileManager/FileManager.js +124 -16
  28. package/dist/es/components/FileManager/FileManagerProvider.js +8 -3
  29. package/dist/es/components/FileManager/{DragLayer.js → FileSectionItem/DragLayer.js} +10 -12
  30. package/dist/es/components/FileManager/FileSectionItem/DraggableFileSectionItem.js +46 -0
  31. package/dist/es/components/FileManager/FileSectionItem/FileInfo.js +85 -0
  32. package/dist/es/components/FileManager/FileSectionItem/FileSectionItem.js +88 -0
  33. package/dist/es/components/FileManager/FileSectionItem/FileSectionUploadItem.js +30 -0
  34. package/dist/es/components/FileManager/FileSectionItem/FileTypeIcon.js +46 -0
  35. package/dist/es/components/FileManager/FileSectionItem/ItemActions.js +65 -0
  36. package/dist/es/components/FileManager/FileSectionItem/ProgressBarUploadItem.js +113 -0
  37. package/dist/es/components/FileManager/FileSectionState.js +78 -0
  38. package/dist/es/components/FileManager/FilesSection.js +34 -0
  39. package/dist/es/components/FileManager/InlineFilesSection.js +124 -65
  40. package/dist/es/components/FileManager/ItemsAction.js +42 -0
  41. package/dist/es/components/FileManager/{Tooltip.js → TooltipDiv.js} +2 -7
  42. package/dist/es/components/FileManager/{FileUploader.js → UploadFileArea.js} +10 -17
  43. package/dist/es/components/FileManager/util.js +65 -47
  44. package/dist/es/components/icons/document-icon-with-dot.js +1 -1
  45. package/dist/es/hooks/use-deep-compare.js +2 -2
  46. package/dist/es/hooks/use-files.js +40 -29
  47. package/dist/es/index.js +2 -2
  48. package/dist/es/lib/inlineFiles.js +90 -0
  49. package/dist/types/components/FileManager/ConfirmationPopUp.d.ts +12 -0
  50. package/dist/types/components/FileManager/DragItemArea.d.ts +4 -0
  51. package/dist/types/components/FileManager/FileManager.d.ts +8 -17
  52. package/dist/types/components/FileManager/FileManagerProvider.d.ts +18 -8
  53. package/dist/types/components/FileManager/FileSectionItem/DraggableFileSectionItem.d.ts +3 -0
  54. package/dist/types/components/FileManager/FileSectionItem/FileInfo.d.ts +19 -0
  55. package/dist/types/components/FileManager/FileSectionItem/FileSectionItem.d.ts +38 -0
  56. package/dist/types/components/FileManager/FileSectionItem/FileSectionUploadItem.d.ts +12 -0
  57. package/dist/types/components/FileManager/{FileTypeIcon.d.ts → FileSectionItem/FileTypeIcon.d.ts} +3 -2
  58. package/dist/types/components/FileManager/FileSectionItem/ItemActions.d.ts +21 -0
  59. package/dist/types/components/FileManager/FileSectionItem/ProgressBarUploadItem.d.ts +4 -0
  60. package/dist/types/components/FileManager/FileSectionState.d.ts +38 -0
  61. package/dist/types/components/FileManager/FilesSection.d.ts +12 -0
  62. package/dist/types/components/FileManager/InlineFilesSection.d.ts +19 -3
  63. package/dist/types/components/FileManager/ItemsAction.d.ts +4 -0
  64. package/dist/types/components/FileManager/TooltipDiv.d.ts +1 -0
  65. package/dist/types/components/FileManager/UploadFileArea.d.ts +9 -0
  66. package/dist/types/components/FileManager/util.d.ts +12 -8
  67. package/dist/types/hooks/use-files.d.ts +6 -4
  68. package/dist/types/index.d.ts +2 -2
  69. package/dist/types/lib/inlineFiles.d.ts +11 -0
  70. package/package.json +2 -2
  71. package/dist/cjs/components/FileManager/FileActions.js +0 -135
  72. package/dist/cjs/components/FileManager/FileContainer.js +0 -38
  73. package/dist/cjs/components/FileManager/FileCreatedDate.js +0 -25
  74. package/dist/cjs/components/FileManager/FileName.js +0 -27
  75. package/dist/cjs/components/FileManager/FileSectionAlert.js +0 -170
  76. package/dist/cjs/components/FileManager/FileTypeIcon.js +0 -22
  77. package/dist/cjs/components/FileManager/OtherFilesSection.js +0 -101
  78. package/dist/cjs/components/FileManager/SupplementsSection.js +0 -118
  79. package/dist/cjs/components/icons/corrupted-file-icon.js +0 -27
  80. package/dist/cjs/lib/files.js +0 -85
  81. package/dist/es/components/FileManager/FileActions.js +0 -105
  82. package/dist/es/components/FileManager/FileContainer.js +0 -32
  83. package/dist/es/components/FileManager/FileCreatedDate.js +0 -18
  84. package/dist/es/components/FileManager/FileName.js +0 -20
  85. package/dist/es/components/FileManager/FileSectionAlert.js +0 -163
  86. package/dist/es/components/FileManager/FileTypeIcon.js +0 -15
  87. package/dist/es/components/FileManager/OtherFilesSection.js +0 -74
  88. package/dist/es/components/FileManager/SupplementsSection.js +0 -91
  89. package/dist/es/components/icons/corrupted-file-icon.js +0 -22
  90. package/dist/es/lib/files.js +0 -79
  91. package/dist/types/components/FileManager/FileActions.d.ts +0 -19
  92. package/dist/types/components/FileManager/FileContainer.d.ts +0 -1
  93. package/dist/types/components/FileManager/FileCreatedDate.d.ts +0 -8
  94. package/dist/types/components/FileManager/FileName.d.ts +0 -6
  95. package/dist/types/components/FileManager/FileSectionAlert.d.ts +0 -13
  96. package/dist/types/components/FileManager/FileUploader.d.ts +0 -4
  97. package/dist/types/components/FileManager/OtherFilesSection.d.ts +0 -5
  98. package/dist/types/components/FileManager/SupplementsSection.d.ts +0 -5
  99. package/dist/types/components/FileManager/Tooltip.d.ts +0 -2
  100. package/dist/types/components/icons/corrupted-file-icon.d.ts +0 -19
  101. package/dist/types/lib/files.d.ts +0 -24
  102. /package/dist/types/components/FileManager/{DragLayer.d.ts → FileSectionItem/DragLayer.d.ts} +0 -0
@@ -0,0 +1,90 @@
1
+ import { ObjectTypes, } from '@manuscripts/json-schema';
2
+ import { hasObjectType } from '@manuscripts/transform';
3
+ import { FileType } from '../components/FileManager/util';
4
+ const getFigureData = (element, modelMap, attachmentsMap) => {
5
+ const attachments = [];
6
+ element.containedObjectIDs.map((id) => {
7
+ const object = modelMap.get(id);
8
+ if (object && object.objectType === ObjectTypes.Figure) {
9
+ const figure = object;
10
+ if (figure.src) {
11
+ const attachment = attachmentsMap.get(figure.src.replace('attachment:', ''));
12
+ if (attachment) {
13
+ attachment.modelId = id;
14
+ attachments.push(attachment);
15
+ }
16
+ }
17
+ }
18
+ });
19
+ return {
20
+ id: element._id,
21
+ attachments,
22
+ };
23
+ };
24
+ export default (modelMap, attachments) => {
25
+ const files = [];
26
+ const attachmentsMap = new Map(attachments.map((attachment) => [attachment.id, attachment]));
27
+ const { graphicalAbstractFigureId, figureElement } = getAuxiliaryObjects(modelMap);
28
+ if (graphicalAbstractFigureId) {
29
+ const element = modelMap.get(graphicalAbstractFigureId);
30
+ files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Graphical Abstract`, type: FileType.GraphicalAbstract }));
31
+ }
32
+ figureElement.map((id, index) => {
33
+ const element = modelMap.get(id);
34
+ files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Figure ${index + 1}`, type: FileType.Figure }));
35
+ });
36
+ return files;
37
+ };
38
+ const getAuxiliaryObjects = (modelMap) => {
39
+ var _a, _b;
40
+ let graphicalAbstractFigureId, figureElementIds = [];
41
+ const tableElementIds = [], orderObjects = {};
42
+ for (const model of modelMap.values()) {
43
+ switch (model.objectType) {
44
+ case ObjectTypes.Section: {
45
+ const section = model;
46
+ if (section.category === 'MPSectionCategory:abstract-graphical') {
47
+ graphicalAbstractFigureId = (_a = section.elementIDs) === null || _a === void 0 ? void 0 : _a.find((id) => {
48
+ const obj = modelMap.get(id);
49
+ return obj && hasObjectType(ObjectTypes.FigureElement)(obj);
50
+ });
51
+ }
52
+ else {
53
+ (_b = section.elementIDs) === null || _b === void 0 ? void 0 : _b.map((elementId) => {
54
+ const element = modelMap.get(elementId);
55
+ if (!element) {
56
+ return;
57
+ }
58
+ switch (element.objectType) {
59
+ case ObjectTypes.FigureElement:
60
+ figureElementIds.push(element._id);
61
+ break;
62
+ case ObjectTypes.TableElement:
63
+ tableElementIds.push(element._id);
64
+ break;
65
+ }
66
+ });
67
+ }
68
+ break;
69
+ }
70
+ case ObjectTypes.ElementsOrder: {
71
+ const elementsOrder = model;
72
+ orderObjects[elementsOrder.elementType] = elementsOrder;
73
+ }
74
+ }
75
+ }
76
+ if (graphicalAbstractFigureId) {
77
+ figureElementIds = figureElementIds.filter((id) => id != graphicalAbstractFigureId);
78
+ }
79
+ return {
80
+ graphicalAbstractFigureId,
81
+ figureElement: sortAuxiliaryObject(figureElementIds, orderObjects[ObjectTypes.FigureElement]),
82
+ tableElement: sortAuxiliaryObject(tableElementIds, orderObjects[ObjectTypes.TableElement]),
83
+ };
84
+ };
85
+ const sortAuxiliaryObject = (auxiliaryObjectIds, orderObject) => {
86
+ if (!orderObject) {
87
+ return auxiliaryObjectIds;
88
+ }
89
+ return auxiliaryObjectIds.sort((a, b) => orderObject.elements.indexOf(a) - orderObject.elements.indexOf(b));
90
+ };
@@ -0,0 +1,12 @@
1
+ import React, { Dispatch } from 'react';
2
+ import { Action } from './FileSectionState';
3
+ export declare const ConfirmationPopUp: React.FC<{
4
+ popupHeader: string;
5
+ popUpMessage: string;
6
+ isOpen: boolean;
7
+ handleClose: () => void;
8
+ handleMove: () => void;
9
+ }>;
10
+ export declare const MoveFilePopup: React.FC<{
11
+ dispatch: Dispatch<Action>;
12
+ }>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const DragItemArea: React.FC<{
3
+ text: string;
4
+ }>;
@@ -1,31 +1,22 @@
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';
5
4
  import { Capabilities } from '../../lib/capabilities';
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
- };
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>;
15
8
  export interface FileManagement {
9
+ getAttachments: () => FileAttachment[];
16
10
  upload: Upload;
17
- download: Download;
18
- previewLink: PreviewLink;
11
+ replace: Replace;
19
12
  }
20
- export type SaveModel = <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
21
- export type DeleteModel = (id: string) => Promise<string>;
22
13
  export declare const PermissionsContext: React.Context<Capabilities | null>;
23
14
  export declare const FileManager: React.FC<{
24
- files: FileAttachment[];
25
15
  fileManagement: FileManagement;
26
16
  modelMap: Map<string, Model>;
27
- saveModel: SaveModel;
28
- deleteModel: DeleteModel;
17
+ saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
18
+ deleteModel: (id: string) => Promise<string>;
29
19
  enableDragAndDrop: boolean;
30
20
  can: Capabilities;
21
+ addAttachmentToState?: (a: FileAttachment) => void;
31
22
  }>;
@@ -1,15 +1,25 @@
1
1
  import { Model } from '@manuscripts/json-schema';
2
- import React from 'react';
3
- import { DeleteModel, FileManagement, SaveModel } from './FileManager';
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
+ };
4
11
  export declare const FileManagerContext: React.Context<{
5
- saveModel: SaveModel;
6
- deleteModel: DeleteModel;
12
+ saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
13
+ deleteModel: (id: string) => Promise<string>;
7
14
  modelMap: Map<string, Model>;
8
- fileManagement: FileManagement;
15
+ getAttachments: () => FileAttachment[];
16
+ moveFilePopup: MoveFilePopup;
17
+ setMoveFilePopupData: Dispatch<SetStateAction<MoveFilePopup>>;
9
18
  }>;
10
19
  export declare const FileManagerProvider: React.FC<{
11
- saveModel: SaveModel;
12
- deleteModel: DeleteModel;
20
+ saveModel: <T extends Model>(model: T | Build<T> | Partial<T>) => Promise<T>;
21
+ deleteModel: (id: string) => Promise<string>;
13
22
  modelMap: Map<string, Model>;
14
- fileManagement: FileManagement;
23
+ getAttachments: () => FileAttachment[];
15
24
  }>;
25
+ export {};
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { FileSectionItemProps } from './FileSectionItem';
3
+ export declare const DraggableFileSectionItem: React.FC<FileSectionItemProps>;
@@ -0,0 +1,19 @@
1
+ import React, { Dispatch } from 'react';
2
+ import { Action } from '../FileSectionState';
3
+ export declare const FileInfo: React.FC<{
4
+ showAttachmentName: boolean;
5
+ title: string;
6
+ fileAttachmentName: string;
7
+ fileExtension: string;
8
+ attachmentId: string;
9
+ fileCreatedDate: Date;
10
+ dispatch?: Dispatch<Action>;
11
+ }>;
12
+ export declare const FileDateContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
13
+ export declare const FileInfoContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
14
+ export declare const FileNameTitleContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
15
+ export declare const FileTitle: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
16
+ export declare const FileNameContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
17
+ export declare const FileName: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
18
+ export declare const FileDate: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
19
+ export declare const FileDescription: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,38 @@
1
+ import React, { CSSProperties, Dispatch } from 'react';
2
+ import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
3
+ import { Maybe } from '../../SubmissionInspector/types';
4
+ import { Replace } from '../FileManager';
5
+ import { Action } from '../FileSectionState';
6
+ import { FileSectionType } from '../util';
7
+ export type FileAttachment = {
8
+ id: string;
9
+ name: string;
10
+ type: FileAttachmentType;
11
+ link: string;
12
+ createdDate: Date;
13
+ };
14
+ export type FileAttachmentType = {
15
+ id: string;
16
+ label?: Maybe<string> | undefined;
17
+ };
18
+ export interface FileSectionItemProps {
19
+ externalFile: FileAttachment;
20
+ fileSection: FileSectionType;
21
+ title: string;
22
+ showAttachmentName?: boolean;
23
+ showActions?: boolean;
24
+ showReplaceAction?: boolean;
25
+ handleDownload?: (url: string) => void;
26
+ handleReplace?: Replace;
27
+ handleSupplementReplace?: (attachment: FileAttachment, oldAttachmentId: string) => void;
28
+ dispatch?: Dispatch<Action>;
29
+ dragRef?: DragElementWrapper<DragSourceOptions>;
30
+ className?: string;
31
+ style?: CSSProperties;
32
+ onClose?: () => void;
33
+ isEditor?: boolean;
34
+ }
35
+ export declare const FileSectionItem: React.FC<FileSectionItemProps>;
36
+ export declare const ActionsIcon: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, {}, never>;
37
+ export declare const Item: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
38
+ export declare const ItemContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,12 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import { DragElementWrapper, DragSourceOptions } from 'react-dnd';
3
+ export interface FileSectionItemProps {
4
+ fileName: string;
5
+ isLoading: boolean;
6
+ dragRef?: DragElementWrapper<DragSourceOptions>;
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ }
10
+ export declare const FileSectionUploadItem: React.FC<FileSectionItemProps>;
11
+ export declare const UploadItemContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
12
+ export declare const ProgressBar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { FileAttachment } from '../../lib/files';
3
2
  export declare const FileTypeIcon: React.FC<{
4
- file: FileAttachment;
3
+ withDot: boolean;
4
+ fileExtension?: string;
5
+ alt?: string;
5
6
  }>;
@@ -0,0 +1,21 @@
1
+ import React, { Dispatch } from 'react';
2
+ import { Replace } from '../FileManager';
3
+ import { Action } from '../FileSectionState';
4
+ import { FileSectionType } from '../util';
5
+ import { FileAttachment } from './FileSectionItem';
6
+ export declare const ItemActions: React.FC<{
7
+ fileSection: FileSectionType;
8
+ isMainManuscript?: boolean;
9
+ downloadAttachmentHandler: (url: string) => void;
10
+ replaceAttachmentHandler: Replace;
11
+ detachAttachmnetHandler?: () => void;
12
+ handleUpdateInline?: (attachment: FileAttachment) => void;
13
+ handleSupplementReplace?: (attachment: FileAttachment, oldAttachmentId: string) => void;
14
+ attachmentId: string;
15
+ fileName: string;
16
+ publicUrl: string | undefined;
17
+ hideActionList: (e?: React.MouseEvent) => void;
18
+ dispatch?: Dispatch<Action>;
19
+ dropDownClassName?: string;
20
+ showReplaceAction?: boolean;
21
+ }>;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const ProgressBarUploadItem: React.FC;
3
+ export declare const LinearProgress: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const Bar: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,38 @@
1
+ import { FileSectionType } from './util';
2
+ export declare const getInitialState: () => State;
3
+ export interface State {
4
+ uploadedFile: File | undefined;
5
+ isUploadFile: boolean;
6
+ moveToOtherState: {
7
+ typeId: string;
8
+ name: string;
9
+ } | undefined;
10
+ fileUploadedSuccessfullySection: FileSectionType | undefined;
11
+ successMessage: string;
12
+ isShowSuccessMessage: boolean;
13
+ currentSection: FileSectionType | undefined;
14
+ }
15
+ declare enum ActionTypes {
16
+ UPLOAD_FILE = "UploadFile",
17
+ MOVE_FILE = "moveFile",
18
+ HANDLE_CANCEL_UPLOAD = "handleCancel",
19
+ HANDLE_UPLOAD_ACTION = "handleUpload",
20
+ HANDLE_FINISH_UPLOAD = "handleFinishUpload",
21
+ HANDLE_SUCCESS_MESSAGE = "handleSuccessMessage",
22
+ HANDLE_SUCCESS_MESSAGE_DISMISS = "handleSuccessMessageDismiss"
23
+ }
24
+ export declare const reducer: (state: State, action: Action) => State;
25
+ export interface Action {
26
+ type: ActionTypes;
27
+ [key: string]: any;
28
+ }
29
+ export declare const actions: {
30
+ UPLOAD_FILE: (uploadFile: File, sectionType: FileSectionType) => Action;
31
+ HANDLE_UPLOAD_ACTION: () => Action;
32
+ HANDLE_CANCEL_UPLOAD: () => Action;
33
+ MOVE_FILE: (attachmentId: string, typeId: string, name: string, successMoveMessage: string) => Action;
34
+ HANDLE_FINISH_UPLOAD: () => Action;
35
+ HANDLE_SUCCESS_MESSAGE: (successMessage: string, sectionType?: FileSectionType) => Action;
36
+ HANDLE_SUCCESS_MESSAGE_DISMISS: () => Action;
37
+ };
38
+ export {};
@@ -0,0 +1,12 @@
1
+ import React, { Dispatch } from 'react';
2
+ import { Upload } from './FileManager';
3
+ import { Action, State } from './FileSectionState';
4
+ import { FileSectionType } from './util';
5
+ export declare const FilesSection: React.FC<{
6
+ enableDragAndDrop: boolean;
7
+ handleUpload: Upload;
8
+ fileSection: FileSectionType;
9
+ filesItem: JSX.Element[];
10
+ dispatch: Dispatch<Action>;
11
+ state: State;
12
+ }>;
@@ -1,6 +1,22 @@
1
- import React from 'react';
2
- import { ElementFiles } from '../../lib/files';
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';
3
6
  export declare const InlineFilesSection: React.FC<{
4
- elements: ElementFiles[];
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;
5
18
  isEditor: boolean;
19
+ dispatch: Dispatch<Action>;
6
20
  }>;
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,4 @@
1
+ export declare const ActionsBox: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const ActionsItem: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const ActionsLabel: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const ActionsSeparator: import("styled-components").StyledComponent<"li", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1 @@
1
+ export declare const TooltipDiv: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,9 @@
1
+ import React, { Dispatch } from 'react';
2
+ import { Upload } from './FileManager';
3
+ import { Action } from './FileSectionState';
4
+ import { FileSectionType } from './util';
5
+ export declare const UploadFileArea: React.FC<{
6
+ handleUploadFile: Upload;
7
+ fileSection: FileSectionType;
8
+ dispatch: Dispatch<Action>;
9
+ }>;
@@ -1,8 +1,8 @@
1
- import { FileAttachment } from '../../lib/files';
1
+ import { FileAttachment } from './FileSectionItem/FileSectionItem';
2
2
  export declare enum FileSectionType {
3
- Inline = "Inline files",
4
- Supplements = "Supplements",
5
- OtherFile = "Other files"
3
+ Inline = 0,
4
+ Supplements = 1,
5
+ OtherFile = 2
6
6
  }
7
7
  export declare enum FileType {
8
8
  Image = 0,
@@ -18,7 +18,11 @@ export declare enum FileType {
18
18
  Figure = 10,
19
19
  GraphicalAbstract = 11
20
20
  }
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;
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[];
@@ -1,8 +1,10 @@
1
1
  import { Model } from '@manuscripts/json-schema';
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[];
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) => {
6
6
  otherFiles: FileAttachment[];
7
+ supplementFiles: FileAttachment[];
8
+ inlineFiles: InlineFile[];
7
9
  };
8
10
  export default useFiles;
@@ -32,6 +32,7 @@ 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';
35
36
  export * from './components/Resizer';
36
37
  export * from './components/SaveStatus';
37
38
  export * from './components/SimpleModal';
@@ -49,11 +50,10 @@ export * from './components/NavDropdown';
49
50
  export * from './components/SubmissionInspector';
50
51
  export * from './components/Dropdown';
51
52
  export * from './hooks/use-dropdown';
52
- export * from './hooks/use-files';
53
+ export { useFiles } from './hooks/use-files';
53
54
  export { useDeepCompareMemo, useDeepCompareCallback, } from './hooks/use-deep-compare';
54
55
  export * from './lib/authors';
55
56
  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';
@@ -0,0 +1,11 @@
1
+ import { Model } from '@manuscripts/json-schema';
2
+ import { FileAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
3
+ import { FileType } from '../components/FileManager/util';
4
+ export type InlineFile = {
5
+ id: string;
6
+ label: string;
7
+ type: FileType;
8
+ attachments?: FileAttachment[];
9
+ };
10
+ declare const _default: (modelMap: Map<string, Model>, attachments: FileAttachment[]) => InlineFile[];
11
+ export default _default;
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.2-LEAN-2859-2",
4
+ "version": "1.3.2-LEAN-2880-1",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -36,7 +36,7 @@
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.12",
39
+ "@manuscripts/transform": "1.3.12-LEAN-2880-6",
40
40
  "@manuscripts/json-schema": "^2.1.2",
41
41
  "@manuscripts/title-editor": "^1.1.0",
42
42
  "@manuscripts/comment-editor": "^1.0.3",
@@ -1,135 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.FileAction = exports.FileActionDropdownList = exports.ActionsIcon = exports.FileActions = void 0;
39
- const react_1 = __importStar(require("react"));
40
- const styled_components_1 = __importDefault(require("styled-components"));
41
- const use_dropdown_1 = require("../../hooks/use-dropdown");
42
- const Dialog_1 = require("../Dialog");
43
- const Dropdown_1 = require("../Dropdown");
44
- const dots_icon_1 = __importDefault(require("../icons/dots-icon"));
45
- const FileManager_1 = require("./FileManager");
46
- const FileActions = ({ sectionType, handleDownload, handleReplace, handleDetach, move, className, }) => {
47
- const can = (0, react_1.useContext)(FileManager_1.PermissionsContext);
48
- const { isOpen, toggleOpen, wrapperRef } = (0, use_dropdown_1.useDropdown)();
49
- const [isMoveDialogOpen, setMoveDialogOpen] = (0, react_1.useState)(false);
50
- const showDownload = (can === null || can === void 0 ? void 0 : can.downloadFiles) && handleDownload;
51
- const showReplace = (can === null || can === void 0 ? void 0 : can.replaceFile) && handleReplace;
52
- const showDetach = (can === null || can === void 0 ? void 0 : can.editArticle) && handleDetach;
53
- const showMove = (can === null || can === void 0 ? void 0 : can.editArticle) && move;
54
- const show = showDownload || showReplace || showDetach || showMove;
55
- const fileInputRef = (0, react_1.useRef)(null);
56
- const handleChange = (event) => __awaiter(void 0, void 0, void 0, function* () {
57
- if (handleReplace && event && event.target && event.target.files) {
58
- const file = event.target.files[0];
59
- yield handleReplace(file);
60
- }
61
- });
62
- const openFileDialog = () => {
63
- if (fileInputRef && fileInputRef.current) {
64
- fileInputRef.current.click();
65
- }
66
- };
67
- return show ? (react_1.default.createElement(Dropdown_1.DropdownContainer, { ref: wrapperRef },
68
- react_1.default.createElement(exports.ActionsIcon, { onClick: toggleOpen, type: "button", className: "show-on-hover", "aria-label": "Actions", "aria-pressed": isOpen },
69
- react_1.default.createElement(dots_icon_1.default, null)),
70
- isOpen && (react_1.default.createElement(exports.FileActionDropdownList, { direction: "right", className: className, width: 192, top: 5, onClick: toggleOpen },
71
- showDownload && (react_1.default.createElement(exports.FileAction, { onClick: handleDownload }, "Download")),
72
- showReplace && (react_1.default.createElement(react_1.default.Fragment, null,
73
- react_1.default.createElement(exports.FileAction, { onClick: openFileDialog }, "Replace"),
74
- react_1.default.createElement("input", { ref: fileInputRef, type: "file", style: { display: 'none' }, onChange: handleChange }))),
75
- showDetach && react_1.default.createElement(exports.FileAction, { onClick: handleDetach }, "Detach"),
76
- showMove && (react_1.default.createElement(exports.FileAction, { onClick: () => setMoveDialogOpen(true) },
77
- "Move to ",
78
- move.sectionType)))),
79
- showMove && (react_1.default.createElement(MoveFileConfirmationDialog, { isOpen: isMoveDialogOpen, close: () => setMoveDialogOpen(false), source: sectionType, target: move.sectionType, handleMove: move.handler })))) : (react_1.default.createElement(react_1.default.Fragment, null));
80
- };
81
- exports.FileActions = FileActions;
82
- const MoveFileConfirmationDialog = ({ isOpen, close, source, target, handleMove }) => {
83
- const header = `Are you sure you want to move this file to “${target}”?`;
84
- const message = `The file will be removed from “${source}” and added to “${target}”.`;
85
- const handleConfirm = () => __awaiter(void 0, void 0, void 0, function* () {
86
- yield handleMove();
87
- close();
88
- });
89
- return (react_1.default.createElement(Dialog_1.Dialog, { isOpen: isOpen, category: Dialog_1.Category.confirmation, header: header, message: message, actions: {
90
- primary: {
91
- action: handleConfirm,
92
- title: 'Move',
93
- },
94
- secondary: {
95
- action: () => close(),
96
- title: 'Cancel',
97
- },
98
- } }));
99
- };
100
- exports.ActionsIcon = styled_components_1.default.button `
101
- visibility: hidden;
102
- border: none;
103
- background: transparent;
104
- cursor: pointer;
105
- padding: 0 8px;
106
- &:focus {
107
- outline: none;
108
- }
109
- &:hover svg circle {
110
- fill: #1a9bc7;
111
- }
112
- `;
113
- exports.FileActionDropdownList = (0, styled_components_1.default)(Dropdown_1.DropdownList) `
114
- border: 1px solid #e2e2e2;
115
- box-sizing: border-box;
116
- box-shadow: 0 4px 9px rgba(0, 0, 0, 0.3);
117
- border-radius: 8px;
118
- min-width: 180px;
119
- background: ${(props) => props.theme.colors.background.primary};
120
- z-index: 999;
121
- text-align: left;
122
- overflow: hidden;
123
- `;
124
- exports.FileAction = styled_components_1.default.div `
125
- font-family: ${(props) => props.theme.font.family.Lato};
126
- cursor: pointer;
127
- font-size: 16px;
128
- line-height: 24px;
129
- color: ${(props) => props.theme.colors.text.primary};
130
- padding: 16px;
131
- &:hover,
132
- &:focus {
133
- background: #f2fbfc;
134
- }
135
- `;