cozy-ui 127.11.0 → 127.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +14 -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 +7 -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 +7 -0
  28. package/react/Contacts/Readme.md +1 -0
  29. package/react/ContactsList/ContactCell.jsx +1 -1
  30. package/react/ContactsList/Contacts/ContactIdentity.jsx +5 -1
  31. package/react/ContactsList/ContactsList.jsx +3 -1
  32. package/react/ContactsList/helpers.js +11 -10
  33. package/react/ContactsList/helpers.spec.js +11 -2
  34. package/react/ContactsList/locales/en.json +6 -4
  35. package/react/ContactsList/locales/fr.json +7 -5
  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 +46 -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 +34 -0
  69. package/transpiled/react/ContactsList/ContactCell.js +1 -1
  70. package/transpiled/react/ContactsList/Contacts/ContactIdentity.js +1 -1
  71. package/transpiled/react/ContactsList/ContactsList.js +4 -1
  72. package/transpiled/react/ContactsList/helpers.js +10 -10
  73. package/transpiled/react/ContactsList/locales/withContactsListLocales.js +12 -8
  74. package/transpiled/react/stylesheet.css +1 -1
@@ -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,34 @@
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
+ };
31
+ export var locales = {
32
+ en: en,
33
+ fr: fr
34
+ };
@@ -41,7 +41,7 @@ var Cell = function Cell(_ref) {
41
41
 
42
42
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(IconButton, {
43
43
  ref: actionsRef,
44
- "arial-label": t('menu'),
44
+ "arial-label": t('ContactsList.menu'),
45
45
  onClick: function onClick() {
46
46
  return setShowActions(true);
47
47
  }
@@ -28,7 +28,7 @@ var MyselfMarker = function MyselfMarker() {
28
28
 
29
29
  return /*#__PURE__*/React.createElement("span", {
30
30
  className: "".concat(styles['contact-myself'])
31
- }, "(", t('me'), ")");
31
+ }, "(", t('ContactsList.me'), ")");
32
32
  };
33
33
 
34
34
  var ContactIdentity = function ContactIdentity(_ref) {
@@ -5,17 +5,20 @@ import React from 'react';
5
5
  import ContactRow from "cozy-ui/transpiled/react/ContactsList/ContactRow";
6
6
  import { sortContacts, categorizeContacts, sortHeaders } from "cozy-ui/transpiled/react/ContactsList/helpers";
7
7
  import withContactsListLocales from "cozy-ui/transpiled/react/ContactsList/locales/withContactsListLocales";
8
+ import { locales } from "cozy-ui/transpiled/react/ContactsList/locales/withContactsListLocales";
8
9
  import List from "cozy-ui/transpiled/react/List";
9
10
  import ListSubheader from "cozy-ui/transpiled/react/ListSubheader";
10
11
  import { Table } from "cozy-ui/transpiled/react/deprecated/Table";
11
12
  import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
12
- import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
13
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
13
14
 
14
15
  var ContactsList = function ContactsList(_ref) {
15
16
  var contacts = _ref.contacts,
16
17
  onItemClick = _ref.onItemClick,
17
18
  rest = _objectWithoutProperties(_ref, _excluded);
18
19
 
20
+ useExtendI18n(locales);
21
+
19
22
  var _useI18n = useI18n(),
20
23
  t = _useI18n.t;
21
24
 
@@ -25,9 +25,9 @@ export var sortContacts = function sortContacts(contacts) {
25
25
  */
26
26
 
27
27
  var makeHeader = function makeHeader(contact, t) {
28
- if (contact.me) return t('me');
28
+ if (contact.me) return t('ContactsList.me');
29
29
  var name = buildLastNameFirst(contact);
30
- return name[0] || t('empty');
30
+ return name[0] || t('ContactsList.empty');
31
31
  };
32
32
  /**
33
33
  * Build header for a contact (first letter of indexes.byFamilyNameGivenNameEmailCozyUrl)
@@ -40,8 +40,8 @@ var makeHeader = function makeHeader(contact, t) {
40
40
  var makeHeaderForIndexedContacts = function makeHeaderForIndexedContacts(contact, t) {
41
41
  var _contact$cozyMetadata;
42
42
 
43
- if (contact.me) return t('me');
44
- if ((_contact$cozyMetadata = contact.cozyMetadata) !== null && _contact$cozyMetadata !== void 0 && _contact$cozyMetadata.favorite) return t('favorite');
43
+ if (contact.me) return t('ContactsList.me');
44
+ if ((_contact$cozyMetadata = contact.cozyMetadata) !== null && _contact$cozyMetadata !== void 0 && _contact$cozyMetadata.favorite) return t('ContactsList.favorite');
45
45
  var index = get(contact, 'indexes.byFamilyNameGivenNameEmailCozyUrl', '');
46
46
  var hasIndex = index !== null && index.length > 0;
47
47
 
@@ -50,7 +50,7 @@ var makeHeaderForIndexedContacts = function makeHeaderForIndexedContacts(contact
50
50
  return firstLetterWithoutAccent;
51
51
  }
52
52
 
53
- return t('empty');
53
+ return t('ContactsList.empty');
54
54
  };
55
55
  /**
56
56
  * @typedef {Object.<string, Object>} CategorizedContactsResult
@@ -83,7 +83,7 @@ export var categorizeContacts = function categorizeContacts(contacts, t) {
83
83
  export var sortHeaders = function sortHeaders(categorized, t) {
84
84
  var headers = Object.keys(categorized);
85
85
  var notEmptyAndMyselfHeaders = headers.filter(function (header) {
86
- return header !== t('empty') && header !== t('me');
86
+ return header !== t('ContactsList.empty') && header !== t('ContactsList.me');
87
87
  });
88
88
  var notEmptyAndMyselfSorted = notEmptyAndMyselfHeaders.slice().sort();
89
89
 
@@ -93,12 +93,12 @@ export var sortHeaders = function sortHeaders(categorized, t) {
93
93
 
94
94
  var headersSorted = [];
95
95
 
96
- if (headers.includes(t('me'))) {
97
- headersSorted.push(t('me'));
96
+ if (headers.includes(t('ContactsList.me'))) {
97
+ headersSorted.push(t('ContactsList.me'));
98
98
  }
99
99
 
100
- if (headers.includes(t('empty'))) {
101
- headersSorted.push(t('empty'));
100
+ if (headers.includes(t('ContactsList.empty'))) {
101
+ headersSorted.push(t('ContactsList.empty'));
102
102
  }
103
103
 
104
104
  return headersSorted.concat(notEmptyAndMyselfSorted);
@@ -1,14 +1,18 @@
1
1
  var en = {
2
- empty: "EMPTY",
3
- me: "me",
4
- favorite: "favorites",
5
- menu: "Menu"
2
+ ContactsList: {
3
+ empty: "EMPTY",
4
+ me: "me",
5
+ favorite: "favorites",
6
+ menu: "Menu"
7
+ }
6
8
  };
7
9
  var fr = {
8
- empty: "VIDE",
9
- me: "moi",
10
- favorite: "favoris",
11
- menu: "Menu"
10
+ ContactsList: {
11
+ empty: "VIDE",
12
+ me: "moi",
13
+ favorite: "favoris",
14
+ menu: "Menu"
15
+ }
12
16
  };
13
17
  import withOnlyLocales from "cozy-ui/transpiled/react/providers/I18n/withOnlyLocales";
14
18
  export var locales = {