cozy-ui 121.1.2 → 121.3.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/assets/icons/twake/illus/twake_workplace.svg +1 -0
  3. package/dist/cozy-ui.min.css +1 -1
  4. package/package.json +1 -1
  5. package/react/Buttons/Readme.md +37 -2
  6. package/react/Buttons/index.jsx +16 -3
  7. package/react/Icon/Readme.md +3 -1
  8. package/react/Icons/TwakeWorkplace.jsx +83 -0
  9. package/react/Layout/Layout.jsx +3 -1
  10. package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +24 -3
  11. package/react/MuiCozyTheme/overrides/twake/makeLightNormalOverrides.js +16 -1
  12. package/react/Sidebar/index.jsx +7 -1
  13. package/react/UploadQueue/FileUploadProgress.jsx +49 -0
  14. package/react/UploadQueue/Item.jsx +99 -0
  15. package/react/UploadQueue/Pending.jsx +12 -0
  16. package/react/UploadQueue/Readme.md +10 -3
  17. package/react/UploadQueue/RemainingTime.jsx +26 -0
  18. package/react/UploadQueue/helpers.js +3 -0
  19. package/react/UploadQueue/index.jsx +3 -172
  20. package/react/UploadQueue/styles.styl +4 -2
  21. package/react/UploadQueue/useStatusIcon.js +34 -0
  22. package/stylus/objects/layouts.styl +12 -2
  23. package/stylus/objects/sidebar.styl +6 -1
  24. package/transpiled/react/Buttons/index.js +7 -4
  25. package/transpiled/react/Icons/TwakeWorkplace.js +86 -0
  26. package/transpiled/react/Layout/Layout.js +6 -2
  27. package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +24 -3
  28. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +24 -3
  29. package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +24 -3
  30. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +24 -3
  31. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +24 -3
  32. package/transpiled/react/MuiCozyTheme/overrides/twake/makeDarkInvertedOverrides.d.ts +40 -4
  33. package/transpiled/react/MuiCozyTheme/overrides/twake/makeDarkNormalOverrides.d.ts +40 -4
  34. package/transpiled/react/MuiCozyTheme/overrides/twake/makeLightInvertedOverrides.d.ts +40 -4
  35. package/transpiled/react/MuiCozyTheme/overrides/twake/makeLightNormalOverrides.d.ts +40 -4
  36. package/transpiled/react/MuiCozyTheme/overrides/twake/makeLightNormalOverrides.js +16 -1
  37. package/transpiled/react/Sidebar/index.js +6 -2
  38. package/transpiled/react/UploadQueue/FileUploadProgress.js +66 -0
  39. package/transpiled/react/UploadQueue/Item.js +106 -0
  40. package/transpiled/react/UploadQueue/Pending.js +10 -0
  41. package/transpiled/react/UploadQueue/RemainingTime.js +43 -0
  42. package/transpiled/react/UploadQueue/helpers.js +4 -0
  43. package/transpiled/react/UploadQueue/index.js +5 -169
  44. package/transpiled/react/UploadQueue/useStatusIcon.js +45 -0
  45. package/transpiled/react/stylesheet.css +1 -1
@@ -151,9 +151,16 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
151
151
  MuiButton: {
152
152
  root: {
153
153
  borderRadius: 2,
154
- height: '2.5rem',
155
154
  lineHeight: 'normal',
156
155
  padding: '0 1rem',
156
+ '&.customSize': {
157
+ '&-default': {
158
+ height: '2.5rem'
159
+ },
160
+ '&-auto': {
161
+ minHeight: '2.5rem'
162
+ }
163
+ },
157
164
  '&.ghost': {
158
165
  borderStyle: 'dashed !important',
159
166
  // important needed to override disable state
@@ -164,15 +171,29 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
164
171
  }
165
172
  },
166
173
  sizeSmall: {
167
- height: '2rem',
168
174
  padding: '0 0.75rem',
175
+ '&.customSize': {
176
+ '&-default': {
177
+ height: '2rem'
178
+ },
179
+ '&-auto': {
180
+ minHeight: '2rem'
181
+ }
182
+ },
169
183
  '&$text': {
170
184
  padding: '8px 6px'
171
185
  }
172
186
  },
173
187
  sizeLarge: {
174
- height: '3rem',
175
188
  padding: '0 1.25rem',
189
+ '&.customSize': {
190
+ '&-default': {
191
+ height: '3rem'
192
+ },
193
+ '&-auto': {
194
+ minHeight: '3rem'
195
+ }
196
+ },
176
197
  '&$text': {
177
198
  padding: '14px 10px'
178
199
  }
@@ -139,9 +139,16 @@ export function makeDarkInvertedTwakeOverrides(theme: any): {
139
139
  MuiButton: {
140
140
  root: {
141
141
  borderRadius: number;
142
- height: string;
143
142
  lineHeight: string;
144
143
  padding: string;
144
+ '&.customSize': {
145
+ '&-default': {
146
+ height: string;
147
+ };
148
+ '&-auto': {
149
+ minHeight: string;
150
+ };
151
+ };
145
152
  '&.ghost': {
146
153
  borderStyle: string;
147
154
  '&:hover': {
@@ -150,15 +157,29 @@ export function makeDarkInvertedTwakeOverrides(theme: any): {
150
157
  };
151
158
  };
152
159
  sizeSmall: {
153
- height: string;
154
160
  padding: string;
161
+ '&.customSize': {
162
+ '&-default': {
163
+ height: string;
164
+ };
165
+ '&-auto': {
166
+ minHeight: string;
167
+ };
168
+ };
155
169
  '&$text': {
156
170
  padding: string;
157
171
  };
158
172
  };
159
173
  sizeLarge: {
160
- height: string;
161
174
  padding: string;
175
+ '&.customSize': {
176
+ '&-default': {
177
+ height: string;
178
+ };
179
+ '&-auto': {
180
+ minHeight: string;
181
+ };
182
+ };
162
183
  '&$text': {
163
184
  padding: string;
164
185
  };
@@ -1621,6 +1642,14 @@ export function makeDarkInvertedTwakeOverrides(theme: any): {
1621
1642
  };
1622
1643
  };
1623
1644
  };
1645
+ MuiLinearProgress: {
1646
+ root: {
1647
+ height: number;
1648
+ };
1649
+ colorPrimary: {
1650
+ backgroundColor: any;
1651
+ };
1652
+ };
1624
1653
  MuiButton: {
1625
1654
  root: {
1626
1655
  borderRadius: number;
@@ -1633,8 +1662,15 @@ export function makeDarkInvertedTwakeOverrides(theme: any): {
1633
1662
  };
1634
1663
  };
1635
1664
  sizeSmall: {
1636
- height: string;
1637
1665
  padding: string;
1666
+ '&.customSize': {
1667
+ '&-default': {
1668
+ height: string;
1669
+ };
1670
+ '&-auto': {
1671
+ minHeight: string;
1672
+ };
1673
+ };
1638
1674
  '&$text': {
1639
1675
  padding: string;
1640
1676
  };
@@ -139,9 +139,16 @@ export function makeDarkNormalTwakeOverrides(theme: any): {
139
139
  MuiButton: {
140
140
  root: {
141
141
  borderRadius: number;
142
- height: string;
143
142
  lineHeight: string;
144
143
  padding: string;
144
+ '&.customSize': {
145
+ '&-default': {
146
+ height: string;
147
+ };
148
+ '&-auto': {
149
+ minHeight: string;
150
+ };
151
+ };
145
152
  '&.ghost': {
146
153
  borderStyle: string;
147
154
  '&:hover': {
@@ -150,15 +157,29 @@ export function makeDarkNormalTwakeOverrides(theme: any): {
150
157
  };
151
158
  };
152
159
  sizeSmall: {
153
- height: string;
154
160
  padding: string;
161
+ '&.customSize': {
162
+ '&-default': {
163
+ height: string;
164
+ };
165
+ '&-auto': {
166
+ minHeight: string;
167
+ };
168
+ };
155
169
  '&$text': {
156
170
  padding: string;
157
171
  };
158
172
  };
159
173
  sizeLarge: {
160
- height: string;
161
174
  padding: string;
175
+ '&.customSize': {
176
+ '&-default': {
177
+ height: string;
178
+ };
179
+ '&-auto': {
180
+ minHeight: string;
181
+ };
182
+ };
162
183
  '&$text': {
163
184
  padding: string;
164
185
  };
@@ -1621,6 +1642,14 @@ export function makeDarkNormalTwakeOverrides(theme: any): {
1621
1642
  };
1622
1643
  };
1623
1644
  };
1645
+ MuiLinearProgress: {
1646
+ root: {
1647
+ height: number;
1648
+ };
1649
+ colorPrimary: {
1650
+ backgroundColor: any;
1651
+ };
1652
+ };
1624
1653
  MuiButton: {
1625
1654
  root: {
1626
1655
  borderRadius: number;
@@ -1633,8 +1662,15 @@ export function makeDarkNormalTwakeOverrides(theme: any): {
1633
1662
  };
1634
1663
  };
1635
1664
  sizeSmall: {
1636
- height: string;
1637
1665
  padding: string;
1666
+ '&.customSize': {
1667
+ '&-default': {
1668
+ height: string;
1669
+ };
1670
+ '&-auto': {
1671
+ minHeight: string;
1672
+ };
1673
+ };
1638
1674
  '&$text': {
1639
1675
  padding: string;
1640
1676
  };
@@ -139,9 +139,16 @@ export function makeLightInvertedTwakeOverrides(theme: any): {
139
139
  MuiButton: {
140
140
  root: {
141
141
  borderRadius: number;
142
- height: string;
143
142
  lineHeight: string;
144
143
  padding: string;
144
+ '&.customSize': {
145
+ '&-default': {
146
+ height: string;
147
+ };
148
+ '&-auto': {
149
+ minHeight: string;
150
+ };
151
+ };
145
152
  '&.ghost': {
146
153
  borderStyle: string;
147
154
  '&:hover': {
@@ -150,15 +157,29 @@ export function makeLightInvertedTwakeOverrides(theme: any): {
150
157
  };
151
158
  };
152
159
  sizeSmall: {
153
- height: string;
154
160
  padding: string;
161
+ '&.customSize': {
162
+ '&-default': {
163
+ height: string;
164
+ };
165
+ '&-auto': {
166
+ minHeight: string;
167
+ };
168
+ };
155
169
  '&$text': {
156
170
  padding: string;
157
171
  };
158
172
  };
159
173
  sizeLarge: {
160
- height: string;
161
174
  padding: string;
175
+ '&.customSize': {
176
+ '&-default': {
177
+ height: string;
178
+ };
179
+ '&-auto': {
180
+ minHeight: string;
181
+ };
182
+ };
162
183
  '&$text': {
163
184
  padding: string;
164
185
  };
@@ -1621,6 +1642,14 @@ export function makeLightInvertedTwakeOverrides(theme: any): {
1621
1642
  };
1622
1643
  };
1623
1644
  };
1645
+ MuiLinearProgress: {
1646
+ root: {
1647
+ height: number;
1648
+ };
1649
+ colorPrimary: {
1650
+ backgroundColor: any;
1651
+ };
1652
+ };
1624
1653
  MuiButton: {
1625
1654
  root: {
1626
1655
  borderRadius: number;
@@ -1633,8 +1662,15 @@ export function makeLightInvertedTwakeOverrides(theme: any): {
1633
1662
  };
1634
1663
  };
1635
1664
  sizeSmall: {
1636
- height: string;
1637
1665
  padding: string;
1666
+ '&.customSize': {
1667
+ '&-default': {
1668
+ height: string;
1669
+ };
1670
+ '&-auto': {
1671
+ minHeight: string;
1672
+ };
1673
+ };
1638
1674
  '&$text': {
1639
1675
  padding: string;
1640
1676
  };
@@ -139,9 +139,16 @@ export function makeLightNormalTwakeOverrides(theme: any): {
139
139
  MuiButton: {
140
140
  root: {
141
141
  borderRadius: number;
142
- height: string;
143
142
  lineHeight: string;
144
143
  padding: string;
144
+ '&.customSize': {
145
+ '&-default': {
146
+ height: string;
147
+ };
148
+ '&-auto': {
149
+ minHeight: string;
150
+ };
151
+ };
145
152
  '&.ghost': {
146
153
  borderStyle: string;
147
154
  '&:hover': {
@@ -150,15 +157,29 @@ export function makeLightNormalTwakeOverrides(theme: any): {
150
157
  };
151
158
  };
152
159
  sizeSmall: {
153
- height: string;
154
160
  padding: string;
161
+ '&.customSize': {
162
+ '&-default': {
163
+ height: string;
164
+ };
165
+ '&-auto': {
166
+ minHeight: string;
167
+ };
168
+ };
155
169
  '&$text': {
156
170
  padding: string;
157
171
  };
158
172
  };
159
173
  sizeLarge: {
160
- height: string;
161
174
  padding: string;
175
+ '&.customSize': {
176
+ '&-default': {
177
+ height: string;
178
+ };
179
+ '&-auto': {
180
+ minHeight: string;
181
+ };
182
+ };
162
183
  '&$text': {
163
184
  padding: string;
164
185
  };
@@ -1621,6 +1642,14 @@ export function makeLightNormalTwakeOverrides(theme: any): {
1621
1642
  };
1622
1643
  };
1623
1644
  };
1645
+ MuiLinearProgress: {
1646
+ root: {
1647
+ height: number;
1648
+ };
1649
+ colorPrimary: {
1650
+ backgroundColor: any;
1651
+ };
1652
+ };
1624
1653
  MuiButton: {
1625
1654
  root: {
1626
1655
  borderRadius: number;
@@ -1633,8 +1662,15 @@ export function makeLightNormalTwakeOverrides(theme: any): {
1633
1662
  };
1634
1663
  };
1635
1664
  sizeSmall: {
1636
- height: string;
1637
1665
  padding: string;
1666
+ '&.customSize': {
1667
+ '&-default': {
1668
+ height: string;
1669
+ };
1670
+ '&-auto': {
1671
+ minHeight: string;
1672
+ };
1673
+ };
1638
1674
  '&$text': {
1639
1675
  padding: string;
1640
1676
  };
@@ -63,6 +63,14 @@ export var makeLightNormalTwakeOverrides = function makeLightNormalTwakeOverride
63
63
  }
64
64
  }
65
65
  },
66
+ MuiLinearProgress: {
67
+ root: {
68
+ height: 3
69
+ },
70
+ colorPrimary: {
71
+ backgroundColor: theme.palette.divider
72
+ }
73
+ },
66
74
  MuiButton: {
67
75
  root: {
68
76
  borderRadius: 100,
@@ -75,8 +83,15 @@ export var makeLightNormalTwakeOverrides = function makeLightNormalTwakeOverride
75
83
  }
76
84
  },
77
85
  sizeSmall: {
78
- height: '2.25rem',
79
86
  padding: '10px 16px',
87
+ '&.customSize': {
88
+ '&-default': {
89
+ height: '2.25rem'
90
+ },
91
+ '&-auto': {
92
+ minHeight: '2.25rem'
93
+ }
94
+ },
80
95
  '&$text': {
81
96
  padding: '8px 16px'
82
97
  }
@@ -1,4 +1,5 @@
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
4
  var _excluded = ["children", "className"];
4
5
  import { useTheme } from '@material-ui/core';
@@ -6,8 +7,11 @@ import cx from 'classnames';
6
7
  import PropTypes from 'prop-types';
7
8
  import React from 'react';
8
9
  var styles = {
9
- "o-sidebar": "styles__o-sidebar___1295j"
10
+ "o-sidebar": "styles__o-sidebar___1295j",
11
+ "o-sidebar--border": "styles__o-sidebar--border___32tfw",
12
+ "o-sidebar--large": "styles__o-sidebar--large___1mT8H"
10
13
  };
14
+ import { isTwakeTheme } from "cozy-ui/transpiled/react/helpers/isTwakeTheme";
11
15
  import { useSetFlagshipUI } from "cozy-ui/transpiled/react/hooks/useSetFlagshipUi/useSetFlagshipUI";
12
16
  import { useCozyTheme } from "cozy-ui/transpiled/react/providers/CozyTheme";
13
17
 
@@ -29,7 +33,7 @@ var Sidebar = function Sidebar(_ref) {
29
33
  }, 'cozy-ui/Sidebar');
30
34
  return /*#__PURE__*/React.createElement("aside", _extends({
31
35
  id: "sidebar",
32
- className: cx(styles['o-sidebar'], className)
36
+ className: cx(styles['o-sidebar'], _defineProperty({}, styles['o-sidebar--border'], !isTwakeTheme()), _defineProperty({}, styles['o-sidebar--large'], isTwakeTheme()), className)
33
37
  }, restProps), children);
34
38
  };
35
39
 
@@ -0,0 +1,66 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import LinearProgress from '@material-ui/core/LinearProgress';
3
+ import React, { useState } from 'react';
4
+ import { useIntervalWhen } from 'rooks';
5
+ import RemainingTime from "cozy-ui/transpiled/react/UploadQueue/RemainingTime";
6
+ var styles = {
7
+ "upload-queue": "styles__upload-queue___1VtNK",
8
+ "upload-queue__threshold-bar": "styles__upload-queue__threshold-bar___tTYal",
9
+ "upload-queue__progress-caption": "styles__upload-queue__progress-caption___1-vXY",
10
+ "upload-queue__upload-progress": "styles__upload-queue__upload-progress___1q-uS",
11
+ "upload-queue--popover": "styles__upload-queue--popover___2z1a4",
12
+ "upload-queue--visible": "styles__upload-queue--visible___DjVRs",
13
+ "upload-queue-header": "styles__upload-queue-header___c9Vf2",
14
+ "upload-queue-header-inner": "styles__upload-queue-header-inner___26wpB",
15
+ "upload-queue-progress": "styles__upload-queue-progress___1CmN-",
16
+ "upload-queue-content": "styles__upload-queue-content___3MPHo",
17
+ "upload-queue--collapsed": "styles__upload-queue--collapsed___3cchD",
18
+ "upload-queue-list": "styles__upload-queue-list___OVvJm",
19
+ "upload-queue-item--error": "styles__upload-queue-item--error___2sSeV",
20
+ "upload-queue-item--done": "styles__upload-queue-item--done___2PSJI",
21
+ "item-file": "styles__item-file___1kfDn",
22
+ "item-status": "styles__item-status___3FNcY",
23
+ "spin": "styles__spin___3GZIp",
24
+ "shake": "styles__shake___u1Pks"
25
+ };
26
+ import { withStyles } from "cozy-ui/transpiled/react/styles";
27
+ var FileLinearProgress = withStyles(function (theme) {
28
+ return {
29
+ root: {
30
+ borderRadius: theme.shape.borderRadius
31
+ },
32
+ colorPrimary: {
33
+ backgroundColor: theme.palette.background.default
34
+ },
35
+ barColorPrimary: {
36
+ backgroundColor: 'var(--emerald)'
37
+ }
38
+ };
39
+ })(LinearProgress);
40
+
41
+ var FileUploadProgress = function FileUploadProgress(_ref) {
42
+ var progressProps = _ref.progress;
43
+
44
+ var _useState = useState(progressProps),
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ progress = _useState2[0],
47
+ setProgress = _useState2[1];
48
+
49
+ useIntervalWhen(function () {
50
+ setProgress(progressProps);
51
+ }, 1000, true, true);
52
+ return /*#__PURE__*/React.createElement("div", {
53
+ className: styles['upload-queue__upload-progress']
54
+ }, /*#__PURE__*/React.createElement("div", {
55
+ className: "u-flex-grow-1 u-pr-1"
56
+ }, /*#__PURE__*/React.createElement(FileLinearProgress, {
57
+ variant: "determinate",
58
+ value: progress.loaded / progress.total * 100
59
+ })), /*#__PURE__*/React.createElement("div", {
60
+ className: "u-flex-shrink"
61
+ }, progress.remainingTime ? /*#__PURE__*/React.createElement(RemainingTime, {
62
+ durationInSec: progress.remainingTime
63
+ }) : null));
64
+ };
65
+
66
+ export default FileUploadProgress;
@@ -0,0 +1,106 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import cx from 'classnames';
3
+ import React from 'react';
4
+ import { splitFilename } from 'cozy-client/dist/models/file';
5
+ import FileUploadProgress from "cozy-ui/transpiled/react/UploadQueue/FileUploadProgress";
6
+ import Pending from "cozy-ui/transpiled/react/UploadQueue/Pending";
7
+ import { uploadStatus } from "cozy-ui/transpiled/react/UploadQueue/index";
8
+ var styles = {
9
+ "upload-queue": "styles__upload-queue___1VtNK",
10
+ "upload-queue__threshold-bar": "styles__upload-queue__threshold-bar___tTYal",
11
+ "upload-queue__progress-caption": "styles__upload-queue__progress-caption___1-vXY",
12
+ "upload-queue__upload-progress": "styles__upload-queue__upload-progress___1q-uS",
13
+ "upload-queue--popover": "styles__upload-queue--popover___2z1a4",
14
+ "upload-queue--visible": "styles__upload-queue--visible___DjVRs",
15
+ "upload-queue-header": "styles__upload-queue-header___c9Vf2",
16
+ "upload-queue-header-inner": "styles__upload-queue-header-inner___26wpB",
17
+ "upload-queue-progress": "styles__upload-queue-progress___1CmN-",
18
+ "upload-queue-content": "styles__upload-queue-content___3MPHo",
19
+ "upload-queue--collapsed": "styles__upload-queue--collapsed___3cchD",
20
+ "upload-queue-list": "styles__upload-queue-list___OVvJm",
21
+ "upload-queue-item--error": "styles__upload-queue-item--error___2sSeV",
22
+ "upload-queue-item--done": "styles__upload-queue-item--done___2PSJI",
23
+ "item-file": "styles__item-file___1kfDn",
24
+ "item-status": "styles__item-status___3FNcY",
25
+ "spin": "styles__spin___3GZIp",
26
+ "shake": "styles__shake___u1Pks"
27
+ };
28
+ import { useStatusIcon } from "cozy-ui/transpiled/react/UploadQueue/useStatusIcon";
29
+ import Icon from "cozy-ui/transpiled/react/Icon";
30
+ import ListItem from "cozy-ui/transpiled/react/ListItem";
31
+ import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
32
+ import ListItemText from "cozy-ui/transpiled/react/ListItemText";
33
+ import Typography from "cozy-ui/transpiled/react/Typography";
34
+ import { Img } from "cozy-ui/transpiled/react/deprecated/Media";
35
+ import { translate } from "cozy-ui/transpiled/react/providers/I18n";
36
+
37
+ var Item = function Item(_ref) {
38
+ var _cx;
39
+
40
+ var file = _ref.file,
41
+ status = _ref.status,
42
+ isDirectory = _ref.isDirectory,
43
+ progress = _ref.progress,
44
+ getMimeTypeIcon = _ref.getMimeTypeIcon;
45
+ var CANCEL = uploadStatus.CANCEL,
46
+ LOADING = uploadStatus.LOADING,
47
+ DONE_STATUSES = uploadStatus.DONE_STATUSES,
48
+ ERROR_STATUSES = uploadStatus.ERROR_STATUSES,
49
+ PENDING = uploadStatus.PENDING;
50
+
51
+ var _splitFilename = splitFilename(file),
52
+ filename = _splitFilename.filename,
53
+ extension = _splitFilename.extension;
54
+
55
+ var done = false;
56
+ var error = false;
57
+ /**
58
+ * Status came from the Upload Queue, but sometimes we're using
59
+ * manual upload without using the Upload Queue system but we're still
60
+ * using the UI component. When this is the case, the file handles on
61
+ * his own its status.
62
+ */
63
+
64
+ var statusToUse = file.status ? file.status : status;
65
+
66
+ if (statusToUse !== LOADING && statusToUse !== CANCEL) {
67
+ if (ERROR_STATUSES.includes(statusToUse)) {
68
+ error = true;
69
+ } else if (DONE_STATUSES.includes(statusToUse)) {
70
+ done = true;
71
+ }
72
+ }
73
+
74
+ var statusIcon = useStatusIcon(statusToUse, progress);
75
+ var isPending = statusToUse !== LOADING && statusToUse !== CANCEL && !ERROR_STATUSES.includes(statusToUse) && !DONE_STATUSES.includes(statusToUse) && statusToUse === PENDING;
76
+ return /*#__PURE__*/React.createElement(ListItem, {
77
+ divider: true,
78
+ "data-testid": "upload-queue-item",
79
+ className: cx((_cx = {}, _defineProperty(_cx, styles['upload-queue-item--done'], done), _defineProperty(_cx, styles['upload-queue-item--error'], error), _cx))
80
+ }, getMimeTypeIcon ? /*#__PURE__*/React.createElement(ListItemIcon, {
81
+ className: "u-ta-center"
82
+ }, /*#__PURE__*/React.createElement(Icon, {
83
+ icon: getMimeTypeIcon(isDirectory, file.name, file.type),
84
+ size: 32,
85
+ className: "u-mr-1"
86
+ })) : null, /*#__PURE__*/React.createElement(ListItemText, {
87
+ disableTypography: true,
88
+ primary: /*#__PURE__*/React.createElement("div", {
89
+ "data-testid": "upload-queue-item-name",
90
+ className: "u-ellipsis"
91
+ }, /*#__PURE__*/React.createElement(Typography, {
92
+ variant: "body1",
93
+ className: "u-ellipsis"
94
+ }, filename, extension && /*#__PURE__*/React.createElement(Typography, {
95
+ component: "span",
96
+ variant: "body1",
97
+ color: "textSecondary",
98
+ className: "u-dib"
99
+ }, extension))),
100
+ secondary: progress ? /*#__PURE__*/React.createElement(FileUploadProgress, {
101
+ progress: progress
102
+ }) : null
103
+ }), statusIcon && /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Img, null, statusIcon)), isPending && /*#__PURE__*/React.createElement(Pending, null));
104
+ };
105
+
106
+ export default translate()(Item);
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import Typography from "cozy-ui/transpiled/react/Typography";
3
+ import { translate } from "cozy-ui/transpiled/react/providers/I18n";
4
+ var Pending = translate()(function (props) {
5
+ return /*#__PURE__*/React.createElement(Typography, {
6
+ variant: "subtitle1",
7
+ color: "primary"
8
+ }, props.t('item.pending'));
9
+ });
10
+ export default Pending;
@@ -0,0 +1,43 @@
1
+ import cx from 'classnames';
2
+ import React from 'react';
3
+ import { numberOfReferencesForPluralForm } from "cozy-ui/transpiled/react/UploadQueue/helpers";
4
+ import { formatRemainingTime } from "cozy-ui/transpiled/react/UploadQueue/index";
5
+ var styles = {
6
+ "upload-queue": "styles__upload-queue___1VtNK",
7
+ "upload-queue__threshold-bar": "styles__upload-queue__threshold-bar___tTYal",
8
+ "upload-queue__progress-caption": "styles__upload-queue__progress-caption___1-vXY",
9
+ "upload-queue__upload-progress": "styles__upload-queue__upload-progress___1q-uS",
10
+ "upload-queue--popover": "styles__upload-queue--popover___2z1a4",
11
+ "upload-queue--visible": "styles__upload-queue--visible___DjVRs",
12
+ "upload-queue-header": "styles__upload-queue-header___c9Vf2",
13
+ "upload-queue-header-inner": "styles__upload-queue-header-inner___26wpB",
14
+ "upload-queue-progress": "styles__upload-queue-progress___1CmN-",
15
+ "upload-queue-content": "styles__upload-queue-content___3MPHo",
16
+ "upload-queue--collapsed": "styles__upload-queue--collapsed___3cchD",
17
+ "upload-queue-list": "styles__upload-queue-list___OVvJm",
18
+ "upload-queue-item--error": "styles__upload-queue-item--error___2sSeV",
19
+ "upload-queue-item--done": "styles__upload-queue-item--done___2PSJI",
20
+ "item-file": "styles__item-file___1kfDn",
21
+ "item-status": "styles__item-status___3FNcY",
22
+ "spin": "styles__spin___3GZIp",
23
+ "shake": "styles__shake___u1Pks"
24
+ };
25
+ import Typography from "cozy-ui/transpiled/react/Typography";
26
+ import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
27
+
28
+ var RemainingTime = function RemainingTime(_ref) {
29
+ var durationInSec = _ref.durationInSec;
30
+
31
+ var _useI18n = useI18n(),
32
+ t = _useI18n.t;
33
+
34
+ return /*#__PURE__*/React.createElement(Typography, {
35
+ variant: "caption",
36
+ className: cx(styles['upload-queue__progress-caption'], 'u-ellipsis')
37
+ }, t('item.remainingTime', {
38
+ time: formatRemainingTime(durationInSec),
39
+ smart_count: numberOfReferencesForPluralForm(durationInSec)
40
+ }));
41
+ };
42
+
43
+ export default RemainingTime;
@@ -0,0 +1,4 @@
1
+ // https://date-fns.org/v2.28.0/docs/formatDistanceToNow
2
+ export var numberOfReferencesForPluralForm = function numberOfReferencesForPluralForm(durationInSec) {
3
+ return durationInSec < 90 || durationInSec > 2670 && durationInSec < 5370 ? 1 : 2;
4
+ };