@rh-support/components 2.0.7 → 2.0.8

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 (65) hide show
  1. package/lib/cjs/AlertMessage/AlertMessage.js +4 -4
  2. package/lib/cjs/ConfirmationModal/ConfirmationContext.js +13 -41
  3. package/lib/cjs/ConfirmationModal/ConfirmationDialog.js +5 -5
  4. package/lib/cjs/CoverSpinner/CoverSpinner.js +1 -1
  5. package/lib/cjs/CustomContentLoader/CustomContentLoader.js +4 -4
  6. package/lib/cjs/CustomTextInput/CustomTextInput.js +8 -19
  7. package/lib/cjs/DropDownList/AsyncDropDownList.js +5 -5
  8. package/lib/cjs/DropDownList/DropDownList.js +45 -75
  9. package/lib/cjs/DropDownList/DropdownWrapper.js +7 -18
  10. package/lib/cjs/DropDownList/MultiSelectDropdownList.js +3 -3
  11. package/lib/cjs/DropDownList/SearchableList.js +41 -55
  12. package/lib/cjs/DropDownList/SelectList.js +15 -26
  13. package/lib/cjs/DropDownList/async.js +28 -38
  14. package/lib/cjs/DropDownList/dropdownUtils.js +9 -20
  15. package/lib/cjs/DropDownList/withMulti.js +15 -26
  16. package/lib/cjs/ErrorBoundary/ErrorBoundary.js +18 -47
  17. package/lib/cjs/ErrorBoundary/ErrorBoundaryFallbackComponent.js +10 -10
  18. package/lib/cjs/ErrorPages/Generic403.js +2 -2
  19. package/lib/cjs/FeedbackForm/FeedbackForm.js +24 -52
  20. package/lib/cjs/Functional/CaseContactsSelectorExternal.js +81 -154
  21. package/lib/cjs/InlineEdit/InlineEdit.js +56 -142
  22. package/lib/cjs/InlineEdit/NewInlineEdit.js +60 -145
  23. package/lib/cjs/LanguageSelector/LanguageSelector.js +10 -26
  24. package/lib/cjs/LoadingDots/LoadingDots.js +3 -3
  25. package/lib/cjs/LoadingIndicator/LoadingIndicator.js +3 -3
  26. package/lib/cjs/LoginModal/LoginModal.js +3 -3
  27. package/lib/cjs/MarkdownEditor/MarkdownEditor.js +113 -165
  28. package/lib/cjs/MoreOrLess/MoreOrLess.js +20 -40
  29. package/lib/cjs/PaginatedList/PaginatedList.js +15 -31
  30. package/lib/cjs/PaginationCompact/PaginationCompact.js +14 -31
  31. package/lib/cjs/ProgressBar/CircularProgressBar/CircularProgressBar.js +14 -14
  32. package/lib/cjs/ProgressBar/CircularProgressBar/Path.js +20 -18
  33. package/lib/cjs/ProgressBar/ProgressBar.js +8 -19
  34. package/lib/cjs/PromisifyModal/PromisifyModal.js +19 -36
  35. package/lib/cjs/SubscriptionAbuse/SubscriptionAbuseModal.js +5 -5
  36. package/lib/cjs/SubscriptionAbuse/const.js +3 -3
  37. package/lib/cjs/SupportFeedbackForm/SupportFeedbackForm.js +8 -24
  38. package/lib/cjs/SupportFeedbackForm/SupportFeedbackModal.js +50 -120
  39. package/lib/cjs/Table/PFTable.js +52 -89
  40. package/lib/cjs/Table/Table.js +12 -29
  41. package/lib/cjs/Table/TableColumnSelector.js +14 -15
  42. package/lib/cjs/Table/TablePagination.js +8 -8
  43. package/lib/cjs/Table/TableProvider.js +6 -6
  44. package/lib/cjs/TermsAndConditions/AcceptTermsModal.js +46 -100
  45. package/lib/cjs/TextAreaAutosize/TextAreaAutosize.js +35 -62
  46. package/lib/cjs/TextAreaResizable/TextAreaResizable.js +9 -25
  47. package/lib/cjs/ToastNotification/ToastNotification.js +35 -70
  48. package/lib/cjs/TopContentSearch/TopContentSearch.js +48 -113
  49. package/lib/cjs/ValueChangedIcon/ValueChangedIcon.js +13 -29
  50. package/lib/cjs/helperFunctions/errorMessage.js +13 -13
  51. package/lib/cjs/hooks/useBreakpoint.js +26 -43
  52. package/lib/cjs/hooks/useCopyToClipboard.js +8 -24
  53. package/lib/cjs/hooks/useDebounce.js +13 -38
  54. package/lib/cjs/hooks/useFetch.js +47 -123
  55. package/lib/cjs/hooks/useForceUpdate.js +2 -18
  56. package/lib/cjs/hooks/useForkRef.js +3 -3
  57. package/lib/cjs/hooks/useIsMounted.js +4 -4
  58. package/lib/cjs/hooks/useLRUCache.js +11 -11
  59. package/lib/cjs/hooks/useLocalStorage.js +7 -23
  60. package/lib/cjs/hooks/useOnScreen.js +5 -24
  61. package/lib/cjs/hooks/usePolling.js +8 -30
  62. package/lib/cjs/hooks/usePrevious.js +3 -3
  63. package/lib/cjs/hooks/useTitle.js +4 -4
  64. package/lib/cjs/hooks/useUndo.js +49 -72
  65. package/package.json +6 -7
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -29,79 +18,62 @@ var __importStar = (this && this.__importStar) || function (mod) {
29
18
  __setModuleDefault(result, mod);
30
19
  return result;
31
20
  };
32
- var __read = (this && this.__read) || function (o, n) {
33
- var m = typeof Symbol === "function" && o[Symbol.iterator];
34
- if (!m) return o;
35
- var i = m.call(o), r, ar = [], e;
36
- try {
37
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
38
- }
39
- catch (error) { e = { error: error }; }
40
- finally {
41
- try {
42
- if (r && !r.done && (m = i["return"])) m.call(i);
43
- }
44
- finally { if (e) throw e.error; }
45
- }
46
- return ar;
47
- };
48
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
49
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
50
23
  };
51
24
  Object.defineProperty(exports, "__esModule", { value: true });
52
25
  exports.FeedbackForm = void 0;
53
- var hydrajs_1 = require("@cee-eng/hydrajs");
54
- var react_core_1 = require("@patternfly/react-core");
55
- var utils_1 = require("@rh-support/utils");
56
- var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
57
- var react_1 = __importStar(require("react"));
58
- var react_i18next_1 = require("react-i18next");
59
- var react_router_dom_1 = require("react-router-dom");
60
- var TextAreaAutosize_1 = require("../TextAreaAutosize");
61
- var required = {
26
+ const hydrajs_1 = require("@cee-eng/hydrajs");
27
+ const react_core_1 = require("@patternfly/react-core");
28
+ const utils_1 = require("@rh-support/utils");
29
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
30
+ const react_1 = __importStar(require("react"));
31
+ const react_i18next_1 = require("react-i18next");
32
+ const react_router_dom_1 = require("react-router-dom");
33
+ const TextAreaAutosize_1 = require("../TextAreaAutosize");
34
+ const required = {
62
35
  isSolutionFound: true,
63
36
  levelOfSatisfied: true,
64
37
  isTimeSaved: true,
65
38
  moreInfo: false,
66
39
  };
67
- var defaultProps = { buttonLabel: 'Provide feedback', additionalBtnClass: '', isInline: false };
40
+ const defaultProps = { buttonLabel: 'Provide feedback', additionalBtnClass: '', isInline: false };
68
41
  function FeedbackForm(props) {
69
42
  var _a, _b;
70
- var t = react_i18next_1.useTranslation().t;
71
- var _c = __read(react_1.useState(false), 2), isModalOpen = _c[0], toggleModal = _c[1];
72
- var seSessionId = (_b = (_a = utils_1.getUrlParsedParams(react_router_dom_1.useLocation().search)) === null || _a === void 0 ? void 0 : _a.seSessionId) !== null && _b !== void 0 ? _b : '';
73
- var formInitState = {
43
+ const { t } = react_i18next_1.useTranslation();
44
+ const [isModalOpen, toggleModal] = react_1.useState(false);
45
+ const seSessionId = (_b = (_a = utils_1.getUrlParsedParams(react_router_dom_1.useLocation().search)) === null || _a === void 0 ? void 0 : _a.seSessionId) !== null && _b !== void 0 ? _b : '';
46
+ const formInitState = {
74
47
  isSolutionFound: null,
75
48
  levelOfSatisfied: null,
76
49
  isTimeSaved: null,
77
50
  moreInfo: '',
78
51
  };
79
- var _d = __read(react_1.useState(formInitState), 2), values = _d[0], setValues = _d[1];
80
- var _e = __read(react_1.useState(true), 2), isSubmitDisabled = _e[0], setSubmitDisabled = _e[1];
81
- react_1.useEffect(function () {
82
- var valid = true;
83
- Object.keys(values).forEach(function (key) {
52
+ const [values, setValues] = react_1.useState(formInitState);
53
+ const [isSubmitDisabled, setSubmitDisabled] = react_1.useState(true);
54
+ react_1.useEffect(() => {
55
+ let valid = true;
56
+ Object.keys(values).forEach((key) => {
84
57
  if (required[key]) {
85
58
  valid = valid && !isEmpty_1.default(values[key]);
86
59
  }
87
60
  });
88
61
  setSubmitDisabled(!valid);
89
62
  }, [values]);
90
- var handleChange = function (event) {
91
- var _a;
92
- setValues(__assign(__assign({}, values), (_a = {}, _a[event.currentTarget.name] = event.currentTarget.value, _a)));
63
+ const handleChange = (event) => {
64
+ setValues(Object.assign(Object.assign({}, values), { [event.currentTarget.name]: event.currentTarget.value }));
93
65
  };
94
- var handleSubmit = function (event) {
66
+ const handleSubmit = (event) => {
95
67
  event.preventDefault();
96
68
  hydrajs_1.pcm.sendFeedbackForm(values, window.sessionjs, window.location.href, seSessionId !== null && seSessionId !== void 0 ? seSessionId : '');
97
69
  setValues(formInitState);
98
70
  toggleModal(!isModalOpen);
99
71
  };
100
- var handleModalToggle = function () {
72
+ const handleModalToggle = () => {
101
73
  toggleModal(!isModalOpen);
102
74
  };
103
75
  return (react_1.default.createElement(react_1.default.Fragment, null,
104
- react_1.default.createElement(react_core_1.Button, { key: "confirm", onClick: handleModalToggle, variant: "link", "data-tracking-id": "se-feedback-trigger", className: "" + props.additionalBtnClass, isInline: props.isInline ? true : null },
76
+ react_1.default.createElement(react_core_1.Button, { key: "confirm", onClick: handleModalToggle, variant: "link", "data-tracking-id": "se-feedback-trigger", className: `${props.additionalBtnClass}`, isInline: props.isInline ? true : null },
105
77
  react_1.default.createElement(react_i18next_1.Trans, null, props.isInline ? props.buttonLabel.toLowerCase() : props.buttonLabel)),
106
78
  react_1.default.createElement(react_core_1.Modal, { className: "feedback-modal", title: t('Thank you for providing feedback'), "aria-describedby": "Feedback Form", isOpen: isModalOpen, variant: react_core_1.ModalVariant.large, onClose: handleModalToggle, actions: [
107
79
  react_1.default.createElement("button", { key: "confirm", onClick: handleSubmit, disabled: isSubmitDisabled, className: "btn btn-app btn-primary", "data-tracking-id": "se-feedback-submit" },
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -38,33 +27,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
38
27
  step((generator = generator.apply(thisArg, _arguments || [])).next());
39
28
  });
40
29
  };
41
- var __generator = (this && this.__generator) || function (thisArg, body) {
42
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
43
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
44
- function verb(n) { return function (v) { return step([n, v]); }; }
45
- function step(op) {
46
- if (f) throw new TypeError("Generator is already executing.");
47
- while (_) try {
48
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
49
- if (y = 0, t) op = [op[0] & 2, t.value];
50
- switch (op[0]) {
51
- case 0: case 1: t = op; break;
52
- case 4: _.label++; return { value: op[1], done: false };
53
- case 5: _.label++; y = op[1]; op = [0]; continue;
54
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
55
- default:
56
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
57
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
58
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
59
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
60
- if (t[2]) _.ops.pop();
61
- _.trys.pop(); continue;
62
- }
63
- op = body.call(thisArg, _);
64
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
65
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
66
- }
67
- };
68
30
  var __rest = (this && this.__rest) || function (s, e) {
69
31
  var t = {};
70
32
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -76,154 +38,119 @@ var __rest = (this && this.__rest) || function (s, e) {
76
38
  }
77
39
  return t;
78
40
  };
79
- var __read = (this && this.__read) || function (o, n) {
80
- var m = typeof Symbol === "function" && o[Symbol.iterator];
81
- if (!m) return o;
82
- var i = m.call(o), r, ar = [], e;
83
- try {
84
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
85
- }
86
- catch (error) { e = { error: error }; }
87
- finally {
88
- try {
89
- if (r && !r.done && (m = i["return"])) m.call(i);
90
- }
91
- finally { if (e) throw e.error; }
92
- }
93
- return ar;
94
- };
95
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
96
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
97
- to[j] = from[i];
98
- return to;
99
- };
100
41
  var __importDefault = (this && this.__importDefault) || function (mod) {
101
42
  return (mod && mod.__esModule) ? mod : { "default": mod };
102
43
  };
103
44
  Object.defineProperty(exports, "__esModule", { value: true });
104
45
  exports.getHydraContactLabel = exports.renderMenuItemChildren = exports.CaseContactsSelectorExternal = void 0;
105
- var hydrajs_1 = require("@cee-eng/hydrajs");
106
- var utils_1 = require("@rh-support/utils");
107
- var differenceBy_1 = __importDefault(require("lodash/differenceBy"));
108
- var isArray_1 = __importDefault(require("lodash/isArray"));
109
- var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
110
- var sortBy_1 = __importDefault(require("lodash/sortBy"));
111
- var react_1 = __importStar(require("react"));
112
- var react_bootstrap_typeahead_1 = require("react-bootstrap-typeahead");
113
- var react_i18next_1 = require("react-i18next");
114
- var usePrevious_1 = require("../hooks/usePrevious");
115
- var renderMenuItemChildren = function (option, p) { return (react_1.default.createElement(react_bootstrap_typeahead_1.Highlighter, { key: getKey(option), search: p.text }, getHydraContactLabel(option))); };
46
+ const hydrajs_1 = require("@cee-eng/hydrajs");
47
+ const utils_1 = require("@rh-support/utils");
48
+ const differenceBy_1 = __importDefault(require("lodash/differenceBy"));
49
+ const isArray_1 = __importDefault(require("lodash/isArray"));
50
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
51
+ const sortBy_1 = __importDefault(require("lodash/sortBy"));
52
+ const react_1 = __importStar(require("react"));
53
+ const react_bootstrap_typeahead_1 = require("react-bootstrap-typeahead");
54
+ const react_i18next_1 = require("react-i18next");
55
+ const usePrevious_1 = require("../hooks/usePrevious");
56
+ const renderMenuItemChildren = (option, p) => (react_1.default.createElement(react_bootstrap_typeahead_1.Highlighter, { key: getKey(option), search: p.text }, getHydraContactLabel(option)));
116
57
  exports.renderMenuItemChildren = renderMenuItemChildren;
117
- var isCustomEmailAddress = function (user) {
58
+ const isCustomEmailAddress = (user) => {
118
59
  var _a;
119
60
  return !!((_a = user) === null || _a === void 0 ? void 0 : _a.emailAddress);
120
61
  };
121
- var isContact = function (user) {
62
+ const isContact = (user) => {
122
63
  var _a, _b;
123
64
  return !!((_a = user) === null || _a === void 0 ? void 0 : _a.ssoUsername) && !((_b = user) === null || _b === void 0 ? void 0 : _b.emailAddress);
124
65
  };
125
- var getKey = function (option) {
66
+ const getKey = (option) => {
126
67
  if (isCustomEmailAddress(option))
127
68
  return option.emailAddress;
128
69
  if (isContact(option))
129
70
  return option.ssoUsername;
130
71
  };
131
- var getHydraContactLabel = function (user) {
72
+ const getHydraContactLabel = (user) => {
132
73
  if (isEmpty_1.default(user) || typeof user !== 'object')
133
74
  return '';
134
- var label = '';
75
+ let label = '';
135
76
  if (isCustomEmailAddress(user)) {
136
77
  label = user.emailAddress;
137
78
  }
138
79
  else if (isContact(user)) {
139
- var fullname = !isEmpty_1.default(user.fullNameCustom)
140
- ? "" + user.fullNameCustom
141
- : user.firstName + " " + user.lastName;
142
- label = fullname + " (" + user.ssoUsername + ")";
80
+ const fullname = !isEmpty_1.default(user.fullNameCustom)
81
+ ? `${user.fullNameCustom}`
82
+ : `${user.firstName} ${user.lastName}`;
83
+ label = `${fullname} (${user.ssoUsername})`;
143
84
  }
144
85
  return label ? label : '';
145
86
  };
146
87
  exports.getHydraContactLabel = getHydraContactLabel;
147
88
  function CaseContactsSelectorExternal(props) {
148
- var _this = this;
149
- var previousSelectedAccountNumber = usePrevious_1.usePrevious(props.selectedAccountNumber);
89
+ const previousSelectedAccountNumber = usePrevious_1.usePrevious(props.selectedAccountNumber);
150
90
  /**
151
91
  * External owner selector related
152
92
  */
153
93
  /** Getting user list for selected account when logged in user is a external */
154
- var _a = __read(react_1.useState(utils_1.getApiResourceObject([])), 2), contactList = _a[0], setContactList = _a[1];
155
- var controllerRef1 = react_1.useRef(new AbortController());
156
- var controllerRef2 = react_1.useRef(new AbortController());
157
- react_1.useEffect(function () {
94
+ const [contactList, setContactList] = react_1.useState(utils_1.getApiResourceObject([]));
95
+ const controllerRef1 = react_1.useRef(new AbortController());
96
+ const controllerRef2 = react_1.useRef(new AbortController());
97
+ react_1.useEffect(() => {
158
98
  if (props.isExportingPDF)
159
99
  return;
160
100
  // when component is unmonted and error happens after apis responses are ready, we use this variable to prevent state update.
161
- var isSubscribed = true;
162
- var fetchStrataAccountUsers = function () { return __awaiter(_this, void 0, void 0, function () {
163
- var contactListTemp, extraLoggedInContacts, contacts, promiseArray, loggedInContactsResponse, selectedAccountsContacts, currentAccountsContacts, e_1;
164
- return __generator(this, function (_a) {
165
- switch (_a.label) {
166
- case 0:
167
- if (controllerRef1.current) {
168
- controllerRef1.current.abort();
169
- }
170
- controllerRef1.current = new AbortController();
171
- if (controllerRef2.current) {
172
- controllerRef2.current.abort();
173
- }
174
- controllerRef2.current = new AbortController();
175
- _a.label = 1;
176
- case 1:
177
- _a.trys.push([1, 9, , 10]);
178
- setContactList(utils_1.getApiResourceObject([], true));
179
- contactListTemp = [];
180
- if (!(props.loggedInUserRights.isPartner() &&
181
- props.loggedInUserRights.isAccountDifferentFromLoggedInAccount(props.selectedAccountNumber))) return [3 /*break*/, 6];
182
- if (!props.loggedInUserRights.isNonOrgAdmin()) return [3 /*break*/, 3];
183
- extraLoggedInContacts = props.loggedInUserRights.getHydraContactFromLoggedInUser();
184
- return [4 /*yield*/, hydrajs_1.accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal)];
185
- case 2:
186
- contacts = _a.sent();
101
+ let isSubscribed = true;
102
+ const fetchStrataAccountUsers = () => __awaiter(this, void 0, void 0, function* () {
103
+ if (controllerRef1.current) {
104
+ controllerRef1.current.abort();
105
+ }
106
+ controllerRef1.current = new AbortController();
107
+ if (controllerRef2.current) {
108
+ controllerRef2.current.abort();
109
+ }
110
+ controllerRef2.current = new AbortController();
111
+ try {
112
+ setContactList(utils_1.getApiResourceObject([], true));
113
+ let contactListTemp = [];
114
+ if (props.loggedInUserRights.isPartner() &&
115
+ props.loggedInUserRights.isAccountDifferentFromLoggedInAccount(props.selectedAccountNumber)) {
116
+ /** Show Partner contacts even when customer account is selected
117
+ - Non Org-Admin partners => Only logged in contact + All Customer contacts
118
+ - Org-Admin partners => All partner contacts + All Customer contacts */
119
+ if (props.loggedInUserRights.isNonOrgAdmin()) {
120
+ const extraLoggedInContacts = props.loggedInUserRights.getHydraContactFromLoggedInUser();
121
+ const contacts = yield hydrajs_1.accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal);
187
122
  contactListTemp = contacts.concat(extraLoggedInContacts);
188
- return [3 /*break*/, 5];
189
- case 3:
190
- promiseArray = [
123
+ }
124
+ else {
125
+ let promiseArray = [
191
126
  hydrajs_1.accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal),
192
127
  hydrajs_1.accounts.getAccountContacts(props.loggedInUserRights.getAccountNumber(), controllerRef2.current.signal),
193
128
  ];
194
- return [4 /*yield*/, Promise.all(promiseArray)];
195
- case 4:
196
- loggedInContactsResponse = _a.sent();
197
- selectedAccountsContacts = loggedInContactsResponse[0];
198
- currentAccountsContacts = loggedInContactsResponse[1];
199
- contactListTemp = __spreadArray(__spreadArray([], __read(selectedAccountsContacts)), __read(currentAccountsContacts));
200
- _a.label = 5;
201
- case 5: return [3 /*break*/, 8];
202
- case 6: return [4 /*yield*/, hydrajs_1.accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal)];
203
- case 7:
204
- contactListTemp = _a.sent();
205
- _a.label = 8;
206
- case 8:
207
- if (props.contactsToExclude && props.contactsToExclude.length > 0) {
208
- contactListTemp = differenceBy_1.default(contactListTemp, props.contactsToExclude, 'ssoUsername');
209
- }
210
- setContactList(utils_1.getApiResourceObject(utils_1.sortHydraContacts(contactListTemp)));
211
- return [3 /*break*/, 10];
212
- case 9:
213
- e_1 = _a.sent();
214
- isSubscribed && setContactList(utils_1.getApiResourceObject([], false, true, e_1.message));
215
- return [3 /*break*/, 10];
216
- case 10: return [2 /*return*/];
129
+ const loggedInContactsResponse = yield Promise.all(promiseArray);
130
+ const selectedAccountsContacts = loggedInContactsResponse[0];
131
+ const currentAccountsContacts = loggedInContactsResponse[1];
132
+ contactListTemp = [...selectedAccountsContacts, ...currentAccountsContacts];
133
+ }
134
+ }
135
+ else {
136
+ contactListTemp = yield hydrajs_1.accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal);
217
137
  }
218
- });
219
- }); };
220
- var isOldAccountNumber = props.selectedAccountNumber && props.selectedAccountNumber === previousSelectedAccountNumber;
138
+ if (props.contactsToExclude && props.contactsToExclude.length > 0) {
139
+ contactListTemp = differenceBy_1.default(contactListTemp, props.contactsToExclude, 'ssoUsername');
140
+ }
141
+ setContactList(utils_1.getApiResourceObject(utils_1.sortHydraContacts(contactListTemp)));
142
+ }
143
+ catch (e) {
144
+ isSubscribed && setContactList(utils_1.getApiResourceObject([], false, true, e.message));
145
+ }
146
+ });
147
+ const isOldAccountNumber = props.selectedAccountNumber && props.selectedAccountNumber === previousSelectedAccountNumber;
221
148
  if (isOldAccountNumber ||
222
149
  (props.loggedInUserRights.isExternal() &&
223
150
  props.loggedInUserRights.isNonOrgAdminWithSameAccount(props.selectedAccountNumber)))
224
151
  return;
225
152
  fetchStrataAccountUsers();
226
- return function () {
153
+ return () => {
227
154
  isSubscribed = false;
228
155
  };
229
156
  }, [
@@ -233,10 +160,10 @@ function CaseContactsSelectorExternal(props) {
233
160
  props.selectedAccountNumber,
234
161
  props.isExportingPDF,
235
162
  ]);
236
- var onCustomerContactSelect = function (contacts) {
163
+ const onCustomerContactSelect = (contacts) => {
237
164
  if (!isArray_1.default(contacts))
238
165
  return;
239
- var customerContacts = contacts.length === 0 || !isEmpty_1.default(contacts[0])
166
+ const customerContacts = contacts.length === 0 || !isEmpty_1.default(contacts[0])
240
167
  ? contacts
241
168
  : [
242
169
  {
@@ -249,15 +176,15 @@ function CaseContactsSelectorExternal(props) {
249
176
  ];
250
177
  props.onChange && props.onChange(customerContacts);
251
178
  };
252
- var onCustomerContactSelectBlur = function (event) {
179
+ const onCustomerContactSelectBlur = (event) => {
253
180
  props.onChange && props.onChange(props.selected);
254
181
  };
255
- var isDisabled = (props.loggedInUserRights.isExternal() &&
182
+ const isDisabled = (props.loggedInUserRights.isExternal() &&
256
183
  props.loggedInUserRights.isNonOrgAdminWithSameAccount(props.selectedAccountNumber)) ||
257
184
  props.isUpdating ||
258
185
  contactList.isFetching;
259
- var renderMenu = function (results, menuProps, state) {
260
- var contacts = results.map(function (item, index) {
186
+ const renderMenu = (results, menuProps, state) => {
187
+ const contacts = results.map((item, index) => {
261
188
  if (item.customOption) {
262
189
  return (react_1.default.createElement(react_bootstrap_typeahead_1.MenuItem, { className: "rbt-menu-custom-option", key: index, option: item, position: index },
263
190
  menuProps.newSelectionPrefix,
@@ -282,15 +209,15 @@ function CaseContactsSelectorExternal(props) {
282
209
  react_1.default.createElement(react_bootstrap_typeahead_1.MenuItem, { key: index, option: item, position: index }, renderMenuItemChildren(item, state))));
283
210
  }
284
211
  });
285
- return react_1.default.createElement(react_bootstrap_typeahead_1.Menu, __assign({}, menuProps), contacts);
212
+ return react_1.default.createElement(react_bootstrap_typeahead_1.Menu, Object.assign({}, menuProps), contacts);
286
213
  };
287
- var customEmails = props.customEmails, restProps = __rest(props, ["customEmails"]);
288
- var conditionalProps = __assign(__assign({}, (props.renderToken ? { renderToken: props.renderToken } : undefined)), ((customEmails || []).length > 0 ? { renderMenu: renderMenu } : undefined));
289
- var getCustomEmails = function () {
290
- return sortBy_1.default((customEmails || []).map(function (item) { return (__assign(__assign({}, item), { ssoUsername: item.emailAddress, firstName: item.emailAddress, lastName: item.emailAddress })); }), 'emailAddress');
214
+ const { customEmails } = props, restProps = __rest(props, ["customEmails"]);
215
+ const conditionalProps = Object.assign(Object.assign({}, (props.renderToken ? { renderToken: props.renderToken } : undefined)), ((customEmails || []).length > 0 ? { renderMenu } : undefined));
216
+ const getCustomEmails = () => {
217
+ return sortBy_1.default((customEmails || []).map((item) => (Object.assign(Object.assign({}, item), { ssoUsername: item.emailAddress, firstName: item.emailAddress, lastName: item.emailAddress }))), 'emailAddress');
291
218
  };
292
- return (react_1.default.createElement(react_bootstrap_typeahead_1.Typeahead, __assign({}, restProps, { id: props.id || '',
219
+ return (react_1.default.createElement(react_bootstrap_typeahead_1.Typeahead, Object.assign({}, restProps, { id: props.id || '',
293
220
  // @ts-expect-error
294
- className: props.className || '', filterBy: ['firstName', 'lastName', 'ssoUsername'], clearButton: !!props.clearButton, multiple: !!props.multiple, isLoading: contactList.isFetching || props.isUpdating, options: __spreadArray(__spreadArray([], __read(contactList.data)), __read(getCustomEmails())), selected: !isEmpty_1.default(props.selected) ? props.selected : [], onChange: onCustomerContactSelect, labelKey: props.multiple ? 'ssoUsername' : getHydraContactLabel, placeholder: props.placeholder || 'Search by name or username', renderMenuItemChildren: renderMenuItemChildren, onBlur: onCustomerContactSelectBlur, minLength: props.minLength || 0, disabled: isDisabled }, conditionalProps)));
221
+ className: props.className || '', filterBy: ['firstName', 'lastName', 'ssoUsername'], clearButton: !!props.clearButton, multiple: !!props.multiple, isLoading: contactList.isFetching || props.isUpdating, options: [...contactList.data, ...getCustomEmails()], selected: !isEmpty_1.default(props.selected) ? props.selected : [], onChange: onCustomerContactSelect, labelKey: props.multiple ? 'ssoUsername' : getHydraContactLabel, placeholder: props.placeholder || 'Search by name or username', renderMenuItemChildren: renderMenuItemChildren, onBlur: onCustomerContactSelectBlur, minLength: props.minLength || 0, disabled: isDisabled }, conditionalProps)));
295
222
  }
296
223
  exports.CaseContactsSelectorExternal = CaseContactsSelectorExternal;