cozy-ui 146.0.0 → 146.1.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 +7 -0
- package/package.json +1 -1
- package/react/MemberList/EmptyMembers.jsx +45 -0
- package/react/MemberList/MemberList.spec.jsx +48 -0
- package/react/MemberList/Readme.md +72 -0
- package/react/MemberList/index.jsx +70 -0
- package/react/MemberList/locales/de.json +8 -0
- package/react/MemberList/locales/en.json +8 -0
- package/react/MemberList/locales/es.json +8 -0
- package/react/MemberList/locales/fr.json +8 -0
- package/react/MemberList/locales/index.js +17 -0
- package/react/MemberList/locales/it.json +8 -0
- package/react/MemberList/locales/ru.json +8 -0
- package/react/MemberList/locales/vi.json +8 -0
- package/react/MemberRow/MemberAvatar.jsx +31 -0
- package/react/MemberRow/MemberAvatar.spec.jsx +26 -0
- package/react/MemberRow/MemberGroupAvatar.jsx +17 -0
- package/react/MemberRow/MemberRoleMenu.jsx +71 -0
- package/react/MemberRow/MemberRoleMenu.spec.jsx +49 -0
- package/react/MemberRow/MemberRoleMenuHeader.jsx +40 -0
- package/react/MemberRow/MemberRow.spec.jsx +39 -0
- package/react/MemberRow/MemberRowActions.jsx +56 -0
- package/react/MemberRow/Readme.md +57 -0
- package/react/MemberRow/index.jsx +112 -0
- package/react/MemberRow/locales/de.json +8 -0
- package/react/MemberRow/locales/en.json +8 -0
- package/react/MemberRow/locales/es.json +8 -0
- package/react/MemberRow/locales/fr.json +8 -0
- package/react/MemberRow/locales/index.js +17 -0
- package/react/MemberRow/locales/it.json +8 -0
- package/react/MemberRow/locales/ru.json +8 -0
- package/react/MemberRow/locales/vi.json +8 -0
- package/react/MemberRow/propTypes.js +33 -0
- package/transpiled/react/MemberList/EmptyMembers.d.ts +2 -0
- package/transpiled/react/MemberList/EmptyMembers.js +42 -0
- package/transpiled/react/MemberList/MemberList.spec.d.ts +1 -0
- package/transpiled/react/MemberList/index.d.ts +61 -0
- package/transpiled/react/MemberList/index.js +63 -0
- package/transpiled/react/MemberList/locales/index.d.ts +16 -0
- package/transpiled/react/MemberList/locales/index.js +65 -0
- package/transpiled/react/MemberRow/MemberAvatar.d.ts +6 -0
- package/transpiled/react/MemberRow/MemberAvatar.js +34 -0
- package/transpiled/react/MemberRow/MemberAvatar.spec.d.ts +1 -0
- package/transpiled/react/MemberRow/MemberGroupAvatar.d.ts +6 -0
- package/transpiled/react/MemberRow/MemberGroupAvatar.js +21 -0
- package/transpiled/react/MemberRow/MemberRoleMenu.d.ts +45 -0
- package/transpiled/react/MemberRow/MemberRoleMenu.js +87 -0
- package/transpiled/react/MemberRow/MemberRoleMenu.spec.d.ts +1 -0
- package/transpiled/react/MemberRow/MemberRoleMenuHeader.d.ts +35 -0
- package/transpiled/react/MemberRow/MemberRoleMenuHeader.js +40 -0
- package/transpiled/react/MemberRow/MemberRow.spec.d.ts +1 -0
- package/transpiled/react/MemberRow/MemberRowActions.d.ts +45 -0
- package/transpiled/react/MemberRow/MemberRowActions.js +61 -0
- package/transpiled/react/MemberRow/index.d.ts +68 -0
- package/transpiled/react/MemberRow/index.js +102 -0
- package/transpiled/react/MemberRow/locales/index.d.ts +16 -0
- package/transpiled/react/MemberRow/locales/index.js +65 -0
- package/transpiled/react/MemberRow/propTypes.d.ts +32 -0
- package/transpiled/react/MemberRow/propTypes.js +30 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Displays a member of a sharing: avatar, name, subtitle, and on the right its role and a button to remove them. `MemberList` renders one row per member.
|
|
2
|
+
|
|
3
|
+
### Props of a member
|
|
4
|
+
|
|
5
|
+
* **id**: unique key of the member
|
|
6
|
+
* **name**: displayed name, replaced by "You" when `isCurrentUser`
|
|
7
|
+
* **subtitle**: email, status… (any node)
|
|
8
|
+
* **avatarUrl** and **initials**: picture of the member, initials when there is no picture or it fails to load
|
|
9
|
+
* **isGroup** and **color**: shows a group avatar
|
|
10
|
+
* **isOwner**: shows the "Owner" label and no action
|
|
11
|
+
* **role** and **roles**: current role, and the roles of this member when they differ from the `roles` of the row
|
|
12
|
+
* **canChangeRole**: shows the role in a menu, as text otherwise
|
|
13
|
+
* **canRemove**, **removeIcon** and **removeLabel**: remove button, its icon and its accessible label
|
|
14
|
+
* **action**: `{ label, onClick }` button shown in place of the role and the remove button
|
|
15
|
+
* **isPending**: shows a spinner instead of the actions
|
|
16
|
+
* **onClick**: makes the row clickable
|
|
17
|
+
* **data**: anything the app needs back in its callbacks, not read by the row
|
|
18
|
+
|
|
19
|
+
### Demo
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
|
|
23
|
+
import List from 'cozy-ui/transpiled/react/List'
|
|
24
|
+
import MemberRow from 'cozy-ui/transpiled/react/MemberRow'
|
|
25
|
+
import { Unlink } from '@linagora/twake-icons'
|
|
26
|
+
|
|
27
|
+
const roles = [
|
|
28
|
+
{ value: 'viewer', label: 'Viewer' },
|
|
29
|
+
{ value: 'editor', label: 'Editor' }
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
const rows = [
|
|
33
|
+
['Owner', { id: 'alice', name: 'Alice', subtitle: 'alice@cozy.cc', initials: 'A', isOwner: true, isCurrentUser: true }],
|
|
34
|
+
['Role and remove button', { id: 'bob', name: 'Bob', subtitle: 'bob@cozy.cc', initials: 'B', role: 'editor', canChangeRole: true, canRemove: true }],
|
|
35
|
+
['Role as text', { id: 'carol', name: 'Carol', subtitle: 'carol@cozy.cc', initials: 'C', role: 'viewer' }],
|
|
36
|
+
['Action', { id: 'dave', name: 'Dave', subtitle: 'dave@cozy.cc', initials: 'D', action: { label: 'Verify', onClick: () => {} } }],
|
|
37
|
+
['Pending', { id: 'eve', name: 'Eve', subtitle: 'eve@cozy.cc', initials: 'E', role: 'editor', canChangeRole: true, canRemove: true, isPending: true }],
|
|
38
|
+
['Clickable group with its only role', { id: 'family', name: 'Family', subtitle: '2 members', isGroup: true, role: 'editor', roles: [{ value: 'editor', label: 'Editor' }], canChangeRole: true, canRemove: true, onClick: () => {} }],
|
|
39
|
+
['Clickable group, other remove icon', { id: 'team', name: 'Team', subtitle: '3 members', isGroup: true, color: '#FF7F1B', role: 'editor', canRemove: true, removeIcon: Unlink, removeLabel: 'Unlink Team', onClick: () => {} }]
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
;
|
|
43
|
+
|
|
44
|
+
<DemoProvider>
|
|
45
|
+
<List>
|
|
46
|
+
{rows.map(([label, member]) => (
|
|
47
|
+
<MemberRow
|
|
48
|
+
key={member.id}
|
|
49
|
+
member={{ ...member, name: `${member.name} (${label})` }}
|
|
50
|
+
roles={roles}
|
|
51
|
+
onRoleChange={() => {}}
|
|
52
|
+
onRemove={() => {}}
|
|
53
|
+
/>
|
|
54
|
+
))}
|
|
55
|
+
</List>
|
|
56
|
+
</DemoProvider>
|
|
57
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React, { Fragment } from 'react'
|
|
3
|
+
import { useI18n, useExtendI18n } from 'twake-i18n'
|
|
4
|
+
|
|
5
|
+
import MemberAvatar from './MemberAvatar'
|
|
6
|
+
import MemberGroupAvatar from './MemberGroupAvatar'
|
|
7
|
+
import MemberRowActions from './MemberRowActions'
|
|
8
|
+
import { locales } from './locales'
|
|
9
|
+
import { memberPropType, rolesPropType } from './propTypes'
|
|
10
|
+
import Button from '../Buttons'
|
|
11
|
+
import Fade from '../Fade'
|
|
12
|
+
import ListItem from '../ListItem'
|
|
13
|
+
import ListItemIcon from '../ListItemIcon'
|
|
14
|
+
import ListItemSecondaryAction from '../ListItemSecondaryAction'
|
|
15
|
+
import ListItemText from '../ListItemText'
|
|
16
|
+
import Typography from '../Typography'
|
|
17
|
+
import useBreakpoints from '../providers/Breakpoints'
|
|
18
|
+
|
|
19
|
+
export const FADE_IN_DURATION = 600
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Displays a member of a sharing: avatar, name, subtitle, role and remove button
|
|
23
|
+
*
|
|
24
|
+
* @param {object} props
|
|
25
|
+
* @param {object} props.member - Member to display, see `memberPropType`
|
|
26
|
+
* @param {object[]} props.roles - Roles a member can get, as `{ value, label }`
|
|
27
|
+
* @param {boolean} [props.isNew] - Whether the row fades in
|
|
28
|
+
* @param {Function} props.onRoleChange - Called with the member and its new role
|
|
29
|
+
* @param {Function} props.onRemove - Called with the member to remove
|
|
30
|
+
*/
|
|
31
|
+
const MemberRow = ({ member, roles, isNew, onRoleChange, onRemove }) => {
|
|
32
|
+
useExtendI18n(locales)
|
|
33
|
+
const { t } = useI18n()
|
|
34
|
+
const { isMobile } = useBreakpoints()
|
|
35
|
+
const {
|
|
36
|
+
name,
|
|
37
|
+
subtitle,
|
|
38
|
+
avatarUrl,
|
|
39
|
+
initials,
|
|
40
|
+
color,
|
|
41
|
+
isGroup,
|
|
42
|
+
isOwner,
|
|
43
|
+
isCurrentUser,
|
|
44
|
+
action,
|
|
45
|
+
onClick
|
|
46
|
+
} = member
|
|
47
|
+
|
|
48
|
+
const ActionsWrapper = onClick ? ListItemSecondaryAction : Fragment
|
|
49
|
+
const actionsWrapperProps = onClick
|
|
50
|
+
? { className: isMobile ? 'u-mr-1' : 'u-mr-2' }
|
|
51
|
+
: undefined
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Fade in timeout={isNew ? FADE_IN_DURATION : 0}>
|
|
55
|
+
<ListItem
|
|
56
|
+
button={Boolean(onClick)}
|
|
57
|
+
onClick={onClick}
|
|
58
|
+
gutters={isMobile ? 'default' : 'double'}
|
|
59
|
+
size="small"
|
|
60
|
+
>
|
|
61
|
+
<ListItemIcon>
|
|
62
|
+
{isGroup ? (
|
|
63
|
+
<MemberGroupAvatar size="m" color={color} />
|
|
64
|
+
) : (
|
|
65
|
+
<MemberAvatar size="m" initials={initials} avatarUrl={avatarUrl} />
|
|
66
|
+
)}
|
|
67
|
+
</ListItemIcon>
|
|
68
|
+
<ListItemText
|
|
69
|
+
primary={
|
|
70
|
+
<Typography variant="body1">
|
|
71
|
+
{isCurrentUser
|
|
72
|
+
? t('MemberRow.you')
|
|
73
|
+
: name || t('MemberRow.defaultName')}
|
|
74
|
+
</Typography>
|
|
75
|
+
}
|
|
76
|
+
secondary={subtitle}
|
|
77
|
+
/>
|
|
78
|
+
<ActionsWrapper {...actionsWrapperProps}>
|
|
79
|
+
{isOwner && (
|
|
80
|
+
<Typography variant="body2">{t('MemberRow.owner')}</Typography>
|
|
81
|
+
)}
|
|
82
|
+
{action && (
|
|
83
|
+
<Button
|
|
84
|
+
style={{ position: 'initial' }} // fix z-index bug on iOS when under a BottomDrawer due to relative position
|
|
85
|
+
variant="text"
|
|
86
|
+
onClick={action.onClick}
|
|
87
|
+
label={action.label}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
{!isOwner && !action && (
|
|
91
|
+
<MemberRowActions
|
|
92
|
+
member={member}
|
|
93
|
+
roles={roles}
|
|
94
|
+
onRoleChange={onRoleChange}
|
|
95
|
+
onRemove={onRemove}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
</ActionsWrapper>
|
|
99
|
+
</ListItem>
|
|
100
|
+
</Fade>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
MemberRow.propTypes = {
|
|
105
|
+
member: memberPropType.isRequired,
|
|
106
|
+
roles: rolesPropType.isRequired,
|
|
107
|
+
isNew: PropTypes.bool,
|
|
108
|
+
onRoleChange: PropTypes.func.isRequired,
|
|
109
|
+
onRemove: PropTypes.func.isRequired
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default MemberRow
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import de from './de.json'
|
|
2
|
+
import en from './en.json'
|
|
3
|
+
import es from './es.json'
|
|
4
|
+
import fr from './fr.json'
|
|
5
|
+
import it from './it.json'
|
|
6
|
+
import ru from './ru.json'
|
|
7
|
+
import vi from './vi.json'
|
|
8
|
+
|
|
9
|
+
export const locales = {
|
|
10
|
+
de,
|
|
11
|
+
en,
|
|
12
|
+
es,
|
|
13
|
+
fr,
|
|
14
|
+
it,
|
|
15
|
+
ru,
|
|
16
|
+
vi
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
|
|
3
|
+
const rolePropType = PropTypes.shape({
|
|
4
|
+
value: PropTypes.string.isRequired,
|
|
5
|
+
label: PropTypes.string.isRequired
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export const rolesPropType = PropTypes.arrayOf(rolePropType)
|
|
9
|
+
|
|
10
|
+
export const memberPropType = PropTypes.shape({
|
|
11
|
+
id: PropTypes.string.isRequired,
|
|
12
|
+
name: PropTypes.string,
|
|
13
|
+
subtitle: PropTypes.node,
|
|
14
|
+
avatarUrl: PropTypes.string,
|
|
15
|
+
initials: PropTypes.string,
|
|
16
|
+
color: PropTypes.string,
|
|
17
|
+
isGroup: PropTypes.bool,
|
|
18
|
+
isOwner: PropTypes.bool,
|
|
19
|
+
isCurrentUser: PropTypes.bool,
|
|
20
|
+
role: PropTypes.string,
|
|
21
|
+
roles: rolesPropType,
|
|
22
|
+
canChangeRole: PropTypes.bool,
|
|
23
|
+
canRemove: PropTypes.bool,
|
|
24
|
+
removeIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
25
|
+
removeLabel: PropTypes.string,
|
|
26
|
+
action: PropTypes.shape({
|
|
27
|
+
label: PropTypes.string.isRequired,
|
|
28
|
+
onClick: PropTypes.func.isRequired
|
|
29
|
+
}),
|
|
30
|
+
isPending: PropTypes.bool,
|
|
31
|
+
onClick: PropTypes.func,
|
|
32
|
+
data: PropTypes.any
|
|
33
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Icon, Team } from '@linagora/twake-icons';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useI18n, useExtendI18n } from 'twake-i18n';
|
|
5
|
+
import { locales } from "cozy-ui/transpiled/react/MemberList/locales";
|
|
6
|
+
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
7
|
+
import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
|
|
8
|
+
import { alpha, makeStyles } from "cozy-ui/transpiled/react/styles";
|
|
9
|
+
var useStyles = makeStyles(function (theme) {
|
|
10
|
+
return {
|
|
11
|
+
root: {
|
|
12
|
+
backgroundColor: alpha(theme.palette.secondary.main, theme.palette.action.hoverOpacity)
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
var EmptyMembers = function EmptyMembers() {
|
|
18
|
+
useExtendI18n(locales);
|
|
19
|
+
|
|
20
|
+
var _useI18n = useI18n(),
|
|
21
|
+
t = _useI18n.t;
|
|
22
|
+
|
|
23
|
+
var _useBreakpoints = useBreakpoints(),
|
|
24
|
+
isMobile = _useBreakpoints.isMobile;
|
|
25
|
+
|
|
26
|
+
var classes = useStyles();
|
|
27
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: cx('u-flex u-flex-column u-flex-items-center u-pv-2 u-ph-1 u-bdrs-6', isMobile ? 'u-mh-1' : 'u-mh-2', classes.root)
|
|
29
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
+
icon: Team,
|
|
31
|
+
size: 48,
|
|
32
|
+
color: "var(--primaryColorLight)"
|
|
33
|
+
}), /*#__PURE__*/React.createElement(Typography, {
|
|
34
|
+
variant: "body2",
|
|
35
|
+
className: "u-mt-half"
|
|
36
|
+
}, t('MemberList.empty.title')), /*#__PURE__*/React.createElement(Typography, {
|
|
37
|
+
variant: "caption",
|
|
38
|
+
color: "textSecondary"
|
|
39
|
+
}, t('MemberList.empty.subtitle')));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default EmptyMembers;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export default MemberList;
|
|
2
|
+
/**
|
|
3
|
+
* Lists the members of a sharing, the owner first
|
|
4
|
+
*
|
|
5
|
+
* @param {object} props
|
|
6
|
+
* @param {object[]} props.members - Members to display, see `MemberRow`
|
|
7
|
+
* @param {object[]} props.roles - Roles a member can get, as `{ value, label }`
|
|
8
|
+
* @param {Function} props.onRoleChange - Called with the member and its new role
|
|
9
|
+
* @param {Function} props.onRemove - Called with the member to remove
|
|
10
|
+
* @param {boolean} [props.showEmptyState] - Whether to show a placeholder
|
|
11
|
+
* when there is no member but the owner
|
|
12
|
+
* @param {string} [props.className] - Class name of the list
|
|
13
|
+
*/
|
|
14
|
+
declare function MemberList({ members, roles, onRoleChange, onRemove, showEmptyState, className }: {
|
|
15
|
+
members: object[];
|
|
16
|
+
roles: object[];
|
|
17
|
+
onRoleChange: Function;
|
|
18
|
+
onRemove: Function;
|
|
19
|
+
showEmptyState?: boolean | undefined;
|
|
20
|
+
className?: string | undefined;
|
|
21
|
+
}): JSX.Element;
|
|
22
|
+
declare namespace MemberList {
|
|
23
|
+
namespace propTypes {
|
|
24
|
+
const members: PropTypes.Validator<(PropTypes.InferProps<{
|
|
25
|
+
id: PropTypes.Validator<string>;
|
|
26
|
+
name: PropTypes.Requireable<string>;
|
|
27
|
+
subtitle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
28
|
+
avatarUrl: PropTypes.Requireable<string>;
|
|
29
|
+
initials: PropTypes.Requireable<string>;
|
|
30
|
+
color: PropTypes.Requireable<string>;
|
|
31
|
+
isGroup: PropTypes.Requireable<boolean>;
|
|
32
|
+
isOwner: PropTypes.Requireable<boolean>;
|
|
33
|
+
isCurrentUser: PropTypes.Requireable<boolean>;
|
|
34
|
+
role: PropTypes.Requireable<string>;
|
|
35
|
+
roles: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
36
|
+
value: PropTypes.Validator<string>;
|
|
37
|
+
label: PropTypes.Validator<string>;
|
|
38
|
+
}> | null)[]>;
|
|
39
|
+
canChangeRole: PropTypes.Requireable<boolean>;
|
|
40
|
+
canRemove: PropTypes.Requireable<boolean>;
|
|
41
|
+
removeIcon: PropTypes.Requireable<object>;
|
|
42
|
+
removeLabel: PropTypes.Requireable<string>;
|
|
43
|
+
action: PropTypes.Requireable<PropTypes.InferProps<{
|
|
44
|
+
label: PropTypes.Validator<string>;
|
|
45
|
+
onClick: PropTypes.Validator<(...args: any[]) => any>;
|
|
46
|
+
}>>;
|
|
47
|
+
isPending: PropTypes.Requireable<boolean>;
|
|
48
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
49
|
+
data: PropTypes.Requireable<any>;
|
|
50
|
+
}> | null)[]>;
|
|
51
|
+
const roles: PropTypes.Validator<(PropTypes.InferProps<{
|
|
52
|
+
value: PropTypes.Validator<string>;
|
|
53
|
+
label: PropTypes.Validator<string>;
|
|
54
|
+
}> | null)[]>;
|
|
55
|
+
const onRoleChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
56
|
+
const onRemove: PropTypes.Validator<(...args: any[]) => any>;
|
|
57
|
+
const showEmptyState: PropTypes.Requireable<boolean>;
|
|
58
|
+
const className: PropTypes.Requireable<string>;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useGetIsMounted } from 'rooks';
|
|
4
|
+
import EmptyMembers from "cozy-ui/transpiled/react/MemberList/EmptyMembers";
|
|
5
|
+
import List from "cozy-ui/transpiled/react/List";
|
|
6
|
+
import MemberRow from "cozy-ui/transpiled/react/MemberRow";
|
|
7
|
+
import { memberPropType, rolesPropType } from "cozy-ui/transpiled/react/MemberRow/propTypes";
|
|
8
|
+
/**
|
|
9
|
+
* Lists the members of a sharing, the owner first
|
|
10
|
+
*
|
|
11
|
+
* @param {object} props
|
|
12
|
+
* @param {object[]} props.members - Members to display, see `MemberRow`
|
|
13
|
+
* @param {object[]} props.roles - Roles a member can get, as `{ value, label }`
|
|
14
|
+
* @param {Function} props.onRoleChange - Called with the member and its new role
|
|
15
|
+
* @param {Function} props.onRemove - Called with the member to remove
|
|
16
|
+
* @param {boolean} [props.showEmptyState] - Whether to show a placeholder
|
|
17
|
+
* when there is no member but the owner
|
|
18
|
+
* @param {string} [props.className] - Class name of the list
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
var MemberList = function MemberList(_ref) {
|
|
22
|
+
var members = _ref.members,
|
|
23
|
+
roles = _ref.roles,
|
|
24
|
+
onRoleChange = _ref.onRoleChange,
|
|
25
|
+
onRemove = _ref.onRemove,
|
|
26
|
+
_ref$showEmptyState = _ref.showEmptyState,
|
|
27
|
+
showEmptyState = _ref$showEmptyState === void 0 ? true : _ref$showEmptyState,
|
|
28
|
+
className = _ref.className;
|
|
29
|
+
var getIsMounted = useGetIsMounted();
|
|
30
|
+
var owner = members.find(function (member) {
|
|
31
|
+
return member.isOwner;
|
|
32
|
+
});
|
|
33
|
+
var otherMembers = members.filter(function (member) {
|
|
34
|
+
return !member.isOwner;
|
|
35
|
+
});
|
|
36
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(List, {
|
|
37
|
+
className: className
|
|
38
|
+
}, owner && /*#__PURE__*/React.createElement(MemberRow, {
|
|
39
|
+
member: owner,
|
|
40
|
+
roles: roles,
|
|
41
|
+
onRoleChange: onRoleChange,
|
|
42
|
+
onRemove: onRemove
|
|
43
|
+
}), otherMembers.map(function (member) {
|
|
44
|
+
return /*#__PURE__*/React.createElement(MemberRow, {
|
|
45
|
+
key: member.id,
|
|
46
|
+
member: member,
|
|
47
|
+
roles: roles,
|
|
48
|
+
isNew: getIsMounted(),
|
|
49
|
+
onRoleChange: onRoleChange,
|
|
50
|
+
onRemove: onRemove
|
|
51
|
+
});
|
|
52
|
+
})), showEmptyState && otherMembers.length === 0 && /*#__PURE__*/React.createElement(EmptyMembers, null));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
MemberList.propTypes = {
|
|
56
|
+
members: PropTypes.arrayOf(memberPropType).isRequired,
|
|
57
|
+
roles: rolesPropType.isRequired,
|
|
58
|
+
onRoleChange: PropTypes.func.isRequired,
|
|
59
|
+
onRemove: PropTypes.func.isRequired,
|
|
60
|
+
showEmptyState: PropTypes.bool,
|
|
61
|
+
className: PropTypes.string
|
|
62
|
+
};
|
|
63
|
+
export default MemberList;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export namespace locales {
|
|
2
|
+
export { de };
|
|
3
|
+
export { en };
|
|
4
|
+
export { es };
|
|
5
|
+
export { fr };
|
|
6
|
+
export { it };
|
|
7
|
+
export { ru };
|
|
8
|
+
export { vi };
|
|
9
|
+
}
|
|
10
|
+
import de from "./de.json";
|
|
11
|
+
import en from "./en.json";
|
|
12
|
+
import es from "./es.json";
|
|
13
|
+
import fr from "./fr.json";
|
|
14
|
+
import it from "./it.json";
|
|
15
|
+
import ru from "./ru.json";
|
|
16
|
+
import vi from "./vi.json";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var de = {
|
|
2
|
+
MemberList: {
|
|
3
|
+
empty: {
|
|
4
|
+
title: "Noch niemand hinzugef\xFCgt",
|
|
5
|
+
subtitle: "Eingeladene Personen werden hier angezeigt."
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
var en = {
|
|
10
|
+
MemberList: {
|
|
11
|
+
empty: {
|
|
12
|
+
title: "No one has been added yet",
|
|
13
|
+
subtitle: "People invited to join will be listed here."
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var es = {
|
|
18
|
+
MemberList: {
|
|
19
|
+
empty: {
|
|
20
|
+
title: "Todav\xEDa no se ha a\xF1adido a nadie",
|
|
21
|
+
subtitle: "Las personas invitadas aparecer\xE1n aqu\xED."
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var fr = {
|
|
26
|
+
MemberList: {
|
|
27
|
+
empty: {
|
|
28
|
+
title: "Personne n'a encore \xE9t\xE9 ajout\xE9",
|
|
29
|
+
subtitle: "Les personnes invit\xE9es appara\xEEtront ici."
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var it = {
|
|
34
|
+
MemberList: {
|
|
35
|
+
empty: {
|
|
36
|
+
title: "Nessuno \xE8 stato ancora aggiunto",
|
|
37
|
+
subtitle: "Le persone invitate verranno elencate qui."
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var ru = {
|
|
42
|
+
MemberList: {
|
|
43
|
+
empty: {
|
|
44
|
+
title: "\u041F\u043E\u043A\u0430 \u043D\u0438\u043A\u0442\u043E \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u0435\u043D",
|
|
45
|
+
subtitle: "\u0417\u0434\u0435\u0441\u044C \u043F\u043E\u044F\u0432\u044F\u0442\u0441\u044F \u043F\u0440\u0438\u0433\u043B\u0430\u0448\u0451\u043D\u043D\u044B\u0435 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u0438."
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var vi = {
|
|
50
|
+
MemberList: {
|
|
51
|
+
empty: {
|
|
52
|
+
title: "Ch\u01B0a c\xF3 ai \u0111\u01B0\u1EE3c th\xEAm",
|
|
53
|
+
subtitle: "Nh\u1EEFng ng\u01B0\u1EDDi \u0111\u01B0\u1EE3c m\u1EDDi s\u1EBD hi\u1EC3n th\u1ECB t\u1EA1i \u0111\xE2y."
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export var locales = {
|
|
58
|
+
de: de,
|
|
59
|
+
en: en,
|
|
60
|
+
es: es,
|
|
61
|
+
fr: fr,
|
|
62
|
+
it: it,
|
|
63
|
+
ru: ru,
|
|
64
|
+
vi: vi
|
|
65
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["initials", "avatarUrl"];
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import Avatar from "cozy-ui/transpiled/react/Avatar";
|
|
6
|
+
|
|
7
|
+
var MemberAvatar = function MemberAvatar(_ref) {
|
|
8
|
+
var initials = _ref.initials,
|
|
9
|
+
avatarUrl = _ref.avatarUrl,
|
|
10
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
11
|
+
|
|
12
|
+
// Remember which image url failed to load so we can fall back to the
|
|
13
|
+
// initials. Storing the url (instead of a boolean) means a new url is
|
|
14
|
+
// retried automatically, without an effect to reset the error state.
|
|
15
|
+
var _useState = useState(null),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
erroredSrc = _useState2[0],
|
|
18
|
+
setErroredSrc = _useState2[1]; // The avatar can become unreachable (eg. the related sharing is revoked
|
|
19
|
+
// while its members are still rendered), in which case the image request
|
|
20
|
+
// fails. Without a fallback the browser shows a broken-image icon, so we
|
|
21
|
+
// render the initials instead.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
return /*#__PURE__*/React.createElement(Avatar, rest, avatarUrl && erroredSrc !== avatarUrl ? /*#__PURE__*/React.createElement("img", {
|
|
25
|
+
width: "100%",
|
|
26
|
+
height: "100%",
|
|
27
|
+
src: avatarUrl,
|
|
28
|
+
onError: function onError() {
|
|
29
|
+
return setErroredSrc(avatarUrl);
|
|
30
|
+
}
|
|
31
|
+
}) : initials);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default MemberAvatar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Icon, Peoples } from '@linagora/twake-icons';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Avatar, { colorToGradient } from "cozy-ui/transpiled/react/Avatar";
|
|
4
|
+
import { COLORS } from "cozy-ui/transpiled/react/ColorList/helpers";
|
|
5
|
+
var DEFAULT_COLOR = COLORS[4];
|
|
6
|
+
|
|
7
|
+
var MemberGroupAvatar = function MemberGroupAvatar(_ref) {
|
|
8
|
+
var size = _ref.size,
|
|
9
|
+
_ref$color = _ref.color,
|
|
10
|
+
color = _ref$color === void 0 ? DEFAULT_COLOR : _ref$color,
|
|
11
|
+
className = _ref.className;
|
|
12
|
+
return /*#__PURE__*/React.createElement(Avatar, {
|
|
13
|
+
size: size,
|
|
14
|
+
color: colorToGradient(color),
|
|
15
|
+
className: className
|
|
16
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
17
|
+
icon: Peoples
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default MemberGroupAvatar;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export default MemberRoleMenu;
|
|
2
|
+
declare function MemberRoleMenu({ member, value, roles, onChange }: {
|
|
3
|
+
member: any;
|
|
4
|
+
value: any;
|
|
5
|
+
roles: any;
|
|
6
|
+
onChange: any;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
declare namespace MemberRoleMenu {
|
|
9
|
+
namespace propTypes {
|
|
10
|
+
const member: PropTypes.Validator<PropTypes.InferProps<{
|
|
11
|
+
id: PropTypes.Validator<string>;
|
|
12
|
+
name: PropTypes.Requireable<string>;
|
|
13
|
+
subtitle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
14
|
+
avatarUrl: PropTypes.Requireable<string>;
|
|
15
|
+
initials: PropTypes.Requireable<string>;
|
|
16
|
+
color: PropTypes.Requireable<string>;
|
|
17
|
+
isGroup: PropTypes.Requireable<boolean>;
|
|
18
|
+
isOwner: PropTypes.Requireable<boolean>;
|
|
19
|
+
isCurrentUser: PropTypes.Requireable<boolean>;
|
|
20
|
+
role: PropTypes.Requireable<string>;
|
|
21
|
+
roles: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
22
|
+
value: PropTypes.Validator<string>;
|
|
23
|
+
label: PropTypes.Validator<string>;
|
|
24
|
+
}> | null)[]>;
|
|
25
|
+
canChangeRole: PropTypes.Requireable<boolean>;
|
|
26
|
+
canRemove: PropTypes.Requireable<boolean>;
|
|
27
|
+
removeIcon: PropTypes.Requireable<object>;
|
|
28
|
+
removeLabel: PropTypes.Requireable<string>;
|
|
29
|
+
action: PropTypes.Requireable<PropTypes.InferProps<{
|
|
30
|
+
label: PropTypes.Validator<string>;
|
|
31
|
+
onClick: PropTypes.Validator<(...args: any[]) => any>;
|
|
32
|
+
}>>;
|
|
33
|
+
isPending: PropTypes.Requireable<boolean>;
|
|
34
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
35
|
+
data: PropTypes.Requireable<any>;
|
|
36
|
+
}>>;
|
|
37
|
+
const value: PropTypes.Validator<string>;
|
|
38
|
+
const roles: PropTypes.Validator<(PropTypes.InferProps<{
|
|
39
|
+
value: PropTypes.Validator<string>;
|
|
40
|
+
label: PropTypes.Validator<string>;
|
|
41
|
+
}> | null)[]>;
|
|
42
|
+
const onChange: PropTypes.Validator<(...args: any[]) => any>;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
import PropTypes from "prop-types";
|