cozy-ui 82.8.0 → 82.9.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,21 @@
1
+ # [82.9.0](https://github.com/cozy/cozy-ui/compare/v82.8.0...v82.9.0) (2023-04-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **helpers:** GetRandomUUID was called even if undefined ([749f79b](https://github.com/cozy/cozy-ui/commit/749f79b))
7
+ * **ListItemContact:** DisplayName wasn't compliant with old contact app ([1cd6ffb](https://github.com/cozy/cozy-ui/commit/1cd6ffb))
8
+ * **ListItemContact:** UseActions wasn't executed correctly in prod env ([8c06496](https://github.com/cozy/cozy-ui/commit/8c06496))
9
+ * **Viewer:** Typo for contractType ([382bf2e](https://github.com/cozy/cozy-ui/commit/382bf2e))
10
+
11
+
12
+ ### Features
13
+
14
+ * **ExpandedAttributes:** Add localized contact address support ([52fffe3](https://github.com/cozy/cozy-ui/commit/52fffe3))
15
+ * **ExpandedAttributes:** Add support for residence_permit... ([90c3af0](https://github.com/cozy/cozy-ui/commit/90c3af0))
16
+ * **ExpandedAttributes:** Remove driver license obtention date support ([3b7db1b](https://github.com/cozy/cozy-ui/commit/3b7db1b))
17
+ * **Viewer:** Add locales for residence permit ([f410942](https://github.com/cozy/cozy-ui/commit/f410942))
18
+
1
19
  # [82.8.0](https://github.com/cozy/cozy-ui/compare/v82.7.0...v82.8.0) (2023-03-31)
2
20
 
3
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "82.8.0",
3
+ "version": "82.9.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -10,7 +10,15 @@ export const normalizeExpandedAttribute = attr =>
10
10
 
11
11
  // attributes not considered as expanded attributes
12
12
  export const notExpandedAttributes = {
13
- 'io.cozy.contacts': ['fullname', 'civility', 'note'],
13
+ 'io.cozy.contacts': [
14
+ 'fullname',
15
+ 'civility',
16
+ 'note',
17
+ 'flexsearchProps:translated:phone',
18
+ 'flexsearchProps:translated:email',
19
+ 'flexsearchProps:translated:birthday',
20
+ 'flexsearchProps:translated:address'
21
+ ],
14
22
  'io.cozy.files': [
15
23
  'name',
16
24
  'flexsearchProps:translated:qualificationLabel',
@@ -21,7 +29,9 @@ export const notExpandedAttributes = {
21
29
  'flexsearchProps:translated:vehicleRegistration',
22
30
  'flexsearchProps:translated:nationalIdCard',
23
31
  'flexsearchProps:translated:bankDetails',
24
- 'flexsearchProps:translated:passport'
32
+ 'flexsearchProps:translated:passport',
33
+ 'flexsearchProps:translated:residencePermit',
34
+ 'flexsearchProps:translated:expirationDate'
25
35
  ]
26
36
  }
27
37
 
@@ -36,10 +46,6 @@ export const defaultExpandedAttributes = {
36
46
  'metadata.ibanNumber',
37
47
  'metadata.passportNumber',
38
48
  'metadata.noticePeriod',
39
- 'metadata.AObtentionDate',
40
- 'metadata.BObtentionDate',
41
- 'metadata.CObtentionDate',
42
- 'metadata.DObtentionDate',
43
49
  'metadata.obtentionDate',
44
50
  'metadata.expirationDate',
45
51
  'metadata.country',
@@ -0,0 +1,23 @@
1
+ import { hr, emailTo, smsTo, call } from '../../../ActionMenu/Actions'
2
+
3
+ export const makeOptionalActions = contact => {
4
+ const hasPhoneAction = contact.phone?.length > 0
5
+ const hasEmailAction = contact.email?.length > 0
6
+ const hasMessageActions = hasPhoneAction || hasEmailAction
7
+
8
+ const actionsAndOptions = [
9
+ { action: hr, condition: hasMessageActions },
10
+ { action: call, condition: hasPhoneAction },
11
+ { action: smsTo, condition: hasPhoneAction },
12
+ { action: emailTo, condition: hasEmailAction }
13
+ ]
14
+
15
+ const filteredOptionalActions = actionsAndOptions.reduce((acc, curr) => {
16
+ if (curr.condition) {
17
+ acc.push(curr.action)
18
+ }
19
+ return acc
20
+ }, [])
21
+
22
+ return filteredOptionalActions
23
+ }
@@ -0,0 +1,36 @@
1
+ import { hr, emailTo, smsTo, call } from '../../../ActionMenu/Actions'
2
+
3
+ import { makeOptionalActions } from './helpers'
4
+
5
+ describe('makeOptionalActions', () => {
6
+ it('should return hr, call, smsTo, emailTo', () => {
7
+ const res = makeOptionalActions({
8
+ email: [{ address: 'mail@cozy.com' }],
9
+ phone: [{ number: '123456' }]
10
+ })
11
+
12
+ expect(res).toStrictEqual([hr, call, smsTo, emailTo])
13
+ })
14
+
15
+ it('should return hr, emailTo', () => {
16
+ const res = makeOptionalActions({
17
+ email: [{ address: 'mail@cozy.com' }]
18
+ })
19
+
20
+ expect(res).toStrictEqual([hr, emailTo])
21
+ })
22
+
23
+ it('should return hr, call, smsTo', () => {
24
+ const res = makeOptionalActions({
25
+ phone: [{ number: '123456' }]
26
+ })
27
+
28
+ expect(res).toStrictEqual([hr, call, smsTo])
29
+ })
30
+
31
+ it('should empty array', () => {
32
+ const res = makeOptionalActions({})
33
+
34
+ expect(res).toStrictEqual([])
35
+ })
36
+ })
@@ -1,6 +1,8 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
+ import { getDisplayName } from 'cozy-client/dist/models/contact'
5
+
4
6
  import Filename from '../../../Filename'
5
7
  import Icon from '../../../Icon'
6
8
  import ContactsIcon from '../../../Icons/Contacts'
@@ -19,7 +21,7 @@ const ListItemContact = ({
19
21
  onClick
20
22
  }) => {
21
23
  const defaultActions = useActions(contact)
22
- const primaryText = primary || contact.displayName
24
+ const primaryText = primary || getDisplayName(contact)
23
25
  const secondaryText = secondary || contact.email?.[0]?.address
24
26
  const itemIcon = icon || <Icon icon={ContactsIcon} width="32" height="32" />
25
27
 
@@ -1,29 +1,9 @@
1
1
  import { useMemo } from 'react'
2
2
 
3
3
  import { makeActions } from '../../../ActionMenu/Actions/helpers'
4
- import { hr } from '../../../ActionMenu/Actions/hr'
5
- import { emailTo } from '../../../ActionMenu/Actions/emailTo'
6
- import { smsTo } from '../../../ActionMenu/Actions/smsTo'
7
- import { call } from '../../../ActionMenu/Actions/call'
8
4
  import { modify } from '../../../ActionMenu/Actions/modify'
9
5
  import { viewInContacts } from '../../../ActionMenu/Actions/viewInContacts'
10
-
11
- const makeOptionalActions = contact => {
12
- const optionalActions = [hr, call, smsTo, emailTo]
13
-
14
- const hasPhoneAction = contact.phone?.length > 0
15
- const hasEmailAction = contact.email?.length > 0
16
- const hasMessageActions = hasPhoneAction || hasEmailAction
17
-
18
- const conditions = {
19
- hr: hasMessageActions,
20
- call: hasPhoneAction,
21
- smsTo: hasPhoneAction,
22
- emailTo: hasEmailAction
23
- }
24
-
25
- return optionalActions.filter(action => conditions[action.name])
26
- }
6
+ import { makeOptionalActions } from './helpers'
27
7
 
28
8
  const useActions = contact => {
29
9
  const optionalActions = useMemo(() => makeOptionalActions(contact), [contact])
@@ -10,10 +10,6 @@
10
10
  "jobTitle": "Job title",
11
11
  "metadata": {
12
12
  "datetime": "Added on",
13
- "AObtentionDate": "License A, delivered on",
14
- "BObtentionDate": "License B, delivered on",
15
- "CObtentionDate": "License C, delivered on",
16
- "DObtentionDate": "License D, delivered on",
17
13
  "issueDate": "Delivered on",
18
14
  "expirationDate": "Expiration date",
19
15
  "referencedDate": "Referenced date",
@@ -36,7 +32,8 @@
36
32
  "vehicle_registration": "Vehicle registration number (VIN)",
37
33
  "national_id_card": "National ID card number",
38
34
  "bank_details": "IBAN number",
39
- "passport": "Passport number"
35
+ "passport": "Passport number",
36
+ "residence_permit": "License number"
40
37
  }
41
38
  }
42
39
  },
@@ -10,10 +10,6 @@
10
10
  "jobTitle": "Fonction",
11
11
  "metadata": {
12
12
  "datetime": "Ajouté le",
13
- "AObtentionDate": "Permis A, délivré le",
14
- "BObtentionDate": "Permis B, délivré le",
15
- "CObtentionDate": "Permis C, délivré le",
16
- "DObtentionDate": "Permis D, délivré le",
17
13
  "issueDate": "Délivré le",
18
14
  "expirationDate": "Date d'expiration",
19
15
  "referencedDate": "Date de référence",
@@ -36,7 +32,8 @@
36
32
  "vehicle_registration": "Numéro de la carte grise (VIN)",
37
33
  "national_id_card": "Numéro de la carte d'identité",
38
34
  "bank_details": "Numéro d'IBAN",
39
- "passport": "Numéro du passeport"
35
+ "passport": "Numéro du passeport",
36
+ "residence_permit": "Numéro du permis"
40
37
  }
41
38
  }
42
39
  },
@@ -73,11 +73,13 @@
73
73
  "driver_license": {
74
74
  "number": "License number"
75
75
  },
76
+ "residence_permit": {
77
+ "number": "License number"
78
+ },
76
79
  "country": "Beneficiary nationality",
77
80
  "refTaxIncome": "Reference tax income",
78
81
  "contractType": "Contract type",
79
82
  "noticePeriod": "Expiration alert",
80
-
81
83
  "number": "License number",
82
84
  "cafFileNumber": "CAF file number",
83
85
  "cardNumber": "National ID card number",
@@ -73,11 +73,13 @@
73
73
  "driver_license": {
74
74
  "number": "Numéro du permis"
75
75
  },
76
+ "residence_permit": {
77
+ "number": "Numéro du permis"
78
+ },
76
79
  "country": "Nationalité du bénéficiaire",
77
80
  "refTaxIncome": "Revenu fiscal de référence",
78
- "contractType": "Type de contat",
81
+ "contractType": "Type de contrat",
79
82
  "noticePeriod": "Alerte d’expiration",
80
-
81
83
  "number": "Numéro du permis",
82
84
  "cafFileNumber": "Numéro de dossier CAF",
83
85
  "cardNumber": "Numéro de la carte d'identité",
@@ -7,5 +7,5 @@ export const getRandomUUID = () => {
7
7
  return 'random-uuid-for-jest'
8
8
  }
9
9
 
10
- return window.crypto.randomUUID()
10
+ return window?.crypto?.randomUUID?.()
11
11
  }
@@ -5,13 +5,13 @@ export var normalizeExpandedAttribute = function normalizeExpandedAttribute(attr
5
5
  }; // attributes not considered as expanded attributes
6
6
 
7
7
  export var notExpandedAttributes = {
8
- 'io.cozy.contacts': ['fullname', 'civility', 'note'],
9
- 'io.cozy.files': ['name', 'flexsearchProps:translated:qualificationLabel', 'flexsearchProps:translated:refTaxIncome', 'flexsearchProps:translated:contractType', 'flexsearchProps:translated:driverLicense', 'flexsearchProps:translated:paymentProofFamilyAllowance', 'flexsearchProps:translated:vehicleRegistration', 'flexsearchProps:translated:nationalIdCard', 'flexsearchProps:translated:bankDetails', 'flexsearchProps:translated:passport']
8
+ 'io.cozy.contacts': ['fullname', 'civility', 'note', 'flexsearchProps:translated:phone', 'flexsearchProps:translated:email', 'flexsearchProps:translated:birthday', 'flexsearchProps:translated:address'],
9
+ 'io.cozy.files': ['name', 'flexsearchProps:translated:qualificationLabel', 'flexsearchProps:translated:refTaxIncome', 'flexsearchProps:translated:contractType', 'flexsearchProps:translated:driverLicense', 'flexsearchProps:translated:paymentProofFamilyAllowance', 'flexsearchProps:translated:vehicleRegistration', 'flexsearchProps:translated:nationalIdCard', 'flexsearchProps:translated:bankDetails', 'flexsearchProps:translated:passport', 'flexsearchProps:translated:residencePermit', 'flexsearchProps:translated:expirationDate']
10
10
  }; // attributes that we want to display if no attribute of the document is related to the search
11
11
 
12
12
  export var defaultExpandedAttributes = {
13
13
  'io.cozy.contacts': ['email', 'phone', 'address', 'birthday'],
14
- 'io.cozy.files': ['metadata.number', 'metadata.cafFileNumber', 'metadata.cardNumber', 'metadata.vinNumber', 'metadata.ibanNumber', 'metadata.passportNumber', 'metadata.noticePeriod', 'metadata.AObtentionDate', 'metadata.BObtentionDate', 'metadata.CObtentionDate', 'metadata.DObtentionDate', 'metadata.obtentionDate', 'metadata.expirationDate', 'metadata.country', 'metadata.refTaxIncome', 'metadata.contractType']
14
+ 'io.cozy.files': ['metadata.number', 'metadata.cafFileNumber', 'metadata.cardNumber', 'metadata.vinNumber', 'metadata.ibanNumber', 'metadata.passportNumber', 'metadata.noticePeriod', 'metadata.obtentionDate', 'metadata.expirationDate', 'metadata.country', 'metadata.refTaxIncome', 'metadata.contractType']
15
15
  };
16
16
  export var hasAllElement = function hasAllElement(arr1, arr2) {
17
17
  return arr1 === null || arr1 === void 0 ? void 0 : arr1.every(function (x) {
@@ -0,0 +1,29 @@
1
+ import { hr, emailTo, smsTo, call } from "cozy-ui/transpiled/react/ActionMenu/Actions";
2
+ export var makeOptionalActions = function makeOptionalActions(contact) {
3
+ var _contact$phone, _contact$email;
4
+
5
+ var hasPhoneAction = ((_contact$phone = contact.phone) === null || _contact$phone === void 0 ? void 0 : _contact$phone.length) > 0;
6
+ var hasEmailAction = ((_contact$email = contact.email) === null || _contact$email === void 0 ? void 0 : _contact$email.length) > 0;
7
+ var hasMessageActions = hasPhoneAction || hasEmailAction;
8
+ var actionsAndOptions = [{
9
+ action: hr,
10
+ condition: hasMessageActions
11
+ }, {
12
+ action: call,
13
+ condition: hasPhoneAction
14
+ }, {
15
+ action: smsTo,
16
+ condition: hasPhoneAction
17
+ }, {
18
+ action: emailTo,
19
+ condition: hasEmailAction
20
+ }];
21
+ var filteredOptionalActions = actionsAndOptions.reduce(function (acc, curr) {
22
+ if (curr.condition) {
23
+ acc.push(curr.action);
24
+ }
25
+
26
+ return acc;
27
+ }, []);
28
+ return filteredOptionalActions;
29
+ };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { getDisplayName } from 'cozy-client/dist/models/contact';
3
4
  import Filename from "cozy-ui/transpiled/react/Filename";
4
5
  import Icon from "cozy-ui/transpiled/react/Icon";
5
6
  import ContactsIcon from "cozy-ui/transpiled/react/Icons/Contacts";
@@ -18,7 +19,7 @@ var ListItemContact = function ListItemContact(_ref) {
18
19
  expandedAttributesProps = _ref.expandedAttributesProps,
19
20
  onClick = _ref.onClick;
20
21
  var defaultActions = useActions(contact);
21
- var primaryText = primary || contact.displayName;
22
+ var primaryText = primary || getDisplayName(contact);
22
23
  var secondaryText = secondary || ((_contact$email = contact.email) === null || _contact$email === void 0 ? void 0 : (_contact$email$ = _contact$email[0]) === null || _contact$email$ === void 0 ? void 0 : _contact$email$.address);
23
24
  var itemIcon = icon || /*#__PURE__*/React.createElement(Icon, {
24
25
  icon: ContactsIcon,
@@ -1,29 +1,8 @@
1
1
  import { useMemo } from 'react';
2
2
  import { makeActions } from "cozy-ui/transpiled/react/ActionMenu/Actions/helpers";
3
- import { hr } from "cozy-ui/transpiled/react/ActionMenu/Actions/hr";
4
- import { emailTo } from "cozy-ui/transpiled/react/ActionMenu/Actions/emailTo";
5
- import { smsTo } from "cozy-ui/transpiled/react/ActionMenu/Actions/smsTo";
6
- import { call } from "cozy-ui/transpiled/react/ActionMenu/Actions/call";
7
3
  import { modify } from "cozy-ui/transpiled/react/ActionMenu/Actions/modify";
8
4
  import { viewInContacts } from "cozy-ui/transpiled/react/ActionMenu/Actions/viewInContacts";
9
-
10
- var makeOptionalActions = function makeOptionalActions(contact) {
11
- var _contact$phone, _contact$email;
12
-
13
- var optionalActions = [hr, call, smsTo, emailTo];
14
- var hasPhoneAction = ((_contact$phone = contact.phone) === null || _contact$phone === void 0 ? void 0 : _contact$phone.length) > 0;
15
- var hasEmailAction = ((_contact$email = contact.email) === null || _contact$email === void 0 ? void 0 : _contact$email.length) > 0;
16
- var hasMessageActions = hasPhoneAction || hasEmailAction;
17
- var conditions = {
18
- hr: hasMessageActions,
19
- call: hasPhoneAction,
20
- smsTo: hasPhoneAction,
21
- emailTo: hasEmailAction
22
- };
23
- return optionalActions.filter(function (action) {
24
- return conditions[action.name];
25
- });
26
- };
5
+ import { makeOptionalActions } from "cozy-ui/transpiled/react/MuiCozyTheme/ListItem/ListItemContact/helpers";
27
6
 
28
7
  var useActions = function useActions(contact) {
29
8
  var optionalActions = useMemo(function () {
@@ -11,10 +11,6 @@ var en = {
11
11
  jobTitle: "Job title",
12
12
  metadata: {
13
13
  datetime: "Added on",
14
- AObtentionDate: "License A, delivered on",
15
- BObtentionDate: "License B, delivered on",
16
- CObtentionDate: "License C, delivered on",
17
- DObtentionDate: "License D, delivered on",
18
14
  issueDate: "Delivered on",
19
15
  expirationDate: "Expiration date",
20
16
  referencedDate: "Referenced date",
@@ -37,7 +33,8 @@ var en = {
37
33
  vehicle_registration: "Vehicle registration number (VIN)",
38
34
  national_id_card: "National ID card number",
39
35
  bank_details: "IBAN number",
40
- passport: "Passport number"
36
+ passport: "Passport number",
37
+ residence_permit: "License number"
41
38
  }
42
39
  }
43
40
  },
@@ -75,10 +72,6 @@ var fr = {
75
72
  jobTitle: "Fonction",
76
73
  metadata: {
77
74
  datetime: "Ajout\xE9 le",
78
- AObtentionDate: "Permis A, d\xE9livr\xE9 le",
79
- BObtentionDate: "Permis B, d\xE9livr\xE9 le",
80
- CObtentionDate: "Permis C, d\xE9livr\xE9 le",
81
- DObtentionDate: "Permis D, d\xE9livr\xE9 le",
82
75
  issueDate: "D\xE9livr\xE9 le",
83
76
  expirationDate: "Date d'expiration",
84
77
  referencedDate: "Date de r\xE9f\xE9rence",
@@ -101,7 +94,8 @@ var fr = {
101
94
  vehicle_registration: "Num\xE9ro de la carte grise (VIN)",
102
95
  national_id_card: "Num\xE9ro de la carte d'identit\xE9",
103
96
  bank_details: "Num\xE9ro d'IBAN",
104
- passport: "Num\xE9ro du passeport"
97
+ passport: "Num\xE9ro du passeport",
98
+ residence_permit: "Num\xE9ro du permis"
105
99
  }
106
100
  }
107
101
  },
@@ -74,6 +74,9 @@ var en = {
74
74
  driver_license: {
75
75
  number: "License number"
76
76
  },
77
+ residence_permit: {
78
+ number: "License number"
79
+ },
77
80
  country: "Beneficiary nationality",
78
81
  refTaxIncome: "Reference tax income",
79
82
  contractType: "Contract type",
@@ -200,9 +203,12 @@ var fr = {
200
203
  driver_license: {
201
204
  number: "Num\xE9ro du permis"
202
205
  },
206
+ residence_permit: {
207
+ number: "Num\xE9ro du permis"
208
+ },
203
209
  country: "Nationalit\xE9 du b\xE9n\xE9ficiaire",
204
210
  refTaxIncome: "Revenu fiscal de r\xE9f\xE9rence",
205
- contractType: "Type de contat",
211
+ contractType: "Type de contrat",
206
212
  noticePeriod: "Alerte d\u2019expiration",
207
213
  number: "Num\xE9ro du permis",
208
214
  cafFileNumber: "Num\xE9ro de dossier CAF",
@@ -3,9 +3,11 @@
3
3
  * @returns {string} a random UUID
4
4
  */
5
5
  export var getRandomUUID = function getRandomUUID() {
6
+ var _window, _window$crypto, _window$crypto$random;
7
+
6
8
  if (process.env.NODE_ENV === 'test') {
7
9
  return 'random-uuid-for-jest';
8
10
  }
9
11
 
10
- return window.crypto.randomUUID();
12
+ return (_window = window) === null || _window === void 0 ? void 0 : (_window$crypto = _window.crypto) === null || _window$crypto === void 0 ? void 0 : (_window$crypto$random = _window$crypto.randomUUID) === null || _window$crypto$random === void 0 ? void 0 : _window$crypto$random.call(_window$crypto);
11
13
  };