intelicoreact 0.3.17 → 0.3.18
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
@@ -13,6 +13,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
13
13
|
|
|
14
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
15
|
|
|
16
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
+
|
|
18
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
19
|
+
|
|
20
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
21
|
+
|
|
16
22
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
23
|
|
|
18
24
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -23,9 +29,11 @@ var _defaultIcons = require("./partial/defaultIcons");
|
|
|
23
29
|
|
|
24
30
|
require("./UserContacts.scss");
|
|
25
31
|
|
|
32
|
+
var _excluded = ["email", "phone", "EmalIcon", "PhoneIcon", "maxWidth", "className", "isUseCommaSeparator", "isNotRenderGeneralizingWord", "Lng", "otherContacts"];
|
|
33
|
+
|
|
26
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); }
|
|
27
35
|
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
36
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
37
|
|
|
30
38
|
var RC = 'user-contacts';
|
|
31
39
|
|
|
@@ -35,26 +43,49 @@ var UserContacts = function UserContacts(props) {
|
|
|
35
43
|
var _ref = props || {},
|
|
36
44
|
email = _ref.email,
|
|
37
45
|
phone = _ref.phone,
|
|
38
|
-
contactType = _ref.contactType,
|
|
39
|
-
_ref$useCommaSeparato = _ref.useCommaSeparator,
|
|
40
|
-
useCommaSeparator = _ref$useCommaSeparato === void 0 ? true : _ref$useCommaSeparato,
|
|
41
|
-
_ref$isDisputeContact = _ref.isDisputeContact,
|
|
42
|
-
isDisputeContact = _ref$isDisputeContact === void 0 ? null : _ref$isDisputeContact,
|
|
43
|
-
_ref$isSalesContact = _ref.isSalesContact,
|
|
44
|
-
isSalesContact = _ref$isSalesContact === void 0 ? null : _ref$isSalesContact,
|
|
45
|
-
_ref$isAccountingCont = _ref.isAccountingContact,
|
|
46
|
-
isAccountingContact = _ref$isAccountingCont === void 0 ? null : _ref$isAccountingCont,
|
|
47
46
|
EmalIcon = _ref.EmalIcon,
|
|
48
47
|
PhoneIcon = _ref.PhoneIcon,
|
|
49
48
|
maxWidth = _ref.maxWidth,
|
|
49
|
+
className = _ref.className,
|
|
50
|
+
_ref$isUseCommaSepara = _ref.isUseCommaSeparator,
|
|
51
|
+
isUseCommaSeparator = _ref$isUseCommaSepara === void 0 ? true : _ref$isUseCommaSepara,
|
|
52
|
+
_ref$isNotRenderGener = _ref.isNotRenderGeneralizingWord,
|
|
53
|
+
isNotRenderGeneralizingWord = _ref$isNotRenderGener === void 0 ? false : _ref$isNotRenderGener,
|
|
50
54
|
_ref$Lng = _ref.Lng,
|
|
51
55
|
Lng = _ref$Lng === void 0 ? function (value) {
|
|
52
56
|
return value;
|
|
53
57
|
} : _ref$Lng,
|
|
54
|
-
|
|
58
|
+
_ref$otherContacts = _ref.otherContacts,
|
|
59
|
+
otherContacts = _ref$otherContacts === void 0 ? [] : _ref$otherContacts,
|
|
60
|
+
mainContacts = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
61
|
+
|
|
62
|
+
var PRIMARY_TEXT = Lng('Primary'); //? В случае появления новых типов контактов добавлять их сюда по аналогии,
|
|
63
|
+
//? или на крайний случай в массив otherContacts (otherContacts - массив строк)
|
|
64
|
+
|
|
65
|
+
var mainContactsDescriptions = {
|
|
66
|
+
isDisputeContact: 'Dispute',
|
|
67
|
+
isSalesContact: 'Sales',
|
|
68
|
+
isAccountingContact: 'Accounting',
|
|
69
|
+
isBusinessContact: 'Business',
|
|
70
|
+
isTechnicalContact: 'Technical'
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
var getContact = function getContact(key) {
|
|
74
|
+
var _ref2 = (0, _typeof2.default)(mainContacts[key]) === 'object' ? mainContacts[key] : {},
|
|
75
|
+
prefix = _ref2.prefix,
|
|
76
|
+
postfix = _ref2.postfix;
|
|
77
|
+
|
|
78
|
+
return "".concat(prefix ? Lng(prefix.toString()) + ' ' : '').concat(Lng(mainContactsDescriptions[key])).concat(postfix ? ' ' + Lng(postfix.toString()) : '');
|
|
79
|
+
};
|
|
55
80
|
|
|
56
|
-
var
|
|
57
|
-
|
|
81
|
+
var mainContactsStructure = Object.keys(mainContacts).reduce(function (acc, key) {
|
|
82
|
+
return mainContacts[key] && key in mainContactsDescriptions ? [].concat((0, _toConsumableArray2.default)(acc), [getContact(key)]) : acc;
|
|
83
|
+
}, []);
|
|
84
|
+
mainContactsStructure = [].concat((0, _toConsumableArray2.default)(mainContactsStructure), (0, _toConsumableArray2.default)(otherContacts.map(function (contact) {
|
|
85
|
+
return Lng(contact);
|
|
86
|
+
})));
|
|
87
|
+
var typeContactCount = mainContactsStructure.length;
|
|
88
|
+
var isContact = !!typeContactCount;
|
|
58
89
|
var mainRef = (0, _react.useRef)(null);
|
|
59
90
|
var emailRef = (0, _react.useRef)(null);
|
|
60
91
|
var phoneRef = (0, _react.useRef)(null);
|
|
@@ -75,8 +106,10 @@ var UserContacts = function UserContacts(props) {
|
|
|
75
106
|
isRunTask = _useState6[0],
|
|
76
107
|
setIsRunTask = _useState6[1];
|
|
77
108
|
|
|
78
|
-
var
|
|
79
|
-
|
|
109
|
+
var getSeparator = function getSeparator(isNotUseACount) {
|
|
110
|
+
if (isNotUseACount) return isUseCommaSeparator ? ', ' : ' ';
|
|
111
|
+
if (typeContactCount-- > 1) return isUseCommaSeparator ? ', ' : ' ';
|
|
112
|
+
return '';
|
|
80
113
|
};
|
|
81
114
|
|
|
82
115
|
var EIcon = EmalIcon || /*#__PURE__*/_react.default.createElement(_defaultIcons.DefaultEmalIcon, null);
|
|
@@ -104,7 +137,7 @@ var UserContacts = function UserContacts(props) {
|
|
|
104
137
|
setIsUseEmailIcon(false);
|
|
105
138
|
setIsUsePhoneIcon(false);
|
|
106
139
|
};
|
|
107
|
-
}, [email, phone,
|
|
140
|
+
}, [email, phone, JSON.stringify(mainContactsStructure), +maxWidth, mainRef === null || mainRef === void 0 ? void 0 : (_mainRef$current = mainRef.current) === null || _mainRef$current === void 0 ? void 0 : _mainRef$current.clientWidth]);
|
|
108
141
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
109
142
|
ref: mainRef,
|
|
110
143
|
className: (0, _classnames.default)('j4', RC, className)
|
|
@@ -114,18 +147,18 @@ var UserContacts = function UserContacts(props) {
|
|
|
114
147
|
target: "_blank",
|
|
115
148
|
rel: "noreferrer",
|
|
116
149
|
className: (0, _classnames.default)('no-wrap', "".concat(RC, "__email"), (0, _defineProperty2.default)({}, "".concat(RC, "__email_icon-mode"), isUseEmailIcon))
|
|
117
|
-
}, isUseEmailIcon ? EIcon : "".concat(email).concat(phone
|
|
150
|
+
}, isUseEmailIcon ? EIcon : "".concat(email).concat(phone || isContact ? getSeparator(true) : '')), !!phone && /*#__PURE__*/_react.default.createElement("a", {
|
|
118
151
|
ref: phoneRef,
|
|
119
152
|
href: "tel:+".concat((0, _fieldValueFormatters.formatOnlyNumbers)(phone).trim()),
|
|
120
153
|
target: "_blank",
|
|
121
154
|
rel: "noreferrer",
|
|
122
155
|
className: (0, _classnames.default)('no-wrap', "".concat(RC, "__phone"), (0, _defineProperty2.default)({}, "".concat(RC, "__phone_icon-mode"), isUsePhonelIcon))
|
|
123
|
-
}, isUsePhonelIcon ? PIcon : "".concat(phone).concat(
|
|
124
|
-
className: (0, _classnames.default)('no-wrap', "".concat(RC, "__contactType"))
|
|
125
|
-
}, contactType), isContact && /*#__PURE__*/_react.default.createElement("span", {
|
|
156
|
+
}, isUsePhonelIcon ? PIcon : "".concat(phone).concat(isContact ? getSeparator(true) : '')), isContact && /*#__PURE__*/_react.default.createElement("span", {
|
|
126
157
|
ref: contactsRef,
|
|
127
158
|
className: (0, _classnames.default)('no-wrap', "".concat(RC, "__contacts"))
|
|
128
|
-
},
|
|
159
|
+
}, mainContactsStructure.map(function (contact) {
|
|
160
|
+
return "".concat(contact).concat(getSeparator());
|
|
161
|
+
}), !isNotRenderGeneralizingWord ? " ".concat(Lng('contact')) : null));
|
|
129
162
|
};
|
|
130
163
|
|
|
131
164
|
var _default = UserContacts;
|
|
@@ -56,7 +56,7 @@ var WidgetWithSwitchableRows = function WidgetWithSwitchableRows(props) {
|
|
|
56
56
|
className: (0, _classnames.default)("".concat(RC, "__thead"))
|
|
57
57
|
}, preperedColumns.map(function (field) {
|
|
58
58
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
59
|
-
key: field.key,
|
|
59
|
+
key: "thead-".concat(field.key),
|
|
60
60
|
className: (0, _classnames.default)("".concat(RC, "__thead-cell"), field.theadCellClassName, field.columnClassName, (0, _defineProperty2.default)({}, "".concat(RC, "__thead-cell_reqiured"), field.isRequired)),
|
|
61
61
|
"data-key": field.key
|
|
62
62
|
}, field.label);
|
|
@@ -64,10 +64,12 @@ var WidgetWithSwitchableRows = function WidgetWithSwitchableRows(props) {
|
|
|
64
64
|
className: (0, _classnames.default)("".concat(RC, "__table"))
|
|
65
65
|
}, rows !== null && rows !== void 0 && rows.length ? rows.map(function (row) {
|
|
66
66
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
67
|
+
key: "row-".concat(row.id),
|
|
67
68
|
className: (0, _classnames.default)("".concat(RC, "__row")),
|
|
68
69
|
"data-id": row.id
|
|
69
70
|
}, preperedColumns.map(function (cell) {
|
|
70
71
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
+
key: "row-".concat(row.id, "-cell-").concat(cell.key),
|
|
71
73
|
className: (0, _classnames.default)("".concat(RC, "__cell"), cell.cellClassName, cell.columnClassName)
|
|
72
74
|
}, /*#__PURE__*/_react.default.createElement(CellComponent, (0, _extends2.default)({}, CellComponentProps, {
|
|
73
75
|
field: _objectSpread(_objectSpread({}, cell), {}, {
|