cozy-sharing 16.12.0 → 16.13.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.13.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.12.0...cozy-sharing@16.13.0) (2024-12-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * Use Sharing locales instead apps ([55265c9](https://github.com/cozy/cozy-libs/commit/55265c9366e8ee98664503a6a62500e4ec986606))
12
+
13
+
14
+
15
+
16
+
6
17
  # [16.12.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@16.11.0...cozy-sharing@16.12.0) (2024-12-06)
7
18
 
8
19
 
@@ -7,6 +7,7 @@ import Button from 'cozy-ui/transpiled/react/Buttons';
7
7
  import Icon from 'cozy-ui/transpiled/react/Icon';
8
8
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
9
9
  import { getIconWithlabel, openExternalLink } from './helpers/sharings';
10
+ import withLocales from './hoc/withLocales';
10
11
  /**
11
12
  * OpenSharingLinkButton component renders a Button
12
13
  * that opens an link for Add/Synchronize/Create Cozy when clicked.
@@ -17,7 +18,7 @@ import { getIconWithlabel, openExternalLink } from './helpers/sharings';
17
18
  * @param {Object} [props] - Additional props to be passed to the Button component.
18
19
  */
19
20
 
20
- export var OpenSharingLinkButton = function OpenSharingLinkButton(_ref) {
21
+ var OpenSharingLinkButton = function OpenSharingLinkButton(_ref) {
21
22
  var link = _ref.link,
22
23
  _ref$isSharingShortcu = _ref.isSharingShortcutCreated,
23
24
  isSharingShortcutCreated = _ref$isSharingShortcu === void 0 ? false : _ref$isSharingShortcu,
@@ -46,7 +47,9 @@ export var OpenSharingLinkButton = function OpenSharingLinkButton(_ref) {
46
47
  label: label
47
48
  }, props));
48
49
  };
50
+
49
51
  OpenSharingLinkButton.propTypes = {
50
52
  link: PropTypes.string,
51
53
  isSharingShortcutCreated: PropTypes.bool
52
- };
54
+ };
55
+ export default withLocales(OpenSharingLinkButton);
@@ -14,6 +14,7 @@ import React from 'react';
14
14
  import { ExtendableFab } from 'cozy-ui/transpiled/react/Fab';
15
15
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
16
16
  import { getIconWithlabel, openExternalLink } from './helpers/sharings';
17
+ import withLocales from './hoc/withLocales';
17
18
 
18
19
  var makeStyles = function makeStyles(customStyle) {
19
20
  var position = customStyle.position,
@@ -38,7 +39,7 @@ var makeStyles = function makeStyles(customStyle) {
38
39
  */
39
40
 
40
41
 
41
- export var OpenSharingLinkFabButton = function OpenSharingLinkFabButton(_ref) {
42
+ var OpenSharingLinkFabButton = function OpenSharingLinkFabButton(_ref) {
42
43
  var link = _ref.link,
43
44
  _ref$isSharingShortcu = _ref.isSharingShortcutCreated,
44
45
  isSharingShortcutCreated = _ref$isSharingShortcu === void 0 ? false : _ref$isSharingShortcu,
@@ -74,7 +75,9 @@ export var OpenSharingLinkFabButton = function OpenSharingLinkFabButton(_ref) {
74
75
  onClick: handleClick
75
76
  }, rest));
76
77
  };
78
+
77
79
  OpenSharingLinkFabButton.propTypes = {
78
80
  link: PropTypes.string.isRequired,
79
81
  isSharingShortcutCreated: PropTypes.bool
80
- };
82
+ };
83
+ export default withLocales(OpenSharingLinkFabButton);
@@ -5,6 +5,7 @@ import Icon from 'cozy-ui/transpiled/react/Icon';
5
5
  import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon';
6
6
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText';
7
7
  import { getIconWithlabel, openExternalLink } from '../helpers/sharings';
8
+ import { getActionsI18n } from '../hoc/withLocales';
8
9
 
9
10
  var makeComponent = function makeComponent(label, icon) {
10
11
  var Component = /*#__PURE__*/forwardRef(function (props, ref) {
@@ -21,10 +22,12 @@ var makeComponent = function makeComponent(label, icon) {
21
22
  };
22
23
 
23
24
  export var openSharingLink = function openSharingLink(_ref) {
24
- var t = _ref.t,
25
- isSharingShortcutCreated = _ref.isSharingShortcutCreated,
25
+ var isSharingShortcutCreated = _ref.isSharingShortcutCreated,
26
26
  link = _ref.link;
27
27
 
28
+ var _getActionsI18n = getActionsI18n(),
29
+ t = _getActionsI18n.t;
30
+
28
31
  var _getIconWithlabel = getIconWithlabel({
29
32
  link: link,
30
33
  isSharingShortcutCreated: isSharingShortcutCreated,
@@ -142,12 +142,12 @@ export var getIconWithlabel = function getIconWithlabel(_ref4) {
142
142
  if (!isSharingShortcutCreated) {
143
143
  return {
144
144
  icon: CloudPlusOutlinedIcon,
145
- label: t('toolbar.add_to_mine')
145
+ label: t('Share.banner.add_to_mine')
146
146
  };
147
147
  }
148
148
 
149
149
  return {
150
150
  icon: SyncIcon,
151
- label: t('toolbar.menu_sync_cozy')
151
+ label: t('Share.banner.sync_to_mine')
152
152
  };
153
153
  };
@@ -1,9 +1,15 @@
1
1
  import React from 'react';
2
2
  import { I18n, translate } from 'cozy-ui/transpiled/react/providers/I18n';
3
+ import { getI18n } from 'cozy-ui/transpiled/react/providers/I18n/helpers';
3
4
  var locales = {
4
5
  en: require("../../locales/en.json"),
5
6
  fr: require("../../locales/fr.json")
6
7
  };
8
+ export var getActionsI18n = function getActionsI18n() {
9
+ return getI18n(undefined, function (lang) {
10
+ return locales[lang];
11
+ });
12
+ };
7
13
  /**
8
14
  * Adds cozy-sharing translations in the React context
9
15
  *
package/dist/index.js CHANGED
@@ -23,6 +23,6 @@ export { useSharingInfos } from './components/SharingBanner/hooks/useSharingInfo
23
23
  export { ConfirmTrustedRecipientsDialog } from './ConfirmTrustedRecipientsDialog';
24
24
  export { ShareButtonWithRecipients } from './ShareButtonWithRecipients';
25
25
  export { DOCUMENT_TYPE } from './helpers/documentType';
26
- export { OpenSharingLinkButton } from './OpenSharingLinkButton';
27
- export { OpenSharingLinkFabButton } from './OpenSharingLinkFabButton';
26
+ export { default as OpenSharingLinkButton } from './OpenSharingLinkButton';
27
+ export { default as OpenSharingLinkFabButton } from './OpenSharingLinkFabButton';
28
28
  export { openSharingLink } from './actions/openSharingLink';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-sharing",
3
- "version": "16.12.0",
3
+ "version": "16.13.0",
4
4
  "description": "Provides sharing login for React applications.",
5
5
  "main": "dist/index.js",
6
6
  "author": "Cozy",
@@ -74,5 +74,5 @@
74
74
  "sideEffects": [
75
75
  "*.css"
76
76
  ],
77
- "gitHead": "2f410e1905e3b74d32346b2be30377e31516f195"
77
+ "gitHead": "881a7c6ce006d5fb515b2a5264ebf1a6f5a3b6b6"
78
78
  }
@@ -6,6 +6,7 @@ import Icon from 'cozy-ui/transpiled/react/Icon'
6
6
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
7
7
 
8
8
  import { getIconWithlabel, openExternalLink } from './helpers/sharings'
9
+ import withLocales from './hoc/withLocales'
9
10
 
10
11
  /**
11
12
  * OpenSharingLinkButton component renders a Button
@@ -16,7 +17,7 @@ import { getIconWithlabel, openExternalLink } from './helpers/sharings'
16
17
  * @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
17
18
  * @param {Object} [props] - Additional props to be passed to the Button component.
18
19
  */
19
- export const OpenSharingLinkButton = ({
20
+ const OpenSharingLinkButton = ({
20
21
  link,
21
22
  isSharingShortcutCreated = false,
22
23
  ...props
@@ -47,3 +48,5 @@ OpenSharingLinkButton.propTypes = {
47
48
  link: PropTypes.string,
48
49
  isSharingShortcutCreated: PropTypes.bool
49
50
  }
51
+
52
+ export default withLocales(OpenSharingLinkButton)
@@ -5,6 +5,7 @@ import { ExtendableFab } from 'cozy-ui/transpiled/react/Fab'
5
5
  import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
6
6
 
7
7
  import { getIconWithlabel, openExternalLink } from './helpers/sharings'
8
+ import withLocales from './hoc/withLocales'
8
9
 
9
10
  const makeStyles = customStyle => {
10
11
  const { position, right, bottom, ...rest } = customStyle
@@ -25,7 +26,7 @@ const makeStyles = customStyle => {
25
26
  * @param {boolean} [props.isSharingShortcutCreated=false] - Indicates if a sharing shortcut has been created. (default false)
26
27
  * @param {Object} [props] - Additional props to be passed to the ExtendableFab component.
27
28
  */
28
- export const OpenSharingLinkFabButton = ({
29
+ const OpenSharingLinkFabButton = ({
29
30
  link,
30
31
  isSharingShortcutCreated = false,
31
32
  ...props
@@ -61,3 +62,5 @@ OpenSharingLinkFabButton.propTypes = {
61
62
  link: PropTypes.string.isRequired,
62
63
  isSharingShortcutCreated: PropTypes.bool
63
64
  }
65
+
66
+ export default withLocales(OpenSharingLinkFabButton)
@@ -6,6 +6,7 @@ import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
6
6
  import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
7
7
 
8
8
  import { getIconWithlabel, openExternalLink } from '../helpers/sharings'
9
+ import { getActionsI18n } from '../hoc/withLocales'
9
10
 
10
11
  const makeComponent = (label, icon) => {
11
12
  const Component = forwardRef((props, ref) => {
@@ -23,7 +24,8 @@ const makeComponent = (label, icon) => {
23
24
  return Component
24
25
  }
25
26
 
26
- export const openSharingLink = ({ t, isSharingShortcutCreated, link }) => {
27
+ export const openSharingLink = ({ isSharingShortcutCreated, link }) => {
28
+ const { t } = getActionsI18n()
27
29
  const { icon, label } = getIconWithlabel({
28
30
  link,
29
31
  isSharingShortcutCreated,
@@ -75,7 +75,7 @@ export const getIconWithlabel = ({ link, isSharingShortcutCreated, t }) => {
75
75
  return { icon: ToTheCloudIcon, label: t('Share.create-cozy') }
76
76
  }
77
77
  if (!isSharingShortcutCreated) {
78
- return { icon: CloudPlusOutlinedIcon, label: t('toolbar.add_to_mine') }
78
+ return { icon: CloudPlusOutlinedIcon, label: t('Share.banner.add_to_mine') }
79
79
  }
80
- return { icon: SyncIcon, label: t('toolbar.menu_sync_cozy') }
80
+ return { icon: SyncIcon, label: t('Share.banner.sync_to_mine') }
81
81
  }
@@ -1,12 +1,15 @@
1
1
  import React from 'react'
2
2
 
3
3
  import { I18n, translate } from 'cozy-ui/transpiled/react/providers/I18n'
4
+ import { getI18n } from 'cozy-ui/transpiled/react/providers/I18n/helpers'
4
5
 
5
6
  const locales = {
6
7
  en: require(`../../locales/en.json`),
7
8
  fr: require(`../../locales/fr.json`)
8
9
  }
9
10
 
11
+ export const getActionsI18n = () => getI18n(undefined, lang => locales[lang])
12
+
10
13
  /**
11
14
  * Adds cozy-sharing translations in the React context
12
15
  *
package/src/index.jsx CHANGED
@@ -27,6 +27,6 @@ export { useSharingInfos } from './components/SharingBanner/hooks/useSharingInfo
27
27
  export { ConfirmTrustedRecipientsDialog } from './ConfirmTrustedRecipientsDialog'
28
28
  export { ShareButtonWithRecipients } from './ShareButtonWithRecipients'
29
29
  export { DOCUMENT_TYPE } from './helpers/documentType'
30
- export { OpenSharingLinkButton } from './OpenSharingLinkButton'
31
- export { OpenSharingLinkFabButton } from './OpenSharingLinkFabButton'
30
+ export { default as OpenSharingLinkButton } from './OpenSharingLinkButton'
31
+ export { default as OpenSharingLinkFabButton } from './OpenSharingLinkFabButton'
32
32
  export { openSharingLink } from './actions/openSharingLink'