@meetelise/chat 1.30.0 → 1.30.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.
Files changed (227) hide show
  1. package/dist/src/MyPubnub.d.ts +116 -0
  2. package/dist/src/WebComponent/FeeCalculator/components/addon-item/addon-item-styles.d.ts +2 -0
  3. package/dist/src/WebComponent/FeeCalculator/components/addon-item/addon-item.d.ts +22 -0
  4. package/dist/src/WebComponent/FeeCalculator/components/addon-item/index.d.ts +1 -0
  5. package/dist/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout-styles.d.ts +2 -0
  6. package/dist/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout.d.ts +34 -0
  7. package/dist/src/WebComponent/FeeCalculator/components/fee-card/fee-card-styles.d.ts +2 -0
  8. package/dist/src/WebComponent/FeeCalculator/components/fee-card/fee-card.d.ts +21 -0
  9. package/dist/src/WebComponent/FeeCalculator/components/fee-item/fee-item-styles.d.ts +2 -0
  10. package/dist/src/WebComponent/FeeCalculator/components/fee-item/fee-item.d.ts +13 -0
  11. package/dist/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles.d.ts +2 -0
  12. package/dist/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector.d.ts +33 -0
  13. package/dist/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles.d.ts +2 -0
  14. package/dist/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card.d.ts +18 -0
  15. package/dist/src/WebComponent/FeeCalculator/components/index.d.ts +5 -0
  16. package/dist/src/WebComponent/FeeCalculator/components/promo-card/promo-card-styles.d.ts +2 -0
  17. package/dist/src/WebComponent/FeeCalculator/components/promo-card/promo-card.d.ts +13 -0
  18. package/dist/src/WebComponent/FeeCalculator/constants.d.ts +2 -0
  19. package/dist/src/WebComponent/FeeCalculator/fee-calculator-styles.d.ts +1 -0
  20. package/dist/src/WebComponent/FeeCalculator/fee-calculator.d.ts +59 -0
  21. package/dist/src/WebComponent/FeeCalculator/index.d.ts +2 -0
  22. package/dist/src/WebComponent/FeeCalculator/model/building-fee.d.ts +80 -0
  23. package/dist/src/WebComponent/FeeCalculator/model/transaction-category.d.ts +23 -0
  24. package/dist/src/WebComponent/LeadSourceClient.d.ts +46 -0
  25. package/dist/src/WebComponent/OfficeHours.d.ts +21 -0
  26. package/dist/src/WebComponent/Scheduler/date-picker.d.ts +28 -0
  27. package/dist/src/WebComponent/Scheduler/time-picker.d.ts +14 -0
  28. package/dist/src/WebComponent/Scheduler/tour-scheduler.d.ts +100 -0
  29. package/dist/src/WebComponent/Scheduler/tour-type-option.d.ts +13 -0
  30. package/dist/src/WebComponent/Scheduler/tourSchedulerStyles.d.ts +1 -0
  31. package/dist/src/WebComponent/actions/InputStyles.d.ts +1 -0
  32. package/dist/src/WebComponent/actions/action-confirm-button.d.ts +13 -0
  33. package/dist/src/WebComponent/actions/call-us-window.d.ts +37 -0
  34. package/dist/src/WebComponent/actions/collapse-expand-button.d.ts +8 -0
  35. package/dist/src/WebComponent/actions/details-window.d.ts +14 -0
  36. package/dist/src/WebComponent/actions/email-us-window.d.ts +46 -0
  37. package/dist/src/WebComponent/actions/formatPhoneNumber.d.ts +17 -0
  38. package/dist/src/WebComponent/actions/minimize-expand-button.d.ts +8 -0
  39. package/dist/src/WebComponent/chat-additional-actions.d.ts +28 -0
  40. package/dist/src/WebComponent/health-chat.d.ts +47 -0
  41. package/dist/src/WebComponent/healthchat-styles.d.ts +1 -0
  42. package/dist/src/WebComponent/icons/ApplyOutlineIcon.d.ts +2 -0
  43. package/dist/src/WebComponent/icons/BookTourOutlineIcon.d.ts +2 -0
  44. package/dist/src/WebComponent/icons/CalculatorOutlineIcon.d.ts +2 -0
  45. package/dist/src/WebComponent/icons/ChatOutlineIcon.d.ts +2 -0
  46. package/dist/src/WebComponent/icons/ChevronLeftIcon.d.ts +2 -0
  47. package/dist/src/WebComponent/icons/ChevronRightIcon.d.ts +2 -0
  48. package/dist/src/WebComponent/icons/ContactResidentIcon.d.ts +2 -0
  49. package/dist/src/WebComponent/icons/DollarOutlineIcon.d.ts +3 -0
  50. package/dist/src/WebComponent/icons/EmailOutlineIcon.d.ts +2 -0
  51. package/dist/src/WebComponent/icons/HeyThereEmojiIcon.d.ts +2 -0
  52. package/dist/src/WebComponent/icons/PhoneOutlineIcon.d.ts +2 -0
  53. package/dist/src/WebComponent/icons/SendMessageIcon.d.ts +3 -0
  54. package/dist/src/WebComponent/icons/TourSelfGuidedIcon.d.ts +2 -0
  55. package/dist/src/WebComponent/icons/TourVirtuallyIcon.d.ts +2 -0
  56. package/dist/src/WebComponent/icons/TourWithAgentIcon.d.ts +2 -0
  57. package/dist/src/WebComponent/icons/XOutlineIcon.d.ts +2 -0
  58. package/dist/src/WebComponent/index.d.ts +2 -0
  59. package/dist/src/WebComponent/launcher/Launcher.d.ts +98 -0
  60. package/dist/src/WebComponent/launcher/launcherStyles.d.ts +1 -0
  61. package/dist/src/WebComponent/launcher/mobile-launcher.d.ts +27 -0
  62. package/dist/src/WebComponent/launcher/typeEmojiStyles.d.ts +1 -0
  63. package/dist/src/WebComponent/launcher/typeMiniStyles.d.ts +1 -0
  64. package/dist/src/WebComponent/launcher/typeMobileStyles.d.ts +1 -0
  65. package/dist/src/WebComponent/leasing-chat-styles.d.ts +1 -0
  66. package/dist/src/WebComponent/me-chat.d.ts +91 -0
  67. package/dist/src/WebComponent/me-select.d.ts +24 -0
  68. package/dist/src/WebComponent/mega-loader.d.ts +7 -0
  69. package/dist/src/WebComponent/mini-loader.d.ts +5 -0
  70. package/dist/src/WebComponent/pubnub-chat-styles.d.ts +1 -0
  71. package/dist/src/WebComponent/pubnub-chat.d.ts +49 -0
  72. package/dist/src/WebComponent/pubnub-media.d.ts +14 -0
  73. package/dist/src/WebComponent/pubnub-message-styles.d.ts +1 -0
  74. package/dist/src/WebComponent/pubnub-message.d.ts +39 -0
  75. package/dist/src/WebComponent/simple-launcher/simple-launcher-styles.d.ts +1 -0
  76. package/dist/src/WebComponent/simple-launcher/simple-launcher.d.ts +12 -0
  77. package/dist/src/WebComponent/utilities-chat.d.ts +47 -0
  78. package/dist/src/WebComponent/utilities-styles.d.ts +1 -0
  79. package/dist/src/WebComponent/utils.d.ts +31 -0
  80. package/dist/src/analytics.d.ts +64 -0
  81. package/dist/src/disclaimers.d.ts +8 -0
  82. package/dist/src/fetchBuildingABTestType.d.ts +8 -0
  83. package/dist/src/fetchBuildingInfo.d.ts +57 -0
  84. package/dist/src/fetchBuildingWebchatView.d.ts +123 -0
  85. package/dist/src/fetchFeatureFlag.d.ts +14 -0
  86. package/dist/src/fetchLeadSources.d.ts +4 -0
  87. package/dist/src/fetchPhoneNumberFromSource.d.ts +6 -0
  88. package/dist/src/getAvailabilities.d.ts +45 -0
  89. package/dist/src/getBuildingPhoneNumber.d.ts +1 -0
  90. package/dist/src/getShouldAllowScheduling.d.ts +1 -0
  91. package/dist/src/getShouldShowWebchat.d.ts +3 -0
  92. package/dist/src/getTimezoneString.d.ts +1 -0
  93. package/dist/src/globals.d.ts +1 -0
  94. package/dist/src/gtm.d.ts +6 -0
  95. package/dist/src/handleChatId.d.ts +11 -0
  96. package/dist/src/insertDNIIntoWebsite.d.ts +5 -0
  97. package/dist/src/insertLeadSourceIntoSchedulerLinks.d.ts +4 -0
  98. package/dist/src/main/MEChat.d.ts +74 -0
  99. package/dist/src/main/utils.d.ts +2 -0
  100. package/dist/src/postLeadSources.d.ts +3 -0
  101. package/dist/src/rentgrata.d.ts +4 -0
  102. package/dist/src/replaceSelectButtonsWithNewLink.d.ts +5 -0
  103. package/dist/src/services/fees/calculateQuote.d.ts +52 -0
  104. package/dist/src/services/fees/fetchBuildingFees.d.ts +24 -0
  105. package/dist/src/services/fees/fetchBuildingFloorplans.d.ts +21 -0
  106. package/dist/src/services/fees/utils.d.ts +1 -0
  107. package/dist/src/svgIcons.d.ts +5 -0
  108. package/dist/src/themes.d.ts +5 -0
  109. package/dist/src/types/rest-sdk.types.d.ts +11 -0
  110. package/dist/src/types/webchat-no-show-reason.d.ts +1 -0
  111. package/dist/src/utils.d.ts +13 -0
  112. package/package.json +1 -1
  113. package/src/MyPubnub.ts +792 -0
  114. package/src/WebComponent/FeeCalculator/components/addon-item/addon-item-styles.ts +79 -0
  115. package/src/WebComponent/FeeCalculator/components/addon-item/addon-item.ts +121 -0
  116. package/src/WebComponent/FeeCalculator/components/addon-item/index.ts +1 -0
  117. package/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout-styles.ts +127 -0
  118. package/src/WebComponent/FeeCalculator/components/fee-calculator-layout/fee-calculator-layout.ts +191 -0
  119. package/src/WebComponent/FeeCalculator/components/fee-card/fee-card-styles.ts +65 -0
  120. package/src/WebComponent/FeeCalculator/components/fee-card/fee-card.ts +91 -0
  121. package/src/WebComponent/FeeCalculator/components/fee-item/fee-item-styles.ts +44 -0
  122. package/src/WebComponent/FeeCalculator/components/fee-item/fee-item.ts +38 -0
  123. package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles.ts +144 -0
  124. package/src/WebComponent/FeeCalculator/components/floor-plan-selector/floor-plan-selector.ts +241 -0
  125. package/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card-styles.ts +74 -0
  126. package/src/WebComponent/FeeCalculator/components/floorplan-image-card/floorplan-image-card.ts +72 -0
  127. package/src/WebComponent/FeeCalculator/components/index.ts +5 -0
  128. package/src/WebComponent/FeeCalculator/components/promo-card/promo-card-styles.ts +39 -0
  129. package/src/WebComponent/FeeCalculator/components/promo-card/promo-card.ts +39 -0
  130. package/src/WebComponent/FeeCalculator/constants.ts +3 -0
  131. package/src/WebComponent/FeeCalculator/fee-calculator-styles.ts +334 -0
  132. package/src/WebComponent/FeeCalculator/fee-calculator.ts +369 -0
  133. package/src/WebComponent/FeeCalculator/index.ts +4 -0
  134. package/src/WebComponent/FeeCalculator/model/building-fee.ts +120 -0
  135. package/src/WebComponent/FeeCalculator/model/transaction-category.ts +23 -0
  136. package/src/WebComponent/LeadSourceClient.ts +332 -0
  137. package/src/WebComponent/MEChat.css +5 -0
  138. package/src/WebComponent/OfficeHours.ts +73 -0
  139. package/src/WebComponent/Scheduler/date-picker.ts +405 -0
  140. package/src/WebComponent/Scheduler/time-picker.ts +190 -0
  141. package/src/WebComponent/Scheduler/tour-scheduler.ts +1373 -0
  142. package/src/WebComponent/Scheduler/tour-type-option.ts +112 -0
  143. package/src/WebComponent/Scheduler/tourSchedulerStyles.ts +418 -0
  144. package/src/WebComponent/actions/InputStyles.ts +57 -0
  145. package/src/WebComponent/actions/action-confirm-button.ts +125 -0
  146. package/src/WebComponent/actions/call-us-window.ts +445 -0
  147. package/src/WebComponent/actions/collapse-expand-button.ts +65 -0
  148. package/src/WebComponent/actions/details-window.ts +150 -0
  149. package/src/WebComponent/actions/email-us-window.ts +555 -0
  150. package/src/WebComponent/actions/formatPhoneNumber.ts +72 -0
  151. package/src/WebComponent/actions/minimize-expand-button.ts +93 -0
  152. package/src/WebComponent/chat-additional-actions.ts +135 -0
  153. package/src/WebComponent/health-chat.ts +270 -0
  154. package/src/WebComponent/healthchat-styles.ts +119 -0
  155. package/src/WebComponent/icons/ApplyOutlineIcon.ts +22 -0
  156. package/src/WebComponent/icons/BookTourOutlineIcon.ts +13 -0
  157. package/src/WebComponent/icons/CalculatorOutlineIcon.ts +22 -0
  158. package/src/WebComponent/icons/ChatOutlineIcon.ts +10 -0
  159. package/src/WebComponent/icons/ChevronLeftIcon.ts +7 -0
  160. package/src/WebComponent/icons/ChevronRightIcon.ts +7 -0
  161. package/src/WebComponent/icons/ContactResidentIcon.ts +9 -0
  162. package/src/WebComponent/icons/DollarOutlineIcon.ts +18 -0
  163. package/src/WebComponent/icons/EmailOutlineIcon.ts +7 -0
  164. package/src/WebComponent/icons/HeyThereEmojiIcon.ts +12 -0
  165. package/src/WebComponent/icons/PhoneOutlineIcon.ts +7 -0
  166. package/src/WebComponent/icons/SendMessageIcon.ts +17 -0
  167. package/src/WebComponent/icons/TourSelfGuidedIcon.ts +17 -0
  168. package/src/WebComponent/icons/TourVirtuallyIcon.ts +17 -0
  169. package/src/WebComponent/icons/TourWithAgentIcon.ts +17 -0
  170. package/src/WebComponent/icons/XOutlineIcon.ts +8 -0
  171. package/src/WebComponent/index.ts +2 -0
  172. package/src/WebComponent/launcher/Launcher.ts +1282 -0
  173. package/src/WebComponent/launcher/launcherStyles.ts +500 -0
  174. package/src/WebComponent/launcher/mobile-launcher.ts +162 -0
  175. package/src/WebComponent/launcher/typeEmojiStyles.ts +161 -0
  176. package/src/WebComponent/launcher/typeMiniStyles.ts +60 -0
  177. package/src/WebComponent/launcher/typeMobileStyles.ts +50 -0
  178. package/src/WebComponent/leasing-chat-styles.ts +114 -0
  179. package/src/WebComponent/me-chat.ts +1262 -0
  180. package/src/WebComponent/me-select.ts +322 -0
  181. package/src/WebComponent/mega-loader.ts +36 -0
  182. package/src/WebComponent/mini-loader.ts +28 -0
  183. package/src/WebComponent/pubnub-chat-styles.ts +204 -0
  184. package/src/WebComponent/pubnub-chat.ts +928 -0
  185. package/src/WebComponent/pubnub-media.ts +208 -0
  186. package/src/WebComponent/pubnub-message-styles.ts +54 -0
  187. package/src/WebComponent/pubnub-message.ts +431 -0
  188. package/src/WebComponent/simple-launcher/simple-launcher-styles.ts +34 -0
  189. package/src/WebComponent/simple-launcher/simple-launcher.ts +100 -0
  190. package/src/WebComponent/utilities-chat.ts +270 -0
  191. package/src/WebComponent/utilities-styles.ts +110 -0
  192. package/src/WebComponent/utils.ts +82 -0
  193. package/src/analytics.ts +217 -0
  194. package/src/assetUrls.ts +6 -0
  195. package/src/disclaimers.ts +58 -0
  196. package/src/fetchBuildingABTestType.ts +21 -0
  197. package/src/fetchBuildingInfo.ts +87 -0
  198. package/src/fetchBuildingWebchatView.ts +156 -0
  199. package/src/fetchFeatureFlag.ts +250 -0
  200. package/src/fetchLeadSources.ts +98 -0
  201. package/src/fetchPhoneNumberFromSource.ts +31 -0
  202. package/src/fetchWebchatPreferences.ts +54 -0
  203. package/src/getAvailabilities.ts +179 -0
  204. package/src/getBuildingPhoneNumber.ts +26 -0
  205. package/src/getShouldAllowScheduling.ts +16 -0
  206. package/src/getShouldShowWebchat.ts +114 -0
  207. package/src/getTimezoneString.ts +39 -0
  208. package/src/globals.ts +1 -0
  209. package/src/gtm.ts +17 -0
  210. package/src/handleChatId.ts +101 -0
  211. package/src/insertDNIIntoWebsite.ts +146 -0
  212. package/src/insertLeadSourceIntoSchedulerLinks.ts +71 -0
  213. package/src/main/MEChat.test.ts +110 -0
  214. package/src/main/MEChat.ts +404 -0
  215. package/src/main/utils.ts +70 -0
  216. package/src/postLeadSources.ts +44 -0
  217. package/src/rentgrata.ts +74 -0
  218. package/src/replaceSelectButtonsWithNewLink.ts +69 -0
  219. package/src/services/fees/calculateQuote.ts +135 -0
  220. package/src/services/fees/fetchBuildingFees.ts +63 -0
  221. package/src/services/fees/fetchBuildingFloorplans.ts +74 -0
  222. package/src/services/fees/utils.ts +4 -0
  223. package/src/svgIcons.ts +14 -0
  224. package/src/themes.ts +65 -0
  225. package/src/types/rest-sdk.types.ts +13 -0
  226. package/src/types/webchat-no-show-reason.ts +6 -0
  227. package/src/utils.ts +121 -0
@@ -0,0 +1,555 @@
1
+ import { css, html, LitElement, TemplateResult } from "lit";
2
+ import { customElement, property, query, state } from "lit/decorators.js";
3
+ import { classMap } from "lit/directives/class-map.js";
4
+ import { createRef, ref, Ref } from "lit/directives/ref.js";
5
+ import { installActionConfirmButton } from "./action-confirm-button";
6
+ import { installDetailsWindow } from "./details-window";
7
+ import "../me-select.ts";
8
+ import { MESelect } from "../me-select";
9
+ import {
10
+ formatToPhoneInput,
11
+ isModifierKey,
12
+ isNumericInput,
13
+ } from "./formatPhoneNumber";
14
+ import { InputStyles } from "./InputStyles";
15
+ import axios from "axios";
16
+ import { FeatureFlagsShowDropdown } from "../../fetchFeatureFlag";
17
+ import { pushGtmEvent } from "../../gtm";
18
+ import disclaimer from "../../disclaimers";
19
+ import { isMobile } from "../../utils";
20
+ import LeadSourceClient, {
21
+ getDefaultLeadSourceAttribution,
22
+ } from "../LeadSourceClient";
23
+
24
+ @customElement("email-us-window")
25
+ export class EmailUsWindow extends LitElement {
26
+ static styles = [
27
+ css`
28
+ .email-us__name-input,
29
+ .email-us__contact_input,
30
+ .email-us_message-input {
31
+ white-space: nowrap;
32
+ overflow: hidden;
33
+ text-overflow: ellipsis;
34
+ }
35
+
36
+ .email-us__name-input {
37
+ width: 50%;
38
+ }
39
+
40
+ .email-us__name-wrapper {
41
+ display: flex;
42
+ gap: 4px;
43
+ }
44
+
45
+ .email-us__contact-input {
46
+ width: 100%;
47
+ width: -webkit-fill-available;
48
+ width: -moz-available;
49
+ }
50
+
51
+ .email-us__vertical-spacer {
52
+ margin-top: 8px;
53
+ margin-bottom: 8px;
54
+ }
55
+
56
+ .action-bttn-container {
57
+ margin-top: 19px;
58
+ display: flex;
59
+ justify-content: flex-end;
60
+ }
61
+
62
+ .email-us__message-input {
63
+ resize: none;
64
+ width: 100%;
65
+ width: -webkit-fill-available;
66
+ width: -moz-available;
67
+ height: 159px;
68
+ }
69
+
70
+ .email-us__submitted-info {
71
+ font-size: 18px;
72
+ line-height: 24px;
73
+ color: #202020;
74
+ }
75
+
76
+ .email-us__error-text {
77
+ margin-top: 4px;
78
+ font-family: "Helvetica", Arial;
79
+ font-style: normal;
80
+ font-weight: 400;
81
+ font-size: 12px;
82
+ line-height: 14px;
83
+
84
+ color: rgb(235, 64, 52);
85
+ }
86
+
87
+ .email-us__center_icon {
88
+ display: flex;
89
+ justify-content: center;
90
+ }
91
+
92
+ @media screen and (max-width: 767px) {
93
+ .email-us__name-input {
94
+ width: 50%;
95
+ }
96
+ }
97
+ `,
98
+ InputStyles,
99
+ ];
100
+
101
+ @property({ attribute: false })
102
+ leadSources: string[] = [];
103
+
104
+ @property({ attribute: false })
105
+ onCloseClicked?: (e: MouseEvent) => void;
106
+
107
+ @property({ attribute: true })
108
+ chatId = "";
109
+ @property({ attribute: false })
110
+ buildingId = 0;
111
+ @property({ attribute: true })
112
+ buildingSlug = "";
113
+ @property({ attribute: true })
114
+ orgSlug = "";
115
+ @property({ attribute: true })
116
+ buildingName = "";
117
+ @property({ attribute: true })
118
+ orgLegalName = "";
119
+
120
+ @property({ attribute: true })
121
+ private leadSourceClient: LeadSourceClient | null = null;
122
+
123
+ @property({ attribute: true })
124
+ featureFlagShowDropdown = "";
125
+
126
+ phoneNumberInputRef: Ref<HTMLInputElement> = createRef();
127
+
128
+ @property()
129
+ privatePolicyUrl = "https://www.meetelise.com/privacy";
130
+ @property()
131
+ termsOfServiceUrl = "_blank";
132
+
133
+ @state()
134
+ firstName = "";
135
+ @state()
136
+ lastName = "";
137
+ @state()
138
+ email = "";
139
+ @state()
140
+ phoneNumber = "";
141
+ @state()
142
+ message = "";
143
+
144
+ @query("me-select#leadSource")
145
+ selectedLeadSource!: MESelect;
146
+
147
+ @property({ attribute: true })
148
+ currentLeadSource = ""; // the default lead source based on referrer and query params
149
+
150
+ @state()
151
+ hasNameError = false;
152
+ @state()
153
+ hasEmailError = false;
154
+ @state()
155
+ hasPhoneNumberError = false;
156
+ @state()
157
+ hasMessageError = false;
158
+ @state()
159
+ hasSubmittedForm = false;
160
+ @state()
161
+ windowHeight = 525;
162
+ @state()
163
+ hasSubmissionError = false;
164
+ @state()
165
+ isSubmitting = false;
166
+
167
+ onChangeFirstName = (e: Event): void => {
168
+ if (!e.target) {
169
+ return;
170
+ }
171
+
172
+ this.firstName = (e.target as HTMLInputElement).value;
173
+ };
174
+
175
+ onChangeLastName = (e: Event): void => {
176
+ if (!e.target) {
177
+ return;
178
+ }
179
+
180
+ this.lastName = (e.target as HTMLInputElement).value;
181
+ };
182
+
183
+ onChangeEmail = (e: Event): void => {
184
+ if (!e.target) {
185
+ return;
186
+ }
187
+
188
+ this.email = (e.target as HTMLInputElement).value;
189
+ };
190
+
191
+ onChangePhoneNumber = (e: Event): void => {
192
+ if (!e.target || !this.phoneNumberInputRef.value) {
193
+ return;
194
+ }
195
+ if (isModifierKey(e as KeyboardEvent)) {
196
+ return;
197
+ }
198
+ const inputElement = e.target as HTMLInputElement;
199
+
200
+ this.phoneNumber = formatToPhoneInput(inputElement.value);
201
+
202
+ this.phoneNumberInputRef.value.value = this.phoneNumber;
203
+ };
204
+
205
+ onChangeMessage = (e: Event): void => {
206
+ if (!e.target) {
207
+ return;
208
+ }
209
+
210
+ this.message = (e.target as HTMLTextAreaElement).value;
211
+ };
212
+
213
+ enforceFormat = (e: KeyboardEvent): void => {
214
+ if (!isNumericInput(e) && !isModifierKey(e)) {
215
+ e.preventDefault();
216
+ }
217
+ };
218
+
219
+ validateFormFields = (): void => {
220
+ this.hasNameError = false;
221
+ this.hasEmailError = false;
222
+ this.hasPhoneNumberError = false;
223
+ this.hasMessageError = false;
224
+ this.hasSubmissionError = false;
225
+ if (!this.firstName || !this.lastName) {
226
+ this.hasNameError = true;
227
+ }
228
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
229
+ if (!this.email || !emailRegex.test(this.email)) {
230
+ this.hasEmailError = true;
231
+ }
232
+ if (!this.phoneNumber || this.phoneNumber.length !== 14) {
233
+ this.hasPhoneNumberError = true;
234
+ }
235
+ this.windowHeight = 525 + 30 * this.getNumErrors();
236
+ };
237
+
238
+ onClick = async (): Promise<void> => {
239
+ if (this.isSubmitting) {
240
+ return;
241
+ }
242
+ this.validateFormFields();
243
+ if (
244
+ this.hasNameError ||
245
+ this.hasEmailError ||
246
+ this.hasPhoneNumberError ||
247
+ this.hasMessageError
248
+ ) {
249
+ return;
250
+ }
251
+ try {
252
+ this.isSubmitting = true;
253
+ // Height of the button when it's in the loading state
254
+ this.windowHeight = 525 + 60;
255
+ const parsedLeadSource =
256
+ this.selectedLeadSource && this.selectedLeadSource.value
257
+ ? this.selectedLeadSource.value
258
+ : this.currentLeadSource;
259
+ await createEmail(
260
+ this.firstName,
261
+ this.lastName,
262
+ this.email,
263
+ this.phoneNumber,
264
+ this.message,
265
+ this.buildingId,
266
+ this.orgSlug,
267
+ this.buildingSlug,
268
+ [
269
+ ...new Set(
270
+ parsedLeadSource
271
+ ? [
272
+ parsedLeadSource,
273
+ getDefaultLeadSourceAttribution(this.orgSlug),
274
+ ]
275
+ : [getDefaultLeadSourceAttribution(this.orgSlug)]
276
+ ),
277
+ ],
278
+ this.leadSourceClient?.chatId
279
+ );
280
+ this.leadSourceClient?.checkAndHandleForLogLeadSource({
281
+ webchatAction: "email-us",
282
+ stateId: null,
283
+ });
284
+ this.hasSubmittedForm = true;
285
+ this.isSubmitting = false;
286
+ // Remove the height of the button when it leaves the loading state
287
+ this.windowHeight = 525;
288
+ } catch (e) {
289
+ this.hasSubmissionError = true;
290
+ this.isSubmitting = false;
291
+ // Remove the height of the button when it leaves the loading state
292
+ this.windowHeight = 525;
293
+ }
294
+ };
295
+
296
+ getNumErrors = (): number => {
297
+ return [
298
+ this.hasNameError,
299
+ this.hasEmailError,
300
+ this.hasPhoneNumberError,
301
+ this.hasMessageError,
302
+ this.hasSubmissionError,
303
+ ].filter((v) => v).length;
304
+ };
305
+
306
+ render = (): TemplateResult => {
307
+ installDetailsWindow();
308
+ installActionConfirmButton();
309
+
310
+ if (this.hasSubmittedForm) {
311
+ return html`
312
+ <details-window
313
+ id="details-window"
314
+ headerText=""
315
+ useGradientDesign="true"
316
+ .onCloseClick=${this.onCloseClicked}
317
+ >
318
+ <div class="email-us-wrapper">
319
+ <div class="email-us__vertical-spacer"></div>
320
+ <div class="email-us__center_icon">
321
+ <svg
322
+ width="22"
323
+ height="18"
324
+ viewBox="0 0 22 18"
325
+ fill="none"
326
+ xmlns="http://www.w3.org/2000/svg"
327
+ >
328
+ <path
329
+ d="M22 17.007C21.9982 17.2696 21.8931 17.521 21.7075 17.7068C21.5219 17.8926 21.2706 17.9979 21.008 18H2.992C2.72881 17.9997 2.4765 17.895 2.29049 17.7088C2.10448 17.5226 2 17.2702 2 17.007V16H20V4.3L12 11.5L2 2.5V1C2 0.734784 2.10536 0.48043 2.29289 0.292893C2.48043 0.105357 2.73478 0 3 0H21C21.2652 0 21.5196 0.105357 21.7071 0.292893C21.8946 0.48043 22 0.734784 22 1V17.007ZM4.434 2L12 8.81L19.566 2H4.434ZM0 12H8V14H0V12ZM0 7H5V9H0V7Z"
330
+ fill="#202020"
331
+ />
332
+ </svg>
333
+ </div>
334
+ <div class="email-us__vertical-spacer"></div>
335
+ <div class="email-us__submitted-info">
336
+ Thank you for your message. A member of our leasing team will
337
+ contact you.
338
+ </div>
339
+ </div>
340
+ </details-window>
341
+ `;
342
+ }
343
+
344
+ return html`
345
+ <details-window
346
+ id="details-window"
347
+ headerText="Email Our Leasing Team"
348
+ .onCloseClick=${this.onCloseClicked}
349
+ height="${this.windowHeight}px"
350
+ >
351
+ <div class="email-us-wrapper" id="email-us-form">
352
+ <div class="email-us__name-wrapper">
353
+ <input
354
+ type="text"
355
+ class=${classMap({
356
+ ["webchat-input"]: true,
357
+ ["email-us__name-input"]: true,
358
+ ["webchat-font__desktop"]: !isMobile(),
359
+ ["webchat-font__mobile"]: isMobile(),
360
+ })}
361
+ placeholder="First name"
362
+ autocomplete="given-name"
363
+ value="${this.firstName}"
364
+ @keyup=${this.onChangeFirstName}
365
+ />
366
+ <div class="email-us__horizontal-spacer"></div>
367
+ <input
368
+ type="text"
369
+ class=${classMap({
370
+ ["webchat-input"]: true,
371
+ ["email-us__name-input"]: true,
372
+ ["webchat-font__desktop"]: !isMobile(),
373
+ ["webchat-font__mobile"]: isMobile(),
374
+ })}
375
+ placeholder="Last name"
376
+ autocomplete="family-name"
377
+ value="${this.lastName}"
378
+ @keyup=${this.onChangeLastName}
379
+ />
380
+ </div>
381
+ ${this.hasNameError
382
+ ? html`
383
+ <div class="email-us__error-text">Enter your full name</div>
384
+ `
385
+ : ""}
386
+ <div class="email-us__vertical-spacer"></div>
387
+ <input
388
+ type="email"
389
+ placeholder="Email"
390
+ autocomplete="email"
391
+ class=${classMap({
392
+ ["webchat-input"]: true,
393
+ ["email-us__contact-input"]: true,
394
+ ["webchat-font__desktop"]: !isMobile(),
395
+ ["webchat-font__mobile"]: isMobile(),
396
+ })}
397
+ .value=${this.email}
398
+ @keyup=${this.onChangeEmail}
399
+ />
400
+ ${this.hasEmailError
401
+ ? html`
402
+ <div class="email-us__error-text">
403
+ Enter valid email address
404
+ </div>
405
+ `
406
+ : ""}
407
+ <div class="email-us__vertical-spacer"></div>
408
+ <input
409
+ ${ref(this.phoneNumberInputRef)}
410
+ type="text"
411
+ placeholder="Phone"
412
+ autocomplete="tel-national"
413
+ inputmode="tel"
414
+ class=${classMap({
415
+ ["webchat-input"]: true,
416
+ ["email-us__contact-input"]: true,
417
+ ["webchat-font__desktop"]: !isMobile(),
418
+ ["webchat-font__mobile"]: isMobile(),
419
+ })}
420
+ .value=${this.phoneNumber}
421
+ maxlength="14"
422
+ @keydown=${this.enforceFormat}
423
+ @keyup=${this.onChangePhoneNumber}
424
+ />
425
+ ${this.hasPhoneNumberError
426
+ ? html`
427
+ <div class="email-us__error-text">
428
+ Enter a valid phone number
429
+ </div>
430
+ `
431
+ : ""}
432
+ <div class="email-us__vertical-spacer"></div>
433
+ ${this.leadSources.length > 0 &&
434
+ (this.featureFlagShowDropdown === FeatureFlagsShowDropdown.always ||
435
+ (this.featureFlagShowDropdown ===
436
+ FeatureFlagsShowDropdown.onAttributionFailure &&
437
+ this.currentLeadSource.length === 0))
438
+ ? html`
439
+ <me-select
440
+ id="leadSource"
441
+ placeholder="How did you hear about us?"
442
+ value="${this.currentLeadSource}"
443
+ .options="${this.leadSources.map((i) => ({
444
+ label: i,
445
+ value: i,
446
+ }))}"
447
+ @change=${() => {
448
+ this.requestUpdate();
449
+ }}
450
+ >
451
+ </me-select>
452
+ `
453
+ : ""}
454
+ <div class="email-us__vertical-spacer"></div>
455
+ <textarea
456
+ placeholder="Your message..."
457
+ .value=${this.message}
458
+ class=${classMap({
459
+ ["email-us__message-input"]: true,
460
+ ["webchat-input"]: true,
461
+ ["webchat-textarea"]: true,
462
+ ["webchat-font__desktop"]: !isMobile(),
463
+ ["webchat-font__mobile"]: isMobile(),
464
+ })}
465
+ @keyup=${this.onChangeMessage}
466
+ ></textarea>
467
+ ${this.hasMessageError
468
+ ? html` <div class="email-us__error-text">Include a message</div> `
469
+ : ""}
470
+ <div class="action-bttn-container">
471
+ <action-confirm-button
472
+ .onClick=${this.onClick}
473
+ .isLoading=${this.isSubmitting}
474
+ text="SEND"
475
+ ></action-confirm-button>
476
+ </div>
477
+ ${this.hasSubmissionError
478
+ ? html`
479
+ <div class="email-us__error-text">Error submitting message</div>
480
+ `
481
+ : ""}
482
+ </div>
483
+
484
+ ${disclaimer({
485
+ buildingName: this.buildingName,
486
+ phoneNumberInput: this.phoneNumber,
487
+ emailInput: this.email,
488
+ orgLegalName: this.orgLegalName,
489
+ })}
490
+ </details-window>
491
+ `;
492
+ };
493
+ }
494
+
495
+ export const installEmailUsWindow = (): void => {
496
+ if (!window.customElements.get("email-us-window")) {
497
+ window.customElements.define("email-us-window", EmailUsWindow);
498
+ }
499
+ };
500
+
501
+ const createEmail = async (
502
+ firstName: string,
503
+ lastName: string,
504
+ email: string,
505
+ rawPhoneNumber: string,
506
+ message: string,
507
+ buildingId: number,
508
+ orgSlug: string,
509
+ buildingSlug: string,
510
+ leadSources: string[],
511
+ chatId?: string | null
512
+ ) => {
513
+ const formattedPhoneNumber =
514
+ "+1" +
515
+ rawPhoneNumber
516
+ .replace("(", "")
517
+ .replace(")", "")
518
+ .replace(" ", "")
519
+ .replace("-", "");
520
+ const queryParams = new URLSearchParams(window.location.search);
521
+ const requestBody = {
522
+ email_address: email,
523
+ building_id: buildingId,
524
+ lead_sources: leadSources,
525
+ first_message: message,
526
+ first_name: firstName,
527
+ last_name: lastName,
528
+ phone_number: formattedPhoneNumber,
529
+ referrer: document.referrer,
530
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
531
+ // @ts-ignore
532
+ query_params: Object.fromEntries(queryParams.entries()),
533
+ conversation_tracking_id: chatId,
534
+ };
535
+ pushGtmEvent("emailUsSubmitted", {
536
+ firstName,
537
+ lastName,
538
+ email,
539
+ phone: formattedPhoneNumber,
540
+ message,
541
+ originatingSource:
542
+ leadSources.find((i) => i !== "property-website") || null,
543
+ });
544
+ await axios.post(
545
+ "https://app.meetelise.com/platformApi/state/create/emailMe",
546
+ requestBody,
547
+ {
548
+ headers: {
549
+ ["building-slug"]: buildingSlug,
550
+ ["org-slug"]: orgSlug,
551
+ ["X-SecurityKey"]: "JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG",
552
+ },
553
+ }
554
+ );
555
+ };
@@ -0,0 +1,72 @@
1
+ /**
2
+ * For now, only handles the US phone number case.....
3
+ * Formats into phone number as you type
4
+ */
5
+ export const formatToPhoneInput = (phoneNumber: string): string => {
6
+ const input = phoneNumber.replace(/\D/g, "").substring(0, 10);
7
+ const areaCode = input.substring(0, 3);
8
+ const middle = input.substring(3, 6);
9
+ const last = input.substring(6, 10);
10
+
11
+ if (input.length > 5) {
12
+ return `(${areaCode}) ${middle}-${last}`;
13
+ }
14
+ if (input.length > 2) {
15
+ return `(${areaCode}) ${middle}`;
16
+ }
17
+ if (input.length > 0) {
18
+ return `(${areaCode}`;
19
+ }
20
+ return "";
21
+ };
22
+
23
+ /**
24
+ * Formats a phone number into a human-readable format.
25
+ */
26
+ export const formatPhoneNumber = (phoneNumberString: string): string => {
27
+ const cleaned = ("" + phoneNumberString).replace(/\D/g, "");
28
+ const match = cleaned.match(/^(1|)?(\d{3})(\d{3})(\d{4})$/);
29
+ if (match) {
30
+ const intlCode = match[1] ? "+1 " : "";
31
+ return [intlCode, "(", match[2], ") ", match[3], "-", match[4]].join("");
32
+ }
33
+ return phoneNumberString;
34
+ };
35
+
36
+ export const isNumericInput = (event: KeyboardEvent): boolean => {
37
+ const key = event.keyCode;
38
+ return (key >= 48 && key <= 57) || (key >= 96 && key <= 105);
39
+ };
40
+
41
+ export const isPrintableCharacter = (event: KeyboardEvent): boolean =>
42
+ event.key.length === 1;
43
+
44
+ /** Returns true if any key is pressed whose only function when typing text would be as part of a keyboard shortcut.
45
+ * For example, `Shift` or `f` would not suffice, because these are used for typing text.
46
+ * But `Command` or `Control` would.
47
+ */
48
+ export const shortcutKeyIsPressed = (event: KeyboardEvent): boolean =>
49
+ event.altKey || event.ctrlKey || event.metaKey;
50
+
51
+ export const isModifierKey = (event: KeyboardEvent): boolean => {
52
+ const key = event.keyCode;
53
+ // TODO: whitelisting specific keyboard shortcuts is brittle (e.g. this is missing Cmd + R to reload)
54
+ // Allow left, up, right, down, Backspace, Tab, Enter, Delete, Ctrl/Command + A,C,L,V,X,Z, Shift, Home, End
55
+ return (
56
+ event.shiftKey ||
57
+ key === 35 ||
58
+ key === 36 || // Allow
59
+ key === 8 ||
60
+ key === 9 ||
61
+ key === 13 ||
62
+ key === 46 ||
63
+ (key > 36 && key < 41) ||
64
+ ((event.ctrlKey || event.metaKey) &&
65
+ (key === 65 ||
66
+ key === 67 ||
67
+ key === 76 ||
68
+ key === 86 ||
69
+ key === 88 ||
70
+ key === 90))
71
+ );
72
+ };
@@ -0,0 +1,93 @@
1
+ import { css, html, LitElement, TemplateResult } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+ import { styleMap } from "lit/directives/style-map.js";
4
+ import { defaultPrimaryColor } from "../../themes";
5
+ import { ChevronRightIcon } from "../icons/ChevronRightIcon";
6
+ import { XOutlineIcon } from "../icons/XOutlineIcon";
7
+
8
+ @customElement("minimize-expand-button")
9
+ export class MinimizeExpandButton extends LitElement {
10
+ static styles = [
11
+ css`
12
+ .button-container {
13
+ width: 56px;
14
+ height: 56px;
15
+
16
+ background: #ffffff;
17
+ border: 1px solid rgba(95, 95, 95, 0.2);
18
+ border-radius: 1000px;
19
+
20
+ display: flex;
21
+ justify-content: center;
22
+ align-items: center;
23
+ }
24
+ .mini {
25
+ width: 36px;
26
+ height: 36px;
27
+ }
28
+ .inner-container {
29
+ width: 46px;
30
+ height: 46px;
31
+
32
+ border-radius: 1000px;
33
+ border: 1px solid rgba(255, 255, 255, 0.7);
34
+
35
+ display: flex;
36
+ justify-content: center;
37
+ align-items: center;
38
+ text-align: center;
39
+ }
40
+ .mini > .inner-container {
41
+ width: 30px;
42
+ height: 30px;
43
+ }
44
+ .x-icon,
45
+ .chevron-up {
46
+ width: 100%;
47
+ height: 100%;
48
+ display: flex;
49
+ justify-content: center;
50
+ align-items: center;
51
+ border-radius: 1000px;
52
+ }
53
+ .chevron-up {
54
+ transform: rotate(-90deg);
55
+ }
56
+ .button-container:hover {
57
+ cursor: pointer;
58
+ filter: brightness(90%);
59
+ }
60
+ `,
61
+ ];
62
+
63
+ @property({ attribute: true })
64
+ onClick: () => void = () => {
65
+ return;
66
+ };
67
+
68
+ @property({ attribute: true })
69
+ primaryColor: string = defaultPrimaryColor;
70
+
71
+ @property({ attribute: true })
72
+ toExpand = false;
73
+
74
+ render(): TemplateResult {
75
+ return html`
76
+ <div
77
+ class=${this.toExpand ? "button-container mini" : "button-container"}
78
+ @click=${this.onClick}
79
+ >
80
+ <div
81
+ class="inner-container"
82
+ style=${styleMap({
83
+ background: this.primaryColor,
84
+ })}
85
+ >
86
+ ${this.toExpand
87
+ ? html`<div class="chevron-up">${ChevronRightIcon("white")}</div>`
88
+ : html` <div class="x-icon">${XOutlineIcon("white")}</div>`}
89
+ </div>
90
+ </div>
91
+ `;
92
+ }
93
+ }