cozy-ui 110.4.0 → 110.5.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 CHANGED
@@ -1,3 +1,15 @@
1
+ # [110.5.0](https://github.com/cozy/cozy-ui/compare/v110.4.0...v110.5.0) (2024-07-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Backdrop:** Add `isOver` props ([67e6de7](https://github.com/cozy/cozy-ui/commit/67e6de7))
7
+ * **Empty:** Add `componentsProps.icon/title/text/childrenContainer` props ([8d50ee6](https://github.com/cozy/cozy-ui/commit/8d50ee6))
8
+ * **IntentDialogOpener:** Add `Component` prop to replace Dialog ([01a4499](https://github.com/cozy/cozy-ui/commit/01a4499))
9
+ * **IntentIframe:** Add `iframeProps.setIsLoading` prop to wind it up ([bf0db3d](https://github.com/cozy/cozy-ui/commit/bf0db3d))
10
+ * **IntentProvider:** Add provider to deal with intents ([b00b893](https://github.com/cozy/cozy-ui/commit/b00b893))
11
+ * **Viewer:** Add BlankPaperViewer view and plug it to blank papers ([41ee4fe](https://github.com/cozy/cozy-ui/commit/41ee4fe))
12
+
1
13
  # [110.4.0](https://github.com/cozy/cozy-ui/compare/v110.3.0...v110.4.0) (2024-07-04)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "110.4.0",
3
+ "version": "110.5.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -1,3 +1,30 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
1
3
  import MuiBackdrop from '@material-ui/core/Backdrop'
4
+ import cx from 'classnames'
2
5
 
3
- export default MuiBackdrop
6
+ import { makeStyles } from '../styles'
7
+
8
+ const useStyles = makeStyles({
9
+ isOver: {
10
+ zIndex: 'calc(var(--zIndex-modal-toolbar) + 1)' // to be over a modal if used inside it
11
+ }
12
+ })
13
+
14
+ const Backdrop = ({ isOver, ...props }) => {
15
+ const styles = useStyles()
16
+
17
+ return (
18
+ <MuiBackdrop
19
+ {...props}
20
+ className={cx({ [styles.isOver]: isOver }, props.className)}
21
+ />
22
+ )
23
+ }
24
+
25
+ Backdrop.propTypes = {
26
+ /** Whether the Backdrop is over modal */
27
+ isOver: PropTypes.bool
28
+ }
29
+
30
+ export default Backdrop
@@ -15,6 +15,7 @@ export const Empty = ({
15
15
  children,
16
16
  className,
17
17
  centered,
18
+ componentsProps,
18
19
  ...restProps
19
20
  }) => {
20
21
  const isReactIconElement = typeof icon === 'object' && !!icon.props
@@ -38,7 +39,8 @@ export const Empty = ({
38
39
  },
39
40
  icon.props?.className
40
41
  ),
41
- size: icon.props?.size || (icon.type === Icon ? '100%' : undefined)
42
+ size: icon.props?.size || (icon.type === Icon ? '100%' : undefined),
43
+ ...componentsProps?.icon
42
44
  })
43
45
  ) : (
44
46
  <Icon
@@ -47,15 +49,30 @@ export const Empty = ({
47
49
  })}
48
50
  icon={icon}
49
51
  size="100%"
52
+ {...componentsProps?.icon}
50
53
  />
51
54
  ))}
52
55
  {title && (
53
- <Typography gutterBottom variant="h3" color="textPrimary">
56
+ <Typography
57
+ gutterBottom
58
+ variant="h3"
59
+ color="textPrimary"
60
+ {...componentsProps?.title}
61
+ >
54
62
  {title}
55
63
  </Typography>
56
64
  )}
57
- {text && <EmptySubTitle gutterBottom>{text}</EmptySubTitle>}
58
- <div className={styles['c-empty-text']}>{children}</div>
65
+ {text && (
66
+ <EmptySubTitle gutterBottom {...componentsProps?.text}>
67
+ {text}
68
+ </EmptySubTitle>
69
+ )}
70
+ <div
71
+ className={styles['c-empty-text']}
72
+ {...componentsProps?.childrenContainer}
73
+ >
74
+ {children}
75
+ </div>
59
76
  </div>
60
77
  )
61
78
  }
@@ -68,6 +85,12 @@ Empty.propTypes = {
68
85
  /** Sets horizontal and vertical centring. The reference element is that of a fixed position */
69
86
  centered: PropTypes.bool,
70
87
  children: PropTypes.node,
88
+ componentsProps: PropTypes.shape({
89
+ icon: PropTypes.object,
90
+ title: PropTypes.object,
91
+ text: PropTypes.object,
92
+ childrenContainer: PropTypes.object
93
+ }),
71
94
  className: PropTypes.string
72
95
  }
73
96
 
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
- import IntentIframe from '../IntentIframe'
4
+ import IntentIframe, { iframeProps } from '../IntentIframe'
5
5
  import { DialogCloseButton } from '../CozyDialogs'
6
6
  import Dialog from '../Dialog'
7
7
 
@@ -22,7 +22,8 @@ const IntentDialogOpener = props => {
22
22
  onComplete,
23
23
  onDismiss,
24
24
  iframeProps,
25
- ...dialogProps
25
+ Component,
26
+ ...componentProps
26
27
  } = props
27
28
  const [modalOpened, setModalOpened] = useState(false)
28
29
 
@@ -50,11 +51,11 @@ const IntentDialogOpener = props => {
50
51
 
51
52
  if (modalOpened) {
52
53
  elements.push(
53
- <Dialog
54
+ <Component
54
55
  key="intent-modal"
55
56
  open={modalOpened}
56
57
  onClose={closable && handleDismiss}
57
- {...dialogProps}
58
+ {...componentProps}
58
59
  >
59
60
  {closable && showCloseButton && (
60
61
  <DialogCloseButton onClick={handleDismiss} />
@@ -68,7 +69,7 @@ const IntentDialogOpener = props => {
68
69
  onTerminate={handleComplete}
69
70
  iframeProps={iframeProps}
70
71
  />
71
- </Dialog>
72
+ </Component>
72
73
  )
73
74
  }
74
75
 
@@ -92,16 +93,16 @@ IntentDialogOpener.propTypes = {
92
93
  showCloseButton: PropTypes.bool.isRequired,
93
94
  /** Tag used to wrap children */
94
95
  tag: PropTypes.string.isRequired,
96
+ /** Component to be used instead of the dialog */
97
+ Component: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
95
98
  /** Props to be passed to the iframe */
96
- iframeProps: PropTypes.shape({
97
- wrapperProps: PropTypes.object,
98
- spinnerProps: PropTypes.object
99
- })
99
+ iframeProps: iframeProps
100
100
  }
101
101
 
102
102
  IntentDialogOpener.defaultProps = {
103
103
  tag: 'span',
104
104
  closable: true,
105
+ Component: Dialog,
105
106
  showCloseButton: true
106
107
  }
107
108
 
@@ -1,32 +1,25 @@
1
1
  ```jsx
2
- import { withStyles } from 'cozy-ui/transpiled/react/styles'
3
2
  import IntentDialogOpener from 'cozy-ui/transpiled/react/IntentDialogOpener'
3
+ import Button from 'cozy-ui/transpiled/react/Buttons'
4
4
  import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
5
5
 
6
- const customStyles = () => ({
7
- paper: {
8
- height: '100%'
9
- }
10
- })
11
-
12
- const StyledIntentDialogOpener = withStyles(customStyles)(IntentDialogOpener)
13
-
14
6
  ;
15
7
 
16
8
  <DemoProvider>
17
- <StyledIntentDialogOpener
18
- onComplete={res => alert('intent has completed ! ' + JSON.stringify(res))}
19
- onDismiss={() => alert('intent has been dismissed !')}
9
+ <IntentDialogOpener
20
10
  action='OPEN'
21
11
  doctype='io.cozy.files'
22
12
  // you would not pass create normally as it defaults to
23
13
  // cozy.client.intents.create
24
14
  create={utils.fakeIntentCreate}
25
- //extra props will be passed to the dialog
26
- fullWidth
27
- maxWidth="md"
15
+ classes={{ paper: 'u-h-100' }} // extra props will be passed to the dialog
16
+ fullWidth // extra props will be passed to the dialog
17
+ maxWidth="md" // extra props will be passed to the dialog
18
+ iframeProps={{ spinnerProps: { middle: true } }}
19
+ onComplete={res => alert('intent has completed ! ' + JSON.stringify(res))}
20
+ onDismiss={() => alert('intent has been dismissed !')}
28
21
  >
29
- <button>Launch Intent OPEN for doctype io.cozy.files</button>
30
- </StyledIntentDialogOpener>
22
+ <Button label="Launch Intent OPEN for doctype io.cozy.files" />
23
+ </IntentDialogOpener>
31
24
  </DemoProvider>
32
25
  ```
@@ -57,13 +57,15 @@ class IntentIframe extends React.Component {
57
57
  result ? onTerminate && onTerminate(result) : onCancel()
58
58
  })
59
59
  .catch(error => {
60
- ;(onError && onError(error)) ||
61
- this.setState({ error: error, loading: false })
60
+ onError?.(error)
61
+ this.setState({ error: error, loading: false })
62
+ this.props.iframeProps?.setIsLoading?.(false)
62
63
  })
63
64
  }
64
65
 
65
66
  onFrameLoaded = () => {
66
67
  this.setState({ loading: false })
68
+ this.props.iframeProps?.setIsLoading?.(false)
67
69
  }
68
70
 
69
71
  render() {
@@ -89,6 +91,12 @@ class IntentIframe extends React.Component {
89
91
  }
90
92
  }
91
93
 
94
+ export const iframeProps = PropTypes.shape({
95
+ wrapperProps: PropTypes.object,
96
+ spinnerProps: PropTypes.object,
97
+ setIsLoading: PropTypes.func
98
+ })
99
+
92
100
  IntentIframe.propTypes = {
93
101
  action: PropTypes.string.isRequired,
94
102
  create: PropTypes.func,
@@ -97,10 +105,7 @@ IntentIframe.propTypes = {
97
105
  onCancel: PropTypes.func,
98
106
  onError: PropTypes.func,
99
107
  onTerminate: PropTypes.func.isRequired,
100
- iframeProps: PropTypes.shape({
101
- wrapperProps: PropTypes.object,
102
- spinnerProps: PropTypes.object
103
- }),
108
+ iframeProps: iframeProps,
104
109
  onHideCross: PropTypes.func,
105
110
  onShowCross: PropTypes.func
106
111
  }
@@ -1 +1 @@
1
- export { default } from './IntentIframe'
1
+ export { default, iframeProps } from './IntentIframe'
@@ -0,0 +1,48 @@
1
+ import React, { useState } from 'react'
2
+
3
+ import Button from '../../Buttons'
4
+ import Empty from '../../Empty'
5
+ import Backdrop from '../../Backdrop'
6
+ import IntentDialogOpener from '../../IntentDialogOpener'
7
+
8
+ import IlluGenericNewPage from '../assets/IlluGenericNewPage.svg'
9
+ import { withViewerLocales } from '../hoc/withViewerLocales'
10
+
11
+ import styles from './styles.styl'
12
+
13
+ const BlankPaperViewer = ({ file, t }) => {
14
+ const [isLoading, setIsLoading] = useState(true)
15
+
16
+ return (
17
+ <div className={styles['viewer-noviewer']}>
18
+ <Empty
19
+ icon={<img src={IlluGenericNewPage} />}
20
+ text={t('Viewer.noImage')}
21
+ componentsProps={{
22
+ text: { color: 'inherit' }
23
+ }}
24
+ >
25
+ <IntentDialogOpener
26
+ action="OPEN"
27
+ doctype="io.cozy.files.paper"
28
+ Component={Backdrop}
29
+ invisible={!isLoading}
30
+ isOver
31
+ options={{
32
+ fileId: file._id,
33
+ qualificationLabel: file.metadata?.qualification?.label
34
+ }}
35
+ showCloseButton={false}
36
+ iframeProps={{
37
+ spinnerProps: { className: 'u-m-0', middle: true, color: 'white' },
38
+ setIsLoading
39
+ }}
40
+ >
41
+ <Button className="u-mt-1" label={t('Viewer.complete')} />
42
+ </IntentDialogOpener>
43
+ </Empty>
44
+ </div>
45
+ )
46
+ }
47
+
48
+ export default withViewerLocales(BlankPaperViewer)
@@ -0,0 +1,10 @@
1
+ <svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M0 4C0 1.79086 1.79086 0 4 0H29.3333C30.8061 0 32 1.19391 32 2.66667C32 4.13943 30.8061 5.33333 29.3333 5.33333L5.33333 5.33333V29.3333C5.33333 30.8061 4.13943 32 2.66667 32C1.19391 32 0 30.8061 0 29.3333V4Z" fill="#B3D3FF"/>
3
+ <path d="M0 124C0 126.209 1.79086 128 4 128H29.3333C30.8061 128 32 126.806 32 125.333C32 123.861 30.8061 122.667 29.3333 122.667H5.33333V98.6667C5.33333 97.1939 4.13943 96 2.66667 96C1.19391 96 0 97.1939 0 98.6667V124Z" fill="#B3D3FF"/>
4
+ <path d="M124 0C126.209 0 128 1.79086 128 4V29.3333C128 30.8061 126.806 32 125.333 32C123.861 32 122.667 30.8061 122.667 29.3333V5.33333L98.6667 5.33333C97.1939 5.33333 96 4.13943 96 2.66667C96 1.19391 97.1939 0 98.6667 0H124Z" fill="#B3D3FF"/>
5
+ <path d="M128 98.6667V124C128 126.209 126.209 128 124 128H98.6667C97.1939 128 96 126.806 96 125.333C96 123.861 97.1939 122.667 98.6667 122.667H122.667V98.6667C122.667 97.1939 123.861 96 125.333 96C126.806 96 128 97.1939 128 98.6667Z" fill="#B3D3FF"/>
6
+ <path d="M30.0876 89.1458C29.5095 91.8804 29.0759 94.471 29.5095 96.9177C30.2322 101.236 33.7011 102.963 38.0372 103.97C39.9162 104.402 42.0842 104.69 43.8187 104.834C52.4909 105.841 67.0892 106.273 75.906 107.136C78.6522 107.568 81.3985 107.712 84.0001 107.856C85.1564 107.856 86.1682 107.856 87.18 107.856C88.1917 108 89.2035 108 90.2152 108C95.1295 108 96.7194 104.978 97.2976 100.948C97.4421 100.372 97.5867 99.7963 97.7312 99.0766C97.7312 98.7888 97.7312 98.357 97.7312 98.0692C97.7312 97.6374 97.7312 97.2056 97.8757 96.9178C98.4539 94.1832 98.8875 91.4486 99.3211 88.714C99.3211 88.4262 99.4657 87.9944 99.4657 87.7065C100.333 83.3888 103.657 64.8224 105.103 50.8617C106.114 45.6803 108.861 36.0373 103.224 33.0149C99.8993 31.2878 47.7212 26.8261 45.5532 26.6822C42.8069 26.5383 41.217 27.4018 40.3498 28.985C39.6271 29.7046 39.338 30.7121 39.049 32.0074C37.8927 35.3177 30.3767 82.5252 30.0876 89.1458Z" fill="#B3D3FF"/>
7
+ <path d="M28.2551 88.6304C27.9636 91.3461 27.8178 93.9187 28.4008 96.3485C29.5668 100.493 33.3563 101.923 37.7287 102.351C39.7692 102.637 41.8097 102.637 43.5586 102.637C52.3035 102.78 64.2549 102.351 73.1456 102.351C75.9148 102.494 78.684 102.494 81.4532 102.209C82.6192 102.209 83.7852 102.209 84.6597 102.066C85.6799 102.066 86.7002 102.066 87.7204 101.923C92.6759 101.494 93.8418 98.2066 93.9876 94.3475C94.1333 93.6329 94.2791 93.0612 94.2791 92.2036C94.2791 91.9178 94.2791 91.489 94.1333 91.2031C94.1333 90.7743 94.1333 90.3456 94.2791 90.0597C94.5706 87.3441 94.7163 84.6285 94.8621 81.7699C94.8621 81.4841 94.8621 81.0553 94.8621 80.7694C95.2993 76.4816 96.7568 57.7581 96.7568 43.7512C97.1941 38.7487 98.943 28.8867 92.9674 26.4569C89.4694 25.0277 39.4777 25.3135 37.1457 25.4565C34.3765 25.5994 32.919 26.5999 32.0445 28.1721C31.4615 28.8867 31.17 30.0301 31.0243 31.3165C30.587 34.7467 27.6721 82.0558 28.2551 88.6304Z" fill="#297EF2"/>
8
+ <path d="M27.3492 89.0204C27.4924 91.7375 27.7789 94.3116 28.6383 96.5997C30.3572 100.604 34.2245 101.462 38.5215 101.319C40.5268 101.319 42.5321 101.033 44.2509 100.747C52.8451 99.6028 61.7256 99.3168 70.3197 98.0298C73.0412 97.7437 75.7627 97.3147 78.3409 96.7427C79.4868 96.4567 80.4894 96.3137 81.3488 96.0277C82.3515 95.8847 83.3541 95.7417 84.2135 95.4557C88.9403 94.3116 89.6565 91.0225 89.2268 87.0183C89.2268 86.4463 89.2268 85.7313 89.2268 85.0163C89.2268 84.7303 89.0835 84.3013 88.9403 84.1582C88.9403 83.7292 88.9403 83.3002 88.7971 83.0142C88.6538 80.2971 88.5106 77.58 88.0809 74.7199C88.0809 74.4339 88.0809 74.0049 87.9377 73.7189C87.6512 69.4287 86.3621 50.695 84.3568 36.8235C84.0703 31.6753 84.3568 21.6649 78.1977 20.0919C74.6168 19.2338 28.6383 24.668 26.3466 25.0971C23.7683 25.6691 22.336 26.8131 21.9063 28.5292C21.3333 29.3872 21.3333 30.3882 21.3333 31.8183C21.763 35.2504 25.9169 82.5852 27.3492 89.0204Z" fill="#B3D3FF"/>
9
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M35.7958 40.7716C41.1805 40.1972 46.6011 39.6587 52.0218 39.1203L52.0219 39.1203C57.4425 38.5818 62.8631 38.0433 68.2478 37.469C70.5453 37.1818 70.2581 33.592 67.9606 33.8791C57.1911 34.8843 46.2781 36.033 35.5086 37.1818C33.0675 37.3254 33.4983 40.9152 35.7958 40.7716ZM46.5729 47.3879L46.5729 47.3879L46.5728 47.3879C45.1604 47.5673 42.7233 47.8769 36.9445 48.5256C34.647 48.8128 34.3598 45.2229 36.5137 44.9358C38.5044 44.6789 40.0867 44.4731 41.3642 44.3069L41.3643 44.3069C45.1248 43.8178 46.2448 43.6721 47.3691 43.5787C47.846 43.5391 48.3237 43.5089 49.004 43.4658L49.0041 43.4658C49.8302 43.4136 50.9549 43.3425 52.7397 43.2127C55.0372 43.0691 55.468 46.6589 53.1705 46.8025L52.6398 46.8411L52.6396 46.8411C49.8467 47.0441 48.947 47.1095 48.0509 47.2076C47.625 47.2542 47.2 47.3082 46.5729 47.3879ZM43.4879 55.3257L43.4882 55.3257L43.4883 55.3257L43.4883 55.3257L43.4883 55.3257L43.4883 55.3257L43.4883 55.3257C47.2575 55.0107 51.066 54.6925 54.7501 54.1257C57.0476 53.8386 56.6168 50.2487 54.3193 50.5359C51.2189 51.0129 48.0305 51.2698 44.8514 51.526C42.2884 51.7325 39.7315 51.9385 37.2318 52.259C34.7907 52.4026 35.3651 56.136 37.6625 55.8489C39.5784 55.6524 41.5278 55.4895 43.4879 55.3257ZM62.2168 67.1927C54.3192 67.6235 52.5961 67.7671 38.524 69.0594C36.2265 69.3466 35.9393 65.7568 38.2368 65.4696C48.7943 64.2208 52.531 64.0491 57.5355 63.819L57.5365 63.819C58.8619 63.7581 60.2762 63.6931 61.9296 63.6029C64.2271 63.4593 64.5143 67.0491 62.2168 67.1927ZM41.4373 81.1075L41.4371 81.1075L40.2472 81.2648C37.9497 81.552 38.3805 85.1418 40.678 84.8546C49.1809 83.987 51.0257 83.7484 53.1498 83.4738L53.1499 83.4738C54.5411 83.2939 56.0521 83.0985 59.6323 82.7007C61.9298 82.4135 61.6426 78.8237 59.2015 79.1109C50.3738 79.9258 48.0971 80.2268 41.4373 81.1075ZM38.8112 73.5108C49.5806 72.362 60.4937 71.2133 71.2632 70.2082C73.5607 69.921 73.9914 73.5108 71.5504 73.798C66.1656 74.3724 60.745 74.9108 55.3244 75.4493C49.9037 75.9878 44.4831 76.5262 39.0984 77.1006C36.8009 77.3878 36.5137 73.798 38.8112 73.5108Z" fill="#297EF2"/>
10
+ </svg>
@@ -2,7 +2,7 @@ import React, { useMemo } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
4
  import { isMobile as isMobileDevice } from 'cozy-device-helper'
5
- import { models } from 'cozy-client'
5
+ import { isPlainText } from 'cozy-client/dist/models/file'
6
6
 
7
7
  import { FileDoctype } from '../../proptypes'
8
8
  import withBreakpoints from '../../helpers/withBreakpoints'
@@ -11,6 +11,7 @@ import ImageViewer from '../ViewersByFile/ImageViewer'
11
11
  import AudioViewer from '../ViewersByFile/AudioViewer'
12
12
  import VideoViewer from '../ViewersByFile/VideoViewer'
13
13
  import PdfJsViewer from '../ViewersByFile/PdfJsViewer'
14
+ import BlankPaperViewer from '../ViewersByFile/BlankPaperViewer'
14
15
  import TextViewer from '../ViewersByFile/TextViewer'
15
16
  import PdfMobileViewer from '../ViewersByFile/PdfMobileViewer'
16
17
  import NoViewer from '../NoViewer'
@@ -19,7 +20,7 @@ import OnlyOfficeViewer from '../ViewersByFile/OnlyOfficeViewer'
19
20
 
20
21
  import { useEncrypted } from '../providers/EncryptedProvider'
21
22
 
22
- const { isPlainText } = models.file
23
+ const isBlankPaper = doc => doc.metadata?.paperProps?.isBlank
23
24
 
24
25
  export const getViewerComponentName = ({
25
26
  file,
@@ -36,7 +37,11 @@ export const getViewerComponentName = ({
36
37
  case 'video':
37
38
  return isMobileDevice() ? NoViewer : VideoViewer
38
39
  case 'pdf':
39
- return isDesktop ? PdfJsViewer : PdfMobileViewer
40
+ return isBlankPaper(file)
41
+ ? BlankPaperViewer
42
+ : isDesktop
43
+ ? PdfJsViewer
44
+ : PdfMobileViewer
40
45
  case 'text':
41
46
  return isPlainText(file.mime, file.name)
42
47
  ? TextViewer
@@ -9,6 +9,8 @@
9
9
  },
10
10
  "close": "close",
11
11
  "download": "Download",
12
+ "complete": "Complete the document",
13
+ "noImage": "No image",
12
14
  "error": {
13
15
  "downloadFile": {
14
16
  "offline": "You should be connected to download this file"
@@ -9,6 +9,8 @@
9
9
  },
10
10
  "close": "Fermer",
11
11
  "download": "Télécharger",
12
+ "complete": "Compléter le document",
13
+ "noImage": "Aucune image",
12
14
  "error": {
13
15
  "downloadFile": {
14
16
  "offline": "Vous devez être connecté pour télécharger ce fichier"
@@ -0,0 +1,83 @@
1
+ import React, {
2
+ useEffect,
3
+ useMemo,
4
+ useState,
5
+ createContext,
6
+ useContext
7
+ } from 'react'
8
+
9
+ import { useClient } from 'cozy-client'
10
+ import Spinner from 'cozy-ui/transpiled/react/Spinner'
11
+ import Backdrop from 'cozy-ui/transpiled/react/Backdrop'
12
+
13
+ export const IntentContext = createContext()
14
+
15
+ export const useIntent = () => {
16
+ const context = useContext(IntentContext)
17
+
18
+ if (!context) {
19
+ throw new Error('useIntent must be used within a IntentProvider')
20
+ }
21
+ return context
22
+ }
23
+
24
+ const IntentProvider = ({ intentId, componentsProps, children }) => {
25
+ const client = useClient()
26
+ const [state, setState] = useState({
27
+ service: null,
28
+ intent: null,
29
+ data: null
30
+ })
31
+
32
+ const value = useMemo(
33
+ () => ({
34
+ service: state.service,
35
+ intent: state.intent,
36
+ data: state.data
37
+ }),
38
+ [state]
39
+ )
40
+
41
+ useEffect(() => {
42
+ const startService = async () => {
43
+ let service
44
+
45
+ try {
46
+ service = await client.intents.createService(intentId, window)
47
+ const intent = service.getIntent()
48
+ const data = service.getData()
49
+
50
+ setState({
51
+ service,
52
+ intent,
53
+ data
54
+ })
55
+ } catch (error) {
56
+ service.throw(error)
57
+ }
58
+ }
59
+
60
+ if (!state.service) {
61
+ startService()
62
+ }
63
+ }, [client, intentId, state.service])
64
+
65
+ if (!state.service) {
66
+ return (
67
+ <Backdrop open {...componentsProps?.backdrop}>
68
+ <Spinner
69
+ className="u-m-0"
70
+ size="xxlarge"
71
+ middle
72
+ {...componentsProps?.spinner}
73
+ />
74
+ </Backdrop>
75
+ )
76
+ }
77
+
78
+ return (
79
+ <IntentContext.Provider value={value}>{children}</IntentContext.Provider>
80
+ )
81
+ }
82
+
83
+ export default IntentProvider
@@ -1,2 +1,31 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["isOver"];
5
+ import React from 'react';
6
+ import PropTypes from 'prop-types';
1
7
  import MuiBackdrop from '@material-ui/core/Backdrop';
2
- export default MuiBackdrop;
8
+ import cx from 'classnames';
9
+ import { makeStyles } from "cozy-ui/transpiled/react/styles";
10
+ var useStyles = makeStyles({
11
+ isOver: {
12
+ zIndex: 'calc(var(--zIndex-modal-toolbar) + 1)' // to be over a modal if used inside it
13
+
14
+ }
15
+ });
16
+
17
+ var Backdrop = function Backdrop(_ref) {
18
+ var isOver = _ref.isOver,
19
+ props = _objectWithoutProperties(_ref, _excluded);
20
+
21
+ var styles = useStyles();
22
+ return /*#__PURE__*/React.createElement(MuiBackdrop, _extends({}, props, {
23
+ className: cx(_defineProperty({}, styles.isOver, isOver), props.className)
24
+ }));
25
+ };
26
+
27
+ Backdrop.propTypes = {
28
+ /** Whether the Backdrop is over modal */
29
+ isOver: PropTypes.bool
30
+ };
31
+ export default Backdrop;
@@ -1,7 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["icon", "iconSize", "title", "text", "children", "className", "centered"];
4
+ var _excluded = ["icon", "iconSize", "title", "text", "children", "className", "centered", "componentsProps"];
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
+
5
10
  import React from 'react';
6
11
  import cx from 'classnames';
7
12
  import PropTypes from 'prop-types';
@@ -26,27 +31,28 @@ export var Empty = function Empty(_ref) {
26
31
  children = _ref.children,
27
32
  className = _ref.className,
28
33
  centered = _ref.centered,
34
+ componentsProps = _ref.componentsProps,
29
35
  restProps = _objectWithoutProperties(_ref, _excluded);
30
36
 
31
37
  var isReactIconElement = typeof icon === 'object' && !!icon.props;
32
38
  return /*#__PURE__*/React.createElement("div", _extends({
33
39
  className: cx(styles['c-empty'], _defineProperty({}, styles['c-empty--centered'], centered), className)
34
- }, restProps), icon && (isReactIconElement ? /*#__PURE__*/React.cloneElement(icon, {
40
+ }, restProps), icon && (isReactIconElement ? /*#__PURE__*/React.cloneElement(icon, _objectSpread({
35
41
  className: cx(styles['c-empty-img'], _defineProperty({}, styles["c-empty-img--".concat(iconSize)], iconSize !== 'normal'), (_icon$props = icon.props) === null || _icon$props === void 0 ? void 0 : _icon$props.className),
36
42
  size: ((_icon$props2 = icon.props) === null || _icon$props2 === void 0 ? void 0 : _icon$props2.size) || (icon.type === Icon ? '100%' : undefined)
37
- }) : /*#__PURE__*/React.createElement(Icon, {
43
+ }, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.icon)) : /*#__PURE__*/React.createElement(Icon, _extends({
38
44
  className: cx(styles['c-empty-img'], _defineProperty({}, styles["c-empty-img--".concat(iconSize)], iconSize !== 'normal')),
39
45
  icon: icon,
40
46
  size: "100%"
41
- })), title && /*#__PURE__*/React.createElement(Typography, {
47
+ }, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.icon))), title && /*#__PURE__*/React.createElement(Typography, _extends({
42
48
  gutterBottom: true,
43
49
  variant: "h3",
44
50
  color: "textPrimary"
45
- }, title), text && /*#__PURE__*/React.createElement(EmptySubTitle, {
51
+ }, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.title), title), text && /*#__PURE__*/React.createElement(EmptySubTitle, _extends({
46
52
  gutterBottom: true
47
- }, text), /*#__PURE__*/React.createElement("div", {
53
+ }, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.text), text), /*#__PURE__*/React.createElement("div", _extends({
48
54
  className: styles['c-empty-text']
49
- }, children));
55
+ }, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.childrenContainer), children));
50
56
  };
51
57
  Empty.propTypes = {
52
58
  icon: iconPropType,
@@ -57,6 +63,12 @@ Empty.propTypes = {
57
63
  /** Sets horizontal and vertical centring. The reference element is that of a fixed position */
58
64
  centered: PropTypes.bool,
59
65
  children: PropTypes.node,
66
+ componentsProps: PropTypes.shape({
67
+ icon: PropTypes.object,
68
+ title: PropTypes.object,
69
+ text: PropTypes.object,
70
+ childrenContainer: PropTypes.object
71
+ }),
60
72
  className: PropTypes.string
61
73
  };
62
74
  Empty.defaultProps = {
@@ -1,10 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["options", "action", "doctype", "children", "closable", "showCloseButton", "create", "tag", "onComplete", "onDismiss", "iframeProps"];
4
+ var _excluded = ["options", "action", "doctype", "children", "closable", "showCloseButton", "create", "tag", "onComplete", "onDismiss", "iframeProps", "Component"];
5
5
  import React, { useState } from 'react';
6
6
  import PropTypes from 'prop-types';
7
- import IntentIframe from "cozy-ui/transpiled/react/IntentIframe";
7
+ import IntentIframe, { iframeProps } from "cozy-ui/transpiled/react/IntentIframe";
8
8
  import { DialogCloseButton } from "cozy-ui/transpiled/react/CozyDialogs";
9
9
  import Dialog from "cozy-ui/transpiled/react/Dialog";
10
10
  /**
@@ -24,7 +24,8 @@ var IntentDialogOpener = function IntentDialogOpener(props) {
24
24
  onComplete = props.onComplete,
25
25
  onDismiss = props.onDismiss,
26
26
  iframeProps = props.iframeProps,
27
- dialogProps = _objectWithoutProperties(props, _excluded);
27
+ Component = props.Component,
28
+ componentProps = _objectWithoutProperties(props, _excluded);
28
29
 
29
30
  var _useState = useState(false),
30
31
  _useState2 = _slicedToArray(_useState, 2),
@@ -59,11 +60,11 @@ var IntentDialogOpener = function IntentDialogOpener(props) {
59
60
  })];
60
61
 
61
62
  if (modalOpened) {
62
- elements.push( /*#__PURE__*/React.createElement(Dialog, _extends({
63
+ elements.push( /*#__PURE__*/React.createElement(Component, _extends({
63
64
  key: "intent-modal",
64
65
  open: modalOpened,
65
66
  onClose: closable && handleDismiss
66
- }, dialogProps), closable && showCloseButton && /*#__PURE__*/React.createElement(DialogCloseButton, {
67
+ }, componentProps), closable && showCloseButton && /*#__PURE__*/React.createElement(DialogCloseButton, {
67
68
  onClick: handleDismiss
68
69
  }), /*#__PURE__*/React.createElement(IntentIframe, {
69
70
  action: action,
@@ -104,15 +105,16 @@ IntentDialogOpener.propTypes = {
104
105
  /** Tag used to wrap children */
105
106
  tag: PropTypes.string.isRequired,
106
107
 
108
+ /** Component to be used instead of the dialog */
109
+ Component: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
110
+
107
111
  /** Props to be passed to the iframe */
108
- iframeProps: PropTypes.shape({
109
- wrapperProps: PropTypes.object,
110
- spinnerProps: PropTypes.object
111
- })
112
+ iframeProps: iframeProps
112
113
  };
113
114
  IntentDialogOpener.defaultProps = {
114
115
  tag: 'span',
115
116
  closable: true,
117
+ Component: Dialog,
116
118
  showCloseButton: true
117
119
  };
118
120
  export default IntentDialogOpener;
@@ -54,9 +54,13 @@ var IntentIframe = /*#__PURE__*/function (_React$Component) {
54
54
  });
55
55
 
56
56
  _defineProperty(_assertThisInitialized(_this), "onFrameLoaded", function () {
57
+ var _this$props$iframePro, _this$props$iframePro2;
58
+
57
59
  _this.setState({
58
60
  loading: false
59
61
  });
62
+
63
+ (_this$props$iframePro = _this.props.iframeProps) === null || _this$props$iframePro === void 0 ? void 0 : (_this$props$iframePro2 = _this$props$iframePro.setIsLoading) === null || _this$props$iframePro2 === void 0 ? void 0 : _this$props$iframePro2.call(_this$props$iframePro, false);
60
64
  });
61
65
 
62
66
  return _this;
@@ -94,11 +98,16 @@ var IntentIframe = /*#__PURE__*/function (_React$Component) {
94
98
  // eslint-disable-next-line promise/always-return
95
99
  result ? onTerminate && onTerminate(result) : onCancel();
96
100
  }).catch(function (error) {
97
- ;
98
- onError && onError(error) || _this2.setState({
101
+ var _this2$props$iframePr, _this2$props$iframePr2;
102
+
103
+ onError === null || onError === void 0 ? void 0 : onError(error);
104
+
105
+ _this2.setState({
99
106
  error: error,
100
107
  loading: false
101
108
  });
109
+
110
+ (_this2$props$iframePr = _this2.props.iframeProps) === null || _this2$props$iframePr === void 0 ? void 0 : (_this2$props$iframePr2 = _this2$props$iframePr.setIsLoading) === null || _this2$props$iframePr2 === void 0 ? void 0 : _this2$props$iframePr2.call(_this2$props$iframePr, false);
102
111
  });
103
112
  }
104
113
  }, {
@@ -127,6 +136,11 @@ var IntentIframe = /*#__PURE__*/function (_React$Component) {
127
136
  return IntentIframe;
128
137
  }(React.Component);
129
138
 
139
+ export var iframeProps = PropTypes.shape({
140
+ wrapperProps: PropTypes.object,
141
+ spinnerProps: PropTypes.object,
142
+ setIsLoading: PropTypes.func
143
+ });
130
144
  IntentIframe.propTypes = {
131
145
  action: PropTypes.string.isRequired,
132
146
  create: PropTypes.func,
@@ -135,10 +149,7 @@ IntentIframe.propTypes = {
135
149
  onCancel: PropTypes.func,
136
150
  onError: PropTypes.func,
137
151
  onTerminate: PropTypes.func.isRequired,
138
- iframeProps: PropTypes.shape({
139
- wrapperProps: PropTypes.object,
140
- spinnerProps: PropTypes.object
141
- }),
152
+ iframeProps: iframeProps,
142
153
  onHideCross: PropTypes.func,
143
154
  onShowCross: PropTypes.func
144
155
  };
@@ -1 +1 @@
1
- export { default } from './IntentIframe';
1
+ export { default, iframeProps } from './IntentIframe';
@@ -0,0 +1,74 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useState } from 'react';
3
+ import Button from "cozy-ui/transpiled/react/Buttons";
4
+ import Empty from "cozy-ui/transpiled/react/Empty";
5
+ import Backdrop from "cozy-ui/transpiled/react/Backdrop";
6
+ import IntentDialogOpener from "cozy-ui/transpiled/react/IntentDialogOpener";
7
+ import IlluGenericNewPage from "cozy-ui/transpiled/react/Viewer/assets/IlluGenericNewPage.svg";
8
+ import { withViewerLocales } from "cozy-ui/transpiled/react/Viewer/hoc/withViewerLocales";
9
+ var styles = {
10
+ "viewer-imageviewer": "styles__viewer-imageviewer___26k0p",
11
+ "viewer-noviewer": "styles__viewer-noviewer___auG-6",
12
+ "viewer-audioviewer": "styles__viewer-audioviewer___1OQPB",
13
+ "viewer-videoviewer": "styles__viewer-videoviewer___NhFoe",
14
+ "viewer-pdfviewer": "styles__viewer-pdfviewer___1gTP9",
15
+ "viewer-textviewer": "styles__viewer-textviewer___3u5Zw",
16
+ "viewer-canceled": "styles__viewer-canceled___pOA_O",
17
+ "viewer-textviewer-content": "styles__viewer-textviewer-content___PB-c3",
18
+ "viewer-filename": "styles__viewer-filename___3jZCt",
19
+ "viewer-pdfviewer-pdf": "styles__viewer-pdfviewer-pdf___16ID9",
20
+ "viewer-pdfviewer-page": "styles__viewer-pdfviewer-page___2RPuw",
21
+ "viewer-pdfviewer-toolbar": "styles__viewer-pdfviewer-toolbar___3NXOk",
22
+ "viewer-pdfMobile": "styles__viewer-pdfMobile___25FPg",
23
+ "viewer-pdfMobile--image": "styles__viewer-pdfMobile--image___3gpFL"
24
+ };
25
+
26
+ var BlankPaperViewer = function BlankPaperViewer(_ref) {
27
+ var _file$metadata, _file$metadata$qualif;
28
+
29
+ var file = _ref.file,
30
+ t = _ref.t;
31
+
32
+ var _useState = useState(true),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ isLoading = _useState2[0],
35
+ setIsLoading = _useState2[1];
36
+
37
+ return /*#__PURE__*/React.createElement("div", {
38
+ className: styles['viewer-noviewer']
39
+ }, /*#__PURE__*/React.createElement(Empty, {
40
+ icon: /*#__PURE__*/React.createElement("img", {
41
+ src: IlluGenericNewPage
42
+ }),
43
+ text: t('Viewer.noImage'),
44
+ componentsProps: {
45
+ text: {
46
+ color: 'inherit'
47
+ }
48
+ }
49
+ }, /*#__PURE__*/React.createElement(IntentDialogOpener, {
50
+ action: "OPEN",
51
+ doctype: "io.cozy.files.paper",
52
+ Component: Backdrop,
53
+ invisible: !isLoading,
54
+ isOver: true,
55
+ options: {
56
+ fileId: file._id,
57
+ qualificationLabel: (_file$metadata = file.metadata) === null || _file$metadata === void 0 ? void 0 : (_file$metadata$qualif = _file$metadata.qualification) === null || _file$metadata$qualif === void 0 ? void 0 : _file$metadata$qualif.label
58
+ },
59
+ showCloseButton: false,
60
+ iframeProps: {
61
+ spinnerProps: {
62
+ className: 'u-m-0',
63
+ middle: true,
64
+ color: 'white'
65
+ },
66
+ setIsLoading: setIsLoading
67
+ }
68
+ }, /*#__PURE__*/React.createElement(Button, {
69
+ className: "u-mt-1",
70
+ label: t('Viewer.complete')
71
+ }))));
72
+ };
73
+
74
+ export default withViewerLocales(BlankPaperViewer);
@@ -0,0 +1,10 @@
1
+ <svg width="128" height="128" viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M0 4C0 1.79086 1.79086 0 4 0H29.3333C30.8061 0 32 1.19391 32 2.66667C32 4.13943 30.8061 5.33333 29.3333 5.33333L5.33333 5.33333V29.3333C5.33333 30.8061 4.13943 32 2.66667 32C1.19391 32 0 30.8061 0 29.3333V4Z" fill="#B3D3FF"/>
3
+ <path d="M0 124C0 126.209 1.79086 128 4 128H29.3333C30.8061 128 32 126.806 32 125.333C32 123.861 30.8061 122.667 29.3333 122.667H5.33333V98.6667C5.33333 97.1939 4.13943 96 2.66667 96C1.19391 96 0 97.1939 0 98.6667V124Z" fill="#B3D3FF"/>
4
+ <path d="M124 0C126.209 0 128 1.79086 128 4V29.3333C128 30.8061 126.806 32 125.333 32C123.861 32 122.667 30.8061 122.667 29.3333V5.33333L98.6667 5.33333C97.1939 5.33333 96 4.13943 96 2.66667C96 1.19391 97.1939 0 98.6667 0H124Z" fill="#B3D3FF"/>
5
+ <path d="M128 98.6667V124C128 126.209 126.209 128 124 128H98.6667C97.1939 128 96 126.806 96 125.333C96 123.861 97.1939 122.667 98.6667 122.667H122.667V98.6667C122.667 97.1939 123.861 96 125.333 96C126.806 96 128 97.1939 128 98.6667Z" fill="#B3D3FF"/>
6
+ <path d="M30.0876 89.1458C29.5095 91.8804 29.0759 94.471 29.5095 96.9177C30.2322 101.236 33.7011 102.963 38.0372 103.97C39.9162 104.402 42.0842 104.69 43.8187 104.834C52.4909 105.841 67.0892 106.273 75.906 107.136C78.6522 107.568 81.3985 107.712 84.0001 107.856C85.1564 107.856 86.1682 107.856 87.18 107.856C88.1917 108 89.2035 108 90.2152 108C95.1295 108 96.7194 104.978 97.2976 100.948C97.4421 100.372 97.5867 99.7963 97.7312 99.0766C97.7312 98.7888 97.7312 98.357 97.7312 98.0692C97.7312 97.6374 97.7312 97.2056 97.8757 96.9178C98.4539 94.1832 98.8875 91.4486 99.3211 88.714C99.3211 88.4262 99.4657 87.9944 99.4657 87.7065C100.333 83.3888 103.657 64.8224 105.103 50.8617C106.114 45.6803 108.861 36.0373 103.224 33.0149C99.8993 31.2878 47.7212 26.8261 45.5532 26.6822C42.8069 26.5383 41.217 27.4018 40.3498 28.985C39.6271 29.7046 39.338 30.7121 39.049 32.0074C37.8927 35.3177 30.3767 82.5252 30.0876 89.1458Z" fill="#B3D3FF"/>
7
+ <path d="M28.2551 88.6304C27.9636 91.3461 27.8178 93.9187 28.4008 96.3485C29.5668 100.493 33.3563 101.923 37.7287 102.351C39.7692 102.637 41.8097 102.637 43.5586 102.637C52.3035 102.78 64.2549 102.351 73.1456 102.351C75.9148 102.494 78.684 102.494 81.4532 102.209C82.6192 102.209 83.7852 102.209 84.6597 102.066C85.6799 102.066 86.7002 102.066 87.7204 101.923C92.6759 101.494 93.8418 98.2066 93.9876 94.3475C94.1333 93.6329 94.2791 93.0612 94.2791 92.2036C94.2791 91.9178 94.2791 91.489 94.1333 91.2031C94.1333 90.7743 94.1333 90.3456 94.2791 90.0597C94.5706 87.3441 94.7163 84.6285 94.8621 81.7699C94.8621 81.4841 94.8621 81.0553 94.8621 80.7694C95.2993 76.4816 96.7568 57.7581 96.7568 43.7512C97.1941 38.7487 98.943 28.8867 92.9674 26.4569C89.4694 25.0277 39.4777 25.3135 37.1457 25.4565C34.3765 25.5994 32.919 26.5999 32.0445 28.1721C31.4615 28.8867 31.17 30.0301 31.0243 31.3165C30.587 34.7467 27.6721 82.0558 28.2551 88.6304Z" fill="#297EF2"/>
8
+ <path d="M27.3492 89.0204C27.4924 91.7375 27.7789 94.3116 28.6383 96.5997C30.3572 100.604 34.2245 101.462 38.5215 101.319C40.5268 101.319 42.5321 101.033 44.2509 100.747C52.8451 99.6028 61.7256 99.3168 70.3197 98.0298C73.0412 97.7437 75.7627 97.3147 78.3409 96.7427C79.4868 96.4567 80.4894 96.3137 81.3488 96.0277C82.3515 95.8847 83.3541 95.7417 84.2135 95.4557C88.9403 94.3116 89.6565 91.0225 89.2268 87.0183C89.2268 86.4463 89.2268 85.7313 89.2268 85.0163C89.2268 84.7303 89.0835 84.3013 88.9403 84.1582C88.9403 83.7292 88.9403 83.3002 88.7971 83.0142C88.6538 80.2971 88.5106 77.58 88.0809 74.7199C88.0809 74.4339 88.0809 74.0049 87.9377 73.7189C87.6512 69.4287 86.3621 50.695 84.3568 36.8235C84.0703 31.6753 84.3568 21.6649 78.1977 20.0919C74.6168 19.2338 28.6383 24.668 26.3466 25.0971C23.7683 25.6691 22.336 26.8131 21.9063 28.5292C21.3333 29.3872 21.3333 30.3882 21.3333 31.8183C21.763 35.2504 25.9169 82.5852 27.3492 89.0204Z" fill="#B3D3FF"/>
9
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M35.7958 40.7716C41.1805 40.1972 46.6011 39.6587 52.0218 39.1203L52.0219 39.1203C57.4425 38.5818 62.8631 38.0433 68.2478 37.469C70.5453 37.1818 70.2581 33.592 67.9606 33.8791C57.1911 34.8843 46.2781 36.033 35.5086 37.1818C33.0675 37.3254 33.4983 40.9152 35.7958 40.7716ZM46.5729 47.3879L46.5729 47.3879L46.5728 47.3879C45.1604 47.5673 42.7233 47.8769 36.9445 48.5256C34.647 48.8128 34.3598 45.2229 36.5137 44.9358C38.5044 44.6789 40.0867 44.4731 41.3642 44.3069L41.3643 44.3069C45.1248 43.8178 46.2448 43.6721 47.3691 43.5787C47.846 43.5391 48.3237 43.5089 49.004 43.4658L49.0041 43.4658C49.8302 43.4136 50.9549 43.3425 52.7397 43.2127C55.0372 43.0691 55.468 46.6589 53.1705 46.8025L52.6398 46.8411L52.6396 46.8411C49.8467 47.0441 48.947 47.1095 48.0509 47.2076C47.625 47.2542 47.2 47.3082 46.5729 47.3879ZM43.4879 55.3257L43.4882 55.3257L43.4883 55.3257L43.4883 55.3257L43.4883 55.3257L43.4883 55.3257L43.4883 55.3257C47.2575 55.0107 51.066 54.6925 54.7501 54.1257C57.0476 53.8386 56.6168 50.2487 54.3193 50.5359C51.2189 51.0129 48.0305 51.2698 44.8514 51.526C42.2884 51.7325 39.7315 51.9385 37.2318 52.259C34.7907 52.4026 35.3651 56.136 37.6625 55.8489C39.5784 55.6524 41.5278 55.4895 43.4879 55.3257ZM62.2168 67.1927C54.3192 67.6235 52.5961 67.7671 38.524 69.0594C36.2265 69.3466 35.9393 65.7568 38.2368 65.4696C48.7943 64.2208 52.531 64.0491 57.5355 63.819L57.5365 63.819C58.8619 63.7581 60.2762 63.6931 61.9296 63.6029C64.2271 63.4593 64.5143 67.0491 62.2168 67.1927ZM41.4373 81.1075L41.4371 81.1075L40.2472 81.2648C37.9497 81.552 38.3805 85.1418 40.678 84.8546C49.1809 83.987 51.0257 83.7484 53.1498 83.4738L53.1499 83.4738C54.5411 83.2939 56.0521 83.0985 59.6323 82.7007C61.9298 82.4135 61.6426 78.8237 59.2015 79.1109C50.3738 79.9258 48.0971 80.2268 41.4373 81.1075ZM38.8112 73.5108C49.5806 72.362 60.4937 71.2133 71.2632 70.2082C73.5607 69.921 73.9914 73.5108 71.5504 73.798C66.1656 74.3724 60.745 74.9108 55.3244 75.4493C49.9037 75.9878 44.4831 76.5262 39.0984 77.1006C36.8009 77.3878 36.5137 73.798 38.8112 73.5108Z" fill="#297EF2"/>
10
+ </svg>
@@ -1,20 +1,27 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { isMobile as isMobileDevice } from 'cozy-device-helper';
4
- import { models } from 'cozy-client';
4
+ import { isPlainText } from 'cozy-client/dist/models/file';
5
5
  import { FileDoctype } from "cozy-ui/transpiled/react/proptypes";
6
6
  import withBreakpoints from "cozy-ui/transpiled/react/helpers/withBreakpoints";
7
7
  import ImageViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/ImageViewer";
8
8
  import AudioViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/AudioViewer";
9
9
  import VideoViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/VideoViewer";
10
10
  import PdfJsViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/PdfJsViewer";
11
+ import BlankPaperViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/BlankPaperViewer";
11
12
  import TextViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/TextViewer";
12
13
  import PdfMobileViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/PdfMobileViewer";
13
14
  import NoViewer from "cozy-ui/transpiled/react/Viewer/NoViewer";
14
15
  import ShortcutViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/ShortcutViewer";
15
16
  import OnlyOfficeViewer from "cozy-ui/transpiled/react/Viewer/ViewersByFile/OnlyOfficeViewer";
16
17
  import { useEncrypted } from "cozy-ui/transpiled/react/Viewer/providers/EncryptedProvider";
17
- var isPlainText = models.file.isPlainText;
18
+
19
+ var isBlankPaper = function isBlankPaper(doc) {
20
+ var _doc$metadata, _doc$metadata$paperPr;
21
+
22
+ return (_doc$metadata = doc.metadata) === null || _doc$metadata === void 0 ? void 0 : (_doc$metadata$paperPr = _doc$metadata.paperProps) === null || _doc$metadata$paperPr === void 0 ? void 0 : _doc$metadata$paperPr.isBlank;
23
+ };
24
+
18
25
  export var getViewerComponentName = function getViewerComponentName(_ref) {
19
26
  var file = _ref.file,
20
27
  isDesktop = _ref.isDesktop,
@@ -34,7 +41,7 @@ export var getViewerComponentName = function getViewerComponentName(_ref) {
34
41
  return isMobileDevice() ? NoViewer : VideoViewer;
35
42
 
36
43
  case 'pdf':
37
- return isDesktop ? PdfJsViewer : PdfMobileViewer;
44
+ return isBlankPaper(file) ? BlankPaperViewer : isDesktop ? PdfJsViewer : PdfMobileViewer;
38
45
 
39
46
  case 'text':
40
47
  return isPlainText(file.mime, file.name) ? TextViewer : isOnlyOfficeEnabled ? OnlyOfficeViewer : NoViewer;
@@ -9,6 +9,8 @@ var en = {
9
9
  },
10
10
  close: "close",
11
11
  download: "Download",
12
+ complete: "Complete the document",
13
+ noImage: "No image",
12
14
  error: {
13
15
  downloadFile: {
14
16
  offline: "You should be connected to download this file"
@@ -73,6 +75,8 @@ var fr = {
73
75
  },
74
76
  close: "Fermer",
75
77
  download: "T\xE9l\xE9charger",
78
+ complete: "Compl\xE9ter le document",
79
+ noImage: "Aucune image",
76
80
  error: {
77
81
  downloadFile: {
78
82
  offline: "Vous devez \xEAtre connect\xE9 pour t\xE9l\xE9charger ce fichier"
@@ -0,0 +1,104 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import React, { useEffect, useMemo, useState, createContext, useContext } from 'react';
6
+ import { useClient } from 'cozy-client';
7
+ import Spinner from 'cozy-ui/transpiled/react/Spinner';
8
+ import Backdrop from 'cozy-ui/transpiled/react/Backdrop';
9
+ export var IntentContext = /*#__PURE__*/createContext();
10
+ export var useIntent = function useIntent() {
11
+ var context = useContext(IntentContext);
12
+
13
+ if (!context) {
14
+ throw new Error('useIntent must be used within a IntentProvider');
15
+ }
16
+
17
+ return context;
18
+ };
19
+
20
+ var IntentProvider = function IntentProvider(_ref) {
21
+ var intentId = _ref.intentId,
22
+ componentsProps = _ref.componentsProps,
23
+ children = _ref.children;
24
+ var client = useClient();
25
+
26
+ var _useState = useState({
27
+ service: null,
28
+ intent: null,
29
+ data: null
30
+ }),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ state = _useState2[0],
33
+ setState = _useState2[1];
34
+
35
+ var value = useMemo(function () {
36
+ return {
37
+ service: state.service,
38
+ intent: state.intent,
39
+ data: state.data
40
+ };
41
+ }, [state]);
42
+ useEffect(function () {
43
+ var startService = /*#__PURE__*/function () {
44
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
45
+ var service, intent, data;
46
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
47
+ while (1) {
48
+ switch (_context.prev = _context.next) {
49
+ case 0:
50
+ _context.prev = 0;
51
+ _context.next = 3;
52
+ return client.intents.createService(intentId, window);
53
+
54
+ case 3:
55
+ service = _context.sent;
56
+ intent = service.getIntent();
57
+ data = service.getData();
58
+ setState({
59
+ service: service,
60
+ intent: intent,
61
+ data: data
62
+ });
63
+ _context.next = 12;
64
+ break;
65
+
66
+ case 9:
67
+ _context.prev = 9;
68
+ _context.t0 = _context["catch"](0);
69
+ service.throw(_context.t0);
70
+
71
+ case 12:
72
+ case "end":
73
+ return _context.stop();
74
+ }
75
+ }
76
+ }, _callee, null, [[0, 9]]);
77
+ }));
78
+
79
+ return function startService() {
80
+ return _ref2.apply(this, arguments);
81
+ };
82
+ }();
83
+
84
+ if (!state.service) {
85
+ startService();
86
+ }
87
+ }, [client, intentId, state.service]);
88
+
89
+ if (!state.service) {
90
+ return /*#__PURE__*/React.createElement(Backdrop, _extends({
91
+ open: true
92
+ }, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.backdrop), /*#__PURE__*/React.createElement(Spinner, _extends({
93
+ className: "u-m-0",
94
+ size: "xxlarge",
95
+ middle: true
96
+ }, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.spinner)));
97
+ }
98
+
99
+ return /*#__PURE__*/React.createElement(IntentContext.Provider, {
100
+ value: value
101
+ }, children);
102
+ };
103
+
104
+ export default IntentProvider;