@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.
- package/ViewItem.js +8 -0
- package/ViewItem.mjs +59 -0
- package/ai-prompt/AIPrompt.js +8 -0
- package/ai-prompt/AIPrompt.mjs +35 -0
- package/ai-prompt/AIPromptContent.js +8 -0
- package/ai-prompt/AIPromptContent.mjs +17 -0
- package/ai-prompt/AIPromptContext.js +8 -0
- package/ai-prompt/AIPromptContext.mjs +15 -0
- package/ai-prompt/AIPromptExpander.js +8 -0
- package/ai-prompt/AIPromptExpander.mjs +27 -0
- package/ai-prompt/AIPromptFooter.js +8 -0
- package/ai-prompt/AIPromptFooter.mjs +16 -0
- package/ai-prompt/AIPromptHeader.js +8 -0
- package/ai-prompt/AIPromptHeader.mjs +36 -0
- package/ai-prompt/views/AIPromptCommandsView.js +8 -0
- package/ai-prompt/views/AIPromptCommandsView.mjs +38 -0
- package/ai-prompt/views/AIPromptOutputView.js +8 -0
- package/ai-prompt/views/AIPromptOutputView.mjs +93 -0
- package/ai-prompt/views/AIPromptView.js +8 -0
- package/ai-prompt/views/AIPromptView.mjs +61 -0
- package/ai-prompt/views/AIPromptViewRender.js +8 -0
- package/ai-prompt/views/AIPromptViewRender.mjs +16 -0
- package/components/Action.js +8 -0
- package/components/Action.mjs +44 -0
- package/components/ActionGroup.js +8 -0
- package/components/ActionGroup.mjs +49 -0
- package/components/Attachment.js +8 -0
- package/components/Attachment.mjs +49 -0
- package/components/AttachmentGroup.js +8 -0
- package/components/AttachmentGroup.mjs +74 -0
- package/components/Chat.js +8 -0
- package/components/Chat.mjs +208 -0
- package/components/ChatMessage.js +8 -0
- package/components/ChatMessage.mjs +62 -0
- package/components/DateMarker.js +8 -0
- package/components/DateMarker.mjs +20 -0
- package/components/MessageGroup.js +8 -0
- package/components/MessageGroup.mjs +69 -0
- package/components/NewMessage.js +8 -0
- package/components/NewMessage.mjs +94 -0
- package/components/Toolbar.js +8 -0
- package/components/Toolbar.mjs +17 -0
- package/components/base/FocusableUponSelection.js +8 -0
- package/components/base/FocusableUponSelection.mjs +20 -0
- package/components/base/SelectableItemsContainer.js +8 -0
- package/components/base/SelectableItemsContainer.mjs +42 -0
- package/components/templates/HeroCard.js +8 -0
- package/components/templates/HeroCard.mjs +45 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +8 -5
- package/index.d.mts +811 -5
- package/index.d.ts +811 -23
- package/index.js +8 -5
- package/index.mjs +32 -876
- package/messages/index.js +8 -0
- package/messages/index.mjs +25 -0
- package/package-metadata.js +8 -0
- package/package-metadata.mjs +19 -0
- package/package.json +6 -6
- package/utils.js +8 -0
- package/utils.mjs +12 -0
- package/ChatPropsAndState.d.ts +0 -95
- package/Events.d.ts +0 -42
- package/ViewItem.d.ts +0 -61
- package/ai-prompt/AIPrompt.d.ts +0 -95
- package/ai-prompt/AIPromptContent.d.ts +0 -19
- package/ai-prompt/AIPromptContext.d.ts +0 -24
- package/ai-prompt/AIPromptExpander.d.ts +0 -10
- package/ai-prompt/AIPromptFooter.d.ts +0 -19
- package/ai-prompt/AIPromptHeader.d.ts +0 -36
- package/ai-prompt/views/AIPromptCommandsView.d.ts +0 -54
- package/ai-prompt/views/AIPromptOutputView.d.ts +0 -66
- package/ai-prompt/views/AIPromptView.d.ts +0 -26
- package/ai-prompt/views/AIPromptViewRender.d.ts +0 -23
- package/api/action.interface.d.ts +0 -35
- package/api/attachment.interface.d.ts +0 -36
- package/api/message.interface.d.ts +0 -60
- package/api/user.interface.d.ts +0 -27
- package/components/Action.d.ts +0 -23
- package/components/ActionGroup.d.ts +0 -27
- package/components/Attachment.d.ts +0 -28
- package/components/AttachmentGroup.d.ts +0 -27
- package/components/Chat.d.ts +0 -76
- package/components/ChatMessage.d.ts +0 -72
- package/components/DateMarker.d.ts +0 -18
- package/components/MessageGroup.d.ts +0 -29
- package/components/NewMessage.d.ts +0 -38
- package/components/Toolbar.d.ts +0 -13
- package/components/base/FocusableUponSelection.d.ts +0 -24
- package/components/base/SelectableItemsContainer.d.ts +0 -37
- package/components/templates/HeroCard.d.ts +0 -45
- package/messages/index.d.ts +0 -39
- package/package-metadata.d.ts +0 -9
- package/utils.d.ts +0 -9
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import { Keys as c, classNames as m } from "@progress/kendo-react-common";
|
|
10
|
+
import * as e from "react";
|
|
11
|
+
import h from "./Toolbar.mjs";
|
|
12
|
+
import { Button as l } from "@progress/kendo-react-buttons";
|
|
13
|
+
import { paperPlaneIcon as g, moreHorizontalIcon as d } from "@progress/kendo-svg-icons";
|
|
14
|
+
import { provideLocalizationService as f } from "@progress/kendo-react-intl";
|
|
15
|
+
import { newMessageMessageInput as r, messages as a, newMessageSendButton as p, newMessageOptionsButton as u } from "../messages/index.mjs";
|
|
16
|
+
class B extends e.Component {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments), this.state = { focused: !1 }, this.inputEl = null, this.onInputKeyDown = (t) => {
|
|
19
|
+
t.keyCode === c.enter && this.sendMessage(t);
|
|
20
|
+
}, this.sendMessage = (t) => {
|
|
21
|
+
if (this.props.onMessageSend && this.inputEl !== null) {
|
|
22
|
+
const s = this.inputEl.value;
|
|
23
|
+
if (s) {
|
|
24
|
+
const o = {
|
|
25
|
+
author: this.props.user,
|
|
26
|
+
text: s,
|
|
27
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
28
|
+
};
|
|
29
|
+
this.props.onMessageSend(o, t);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
this.inputEl !== null && (this.inputEl.value = null);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const t = f(this), s = /* @__PURE__ */ e.createElement(
|
|
37
|
+
"input",
|
|
38
|
+
{
|
|
39
|
+
type: "text",
|
|
40
|
+
className: this.getClassNames(),
|
|
41
|
+
placeholder: this.props.placeholder,
|
|
42
|
+
onKeyDown: this.onInputKeyDown,
|
|
43
|
+
onFocus: () => this.setState({ focused: !0 }),
|
|
44
|
+
onBlur: () => this.setState({ focused: !1 }),
|
|
45
|
+
ref: (n) => this.inputEl = n,
|
|
46
|
+
"aria-label": t.toLanguageString(r, a[r])
|
|
47
|
+
}
|
|
48
|
+
), o = /* @__PURE__ */ e.createElement(
|
|
49
|
+
l,
|
|
50
|
+
{
|
|
51
|
+
fillMode: "flat",
|
|
52
|
+
themeColor: "base",
|
|
53
|
+
className: "k-chat-send",
|
|
54
|
+
icon: "paper-plane",
|
|
55
|
+
svgIcon: g,
|
|
56
|
+
onClick: this.sendMessage,
|
|
57
|
+
"aria-label": t.toLanguageString(p, a[p]),
|
|
58
|
+
dir: this.props.isDirectionRightToLeft ? "rtl" : void 0
|
|
59
|
+
}
|
|
60
|
+
), i = /* @__PURE__ */ e.createElement(
|
|
61
|
+
l,
|
|
62
|
+
{
|
|
63
|
+
fillMode: "flat",
|
|
64
|
+
themeColor: "base",
|
|
65
|
+
rounded: null,
|
|
66
|
+
className: "k-button-toggle",
|
|
67
|
+
icon: "more-horizontal",
|
|
68
|
+
svgIcon: d,
|
|
69
|
+
onClick: (n) => this.props.onToolbarActionButtonClick(!this.props.showToolbar, n),
|
|
70
|
+
"aria-label": t.toLanguageString(u, a[u])
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("span", { className: "k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid" }, this.props.MessageBox ? /* @__PURE__ */ e.createElement(
|
|
74
|
+
this.props.MessageBox,
|
|
75
|
+
{
|
|
76
|
+
messageInput: s,
|
|
77
|
+
sendButton: o,
|
|
78
|
+
toolbarButton: i
|
|
79
|
+
}
|
|
80
|
+
) : /* @__PURE__ */ e.createElement(e.Fragment, null, s, /* @__PURE__ */ e.createElement("span", { className: "k-input-suffix" }, this.props.toolbar && i, o))), this.props.showToolbar && /* @__PURE__ */ e.createElement(h, null, this.props.toolbar));
|
|
81
|
+
}
|
|
82
|
+
focusInput() {
|
|
83
|
+
this.inputEl !== null && this.inputEl.focus();
|
|
84
|
+
}
|
|
85
|
+
getClassNames() {
|
|
86
|
+
return m(
|
|
87
|
+
"k-input-inner",
|
|
88
|
+
{ "k-focus": this.state.focused }
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
B as default
|
|
94
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";"use strict";const o=require("react");function a(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const c=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,c.get?c:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const n=a(o);class s extends n.Component{render(){return n.createElement("div",{className:"k-toolbar-box"},n.createElement("div",{className:"k-button-list"},this.props.children))}}module.exports=s;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
class a extends e.Component {
|
|
11
|
+
render() {
|
|
12
|
+
return /* @__PURE__ */ e.createElement("div", { className: "k-toolbar-box" }, /* @__PURE__ */ e.createElement("div", { className: "k-button-list" }, this.props.children));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
a as default
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react");function s(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const r=s(c);class l extends r.Component{componentDidUpdate(t){!t.selected&&this.props.selected&&this.elementToFocus.focus()}}exports.FocusableUponSelection=l;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as o from "react";
|
|
10
|
+
class s extends o.Component {
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
componentDidUpdate(e) {
|
|
15
|
+
!e.selected && this.props.selected && this.elementToFocus.focus();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
s as FocusableUponSelection
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),o=require("@progress/kendo-react-common");function i(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const a=i(r);class c extends a.Component{constructor(){super(...arguments),this.state={selectedItemIndex:null},this.onRequestContainerSelection=()=>this.props.onRequestSelection(this.props.group.selectionIndex),this.onKeyDown=t=>{let e=null,n,s;this.isKeyboardNavigationLeftRight?(n=o.Keys.left,s=o.Keys.right):(n=o.Keys.up,s=o.Keys.down),t.keyCode===n?e=this.navigate(!1):t.keyCode===s&&(e=this.navigate(!0)),e!==null&&(t.preventDefault(),t.stopPropagation())}}static getDerivedStateFromProps(t,e){return!t.selected&&e.selectedItemIndex!==null?{selectedItemIndex:null}:t.selected&&e.selectedItemIndex===null?{selectedItemIndex:0}:null}navigate(t,e=0){let n=null,s=this.state.selectedItemIndex;return t?s===null?n=e:s<this.getLastSelectionIndex()&&(n=s+1):s===null?n=0:s>0&&(n=s-1),n!==null&&this.setState({selectedItemIndex:n}),n}get isKeyboardNavigationLeftRight(){return!0}getLastSelectionIndex(){let t=-1;if(this.props.group.type==="action-group"){const e=this.props.group;t=e.actions?e.actions.length-1:-1}else if(this.props.group.type==="attachment-group"){const e=this.props.group;t=e.attachments?e.attachments.length-1:-1}return t}}exports.SelectableItemsContainer=c;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as i from "react";
|
|
10
|
+
import { Keys as l } from "@progress/kendo-react-common";
|
|
11
|
+
class a extends i.Component {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.state = { selectedItemIndex: null }, this.onRequestContainerSelection = () => this.props.onRequestSelection(this.props.group.selectionIndex), this.onKeyDown = (t) => {
|
|
14
|
+
let e = null, n, s;
|
|
15
|
+
this.isKeyboardNavigationLeftRight ? (n = l.left, s = l.right) : (n = l.up, s = l.down), t.keyCode === n ? e = this.navigate(!1) : t.keyCode === s && (e = this.navigate(!0)), e !== null && (t.preventDefault(), t.stopPropagation());
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
static getDerivedStateFromProps(t, e) {
|
|
19
|
+
return !t.selected && e.selectedItemIndex !== null ? { selectedItemIndex: null } : t.selected && e.selectedItemIndex === null ? { selectedItemIndex: 0 } : null;
|
|
20
|
+
}
|
|
21
|
+
navigate(t, e = 0) {
|
|
22
|
+
let n = null, s = this.state.selectedItemIndex;
|
|
23
|
+
return t ? s === null ? n = e : s < this.getLastSelectionIndex() && (n = s + 1) : s === null ? n = 0 : s > 0 && (n = s - 1), n !== null && this.setState({ selectedItemIndex: n }), n;
|
|
24
|
+
}
|
|
25
|
+
get isKeyboardNavigationLeftRight() {
|
|
26
|
+
return !0;
|
|
27
|
+
}
|
|
28
|
+
getLastSelectionIndex() {
|
|
29
|
+
let t = -1;
|
|
30
|
+
if (this.props.group.type === "action-group") {
|
|
31
|
+
const e = this.props.group;
|
|
32
|
+
t = e.actions ? e.actions.length - 1 : -1;
|
|
33
|
+
} else if (this.props.group.type === "attachment-group") {
|
|
34
|
+
const e = this.props.group;
|
|
35
|
+
t = e.attachments ? e.attachments.length - 1 : -1;
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
a as SelectableItemsContainer
|
|
42
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),c=require("@progress/kendo-react-buttons"),n=require("@progress/kendo-react-common");function l(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const r in s)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}return e.default=s,Object.freeze(e)}const t=l(a);class o extends t.Component{constructor(){super(...arguments),this.onBtnClick=(e,r)=>{n.dispatchEvent(this.props.onActionExecute,r,this,{action:e})}}render(){return t.createElement("div",{className:"k-card"},t.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),t.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),t.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map((e,r)=>t.createElement("span",{className:"k-card-action",key:r},t.createElement(c.Button,{fillMode:"flat",onClick:i=>this.onBtnClick(e,i)},e.title)))}getTitleView(){let e=null;return this.props.title&&(e=t.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=t.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}exports.HeroCard=o;
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
*/
|
|
8
|
+
"use client";
|
|
9
|
+
import * as e from "react";
|
|
10
|
+
import { Button as r } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { dispatchEvent as a } from "@progress/kendo-react-common";
|
|
12
|
+
class o extends e.Component {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.onBtnClick = (t, i) => {
|
|
15
|
+
a(this.props.onActionExecute, i, this, { action: t });
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
render() {
|
|
22
|
+
return /* @__PURE__ */ e.createElement("div", { className: "k-card" }, /* @__PURE__ */ e.createElement(
|
|
23
|
+
"img",
|
|
24
|
+
{
|
|
25
|
+
className: "k-card-image",
|
|
26
|
+
src: this.props.imageUrl,
|
|
27
|
+
style: { maxWidth: this.props.imageMaxWidth }
|
|
28
|
+
}
|
|
29
|
+
), /* @__PURE__ */ e.createElement("div", { className: "k-card-body" }, this.getTitleView(), this.getSubtitleView()), /* @__PURE__ */ e.createElement("div", { className: "k-card-actions k-card-actions-vertical" }, this.getActionsView()));
|
|
30
|
+
}
|
|
31
|
+
getActionsView() {
|
|
32
|
+
return this.props.actions.map((t, i) => /* @__PURE__ */ e.createElement("span", { className: "k-card-action", key: i }, /* @__PURE__ */ e.createElement(r, { fillMode: "flat", onClick: (s) => this.onBtnClick(t, s) }, t.title)));
|
|
33
|
+
}
|
|
34
|
+
getTitleView() {
|
|
35
|
+
let t = null;
|
|
36
|
+
return this.props.title && (t = /* @__PURE__ */ e.createElement("h5", { className: "k-card-title" }, this.props.title)), t;
|
|
37
|
+
}
|
|
38
|
+
getSubtitleView() {
|
|
39
|
+
let t = null;
|
|
40
|
+
return this.props.subtitle && (t = /* @__PURE__ */ e.createElement("h6", { className: "k-card-subtitle" }, this.props.subtitle)), t;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
o as HeroCard
|
|
45
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(function(l,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-buttons"),require("@progress/kendo-react-layout"),require("@progress/kendo-react-inputs")):typeof define=="function"&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-intl","prop-types","@progress/kendo-svg-icons","@progress/kendo-react-buttons","@progress/kendo-react-layout","@progress/kendo-react-inputs"],i):(l=typeof globalThis!="undefined"?globalThis:l||self,i(l.KendoReactConversationalUi={},l.React,l.KendoReactCommon,l.KendoReactIntl,l.PropTypes,l.KendoSvgIcons,l.KendoReactButtons,l.KendoReactLayout,l.KendoReactInputs))})(this,function(l,i,p,E,h,m,u,d,ee){"use strict";"use client";function te(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const r=te(i);class V extends r.Component{componentDidUpdate(e){!e.selected&&this.props.selected&&this.elementToFocus.focus()}}class D extends V{render(){return r.createElement("div",{className:this.getClassNames(),tabIndex:this.props.tabIndex,onClick:()=>this.props.onRequestSelection(this.props.item.selectionIndex),onFocus:()=>this.props.onRequestSelection(this.props.item.selectionIndex),ref:e=>this.elementToFocus=e},this.getTimestampView(),this.getMainView(),this.getStatusView())}getMainView(){return this.props.item.typing?r.createElement("div",{className:"k-chat-bubble"},r.createElement("div",{className:"k-typing-indicator"},r.createElement("span",null),r.createElement("span",null),r.createElement("span",null))):this.props.template?r.createElement(this.props.template,{item:this.props.item}):this.props.item.text?r.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=r.createElement("time",{className:"k-message-time","aria-hidden":!this.props.selected},E.provideIntlService(this).formatDate(this.props.item.timestamp,this.props.dateFormat))),e}getStatusView(){let e=null;return this.props.item.status&&(e=r.createElement("span",{className:"k-message-status"},this.props.item.status)),e}getClassNames(){return p.classNames({"k-only":this.props.isOnlyItemInGroup},{"k-first":this.props.isFirstItemInGroup&&!this.props.isOnlyItemInGroup},{"k-last":this.props.isLastItemInGroup&&!this.props.isOnlyItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected},"k-message")}}D.defaultProps={dateFormat:"g",tabIndex:-1},E.registerForIntl(D);const H=(s,e)=>s&&e.author&&s.id===e.author.id,B=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)=>{const t=e.timestamp,n=B(s);if(t&&(!n||se(t,n.timestamp))){const o={type:"date-marker",timestamp:t,trackBy:t.getTime()};s.push(o)}},re=(s,e,t)=>{const n=B(s);let o;e.typing&&!t||(n&&n.type==="message-group"&&(o=n.messages),o&&H(e.author,B(o))?o.push(e):s.push({type:"message-group",messages:[e],author:e.author,timestamp:e.timestamp,trackBy:e}))},ie=s=>(e,t,n)=>{const o=n===s-1;return ne(e,t),re(e,t,o),t.attachments&&t.attachments.length>1&&e.push({type:"attachment-group",attachments:t.attachments,attachmentLayout:t.attachmentLayout,timestamp:t.timestamp,trackBy:t}),t.suggestedActions&&o&&e.push({type:"action-group",actions:t.suggestedActions,timestamp:t.timestamp,trackBy:t}),e};function oe(s){let e=0;s.forEach(t=>{t.type==="message-group"?t.messages.forEach(n=>{n.selectionIndex=e++}):(t.type==="attachment-group"||t.type==="action-group")&&(t.selectionIndex=e++)}),s.lastSelectionIndex=e-1}const ae=s=>{const t=s.slice().reduce(ie(s.length),[]);return oe(t),t};class le extends V{constructor(){super(...arguments),this.onKeyDown=e=>{e.keyCode===p.Keys.enter&&this.props.onActionExecute(this.props.item,e)}}render(){return r.createElement("span",{role:"button",className:this.getClassNames(),onClick:e=>this.props.onActionExecute(this.props.item,e),ref:e=>this.elementToFocus=e,onKeyDown:this.onKeyDown,tabIndex:0},this.props.item.title||this.props.item.value)}getClassNames(){return p.classNames("k-quick-reply",{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected})}}class j extends r.Component{constructor(){super(...arguments),this.state={selectedItemIndex:null},this.onRequestContainerSelection=()=>this.props.onRequestSelection(this.props.group.selectionIndex),this.onKeyDown=e=>{let t=null,n,o;this.isKeyboardNavigationLeftRight?(n=p.Keys.left,o=p.Keys.right):(n=p.Keys.up,o=p.Keys.down),e.keyCode===n?t=this.navigate(!1):e.keyCode===o&&(t=this.navigate(!0)),t!==null&&(e.preventDefault(),e.stopPropagation())}}static getDerivedStateFromProps(e,t){return!e.selected&&t.selectedItemIndex!==null?{selectedItemIndex:null}:e.selected&&t.selectedItemIndex===null?{selectedItemIndex:0}:null}navigate(e,t=0){let n=null,o=this.state.selectedItemIndex;return e?o===null?n=t:o<this.getLastSelectionIndex()&&(n=o+1):o===null?n=0:o>0&&(n=o-1),n!==null&&this.setState({selectedItemIndex:n}),n}get isKeyboardNavigationLeftRight(){return!0}getLastSelectionIndex(){let e=-1;if(this.props.group.type==="action-group"){const t=this.props.group;e=t.actions?t.actions.length-1:-1}else if(this.props.group.type==="attachment-group"){const t=this.props.group;e=t.attachments?t.attachments.length-1:-1}return e}}class ce extends j{constructor(e){super(e)}render(){const e=this.props.group.actions?this.props.group.actions.length-1:0;return r.createElement("div",{className:this.getClassNames(),onClick:this.onRequestContainerSelection,onKeyDown:this.onKeyDown},this.props.group.actions&&this.props.group.actions.map((t,n)=>r.createElement(le,{item:t,onActionExecute:this.props.onActionExecute,selected:n===this.state.selectedItemIndex,isFirstItemInGroup:n===0,isLastItemInGroup:n===e,key:n})))}getClassNames(){return p.classNames("k-quick-replies")}}class _ extends V{render(){return r.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:e=>this.elementToFocus=e},this.props.template?r.createElement(this.props.template,{item:this.props.item}):r.createElement("div",{className:"k-card"},r.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView(),this.getContentView())))}getTabIndexValue(){if(this.props.tabbable!==void 0)return this.props.tabbable?0:-1}getClassNames(){return p.classNames({"k-selected":this.props.selected},{"k-focus":this.props.selected},{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup})}getTitleView(){return this.props.item.title?r.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?r.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return this.props.item.contentType.indexOf("image/")===0?r.createElement("img",{src:this.props.item.content}):this.props.item.content}}class pe extends j{render(){const e=this.isCardDeckLayout(this.props),t=r.createElement("div",{className:this.getClassNames(),onKeyDown:e?void 0:this.onKeyDown},this.props.group.attachments.map((n,o)=>r.createElement(_,{item:n,template:this.props.itemTemplate,selected:o===this.state.selectedItemIndex,tabbable:this.props.isLastGroup&&o===this.state.selectedItemIndex,isFirstItemInGroup:o===0,isLastItemInGroup:o===this.getLastItemIndex(),onClick:()=>this.onAttachmentClick(o),key:o})));return e?r.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:this.onKeyDown},this.getLeftScrollBtn(),t,this.getRightScrollBtn()):t}get isKeyboardNavigationLeftRight(){return this.isCardDeckLayout(this.props)}getLastItemIndex(){return this.props.group.attachments.length-1}getLeftScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex&&(e=r.createElement(u.Button,{icon:"chevron-left",onClick:()=>this.onNavigateBtnClick(!1),svgIcon:m.chevronLeftIcon})),e}getRightScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex!==this.getLastItemIndex()&&(e=r.createElement(u.Button,{icon:"chevron-right",onClick:()=>this.onNavigateBtnClick(!0),svgIcon:m.chevronRightIcon})),e}onAttachmentClick(e){this.onRequestContainerSelection(),this.setState({selectedItemIndex:e})}onNavigateBtnClick(e){this.onRequestContainerSelection(),this.navigate(e,1)}isCardDeckLayout(e){return e.group.attachmentLayout!=="list"}getClassNames(){return p.classNames({"k-card-list":this.props.group.attachmentLayout,"k-card-deck":this.isCardDeckLayout(this.props)})}}class $ extends r.Component{render(){const e=this.props.item;return r.createElement("div",{className:"k-timestamp"},E.provideIntlService(this).formatDate(e.timestamp,"D"))}}E.registerForIntl($);const P="newMessage.sendButton",K="newMessage.optionsButton",F="newMessage.messageInput",q="avatar.alt",O="messageList.ariaLabel",G="aIPrompt.noOutputs",k={[P]:"Send",[K]:"Options",[F]:"Message",[q]:"Avatar",[O]:"Message list",[G]:"No output from AI available"};class me extends r.Component{render(){const{avatarUrl:e,avatarAltText:t,name:n}=this.props.group.author,o=E.provideLocalizationService(this);return r.createElement("div",{className:this.getMsgGroupClassNames()},n&&r.createElement("p",{className:"k-author"},n),e&&r.createElement(d.Avatar,{type:"image"},r.createElement("img",{src:e,alt:t!==void 0?t:o.toLanguageString(q,k[q])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return p.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":H(this.props.user,this.props.group.messages[0])})}getGroupMessagesView(){const e=this.props.group.messages.length-1;return this.props.group.messages.map((t,n)=>{const o=[r.createElement(this.props.message,{item:t,template:this.props.itemTemplate,selected:t.selectionIndex===this.props.selectedItemIndex,onRequestSelection:this.props.onRequestSelection,tabIndex:n===e&&this.props.isLastGroup?0:-1,isFirstItemInGroup:n===0,isLastItemInGroup:n===e,isOnlyItemInGroup:e===0,key:n})];return t.attachments&&t.attachments.length===1&&o.push(r.createElement(_,{item:t.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${n}`})),o})}}class ue extends r.Component{render(){return r.createElement("div",{className:"k-toolbar-box"},r.createElement("div",{className:"k-button-list"},this.props.children))}}class he extends r.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.onInputKeyDown=e=>{e.keyCode===p.Keys.enter&&this.sendMessage(e)},this.sendMessage=e=>{if(this.props.onMessageSend&&this.inputEl!==null){const t=this.inputEl.value;if(t){const n={author:this.props.user,text:t,timestamp:new Date};this.props.onMessageSend(n,e)}}this.inputEl!==null&&(this.inputEl.value=null)}}render(){const e=E.provideLocalizationService(this),t=r.createElement("input",{type:"text",className:this.getClassNames(),placeholder:this.props.placeholder,onKeyDown:this.onInputKeyDown,onFocus:()=>this.setState({focused:!0}),onBlur:()=>this.setState({focused:!1}),ref:c=>this.inputEl=c,"aria-label":e.toLanguageString(F,k[F])}),n=r.createElement(u.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:m.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(P,k[P]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),o=r.createElement(u.Button,{fillMode:"flat",themeColor:"base",rounded:null,className:"k-button-toggle",icon:"more-horizontal",svgIcon:m.moreHorizontalIcon,onClick:c=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,c),"aria-label":e.toLanguageString(K,k[K])});return r.createElement(r.Fragment,null,r.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?r.createElement(this.props.MessageBox,{messageInput:t,sendButton:n,toolbarButton:o}):r.createElement(r.Fragment,null,t,r.createElement("span",{className:"k-input-suffix"},this.props.toolbar&&o,n))),this.props.showToolbar&&r.createElement(ue,null,this.props.toolbar))}focusInput(){this.inputEl!==null&&this.inputEl.focus()}getClassNames(){return p.classNames("k-input-inner",{"k-focus":this.state.focused})}}const de={name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},Y=class extends r.Component{constructor(s){super(s),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.onFocus=()=>{clearTimeout(this.timeoutIdForChatLosingFocus)},this.onBlur=()=>{this.timeoutIdForChatLosingFocus=window.setTimeout(()=>{this.setState({selectedItemIndex:null})},0)},this.onSelectionRequested=e=>{this.setState({selectedItemIndex:e})},this.onKeyDown=e=>{let t=null,n=this.state.selectedItemIndex!==null?this.state.selectedItemIndex:this.viewItems.lastSelectionIndex;e.keyCode===p.Keys.up?n===null?t=0:n>0&&(t=n-1):e.keyCode===p.Keys.down&&(n===null?t=0:n<this.viewItems.lastSelectionIndex&&(t=n+1)),t!==null&&(this.setState({selectedItemIndex:t}),e.preventDefault())},this.onMessageSend=(e,t)=>{p.dispatchEvent(this.props.onMessageSend,t,this,{message:e})},this.onActionExecute=(e,t)=>{if(p.dispatchEvent(this.props.onActionExecute,t,this,{action:e}),!t.isDefaultPrevented()){switch(e.type){case"reply":this.onMessageSend({author:this.props.user,text:e.value,timestamp:new Date},t);break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value);break}this.newMsgComp.focusInput()}},p.validatePackage(de),this.state={selectedItemIndex:null,isFirstRender:!0}}render(){this.viewItems=this.getViewItemsFromMsgs(this.props.messages),this.isDirectionRightToLeft=this.checkIsDirectionRightToLeft(this.props);const s=E.provideLocalizationService(this);return r.createElement("div",{style:{width:this.props.width},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>this.chatWrapperEl=e},r.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":s.toLanguageString(O,k[O]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>this.viewItemsWrapperEl=e},r.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),r.createElement(he,{user:this.props.user,onMessageSend:this.onMessageSend,isDirectionRightToLeft:this.isDirectionRightToLeft,ref:e=>this.newMsgComp=e,placeholder:this.props.placeholder,MessageBox:this.props.messageBox,toolbar:this.props.toolbar,onToolbarActionButtonClick:this.props.onToolbarActionExecute,showToolbar:this.props.showToolbar}))}componentDidMount(){this.setState({isFirstRender:!1},()=>{this.nextTickId=window.setTimeout(()=>this.scrollViewItemsToBottom(),250)})}componentWillUnmount(){clearTimeout(this.nextTickId)}componentDidUpdate(s){s.messages.length!==this.props.messages.length&&this.scrollToBottomOnLoadingData&&this.scrollViewItemsToBottom()}getClassNames(){return p.classNames("k-chat",this.props.className,{"k-rtl":this.isDirectionRightToLeft})}checkIsDirectionRightToLeft(s){return!!(s.dir!==void 0?s.dir==="rtl":this.chatWrapperEl&&getComputedStyle(this.chatWrapperEl).direction==="rtl")}renderViewItems(){const s=this.viewItems.length-1;return this.viewItems.map((e,t)=>{if(e.type==="date-marker")return r.createElement($,{item:e,key:t});if(e.type==="message-group")return r.createElement(me,{group:e,itemTemplate:this.props.messageTemplate,attachmentTemplate:this.props.attachmentTemplate,user:this.props.user,selectedItemIndex:this.state.selectedItemIndex,onRequestSelection:this.onSelectionRequested,isLastGroup:t===s,key:t,message:this.props.message||Y.defaultProps.message});if(e.type==="attachment-group")return r.createElement(pe,{group:e,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:e.selectionIndex===this.state.selectedItemIndex,isLastGroup:t===s,key:t});if(e.type==="action-group")return r.createElement(ce,{group:e,onActionExecute:this.onActionExecute,onRequestSelection:this.onSelectionRequested,selected:e.selectionIndex===this.state.selectedItemIndex,isLastGroup:t===s,key:t})})}scrollViewItemsToBottom(){this.viewItemsWrapperEl&&(this.viewItemsWrapperEl.scrollTop=this.viewItemsWrapperEl.scrollHeight-this.viewItemsWrapperEl.clientHeight)}getViewItemsFromMsgs(s){return s.length>0?ae(s):[]}};let z=Y;z.propTypes={messages:h.arrayOf(h.object),user:h.object,messageTemplate:h.any,attachmentTemplate:h.any,width:h.oneOfType([h.string,h.number]),onMessageSend:h.func,onActionExecute:h.func,dir:h.string,messageBox:h.any},z.defaultProps={messages:[],dateFormat:"g",message:D};class ge extends r.Component{constructor(){super(...arguments),this.onBtnClick=(e,t)=>{p.dispatchEvent(this.props.onActionExecute,t,this,{action:e})}}render(){return r.createElement("div",{className:"k-card"},r.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),r.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),r.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map((e,t)=>r.createElement("span",{className:"k-card-action",key:t},r.createElement(u.Button,{fillMode:"flat",onClick:n=>this.onBtnClick(e,n)},e.title)))}getTitleView(){let e=null;return this.props.title&&(e=r.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=r.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}const J=s=>{const{activeView:e,toolbarItems:t,activeViewChange:n}=s,o=c=>{n==null||n.call(null,c)};return i.createElement("div",{className:"k-prompt-header"},i.createElement(u.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},t.map(c=>i.isValidElement(c)?c:i.createElement(u.Button,{key:c.name,className:e===c.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:c.buttonText,svgIcon:c.buttonIcon,"aria-hidden":"true",onClick:()=>o(c.name)},c.buttonText))))},x=i.forwardRef((s,e)=>{const{children:t}=s;return i.createElement("div",{className:"k-prompt-content",ref:e},i.createElement("div",{className:"k-prompt-view"},t))});x.displayName="KendoReactAIPromptContent";const Q=s=>{const{children:e}=s;return i.createElement("div",{className:"k-prompt-footer"},i.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},e))},X=i.createContext([{},()=>{}]),M=()=>i.useContext(X),A=s=>{const[e]=M();return e.activeView===s.name?s.children:null},Ie=s=>{const[e,t]=i.useState(!0),{children:n,title:o}=s;return i.createElement("div",{className:"k-prompt-expander"},i.createElement(u.Button,{fillMode:"flat",svgIcon:e?m.chevronUpIcon:m.chevronDownIcon,title:o,onClick:()=>t(!e)},o),e&&i.createElement("div",{className:"k-prompt-expander-content"},n))},U={name:"prompt-view",buttonText:"Ask AI",buttonIcon:m.sparklesIcon},fe=s=>{const e="Generate",{promptInput:t=ee.TextArea,generateButton:n=u.Button,promptValue:o,promptSuggestions:c}=s,[f,g]=i.useState(o||""),[I]=M(),[w,y]=p.useCustomComponent(n),[N,C]=p.useCustomComponent(t),T=()=>{I.onPromptRequest&&I.onPromptRequest.call(null,f),g("")},v=b=>{g(b)},L=b=>{g(b.target.value)},a={title:"Generate",svgIcon:m.sparklesIcon},S={placeholder:"Ask or generate content with AI ...",rows:2},be=Object.keys(y).length>0?y:a,ke=Object.keys(C).length>0?C:S;return i.createElement(A,{name:U.name},i.createElement(x,null,i.createElement(N,{value:f,onChange:L,...ke}),c&&c.length>0&&i.createElement(Ie,{title:"Prompt Suggestions"},c.map(b=>i.createElement("div",{key:b,className:"k-prompt-suggestion",onClick:()=>v(b)},b)))),i.createElement(Q,null,i.createElement(w,{themeColor:"primary",fillMode:"solid","aria-hidden":"true",rounded:"full",size:"medium",onClick:T,...be},e)))},W={name:"Output view",buttonText:"Output",buttonIcon:m.commentIcon},Ee=s=>{const[e,t]=i.useState(""),n=i.useRef(null),[o]=M(),{outputs:c,showOutputRating:f,outputCard:g}=s,{header:I,body:w,actions:y}=g||{},N=E.useLocalization(),C=a=>{o.onPromptRequest&&o.onPromptRequest.call(null,a.prompt,{...a,isRetry:!0}),L()},T=a=>{a!=null&&a.responseContent&&navigator.clipboard.writeText(a.responseContent),t(a.id),setTimeout(()=>{t("")},1e3)},v=(a,S)=>{o.onPromptRequest&&o.onPromptRequest.call(null,a.prompt,{...a,ratingType:S,isRetry:!1}),L()},L=()=>{n&&n.current&&n.current.scrollTo({top:0,behavior:"smooth"})};return i.createElement(A,{name:W.name},i.createElement(x,{ref:n},i.createElement("div",{className:"k-card-list"},c&&c.length>0?c.map((a,S)=>i.createElement(d.Card,{key:`${a.id}_${S}`},i.createElement(d.CardHeader,null,I?I(a):i.createElement(i.Fragment,null,a.title&&i.createElement(d.CardTitle,null,a.title),a.subTitle&&i.createElement(d.CardSubtitle,null,a.subTitle))),i.createElement(d.CardBody,null,w?w(a):a.responseContent),i.createElement(d.CardActions,null,y?y(a):i.createElement(i.Fragment,null,i.createElement(u.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:e===a.id?m.copyIcon:m.checkIcon,"aria-hidden":"true",onClick:()=>T(a)},"Copy"),i.createElement(u.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:m.rotateIcon,"aria-hidden":"true",onClick:()=>C(a)},"Retry"),f&&i.createElement(i.Fragment,null,i.createElement("span",{className:"k-spacer"}),i.createElement(u.Button,{size:"medium",themeColor:a.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:m.thumbUpOutlineIcon,"aria-hidden":"true",onClick:()=>v(a,"positive")}),i.createElement(u.Button,{size:"medium",themeColor:a.ratingType==="negative"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:m.thumbDownOutlineIcon,"aria-hidden":"true",onClick:()=>v(a,"negative")})))))):i.createElement(d.Card,null,i.createElement(d.CardBody,null,N.toLanguageString(G,k[G]))))))},ye=s=>{const{activeView:e,toolbarItems:t,children:n,onActiveViewChange:o,onPromptRequest:c,onCommandExecute:f,style:g,dir:I}=s,w=t||[U,W],[y,N]=i.useState({activeView:e}),C={...y,activeView:e,onActiveViewChange:o,onPromptRequest:c,onCommandExecute:f},T=v=>{N(v)};return i.createElement(X.Provider,{value:[C,T]},i.createElement("div",{className:"k-prompt",style:g,dir:I},i.createElement(J,{activeView:C.activeView,toolbarItems:w,activeViewChange:o}),n))},Z={name:"Commands view",buttonIcon:m.moreHorizontalIcon},R=s=>s==null?void 0:s.map(e=>i.createElement(d.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&R(e.children||[]))),Ce=s=>{const{commands:e}=s,[t]=M(),n=o=>{var f,g,I;const c=(g=(f=o.target)==null?void 0:f.props)==null?void 0:g.data;(I=c.children)!=null&&I.length||t.onCommandExecute&&t.onCommandExecute.call(null,c)};return i.createElement(A,{name:Z.name},i.createElement(x,null,i.createElement("div",{className:"k-prompt-view"},i.createElement(d.PanelBar,{onSelect:n,selected:""},R(e!=null?e:[])))))};l.AIPrompt=ye,l.AIPromptCommandsView=Ce,l.AIPromptContent=x,l.AIPromptFooter=Q,l.AIPromptOutputView=Ee,l.AIPromptView=fe,l.AIPromptViewRender=A,l.Chat=z,l.ChatMessage=D,l.HeroCard=ge,l.PromptHeader=J,l.commandsViewDefaults=Z,l.outputViewDefaults=W,l.promptViewDefaults=U,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
|
|
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
|
+
*/
|
|
8
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-buttons"),require("@progress/kendo-react-layout"),require("@progress/kendo-react-inputs")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-intl","prop-types","@progress/kendo-svg-icons","@progress/kendo-react-buttons","@progress/kendo-react-layout","@progress/kendo-react-inputs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactIntl,e.PropTypes,e.KendoSvgIcons,e.KendoReactButtons,e.KendoReactLayout,e.KendoReactInputs)}(this,(function(e,t,s,n,o,a,i,r,l){"use strict";function c(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var p=c(t);let m=class extends p.Component{componentDidUpdate(e){!e.selected&&this.props.selected&&this.elementToFocus.focus()}};const u=class extends m{render(){return p.createElement("div",{className:this.getClassNames(),tabIndex:this.props.tabIndex,onClick:()=>this.props.onRequestSelection(this.props.item.selectionIndex),onFocus:()=>this.props.onRequestSelection(this.props.item.selectionIndex),ref:e=>this.elementToFocus=e},this.getTimestampView(),this.getMainView(),this.getStatusView())}getMainView(){return this.props.item.typing?p.createElement("div",{className:"k-chat-bubble"},p.createElement("div",{className:"k-typing-indicator"},p.createElement("span",null),p.createElement("span",null),p.createElement("span",null))):this.props.template?p.createElement(this.props.template,{item:this.props.item}):this.props.item.text?p.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=p.createElement("time",{className:"k-message-time","aria-hidden":!this.props.selected},n.provideIntlService(this).formatDate(this.props.item.timestamp,this.props.dateFormat))),e}getStatusView(){let e=null;return this.props.item.status&&(e=p.createElement("span",{className:"k-message-status"},this.props.item.status)),e}getClassNames(){return s.classNames({"k-only":this.props.isOnlyItemInGroup},{"k-first":this.props.isFirstItemInGroup&&!this.props.isOnlyItemInGroup},{"k-last":this.props.isLastItemInGroup&&!this.props.isOnlyItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected},"k-message")}};u.defaultProps={dateFormat:"g",tabIndex:-1};let h=u;n.registerForIntl(h);const d=(e,t)=>e&&t.author&&e.id===t.author.id,g=e=>e[e.length-1],I=e=>(t,s,n)=>{const o=n===e-1;return((e,t)=>{const s=t.timestamp,n=g(e);if(s&&(!n||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(s,n.timestamp))){const t={type:"date-marker",timestamp:s,trackBy:s.getTime()};e.push(t)}})(t,s),((e,t,s)=>{const n=g(e);let o;t.typing&&!s||(n&&"message-group"===n.type&&(o=n.messages),o&&d(t.author,g(o))?o.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,s,o),s.attachments&&s.attachments.length>1&&t.push({type:"attachment-group",attachments:s.attachments,attachmentLayout:s.attachmentLayout,timestamp:s.timestamp,trackBy:s}),s.suggestedActions&&o&&t.push({type:"action-group",actions:s.suggestedActions,timestamp:s.timestamp,trackBy:s}),t};let k=class extends m{constructor(){super(...arguments),this.onKeyDown=e=>{e.keyCode===s.Keys.enter&&this.props.onActionExecute(this.props.item,e)}}render(){return p.createElement("span",{role:"button",className:this.getClassNames(),onClick:e=>this.props.onActionExecute(this.props.item,e),ref:e=>this.elementToFocus=e,onKeyDown:this.onKeyDown,tabIndex:0},this.props.item.title||this.props.item.value)}getClassNames(){return s.classNames("k-quick-reply",{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected})}},v=class extends p.Component{constructor(){super(...arguments),this.state={selectedItemIndex:null},this.onRequestContainerSelection=()=>this.props.onRequestSelection(this.props.group.selectionIndex),this.onKeyDown=e=>{let t,n,o=null;this.isKeyboardNavigationLeftRight?(t=s.Keys.left,n=s.Keys.right):(t=s.Keys.up,n=s.Keys.down),e.keyCode===t?o=this.navigate(!1):e.keyCode===n&&(o=this.navigate(!0)),null!==o&&(e.preventDefault(),e.stopPropagation())}}static getDerivedStateFromProps(e,t){return e.selected||null===t.selectedItemIndex?e.selected&&null===t.selectedItemIndex?{selectedItemIndex:0}:null:{selectedItemIndex:null}}navigate(e,t=0){let s=null,n=this.state.selectedItemIndex;return e?null===n?s=t:n<this.getLastSelectionIndex()&&(s=n+1):null===n?s=0:n>0&&(s=n-1),null!==s&&this.setState({selectedItemIndex:s}),s}get isKeyboardNavigationLeftRight(){return!0}getLastSelectionIndex(){let e=-1;if("action-group"===this.props.group.type){const t=this.props.group;e=t.actions?t.actions.length-1:-1}else if("attachment-group"===this.props.group.type){const t=this.props.group;e=t.attachments?t.attachments.length-1:-1}return e}};class E extends v{constructor(e){super(e)}render(){const e=this.props.group.actions?this.props.group.actions.length-1:0;return p.createElement("div",{className:this.getClassNames(),onClick:this.onRequestContainerSelection,onKeyDown:this.onKeyDown},this.props.group.actions&&this.props.group.actions.map(((t,s)=>p.createElement(k,{item:t,onActionExecute:this.props.onActionExecute,selected:s===this.state.selectedItemIndex,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,key:s}))))}getClassNames(){return s.classNames("k-quick-replies")}}class y extends m{render(){return p.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:e=>this.elementToFocus=e},this.props.template?p.createElement(this.props.template,{item:this.props.item}):p.createElement("div",{className:"k-card"},p.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView(),this.getContentView())))}getTabIndexValue(){if(void 0!==this.props.tabbable)return this.props.tabbable?0:-1}getClassNames(){return s.classNames({"k-selected":this.props.selected},{"k-focus":this.props.selected},{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup})}getTitleView(){return this.props.item.title?p.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?p.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return 0===this.props.item.contentType.indexOf("image/")?p.createElement("img",{src:this.props.item.content}):this.props.item.content}}class C extends v{render(){const e=this.isCardDeckLayout(this.props),t=p.createElement("div",{className:this.getClassNames(),onKeyDown:e?void 0:this.onKeyDown},this.props.group.attachments.map(((e,t)=>p.createElement(y,{item:e,template:this.props.itemTemplate,selected:t===this.state.selectedItemIndex,tabbable:this.props.isLastGroup&&t===this.state.selectedItemIndex,isFirstItemInGroup:0===t,isLastItemInGroup:t===this.getLastItemIndex(),onClick:()=>this.onAttachmentClick(t),key:t}))));return e?p.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:this.onKeyDown},this.getLeftScrollBtn(),t,this.getRightScrollBtn()):t}get isKeyboardNavigationLeftRight(){return this.isCardDeckLayout(this.props)}getLastItemIndex(){return this.props.group.attachments.length-1}getLeftScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex&&(e=p.createElement(i.Button,{icon:"chevron-left",onClick:()=>this.onNavigateBtnClick(!1),svgIcon:a.chevronLeftIcon})),e}getRightScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex!==this.getLastItemIndex()&&(e=p.createElement(i.Button,{icon:"chevron-right",onClick:()=>this.onNavigateBtnClick(!0),svgIcon:a.chevronRightIcon})),e}onAttachmentClick(e){this.onRequestContainerSelection(),this.setState({selectedItemIndex:e})}onNavigateBtnClick(e){this.onRequestContainerSelection(),this.navigate(e,1)}isCardDeckLayout(e){return"list"!==e.group.attachmentLayout}getClassNames(){return s.classNames({"k-card-list":this.props.group.attachmentLayout,"k-card-deck":this.isCardDeckLayout(this.props)})}}let f=class extends p.Component{render(){const e=this.props.item;return p.createElement("div",{className:"k-timestamp"},n.provideIntlService(this).formatDate(e.timestamp,"D"))}};n.registerForIntl(f);const w="newMessage.sendButton",x="newMessage.optionsButton",b="newMessage.messageInput",N="avatar.alt",T="messageList.ariaLabel",S="aIPrompt.noOutputs",R={[w]:"Send",[x]:"Options",[b]:"Message",[N]:"Avatar",[T]:"Message list",[S]:"No output from AI available"};class L extends p.Component{render(){const{avatarUrl:e,avatarAltText:t,name:s}=this.props.group.author,o=n.provideLocalizationService(this);return p.createElement("div",{className:this.getMsgGroupClassNames()},s&&p.createElement("p",{className:"k-author"},s),e&&p.createElement(r.Avatar,{type:"image"},p.createElement("img",{src:e,alt:void 0!==t?t:o.toLanguageString(N,R[N])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return s.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":d(this.props.user,this.props.group.messages[0])})}getGroupMessagesView(){const e=this.props.group.messages.length-1;return this.props.group.messages.map(((t,s)=>{const n=[p.createElement(this.props.message,{item:t,template:this.props.itemTemplate,selected:t.selectionIndex===this.props.selectedItemIndex,onRequestSelection:this.props.onRequestSelection,tabIndex:s===e&&this.props.isLastGroup?0:-1,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,isOnlyItemInGroup:0===e,key:s})];return t.attachments&&1===t.attachments.length&&n.push(p.createElement(y,{item:t.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${s}`})),n}))}}let D=class extends p.Component{render(){return p.createElement("div",{className:"k-toolbar-box"},p.createElement("div",{className:"k-button-list"},this.props.children))}};class B extends p.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.onInputKeyDown=e=>{e.keyCode===s.Keys.enter&&this.sendMessage(e)},this.sendMessage=e=>{if(this.props.onMessageSend&&null!==this.inputEl){const t=this.inputEl.value;if(t){const s={author:this.props.user,text:t,timestamp:new Date};this.props.onMessageSend(s,e)}}null!==this.inputEl&&(this.inputEl.value=null)}}render(){const e=n.provideLocalizationService(this),t=p.createElement("input",{type:"text",className:this.getClassNames(),placeholder:this.props.placeholder,onKeyDown:this.onInputKeyDown,onFocus:()=>this.setState({focused:!0}),onBlur:()=>this.setState({focused:!1}),ref:e=>this.inputEl=e,"aria-label":e.toLanguageString(b,R[b])}),s=p.createElement(i.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:a.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(w,R[w]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),o=p.createElement(i.Button,{fillMode:"flat",themeColor:"base",rounded:null,className:"k-button-toggle",icon:"more-horizontal",svgIcon:a.moreHorizontalIcon,onClick:e=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,e),"aria-label":e.toLanguageString(x,R[x])});return p.createElement(p.Fragment,null,p.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?p.createElement(this.props.MessageBox,{messageInput:t,sendButton:s,toolbarButton:o}):p.createElement(p.Fragment,null,t,p.createElement("span",{className:"k-input-suffix"},this.props.toolbar&&o,s))),this.props.showToolbar&&p.createElement(D,null,this.props.toolbar))}focusInput(){null!==this.inputEl&&this.inputEl.focus()}getClassNames(){return s.classNames("k-input-inner",{"k-focus":this.state.focused})}}const V={name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCodes:["KENDOUIREACT","KENDOUICOMPLETE"],publishDate:0,version:"",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},M=class e extends p.Component{constructor(e){super(e),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.onFocus=()=>{clearTimeout(this.timeoutIdForChatLosingFocus)},this.onBlur=()=>{this.timeoutIdForChatLosingFocus=window.setTimeout((()=>{this.setState({selectedItemIndex:null})}),0)},this.onSelectionRequested=e=>{this.setState({selectedItemIndex:e})},this.onKeyDown=e=>{let t=null,n=null!==this.state.selectedItemIndex?this.state.selectedItemIndex:this.viewItems.lastSelectionIndex;e.keyCode===s.Keys.up?null===n?t=0:n>0&&(t=n-1):e.keyCode===s.Keys.down&&(null===n?t=0:n<this.viewItems.lastSelectionIndex&&(t=n+1)),null!==t&&(this.setState({selectedItemIndex:t}),e.preventDefault())},this.onMessageSend=(e,t)=>{s.dispatchEvent(this.props.onMessageSend,t,this,{message:e})},this.onActionExecute=(e,t)=>{if(s.dispatchEvent(this.props.onActionExecute,t,this,{action:e}),!t.isDefaultPrevented()){switch(e.type){case"reply":this.onMessageSend({author:this.props.user,text:e.value,timestamp:new Date},t);break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value)}this.newMsgComp.focusInput()}},s.validatePackage(V),this.state={selectedItemIndex:null,isFirstRender:!0}}render(){this.viewItems=this.getViewItemsFromMsgs(this.props.messages),this.isDirectionRightToLeft=this.checkIsDirectionRightToLeft(this.props);const e=n.provideLocalizationService(this);return p.createElement("div",{style:{width:this.props.width},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>this.chatWrapperEl=e},p.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":e.toLanguageString(T,R[T]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>this.viewItemsWrapperEl=e},p.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),p.createElement(B,{user:this.props.user,onMessageSend:this.onMessageSend,isDirectionRightToLeft:this.isDirectionRightToLeft,ref:e=>this.newMsgComp=e,placeholder:this.props.placeholder,MessageBox:this.props.messageBox,toolbar:this.props.toolbar,onToolbarActionButtonClick:this.props.onToolbarActionExecute,showToolbar:this.props.showToolbar}))}componentDidMount(){this.setState({isFirstRender:!1},(()=>{this.nextTickId=window.setTimeout((()=>this.scrollViewItemsToBottom()),250)}))}componentWillUnmount(){clearTimeout(this.nextTickId)}componentDidUpdate(e){e.messages.length!==this.props.messages.length&&this.scrollToBottomOnLoadingData&&this.scrollViewItemsToBottom()}getClassNames(){return s.classNames("k-chat",this.props.className,{"k-rtl":this.isDirectionRightToLeft})}checkIsDirectionRightToLeft(e){return!!(void 0!==e.dir?"rtl"===e.dir:this.chatWrapperEl&&"rtl"===getComputedStyle(this.chatWrapperEl).direction)}renderViewItems(){const t=this.viewItems.length-1;return this.viewItems.map(((s,n)=>"date-marker"===s.type?p.createElement(f,{item:s,key:n}):"message-group"===s.type?p.createElement(L,{group:s,itemTemplate:this.props.messageTemplate,attachmentTemplate:this.props.attachmentTemplate,user:this.props.user,selectedItemIndex:this.state.selectedItemIndex,onRequestSelection:this.onSelectionRequested,isLastGroup:n===t,key:n,message:this.props.message||e.defaultProps.message}):"attachment-group"===s.type?p.createElement(C,{group:s,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):"action-group"===s.type?p.createElement(E,{group:s,onActionExecute:this.onActionExecute,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):void 0))}scrollViewItemsToBottom(){this.viewItemsWrapperEl&&(this.viewItemsWrapperEl.scrollTop=this.viewItemsWrapperEl.scrollHeight-this.viewItemsWrapperEl.clientHeight)}getViewItemsFromMsgs(e){return e.length>0?(e=>{const t=e.slice().reduce(I(e.length),[]);return function(e){let t=0;e.forEach((e=>{"message-group"===e.type?e.messages.forEach((e=>{e.selectionIndex=t++})):("attachment-group"===e.type||"action-group"===e.type)&&(e.selectionIndex=t++)})),e.lastSelectionIndex=t-1}(t),t})(e):[]}};M.propTypes={messages:o.arrayOf(o.object),user:o.object,messageTemplate:o.any,attachmentTemplate:o.any,width:o.oneOfType([o.string,o.number]),onMessageSend:o.func,onActionExecute:o.func,dir:o.string,messageBox:o.any},M.defaultProps={messages:[],dateFormat:"g",message:h};let A=M;class K extends p.Component{constructor(){super(...arguments),this.onBtnClick=(e,t)=>{s.dispatchEvent(this.props.onActionExecute,t,this,{action:e})}}render(){return p.createElement("div",{className:"k-card"},p.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),p.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),p.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map(((e,t)=>p.createElement("span",{className:"k-card-action",key:t},p.createElement(i.Button,{fillMode:"flat",onClick:t=>this.onBtnClick(e,t)},e.title))))}getTitleView(){let e=null;return this.props.title&&(e=p.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=p.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}const F=e=>{const{activeView:s,toolbarItems:n,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(i.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map((e=>t.isValidElement(e)?e:t.createElement(i.Button,{key:e.name,className:s===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,"aria-hidden":"true",onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText)))))},q=t.forwardRef(((e,s)=>{const{children:n}=e;return t.createElement("div",{className:"k-prompt-content",ref:s},t.createElement("div",{className:"k-prompt-view"},n))}));q.displayName="KendoReactAIPromptContent";const P=e=>{const{children:s}=e;return t.createElement("div",{className:"k-prompt-footer"},t.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},s))},O=t.createContext([{},()=>{}]),G=()=>t.useContext(O),z=e=>{const[t]=G();return t.activeView===e.name?e.children:null},U=e=>{const[s,n]=t.useState(!0),{children:o,title:r}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(i.Button,{fillMode:"flat",svgIcon:s?a.chevronUpIcon:a.chevronDownIcon,title:r,onClick:()=>n(!s)},r),s&&t.createElement("div",{className:"k-prompt-expander-content"},o))},W={name:"prompt-view",buttonText:"Ask AI",buttonIcon:a.sparklesIcon},j={name:"Output view",buttonText:"Output",buttonIcon:a.commentIcon},H={name:"Commands view",buttonIcon:a.moreHorizontalIcon},$=e=>null==e?void 0:e.map((e=>t.createElement(r.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&$(e.children||[]))));e.AIPrompt=e=>{const{activeView:s,toolbarItems:n,children:o,onActiveViewChange:a,onPromptRequest:i,onCommandExecute:r,style:l,dir:c}=e,p=n||[W,j],[m,u]=t.useState({activeView:s}),h={...m,activeView:s,onActiveViewChange:a,onPromptRequest:i,onCommandExecute:r};return t.createElement(O.Provider,{value:[h,e=>{u(e)}]},t.createElement("div",{className:"k-prompt",style:l,dir:c},t.createElement(F,{activeView:h.activeView,toolbarItems:p,activeViewChange:a}),o))},e.AIPromptCommandsView=e=>{const{commands:s}=e,[n]=G();return t.createElement(z,{name:H.name},t.createElement(q,null,t.createElement("div",{className:"k-prompt-view"},t.createElement(r.PanelBar,{onSelect:e=>{var t,s,o;const a=null==(s=null==(t=e.target)?void 0:t.props)?void 0:s.data;null!=(o=a.children)&&o.length||n.onCommandExecute&&n.onCommandExecute.call(null,a)},selected:""},$(null!=s?s:[])))))},e.AIPromptContent=q,e.AIPromptFooter=P,e.AIPromptOutputView=e=>{const[s,o]=t.useState(""),l=t.useRef(null),[c]=G(),{outputs:p,showOutputRating:m,outputCard:u}=e,{header:h,body:d,actions:g}=u||{},I=n.useLocalization(),k=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),v()},v=()=>{l&&l.current&&l.current.scrollTo({top:0,behavior:"smooth"})};return t.createElement(z,{name:j.name},t.createElement(q,{ref:l},t.createElement("div",{className:"k-card-list"},p&&p.length>0?p.map(((e,n)=>t.createElement(r.Card,{key:`${e.id}_${n}`},t.createElement(r.CardHeader,null,h?h(e):t.createElement(t.Fragment,null,e.title&&t.createElement(r.CardTitle,null,e.title),e.subTitle&&t.createElement(r.CardSubtitle,null,e.subTitle))),t.createElement(r.CardBody,null,d?d(e):e.responseContent),t.createElement(r.CardActions,null,g?g(e):t.createElement(t.Fragment,null,t.createElement(i.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:s===e.id?a.copyIcon:a.checkIcon,"aria-hidden":"true",onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),o(e.id),setTimeout((()=>{o("")}),1e3)})(e)},"Copy"),t.createElement(i.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:a.rotateIcon,"aria-hidden":"true",onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),v()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(i.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:a.thumbUpOutlineIcon,"aria-hidden":"true",onClick:()=>k(e,"positive")}),t.createElement(i.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:a.thumbDownOutlineIcon,"aria-hidden":"true",onClick:()=>k(e,"negative")}))))))):t.createElement(r.Card,null,t.createElement(r.CardBody,null,I.toLanguageString(S,R[S]))))))},e.AIPromptView=e=>{const{promptInput:n=l.TextArea,generateButton:o=i.Button,promptValue:r,promptSuggestions:c}=e,[p,m]=t.useState(r||""),[u]=G(),[h,d]=s.useCustomComponent(o),[g,I]=s.useCustomComponent(n),k={title:"Generate",svgIcon:a.sparklesIcon},v=Object.keys(d).length>0?d:k,E=Object.keys(I).length>0?I:{placeholder:"Ask or generate content with AI ...",rows:2};return t.createElement(z,{name:W.name},t.createElement(q,null,t.createElement(g,{value:p,onChange:e=>{m(e.target.value)},...E}),c&&c.length>0&&t.createElement(U,{title:"Prompt Suggestions"},c.map((e=>t.createElement("div",{key:e,className:"k-prompt-suggestion",onClick:()=>(e=>{m(e)})(e)},e))))),t.createElement(P,null,t.createElement(h,{themeColor:"primary",fillMode:"solid","aria-hidden":"true",rounded:"full",size:"medium",onClick:()=>{u.onPromptRequest&&u.onPromptRequest.call(null,p),m("")},...v},"Generate")))},e.AIPromptViewRender=z,e.Chat=A,e.ChatMessage=h,e.HeroCard=K,e.PromptHeader=F,e.commandsViewDefaults=H,e.outputViewDefaults=j,e.promptViewDefaults=W}));
|