cozy-ui 111.12.0 → 111.13.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
+ # [111.13.0](https://github.com/cozy/cozy-ui/compare/v111.12.0...v111.13.0) (2024-09-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **AppTile:** Display the name of the developer instead custom property ([ff428f8](https://github.com/cozy/cozy-ui/commit/ff428f8))
7
+ * **AppTile:** Show favorite label also desktop ([6477abe](https://github.com/cozy/cozy-ui/commit/6477abe))
8
+ * **I18n:** Allow multiple locales extensions in apps by isolating state ([2bf2645](https://github.com/cozy/cozy-ui/commit/2bf2645))
9
+
10
+
11
+ ### Features
12
+
13
+ * **AppSections:** Rename shortcuts section to additional apps ([3b53853](https://github.com/cozy/cozy-ui/commit/3b53853))
14
+
1
15
  # [111.12.0](https://github.com/cozy/cozy-ui/compare/v111.11.0...v111.12.0) (2024-09-23)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "111.12.0",
3
+ "version": "111.13.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types'
3
3
  import React, { Component } from 'react'
4
4
 
5
5
  import flag from 'cozy-flags'
6
- import { useExtendI18n } from 'cozy-ui/transpiled/react/providers/I18n'
7
6
 
8
7
  import styles from './Sections.styl'
9
8
  import * as catUtils from './categories'
@@ -16,9 +15,9 @@ import en from './locales/en.json'
16
15
  import fr from './locales/fr.json'
17
16
  import * as searchUtils from './search'
18
17
  import Typography from '../Typography'
19
- import withBreakpoints from '../helpers/withBreakpoints'
20
- import { translate } from '../providers/I18n'
21
- import withLocales from '../providers/I18n/withLocales'
18
+ import { useBreakpoints } from '../providers/Breakpoints'
19
+ import { useI18n, useExtendI18n } from '../providers/I18n'
20
+ import withOnlyLocales from '../providers/I18n/withOnlyLocales'
22
21
 
23
22
  const locales = {
24
23
  en,
@@ -230,7 +229,10 @@ const SectionsWrapper = props => {
230
229
  const i18nConfig = generateI18nConfig(config?.categories)
231
230
  useExtendI18n(i18nConfig)
232
231
 
233
- return <Sections {...props} />
232
+ const { t } = useI18n()
233
+ const breakpoints = useBreakpoints()
234
+
235
+ return <Sections {...props} breakpoints={breakpoints} t={t} />
234
236
  }
235
237
 
236
238
  Sections.propTypes = {
@@ -277,6 +279,4 @@ Sections.defaultProps = {
277
279
  })
278
280
  }
279
281
 
280
- export const Untranslated = withBreakpoints()(SectionsWrapper)
281
-
282
- export default withLocales(locales)(translate()(Untranslated))
282
+ export default withOnlyLocales(locales)(SectionsWrapper)
@@ -1076,7 +1076,7 @@ exports[`AppsSection component should render dropdown filter on mobile if no nav
1076
1076
  "value": "partners",
1077
1077
  },
1078
1078
  Object {
1079
- "label": "Shortcuts",
1079
+ "label": "Additional apps",
1080
1080
  "secondary": false,
1081
1081
  "value": "shortcuts",
1082
1082
  },
@@ -1482,7 +1482,7 @@ exports[`AppsSection component should render dropdown filter on tablet if no nav
1482
1482
  "value": "partners",
1483
1483
  },
1484
1484
  Object {
1485
- "label": "Shortcuts",
1485
+ "label": "Additional apps",
1486
1486
  "secondary": false,
1487
1487
  "value": "shortcuts",
1488
1488
  },
@@ -104,7 +104,7 @@ describe('generateOptionsFromApps', () => {
104
104
  type: 'webapp',
105
105
  value: 'others'
106
106
  },
107
- { label: 'Shortcuts', secondary: false, value: 'shortcuts' },
107
+ { label: 'Additional apps', secondary: false, value: 'shortcuts' },
108
108
  {
109
109
  label: 'Services',
110
110
  secondary: false,
@@ -158,7 +158,7 @@ describe('generateOptionsFromApps', () => {
158
158
  value: 'others'
159
159
  },
160
160
  {
161
- label: 'Shortcuts',
161
+ label: 'Additional apps',
162
162
  secondary: false,
163
163
  value: 'shortcuts'
164
164
  },
@@ -28,7 +28,7 @@ Array [
28
28
  "title": "Cozy Photos",
29
29
  },
30
30
  Object {
31
- "developer": "By undefined",
31
+ "developer": null,
32
32
  "status": "Update available",
33
33
  "title": "Tasky",
34
34
  },
@@ -27,11 +27,11 @@
27
27
  "telecom": "Telecom",
28
28
  "transport": "Transportation",
29
29
  "pro": "Work",
30
- "shortcuts": "Shortcuts"
30
+ "shortcuts": "Additional apps"
31
31
  },
32
32
  "sections": {
33
33
  "applications": "Applications",
34
34
  "konnectors": "Services",
35
- "shortcuts": "Shortcuts"
35
+ "shortcuts": "Additional apps"
36
36
  }
37
37
  }
@@ -27,11 +27,11 @@
27
27
  "telecom": "Mobile",
28
28
  "transport": "Voyage et transport",
29
29
  "pro": "Travail",
30
- "shortcuts": "Raccourcis"
30
+ "shortcuts": "App supplémentaires"
31
31
  },
32
32
  "sections": {
33
33
  "applications": "Applications",
34
34
  "konnectors": "Services",
35
- "shortcuts": "Raccourcis"
35
+ "shortcuts": "App supplémentaires"
36
36
  }
37
37
  }
@@ -20,7 +20,6 @@ import Tile, {
20
20
  } from '../Tile'
21
21
  import palette from '../palette'
22
22
  import { AppDoctype } from '../proptypes'
23
- import useBreakpoints from '../providers/Breakpoints'
24
23
  import { createUseI18n } from '../providers/I18n'
25
24
 
26
25
  const locales = { en, fr }
@@ -52,7 +51,6 @@ export const AppTile = ({
52
51
  }) => {
53
52
  const { t } = useI18n()
54
53
  const { developer = {} } = app
55
- const { isMobile } = useBreakpoints()
56
54
 
57
55
  const name = nameProp || app.name
58
56
 
@@ -61,7 +59,7 @@ export const AppTile = ({
61
59
  const isStatusArray = Array.isArray(showStatus)
62
60
 
63
61
  const statusToDisplay =
64
- isShortcutFile(app) && statusLabel === APP_STATUS.installed && isMobile
62
+ isShortcutFile(app) && statusLabel === APP_STATUS.installed
65
63
  ? 'favorite'
66
64
  : isStatusArray
67
65
  ? showStatus.indexOf(statusLabel) > -1 && statusLabel
@@ -71,9 +69,6 @@ export const AppTile = ({
71
69
 
72
70
  const isInMaintenanceWithSpecificDisplay =
73
71
  displaySpecificMaintenanceStyle && statusLabel === APP_STATUS.maintenance
74
- const tileSubtitle = isShortcutFile(app)
75
- ? app.metadata?.source
76
- : developer.name
77
72
 
78
73
  return (
79
74
  <Tile
@@ -109,8 +104,8 @@ export const AppTile = ({
109
104
  <TileTitle isMultiline={!statusLabel}>
110
105
  {namePrefix ? `${namePrefix} ${name}` : name}
111
106
  </TileTitle>
112
- {showDeveloper && (
113
- <TileSubtitle>{`${t('app_item.by')} ${tileSubtitle}`}</TileSubtitle>
107
+ {developer.name && showDeveloper && (
108
+ <TileSubtitle>{`${t('app_item.by')} ${developer.name}`}</TileSubtitle>
114
109
  )}
115
110
  {statusToDisplay && (
116
111
  <TileFooter isAccent={statusLabel === APP_STATUS.update}>
@@ -4,6 +4,6 @@
4
4
  "installed": "Installée",
5
5
  "maintenance": "En maintenance",
6
6
  "update": "Mise à jour dispo.",
7
- "favorite": "Ajouté sur la page d'accueil"
7
+ "favorite": "Ajouté sur l'accueil"
8
8
  }
9
9
  }
@@ -89,8 +89,9 @@ I18n.childContextTypes = {
89
89
  lang: PropTypes.string
90
90
  }
91
91
 
92
- export { initTranslation, extend, useExtendI18n } from './translation'
92
+ export { initTranslation, extend } from './translation'
93
93
  export { default as translate } from './translate'
94
94
  export { default as createUseI18n } from './createUseI18n'
95
+ export { default as useExtendI18n } from './useExtendI18n'
95
96
 
96
97
  export default I18n
@@ -1,6 +1,6 @@
1
1
  import Polyglot from 'node-polyglot'
2
2
 
3
- import { DEFAULT_LANG, useI18n } from '.'
3
+ import { DEFAULT_LANG } from '.'
4
4
 
5
5
  export let _polyglot
6
6
 
@@ -40,34 +40,3 @@ export const initTranslation = (
40
40
  }
41
41
 
42
42
  export const extend = (dict, polyglot) => (polyglot || _polyglot)?.extend(dict)
43
-
44
- // Use to determine if we need to merge locales again, and to avoid useless calls
45
- let useExtendI18nLang = ''
46
-
47
- /**
48
- * Hook to merge app locales with cozy-ui locales
49
- * @param {object} locales - Locales sorted by lang `{ fr: {...}, en: {...} }`
50
- * @returns {void}
51
- */
52
- export const useExtendI18n = locales => {
53
- const { lang, polyglot } = useI18n()
54
-
55
- if (!locales || !lang || !polyglot) return
56
-
57
- // To simplify code we use Polyglot.extend to merge
58
- // locales from object and from polyglot.phrases
59
- // rather than native JS or lodash. this is why we have two extend.
60
- if (useExtendI18nLang !== lang) {
61
- const _polyglot = new Polyglot({
62
- phrases: locales[lang],
63
- locale: lang
64
- })
65
-
66
- // merge locales from app and cozy-ui, without replacing existing one in app
67
- extend(polyglot.phrases, _polyglot)
68
- // use merged locales in app
69
- extend(_polyglot.phrases, polyglot)
70
- // set the sitch to avoid useless merge
71
- useExtendI18nLang = lang
72
- }
73
- }
@@ -0,0 +1,37 @@
1
+ import Polyglot from 'node-polyglot'
2
+ import { useState } from 'react'
3
+
4
+ import { useI18n } from '.'
5
+ import { extend } from './translation'
6
+
7
+ /**
8
+ * Hook to merge app locales with cozy-ui locales
9
+ * @param {object} locales - Locales sorted by lang `{ fr: {...}, en: {...} }`
10
+ * @returns {void}
11
+ */
12
+ const useExtendI18n = locales => {
13
+ const { lang, polyglot } = useI18n()
14
+ // Use to determine if we need to merge locales again, and to avoid useless calls
15
+ const [useExtendI18nLang, setUseExtendI18nLang] = useState('')
16
+
17
+ if (!locales || !lang || !polyglot) return
18
+
19
+ // To simplify code we use Polyglot.extend to merge
20
+ // locales from object and from polyglot.phrases
21
+ // rather than native JS or lodash. this is why we have two extend.
22
+ if (useExtendI18nLang !== lang) {
23
+ const _polyglot = new Polyglot({
24
+ phrases: locales[lang],
25
+ locale: lang
26
+ })
27
+
28
+ // merge locales from app and cozy-ui, without replacing existing one in app
29
+ extend(polyglot.phrases, _polyglot)
30
+ // use merged locales in app
31
+ extend(_polyglot.phrases, polyglot)
32
+ // set the switch to avoid useless merge
33
+ setUseExtendI18nLang(lang)
34
+ }
35
+ }
36
+
37
+ export default useExtendI18n
@@ -14,7 +14,6 @@ import cx from 'classnames';
14
14
  import PropTypes from 'prop-types';
15
15
  import React, { Component } from 'react';
16
16
  import flag from 'cozy-flags';
17
- import { useExtendI18n } from 'cozy-ui/transpiled/react/providers/I18n';
18
17
  var styles = {
19
18
  "Sections__section": "Sections__Sections__section___2onYy"
20
19
  };
@@ -53,12 +52,12 @@ var en = {
53
52
  telecom: "Telecom",
54
53
  transport: "Transportation",
55
54
  pro: "Work",
56
- shortcuts: "Shortcuts"
55
+ shortcuts: "Additional apps"
57
56
  },
58
57
  sections: {
59
58
  applications: "Applications",
60
59
  konnectors: "Services",
61
- shortcuts: "Shortcuts"
60
+ shortcuts: "Additional apps"
62
61
  }
63
62
  };
64
63
  var fr = {
@@ -90,19 +89,19 @@ var fr = {
90
89
  telecom: "Mobile",
91
90
  transport: "Voyage et transport",
92
91
  pro: "Travail",
93
- shortcuts: "Raccourcis"
92
+ shortcuts: "App suppl\xE9mentaires"
94
93
  },
95
94
  sections: {
96
95
  applications: "Applications",
97
96
  konnectors: "Services",
98
- shortcuts: "Raccourcis"
97
+ shortcuts: "App suppl\xE9mentaires"
99
98
  }
100
99
  };
101
100
  import * as searchUtils from "cozy-ui/transpiled/react/AppSections/search";
102
101
  import Typography from "cozy-ui/transpiled/react/Typography";
103
- import withBreakpoints from "cozy-ui/transpiled/react/helpers/withBreakpoints";
104
- import { translate } from "cozy-ui/transpiled/react/providers/I18n";
105
- import withLocales from "cozy-ui/transpiled/react/providers/I18n/withLocales";
102
+ import { useBreakpoints } from "cozy-ui/transpiled/react/providers/Breakpoints";
103
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
104
+ import withOnlyLocales from "cozy-ui/transpiled/react/providers/I18n/withOnlyLocales";
106
105
  var locales = {
107
106
  en: en,
108
107
  fr: fr
@@ -291,7 +290,15 @@ var SectionsWrapper = function SectionsWrapper(props) {
291
290
  var config = flag('store.alternative-source');
292
291
  var i18nConfig = generateI18nConfig(config === null || config === void 0 ? void 0 : config.categories);
293
292
  useExtendI18n(i18nConfig);
294
- return /*#__PURE__*/React.createElement(Sections, props);
293
+
294
+ var _useI18n = useI18n(),
295
+ t = _useI18n.t;
296
+
297
+ var breakpoints = useBreakpoints();
298
+ return /*#__PURE__*/React.createElement(Sections, _extends({}, props, {
299
+ breakpoints: breakpoints,
300
+ t: t
301
+ }));
295
302
  };
296
303
 
297
304
  Sections.propTypes = {
@@ -334,5 +341,4 @@ Sections.defaultProps = {
334
341
  })
335
342
  })
336
343
  };
337
- export var Untranslated = withBreakpoints()(SectionsWrapper);
338
- export default withLocales(locales)(translate()(Untranslated));
344
+ export default withOnlyLocales(locales)(SectionsWrapper);
@@ -19,7 +19,7 @@ var fr = {
19
19
  installed: "Install\xE9e",
20
20
  maintenance: "En maintenance",
21
21
  update: "Mise \xE0 jour dispo.",
22
- favorite: "Ajout\xE9 sur la page d'accueil"
22
+ favorite: "Ajout\xE9 sur l'accueil"
23
23
  }
24
24
  };
25
25
  var styles = {
@@ -36,7 +36,6 @@ import { ShortcutTile } from "cozy-ui/transpiled/react/ShortcutTile";
36
36
  import Tile, { TileTitle, TileSubtitle, TileFooter, TileIcon, TileDescription } from "cozy-ui/transpiled/react/Tile";
37
37
  import palette from "cozy-ui/transpiled/react/palette";
38
38
  import { AppDoctype } from "cozy-ui/transpiled/react/proptypes";
39
- import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
40
39
  import { createUseI18n } from "cozy-ui/transpiled/react/providers/I18n";
41
40
  var locales = {
42
41
  en: en,
@@ -60,8 +59,6 @@ var getAppIconProps = function getAppIconProps() {
60
59
 
61
60
  var useI18n = createUseI18n(locales);
62
61
  export var AppTile = function AppTile(_ref) {
63
- var _app$metadata;
64
-
65
62
  var app = _ref.app,
66
63
  nameProp = _ref.name,
67
64
  namePrefix = _ref.namePrefix,
@@ -76,17 +73,12 @@ export var AppTile = function AppTile(_ref) {
76
73
 
77
74
  var _app$developer = app.developer,
78
75
  developer = _app$developer === void 0 ? {} : _app$developer;
79
-
80
- var _useBreakpoints = useBreakpoints(),
81
- isMobile = _useBreakpoints.isMobile;
82
-
83
76
  var name = nameProp || app.name;
84
77
  var statusLabel = getCurrentStatusLabel(app);
85
78
  var isStatusArray = Array.isArray(showStatus);
86
- var statusToDisplay = isShortcutFile(app) && statusLabel === APP_STATUS.installed && isMobile ? 'favorite' : isStatusArray ? showStatus.indexOf(statusLabel) > -1 && statusLabel : showStatus && statusLabel;
79
+ var statusToDisplay = isShortcutFile(app) && statusLabel === APP_STATUS.installed ? 'favorite' : isStatusArray ? showStatus.indexOf(statusLabel) > -1 && statusLabel : showStatus && statusLabel;
87
80
  var IconComponent = IconComponentProp || AppIcon;
88
81
  var isInMaintenanceWithSpecificDisplay = displaySpecificMaintenanceStyle && statusLabel === APP_STATUS.maintenance;
89
- var tileSubtitle = isShortcutFile(app) ? (_app$metadata = app.metadata) === null || _app$metadata === void 0 ? void 0 : _app$metadata.source : developer.name;
90
82
  return /*#__PURE__*/React.createElement(Tile, {
91
83
  tag: "button",
92
84
  type: "button",
@@ -107,7 +99,7 @@ export var AppTile = function AppTile(_ref) {
107
99
  className: styles["AppTile-description"]
108
100
  }, /*#__PURE__*/React.createElement(TileTitle, {
109
101
  isMultiline: !statusLabel
110
- }, namePrefix ? "".concat(namePrefix, " ").concat(name) : name), showDeveloper && /*#__PURE__*/React.createElement(TileSubtitle, null, "".concat(t('app_item.by'), " ").concat(tileSubtitle)), statusToDisplay && /*#__PURE__*/React.createElement(TileFooter, {
102
+ }, namePrefix ? "".concat(namePrefix, " ").concat(name) : name), developer.name && showDeveloper && /*#__PURE__*/React.createElement(TileSubtitle, null, "".concat(t('app_item.by'), " ").concat(developer.name)), statusToDisplay && /*#__PURE__*/React.createElement(TileFooter, {
111
103
  isAccent: statusLabel === APP_STATUS.update
112
104
  }, t("app_item.".concat(statusToDisplay)))));
113
105
  };
@@ -114,7 +114,8 @@ I18n.childContextTypes = {
114
114
  polyglot: PropTypes.object,
115
115
  lang: PropTypes.string
116
116
  };
117
- export { initTranslation, extend, useExtendI18n } from './translation';
117
+ export { initTranslation, extend } from './translation';
118
118
  export { default as translate } from './translate';
119
119
  export { default as createUseI18n } from './createUseI18n';
120
+ export { default as useExtendI18n } from './useExtendI18n';
120
121
  export default I18n;
@@ -1,5 +1,5 @@
1
1
  import Polyglot from 'node-polyglot';
2
- import { DEFAULT_LANG, useI18n } from "cozy-ui/transpiled/react/providers/I18n";
2
+ import { DEFAULT_LANG } from "cozy-ui/transpiled/react/providers/I18n";
3
3
  export var _polyglot;
4
4
  export var initTranslation = function initTranslation(lang, dictRequire, context) {
5
5
  var defaultLang = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_LANG;
@@ -37,35 +37,4 @@ export var extend = function extend(dict, polyglot) {
37
37
  var _ref;
38
38
 
39
39
  return (_ref = polyglot || _polyglot) === null || _ref === void 0 ? void 0 : _ref.extend(dict);
40
- }; // Use to determine if we need to merge locales again, and to avoid useless calls
41
-
42
- var useExtendI18nLang = '';
43
- /**
44
- * Hook to merge app locales with cozy-ui locales
45
- * @param {object} locales - Locales sorted by lang `{ fr: {...}, en: {...} }`
46
- * @returns {void}
47
- */
48
-
49
- export var useExtendI18n = function useExtendI18n(locales) {
50
- var _useI18n = useI18n(),
51
- lang = _useI18n.lang,
52
- polyglot = _useI18n.polyglot;
53
-
54
- if (!locales || !lang || !polyglot) return; // To simplify code we use Polyglot.extend to merge
55
- // locales from object and from polyglot.phrases
56
- // rather than native JS or lodash. this is why we have two extend.
57
-
58
- if (useExtendI18nLang !== lang) {
59
- var _polyglot2 = new Polyglot({
60
- phrases: locales[lang],
61
- locale: lang
62
- }); // merge locales from app and cozy-ui, without replacing existing one in app
63
-
64
-
65
- extend(polyglot.phrases, _polyglot2); // use merged locales in app
66
-
67
- extend(_polyglot2.phrases, polyglot); // set the sitch to avoid useless merge
68
-
69
- useExtendI18nLang = lang;
70
- }
71
40
  };
@@ -0,0 +1,42 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import Polyglot from 'node-polyglot';
3
+ import { useState } from 'react';
4
+ import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
5
+ import { extend } from "cozy-ui/transpiled/react/providers/I18n/translation";
6
+ /**
7
+ * Hook to merge app locales with cozy-ui locales
8
+ * @param {object} locales - Locales sorted by lang `{ fr: {...}, en: {...} }`
9
+ * @returns {void}
10
+ */
11
+
12
+ var useExtendI18n = function useExtendI18n(locales) {
13
+ var _useI18n = useI18n(),
14
+ lang = _useI18n.lang,
15
+ polyglot = _useI18n.polyglot; // Use to determine if we need to merge locales again, and to avoid useless calls
16
+
17
+
18
+ var _useState = useState(''),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ useExtendI18nLang = _useState2[0],
21
+ setUseExtendI18nLang = _useState2[1];
22
+
23
+ if (!locales || !lang || !polyglot) return; // To simplify code we use Polyglot.extend to merge
24
+ // locales from object and from polyglot.phrases
25
+ // rather than native JS or lodash. this is why we have two extend.
26
+
27
+ if (useExtendI18nLang !== lang) {
28
+ var _polyglot = new Polyglot({
29
+ phrases: locales[lang],
30
+ locale: lang
31
+ }); // merge locales from app and cozy-ui, without replacing existing one in app
32
+
33
+
34
+ extend(polyglot.phrases, _polyglot); // use merged locales in app
35
+
36
+ extend(_polyglot.phrases, polyglot); // set the switch to avoid useless merge
37
+
38
+ setUseExtendI18nLang(lang);
39
+ }
40
+ };
41
+
42
+ export default useExtendI18n;