cozy-ui 77.7.0 → 77.8.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 +14 -0
- package/package.json +1 -1
- package/react/I18n/index.jsx +10 -2
- package/react/I18n/index.spec.jsx +37 -0
- package/react/InputAdornment/Readme.md +1 -0
- package/react/InputAdornment/index.js +3 -0
- package/react/index.js +1 -0
- package/transpiled/react/I18n/index.js +12 -2
- package/transpiled/react/InputAdornment/index.js +2 -0
- package/transpiled/react/index.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [77.8.0](https://github.com/cozy/cozy-ui/compare/v77.7.1...v77.8.0) (2022-11-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add InputAdornment component ([b92a034](https://github.com/cozy/cozy-ui/commit/b92a034))
|
|
7
|
+
|
|
8
|
+
## [77.7.1](https://github.com/cozy/cozy-ui/compare/v77.7.0...v77.7.1) (2022-11-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Load default langage when using createUseI18n ([5ce65fe](https://github.com/cozy/cozy-ui/commit/5ce65fe))
|
|
14
|
+
|
|
1
15
|
# [77.7.0](https://github.com/cozy/cozy-ui/compare/v77.6.0...v77.7.0) (2022-11-21)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/react/I18n/index.jsx
CHANGED
|
@@ -102,9 +102,17 @@ export const createUseI18n = locales => () => {
|
|
|
102
102
|
const { lang } = useI18n() || { lang: DEFAULT_LANG }
|
|
103
103
|
return useMemo(() => {
|
|
104
104
|
const polyglot = new Polyglot({
|
|
105
|
-
|
|
106
|
-
phrases: locales[
|
|
105
|
+
locale: DEFAULT_LANG,
|
|
106
|
+
phrases: locales[DEFAULT_LANG]
|
|
107
107
|
})
|
|
108
|
+
if (lang && lang !== DEFAULT_LANG) {
|
|
109
|
+
try {
|
|
110
|
+
polyglot.locale(lang)
|
|
111
|
+
polyglot.extend(locales[lang])
|
|
112
|
+
} catch (e) {
|
|
113
|
+
console.warn(`The dict phrases for "${lang}" can't be loaded`)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
108
116
|
const f = initFormat(lang)
|
|
109
117
|
const t = polyglot.t.bind(polyglot)
|
|
110
118
|
return { t, f, lang }
|
|
@@ -87,3 +87,40 @@ describe('use i18n with custom locales', () => {
|
|
|
87
87
|
expect(root.getByText('Bonjour le monde')).toBeTruthy()
|
|
88
88
|
})
|
|
89
89
|
})
|
|
90
|
+
|
|
91
|
+
describe('use i18n with custom locales and fallback to default', () => {
|
|
92
|
+
const locales = {
|
|
93
|
+
en: {
|
|
94
|
+
'hello-world': 'Hello world',
|
|
95
|
+
'how-are-you': 'How are you ?'
|
|
96
|
+
},
|
|
97
|
+
fr: {
|
|
98
|
+
'hello-world': 'Bonjour le monde'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const useI18n = createUseI18n(locales)
|
|
102
|
+
const Child = () => {
|
|
103
|
+
const { t } = useI18n()
|
|
104
|
+
return (
|
|
105
|
+
<div>
|
|
106
|
+
<div>{t('hello-world')}</div>
|
|
107
|
+
<div>{t('how-are-you')}</div>
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
const Parent = () => {
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
<I18n lang="fr" dictRequire={() => ({})}>
|
|
115
|
+
<Child />
|
|
116
|
+
</I18n>
|
|
117
|
+
</>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
it('should display missing key in default langage', () => {
|
|
122
|
+
const root = render(<Parent />)
|
|
123
|
+
expect(root.getByText('Bonjour le monde')).toBeInTheDocument()
|
|
124
|
+
expect(root.getByText('How are you ?')).toBeInTheDocument()
|
|
125
|
+
})
|
|
126
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Re-export of @material-ui. See [the official API](https://v4.mui.com/api/input-adornment).
|
package/react/index.js
CHANGED
|
@@ -133,9 +133,19 @@ export var createUseI18n = function createUseI18n(locales) {
|
|
|
133
133
|
|
|
134
134
|
return useMemo(function () {
|
|
135
135
|
var polyglot = new Polyglot({
|
|
136
|
-
|
|
137
|
-
phrases: locales[
|
|
136
|
+
locale: DEFAULT_LANG,
|
|
137
|
+
phrases: locales[DEFAULT_LANG]
|
|
138
138
|
});
|
|
139
|
+
|
|
140
|
+
if (lang && lang !== DEFAULT_LANG) {
|
|
141
|
+
try {
|
|
142
|
+
polyglot.locale(lang);
|
|
143
|
+
polyglot.extend(locales[lang]);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.warn("The dict phrases for \"".concat(lang, "\" can't be loaded"));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
139
149
|
var f = initFormat(lang);
|
|
140
150
|
var t = polyglot.t.bind(polyglot);
|
|
141
151
|
return {
|
|
@@ -88,4 +88,5 @@ export { default as AlertTitle } from './AlertTitle';
|
|
|
88
88
|
export { default as Tabs } from './Tabs';
|
|
89
89
|
export { default as Tab } from './Tab';
|
|
90
90
|
export { default as CircularChart } from './CircularChart';
|
|
91
|
-
export { default as Skeleton } from './Skeleton';
|
|
91
|
+
export { default as Skeleton } from './Skeleton';
|
|
92
|
+
export { default as InputAdornment } from './InputAdornment';
|