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
@@ -6,7 +6,6 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
10
9
 
11
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
11
 
@@ -14,9 +13,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
14
13
 
15
14
  import LinearProgress from '@material-ui/core/LinearProgress';
16
15
  import cx from 'classnames';
17
- import React, { Component, useState } from 'react';
18
- import { useIntervalWhen } from 'rooks';
19
- import { splitFilename } from 'cozy-client/dist/models/file';
16
+ import React, { Component } from 'react';
17
+ import Item from "cozy-ui/transpiled/react/UploadQueue/Item";
20
18
  var localeEn = {
21
19
  header: "Uploading %{smart_count} photo to %{app} |||| Uploading %{smart_count} photos to %{app}",
22
20
  header_mobile: "Uploading %{done} of %{smart_count}",
@@ -67,19 +65,9 @@ var styles = {
67
65
  "spin": "styles__spin___3GZIp",
68
66
  "shake": "styles__shake___u1Pks"
69
67
  };
70
- import Icon from "cozy-ui/transpiled/react/Icon";
71
- import CheckIcon from "cozy-ui/transpiled/react/Icons/Check";
72
- import CrossIcon from "cozy-ui/transpiled/react/Icons/Cross";
73
- import WarningIcon from "cozy-ui/transpiled/react/Icons/Warning";
74
- import Spinner from "cozy-ui/transpiled/react/Spinner";
75
- import Typography from "cozy-ui/transpiled/react/Typography";
76
68
  import List from "cozy-ui/transpiled/react/List";
77
- import ListItem from "cozy-ui/transpiled/react/ListItem";
78
- import ListItemText from "cozy-ui/transpiled/react/ListItemText";
79
- import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
80
- import { Img } from "cozy-ui/transpiled/react/deprecated/Media";
69
+ import Typography from "cozy-ui/transpiled/react/Typography";
81
70
  import Button from "cozy-ui/transpiled/react/deprecated/Button";
82
- import { translate, useI18n } from "cozy-ui/transpiled/react/providers/I18n";
83
71
  import { formatLocallyDistanceToNow } from "cozy-ui/transpiled/react/providers/I18n/format";
84
72
  import withLocales from "cozy-ui/transpiled/react/providers/I18n/withLocales";
85
73
  import { withStyles } from "cozy-ui/transpiled/react/styles";
@@ -112,167 +100,15 @@ export var uploadStatus = {
112
100
  DONE_STATUSES: DONE_STATUSES,
113
101
  ERROR_STATUSES: ERROR_STATUSES
114
102
  };
115
- var Pending = translate()(function (props) {
116
- return /*#__PURE__*/React.createElement(Typography, {
117
- variant: "subtitle1",
118
- color: "primary"
119
- }, props.t('item.pending'));
120
- });
121
103
  export var formatRemainingTime = function formatRemainingTime(durationInSec) {
122
104
  var later = Date.now() + durationInSec * 1000;
123
105
  return formatLocallyDistanceToNow(later);
124
- }; // https://date-fns.org/v2.28.0/docs/formatDistanceToNow
125
-
126
- var numberOfReferencesForPluralForm = function numberOfReferencesForPluralForm(durationInSec) {
127
- return durationInSec < 90 || durationInSec > 2670 && durationInSec < 5370 ? 1 : 2;
128
- };
129
-
130
- var RemainingTime = function RemainingTime(_ref) {
131
- var durationInSec = _ref.durationInSec;
132
-
133
- var _useI18n = useI18n(),
134
- t = _useI18n.t;
135
-
136
- return /*#__PURE__*/React.createElement(Typography, {
137
- variant: "caption",
138
- className: cx(styles['upload-queue__progress-caption'], 'u-ellipsis')
139
- }, t('item.remainingTime', {
140
- time: formatRemainingTime(durationInSec),
141
- smart_count: numberOfReferencesForPluralForm(durationInSec)
142
- }));
143
106
  };
144
-
145
- var FileLinearProgress = withStyles(function (theme) {
146
- return {
147
- root: {
148
- borderRadius: theme.shape.borderRadius
149
- },
150
- colorPrimary: {
151
- backgroundColor: theme.palette.background.default
152
- },
153
- barColorPrimary: {
154
- backgroundColor: 'var(--emerald)'
155
- }
156
- };
157
- })(LinearProgress);
158
107
  var QueueLinearProgress = withStyles({
159
108
  root: {
160
109
  height: '2px'
161
110
  }
162
111
  })(LinearProgress);
163
-
164
- var FileUploadProgress = function FileUploadProgress(_ref2) {
165
- var progressProps = _ref2.progress;
166
-
167
- var _useState = useState(progressProps),
168
- _useState2 = _slicedToArray(_useState, 2),
169
- progress = _useState2[0],
170
- setProgress = _useState2[1];
171
-
172
- useIntervalWhen(function () {
173
- setProgress(progressProps);
174
- }, 1000, true, true);
175
- return /*#__PURE__*/React.createElement("div", {
176
- className: styles['upload-queue__upload-progress']
177
- }, /*#__PURE__*/React.createElement("div", {
178
- className: "u-flex-grow-1 u-pr-1"
179
- }, /*#__PURE__*/React.createElement(FileLinearProgress, {
180
- variant: "determinate",
181
- value: progress.loaded / progress.total * 100
182
- })), /*#__PURE__*/React.createElement("div", {
183
- className: "u-flex-shrink"
184
- }, progress.remainingTime ? /*#__PURE__*/React.createElement(RemainingTime, {
185
- durationInSec: progress.remainingTime
186
- }) : null));
187
- };
188
-
189
- var Item = translate()(function (_ref3) {
190
- var _cx;
191
-
192
- var file = _ref3.file,
193
- status = _ref3.status,
194
- isDirectory = _ref3.isDirectory,
195
- progress = _ref3.progress,
196
- getMimeTypeIcon = _ref3.getMimeTypeIcon;
197
- var CANCEL = uploadStatus.CANCEL,
198
- LOADING = uploadStatus.LOADING,
199
- DONE_STATUSES = uploadStatus.DONE_STATUSES,
200
- ERROR_STATUSES = uploadStatus.ERROR_STATUSES;
201
-
202
- var _splitFilename = splitFilename(file),
203
- filename = _splitFilename.filename,
204
- extension = _splitFilename.extension;
205
-
206
- var statusIcon;
207
- var done = false;
208
- var error = false;
209
- /**
210
- * Status came from the Upload Queue, but sometimes we're using
211
- * manual upload without using the Upload Queue system but we're still
212
- * using the UI component. When this is the case, the file handles on
213
- * his own its status.
214
- */
215
-
216
- var statusToUse = file.status ? file.status : status;
217
-
218
- if (statusToUse === LOADING) {
219
- statusIcon = !progress ? /*#__PURE__*/React.createElement(Spinner, {
220
- className: "u-ml-half",
221
- color: "var(--primaryColor)"
222
- }) : null;
223
- } else if (statusToUse === CANCEL) {
224
- statusIcon = /*#__PURE__*/React.createElement(Icon, {
225
- className: "u-ml-half",
226
- icon: CrossIcon,
227
- color: "var(--errorColor)"
228
- });
229
- } else if (ERROR_STATUSES.includes(statusToUse)) {
230
- error = true;
231
- statusIcon = /*#__PURE__*/React.createElement(Icon, {
232
- className: "u-ml-half",
233
- icon: WarningIcon,
234
- color: "var(--errorColor)"
235
- });
236
- } else if (DONE_STATUSES.includes(statusToUse)) {
237
- done = true;
238
- statusIcon = /*#__PURE__*/React.createElement(Icon, {
239
- className: "u-ml-half",
240
- icon: CheckIcon,
241
- color: "var(--successColor)"
242
- });
243
- } else if (statusToUse === PENDING) {
244
- statusIcon = /*#__PURE__*/React.createElement(Pending, null);
245
- }
246
-
247
- return /*#__PURE__*/React.createElement(ListItem, {
248
- divider: true,
249
- "data-testid": "upload-queue-item",
250
- className: cx('u-ph-1', (_cx = {}, _defineProperty(_cx, styles['upload-queue-item--done'], done), _defineProperty(_cx, styles['upload-queue-item--error'], error), _cx))
251
- }, getMimeTypeIcon ? /*#__PURE__*/React.createElement(ListItemIcon, {
252
- className: "u-ta-center"
253
- }, /*#__PURE__*/React.createElement(Icon, {
254
- icon: getMimeTypeIcon(isDirectory, file.name, file.type),
255
- size: 32,
256
- className: "u-mr-1"
257
- })) : null, /*#__PURE__*/React.createElement(ListItemText, {
258
- disableTypography: true
259
- }, /*#__PURE__*/React.createElement("div", {
260
- "data-testid": "upload-queue-item-name",
261
- className: "u-ellipsis"
262
- }, /*#__PURE__*/React.createElement(Typography, {
263
- variant: "body1",
264
- className: "u-ellipsis"
265
- }, filename, extension && /*#__PURE__*/React.createElement(Typography, {
266
- component: "span",
267
- variant: "body1",
268
- color: "textSecondary",
269
- className: "u-dib"
270
- }, extension))), progress ? /*#__PURE__*/React.createElement(FileUploadProgress, {
271
- progress: progress
272
- }) : null), /*#__PURE__*/React.createElement(Img, {
273
- className: styles['item-status']
274
- }, statusIcon));
275
- });
276
112
  export var UploadQueue = /*#__PURE__*/function (_Component) {
277
113
  _inherits(UploadQueue, _Component);
278
114
 
@@ -307,7 +143,7 @@ export var UploadQueue = /*#__PURE__*/function (_Component) {
307
143
  _createClass(UploadQueue, [{
308
144
  key: "render",
309
145
  value: function render() {
310
- var _cx2;
146
+ var _cx;
311
147
 
312
148
  var _this$props = this.props,
313
149
  t = _this$props.t,
@@ -321,7 +157,7 @@ export var UploadQueue = /*#__PURE__*/function (_Component) {
321
157
  var collapsed = this.state.collapsed;
322
158
  return /*#__PURE__*/React.createElement("div", {
323
159
  "data-testid": "upload-queue",
324
- className: cx(styles['upload-queue'], (_cx2 = {}, _defineProperty(_cx2, styles['upload-queue--visible'], queue.length !== 0), _defineProperty(_cx2, styles['upload-queue--collapsed'], collapsed), _defineProperty(_cx2, styles['upload-queue--popover'], popover), _cx2))
160
+ className: cx(styles['upload-queue'], (_cx = {}, _defineProperty(_cx, styles['upload-queue--visible'], queue.length !== 0), _defineProperty(_cx, styles['upload-queue--collapsed'], collapsed), _defineProperty(_cx, styles['upload-queue--popover'], popover), _cx))
325
161
  }, /*#__PURE__*/React.createElement("h4", {
326
162
  className: styles['upload-queue-header'],
327
163
  onDoubleClick: this.toggleCollapsed
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { uploadStatus } from "cozy-ui/transpiled/react/UploadQueue/index";
3
+ import Icon from "cozy-ui/transpiled/react/Icon";
4
+ import CheckIcon from "cozy-ui/transpiled/react/Icons/Check";
5
+ import CheckCircleIcon from "cozy-ui/transpiled/react/Icons/CheckCircle";
6
+ import CrossIcon from "cozy-ui/transpiled/react/Icons/Cross";
7
+ import CrossCircleIcon from "cozy-ui/transpiled/react/Icons/CrossCircle";
8
+ import WarningIcon from "cozy-ui/transpiled/react/Icons/Warning";
9
+ import Spinner from "cozy-ui/transpiled/react/Spinner";
10
+ import { isTwakeTheme } from "cozy-ui/transpiled/react/helpers/isTwakeTheme";
11
+ export var useStatusIcon = function useStatusIcon(statusToUse, progress) {
12
+ var CANCEL = uploadStatus.CANCEL,
13
+ LOADING = uploadStatus.LOADING,
14
+ DONE_STATUSES = uploadStatus.DONE_STATUSES,
15
+ ERROR_STATUSES = uploadStatus.ERROR_STATUSES,
16
+ PENDING = uploadStatus.PENDING;
17
+ var SuccessIcon = isTwakeTheme() ? CheckCircleIcon : CheckIcon;
18
+ var ErrorIcon = isTwakeTheme() ? CrossCircleIcon : CrossIcon;
19
+ var statusIcon;
20
+
21
+ if (statusToUse === LOADING) {
22
+ statusIcon = !progress ? /*#__PURE__*/React.createElement(Spinner, {
23
+ color: "var(--primaryColor)"
24
+ }) : null;
25
+ } else if (statusToUse === CANCEL) {
26
+ statusIcon = /*#__PURE__*/React.createElement(Icon, {
27
+ icon: ErrorIcon,
28
+ color: "var(--errorColor)"
29
+ });
30
+ } else if (ERROR_STATUSES.includes(statusToUse)) {
31
+ statusIcon = /*#__PURE__*/React.createElement(Icon, {
32
+ icon: WarningIcon,
33
+ color: "var(--errorColor)"
34
+ });
35
+ } else if (DONE_STATUSES.includes(statusToUse)) {
36
+ statusIcon = /*#__PURE__*/React.createElement(Icon, {
37
+ icon: SuccessIcon,
38
+ color: "var(--successColor)"
39
+ });
40
+ } else if (statusToUse === PENDING) {
41
+ statusIcon = null;
42
+ }
43
+
44
+ return statusIcon;
45
+ };