@telia-ace/widget-conversation 1.0.34-experimental.2 → 1.0.34-experimental.20
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/dist/components/conversation/conversation-wrapper.d.ts +8 -0
- package/dist/components/conversation/conversation.d.ts +25 -6
- package/dist/components/conversation/plugin.d.ts +2 -3
- package/dist/components/conversation/ui/conversation-content.d.ts +8 -0
- package/dist/components/conversation/ui/conversation-input.d.ts +12 -0
- package/dist/components/conversation/ui/conversation-message.d.ts +16 -0
- package/dist/components/conversation/ui/message.d.ts +13 -5
- package/dist/conversation-controller.d.ts +2 -2
- package/dist/conversation-wrapper.bfcf4c5c.js +475 -0
- package/dist/conversation-wrapper.bfcf4c5c.js.map +1 -0
- package/dist/index.js +276 -312
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +14 -10
- package/dist/conversation.bc31361a.js +0 -1189
- package/dist/conversation.bc31361a.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NodeConnector } from '@telia-ace/widget-ui';
|
|
2
|
+
import Conversation from './conversation';
|
|
3
|
+
declare const ConversationWrapper_base: import("@telia-ace/widget-ui").WidgetComponentConstructor<import("@telia-ace/widget-ui/dist/mixins/widget-component").WidgetComponentInterface> & typeof Conversation;
|
|
4
|
+
export default class ConversationWrapper extends ConversationWrapper_base {
|
|
5
|
+
connector: NodeConnector;
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const Conversation_base: (new (...args: any[]) => import("@telia-ace/widget-ui/dist/mixins/requester").RequesterInterface) & typeof LitElement;
|
|
3
|
+
export default class Conversation extends Conversation_base {
|
|
4
|
+
static styles: import("lit").CSSResult;
|
|
5
|
+
_messages: any[];
|
|
6
|
+
_inputPlaceholder: string;
|
|
7
|
+
_userLabel: string;
|
|
8
|
+
_conversationControllerId: string;
|
|
9
|
+
constructor();
|
|
10
|
+
onUserSubmit(event: CustomEvent<{
|
|
11
|
+
text: string;
|
|
12
|
+
}>): void;
|
|
13
|
+
onUserTyping(event: CustomEvent<{
|
|
14
|
+
length: number;
|
|
15
|
+
}>): void;
|
|
16
|
+
onActionClick(event: CustomEvent<{
|
|
17
|
+
action: any;
|
|
18
|
+
}>): void;
|
|
19
|
+
dispatch(type: string, data: any): Promise<void>;
|
|
20
|
+
getDescriptor(): {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
} | null;
|
|
23
|
+
render(): import("lit").TemplateResult<1>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -3,11 +3,11 @@ import { ConversationMessage, ConversationMessageType } from '../../conversation
|
|
|
3
3
|
import { ConversationMessageContent, ConversationMessageSender } from '../../types';
|
|
4
4
|
export type BundledConversationMessage = {
|
|
5
5
|
timestamp: number;
|
|
6
|
-
content: [
|
|
6
|
+
content: BundledMessageContent[];
|
|
7
7
|
sender: ConversationMessageSender;
|
|
8
8
|
type: ConversationMessageType;
|
|
9
9
|
};
|
|
10
|
-
type BundledMessageContent = {
|
|
10
|
+
export type BundledMessageContent = {
|
|
11
11
|
key: string;
|
|
12
12
|
} & ConversationMessageContent;
|
|
13
13
|
export type ConversationContent = {
|
|
@@ -42,4 +42,3 @@ export type ConversationComponentProperties = {
|
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
export declare const ConversationComponent: (container: Container) => Promise<void>;
|
|
45
|
-
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { Ref } from 'lit/directives/ref.js';
|
|
3
|
+
export declare class ConversationInput extends LitElement {
|
|
4
|
+
inputRef: Ref<HTMLInputElement>;
|
|
5
|
+
hasContent: boolean;
|
|
6
|
+
placeholder: string;
|
|
7
|
+
constructor();
|
|
8
|
+
onSubmit(e: any): void;
|
|
9
|
+
onChange(e: any): void;
|
|
10
|
+
render(): import("lit").TemplateResult<1>;
|
|
11
|
+
protected createRenderRoot(): Element | ShadowRoot;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement, nothing } from 'lit';
|
|
2
|
+
import { ConversationMessageType } from '../../../conversation-controller';
|
|
3
|
+
import { BundledConversationMessage } from '../plugin';
|
|
4
|
+
export declare class ConversationMessage extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
sender: BundledConversationMessage['sender'] | null;
|
|
7
|
+
content: BundledConversationMessage['content'];
|
|
8
|
+
timestamp: number;
|
|
9
|
+
messageType: ConversationMessageType;
|
|
10
|
+
userLabel: string;
|
|
11
|
+
constructor();
|
|
12
|
+
getMessageStackPosition(index: number): "first" | "last" | "middle";
|
|
13
|
+
renderTimestamp(name: string, timestamp: number): import("lit").TemplateResult<1> | typeof nothing;
|
|
14
|
+
render(): import("lit").TemplateResult<1> | typeof nothing;
|
|
15
|
+
protected createRenderRoot(): Element | ShadowRoot;
|
|
16
|
+
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { ItemPayload } from '../../../types';
|
|
3
|
+
import { BundledMessageContent } from '../plugin';
|
|
4
|
+
export declare class Message extends LitElement {
|
|
5
|
+
content: BundledMessageContent;
|
|
6
|
+
isUser: boolean;
|
|
7
|
+
stacked: 'first' | 'last' | 'middle';
|
|
8
|
+
constructor();
|
|
9
|
+
onActionClick(action: any): void;
|
|
10
|
+
renderItem(item: ItemPayload): import("lit").TemplateResult<2 | 1>;
|
|
11
|
+
render(): import("lit").TemplateResult<2 | 1>;
|
|
12
|
+
protected createRenderRoot(): Element | ShadowRoot;
|
|
13
|
+
}
|
|
@@ -42,8 +42,8 @@ export type ConversationMessage = {
|
|
|
42
42
|
};
|
|
43
43
|
export type EntryWriter = (content: ConversationMessageUpdateSettings | null) => void;
|
|
44
44
|
export declare const getNormalizedMessageSettings: (settings: string | ConversationMessageSettings | ConverstationMessageItem<any> | ConverstationMessageItem<any>[], options?: {
|
|
45
|
-
key?: string
|
|
46
|
-
}
|
|
45
|
+
key?: string;
|
|
46
|
+
}) => NormalizedMessageSettings;
|
|
47
47
|
/**
|
|
48
48
|
* Manages the stream of messages inside a `ConversationComponent` and provides external read-write
|
|
49
49
|
* access to it as well as exposing emitted actions.
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
var z = (a, e, s) => new Promise((r, t) => {
|
|
2
|
+
var n = (m) => {
|
|
3
|
+
try {
|
|
4
|
+
p(s.next(m));
|
|
5
|
+
} catch (x) {
|
|
6
|
+
t(x);
|
|
7
|
+
}
|
|
8
|
+
}, o = (m) => {
|
|
9
|
+
try {
|
|
10
|
+
p(s.throw(m));
|
|
11
|
+
} catch (x) {
|
|
12
|
+
t(x);
|
|
13
|
+
}
|
|
14
|
+
}, p = (m) => m.done ? r(m.value) : Promise.resolve(m.value).then(n, o);
|
|
15
|
+
p((s = s.apply(a, e)).next());
|
|
16
|
+
});
|
|
17
|
+
import { Requester as R, WidgetComponentMixin as T, NodeConnector as L } from "@telia-ace/widget-ui";
|
|
18
|
+
import { ComponentPlatform as j, ComponentQuery as D } from "@telia-ace/widget-core";
|
|
19
|
+
import { LitElement as v, html as c, nothing as u, css as M, unsafeCSS as A } from "lit";
|
|
20
|
+
import { property as i, state as E } from "lit/decorators.js";
|
|
21
|
+
import { classMap as f } from "lit/directives/class-map.js";
|
|
22
|
+
import { createRef as U, ref as I } from "lit/directives/ref.js";
|
|
23
|
+
import { ConversationMessageType as y, ConversationMessageListItemType as g } from "./index.js";
|
|
24
|
+
import { spread as q } from "@open-wc/lit-helpers";
|
|
25
|
+
import { html as l, unsafeStatic as B } from "lit/static-html.js";
|
|
26
|
+
import "@telia-ace/widget-services";
|
|
27
|
+
import "@telia-ace/widget-utilities";
|
|
28
|
+
import "@telia-ace/widget-forms";
|
|
29
|
+
import "@telia-ace/widget-plugins";
|
|
30
|
+
import "react";
|
|
31
|
+
const K = `:host{--send-button-color: #a6a6a6}.wrapper{background-color:var(--conversation-bg-color);position:absolute;inset:0;overflow:hidden;display:flex;flex-direction:column;overflow-y:auto}.scrollable{display:flex;flex-direction:column;align-items:stretch;padding:0 var(--size-medium)}.scrollable:focus-visible{outline:var(--accessibility-border);color:var(--accessibility-colors-inactiveText);border-color:transparent}.message-container{display:flex}.message-container-left{justify-content:start}.message-container-center{justify-content:center}.message-container-right{justify-content:end}.conversation-entry{margin:0;margin-bottom:var(--size-medium)}.conversation-entry:first-of-type{margin-top:var(--size-medium)}.conversation-entry:last-of-type{padding-bottom:var(--size-medium)}.conversation-entry span,.conversation-entry p,.conversation-entry a,.conversation-entry div{font-weight:300}.conversation-entry b,.conversation-entry h1{font-weight:400}.conversation-entry .agent-message{display:grid;margin-right:10%;width:90%;grid-template-columns:1fr;grid-template-rows:1fr auto;grid-template-areas:"content" "info"}.conversation-entry .agent-message.has-avatar{grid-template-columns:auto 1fr;grid-template-rows:1fr auto;grid-template-areas:"avatar content" ". info"}.conversation-entry .user-message{margin-left:10%;width:90%;display:flex;flex-direction:column;align-items:flex-end}.conversation-entry .content-bundle{grid-area:content;max-width:100%;overflow:hidden}.conversation-entry .timestamp{font-size:var(--fonts-small);color:var(--colors-text);font-weight:300;margin:0;line-height:1.5em;grid-area:info}.content{display:inline-block;margin-top:var(--size-normal);max-width:100%}.content>*{overflow-wrap:break-word;word-wrap:break-word;word-break:break-all;word-break:break-word;hyphens:auto}.content.full-width{width:100%}.content.padded{padding:var(--sized-medium)}.content.user.stacked{background-color:var(--colors-primary);color:var(--colors-accent);border-top-left-radius:var(--borderRadius);border-bottom-left-radius:var(--borderRadius)}.content.user.stacked.stacked-first{border-top-right-radius:var(--borderRadius)}.content.user.stacked.stacked-last{border-bottom-right-radius:var(--borderRadius)}.content.stacked:not(.user){background-color:var(--colors-accent);color:var(--colors-text);border:var(--border, "none");border-top-right-radius:var(--borderRadius);border-bottom-right-radius:var(--borderRadius)}.content.stacked:not(.user).stacked-first{border-top-left-radius:var(--borderRadius)}.content.stacked:not(.user).stacked-last{border-bottom-left-radius:var(--borderRadius)}.message-type-text{margin:var(--size-medium) 0;padding:0 var(--size-medium)}.message-type-html{font-size:var(--fonts-normal);font-weight:300;line-height:1.5em;color:var(--colors-text);margin:var(--size-medium) 0;padding:0 var(--size-medium);color:inherit}.message-type-html h1,.message-type-html h2,.message-type-html h3,.message-type-html h4,.message-type-html h5,.message-type-html h6{word-break:break-word}.message-type-html h1:first-child,.message-type-html h2:first-child,.message-type-html h3:first-child,.message-type-html h4:first-child,.message-type-html h5:first-child,.message-type-html h6:first-child{margin-top:0}.message-type-html h1:only-child,.message-type-html h2:only-child,.message-type-html h3:only-child,.message-type-html h4:only-child,.message-type-html h5:only-child,.message-type-html h6:only-child{margin:0}.message-type-html h1:last-child,.message-type-html h2:last-child,.message-type-html h3:last-child,.message-type-html h4:last-child,.message-type-html h5:last-child,.message-type-html h6:last-child{margin-bottom:0}.message-type-html a:focus-visible{outline:var(--accessibility-border);color:var(--accessibility-colors-inactiveText);border-color:transparent;text-decoration:underline}.message-type-html img{max-width:100%!important;height:auto!important}.message-type-html p{word-break:break-word;margin:var(--size-normal) 0}.message-type-html p:first-child{margin:0 0 var(--size-normal)}.message-type-html p:last-child{margin:var(--size-normal) 0 0}.message-type-html p:only-child{margin:0}.message-type-html a{color:var(--colors-link)}.message-type-html a:focus-visible{outline:var(--accessibility-border);color:var(--accessibility-colors-inactiveText);border-color:transparent}.message-type-separator{width:100%;border-bottom:var(--border)}.message-type-button-list{margin:var(--size-medium) 0;padding:0 var(--size-medium)}.message-type-button-list ul{list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:var(--size-normal)}.message-type-button-list ul>li{margin:0}.message-type-button-list-button{text-align:center;font-weight:300;border-radius:var(--borderRadius);font-family:inherit;font-size:var(--fonts-normal);display:block;padding:var(--size-normal);background-color:var(--colors-primary);width:100%;color:#fff;overflow:hidden;text-overflow:ellipsis;cursor:pointer;font-size:inherit;border:none}.message-type-button-list-button:focus-visible{outline:var(--accessibility-border);color:var(--accessibility-colors-inactiveText);border-color:transparent;background-color:transparent}.message-type-button-list-button i,.message-type-button-list-button svg{margin-right:var(--size-small)}.message-type-link-list{margin:var(--size-medium) 0;padding:0 var(--size-medium)}.message-type-link-list h1{white-space:normal;font-size:var(--fonts-medium);font-weight:400;margin:0 0 var(--size-normal);color:var(--colors-text);line-height:1.8em}.message-type-link-list ul{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:var(--size-normal)}.message-type-link-list ul>li{margin:0}.message-type-link-list-button{display:block;text-align:left;font-weight:300;color:var(--colors-primary);max-width:100%;text-overflow:ellipsis;overflow:hidden;background-color:transparent;cursor:pointer;font-size:inherit;border:none}.message-list{list-style:none;padding:0;margin:0}.message-list .message-list-item p{padding:0;margin:0}.conversation-input{height:50px;display:flex;align-items:center;background-color:var(--colors-accent);border-top:var(--inputBorder)}.conversation-input.has-content{--send-button-color: var(--colors-primary)}.conversation-input input{flex:1;border:none;background-color:transparent;font-weight:300;font-size:var(--fonts-normal);line-height:1.2em;outline:none;padding:var(--size-medium);color:var(--colors-text)}.conversation-input input::placeholder{color:var(--colors-textLight);font-style:italic}.conversation-input button{flex:0 0 50px;align-self:stretch;background-color:transparent;display:flex;align-items:center;justify-content:center;border:none;color:var(--send-button-color)}conversation-content{flex:0 1 100%;overflow-y:auto;overflow-x:hidden;-ms-overflow-style:none;scrollbar-width:thin;scrollbar-color:transparent transparent;scrollbar-color:#7f7f7f transparent!important;scrollbar-width:thin!important;-ms-overflow-style:none!important}conversation-content::-webkit-scrollbar{width:3px!important;background-color:transparent;border-left:none}conversation-content::-webkit-scrollbar-thumb{background-color:#7f7f7f!important}conversation-content::-webkit-scrollbar-track{-webkit-box-shadow:none!important;background-color:transparent}conversation-content ::-webkit-scrollbar-thumb{background-color:#7f7f7f!important}conversation-input{flex:0 0 auto;min-height:50px;max-height:150px}
|
|
32
|
+
`;
|
|
33
|
+
var N = Object.defineProperty, W = Object.getOwnPropertyDescriptor, S = (a, e, s, r) => {
|
|
34
|
+
for (var t = r > 1 ? void 0 : r ? W(e, s) : e, n = a.length - 1, o; n >= 0; n--)
|
|
35
|
+
(o = a[n]) && (t = (r ? o(e, s, t) : o(t)) || t);
|
|
36
|
+
return r && t && N(e, s, t), t;
|
|
37
|
+
};
|
|
38
|
+
class k extends v {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(), this.userLabel = "", this.messages = [];
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
return c`
|
|
44
|
+
<div class="scrollable">
|
|
45
|
+
${this.messages.map(
|
|
46
|
+
(e) => c`<div class="conversation-entry">
|
|
47
|
+
<conversation-message
|
|
48
|
+
.content=${e.content}
|
|
49
|
+
.sender=${e.sender}
|
|
50
|
+
.messageType=${e.type}
|
|
51
|
+
.timestamp=${e.timestamp}
|
|
52
|
+
.userLabel=${this.userLabel}
|
|
53
|
+
/>
|
|
54
|
+
</div>`
|
|
55
|
+
)}
|
|
56
|
+
</div>
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
createRenderRoot() {
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
S([
|
|
64
|
+
i({ type: Array })
|
|
65
|
+
], k.prototype, "messages", 2);
|
|
66
|
+
S([
|
|
67
|
+
i({ type: String })
|
|
68
|
+
], k.prototype, "userLabel", 2);
|
|
69
|
+
var H = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, O = (a, e, s, r) => {
|
|
70
|
+
for (var t = r > 1 ? void 0 : r ? Q(e, s) : e, n = a.length - 1, o; n >= 0; n--)
|
|
71
|
+
(o = a[n]) && (t = (r ? o(e, s, t) : o(t)) || t);
|
|
72
|
+
return r && t && H(e, s, t), t;
|
|
73
|
+
};
|
|
74
|
+
class _ extends v {
|
|
75
|
+
constructor() {
|
|
76
|
+
super(), this.inputRef = U(), this.hasContent = !1;
|
|
77
|
+
}
|
|
78
|
+
onSubmit(e) {
|
|
79
|
+
e.shiftKey, e.preventDefault(), this.inputRef.value.value.length > 0 && (this.dispatchEvent(
|
|
80
|
+
new CustomEvent("user-submit", {
|
|
81
|
+
detail: {
|
|
82
|
+
text: this.inputRef.value.value
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
), this.inputRef.value.value = "");
|
|
86
|
+
}
|
|
87
|
+
onChange(e) {
|
|
88
|
+
e.target.value.length > 0 ? this.hasContent = !0 : this.hasContent = !1, e.target.value && e.target.value.length > 0 && this.dispatchEvent(
|
|
89
|
+
new CustomEvent("user-typing", {
|
|
90
|
+
detail: {
|
|
91
|
+
textLength: e.target.value.length
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
render() {
|
|
97
|
+
return c`
|
|
98
|
+
<div
|
|
99
|
+
class=${f({
|
|
100
|
+
"conversation-input": !0,
|
|
101
|
+
"has-content": this.hasContent
|
|
102
|
+
})}
|
|
103
|
+
>
|
|
104
|
+
${u}
|
|
105
|
+
${c`
|
|
106
|
+
<input
|
|
107
|
+
${I(this.inputRef)}
|
|
108
|
+
@input=${this.onChange}
|
|
109
|
+
placeholder=${this.placeholder}
|
|
110
|
+
/>
|
|
111
|
+
`}
|
|
112
|
+
|
|
113
|
+
<button @click="${this.onSubmit}">
|
|
114
|
+
<ui-symbol-badge
|
|
115
|
+
size="22"
|
|
116
|
+
.symbol=${{ type: "Svg", content: "send" }}
|
|
117
|
+
></ui-symbol-badge>
|
|
118
|
+
</button>
|
|
119
|
+
</div>
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
createRenderRoot() {
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
O([
|
|
127
|
+
E()
|
|
128
|
+
], _.prototype, "hasContent", 2);
|
|
129
|
+
O([
|
|
130
|
+
i({ type: String })
|
|
131
|
+
], _.prototype, "placeholder", 2);
|
|
132
|
+
var F = Object.defineProperty, G = Object.getOwnPropertyDescriptor, b = (a, e, s, r) => {
|
|
133
|
+
for (var t = r > 1 ? void 0 : r ? G(e, s) : e, n = a.length - 1, o; n >= 0; n--)
|
|
134
|
+
(o = a[n]) && (t = (r ? o(e, s, t) : o(t)) || t);
|
|
135
|
+
return r && t && F(e, s, t), t;
|
|
136
|
+
};
|
|
137
|
+
class d extends v {
|
|
138
|
+
constructor() {
|
|
139
|
+
super(), this.content = [], this.sender = null, this.messageType = y.System, this.userLabel = "";
|
|
140
|
+
}
|
|
141
|
+
getMessageStackPosition(e) {
|
|
142
|
+
let s = "first";
|
|
143
|
+
return this.content.length > 1 && (s = e === 0 ? "first" : e + 1 === this.content.length ? "last" : "middle"), s;
|
|
144
|
+
}
|
|
145
|
+
renderTimestamp(e, s) {
|
|
146
|
+
const r = (n) => new Date(n).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
|
|
147
|
+
if (!e && !s)
|
|
148
|
+
return u;
|
|
149
|
+
let t = "";
|
|
150
|
+
return e ? s ? t = `${e}: ${r(s)}` : t = e : s && (t = r(s)), c`<p class="timestamp">${t}</p>`;
|
|
151
|
+
}
|
|
152
|
+
render() {
|
|
153
|
+
const e = () => {
|
|
154
|
+
var t, n, o;
|
|
155
|
+
return c`
|
|
156
|
+
<div
|
|
157
|
+
class=${f({
|
|
158
|
+
"conversation-entry": !0,
|
|
159
|
+
"agent-message": !0,
|
|
160
|
+
"has-avatar": !!((t = this.sender) != null && t.avatar)
|
|
161
|
+
})}
|
|
162
|
+
>
|
|
163
|
+
${(n = this.sender) != null && n.avatar ? c`` : c``}
|
|
164
|
+
<div class="content-bundle">
|
|
165
|
+
${this.content.map((p, m) => c`
|
|
166
|
+
<div class="message-container message-container-left">
|
|
167
|
+
<conversation-message-item
|
|
168
|
+
.content=${p}
|
|
169
|
+
.isUser=${this.messageType === "user"}
|
|
170
|
+
.stacked=${this.getMessageStackPosition(m)}
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
`)}
|
|
174
|
+
</div>
|
|
175
|
+
${this.renderTimestamp(((o = this.sender) == null ? void 0 : o.name) || "", this.timestamp)}
|
|
176
|
+
</div>
|
|
177
|
+
`;
|
|
178
|
+
}, s = () => c`SystemMessage`, r = () => c`
|
|
179
|
+
<div
|
|
180
|
+
class=${f({
|
|
181
|
+
"conversation-entry": !0,
|
|
182
|
+
"user-message": !0
|
|
183
|
+
})}
|
|
184
|
+
>
|
|
185
|
+
<div class="content-bundle">
|
|
186
|
+
${this.content.map((t, n) => c`
|
|
187
|
+
<div class="message-container message-container-right">
|
|
188
|
+
<conversation-message-item
|
|
189
|
+
.content=${t}
|
|
190
|
+
.isUser=${this.messageType === "user"}
|
|
191
|
+
.stacked=${this.getMessageStackPosition(n)}
|
|
192
|
+
/>
|
|
193
|
+
</div>
|
|
194
|
+
`)}
|
|
195
|
+
</div>
|
|
196
|
+
${this.renderTimestamp(this.userLabel || "", this.timestamp)}
|
|
197
|
+
</div>
|
|
198
|
+
`;
|
|
199
|
+
switch (this.messageType) {
|
|
200
|
+
case y.System:
|
|
201
|
+
return s();
|
|
202
|
+
case y.Agent:
|
|
203
|
+
return e();
|
|
204
|
+
case y.User:
|
|
205
|
+
return r();
|
|
206
|
+
default:
|
|
207
|
+
return u;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
createRenderRoot() {
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
d.styles = [
|
|
215
|
+
M`
|
|
216
|
+
:host {
|
|
217
|
+
display: block;
|
|
218
|
+
}
|
|
219
|
+
.agent-message {
|
|
220
|
+
display: grid;
|
|
221
|
+
margin-right: 10%;
|
|
222
|
+
width: 90%;
|
|
223
|
+
grid-template-columns: 1fr;
|
|
224
|
+
grid-template-rows: 1fr auto;
|
|
225
|
+
grid-template-areas:
|
|
226
|
+
'content'
|
|
227
|
+
'info';
|
|
228
|
+
}
|
|
229
|
+
.agent-message.has-avatar {
|
|
230
|
+
grid-template-columns: auto 1fr;
|
|
231
|
+
grid-template-rows: 1fr auto;
|
|
232
|
+
grid-template-areas:
|
|
233
|
+
'avatar content'
|
|
234
|
+
'. info';
|
|
235
|
+
}
|
|
236
|
+
.content-bundle {
|
|
237
|
+
grid-area: content;
|
|
238
|
+
max-width: 100%;
|
|
239
|
+
overflow: hidden;
|
|
240
|
+
}
|
|
241
|
+
.timestamp {
|
|
242
|
+
font-size: var(--fonts-small);
|
|
243
|
+
color: var(--colors-text);
|
|
244
|
+
font-weight: 300;
|
|
245
|
+
margin: 0;
|
|
246
|
+
line-height: 1.5em;
|
|
247
|
+
grid-area: info;
|
|
248
|
+
}
|
|
249
|
+
`
|
|
250
|
+
];
|
|
251
|
+
b([
|
|
252
|
+
i({ type: Object })
|
|
253
|
+
], d.prototype, "sender", 2);
|
|
254
|
+
b([
|
|
255
|
+
i({ type: Array })
|
|
256
|
+
], d.prototype, "content", 2);
|
|
257
|
+
b([
|
|
258
|
+
i({ type: Number })
|
|
259
|
+
], d.prototype, "timestamp", 2);
|
|
260
|
+
b([
|
|
261
|
+
i({ type: String })
|
|
262
|
+
], d.prototype, "messageType", 2);
|
|
263
|
+
b([
|
|
264
|
+
i({ type: String })
|
|
265
|
+
], d.prototype, "userLabel", 2);
|
|
266
|
+
var J = Object.defineProperty, V = Object.getOwnPropertyDescriptor, C = (a, e, s, r) => {
|
|
267
|
+
for (var t = r > 1 ? void 0 : r ? V(e, s) : e, n = a.length - 1, o; n >= 0; n--)
|
|
268
|
+
(o = a[n]) && (t = (r ? o(e, s, t) : o(t)) || t);
|
|
269
|
+
return r && t && J(e, s, t), t;
|
|
270
|
+
};
|
|
271
|
+
const P = (a) => Array.isArray(a) ? a : Object.keys(a).map((e) => ({
|
|
272
|
+
label: a[e],
|
|
273
|
+
actionKey: e
|
|
274
|
+
}));
|
|
275
|
+
class w extends v {
|
|
276
|
+
constructor() {
|
|
277
|
+
super(), this.isUser = !1, this.stacked = "first";
|
|
278
|
+
}
|
|
279
|
+
onActionClick(e) {
|
|
280
|
+
this.dispatchEvent(
|
|
281
|
+
new CustomEvent("action", {
|
|
282
|
+
detail: e,
|
|
283
|
+
composed: !0,
|
|
284
|
+
bubbles: !0,
|
|
285
|
+
cancelable: !0
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
renderItem(e) {
|
|
290
|
+
const [s, r] = e;
|
|
291
|
+
switch (s) {
|
|
292
|
+
case g.Text:
|
|
293
|
+
return l`<span class="message-type-text">${r}</span>`;
|
|
294
|
+
case g.HTML:
|
|
295
|
+
return l`<div class="message-type-html">
|
|
296
|
+
<ui-html .html=${r.body}></ui-html>
|
|
297
|
+
</div>`;
|
|
298
|
+
case g.Separator:
|
|
299
|
+
return l`<div class="message-type-separator"></div>`;
|
|
300
|
+
case g.LinkList:
|
|
301
|
+
return l`
|
|
302
|
+
<div class="message-type-link-list">
|
|
303
|
+
${r.header ? l`<h1>${r.header}</h1>` : u}
|
|
304
|
+
<ul>
|
|
305
|
+
${P(r.actions).map((t) => l`<li>
|
|
306
|
+
<button
|
|
307
|
+
class="message-type-link-list-button"
|
|
308
|
+
aria-label=${t.label}
|
|
309
|
+
title=${t.label}
|
|
310
|
+
@click=${(n) => {
|
|
311
|
+
this.onActionClick(t);
|
|
312
|
+
}}
|
|
313
|
+
>
|
|
314
|
+
${t.label}
|
|
315
|
+
${t.actionKey === "help" ? l`
|
|
316
|
+
<ui-symbol-badge
|
|
317
|
+
.size=${14}
|
|
318
|
+
.symbol=${{
|
|
319
|
+
type: "Svg",
|
|
320
|
+
content: "caret-down"
|
|
321
|
+
}}
|
|
322
|
+
></ui-symbol-badge>
|
|
323
|
+
` : u}
|
|
324
|
+
</button>
|
|
325
|
+
</li>`)}
|
|
326
|
+
</ul>
|
|
327
|
+
</div>
|
|
328
|
+
`;
|
|
329
|
+
case g.ButtonList:
|
|
330
|
+
return l`
|
|
331
|
+
<div class="message-type-button-list">
|
|
332
|
+
${r.header ? l`<h1>${r.header}</h1>` : u}
|
|
333
|
+
<ul>
|
|
334
|
+
${P(r.actions).map((t) => l`<li>
|
|
335
|
+
<button
|
|
336
|
+
class="message-type-button-list-button"
|
|
337
|
+
aria-label=${t.label}
|
|
338
|
+
title=${t.label}
|
|
339
|
+
@click=${(n) => {
|
|
340
|
+
this.onActionClick(t);
|
|
341
|
+
}}
|
|
342
|
+
>
|
|
343
|
+
<!-- <ui-symbol-badge /> -->
|
|
344
|
+
${t.label}
|
|
345
|
+
</button>
|
|
346
|
+
</li>`)}
|
|
347
|
+
</ul>
|
|
348
|
+
</div>
|
|
349
|
+
`;
|
|
350
|
+
default: {
|
|
351
|
+
let t = Object.entries(r).reduce(
|
|
352
|
+
(n, [o, p]) => (n[`.${o}`] = p, n),
|
|
353
|
+
{}
|
|
354
|
+
);
|
|
355
|
+
return l`<${B(s)} ${q(t)} />`;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
render() {
|
|
360
|
+
return l`
|
|
361
|
+
<div
|
|
362
|
+
class=${f({
|
|
363
|
+
content: !0,
|
|
364
|
+
user: this.isUser,
|
|
365
|
+
stacked: !0,
|
|
366
|
+
"stacked-first": this.stacked === "first",
|
|
367
|
+
"stacked-middle": this.stacked === "middle",
|
|
368
|
+
"stacked-last": this.stacked === "last"
|
|
369
|
+
})}
|
|
370
|
+
>
|
|
371
|
+
<ul class="message-list">
|
|
372
|
+
${(this.content.items || []).map((e) => l`<li class="message-list-item">${this.renderItem(e)}</li>`)}
|
|
373
|
+
</ul>
|
|
374
|
+
</div>
|
|
375
|
+
`;
|
|
376
|
+
}
|
|
377
|
+
createRenderRoot() {
|
|
378
|
+
return this;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
C([
|
|
382
|
+
i({ type: Object })
|
|
383
|
+
], w.prototype, "content", 2);
|
|
384
|
+
C([
|
|
385
|
+
i({ type: Boolean })
|
|
386
|
+
], w.prototype, "isUser", 2);
|
|
387
|
+
C([
|
|
388
|
+
i({ type: String })
|
|
389
|
+
], w.prototype, "stacked", 2);
|
|
390
|
+
var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, $ = (a, e, s, r) => {
|
|
391
|
+
for (var t = r > 1 ? void 0 : r ? Y(e, s) : e, n = a.length - 1, o; n >= 0; n--)
|
|
392
|
+
(o = a[n]) && (t = (r ? o(e, s, t) : o(t)) || t);
|
|
393
|
+
return r && t && X(e, s, t), t;
|
|
394
|
+
};
|
|
395
|
+
customElements.define("conversation-content", k);
|
|
396
|
+
customElements.define("conversation-input", _);
|
|
397
|
+
customElements.define("conversation-message", d);
|
|
398
|
+
customElements.define("conversation-message-item", w);
|
|
399
|
+
class h extends R(v) {
|
|
400
|
+
constructor() {
|
|
401
|
+
super(), this._messages = [], this._userLabel = "", this._inputPlaceholder = "Type your message";
|
|
402
|
+
}
|
|
403
|
+
onUserSubmit(e) {
|
|
404
|
+
this.dispatch("user-submit", e.detail);
|
|
405
|
+
}
|
|
406
|
+
onUserTyping(e) {
|
|
407
|
+
this.dispatch("user-typing", e.detail);
|
|
408
|
+
}
|
|
409
|
+
onActionClick(e) {
|
|
410
|
+
this.dispatch("action", e.detail);
|
|
411
|
+
}
|
|
412
|
+
dispatch(e, s) {
|
|
413
|
+
return z(this, null, function* () {
|
|
414
|
+
const r = this.requestInstance("container"), t = this.getDescriptor();
|
|
415
|
+
if (!r || !t)
|
|
416
|
+
return;
|
|
417
|
+
const n = yield j.getInstance(r);
|
|
418
|
+
if (!n)
|
|
419
|
+
return;
|
|
420
|
+
const o = new D(n).withId(t.id);
|
|
421
|
+
n.actions(o, t.type).dispatch(e, s);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
getDescriptor() {
|
|
425
|
+
const e = new CustomEvent(
|
|
426
|
+
"request-descriptor",
|
|
427
|
+
{
|
|
428
|
+
detail: {},
|
|
429
|
+
bubbles: !0,
|
|
430
|
+
composed: !0,
|
|
431
|
+
cancelable: !0
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
return this.dispatchEvent(e), e.detail.descriptor || null;
|
|
435
|
+
}
|
|
436
|
+
render() {
|
|
437
|
+
return c`
|
|
438
|
+
<div class="wrapper">
|
|
439
|
+
<conversation-content
|
|
440
|
+
.messages=${this._messages}
|
|
441
|
+
.userLabel=${this._userLabel}
|
|
442
|
+
@action=${this.onActionClick}
|
|
443
|
+
></conversation-content>
|
|
444
|
+
<conversation-input
|
|
445
|
+
@user-submit=${this.onUserSubmit}
|
|
446
|
+
@user-typing=${this.onUserTyping}
|
|
447
|
+
.placeholder=${this._inputPlaceholder}
|
|
448
|
+
>
|
|
449
|
+
</conversation-input>
|
|
450
|
+
</div>
|
|
451
|
+
`;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
h.styles = A(K);
|
|
455
|
+
$([
|
|
456
|
+
i({ type: Array })
|
|
457
|
+
], h.prototype, "_messages", 2);
|
|
458
|
+
$([
|
|
459
|
+
i({ type: String })
|
|
460
|
+
], h.prototype, "_inputPlaceholder", 2);
|
|
461
|
+
$([
|
|
462
|
+
i({ type: String })
|
|
463
|
+
], h.prototype, "_userLabel", 2);
|
|
464
|
+
$([
|
|
465
|
+
i({ type: String })
|
|
466
|
+
], h.prototype, "_conversationControllerId", 2);
|
|
467
|
+
class he extends T(h) {
|
|
468
|
+
constructor() {
|
|
469
|
+
super(), this.connector = new L(this);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
export {
|
|
473
|
+
he as default
|
|
474
|
+
};
|
|
475
|
+
//# sourceMappingURL=conversation-wrapper.bfcf4c5c.js.map
|