cozy-ui 130.6.0 → 130.6.1
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 +7 -0
- package/CODEOWNERS +1 -1
- package/package.json +1 -1
- package/react/Contacts/AddModal/ContactForm/formValuesToContact.spec.js +6 -0
- package/react/Contacts/AddModal/ContactForm/helpers.js +10 -5
- package/react/Contacts/AddModal/ContactForm/helpers.spec.js +35 -0
- package/react/Contacts/AddModal/mocks.js +11 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.js +2 -1
- package/transpiled/react/Contacts/AddModal/mocks.d.ts +15 -4
- package/transpiled/react/Contacts/AddModal/mocks.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [130.6.1](https://github.com/cozy/cozy-ui/compare/v130.6.0...v130.6.1) (2025-10-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **AddModal/ContactForm:** Custom label now display correctly unsupported label ([8f81a8a](https://github.com/cozy/cozy-ui/commit/8f81a8a))
|
|
7
|
+
|
|
1
8
|
# [130.6.0](https://github.com/cozy/cozy-ui/compare/v130.5.0...v130.6.0) (2025-10-02)
|
|
2
9
|
|
|
3
10
|
|
package/CODEOWNERS
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# General code owners
|
|
2
|
-
* @JF-Cozy @
|
|
2
|
+
* @JF-Cozy @rezk2ll @zatteo
|
package/package.json
CHANGED
|
@@ -271,12 +271,17 @@ export const removeField = (fields, index) => {
|
|
|
271
271
|
export const makeCustomLabel = (value, t) => {
|
|
272
272
|
const { type, label } = JSON.parse(value)
|
|
273
273
|
|
|
274
|
+
const isSupportedLabel = ['home', 'work'].includes(label)
|
|
275
|
+
|
|
274
276
|
const firstString = type || ''
|
|
275
|
-
const secondString =
|
|
276
|
-
|
|
277
|
-
?
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
const secondString =
|
|
278
|
+
label && isSupportedLabel
|
|
279
|
+
? type
|
|
280
|
+
? ` (${t(
|
|
281
|
+
`Contacts.AddModal.ContactForm.label.${label}`
|
|
282
|
+
)})`.toLowerCase()
|
|
283
|
+
: `label.${label}`
|
|
284
|
+
: ''
|
|
280
285
|
|
|
281
286
|
return firstString + secondString || null
|
|
282
287
|
}
|
|
@@ -1,10 +1,45 @@
|
|
|
1
|
+
import get from 'lodash/get'
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
moveToHead,
|
|
3
5
|
makeItemLabel,
|
|
4
6
|
makeTypeAndLabel,
|
|
5
7
|
makeImppValues,
|
|
8
|
+
makeCustomLabel,
|
|
6
9
|
makeInitialCustomValue
|
|
7
10
|
} from './helpers'
|
|
11
|
+
import { locales } from './locales'
|
|
12
|
+
|
|
13
|
+
const t = x => get(locales.en, x)
|
|
14
|
+
|
|
15
|
+
describe('makeCustomLabel', () => {
|
|
16
|
+
it('should return custom type and supported label', () => {
|
|
17
|
+
const resForWork = makeCustomLabel('{"type":"someType","label":"work"}', t)
|
|
18
|
+
expect(resForWork).toBe('someType (pro)')
|
|
19
|
+
|
|
20
|
+
const resForHome = makeCustomLabel('{"type":"someType","label":"home"}', t)
|
|
21
|
+
expect(resForHome).toBe('someType (personal)')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should return label if no type', () => {
|
|
25
|
+
const resForWork = makeCustomLabel('{"label":"work"}', t)
|
|
26
|
+
expect(resForWork).toBe('label.work')
|
|
27
|
+
|
|
28
|
+
const resForHome = makeCustomLabel('{"label":"home"}', t)
|
|
29
|
+
expect(resForHome).toBe('label.home')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should return only custom type if label is not supported or undefined', () => {
|
|
33
|
+
const resForNotSupported = makeCustomLabel(
|
|
34
|
+
'{"type":"someType","label":"someLabel"}',
|
|
35
|
+
t
|
|
36
|
+
)
|
|
37
|
+
expect(resForNotSupported).toBe('someType')
|
|
38
|
+
|
|
39
|
+
const resForUndefined = makeCustomLabel('{"type":"someType"}', t)
|
|
40
|
+
expect(resForUndefined).toBe('someType')
|
|
41
|
+
})
|
|
42
|
+
})
|
|
8
43
|
|
|
9
44
|
describe('moveToHead function', () => {
|
|
10
45
|
it('should move an item to head of the array', () => {
|
|
@@ -86,6 +86,12 @@ export const johnDoeContact = {
|
|
|
86
86
|
{
|
|
87
87
|
number: '+33 6 77 11 22 33',
|
|
88
88
|
primary: false
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
label: 'Mobile', // could be this when importing from other sources i.e. google
|
|
92
|
+
number: '0876467998',
|
|
93
|
+
primary: false,
|
|
94
|
+
type: 'mobile'
|
|
89
95
|
}
|
|
90
96
|
]
|
|
91
97
|
}
|
|
@@ -156,6 +162,11 @@ export const johnDoeFormValues = {
|
|
|
156
162
|
fieldId: 'fieldId_6',
|
|
157
163
|
phone: '+33 6 77 11 22 33',
|
|
158
164
|
phoneLabel: undefined
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
fieldId: 'fieldId_7',
|
|
168
|
+
phone: '0876467998',
|
|
169
|
+
phoneLabel: '{"type":"mobile","label":"Mobile"}'
|
|
159
170
|
}
|
|
160
171
|
],
|
|
161
172
|
givenName: 'John',
|
|
@@ -278,8 +278,9 @@ export var makeCustomLabel = function makeCustomLabel(value, t) {
|
|
|
278
278
|
type = _JSON$parse.type,
|
|
279
279
|
label = _JSON$parse.label;
|
|
280
280
|
|
|
281
|
+
var isSupportedLabel = ['home', 'work'].includes(label);
|
|
281
282
|
var firstString = type || '';
|
|
282
|
-
var secondString = label ? type ? " (".concat(t("Contacts.AddModal.ContactForm.label.".concat(label)), ")").toLowerCase() : "label.".concat(label) : '';
|
|
283
|
+
var secondString = label && isSupportedLabel ? type ? " (".concat(t("Contacts.AddModal.ContactForm.label.".concat(label)), ")").toLowerCase() : "label.".concat(label) : '';
|
|
283
284
|
return firstString + secondString || null;
|
|
284
285
|
};
|
|
285
286
|
/**
|
|
@@ -66,10 +66,17 @@ export namespace johnDoeContact {
|
|
|
66
66
|
export const version: number;
|
|
67
67
|
}
|
|
68
68
|
const note: string;
|
|
69
|
-
const phone: {
|
|
69
|
+
const phone: ({
|
|
70
70
|
number: string;
|
|
71
71
|
primary: boolean;
|
|
72
|
-
|
|
72
|
+
label?: undefined;
|
|
73
|
+
type?: undefined;
|
|
74
|
+
} | {
|
|
75
|
+
label: string;
|
|
76
|
+
number: string;
|
|
77
|
+
primary: boolean;
|
|
78
|
+
type: string;
|
|
79
|
+
})[];
|
|
73
80
|
}
|
|
74
81
|
export namespace johnDoeFormValues {
|
|
75
82
|
const birthday_1: string;
|
|
@@ -126,11 +133,15 @@ export namespace johnDoeFormValues {
|
|
|
126
133
|
emailLabel: string;
|
|
127
134
|
})[];
|
|
128
135
|
export { email_1 as email };
|
|
129
|
-
const phone_1: {
|
|
136
|
+
const phone_1: ({
|
|
130
137
|
fieldId: string;
|
|
131
138
|
phone: string;
|
|
132
139
|
phoneLabel: undefined;
|
|
133
|
-
}
|
|
140
|
+
} | {
|
|
141
|
+
fieldId: string;
|
|
142
|
+
phone: string;
|
|
143
|
+
phoneLabel: string;
|
|
144
|
+
})[];
|
|
134
145
|
export { phone_1 as phone };
|
|
135
146
|
const givenName_1: string;
|
|
136
147
|
export { givenName_1 as givenName };
|
|
@@ -71,6 +71,12 @@ export var johnDoeContact = {
|
|
|
71
71
|
}, {
|
|
72
72
|
number: '+33 6 77 11 22 33',
|
|
73
73
|
primary: false
|
|
74
|
+
}, {
|
|
75
|
+
label: 'Mobile',
|
|
76
|
+
// could be this when importing from other sources i.e. google
|
|
77
|
+
number: '0876467998',
|
|
78
|
+
primary: false,
|
|
79
|
+
type: 'mobile'
|
|
74
80
|
}]
|
|
75
81
|
};
|
|
76
82
|
export var johnDoeFormValues = {
|
|
@@ -130,6 +136,10 @@ export var johnDoeFormValues = {
|
|
|
130
136
|
fieldId: 'fieldId_6',
|
|
131
137
|
phone: '+33 6 77 11 22 33',
|
|
132
138
|
phoneLabel: undefined
|
|
139
|
+
}, {
|
|
140
|
+
fieldId: 'fieldId_7',
|
|
141
|
+
phone: '0876467998',
|
|
142
|
+
phoneLabel: '{"type":"mobile","label":"Mobile"}'
|
|
133
143
|
}],
|
|
134
144
|
givenName: 'John',
|
|
135
145
|
additionalName: 'J.',
|