@meetelise/chat 1.62.0 → 1.63.1
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/dist/src/WebComponent/Scheduler/date-picker.d.ts +9 -1
- package/dist/src/WebComponent/Scheduler/tour-type-option.d.ts +2 -0
- package/dist/src/WebComponent/actions/call-us-window.d.ts +0 -2
- package/dist/src/WebComponent/actions/email-us-window.d.ts +1 -2
- package/dist/src/WebComponent/icons/CalendarCheckIcon.d.ts +2 -0
- package/dist/src/WebComponent/icons/CheckCircleIcon.d.ts +2 -0
- package/dist/src/WebComponent/pubnub-chat.d.ts +5 -0
- package/package.json +1 -1
- package/public/dist/index.js +310 -175
- package/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles.ts +9 -0
- package/src/WebComponent/Scheduler/date-picker.ts +85 -1
- package/src/WebComponent/Scheduler/tour-scheduler.ts +2 -2
- package/src/WebComponent/Scheduler/tour-type-option.ts +66 -7
- package/src/WebComponent/Scheduler/tourSchedulerStyles.ts +14 -0
- package/src/WebComponent/actions/action-confirm-button.ts +3 -2
- package/src/WebComponent/actions/call-us-window.ts +12 -8
- package/src/WebComponent/actions/email-us-window.ts +12 -6
- package/src/WebComponent/icons/CalendarCheckIcon.ts +18 -0
- package/src/WebComponent/icons/CheckCircleIcon.ts +22 -0
- package/src/WebComponent/pubnub-chat.ts +14 -0
- package/src/overlayFocus.test.ts +102 -0
|
@@ -36,6 +36,15 @@ const floorplanImageCardStyles = css`
|
|
|
36
36
|
background-color: #f0f7ff;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/* A card that can't be chosen right now (the tour scheduler's community cards). */
|
|
40
|
+
.floorplan-image-card.disabled {
|
|
41
|
+
opacity: 0.5;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.floorplan-image-card.disabled .section-right {
|
|
45
|
+
cursor: not-allowed;
|
|
46
|
+
}
|
|
47
|
+
|
|
39
48
|
.section-right {
|
|
40
49
|
flex: 1 1 auto;
|
|
41
50
|
display: flex;
|
|
@@ -3,7 +3,7 @@ import format from "date-fns/format";
|
|
|
3
3
|
import getDate from "date-fns/getDate";
|
|
4
4
|
import getMonth from "date-fns/getMonth";
|
|
5
5
|
import getYear from "date-fns/getYear";
|
|
6
|
-
import { LitElement, html, TemplateResult, css } from "lit";
|
|
6
|
+
import { LitElement, html, TemplateResult, css, PropertyValues } from "lit";
|
|
7
7
|
import { customElement, property, state } from "lit/decorators.js";
|
|
8
8
|
import { classMap } from "lit/directives/class-map.js";
|
|
9
9
|
import {
|
|
@@ -36,6 +36,25 @@ export class DatePicker extends LitElement {
|
|
|
36
36
|
@property({ attribute: true })
|
|
37
37
|
defaultDate?: Date;
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Optional "yyyy-MM": show that month, and move there each time it changes.
|
|
41
|
+
* Left unset, the calendar opens on the current month as before.
|
|
42
|
+
*/
|
|
43
|
+
@property({ attribute: false })
|
|
44
|
+
shownMonth?: string;
|
|
45
|
+
|
|
46
|
+
protected willUpdate(changedProperties: PropertyValues): void {
|
|
47
|
+
if (changedProperties.has("shownMonth") && this.shownMonth) {
|
|
48
|
+
const [year, month] = this.shownMonth.split("-").map(Number);
|
|
49
|
+
this.yearShown = year;
|
|
50
|
+
this.monthShown = month - 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Tour-scheduler-v2's look: white and bordered, open days tinted with the brand colour. */
|
|
55
|
+
@property({ type: Boolean, reflect: true })
|
|
56
|
+
outlined = false;
|
|
57
|
+
|
|
39
58
|
@property({ attribute: false })
|
|
40
59
|
availabilities?: {
|
|
41
60
|
[day: string]: Date[];
|
|
@@ -256,6 +275,71 @@ export class DatePicker extends LitElement {
|
|
|
256
275
|
.dayNumber:is(.differentMonth, .past, .noAvailabilities) {
|
|
257
276
|
opacity: 30%;
|
|
258
277
|
}
|
|
278
|
+
|
|
279
|
+
/* Only with the outlined attribute, which today's scheduler doesn't set. */
|
|
280
|
+
:host([outlined]) #calendar {
|
|
281
|
+
background: #ffffff;
|
|
282
|
+
border: 1px solid #e7e7e7;
|
|
283
|
+
border-radius: 8px;
|
|
284
|
+
max-width: 18rem;
|
|
285
|
+
min-width: 0;
|
|
286
|
+
padding: 12px;
|
|
287
|
+
width: 100%;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@media screen and (max-width: 767px) {
|
|
291
|
+
:host([outlined]) #calendar {
|
|
292
|
+
max-width: none;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
:host([outlined]) #rows {
|
|
297
|
+
gap: 6px;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
:host([outlined]) .dayNumber {
|
|
301
|
+
height: 28px;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
:host([outlined]) .dayNumber:not(:disabled) {
|
|
305
|
+
cursor: pointer;
|
|
306
|
+
z-index: 1;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
:host([outlined]) .dayNumber:not(:disabled):not(.selected)::after {
|
|
310
|
+
background-color: color-mix(
|
|
311
|
+
in srgb,
|
|
312
|
+
var(--primary-color, #202020) 12%,
|
|
313
|
+
#ffffff
|
|
314
|
+
);
|
|
315
|
+
aspect-ratio: 1;
|
|
316
|
+
border: none;
|
|
317
|
+
border-radius: 50%;
|
|
318
|
+
content: "";
|
|
319
|
+
height: 28px;
|
|
320
|
+
left: 50%;
|
|
321
|
+
position: absolute;
|
|
322
|
+
top: 50%;
|
|
323
|
+
transform: translate(-50%, -50%);
|
|
324
|
+
z-index: -1;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
:host([outlined]) .dayNumber:not(:disabled):not(.selected):hover::after {
|
|
328
|
+
background-color: color-mix(
|
|
329
|
+
in srgb,
|
|
330
|
+
var(--primary-color, #202020) 24%,
|
|
331
|
+
#ffffff
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
:host([outlined]) .dayNumber.selected::after {
|
|
336
|
+
background-color: var(--primary-color, #202020);
|
|
337
|
+
height: 28px;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
:host([outlined]) .dayNumber.selected {
|
|
341
|
+
color: var(--on-primary-color, #ffffff);
|
|
342
|
+
}
|
|
259
343
|
`;
|
|
260
344
|
|
|
261
345
|
render(): TemplateResult {
|
|
@@ -78,7 +78,7 @@ import { readGoogleReserveReferral } from "../../googleReserve";
|
|
|
78
78
|
import fetchBuildingUnitsSummary, {
|
|
79
79
|
UnitSummary,
|
|
80
80
|
} from "../../fetchBuildingUnitsSummary";
|
|
81
|
-
import {
|
|
81
|
+
import { placeFocusInside, trapTabInside } from "../pubnub-chat";
|
|
82
82
|
|
|
83
83
|
@customElement("tour-scheduler")
|
|
84
84
|
export class TourScheduler extends LitElement {
|
|
@@ -167,7 +167,7 @@ export class TourScheduler extends LitElement {
|
|
|
167
167
|
|
|
168
168
|
updated(): void {
|
|
169
169
|
if (this.movedFocusInside) return;
|
|
170
|
-
if (
|
|
170
|
+
if (placeFocusInside(this)) {
|
|
171
171
|
this.movedFocusInside = true;
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
@@ -13,6 +13,9 @@ export class TourTypeOption extends LitElement {
|
|
|
13
13
|
subtitle = "";
|
|
14
14
|
@property({ type: Boolean })
|
|
15
15
|
selected = false;
|
|
16
|
+
/** A white row with the icon on the left, marked by a brand-colour tint when selected. */
|
|
17
|
+
@property({ type: Boolean, reflect: true })
|
|
18
|
+
outlined = false;
|
|
16
19
|
@property({ attribute: false })
|
|
17
20
|
onClick?: () => void;
|
|
18
21
|
|
|
@@ -77,6 +80,52 @@ export class TourTypeOption extends LitElement {
|
|
|
77
80
|
.subtitle {
|
|
78
81
|
font-weight: 400;
|
|
79
82
|
}
|
|
83
|
+
|
|
84
|
+
:host([outlined]) .tour-type-option,
|
|
85
|
+
:host([outlined][selected]) .tour-type-option {
|
|
86
|
+
background: #ffffff;
|
|
87
|
+
border: 1px solid #e7e7e7;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
height: auto;
|
|
90
|
+
padding: 10px 12px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:host([outlined]) .content {
|
|
94
|
+
justify-content: flex-start;
|
|
95
|
+
gap: 12px;
|
|
96
|
+
position: static;
|
|
97
|
+
transform: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
:host([outlined]) .icon {
|
|
101
|
+
align-items: center;
|
|
102
|
+
background: #f8f9fa;
|
|
103
|
+
border-radius: 8px;
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-shrink: 0;
|
|
106
|
+
height: 40px;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
width: 40px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:host([outlined]) ::slotted(svg) {
|
|
112
|
+
height: 20px;
|
|
113
|
+
width: 20px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:host([outlined]) .text,
|
|
117
|
+
:host([outlined][selected]) .text {
|
|
118
|
+
color: #202020;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:host([outlined]) .heading {
|
|
122
|
+
font-weight: 400;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:host([outlined]) .subtitle {
|
|
126
|
+
color: #737373;
|
|
127
|
+
font-size: 13px;
|
|
128
|
+
}
|
|
80
129
|
`,
|
|
81
130
|
];
|
|
82
131
|
|
|
@@ -88,18 +137,28 @@ export class TourTypeOption extends LitElement {
|
|
|
88
137
|
tabindex="0"
|
|
89
138
|
aria-checked=${this.selected ? "true" : "false"}
|
|
90
139
|
aria-label="${this.heading} ${this.subtitle}"
|
|
91
|
-
style=${styleMap(
|
|
92
|
-
|
|
93
|
-
|
|
140
|
+
style=${styleMap(
|
|
141
|
+
this.outlined
|
|
142
|
+
? {
|
|
143
|
+
background: this.selected
|
|
144
|
+
? `color-mix(in srgb, ${this.primaryColor} 8%, #ffffff)`
|
|
145
|
+
: undefined,
|
|
146
|
+
"border-color": this.selected ? this.primaryColor : undefined,
|
|
147
|
+
}
|
|
148
|
+
: { background: this.selected ? this.primaryColor : undefined }
|
|
149
|
+
)}
|
|
94
150
|
>
|
|
95
151
|
<div class="content">
|
|
96
|
-
|
|
152
|
+
${this.outlined
|
|
153
|
+
? html`<span class="icon"><slot name="icon"></slot></span>`
|
|
154
|
+
: html`<slot name="icon"></slot>`}
|
|
97
155
|
<div
|
|
98
156
|
class="text"
|
|
99
157
|
style=${styleMap({
|
|
100
|
-
color:
|
|
101
|
-
|
|
102
|
-
|
|
158
|
+
color:
|
|
159
|
+
this.selected && !this.outlined
|
|
160
|
+
? this.foregroundColorOnPrimaryBackgroundColor
|
|
161
|
+
: undefined,
|
|
103
162
|
})}
|
|
104
163
|
>
|
|
105
164
|
<span class="heading">${this.heading}</span>
|
|
@@ -338,6 +338,20 @@ otherwise there's some empty space at the bottom of the button, which interferes
|
|
|
338
338
|
font-size: 14px;
|
|
339
339
|
padding-right: 24px;
|
|
340
340
|
}
|
|
341
|
+
|
|
342
|
+
/* A footer whose button sits under its text (tour-scheduler-v2 on phones). */
|
|
343
|
+
#tour-scheduler-footer.stacked {
|
|
344
|
+
align-items: stretch;
|
|
345
|
+
flex-direction: column;
|
|
346
|
+
gap: 8px;
|
|
347
|
+
padding-bottom: 12px;
|
|
348
|
+
padding-top: 12px;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#tour-scheduler-footer.stacked .explanation {
|
|
352
|
+
font-size: 12px;
|
|
353
|
+
padding-right: 0;
|
|
354
|
+
}
|
|
341
355
|
#schedule {
|
|
342
356
|
width: 145px;
|
|
343
357
|
height: 50px;
|
|
@@ -16,7 +16,8 @@ export class ActionConfirmButton extends LitElement {
|
|
|
16
16
|
justify-content: center;
|
|
17
17
|
align-items: center;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
/* Black unless a surrounding page sets these, as the v2 scheduler does. */
|
|
20
|
+
background: var(--action-confirm-button-background, #000000);
|
|
20
21
|
border: none;
|
|
21
22
|
|
|
22
23
|
border-radius: 20px;
|
|
@@ -27,7 +28,7 @@ export class ActionConfirmButton extends LitElement {
|
|
|
27
28
|
font-size: 12px;
|
|
28
29
|
line-height: 20px;
|
|
29
30
|
|
|
30
|
-
color: #ffffff;
|
|
31
|
+
color: var(--action-confirm-button-color, #ffffff);
|
|
31
32
|
padding: 5px 15px;
|
|
32
33
|
cursor: pointer;
|
|
33
34
|
}
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "../LeadSourceMultitouchClient";
|
|
18
18
|
|
|
19
19
|
import { getOfficeHourText } from "../OfficeHours";
|
|
20
|
-
import {
|
|
20
|
+
import { placeFocusInside, trapTabInside } from "../pubnub-chat";
|
|
21
21
|
import {
|
|
22
22
|
formatToUsPhoneInput,
|
|
23
23
|
isModifierKey,
|
|
@@ -47,13 +47,6 @@ export class CallUsWindow extends LitElement {
|
|
|
47
47
|
trapTabInside(event, this);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
private movedFocusInside = false;
|
|
51
|
-
|
|
52
|
-
updated(): void {
|
|
53
|
-
if (this.movedFocusInside) return;
|
|
54
|
-
if (focusFirstTabStop(this)) this.movedFocusInside = true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
50
|
static styles = [
|
|
58
51
|
InputStyles,
|
|
59
52
|
css`
|
|
@@ -225,7 +218,18 @@ export class CallUsWindow extends LitElement {
|
|
|
225
218
|
| { dayOfWeek: string; startTime: string; endTime: string }
|
|
226
219
|
)[] = [];
|
|
227
220
|
|
|
221
|
+
// Focus moves in once, on open, after details-window has drawn the controls.
|
|
228
222
|
firstUpdated = async (): Promise<void> => {
|
|
223
|
+
await this.renderRoot.querySelector<LitElement>("details-window")
|
|
224
|
+
?.updateComplete;
|
|
225
|
+
if (this.isConnected) {
|
|
226
|
+
placeFocusInside(
|
|
227
|
+
this,
|
|
228
|
+
this.renderRoot.querySelector<HTMLElement>(
|
|
229
|
+
"#call-us-window__content-wrapper"
|
|
230
|
+
)
|
|
231
|
+
);
|
|
232
|
+
}
|
|
229
233
|
if (!this.buildingId || !this.hasCallUsEnabled) return;
|
|
230
234
|
this.officeHoursTextInfo = await getOfficeHourText(this.buildingId);
|
|
231
235
|
};
|
|
@@ -14,7 +14,7 @@ import axios from "axios";
|
|
|
14
14
|
import { FeatureFlagsShowDropdown } from "../../fetchFeatureFlag";
|
|
15
15
|
import { pushGtmEvent } from "../../gtm";
|
|
16
16
|
import formDisclaimer from "../../disclaimers";
|
|
17
|
-
import {
|
|
17
|
+
import { placeFocusInside, trapTabInside } from "../pubnub-chat";
|
|
18
18
|
import { isMobile, isValidEmail, snakify } from "../../utils";
|
|
19
19
|
import LeadSourceClient, {
|
|
20
20
|
getDefaultLeadSourceAttribution,
|
|
@@ -47,11 +47,17 @@ export class EmailUsWindow extends LitElement {
|
|
|
47
47
|
trapTabInside(event, this);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
// Focus moves in once, on open. The fields render inside details-window, which draws
|
|
51
|
+
// after this element's first update, so wait for it. Later renders (every keystroke)
|
|
52
|
+
// never move focus.
|
|
53
|
+
async firstUpdated(): Promise<void> {
|
|
54
|
+
await this.renderRoot.querySelector<LitElement>("details-window")
|
|
55
|
+
?.updateComplete;
|
|
56
|
+
if (!this.isConnected) return;
|
|
57
|
+
placeFocusInside(
|
|
58
|
+
this,
|
|
59
|
+
this.renderRoot.querySelector<HTMLElement>("#email-us-form")
|
|
60
|
+
);
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
static styles = [
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { svg, SVGTemplateResult } from "lit";
|
|
2
|
+
|
|
3
|
+
export const CalendarCheckIcon = (
|
|
4
|
+
color = "#202020"
|
|
5
|
+
): SVGTemplateResult => svg`<svg
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
focusable="false"
|
|
8
|
+
width="20"
|
|
9
|
+
height="20"
|
|
10
|
+
viewBox="0 0 20 20"
|
|
11
|
+
fill="none"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
>
|
|
14
|
+
<path
|
|
15
|
+
d="M7 0V2H13V0H15V2H19C19.2652 2 19.5196 2.10536 19.7071 2.29289C19.8946 2.48043 20 2.73478 20 3V19C20 19.2652 19.8946 19.5196 19.7071 19.7071C19.5196 19.8946 19.2652 20 19 20H1C0.734784 20 0.48043 19.8946 0.292893 19.7071C0.105357 19.5196 0 19.2652 0 19V3C0 2.73478 0.105357 2.48043 0.292893 2.29289C0.48043 2.10536 0.734784 2 1 2H5V0H7ZM18 9H2V18H18V9ZM13.036 10.136L14.45 11.55L9.5 16.5L5.964 12.964L7.38 11.55L9.501 13.672L13.037 10.136H13.036ZM5 4H2V7H18V4H15V5H13V4H7V5H5V4Z"
|
|
16
|
+
fill="${color}"
|
|
17
|
+
/>
|
|
18
|
+
</svg>`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { svg, SVGTemplateResult } from "lit";
|
|
2
|
+
|
|
3
|
+
export const CheckCircleIcon = (
|
|
4
|
+
color = "#202020"
|
|
5
|
+
): SVGTemplateResult => svg`<svg
|
|
6
|
+
aria-hidden="true"
|
|
7
|
+
focusable="false"
|
|
8
|
+
width="28"
|
|
9
|
+
height="28"
|
|
10
|
+
viewBox="0 0 24 24"
|
|
11
|
+
fill="none"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
>
|
|
14
|
+
<circle cx="12" cy="12" r="10.5" stroke="${color}" stroke-width="1.5" />
|
|
15
|
+
<path
|
|
16
|
+
d="M7.5 12.5L10.5 15.5L16.5 9"
|
|
17
|
+
stroke="${color}"
|
|
18
|
+
stroke-width="1.5"
|
|
19
|
+
stroke-linecap="round"
|
|
20
|
+
stroke-linejoin="round"
|
|
21
|
+
/>
|
|
22
|
+
</svg>`;
|
|
@@ -1079,6 +1079,20 @@ export function focusFirstTabStop(container: HTMLElement): boolean {
|
|
|
1079
1079
|
return true;
|
|
1080
1080
|
}
|
|
1081
1081
|
|
|
1082
|
+
/**
|
|
1083
|
+
* Move focus into an overlay, to the first control in `preferred` when it has one.
|
|
1084
|
+
* Leaves focus alone when the person is already on a control inside the overlay.
|
|
1085
|
+
*/
|
|
1086
|
+
export function placeFocusInside(
|
|
1087
|
+
container: HTMLElement,
|
|
1088
|
+
preferred?: HTMLElement | null
|
|
1089
|
+
): boolean {
|
|
1090
|
+
const active = activeElementInside(container);
|
|
1091
|
+
if (active && active !== container) return true;
|
|
1092
|
+
if (preferred && focusFirstTabStop(preferred)) return true;
|
|
1093
|
+
return focusFirstTabStop(container);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1082
1096
|
/** Wrap Tab inside container when focus is already in it. No effect otherwise. */
|
|
1083
1097
|
export function trapTabInside(
|
|
1084
1098
|
event: KeyboardEvent,
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { expect } from "@esm-bundle/chai";
|
|
2
|
+
import { sendKeys, sendMouse } from "@web/test-runner-commands";
|
|
3
|
+
import "../public/dist/index";
|
|
4
|
+
import type { EmailUsWindow } from "./WebComponent/actions/email-us-window";
|
|
5
|
+
import type { Launcher } from "./WebComponent/launcher/Launcher";
|
|
6
|
+
|
|
7
|
+
declare const afterEach: (callback: () => void) => void;
|
|
8
|
+
|
|
9
|
+
const deepestActive = (): Element | null => {
|
|
10
|
+
let active: Element | null = document.activeElement;
|
|
11
|
+
while (active?.shadowRoot?.activeElement) {
|
|
12
|
+
active = active.shadowRoot.activeElement;
|
|
13
|
+
}
|
|
14
|
+
return active;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Compare labels, not elements: a failed equal on DOM nodes stalls chai's output.
|
|
18
|
+
const label = (el: Node | null): string =>
|
|
19
|
+
el instanceof Element
|
|
20
|
+
? `${el.tagName.toLowerCase()} ${
|
|
21
|
+
el.getAttribute("placeholder") ?? el.getAttribute("aria-label") ?? ""
|
|
22
|
+
}`.trim()
|
|
23
|
+
: String(el);
|
|
24
|
+
|
|
25
|
+
const settle = (): Promise<void> =>
|
|
26
|
+
new Promise((resolve) => setTimeout(resolve, 50));
|
|
27
|
+
|
|
28
|
+
// Open the overlay the way a visitor does, through the launcher, which also wires
|
|
29
|
+
// the window's Close button.
|
|
30
|
+
const openFromLauncher = async (
|
|
31
|
+
open: (launcher: Launcher) => void,
|
|
32
|
+
tag: string
|
|
33
|
+
): Promise<HTMLElement> => {
|
|
34
|
+
const eliseWindow = window as unknown as {
|
|
35
|
+
eliseAi?: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
eliseWindow.eliseAi = eliseWindow.eliseAi ?? {};
|
|
38
|
+
const launcher = document.createElement("meetelise-launcher") as Launcher;
|
|
39
|
+
document.body.appendChild(launcher);
|
|
40
|
+
await launcher.updateComplete;
|
|
41
|
+
open(launcher);
|
|
42
|
+
await launcher.updateComplete;
|
|
43
|
+
await settle();
|
|
44
|
+
const overlay = launcher.shadowRoot?.querySelector<HTMLElement>(tag);
|
|
45
|
+
if (!overlay) throw new Error(`no ${tag}`);
|
|
46
|
+
return overlay;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const openEmailWindow = (): Promise<EmailUsWindow> =>
|
|
50
|
+
openFromLauncher(
|
|
51
|
+
(launcher) => launcher.onClickEmailOption(new MouseEvent("click")),
|
|
52
|
+
"email-us-window"
|
|
53
|
+
) as Promise<EmailUsWindow>;
|
|
54
|
+
|
|
55
|
+
const field = (emailUs: EmailUsWindow, selector: string): HTMLInputElement => {
|
|
56
|
+
const input = emailUs.shadowRoot?.querySelector<HTMLInputElement>(selector);
|
|
57
|
+
if (!input) throw new Error(`no ${selector}`);
|
|
58
|
+
return input;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
document.querySelectorAll("meetelise-launcher").forEach((el) => el.remove());
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("puts focus on the first name field when the email window opens", async () => {
|
|
66
|
+
const emailUs = await openEmailWindow();
|
|
67
|
+
|
|
68
|
+
expect(label(deepestActive())).to.equal(
|
|
69
|
+
label(field(emailUs, 'input[placeholder="First name"]'))
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("keeps focus in the field the person clicked and is typing in", async () => {
|
|
74
|
+
const emailUs = await openEmailWindow();
|
|
75
|
+
const email = field(emailUs, 'input[type="email"]');
|
|
76
|
+
const box = email.getBoundingClientRect();
|
|
77
|
+
|
|
78
|
+
await sendMouse({
|
|
79
|
+
type: "click",
|
|
80
|
+
position: [Math.round(box.x + 10), Math.round(box.y + box.height / 2)],
|
|
81
|
+
});
|
|
82
|
+
await sendKeys({ type: "jo@example.com" });
|
|
83
|
+
await settle();
|
|
84
|
+
|
|
85
|
+
expect(label(deepestActive())).to.equal(label(email));
|
|
86
|
+
expect(email.value).to.equal("jo@example.com");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("moves focus into the call window when it opens", async () => {
|
|
90
|
+
const callUs = await openFromLauncher(
|
|
91
|
+
(launcher) => launcher.onClickPhoneOption(new MouseEvent("click")),
|
|
92
|
+
"call-us-window"
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
let node: Node | null = deepestActive();
|
|
96
|
+
while (node && node !== callUs) {
|
|
97
|
+
node = node instanceof ShadowRoot ? node.host : node.parentNode;
|
|
98
|
+
}
|
|
99
|
+
expect(node === callUs, `focus is on ${label(deepestActive())}`).to.equal(
|
|
100
|
+
true
|
|
101
|
+
);
|
|
102
|
+
});
|