cozy-ui 113.6.0 → 113.7.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
@@ -1,3 +1,10 @@
1
+ # [113.7.0](https://github.com/cozy/cozy-ui/compare/v113.6.0...v113.7.0) (2024-11-27)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Actions:** Add copyToClipboard and editAttribute ([a7e91a6](https://github.com/cozy/cozy-ui/commit/a7e91a6))
7
+
1
8
  # [113.6.0](https://github.com/cozy/cozy-ui/compare/v113.5.0...v113.6.0) (2024-11-27)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "113.6.0",
3
+ "version": "113.7.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -0,0 +1,55 @@
1
+ import React, { forwardRef } from 'react'
2
+
3
+ import { getActionsI18n } from './locales/withActionsLocales'
4
+ import Icon from '../../Icon'
5
+ import CopyIcon from '../../Icons/Copy'
6
+ import ListItemIcon from '../../ListItemIcon'
7
+ import ListItemText from '../../ListItemText'
8
+ import ActionsMenuItem from '../ActionsMenuItem'
9
+
10
+ const makeComponent = (label, icon) => {
11
+ const Component = forwardRef((props, ref) => {
12
+ return (
13
+ <ActionsMenuItem {...props} ref={ref}>
14
+ <ListItemIcon>
15
+ <Icon icon={icon} />
16
+ </ListItemIcon>
17
+ <ListItemText primary={label} />
18
+ </ActionsMenuItem>
19
+ )
20
+ })
21
+
22
+ Component.displayName = 'copyToClipboard'
23
+
24
+ return Component
25
+ }
26
+
27
+ export const copyToClipboard = () => {
28
+ const { t } = getActionsI18n()
29
+ const icon = CopyIcon
30
+ const label = t('copyToClipboard.copy')
31
+
32
+ return {
33
+ name: 'copyToClipboard',
34
+ icon,
35
+ label,
36
+ Component: makeComponent(label, icon),
37
+ action: async (_, { showAlert, copyValue }) => {
38
+ if (!copyValue) return false
39
+ try {
40
+ await navigator.clipboard.writeText(copyValue)
41
+ showAlert({
42
+ message: t('copyToClipboard.success'),
43
+ severity: 'success',
44
+ variant: 'filled'
45
+ })
46
+ } catch (error) {
47
+ showAlert({
48
+ message: t('copyToClipboard.error'),
49
+ severity: 'error',
50
+ variant: 'filled'
51
+ })
52
+ }
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,41 @@
1
+ import React, { forwardRef } from 'react'
2
+
3
+ import { getActionsI18n } from './locales/withActionsLocales'
4
+ import Icon from '../../Icon'
5
+ import TextInfoIcon from '../../Icons/TextInfo'
6
+ import ListItemIcon from '../../ListItemIcon'
7
+ import ListItemText from '../../ListItemText'
8
+ import ActionsMenuItem from '../ActionsMenuItem'
9
+
10
+ const makeComponent = (label, icon) => {
11
+ const Component = forwardRef((props, ref) => {
12
+ return (
13
+ <ActionsMenuItem {...props} ref={ref}>
14
+ <ListItemIcon>
15
+ <Icon icon={icon} />
16
+ </ListItemIcon>
17
+ <ListItemText primary={label} />
18
+ </ActionsMenuItem>
19
+ )
20
+ })
21
+
22
+ Component.displayName = 'editAttribute'
23
+
24
+ return Component
25
+ }
26
+
27
+ export const editAttribute = () => {
28
+ const { t } = getActionsI18n()
29
+ const icon = TextInfoIcon
30
+ const label = t('editAttribute')
31
+
32
+ return {
33
+ name: 'editAttribute',
34
+ icon,
35
+ label,
36
+ Component: makeComponent(label, icon),
37
+ action: (docs, { editAttributeCallback }) => {
38
+ editAttributeCallback(docs)
39
+ }
40
+ }
41
+ }
@@ -7,4 +7,6 @@ export { emailTo } from './emailTo'
7
7
  export { print } from './print'
8
8
  export { viewInContacts } from './viewInContacts'
9
9
  export { viewInDrive } from './viewInDrive'
10
+ export { copyToClipboard } from './copyToClipboard'
11
+ export { editAttribute } from './editAttribute'
10
12
  export { others } from './others'
@@ -6,5 +6,11 @@
6
6
  "smsTo": "Send a message",
7
7
  "print": "Print",
8
8
  "others": "Others",
9
+ "editAttribute": "Edit attribute",
10
+ "copyToClipboard": {
11
+ "copy": "Copy",
12
+ "success": "Copied to clipboard",
13
+ "error": "Cannot copy to clipboard"
14
+ },
9
15
  "call": "Call"
10
16
  }
@@ -6,5 +6,11 @@
6
6
  "smsTo": "Envoyer un message",
7
7
  "print": "Imprimer",
8
8
  "others": "Autres",
9
+ "editAttribute": "Editer l'attribut",
10
+ "copyToClipboard": {
11
+ "copy": "Copier",
12
+ "success": "Copié dans le presse-papier",
13
+ "error": "Impossible de copier dans le presse-papier"
14
+ },
9
15
  "call": "Appeler"
10
16
  }
@@ -0,0 +1,91 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import React, { forwardRef } from 'react';
5
+ import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
6
+ import Icon from "cozy-ui/transpiled/react/Icon";
7
+ import CopyIcon from "cozy-ui/transpiled/react/Icons/Copy";
8
+ import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
9
+ import ListItemText from "cozy-ui/transpiled/react/ListItemText";
10
+ import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
11
+
12
+ var makeComponent = function makeComponent(label, icon) {
13
+ var Component = /*#__PURE__*/forwardRef(function (props, ref) {
14
+ return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
15
+ ref: ref
16
+ }), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
17
+ icon: icon
18
+ })), /*#__PURE__*/React.createElement(ListItemText, {
19
+ primary: label
20
+ }));
21
+ });
22
+ Component.displayName = 'copyToClipboard';
23
+ return Component;
24
+ };
25
+
26
+ export var copyToClipboard = function copyToClipboard() {
27
+ var _getActionsI18n = getActionsI18n(),
28
+ t = _getActionsI18n.t;
29
+
30
+ var icon = CopyIcon;
31
+ var label = t('copyToClipboard.copy');
32
+ return {
33
+ name: 'copyToClipboard',
34
+ icon: icon,
35
+ label: label,
36
+ Component: makeComponent(label, icon),
37
+ action: function () {
38
+ var _action = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_, _ref) {
39
+ var showAlert, copyValue;
40
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
41
+ while (1) {
42
+ switch (_context.prev = _context.next) {
43
+ case 0:
44
+ showAlert = _ref.showAlert, copyValue = _ref.copyValue;
45
+
46
+ if (copyValue) {
47
+ _context.next = 3;
48
+ break;
49
+ }
50
+
51
+ return _context.abrupt("return", false);
52
+
53
+ case 3:
54
+ _context.prev = 3;
55
+ _context.next = 6;
56
+ return navigator.clipboard.writeText(copyValue);
57
+
58
+ case 6:
59
+ showAlert({
60
+ message: t('copyToClipboard.success'),
61
+ severity: 'success',
62
+ variant: 'filled'
63
+ });
64
+ _context.next = 12;
65
+ break;
66
+
67
+ case 9:
68
+ _context.prev = 9;
69
+ _context.t0 = _context["catch"](3);
70
+ showAlert({
71
+ message: t('copyToClipboard.error'),
72
+ severity: 'error',
73
+ variant: 'filled'
74
+ });
75
+
76
+ case 12:
77
+ case "end":
78
+ return _context.stop();
79
+ }
80
+ }
81
+ }, _callee, null, [[3, 9]]);
82
+ }));
83
+
84
+ function action(_x, _x2) {
85
+ return _action.apply(this, arguments);
86
+ }
87
+
88
+ return action;
89
+ }()
90
+ };
91
+ };
@@ -0,0 +1,40 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
4
+ import Icon from "cozy-ui/transpiled/react/Icon";
5
+ import TextInfoIcon from "cozy-ui/transpiled/react/Icons/TextInfo";
6
+ import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
7
+ import ListItemText from "cozy-ui/transpiled/react/ListItemText";
8
+ import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
9
+
10
+ var makeComponent = function makeComponent(label, icon) {
11
+ var Component = /*#__PURE__*/forwardRef(function (props, ref) {
12
+ return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
13
+ ref: ref
14
+ }), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
15
+ icon: icon
16
+ })), /*#__PURE__*/React.createElement(ListItemText, {
17
+ primary: label
18
+ }));
19
+ });
20
+ Component.displayName = 'editAttribute';
21
+ return Component;
22
+ };
23
+
24
+ export var editAttribute = function editAttribute() {
25
+ var _getActionsI18n = getActionsI18n(),
26
+ t = _getActionsI18n.t;
27
+
28
+ var icon = TextInfoIcon;
29
+ var label = t('editAttribute');
30
+ return {
31
+ name: 'editAttribute',
32
+ icon: icon,
33
+ label: label,
34
+ Component: makeComponent(label, icon),
35
+ action: function action(docs, _ref) {
36
+ var editAttributeCallback = _ref.editAttributeCallback;
37
+ editAttributeCallback(docs);
38
+ }
39
+ };
40
+ };
@@ -7,4 +7,6 @@ export { emailTo } from './emailTo';
7
7
  export { print } from './print';
8
8
  export { viewInContacts } from './viewInContacts';
9
9
  export { viewInDrive } from './viewInDrive';
10
+ export { copyToClipboard } from './copyToClipboard';
11
+ export { editAttribute } from './editAttribute';
10
12
  export { others } from './others';
@@ -6,6 +6,12 @@ var en = {
6
6
  smsTo: "Send a message",
7
7
  print: "Print",
8
8
  others: "Others",
9
+ editAttribute: "Edit attribute",
10
+ copyToClipboard: {
11
+ copy: "Copy",
12
+ success: "Copied to clipboard",
13
+ error: "Cannot copy to clipboard"
14
+ },
9
15
  call: "Call"
10
16
  };
11
17
  var fr = {
@@ -16,6 +22,12 @@ var fr = {
16
22
  smsTo: "Envoyer un message",
17
23
  print: "Imprimer",
18
24
  others: "Autres",
25
+ editAttribute: "Editer l'attribut",
26
+ copyToClipboard: {
27
+ copy: "Copier",
28
+ success: "Copi\xE9 dans le presse-papier",
29
+ error: "Impossible de copier dans le presse-papier"
30
+ },
19
31
  call: "Appeler"
20
32
  };
21
33
  import { getI18n } from "cozy-ui/transpiled/react/providers/I18n/helpers";