cozy-ui 127.11.0 → 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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/react/Contacts/GroupsSelect/GroupCreation.jsx +95 -0
- package/react/Contacts/GroupsSelect/GroupsSelect.jsx +159 -0
- package/react/Contacts/GroupsSelect/GroupsSelect.spec.jsx +248 -0
- package/react/Contacts/GroupsSelect/GroupsSelectProvider.jsx +39 -0
- package/react/Contacts/GroupsSelect/Readme.md +1 -0
- package/react/Contacts/GroupsSelect/SelectBox/Control.jsx +36 -0
- package/react/Contacts/GroupsSelect/SelectBox/EditGroupName.jsx +52 -0
- package/react/Contacts/GroupsSelect/SelectBox/Menu.jsx +26 -0
- package/react/Contacts/GroupsSelect/SelectBox/Option.jsx +67 -0
- package/react/Contacts/GroupsSelect/SelectBox/SelectContainer.jsx +15 -0
- package/react/Contacts/GroupsSelect/SelectBox/styles.styl +2 -0
- package/react/Contacts/GroupsSelect/helpers.js +25 -0
- package/react/Contacts/GroupsSelect/locales/en.json +21 -0
- package/react/Contacts/GroupsSelect/locales/fr.json +21 -0
- package/react/Contacts/GroupsSelect/locales/index.jsx +12 -0
- package/react/Contacts/GroupsSelect/styles.styl +47 -0
- package/react/Contacts/GroupsSelect/useGroupSelect.jsx +88 -0
- package/react/Contacts/Header/GroupsSelection.jsx +74 -0
- package/react/Contacts/Header/ImportDropdown.jsx +78 -0
- package/react/Contacts/Header/Readme.md +40 -0
- package/react/Contacts/Header/SearchInput.jsx +19 -0
- package/react/Contacts/Header/index.jsx +79 -0
- package/react/Contacts/Header/locales/en.json +15 -0
- package/react/Contacts/Header/locales/fr.json +15 -0
- package/react/Contacts/Header/locales/index.jsx +12 -0
- package/react/Contacts/Readme.md +1 -0
- package/transpiled/react/Contacts/GroupsSelect/GroupCreation.d.ts +3 -0
- package/transpiled/react/Contacts/GroupsSelect/GroupCreation.js +133 -0
- package/transpiled/react/Contacts/GroupsSelect/GroupsSelect.d.ts +56 -0
- package/transpiled/react/Contacts/GroupsSelect/GroupsSelect.js +181 -0
- package/transpiled/react/Contacts/GroupsSelect/GroupsSelect.spec.d.ts +22 -0
- package/transpiled/react/Contacts/GroupsSelect/GroupsSelectProvider.d.ts +5 -0
- package/transpiled/react/Contacts/GroupsSelect/GroupsSelectProvider.js +38 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/Control.d.ts +14 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/Control.js +37 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/EditGroupName.d.ts +7 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/EditGroupName.js +71 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/Menu.d.ts +7 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/Menu.js +34 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/Option.d.ts +18 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/Option.js +66 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/SelectContainer.d.ts +2 -0
- package/transpiled/react/Contacts/GroupsSelect/SelectBox/SelectContainer.js +12 -0
- package/transpiled/react/Contacts/GroupsSelect/helpers.d.ts +9 -0
- package/transpiled/react/Contacts/GroupsSelect/helpers.js +30 -0
- package/transpiled/react/Contacts/GroupsSelect/locales/index.d.ts +6 -0
- package/transpiled/react/Contacts/GroupsSelect/locales/index.js +49 -0
- package/transpiled/react/Contacts/GroupsSelect/useGroupSelect.d.ts +11 -0
- package/transpiled/react/Contacts/GroupsSelect/useGroupSelect.js +179 -0
- package/transpiled/react/Contacts/Header/GroupsSelection.d.ts +7 -0
- package/transpiled/react/Contacts/Header/GroupsSelection.js +84 -0
- package/transpiled/react/Contacts/Header/ImportDropdown.d.ts +4 -0
- package/transpiled/react/Contacts/Header/ImportDropdown.js +88 -0
- package/transpiled/react/Contacts/Header/SearchInput.d.ts +4 -0
- package/transpiled/react/Contacts/Header/SearchInput.js +24 -0
- package/transpiled/react/Contacts/Header/index.d.ts +26 -0
- package/transpiled/react/Contacts/Header/index.js +72 -0
- package/transpiled/react/Contacts/Header/locales/index.d.ts +6 -0
- package/transpiled/react/Contacts/Header/locales/index.js +37 -0
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import EditGroupName from "cozy-ui/transpiled/react/Contacts/GroupsSelect/SelectBox/EditGroupName";
|
|
5
|
+
import { ActionsOption, Option as DefaultOption } from "cozy-ui/transpiled/react/SelectBox";
|
|
6
|
+
|
|
7
|
+
var Option = function Option(props) {
|
|
8
|
+
var _props$data = props.data,
|
|
9
|
+
groupName = _props$data.name,
|
|
10
|
+
groupId = _props$data.id,
|
|
11
|
+
withNoAction = _props$data.withNoAction;
|
|
12
|
+
var _props$selectProps = props.selectProps,
|
|
13
|
+
editedGroupId = _props$selectProps.editedGroupId,
|
|
14
|
+
setEditedGroupId = _props$selectProps.setEditedGroupId,
|
|
15
|
+
deleteGroup = _props$selectProps.deleteGroup,
|
|
16
|
+
renameGroup = _props$selectProps.renameGroup,
|
|
17
|
+
withCheckbox = _props$selectProps.withCheckbox;
|
|
18
|
+
|
|
19
|
+
if (editedGroupId === groupId) {
|
|
20
|
+
return /*#__PURE__*/React.createElement(EditGroupName, {
|
|
21
|
+
groupId: groupId,
|
|
22
|
+
groupName: groupName,
|
|
23
|
+
setEditedGroupId: setEditedGroupId,
|
|
24
|
+
renameGroup: renameGroup
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (withNoAction) {
|
|
29
|
+
return /*#__PURE__*/React.createElement(DefaultOption, props);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return /*#__PURE__*/React.createElement(ActionsOption, _extends({}, props, {
|
|
33
|
+
withCheckbox: withCheckbox,
|
|
34
|
+
actions: [{
|
|
35
|
+
icon: 'pen',
|
|
36
|
+
onClick: function onClick(_ref) {
|
|
37
|
+
var data = _ref.data;
|
|
38
|
+
return setEditedGroupId(data.id);
|
|
39
|
+
},
|
|
40
|
+
iconProps: {
|
|
41
|
+
'data-testid': "ActionsOption_".concat(props.children, "-icon_pen")
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
icon: 'trash',
|
|
45
|
+
onClick: function onClick(_ref2) {
|
|
46
|
+
var data = _ref2.data;
|
|
47
|
+
return deleteGroup(data);
|
|
48
|
+
}
|
|
49
|
+
}]
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Option.propTypes = {
|
|
54
|
+
selectProps: PropTypes.shape({
|
|
55
|
+
editedGroupId: PropTypes.string.isRequired,
|
|
56
|
+
deleteGroup: PropTypes.func.isRequired,
|
|
57
|
+
setEditedGroupId: PropTypes.func.isRequired,
|
|
58
|
+
withCheckbox: PropTypes.bool
|
|
59
|
+
}),
|
|
60
|
+
data: PropTypes.shape({
|
|
61
|
+
name: PropTypes.string.isRequired,
|
|
62
|
+
id: PropTypes.string,
|
|
63
|
+
withNoAction: PropTypes.bool
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
export default Option;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { components } from "cozy-ui/transpiled/react/SelectBox";
|
|
5
|
+
|
|
6
|
+
var SelectContainer = function SelectContainer(props) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(components.SelectContainer, _extends({}, props, {
|
|
8
|
+
className: classNames(props.className, 'react-select__custom__container')
|
|
9
|
+
}));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default SelectContainer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function isExistingGroup(groupsAlreadyCreated: any, groupToCreate: any): boolean;
|
|
2
|
+
export namespace defaultSelectedGroup {
|
|
3
|
+
const name: string;
|
|
4
|
+
const withNoAction: boolean;
|
|
5
|
+
}
|
|
6
|
+
export function translatedDefaultSelectedGroup(t: Function): {
|
|
7
|
+
name: any;
|
|
8
|
+
withNoAction: boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
export var isExistingGroup = function isExistingGroup(groupsAlreadyCreated, groupToCreate) {
|
|
8
|
+
var isNameAlreadyUsed = groupsAlreadyCreated.find(function (group) {
|
|
9
|
+
return group.name.toLowerCase() === groupToCreate.name.toLowerCase();
|
|
10
|
+
}) !== undefined;
|
|
11
|
+
return isNameAlreadyUsed;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Returns the group defined as default in the group filter
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var defaultSelectedGroup = {
|
|
18
|
+
name: 'Contacts.GroupsSelect.filter.all-groups',
|
|
19
|
+
withNoAction: true
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Returns the translated group defined as default in the group filter
|
|
23
|
+
* @param {function} t - Translate
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export var translatedDefaultSelectedGroup = function translatedDefaultSelectedGroup(t) {
|
|
27
|
+
return _objectSpread(_objectSpread({}, defaultSelectedGroup), {}, {
|
|
28
|
+
name: t(defaultSelectedGroup.name)
|
|
29
|
+
});
|
|
30
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var en = {
|
|
2
|
+
Contacts: {
|
|
3
|
+
GroupsSelect: {
|
|
4
|
+
create: "Create a group",
|
|
5
|
+
name: "Name of the group",
|
|
6
|
+
already_exists: "The group %{name} already exists.",
|
|
7
|
+
manage: "Groups",
|
|
8
|
+
filter: {
|
|
9
|
+
"all-groups": "All groups"
|
|
10
|
+
},
|
|
11
|
+
created: {
|
|
12
|
+
success: "The group has been created correctly.",
|
|
13
|
+
error: "The group has not been created."
|
|
14
|
+
},
|
|
15
|
+
renamed: {
|
|
16
|
+
success: "The group has been renamed correctly.",
|
|
17
|
+
error: "The group has not been renamed."
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var fr = {
|
|
23
|
+
Contacts: {
|
|
24
|
+
GroupsSelect: {
|
|
25
|
+
create: "Cr\xE9er un groupe",
|
|
26
|
+
name: "Nom du groupe",
|
|
27
|
+
already_exists: "Le groupe %{name} existe d\xE9j\xE0.",
|
|
28
|
+
manage: "Groupes",
|
|
29
|
+
filter: {
|
|
30
|
+
"all-groups": "Tous les groupes"
|
|
31
|
+
},
|
|
32
|
+
created: {
|
|
33
|
+
success: "Le groupe a bien \xE9t\xE9 cr\xE9\xE9.",
|
|
34
|
+
error: "Le groupe n'a pas \xE9t\xE9 cr\xE9\xE9."
|
|
35
|
+
},
|
|
36
|
+
renamed: {
|
|
37
|
+
success: "Le groupe a bien \xE9t\xE9 renomm\xE9.",
|
|
38
|
+
error: "Le groupe n'a pas \xE9t\xE9 renomm\xE9."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}; // import { getI18n } from '../../../providers/I18n/helpers'
|
|
43
|
+
// import withOnlyLocales from '../../../providers/I18n/withOnlyLocales'
|
|
44
|
+
|
|
45
|
+
export var locales = {
|
|
46
|
+
en: en,
|
|
47
|
+
fr: fr
|
|
48
|
+
}; // export const getOwnI18n = () => getI18n(undefined, lang => locales[lang])
|
|
49
|
+
// export default withOnlyLocales(locales)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default useGroupsSelect;
|
|
2
|
+
declare function useGroupsSelect({ allGroups, onGroupCreated, client, onGroupCreate, onGroupUpdate }: {
|
|
3
|
+
allGroups: any;
|
|
4
|
+
onGroupCreated: any;
|
|
5
|
+
client: any;
|
|
6
|
+
onGroupCreate: any;
|
|
7
|
+
onGroupUpdate: any;
|
|
8
|
+
}): {
|
|
9
|
+
createGroup: (group: any) => Promise<void>;
|
|
10
|
+
renameGroup: (groupId: any, newName: any) => Promise<void>;
|
|
11
|
+
};
|
|
@@ -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,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,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,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";
|