cozy-ui 128.7.0 → 128.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 +21 -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 +2 -2
- package/react/Contacts/AddModal/ContactForm/fieldsConfig.jsx +42 -32
- package/react/Contacts/AddModal/ContactForm/index.jsx +14 -1
- package/react/Contacts/AddModal/ContactForm/locales/en.json +1 -0
- package/react/Contacts/AddModal/ContactForm/locales/fr.json +1 -0
- package/react/Contacts/AddModal/types.js +1 -1
- package/react/Layout/Layout.md +25 -6
- package/react/Nav/index.jsx +43 -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 +2 -2
- package/transpiled/react/Contacts/AddModal/ContactForm/fieldsConfig.js +36 -28
- package/transpiled/react/Contacts/AddModal/ContactForm/index.js +18 -2
- package/transpiled/react/Contacts/AddModal/ContactForm/locales/index.js +2 -0
- package/transpiled/react/Contacts/AddModal/types.d.ts +1 -1
- package/transpiled/react/Contacts/AddModal/types.js +1 -1
- package/transpiled/react/Nav/index.d.ts +6 -0
- package/transpiled/react/Nav/index.js +49 -0
- package/transpiled/react/deprecated/Menus/index.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [128.9.0](https://github.com/cozy/cozy-ui/compare/v128.8.0...v128.9.0) (2025-09-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ContactForm:** Remove button position wasn't correct on mobile ([d96647f](https://github.com/cozy/cozy-ui/commit/d96647f))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ContactForm/FieldInput:** Add className prop ([38d48f5](https://github.com/cozy/cozy-ui/commit/38d48f5))
|
|
12
|
+
* **ContactForm:** Add `isSecondary` attribute ([ff1bf5f](https://github.com/cozy/cozy-ui/commit/ff1bf5f))
|
|
13
|
+
* **ContactForm:** Add FieldInputAccordion component ([f285990](https://github.com/cozy/cozy-ui/commit/f285990))
|
|
14
|
+
|
|
15
|
+
# [128.8.0](https://github.com/cozy/cozy-ui/compare/v128.7.0...v128.8.0) (2025-09-09)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **NavDesktopDropdown:** introduce NavDesktopDropdown component for enhanced navigation item management ([3cb8a44](https://github.com/cozy/cozy-ui/commit/3cb8a44))
|
|
21
|
+
|
|
1
22
|
# [128.7.0](https://github.com/cozy/cozy-ui/compare/v128.6.0...v128.7.0) (2025-09-09)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import { fieldInputAttributesTypes, labelPropTypes } from '../types'
|
|
|
16
16
|
const FieldInput = ({
|
|
17
17
|
name,
|
|
18
18
|
labelProps,
|
|
19
|
+
className,
|
|
19
20
|
attributes: { subFields, ...restAttributes },
|
|
20
21
|
contacts,
|
|
21
22
|
error,
|
|
@@ -48,6 +49,7 @@ const FieldInput = ({
|
|
|
48
49
|
return (
|
|
49
50
|
<div
|
|
50
51
|
className={cx(
|
|
52
|
+
className,
|
|
51
53
|
styles['contact-form-field__wrapper'],
|
|
52
54
|
'u-flex',
|
|
53
55
|
'u-flex-column-s'
|
|
@@ -98,6 +100,7 @@ const FieldInput = ({
|
|
|
98
100
|
|
|
99
101
|
FieldInput.propTypes = {
|
|
100
102
|
name: PropTypes.string.isRequired,
|
|
103
|
+
className: PropTypes.string,
|
|
101
104
|
labelProps: labelPropTypes,
|
|
102
105
|
attributes: fieldInputAttributesTypes,
|
|
103
106
|
contacts: PropTypes.shape({
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import React, { useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import FieldInput from './FieldInput'
|
|
5
|
+
import { locales } from './locales'
|
|
6
|
+
import Icon from '../../../Icon'
|
|
7
|
+
import IconButton from '../../../IconButton'
|
|
8
|
+
import DropdownIcon from '../../../Icons/Dropdown'
|
|
9
|
+
import DropupIcon from '../../../Icons/Dropup'
|
|
10
|
+
import { useI18n, useExtendI18n } from '../../../providers/I18n'
|
|
11
|
+
|
|
12
|
+
const FieldInputAccordion = ({
|
|
13
|
+
attributes: { name, label, subFields, ...restAttributes },
|
|
14
|
+
contacts,
|
|
15
|
+
error,
|
|
16
|
+
helperText
|
|
17
|
+
}) => {
|
|
18
|
+
useExtendI18n(locales)
|
|
19
|
+
const { t } = useI18n()
|
|
20
|
+
const [showExtended, setShowExtended] = useState(false)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<div className="u-flex u-flex-items-baseline">
|
|
25
|
+
<FieldInput
|
|
26
|
+
attributes={restAttributes}
|
|
27
|
+
contacts={contacts}
|
|
28
|
+
error={error}
|
|
29
|
+
helperText={helperText}
|
|
30
|
+
name={name}
|
|
31
|
+
label={t(`Contacts.AddModal.ContactForm.fields.${name}`)}
|
|
32
|
+
labelProps={label}
|
|
33
|
+
/>
|
|
34
|
+
<IconButton
|
|
35
|
+
className="u-ml-half"
|
|
36
|
+
size="medium"
|
|
37
|
+
onClick={() => setShowExtended(v => !v)}
|
|
38
|
+
>
|
|
39
|
+
<Icon icon={showExtended ? DropupIcon : DropdownIcon} />
|
|
40
|
+
</IconButton>
|
|
41
|
+
</div>
|
|
42
|
+
{subFields.map(({ name, ...attributes }, index) => {
|
|
43
|
+
return (
|
|
44
|
+
<FieldInput
|
|
45
|
+
key={index}
|
|
46
|
+
className={cx('u-mt-1', { 'u-dn': !showExtended })}
|
|
47
|
+
attributes={attributes}
|
|
48
|
+
name={name}
|
|
49
|
+
label={t(`Contacts.AddModal.ContactForm.fields.${name}`)}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
52
|
+
})}
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default FieldInputAccordion
|
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
|
|
5
5
|
import FieldInput from './FieldInput'
|
|
6
|
+
import FieldInputAccordion from './FieldInputAccordion'
|
|
6
7
|
import FieldInputArray from './FieldInputArray'
|
|
7
8
|
import { fieldsRequired } from './helpers'
|
|
8
9
|
import { locales } from './locales'
|
|
@@ -10,8 +11,9 @@ import Icon from '../../../Icon'
|
|
|
10
11
|
import { useI18n, useExtendI18n } from '../../../providers/I18n'
|
|
11
12
|
|
|
12
13
|
const FieldInputLayout = ({
|
|
13
|
-
attributes: {
|
|
14
|
+
attributes: { layout, icon, isSecondary, ...attributes }, // ⚠️ `layout` `icon` `isSecondary` here are removed from attributes to avoid DOM propagration
|
|
14
15
|
contacts,
|
|
16
|
+
showSecondaryFields,
|
|
15
17
|
formProps
|
|
16
18
|
}) => {
|
|
17
19
|
useExtendI18n(locales)
|
|
@@ -24,20 +26,28 @@ const FieldInputLayout = ({
|
|
|
24
26
|
return (
|
|
25
27
|
<div
|
|
26
28
|
className={cx('u-flex u-mt-1', {
|
|
27
|
-
'u-flex-items-center': !
|
|
28
|
-
'u-flex-items-baseline':
|
|
29
|
+
'u-flex-items-center': !layout,
|
|
30
|
+
'u-flex-items-baseline': !!layout,
|
|
31
|
+
'u-dn': isSecondary && !showSecondaryFields
|
|
29
32
|
})}
|
|
30
33
|
>
|
|
31
34
|
<div className="u-w-2-half">
|
|
32
35
|
{icon && <Icon icon={icon} color="var(--iconTextColor)" />}
|
|
33
36
|
</div>
|
|
34
37
|
<div className="u-w-100">
|
|
35
|
-
{
|
|
38
|
+
{layout === 'array' ? (
|
|
36
39
|
<FieldInputArray
|
|
37
40
|
attributes={attributes}
|
|
38
41
|
contacts={contacts}
|
|
39
42
|
formProps={formProps}
|
|
40
43
|
/>
|
|
44
|
+
) : layout === 'accordion' ? (
|
|
45
|
+
<FieldInputAccordion
|
|
46
|
+
attributes={attributes}
|
|
47
|
+
contacts={contacts}
|
|
48
|
+
error={isError}
|
|
49
|
+
helperText={isError ? errors[name] : null}
|
|
50
|
+
/>
|
|
41
51
|
) : (
|
|
42
52
|
<FieldInput
|
|
43
53
|
attributes={restAttributes}
|
|
@@ -8,8 +8,8 @@ import { makeItemLabel, makeRelatedContact, movePrimaryToHead } from './helpers'
|
|
|
8
8
|
const contactToFormValues = (contact, t) => {
|
|
9
9
|
// initialize the form values, required so that array fields start with at least one editable field
|
|
10
10
|
const initialFieldValues = fields.reduce(
|
|
11
|
-
(initialValues, { name,
|
|
12
|
-
initialValues[name] =
|
|
11
|
+
(initialValues, { name, layout }) => {
|
|
12
|
+
initialValues[name] = layout === 'array' ? [undefined] : undefined
|
|
13
13
|
return initialValues
|
|
14
14
|
},
|
|
15
15
|
{}
|
|
@@ -35,37 +35,44 @@ export const fields = [
|
|
|
35
35
|
{
|
|
36
36
|
name: 'givenName',
|
|
37
37
|
icon: null,
|
|
38
|
-
type: 'text'
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
type: 'text',
|
|
39
|
+
layout: 'accordion',
|
|
40
|
+
subFields: [
|
|
41
|
+
{
|
|
42
|
+
name: 'additionalName',
|
|
43
|
+
icon: null,
|
|
44
|
+
type: 'text'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'surname',
|
|
48
|
+
icon: null,
|
|
49
|
+
type: 'text'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
44
52
|
},
|
|
45
53
|
{
|
|
46
54
|
name: 'familyName',
|
|
47
55
|
icon: null,
|
|
48
56
|
type: 'text'
|
|
49
57
|
},
|
|
50
|
-
{
|
|
51
|
-
name: 'surname',
|
|
52
|
-
icon: null,
|
|
53
|
-
type: 'text'
|
|
54
|
-
},
|
|
55
58
|
{
|
|
56
59
|
name: 'company',
|
|
57
60
|
icon: CompanyIcon,
|
|
58
|
-
type: 'text'
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
type: 'text',
|
|
62
|
+
layout: 'accordion',
|
|
63
|
+
subFields: [
|
|
64
|
+
{
|
|
65
|
+
name: 'jobTitle',
|
|
66
|
+
icon: null,
|
|
67
|
+
type: 'text'
|
|
68
|
+
}
|
|
69
|
+
]
|
|
64
70
|
},
|
|
65
71
|
{
|
|
66
72
|
name: 'phone',
|
|
67
73
|
icon: TelephoneIcon,
|
|
68
74
|
type: 'tel',
|
|
75
|
+
layout: 'array',
|
|
69
76
|
label: {
|
|
70
77
|
name: 'phoneLabel',
|
|
71
78
|
select: true,
|
|
@@ -103,13 +110,13 @@ export const fields = [
|
|
|
103
110
|
label: 'Contacts.AddModal.ContactForm.label.phone.fax-work'
|
|
104
111
|
}
|
|
105
112
|
]
|
|
106
|
-
}
|
|
107
|
-
isArray: true
|
|
113
|
+
}
|
|
108
114
|
},
|
|
109
115
|
{
|
|
110
116
|
name: 'email',
|
|
111
117
|
icon: EmailIcon,
|
|
112
118
|
type: 'email',
|
|
119
|
+
layout: 'array',
|
|
113
120
|
label: {
|
|
114
121
|
name: 'emailLabel',
|
|
115
122
|
select: true,
|
|
@@ -131,13 +138,13 @@ export const fields = [
|
|
|
131
138
|
label: 'Contacts.AddModal.ContactForm.label.work'
|
|
132
139
|
}
|
|
133
140
|
]
|
|
134
|
-
}
|
|
135
|
-
isArray: true
|
|
141
|
+
}
|
|
136
142
|
},
|
|
137
143
|
{
|
|
138
144
|
name: 'address',
|
|
139
145
|
icon: LocationIcon,
|
|
140
146
|
type: 'text',
|
|
147
|
+
layout: 'array',
|
|
141
148
|
InputProps: {
|
|
142
149
|
readOnly: true
|
|
143
150
|
},
|
|
@@ -224,13 +231,19 @@ export const fields = [
|
|
|
224
231
|
label: 'Contacts.AddModal.ContactForm.label.address.work'
|
|
225
232
|
}
|
|
226
233
|
]
|
|
227
|
-
}
|
|
228
|
-
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'note',
|
|
238
|
+
icon: CommentIcon,
|
|
239
|
+
type: 'text',
|
|
240
|
+
multiline: true
|
|
229
241
|
},
|
|
230
242
|
{
|
|
231
243
|
name: 'cozy',
|
|
232
244
|
icon: CloudIcon,
|
|
233
245
|
type: 'url',
|
|
246
|
+
isSecondary: true,
|
|
234
247
|
label: {
|
|
235
248
|
name: 'cozyLabel',
|
|
236
249
|
select: true,
|
|
@@ -258,16 +271,20 @@ export const fields = [
|
|
|
258
271
|
name: 'birthday',
|
|
259
272
|
icon: CalendarIcon,
|
|
260
273
|
type: 'date',
|
|
274
|
+
isSecondary: true,
|
|
261
275
|
InputLabelProps: { shrink: true }
|
|
262
276
|
},
|
|
263
277
|
{
|
|
264
278
|
name: 'birthplace',
|
|
265
279
|
icon: null,
|
|
266
|
-
type: 'text'
|
|
280
|
+
type: 'text',
|
|
281
|
+
isSecondary: true
|
|
267
282
|
},
|
|
268
283
|
{
|
|
269
284
|
name: 'relatedContact',
|
|
270
285
|
icon: RelationshipIcon,
|
|
286
|
+
layout: 'array',
|
|
287
|
+
isSecondary: true,
|
|
271
288
|
InputProps: {
|
|
272
289
|
readOnly: true,
|
|
273
290
|
endAdornment: (
|
|
@@ -329,13 +346,6 @@ export const fields = [
|
|
|
329
346
|
label: 'Contacts.AddModal.ContactForm.label.relationship.recipient'
|
|
330
347
|
}
|
|
331
348
|
]
|
|
332
|
-
}
|
|
333
|
-
isArray: true
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
name: 'note',
|
|
337
|
-
icon: CommentIcon,
|
|
338
|
-
type: 'text',
|
|
339
|
-
multiline: true
|
|
349
|
+
}
|
|
340
350
|
}
|
|
341
351
|
]
|
|
@@ -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
|
}}
|
|
@@ -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/Layout/Layout.md
CHANGED
|
@@ -4,6 +4,7 @@ The Layout component brings a strong context for apps with any screen resolution
|
|
|
4
4
|
* `<Content />` is the main content or your app.
|
|
5
5
|
* ⚠️ Secondary `<NavItem />` are not visible on mobile and tablets
|
|
6
6
|
* `<NavDesktopLimiter />` is a component that allows you to limit the number of visible items in a list and toggle between showing a limited view and displaying all items.
|
|
7
|
+
* `<NavDesktopDropdown />` is a component that allows you to show / hide the items in a list when the number of items exceeds a defined limit
|
|
7
8
|
|
|
8
9
|
### NavDesktopLimiter
|
|
9
10
|
|
|
@@ -16,17 +17,24 @@ It can be used to wrap any list of React elements, automatically providing funct
|
|
|
16
17
|
* **children**: React.ReactNode (required) - The list items or elements that **NavDesktopLimiter** will manage.
|
|
17
18
|
* **max**: number (optional) - The maximum number of items to display initially. Default is **5**.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
### NavDesktopDropdown
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
The **NavDesktopDropdown** component is designed to manage the display of nav items efficiently, allowing users to toggle between showing a collapsed view and displaying all items. This component enhances the UI/UX by providing a clean and intuitive way to handle dropdowns with many items.
|
|
23
|
+
|
|
24
|
+
It can be used to wrap any list of React elements, automatically providing functionality to limit the number of displayed elements based on the `limit` prop (defaulting to **5**). Users can toggle the dropdown to show or hide the items as needed.
|
|
25
|
+
|
|
26
|
+
**Props**:
|
|
27
|
+
|
|
28
|
+
* **label**: string (required) - The label for the dropdown.
|
|
29
|
+
* **children**: React.ReactNode (required) - The list items or elements that **NavDesktopDropdown** will manage.
|
|
30
|
+
* **defaultOpen**: boolean (optional) - Determines whether the dropdown is open by default. Default is **true**.
|
|
31
|
+
* **limit**: number (optional) - The maximum number of items to display before enabling collapsing. Default is **5**.
|
|
24
32
|
|
|
25
33
|
```jsx
|
|
26
34
|
import { useState } from 'react'
|
|
27
35
|
import { Layout, Main, Content } from 'cozy-ui/transpiled/react/Layout'
|
|
28
36
|
import Sidebar from 'cozy-ui/transpiled/react/Sidebar'
|
|
29
|
-
import Nav, { NavItem, NavIcon, NavText, genNavLink, NavDesktopLimiter } from 'cozy-ui/transpiled/react/Nav'
|
|
37
|
+
import Nav, { NavItem, NavIcon, NavText, genNavLink, NavDesktopLimiter, NavDesktopDropdown } from 'cozy-ui/transpiled/react/Nav'
|
|
30
38
|
import cx from 'classnames'
|
|
31
39
|
import isEqual from 'lodash/isEqual'
|
|
32
40
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
@@ -83,7 +91,7 @@ const useStyles = makeStyles(theme => ({
|
|
|
83
91
|
}
|
|
84
92
|
}))
|
|
85
93
|
|
|
86
|
-
const initialVariants = [{ monoColumn: false, withTopBar: true, longContent: true }]
|
|
94
|
+
const initialVariants = [{ monoColumn: false, withTopBar: true, longContent: true, moreThanMax: true }]
|
|
87
95
|
const [active, setActive] = useState(['Section 1', 'Subsection 1'])
|
|
88
96
|
const [showDialog, setShowDialog] = useState(isTesting() ? true : false)
|
|
89
97
|
const styles = useStyles()
|
|
@@ -130,6 +138,17 @@ const SideBar = ({ variant }) => {
|
|
|
130
138
|
<NavText>Section 3</NavText>
|
|
131
139
|
</NavLink>
|
|
132
140
|
</NavItem>
|
|
141
|
+
<NavDesktopDropdown label="Section 4" max={5}>
|
|
142
|
+
{
|
|
143
|
+
Array.from(Array(variant.moreThanMax ? 6 : 3).keys()).map(i => (
|
|
144
|
+
<NavItem secondary key={i}>
|
|
145
|
+
<NavLink>
|
|
146
|
+
<NavText>Subsection {i}</NavText>
|
|
147
|
+
</NavLink>
|
|
148
|
+
</NavItem>
|
|
149
|
+
))
|
|
150
|
+
}
|
|
151
|
+
</NavDesktopDropdown>
|
|
133
152
|
</Nav>
|
|
134
153
|
</Sidebar>
|
|
135
154
|
)
|
package/react/Nav/index.jsx
CHANGED
|
@@ -3,9 +3,11 @@ import React, { Children, isValidElement, useState, forwardRef } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import withNavLocales from './locales/withNavLocales'
|
|
5
5
|
import styles from './styles.styl'
|
|
6
|
+
import DropdownText from '../DropdownText'
|
|
6
7
|
import Icon from '../Icon'
|
|
7
8
|
import BottomIcon from '../Icons/Bottom'
|
|
8
9
|
import TopIcon from '../Icons/Top'
|
|
10
|
+
import ListItem from '../ListItem'
|
|
9
11
|
import useBreakpoints from '../providers/Breakpoints'
|
|
10
12
|
import { useI18n } from '../providers/I18n'
|
|
11
13
|
|
|
@@ -116,5 +118,46 @@ const _NavDesktopLimiter = ({ children, max = 5 }) => {
|
|
|
116
118
|
|
|
117
119
|
export const NavDesktopLimiter = withNavLocales(_NavDesktopLimiter)
|
|
118
120
|
|
|
121
|
+
export const NavDesktopDropdown = ({
|
|
122
|
+
label,
|
|
123
|
+
children,
|
|
124
|
+
defaultOpen = true,
|
|
125
|
+
limit = 5
|
|
126
|
+
}) => {
|
|
127
|
+
const { isDesktop } = useBreakpoints()
|
|
128
|
+
const [open, setOpen] = useState(defaultOpen)
|
|
129
|
+
const isActivated =
|
|
130
|
+
Children.toArray(children).filter(isValidElement).length > limit
|
|
131
|
+
|
|
132
|
+
const innerIconProps = {
|
|
133
|
+
rotate: open ? 0 : -90,
|
|
134
|
+
...(!isActivated && { className: 'u-dn' })
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!isDesktop) return null
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<>
|
|
141
|
+
<ListItem size="small" className={isActivated ? 'u-c-pointer' : ''}>
|
|
142
|
+
<DropdownText
|
|
143
|
+
variant="subtitle2"
|
|
144
|
+
color="textSecondary"
|
|
145
|
+
innerIconProps={innerIconProps}
|
|
146
|
+
onClick={() => {
|
|
147
|
+
if (!isActivated) {
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
setOpen(!open)
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
{label}
|
|
154
|
+
</DropdownText>
|
|
155
|
+
</ListItem>
|
|
156
|
+
|
|
157
|
+
{open && <>{children}</>}
|
|
158
|
+
</>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
119
162
|
export default Nav
|
|
120
163
|
Nav.NavItem = NavItem
|
|
@@ -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,
|
|
@@ -7,8 +7,8 @@ var contactToFormValues = function contactToFormValues(contact, t) {
|
|
|
7
7
|
// initialize the form values, required so that array fields start with at least one editable field
|
|
8
8
|
var initialFieldValues = fields.reduce(function (initialValues, _ref) {
|
|
9
9
|
var name = _ref.name,
|
|
10
|
-
|
|
11
|
-
initialValues[name] =
|
|
10
|
+
layout = _ref.layout;
|
|
11
|
+
initialValues[name] = layout === 'array' ? [undefined] : undefined;
|
|
12
12
|
return initialValues;
|
|
13
13
|
}, {});
|
|
14
14
|
|
|
@@ -29,31 +29,36 @@ export var fields = [{
|
|
|
29
29
|
}, {
|
|
30
30
|
name: 'givenName',
|
|
31
31
|
icon: null,
|
|
32
|
-
type: 'text'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
type: 'text',
|
|
33
|
+
layout: 'accordion',
|
|
34
|
+
subFields: [{
|
|
35
|
+
name: 'additionalName',
|
|
36
|
+
icon: null,
|
|
37
|
+
type: 'text'
|
|
38
|
+
}, {
|
|
39
|
+
name: 'surname',
|
|
40
|
+
icon: null,
|
|
41
|
+
type: 'text'
|
|
42
|
+
}]
|
|
37
43
|
}, {
|
|
38
44
|
name: 'familyName',
|
|
39
45
|
icon: null,
|
|
40
46
|
type: 'text'
|
|
41
|
-
}, {
|
|
42
|
-
name: 'surname',
|
|
43
|
-
icon: null,
|
|
44
|
-
type: 'text'
|
|
45
47
|
}, {
|
|
46
48
|
name: 'company',
|
|
47
49
|
icon: CompanyIcon,
|
|
48
|
-
type: 'text'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
type: 'text',
|
|
51
|
+
layout: 'accordion',
|
|
52
|
+
subFields: [{
|
|
53
|
+
name: 'jobTitle',
|
|
54
|
+
icon: null,
|
|
55
|
+
type: 'text'
|
|
56
|
+
}]
|
|
53
57
|
}, {
|
|
54
58
|
name: 'phone',
|
|
55
59
|
icon: TelephoneIcon,
|
|
56
60
|
type: 'tel',
|
|
61
|
+
layout: 'array',
|
|
57
62
|
label: {
|
|
58
63
|
name: 'phoneLabel',
|
|
59
64
|
select: true,
|
|
@@ -83,12 +88,12 @@ export var fields = [{
|
|
|
83
88
|
value: '{"type":"fax","label":"work"}',
|
|
84
89
|
label: 'Contacts.AddModal.ContactForm.label.phone.fax-work'
|
|
85
90
|
}]
|
|
86
|
-
}
|
|
87
|
-
isArray: true
|
|
91
|
+
}
|
|
88
92
|
}, {
|
|
89
93
|
name: 'email',
|
|
90
94
|
icon: EmailIcon,
|
|
91
95
|
type: 'email',
|
|
96
|
+
layout: 'array',
|
|
92
97
|
label: {
|
|
93
98
|
name: 'emailLabel',
|
|
94
99
|
select: true,
|
|
@@ -106,12 +111,12 @@ export var fields = [{
|
|
|
106
111
|
value: '{"label":"work"}',
|
|
107
112
|
label: 'Contacts.AddModal.ContactForm.label.work'
|
|
108
113
|
}]
|
|
109
|
-
}
|
|
110
|
-
isArray: true
|
|
114
|
+
}
|
|
111
115
|
}, {
|
|
112
116
|
name: 'address',
|
|
113
117
|
icon: LocationIcon,
|
|
114
118
|
type: 'text',
|
|
119
|
+
layout: 'array',
|
|
115
120
|
InputProps: {
|
|
116
121
|
readOnly: true
|
|
117
122
|
},
|
|
@@ -181,12 +186,17 @@ export var fields = [{
|
|
|
181
186
|
value: '{"label":"work"}',
|
|
182
187
|
label: 'Contacts.AddModal.ContactForm.label.address.work'
|
|
183
188
|
}]
|
|
184
|
-
}
|
|
185
|
-
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
name: 'note',
|
|
192
|
+
icon: CommentIcon,
|
|
193
|
+
type: 'text',
|
|
194
|
+
multiline: true
|
|
186
195
|
}, {
|
|
187
196
|
name: 'cozy',
|
|
188
197
|
icon: CloudIcon,
|
|
189
198
|
type: 'url',
|
|
199
|
+
isSecondary: true,
|
|
190
200
|
label: {
|
|
191
201
|
name: 'cozyLabel',
|
|
192
202
|
select: true,
|
|
@@ -209,16 +219,20 @@ export var fields = [{
|
|
|
209
219
|
name: 'birthday',
|
|
210
220
|
icon: CalendarIcon,
|
|
211
221
|
type: 'date',
|
|
222
|
+
isSecondary: true,
|
|
212
223
|
InputLabelProps: {
|
|
213
224
|
shrink: true
|
|
214
225
|
}
|
|
215
226
|
}, {
|
|
216
227
|
name: 'birthplace',
|
|
217
228
|
icon: null,
|
|
218
|
-
type: 'text'
|
|
229
|
+
type: 'text',
|
|
230
|
+
isSecondary: true
|
|
219
231
|
}, {
|
|
220
232
|
name: 'relatedContact',
|
|
221
233
|
icon: RelationshipIcon,
|
|
234
|
+
layout: 'array',
|
|
235
|
+
isSecondary: true,
|
|
222
236
|
InputProps: {
|
|
223
237
|
readOnly: true,
|
|
224
238
|
endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
|
|
@@ -268,11 +282,5 @@ export var fields = [{
|
|
|
268
282
|
value: '{"type":"recipient"}',
|
|
269
283
|
label: 'Contacts.AddModal.ContactForm.label.relationship.recipient'
|
|
270
284
|
}]
|
|
271
|
-
}
|
|
272
|
-
isArray: true
|
|
273
|
-
}, {
|
|
274
|
-
name: 'note',
|
|
275
|
-
icon: CommentIcon,
|
|
276
|
-
type: 'text',
|
|
277
|
-
multiline: true
|
|
285
|
+
}
|
|
278
286
|
}];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
|
|
3
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
5
|
|
|
5
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
7
|
|
|
7
8
|
import arrayMutators from 'final-form-arrays';
|
|
8
|
-
import React from 'react';
|
|
9
|
+
import React, { useState } from 'react';
|
|
9
10
|
import { Form } from 'react-final-form';
|
|
10
11
|
import { getHasManyItems } from 'cozy-client/dist/associations/HasMany';
|
|
11
12
|
import FieldInputLayout from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/FieldInputLayout";
|
|
@@ -14,6 +15,7 @@ import { fields } from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/f
|
|
|
14
15
|
import formValuesToContact from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/formValuesToContact";
|
|
15
16
|
import { validateFields } from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/helpers";
|
|
16
17
|
import { locales } from "cozy-ui/transpiled/react/Contacts/AddModal/ContactForm/locales";
|
|
18
|
+
import Button from "cozy-ui/transpiled/react/Buttons";
|
|
17
19
|
import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n"; // import { fullContactPropTypes } from '../../ContactPropTypes' // !!
|
|
18
20
|
// this variable will be set in the form's render prop
|
|
19
21
|
// and used by the submit button in ContactFormModal
|
|
@@ -42,6 +44,12 @@ var ContactForm = function ContactForm(_ref) {
|
|
|
42
44
|
var contact = _ref.contact,
|
|
43
45
|
_onSubmit = _ref.onSubmit,
|
|
44
46
|
contacts = _ref.contacts;
|
|
47
|
+
|
|
48
|
+
var _useState = useState(false),
|
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
+
showSecondaryFields = _useState2[0],
|
|
51
|
+
setShowSecondaryFields = _useState2[1];
|
|
52
|
+
|
|
45
53
|
useExtendI18n(locales);
|
|
46
54
|
|
|
47
55
|
var _useI18n = useI18n(),
|
|
@@ -75,13 +83,21 @@ var ContactForm = function ContactForm(_ref) {
|
|
|
75
83
|
key: index,
|
|
76
84
|
attributes: attributes,
|
|
77
85
|
contacts: contacts,
|
|
86
|
+
showSecondaryFields: showSecondaryFields,
|
|
78
87
|
formProps: {
|
|
79
88
|
valid: valid,
|
|
80
89
|
submitFailed: submitFailed,
|
|
81
90
|
errors: errors
|
|
82
91
|
}
|
|
83
92
|
});
|
|
84
|
-
})
|
|
93
|
+
}), !showSecondaryFields && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
|
|
94
|
+
className: "u-db u-ml-2 u-mt-1",
|
|
95
|
+
variant: "text",
|
|
96
|
+
label: t('Contacts.AddModal.ContactForm.other-fields'),
|
|
97
|
+
onClick: function onClick() {
|
|
98
|
+
return setShowSecondaryFields(true);
|
|
99
|
+
}
|
|
100
|
+
})));
|
|
85
101
|
}
|
|
86
102
|
});
|
|
87
103
|
}; // Used to avoid unnecessary multiple rendering of ContactForm when creating a new contact in another way.
|
|
@@ -6,6 +6,7 @@ var en = {
|
|
|
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",
|
|
@@ -79,6 +80,7 @@ var fr = {
|
|
|
79
80
|
man: "Homme",
|
|
80
81
|
woman: "Femme"
|
|
81
82
|
},
|
|
83
|
+
"other-fields": "Autres champs",
|
|
82
84
|
fields: {
|
|
83
85
|
gender: "Civilit\xE9",
|
|
84
86
|
givenName: "Pr\xE9nom",
|
|
@@ -26,7 +26,7 @@ export const fieldInputAttributesTypes: PropTypes.Requireable<PropTypes.InferPro
|
|
|
26
26
|
defaultLabel: PropTypes.Requireable<string>;
|
|
27
27
|
}>>;
|
|
28
28
|
}>>;
|
|
29
|
-
|
|
29
|
+
layout: PropTypes.Requireable<string>;
|
|
30
30
|
subFields: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
31
31
|
name: PropTypes.Validator<string>;
|
|
32
32
|
icon: PropTypes.Requireable<string>;
|
|
@@ -17,7 +17,7 @@ export var fieldInputAttributesTypes = PropTypes.shape({
|
|
|
17
17
|
icon: iconPropType,
|
|
18
18
|
type: PropTypes.string,
|
|
19
19
|
label: labelPropTypes,
|
|
20
|
-
|
|
20
|
+
layout: PropTypes.string,
|
|
21
21
|
subFields: PropTypes.arrayOf(PropTypes.shape({
|
|
22
22
|
name: PropTypes.string.isRequired,
|
|
23
23
|
icon: PropTypes.string,
|
|
@@ -23,6 +23,12 @@ export function NavIcon({ className, icon }: {
|
|
|
23
23
|
icon: any;
|
|
24
24
|
}): JSX.Element;
|
|
25
25
|
export const NavDesktopLimiter: any;
|
|
26
|
+
export function NavDesktopDropdown({ label, children, defaultOpen, limit }: {
|
|
27
|
+
label: any;
|
|
28
|
+
children: any;
|
|
29
|
+
defaultOpen?: boolean | undefined;
|
|
30
|
+
limit?: number | undefined;
|
|
31
|
+
}): JSX.Element | null;
|
|
26
32
|
export default Nav;
|
|
27
33
|
import React from "react";
|
|
28
34
|
declare function Nav({ className, children }: {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
5
|
var _excluded = ["className", "children", "secondary"],
|
|
5
6
|
_excluded2 = ["to", "children"];
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
6
12
|
import cx from 'classnames';
|
|
7
13
|
import React, { Children, isValidElement, useState, forwardRef } from 'react';
|
|
8
14
|
import withNavLocales from "cozy-ui/transpiled/react/Nav/locales/withNavLocales";
|
|
@@ -16,9 +22,11 @@ var styles = {
|
|
|
16
22
|
"c-nav-item-secondary": "styles__c-nav-item-secondary___k14rf",
|
|
17
23
|
"c-nav-limiter": "styles__c-nav-limiter___3oxQU"
|
|
18
24
|
};
|
|
25
|
+
import DropdownText from "cozy-ui/transpiled/react/DropdownText";
|
|
19
26
|
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
27
|
import BottomIcon from "cozy-ui/transpiled/react/Icons/Bottom";
|
|
21
28
|
import TopIcon from "cozy-ui/transpiled/react/Icons/Top";
|
|
29
|
+
import ListItem from "cozy-ui/transpiled/react/ListItem";
|
|
22
30
|
import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
23
31
|
import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
24
32
|
export var NavItem = function NavItem(_ref) {
|
|
@@ -136,5 +144,46 @@ var _NavDesktopLimiter = function _NavDesktopLimiter(_ref7) {
|
|
|
136
144
|
};
|
|
137
145
|
|
|
138
146
|
export var NavDesktopLimiter = withNavLocales(_NavDesktopLimiter);
|
|
147
|
+
export var NavDesktopDropdown = function NavDesktopDropdown(_ref8) {
|
|
148
|
+
var label = _ref8.label,
|
|
149
|
+
children = _ref8.children,
|
|
150
|
+
_ref8$defaultOpen = _ref8.defaultOpen,
|
|
151
|
+
defaultOpen = _ref8$defaultOpen === void 0 ? true : _ref8$defaultOpen,
|
|
152
|
+
_ref8$limit = _ref8.limit,
|
|
153
|
+
limit = _ref8$limit === void 0 ? 5 : _ref8$limit;
|
|
154
|
+
|
|
155
|
+
var _useBreakpoints2 = useBreakpoints(),
|
|
156
|
+
isDesktop = _useBreakpoints2.isDesktop;
|
|
157
|
+
|
|
158
|
+
var _useState3 = useState(defaultOpen),
|
|
159
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
160
|
+
open = _useState4[0],
|
|
161
|
+
setOpen = _useState4[1];
|
|
162
|
+
|
|
163
|
+
var isActivated = Children.toArray(children).filter(isValidElement).length > limit;
|
|
164
|
+
|
|
165
|
+
var innerIconProps = _objectSpread({
|
|
166
|
+
rotate: open ? 0 : -90
|
|
167
|
+
}, !isActivated && {
|
|
168
|
+
className: 'u-dn'
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (!isDesktop) return null;
|
|
172
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItem, {
|
|
173
|
+
size: "small",
|
|
174
|
+
className: isActivated ? 'u-c-pointer' : ''
|
|
175
|
+
}, /*#__PURE__*/React.createElement(DropdownText, {
|
|
176
|
+
variant: "subtitle2",
|
|
177
|
+
color: "textSecondary",
|
|
178
|
+
innerIconProps: innerIconProps,
|
|
179
|
+
onClick: function onClick() {
|
|
180
|
+
if (!isActivated) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setOpen(!open);
|
|
185
|
+
}
|
|
186
|
+
}, label)), open && /*#__PURE__*/React.createElement(React.Fragment, null, children));
|
|
187
|
+
};
|
|
139
188
|
export default Nav;
|
|
140
189
|
Nav.NavItem = NavItem;
|
|
@@ -12,11 +12,11 @@ declare var _default: React.ComponentType<Pick<Pick<PropTypes.InferProps<{
|
|
|
12
12
|
component: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
13
13
|
/** placement for the popover */
|
|
14
14
|
placement: PropTypes.Requireable<string>;
|
|
15
|
-
}>, "disabled" | "
|
|
15
|
+
}>, "disabled" | "component" | "placement">> & Partial<Pick<{
|
|
16
16
|
disabled: boolean;
|
|
17
17
|
component: null;
|
|
18
18
|
placement: string;
|
|
19
|
-
}, never>>, "disabled" | "
|
|
19
|
+
}, never>>, "disabled" | "component" | "placement"> & import("@material-ui/styles/withStyles/withStyles").StyledComponentProps<"root" | "paper">>;
|
|
20
20
|
export default _default;
|
|
21
21
|
export { MenuButton };
|
|
22
22
|
import PropTypes from "prop-types";
|