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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 1.1.0 (2024-09-11)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- Add cozy-viewer ([d960ea6](https://github.com/cozy/cozy-libs/commit/d960ea6724afd6b036e0afda31f1742103a149ac))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Cozy.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/Readme.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Cozy Viewer
|
|
2
|
+
|
|
3
|
+
Cozy-Viewer provides a component to show files in a viewer.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
- You must `import 'cozy-viewer/dist/stylesheet.css'` somewhere in your app
|
|
8
|
+
- You must have [WebviewIntent Provider](https://github.com/cozy/cozy-libs/blob/b1ad6f5933b463878f641d9fbb63eddd4c45b0d0/packages/cozy-intent/src/view/components/WebviewIntentProvider.tsx#L89)
|
|
9
|
+
- You must have [CozySharing Provider](https://github.com/cozy/cozy-libs/tree/master/packages/cozy-sharing)
|
|
10
|
+
- In order to download and display the files, it will need a `cozy-client` instance in the React context.
|
|
11
|
+
- To have the panels, the app need to have [cozy-harvest-lib](https://github.com/cozy/cozy-libs/tree/master/packages/cozy-harvest-lib) installed
|
|
12
|
+
- See peer dependencies to be sure to not miss anything
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
`import Viewer from 'cozy-viewer'`
|
|
17
|
+
|
|
18
|
+
## Props
|
|
19
|
+
|
|
20
|
+
- **files** : `<array>` – One or more `io.cozy.files` to display
|
|
21
|
+
- **currentIndex** : `<number>` – Index of the file to show
|
|
22
|
+
- **currentURL** : `<string>` – Optionnal URL of the file
|
|
23
|
+
- **className** : `<string>` – CSS classes
|
|
24
|
+
- **showNavigation** : `<boolean>` – Whether to show left and right arrows to navigate between files
|
|
25
|
+
- **renderFallbackExtraContent** : `<function>` – A render prop that is called when a file can't be displayed
|
|
26
|
+
- **disablePanel** : `<boolean>` – Show/Hide the panel containing more information about the file only on Desktop
|
|
27
|
+
- **disableFooter** : `<boolean>` – Show/Hide the panel containing more information about the file only on Phone & Tablet devices
|
|
28
|
+
- **disableModal** : `<boolean>` – To avoid wrapping the Viewer with a Modal component (wrapper of Viewer)
|
|
29
|
+
- **editPathByModelProps** : `<object>` – Edit path by model properties
|
|
30
|
+
- **information** : `<string>` – URL used to edit the file when editing a `information` type metadata (text, date)
|
|
31
|
+
- **page** : `<string>` – URL used to edit the file when editing a `page` type metadata (side of the document)
|
|
32
|
+
- **onChangeRequest** : `<function>` - Called with (nextFile, nextIndex) when the user requests to navigate to another file
|
|
33
|
+
- **onCloseRequest** : `<function>` - Called when the user wants to leave the Viewer
|
|
34
|
+
- **isPublic**: `<boolean>` - Whether the viewer is used in a public page or not
|
|
35
|
+
- **componentsProps** : `<object>` – Props passed to components with the same name
|
|
36
|
+
- **modalProps** : `<object>` – Props passed to Modal component
|
|
37
|
+
- **OnlyOfficeViewer** : `<object>` – Used to open an Only Office file
|
|
38
|
+
- **isEnabled** : `<boolean>` – Whether Only Office is enabled on the server
|
|
39
|
+
- **opener** : `<function>` – To open the Only Office file
|
|
40
|
+
- **toolbarProps** : `<object>` – Toolbar properties
|
|
41
|
+
- **toolbarRef** : `<object>` – React reference of the toolbar node
|
|
42
|
+
- **showToolbar** : `<boolean>` – Whether to show the toolbar or not. Note that the built-in close button is in the toolbar
|
|
43
|
+
- **showClose** : `<boolean>` – Whether to show close button in toolbar
|
|
44
|
+
- **showFilePath** : `<boolean>` – Whether to show file path below his name
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
presets: ['cozy-app'],
|
|
3
|
+
env: {
|
|
4
|
+
transpilation: {
|
|
5
|
+
ignore: ['**/*.spec.jsx', '**/*.spec.js', '**/*.spec.tsx', '**/*.spec.ts']
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
plugins: [
|
|
9
|
+
[
|
|
10
|
+
'css-modules-transform',
|
|
11
|
+
{
|
|
12
|
+
extensions: ['.styl'],
|
|
13
|
+
preprocessCss: './preprocess',
|
|
14
|
+
extractCss: './dist/stylesheet.css',
|
|
15
|
+
generateScopedName:
|
|
16
|
+
process.env['NODE_ENV'] == 'test'
|
|
17
|
+
? '[local]'
|
|
18
|
+
: '[name]__[local]___[hash:base64:5]'
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
],
|
|
22
|
+
ignore: ['examples/**/*', '**/*.md', '**/*.styl', '**/*.json', '**/*.snap']
|
|
23
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default BottomSheetContent;
|
|
2
|
+
declare function BottomSheetContent({ file, isPublic }: {
|
|
3
|
+
file: any;
|
|
4
|
+
isPublic: any;
|
|
5
|
+
}): JSX.Element[];
|
|
6
|
+
declare namespace BottomSheetContent {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
const file: PropTypes.Validator<object>;
|
|
9
|
+
const isPublic: PropTypes.Requireable<boolean>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,45 @@
|
|
|
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 _BottomSheet = require("cozy-ui/transpiled/react/BottomSheet");
|
|
15
|
+
|
|
16
|
+
var _getPanelBlocks = _interopRequireWildcard(require("../Panel/getPanelBlocks"));
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
var BottomSheetContent = function BottomSheetContent(_ref) {
|
|
23
|
+
var file = _ref.file,
|
|
24
|
+
isPublic = _ref.isPublic;
|
|
25
|
+
var panelBlocks = (0, _getPanelBlocks.default)({
|
|
26
|
+
panelBlocksSpecs: (0, _getPanelBlocks.getPanelBlocksSpecs)(isPublic),
|
|
27
|
+
file: file
|
|
28
|
+
});
|
|
29
|
+
return panelBlocks.map(function (PanelBlock, index) {
|
|
30
|
+
return /*#__PURE__*/_react.default.createElement(_BottomSheet.BottomSheetItem, {
|
|
31
|
+
key: index,
|
|
32
|
+
disableGutters: true,
|
|
33
|
+
disableElevation: index === panelBlocks.length - 1
|
|
34
|
+
}, /*#__PURE__*/_react.default.createElement(PanelBlock, {
|
|
35
|
+
file: file
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
BottomSheetContent.propTypes = {
|
|
41
|
+
file: _propTypes.default.object.isRequired,
|
|
42
|
+
isPublic: _propTypes.default.bool
|
|
43
|
+
};
|
|
44
|
+
var _default = BottomSheetContent;
|
|
45
|
+
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default DownloadButton;
|
|
2
|
+
declare function DownloadButton({ file, variant }: {
|
|
3
|
+
file: any;
|
|
4
|
+
variant: any;
|
|
5
|
+
}): JSX.Element;
|
|
6
|
+
declare namespace DownloadButton {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
const file: PropTypes.Requireable<object>;
|
|
9
|
+
const variant: PropTypes.Requireable<string>;
|
|
10
|
+
}
|
|
11
|
+
namespace defaultProptypes {
|
|
12
|
+
const variant_1: string;
|
|
13
|
+
export { variant_1 as variant };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,113 @@
|
|
|
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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _cozyClient = require("cozy-client");
|
|
19
|
+
|
|
20
|
+
var _Buttons = _interopRequireDefault(require("cozy-ui/transpiled/react/Buttons"));
|
|
21
|
+
|
|
22
|
+
var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
23
|
+
|
|
24
|
+
var _IconButton = _interopRequireDefault(require("cozy-ui/transpiled/react/IconButton"));
|
|
25
|
+
|
|
26
|
+
var _Download = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Download"));
|
|
27
|
+
|
|
28
|
+
var _Alerter = _interopRequireDefault(require("cozy-ui/transpiled/react/deprecated/Alerter"));
|
|
29
|
+
|
|
30
|
+
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
31
|
+
|
|
32
|
+
var DownloadButton = function DownloadButton(_ref) {
|
|
33
|
+
var file = _ref.file,
|
|
34
|
+
variant = _ref.variant;
|
|
35
|
+
var client = (0, _cozyClient.useClient)();
|
|
36
|
+
|
|
37
|
+
var _useI18n = (0, _I18n.useI18n)(),
|
|
38
|
+
t = _useI18n.t;
|
|
39
|
+
|
|
40
|
+
var icon = /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
41
|
+
icon: _Download.default
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
var label = t('Viewer.download');
|
|
45
|
+
|
|
46
|
+
var handleClick = /*#__PURE__*/function () {
|
|
47
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
48
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
_context.prev = 0;
|
|
53
|
+
_context.next = 3;
|
|
54
|
+
return client.collection('io.cozy.files').download(file);
|
|
55
|
+
|
|
56
|
+
case 3:
|
|
57
|
+
_context.next = 8;
|
|
58
|
+
break;
|
|
59
|
+
|
|
60
|
+
case 5:
|
|
61
|
+
_context.prev = 5;
|
|
62
|
+
_context.t0 = _context["catch"](0);
|
|
63
|
+
|
|
64
|
+
_Alerter.default.info('Viewer.error.generic');
|
|
65
|
+
|
|
66
|
+
case 8:
|
|
67
|
+
case "end":
|
|
68
|
+
return _context.stop();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, _callee, null, [[0, 5]]);
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
return function handleClick() {
|
|
75
|
+
return _ref2.apply(this, arguments);
|
|
76
|
+
};
|
|
77
|
+
}();
|
|
78
|
+
|
|
79
|
+
if (variant === 'iconButton') {
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
81
|
+
className: "u-white",
|
|
82
|
+
"aria-label": label,
|
|
83
|
+
onClick: handleClick
|
|
84
|
+
}, icon);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (variant === 'buttonIcon') {
|
|
88
|
+
return /*#__PURE__*/_react.default.createElement(_Buttons.default, {
|
|
89
|
+
variant: "secondary",
|
|
90
|
+
label: icon,
|
|
91
|
+
"aria-label": label,
|
|
92
|
+
onClick: handleClick
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return /*#__PURE__*/_react.default.createElement(_Buttons.default, {
|
|
97
|
+
fullWidth: true,
|
|
98
|
+
variant: "secondary",
|
|
99
|
+
startIcon: icon,
|
|
100
|
+
label: label,
|
|
101
|
+
onClick: handleClick
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
DownloadButton.propTypes = {
|
|
106
|
+
file: _propTypes.default.object,
|
|
107
|
+
variant: _propTypes.default.oneOf(['default', 'iconButton', 'buttonIcon'])
|
|
108
|
+
};
|
|
109
|
+
DownloadButton.defaultProptypes = {
|
|
110
|
+
variant: 'default'
|
|
111
|
+
};
|
|
112
|
+
var _default = DownloadButton;
|
|
113
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default FooterActionButtons;
|
|
2
|
+
declare function FooterActionButtons({ children, file }: {
|
|
3
|
+
children: any;
|
|
4
|
+
file: any;
|
|
5
|
+
}): any;
|
|
6
|
+
declare namespace FooterActionButtons {
|
|
7
|
+
const displayName: string;
|
|
8
|
+
namespace propTypes {
|
|
9
|
+
const children: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
10
|
+
const file: PropTypes.Requireable<object>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,33 @@
|
|
|
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 = require("react");
|
|
13
|
+
|
|
14
|
+
var _helpers = require("./helpers");
|
|
15
|
+
|
|
16
|
+
var FooterActionButtons = function FooterActionButtons(_ref) {
|
|
17
|
+
var children = _ref.children,
|
|
18
|
+
file = _ref.file;
|
|
19
|
+
if (!children) return null;
|
|
20
|
+
return (0, _helpers.mapToAllChildren)(children, function (child) {
|
|
21
|
+
return /*#__PURE__*/(0, _react.cloneElement)(child, {
|
|
22
|
+
file: file
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
FooterActionButtons.displayName = 'FooterActionButtons';
|
|
28
|
+
FooterActionButtons.propTypes = {
|
|
29
|
+
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.arrayOf(_propTypes.default.node)]),
|
|
30
|
+
file: _propTypes.default.object
|
|
31
|
+
};
|
|
32
|
+
var _default = FooterActionButtons;
|
|
33
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default FooterContent;
|
|
2
|
+
declare function FooterContent({ file, toolbarRef, children, isPublic }: {
|
|
3
|
+
file: any;
|
|
4
|
+
toolbarRef: any;
|
|
5
|
+
children: any;
|
|
6
|
+
isPublic: any;
|
|
7
|
+
}): JSX.Element | null;
|
|
8
|
+
declare namespace FooterContent {
|
|
9
|
+
namespace propTypes {
|
|
10
|
+
const file: PropTypes.Validator<object>;
|
|
11
|
+
const toolbarRef: PropTypes.Requireable<object>;
|
|
12
|
+
const isPublic: PropTypes.Requireable<boolean>;
|
|
13
|
+
const children: PropTypes.Requireable<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,120 @@
|
|
|
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 _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _BottomSheet = _interopRequireWildcard(require("cozy-ui/transpiled/react/BottomSheet"));
|
|
17
|
+
|
|
18
|
+
var _styles = require("cozy-ui/transpiled/react/styles");
|
|
19
|
+
|
|
20
|
+
var _BottomSheetContent = _interopRequireDefault(require("./BottomSheetContent"));
|
|
21
|
+
|
|
22
|
+
var _helpers = require("./helpers");
|
|
23
|
+
|
|
24
|
+
var _PrintButton = _interopRequireDefault(require("../components/PrintButton"));
|
|
25
|
+
|
|
26
|
+
var _helpers2 = require("../helpers");
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
var FooterButtons = function FooterButtons(_ref) {
|
|
33
|
+
var file = _ref.file,
|
|
34
|
+
_ref$FooterActionButt = _ref.FooterActionButtonsWithFile,
|
|
35
|
+
FooterActionButtonsWithFile = _ref$FooterActionButt === void 0 ? {
|
|
36
|
+
FooterActionButtonsWithFile: FooterActionButtonsWithFile
|
|
37
|
+
} : _ref$FooterActionButt;
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, FooterActionButtonsWithFile, /*#__PURE__*/_react.default.createElement(_PrintButton.default, {
|
|
39
|
+
file: file,
|
|
40
|
+
variant: "button"
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
45
|
+
return {
|
|
46
|
+
footer: {
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
width: 'calc(100% - 2rem)',
|
|
50
|
+
height: '100%',
|
|
51
|
+
paddingLeft: '1rem',
|
|
52
|
+
paddingRight: '1rem',
|
|
53
|
+
borderTop: "1px solid ".concat(theme.palette.divider),
|
|
54
|
+
columnGap: '0.5rem'
|
|
55
|
+
},
|
|
56
|
+
bottomSheetHeader: {
|
|
57
|
+
columnGap: '0.5rem'
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var FooterContent = function FooterContent(_ref2) {
|
|
63
|
+
var file = _ref2.file,
|
|
64
|
+
toolbarRef = _ref2.toolbarRef,
|
|
65
|
+
children = _ref2.children,
|
|
66
|
+
isPublic = _ref2.isPublic;
|
|
67
|
+
var styles = useStyles();
|
|
68
|
+
var toolbarProps = (0, _react.useMemo)(function () {
|
|
69
|
+
return {
|
|
70
|
+
ref: toolbarRef
|
|
71
|
+
};
|
|
72
|
+
}, [toolbarRef]);
|
|
73
|
+
var FooterActionButtonsWithFile = (0, _helpers.extractChildrenCompByName)({
|
|
74
|
+
children: children,
|
|
75
|
+
file: file,
|
|
76
|
+
name: 'FooterActionButtons'
|
|
77
|
+
});
|
|
78
|
+
var bottomSheetSettings = {
|
|
79
|
+
isOpenMin: isPublic ? true : false,
|
|
80
|
+
mediumHeightRatio: isPublic ? undefined : 0.5
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if ((0, _helpers2.isValidForPanel)({
|
|
84
|
+
file: file
|
|
85
|
+
})) {
|
|
86
|
+
return /*#__PURE__*/_react.default.createElement(_BottomSheet.default, {
|
|
87
|
+
toolbarProps: toolbarProps,
|
|
88
|
+
portalProps: {
|
|
89
|
+
disablePortal: true
|
|
90
|
+
},
|
|
91
|
+
settings: bottomSheetSettings
|
|
92
|
+
}, /*#__PURE__*/_react.default.createElement(_BottomSheet.BottomSheetHeader, {
|
|
93
|
+
className: (0, _classnames.default)('u-ph-1 u-pb-1', styles.bottomSheetHeader)
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(FooterButtons, {
|
|
95
|
+
file: file,
|
|
96
|
+
FooterActionButtonsWithFile: FooterActionButtonsWithFile
|
|
97
|
+
})), /*#__PURE__*/_react.default.createElement(_BottomSheetContent.default, {
|
|
98
|
+
file: file,
|
|
99
|
+
isPublic: isPublic
|
|
100
|
+
}));
|
|
101
|
+
} // If `FooterActionButtons` hasn't children
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (!FooterActionButtonsWithFile) return null;
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
106
|
+
className: styles.footer
|
|
107
|
+
}, /*#__PURE__*/_react.default.createElement(FooterButtons, {
|
|
108
|
+
file: file,
|
|
109
|
+
FooterActionButtonsWithFile: FooterActionButtonsWithFile
|
|
110
|
+
}));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
FooterContent.propTypes = {
|
|
114
|
+
file: _propTypes.default.object.isRequired,
|
|
115
|
+
toolbarRef: _propTypes.default.object,
|
|
116
|
+
isPublic: _propTypes.default.bool,
|
|
117
|
+
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.arrayOf(_propTypes.default.node)])
|
|
118
|
+
};
|
|
119
|
+
var _default = FooterContent;
|
|
120
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { exportFilesNative };
|
|
2
|
+
export default ForwardButton;
|
|
3
|
+
import { exportFilesNative } from "./helpers";
|
|
4
|
+
declare function ForwardButton({ file, variant, onClick }: {
|
|
5
|
+
file: any;
|
|
6
|
+
variant: any;
|
|
7
|
+
onClick: any;
|
|
8
|
+
}): JSX.Element;
|
|
9
|
+
declare namespace ForwardButton {
|
|
10
|
+
namespace propTypes {
|
|
11
|
+
const file: PropTypes.Validator<object>;
|
|
12
|
+
const variant: PropTypes.Requireable<string>;
|
|
13
|
+
const onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
14
|
+
}
|
|
15
|
+
namespace defaultProptypes {
|
|
16
|
+
const variant_1: string;
|
|
17
|
+
export { variant_1 as variant };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
Object.defineProperty(exports, "exportFilesNative", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _helpers.exportFilesNative;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
17
|
+
|
|
18
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
19
|
+
|
|
20
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
21
|
+
|
|
22
|
+
var _react = _interopRequireDefault(require("react"));
|
|
23
|
+
|
|
24
|
+
var _cozyClient = require("cozy-client");
|
|
25
|
+
|
|
26
|
+
var _sharing = require("cozy-client/dist/models/sharing");
|
|
27
|
+
|
|
28
|
+
var _cozyDeviceHelper = require("cozy-device-helper");
|
|
29
|
+
|
|
30
|
+
var _Buttons = _interopRequireDefault(require("cozy-ui/transpiled/react/Buttons"));
|
|
31
|
+
|
|
32
|
+
var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
33
|
+
|
|
34
|
+
var _IconButton = _interopRequireDefault(require("cozy-ui/transpiled/react/IconButton"));
|
|
35
|
+
|
|
36
|
+
var _Reply = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Reply"));
|
|
37
|
+
|
|
38
|
+
var _ShareIos = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/ShareIos"));
|
|
39
|
+
|
|
40
|
+
var _Alerter = _interopRequireDefault(require("cozy-ui/transpiled/react/deprecated/Alerter"));
|
|
41
|
+
|
|
42
|
+
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
43
|
+
|
|
44
|
+
var _helpers = require("./helpers");
|
|
45
|
+
|
|
46
|
+
var ForwardIcon = (0, _cozyDeviceHelper.isIOS)() ? _ShareIos.default : _Reply.default;
|
|
47
|
+
|
|
48
|
+
var ForwardButton = function ForwardButton(_ref) {
|
|
49
|
+
var file = _ref.file,
|
|
50
|
+
variant = _ref.variant,
|
|
51
|
+
onClick = _ref.onClick;
|
|
52
|
+
|
|
53
|
+
var _useI18n = (0, _I18n.useI18n)(),
|
|
54
|
+
t = _useI18n.t;
|
|
55
|
+
|
|
56
|
+
var client = (0, _cozyClient.useClient)();
|
|
57
|
+
|
|
58
|
+
var icon = /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
59
|
+
icon: ForwardIcon
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var label = t('Viewer.actions.forward');
|
|
63
|
+
|
|
64
|
+
var onFileOpen = /*#__PURE__*/function () {
|
|
65
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(file) {
|
|
66
|
+
var url, shareData;
|
|
67
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
68
|
+
while (1) {
|
|
69
|
+
switch (_context.prev = _context.next) {
|
|
70
|
+
case 0:
|
|
71
|
+
if (!(0, _cozyDeviceHelper.isMobileApp)()) {
|
|
72
|
+
_context.next = 11;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_context.prev = 1;
|
|
77
|
+
_context.next = 4;
|
|
78
|
+
return (0, _helpers.exportFilesNative)(client, [file]);
|
|
79
|
+
|
|
80
|
+
case 4:
|
|
81
|
+
_context.next = 9;
|
|
82
|
+
break;
|
|
83
|
+
|
|
84
|
+
case 6:
|
|
85
|
+
_context.prev = 6;
|
|
86
|
+
_context.t0 = _context["catch"](1);
|
|
87
|
+
|
|
88
|
+
_Alerter.default.info("Viewer.error.".concat(_context.t0), {
|
|
89
|
+
fileMime: file.mime
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
case 9:
|
|
93
|
+
_context.next = 22;
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case 11:
|
|
97
|
+
_context.prev = 11;
|
|
98
|
+
_context.next = 14;
|
|
99
|
+
return (0, _sharing.getSharingLink)(client, [file.id]);
|
|
100
|
+
|
|
101
|
+
case 14:
|
|
102
|
+
url = _context.sent;
|
|
103
|
+
shareData = {
|
|
104
|
+
title: t('Viewer.share.title', {
|
|
105
|
+
name: file.name
|
|
106
|
+
}),
|
|
107
|
+
text: t('Viewer.share.text', {
|
|
108
|
+
name: file.name
|
|
109
|
+
}),
|
|
110
|
+
url: url
|
|
111
|
+
};
|
|
112
|
+
navigator.share(shareData);
|
|
113
|
+
_context.next = 22;
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
case 19:
|
|
117
|
+
_context.prev = 19;
|
|
118
|
+
_context.t1 = _context["catch"](11);
|
|
119
|
+
|
|
120
|
+
_Alerter.default.error('Viewer.share.error', {
|
|
121
|
+
error: _context.t1
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
case 22:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context.stop();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, _callee, null, [[1, 6], [11, 19]]);
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
return function onFileOpen(_x) {
|
|
133
|
+
return _ref2.apply(this, arguments);
|
|
134
|
+
};
|
|
135
|
+
}();
|
|
136
|
+
|
|
137
|
+
var handleClick = function handleClick() {
|
|
138
|
+
if (onClick) onClick();else onFileOpen(file);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
if (variant === 'iconButton') {
|
|
142
|
+
return /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
143
|
+
className: "u-white",
|
|
144
|
+
"aria-label": label,
|
|
145
|
+
onClick: handleClick
|
|
146
|
+
}, icon);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (variant === 'buttonIcon') {
|
|
150
|
+
return /*#__PURE__*/_react.default.createElement(_Buttons.default, {
|
|
151
|
+
variant: "secondary",
|
|
152
|
+
label: icon,
|
|
153
|
+
"aria-label": label,
|
|
154
|
+
onClick: handleClick
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return /*#__PURE__*/_react.default.createElement(_Buttons.default, {
|
|
159
|
+
fullWidth: true,
|
|
160
|
+
variant: "secondary",
|
|
161
|
+
startIcon: icon,
|
|
162
|
+
"data-testid": "openFileButton",
|
|
163
|
+
label: label,
|
|
164
|
+
onClick: handleClick
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
ForwardButton.propTypes = {
|
|
169
|
+
file: _propTypes.default.object.isRequired,
|
|
170
|
+
variant: _propTypes.default.oneOf(['default', 'iconButton', 'buttonIcon']),
|
|
171
|
+
onClick: _propTypes.default.func
|
|
172
|
+
};
|
|
173
|
+
ForwardButton.defaultProptypes = {
|
|
174
|
+
variant: 'default'
|
|
175
|
+
};
|
|
176
|
+
var _default = ForwardButton;
|
|
177
|
+
exports.default = _default;
|