cozy-ui 127.10.1 → 127.12.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/react/Contacts/GroupsSelect/GroupCreation.jsx +95 -0
  4. package/react/Contacts/GroupsSelect/GroupsSelect.jsx +159 -0
  5. package/react/Contacts/GroupsSelect/GroupsSelect.spec.jsx +248 -0
  6. package/react/Contacts/GroupsSelect/GroupsSelectProvider.jsx +39 -0
  7. package/react/Contacts/GroupsSelect/Readme.md +1 -0
  8. package/react/Contacts/GroupsSelect/SelectBox/Control.jsx +36 -0
  9. package/react/Contacts/GroupsSelect/SelectBox/EditGroupName.jsx +52 -0
  10. package/react/Contacts/GroupsSelect/SelectBox/Menu.jsx +26 -0
  11. package/react/Contacts/GroupsSelect/SelectBox/Option.jsx +67 -0
  12. package/react/Contacts/GroupsSelect/SelectBox/SelectContainer.jsx +15 -0
  13. package/react/Contacts/GroupsSelect/SelectBox/styles.styl +2 -0
  14. package/react/Contacts/GroupsSelect/helpers.js +25 -0
  15. package/react/Contacts/GroupsSelect/locales/en.json +21 -0
  16. package/react/Contacts/GroupsSelect/locales/fr.json +21 -0
  17. package/react/Contacts/GroupsSelect/locales/index.jsx +12 -0
  18. package/react/Contacts/GroupsSelect/styles.styl +47 -0
  19. package/react/Contacts/GroupsSelect/useGroupSelect.jsx +88 -0
  20. package/react/Contacts/Header/GroupsSelection.jsx +74 -0
  21. package/react/Contacts/Header/ImportDropdown.jsx +78 -0
  22. package/react/Contacts/Header/Readme.md +40 -0
  23. package/react/Contacts/Header/SearchInput.jsx +19 -0
  24. package/react/Contacts/Header/index.jsx +79 -0
  25. package/react/Contacts/Header/locales/en.json +15 -0
  26. package/react/Contacts/Header/locales/fr.json +15 -0
  27. package/react/Contacts/Header/locales/index.jsx +12 -0
  28. package/react/Contacts/Readme.md +1 -0
  29. package/react/ContactsList/ContactCell.jsx +58 -0
  30. package/react/ContactsList/helpers.js +50 -1
  31. package/react/ContactsList/helpers.spec.js +50 -1
  32. package/react/ContactsList/locales/en.json +3 -1
  33. package/react/ContactsList/locales/fr.json +3 -1
  34. package/react/providers/Selection/Readme.md +28 -0
  35. package/react/providers/Selection/index.jsx +85 -0
  36. package/transpiled/react/Contacts/GroupsSelect/GroupCreation.d.ts +3 -0
  37. package/transpiled/react/Contacts/GroupsSelect/GroupCreation.js +133 -0
  38. package/transpiled/react/Contacts/GroupsSelect/GroupsSelect.d.ts +56 -0
  39. package/transpiled/react/Contacts/GroupsSelect/GroupsSelect.js +181 -0
  40. package/transpiled/react/Contacts/GroupsSelect/GroupsSelect.spec.d.ts +22 -0
  41. package/transpiled/react/Contacts/GroupsSelect/GroupsSelectProvider.d.ts +5 -0
  42. package/transpiled/react/Contacts/GroupsSelect/GroupsSelectProvider.js +38 -0
  43. package/transpiled/react/Contacts/GroupsSelect/SelectBox/Control.d.ts +14 -0
  44. package/transpiled/react/Contacts/GroupsSelect/SelectBox/Control.js +37 -0
  45. package/transpiled/react/Contacts/GroupsSelect/SelectBox/EditGroupName.d.ts +7 -0
  46. package/transpiled/react/Contacts/GroupsSelect/SelectBox/EditGroupName.js +71 -0
  47. package/transpiled/react/Contacts/GroupsSelect/SelectBox/Menu.d.ts +7 -0
  48. package/transpiled/react/Contacts/GroupsSelect/SelectBox/Menu.js +34 -0
  49. package/transpiled/react/Contacts/GroupsSelect/SelectBox/Option.d.ts +18 -0
  50. package/transpiled/react/Contacts/GroupsSelect/SelectBox/Option.js +66 -0
  51. package/transpiled/react/Contacts/GroupsSelect/SelectBox/SelectContainer.d.ts +2 -0
  52. package/transpiled/react/Contacts/GroupsSelect/SelectBox/SelectContainer.js +12 -0
  53. package/transpiled/react/Contacts/GroupsSelect/helpers.d.ts +9 -0
  54. package/transpiled/react/Contacts/GroupsSelect/helpers.js +30 -0
  55. package/transpiled/react/Contacts/GroupsSelect/locales/index.d.ts +6 -0
  56. package/transpiled/react/Contacts/GroupsSelect/locales/index.js +49 -0
  57. package/transpiled/react/Contacts/GroupsSelect/useGroupSelect.d.ts +11 -0
  58. package/transpiled/react/Contacts/GroupsSelect/useGroupSelect.js +179 -0
  59. package/transpiled/react/Contacts/Header/GroupsSelection.d.ts +7 -0
  60. package/transpiled/react/Contacts/Header/GroupsSelection.js +84 -0
  61. package/transpiled/react/Contacts/Header/ImportDropdown.d.ts +4 -0
  62. package/transpiled/react/Contacts/Header/ImportDropdown.js +88 -0
  63. package/transpiled/react/Contacts/Header/SearchInput.d.ts +4 -0
  64. package/transpiled/react/Contacts/Header/SearchInput.js +24 -0
  65. package/transpiled/react/Contacts/Header/index.d.ts +26 -0
  66. package/transpiled/react/Contacts/Header/index.js +72 -0
  67. package/transpiled/react/Contacts/Header/locales/index.d.ts +6 -0
  68. package/transpiled/react/Contacts/Header/locales/index.js +37 -0
  69. package/transpiled/react/ContactsList/ContactCell.d.ts +8 -0
  70. package/transpiled/react/ContactsList/ContactCell.js +68 -0
  71. package/transpiled/react/ContactsList/helpers.d.ts +1 -0
  72. package/transpiled/react/ContactsList/helpers.js +51 -1
  73. package/transpiled/react/ContactsList/locales/withContactsListLocales.js +6 -2
  74. package/transpiled/react/providers/Selection/index.d.ts +6 -0
  75. package/transpiled/react/providers/Selection/index.js +99 -0
  76. package/transpiled/react/stylesheet.css +1 -1
@@ -0,0 +1,179 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+ import get from 'lodash/get';
10
+ import { useSelectedGroup } from "cozy-ui/transpiled/react/Contacts/GroupsSelect/GroupsSelectProvider";
11
+ import { isExistingGroup } from "cozy-ui/transpiled/react/Contacts/GroupsSelect/helpers";
12
+ import { locales } from "cozy-ui/transpiled/react/Contacts/GroupsSelect/locales";
13
+ import { useAlert } from "cozy-ui/transpiled/react/providers/Alert";
14
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
15
+
16
+ var useGroupsSelect = function useGroupsSelect(_ref) {
17
+ var allGroups = _ref.allGroups,
18
+ onGroupCreated = _ref.onGroupCreated,
19
+ client = _ref.client,
20
+ onGroupCreate = _ref.onGroupCreate,
21
+ onGroupUpdate = _ref.onGroupUpdate;
22
+
23
+ var _useSelectedGroup = useSelectedGroup(),
24
+ selectedGroup = _useSelectedGroup.selectedGroup,
25
+ setSelectedGroup = _useSelectedGroup.setSelectedGroup;
26
+
27
+ var _useAlert = useAlert(),
28
+ showAlert = _useAlert.showAlert;
29
+
30
+ useExtendI18n(locales);
31
+
32
+ var _useI18n = useI18n(),
33
+ t = _useI18n.t;
34
+
35
+ var createGroupSelf = /*#__PURE__*/function () {
36
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(group) {
37
+ var _yield$onGroupCreate, createdGroup;
38
+
39
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
40
+ while (1) {
41
+ switch (_context.prev = _context.next) {
42
+ case 0:
43
+ if (group.name) {
44
+ _context.next = 2;
45
+ break;
46
+ }
47
+
48
+ return _context.abrupt("return");
49
+
50
+ case 2:
51
+ if (!isExistingGroup(allGroups, group)) {
52
+ _context.next = 4;
53
+ break;
54
+ }
55
+
56
+ return _context.abrupt("return", showAlert({
57
+ severity: 'error',
58
+ message: t('Contacts.GroupsSelect.already_exists', {
59
+ name: group.name
60
+ })
61
+ }));
62
+
63
+ case 4:
64
+ _context.prev = 4;
65
+ _context.next = 7;
66
+ return onGroupCreate(client, group);
67
+
68
+ case 7:
69
+ _yield$onGroupCreate = _context.sent;
70
+ createdGroup = _yield$onGroupCreate.data;
71
+
72
+ if (onGroupCreated) {
73
+ onGroupCreated(createdGroup);
74
+ }
75
+
76
+ return _context.abrupt("return", showAlert({
77
+ severity: 'success',
78
+ message: t('Contacts.GroupsSelect.created.success')
79
+ }));
80
+
81
+ case 13:
82
+ _context.prev = 13;
83
+ _context.t0 = _context["catch"](4);
84
+ return _context.abrupt("return", showAlert({
85
+ severity: 'error',
86
+ message: t('Contacts.GroupsSelect.created.error')
87
+ }));
88
+
89
+ case 16:
90
+ case "end":
91
+ return _context.stop();
92
+ }
93
+ }
94
+ }, _callee, null, [[4, 13]]);
95
+ }));
96
+
97
+ return function createGroupSelf(_x) {
98
+ return _ref2.apply(this, arguments);
99
+ };
100
+ }();
101
+
102
+ var renameGroupSelf = /*#__PURE__*/function () {
103
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(groupId, newName) {
104
+ var group, allOtherGroups, isRenamedGroupSelected, _yield$onGroupUpdate, data;
105
+
106
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
107
+ while (1) {
108
+ switch (_context2.prev = _context2.next) {
109
+ case 0:
110
+ group = allGroups.find(function (group) {
111
+ return group.id === groupId;
112
+ });
113
+ allOtherGroups = allGroups.filter(function (group) {
114
+ return group.id !== groupId;
115
+ });
116
+ isRenamedGroupSelected = get(group, '_id') === get(selectedGroup, '_id');
117
+
118
+ if (!isExistingGroup(allOtherGroups, {
119
+ name: newName
120
+ })) {
121
+ _context2.next = 5;
122
+ break;
123
+ }
124
+
125
+ return _context2.abrupt("return", showAlert({
126
+ severity: 'error',
127
+ message: t('Contacts.GroupsSelect.already_exists', {
128
+ name: newName
129
+ })
130
+ }));
131
+
132
+ case 5:
133
+ _context2.prev = 5;
134
+ _context2.next = 8;
135
+ return onGroupUpdate(client, _objectSpread(_objectSpread({}, group), {}, {
136
+ name: newName
137
+ }));
138
+
139
+ case 8:
140
+ _yield$onGroupUpdate = _context2.sent;
141
+ data = _yield$onGroupUpdate.data;
142
+
143
+ if (isRenamedGroupSelected) {
144
+ setSelectedGroup(data);
145
+ }
146
+
147
+ return _context2.abrupt("return", showAlert({
148
+ severity: 'success',
149
+ message: t('Contacts.GroupsSelect.renamed.success')
150
+ }));
151
+
152
+ case 14:
153
+ _context2.prev = 14;
154
+ _context2.t0 = _context2["catch"](5);
155
+ return _context2.abrupt("return", showAlert({
156
+ severity: 'error',
157
+ message: t('Contacts.GroupsSelect.renamed.error')
158
+ }));
159
+
160
+ case 17:
161
+ case "end":
162
+ return _context2.stop();
163
+ }
164
+ }
165
+ }, _callee2, null, [[5, 14]]);
166
+ }));
167
+
168
+ return function renameGroupSelf(_x2, _x3) {
169
+ return _ref3.apply(this, arguments);
170
+ };
171
+ }();
172
+
173
+ return {
174
+ createGroup: createGroupSelf,
175
+ renameGroup: renameGroupSelf
176
+ };
177
+ };
178
+
179
+ export default useGroupsSelect;
@@ -0,0 +1,7 @@
1
+ export default GroupsSelection;
2
+ declare function GroupsSelection({ allGroups, onGroupCreate, onGroupUpdate, onGroupDelete }: {
3
+ allGroups: any;
4
+ onGroupCreate: any;
5
+ onGroupUpdate: any;
6
+ onGroupDelete: any;
7
+ }): JSX.Element;
@@ -0,0 +1,84 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
8
+ import React from 'react';
9
+ import { locales } from "cozy-ui/transpiled/react/Contacts/Header/locales";
10
+ import { ControlDefault } from "cozy-ui/transpiled/react/SelectBox";
11
+ import { useBreakpoints } from "cozy-ui/transpiled/react/providers/Breakpoints";
12
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
13
+ import GroupsSelect from "cozy-ui/transpiled/react/Contacts/GroupsSelect/GroupsSelect";
14
+ import { useSelectedGroup } from "cozy-ui/transpiled/react/Contacts/GroupsSelect/GroupsSelectProvider";
15
+ import { translatedDefaultSelectedGroup } from "cozy-ui/transpiled/react/Contacts/GroupsSelect/helpers";
16
+
17
+ var setGroupsSelectOptions = function setGroupsSelectOptions(allGroups, defaultSelectedGroup) {
18
+ return allGroups.length > 0 ? [defaultSelectedGroup].concat(allGroups) : allGroups;
19
+ };
20
+
21
+ var useGroupsSelectCustomStyles = function useGroupsSelectCustomStyles() {
22
+ var _useBreakpoints = useBreakpoints(),
23
+ isMobile = _useBreakpoints.isMobile;
24
+
25
+ return {
26
+ container: function container(base) {
27
+ return _objectSpread(_objectSpread({}, base), {}, {
28
+ width: isMobile ? '100%' : '50%'
29
+ });
30
+ },
31
+ noOptionsMessage: function noOptionsMessage(base) {
32
+ return _objectSpread(_objectSpread({}, base), {}, {
33
+ textAlign: 'left'
34
+ });
35
+ }
36
+ };
37
+ };
38
+
39
+ var ControlDefaultWithTestId = function ControlDefaultWithTestId(_ref) {
40
+ var props = _extends({}, _ref);
41
+
42
+ return /*#__PURE__*/React.createElement(ControlDefault, _extends({}, props, {
43
+ innerProps: _objectSpread(_objectSpread({}, props.innerProps), {}, {
44
+ 'data-testid': 'selectBox-controlDefault',
45
+ className: 'u-bdrs-4'
46
+ })
47
+ }));
48
+ };
49
+
50
+ var GroupsSelection = function GroupsSelection(_ref2) {
51
+ var allGroups = _ref2.allGroups,
52
+ onGroupCreate = _ref2.onGroupCreate,
53
+ onGroupUpdate = _ref2.onGroupUpdate,
54
+ onGroupDelete = _ref2.onGroupDelete;
55
+ useExtendI18n(locales);
56
+
57
+ var _useI18n = useI18n(),
58
+ t = _useI18n.t;
59
+
60
+ var _useSelectedGroup = useSelectedGroup(),
61
+ selectedGroup = _useSelectedGroup.selectedGroup,
62
+ setSelectedGroup = _useSelectedGroup.setSelectedGroup;
63
+
64
+ var groupsSelectOptions = setGroupsSelectOptions(allGroups, translatedDefaultSelectedGroup(t));
65
+ var groupsSelectCustomStyles = useGroupsSelectCustomStyles();
66
+ return /*#__PURE__*/React.createElement(GroupsSelect, {
67
+ allGroups: groupsSelectOptions,
68
+ value: selectedGroup,
69
+ noOptionsMessage: function noOptionsMessage() {
70
+ return t('Contacts.Header.filter.no-group');
71
+ },
72
+ styles: groupsSelectCustomStyles,
73
+ closeMenuOnSelect: true,
74
+ components: {
75
+ Control: ControlDefaultWithTestId
76
+ },
77
+ onChange: setSelectedGroup,
78
+ onGroupCreate: onGroupCreate,
79
+ onGroupUpdate: onGroupUpdate,
80
+ onGroupDelete: onGroupDelete
81
+ });
82
+ };
83
+
84
+ export default GroupsSelection;
@@ -0,0 +1,4 @@
1
+ export default ImportDropdown;
2
+ declare function ImportDropdown({ onContactImport }: {
3
+ onContactImport: any;
4
+ }): JSX.Element;
@@ -0,0 +1,88 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useState, useRef } from 'react';
3
+ import { useClient, generateWebLink } from 'cozy-client';
4
+ import { CONTACTS_DOCTYPE } from 'cozy-client/dist/models/contact';
5
+ import { locales } from "cozy-ui/transpiled/react/Contacts/Header/locales";
6
+ import AppIcon from "cozy-ui/transpiled/react/AppIcon";
7
+ import AppLinker from "cozy-ui/transpiled/react/AppLinker";
8
+ import Button from "cozy-ui/transpiled/react/Buttons";
9
+ import Icon from "cozy-ui/transpiled/react/Icon";
10
+ import BottomIcon from "cozy-ui/transpiled/react/Icons/Bottom";
11
+ import TeamIcon from "cozy-ui/transpiled/react/Icons/Team";
12
+ import Link from "cozy-ui/transpiled/react/Link";
13
+ import ActionMenu, { ActionMenuItem } from "cozy-ui/transpiled/react/deprecated/ActionMenu";
14
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
15
+
16
+ var ImportDropdown = function ImportDropdown(_ref) {
17
+ var onContactImport = _ref.onContactImport;
18
+ useExtendI18n(locales);
19
+
20
+ var _useI18n = useI18n(),
21
+ t = _useI18n.t;
22
+
23
+ var client = useClient();
24
+ var anchorRef = useRef();
25
+
26
+ var _useState = useState(false),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ showMenu = _useState2[0],
29
+ setShowMenu = _useState2[1];
30
+
31
+ var storeURL = generateWebLink({
32
+ cozyUrl: client.getStackClient().uri,
33
+ hash: "discover/?type=konnector&doctype=".concat(CONTACTS_DOCTYPE),
34
+ pathname: '/',
35
+ slug: 'store',
36
+ subDomainType: client.getInstanceOptions().subdomain
37
+ });
38
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
39
+ ref: anchorRef,
40
+ variant: "secondary",
41
+ label: t('Contacts.Header.import.title'),
42
+ endIcon: /*#__PURE__*/React.createElement(Icon, {
43
+ icon: BottomIcon
44
+ }),
45
+ fullWidth: true,
46
+ onClick: function onClick() {
47
+ return setShowMenu(function (v) {
48
+ return !v;
49
+ });
50
+ }
51
+ }), showMenu && /*#__PURE__*/React.createElement(ActionMenu, {
52
+ anchorElRef: anchorRef,
53
+ popperOptions: {
54
+ placement: 'bottom-end'
55
+ },
56
+ onClose: function onClose() {
57
+ return setShowMenu(false);
58
+ }
59
+ }, /*#__PURE__*/React.createElement(ActionMenuItem, {
60
+ left: /*#__PURE__*/React.createElement(Icon, {
61
+ icon: TeamIcon
62
+ }),
63
+ onClick: onContactImport
64
+ }, t('Contacts.Header.import.vcard')), /*#__PURE__*/React.createElement(AppLinker, {
65
+ app: {
66
+ slug: 'store'
67
+ },
68
+ href: storeURL
69
+ }, function (_ref2) {
70
+ var onClick = _ref2.onClick,
71
+ href = _ref2.href;
72
+ return /*#__PURE__*/React.createElement(ActionMenuItem, {
73
+ left: /*#__PURE__*/React.createElement(AppIcon, {
74
+ app: "store",
75
+ className: "u-h-1 u-w-1"
76
+ }),
77
+ onClick: onClick
78
+ }, /*#__PURE__*/React.createElement(Link, {
79
+ className: "u-p-0",
80
+ href: href,
81
+ style: {
82
+ color: 'var(--primaryTextColor)'
83
+ }
84
+ }, t('Contacts.Header.import.store')));
85
+ })));
86
+ };
87
+
88
+ export default ImportDropdown;
@@ -0,0 +1,4 @@
1
+ export default SearchInput;
2
+ declare function SearchInput({ setSearchValue }: {
3
+ setSearchValue: any;
4
+ }): JSX.Element;
@@ -0,0 +1,24 @@
1
+ import debounce from 'lodash/debounce';
2
+ import React, { useMemo } from 'react';
3
+ import SearchBar from "cozy-ui/transpiled/react/SearchBar";
4
+
5
+ var SearchInput = function SearchInput(_ref) {
6
+ var setSearchValue = _ref.setSearchValue;
7
+ var delayedSetSearchValue = useMemo(function () {
8
+ return debounce(function (searchValue) {
9
+ return setSearchValue(searchValue);
10
+ }, 375);
11
+ }, [setSearchValue]);
12
+
13
+ var handleOnChange = function handleOnChange(ev) {
14
+ delayedSetSearchValue(ev.target.value);
15
+ };
16
+
17
+ return /*#__PURE__*/React.createElement(SearchBar, {
18
+ size: "small",
19
+ elevation: 0,
20
+ onChange: handleOnChange
21
+ });
22
+ };
23
+
24
+ export default SearchInput;
@@ -0,0 +1,26 @@
1
+ export default Header;
2
+ declare function Header({ allGroups, onContactCreate, onContactImport, onSearch, onGroupCreate, onGroupDelete, onGroupUpdate }: {
3
+ allGroups: any;
4
+ onContactCreate: any;
5
+ onContactImport: any;
6
+ onSearch: any;
7
+ onGroupCreate: any;
8
+ onGroupDelete: any;
9
+ onGroupUpdate: any;
10
+ }): JSX.Element;
11
+ declare namespace Header {
12
+ namespace propTypes {
13
+ const allGroups: PropTypes.Requireable<any[]>;
14
+ const onContactCreate: PropTypes.Requireable<(...args: any[]) => any>;
15
+ const onContactImport: PropTypes.Requireable<(...args: any[]) => any>;
16
+ const onSearch: PropTypes.Requireable<(...args: any[]) => any>;
17
+ const onGroupCreate: PropTypes.Requireable<(...args: any[]) => any>;
18
+ const onGroupUpdate: PropTypes.Requireable<(...args: any[]) => any>;
19
+ const onGroupDelete: PropTypes.Requireable<(...args: any[]) => any>;
20
+ }
21
+ namespace defaultProps {
22
+ const allGroups_1: never[];
23
+ export { allGroups_1 as allGroups };
24
+ }
25
+ }
26
+ import PropTypes from "prop-types";
@@ -0,0 +1,72 @@
1
+ import cx from 'classnames';
2
+ import PropTypes from 'prop-types';
3
+ import React from 'react';
4
+ import GroupsSelection from "cozy-ui/transpiled/react/Contacts/Header/GroupsSelection";
5
+ import ImportDropdown from "cozy-ui/transpiled/react/Contacts/Header/ImportDropdown";
6
+ import SearchInput from "cozy-ui/transpiled/react/Contacts/Header/SearchInput";
7
+ import { locales } from "cozy-ui/transpiled/react/Contacts/Header/locales";
8
+ import Button from "cozy-ui/transpiled/react/Buttons";
9
+ import Icon from "cozy-ui/transpiled/react/Icon";
10
+ import PersonAddIcon from "cozy-ui/transpiled/react/Icons/PersonAdd";
11
+ import { useBreakpoints } from "cozy-ui/transpiled/react/providers/Breakpoints";
12
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
13
+
14
+ var Header = function Header(_ref) {
15
+ var allGroups = _ref.allGroups,
16
+ onContactCreate = _ref.onContactCreate,
17
+ onContactImport = _ref.onContactImport,
18
+ onSearch = _ref.onSearch,
19
+ onGroupCreate = _ref.onGroupCreate,
20
+ onGroupDelete = _ref.onGroupDelete,
21
+ onGroupUpdate = _ref.onGroupUpdate;
22
+ useExtendI18n(locales);
23
+
24
+ var _useI18n = useI18n(),
25
+ t = _useI18n.t;
26
+
27
+ var _useBreakpoints = useBreakpoints(),
28
+ isMobile = _useBreakpoints.isMobile;
29
+
30
+ return /*#__PURE__*/React.createElement("div", {
31
+ className: !isMobile ? 'u-flex u-flex-justify-between' : undefined
32
+ }, /*#__PURE__*/React.createElement("div", {
33
+ className: cx('u-flex u-flex-items-center u-w-auto-s u-w-5 u-maw-6', {
34
+ 'u-mb-1': isMobile,
35
+ 'u-mr-1': !isMobile
36
+ })
37
+ }, /*#__PURE__*/React.createElement(Button, {
38
+ className: "u-mr-half",
39
+ variant: "ghost",
40
+ startIcon: /*#__PURE__*/React.createElement(Icon, {
41
+ icon: PersonAddIcon
42
+ }),
43
+ label: t('Contacts.Header.create'),
44
+ fullWidth: true,
45
+ onClick: onContactCreate
46
+ }), /*#__PURE__*/React.createElement(ImportDropdown, {
47
+ onContactImport: onContactImport
48
+ })), /*#__PURE__*/React.createElement("div", {
49
+ className: !isMobile ? 'u-flex u-flex-items-center u-flex-justify-end u-flex-grow-1 u-maw-7' : undefined
50
+ }, /*#__PURE__*/React.createElement(GroupsSelection, {
51
+ allGroups: allGroups,
52
+ onGroupCreate: onGroupCreate,
53
+ onGroupUpdate: onGroupUpdate,
54
+ onGroupDelete: onGroupDelete
55
+ }), /*#__PURE__*/React.createElement(SearchInput, {
56
+ setSearchValue: onSearch
57
+ })));
58
+ };
59
+
60
+ Header.propTypes = {
61
+ allGroups: PropTypes.array,
62
+ onContactCreate: PropTypes.func,
63
+ onContactImport: PropTypes.func,
64
+ onSearch: PropTypes.func,
65
+ onGroupCreate: PropTypes.func,
66
+ onGroupUpdate: PropTypes.func,
67
+ onGroupDelete: PropTypes.func
68
+ };
69
+ Header.defaultProps = {
70
+ allGroups: []
71
+ };
72
+ export default Header;
@@ -0,0 +1,6 @@
1
+ export namespace locales {
2
+ export { en };
3
+ export { fr };
4
+ }
5
+ import en from "./en.json";
6
+ import fr from "./fr.json";
@@ -0,0 +1,37 @@
1
+ var en = {
2
+ Contacts: {
3
+ Header: {
4
+ create: "Create",
5
+ filter: {
6
+ "no-group": "Create contact groups to facilitate filing and sharing!"
7
+ },
8
+ "import": {
9
+ title: "Import",
10
+ store: "From other sources",
11
+ vcard: "From a vCard file"
12
+ }
13
+ }
14
+ }
15
+ };
16
+ var fr = {
17
+ Contacts: {
18
+ Header: {
19
+ create: "Cr\xE9er",
20
+ filter: {
21
+ "no-group": "Cr\xE9er des groupes de contacts pour faciliter leur classement et le partage !"
22
+ },
23
+ "import": {
24
+ title: "Importer",
25
+ store: "Depuis d'autres sources",
26
+ vcard: "Depuis un fichier vCard"
27
+ }
28
+ }
29
+ }
30
+ }; // import { getI18n } from '../../../providers/I18n/helpers'
31
+ // import withOnlyLocales from '../../../providers/I18n/withOnlyLocales'
32
+
33
+ export var locales = {
34
+ en: en,
35
+ fr: fr
36
+ }; // export const getOwnI18n = () => getI18n(undefined, lang => locales[lang])
37
+ // export default withOnlyLocales(locales)
@@ -0,0 +1,8 @@
1
+ declare var _default: React.MemoExoticComponent<({ row, column, cell, actions }: {
2
+ row: any;
3
+ column: any;
4
+ cell: any;
5
+ actions: any;
6
+ }) => any>;
7
+ export default _default;
8
+ import React from "react";
@@ -0,0 +1,68 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useRef, useState } from 'react';
3
+ import ContactIdentity from "cozy-ui/transpiled/react/ContactsList/Contacts/ContactIdentity";
4
+ import { locales } from "cozy-ui/transpiled/react/ContactsList/locales/withContactsListLocales";
5
+ import ActionsMenu from "cozy-ui/transpiled/react/ActionsMenu";
6
+ import Icon from "cozy-ui/transpiled/react/Icon";
7
+ import IconButton from "cozy-ui/transpiled/react/IconButton";
8
+ import DotsIcon from "cozy-ui/transpiled/react/Icons/Dots";
9
+ import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
10
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
11
+
12
+ var Cell = function Cell(_ref) {
13
+ var row = _ref.row,
14
+ column = _ref.column,
15
+ cell = _ref.cell,
16
+ actions = _ref.actions;
17
+
18
+ var _useState = useState(false),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ showActions = _useState2[0],
21
+ setShowActions = _useState2[1];
22
+
23
+ useExtendI18n(locales);
24
+
25
+ var _useI18n = useI18n(),
26
+ t = _useI18n.t;
27
+
28
+ var actionsRef = useRef();
29
+
30
+ if (column.id === 'fullname') {
31
+ return /*#__PURE__*/React.createElement(ContactIdentity, {
32
+ contact: row,
33
+ noWrapper: true
34
+ });
35
+ }
36
+
37
+ if (column.id === 'actions') {
38
+ if (!actions) {
39
+ return null;
40
+ }
41
+
42
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(IconButton, {
43
+ ref: actionsRef,
44
+ "arial-label": t('menu'),
45
+ onClick: function onClick() {
46
+ return setShowActions(true);
47
+ }
48
+ }, /*#__PURE__*/React.createElement(Icon, {
49
+ icon: DotsIcon
50
+ }))), showActions && /*#__PURE__*/React.createElement(ActionsMenu, {
51
+ open: true,
52
+ ref: actionsRef,
53
+ docs: [row],
54
+ actions: actions,
55
+ anchorOrigin: {
56
+ vertical: 'bottom',
57
+ horizontal: 'right'
58
+ },
59
+ onClose: function onClose() {
60
+ return setShowActions(false);
61
+ }
62
+ }));
63
+ }
64
+
65
+ return cell;
66
+ };
67
+
68
+ export default /*#__PURE__*/React.memo(Cell);
@@ -3,6 +3,7 @@ export function sortLastNameFirst(contact: any, comparedContact: any): any;
3
3
  export function sortContacts(contacts: any): any;
4
4
  export function categorizeContacts(contacts: object[], t: Function): CategorizedContactsResult;
5
5
  export function sortHeaders(categorized: CategorizedContactsResult, t: Function): string[];
6
+ export function makeGroupLabelsAndCounts(contacts: array, t: any): object;
6
7
  export type CategorizedContactsResult = {
7
8
  [x: string]: Object;
8
9
  };