@progress/kendo-react-conversational-ui 7.2.4-develop.3 → 7.2.4-develop.4

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 (93) hide show
  1. package/ViewItem.js +8 -0
  2. package/ViewItem.mjs +59 -0
  3. package/ai-prompt/AIPrompt.js +8 -0
  4. package/ai-prompt/AIPrompt.mjs +35 -0
  5. package/ai-prompt/AIPromptContent.js +8 -0
  6. package/ai-prompt/AIPromptContent.mjs +17 -0
  7. package/ai-prompt/AIPromptContext.js +8 -0
  8. package/ai-prompt/AIPromptContext.mjs +15 -0
  9. package/ai-prompt/AIPromptExpander.js +8 -0
  10. package/ai-prompt/AIPromptExpander.mjs +27 -0
  11. package/ai-prompt/AIPromptFooter.js +8 -0
  12. package/ai-prompt/AIPromptFooter.mjs +16 -0
  13. package/ai-prompt/AIPromptHeader.js +8 -0
  14. package/ai-prompt/AIPromptHeader.mjs +36 -0
  15. package/ai-prompt/views/AIPromptCommandsView.js +8 -0
  16. package/ai-prompt/views/AIPromptCommandsView.mjs +38 -0
  17. package/ai-prompt/views/AIPromptOutputView.js +8 -0
  18. package/ai-prompt/views/AIPromptOutputView.mjs +93 -0
  19. package/ai-prompt/views/AIPromptView.js +8 -0
  20. package/ai-prompt/views/AIPromptView.mjs +61 -0
  21. package/ai-prompt/views/AIPromptViewRender.js +8 -0
  22. package/ai-prompt/views/AIPromptViewRender.mjs +16 -0
  23. package/components/Action.js +8 -0
  24. package/components/Action.mjs +44 -0
  25. package/components/ActionGroup.js +8 -0
  26. package/components/ActionGroup.mjs +49 -0
  27. package/components/Attachment.js +8 -0
  28. package/components/Attachment.mjs +49 -0
  29. package/components/AttachmentGroup.js +8 -0
  30. package/components/AttachmentGroup.mjs +74 -0
  31. package/components/Chat.js +8 -0
  32. package/components/Chat.mjs +208 -0
  33. package/components/ChatMessage.js +8 -0
  34. package/components/ChatMessage.mjs +62 -0
  35. package/components/DateMarker.js +8 -0
  36. package/components/DateMarker.mjs +20 -0
  37. package/components/MessageGroup.js +8 -0
  38. package/components/MessageGroup.mjs +69 -0
  39. package/components/NewMessage.js +8 -0
  40. package/components/NewMessage.mjs +94 -0
  41. package/components/Toolbar.js +8 -0
  42. package/components/Toolbar.mjs +17 -0
  43. package/components/base/FocusableUponSelection.js +8 -0
  44. package/components/base/FocusableUponSelection.mjs +20 -0
  45. package/components/base/SelectableItemsContainer.js +8 -0
  46. package/components/base/SelectableItemsContainer.mjs +42 -0
  47. package/components/templates/HeroCard.js +8 -0
  48. package/components/templates/HeroCard.mjs +45 -0
  49. package/dist/cdn/js/kendo-react-conversational-ui.js +8 -5
  50. package/index.d.mts +811 -5
  51. package/index.d.ts +811 -23
  52. package/index.js +8 -5
  53. package/index.mjs +32 -876
  54. package/messages/index.js +8 -0
  55. package/messages/index.mjs +25 -0
  56. package/package-metadata.js +8 -0
  57. package/package-metadata.mjs +19 -0
  58. package/package.json +6 -6
  59. package/utils.js +8 -0
  60. package/utils.mjs +12 -0
  61. package/ChatPropsAndState.d.ts +0 -95
  62. package/Events.d.ts +0 -42
  63. package/ViewItem.d.ts +0 -61
  64. package/ai-prompt/AIPrompt.d.ts +0 -95
  65. package/ai-prompt/AIPromptContent.d.ts +0 -19
  66. package/ai-prompt/AIPromptContext.d.ts +0 -24
  67. package/ai-prompt/AIPromptExpander.d.ts +0 -10
  68. package/ai-prompt/AIPromptFooter.d.ts +0 -19
  69. package/ai-prompt/AIPromptHeader.d.ts +0 -36
  70. package/ai-prompt/views/AIPromptCommandsView.d.ts +0 -54
  71. package/ai-prompt/views/AIPromptOutputView.d.ts +0 -66
  72. package/ai-prompt/views/AIPromptView.d.ts +0 -26
  73. package/ai-prompt/views/AIPromptViewRender.d.ts +0 -23
  74. package/api/action.interface.d.ts +0 -35
  75. package/api/attachment.interface.d.ts +0 -36
  76. package/api/message.interface.d.ts +0 -60
  77. package/api/user.interface.d.ts +0 -27
  78. package/components/Action.d.ts +0 -23
  79. package/components/ActionGroup.d.ts +0 -27
  80. package/components/Attachment.d.ts +0 -28
  81. package/components/AttachmentGroup.d.ts +0 -27
  82. package/components/Chat.d.ts +0 -76
  83. package/components/ChatMessage.d.ts +0 -72
  84. package/components/DateMarker.d.ts +0 -18
  85. package/components/MessageGroup.d.ts +0 -29
  86. package/components/NewMessage.d.ts +0 -38
  87. package/components/Toolbar.d.ts +0 -13
  88. package/components/base/FocusableUponSelection.d.ts +0 -24
  89. package/components/base/SelectableItemsContainer.d.ts +0 -37
  90. package/components/templates/HeroCard.d.ts +0 -45
  91. package/messages/index.d.ts +0 -39
  92. package/package-metadata.d.ts +0 -9
  93. package/utils.d.ts +0 -9
package/index.mjs CHANGED
@@ -1,879 +1,35 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the package root for more information
4
- *-------------------------------------------------------------------------------------------*/
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2024 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
5
8
  "use client";
6
- import * as o from "react";
7
- import a from "react";
8
- import { classNames as g, Keys as d, dispatchEvent as N, validatePackage as ae, useCustomComponent as q } from "@progress/kendo-react-common";
9
- import { provideIntlService as U, registerForIntl as W, provideLocalizationService as P, useLocalization as re } from "@progress/kendo-react-intl";
10
- import c from "prop-types";
11
- import { chevronLeftIcon as ie, chevronRightIcon as le, paperPlaneIcon as ce, moreHorizontalIcon as H, chevronUpIcon as pe, chevronDownIcon as me, sparklesIcon as $, commentIcon as ue, copyIcon as he, checkIcon as de, rotateIcon as ge, thumbUpOutlineIcon as Ie, thumbDownOutlineIcon as fe } from "@progress/kendo-svg-icons";
12
- import { Button as p, Toolbar as ke } from "@progress/kendo-react-buttons";
13
- import { Avatar as Ee, Card as K, CardHeader as Ce, CardTitle as ye, CardSubtitle as xe, CardBody as z, CardActions as be, PanelBar as ve, PanelBarItem as we } from "@progress/kendo-react-layout";
14
- import { TextArea as Te } from "@progress/kendo-react-inputs";
15
- class F extends o.Component {
16
- /**
17
- * @hidden
18
- */
19
- componentDidUpdate(e) {
20
- !e.selected && this.props.selected && this.elementToFocus.focus();
21
- }
22
- }
23
- class G extends F {
24
- /**
25
- * @hidden
26
- */
27
- render() {
28
- return /* @__PURE__ */ o.createElement(
29
- "div",
30
- {
31
- className: this.getClassNames(),
32
- tabIndex: this.props.tabIndex,
33
- onClick: () => this.props.onRequestSelection(this.props.item.selectionIndex),
34
- onFocus: () => this.props.onRequestSelection(this.props.item.selectionIndex),
35
- ref: (e) => this.elementToFocus = e
36
- },
37
- this.getTimestampView(),
38
- this.getMainView(),
39
- this.getStatusView()
40
- );
41
- }
42
- getMainView() {
43
- return this.props.item.typing ? /* @__PURE__ */ o.createElement("div", { className: "k-chat-bubble" }, /* @__PURE__ */ o.createElement("div", { className: "k-typing-indicator" }, /* @__PURE__ */ o.createElement("span", null), /* @__PURE__ */ o.createElement("span", null), /* @__PURE__ */ o.createElement("span", null))) : this.props.template ? /* @__PURE__ */ o.createElement(this.props.template, { item: this.props.item }) : this.props.item.text ? /* @__PURE__ */ o.createElement("div", { className: "k-chat-bubble" }, this.props.item.text) : null;
44
- }
45
- getTimestampView() {
46
- let e = null;
47
- return this.props.item.timestamp && (e = /* @__PURE__ */ o.createElement("time", { className: "k-message-time", "aria-hidden": !this.props.selected }, U(this).formatDate(this.props.item.timestamp, this.props.dateFormat))), e;
48
- }
49
- getStatusView() {
50
- let e = null;
51
- return this.props.item.status && (e = /* @__PURE__ */ o.createElement("span", { className: "k-message-status" }, this.props.item.status)), e;
52
- }
53
- getClassNames() {
54
- return g(
55
- { "k-only": this.props.isOnlyItemInGroup },
56
- { "k-first": this.props.isFirstItemInGroup && !this.props.isOnlyItemInGroup },
57
- { "k-last": this.props.isLastItemInGroup && !this.props.isOnlyItemInGroup },
58
- { "k-selected": this.props.selected },
59
- { "k-focus": this.props.selected },
60
- "k-message"
61
- );
62
- }
63
- }
64
- G.defaultProps = {
65
- dateFormat: "g",
66
- tabIndex: -1
67
- };
68
- W(G);
69
- const j = (s, e) => s && e.author && s.id === e.author.id, L = (s) => s[s.length - 1], Se = (s, e) => s && e && (e.getDate() !== s.getDate() || e.getMonth() !== s.getMonth() || e.getFullYear() !== s.getFullYear()), Ne = (s, e) => {
70
- const t = e.timestamp, n = L(s);
71
- if (t && (!n || Se(t, n.timestamp))) {
72
- const r = {
73
- type: "date-marker",
74
- timestamp: t,
75
- trackBy: t.getTime()
76
- };
77
- s.push(r);
78
- }
79
- }, Le = (s, e, t) => {
80
- const n = L(s);
81
- let r;
82
- e.typing && !t || (n && n.type === "message-group" && (r = n.messages), r && j(e.author, L(r)) ? r.push(e) : s.push({
83
- type: "message-group",
84
- messages: [e],
85
- author: e.author,
86
- timestamp: e.timestamp,
87
- trackBy: e
88
- }));
89
- }, De = (s) => (e, t, n) => {
90
- const r = n === s - 1;
91
- return Ne(e, t), Le(e, t, r), t.attachments && t.attachments.length > 1 && e.push({
92
- type: "attachment-group",
93
- attachments: t.attachments,
94
- attachmentLayout: t.attachmentLayout,
95
- timestamp: t.timestamp,
96
- trackBy: t
97
- }), t.suggestedActions && r && e.push({
98
- type: "action-group",
99
- actions: t.suggestedActions,
100
- timestamp: t.timestamp,
101
- trackBy: t
102
- }), e;
103
- };
104
- function Me(s) {
105
- let e = 0;
106
- s.forEach((t) => {
107
- t.type === "message-group" ? t.messages.forEach((n) => {
108
- n.selectionIndex = e++;
109
- }) : (t.type === "attachment-group" || t.type === "action-group") && (t.selectionIndex = e++);
110
- }), s.lastSelectionIndex = e - 1;
111
- }
112
- const Re = (s) => {
113
- const t = s.slice().reduce(De(s.length), []);
114
- return Me(t), t;
115
- };
116
- class Ae extends F {
117
- constructor() {
118
- super(...arguments), this.onKeyDown = (e) => {
119
- e.keyCode === d.enter && this.props.onActionExecute(this.props.item, e);
120
- };
121
- }
122
- render() {
123
- return /* @__PURE__ */ o.createElement(
124
- "span",
125
- {
126
- role: "button",
127
- className: this.getClassNames(),
128
- onClick: (e) => this.props.onActionExecute(this.props.item, e),
129
- ref: (e) => this.elementToFocus = e,
130
- onKeyDown: this.onKeyDown,
131
- tabIndex: 0
132
- },
133
- this.props.item.title || this.props.item.value
134
- );
135
- }
136
- getClassNames() {
137
- return g(
138
- "k-quick-reply",
139
- { "k-first": this.props.isFirstItemInGroup },
140
- { "k-last": this.props.isLastItemInGroup },
141
- { "k-selected": this.props.selected },
142
- { "k-focus": this.props.selected }
143
- );
144
- }
145
- }
146
- class _ extends o.Component {
147
- constructor() {
148
- super(...arguments), this.state = { selectedItemIndex: null }, this.onRequestContainerSelection = () => this.props.onRequestSelection(this.props.group.selectionIndex), this.onKeyDown = (e) => {
149
- let t = null, n, r;
150
- this.isKeyboardNavigationLeftRight ? (n = d.left, r = d.right) : (n = d.up, r = d.down), e.keyCode === n ? t = this.navigate(!1) : e.keyCode === r && (t = this.navigate(!0)), t !== null && (e.preventDefault(), e.stopPropagation());
151
- };
152
- }
153
- static getDerivedStateFromProps(e, t) {
154
- return !e.selected && t.selectedItemIndex !== null ? { selectedItemIndex: null } : e.selected && t.selectedItemIndex === null ? { selectedItemIndex: 0 } : null;
155
- }
156
- navigate(e, t = 0) {
157
- let n = null, r = this.state.selectedItemIndex;
158
- return e ? r === null ? n = t : r < this.getLastSelectionIndex() && (n = r + 1) : r === null ? n = 0 : r > 0 && (n = r - 1), n !== null && this.setState({ selectedItemIndex: n }), n;
159
- }
160
- get isKeyboardNavigationLeftRight() {
161
- return !0;
162
- }
163
- getLastSelectionIndex() {
164
- let e = -1;
165
- if (this.props.group.type === "action-group") {
166
- const t = this.props.group;
167
- e = t.actions ? t.actions.length - 1 : -1;
168
- } else if (this.props.group.type === "attachment-group") {
169
- const t = this.props.group;
170
- e = t.attachments ? t.attachments.length - 1 : -1;
171
- }
172
- return e;
173
- }
174
- }
175
- class Ve extends _ {
176
- constructor(e) {
177
- super(e);
178
- }
179
- render() {
180
- const e = this.props.group.actions ? this.props.group.actions.length - 1 : 0;
181
- return /* @__PURE__ */ o.createElement(
182
- "div",
183
- {
184
- className: this.getClassNames(),
185
- onClick: this.onRequestContainerSelection,
186
- onKeyDown: this.onKeyDown
187
- },
188
- this.props.group.actions && this.props.group.actions.map(
189
- (t, n) => /* @__PURE__ */ o.createElement(
190
- Ae,
191
- {
192
- item: t,
193
- onActionExecute: this.props.onActionExecute,
194
- selected: n === this.state.selectedItemIndex,
195
- isFirstItemInGroup: n === 0,
196
- isLastItemInGroup: n === e,
197
- key: n
198
- }
199
- )
200
- )
201
- );
202
- }
203
- getClassNames() {
204
- return g(
205
- "k-quick-replies"
206
- );
207
- }
208
- }
209
- class Y extends F {
210
- render() {
211
- return /* @__PURE__ */ o.createElement(
212
- "div",
213
- {
214
- className: this.getClassNames(),
215
- tabIndex: this.getTabIndexValue(),
216
- onClick: this.props.onClick,
217
- ref: (e) => this.elementToFocus = e
218
- },
219
- this.props.template ? /* @__PURE__ */ o.createElement(this.props.template, { item: this.props.item }) : /* @__PURE__ */ o.createElement("div", { className: "k-card" }, /* @__PURE__ */ o.createElement("div", { className: "k-card-body" }, this.getTitleView(), this.getSubtitleView(), this.getContentView()))
220
- );
221
- }
222
- getTabIndexValue() {
223
- if (this.props.tabbable !== void 0)
224
- return this.props.tabbable ? 0 : -1;
225
- }
226
- getClassNames() {
227
- return g(
228
- { "k-selected": this.props.selected },
229
- { "k-focus": this.props.selected },
230
- { "k-first": this.props.isFirstItemInGroup },
231
- { "k-last": this.props.isLastItemInGroup }
232
- );
233
- }
234
- getTitleView() {
235
- return this.props.item.title ? /* @__PURE__ */ o.createElement("h5", { className: "k-card-title" }, this.props.item.title) : null;
236
- }
237
- getSubtitleView() {
238
- return this.props.item.subtitle ? /* @__PURE__ */ o.createElement("h6", { className: "k-card-subtitle" }, this.props.item.subtitle) : null;
239
- }
240
- getContentView() {
241
- return this.props.item.contentType.indexOf("image/") === 0 ? /* @__PURE__ */ o.createElement("img", { src: this.props.item.content }) : this.props.item.content;
242
- }
243
- }
244
- class Be extends _ {
245
- render() {
246
- const e = this.isCardDeckLayout(this.props), t = /* @__PURE__ */ o.createElement(
247
- "div",
248
- {
249
- className: this.getClassNames(),
250
- onKeyDown: e ? void 0 : this.onKeyDown
251
- },
252
- this.props.group.attachments.map((n, r) => /* @__PURE__ */ o.createElement(
253
- Y,
254
- {
255
- item: n,
256
- template: this.props.itemTemplate,
257
- selected: r === this.state.selectedItemIndex,
258
- tabbable: this.props.isLastGroup && r === this.state.selectedItemIndex,
259
- isFirstItemInGroup: r === 0,
260
- isLastItemInGroup: r === this.getLastItemIndex(),
261
- onClick: () => this.onAttachmentClick(r),
262
- key: r
263
- }
264
- ))
265
- );
266
- return e ? /* @__PURE__ */ o.createElement("div", { className: "k-card-deck-scrollwrap", onKeyDown: this.onKeyDown }, this.getLeftScrollBtn(), t, this.getRightScrollBtn()) : t;
267
- }
268
- // Overriding the default navigation.
269
- get isKeyboardNavigationLeftRight() {
270
- return this.isCardDeckLayout(this.props);
271
- }
272
- getLastItemIndex() {
273
- return this.props.group.attachments.length - 1;
274
- }
275
- getLeftScrollBtn() {
276
- let e = null;
277
- return this.isCardDeckLayout(this.props) && this.state.selectedItemIndex && (e = /* @__PURE__ */ o.createElement(p, { icon: "chevron-left", onClick: () => this.onNavigateBtnClick(!1), svgIcon: ie })), e;
278
- }
279
- getRightScrollBtn() {
280
- let e = null;
281
- return this.isCardDeckLayout(this.props) && this.state.selectedItemIndex !== this.getLastItemIndex() && (e = /* @__PURE__ */ o.createElement(p, { icon: "chevron-right", onClick: () => this.onNavigateBtnClick(!0), svgIcon: le })), e;
282
- }
283
- onAttachmentClick(e) {
284
- this.onRequestContainerSelection(), this.setState({ selectedItemIndex: e });
285
- }
286
- onNavigateBtnClick(e) {
287
- this.onRequestContainerSelection(), this.navigate(e, 1);
288
- }
289
- isCardDeckLayout(e) {
290
- return e.group.attachmentLayout !== "list";
291
- }
292
- getClassNames() {
293
- return g(
294
- {
295
- "k-card-list": this.props.group.attachmentLayout,
296
- "k-card-deck": this.isCardDeckLayout(this.props)
297
- }
298
- );
299
- }
300
- }
301
- class J extends o.Component {
302
- render() {
303
- const e = this.props.item;
304
- return /* @__PURE__ */ o.createElement("div", { className: "k-timestamp" }, U(this).formatDate(e.timestamp, "D"));
305
- }
306
- }
307
- W(J);
308
- const D = "newMessage.sendButton", M = "newMessage.optionsButton", R = "newMessage.messageInput", A = "avatar.alt", V = "messageList.ariaLabel", B = "aIPrompt.noOutputs", y = {
309
- [D]: "Send",
310
- [M]: "Options",
311
- [R]: "Message",
312
- [A]: "Avatar",
313
- [V]: "Message list",
314
- [B]: "No output from AI available"
315
- };
316
- class Pe extends o.Component {
317
- render() {
318
- const { avatarUrl: e, avatarAltText: t, name: n } = this.props.group.author, r = P(this);
319
- return /* @__PURE__ */ o.createElement("div", { className: this.getMsgGroupClassNames() }, n && /* @__PURE__ */ o.createElement("p", { className: "k-author" }, n), e && /* @__PURE__ */ o.createElement(Ee, { type: "image" }, /* @__PURE__ */ o.createElement(
320
- "img",
321
- {
322
- src: e,
323
- alt: t !== void 0 ? t : r.toLanguageString(A, y[A])
324
- }
325
- )), this.getGroupMessagesView());
326
- }
327
- getMsgGroupClassNames() {
328
- return g(
329
- "k-message-group",
330
- {
331
- "k-no-avatar": !this.props.group.author.avatarUrl,
332
- "k-alt": j(this.props.user, this.props.group.messages[0])
333
- }
334
- );
335
- }
336
- getGroupMessagesView() {
337
- const e = this.props.group.messages.length - 1;
338
- return this.props.group.messages.map((t, n) => {
339
- const r = [/* @__PURE__ */ o.createElement(
340
- this.props.message,
341
- {
342
- item: t,
343
- template: this.props.itemTemplate,
344
- selected: t.selectionIndex === this.props.selectedItemIndex,
345
- onRequestSelection: this.props.onRequestSelection,
346
- tabIndex: n === e && this.props.isLastGroup ? 0 : -1,
347
- isFirstItemInGroup: n === 0,
348
- isLastItemInGroup: n === e,
349
- isOnlyItemInGroup: e === 0,
350
- key: n
351
- }
352
- )];
353
- return t.attachments && t.attachments.length === 1 && r.push(
354
- /* @__PURE__ */ o.createElement(
355
- Y,
356
- {
357
- item: t.attachments[0],
358
- template: this.props.attachmentTemplate,
359
- selected: !1,
360
- key: `att-${n}`
361
- }
362
- )
363
- ), r;
364
- });
365
- }
366
- }
367
- class Fe extends o.Component {
368
- render() {
369
- return /* @__PURE__ */ o.createElement("div", { className: "k-toolbar-box" }, /* @__PURE__ */ o.createElement("div", { className: "k-button-list" }, this.props.children));
370
- }
371
- }
372
- class Ge extends o.Component {
373
- constructor() {
374
- super(...arguments), this.state = { focused: !1 }, this.inputEl = null, this.onInputKeyDown = (e) => {
375
- e.keyCode === d.enter && this.sendMessage(e);
376
- }, this.sendMessage = (e) => {
377
- if (this.props.onMessageSend && this.inputEl !== null) {
378
- const t = this.inputEl.value;
379
- if (t) {
380
- const n = {
381
- author: this.props.user,
382
- text: t,
383
- timestamp: /* @__PURE__ */ new Date()
384
- };
385
- this.props.onMessageSend(n, e);
386
- }
387
- }
388
- this.inputEl !== null && (this.inputEl.value = null);
389
- };
390
- }
391
- render() {
392
- const e = P(this), t = /* @__PURE__ */ o.createElement(
393
- "input",
394
- {
395
- type: "text",
396
- className: this.getClassNames(),
397
- placeholder: this.props.placeholder,
398
- onKeyDown: this.onInputKeyDown,
399
- onFocus: () => this.setState({ focused: !0 }),
400
- onBlur: () => this.setState({ focused: !1 }),
401
- ref: (l) => this.inputEl = l,
402
- "aria-label": e.toLanguageString(R, y[R])
403
- }
404
- ), n = /* @__PURE__ */ o.createElement(
405
- p,
406
- {
407
- fillMode: "flat",
408
- themeColor: "base",
409
- className: "k-chat-send",
410
- icon: "paper-plane",
411
- svgIcon: ce,
412
- onClick: this.sendMessage,
413
- "aria-label": e.toLanguageString(D, y[D]),
414
- dir: this.props.isDirectionRightToLeft ? "rtl" : void 0
415
- }
416
- ), r = /* @__PURE__ */ o.createElement(
417
- p,
418
- {
419
- fillMode: "flat",
420
- themeColor: "base",
421
- rounded: null,
422
- className: "k-button-toggle",
423
- icon: "more-horizontal",
424
- svgIcon: H,
425
- onClick: (l) => this.props.onToolbarActionButtonClick(!this.props.showToolbar, l),
426
- "aria-label": e.toLanguageString(M, y[M])
427
- }
428
- );
429
- return /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement("span", { className: "k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid" }, this.props.MessageBox ? /* @__PURE__ */ o.createElement(
430
- this.props.MessageBox,
431
- {
432
- messageInput: t,
433
- sendButton: n,
434
- toolbarButton: r
435
- }
436
- ) : /* @__PURE__ */ o.createElement(o.Fragment, null, t, /* @__PURE__ */ o.createElement("span", { className: "k-input-suffix" }, this.props.toolbar && r, n))), this.props.showToolbar && /* @__PURE__ */ o.createElement(Fe, null, this.props.toolbar));
437
- }
438
- focusInput() {
439
- this.inputEl !== null && this.inputEl.focus();
440
- }
441
- getClassNames() {
442
- return g(
443
- "k-input-inner",
444
- { "k-focus": this.state.focused }
445
- );
446
- }
447
- }
448
- const Oe = {
449
- name: "@progress/kendo-react-conversational-ui",
450
- productName: "KendoReact",
451
- productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
452
- publishDate: 1709632269,
453
- version: "",
454
- licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
455
- }, Q = class extends o.Component {
456
- constructor(s) {
457
- super(s), this.viewItems = [], this.isDirectionRightToLeft = !1, this.scrollToBottomOnLoadingData = !0, this.onFocus = () => {
458
- clearTimeout(this.timeoutIdForChatLosingFocus);
459
- }, this.onBlur = () => {
460
- this.timeoutIdForChatLosingFocus = window.setTimeout(() => {
461
- this.setState({ selectedItemIndex: null });
462
- }, 0);
463
- }, this.onSelectionRequested = (e) => {
464
- this.setState({ selectedItemIndex: e });
465
- }, this.onKeyDown = (e) => {
466
- let t = null, n = this.state.selectedItemIndex !== null ? this.state.selectedItemIndex : this.viewItems.lastSelectionIndex;
467
- e.keyCode === d.up ? n === null ? t = 0 : n > 0 && (t = n - 1) : e.keyCode === d.down && (n === null ? t = 0 : n < this.viewItems.lastSelectionIndex && (t = n + 1)), t !== null && (this.setState({ selectedItemIndex: t }), e.preventDefault());
468
- }, this.onMessageSend = (e, t) => {
469
- N(this.props.onMessageSend, t, this, { message: e });
470
- }, this.onActionExecute = (e, t) => {
471
- if (N(this.props.onActionExecute, t, this, { action: e }), !t.isDefaultPrevented()) {
472
- switch (e.type) {
473
- case "reply":
474
- this.onMessageSend(
475
- {
476
- author: this.props.user,
477
- text: e.value,
478
- timestamp: /* @__PURE__ */ new Date()
479
- },
480
- t
481
- );
482
- break;
483
- case "call":
484
- window.open("tel:" + e.value);
485
- break;
486
- case "openUrl":
487
- window.open(e.value);
488
- break;
489
- }
490
- this.newMsgComp.focusInput();
491
- }
492
- }, ae(Oe), this.state = { selectedItemIndex: null, isFirstRender: !0 };
493
- }
494
- /**
495
- * @hidden
496
- */
497
- render() {
498
- this.viewItems = this.getViewItemsFromMsgs(this.props.messages), this.isDirectionRightToLeft = this.checkIsDirectionRightToLeft(this.props);
499
- const s = P(this);
500
- return /* @__PURE__ */ o.createElement(
501
- "div",
502
- {
503
- style: { width: this.props.width },
504
- onKeyDown: this.onKeyDown,
505
- className: this.getClassNames(),
506
- ref: (e) => this.chatWrapperEl = e
507
- },
508
- /* @__PURE__ */ o.createElement(
509
- "div",
510
- {
511
- className: "k-message-list k-avatars",
512
- onBlur: this.onBlur,
513
- onFocus: this.onFocus,
514
- role: "log",
515
- "aria-label": s.toLanguageString(V, y[V]),
516
- "aria-live": "polite",
517
- onScroll: (e) => {
518
- this.scrollToBottomOnLoadingData = e.currentTarget.scrollTop === e.currentTarget.scrollHeight - e.currentTarget.clientHeight;
519
- },
520
- ref: (e) => this.viewItemsWrapperEl = e
521
- },
522
- /* @__PURE__ */ o.createElement("div", { className: "k-message-list-content" }, this.renderViewItems())
523
- ),
524
- /* @__PURE__ */ o.createElement(
525
- Ge,
526
- {
527
- user: this.props.user,
528
- onMessageSend: this.onMessageSend,
529
- isDirectionRightToLeft: this.isDirectionRightToLeft,
530
- ref: (e) => this.newMsgComp = e,
531
- placeholder: this.props.placeholder,
532
- MessageBox: this.props.messageBox,
533
- toolbar: this.props.toolbar,
534
- onToolbarActionButtonClick: this.props.onToolbarActionExecute,
535
- showToolbar: this.props.showToolbar
536
- }
537
- )
538
- );
539
- }
540
- /**
541
- * @hidden
542
- */
543
- componentDidMount() {
544
- this.setState({ isFirstRender: !1 }, () => {
545
- this.nextTickId = window.setTimeout(() => this.scrollViewItemsToBottom(), 250);
546
- });
547
- }
548
- /**
549
- * @hidden
550
- */
551
- componentWillUnmount() {
552
- clearTimeout(this.nextTickId);
553
- }
554
- /**
555
- * @hidden
556
- */
557
- componentDidUpdate(s) {
558
- s.messages.length !== this.props.messages.length && this.scrollToBottomOnLoadingData && this.scrollViewItemsToBottom();
559
- }
560
- getClassNames() {
561
- return g(
562
- "k-chat",
563
- this.props.className,
564
- { "k-rtl": this.isDirectionRightToLeft }
565
- );
566
- }
567
- checkIsDirectionRightToLeft(s) {
568
- return !!(s.dir !== void 0 ? s.dir === "rtl" : this.chatWrapperEl && getComputedStyle(this.chatWrapperEl).direction === "rtl");
569
- }
570
- renderViewItems() {
571
- const s = this.viewItems.length - 1;
572
- return this.viewItems.map((e, t) => {
573
- if (e.type === "date-marker")
574
- return /* @__PURE__ */ o.createElement(J, { item: e, key: t });
575
- if (e.type === "message-group")
576
- return /* @__PURE__ */ o.createElement(
577
- Pe,
578
- {
579
- group: e,
580
- itemTemplate: this.props.messageTemplate,
581
- attachmentTemplate: this.props.attachmentTemplate,
582
- user: this.props.user,
583
- selectedItemIndex: this.state.selectedItemIndex,
584
- onRequestSelection: this.onSelectionRequested,
585
- isLastGroup: t === s,
586
- key: t,
587
- message: this.props.message || Q.defaultProps.message
588
- }
589
- );
590
- if (e.type === "attachment-group")
591
- return /* @__PURE__ */ o.createElement(
592
- Be,
593
- {
594
- group: e,
595
- itemTemplate: this.props.attachmentTemplate,
596
- onRequestSelection: this.onSelectionRequested,
597
- selected: e.selectionIndex === this.state.selectedItemIndex,
598
- isLastGroup: t === s,
599
- key: t
600
- }
601
- );
602
- if (e.type === "action-group")
603
- return /* @__PURE__ */ o.createElement(
604
- Ve,
605
- {
606
- group: e,
607
- onActionExecute: this.onActionExecute,
608
- onRequestSelection: this.onSelectionRequested,
609
- selected: e.selectionIndex === this.state.selectedItemIndex,
610
- isLastGroup: t === s,
611
- key: t
612
- }
613
- );
614
- });
615
- }
616
- scrollViewItemsToBottom() {
617
- this.viewItemsWrapperEl && (this.viewItemsWrapperEl.scrollTop = this.viewItemsWrapperEl.scrollHeight - this.viewItemsWrapperEl.clientHeight);
618
- }
619
- getViewItemsFromMsgs(s) {
620
- return s.length > 0 ? Re(s) : [];
621
- }
622
- };
623
- let X = Q;
624
- X.propTypes = {
625
- messages: c.arrayOf(c.object),
626
- user: c.object,
627
- messageTemplate: c.any,
628
- attachmentTemplate: c.any,
629
- width: c.oneOfType([c.string, c.number]),
630
- onMessageSend: c.func,
631
- onActionExecute: c.func,
632
- dir: c.string,
633
- messageBox: c.any
634
- };
635
- X.defaultProps = {
636
- messages: [],
637
- dateFormat: "g",
638
- message: G
639
- };
640
- class Xe extends o.Component {
641
- constructor() {
642
- super(...arguments), this.onBtnClick = (e, t) => {
643
- N(this.props.onActionExecute, t, this, { action: e });
644
- };
645
- }
646
- /**
647
- * @hidden
648
- */
649
- render() {
650
- return /* @__PURE__ */ o.createElement("div", { className: "k-card" }, /* @__PURE__ */ o.createElement(
651
- "img",
652
- {
653
- className: "k-card-image",
654
- src: this.props.imageUrl,
655
- style: { maxWidth: this.props.imageMaxWidth }
656
- }
657
- ), /* @__PURE__ */ o.createElement("div", { className: "k-card-body" }, this.getTitleView(), this.getSubtitleView()), /* @__PURE__ */ o.createElement("div", { className: "k-card-actions k-card-actions-vertical" }, this.getActionsView()));
658
- }
659
- getActionsView() {
660
- return this.props.actions.map((e, t) => /* @__PURE__ */ o.createElement("span", { className: "k-card-action", key: t }, /* @__PURE__ */ o.createElement(p, { fillMode: "flat", onClick: (n) => this.onBtnClick(e, n) }, e.title)));
661
- }
662
- getTitleView() {
663
- let e = null;
664
- return this.props.title && (e = /* @__PURE__ */ o.createElement("h5", { className: "k-card-title" }, this.props.title)), e;
665
- }
666
- getSubtitleView() {
667
- let e = null;
668
- return this.props.subtitle && (e = /* @__PURE__ */ o.createElement("h6", { className: "k-card-subtitle" }, this.props.subtitle)), e;
669
- }
670
- }
671
- const qe = (s) => {
672
- const { activeView: e, toolbarItems: t, activeViewChange: n } = s, r = (l) => {
673
- n == null || n.call(null, l);
674
- };
675
- return /* @__PURE__ */ a.createElement("div", { className: "k-prompt-header" }, /* @__PURE__ */ a.createElement(ke, { keyboardNavigation: !1, role: "toolbar", className: "k-toolbar-flat" }, t.map(
676
- (l) => a.isValidElement(l) ? l : /* @__PURE__ */ a.createElement(
677
- p,
678
- {
679
- key: l.name,
680
- className: e === l.name ? "k-selected" : "",
681
- size: "medium",
682
- themeColor: "primary",
683
- fillMode: "flat",
684
- rounded: "full",
685
- title: l.buttonText,
686
- svgIcon: l.buttonIcon,
687
- "aria-hidden": "true",
688
- onClick: () => r(l.name)
689
- },
690
- l.buttonText
691
- )
692
- )));
693
- }, T = a.forwardRef((s, e) => {
694
- const { children: t } = s;
695
- return /* @__PURE__ */ a.createElement("div", { className: "k-prompt-content", ref: e }, /* @__PURE__ */ a.createElement("div", { className: "k-prompt-view" }, t));
696
- });
697
- T.displayName = "KendoReactAIPromptContent";
698
- const Ke = (s) => {
699
- const { children: e } = s;
700
- return /* @__PURE__ */ a.createElement("div", { className: "k-prompt-footer" }, /* @__PURE__ */ a.createElement("div", { className: "k-actions k-actions-start k-actions-horizontal k-prompt-actions" }, e));
701
- }, Z = a.createContext([{}, () => {
702
- }]), S = () => a.useContext(Z), O = (s) => {
703
- const [e] = S();
704
- return e.activeView === s.name ? s.children : null;
705
- }, ze = (s) => {
706
- const [e, t] = a.useState(!0), { children: n, title: r } = s;
707
- return /* @__PURE__ */ a.createElement("div", { className: "k-prompt-expander" }, /* @__PURE__ */ a.createElement(
708
- p,
709
- {
710
- fillMode: "flat",
711
- svgIcon: e ? pe : me,
712
- title: r,
713
- onClick: () => t(!e)
714
- },
715
- r
716
- ), e && /* @__PURE__ */ a.createElement("div", { className: "k-prompt-expander-content" }, n));
717
- }, ee = {
718
- name: "prompt-view",
719
- buttonText: "Ask AI",
720
- buttonIcon: $
721
- }, Ze = (s) => {
722
- const e = "Generate", { promptInput: t = Te, generateButton: n = p, promptValue: r, promptSuggestions: l } = s, [h, m] = a.useState(r || ""), [u] = S(), [E, I] = q(n), [x, f] = q(t), b = () => {
723
- u.onPromptRequest && u.onPromptRequest.call(null, h), m("");
724
- }, C = (k) => {
725
- m(k);
726
- }, w = (k) => {
727
- m(k.target.value);
728
- }, i = {
729
- title: "Generate",
730
- svgIcon: $
731
- }, v = {
732
- placeholder: "Ask or generate content with AI ...",
733
- rows: 2
734
- }, ne = Object.keys(I).length > 0 ? I : i, oe = Object.keys(f).length > 0 ? f : v;
735
- return /* @__PURE__ */ a.createElement(O, { name: ee.name }, /* @__PURE__ */ a.createElement(T, null, /* @__PURE__ */ a.createElement(
736
- x,
737
- {
738
- value: h,
739
- onChange: w,
740
- ...oe
741
- }
742
- ), l && l.length > 0 && /* @__PURE__ */ a.createElement(ze, { title: "Prompt Suggestions" }, l.map((k) => /* @__PURE__ */ a.createElement("div", { key: k, className: "k-prompt-suggestion", onClick: () => C(k) }, k)))), /* @__PURE__ */ a.createElement(Ke, null, /* @__PURE__ */ a.createElement(
743
- E,
744
- {
745
- themeColor: "primary",
746
- fillMode: "solid",
747
- "aria-hidden": "true",
748
- rounded: "full",
749
- size: "medium",
750
- onClick: b,
751
- ...ne
752
- },
753
- e
754
- )));
755
- }, te = {
756
- name: "Output view",
757
- buttonText: "Output",
758
- buttonIcon: ue
759
- }, et = (s) => {
760
- const [e, t] = a.useState(""), n = a.useRef(null), [r] = S(), { outputs: l, showOutputRating: h, outputCard: m } = s, { header: u, body: E, actions: I } = m || {}, x = re(), f = (i) => {
761
- r.onPromptRequest && r.onPromptRequest.call(null, i.prompt, { ...i, isRetry: !0 }), w();
762
- }, b = (i) => {
763
- i != null && i.responseContent && navigator.clipboard.writeText(i.responseContent), t(i.id), setTimeout(() => {
764
- t("");
765
- }, 1e3);
766
- }, C = (i, v) => {
767
- r.onPromptRequest && r.onPromptRequest.call(
768
- null,
769
- i.prompt,
770
- { ...i, ratingType: v, isRetry: !1 }
771
- ), w();
772
- }, w = () => {
773
- n && n.current && n.current.scrollTo({ top: 0, behavior: "smooth" });
774
- };
775
- return /* @__PURE__ */ a.createElement(O, { name: te.name }, /* @__PURE__ */ a.createElement(T, { ref: n }, /* @__PURE__ */ a.createElement("div", { className: "k-card-list" }, l && l.length > 0 ? l.map((i, v) => /* @__PURE__ */ a.createElement(K, { key: `${i.id}_${v}` }, /* @__PURE__ */ a.createElement(Ce, null, u ? u(i) : /* @__PURE__ */ a.createElement(a.Fragment, null, i.title && /* @__PURE__ */ a.createElement(ye, null, i.title), i.subTitle && /* @__PURE__ */ a.createElement(xe, null, i.subTitle))), /* @__PURE__ */ a.createElement(z, null, E ? E(i) : i.responseContent), /* @__PURE__ */ a.createElement(be, null, I ? I(i) : /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement(
776
- p,
777
- {
778
- size: "medium",
779
- themeColor: "primary",
780
- fillMode: "flat",
781
- rounded: "medium",
782
- title: "Copy",
783
- svgIcon: e === i.id ? he : de,
784
- "aria-hidden": "true",
785
- onClick: () => b(i)
786
- },
787
- "Copy"
788
- ), /* @__PURE__ */ a.createElement(
789
- p,
790
- {
791
- size: "medium",
792
- themeColor: "base",
793
- fillMode: "flat",
794
- rounded: "medium",
795
- title: "Retry",
796
- svgIcon: ge,
797
- "aria-hidden": "true",
798
- onClick: () => f(i)
799
- },
800
- "Retry"
801
- ), h && /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement("span", { className: "k-spacer" }), /* @__PURE__ */ a.createElement(
802
- p,
803
- {
804
- size: "medium",
805
- themeColor: i.ratingType === "positive" ? "primary" : "base",
806
- fillMode: "flat",
807
- rounded: "medium",
808
- title: "Rate up",
809
- svgIcon: Ie,
810
- "aria-hidden": "true",
811
- onClick: () => C(i, "positive")
812
- }
813
- ), /* @__PURE__ */ a.createElement(
814
- p,
815
- {
816
- size: "medium",
817
- themeColor: i.ratingType === "negative" ? "primary" : "base",
818
- fillMode: "flat",
819
- rounded: "medium",
820
- title: "Rate down",
821
- svgIcon: fe,
822
- "aria-hidden": "true",
823
- onClick: () => C(i, "negative")
824
- }
825
- )))))) : /* @__PURE__ */ a.createElement(K, null, /* @__PURE__ */ a.createElement(z, null, x.toLanguageString(B, y[B]))))));
826
- }, tt = (s) => {
827
- const { activeView: e, toolbarItems: t, children: n, onActiveViewChange: r, onPromptRequest: l, onCommandExecute: h, style: m, dir: u } = s, E = t || [ee, te], [I, x] = a.useState({ activeView: e }), f = {
828
- ...I,
829
- activeView: e,
830
- onActiveViewChange: r,
831
- onPromptRequest: l,
832
- onCommandExecute: h
833
- }, b = (C) => {
834
- x(C);
835
- };
836
- return /* @__PURE__ */ a.createElement(Z.Provider, { value: [f, b] }, /* @__PURE__ */ a.createElement("div", { className: "k-prompt", style: m, dir: u }, /* @__PURE__ */ a.createElement(
837
- qe,
838
- {
839
- activeView: f.activeView,
840
- toolbarItems: E,
841
- activeViewChange: r
842
- }
843
- ), n));
844
- }, Ue = {
845
- name: "Commands view",
846
- buttonIcon: H
847
- }, se = (s) => s == null ? void 0 : s.map((e) => /* @__PURE__ */ a.createElement(
848
- we,
849
- {
850
- title: e.text,
851
- key: e.id,
852
- svgIcon: e.svgIcon,
853
- data: e
854
- },
855
- e.children && se(e.children || [])
856
- )), st = (s) => {
857
- const { commands: e } = s, [t] = S(), n = (r) => {
858
- var h, m, u;
859
- const l = (m = (h = r.target) == null ? void 0 : h.props) == null ? void 0 : m.data;
860
- (u = l.children) != null && u.length || t.onCommandExecute && t.onCommandExecute.call(null, l);
861
- };
862
- return /* @__PURE__ */ a.createElement(O, { name: Ue.name }, /* @__PURE__ */ a.createElement(T, null, /* @__PURE__ */ a.createElement("div", { className: "k-prompt-view" }, /* @__PURE__ */ a.createElement(ve, { onSelect: n, selected: "" }, se(e != null ? e : [])))));
863
- };
9
+ import { ChatMessage as t } from "./components/ChatMessage.mjs";
10
+ import { Chat as m } from "./components/Chat.mjs";
11
+ import { HeroCard as f } from "./components/templates/HeroCard.mjs";
12
+ import { AIPrompt as a } from "./ai-prompt/AIPrompt.mjs";
13
+ import { PromptHeader as s } from "./ai-prompt/AIPromptHeader.mjs";
14
+ import { AIPromptFooter as P } from "./ai-prompt/AIPromptFooter.mjs";
15
+ import { AIPromptContent as A } from "./ai-prompt/AIPromptContent.mjs";
16
+ import { AIPromptView as V, promptViewDefaults as n } from "./ai-prompt/views/AIPromptView.mjs";
17
+ import { AIPromptOutputView as C, outputViewDefaults as l } from "./ai-prompt/views/AIPromptOutputView.mjs";
18
+ import { AIPromptCommandsView as c, commandsViewDefaults as h } from "./ai-prompt/views/AIPromptCommandsView.mjs";
19
+ import { AIPromptViewRender as g } from "./ai-prompt/views/AIPromptViewRender.mjs";
864
20
  export {
865
- tt as AIPrompt,
866
- st as AIPromptCommandsView,
867
- T as AIPromptContent,
868
- Ke as AIPromptFooter,
869
- et as AIPromptOutputView,
870
- Ze as AIPromptView,
871
- O as AIPromptViewRender,
872
- X as Chat,
873
- G as ChatMessage,
874
- Xe as HeroCard,
875
- qe as PromptHeader,
876
- Ue as commandsViewDefaults,
877
- te as outputViewDefaults,
878
- ee as promptViewDefaults
21
+ a as AIPrompt,
22
+ c as AIPromptCommandsView,
23
+ A as AIPromptContent,
24
+ P as AIPromptFooter,
25
+ C as AIPromptOutputView,
26
+ V as AIPromptView,
27
+ g as AIPromptViewRender,
28
+ m as Chat,
29
+ t as ChatMessage,
30
+ f as HeroCard,
31
+ s as PromptHeader,
32
+ h as commandsViewDefaults,
33
+ l as outputViewDefaults,
34
+ n as promptViewDefaults
879
35
  };