@telia-ace/widget-conversation-flamingo 1.1.70-rc.16 → 1.1.70-rc.18
Sign up to get free protection for your applications and to get access to all the features.
- package/conversation.d.ts +2 -1
- package/index.js +7 -1
- package/index.mjs +8 -2
- package/package.json +2 -2
package/conversation.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { LitElement } from 'lit';
|
2
2
|
import { Ref } from 'lit-html/directives/ref.js';
|
3
3
|
import { ConversationPlatform } from './conversation-platform';
|
4
|
-
import { Observable } from 'rxjs';
|
4
|
+
import { Observable, Subject } from 'rxjs';
|
5
5
|
import { ConversationEntry } from './models/conversation-entry';
|
6
6
|
declare const WidgetElement: (new (...args: any[]) => import("@telia-ace/widget-core-flamingo").WidgetComponentType) & typeof LitElement;
|
7
7
|
export declare class Conversation extends WidgetElement {
|
@@ -29,6 +29,7 @@ export declare class Conversation extends WidgetElement {
|
|
29
29
|
private conversationState$;
|
30
30
|
private stateMachine;
|
31
31
|
private provider$;
|
32
|
+
userTyping$: Subject<string>;
|
32
33
|
connectedCallback(): Promise<void>;
|
33
34
|
disconnectedCallback(): void;
|
34
35
|
_actionHandler(_e: CustomEvent<{
|
package/index.js
CHANGED
@@ -305,6 +305,7 @@
|
|
305
305
|
@media screen and (max-width: 800px) {
|
306
306
|
:host(.floating) {
|
307
307
|
inset: 0 0 95px 0;
|
308
|
+
height: 100vh;
|
308
309
|
}
|
309
310
|
}
|
310
311
|
@media screen and (min-width: 801px) {
|
@@ -325,6 +326,10 @@
|
|
325
326
|
:host(.floating) .widget-container {
|
326
327
|
box-shadow: rgba(0, 0, 0, 0.16) 0px 5px 40px;
|
327
328
|
border-radius: 0.7rem;
|
329
|
+
|
330
|
+
@media screen and (max-width: 800px) {
|
331
|
+
border-radius: 0;
|
332
|
+
}
|
328
333
|
}
|
329
334
|
|
330
335
|
* {
|
@@ -363,6 +368,7 @@
|
|
363
368
|
:host(.hidden) {
|
364
369
|
opacity: 0;
|
365
370
|
animation: slideDown 0.3s linear;
|
371
|
+
pointer-events: none;
|
366
372
|
}
|
367
373
|
`;_a([w({attribute:!1}),xa({context:Sa})],cn.prototype,"application",2);var Ca=Object.defineProperty,Aa=Object.getOwnPropertyDescriptor,hn=(s,e,t,n)=>{for(var i=n>1?void 0:n?Aa(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&Ca(e,t,i),i};class ze extends k{constructor(){super(),this.status="deactivated",this.addEventListener("environment-created",this.onEnvironmentCreated)}async connectedCallback(){super.connectedCallback(),await this.getGlobalEnvironment()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("environment-created",this.onEnvironmentCreated)}async onEnvironmentCreated(e){this.widget=e.detail.widget,await this.activate(),this.requestUpdate()}async activate(){this.widget&&(await this.widget.activate(),this.status="activated")}async getGlobalEnvironment(){const e=globalThis.widgets;e&&(this.widget=e.applications.find(t=>t.name===this.name),await this.activate())}render(){if(!this.widget||this.status!=="activated")return g;if(this.widget.renderStrategy===ln.Trigger){const e=new re;return e.application=this.widget,e}return this.widget.render()}}ze.styles=[A`
|
368
374
|
:host {
|
@@ -767,7 +773,7 @@ Please report this to https://github.com/markedjs/marked.`,e){const i="<p>An err
|
|
767
773
|
width: 80%;
|
768
774
|
max-width: 700px;
|
769
775
|
}
|
770
|
-
`];Tl([w({attribute:!0})],xn.prototype,"imageUrl",2);var Ll=Object.defineProperty,Ol=Object.getOwnPropertyDescriptor,G=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ol(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&Ll(e,t,i),i};customElements.get("conversation-entry")||customElements.define("conversation-entry",un);customElements.get("ace-conversation-feed")||customElements.define("ace-conversation-feed",mt);customElements.get("conversation-group")||customElements.define("conversation-group",pn);customElements.get("ace-typing-state")||customElements.define("ace-typing-state",pi);customElements.get("message-type-html")||customElements.define("message-type-html",dn);customElements.get("message-type-markdown")||customElements.define("message-type-markdown",bt);customElements.get("ace-lightbox")||customElements.define("ace-lightbox",xn);const Si=ci(k);class O extends Si{constructor(){super(...arguments),this.message="",this.disabledInput=!1,this.disabledSubmit=!1,this.chatOverlayActive=!1,this.textAreaLength=0,this.conversationContentRef=B(),this.conversationFeedRef=B(),this.formRef=B(),this.inputRef=B(),this.scrollRef=B(),this.chatScrollHeight=0,this.chatCurrentScrollPosition=0,this.toast=new Ea(this),this.messageMaxLength=1e3,this.skipToLatestMessageLabel="Skip to latest message",this.platform=null,this.entries=[],this.typing=!1,this.conversationState$=new M("waiting"),this.stateMachine=new La(this.conversationState$,this),this.provider$=this.stateMachine.session().pipe(pe(e=>e?e==null?void 0:e.provider$:It(null)))}async connectedCallback(){super.connectedCallback(),this.messageMaxLength=this.properties.messageMaxLength??this.messageMaxLength,this.skipToLatestMessageLabel=this.properties.skipToLatestMessageLabel??this.skipToLatestMessageLabel;const e=await this.application.container.get("conversation");this.platform=e||null;const t=this.application.trigger;t&&t.widgetActive$.pipe(zt(t.componentIsDestroyed$)).subscribe(n=>{const i=this.conversationContentRef.value;i&&(n?i.scrollTop=this.chatCurrentScrollPosition:this.chatCurrentScrollPosition=i.scrollTop)}),this.stateSubscription=dr([this.stateMachine.entries(),this.stateMachine.isTyping()]).subscribe(([n,i])=>{this.entries=n,this.typing=i}),this.userSubmitSubscription=Ke(this,"user-submit").pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.onUserSubmit(n.detail)}),this._addHeaderOptions(),this.provider$.pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.showChatOverlay$.pipe().subscribe(r=>{this.chatOverlayActive=r})})}disconnectedCallback(){var e,t;super.disconnectedCallback(),(e=this.userSubmitSubscription)==null||e.unsubscribe(),(t=this.stateSubscription)==null||t.unsubscribe()}_actionHandler(e){}isTypingState(){var t,n;const e=(n=(t=this.conversationFeedRef.value)==null?void 0:t.shadowRoot)==null?void 0:n.querySelector(".conversation-feed");if(e){const i=e.lastElementChild;if(i&&i.tagName.toLowerCase()==="ace-typing-state")return!0}return!1}isAtBottom(){const e=this.conversationContentRef.value;return e?e.scrollHeight-e.scrollTop-e.clientHeight<1:!1}scrollToBottom(){var e,t;(!this.isTypingState()||this.isAtBottom())&&(setTimeout(()=>{var n;return(n=this.scrollRef.value)==null?void 0:n.scrollIntoView({behavior:"smooth"})},300),this.chatScrollHeight=(e=this.scrollRef.value)==null?void 0:e.scrollHeight,this.chatCurrentScrollPosition=(t=this.scrollRef.value)==null?void 0:t.scrollTop)}onSessionUpdated(){this.scrollToBottom()}disableInput(){this.disabledInput=!0}enableInput(){this.disabledInput=!1}disableSubmit(){this.disabledSubmit=!0}enableSubmit(){this.disabledSubmit=!1}clearMessages(){var i,r;const e=(i=this.shadowRoot)==null?void 0:i.querySelector("ace-conversation-feed"),t=(r=e==null?void 0:e.shadowRoot)==null?void 0:r.querySelector(".conversation-feed"),n=t==null?void 0:t.querySelectorAll(".conversation-entry");n==null||n.forEach(o=>o.remove())}setToastMessage(e){this.toast.message=e}async _onSendMessage(e){var n;if(e.preventDefault(),this.message.length<=0){(n=this.formRef.value)==null||n.classList.add("shake"),setTimeout(()=>{var i;(i=this.formRef.value)==null||i.classList.remove("shake")},500);return}this.message=this.message.slice(0,this.messageMaxLength);const t=new CustomEvent("user-submit",{detail:{text:this.message}});this.dispatchEvent(t),this.message="",this.inputRef.value.style.height=this.style.getPropertyValue("--textarea-default-height")}_addHeaderOptions(){const e=this.application.getComponent("widget-header");if(!e)return;const t=this.application.texts,n=t.getOrFallback("conversation.mute","Mute"),i=t.getOrFallback("conversation.unmute","Unmute"),r=!!this.application.storage.get("muteAudioNotifications"),o=e.addOption({label:r?i:n,icon:r?Dn.svg:Hn.svg,closeOnClick:!1,datatestid:"options-mute-button",onClick:()=>{!!this.application.storage.get("muteAudioNotifications")?(this.application.unmute(),o.updateLabel(n),o.updateIcon(Hn.svg)):(this.application.mute(),o.updateLabel(i),o.updateIcon(Dn.svg))}})}_inputHandler(e){this.message=e.target.value,e.target.style.height=this.style.getPropertyValue("--textarea-default-height"),e.target.style.height=e.target.scrollHeight+"px",this.textAreaLength=e.target.value.length}_keyDownHandler(e){e.key==="Enter"&&!e.shiftKey&&!this.disabledSubmit&&(this._onSendMessage(e),e.preventDefault())}skipToLatestMessage(){var n,i;const e=(n=this.conversationFeedRef)==null?void 0:n.value,t=(i=e==null?void 0:e.shadowRoot)==null?void 0:i.querySelectorAll(".conversation-entry");t.length&&Array.from(t).pop().focus()}handover(e,t){this.enableInput(),this.setToastMessage(null);const n=new CustomEvent("handover",{detail:{providerKey:e,providerOptions:t}});return this.dispatchEvent(n),n.detail.complete||Pe}render(){var t;const e=this.application.texts;return this.conversationState$.value==="waiting"&&((t=this.application)!=null&&t.storage)&&this.platform&&(this.stateMachine.setStorage(this.application.storage),this.conversationState$.next("init")),m` <div
|
776
|
+
`];Tl([w({attribute:!0})],xn.prototype,"imageUrl",2);var Ll=Object.defineProperty,Ol=Object.getOwnPropertyDescriptor,G=(s,e,t,n)=>{for(var i=n>1?void 0:n?Ol(e,t):e,r=s.length-1,o;r>=0;r--)(o=s[r])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&Ll(e,t,i),i};customElements.get("conversation-entry")||customElements.define("conversation-entry",un);customElements.get("ace-conversation-feed")||customElements.define("ace-conversation-feed",mt);customElements.get("conversation-group")||customElements.define("conversation-group",pn);customElements.get("ace-typing-state")||customElements.define("ace-typing-state",pi);customElements.get("message-type-html")||customElements.define("message-type-html",dn);customElements.get("message-type-markdown")||customElements.define("message-type-markdown",bt);customElements.get("ace-lightbox")||customElements.define("ace-lightbox",xn);const Si=ci(k);class O extends Si{constructor(){super(...arguments),this.message="",this.disabledInput=!1,this.disabledSubmit=!1,this.chatOverlayActive=!1,this.textAreaLength=0,this.conversationContentRef=B(),this.conversationFeedRef=B(),this.formRef=B(),this.inputRef=B(),this.scrollRef=B(),this.chatScrollHeight=0,this.chatCurrentScrollPosition=0,this.toast=new Ea(this),this.messageMaxLength=1e3,this.skipToLatestMessageLabel="Skip to latest message",this.platform=null,this.entries=[],this.typing=!1,this.conversationState$=new M("waiting"),this.stateMachine=new La(this.conversationState$,this),this.provider$=this.stateMachine.session().pipe(pe(e=>e?e==null?void 0:e.provider$:It(null))),this.userTyping$=new _}async connectedCallback(){super.connectedCallback(),this.messageMaxLength=this.properties.messageMaxLength??this.messageMaxLength,this.skipToLatestMessageLabel=this.properties.skipToLatestMessageLabel??this.skipToLatestMessageLabel;const e=await this.application.container.get("conversation");this.platform=e||null;const t=this.application.trigger;t&&t.widgetActive$.pipe(zt(t.componentIsDestroyed$)).subscribe(n=>{const i=this.conversationContentRef.value;i&&(n?i.scrollTop=this.chatCurrentScrollPosition:this.chatCurrentScrollPosition=i.scrollTop)}),this.stateSubscription=dr([this.stateMachine.entries(),this.stateMachine.isTyping()]).subscribe(([n,i])=>{this.entries=n,this.typing=i}),this.userSubmitSubscription=Ke(this,"user-submit").pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.onUserSubmit(n.detail)}),this._addHeaderOptions(),this.provider$.pipe(Ut(this.provider$)).subscribe(([n,i])=>{i&&i.showChatOverlay$.pipe().subscribe(r=>{this.chatOverlayActive=r})})}disconnectedCallback(){var e,t;super.disconnectedCallback(),(e=this.userSubmitSubscription)==null||e.unsubscribe(),(t=this.stateSubscription)==null||t.unsubscribe()}_actionHandler(e){}isTypingState(){var t,n;const e=(n=(t=this.conversationFeedRef.value)==null?void 0:t.shadowRoot)==null?void 0:n.querySelector(".conversation-feed");if(e){const i=e.lastElementChild;if(i&&i.tagName.toLowerCase()==="ace-typing-state")return!0}return!1}isAtBottom(){const e=this.conversationContentRef.value;return e?e.scrollHeight-e.scrollTop-e.clientHeight<1:!1}scrollToBottom(){var e,t;(!this.isTypingState()||this.isAtBottom())&&(setTimeout(()=>{var n;return(n=this.scrollRef.value)==null?void 0:n.scrollIntoView({behavior:"smooth"})},300),this.chatScrollHeight=(e=this.scrollRef.value)==null?void 0:e.scrollHeight,this.chatCurrentScrollPosition=(t=this.scrollRef.value)==null?void 0:t.scrollTop)}onSessionUpdated(){this.scrollToBottom()}disableInput(){this.disabledInput=!0}enableInput(){this.disabledInput=!1}disableSubmit(){this.disabledSubmit=!0}enableSubmit(){this.disabledSubmit=!1}clearMessages(){var i,r;const e=(i=this.shadowRoot)==null?void 0:i.querySelector("ace-conversation-feed"),t=(r=e==null?void 0:e.shadowRoot)==null?void 0:r.querySelector(".conversation-feed"),n=t==null?void 0:t.querySelectorAll(".conversation-entry");n==null||n.forEach(o=>o.remove())}setToastMessage(e){this.toast.message=e}async _onSendMessage(e){var n;if(e.preventDefault(),this.message.length<=0){(n=this.formRef.value)==null||n.classList.add("shake"),setTimeout(()=>{var i;(i=this.formRef.value)==null||i.classList.remove("shake")},500);return}this.message=this.message.slice(0,this.messageMaxLength);const t=new CustomEvent("user-submit",{detail:{text:this.message}});this.dispatchEvent(t),this.message="",this.inputRef.value.style.height=this.style.getPropertyValue("--textarea-default-height")}_addHeaderOptions(){const e=this.application.getComponent("widget-header");if(!e)return;const t=this.application.texts,n=t.getOrFallback("conversation.mute","Mute"),i=t.getOrFallback("conversation.unmute","Unmute"),r=!!this.application.storage.get("muteAudioNotifications"),o=e.addOption({label:r?i:n,icon:r?Dn.svg:Hn.svg,closeOnClick:!1,datatestid:"options-mute-button",onClick:()=>{!!this.application.storage.get("muteAudioNotifications")?(this.application.unmute(),o.updateLabel(n),o.updateIcon(Hn.svg)):(this.application.mute(),o.updateLabel(i),o.updateIcon(Dn.svg))}})}_inputHandler(e){this.message=e.target.value,e.target.style.height=this.style.getPropertyValue("--textarea-default-height"),e.target.style.height=e.target.scrollHeight+"px",this.textAreaLength=e.target.value.length}_keyDownHandler(e){this.userTyping$.next(e.key),e.key==="Enter"&&!e.shiftKey&&!this.disabledSubmit&&(this._onSendMessage(e),e.preventDefault())}skipToLatestMessage(){var n,i;const e=(n=this.conversationFeedRef)==null?void 0:n.value,t=(i=e==null?void 0:e.shadowRoot)==null?void 0:i.querySelectorAll(".conversation-entry");t.length&&Array.from(t).pop().focus()}handover(e,t){this.enableInput(),this.setToastMessage(null);const n=new CustomEvent("handover",{detail:{providerKey:e,providerOptions:t}});return this.dispatchEvent(n),n.detail.complete||Pe}render(){var t;const e=this.application.texts;return this.conversationState$.value==="waiting"&&((t=this.application)!=null&&t.storage)&&this.platform&&(this.stateMachine.setStorage(this.application.storage),this.conversationState$.next("init")),m` <div
|
771
777
|
@action=${this._actionHandler}
|
772
778
|
class=${Te({conversation:!0,disabled:this.disabledInput,"conversation--has-toast":this.toast.hasMessage(),"conversation--input-has-text":this.message.length>0&&!this.disabledSubmit,"overlay-mode":this.chatOverlayActive})}
|
773
779
|
>
|
package/index.mjs
CHANGED
@@ -3641,6 +3641,7 @@ ln.styles = A`
|
|
3641
3641
|
@media screen and (max-width: 800px) {
|
3642
3642
|
:host(.floating) {
|
3643
3643
|
inset: 0 0 95px 0;
|
3644
|
+
height: 100vh;
|
3644
3645
|
}
|
3645
3646
|
}
|
3646
3647
|
@media screen and (min-width: 801px) {
|
@@ -3661,6 +3662,10 @@ ln.styles = A`
|
|
3661
3662
|
:host(.floating) .widget-container {
|
3662
3663
|
box-shadow: rgba(0, 0, 0, 0.16) 0px 5px 40px;
|
3663
3664
|
border-radius: 0.7rem;
|
3665
|
+
|
3666
|
+
@media screen and (max-width: 800px) {
|
3667
|
+
border-radius: 0;
|
3668
|
+
}
|
3664
3669
|
}
|
3665
3670
|
|
3666
3671
|
* {
|
@@ -3699,6 +3704,7 @@ ln.styles = A`
|
|
3699
3704
|
:host(.hidden) {
|
3700
3705
|
opacity: 0;
|
3701
3706
|
animation: slideDown 0.3s linear;
|
3707
|
+
pointer-events: none;
|
3702
3708
|
}
|
3703
3709
|
`;
|
3704
3710
|
wa([
|
@@ -6105,7 +6111,7 @@ class R extends ki {
|
|
6105
6111
|
constructor() {
|
6106
6112
|
super(...arguments), this.message = "", this.disabledInput = !1, this.disabledSubmit = !1, this.chatOverlayActive = !1, this.textAreaLength = 0, this.conversationContentRef = B(), this.conversationFeedRef = B(), this.formRef = B(), this.inputRef = B(), this.scrollRef = B(), this.chatScrollHeight = 0, this.chatCurrentScrollPosition = 0, this.toast = new Ca(this), this.messageMaxLength = 1e3, this.skipToLatestMessageLabel = "Skip to latest message", this.platform = null, this.entries = [], this.typing = !1, this.conversationState$ = new M("waiting"), this.stateMachine = new Ea(this.conversationState$, this), this.provider$ = this.stateMachine.session().pipe(
|
6107
6113
|
pe((e) => e ? e == null ? void 0 : e.provider$ : It(null))
|
6108
|
-
);
|
6114
|
+
), this.userTyping$ = new _();
|
6109
6115
|
}
|
6110
6116
|
async connectedCallback() {
|
6111
6117
|
super.connectedCallback(), this.messageMaxLength = this.properties.messageMaxLength ?? this.messageMaxLength, this.skipToLatestMessageLabel = this.properties.skipToLatestMessageLabel ?? this.skipToLatestMessageLabel;
|
@@ -6226,7 +6232,7 @@ class R extends ki {
|
|
6226
6232
|
), e.target.style.height = e.target.scrollHeight + "px", this.textAreaLength = e.target.value.length;
|
6227
6233
|
}
|
6228
6234
|
_keyDownHandler(e) {
|
6229
|
-
e.key === "Enter" && !e.shiftKey && !this.disabledSubmit && (this._onSendMessage(e), e.preventDefault());
|
6235
|
+
this.userTyping$.next(e.key), e.key === "Enter" && !e.shiftKey && !this.disabledSubmit && (this._onSendMessage(e), e.preventDefault());
|
6230
6236
|
}
|
6231
6237
|
skipToLatestMessage() {
|
6232
6238
|
var n, i;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@telia-ace/widget-conversation-flamingo",
|
3
|
-
"version": "1.1.70-rc.
|
3
|
+
"version": "1.1.70-rc.18",
|
4
4
|
"publishConfig": {
|
5
5
|
"registry": "https://registry.npmjs.org"
|
6
6
|
},
|
@@ -9,7 +9,7 @@
|
|
9
9
|
"@lit-labs/motion": "^1.0.4",
|
10
10
|
"@teliads/icons": "^8.4.0",
|
11
11
|
"@teliads/components": "^22.1.1",
|
12
|
-
"@telia-ace/widget-core-flamingo": "1.1.70-rc.
|
12
|
+
"@telia-ace/widget-core-flamingo": "1.1.70-rc.18",
|
13
13
|
"lit-html": "^3.0.2",
|
14
14
|
"rxjs": "^7.8.1",
|
15
15
|
"marked": "^12.0.2"
|