cozy-ui 111.12.0 → 111.14.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 (43) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/package.json +1 -1
  3. package/react/AppSections/Sections.jsx +8 -8
  4. package/react/AppSections/__snapshots__/index.spec.jsx.snap +2 -2
  5. package/react/AppSections/categories.spec.js +2 -2
  6. package/react/AppSections/components/__snapshots__/AppsSection.spec.jsx.snap +1 -1
  7. package/react/AppSections/locales/en.json +2 -2
  8. package/react/AppSections/locales/fr.json +2 -2
  9. package/react/AppTile/index.jsx +3 -8
  10. package/react/AppTile/locales/fr.json +1 -1
  11. package/react/BottomSheet/BottomSheet.jsx +5 -1
  12. package/react/BottomSheet/README.md +2 -0
  13. package/react/BottomSheet/helpers.js +2 -0
  14. package/react/BottomSheet/helpers.spec.js +12 -0
  15. package/react/CozyDialogs/Readme.md +8 -1
  16. package/react/CozyDialogs/dialogPropTypes.js +1 -1
  17. package/react/CozyDialogs/useCozyDialog.js +4 -1
  18. package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +4 -0
  19. package/react/SearchBar/Readme.md +56 -3
  20. package/react/SearchBar/index.jsx +105 -27
  21. package/react/SearchBar/locales/en.json +1 -1
  22. package/react/SearchBar/locales/fr.json +1 -1
  23. package/react/providers/DemoProvider.jsx +3 -9
  24. package/react/providers/I18n/index.jsx +2 -1
  25. package/react/providers/I18n/translation.jsx +1 -32
  26. package/react/providers/I18n/useExtendI18n.jsx +37 -0
  27. package/transpiled/react/AppSections/Sections.js +17 -11
  28. package/transpiled/react/AppTile/index.js +3 -11
  29. package/transpiled/react/BottomSheet/BottomSheet.js +7 -1
  30. package/transpiled/react/BottomSheet/helpers.js +3 -1
  31. package/transpiled/react/CozyDialogs/dialogPropTypes.js +1 -1
  32. package/transpiled/react/CozyDialogs/useCozyDialog.js +12 -7
  33. package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +4 -0
  34. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +4 -0
  35. package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +4 -0
  36. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +4 -0
  37. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +4 -0
  38. package/transpiled/react/SearchBar/index.js +113 -30
  39. package/transpiled/react/SearchBar/locales/withOnlyLocales.js +2 -2
  40. package/transpiled/react/providers/DemoProvider.js +5 -10
  41. package/transpiled/react/providers/I18n/index.js +2 -1
  42. package/transpiled/react/providers/I18n/translation.js +1 -32
  43. package/transpiled/react/providers/I18n/useExtendI18n.js +42 -0
@@ -1,10 +1,10 @@
1
1
  var en = {
2
- search: {
2
+ SearchBar: {
3
3
  placeholder: "Search"
4
4
  }
5
5
  };
6
6
  var fr = {
7
- search: {
7
+ SearchBar: {
8
8
  placeholder: "Rechercher"
9
9
  }
10
10
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { CozyProvider } from 'cozy-client';
3
3
  import { BreakpointsProvider } from "cozy-ui/transpiled/react/providers/Breakpoints";
4
4
  import CozyTheme from "cozy-ui/transpiled/react/providers/CozyTheme";
5
- import { I18nContext } from "cozy-ui/transpiled/react/providers/I18n";
5
+ import I18n from "cozy-ui/transpiled/react/providers/I18n";
6
6
  var defaultClient = {
7
7
  plugins: {
8
8
  realtime: {
@@ -30,15 +30,10 @@ var DemoProvider = function DemoProvider(_ref) {
30
30
  var lang = localStorage.getItem('lang') || 'en';
31
31
  return /*#__PURE__*/React.createElement(CozyProvider, {
32
32
  client: client || defaultClient
33
- }, /*#__PURE__*/React.createElement(BreakpointsProvider, null, /*#__PURE__*/React.createElement(I18nContext.Provider, {
34
- value: {
35
- t: function t(x) {
36
- return x;
37
- },
38
- f: function f() {
39
- return '01 Jan. 2022';
40
- },
41
- lang: lang
33
+ }, /*#__PURE__*/React.createElement(BreakpointsProvider, null, /*#__PURE__*/React.createElement(I18n, {
34
+ lang: lang,
35
+ dictRequire: function dictRequire() {
36
+ return {};
42
37
  }
43
38
  }, /*#__PURE__*/React.createElement(CozyTheme, {
44
39
  variant: variant
@@ -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;