@meetelise/chat 1.66.0 → 1.68.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.
@@ -0,0 +1,33 @@
1
+ import { LitElement, TemplateResult } from "lit";
2
+ import { BookedStopStatus, CommunitySummary, TourTypeId } from "./tourItineraryApi";
3
+ export interface ConfirmedStop {
4
+ community: CommunitySummary;
5
+ start: string | null;
6
+ end: string | null;
7
+ status: BookedStopStatus;
8
+ /** The server's prospect-facing reason, for a failed stop. */
9
+ error: string | null;
10
+ distanceFromPrevMi: number | null;
11
+ }
12
+ /**
13
+ * The Central Agent design's "Your Tour Is Booked" header, then an itinerary's
14
+ * stops, including any that failed to book. The extend picker goes in its slot.
15
+ */
16
+ export declare class BookingConfirmation extends LitElement {
17
+ /** At least one is booked: the scheduler keeps a booking that failed outright on its form. */
18
+ stops: ConfirmedStop[];
19
+ tourType: TourTypeId | null;
20
+ /** The prospect confirmed moving a tour they already had. */
21
+ rescheduled: boolean;
22
+ private heading;
23
+ /** Where, how and when, as one line: the stops list shows each stop's own time. */
24
+ private summary;
25
+ private renderStops;
26
+ render(): TemplateResult;
27
+ static styles: import("lit").CSSResult[];
28
+ }
29
+ declare global {
30
+ interface HTMLElementTagNameMap {
31
+ "booking-confirmation": BookingConfirmation;
32
+ }
33
+ }
@@ -0,0 +1,49 @@
1
+ import { LitElement, TemplateResult } from "lit";
2
+ import "../actions/international-phone-input";
3
+ import "../me-select";
4
+ import type { LayoutOption } from "../../fetchBuildingWebchatView";
5
+ export interface ContactValues {
6
+ firstName: string;
7
+ lastName: string;
8
+ email: string;
9
+ phone: string;
10
+ phoneE164: string | null;
11
+ phoneCountry: string | null;
12
+ /** The building's layout option value picked, or null. */
13
+ layout: number | null;
14
+ moveIn: string;
15
+ notes: string;
16
+ /** Picked in "How did you hear about us?", when that is shown. */
17
+ leadSource: string | null;
18
+ }
19
+ export declare const EMPTY_CONTACT: ContactValues;
20
+ /**
21
+ * Today's scheduler's rules: a first or last name, a valid email and phone,
22
+ * and a bedroom preference only where the building requires one.
23
+ */
24
+ export declare const contactIsValid: (values: ContactValues, bedroomsRequired: boolean) => boolean;
25
+ /**
26
+ * The prospect's details, in today's scheduler's "Your Information" column
27
+ * with its inputs. The scheduler's footer holds the submit button.
28
+ */
29
+ export declare class ContactForm extends LitElement {
30
+ values: ContactValues;
31
+ /** The building's bedroom layouts, as today's scheduler offers them. */
32
+ layoutOptions: LayoutOption[];
33
+ bedroomsRequired: boolean;
34
+ leadSources: string[];
35
+ showLeadSourceDropdown: boolean;
36
+ currentLeadSource: string;
37
+ country: string | null;
38
+ mobile: boolean;
39
+ private phoneHasBlurred;
40
+ private setValues;
41
+ private inputClasses;
42
+ render(): TemplateResult;
43
+ static styles: import("lit").CSSResult[];
44
+ }
45
+ declare global {
46
+ interface HTMLElementTagNameMap {
47
+ "contact-form": ContactForm;
48
+ }
49
+ }
@@ -0,0 +1,171 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from "lit";
2
+ import "./community-picker";
3
+ import "./itinerary-editor";
4
+ import "./contact-form";
5
+ import "./booking-confirmation";
6
+ import "../actions/action-confirm-button";
7
+ import "../loaders/mega-loader";
8
+ import { LabeledOption } from "../../fetchBuildingInfo";
9
+ import type { LayoutOption } from "../../fetchBuildingWebchatView";
10
+ import type LeadSourceClient from "../LeadSourceClient";
11
+ import type { LeadSourceMultitouchClient } from "../LeadSourceMultitouchClient";
12
+ /**
13
+ * The rebuilt tour scheduler, behind the `webchat_tour_scheduler_v2` rollout.
14
+ * It books one community, or up to the server's cap of communities in a
15
+ * central group as one same-day itinerary, and offers more communities after a
16
+ * booking. The server decides which communities can tour, their order, the
17
+ * chained times and the cap; this element keeps only the step, the prospect's
18
+ * choices and the form.
19
+ */
20
+ export declare class TourSchedulerV2 extends LitElement {
21
+ orgSlug: string;
22
+ buildingSlug: string;
23
+ buildingId: number;
24
+ orgId: number;
25
+ buildingName: string;
26
+ sgtUrl: string;
27
+ selfGuidedToursTypeOffered: string;
28
+ escortedToursLink: string;
29
+ escortedToursTypeOffered: string;
30
+ virtualToursLink: string;
31
+ virtualToursTypeOffered: string;
32
+ tourTypeOptions: LabeledOption[];
33
+ layoutOptions: LayoutOption[];
34
+ currentLeadSource: string;
35
+ leadSources: string[];
36
+ featureFlagShowDropdown: string;
37
+ bedroomPreferenceRequired: boolean;
38
+ orgLegalName: string;
39
+ country: string | null;
40
+ buildingState: string | null;
41
+ primaryColor: string;
42
+ foregroundColorOnPrimaryBackgroundColor: string;
43
+ compactDesign: boolean | string;
44
+ leadSourceClient: LeadSourceClient | null;
45
+ leadSourceMultitouchClient: LeadSourceMultitouchClient | null;
46
+ /** The /webchat/init session token, read when each request is sent. */
47
+ getSessionToken: () => string | null;
48
+ private api;
49
+ onCloseClicked?: (e: MouseEvent) => void;
50
+ private step;
51
+ private loadError;
52
+ private mobile;
53
+ /** Null outside a central group, where only this building can be toured. */
54
+ private group;
55
+ private communities;
56
+ private selectedIds;
57
+ /** The open picker's picks, shown in the footer until Continue. */
58
+ private picks;
59
+ private existingEventIds;
60
+ private tourType;
61
+ /** A tour type this building books on its own page, once picked. */
62
+ private linkTourType;
63
+ private date;
64
+ private firstStart;
65
+ private laterStarts;
66
+ private plan;
67
+ private planLoading;
68
+ private planError;
69
+ private notice;
70
+ private contact;
71
+ private submitting;
72
+ private bookingError;
73
+ private reschedulePrompt;
74
+ private confirmed;
75
+ private bookedTourType;
76
+ private bookedEventIds;
77
+ private extendInitial;
78
+ /** The booking the extend picker adds stops after. */
79
+ private extendFrom;
80
+ /** The schedule step is adding stops to a booking. */
81
+ private extending;
82
+ /** The prospect agreed to move a tour they already had. */
83
+ private rescheduled;
84
+ /** The prospect kept the tour they already had. */
85
+ private rescheduleCanceled;
86
+ private planRequestId;
87
+ private idempotency;
88
+ private cleanupMobileListener?;
89
+ connectedCallback(): void;
90
+ disconnectedCallback(): void;
91
+ private onKeydown;
92
+ private close;
93
+ private get client();
94
+ willUpdate(changed: PropertyValues<this>): void;
95
+ firstUpdated(): void;
96
+ updated(changed: PropertyValues): void;
97
+ private start;
98
+ private goTo;
99
+ private remember;
100
+ private rememberOne;
101
+ private startSchedule;
102
+ private choice;
103
+ /**
104
+ * Asks /plan for the chained times. When the server reports that the tour
105
+ * type or date isn't offered, moves to the first one it offers and asks again.
106
+ */
107
+ private runPlan;
108
+ private tourLink;
109
+ /**
110
+ * Only a lone tour of this widget's own building can use its links: the widget
111
+ * has its own building's tour settings and no other's. An itinerary with
112
+ * other buildings offers only the tour types /plan serves for all of them.
113
+ */
114
+ private get bookingOwnBuildingAlone();
115
+ private openTourLink;
116
+ private tourTypeChoices;
117
+ /** The tour type shown as chosen: a link type the prospect picked, or the plan's. */
118
+ private get shownTourType();
119
+ /**
120
+ * The shown tour type when this building books it on its own page, whether the
121
+ * prospect picked it or the plan did. It replaces the times and blocks booking.
122
+ */
123
+ private get activeLinkType();
124
+ private onTourType;
125
+ private onDate;
126
+ private onStopTime;
127
+ private onReorder;
128
+ private onRemove;
129
+ private onEditCommunities;
130
+ private loadSelectCommunities;
131
+ private loadExtendCommunities;
132
+ private rememberPage;
133
+ private onCommunitiesSelected;
134
+ private submit;
135
+ private onBooked;
136
+ /**
137
+ * What the server needs to offer stops after this booking: when its last stop
138
+ * ends, its tour type, where that stop is, and every building already in it.
139
+ */
140
+ private extendQueryFromBooking;
141
+ private stopsRemaining;
142
+ /** Offers more communities while the itinerary has stops left. */
143
+ private loadExtension;
144
+ private onBookingError;
145
+ private showLeadSourceDropdown;
146
+ private log;
147
+ /** Where the back button goes from the current step, if anywhere. */
148
+ private backStep;
149
+ private problems;
150
+ private isMultiStop;
151
+ private canSubmit;
152
+ private disclaimer;
153
+ /** Today's scheduler's body area, which scrolls the whole sheet on phones. */
154
+ private container;
155
+ private renderPicker;
156
+ private onPicksChange;
157
+ private renderTray;
158
+ private renderSchedule;
159
+ /** Today's reschedule prompt, with the server's reason. */
160
+ private renderReschedulePrompt;
161
+ private renderRescheduleCanceled;
162
+ private renderBooked;
163
+ private renderBody;
164
+ render(): TemplateResult;
165
+ static styles: import("lit").CSSResult[];
166
+ }
167
+ declare global {
168
+ interface HTMLElementTagNameMap {
169
+ "tour-scheduler-v2": TourSchedulerV2;
170
+ }
171
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.66.0",
3
+ "version": "1.68.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -0,0 +1,205 @@
1
+ import { css, html, LitElement, TemplateResult } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+ import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
4
+ import { InputStyles } from "../actions/InputStyles";
5
+ import { itineraryStopStyles } from "./itineraryStopStyles";
6
+ import floorplanImageCardStyles from "../FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles";
7
+ import { CheckCircleIcon } from "../icons/CheckCircleIcon";
8
+ import {
9
+ BookedStopStatus,
10
+ CommunitySummary,
11
+ formatAddress,
12
+ TourTypeId,
13
+ } from "./tourItineraryApi";
14
+ import {
15
+ formatMonthDay,
16
+ formatTime,
17
+ formatTimeRange,
18
+ isoDate,
19
+ TOUR_TYPES,
20
+ } from "./tourTimes";
21
+ import { getTimezoneAbbreviation } from "../../getTimezoneString";
22
+
23
+ export interface ConfirmedStop {
24
+ community: CommunitySummary;
25
+ start: string | null;
26
+ end: string | null;
27
+ status: BookedStopStatus;
28
+ /** The server's prospect-facing reason, for a failed stop. */
29
+ error: string | null;
30
+ distanceFromPrevMi: number | null;
31
+ }
32
+
33
+ /**
34
+ * The Central Agent design's "Your Tour Is Booked" header, then an itinerary's
35
+ * stops, including any that failed to book. The extend picker goes in its slot.
36
+ */
37
+ @customElement("booking-confirmation")
38
+ export class BookingConfirmation extends LitElement {
39
+ /** At least one is booked: the scheduler keeps a booking that failed outright on its form. */
40
+ @property({ attribute: false })
41
+ stops: ConfirmedStop[] = [];
42
+
43
+ @property({ attribute: false })
44
+ tourType: TourTypeId | null = null;
45
+
46
+ /** The prospect confirmed moving a tour they already had. */
47
+ @property({ type: Boolean })
48
+ rescheduled = false;
49
+
50
+ private heading(): string {
51
+ const booked = this.stops.filter((s) => s.status !== "failed").length;
52
+ const verb = this.rescheduled ? "Rescheduled" : "Booked";
53
+ return booked === 1 ? `Your Tour Is ${verb}` : `Your Tours Are ${verb}`;
54
+ }
55
+
56
+ /** Where, how and when, as one line: the stops list shows each stop's own time. */
57
+ private summary(): string {
58
+ const booked = this.stops.filter((s) => s.status !== "failed");
59
+ const first = booked[0];
60
+ if (!first) return "";
61
+ const parts = [
62
+ booked.length === 1 ? first.community.name : "",
63
+ this.tourType ? TOUR_TYPES[this.tourType].heading : "",
64
+ ];
65
+ if (first.start) {
66
+ const zone = first.community.timezone
67
+ ? ` ${getTimezoneAbbreviation(first.community.timezone)}`
68
+ : "";
69
+ parts.push(
70
+ booked.length === 1
71
+ ? `${formatMonthDay(isoDate(first.start))} at ${formatTime(
72
+ first.start
73
+ )}${zone}`
74
+ : formatMonthDay(isoDate(first.start))
75
+ );
76
+ }
77
+ return parts.filter(Boolean).join(" · ");
78
+ }
79
+
80
+ private renderStops(): TemplateResult | string {
81
+ if (this.stops.length < 2) return "";
82
+ return html`<ol class="stops">
83
+ ${this.stops.map(
84
+ (stop, i) => html`<li>
85
+ ${i > 0
86
+ ? html`<p class="image-card-subtitle leg">
87
+ ${stop.distanceFromPrevMi !== null
88
+ ? html`${stop.distanceFromPrevMi.toFixed(1)} mi<span
89
+ class="sr-only"
90
+ >
91
+ from the previous stop</span
92
+ >`
93
+ : ""}
94
+ </p>`
95
+ : ""}
96
+ <div class="floorplan-image-card">
97
+ <span class="stop-number" aria-hidden="true">${i + 1}</span>
98
+ <div class="section-right">
99
+ <p class="image-card-title">
100
+ <span class="sr-only">Stop ${i + 1}:</span>
101
+ ${stop.community.name}
102
+ </p>
103
+ <p class="image-card-subtitle">
104
+ ${formatAddress(stop.community.address)}
105
+ </p>
106
+ ${stop.status === "failed"
107
+ ? html`<p class="error-message">
108
+ <span class="sr-only">Not booked:</span>
109
+ ${stop.error ?? "This tour couldn't be booked."}
110
+ </p>`
111
+ : stop.start && stop.end
112
+ ? html`<p class="stop-time">
113
+ ${formatMonthDay(isoDate(stop.start))} ·
114
+ ${formatTimeRange(stop.start, stop.end)}
115
+ </p>`
116
+ : ""}
117
+ </div>
118
+ </div>
119
+ </li>`
120
+ )}
121
+ </ol>`;
122
+ }
123
+
124
+ render(): TemplateResult {
125
+ const failed = this.stops.filter((s) => s.status === "failed").length;
126
+ return html`<div id="confirmationMessage" role="status">
127
+ <span class="booked-icon">${CheckCircleIcon("currentColor")}</span>
128
+ <h2 class="booked-title">${this.heading()}</h2>
129
+ <p class="booked-summary">${this.summary()}</p>
130
+ ${failed > 0
131
+ ? html`<p class="error-message">
132
+ ${failed === 1 ? "One tour" : `${failed} tours`} couldn't be
133
+ booked.
134
+ </p>`
135
+ : ""}
136
+ <p class="booked-note">
137
+ Look for an email confirmation along with instructions and directions.
138
+ You can make changes at any time, just reply to the email.
139
+ </p>
140
+ ${this.renderStops()}
141
+ </div>
142
+ <slot></slot>`;
143
+ }
144
+
145
+ static styles = [
146
+ tourSchedulerStyles,
147
+ InputStyles,
148
+ floorplanImageCardStyles,
149
+ itineraryStopStyles,
150
+ css`
151
+ /* New layout only: the header and the list of stops. */
152
+ :host {
153
+ display: block;
154
+ }
155
+
156
+ #confirmationMessage {
157
+ gap: 8px;
158
+ text-align: center;
159
+ }
160
+
161
+ .booked-icon {
162
+ color: var(--primary-color, #202020);
163
+ display: flex;
164
+ }
165
+
166
+ .booked-title {
167
+ font-size: 22px;
168
+ font-weight: 400;
169
+ margin: 4px 0 0;
170
+ }
171
+
172
+ #confirmationMessage > .booked-summary {
173
+ font-size: 16px;
174
+ margin: 0;
175
+ }
176
+
177
+ #confirmationMessage > .error-message {
178
+ font-size: 14px;
179
+ margin: 0;
180
+ }
181
+
182
+ #confirmationMessage > .booked-note {
183
+ color: #737373;
184
+ font-size: 13px;
185
+ margin: 0 0 8px;
186
+ max-width: 28rem;
187
+ }
188
+
189
+ .stops {
190
+ text-align: left;
191
+ }
192
+
193
+ .floorplan-image-card {
194
+ align-items: center;
195
+ min-width: 0;
196
+ }
197
+ `,
198
+ ];
199
+ }
200
+
201
+ declare global {
202
+ interface HTMLElementTagNameMap {
203
+ "booking-confirmation": BookingConfirmation;
204
+ }
205
+ }