cozy-ui 128.8.0 → 128.10.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 +22 -0
- package/assets/icons/ui/matrix.svg +1 -0
- package/package.json +1 -1
- package/react/Contacts/AddModal/ContactForm/FieldInput.jsx +3 -0
- package/react/Contacts/AddModal/ContactForm/FieldInputAccordion.jsx +57 -0
- package/react/Contacts/AddModal/ContactForm/FieldInputArray.jsx +1 -1
- package/react/Contacts/AddModal/ContactForm/FieldInputLayout.jsx +14 -4
- package/react/Contacts/AddModal/ContactForm/contactToFormValues.js +9 -2
- package/react/Contacts/AddModal/ContactForm/contactToFormValues.spec.js +5 -0
- package/react/Contacts/AddModal/ContactForm/fieldsConfig.jsx +48 -32
- package/react/Contacts/AddModal/ContactForm/formValuesToContact.js +3 -0
- package/react/Contacts/AddModal/ContactForm/formValuesToContact.spec.js +57 -0
- package/react/Contacts/AddModal/ContactForm/helpers.js +41 -0
- package/react/Contacts/AddModal/ContactForm/helpers.spec.js +138 -0
- package/react/Contacts/AddModal/ContactForm/index.jsx +14 -1
- package/react/Contacts/AddModal/ContactForm/index.spec.jsx +12 -0
- package/react/Contacts/AddModal/ContactForm/locales/en.json +2 -0
- package/react/Contacts/AddModal/ContactForm/locales/fr.json +2 -0
- package/react/Contacts/AddModal/Readme.md +1 -1
- package/react/Contacts/AddModal/mocks.js +40 -1
- package/react/Contacts/AddModal/types.js +1 -1
- package/react/Icon/Readme.md +3 -1
- package/react/Icons/Matrix.jsx +12 -0
- package/transpiled/react/Contacts/AddModal/ContactAddressDialog/index.d.ts +1 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInput.d.ts +3 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInput.js +3 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputAccordion.d.ts +12 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputAccordion.js +71 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputArray.js +1 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputLayout.d.ts +4 -2
- package/transpiled/react/Contacts/AddModal/ContactForm/FieldInputLayout.js +14 -5
- package/transpiled/react/Contacts/AddModal/ContactForm/contactToFormValues.js +9 -2
- package/transpiled/react/Contacts/AddModal/ContactForm/fieldsConfig.js +41 -28
- package/transpiled/react/Contacts/AddModal/ContactForm/formValuesToContact.js +3 -1
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.d.ts +6 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/helpers.js +39 -0
- package/transpiled/react/Contacts/AddModal/ContactForm/index.js +18 -2
- package/transpiled/react/Contacts/AddModal/ContactForm/locales/index.js +4 -0
- package/transpiled/react/Contacts/AddModal/mocks.d.ts +19 -0
- package/transpiled/react/Contacts/AddModal/mocks.js +32 -0
- package/transpiled/react/Contacts/AddModal/types.d.ts +1 -1
- package/transpiled/react/Contacts/AddModal/types.js +1 -1
- package/transpiled/react/Icon/icons-sprite.d.ts +1 -1
- package/transpiled/react/Icon/icons-sprite.js +1 -1
- package/transpiled/react/Icons/Matrix.d.ts +2 -0
- package/transpiled/react/Icons/Matrix.js +13 -0
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
moveToHead,
|
|
3
3
|
makeItemLabel,
|
|
4
4
|
makeTypeAndLabel,
|
|
5
|
+
makeImppValues,
|
|
5
6
|
makeInitialCustomValue
|
|
6
7
|
} from './helpers'
|
|
7
8
|
|
|
@@ -73,6 +74,143 @@ describe('makeTypeAndLabel', () => {
|
|
|
73
74
|
})
|
|
74
75
|
})
|
|
75
76
|
|
|
77
|
+
describe('makeImppValues', () => {
|
|
78
|
+
it('should replace only uri for {label: "work", protocol: "matrix"}', () => {
|
|
79
|
+
const res = makeImppValues(
|
|
80
|
+
{
|
|
81
|
+
impp: [
|
|
82
|
+
{
|
|
83
|
+
uri: 'john.doe@xmpp.net',
|
|
84
|
+
protocol: 'xmpp',
|
|
85
|
+
label: 'home',
|
|
86
|
+
primary: false
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
uri: 'john.doe@xmpp.net',
|
|
90
|
+
protocol: 'xmpp',
|
|
91
|
+
label: 'work',
|
|
92
|
+
primary: false
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
uri: 'john@doe.matrix.net',
|
|
96
|
+
protocol: 'matrix',
|
|
97
|
+
label: 'work',
|
|
98
|
+
primary: true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
uri: 'john@doe.matrix.home',
|
|
102
|
+
protocol: 'matrix',
|
|
103
|
+
label: 'home'
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
'newMatrixURI'
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
expect(res).toStrictEqual([
|
|
111
|
+
{
|
|
112
|
+
uri: 'john.doe@xmpp.net',
|
|
113
|
+
protocol: 'xmpp',
|
|
114
|
+
label: 'home',
|
|
115
|
+
primary: false
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
uri: 'john.doe@xmpp.net',
|
|
119
|
+
protocol: 'xmpp',
|
|
120
|
+
label: 'work',
|
|
121
|
+
primary: false
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
uri: 'newMatrixURI',
|
|
125
|
+
protocol: 'matrix',
|
|
126
|
+
label: 'work',
|
|
127
|
+
primary: true
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
uri: 'john@doe.matrix.home',
|
|
131
|
+
protocol: 'matrix',
|
|
132
|
+
label: 'home'
|
|
133
|
+
}
|
|
134
|
+
])
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('should remove correctly', () => {
|
|
138
|
+
const res = makeImppValues(
|
|
139
|
+
{
|
|
140
|
+
impp: [
|
|
141
|
+
{
|
|
142
|
+
uri: 'john.doe@xmpp.net',
|
|
143
|
+
protocol: 'xmpp',
|
|
144
|
+
label: 'home',
|
|
145
|
+
primary: false
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
uri: 'john.doe@xmpp.net',
|
|
149
|
+
protocol: 'xmpp',
|
|
150
|
+
label: 'work',
|
|
151
|
+
primary: false
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
uri: 'john@doe.matrix.net',
|
|
155
|
+
protocol: 'matrix',
|
|
156
|
+
label: 'work',
|
|
157
|
+
primary: true
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
uri: 'john@doe.matrix.home',
|
|
161
|
+
protocol: 'matrix',
|
|
162
|
+
label: 'home'
|
|
163
|
+
}
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
''
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
expect(res).toStrictEqual([
|
|
170
|
+
{
|
|
171
|
+
uri: 'john.doe@xmpp.net',
|
|
172
|
+
protocol: 'xmpp',
|
|
173
|
+
label: 'home',
|
|
174
|
+
primary: false
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
uri: 'john.doe@xmpp.net',
|
|
178
|
+
protocol: 'xmpp',
|
|
179
|
+
label: 'work',
|
|
180
|
+
primary: false
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
uri: 'john@doe.matrix.home',
|
|
184
|
+
protocol: 'matrix',
|
|
185
|
+
label: 'home'
|
|
186
|
+
}
|
|
187
|
+
])
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
it('should add the matrix impp values for the first time if no impp attribute', () => {
|
|
191
|
+
const expected = [
|
|
192
|
+
{
|
|
193
|
+
uri: 'newMatrixURI',
|
|
194
|
+
protocol: 'matrix',
|
|
195
|
+
label: 'work',
|
|
196
|
+
primary: true
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
expect(makeImppValues({ impp: undefined }, 'newMatrixURI')).toStrictEqual(
|
|
201
|
+
expected
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
expect(makeImppValues({ impp: [] }, 'newMatrixURI')).toStrictEqual(expected)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('should not add empty object if value is empty', () => {
|
|
208
|
+
expect(makeImppValues({ impp: undefined }, '')).toStrictEqual([])
|
|
209
|
+
|
|
210
|
+
expect(makeImppValues({ impp: [] }, '')).toStrictEqual([])
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
|
|
76
214
|
describe('makeInitialCustomValue', () => {
|
|
77
215
|
it('should return undefined if no name', () => {
|
|
78
216
|
const res = makeInitialCustomValue(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import arrayMutators from 'final-form-arrays'
|
|
2
|
-
import React from 'react'
|
|
2
|
+
import React, { useState } from 'react'
|
|
3
3
|
import { Form } from 'react-final-form'
|
|
4
4
|
|
|
5
5
|
import { getHasManyItems } from 'cozy-client/dist/associations/HasMany'
|
|
@@ -10,6 +10,7 @@ import { fields } from './fieldsConfig'
|
|
|
10
10
|
import formValuesToContact from './formValuesToContact'
|
|
11
11
|
import { validateFields } from './helpers'
|
|
12
12
|
import { locales } from './locales'
|
|
13
|
+
import Button from '../../../Buttons'
|
|
13
14
|
import { useI18n, useExtendI18n } from '../../../providers/I18n'
|
|
14
15
|
// import { fullContactPropTypes } from '../../ContactPropTypes' // !!
|
|
15
16
|
|
|
@@ -36,6 +37,7 @@ export function getSubmitContactForm() {
|
|
|
36
37
|
* @returns
|
|
37
38
|
*/
|
|
38
39
|
const ContactForm = ({ contact, onSubmit, contacts }) => {
|
|
40
|
+
const [showSecondaryFields, setShowSecondaryFields] = useState(false)
|
|
39
41
|
useExtendI18n(locales)
|
|
40
42
|
const { t } = useI18n()
|
|
41
43
|
|
|
@@ -60,6 +62,7 @@ const ContactForm = ({ contact, onSubmit, contacts }) => {
|
|
|
60
62
|
key={index}
|
|
61
63
|
attributes={attributes}
|
|
62
64
|
contacts={contacts}
|
|
65
|
+
showSecondaryFields={showSecondaryFields}
|
|
63
66
|
formProps={{
|
|
64
67
|
valid,
|
|
65
68
|
submitFailed,
|
|
@@ -67,6 +70,16 @@ const ContactForm = ({ contact, onSubmit, contacts }) => {
|
|
|
67
70
|
}}
|
|
68
71
|
/>
|
|
69
72
|
))}
|
|
73
|
+
{!showSecondaryFields && (
|
|
74
|
+
<div>
|
|
75
|
+
<Button
|
|
76
|
+
className="u-db u-ml-2 u-mt-1"
|
|
77
|
+
variant="text"
|
|
78
|
+
label={t('Contacts.AddModal.ContactForm.other-fields')}
|
|
79
|
+
onClick={() => setShowSecondaryFields(true)}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
70
83
|
</form>
|
|
71
84
|
)
|
|
72
85
|
}}
|
|
@@ -21,6 +21,7 @@ const labels = [
|
|
|
21
21
|
'Phone',
|
|
22
22
|
'Email',
|
|
23
23
|
'Address',
|
|
24
|
+
'Matrix ID',
|
|
24
25
|
'Twake URL',
|
|
25
26
|
'Company',
|
|
26
27
|
'Job title',
|
|
@@ -54,6 +55,7 @@ describe('ContactForm', () => {
|
|
|
54
55
|
expect(screen.queryByDisplayValue(contact.name.familyName)).not.toBeNull()
|
|
55
56
|
expect(screen.queryByDisplayValue(contact.phone[0].number)).not.toBeNull()
|
|
56
57
|
expect(screen.queryByDisplayValue(contact.email[0].address)).not.toBeNull()
|
|
58
|
+
expect(screen.queryByDisplayValue(contact.impp[2].uri)).not.toBeNull()
|
|
57
59
|
expect(
|
|
58
60
|
screen.queryByDisplayValue(contact.address[0].formattedAddress)
|
|
59
61
|
).not.toBeNull()
|
|
@@ -78,6 +80,14 @@ describe('ContactForm', () => {
|
|
|
78
80
|
type: undefined
|
|
79
81
|
}
|
|
80
82
|
],
|
|
83
|
+
impp: [
|
|
84
|
+
{
|
|
85
|
+
uri: '123-matrixID-456',
|
|
86
|
+
protocol: 'matrix',
|
|
87
|
+
label: 'work',
|
|
88
|
+
primary: true
|
|
89
|
+
}
|
|
90
|
+
],
|
|
81
91
|
birthday: '2015-12-31',
|
|
82
92
|
birthplace: 'somewhere',
|
|
83
93
|
gender: 'male',
|
|
@@ -124,6 +134,7 @@ describe('ContactForm', () => {
|
|
|
124
134
|
additionalName: '',
|
|
125
135
|
'phone[0].phone': '+33678987654',
|
|
126
136
|
'email[0].email': 'jcvc@cozy.cloud',
|
|
137
|
+
matrix: '123-matrixID-456',
|
|
127
138
|
cozy: 'https://jcvd.cozy.cloud',
|
|
128
139
|
company: 'Cozy CLoud',
|
|
129
140
|
jobTitle: 'Dreamer',
|
|
@@ -171,6 +182,7 @@ describe('ContactForm', () => {
|
|
|
171
182
|
Lastname: 'Van Cozy',
|
|
172
183
|
Phone: '+33678987654',
|
|
173
184
|
Email: 'jcvc@cozy.cloud',
|
|
185
|
+
Matrix: '123-matrixID-456',
|
|
174
186
|
Address: '18 rue des fleurs, Pecado',
|
|
175
187
|
'Twake URL': 'https://jcvd.cozy.cloud',
|
|
176
188
|
Company: 'Cozy CLoud',
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"man": "Man",
|
|
7
7
|
"woman": "Woman"
|
|
8
8
|
},
|
|
9
|
+
"other-fields": "Other fields",
|
|
9
10
|
"fields": {
|
|
10
11
|
"gender": "Civility",
|
|
11
12
|
"givenName": "Firstname",
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
"familyName": "Lastname",
|
|
15
16
|
"phone": "Phone",
|
|
16
17
|
"email": "Email",
|
|
18
|
+
"matrix": "Matrix ID",
|
|
17
19
|
"address": "Address",
|
|
18
20
|
"cozy": "Twake URL",
|
|
19
21
|
"company": "Company",
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"man": "Homme",
|
|
7
7
|
"woman": "Femme"
|
|
8
8
|
},
|
|
9
|
+
"other-fields": "Autres champs",
|
|
9
10
|
"fields": {
|
|
10
11
|
"gender": "Civilité",
|
|
11
12
|
"givenName": "Prénom",
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
"phone": "Téléphone",
|
|
16
17
|
"email": "Email",
|
|
17
18
|
"address": "Adresse",
|
|
19
|
+
"matrix": "ID Matrix",
|
|
18
20
|
"cozy": "URL du Twake",
|
|
19
21
|
"company": "Entreprise",
|
|
20
22
|
"jobTitle": "Fonction",
|
|
@@ -8,7 +8,7 @@ import ContactsAddModal from 'cozy-ui/transpiled/react/Contacts/AddModal'
|
|
|
8
8
|
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
9
9
|
import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert'
|
|
10
10
|
import Button from 'cozy-ui/transpiled/react/Buttons'
|
|
11
|
-
import { johnDoeContact
|
|
11
|
+
import { johnDoeContact } from 'cozy-ui/transpiled/react/Contacts/AddModal/mocks'
|
|
12
12
|
import contacts from 'cozy-ui/transpiled/react/ContactsList/_mockContacts.json'
|
|
13
13
|
import Variants from 'cozy-ui/docs/components/Variants'
|
|
14
14
|
|
|
@@ -30,6 +30,31 @@ export const johnDoeContact = {
|
|
|
30
30
|
primary: true
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
|
+
impp: [
|
|
34
|
+
{
|
|
35
|
+
uri: 'john.doe@xmpp.net',
|
|
36
|
+
protocol: 'xmpp',
|
|
37
|
+
label: 'home',
|
|
38
|
+
primary: false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
uri: 'john.doe@xmpp.net',
|
|
42
|
+
protocol: 'xmpp',
|
|
43
|
+
label: 'work',
|
|
44
|
+
primary: false
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
uri: 'john@doe.matrix.net',
|
|
48
|
+
protocol: 'matrix',
|
|
49
|
+
label: 'work',
|
|
50
|
+
primary: true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
uri: 'john@doe.matrix.home',
|
|
54
|
+
protocol: 'matrix',
|
|
55
|
+
label: 'home'
|
|
56
|
+
}
|
|
57
|
+
],
|
|
33
58
|
birthday: '1999-5-1',
|
|
34
59
|
birthplace: 'somewhere',
|
|
35
60
|
gender: 'male',
|
|
@@ -71,6 +96,7 @@ export const johnDoeFormValues = {
|
|
|
71
96
|
gender: 'male',
|
|
72
97
|
cozy: 'https://johndoe.mycozy.cloud',
|
|
73
98
|
cozyLabel: '{"type":"MyCozy"}',
|
|
99
|
+
matrix: 'john@doe.matrix.net',
|
|
74
100
|
address: [
|
|
75
101
|
{
|
|
76
102
|
fieldId: 'fieldId_1',
|
|
@@ -167,6 +193,20 @@ export const johnDoeContactWithRelated = {
|
|
|
167
193
|
type: 'Work'
|
|
168
194
|
}
|
|
169
195
|
],
|
|
196
|
+
impp: [
|
|
197
|
+
{
|
|
198
|
+
uri: 'john.doe@xmpp.net',
|
|
199
|
+
protocol: 'xmpp',
|
|
200
|
+
label: 'home',
|
|
201
|
+
primary: false
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
uri: 'john@doe.matrix.net',
|
|
205
|
+
protocol: 'matrix',
|
|
206
|
+
label: 'work',
|
|
207
|
+
primary: true
|
|
208
|
+
}
|
|
209
|
+
],
|
|
170
210
|
email: [
|
|
171
211
|
{
|
|
172
212
|
address: 'john.doe@posteo.net',
|
|
@@ -211,7 +251,6 @@ export const johnDoeContactWithRelated = {
|
|
|
211
251
|
primary: false
|
|
212
252
|
}
|
|
213
253
|
],
|
|
214
|
-
|
|
215
254
|
relationships: {
|
|
216
255
|
accounts: { data: [] },
|
|
217
256
|
groups: { data: [] },
|
|
@@ -22,7 +22,7 @@ export const fieldInputAttributesTypes = PropTypes.shape({
|
|
|
22
22
|
icon: iconPropType,
|
|
23
23
|
type: PropTypes.string,
|
|
24
24
|
label: labelPropTypes,
|
|
25
|
-
|
|
25
|
+
layout: PropTypes.string,
|
|
26
26
|
subFields: PropTypes.arrayOf(
|
|
27
27
|
PropTypes.shape({
|
|
28
28
|
name: PropTypes.string.isRequired,
|
package/react/Icon/Readme.md
CHANGED
|
@@ -229,6 +229,7 @@ import Logout from 'cozy-ui/transpiled/react/Icons/Logout'
|
|
|
229
229
|
import MagicTrick from 'cozy-ui/transpiled/react/Icons/MagicTrick'
|
|
230
230
|
import Magnet from 'cozy-ui/transpiled/react/Icons/Magnet'
|
|
231
231
|
import Magnifier from 'cozy-ui/transpiled/react/Icons/Magnifier'
|
|
232
|
+
import Matrix from 'cozy-ui/transpiled/react/Icons/Matrix'
|
|
232
233
|
import Merge from 'cozy-ui/transpiled/react/Icons/Merge'
|
|
233
234
|
import Moped from 'cozy-ui/transpiled/react/Icons/Moped'
|
|
234
235
|
import Mosaic from 'cozy-ui/transpiled/react/Icons/Mosaic'
|
|
@@ -512,6 +513,7 @@ const icons = [
|
|
|
512
513
|
MagicTrick,
|
|
513
514
|
Magnet,
|
|
514
515
|
Magnifier,
|
|
516
|
+
Matrix,
|
|
515
517
|
Merge,
|
|
516
518
|
Moped,
|
|
517
519
|
Mosaic,
|
|
@@ -992,7 +994,7 @@ import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
|
992
994
|
|
|
993
995
|
const colors = ['#297EF2', '#08b442', '#B449E7', '#F52D2D', '#FF962F']
|
|
994
996
|
let i = 0
|
|
995
|
-
const availableIcons = ['album-add','album-remove','album','answer','apple','archive','arrowUp','assign-admin','assign-moderator','attachment','attention','bank-check','bank','banking-add','banking','bell','benefit','bike','bill','bottom','browser-brave','browser-chrome','browser-duckduckgo','browser-edge','browser-edge-chromium','browser-firefox','browser-ie','browser-opera','browser-safari','burger','bus','calendar','camera','car','carbonCopy','carpooling','categories','certified','check-circle','check-list','check-square','check','checkbox','chess','child','circle-filled','clock','clock-outline','cloud-happy','cloud-rainbow','cloud-plus-outlined','cloud','cloud2','collect','cocktail','comment','company','compare','compass','connector','contract','contrast','copy','cozy-circle','cozy-laugh', 'cozy-lock', 'cozy-text', 'cozy-release', 'credit-card-add','credit-card','credit','crop','cross-circle-outline','cross-circle','cross-medium','cross-small','cross','cube','dash','dashboard','data-control','debit','desktop-download','devices','discuss','dots','down','download','drawing-arrow-up','dropdown-close','dropdown-open','dropdown','dropup','electric-bike','electric-car','electric-scooter','email-notification','email-open','email','eu','euro','exchange','eye-closed','eye','face-id','file-add','file-duotone','file-new','file-none','file-outline','file','filter','fingerprint','fitness','flag-outlined','flag','flash-auto','flashlight','folder-add','folder-moveto','folder-open','folder','forbidden','from-user','gear','globe','gouv','graph-circle','grid','group-list','groups','growth','hand','heart','help','help-outlined','history','home','hourglass','image','info-outlined','info','justice','key','key2','label-outlined','laudry','laptop','left','library','lightbulb','lightning','link-out','link','list','list-min','location','lock', 'lock-screen', 'logout','magic-trick','magnet','magnifier','merge','moped','mosaic','mosaic-min','motorcycle','mountain','movement-in','movement-out','mouvement','moveto','multi-files','music','new','next','note','notification-email','number','offline','online', 'openapp', 'openwith','palette','paper','paperplane','password','pen','people','peoples','percent-circle','percent','person-add','personal-data','phone-download','phone-upload','phone','pie-chart','pin','plane','plus-small','plus', 'pop-inside', 'previous','printer','qualify','radio-checked','radio-unchecked','refresh','relationship','remboursement','rename','repare','reply','restaurant','restore-straight','restore','right','rise','rotate-left','rotate-right','sad-cozy','safe','school','scooter','secutiry','select-all','server','setting','share-circle','share','shield','shop','sound','spinner','sport-bag','stack','star','star-outline','stats','stop', 'subway', 'support', 'swap', 'sync-cozy','sync','tab','tag','target','task','team','telecom','telephone','text','text-info','to-the-cloud','top','train','tram','trash','trophy', 'uncloud', 'unknow','unlink','unlock','up','upload','videos','walk','wallet-add','wallet-new','wallet','warn','warning-circle','warning','water','wrench-circle','work']
|
|
997
|
+
const availableIcons = ['album-add','album-remove','album','answer','apple','archive','arrowUp','assign-admin','assign-moderator','attachment','attention','bank-check','bank','banking-add','banking','bell','benefit','bike','bill','bottom','browser-brave','browser-chrome','browser-duckduckgo','browser-edge','browser-edge-chromium','browser-firefox','browser-ie','browser-opera','browser-safari','burger','bus','calendar','camera','car','carbonCopy','carpooling','categories','certified','check-circle','check-list','check-square','check','checkbox','chess','child','circle-filled','clock','clock-outline','cloud-happy','cloud-rainbow','cloud-plus-outlined','cloud','cloud2','collect','cocktail','comment','company','compare','compass','connector','contract','contrast','copy','cozy-circle','cozy-laugh', 'cozy-lock', 'cozy-text', 'cozy-release', 'credit-card-add','credit-card','credit','crop','cross-circle-outline','cross-circle','cross-medium','cross-small','cross','cube','dash','dashboard','data-control','debit','desktop-download','devices','discuss','dots','down','download','drawing-arrow-up','dropdown-close','dropdown-open','dropdown','dropup','electric-bike','electric-car','electric-scooter','email-notification','email-open','email','eu','euro','exchange','eye-closed','eye','face-id','file-add','file-duotone','file-new','file-none','file-outline','file','filter','fingerprint','fitness','flag-outlined','flag','flash-auto','flashlight','folder-add','folder-moveto','folder-open','folder','forbidden','from-user','gear','globe','gouv','graph-circle','grid','group-list','groups','growth','hand','heart','help','help-outlined','history','home','hourglass','image','info-outlined','info','justice','key','key2','label-outlined','laudry','laptop','left','library','lightbulb','lightning','link-out','link','list','list-min','location','lock', 'lock-screen', 'logout','magic-trick','magnet','magnifier','matrix','merge','moped','mosaic','mosaic-min','motorcycle','mountain','movement-in','movement-out','mouvement','moveto','multi-files','music','new','next','note','notification-email','number','offline','online', 'openapp', 'openwith','palette','paper','paperplane','password','pen','people','peoples','percent-circle','percent','person-add','personal-data','phone-download','phone-upload','phone','pie-chart','pin','plane','plus-small','plus', 'pop-inside', 'previous','printer','qualify','radio-checked','radio-unchecked','refresh','relationship','remboursement','rename','repare','reply','restaurant','restore-straight','restore','right','rise','rotate-left','rotate-right','sad-cozy','safe','school','scooter','secutiry','select-all','server','setting','share-circle','share','shield','shop','sound','spinner','sport-bag','stack','star','star-outline','stats','stop', 'subway', 'support', 'swap', 'sync-cozy','sync','tab','tag','target','task','team','telecom','telephone','text','text-info','to-the-cloud','top','train','tram','trash','trophy', 'uncloud', 'unknow','unlink','unlock','up','upload','videos','walk','wallet-add','wallet-new','wallet','warn','warning-circle','warning','water','wrench-circle','work']
|
|
996
998
|
;
|
|
997
999
|
|
|
998
1000
|
<Grid container spacing={2}>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Automatically created, please run `scripts/generate-svgr-icon.sh assets/icons/ui/matrix.svg` to regenerate;
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
function SvgMatrix(props) {
|
|
5
|
+
return (
|
|
6
|
+
<svg viewBox="0 0 16 10" {...props}>
|
|
7
|
+
<path d="M3 1.111H1.333V8.89H3V10H0V0h3v1.111zM16 10h-3V8.889h1.667V1.11H13V0h3v10zM9.807 3.667c.587 0 1.043.167 1.368.503.328.332.492.79.492 1.374V9h-1.23V5.72c0-.688-.311-1.032-.931-1.032a.983.983 0 00-.531.162.945.945 0 00-.36.372V9h-1.23V5.53c0-.258-.08-.462-.241-.612-.161-.153-.387-.23-.68-.23-.153 0-.323.057-.507.171-.18.114-.312.24-.394.377V9h-1.23V3.765h.847l.25.459c.342-.372.784-.557 1.325-.557.699 0 1.226.188 1.58.566.154-.172.369-.309.644-.41.276-.104.552-.156.828-.156z" />
|
|
8
|
+
</svg>
|
|
9
|
+
)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default SvgMatrix
|
|
@@ -24,7 +24,7 @@ declare namespace ContactAddressModal {
|
|
|
24
24
|
defaultLabel: PropTypes.Requireable<string>;
|
|
25
25
|
}>>;
|
|
26
26
|
}>>;
|
|
27
|
-
|
|
27
|
+
layout: PropTypes.Requireable<string>;
|
|
28
28
|
subFields: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
29
29
|
name: PropTypes.Validator<string>;
|
|
30
30
|
icon: PropTypes.Requireable<string>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default FieldInput;
|
|
2
|
-
declare function FieldInput({ name, labelProps, attributes: { subFields, ...restAttributes }, contacts, error, helperText, label, required }: {
|
|
2
|
+
declare function FieldInput({ name, labelProps, className, attributes: { subFields, ...restAttributes }, contacts, error, helperText, label, required }: {
|
|
3
3
|
name: any;
|
|
4
4
|
labelProps: any;
|
|
5
|
+
className: any;
|
|
5
6
|
attributes: {
|
|
6
7
|
[x: string]: any;
|
|
7
8
|
subFields: any;
|
|
@@ -15,6 +16,7 @@ declare function FieldInput({ name, labelProps, attributes: { subFields, ...rest
|
|
|
15
16
|
declare namespace FieldInput {
|
|
16
17
|
namespace propTypes {
|
|
17
18
|
export const name: PropTypes.Validator<string>;
|
|
19
|
+
export const className: PropTypes.Requireable<string>;
|
|
18
20
|
export { labelPropTypes as labelProps };
|
|
19
21
|
export { fieldInputAttributesTypes as attributes };
|
|
20
22
|
export const contacts: PropTypes.Requireable<PropTypes.InferProps<{
|
|
@@ -20,6 +20,7 @@ import { fieldInputAttributesTypes, labelPropTypes } from "cozy-ui/transpiled/re
|
|
|
20
20
|
var FieldInput = function FieldInput(_ref) {
|
|
21
21
|
var name = _ref.name,
|
|
22
22
|
labelProps = _ref.labelProps,
|
|
23
|
+
className = _ref.className,
|
|
23
24
|
_ref$attributes = _ref.attributes,
|
|
24
25
|
subFields = _ref$attributes.subFields,
|
|
25
26
|
restAttributes = _objectWithoutProperties(_ref$attributes, _excluded),
|
|
@@ -69,7 +70,7 @@ var FieldInput = function FieldInput(_ref) {
|
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
-
className: cx(styles['contact-form-field__wrapper'], 'u-flex', 'u-flex-column-s')
|
|
73
|
+
className: cx(className, styles['contact-form-field__wrapper'], 'u-flex', 'u-flex-column-s')
|
|
73
74
|
}, /*#__PURE__*/React.createElement(Field, {
|
|
74
75
|
required: required,
|
|
75
76
|
error: error,
|
|
@@ -109,6 +110,7 @@ var FieldInput = function FieldInput(_ref) {
|
|
|
109
110
|
|
|
110
111
|
FieldInput.propTypes = {
|
|
111
112
|
name: PropTypes.string.isRequired,
|
|
113
|
+
className: PropTypes.string,
|
|
112
114
|
labelProps: labelPropTypes,
|
|
113
115
|
attributes: fieldInputAttributesTypes,
|
|
114
116
|
contacts: PropTypes.shape({
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default FieldInputAccordion;
|
|
2
|
+
declare function FieldInputAccordion({ attributes: { name, label, subFields, ...restAttributes }, contacts, error, helperText }: {
|
|
3
|
+
attributes: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
name: any;
|
|
6
|
+
label: any;
|
|
7
|
+
subFields: any;
|
|
8
|
+
};
|
|
9
|
+
contacts: any;
|
|
10
|
+
error: any;
|
|
11
|
+
helperText: any;
|
|
12
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["name", "label", "subFields"],
|
|
4
|
+
_excluded2 = ["name"];
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
import FieldInput from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/FieldInput";
|
|
8
|
+
import { locales } from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/locales";
|
|
9
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
10
|
+
import IconButton from "cozy-ui/transpiled/react/IconButton";
|
|
11
|
+
import DropdownIcon from "cozy-ui/transpiled/react/Icons/Dropdown";
|
|
12
|
+
import DropupIcon from "cozy-ui/transpiled/react/Icons/Dropup";
|
|
13
|
+
import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
14
|
+
|
|
15
|
+
var FieldInputAccordion = function FieldInputAccordion(_ref) {
|
|
16
|
+
var _ref$attributes = _ref.attributes,
|
|
17
|
+
name = _ref$attributes.name,
|
|
18
|
+
label = _ref$attributes.label,
|
|
19
|
+
subFields = _ref$attributes.subFields,
|
|
20
|
+
restAttributes = _objectWithoutProperties(_ref$attributes, _excluded),
|
|
21
|
+
contacts = _ref.contacts,
|
|
22
|
+
error = _ref.error,
|
|
23
|
+
helperText = _ref.helperText;
|
|
24
|
+
|
|
25
|
+
useExtendI18n(locales);
|
|
26
|
+
|
|
27
|
+
var _useI18n = useI18n(),
|
|
28
|
+
t = _useI18n.t;
|
|
29
|
+
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
showExtended = _useState2[0],
|
|
33
|
+
setShowExtended = _useState2[1];
|
|
34
|
+
|
|
35
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "u-flex u-flex-items-baseline"
|
|
37
|
+
}, /*#__PURE__*/React.createElement(FieldInput, {
|
|
38
|
+
attributes: restAttributes,
|
|
39
|
+
contacts: contacts,
|
|
40
|
+
error: error,
|
|
41
|
+
helperText: helperText,
|
|
42
|
+
name: name,
|
|
43
|
+
label: t("Contacts.AddModal.ContactForm.fields.".concat(name)),
|
|
44
|
+
labelProps: label
|
|
45
|
+
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
46
|
+
className: "u-ml-half",
|
|
47
|
+
size: "medium",
|
|
48
|
+
onClick: function onClick() {
|
|
49
|
+
return setShowExtended(function (v) {
|
|
50
|
+
return !v;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
54
|
+
icon: showExtended ? DropupIcon : DropdownIcon
|
|
55
|
+
}))), subFields.map(function (_ref2, index) {
|
|
56
|
+
var name = _ref2.name,
|
|
57
|
+
attributes = _objectWithoutProperties(_ref2, _excluded2);
|
|
58
|
+
|
|
59
|
+
return /*#__PURE__*/React.createElement(FieldInput, {
|
|
60
|
+
key: index,
|
|
61
|
+
className: cx('u-mt-1', {
|
|
62
|
+
'u-dn': !showExtended
|
|
63
|
+
}),
|
|
64
|
+
attributes: attributes,
|
|
65
|
+
name: name,
|
|
66
|
+
label: t("Contacts.AddModal.ContactForm.fields.".concat(name))
|
|
67
|
+
});
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default FieldInputAccordion;
|
|
@@ -43,7 +43,7 @@ var FieldInputArray = function FieldInputArray(_ref) {
|
|
|
43
43
|
var isError = fieldsRequired.includes(inputName) && !valid && submitFailed;
|
|
44
44
|
return /*#__PURE__*/React.createElement("div", {
|
|
45
45
|
key: key,
|
|
46
|
-
className: cx('u-flex u-flex-items-
|
|
46
|
+
className: cx('u-flex u-flex-items-baseline', {
|
|
47
47
|
'u-mt-1': index !== 0
|
|
48
48
|
})
|
|
49
49
|
}, /*#__PURE__*/React.createElement(FieldInput, {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export default FieldInputLayout;
|
|
2
|
-
declare function FieldInputLayout({ attributes: {
|
|
2
|
+
declare function FieldInputLayout({ attributes: { layout, icon, isSecondary, ...attributes }, contacts, showSecondaryFields, formProps }: {
|
|
3
3
|
attributes: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
|
|
5
|
+
layout: any;
|
|
6
6
|
icon: any;
|
|
7
|
+
isSecondary: any;
|
|
7
8
|
};
|
|
8
9
|
contacts: any;
|
|
10
|
+
showSecondaryFields: any;
|
|
9
11
|
formProps: any;
|
|
10
12
|
}): JSX.Element;
|
|
11
13
|
declare namespace FieldInputLayout {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
var _excluded = ["
|
|
2
|
+
var _excluded = ["layout", "icon", "isSecondary"],
|
|
3
3
|
_excluded2 = ["name", "label"];
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import FieldInput from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/FieldInput";
|
|
8
|
+
import FieldInputAccordion from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/FieldInputAccordion";
|
|
8
9
|
import FieldInputArray from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/FieldInputArray";
|
|
9
10
|
import { fieldsRequired } from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/helpers";
|
|
10
11
|
import { locales } from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/locales";
|
|
@@ -13,10 +14,12 @@ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n"
|
|
|
13
14
|
|
|
14
15
|
var FieldInputLayout = function FieldInputLayout(_ref) {
|
|
15
16
|
var _ref$attributes = _ref.attributes,
|
|
16
|
-
|
|
17
|
+
layout = _ref$attributes.layout,
|
|
17
18
|
icon = _ref$attributes.icon,
|
|
19
|
+
isSecondary = _ref$attributes.isSecondary,
|
|
18
20
|
attributes = _objectWithoutProperties(_ref$attributes, _excluded),
|
|
19
21
|
contacts = _ref.contacts,
|
|
22
|
+
showSecondaryFields = _ref.showSecondaryFields,
|
|
20
23
|
formProps = _ref.formProps;
|
|
21
24
|
|
|
22
25
|
useExtendI18n(locales);
|
|
@@ -35,8 +38,9 @@ var FieldInputLayout = function FieldInputLayout(_ref) {
|
|
|
35
38
|
var isError = fieldsRequired.includes(name) && !valid && submitFailed;
|
|
36
39
|
return /*#__PURE__*/React.createElement("div", {
|
|
37
40
|
className: cx('u-flex u-mt-1', {
|
|
38
|
-
'u-flex-items-center': !
|
|
39
|
-
'u-flex-items-baseline':
|
|
41
|
+
'u-flex-items-center': !layout,
|
|
42
|
+
'u-flex-items-baseline': !!layout,
|
|
43
|
+
'u-dn': isSecondary && !showSecondaryFields
|
|
40
44
|
})
|
|
41
45
|
}, /*#__PURE__*/React.createElement("div", {
|
|
42
46
|
className: "u-w-2-half"
|
|
@@ -45,10 +49,15 @@ var FieldInputLayout = function FieldInputLayout(_ref) {
|
|
|
45
49
|
color: "var(--iconTextColor)"
|
|
46
50
|
})), /*#__PURE__*/React.createElement("div", {
|
|
47
51
|
className: "u-w-100"
|
|
48
|
-
},
|
|
52
|
+
}, layout === 'array' ? /*#__PURE__*/React.createElement(FieldInputArray, {
|
|
49
53
|
attributes: attributes,
|
|
50
54
|
contacts: contacts,
|
|
51
55
|
formProps: formProps
|
|
56
|
+
}) : layout === 'accordion' ? /*#__PURE__*/React.createElement(FieldInputAccordion, {
|
|
57
|
+
attributes: attributes,
|
|
58
|
+
contacts: contacts,
|
|
59
|
+
error: isError,
|
|
60
|
+
helperText: isError ? errors[name] : null
|
|
52
61
|
}) : /*#__PURE__*/React.createElement(FieldInput, {
|
|
53
62
|
attributes: restAttributes,
|
|
54
63
|
contacts: contacts,
|