@telia-ace/widget-conversation 1.0.26 → 1.0.28

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.
Files changed (46) hide show
  1. package/README.md +246 -106
  2. package/dist/{ui → components}/conversation/conversation.d.ts +0 -0
  3. package/dist/{ui/conversation/conversation-component.d.ts → components/conversation/plugin.d.ts} +13 -2
  4. package/dist/components/conversation/ui/content.d.ts +2 -0
  5. package/dist/{ui/conversation/conversation-input.d.ts → components/conversation/ui/input.d.ts} +0 -0
  6. package/dist/components/conversation/ui/loader.d.ts +9 -0
  7. package/dist/components/conversation/ui/message-list-items/button-list.d.ts +8 -0
  8. package/dist/components/conversation/ui/message-list-items/custom.d.ts +9 -0
  9. package/dist/components/conversation/ui/message-list-items/html.d.ts +5 -0
  10. package/dist/components/conversation/ui/message-list-items/link-list.d.ts +8 -0
  11. package/dist/components/conversation/ui/message-list-items/separator.d.ts +2 -0
  12. package/dist/components/conversation/ui/message-list-items/text.d.ts +6 -0
  13. package/dist/components/conversation/ui/message-list-items/video-request.d.ts +8 -0
  14. package/dist/{ui/conversation → components/conversation/ui}/message-types/agent.d.ts +1 -1
  15. package/dist/{ui/conversation → components/conversation/ui}/message-types/index.d.ts +0 -1
  16. package/dist/components/conversation/ui/message-types/message-list.d.ts +9 -0
  17. package/dist/{ui/conversation → components/conversation/ui}/message-types/system.d.ts +1 -1
  18. package/dist/{ui/conversation → components/conversation/ui}/message-types/timestamp.d.ts +0 -0
  19. package/dist/{ui/conversation → components/conversation/ui}/message-types/user.d.ts +0 -0
  20. package/dist/components/conversation/ui/message.d.ts +5 -0
  21. package/dist/components/conversation/ui/overlay-outlets.d.ts +13 -0
  22. package/dist/components/conversation/ui/styles.d.ts +31 -0
  23. package/dist/{ui/return-button/return-button-component.d.ts → components/return-button/plugin.d.ts} +1 -2
  24. package/dist/{ui → components}/return-button/return-button.d.ts +0 -0
  25. package/dist/conversation.d7aad569.js +1153 -0
  26. package/dist/conversation.d7aad569.js.map +1 -0
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +453 -341
  29. package/dist/index.js.map +1 -1
  30. package/dist/{return-button.8773c0de.js → return-button.9c517bbe.js} +11 -14
  31. package/dist/return-button.9c517bbe.js.map +1 -0
  32. package/dist/types.d.ts +34 -41
  33. package/dist/utils/map-actions.d.ts +1 -0
  34. package/dist/utils/open-chat-widget.d.ts +1 -1
  35. package/package.json +10 -9
  36. package/dist/conversation.3981560b.js +0 -1100
  37. package/dist/conversation.3981560b.js.map +0 -1
  38. package/dist/return-button.8773c0de.js.map +0 -1
  39. package/dist/ui/conversation/conversation-content.d.ts +0 -11
  40. package/dist/ui/conversation/conversation-loader.d.ts +0 -8
  41. package/dist/ui/conversation/conversation-message.d.ts +0 -7
  42. package/dist/ui/conversation/conversation-styles.d.ts +0 -11
  43. package/dist/ui/conversation/index.d.ts +0 -2
  44. package/dist/ui/conversation/message-types/custom.d.ts +0 -9
  45. package/dist/ui/index.d.ts +0 -2
  46. package/dist/ui/return-button/index.d.ts +0 -2
@@ -1,1100 +0,0 @@
1
- var pe = Object.defineProperty, ye = Object.defineProperties;
2
- var be = Object.getOwnPropertyDescriptors;
3
- var I = Object.getOwnPropertySymbols;
4
- var Y = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable;
5
- var V = (e, t, r) => t in e ? pe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, z = (e, t) => {
6
- for (var r in t || (t = {}))
7
- Y.call(t, r) && V(e, r, t[r]);
8
- if (I)
9
- for (var r of I(t))
10
- q.call(t, r) && V(e, r, t[r]);
11
- return e;
12
- }, J = (e, t) => ye(e, be(t));
13
- var Q = (e, t) => {
14
- var r = {};
15
- for (var o in e)
16
- Y.call(e, o) && t.indexOf(o) < 0 && (r[o] = e[o]);
17
- if (e != null && I)
18
- for (var o of I(e))
19
- t.indexOf(o) < 0 && q.call(e, o) && (r[o] = e[o]);
20
- return r;
21
- };
22
- import { Input as le, Button as $e, borderTabStyle as x, SymbolBadge as M, useDispatch as U, useProperties as K, useScroll as se, Typography as Ee, useComponent as ke, invertedHoverButton as W, Html as _, List as P, buttonCss as R, Icon as xe, Lightbox as ie, useTransitionEnd as ve, headingElement as we } from "@telia-ace/widget-ui";
23
- import { appendClassNames as T, uuid as X } from "@telia-ace/widget-utilities";
24
- import n, { useState as S, useEffect as ce, Suspense as Ce, Fragment as Z, useRef as ze, useCallback as Se } from "react";
25
- import l, { css as m, keyframes as Te } from "styled-components";
26
- import { FormComponent as me } from "@telia-ace/widget-forms";
27
- import { ConversationMessageListItemType as E, ConversationMessageType as B } from "./index.js";
28
- import "@telia-ace/widget-core";
29
- import "@telia-ace/widget-services";
30
- import "@telia-ace/widget-plugins";
31
- const Le = ({ className: e }) => {
32
- const [t, r] = S(""), [o, c] = S(!1), [g, u] = S(0), [p, b] = S(0), d = U(), {
33
- inputPlaceholder: a = "Type your message",
34
- inputHidden: i = !1,
35
- inputDisabled: s = !1,
36
- sendButtonLabel: v = "Send message",
37
- inputMultiline: y = !0
38
- } = K(), [$, f] = se(!0);
39
- ce(() => {
40
- if (f.current) {
41
- const { lineHeight: h, maxHeight: L } = getComputedStyle(f.current);
42
- if (h && h.indexOf("px") > -1) {
43
- const C = h.split("px"), ge = parseInt(C[0], 10);
44
- u(ge);
45
- const fe = L.split("px");
46
- b(parseInt(fe[0], 10));
47
- }
48
- }
49
- }, [f.current]);
50
- const F = (h) => {
51
- !h.shiftKey || !y ? (h.preventDefault(), t && t.length > 0 && (d("user-submit", { text: t }), r(""), A(""))) : t.length < 1 && h.preventDefault();
52
- }, he = (h) => {
53
- if (y && f.current) {
54
- const L = f.current.scrollHeight;
55
- if (L > g) {
56
- f.current.style.height = "auto";
57
- let C = L;
58
- h.length < 1 && (C = g), f.current.style.height = `${C}px`, C >= p ? f.current.style.overflowY = "scroll" : f.current.style.overflowY = "hidden";
59
- }
60
- }
61
- }, A = (h) => {
62
- he(h), r(h), h && h.length > 0 && d("user-typing", { textLength: h.length });
63
- };
64
- return i ? null : /* @__PURE__ */ n.createElement(He, {
65
- grow: y,
66
- className: T("humany-conversation-input", e),
67
- "data-has-focus": o,
68
- scrollableCss: $
69
- }, y ? /* @__PURE__ */ n.createElement(de, {
70
- value: t,
71
- onChange: A,
72
- onEnter: F,
73
- disabled: s,
74
- "aria-label": a,
75
- placeholder: a,
76
- onFocusChange: c,
77
- type: "textarea",
78
- rows: 1,
79
- ref: f
80
- }) : /* @__PURE__ */ n.createElement(Ie, {
81
- value: t,
82
- onChange: A,
83
- onEnter: F,
84
- disabled: s,
85
- "aria-label": a,
86
- placeholder: a,
87
- onFocusChange: c
88
- }), /* @__PURE__ */ n.createElement(Me, {
89
- disabled: s,
90
- onClick: F,
91
- title: v,
92
- "aria-label": v
93
- }, /* @__PURE__ */ n.createElement(Ke, {
94
- size: 22,
95
- symbol: { type: "Svg", content: "send" },
96
- hasContent: t && t.length
97
- })));
98
- }, de = l(le)`
99
- resize: none;
100
- flex: 1;
101
- flex-shrink: 1;
102
- min-height: 1.2em;
103
- max-height: 148px;
104
- line-height: 1.2em;
105
- height: 1.2em;
106
- padding: 0;
107
- margin: ${(e) => {
108
- var t;
109
- return (t = e.theme.sizes) == null ? void 0 : t.small;
110
- }} ${(e) => {
111
- var t;
112
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
113
- }};
114
- font-size: ${(e) => {
115
- var t;
116
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
117
- }};
118
- border: none;
119
- transition: height 200ms linear;
120
- outline: none;
121
- `, Ie = l(le)`
122
- flex: 1;
123
- border: none;
124
- background-color: transparent;
125
- font-weight: 300;
126
- font-size: ${(e) => {
127
- var t;
128
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
129
- }};
130
- line-height: 1.2em;
131
- outline: none;
132
- padding-left: ${(e) => {
133
- var t;
134
- return (t = e.theme.sizes) == null ? void 0 : t.large;
135
- }};
136
- color: ${(e) => {
137
- var t;
138
- return (t = e.theme.colors) == null ? void 0 : t.text;
139
- }};
140
- &::placeholder {
141
- color: ${(e) => {
142
- var t;
143
- return (t = e.theme.colors) == null ? void 0 : t.textLight;
144
- }};
145
- font-style: italic;
146
- }
147
- `, Me = l($e)`
148
- flex: 0 0 50px;
149
- align-self: stretch;
150
- background-color: transparent;
151
- border: none;
152
- &:focus {
153
- ${(e) => {
154
- var t;
155
- return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && x;
156
- }};
157
- }
158
- `, He = l.div`
159
- ${(e) => e.grow ? m`
160
- min-height: 50px;
161
- max-height: 150px;
162
- ` : m`
163
- height: 50px;
164
- `}
165
- flex: 0 0 auto;
166
- display: flex;
167
- align-items: center;
168
- background-color: ${(e) => {
169
- var t;
170
- return (t = e.theme.colors) == null ? void 0 : t.accent;
171
- }};
172
- border-top: ${(e) => e.theme.inputBorder};
173
- ${(e) => e["data-has-focus"] && m`
174
- ${(t) => {
175
- var r;
176
- return ((r = t.theme.accessibility) == null ? void 0 : r.isTabbing) && x;
177
- }};
178
- `}
179
- ${de} {
180
- ${(e) => !!e.scrollableCss && e.scrollableCss}
181
- }
182
- `, Ke = l((r) => {
183
- var o = r, { hasContent: e } = o, t = Q(o, ["hasContent"]);
184
- return /* @__PURE__ */ n.createElement(M, z({}, t));
185
- })`
186
- line,
187
- path {
188
- stroke: ${(e) => {
189
- var t;
190
- return e.hasContent ? (t = e.theme.colors) == null ? void 0 : t.primary : "#a6a6a6";
191
- }};
192
- fill: ${(e) => {
193
- var t;
194
- return e.hasContent ? (t = e.theme.colors) == null ? void 0 : t.primary : "#a6a6a6";
195
- }};
196
- }
197
- `, Pe = l.div`
198
- width: ${(e) => e.avatarSize || "32px"};
199
- height: ${(e) => e.avatarSize || "32px"};
200
- border-radius: 50%;
201
- background-color: ${(e) => {
202
- var t;
203
- return (t = e.theme.colors) == null ? void 0 : t.accent;
204
- }};
205
- border: ${(e) => e.theme.border};
206
- grid-area: avatar;
207
- align-self: flex-end;
208
- justify-self: center;
209
- overflow: hidden;
210
- margin-right: ${(e) => {
211
- var t;
212
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
213
- }};
214
- display: flex;
215
- justify-content: center;
216
- align-items: center;
217
- color: ${(e) => {
218
- var t;
219
- return (t = e.theme.colors) == null ? void 0 : t.text;
220
- }};
221
-
222
- > img {
223
- height: 100%;
224
- width: 100%;
225
- object-fit: cover;
226
- }
227
-
228
- > svg {
229
- width: 90%;
230
- height: 90%;
231
- padding: 10%;
232
- color: ${(e) => {
233
- var t;
234
- return (t = e.theme.colors) == null ? void 0 : t.text;
235
- }};
236
-
237
- line,
238
- path,
239
- circle,
240
- fill {
241
- stroke: ${(e) => {
242
- var t;
243
- return (t = e.theme.colors) == null ? void 0 : t.text;
244
- }};
245
- }
246
- }
247
- `, Fe = Te`
248
- 0% {
249
- opacity: 0;
250
- }
251
- 75% {
252
- opacity: 1;
253
- }
254
- 100% {
255
- opacity: 0;
256
- }
257
- `, Ae = l.div`
258
- display: flex;
259
- justify-content: center;
260
- > div {
261
- height: 10px;
262
- width: 10px;
263
- border-radius: 50%;
264
- margin: 5px;
265
- background-color: ${(e) => {
266
- var t;
267
- return (t = e.theme.colors) == null ? void 0 : t.text;
268
- }};
269
- animation: ${Fe} 1s infinite;
270
- }
271
- > div:nth-child(2) {
272
- animation-delay: 100ms;
273
- }
274
- > div:nth-child(3) {
275
- animation-delay: 200ms;
276
- }
277
- `, D = l.div`
278
- grid-area: content;
279
- max-width: 100%;
280
- overflow: hidden;
281
- `, Be = l(Ee)`
282
- font-size: ${(e) => {
283
- var t;
284
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
285
- }};
286
- font-weight: normal;
287
- margin: 0;
288
- `, j = l.div`
289
- display: flex;
290
- `, G = l.div`
291
- background-color: ${(e) => {
292
- var t, r;
293
- return e.user ? (t = e.theme.colors) == null ? void 0 : t.primary : (r = e.theme.colors) == null ? void 0 : r.accent;
294
- }};
295
- color: ${(e) => {
296
- var t, r;
297
- return e.user ? (t = e.theme.colors) == null ? void 0 : t.accent : (r = e.theme.colors) == null ? void 0 : r.text;
298
- }};
299
- border-radius: 5px; // TODO: prop?
300
- margin-top: ${(e) => {
301
- var t;
302
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
303
- }};
304
- display: inline-block;
305
- && > * {
306
- overflow-wrap: break-word;
307
- word-wrap: break-word;
308
- word-break: break-all;
309
- word-break: break-word;
310
- hyphens: auto;
311
- }
312
- max-width: 100%;
313
- ${(e) => e.fullWidth && "width: 100%;"}
314
-
315
- ${(e) => !e.user && m`
316
- border: ${e.theme.border};
317
- `}
318
- ${(e) => e.user && "margin-left: auto"};
319
-
320
- ${(e) => e.stacked === "first" && e.user && m`
321
- border-bottom-right-radius: 1px; // TODO: Prop?
322
- `}
323
- ${(e) => e.stacked === "middle" && e.user && m`
324
- border-bottom-right-radius: 1px;
325
- border-top-right-radius: 1px;
326
- `}
327
- ${(e) => e.stacked === "last" && e.user && m`
328
- border-top-right-radius: 1px;
329
- `}
330
- ${(e) => e.stacked === "first" && !e.user && m`
331
- border-bottom-left-radius: 1px;
332
- `}
333
- ${(e) => e.stacked === "middle" && !e.user && m`
334
- border-bottom-left-radius: 1px;
335
- border-top-left-radius: 1px;
336
- `}
337
- ${(e) => e.stacked === "last" && !e.user && m`
338
- border-top-left-radius: 1px;
339
- `};
340
-
341
- ${(e) => !e.stacked && m`
342
- ${e.user ? "border-bottom-right-radius: 1px;" : "border-bottom-left-radius: 1px;"}
343
- `};
344
-
345
- transition: border-radius 500ms linear;
346
- `, w = l.div`
347
- padding: ${(e) => {
348
- var t;
349
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
350
- }};
351
-
352
- ${(e) => e.noPadding && m`
353
- padding: 0;
354
- `}
355
-
356
- margin-bottom: ${(e) => {
357
- var t;
358
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
359
- }};
360
- &:last-child {
361
- margin-bottom: 0;
362
- }
363
- `, ee = ({ className: e, agentData: t }) => /* @__PURE__ */ n.createElement(D, null, /* @__PURE__ */ n.createElement(j, null, /* @__PURE__ */ n.createElement(G, null, /* @__PURE__ */ n.createElement(Ae, null, /* @__PURE__ */ n.createElement("div", null), /* @__PURE__ */ n.createElement("div", null), /* @__PURE__ */ n.createElement("div", null))))), Ne = l.p`
364
- && {
365
- font-size: ${(e) => {
366
- var t;
367
- return (t = e.theme.fonts) == null ? void 0 : t.small;
368
- }};
369
- font-weight: 300;
370
- }
371
- margin: 0;
372
- line-height: 1.5em;
373
- grid-area: info;
374
- color: ${(e) => {
375
- var t;
376
- return (t = e.theme.colors) == null ? void 0 : t.text;
377
- }};
378
- `, te = (e) => new Date(e).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), H = ({ className: e, name: t, timestamp: r }) => {
379
- if (!t && !r)
380
- return null;
381
- let o = "";
382
- return t ? r ? o = `${t}: ${te(r)}` : o = t : r && (o = te(r)), /* @__PURE__ */ n.createElement(Ne, null, o);
383
- }, ue = ({ className: e, children: t, sender: r, timestamp: o }) => {
384
- const { avatar: c, name: g } = r, { avatarSize: u } = K();
385
- return /* @__PURE__ */ n.createElement(Oe, {
386
- hasAvatar: !!c,
387
- className: T(e, "humany-conversation-agent-message")
388
- }, c && /* @__PURE__ */ n.createElement(Pe, {
389
- avatarSize: u
390
- }, typeof c == "string" ? /* @__PURE__ */ n.createElement("img", {
391
- src: c
392
- }) : /* @__PURE__ */ n.createElement(M, {
393
- symbol: c
394
- })), t, /* @__PURE__ */ n.createElement(H, {
395
- name: g,
396
- timestamp: o
397
- }));
398
- }, Oe = l.div`
399
- display: grid;
400
- margin-right: 0;
401
- width: 100%;
402
- ${(e) => e.hasAvatar ? m`
403
- grid-template-columns: auto 1fr;
404
- grid-template-rows: 1fr auto;
405
- grid-template-areas:
406
- 'avatar content'
407
- '. info';
408
- ` : m`
409
- grid-template-columns: 1fr;
410
- grid-template-rows: 1fr auto;
411
- grid-template-areas:
412
- 'content'
413
- 'info';
414
- `};
415
- `, De = (e) => {
416
- const t = ke(e.type);
417
- return t ? /* @__PURE__ */ n.createElement(Ce, {
418
- fallback: null
419
- }, /* @__PURE__ */ n.createElement(G, {
420
- user: e.isUser,
421
- stacked: !!e.stacked && e.stacked,
422
- fullWidth: !!e.content.form || !!e.content.actions
423
- }, /* @__PURE__ */ n.createElement(w, {
424
- noPadding: !!e.content.noPadding && e.content.noPadding
425
- }, /* @__PURE__ */ n.createElement(t, z({}, e.content))))) : null;
426
- }, je = ({
427
- className: e,
428
- children: t,
429
- timestamp: r,
430
- discrete: o,
431
- fullWidth: c
432
- }) => /* @__PURE__ */ n.createElement(Ue, {
433
- className: T(e, "humany-conversation-system-message"),
434
- fullWidth: c
435
- }, o ? /* @__PURE__ */ n.createElement(We, {
436
- className: "humany-conversation-discrete-message"
437
- }, t, /* @__PURE__ */ n.createElement(H, {
438
- timestamp: r
439
- })) : /* @__PURE__ */ n.createElement(n.Fragment, null, t, /* @__PURE__ */ n.createElement(H, {
440
- timestamp: r
441
- }))), Ue = l.div`
442
- ${(e) => e.fullWidth && "width: 100%"};
443
- padding: 0 ${(e) => {
444
- var t;
445
- return (t = e.theme.sizes) == null ? void 0 : t.large;
446
- }};
447
- overflow: auto;
448
- `, We = l.div`
449
- text-align: center;
450
- word-wrap: break-word;
451
- font-size: ${(e) => {
452
- var t;
453
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
454
- }};
455
- color: ${(e) => {
456
- var t;
457
- return (t = e.theme.colors) == null ? void 0 : t.text;
458
- }};
459
- > p {
460
- margin: 0;
461
- }
462
- `, _e = ({ className: e, children: t, timestamp: r }) => {
463
- const { userLabel: o = "" } = K();
464
- return /* @__PURE__ */ n.createElement(Re, {
465
- className: T(e, "humany-conversation-user-message")
466
- }, t, /* @__PURE__ */ n.createElement(H, {
467
- name: o,
468
- timestamp: r
469
- }));
470
- }, Re = l.div`
471
- margin-left: 15%;
472
- width: 85%;
473
- display: flex;
474
- flex-direction: column;
475
- align-items: flex-end;
476
- `, Ge = (e) => /* @__PURE__ */ n.createElement(ie, {
477
- attrs: e
478
- }), ne = {
479
- transform: {
480
- img: Ge
481
- }
482
- }, N = ({ content: e, isUser: t, stacked: r }) => {
483
- const o = U(), { title: c, body: g, actions: u, form: p, type: b, items: d } = e;
484
- return b ? /* @__PURE__ */ n.createElement(De, {
485
- type: b,
486
- content: e,
487
- isUser: t,
488
- stacked: r
489
- }) : /* @__PURE__ */ n.createElement(G, {
490
- noPadding: !0,
491
- user: t,
492
- stacked: !!r && r,
493
- fullWidth: !!p || !!u
494
- }, c && /* @__PURE__ */ n.createElement(w, null, /* @__PURE__ */ n.createElement(Be, {
495
- variant: "h2"
496
- }, c)), g && /* @__PURE__ */ n.createElement(w, null, /* @__PURE__ */ n.createElement(re, {
497
- html: g,
498
- htmlParseInstruction: ne
499
- })), p && /* @__PURE__ */ n.createElement(w, null, /* @__PURE__ */ n.createElement(Ve, J(z({}, p), {
500
- onChange: (a, i) => {
501
- o("form", {
502
- data: i,
503
- formKey: p.schema.id,
504
- actionKey: a
505
- });
506
- }
507
- }))), u && /* @__PURE__ */ n.createElement(w, null, /* @__PURE__ */ n.createElement(oe, {
508
- items: Object.keys(u).map((a) => ({ label: u[a], actionKey: a })),
509
- renderItem: (a) => /* @__PURE__ */ n.createElement("li", {
510
- key: a.actionKey
511
- }, /* @__PURE__ */ n.createElement(Qe, {
512
- onClick: () => {
513
- o("action", a.actionKey);
514
- }
515
- }, a.label))
516
- })), d && /* @__PURE__ */ n.createElement(Z, null, /* @__PURE__ */ n.createElement(w, {
517
- key: X(),
518
- noPadding: !0
519
- }, /* @__PURE__ */ n.createElement(oe, {
520
- items: d.map(([a, i]) => ({ type: a, content: i })),
521
- renderItem: (a) => {
522
- const i = X();
523
- switch (a.type) {
524
- case E.Header:
525
- return /* @__PURE__ */ n.createElement(k, {
526
- key: i
527
- }, /* @__PURE__ */ n.createElement("strong", null, a.content));
528
- case E.Text:
529
- return /* @__PURE__ */ n.createElement(k, {
530
- key: i
531
- }, /* @__PURE__ */ n.createElement("span", null, a.content));
532
- case E.HTML:
533
- return /* @__PURE__ */ n.createElement(k, {
534
- key: i
535
- }, /* @__PURE__ */ n.createElement(re, {
536
- html: a.content.body,
537
- htmlParseInstruction: ne
538
- }));
539
- case E.Separator:
540
- return /* @__PURE__ */ n.createElement(k, {
541
- key: i,
542
- noPadding: !0
543
- }, /* @__PURE__ */ n.createElement(Xe, null));
544
- case E.LinkList:
545
- return /* @__PURE__ */ n.createElement(k, {
546
- key: i
547
- }, /* @__PURE__ */ n.createElement(qe, {
548
- items: Object.keys(a.content.actions).map((s) => ({
549
- label: a.content.actions[s],
550
- actionKey: s
551
- })),
552
- renderItem: (s) => /* @__PURE__ */ n.createElement("li", {
553
- key: s.actionKey
554
- }, /* @__PURE__ */ n.createElement(Je, {
555
- help: s.actionKey === "help",
556
- onClick: () => {
557
- o("action", s.actionKey);
558
- }
559
- }, s.label, s.actionKey === "help" && /* @__PURE__ */ n.createElement(M, {
560
- size: 14,
561
- symbol: {
562
- type: "Svg",
563
- content: "caret-down"
564
- }
565
- })))
566
- }));
567
- case E.ButtonList:
568
- return /* @__PURE__ */ n.createElement(k, {
569
- key: i
570
- }, /* @__PURE__ */ n.createElement(ae, {
571
- items: Object.keys(a.content.actions).map((s) => ({
572
- label: a.content.actions[s],
573
- actionKey: s
574
- })),
575
- renderItem: (s) => /* @__PURE__ */ n.createElement("li", {
576
- key: s.actionKey
577
- }, /* @__PURE__ */ n.createElement(Ye, {
578
- onClick: () => {
579
- o("action", s.actionKey);
580
- }
581
- }, s.label))
582
- }));
583
- case E.NoGoodAlternative:
584
- return /* @__PURE__ */ n.createElement(k, {
585
- key: i
586
- }, /* @__PURE__ */ n.createElement(Ze, {
587
- onClick: () => {
588
- o("action", "help");
589
- }
590
- }, /* @__PURE__ */ n.createElement(M, {
591
- size: 14,
592
- symbol: {
593
- type: "FontAwesome",
594
- content: "meh-o"
595
- }
596
- }), /* @__PURE__ */ n.createElement("span", null, a.content.body)));
597
- case E.FeedbackList:
598
- return /* @__PURE__ */ n.createElement(k, {
599
- key: i
600
- }, /* @__PURE__ */ n.createElement(ae, {
601
- items: Object.keys(a.content.actions).map((s) => ({
602
- label: a.content.actions[s],
603
- actionKey: s
604
- })),
605
- renderItem: (s) => /* @__PURE__ */ n.createElement("li", {
606
- key: s.actionKey
607
- }, /* @__PURE__ */ n.createElement(et, {
608
- className: "humany-feedback-button",
609
- disabled: !1,
610
- "aria-pressed": !0,
611
- "data-selected": !0,
612
- "data-direction": "vertical",
613
- onClick: () => {
614
- o("action", s.actionKey);
615
- }
616
- }, /* @__PURE__ */ n.createElement(xe, {
617
- faIcon: s.actionKey == "yes" ? "smile-o" : "frown-o"
618
- }), /* @__PURE__ */ n.createElement("span", null, s.label)))
619
- }));
620
- default:
621
- return /* @__PURE__ */ n.createElement(Z, null, /* @__PURE__ */ n.createElement("p", null, "Unknown message type"));
622
- }
623
- }
624
- }))));
625
- }, Ve = l(me)`
626
- & button.humany-form-component-button {
627
- ${(e) => {
628
- var t, r;
629
- return W({
630
- active: !1,
631
- primaryColor: (t = e.theme.colors) == null ? void 0 : t.primary,
632
- secondaryColor: (r = e.theme.colors) == null ? void 0 : r.accent
633
- });
634
- }};
635
- display: block;
636
- width: 100%;
637
- margin-bottom: ${(e) => {
638
- var t;
639
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
640
- }};
641
- }
642
- & button.humany-form-component-submit {
643
- width: 100%;
644
- margin: 0;
645
- :not(:last-child) {
646
- margin-bottom: ${(e) => {
647
- var t;
648
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
649
- }};
650
- }
651
- }
652
- `, re = l(_)`
653
- white-space: pre-wrap;
654
- a {
655
- color: ${(e) => e.theme.colors.link};
656
- &:focus {
657
- ${(e) => {
658
- var t;
659
- return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && x;
660
- }};
661
- }
662
- }
663
- `, oe = l(P)`
664
- padding: 0;
665
- list-style: none;
666
- margin: 0 -${(e) => {
667
- var t;
668
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
669
- }};
670
- > li {
671
- margin: ${(e) => {
672
- var t;
673
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
674
- }};
675
- }
676
- `, ae = l(P)`
677
- padding: 0;
678
- list-style: none;
679
- > li {
680
- margin: ${(e) => {
681
- var t;
682
- return (t = e.theme.sizes) == null ? void 0 : t.small;
683
- }} ${(e) => {
684
- var t;
685
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
686
- }};
687
- margin-left: 0;
688
- display: inline-block;
689
- }
690
- `, Ye = l.button`
691
- ${R};
692
- display: block;
693
- background-color: ${(e) => {
694
- var t;
695
- return (t = e.theme.colors) == null ? void 0 : t.primary;
696
- }};
697
- width: 100%;
698
- color: #fff;
699
- &:focus {
700
- ${(e) => {
701
- var t;
702
- return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && m`
703
- ${x}
704
- background-color: transparent;
705
- `;
706
- }}
707
- }
708
- `, qe = l(P)`
709
- padding: 0;
710
- list-style: none;
711
- > li {
712
- margin-bottom: ${(e) => {
713
- var t;
714
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
715
- }};
716
-
717
- &:last-child {
718
- margin-bottom: 0;
719
- }
720
- }
721
- `, Je = l.button`
722
- display: block;
723
- background-color: transparent;
724
- border: none;
725
- padding: 0;
726
- font-weight: 300;
727
- font-family: inherit;
728
- cursor: pointer;
729
- color: ${(e) => {
730
- var t;
731
- return (t = e.theme.colors) == null ? void 0 : t.primary;
732
- }};
733
-
734
- ${(e) => {
735
- var t, r;
736
- return e.help && m`
737
- color: ${(t = e.theme.colors) == null ? void 0 : t.text};
738
- text-decoration: underline;
739
-
740
- i,
741
- svg {
742
- margin-left: ${(r = e.theme.sizes) == null ? void 0 : r.small};
743
- }
744
- `;
745
- }}
746
- `, Qe = l.button`
747
- ${R};
748
- display: block;
749
- background-color: ${(e) => {
750
- var t;
751
- return (t = e.theme.colors) == null ? void 0 : t.primary;
752
- }};
753
- width: 100%;
754
- color: #fff;
755
- font-family: Lato;
756
- font-size: 1rem;
757
- font-weight: 300;
758
- &:focus {
759
- ${(e) => {
760
- var t;
761
- return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && m`
762
- ${x}
763
- background-color: transparent;
764
- `;
765
- }}
766
- }
767
- `, Xe = l.div`
768
- background-color: #efefef;
769
- height: 1px;
770
- width: 100%;
771
- `, Ze = l.div`
772
- display: flex;
773
- align-items: center;
774
- justify-content: center;
775
- cursor: pointer;
776
-
777
- > i,
778
- svg {
779
- margin-right: ${(e) => {
780
- var t;
781
- return (t = e.theme.sizes) == null ? void 0 : t.small;
782
- }};
783
- }
784
- `, k = l.li`
785
- padding-left: ${(e) => {
786
- var t;
787
- return e.noPadding ? 0 : (t = e.theme.sizes) == null ? void 0 : t.medium;
788
- }};
789
- padding-right: ${(e) => {
790
- var t;
791
- return e.noPadding ? 0 : (t = e.theme.sizes) == null ? void 0 : t.medium;
792
- }};
793
- `, et = l.button`
794
- display: inline-block;
795
- font-size: ${(e) => {
796
- var t;
797
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
798
- }};
799
- background-color: #ffffff !important;
800
- color: ${(e) => {
801
- var t;
802
- return (t = e.theme.colors) == null ? void 0 : t.primary;
803
- }} !important;
804
- border-color: ${(e) => {
805
- var t;
806
- return (t = e.theme.colors) == null ? void 0 : t.primary;
807
- }} !important;
808
- font-weight: 300;
809
- && {
810
- margin-right: ${(e) => {
811
- var t;
812
- return (t = e.theme.sizes) == null ? void 0 : t.small;
813
- }};
814
- }
815
- ${(e) => {
816
- var t, r;
817
- return e["data-direction"] === "horizontal" && m`
818
- width: 225px;
819
- max-width: calc(50% - ${(t = e.theme.sizes) == null ? void 0 : t.large} - ${(r = e.theme.sizes) == null ? void 0 : r.small});
820
- `;
821
- }}
822
- ${(e) => e["data-direction"] === "vertical" && m`
823
- min-width: 150px;
824
- `}
825
- ${(e) => {
826
- var t;
827
- return W({
828
- active: e["data-selected"],
829
- primaryColor: (t = e.theme.colors) == null ? void 0 : t.primary,
830
- secondaryColor: "#FFFFFF"
831
- });
832
- }}
833
- i {
834
- margin: 0 ${(e) => {
835
- var t;
836
- return (t = e.theme.sizes) == null ? void 0 : t.small;
837
- }} 0 0;
838
- color: ${(e) => {
839
- var t;
840
- return (t = e.theme.colors) == null ? void 0 : t.primary;
841
- }} !important;
842
- }
843
- span {
844
- color: ${(e) => {
845
- var t;
846
- return (t = e.theme.colors) == null ? void 0 : t.primary;
847
- }} !important;
848
- }
849
- `, tt = (e) => /* @__PURE__ */ n.createElement(ie, {
850
- attrs: e
851
- }), nt = {
852
- transform: {
853
- img: tt
854
- }
855
- }, rt = ({
856
- className: e,
857
- timestamp: t,
858
- sender: r,
859
- type: o,
860
- content: c
861
- }) => {
862
- U();
863
- const g = (d) => {
864
- let a;
865
- return c.length > 1 && (a = d === 0 ? "first" : d + 1 === c.length ? "last" : "middle"), a;
866
- }, u = () => /* @__PURE__ */ n.createElement(n.Fragment, null, c.map((d) => {
867
- const { key: a, body: i, title: s, form: v, actions: y } = d, $ = !!i && !s && !v && !y;
868
- return /* @__PURE__ */ n.createElement(je, {
869
- className: e,
870
- key: a,
871
- discrete: $,
872
- timestamp: t,
873
- fullWidth: !!v || !!y
874
- }, $ && i ? /* @__PURE__ */ n.createElement(_, {
875
- html: i,
876
- htmlParseInstruction: nt
877
- }) : /* @__PURE__ */ n.createElement(N, {
878
- content: d,
879
- isUser: !1
880
- }));
881
- })), p = () => /* @__PURE__ */ n.createElement(ue, {
882
- sender: r,
883
- timestamp: t,
884
- className: e
885
- }, /* @__PURE__ */ n.createElement(D, null, c.map((d, a) => /* @__PURE__ */ n.createElement(j, {
886
- key: d.key
887
- }, /* @__PURE__ */ n.createElement(N, {
888
- content: d,
889
- isUser: !1,
890
- stacked: g(a)
891
- }))))), b = () => /* @__PURE__ */ n.createElement(_e, {
892
- timestamp: t,
893
- className: e
894
- }, /* @__PURE__ */ n.createElement(D, null, c.map((d, a) => /* @__PURE__ */ n.createElement(j, {
895
- key: d.key
896
- }, /* @__PURE__ */ n.createElement(N, {
897
- content: d,
898
- isUser: !0,
899
- stacked: g(a)
900
- })))));
901
- switch (o) {
902
- case B.System:
903
- return u();
904
- case B.Agent:
905
- return p();
906
- case B.User:
907
- return b();
908
- default:
909
- return null;
910
- }
911
- };
912
- l(me)`
913
- & button.humany-form-component-button {
914
- ${(e) => {
915
- var t, r;
916
- return W({
917
- active: !1,
918
- primaryColor: (t = e.theme.colors) == null ? void 0 : t.primary,
919
- secondaryColor: (r = e.theme.colors) == null ? void 0 : r.accent
920
- });
921
- }};
922
- display: block;
923
- width: 100%;
924
- margin-bottom: ${(e) => {
925
- var t;
926
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
927
- }};
928
- }
929
-
930
- & button.humany-form-component-submit {
931
- width: 100%;
932
- margin: 0;
933
- :not(:last-child) {
934
- margin-bottom: ${(e) => {
935
- var t;
936
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
937
- }};
938
- }
939
- }
940
- `;
941
- l(_)`
942
- white-space: pre-wrap;
943
-
944
- a {
945
- color: ${(e) => e.theme.colors.link};
946
- &:focus {
947
- ${(e) => {
948
- var t;
949
- return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && x;
950
- }};
951
- }
952
- }
953
- `;
954
- l(P)`
955
- padding: 0;
956
- list-style: none;
957
- margin: 0 -${(e) => {
958
- var t;
959
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
960
- }};
961
- > li {
962
- margin: ${(e) => {
963
- var t;
964
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
965
- }};
966
- }
967
- `;
968
- l.button`
969
- ${R};
970
- display: block;
971
- background-color: ${(e) => {
972
- var t;
973
- return (t = e.theme.colors) == null ? void 0 : t.primary;
974
- }};
975
- width: 100%;
976
- color: #fff;
977
- &:focus {
978
- ${(e) => {
979
- var t;
980
- return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && m`
981
- ${x}
982
- background-color: transparent;
983
- `;
984
- }}
985
- }
986
- `;
987
- const pt = ({ className: e }) => {
988
- const t = ze(document.createElement("div")), [r, o] = se(!0), { messages: c, loading: g, typingActors: u } = K(), [p, b] = S(!1), d = Se((i, s = !0) => {
989
- if (i !== null && i.current !== null) {
990
- if (c && c.length === 1 && i.current.focus(), i.current.id.indexOf("typing_") !== -1 && o.current.scrollTopMax - o.current.scrollTop > i.current.clientHeight + 100)
991
- return;
992
- setTimeout(() => {
993
- i.current && i.current.scrollIntoView({
994
- block: "end",
995
- behavior: s ? "smooth" : "auto"
996
- });
997
- }, 0);
998
- }
999
- }, [t]);
1000
- ce(() => {
1001
- p && d(t);
1002
- }, [c, u]), ve(() => {
1003
- b(!0), d(t, !1);
1004
- });
1005
- const a = () => u && u.length ? u.map((i, s) => /* @__PURE__ */ n.createElement(O, {
1006
- id: `typing_${i.name}`,
1007
- ref: u.length ? t : null,
1008
- key: `typing_${i.name}`
1009
- }, /* @__PURE__ */ n.createElement(ue, {
1010
- timestamp: Date.now(),
1011
- sender: i
1012
- }, /* @__PURE__ */ n.createElement(ee, null)))) : null;
1013
- return /* @__PURE__ */ n.createElement(ot, {
1014
- className: T(e, "humany-conversation-component")
1015
- }, /* @__PURE__ */ n.createElement(at, {
1016
- tabIndex: 0,
1017
- scrollableCss: r,
1018
- ref: o
1019
- }, c && c.length ? c.map((i, s) => {
1020
- const { type: v, timestamp: y, sender: $, content: f } = i;
1021
- return /* @__PURE__ */ n.createElement(O, {
1022
- className: "humany-conversation-entry",
1023
- tabIndex: -1,
1024
- key: `${v}_${$ == null ? void 0 : $.name}_${y}_${f[0].key}`,
1025
- ref: s + 1 < c.length || u.length ? null : t
1026
- }, /* @__PURE__ */ n.createElement(rt, z({}, i)));
1027
- }) : null, a(), g && /* @__PURE__ */ n.createElement(O, null, /* @__PURE__ */ n.createElement(ee, null))), /* @__PURE__ */ n.createElement(Le, null));
1028
- }, ot = l.div`
1029
- position: absolute;
1030
- right: 0;
1031
- left: 0;
1032
- bottom: 0;
1033
- top: 0;
1034
- overflow: hidden;
1035
- display: flex;
1036
- flex-direction: column;
1037
- `, at = l.div`
1038
- display: flex;
1039
- flex-direction: column;
1040
- align-items: stretch;
1041
- flex: 0 1 100%;
1042
- padding: 0 ${(e) => {
1043
- var t;
1044
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1045
- }};
1046
- ${(e) => !!e.scrollableCss && e.scrollableCss};
1047
- &:focus {
1048
- ${(e) => {
1049
- var t;
1050
- return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && x;
1051
- }};
1052
- }
1053
- `, O = l.div`
1054
- margin: 0;
1055
- margin-bottom: ${(e) => {
1056
- var t;
1057
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1058
- }};
1059
-
1060
- &:first-of-type {
1061
- margin-top: ${(e) => {
1062
- var t;
1063
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1064
- }};
1065
- }
1066
-
1067
- &:last-of-type {
1068
- padding-bottom: ${(e) => {
1069
- var t;
1070
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1071
- }};
1072
- }
1073
-
1074
- * {
1075
- font-size: ${(e) => {
1076
- var t;
1077
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
1078
- }};
1079
- }
1080
-
1081
- & span,
1082
- p,
1083
- a,
1084
- div {
1085
- font-weight: 300;
1086
- }
1087
-
1088
- & b,
1089
- h1 {
1090
- font-weight: normal;
1091
- }
1092
-
1093
- ${we("h1", m`
1094
- font-weight: normal;
1095
- `)}
1096
- `;
1097
- export {
1098
- pt as default
1099
- };
1100
- //# sourceMappingURL=conversation.3981560b.js.map