@zextras/carbonio-ui-preview 0.1.3 → 0.2.0

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 (107) hide show
  1. package/README.md +5 -5
  2. package/lib/index.d.ts +6 -0
  3. package/lib/index.js +28 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/preview/FocusWithin.d.ts +7 -0
  6. package/lib/preview/FocusWithin.js +87 -0
  7. package/lib/preview/FocusWithin.js.map +1 -0
  8. package/lib/preview/Header.d.ts +29 -0
  9. package/lib/preview/Header.js +44 -0
  10. package/lib/preview/Header.js.map +1 -0
  11. package/lib/preview/Header.test.d.ts +1 -0
  12. package/lib/preview/Header.test.js +143 -0
  13. package/lib/preview/Header.test.js.map +1 -0
  14. package/lib/preview/ImagePreview.d.ts +42 -0
  15. package/lib/preview/ImagePreview.js +116 -0
  16. package/lib/preview/ImagePreview.js.map +1 -0
  17. package/lib/preview/ImagePreview.test.d.ts +1 -0
  18. package/lib/preview/ImagePreview.test.js +161 -0
  19. package/lib/preview/ImagePreview.test.js.map +1 -0
  20. package/lib/preview/PdfPreview.d.ts +63 -0
  21. package/lib/preview/PdfPreview.js +235 -0
  22. package/lib/preview/PdfPreview.js.map +1 -0
  23. package/lib/preview/PdfPreview.test.d.ts +1 -0
  24. package/lib/preview/PdfPreview.test.js +718 -0
  25. package/lib/preview/PdfPreview.test.js.map +1 -0
  26. package/lib/preview/PreviewCriteriaAlternativeContent.d.ts +12 -0
  27. package/lib/preview/PreviewCriteriaAlternativeContent.js +72 -0
  28. package/lib/preview/PreviewCriteriaAlternativeContent.js.map +1 -0
  29. package/lib/preview/PreviewManager.d.ts +13 -0
  30. package/lib/preview/PreviewManager.js +102 -0
  31. package/lib/preview/PreviewManager.js.map +1 -0
  32. package/lib/preview/PreviewManager.test.d.ts +1 -0
  33. package/lib/preview/PreviewManager.test.js +162 -0
  34. package/lib/preview/PreviewManager.test.js.map +1 -0
  35. package/lib/preview/PreviewWrapper.d.ts +9 -0
  36. package/lib/preview/PreviewWrapper.js +42 -0
  37. package/lib/preview/PreviewWrapper.js.map +1 -0
  38. package/lib/preview/PreviewWrapper.test.d.ts +1 -0
  39. package/lib/preview/PreviewWrapper.test.js +85 -0
  40. package/lib/preview/PreviewWrapper.test.js.map +1 -0
  41. package/lib/preview/constants.d.ts +1 -0
  42. package/lib/preview/constants.js +10 -0
  43. package/lib/preview/constants.js.map +1 -0
  44. package/lib/utils/test-utils.d.ts +20 -0
  45. package/lib/utils/test-utils.js +86 -0
  46. package/lib/utils/test-utils.js.map +1 -0
  47. package/lib/utils/utils.d.ts +3 -0
  48. package/lib/utils/utils.js +8 -0
  49. package/lib/utils/utils.js.map +1 -0
  50. package/lib-esm/index.d.ts +6 -0
  51. package/{src/index.ts → lib-esm/index.js} +1 -1
  52. package/lib-esm/index.js.map +1 -0
  53. package/lib-esm/preview/FocusWithin.d.ts +7 -0
  54. package/lib-esm/preview/FocusWithin.js +59 -0
  55. package/lib-esm/preview/FocusWithin.js.map +1 -0
  56. package/lib-esm/preview/Header.d.ts +29 -0
  57. package/lib-esm/preview/Header.js +39 -0
  58. package/lib-esm/preview/Header.js.map +1 -0
  59. package/lib-esm/preview/Header.test.d.ts +1 -0
  60. package/lib-esm/preview/Header.test.js +138 -0
  61. package/lib-esm/preview/Header.test.js.map +1 -0
  62. package/lib-esm/preview/ImagePreview.d.ts +42 -0
  63. package/lib-esm/preview/ImagePreview.js +87 -0
  64. package/lib-esm/preview/ImagePreview.js.map +1 -0
  65. package/lib-esm/preview/ImagePreview.test.d.ts +1 -0
  66. package/lib-esm/preview/ImagePreview.test.js +156 -0
  67. package/lib-esm/preview/ImagePreview.test.js.map +1 -0
  68. package/lib-esm/preview/PdfPreview.d.ts +63 -0
  69. package/lib-esm/preview/PdfPreview.js +206 -0
  70. package/lib-esm/preview/PdfPreview.js.map +1 -0
  71. package/lib-esm/preview/PdfPreview.test.d.ts +1 -0
  72. package/lib-esm/preview/PdfPreview.test.js +713 -0
  73. package/lib-esm/preview/PdfPreview.test.js.map +1 -0
  74. package/lib-esm/preview/PreviewCriteriaAlternativeContent.d.ts +12 -0
  75. package/lib-esm/preview/PreviewCriteriaAlternativeContent.js +42 -0
  76. package/lib-esm/preview/PreviewCriteriaAlternativeContent.js.map +1 -0
  77. package/lib-esm/preview/PreviewManager.d.ts +13 -0
  78. package/lib-esm/preview/PreviewManager.js +75 -0
  79. package/lib-esm/preview/PreviewManager.js.map +1 -0
  80. package/lib-esm/preview/PreviewManager.test.d.ts +1 -0
  81. package/lib-esm/preview/PreviewManager.test.js +137 -0
  82. package/lib-esm/preview/PreviewManager.test.js.map +1 -0
  83. package/lib-esm/preview/PreviewWrapper.d.ts +9 -0
  84. package/lib-esm/preview/PreviewWrapper.js +36 -0
  85. package/lib-esm/preview/PreviewWrapper.js.map +1 -0
  86. package/lib-esm/preview/PreviewWrapper.test.d.ts +1 -0
  87. package/lib-esm/preview/PreviewWrapper.test.js +80 -0
  88. package/lib-esm/preview/PreviewWrapper.test.js.map +1 -0
  89. package/lib-esm/preview/constants.d.ts +1 -0
  90. package/{src/utils.ts → lib-esm/preview/constants.js} +2 -2
  91. package/lib-esm/preview/constants.js.map +1 -0
  92. package/lib-esm/utils/test-utils.d.ts +20 -0
  93. package/lib-esm/utils/test-utils.js +55 -0
  94. package/lib-esm/utils/test-utils.js.map +1 -0
  95. package/lib-esm/utils/utils.d.ts +3 -0
  96. package/{src/types/carbonio-design-system.d.ts → lib-esm/utils/utils.js} +2 -2
  97. package/lib-esm/utils/utils.js.map +1 -0
  98. package/package.json +49 -20
  99. package/babel.config.js +0 -13
  100. package/src/preview/ContainerWithGap.tsx +0 -11
  101. package/src/preview/FocusWithin.tsx +0 -76
  102. package/src/preview/Header.tsx +0 -122
  103. package/src/preview/ImagePreview.tsx +0 -194
  104. package/src/preview/PdfPreview.tsx +0 -398
  105. package/src/preview/PreviewCriteriaAlternativeContent.tsx +0 -94
  106. package/src/preview/PreviewManager.tsx +0 -75
  107. package/src/preview/PreviewWrapper.tsx +0 -20
package/package.json CHANGED
@@ -1,44 +1,73 @@
1
1
  {
2
2
  "name": "@zextras/carbonio-ui-preview",
3
- "version": "0.1.3",
4
- "description": "Preview utility for Zextras Carbonio",
5
- "main": "src/index.ts",
3
+ "version": "0.2.0",
4
+ "description": "Preview ui utility for Zextras Carbonio",
5
+ "main": "lib/index.js",
6
+ "module": "lib-esm/index.js",
7
+ "types": "lib/index.d.ts",
6
8
  "files": [
7
- "src/*",
8
- "babel.config.js"
9
+ "/lib",
10
+ "/lib-esm"
9
11
  ],
10
12
  "scripts": {
11
- "_postinstall": "is-ci || husky install",
12
- "prepublishOnly": "pinst --disable",
13
- "postpublish": "pinst --enable",
13
+ "build": "tsc",
14
+ "build-esm": "tsc -m es6 --outDir lib-esm",
15
+ "clean": "rm -rf lib lib-esm",
16
+ "build-all": "npm run clean && npm run build && npm run build-esm",
17
+ "prepare": "is-ci || husky install",
18
+ "prepack": "npm run build-all",
14
19
  "type-check": "tsc --noEmit",
15
20
  "type-check:watch": "npm run type-check -- --watch",
16
21
  "lint": "eslint --ext .js,.jsx,.ts,.tsx --resolve-plugins-relative-to node_modules/@zextras/carbonio-ui-configs src",
17
- "test": "echo jest"
22
+ "packTo": "npm pack --pack-destination $PKG_PATH && cd $PKG_PATH && npm i zextras-carbonio-ui-preview-$npm_package_version.tgz",
23
+ "deploy": "npm pack && rm -rf $PKG_PATH/node_modules/@zextras/carbonio-ui-preview/* && tar -xf zextras-carbonio-ui-preview-$npm_package_version.tgz -C $PKG_PATH/node_modules/@zextras/carbonio-ui-preview/ --strip-components 1",
24
+ "test": "jest"
18
25
  },
19
26
  "keywords": [],
20
27
  "author": "Zextras SF Team <https://www.zextras.com/carbonio/>",
21
28
  "license": "AGPL-3.0-only",
22
29
  "devDependencies": {
23
- "@commitlint/cli": "14.1.0",
24
- "@commitlint/config-conventional": "14.1.0",
30
+ "@babel/core": "^7.16.0",
31
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
32
+ "@babel/plugin-transform-runtime": "^7.16.4",
33
+ "@babel/preset-env": "^7.16.4",
34
+ "@babel/preset-react": "^7.16.0",
35
+ "@babel/preset-typescript": "^7.16.0",
36
+ "@commitlint/cli": "^17.0.3",
37
+ "@commitlint/config-conventional": "^17.0.3",
38
+ "@faker-js/faker": "^7.3.0",
39
+ "@testing-library/jest-dom": "^5.16.4",
40
+ "@testing-library/react": "^12.1.5",
41
+ "@testing-library/user-event": "^14.4.0",
42
+ "@types/jest": "^28.1.6",
25
43
  "@types/lodash": "^4.14.181",
26
- "@types/react": "17.0.36",
27
- "@types/react-dom": "17.0.11",
44
+ "@types/react": "^17.0.36",
45
+ "@types/react-dom": "^17.0.11",
46
+ "@types/react-pdf": "^5.0.9",
28
47
  "@types/styled-components": "^5.1.15",
29
48
  "@zextras/carbonio-ui-configs": "^0.1.11",
49
+ "babel-jest": "^28.1.3",
50
+ "babel-plugin-i18next-extract": "^0.8.3",
51
+ "babel-plugin-styled-components": "^2.0.1",
52
+ "eslint-plugin-import": "^2.26.0",
53
+ "eslint-plugin-jest-dom": "^4.0.2",
30
54
  "eslint-plugin-notice": "^0.9.10",
31
- "husky": "^5.2.0",
32
- "is-ci": "3.0.1",
33
- "pinst": "2.1.6"
55
+ "eslint-plugin-testing-library": "^5.6.0",
56
+ "eslint-plugin-unused-imports": "^2.0.0",
57
+ "husky": "^8.0.1",
58
+ "is-ci": "^3.0.1",
59
+ "jest": "^28.1.3",
60
+ "jest-canvas-mock": "^2.4.0",
61
+ "jest-environment-jsdom": "^28.1.3",
62
+ "jest-fail-on-console": "^2.4.2",
63
+ "jest-junit": "^14.0.0"
34
64
  },
35
65
  "dependencies": {
36
- "@types/react-pdf": "^5.0.9",
37
- "core-js": "3.19.1",
38
- "react-pdf": "^5.7.1"
66
+ "core-js": "^3.19.1",
67
+ "react-pdf": "^5.7.2"
39
68
  },
40
69
  "peerDependencies": {
41
- "@zextras/carbonio-design-system": "^0.2.0",
70
+ "@zextras/carbonio-design-system": "^0.4.0",
42
71
  "lodash": "^4.17.21",
43
72
  "react": "^17.0.2",
44
73
  "react-dom": "^17.0.2",
package/babel.config.js DELETED
@@ -1,13 +0,0 @@
1
- /*
2
- * SPDX-FileCopyrightText: 2021 Zextras <https://www.zextras.com>
3
- *
4
- * SPDX-License-Identifier: AGPL-3.0-only
5
- */
6
- module.exports = {
7
- presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
8
- plugins: [
9
- '@babel/plugin-transform-runtime',
10
- '@babel/plugin-proposal-class-properties',
11
- 'babel-plugin-styled-components'
12
- ]
13
- };
@@ -1,11 +0,0 @@
1
- /*
2
- * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
3
- *
4
- * SPDX-License-Identifier: AGPL-3.0-only
5
- */
6
- import { Container } from '@zextras/carbonio-design-system';
7
- import styled from 'styled-components';
8
-
9
- export const ContainerWithGap = styled(Container)`
10
- gap: ${({ gap }): string => gap};
11
- `;
@@ -1,76 +0,0 @@
1
- /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
2
- /*
3
- * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
4
- *
5
- * SPDX-License-Identifier: AGPL-3.0-only
6
- */
7
- import React, { useCallback, useEffect, useRef } from 'react';
8
-
9
- import last from 'lodash/last';
10
- import styled from 'styled-components';
11
-
12
- const FocusContainer = styled.span`
13
- outline: none;
14
- & > * {
15
- outline: none;
16
- }
17
- `;
18
-
19
- interface FocusContainerProps {
20
- returnFocus?: boolean;
21
- children: React.ReactChild | React.ReactChildren;
22
- }
23
-
24
- const FocusWithin = ({ children, returnFocus = true }: FocusContainerProps): JSX.Element => {
25
- const contentRef = useRef<HTMLDivElement | null>(null);
26
- const startSentinelRef = useRef<HTMLDivElement | null>(null);
27
- const endSentinelRef = useRef<HTMLDivElement | null>(null);
28
-
29
- const onStartSentinelFocus = useCallback(() => {
30
- if (contentRef.current) {
31
- const node = last(contentRef.current.querySelectorAll<HTMLElement>('[tabindex]'));
32
- node && node.focus();
33
- }
34
- }, []);
35
-
36
- const onEndSentinelFocus = useCallback(() => {
37
- if (contentRef.current) {
38
- const node = contentRef.current.querySelector<HTMLElement>('[tabindex]');
39
- node && node.focus();
40
- }
41
- }, []);
42
-
43
- useEffect(() => {
44
- const documentElement = window.top?.document || document;
45
- const focusedElement = documentElement.activeElement as HTMLElement;
46
-
47
- contentRef.current && contentRef.current.focus();
48
- startSentinelRef.current &&
49
- startSentinelRef.current.addEventListener('focus', onStartSentinelFocus);
50
- endSentinelRef.current && endSentinelRef.current.addEventListener('focus', onEndSentinelFocus);
51
- const startSentinelRefSave = startSentinelRef.current;
52
- const endSentinelRefSave = endSentinelRef.current;
53
-
54
- return (): void => {
55
- startSentinelRefSave &&
56
- startSentinelRefSave.removeEventListener('focus', onStartSentinelFocus);
57
- endSentinelRefSave && endSentinelRefSave.removeEventListener('focus', onEndSentinelFocus);
58
- // return focus to previous initial element
59
- if (focusedElement && returnFocus) {
60
- focusedElement.focus();
61
- }
62
- };
63
- }, [onStartSentinelFocus, onEndSentinelFocus, returnFocus]);
64
-
65
- return (
66
- <FocusContainer>
67
- <span tabIndex={0} ref={startSentinelRef} />
68
- <div tabIndex={-1} ref={contentRef}>
69
- {children}
70
- </div>
71
- <span tabIndex={0} ref={endSentinelRef} />
72
- </FocusContainer>
73
- );
74
- };
75
-
76
- export default FocusWithin;
@@ -1,122 +0,0 @@
1
- /*
2
- * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
3
- *
4
- * SPDX-License-Identifier: AGPL-3.0-only
5
- */
6
- import React from 'react';
7
-
8
- import { IconButton, Text, Tooltip } from '@zextras/carbonio-design-system';
9
- import map from 'lodash/map';
10
- import styled from 'styled-components';
11
-
12
- const HeaderContainer = styled.div`
13
- display: flex;
14
- justify-content: space-between;
15
- padding: 16px;
16
- `;
17
-
18
- const LeftContainer = styled.div`
19
- display: flex;
20
- justify-content: flex-start;
21
- align-items: center;
22
- gap: 8px;
23
- `;
24
-
25
- const RightContainer = styled.div`
26
- display: flex;
27
- justify-content: flex-end;
28
- align-items: center;
29
- gap: 8px;
30
- `;
31
-
32
- const InfoContainer = styled.div`
33
- width: fit-content;
34
- & div {
35
- line-height: 1.5;
36
- }
37
- `;
38
-
39
- const UpperCaseText = styled(Text)`
40
- text-transform: uppercase;
41
- `;
42
-
43
- interface HeaderAction {
44
- /** id used as key */
45
- id: string;
46
- /** Action called on click */
47
- onClick?: React.ReactEventHandler;
48
- /** Icon from the theme */
49
- icon: string;
50
- /** Label to show as tooltip for the action */
51
- tooltipLabel?: string;
52
- tooltipPlacement?: React.ComponentPropsWithRef<typeof Tooltip>['placement'];
53
- /** Disabled status for the action */
54
- disabled?: boolean;
55
- }
56
-
57
- export interface HeaderProps {
58
- /** Left Action for the preview */
59
- closeAction?: HeaderAction;
60
- /** Actions for the preview */
61
- actions: HeaderAction[];
62
- /** Extension of the file, shown as info */
63
- extension: string;
64
- /** Name of the file, shown as info */
65
- filename: string;
66
- /** Size of the file, shown as info */
67
- size: string;
68
- }
69
-
70
- const Header: React.VFC<HeaderProps> = ({ closeAction, actions, filename, extension, size }) => (
71
- <HeaderContainer>
72
- <LeftContainer>
73
- {closeAction && (
74
- <Tooltip
75
- label={closeAction.tooltipLabel}
76
- disabled={!closeAction.tooltipLabel}
77
- key={closeAction.id}
78
- placement={closeAction.tooltipPlacement}
79
- >
80
- <IconButton
81
- onClick={closeAction.onClick}
82
- icon={closeAction.icon}
83
- size="medium"
84
- backgroundColor="transparent"
85
- iconColor="gray6"
86
- />
87
- </Tooltip>
88
- )}
89
- <InfoContainer>
90
- <Text size="small" color="gray6">
91
- {filename}
92
- </Text>
93
- <UpperCaseText size="small" color="gray6">
94
- {extension}
95
- {extension && size && <> &middot; </>}
96
- {size}
97
- </UpperCaseText>
98
- </InfoContainer>
99
- </LeftContainer>
100
- <RightContainer>
101
- {map(actions, ({ id, onClick, disabled, icon, tooltipLabel, tooltipPlacement }) => (
102
- <Tooltip
103
- label={tooltipLabel}
104
- disabled={!tooltipLabel}
105
- key={id}
106
- placement={tooltipPlacement}
107
- >
108
- <IconButton
109
- onClick={onClick}
110
- disabled={disabled}
111
- icon={icon}
112
- size="medium"
113
- backgroundColor="transparent"
114
- iconColor="gray6"
115
- />
116
- </Tooltip>
117
- ))}
118
- </RightContainer>
119
- </HeaderContainer>
120
- );
121
-
122
- export default Header;
@@ -1,194 +0,0 @@
1
- /*
2
- * SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
3
- *
4
- * SPDX-License-Identifier: AGPL-3.0-only
5
- */
6
- import React, { useCallback, useEffect, useRef } from 'react';
7
-
8
- import { Container, Portal, useCombinedRefs } from '@zextras/carbonio-design-system';
9
- import styled from 'styled-components';
10
-
11
- import FocusWithin from './FocusWithin';
12
- import Header, { HeaderProps } from './Header';
13
-
14
- const Overlay = styled.div`
15
- height: 100vh;
16
- max-height: 100vh;
17
- width: 100%;
18
- max-width: 100%;
19
- position: fixed;
20
- top: 0;
21
- left: 0;
22
- background-color: rgba(0, 0, 0, 0.8);
23
- display: flex;
24
- justify-content: center;
25
- align-items: center;
26
- z-index: 1003;
27
- `;
28
-
29
- const ExternalContainer = styled.div`
30
- height: 100vh;
31
- max-height: 100vh;
32
- width: 100vw;
33
- max-width: 100vw;
34
- display: flex;
35
- flex-direction: column;
36
- position: relative;
37
- `;
38
-
39
- const MiddleContainer = styled(Container)`
40
- flex-grow: 1;
41
- `;
42
-
43
- const Image = styled.img`
44
- max-height: 100%;
45
- max-width: 100%;
46
- min-height: 0;
47
- min-width: 0;
48
- align-self: center;
49
- filter: drop-shadow(0px 5px 14px rgba(0, 0, 0, 0.35));
50
- border-radius: 4px;
51
- `;
52
-
53
- const PreviewContainer = styled.div.attrs({
54
- $paddingVertical: '32px',
55
- $paddingHorizontal: '16px',
56
- $gap: '8px'
57
- })`
58
- display: flex;
59
- max-width: 100%;
60
- max-height: calc(100vh - ${({ $paddingVertical }): string => $paddingVertical} * 2);
61
- flex-direction: column;
62
- gap: ${({ $gap }): string => $gap};
63
- justify-content: center;
64
- align-items: center;
65
- overflow: hidden;
66
- padding: ${({ $paddingVertical, $paddingHorizontal }): string =>
67
- `${$paddingVertical} ${$paddingHorizontal}`};
68
- outline: none;
69
- flex-grow: 1;
70
- `;
71
-
72
- type ImagePreviewProps = Partial<HeaderProps> & {
73
- /**
74
- * HTML node where to insert the Portal's children.
75
- * The default value is 'window.top.document'.
76
- * */
77
- container?: React.RefObject<HTMLElement>;
78
- /** Flag to disable the Portal implementation */
79
- disablePortal?: boolean;
80
- /** Flag to show or hide Portal's content */
81
- show: boolean;
82
- /** preview img source */
83
- src: string;
84
- /** Callback to hide the preview */
85
- onClose: (e: React.SyntheticEvent | KeyboardEvent) => void;
86
- /** Alternative text for image */
87
- alt?: string;
88
- };
89
-
90
- const ImagePreview = React.forwardRef<HTMLDivElement, ImagePreviewProps>(function PreviewFn(
91
- {
92
- src,
93
- show,
94
- container,
95
- disablePortal,
96
- extension = '',
97
- filename = '',
98
- size = '',
99
- actions = [],
100
- closeAction,
101
- onClose,
102
- alt
103
- },
104
- ref
105
- ) {
106
- const previewRef: React.MutableRefObject<HTMLDivElement | null> = useCombinedRefs(ref);
107
- const imageRef = useRef<HTMLImageElement | null>(null);
108
-
109
- const escapeEvent = useCallback<(e: KeyboardEvent) => void>(
110
- (event) => {
111
- if (event.key === 'Escape') {
112
- onClose(event);
113
- }
114
- },
115
- [onClose]
116
- );
117
-
118
- useEffect(() => {
119
- if (show) {
120
- document.addEventListener('keyup', escapeEvent);
121
- }
122
-
123
- return (): void => {
124
- document.removeEventListener('keyup', escapeEvent);
125
- };
126
- }, [escapeEvent, show]);
127
-
128
- const onOverlayClick = useCallback<React.ReactEventHandler>(
129
- (event) => {
130
- // TODO: stop propagation or not?
131
- event.stopPropagation();
132
- previewRef.current &&
133
- !event.isDefaultPrevented() &&
134
- (previewRef.current === event.target ||
135
- !previewRef.current.contains(event.target as Node)) &&
136
- onClose(event);
137
- },
138
- [onClose, previewRef]
139
- );
140
-
141
- return (
142
- <Portal show={show} disablePortal={disablePortal} container={container}>
143
- <Overlay onClick={onOverlayClick}>
144
- <FocusWithin>
145
- <ExternalContainer>
146
- <Header
147
- actions={actions}
148
- filename={filename}
149
- extension={extension}
150
- size={size}
151
- closeAction={closeAction}
152
- />
153
- <MiddleContainer orientation="horizontal" crossAlignment="unset" minHeight={0}>
154
- {/* TODO: uncomment when navigation between items will be implemented */}
155
- {/* <Container width="fit"> */}
156
- {/* <Padding left="small" right="small"> */}
157
- {/* <IconButton */}
158
- {/* icon="ArrowBackOutline" */}
159
- {/* size="medium" */}
160
- {/* backgroundColor="gray0" */}
161
- {/* iconColor="gray6" */}
162
- {/* borderRadius="round" */}
163
- {/* /> */}
164
- {/* </Padding> */}
165
- {/* </Container> */}
166
- <PreviewContainer ref={previewRef}>
167
- <Image
168
- alt={alt ?? filename}
169
- src={src}
170
- onError={(): void => console.log('TODO handle error')}
171
- ref={imageRef}
172
- />
173
- </PreviewContainer>
174
- {/* TODO: uncomment when navigation between items will be implemented */}
175
- {/* <Container width="fit"> */}
176
- {/* <Padding left="small" right="small"> */}
177
- {/* <IconButton */}
178
- {/* icon="ArrowForwardOutline" */}
179
- {/* size="medium" */}
180
- {/* backgroundColor="gray0" */}
181
- {/* iconColor="gray6" */}
182
- {/* borderRadius="round" */}
183
- {/* /> */}
184
- {/* </Padding> */}
185
- {/* </Container> */}
186
- </MiddleContainer>
187
- </ExternalContainer>
188
- </FocusWithin>
189
- </Overlay>
190
- </Portal>
191
- );
192
- });
193
-
194
- export { ImagePreview, ImagePreviewProps };