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,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.infoWidth = exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var infoWidth = '22rem';
|
|
15
|
+
exports.infoWidth = infoWidth;
|
|
16
|
+
var styles = {
|
|
17
|
+
panel: {
|
|
18
|
+
width: infoWidth,
|
|
19
|
+
backgroundColor: 'var(--defaultBackgroundColor)'
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var InformationPanel = function InformationPanel(_ref) {
|
|
24
|
+
var children = _ref.children;
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
26
|
+
style: styles.panel,
|
|
27
|
+
className: "u-h-100 u-ov-auto"
|
|
28
|
+
}, children);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
InformationPanel.propTypes = {
|
|
32
|
+
classes: _propTypes.default.object,
|
|
33
|
+
children: _propTypes.default.element
|
|
34
|
+
};
|
|
35
|
+
var _default = InformationPanel;
|
|
36
|
+
exports.default = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default Navigation;
|
|
2
|
+
declare function Navigation({ className, hidden, onMouseEnter, onMouseLeave, onClick }: {
|
|
3
|
+
className: any;
|
|
4
|
+
hidden: any;
|
|
5
|
+
onMouseEnter: any;
|
|
6
|
+
onMouseLeave: any;
|
|
7
|
+
onClick: any;
|
|
8
|
+
}): JSX.Element;
|
|
9
|
+
declare namespace Navigation {
|
|
10
|
+
namespace propTypes {
|
|
11
|
+
const className: PropTypes.Validator<string>;
|
|
12
|
+
const hidden: PropTypes.Validator<boolean>;
|
|
13
|
+
const onMouseEnter: PropTypes.Validator<(...args: any[]) => any>;
|
|
14
|
+
const onMouseLeave: PropTypes.Validator<(...args: any[]) => any>;
|
|
15
|
+
const onClick: PropTypes.Validator<(...args: any[]) => any>;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,63 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
19
|
+
|
|
20
|
+
var _DropdownClose = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/DropdownClose"));
|
|
21
|
+
|
|
22
|
+
var styles = {
|
|
23
|
+
"viewer-nav": "styles__viewer-nav___3V03k",
|
|
24
|
+
"viewer-nav--visible": "styles__viewer-nav--visible___4GLTe",
|
|
25
|
+
"viewer-nav--previous": "styles__viewer-nav--previous___2LsMS",
|
|
26
|
+
"viewer-nav-arrow": "styles__viewer-nav-arrow___Z0ykc",
|
|
27
|
+
"viewer-nav--next": "styles__viewer-nav--next___3mBHi",
|
|
28
|
+
"viewer-controls": "styles__viewer-controls___2lf-z",
|
|
29
|
+
"--expanded": "styles__--expanded___1sp4Q",
|
|
30
|
+
"viewer-controls--display-content-top": "styles__viewer-controls--display-content-top___3wszk",
|
|
31
|
+
"viewer-toolbar": "styles__viewer-toolbar___1GLOA",
|
|
32
|
+
"viewer-toolbar--hidden": "styles__viewer-toolbar--hidden___Zq97m",
|
|
33
|
+
"viewer-footer": "styles__viewer-footer___iGv8J"
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var Navigation = function Navigation(_ref) {
|
|
37
|
+
var className = _ref.className,
|
|
38
|
+
hidden = _ref.hidden,
|
|
39
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
40
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
41
|
+
onClick = _ref.onClick;
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
+
role: "button",
|
|
44
|
+
className: (0, _classnames.default)(className, styles['viewer-nav'], (0, _defineProperty2.default)({}, styles['viewer-nav--visible'], !hidden)),
|
|
45
|
+
onClick: onClick,
|
|
46
|
+
onMouseEnter: onMouseEnter,
|
|
47
|
+
onMouseLeave: onMouseLeave
|
|
48
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
49
|
+
icon: _DropdownClose.default,
|
|
50
|
+
size: "32",
|
|
51
|
+
className: styles['viewer-nav-arrow']
|
|
52
|
+
}));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
Navigation.propTypes = {
|
|
56
|
+
className: _propTypes.default.string.isRequired,
|
|
57
|
+
hidden: _propTypes.default.bool.isRequired,
|
|
58
|
+
onMouseEnter: _propTypes.default.func.isRequired,
|
|
59
|
+
onMouseLeave: _propTypes.default.func.isRequired,
|
|
60
|
+
onClick: _propTypes.default.func.isRequired
|
|
61
|
+
};
|
|
62
|
+
var _default = Navigation;
|
|
63
|
+
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default PdfToolbarButton;
|
|
2
|
+
declare function PdfToolbarButton({ icon, onClick, disabled, label }: {
|
|
3
|
+
icon: any;
|
|
4
|
+
onClick: any;
|
|
5
|
+
disabled: any;
|
|
6
|
+
label: any;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
declare namespace PdfToolbarButton {
|
|
9
|
+
namespace propTypes {
|
|
10
|
+
const icon: PropTypes.Validator<string>;
|
|
11
|
+
const onClick: PropTypes.Validator<(...args: any[]) => any>;
|
|
12
|
+
const disabled: PropTypes.Requireable<boolean>;
|
|
13
|
+
const label: PropTypes.Validator<string>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,40 @@
|
|
|
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 _Button = _interopRequireDefault(require("cozy-ui/transpiled/react/deprecated/Button"));
|
|
15
|
+
|
|
16
|
+
var PdfToolbarButton = function PdfToolbarButton(_ref) {
|
|
17
|
+
var icon = _ref.icon,
|
|
18
|
+
onClick = _ref.onClick,
|
|
19
|
+
disabled = _ref.disabled,
|
|
20
|
+
label = _ref.label;
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
22
|
+
iconOnly: true,
|
|
23
|
+
subtle: true,
|
|
24
|
+
theme: "secondary",
|
|
25
|
+
className: "u-p-half u-m-half",
|
|
26
|
+
icon: icon,
|
|
27
|
+
onClick: onClick,
|
|
28
|
+
disabled: disabled,
|
|
29
|
+
label: label
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
PdfToolbarButton.propTypes = {
|
|
34
|
+
icon: _propTypes.default.string.isRequired,
|
|
35
|
+
onClick: _propTypes.default.func.isRequired,
|
|
36
|
+
disabled: _propTypes.default.bool,
|
|
37
|
+
label: _propTypes.default.string.isRequired
|
|
38
|
+
};
|
|
39
|
+
var _default = PdfToolbarButton;
|
|
40
|
+
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default PrintButton;
|
|
2
|
+
declare function PrintButton({ file, variant }: {
|
|
3
|
+
file: any;
|
|
4
|
+
variant: any;
|
|
5
|
+
}): JSX.Element | null;
|
|
6
|
+
declare namespace PrintButton {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
const file: PropTypes.Validator<object>;
|
|
9
|
+
const variant: PropTypes.Requireable<string>;
|
|
10
|
+
}
|
|
11
|
+
namespace defaultProps {
|
|
12
|
+
const variant_1: string;
|
|
13
|
+
export { variant_1 as variant };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,163 @@
|
|
|
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 _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
+
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
|
|
22
|
+
var _cozyIntent = require("cozy-intent");
|
|
23
|
+
|
|
24
|
+
var _helpers = require("cozy-ui/transpiled/react/ActionsMenu/Actions/helpers");
|
|
25
|
+
|
|
26
|
+
var _print = require("cozy-ui/transpiled/react/ActionsMenu/Actions/print");
|
|
27
|
+
|
|
28
|
+
var _ActionsItems = _interopRequireWildcard(require("cozy-ui/transpiled/react/ActionsMenu/ActionsItems"));
|
|
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
|
+
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
|
+
var ActionComponent = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
45
|
+
var action = _ref.action,
|
|
46
|
+
variant = _ref.variant,
|
|
47
|
+
onClick = _ref.onClick;
|
|
48
|
+
var label = action.label,
|
|
49
|
+
icon = action.icon;
|
|
50
|
+
|
|
51
|
+
if (variant === 'button') {
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement(_Buttons.default, {
|
|
53
|
+
ref: ref,
|
|
54
|
+
variant: "secondary",
|
|
55
|
+
"aria-label": label,
|
|
56
|
+
label: /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
57
|
+
icon: icon
|
|
58
|
+
}),
|
|
59
|
+
onClick: onClick
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
64
|
+
ref: ref,
|
|
65
|
+
className: "u-white",
|
|
66
|
+
"aria-label": label,
|
|
67
|
+
onClick: onClick
|
|
68
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
69
|
+
icon: icon
|
|
70
|
+
}));
|
|
71
|
+
});
|
|
72
|
+
ActionComponent.displayName = 'ActionComponent';
|
|
73
|
+
ActionComponent.propTypes = _objectSpread(_objectSpread({}, _ActionsItems.actionsItemsComponentPropTypes), {}, {
|
|
74
|
+
variant: _propTypes.default.oneOf(['default', 'button'])
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
var PrintButton = function PrintButton(_ref2) {
|
|
78
|
+
var file = _ref2.file,
|
|
79
|
+
variant = _ref2.variant;
|
|
80
|
+
|
|
81
|
+
var _useState = (0, _react.useState)(false),
|
|
82
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
83
|
+
isPrintAvailable = _useState2[0],
|
|
84
|
+
setIsPrintAvailable = _useState2[1];
|
|
85
|
+
|
|
86
|
+
var webviewIntent = (0, _cozyIntent.useWebviewIntent)();
|
|
87
|
+
var isPDFDoc = file.mime === 'application/pdf';
|
|
88
|
+
var showPrintButton = isPDFDoc && isPrintAvailable;
|
|
89
|
+
(0, _react.useEffect)(function () {
|
|
90
|
+
var init = /*#__PURE__*/function () {
|
|
91
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
92
|
+
var _yield$webviewIntent$;
|
|
93
|
+
|
|
94
|
+
var isAvailable;
|
|
95
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
96
|
+
while (1) {
|
|
97
|
+
switch (_context.prev = _context.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
_context.next = 2;
|
|
100
|
+
return webviewIntent === null || webviewIntent === void 0 ? void 0 : webviewIntent.call('isAvailable', 'print');
|
|
101
|
+
|
|
102
|
+
case 2:
|
|
103
|
+
_context.t1 = _yield$webviewIntent$ = _context.sent;
|
|
104
|
+
_context.t0 = _context.t1 !== null;
|
|
105
|
+
|
|
106
|
+
if (!_context.t0) {
|
|
107
|
+
_context.next = 6;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_context.t0 = _yield$webviewIntent$ !== void 0;
|
|
112
|
+
|
|
113
|
+
case 6:
|
|
114
|
+
if (!_context.t0) {
|
|
115
|
+
_context.next = 10;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_context.t2 = _yield$webviewIntent$;
|
|
120
|
+
_context.next = 11;
|
|
121
|
+
break;
|
|
122
|
+
|
|
123
|
+
case 10:
|
|
124
|
+
_context.t2 = true;
|
|
125
|
+
|
|
126
|
+
case 11:
|
|
127
|
+
isAvailable = _context.t2;
|
|
128
|
+
setIsPrintAvailable(isAvailable);
|
|
129
|
+
|
|
130
|
+
case 13:
|
|
131
|
+
case "end":
|
|
132
|
+
return _context.stop();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}, _callee);
|
|
136
|
+
}));
|
|
137
|
+
|
|
138
|
+
return function init() {
|
|
139
|
+
return _ref3.apply(this, arguments);
|
|
140
|
+
};
|
|
141
|
+
}();
|
|
142
|
+
|
|
143
|
+
init();
|
|
144
|
+
}, [webviewIntent]);
|
|
145
|
+
if (!showPrintButton) return null;
|
|
146
|
+
var actions = (0, _helpers.makeActions)([_print.print]);
|
|
147
|
+
return /*#__PURE__*/_react.default.createElement(_ActionsItems.default, {
|
|
148
|
+
docs: [file],
|
|
149
|
+
actions: actions,
|
|
150
|
+
component: ActionComponent,
|
|
151
|
+
variant: variant
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
PrintButton.propTypes = {
|
|
156
|
+
file: _propTypes.default.object.isRequired,
|
|
157
|
+
variant: _propTypes.default.oneOf(['default', 'button'])
|
|
158
|
+
};
|
|
159
|
+
PrintButton.defaultProps = {
|
|
160
|
+
variant: 'default'
|
|
161
|
+
};
|
|
162
|
+
var _default = PrintButton;
|
|
163
|
+
exports.default = _default;
|
|
@@ -0,0 +1,146 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
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 _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
21
|
+
|
|
22
|
+
var _IconButton = _interopRequireDefault(require("cozy-ui/transpiled/react/IconButton"));
|
|
23
|
+
|
|
24
|
+
var _Download = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Download"));
|
|
25
|
+
|
|
26
|
+
var _Previous = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Previous"));
|
|
27
|
+
|
|
28
|
+
var _MidEllipsis = _interopRequireDefault(require("cozy-ui/transpiled/react/MidEllipsis"));
|
|
29
|
+
|
|
30
|
+
var _Typography = _interopRequireDefault(require("cozy-ui/transpiled/react/Typography"));
|
|
31
|
+
|
|
32
|
+
var _withBreakpoints = _interopRequireDefault(require("cozy-ui/transpiled/react/helpers/withBreakpoints"));
|
|
33
|
+
|
|
34
|
+
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
35
|
+
|
|
36
|
+
var _styles = require("cozy-ui/transpiled/react/styles");
|
|
37
|
+
|
|
38
|
+
var _PrintButton = _interopRequireDefault(require("./PrintButton"));
|
|
39
|
+
|
|
40
|
+
var _ToolbarFilePath = require("./ToolbarFilePath");
|
|
41
|
+
|
|
42
|
+
var _helpers = require("../Footer/helpers");
|
|
43
|
+
|
|
44
|
+
var _helpers2 = require("../helpers");
|
|
45
|
+
|
|
46
|
+
var _EncryptedProvider = require("../providers/EncryptedProvider");
|
|
47
|
+
|
|
48
|
+
var styles = {
|
|
49
|
+
"viewer-nav": "styles__viewer-nav___3V03k",
|
|
50
|
+
"viewer-nav--visible": "styles__viewer-nav--visible___4GLTe",
|
|
51
|
+
"viewer-nav--previous": "styles__viewer-nav--previous___2LsMS",
|
|
52
|
+
"viewer-nav-arrow": "styles__viewer-nav-arrow___Z0ykc",
|
|
53
|
+
"viewer-nav--next": "styles__viewer-nav--next___3mBHi",
|
|
54
|
+
"viewer-controls": "styles__viewer-controls___2lf-z",
|
|
55
|
+
"--expanded": "styles__--expanded___1sp4Q",
|
|
56
|
+
"viewer-controls--display-content-top": "styles__viewer-controls--display-content-top___3wszk",
|
|
57
|
+
"viewer-toolbar": "styles__viewer-toolbar___1GLOA",
|
|
58
|
+
"viewer-toolbar--hidden": "styles__viewer-toolbar--hidden___Zq97m",
|
|
59
|
+
"viewer-footer": "styles__viewer-footer___iGv8J"
|
|
60
|
+
};
|
|
61
|
+
var useClasses = (0, _styles.makeStyles)(function (theme) {
|
|
62
|
+
return {
|
|
63
|
+
iconButton: (0, _defineProperty2.default)({}, theme.breakpoints.down('md'), {
|
|
64
|
+
marginLeft: '0.25rem'
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
var Toolbar = function Toolbar(_ref) {
|
|
70
|
+
var hidden = _ref.hidden,
|
|
71
|
+
onMouseEnter = _ref.onMouseEnter,
|
|
72
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
73
|
+
file = _ref.file,
|
|
74
|
+
onClose = _ref.onClose,
|
|
75
|
+
toolbarRef = _ref.toolbarRef,
|
|
76
|
+
isDesktop = _ref.breakpoints.isDesktop,
|
|
77
|
+
children = _ref.children,
|
|
78
|
+
showFilePath = _ref.showFilePath;
|
|
79
|
+
var client = (0, _cozyClient.useClient)();
|
|
80
|
+
var classes = useClasses();
|
|
81
|
+
|
|
82
|
+
var _useI18n = (0, _I18n.useI18n)(),
|
|
83
|
+
t = _useI18n.t;
|
|
84
|
+
|
|
85
|
+
var _useEncrypted = (0, _EncryptedProvider.useEncrypted)(),
|
|
86
|
+
url = _useEncrypted.url;
|
|
87
|
+
|
|
88
|
+
var ToolbarButtons = (0, _helpers.extractChildrenCompByName)({
|
|
89
|
+
children: children,
|
|
90
|
+
file: file,
|
|
91
|
+
name: 'ToolbarButtons'
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
94
|
+
ref: toolbarRef,
|
|
95
|
+
"data-testid": "viewer-toolbar",
|
|
96
|
+
className: (0, _classnames.default)(styles['viewer-toolbar'], (0, _defineProperty2.default)({}, styles['viewer-toolbar--hidden'], hidden)),
|
|
97
|
+
onMouseEnter: onMouseEnter,
|
|
98
|
+
onMouseLeave: onMouseLeave
|
|
99
|
+
}, onClose && /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
100
|
+
className: (0, _classnames.default)(classes.iconButton, {
|
|
101
|
+
'u-white': isDesktop
|
|
102
|
+
}),
|
|
103
|
+
onClick: onClose
|
|
104
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
105
|
+
icon: _Previous.default
|
|
106
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
107
|
+
className: "u-pl-half u-ov-auto u-w-100"
|
|
108
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
109
|
+
variant: "h3",
|
|
110
|
+
color: isDesktop ? 'inherit' : 'textPrimary',
|
|
111
|
+
noWrap: true
|
|
112
|
+
}, /*#__PURE__*/_react.default.createElement(_MidEllipsis.default, {
|
|
113
|
+
text: file.name
|
|
114
|
+
})), showFilePath ? /*#__PURE__*/_react.default.createElement(_ToolbarFilePath.ToolbarFilePath, {
|
|
115
|
+
file: file
|
|
116
|
+
}) : null), /*#__PURE__*/_react.default.createElement("div", {
|
|
117
|
+
className: "u-flex"
|
|
118
|
+
}, isDesktop && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ToolbarButtons, /*#__PURE__*/_react.default.createElement(_PrintButton.default, {
|
|
119
|
+
file: file
|
|
120
|
+
}), /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
121
|
+
className: "u-white",
|
|
122
|
+
"aria-label": t('Viewer.download'),
|
|
123
|
+
onClick: function onClick() {
|
|
124
|
+
return (0, _helpers2.downloadFile)({
|
|
125
|
+
client: client,
|
|
126
|
+
file: file,
|
|
127
|
+
url: url
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
131
|
+
icon: _Download.default
|
|
132
|
+
})))));
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
Toolbar.propTypes = {
|
|
136
|
+
hidden: _propTypes.default.bool,
|
|
137
|
+
onMouseEnter: _propTypes.default.func.isRequired,
|
|
138
|
+
onMouseLeave: _propTypes.default.func.isRequired,
|
|
139
|
+
file: _propTypes.default.object.isRequired,
|
|
140
|
+
onClose: _propTypes.default.func,
|
|
141
|
+
showFilePath: _propTypes.default.bool
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
var _default = (0, _withBreakpoints.default)()(Toolbar);
|
|
145
|
+
|
|
146
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _FooterActionButtons = _interopRequireDefault(require("../Footer/FooterActionButtons"));
|
|
13
|
+
|
|
14
|
+
var ToolbarButtons = function ToolbarButtons(props) {
|
|
15
|
+
return /*#__PURE__*/_react.default.createElement(_FooterActionButtons.default, props);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
ToolbarButtons.displayName = 'ToolbarButtons';
|
|
19
|
+
var _default = ToolbarButtons;
|
|
20
|
+
exports.default = _default;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ToolbarFilePath = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _cozyClient = require("cozy-client");
|
|
15
|
+
|
|
16
|
+
var _AppLinker = _interopRequireDefault(require("cozy-ui/transpiled/react/AppLinker"));
|
|
17
|
+
|
|
18
|
+
var _FilePath = _interopRequireDefault(require("cozy-ui/transpiled/react/FilePath"));
|
|
19
|
+
|
|
20
|
+
var _Link = _interopRequireDefault(require("cozy-ui/transpiled/react/Link"));
|
|
21
|
+
|
|
22
|
+
var _Breakpoints = _interopRequireDefault(require("cozy-ui/transpiled/react/providers/Breakpoints"));
|
|
23
|
+
|
|
24
|
+
var _helpers = require("../helpers");
|
|
25
|
+
|
|
26
|
+
var _queries = require("../queries");
|
|
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
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
var ensureFilePath = _cozyClient.models.file.ensureFilePath;
|
|
37
|
+
|
|
38
|
+
var ToolbarFilePath = function ToolbarFilePath(_ref) {
|
|
39
|
+
var file = _ref.file;
|
|
40
|
+
var client = (0, _cozyClient.useClient)();
|
|
41
|
+
|
|
42
|
+
var _useBreakpoints = (0, _Breakpoints.default)(),
|
|
43
|
+
isDesktop = _useBreakpoints.isDesktop;
|
|
44
|
+
|
|
45
|
+
var normalizeFile = (0, _helpers.normalizeAndSpreadAttributes)(file);
|
|
46
|
+
var parentQuery = (0, _queries.buildFileByIdQuery)(normalizeFile.dir_id);
|
|
47
|
+
var parentResult = (0, _cozyClient.useQuery)(parentQuery.definition, _objectSpread(_objectSpread({}, parentQuery.options), {}, {
|
|
48
|
+
enabled: !!normalizeFile.dir_id
|
|
49
|
+
}));
|
|
50
|
+
var fileWithPath = (0, _react.useMemo)(function () {
|
|
51
|
+
return parentResult.data ? ensureFilePath(normalizeFile, parentResult.data) : undefined;
|
|
52
|
+
}, [normalizeFile, parentResult.data]);
|
|
53
|
+
|
|
54
|
+
if (fileWithPath) {
|
|
55
|
+
var appSlug = 'drive';
|
|
56
|
+
var nativePath = "/folder/".concat(fileWithPath.dir_id);
|
|
57
|
+
var path = (0, _helpers.removeFilenameFromPath)(fileWithPath.path);
|
|
58
|
+
var link = (0, _helpers.makeWebLink)({
|
|
59
|
+
client: client,
|
|
60
|
+
path: nativePath,
|
|
61
|
+
slug: appSlug
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (isDesktop && link) {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_AppLinker.default, {
|
|
66
|
+
app: {
|
|
67
|
+
slug: appSlug
|
|
68
|
+
},
|
|
69
|
+
nativePath: nativePath,
|
|
70
|
+
href: link
|
|
71
|
+
}, function (_ref2) {
|
|
72
|
+
var href = _ref2.href,
|
|
73
|
+
onClick = _ref2.onClick;
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_Link.default, {
|
|
75
|
+
href: href,
|
|
76
|
+
onClick: onClick,
|
|
77
|
+
color: "inherit"
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement(_FilePath.default, {
|
|
79
|
+
className: "u-white"
|
|
80
|
+
}, path));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(_FilePath.default, {
|
|
85
|
+
className: isDesktop ? 'u-white' : null
|
|
86
|
+
}, path);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.ToolbarFilePath = ToolbarFilePath;
|