@meetelise/chat 1.77.1 → 1.77.3

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.
@@ -1236,20 +1236,25 @@ export class TourSchedulerV2 extends LitElement {
1236
1236
  ></contact-form>`;
1237
1237
  }
1238
1238
 
1239
- /** The consent text and the submit button, under the form or the itinerary. */
1239
+ /** The consent text, any booking error and the submit button, under the form or the itinerary. */
1240
1240
  private renderFooter(): TemplateResult {
1241
1241
  return html`<div
1242
1242
  id="tour-scheduler-footer"
1243
1243
  class=${classMap({ itinerary: this.extending })}
1244
1244
  >
1245
- <div class="explanation consent">
1246
- We'll send a confirmation and any follow-ups to your email address,
1247
- please reply to the email to make any appointment changes.
1248
- ${this.disclaimer()}
1249
- ${this.bookingError
1250
- ? html`<p class="error-message" role="alert">${this.bookingError}</p>`
1251
- : ""}
1252
- </div>
1245
+ ${this.extending
1246
+ ? // Adding stops sends no contact details: it books into the first
1247
+ // booking's conversation, whose form showed the consent. So, as in
1248
+ // the design, the itinerary has only its button.
1249
+ ""
1250
+ : html`<div class="explanation consent">
1251
+ We'll send a confirmation and any follow-ups to your email address,
1252
+ please reply to the email to make any appointment changes.
1253
+ ${this.disclaimer()}
1254
+ </div>`}
1255
+ ${this.bookingError
1256
+ ? html`<p class="error-message" role="alert">${this.bookingError}</p>`
1257
+ : ""}
1253
1258
  <action-confirm-button
1254
1259
  id="schedule-bttn"
1255
1260
  .onClick=${() => this.submit()}
@@ -1318,7 +1323,9 @@ export class TourSchedulerV2 extends LitElement {
1318
1323
  </p>
1319
1324
  </div>`)}
1320
1325
  <div id="tour-scheduler-footer" class="itinerary">
1321
- <div class="explanation consent">${this.disclaimer()}</div>
1326
+ ${this.extending
1327
+ ? ""
1328
+ : html`<div class="explanation consent">${this.disclaimer()}</div>`}
1322
1329
  <div class="reschedule-buttons-wrapper">
1323
1330
  <action-confirm-button
1324
1331
  id="cancel-reschedule-bttn"
@@ -1629,6 +1636,15 @@ export class TourSchedulerV2 extends LitElement {
1629
1636
  text-align: center;
1630
1637
  }
1631
1638
 
1639
+ /* The footer's gap spaces it. */
1640
+ #tour-scheduler-footer > .error-message {
1641
+ margin: 0;
1642
+ }
1643
+
1644
+ #tour-scheduler-footer.itinerary > .error-message {
1645
+ text-align: center;
1646
+ }
1647
+
1632
1648
  .consent {
1633
1649
  font-size: 10px;
1634
1650
  line-height: 14px;
@@ -27,6 +27,12 @@ it("accepts emails whose top-level domain is two or more letters", async () => {
27
27
  "o'brien_99@example-mail.io",
28
28
  "jane@例え.テスト",
29
29
  "jane@xn--80ak6aa92e.xn--p1ai",
30
+ "jane@xn--80ak6aa92e.com",
31
+ "jane@пример.рф",
32
+ "jane@example.भारत",
33
+ "jane@example.xn--h2brj9c",
34
+ "jane@xn--e1afmkfd.xn--p1ai",
35
+ "JANE@EXAMPLE.XN--P1AI",
30
36
  "JANE@EXAMPLE.COM",
31
37
  ]) {
32
38
  expect(await flagged(email), email).to.equal(false);
@@ -36,9 +42,19 @@ it("accepts emails whose top-level domain is two or more letters", async () => {
36
42
  it("rejects a one-letter or non-letter top-level domain, and what it rejected before", async () => {
37
43
  for (const email of [
38
44
  "brittney.ciesa+tc17@onmicrosoft.c",
45
+ // A one-letter Cyrillic TLD, as typed and as an email input hands it over (punycode).
46
+ "yury+tc17@onmicrosoft.с",
47
+ "yury+tc17@onmicrosoft.xn--q1a",
48
+ "yury+tc17@onmicrosoft.ю",
49
+ "yury+tc17@onmicrosoft.xn--31a",
50
+ "jane@example.xn--zz",
51
+ "jane@example.xn--com-",
52
+ "jane@example.xn--c0-9lc", // c0м, a digit between two letters
39
53
  "jane@example.c",
40
54
  "jane@example.1",
41
55
  "jane@example.c0m",
56
+ "jane@example.भा", // One letter and a vowel mark.
57
+ "jane@example.\u093eभर", // A leading vowel mark.
42
58
  "jane@example.com.",
43
59
  "jane@example",
44
60
  "jane.example.com",
@@ -454,9 +454,15 @@ it("books a tour with the prospect's details, attribution and conversation, and
454
454
  it("extends a booking without asking for contact details again, sending the booked tour as an existing stop and only the new community as a new one", async () => {
455
455
  const { bookings, communityQueries } = fakeBackend();
456
456
  const scheduler = mount();
457
+ const footerText = () =>
458
+ inScheduler(scheduler, "#tour-scheduler-footer")?.textContent ?? "";
457
459
 
460
+ await waitFor(() => inScheduler(scheduler, "contact-form"));
461
+ expect(footerText()).to.include("you consent to");
458
462
  await bookAndAddLinden(scheduler);
459
463
  expect(inScheduler(scheduler, "contact-form")).to.equal(null);
464
+ // The first booking's form showed the consent; adding a stop asks for nothing new.
465
+ expect(footerText()).not.to.include("consent");
460
466
  await submitWhenReady(scheduler);
461
467
  await waitFor(() => bookings.length === 2);
462
468
 
package/src/utils.ts CHANGED
@@ -5,6 +5,7 @@ import isObject from "lodash/isObject";
5
5
  import transform from "lodash/transform";
6
6
  import addHours from "date-fns/addHours";
7
7
  import isBefore from "date-fns/isBefore";
8
+ import { decode } from "punycode";
8
9
  import { BASE_DOMAIN } from "./globals";
9
10
 
10
11
  export const camelize = <T>(
@@ -95,13 +96,20 @@ export const isValidPhoneNumber = (phoneNumber: string): boolean => {
95
96
  return phoneNumberRegex.test(phoneNumber);
96
97
  };
97
98
 
98
- /**
99
- * Something@domain.tld, where the top-level domain is two or more letters
100
- * (any script) or an IDN's punycode form, so a typo such as "x@y.c" is caught.
101
- */
99
+ /** An email input can return an internationalized TLD in its ASCII (xn--) form. */
102
100
  export const isValidEmail = (email: string): boolean => {
103
- const emailRegex = /^[^\s@]+@[^\s@]+\.(?:\p{L}{2,}|xn--[a-z\d-]+)$/iu;
104
- return emailRegex.test(email);
101
+ const match =
102
+ /^[^\s@]+@[^\s@]+\.(?:([\p{L}\p{M}]+)|xn--([a-z\d-]*[a-z\d]))$/iu.exec(
103
+ email
104
+ );
105
+ if (!match) return false;
106
+ const [, literalTld, encodedTld] = match;
107
+ try {
108
+ const tld = encodedTld ? decode(encodedTld) : literalTld;
109
+ return /^(?:\p{L}\p{M}*){2,}$/u.test(tld);
110
+ } catch {
111
+ return false;
112
+ }
105
113
  };
106
114
 
107
115
  export const isContainingEmail = (message: string): boolean => {