@rh-support/components 2.5.214 → 2.5.223

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 (48) hide show
  1. package/lib/esm/ConfirmationModal/ConfirmationDialog.js +1 -1
  2. package/lib/esm/Functional/CaseContactsSelectorExternal.d.ts +0 -2
  3. package/lib/esm/Functional/CaseContactsSelectorExternal.d.ts.map +1 -1
  4. package/lib/esm/Functional/CaseContactsSelectorExternal.js +82 -156
  5. package/lib/esm/MarkdownEditor/MarkdownEditor.d.ts +49 -0
  6. package/lib/esm/MarkdownEditor/MarkdownEditor.d.ts.map +1 -0
  7. package/lib/esm/MarkdownEditor/MarkdownEditor.js +601 -0
  8. package/lib/esm/MarkdownEditor/index.d.ts +2 -0
  9. package/lib/esm/MarkdownEditor/index.d.ts.map +1 -0
  10. package/lib/esm/MarkdownEditor/index.js +1 -0
  11. package/lib/esm/MarkdownEditor/markdownEditor.css +223 -0
  12. package/lib/esm/OwnerTypeaheadDropdown/OwnerTypeaheadDropdown.d.ts +0 -2
  13. package/lib/esm/OwnerTypeaheadDropdown/OwnerTypeaheadDropdown.d.ts.map +1 -1
  14. package/lib/esm/OwnerTypeaheadDropdown/OwnerTypeaheadDropdown.js +3 -8
  15. package/lib/esm/PhoneInput/PhoneInput.d.ts.map +1 -1
  16. package/lib/esm/PhoneInput/PhoneInput.js +1 -38
  17. package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.d.ts.map +1 -1
  18. package/lib/esm/SupportFeedbackForm/SupportFeedbackModal.js +17 -3
  19. package/lib/esm/Table/TablePagination.d.ts +0 -1
  20. package/lib/esm/Table/TablePagination.d.ts.map +1 -1
  21. package/lib/esm/Table/TablePagination.js +1 -1
  22. package/lib/esm/helperFunctions/errorMessage.d.ts +1 -2
  23. package/lib/esm/helperFunctions/errorMessage.d.ts.map +1 -1
  24. package/lib/esm/helperFunctions/errorMessage.js +5 -19
  25. package/lib/esm/hooks/useCopyToClipboard.d.ts +1 -1
  26. package/lib/esm/hooks/useCopyToClipboard.d.ts.map +1 -1
  27. package/lib/esm/hooks/useCopyToClipboard.js +1 -3
  28. package/lib/esm/index.d.ts +1 -2
  29. package/lib/esm/index.d.ts.map +1 -1
  30. package/lib/esm/index.js +1 -3
  31. package/package.json +6 -9
  32. package/lib/esm/CustomDatePicker/CustomDatePicker.d.ts +0 -18
  33. package/lib/esm/CustomDatePicker/CustomDatePicker.d.ts.map +0 -1
  34. package/lib/esm/CustomDatePicker/CustomDatePicker.js +0 -27
  35. package/lib/esm/CustomDatePicker/customDatePicker.css +0 -52
  36. package/lib/esm/CustomDatePicker/index.d.ts +0 -2
  37. package/lib/esm/CustomDatePicker/index.d.ts.map +0 -1
  38. package/lib/esm/CustomDatePicker/index.js +0 -1
  39. package/lib/esm/RichTextEditor/RichTextEditor.d.ts +0 -45
  40. package/lib/esm/RichTextEditor/RichTextEditor.d.ts.map +0 -1
  41. package/lib/esm/RichTextEditor/RichTextEditor.js +0 -463
  42. package/lib/esm/RichTextEditor/index.d.ts +0 -4
  43. package/lib/esm/RichTextEditor/index.d.ts.map +0 -1
  44. package/lib/esm/RichTextEditor/index.js +0 -2
  45. package/lib/esm/RichTextEditor/richTextEditor.css +0 -148
  46. package/lib/esm/RichTextEditor/useQuillEditor.d.ts +0 -20
  47. package/lib/esm/RichTextEditor/useQuillEditor.d.ts.map +0 -1
  48. package/lib/esm/RichTextEditor/useQuillEditor.js +0 -81
@@ -15,7 +15,7 @@ function ConfirmationDialog(props) {
15
15
  !isEmpty(props.title) && (React.createElement(ModalHeader, null,
16
16
  React.createElement("h2", null, props.title))),
17
17
  React.createElement(ModalBody, null,
18
- React.createElement("div", { id: "se-confirm-dialog" }, props.description)),
18
+ React.createElement("p", { id: "se-confirm-dialog" }, props.description)),
19
19
  React.createElement(ModalFooter, null,
20
20
  React.createElement(Button, { key: "confirm", onClick: props.onConfirm, variant: props.confirmButtonVariant },
21
21
  React.createElement(Trans, null, props.confirmText)),
@@ -28,8 +28,6 @@ interface IProps extends IDClassNameProps {
28
28
  onNew?: (query: string) => void;
29
29
  canAddNew?: (options: ITypeaheadDropdownGroupOrOption[], query: string) => boolean;
30
30
  getCreateNewText?: (query: string) => string;
31
- onContactEnriched?: (contact: IContact) => void;
32
- contactFilter?: (contact: IContact) => boolean;
33
31
  }
34
32
  export declare const CONTACTS_PAGE_SIZE = 10;
35
33
  export declare const DEFAULT_CONTACTS_OFFSET: number;
@@ -1 +1 @@
1
- {"version":3,"file":"CaseContactsSelectorExternal.d.ts","sourceRoot":"","sources":["../../../src/Functional/CaseContactsSelectorExternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAuB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAcxD,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AAEzF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,0BAA0B,CAAC;AACzE,UAAU,MAAO,SAAQ,gBAAgB;IACrC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,CAAC,QAAQ,GAAG,0BAA0B,CAAC,EAAE,CAAC;IACpD,QAAQ,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAQ,GAAG,0BAA0B,CAAC,EAAE,KAAK,IAAI,CAAC;IAChF,kBAAkB,EAAE,QAAQ,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB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AmB,CAAC,EAAE,OAAO,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,+BAA+B,EAAE,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACnF,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAChD;AAED,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,eAAO,MAAM,uBAAuB,QAAyB,CAAC;AAE9D,eAAO,MAAM,oBAAoB,GAAI,MAAM,oBAAoB,KAAG,IAAI,IAAI,0BAEzE,CAAC;AAMF,QAAA,MAAM,oBAAoB,GAAI,MAAM,oBAAoB,KAAG,MAa1D,CAAC;AAEF,iBAAS,4BAA4B,CAAC,KAAK,EAAE,MAAM,qBAwNlD;AAED,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,CAAC"}
@@ -7,9 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { useApolloClient } from '@apollo/client/react';
11
- import { GET_ACCOUNT_CONTACTS, getApiResourceObject, isEmailValid, } from '@rh-support/utils';
12
- import debounce from 'lodash/debounce';
10
+ import { accounts } from '@cee-eng/hydrajs';
11
+ import { getApiResourceObject, isEmailValid, sortHydraContacts } from '@rh-support/utils';
13
12
  import differenceBy from 'lodash/differenceBy';
14
13
  import filter from 'lodash/filter';
15
14
  import isArray from 'lodash/isArray';
@@ -17,6 +16,7 @@ import isEmpty from 'lodash/isEmpty';
17
16
  import map from 'lodash/map';
18
17
  import sortBy from 'lodash/sortBy';
19
18
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
+ import { usePrevious } from '../hooks/usePrevious';
20
20
  import { OwnerTypeaheadDropdown } from '../OwnerTypeaheadDropdown';
21
21
  export const CONTACTS_PAGE_SIZE = 10;
22
22
  export const DEFAULT_CONTACTS_OFFSET = CONTACTS_PAGE_SIZE - 1;
@@ -42,152 +42,82 @@ const getHydraContactLabel = (user) => {
42
42
  return label ? label : '';
43
43
  };
44
44
  function CaseContactsSelectorExternal(props) {
45
- const apolloClient = useApolloClient();
46
45
  const { customEmails, contactSsoUsername, isInvalid, groupContactsAndEmails, selected } = props;
46
+ const previousSelectedAccountNumber = usePrevious(props.selectedAccountNumber);
47
47
  const [filteredContacts, setFilteredContacts] = useState([]);
48
+ /**
49
+ * External owner selector related
50
+ */
51
+ /** Getting user list for selected account when logged in user is a external */
48
52
  const [contactList, setContactList] = useState(getApiResourceObject([]));
49
- const [hasNextPage, setHasNextPage] = useState(false);
50
- const [endCursor, setEndCursor] = useState(null);
51
- const [isLoadingMore, setIsLoadingMore] = useState(false);
52
- const mapContactEdges = (edges, accountNumber) => edges
53
- .filter(({ node }) => { var _a; return (_a = node.SSOUserName__c) === null || _a === void 0 ? void 0 : _a.value; })
54
- .map(({ node }) => {
55
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
56
- return ({
57
- id: node.Id,
58
- ssoUsername: node.SSOUserName__c.value,
59
- firstName: (_b = (_a = node.FirstName) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '',
60
- lastName: (_d = (_c = node.LastName) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : '',
61
- fullNameCustom: (_f = (_e = node.Name) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : '',
62
- manageSupportCases: (_h = (_g = node.ManageSupportCases__c) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : true,
63
- isInternal: (_k = (_j = node.IsInternal__c) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : false,
64
- isOrgAdmin: (_m = (_l = node.IsOrgAdmin__c) === null || _l === void 0 ? void 0 : _l.value) !== null && _m !== void 0 ? _m : false,
65
- phone: (_p = (_o = node.Phone) === null || _o === void 0 ? void 0 : _o.value) !== null && _p !== void 0 ? _p : '',
66
- defaultCaseGroup: (_r = (_q = node.DefaultCaseGroup__c) === null || _q === void 0 ? void 0 : _q.value) !== null && _r !== void 0 ? _r : null,
67
- accountNumber,
68
- });
69
- });
70
- const buildContactsWhere = (searchQuery) => {
71
- const base = { IsActive__c: { eq: true } };
72
- if (!(searchQuery === null || searchQuery === void 0 ? void 0 : searchQuery.trim()))
73
- return base;
74
- const term = `%${searchQuery.trim()}%`;
75
- return {
76
- and: [
77
- base,
78
- {
79
- or: [{ Name: { like: term } }, { SSOUserName__c: { like: term } }],
80
- },
81
- ],
82
- };
83
- };
84
- const fetchContactsPage = (after, searchQuery) => __awaiter(this, void 0, void 0, function* () {
85
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
86
- const { data } = yield apolloClient.query({
87
- query: GET_ACCOUNT_CONTACTS,
88
- variables: Object.assign(Object.assign({ first: CONTACTS_PAGE_SIZE }, (after ? { after } : {})), { contactsWhere: buildContactsWhere(searchQuery) }),
89
- fetchPolicy: after ? 'network-only' : 'network-only',
90
- });
91
- const response = data;
92
- const accountNode = (_e = (_d = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportAccount) === null || _c === void 0 ? void 0 : _c.edges) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.node;
93
- const contactEdges = (_g = (_f = accountNode === null || accountNode === void 0 ? void 0 : accountNode.Contacts) === null || _f === void 0 ? void 0 : _f.edges) !== null && _g !== void 0 ? _g : [];
94
- const pageInfo = (_j = (_h = accountNode === null || accountNode === void 0 ? void 0 : accountNode.Contacts) === null || _h === void 0 ? void 0 : _h.pageInfo) !== null && _j !== void 0 ? _j : { hasNextPage: false, endCursor: null };
95
- const accountNumber = (_l = (_k = accountNode === null || accountNode === void 0 ? void 0 : accountNode.AccountNumber) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : props.selectedAccountNumber;
96
- return { contacts: mapContactEdges(contactEdges, accountNumber), pageInfo };
97
- });
98
- const currentSearchQuery = useRef('');
99
- const loadMoreContacts = () => __awaiter(this, void 0, void 0, function* () {
100
- if (!hasNextPage || isLoadingMore)
101
- return;
102
- setIsLoadingMore(true);
103
- try {
104
- const { contacts: newContacts, pageInfo } = yield fetchContactsPage(endCursor, currentSearchQuery.current);
105
- setContactList((prev) => getApiResourceObject([...(prev.data || []), ...newContacts]));
106
- setHasNextPage(pageInfo.hasNextPage);
107
- setEndCursor(pageInfo.endCursor);
108
- }
109
- catch (_a) {
110
- // silently fail on load more
111
- }
112
- setIsLoadingMore(false);
113
- });
114
- const searchContacts = (query) => __awaiter(this, void 0, void 0, function* () {
115
- currentSearchQuery.current = query;
116
- setContactList(getApiResourceObject([], true));
117
- setHasNextPage(false);
118
- setEndCursor(null);
119
- try {
120
- const { contacts, pageInfo } = yield fetchContactsPage(null, query);
121
- if (currentSearchQuery.current === query) {
122
- setContactList(getApiResourceObject(contacts));
123
- setHasNextPage(pageInfo.hasNextPage);
124
- setEndCursor(pageInfo.endCursor);
125
- }
126
- }
127
- catch (_a) {
128
- setContactList(getApiResourceObject([]));
129
- }
130
- });
131
- // eslint-disable-next-line react-hooks/exhaustive-deps
132
- const debouncedSearch = useCallback(debounce(searchContacts, 400), [apolloClient]);
53
+ const controllerRef1 = useRef(new AbortController());
54
+ const controllerRef2 = useRef(new AbortController());
133
55
  useEffect(() => {
134
- const { selectedAccountNumber, loggedInUserRights, isExportingPDF } = props;
135
- const isNonOrgAdminSameAccount = loggedInUserRights.isExternal() && loggedInUserRights.isNonOrgAdminWithSameAccount(selectedAccountNumber);
136
- if (isExportingPDF || !selectedAccountNumber || isNonOrgAdminSameAccount) {
56
+ if (props.isExportingPDF)
137
57
  return;
138
- }
139
- let cancelled = false;
140
- const fetchAccountContacts = () => __awaiter(this, void 0, void 0, function* () {
141
- setContactList(getApiResourceObject([], true));
58
+ // when component is unmonted and error happens after apis responses are ready, we use this variable to prevent state update.
59
+ let isSubscribed = true;
60
+ const fetchStrataAccountUsers = () => __awaiter(this, void 0, void 0, function* () {
61
+ if (controllerRef1.current) {
62
+ controllerRef1.current.abort();
63
+ }
64
+ controllerRef1.current = new AbortController();
65
+ if (controllerRef2.current) {
66
+ controllerRef2.current.abort();
67
+ }
68
+ controllerRef2.current = new AbortController();
142
69
  try {
143
- const { contacts, pageInfo } = yield fetchContactsPage();
144
- if (!cancelled) {
145
- setContactList(getApiResourceObject(contacts));
146
- setHasNextPage(pageInfo.hasNextPage);
147
- setEndCursor(pageInfo.endCursor);
70
+ setContactList(getApiResourceObject([], true));
71
+ let contactListTemp = [];
72
+ if (props.loggedInUserRights.isPartner() &&
73
+ props.loggedInUserRights.isAccountDifferentFromLoggedInAccount(props.selectedAccountNumber)) {
74
+ /** Show Partner contacts even when customer account is selected
75
+ - Non Org-Admin partners => Only logged in contact + All Customer contacts
76
+ - Org-Admin partners => All partner contacts + All Customer contacts */
77
+ if (props.loggedInUserRights.isNonOrgAdmin()) {
78
+ const extraLoggedInContacts = props.loggedInUserRights.getHydraContactFromLoggedInUser();
79
+ const contacts = yield accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal);
80
+ contactListTemp = contacts.concat(extraLoggedInContacts);
81
+ }
82
+ else {
83
+ let promiseArray = [
84
+ accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal),
85
+ accounts.getAccountContacts(props.loggedInUserRights.getAccountNumber(), controllerRef2.current.signal),
86
+ ];
87
+ const loggedInContactsResponse = yield Promise.all(promiseArray);
88
+ const selectedAccountsContacts = loggedInContactsResponse[0];
89
+ const currentAccountsContacts = loggedInContactsResponse[1];
90
+ contactListTemp = [...selectedAccountsContacts, ...currentAccountsContacts];
91
+ }
92
+ }
93
+ else {
94
+ contactListTemp = yield accounts.getAccountContacts(props.selectedAccountNumber, controllerRef1.current.signal);
95
+ }
96
+ if (props.contactsToExclude && props.contactsToExclude.length > 0) {
97
+ contactListTemp = differenceBy(contactListTemp, props.contactsToExclude, 'ssoUsername');
148
98
  }
99
+ setContactList(getApiResourceObject(sortHydraContacts(contactListTemp)));
149
100
  }
150
101
  catch (e) {
151
- if (!cancelled) {
152
- setContactList(getApiResourceObject([], false, true, e.message));
153
- }
102
+ isSubscribed && setContactList(getApiResourceObject([], false, true, e.message));
154
103
  }
155
104
  });
156
- fetchAccountContacts();
105
+ const isOldAccountNumber = props.selectedAccountNumber && props.selectedAccountNumber === previousSelectedAccountNumber;
106
+ if (isOldAccountNumber ||
107
+ (props.loggedInUserRights.isExternal() &&
108
+ props.loggedInUserRights.isNonOrgAdminWithSameAccount(props.selectedAccountNumber)))
109
+ return;
110
+ fetchStrataAccountUsers();
157
111
  return () => {
158
- cancelled = true;
112
+ isSubscribed = false;
159
113
  };
160
- // eslint-disable-next-line react-hooks/exhaustive-deps
161
- }, [apolloClient, props.selectedAccountNumber, props.isExportingPDF]);
162
- useEffect(() => {
163
- if (contactList.isFetching || isEmpty(contactList.data) || isEmpty(selected))
164
- return;
165
- const currentOwner = selected[0];
166
- if (!(currentOwner === null || currentOwner === void 0 ? void 0 : currentOwner.ssoUsername))
167
- return;
168
- const matchedContact = contactList.data.find((c) => {
169
- var _a, _b;
170
- return c.id === (currentOwner === null || currentOwner === void 0 ? void 0 : currentOwner.id) ||
171
- ((_a = c.ssoUsername) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = currentOwner.ssoUsername) === null || _b === void 0 ? void 0 : _b.toLowerCase());
172
- });
173
- if (matchedContact === null || matchedContact === void 0 ? void 0 : matchedContact.id) {
174
- props.onContactEnriched
175
- ? props.onContactEnriched(matchedContact)
176
- : props.onChange && props.onChange([matchedContact]);
177
- }
178
- // eslint-disable-next-line react-hooks/exhaustive-deps
179
- }, [contactList.data, contactList.isFetching]);
180
- const displayedContacts = useMemo(() => {
181
- var _a;
182
- let contacts = (_a = contactList.data) !== null && _a !== void 0 ? _a : [];
183
- if (props.contactsToExclude && props.contactsToExclude.length > 0) {
184
- contacts = differenceBy(contacts, props.contactsToExclude, 'ssoUsername');
185
- }
186
- if (props.contactFilter) {
187
- contacts = contacts.filter(props.contactFilter);
188
- }
189
- return contacts;
190
- }, [contactList.data, props.contactsToExclude, props.contactFilter]);
114
+ }, [
115
+ previousSelectedAccountNumber,
116
+ props.contactsToExclude,
117
+ props.loggedInUserRights,
118
+ props.selectedAccountNumber,
119
+ props.isExportingPDF,
120
+ ]);
191
121
  const onCustomerContactSelect = (contacts) => {
192
122
  if (!isArray(contacts))
193
123
  return;
@@ -204,10 +134,11 @@ function CaseContactsSelectorExternal(props) {
204
134
  ];
205
135
  props.onChange && props.onChange(customerContacts);
206
136
  };
207
- const isNonOrgAdminSameAccountDisabled = props.loggedInUserRights.isExternal() &&
208
- props.loggedInUserRights.isNonOrgAdminWithSameAccount(props.selectedAccountNumber);
209
- const isDisabled = isNonOrgAdminSameAccountDisabled || props.isUpdating || contactList.isFetching || props.isDisabled;
210
- const isLoading = props.isUpdating || contactList.isFetching;
137
+ const isDisabled = (props.loggedInUserRights.isExternal() &&
138
+ props.loggedInUserRights.isNonOrgAdminWithSameAccount(props.selectedAccountNumber)) ||
139
+ props.isUpdating ||
140
+ contactList.isFetching ||
141
+ props.isDisabled;
211
142
  const getCustomEmails = useCallback(() => {
212
143
  return sortBy((customEmails || []).map((item) => (Object.assign(Object.assign({}, item), { ssoUsername: item.emailAddress, firstName: item.emailAddress, lastName: item.emailAddress }))), 'emailAddress');
213
144
  }, [customEmails]);
@@ -216,39 +147,34 @@ function CaseContactsSelectorExternal(props) {
216
147
  */
217
148
  const allOptions = useMemo(() => {
218
149
  return [
219
- ...map(displayedContacts, (contact) => ({ contact, isCustomEmail: false })),
150
+ ...map(contactList.data, (contact) => ({ contact, isCustomEmail: false })),
220
151
  ...map(getCustomEmails(), (email) => ({
221
152
  isCustomEmail: true,
222
153
  contact: Object.assign(Object.assign({}, email), { ssoUsername: email.emailAddress, firstName: email.emailAddress, lastName: email.emailAddress }),
223
154
  })),
224
155
  ];
225
- }, [displayedContacts, getCustomEmails]);
156
+ }, [contactList.data, getCustomEmails]);
226
157
  /**
227
158
  * update the shown options in the dropdown and reset the amount of options show to the default.
228
159
  * @param query The user search term
229
160
  */
230
161
  const onQueryUpdated = (query) => {
231
- setHasNextPage(false);
232
162
  if (isEmpty(query)) {
233
- currentSearchQuery.current = '';
234
- debouncedSearch.cancel();
235
- searchContacts('');
163
+ setFilteredContacts(allOptions);
236
164
  }
237
165
  else {
238
- const localFiltered = filter(allOptions, (option) => getHydraContactLabel(option.contact).toLowerCase().includes(query.toLowerCase()));
239
- setFilteredContacts(localFiltered);
240
- debouncedSearch(query);
166
+ const filteredContacts = filter(allOptions, (option) => getHydraContactLabel(option.contact).toLowerCase().includes(query.toLowerCase()));
167
+ setFilteredContacts(filteredContacts);
241
168
  }
242
169
  };
243
170
  /**
244
171
  * Reset the filtered contacts and the current offset.
245
172
  */
246
173
  const onClearQuery = () => {
247
- if (currentSearchQuery.current) {
248
- currentSearchQuery.current = '';
249
- debouncedSearch.cancel();
250
- searchContacts('');
251
- }
174
+ var _a;
175
+ const numOfCustomEmails = (_a = customEmails === null || customEmails === void 0 ? void 0 : customEmails.length) !== null && _a !== void 0 ? _a : 0;
176
+ if (filteredContacts.length === contactList.data.length + numOfCustomEmails)
177
+ return;
252
178
  setFilteredContacts(allOptions);
253
179
  };
254
180
  /**
@@ -269,7 +195,7 @@ function CaseContactsSelectorExternal(props) {
269
195
  */
270
196
  useEffect(() => {
271
197
  setFilteredContacts(allOptions);
272
- }, [displayedContacts, customEmails, allOptions, selected]);
273
- return (React.createElement(OwnerTypeaheadDropdown, { id: props.id || '', hasClearButton: true, multiple: !!props.multiple, contactSsoUsername: contactSsoUsername, groupContactsAndEmails: groupContactsAndEmails, selected: !isEmpty(props.selected) ? props.selected : [], options: filteredContacts, placeholder: props.placeholder || 'Search by name or username', "data-tracking-id": "external-case-contact-selector", isDisabled: isDisabled, status: isInvalid ? 'danger' : undefined, onChipRemoved: onChipRemoved, onClearQuery: onClearQuery, onQueryUpdated: onQueryUpdated, onSelect: onCustomerContactSelect, canAddNew: canAddNew, getCreateNewText: props === null || props === void 0 ? void 0 : props.getCreateNewText, isLoading: isLoading || isLoadingMore, onHandleLoadMore: loadMoreContacts, isShowMoreOptionVisible: hasNextPage }));
198
+ }, [contactList.data, customEmails, allOptions, selected]);
199
+ return (React.createElement(OwnerTypeaheadDropdown, { id: props.id || '', hasClearButton: true, multiple: !!props.multiple, contactSsoUsername: contactSsoUsername, groupContactsAndEmails: groupContactsAndEmails, selected: !isEmpty(props.selected) ? props.selected : [], options: filteredContacts, placeholder: props.placeholder || 'Search by name or username', "data-tracking-id": "external-case-contact-selector", isDisabled: isDisabled, status: isInvalid ? 'danger' : undefined, onChipRemoved: onChipRemoved, onClearQuery: onClearQuery, onQueryUpdated: onQueryUpdated, onSelect: onCustomerContactSelect, canAddNew: canAddNew, getCreateNewText: props === null || props === void 0 ? void 0 : props.getCreateNewText, isLoading: props.isUpdating || contactList.isFetching }));
274
200
  }
275
201
  export { CaseContactsSelectorExternal, getHydraContactLabel };
@@ -0,0 +1,49 @@
1
+ import './markdownEditor.css';
2
+ import { IAttachment } from '@cee-eng/hydrajs/@types/models/attachment';
3
+ import { IMarkdownOptions } from '@cee-eng/ui-toolkit';
4
+ import React, { HTMLProps } from 'react';
5
+ export declare enum EditorMode {
6
+ PLAIN = "plaintext",
7
+ MARKDOWN = "markdown"
8
+ }
9
+ interface IFileSelectorProps {
10
+ showFileSelectorInToolbar: boolean;
11
+ filesList: Partial<IAttachment>[];
12
+ onFileSelect: (file: Partial<IAttachment>) => void;
13
+ onFileDelete: (file: Partial<IAttachment>) => void;
14
+ onClipboardPaste: (file: any) => void;
15
+ isSupportedFile: (extension: string) => boolean;
16
+ attachFileBtn: React.ReactNode;
17
+ isUploadingFile: boolean;
18
+ }
19
+ export interface IMDEditorProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'onChange' | 'value' | 'ref'> {
20
+ value: string;
21
+ onChange: (value: string, mode?: EditorMode) => void;
22
+ className?: string;
23
+ id?: string;
24
+ hidePreviewText?: string;
25
+ showPreviewText?: string;
26
+ bindTextArea?: (ref: HTMLTextAreaElement) => void;
27
+ textAreaClassName?: string;
28
+ mdPlaceholder?: string;
29
+ plainTextPlaceholder?: string;
30
+ allowEmoji?: boolean;
31
+ hideHeadingOptions?: boolean;
32
+ markedownOptions?: IMarkdownOptions;
33
+ showMarkdownPlainTextToggle?: boolean;
34
+ editorMode?: EditorMode;
35
+ charLimit?: number;
36
+ minCharsForCounter?: number;
37
+ onCommentExceedCharsLimit: (val: boolean) => void;
38
+ fileSelectorProps?: Partial<IFileSelectorProps>;
39
+ }
40
+ export declare const validateFile: (file: Partial<IAttachment>) => {
41
+ isValid: boolean;
42
+ errorMsg: string;
43
+ };
44
+ declare function MarkdownEditor(props: IMDEditorProps): React.JSX.Element;
45
+ declare namespace MarkdownEditor {
46
+ var defaultProps: Partial<IMDEditorProps>;
47
+ }
48
+ export { MarkdownEditor };
49
+ //# sourceMappingURL=MarkdownEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownEditor.d.ts","sourceRoot":"","sources":["../../../src/MarkdownEditor/MarkdownEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,qBAAqB,CAAC;AAiC7E,OAAO,KAAK,EAAE,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAMtE,oBAAY,UAAU;IAClB,KAAK,cAAc;IACnB,QAAQ,aAAa;CACxB;AAED,UAAU,kBAAkB;IAC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