cozy-ui 128.5.0 → 128.7.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,17 @@
1
+ # [128.7.0](https://github.com/cozy/cozy-ui/compare/v128.6.0...v128.7.0) (2025-09-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add Storage component ([76c74ed](https://github.com/cozy/cozy-ui/commit/76c74ed))
7
+
8
+ # [128.6.0](https://github.com/cozy/cozy-ui/compare/v128.5.0...v128.6.0) (2025-09-08)
9
+
10
+
11
+ ### Features
12
+
13
+ * **DropdownText:** add color prop for Typography and update README example ([f5006b0](https://github.com/cozy/cozy-ui/commit/f5006b0))
14
+
1
15
  # [128.5.0](https://github.com/cozy/cozy-ui/compare/v128.4.0...v128.5.0) (2025-09-08)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "128.5.0",
3
+ "version": "128.7.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -22,7 +22,7 @@ const variants = [
22
22
 
23
23
  <>
24
24
  <Grid container>
25
- <Grid item xs={6}>
25
+ <Grid item xs={6} sm={3} sd={2}>
26
26
  Default
27
27
  {variants.map((variant, index) => (
28
28
  <div key={index} className='u-mb-1'>
@@ -32,7 +32,7 @@ const variants = [
32
32
  </div>
33
33
  ))}
34
34
  </Grid>
35
- <Grid item xs={6}>
35
+ <Grid item xs={6} sm={3} sd={2}>
36
36
  Disabled
37
37
  {variants.map((variant, index) => (
38
38
  <div key={index} className='u-mb-1'>
@@ -42,7 +42,29 @@ const variants = [
42
42
  </div>
43
43
  ))}
44
44
  </Grid>
45
+ <Grid item xs={6} sm={3} sd={2}>
46
+ Color primary
47
+ {variants.map((variant, index) => (
48
+ <div key={index} className='u-mb-1'>
49
+ <DropdownText variant={variant} color="primary">
50
+ {variant}
51
+ </DropdownText>
52
+ </div>
53
+ ))}
54
+ </Grid>
55
+ <Grid item xs={6} sm={3} sd={2}>
56
+ Color error
57
+ {variants.map((variant, index) => (
58
+ <div key={index} className='u-mb-1'>
59
+ <DropdownText variant={variant} color="error">
60
+ {variant}
61
+ </DropdownText>
62
+ </div>
63
+ ))}
64
+ </Grid>
45
65
  </Grid>
66
+
67
+ <p>
46
68
  <div style={{ border: '1px dashed var(--borderMainColor)', marginBottom: '1rem' }}>
47
69
  <DropdownText>
48
70
  This is a long text without ellipsis without restrictive container
@@ -68,5 +90,6 @@ const variants = [
68
90
  Space between text and icon
69
91
  </DropdownText>
70
92
  </div>
93
+ </p>
71
94
  </>
72
95
  ```
@@ -16,14 +16,14 @@ const useStyles = makeStyles(theme => ({
16
16
  },
17
17
  typography: {
18
18
  color: ({ disabled }) =>
19
- theme.palette.text[disabled ? 'disabled' : 'primary']
19
+ disabled ? theme.palette.text.disabled : undefined
20
20
  },
21
21
  endIcon: {
22
22
  display: 'flex',
23
23
  marginLeft: '5px',
24
24
  marginTop: ({ variant }) => (variant === 'body1' ? '3px' : undefined),
25
25
  color: ({ disabled }) =>
26
- theme.palette.text[disabled ? 'disabled' : 'primary']
26
+ disabled ? theme.palette.text.disabled : undefined
27
27
  }
28
28
  }))
29
29
 
@@ -48,7 +48,7 @@ const DropdownText = forwardRef(
48
48
  variant = 'body1',
49
49
  disabled = false,
50
50
  noWrap = false,
51
- color = 'primary',
51
+ color = 'initial',
52
52
  children,
53
53
  innerTextProps,
54
54
  innerIconContainerProps,
@@ -57,11 +57,12 @@ const DropdownText = forwardRef(
57
57
  },
58
58
  ref
59
59
  ) => {
60
- const styles = useStyles({ spaceBetween, disabled, color, variant })
60
+ const styles = useStyles({ spaceBetween, disabled, variant })
61
61
 
62
62
  return (
63
63
  <div ref={ref} className={styles.container} {...props}>
64
64
  <Typography
65
+ color={color}
65
66
  classes={{ root: styles.typography }}
66
67
  variant={variant}
67
68
  noWrap={noWrap}
@@ -70,6 +71,7 @@ const DropdownText = forwardRef(
70
71
  {children}
71
72
  </Typography>
72
73
  <Typography
74
+ color={color}
73
75
  classes={{ root: styles.endIcon }}
74
76
  {...innerIconContainerProps}
75
77
  >
@@ -85,6 +87,8 @@ const DropdownText = forwardRef(
85
87
  )
86
88
 
87
89
  DropdownText.propTypes = {
90
+ /** Color used by Typography component */
91
+ color: PropTypes.string,
88
92
  /** Whether there is a space between the label and the icon */
89
93
  spaceBetween: PropTypes.bool,
90
94
  /** Variant used by Typography component */
@@ -0,0 +1,46 @@
1
+ ```jsx
2
+ import Storage from 'cozy-ui/transpiled/react/Storage'
3
+ import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
4
+
5
+ const client = {
6
+ store: {
7
+ getState: () => {},
8
+ subscribe: () => {},
9
+ unsubscribe: () => {}
10
+ },
11
+ getInstanceOptions: () => {},
12
+ query: () => {},
13
+ getQueryFromState: queryName => {
14
+ if (queryName === 'io.cozy.settings/io.cozy.settings.instance') {
15
+ return {
16
+ data: {
17
+ uuid: "uid123"
18
+ }
19
+ }
20
+ } else if (queryName === 'io.cozy.settings/io.cozy.settings.context') {
21
+ return {
22
+ data: {
23
+ manager_url: "http://manager-url/",
24
+ enable_premium_links: true
25
+ }
26
+ }
27
+ } else if (queryName === 'io.cozy.settings/io.cozy.settings.disk-usage') {
28
+ return {
29
+ data: {
30
+ used: "500000000",
31
+ quota: "1000000000"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ ;
39
+
40
+ <DemoProvider client={client}>
41
+ <div className="u-p-1-half u-maw-5">
42
+ <Storage onlyDesktop={false} />
43
+ </div>
44
+ </DemoProvider>
45
+
46
+ ```
@@ -0,0 +1,34 @@
1
+ import cx from 'classnames'
2
+ import React from 'react'
3
+
4
+ import { useInstanceInfo } from 'cozy-client'
5
+ import { buildPremiumLink } from 'cozy-client/dist/models/instance'
6
+
7
+ import { locales } from './locales'
8
+ import Button from '../Buttons'
9
+ import Icon from '../Icon'
10
+ import TwakeWorkplaceIcon from '../Icons/TwakeWorkplace'
11
+ import { useI18n, useExtendI18n } from '../providers/I18n'
12
+
13
+ const StorageButton = ({ className }) => {
14
+ useExtendI18n(locales)
15
+ const { t } = useI18n()
16
+ const instanceInfo = useInstanceInfo()
17
+
18
+ return (
19
+ <Button
20
+ className={cx('u-bdrs-4', className)}
21
+ variant="secondary"
22
+ label={t('Storage.increase')}
23
+ startIcon={<Icon icon={TwakeWorkplaceIcon} size={22} />}
24
+ size="small"
25
+ height="auto"
26
+ fullWidth
27
+ component="a"
28
+ target="_blank"
29
+ href={buildPremiumLink(instanceInfo)}
30
+ />
31
+ )
32
+ }
33
+
34
+ export default StorageButton
@@ -0,0 +1,52 @@
1
+ import React from 'react'
2
+
3
+ import { useInstanceInfo } from 'cozy-client'
4
+ import { makeDiskInfos } from 'cozy-client/dist/models/instance'
5
+
6
+ import { locales } from './locales'
7
+ import Icon from '../Icon'
8
+ import CloudIcon from '../Icons/Cloud'
9
+ import { LinearProgress } from '../Progress'
10
+ import Typography from '../Typography'
11
+ import { useI18n, useExtendI18n } from '../providers/I18n'
12
+
13
+ /**
14
+ * Show remaining disk space with a progress bar
15
+ */
16
+ const StorageProgress = () => {
17
+ useExtendI18n(locales)
18
+ const { t } = useI18n()
19
+
20
+ const { diskUsage } = useInstanceInfo()
21
+
22
+ const { humanDiskQuota, humanDiskUsage, percentUsage } = makeDiskInfos(
23
+ diskUsage.data?.used,
24
+ diskUsage.data?.quota
25
+ )
26
+
27
+ return (
28
+ <>
29
+ <div className="u-flex u-flex-items-center">
30
+ <Icon
31
+ className="u-mr-half"
32
+ icon={CloudIcon}
33
+ size={24}
34
+ color="var(--iconTextColor)"
35
+ />
36
+ <Typography variant="caption">{t('Storage.title')}</Typography>
37
+ </div>
38
+ <LinearProgress
39
+ className="u-mv-half"
40
+ variant="determinate"
41
+ value={parseInt(percentUsage)}
42
+ />
43
+ <Typography variant="caption">
44
+ {t('Storage.availability', {
45
+ smart_count: (humanDiskQuota - humanDiskUsage).toFixed(2)
46
+ })}
47
+ </Typography>
48
+ </>
49
+ )
50
+ }
51
+
52
+ export default StorageProgress
@@ -0,0 +1,41 @@
1
+ import PropTypes from 'prop-types'
2
+ import React from 'react'
3
+
4
+ import { useInstanceInfo } from 'cozy-client'
5
+ import { shouldDisplayOffers } from 'cozy-client/dist/models/instance'
6
+ import { isFlagshipApp } from 'cozy-device-helper'
7
+
8
+ import StorageButton from './StorageButton'
9
+ import StorageProgress from './StorageProgress'
10
+ import useBreakpoints from '../providers/Breakpoints'
11
+
12
+ const Storage = ({ onlyDesktop }) => {
13
+ const { isDesktop, isMobile } = useBreakpoints()
14
+ const instanceInfo = useInstanceInfo()
15
+
16
+ if (onlyDesktop && !isDesktop) return null
17
+
18
+ const showStorageButton =
19
+ instanceInfo.isLoaded &&
20
+ !isFlagshipApp() &&
21
+ !isMobile &&
22
+ shouldDisplayOffers(instanceInfo)
23
+
24
+ return (
25
+ <>
26
+ <StorageProgress />
27
+ {showStorageButton && <StorageButton className="u-mt-1" />}
28
+ </>
29
+ )
30
+ }
31
+
32
+ Storage.propTypes = {
33
+ /** Component enabled only for desktop. Using `false` will enable it for mobile and tablet also. */
34
+ onlyDesktop: PropTypes.bool
35
+ }
36
+
37
+ Storage.defaultProps = {
38
+ onlyDesktop: true
39
+ }
40
+
41
+ export default Storage
@@ -0,0 +1,7 @@
1
+ {
2
+ "Storage": {
3
+ "title": "Storage",
4
+ "availability": "%{smart_count} GB available",
5
+ "increase": "Increase the space"
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "Storage": {
3
+ "title": "Stockage",
4
+ "availability": "%{smart_count} Go disponible",
5
+ "increase": "Augmenter l'espace"
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ import en from './en.json'
2
+ import fr from './fr.json'
3
+
4
+ export const locales = {
5
+ en,
6
+ fr
7
+ }
@@ -21,7 +21,7 @@ var useStyles = makeStyles(function (theme) {
21
21
  typography: {
22
22
  color: function color(_ref2) {
23
23
  var disabled = _ref2.disabled;
24
- return theme.palette.text[disabled ? 'disabled' : 'primary'];
24
+ return disabled ? theme.palette.text.disabled : undefined;
25
25
  }
26
26
  },
27
27
  endIcon: {
@@ -33,7 +33,7 @@ var useStyles = makeStyles(function (theme) {
33
33
  },
34
34
  color: function color(_ref4) {
35
35
  var disabled = _ref4.disabled;
36
- return theme.palette.text[disabled ? 'disabled' : 'primary'];
36
+ return disabled ? theme.palette.text.disabled : undefined;
37
37
  }
38
38
  }
39
39
  };
@@ -61,7 +61,7 @@ var DropdownText = /*#__PURE__*/forwardRef(function (_ref5, ref) {
61
61
  _ref5$noWrap = _ref5.noWrap,
62
62
  noWrap = _ref5$noWrap === void 0 ? false : _ref5$noWrap,
63
63
  _ref5$color = _ref5.color,
64
- color = _ref5$color === void 0 ? 'primary' : _ref5$color,
64
+ color = _ref5$color === void 0 ? 'initial' : _ref5$color,
65
65
  children = _ref5.children,
66
66
  innerTextProps = _ref5.innerTextProps,
67
67
  innerIconContainerProps = _ref5.innerIconContainerProps,
@@ -71,19 +71,20 @@ var DropdownText = /*#__PURE__*/forwardRef(function (_ref5, ref) {
71
71
  var styles = useStyles({
72
72
  spaceBetween: spaceBetween,
73
73
  disabled: disabled,
74
- color: color,
75
74
  variant: variant
76
75
  });
77
76
  return /*#__PURE__*/React.createElement("div", _extends({
78
77
  ref: ref,
79
78
  className: styles.container
80
79
  }, props), /*#__PURE__*/React.createElement(Typography, _extends({
80
+ color: color,
81
81
  classes: {
82
82
  root: styles.typography
83
83
  },
84
84
  variant: variant,
85
85
  noWrap: noWrap
86
86
  }, innerTextProps), children), /*#__PURE__*/React.createElement(Typography, _extends({
87
+ color: color,
87
88
  classes: {
88
89
  root: styles.endIcon
89
90
  }
@@ -93,6 +94,9 @@ var DropdownText = /*#__PURE__*/forwardRef(function (_ref5, ref) {
93
94
  }, innerIconProps))));
94
95
  });
95
96
  DropdownText.propTypes = {
97
+ /** Color used by Typography component */
98
+ color: PropTypes.string,
99
+
96
100
  /** Whether there is a space between the label and the icon */
97
101
  spaceBetween: PropTypes.bool,
98
102
 
@@ -0,0 +1,4 @@
1
+ export default StorageButton;
2
+ declare function StorageButton({ className }: {
3
+ className: any;
4
+ }): JSX.Element;
@@ -0,0 +1,36 @@
1
+ import cx from 'classnames';
2
+ import React from 'react';
3
+ import { useInstanceInfo } from 'cozy-client';
4
+ import { buildPremiumLink } from 'cozy-client/dist/models/instance';
5
+ import { locales } from "cozy-ui/transpiled/react/Storage/locales";
6
+ import Button from "cozy-ui/transpiled/react/Buttons";
7
+ import Icon from "cozy-ui/transpiled/react/Icon";
8
+ import TwakeWorkplaceIcon from "cozy-ui/transpiled/react/Icons/TwakeWorkplace";
9
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
10
+
11
+ var StorageButton = function StorageButton(_ref) {
12
+ var className = _ref.className;
13
+ useExtendI18n(locales);
14
+
15
+ var _useI18n = useI18n(),
16
+ t = _useI18n.t;
17
+
18
+ var instanceInfo = useInstanceInfo();
19
+ return /*#__PURE__*/React.createElement(Button, {
20
+ className: cx('u-bdrs-4', className),
21
+ variant: "secondary",
22
+ label: t('Storage.increase'),
23
+ startIcon: /*#__PURE__*/React.createElement(Icon, {
24
+ icon: TwakeWorkplaceIcon,
25
+ size: 22
26
+ }),
27
+ size: "small",
28
+ height: "auto",
29
+ fullWidth: true,
30
+ component: "a",
31
+ target: "_blank",
32
+ href: buildPremiumLink(instanceInfo)
33
+ });
34
+ };
35
+
36
+ export default StorageButton;
@@ -0,0 +1,5 @@
1
+ export default StorageProgress;
2
+ /**
3
+ * Show remaining disk space with a progress bar
4
+ */
5
+ declare function StorageProgress(): JSX.Element;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { useInstanceInfo } from 'cozy-client';
3
+ import { makeDiskInfos } from 'cozy-client/dist/models/instance';
4
+ import { locales } from "cozy-ui/transpiled/react/Storage/locales";
5
+ import Icon from "cozy-ui/transpiled/react/Icon";
6
+ import CloudIcon from "cozy-ui/transpiled/react/Icons/Cloud";
7
+ import { LinearProgress } from "cozy-ui/transpiled/react/Progress";
8
+ import Typography from "cozy-ui/transpiled/react/Typography";
9
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
10
+ /**
11
+ * Show remaining disk space with a progress bar
12
+ */
13
+
14
+ var StorageProgress = function StorageProgress() {
15
+ var _diskUsage$data, _diskUsage$data2;
16
+
17
+ useExtendI18n(locales);
18
+
19
+ var _useI18n = useI18n(),
20
+ t = _useI18n.t;
21
+
22
+ var _useInstanceInfo = useInstanceInfo(),
23
+ diskUsage = _useInstanceInfo.diskUsage;
24
+
25
+ var _makeDiskInfos = makeDiskInfos((_diskUsage$data = diskUsage.data) === null || _diskUsage$data === void 0 ? void 0 : _diskUsage$data.used, (_diskUsage$data2 = diskUsage.data) === null || _diskUsage$data2 === void 0 ? void 0 : _diskUsage$data2.quota),
26
+ humanDiskQuota = _makeDiskInfos.humanDiskQuota,
27
+ humanDiskUsage = _makeDiskInfos.humanDiskUsage,
28
+ percentUsage = _makeDiskInfos.percentUsage;
29
+
30
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
31
+ className: "u-flex u-flex-items-center"
32
+ }, /*#__PURE__*/React.createElement(Icon, {
33
+ className: "u-mr-half",
34
+ icon: CloudIcon,
35
+ size: 24,
36
+ color: "var(--iconTextColor)"
37
+ }), /*#__PURE__*/React.createElement(Typography, {
38
+ variant: "caption"
39
+ }, t('Storage.title'))), /*#__PURE__*/React.createElement(LinearProgress, {
40
+ className: "u-mv-half",
41
+ variant: "determinate",
42
+ value: parseInt(percentUsage)
43
+ }), /*#__PURE__*/React.createElement(Typography, {
44
+ variant: "caption"
45
+ }, t('Storage.availability', {
46
+ smart_count: (humanDiskQuota - humanDiskUsage).toFixed(2)
47
+ })));
48
+ };
49
+
50
+ export default StorageProgress;
@@ -0,0 +1,14 @@
1
+ export default Storage;
2
+ declare function Storage({ onlyDesktop }: {
3
+ onlyDesktop: any;
4
+ }): JSX.Element | null;
5
+ declare namespace Storage {
6
+ namespace propTypes {
7
+ const onlyDesktop: PropTypes.Requireable<boolean>;
8
+ }
9
+ namespace defaultProps {
10
+ const onlyDesktop_1: boolean;
11
+ export { onlyDesktop_1 as onlyDesktop };
12
+ }
13
+ }
14
+ import PropTypes from "prop-types";
@@ -0,0 +1,32 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import { useInstanceInfo } from 'cozy-client';
4
+ import { shouldDisplayOffers } from 'cozy-client/dist/models/instance';
5
+ import { isFlagshipApp } from 'cozy-device-helper';
6
+ import StorageButton from "cozy-ui/transpiled/react/Storage/StorageButton";
7
+ import StorageProgress from "cozy-ui/transpiled/react/Storage/StorageProgress";
8
+ import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
9
+
10
+ var Storage = function Storage(_ref) {
11
+ var onlyDesktop = _ref.onlyDesktop;
12
+
13
+ var _useBreakpoints = useBreakpoints(),
14
+ isDesktop = _useBreakpoints.isDesktop,
15
+ isMobile = _useBreakpoints.isMobile;
16
+
17
+ var instanceInfo = useInstanceInfo();
18
+ if (onlyDesktop && !isDesktop) return null;
19
+ var showStorageButton = instanceInfo.isLoaded && !isFlagshipApp() && !isMobile && shouldDisplayOffers(instanceInfo);
20
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StorageProgress, null), showStorageButton && /*#__PURE__*/React.createElement(StorageButton, {
21
+ className: "u-mt-1"
22
+ }));
23
+ };
24
+
25
+ Storage.propTypes = {
26
+ /** Component enabled only for desktop. Using `false` will enable it for mobile and tablet also. */
27
+ onlyDesktop: PropTypes.bool
28
+ };
29
+ Storage.defaultProps = {
30
+ onlyDesktop: true
31
+ };
32
+ export default Storage;
@@ -0,0 +1,6 @@
1
+ export namespace locales {
2
+ export { en };
3
+ export { fr };
4
+ }
5
+ import en from "./en.json";
6
+ import fr from "./fr.json";
@@ -0,0 +1,18 @@
1
+ var en = {
2
+ Storage: {
3
+ title: "Storage",
4
+ availability: "%{smart_count} GB available",
5
+ increase: "Increase the space"
6
+ }
7
+ };
8
+ var fr = {
9
+ Storage: {
10
+ title: "Stockage",
11
+ availability: "%{smart_count} Go disponible",
12
+ increase: "Augmenter l'espace"
13
+ }
14
+ };
15
+ export var locales = {
16
+ en: en,
17
+ fr: fr
18
+ };