@zextras/carbonio-ui-preview 1.2.2 → 1.2.4
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.
- package/README.md +62 -0
- package/THIRDPARTIES +388 -0
- package/lib/constants/index.js +2 -5
- package/lib/constants/index.js.map +1 -1
- package/lib/index.d.ts +9 -6
- package/lib/index.js +11 -22
- package/lib/index.js.map +1 -1
- package/lib/preview/FocusWithin.d.ts +5 -0
- package/lib/preview/FocusWithin.js +26 -57
- package/lib/preview/FocusWithin.js.map +1 -1
- package/lib/preview/FocusWithin.module.css +13 -0
- package/lib/preview/Header.d.ts +37 -4
- package/lib/preview/Header.js +17 -38
- package/lib/preview/Header.js.map +1 -1
- package/lib/preview/Header.module.css +37 -0
- package/lib/preview/ImagePreview.d.ts +7 -47
- package/lib/preview/ImagePreview.js +17 -96
- package/lib/preview/ImagePreview.js.map +1 -1
- package/lib/preview/ImagePreview.module.css +29 -0
- package/lib/preview/Navigator.d.ts +1 -0
- package/lib/preview/Navigator.js +7 -21
- package/lib/preview/Navigator.js.map +1 -1
- package/lib/preview/Navigator.module.css +18 -0
- package/lib/preview/PageController.d.ts +8 -0
- package/lib/preview/PageController.js +29 -67
- package/lib/preview/PageController.js.map +1 -1
- package/lib/preview/PageController.module.css +19 -0
- package/lib/preview/PdfPreview.d.ts +21 -69
- package/lib/preview/PdfPreview.js +79 -161
- package/lib/preview/PdfPreview.js.map +1 -1
- package/lib/preview/PdfPreview.module.css +46 -0
- package/lib/preview/PreviewCriteriaAlternativeContent.d.ts +13 -1
- package/lib/preview/PreviewCriteriaAlternativeContent.js +22 -55
- package/lib/preview/PreviewCriteriaAlternativeContent.js.map +1 -1
- package/lib/preview/PreviewCriteriaAlternativeContent.module.css +15 -0
- package/lib/preview/PreviewManager.d.ts +38 -15
- package/lib/preview/PreviewManager.js +40 -74
- package/lib/preview/PreviewManager.js.map +1 -1
- package/lib/preview/PreviewNavigator.d.ts +42 -0
- package/lib/preview/PreviewNavigator.js +29 -0
- package/lib/preview/PreviewNavigator.js.map +1 -0
- package/lib/preview/PreviewNavigator.module.css +43 -0
- package/lib/preview/PreviewWrapper.d.ts +14 -8
- package/lib/preview/PreviewWrapper.js +12 -24
- package/lib/preview/PreviewWrapper.js.map +1 -1
- package/lib/preview/ZoomController.d.ts +1 -0
- package/lib/preview/ZoomController.js +11 -52
- package/lib/preview/ZoomController.js.map +1 -1
- package/lib/preview/ZoomController.module.css +18 -0
- package/lib/preview/usePageScrollController.js +18 -22
- package/lib/preview/usePageScrollController.js.map +1 -1
- package/lib/preview/useZoom.js +31 -39
- package/lib/preview/useZoom.js.map +1 -1
- package/lib/types/utils.d.ts +4 -0
- package/lib/types/utils.js +2 -0
- package/lib/types/utils.js.map +1 -0
- package/lib/utils/utils.js +5 -9
- package/lib/utils/utils.js.map +1 -1
- package/package.json +55 -44
- package/lib/preview/StyledComponents.d.ts +0 -2
- package/lib/preview/StyledComponents.js +0 -21
- package/lib/preview/StyledComponents.js.map +0 -1
- package/lib/utils/type-utils.d.ts +0 -3
- package/lib/utils/type-utils.js +0 -3
- package/lib/utils/type-utils.js.map +0 -1
- package/lib-esm/constants/index.d.ts +0 -2
- package/lib-esm/constants/index.js +0 -8
- package/lib-esm/constants/index.js.map +0 -1
- package/lib-esm/index.d.ts +0 -6
- package/lib-esm/index.js +0 -12
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/preview/FocusWithin.d.ts +0 -7
- package/lib-esm/preview/FocusWithin.js +0 -57
- package/lib-esm/preview/FocusWithin.js.map +0 -1
- package/lib-esm/preview/Header.d.ts +0 -29
- package/lib-esm/preview/Header.js +0 -39
- package/lib-esm/preview/Header.js.map +0 -1
- package/lib-esm/preview/ImagePreview.d.ts +0 -50
- package/lib-esm/preview/ImagePreview.js +0 -105
- package/lib-esm/preview/ImagePreview.js.map +0 -1
- package/lib-esm/preview/Navigator.d.ts +0 -5
- package/lib-esm/preview/Navigator.js +0 -21
- package/lib-esm/preview/Navigator.js.map +0 -1
- package/lib-esm/preview/PageController.d.ts +0 -8
- package/lib-esm/preview/PageController.js +0 -82
- package/lib-esm/preview/PageController.js.map +0 -1
- package/lib-esm/preview/PdfPreview.d.ts +0 -89
- package/lib-esm/preview/PdfPreview.js +0 -280
- package/lib-esm/preview/PdfPreview.js.map +0 -1
- package/lib-esm/preview/PreviewCriteriaAlternativeContent.d.ts +0 -13
- package/lib-esm/preview/PreviewCriteriaAlternativeContent.js +0 -42
- package/lib-esm/preview/PreviewCriteriaAlternativeContent.js.map +0 -1
- package/lib-esm/preview/PreviewManager.d.ts +0 -19
- package/lib-esm/preview/PreviewManager.js +0 -108
- package/lib-esm/preview/PreviewManager.js.map +0 -1
- package/lib-esm/preview/PreviewWrapper.d.ts +0 -9
- package/lib-esm/preview/PreviewWrapper.js +0 -36
- package/lib-esm/preview/PreviewWrapper.js.map +0 -1
- package/lib-esm/preview/StyledComponents.d.ts +0 -2
- package/lib-esm/preview/StyledComponents.js +0 -15
- package/lib-esm/preview/StyledComponents.js.map +0 -1
- package/lib-esm/preview/ZoomController.d.ts +0 -17
- package/lib-esm/preview/ZoomController.js +0 -28
- package/lib-esm/preview/ZoomController.js.map +0 -1
- package/lib-esm/preview/usePageScrollController.d.ts +0 -4
- package/lib-esm/preview/usePageScrollController.js +0 -67
- package/lib-esm/preview/usePageScrollController.js.map +0 -1
- package/lib-esm/preview/useZoom.d.ts +0 -13
- package/lib-esm/preview/useZoom.js +0 -78
- package/lib-esm/preview/useZoom.js.map +0 -1
- package/lib-esm/utils/type-utils.d.ts +0 -3
- package/lib-esm/utils/type-utils.js +0 -2
- package/lib-esm/utils/type-utils.js.map +0 -1
- package/lib-esm/utils/utils.d.ts +0 -1
- package/lib-esm/utils/utils.js +0 -18
- package/lib-esm/utils/utils.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.fakeModal {
|
|
8
|
+
border-radius: 1rem;
|
|
9
|
+
padding: 2rem 4rem 2rem 4rem;
|
|
10
|
+
margin: auto;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.attachmentLink {
|
|
14
|
+
text-decoration: none;
|
|
15
|
+
}
|
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ImagePreviewProps } from './ImagePreview';
|
|
3
|
-
import { PdfPreviewProps } from './PdfPreview';
|
|
4
|
-
import { type MakeOptional } from '../
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { ImagePreviewProps } from './ImagePreview.js';
|
|
3
|
+
import { PdfPreviewProps } from './PdfPreview.js';
|
|
4
|
+
import { type MakeOptional } from '../types/utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* Define an item for the preview. It can be of type 'image' or 'pdf'.
|
|
7
|
+
* The id is required to control the opening of the preview after its initialization.
|
|
8
|
+
*/
|
|
9
|
+
export type PreviewItem = ((MakeOptional<Omit<ImagePreviewProps, 'show'>, 'onClose'> & {
|
|
10
|
+
previewType: 'image';
|
|
11
|
+
}) | (MakeOptional<Omit<PdfPreviewProps, 'show'>, 'onClose'> & {
|
|
12
|
+
previewType: 'pdf';
|
|
13
|
+
})) & {
|
|
14
|
+
id: string;
|
|
8
15
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
export interface PreviewManagerContextType {
|
|
17
|
+
/** Initialize and open the preview for the given item */
|
|
18
|
+
createPreview: (item: MakeOptional<PreviewItem, 'id'>) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the preview for the given items. This function does not open the preview.
|
|
21
|
+
* Use openPreview to open the preview for one of the initialized items.
|
|
22
|
+
*/
|
|
23
|
+
initPreview: (items: PreviewItem[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Open the preview for the item with the given id. The item must have been initialized
|
|
26
|
+
* before with the initPreview method.
|
|
27
|
+
*/
|
|
14
28
|
openPreview: (id: string) => void;
|
|
29
|
+
/** Clear the initialized previews */
|
|
15
30
|
emptyPreview: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The context give access to the functions needed to manage multiple previews.
|
|
34
|
+
* It must be used together with the PreviewManager.
|
|
35
|
+
*/
|
|
36
|
+
export declare const PreviewsManagerContext: React.Context<PreviewManagerContextType>;
|
|
37
|
+
/**
|
|
38
|
+
* The manager for showing multiple previews.
|
|
39
|
+
* From within it, the PreviewsManagerContext give access to the functions to initialize and open
|
|
40
|
+
* the previews of different items.
|
|
41
|
+
*/
|
|
42
|
+
export declare const PreviewManager: React.FC;
|
|
@@ -1,43 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* SPDX-FileCopyrightText: 2021 Zextras <https://www.zextras.com>
|
|
4
3
|
*
|
|
5
4
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
6
5
|
*/
|
|
7
|
-
var __assign = (this && this.__assign) || function () {
|
|
8
|
-
__assign = Object.assign || function(t) {
|
|
9
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10
|
-
s = arguments[i];
|
|
11
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
12
|
-
t[p] = s[p];
|
|
13
|
-
}
|
|
14
|
-
return t;
|
|
15
|
-
};
|
|
16
|
-
return __assign.apply(this, arguments);
|
|
17
|
-
};
|
|
18
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
-
}
|
|
24
|
-
Object.defineProperty(o, k2, desc);
|
|
25
|
-
}) : (function(o, m, k, k2) {
|
|
26
|
-
if (k2 === undefined) k2 = k;
|
|
27
|
-
o[k2] = m[k];
|
|
28
|
-
}));
|
|
29
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
-
}) : function(o, v) {
|
|
32
|
-
o["default"] = v;
|
|
33
|
-
});
|
|
34
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
35
|
-
if (mod && mod.__esModule) return mod;
|
|
36
|
-
var result = {};
|
|
37
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
38
|
-
__setModuleDefault(result, mod);
|
|
39
|
-
return result;
|
|
40
|
-
};
|
|
41
6
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
42
7
|
var t = {};
|
|
43
8
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -49,24 +14,26 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
49
14
|
}
|
|
50
15
|
return t;
|
|
51
16
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
emptyPreview: function () { return undefined; }
|
|
17
|
+
import React, { useCallback, createContext, useReducer, useState, useMemo } from 'react';
|
|
18
|
+
import { findIndex } from 'lodash';
|
|
19
|
+
import { PreviewWrapper } from './PreviewWrapper.js';
|
|
20
|
+
/**
|
|
21
|
+
* The context give access to the functions needed to manage multiple previews.
|
|
22
|
+
* It must be used together with the PreviewManager.
|
|
23
|
+
*/
|
|
24
|
+
export const PreviewsManagerContext = createContext({
|
|
25
|
+
createPreview: () => undefined,
|
|
26
|
+
initPreview: () => undefined,
|
|
27
|
+
openPreview: () => undefined,
|
|
28
|
+
emptyPreview: () => undefined
|
|
65
29
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The manager for showing multiple previews.
|
|
32
|
+
* From within it, the PreviewsManagerContext give access to the functions to initialize and open
|
|
33
|
+
* the previews of different items.
|
|
34
|
+
*/
|
|
35
|
+
export const PreviewManager = ({ children }) => {
|
|
36
|
+
const [previews, dispatchPreviews] = useReducer((state, action) => {
|
|
70
37
|
switch (action.type) {
|
|
71
38
|
case 'init': {
|
|
72
39
|
return action.value;
|
|
@@ -78,61 +45,60 @@ var PreviewManager = function (_a) {
|
|
|
78
45
|
return state;
|
|
79
46
|
}
|
|
80
47
|
}
|
|
81
|
-
}, [])
|
|
82
|
-
|
|
83
|
-
|
|
48
|
+
}, []);
|
|
49
|
+
const [openArrayIndex, setOpenArrayIndex] = useState(-1);
|
|
50
|
+
const previewElement = useMemo(() => {
|
|
84
51
|
if (openArrayIndex >= 0) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
|
|
52
|
+
const _a = previews[openArrayIndex], { onClose } = _a, props = __rest(_a, ["onClose"]);
|
|
53
|
+
const closePreview = (ev) => {
|
|
54
|
+
if (onClose)
|
|
55
|
+
onClose(ev);
|
|
89
56
|
setOpenArrayIndex(-1);
|
|
90
57
|
};
|
|
91
|
-
|
|
58
|
+
const onPreviousPreviewCallback = openArrayIndex === 0
|
|
92
59
|
? undefined
|
|
93
|
-
:
|
|
60
|
+
: (e) => {
|
|
94
61
|
e.stopPropagation();
|
|
95
62
|
setOpenArrayIndex(openArrayIndex - 1);
|
|
96
63
|
};
|
|
97
|
-
|
|
64
|
+
const onNextPreviewCallback = openArrayIndex === previews.length - 1
|
|
98
65
|
? undefined
|
|
99
|
-
:
|
|
66
|
+
: (e) => {
|
|
100
67
|
e.stopPropagation();
|
|
101
68
|
setOpenArrayIndex(openArrayIndex + 1);
|
|
102
69
|
};
|
|
103
|
-
return (
|
|
70
|
+
return (React.createElement(PreviewWrapper, Object.assign({}, props, { show: true, onClose: closePreview, onPreviousPreview: onPreviousPreviewCallback, onNextPreview: onNextPreviewCallback })));
|
|
104
71
|
}
|
|
105
72
|
return undefined;
|
|
106
73
|
}, [openArrayIndex, previews]);
|
|
107
|
-
|
|
74
|
+
const createPreview = useCallback((args) => {
|
|
108
75
|
dispatchPreviews({
|
|
109
76
|
type: 'init',
|
|
110
|
-
value: [args]
|
|
77
|
+
value: [Object.assign({ id: 'default-id' }, args)]
|
|
111
78
|
});
|
|
112
79
|
setOpenArrayIndex(0);
|
|
113
80
|
}, [dispatchPreviews]);
|
|
114
|
-
|
|
81
|
+
const emptyPreview = useCallback(() => {
|
|
115
82
|
dispatchPreviews({
|
|
116
83
|
type: 'empty'
|
|
117
84
|
});
|
|
118
85
|
setOpenArrayIndex(-1);
|
|
119
86
|
}, [dispatchPreviews]);
|
|
120
|
-
|
|
87
|
+
const initPreview = useCallback((args) => {
|
|
121
88
|
dispatchPreviews({
|
|
122
89
|
type: 'init',
|
|
123
90
|
value: args
|
|
124
91
|
});
|
|
125
92
|
}, [dispatchPreviews]);
|
|
126
|
-
|
|
127
|
-
|
|
93
|
+
const openPreview = useCallback((id) => {
|
|
94
|
+
const index = findIndex(previews, (preview) => preview.id === id);
|
|
128
95
|
if (index >= 0) {
|
|
129
96
|
setOpenArrayIndex(index);
|
|
130
97
|
}
|
|
131
98
|
}, [previews, setOpenArrayIndex]);
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
|
|
99
|
+
const previewManagerContextValue = useMemo(() => ({ createPreview, initPreview, openPreview, emptyPreview }), [createPreview, emptyPreview, initPreview, openPreview]);
|
|
100
|
+
return (React.createElement(React.Fragment, null,
|
|
101
|
+
React.createElement(PreviewsManagerContext.Provider, { value: previewManagerContextValue }, children),
|
|
135
102
|
previewElement));
|
|
136
103
|
};
|
|
137
|
-
exports.PreviewManager = PreviewManager;
|
|
138
104
|
//# sourceMappingURL=PreviewManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewManager.js","sourceRoot":"","sources":["../../src/preview/PreviewManager.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PreviewManager.js","sourceRoot":"","sources":["../../src/preview/PreviewManager.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;;;AAEH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAInC,OAAO,EAAE,cAAc,EAAuB,MAAM,qBAAqB,CAAC;AA+B1E;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAA4B;IAC9E,aAAa,EAAE,GAAG,EAAE,CAAC,SAAS;IAC9B,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS;IAC5B,WAAW,EAAE,GAAG,EAAE,CAAC,SAAS;IAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxD,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,UAAU,CAC9C,CAAC,KAAoB,EAAE,MAAkE,EAAE,EAAE;QAC5F,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,MAAM,CAAC,CAAC,CAAC;gBACb,OAAO,MAAM,CAAC,KAAK,CAAC;YACrB,CAAC;YACD,KAAK,OAAO,CAAC,CAAC,CAAC;gBACd,OAAO,EAAE,CAAC;YACX,CAAC;YACD,OAAO,CAAC,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vD,CAAC;IAEF,OAAO,CACN;QACC,oBAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,0BAA0B,IAChE,QAAQ,CACwB;QACjC,cAAc,CACb,CACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HeaderAction, HeaderProps } from './Header.js';
|
|
3
|
+
export interface PreviewNavigatorProps extends Partial<Omit<HeaderProps, 'closeAction'>> {
|
|
4
|
+
/**
|
|
5
|
+
* Close action for the preview.
|
|
6
|
+
* The close action does not accept the onClick field, because its click callback
|
|
7
|
+
* is always set to be the onClose function.
|
|
8
|
+
*/
|
|
9
|
+
closeAction?: Omit<HeaderAction, 'onClick'>;
|
|
10
|
+
/**
|
|
11
|
+
* Callback to hide the preview. This function is invoked by all events that must close the preview
|
|
12
|
+
* (closeAction, overlay click, keyboard shortcuts).
|
|
13
|
+
* In order to invoke the onClose only once when clicking on the closeAction, the event of the onClose
|
|
14
|
+
* should call preventDefault.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const onClose = (e: React.SyntheticEvent | KeyboardEvent): void => {
|
|
19
|
+
* // prevent the default to invoke the onClose callback only once
|
|
20
|
+
* e.preventDefault();
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
onClose: (e: React.SyntheticEvent | KeyboardEvent) => void;
|
|
25
|
+
/**
|
|
26
|
+
* HTML node where to insert the Portal's children.
|
|
27
|
+
* The default value is 'window.top.document'.
|
|
28
|
+
*/
|
|
29
|
+
container?: Element;
|
|
30
|
+
/** Flag to disable the Portal implementation */
|
|
31
|
+
disablePortal?: boolean;
|
|
32
|
+
/** Flag to show or hide Portal's content */
|
|
33
|
+
show: boolean;
|
|
34
|
+
/** Callback invoked when the next preview is requested */
|
|
35
|
+
onNextPreview?: (e: React.SyntheticEvent | KeyboardEvent) => void;
|
|
36
|
+
/** Callback invoked when the previous preview is requested */
|
|
37
|
+
onPreviousPreview?: (e: React.SyntheticEvent | KeyboardEvent) => void;
|
|
38
|
+
/** Callback invoked when the preview overlay is clicked */
|
|
39
|
+
onOverlayClick?: React.JSX.IntrinsicElements['div']['onClick'];
|
|
40
|
+
}
|
|
41
|
+
/** Define the preview main layout, allowing the navigation between multiple previews. */
|
|
42
|
+
export declare const PreviewNavigator: ({ children, onPreviousPreview, onNextPreview, container, disablePortal, extension, show, filename, actions, size, onOverlayClick, closeAction, onClose }: React.PropsWithChildren<PreviewNavigatorProps>) => React.JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
+
*/
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
import { IconButton, Portal, Container } from '@zextras/carbonio-design-system';
|
|
8
|
+
import FocusWithin from './FocusWithin.js';
|
|
9
|
+
import Header from './Header.js';
|
|
10
|
+
import styles from './PreviewNavigator.module.css';
|
|
11
|
+
/** Define the preview main layout, allowing the navigation between multiple previews. */
|
|
12
|
+
export const PreviewNavigator = ({ children, onPreviousPreview, onNextPreview, container, disablePortal, extension = '', show, filename = '', actions = [], size = '', onOverlayClick, closeAction, onClose }) => {
|
|
13
|
+
const $closeAction = useMemo(() => {
|
|
14
|
+
if (closeAction) {
|
|
15
|
+
return Object.assign(Object.assign({}, closeAction), { onClick: onClose });
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}, [closeAction, onClose]);
|
|
19
|
+
return (React.createElement(Portal, { show: show, disablePortal: disablePortal, container: container },
|
|
20
|
+
React.createElement("div", { onClick: onOverlayClick, className: styles.overlay },
|
|
21
|
+
React.createElement(FocusWithin, null,
|
|
22
|
+
React.createElement("div", { className: styles.externalContainer },
|
|
23
|
+
React.createElement(Header, { actions: actions, filename: filename, extension: extension, size: size, closeAction: $closeAction }),
|
|
24
|
+
React.createElement(Container, { orientation: "horizontal", crossAlignment: "unset", minHeight: 0, flexGrow: 1 },
|
|
25
|
+
onPreviousPreview ? (React.createElement(IconButton, { className: styles.absoluteLeftIconButton, icon: "ArrowBackOutline", size: "medium", backgroundColor: "gray0", iconColor: "gray6", borderRadius: "round", onClick: onPreviousPreview })) : null,
|
|
26
|
+
children,
|
|
27
|
+
onNextPreview ? (React.createElement(IconButton, { className: styles.absoluteRightIconButton, icon: "ArrowForwardOutline", size: "medium", backgroundColor: "gray0", iconColor: "gray6", borderRadius: "round", onClick: onNextPreview })) : null))))));
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=PreviewNavigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewNavigator.js","sourceRoot":"","sources":["../../src/preview/PreviewNavigator.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,MAAqC,MAAM,aAAa,CAAC;AAChE,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAyCnD,yFAAyF;AACzF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAChC,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,GAAG,EAAE,EACd,IAAI,EACJ,QAAQ,GAAG,EAAE,EACb,OAAO,GAAG,EAAE,EACZ,IAAI,GAAG,EAAE,EACT,cAAc,EACd,WAAW,EACX,OAAO,EACyC,EAAqB,EAAE;IACvE,MAAM,YAAY,GAAG,OAAO,CAA2B,GAAG,EAAE;QAC3D,IAAI,WAAW,EAAE,CAAC;YACjB,uCACI,WAAW,KACd,OAAO,EA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 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.overlay {
|
|
8
|
+
height: 100vh;
|
|
9
|
+
max-height: 100vh;
|
|
10
|
+
width: 100%;
|
|
11
|
+
max-width: 100%;
|
|
12
|
+
position: fixed;
|
|
13
|
+
top: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
background-color: rgba(0, 0, 0, 0.8);
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
align-items: center;
|
|
19
|
+
z-index: 1003;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.externalContainer {
|
|
23
|
+
height: 100vh;
|
|
24
|
+
max-height: 100vh;
|
|
25
|
+
width: 100vw;
|
|
26
|
+
max-width: 100vw;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
position: relative;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.absoluteLeftIconButton {
|
|
33
|
+
position: absolute !important;
|
|
34
|
+
left: 0.5rem;
|
|
35
|
+
top: 50%;
|
|
36
|
+
z-index: 1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.absoluteRightIconButton {
|
|
40
|
+
position: absolute !important;
|
|
41
|
+
right: 0.5rem;
|
|
42
|
+
top: 50%;
|
|
43
|
+
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ImagePreviewProps } from './ImagePreview';
|
|
3
|
-
import { PdfPreviewProps } from './PdfPreview';
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { ImagePreviewProps } from './ImagePreview.js';
|
|
3
|
+
import { PdfPreviewProps } from './PdfPreview.js';
|
|
4
|
+
export type PreviewWrapperProps = (ImagePreviewProps & {
|
|
5
|
+
previewType: 'image';
|
|
6
|
+
}) | (PdfPreviewProps & {
|
|
7
|
+
previewType: 'pdf';
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Show the preview for either an image or a pdf.
|
|
11
|
+
* This component is just a wrapper on the two specific preview components.
|
|
12
|
+
* @param previewType - The type of the preview
|
|
13
|
+
* @param props - The item to show
|
|
14
|
+
*/
|
|
15
|
+
export declare const PreviewWrapper: React.VFC<PreviewWrapperProps>;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
1
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
2
|
var t = {};
|
|
15
3
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -21,22 +9,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
9
|
}
|
|
22
10
|
return t;
|
|
23
11
|
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.PreviewWrapper = void 0;
|
|
29
12
|
/*
|
|
30
13
|
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
|
|
31
14
|
*
|
|
32
15
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
33
16
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import { ImagePreview } from './ImagePreview.js';
|
|
19
|
+
import { PdfPreview } from './PdfPreview.js';
|
|
20
|
+
/**
|
|
21
|
+
* Show the preview for either an image or a pdf.
|
|
22
|
+
* This component is just a wrapper on the two specific preview components.
|
|
23
|
+
* @param previewType - The type of the preview
|
|
24
|
+
* @param props - The item to show
|
|
25
|
+
*/
|
|
26
|
+
export const PreviewWrapper = (_a) => {
|
|
27
|
+
var { previewType } = _a, props = __rest(_a, ["previewType"]);
|
|
28
|
+
return previewType === 'pdf' ? (React.createElement(PdfPreview, Object.assign({}, props))) : (React.createElement(ImagePreview, Object.assign({}, props)));
|
|
40
29
|
};
|
|
41
|
-
exports.PreviewWrapper = PreviewWrapper;
|
|
42
30
|
//# sourceMappingURL=PreviewWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewWrapper.js","sourceRoot":"","sources":["../../src/preview/PreviewWrapper.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PreviewWrapper.js","sourceRoot":"","sources":["../../src/preview/PreviewWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAmB,MAAM,iBAAiB,CAAC;AAQ9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmC,CAAC,EAAyB,EAAE,EAAE;QAA7B,EAAE,WAAW,OAAY,EAAP,KAAK,cAAvB,eAAyB,CAAF;IACrF,OAAA,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,CACvB,oBAAC,UAAU,oBAAM,KAAyB,EAAI,CAC9C,CAAC,CAAC,CAAC,CACH,oBAAC,YAAY,oBAAM,KAA2B,EAAI,CAClD,CAAA;CAAA,CAAC"}
|
|
@@ -14,4 +14,5 @@ export interface ZoomControllerProps {
|
|
|
14
14
|
upperLimitReachedLabel: string | undefined;
|
|
15
15
|
increaseByStep: (event: React.MouseEvent<HTMLButtonElement> | KeyboardEvent) => void;
|
|
16
16
|
}
|
|
17
|
+
/** Render a controller for the zoom */
|
|
17
18
|
export declare const ZoomController: ({ decrementable, fitToWidth, fitToWidthActive, fitToWidthLabel, incrementable, lowerLimitReachedLabel, decreaseByStep, increaseByStep, resetWidth, resetZoomLabel, upperLimitReachedLabel, zoomInLabel, zoomOutLabel }: ZoomControllerProps) => React.JSX.Element;
|
|
@@ -1,58 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
-
};
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.ZoomController = void 0;
|
|
34
1
|
/*
|
|
35
2
|
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
|
|
36
3
|
*
|
|
37
4
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
38
5
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
react_1.default.createElement(CustomIconButton, { disabled: !decrementable, icon: "Minus", size: "small", backgroundColor: "gray0", iconColor: "gray6", onClick: decreaseByStep })),
|
|
51
|
-
react_1.default.createElement(carbonio_design_system_1.Tooltip, { label: fitToWidthActive ? resetZoomLabel : fitToWidthLabel },
|
|
52
|
-
react_1.default.createElement(CustomIconButton, { icon: fitToWidthActive ? 'MinimizeOutline' : 'MaximizeOutline', size: "small", backgroundColor: "gray0", iconColor: "gray6", onClick: fitToWidthActive ? resetWidth : fitToWidth })),
|
|
53
|
-
react_1.default.createElement(carbonio_design_system_1.Tooltip, { label: incrementable ? zoomInLabel : upperLimitReachedLabel },
|
|
54
|
-
react_1.default.createElement(CustomIconButton, { icon: "Plus", size: "small", backgroundColor: "gray0", iconColor: "gray6", onClick: increaseByStep, disabled: !incrementable }))));
|
|
55
|
-
};
|
|
56
|
-
exports.ZoomController = ZoomController;
|
|
57
|
-
var templateObject_1, templateObject_2;
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { Container, IconButton, Tooltip } from '@zextras/carbonio-design-system';
|
|
8
|
+
import styles from './ZoomController.module.css';
|
|
9
|
+
/** Render a controller for the zoom */
|
|
10
|
+
export const ZoomController = ({ decrementable, fitToWidth, fitToWidthActive, fitToWidthLabel = 'Fit to width', incrementable, lowerLimitReachedLabel = 'Minimum zoom level reached', decreaseByStep, increaseByStep, resetWidth, resetZoomLabel = 'Reset zoom', upperLimitReachedLabel = 'Maximum zoom level reached', zoomInLabel = 'Zoom in', zoomOutLabel = 'Zoom out' }) => (React.createElement(Container, { orientation: "horizontal", gap: "0.5rem", width: "fit" },
|
|
11
|
+
React.createElement(Tooltip, { label: decrementable ? zoomOutLabel : lowerLimitReachedLabel },
|
|
12
|
+
React.createElement(IconButton, { disabled: !decrementable, icon: "Minus", size: "small", backgroundColor: "gray0", iconColor: "gray6", onClick: decreaseByStep, className: styles.zoomIconButton })),
|
|
13
|
+
React.createElement(Tooltip, { label: fitToWidthActive ? resetZoomLabel : fitToWidthLabel },
|
|
14
|
+
React.createElement(IconButton, { icon: fitToWidthActive ? 'MinimizeOutline' : 'MaximizeOutline', size: "small", backgroundColor: "gray0", iconColor: "gray6", onClick: fitToWidthActive ? resetWidth : fitToWidth, className: styles.zoomIconButton })),
|
|
15
|
+
React.createElement(Tooltip, { label: incrementable ? zoomInLabel : upperLimitReachedLabel },
|
|
16
|
+
React.createElement(IconButton, { icon: "Plus", size: "small", backgroundColor: "gray0", iconColor: "gray6", onClick: increaseByStep, disabled: !incrementable, className: styles.zoomIconButton }))));
|
|
58
17
|
//# sourceMappingURL=ZoomController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoomController.js","sourceRoot":"","sources":["../../src/preview/ZoomController.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ZoomController.js","sourceRoot":"","sources":["../../src/preview/ZoomController.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MA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GAC/B,CACO;IACV,oBAAC,OAAO,IAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,sBAAsB;QACnE,oBAAC,UAAU,IACV,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,OAAO,EACZ,eAAe,EAAC,OAAO,EACvB,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,CAAC,aAAa,EACxB,SAAS,EAAE,MAAM,CAAC,cAAc,GAC/B,CACO,CACC,CACZ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: 2024 Zextras <https://www.zextras.com>
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-only
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.zoomIconButton:disabled {
|
|
8
|
+
background: rgba(204, 204, 204, 0.2);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.zoomIconButton:disabled > svg {
|
|
12
|
+
background: unset;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.zoomIconButton > svg {
|
|
16
|
+
width: 1.25rem;
|
|
17
|
+
height: 1.25rem;
|
|
18
|
+
}
|