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