@meetelise/chat 1.21.2 → 1.21.4
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.
- package/README.md +22 -0
- package/package.json +1 -1
- package/public/demo/index.html +24 -2
- package/public/dist/index.js +124 -87
- package/src/MEChat.ts +46 -0
- package/src/WebComponent/launcher/Launcher.ts +57 -0
- package/src/WebComponent/launcher/mobile-launcher.ts +3 -0
- package/src/WebComponent/launcher/typeEmojiStyles.ts +1 -1
- package/src/WebComponent/launcher/typeMiniStyles.ts +1 -1
- package/src/WebComponent/me-chat.ts +13 -0
- package/src/rentgrata.ts +74 -0
- package/src/svgIcons.ts +7 -0
package/src/MEChat.ts
CHANGED
|
@@ -140,6 +140,10 @@ export default class MEChat {
|
|
|
140
140
|
meChat.setAttribute("top", opts.position.top?.toString() || "unset");
|
|
141
141
|
meChat.setAttribute("left", opts.position.left?.toString() || "unset");
|
|
142
142
|
}
|
|
143
|
+
if (opts.overrideRentgrata) {
|
|
144
|
+
this.handleRentgrataOverride();
|
|
145
|
+
meChat.overrideRentgrata = true;
|
|
146
|
+
}
|
|
143
147
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
148
|
(window as any).eliseAi = {};
|
|
145
149
|
document.body.appendChild(meChat);
|
|
@@ -198,6 +202,47 @@ export default class MEChat {
|
|
|
198
202
|
);
|
|
199
203
|
}
|
|
200
204
|
|
|
205
|
+
static async handleRentgrataOverride(): Promise<void> {
|
|
206
|
+
const rentgrataWrapperElement = await this.waitForElement(
|
|
207
|
+
"rg-widget-compact"
|
|
208
|
+
);
|
|
209
|
+
if (!rentgrataWrapperElement) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
rentgrataWrapperElement.setAttribute("style", "display: none");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
static async waitForElement(
|
|
216
|
+
elementId: string,
|
|
217
|
+
timeout = 5000
|
|
218
|
+
): Promise<Element> {
|
|
219
|
+
return new Promise((resolve, reject) => {
|
|
220
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
221
|
+
const element = document.getElementById(elementId);
|
|
222
|
+
if (element) {
|
|
223
|
+
observer.disconnect();
|
|
224
|
+
resolve(element);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
229
|
+
|
|
230
|
+
const timeoutId = setTimeout(() => {
|
|
231
|
+
observer.disconnect();
|
|
232
|
+
reject(
|
|
233
|
+
new Error(`Element ${elementId} did not appear within ${timeout}ms`)
|
|
234
|
+
);
|
|
235
|
+
}, timeout);
|
|
236
|
+
|
|
237
|
+
const element = document.querySelector(elementId);
|
|
238
|
+
if (element) {
|
|
239
|
+
clearTimeout(timeoutId);
|
|
240
|
+
observer.disconnect();
|
|
241
|
+
resolve(element);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
201
246
|
static async handleSingleFamilyUrl(): Promise<void> {
|
|
202
247
|
if (this.hasBuildingSlug) {
|
|
203
248
|
return;
|
|
@@ -294,6 +339,7 @@ export interface Options {
|
|
|
294
339
|
mobileStyles?: StyleInfo;
|
|
295
340
|
position?: PositioningOptions;
|
|
296
341
|
onWidgetLoaded?: () => void;
|
|
342
|
+
overrideRentgrata?: boolean;
|
|
297
343
|
}
|
|
298
344
|
|
|
299
345
|
/** You can't install a font from CSS in a shadow DOM, so we use JS to do it here in the regular DOM. */
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
ChevronIconBlack,
|
|
22
22
|
ChevronIconWhite,
|
|
23
23
|
ChatBlackOutlineIcon,
|
|
24
|
+
ContactResidentBlackOutlineIcon,
|
|
24
25
|
} from "../../svgIcons";
|
|
25
26
|
import {
|
|
26
27
|
defaultBackgroundColor,
|
|
@@ -33,6 +34,12 @@ import { isMobile } from "../../utils";
|
|
|
33
34
|
import classNames from "classnames";
|
|
34
35
|
import LeadSourceClient from "../LeadSourceClient";
|
|
35
36
|
|
|
37
|
+
import {
|
|
38
|
+
closeRengrataWidget,
|
|
39
|
+
hasRentgrata,
|
|
40
|
+
openRengrataWidget,
|
|
41
|
+
} from "../../rentgrata";
|
|
42
|
+
|
|
36
43
|
@customElement("meetelise-launcher")
|
|
37
44
|
export class Launcher extends LitElement {
|
|
38
45
|
static styles = css`
|
|
@@ -135,6 +142,9 @@ export class Launcher extends LitElement {
|
|
|
135
142
|
return;
|
|
136
143
|
};
|
|
137
144
|
|
|
145
|
+
@property({ attribute: true })
|
|
146
|
+
overrideRentgrata = false;
|
|
147
|
+
|
|
138
148
|
@property({ attribute: false })
|
|
139
149
|
launcherStyles: StyleInfo = {};
|
|
140
150
|
|
|
@@ -209,6 +219,7 @@ export class Launcher extends LitElement {
|
|
|
209
219
|
onClickEmailOption = (e: MouseEvent): void => {
|
|
210
220
|
e.preventDefault();
|
|
211
221
|
e.stopPropagation();
|
|
222
|
+
closeRengrataWidget();
|
|
212
223
|
|
|
213
224
|
this.isEmailWindowOpen = true;
|
|
214
225
|
};
|
|
@@ -232,6 +243,7 @@ export class Launcher extends LitElement {
|
|
|
232
243
|
onClickPhoneOption = (e: MouseEvent): void => {
|
|
233
244
|
e.preventDefault();
|
|
234
245
|
e.stopPropagation();
|
|
246
|
+
closeRengrataWidget();
|
|
235
247
|
this.isCallUsWindowOpen = true;
|
|
236
248
|
};
|
|
237
249
|
|
|
@@ -247,6 +259,7 @@ export class Launcher extends LitElement {
|
|
|
247
259
|
onClickSSTOption = (e: MouseEvent): void => {
|
|
248
260
|
e.preventDefault();
|
|
249
261
|
e.stopPropagation();
|
|
262
|
+
closeRengrataWidget();
|
|
250
263
|
this.isSSTWindowOpen = true;
|
|
251
264
|
};
|
|
252
265
|
|
|
@@ -317,6 +330,7 @@ export class Launcher extends LitElement {
|
|
|
317
330
|
.onClickPhoneOption=${this.onClickPhoneOption}
|
|
318
331
|
.onClickSSTOption=${this.onClickSSTOption}
|
|
319
332
|
.onChatTapped=${this.onChatTapped}
|
|
333
|
+
.overrideRentgrata=${this.overrideRentgrata}
|
|
320
334
|
.isMobileDesign=${isMobile() ||
|
|
321
335
|
this.designConcept === DesignConcepts.MINIMIZED}
|
|
322
336
|
.brandColor=${this.brandColor}
|
|
@@ -460,6 +474,26 @@ export class Launcher extends LitElement {
|
|
|
460
474
|
</div>
|
|
461
475
|
</div>`
|
|
462
476
|
: ""}
|
|
477
|
+
${this.overrideRentgrata && hasRentgrata()
|
|
478
|
+
? html`
|
|
479
|
+
<div
|
|
480
|
+
class="type-hey__pill"
|
|
481
|
+
@click=${() => {
|
|
482
|
+
openRengrataWidget();
|
|
483
|
+
}}
|
|
484
|
+
style=${styleMap({
|
|
485
|
+
background: this.backgroundColor,
|
|
486
|
+
})}>
|
|
487
|
+
<div class="type-hey__pill-left">
|
|
488
|
+
<div class="type-hey__icon">${ContactResidentBlackOutlineIcon}</div>
|
|
489
|
+
<div>
|
|
490
|
+
<span class="title-bold">Contact</span> a resident
|
|
491
|
+
</div>
|
|
492
|
+
</div>
|
|
493
|
+
<div class="type-gradient__icon">${ChevronIconBlack}</div>
|
|
494
|
+
</div>
|
|
495
|
+
</div>`
|
|
496
|
+
: ""}
|
|
463
497
|
</div>
|
|
464
498
|
|
|
465
499
|
<div class="type-hey__bottom-info">
|
|
@@ -680,6 +714,29 @@ export class Launcher extends LitElement {
|
|
|
680
714
|
</div>
|
|
681
715
|
`
|
|
682
716
|
: ""}
|
|
717
|
+
${this.overrideRentgrata && hasRentgrata()
|
|
718
|
+
? html`
|
|
719
|
+
<div
|
|
720
|
+
@click=${() => {
|
|
721
|
+
openRengrataWidget();
|
|
722
|
+
}}
|
|
723
|
+
class="inner-pill-wrapper"
|
|
724
|
+
style=${styleMap({
|
|
725
|
+
background: this.backgroundColor,
|
|
726
|
+
})}
|
|
727
|
+
>
|
|
728
|
+
<div class="vertical-pill-left">
|
|
729
|
+
<div class="vertical-pill-icon">
|
|
730
|
+
${ContactResidentBlackOutlineIcon}
|
|
731
|
+
</div>
|
|
732
|
+
<div class="vertical-pill-title">
|
|
733
|
+
<span class="vertical-pill-bold">Contact</span> a resident
|
|
734
|
+
</div>
|
|
735
|
+
</div>
|
|
736
|
+
<div class="chevron-right">${ChevronIconBlack}</div>
|
|
737
|
+
</div>
|
|
738
|
+
`
|
|
739
|
+
: ""}
|
|
683
740
|
</div>`;
|
|
684
741
|
};
|
|
685
742
|
|
|
@@ -63,6 +63,9 @@ export class MobileLauncher extends LitElement {
|
|
|
63
63
|
@property({ attribute: true })
|
|
64
64
|
hasSSTEnabled = false;
|
|
65
65
|
|
|
66
|
+
@property({ attribute: true })
|
|
67
|
+
overrideRentgrata = false;
|
|
68
|
+
|
|
66
69
|
private renderListElement = (
|
|
67
70
|
isEnabled: boolean,
|
|
68
71
|
onClick: (e: MouseEvent) => void,
|
|
@@ -56,6 +56,7 @@ import LeadSourceClient, {
|
|
|
56
56
|
getDefaultLeadSourceAttribution,
|
|
57
57
|
} from "./LeadSourceClient";
|
|
58
58
|
import noop from "lodash/noop";
|
|
59
|
+
import { updateRentgrataToken } from "../rentgrata";
|
|
59
60
|
|
|
60
61
|
@customElement("me-chat")
|
|
61
62
|
export class MEChat extends LitElement {
|
|
@@ -179,6 +180,9 @@ export class MEChat extends LitElement {
|
|
|
179
180
|
@property({ type: Number })
|
|
180
181
|
private left = undefined;
|
|
181
182
|
|
|
183
|
+
@property({ attribute: true })
|
|
184
|
+
overrideRentgrata = false;
|
|
185
|
+
|
|
182
186
|
@property()
|
|
183
187
|
onWidgetLoaded: () => void = noop;
|
|
184
188
|
|
|
@@ -223,6 +227,14 @@ export class MEChat extends LitElement {
|
|
|
223
227
|
private setupWebchat = async (): Promise<void> => {
|
|
224
228
|
if (!this.buildingSlug || !this.orgSlug) return;
|
|
225
229
|
const building = await fetchBuildingInfo(this.orgSlug, this.buildingSlug);
|
|
230
|
+
if (Math.random() < 0.2) {
|
|
231
|
+
try {
|
|
232
|
+
updateRentgrataToken(this.buildingSlug, this.orgSlug);
|
|
233
|
+
} catch (e) {
|
|
234
|
+
// eslint-disable-next-line no-console
|
|
235
|
+
console.warn("Error updating rentgrata token", e);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
226
238
|
if (building.conversationMaintenanceMode) {
|
|
227
239
|
// eslint-disable-next-line no-console
|
|
228
240
|
console.warn(
|
|
@@ -777,6 +789,7 @@ export class MEChat extends LitElement {
|
|
|
777
789
|
.backgroundColor=${this.backgroundColor}
|
|
778
790
|
.isMinimized=${this.isMinimized}
|
|
779
791
|
.onClickMinimize=${this.onClickMinimize}
|
|
792
|
+
.overrideRentgrata=${this.overrideRentgrata}
|
|
780
793
|
.autoOpenChatWidget=${this.building.autoOpenChatWidget ??
|
|
781
794
|
false}
|
|
782
795
|
.mobileStyles=${isMobile() || this.isMinimized
|
package/src/rentgrata.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
export const openRengrataWidget = (): void => {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
const rentgrata = (window as any).rentgrata;
|
|
6
|
+
if (!rentgrata) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const rentgrataWidget = rentgrata.Widget;
|
|
10
|
+
if (!rentgrataWidget) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!rentgrataWidget.openWidget) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
rentgrataWidget.openWidget();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const closeRengrataWidget = (): void => {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const rentgrata = (window as any).rentgrata;
|
|
22
|
+
if (!rentgrata) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const rentgrataWidget = rentgrata.Widget;
|
|
26
|
+
if (!rentgrataWidget) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!rentgrataWidget.openWidget) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
rentgrataWidget.close();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const hasRentgrata = (): boolean => {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
return !!(window as any).rentgrata;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const updateRentgrataToken = async (
|
|
41
|
+
buildingSlug: string,
|
|
42
|
+
orgSlug: string
|
|
43
|
+
): Promise<void> => {
|
|
44
|
+
const host = "https://app.meetelise.com";
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
const rentgrata = (window as any).rentgrata;
|
|
47
|
+
if (!rentgrata) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const rentgrataWidget = rentgrata.Widget;
|
|
51
|
+
if (!rentgrataWidget) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const rentgrataConfig = rentgrataWidget.config;
|
|
55
|
+
if (!rentgrataConfig) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const widgetKey = rentgrataConfig.widgetKey;
|
|
60
|
+
if (!widgetKey) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
await axios.post(
|
|
64
|
+
`${host}/platformApi/webchat/rentgrata?token=${widgetKey}`,
|
|
65
|
+
{},
|
|
66
|
+
{
|
|
67
|
+
headers: {
|
|
68
|
+
"Content-Type": "application/json",
|
|
69
|
+
"building-slug": buildingSlug ?? "",
|
|
70
|
+
"org-slug": orgSlug ?? "",
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
};
|
package/src/svgIcons.ts
CHANGED
|
@@ -24,6 +24,13 @@ export const BookTourBlackOutlineIcon = svg`<svg xmlns="http://www.w3.org/2000/s
|
|
|
24
24
|
<path d="M15.689 6.11862V6.22322C15.689 6.19053 15.689 6.15131 15.6825 6.11862H15.689Z" fill="white"/>
|
|
25
25
|
<path d="M4.74594 11.9562L6.56326 13.7735C6.8182 14.0285 7.23004 14.0285 7.48499 13.7735L10.9366 10.3219" stroke="black" stroke-miterlimit="10" stroke-linecap="round"/>
|
|
26
26
|
</svg>`;
|
|
27
|
+
|
|
28
|
+
export const ContactResidentBlackOutlineIcon = svg`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
29
|
+
<path d="M6 6C7.65685 6 9 4.65685 9 3C9 1.34315 7.65685 0 6 0C4.34315 0 3 1.34315 3 3C3 4.65685 4.34315 6 6 6ZM8 3C8 4.10457 7.10457 5 6 5C4.89543 5 4 4.10457 4 3C4 1.89543 4.89543 1 6 1C7.10457 1 8 1.89543 8 3Z" fill="black"/>
|
|
30
|
+
<path d="M12 11C12 12 11 12 11 12H1C1 12 0 12 0 11C0 10 1 7 6 7C11 7 12 10 12 11ZM11 10.9965C10.9986 10.7497 10.8462 10.0104 10.1679 9.33211C9.51563 8.67985 8.2891 8 5.99999 8C3.71088 8 2.48435 8.67985 1.8321 9.33211C1.15375 10.0104 1.00142 10.7497 1 10.9965H11Z" fill="black"/>
|
|
31
|
+
</svg>
|
|
32
|
+
`;
|
|
33
|
+
|
|
27
34
|
export const PhoneBlackOutlineIcon = svg`<svg xmlns="http://www.w3.org/2000/svg" width="14" height="17" viewBox="0 0 14 17" fill="none">
|
|
28
35
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.95487 2.54301e-07H7.04513C8.51534 -1.22821e-05 9.67985 -2.22686e-05 10.5912 0.121084C11.5292 0.24572 12.2883 0.508324 12.887 1.10005C13.4857 1.69178 13.7514 2.44211 13.8775 3.36914C14 4.26992 14 5.42089 14 6.874V10.126C14 11.5791 14 12.7301 13.8775 13.6309C13.7514 14.5579 13.4857 15.3082 12.887 15.8999C12.2883 16.4917 11.5292 16.7543 10.5912 16.8789C9.67985 17 8.51534 17 7.04513 17H6.95487C5.48466 17 4.32015 17 3.40878 16.8789C2.47084 16.7543 1.71169 16.4917 1.11299 15.8999C0.514304 15.3082 0.248611 14.5579 0.122508 13.6309C-2.25306e-05 12.7301 -1.24266e-05 11.5791 2.57292e-07 10.126V6.87399C-1.24266e-05 5.42088 -2.25306e-05 4.26992 0.122508 3.36914C0.248611 2.44211 0.514304 1.69178 1.11299 1.10005C1.71169 0.508324 2.47084 0.24572 3.40878 0.121084C4.32015 -2.22686e-05 5.48466 -1.22821e-05 6.95487 2.54301e-07ZM2.85118 1.44157C2.45996 1.55714 2.18378 1.71904 1.96152 1.93871C1.62295 2.27335 1.42002 2.73167 1.31181 3.52718C1.20127 4.33975 1.2 5.41089 1.2 6.9186V10.0814C1.2 11.5891 1.20127 12.6602 1.31181 13.4728C1.42002 14.2683 1.62295 14.7267 1.96152 15.0613C2.30009 15.3959 2.76381 15.5965 3.56868 15.7034C4.39081 15.8127 5.47454 15.814 7 15.814C8.52546 15.814 9.60919 15.8127 10.4313 15.7034C11.2362 15.5965 11.6999 15.3959 12.0385 15.0613C12.377 14.7267 12.58 14.2683 12.6882 13.4728C12.7987 12.6602 12.8 11.5891 12.8 10.0814V6.9186C12.8 5.41089 12.7987 4.33975 12.6882 3.52718C12.58 2.73167 12.377 2.27335 12.0385 1.93871C11.8162 1.71905 11.54 1.55714 11.1488 1.44157C10.6194 2.22728 10.2493 2.77349 9.69896 3.1115C9.58916 3.17894 9.47507 3.23928 9.3574 3.29217C8.76366 3.55903 8.09363 3.55868 7.12834 3.55818C7.08613 3.55816 7.04336 3.55814 7 3.55814C6.95664 3.55814 6.91387 3.55816 6.87166 3.55818C5.90637 3.55868 5.23634 3.55903 4.6426 3.29217C4.52493 3.23928 4.41084 3.17894 4.30104 3.1115C3.75069 2.77349 3.38057 2.22729 2.85118 1.44157ZM4.16103 1.2383C4.51629 1.74715 4.70232 1.96157 4.9344 2.10411C5.00028 2.14457 5.06873 2.18078 5.13933 2.21251C5.46646 2.35954 5.85406 2.37209 7 2.37209C8.14594 2.37209 8.53354 2.35954 8.86066 2.21251C8.93127 2.18078 8.99972 2.14457 9.0656 2.10411C9.29768 1.96157 9.48371 1.74715 9.83897 1.2383C9.10278 1.18681 8.18457 1.18605 7 1.18605C5.81543 1.18605 4.89722 1.18681 4.16103 1.2383ZM4 14.0349C4 13.7074 4.26863 13.4419 4.6 13.4419H9.4C9.73137 13.4419 10 13.7074 10 14.0349C10 14.3624 9.73137 14.6279 9.4 14.6279H4.6C4.26863 14.6279 4 14.3624 4 14.0349Z" fill="black"/>
|
|
29
36
|
</svg>`;
|