cozy-ui 103.11.1 → 104.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 +54 -0
- package/package.json +1 -1
- package/react/Alert/index.jsx +25 -1
- package/react/Empty/Readme.md +1 -1
- package/react/Icon/Readme.md +0 -1
- package/react/Paywall/howto.md +2 -0
- package/react/Viewer/Panel/ActionMenuWrapper.jsx +14 -7
- package/react/Viewer/Readme.md +0 -1
- package/react/Viewer/ViewerContainer.jsx +3 -5
- package/react/Viewer/ViewersByFile/PdfMobileViewer.jsx +34 -35
- package/react/Viewer/ViewersByFile/PdfMobileViewer.spec.jsx +3 -21
- package/react/Viewer/locales/en.json +1 -3
- package/react/Viewer/locales/fr.json +1 -3
- package/react/deprecated/readme.md +1 -1
- package/react/legacy/readme.md +1 -1
- package/react/providers/Alert/Readme.md +41 -4
- package/react/providers/Alert/index.jsx +27 -7
- package/react/providers/Readme.md +1 -1
- package/transpiled/react/Alert/index.js +32 -5
- package/transpiled/react/Viewer/Panel/ActionMenuWrapper.js +15 -5
- package/transpiled/react/Viewer/ViewerContainer.js +3 -4
- package/transpiled/react/Viewer/ViewersByFile/PdfMobileViewer.js +32 -37
- package/transpiled/react/Viewer/hoc/withViewerLocales.js +2 -6
- package/transpiled/react/providers/Alert/index.js +32 -11
- package/react/Viewer/providers/ViewerSnackbarProvider.jsx +0 -64
- package/react/Viewer/snackbar/ViewerSnackbar.jsx +0 -30
- package/transpiled/react/Viewer/providers/ViewerSnackbarProvider.js +0 -73
- package/transpiled/react/Viewer/snackbar/ViewerSnackbar.js +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
# [104.0.0](https://github.com/cozy/cozy-ui/compare/v103.12.0...v104.0.0) (2024-03-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Color & square props are ignored ([c37ad2f](https://github.com/cozy/cozy-ui/commit/c37ad2f)), closes [/github.com/mui/material-ui/blob/bda562b435a70e3e8f6d7fb04581c6816a5ba0c7/packages/material-ui/src/Snackbar/Snackbar.js#L235](https://github.com//github.com/mui/material-ui/blob/bda562b435a70e3e8f6d7fb04581c6816a5ba0c7/packages/material-ui/src/Snackbar/Snackbar.js/issues/L235) [#L193](https://github.com/cozy/cozy-ui/issues/L193)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add typedef to Alert component ([16f2097](https://github.com/cozy/cozy-ui/commit/16f2097))
|
|
12
|
+
* Improve AlertProvider ([723a627](https://github.com/cozy/cozy-ui/commit/723a627))
|
|
13
|
+
* Replace ViewerSnackbarProvider by AlertProvider ([374537a](https://github.com/cozy/cozy-ui/commit/374537a))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* The `showAlert` function returned by the `useAlert` hook changes signature.
|
|
19
|
+
|
|
20
|
+
Also, the `variant` was set to `filled`,
|
|
21
|
+
it now takes the default value of `Alert`, i.e. `standard`.
|
|
22
|
+
|
|
23
|
+
Before:
|
|
24
|
+
```
|
|
25
|
+
const { showAlert } = useAlert()
|
|
26
|
+
showAlert(t('foo.bar'), 'error',)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Now:
|
|
30
|
+
```
|
|
31
|
+
const { showAlert } = useAlert()
|
|
32
|
+
showAlert({ message: t('foo.bar'), severity: 'error' })
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Its options now support Alert component props.
|
|
36
|
+
Example:
|
|
37
|
+
```
|
|
38
|
+
showAlert({
|
|
39
|
+
message: t('foo.bar'),
|
|
40
|
+
severity: 'info',
|
|
41
|
+
icon: [secure],
|
|
42
|
+
color: 'blue',
|
|
43
|
+
square: true
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
# [103.12.0](https://github.com/cozy/cozy-ui/compare/v103.11.1...v103.12.0) (2024-03-07)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* **viewer:** Remove useless locales ([476fe37](https://github.com/cozy/cozy-ui/commit/476fe37))
|
|
53
|
+
* **viewer:** Use pinchend & tap events on mobile for download file ([8f4b2e7](https://github.com/cozy/cozy-ui/commit/8f4b2e7))
|
|
54
|
+
|
|
1
55
|
## [103.11.1](https://github.com/cozy/cozy-ui/compare/v103.11.0...v103.11.1) (2024-03-05)
|
|
2
56
|
|
|
3
57
|
|
package/package.json
CHANGED
package/react/Alert/index.jsx
CHANGED
|
@@ -52,6 +52,7 @@ const Alert = forwardRef(
|
|
|
52
52
|
square,
|
|
53
53
|
action,
|
|
54
54
|
variant,
|
|
55
|
+
style,
|
|
55
56
|
children,
|
|
56
57
|
...props
|
|
57
58
|
},
|
|
@@ -65,10 +66,22 @@ const Alert = forwardRef(
|
|
|
65
66
|
const iconSize = icon?.props?.size || DEFAULT_ICON_SIZE
|
|
66
67
|
const styles = useStyles({ iconSize, block })
|
|
67
68
|
|
|
69
|
+
/*
|
|
70
|
+
When this component is the child of Snackbar, MUI injects a `style` prop
|
|
71
|
+
(https://github.com/mui/material-ui/blob/bda562b435a70e3e8f6d7fb04581c6816a5ba0c7/packages/material-ui/src/Snackbar/Snackbar.js#L235
|
|
72
|
+
=>
|
|
73
|
+
https://github.com/mui/material-ui/blob/1e80616d3dde536227af56d49f91b28f830bd33c/packages/mui-material/src/Grow/Grow.js #L193), our styles are overwritten.
|
|
74
|
+
*/
|
|
75
|
+
const computedStyles = {
|
|
76
|
+
backgroundColor: color,
|
|
77
|
+
borderRadius: square && 0,
|
|
78
|
+
...style
|
|
79
|
+
}
|
|
80
|
+
|
|
68
81
|
return (
|
|
69
82
|
<MuiAlert
|
|
70
83
|
ref={ref}
|
|
71
|
-
style={
|
|
84
|
+
style={computedStyles}
|
|
72
85
|
className={cx(
|
|
73
86
|
className,
|
|
74
87
|
`cozyStyles-${severity}-${variant}`,
|
|
@@ -91,6 +104,17 @@ const Alert = forwardRef(
|
|
|
91
104
|
|
|
92
105
|
Alert.displayName = 'Alert'
|
|
93
106
|
|
|
107
|
+
/**
|
|
108
|
+
* @typedef {Object} AlertProps
|
|
109
|
+
* @property {string} className - Classname of the alert
|
|
110
|
+
* @property {React.FC<PropTypes.InferProps<typeof Icon.propTypes>>|false} icon - Icon component to display in the alert (or false to hide it)
|
|
111
|
+
* @property {'primary'|'secondary'|'success'|'error'|'warning'|'info'} severity - Severity of the alert (default: primary)
|
|
112
|
+
* @property {boolean} block - Block the alert to the full width of its container (default: false)
|
|
113
|
+
* @property {string} color - Background color of the alert
|
|
114
|
+
* @property {boolean} square - Square the alert corners (default: false)
|
|
115
|
+
* @property {'standard'|'outlined'|'filled'} variant - Variant of the alert (default: standard)
|
|
116
|
+
*/
|
|
117
|
+
|
|
94
118
|
export const AlertPropTypes = {
|
|
95
119
|
className: PropTypes.string,
|
|
96
120
|
icon: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]),
|
package/react/Empty/Readme.md
CHANGED
package/react/Icon/Readme.md
CHANGED
|
@@ -7,7 +7,6 @@ to load your SVG (either explicitly or, better, implicitly in your `webpack.conf
|
|
|
7
7
|
|
|
8
8
|
Be aware that Icon forwards unknown props to the underlying `<svg />` element, such as onClick prop.
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
```jsx
|
|
12
11
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
13
12
|
import People from 'cozy-ui/transpiled/react/Icons/People'
|
package/react/Paywall/howto.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
A new variant is essentially a set of translations adapted to a specific context of use.
|
|
4
4
|
|
|
5
5
|
To create a new one, add your translation to the `src/react/Paywall/locales` directory. The translations for each case (default, premium or public) are grouped together under the name of your variant. A case includes a title, content and a label for the action.
|
|
6
|
+
|
|
6
7
|
```static
|
|
7
8
|
"variantNamePaywall": {
|
|
8
9
|
"premium": {
|
|
@@ -15,6 +16,7 @@ To create a new one, add your translation to the `src/react/Paywall/locales` dir
|
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
Next, we create a new component returning the `Paywall`, specifying the name of the new variant. You can also use `contentInterpolation` to insert variables into the content translation.
|
|
19
|
+
|
|
18
20
|
```js static
|
|
19
21
|
<Paywall
|
|
20
22
|
variant="variantName"
|
|
@@ -5,7 +5,7 @@ import { useAppLinkWithStoreFallback, useClient } from 'cozy-client'
|
|
|
5
5
|
|
|
6
6
|
import useBreakpoints from '../../providers/Breakpoints'
|
|
7
7
|
import { useI18n } from '../../providers/I18n'
|
|
8
|
-
import
|
|
8
|
+
import { useAlert } from '../../providers/Alert'
|
|
9
9
|
import {
|
|
10
10
|
buildEditAttributePath,
|
|
11
11
|
isEditableAttribute,
|
|
@@ -22,7 +22,7 @@ const ActionMenuWrapper = forwardRef(({ onClose, file, optionFile }, ref) => {
|
|
|
22
22
|
const editPathByModelProps = useActionMenuContext()
|
|
23
23
|
const { isMobile } = useBreakpoints()
|
|
24
24
|
const { t } = useI18n()
|
|
25
|
-
const {
|
|
25
|
+
const { showAlert } = useAlert()
|
|
26
26
|
const client = useClient()
|
|
27
27
|
|
|
28
28
|
const currentModel = getCurrentModel(name)
|
|
@@ -42,12 +42,19 @@ const ActionMenuWrapper = forwardRef(({ onClose, file, optionFile }, ref) => {
|
|
|
42
42
|
const handleCopy = async () => {
|
|
43
43
|
try {
|
|
44
44
|
await navigator.clipboard.writeText(value)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
showAlert({
|
|
46
|
+
message: t(`Viewer.snackbar.copiedToClipboard.success`),
|
|
47
|
+
severity: 'success',
|
|
48
|
+
variant: 'filled',
|
|
49
|
+
icon: false
|
|
50
|
+
})
|
|
49
51
|
} catch (error) {
|
|
50
|
-
|
|
52
|
+
showAlert({
|
|
53
|
+
message: t(`Viewer.snackbar.copiedToClipboard.error`),
|
|
54
|
+
severity: 'error',
|
|
55
|
+
variant: 'filled',
|
|
56
|
+
icon: false
|
|
57
|
+
})
|
|
51
58
|
}
|
|
52
59
|
onClose()
|
|
53
60
|
}
|
package/react/Viewer/Readme.md
CHANGED
|
@@ -38,7 +38,6 @@ The `Viewer` can display an **information panel** to show additional information
|
|
|
38
38
|
* **showClose** : `<boolean>` – Whether to show close button in toolbar
|
|
39
39
|
* **showFilePath** : `<boolean>` – Whether to show file path below his name
|
|
40
40
|
|
|
41
|
-
|
|
42
41
|
### Demo
|
|
43
42
|
|
|
44
43
|
```jsx
|
|
@@ -12,8 +12,7 @@ import { isValidForPanel } from './helpers'
|
|
|
12
12
|
import Viewer from './Viewer'
|
|
13
13
|
import ViewerInformationsWrapper from './ViewerInformationsWrapper'
|
|
14
14
|
import EncryptedProvider from './providers/EncryptedProvider'
|
|
15
|
-
import
|
|
16
|
-
import ViewerSnackbar from './snackbar/ViewerSnackbar'
|
|
15
|
+
import AlertProvider from '../providers/Alert'
|
|
17
16
|
import { ActionMenuProvider } from './providers/ActionMenuProvider'
|
|
18
17
|
|
|
19
18
|
import styles from './styles.styl'
|
|
@@ -49,7 +48,7 @@ const ViewerContainer = props => {
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
|
-
<
|
|
51
|
+
<AlertProvider>
|
|
53
52
|
<ActionMenuProvider editPathByModelProps={editPathByModelProps}>
|
|
54
53
|
<div
|
|
55
54
|
id="viewer-wrapper"
|
|
@@ -76,9 +75,8 @@ const ViewerContainer = props => {
|
|
|
76
75
|
{children}
|
|
77
76
|
</ViewerInformationsWrapper>
|
|
78
77
|
</div>
|
|
79
|
-
<ViewerSnackbar />
|
|
80
78
|
</ActionMenuProvider>
|
|
81
|
-
</
|
|
79
|
+
</AlertProvider>
|
|
82
80
|
)
|
|
83
81
|
}
|
|
84
82
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react'
|
|
1
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
2
3
|
|
|
3
4
|
import { useClient } from 'cozy-client'
|
|
4
|
-
import { openFileWith } from 'cozy-client/dist/models/fsnative'
|
|
5
|
-
import { isMobileApp } from 'cozy-device-helper'
|
|
6
5
|
|
|
7
|
-
import Alerter from '../../deprecated/Alerter'
|
|
8
6
|
import Spinner from '../../Spinner'
|
|
9
|
-
import Button from '../../deprecated/Button'
|
|
10
7
|
import FileImageLoader from '../../FileImageLoader'
|
|
11
8
|
|
|
12
|
-
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
13
9
|
import DownloadButton from '../NoViewer/DownloadButton'
|
|
14
10
|
import NoViewer from '../NoViewer'
|
|
15
11
|
|
|
16
12
|
import styles from './styles.styl'
|
|
13
|
+
import { FileDoctype } from '../../proptypes'
|
|
14
|
+
import { useAlert } from '../../providers/Alert'
|
|
15
|
+
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
17
16
|
|
|
18
17
|
export const PdfMobileViewer = ({ file, url, t, gestures }) => {
|
|
19
18
|
const [loading, setLoading] = useState(true)
|
|
20
19
|
const [error, setError] = useState(false)
|
|
21
20
|
const imgRef = useRef(null)
|
|
21
|
+
const { showAlert } = useAlert()
|
|
22
22
|
|
|
23
23
|
const client = useClient()
|
|
24
24
|
|
|
@@ -31,48 +31,42 @@ export const PdfMobileViewer = ({ file, url, t, gestures }) => {
|
|
|
31
31
|
setLoading(false)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
const handleOnClick = useCallback(
|
|
35
|
+
async file => {
|
|
36
|
+
try {
|
|
37
|
+
await client.collection('io.cozy.files').download(file)
|
|
38
|
+
} catch (error) {
|
|
39
|
+
showAlert({
|
|
40
|
+
message: t('Viewer.error.generic'),
|
|
41
|
+
severity: 'error',
|
|
42
|
+
variant: 'filled',
|
|
43
|
+
icon: false
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
[client, showAlert, t]
|
|
48
|
+
)
|
|
45
49
|
|
|
46
50
|
useEffect(() => {
|
|
47
|
-
if (gestures
|
|
51
|
+
if (gestures) {
|
|
48
52
|
gestures.get('pinch').set({ enable: true })
|
|
49
|
-
gestures.on('tap
|
|
50
|
-
if (
|
|
51
|
-
|
|
53
|
+
gestures.on('pinchend tap', evt => {
|
|
54
|
+
if (evt.tapCount === 1) {
|
|
55
|
+
handleOnClick(file)
|
|
52
56
|
}
|
|
53
57
|
})
|
|
54
58
|
|
|
55
59
|
return () => {
|
|
56
|
-
gestures.off('tap
|
|
60
|
+
gestures.off('pinchend tap')
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
|
-
|
|
60
|
-
}, [gestures])
|
|
63
|
+
}, [client, gestures, file, handleOnClick])
|
|
61
64
|
|
|
62
65
|
if (error) {
|
|
63
66
|
return (
|
|
64
67
|
<NoViewer
|
|
65
68
|
file={file}
|
|
66
|
-
renderFallbackExtraContent={
|
|
67
|
-
isMobileApp()
|
|
68
|
-
? file => (
|
|
69
|
-
<Button
|
|
70
|
-
onClick={() => onFileOpen(file)}
|
|
71
|
-
label={t('Viewer.openWith')}
|
|
72
|
-
/>
|
|
73
|
-
)
|
|
74
|
-
: file => <DownloadButton file={file} />
|
|
75
|
-
}
|
|
69
|
+
renderFallbackExtraContent={file => <DownloadButton file={file} />}
|
|
76
70
|
/>
|
|
77
71
|
)
|
|
78
72
|
}
|
|
@@ -94,7 +88,6 @@ export const PdfMobileViewer = ({ file, url, t, gestures }) => {
|
|
|
94
88
|
alt={file.name}
|
|
95
89
|
src={src}
|
|
96
90
|
onLoad={onImageLoad}
|
|
97
|
-
onClick={() => handleOnClick(file)}
|
|
98
91
|
/>
|
|
99
92
|
)}
|
|
100
93
|
/>
|
|
@@ -103,4 +96,10 @@ export const PdfMobileViewer = ({ file, url, t, gestures }) => {
|
|
|
103
96
|
)
|
|
104
97
|
}
|
|
105
98
|
|
|
99
|
+
PdfMobileViewer.prototype = {
|
|
100
|
+
file: FileDoctype.isRequired,
|
|
101
|
+
url: PropTypes.string,
|
|
102
|
+
gestures: PropTypes.object
|
|
103
|
+
}
|
|
104
|
+
|
|
106
105
|
export default withViewerLocales(PdfMobileViewer)
|
|
@@ -2,7 +2,6 @@ import React from 'react'
|
|
|
2
2
|
import { render, waitFor } from '@testing-library/react'
|
|
3
3
|
|
|
4
4
|
import { CozyProvider, createMockClient } from 'cozy-client'
|
|
5
|
-
import { isMobileApp } from 'cozy-device-helper'
|
|
6
5
|
import logger from 'cozy-logger'
|
|
7
6
|
|
|
8
7
|
import { I18n } from '../../providers/I18n'
|
|
@@ -12,11 +11,6 @@ import { PdfMobileViewer } from './PdfMobileViewer'
|
|
|
12
11
|
|
|
13
12
|
logger.error = logger.warn = jest.fn()
|
|
14
13
|
|
|
15
|
-
jest.mock('cozy-device-helper', () => ({
|
|
16
|
-
...jest.requireActual('cozy-device-helper'),
|
|
17
|
-
isMobileApp: jest.fn()
|
|
18
|
-
}))
|
|
19
|
-
|
|
20
14
|
const client = createMockClient({})
|
|
21
15
|
client.collection = jest.fn(() => ({
|
|
22
16
|
getDownloadLinkById: jest.fn()
|
|
@@ -26,6 +20,9 @@ client.plugins.realtime = {
|
|
|
26
20
|
unsubscribe: jest.fn(),
|
|
27
21
|
unsubscribeAll: jest.fn()
|
|
28
22
|
}
|
|
23
|
+
jest.mock('../../providers/Alert', () => ({
|
|
24
|
+
useAlert: jest.fn().mockReturnValue({ showAlert: jest.fn() })
|
|
25
|
+
}))
|
|
29
26
|
|
|
30
27
|
const file = {
|
|
31
28
|
_id: 'pdf',
|
|
@@ -67,8 +64,6 @@ describe('PdfMobileViewer', () => {
|
|
|
67
64
|
})
|
|
68
65
|
|
|
69
66
|
it('should show "download" button on browser', async () => {
|
|
70
|
-
isMobileApp.mockReturnValue(false)
|
|
71
|
-
|
|
72
67
|
const { root } = setup({ file: fileWithoutLinks })
|
|
73
68
|
const { getByText, queryByRole } = root
|
|
74
69
|
|
|
@@ -78,18 +73,5 @@ describe('PdfMobileViewer', () => {
|
|
|
78
73
|
expect(getByText(file.name))
|
|
79
74
|
})
|
|
80
75
|
})
|
|
81
|
-
|
|
82
|
-
it('should show "open with" button on native app', async () => {
|
|
83
|
-
isMobileApp.mockReturnValue(true)
|
|
84
|
-
|
|
85
|
-
const { root } = setup({ file: fileWithoutLinks })
|
|
86
|
-
const { getByText, queryByRole } = root
|
|
87
|
-
|
|
88
|
-
await waitFor(() => {
|
|
89
|
-
expect(queryByRole('progressbar')).toBeFalsy()
|
|
90
|
-
expect(getByText('Viewer.openWith'))
|
|
91
|
-
expect(getByText(file.name))
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
76
|
})
|
|
95
77
|
})
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"generic": "An error occurred when opening this file, please try again.",
|
|
17
17
|
"missing": "This file is missing",
|
|
18
|
-
"network": "This file could not be loaded. Do you have a working internet connection right now?"
|
|
19
|
-
"noapp": "No application on your device can open this file with mime type: %{fileMime} ",
|
|
20
|
-
"offline": "You should be connected to open this file"
|
|
18
|
+
"network": "This file could not be loaded. Do you have a working internet connection right now?"
|
|
21
19
|
},
|
|
22
20
|
"goto": "Go to %{url}",
|
|
23
21
|
"next": "Next",
|
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"generic": "Une erreur s'est produite lors de l'ouverture de ce fichier, veuillez réessayer.",
|
|
17
17
|
"missing": "Le fichier est manquant",
|
|
18
|
-
"network": "Ce fichier n'a pas pu être chargé. Avez-vous une connexion internet qui fonctionne actuellement ?"
|
|
19
|
-
"noapp": "Aucune application de votre appareil ne peut ouvrir ce fichier avec le type mime : %{fileMime} ",
|
|
20
|
-
"offline": "Vous devez être connecté pour ouvrir ce fichier"
|
|
18
|
+
"network": "Ce fichier n'a pas pu être chargé. Avez-vous une connexion internet qui fonctionne actuellement ?"
|
|
21
19
|
},
|
|
22
20
|
"goto": "Ouvrir %{url}",
|
|
23
21
|
"next": "Suivante",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!-- For styleguidist, a .md file is needed in directories -->
|
|
1
|
+
<!-- For styleguidist, a .md file is needed in directories -->
|
package/react/legacy/readme.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!-- For styleguidist, a .md file is needed in directories -->
|
|
1
|
+
<!-- For styleguidist, a .md file is needed in directories -->
|
|
@@ -3,23 +3,60 @@ import Variants from 'cozy-ui/docs/components/Variants'
|
|
|
3
3
|
import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
4
4
|
import AlertProvider, { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
|
|
5
5
|
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
6
|
+
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
7
|
+
import DeviceLaptopIcon from 'cozy-ui/transpiled/react/Icons/DeviceLaptop'
|
|
6
8
|
|
|
7
|
-
const initialVariants = [{
|
|
9
|
+
const initialVariants = [{
|
|
10
|
+
title: false,
|
|
11
|
+
block: false,
|
|
12
|
+
color: false,
|
|
13
|
+
largeIcon: false,
|
|
14
|
+
noIcon: false,
|
|
15
|
+
square: false,
|
|
16
|
+
filled: false,
|
|
17
|
+
outlined: false,
|
|
18
|
+
close: true
|
|
19
|
+
}]
|
|
8
20
|
|
|
9
21
|
const Component = ({ variant }) => {
|
|
10
22
|
const { showAlert } = useAlert()
|
|
11
23
|
|
|
12
|
-
return
|
|
24
|
+
return (
|
|
25
|
+
<Button
|
|
26
|
+
label="show alert"
|
|
27
|
+
onClick={() =>
|
|
28
|
+
showAlert({
|
|
29
|
+
title: variant.title ? 'Alert title' : undefined,
|
|
30
|
+
severity: 'success',
|
|
31
|
+
message: 'Alert message',
|
|
32
|
+
color: variant.color ? "#EFA82D" : undefined,
|
|
33
|
+
variant: variant.filled
|
|
34
|
+
? 'filled'
|
|
35
|
+
: variant.outlined
|
|
36
|
+
? 'outlined'
|
|
37
|
+
: undefined,
|
|
38
|
+
block: variant.block,
|
|
39
|
+
square: variant.square,
|
|
40
|
+
icon: variant.noIcon
|
|
41
|
+
? false
|
|
42
|
+
: variant.largeIcon
|
|
43
|
+
? <Icon icon={DeviceLaptopIcon} color="var(--errorColor)" size={32} />
|
|
44
|
+
: undefined,
|
|
45
|
+
onClose: variant.close ? () => {} : undefined
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
13
50
|
}
|
|
14
51
|
|
|
15
52
|
;
|
|
16
53
|
|
|
17
54
|
<BreakpointsProvider>
|
|
18
55
|
<AlertProvider>
|
|
19
|
-
<Variants initialVariants={initialVariants}
|
|
56
|
+
<Variants initialVariants={initialVariants}>
|
|
20
57
|
{variant => (
|
|
21
58
|
<>
|
|
22
|
-
<Component variant={
|
|
59
|
+
<Component variant={variant} />
|
|
23
60
|
</>
|
|
24
61
|
)}
|
|
25
62
|
</Variants>
|
|
@@ -2,9 +2,21 @@ import React, { createContext, useState, useContext, useMemo } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import Snackbar from '../../Snackbar'
|
|
4
4
|
import Alert from '../../Alert'
|
|
5
|
+
import AlertTitle from '../../AlertTitle'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('../../Alert').AlertProps & { message: string, title: string }} ShowAlertArgs
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} UseAlertReturn
|
|
12
|
+
* @property {(args: ShowAlertArgs) => void} showAlert
|
|
13
|
+
*/
|
|
5
14
|
|
|
6
15
|
export const AlertContext = createContext()
|
|
7
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @returns {UseAlertReturn}
|
|
19
|
+
*/
|
|
8
20
|
export const useAlert = () => {
|
|
9
21
|
const context = useContext(AlertContext)
|
|
10
22
|
|
|
@@ -14,18 +26,26 @@ export const useAlert = () => {
|
|
|
14
26
|
return context
|
|
15
27
|
}
|
|
16
28
|
|
|
17
|
-
const defaultState = {
|
|
29
|
+
const defaultState = {
|
|
30
|
+
title: '',
|
|
31
|
+
message: '',
|
|
32
|
+
open: false
|
|
33
|
+
}
|
|
18
34
|
const handleClose = (state, setState) => () => {
|
|
19
35
|
return setState({ ...state, open: false })
|
|
20
36
|
}
|
|
21
37
|
|
|
22
38
|
const AlertProvider = ({ children }) => {
|
|
23
39
|
const [state, setState] = useState(defaultState)
|
|
40
|
+
const { open, message, title, ...alertProps } = state
|
|
24
41
|
|
|
25
42
|
const value = useMemo(
|
|
26
43
|
() => ({
|
|
27
|
-
|
|
28
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @param {ShowAlertArgs} args
|
|
46
|
+
*/
|
|
47
|
+
showAlert: args => {
|
|
48
|
+
setState({ open: true, ...args })
|
|
29
49
|
}
|
|
30
50
|
}),
|
|
31
51
|
[]
|
|
@@ -34,14 +54,14 @@ const AlertProvider = ({ children }) => {
|
|
|
34
54
|
return (
|
|
35
55
|
<AlertContext.Provider value={value}>
|
|
36
56
|
{children}
|
|
37
|
-
<Snackbar open={
|
|
57
|
+
<Snackbar open={open} onClose={handleClose(state, setState)}>
|
|
38
58
|
<Alert
|
|
39
|
-
variant="filled"
|
|
40
59
|
elevation={6}
|
|
41
|
-
severity={state.severity}
|
|
42
60
|
onClose={handleClose(state, setState)}
|
|
61
|
+
{...alertProps}
|
|
43
62
|
>
|
|
44
|
-
{
|
|
63
|
+
{title && <AlertTitle>{title}</AlertTitle>}
|
|
64
|
+
{message}
|
|
45
65
|
</Alert>
|
|
46
66
|
</Snackbar>
|
|
47
67
|
</AlertContext.Provider>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!-- For styleguidist, a .md file is needed in directories -->
|
|
1
|
+
<!-- For styleguidist, a .md file is needed in directories -->
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "classes", "icon", "severity", "block", "color", "square", "action", "variant", "children"];
|
|
4
|
+
var _excluded = ["className", "classes", "icon", "severity", "block", "color", "square", "action", "variant", "style", "children"];
|
|
5
|
+
|
|
6
|
+
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; }
|
|
7
|
+
|
|
8
|
+
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) { _defineProperty(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; }
|
|
9
|
+
|
|
4
10
|
import React, { forwardRef } from 'react';
|
|
5
11
|
import PropTypes from 'prop-types';
|
|
6
12
|
import cx from 'classnames';
|
|
@@ -60,6 +66,7 @@ var Alert = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
60
66
|
square = _ref2.square,
|
|
61
67
|
action = _ref2.action,
|
|
62
68
|
variant = _ref2.variant,
|
|
69
|
+
style = _ref2.style,
|
|
63
70
|
children = _ref2.children,
|
|
64
71
|
props = _objectWithoutProperties(_ref2, _excluded);
|
|
65
72
|
|
|
@@ -71,12 +78,21 @@ var Alert = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
71
78
|
iconSize: iconSize,
|
|
72
79
|
block: block
|
|
73
80
|
});
|
|
81
|
+
/*
|
|
82
|
+
When this component is the child of Snackbar, MUI injects a `style` prop
|
|
83
|
+
(https://github.com/mui/material-ui/blob/bda562b435a70e3e8f6d7fb04581c6816a5ba0c7/packages/material-ui/src/Snackbar/Snackbar.js#L235
|
|
84
|
+
=>
|
|
85
|
+
https://github.com/mui/material-ui/blob/1e80616d3dde536227af56d49f91b28f830bd33c/packages/mui-material/src/Grow/Grow.js #L193), our styles are overwritten.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
var computedStyles = _objectSpread({
|
|
89
|
+
backgroundColor: color,
|
|
90
|
+
borderRadius: square && 0
|
|
91
|
+
}, style);
|
|
92
|
+
|
|
74
93
|
return /*#__PURE__*/React.createElement(MuiAlert, _extends({
|
|
75
94
|
ref: ref,
|
|
76
|
-
style:
|
|
77
|
-
backgroundColor: color,
|
|
78
|
-
borderRadius: square && 0
|
|
79
|
-
},
|
|
95
|
+
style: computedStyles,
|
|
80
96
|
className: cx(className, "cozyStyles-".concat(severity, "-").concat(variant), {
|
|
81
97
|
block: block
|
|
82
98
|
}, {
|
|
@@ -91,6 +107,17 @@ var Alert = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
91
107
|
}, props), children);
|
|
92
108
|
});
|
|
93
109
|
Alert.displayName = 'Alert';
|
|
110
|
+
/**
|
|
111
|
+
* @typedef {Object} AlertProps
|
|
112
|
+
* @property {string} className - Classname of the alert
|
|
113
|
+
* @property {React.FC<PropTypes.InferProps<typeof Icon.propTypes>>|false} icon - Icon component to display in the alert (or false to hide it)
|
|
114
|
+
* @property {'primary'|'secondary'|'success'|'error'|'warning'|'info'} severity - Severity of the alert (default: primary)
|
|
115
|
+
* @property {boolean} block - Block the alert to the full width of its container (default: false)
|
|
116
|
+
* @property {string} color - Background color of the alert
|
|
117
|
+
* @property {boolean} square - Square the alert corners (default: false)
|
|
118
|
+
* @property {'standard'|'outlined'|'filled'} variant - Variant of the alert (default: standard)
|
|
119
|
+
*/
|
|
120
|
+
|
|
94
121
|
export var AlertPropTypes = {
|
|
95
122
|
className: PropTypes.string,
|
|
96
123
|
icon: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]),
|
|
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import { useAppLinkWithStoreFallback, useClient } from 'cozy-client';
|
|
6
6
|
import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
7
7
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
8
|
-
import
|
|
8
|
+
import { useAlert } from "cozy-ui/transpiled/react/providers/Alert";
|
|
9
9
|
import { buildEditAttributePath, isEditableAttribute, getCurrentModel } from "cozy-ui/transpiled/react/Viewer/helpers";
|
|
10
10
|
import useActionMenuContext from "cozy-ui/transpiled/react/Viewer/providers/ActionMenuProvider";
|
|
11
11
|
import ActionMenuMobile from "cozy-ui/transpiled/react/Viewer/Panel/ActionMenuMobile";
|
|
@@ -25,8 +25,8 @@ var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
25
25
|
var _useI18n = useI18n(),
|
|
26
26
|
t = _useI18n.t;
|
|
27
27
|
|
|
28
|
-
var
|
|
29
|
-
|
|
28
|
+
var _useAlert = useAlert(),
|
|
29
|
+
showAlert = _useAlert.showAlert;
|
|
30
30
|
|
|
31
31
|
var client = useClient();
|
|
32
32
|
var currentModel = getCurrentModel(name);
|
|
@@ -49,14 +49,24 @@ var ActionMenuWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
49
49
|
return navigator.clipboard.writeText(value);
|
|
50
50
|
|
|
51
51
|
case 3:
|
|
52
|
-
|
|
52
|
+
showAlert({
|
|
53
|
+
message: t("Viewer.snackbar.copiedToClipboard.success"),
|
|
54
|
+
severity: 'success',
|
|
55
|
+
variant: 'filled',
|
|
56
|
+
icon: false
|
|
57
|
+
});
|
|
53
58
|
_context.next = 9;
|
|
54
59
|
break;
|
|
55
60
|
|
|
56
61
|
case 6:
|
|
57
62
|
_context.prev = 6;
|
|
58
63
|
_context.t0 = _context["catch"](0);
|
|
59
|
-
|
|
64
|
+
showAlert({
|
|
65
|
+
message: t("Viewer.snackbar.copiedToClipboard.error"),
|
|
66
|
+
severity: 'error',
|
|
67
|
+
variant: 'filled',
|
|
68
|
+
icon: false
|
|
69
|
+
});
|
|
60
70
|
|
|
61
71
|
case 9:
|
|
62
72
|
onClose();
|
|
@@ -20,8 +20,7 @@ import { isValidForPanel } from "cozy-ui/transpiled/react/Viewer/helpers";
|
|
|
20
20
|
import Viewer from "cozy-ui/transpiled/react/Viewer/Viewer";
|
|
21
21
|
import ViewerInformationsWrapper from "cozy-ui/transpiled/react/Viewer/ViewerInformationsWrapper";
|
|
22
22
|
import EncryptedProvider from "cozy-ui/transpiled/react/Viewer/providers/EncryptedProvider";
|
|
23
|
-
import
|
|
24
|
-
import ViewerSnackbar from "cozy-ui/transpiled/react/Viewer/snackbar/ViewerSnackbar";
|
|
23
|
+
import AlertProvider from "cozy-ui/transpiled/react/providers/Alert";
|
|
25
24
|
import { ActionMenuProvider } from "cozy-ui/transpiled/react/Viewer/providers/ActionMenuProvider";
|
|
26
25
|
var styles = {
|
|
27
26
|
"viewer-wrapper": "styles__viewer-wrapper___2GIXH",
|
|
@@ -61,7 +60,7 @@ var ViewerContainer = function ViewerContainer(props) {
|
|
|
61
60
|
}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.toolbarProps)
|
|
62
61
|
});
|
|
63
62
|
|
|
64
|
-
return /*#__PURE__*/React.createElement(
|
|
63
|
+
return /*#__PURE__*/React.createElement(AlertProvider, null, /*#__PURE__*/React.createElement(ActionMenuProvider, {
|
|
65
64
|
editPathByModelProps: editPathByModelProps
|
|
66
65
|
}, /*#__PURE__*/React.createElement("div", {
|
|
67
66
|
id: "viewer-wrapper",
|
|
@@ -81,7 +80,7 @@ var ViewerContainer = function ViewerContainer(props) {
|
|
|
81
80
|
validForPanel: validForPanel,
|
|
82
81
|
currentFile: currentFile,
|
|
83
82
|
toolbarRef: toolbarRef
|
|
84
|
-
}, children))
|
|
83
|
+
}, children))));
|
|
85
84
|
};
|
|
86
85
|
|
|
87
86
|
ViewerContainer.propTypes = {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
4
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import { useClient } from 'cozy-client';
|
|
6
|
-
import { openFileWith } from 'cozy-client/dist/models/fsnative';
|
|
7
|
-
import { isMobileApp } from 'cozy-device-helper';
|
|
8
|
-
import Alerter from "cozy-ui/transpiled/react/deprecated/Alerter";
|
|
9
7
|
import Spinner from "cozy-ui/transpiled/react/Spinner";
|
|
10
|
-
import Button from "cozy-ui/transpiled/react/deprecated/Button";
|
|
11
8
|
import FileImageLoader from "cozy-ui/transpiled/react/FileImageLoader";
|
|
12
|
-
import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/hoc/withViewerLocales";
|
|
13
9
|
import DownloadButton from "cozy-ui/transpiled/react/Viewer/NoViewer/DownloadButton";
|
|
14
10
|
import NoViewer from "cozy-ui/transpiled/react/Viewer/NoViewer";
|
|
15
11
|
var styles = {
|
|
@@ -28,6 +24,9 @@ var styles = {
|
|
|
28
24
|
"viewer-pdfMobile": "styles__viewer-pdfMobile___25FPg",
|
|
29
25
|
"viewer-pdfMobile--image": "styles__viewer-pdfMobile--image___3gpFL"
|
|
30
26
|
};
|
|
27
|
+
import { FileDoctype } from "cozy-ui/transpiled/react/proptypes";
|
|
28
|
+
import { useAlert } from "cozy-ui/transpiled/react/providers/Alert";
|
|
29
|
+
import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/hoc/withViewerLocales";
|
|
31
30
|
export var PdfMobileViewer = function PdfMobileViewer(_ref) {
|
|
32
31
|
var file = _ref.file,
|
|
33
32
|
url = _ref.url,
|
|
@@ -45,6 +44,10 @@ export var PdfMobileViewer = function PdfMobileViewer(_ref) {
|
|
|
45
44
|
setError = _useState4[1];
|
|
46
45
|
|
|
47
46
|
var imgRef = useRef(null);
|
|
47
|
+
|
|
48
|
+
var _useAlert = useAlert(),
|
|
49
|
+
showAlert = _useAlert.showAlert;
|
|
50
|
+
|
|
48
51
|
var client = useClient();
|
|
49
52
|
|
|
50
53
|
var onImageError = function onImageError() {
|
|
@@ -56,7 +59,7 @@ export var PdfMobileViewer = function PdfMobileViewer(_ref) {
|
|
|
56
59
|
setLoading(false);
|
|
57
60
|
};
|
|
58
61
|
|
|
59
|
-
var
|
|
62
|
+
var handleOnClick = useCallback( /*#__PURE__*/function () {
|
|
60
63
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
|
|
61
64
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
62
65
|
while (1) {
|
|
@@ -64,7 +67,7 @@ export var PdfMobileViewer = function PdfMobileViewer(_ref) {
|
|
|
64
67
|
case 0:
|
|
65
68
|
_context.prev = 0;
|
|
66
69
|
_context.next = 3;
|
|
67
|
-
return
|
|
70
|
+
return client.collection('io.cozy.files').download(file);
|
|
68
71
|
|
|
69
72
|
case 3:
|
|
70
73
|
_context.next = 8;
|
|
@@ -73,8 +76,11 @@ export var PdfMobileViewer = function PdfMobileViewer(_ref) {
|
|
|
73
76
|
case 5:
|
|
74
77
|
_context.prev = 5;
|
|
75
78
|
_context.t0 = _context["catch"](0);
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
showAlert({
|
|
80
|
+
message: t('Viewer.error.generic'),
|
|
81
|
+
severity: 'error',
|
|
82
|
+
variant: 'filled',
|
|
83
|
+
icon: false
|
|
78
84
|
});
|
|
79
85
|
|
|
80
86
|
case 8:
|
|
@@ -85,43 +91,30 @@ export var PdfMobileViewer = function PdfMobileViewer(_ref) {
|
|
|
85
91
|
}, _callee, null, [[0, 5]]);
|
|
86
92
|
}));
|
|
87
93
|
|
|
88
|
-
return function
|
|
94
|
+
return function (_x) {
|
|
89
95
|
return _ref2.apply(this, arguments);
|
|
90
96
|
};
|
|
91
|
-
}();
|
|
92
|
-
|
|
93
|
-
var handleOnClick = function handleOnClick(file) {
|
|
94
|
-
!isMobileApp() && client.collection('io.cozy.files').download(file);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
+
}(), [client, showAlert, t]);
|
|
97
98
|
useEffect(function () {
|
|
98
|
-
if (gestures
|
|
99
|
+
if (gestures) {
|
|
99
100
|
gestures.get('pinch').set({
|
|
100
101
|
enable: true
|
|
101
102
|
});
|
|
102
|
-
gestures.on('tap
|
|
103
|
-
if (
|
|
104
|
-
|
|
103
|
+
gestures.on('pinchend tap', function (evt) {
|
|
104
|
+
if (evt.tapCount === 1) {
|
|
105
|
+
handleOnClick(file);
|
|
105
106
|
}
|
|
106
107
|
});
|
|
107
108
|
return function () {
|
|
108
|
-
gestures.off('tap
|
|
109
|
+
gestures.off('pinchend tap');
|
|
109
110
|
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
}, [gestures]);
|
|
111
|
+
}
|
|
112
|
+
}, [client, gestures, file, handleOnClick]);
|
|
113
113
|
|
|
114
114
|
if (error) {
|
|
115
115
|
return /*#__PURE__*/React.createElement(NoViewer, {
|
|
116
116
|
file: file,
|
|
117
|
-
renderFallbackExtraContent:
|
|
118
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
119
|
-
onClick: function onClick() {
|
|
120
|
-
return onFileOpen(file);
|
|
121
|
-
},
|
|
122
|
-
label: t('Viewer.openWith')
|
|
123
|
-
});
|
|
124
|
-
} : function (file) {
|
|
117
|
+
renderFallbackExtraContent: function renderFallbackExtraContent(file) {
|
|
125
118
|
return /*#__PURE__*/React.createElement(DownloadButton, {
|
|
126
119
|
file: file
|
|
127
120
|
});
|
|
@@ -147,12 +140,14 @@ export var PdfMobileViewer = function PdfMobileViewer(_ref) {
|
|
|
147
140
|
className: styles['viewer-pdfMobile--image'],
|
|
148
141
|
alt: file.name,
|
|
149
142
|
src: src,
|
|
150
|
-
onLoad: onImageLoad
|
|
151
|
-
onClick: function onClick() {
|
|
152
|
-
return handleOnClick(file);
|
|
153
|
-
}
|
|
143
|
+
onLoad: onImageLoad
|
|
154
144
|
});
|
|
155
145
|
}
|
|
156
146
|
}));
|
|
157
147
|
};
|
|
148
|
+
PdfMobileViewer.prototype = {
|
|
149
|
+
file: FileDoctype.isRequired,
|
|
150
|
+
url: PropTypes.string,
|
|
151
|
+
gestures: PropTypes.object
|
|
152
|
+
};
|
|
158
153
|
export default withViewerLocales(PdfMobileViewer);
|
|
@@ -16,9 +16,7 @@ var en = {
|
|
|
16
16
|
},
|
|
17
17
|
generic: "An error occurred when opening this file, please try again.",
|
|
18
18
|
missing: "This file is missing",
|
|
19
|
-
network: "This file could not be loaded. Do you have a working internet connection right now?"
|
|
20
|
-
noapp: "No application on your device can open this file with mime type: %{fileMime} ",
|
|
21
|
-
offline: "You should be connected to open this file"
|
|
19
|
+
network: "This file could not be loaded. Do you have a working internet connection right now?"
|
|
22
20
|
},
|
|
23
21
|
goto: "Go to %{url}",
|
|
24
22
|
next: "Next",
|
|
@@ -166,9 +164,7 @@ var fr = {
|
|
|
166
164
|
},
|
|
167
165
|
generic: "Une erreur s'est produite lors de l'ouverture de ce fichier, veuillez r\xE9essayer.",
|
|
168
166
|
missing: "Le fichier est manquant",
|
|
169
|
-
network: "Ce fichier n'a pas pu \xEAtre charg\xE9. Avez-vous une connexion internet qui fonctionne actuellement ?"
|
|
170
|
-
noapp: "Aucune application de votre appareil ne peut ouvrir ce fichier avec le type mime : %{fileMime} ",
|
|
171
|
-
offline: "Vous devez \xEAtre connect\xE9 pour ouvrir ce fichier"
|
|
167
|
+
network: "Ce fichier n'a pas pu \xEAtre charg\xE9. Avez-vous une connexion internet qui fonctionne actuellement ?"
|
|
172
168
|
},
|
|
173
169
|
goto: "Ouvrir %{url}",
|
|
174
170
|
next: "Suivante",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
var _excluded = ["open", "message", "title"];
|
|
3
6
|
|
|
4
7
|
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; }
|
|
5
8
|
|
|
@@ -8,7 +11,21 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
8
11
|
import React, { createContext, useState, useContext, useMemo } from 'react';
|
|
9
12
|
import Snackbar from "cozy-ui/transpiled/react/Snackbar";
|
|
10
13
|
import Alert from "cozy-ui/transpiled/react/Alert";
|
|
14
|
+
import AlertTitle from "cozy-ui/transpiled/react/AlertTitle";
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {import('../../Alert').AlertProps & { message: string, title: string }} ShowAlertArgs
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} UseAlertReturn
|
|
21
|
+
* @property {(args: ShowAlertArgs) => void} showAlert
|
|
22
|
+
*/
|
|
23
|
+
|
|
11
24
|
export var AlertContext = /*#__PURE__*/createContext();
|
|
25
|
+
/**
|
|
26
|
+
* @returns {UseAlertReturn}
|
|
27
|
+
*/
|
|
28
|
+
|
|
12
29
|
export var useAlert = function useAlert() {
|
|
13
30
|
var context = useContext(AlertContext);
|
|
14
31
|
|
|
@@ -19,8 +36,8 @@ export var useAlert = function useAlert() {
|
|
|
19
36
|
return context;
|
|
20
37
|
};
|
|
21
38
|
var defaultState = {
|
|
39
|
+
title: '',
|
|
22
40
|
message: '',
|
|
23
|
-
severity: 'primary',
|
|
24
41
|
open: false
|
|
25
42
|
};
|
|
26
43
|
|
|
@@ -40,28 +57,32 @@ var AlertProvider = function AlertProvider(_ref) {
|
|
|
40
57
|
state = _useState2[0],
|
|
41
58
|
setState = _useState2[1];
|
|
42
59
|
|
|
60
|
+
var open = state.open,
|
|
61
|
+
message = state.message,
|
|
62
|
+
title = state.title,
|
|
63
|
+
alertProps = _objectWithoutProperties(state, _excluded);
|
|
64
|
+
|
|
43
65
|
var value = useMemo(function () {
|
|
44
66
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
67
|
+
/**
|
|
68
|
+
* @param {ShowAlertArgs} args
|
|
69
|
+
*/
|
|
70
|
+
showAlert: function showAlert(args) {
|
|
71
|
+
setState(_objectSpread({
|
|
49
72
|
open: true
|
|
50
|
-
});
|
|
73
|
+
}, args));
|
|
51
74
|
}
|
|
52
75
|
};
|
|
53
76
|
}, []);
|
|
54
77
|
return /*#__PURE__*/React.createElement(AlertContext.Provider, {
|
|
55
78
|
value: value
|
|
56
79
|
}, children, /*#__PURE__*/React.createElement(Snackbar, {
|
|
57
|
-
open:
|
|
80
|
+
open: open,
|
|
58
81
|
onClose: handleClose(state, setState)
|
|
59
|
-
}, /*#__PURE__*/React.createElement(Alert, {
|
|
60
|
-
variant: "filled",
|
|
82
|
+
}, /*#__PURE__*/React.createElement(Alert, _extends({
|
|
61
83
|
elevation: 6,
|
|
62
|
-
severity: state.severity,
|
|
63
84
|
onClose: handleClose(state, setState)
|
|
64
|
-
},
|
|
85
|
+
}, alertProps), title && /*#__PURE__*/React.createElement(AlertTitle, null, title), message)));
|
|
65
86
|
};
|
|
66
87
|
|
|
67
88
|
export default /*#__PURE__*/React.memo(AlertProvider);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {('primary'|'secondary'|'success'|'error'|'warning'|'info')} enumSeverity
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {object} useViewerSnackbarReturn
|
|
8
|
-
* @property {boolean} isViewerSnackbarOpen
|
|
9
|
-
* @property {string} viewerSnackbarMessage
|
|
10
|
-
* @property {enumSeverity} viewerSnackbarSeverity
|
|
11
|
-
* @property {(severity: enumSeverity, message: string) => void} showViewerSnackbar
|
|
12
|
-
* @property {(message: string) => void} hideViewerSnackbar
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const ViewerSnackbarContext = createContext()
|
|
16
|
-
|
|
17
|
-
const ViewerSnackbarProvider = ({ children }) => {
|
|
18
|
-
const [isViewerSnackbarOpen, setIsViewerSnackbarOpen] = useState(false)
|
|
19
|
-
const [viewerSnackbarMessage, setViewerSnackbarMessage] = useState('')
|
|
20
|
-
const [viewerSnackbarSeverity, setViewerSnackbarSeverity] = useState(
|
|
21
|
-
'primary'
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
const showViewerSnackbar = (severity, message) => {
|
|
25
|
-
setIsViewerSnackbarOpen(true)
|
|
26
|
-
setViewerSnackbarMessage(message)
|
|
27
|
-
setViewerSnackbarSeverity(severity)
|
|
28
|
-
}
|
|
29
|
-
const hideViewerSnackbar = () => {
|
|
30
|
-
setIsViewerSnackbarOpen(false)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const result = {
|
|
34
|
-
isViewerSnackbarOpen,
|
|
35
|
-
viewerSnackbarMessage,
|
|
36
|
-
viewerSnackbarSeverity,
|
|
37
|
-
showViewerSnackbar,
|
|
38
|
-
hideViewerSnackbar
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<ViewerSnackbarContext.Provider value={result}>
|
|
43
|
-
{children}
|
|
44
|
-
</ViewerSnackbarContext.Provider>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @returns {useViewerSnackbarReturn}
|
|
50
|
-
*/
|
|
51
|
-
const useViewerSnackbar = () => {
|
|
52
|
-
const viewerSnackbar = useContext(ViewerSnackbarContext)
|
|
53
|
-
if (!viewerSnackbar) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
'ViewerSnackbarContext must be used within a ViewerSnackbarProvider'
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return viewerSnackbar
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default useViewerSnackbar
|
|
63
|
-
|
|
64
|
-
export { ViewerSnackbarProvider }
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import Snackbar from '../../Snackbar'
|
|
4
|
-
import Alert from '../../Alert'
|
|
5
|
-
import useViewerSnackbar from '../providers/ViewerSnackbarProvider'
|
|
6
|
-
|
|
7
|
-
const ViewerSnackbar = () => {
|
|
8
|
-
const {
|
|
9
|
-
isViewerSnackbarOpen,
|
|
10
|
-
viewerSnackbarMessage,
|
|
11
|
-
viewerSnackbarSeverity,
|
|
12
|
-
hideViewerSnackbar
|
|
13
|
-
} = useViewerSnackbar()
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Snackbar open={isViewerSnackbarOpen} onClose={hideViewerSnackbar}>
|
|
17
|
-
<Alert
|
|
18
|
-
variant="filled"
|
|
19
|
-
elevation={6}
|
|
20
|
-
onClose={hideViewerSnackbar}
|
|
21
|
-
severity={viewerSnackbarSeverity}
|
|
22
|
-
icon={false}
|
|
23
|
-
>
|
|
24
|
-
{viewerSnackbarMessage}
|
|
25
|
-
</Alert>
|
|
26
|
-
</Snackbar>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default ViewerSnackbar
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { createContext, useContext, useState } from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {('primary'|'secondary'|'success'|'error'|'warning'|'info')} enumSeverity
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {object} useViewerSnackbarReturn
|
|
9
|
-
* @property {boolean} isViewerSnackbarOpen
|
|
10
|
-
* @property {string} viewerSnackbarMessage
|
|
11
|
-
* @property {enumSeverity} viewerSnackbarSeverity
|
|
12
|
-
* @property {(severity: enumSeverity, message: string) => void} showViewerSnackbar
|
|
13
|
-
* @property {(message: string) => void} hideViewerSnackbar
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
var ViewerSnackbarContext = /*#__PURE__*/createContext();
|
|
17
|
-
|
|
18
|
-
var ViewerSnackbarProvider = function ViewerSnackbarProvider(_ref) {
|
|
19
|
-
var children = _ref.children;
|
|
20
|
-
|
|
21
|
-
var _useState = useState(false),
|
|
22
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
-
isViewerSnackbarOpen = _useState2[0],
|
|
24
|
-
setIsViewerSnackbarOpen = _useState2[1];
|
|
25
|
-
|
|
26
|
-
var _useState3 = useState(''),
|
|
27
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28
|
-
viewerSnackbarMessage = _useState4[0],
|
|
29
|
-
setViewerSnackbarMessage = _useState4[1];
|
|
30
|
-
|
|
31
|
-
var _useState5 = useState('primary'),
|
|
32
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
33
|
-
viewerSnackbarSeverity = _useState6[0],
|
|
34
|
-
setViewerSnackbarSeverity = _useState6[1];
|
|
35
|
-
|
|
36
|
-
var showViewerSnackbar = function showViewerSnackbar(severity, message) {
|
|
37
|
-
setIsViewerSnackbarOpen(true);
|
|
38
|
-
setViewerSnackbarMessage(message);
|
|
39
|
-
setViewerSnackbarSeverity(severity);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var hideViewerSnackbar = function hideViewerSnackbar() {
|
|
43
|
-
setIsViewerSnackbarOpen(false);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var result = {
|
|
47
|
-
isViewerSnackbarOpen: isViewerSnackbarOpen,
|
|
48
|
-
viewerSnackbarMessage: viewerSnackbarMessage,
|
|
49
|
-
viewerSnackbarSeverity: viewerSnackbarSeverity,
|
|
50
|
-
showViewerSnackbar: showViewerSnackbar,
|
|
51
|
-
hideViewerSnackbar: hideViewerSnackbar
|
|
52
|
-
};
|
|
53
|
-
return /*#__PURE__*/React.createElement(ViewerSnackbarContext.Provider, {
|
|
54
|
-
value: result
|
|
55
|
-
}, children);
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* @returns {useViewerSnackbarReturn}
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var useViewerSnackbar = function useViewerSnackbar() {
|
|
63
|
-
var viewerSnackbar = useContext(ViewerSnackbarContext);
|
|
64
|
-
|
|
65
|
-
if (!viewerSnackbar) {
|
|
66
|
-
throw new Error('ViewerSnackbarContext must be used within a ViewerSnackbarProvider');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return viewerSnackbar;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default useViewerSnackbar;
|
|
73
|
-
export { ViewerSnackbarProvider };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Snackbar from "cozy-ui/transpiled/react/Snackbar";
|
|
3
|
-
import Alert from "cozy-ui/transpiled/react/Alert";
|
|
4
|
-
import useViewerSnackbar from "cozy-ui/transpiled/react/Viewer/providers/ViewerSnackbarProvider";
|
|
5
|
-
|
|
6
|
-
var ViewerSnackbar = function ViewerSnackbar() {
|
|
7
|
-
var _useViewerSnackbar = useViewerSnackbar(),
|
|
8
|
-
isViewerSnackbarOpen = _useViewerSnackbar.isViewerSnackbarOpen,
|
|
9
|
-
viewerSnackbarMessage = _useViewerSnackbar.viewerSnackbarMessage,
|
|
10
|
-
viewerSnackbarSeverity = _useViewerSnackbar.viewerSnackbarSeverity,
|
|
11
|
-
hideViewerSnackbar = _useViewerSnackbar.hideViewerSnackbar;
|
|
12
|
-
|
|
13
|
-
return /*#__PURE__*/React.createElement(Snackbar, {
|
|
14
|
-
open: isViewerSnackbarOpen,
|
|
15
|
-
onClose: hideViewerSnackbar
|
|
16
|
-
}, /*#__PURE__*/React.createElement(Alert, {
|
|
17
|
-
variant: "filled",
|
|
18
|
-
elevation: 6,
|
|
19
|
-
onClose: hideViewerSnackbar,
|
|
20
|
-
severity: viewerSnackbarSeverity,
|
|
21
|
-
icon: false
|
|
22
|
-
}, viewerSnackbarMessage));
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default ViewerSnackbar;
|