@telia-ace/widget-conversation 1.1.2-rc.5 → 1.1.2-rc.7
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.
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("@emotion/styled"),n=require("@telia-ace/widget-ui"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("@emotion/styled"),n=require("@telia-ace/widget-ui"),L=require("@telia-ace/widget-utilities"),f=require("@emotion/react"),y=require("react"),Q=require("@telia-ace/widget-forms"),$=require("./index.js");require("@telia-ace/widget-core");require("@telia-ace/widget-services");require("@telia-ace/widget-plugins");const Z=({className:t})=>{const[e,r]=y.useState(""),[o,a]=y.useState(0),[l,d]=y.useState(0),u=n.useIsTabbing(),h=n.useDispatch(),b=n.useContainer(),{inputPlaceholder:p="Type your message",inputHidden:c=!1,inputDisabled:g=!1,sendButtonLabel:S="Send message",inputMultiline:k=!0,secondaryAction:x,skipToLatestMessageLabel:T="Skip to latest message"}=n.useProperties(),[z,v]=n.useScroll(!0);y.useEffect(()=>{if(v.current){const{lineHeight:m,maxHeight:w}=getComputedStyle(v.current);if(m&&m.indexOf("px")>-1){const j=m.split("px"),K=parseInt(j[0],10);a(K);const J=w.split("px");d(parseInt(J[0],10))}}},[v.current]);const I=m=>{!m.shiftKey||!k?(m.preventDefault(),e&&e.length>0&&(h("user-submit",{text:e}),r(""),B(""))):e.length<1&&m.preventDefault()},Y=m=>{x&&(m.preventDefault(),h("action",{actionKey:x.action,...x}))},X=m=>{if(k&&v.current){const w=v.current.scrollHeight;if(w>o){v.current.style.height="auto";let j=w;m.length<1&&(j=o),v.current.style.height=`${j}px`,j>=l?v.current.style.overflowY="scroll":v.current.style.overflowY="hidden"}}},B=m=>{X(m),r(m),m&&m.length>0&&h("user-typing",{textLength:m.length})},G=m=>{m.preventDefault();const w=b.get("widgetDOMElement");if(w){const j=w.querySelectorAll(".humany-conversation-entry");j.length&&j[j.length-1].focus()}};return c?null:s.jsxs(re,{grow:k,className:L.appendClassNames("humany-conversation-input",t),scrollableCss:z,isTabbing:u,children:[x&&s.jsx(ne,{disabled:g,onClick:Y,title:x.label,"aria-label":x.label,children:s.jsx(n.SymbolBadge,{size:24,symbol:{type:"Svg",content:x.icon||"browse"}})}),k?s.jsx(te,{value:e,onChange:B,onEnter:I,disabled:g,"aria-label":p,placeholder:p,type:"textarea",rows:1,ref:v}):s.jsx(se,{value:e,onChange:B,onEnter:I,disabled:g,"aria-label":p,placeholder:p}),s.jsx(W,{disabled:!1,onClick:I,title:S,"aria-label":S,children:s.jsx(oe,{size:22,symbol:{type:"Svg",content:"send"},hasContent:!!e&&!!e.length})}),s.jsx(ee,{onKeyDown:m=>{(m.key==="Enter"||m.keyCode===13)&&G(m)},children:s.jsx("a",{href:"",className:"humany-skip-to-latest-message",children:T})})]})},ee=i.div`
|
|
2
|
+
position: absolute;
|
|
3
|
+
bottom: 80px;
|
|
4
|
+
width: 100%;
|
|
5
|
+
text-align: center;
|
|
6
|
+
a {
|
|
7
|
+
position: absolute;
|
|
8
|
+
left: -10000000px;
|
|
9
|
+
}
|
|
10
|
+
a:focus {
|
|
11
|
+
left: 50%;
|
|
12
|
+
transform: translateX(-50%);
|
|
13
|
+
${n.borderTabStyle};
|
|
14
|
+
outline-offset: 12px;
|
|
15
|
+
}
|
|
16
|
+
`,te=i(n.Input)`
|
|
2
17
|
resize: none;
|
|
3
18
|
flex: 1;
|
|
4
19
|
flex-shrink: 1;
|
|
@@ -16,7 +31,7 @@
|
|
|
16
31
|
${n.borderTabStyle};
|
|
17
32
|
outline-offset: 12px;
|
|
18
33
|
}
|
|
19
|
-
`,
|
|
34
|
+
`,se=i(n.Input)`
|
|
20
35
|
flex: 1;
|
|
21
36
|
border: none;
|
|
22
37
|
background-color: transparent;
|
|
@@ -30,7 +45,7 @@
|
|
|
30
45
|
color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.textLight}};
|
|
31
46
|
font-style: italic;
|
|
32
47
|
}
|
|
33
|
-
`,
|
|
48
|
+
`,W=i(n.Button)`
|
|
34
49
|
flex: 0 0 50px;
|
|
35
50
|
align-self: stretch;
|
|
36
51
|
background-color: transparent;
|
|
@@ -42,14 +57,14 @@
|
|
|
42
57
|
&:focus-visible {
|
|
43
58
|
${n.borderTabStyle};
|
|
44
59
|
}
|
|
45
|
-
`,
|
|
60
|
+
`,ne=i(W)`
|
|
46
61
|
border-right: ${t=>t.theme.border};
|
|
47
62
|
margin: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}} 0;
|
|
48
|
-
`,
|
|
49
|
-
${t=>t.grow?
|
|
63
|
+
`,re=i.div`
|
|
64
|
+
${t=>t.grow?f.css`
|
|
50
65
|
min-height: 50px;
|
|
51
66
|
max-height: 150px;
|
|
52
|
-
`:
|
|
67
|
+
`:f.css`
|
|
53
68
|
height: 50px;
|
|
54
69
|
`}
|
|
55
70
|
flex: 0 0 auto;
|
|
@@ -61,13 +76,13 @@
|
|
|
61
76
|
textarea {
|
|
62
77
|
${t=>!!t.scrollableCss&&t.scrollableCss}
|
|
63
78
|
}
|
|
64
|
-
`,
|
|
79
|
+
`,oe=i(({hasContent:t,...e})=>s.jsx(n.SymbolBadge,{...e}))`
|
|
65
80
|
line,
|
|
66
81
|
path {
|
|
67
82
|
stroke: ${t=>{var e;return t.hasContent?(e=t.theme.colors)==null?void 0:e.primary:"#a6a6a6"}};
|
|
68
83
|
fill: ${t=>{var e;return t.hasContent?(e=t.theme.colors)==null?void 0:e.primary:"#a6a6a6"}};
|
|
69
84
|
}
|
|
70
|
-
`,
|
|
85
|
+
`,ae=i.div`
|
|
71
86
|
width: ${t=>t.avatarSize||"32px"};
|
|
72
87
|
height: ${t=>t.avatarSize||"32px"};
|
|
73
88
|
border-radius: 50%;
|
|
@@ -102,7 +117,7 @@
|
|
|
102
117
|
stroke: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
|
|
103
118
|
}
|
|
104
119
|
}
|
|
105
|
-
`,
|
|
120
|
+
`,ie=f.keyframes`
|
|
106
121
|
0% {
|
|
107
122
|
opacity: 0;
|
|
108
123
|
}
|
|
@@ -112,7 +127,7 @@
|
|
|
112
127
|
100% {
|
|
113
128
|
opacity: 0;
|
|
114
129
|
}
|
|
115
|
-
`,
|
|
130
|
+
`,le=i.div`
|
|
116
131
|
display: flex;
|
|
117
132
|
justify-content: center;
|
|
118
133
|
> div {
|
|
@@ -121,7 +136,7 @@
|
|
|
121
136
|
border-radius: 50%;
|
|
122
137
|
margin: 5px;
|
|
123
138
|
background-color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
|
|
124
|
-
animation: ${
|
|
139
|
+
animation: ${ie} 1s infinite;
|
|
125
140
|
}
|
|
126
141
|
> div:nth-of-type(2) {
|
|
127
142
|
animation-delay: 100ms;
|
|
@@ -129,23 +144,23 @@
|
|
|
129
144
|
> div:nth-of-type(3) {
|
|
130
145
|
animation-delay: 200ms;
|
|
131
146
|
}
|
|
132
|
-
`,
|
|
147
|
+
`,O=i.div`
|
|
133
148
|
grid-area: content;
|
|
134
149
|
max-width: 100%;
|
|
135
150
|
overflow: hidden;
|
|
136
|
-
`,
|
|
151
|
+
`,ce=i(n.Typography)`
|
|
137
152
|
font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
|
|
138
153
|
font-weight: normal;
|
|
139
154
|
margin: 0;
|
|
140
|
-
`,
|
|
155
|
+
`,R=i.div`
|
|
141
156
|
display: flex;
|
|
142
157
|
${t=>t.left&&"justify-content: start;"};
|
|
143
158
|
${t=>t.center&&"justify-content: center;"};
|
|
144
159
|
${t=>t.right&&"justify-content: end;"};
|
|
145
|
-
`,
|
|
160
|
+
`,E=i.div`
|
|
146
161
|
${t=>{var e;return t.padded&&`padding: ${(e=t.theme.sizes)==null?void 0:e.medium};`}}
|
|
147
|
-
${t=>!t.user&&t.stacked&&
|
|
148
|
-
${t=>t.user&&t.stacked&&
|
|
162
|
+
${t=>!t.user&&t.stacked&&de(t.stacked,t.theme)}
|
|
163
|
+
${t=>t.user&&t.stacked&&me(t.stacked,t.theme)}
|
|
149
164
|
|
|
150
165
|
display: inline-block;
|
|
151
166
|
margin-top: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
|
|
@@ -158,11 +173,11 @@
|
|
|
158
173
|
}
|
|
159
174
|
max-width: 100%;
|
|
160
175
|
${t=>t.fullWidth&&"width: 100%;"}
|
|
161
|
-
`,
|
|
176
|
+
`,de=(t,e)=>{var o,a;const r=f.css`
|
|
162
177
|
background-color: ${(o=e.colors)==null?void 0:o.accent};
|
|
163
178
|
color: ${(a=e.colors)==null?void 0:a.text};
|
|
164
179
|
${e.border&&`border: ${e.border};`};
|
|
165
|
-
`;return e.borderRadius?
|
|
180
|
+
`;return e.borderRadius?f.css`
|
|
166
181
|
${r}
|
|
167
182
|
|
|
168
183
|
border-top-right-radius: ${e.borderRadius};
|
|
@@ -175,10 +190,10 @@
|
|
|
175
190
|
${t==="last"&&`
|
|
176
191
|
border-bottom-left-radius: ${e.borderRadius};
|
|
177
192
|
`}
|
|
178
|
-
`:r},
|
|
193
|
+
`:r},me=(t,e)=>{var o,a;const r=f.css`
|
|
179
194
|
background-color: ${(o=e.colors)==null?void 0:o.primary};
|
|
180
195
|
color: ${(a=e.colors)==null?void 0:a.accent};
|
|
181
|
-
`;return e.borderRadius?
|
|
196
|
+
`;return e.borderRadius?f.css`
|
|
182
197
|
${r}
|
|
183
198
|
|
|
184
199
|
border-top-left-radius: ${e.borderRadius};
|
|
@@ -191,15 +206,15 @@
|
|
|
191
206
|
${t==="last"&&`
|
|
192
207
|
border-bottom-right-radius: ${e.borderRadius};
|
|
193
208
|
`}
|
|
194
|
-
`:r},
|
|
209
|
+
`:r},N=i.div`
|
|
195
210
|
margin-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
|
|
196
211
|
&:last-child {
|
|
197
212
|
margin-bottom: 0;
|
|
198
213
|
}
|
|
199
|
-
`,
|
|
214
|
+
`,C=t=>{var e,r;return f.css`
|
|
200
215
|
margin: ${(e=t.theme.sizes)==null?void 0:e.medium} 0;
|
|
201
216
|
padding: 0 ${(r=t.theme.sizes)==null?void 0:r.medium};
|
|
202
|
-
`},
|
|
217
|
+
`},ue=i(Q.FormComponent)`
|
|
203
218
|
& button.humany-form-component-button {
|
|
204
219
|
${t=>{var e,r,o,a;return((e=t.theme.colors)==null?void 0:e.primary)&&((r=t.theme.colors)==null?void 0:r.accent)&&n.invertedHoverButton({active:!1,primaryColor:(o=t.theme.colors)==null?void 0:o.primary,secondaryColor:(a=t.theme.colors)==null?void 0:a.accent,theme:t.theme})}};
|
|
205
220
|
display: block;
|
|
@@ -213,7 +228,7 @@
|
|
|
213
228
|
margin-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
|
|
214
229
|
}
|
|
215
230
|
}
|
|
216
|
-
`,
|
|
231
|
+
`,he=i(n.Html)`
|
|
217
232
|
white-space: pre-wrap;
|
|
218
233
|
a {
|
|
219
234
|
color: ${t=>t.theme.colors.link};
|
|
@@ -221,14 +236,14 @@
|
|
|
221
236
|
${t=>{var e;return((e=t.theme.accessibility)==null?void 0:e.isTabbing)&&n.borderTabStyle}};
|
|
222
237
|
}
|
|
223
238
|
}
|
|
224
|
-
`,
|
|
239
|
+
`,ge=i(n.List)`
|
|
225
240
|
padding: 0;
|
|
226
241
|
list-style: none;
|
|
227
242
|
margin: 0 -${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
|
|
228
243
|
> li {
|
|
229
244
|
margin: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
|
|
230
245
|
}
|
|
231
|
-
`,
|
|
246
|
+
`,ye=i.button`
|
|
232
247
|
${t=>n.buttonCss(t)};
|
|
233
248
|
display: block;
|
|
234
249
|
background-color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.primary}};
|
|
@@ -238,7 +253,7 @@
|
|
|
238
253
|
${n.borderTabStyle}
|
|
239
254
|
background-color: transparent;
|
|
240
255
|
}
|
|
241
|
-
`,
|
|
256
|
+
`,q=y.forwardRef(({boxed:t,className:e,agentData:r},o)=>s.jsx(O,{ref:o,children:s.jsx(R,{left:t,center:!t,children:s.jsx(E,{padded:!!t,stacked:t?"first":void 0,children:s.jsxs(le,{children:[s.jsx("div",{}),s.jsx("div",{}),s.jsx("div",{})]})})})})),U=y.createContext(null),fe=i.p`
|
|
242
257
|
&& {
|
|
243
258
|
font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.small}};
|
|
244
259
|
font-weight: 300;
|
|
@@ -247,28 +262,28 @@
|
|
|
247
262
|
line-height: 1.5em;
|
|
248
263
|
grid-area: info;
|
|
249
264
|
color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
|
|
250
|
-
`,
|
|
265
|
+
`,P=(t,e)=>new Date(t).toLocaleTimeString(e||[],{hour:"numeric",minute:"2-digit"}),M=({className:t,name:e,timestamp:r})=>{const o=y.useContext(U);if(!e&&!r)return null;let a="";return e?r?a=`${e}: ${P(r,o)}`:a=e:r&&(a=P(r,o)),s.jsx(fe,{children:a})},V=({className:t,children:e,sender:r,timestamp:o})=>{const{avatar:a,name:l}=r,{avatarSize:d}=n.useProperties();return s.jsxs(be,{hasAvatar:!!a,className:L.appendClassNames(t,"humany-conversation-agent-message"),children:[a&&s.jsx(ae,{avatarSize:d,children:typeof a=="string"?s.jsx("img",{src:a}):s.jsx(n.SymbolBadge,{symbol:a})}),e,s.jsx(M,{name:l,timestamp:o})]})},be=i.div`
|
|
251
266
|
display: grid;
|
|
252
267
|
margin-right: 10%;
|
|
253
268
|
width: 90%;
|
|
254
|
-
${t=>t.hasAvatar?
|
|
269
|
+
${t=>t.hasAvatar?f.css`
|
|
255
270
|
grid-template-columns: auto 1fr;
|
|
256
271
|
grid-template-rows: 1fr auto;
|
|
257
272
|
grid-template-areas:
|
|
258
273
|
'avatar content'
|
|
259
274
|
'. info';
|
|
260
|
-
`:
|
|
275
|
+
`:f.css`
|
|
261
276
|
grid-template-columns: 1fr;
|
|
262
277
|
grid-template-rows: 1fr auto;
|
|
263
278
|
grid-template-areas:
|
|
264
279
|
'content'
|
|
265
280
|
'info';
|
|
266
281
|
`};
|
|
267
|
-
`,
|
|
282
|
+
`,pe=y.forwardRef(({className:t,children:e,timestamp:r,discrete:o,fullWidth:a},l)=>s.jsx(xe,{ref:l,className:L.appendClassNames(t,"humany-conversation-system-message"),fullWidth:a,children:o?s.jsxs(ve,{className:"humany-conversation-discrete-message",children:[e,s.jsx(M,{timestamp:r})]}):s.jsxs(s.Fragment,{children:[e,s.jsx(M,{timestamp:r})]})})),xe=i.div`
|
|
268
283
|
${t=>t.fullWidth&&"width: 100%"};
|
|
269
284
|
padding: 0 ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.large}};
|
|
270
285
|
overflow: auto;
|
|
271
|
-
`,
|
|
286
|
+
`,ve=i.div`
|
|
272
287
|
text-align: center;
|
|
273
288
|
word-wrap: break-word;
|
|
274
289
|
font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.normal}};
|
|
@@ -276,13 +291,13 @@
|
|
|
276
291
|
> p {
|
|
277
292
|
margin: 0;
|
|
278
293
|
}
|
|
279
|
-
|
|
294
|
+
`,$e=({className:t,children:e,timestamp:r})=>{const{userLabel:o=""}=n.useProperties();return s.jsxs(je,{className:L.appendClassNames(t,"humany-conversation-user-message"),children:[e,s.jsx(M,{name:o,timestamp:r})]})},je=i.div`
|
|
280
295
|
margin-left: 10%;
|
|
281
296
|
width: 90%;
|
|
282
297
|
display: flex;
|
|
283
298
|
flex-direction: column;
|
|
284
299
|
align-items: flex-end;
|
|
285
|
-
`,
|
|
300
|
+
`,D=t=>Array.isArray(t)?t:Object.keys(t).map(e=>({label:t[e],actionKey:e})),Se=({header:t,actions:e,dispatch:r})=>s.jsx(we,{className:"humany-conversation-button-list",header:t,items:D(e),renderItem:o=>{var l;const a=!!((l=o==null?void 0:o.data)!=null&&l.href);return s.jsx("li",{children:a?s.jsxs(Ce,{onClick:()=>{r("action",o)},href:o.data.href,target:o.data.target,"aria-label":o.label,title:o.label,children:[s.jsx(n.SymbolBadge,{symbol:o.symbol}),o.label]}):s.jsxs(ke,{onClick:()=>{r("action",o)},"aria-label":o.label,title:o.label,children:[s.jsx(n.SymbolBadge,{symbol:o.symbol}),o.label]})},o.actionKey)}}),we=i(n.ItemList)`
|
|
286
301
|
${n.itemList}
|
|
287
302
|
> ul {
|
|
288
303
|
display: flex;
|
|
@@ -292,8 +307,8 @@
|
|
|
292
307
|
margin: 0;
|
|
293
308
|
}
|
|
294
309
|
}
|
|
295
|
-
${
|
|
296
|
-
|
|
310
|
+
${C}
|
|
311
|
+
`,Ce=i(n.Link)`
|
|
297
312
|
${n.buttonCss};
|
|
298
313
|
|
|
299
314
|
display: block;
|
|
@@ -312,7 +327,7 @@
|
|
|
312
327
|
svg {
|
|
313
328
|
margin-right: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.small}};
|
|
314
329
|
}
|
|
315
|
-
`,
|
|
330
|
+
`,ke=i(n.Button)`
|
|
316
331
|
${n.buttonCss};
|
|
317
332
|
|
|
318
333
|
display: block;
|
|
@@ -331,22 +346,22 @@
|
|
|
331
346
|
svg {
|
|
332
347
|
margin-right: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.small}};
|
|
333
348
|
}
|
|
334
|
-
`,
|
|
349
|
+
`,Le=({type:t,content:e={}})=>{const r=n.useComponent(t);return!r||!t?null:s.jsx(y.Suspense,{fallback:null,children:s.jsx(r,{...e})})},Te=({body:t})=>s.jsx(ze,{html:t}),ze=i(n.Html)`
|
|
335
350
|
${n.genericHtml}
|
|
336
351
|
color: inherit;
|
|
337
352
|
white-space: pre-wrap;
|
|
338
|
-
${
|
|
353
|
+
${C}
|
|
339
354
|
a {
|
|
340
355
|
color: ${t=>t.theme.colors.link};
|
|
341
356
|
&:focus-visible {
|
|
342
357
|
${n.borderTabStyle};
|
|
343
358
|
}
|
|
344
359
|
}
|
|
345
|
-
`,
|
|
360
|
+
`,Ne=({header:t,actions:e,dispatch:r})=>s.jsx(Me,{className:"humany-conversation-item-list",header:t,items:D(e),renderItem:o=>{var a;return s.jsx("li",{children:s.jsxs(Ie,{children:[((a=o.symbol)==null?void 0:a.content)&&s.jsx("div",{className:"item-icon",children:s.jsx(n.SymbolBadge,{size:22,symbol:{type:o.symbol.type,content:o.symbol.content}})}),s.jsxs("div",{className:"item-body",children:[s.jsx(n.Button,{onClick:()=>{r("action",o)},"aria-label":o.label,title:o.label,children:o.label}),o.description&&s.jsx("p",{children:o.description})]})]})},o.actionKey)}}),Me=i(n.ItemList)`
|
|
346
361
|
${n.itemList}
|
|
347
362
|
|
|
348
363
|
> .humany-paragraph {
|
|
349
|
-
${
|
|
364
|
+
${C}
|
|
350
365
|
margin-bottom: 0;
|
|
351
366
|
|
|
352
367
|
h1 {
|
|
@@ -354,7 +369,7 @@
|
|
|
354
369
|
}
|
|
355
370
|
}
|
|
356
371
|
|
|
357
|
-
${t=>n.headingElement(t)("h1",
|
|
372
|
+
${t=>n.headingElement(t)("h1",f.css`
|
|
358
373
|
white-space: normal;
|
|
359
374
|
`)}
|
|
360
375
|
|
|
@@ -374,10 +389,10 @@
|
|
|
374
389
|
border-bottom: none;
|
|
375
390
|
}
|
|
376
391
|
}
|
|
377
|
-
`,
|
|
392
|
+
`,Ie=i.div`
|
|
378
393
|
display: flex;
|
|
379
394
|
gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
|
|
380
|
-
${
|
|
395
|
+
${C}
|
|
381
396
|
|
|
382
397
|
.item-icon {
|
|
383
398
|
}
|
|
@@ -411,11 +426,11 @@
|
|
|
411
426
|
}
|
|
412
427
|
}
|
|
413
428
|
}
|
|
414
|
-
`,
|
|
429
|
+
`,Be=({header:t,actions:e,dispatch:r})=>{const o=n.usePrevious(e),a=y.useRef(),l=n.useIsTabbing();return y.useEffect(()=>{if(o&&Array.isArray(e)&&Array.isArray(o)&&o.length<e.length&&a.current){const d=a.current.querySelectorAll(".humany-conversation-link-list > ul > li"),u=d[o.length];if(d.length===e.length&&o.length){const h=d[o.length-1];if(h){const b=h.querySelector(".humany-button");b&&b.focus()}}else u&&new MutationObserver((b,p)=>{b.forEach(c=>{if(c.addedNodes){const g=Array.from(c.addedNodes).find(S=>S.tagName==="BUTTON");g&&L.htmlParentContains(a.current,document.activeElement)&&(l&&g.focus(),p.disconnect())}})}).observe(u,{attributes:!1,characterData:!1,childList:!0,subtree:!0,attributeOldValue:!1,characterDataOldValue:!1})}}),s.jsx(Ae,{ref:a,className:"humany-conversation-link-list",header:t,items:D(e),renderItem:d=>s.jsx("li",{children:s.jsxs(He,{help:d.actionKey==="help",onClick:()=>{r("action",d)},"aria-label":d.label,title:d.label,children:[d.label,d.actionKey==="help"&&s.jsx(n.SymbolBadge,{size:14,symbol:{type:"Svg",content:"caret-down"}})]})},d.actionKey)})},Ae=i(n.ItemList)`
|
|
415
430
|
${n.itemList}
|
|
416
|
-
${
|
|
431
|
+
${C}
|
|
417
432
|
|
|
418
|
-
${t=>n.headingElement(t)("h1",
|
|
433
|
+
${t=>n.headingElement(t)("h1",f.css`
|
|
419
434
|
white-space: normal;
|
|
420
435
|
`)}
|
|
421
436
|
|
|
@@ -427,7 +442,7 @@
|
|
|
427
442
|
margin: 0;
|
|
428
443
|
}
|
|
429
444
|
}
|
|
430
|
-
`,
|
|
445
|
+
`,He=i(n.Button)`
|
|
431
446
|
display: block;
|
|
432
447
|
text-align: left;
|
|
433
448
|
font-weight: 300;
|
|
@@ -436,7 +451,7 @@
|
|
|
436
451
|
text-overflow: ellipsis;
|
|
437
452
|
overflow: hidden;
|
|
438
453
|
|
|
439
|
-
${t=>{var e,r;return t.help&&
|
|
454
|
+
${t=>{var e,r;return t.help&&f.css`
|
|
440
455
|
color: ${(e=t.theme.colors)==null?void 0:e.text};
|
|
441
456
|
text-decoration: underline;
|
|
442
457
|
|
|
@@ -453,12 +468,12 @@
|
|
|
453
468
|
text-decoration: underline;
|
|
454
469
|
}
|
|
455
470
|
}
|
|
456
|
-
`,
|
|
471
|
+
`,Oe=()=>s.jsx(Re,{className:"humany-conversation-separator"}),Re=i.div`
|
|
457
472
|
${t=>t.theme.border&&`border-bottom: ${t.theme.border};`}
|
|
458
473
|
width: 100%;
|
|
459
|
-
`,
|
|
460
|
-
${
|
|
461
|
-
`,
|
|
474
|
+
`,Ee=({text:t})=>s.jsx(De,{className:"humany-conversation-text",variant:"span",children:t}),De=i(n.Typography)`
|
|
475
|
+
${C}
|
|
476
|
+
`,Ke=({header:t="Video call",acceptLabel:e="Accept",declineLabel:r="Decline",dispatch:o})=>{const a=y.useMemo(()=>[{label:e,actionKey:"accept-video-call",symbol:{type:"Svg",content:"video"}},{label:r,actionKey:"decline-video-call",symbol:{type:"Svg",content:"close"}}],[e,r]);return s.jsx(qe,{className:"humany-conversation-video-request",header:t,items:a,renderItem:l=>{const d=l.actionKey==="accept-video-call"?"#70c48e":"#da5c85";return s.jsx("li",{children:s.jsx(Pe,{onClick:()=>{o("action",l)},"aria-label":l.label,title:l.label,bgColor:d,children:s.jsx(n.SymbolBadge,{symbol:l.symbol,size:25})})},l.actionKey)}})},qe=i(n.ItemList)`
|
|
462
477
|
${t=>n.itemList(t)}
|
|
463
478
|
> ul {
|
|
464
479
|
display: flex;
|
|
@@ -468,8 +483,8 @@
|
|
|
468
483
|
margin: 0;
|
|
469
484
|
}
|
|
470
485
|
}
|
|
471
|
-
${t=>
|
|
472
|
-
`,
|
|
486
|
+
${t=>C(t)}
|
|
487
|
+
`,Pe=i(n.Button)`
|
|
473
488
|
${n.buttonCss};
|
|
474
489
|
|
|
475
490
|
background-color: ${t=>t.bgColor};
|
|
@@ -503,20 +518,20 @@
|
|
|
503
518
|
stroke: #fff;
|
|
504
519
|
}
|
|
505
520
|
}
|
|
506
|
-
`,
|
|
521
|
+
`,Fe=([t,e])=>({type:t,content:e}),We=({items:t,dispatch:e})=>s.jsx(Ue,{role:"none",className:"humany-message-list",items:t.map(Fe),renderLi:!0,renderItem:r=>{switch(r.type){case $.ConversationMessageListItemType.Text:return s.jsx(Ee,{text:r.content});case $.ConversationMessageListItemType.HTML:return s.jsx(Te,{...r.content});case $.ConversationMessageListItemType.Separator:return s.jsx(Oe,{...r.content});case $.ConversationMessageListItemType.ItemList:return s.jsx(Ne,{...r.content,dispatch:e});case $.ConversationMessageListItemType.LinkList:return s.jsx(Be,{...r.content,dispatch:e});case $.ConversationMessageListItemType.ButtonList:return s.jsx(Se,{...r.content,dispatch:e});case $.ConversationMessageListItemType.VideoRequest:return s.jsx(Ke,{...r.content,dispatch:e});default:return s.jsx(Le,{type:r.type,content:r.content})}}}),Ue=i(n.List)`
|
|
507
522
|
${n.list}
|
|
508
523
|
|
|
509
524
|
> li {
|
|
510
525
|
margin: 0;
|
|
511
526
|
}
|
|
512
|
-
`,
|
|
527
|
+
`,Ve=y.forwardRef(({className:t,timestamp:e,sender:r,type:o,content:a},l)=>{const d=y.useCallback(c=>{let g="first";return a.length>1&&(g=c===0?"first":c+1===a.length?"last":"middle"),g},[a]),{userLabel:u=""}=n.useProperties(),h=()=>s.jsx(s.Fragment,{children:a.map(c=>{const{key:g,body:S,title:k,form:x,actions:T}=c,z=!!S&&!k&&!x&&!T;return s.jsx(pe,{className:t,discrete:z,ref:l,timestamp:e,fullWidth:!!x||!!T,children:z&&S?s.jsx(n.Html,{html:S}):s.jsx(A,{isSystem:!0,content:c})},g)})}),b=()=>s.jsxs(s.Fragment,{children:[s.jsxs(F,{className:"humany-sr-only",children:[r==null?void 0:r.name,":"]}),s.jsx(V,{sender:r,timestamp:e,className:t,children:s.jsx(O,{className:"humany-message-content-bundle",children:a.map((c,g)=>s.jsx(R,{className:"humany-message-container",left:!0,ref:l,children:s.jsx(A,{content:c,stacked:d(g)})},c.key))})})]}),p=()=>s.jsxs(s.Fragment,{children:[s.jsxs(F,{className:"humany-sr-only",children:[u,":"]}),s.jsx($e,{timestamp:e,className:t,children:s.jsx(O,{className:"humany-message-content-bundle",children:a.map((c,g)=>s.jsx(R,{className:"humany-message-container",right:!0,ref:l,children:s.jsx(A,{isUser:!0,content:c,stacked:d(g)})},c.key))})})]});switch(o){case $.ConversationMessageType.System:return h();case $.ConversationMessageType.Agent:return b();case $.ConversationMessageType.User:return p();default:return null}}),A=({content:t,isUser:e,isSystem:r,stacked:o})=>{const a=n.useDispatch(),{title:l,body:d,actions:u,form:h,items:b}=t;return b?s.jsx(E,{className:"humany-message-content",user:!!e,stacked:o,children:s.jsx(We,{items:b,dispatch:a})}):s.jsxs(E,{className:"humany-message-content",padded:!r,user:!!e,stacked:o,fullWidth:!!h||!!u,children:[l&&s.jsx(N,{children:s.jsx(ce,{variant:"h2",children:l})}),d&&s.jsx(N,{children:s.jsx(he,{html:d})}),h&&s.jsx(N,{children:s.jsx(ue,{...h,onChange:(c,g)=>{a("form",{data:g,formKey:h.schema.id,actionKey:c})}})}),u&&s.jsx(N,{children:s.jsx(ge,{items:Object.keys(u).map(c=>({label:u[c],actionKey:c})),renderItem:c=>s.jsx("li",{children:s.jsx(ye,{onClick:()=>{a("action",c.actionKey)},children:c.label})},c.actionKey)})})]})},F=i.div`
|
|
513
528
|
position: absolute;
|
|
514
529
|
left: -10000px;
|
|
515
530
|
top: auto;
|
|
516
531
|
width: 1px;
|
|
517
532
|
height: 1px;
|
|
518
533
|
overflow: hidden;
|
|
519
|
-
`,
|
|
534
|
+
`,_=()=>{const t=y.useCallback(u=>{u&&setTimeout(()=>{u.scrollIntoView({block:"start",behavior:"smooth"})},250)},[]),[e,r]=n.useScroll(!0),{messages:o,loading:a,typingActors:l=[]}=n.useProperties(),d=()=>l&&l.length?l.map((u,h)=>s.jsx(H,{id:`typing_${u.name}`,children:s.jsx(V,{timestamp:Date.now(),sender:u,children:s.jsx(q,{boxed:!0,ref:t})})},`typing_${u.name}`)):null;return s.jsxs(s.Fragment,{children:[s.jsxs(_e,{tabIndex:0,scrollableCss:e,ref:r,children:[o&&o.length?o.map((u,h)=>{const{type:b,timestamp:p,sender:c,content:g}=u;return s.jsx(H,{className:"humany-conversation-entry",tabIndex:-1,children:s.jsx(Ve,{...u,ref:t})},`${b}_${c==null?void 0:c.name}_${p}_${g[0].key}`)}):null,d(),a&&s.jsx(H,{children:s.jsx(q,{ref:t})})]}),s.jsx(Z,{})]})},_e=i.div`
|
|
520
535
|
display: flex;
|
|
521
536
|
flex-direction: column;
|
|
522
537
|
align-items: stretch;
|
|
@@ -526,7 +541,7 @@
|
|
|
526
541
|
&:focus-visible {
|
|
527
542
|
${t=>n.borderTabStyle(t)};
|
|
528
543
|
}
|
|
529
|
-
`,
|
|
544
|
+
`,H=i.div`
|
|
530
545
|
margin: 0;
|
|
531
546
|
margin-bottom: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.medium}};
|
|
532
547
|
|
|
@@ -549,10 +564,10 @@
|
|
|
549
564
|
h1 {
|
|
550
565
|
font-weight: normal;
|
|
551
566
|
}
|
|
552
|
-
${t=>n.headingElement(t)("h1",
|
|
567
|
+
${t=>n.headingElement(t)("h1",f.css`
|
|
553
568
|
font-weight: normal;
|
|
554
569
|
`)}
|
|
555
|
-
`,
|
|
570
|
+
`,Ye=({dispatch:t})=>{const e=y.useRef(null);return y.useEffect(()=>{e.current&&e.current.parentNode&&t("overlay-mounted",e.current)},[e]),s.jsx(n.WidgetOverlayOutlet,{portalId:"humany-conversation-overlay-portal",className:"humany-conversation-overlay-outlet",ref:e})},Xe=({dispatch:t,header:e,buttonLabel:r})=>s.jsxs(Ge,{portalId:"humany-conversation-portal",className:"humany-conversation-outlet",children:[s.jsxs(Je,{className:"humany-conversation-outlet-head",children:[s.jsx(Ze,{className:"humany-conversation-outlet-head-button","aria-label":r,title:r,onClick:()=>t("hide-overlay-conversation"),children:s.jsx(n.SymbolBadge,{symbol:{type:"Svg",content:"caret-down"},size:20})}),e&&s.jsx(Qe,{className:"humany-conversation-outlet-header",variant:"h1",children:e})]}),s.jsx(_,{})]}),Ge=i(n.WidgetOverlayOutlet)`
|
|
556
571
|
z-index: 11;
|
|
557
572
|
top: auto;
|
|
558
573
|
height: 65%;
|
|
@@ -561,7 +576,7 @@
|
|
|
561
576
|
flex-direction: column;
|
|
562
577
|
border-top-right-radius: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.large}};
|
|
563
578
|
border-top-left-radius: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.large}};
|
|
564
|
-
`,
|
|
579
|
+
`,Je=i.div`
|
|
565
580
|
display: flex;
|
|
566
581
|
flex-direction: column;
|
|
567
582
|
justify-content: center;
|
|
@@ -569,11 +584,11 @@
|
|
|
569
584
|
gap: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
|
|
570
585
|
padding: ${t=>{var e;return(e=t.theme.sizes)==null?void 0:e.normal}};
|
|
571
586
|
${t=>t.theme.border&&`border-bottom: ${t.theme.border};`}
|
|
572
|
-
`,
|
|
587
|
+
`,Qe=i(n.Typography)`
|
|
573
588
|
font-size: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.medium}};
|
|
574
589
|
color: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
|
|
575
590
|
margin: 0;
|
|
576
|
-
`,
|
|
591
|
+
`,Ze=i(n.Button)`
|
|
577
592
|
display: flex;
|
|
578
593
|
align-items: center;
|
|
579
594
|
justify-content: center;
|
|
@@ -587,7 +602,7 @@
|
|
|
587
602
|
svg line {
|
|
588
603
|
stroke: ${t=>{var e;return(e=t.theme.colors)==null?void 0:e.text}};
|
|
589
604
|
}
|
|
590
|
-
`,
|
|
605
|
+
`,et=({className:t,...e})=>{const{overlay:r,overlayConversationHeader:o,overlayConversationCloseLabel:a,conversationControllerId:l}=n.useProperties(),d=n.useDispatch(),h=n.useContainer().get("$settings");return s.jsx(n.ConversationContext.Provider,{value:l?{id:l}:null,children:s.jsxs(U.Provider,{value:h==null?void 0:h.language,children:[s.jsx(tt,{"aria-live":"assertive",...e,className:L.appendClassNames(t,"humany-conversation-component"),children:s.jsx(_,{})}),r&&s.jsxs(s.Fragment,{children:[s.jsx(Ye,{dispatch:d}),r.conversation&&s.jsx(Xe,{dispatch:d,header:o,buttonLabel:a})]})]})})},tt=i.div`
|
|
591
606
|
position: absolute;
|
|
592
607
|
right: 0;
|
|
593
608
|
left: 0;
|
|
@@ -596,4 +611,4 @@
|
|
|
596
611
|
overflow: hidden;
|
|
597
612
|
display: flex;
|
|
598
613
|
flex-direction: column;
|
|
599
|
-
`;exports.default=
|
|
614
|
+
`;exports.default=et;
|