@meetelise/chat 1.20.82 → 1.20.83

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.20.82",
3
+ "version": "1.20.83",
4
4
  "description": "",
5
5
  "main": "public/dist/index.js",
6
6
  "type": "module",
@@ -2956,4 +2956,4 @@ var e={8005:function(e,t,i){var n,r=this&&this.__extends||(n=function(e,t){retur
2956
2956
  border-bottom: 22px solid transparent;
2957
2957
  border-right: 30px solid black;
2958
2958
  }
2959
- `,xr.session=null,Ar([de({type:String})],xr.prototype,"buildingSlug",void 0),Ar([de({type:String})],xr.prototype,"orgSlug",void 0),Ar([de({type:String})],xr.prototype,"themeId",void 0),Ar([de({attribute:!1})],xr.prototype,"avatarSrc",void 0),Ar([de({type:Boolean})],xr.prototype,"useMiniWidget",void 0),Ar([de({type:Object})],xr.prototype,"launcherStyles",void 0),Ar([de({type:Boolean})],xr.prototype,"isMinimized",void 0),Ar([de({type:String})],xr.prototype,"brandColor",void 0),Ar([ce()],xr.prototype,"popup",void 0),Ar([ce()],xr.prototype,"theme",void 0),Ar([ce()],xr.prototype,"chatId",void 0),Ar([ce()],xr.prototype,"analytics",void 0),Ar([ce()],xr.prototype,"isMobile",void 0),Ar([ce()],xr.prototype,"launcher",void 0),Ar([ce()],xr.prototype,"building",void 0),Ar([ce()],xr.prototype,"buildingABTestType",void 0),Ar([ce()],xr.prototype,"leadSources",void 0),Ar([ce()],xr.prototype,"currentLeadSource",void 0),Ar([ce()],xr.prototype,"featureFlagShowDropdown",void 0),Ar([ce()],xr.prototype,"phoneNumberForSource",void 0),Ar([ce()],xr.prototype,"hasMounted",void 0),Ar([ce()],xr.prototype,"hideLauncher",void 0),Ar([ce()],xr.prototype,"isLoading",void 0),Ar([ce()],xr.prototype,"talkjsPopupElement",void 0),xr=Tr=Ar([le("me-chat")],xr);class Or{static start(e,t=!0){if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug=e.organization,this.hasBuildingSlug=!!e.building),Cr(),Ir();const i=document.createElement("me-chat");i.setAttribute("orgSlug",e.organization),this.handleBuildingslug(i,e.building),i.setAttribute("class","meetelise-chat"),i.setAttribute("role","dialog"),i.setAttribute("aria-label","EliseAI Widget"),i.setAttribute("aria-describedby","aria-describe-info"),i.setAttribute("aria-modal","true"),e.themeId&&i.setAttribute("themeId",e.themeId),e.avatarSrc&&i.setAttribute("avatarSrc",e.avatarSrc),void 0!==e.mini&&(i.useMiniWidget=e.mini),e.launcherStyles&&(i.launcherStyles=e.launcherStyles),e.brandColor&&(this.brandColor=e.brandColor,i.setAttribute("brandColor",((e,t)=>{const i=(r=e,{r:parseInt(r.substring(1,3),16),g:parseInt(r.substring(3,5),16),b:parseInt(r.substring(5,7),16)}),n={r:i.r+Math.round(.3*(0-i.r)),g:i.g+Math.round(.3*(0-i.g)),b:i.b+Math.round(.3*(0-i.b))};var r;return((e,t,i)=>"#"+[e,t,i].map((e=>{const t=e.toString(16);return 1===t.length?"0"+t:t})).join(""))(n.r,n.g,n.b)})(e.brandColor))),document.body.appendChild(i),Or.meChat=i,e.building&&e.organization&&Nr(e.organization,e.building)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),Or.meChat=null)}static async handleBuildingslug(e,t){t?e.setAttribute("buildingSlug",t):this.mutationObserver||(this.handleSingleFamilyUrl(),this.previousUrl=window.location.href,document.body.addEventListener("click",(()=>{requestAnimationFrame((()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,this.handleSingleFamilyUrl())}))}),!0))}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,n=await t().get(i,{headers:{"org-slug":this.orgSlug}});if(!n||!n.data)return;const r={organization:this.orgSlug,building:n.data,brandColor:this.brandColor};this.start(r,!1)}}Or.meChat=null,Or.orgSlug="",Or.mutationObserver=null,Or.previousUrl="",Or.hasBuildingSlug=null,Or.brandColor="";const Cr=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)},Ir=()=>{const e=document.createElement("meta");e.setAttribute("name","viewport"),e.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=2"),document.head.appendChild(e)},Nr=async(e,i)=>{var n;const r=await async function(e){try{return(await t().get(_i(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-override-contact-us-form",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(i);if(!r)return;const o=document.getElementById("myContactForm");let a;if(!(o&&o instanceof HTMLFormElement))return void(window.location.pathname.toLowerCase().includes("contactus")&&Rr(i,e,"Could not find form"));for(let e=0;e<o.elements.length;e++){const t=o.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){a=t;break}}if(!a)return Rr(i,e,"Could not find submit button");const s=()=>({firstName:document.getElementById("firstname"),lastName:document.getElementById("lastname"),email:document.getElementById("email"),phone:document.getElementById("phonenumber"),message:document.getElementById("message")});if(Object.values(s()).some((e=>null===e))){const t=Object.entries(s()).filter((([,e])=>null===e)).map((([e])=>e));return Rr(i,e,"Missing the following form elements: "+t.join(", "))}const l=a.textContent,u=a.cloneNode(!0);null===(n=a.parentNode)||void 0===n||n.replaceChild(u,a),u.onclick=async function(t){if(!Object.values(s()).every((t=>null!==t&&(null===t.getAttribute("aria-invalid")&&Rr(i,e,"Missing aria-invalid attribute on "+t.id),"true"!==t.getAttribute("aria-invalid")))))return;t.preventDefault(),u.textContent="Processing request...",u.disabled=!0;const n={};Object.entries(s()).forEach((([e,t])=>n[e]=null==t?void 0:t.value));const r=await gn(e,i),a=await Tn(i,document.referrer);if(!r)return Rr(i,e,"Could not find building"),null;const d={email_address:n.email,first_name:n.firstName,last_name:n.lastName,phone_number:n.phone,first_message:n.message,building_id:r.id,is_external_form:!0,lead_sources:[...new Set(a?[a,"property-website"]:["property-website"])]},c=JSON.stringify(d);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":i,"org-slug":e},body:c}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return o.reset(),Object.values(s()).forEach((e=>{e&&(e.disabled=!0)})),u.textContent="Submitted",u.disabled=!0,e.json()})).catch((()=>{u.textContent=l}))}},Rr=(e,t,i)=>{const n=JSON.stringify({orgSlug:t,buildingSlug:e,reason:i});fetch("https://app.meetelise.com/platformApi/webchat/form-override-error",{method:"POST",headers:{"Content-Type":"application/json","building-slug":e,"org-slug":t},body:n})}})();var r=n.Z;export{r as default};
2959
+ `,xr.session=null,Ar([de({type:String})],xr.prototype,"buildingSlug",void 0),Ar([de({type:String})],xr.prototype,"orgSlug",void 0),Ar([de({type:String})],xr.prototype,"themeId",void 0),Ar([de({attribute:!1})],xr.prototype,"avatarSrc",void 0),Ar([de({type:Boolean})],xr.prototype,"useMiniWidget",void 0),Ar([de({type:Object})],xr.prototype,"launcherStyles",void 0),Ar([de({type:Boolean})],xr.prototype,"isMinimized",void 0),Ar([de({type:String})],xr.prototype,"brandColor",void 0),Ar([ce()],xr.prototype,"popup",void 0),Ar([ce()],xr.prototype,"theme",void 0),Ar([ce()],xr.prototype,"chatId",void 0),Ar([ce()],xr.prototype,"analytics",void 0),Ar([ce()],xr.prototype,"isMobile",void 0),Ar([ce()],xr.prototype,"launcher",void 0),Ar([ce()],xr.prototype,"building",void 0),Ar([ce()],xr.prototype,"buildingABTestType",void 0),Ar([ce()],xr.prototype,"leadSources",void 0),Ar([ce()],xr.prototype,"currentLeadSource",void 0),Ar([ce()],xr.prototype,"featureFlagShowDropdown",void 0),Ar([ce()],xr.prototype,"phoneNumberForSource",void 0),Ar([ce()],xr.prototype,"hasMounted",void 0),Ar([ce()],xr.prototype,"hideLauncher",void 0),Ar([ce()],xr.prototype,"isLoading",void 0),Ar([ce()],xr.prototype,"talkjsPopupElement",void 0),xr=Tr=Ar([le("me-chat")],xr);class Or{static start(e,t=!0){if(window.location.pathname.includes("residentservices")||window.location.pathname.includes("onlineleasing"))return;t&&(this.orgSlug=e.organization,this.hasBuildingSlug=!!e.building),Cr(),Ir();const i=document.createElement("me-chat");i.setAttribute("orgSlug",e.organization),this.handleBuildingslug(i,e.building),i.setAttribute("class","meetelise-chat"),i.setAttribute("role","dialog"),i.setAttribute("aria-label","EliseAI Widget"),i.setAttribute("aria-describedby","aria-describe-info"),i.setAttribute("aria-modal","true"),e.themeId&&i.setAttribute("themeId",e.themeId),e.avatarSrc&&i.setAttribute("avatarSrc",e.avatarSrc),void 0!==e.mini&&(i.useMiniWidget=e.mini),e.launcherStyles&&(i.launcherStyles=e.launcherStyles),e.brandColor&&(this.brandColor=e.brandColor,i.setAttribute("brandColor",((e,t)=>{const i=(r=e,{r:parseInt(r.substring(1,3),16),g:parseInt(r.substring(3,5),16),b:parseInt(r.substring(5,7),16)}),n={r:i.r+Math.round(.3*(0-i.r)),g:i.g+Math.round(.3*(0-i.g)),b:i.b+Math.round(.3*(0-i.b))};var r;return((e,t,i)=>"#"+[e,t,i].map((e=>{const t=e.toString(16);return 1===t.length?"0"+t:t})).join(""))(n.r,n.g,n.b)})(e.brandColor))),document.body.appendChild(i),Or.meChat=i,e.building&&e.organization&&Nr(e.organization,e.building)}static async restartConversation(){this.meChat&&await this.meChat.restartConversation()}static async remove(){this.meChat&&(await this.meChat.remove(),document.body.removeChild(this.meChat),Or.meChat=null)}static async handleBuildingslug(e,t){t?e.setAttribute("buildingSlug",t):this.mutationObserver||(this.handleSingleFamilyUrl(),this.previousUrl=window.location.href,document.body.addEventListener("click",(()=>{requestAnimationFrame((()=>{this.previousUrl===window.location.href||this.hasBuildingSlug||(this.previousUrl=window.location.href,this.handleSingleFamilyUrl())}))}),!0))}static async handleSingleFamilyUrl(){if(this.hasBuildingSlug)return;this.remove();const e=window.location.href,i=`https://app.meetelise.com/platformApi/webchat/microsite_slug?uri=${encodeURIComponent(e)}`,n=await t().get(i,{headers:{"org-slug":this.orgSlug}});if(!n||!n.data)return;const r={organization:this.orgSlug,building:n.data,brandColor:this.brandColor};this.start(r,!1)}}Or.meChat=null,Or.orgSlug="",Or.mutationObserver=null,Or.previousUrl="",Or.hasBuildingSlug=null,Or.brandColor="";const Cr=()=>{const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),document.head.appendChild(e)},Ir=()=>{const e=document.createElement("meta");e.setAttribute("name","viewport"),e.setAttribute("content","width=device-width, initial-scale=1, maximum-scale=2"),document.head.appendChild(e)},Nr=async(e,i)=>{var n;const r=await async function(e){try{return(await t().get(_i(e),{params:{building_slug:e,flag_type:"bool",feature_flag:"webchat-use-override-contact-us-form",default_str:null,default_bool:!1}})).data}catch(e){return!1}}(i);if(!r)return;const o=document.getElementById("myContactForm");let a;if(!(o&&o instanceof HTMLFormElement))return void(window.location.pathname.toLowerCase().includes("contactus")&&Rr(i,e,"Could not find form"));for(let e=0;e<o.elements.length;e++){const t=o.elements[e];if("button"===t.tagName.toLowerCase()&&"fakebutton"===t.getAttribute("data-selenium-id")){a=t;break}}if(!a)return Rr(i,e,"Could not find submit button");const s=()=>({firstName:document.getElementById("firstname"),lastName:document.getElementById("lastname"),email:document.getElementById("email"),phone:document.getElementById("phonenumber"),message:document.getElementById("message")});if(Object.values(s()).some((e=>null===e))){const t=Object.entries(s()).filter((([,e])=>null===e)).map((([e])=>e));return Rr(i,e,"Missing the following form elements: "+t.join(", "))}const l=a.textContent,u=a.cloneNode(!0);null===(n=a.parentNode)||void 0===n||n.replaceChild(u,a),u.onclick=async function(t){if(Object.values(s()).forEach((e=>{"true"!==(null==e?void 0:e.getAttribute("aria-required"))||e.value||(e.className="form-control required is-invalid")})),!Object.values(s()).every((e=>null!==e&&!("true"===e.getAttribute("aria-required")&&!e.value)&&("email"!==e.id&&"phonenumber"!==e.id||"true"!==e.getAttribute("aria-invalid")))))return;t.preventDefault(),u.textContent="Processing request...",u.disabled=!0;const n={};Object.entries(s()).forEach((([e,t])=>n[e]=null==t?void 0:t.value));const r=await gn(e,i),a=await Tn(i,document.referrer);if(!r)return Rr(i,e,"Could not find building"),null;const d={email_address:n.email,first_name:n.firstName,last_name:n.lastName,phone_number:n.phone,first_message:n.message,building_id:r.id,is_external_form:!0,lead_sources:[...new Set(a?[a,"property-website"]:["property-website"])]},c=JSON.stringify(d);fetch("https://app.meetelise.com/platformApi/state/create/contactMe",{method:"POST",headers:{"Content-Type":"application/json","building-slug":i,"org-slug":e},body:c}).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}`);return o.reset(),Object.values(s()).forEach((e=>{e&&(e.disabled=!0)})),u.textContent="Submitted",u.disabled=!0,e.json()})).catch((()=>{u.textContent=l}))}},Rr=(e,t,i)=>{const n=JSON.stringify({orgSlug:t,buildingSlug:e,reason:i});fetch("https://app.meetelise.com/platformApi/webchat/form-override-error",{method:"POST",headers:{"Content-Type":"application/json","building-slug":e,"org-slug":t},body:n})}})();var r=n.Z;export{r as default};
package/src/MEChat.ts CHANGED
@@ -249,17 +249,27 @@ const overrideContactUsForm = async (
249
249
  return false;
250
250
  };
251
251
 
252
+ const validateFormElements = () => {
253
+ Object.values(getFormElements()).forEach((el) => {
254
+ if (el?.getAttribute("aria-required") === "true" && !el.value) {
255
+ el.className = "form-control required is-invalid";
256
+ }
257
+ });
258
+ };
259
+
252
260
  const isValid = () => {
253
261
  return Object.values(getFormElements()).every((el) => {
254
262
  if (el === null) return false;
255
- if (el.getAttribute("aria-invalid") === null) {
256
- logContactUsFormError(
257
- buildingSlug,
258
- orgSlug,
259
- "Missing aria-invalid attribute on " + el.id
260
- );
263
+ if (el.getAttribute("aria-required") === "true" && !el.value) {
264
+ return false;
261
265
  }
262
- return el.getAttribute("aria-invalid") !== "true";
266
+ if (
267
+ (el.id === "email" || el.id === "phonenumber") &&
268
+ el.getAttribute("aria-invalid") === "true"
269
+ ) {
270
+ return false;
271
+ }
272
+ return true;
263
273
  });
264
274
  };
265
275
 
@@ -280,6 +290,8 @@ const overrideContactUsForm = async (
280
290
  btn.parentNode?.replaceChild(clonedButton, btn);
281
291
 
282
292
  clonedButton.onclick = async function (event) {
293
+ validateFormElements();
294
+
283
295
  if (!isValid()) return;
284
296
  event.preventDefault();
285
297