cozy-ui 117.3.0 → 118.0.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 -2
- package/react/helpers/isTesting.js +2 -5
- package/react/palette.js +1 -1
- package/react/providers/I18n/format.jsx +26 -29
- package/react/providers/I18n/format.spec.jsx +15 -1
- package/scripts/make-icon-sprite.sh +1 -1
- package/scripts/make-palette.sh +1 -1
- package/transpiled/react/Icon/icons-sprite.js +1 -1
- package/transpiled/react/helpers/isTesting.d.ts +2 -2
- package/transpiled/react/helpers/isTesting.js +2 -2
- package/transpiled/react/palette.d.ts +49 -46
- package/transpiled/react/palette.js +1 -1
- package/transpiled/react/providers/I18n/format.js +22 -28
- package/react/helpers/tracker.jsx +0 -173
- package/react/helpers/tracker.spec.js +0 -66
- package/transpiled/react/helpers/tracker.js +0 -162
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [118.0.0](https://github.com/cozy/cozy-ui/compare/v117.3.0...v118.0.0) (2025-03-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Migrate date formatting to es module ([9d4ab11](https://github.com/cozy/cozy-ui/commit/9d4ab11))
|
|
7
|
+
* Migrate to es module ([b677678](https://github.com/cozy/cozy-ui/commit/b677678))
|
|
8
|
+
* Remove tracking API ([a2dade9](https://github.com/cozy/cozy-ui/commit/a2dade9))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### BREAKING CHANGES
|
|
12
|
+
|
|
13
|
+
* 'cozy-ui/transpiled/react/helpers/tracker' endpoint has been removed. It was unused since we removed Piwik. You can safely delete the code.
|
|
14
|
+
|
|
1
15
|
# [117.3.0](https://github.com/cozy/cozy-ui/compare/v117.2.2...v117.3.0) (2025-02-20)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "118.0.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -173,7 +173,6 @@
|
|
|
173
173
|
"node-polyglot": "^2.5.0",
|
|
174
174
|
"normalize.css": "^8.0.0",
|
|
175
175
|
"pdf-lib": "1.17.1",
|
|
176
|
-
"piwik-react-router": "0.12.1",
|
|
177
176
|
"react-chartjs-2": "4.1.0",
|
|
178
177
|
"react-markdown": "^4.0.8",
|
|
179
178
|
"react-popper": "^2.2.3",
|
package/react/palette.js
CHANGED
|
@@ -1,50 +1,47 @@
|
|
|
1
1
|
import format from 'date-fns/format'
|
|
2
2
|
import formatDistanceToNow from 'date-fns/formatDistanceToNow'
|
|
3
|
+
import {
|
|
4
|
+
enGB as enLocale,
|
|
5
|
+
fr as frLocale,
|
|
6
|
+
es as esLocale
|
|
7
|
+
} from 'date-fns/locale'
|
|
3
8
|
|
|
4
9
|
import { DEFAULT_LANG } from '.'
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
let lang = DEFAULT_LANG
|
|
11
|
+
let currentLocale
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
* Ensure that the locale is in the correct format for date-fns (see 2.0.0 BC https://github.com/date-fns/date-fns/blob/main/CHANGELOG.md#200---2019-08-20)
|
|
11
|
-
* @param {string} lang
|
|
12
|
-
*/
|
|
13
|
-
const ensureLocaleFormat = lang => {
|
|
13
|
+
const getDateFnsLocale = lang => {
|
|
14
14
|
switch (lang) {
|
|
15
15
|
case 'en':
|
|
16
|
-
return
|
|
17
|
-
case '
|
|
18
|
-
return
|
|
19
|
-
case '
|
|
20
|
-
return
|
|
16
|
+
return enLocale
|
|
17
|
+
case 'fr':
|
|
18
|
+
return frLocale
|
|
19
|
+
case 'es':
|
|
20
|
+
return esLocale
|
|
21
21
|
default:
|
|
22
|
-
|
|
22
|
+
throw new Error('Locale not found')
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const getWarningMessage = lang =>
|
|
27
|
-
`The "${lang}" locale isn't supported by date-fns
|
|
27
|
+
`The "${lang}" locale isn't supported by date-fns or has not been included in the build. Check if you have configured a ContextReplacementPlugin that is too restrictive.`
|
|
28
28
|
|
|
29
29
|
export const provideDateFnsLocale = (userLang, defaultLang = DEFAULT_LANG) => {
|
|
30
|
-
lang = ensureLocaleFormat(userLang)
|
|
31
|
-
const ensureDefaultLang = ensureLocaleFormat(defaultLang)
|
|
32
30
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} catch (
|
|
37
|
-
console.warn(getWarningMessage(
|
|
31
|
+
const userLocale = getDateFnsLocale(userLang)
|
|
32
|
+
currentLocale = userLocale
|
|
33
|
+
return userLocale
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.warn(getWarningMessage(userLang))
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
try {
|
|
39
|
+
const defaultLocale = getDateFnsLocale(defaultLang)
|
|
40
|
+
currentLocale = defaultLocale
|
|
41
|
+
return defaultLocale
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.warn(getWarningMessage(defaultLang))
|
|
46
44
|
}
|
|
47
|
-
return locales[lang]
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
export const initFormat =
|
|
@@ -61,5 +58,5 @@ export const initFormat =
|
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
export const formatLocallyDistanceToNow = date => {
|
|
64
|
-
return formatDistanceToNow(date, { locale:
|
|
61
|
+
return formatDistanceToNow(date, { locale: currentLocale })
|
|
65
62
|
}
|
|
@@ -4,9 +4,11 @@ describe('initFormat', () => {
|
|
|
4
4
|
beforeEach(() => {
|
|
5
5
|
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
6
6
|
})
|
|
7
|
+
|
|
7
8
|
afterEach(() => {
|
|
8
9
|
console.warn.mockRestore()
|
|
9
10
|
})
|
|
11
|
+
|
|
10
12
|
it('should not throw if a date-fns locale can not be found', () => {
|
|
11
13
|
expect(() => initFormat('unknown-lang', 'unknown-default')).not.toThrow()
|
|
12
14
|
})
|
|
@@ -17,7 +19,13 @@ describe('initFormat', () => {
|
|
|
17
19
|
expect(date).toBe('1970-janvier-01')
|
|
18
20
|
})
|
|
19
21
|
|
|
20
|
-
it('should
|
|
22
|
+
it('should use the correct default locale if user locale can not be found', () => {
|
|
23
|
+
const f = initFormat('it', 'fr')
|
|
24
|
+
const date = f(0, 'yyyy-LLLL-dd')
|
|
25
|
+
expect(date).toBe('1970-janvier-01')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should fallback english if user locale and default locale can not be found', () => {
|
|
21
29
|
const f = initFormat('unknown-lang', 'unknown-default')
|
|
22
30
|
const date = f(0, 'yyyy-LLLL-dd')
|
|
23
31
|
expect(date).toBe('1970-January-01')
|
|
@@ -25,6 +33,12 @@ describe('initFormat', () => {
|
|
|
25
33
|
})
|
|
26
34
|
|
|
27
35
|
describe('formatLocallyDistanceToNow', () => {
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
// To avoid currentLocale set to 'fr' because of previous tests
|
|
38
|
+
const f = initFormat('en')
|
|
39
|
+
f(0, 'yyyy-LLLL-dd')
|
|
40
|
+
})
|
|
41
|
+
|
|
28
42
|
it('should formatDistanceToNow with small value', () => {
|
|
29
43
|
const date = Date.now() + 29 * 1000 // 29s
|
|
30
44
|
|
|
@@ -10,4 +10,4 @@ echo "Making icon sprite, output file : ${outfile}..."
|
|
|
10
10
|
echo $icons | xargs yarn svgstore --inline -o /tmp/icons-sprite.svg
|
|
11
11
|
echo "// GENERATED FILE, DO NOT EDIT THIS FILE BY HAND" > $outfile
|
|
12
12
|
echo "// Use yarn sprite to regenerate" >> $outfile
|
|
13
|
-
echo "
|
|
13
|
+
echo "export default \``cat /tmp/icons-sprite.svg`\`" >> $outfile
|
package/scripts/make-palette.sh
CHANGED
|
@@ -7,5 +7,5 @@ JS_PALETTE='react/palette.js'
|
|
|
7
7
|
|
|
8
8
|
echo "Making palette, output file : ${JS_PALETTE}..."
|
|
9
9
|
echo "// GENERATED AUTOMATICALLY FROM stylus/settings/palette.json" > $JS_PALETTE
|
|
10
|
-
echo "
|
|
10
|
+
echo "export default `cat stylus/settings/palette.json`" >> $JS_PALETTE
|
|
11
11
|
node_modules/.bin/eslint --fix $JS_PALETTE
|