intelicoreact 0.3.21 → 0.3.22

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.
@@ -29,7 +29,7 @@ var _defaultIcons = require("./partial/defaultIcons");
29
29
 
30
30
  require("./UserContacts.scss");
31
31
 
32
- var _excluded = ["className", "email", "phone", "EmalIcon", "PhoneIcon", "isFirstPhone", "maxWidth", "isUseCommaSeparator", "generalizingWord", "isNotRenderGeneralizingWord", "Lng", "otherContacts"];
32
+ var _excluded = ["className", "email", "phone", "EmalIcon", "PhoneIcon", "isFirstPhone", "maxWidth", "isUseCommaSeparator", "generalizingWord", "isNotRenderGeneralizingWord", "Lng", "otherContacts", "isOtherTogetherMainContacts"];
33
33
 
34
34
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
35
 
@@ -38,7 +38,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
38
38
  var RC = 'user-contacts';
39
39
 
40
40
  var UserContacts = function UserContacts(props) {
41
- var _otherContacts$map, _mainRef$current;
41
+ var _otherContacts$map, _mainRef$current, _otherContacts$map2;
42
42
 
43
43
  var _ref = props || {},
44
44
  className = _ref.className,
@@ -60,6 +60,8 @@ var UserContacts = function UserContacts(props) {
60
60
  } : _ref$Lng,
61
61
  _ref$otherContacts = _ref.otherContacts,
62
62
  otherContacts = _ref$otherContacts === void 0 ? [] : _ref$otherContacts,
63
+ _ref$isOtherTogetherM = _ref.isOtherTogetherMainContacts,
64
+ isOtherTogetherMainContacts = _ref$isOtherTogetherM === void 0 ? false : _ref$isOtherTogetherM,
63
65
  mainContacts = (0, _objectWithoutProperties2.default)(_ref, _excluded);
64
66
 
65
67
  var PRIMARY_TEXT = Lng('Primary'); //? В случае появления новых типов контактов добавлять их сюда по аналогии,
@@ -84,11 +86,12 @@ var UserContacts = function UserContacts(props) {
84
86
  var mainContactsStructure = Object.keys(mainContacts).reduce(function (acc, key) {
85
87
  return mainContacts[key] && key in mainContactsDescriptions ? [].concat((0, _toConsumableArray2.default)(acc), [getContact(key)]) : acc;
86
88
  }, []);
87
- mainContactsStructure = [].concat((0, _toConsumableArray2.default)(mainContactsStructure), (0, _toConsumableArray2.default)(Array.isArray(otherContacts) ? otherContacts === null || otherContacts === void 0 ? void 0 : (_otherContacts$map = otherContacts.map) === null || _otherContacts$map === void 0 ? void 0 : _otherContacts$map.call(otherContacts, function (contact) {
89
+ mainContactsStructure = isOtherTogetherMainContacts ? [].concat((0, _toConsumableArray2.default)(mainContactsStructure), (0, _toConsumableArray2.default)(Array.isArray(otherContacts) ? otherContacts === null || otherContacts === void 0 ? void 0 : (_otherContacts$map = otherContacts.map) === null || _otherContacts$map === void 0 ? void 0 : _otherContacts$map.call(otherContacts, function (contact) {
88
90
  return Lng(contact);
89
- }) : []));
90
- var typeContactCount = mainContactsStructure.length;
91
- var isContact = !!typeContactCount;
91
+ }) : [])) : mainContactsStructure;
92
+ var mainContactsCount = mainContactsStructure.length;
93
+ var otherContactsCount = (otherContacts === null || otherContacts === void 0 ? void 0 : otherContacts.length) || 0;
94
+ var isContact = !!mainContactsCount;
92
95
  var mainRef = (0, _react.useRef)(null);
93
96
  var firstRef = (0, _react.useRef)(null);
94
97
  var secondRef = (0, _react.useRef)(null);
@@ -104,10 +107,19 @@ var UserContacts = function UserContacts(props) {
104
107
  isRunTask = _useState4[0],
105
108
  setIsRunTask = _useState4[1];
106
109
 
107
- var getSeparator = function getSeparator(isNotUseACount) {
108
- if (isNotUseACount) return isUseCommaSeparator ? ', ' : ' ';
109
- if (typeContactCount-- > 1) return isUseCommaSeparator ? ', ' : ' ';
110
- return '';
110
+ var getSeparator = function getSeparator(type) {
111
+ var separator = isUseCommaSeparator ? ', ' : ' ';
112
+
113
+ switch (type) {
114
+ case 'main':
115
+ return mainContactsCount-- > 1 ? separator : '';
116
+
117
+ case 'other':
118
+ return otherContactsCount-- > 1 ? separator : '';
119
+
120
+ default:
121
+ return separator;
122
+ }
111
123
  };
112
124
 
113
125
  var firstKey = isFirstPhone ? 'phone' : 'email';
@@ -166,18 +178,20 @@ var UserContacts = function UserContacts(props) {
166
178
  target: "_blank",
167
179
  rel: "noreferrer",
168
180
  className: getClasses(true)
169
- }, isIconMode ? getIcon(firstKey) : "".concat(props[firstKey]).concat(props[secondKey] || isContact ? getSeparator(true) : '')), !!props[secondKey] && /*#__PURE__*/_react.default.createElement("a", {
181
+ }, isIconMode ? getIcon(firstKey) : "".concat(props[firstKey]).concat(props[secondKey] || isContact ? getSeparator() : '')), !!props[secondKey] && /*#__PURE__*/_react.default.createElement("a", {
170
182
  ref: secondRef,
171
183
  href: "".concat(getProtocol(secondKey)).concat(props[secondKey].trim()),
172
184
  target: "_blank",
173
185
  rel: "noreferrer",
174
186
  className: getClasses()
175
- }, isIconMode ? getIcon(secondKey) : "".concat(props[secondKey]).concat(isContact ? getSeparator(true) : '')), isContact && /*#__PURE__*/_react.default.createElement("span", {
187
+ }, isIconMode ? getIcon(secondKey) : "".concat(props[secondKey]).concat(isContact ? getSeparator() : '')), isContact && /*#__PURE__*/_react.default.createElement("span", {
176
188
  ref: contactsRef,
177
189
  className: (0, _classnames.default)('no-wrap', "".concat(RC, "__contacts"))
178
190
  }, mainContactsStructure.map(function (contact) {
179
- return "".concat(contact).concat(getSeparator());
180
- }), generalizingWord && !isNotRenderGeneralizingWord ? " ".concat(Lng(generalizingWord)) : ''));
191
+ return "".concat(contact).concat(getSeparator('main'));
192
+ }), generalizingWord && !isNotRenderGeneralizingWord ? " ".concat(Lng(generalizingWord)) : '', !!otherContacts && !!(otherContacts !== null && otherContacts !== void 0 && otherContacts.length) && !isOtherTogetherMainContacts ? getSeparator() : '', !!otherContacts && !!(otherContacts !== null && otherContacts !== void 0 && otherContacts.length) && !isOtherTogetherMainContacts ? otherContacts === null || otherContacts === void 0 ? void 0 : (_otherContacts$map2 = otherContacts.map) === null || _otherContacts$map2 === void 0 ? void 0 : _otherContacts$map2.call(otherContacts, function (contact) {
193
+ return "".concat(contact).concat(getSeparator('other'));
194
+ }) : null));
181
195
  };
182
196
 
183
197
  var _default = UserContacts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [