@meetelise/chat 1.70.1 → 1.71.0
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/SchedulerV2/community-picker.d.ts +14 -1
- package/dist/src/WebComponent/SchedulerV2/scheduler-popover.d.ts +29 -0
- package/dist/src/WebComponent/SchedulerV2/schedulerRequests.d.ts +2 -1
- package/dist/src/WebComponent/SchedulerV2/tour-scheduler-v2.d.ts +14 -0
- package/dist/src/WebComponent/SchedulerV2/tourItineraryApi.d.ts +2 -1
- package/package.json +1 -1
- package/public/dist/index.js +484 -429
- package/src/WebComponent/SchedulerV2/community-picker.ts +153 -91
- package/src/WebComponent/SchedulerV2/scheduler-popover.ts +108 -0
- package/src/WebComponent/SchedulerV2/schedulerRequests.ts +3 -2
- package/src/WebComponent/SchedulerV2/tour-scheduler-v2.ts +96 -50
- package/src/WebComponent/SchedulerV2/tourItineraryApi.ts +2 -1
- package/src/orgLevelNavigation.test.ts +7 -0
- package/src/tourSchedulerV2Booking.test.ts +224 -20
|
@@ -3,6 +3,7 @@ import { customElement, property, state } from "lit/decorators.js";
|
|
|
3
3
|
import { classMap } from "lit/directives/class-map.js";
|
|
4
4
|
import "../actions/action-confirm-button";
|
|
5
5
|
import "../shared/simple-tooltip";
|
|
6
|
+
import "./scheduler-popover";
|
|
6
7
|
import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
|
|
7
8
|
import { InputStyles } from "../actions/InputStyles";
|
|
8
9
|
import floorplanImageCardStyles from "../FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles";
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
toCommunitySummary,
|
|
19
20
|
} from "./tourItineraryApi";
|
|
20
21
|
import { formatHourMinute, formatShortDate } from "./tourTimes";
|
|
21
|
-
import { formatCurrency } from "../../utils";
|
|
22
|
+
import { formatCurrency, isMobile, onMobileChange } from "../../utils";
|
|
22
23
|
|
|
23
24
|
export type CommunityLoader = (
|
|
24
25
|
filters: CommunityFilters
|
|
@@ -68,23 +69,47 @@ export class CommunityPicker extends LitElement {
|
|
|
68
69
|
@property({ type: Number })
|
|
69
70
|
maxSelectable = 0;
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
/**
|
|
73
|
+
* The prospect's filters, which the scheduler shares with its form for this
|
|
74
|
+
* visit; a change is reported with `filters-change`.
|
|
75
|
+
*/
|
|
76
|
+
@property({ attribute: false })
|
|
77
|
+
filters: CommunityFilters = EMPTY_FILTERS;
|
|
78
|
+
|
|
72
79
|
@state() private openFilter: FilterId | null = null;
|
|
73
80
|
@state() private communities: Community[] = [];
|
|
74
81
|
@state() private loading = false;
|
|
75
82
|
@state() private error: string | null = null;
|
|
83
|
+
@state() private mobile = isMobile();
|
|
76
84
|
|
|
77
85
|
private requestId = 0;
|
|
86
|
+
private cleanupMobileListener?: () => void;
|
|
87
|
+
|
|
88
|
+
connectedCallback(): void {
|
|
89
|
+
super.connectedCallback();
|
|
90
|
+
this.cleanupMobileListener = onMobileChange((m) => (this.mobile = m));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
disconnectedCallback(): void {
|
|
94
|
+
this.cleanupMobileListener?.();
|
|
95
|
+
super.disconnectedCallback();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The scheduler's unfiltered page, while no filter is set. */
|
|
99
|
+
private get initialPage(): CommunitiesResponse | null {
|
|
100
|
+
return FILTER_IDS.some((id) => this.isFilterActive(id))
|
|
101
|
+
? null
|
|
102
|
+
: this.initial;
|
|
103
|
+
}
|
|
78
104
|
|
|
79
105
|
willUpdate(): void {
|
|
80
106
|
// Show the page the scheduler already has from the first paint.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
107
|
+
const initial = this.initialPage;
|
|
108
|
+
if (!this.hasUpdated && initial) this.communities = initial.communities;
|
|
84
109
|
}
|
|
85
110
|
|
|
86
111
|
firstUpdated(): void {
|
|
87
|
-
if (!this.
|
|
112
|
+
if (!this.initialPage) void this.reload();
|
|
88
113
|
}
|
|
89
114
|
|
|
90
115
|
private async reload(): Promise<void> {
|
|
@@ -106,6 +131,13 @@ export class CommunityPicker extends LitElement {
|
|
|
106
131
|
|
|
107
132
|
private setFilters(next: Partial<CommunityFilters>): void {
|
|
108
133
|
this.filters = { ...this.filters, ...next };
|
|
134
|
+
this.dispatchEvent(
|
|
135
|
+
new CustomEvent("filters-change", {
|
|
136
|
+
detail: { filters: this.filters },
|
|
137
|
+
bubbles: true,
|
|
138
|
+
composed: true,
|
|
139
|
+
})
|
|
140
|
+
);
|
|
109
141
|
void this.reload();
|
|
110
142
|
}
|
|
111
143
|
|
|
@@ -157,9 +189,13 @@ export class CommunityPicker extends LitElement {
|
|
|
157
189
|
private filterLabel(id: FilterId): string {
|
|
158
190
|
const f = this.filters;
|
|
159
191
|
if (id === "bedrooms") {
|
|
192
|
+
// A count from the form can be one the chips don't offer, e.g. 4.
|
|
160
193
|
return f.bedrooms.length
|
|
161
|
-
?
|
|
162
|
-
.map(
|
|
194
|
+
? f.bedrooms
|
|
195
|
+
.map(
|
|
196
|
+
(n) =>
|
|
197
|
+
BEDROOM_OPTIONS.find((o) => o.value === n)?.label ?? `${n} bd`
|
|
198
|
+
)
|
|
163
199
|
.join(", ")
|
|
164
200
|
: "Bedrooms";
|
|
165
201
|
}
|
|
@@ -171,93 +207,111 @@ export class CommunityPicker extends LitElement {
|
|
|
171
207
|
: "Budget";
|
|
172
208
|
}
|
|
173
209
|
|
|
174
|
-
|
|
210
|
+
/** Each filter's controls, in the panel its chip opens. */
|
|
211
|
+
private renderFilterPanel(id: FilterId): TemplateResult {
|
|
175
212
|
const f = this.filters;
|
|
213
|
+
if (id === "bedrooms") {
|
|
214
|
+
return html`<div
|
|
215
|
+
class="floor-plan-selector-badges"
|
|
216
|
+
role="group"
|
|
217
|
+
aria-label="Bedrooms"
|
|
218
|
+
>
|
|
219
|
+
${BEDROOM_OPTIONS.map(
|
|
220
|
+
(o) => html`<button
|
|
221
|
+
class=${classMap({
|
|
222
|
+
"floor-plan-badge": true,
|
|
223
|
+
selected: f.bedrooms.includes(o.value),
|
|
224
|
+
})}
|
|
225
|
+
aria-pressed=${String(f.bedrooms.includes(o.value))}
|
|
226
|
+
@click=${() =>
|
|
227
|
+
this.setFilters({
|
|
228
|
+
bedrooms: f.bedrooms.includes(o.value)
|
|
229
|
+
? f.bedrooms.filter((b) => b !== o.value)
|
|
230
|
+
: [...f.bedrooms, o.value].sort(),
|
|
231
|
+
})}
|
|
232
|
+
>
|
|
233
|
+
${o.label}
|
|
234
|
+
</button>`
|
|
235
|
+
)}
|
|
236
|
+
</div>`;
|
|
237
|
+
}
|
|
238
|
+
if (id === "moveIn") {
|
|
239
|
+
return html`<div class="date-field">
|
|
240
|
+
<label for="move-in">Move-in date</label>
|
|
241
|
+
<input
|
|
242
|
+
id="move-in"
|
|
243
|
+
type="date"
|
|
244
|
+
.value=${f.moveIn ?? ""}
|
|
245
|
+
@change=${(e: Event) => {
|
|
246
|
+
this.openFilter = null;
|
|
247
|
+
this.setFilters({
|
|
248
|
+
moveIn: (e.target as HTMLInputElement).value || null,
|
|
249
|
+
});
|
|
250
|
+
}}
|
|
251
|
+
/>
|
|
252
|
+
</div>`;
|
|
253
|
+
}
|
|
254
|
+
return html`<div class="date-field">
|
|
255
|
+
<label for="max-budget">Max monthly rent ($)</label>
|
|
256
|
+
<input
|
|
257
|
+
id="max-budget"
|
|
258
|
+
type="number"
|
|
259
|
+
inputmode="numeric"
|
|
260
|
+
min="0"
|
|
261
|
+
step="50"
|
|
262
|
+
.value=${f.maxBudget === null ? "" : String(f.maxBudget)}
|
|
263
|
+
@change=${(e: Event) => {
|
|
264
|
+
const value = parseInt((e.target as HTMLInputElement).value, 10);
|
|
265
|
+
this.openFilter = null;
|
|
266
|
+
this.setFilters({
|
|
267
|
+
maxBudget: Number.isFinite(value) && value > 0 ? value : null,
|
|
268
|
+
});
|
|
269
|
+
}}
|
|
270
|
+
/>
|
|
271
|
+
</div>`;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private renderFilters(): TemplateResult {
|
|
176
275
|
const open = this.openFilter;
|
|
177
276
|
return html`<div class="picker-toolbar" role="group" aria-label="Filters">
|
|
178
|
-
|
|
179
|
-
|
|
277
|
+
${FILTER_IDS.map(
|
|
278
|
+
(id) => html`<scheduler-popover
|
|
279
|
+
?open=${open === id}
|
|
280
|
+
?inline=${this.mobile}
|
|
281
|
+
@popover-close=${() => {
|
|
282
|
+
// Another chip's click opens its own panel before this one hears it.
|
|
283
|
+
if (this.openFilter === id) this.openFilter = null;
|
|
284
|
+
}}
|
|
285
|
+
>
|
|
286
|
+
<button
|
|
287
|
+
slot="trigger"
|
|
180
288
|
class=${classMap({
|
|
181
289
|
"floor-plan-badge": true,
|
|
182
290
|
selected: this.isFilterActive(id),
|
|
183
291
|
})}
|
|
184
292
|
aria-expanded=${String(open === id)}
|
|
185
|
-
aria-controls
|
|
293
|
+
aria-controls=${`filter-${id}`}
|
|
186
294
|
@click=${() => (this.openFilter = open === id ? null : id)}
|
|
187
295
|
>
|
|
188
296
|
${this.filterLabel(id)}
|
|
189
|
-
</button
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
: ""}
|
|
202
|
-
</div>
|
|
203
|
-
<div
|
|
204
|
-
id="picker-filters"
|
|
205
|
-
class=${classMap({ "advanced-section": true, open: open !== null })}
|
|
206
|
-
>
|
|
207
|
-
<div
|
|
208
|
-
class="floor-plan-selector-badges"
|
|
209
|
-
role="group"
|
|
210
|
-
aria-label="Bedrooms"
|
|
211
|
-
?hidden=${open !== "bedrooms"}
|
|
212
|
-
>
|
|
213
|
-
${BEDROOM_OPTIONS.map(
|
|
214
|
-
(o) => html`<button
|
|
215
|
-
class=${classMap({
|
|
216
|
-
"floor-plan-badge": true,
|
|
217
|
-
selected: f.bedrooms.includes(o.value),
|
|
218
|
-
})}
|
|
219
|
-
aria-pressed=${String(f.bedrooms.includes(o.value))}
|
|
220
|
-
@click=${() =>
|
|
221
|
-
this.setFilters({
|
|
222
|
-
bedrooms: f.bedrooms.includes(o.value)
|
|
223
|
-
? f.bedrooms.filter((b) => b !== o.value)
|
|
224
|
-
: [...f.bedrooms, o.value].sort(),
|
|
225
|
-
})}
|
|
226
|
-
>
|
|
227
|
-
${o.label}
|
|
228
|
-
</button>`
|
|
229
|
-
)}
|
|
230
|
-
</div>
|
|
231
|
-
<div class="date-field" ?hidden=${open !== "moveIn"}>
|
|
232
|
-
<label for="move-in">Move-in date</label>
|
|
233
|
-
<input
|
|
234
|
-
id="move-in"
|
|
235
|
-
type="date"
|
|
236
|
-
.value=${f.moveIn ?? ""}
|
|
237
|
-
@change=${(e: Event) =>
|
|
238
|
-
this.setFilters({
|
|
239
|
-
moveIn: (e.target as HTMLInputElement).value || null,
|
|
240
|
-
})}
|
|
241
|
-
/>
|
|
242
|
-
</div>
|
|
243
|
-
<div class="date-field" ?hidden=${open !== "budget"}>
|
|
244
|
-
<label for="max-budget">Max monthly rent ($)</label>
|
|
245
|
-
<input
|
|
246
|
-
id="max-budget"
|
|
247
|
-
type="number"
|
|
248
|
-
inputmode="numeric"
|
|
249
|
-
min="0"
|
|
250
|
-
step="50"
|
|
251
|
-
.value=${f.maxBudget === null ? "" : String(f.maxBudget)}
|
|
252
|
-
@change=${(e: Event) => {
|
|
253
|
-
const value = parseInt((e.target as HTMLInputElement).value, 10);
|
|
254
|
-
this.setFilters({
|
|
255
|
-
maxBudget: Number.isFinite(value) && value > 0 ? value : null,
|
|
256
|
-
});
|
|
297
|
+
</button>
|
|
298
|
+
<div id=${`filter-${id}`} class="filter-panel">
|
|
299
|
+
${open === id ? this.renderFilterPanel(id) : ""}
|
|
300
|
+
</div>
|
|
301
|
+
</scheduler-popover>`
|
|
302
|
+
)}
|
|
303
|
+
${FILTER_IDS.some((id) => this.isFilterActive(id))
|
|
304
|
+
? html`<button
|
|
305
|
+
class="clear-filters"
|
|
306
|
+
@click=${() => {
|
|
307
|
+
this.openFilter = null;
|
|
308
|
+
this.setFilters(EMPTY_FILTERS);
|
|
257
309
|
}}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
310
|
+
>
|
|
311
|
+
Clear all
|
|
312
|
+
</button>`
|
|
313
|
+
: ""}
|
|
314
|
+
</div>`;
|
|
261
315
|
}
|
|
262
316
|
|
|
263
317
|
private renderCard(c: Community): TemplateResult {
|
|
@@ -413,12 +467,12 @@ export class CommunityPicker extends LitElement {
|
|
|
413
467
|
margin-bottom: 16px;
|
|
414
468
|
}
|
|
415
469
|
|
|
416
|
-
.picker-toolbar .floor-plan-badge:not(.selected) {
|
|
470
|
+
.picker-toolbar [slot="trigger"].floor-plan-badge:not(.selected) {
|
|
417
471
|
background: #ffffff;
|
|
418
472
|
border-color: #e7e7e7;
|
|
419
473
|
}
|
|
420
474
|
|
|
421
|
-
.picker-toolbar .floor-plan-badge:not(.selected):hover {
|
|
475
|
+
.picker-toolbar [slot="trigger"].floor-plan-badge:not(.selected):hover {
|
|
422
476
|
background: #f8f9fa;
|
|
423
477
|
}
|
|
424
478
|
|
|
@@ -432,18 +486,26 @@ export class CommunityPicker extends LitElement {
|
|
|
432
486
|
text-decoration: underline;
|
|
433
487
|
}
|
|
434
488
|
|
|
435
|
-
|
|
436
|
-
|
|
489
|
+
.filter-panel .floor-plan-selector-badges {
|
|
490
|
+
margin: 0;
|
|
491
|
+
overflow: visible;
|
|
437
492
|
}
|
|
438
493
|
|
|
439
|
-
|
|
494
|
+
.filter-panel .date-field {
|
|
495
|
+
margin: 0;
|
|
496
|
+
width: 14rem;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/* Phones: the panel opens in place under the chips, as the filter row did. */
|
|
500
|
+
scheduler-popover[inline] .filter-panel .floor-plan-selector-badges {
|
|
501
|
+
flex-wrap: wrap;
|
|
440
502
|
justify-content: center;
|
|
441
|
-
margin-bottom: 12px;
|
|
442
503
|
}
|
|
443
504
|
|
|
444
|
-
|
|
445
|
-
margin: 0 auto
|
|
505
|
+
scheduler-popover[inline] .filter-panel .date-field {
|
|
506
|
+
margin: 0 auto;
|
|
446
507
|
max-width: 16rem;
|
|
508
|
+
width: auto;
|
|
447
509
|
}
|
|
448
510
|
|
|
449
511
|
.floor-plan-selector-badges {
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { css, html, LitElement, TemplateResult } from "lit";
|
|
2
|
+
import { customElement, property } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A trigger and the small panel it opens, for the v2 scheduler's secondary
|
|
6
|
+
* choices. The panel floats under the trigger with `me-select`'s list surface
|
|
7
|
+
* and closes, as that list does, on a click outside it, or on Escape. With
|
|
8
|
+
* `inline` (phones) it opens in place instead, after its siblings in the
|
|
9
|
+
* parent's flex row, as the filter row always did there.
|
|
10
|
+
*
|
|
11
|
+
* The parent owns `open`; the element asks for a close with `popover-close`.
|
|
12
|
+
* Slot the trigger as `slot="trigger"` and the panel's content in the default
|
|
13
|
+
* slot, so the trigger's `aria-controls` can name an id in the parent's tree.
|
|
14
|
+
*/
|
|
15
|
+
@customElement("scheduler-popover")
|
|
16
|
+
export class SchedulerPopover extends LitElement {
|
|
17
|
+
@property({ type: Boolean, reflect: true })
|
|
18
|
+
open = false;
|
|
19
|
+
|
|
20
|
+
@property({ type: Boolean, reflect: true })
|
|
21
|
+
inline = false;
|
|
22
|
+
|
|
23
|
+
connectedCallback(): void {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
document.addEventListener("click", this.onDocumentClick);
|
|
26
|
+
this.addEventListener("keydown", this.onKeydown);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
disconnectedCallback(): void {
|
|
30
|
+
document.removeEventListener("click", this.onDocumentClick);
|
|
31
|
+
this.removeEventListener("keydown", this.onKeydown);
|
|
32
|
+
super.disconnectedCallback();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private requestClose(): void {
|
|
36
|
+
this.dispatchEvent(new CustomEvent("popover-close"));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** As `me-select`: a click anywhere outside, trigger included, closes it. */
|
|
40
|
+
private onDocumentClick = (e: MouseEvent): void => {
|
|
41
|
+
if (this.open && !this.inline && !e.composedPath().includes(this)) {
|
|
42
|
+
this.requestClose();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
private onKeydown = (e: KeyboardEvent): void => {
|
|
47
|
+
if (!this.open || e.key !== "Escape" || e.isComposing) return;
|
|
48
|
+
// The scheduler closes on Escape; here it only closes the panel.
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
this.requestClose();
|
|
52
|
+
this.querySelector<HTMLElement>('[slot="trigger"]')?.focus();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
render(): TemplateResult {
|
|
56
|
+
return html`<slot name="trigger"></slot>
|
|
57
|
+
<div class="panel" ?hidden=${!this.open}><slot></slot></div>`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static styles = css`
|
|
61
|
+
/* New element, from me-select's list surface and the picker's card border. */
|
|
62
|
+
:host {
|
|
63
|
+
display: inline-block;
|
|
64
|
+
position: relative;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:host([inline]) {
|
|
68
|
+
display: contents;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.panel {
|
|
72
|
+
background-color: #ffffff;
|
|
73
|
+
border: 1px solid #e7e7e7;
|
|
74
|
+
border-radius: 10px;
|
|
75
|
+
box-shadow: 0px 4px 14px rgba(0, 0, 0, 0.15);
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
left: 0;
|
|
78
|
+
margin-top: 4px;
|
|
79
|
+
padding: 12px 16px;
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: 100%;
|
|
82
|
+
width: max-content;
|
|
83
|
+
z-index: 20;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host([inline]) .panel {
|
|
87
|
+
background: none;
|
|
88
|
+
border: none;
|
|
89
|
+
box-shadow: none;
|
|
90
|
+
flex-basis: 100%;
|
|
91
|
+
margin-top: 0;
|
|
92
|
+
order: 1;
|
|
93
|
+
padding: 0;
|
|
94
|
+
position: static;
|
|
95
|
+
width: auto;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
[hidden] {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare global {
|
|
105
|
+
interface HTMLElementTagNameMap {
|
|
106
|
+
"scheduler-popover": SchedulerPopover;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -102,7 +102,8 @@ export const buildBookingRequest = ({
|
|
|
102
102
|
}: {
|
|
103
103
|
choice: ItineraryChoice;
|
|
104
104
|
plan: PlanResponse;
|
|
105
|
-
|
|
105
|
+
/** Null when adding stops to a booking: the server already has the prospect. */
|
|
106
|
+
contact: BookingContact | null;
|
|
106
107
|
attribution: BookingAttribution;
|
|
107
108
|
conversationTrackingId: string | null;
|
|
108
109
|
cancelExistingTours: boolean;
|
|
@@ -116,7 +117,7 @@ export const buildBookingRequest = ({
|
|
|
116
117
|
.filter((stop) => !stop.fixed)
|
|
117
118
|
.map((stop) => ({ building_id: stop.building_id, start: stop.start })),
|
|
118
119
|
],
|
|
119
|
-
contact,
|
|
120
|
+
...(contact ? { contact } : {}),
|
|
120
121
|
lead_sources: attribution,
|
|
121
122
|
conversation_tracking_id: conversationTrackingId,
|
|
122
123
|
cancel_existing_tours: cancelExistingTours,
|