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/dist/helpers.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.removeFilenameFromPath = exports.normalizeAndSpreadAttributes = exports.makeWebLink = exports.isValidForPanel = exports.isFileEncrypted = exports.isEditableAttribute = exports.getCurrentModel = exports.formatDate = exports.downloadFile = exports.buildEditAttributePath = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var _cozyClient = require("cozy-client");
|
|
17
|
+
|
|
18
|
+
var _file = require("cozy-client/dist/models/file");
|
|
19
|
+
|
|
20
|
+
var _paper = require("cozy-client/dist/models/paper");
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
var getCurrentModel = function getCurrentModel(metadataName) {
|
|
27
|
+
if (_paper.KNOWN_DATE_METADATA_NAMES.includes(metadataName) || _paper.KNOWN_INFORMATION_METADATA_NAMES.includes(metadataName) || _paper.KNOWN_BILLS_ATTRIBUTES_NAMES.includes(metadataName)) {
|
|
28
|
+
return 'information';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (metadataName === 'contact') return 'contact';
|
|
32
|
+
if (metadataName === 'page') return 'page';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @typedef {object} Reference
|
|
36
|
+
* @property {string} id - id of the document
|
|
37
|
+
* @property {string} type - doctype of the document
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Checks if the file matches one of the following conditions:
|
|
42
|
+
* - Is certified
|
|
43
|
+
* - Is Qualified
|
|
44
|
+
* - From a Connector
|
|
45
|
+
*
|
|
46
|
+
* @param {object} param
|
|
47
|
+
* @param {IOCozyFile} param.file
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
exports.getCurrentModel = getCurrentModel;
|
|
53
|
+
|
|
54
|
+
var isValidForPanel = function isValidForPanel(_ref) {
|
|
55
|
+
var file = _ref.file;
|
|
56
|
+
return (0, _file.hasCertifications)(file) || (0, _file.hasQualifications)(file) || (0, _file.isFromKonnector)(file);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
exports.isValidForPanel = isValidForPanel;
|
|
60
|
+
|
|
61
|
+
var downloadFile = /*#__PURE__*/function () {
|
|
62
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
|
|
63
|
+
var client, file, url;
|
|
64
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
65
|
+
while (1) {
|
|
66
|
+
switch (_context.prev = _context.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
client = _ref2.client, file = _ref2.file, url = _ref2.url;
|
|
69
|
+
|
|
70
|
+
if (!(0, _file.isEncrypted)(file)) {
|
|
71
|
+
_context.next = 3;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return _context.abrupt("return", client.collection('io.cozy.files').forceFileDownload(url, file.name));
|
|
76
|
+
|
|
77
|
+
case 3:
|
|
78
|
+
return _context.abrupt("return", client.collection('io.cozy.files').download(file));
|
|
79
|
+
|
|
80
|
+
case 4:
|
|
81
|
+
case "end":
|
|
82
|
+
return _context.stop();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, _callee);
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
return function downloadFile(_x) {
|
|
89
|
+
return _ref3.apply(this, arguments);
|
|
90
|
+
};
|
|
91
|
+
}();
|
|
92
|
+
|
|
93
|
+
exports.downloadFile = downloadFile;
|
|
94
|
+
|
|
95
|
+
var isFileEncrypted = function isFileEncrypted(file) {
|
|
96
|
+
return (0, _file.isEncrypted)(file);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.isFileEncrypted = isFileEncrypted;
|
|
100
|
+
|
|
101
|
+
var formatDate = function formatDate(_ref4) {
|
|
102
|
+
var f = _ref4.f,
|
|
103
|
+
lang = _ref4.lang,
|
|
104
|
+
date = _ref4.date;
|
|
105
|
+
|
|
106
|
+
if (lang === 'en') {
|
|
107
|
+
return f(date, 'MM/DD/YYYY');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return f(date, 'DD/MM/YYYY');
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* @param {{ information: string, page: string }} editPathByModelProps
|
|
114
|
+
* @param {string} currentModel
|
|
115
|
+
* @param {string} name
|
|
116
|
+
* @returns {string}
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
exports.formatDate = formatDate;
|
|
121
|
+
|
|
122
|
+
var buildEditAttributePath = function buildEditAttributePath(editPathByModelProps, currentModel, name) {
|
|
123
|
+
var _currentPath$replace;
|
|
124
|
+
|
|
125
|
+
var currentPath = editPathByModelProps[currentModel];
|
|
126
|
+
return (_currentPath$replace = currentPath === null || currentPath === void 0 ? void 0 : currentPath.replace(/__NAME__/, name)) !== null && _currentPath$replace !== void 0 ? _currentPath$replace : '';
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
exports.buildEditAttributePath = buildEditAttributePath;
|
|
130
|
+
|
|
131
|
+
var isEditableAttribute = function isEditableAttribute(name, file) {
|
|
132
|
+
var isNotEditableAttributes = ['datetime', 'qualification'];
|
|
133
|
+
return !isNotEditableAttributes.includes(name) && (name === 'issueDate' && !(0, _file.isFromKonnector)(file) || name !== 'issueDate');
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
exports.isEditableAttribute = isEditableAttribute;
|
|
137
|
+
|
|
138
|
+
var normalizeAndSpreadAttributes = function normalizeAndSpreadAttributes(rawFile) {
|
|
139
|
+
var normalizedFile = (0, _file.normalize)(rawFile);
|
|
140
|
+
return _objectSpread(_objectSpread({}, normalizedFile), normalizedFile === null || normalizedFile === void 0 ? void 0 : normalizedFile.attributes);
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Return a web link to an application in the Cozy environment with the specified path
|
|
144
|
+
* @param {object} param
|
|
145
|
+
* @param {CozyClient} param.client - Instance of CozyClient
|
|
146
|
+
* @param {string} param.slug - Slug of the application
|
|
147
|
+
* @param {string} param.path - Path into the application
|
|
148
|
+
* @returns {string} web link
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
exports.normalizeAndSpreadAttributes = normalizeAndSpreadAttributes;
|
|
153
|
+
|
|
154
|
+
var makeWebLink = function makeWebLink(_ref5) {
|
|
155
|
+
var client = _ref5.client,
|
|
156
|
+
slug = _ref5.slug,
|
|
157
|
+
path = _ref5.path;
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
var cozyURL = new URL(client.getStackClient().uri);
|
|
161
|
+
|
|
162
|
+
var _client$getInstanceOp = client.getInstanceOptions(),
|
|
163
|
+
subDomainType = _client$getInstanceOp.subdomain;
|
|
164
|
+
|
|
165
|
+
return (0, _cozyClient.generateWebLink)({
|
|
166
|
+
pathname: '/',
|
|
167
|
+
cozyUrl: cozyURL.origin,
|
|
168
|
+
slug: slug,
|
|
169
|
+
hash: path,
|
|
170
|
+
subDomainType: subDomainType
|
|
171
|
+
});
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Remove the file name at the end of a path
|
|
178
|
+
* @param {string} path
|
|
179
|
+
* @returns {string} new path
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
exports.makeWebLink = makeWebLink;
|
|
184
|
+
|
|
185
|
+
var removeFilenameFromPath = function removeFilenameFromPath(path) {
|
|
186
|
+
var newPath = path.substring(0, path.lastIndexOf('/'));
|
|
187
|
+
return newPath === '' ? '/' : newPath;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
exports.removeFilenameFromPath = removeFilenameFromPath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export default withFileUrl;
|
|
2
|
+
declare function withFileUrl(BaseComponent: any): {
|
|
3
|
+
new (props: Readonly<any>): {
|
|
4
|
+
state: {
|
|
5
|
+
status: string;
|
|
6
|
+
downloadUrl: null;
|
|
7
|
+
};
|
|
8
|
+
UNSAFE_componentWillMount(): void;
|
|
9
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
10
|
+
componentDidUpdate(): void;
|
|
11
|
+
loadDownloadUrl(): Promise<void>;
|
|
12
|
+
timeout: number | null | undefined;
|
|
13
|
+
getDownloadLink(file: any): any;
|
|
14
|
+
clearTimeout(): void;
|
|
15
|
+
reset: () => void;
|
|
16
|
+
render(): JSX.Element;
|
|
17
|
+
context: any;
|
|
18
|
+
setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
|
|
19
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
20
|
+
readonly props: Readonly<any> & Readonly<{
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}>;
|
|
23
|
+
refs: {
|
|
24
|
+
[key: string]: React.ReactInstance;
|
|
25
|
+
};
|
|
26
|
+
componentDidMount?(): void;
|
|
27
|
+
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): boolean;
|
|
28
|
+
componentWillUnmount?(): void;
|
|
29
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
30
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>): any;
|
|
31
|
+
componentWillMount?(): void;
|
|
32
|
+
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
33
|
+
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
34
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
35
|
+
};
|
|
36
|
+
new (props: any, context?: any): {
|
|
37
|
+
state: {
|
|
38
|
+
status: string;
|
|
39
|
+
downloadUrl: null;
|
|
40
|
+
};
|
|
41
|
+
UNSAFE_componentWillMount(): void;
|
|
42
|
+
UNSAFE_componentWillReceiveProps(nextProps: any): void;
|
|
43
|
+
componentDidUpdate(): void;
|
|
44
|
+
loadDownloadUrl(): Promise<void>;
|
|
45
|
+
timeout: number | null | undefined;
|
|
46
|
+
getDownloadLink(file: any): any;
|
|
47
|
+
clearTimeout(): void;
|
|
48
|
+
reset: () => void;
|
|
49
|
+
render(): JSX.Element;
|
|
50
|
+
context: any;
|
|
51
|
+
setState<K extends string | number | symbol>(state: any, callback?: (() => void) | undefined): void;
|
|
52
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
53
|
+
readonly props: Readonly<any> & Readonly<{
|
|
54
|
+
children?: React.ReactNode;
|
|
55
|
+
}>;
|
|
56
|
+
refs: {
|
|
57
|
+
[key: string]: React.ReactInstance;
|
|
58
|
+
};
|
|
59
|
+
componentDidMount?(): void;
|
|
60
|
+
shouldComponentUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): boolean;
|
|
61
|
+
componentWillUnmount?(): void;
|
|
62
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
63
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<any>, prevState: Readonly<any>): any;
|
|
64
|
+
componentWillMount?(): void;
|
|
65
|
+
componentWillReceiveProps?(nextProps: Readonly<any>, nextContext: any): void;
|
|
66
|
+
componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
67
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): void;
|
|
68
|
+
};
|
|
69
|
+
contextTypes: {
|
|
70
|
+
client: PropTypes.Validator<object>;
|
|
71
|
+
};
|
|
72
|
+
contextType?: React.Context<any> | undefined;
|
|
73
|
+
};
|
|
74
|
+
import React from "react";
|
|
75
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,231 @@
|
|
|
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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
+
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
|
|
20
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
21
|
+
|
|
22
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
24
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
+
|
|
26
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
+
|
|
28
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
|
+
|
|
30
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
+
|
|
32
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
33
|
+
|
|
34
|
+
var _NoNetworkViewer = _interopRequireDefault(require("../ViewersByFile/NoNetworkViewer"));
|
|
35
|
+
|
|
36
|
+
var _ViewerSpinner = _interopRequireDefault(require("../components/ViewerSpinner"));
|
|
37
|
+
|
|
38
|
+
var _helpers = require("../helpers");
|
|
39
|
+
|
|
40
|
+
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); }
|
|
41
|
+
|
|
42
|
+
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; }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
45
|
+
|
|
46
|
+
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; }
|
|
47
|
+
|
|
48
|
+
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); }; }
|
|
49
|
+
|
|
50
|
+
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; } }
|
|
51
|
+
|
|
52
|
+
var TTL = 6000;
|
|
53
|
+
var LOADING = 'LOADING';
|
|
54
|
+
var LOADED = 'LOADED';
|
|
55
|
+
var FAILED = 'FAILED';
|
|
56
|
+
|
|
57
|
+
var withFileUrl = function withFileUrl(BaseComponent) {
|
|
58
|
+
var _class;
|
|
59
|
+
|
|
60
|
+
return _class = /*#__PURE__*/function (_Component) {
|
|
61
|
+
(0, _inherits2.default)(withFileUrlClass, _Component);
|
|
62
|
+
|
|
63
|
+
var _super = _createSuper(withFileUrlClass);
|
|
64
|
+
|
|
65
|
+
function withFileUrlClass() {
|
|
66
|
+
var _this;
|
|
67
|
+
|
|
68
|
+
(0, _classCallCheck2.default)(this, withFileUrlClass);
|
|
69
|
+
|
|
70
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
71
|
+
args[_key] = arguments[_key];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
75
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
76
|
+
status: LOADING,
|
|
77
|
+
downloadUrl: null
|
|
78
|
+
});
|
|
79
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reset", function () {
|
|
80
|
+
_this.clearTimeout();
|
|
81
|
+
|
|
82
|
+
_this.setState({
|
|
83
|
+
status: LOADING,
|
|
84
|
+
downloadUrl: null
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
(0, _createClass2.default)(withFileUrlClass, [{
|
|
91
|
+
key: "UNSAFE_componentWillMount",
|
|
92
|
+
value: function UNSAFE_componentWillMount() {
|
|
93
|
+
this.loadDownloadUrl();
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
97
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
98
|
+
if (nextProps.file.id !== this.props.file.id || nextProps.url !== this.props.url) {
|
|
99
|
+
this.reset();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "componentDidUpdate",
|
|
104
|
+
value: function componentDidUpdate() {
|
|
105
|
+
if (this.state.status === LOADING && !this.timeout) {
|
|
106
|
+
this.loadDownloadUrl();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "loadDownloadUrl",
|
|
111
|
+
value: function () {
|
|
112
|
+
var _loadDownloadUrl = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
113
|
+
var _this2 = this;
|
|
114
|
+
|
|
115
|
+
var _this$props, file, url, downloadUrl;
|
|
116
|
+
|
|
117
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
118
|
+
while (1) {
|
|
119
|
+
switch (_context.prev = _context.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
_this$props = this.props, file = _this$props.file, url = _this$props.url;
|
|
122
|
+
this.timeout = setTimeout(function () {
|
|
123
|
+
return _this2.setState(function (state) {
|
|
124
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
125
|
+
status: FAILED
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}, TTL);
|
|
129
|
+
_context.prev = 2;
|
|
130
|
+
|
|
131
|
+
if (!(0, _helpers.isFileEncrypted)(file)) {
|
|
132
|
+
_context.next = 6;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// The download link cannot be provided by the stack if the file is encrypted
|
|
137
|
+
if (url) {
|
|
138
|
+
this.clearTimeout();
|
|
139
|
+
this.setState({
|
|
140
|
+
downloadUrl: url,
|
|
141
|
+
status: LOADED
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return _context.abrupt("return");
|
|
146
|
+
|
|
147
|
+
case 6:
|
|
148
|
+
_context.next = 8;
|
|
149
|
+
return this.getDownloadLink(file);
|
|
150
|
+
|
|
151
|
+
case 8:
|
|
152
|
+
downloadUrl = _context.sent;
|
|
153
|
+
this.clearTimeout();
|
|
154
|
+
this.setState({
|
|
155
|
+
downloadUrl: downloadUrl,
|
|
156
|
+
status: LOADED
|
|
157
|
+
});
|
|
158
|
+
_context.next = 17;
|
|
159
|
+
break;
|
|
160
|
+
|
|
161
|
+
case 13:
|
|
162
|
+
_context.prev = 13;
|
|
163
|
+
_context.t0 = _context["catch"](2);
|
|
164
|
+
this.clearTimeout();
|
|
165
|
+
this.setState(function (state) {
|
|
166
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
167
|
+
status: FAILED
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
case 17:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}, _callee, this, [[2, 13]]);
|
|
177
|
+
}));
|
|
178
|
+
|
|
179
|
+
function loadDownloadUrl() {
|
|
180
|
+
return _loadDownloadUrl.apply(this, arguments);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return loadDownloadUrl;
|
|
184
|
+
}()
|
|
185
|
+
}, {
|
|
186
|
+
key: "getDownloadLink",
|
|
187
|
+
value: function getDownloadLink(file) {
|
|
188
|
+
return this.context.client.collection('io.cozy.files').getDownloadLinkById(file._id, file.name);
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "clearTimeout",
|
|
192
|
+
value: function (_clearTimeout) {
|
|
193
|
+
function clearTimeout() {
|
|
194
|
+
return _clearTimeout.apply(this, arguments);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
clearTimeout.toString = function () {
|
|
198
|
+
return _clearTimeout.toString();
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
return clearTimeout;
|
|
202
|
+
}(function () {
|
|
203
|
+
clearTimeout(this.timeout);
|
|
204
|
+
this.timeout = null;
|
|
205
|
+
})
|
|
206
|
+
}, {
|
|
207
|
+
key: "render",
|
|
208
|
+
value: function render() {
|
|
209
|
+
if (this.state.status === LOADING) {
|
|
210
|
+
return /*#__PURE__*/_react.default.createElement(_ViewerSpinner.default, null);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (this.state.status === FAILED) {
|
|
214
|
+
return /*#__PURE__*/_react.default.createElement(_NoNetworkViewer.default, {
|
|
215
|
+
onReload: this.reset
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return /*#__PURE__*/_react.default.createElement(BaseComponent, (0, _extends2.default)({}, this.props, {
|
|
220
|
+
url: this.state.downloadUrl
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
}]);
|
|
224
|
+
return withFileUrlClass;
|
|
225
|
+
}(_react.Component), (0, _defineProperty2.default)(_class, "contextTypes", {
|
|
226
|
+
client: _propTypes.default.object.isRequired
|
|
227
|
+
}), _class;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
var _default = withFileUrl;
|
|
231
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const withViewerLocales: any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.withViewerLocales = void 0;
|
|
9
|
+
|
|
10
|
+
var _withLocales = _interopRequireDefault(require("cozy-ui/transpiled/react/providers/I18n/withLocales"));
|
|
11
|
+
|
|
12
|
+
var _locales = require("../locales");
|
|
13
|
+
|
|
14
|
+
var withViewerLocales = (0, _withLocales.default)(_locales.locales);
|
|
15
|
+
exports.withViewerLocales = withViewerLocales;
|
|
@@ -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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
|
|
14
|
+
var _cozyClient = require("cozy-client");
|
|
15
|
+
|
|
16
|
+
var _queries = require("../queries");
|
|
17
|
+
|
|
18
|
+
var _excluded = ["data"];
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
var useReferencedContactName = function useReferencedContactName(file) {
|
|
25
|
+
var contactIds = (0, _cozyClient.getReferencedBy)(file, 'io.cozy.contacts').map(function (ref) {
|
|
26
|
+
return ref.id;
|
|
27
|
+
});
|
|
28
|
+
var isContactByIdsQueryEnabled = contactIds.length > 0;
|
|
29
|
+
var contactByIdsQuery = (0, _queries.buildContactByIdsQuery)(contactIds);
|
|
30
|
+
|
|
31
|
+
var _useQuery = (0, _cozyClient.useQuery)(contactByIdsQuery.definition, _objectSpread(_objectSpread({}, contactByIdsQuery.options), {}, {
|
|
32
|
+
enabled: isContactByIdsQueryEnabled
|
|
33
|
+
})),
|
|
34
|
+
contacts = _useQuery.data,
|
|
35
|
+
contactsQueryResult = (0, _objectWithoutProperties2.default)(_useQuery, _excluded);
|
|
36
|
+
|
|
37
|
+
var isLoadingContacts = isContactByIdsQueryEnabled && ((0, _cozyClient.isQueryLoading)(contactsQueryResult) || contactsQueryResult.hasMore);
|
|
38
|
+
return {
|
|
39
|
+
contacts: contacts,
|
|
40
|
+
isLoadingContacts: isLoadingContacts
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var _default = useReferencedContactName;
|
|
45
|
+
exports.default = _default;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Viewer } from "./Viewer";
|
|
2
|
+
export { default as ViewerContainer } from "./ViewerContainer";
|
|
3
|
+
export { toolbarPropsPropType } from "./proptypes";
|
|
4
|
+
export { default as ViewerWithCustomPanelAndFooter } from "./ViewerWithCustomPanelAndFooter";
|
|
5
|
+
export { default as ToolbarButtons } from "./components/ToolbarButtons";
|
|
6
|
+
export { default as FooterActionButtons } from "./Footer/FooterActionButtons";
|
|
7
|
+
export { default as ForwardButton } from "./Footer/ForwardButton";
|
|
8
|
+
export { default as ForwardOrDownloadButton } from "./Footer/ForwardOrDownloadButton";
|
|
9
|
+
export default ViewerContainer;
|
|
10
|
+
import ViewerContainer from "./ViewerContainer";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "FooterActionButtons", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _FooterActionButtons.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "ForwardButton", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _ForwardButton.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "ForwardOrDownloadButton", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _ForwardOrDownloadButton.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "ToolbarButtons", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _ToolbarButtons.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "Viewer", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _Viewer.default;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "ViewerContainer", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return _ViewerContainer.default;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "ViewerWithCustomPanelAndFooter", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return _ViewerWithCustomPanelAndFooter.default;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
exports.default = void 0;
|
|
51
|
+
Object.defineProperty(exports, "toolbarPropsPropType", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _proptypes.toolbarPropsPropType;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
var _ViewerContainer = _interopRequireDefault(require("./ViewerContainer"));
|
|
59
|
+
|
|
60
|
+
var _Viewer = _interopRequireDefault(require("./Viewer"));
|
|
61
|
+
|
|
62
|
+
var _proptypes = require("./proptypes");
|
|
63
|
+
|
|
64
|
+
var _ViewerWithCustomPanelAndFooter = _interopRequireDefault(require("./ViewerWithCustomPanelAndFooter"));
|
|
65
|
+
|
|
66
|
+
var _ToolbarButtons = _interopRequireDefault(require("./components/ToolbarButtons"));
|
|
67
|
+
|
|
68
|
+
var _FooterActionButtons = _interopRequireDefault(require("./Footer/FooterActionButtons"));
|
|
69
|
+
|
|
70
|
+
var _ForwardButton = _interopRequireDefault(require("./Footer/ForwardButton"));
|
|
71
|
+
|
|
72
|
+
var _ForwardOrDownloadButton = _interopRequireDefault(require("./Footer/ForwardOrDownloadButton"));
|
|
73
|
+
|
|
74
|
+
var _default = _ViewerContainer.default;
|
|
75
|
+
exports.default = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.locales = void 0;
|
|
9
|
+
|
|
10
|
+
var _en = _interopRequireDefault(require("./en.json"));
|
|
11
|
+
|
|
12
|
+
var _fr = _interopRequireDefault(require("./fr.json"));
|
|
13
|
+
|
|
14
|
+
var locales = {
|
|
15
|
+
en: _en.default,
|
|
16
|
+
fr: _fr.default
|
|
17
|
+
};
|
|
18
|
+
exports.locales = locales;
|