cozy-sharing 16.7.0 → 16.8.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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [16.8.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.7.0...cozy-sharing@16.8.0) (2024-12-02)
7
+
8
+
9
+ ### Features
10
+
11
+ * **Sharing:** Expose too new component to get recipients ([a5836f7](https://github.com/cozy/cozy-libs/commit/a5836f7ea3634de44689b4e6c34eeac9b5fcb731))
12
+
13
+
14
+
15
+
16
+
6
17
  # [16.7.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.6.1...cozy-sharing@16.7.0) (2024-11-26)
7
18
 
8
19
 
@@ -0,0 +1,61 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import Circle from 'cozy-ui/transpiled/react/Circle';
4
+ import Icon from 'cozy-ui/transpiled/react/Icon';
5
+ import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link';
6
+ import ListItem from 'cozy-ui/transpiled/react/ListItem';
7
+ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
8
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
9
+ import Typography from 'cozy-ui/transpiled/react/Typography';
10
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
11
+ import { checkIsReadOnlyPermissions } from '../../helpers/permissions';
12
+ import withLocales from '../../hoc/withLocales';
13
+ var styles = {
14
+ "recipient": "recipient__recipient___2DmZI",
15
+ "recipients-list-light": "recipient__recipients-list-light___Vq4op",
16
+ "recipient-idents": "recipient__recipient-idents___3s7rw",
17
+ "recipient-status-icon": "recipient__recipient-status-icon___-liGw",
18
+ "recipient-user": "recipient__recipient-user___1THIU",
19
+ "recipient-details": "recipient__recipient-details___2fZfc",
20
+ "avatar": "recipient__avatar___2LnIV",
21
+ "link-recipient-icon-circle": "recipient__link-recipient-icon-circle___3ZTU-",
22
+ "recipients-avatars": "recipient__recipients-avatars___1npjD",
23
+ "--interactive": "recipient__--interactive___160Bp",
24
+ "recipients-avatars--link": "recipient__recipients-avatars--link___1qeON",
25
+ "recipients-avatars--plusX": "recipient__recipients-avatars--plusX___3-6_l",
26
+ "recipients-avatars--avatar": "recipient__recipients-avatars--avatar___-owjC",
27
+ "spin": "recipient__spin___2tYv3",
28
+ "shake": "recipient__shake___TGyPp"
29
+ };
30
+
31
+ var LinkRecipientLite = function LinkRecipientLite(_ref) {
32
+ var permissions = _ref.permissions,
33
+ link = _ref.link;
34
+
35
+ var _useI18n = useI18n(),
36
+ t = _useI18n.t;
37
+
38
+ if (!link) return null;
39
+ var isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions);
40
+ return /*#__PURE__*/React.createElement(ListItem, {
41
+ size: "small",
42
+ ellipsis: true
43
+ }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Circle, {
44
+ size: "small",
45
+ className: styles['link-recipient-icon-circle']
46
+ }, /*#__PURE__*/React.createElement(Icon, {
47
+ icon: LinkIcon
48
+ }))), /*#__PURE__*/React.createElement(ListItemText, {
49
+ primary: t('Share.recipients.anyoneWithTheLink'),
50
+ secondary: link
51
+ }), /*#__PURE__*/React.createElement(Typography, {
52
+ className: "u-flex-shrink-0",
53
+ variant: "body2"
54
+ }, t("Share.type.".concat(isReadOnlyPermissions ? 'one-way' : 'two-way')).toLowerCase()));
55
+ };
56
+
57
+ LinkRecipientLite.propTypes = {
58
+ permissions: PropTypes.array,
59
+ link: PropTypes.string
60
+ };
61
+ export default withLocales(LinkRecipientLite);
@@ -0,0 +1,56 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["recipient", "isOwner"];
4
+ import PropTypes from 'prop-types';
5
+ import React from 'react';
6
+ import { useClient } from 'cozy-client';
7
+ import ListItem from 'cozy-ui/transpiled/react/ListItem';
8
+ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
9
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
10
+ import Typography from 'cozy-ui/transpiled/react/Typography';
11
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
12
+ import MemberRecipientStatus from './MemberRecipientStatus';
13
+ import { DEFAULT_DISPLAY_NAME } from '../../helpers/recipients';
14
+ import withLocales from '../../hoc/withLocales';
15
+ import { getDisplayName } from '../../models';
16
+ import { MemberAvatar } from '../Avatar/MemberAvatar';
17
+
18
+ var MemberRecipientLite = function MemberRecipientLite(_ref) {
19
+ var _recipient$type;
20
+
21
+ var recipient = _ref.recipient,
22
+ isOwner = _ref.isOwner,
23
+ props = _objectWithoutProperties(_ref, _excluded);
24
+
25
+ var _useI18n = useI18n(),
26
+ t = _useI18n.t;
27
+
28
+ var client = useClient();
29
+ var isMe = isOwner && recipient.status === 'owner' || recipient.instance === client.options.uri;
30
+ return /*#__PURE__*/React.createElement(ListItem, {
31
+ size: "small",
32
+ ellipsis: true
33
+ }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(MemberAvatar, _extends({
34
+ size: "small",
35
+ recipient: recipient
36
+ }, props))), /*#__PURE__*/React.createElement(ListItemText, {
37
+ primary: isMe ? t('Share.recipients.you') : getDisplayName(recipient, t(DEFAULT_DISPLAY_NAME)),
38
+ secondary: /*#__PURE__*/React.createElement(MemberRecipientStatus, {
39
+ status: recipient.status,
40
+ isMe: isMe,
41
+ instance: recipient.instance,
42
+ typographyProps: {
43
+ noWrap: true
44
+ }
45
+ })
46
+ }), /*#__PURE__*/React.createElement(Typography, {
47
+ className: "u-flex-shrink-0",
48
+ variant: "body2"
49
+ }, isMe ? t("Share.status.".concat(recipient.status)).toLowerCase() : t("Share.type.".concat((_recipient$type = recipient.type) !== null && _recipient$type !== void 0 ? _recipient$type : 'one-way')).toLowerCase()));
50
+ };
51
+
52
+ MemberRecipientLite.propTypes = {
53
+ recipient: PropTypes.object,
54
+ isOwner: PropTypes.bool
55
+ };
56
+ export default withLocales(MemberRecipientLite);
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import React from 'react';
2
3
  import Icon from 'cozy-ui/transpiled/react/Icon';
3
4
  import EyeIcon from 'cozy-ui/transpiled/react/Icons/Eye';
@@ -27,7 +28,8 @@ var styles = {
27
28
  var MemberRecipientStatus = function MemberRecipientStatus(_ref) {
28
29
  var status = _ref.status,
29
30
  isMe = _ref.isMe,
30
- instance = _ref.instance;
31
+ instance = _ref.instance,
32
+ typographyProps = _ref.typographyProps;
31
33
 
32
34
  var _useI18n = useI18n(),
33
35
  t = _useI18n.t;
@@ -53,10 +55,10 @@ var MemberRecipientStatus = function MemberRecipientStatus(_ref) {
53
55
  }, /*#__PURE__*/React.createElement(Icon, {
54
56
  icon: icon,
55
57
  size: 10
56
- })), /*#__PURE__*/React.createElement(Bd, null, /*#__PURE__*/React.createElement(Typography, {
58
+ })), /*#__PURE__*/React.createElement(Bd, null, /*#__PURE__*/React.createElement(Typography, _extends({
57
59
  variant: "caption",
58
60
  color: "textSecondary"
59
- }, text)));
61
+ }, typographyProps), text)));
60
62
  };
61
63
 
62
64
  export default MemberRecipientStatus;
package/dist/index.js CHANGED
@@ -10,6 +10,8 @@ export { SharedStatus } from './SharedStatus';
10
10
  export { SharedBadge } from './SharedBadge';
11
11
  export { SharingOwnerAvatar } from './SharingOwnerAvatar';
12
12
  export { SharedRecipients } from './SharedRecipients';
13
+ export { default as MemberRecipientLite } from './components/Recipient/MemberRecipientLite';
14
+ export { default as LinkRecipientLite } from './components/Recipient/LinkRecipientLite';
13
15
  export { SharedRecipientsList } from './SharedRecipientsList';
14
16
  export { ShareButton } from './ShareButton';
15
17
  export { ShareModal } from './components/ShareModal/ShareModal';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "16.7.0",
3
+ "version": "16.8.0",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -71,5 +71,5 @@
71
71
  "sideEffects": [
72
72
  "*.css"
73
73
  ],
74
- "gitHead": "b049c601e43f5eb4aa906a2eec0ed280522cf08b"
74
+ "gitHead": "f248b0165931e5cc3c18606d77e94927d7a9f386"
75
75
  }
@@ -27,7 +27,7 @@ const LinkRecipient = props => {
27
27
  <RecipientConfirm
28
28
  recipientConfirmationData={recipientConfirmationData}
29
29
  verifyRecipient={verifyRecipient}
30
- ></RecipientConfirm>
30
+ />
31
31
  ) : (
32
32
  <LinkRecipientPermissions {...props} className="u-flex-shrink-0" />
33
33
  )
@@ -0,0 +1,49 @@
1
+ import PropTypes from 'prop-types'
2
+ import React from 'react'
3
+
4
+ import Circle from 'cozy-ui/transpiled/react/Circle'
5
+ import Icon from 'cozy-ui/transpiled/react/Icon'
6
+ import LinkIcon from 'cozy-ui/transpiled/react/Icons/Link'
7
+ import ListItem from 'cozy-ui/transpiled/react/ListItem'
8
+ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
9
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
10
+ import Typography from 'cozy-ui/transpiled/react/Typography'
11
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
12
+
13
+ import { checkIsReadOnlyPermissions } from '../../helpers/permissions'
14
+ import withLocales from '../../hoc/withLocales'
15
+ import styles from '../../styles/recipient.styl'
16
+
17
+ const LinkRecipientLite = ({ permissions, link }) => {
18
+ const { t } = useI18n()
19
+
20
+ if (!link) return null
21
+
22
+ const isReadOnlyPermissions = checkIsReadOnlyPermissions(permissions)
23
+
24
+ return (
25
+ <ListItem size="small" ellipsis>
26
+ <ListItemIcon>
27
+ <Circle size="small" className={styles['link-recipient-icon-circle']}>
28
+ <Icon icon={LinkIcon} />
29
+ </Circle>
30
+ </ListItemIcon>
31
+ <ListItemText
32
+ primary={t('Share.recipients.anyoneWithTheLink')}
33
+ secondary={link}
34
+ />
35
+ <Typography className="u-flex-shrink-0" variant="body2">
36
+ {t(
37
+ `Share.type.${isReadOnlyPermissions ? 'one-way' : 'two-way'}`
38
+ ).toLowerCase()}
39
+ </Typography>
40
+ </ListItem>
41
+ )
42
+ }
43
+
44
+ LinkRecipientLite.propTypes = {
45
+ permissions: PropTypes.array,
46
+ link: PropTypes.string
47
+ }
48
+
49
+ export default withLocales(LinkRecipientLite)
@@ -0,0 +1,59 @@
1
+ import PropTypes from 'prop-types'
2
+ import React from 'react'
3
+
4
+ import { useClient } from 'cozy-client'
5
+ import ListItem from 'cozy-ui/transpiled/react/ListItem'
6
+ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
7
+ import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
8
+ import Typography from 'cozy-ui/transpiled/react/Typography'
9
+ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
10
+
11
+ import MemberRecipientStatus from './MemberRecipientStatus'
12
+ import { DEFAULT_DISPLAY_NAME } from '../../helpers/recipients'
13
+ import withLocales from '../../hoc/withLocales'
14
+ import { getDisplayName } from '../../models'
15
+ import { MemberAvatar } from '../Avatar/MemberAvatar'
16
+
17
+ const MemberRecipientLite = ({ recipient, isOwner, ...props }) => {
18
+ const { t } = useI18n()
19
+ const client = useClient()
20
+
21
+ const isMe =
22
+ (isOwner && recipient.status === 'owner') ||
23
+ recipient.instance === client.options.uri
24
+
25
+ return (
26
+ <ListItem size="small" ellipsis>
27
+ <ListItemIcon>
28
+ <MemberAvatar size="small" recipient={recipient} {...props} />
29
+ </ListItemIcon>
30
+ <ListItemText
31
+ primary={
32
+ isMe
33
+ ? t('Share.recipients.you')
34
+ : getDisplayName(recipient, t(DEFAULT_DISPLAY_NAME))
35
+ }
36
+ secondary={
37
+ <MemberRecipientStatus
38
+ status={recipient.status}
39
+ isMe={isMe}
40
+ instance={recipient.instance}
41
+ typographyProps={{ noWrap: true }}
42
+ />
43
+ }
44
+ />
45
+ <Typography className="u-flex-shrink-0" variant="body2">
46
+ {isMe
47
+ ? t(`Share.status.${recipient.status}`).toLowerCase()
48
+ : t(`Share.type.${recipient.type ?? 'one-way'}`).toLowerCase()}
49
+ </Typography>
50
+ </ListItem>
51
+ )
52
+ }
53
+
54
+ MemberRecipientLite.propTypes = {
55
+ recipient: PropTypes.object,
56
+ isOwner: PropTypes.bool
57
+ }
58
+
59
+ export default withLocales(MemberRecipientLite)
@@ -10,7 +10,7 @@ import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
10
10
 
11
11
  import styles from '../../styles/recipient.styl'
12
12
 
13
- const MemberRecipientStatus = ({ status, isMe, instance }) => {
13
+ const MemberRecipientStatus = ({ status, isMe, instance, typographyProps }) => {
14
14
  const { t } = useI18n()
15
15
 
16
16
  const isSendingEmail = !isMe && status === 'mail-not-sent'
@@ -37,7 +37,11 @@ const MemberRecipientStatus = ({ status, isMe, instance }) => {
37
37
  <Icon icon={icon} size={10} />
38
38
  </Img>
39
39
  <Bd>
40
- <Typography variant="caption" color="textSecondary">
40
+ <Typography
41
+ variant="caption"
42
+ color="textSecondary"
43
+ {...typographyProps}
44
+ >
41
45
  {text}
42
46
  </Typography>
43
47
  </Bd>
package/src/index.jsx CHANGED
@@ -14,6 +14,8 @@ export { SharedStatus } from './SharedStatus'
14
14
  export { SharedBadge } from './SharedBadge'
15
15
  export { SharingOwnerAvatar } from './SharingOwnerAvatar'
16
16
  export { SharedRecipients } from './SharedRecipients'
17
+ export { default as MemberRecipientLite } from './components/Recipient/MemberRecipientLite'
18
+ export { default as LinkRecipientLite } from './components/Recipient/LinkRecipientLite'
17
19
  export { SharedRecipientsList } from './SharedRecipientsList'
18
20
  export { ShareButton } from './ShareButton'
19
21
  export { ShareModal } from './components/ShareModal/ShareModal'