@meetelise/chat 1.13.7 → 1.13.8
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/package.json
CHANGED
package/public/dist/index.js
CHANGED
|
@@ -430,7 +430,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
430
430
|
.option.active {
|
|
431
431
|
background-color: var(--active-option-color);
|
|
432
432
|
}
|
|
433
|
-
`,Gt([oe({attribute:!1})],zt.prototype,"options",void 0),Gt([oe({type:String})],zt.prototype,"placeholder",void 0),Gt([oe({type:String})],zt.prototype,"value",void 0),Gt([ae()],zt.prototype,"activeOption",void 0),Gt([ae()],zt.prototype,"isOpen",void 0),Gt([se("#select",!0)],zt.prototype,"meSelect",void 0),zt=Gt([ie("me-select")],zt);var Vt=n(9669),Xt=n.n(Vt),Qt=n(7739),Zt=n.n(Qt);const Kt={},Yt=async e=>{if(Kt[e])return Kt[e];const t=function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(0,0,0,0),t}(Date.now()),n=$t(function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ee(2,arguments);var n=Fe(e),i=Ve(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(t,30))),i=`https://app.meetelise.com/api/pub/v1/buildings/${e}/tour/availabilities?startTime=${$t(t)}&endTime=${n}`,r=await Xt().get(i);return Kt[e]=r.data,r.data},en=async e=>(async(e,t)=>{var n,i;const r=await(async(e,t)=>{var n,i;const r=await Yt(e),o=(null===(n=r.availability)||void 0===n?void 0:n[t])?null===(i=r.availability)||void 0===i?void 0:i[t].availableTourStartTimes:[];return r.availability?{...r.availability[t],availableTourStartTimes:o}:null})(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes:[])||void 0===n?void 0:n.map((e=>tn(e)))};return Zt()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Pt(new Date(e.datetime),"yyyy-MM-dd")))})(Object.keys(Kt).map(Number)[0],e),tn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});var nn=n(9991);n(7294);const rn=()=>window.matchMedia("(max-width: 767px)").matches;var on=n(6486),an=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let sn=class extends te{constructor(){super(...arguments),this.layoutOptions=[],this.tourTypeOptions=[],this.buildingId=0,this.tourType=un.Guided,this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.mobilePageIndex=0,this.tourIsBooked=!1,this.firstUpdated=async()=>{this.availabilitiesGroupedByDay=await en(ln[this.tourType])},this.willUpdate=async e=>{e.has("tourType")&&(this.availabilitiesGroupedByDay=await en(ln[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ce(e)){if("Backspace"===e.key){if(Ce(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ce(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>!isNaN(this.tourType),dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t;return!!(null===(e=this.nameInput)||void 0===e?void 0:e.value)&&(null===(t=this.emailInput)||void 0===t?void 0:t.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e;if(!this.selectedDate||!this.selectedTime)return;const t={email_address:this.email,phone_number:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,building_id:this.buildingId,first_name:this.nameInput.value.split(" ")[0],last_name:this.nameInput.value.split(" ").slice(1).join(" "),tour_type:dn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`};200===(await Xt().post("https://app.meetelise.com/platformApi/state/create/scheduleMe",t,{headers:{"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG"}})).status&&(this.tourIsBooked=!0)},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:"Schedule tour",nextButtonAction:this.submit,render:()=>D`${this.userInfoAndLayoutMenu()}`}]}tourTypeMenu(){return D`<h2 id="tourType">Tour Type</h2>
|
|
433
|
+
`,Gt([oe({attribute:!1})],zt.prototype,"options",void 0),Gt([oe({type:String})],zt.prototype,"placeholder",void 0),Gt([oe({type:String})],zt.prototype,"value",void 0),Gt([ae()],zt.prototype,"activeOption",void 0),Gt([ae()],zt.prototype,"isOpen",void 0),Gt([se("#select",!0)],zt.prototype,"meSelect",void 0),zt=Gt([ie("me-select")],zt);var Vt=n(9669),Xt=n.n(Vt),Qt=n(7739),Zt=n.n(Qt);const Kt={},Yt=async e=>{if(Kt[e])return Kt[e];const t=function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(0,0,0,0),t}(Date.now()),n=$t(function(e){Ee(1,arguments);var t=Fe(e);return t.setHours(23,59,59,999),t}(function(e,t){Ee(2,arguments);var n=Fe(e),i=Ve(t);return isNaN(i)?new Date(NaN):i?(n.setDate(n.getDate()+i),n):n}(t,30))),i=`https://app.meetelise.com/api/pub/v1/buildings/${e}/tour/availabilities?startTime=${$t(t)}&endTime=${n}`,r=await Xt().get(i);return Kt[e]=r.data,r.data},en=async e=>(async(e,t)=>{var n,i;const r=await(async(e,t)=>{var n,i;const r=await Yt(e),o=(null===(n=r.availability)||void 0===n?void 0:n[t])?null===(i=r.availability)||void 0===i?void 0:i[t].availableTourStartTimes:[];return r.availability?{...r.availability[t],availableTourStartTimes:o}:null})(e,t);if(!r)return{};const o={availableTourStartTimes:null===(n=r.availableTourStartTimes?r.availableTourStartTimes:[])||void 0===n?void 0:n.map((e=>tn(e)))};return Zt()(null!==(i=o.availableTourStartTimes)&&void 0!==i?i:[],(e=>Pt(new Date(e.datetime),"yyyy-MM-dd")))})(Object.keys(Kt).map(Number)[0],e),tn=e=>({datetime:e.slice(0,19),offset:e.slice(19)});var nn=n(9991);n(7294);const rn=()=>window.matchMedia("(max-width: 767px)").matches;var on=n(6486),an=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a};let sn=class extends te{constructor(){super(...arguments),this.layoutOptions=[],this.tourTypeOptions=[],this.buildingId=0,this.tourType=un.Guided,this.email="",this.phoneNumber="",this.availabilitiesGroupedByDay={},this.mobilePageIndex=0,this.tourIsBooked=!1,this.firstUpdated=async()=>{this.availabilitiesGroupedByDay=await en(ln[this.tourType])},this.willUpdate=async e=>{e.has("tourType")&&(this.availabilitiesGroupedByDay=await en(ln[this.tourType]))},this.handlePhoneKeydown=e=>{var t;if(!(e instanceof KeyboardEvent&&e.target instanceof HTMLInputElement&&null!==e.target.selectionStart))return;const n=e.target.selectionStart;if(1!==e.key.length||Ce(e)){if("Backspace"===e.key){if(Ce(e))return;if(this.phoneInput.selectionEnd&&this.phoneInput.selectionStart&&this.phoneInput.selectionEnd-this.phoneInput.selectionStart>0)return;const t=this.phoneNumber.length,i=this.phoneNumber.slice(0,n).replace(/\D/g,""),r=this.phoneNumber.slice(n).replace(/\D/g,""),o=`${i.slice(0,-1)}${r}`;this.phoneNumber=Ie(o),this.phoneInput.value=this.phoneNumber;const a=n-(t-this.phoneNumber.length);return this.phoneInput.setSelectionRange(a,a),e.preventDefault(),void e.stopPropagation()}if(!["ArrowLeft","ArrowRight"].includes(e.key)||Ce(e)||e.shiftKey)return;if("ArrowLeft"===e.key){const e=((null===(t=this.phoneNumber.slice(0,n).split(/\d+/).at(-1))||void 0===t?void 0:t.length)||0)+1,i=n-e>-1?n-e:0;this.phoneInput.setSelectionRange(i,i)}if("ArrowRight"===e.key){const e=(this.phoneNumber.slice(n).split(/\d+/)[0].length||0)+1,t=n+e<this.phoneNumber.length?n+e:this.phoneNumber.length;this.phoneInput.setSelectionRange(t,t)}e.preventDefault(),e.stopPropagation()}else{e.preventDefault(),e.stopPropagation();const t=this.phoneNumber.slice(0,n)+e.key+this.phoneNumber.slice(n);this.phoneNumber=Ie(t.replace(/\D/g,"")),this.phoneInput.value=this.phoneNumber}},this.handlePhoneKeyup=e=>{var t;if(!e.key)return;if(e.key.includes("Arrow")||["Meta","Shift","Control","Alt"].includes(e.key))return;const n=this.phoneInput.selectionStart,i=n?this.phoneInput.value.slice(n).replace(/\D/g,""):"";this.phoneNumber=Ie(this.phoneInput.value);let r=0,o=i.length;for(;o;)(null===(t=this.phoneNumber.at(r))||void 0===t?void 0:t.match(/\d/))&&o--,r++;const a=this.phoneInput.value.length-r+1;this.phoneInput.setSelectionRange(a,a)},this.onChangeEmail=e=>{e.target&&(this.email=e.target.value)},this.validators={tourType:()=>!isNaN(this.tourType),dateAndTime:()=>!!this.selectedDate&&!!this.selectedTime,leadInfo:()=>{var e,t;return!!(null===(e=this.nameInput)||void 0===e?void 0:e.value)&&(null===(t=this.emailInput)||void 0===t?void 0:t.value.includes("@"))&&!!this.phoneNumber&&14===this.phoneNumber.length}},this.formIsValidForSubmission=()=>this.validators.tourType()&&this.validators.dateAndTime()&&this.validators.leadInfo(),this.timeStringToHoursAndMinutes=e=>{const[t,n]=e.split(/\D/g);return[parseInt(t)+(e.toLowerCase().includes("pm")?12:0),parseInt(n)]},this.submit=async()=>{var e;if(!this.selectedDate||!this.selectedTime)return;const t={email_address:this.email,phone_number:`+1${null===(e=this.phoneNumber.match(/\d/g))||void 0===e?void 0:e.join("")}`,building_id:this.buildingId,first_name:this.nameInput.value.split(" ")[0],last_name:this.nameInput.value.split(" ").slice(1).join(" "),tour_type:dn[this.tourType],tour_time:`${this.selectedTime.datetime}${this.selectedTime.offset}`};200===(await Xt().post("https://app.meetelise.com/platformApi/state/create/scheduleMe",t,{headers:{"X-SecurityKey":"JRL8jV4VcSCwOSir5gWkpgNLfKghmhBG"}})).status&&(this.tourIsBooked=!0)},this.mobilePages=[{validate:this.validators.tourType,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.tourTypeMenu()}`},{validate:this.validators.dateAndTime,nextButtonText:"Next",nextButtonAction:()=>{this.mobilePageIndex++},render:()=>D`${this.dateAndTimeMenu(!0)}`},{validate:()=>this.validators.leadInfo(),nextButtonText:"Schedule tour",nextButtonAction:this.submit,render:()=>D`${this.userInfoAndLayoutMenu()}`}]}tourTypeMenu(){return D`<h2 id="tourType">Tour Type</h2>
|
|
434
434
|
<div id="tourTypeMenu">
|
|
435
435
|
${this.tourTypeOptions.map((e=>e.value)).includes("WITH_AGENT")?D` <tour-type-option
|
|
436
436
|
tourtype="guided"
|
|
@@ -536,14 +536,19 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
536
536
|
</svg>
|
|
537
537
|
</button>`}userInfoAndLayoutMenu(){return D`<h2 id="yourInformation">Your information</h2>
|
|
538
538
|
<div id="yourInformationMenu">
|
|
539
|
-
<input
|
|
539
|
+
<input
|
|
540
|
+
type="text"
|
|
541
|
+
placeholder="Name"
|
|
542
|
+
id="name"
|
|
543
|
+
@input=${()=>this.requestUpdate()}
|
|
544
|
+
/>
|
|
540
545
|
<input
|
|
541
546
|
type="email"
|
|
542
547
|
inputmode="email"
|
|
543
548
|
placeholder="Email"
|
|
544
549
|
id="email"
|
|
545
550
|
.value=${this.email}
|
|
546
|
-
@
|
|
551
|
+
@input=${this.onChangeEmail}
|
|
547
552
|
/>
|
|
548
553
|
<input
|
|
549
554
|
type="tel"
|
|
@@ -554,7 +559,7 @@ var e={8005:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){retur
|
|
|
554
559
|
.value=${this.phoneNumber}
|
|
555
560
|
@keydown=${this.handlePhoneKeydown}
|
|
556
561
|
@keyup=${this.handlePhoneKeyup}
|
|
557
|
-
@
|
|
562
|
+
@input=${e=>{e.target&&(this.phoneNumber=Ie(e.target.value))}}
|
|
558
563
|
/>
|
|
559
564
|
</div>
|
|
560
565
|
|
|
@@ -185,6 +185,9 @@ export class TourScheduler extends LitElement {
|
|
|
185
185
|
};
|
|
186
186
|
|
|
187
187
|
handlePhoneKeyup = (e: KeyboardEvent): void => {
|
|
188
|
+
if (!e.key) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
188
191
|
// After formatting, place the cursor where it was before, defined as "before the digit that followed it before formatting, if any, otherwise at the end".
|
|
189
192
|
// (We never want the cursor to be before a punctuation mark because the next digit typed will appear after the punctuation mark, not before.)
|
|
190
193
|
// If we don't do this, the cursor automatically goes to the end when we set `this.phoneNumber`.
|
|
@@ -230,12 +233,15 @@ export class TourScheduler extends LitElement {
|
|
|
230
233
|
validators = {
|
|
231
234
|
tourType: (): boolean => !isNaN(this.tourType),
|
|
232
235
|
dateAndTime: (): boolean => !!this.selectedDate && !!this.selectedTime,
|
|
233
|
-
leadInfo: (): boolean =>
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
leadInfo: (): boolean => {
|
|
237
|
+
return (
|
|
238
|
+
!!this.nameInput?.value &&
|
|
239
|
+
this.emailInput?.value.includes("@") &&
|
|
240
|
+
// TODO: deleting phone number doesn't cause validation to fail, at least on mobile
|
|
241
|
+
!!this.phoneNumber &&
|
|
242
|
+
this.phoneNumber.length === 14
|
|
243
|
+
);
|
|
244
|
+
},
|
|
239
245
|
};
|
|
240
246
|
|
|
241
247
|
formIsValidForSubmission = (): boolean => {
|
|
@@ -803,14 +809,19 @@ export class TourScheduler extends LitElement {
|
|
|
803
809
|
userInfoAndLayoutMenu(): TemplateResult {
|
|
804
810
|
return html`<h2 id="yourInformation">Your information</h2>
|
|
805
811
|
<div id="yourInformationMenu">
|
|
806
|
-
<input
|
|
812
|
+
<input
|
|
813
|
+
type="text"
|
|
814
|
+
placeholder="Name"
|
|
815
|
+
id="name"
|
|
816
|
+
@input=${() => this.requestUpdate()}
|
|
817
|
+
/>
|
|
807
818
|
<input
|
|
808
819
|
type="email"
|
|
809
820
|
inputmode="email"
|
|
810
821
|
placeholder="Email"
|
|
811
822
|
id="email"
|
|
812
823
|
.value=${this.email}
|
|
813
|
-
@
|
|
824
|
+
@input=${this.onChangeEmail}
|
|
814
825
|
/>
|
|
815
826
|
<input
|
|
816
827
|
type="tel"
|
|
@@ -821,7 +832,14 @@ export class TourScheduler extends LitElement {
|
|
|
821
832
|
.value=${this.phoneNumber}
|
|
822
833
|
@keydown=${this.handlePhoneKeydown}
|
|
823
834
|
@keyup=${this.handlePhoneKeyup}
|
|
824
|
-
@
|
|
835
|
+
@input=${(e: Event) => {
|
|
836
|
+
if (!e.target) {
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
this.phoneNumber = formatToPhone(
|
|
840
|
+
(e.target as HTMLInputElement).value
|
|
841
|
+
);
|
|
842
|
+
}}
|
|
825
843
|
/>
|
|
826
844
|
</div>
|
|
827
845
|
|