@meetelise/chat 1.20.82 → 1.20.84

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/src/MEChat.ts CHANGED
@@ -249,17 +249,27 @@ const overrideContactUsForm = async (
249
249
  return false;
250
250
  };
251
251
 
252
+ const validateFormElements = () => {
253
+ Object.values(getFormElements()).forEach((el) => {
254
+ if (el?.getAttribute("aria-required") === "true" && !el.value) {
255
+ el.className = "form-control required is-invalid";
256
+ }
257
+ });
258
+ };
259
+
252
260
  const isValid = () => {
253
261
  return Object.values(getFormElements()).every((el) => {
254
262
  if (el === null) return false;
255
- if (el.getAttribute("aria-invalid") === null) {
256
- logContactUsFormError(
257
- buildingSlug,
258
- orgSlug,
259
- "Missing aria-invalid attribute on " + el.id
260
- );
263
+ if (el.getAttribute("aria-required") === "true" && !el.value) {
264
+ return false;
261
265
  }
262
- return el.getAttribute("aria-invalid") !== "true";
266
+ if (
267
+ (el.id === "email" || el.id === "phonenumber") &&
268
+ el.getAttribute("aria-invalid") === "true"
269
+ ) {
270
+ return false;
271
+ }
272
+ return true;
263
273
  });
264
274
  };
265
275
 
@@ -280,6 +290,8 @@ const overrideContactUsForm = async (
280
290
  btn.parentNode?.replaceChild(clonedButton, btn);
281
291
 
282
292
  clonedButton.onclick = async function (event) {
293
+ validateFormElements();
294
+
283
295
  if (!isValid()) return;
284
296
  event.preventDefault();
285
297
 
@@ -33,6 +33,7 @@ import { classMap } from "lit/directives/class-map.js";
33
33
  import postLeadSources from "../../postLeadSources";
34
34
  import { FeatureFlagsShowDropdown } from "../../fetchFeatureFlag";
35
35
  import { pushGtmEvent } from "../../gtm";
36
+ import disclaimer from "../../disclaimers";
36
37
 
37
38
  const getHumanReadableLayout = (layout: string) => {
38
39
  if (layout == "studio") return "Studio";
@@ -72,6 +73,10 @@ export class TourScheduler extends LitElement {
72
73
  virtualToursLink = "";
73
74
  @property({ attribute: true })
74
75
  orgSlug = "";
76
+
77
+ @property({ attribute: true })
78
+ buildingName = "";
79
+
75
80
  onCloseClicked?: (e: MouseEvent) => void;
76
81
 
77
82
  @state()
@@ -621,7 +626,7 @@ export class TourScheduler extends LitElement {
621
626
  margin: 0;
622
627
  }
623
628
 
624
- p {
629
+ .explanation {
625
630
  font-weight: 400;
626
631
  font-size: 12px;
627
632
  grid-row: 7;
@@ -630,6 +635,9 @@ export class TourScheduler extends LitElement {
630
635
  margin: 0;
631
636
  padding-top: 32px;
632
637
  }
638
+ .withDisclaimer {
639
+ padding-top: 16px;
640
+ }
633
641
 
634
642
  #schedule {
635
643
  width: 145px;
@@ -1336,10 +1344,20 @@ export class TourScheduler extends LitElement {
1336
1344
  : html`${this.tourTypeMenu()} ${this.dateAndTimeMenu()}
1337
1345
  ${this.userInfoAndLayoutMenu()}
1338
1346
  <hr />
1339
- <p id="explanation">
1347
+ <p
1348
+ class=${this.phoneInput?.value || this.emailInput?.value
1349
+ ? "explanation withDisclaimer"
1350
+ : "explanation"}
1351
+ >
1340
1352
  We’ll send a confirmation and any follow-ups to your email
1341
1353
  address.
1354
+ ${disclaimer({
1355
+ buildingName: this.buildingName,
1356
+ phoneNumberInput: this.phoneInput?.value,
1357
+ emailInput: this.emailInput?.value,
1358
+ })}
1342
1359
  </p>
1360
+
1343
1361
  <action-confirm-button
1344
1362
  id="schedule"
1345
1363
  .onClick=${this.submit}
@@ -1383,6 +1401,15 @@ export class TourScheduler extends LitElement {
1383
1401
  ${currentPage.nextButtonText}
1384
1402
  </button>`
1385
1403
  : currentPage.renderNextButton()}`}
1404
+ ${this.mobilePageIndex + 1 === this.mobilePages.length
1405
+ ? html`
1406
+ ${disclaimer({
1407
+ buildingName: this.buildingName,
1408
+ phoneNumberInput: this.phoneInput?.value,
1409
+ emailInput: this.emailInput?.value,
1410
+ })}
1411
+ `
1412
+ : html``}
1386
1413
  </div>
1387
1414
  `;
1388
1415
  }
@@ -16,6 +16,7 @@ import { InputStyles } from "./InputStyles";
16
16
  import axios from "axios";
17
17
  import { FeatureFlagsShowDropdown } from "../../fetchFeatureFlag";
18
18
  import { pushGtmEvent } from "../../gtm";
19
+ import disclaimer from "../../disclaimers";
19
20
 
20
21
  @customElement("email-us-window")
21
22
  export class EmailUsWindow extends LitElement {
@@ -100,6 +101,8 @@ export class EmailUsWindow extends LitElement {
100
101
  buildingSlug = "";
101
102
  @property({ attribute: true })
102
103
  orgSlug = "";
104
+ @property({ attribute: true })
105
+ buildingName = "";
103
106
 
104
107
  @property({ attribute: true })
105
108
  featureFlagShowDropdown = "";
@@ -446,6 +449,12 @@ export class EmailUsWindow extends LitElement {
446
449
  `
447
450
  : ""}
448
451
  </div>
452
+
453
+ ${disclaimer({
454
+ buildingName: this.buildingName,
455
+ phoneNumberInput: this.phoneNumber,
456
+ emailInput: this.email,
457
+ })}
449
458
  </details-window>
450
459
  `;
451
460
  };
@@ -60,6 +60,8 @@ export class Launcher extends LitElement {
60
60
  @property()
61
61
  phoneNumber = "";
62
62
  @property({ attribute: true })
63
+ buildingName = "";
64
+ @property({ attribute: true })
63
65
  chatId = "";
64
66
  @property({ attribute: true })
65
67
  chatCallUsHeader = "";
@@ -528,6 +530,7 @@ export class Launcher extends LitElement {
528
530
  featureFlagShowDropdown="${this.featureFlagShowDropdown}"
529
531
  ${ref(this.emailUsWindowRef)}
530
532
  .buildingId=${this.buildingId}
533
+ .buildingName=${this.buildingName}
531
534
  >
532
535
  </email-us-window>
533
536
  </div>`
@@ -559,6 +562,7 @@ export class Launcher extends LitElement {
559
562
  .tourTypeOptions=${this.tourTypeOptions}
560
563
  buildingId=${this.buildingId}
561
564
  featureFlagShowDropdown="${this.featureFlagShowDropdown}"
565
+ .buildingName=${this.buildingName}
562
566
  ${ref(this.tourSchedulerRef)}
563
567
  ></tour-scheduler>
564
568
  </div>`
@@ -534,6 +534,7 @@ export class MEChat extends LitElement {
534
534
  phoneNumber="${this.phoneNumberForSource?.number ??
535
535
  this.building?.phoneNumber ??
536
536
  ""}"
537
+ buildingName=${this.building?.name ?? ""}
537
538
  textColor="${this.theme.chatHeader.textColor}"
538
539
  backgroundColor="${this.theme.chatPaneBackgroundColor}"
539
540
  orgSlug="${this.orgSlug}"
@@ -0,0 +1,56 @@
1
+ import { html, TemplateResult } from "lit";
2
+ import { styleMap } from "lit/directives/style-map.js";
3
+
4
+ const disclaimerStyles = {
5
+ container: {
6
+ fontSize: "10px",
7
+ paddingTop: "4px",
8
+ },
9
+ link: {
10
+ color: "#4287f5",
11
+ },
12
+ };
13
+
14
+ const disclaimer = ({
15
+ buildingName,
16
+ phoneNumberInput,
17
+ emailInput,
18
+ }: {
19
+ buildingName: string;
20
+ phoneNumberInput?: string;
21
+ emailInput?: string;
22
+ }): TemplateResult => {
23
+ if (phoneNumberInput) {
24
+ return html` <div style=${styleMap(disclaimerStyles.container)}>
25
+ By providing your number and clicking submit, you consent to recurring
26
+ marketing text messages from or for
27
+ ${buildingName.length > 0 ? buildingName : "this building"} at this
28
+ number, which may be sent by an autodialer system. Replies may be AI or
29
+ human generated. This consent is not required to lease at this property.
30
+ Msg & Data rates may apply. You consent to this
31
+ <a
32
+ style=${styleMap(disclaimerStyles.link)}
33
+ href="http://bit.ly/me_privacy_policy"
34
+ target="_blank"
35
+ rel="noopener noreferrer"
36
+ >privacy policy</a
37
+ >, including having your communications recorded by a third party.
38
+ </div>`;
39
+ }
40
+ if (emailInput) {
41
+ return html` <div style=${styleMap(disclaimerStyles.container)}>
42
+ By entering your email and clicking submit, you consent to this
43
+ <a
44
+ style=${styleMap(disclaimerStyles.link)}
45
+ href="http://bit.ly/me_privacy_policy"
46
+ target="_blank"
47
+ rel="noopener noreferrer"
48
+ >privacy policy</a
49
+ >, including having your email address and communications collected and
50
+ recorded by a third party.
51
+ </div>`;
52
+ }
53
+ return html``;
54
+ };
55
+
56
+ export default disclaimer;