cozy-ui-plus 12.3.14 → 13.0.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 +27 -0
- package/package.json +3 -3
- package/dist/ListItem/ExpandedAttributes/ExpandedAttribute.js +0 -62
- package/dist/ListItem/ExpandedAttributes/helpers.js +0 -263
- package/dist/ListItem/ExpandedAttributes/index.js +0 -90
- package/dist/ListItem/ListItemBase/Renaming/RenameDialog.js +0 -52
- package/dist/ListItem/ListItemBase/Renaming/RenameInput.js +0 -319
- package/dist/ListItem/ListItemBase/Renaming/helpers.js +0 -73
- package/dist/ListItem/ListItemBase/index.js +0 -151
- package/dist/ListItem/ListItemByDoc/index.js +0 -109
- package/dist/ListItem/ListItemContact/helpers.js +0 -39
- package/dist/ListItem/ListItemContact/index.js +0 -85
- package/dist/ListItem/ListItemContact/useActions.js +0 -28
- package/dist/ListItem/ListItemFile/ExpirationAnnotation.js +0 -54
- package/dist/ListItem/ListItemFile/ItemIcon.js +0 -64
- package/dist/ListItem/ListItemFile/PrimaryText.js +0 -47
- package/dist/ListItem/ListItemFile/SecondaryText.js +0 -41
- package/dist/ListItem/ListItemFile/index.js +0 -96
- package/dist/ListItem/hoc/withListItemLocales.js +0 -320
- package/dist/Qualification/QualificationGrid/helpers.js +0 -16
- package/dist/Qualification/QualificationGrid/index.js +0 -118
- package/dist/Qualification/QualificationGrid/locales/withLocales.js +0 -80
- package/dist/Qualification/QualificationItem/index.js +0 -76
- package/dist/providers/Intent/index.js +0 -130
- package/dist/src/ListItem/ExpandedAttributes/ExpandedAttribute.d.ts +0 -14
- package/dist/src/ListItem/ExpandedAttributes/helpers.d.ts +0 -43
- package/dist/src/ListItem/ExpandedAttributes/helpers.spec.d.ts +0 -1
- package/dist/src/ListItem/ExpandedAttributes/index.d.ts +0 -2
- package/dist/src/ListItem/ListItemBase/Renaming/RenameDialog.d.ts +0 -2
- package/dist/src/ListItem/ListItemBase/Renaming/RenameInput.d.ts +0 -12
- package/dist/src/ListItem/ListItemBase/Renaming/helpers.d.ts +0 -1
- package/dist/src/ListItem/ListItemBase/index.d.ts +0 -2
- package/dist/src/ListItem/ListItemByDoc/index.d.ts +0 -46
- package/dist/src/ListItem/ListItemContact/helpers.d.ts +0 -1
- package/dist/src/ListItem/ListItemContact/helpers.spec.d.ts +0 -1
- package/dist/src/ListItem/ListItemContact/index.d.ts +0 -35
- package/dist/src/ListItem/ListItemContact/useActions.d.ts +0 -2
- package/dist/src/ListItem/ListItemFile/ExpirationAnnotation.d.ts +0 -2
- package/dist/src/ListItem/ListItemFile/ItemIcon.d.ts +0 -12
- package/dist/src/ListItem/ListItemFile/PrimaryText.d.ts +0 -12
- package/dist/src/ListItem/ListItemFile/SecondaryText.d.ts +0 -12
- package/dist/src/ListItem/ListItemFile/index.d.ts +0 -37
- package/dist/src/ListItem/hoc/withListItemLocales.d.ts +0 -12
- package/dist/src/Qualification/QualificationGrid/helpers.d.ts +0 -1
- package/dist/src/Qualification/QualificationGrid/index.d.ts +0 -2
- package/dist/src/Qualification/QualificationGrid/locales/withLocales.d.ts +0 -12
- package/dist/src/Qualification/QualificationItem/index.d.ts +0 -17
- package/dist/src/providers/Intent/index.d.ts +0 -9
- package/src/ListItem/ExpandedAttributes/ExpandedAttribute.jsx +0 -39
- package/src/ListItem/ExpandedAttributes/helpers.js +0 -214
- package/src/ListItem/ExpandedAttributes/helpers.spec.js +0 -175
- package/src/ListItem/ExpandedAttributes/index.jsx +0 -62
- package/src/ListItem/ListItemBase/Renaming/RenameDialog.jsx +0 -38
- package/src/ListItem/ListItemBase/Renaming/RenameInput.jsx +0 -134
- package/src/ListItem/ListItemBase/Renaming/helpers.js +0 -35
- package/src/ListItem/ListItemBase/index.jsx +0 -115
- package/src/ListItem/ListItemByDoc/index.jsx +0 -103
- package/src/ListItem/ListItemContact/helpers.js +0 -28
- package/src/ListItem/ListItemContact/helpers.spec.js +0 -41
- package/src/ListItem/ListItemContact/index.jsx +0 -67
- package/src/ListItem/ListItemContact/useActions.jsx +0 -22
- package/src/ListItem/ListItemFile/ExpirationAnnotation.jsx +0 -39
- package/src/ListItem/ListItemFile/ItemIcon.jsx +0 -55
- package/src/ListItem/ListItemFile/PrimaryText.jsx +0 -38
- package/src/ListItem/ListItemFile/SecondaryText.jsx +0 -36
- package/src/ListItem/ListItemFile/index.jsx +0 -75
- package/src/ListItem/Readme.md +0 -211
- package/src/ListItem/hoc/withListItemLocales.jsx +0 -15
- package/src/ListItem/locales/en.json +0 -75
- package/src/ListItem/locales/fr.json +0 -75
- package/src/ListItem/locales/ru.json +0 -75
- package/src/ListItem/locales/vi.json +0 -75
- package/src/Qualification/QualificationGrid/Readme.md +0 -26
- package/src/Qualification/QualificationGrid/helpers.js +0 -4
- package/src/Qualification/QualificationGrid/index.jsx +0 -93
- package/src/Qualification/QualificationGrid/locales/en.json +0 -15
- package/src/Qualification/QualificationGrid/locales/fr.json +0 -15
- package/src/Qualification/QualificationGrid/locales/ru.json +0 -15
- package/src/Qualification/QualificationGrid/locales/vi.json +0 -15
- package/src/Qualification/QualificationGrid/locales/withLocales.jsx +0 -15
- package/src/Qualification/QualificationItem/Readme.md +0 -8
- package/src/Qualification/QualificationItem/index.jsx +0 -63
- package/src/providers/Intent/index.jsx +0 -83
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { Icon, Dots } from '@linagora/twake-icons'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React, { useState, useRef } from 'react'
|
|
4
|
-
|
|
5
|
-
import ActionsMenu from 'cozy-ui/transpiled/react/ActionsMenu'
|
|
6
|
-
import ActionsMenuMobileHeader from 'cozy-ui/transpiled/react/ActionsMenu/ActionsMenuMobileHeader'
|
|
7
|
-
import Checkbox from 'cozy-ui/transpiled/react/Checkbox'
|
|
8
|
-
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
9
|
-
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
10
|
-
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
11
|
-
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction'
|
|
12
|
-
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
13
|
-
|
|
14
|
-
import ExpandedAttributes from '../ExpandedAttributes'
|
|
15
|
-
import RenameInput from './Renaming/RenameInput'
|
|
16
|
-
import withListItemLocales from '../hoc/withListItemLocales'
|
|
17
|
-
|
|
18
|
-
const ListItemBase = ({
|
|
19
|
-
doc,
|
|
20
|
-
primary,
|
|
21
|
-
secondary,
|
|
22
|
-
icon,
|
|
23
|
-
actions,
|
|
24
|
-
actionMenuComp,
|
|
25
|
-
expandedAttributesProps: { isExpandedAttributesActive, expandedAttributes },
|
|
26
|
-
selectProps: { isSelectActive, isSelected, isChecked },
|
|
27
|
-
onClick
|
|
28
|
-
}) => {
|
|
29
|
-
const [showActionMenu, setShowActionMenu] = useState(false)
|
|
30
|
-
const [isRenaming, setIsRenaming] = useState(false)
|
|
31
|
-
const anchorRef = useRef()
|
|
32
|
-
|
|
33
|
-
const toggleMenu = () => setShowActionMenu(v => !v)
|
|
34
|
-
|
|
35
|
-
const showActionMenuHeader = actionMenuComp?.Header
|
|
36
|
-
const isButton = !isRenaming && !!onClick
|
|
37
|
-
const handleClick =
|
|
38
|
-
!isRenaming && !isSelected && onClick ? onClick : undefined
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<>
|
|
42
|
-
<ListItem button={isButton} disabled={isSelected} onClick={handleClick}>
|
|
43
|
-
{isSelectActive && (
|
|
44
|
-
<Checkbox
|
|
45
|
-
className="u-p-0"
|
|
46
|
-
value={doc._id}
|
|
47
|
-
checked={isChecked}
|
|
48
|
-
disabled={isSelected}
|
|
49
|
-
/>
|
|
50
|
-
)}
|
|
51
|
-
<ListItemIcon>{icon}</ListItemIcon>
|
|
52
|
-
{isRenaming ? (
|
|
53
|
-
<RenameInput file={doc} onClose={() => setIsRenaming(false)} />
|
|
54
|
-
) : (
|
|
55
|
-
<ListItemText primary={primary} secondary={secondary} />
|
|
56
|
-
)}
|
|
57
|
-
{actions && !isSelectActive && (
|
|
58
|
-
<ListItemSecondaryAction>
|
|
59
|
-
<IconButton ref={anchorRef} onClick={toggleMenu}>
|
|
60
|
-
<Icon icon={Dots} />
|
|
61
|
-
</IconButton>
|
|
62
|
-
</ListItemSecondaryAction>
|
|
63
|
-
)}
|
|
64
|
-
</ListItem>
|
|
65
|
-
{isExpandedAttributesActive && (
|
|
66
|
-
<ExpandedAttributes doc={doc} expandedAttributes={expandedAttributes} />
|
|
67
|
-
)}
|
|
68
|
-
{showActionMenu && (
|
|
69
|
-
<ActionsMenu
|
|
70
|
-
open
|
|
71
|
-
ref={anchorRef}
|
|
72
|
-
docs={[doc]}
|
|
73
|
-
actions={actions}
|
|
74
|
-
anchorOrigin={{
|
|
75
|
-
vertical: 'bottom',
|
|
76
|
-
horizontal: 'right'
|
|
77
|
-
}}
|
|
78
|
-
componentsProps={{
|
|
79
|
-
actionsItems: { actionOptions: { setIsRenaming } }
|
|
80
|
-
}}
|
|
81
|
-
onClose={() => setShowActionMenu(false)}
|
|
82
|
-
>
|
|
83
|
-
{showActionMenuHeader && (
|
|
84
|
-
<ActionsMenuMobileHeader>
|
|
85
|
-
{actionMenuComp.Header}
|
|
86
|
-
</ActionsMenuMobileHeader>
|
|
87
|
-
)}
|
|
88
|
-
</ActionsMenu>
|
|
89
|
-
)}
|
|
90
|
-
</>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
ListItemBase.propTypes = {
|
|
95
|
-
doc: PropTypes.object,
|
|
96
|
-
primary: PropTypes.node,
|
|
97
|
-
secondary: PropTypes.node,
|
|
98
|
-
icon: PropTypes.node,
|
|
99
|
-
actions: PropTypes.array,
|
|
100
|
-
actionMenuComp: PropTypes.shape({
|
|
101
|
-
Header: PropTypes.node
|
|
102
|
-
}),
|
|
103
|
-
selectProps: PropTypes.shape({
|
|
104
|
-
isSelectActive: PropTypes.bool,
|
|
105
|
-
isSelected: PropTypes.bool,
|
|
106
|
-
isChecked: PropTypes.bool
|
|
107
|
-
}),
|
|
108
|
-
expandedAttributesProps: PropTypes.shape({
|
|
109
|
-
isExpandedAttributesActive: PropTypes.bool,
|
|
110
|
-
expandedAttributes: PropTypes.array
|
|
111
|
-
}),
|
|
112
|
-
onClick: PropTypes.func
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default withListItemLocales(ListItemBase)
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { makeDefaultExpandedAttributes } from '../ExpandedAttributes/helpers'
|
|
5
|
-
import ListItemContact from '../ListItemContact'
|
|
6
|
-
import ListItemFile from '../ListItemFile'
|
|
7
|
-
|
|
8
|
-
const ListItemByDoc = ({
|
|
9
|
-
doc,
|
|
10
|
-
primary,
|
|
11
|
-
secondary,
|
|
12
|
-
icon,
|
|
13
|
-
actions,
|
|
14
|
-
selectProps,
|
|
15
|
-
expandedAttributesProps: { isExpandedAttributesActive, expandedAttributes },
|
|
16
|
-
|
|
17
|
-
onClick
|
|
18
|
-
}) => {
|
|
19
|
-
const itemExpandedAttributes = makeDefaultExpandedAttributes(
|
|
20
|
-
doc,
|
|
21
|
-
expandedAttributes
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
switch (doc._type) {
|
|
25
|
-
case 'io.cozy.contacts':
|
|
26
|
-
return (
|
|
27
|
-
<ListItemContact
|
|
28
|
-
contact={doc}
|
|
29
|
-
primary={primary}
|
|
30
|
-
secondary={secondary}
|
|
31
|
-
icon={icon}
|
|
32
|
-
actions={actions}
|
|
33
|
-
selectProps={selectProps}
|
|
34
|
-
expandedAttributesProps={{
|
|
35
|
-
isExpandedAttributesActive,
|
|
36
|
-
expandedAttributes: itemExpandedAttributes
|
|
37
|
-
}}
|
|
38
|
-
onClick={onClick}
|
|
39
|
-
/>
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
case 'io.cozy.files':
|
|
43
|
-
return (
|
|
44
|
-
<ListItemFile
|
|
45
|
-
file={doc}
|
|
46
|
-
primary={primary}
|
|
47
|
-
secondary={secondary}
|
|
48
|
-
icon={icon}
|
|
49
|
-
actions={actions}
|
|
50
|
-
selectProps={selectProps}
|
|
51
|
-
expandedAttributesProps={{
|
|
52
|
-
isExpandedAttributesActive,
|
|
53
|
-
expandedAttributes: itemExpandedAttributes
|
|
54
|
-
}}
|
|
55
|
-
onClick={onClick}
|
|
56
|
-
/>
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
default:
|
|
60
|
-
return (
|
|
61
|
-
<ListItemFile
|
|
62
|
-
file={doc}
|
|
63
|
-
primary={primary}
|
|
64
|
-
secondary={secondary}
|
|
65
|
-
icon={icon}
|
|
66
|
-
actions={actions}
|
|
67
|
-
selectProps={selectProps}
|
|
68
|
-
expandedAttributesProps={{
|
|
69
|
-
isExpandedAttributesActive,
|
|
70
|
-
expandedAttributes: itemExpandedAttributes
|
|
71
|
-
}}
|
|
72
|
-
onClick={onClick}
|
|
73
|
-
/>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
ListItemByDoc.defaultProps = {
|
|
79
|
-
selectProps: { isSelectActive: false, isSelected: false, isChecked: false },
|
|
80
|
-
expandedAttributesProps: {
|
|
81
|
-
isExpandedAttributesActive: false
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
ListItemByDoc.propTypes = {
|
|
86
|
-
doc: PropTypes.object,
|
|
87
|
-
primary: PropTypes.node,
|
|
88
|
-
secondary: PropTypes.node,
|
|
89
|
-
icon: PropTypes.node,
|
|
90
|
-
actions: PropTypes.array,
|
|
91
|
-
selectProps: PropTypes.shape({
|
|
92
|
-
isSelectActive: PropTypes.bool,
|
|
93
|
-
isSelected: PropTypes.bool,
|
|
94
|
-
isChecked: PropTypes.bool
|
|
95
|
-
}),
|
|
96
|
-
expandedAttributesProps: PropTypes.shape({
|
|
97
|
-
isExpandedAttributesActive: PropTypes.bool,
|
|
98
|
-
expandedAttributes: PropTypes.array
|
|
99
|
-
}),
|
|
100
|
-
onClick: PropTypes.func
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default ListItemByDoc
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
divider,
|
|
3
|
-
emailTo,
|
|
4
|
-
smsTo,
|
|
5
|
-
call
|
|
6
|
-
} from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
|
|
7
|
-
|
|
8
|
-
export const makeOptionalActions = contact => {
|
|
9
|
-
const hasPhoneAction = contact.phone?.length > 0
|
|
10
|
-
const hasEmailAction = contact.email?.length > 0
|
|
11
|
-
const hasMessageActions = hasPhoneAction || hasEmailAction
|
|
12
|
-
|
|
13
|
-
const actionsAndOptions = [
|
|
14
|
-
{ action: divider, condition: hasMessageActions },
|
|
15
|
-
{ action: call, condition: hasPhoneAction },
|
|
16
|
-
{ action: smsTo, condition: hasPhoneAction },
|
|
17
|
-
{ action: emailTo, condition: hasEmailAction }
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
const filteredOptionalActions = actionsAndOptions.reduce((acc, curr) => {
|
|
21
|
-
if (curr.condition) {
|
|
22
|
-
acc.push(curr.action)
|
|
23
|
-
}
|
|
24
|
-
return acc
|
|
25
|
-
}, [])
|
|
26
|
-
|
|
27
|
-
return filteredOptionalActions
|
|
28
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
divider,
|
|
3
|
-
emailTo,
|
|
4
|
-
smsTo,
|
|
5
|
-
call
|
|
6
|
-
} from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
|
|
7
|
-
|
|
8
|
-
import { makeOptionalActions } from './helpers'
|
|
9
|
-
|
|
10
|
-
describe('makeOptionalActions', () => {
|
|
11
|
-
it('should return divider, call, smsTo, emailTo', () => {
|
|
12
|
-
const res = makeOptionalActions({
|
|
13
|
-
email: [{ address: 'mail@cozy.com' }],
|
|
14
|
-
phone: [{ number: '123456' }]
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
expect(res).toStrictEqual([divider, call, smsTo, emailTo])
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('should return divider, emailTo', () => {
|
|
21
|
-
const res = makeOptionalActions({
|
|
22
|
-
email: [{ address: 'mail@cozy.com' }]
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
expect(res).toStrictEqual([divider, emailTo])
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it('should return divider, call, smsTo', () => {
|
|
29
|
-
const res = makeOptionalActions({
|
|
30
|
-
phone: [{ number: '123456' }]
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
expect(res).toStrictEqual([divider, call, smsTo])
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('should empty array', () => {
|
|
37
|
-
const res = makeOptionalActions({})
|
|
38
|
-
|
|
39
|
-
expect(res).toStrictEqual([])
|
|
40
|
-
})
|
|
41
|
-
})
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Icon, Contacts } from '@linagora/twake-icons'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { getDisplayName } from 'cozy-client/dist/models/contact'
|
|
6
|
-
import Filename from 'cozy-ui/transpiled/react/Filename'
|
|
7
|
-
|
|
8
|
-
import useActions from './useActions'
|
|
9
|
-
import ListItemBase from '../ListItemBase'
|
|
10
|
-
|
|
11
|
-
const ListItemContact = ({
|
|
12
|
-
contact,
|
|
13
|
-
primary,
|
|
14
|
-
secondary,
|
|
15
|
-
icon,
|
|
16
|
-
actions,
|
|
17
|
-
selectProps,
|
|
18
|
-
expandedAttributesProps,
|
|
19
|
-
onClick
|
|
20
|
-
}) => {
|
|
21
|
-
const defaultActions = useActions(contact)
|
|
22
|
-
const primaryText = primary || getDisplayName(contact)
|
|
23
|
-
const secondaryText = secondary || contact.email?.[0]?.address
|
|
24
|
-
const itemIcon = icon || <Icon icon={Contacts} width="32" height="32" />
|
|
25
|
-
|
|
26
|
-
const itemActions = defaultActions.concat(actions)
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<ListItemBase
|
|
30
|
-
doc={contact}
|
|
31
|
-
primary={primaryText}
|
|
32
|
-
secondary={secondaryText}
|
|
33
|
-
icon={itemIcon}
|
|
34
|
-
actions={itemActions}
|
|
35
|
-
actionMenuComp={{
|
|
36
|
-
Header: <Filename icon={Contacts} filename={primaryText} />
|
|
37
|
-
}}
|
|
38
|
-
selectProps={selectProps}
|
|
39
|
-
expandedAttributesProps={expandedAttributesProps}
|
|
40
|
-
onClick={onClick}
|
|
41
|
-
/>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
ListItemContact.defaultProps = {
|
|
46
|
-
actions: []
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
ListItemContact.propTypes = {
|
|
50
|
-
contact: PropTypes.object,
|
|
51
|
-
primary: PropTypes.node,
|
|
52
|
-
secondary: PropTypes.node,
|
|
53
|
-
icon: PropTypes.node,
|
|
54
|
-
actions: PropTypes.array,
|
|
55
|
-
selectProps: PropTypes.shape({
|
|
56
|
-
isSelectActive: PropTypes.bool,
|
|
57
|
-
isSelected: PropTypes.bool,
|
|
58
|
-
isChecked: PropTypes.bool
|
|
59
|
-
}),
|
|
60
|
-
expandedAttributesProps: PropTypes.shape({
|
|
61
|
-
isExpandedAttributesActive: PropTypes.bool,
|
|
62
|
-
expandedAttributes: PropTypes.array
|
|
63
|
-
}),
|
|
64
|
-
onClick: PropTypes.func
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default ListItemContact
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
makeActions,
|
|
5
|
-
modify,
|
|
6
|
-
viewInContacts
|
|
7
|
-
} from 'cozy-ui/transpiled/react/ActionsMenu/Actions'
|
|
8
|
-
|
|
9
|
-
import { makeOptionalActions } from './helpers'
|
|
10
|
-
|
|
11
|
-
const useActions = contact => {
|
|
12
|
-
const optionalActions = useMemo(() => makeOptionalActions(contact), [contact])
|
|
13
|
-
const finalActions = useMemo(
|
|
14
|
-
() => [modify, viewInContacts].concat(optionalActions),
|
|
15
|
-
[optionalActions]
|
|
16
|
-
)
|
|
17
|
-
const actions = useMemo(() => makeActions(finalActions), [finalActions])
|
|
18
|
-
|
|
19
|
-
return actions
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default useActions
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
computeExpirationDate,
|
|
6
|
-
isExpired,
|
|
7
|
-
makeExpiredMessage,
|
|
8
|
-
makeExpiresInMessage
|
|
9
|
-
} from 'cozy-client/dist/models/paper'
|
|
10
|
-
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
11
|
-
import { useI18n } from 'twake-i18n'
|
|
12
|
-
|
|
13
|
-
import withListItemLocales from '../hoc/withListItemLocales'
|
|
14
|
-
|
|
15
|
-
const ExpirationAnnotation = ({ file }) => {
|
|
16
|
-
const { lang } = useI18n()
|
|
17
|
-
|
|
18
|
-
if (isExpired(file)) {
|
|
19
|
-
return (
|
|
20
|
-
<Typography component="span" variant="inherit" color="error">
|
|
21
|
-
{makeExpiredMessage({ lang })}
|
|
22
|
-
</Typography>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const expirationDate = computeExpirationDate(file)
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Typography component="span" variant="inherit" className="u-warning">
|
|
30
|
-
{makeExpiresInMessage(expirationDate, { lang })}
|
|
31
|
-
</Typography>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
ExpirationAnnotation.propTypes = {
|
|
36
|
-
file: PropTypes.object.isRequired
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default withListItemLocales(ExpirationAnnotation)
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Icon, FileTypeNote, FileTypeText } from '@linagora/twake-icons'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { useClient } from 'cozy-client'
|
|
6
|
-
import { isNote } from 'cozy-client/dist/models/file'
|
|
7
|
-
import Skeleton from 'cozy-ui/transpiled/react/Skeleton'
|
|
8
|
-
|
|
9
|
-
import FileImageLoader from '../../FileImageLoader'
|
|
10
|
-
|
|
11
|
-
const ItemIcon = ({ icon, file }) => {
|
|
12
|
-
const client = useClient()
|
|
13
|
-
|
|
14
|
-
if (icon) return icon
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<FileImageLoader
|
|
18
|
-
client={client}
|
|
19
|
-
file={file}
|
|
20
|
-
linkType="tiny"
|
|
21
|
-
render={src => {
|
|
22
|
-
return (
|
|
23
|
-
<div className="u-flex u-w-2 u-h-2 u-flex-items-center u-flex-justify-center">
|
|
24
|
-
{src ? (
|
|
25
|
-
<img
|
|
26
|
-
className="u-w-2 u-h-2"
|
|
27
|
-
style={{ objectFit: 'contain' }}
|
|
28
|
-
src={src}
|
|
29
|
-
alt=""
|
|
30
|
-
/>
|
|
31
|
-
) : (
|
|
32
|
-
<Skeleton
|
|
33
|
-
className="u-w-100 u-h-100"
|
|
34
|
-
variant="rect"
|
|
35
|
-
animation="wave"
|
|
36
|
-
/>
|
|
37
|
-
)}
|
|
38
|
-
</div>
|
|
39
|
-
)
|
|
40
|
-
}}
|
|
41
|
-
renderFallback={() => (
|
|
42
|
-
<div className="u-flex u-w-2 u-h-2 u-flex-items-center u-flex-justify-center">
|
|
43
|
-
<Icon icon={isNote(file) ? FileTypeNote : FileTypeText} />
|
|
44
|
-
</div>
|
|
45
|
-
)}
|
|
46
|
-
/>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
ItemIcon.propTypes = {
|
|
51
|
-
icon: PropTypes.node,
|
|
52
|
-
file: PropTypes.object
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default ItemIcon
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { splitFilename } from 'cozy-client/dist/models/file'
|
|
5
|
-
import Filename from 'cozy-ui/transpiled/react/Filename'
|
|
6
|
-
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'
|
|
7
|
-
|
|
8
|
-
const PrimaryText = ({ primary, file }) => {
|
|
9
|
-
const { isMobile } = useBreakpoints()
|
|
10
|
-
|
|
11
|
-
if (primary) return primary
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Filename
|
|
15
|
-
variant="body1"
|
|
16
|
-
midEllipsis={isMobile}
|
|
17
|
-
filename={
|
|
18
|
-
splitFilename({
|
|
19
|
-
name: file.name,
|
|
20
|
-
type: 'file'
|
|
21
|
-
}).filename
|
|
22
|
-
}
|
|
23
|
-
extension={
|
|
24
|
-
splitFilename({
|
|
25
|
-
name: file.name,
|
|
26
|
-
type: 'file'
|
|
27
|
-
}).extension
|
|
28
|
-
}
|
|
29
|
-
/>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
PrimaryText.propTypes = {
|
|
34
|
-
primary: PropTypes.node,
|
|
35
|
-
file: PropTypes.object
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default PrimaryText
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { isExpired, isExpiringSoon } from 'cozy-client/dist/models/paper'
|
|
5
|
-
import { useI18n } from 'twake-i18n'
|
|
6
|
-
|
|
7
|
-
import ExpirationAnnotation from './ExpirationAnnotation'
|
|
8
|
-
|
|
9
|
-
const SecondaryText = ({ secondary, file }) => {
|
|
10
|
-
const { f } = useI18n()
|
|
11
|
-
|
|
12
|
-
if (secondary) return secondary
|
|
13
|
-
|
|
14
|
-
const date = file?.metadata?.datetime
|
|
15
|
-
? f(file?.metadata?.datetime, 'dd/LL/yyyy')
|
|
16
|
-
: null
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<>
|
|
20
|
-
{date ? date : ''}
|
|
21
|
-
{(isExpired(file) || isExpiringSoon(file)) && (
|
|
22
|
-
<>
|
|
23
|
-
{date ? ' · ' : ''}
|
|
24
|
-
<ExpirationAnnotation file={file} />
|
|
25
|
-
</>
|
|
26
|
-
)}
|
|
27
|
-
</>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
SecondaryText.propTypes = {
|
|
32
|
-
secondary: PropTypes.node,
|
|
33
|
-
file: PropTypes.object
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default SecondaryText
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { FileTypePdf } from '@linagora/twake-icons'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { splitFilename } from 'cozy-client/dist/models/file'
|
|
6
|
-
import Filename from 'cozy-ui/transpiled/react/Filename'
|
|
7
|
-
|
|
8
|
-
import ItemIcon from './ItemIcon'
|
|
9
|
-
import PrimaryText from './PrimaryText'
|
|
10
|
-
import SecondaryText from './SecondaryText'
|
|
11
|
-
import ListItemBase from '../ListItemBase'
|
|
12
|
-
|
|
13
|
-
const ListItemFile = ({
|
|
14
|
-
file,
|
|
15
|
-
primary,
|
|
16
|
-
secondary,
|
|
17
|
-
icon,
|
|
18
|
-
actions,
|
|
19
|
-
selectProps,
|
|
20
|
-
expandedAttributesProps,
|
|
21
|
-
onClick
|
|
22
|
-
}) => {
|
|
23
|
-
const { filename, extension } = splitFilename({
|
|
24
|
-
name: file.name,
|
|
25
|
-
type: 'file'
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<ListItemBase
|
|
30
|
-
doc={file}
|
|
31
|
-
primary={<PrimaryText primary={primary} file={file} />}
|
|
32
|
-
secondary={<SecondaryText secondary={secondary} file={file} />}
|
|
33
|
-
icon={<ItemIcon icon={icon} file={file} />}
|
|
34
|
-
actions={actions}
|
|
35
|
-
actionMenuComp={{
|
|
36
|
-
Header: (
|
|
37
|
-
<Filename
|
|
38
|
-
icon={FileTypePdf}
|
|
39
|
-
filename={filename}
|
|
40
|
-
extension={extension}
|
|
41
|
-
/>
|
|
42
|
-
)
|
|
43
|
-
}}
|
|
44
|
-
selectProps={selectProps}
|
|
45
|
-
expandedAttributesProps={expandedAttributesProps}
|
|
46
|
-
onClick={onClick}
|
|
47
|
-
/>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
ListItemFile.defaultProps = {
|
|
52
|
-
expandedAttributesProps: {
|
|
53
|
-
isExpandedAttributesActive: false
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
ListItemFile.propTypes = {
|
|
58
|
-
file: PropTypes.object,
|
|
59
|
-
primary: PropTypes.node,
|
|
60
|
-
secondary: PropTypes.node,
|
|
61
|
-
icon: PropTypes.node,
|
|
62
|
-
actions: PropTypes.array,
|
|
63
|
-
selectProps: PropTypes.shape({
|
|
64
|
-
isSelectActive: PropTypes.bool,
|
|
65
|
-
isSelected: PropTypes.bool,
|
|
66
|
-
isChecked: PropTypes.bool
|
|
67
|
-
}),
|
|
68
|
-
expandedAttributesProps: PropTypes.shape({
|
|
69
|
-
isExpandedAttributesActive: PropTypes.bool,
|
|
70
|
-
expandedAttributes: PropTypes.array
|
|
71
|
-
}),
|
|
72
|
-
onClick: PropTypes.func
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export default ListItemFile
|