cozy-viewer 1.1.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.
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/Readme.md +44 -0
- package/babel.config.js +23 -0
- package/dist/Footer/BottomSheetContent.d.ts +12 -0
- package/dist/Footer/BottomSheetContent.js +45 -0
- package/dist/Footer/DownloadButton.d.ts +16 -0
- package/dist/Footer/DownloadButton.js +113 -0
- package/dist/Footer/FooterActionButtons.d.ts +13 -0
- package/dist/Footer/FooterActionButtons.js +33 -0
- package/dist/Footer/FooterActionButtons.spec.d.ts +1 -0
- package/dist/Footer/FooterContent.d.ts +16 -0
- package/dist/Footer/FooterContent.js +120 -0
- package/dist/Footer/ForwardButton.d.ts +20 -0
- package/dist/Footer/ForwardButton.js +177 -0
- package/dist/Footer/ForwardButton.spec.d.ts +1 -0
- package/dist/Footer/ForwardOrDownloadButton.d.ts +11 -0
- package/dist/Footer/ForwardOrDownloadButton.js +42 -0
- package/dist/Footer/Sharing.d.ts +16 -0
- package/dist/Footer/Sharing.js +79 -0
- package/dist/Footer/helpers.d.ts +8 -0
- package/dist/Footer/helpers.js +179 -0
- package/dist/Footer/helpers.spec.d.ts +1 -0
- package/dist/NoViewer/DownloadButton.d.ts +2 -0
- package/dist/NoViewer/DownloadButton.js +52 -0
- package/dist/NoViewer/FileIcon.d.ts +4 -0
- package/dist/NoViewer/FileIcon.js +76 -0
- package/dist/NoViewer/NoViewer.d.ts +18 -0
- package/dist/NoViewer/NoViewer.js +64 -0
- package/dist/NoViewer/NoViewer.spec.d.ts +1 -0
- package/dist/NoViewer/index.d.ts +1 -0
- package/dist/NoViewer/index.js +15 -0
- package/dist/Panel/ActionMenuDesktop.d.ts +3 -0
- package/dist/Panel/ActionMenuDesktop.js +91 -0
- package/dist/Panel/ActionMenuMobile.d.ts +20 -0
- package/dist/Panel/ActionMenuMobile.js +95 -0
- package/dist/Panel/ActionMenuWrapper.d.ts +3 -0
- package/dist/Panel/ActionMenuWrapper.js +155 -0
- package/dist/Panel/Certifications.d.ts +2 -0
- package/dist/Panel/Certifications.js +80 -0
- package/dist/Panel/PanelContent.d.ts +2 -0
- package/dist/Panel/PanelContent.js +71 -0
- package/dist/Panel/Qualification.d.ts +2 -0
- package/dist/Panel/Qualification.js +148 -0
- package/dist/Panel/QualificationListItemContact.d.ts +10 -0
- package/dist/Panel/QualificationListItemContact.js +123 -0
- package/dist/Panel/QualificationListItemDate.d.ts +3 -0
- package/dist/Panel/QualificationListItemDate.js +90 -0
- package/dist/Panel/QualificationListItemInformation.d.ts +3 -0
- package/dist/Panel/QualificationListItemInformation.js +84 -0
- package/dist/Panel/QualificationListItemInformation.spec.d.ts +1 -0
- package/dist/Panel/QualificationListItemOther.d.ts +3 -0
- package/dist/Panel/QualificationListItemOther.js +78 -0
- package/dist/Panel/QualificationListItemText.d.ts +13 -0
- package/dist/Panel/QualificationListItemText.js +42 -0
- package/dist/Panel/getPanelBlocks.d.ts +26 -0
- package/dist/Panel/getPanelBlocks.js +79 -0
- package/dist/Panel/getPanelBlocks.spec.d.ts +1 -0
- package/dist/Viewer.d.ts +39 -0
- package/dist/Viewer.js +191 -0
- package/dist/ViewerContainer.d.ts +22 -0
- package/dist/ViewerContainer.js +221 -0
- package/dist/ViewerExposer.d.ts +2 -0
- package/dist/ViewerExposer.js +13 -0
- package/dist/ViewerInformationsWrapper.d.ts +20 -0
- package/dist/ViewerInformationsWrapper.js +68 -0
- package/dist/ViewerInformationsWrapper.spec.d.ts +1 -0
- package/dist/ViewerWithCustomPanelAndFooter.d.ts +2 -0
- package/dist/ViewerWithCustomPanelAndFooter.js +78 -0
- package/dist/ViewersByFile/AudioViewer.d.ts +74 -0
- package/dist/ViewersByFile/AudioViewer.js +57 -0
- package/dist/ViewersByFile/AudioViewer.spec.d.ts +1 -0
- package/dist/ViewersByFile/BlankPaperViewer.d.ts +2 -0
- package/dist/ViewersByFile/BlankPaperViewer.js +97 -0
- package/dist/ViewersByFile/ImageViewer.d.ts +31 -0
- package/dist/ViewersByFile/ImageViewer.js +385 -0
- package/dist/ViewersByFile/ImageViewer.spec.d.ts +1 -0
- package/dist/ViewersByFile/NoNetworkViewer.d.ts +2 -0
- package/dist/ViewersByFile/NoNetworkViewer.js +54 -0
- package/dist/ViewersByFile/OnlyOfficeViewer.d.ts +2 -0
- package/dist/ViewersByFile/OnlyOfficeViewer.js +46 -0
- package/dist/ViewersByFile/PdfJsViewer.d.ts +31 -0
- package/dist/ViewersByFile/PdfJsViewer.js +283 -0
- package/dist/ViewersByFile/PdfJsViewer.spec.d.ts +1 -0
- package/dist/ViewersByFile/PdfMobileViewer.d.ts +4 -0
- package/dist/ViewersByFile/PdfMobileViewer.js +185 -0
- package/dist/ViewersByFile/PdfMobileViewer.spec.d.ts +1 -0
- package/dist/ViewersByFile/ShortcutViewer.d.ts +2 -0
- package/dist/ViewersByFile/ShortcutViewer.js +61 -0
- package/dist/ViewersByFile/ShortcutViewer.spec.d.ts +4 -0
- package/dist/ViewersByFile/TextViewer.d.ts +90 -0
- package/dist/ViewersByFile/TextViewer.js +250 -0
- package/dist/ViewersByFile/TextViewer.spec.d.ts +1 -0
- package/dist/ViewersByFile/VideoViewer.d.ts +74 -0
- package/dist/ViewersByFile/VideoViewer.js +46 -0
- package/dist/ViewersByFile/VideoViewer.spec.d.ts +1 -0
- package/dist/assets/IlluGenericNewPage.svg +10 -0
- package/dist/components/ExpirationAlert.d.ts +2 -0
- package/dist/components/ExpirationAlert.js +129 -0
- package/dist/components/ExpirationAnnotation.d.ts +10 -0
- package/dist/components/ExpirationAnnotation.js +56 -0
- package/dist/components/Footer.d.ts +4 -0
- package/dist/components/Footer.js +41 -0
- package/dist/components/InformationPanel.d.ts +12 -0
- package/dist/components/InformationPanel.js +36 -0
- package/dist/components/Navigation.d.ts +18 -0
- package/dist/components/Navigation.js +63 -0
- package/dist/components/PdfToolbarButton.d.ts +16 -0
- package/dist/components/PdfToolbarButton.js +40 -0
- package/dist/components/PrintButton.d.ts +16 -0
- package/dist/components/PrintButton.js +163 -0
- package/dist/components/Toolbar.d.ts +2 -0
- package/dist/components/Toolbar.js +146 -0
- package/dist/components/ToolbarButtons.d.ts +5 -0
- package/dist/components/ToolbarButtons.js +20 -0
- package/dist/components/ToolbarFilePath.d.ts +3 -0
- package/dist/components/ToolbarFilePath.js +92 -0
- package/dist/components/ViewerByFile.d.ts +7 -0
- package/dist/components/ViewerByFile.js +137 -0
- package/dist/components/ViewerByFile.spec.d.ts +1 -0
- package/dist/components/ViewerControls.d.ts +9 -0
- package/dist/components/ViewerControls.js +251 -0
- package/dist/components/ViewerControls.spec.d.ts +1 -0
- package/dist/components/ViewerSpinner.d.ts +2 -0
- package/dist/components/ViewerSpinner.js +31 -0
- package/dist/docs/DemoProvider.d.ts +6 -0
- package/dist/docs/DemoProvider.js +159 -0
- package/dist/helpers.d.ts +37 -0
- package/dist/helpers.js +190 -0
- package/dist/helpers.spec.d.ts +1 -0
- package/dist/hoc/withFileUrl.d.ts +75 -0
- package/dist/hoc/withFileUrl.js +231 -0
- package/dist/hoc/withViewerLocales.d.ts +1 -0
- package/dist/hoc/withViewerLocales.js +15 -0
- package/dist/hooks/useReferencedContactName.d.ts +5 -0
- package/dist/hooks/useReferencedContactName.js +45 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +75 -0
- package/dist/locales/index.d.ts +6 -0
- package/dist/locales/index.js +18 -0
- package/dist/proptypes.d.ts +7 -0
- package/dist/proptypes.js +25 -0
- package/dist/providers/ActionMenuProvider.d.ts +13 -0
- package/dist/providers/ActionMenuProvider.js +47 -0
- package/dist/providers/EncryptedProvider.d.ts +8 -0
- package/dist/providers/EncryptedProvider.js +43 -0
- package/dist/queries.d.ts +15 -0
- package/dist/queries.js +40 -0
- package/dist/stylesheet.css +218 -0
- package/jest.config.js +23 -0
- package/package.json +62 -0
- package/preprocess.js +16 -0
- package/src/Footer/BottomSheetContent.jsx +30 -0
- package/src/Footer/DownloadButton.jsx +66 -0
- package/src/Footer/FooterActionButtons.jsx +22 -0
- package/src/Footer/FooterActionButtons.spec.jsx +30 -0
- package/src/Footer/FooterContent.jsx +102 -0
- package/src/Footer/ForwardButton.jsx +95 -0
- package/src/Footer/ForwardButton.spec.jsx +87 -0
- package/src/Footer/ForwardOrDownloadButton.jsx +24 -0
- package/src/Footer/Sharing.jsx +59 -0
- package/src/Footer/helpers.js +106 -0
- package/src/Footer/helpers.spec.js +77 -0
- package/src/NoViewer/DownloadButton.jsx +28 -0
- package/src/NoViewer/FileIcon.jsx +46 -0
- package/src/NoViewer/NoViewer.jsx +30 -0
- package/src/NoViewer/NoViewer.spec.jsx +44 -0
- package/src/NoViewer/__snapshots__/NoViewer.spec.jsx.snap +82 -0
- package/src/NoViewer/index.jsx +1 -0
- package/src/Panel/ActionMenuDesktop.jsx +69 -0
- package/src/Panel/ActionMenuMobile.jsx +76 -0
- package/src/Panel/ActionMenuWrapper.jsx +104 -0
- package/src/Panel/Certifications.jsx +63 -0
- package/src/Panel/PanelContent.jsx +50 -0
- package/src/Panel/Qualification.jsx +114 -0
- package/src/Panel/QualificationListItemContact.jsx +85 -0
- package/src/Panel/QualificationListItemDate.jsx +78 -0
- package/src/Panel/QualificationListItemInformation.jsx +68 -0
- package/src/Panel/QualificationListItemInformation.spec.jsx +73 -0
- package/src/Panel/QualificationListItemOther.jsx +61 -0
- package/src/Panel/QualificationListItemText.jsx +30 -0
- package/src/Panel/getPanelBlocks.jsx +56 -0
- package/src/Panel/getPanelBlocks.spec.jsx +79 -0
- package/src/Panel/styles.styl +13 -0
- package/src/Readme.md +352 -0
- package/src/Viewer.jsx +135 -0
- package/src/ViewerContainer.jsx +170 -0
- package/src/ViewerExposer.js +3 -0
- package/src/ViewerInformationsWrapper.jsx +70 -0
- package/src/ViewerInformationsWrapper.spec.jsx +63 -0
- package/src/ViewerWithCustomPanelAndFooter.jsx +57 -0
- package/src/ViewersByFile/AudioViewer.jsx +22 -0
- package/src/ViewersByFile/AudioViewer.spec.jsx +40 -0
- package/src/ViewersByFile/BlankPaperViewer.jsx +47 -0
- package/src/ViewersByFile/ImageViewer.jsx +331 -0
- package/src/ViewersByFile/ImageViewer.spec.jsx +73 -0
- package/src/ViewersByFile/NoNetworkViewer.jsx +18 -0
- package/src/ViewersByFile/OnlyOfficeViewer.jsx +29 -0
- package/src/ViewersByFile/PdfJsViewer.jsx +210 -0
- package/src/ViewersByFile/PdfJsViewer.spec.jsx +161 -0
- package/src/ViewersByFile/PdfMobileViewer.jsx +106 -0
- package/src/ViewersByFile/PdfMobileViewer.spec.jsx +76 -0
- package/src/ViewersByFile/ShortcutViewer.jsx +38 -0
- package/src/ViewersByFile/ShortcutViewer.spec.jsx +32 -0
- package/src/ViewersByFile/TextViewer.jsx +126 -0
- package/src/ViewersByFile/TextViewer.spec.jsx +118 -0
- package/src/ViewersByFile/VideoViewer.jsx +13 -0
- package/src/ViewersByFile/VideoViewer.spec.jsx +40 -0
- package/src/ViewersByFile/__snapshots__/AudioViewer.spec.jsx.snap +43 -0
- package/src/ViewersByFile/__snapshots__/ShortcutViewer.spec.jsx.snap +57 -0
- package/src/ViewersByFile/__snapshots__/TextViewer.spec.jsx.snap +100 -0
- package/src/ViewersByFile/__snapshots__/VideoViewer.spec.jsx.snap +19 -0
- package/src/ViewersByFile/styles.styl +87 -0
- package/src/assets/IlluGenericNewPage.svg +10 -0
- package/src/components/ExpirationAlert.jsx +86 -0
- package/src/components/ExpirationAnnotation.jsx +39 -0
- package/src/components/Footer.jsx +14 -0
- package/src/components/InformationPanel.jsx +26 -0
- package/src/components/Navigation.jsx +40 -0
- package/src/components/PdfToolbarButton.jsx +26 -0
- package/src/components/PrintButton.jsx +89 -0
- package/src/components/Toolbar.jsx +111 -0
- package/src/components/ToolbarButtons.jsx +11 -0
- package/src/components/ToolbarFilePath.jsx +61 -0
- package/src/components/ViewerByFile.jsx +112 -0
- package/src/components/ViewerByFile.spec.jsx +100 -0
- package/src/components/ViewerControls.jsx +191 -0
- package/src/components/ViewerControls.spec.jsx +54 -0
- package/src/components/ViewerSpinner.jsx +17 -0
- package/src/components/styles.styl +93 -0
- package/src/docs/DemoProvider.jsx +90 -0
- package/src/helpers.js +131 -0
- package/src/helpers.spec.js +136 -0
- package/src/hoc/withFileUrl.jsx +93 -0
- package/src/hoc/withViewerLocales.jsx +5 -0
- package/src/hooks/useReferencedContactName.jsx +26 -0
- package/src/index.jsx +12 -0
- package/src/locales/en.json +66 -0
- package/src/locales/fr.json +66 -0
- package/src/locales/index.js +4 -0
- package/src/proptypes.js +12 -0
- package/src/providers/ActionMenuProvider.jsx +35 -0
- package/src/providers/EncryptedProvider.jsx +25 -0
- package/src/queries.js +20 -0
- package/src/styles.styl +22 -0
- package/src/vars.styl +6 -0
- package/test/__mocks__/fileMock.js +3 -0
- package/test/jestLib/setup.js +5 -0
- package/tsconfig-build.json +13 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getPanelBlocksSpecs = exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _cozyClient = require("cozy-client");
|
|
11
|
+
|
|
12
|
+
var _KonnectorBlock = _interopRequireDefault(require("cozy-harvest-lib/dist/components/KonnectorBlock"));
|
|
13
|
+
|
|
14
|
+
var _Certifications = _interopRequireDefault(require("./Certifications"));
|
|
15
|
+
|
|
16
|
+
var _Qualification = _interopRequireDefault(require("./Qualification"));
|
|
17
|
+
|
|
18
|
+
var _models$file = _cozyClient.models.file,
|
|
19
|
+
isFromKonnector = _models$file.isFromKonnector,
|
|
20
|
+
hasQualifications = _models$file.hasQualifications,
|
|
21
|
+
hasCertifications = _models$file.hasCertifications;
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} PanelBlockSpec
|
|
24
|
+
* @property {Function} condition - Function that returns true if the block should be displayed
|
|
25
|
+
* @property {React.Component} component - Component to display
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object.<string, PanelBlockSpec>} PanelBlocksSpecs
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the specs of the blocks to display in the panel
|
|
34
|
+
* @param {boolean} isPublic - Whether the panel is displayed in public view
|
|
35
|
+
* @returns {PanelBlocksSpecs}
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
var getPanelBlocksSpecs = function getPanelBlocksSpecs() {
|
|
39
|
+
var isPublic = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
40
|
+
return {
|
|
41
|
+
qualifications: {
|
|
42
|
+
condition: hasQualifications,
|
|
43
|
+
component: _Qualification.default
|
|
44
|
+
},
|
|
45
|
+
konnector: {
|
|
46
|
+
condition: function condition(file) {
|
|
47
|
+
return isFromKonnector(file) && !isPublic;
|
|
48
|
+
},
|
|
49
|
+
component: _KonnectorBlock.default
|
|
50
|
+
},
|
|
51
|
+
certifications: {
|
|
52
|
+
condition: hasCertifications,
|
|
53
|
+
component: _Certifications.default
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Returns the blocks to display in the panel
|
|
59
|
+
* @param {Object} options
|
|
60
|
+
* @param {PanelBlocksSpecs} options.panelBlocksSpecs - Specs of the blocks to display in the panel
|
|
61
|
+
* @param {import('cozy-client/types/types').FileDocument} options.file - File object
|
|
62
|
+
* @returns {Array.<React.Component>}
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
exports.getPanelBlocksSpecs = getPanelBlocksSpecs;
|
|
67
|
+
|
|
68
|
+
var getPanelBlocks = function getPanelBlocks(_ref) {
|
|
69
|
+
var panelBlocksSpecs = _ref.panelBlocksSpecs,
|
|
70
|
+
file = _ref.file;
|
|
71
|
+
var panelBlocks = [];
|
|
72
|
+
Object.values(panelBlocksSpecs).forEach(function (panelBlock) {
|
|
73
|
+
panelBlock.condition(file) && panelBlocks.push(panelBlock.component);
|
|
74
|
+
});
|
|
75
|
+
return panelBlocks;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var _default = getPanelBlocks;
|
|
79
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/Viewer.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default Viewer;
|
|
2
|
+
declare class Viewer extends React.Component<any, any, any> {
|
|
3
|
+
constructor();
|
|
4
|
+
onKeyUp: (e: any) => void;
|
|
5
|
+
onNext: () => void;
|
|
6
|
+
onPrevious: () => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onChange(nextFile: any, nextIndex: any): void;
|
|
9
|
+
}
|
|
10
|
+
declare namespace Viewer {
|
|
11
|
+
namespace propTypes {
|
|
12
|
+
const currentFile: any;
|
|
13
|
+
const hasNext: PropTypes.Requireable<boolean>;
|
|
14
|
+
const hasPrevious: PropTypes.Requireable<boolean>;
|
|
15
|
+
const onCloseRequest: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
|
+
const onChangeRequest: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
|
+
const toolbarRef: PropTypes.Requireable<object>;
|
|
18
|
+
const showNavigation: PropTypes.Requireable<boolean>;
|
|
19
|
+
const renderFallbackExtraContent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
const validForPanel: PropTypes.Requireable<boolean>;
|
|
21
|
+
const componentsProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
22
|
+
/** Used to open an Only Office file */
|
|
23
|
+
OnlyOfficeViewer: PropTypes.Requireable<PropTypes.InferProps<{
|
|
24
|
+
/** Whether Only Office is enabled on the server */
|
|
25
|
+
isEnabled: PropTypes.Requireable<boolean>;
|
|
26
|
+
/** To open the Only Office file */
|
|
27
|
+
opener: PropTypes.Requireable<(...args: any[]) => any>;
|
|
28
|
+
}>>;
|
|
29
|
+
toolbarProps: PropTypes.Requireable<PropTypes.InferProps<{
|
|
30
|
+
showToolbar: PropTypes.Requireable<boolean>;
|
|
31
|
+
showClose: PropTypes.Requireable<boolean>;
|
|
32
|
+
toolbarRef: PropTypes.Requireable<object>;
|
|
33
|
+
showFilePath: PropTypes.Requireable<boolean>;
|
|
34
|
+
}>>;
|
|
35
|
+
}>>;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
import React from "react";
|
|
39
|
+
import PropTypes from "prop-types";
|
package/dist/Viewer.js
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
+
|
|
28
|
+
var _proptypes = require("cozy-ui/transpiled/react/proptypes");
|
|
29
|
+
|
|
30
|
+
var _ViewerByFile = _interopRequireDefault(require("./components/ViewerByFile"));
|
|
31
|
+
|
|
32
|
+
var _ViewerControls = _interopRequireDefault(require("./components/ViewerControls"));
|
|
33
|
+
|
|
34
|
+
var _proptypes2 = require("./proptypes");
|
|
35
|
+
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
|
+
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
+
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
|
+
|
|
44
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
45
|
+
|
|
46
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
|
+
|
|
48
|
+
var KEY_CODE_LEFT = 37;
|
|
49
|
+
var KEY_CODE_RIGHT = 39;
|
|
50
|
+
var KEY_CODE_ESCAPE = 27;
|
|
51
|
+
|
|
52
|
+
var Viewer = /*#__PURE__*/function (_Component) {
|
|
53
|
+
(0, _inherits2.default)(Viewer, _Component);
|
|
54
|
+
|
|
55
|
+
var _super = _createSuper(Viewer);
|
|
56
|
+
|
|
57
|
+
function Viewer() {
|
|
58
|
+
var _this;
|
|
59
|
+
|
|
60
|
+
(0, _classCallCheck2.default)(this, Viewer);
|
|
61
|
+
_this = _super.call(this);
|
|
62
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onKeyUp", function (e) {
|
|
63
|
+
if (e.keyCode === KEY_CODE_LEFT) _this.onPrevious();else if (e.keyCode === KEY_CODE_RIGHT) _this.onNext();else if (e.keyCode === KEY_CODE_ESCAPE) _this.onClose();
|
|
64
|
+
});
|
|
65
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onNext", function () {
|
|
66
|
+
var _this$props = _this.props,
|
|
67
|
+
files = _this$props.files,
|
|
68
|
+
currentIndex = _this$props.currentIndex;
|
|
69
|
+
|
|
70
|
+
if (currentIndex === files.length - 1) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
var nextIndex = currentIndex + 1;
|
|
75
|
+
var nextFile = files[nextIndex];
|
|
76
|
+
|
|
77
|
+
_this.onChange(nextFile, nextIndex);
|
|
78
|
+
});
|
|
79
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPrevious", function () {
|
|
80
|
+
var _this$props2 = _this.props,
|
|
81
|
+
files = _this$props2.files,
|
|
82
|
+
currentIndex = _this$props2.currentIndex;
|
|
83
|
+
|
|
84
|
+
if (currentIndex === 0) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var prevIndex = currentIndex - 1;
|
|
89
|
+
var prevFile = files[prevIndex];
|
|
90
|
+
|
|
91
|
+
_this.onChange(prevFile, prevIndex);
|
|
92
|
+
});
|
|
93
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClose", function () {
|
|
94
|
+
if (_this.props.onCloseRequest) {
|
|
95
|
+
_this.props.onCloseRequest();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return _this;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
(0, _createClass2.default)(Viewer, [{
|
|
102
|
+
key: "componentDidMount",
|
|
103
|
+
value: function componentDidMount() {
|
|
104
|
+
document.addEventListener('keyup', this.onKeyUp, false);
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "componentWillUnmount",
|
|
108
|
+
value: function componentWillUnmount() {
|
|
109
|
+
document.removeEventListener('keyup', this.onKeyUp, false);
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "onChange",
|
|
113
|
+
value: function onChange(nextFile, nextIndex) {
|
|
114
|
+
if (this.props.onChangeRequest) {
|
|
115
|
+
this.props.onChangeRequest(nextFile, nextIndex);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "render",
|
|
120
|
+
value: function render() {
|
|
121
|
+
var _this$props3 = this.props,
|
|
122
|
+
currentFile = _this$props3.currentFile,
|
|
123
|
+
hasPrevious = _this$props3.hasPrevious,
|
|
124
|
+
hasNext = _this$props3.hasNext,
|
|
125
|
+
toolbarRef = _this$props3.toolbarRef,
|
|
126
|
+
showNavigation = _this$props3.showNavigation,
|
|
127
|
+
renderFallbackExtraContent = _this$props3.renderFallbackExtraContent,
|
|
128
|
+
validForPanel = _this$props3.validForPanel,
|
|
129
|
+
children = _this$props3.children,
|
|
130
|
+
componentsProps = _this$props3.componentsProps; // this `expanded` property makes the next/previous controls cover the displayed image
|
|
131
|
+
|
|
132
|
+
var expanded = currentFile && currentFile.class === 'image';
|
|
133
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ViewerControls.default, {
|
|
134
|
+
file: currentFile,
|
|
135
|
+
onClose: this.onClose,
|
|
136
|
+
hasPrevious: hasPrevious,
|
|
137
|
+
hasNext: hasNext,
|
|
138
|
+
onPrevious: this.onPrevious,
|
|
139
|
+
onNext: this.onNext,
|
|
140
|
+
expanded: expanded,
|
|
141
|
+
toolbarProps: _objectSpread(_objectSpread({}, componentsProps.toolbarProps), {}, {
|
|
142
|
+
toolbarRef: toolbarRef
|
|
143
|
+
}),
|
|
144
|
+
showNavigation: showNavigation,
|
|
145
|
+
showInfoPanel: validForPanel
|
|
146
|
+
}, children, /*#__PURE__*/_react.default.createElement(_ViewerByFile.default, {
|
|
147
|
+
file: currentFile,
|
|
148
|
+
onClose: this.onClose,
|
|
149
|
+
renderFallbackExtraContent: renderFallbackExtraContent,
|
|
150
|
+
componentsProps: componentsProps
|
|
151
|
+
})));
|
|
152
|
+
}
|
|
153
|
+
}]);
|
|
154
|
+
return Viewer;
|
|
155
|
+
}(_react.Component);
|
|
156
|
+
|
|
157
|
+
Viewer.propTypes = {
|
|
158
|
+
/** One `io.cozy.files` to display */
|
|
159
|
+
currentFile: _proptypes.FileDoctype.isRequired,
|
|
160
|
+
hasNext: _propTypes.default.bool,
|
|
161
|
+
hasPrevious: _propTypes.default.bool,
|
|
162
|
+
|
|
163
|
+
/** Called when the user wants to leave the Viewer */
|
|
164
|
+
onCloseRequest: _propTypes.default.func,
|
|
165
|
+
|
|
166
|
+
/** Called with (nextFile, nextIndex) when the user requests to navigate to another file */
|
|
167
|
+
onChangeRequest: _propTypes.default.func,
|
|
168
|
+
toolbarRef: _propTypes.default.object,
|
|
169
|
+
|
|
170
|
+
/** Whether to show left and right arrows to navigate between files */
|
|
171
|
+
showNavigation: _propTypes.default.bool,
|
|
172
|
+
|
|
173
|
+
/** A render prop that is called when a file can't be displayed */
|
|
174
|
+
renderFallbackExtraContent: _propTypes.default.func,
|
|
175
|
+
validForPanel: _propTypes.default.bool,
|
|
176
|
+
|
|
177
|
+
/* Props passed to components with the same name */
|
|
178
|
+
componentsProps: _propTypes.default.shape({
|
|
179
|
+
/** Used to open an Only Office file */
|
|
180
|
+
OnlyOfficeViewer: _propTypes.default.shape({
|
|
181
|
+
/** Whether Only Office is enabled on the server */
|
|
182
|
+
isEnabled: _propTypes.default.bool,
|
|
183
|
+
|
|
184
|
+
/** To open the Only Office file */
|
|
185
|
+
opener: _propTypes.default.func
|
|
186
|
+
}),
|
|
187
|
+
toolbarProps: _propTypes.default.shape(_proptypes2.toolbarPropsPropType)
|
|
188
|
+
})
|
|
189
|
+
};
|
|
190
|
+
var _default = Viewer;
|
|
191
|
+
exports.default = _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default ViewerContainerWrapper;
|
|
2
|
+
declare function ViewerContainerWrapper({ disableModal, ...props }: {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
disableModal: any;
|
|
5
|
+
}): JSX.Element;
|
|
6
|
+
declare namespace ViewerContainerWrapper {
|
|
7
|
+
namespace defaultProps {
|
|
8
|
+
namespace componentsProps {
|
|
9
|
+
namespace modalProps {
|
|
10
|
+
const open: boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
namespace propTypes {
|
|
15
|
+
export const disableModal: PropTypes.Requireable<boolean>;
|
|
16
|
+
const componentsProps_1: PropTypes.Requireable<PropTypes.InferProps<{
|
|
17
|
+
modalProps: PropTypes.Requireable<object>;
|
|
18
|
+
}>>;
|
|
19
|
+
export { componentsProps_1 as componentsProps };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
+
|
|
16
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
+
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
|
|
22
|
+
var _Modal = _interopRequireDefault(require("cozy-ui/transpiled/react/Modal"));
|
|
23
|
+
|
|
24
|
+
var _proptypes = require("cozy-ui/transpiled/react/proptypes");
|
|
25
|
+
|
|
26
|
+
var _Alert = _interopRequireDefault(require("cozy-ui/transpiled/react/providers/Alert"));
|
|
27
|
+
|
|
28
|
+
var _Breakpoints = _interopRequireDefault(require("cozy-ui/transpiled/react/providers/Breakpoints"));
|
|
29
|
+
|
|
30
|
+
var _CozyTheme = require("cozy-ui/transpiled/react/providers/CozyTheme");
|
|
31
|
+
|
|
32
|
+
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
33
|
+
|
|
34
|
+
var _Viewer = _interopRequireDefault(require("./Viewer"));
|
|
35
|
+
|
|
36
|
+
var _ViewerInformationsWrapper = _interopRequireDefault(require("./ViewerInformationsWrapper"));
|
|
37
|
+
|
|
38
|
+
var _helpers = require("./helpers");
|
|
39
|
+
|
|
40
|
+
var _locales = require("./locales");
|
|
41
|
+
|
|
42
|
+
var _proptypes2 = require("./proptypes");
|
|
43
|
+
|
|
44
|
+
var _ActionMenuProvider = require("./providers/ActionMenuProvider");
|
|
45
|
+
|
|
46
|
+
var _EncryptedProvider = _interopRequireDefault(require("./providers/EncryptedProvider"));
|
|
47
|
+
|
|
48
|
+
var _excluded = ["className", "disableFooter", "disablePanel", "editPathByModelProps", "children", "componentsProps", "isPublic"],
|
|
49
|
+
_excluded2 = ["disableModal"];
|
|
50
|
+
|
|
51
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
52
|
+
|
|
53
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
54
|
+
|
|
55
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
56
|
+
|
|
57
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
58
|
+
|
|
59
|
+
var styles = {
|
|
60
|
+
"viewer-wrapper": "styles__viewer-wrapper___OkRf5",
|
|
61
|
+
"flagship-app": "styles__flagship-app___2EqfW"
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var ViewerContainer = function ViewerContainer(props) {
|
|
65
|
+
var className = props.className,
|
|
66
|
+
disableFooter = props.disableFooter,
|
|
67
|
+
disablePanel = props.disablePanel,
|
|
68
|
+
editPathByModelProps = props.editPathByModelProps,
|
|
69
|
+
children = props.children,
|
|
70
|
+
componentsProps = props.componentsProps,
|
|
71
|
+
isPublic = props.isPublic,
|
|
72
|
+
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
73
|
+
var currentIndex = props.currentIndex,
|
|
74
|
+
files = props.files,
|
|
75
|
+
currentURL = props.currentURL;
|
|
76
|
+
var toolbarRef = /*#__PURE__*/(0, _react.createRef)();
|
|
77
|
+
|
|
78
|
+
var _useBreakpoints = (0, _Breakpoints.default)(),
|
|
79
|
+
isDesktop = _useBreakpoints.isDesktop;
|
|
80
|
+
|
|
81
|
+
(0, _I18n.useExtendI18n)(_locales.locales);
|
|
82
|
+
var currentFile = files[currentIndex];
|
|
83
|
+
var fileCount = files.length;
|
|
84
|
+
var hasPrevious = currentIndex > 0;
|
|
85
|
+
var hasNext = currentIndex < fileCount - 1;
|
|
86
|
+
var validForPanel = (0, _helpers.isValidForPanel)({
|
|
87
|
+
file: currentFile
|
|
88
|
+
}) && isDesktop && !disablePanel;
|
|
89
|
+
|
|
90
|
+
var componentsPropsWithDefault = _objectSpread(_objectSpread({}, componentsProps), {}, {
|
|
91
|
+
toolbarProps: _objectSpread({
|
|
92
|
+
showToolbar: true,
|
|
93
|
+
showClose: true
|
|
94
|
+
}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.toolbarProps)
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return /*#__PURE__*/_react.default.createElement(_Alert.default, null, /*#__PURE__*/_react.default.createElement(_ActionMenuProvider.ActionMenuProvider, {
|
|
98
|
+
editPathByModelProps: editPathByModelProps
|
|
99
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
100
|
+
id: "viewer-wrapper",
|
|
101
|
+
className: (0, _classnames.default)(styles['viewer-wrapper'], className)
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement(_EncryptedProvider.default, {
|
|
103
|
+
url: currentURL
|
|
104
|
+
}, /*#__PURE__*/_react.default.createElement(_Viewer.default, (0, _extends2.default)({}, rest, {
|
|
105
|
+
componentsProps: componentsPropsWithDefault,
|
|
106
|
+
currentFile: currentFile,
|
|
107
|
+
hasPrevious: hasPrevious,
|
|
108
|
+
hasNext: hasNext,
|
|
109
|
+
validForPanel: validForPanel,
|
|
110
|
+
toolbarRef: toolbarRef
|
|
111
|
+
}), children)), /*#__PURE__*/_react.default.createElement(_ViewerInformationsWrapper.default, {
|
|
112
|
+
isPublic: isPublic,
|
|
113
|
+
disableFooter: disableFooter,
|
|
114
|
+
validForPanel: validForPanel,
|
|
115
|
+
currentFile: currentFile,
|
|
116
|
+
toolbarRef: toolbarRef
|
|
117
|
+
}, children))));
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
ViewerContainer.propTypes = {
|
|
121
|
+
/** One or more `io.cozy.files` to display */
|
|
122
|
+
files: _propTypes.default.arrayOf(_proptypes.FileDoctype).isRequired,
|
|
123
|
+
|
|
124
|
+
/** Index of the file to show */
|
|
125
|
+
currentIndex: _propTypes.default.number,
|
|
126
|
+
|
|
127
|
+
/** Optionnal URL of the file */
|
|
128
|
+
currentURL: _propTypes.default.string,
|
|
129
|
+
className: _propTypes.default.string,
|
|
130
|
+
|
|
131
|
+
/** Called when the user wants to leave the Viewer */
|
|
132
|
+
onCloseRequest: _propTypes.default.func,
|
|
133
|
+
|
|
134
|
+
/** Called with (nextFile, nextIndex) when the user requests to navigate to another file */
|
|
135
|
+
onChangeRequest: _propTypes.default.func,
|
|
136
|
+
|
|
137
|
+
/** Whether to show left and right arrows to navigate between files */
|
|
138
|
+
showNavigation: _propTypes.default.bool,
|
|
139
|
+
|
|
140
|
+
/** A render prop that is called when a file can't be displayed */
|
|
141
|
+
renderFallbackExtraContent: _propTypes.default.func,
|
|
142
|
+
|
|
143
|
+
/** Edit path by model properties */
|
|
144
|
+
editPathByModelProps: _propTypes.default.shape({
|
|
145
|
+
/** URL used to edit the file when editing a `information` type metadata (text, date) */
|
|
146
|
+
information: _propTypes.default.string,
|
|
147
|
+
|
|
148
|
+
/** URL used to edit the file when editing a `page` type metadata (side of the document) */
|
|
149
|
+
page: _propTypes.default.string
|
|
150
|
+
}),
|
|
151
|
+
|
|
152
|
+
/** Show/Hide the panel containing more information about the file only on Desktop */
|
|
153
|
+
disablePanel: _propTypes.default.bool,
|
|
154
|
+
|
|
155
|
+
/** Show/Hide the panel containing more information about the file only on Phone & Tablet devices */
|
|
156
|
+
disableFooter: _propTypes.default.bool,
|
|
157
|
+
|
|
158
|
+
/** If the Viewer is in public view */
|
|
159
|
+
isPublic: _propTypes.default.bool,
|
|
160
|
+
|
|
161
|
+
/* Props passed to components with the same name */
|
|
162
|
+
componentsProps: _propTypes.default.shape({
|
|
163
|
+
/** Used to open an Only Office file */
|
|
164
|
+
OnlyOfficeViewer: _propTypes.default.shape({
|
|
165
|
+
/** Whether Only Office is enabled on the server */
|
|
166
|
+
isEnabled: _propTypes.default.bool,
|
|
167
|
+
|
|
168
|
+
/** To open the Only Office file */
|
|
169
|
+
opener: _propTypes.default.func
|
|
170
|
+
}),
|
|
171
|
+
|
|
172
|
+
/** Toolbar properties */
|
|
173
|
+
toolbarProps: _propTypes.default.shape(_proptypes2.toolbarPropsPropType)
|
|
174
|
+
})
|
|
175
|
+
};
|
|
176
|
+
ViewerContainer.defaultProps = {
|
|
177
|
+
currentIndex: 0,
|
|
178
|
+
showNavigation: true
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
var ViewerContainerWrapper = function ViewerContainerWrapper(_ref) {
|
|
182
|
+
var disableModal = _ref.disableModal,
|
|
183
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded2);
|
|
184
|
+
|
|
185
|
+
var _useCozyTheme = (0, _CozyTheme.useCozyTheme)(),
|
|
186
|
+
type = _useCozyTheme.type,
|
|
187
|
+
variant = _useCozyTheme.variant;
|
|
188
|
+
|
|
189
|
+
var _ref2 = props.componentsProps || {},
|
|
190
|
+
_ref2$modalProps = _ref2.modalProps,
|
|
191
|
+
modalProps = _ref2$modalProps === void 0 ? {
|
|
192
|
+
open: true
|
|
193
|
+
} : _ref2$modalProps;
|
|
194
|
+
|
|
195
|
+
if (disableModal) {
|
|
196
|
+
return /*#__PURE__*/_react.default.createElement(ViewerContainer, props);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return /*#__PURE__*/_react.default.createElement(_Modal.default, (0, _extends2.default)({}, modalProps, {
|
|
200
|
+
className: "CozyTheme--".concat(type, "-").concat(variant)
|
|
201
|
+
}), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(ViewerContainer, props)));
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
ViewerContainerWrapper.defaultProps = {
|
|
205
|
+
componentsProps: {
|
|
206
|
+
modalProps: {
|
|
207
|
+
open: true
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
ViewerContainerWrapper.propTypes = {
|
|
212
|
+
/** To avoid wrapping the Viewer with a Modal component */
|
|
213
|
+
disableModal: _propTypes.default.bool,
|
|
214
|
+
|
|
215
|
+
/** Props passed to Modal component */
|
|
216
|
+
componentsProps: _propTypes.default.shape({
|
|
217
|
+
modalProps: _propTypes.default.object
|
|
218
|
+
})
|
|
219
|
+
};
|
|
220
|
+
var _default = ViewerContainerWrapper;
|
|
221
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _ = _interopRequireDefault(require("."));
|
|
11
|
+
|
|
12
|
+
var _default = _.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default ViewerInformationsWrapper;
|
|
2
|
+
declare function ViewerInformationsWrapper({ currentFile, disableFooter, validForPanel, toolbarRef, isPublic, children }: {
|
|
3
|
+
currentFile: any;
|
|
4
|
+
disableFooter: any;
|
|
5
|
+
validForPanel: any;
|
|
6
|
+
toolbarRef: any;
|
|
7
|
+
isPublic: any;
|
|
8
|
+
children: any;
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
declare namespace ViewerInformationsWrapper {
|
|
11
|
+
namespace propTypes {
|
|
12
|
+
const currentFile: any;
|
|
13
|
+
const disableFooter: PropTypes.Requireable<boolean>;
|
|
14
|
+
const validForPanel: PropTypes.Requireable<boolean>;
|
|
15
|
+
const toolbarRef: PropTypes.Requireable<object>;
|
|
16
|
+
const isPublic: PropTypes.Requireable<boolean>;
|
|
17
|
+
const children: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _useSetFlagshipUI = require("cozy-ui/transpiled/react/hooks/useSetFlagshipUi/useSetFlagshipUI");
|
|
15
|
+
|
|
16
|
+
var _proptypes = require("cozy-ui/transpiled/react/proptypes");
|
|
17
|
+
|
|
18
|
+
var _CozyTheme = require("cozy-ui/transpiled/react/providers/CozyTheme");
|
|
19
|
+
|
|
20
|
+
var _styles = require("cozy-ui/transpiled/react/styles");
|
|
21
|
+
|
|
22
|
+
var _FooterContent = _interopRequireDefault(require("./Footer/FooterContent"));
|
|
23
|
+
|
|
24
|
+
var _PanelContent = _interopRequireDefault(require("./Panel/PanelContent"));
|
|
25
|
+
|
|
26
|
+
var _Footer = _interopRequireDefault(require("./components/Footer"));
|
|
27
|
+
|
|
28
|
+
var _InformationPanel = _interopRequireDefault(require("./components/InformationPanel"));
|
|
29
|
+
|
|
30
|
+
var ViewerInformationsWrapper = function ViewerInformationsWrapper(_ref) {
|
|
31
|
+
var currentFile = _ref.currentFile,
|
|
32
|
+
disableFooter = _ref.disableFooter,
|
|
33
|
+
validForPanel = _ref.validForPanel,
|
|
34
|
+
toolbarRef = _ref.toolbarRef,
|
|
35
|
+
isPublic = _ref.isPublic,
|
|
36
|
+
children = _ref.children;
|
|
37
|
+
var theme = (0, _styles.useTheme)();
|
|
38
|
+
|
|
39
|
+
var _useCozyTheme = (0, _CozyTheme.useCozyTheme)(),
|
|
40
|
+
isLight = _useCozyTheme.isLight;
|
|
41
|
+
|
|
42
|
+
var sidebar = document.querySelector('[class*="sidebar"]');
|
|
43
|
+
(0, _useSetFlagshipUI.useSetFlagshipUI)({
|
|
44
|
+
bottomBackground: theme.palette.background.paper,
|
|
45
|
+
bottomTheme: isLight ? 'dark' : 'light'
|
|
46
|
+
}, {
|
|
47
|
+
bottomBackground: theme.palette.background[sidebar ? 'default' : 'paper']
|
|
48
|
+
});
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !disableFooter && /*#__PURE__*/_react.default.createElement(_Footer.default, null, /*#__PURE__*/_react.default.createElement(_FooterContent.default, {
|
|
50
|
+
file: currentFile,
|
|
51
|
+
toolbarRef: toolbarRef,
|
|
52
|
+
isPublic: isPublic
|
|
53
|
+
}, children)), validForPanel && /*#__PURE__*/_react.default.createElement(_InformationPanel.default, null, /*#__PURE__*/_react.default.createElement(_PanelContent.default, {
|
|
54
|
+
file: currentFile,
|
|
55
|
+
isPublic: isPublic
|
|
56
|
+
})));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
ViewerInformationsWrapper.propTypes = {
|
|
60
|
+
currentFile: _proptypes.FileDoctype.isRequired,
|
|
61
|
+
disableFooter: _propTypes.default.bool,
|
|
62
|
+
validForPanel: _propTypes.default.bool,
|
|
63
|
+
toolbarRef: _propTypes.default.object,
|
|
64
|
+
isPublic: _propTypes.default.bool,
|
|
65
|
+
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.arrayOf(_propTypes.default.node)])
|
|
66
|
+
};
|
|
67
|
+
var _default = ViewerInformationsWrapper;
|
|
68
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|