cozy-ui 111.20.0 → 112.0.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 +21 -0
- package/package.json +3 -2
- package/react/FileImageLoader/Readme.md +66 -3
- package/react/FileImageLoader/index.jsx +3 -3
- package/react/FileImageLoader/index.spec.jsx +1 -1
- package/react/Skeletons/ListItemSkeleton.jsx +4 -3
- package/react/Skeletons/Readme.md +12 -3
- package/react/hooks/useClientErrors.jsx +140 -0
- package/react/hooks/useClientErrors.spec.jsx +102 -0
- package/react/index.js +0 -1
- package/transpiled/react/FileImageLoader/index.js +3 -3
- package/transpiled/react/Skeletons/ListItemSkeleton.js +7 -3
- package/transpiled/react/hooks/useClientErrors.js +167 -0
- package/transpiled/react/index.js +0 -1
- package/transpiled/react/stylesheet.css +1 -1
- package/react/Viewer/Footer/BottomSheetContent.jsx +0 -29
- package/react/Viewer/Footer/DownloadButton.jsx +0 -67
- package/react/Viewer/Footer/FooterActionButtons.jsx +0 -22
- package/react/Viewer/Footer/FooterActionButtons.spec.jsx +0 -30
- package/react/Viewer/Footer/FooterContent.jsx +0 -99
- package/react/Viewer/Footer/ForwardButton.jsx +0 -95
- package/react/Viewer/Footer/ForwardButton.spec.jsx +0 -87
- package/react/Viewer/Footer/ForwardOrDownloadButton.jsx +0 -24
- package/react/Viewer/Footer/Sharing.jsx +0 -60
- package/react/Viewer/Footer/helpers.js +0 -107
- package/react/Viewer/Footer/helpers.spec.js +0 -77
- package/react/Viewer/NoViewer/DownloadButton.jsx +0 -28
- package/react/Viewer/NoViewer/FileIcon.jsx +0 -46
- package/react/Viewer/NoViewer/NoViewer.jsx +0 -29
- package/react/Viewer/NoViewer/NoViewer.spec.jsx +0 -44
- package/react/Viewer/NoViewer/__snapshots__/NoViewer.spec.jsx.snap +0 -82
- package/react/Viewer/NoViewer/index.jsx +0 -1
- package/react/Viewer/Panel/ActionMenuDesktop.jsx +0 -66
- package/react/Viewer/Panel/ActionMenuMobile.jsx +0 -74
- package/react/Viewer/Panel/ActionMenuWrapper.jsx +0 -104
- package/react/Viewer/Panel/Certifications.jsx +0 -62
- package/react/Viewer/Panel/PanelContent.jsx +0 -49
- package/react/Viewer/Panel/Qualification.jsx +0 -114
- package/react/Viewer/Panel/QualificationListItemContact.jsx +0 -85
- package/react/Viewer/Panel/QualificationListItemDate.jsx +0 -77
- package/react/Viewer/Panel/QualificationListItemInformation.jsx +0 -68
- package/react/Viewer/Panel/QualificationListItemInformation.spec.jsx +0 -73
- package/react/Viewer/Panel/QualificationListItemOther.jsx +0 -61
- package/react/Viewer/Panel/QualificationListItemText.jsx +0 -30
- package/react/Viewer/Panel/getPanelBlocks.jsx +0 -56
- package/react/Viewer/Panel/getPanelBlocks.spec.jsx +0 -79
- package/react/Viewer/Panel/styles.styl +0 -13
- package/react/Viewer/Readme.md +0 -352
- package/react/Viewer/Viewer.jsx +0 -134
- package/react/Viewer/ViewerContainer.jsx +0 -169
- package/react/Viewer/ViewerExposer.js +0 -3
- package/react/Viewer/ViewerInformationsWrapper.jsx +0 -69
- package/react/Viewer/ViewerInformationsWrapper.spec.jsx +0 -63
- package/react/Viewer/ViewerWithCustomPanelAndFooter.jsx +0 -55
- package/react/Viewer/ViewersByFile/AudioViewer.jsx +0 -21
- package/react/Viewer/ViewersByFile/AudioViewer.spec.jsx +0 -39
- package/react/Viewer/ViewersByFile/BlankPaperViewer.jsx +0 -46
- package/react/Viewer/ViewersByFile/ImageViewer.jsx +0 -330
- package/react/Viewer/ViewersByFile/ImageViewer.spec.jsx +0 -70
- package/react/Viewer/ViewersByFile/NoNetworkViewer.jsx +0 -17
- package/react/Viewer/ViewersByFile/OnlyOfficeViewer.jsx +0 -28
- package/react/Viewer/ViewersByFile/PdfJsViewer.jsx +0 -210
- package/react/Viewer/ViewersByFile/PdfJsViewer.spec.jsx +0 -160
- package/react/Viewer/ViewersByFile/PdfMobileViewer.jsx +0 -106
- package/react/Viewer/ViewersByFile/PdfMobileViewer.spec.jsx +0 -76
- package/react/Viewer/ViewersByFile/ShortcutViewer.jsx +0 -38
- package/react/Viewer/ViewersByFile/ShortcutViewer.spec.jsx +0 -32
- package/react/Viewer/ViewersByFile/TextViewer.jsx +0 -126
- package/react/Viewer/ViewersByFile/TextViewer.spec.jsx +0 -118
- package/react/Viewer/ViewersByFile/VideoViewer.jsx +0 -13
- package/react/Viewer/ViewersByFile/VideoViewer.spec.jsx +0 -39
- package/react/Viewer/ViewersByFile/__snapshots__/AudioViewer.spec.jsx.snap +0 -43
- package/react/Viewer/ViewersByFile/__snapshots__/ShortcutViewer.spec.jsx.snap +0 -57
- package/react/Viewer/ViewersByFile/__snapshots__/TextViewer.spec.jsx.snap +0 -100
- package/react/Viewer/ViewersByFile/__snapshots__/VideoViewer.spec.jsx.snap +0 -19
- package/react/Viewer/ViewersByFile/styles.styl +0 -87
- package/react/Viewer/assets/IlluGenericNewPage.svg +0 -10
- package/react/Viewer/components/ExpirationAlert.jsx +0 -86
- package/react/Viewer/components/ExpirationAnnotation.jsx +0 -40
- package/react/Viewer/components/Footer.jsx +0 -13
- package/react/Viewer/components/InformationPanel.jsx +0 -26
- package/react/Viewer/components/Navigation.jsx +0 -39
- package/react/Viewer/components/PdfToolbarButton.jsx +0 -26
- package/react/Viewer/components/PrintButton.jsx +0 -90
- package/react/Viewer/components/Toolbar.jsx +0 -111
- package/react/Viewer/components/ToolbarButtons.jsx +0 -11
- package/react/Viewer/components/ToolbarFilePath.jsx +0 -61
- package/react/Viewer/components/ViewerByFile.jsx +0 -112
- package/react/Viewer/components/ViewerByFile.spec.jsx +0 -100
- package/react/Viewer/components/ViewerControls.jsx +0 -190
- package/react/Viewer/components/ViewerControls.spec.jsx +0 -54
- package/react/Viewer/components/ViewerSpinner.jsx +0 -17
- package/react/Viewer/components/styles.styl +0 -93
- package/react/Viewer/helpers.js +0 -131
- package/react/Viewer/helpers.spec.js +0 -136
- package/react/Viewer/hoc/withFileUrl.jsx +0 -93
- package/react/Viewer/hoc/withViewerLocales.jsx +0 -4
- package/react/Viewer/hooks/useReferencedContactName.jsx +0 -26
- package/react/Viewer/index.jsx +0 -12
- package/react/Viewer/locales/en.json +0 -66
- package/react/Viewer/locales/fr.json +0 -66
- package/react/Viewer/locales/index.js +0 -4
- package/react/Viewer/proptypes.js +0 -12
- package/react/Viewer/providers/ActionMenuProvider.jsx +0 -35
- package/react/Viewer/queries.js +0 -20
- package/react/Viewer/styles.styl +0 -22
- package/react/Viewer/vars.styl +0 -6
- package/transpiled/react/Viewer/Footer/BottomSheetContent.js +0 -28
- package/transpiled/react/Viewer/Footer/DownloadButton.js +0 -91
- package/transpiled/react/Viewer/Footer/FooterActionButtons.js +0 -21
- package/transpiled/react/Viewer/Footer/FooterContent.js +0 -98
- package/transpiled/react/Viewer/Footer/ForwardButton.js +0 -143
- package/transpiled/react/Viewer/Footer/ForwardOrDownloadButton.js +0 -25
- package/transpiled/react/Viewer/Footer/Sharing.js +0 -57
- package/transpiled/react/Viewer/Footer/helpers.js +0 -151
- package/transpiled/react/Viewer/NoViewer/DownloadButton.js +0 -34
- package/transpiled/react/Viewer/NoViewer/FileIcon.js +0 -57
- package/transpiled/react/Viewer/NoViewer/NoViewer.js +0 -49
- package/transpiled/react/Viewer/NoViewer/index.js +0 -1
- package/transpiled/react/Viewer/Panel/ActionMenuDesktop.js +0 -68
- package/transpiled/react/Viewer/Panel/ActionMenuMobile.js +0 -70
- package/transpiled/react/Viewer/Panel/ActionMenuWrapper.js +0 -129
- package/transpiled/react/Viewer/Panel/Certifications.js +0 -56
- package/transpiled/react/Viewer/Panel/PanelContent.js +0 -48
- package/transpiled/react/Viewer/Panel/Qualification.js +0 -119
- package/transpiled/react/Viewer/Panel/QualificationListItemContact.js +0 -96
- package/transpiled/react/Viewer/Panel/QualificationListItemDate.js +0 -64
- package/transpiled/react/Viewer/Panel/QualificationListItemInformation.js +0 -59
- package/transpiled/react/Viewer/Panel/QualificationListItemOther.js +0 -53
- package/transpiled/react/Viewer/Panel/QualificationListItemText.js +0 -29
- package/transpiled/react/Viewer/Panel/getPanelBlocks.js +0 -62
- package/transpiled/react/Viewer/Viewer.js +0 -172
- package/transpiled/react/Viewer/ViewerContainer.js +0 -189
- package/transpiled/react/Viewer/ViewerExposer.js +0 -2
- package/transpiled/react/Viewer/ViewerInformationsWrapper.js +0 -49
- package/transpiled/react/Viewer/ViewerWithCustomPanelAndFooter.js +0 -56
- package/transpiled/react/Viewer/ViewersByFile/AudioViewer.js +0 -41
- package/transpiled/react/Viewer/ViewersByFile/BlankPaperViewer.js +0 -74
- package/transpiled/react/Viewer/ViewersByFile/ImageViewer.js +0 -367
- package/transpiled/react/Viewer/ViewersByFile/NoNetworkViewer.js +0 -38
- package/transpiled/react/Viewer/ViewersByFile/OnlyOfficeViewer.js +0 -29
- package/transpiled/react/Viewer/ViewersByFile/PdfJsViewer.js +0 -254
- package/transpiled/react/Viewer/ViewersByFile/PdfMobileViewer.js +0 -153
- package/transpiled/react/Viewer/ViewersByFile/ShortcutViewer.js +0 -42
- package/transpiled/react/Viewer/ViewersByFile/TextViewer.js +0 -219
- package/transpiled/react/Viewer/ViewersByFile/VideoViewer.js +0 -33
- package/transpiled/react/Viewer/assets/IlluGenericNewPage.svg +0 -10
- package/transpiled/react/Viewer/components/ExpirationAlert.js +0 -100
- package/transpiled/react/Viewer/components/ExpirationAnnotation.js +0 -41
- package/transpiled/react/Viewer/components/Footer.js +0 -29
- package/transpiled/react/Viewer/components/InformationPanel.js +0 -23
- package/transpiled/react/Viewer/components/Navigation.js +0 -47
- package/transpiled/react/Viewer/components/PdfToolbarButton.js +0 -28
- package/transpiled/react/Viewer/components/PrintButton.js +0 -137
- package/transpiled/react/Viewer/components/Toolbar.js +0 -115
- package/transpiled/react/Viewer/components/ToolbarButtons.js +0 -9
- package/transpiled/react/Viewer/components/ToolbarFilePath.js +0 -71
- package/transpiled/react/Viewer/components/ViewerByFile.js +0 -105
- package/transpiled/react/Viewer/components/ViewerControls.js +0 -226
- package/transpiled/react/Viewer/components/ViewerSpinner.js +0 -17
- package/transpiled/react/Viewer/helpers.js +0 -147
- package/transpiled/react/Viewer/hoc/withFileUrl.js +0 -207
- package/transpiled/react/Viewer/hoc/withViewerLocales.js +0 -3
- package/transpiled/react/Viewer/hooks/useReferencedContactName.js +0 -32
- package/transpiled/react/Viewer/index.js +0 -11
- package/transpiled/react/Viewer/locales/index.js +0 -136
- package/transpiled/react/Viewer/proptypes.js +0 -14
- package/transpiled/react/Viewer/providers/ActionMenuProvider.js +0 -34
- package/transpiled/react/Viewer/queries.js +0 -26
- /package/react/{Viewer/providers/EncryptedProvider.jsx → providers/Encrypted/index.jsx} +0 -0
- /package/transpiled/react/{Viewer/providers/EncryptedProvider.js → providers/Encrypted/index.js} +0 -0
package/react/Viewer/Readme.md
DELETED
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
The `Viewer` component can be used to display the content of various file types.
|
|
2
|
-
|
|
3
|
-
Once rendered, the `Viewer` will take up all the available space in it's container (using `position: absolute`).
|
|
4
|
-
|
|
5
|
-
The `Viewer` can display an **information panel** to show additional information about the current file (e.g. whether a file is certified).
|
|
6
|
-
|
|
7
|
-
### ⚠️ Requirement
|
|
8
|
-
|
|
9
|
-
* You must have [WebviewIntent Provider](https://github.com/cozy/cozy-libs/blob/b1ad6f5933b463878f641d9fbb63eddd4c45b0d0/packages/cozy-intent/src/view/components/WebviewIntentProvider.tsx#L89) & [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
|
-
|
|
13
|
-
### Props
|
|
14
|
-
|
|
15
|
-
* **files** : `<array>` – One or more `io.cozy.files` to display
|
|
16
|
-
* **currentIndex** : `<number>` – Index of the file to show
|
|
17
|
-
* **currentURL** : `<string>` – Optionnal URL of the file
|
|
18
|
-
* **className** : `<string>` – CSS classes
|
|
19
|
-
* **showNavigation** : `<boolean>` – Whether to show left and right arrows to navigate between files
|
|
20
|
-
* **renderFallbackExtraContent** : `<function>` – A render prop that is called when a file can't be displayed
|
|
21
|
-
* **disablePanel** : `<boolean>` – Show/Hide the panel containing more information about the file only on Desktop
|
|
22
|
-
* **disableFooter** : `<boolean>` – Show/Hide the panel containing more information about the file only on Phone & Tablet devices
|
|
23
|
-
* **disableModal** : `<boolean>` – To avoid wrapping the Viewer with a Modal component (wrapper of Viewer)
|
|
24
|
-
* **editPathByModelProps** : `<object>` – Edit path by model properties
|
|
25
|
-
* **information** : `<string>` – URL used to edit the file when editing a `information` type metadata (text, date)
|
|
26
|
-
* **page** : `<string>` – URL used to edit the file when editing a `page` type metadata (side of the document)
|
|
27
|
-
* **onChangeRequest** : `<function>` - Called with (nextFile, nextIndex) when the user requests to navigate to another file
|
|
28
|
-
* **onCloseRequest** : `<function>` - Called when the user wants to leave the Viewer
|
|
29
|
-
* **isPublic**: `<boolean>` - Whether the viewer is used in a public page or not
|
|
30
|
-
* **componentsProps** : `<object>` – Props passed to components with the same name
|
|
31
|
-
* **modalProps** : `<object>` – Props passed to Modal component
|
|
32
|
-
* **OnlyOfficeViewer** : `<object>` – Used to open an Only Office file
|
|
33
|
-
* **isEnabled** : `<boolean>` – Whether Only Office is enabled on the server
|
|
34
|
-
* **opener** : `<function>` – To open the Only Office file
|
|
35
|
-
* **toolbarProps** : `<object>` – Toolbar properties
|
|
36
|
-
* **toolbarRef** : `<object>` – React reference of the toolbar node
|
|
37
|
-
* **showToolbar** : `<boolean>` – Whether to show the toolbar or not. Note that the built-in close button is in the toolbar
|
|
38
|
-
* **showClose** : `<boolean>` – Whether to show close button in toolbar
|
|
39
|
-
* **showFilePath** : `<boolean>` – Whether to show file path below his name
|
|
40
|
-
|
|
41
|
-
### Demo
|
|
42
|
-
|
|
43
|
-
```jsx
|
|
44
|
-
import cx from 'classnames'
|
|
45
|
-
import { makeStyles } from 'cozy-ui/transpiled/react/styles'
|
|
46
|
-
import Variants from 'cozy-ui/docs/components/Variants'
|
|
47
|
-
import Card from 'cozy-ui/transpiled/react/Card'
|
|
48
|
-
import Checkbox from 'cozy-ui/transpiled/react/Checkbox'
|
|
49
|
-
import Viewer, { ToolbarButtons, FooterActionButtons, ForwardOrDownloadButton } from 'cozy-ui/transpiled/react/Viewer'
|
|
50
|
-
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
51
|
-
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
52
|
-
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
53
|
-
import { Media, Img, Bd } from 'cozy-ui/transpiled/react/deprecated/Media'
|
|
54
|
-
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
55
|
-
import CarbonCopyIcon from 'cozy-ui/transpiled/react/Icons/CarbonCopy'
|
|
56
|
-
// The DemoProvider inserts a fake cozy-client in the React context.
|
|
57
|
-
import DemoProvider from './docs/DemoProvider'
|
|
58
|
-
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
59
|
-
import DownloadIcon from 'cozy-ui/transpiled/react/Icons/Download'
|
|
60
|
-
import ShareIcon from 'cozy-ui/transpiled/react/Icons/Share'
|
|
61
|
-
import { isValidForPanel } from 'cozy-ui/transpiled/react/Viewer/helpers'
|
|
62
|
-
import getPanelBlocks, { panelBlocksSpecs } from 'cozy-ui/transpiled/react/Viewer/Panel/getPanelBlocks'
|
|
63
|
-
import Sprite from 'cozy-ui/transpiled/react/Icon/Sprite'
|
|
64
|
-
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
65
|
-
|
|
66
|
-
// We provide a collection of (fake) io.cozy.files to be rendered
|
|
67
|
-
const files = [
|
|
68
|
-
{
|
|
69
|
-
_id: 'audio',
|
|
70
|
-
class: 'audio',
|
|
71
|
-
type: 'file',
|
|
72
|
-
name: 'Sample.mp3',
|
|
73
|
-
mime: 'audio/mp3',
|
|
74
|
-
dir_id: 'parent_folder'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
_id: 'slide',
|
|
78
|
-
class: 'slide',
|
|
79
|
-
type: 'file',
|
|
80
|
-
name: 'Slide.pptx',
|
|
81
|
-
mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
82
|
-
dir_id: 'parent_folder'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
_id: 'pdf',
|
|
86
|
-
class: 'pdf',
|
|
87
|
-
type: 'file',
|
|
88
|
-
name: 'My vehicle registration.pdf',
|
|
89
|
-
mime: 'application/pdf',
|
|
90
|
-
bills: { data: [{ amount: '500' }] },
|
|
91
|
-
metadata: {
|
|
92
|
-
carbonCopy: true,
|
|
93
|
-
AObtentionDate: null,
|
|
94
|
-
BObtentionDate: "2022-02-09T09:05:38.000Z",
|
|
95
|
-
CObtentionDate: null,
|
|
96
|
-
DObtentionDate: null,
|
|
97
|
-
datetime: "2022-09-23T07:50:22.000Z",
|
|
98
|
-
datetimeLabel: "BObtentionDate",
|
|
99
|
-
expirationDate: new Date(Date.now() + 10 * 24 * 60 * 60 * 1000).toISOString(),
|
|
100
|
-
noticePeriod: "90",
|
|
101
|
-
number: "",
|
|
102
|
-
page: "front",
|
|
103
|
-
qualification: {
|
|
104
|
-
label: "driver_license",
|
|
105
|
-
purpose: "attestation",
|
|
106
|
-
sourceCategory: "gov",
|
|
107
|
-
sourceSubCategory: "transport",
|
|
108
|
-
subjects: ["permit", "driving"]
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
dir_id: 'parent_folder'
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
_id: 'text',
|
|
115
|
-
class: 'text',
|
|
116
|
-
type: 'file',
|
|
117
|
-
name: 'LoremipsumdolorsitametconsecteturadipiscingelitSednonrisusSuspendisselectustortordignissimsitametadipiscingnecultriciesseddolorCraselementumultricesdiamMaecenasligulamassavariusasempercongueeuismodnonmiProinporttitororcinecnonummymolestieenimesteleifendminonfermentumdiamnislsitameteratDuissemperDuisarcumassascelerisquevitaeconsequatinpretiumaenimPellentesquecongueUtinrisusvolutpatliberopharetratemporCrasvestibulumbibendumauguePraesentegestasleoinpedePraesentblanditodioeuenimPellentesquesedduiutaugueblanditsodalesVestibulumanteipsumprimisinfaucibusorciluctusetultricesposuerecubiliaCuraeAliquamnibhMaurisacmaurissedpedepellentesquefermentumMaecenasadipiscingantenondiamsodaleshendrerit.txt',
|
|
118
|
-
mime: 'text/plain',
|
|
119
|
-
metadata: {
|
|
120
|
-
datetime: "2022-01-01T12:00:00.000Z",
|
|
121
|
-
datetimeLabel: "datetime",
|
|
122
|
-
qualification: {
|
|
123
|
-
label: 'tax_notice'
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
_id: 'text',
|
|
129
|
-
class: 'text',
|
|
130
|
-
type: 'file',
|
|
131
|
-
name: 'encrypted-example.txt',
|
|
132
|
-
mime: 'text/plain',
|
|
133
|
-
encrypted: true
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
_id: 'image',
|
|
137
|
-
class: 'image',
|
|
138
|
-
type: 'file',
|
|
139
|
-
name: 'Demo.jpg',
|
|
140
|
-
mime: 'image/jpg',
|
|
141
|
-
metadata: {
|
|
142
|
-
carbonCopy: true,
|
|
143
|
-
electronicSafe: true,
|
|
144
|
-
referencedDate: new Date(Date.now() - 357 * 24 * 60 * 60 * 1000).toISOString(),
|
|
145
|
-
datetimeLabel: "referencedDate",
|
|
146
|
-
qualification: {
|
|
147
|
-
label: 'personal_sporting_licence'
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
_id: 'none',
|
|
153
|
-
class: 'unknown',
|
|
154
|
-
type: 'file',
|
|
155
|
-
name: 'Unsupported file type',
|
|
156
|
-
mime: '???/???'
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
_id: 'none',
|
|
160
|
-
class: 'unknown',
|
|
161
|
-
type: 'file',
|
|
162
|
-
name: 'Unsupported file type',
|
|
163
|
-
mime: '???/???',
|
|
164
|
-
metadata: {
|
|
165
|
-
carbonCopy: true,
|
|
166
|
-
AObtentionDate: null,
|
|
167
|
-
BObtentionDate: "2022-02-09T09:05:38.000Z",
|
|
168
|
-
CObtentionDate: null,
|
|
169
|
-
DObtentionDate: null,
|
|
170
|
-
datetime: "2022-09-23T07:50:22.000Z",
|
|
171
|
-
datetimeLabel: "BObtentionDate",
|
|
172
|
-
number: "",
|
|
173
|
-
page: "front",
|
|
174
|
-
qualification: {
|
|
175
|
-
label: "driver_license",
|
|
176
|
-
purpose: "attestation",
|
|
177
|
-
sourceCategory: "gov",
|
|
178
|
-
sourceSubCategory: "transport",
|
|
179
|
-
subjects: ["permit", "driving"]
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
]
|
|
184
|
-
|
|
185
|
-
const ShareButtonFake = () => {
|
|
186
|
-
return (
|
|
187
|
-
<Button
|
|
188
|
-
label="Share"
|
|
189
|
-
className="u-w-100 u-ml-0 u-mr-0"
|
|
190
|
-
variant="secondary"
|
|
191
|
-
startIcon={<Icon icon={ShareIcon} />}
|
|
192
|
-
onClick={() => {
|
|
193
|
-
return alert("This is a demo, there's no actual Cozy to share the file from ¯\\_(ツ)_/¯")
|
|
194
|
-
}}
|
|
195
|
-
/>
|
|
196
|
-
)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// The host app will usually need a small wrapper to display the Viewer. This is a very small example of such a wrapper that handles opening, closing, and navigating between files.
|
|
200
|
-
initialState = {
|
|
201
|
-
viewerOpened: isTesting(),
|
|
202
|
-
currentIndex: 0,
|
|
203
|
-
showToolbarCloseButton: true,
|
|
204
|
-
showToolbarWithPath: false
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const initialVariants = [
|
|
208
|
-
{ navigation: true, toolbar: true, onlyOfficeEnabled: true, disableModal: false, isPublic: false }
|
|
209
|
-
]
|
|
210
|
-
|
|
211
|
-
const getURL = (file) => {
|
|
212
|
-
if (file.encrypted && file.class === 'text') {
|
|
213
|
-
const text = 'Well, hello there. This file is served through an URL'
|
|
214
|
-
const textBlob = new Blob([text], {
|
|
215
|
-
type: 'text/plain'
|
|
216
|
-
})
|
|
217
|
-
return URL.createObjectURL(textBlob)
|
|
218
|
-
}
|
|
219
|
-
return null
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const toggleViewer = () => setState({ viewerOpened: !state.viewerOpened })
|
|
223
|
-
const handleToggleToolbarClose = () => setState({ showToolbarCloseButton: !state.showToolbarCloseButton })
|
|
224
|
-
const handleToggleToolbarWithPath = () => setState({ showToolbarWithPath: !state.showToolbarWithPath })
|
|
225
|
-
const onFileChange = (file, nextIndex) => setState({ currentIndex: nextIndex, currentURL: getURL(file) })
|
|
226
|
-
const editPathByModelProps = {
|
|
227
|
-
information: `#!/Viewer?metadata=__NAME__`,
|
|
228
|
-
page: `#!/Viewer`
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
<DemoProvider>
|
|
232
|
-
<Variants initialVariants={initialVariants}>{
|
|
233
|
-
variant => (
|
|
234
|
-
<>
|
|
235
|
-
{variant.toolbar && (
|
|
236
|
-
<Card className="u-mb-1">
|
|
237
|
-
<div className="u-dib u-mr-1">Toolbar props :</div>
|
|
238
|
-
<Checkbox
|
|
239
|
-
className="u-dib"
|
|
240
|
-
label="Close"
|
|
241
|
-
checked={state.showToolbarCloseButton}
|
|
242
|
-
onChange={handleToggleToolbarClose}
|
|
243
|
-
/>
|
|
244
|
-
<Checkbox
|
|
245
|
-
className="u-dib"
|
|
246
|
-
label="Show path"
|
|
247
|
-
checked={state.showToolbarWithPath}
|
|
248
|
-
onChange={handleToggleToolbarWithPath}
|
|
249
|
-
/>
|
|
250
|
-
</Card>
|
|
251
|
-
)}
|
|
252
|
-
<Button label="Open viewer" variant="ghost" size="small" onClick={toggleViewer} />
|
|
253
|
-
{state.viewerOpened && (
|
|
254
|
-
<Viewer
|
|
255
|
-
files={files}
|
|
256
|
-
isPublic={variant.isPublic}
|
|
257
|
-
currentIndex={state.currentIndex}
|
|
258
|
-
currentURL={state.currentURL}
|
|
259
|
-
disableModal={variant.disableModal}
|
|
260
|
-
showNavigation={variant.navigation}
|
|
261
|
-
editPathByModelProps={editPathByModelProps}
|
|
262
|
-
onCloseRequest={toggleViewer}
|
|
263
|
-
onChangeRequest={onFileChange}
|
|
264
|
-
componentsProps={{
|
|
265
|
-
OnlyOfficeViewer: {
|
|
266
|
-
isEnabled: variant.onlyOfficeEnabled,
|
|
267
|
-
opener: () => alert('This is a demo, no Only Office opener here')
|
|
268
|
-
},
|
|
269
|
-
toolbarProps:{
|
|
270
|
-
showToolbar: variant.toolbar,
|
|
271
|
-
showClose: state.showToolbarCloseButton,
|
|
272
|
-
showFilePath: state.showToolbarWithPath
|
|
273
|
-
}
|
|
274
|
-
}}
|
|
275
|
-
>
|
|
276
|
-
<ToolbarButtons>
|
|
277
|
-
<IconButton
|
|
278
|
-
className="u-white"
|
|
279
|
-
aria-label="Share"
|
|
280
|
-
onClick={() => alert("Click Share toolbar button")}
|
|
281
|
-
>
|
|
282
|
-
<Icon icon={ShareIcon} />
|
|
283
|
-
</IconButton>
|
|
284
|
-
<IconButton
|
|
285
|
-
className="u-white"
|
|
286
|
-
aria-label="Carbon Copy"
|
|
287
|
-
onClick={() => alert("Click CarbonCopy toolbar button")}
|
|
288
|
-
>
|
|
289
|
-
<Icon icon={CarbonCopyIcon} />
|
|
290
|
-
</IconButton>
|
|
291
|
-
</ToolbarButtons>
|
|
292
|
-
<FooterActionButtons>
|
|
293
|
-
<ShareButtonFake />
|
|
294
|
-
<ForwardOrDownloadButton />
|
|
295
|
-
</FooterActionButtons>
|
|
296
|
-
</Viewer>
|
|
297
|
-
)}
|
|
298
|
-
</>
|
|
299
|
-
)
|
|
300
|
-
}
|
|
301
|
-
</Variants>
|
|
302
|
-
<Sprite />
|
|
303
|
-
</DemoProvider>
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
### Using a worker for pdfjs
|
|
307
|
-
|
|
308
|
-
For performance reasons, it is important to use a web worker when showing PDF files in the viewer. If you use webpack, you should add the following alias in your configuration :
|
|
309
|
-
|
|
310
|
-
```diff
|
|
311
|
-
+ resolve: {
|
|
312
|
-
+ alias: {
|
|
313
|
-
+ 'react-pdf$' : 'react-pdf/dist/esm/entry.webpack'
|
|
314
|
-
+ }
|
|
315
|
-
+ }
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
With this alias, a specific JS file for the worker will be created in the build directory. By design, this directory is only accessible (ie. served by the stack) if you are logged in. If you need the viewer on a public page, you must tell webpack to create the worker in a public folder, that will be served by the stack even if the user is not logged in.
|
|
319
|
-
|
|
320
|
-
One way to do this is to explicitly load the web worker in your application like this:
|
|
321
|
-
|
|
322
|
-
```js static
|
|
323
|
-
import createWorker from 'react-pdf/dist/esm/pdf.worker.entry';
|
|
324
|
-
import { pdfjs } from 'react-pdf';
|
|
325
|
-
|
|
326
|
-
pdfjs.GlobalWorkerOptions.workerPort = createWorker();
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
And then configure the [webpack worker-loader](https://github.com/webpack-contrib/worker-loader) to output the file in a publicly served directory:
|
|
330
|
-
|
|
331
|
-
```js static
|
|
332
|
-
{
|
|
333
|
-
test: /\.worker\.entry\.js$/,
|
|
334
|
-
issuer: { not: [/node_modules\//] }, // only for the worker loaded by the app, leave the workers created by dependencies alone
|
|
335
|
-
use: [{
|
|
336
|
-
loader: 'worker-loader',
|
|
337
|
-
options: {
|
|
338
|
-
name: 'public-folder/[name].[hash].worker.js'
|
|
339
|
-
}
|
|
340
|
-
}]
|
|
341
|
-
}
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### Only works with React
|
|
345
|
-
|
|
346
|
-
The `Viewer` can be used only in a `React` Application. You can't use it with `Preact`.
|
|
347
|
-
|
|
348
|
-
### Special case: client-side encrypted files
|
|
349
|
-
|
|
350
|
-
When a file is client-side encrypted, it is not possible to get the download link from the server anymore.
|
|
351
|
-
Hence, an additional `currentURL` prop must be eventually given to the `<Viewer>`. This URL is the decrypted
|
|
352
|
-
file, asynchronously provided by the app.
|
package/react/Viewer/Viewer.jsx
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React, { Component } from 'react'
|
|
3
|
-
|
|
4
|
-
import { toolbarPropsPropType } from '.'
|
|
5
|
-
import ViewerByFile from './components/ViewerByFile'
|
|
6
|
-
import ViewerControls from './components/ViewerControls'
|
|
7
|
-
import { FileDoctype } from '../proptypes'
|
|
8
|
-
|
|
9
|
-
const KEY_CODE_LEFT = 37
|
|
10
|
-
const KEY_CODE_RIGHT = 39
|
|
11
|
-
const KEY_CODE_ESCAPE = 27
|
|
12
|
-
|
|
13
|
-
class Viewer extends Component {
|
|
14
|
-
constructor() {
|
|
15
|
-
super()
|
|
16
|
-
}
|
|
17
|
-
componentDidMount() {
|
|
18
|
-
document.addEventListener('keyup', this.onKeyUp, false)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
componentWillUnmount() {
|
|
22
|
-
document.removeEventListener('keyup', this.onKeyUp, false)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
onKeyUp = e => {
|
|
26
|
-
if (e.keyCode === KEY_CODE_LEFT) this.onPrevious()
|
|
27
|
-
else if (e.keyCode === KEY_CODE_RIGHT) this.onNext()
|
|
28
|
-
else if (e.keyCode === KEY_CODE_ESCAPE) this.onClose()
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
onNext = () => {
|
|
32
|
-
const { files, currentIndex } = this.props
|
|
33
|
-
if (currentIndex === files.length - 1) {
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
const nextIndex = currentIndex + 1
|
|
37
|
-
const nextFile = files[nextIndex]
|
|
38
|
-
this.onChange(nextFile, nextIndex)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
onPrevious = () => {
|
|
42
|
-
const { files, currentIndex } = this.props
|
|
43
|
-
if (currentIndex === 0) {
|
|
44
|
-
return
|
|
45
|
-
}
|
|
46
|
-
const prevIndex = currentIndex - 1
|
|
47
|
-
const prevFile = files[prevIndex]
|
|
48
|
-
this.onChange(prevFile, prevIndex)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
onClose = () => {
|
|
52
|
-
if (this.props.onCloseRequest) {
|
|
53
|
-
this.props.onCloseRequest()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
onChange(nextFile, nextIndex) {
|
|
58
|
-
if (this.props.onChangeRequest) {
|
|
59
|
-
this.props.onChangeRequest(nextFile, nextIndex)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
render() {
|
|
64
|
-
const {
|
|
65
|
-
currentFile,
|
|
66
|
-
hasPrevious,
|
|
67
|
-
hasNext,
|
|
68
|
-
toolbarRef,
|
|
69
|
-
showNavigation,
|
|
70
|
-
renderFallbackExtraContent,
|
|
71
|
-
validForPanel,
|
|
72
|
-
children,
|
|
73
|
-
componentsProps
|
|
74
|
-
} = this.props
|
|
75
|
-
|
|
76
|
-
// this `expanded` property makes the next/previous controls cover the displayed image
|
|
77
|
-
const expanded = currentFile && currentFile.class === 'image'
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
<ViewerControls
|
|
82
|
-
file={currentFile}
|
|
83
|
-
onClose={this.onClose}
|
|
84
|
-
hasPrevious={hasPrevious}
|
|
85
|
-
hasNext={hasNext}
|
|
86
|
-
onPrevious={this.onPrevious}
|
|
87
|
-
onNext={this.onNext}
|
|
88
|
-
expanded={expanded}
|
|
89
|
-
toolbarProps={{ ...componentsProps.toolbarProps, toolbarRef }}
|
|
90
|
-
showNavigation={showNavigation}
|
|
91
|
-
showInfoPanel={validForPanel}
|
|
92
|
-
>
|
|
93
|
-
{children}
|
|
94
|
-
<ViewerByFile
|
|
95
|
-
file={currentFile}
|
|
96
|
-
onClose={this.onClose}
|
|
97
|
-
renderFallbackExtraContent={renderFallbackExtraContent}
|
|
98
|
-
componentsProps={componentsProps}
|
|
99
|
-
/>
|
|
100
|
-
</ViewerControls>
|
|
101
|
-
</>
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
Viewer.propTypes = {
|
|
107
|
-
/** One `io.cozy.files` to display */
|
|
108
|
-
currentFile: FileDoctype.isRequired,
|
|
109
|
-
hasNext: PropTypes.bool,
|
|
110
|
-
hasPrevious: PropTypes.bool,
|
|
111
|
-
/** Called when the user wants to leave the Viewer */
|
|
112
|
-
onCloseRequest: PropTypes.func,
|
|
113
|
-
/** Called with (nextFile, nextIndex) when the user requests to navigate to another file */
|
|
114
|
-
onChangeRequest: PropTypes.func,
|
|
115
|
-
toolbarRef: PropTypes.object,
|
|
116
|
-
/** Whether to show left and right arrows to navigate between files */
|
|
117
|
-
showNavigation: PropTypes.bool,
|
|
118
|
-
/** A render prop that is called when a file can't be displayed */
|
|
119
|
-
renderFallbackExtraContent: PropTypes.func,
|
|
120
|
-
validForPanel: PropTypes.bool,
|
|
121
|
-
/* Props passed to components with the same name */
|
|
122
|
-
componentsProps: PropTypes.shape({
|
|
123
|
-
/** Used to open an Only Office file */
|
|
124
|
-
OnlyOfficeViewer: PropTypes.shape({
|
|
125
|
-
/** Whether Only Office is enabled on the server */
|
|
126
|
-
isEnabled: PropTypes.bool,
|
|
127
|
-
/** To open the Only Office file */
|
|
128
|
-
opener: PropTypes.func
|
|
129
|
-
}),
|
|
130
|
-
toolbarProps: PropTypes.shape(toolbarPropsPropType)
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export default Viewer
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import cx from 'classnames'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React, { createRef } from 'react'
|
|
4
|
-
|
|
5
|
-
import Viewer from './Viewer'
|
|
6
|
-
import ViewerInformationsWrapper from './ViewerInformationsWrapper'
|
|
7
|
-
import { isValidForPanel } from './helpers'
|
|
8
|
-
import { locales } from './locales'
|
|
9
|
-
import { toolbarPropsPropType } from './proptypes'
|
|
10
|
-
import { ActionMenuProvider } from './providers/ActionMenuProvider'
|
|
11
|
-
import EncryptedProvider from './providers/EncryptedProvider'
|
|
12
|
-
import styles from './styles.styl'
|
|
13
|
-
import Modal from '../Modal'
|
|
14
|
-
import { FileDoctype } from '../proptypes'
|
|
15
|
-
import AlertProvider from '../providers/Alert'
|
|
16
|
-
import useBreakpoints from '../providers/Breakpoints'
|
|
17
|
-
import { useCozyTheme } from '../providers/CozyTheme'
|
|
18
|
-
import { useExtendI18n } from '../providers/I18n'
|
|
19
|
-
|
|
20
|
-
const ViewerContainer = props => {
|
|
21
|
-
const {
|
|
22
|
-
className,
|
|
23
|
-
disableFooter,
|
|
24
|
-
disablePanel,
|
|
25
|
-
editPathByModelProps,
|
|
26
|
-
children,
|
|
27
|
-
componentsProps,
|
|
28
|
-
isPublic,
|
|
29
|
-
...rest
|
|
30
|
-
} = props
|
|
31
|
-
const { currentIndex, files, currentURL } = props
|
|
32
|
-
const toolbarRef = createRef()
|
|
33
|
-
const { isDesktop } = useBreakpoints()
|
|
34
|
-
useExtendI18n(locales)
|
|
35
|
-
const currentFile = files[currentIndex]
|
|
36
|
-
const fileCount = files.length
|
|
37
|
-
const hasPrevious = currentIndex > 0
|
|
38
|
-
const hasNext = currentIndex < fileCount - 1
|
|
39
|
-
const validForPanel =
|
|
40
|
-
isValidForPanel({ file: currentFile }) && isDesktop && !disablePanel
|
|
41
|
-
|
|
42
|
-
const componentsPropsWithDefault = {
|
|
43
|
-
...componentsProps,
|
|
44
|
-
toolbarProps: {
|
|
45
|
-
showToolbar: true,
|
|
46
|
-
showClose: true,
|
|
47
|
-
...componentsProps?.toolbarProps
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<AlertProvider>
|
|
53
|
-
<ActionMenuProvider editPathByModelProps={editPathByModelProps}>
|
|
54
|
-
<div
|
|
55
|
-
id="viewer-wrapper"
|
|
56
|
-
className={cx(styles['viewer-wrapper'], className)}
|
|
57
|
-
>
|
|
58
|
-
<EncryptedProvider url={currentURL}>
|
|
59
|
-
<Viewer
|
|
60
|
-
{...rest}
|
|
61
|
-
componentsProps={componentsPropsWithDefault}
|
|
62
|
-
currentFile={currentFile}
|
|
63
|
-
hasPrevious={hasPrevious}
|
|
64
|
-
hasNext={hasNext}
|
|
65
|
-
validForPanel={validForPanel}
|
|
66
|
-
toolbarRef={toolbarRef}
|
|
67
|
-
>
|
|
68
|
-
{children}
|
|
69
|
-
</Viewer>
|
|
70
|
-
</EncryptedProvider>
|
|
71
|
-
<ViewerInformationsWrapper
|
|
72
|
-
isPublic={isPublic}
|
|
73
|
-
disableFooter={disableFooter}
|
|
74
|
-
validForPanel={validForPanel}
|
|
75
|
-
currentFile={currentFile}
|
|
76
|
-
toolbarRef={toolbarRef}
|
|
77
|
-
>
|
|
78
|
-
{children}
|
|
79
|
-
</ViewerInformationsWrapper>
|
|
80
|
-
</div>
|
|
81
|
-
</ActionMenuProvider>
|
|
82
|
-
</AlertProvider>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
ViewerContainer.propTypes = {
|
|
87
|
-
/** One or more `io.cozy.files` to display */
|
|
88
|
-
files: PropTypes.arrayOf(FileDoctype).isRequired,
|
|
89
|
-
/** Index of the file to show */
|
|
90
|
-
currentIndex: PropTypes.number,
|
|
91
|
-
/** Optionnal URL of the file */
|
|
92
|
-
currentURL: PropTypes.string,
|
|
93
|
-
className: PropTypes.string,
|
|
94
|
-
/** Called when the user wants to leave the Viewer */
|
|
95
|
-
onCloseRequest: PropTypes.func,
|
|
96
|
-
/** Called with (nextFile, nextIndex) when the user requests to navigate to another file */
|
|
97
|
-
onChangeRequest: PropTypes.func,
|
|
98
|
-
/** Whether to show left and right arrows to navigate between files */
|
|
99
|
-
showNavigation: PropTypes.bool,
|
|
100
|
-
/** A render prop that is called when a file can't be displayed */
|
|
101
|
-
renderFallbackExtraContent: PropTypes.func,
|
|
102
|
-
/** Edit path by model properties */
|
|
103
|
-
editPathByModelProps: PropTypes.shape({
|
|
104
|
-
/** URL used to edit the file when editing a `information` type metadata (text, date) */
|
|
105
|
-
information: PropTypes.string,
|
|
106
|
-
/** URL used to edit the file when editing a `page` type metadata (side of the document) */
|
|
107
|
-
page: PropTypes.string
|
|
108
|
-
}),
|
|
109
|
-
/** Show/Hide the panel containing more information about the file only on Desktop */
|
|
110
|
-
disablePanel: PropTypes.bool,
|
|
111
|
-
/** Show/Hide the panel containing more information about the file only on Phone & Tablet devices */
|
|
112
|
-
disableFooter: PropTypes.bool,
|
|
113
|
-
/** If the Viewer is in public view */
|
|
114
|
-
isPublic: PropTypes.bool,
|
|
115
|
-
/* Props passed to components with the same name */
|
|
116
|
-
componentsProps: PropTypes.shape({
|
|
117
|
-
/** Used to open an Only Office file */
|
|
118
|
-
OnlyOfficeViewer: PropTypes.shape({
|
|
119
|
-
/** Whether Only Office is enabled on the server */
|
|
120
|
-
isEnabled: PropTypes.bool,
|
|
121
|
-
/** To open the Only Office file */
|
|
122
|
-
opener: PropTypes.func
|
|
123
|
-
}),
|
|
124
|
-
/** Toolbar properties */
|
|
125
|
-
toolbarProps: PropTypes.shape(toolbarPropsPropType)
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
ViewerContainer.defaultProps = {
|
|
130
|
-
currentIndex: 0,
|
|
131
|
-
showNavigation: true
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const ViewerContainerWrapper = ({ disableModal, ...props }) => {
|
|
135
|
-
const { type, variant } = useCozyTheme()
|
|
136
|
-
const { modalProps = { open: true } } = props.componentsProps || {}
|
|
137
|
-
|
|
138
|
-
if (disableModal) {
|
|
139
|
-
return <ViewerContainer {...props} />
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<Modal {...modalProps} className={`CozyTheme--${type}-${variant}`}>
|
|
144
|
-
{/* This div is needed for the Modal ref */}
|
|
145
|
-
<div>
|
|
146
|
-
<ViewerContainer {...props} />
|
|
147
|
-
</div>
|
|
148
|
-
</Modal>
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
ViewerContainerWrapper.defaultProps = {
|
|
153
|
-
componentsProps: {
|
|
154
|
-
modalProps: {
|
|
155
|
-
open: true
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
ViewerContainerWrapper.propTypes = {
|
|
161
|
-
/** To avoid wrapping the Viewer with a Modal component */
|
|
162
|
-
disableModal: PropTypes.bool,
|
|
163
|
-
/** Props passed to Modal component */
|
|
164
|
-
componentsProps: PropTypes.shape({
|
|
165
|
-
modalProps: PropTypes.object
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export default ViewerContainerWrapper
|