@manuscripts/style-guide 0.30.26 → 0.31.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 (42) hide show
  1. package/dist/cjs/components/FileManager/FileManager.js +14 -2
  2. package/dist/cjs/components/FileManager/InlineFilesSection.js +8 -10
  3. package/dist/cjs/components/Resizer/Resizer.js +109 -0
  4. package/dist/cjs/components/Resizer/ResizerButton.js +30 -0
  5. package/dist/cjs/components/Resizer/ResizerButtonInner.js +169 -0
  6. package/dist/cjs/components/Resizer/ResizerInner.js +74 -0
  7. package/dist/cjs/components/Resizer/index.js +16 -0
  8. package/dist/cjs/components/Resizer/types.js +2 -0
  9. package/dist/cjs/components/icons/attach.js +2 -4
  10. package/dist/cjs/components/icons/index.js +3 -1
  11. package/dist/cjs/components/icons/missing-image.js +12 -0
  12. package/dist/cjs/components/icons/upload.js +4 -6
  13. package/dist/cjs/index.js +1 -0
  14. package/dist/cjs/lib/inlineFiles.js +23 -11
  15. package/dist/es/components/FileManager/FileManager.js +15 -3
  16. package/dist/es/components/FileManager/InlineFilesSection.js +11 -13
  17. package/dist/es/components/Resizer/Resizer.js +102 -0
  18. package/dist/es/components/Resizer/ResizerButton.js +23 -0
  19. package/dist/es/components/Resizer/ResizerButtonInner.js +163 -0
  20. package/dist/es/components/Resizer/ResizerInner.js +68 -0
  21. package/dist/es/components/Resizer/index.js +2 -0
  22. package/dist/es/components/Resizer/types.js +1 -0
  23. package/dist/es/components/icons/attach.js +2 -4
  24. package/dist/es/components/icons/index.js +1 -0
  25. package/dist/es/components/icons/missing-image.js +7 -0
  26. package/dist/es/components/icons/upload.js +4 -6
  27. package/dist/es/index.js +1 -0
  28. package/dist/es/lib/inlineFiles.js +23 -11
  29. package/dist/types/components/FileManager/InlineFilesSection.d.ts +10 -3
  30. package/dist/types/components/Resizer/Resizer.d.ts +36 -0
  31. package/dist/types/components/Resizer/ResizerButton.d.ts +18 -0
  32. package/dist/types/components/Resizer/ResizerButtonInner.d.ts +8 -0
  33. package/dist/types/components/Resizer/ResizerInner.d.ts +4 -0
  34. package/dist/types/components/Resizer/index.d.ts +2 -0
  35. package/dist/types/components/Resizer/types.d.ts +2 -0
  36. package/dist/types/components/icons/attach.d.ts +1 -1
  37. package/dist/types/components/icons/index.d.ts +1 -0
  38. package/dist/types/components/icons/missing-image.d.ts +3 -0
  39. package/dist/types/components/icons/upload.d.ts +1 -1
  40. package/dist/types/index.d.ts +1 -0
  41. package/dist/types/lib/inlineFiles.d.ts +3 -3
  42. package/package.json +1 -1
@@ -4,33 +4,44 @@ import { FileType } from '../components/FileManager/util';
4
4
  const getCaptionText = (caption) => caption &&
5
5
  new DOMParser().parseFromString(caption, 'text/html').documentElement
6
6
  .innerText;
7
- const getFigureData = (element, modelMap) => {
8
- const externalFileReferences = [];
7
+ const getAttachment = (externalFileRef, attachmentsMap) => {
8
+ if (!(externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.includes('https://'))) {
9
+ const attachmentId = externalFileRef === null || externalFileRef === void 0 ? void 0 : externalFileRef.url.replace('attachment:', '');
10
+ return attachmentId ? attachmentsMap.get(attachmentId) : undefined;
11
+ }
12
+ else {
13
+ return [...attachmentsMap.values()].find((attachment) => attachment.link === externalFileRef.url);
14
+ }
15
+ };
16
+ const getFigureData = (element, modelMap, attachmentsMap) => {
17
+ const attachments = [];
9
18
  element.containedObjectIDs.map((e) => {
10
19
  var _a;
11
20
  const object = modelMap.get(e);
12
21
  if (object && object.objectType === ObjectTypes.Figure) {
13
22
  const externalFileRef = (_a = object.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((figure) => figure.kind === 'imageRepresentation');
14
- if (externalFileRef) {
15
- externalFileReferences.push(externalFileRef);
23
+ const attachment = getAttachment(externalFileRef, attachmentsMap);
24
+ if (attachment) {
25
+ attachments.push(attachment);
16
26
  }
17
27
  }
18
28
  });
19
29
  return {
20
30
  id: element._id,
21
- externalFileReferences,
31
+ attachments,
22
32
  caption: getCaptionText(element.caption),
23
33
  };
24
34
  };
25
- export default (modelMap) => {
35
+ export default (modelMap, attachments) => {
26
36
  const files = [];
37
+ const attachmentsMap = new Map(attachments.map((attachment) => [attachment.id, attachment]));
27
38
  getModelsByType(modelMap, ObjectTypes.Section).map((section) => {
28
39
  var _a, _b;
29
40
  if (section.category === 'MPSectionCategory:abstract-graphical') {
30
41
  (_a = section.elementIDs) === null || _a === void 0 ? void 0 : _a.some((elementId) => {
31
42
  const element = modelMap.get(elementId);
32
43
  if (element && hasObjectType(ObjectTypes.FigureElement)(element)) {
33
- files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Graphical Abstract`, type: FileType.GraphicalAbstract }));
44
+ files.unshift(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Graphical Abstract`, type: FileType.GraphicalAbstract }));
34
45
  return true;
35
46
  }
36
47
  });
@@ -45,19 +56,20 @@ export default (modelMap) => {
45
56
  switch (element.objectType) {
46
57
  case ObjectTypes.FigureElement:
47
58
  case ObjectTypes.MultiGraphicFigureElement: {
48
- files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap)), { label: `Figure`, type: FileType.Figure }));
59
+ files.push(Object.assign(Object.assign({}, getFigureData(element, modelMap, attachmentsMap)), { label: `Figure`, type: FileType.Figure }));
49
60
  break;
50
61
  }
51
62
  case ObjectTypes.TableElement: {
52
63
  const tableElement = element;
53
64
  const table = modelMap.get(tableElement.containedObjectID);
54
- const externalFileReferences = (_a = table.externalFileReferences) === null || _a === void 0 ? void 0 : _a.filter((file) => file.kind === 'dataset' && file.ref);
55
- if (externalFileReferences && externalFileReferences.length > 0) {
65
+ const externalFileReference = (_a = table.externalFileReferences) === null || _a === void 0 ? void 0 : _a.find((file) => file.kind === 'dataset' && file.ref);
66
+ const attachment = getAttachment(externalFileReference, attachmentsMap);
67
+ if (attachment) {
56
68
  files.push({
57
69
  id: element._id,
58
70
  label: `Table`,
59
71
  type: FileType.SheetsWorkbooks,
60
- externalFileReferences: table.externalFileReferences,
72
+ attachments: [attachment],
61
73
  caption: getCaptionText(tableElement.caption),
62
74
  });
63
75
  }
@@ -1,14 +1,21 @@
1
- import { ExternalFile, Model } from '@manuscripts/manuscripts-json-schema';
2
1
  import React, { Dispatch } from 'react';
2
+ import { SubmissionAttachment } from './FileSectionItem/FileSectionItem';
3
3
  import { Action } from './FileSectionState';
4
+ import { FileType } from './util';
4
5
  export interface ExternalFileRef {
5
6
  url: string;
6
7
  kind?: string;
7
- ref?: ExternalFile;
8
+ ref?: SubmissionAttachment;
8
9
  }
9
10
  export declare const InlineFilesSection: React.FC<{
10
11
  submissionId: string;
11
- modelMap: Map<string, Model>;
12
+ inlineFiles: {
13
+ id: string;
14
+ label: string;
15
+ type: FileType;
16
+ caption?: string;
17
+ attachments?: SubmissionAttachment[];
18
+ }[];
12
19
  handleReplace: (submissionId: string, attachmentId: string, name: string, file: File, typeId: string) => Promise<boolean>;
13
20
  handleDownload: (url: string) => void;
14
21
  isEditor: boolean;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { ResizerButtonInnerProps } from './ResizerButtonInner';
3
+ import { ResizerDirection, ResizerSide } from './types';
4
+ interface Props {
5
+ collapsed: boolean;
6
+ direction: ResizerDirection;
7
+ onResize: (resizeDelta: number) => void;
8
+ onResizeButton: () => void;
9
+ onResizeEnd: (resizeDelta: number) => void;
10
+ side: ResizerSide;
11
+ buttonInner?: React.ComponentType<ResizerButtonInnerProps>;
12
+ }
13
+ interface State {
14
+ isHovering: boolean;
15
+ isResizing: boolean;
16
+ startPosition: number;
17
+ }
18
+ export declare class Resizer extends React.Component<Props, State> {
19
+ resizerRef: React.RefObject<HTMLDivElement>;
20
+ state: {
21
+ isHovering: boolean;
22
+ isResizing: boolean;
23
+ startPosition: number;
24
+ };
25
+ render(): JSX.Element;
26
+ private scheduleResize;
27
+ private mouseDownHandler;
28
+ private mouseUpHandler;
29
+ private mouseMoveHandler;
30
+ private mouseEnterHandler;
31
+ private mouseLeaveHandler;
32
+ private handleOutofBounds;
33
+ private getDelta;
34
+ private getPosition;
35
+ }
36
+ export {};
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { ResizerButtonInnerProps } from './ResizerButtonInner';
3
+ import { ResizerDirection, ResizerSide } from './types';
4
+ interface Props extends React.HTMLProps<HTMLButtonElement> {
5
+ direction: ResizerDirection;
6
+ isCollapsed: boolean;
7
+ isVisible: boolean;
8
+ side: ResizerSide;
9
+ buttonInner?: React.ComponentType<ResizerButtonInnerProps>;
10
+ }
11
+ export declare class ResizerButton extends React.PureComponent<Props> {
12
+ static defaultProps: {
13
+ isCollapsed: boolean;
14
+ isVisible: boolean;
15
+ };
16
+ render(): JSX.Element;
17
+ }
18
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface ResizerButtonInnerProps {
2
+ isCollapsed: boolean;
3
+ isVisible: boolean;
4
+ }
5
+ export declare const HorizontalEndResizerButtonInner: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, ResizerButtonInnerProps, never>;
6
+ export declare const HorizontalStartResizerButtonInner: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, ResizerButtonInnerProps, never>;
7
+ export declare const VerticalEndResizerButtonInner: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, ResizerButtonInnerProps, never>;
8
+ export declare const VerticalStartResizerButtonInner: import("styled-components").StyledComponent<"button", import("styled-components").DefaultTheme, ResizerButtonInnerProps, never>;
@@ -0,0 +1,4 @@
1
+ export declare const HorizontalStartResizerInner: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
2
+ export declare const HorizontalEndResizerInner: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
3
+ export declare const VerticalStartResizerInner: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
4
+ export declare const VerticalEndResizerInner: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
@@ -0,0 +1,2 @@
1
+ export { Resizer } from './Resizer';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ export declare type ResizerDirection = 'row' | 'column';
2
+ export declare type ResizerSide = 'start' | 'end';
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import React from 'react';
17
- declare const AttachIcon: React.FC<React.SVGAttributes<SVGElement>>;
17
+ declare const AttachIcon: React.FC;
18
18
  export default AttachIcon;
@@ -34,3 +34,4 @@ export { default as TaskStepDoneIcon } from './task-step-done';
34
34
  export { default as TaskStepNextIcon } from './task-step-next';
35
35
  export { default as AttachIcon } from './attach';
36
36
  export { default as UploadIcon } from './upload';
37
+ export { default as MissingImage } from './missing-image';
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const MissingImage: React.FC;
3
+ export default MissingImage;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- declare const UploadIcon: React.FC<React.SVGAttributes<SVGElement>>;
2
+ declare const UploadIcon: React.FC;
3
3
  export default UploadIcon;
@@ -33,6 +33,7 @@ export * from './components/Form';
33
33
  export * from './components/FileManager';
34
34
  export * from './components/FileManager/util';
35
35
  export * from './components/FileManager/FileSectionItem/FileSectionItem';
36
+ export * from './components/Resizer';
36
37
  export * from './components/SaveStatus';
37
38
  export * from './components/SimpleModal';
38
39
  export * from './components/StyledModal';
@@ -1,11 +1,11 @@
1
1
  import { Model } from '@manuscripts/manuscripts-json-schema';
2
- import { ExternalFileRef } from '../components/FileManager/InlineFilesSection';
2
+ import { SubmissionAttachment } from '../components/FileManager/FileSectionItem/FileSectionItem';
3
3
  import { FileType } from '../components/FileManager/util';
4
- declare const _default: (modelMap: Map<string, Model>) => {
4
+ declare const _default: (modelMap: Map<string, Model>, attachments: SubmissionAttachment[]) => {
5
5
  id: string;
6
6
  label: string;
7
7
  type: FileType;
8
8
  caption?: string | undefined;
9
- externalFileReferences?: ExternalFileRef[] | undefined;
9
+ attachments?: SubmissionAttachment[] | undefined;
10
10
  }[];
11
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": "0.30.26",
4
+ "version": "0.31.1",
5
5
  "repository": "gitlab:atypon-opensource/manuscripts-style-guide",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",