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