@progress/kendo-react-conversational-ui 6.1.1 → 7.0.0-develop.2

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 (109) hide show
  1. package/{dist/npm/ChatPropsAndState.d.ts → ChatPropsAndState.d.ts} +5 -2
  2. package/{dist/npm/Events.d.ts → Events.d.ts} +5 -1
  3. package/LICENSE.md +1 -1
  4. package/{dist/es/ViewItem.d.ts → ViewItem.d.ts} +6 -2
  5. package/{dist/npm/api → api}/action.interface.d.ts +5 -1
  6. package/{dist/es/api → api}/attachment.interface.d.ts +5 -1
  7. package/{dist/npm/api → api}/message.interface.d.ts +4 -0
  8. package/{dist/es/api → api}/user.interface.d.ts +4 -0
  9. package/{dist/npm/components → components}/Action.d.ts +6 -3
  10. package/{dist/npm/components → components}/ActionGroup.d.ts +5 -2
  11. package/{dist/npm/components → components}/Attachment.d.ts +6 -3
  12. package/{dist/npm/components → components}/AttachmentGroup.d.ts +5 -2
  13. package/{dist/es/components → components}/Chat.d.ts +6 -2
  14. package/{dist/npm/components → components}/ChatMessage.d.ts +5 -1
  15. package/components/DateMarker.d.ts +18 -0
  16. package/{dist/npm/components → components}/MessageGroup.d.ts +6 -2
  17. package/{dist/npm/components → components}/NewMessage.d.ts +6 -2
  18. package/components/Toolbar.d.ts +13 -0
  19. package/{dist/npm/components → components}/base/FocusableUponSelection.d.ts +4 -0
  20. package/{dist/es/components → components}/base/SelectableItemsContainer.d.ts +4 -0
  21. package/{dist/npm/components → components}/templates/HeroCard.d.ts +6 -2
  22. package/dist/cdn/js/kendo-react-conversational-ui.js +5 -1
  23. package/index.d.ts +15 -0
  24. package/index.js +5 -0
  25. package/index.mjs +671 -0
  26. package/{dist/npm/messages → messages}/index.d.ts +4 -0
  27. package/package-metadata.d.ts +9 -0
  28. package/package.json +29 -39
  29. package/utils.d.ts +9 -0
  30. package/about.md +0 -3
  31. package/dist/es/ChatPropsAndState.d.ts +0 -92
  32. package/dist/es/ChatPropsAndState.js +0 -1
  33. package/dist/es/Events.d.ts +0 -38
  34. package/dist/es/Events.js +0 -1
  35. package/dist/es/ViewItem.js +0 -90
  36. package/dist/es/api/action.interface.d.ts +0 -31
  37. package/dist/es/api/action.interface.js +0 -1
  38. package/dist/es/api/attachment.interface.js +0 -1
  39. package/dist/es/api/message.interface.d.ts +0 -56
  40. package/dist/es/api/message.interface.js +0 -1
  41. package/dist/es/api/user.interface.js +0 -1
  42. package/dist/es/components/Action.d.ts +0 -20
  43. package/dist/es/components/Action.js +0 -43
  44. package/dist/es/components/ActionGroup.d.ts +0 -24
  45. package/dist/es/components/ActionGroup.js +0 -40
  46. package/dist/es/components/Attachment.d.ts +0 -25
  47. package/dist/es/components/Attachment.js +0 -68
  48. package/dist/es/components/AttachmentGroup.d.ts +0 -24
  49. package/dist/es/components/AttachmentGroup.js +0 -92
  50. package/dist/es/components/Chat.js +0 -210
  51. package/dist/es/components/ChatMessage.d.ts +0 -68
  52. package/dist/es/components/ChatMessage.js +0 -83
  53. package/dist/es/components/DateMarker.d.ts +0 -14
  54. package/dist/es/components/DateMarker.js +0 -33
  55. package/dist/es/components/MessageGroup.d.ts +0 -25
  56. package/dist/es/components/MessageGroup.js +0 -61
  57. package/dist/es/components/NewMessage.d.ts +0 -34
  58. package/dist/es/components/NewMessage.js +0 -81
  59. package/dist/es/components/Toolbar.d.ts +0 -9
  60. package/dist/es/components/Toolbar.js +0 -31
  61. package/dist/es/components/base/FocusableUponSelection.d.ts +0 -20
  62. package/dist/es/components/base/FocusableUponSelection.js +0 -35
  63. package/dist/es/components/base/SelectableItemsContainer.js +0 -113
  64. package/dist/es/components/templates/HeroCard.d.ts +0 -41
  65. package/dist/es/components/templates/HeroCard.js +0 -64
  66. package/dist/es/main.d.ts +0 -11
  67. package/dist/es/main.js +0 -10
  68. package/dist/es/messages/index.d.ts +0 -30
  69. package/dist/es/messages/index.js +0 -31
  70. package/dist/es/package-metadata.d.ts +0 -5
  71. package/dist/es/package-metadata.js +0 -11
  72. package/dist/es/utils.d.ts +0 -5
  73. package/dist/es/utils.js +0 -6
  74. package/dist/npm/ChatPropsAndState.js +0 -2
  75. package/dist/npm/Events.js +0 -2
  76. package/dist/npm/ViewItem.d.ts +0 -57
  77. package/dist/npm/ViewItem.js +0 -94
  78. package/dist/npm/api/action.interface.js +0 -2
  79. package/dist/npm/api/attachment.interface.d.ts +0 -32
  80. package/dist/npm/api/attachment.interface.js +0 -2
  81. package/dist/npm/api/message.interface.js +0 -2
  82. package/dist/npm/api/user.interface.d.ts +0 -23
  83. package/dist/npm/api/user.interface.js +0 -2
  84. package/dist/npm/components/Action.js +0 -45
  85. package/dist/npm/components/ActionGroup.js +0 -42
  86. package/dist/npm/components/Attachment.js +0 -70
  87. package/dist/npm/components/AttachmentGroup.js +0 -94
  88. package/dist/npm/components/Chat.d.ts +0 -72
  89. package/dist/npm/components/Chat.js +0 -213
  90. package/dist/npm/components/ChatMessage.js +0 -86
  91. package/dist/npm/components/DateMarker.d.ts +0 -14
  92. package/dist/npm/components/DateMarker.js +0 -35
  93. package/dist/npm/components/MessageGroup.js +0 -63
  94. package/dist/npm/components/NewMessage.js +0 -83
  95. package/dist/npm/components/Toolbar.d.ts +0 -9
  96. package/dist/npm/components/Toolbar.js +0 -33
  97. package/dist/npm/components/base/FocusableUponSelection.js +0 -38
  98. package/dist/npm/components/base/SelectableItemsContainer.d.ts +0 -33
  99. package/dist/npm/components/base/SelectableItemsContainer.js +0 -116
  100. package/dist/npm/components/templates/HeroCard.js +0 -67
  101. package/dist/npm/main.d.ts +0 -11
  102. package/dist/npm/main.js +0 -27
  103. package/dist/npm/messages/index.js +0 -34
  104. package/dist/npm/package-metadata.d.ts +0 -5
  105. package/dist/npm/package-metadata.js +0 -14
  106. package/dist/npm/utils.d.ts +0 -5
  107. package/dist/npm/utils.js +0 -10
  108. package/dist/systemjs/kendo-react-conversational-ui.js +0 -1
  109. package/e2e-next/conversationalui.basic.tests.ts +0 -24
package/index.mjs ADDED
@@ -0,0 +1,671 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as s from "react";
6
+ import { classNames as l, Keys as r, dispatchEvent as m, validatePackage as D } from "@progress/kendo-react-common";
7
+ import { provideIntlService as C, registerForIntl as w, provideLocalizationService as y } from "@progress/kendo-react-intl";
8
+ import * as a from "prop-types";
9
+ import { chevronLeftIcon as M, chevronRightIcon as B, paperPlaneIcon as R, moreHorizontalIcon as F } from "@progress/kendo-svg-icons";
10
+ import { Button as c } from "@progress/kendo-react-buttons";
11
+ import { Avatar as V } from "@progress/kendo-react-layout";
12
+ class E extends s.Component {
13
+ /**
14
+ * @hidden
15
+ */
16
+ componentDidUpdate(e) {
17
+ !e.selected && this.props.selected && this.elementToFocus.focus();
18
+ }
19
+ }
20
+ class x extends E {
21
+ /**
22
+ * @hidden
23
+ */
24
+ render() {
25
+ return /* @__PURE__ */ s.createElement(
26
+ "div",
27
+ {
28
+ className: this.getClassNames(),
29
+ tabIndex: this.props.tabIndex,
30
+ onClick: () => this.props.onRequestSelection(this.props.item.selectionIndex),
31
+ onFocus: () => this.props.onRequestSelection(this.props.item.selectionIndex),
32
+ ref: (e) => this.elementToFocus = e
33
+ },
34
+ this.getTimestampView(),
35
+ this.getMainView(),
36
+ this.getStatusView()
37
+ );
38
+ }
39
+ getMainView() {
40
+ return this.props.item.typing ? /* @__PURE__ */ s.createElement("div", { className: "k-chat-bubble" }, /* @__PURE__ */ s.createElement("div", { className: "k-typing-indicator" }, /* @__PURE__ */ s.createElement("span", null), /* @__PURE__ */ s.createElement("span", null), /* @__PURE__ */ s.createElement("span", null))) : this.props.template ? /* @__PURE__ */ s.createElement(this.props.template, { item: this.props.item }) : this.props.item.text ? /* @__PURE__ */ s.createElement("div", { className: "k-chat-bubble" }, this.props.item.text) : null;
41
+ }
42
+ getTimestampView() {
43
+ let e = null;
44
+ return this.props.item.timestamp && (e = /* @__PURE__ */ s.createElement("time", { className: "k-message-time", "aria-hidden": !this.props.selected }, C(this).formatDate(this.props.item.timestamp, this.props.dateFormat))), e;
45
+ }
46
+ getStatusView() {
47
+ let e = null;
48
+ return this.props.item.status && (e = /* @__PURE__ */ s.createElement("span", { className: "k-message-status" }, this.props.item.status)), e;
49
+ }
50
+ getClassNames() {
51
+ return l(
52
+ { "k-only": this.props.isOnlyItemInGroup },
53
+ { "k-first": this.props.isFirstItemInGroup && !this.props.isOnlyItemInGroup },
54
+ { "k-last": this.props.isLastItemInGroup && !this.props.isOnlyItemInGroup },
55
+ { "k-selected": this.props.selected },
56
+ { "k-focus": this.props.selected },
57
+ "k-message"
58
+ );
59
+ }
60
+ }
61
+ x.defaultProps = {
62
+ dateFormat: "g",
63
+ tabIndex: -1
64
+ };
65
+ w(x);
66
+ const b = (i, e) => i && e.author && i.id === e.author.id, u = (i) => i[i.length - 1], G = (i, e) => i && e && (e.getDate() !== i.getDate() || e.getMonth() !== i.getMonth() || e.getFullYear() !== i.getFullYear()), A = (i, e) => {
67
+ const t = e.timestamp, o = u(i);
68
+ if (t && (!o || G(t, o.timestamp))) {
69
+ const n = {
70
+ type: "date-marker",
71
+ timestamp: t,
72
+ trackBy: t.getTime()
73
+ };
74
+ i.push(n);
75
+ }
76
+ }, K = (i, e, t) => {
77
+ const o = u(i);
78
+ let n;
79
+ e.typing && !t || (o && o.type === "message-group" && (n = o.messages), n && b(e.author, u(n)) ? n.push(e) : i.push({
80
+ type: "message-group",
81
+ messages: [e],
82
+ author: e.author,
83
+ timestamp: e.timestamp,
84
+ trackBy: e
85
+ }));
86
+ }, q = (i) => (e, t, o) => {
87
+ const n = o === i - 1;
88
+ return A(e, t), K(e, t, n), t.attachments && t.attachments.length > 1 && e.push({
89
+ type: "attachment-group",
90
+ attachments: t.attachments,
91
+ attachmentLayout: t.attachmentLayout,
92
+ timestamp: t.timestamp,
93
+ trackBy: t
94
+ }), t.suggestedActions && n && e.push({
95
+ type: "action-group",
96
+ actions: t.suggestedActions,
97
+ timestamp: t.timestamp,
98
+ trackBy: t
99
+ }), e;
100
+ };
101
+ function O(i) {
102
+ let e = 0;
103
+ i.forEach((t) => {
104
+ t.type === "message-group" ? t.messages.forEach((o) => {
105
+ o.selectionIndex = e++;
106
+ }) : (t.type === "attachment-group" || t.type === "action-group") && (t.selectionIndex = e++);
107
+ }), i.lastSelectionIndex = e - 1;
108
+ }
109
+ const W = (i) => {
110
+ const t = i.slice().reduce(q(i.length), []);
111
+ return O(t), t;
112
+ };
113
+ class U extends E {
114
+ constructor() {
115
+ super(...arguments), this.onKeyDown = (e) => {
116
+ e.keyCode === r.enter && this.props.onActionExecute(this.props.item, e);
117
+ };
118
+ }
119
+ render() {
120
+ return /* @__PURE__ */ s.createElement(
121
+ "span",
122
+ {
123
+ role: "button",
124
+ className: this.getClassNames(),
125
+ onClick: (e) => this.props.onActionExecute(this.props.item, e),
126
+ ref: (e) => this.elementToFocus = e,
127
+ onKeyDown: this.onKeyDown,
128
+ tabIndex: 0
129
+ },
130
+ this.props.item.title || this.props.item.value
131
+ );
132
+ }
133
+ getClassNames() {
134
+ return l(
135
+ "k-quick-reply",
136
+ { "k-first": this.props.isFirstItemInGroup },
137
+ { "k-last": this.props.isLastItemInGroup },
138
+ { "k-selected": this.props.selected },
139
+ { "k-focus": this.props.selected }
140
+ );
141
+ }
142
+ }
143
+ class S extends s.Component {
144
+ constructor() {
145
+ super(...arguments), this.state = { selectedItemIndex: null }, this.onRequestContainerSelection = () => this.props.onRequestSelection(this.props.group.selectionIndex), this.onKeyDown = (e) => {
146
+ let t = null, o, n;
147
+ this.isKeyboardNavigationLeftRight ? (o = r.left, n = r.right) : (o = r.up, n = r.down), e.keyCode === o ? t = this.navigate(!1) : e.keyCode === n && (t = this.navigate(!0)), t !== null && (e.preventDefault(), e.stopPropagation());
148
+ };
149
+ }
150
+ static getDerivedStateFromProps(e, t) {
151
+ return !e.selected && t.selectedItemIndex !== null ? { selectedItemIndex: null } : e.selected && t.selectedItemIndex === null ? { selectedItemIndex: 0 } : null;
152
+ }
153
+ navigate(e, t = 0) {
154
+ let o = null, n = this.state.selectedItemIndex;
155
+ return e ? n === null ? o = t : n < this.getLastSelectionIndex() && (o = n + 1) : n === null ? o = 0 : n > 0 && (o = n - 1), o !== null && this.setState({ selectedItemIndex: o }), o;
156
+ }
157
+ get isKeyboardNavigationLeftRight() {
158
+ return !0;
159
+ }
160
+ getLastSelectionIndex() {
161
+ let e = -1;
162
+ if (this.props.group.type === "action-group") {
163
+ const t = this.props.group;
164
+ e = t.actions ? t.actions.length - 1 : -1;
165
+ } else if (this.props.group.type === "attachment-group") {
166
+ const t = this.props.group;
167
+ e = t.attachments ? t.attachments.length - 1 : -1;
168
+ }
169
+ return e;
170
+ }
171
+ }
172
+ class P extends S {
173
+ constructor(e) {
174
+ super(e);
175
+ }
176
+ render() {
177
+ const e = this.props.group.actions ? this.props.group.actions.length - 1 : 0;
178
+ return /* @__PURE__ */ s.createElement(
179
+ "div",
180
+ {
181
+ className: this.getClassNames(),
182
+ onClick: this.onRequestContainerSelection,
183
+ onKeyDown: this.onKeyDown
184
+ },
185
+ this.props.group.actions && this.props.group.actions.map(
186
+ (t, o) => /* @__PURE__ */ s.createElement(
187
+ U,
188
+ {
189
+ item: t,
190
+ onActionExecute: this.props.onActionExecute,
191
+ selected: o === this.state.selectedItemIndex,
192
+ isFirstItemInGroup: o === 0,
193
+ isLastItemInGroup: o === e,
194
+ key: o
195
+ }
196
+ )
197
+ )
198
+ );
199
+ }
200
+ getClassNames() {
201
+ return l(
202
+ "k-quick-replies"
203
+ );
204
+ }
205
+ }
206
+ class T extends E {
207
+ render() {
208
+ return /* @__PURE__ */ s.createElement(
209
+ "div",
210
+ {
211
+ className: this.getClassNames(),
212
+ tabIndex: this.getTabIndexValue(),
213
+ onClick: this.props.onClick,
214
+ ref: (e) => this.elementToFocus = e
215
+ },
216
+ this.props.template ? /* @__PURE__ */ s.createElement(this.props.template, { item: this.props.item }) : /* @__PURE__ */ s.createElement("div", { className: "k-card" }, /* @__PURE__ */ s.createElement("div", { className: "k-card-body" }, this.getTitleView(), this.getSubtitleView(), this.getContentView()))
217
+ );
218
+ }
219
+ getTabIndexValue() {
220
+ if (this.props.tabbable !== void 0)
221
+ return this.props.tabbable ? 0 : -1;
222
+ }
223
+ getClassNames() {
224
+ return l(
225
+ { "k-selected": this.props.selected },
226
+ { "k-focus": this.props.selected },
227
+ { "k-first": this.props.isFirstItemInGroup },
228
+ { "k-last": this.props.isLastItemInGroup }
229
+ );
230
+ }
231
+ getTitleView() {
232
+ return this.props.item.title ? /* @__PURE__ */ s.createElement("h5", { className: "k-card-title" }, this.props.item.title) : null;
233
+ }
234
+ getSubtitleView() {
235
+ return this.props.item.subtitle ? /* @__PURE__ */ s.createElement("h6", { className: "k-card-subtitle" }, this.props.item.subtitle) : null;
236
+ }
237
+ getContentView() {
238
+ return this.props.item.contentType.indexOf("image/") === 0 ? /* @__PURE__ */ s.createElement("img", { src: this.props.item.content }) : this.props.item.content;
239
+ }
240
+ }
241
+ class z extends S {
242
+ render() {
243
+ const e = this.isCardDeckLayout(this.props), t = /* @__PURE__ */ s.createElement(
244
+ "div",
245
+ {
246
+ className: this.getClassNames(),
247
+ onKeyDown: e ? void 0 : this.onKeyDown
248
+ },
249
+ this.props.group.attachments.map((o, n) => /* @__PURE__ */ s.createElement(
250
+ T,
251
+ {
252
+ item: o,
253
+ template: this.props.itemTemplate,
254
+ selected: n === this.state.selectedItemIndex,
255
+ tabbable: this.props.isLastGroup && n === this.state.selectedItemIndex,
256
+ isFirstItemInGroup: n === 0,
257
+ isLastItemInGroup: n === this.getLastItemIndex(),
258
+ onClick: () => this.onAttachmentClick(n),
259
+ key: n
260
+ }
261
+ ))
262
+ );
263
+ return e ? /* @__PURE__ */ s.createElement("div", { className: "k-card-deck-scrollwrap", onKeyDown: this.onKeyDown }, this.getLeftScrollBtn(), t, this.getRightScrollBtn()) : t;
264
+ }
265
+ // Overriding the default navigation.
266
+ get isKeyboardNavigationLeftRight() {
267
+ return this.isCardDeckLayout(this.props);
268
+ }
269
+ getLastItemIndex() {
270
+ return this.props.group.attachments.length - 1;
271
+ }
272
+ getLeftScrollBtn() {
273
+ let e = null;
274
+ return this.isCardDeckLayout(this.props) && this.state.selectedItemIndex && (e = /* @__PURE__ */ s.createElement(c, { icon: "chevron-left", onClick: () => this.onNavigateBtnClick(!1), svgIcon: M })), e;
275
+ }
276
+ getRightScrollBtn() {
277
+ let e = null;
278
+ return this.isCardDeckLayout(this.props) && this.state.selectedItemIndex !== this.getLastItemIndex() && (e = /* @__PURE__ */ s.createElement(c, { icon: "chevron-right", onClick: () => this.onNavigateBtnClick(!0), svgIcon: B })), e;
279
+ }
280
+ onAttachmentClick(e) {
281
+ this.onRequestContainerSelection(), this.setState({ selectedItemIndex: e });
282
+ }
283
+ onNavigateBtnClick(e) {
284
+ this.onRequestContainerSelection(), this.navigate(e, 1);
285
+ }
286
+ isCardDeckLayout(e) {
287
+ return e.group.attachmentLayout !== "list";
288
+ }
289
+ getClassNames() {
290
+ return l(
291
+ {
292
+ "k-card-list": this.props.group.attachmentLayout,
293
+ "k-card-deck": this.isCardDeckLayout(this.props)
294
+ }
295
+ );
296
+ }
297
+ }
298
+ class v extends s.Component {
299
+ render() {
300
+ const e = this.props.item;
301
+ return /* @__PURE__ */ s.createElement("div", { className: "k-timestamp" }, C(this).formatDate(e.timestamp, "D"));
302
+ }
303
+ }
304
+ w(v);
305
+ const d = "newMessage.sendButton", g = "newMessage.optionsButton", I = "newMessage.messageInput", f = "avatar.alt", k = "messageList.ariaLabel", p = {
306
+ [d]: "Send",
307
+ [g]: "Options",
308
+ [I]: "Message",
309
+ [f]: "Avatar",
310
+ [k]: "Message list"
311
+ };
312
+ class H extends s.Component {
313
+ render() {
314
+ const { avatarUrl: e, avatarAltText: t, name: o } = this.props.group.author, n = y(this);
315
+ return /* @__PURE__ */ s.createElement("div", { className: this.getMsgGroupClassNames() }, o && /* @__PURE__ */ s.createElement("p", { className: "k-author" }, o), e && /* @__PURE__ */ s.createElement(V, { type: "image" }, /* @__PURE__ */ s.createElement(
316
+ "img",
317
+ {
318
+ src: e,
319
+ alt: t !== void 0 ? t : n.toLanguageString(f, p[f])
320
+ }
321
+ )), this.getGroupMessagesView());
322
+ }
323
+ getMsgGroupClassNames() {
324
+ return l(
325
+ "k-message-group",
326
+ {
327
+ "k-no-avatar": !this.props.group.author.avatarUrl,
328
+ "k-alt": b(this.props.user, this.props.group.messages[0])
329
+ }
330
+ );
331
+ }
332
+ getGroupMessagesView() {
333
+ const e = this.props.group.messages.length - 1;
334
+ return this.props.group.messages.map((t, o) => {
335
+ const n = [/* @__PURE__ */ s.createElement(
336
+ this.props.message,
337
+ {
338
+ item: t,
339
+ template: this.props.itemTemplate,
340
+ selected: t.selectionIndex === this.props.selectedItemIndex,
341
+ onRequestSelection: this.props.onRequestSelection,
342
+ tabIndex: o === e && this.props.isLastGroup ? 0 : -1,
343
+ isFirstItemInGroup: o === 0,
344
+ isLastItemInGroup: o === e,
345
+ isOnlyItemInGroup: e === 0,
346
+ key: o
347
+ }
348
+ )];
349
+ return t.attachments && t.attachments.length === 1 && n.push(
350
+ /* @__PURE__ */ s.createElement(
351
+ T,
352
+ {
353
+ item: t.attachments[0],
354
+ template: this.props.attachmentTemplate,
355
+ selected: !1,
356
+ key: `att-${o}`
357
+ }
358
+ )
359
+ ), n;
360
+ });
361
+ }
362
+ }
363
+ class j extends s.Component {
364
+ render() {
365
+ return /* @__PURE__ */ s.createElement("div", { className: "k-toolbar-box" }, /* @__PURE__ */ s.createElement("div", { className: "k-button-list" }, this.props.children));
366
+ }
367
+ }
368
+ class Y extends s.Component {
369
+ constructor() {
370
+ super(...arguments), this.state = { focused: !1 }, this.inputEl = null, this.onInputKeyDown = (e) => {
371
+ e.keyCode === r.enter && this.sendMessage(e);
372
+ }, this.sendMessage = (e) => {
373
+ if (this.props.onMessageSend && this.inputEl !== null) {
374
+ const t = this.inputEl.value;
375
+ if (t) {
376
+ const o = {
377
+ author: this.props.user,
378
+ text: t,
379
+ timestamp: /* @__PURE__ */ new Date()
380
+ };
381
+ this.props.onMessageSend(o, e);
382
+ }
383
+ }
384
+ this.inputEl !== null && (this.inputEl.value = null);
385
+ };
386
+ }
387
+ render() {
388
+ const e = y(this), t = /* @__PURE__ */ s.createElement(
389
+ "input",
390
+ {
391
+ type: "text",
392
+ className: this.getClassNames(),
393
+ placeholder: this.props.placeholder,
394
+ onKeyDown: this.onInputKeyDown,
395
+ onFocus: () => this.setState({ focused: !0 }),
396
+ onBlur: () => this.setState({ focused: !1 }),
397
+ ref: (h) => this.inputEl = h,
398
+ "aria-label": e.toLanguageString(I, p[I])
399
+ }
400
+ ), o = /* @__PURE__ */ s.createElement(
401
+ c,
402
+ {
403
+ fillMode: "flat",
404
+ themeColor: "base",
405
+ className: "k-chat-send",
406
+ icon: "paper-plane",
407
+ svgIcon: R,
408
+ onClick: this.sendMessage,
409
+ "aria-label": e.toLanguageString(d, p[d]),
410
+ dir: this.props.isDirectionRightToLeft ? "rtl" : void 0
411
+ }
412
+ ), n = /* @__PURE__ */ s.createElement(
413
+ c,
414
+ {
415
+ fillMode: "flat",
416
+ themeColor: "base",
417
+ rounded: null,
418
+ className: "k-button-toggle",
419
+ icon: "more-horizontal",
420
+ svgIcon: F,
421
+ onClick: (h) => this.props.onToolbarActionButtonClick(!this.props.showToolbar, h),
422
+ "aria-label": e.toLanguageString(g, p[g])
423
+ }
424
+ );
425
+ return /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("span", { className: "k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid" }, this.props.MessageBox ? /* @__PURE__ */ s.createElement(
426
+ this.props.MessageBox,
427
+ {
428
+ messageInput: t,
429
+ sendButton: o,
430
+ toolbarButton: n
431
+ }
432
+ ) : /* @__PURE__ */ s.createElement(s.Fragment, null, t, /* @__PURE__ */ s.createElement("span", { className: "k-input-suffix" }, this.props.toolbar && n, o))), this.props.showToolbar && /* @__PURE__ */ s.createElement(j, null, this.props.toolbar));
433
+ }
434
+ focusInput() {
435
+ this.inputEl !== null && this.inputEl.focus();
436
+ }
437
+ getClassNames() {
438
+ return l(
439
+ "k-input-inner",
440
+ { "k-focus": this.state.focused }
441
+ );
442
+ }
443
+ }
444
+ const _ = {
445
+ name: "@progress/kendo-react-conversational-ui",
446
+ productName: "KendoReact",
447
+ productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
448
+ publishDate: 1700573602,
449
+ version: "",
450
+ licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
451
+ }, N = class extends s.Component {
452
+ constructor(i) {
453
+ super(i), this.viewItems = [], this.isDirectionRightToLeft = !1, this.scrollToBottomOnLoadingData = !0, this.onFocus = () => {
454
+ clearTimeout(this.timeoutIdForChatLosingFocus);
455
+ }, this.onBlur = () => {
456
+ this.timeoutIdForChatLosingFocus = window.setTimeout(() => {
457
+ this.setState({ selectedItemIndex: null });
458
+ }, 0);
459
+ }, this.onSelectionRequested = (e) => {
460
+ this.setState({ selectedItemIndex: e });
461
+ }, this.onKeyDown = (e) => {
462
+ let t = null, o = this.state.selectedItemIndex !== null ? this.state.selectedItemIndex : this.viewItems.lastSelectionIndex;
463
+ e.keyCode === r.up ? o === null ? t = 0 : o > 0 && (t = o - 1) : e.keyCode === r.down && (o === null ? t = 0 : o < this.viewItems.lastSelectionIndex && (t = o + 1)), t !== null && (this.setState({ selectedItemIndex: t }), e.preventDefault());
464
+ }, this.onMessageSend = (e, t) => {
465
+ m(this.props.onMessageSend, t, this, { message: e });
466
+ }, this.onActionExecute = (e, t) => {
467
+ if (m(this.props.onActionExecute, t, this, { action: e }), !t.isDefaultPrevented()) {
468
+ switch (e.type) {
469
+ case "reply":
470
+ this.onMessageSend(
471
+ {
472
+ author: this.props.user,
473
+ text: e.value,
474
+ timestamp: /* @__PURE__ */ new Date()
475
+ },
476
+ t
477
+ );
478
+ break;
479
+ case "call":
480
+ window.open("tel:" + e.value);
481
+ break;
482
+ case "openUrl":
483
+ window.open(e.value);
484
+ break;
485
+ }
486
+ this.newMsgComp.focusInput();
487
+ }
488
+ }, D(_), this.state = { selectedItemIndex: null, isFirstRender: !0 };
489
+ }
490
+ /**
491
+ * @hidden
492
+ */
493
+ render() {
494
+ this.viewItems = this.getViewItemsFromMsgs(this.props.messages), this.isDirectionRightToLeft = this.checkIsDirectionRightToLeft(this.props);
495
+ const i = y(this);
496
+ return /* @__PURE__ */ s.createElement(
497
+ "div",
498
+ {
499
+ style: { width: this.props.width },
500
+ onKeyDown: this.onKeyDown,
501
+ className: this.getClassNames(),
502
+ ref: (e) => this.chatWrapperEl = e
503
+ },
504
+ /* @__PURE__ */ s.createElement(
505
+ "div",
506
+ {
507
+ className: "k-message-list k-avatars",
508
+ onBlur: this.onBlur,
509
+ onFocus: this.onFocus,
510
+ role: "log",
511
+ "aria-label": i.toLanguageString(k, p[k]),
512
+ "aria-live": "polite",
513
+ onScroll: (e) => {
514
+ this.scrollToBottomOnLoadingData = e.currentTarget.scrollTop === e.currentTarget.scrollHeight - e.currentTarget.clientHeight;
515
+ },
516
+ ref: (e) => this.viewItemsWrapperEl = e
517
+ },
518
+ /* @__PURE__ */ s.createElement("div", { className: "k-message-list-content" }, this.renderViewItems())
519
+ ),
520
+ /* @__PURE__ */ s.createElement(
521
+ Y,
522
+ {
523
+ user: this.props.user,
524
+ onMessageSend: this.onMessageSend,
525
+ isDirectionRightToLeft: this.isDirectionRightToLeft,
526
+ ref: (e) => this.newMsgComp = e,
527
+ placeholder: this.props.placeholder,
528
+ MessageBox: this.props.messageBox,
529
+ toolbar: this.props.toolbar,
530
+ onToolbarActionButtonClick: this.props.onToolbarActionExecute,
531
+ showToolbar: this.props.showToolbar
532
+ }
533
+ )
534
+ );
535
+ }
536
+ /**
537
+ * @hidden
538
+ */
539
+ componentDidMount() {
540
+ this.setState({ isFirstRender: !1 }, () => {
541
+ this.nextTickId = window.setTimeout(() => this.scrollViewItemsToBottom(), 250);
542
+ });
543
+ }
544
+ /**
545
+ * @hidden
546
+ */
547
+ componentWillUnmount() {
548
+ clearTimeout(this.nextTickId);
549
+ }
550
+ /**
551
+ * @hidden
552
+ */
553
+ componentDidUpdate(i) {
554
+ i.messages.length !== this.props.messages.length && this.scrollToBottomOnLoadingData && this.scrollViewItemsToBottom();
555
+ }
556
+ getClassNames() {
557
+ return l(
558
+ "k-chat",
559
+ this.props.className,
560
+ { "k-rtl": this.isDirectionRightToLeft }
561
+ );
562
+ }
563
+ checkIsDirectionRightToLeft(i) {
564
+ return !!(i.dir !== void 0 ? i.dir === "rtl" : this.chatWrapperEl && getComputedStyle(this.chatWrapperEl).direction === "rtl");
565
+ }
566
+ renderViewItems() {
567
+ const i = this.viewItems.length - 1;
568
+ return this.viewItems.map((e, t) => {
569
+ if (e.type === "date-marker")
570
+ return /* @__PURE__ */ s.createElement(v, { item: e, key: t });
571
+ if (e.type === "message-group")
572
+ return /* @__PURE__ */ s.createElement(
573
+ H,
574
+ {
575
+ group: e,
576
+ itemTemplate: this.props.messageTemplate,
577
+ attachmentTemplate: this.props.attachmentTemplate,
578
+ user: this.props.user,
579
+ selectedItemIndex: this.state.selectedItemIndex,
580
+ onRequestSelection: this.onSelectionRequested,
581
+ isLastGroup: t === i,
582
+ key: t,
583
+ message: this.props.message || N.defaultProps.message
584
+ }
585
+ );
586
+ if (e.type === "attachment-group")
587
+ return /* @__PURE__ */ s.createElement(
588
+ z,
589
+ {
590
+ group: e,
591
+ itemTemplate: this.props.attachmentTemplate,
592
+ onRequestSelection: this.onSelectionRequested,
593
+ selected: e.selectionIndex === this.state.selectedItemIndex,
594
+ isLastGroup: t === i,
595
+ key: t
596
+ }
597
+ );
598
+ if (e.type === "action-group")
599
+ return /* @__PURE__ */ s.createElement(
600
+ P,
601
+ {
602
+ group: e,
603
+ onActionExecute: this.onActionExecute,
604
+ onRequestSelection: this.onSelectionRequested,
605
+ selected: e.selectionIndex === this.state.selectedItemIndex,
606
+ isLastGroup: t === i,
607
+ key: t
608
+ }
609
+ );
610
+ });
611
+ }
612
+ scrollViewItemsToBottom() {
613
+ this.viewItemsWrapperEl && (this.viewItemsWrapperEl.scrollTop = this.viewItemsWrapperEl.scrollHeight - this.viewItemsWrapperEl.clientHeight);
614
+ }
615
+ getViewItemsFromMsgs(i) {
616
+ return i.length > 0 ? W(i) : [];
617
+ }
618
+ };
619
+ let L = N;
620
+ L.propTypes = {
621
+ messages: a.arrayOf(a.object),
622
+ user: a.object,
623
+ messageTemplate: a.any,
624
+ attachmentTemplate: a.any,
625
+ width: a.oneOfType([a.string, a.number]),
626
+ onMessageSend: a.func,
627
+ onActionExecute: a.func,
628
+ dir: a.string,
629
+ messageBox: a.any
630
+ };
631
+ L.defaultProps = {
632
+ messages: [],
633
+ dateFormat: "g",
634
+ message: x
635
+ };
636
+ class ee extends s.Component {
637
+ constructor() {
638
+ super(...arguments), this.onBtnClick = (e, t) => {
639
+ m(this.props.onActionExecute, t, this, { action: e });
640
+ };
641
+ }
642
+ /**
643
+ * @hidden
644
+ */
645
+ render() {
646
+ return /* @__PURE__ */ s.createElement("div", { className: "k-card" }, /* @__PURE__ */ s.createElement(
647
+ "img",
648
+ {
649
+ className: "k-card-image",
650
+ src: this.props.imageUrl,
651
+ style: { maxWidth: this.props.imageMaxWidth }
652
+ }
653
+ ), /* @__PURE__ */ s.createElement("div", { className: "k-card-body" }, this.getTitleView(), this.getSubtitleView()), /* @__PURE__ */ s.createElement("div", { className: "k-card-actions k-card-actions-vertical" }, this.getActionsView()));
654
+ }
655
+ getActionsView() {
656
+ return this.props.actions.map((e, t) => /* @__PURE__ */ s.createElement("span", { className: "k-card-action", key: t }, /* @__PURE__ */ s.createElement(c, { fillMode: "flat", onClick: (o) => this.onBtnClick(e, o) }, e.title)));
657
+ }
658
+ getTitleView() {
659
+ let e = null;
660
+ return this.props.title && (e = /* @__PURE__ */ s.createElement("h5", { className: "k-card-title" }, this.props.title)), e;
661
+ }
662
+ getSubtitleView() {
663
+ let e = null;
664
+ return this.props.subtitle && (e = /* @__PURE__ */ s.createElement("h6", { className: "k-card-subtitle" }, this.props.subtitle)), e;
665
+ }
666
+ }
667
+ export {
668
+ L as Chat,
669
+ x as ChatMessage,
670
+ ee as HeroCard
671
+ };
@@ -1,3 +1,7 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
4
+ *-------------------------------------------------------------------------------------------*/
1
5
  /**
2
6
  * @hidden
3
7
  */
@@ -0,0 +1,9 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2023 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { PackageMetadata } from '@progress/kendo-licensing';
6
+ /**
7
+ * @hidden
8
+ */
9
+ export declare const packageMetadata: PackageMetadata;