@meetelise/chat 1.58.0 → 1.58.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.58.0",
3
+ "version": "1.58.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -6688,8 +6688,7 @@ xmlns="http://www.w3.org/2000/svg"
6688
6688
  justify-content: space-between;
6689
6689
  }
6690
6690
  .leasing-conversation-body-backdrop {
6691
- background: rgba(193, 193, 193, 0.5);
6692
- backdrop-filter: blur(4px);
6691
+ background: #efefef;
6693
6692
 
6694
6693
  border-top: 1px solid rgba(0, 0, 0, 0.1);
6695
6694
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
@@ -7296,11 +7295,11 @@ xmlns="http://www.w3.org/2000/svg"
7296
7295
  <path fill-rule="evenodd" clip-rule="evenodd" d="M15 0C17.7614 0 20 2.23858 20 5V15C20 17.7614 17.7614 20 15 20H5C2.23858 20 0 17.7614 0 15V5C0 2.23858 2.23858 0 5 0H15ZM18 5C18 3.34315 16.6569 2 15 2H5C3.34315 2 2 3.34315 2 5V15C2 16.6569 3.34315 18 5 18H15C16.6569 18 18 16.6569 18 15V5Z" fill="${e}"/>
7297
7296
  <path d="M12.1893 9.25L10.4697 7.53033C10.1768 7.23744 10.1768 6.76256 10.4697 6.46967C10.7626 6.17678 11.2374 6.17678 11.5303 6.46967L13.8232 8.76256C14.5066 9.44598 14.5066 10.554 13.8232 11.2374L11.5303 13.5303C11.2374 13.8232 10.7626 13.8232 10.4697 13.5303C10.1768 13.2374 10.1768 12.7626 10.4697 12.4697L12.1893 10.75L6 10.75C5.58579 10.75 5.25 10.4142 5.25 10C5.25 9.58579 5.58579 9.25 6 9.25L12.1893 9.25Z" fill="${e}"/>
7298
7297
  </svg>
7299
- `;var Tc,_c=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 Oc=Tc=class extends oe{constructor(){super(...arguments),this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.onMount=()=>({}),this.isHealthChat=!1,this.centralConvo=!1,this.widgetType=sh.Default,this.primaryColor=qn,this.backgroundColor=Yn,this.onClickExit=()=>{localStorage.setItem("isChatOpen","false")},this.requiresConsent=!1,this._isMobile=Tr(),this.shouldAutoScroll=!0,this.messages=[],this.isLoadingMessages=!1,this.hasReceivedConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.websitePreviewMapping={},this.sendMessage=async e=>{var t;0!==e.length&&(this.shouldAutoScroll=!0,this.messageInput.value="",this.autoResizeMessageInput(),0===this.messages.length&&(this.messages=[{timestamp:0,message:e,isLeadMessage:!0,chunks:[{text:e,order:0,isDone:!0}],type:Ju.text}]),await(null===(t=this.myPubnub)||void 0===t?void 0:t.sendMessage(e)))},this.scrollToChatBottom=()=>{this.shouldAutoScroll&&this.messageBody.scrollTo({top:this.messageBody.scrollHeight-this.messageBody.clientHeight,behavior:"auto"})},this.handleConversationScroll=e=>{const t=e.currentTarget,n=t.scrollHeight-t.clientHeight-t.scrollTop;this.shouldAutoScroll=n<=Tc.AUTO_SCROLL_THRESHOLD_PX},this.autoResizeMessageInput=()=>{this.messageInput.style.height="auto",this.messageInput.style.height=this.messageInput.scrollHeight+"px"},this.needsConsent=()=>this.requiresConsent&&!this.hasReceivedConsent}get consentKey(){return`${this.orgSlug}Consent`}connectedCallback(){super.connectedCallback(),this._cleanupMobileListener=_r(e=>{this._isMobile=e})}disconnectedCallback(){var e;null===(e=this._cleanupMobileListener)||void 0===e||e.call(this),super.disconnectedCallback()}firstUpdated(){var e,t;this.messages=(null===(e=this.myPubnub)||void 0===e?void 0:e.simpleChatMessages)||[],null===(t=this.myPubnub)||void 0===t||t.addChatListener(e=>{this.messages=e.messages,this.isLoadingMessages=e.isLoading}),this.onMount();const n=localStorage.getItem(this.consentKey);if(!n)return void(this.hasReceivedConsent=!1);const i=JSON.parse(n),{timestamp:r,consentId:o}=i;Sc(new Date,new Date(r))<7&&o===jo?this.hasReceivedConsent=!0:(this.hasReceivedConsent=!1,localStorage.removeItem(this.consentKey))}async updated(){this.scrollToChatBottom();try{const e=document.getElementById("#healthchat-container");if(!e)return;e.focus()}catch(e){}}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x;if(!this.buildingSlug&&!this.centralConvo)return U``;const $=null===(e=this.building)||void 0===e?void 0:e.id;let S={};if(S=this._isMobile?{top:void 0,bottom:0,left:void 0,right:0}:{top:void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:void 0===this.bottom||isNaN(this.bottom)?"130px":`${this.bottom}px`,left:void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:void 0===this.right||isNaN(this.right)?"18px":`${this.right}px`},22320===$&&(S={...S,fontFamily:'"Helvetica Neue", Arial'}),this.widgetType===sh.Utilities)return U`
7298
+ `;var Tc,_c=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 Oc=Tc=class extends oe{constructor(){super(...arguments),this.right=void 0,this.bottom=void 0,this.top=void 0,this.left=void 0,this.onMount=()=>({}),this.isHealthChat=!1,this.centralConvo=!1,this.widgetType=sh.Default,this.primaryColor=qn,this.backgroundColor=Yn,this.onClickExit=()=>{localStorage.setItem("isChatOpen","false")},this.requiresConsent=!1,this._isMobile=Tr(),this.shouldAutoScroll=!0,this.messages=[],this.isLoadingMessages=!1,this.hasReceivedConsent=!1,this.privacyPolicyUrl="http://bit.ly/me_privacy_policy",this.websitePreviewMapping={},this.sendMessage=async e=>{var t;0!==e.length&&(this.shouldAutoScroll=!0,this.messageInput.value="",this.autoResizeMessageInput(),0===this.messages.length&&(this.messages=[{timestamp:0,message:e,isLeadMessage:!0,chunks:[{text:e,order:0,isDone:!0}],type:Ju.text}]),await(null===(t=this.myPubnub)||void 0===t?void 0:t.sendMessage(e)))},this.scrollToChatBottom=()=>{this.shouldAutoScroll&&this.messageBody.scrollTo({top:this.messageBody.scrollHeight-this.messageBody.clientHeight,behavior:"auto"})},this.handleConversationScroll=e=>{const t=e.currentTarget,n=t.scrollHeight-t.clientHeight-t.scrollTop;this.shouldAutoScroll=n<=Tc.AUTO_SCROLL_THRESHOLD_PX},this.autoResizeMessageInput=()=>{this.messageInput.style.height="auto",this.messageInput.style.height=this.messageInput.scrollHeight+"px"},this.needsConsent=()=>this.requiresConsent&&!this.hasReceivedConsent}get consentKey(){return`${this.orgSlug}Consent`}connectedCallback(){super.connectedCallback(),this._cleanupMobileListener=_r(e=>{this._isMobile=e})}disconnectedCallback(){var e;null===(e=this._cleanupMobileListener)||void 0===e||e.call(this),super.disconnectedCallback()}firstUpdated(){var e,t;this.messages=(null===(e=this.myPubnub)||void 0===e?void 0:e.simpleChatMessages)||[],null===(t=this.myPubnub)||void 0===t||t.addChatListener(e=>{this.messages=e.messages,this.isLoadingMessages=e.isLoading}),this.onMount();const n=localStorage.getItem(this.consentKey);if(!n)return void(this.hasReceivedConsent=!1);const i=JSON.parse(n),{timestamp:r,consentId:o}=i;Sc(new Date,new Date(r))<7&&o===jo?this.hasReceivedConsent=!0:(this.hasReceivedConsent=!1,localStorage.removeItem(this.consentKey))}async updated(){this.scrollToChatBottom();try{const e=document.getElementById("#healthchat-container");if(!e)return;e.focus()}catch(e){}}render(){var e,t,n,i,r,o,a,s,l,u,d,c,h,p,f,g,m,b,y,v,w,C,x,$;if(!this.buildingSlug&&!this.centralConvo)return U``;const S=(null===(e=this.building)||void 0===e?void 0:e.userFirstName)||"Elise",A=null===(t=this.building)||void 0===t?void 0:t.id;let k={};if(k=this._isMobile?{top:void 0,bottom:0,left:void 0,right:0}:{top:void 0===this.top||isNaN(this.top)?void 0:`${this.top}px`,bottom:void 0===this.bottom||isNaN(this.bottom)?"130px":`${this.bottom}px`,left:void 0===this.left||isNaN(this.left)?void 0:`${this.left}px`,right:void 0===this.right||isNaN(this.right)?"18px":`${this.right}px`},22320===A&&(k={...k,fontFamily:'"Helvetica Neue", Arial'}),this.widgetType===sh.Utilities)return U`
7300
7299
  <div
7301
7300
  id="utilities-container"
7302
7301
  class=${be({"pubnub-container__mobile":this._isMobile,"utilities-container__desktop":!this._isMobile})}
7303
- style=${Vn(S)}
7302
+ style=${Vn(k)}
7304
7303
  >
7305
7304
  <div id="utilities-header">
7306
7305
  <div>
@@ -7317,7 +7316,7 @@ xmlns="http://www.w3.org/2000/svg"
7317
7316
  <div
7318
7317
  class=${be({hidden:!this.needsConsent(),"legal-confirmation-container":!0})}
7319
7318
  >
7320
- ${Fo(null!==(t=this.orgSlug)&&void 0!==t?t:null,this.privacyPolicyUrl,this.consentKey,e=>{this.hasReceivedConsent=e},null!==(i=null===(n=this.building)||void 0===n?void 0:n.country)&&void 0!==i?i:null)}
7319
+ ${Fo(null!==(n=this.orgSlug)&&void 0!==n?n:null,this.privacyPolicyUrl,this.consentKey,e=>{this.hasReceivedConsent=e},null!==(r=null===(i=this.building)||void 0===i?void 0:i.country)&&void 0!==r?r:null)}
7321
7320
  </div>
7322
7321
  <div
7323
7322
  id="conversation-body"
@@ -7331,27 +7330,25 @@ xmlns="http://www.w3.org/2000/svg"
7331
7330
  class=${be({hidden:this.needsConsent()})}
7332
7331
  >
7333
7332
  <li class="utilities-disclaimer-message">
7334
- ${Ho({orgSlug:null!==(r=this.orgSlug)&&void 0!==r?r:"",type:"utilities",buildingState:null!==(a=null===(o=this.building)||void 0===o?void 0:o.state)&&void 0!==a?a:null})}
7333
+ ${Ho({orgSlug:null!==(o=this.orgSlug)&&void 0!==o?o:"",type:"utilities",buildingState:null!==(s=null===(a=this.building)||void 0===a?void 0:a.state)&&void 0!==s?s:null})}
7335
7334
  </li>
7336
7335
  <li
7337
7336
  class="message-container ai-message"
7338
- tabindex="0"
7339
7337
  role="article"
7340
- aria-label="Elise: Hi I'm Elise. How can I assist you today?"
7338
+ aria-label="${S}: Hi I'm ${S}. How can I assist you today?"
7341
7339
  >
7342
7340
  <p
7343
7341
  class=${be({"message-text-large":!0,"webchat-font__desktop":!this._isMobile,"webchat-font__mobile":this._isMobile})}
7344
7342
  >
7345
- Hi I'm Elise. How can I assist you today?
7343
+ Hi I'm ${S}. How can I assist you today?
7346
7344
  </p>
7347
7345
  </li>
7348
7346
  ${this.messages.map(e=>U`
7349
7347
  <li
7350
7348
  class=${e.isLeadMessage?"message-container lead-message":"message-container ai-message"}
7351
7349
  key=${e.timestamp}
7352
- tabindex="0"
7353
7350
  role="article"
7354
- aria-label="${e.isLeadMessage?"You":"Elise"}: ${Pc(e)}"
7351
+ aria-label="${e.isLeadMessage?"You":S}: ${Pc(e)}"
7355
7352
  >
7356
7353
  ${Zu(e)?U`<pubnub-navigation
7357
7354
  .message=${e}
@@ -7394,6 +7391,7 @@ xmlns="http://www.w3.org/2000/svg"
7394
7391
  <div id="utilities-inner-footer">
7395
7392
  <textarea
7396
7393
  id="message-input"
7394
+ aria-label="Message"
7397
7395
  class=${be({"webchat-font__desktop":!this._isMobile,"webchat-font__mobile":this._isMobile})}
7398
7396
  placeholder="Ask a Question..."
7399
7397
  @keydown=${e=>{"Enter"===e.key&&(e.preventDefault(),this.sendMessage(this.messageInput.value))}}
@@ -7415,7 +7413,7 @@ xmlns="http://www.w3.org/2000/svg"
7415
7413
  <div
7416
7414
  id="healthchat-container"
7417
7415
  class=${be({"pubnub-container__mobile":this._isMobile,"healthchat-container__desktop":!this._isMobile})}
7418
- style=${Vn(S)}
7416
+ style=${Vn(k)}
7419
7417
  >
7420
7418
  <div id="healthchat-header">
7421
7419
  ${"6a9e65e5-9699-4c96-af75-1741d0df79aa"===this.buildingSlug?U` <div>
@@ -7436,7 +7434,7 @@ xmlns="http://www.w3.org/2000/svg"
7436
7434
  <div
7437
7435
  class=${be({hidden:!this.needsConsent(),"legal-confirmation-container":!0})}
7438
7436
  >
7439
- ${Fo(null!==(s=this.orgSlug)&&void 0!==s?s:null,this.privacyPolicyUrl,this.consentKey,e=>{this.hasReceivedConsent=e},null!==(u=null===(l=this.building)||void 0===l?void 0:l.country)&&void 0!==u?u:null)}
7437
+ ${Fo(null!==(l=this.orgSlug)&&void 0!==l?l:null,this.privacyPolicyUrl,this.consentKey,e=>{this.hasReceivedConsent=e},null!==(d=null===(u=this.building)||void 0===u?void 0:u.country)&&void 0!==d?d:null)}
7440
7438
  </div>
7441
7439
  <div
7442
7440
  id="conversation-body"
@@ -7450,28 +7448,26 @@ xmlns="http://www.w3.org/2000/svg"
7450
7448
  class=${be({hidden:this.needsConsent()})}
7451
7449
  >
7452
7450
  <li class="healthcare-disclaimer-message">
7453
- ${Ho({orgSlug:null!==(d=this.orgSlug)&&void 0!==d?d:"",type:"healthcare",buildingState:null!==(h=null===(c=this.building)||void 0===c?void 0:c.state)&&void 0!==h?h:null})}
7451
+ ${Ho({orgSlug:null!==(c=this.orgSlug)&&void 0!==c?c:"",type:"healthcare",buildingState:null!==(p=null===(h=this.building)||void 0===h?void 0:h.state)&&void 0!==p?p:null})}
7454
7452
  </li>
7455
7453
  <li
7456
7454
  class="message-container ai-message"
7457
- tabindex="0"
7458
7455
  role="article"
7459
- aria-label="Elise: Hi I'm Elise. If this is a medical emergency, please call 911. How can I assist you today?"
7456
+ aria-label="${S}: Hi I'm ${S}. If this is a medical emergency, please call 911. How can I assist you today?"
7460
7457
  >
7461
7458
  <p
7462
7459
  class=${be({"message-text":!0,"webchat-font__desktop":!this._isMobile,"webchat-font__mobile":this._isMobile})}
7463
7460
  >
7464
- Hi I'm Elise. If this is a medical emergency, please call 911.
7465
- How can I assist you today?
7461
+ Hi I'm ${S}. If this is a medical emergency,
7462
+ please call 911. How can I assist you today?
7466
7463
  </p>
7467
7464
  </li>
7468
7465
  ${this.messages.map(e=>U`
7469
7466
  <li
7470
7467
  class=${e.isLeadMessage?"message-container lead-message":"message-container ai-message"}
7471
7468
  key=${e.timestamp}
7472
- tabindex="0"
7473
7469
  role="article"
7474
- aria-label="${e.isLeadMessage?"You":"Elise"}: ${Pc(e)}"
7470
+ aria-label="${e.isLeadMessage?"You":S}: ${Pc(e)}"
7475
7471
  >
7476
7472
  ${Zu(e)?U`<pubnub-navigation
7477
7473
  .message=${e}
@@ -7514,6 +7510,7 @@ xmlns="http://www.w3.org/2000/svg"
7514
7510
  <div id="healthcare-inner-footer">
7515
7511
  <textarea
7516
7512
  id="message-input"
7513
+ aria-label="Message"
7517
7514
  class=${be({"webchat-font__desktop":!this._isMobile,"webchat-font__mobile":this._isMobile})}
7518
7515
  placeholder="Ask a Question..."
7519
7516
  @keydown=${e=>{"Enter"===e.key&&(e.preventDefault(),this.sendMessage(this.messageInput.value))}}
@@ -7531,11 +7528,11 @@ xmlns="http://www.w3.org/2000/svg"
7531
7528
  </div>
7532
7529
  </div>
7533
7530
  </div>
7534
- `;if(!this.building)return U``;const A=this.building.orgId;return U`
7531
+ `;if(!this.building)return U``;const E=this.building.orgId;return U`
7535
7532
  <div
7536
7533
  id="pubnub-chat-container"
7537
7534
  class=${be({"pubnub-container__mobile":this._isMobile,"pubnub-container__desktop":!this._isMobile})}
7538
- style=${Vn(S)}
7535
+ style=${Vn(k)}
7539
7536
  @keydown=${e=>e.stopPropagation()}
7540
7537
  @keyup=${e=>e.stopPropagation()}
7541
7538
  >
@@ -7555,7 +7552,7 @@ xmlns="http://www.w3.org/2000/svg"
7555
7552
  <div
7556
7553
  class=${be({hidden:!this.needsConsent(),"legal-confirmation-container":!0})}
7557
7554
  >
7558
- ${Fo(null!==(p=this.orgSlug)&&void 0!==p?p:null,this.privacyPolicyUrl,this.consentKey,e=>{this.hasReceivedConsent=e},null!==(g=null===(f=this.building)||void 0===f?void 0:f.country)&&void 0!==g?g:null)}
7555
+ ${Fo(null!==(f=this.orgSlug)&&void 0!==f?f:null,this.privacyPolicyUrl,this.consentKey,e=>{this.hasReceivedConsent=e},null!==(m=null===(g=this.building)||void 0===g?void 0:g.country)&&void 0!==m?m:null)}
7559
7556
  </div>
7560
7557
  <div
7561
7558
  id="conversation-body"
@@ -7569,12 +7566,11 @@ xmlns="http://www.w3.org/2000/svg"
7569
7566
  aria-live="polite"
7570
7567
  class=${be({hidden:this.needsConsent()})}
7571
7568
  >
7572
- ${Ho({orgSlug:null!==(m=this.orgSlug)&&void 0!==m?m:"",buildingState:null!==(y=null===(b=this.building)||void 0===b?void 0:b.state)&&void 0!==y?y:null,buildingCountry:null!==(w=null===(v=this.building)||void 0===v?void 0:v.country)&&void 0!==w?w:null,type:"leasing",customAdditionalDisclaimer:null===(C=this.building)||void 0===C?void 0:C.customAdditionalDisclaimer})}
7569
+ ${Ho({orgSlug:null!==(b=this.orgSlug)&&void 0!==b?b:"",buildingState:null!==(v=null===(y=this.building)||void 0===y?void 0:y.state)&&void 0!==v?v:null,buildingCountry:null!==(C=null===(w=this.building)||void 0===w?void 0:w.country)&&void 0!==C?C:null,type:"leasing",customAdditionalDisclaimer:null===(x=this.building)||void 0===x?void 0:x.customAdditionalDisclaimer})}
7573
7570
  ${this.building.welcomeMessage?U` <li
7574
- class=${be({"message-container":!0,"ai-message":!0,"with-box-shadow":444===A})}
7575
- tabindex="0"
7571
+ class=${be({"message-container":!0,"ai-message":!0,"with-box-shadow":444===E})}
7576
7572
  role="article"
7577
- aria-label="Elise: ${this.building.welcomeMessage}"
7573
+ aria-label="${S}: ${this.building.welcomeMessage}"
7578
7574
  >
7579
7575
  <p
7580
7576
  class=${be({"message-text":!0,"webchat-font__desktop":!this._isMobile,"webchat-font__mobile":this._isMobile})}
@@ -7584,11 +7580,10 @@ xmlns="http://www.w3.org/2000/svg"
7584
7580
  </li>`:""}
7585
7581
  ${this.messages.map(e=>U`
7586
7582
  <li
7587
- class=${ho()("message-container",{"lead-message":e.isLeadMessage,"ai-message":!e.isLeadMessage,"with-box-shadow":444===A})}
7583
+ class=${ho()("message-container",{"lead-message":e.isLeadMessage,"ai-message":!e.isLeadMessage,"with-box-shadow":444===E})}
7588
7584
  key=${e.timestamp}
7589
- tabindex="0"
7590
7585
  role="article"
7591
- aria-label="${e.isLeadMessage?"You":"Elise"}: ${Pc(e)}"
7586
+ aria-label="${e.isLeadMessage?"You":S}: ${Pc(e)}"
7592
7587
  >
7593
7588
  ${Zu(e)?U`<pubnub-navigation
7594
7589
  .message=${e}
@@ -7627,6 +7622,7 @@ xmlns="http://www.w3.org/2000/svg"
7627
7622
  >
7628
7623
  <textarea
7629
7624
  id="message-input"
7625
+ aria-label="Message"
7630
7626
  class=${be({"webchat-font__desktop":!this._isMobile,"webchat-font__mobile":this._isMobile})}
7631
7627
  style=${Vn({color:Jn(this.building.orgId,this.building.id)&&this.primaryColor!==qn?"black":void 0})}
7632
7628
  placeholder="Ask a question..."
@@ -7639,9 +7635,8 @@ xmlns="http://www.w3.org/2000/svg"
7639
7635
  tabindex="0"
7640
7636
  id="send-message-bttn"
7641
7637
  @click=${()=>this.sendMessage(this.messageInput.value)}
7642
- ?disabled=${null===(x=this.myPubnub)||void 0===x?void 0:x.isCurrentlyStreamingMessage}
7638
+ ?disabled=${null===($=this.myPubnub)||void 0===$?void 0:$.isCurrentlyStreamingMessage}
7643
7639
  aria-label="Send message"
7644
- aria-describedby="Send message"
7645
7640
  >
7646
7641
  ${Jn(this.building.orgId,this.building.id)&&this.primaryColor!==qn?Ec("black"):Ec("white")}
7647
7642
  </button>
@@ -47,8 +47,7 @@ export const leasingChatStyles = css`
47
47
  justify-content: space-between;
48
48
  }
49
49
  .leasing-conversation-body-backdrop {
50
- background: rgba(193, 193, 193, 0.5);
51
- backdrop-filter: blur(4px);
50
+ background: #efefef;
52
51
 
53
52
  border-top: 1px solid rgba(0, 0, 0, 0.1);
54
53
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
@@ -253,6 +253,8 @@ export class PubnubChat extends LitElement {
253
253
  return html``; // error should be here
254
254
  }
255
255
 
256
+ const assistantName = this.building?.userFirstName || "Elise";
257
+
256
258
  const buildingId = this.building?.id;
257
259
  let styles = {};
258
260
  if (this._isMobile) {
@@ -357,9 +359,8 @@ export class PubnubChat extends LitElement {
357
359
  </li>
358
360
  <li
359
361
  class="message-container ai-message"
360
- tabindex="0"
361
362
  role="article"
362
- aria-label="Elise: Hi I'm Elise. How can I assist you today?"
363
+ aria-label="${assistantName}: Hi I'm ${assistantName}. How can I assist you today?"
363
364
  >
364
365
  <p
365
366
  class=${classMap({
@@ -368,7 +369,7 @@ export class PubnubChat extends LitElement {
368
369
  ["webchat-font__mobile"]: this._isMobile,
369
370
  })}
370
371
  >
371
- Hi I'm Elise. How can I assist you today?
372
+ Hi I'm ${assistantName}. How can I assist you today?
372
373
  </p>
373
374
  </li>
374
375
  ${this.messages.map((message) => {
@@ -378,11 +379,10 @@ export class PubnubChat extends LitElement {
378
379
  ? "message-container lead-message"
379
380
  : "message-container ai-message"}
380
381
  key=${message.timestamp}
381
- tabindex="0"
382
382
  role="article"
383
383
  aria-label="${message.isLeadMessage
384
384
  ? "You"
385
- : "Elise"}: ${messageAriaLabel(message)}"
385
+ : assistantName}: ${messageAriaLabel(message)}"
386
386
  >
387
387
  ${isSimpleNavigationChatMessage(message)
388
388
  ? html`<pubnub-navigation
@@ -436,6 +436,7 @@ export class PubnubChat extends LitElement {
436
436
  <div id="utilities-inner-footer">
437
437
  <textarea
438
438
  id="message-input"
439
+ aria-label="Message"
439
440
  class=${classMap({
440
441
  ["webchat-font__desktop"]: !this._isMobile,
441
442
  ["webchat-font__mobile"]: this._isMobile,
@@ -535,9 +536,8 @@ export class PubnubChat extends LitElement {
535
536
  </li>
536
537
  <li
537
538
  class="message-container ai-message"
538
- tabindex="0"
539
539
  role="article"
540
- aria-label="Elise: Hi I'm Elise. If this is a medical emergency, please call 911. How can I assist you today?"
540
+ aria-label="${assistantName}: Hi I'm ${assistantName}. If this is a medical emergency, please call 911. How can I assist you today?"
541
541
  >
542
542
  <p
543
543
  class=${classMap({
@@ -546,8 +546,8 @@ export class PubnubChat extends LitElement {
546
546
  ["webchat-font__mobile"]: this._isMobile,
547
547
  })}
548
548
  >
549
- Hi I'm Elise. If this is a medical emergency, please call 911.
550
- How can I assist you today?
549
+ Hi I'm ${assistantName}. If this is a medical emergency,
550
+ please call 911. How can I assist you today?
551
551
  </p>
552
552
  </li>
553
553
  ${this.messages.map((message) => {
@@ -557,11 +557,10 @@ export class PubnubChat extends LitElement {
557
557
  ? "message-container lead-message"
558
558
  : "message-container ai-message"}
559
559
  key=${message.timestamp}
560
- tabindex="0"
561
560
  role="article"
562
561
  aria-label="${message.isLeadMessage
563
562
  ? "You"
564
- : "Elise"}: ${messageAriaLabel(message)}"
563
+ : assistantName}: ${messageAriaLabel(message)}"
565
564
  >
566
565
  ${isSimpleNavigationChatMessage(message)
567
566
  ? html`<pubnub-navigation
@@ -615,6 +614,7 @@ export class PubnubChat extends LitElement {
615
614
  <div id="healthcare-inner-footer">
616
615
  <textarea
617
616
  id="message-input"
617
+ aria-label="Message"
618
618
  class=${classMap({
619
619
  ["webchat-font__desktop"]: !this._isMobile,
620
620
  ["webchat-font__mobile"]: this._isMobile,
@@ -734,9 +734,8 @@ export class PubnubChat extends LitElement {
734
734
  "ai-message": true,
735
735
  "with-box-shadow": orgId === 444,
736
736
  })}
737
- tabindex="0"
738
737
  role="article"
739
- aria-label="Elise: ${this.building.welcomeMessage}"
738
+ aria-label="${assistantName}: ${this.building.welcomeMessage}"
740
739
  >
741
740
  <p
742
741
  class=${classMap({
@@ -760,11 +759,10 @@ export class PubnubChat extends LitElement {
760
759
  "with-box-shadow": orgId === 444,
761
760
  })}
762
761
  key=${message.timestamp}
763
- tabindex="0"
764
762
  role="article"
765
763
  aria-label="${message.isLeadMessage
766
764
  ? "You"
767
- : "Elise"}: ${messageAriaLabel(message)}"
765
+ : assistantName}: ${messageAriaLabel(message)}"
768
766
  >
769
767
  ${isSimpleNavigationChatMessage(message)
770
768
  ? html`<pubnub-navigation
@@ -822,6 +820,7 @@ export class PubnubChat extends LitElement {
822
820
  >
823
821
  <textarea
824
822
  id="message-input"
823
+ aria-label="Message"
825
824
  class=${classMap({
826
825
  ["webchat-font__desktop"]: !this._isMobile,
827
826
  ["webchat-font__mobile"]: this._isMobile,
@@ -855,7 +854,6 @@ export class PubnubChat extends LitElement {
855
854
  @click=${() => this.sendMessage(this.messageInput.value)}
856
855
  ?disabled=${this.myPubnub?.isCurrentlyStreamingMessage}
857
856
  aria-label="Send message"
858
- aria-describedby="Send message"
859
857
  >
860
858
  ${shouldUsePrimaryColorForChatFooter(
861
859
  this.building.orgId,
@@ -0,0 +1,152 @@
1
+ import { expect } from "@esm-bundle/chai";
2
+ import "../public/dist/index";
3
+ import { BuildingWebchatView } from "./fetchBuildingWebchatView";
4
+ import type { SimpleChatMessage } from "./MyPubnub";
5
+ import type { PubnubChat } from "./WebComponent/pubnub-chat";
6
+
7
+ type WidgetTypeName = "default" | "healthcare" | "utilities";
8
+
9
+ declare const afterEach: (callback: () => void) => void;
10
+ declare const it: (name: string, callback: () => void | Promise<void>) => void;
11
+
12
+ const text = (visible: string): string => visible.replace(/\s+/g, " ").trim();
13
+
14
+ const conversation = (): SimpleChatMessage[] => [
15
+ {
16
+ timestamp: 1,
17
+ message: "Do you have a two bedroom?",
18
+ isLeadMessage: true,
19
+ chunks: [{ text: "Do you have a two bedroom?", order: 0, isDone: true }],
20
+ type: "text",
21
+ },
22
+ {
23
+ timestamp: 2,
24
+ message: "Yes, I can help with that.",
25
+ isLeadMessage: false,
26
+ chunks: [{ text: "Yes, I can help with that.", order: 0, isDone: true }],
27
+ type: "text",
28
+ },
29
+ {
30
+ timestamp: 3,
31
+ media: [{ title: null, description: null, url: null }],
32
+ isLeadMessage: false,
33
+ type: "media",
34
+ },
35
+ {
36
+ timestamp: 4,
37
+ navigation: {
38
+ url: "https://example.com/floor-plans",
39
+ label: "the floor plans",
40
+ },
41
+ isLeadMessage: false,
42
+ type: "navigation",
43
+ },
44
+ ];
45
+
46
+ const mount = async (
47
+ widgetType: WidgetTypeName,
48
+ assistantName: string | null
49
+ ): Promise<PubnubChat> => {
50
+ const chat = document.createElement("pubnub-chat") as PubnubChat;
51
+ chat.buildingSlug = "alta-federal-hill";
52
+ chat.orgSlug = "greystar";
53
+ chat.widgetType = widgetType;
54
+ if (assistantName !== null) {
55
+ chat.building = {
56
+ id: 1,
57
+ orgId: 1,
58
+ name: "Alta Federal Hill",
59
+ userFirstName: assistantName,
60
+ welcomeMessage: `Hi, I'm ${assistantName}. How can I help you today?`,
61
+ state: "MD",
62
+ country: "US",
63
+ customAdditionalDisclaimer: null,
64
+ } as BuildingWebchatView;
65
+ }
66
+ document.body.appendChild(chat);
67
+ await chat.updateComplete;
68
+ // firstUpdated clears messages until PubNub has history.
69
+ chat.messages = conversation();
70
+ await chat.updateComplete;
71
+ return chat;
72
+ };
73
+
74
+ const labels = (chat: PubnubChat): string[] =>
75
+ Array.from(
76
+ chat.shadowRoot?.querySelectorAll<HTMLElement>('[role="article"]') ?? []
77
+ ).map((article) => article.getAttribute("aria-label") ?? "");
78
+
79
+ afterEach(() => {
80
+ document.querySelectorAll("pubnub-chat").forEach((chat) => chat.remove());
81
+ });
82
+
83
+ it("announces leasing messages as the configured assistant", async () => {
84
+ const chat = await mount("default", "Emily");
85
+ const articles = Array.from(
86
+ chat.shadowRoot?.querySelectorAll<HTMLElement>('[role="article"]') ?? []
87
+ );
88
+
89
+ expect(text(articles[0].innerText)).to.equal(
90
+ "Hi, I'm Emily. How can I help you today?"
91
+ );
92
+ expect(labels(chat)).to.deep.equal([
93
+ "Emily: Hi, I'm Emily. How can I help you today?",
94
+ "You: Do you have a two bedroom?",
95
+ "Emily: Yes, I can help with that.",
96
+ "Emily: Media message",
97
+ "Emily: Take me to the floor plans",
98
+ ]);
99
+ });
100
+
101
+ it("announces healthcare messages as the configured assistant", async () => {
102
+ const chat = await mount("healthcare", "Ezra");
103
+ const greeting = chat.shadowRoot?.querySelector<HTMLElement>(
104
+ "#message-thread-list > li.message-container"
105
+ );
106
+
107
+ expect(text(greeting?.innerText ?? "")).to.equal(
108
+ "Hi I'm Ezra. If this is a medical emergency, please call 911. How can I assist you today?"
109
+ );
110
+ expect(labels(chat)[0]).to.equal(
111
+ "Ezra: Hi I'm Ezra. If this is a medical emergency, please call 911. How can I assist you today?"
112
+ );
113
+ expect(labels(chat).slice(1)).to.deep.equal([
114
+ "You: Do you have a two bedroom?",
115
+ "Ezra: Yes, I can help with that.",
116
+ "Ezra: Media message",
117
+ "Ezra: Take me to the floor plans",
118
+ ]);
119
+ });
120
+
121
+ it("announces utilities messages as the configured assistant", async () => {
122
+ const chat = await mount("utilities", "Emily");
123
+ const greeting = chat.shadowRoot?.querySelector<HTMLElement>(
124
+ "#message-thread-list > li.message-container"
125
+ );
126
+
127
+ expect(text(greeting?.innerText ?? "")).to.equal(
128
+ "Hi I'm Emily. How can I assist you today?"
129
+ );
130
+ expect(labels(chat)).to.deep.equal([
131
+ "Emily: Hi I'm Emily. How can I assist you today?",
132
+ "You: Do you have a two bedroom?",
133
+ "Emily: Yes, I can help with that.",
134
+ "Emily: Media message",
135
+ "Emily: Take me to the floor plans",
136
+ ]);
137
+ });
138
+
139
+ it("keeps Elise when a chat has no configured assistant name", async () => {
140
+ const chat = await mount("utilities", null);
141
+ const greeting = chat.shadowRoot?.querySelector<HTMLElement>(
142
+ "#message-thread-list > li.message-container"
143
+ );
144
+
145
+ expect(text(greeting?.innerText ?? "")).to.equal(
146
+ "Hi I'm Elise. How can I assist you today?"
147
+ );
148
+ expect(labels(chat)[0]).to.equal(
149
+ "Elise: Hi I'm Elise. How can I assist you today?"
150
+ );
151
+ expect(labels(chat)[2]).to.equal("Elise: Yes, I can help with that.");
152
+ });