cozy-ui 127.12.0 → 127.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,10 @@
1
+ # [127.13.0](https://github.com/cozy/cozy-ui/compare/v127.12.0...v127.13.0) (2025-08-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * **ContactsList:** Move locales inside `ContactsList` attribute ([068d23e](https://github.com/cozy/cozy-ui/commit/068d23e))
7
+
1
8
  # [127.12.0](https://github.com/cozy/cozy-ui/compare/v127.11.0...v127.12.0) (2025-08-20)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "127.12.0",
3
+ "version": "127.13.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -1,12 +1,7 @@
1
1
  import en from './en.json'
2
2
  import fr from './fr.json'
3
- // import { getI18n } from '../../../providers/I18n/helpers'
4
- // import withOnlyLocales from '../../../providers/I18n/withOnlyLocales'
5
3
 
6
4
  export const locales = {
7
5
  en,
8
6
  fr
9
7
  }
10
-
11
- // export const getOwnI18n = () => getI18n(undefined, lang => locales[lang])
12
- // export default withOnlyLocales(locales)
@@ -1,12 +1,7 @@
1
1
  import en from './en.json'
2
2
  import fr from './fr.json'
3
- // import { getI18n } from '../../../providers/I18n/helpers'
4
- // import withOnlyLocales from '../../../providers/I18n/withOnlyLocales'
5
3
 
6
4
  export const locales = {
7
5
  en,
8
6
  fr
9
7
  }
10
-
11
- // export const getOwnI18n = () => getI18n(undefined, lang => locales[lang])
12
- // export default withOnlyLocales(locales)
@@ -29,7 +29,7 @@ const Cell = ({ row, column, cell, actions }) => {
29
29
  <ListItemIcon>
30
30
  <IconButton
31
31
  ref={actionsRef}
32
- arial-label={t('menu')}
32
+ arial-label={t('ContactsList.menu')}
33
33
  onClick={() => setShowActions(true)}
34
34
  >
35
35
  <Icon icon={DotsIcon} />
@@ -14,7 +14,11 @@ const MyselfMarker = () => {
14
14
  useExtendI18n(locales)
15
15
  const { t } = useI18n()
16
16
 
17
- return <span className={`${styles['contact-myself']}`}>({t('me')})</span>
17
+ return (
18
+ <span className={`${styles['contact-myself']}`}>
19
+ ({t('ContactsList.me')})
20
+ </span>
21
+ )
18
22
  }
19
23
 
20
24
  const ContactIdentity = ({ contact }) => {
@@ -4,13 +4,15 @@ import React from 'react'
4
4
  import ContactRow from './ContactRow'
5
5
  import { sortContacts, categorizeContacts, sortHeaders } from './helpers'
6
6
  import withContactsListLocales from './locales/withContactsListLocales'
7
+ import { locales } from './locales/withContactsListLocales'
7
8
  import List from '../List'
8
9
  import ListSubheader from '../ListSubheader'
9
10
  import { Table } from '../deprecated/Table'
10
11
  import useBreakpoints from '../providers/Breakpoints'
11
- import { useI18n } from '../providers/I18n'
12
+ import { useI18n, useExtendI18n } from '../providers/I18n'
12
13
 
13
14
  const ContactsList = ({ contacts, onItemClick, ...rest }) => {
15
+ useExtendI18n(locales)
14
16
  const { t } = useI18n()
15
17
  const sortedContacts = sortContacts(contacts)
16
18
  const categorizedContacts = categorizeContacts(sortedContacts, t)
@@ -32,10 +32,10 @@ export const sortContacts = contacts => contacts.sort(sortLastNameFirst)
32
32
  * @returns {string} header
33
33
  */
34
34
  const makeHeader = (contact, t) => {
35
- if (contact.me) return t('me')
35
+ if (contact.me) return t('ContactsList.me')
36
36
 
37
37
  const name = buildLastNameFirst(contact)
38
- return name[0] || t('empty')
38
+ return name[0] || t('ContactsList.empty')
39
39
  }
40
40
 
41
41
  /**
@@ -45,8 +45,8 @@ const makeHeader = (contact, t) => {
45
45
  * @returns {string} header
46
46
  */
47
47
  const makeHeaderForIndexedContacts = (contact, t) => {
48
- if (contact.me) return t('me')
49
- if (contact.cozyMetadata?.favorite) return t('favorite')
48
+ if (contact.me) return t('ContactsList.me')
49
+ if (contact.cozyMetadata?.favorite) return t('ContactsList.favorite')
50
50
 
51
51
  const index = get(contact, 'indexes.byFamilyNameGivenNameEmailCozyUrl', '')
52
52
  const hasIndex = index !== null && index.length > 0
@@ -58,7 +58,7 @@ const makeHeaderForIndexedContacts = (contact, t) => {
58
58
  return firstLetterWithoutAccent
59
59
  }
60
60
 
61
- return t('empty')
61
+ return t('ContactsList.empty')
62
62
  }
63
63
 
64
64
  /**
@@ -89,7 +89,8 @@ export const categorizeContacts = (contacts, t) =>
89
89
  export const sortHeaders = (categorized, t) => {
90
90
  const headers = Object.keys(categorized)
91
91
  const notEmptyAndMyselfHeaders = headers.filter(
92
- header => header !== t('empty') && header !== t('me')
92
+ header =>
93
+ header !== t('ContactsList.empty') && header !== t('ContactsList.me')
93
94
  )
94
95
  const notEmptyAndMyselfSorted = notEmptyAndMyselfHeaders.slice().sort()
95
96
 
@@ -98,11 +99,11 @@ export const sortHeaders = (categorized, t) => {
98
99
  }
99
100
 
100
101
  const headersSorted = []
101
- if (headers.includes(t('me'))) {
102
- headersSorted.push(t('me'))
102
+ if (headers.includes(t('ContactsList.me'))) {
103
+ headersSorted.push(t('ContactsList.me'))
103
104
  }
104
- if (headers.includes(t('empty'))) {
105
- headersSorted.push(t('empty'))
105
+ if (headers.includes(t('ContactsList.empty'))) {
106
+ headersSorted.push(t('ContactsList.empty'))
106
107
  }
107
108
 
108
109
  return headersSorted.concat(notEmptyAndMyselfSorted)
@@ -103,7 +103,7 @@ describe('sortHeaders', () => {
103
103
 
104
104
  const sortedHeaders = sortHeaders(contacts, t)
105
105
 
106
- expect(sortedHeaders).toEqual(['me', 'empty', 'B', 'F', 'H'])
106
+ expect(sortedHeaders).toEqual(['B', 'F', 'H', 'empty', 'me'])
107
107
  })
108
108
  })
109
109
 
@@ -143,7 +143,16 @@ describe('makeGroupLabelsAndCounts', () => {
143
143
  const res = makeGroupLabelsAndCounts(contacts, t)
144
144
 
145
145
  expect(res).toStrictEqual({
146
- groupLabels: ['A', 'C', 'B', 'X', 'Z', 'empty', 'me', 'E'],
146
+ groupLabels: [
147
+ 'A',
148
+ 'C',
149
+ 'B',
150
+ 'X',
151
+ 'Z',
152
+ 'ContactsList.empty',
153
+ 'ContactsList.me',
154
+ 'E'
155
+ ],
147
156
  groupCounts: [3, 5, 2, 1, 1, 4, 1, 1]
148
157
  })
149
158
  })
@@ -1,6 +1,8 @@
1
1
  {
2
- "empty": "EMPTY",
3
- "me": "me",
4
- "favorite": "favorites",
5
- "menu": "Menu"
2
+ "ContactsList": {
3
+ "empty": "EMPTY",
4
+ "me": "me",
5
+ "favorite": "favorites",
6
+ "menu": "Menu"
7
+ }
6
8
  }
@@ -1,6 +1,8 @@
1
1
  {
2
- "empty": "VIDE",
3
- "me": "moi",
4
- "favorite": "favoris",
5
- "menu": "Menu"
6
- }
2
+ "ContactsList": {
3
+ "empty": "VIDE",
4
+ "me": "moi",
5
+ "favorite": "favoris",
6
+ "menu": "Menu"
7
+ }
8
+ }
@@ -39,11 +39,8 @@ var fr = {
39
39
  }
40
40
  }
41
41
  }
42
- }; // import { getI18n } from '../../../providers/I18n/helpers'
43
- // import withOnlyLocales from '../../../providers/I18n/withOnlyLocales'
44
-
42
+ };
45
43
  export var locales = {
46
44
  en: en,
47
45
  fr: fr
48
- }; // export const getOwnI18n = () => getI18n(undefined, lang => locales[lang])
49
- // export default withOnlyLocales(locales)
46
+ };
@@ -27,11 +27,8 @@ var fr = {
27
27
  }
28
28
  }
29
29
  }
30
- }; // import { getI18n } from '../../../providers/I18n/helpers'
31
- // import withOnlyLocales from '../../../providers/I18n/withOnlyLocales'
32
-
30
+ };
33
31
  export var locales = {
34
32
  en: en,
35
33
  fr: fr
36
- }; // export const getOwnI18n = () => getI18n(undefined, lang => locales[lang])
37
- // export default withOnlyLocales(locales)
34
+ };
@@ -41,7 +41,7 @@ var Cell = function Cell(_ref) {
41
41
 
42
42
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(IconButton, {
43
43
  ref: actionsRef,
44
- "arial-label": t('menu'),
44
+ "arial-label": t('ContactsList.menu'),
45
45
  onClick: function onClick() {
46
46
  return setShowActions(true);
47
47
  }
@@ -28,7 +28,7 @@ var MyselfMarker = function MyselfMarker() {
28
28
 
29
29
  return /*#__PURE__*/React.createElement("span", {
30
30
  className: "".concat(styles['contact-myself'])
31
- }, "(", t('me'), ")");
31
+ }, "(", t('ContactsList.me'), ")");
32
32
  };
33
33
 
34
34
  var ContactIdentity = function ContactIdentity(_ref) {
@@ -5,17 +5,20 @@ import React from 'react';
5
5
  import ContactRow from "cozy-ui/transpiled/react/ContactsList/ContactRow";
6
6
  import { sortContacts, categorizeContacts, sortHeaders } from "cozy-ui/transpiled/react/ContactsList/helpers";
7
7
  import withContactsListLocales from "cozy-ui/transpiled/react/ContactsList/locales/withContactsListLocales";
8
+ import { locales } from "cozy-ui/transpiled/react/ContactsList/locales/withContactsListLocales";
8
9
  import List from "cozy-ui/transpiled/react/List";
9
10
  import ListSubheader from "cozy-ui/transpiled/react/ListSubheader";
10
11
  import { Table } from "cozy-ui/transpiled/react/deprecated/Table";
11
12
  import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
12
- import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
13
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
13
14
 
14
15
  var ContactsList = function ContactsList(_ref) {
15
16
  var contacts = _ref.contacts,
16
17
  onItemClick = _ref.onItemClick,
17
18
  rest = _objectWithoutProperties(_ref, _excluded);
18
19
 
20
+ useExtendI18n(locales);
21
+
19
22
  var _useI18n = useI18n(),
20
23
  t = _useI18n.t;
21
24
 
@@ -25,9 +25,9 @@ export var sortContacts = function sortContacts(contacts) {
25
25
  */
26
26
 
27
27
  var makeHeader = function makeHeader(contact, t) {
28
- if (contact.me) return t('me');
28
+ if (contact.me) return t('ContactsList.me');
29
29
  var name = buildLastNameFirst(contact);
30
- return name[0] || t('empty');
30
+ return name[0] || t('ContactsList.empty');
31
31
  };
32
32
  /**
33
33
  * Build header for a contact (first letter of indexes.byFamilyNameGivenNameEmailCozyUrl)
@@ -40,8 +40,8 @@ var makeHeader = function makeHeader(contact, t) {
40
40
  var makeHeaderForIndexedContacts = function makeHeaderForIndexedContacts(contact, t) {
41
41
  var _contact$cozyMetadata;
42
42
 
43
- if (contact.me) return t('me');
44
- if ((_contact$cozyMetadata = contact.cozyMetadata) !== null && _contact$cozyMetadata !== void 0 && _contact$cozyMetadata.favorite) return t('favorite');
43
+ if (contact.me) return t('ContactsList.me');
44
+ if ((_contact$cozyMetadata = contact.cozyMetadata) !== null && _contact$cozyMetadata !== void 0 && _contact$cozyMetadata.favorite) return t('ContactsList.favorite');
45
45
  var index = get(contact, 'indexes.byFamilyNameGivenNameEmailCozyUrl', '');
46
46
  var hasIndex = index !== null && index.length > 0;
47
47
 
@@ -50,7 +50,7 @@ var makeHeaderForIndexedContacts = function makeHeaderForIndexedContacts(contact
50
50
  return firstLetterWithoutAccent;
51
51
  }
52
52
 
53
- return t('empty');
53
+ return t('ContactsList.empty');
54
54
  };
55
55
  /**
56
56
  * @typedef {Object.<string, Object>} CategorizedContactsResult
@@ -83,7 +83,7 @@ export var categorizeContacts = function categorizeContacts(contacts, t) {
83
83
  export var sortHeaders = function sortHeaders(categorized, t) {
84
84
  var headers = Object.keys(categorized);
85
85
  var notEmptyAndMyselfHeaders = headers.filter(function (header) {
86
- return header !== t('empty') && header !== t('me');
86
+ return header !== t('ContactsList.empty') && header !== t('ContactsList.me');
87
87
  });
88
88
  var notEmptyAndMyselfSorted = notEmptyAndMyselfHeaders.slice().sort();
89
89
 
@@ -93,12 +93,12 @@ export var sortHeaders = function sortHeaders(categorized, t) {
93
93
 
94
94
  var headersSorted = [];
95
95
 
96
- if (headers.includes(t('me'))) {
97
- headersSorted.push(t('me'));
96
+ if (headers.includes(t('ContactsList.me'))) {
97
+ headersSorted.push(t('ContactsList.me'));
98
98
  }
99
99
 
100
- if (headers.includes(t('empty'))) {
101
- headersSorted.push(t('empty'));
100
+ if (headers.includes(t('ContactsList.empty'))) {
101
+ headersSorted.push(t('ContactsList.empty'));
102
102
  }
103
103
 
104
104
  return headersSorted.concat(notEmptyAndMyselfSorted);
@@ -1,14 +1,18 @@
1
1
  var en = {
2
- empty: "EMPTY",
3
- me: "me",
4
- favorite: "favorites",
5
- menu: "Menu"
2
+ ContactsList: {
3
+ empty: "EMPTY",
4
+ me: "me",
5
+ favorite: "favorites",
6
+ menu: "Menu"
7
+ }
6
8
  };
7
9
  var fr = {
8
- empty: "VIDE",
9
- me: "moi",
10
- favorite: "favoris",
11
- menu: "Menu"
10
+ ContactsList: {
11
+ empty: "VIDE",
12
+ me: "moi",
13
+ favorite: "favoris",
14
+ menu: "Menu"
15
+ }
12
16
  };
13
17
  import withOnlyLocales from "cozy-ui/transpiled/react/providers/I18n/withOnlyLocales";
14
18
  export var locales = {