cozy-ui 95.5.0 → 95.6.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
+ # [95.6.0](https://github.com/cozy/cozy-ui/compare/v95.5.0...v95.6.0) (2023-10-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Update AllowLocationDialog to fit Play Store needs ([3a00bd2](https://github.com/cozy/cozy-ui/commit/3a00bd2))
7
+
8
+
9
+ ### Features
10
+
11
+ * **Empty:** Accept now <Icon />, <img> and <svg> as icon prop value ([d13cf26](https://github.com/cozy/cozy-ui/commit/d13cf26))
12
+
1
13
  # [95.5.0](https://github.com/cozy/cozy-ui/compare/v95.4.0...v95.5.0) (2023-10-24)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "95.5.0",
3
+ "version": "95.6.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -10,10 +10,18 @@ import CozyLocation from './icons/CozyLocation'
10
10
 
11
11
  import withSpecificDialogsLocales from './withSpecificDialogsLocales'
12
12
 
13
+ const createStyles = () => ({
14
+ typography: {
15
+ whiteSpace: 'pre-line'
16
+ }
17
+ })
18
+
13
19
  const AllowLocationDialog = forwardRef(
14
20
  ({ onClose, onAllow, description }, ref) => {
15
21
  const { t } = useI18n()
16
22
 
23
+ const styles = createStyles()
24
+
17
25
  return (
18
26
  <IllustrationDialog
19
27
  open
@@ -30,7 +38,12 @@ const AllowLocationDialog = forwardRef(
30
38
  }
31
39
  content={
32
40
  <div className="u-ta-center">
33
- <Typography gutterBottom variant="body1" color="textPrimary">
41
+ <Typography
42
+ gutterBottom
43
+ variant="body1"
44
+ color="textPrimary"
45
+ style={styles.typography}
46
+ >
34
47
  {description || t('allow-location-dialog.description')}
35
48
  </Typography>
36
49
  </div>
@@ -3,7 +3,7 @@
3
3
  "allow": "Allow",
4
4
  "allow-location-dialog": {
5
5
  "title": "Allow access to your location",
6
- "description": "Cozy needs to be able to access your location in order to record your movements. This may consume a little battery power, but you can always disable the feature from your CO2 Coach settings."
6
+ "description": "Your Cozy needs to always be authorised to access your phone's location in order to memorise and help you analyse your movements, even when the app is not in use.\n\nIt will NEVER be passed on to anyone without your request.\n\nYou can deactivate this feature from the Coach CO2 app settings."
7
7
  },
8
8
  "install-flagship-app-dialog": {
9
9
  "title": "Scan the QR Code",
@@ -3,7 +3,7 @@
3
3
  "allow": "Autoriser",
4
4
  "allow-location-dialog": {
5
5
  "title": "Autoriser l'accès à votre position",
6
- "description": "Cozy a besoin de pouvoir accéder à votre position pour enregistrer vos déplacements. Cela peut consommer un peu de batterie, mais il vous sera toujours possible de désactiver la fonctionnalité depuis les paramètres de votre Coach CO2."
6
+ "description": "Votre Cozy a besoin d'être toujours autorisé à accéder à la position de votre téléphone pour mémoriser, et vous aider à analyser vos déplacements, même lorsque l'app n'est pas utilisée ou affichée.\n\nElle ne sera JAMAIS transmise à qui que ce soit sans votre demande.\n\nVous pourrez désactiver cette fonctionnalité depuis les paramètres de l'app Coach CO2."
7
7
  },
8
8
  "install-flagship-app-dialog": {
9
9
  "title": "Scannez le QR Code",
@@ -28,3 +28,41 @@ const initialVariants = [
28
28
  )}
29
29
  </Variants>
30
30
  ```
31
+
32
+ ### With custom image
33
+
34
+ ```jsx
35
+ import CozyIcon from 'cozy-ui/transpiled/react/Icons/Cozy'
36
+ import PeopleSVGIcon from '../../assets/icons/ui/people.svg'
37
+ import Empty from 'cozy-ui/transpiled/react/Empty'
38
+ import Icon from 'cozy-ui/transpiled/react/Icon'
39
+
40
+ ;
41
+
42
+ <>
43
+ <Empty
44
+ icon={CozyIcon}
45
+ title="With functional SVG"
46
+ text="Try adding some content to this list"
47
+ />
48
+ <Empty
49
+ icon={<img src='https://viewerdemo.cozycloud.cc/IMG_0062.PNG' />}
50
+ title="With IMG"
51
+ text="Try adding some content to this list"
52
+ />
53
+ <Empty
54
+ icon={
55
+ <svg width="100" height="100">
56
+ <circle cx="50" cy="50" r="40" stroke="var(--primaryColor)" strokeWidth="4" fill="var(--paperBackgroundColor)" />
57
+ </svg>
58
+ }
59
+ title="With SVG"
60
+ text="Try adding some content to this list"
61
+ />
62
+ <Empty
63
+ icon={<Icon icon={CozyIcon} />}
64
+ title="With Icon component"
65
+ text="Try adding some content to this list"
66
+ />
67
+ </>
68
+ ```
@@ -1,10 +1,12 @@
1
1
  import React from 'react'
2
2
  import cx from 'classnames'
3
3
  import PropTypes from 'prop-types'
4
+
4
5
  import Icon, { iconPropType } from '../Icon'
5
- import styles from './styles.styl'
6
6
  import Typography from '../Typography'
7
7
 
8
+ import styles from './styles.styl'
9
+
8
10
  export const Empty = ({
9
11
  icon,
10
12
  iconSize,
@@ -15,6 +17,8 @@ export const Empty = ({
15
17
  centered,
16
18
  ...restProps
17
19
  }) => {
20
+ const isReactIconElement = typeof icon === 'object' && !!icon.props
21
+
18
22
  return (
19
23
  <div
20
24
  className={cx(
@@ -24,15 +28,27 @@ export const Empty = ({
24
28
  )}
25
29
  {...restProps}
26
30
  >
27
- {icon && (
28
- <Icon
29
- className={cx(styles['c-empty-img'], {
30
- [styles[`c-empty-img--${iconSize}`]]: iconSize !== 'normal'
31
- })}
32
- icon={icon}
33
- size="100%"
34
- />
35
- )}
31
+ {icon &&
32
+ (isReactIconElement ? (
33
+ React.cloneElement(icon, {
34
+ className: cx(
35
+ styles['c-empty-img'],
36
+ {
37
+ [styles[`c-empty-img--${iconSize}`]]: iconSize !== 'normal'
38
+ },
39
+ icon.props?.className
40
+ ),
41
+ size: icon.props?.size || (icon.type === Icon ? '100%' : undefined)
42
+ })
43
+ ) : (
44
+ <Icon
45
+ className={cx(styles['c-empty-img'], {
46
+ [styles[`c-empty-img--${iconSize}`]]: iconSize !== 'normal'
47
+ })}
48
+ icon={icon}
49
+ size="100%"
50
+ />
51
+ ))}
36
52
  {title && (
37
53
  <Typography gutterBottom variant="h3" color="textPrimary">
38
54
  {title}
@@ -51,6 +67,7 @@ Empty.propTypes = {
51
67
  text: PropTypes.node,
52
68
  /** Sets horizontal and vertical centring. The reference element is that of a fixed position */
53
69
  centered: PropTypes.bool,
70
+ children: PropTypes.node,
54
71
  className: PropTypes.string
55
72
  }
56
73
 
@@ -2498,6 +2498,37 @@ exports[`Empty should render examples: Empty 1`] = `
2498
2498
  </div>"
2499
2499
  `;
2500
2500
 
2501
+ exports[`Empty should render examples: Empty 2`] = `
2502
+ "<div data-testid=\\"mountNode\\">
2503
+ <div class=\\"styles__c-empty___3w5oV\\"><svg viewBox=\\"0 0 52 52\\" class=\\"styles__c-empty-img___2GC4d styles__icon___23x3R\\" width=\\"100%\\" height=\\"100%\\">
2504
+ <path fill=\\"#297EF2\\" fill-rule=\\"evenodd\\" d=\\"M38.231 44H13.769C6.175 44 0 37.756 0 30.08c0-3.66 1.394-7.117 3.927-9.733 2.219-2.29 5.093-3.715 8.203-4.086a13.887 13.887 0 014.042-8.292A13.608 13.608 0 0125.801 4c3.62 0 7.04 1.407 9.629 3.968a13.897 13.897 0 014.038 8.25C46.482 16.853 52 22.828 52 30.082 52 37.756 45.82 44 38.23 44h.001zm-.163-3.001h.104c5.97 0 10.828-4.91 10.828-10.947 0-6.035-4.857-10.946-10.828-10.946h-.11c-.779 0-1.417-.627-1.435-1.417C36.492 11.794 31.637 7 25.803 7c-5.835 0-10.692 4.796-10.826 10.69a1.445 1.445 0 01-1.403 1.42C7.744 19.244 3 24.153 3 30.052 3 36.09 7.857 41 13.828 41h.088l.035-.002c.03 0 .062 0 .093.002h24.021l.003-.001zm-4.302-11.776c-.875-.585-.918-1.659-.92-1.706A.52.52 0 0032.32 27a.523.523 0 00-.506.536c.002.039.016.543.251 1.137a7.99 7.99 0 01-11.138.019 3.554 3.554 0 00.257-1.155.523.523 0 00-.503-.536.526.526 0 00-.528.515c0 .043-.042 1.121-.92 1.706a.536.536 0 00-.15.731.51.51 0 00.714.154c.225-.15.414-.322.572-.505a9.006 9.006 0 0012.251-.01c.16.184.35.36.582.515a.503.503 0 00.281.085.516.516 0 00.432-.24.537.537 0 00-.15-.731v.002z\\"></path>
2505
+ </svg>
2506
+ <h3 class=\\"MuiTypography-root MuiTypography-h3 MuiTypography-colorTextPrimary MuiTypography-gutterBottom\\">With functional SVG</h3>
2507
+ <p class=\\"MuiTypography-root MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom\\">Try adding some content to this list</p>
2508
+ <div class=\\"styles__c-empty-text___3HnvR\\"></div>
2509
+ </div>
2510
+ <div class=\\"styles__c-empty___3w5oV\\"><img src=\\"https://viewerdemo.cozycloud.cc/IMG_0062.PNG\\" class=\\"styles__c-empty-img___2GC4d\\">
2511
+ <h3 class=\\"MuiTypography-root MuiTypography-h3 MuiTypography-colorTextPrimary MuiTypography-gutterBottom\\">With IMG</h3>
2512
+ <p class=\\"MuiTypography-root MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom\\">Try adding some content to this list</p>
2513
+ <div class=\\"styles__c-empty-text___3HnvR\\"></div>
2514
+ </div>
2515
+ <div class=\\"styles__c-empty___3w5oV\\"><svg width=\\"100\\" height=\\"100\\" class=\\"styles__c-empty-img___2GC4d\\">
2516
+ <circle cx=\\"50\\" cy=\\"50\\" r=\\"40\\" stroke=\\"var(--primaryColor)\\" stroke-width=\\"4\\" fill=\\"var(--paperBackgroundColor)\\"></circle>
2517
+ </svg>
2518
+ <h3 class=\\"MuiTypography-root MuiTypography-h3 MuiTypography-colorTextPrimary MuiTypography-gutterBottom\\">With SVG</h3>
2519
+ <p class=\\"MuiTypography-root MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom\\">Try adding some content to this list</p>
2520
+ <div class=\\"styles__c-empty-text___3HnvR\\"></div>
2521
+ </div>
2522
+ <div class=\\"styles__c-empty___3w5oV\\"><svg viewBox=\\"0 0 52 52\\" class=\\"styles__c-empty-img___2GC4d styles__icon___23x3R\\" width=\\"100%\\" height=\\"100%\\">
2523
+ <path fill=\\"#297EF2\\" fill-rule=\\"evenodd\\" d=\\"M38.231 44H13.769C6.175 44 0 37.756 0 30.08c0-3.66 1.394-7.117 3.927-9.733 2.219-2.29 5.093-3.715 8.203-4.086a13.887 13.887 0 014.042-8.292A13.608 13.608 0 0125.801 4c3.62 0 7.04 1.407 9.629 3.968a13.897 13.897 0 014.038 8.25C46.482 16.853 52 22.828 52 30.082 52 37.756 45.82 44 38.23 44h.001zm-.163-3.001h.104c5.97 0 10.828-4.91 10.828-10.947 0-6.035-4.857-10.946-10.828-10.946h-.11c-.779 0-1.417-.627-1.435-1.417C36.492 11.794 31.637 7 25.803 7c-5.835 0-10.692 4.796-10.826 10.69a1.445 1.445 0 01-1.403 1.42C7.744 19.244 3 24.153 3 30.052 3 36.09 7.857 41 13.828 41h.088l.035-.002c.03 0 .062 0 .093.002h24.021l.003-.001zm-4.302-11.776c-.875-.585-.918-1.659-.92-1.706A.52.52 0 0032.32 27a.523.523 0 00-.506.536c.002.039.016.543.251 1.137a7.99 7.99 0 01-11.138.019 3.554 3.554 0 00.257-1.155.523.523 0 00-.503-.536.526.526 0 00-.528.515c0 .043-.042 1.121-.92 1.706a.536.536 0 00-.15.731.51.51 0 00.714.154c.225-.15.414-.322.572-.505a9.006 9.006 0 0012.251-.01c.16.184.35.36.582.515a.503.503 0 00.281.085.516.516 0 00.432-.24.537.537 0 00-.15-.731v.002z\\"></path>
2524
+ </svg>
2525
+ <h3 class=\\"MuiTypography-root MuiTypography-h3 MuiTypography-colorTextPrimary MuiTypography-gutterBottom\\">With Icon component</h3>
2526
+ <p class=\\"MuiTypography-root MuiTypography-body1 MuiTypography-colorTextSecondary MuiTypography-gutterBottom\\">Try adding some content to this list</p>
2527
+ <div class=\\"styles__c-empty-text___3HnvR\\"></div>
2528
+ </div>
2529
+ </div>"
2530
+ `;
2531
+
2501
2532
  exports[`Hero should render examples: Hero 1`] = `
2502
2533
  "<div data-testid=\\"mountNode\\">
2503
2534
  <div class=\\"styles__Hero___14z7_\\">
@@ -7,6 +7,15 @@ import Typography from "cozy-ui/transpiled/react/Typography";
7
7
  import Button from "cozy-ui/transpiled/react/Buttons";
8
8
  import CozyLocation from "cozy-ui/transpiled/react/CozyDialogs/SpecificDialogs/icons/CozyLocation";
9
9
  import withSpecificDialogsLocales from "cozy-ui/transpiled/react/CozyDialogs/SpecificDialogs/withSpecificDialogsLocales";
10
+
11
+ var createStyles = function createStyles() {
12
+ return {
13
+ typography: {
14
+ whiteSpace: 'pre-line'
15
+ }
16
+ };
17
+ };
18
+
10
19
  var AllowLocationDialog = /*#__PURE__*/forwardRef(function (_ref, ref) {
11
20
  var onClose = _ref.onClose,
12
21
  onAllow = _ref.onAllow,
@@ -15,6 +24,7 @@ var AllowLocationDialog = /*#__PURE__*/forwardRef(function (_ref, ref) {
15
24
  var _useI18n = useI18n(),
16
25
  t = _useI18n.t;
17
26
 
27
+ var styles = createStyles();
18
28
  return /*#__PURE__*/React.createElement(IllustrationDialog, {
19
29
  open: true,
20
30
  ref: ref,
@@ -35,7 +45,8 @@ var AllowLocationDialog = /*#__PURE__*/forwardRef(function (_ref, ref) {
35
45
  }, /*#__PURE__*/React.createElement(Typography, {
36
46
  gutterBottom: true,
37
47
  variant: "body1",
38
- color: "textPrimary"
48
+ color: "textPrimary",
49
+ style: styles.typography
39
50
  }, description || t('allow-location-dialog.description'))),
40
51
  actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
41
52
  variant: "secondary",
@@ -4,7 +4,7 @@ var en = {
4
4
  allow: "Allow",
5
5
  "allow-location-dialog": {
6
6
  title: "Allow access to your location",
7
- description: "Cozy needs to be able to access your location in order to record your movements. This may consume a little battery power, but you can always disable the feature from your CO2 Coach settings."
7
+ description: "Your Cozy needs to always be authorised to access your phone's location in order to memorise and help you analyse your movements, even when the app is not in use.\n\nIt will NEVER be passed on to anyone without your request.\n\nYou can deactivate this feature from the Coach CO2 app settings."
8
8
  },
9
9
  "install-flagship-app-dialog": {
10
10
  title: "Scan the QR Code",
@@ -31,7 +31,7 @@ var fr = {
31
31
  allow: "Autoriser",
32
32
  "allow-location-dialog": {
33
33
  title: "Autoriser l'acc\xE8s \xE0 votre position",
34
- description: "Cozy a besoin de pouvoir acc\xE9der \xE0 votre position pour enregistrer vos d\xE9placements. Cela peut consommer un peu de batterie, mais il vous sera toujours possible de d\xE9sactiver la fonctionnalit\xE9 depuis les param\xE8tres de votre Coach CO2."
34
+ description: "Votre Cozy a besoin d'\xEAtre toujours autoris\xE9 \xE0 acc\xE9der \xE0 la position de votre t\xE9l\xE9phone pour m\xE9moriser, et vous aider \xE0 analyser vos d\xE9placements, m\xEAme lorsque l'app n'est pas utilis\xE9e ou affich\xE9e.\n\nElle ne sera JAMAIS transmise \xE0 qui que ce soit sans votre demande.\n\nVous pourrez d\xE9sactiver cette fonctionnalit\xE9 depuis les param\xE8tres de l'app Coach CO2."
35
35
  },
36
36
  "install-flagship-app-dialog": {
37
37
  title: "Scannez le QR Code",
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  import cx from 'classnames';
7
7
  import PropTypes from 'prop-types';
8
8
  import Icon, { iconPropType } from "cozy-ui/transpiled/react/Icon";
9
+ import Typography from "cozy-ui/transpiled/react/Typography";
9
10
  var styles = {
10
11
  "c-empty": "styles__c-empty___3w5oV",
11
12
  "c-empty--centered": "styles__c-empty--centered___2ijsY",
@@ -15,8 +16,9 @@ var styles = {
15
16
  "c-empty-title": "styles__c-empty-title___2HduE",
16
17
  "c-empty-text": "styles__c-empty-text___3HnvR"
17
18
  };
18
- import Typography from "cozy-ui/transpiled/react/Typography";
19
19
  export var Empty = function Empty(_ref) {
20
+ var _icon$props, _icon$props2;
21
+
20
22
  var icon = _ref.icon,
21
23
  iconSize = _ref.iconSize,
22
24
  title = _ref.title,
@@ -26,13 +28,17 @@ export var Empty = function Empty(_ref) {
26
28
  centered = _ref.centered,
27
29
  restProps = _objectWithoutProperties(_ref, _excluded);
28
30
 
31
+ var isReactIconElement = typeof icon === 'object' && !!icon.props;
29
32
  return /*#__PURE__*/React.createElement("div", _extends({
30
33
  className: cx(styles['c-empty'], _defineProperty({}, styles['c-empty--centered'], centered), className)
31
- }, restProps), icon && /*#__PURE__*/React.createElement(Icon, {
34
+ }, restProps), icon && (isReactIconElement ? /*#__PURE__*/React.cloneElement(icon, {
35
+ 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
+ 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, {
32
38
  className: cx(styles['c-empty-img'], _defineProperty({}, styles["c-empty-img--".concat(iconSize)], iconSize !== 'normal')),
33
39
  icon: icon,
34
40
  size: "100%"
35
- }), title && /*#__PURE__*/React.createElement(Typography, {
41
+ })), title && /*#__PURE__*/React.createElement(Typography, {
36
42
  gutterBottom: true,
37
43
  variant: "h3",
38
44
  color: "textPrimary"
@@ -50,6 +56,7 @@ Empty.propTypes = {
50
56
 
51
57
  /** Sets horizontal and vertical centring. The reference element is that of a fixed position */
52
58
  centered: PropTypes.bool,
59
+ children: PropTypes.node,
53
60
  className: PropTypes.string
54
61
  };
55
62
  Empty.defaultProps = {