cozy-ui 117.2.2 → 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 CHANGED
@@ -1,3 +1,24 @@
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
+
15
+ # [117.3.0](https://github.com/cozy/cozy-ui/compare/v117.2.2...v117.3.0) (2025-02-20)
16
+
17
+
18
+ ### Features
19
+
20
+ * Add FileTypeServer illustration ([740ddb7](https://github.com/cozy/cozy-ui/commit/740ddb7))
21
+
1
22
  ## [117.2.2](https://github.com/cozy/cozy-ui/compare/v117.2.1...v117.2.2) (2025-02-04)
2
23
 
3
24
 
@@ -0,0 +1 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.799 16.501A4 4 0 0 1 5.923 15h20.155a4 4 0 0 1 3.123 1.501l2.142 2.677A3 3 0 0 1 32 21.052V24H0v-2.948a3 3 0 0 1 .657-1.874L2.8 16.501ZM2.799 2.501A4 4 0 0 1 5.923 1h20.155A4 4 0 0 1 29.2 2.501l2.142 2.677A3 3 0 0 1 32 7.052V10H0V7.052a3 3 0 0 1 .657-1.874L2.8 2.501Z" fill="#197BFF"/><path d="M0 21a2 2 0 0 1 2-2h28a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-8ZM0 7a2 2 0 0 1 2-2h28a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V7Z" fill="#B2D3FF"/><path d="M8 25a2 2 0 1 1-4 0 2 2 0 0 1 4 0ZM8 11a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" fill="#297EF2"/></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "117.2.2",
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",
@@ -693,6 +693,7 @@ import FileTypeBinIcon from 'cozy-ui/transpiled/react/Icons/FileTypeBin'
693
693
  import FileTypeCodeIcon from 'cozy-ui/transpiled/react/Icons/FileTypeCode'
694
694
  import FileTypeFilesIcon from 'cozy-ui/transpiled/react/Icons/FileTypeFiles'
695
695
  import FileTypeFolderIcon from 'cozy-ui/transpiled/react/Icons/FileTypeFolder'
696
+ import FileTypeServerIcon from 'cozy-ui/transpiled/react/Icons/FileTypeServer'
696
697
  import FileTypeImageIcon from 'cozy-ui/transpiled/react/Icons/FileTypeImage'
697
698
  import FileTypeNoteIcon from 'cozy-ui/transpiled/react/Icons/FileTypeNote'
698
699
  import FileTypePdfIcon from 'cozy-ui/transpiled/react/Icons/FileTypePdf'
@@ -733,6 +734,7 @@ const icons = [
733
734
  FileTypeCodeIcon,
734
735
  FileTypeFilesIcon,
735
736
  FileTypeFolderIcon,
737
+ FileTypeServerIcon,
736
738
  FileTypeImageIcon,
737
739
  FileTypeNoteIcon,
738
740
  FileTypePdfIcon,
@@ -788,7 +790,7 @@ import Icon from 'cozy-ui/transpiled/react/Icon'
788
790
  import Typography from 'cozy-ui/transpiled/react/Typography'
789
791
  import Sprite from 'cozy-ui/transpiled/react/Icon/Sprite'
790
792
 
791
- const availableIcons = ['account', 'bottom-select', 'check-white', 'cloud-broken', 'contacts', 'cozy-authentification', 'cozy-logo', 'cozy-upgrade', 'credit-card-large', 'dash-white', 'device-browser', 'device-laptop', 'device-phone', 'device-tablet', 'file-type-audio', 'file-type-banking-account' , 'file-type-bin', 'file-type-code', 'file-type-files', 'file-type-folder', 'file-type-image', 'file-type-note', 'file-type-pdf', 'file-type-sheet', 'file-type-slide', 'file-type-text', 'file-type-video', 'file-type-zip', 'forbidden-sign', 'google', 'keychain', 'logout-large', 'papers', 'store', 'top-select', 'trash-duotone', 'cozy']
793
+ const availableIcons = ['account', 'bottom-select', 'check-white', 'cloud-broken', 'contacts', 'cozy-authentification', 'cozy-logo', 'cozy-upgrade', 'credit-card-large', 'dash-white', 'device-browser', 'device-laptop', 'device-phone', 'device-tablet', 'file-type-audio', 'file-type-banking-account' , 'file-type-bin', 'file-type-code', 'file-type-files', 'file-type-folder', 'file-type-server', 'file-type-image', 'file-type-note', 'file-type-pdf', 'file-type-sheet', 'file-type-slide', 'file-type-text', 'file-type-video', 'file-type-zip', 'forbidden-sign', 'google', 'keychain', 'logout-large', 'papers', 'store', 'top-select', 'trash-duotone', 'cozy']
792
794
 
793
795
  ;
794
796
 
@@ -0,0 +1,23 @@
1
+ // Automatically created, please run `scripts/generate-svgr-icon.sh assets/icons/illus/file-type-server.svg` to regenerate;
2
+ import React from 'react'
3
+
4
+ function SvgFileTypeServer(props) {
5
+ return (
6
+ <svg viewBox="0 0 32 32" fill="none" {...props}>
7
+ <path
8
+ d="M2.799 16.501A4 4 0 015.923 15h20.155a4 4 0 013.123 1.501l2.142 2.677A3 3 0 0132 21.052V24H0v-2.948a3 3 0 01.657-1.874L2.8 16.501zm0-14A4 4 0 015.923 1h20.155A4 4 0 0129.2 2.501l2.142 2.677A3 3 0 0132 7.052V10H0V7.052a3 3 0 01.657-1.874L2.8 2.501z"
9
+ fill="#197BFF"
10
+ />
11
+ <path
12
+ d="M0 21a2 2 0 012-2h28a2 2 0 012 2v8a2 2 0 01-2 2H2a2 2 0 01-2-2v-8zM0 7a2 2 0 012-2h28a2 2 0 012 2v8a2 2 0 01-2 2H2a2 2 0 01-2-2V7z"
13
+ fill="#B2D3FF"
14
+ />
15
+ <path
16
+ d="M8 25a2 2 0 11-4 0 2 2 0 014 0zm0-14a2 2 0 11-4 0 2 2 0 014 0z"
17
+ fill="#297EF2"
18
+ />
19
+ </svg>
20
+ )
21
+ }
22
+
23
+ export default SvgFileTypeServer
@@ -1,5 +1,2 @@
1
- module.exports = () => {
2
- return (
3
- navigator && navigator.userAgent && navigator.userAgent.includes('Argos')
4
- )
5
- }
1
+ export default () =>
2
+ navigator && navigator.userAgent && navigator.userAgent.includes('Argos')
package/react/palette.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // GENERATED AUTOMATICALLY FROM stylus/settings/palette.json
2
- module.exports = {
2
+ export default {
3
3
  black: 'var(--black)',
4
4
  white: 'var(--white)',
5
5
  paleGrey: 'var(--paleGrey)',
@@ -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
- const locales = {}
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 'en-US'
17
- case 'zh_cn':
18
- return 'zh-CN'
19
- case 'zh_tw':
20
- return 'zh-TW'
16
+ return enLocale
17
+ case 'fr':
18
+ return frLocale
19
+ case 'es':
20
+ return esLocale
21
21
  default:
22
- return lang
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. or has not been included in the build. Check if you have configured a ContextReplacementPlugin that is too restrictive.`
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
- locales[
34
- ensureDefaultLang
35
- ] = require(`date-fns/locale/${ensureDefaultLang}/index.js`)
36
- } catch (err) {
37
- console.warn(getWarningMessage(ensureDefaultLang))
31
+ const userLocale = getDateFnsLocale(userLang)
32
+ currentLocale = userLocale
33
+ return userLocale
34
+ } catch (e) {
35
+ console.warn(getWarningMessage(userLang))
38
36
  }
39
37
 
40
- if (lang && lang !== ensureDefaultLang) {
41
- try {
42
- locales[lang] = require(`date-fns/locale/${lang}/index.js`)
43
- } catch (e) {
44
- console.warn(getWarningMessage(lang))
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: locales[lang] })
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 fallback english if a date-fns locale can not be found', () => {
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 "module.exports = \``cat /tmp/icons-sprite.svg`\`" >> $outfile
13
+ echo "export default \``cat /tmp/icons-sprite.svg`\`" >> $outfile
@@ -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 "module.exports = `cat stylus/settings/palette.json`" >> $JS_PALETTE
10
+ echo "export default `cat stylus/settings/palette.json`" >> $JS_PALETTE
11
11
  node_modules/.bin/eslint --fix $JS_PALETTE