cozy-ui 62.11.0 → 62.12.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 +14 -0
- package/CODEOWNERS +2 -0
- package/package.json +3 -4
- package/react/ActionMenu/index.jsx +2 -1
- package/react/BottomSheet/BottomSheet.jsx +53 -45
- package/react/Dialog/index.jsx +7 -3
- package/react/SelectionBar/index.jsx +8 -4
- package/react/Sidebar/index.jsx +2 -1
- package/react/Viewer/Viewer.jsx +131 -0
- package/react/Viewer/ViewerContainer.jsx +88 -0
- package/react/Viewer/ViewerInformationsWrapper.jsx +61 -0
- package/react/Viewer/ViewerWithCustomPanelAndFooter.jsx +52 -0
- package/react/Viewer/index.jsx +8 -310
- package/react/Viewer/proptypes.js +9 -0
- package/react/__snapshots__/examples.spec.jsx.snap +0 -11
- package/react/examples.spec.jsx +0 -1
- package/react/hooks/useSetFlagshipUi/useSetFlagshipUI.spec.ts +122 -31
- package/react/hooks/useSetFlagshipUi/useSetFlagshipUI.ts +7 -5
- package/transpiled/react/ActionMenu/index.js +1 -1
- package/transpiled/react/BottomSheet/BottomSheet.js +16 -6
- package/transpiled/react/Dialog/index.js +4 -3
- package/transpiled/react/SelectionBar/index.js +1 -1
- package/transpiled/react/Sidebar/index.js +1 -1
- package/transpiled/react/Viewer/Viewer.js +169 -0
- package/transpiled/react/Viewer/ViewerContainer.js +99 -0
- package/transpiled/react/Viewer/ViewerInformationsWrapper.js +41 -0
- package/transpiled/react/Viewer/ViewerWithCustomPanelAndFooter.js +48 -0
- package/transpiled/react/Viewer/index.js +5 -337
- package/transpiled/react/Viewer/proptypes.js +9 -0
- package/transpiled/react/hooks/useSetFlagshipUi/useSetFlagshipUI.js +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [62.12.0](https://github.com/cozy/cozy-ui/compare/v62.11.0...v62.12.0) (2022-04-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Hide bottom of screen in immersive mode ([65fcc5f](https://github.com/cozy/cozy-ui/commit/65fcc5f))
|
|
7
|
+
* Revert icons to white in immersive mode ([43bc925](https://github.com/cozy/cozy-ui/commit/43bc925))
|
|
8
|
+
* Upgrade cozy-intent and cozy-device-helper ([44904b4](https://github.com/cozy/cozy-ui/commit/44904b4))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Use new caller API in components ([10742b0](https://github.com/cozy/cozy-ui/commit/10742b0))
|
|
14
|
+
|
|
1
15
|
# [62.11.0](https://github.com/cozy/cozy-ui/compare/v62.10.0...v62.11.0) (2022-04-22)
|
|
2
16
|
|
|
3
17
|
|
package/CODEOWNERS
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "62.
|
|
3
|
+
"version": "62.12.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"prebuild:css:kss": "mkdir -p build/styleguide && stylus -C node_modules/normalize.css/normalize.css node_modules/normalize.css/normalize.styl",
|
|
44
44
|
"prebuild:doc:kss": "run-s clean:doc:kss build:css:kss",
|
|
45
45
|
"prepare": "yarn release",
|
|
46
|
-
"prepush": "[[ $(git rev-parse --abbrev-ref HEAD) != 'gh-pages' ]] && yarn lint || true",
|
|
47
46
|
"release": "npm-run-all --parallel sprite palette && yarn build",
|
|
48
47
|
"semantic-release": "semantic-release",
|
|
49
48
|
"sprite": "scripts/make-icon-sprite.sh",
|
|
@@ -92,10 +91,10 @@
|
|
|
92
91
|
"commitlint-config-cozy": "0.6.0",
|
|
93
92
|
"copyfiles": "2.4.1",
|
|
94
93
|
"cozy-client": "27.19.1",
|
|
95
|
-
"cozy-device-helper": "
|
|
94
|
+
"cozy-device-helper": "1.18.0",
|
|
96
95
|
"cozy-doctypes": "^1.69.0",
|
|
97
96
|
"cozy-harvest-lib": "^6.7.3",
|
|
98
|
-
"cozy-intent": "1.
|
|
97
|
+
"cozy-intent": "1.16.1",
|
|
99
98
|
"cozy-sharing": "^3.10.0",
|
|
100
99
|
"cozy-stack-client": "27.19.1",
|
|
101
100
|
"css-loader": "0.28.11",
|
|
@@ -2,6 +2,8 @@ import React, { useState, useEffect, useRef, useMemo } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { BottomSheet as MuiBottomSheet } from 'mui-bottom-sheet'
|
|
4
4
|
|
|
5
|
+
import { flagshipMetadata } from 'cozy-device-helper'
|
|
6
|
+
|
|
5
7
|
import Stack from 'cozy-ui/transpiled/react/Stack'
|
|
6
8
|
import Paper from 'cozy-ui/transpiled/react/Paper'
|
|
7
9
|
|
|
@@ -27,6 +29,15 @@ const makeStyles = ({ isTopPosition }) => ({
|
|
|
27
29
|
},
|
|
28
30
|
stack: {
|
|
29
31
|
backgroundColor: 'var(--defaultBackgroundColor)'
|
|
32
|
+
},
|
|
33
|
+
flagshipImmersive: {
|
|
34
|
+
backgroundColor: 'var(--paperBackgroundColor)',
|
|
35
|
+
bottom: 0,
|
|
36
|
+
content: '',
|
|
37
|
+
height: 'var(--flagship-bottom-height)',
|
|
38
|
+
position: 'fixed',
|
|
39
|
+
width: '100%',
|
|
40
|
+
zIndex: 'var(--zIndex-modal)'
|
|
30
41
|
}
|
|
31
42
|
})
|
|
32
43
|
|
|
@@ -97,18 +108,11 @@ const BottomSheet = ({ toolbarProps, settings, children }) => {
|
|
|
97
108
|
)
|
|
98
109
|
: 0
|
|
99
110
|
|
|
100
|
-
// Will return 0 if the variable is not set
|
|
101
|
-
const flagshipBottomOffset = Number(
|
|
102
|
-
getComputedStyle(document.body)
|
|
103
|
-
.getPropertyValue('--flagship-bottom-height')
|
|
104
|
-
.replace('px', '')
|
|
105
|
-
)
|
|
106
|
-
|
|
107
111
|
const minHeight =
|
|
108
112
|
headerRef.current.offsetHeight +
|
|
109
113
|
actionButtonsHeight +
|
|
110
114
|
actionButtonsBottomMargin +
|
|
111
|
-
|
|
115
|
+
(flagshipMetadata.navbarHeight || 0)
|
|
112
116
|
|
|
113
117
|
// Used so that the bottomSheet can be opened to the top,
|
|
114
118
|
// without stopping at the content height
|
|
@@ -149,43 +153,47 @@ const BottomSheet = ({ toolbarProps, settings, children }) => {
|
|
|
149
153
|
})
|
|
150
154
|
|
|
151
155
|
return (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
156
|
+
<>
|
|
157
|
+
{flagshipMetadata.immersive && <span style={styles.flagshipImmersive} />}
|
|
158
|
+
|
|
159
|
+
<MuiBottomSheet
|
|
160
|
+
peekHeights={peekHeights}
|
|
161
|
+
defaultHeight={initPos}
|
|
162
|
+
backdrop={false}
|
|
163
|
+
fullHeight={false}
|
|
164
|
+
onIndexChange={snapIndex => handleOnIndexChange(snapIndex)}
|
|
165
|
+
styles={{ root: styles.root }}
|
|
166
|
+
threshold={0}
|
|
167
|
+
// springConfig doc : https://docs.pmnd.rs/react-spring/common/configs
|
|
168
|
+
springConfig={{
|
|
169
|
+
tension: defaultBottomSheetSpringConfig.tension,
|
|
170
|
+
friction: defaultBottomSheetSpringConfig.friction,
|
|
171
|
+
clamp: defaultBottomSheetSpringConfig.clamp
|
|
172
|
+
}}
|
|
173
|
+
disabledClosing={true}
|
|
174
|
+
snapPointSeekerMode="next"
|
|
175
|
+
>
|
|
176
|
+
<div ref={innerContentRef}>
|
|
177
|
+
<Paper
|
|
178
|
+
data-testid="bottomSheet-header"
|
|
179
|
+
className="u-w-100 u-h-2-half u-pos-relative u-flex u-flex-items-center u-flex-justify-center"
|
|
180
|
+
ref={headerRef}
|
|
181
|
+
elevation={0}
|
|
182
|
+
square
|
|
183
|
+
>
|
|
184
|
+
<div style={styles.indicator} />
|
|
185
|
+
</Paper>
|
|
186
|
+
<Stack
|
|
187
|
+
style={styles.stack}
|
|
188
|
+
className="u-flex u-flex-column u-ov-hidden"
|
|
189
|
+
spacing="s"
|
|
190
|
+
>
|
|
191
|
+
{overriddenChildren}
|
|
192
|
+
</Stack>
|
|
193
|
+
</div>
|
|
194
|
+
<div style={{ height: bottomSpacerHeight }} />
|
|
195
|
+
</MuiBottomSheet>
|
|
196
|
+
</>
|
|
189
197
|
)
|
|
190
198
|
}
|
|
191
199
|
|
package/react/Dialog/index.jsx
CHANGED
|
@@ -3,6 +3,8 @@ import { RemoveScroll } from 'react-remove-scroll'
|
|
|
3
3
|
import { default as MUIDialog } from '@material-ui/core/Dialog'
|
|
4
4
|
import { useTheme } from '@material-ui/core'
|
|
5
5
|
|
|
6
|
+
import { flagshipMetadata } from 'cozy-device-helper'
|
|
7
|
+
|
|
6
8
|
import useBreakpoints from '../hooks/useBreakpoints'
|
|
7
9
|
import { useCozyTheme } from '../CozyTheme'
|
|
8
10
|
import themesStyles from '../../stylus/settings/palette.styl'
|
|
@@ -47,16 +49,18 @@ const Dialog = props => {
|
|
|
47
49
|
},
|
|
48
50
|
{
|
|
49
51
|
bottomBackground: theme.palette.background[sidebar ? 'default' : 'paper'],
|
|
50
|
-
bottomTheme: 'dark',
|
|
52
|
+
bottomTheme: flagshipMetadata.immersive ? 'light' : 'dark',
|
|
51
53
|
bottomOverlay: 'transparent',
|
|
52
54
|
topOverlay: 'transparent',
|
|
53
55
|
topBackground:
|
|
54
56
|
cozBar && getComputedStyle(cozBar).getPropertyValue('background-color'),
|
|
55
57
|
topTheme:
|
|
56
|
-
|
|
58
|
+
flagshipMetadata.immersive ||
|
|
59
|
+
(cozBar && cozBar.classList.contains('coz-theme-primary'))
|
|
57
60
|
? 'light'
|
|
58
61
|
: 'dark'
|
|
59
|
-
}
|
|
62
|
+
},
|
|
63
|
+
'cozy-ui/Dialog'
|
|
60
64
|
)
|
|
61
65
|
|
|
62
66
|
return (
|
|
@@ -66,10 +66,14 @@ const SelectionBar = ({ actions, selected, hideSelectionBar }) => {
|
|
|
66
66
|
return () =>
|
|
67
67
|
webviewIntent &&
|
|
68
68
|
theme &&
|
|
69
|
-
webviewIntent.call(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
webviewIntent.call(
|
|
70
|
+
'setFlagshipUI',
|
|
71
|
+
{
|
|
72
|
+
bottomBackground: theme.palette.background.default,
|
|
73
|
+
bottomTheme: 'dark'
|
|
74
|
+
},
|
|
75
|
+
'cozy-ui/SelectionBar'
|
|
76
|
+
)
|
|
73
77
|
// TODO: validate the deps are correct
|
|
74
78
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
79
|
}, [selectedCount, webviewIntent])
|
package/react/Sidebar/index.jsx
CHANGED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { Component } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import { FileDoctype } from '../proptypes'
|
|
5
|
+
|
|
6
|
+
import ViewerControls from './ViewerControls'
|
|
7
|
+
import ViewerByFile from './ViewerByFile'
|
|
8
|
+
import { toolbarPropsPropType } from './index'
|
|
9
|
+
|
|
10
|
+
const KEY_CODE_LEFT = 37
|
|
11
|
+
const KEY_CODE_RIGHT = 39
|
|
12
|
+
const KEY_CODE_ESCAPE = 27
|
|
13
|
+
|
|
14
|
+
class Viewer extends Component {
|
|
15
|
+
constructor() {
|
|
16
|
+
super()
|
|
17
|
+
}
|
|
18
|
+
componentDidMount() {
|
|
19
|
+
document.addEventListener('keyup', this.onKeyUp, false)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
componentWillUnmount() {
|
|
23
|
+
document.removeEventListener('keyup', this.onKeyUp, false)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
onKeyUp = e => {
|
|
27
|
+
if (e.keyCode === KEY_CODE_LEFT) this.onPrevious()
|
|
28
|
+
else if (e.keyCode === KEY_CODE_RIGHT) this.onNext()
|
|
29
|
+
else if (e.keyCode === KEY_CODE_ESCAPE) this.onClose()
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
onNext = () => {
|
|
33
|
+
const { files, currentIndex } = this.props
|
|
34
|
+
if (currentIndex === files.length - 1) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const nextIndex = currentIndex + 1
|
|
38
|
+
const nextFile = files[nextIndex]
|
|
39
|
+
this.onChange(nextFile, nextIndex)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
onPrevious = () => {
|
|
43
|
+
const { files, currentIndex } = this.props
|
|
44
|
+
if (currentIndex === 0) {
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
const prevIndex = currentIndex - 1
|
|
48
|
+
const prevFile = files[prevIndex]
|
|
49
|
+
this.onChange(prevFile, prevIndex)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
onClose = () => {
|
|
53
|
+
if (this.props.onCloseRequest) {
|
|
54
|
+
this.props.onCloseRequest()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
onChange(nextFile, nextIndex) {
|
|
59
|
+
if (this.props.onChangeRequest) {
|
|
60
|
+
this.props.onChangeRequest(nextFile, nextIndex)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
render() {
|
|
65
|
+
const {
|
|
66
|
+
currentFile,
|
|
67
|
+
hasPrevious,
|
|
68
|
+
hasNext,
|
|
69
|
+
toolbarProps,
|
|
70
|
+
toolbarRef,
|
|
71
|
+
showNavigation,
|
|
72
|
+
renderFallbackExtraContent,
|
|
73
|
+
validForPanel,
|
|
74
|
+
onlyOfficeProps
|
|
75
|
+
} = this.props
|
|
76
|
+
|
|
77
|
+
// this `expanded` property makes the next/previous controls cover the displayed image
|
|
78
|
+
const expanded = currentFile && currentFile.class === 'image'
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
<ViewerControls
|
|
83
|
+
file={currentFile}
|
|
84
|
+
onClose={this.onClose}
|
|
85
|
+
hasPrevious={hasPrevious}
|
|
86
|
+
hasNext={hasNext}
|
|
87
|
+
onPrevious={this.onPrevious}
|
|
88
|
+
onNext={this.onNext}
|
|
89
|
+
expanded={expanded}
|
|
90
|
+
toolbarProps={{ ...toolbarProps, toolbarRef }}
|
|
91
|
+
showNavigation={showNavigation}
|
|
92
|
+
showInfoPanel={validForPanel}
|
|
93
|
+
>
|
|
94
|
+
<ViewerByFile
|
|
95
|
+
file={currentFile}
|
|
96
|
+
onClose={this.onClose}
|
|
97
|
+
renderFallbackExtraContent={renderFallbackExtraContent}
|
|
98
|
+
onlyOfficeProps={onlyOfficeProps}
|
|
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
|
+
toolbarProps: PropTypes.shape(toolbarPropsPropType),
|
|
116
|
+
toolbarRef: PropTypes.object,
|
|
117
|
+
/** Whether to show left and right arrows to navigate between files */
|
|
118
|
+
showNavigation: PropTypes.bool,
|
|
119
|
+
/** A render prop that is called when a file can't be displayed */
|
|
120
|
+
renderFallbackExtraContent: PropTypes.func,
|
|
121
|
+
/** Used to open an Only Office file */
|
|
122
|
+
onlyOfficeProps: PropTypes.shape({
|
|
123
|
+
/** Whether Only Office is enabled on the server */
|
|
124
|
+
isEnabled: PropTypes.bool,
|
|
125
|
+
/** To open the Only Office file */
|
|
126
|
+
opener: PropTypes.func
|
|
127
|
+
}),
|
|
128
|
+
validForPanel: PropTypes.bool
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default Viewer
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { createRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
|
|
4
|
+
import useBreakpoints from '../hooks/useBreakpoints'
|
|
5
|
+
import { FileDoctype } from '../proptypes'
|
|
6
|
+
|
|
7
|
+
import { toolbarPropsPropType } from './proptypes'
|
|
8
|
+
import { isValidForPanel } from './helpers'
|
|
9
|
+
import ViewerWrapper from './ViewerWrapper'
|
|
10
|
+
import Viewer from './Viewer'
|
|
11
|
+
import ViewerInformationsWrapper from './ViewerInformationsWrapper'
|
|
12
|
+
|
|
13
|
+
const ViewerContainer = props => {
|
|
14
|
+
const {
|
|
15
|
+
className,
|
|
16
|
+
disableFooter,
|
|
17
|
+
disablePanel,
|
|
18
|
+
disableSharing,
|
|
19
|
+
...rest
|
|
20
|
+
} = props
|
|
21
|
+
const { currentIndex, files } = props
|
|
22
|
+
const toolbarRef = createRef()
|
|
23
|
+
const { isDesktop } = useBreakpoints()
|
|
24
|
+
const currentFile = files[currentIndex]
|
|
25
|
+
const fileCount = files.length
|
|
26
|
+
const hasPrevious = currentIndex > 0
|
|
27
|
+
const hasNext = currentIndex < fileCount - 1
|
|
28
|
+
const validForPanel =
|
|
29
|
+
isValidForPanel({ file: currentFile }) && isDesktop && !disablePanel
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<ViewerWrapper className={className}>
|
|
33
|
+
<Viewer
|
|
34
|
+
{...rest}
|
|
35
|
+
currentFile={currentFile}
|
|
36
|
+
hasPrevious={hasPrevious}
|
|
37
|
+
hasNext={hasNext}
|
|
38
|
+
validForPanel={validForPanel}
|
|
39
|
+
toolbarRef={toolbarRef}
|
|
40
|
+
/>
|
|
41
|
+
<ViewerInformationsWrapper
|
|
42
|
+
disableFooter={disableFooter}
|
|
43
|
+
disableSharing={disableSharing}
|
|
44
|
+
validForPanel={validForPanel}
|
|
45
|
+
currentFile={currentFile}
|
|
46
|
+
toolbarRef={toolbarRef}
|
|
47
|
+
/>
|
|
48
|
+
</ViewerWrapper>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ViewerContainer.propTypes = {
|
|
53
|
+
/** One or more `io.cozy.files` to display */
|
|
54
|
+
files: PropTypes.arrayOf(FileDoctype).isRequired,
|
|
55
|
+
/** Index of the file to show */
|
|
56
|
+
currentIndex: PropTypes.number,
|
|
57
|
+
className: PropTypes.string,
|
|
58
|
+
/** Called when the user wants to leave the Viewer */
|
|
59
|
+
onCloseRequest: PropTypes.func,
|
|
60
|
+
/** Called with (nextFile, nextIndex) when the user requests to navigate to another file */
|
|
61
|
+
onChangeRequest: PropTypes.func,
|
|
62
|
+
toolbarProps: PropTypes.shape(toolbarPropsPropType),
|
|
63
|
+
/** Whether to show left and right arrows to navigate between files */
|
|
64
|
+
showNavigation: PropTypes.bool,
|
|
65
|
+
/** A render prop that is called when a file can't be displayed */
|
|
66
|
+
renderFallbackExtraContent: PropTypes.func,
|
|
67
|
+
/** Used to open an Only Office file */
|
|
68
|
+
onlyOfficeProps: PropTypes.shape({
|
|
69
|
+
/** Whether Only Office is enabled on the server */
|
|
70
|
+
isEnabled: PropTypes.bool,
|
|
71
|
+
/** To open the Only Office file */
|
|
72
|
+
opener: PropTypes.func
|
|
73
|
+
}),
|
|
74
|
+
/** Show/Hide the panel containing more information about the file only on Desktop */
|
|
75
|
+
disablePanel: PropTypes.bool,
|
|
76
|
+
/** Show/Hide the panel containing more information about the file only on Phone & Tablet devices */
|
|
77
|
+
disableFooter: PropTypes.bool,
|
|
78
|
+
/** Show/Hide cozy share button */
|
|
79
|
+
disableSharing: PropTypes.bool
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ViewerContainer.defaultProps = {
|
|
83
|
+
currentIndex: 0,
|
|
84
|
+
toolbarProps: { showToolbar: true, showClose: true },
|
|
85
|
+
showNavigation: true
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default ViewerContainer
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { useTheme } from '@material-ui/core'
|
|
4
|
+
|
|
5
|
+
import { FileDoctype } from '../proptypes'
|
|
6
|
+
|
|
7
|
+
import InformationPanel from './InformationPanel'
|
|
8
|
+
import Footer from './Footer'
|
|
9
|
+
import PanelContent from './Panel/PanelContent'
|
|
10
|
+
import FooterContent from './Footer/FooterContent'
|
|
11
|
+
import { useSetFlagshipUI } from '../hooks/useSetFlagshipUi/useSetFlagshipUI'
|
|
12
|
+
|
|
13
|
+
const ViewerInformationsWrapper = ({
|
|
14
|
+
currentFile,
|
|
15
|
+
disableFooter,
|
|
16
|
+
disableSharing,
|
|
17
|
+
validForPanel,
|
|
18
|
+
toolbarRef
|
|
19
|
+
}) => {
|
|
20
|
+
const theme = useTheme()
|
|
21
|
+
const sidebar = document.querySelector('[class*="sidebar"]')
|
|
22
|
+
|
|
23
|
+
useSetFlagshipUI(
|
|
24
|
+
{
|
|
25
|
+
bottomBackground: theme.palette.background.paper,
|
|
26
|
+
bottomTheme: 'dark'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
bottomBackground: theme.palette.background[sidebar ? 'default' : 'paper']
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
{!disableFooter && (
|
|
36
|
+
<Footer>
|
|
37
|
+
<FooterContent
|
|
38
|
+
file={currentFile}
|
|
39
|
+
toolbarRef={toolbarRef}
|
|
40
|
+
disableSharing={disableSharing}
|
|
41
|
+
/>
|
|
42
|
+
</Footer>
|
|
43
|
+
)}
|
|
44
|
+
{validForPanel && (
|
|
45
|
+
<InformationPanel>
|
|
46
|
+
<PanelContent file={currentFile} />
|
|
47
|
+
</InformationPanel>
|
|
48
|
+
)}
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
ViewerInformationsWrapper.propTypes = {
|
|
54
|
+
currentFile: FileDoctype.isRequired,
|
|
55
|
+
disableFooter: PropTypes.bool,
|
|
56
|
+
disableSharing: PropTypes.bool,
|
|
57
|
+
validForPanel: PropTypes.bool,
|
|
58
|
+
toolbarRef: PropTypes.object
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default ViewerInformationsWrapper
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { createRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import useBreakpoints from '../hooks/useBreakpoints'
|
|
4
|
+
|
|
5
|
+
import ViewerWrapper from './ViewerWrapper'
|
|
6
|
+
import InformationPanel from './InformationPanel'
|
|
7
|
+
import Footer from './Footer'
|
|
8
|
+
import Viewer from './Viewer'
|
|
9
|
+
|
|
10
|
+
const ViewerWithCustomPanelAndFooter = props => {
|
|
11
|
+
console.warn(
|
|
12
|
+
'Warning: Please do not use the "ViewerWithCustomPanelAndFooter" Component, replace it with the default export component'
|
|
13
|
+
)
|
|
14
|
+
const { footerProps, panelInfoProps, ...rest } = props
|
|
15
|
+
const { files, currentIndex } = props
|
|
16
|
+
const fileCount = files.length
|
|
17
|
+
const hasPrevious = currentIndex > 0
|
|
18
|
+
const hasNext = currentIndex < fileCount - 1
|
|
19
|
+
const { isDesktop } = useBreakpoints()
|
|
20
|
+
const toolbarRef = createRef()
|
|
21
|
+
const currentFile = files[currentIndex]
|
|
22
|
+
|
|
23
|
+
const showInfoPanel =
|
|
24
|
+
isDesktop &&
|
|
25
|
+
panelInfoProps &&
|
|
26
|
+
panelInfoProps.showPanel({ file: currentFile })
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ViewerWrapper>
|
|
30
|
+
<Viewer
|
|
31
|
+
{...rest}
|
|
32
|
+
disablePanel={true}
|
|
33
|
+
disableFooter={true}
|
|
34
|
+
currentFile={currentFile}
|
|
35
|
+
hasPrevious={hasPrevious}
|
|
36
|
+
hasNext={hasNext}
|
|
37
|
+
validForPanel={showInfoPanel}
|
|
38
|
+
toolbarRef={toolbarRef}
|
|
39
|
+
/>
|
|
40
|
+
<Footer>
|
|
41
|
+
<footerProps.FooterContent file={currentFile} toolbarRef={toolbarRef} />
|
|
42
|
+
</Footer>
|
|
43
|
+
{showInfoPanel && (
|
|
44
|
+
<InformationPanel>
|
|
45
|
+
<panelInfoProps.PanelContent file={currentFile} />
|
|
46
|
+
</InformationPanel>
|
|
47
|
+
)}
|
|
48
|
+
</ViewerWrapper>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default ViewerWithCustomPanelAndFooter
|